Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 23 additions & 23 deletions Source/JavaScriptCore/bytecode/CodeBlock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2126,7 +2126,6 @@ CodeBlock* CodeBlock::newReplacement()
return ownerExecutable()->newReplacementCodeBlockFor(specializationKind());
}

#if ENABLE(JIT)
CodeBlock* CodeBlock::replacement()
{
const ClassInfo* classInfo = this->classInfo();
Expand All @@ -2147,6 +2146,7 @@ CodeBlock* CodeBlock::replacement()
return nullptr;
}

#if ENABLE(JIT)
DFG::CapabilityLevel CodeBlock::computeCapabilityLevel()
{
const ClassInfo* classInfo = this->classInfo();
Expand Down Expand Up @@ -2254,10 +2254,9 @@ void CodeBlock::jettison(Profiler::JettisonReason reason, ReoptimizationMode mod
}
}
}

if (DFG::shouldDumpDisassembly())
dataLog(" Did invalidate ", *this, "\n");

// Count the reoptimization if that's what the user wanted.
if (mode == CountReoptimization) {
// FIXME: Maybe this should call alternative().
Expand All @@ -2266,32 +2265,33 @@ void CodeBlock::jettison(Profiler::JettisonReason reason, ReoptimizationMode mod
if (DFG::shouldDumpDisassembly())
dataLog(" Did count reoptimization for ", *this, "\n");
}

if (this != replacement()) {
// This means that we were never the entrypoint. This can happen for OSR entry code
// blocks.
return;
}

if (alternative())
alternative()->optimizeAfterWarmUp();

if (reason != Profiler::JettisonDueToOldAge && reason != Profiler::JettisonDueToVMTraps)
tallyFrequentExitSites();
#endif // ENABLE(DFG_JIT)

// Jettison can happen during GC. We don't want to install code to a dead executable
// because that would add a dead object to the remembered set.
if (vm.heap.currentThreadIsDoingGCWork() && !vm.heap.isMarked(ownerExecutable()))
return;
// If this is not true, then this means that we were never the entrypoint. This can happen for OSR entry code blocks.
if (this == replacement()) {
#if ENABLE(DFG_JIT)
if (alternative())
alternative()->optimizeAfterWarmUp();

// This accomplishes (2).
ownerExecutable()->installCode(vm, alternative(), codeType(), specializationKind(), reason);
if (reason != Profiler::JettisonDueToOldAge && reason != Profiler::JettisonDueToVMTraps)
tallyFrequentExitSites();
#endif // ENABLE(DFG_JIT)

// Jettison can happen during GC. We don't want to install code to a dead executable
// because that would add a dead object to the remembered set.
if (!vm.heap.currentThreadIsDoingGCWork() || vm.heap.isMarked(ownerExecutable())) {
// This accomplishes (2).
ownerExecutable()->installCode(vm, alternative(), codeType(), specializationKind(), reason);
#if ENABLE(DFG_JIT)
if (DFG::shouldDumpDisassembly())
dataLog(" Did install baseline version of ", *this, "\n");
if (DFG::shouldDumpDisassembly())
dataLog(" Did install baseline version of ", *this, "\n");
#endif // ENABLE(DFG_JIT)
}
}

// Regardless of whether it is used or replaced or upgraded already or not, since this is already jettisoned,
// there is no reason to keep it linked. Unlink incoming calls.
unlinkIncomingCalls();
}

JSGlobalObject* CodeBlock::globalObjectFor(CodeOrigin codeOrigin)
Expand Down
7 changes: 3 additions & 4 deletions Source/JavaScriptCore/bytecode/CodeBlock.h
Original file line number Diff line number Diff line change
Expand Up @@ -319,8 +319,9 @@ class CodeBlock : public JSCell {

// Exactly equivalent to codeBlock->ownerExecutable()->newReplacementCodeBlockFor(codeBlock->specializationKind())
CodeBlock* newReplacement();

void setJITCode(Ref<JITCode>&& code)
CodeBlock* replacement();

void setJITCode(Ref<JSC::JITCode>&& code)
{
if (!code->isShared())
heap()->reportExtraMemoryAllocated(code->size());
Expand All @@ -347,8 +348,6 @@ class CodeBlock : public JSCell {
bool useDataIC() const;

#if ENABLE(JIT)
CodeBlock* replacement();

DFG::CapabilityLevel computeCapabilityLevel();
DFG::CapabilityLevel capabilityLevel();
DFG::CapabilityLevel capabilityLevelState() { return static_cast<DFG::CapabilityLevel>(m_capabilityLevelState); }
Expand Down