Ignore:
Timestamp:
Oct 6, 2020, 3:04:36 PM (5 years ago)
Author:
[email protected]
Message:

[JSC] More consistent PtrTagging for code types
https://bugs.webkit.org/show_bug.cgi?id=217362

Reviewed by Mark Lam.

  1. Avoid tagging JIT code with OperationPtrTag. OperationPtrTag should be used only for operations (C++ code).
  2. Avoid mixing JIT and C++ code for the same tagged pointers. For exception trampoline, in JIT mode, we should have JIT trampoline thunk which goes to LLInt bytecode handler code.
  • bytecode/BytecodeList.rb:
  • bytecode/CodeBlock.cpp:

(JSC::CodeBlock::finishCreation):
(JSC::CodeBlock::finalizeUnconditionally):

  • dfg/DFGCapabilities.cpp:

(JSC::DFG::capabilityLevel):

  • dfg/DFGJITCompiler.cpp:

(JSC::DFG::JITCompiler::compileExceptionHandlers):

  • dfg/DFGSpeculativeJIT.cpp:

(JSC::DFG::SpeculativeJIT::compileMathIC):

  • jit/ICStats.h:
  • jit/JIT.cpp:

(JSC::JIT::compileWithoutLinking):
(JSC::JIT::link):
(JSC::JIT::privateCompileExceptionHandlers):

  • jit/JIT.h:

(JSC::CallRecord::CallRecord):

  • jit/JITCall.cpp:

(JSC::JIT::compileTailCall):
(JSC::JIT::compileOpCall):
(JSC::JIT::compileOpCallSlowCase):

  • jit/JITCall32_64.cpp:

(JSC::JIT::compileOpCall):
(JSC::JIT::compileOpCallSlowCase):

  • jit/JITExceptions.cpp:

(JSC::genericUnwind):

  • jit/JITInlines.h:

(JSC::JIT::emitNakedNearCall):
(JSC::JIT::emitNakedNearTailCall):
(JSC::JIT::emitNakedCall): Deleted.
(JSC::JIT::emitNakedTailCall): Deleted.

  • jit/JITPropertyAccess.cpp:

(JSC::JIT::privateCompilePutByVal):
(JSC::JIT::privateCompilePutPrivateNameWithCachedId):
(JSC::JIT::privateCompilePutByValWithCachedId):

  • jit/SlowPathCall.h:

(JSC::JITSlowPathCall::call):

  • llint/LLIntData.h:

(JSC::LLInt::getWide16CodeRef):
(JSC::LLInt::getWide32CodeRef):
(JSC::LLInt::getCodeFunctionPtr):
(JSC::LLInt::getWide16CodeFunctionPtr):
(JSC::LLInt::getWide32CodeFunctionPtr):

  • llint/LLIntEntrypoint.cpp:

(JSC::LLInt::setFunctionEntrypoint):
(JSC::LLInt::setEvalEntrypoint):
(JSC::LLInt::setProgramEntrypoint):
(JSC::LLInt::setModuleProgramEntrypoint):

  • llint/LLIntExceptions.cpp:

(JSC::LLInt::callToThrow):
(JSC::LLInt::handleUncaughtException):
(JSC::LLInt::catcher):

  • llint/LLIntExceptions.h:
  • llint/LLIntSlowPaths.cpp:
  • llint/LLIntThunks.cpp:

(JSC::LLInt::generateThunkWithJumpTo):
(JSC::LLInt::functionForCallEntryThunk):
(JSC::LLInt::functionForConstructEntryThunk):
(JSC::LLInt::functionForCallArityCheckThunk):
(JSC::LLInt::functionForConstructArityCheckThunk):
(JSC::LLInt::evalEntryThunk):
(JSC::LLInt::programEntryThunk):
(JSC::LLInt::moduleProgramEntryThunk):
(JSC::LLInt::wasmFunctionEntryThunk):
(JSC::LLInt::callToThrowThunk):
(JSC::LLInt::handleUncaughtExceptionThunk):
(JSC::LLInt::catcherThunk):

  • llint/LLIntThunks.h:
  • llint/LowLevelInterpreter32_64.asm:
  • llint/LowLevelInterpreter64.asm:
  • runtime/SamplingProfiler.cpp:

