#pragma once
#if ENABLE(DFG_JIT)
#include "CodeBlockJettisoningWatchpoint.h"
#include "DFGAdaptiveInferredPropertyValueWatchpoint.h"
#include "DFGAdaptiveStructureWatchpoint.h"
#include "DFGJumpReplacement.h"
#include "DFGOSREntry.h"
#include "InlineCallFrameSet.h"
#include "JSCell.h"
#include "ProfilerCompilation.h"
#include <wtf/Bag.h>
#include <wtf/Noncopyable.h>
namespace JSC {
class CodeBlock;
class Identifier;
class TrackedReferences;
namespace DFG {
struct Node;
struct Plan;
struct WeakReferenceTransition {
WeakReferenceTransition() { }
WeakReferenceTransition(VM& vm, JSCell* owner, JSCell* codeOrigin, JSCell* from, JSCell* to)
: m_from(vm, owner, from)
, m_to(vm, owner, to)
{
if (!!codeOrigin)
m_codeOrigin.set(vm, owner, codeOrigin);
}
WriteBarrier<JSCell> m_codeOrigin;
WriteBarrier<JSCell> m_from;
WriteBarrier<JSCell> m_to;
};
class CommonData {
WTF_MAKE_NONCOPYABLE(CommonData);
public:
CommonData()
: isStillValid(true)
, frameRegisterCount(std::numeric_limits<unsigned>::max())
, requiredRegisterCountForExit(std::numeric_limits<unsigned>::max())
{ }
~CommonData();
void notifyCompilingStructureTransition(Plan&, CodeBlock*, Node*);
CallSiteIndex addCodeOrigin(CodeOrigin);
CallSiteIndex addUniqueCallSiteIndex(CodeOrigin);
CallSiteIndex lastCallSite() const;
void removeCallSiteIndex(CallSiteIndex);
void shrinkToFit();
bool invalidate(); bool hasInstalledVMTrapsBreakpoints() const { return isStillValid && hasVMTrapsBreakpointsInstalled; }
void installVMTrapBreakpoints(CodeBlock* owner);
bool isVMTrapBreakpoint(void* address);
CatchEntrypointData* catchOSREntryDataForBytecodeIndex(unsigned bytecodeIndex)
{
return tryBinarySearch<CatchEntrypointData, unsigned>(
catchEntrypoints, catchEntrypoints.size(), bytecodeIndex,
[] (const CatchEntrypointData* item) { return item->bytecodeIndex; });
}
void appendCatchEntrypoint(unsigned bytecodeIndex, void* machineCode, Vector<FlushFormat>&& argumentFormats)
{
catchEntrypoints.append(CatchEntrypointData { machineCode, WTFMove(argumentFormats), bytecodeIndex });
}
void finalizeCatchEntrypoints();
unsigned requiredRegisterCountForExecutionAndExit() const
{
return std::max(frameRegisterCount, requiredRegisterCountForExit);
}
void validateReferences(const TrackedReferences&);
static ptrdiff_t frameRegisterCountOffset() { return OBJECT_OFFSETOF(CommonData, frameRegisterCount); }
RefPtr<InlineCallFrameSet> inlineCallFrames;
Vector<CodeOrigin, 0, UnsafeVectorOverflow> codeOrigins;
Vector<Identifier> dfgIdentifiers;
Vector<WeakReferenceTransition> transitions;
Vector<WriteBarrier<JSCell>> weakReferences;
Vector<WriteBarrier<Structure>> weakStructureReferences;
Vector<CatchEntrypointData> catchEntrypoints;
Bag<CodeBlockJettisoningWatchpoint> watchpoints;
Bag<AdaptiveStructureWatchpoint> adaptiveStructureWatchpoints;
Bag<AdaptiveInferredPropertyValueWatchpoint> adaptiveInferredPropertyValueWatchpoints;
Vector<JumpReplacement> jumpReplacements;
ScratchBuffer* catchOSREntryBuffer;
RefPtr<Profiler::Compilation> compilation;
bool livenessHasBeenProved; bool allTransitionsHaveBeenMarked; bool isStillValid;
bool hasVMTrapsBreakpointsInstalled { false };
#if USE(JSVALUE32_64)
std::unique_ptr<Bag<double>> doubleConstants;
#endif
unsigned frameRegisterCount;
unsigned requiredRegisterCountForExit;
private:
HashSet<unsigned, WTF::IntHash<unsigned>, WTF::UnsignedWithZeroKeyHashTraits<unsigned>> callSiteIndexFreeList;
};
CodeBlock* codeBlockForVMTrapPC(void* pc);
} }
#endif // ENABLE(DFG_JIT)