Skip to content

Commit be7c61d

Browse files
committed
[JSC] Fix !ENABLE(JIT) build
https://bugs.webkit.org/show_bug.cgi?id=306638 rdar://169822205 Reviewed by Yusuke Suzuki. This patch is originally written by Shu-yu Guo. Yusuke reviewed the original version of the patch. I, Michael Catanzaro, have updated it to resolve conflicts. This is a second try, because my first attempt, 311492@main, was broken and reverted in 311499@main. * Source/JavaScriptCore/jit/ExecutableAllocator.h: (JSC::performJITMemcpy): * Source/JavaScriptCore/llint/InPlaceInterpreter.asm: * Source/JavaScriptCore/llint/LLIntData.cpp: (JSC::LLInt::initialize): * Source/JavaScriptCore/wasm/WasmCallee.cpp: * Source/WTF/wtf/PlatformEnable.h: Canonical link: https://commits.webkit.org/311632@main
1 parent 7442716 commit be7c61d

5 files changed

Lines changed: 83 additions & 23 deletions

File tree

‎Source/JavaScriptCore/jit/ExecutableAllocator.h‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,14 @@ WTF_ALLOW_UNSAFE_BUFFER_USAGE_BEGIN
390390
WTF_ALLOW_UNSAFE_BUFFER_USAGE_END
391391
}
392392

393+
template<RepatchingInfo>
394+
inline void* performJITMemcpy(void *dst, const void *src, size_t n)
395+
{
396+
WTF_ALLOW_UNSAFE_BUFFER_USAGE_BEGIN
397+
return memcpy(dst, src, n);
398+
WTF_ALLOW_UNSAFE_BUFFER_USAGE_END
399+
}
400+
393401
inline bool isJITPC(void*) { return false; }
394402
#endif // ENABLE(JIT)
395403

‎Source/JavaScriptCore/llint/InPlaceInterpreter.asm‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,7 @@ end
526526

527527
# OSR
528528
macro ipintPrologueOSR(increment)
529-
if JIT
529+
if WEBASSEMBLY_BBQJIT
530530
loadp UnboxedWasmCalleeStackSlot[cfr], ws0
531531
baddis increment, Wasm::IPIntCallee::m_tierUpCounter + Wasm::IPIntTierUpCounter::m_counter[ws0], .continue
532532

@@ -563,11 +563,11 @@ end
563563
if ARMv7
564564
break # FIXME: ipint support.
565565
end # ARMv7
566-
end # JIT
566+
end # WEBASSEMBLY_BBQJIT
567567
end
568568

569569
macro ipintLoopOSR(increment)
570-
if JIT and not ARMv7
570+
if WEBASSEMBLY_BBQJIT and not ARMv7
571571
validateOpcodeConfig(ws0)
572572
loadp UnboxedWasmCalleeStackSlot[cfr], ws0
573573
baddis increment, Wasm::IPIntCallee::m_tierUpCounter + Wasm::IPIntTierUpCounter::m_counter[ws0], .continue
@@ -598,7 +598,7 @@ end
598598
end
599599

600600
macro ipintEpilogueOSR(increment)
601-
if JIT and not ARMv7
601+
if WEBASSEMBLY_BBQJIT and not ARMv7
602602
loadp UnboxedWasmCalleeStackSlot[cfr], ws0
603603
baddis increment, Wasm::IPIntCallee::m_tierUpCounter + Wasm::IPIntTierUpCounter::m_counter[ws0], .continue
604604

‎Source/JavaScriptCore/llint/LLIntData.cpp‎

Lines changed: 55 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -213,16 +213,23 @@ void initialize()
213213
g_jscConfig.llint.gateMap[static_cast<unsigned>(Gate::jitCagePtr)] = jitCagePtrThunk().code().taggedPtr();
214214
#endif
215215