(JSC::SamplingProfiler::processUnverifiedStackTraces):

  • wasm/WasmOperations.cpp:

(JSC::Wasm::JSC_DEFINE_JIT_OPERATION):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/llint/LLIntThunks.cpp

    r267820 r268077  
    4848// and others LLIntEntrypoints.
    4949
    50 static MacroAssemblerCodeRef<JITThunkPtrTag> generateThunkWithJumpTo(OpcodeID opcodeID, const char *thunkKind)
     50template<PtrTag tag>
     51static MacroAssemblerCodeRef<tag> generateThunkWithJumpTo(LLIntCode target, const char *thunkKind)
    5152{
    5253    JSInterfaceJIT jit;
    5354
    54     // FIXME: there's probably a better way to do it on X86, but I'm not sure I care.
    55     LLIntCode target = LLInt::getCodeFunctionPtr<JSEntryPtrTag>(opcodeID);
    5655    assertIsTaggedWith(target, JSEntryPtrTag);
    5756
     
    6564
    6665    LinkBuffer patchBuffer(jit, GLOBAL_THUNK_ID);
    67     return FINALIZE_CODE(patchBuffer, JITThunkPtrTag, "LLInt %s prologue thunk", thunkKind);
    68 }
    69 
    70 MacroAssemblerCodeRef<JITThunkPtrTag> functionForCallEntryThunk()
    71 {
    72     static LazyNeverDestroyed<MacroAssemblerCodeRef<JITThunkPtrTag>> codeRef;
    73     static std::once_flag onceKey;
    74     std::call_once(onceKey, [&] {
    75         codeRef.construct(generateThunkWithJumpTo(llint_function_for_call_prologue, "function for call"));
    76     });
    77     return codeRef;
    78 }
    79 
    80 MacroAssemblerCodeRef<JITThunkPtrTag> functionForConstructEntryThunk()
    81 {
    82     static LazyNeverDestroyed<MacroAssemblerCodeRef<JITThunkPtrTag>> codeRef;
    83     static std::once_flag onceKey;
    84     std::call_once(onceKey, [&] {
    85         codeRef.construct(generateThunkWithJumpTo(llint_function_for_construct_prologue, "function for construct"));
    86     });
    87     return codeRef;
    88 }
    89 
    90 MacroAssemblerCodeRef<JITThunkPtrTag> functionForCallArityCheckThunk()
    91 {
    92     static LazyNeverDestroyed<MacroAssemblerCodeRef<JITThunkPtrTag>> codeRef;
    93     static std::once_flag onceKey;
    94     std::call_once(onceKey, [&] {
    95         codeRef.construct(generateThunkWithJumpTo(llint_function_for_call_arity_check, "function for call with arity check"));
    96     });
    97     return codeRef;
    98 }
    99 
    100 MacroAssemblerCodeRef<JITThunkPtrTag> functionForConstructArityCheckThunk()
    101 {
    102     static LazyNeverDestroyed<MacroAssemblerCodeRef<JITThunkPtrTag>> codeRef;
    103     static std::once_flag onceKey;
    104     std::call_once(onceKey, [&] {
    105         codeRef.construct(generateThunkWithJumpTo(llint_function_for_construct_arity_check, "function for construct with arity check"));
    106     });
    107     return codeRef;
    108 }
    109 
    110 MacroAssemblerCodeRef<JITThunkPtrTag> evalEntryThunk()
    111 {
    112     static LazyNeverDestroyed<MacroAssemblerCodeRef<JITThunkPtrTag>> codeRef;
    113     static std::once_flag onceKey;
    114     std::call_once(onceKey, [&] {
    115         codeRef.construct(generateThunkWithJumpTo(llint_eval_prologue, "eval"));
    116     });
    117     return codeRef;
    118 }
    119 
    120 MacroAssemblerCodeRef<JITThunkPtrTag> programEntryThunk()
    121 {
    122     static LazyNeverDestroyed<MacroAssemblerCodeRef<JITThunkPtrTag>> codeRef;
    123     static std::once_flag onceKey;
    124     std::call_once(onceKey, [&] {
    125         codeRef.construct(generateThunkWithJumpTo(llint_program_prologue, "program"));
    126     });
    127     return codeRef;
    128 }
    129 
    130 MacroAssemblerCodeRef<JITThunkPtrTag> moduleProgramEntryThunk()
    131 {
    132     static LazyNeverDestroyed<MacroAssemblerCodeRef<JITThunkPtrTag>> codeRef;
    133     static std::once_flag onceKey;
    134     std::call_once(onceKey, [&] {
    135         codeRef.construct(generateThunkWithJumpTo(llint_module_program_prologue, "module_program"));
     66    return FINALIZE_CODE(patchBuffer, tag, "LLInt %s prologue thunk", thunkKind);
     67}
     68
     69template<PtrTag tag>
     70static MacroAssemblerCodeRef<tag> generateThunkWithJumpTo(OpcodeID opcodeID, const char *thunkKind)
     71{
     72    return generateThunkWithJumpTo<tag>(LLInt::getCodeFunctionPtr<JSEntryPtrTag>(opcodeID), thunkKind);
     73}
     74
     75MacroAssemblerCodeRef<JSEntryPtrTag> functionForCallEntryThunk()
     76{
     77    static LazyNeverDestroyed<MacroAssemblerCodeRef<JSEntryPtrTag>> codeRef;
     78    static std::once_flag onceKey;
     79    std::call_once(onceKey, [&] {
     80        codeRef.construct(generateThunkWithJumpTo<JSEntryPtrTag>(llint_function_for_call_prologue, "function for call"));
     81    });
     82    return codeRef;
     83}
     84
     85MacroAssemblerCodeRef<JSEntryPtrTag> functionForConstructEntryThunk()
     86{
     87    static LazyNeverDestroyed<MacroAssemblerCodeRef<JSEntryPtrTag>> codeRef;
     88    static std::once_flag onceKey;
     89    std::call_once(onceKey, [&] {
     90        codeRef.construct(generateThunkWithJumpTo<JSEntryPtrTag>(llint_function_for_construct_prologue, "function for construct"));
     91    });
     92    return codeRef;
     93}
     94
     95MacroAssemblerCodeRef<JSEntryPtrTag> functionForCallArityCheckThunk()
     96{
     97    static LazyNeverDestroyed<MacroAssemblerCodeRef<JSEntryPtrTag>> codeRef;
     98    static std::once_flag onceKey;
     99    std::call_once(onceKey, [&] {
     100        codeRef.construct(generateThunkWithJumpTo<JSEntryPtrTag>(llint_function_for_call_arity_check, "function for call with arity check"));
     101    });
     102    return codeRef;
     103}
     104
     105MacroAssemblerCodeRef<JSEntryPtrTag> functionForConstructArityCheckThunk()
     106{
     107    static LazyNeverDestroyed<MacroAssemblerCodeRef<JSEntryPtrTag>> codeRef;
     108    static std::once_flag onceKey;
     109    std::call_once(onceKey, [&] {
     110        codeRef.construct(generateThunkWithJumpTo<JSEntryPtrTag>(llint_function_for_construct_arity_check, "function for construct with arity check"));
     111    });
     112    return codeRef;
     113}
     114
     115MacroAssemblerCodeRef<JSEntryPtrTag> evalEntryThunk()
     116{
     117    static LazyNeverDestroyed<MacroAssemblerCodeRef<JSEntryPtrTag>> codeRef;
     118    static std::once_flag onceKey;
     119    std::call_once(onceKey, [&] {
     120        codeRef.construct(generateThunkWithJumpTo<JSEntryPtrTag>(llint_eval_prologue, "eval"));
     121    });
     122    return codeRef;
     123}
     124
     125MacroAssemblerCodeRef<JSEntryPtrTag> programEntryThunk()
     126{
     127    static LazyNeverDestroyed<MacroAssemblerCodeRef<JSEntryPtrTag>> codeRef;
     128    static std::once_flag onceKey;
     129    std::call_once(onceKey, [&] {
     130        codeRef.construct(generateThunkWithJumpTo<JSEntryPtrTag>(llint_program_prologue, "program"));
     131    });
     132    return codeRef;
     133}
     134
     135MacroAssemblerCodeRef<JSEntryPtrTag> moduleProgramEntryThunk()
     136{
     137    static LazyNeverDestroyed<MacroAssemblerCodeRef<JSEntryPtrTag>> codeRef;
     138    static std::once_flag onceKey;
     139    std::call_once(onceKey, [&] {
     140        codeRef.construct(generateThunkWithJumpTo<JSEntryPtrTag>(llint_module_program_prologue, "module_program"));
    136141    });
    137142    return codeRef;
     
    145150    std::call_once(onceKey, [&] {
    146151        if (Wasm::Context::useFastTLS())
    147             codeRef.construct(generateThunkWithJumpTo(wasm_function_prologue, "function for call"));
     152            codeRef.construct(generateThunkWithJumpTo<JITThunkPtrTag>(wasm_function_prologue, "function for call"));
    148153        else
    149             codeRef.construct(generateThunkWithJumpTo(wasm_function_prologue_no_tls, "function for call"));
     154            codeRef.construct(generateThunkWithJumpTo<JITThunkPtrTag>(wasm_function_prologue_no_tls, "function for call"));
    150155    });
    151156    return codeRef;
     
    186191}
    187192
     193MacroAssemblerCodeRef<ExceptionHandlerPtrTag> callToThrowThunk()
     194{
     195    static LazyNeverDestroyed<MacroAssemblerCodeRef<ExceptionHandlerPtrTag>> codeRef;
     196    static std::once_flag onceKey;
     197    std::call_once(onceKey, [&] {
     198        codeRef.construct(generateThunkWithJumpTo<ExceptionHandlerPtrTag>(llint_throw_during_call_trampoline, "LLInt::callToThrow thunk"));
     199    });
     200    return codeRef;
     201}
     202
     203MacroAssemblerCodeRef<ExceptionHandlerPtrTag> handleUncaughtExceptionThunk()
     204{
     205    static LazyNeverDestroyed<MacroAssemblerCodeRef<ExceptionHandlerPtrTag>> codeRef;
     206    static std::once_flag onceKey;
     207    std::call_once(onceKey, [&] {
     208        codeRef.construct(generateThunkWithJumpTo<ExceptionHandlerPtrTag>(llint_handle_uncaught_exception, "handle_uncaught_exception"));
     209    });
     210    return codeRef;
     211}
     212
     213MacroAssemblerCodeRef<ExceptionHandlerPtrTag> handleCatchThunk(OpcodeSize size)
     214{
     215    switch (size) {
     216    case OpcodeSize::Narrow: {
     217        static LazyNeverDestroyed<MacroAssemblerCodeRef<ExceptionHandlerPtrTag>> codeRef;
     218        static std::once_flag onceKey;
     219        std::call_once(onceKey, [&] {
     220            codeRef.construct(generateThunkWithJumpTo<ExceptionHandlerPtrTag>(LLInt::getCodeFunctionPtr<JSEntryPtrTag>(op_catch), "op_catch"));
     221        });
     222        return codeRef;
     223    }
     224    case OpcodeSize::Wide16: {
     225        static LazyNeverDestroyed<MacroAssemblerCodeRef<ExceptionHandlerPtrTag>> codeRef;
     226        static std::once_flag onceKey;
     227        std::call_once(onceKey, [&] {
     228            codeRef.construct(generateThunkWithJumpTo<ExceptionHandlerPtrTag>(LLInt::getWide16CodeFunctionPtr<JSEntryPtrTag>(op_catch), "op_catch16"));
     229        });
     230        return codeRef;
     231    }
     232    case OpcodeSize::Wide32: {
     233        static LazyNeverDestroyed<MacroAssemblerCodeRef<ExceptionHandlerPtrTag>> codeRef;
     234        static std::once_flag onceKey;
     235        std::call_once(onceKey, [&] {
     236            codeRef.construct(generateThunkWithJumpTo<ExceptionHandlerPtrTag>(LLInt::getWide32CodeFunctionPtr<JSEntryPtrTag>(op_catch), "op_catch32"));
     237        });
     238        return codeRef;
     239    }
     240    }
     241    RELEASE_ASSERT_NOT_REACHED();
     242    return { };
     243}
     244
    188245} // namespace LLInt
    189246
Note: See TracChangeset for help on using the changeset viewer.