Skip to content
Permalink
Browse files
[JSC] Introduce unlinked StructureStubInfo into uDFG
https://bugs.webkit.org/show_bug.cgi?id=240557

Reviewed by Saam Barati.

This patch introduces unlinked StructureStubInfo into uDFG. To make it work, we refactor existing StructureStubInfo mechanism
to make unlinked StructureStubInfo first citizen instead of adhoc code.

1. JITXXXGenerator takes CompileTimeStructureStubInfo as its argument. It is variant of unlinked / linked StructureStubInfo. And we configure
   registers etc. in one place. JITXXXGenerator sets necessary fields for each type of StructureStubInfo so we have massive less code in
   Baseline and uDFG.
2. DFG::JITCompiler::LinkableConstant takes DFG::JITCompiler instead of DFG::Graph to make code simpler.
3. Introduce DFG::LinkerIR, which is currently just a constant pool. We will eventually extend it to support many uDFG LinkerIR opcodes.
4. Clean up some of unused registers in some JITXXXGenerator to make code simpler.
5. Rename useDataICInOptimizingJIT to useDataICInFTL and use it only for FTL. That flag was used to keep maintaining DataIC in DFG / FTL,
   and in uDFG case, we already have forceUnlinkedDFG flag.

* Tools/Scripts/run-jsc-stress-tests:
* JSTests/microbenchmarks/deltablue-varargs.js:
* JSTests/microbenchmarks/richards-try-catch.js:
* Source/JavaScriptCore/bytecode/AccessCase.cpp:
(JSC::AccessCase::generateWithGuard):
(JSC::AccessCase::generateImpl):
* Source/JavaScriptCore/bytecode/CodeBlock.cpp:
(JSC::CodeBlock::setupWithUnlinkedBaselineCode):
(JSC::CodeBlock::~CodeBlock):
(JSC::CodeBlock::propagateTransitions):
(JSC::CodeBlock::finalizeJITInlineCaches):
(JSC::CodeBlock::getICStatusMap):
(JSC::CodeBlock::findStubInfo):
(JSC::CodeBlock::stronglyVisitStrongReferences):
(JSC::CodeBlock::findPC):
(JSC::CodeBlock::useDataIC const):
* Source/JavaScriptCore/bytecode/CodeBlock.h:
(JSC::CodeBlock::useDataIC const): Deleted.
* Source/JavaScriptCore/bytecode/InlineAccess.cpp:
(JSC::InlineAccess::generateSelfPropertyAccess):
(JSC::getScratchRegister):
(JSC::InlineAccess::generateSelfPropertyReplace):
(JSC::InlineAccess::generateArrayLength):
(JSC::InlineAccess::generateStringLength):
(JSC::InlineAccess::generateSelfInAccess):
* Source/JavaScriptCore/bytecode/PolymorphicAccess.cpp:
(JSC::AccessGenerationState::makeDefaultScratchAllocator):
(JSC::PolymorphicAccess::regenerate):
* Source/JavaScriptCore/bytecode/PolymorphicAccess.h:
(JSC::AccessGenerationState::AccessGenerationState):
* Source/JavaScriptCore/bytecode/StructureStubInfo.cpp:
(JSC::slowOperationFromUnlinkedStructureStubInfo):
(JSC::StructureStubInfo::initializeFromUnlinkedStructureStubInfo):
(JSC::StructureStubInfo::initializeFromDFGUnlinkedStructureStubInfo):
(JSC::StructureStubInfo::checkConsistency):
* Source/JavaScriptCore/bytecode/StructureStubInfo.h:
(JSC::StructureStubInfo::StructureStubInfo):
(JSC::StructureStubInfo::valueRegs const):
(JSC::StructureStubInfo::propertyRegs const):
(JSC::StructureStubInfo::baseRegs const):
(JSC::StructureStubInfo::thisValueIsInExtraGPR const):
(JSC::StructureStubInfo::thisGPR const):
(JSC::StructureStubInfo::prototypeGPR const):
(JSC::StructureStubInfo::propertyGPR const):
(JSC::StructureStubInfo::brandGPR const):
(JSC::StructureStubInfo::thisValueIsInThisGPR const): Deleted.
* Source/JavaScriptCore/dfg/DFGInlineCacheWrapperInlines.h:
(JSC::DFG::InlineCacheWrapper<GeneratorType>::finalize):
* Source/JavaScriptCore/dfg/DFGJITCode.cpp:
(JSC::DFG::JITData::JITData):
* Source/JavaScriptCore/dfg/DFGJITCode.h:
(JSC::DFG::LinkerIR::ValueHash::hash):
(JSC::DFG::LinkerIR::ValueHash::equal):
(JSC::DFG::LinkerIR::ValueTraits::emptyValue):
(JSC::DFG::LinkerIR::ValueTraits::constructDeletedValue):
(JSC::DFG::LinkerIR::ValueTraits::isDeletedValue):
(JSC::DFG::LinkerIR::LinkerIR):
(JSC::DFG::LinkerIR::size const):
(JSC::DFG::LinkerIR::at const):
(JSC::DFG::JITData::create):
* Source/JavaScriptCore/dfg/DFGJITCompiler.cpp:
(JSC::DFG::JITCompiler::link):
(JSC::DFG::JITCompiler::loadConstant):
(JSC::DFG::JITCompiler::LinkableConstant::LinkableConstant):
(JSC::DFG::JITCompiler::addToConstantPool):
(JSC::DFG::JITCompiler::addStructureStubInfo):
* Source/JavaScriptCore/dfg/DFGJITCompiler.h:
* Source/JavaScriptCore/dfg/DFGPlan.cpp:
(JSC::DFG::Plan::finalizeJITData):
(JSC::DFG::Plan::addLinkableConstant): Deleted.
* Source/JavaScriptCore/dfg/DFGPlan.h:
* Source/JavaScriptCore/dfg/DFGSlowPathGenerator.h:
(JSC::DFG::slowPathICCall):
* Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp:
(JSC::DFG::SpeculativeJIT::emitGetCallee):
(JSC::DFG::SpeculativeJIT::silentFill):
(JSC::DFG::SpeculativeJIT::compileGetById):
(JSC::DFG::SpeculativeJIT::compileGetByIdFlush):
(JSC::DFG::SpeculativeJIT::compileDeleteById):
(JSC::DFG::SpeculativeJIT::compileDeleteByVal):
(JSC::DFG::SpeculativeJIT::compileInById):
(JSC::DFG::SpeculativeJIT::compileInByVal):
(JSC::DFG::SpeculativeJIT::compileHasPrivate):
(JSC::DFG::SpeculativeJIT::compilePushWithScope):
(JSC::DFG::SpeculativeJIT::compileStringSlice):
(JSC::DFG::SpeculativeJIT::compileToLowerCase):
(JSC::DFG::SpeculativeJIT::compileCheckTraps):
(JSC::DFG::SpeculativeJIT::compileContiguousPutByVal):
(JSC::DFG::SpeculativeJIT::compileDoublePutByVal):
(JSC::DFG::SpeculativeJIT::compilePutByVal):
(JSC::DFG::SpeculativeJIT::compileGetByValOnString):
(JSC::DFG::SpeculativeJIT::compileFromCharCode):
(JSC::DFG::SpeculativeJIT::compilePutByValForIntTypedArray):
* Source/JavaScriptCore/dfg/DFGSpeculativeJIT.h:
* Source/JavaScriptCore/dfg/DFGSpeculativeJIT32_64.cpp:
(JSC::DFG::SpeculativeJIT::cachedGetById):
(JSC::DFG::SpeculativeJIT::cachedGetByIdWithThis):
(JSC::DFG::SpeculativeJIT::nonSpeculativeNonPeepholeCompareNullOrUndefined):
(JSC::DFG::SpeculativeJIT::nonSpeculativePeepholeBranchNullOrUndefined):
(JSC::DFG::SpeculativeJIT::nonSpeculativePeepholeStrictEq):
(JSC::DFG::SpeculativeJIT::genericJSValueNonPeepholeStrictEq):
(JSC::DFG::SpeculativeJIT::emitCall):
(JSC::DFG::SpeculativeJIT::compileToBooleanObjectOrOther):
(JSC::DFG::SpeculativeJIT::emitObjectOrOtherBranch):
(JSC::DFG::SpeculativeJIT::compileGetByVal):
(JSC::DFG::SpeculativeJIT::compile):
(JSC::DFG::SpeculativeJIT::compileArithRandom):
* Source/JavaScriptCore/dfg/DFGSpeculativeJIT64.cpp:
(JSC::DFG::SpeculativeJIT::cachedGetById):
(JSC::DFG::SpeculativeJIT::cachedGetByIdWithThis):
(JSC::DFG::SpeculativeJIT::nonSpeculativeNonPeepholeCompareNullOrUndefined):
(JSC::DFG::SpeculativeJIT::nonSpeculativePeepholeBranchNullOrUndefined):
(JSC::DFG::SpeculativeJIT::nonSpeculativePeepholeStrictEq):
(JSC::DFG::SpeculativeJIT::genericJSValueNonPeepholeStrictEq):
(JSC::DFG::SpeculativeJIT::emitCall):
(JSC::DFG::SpeculativeJIT::compileCompareEqPtr):
(JSC::DFG::SpeculativeJIT::compileToBooleanObjectOrOther):
(JSC::DFG::SpeculativeJIT::emitObjectOrOtherBranch):
(JSC::DFG::SpeculativeJIT::emitUntypedBranch):
(JSC::DFG::SpeculativeJIT::compileGetByVal):
(JSC::DFG::SpeculativeJIT::compileRegExpTestInline):
(JSC::DFG::SpeculativeJIT::compile):
* Source/JavaScriptCore/dfg/DFGStrengthReductionPhase.cpp:
(JSC::DFG::StrengthReductionPhase::handleNode):
* Source/JavaScriptCore/ftl/FTLLowerDFGToB3.cpp:
(JSC::FTL::DFG::LowerDFGToB3::getPrivateName):
(JSC::FTL::DFG::LowerDFGToB3::compilePrivateBrandAccess):
(JSC::FTL::DFG::LowerDFGToB3::compilePutPrivateName):
(JSC::FTL::DFG::LowerDFGToB3::cachedPutById):
(JSC::FTL::DFG::LowerDFGToB3::compileGetByValImpl):
(JSC::FTL::DFG::LowerDFGToB3::compilePutByVal):
(JSC::FTL::DFG::LowerDFGToB3::compileDelBy):
(JSC::FTL::DFG::LowerDFGToB3::compileCompareStrictEq):
* Source/JavaScriptCore/ftl/FTLState.cpp:
(JSC::FTL::State::addStructureStubInfo):
* Source/JavaScriptCore/ftl/FTLState.h:
* Source/JavaScriptCore/jit/BaselineJITCode.h:
* Source/JavaScriptCore/jit/BaselineJITRegisters.h:
* Source/JavaScriptCore/jit/GPRInfo.h:
(JSC::JSValueRegs::gpr const):
(JSC::JSValueRegs::JSValueRegs):
(JSC::JSValueRegs::withTwoAvailableRegs):
* Source/JavaScriptCore/jit/IntrinsicEmitter.cpp:
(JSC::IntrinsicGetterAccessCase::canEmitIntrinsicGetter):
* Source/JavaScriptCore/jit/JIT.cpp:
(JSC::JIT::addUnlinkedStructureStubInfo):
(JSC::JIT::link):
* Source/JavaScriptCore/jit/JIT.h:
* Source/JavaScriptCore/jit/JITCall.cpp:
(JSC::JIT::emit_op_iterator_open):
(JSC::JIT::emit_op_iterator_next):
* Source/JavaScriptCore/jit/JITCode.h:
(JSC::JITCode::useDataIC): Deleted.
* Source/JavaScriptCore/jit/JITInlineCacheGenerator.cpp:
(JSC::JITInlineCacheGenerator::JITInlineCacheGenerator):
(JSC::JITInlineCacheGenerator::finalize):
(JSC::JITInlineCacheGenerator::generateDFGDataICFastPath):
(JSC::JITInlineCacheGenerator::generateBaselineDataICFastPath):
(JSC::JITByIdGenerator::JITByIdGenerator):
(JSC::JITByIdGenerator::finalize):
(JSC::JITByIdGenerator::generateFastCommon):
(JSC::JITGetByIdGenerator::JITGetByIdGenerator):
(JSC::JITGetByIdGenerator::generateFastPath):
(JSC::JITGetByIdGenerator::generateBaselineDataICFastPath):
(JSC::JITGetByIdGenerator::generateDFGDataICFastPath):
(JSC::JITGetByIdWithThisGenerator::JITGetByIdWithThisGenerator):
(JSC::JITGetByIdWithThisGenerator::generateFastPath):
(JSC::JITGetByIdWithThisGenerator::generateBaselineDataICFastPath):
(JSC::JITGetByIdWithThisGenerator::generateDFGDataICFastPath):
(JSC::JITPutByIdGenerator::JITPutByIdGenerator):
(JSC::JITPutByIdGenerator::generateBaselineDataICFastPath):
(JSC::JITPutByIdGenerator::generateDFGDataICFastPath):
(JSC::JITPutByIdGenerator::generateFastPath):
(JSC::JITDelByValGenerator::JITDelByValGenerator):
(JSC::JITDelByValGenerator::generateFastPath):
(JSC::JITDelByValGenerator::finalize):
(JSC::JITDelByIdGenerator::JITDelByIdGenerator):
(JSC::JITDelByIdGenerator::generateFastPath):
(JSC::JITDelByIdGenerator::finalize):
(JSC::JITInByValGenerator::JITInByValGenerator):
(JSC::JITInByValGenerator::generateFastPath):
(JSC::JITInByValGenerator::finalize):
(JSC::JITInByIdGenerator::JITInByIdGenerator):
(JSC::JITInByIdGenerator::generateFastPath):
(JSC::JITInByIdGenerator::generateBaselineDataICFastPath):
(JSC::JITInByIdGenerator::generateDFGDataICFastPath):
(JSC::JITInstanceOfGenerator::JITInstanceOfGenerator):
(JSC::JITInstanceOfGenerator::generateFastPath):
(JSC::JITInstanceOfGenerator::finalize):
(JSC::JITGetByValGenerator::JITGetByValGenerator):
(JSC::JITGetByValGenerator::generateFastPath):
(JSC::JITGetByValGenerator::finalize):
(JSC::JITPutByValGenerator::JITPutByValGenerator):
(JSC::JITPutByValGenerator::generateFastPath):
(JSC::JITPutByValGenerator::finalize):
(JSC::JITPrivateBrandAccessGenerator::JITPrivateBrandAccessGenerator):
(JSC::JITPrivateBrandAccessGenerator::generateFastPath):
(JSC::JITPrivateBrandAccessGenerator::finalize):
* Source/JavaScriptCore/jit/JITInlineCacheGenerator.h:
(JSC::JITInlineCacheGenerator::setUpStubInfoImpl):
(JSC::JITByIdGenerator::setUpStubInfoImpl):
(JSC::JITInByValGenerator::setUpStubInfo):
* Source/JavaScriptCore/jit/JITOpcodes.cpp:
(JSC::JIT::emit_op_instanceof):
* Source/JavaScriptCore/jit/JITPropertyAccess.cpp:
(JSC::JIT::emit_op_get_by_val):
(JSC::JIT::emit_op_get_private_name):
(JSC::JIT::emit_op_set_private_brand):
(JSC::JIT::emit_op_check_private_brand):
(JSC::JIT::emit_op_put_by_val):
(JSC::JIT::emit_op_put_private_name):
(JSC::JIT::emit_op_del_by_id):
(JSC::JIT::emit_op_del_by_val):
(JSC::JIT::emit_op_try_get_by_id):
(JSC::JIT::emit_op_get_by_id_direct):
(JSC::JIT::emit_op_get_by_id):
(JSC::JIT::emit_op_get_by_id_with_this):
(JSC::JIT::emit_op_put_by_id):
(JSC::JIT::emit_op_in_by_id):
(JSC::JIT::emit_op_in_by_val):
(JSC::JIT::emitHasPrivate):
(JSC::JIT::emit_op_enumerator_get_by_val):
* Source/JavaScriptCore/runtime/OptionsList.h:
* Source/WTF/wtf/CompactPointerTuple.h:

Canonical link: https://commits.webkit.org/251003@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@294873 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
Constellation committed May 26, 2022
1 parent bfdd867 commit a49f3389c861ec6e0279a4863091139fcd2a0c52
Showing 41 changed files with 1,778 additions and 1,384 deletions.
@@ -1,5 +1,5 @@
//@ skip if $model == "Apple Watch Series 3" # added by mark-jsc-stress-test.py
//@ requireOptions("--useDataICInOptimizingJIT=true", "--useDataICSharing=true")
//@ requireOptions("--useDataICInFTL=true", "--useDataICSharing=true")

// Copyright 2008 the V8 project authors. All rights reserved.
// Copyright 1996 John Maloney and Mario Wolczko.
@@ -1,5 +1,5 @@
//@ skip if $model == "Apple Watch Series 3" # added by mark-jsc-stress-test.py
//@ requireOptions("--useDataICInOptimizingJIT=true", "--useDataICSharing=true")
//@ requireOptions("--useDataICInFTL=true", "--useDataICSharing=true")

// Copyright 2006-2008 the V8 project authors. All rights reserved.
// Redistribution and use in source and binary forms, with or without
@@ -955,7 +955,7 @@ void AccessCase::generateWithGuard(

if (requiresIdentifierNameMatch() && !stubInfo.hasConstantIdentifier) {
RELEASE_ASSERT(m_identifier);
GPRReg propertyGPR = state.u.propertyGPR;
GPRReg propertyGPR = state.propertyGPR();
// non-rope string check done inside polymorphic access.

if (uid()->isSymbol())
@@ -1094,7 +1094,7 @@ void AccessCase::generateWithGuard(
case IndexedScopedArgumentsLoad: {
ASSERT(!viaProxy());
// This code is written such that the result could alias with the base or the property.
GPRReg propertyGPR = state.u.propertyGPR;
GPRReg propertyGPR = state.propertyGPR();

jit.load8(CCallHelpers::Address(baseGPR, JSCell::typeInfoTypeOffset()), scratchGPR);
fallThrough.append(jit.branch32(CCallHelpers::NotEqual, scratchGPR, CCallHelpers::TrustedImm32(ScopedArgumentsType)));
@@ -1156,7 +1156,7 @@ void AccessCase::generateWithGuard(
case IndexedDirectArgumentsLoad: {
ASSERT(!viaProxy());
// This code is written such that the result could alias with the base or the property.
GPRReg propertyGPR = state.u.propertyGPR;
GPRReg propertyGPR = state.propertyGPR();
jit.load8(CCallHelpers::Address(baseGPR, JSCell::typeInfoTypeOffset()), scratchGPR);
fallThrough.append(jit.branch32(CCallHelpers::NotEqual, scratchGPR, CCallHelpers::TrustedImm32(DirectArgumentsType)));

@@ -1183,7 +1183,7 @@ void AccessCase::generateWithGuard(

TypedArrayType type = toTypedArrayType(m_type);

GPRReg propertyGPR = state.u.propertyGPR;
GPRReg propertyGPR = state.propertyGPR();

jit.load8(CCallHelpers::Address(baseGPR, JSCell::typeInfoTypeOffset()), scratchGPR);
fallThrough.append(jit.branch32(CCallHelpers::NotEqual, scratchGPR, CCallHelpers::TrustedImm32(typeForTypedArrayType(type))));
@@ -1276,7 +1276,7 @@ void AccessCase::generateWithGuard(
case IndexedStringLoad: {
ASSERT(!viaProxy());
// This code is written such that the result could alias with the base or the property.
GPRReg propertyGPR = state.u.propertyGPR;
GPRReg propertyGPR = state.propertyGPR();

fallThrough.append(jit.branchIfNotString(baseGPR));

@@ -1328,7 +1328,7 @@ void AccessCase::generateWithGuard(
case IndexedArrayStorageLoad: {
ASSERT(!viaProxy());
// This code is written such that the result could alias with the base or the property.
GPRReg propertyGPR = state.u.propertyGPR;
GPRReg propertyGPR = state.propertyGPR();

// int32 check done in polymorphic access.
jit.load8(CCallHelpers::Address(baseGPR, JSCell::indexingTypeAndMiscOffset()), scratchGPR);
@@ -1427,7 +1427,7 @@ void AccessCase::generateWithGuard(
case IndexedContiguousStore:
case IndexedArrayStorageStore: {
ASSERT(!viaProxy());
GPRReg propertyGPR = state.u.propertyGPR;
GPRReg propertyGPR = state.propertyGPR();

// int32 check done in polymorphic access.
jit.load8(CCallHelpers::Address(baseGPR, JSCell::indexingTypeAndMiscOffset()), scratchGPR);
@@ -1581,7 +1581,7 @@ void AccessCase::generateWithGuard(

TypedArrayType type = toTypedArrayType(m_type);

GPRReg propertyGPR = state.u.propertyGPR;
GPRReg propertyGPR = state.propertyGPR();

jit.load8(CCallHelpers::Address(baseGPR, JSCell::typeInfoTypeOffset()), scratchGPR);
fallThrough.append(jit.branch32(CCallHelpers::NotEqual, scratchGPR, CCallHelpers::TrustedImm32(typeForTypedArrayType(type))));
@@ -1686,13 +1686,13 @@ void AccessCase::generateWithGuard(

fallThrough.append(
jit.branchPtr(
CCallHelpers::NotEqual, state.u.prototypeGPR,
CCallHelpers::NotEqual, state.prototypeGPR(),
CCallHelpers::TrustedImmPtr(as<InstanceOfAccessCase>().prototype())));
break;

case InstanceOfGeneric: {
ASSERT(!viaProxy());
GPRReg prototypeGPR = state.u.prototypeGPR;
GPRReg prototypeGPR = state.prototypeGPR();
// Legend: value = `base instanceof prototypeGPR`.

GPRReg valueGPR = valueRegs.payloadGPR();
@@ -1789,7 +1789,7 @@ void AccessCase::generateImpl(AccessGenerationState& state)
StructureStubInfo& stubInfo = *state.stubInfo;
JSValueRegs valueRegs = state.valueRegs;
GPRReg baseGPR = state.baseGPR;
GPRReg thisGPR = stubInfo.thisValueIsInThisGPR() ? state.u.thisGPR : baseGPR;
GPRReg thisGPR = stubInfo.thisValueIsInExtraGPR() ? state.thisGPR() : baseGPR;
GPRReg scratchGPR = state.scratchGPR;

for (const ObjectPropertyCondition& condition : m_conditionSet) {
@@ -790,9 +790,9 @@ void CodeBlock::setupWithUnlinkedBaselineCode(Ref<BaselineJITCode> jitCode)
break;
case JITConstantPool::Type::StructureStubInfo: {
unsigned index = bitwise_cast<uintptr_t>(entry.pointer());
UnlinkedStructureStubInfo& unlinkedStubInfo = jitCode->m_unlinkedStubInfos[index];
BaselineUnlinkedStructureStubInfo& unlinkedStubInfo = jitCode->m_unlinkedStubInfos[index];
StructureStubInfo& stubInfo = baselineJITData->m_stubInfos[index];
stubInfo.initializeFromUnlinkedStructureStubInfo(this, unlinkedStubInfo);
stubInfo.initializeFromUnlinkedStructureStubInfo(unlinkedStubInfo);
baselineJITData->at(i) = &stubInfo;
break;
}
@@ -893,24 +893,19 @@ CodeBlock::~CodeBlock()
// destructors.

#if ENABLE(JIT)
auto handleStubInfo = [&](StructureStubInfo& stubInfo) {
forEachStructureStubInfo([&](StructureStubInfo& stubInfo) {
stubInfo.aboutToDie();
stubInfo.deref();
};

return IterationStatus::Continue;
});
if (JITCode::isOptimizingJIT(jitType())) {
#if ENABLE(DFG_JIT)
for (auto* stubInfo : jitCode()->dfgCommon()->m_stubInfos)
handleStubInfo(*stubInfo);
if (m_jitData)
delete bitwise_cast<DFG::JITData*>(m_jitData);
if (auto* jitData = dfgJITData())
delete jitData;
#endif
} else {
if (auto* jitData = baselineJITData()) {
for (auto& stubInfo : jitData->m_stubInfos)
handleStubInfo(stubInfo);
if (auto* jitData = baselineJITData())
delete jitData;
}
}
#endif // ENABLE(JIT)
}
@@ -1037,6 +1032,33 @@ size_t CodeBlock::estimatedSize(JSCell* cell, VM& vm)
return Base::estimatedSize(cell, vm) + extraMemoryAllocated;
}

template<typename Func>
inline void CodeBlock::forEachStructureStubInfo(Func func)
{
UNUSED_PARAM(func);
#if ENABLE(JIT)
if (JITCode::isOptimizingJIT(jitType())) {
#if ENABLE(DFG_JIT)
for (auto* stubInfo : jitCode()->dfgCommon()->m_stubInfos) {
if (func(*stubInfo) == IterationStatus::Done)
return;
}
if (auto* jitData = dfgJITData()) {
for (auto& stubInfo : jitData->stubInfos())
if (func(stubInfo) == IterationStatus::Done)
return;
}
#endif
} else {
if (auto* jitData = baselineJITData()) {
for (auto& stubInfo : jitData->m_stubInfos)
if (func(stubInfo) == IterationStatus::Done)
return;
}
}
#endif // ENABLE(JIT)
}

template<typename Visitor>
void CodeBlock::visitChildrenImpl(JSCell* cell, Visitor& visitor)
{
@@ -1239,21 +1261,10 @@ void CodeBlock::propagateTransitions(const ConcurrentJSLocker&, Visitor& visitor
}

#if ENABLE(JIT)
auto handleStubInfo = [&](StructureStubInfo& stubInfo) {
forEachStructureStubInfo([&](StructureStubInfo& stubInfo) {
stubInfo.propagateTransitions(visitor);
};

if (JITCode::isOptimizingJIT(jitType())) {
#if ENABLE(DFG_JIT)
for (auto* stubInfo : jitCode()->dfgCommon()->m_stubInfos)
handleStubInfo(*stubInfo);
#endif
} else {
if (auto* jitData = baselineJITData()) {
for (auto& stubInfo : jitData->m_stubInfos)
handleStubInfo(stubInfo);
}
}
return IterationStatus::Continue;
});
#endif // ENABLE(JIT)

#if ENABLE(DFG_JIT)
@@ -1579,25 +1590,18 @@ void CodeBlock::finalizeLLIntInlineCaches()
#if ENABLE(JIT)
void CodeBlock::finalizeJITInlineCaches()
{
auto handleStubInfo = [&](StructureStubInfo& stubInfo) {
ConcurrentJSLockerBase locker(NoLockingNecessary);
stubInfo.visitWeakReferences(locker, this);
};

if (JITCode::isOptimizingJIT(jitType())) {
#if ENABLE(DFG_JIT)
DFG::CommonData* dfgCommon = m_jitCode->dfgCommon();
for (auto* callLinkInfo : dfgCommon->m_callLinkInfos)
if (JITCode::isOptimizingJIT(jitType())) {
for (auto* callLinkInfo : m_jitCode->dfgCommon()->m_callLinkInfos)
callLinkInfo->visitWeak(vm());
for (auto* stubInfo : dfgCommon->m_stubInfos)
handleStubInfo(*stubInfo);
#endif
} else {
if (auto* jitData = baselineJITData()) {
for (auto& stubInfo : jitData->m_stubInfos)
handleStubInfo(stubInfo);
}
}
#endif

forEachStructureStubInfo([&](StructureStubInfo& stubInfo) {
ConcurrentJSLockerBase locker(NoLockingNecessary);
stubInfo.visitWeakReferences(locker, this);
return IterationStatus::Continue;
});
}
#endif

@@ -1684,11 +1688,13 @@ void CodeBlock::getICStatusMap(const ConcurrentJSLocker&, ICStatusMap& result)
}
#if ENABLE(JIT)
if (JITCode::isJIT(jitType())) {
forEachStructureStubInfo([&](StructureStubInfo& stubInfo) {
result.add(stubInfo.codeOrigin, ICStatus()).iterator->value.stubInfo = &stubInfo;
return IterationStatus::Continue;
});
if (JITCode::isOptimizingJIT(jitType())) {
#if ENABLE(DFG_JIT)
DFG::CommonData* dfgCommon = m_jitCode->dfgCommon();
for (auto* stubInfo : dfgCommon->m_stubInfos)
result.add(stubInfo->codeOrigin, ICStatus()).iterator->value.stubInfo = stubInfo;
for (auto* callLinkInfo : dfgCommon->m_callLinkInfos)
result.add(callLinkInfo->codeOrigin(), ICStatus()).iterator->value.callLinkInfo = callLinkInfo;
for (auto& pair : dfgCommon->recordedStatuses.calls)
@@ -1702,11 +1708,6 @@ void CodeBlock::getICStatusMap(const ConcurrentJSLocker&, ICStatusMap& result)
for (auto& pair : dfgCommon->recordedStatuses.deletes)
result.add(pair.first, ICStatus()).iterator->value.deleteStatus = pair.second.get();
#endif
} else {
if (auto* jitData = baselineJITData()) {
for (auto& stubInfo : jitData->m_stubInfos)
result.add(stubInfo.codeOrigin, ICStatus()).iterator->value.stubInfo = &stubInfo;
}
}
}
#else
@@ -1724,22 +1725,15 @@ void CodeBlock::getICStatusMap(ICStatusMap& result)
StructureStubInfo* CodeBlock::findStubInfo(CodeOrigin codeOrigin)
{
ConcurrentJSLocker locker(m_lock);
if (JITCode::isOptimizingJIT(jitType())) {
#if ENABLE(DFG_JIT)
for (auto* stubInfo : jitCode()->dfgCommon()->m_stubInfos) {
if (stubInfo->codeOrigin == codeOrigin)
return stubInfo;
StructureStubInfo* result = nullptr;
forEachStructureStubInfo([&](StructureStubInfo& stubInfo) {
if (stubInfo.codeOrigin == codeOrigin) {
result = &stubInfo;
return IterationStatus::Done;
}
#endif
} else {
if (auto* jitData = baselineJITData()) {
for (auto& stubInfo : jitData->m_stubInfos) {
if (stubInfo.codeOrigin == codeOrigin)
return &stubInfo;
}
}
}
return nullptr;
return IterationStatus::Continue;
});
return result;
}

CallLinkInfo* CodeBlock::getCallLinkInfoForBytecodeIndex(const ConcurrentJSLocker&, BytecodeIndex index)
@@ -1844,23 +1838,16 @@ void CodeBlock::stronglyVisitStrongReferences(const ConcurrentJSLocker& locker,
});

#if ENABLE(JIT)
auto handleStubInfo = [&](StructureStubInfo& stubInfo) {
forEachStructureStubInfo([&](StructureStubInfo& stubInfo) {
stubInfo.visitAggregate(visitor);
};

return IterationStatus::Continue;
});
if (JITCode::isOptimizingJIT(jitType())) {
#if ENABLE(DFG_JIT)
DFG::CommonData* dfgCommon = m_jitCode->dfgCommon();
for (auto* stubInfo : dfgCommon->m_stubInfos)
handleStubInfo(*stubInfo);
dfgCommon->recordedStatuses.visitAggregate(visitor);
visitOSRExitTargets(locker, visitor);
#endif
} else {
if (auto* jitData = baselineJITData()) {
for (auto& stubInfo : jitData->m_stubInfos)
handleStubInfo(stubInfo);
}
}
#endif
}
@@ -3431,22 +3418,16 @@ std::optional<CodeOrigin> CodeBlock::findPC(void* pc)

{
ConcurrentJSLocker locker(m_lock);
if (JITCode::isOptimizingJIT(jitType())) {
#if ENABLE(DFG_JIT)
DFG::CommonData* dfgCommon = m_jitCode->dfgCommon();
for (auto* stubInfo : dfgCommon->m_stubInfos) {
if (stubInfo->containsPC(pc))
return stubInfo->codeOrigin;
}
#endif
} else {
if (auto* jitData = baselineJITData()) {
for (auto& stubInfo : jitData->m_stubInfos) {
if (stubInfo.containsPC(pc))
return stubInfo.codeOrigin;
}
std::optional<CodeOrigin> result;
forEachStructureStubInfo([&](StructureStubInfo& stubInfo) {
if (stubInfo.containsPC(pc)) {
result = stubInfo.codeOrigin;
return IterationStatus::Done;
}
}
return IterationStatus::Continue;
});
if (result)
return result;
}

return m_jitCode->findPC(this, pc);
@@ -3482,6 +3463,21 @@ void CodeBlock::jitNextInvocation()
m_unlinkedCode->llintExecuteCounter().setNewThreshold(0, this);
}

bool CodeBlock::useDataIC() const
{
#if ENABLE(DFG_JIT)
if (jitType() == JITType::DFGJIT) {
if (auto* jitCode = m_jitCode.get())
return static_cast<const DFG::JITCode*>(jitCode)->isUnlinked();
}
#endif
#if ENABLE(FTL_JIT)
if (jitType() == JITType::FTLJIT)
return Options::useDataICInFTL();
#endif
return true;
}

bool CodeBlock::hasInstalledVMTrapsBreakpoints() const
{
#if ENABLE(SIGNAL_BASED_VM_TRAPS)

0 comments on commit a49f338

Please sign in to comment.