216+
#if ENABLE(JIT)
217+
#define INITIALIZE_JS_GATE_JIT_PATH(name, tag) \
218+
if (Options::useJIT()) { \
219+
codeRef8.construct(createJSGateThunk(retagCodePtr<void*, CFunctionPtrTag, OperationPtrTag>(LLInt::getCodeFunctionPtr<CFunctionPtrTag>(name##_return_location)), tag, #name)); \
220+
codeRef16.construct(createJSGateThunk(retagCodePtr<void*, CFunctionPtrTag, OperationPtrTag>(LLInt::getWide16CodeFunctionPtr<CFunctionPtrTag>(name##_return_location)), tag, #name "_wide16")); \
221+
codeRef32.construct(createJSGateThunk(retagCodePtr<void*, CFunctionPtrTag, OperationPtrTag>(LLInt::getWide32CodeFunctionPtr<CFunctionPtrTag>(name##_return_location)), tag, #name "_wide32")); \
222+
} else
223+
#else
224+
#define INITIALIZE_JS_GATE_JIT_PATH(name, tag)
225+
#endif
226+
216227
#define INITIALIZE_JS_GATE(name, tag) \
217228
do { \
218229
static LazyNeverDestroyed<MacroAssemblerCodeRef<NativeToJITGatePtrTag>> codeRef8; \
219230
static LazyNeverDestroyed<MacroAssemblerCodeRef<NativeToJITGatePtrTag>> codeRef16; \
220231
static LazyNeverDestroyed<MacroAssemblerCodeRef<NativeToJITGatePtrTag>> codeRef32; \
221-
if (Options::useJIT()) { \
222-
codeRef8.construct(createJSGateThunk(retagCodePtr<void*, CFunctionPtrTag, OperationPtrTag>(LLInt::getCodeFunctionPtr<CFunctionPtrTag>(name##_return_location)), tag, #name)); \
223-
codeRef16.construct(createJSGateThunk(retagCodePtr<void*, CFunctionPtrTag, OperationPtrTag>(LLInt::getWide16CodeFunctionPtr<CFunctionPtrTag>(name##_return_location)), tag, #name "_wide16")); \
224-
codeRef32.construct(createJSGateThunk(retagCodePtr<void*, CFunctionPtrTag, OperationPtrTag>(LLInt::getWide32CodeFunctionPtr<CFunctionPtrTag>(name##_return_location)), tag, #name "_wide32")); \
225-
} else { \
232+
INITIALIZE_JS_GATE_JIT_PATH(name, tag) { \
226233
codeRef8.construct(LLInt::getCodeRef<NativeToJITGatePtrTag>(js_trampoline_##name)); \
227234
codeRef16.construct(LLInt::getWide16CodeRef<NativeToJITGatePtrTag>(js_trampoline_##name)); \
228235
codeRef32.construct(LLInt::getWide32CodeRef<NativeToJITGatePtrTag>(js_trampoline_##name)); \
@@ -236,16 +243,23 @@ void initialize()
236243

237244
#if ENABLE(WEBASSEMBLY)
238245

246+
#if ENABLE(JIT)
247+
#define INITIALIZE_WASM_GATE_JIT_PATH(name, tag) \
248+
if (Options::useJIT()) { \
249+
codeRef8.construct(createWasmGateThunk(retagCodePtr<void*, CFunctionPtrTag, OperationPtrTag>(LLInt::getCodeFunctionPtr<CFunctionPtrTag>(name##_return_location)), tag, #name)); \
250+
codeRef16.construct(createWasmGateThunk(retagCodePtr<void*, CFunctionPtrTag, OperationPtrTag>(LLInt::getWide16CodeFunctionPtr<CFunctionPtrTag>(name##_return_location)), tag, #name "_wide16")); \
251+
codeRef32.construct(createWasmGateThunk(retagCodePtr<void*, CFunctionPtrTag, OperationPtrTag>(LLInt::getWide32CodeFunctionPtr<CFunctionPtrTag>(name##_return_location)), tag, #name "_wide32")); \
252+
} else
253+
#else
254+
#define INITIALIZE_WASM_GATE_JIT_PATH(name, tag)
255+
#endif
256+
239257
#define INITIALIZE_WASM_GATE(name, tag) \
240258
do { \
241259
static LazyNeverDestroyed<MacroAssemblerCodeRef<NativeToJITGatePtrTag>> codeRef8; \
242260
static LazyNeverDestroyed<MacroAssemblerCodeRef<NativeToJITGatePtrTag>> codeRef16; \
243261
static LazyNeverDestroyed<MacroAssemblerCodeRef<NativeToJITGatePtrTag>> codeRef32; \
244-
if (Options::useJIT()) { \
245-
codeRef8.construct(createWasmGateThunk(retagCodePtr<void*, CFunctionPtrTag, OperationPtrTag>(LLInt::getCodeFunctionPtr<CFunctionPtrTag>(name##_return_location)), tag, #name)); \
246-
codeRef16.construct(createWasmGateThunk(retagCodePtr<void*, CFunctionPtrTag, OperationPtrTag>(LLInt::getWide16CodeFunctionPtr<CFunctionPtrTag>(name##_return_location)), tag, #name "_wide16")); \
247-
codeRef32.construct(createWasmGateThunk(retagCodePtr<void*, CFunctionPtrTag, OperationPtrTag>(LLInt::getWide32CodeFunctionPtr<CFunctionPtrTag>(name##_return_location)), tag, #name "_wide32")); \
248-
} else { \
262+
INITIALIZE_WASM_GATE_JIT_PATH(name, tag) { \
249263
codeRef8.construct(LLInt::getCodeRef<NativeToJITGatePtrTag>(wasm_trampoline_##name)); \
250264
codeRef16.construct(LLInt::getWide16CodeRef<NativeToJITGatePtrTag>(wasm_trampoline_##name)); \
251265
codeRef32.construct(LLInt::getWide32CodeRef<NativeToJITGatePtrTag>(wasm_trampoline_##name)); \
@@ -263,10 +277,12 @@ void initialize()
263277
// This is key to entering the interpreter.
264278
{
265279
static LazyNeverDestroyed<MacroAssemblerCodeRef<VMEntryToJITGatePtrTag>> codeRef;
280+
#if ENABLE(JIT)
266281
if (Options::useJIT()) {
267282
auto gateCodeRef = createJSGateThunk(retagCodePtr<void*, CFunctionPtrTag, OperationPtrTag>(&vmEntryToJavaScriptGateAfter), JSEntryPtrTag, "vmEntryToJavaScript");
268283
codeRef.construct(gateCodeRef.retagged<VMEntryToJITGatePtrTag>());
269284
} else
285+
#endif
270286
codeRef.construct(MacroAssemblerCodeRef<VMEntryToJITGatePtrTag>::createSelfManagedCodeRef(CodePtr<VMEntryToJITGatePtrTag>::fromTaggedPtr(retagCodePtr<void*, CFunctionPtrTag, VMEntryToJITGatePtrTag>(&vmEntryToJavaScriptTrampoline))));
271287
g_jscConfig.llint.gateMap[static_cast<unsigned>(Gate::vmEntryToJavaScript)] = codeRef.get().code().taggedPtr();
272288
}
@@ -278,66 +294,83 @@ void initialize()
278294

279295
{
280296
static LazyNeverDestroyed<MacroAssemblerCodeRef<NativeToJITGatePtrTag>> codeRef;
297+
#if ENABLE(JIT)
281298
if (Options::useJIT())
282299
codeRef.construct(createTailCallGate(JSEntryPtrTag, true));
283300
else
301+
#endif
284302
codeRef.construct(MacroAssemblerCodeRef<NativeToJITGatePtrTag>::createSelfManagedCodeRef(CodePtr<NativeToJITGatePtrTag>::fromTaggedPtr(retagCodePtr<void*, CFunctionPtrTag, NativeToJITGatePtrTag>(&tailCallJSEntryTrampoline))));
285303
g_jscConfig.llint.gateMap[static_cast<unsigned>(Gate::tailCallJSEntryPtrTag)]= codeRef.get().code().taggedPtr();
286304
}
287305
{
288306
static LazyNeverDestroyed<MacroAssemblerCodeRef<NativeToJITGatePtrTag>> codeRef;
307+
#if ENABLE(JIT)
289308
if (Options::useJIT())
290309
codeRef.construct(createTailCallGate(JSEntryPtrTag, true));
291310
else
311+
#endif
292312
codeRef.construct(MacroAssemblerCodeRef<NativeToJITGatePtrTag>::createSelfManagedCodeRef(CodePtr<NativeToJITGatePtrTag>::fromTaggedPtr(retagCodePtr<void*, CFunctionPtrTag, NativeToJITGatePtrTag>(&tailCallJSEntrySlowPathTrampoline))));
293313
g_jscConfig.llint.gateMap[static_cast<unsigned>(Gate::tailCallJSEntrySlowPathPtrTag)] = codeRef.get().code().taggedPtr();
294314
}
295315
{
296316
static LazyNeverDestroyed<MacroAssemblerCodeRef<NativeToJITGatePtrTag>> codeRef;
317+
#if ENABLE(JIT)
297318
if (Options::useJIT())
298319
codeRef.construct(createTailCallGate(JSEntryPtrTag, false));
299320
else
321+
#endif
300322
codeRef.construct(MacroAssemblerCodeRef<NativeToJITGatePtrTag>::createSelfManagedCodeRef(CodePtr<NativeToJITGatePtrTag>::fromTaggedPtr(retagCodePtr<void*, CFunctionPtrTag, NativeToJITGatePtrTag>(&tailCallWithoutUntagJSEntryTrampoline))));
301323
g_jscConfig.llint.gateMap[static_cast<unsigned>(Gate::tailCallWithoutUntagJSEntryPtrTag)]= codeRef.get().code().taggedPtr();
302324
}
303325
{
304326
static LazyNeverDestroyed<MacroAssemblerCodeRef<NativeToJITGatePtrTag>> codeRef;
327+
#if ENABLE(JIT)
305328
if (Options::useJIT())
306329
codeRef.construct(createWasmTailCallGate(WasmEntryPtrTag));
307330
else
331+
#endif
308332
codeRef.construct(MacroAssemblerCodeRef<NativeToJITGatePtrTag>::createSelfManagedCodeRef(CodePtr<NativeToJITGatePtrTag>::fromTaggedPtr(retagCodePtr<void*, CFunctionPtrTag, NativeToJITGatePtrTag>(&wasmTailCallTrampoline))));
309333
g_jscConfig.llint.gateMap[static_cast<unsigned>(Gate::wasmTailCallWasmEntryPtrTag)]= codeRef.get().code().taggedPtr();
310334
}
311335
{
312336
static LazyNeverDestroyed<MacroAssemblerCodeRef<NativeToJITGatePtrTag>> codeRef;
337+
#if ENABLE(JIT)
313338
if (Options::useJIT())
314339
codeRef.construct(createWasmTailCallGate(WasmEntryPtrTag));
315340
else
341+
#endif
316342
codeRef.construct(MacroAssemblerCodeRef<NativeToJITGatePtrTag>::createSelfManagedCodeRef(CodePtr<NativeToJITGatePtrTag>::fromTaggedPtr(retagCodePtr<void*, CFunctionPtrTag, NativeToJITGatePtrTag>(&wasmTailCallTrampoline))));
317343
g_jscConfig.llint.gateMap[static_cast<unsigned>(Gate::wasmIPIntTailCallWasmEntryPtrTag)]= codeRef.get().code().taggedPtr();
318344
}
319345
{
320346
static LazyNeverDestroyed<MacroAssemblerCodeRef<NativeToJITGatePtrTag>> codeRef;
347+
#if ENABLE(JIT)
321348
if (Options::useJIT())
322349
codeRef.construct(exceptionHandlerGateThunk());
323350
else
351+
#endif
324352
codeRef.construct(MacroAssemblerCodeRef<NativeToJITGatePtrTag>::createSelfManagedCodeRef(CodePtr<NativeToJITGatePtrTag>::fromTaggedPtr(retagCodePtr<void*, CFunctionPtrTag, NativeToJITGatePtrTag>(&exceptionHandlerTrampoline))));
325353
g_jscConfig.llint.gateMap[static_cast<unsigned>(Gate::exceptionHandler)] = codeRef.get().code().taggedPtr();
326354
}
327355
{
328356
static LazyNeverDestroyed<MacroAssemblerCodeRef<NativeToJITGatePtrTag>> codeRef;
357+
#if ENABLE(JIT)
329358
if (Options::useJIT())
330359
codeRef.construct(returnFromLLIntGateThunk());
331360
else
361+
#endif
332362
codeRef.construct(MacroAssemblerCodeRef<NativeToJITGatePtrTag>::createSelfManagedCodeRef(CodePtr<NativeToJITGatePtrTag>::fromTaggedPtr(retagCodePtr<void*, CFunctionPtrTag, NativeToJITGatePtrTag>(&returnFromLLIntTrampoline))));
333363
g_jscConfig.llint.gateMap[static_cast<unsigned>(Gate::returnFromLLInt)] = codeRef.get().code().taggedPtr();
334364
}
335365

366+
#if ENABLE(JIT)
336367
if (Options::useJIT()) {
337368
g_jscConfig.llint.gateMap[static_cast<unsigned>(Gate::loopOSREntry)] = loopOSREntryGateThunk().code().taggedPtr();
338369
g_jscConfig.llint.gateMap[static_cast<unsigned>(Gate::entryOSREntry)] = entryOSREntryGateThunk().code().taggedPtr();
339370
g_jscConfig.llint.gateMap[static_cast<unsigned>(Gate::wasmOSREntry)] = wasmOSREntryGateThunk().code().taggedPtr();
340-
} else {
371+
} else
372+
#endif
373+
{
341374
g_jscConfig.llint.gateMap[static_cast<unsigned>(Gate::loopOSREntry)] = LLInt::getCodeRef<NativeToJITGatePtrTag>(loop_osr_entry_gate).code().taggedPtr();
342375
g_jscConfig.llint.gateMap[static_cast<unsigned>(Gate::entryOSREntry)] = nullptr;
343376
g_jscConfig.llint.gateMap[static_cast<unsigned>(Gate::wasmOSREntry)] = nullptr;
@@ -371,14 +404,21 @@ void initialize()
371404
}
372405
#endif
373406

407+
#if ENABLE(JIT)
408+
#define INITIALIZE_TAG_AND_UNTAG_THUNKS_JIT_PATH(name) \
409+
if (Options::useJIT()) { \
410+
tagCodeRef.construct(tagGateThunk(retagCodePtr<void*, CFunctionPtrTag, OperationPtrTag>(name##TagGateAfter))); \
411+
untagCodeRef.construct(untagGateThunk(retagCodePtr<void*, CFunctionPtrTag, OperationPtrTag>(name##UntagGateAfter))); \
412+
} else
413+
#else
414+
#define INITIALIZE_TAG_AND_UNTAG_THUNKS_JIT_PATH(name)
415+
#endif
416+
374417
#define INITIALIZE_TAG_AND_UNTAG_THUNKS(name) \
375418
do { \
376419
static LazyNeverDestroyed<MacroAssemblerCodeRef<NativeToJITGatePtrTag>> tagCodeRef; \
377420
static LazyNeverDestroyed<MacroAssemblerCodeRef<NativeToJITGatePtrTag>> untagCodeRef; \
378-
if (Options::useJIT()) { \
379-
tagCodeRef.construct(tagGateThunk(retagCodePtr<void*, CFunctionPtrTag, OperationPtrTag>(name##TagGateAfter))); \
380-
untagCodeRef.construct(untagGateThunk(retagCodePtr<void*, CFunctionPtrTag, OperationPtrTag>(name##UntagGateAfter))); \
381-
} else { \
421+
INITIALIZE_TAG_AND_UNTAG_THUNKS_JIT_PATH(name) { \
382422
tagCodeRef.construct(LLInt::getCodeRef<NativeToJITGatePtrTag>(js_trampoline_##name##_tag)); \
383423
untagCodeRef.construct(LLInt::getCodeRef<NativeToJITGatePtrTag>(js_trampoline_##name##_untag)); \
384424
} \

‎Source/JavaScriptCore/wasm/WasmCallee.cpp‎

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,25 @@ WTF_MAKE_COMPACT_TZONE_ALLOCATED_IMPL(Callee);
5656
WTF_MAKE_COMPACT_TZONE_ALLOCATED_IMPL(JITCallee);
5757
WTF_MAKE_COMPACT_TZONE_ALLOCATED_IMPL(JSToWasmCallee);
5858
WTF_MAKE_COMPACT_TZONE_ALLOCATED_IMPL(WasmToJSCallee);
59+
WTF_MAKE_COMPACT_TZONE_ALLOCATED_IMPL(IPIntCallee);
60+
WTF_MAKE_COMPACT_TZONE_ALLOCATED_IMPL(WasmBuiltinCallee);
61+
62+
#if ENABLE(JIT)
5963
WTF_MAKE_COMPACT_TZONE_ALLOCATED_IMPL(JSToWasmICCallee);
64+
#endif
65+
66+
#if ENABLE(WEBASSEMBLY_BBQJIT) || ENABLE(WEBASSEMBLY_OMGJIT)
6067
WTF_MAKE_COMPACT_TZONE_ALLOCATED_IMPL(OptimizingJITCallee);
68+
#endif
69+
70+
#if ENABLE(WEBASSEMBLY_BBQJIT)
71+
WTF_MAKE_COMPACT_TZONE_ALLOCATED_IMPL(BBQCallee);
72+
#endif
73+
74+
#if ENABLE(WEBASSEMBLY_OMGJIT)
6175
WTF_MAKE_COMPACT_TZONE_ALLOCATED_IMPL(OMGCallee);
6276
WTF_MAKE_COMPACT_TZONE_ALLOCATED_IMPL(OMGOSREntryCallee);
63-
WTF_MAKE_COMPACT_TZONE_ALLOCATED_IMPL(BBQCallee);
64-
WTF_MAKE_COMPACT_TZONE_ALLOCATED_IMPL(IPIntCallee);
65-
WTF_MAKE_COMPACT_TZONE_ALLOCATED_IMPL(WasmBuiltinCallee);
77+
#endif
6678

6779
Callee::Callee(Wasm::CompilationMode compilationMode)
6880
: NativeCallee(NativeCallee::Category::Wasm, ImplementationVisibility::Private)

‎Source/WTF/wtf/PlatformEnable.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -989,7 +989,7 @@
989989
#define ENABLE_JIT_OPERATION_DISASSEMBLY 1
990990
#endif
991991

992-
#if CPU(ARM64E)
992+
#if CPU(ARM64E) && ENABLE(JIT)
993993
#define ENABLE_JIT_SIGN_ASSEMBLER_BUFFER 1
994994
#endif
995995

0 commit comments

Comments
 (0)