Skip to content

Commit 0a2b068

Browse files
committed
[JSC] Initialize IPInt regardless
https://bugs.webkit.org/show_bug.cgi?id=297699 rdar://158813183 Reviewed by Yijia Huang. IPInt is acting as a part of validation of wasm. So regardless of whether IPInt is disabled, we are already compiling IPInt metadata. This is necessary since BBQ will rely on IPInt metadata. We will enable IPInt initialization etc. regardless of IPInt is used. When useWasmIPInt is false, then we immediately tier up to BBQ. But still we should compile and have IPInt metadata and IPInt callee. This will also remove WasmToWasm call's callee patchpoints in BBQ and OMG since we will always emit IPIntCallee pointers and callee will store their own pointer to the stack slot. * Source/JavaScriptCore/llint/LLIntData.cpp: (JSC::LLInt::initialize): * Source/JavaScriptCore/wasm/WasmBBQJIT.cpp: (JSC::Wasm::BBQJITImpl::BBQJIT::makeStackMap): * Source/JavaScriptCore/wasm/WasmOMGIRGenerator.cpp: (JSC::Wasm::OMGIRGenerator::addLoop): * Source/JavaScriptCore/wasm/WasmOMGIRGenerator32_64.cpp: (JSC::Wasm::OMGIRGenerator::addLoop): * Source/JavaScriptCore/wasm/WasmOMGPlan.cpp: (JSC::Wasm::OMGPlan::work): * Source/JavaScriptCore/wasm/js/JSWebAssemblyInstance.cpp: (JSC::JSWebAssemblyInstance::finalizeCreation): Canonical link: https://commits.webkit.org/298990@main
1 parent 88be774 commit 0a2b068

6 files changed

Lines changed: 28 additions & 50 deletions

File tree

‎Source/JavaScriptCore/llint/LLIntData.cpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ void initialize()
126126
llint_entry(opcodeMap, opcodeMapWide16, opcodeMapWide32);
127127

128128
#if ENABLE(WEBASSEMBLY)
129-
if (Options::useWasmIPInt())
129+
if (Options::useWasm())
130130
IPInt::initialize();
131131
#endif
132132

@@ -157,7 +157,7 @@ void initialize()
157157
#endif
158158

159159
#if ENABLE(WEBASSEMBLY)
160-
if (Options::useWasmIPInt())
160+
if (Options::useWasm())
161161
IPInt::verifyInitialization();
162162
#endif
163163

‎Source/JavaScriptCore/wasm/WasmBBQJIT.cpp‎

