#pragma once
#include "CompilationResult.h"
#include "DFGCompilationKey.h"
#include "DFGCompilationMode.h"
#include "DFGDesiredIdentifiers.h"
#include "DFGDesiredTransitions.h"
#include "DFGDesiredWatchpoints.h"
#include "DFGDesiredWeakReferences.h"
#include "DFGFinalizer.h"
#include "DeferredCompilationCallback.h"
#include "Operands.h"
#include "ProfilerCompilation.h"
#include <wtf/HashMap.h>
#include <wtf/ThreadSafeRefCounted.h>
namespace JSC {
class CodeBlock;
class SlotVisitor;
namespace DFG {
class ThreadData;
#if ENABLE(DFG_JIT)
struct Plan : public ThreadSafeRefCounted<Plan> {
Plan(
CodeBlock* codeBlockToCompile, CodeBlock* profiledDFGCodeBlock,
CompilationMode, unsigned osrEntryBytecodeIndex,
const Operands<JSValue>& mustHandleValues);
~Plan();
void compileInThread(ThreadData*);
CompilationResult finalizeWithoutNotifyingCallback();
void finalizeAndNotifyCallback();
void notifyCompiling();
void notifyReady();
CompilationKey key();
void markCodeBlocks(SlotVisitor&);
template<typename Func>
void iterateCodeBlocksForGC(const Func&);
void checkLivenessAndVisitChildren(SlotVisitor&);
bool isKnownToBeLiveDuringGC();
void cancel();
bool canTierUpAndOSREnter() const { return !tierUpAndOSREnterBytecodes.isEmpty(); }
void cleanMustHandleValuesIfNecessary();
VM* vm;
CodeBlock* codeBlock;
CodeBlock* profiledDFGCodeBlock;
CompilationMode mode;
const unsigned osrEntryBytecodeIndex;
Operands<JSValue> mustHandleValues;
bool mustHandleValuesMayIncludeGarbage { true };
Lock mustHandleValueCleaningLock;
ThreadData* threadData;
RefPtr<Profiler::Compilation> compilation;
std::unique_ptr<Finalizer> finalizer;
RefPtr<InlineCallFrameSet> inlineCallFrames;
DesiredWatchpoints watchpoints;
DesiredIdentifiers identifiers;
DesiredWeakReferences weakReferences;
DesiredTransitions transitions;
bool willTryToTierUp { false };
HashMap<unsigned, Vector<unsigned>> tierUpInLoopHierarchy;
Vector<unsigned> tierUpAndOSREnterBytecodes;
enum Stage { Preparing, Compiling, Ready, Cancelled };
Stage stage;
RefPtr<DeferredCompilationCallback> callback;
private:
bool computeCompileTimes() const;
bool reportCompileTimes() const;
enum CompilationPath { FailPath, DFGPath, FTLPath, CancelPath };
CompilationPath compileInThreadImpl();
bool isStillValid();
void reallyAdd(CommonData*);
double m_timeBeforeFTL;
};
#endif // ENABLE(DFG_JIT)
} }