Lines changed: 19 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -3263,58 +3263,37 @@ B3::ValueRep BBQJIT::toB3Rep(Location location)
32633263
StackMap BBQJIT::makeStackMap(const ControlData& data, Stack& enclosingStack)
32643264
{
32653265
unsigned numElements = m_locals.size() + data.enclosedHeight() + data.argumentLocations().size();
3266-
if (Options::useWasmIPInt()) {
3267-
for (const ControlEntry& entry : m_parser->controlStack()) {
3268-
if (BBQJIT::ControlData::isTry(entry.controlData))
3269-
++numElements;
3270-
}
3266+
for (const ControlEntry& entry : m_parser->controlStack()) {
3267+
if (BBQJIT::ControlData::isTry(entry.controlData))
3268+
++numElements;
32713269
}
32723270

32733271
StackMap stackMap(numElements);
32743272
unsigned stackMapIndex = 0;
32753273
for (unsigned i = 0; i < m_locals.size(); i ++)
32763274
stackMap[stackMapIndex ++] = OSREntryValue(toB3Rep(m_locals[i]), toB3Type(m_localTypes[i]));
32773275

3278-
if (Options::useWasmIPInt()) {
3279-
// Do rethrow slots first because IPInt has them in a shadow stack.
3280-
for (const ControlEntry& entry : m_parser->controlStack()) {
3281-
unsigned numSlots = entry.controlData.implicitSlots();
3282-
if (BBQJIT::ControlData::isTry(entry.controlData))
3283-
++numSlots;
3284-
for (unsigned i = 0; i < numSlots; i ++) {
3285-
Value exception = this->exception(entry.controlData);
3286-
stackMap[stackMapIndex ++] = OSREntryValue(toB3Rep(locationOf(exception)), B3::Int64); // Exceptions are EncodedJSValues, so they are always Int64
3287-
}
3288-
}
3289-
3290-
for (const ControlEntry& entry : m_parser->controlStack()) {
3291-
for (const TypedExpression& expr : entry.enclosedExpressionStack)
3292-
stackMap[stackMapIndex ++] = OSREntryValue(toB3Rep(locationOf(expr.value())), toB3Type(expr.type().kind));
3276+
// Do rethrow slots first because IPInt has them in a shadow stack.
3277+
for (const ControlEntry& entry : m_parser->controlStack()) {
3278+
unsigned numSlots = entry.controlData.implicitSlots();
3279+
if (BBQJIT::ControlData::isTry(entry.controlData))
3280+
++numSlots;
3281+
for (unsigned i = 0; i < numSlots; i ++) {
3282+
Value exception = this->exception(entry.controlData);
3283+
stackMap[stackMapIndex ++] = OSREntryValue(toB3Rep(locationOf(exception)), B3::Int64); // Exceptions are EncodedJSValues, so they are always Int64
32933284
}
3285+
}
32943286

3295-
for (const TypedExpression& expr : enclosingStack)
3296-
stackMap[stackMapIndex ++] = OSREntryValue(toB3Rep(locationOf(expr.value())), toB3Type(expr.type().kind));
3297-
for (unsigned i = 0; i < data.argumentLocations().size(); i ++)
3298-
stackMap[stackMapIndex ++] = OSREntryValue(toB3Rep(data.argumentLocations()[i]), toB3Type(data.argumentType(i).kind));
3299-
3300-
3301-
} else {
3302-
for (const ControlEntry& entry : m_parser->controlStack()) {
3303-
for (const TypedExpression& expr : entry.enclosedExpressionStack)
3304-
stackMap[stackMapIndex ++] = OSREntryValue(toB3Rep(locationOf(expr.value())), toB3Type(expr.type().kind));
3305-
if (ControlData::isAnyCatch(entry.controlData)) {
3306-
for (unsigned i = 0; i < entry.controlData.implicitSlots(); i ++) {
3307-
Value exception = this->exception(entry.controlData);
3308-
stackMap[stackMapIndex ++] = OSREntryValue(toB3Rep(locationOf(exception)), B3::Int64); // Exceptions are EncodedJSValues, so they are always Int64
3309-
}
3310-
}
3311-
}
3312-
for (const TypedExpression& expr : enclosingStack)
3287+
for (const ControlEntry& entry : m_parser->controlStack()) {
3288+
for (const TypedExpression& expr : entry.enclosedExpressionStack)
33133289
stackMap[stackMapIndex ++] = OSREntryValue(toB3Rep(locationOf(expr.value())), toB3Type(expr.type().kind));
3314-
for (unsigned i = 0; i < data.argumentLocations().size(); i ++)
3315-
stackMap[stackMapIndex ++] = OSREntryValue(toB3Rep(data.argumentLocations()[i]), toB3Type(data.argumentType(i).kind));
33163290
}
33173291

3292+
for (const TypedExpression& expr : enclosingStack)
3293+
stackMap[stackMapIndex ++] = OSREntryValue(toB3Rep(locationOf(expr.value())), toB3Type(expr.type().kind));
3294+
for (unsigned i = 0; i < data.argumentLocations().size(); i ++)
3295+
stackMap[stackMapIndex ++] = OSREntryValue(toB3Rep(data.argumentLocations()[i]), toB3Type(data.argumentType(i).kind));
3296+
33183297
RELEASE_ASSERT(stackMapIndex == numElements);
33193298
m_osrEntryScratchBufferSize = std::max(m_osrEntryScratchBufferSize, numElements + BBQCallee::extraOSRValuesForLoopIndex);
33203299
return stackMap;

‎Source/JavaScriptCore/wasm/WasmOMGIRGenerator.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4398,7 +4398,7 @@ auto OMGIRGenerator::addLoop(BlockSignature signature, Stack& enclosingStack, Co
43984398
ASSERT(&data != &block);
43994399
Variable* exceptionVariable = ControlType::isAnyCatch(data) ? data.exception() : nullptr;
44004400
connectValuesAtEntrypoint(indexInBuffer, pointer, expressionStack, exceptionVariable);
4401-
if (Options::useWasmIPInt() && ControlType::isTry(data))
4401+
if (ControlType::isTry(data))
44024402
++indexInBuffer;
44034403
}
44044404
connectValuesAtEntrypoint(indexInBuffer, pointer, enclosingStack, nullptr);

‎Source/JavaScriptCore/wasm/WasmOMGIRGenerator32_64.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4254,7 +4254,7 @@ auto OMGIRGenerator::addLoop(BlockSignature signature, Stack& enclosingStack, Co
42544254
auto& data = m_parser->controlStack()[controlIndex].controlData;
42554255
auto& expressionStack = m_parser->controlStack()[controlIndex].enclosedExpressionStack;
42564256
connectControlAtEntrypoint(LoadI64, indexInBuffer, pointer, data, expressionStack, block);
4257-
if (Options::useWasmIPInt() && ControlType::isTry(data))
4257+
if (ControlType::isTry(data))
42584258
++indexInBuffer;
42594259
}
42604260
connectControlAtEntrypoint(LoadI64, indexInBuffer, pointer, block, enclosingStack, block);

‎Source/JavaScriptCore/wasm/WasmOMGPlan.cpp‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -210,11 +210,10 @@ void OMGPlan::work()
210210
Locker locker { bbqCallee->tierUpCounter().getLock() };
211211
bbqCallee->tierUpCounter().setCompilationStatusForOMG(mode(), TierUpCount::CompilationStatus::Compiled);
212212
}
213-
if (Options::useWasmIPInt() && m_calleeGroup->m_ipintCallees) {
214-
IPIntCallee& ipintCallee = m_calleeGroup->m_ipintCallees->at(m_functionIndex).get();
215-
Locker locker { ipintCallee.tierUpCounter().m_lock };
216-
ipintCallee.tierUpCounter().setCompilationStatus(mode(), IPIntTierUpCounter::CompilationStatus::Compiled);
217-
}
213+
ASSERT(m_calleeGroup->m_ipintCallees);
214+
IPIntCallee& ipintCallee = m_calleeGroup->m_ipintCallees->at(m_functionIndex).get();
215+
Locker locker { ipintCallee.tierUpCounter().m_lock };
216+
ipintCallee.tierUpCounter().setCompilationStatus(mode(), IPIntTierUpCounter::CompilationStatus::Compiled);
218217
}
219218
}
220219

‎Source/JavaScriptCore/wasm/js/JSWebAssemblyInstance.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ void JSWebAssemblyInstance::finalizeCreation(VM& vm, JSGlobalObject* globalObjec
222222
// results, so that later when memory imports become available, the appropriate CalleeGroup can be used.
223223
// If IPInt is disabled, we instead defer compilation to module evaluation.
224224
// If the code is already compiled, e.g. the module was already instantiated before, we do not re-initialize.
225-
if (Options::useWasmIPInt() && module().moduleInformation().hasMemoryImport())
225+
if (module().moduleInformation().hasMemoryImport())
226226
module().copyInitialCalleeGroupToAllMemoryModes(memoryMode());
227227

228228

0 commit comments

Comments
 (0)