Changeset 294180 in webkit


Ignore:
Timestamp:
May 13, 2022 3:28:16 PM (2 years ago)
Author:
mark.lam@apple.com
Message:

Enhance the ARM64Disassembler to print pc indices and better branch target labels.
https://bugs.webkit.org/show_bug.cgi?id=240370

Reviewed by Saam Barati.

Disassemblies used to look like this:

0x10e480ff8: ldurb w17, [x0, #7]
0x10e480ffc: cmp w17, #0
0x10e481000: b.hi 0x10e48103c
0x10e481004: stur x0, [fp, #-72]
...
0x10e481040: movk x3, #0xfffe, lsl #48
0x10e481044: b 0x10e4814f4
0x10e481048: nop

With this patch, it will now look like this:

<748> 0x10e120aec: ldurb w17, [x0, #7]
<752> 0x10e120af0: cmp w17, #0
<756> 0x10e120af4: b.hi 0x10e120b30 -> <816>
<760> 0x10e120af8: stur x0, [fp, #-80]
...
<820> 0x10e120b34: movk x3, #0xfffe, lsl #48
<824> 0x10e120b38: b 0x10e120fc8 -> <1992>
<828> 0x10e120b3c: nop

  1. Each instruction pc is now prefixed with a pc index i.e. the offset of the pc address from the start of the compilation unit e.g. <756>.
  1. Relative branches now show the branch target as a pc index (effectively, an internal label in this compilation unit) in addition to the pc address e.g. the "-> <816>" in:

<756> 0x10e120af4: b.hi 0x10e120b30 -> <816>

Also fixed a formatting bug where the space between relative branch instructions
and their target pc was short 2 spaces.

  1. If the relative branch target is a known thunk, the disassembler will now print the thunk label e.g.

<828> 0x10e12033c: bl 0x10e0f0a00 -> <thunk: get_from_scope thunk>

<1476> 0x10e120dc4: cbnz x16, 0x10e104100 -> <thunk: handleExceptionWithCallFrameRollback>
<2368> 0x10e121140: b 0x10e10c000 -> <thunk: DFG OSR exit generation thunk>

Introduced a FINALIZE_THUNK macro that will be used instead of FINALIZE_CODE in
thunk generators. By doing so, thunk labels will automatically be registered
with the disassembler, and will be used for the above look up.

Thunk label registration is only done if disassembly is enabled.

  1. If the branch target is neither an internal label nor a thunk, then the disassembler will print some useful info about it to the best of its knowledge e.g.

<168> 0x10e1002e8: b 0x10e120b60 -> <JIT PC>
<168> 0x10e1002e8: b 0x10e120b60 -> <LLInt PC>
<168> 0x10e1002e8: b 0x10e120b60 -> <unknown>

  1. The disassemble() function now takes 2 additional arguments: codeStart, and codeEnd. These are needed so that the disassembler can compute the pc index for each instruction, as well as determine if a branch target is internal to this compilation unit, or pointing out of it.

This feature is currently only supported for the ARM64 disassembler.

Printing of JIT operation labels (via movz + movk + indirect branch) is not yet
supported.

  • assembler/LinkBuffer.cpp:

(JSC::LinkBuffer::finalizeCodeWithDisassemblyImpl):

  • assembler/LinkBuffer.h:

(JSC::LinkBuffer::setIsThunk):

  • b3/air/AirDisassembler.cpp:

(JSC::B3::Air::Disassembler::dump):

  • dfg/DFGDisassembler.cpp:

(JSC::DFG::Disassembler::dumpDisassembly):

  • dfg/DFGThunks.cpp:

(JSC::DFG::osrExitGenerationThunkGenerator):
(JSC::DFG::osrEntryThunkGenerator):

  • disassembler/ARM64/A64DOpcode.cpp:

(JSC::ARM64Disassembler::A64DOpcode::appendPCRelativeOffset):
(JSC::ARM64Disassembler::A64DOpcodeConditionalBranchImmediate::format):

  • disassembler/ARM64/A64DOpcode.h:

(JSC::ARM64Disassembler::A64DOpcode::A64DOpcode):
(JSC::ARM64Disassembler::A64DOpcode::appendPCRelativeOffset): Deleted.

  • disassembler/ARM64Disassembler.cpp:

(JSC::tryToDisassemble):

  • disassembler/CapstoneDisassembler.cpp:

(JSC::tryToDisassemble):

  • disassembler/Disassembler.cpp:

(JSC::disassemble):
(JSC::disassembleAsynchronously):
(JSC::ensureThunkLabelMap):
(JSC::registerThunkLabel):
(JSC::labelForThunk):

  • disassembler/Disassembler.h:

(JSC::tryToDisassemble):

  • disassembler/RISCV64Disassembler.cpp:

(JSC::tryToDisassemble):

  • disassembler/X86Disassembler.cpp:

(JSC::tryToDisassemble):

  • ftl/FTLThunks.cpp:

(JSC::FTL::genericGenerationThunkGenerator):
(JSC::FTL::slowPathCallThunkGenerator):

  • jit/JIT.cpp:

(JSC::JIT::consistencyCheckGenerator):

  • jit/JITCall.cpp:

(JSC::JIT::returnFromBaselineGenerator):

  • jit/JITDisassembler.cpp:

(JSC::JITDisassembler::dump):
(JSC::JITDisassembler::dumpDisassembly):

  • jit/JITDisassembler.h:
  • jit/JITOpcodes.cpp:

(JSC::JIT::valueIsFalseyGenerator):
(JSC::JIT::valueIsTruthyGenerator):
(JSC::JIT::op_throw_handlerGenerator):
(JSC::JIT::op_enter_handlerGenerator):
(JSC::JIT::op_check_traps_handlerGenerator):

  • jit/JITPropertyAccess.cpp:

(JSC::JIT::slow_op_get_by_val_callSlowOperationThenCheckExceptionGenerator):
(JSC::JIT::slow_op_get_private_name_callSlowOperationThenCheckExceptionGenerator):
(JSC::JIT::slow_op_put_by_val_callSlowOperationThenCheckExceptionGenerator):
(JSC::JIT::slow_op_put_private_name_callSlowOperationThenCheckExceptionGenerator):
(JSC::JIT::slow_op_del_by_id_callSlowOperationThenCheckExceptionGenerator):
(JSC::JIT::slow_op_del_by_val_callSlowOperationThenCheckExceptionGenerator):
(JSC::JIT::slow_op_get_by_id_callSlowOperationThenCheckExceptionGenerator):
(JSC::JIT::slow_op_get_by_id_with_this_callSlowOperationThenCheckExceptionGenerator):
(JSC::JIT::slow_op_put_by_id_callSlowOperationThenCheckExceptionGenerator):
(JSC::JIT::generateOpResolveScopeThunk):
(JSC::JIT::slow_op_resolve_scopeGenerator):
(JSC::JIT::generateOpGetFromScopeThunk):
(JSC::JIT::slow_op_get_from_scopeGenerator):
(JSC::JIT::slow_op_put_to_scopeGenerator):

  • jit/SlowPathCall.cpp:

(JSC::JITSlowPathCall::generateThunk):

  • jit/SpecializedThunkJIT.h:

(JSC::SpecializedThunkJIT::finalize):

  • jit/ThunkGenerator.h:
  • jit/ThunkGenerators.cpp:

(JSC::handleExceptionGenerator):
(JSC::handleExceptionWithCallFrameRollbackGenerator):
(JSC::popThunkStackPreservesAndHandleExceptionGenerator):
(JSC::checkExceptionGenerator):
(JSC::throwExceptionFromCallSlowPathGenerator):
(JSC::linkCallThunkGenerator):
(JSC::linkPolymorphicCallThunkGenerator):
(JSC::virtualThunkFor):
(JSC::nativeForGenerator):
(JSC::arityFixupGenerator):
(JSC::unreachableGenerator):
(JSC::stringGetByValGenerator):
(JSC::boundFunctionCallGenerator):
(JSC::remoteFunctionCallGenerator):

  • llint/LLIntThunks.cpp:

(JSC::LLInt::generateThunkWithJumpTo):
(JSC::LLInt::generateThunkWithJumpToPrologue):
(JSC::LLInt::generateThunkWithJumpToLLIntReturnPoint):
(JSC::LLInt::createJSGateThunk):
(JSC::LLInt::createWasmGateThunk):
(JSC::LLInt::createTailCallGate):
(JSC::LLInt::tagGateThunk):
(JSC::LLInt::untagGateThunk):

  • yarr/YarrDisassembler.cpp:

(JSC::Yarr::YarrDisassembler::dump):
(JSC::Yarr::YarrDisassembler::dumpDisassembly):

  • yarr/YarrDisassembler.h:
Location:
trunk/Source/JavaScriptCore
Files:
28 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r294177 r294180  
     12022-05-13  Mark Lam  <mark.lam@apple.com>
     2
     3        Enhance the ARM64Disassembler to print pc indices and better branch target labels.
     4        https://bugs.webkit.org/show_bug.cgi?id=240370
     5
     6        Reviewed by Saam Barati.
     7
     8        Disassemblies used to look like this:
     9
     10             0x10e480ff8:    ldurb    w17, [x0, #7]
     11             0x10e480ffc:    cmp      w17, #0
     12             0x10e481000:    b.hi   0x10e48103c
     13             0x10e481004:    stur     x0, [fp, #-72]
     14             ...
     15             0x10e481040:    movk     x3, #0xfffe, lsl #48
     16             0x10e481044:    b        0x10e4814f4
     17             0x10e481048:    nop     
     18
     19        With this patch, it will now look like this:
     20
     21               <748> 0x10e120aec:    ldurb    w17, [x0, #7]
     22               <752> 0x10e120af0:    cmp      w17, #0
     23               <756> 0x10e120af4:    b.hi     0x10e120b30 -> <816>
     24               <760> 0x10e120af8:    stur     x0, [fp, #-80]
     25               ...
     26               <820> 0x10e120b34:    movk     x3, #0xfffe, lsl #48
     27               <824> 0x10e120b38:    b        0x10e120fc8 -> <1992>
     28               <828> 0x10e120b3c:    nop     
     29
     30        1. Each instruction pc is now prefixed with a pc index i.e. the offset of the
     31           pc address from the start of the compilation unit e.g. <756>.
     32
     33        2. Relative branches now show the branch target as a pc index (effectively, an
     34           internal label in this compilation unit) in addition to the pc address e.g.
     35           the "-> <816>" in:
     36               <756> 0x10e120af4:    b.hi     0x10e120b30 -> <816>
     37
     38           Also fixed a formatting bug where the space between relative branch instructions
     39           and their target pc was short 2 spaces.
     40
     41        3. If the relative branch target is a known thunk, the disassembler will now
     42           print the thunk label e.g.
     43
     44               <828> 0x10e12033c:    bl       0x10e0f0a00 -> <thunk: get_from_scope thunk>
     45              <1476> 0x10e120dc4:    cbnz     x16, 0x10e104100 -> <thunk: handleExceptionWithCallFrameRollback>
     46              <2368> 0x10e121140:    b        0x10e10c000 -> <thunk: DFG OSR exit generation thunk>
     47
     48           Introduced a FINALIZE_THUNK macro that will be used instead of FINALIZE_CODE in
     49           thunk generators.  By doing so, thunk labels will automatically be registered
     50           with the disassembler, and will be used for the above look up.
     51
     52           Thunk label registration is only done if disassembly is enabled.
     53
     54        4. If the branch target is neither an internal label nor a thunk, then the
     55           disassembler will print some useful info about it to the best of its
     56           knowledge e.g.
     57
     58               <168> 0x10e1002e8:    b        0x10e120b60 -> <JIT PC>
     59               <168> 0x10e1002e8:    b        0x10e120b60 -> <LLInt PC>
     60               <168> 0x10e1002e8:    b        0x10e120b60 -> <unknown>
     61
     62        5. The disassemble() function now takes 2 additional arguments: codeStart, and
     63           codeEnd.  These are needed so that the disassembler can compute the pc index
     64           for each instruction, as well as determine if a branch target is internal to
     65           this compilation unit, or pointing out of it.
     66
     67        This feature is currently only supported for the ARM64 disassembler.
     68
     69        Printing of JIT operation labels (via movz + movk + indirect branch) is not yet
     70        supported.
     71
     72        * assembler/LinkBuffer.cpp:
     73        (JSC::LinkBuffer::finalizeCodeWithDisassemblyImpl):
     74        * assembler/LinkBuffer.h:
     75        (JSC::LinkBuffer::setIsThunk):
     76        * b3/air/AirDisassembler.cpp:
     77        (JSC::B3::Air::Disassembler::dump):
     78        * dfg/DFGDisassembler.cpp:
     79        (JSC::DFG::Disassembler::dumpDisassembly):
     80        * dfg/DFGThunks.cpp:
     81        (JSC::DFG::osrExitGenerationThunkGenerator):
     82        (JSC::DFG::osrEntryThunkGenerator):
     83        * disassembler/ARM64/A64DOpcode.cpp:
     84        (JSC::ARM64Disassembler::A64DOpcode::appendPCRelativeOffset):
     85        (JSC::ARM64Disassembler::A64DOpcodeConditionalBranchImmediate::format):
     86        * disassembler/ARM64/A64DOpcode.h:
     87        (JSC::ARM64Disassembler::A64DOpcode::A64DOpcode):
     88        (JSC::ARM64Disassembler::A64DOpcode::appendPCRelativeOffset): Deleted.
     89        * disassembler/ARM64Disassembler.cpp:
     90        (JSC::tryToDisassemble):
     91        * disassembler/CapstoneDisassembler.cpp:
     92        (JSC::tryToDisassemble):
     93        * disassembler/Disassembler.cpp:
     94        (JSC::disassemble):
     95        (JSC::disassembleAsynchronously):
     96        (JSC::ensureThunkLabelMap):
     97        (JSC::registerThunkLabel):
     98        (JSC::labelForThunk):
     99        * disassembler/Disassembler.h:
     100        (JSC::tryToDisassemble):
     101        * disassembler/RISCV64Disassembler.cpp:
     102        (JSC::tryToDisassemble):
     103        * disassembler/X86Disassembler.cpp:
     104        (JSC::tryToDisassemble):
     105        * ftl/FTLThunks.cpp:
     106        (JSC::FTL::genericGenerationThunkGenerator):
     107        (JSC::FTL::slowPathCallThunkGenerator):
     108        * jit/JIT.cpp:
     109        (JSC::JIT::consistencyCheckGenerator):
     110        * jit/JITCall.cpp:
     111        (JSC::JIT::returnFromBaselineGenerator):
     112        * jit/JITDisassembler.cpp:
     113        (JSC::JITDisassembler::dump):
     114        (JSC::JITDisassembler::dumpDisassembly):
     115        * jit/JITDisassembler.h:
     116        * jit/JITOpcodes.cpp:
     117        (JSC::JIT::valueIsFalseyGenerator):
     118        (JSC::JIT::valueIsTruthyGenerator):
     119        (JSC::JIT::op_throw_handlerGenerator):
     120        (JSC::JIT::op_enter_handlerGenerator):
     121        (JSC::JIT::op_check_traps_handlerGenerator):
     122        * jit/JITPropertyAccess.cpp:
     123        (JSC::JIT::slow_op_get_by_val_callSlowOperationThenCheckExceptionGenerator):
     124        (JSC::JIT::slow_op_get_private_name_callSlowOperationThenCheckExceptionGenerator):
     125        (JSC::JIT::slow_op_put_by_val_callSlowOperationThenCheckExceptionGenerator):
     126        (JSC::JIT::slow_op_put_private_name_callSlowOperationThenCheckExceptionGenerator):
     127        (JSC::JIT::slow_op_del_by_id_callSlowOperationThenCheckExceptionGenerator):
     128        (JSC::JIT::slow_op_del_by_val_callSlowOperationThenCheckExceptionGenerator):
     129        (JSC::JIT::slow_op_get_by_id_callSlowOperationThenCheckExceptionGenerator):
     130        (JSC::JIT::slow_op_get_by_id_with_this_callSlowOperationThenCheckExceptionGenerator):
     131        (JSC::JIT::slow_op_put_by_id_callSlowOperationThenCheckExceptionGenerator):
     132        (JSC::JIT::generateOpResolveScopeThunk):
     133        (JSC::JIT::slow_op_resolve_scopeGenerator):
     134        (JSC::JIT::generateOpGetFromScopeThunk):
     135        (JSC::JIT::slow_op_get_from_scopeGenerator):
     136        (JSC::JIT::slow_op_put_to_scopeGenerator):
     137        * jit/SlowPathCall.cpp:
     138        (JSC::JITSlowPathCall::generateThunk):
     139        * jit/SpecializedThunkJIT.h:
     140        (JSC::SpecializedThunkJIT::finalize):
     141        * jit/ThunkGenerator.h:
     142        * jit/ThunkGenerators.cpp:
     143        (JSC::handleExceptionGenerator):
     144        (JSC::handleExceptionWithCallFrameRollbackGenerator):
     145        (JSC::popThunkStackPreservesAndHandleExceptionGenerator):
     146        (JSC::checkExceptionGenerator):
     147        (JSC::throwExceptionFromCallSlowPathGenerator):
     148        (JSC::linkCallThunkGenerator):
     149        (JSC::linkPolymorphicCallThunkGenerator):
     150        (JSC::virtualThunkFor):
     151        (JSC::nativeForGenerator):
     152        (JSC::arityFixupGenerator):
     153        (JSC::unreachableGenerator):
     154        (JSC::stringGetByValGenerator):
     155        (JSC::boundFunctionCallGenerator):
     156        (JSC::remoteFunctionCallGenerator):
     157        * llint/LLIntThunks.cpp:
     158        (JSC::LLInt::generateThunkWithJumpTo):
     159        (JSC::LLInt::generateThunkWithJumpToPrologue):
     160        (JSC::LLInt::generateThunkWithJumpToLLIntReturnPoint):
     161        (JSC::LLInt::createJSGateThunk):
     162        (JSC::LLInt::createWasmGateThunk):
     163        (JSC::LLInt::createTailCallGate):
     164        (JSC::LLInt::tagGateThunk):
     165        (JSC::LLInt::untagGateThunk):
     166        * yarr/YarrDisassembler.cpp:
     167        (JSC::Yarr::YarrDisassembler::dump):
     168        (JSC::Yarr::YarrDisassembler::dumpDisassembly):
     169        * yarr/YarrDisassembler.h:
     170
    11712022-05-13  Adrian Perez de Castro  <aperez@igalia.com>
    2172
  • trunk/Source/JavaScriptCore/assembler/LinkBuffer.cpp

    r288261 r294180  
    11/*
    2  * Copyright (C) 2012-2021 Apple Inc. All rights reserved.
     2 * Copyright (C) 2012-2022 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    7676    va_list argList;
    7777    va_start(argList, format);
    78     out.vprintf(format, argList);
     78
     79    if (m_isThunk) {
     80        va_list preflightArgs;
     81        va_copy(preflightArgs, argList);
     82        size_t stringLength = vsnprintf(nullptr, 0, format, preflightArgs);
     83        va_end(preflightArgs);
     84
     85        char* buffer = 0;
     86        CString label = CString::newUninitialized(stringLength + 1, buffer);
     87        vsnprintf(buffer, stringLength + 1, format, argList);
     88        buffer[stringLength] = '\0';
     89        out.printf("%s", buffer);
     90
     91        registerThunkLabel(result.code().untaggedExecutableAddress(), WTFMove(label));
     92    } else
     93        out.vprintf(format, argList);
     94
    7995    va_end(argList);
    8096    out.printf(":\n");
     
    91107    }
    92108   
     109    void* codeStart = entrypoint<DisassemblyPtrTag>().untaggedExecutableAddress();
     110    void* codeEnd = bitwise_cast<uint8_t*>(codeStart) + size();
     111
    93112    if (Options::asyncDisassembly()) {
    94113        CodeRef<DisassemblyPtrTag> codeRefForDisassembly = result.retagged<DisassemblyPtrTag>();
    95         disassembleAsynchronously(header, WTFMove(codeRefForDisassembly), m_size, "    ");
     114        disassembleAsynchronously(header, WTFMove(codeRefForDisassembly), m_size, codeStart, codeEnd, "    ");
    96115        return result;
    97116    }
    98117   
    99118    dataLog(header);
    100     disassemble(result.retaggedCode<DisassemblyPtrTag>(), m_size, "    ", WTF::dataFile());
     119    disassemble(result.retaggedCode<DisassemblyPtrTag>(), m_size, codeStart, codeEnd, "    ", WTF::dataFile());
    101120   
    102121    return result;
  • trunk/Source/JavaScriptCore/assembler/LinkBuffer.h

    r289417 r294180  
    11/*
    2  * Copyright (C) 2009-2021 Apple Inc. All rights reserved.
     2 * Copyright (C) 2009-2022 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    343343    }
    344344
     345    void setIsThunk() { m_isThunk = true; }
     346
    345347private:
    346348    JS_EXPORT_PRIVATE CodeRef<LinkBufferPtrTag> finalizeCodeWithoutDisassemblyImpl();
     
    418420#endif
    419421    bool m_alreadyDisassembled { false };
     422    bool m_isThunk { false };
    420423    Profile m_profile { Profile::Uncategorized };
    421424    MacroAssemblerCodePtr<LinkBufferPtrTag> m_code;
  • trunk/Source/JavaScriptCore/b3/air/AirDisassembler.cpp

    r261755 r294180  
    11/*
    2  * Copyright (C) 2017-2020 Apple Inc. All rights reserved.
     2 * Copyright (C) 2017-2022 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    7272void Disassembler::dump(Code& code, PrintStream& out, LinkBuffer& linkBuffer, const char* airPrefix, const char* asmPrefix, const ScopedLambda<void(Inst&)>& doToEachInst)
    7373{
     74    void* codeStart = linkBuffer.entrypoint<DisassemblyPtrTag>().untaggedExecutableAddress();
     75    void* codeEnd = bitwise_cast<uint8_t*>(codeStart) +  linkBuffer.size();
     76
    7477    auto dumpAsmRange = [&] (CCallHelpers::Label startLabel, CCallHelpers::Label endLabel) {
    7578        RELEASE_ASSERT(startLabel.isSet());
     
    7881        CodeLocationLabel<DisassemblyPtrTag> end = linkBuffer.locationOf<DisassemblyPtrTag>(endLabel);
    7982        RELEASE_ASSERT(end.dataLocation<uintptr_t>() >= start.dataLocation<uintptr_t>());
    80         disassemble(start, end.dataLocation<uintptr_t>() - start.dataLocation<uintptr_t>(), asmPrefix, out);
     83        disassemble(start, end.dataLocation<uintptr_t>() - start.dataLocation<uintptr_t>(), codeStart, codeEnd, asmPrefix, out);
    8184    };
    8285
  • trunk/Source/JavaScriptCore/dfg/DFGDisassembler.cpp

    r261895 r294180  
    11/*
    2  * Copyright (C) 2012-2018 Apple Inc. All rights reserved.
     2 * Copyright (C) 2012-2022 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    163163    prefixBuffer[prefixLength + amountOfNodeWhiteSpace] = 0;
    164164   
     165    void* codeStart = linkBuffer.entrypoint<DisassemblyPtrTag>().untaggedExecutableAddress();
     166    void* codeEnd = bitwise_cast<uint8_t*>(codeStart) +  linkBuffer.size();
     167
    165168    CodeLocationLabel<DisassemblyPtrTag> start = linkBuffer.locationOf<DisassemblyPtrTag>(previousLabel);
    166169    CodeLocationLabel<DisassemblyPtrTag> end = linkBuffer.locationOf<DisassemblyPtrTag>(currentLabel);
    167170    previousLabel = currentLabel;
    168171    ASSERT(end.dataLocation<uintptr_t>() >= start.dataLocation<uintptr_t>());
    169     disassemble(start, end.dataLocation<uintptr_t>() - start.dataLocation<uintptr_t>(), prefixBuffer.data(), out);
     172    disassemble(start, end.dataLocation<uintptr_t>() - start.dataLocation<uintptr_t>(), codeStart, codeEnd, prefixBuffer.data(), out);
    170173}
    171174
  • trunk/Source/JavaScriptCore/dfg/DFGThunks.cpp

    r293009 r294180  
    11/*
    2  * Copyright (C) 2011-2021 Apple Inc. All rights reserved.
     2 * Copyright (C) 2011-2022 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    128128    patchBuffer.link(functionCall, FunctionPtr<OperationPtrTag>(operationCompileOSRExit));
    129129
    130     return FINALIZE_CODE(patchBuffer, JITThunkPtrTag, "DFG OSR exit generation thunk");
     130    return FINALIZE_THUNK(patchBuffer, JITThunkPtrTag, "DFG OSR exit generation thunk");
    131131}
    132132
     
    176176
    177177    LinkBuffer patchBuffer(jit, GLOBAL_THUNK_ID, LinkBuffer::Profile::DFGOSREntry);
    178     return FINALIZE_CODE(patchBuffer, JITThunkPtrTag, "DFG OSR entry thunk");
     178    return FINALIZE_THUNK(patchBuffer, JITThunkPtrTag, "DFG OSR entry thunk");
    179179}
    180180
  • trunk/Source/JavaScriptCore/disassembler/ARM64/A64DOpcode.cpp

    r279773 r294180  
    11/*
    2  * Copyright (C) 2012-2021 Apple Inc. All rights reserved.
     2 * Copyright (C) 2012-2022 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    3030#include "A64DOpcode.h"
    3131
     32#include "Disassembler.h"
     33#include "ExecutableAllocator.h"
     34#include "GPRInfo.h"
     35#include "LLIntPCRanges.h"
    3236#include <stdarg.h>
    3337#include <stdint.h>
     
    188192}
    189193
     194void A64DOpcode::appendPCRelativeOffset(uint32_t* pc, int32_t immediate)
     195{
     196    uint32_t* targetPC = pc + immediate;
     197    constexpr size_t bufferSize = 101;
     198    char buffer[bufferSize];
     199    const char* targetInfo = buffer;
     200    if (!m_startPC)
     201        targetInfo = "";
     202    else if (targetPC >= m_startPC && targetPC < m_endPC)
     203        snprintf(buffer, bufferSize - 1, " -> <%u>", static_cast<unsigned>((targetPC - m_startPC) * sizeof(uint32_t)));
     204    else if (const char* thunkLabel = labelForThunk(targetPC))
     205        snprintf(buffer, bufferSize - 1, " -> <thunk: %s>", thunkLabel);
     206    else if (isJITPC(targetPC))
     207        targetInfo = " -> <JIT PC>";
     208    else if (LLInt::isLLIntPC(targetPC))
     209        targetInfo = " -> <LLInt PC>";
     210    else
     211        targetInfo = " -> <unknown>";
     212
     213    bufferPrintf("0x%" PRIxPTR "%s", bitwise_cast<uintptr_t>(targetPC),  targetInfo);
     214}
     215
    190216void A64DOpcode::appendRegisterName(unsigned registerNumber, bool is64Bit)
    191217{
     
    413439const char* A64DOpcodeConditionalBranchImmediate::format()
    414440{
    415     bufferPrintf("   b.%-5.5s", conditionName(condition()));
     441    bufferPrintf("   b.%-7.7s", conditionName(condition()));
    416442    appendPCRelativeOffset(m_currentPC, static_cast<int32_t>(immediate19()));
    417443    return m_formatBuffer;
  • trunk/Source/JavaScriptCore/disassembler/ARM64/A64DOpcode.h

    r279773 r294180  
    11/*
    2  * Copyright (C) 2012-2021 Apple Inc. All rights reserved.
     2 * Copyright (C) 2012-2022 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    7474    static void init();
    7575
    76     A64DOpcode()
    77         : m_opcode(0)
     76    A64DOpcode(uint32_t* startPC = nullptr, uint32_t* endPC = nullptr)
     77        : m_startPC(startPC)
     78        , m_endPC(endPC)
     79        , m_opcode(0)
    7880        , m_bufferOffset(0)
    7981    {
     
    186188    }
    187189
    188     void appendPCRelativeOffset(uint32_t* pc, int32_t immediate)
    189     {
    190         bufferPrintf("0x%" PRIxPTR, bitwise_cast<uintptr_t>(pc + immediate));
    191     }
     190    void appendPCRelativeOffset(uint32_t* pc, int32_t immediate);
    192191
    193192    void appendShiftAmount(unsigned amount)
     
    199198
    200199    char m_formatBuffer[bufferSize];
     200    uint32_t* m_startPC;
     201    uint32_t* m_endPC;
    201202    uint32_t* m_currentPC;
    202203    uint32_t m_opcode;
  • trunk/Source/JavaScriptCore/disassembler/ARM64Disassembler.cpp

    r287510 r294180  
    11/*
    2  * Copyright (C) 2012-2018 Apple Inc. All rights reserved.
     2 * Copyright (C) 2012-2022 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    3434namespace JSC {
    3535
    36 bool tryToDisassemble(const MacroAssemblerCodePtr<DisassemblyPtrTag>& codePtr, size_t size, const char* prefix, PrintStream& out)
     36bool tryToDisassemble(const MacroAssemblerCodePtr<DisassemblyPtrTag>& codePtr, size_t size, void* codeStart, void* codeEnd, const char* prefix, PrintStream& out)
    3737{
    38     A64DOpcode arm64Opcode;
    39 
    4038    uint32_t* currentPC = codePtr.untaggedExecutableAddress<uint32_t*>();
    4139    size_t byteCount = size;
    4240
     41    uint32_t* armCodeStart = bitwise_cast<uint32_t*>(codeStart);
     42    uint32_t* armCodeEnd = bitwise_cast<uint32_t*>(codeEnd);
     43    A64DOpcode arm64Opcode(armCodeStart, armCodeEnd);
     44
     45    unsigned pcOffset = (currentPC - armCodeStart) * sizeof(uint32_t);
     46    char pcInfo[25];
    4347    while (byteCount) {
    44         out.printf("%s%#16llx: %s\n", prefix, static_cast<unsigned long long>(bitwise_cast<uintptr_t>(currentPC)), arm64Opcode.disassemble(currentPC));
     48        if (codeStart)
     49            snprintf(pcInfo, sizeof(pcInfo) - 1, "<%u> %#llx", pcOffset, static_cast<unsigned long long>(bitwise_cast<uintptr_t>(currentPC)));
     50        else
     51            snprintf(pcInfo, sizeof(pcInfo) - 1, "%#llx", static_cast<unsigned long long>(bitwise_cast<uintptr_t>(currentPC)));
     52        out.printf("%s%24s: %s\n", prefix, pcInfo, arm64Opcode.disassemble(currentPC));
     53        pcOffset += sizeof(uint32_t);
    4554        currentPC++;
    4655        byteCount -= sizeof(uint32_t);
  • trunk/Source/JavaScriptCore/disassembler/CapstoneDisassembler.cpp

    r287510 r294180  
    3434namespace JSC {
    3535
    36 bool tryToDisassemble(const MacroAssemblerCodePtr<DisassemblyPtrTag>& codePtr, size_t size, const char* prefix, PrintStream& out)
     36bool tryToDisassemble(const MacroAssemblerCodePtr<DisassemblyPtrTag>& codePtr, size_t size, void*, void*, const char* prefix, PrintStream& out)
    3737{
    3838    csh handle;
  • trunk/Source/JavaScriptCore/disassembler/Disassembler.cpp

    r277958 r294180  
    11/*
    2  * Copyright (C) 2012-2018 Apple Inc. All rights reserved.
     2 * Copyright (C) 2012-2022 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    3737namespace JSC {
    3838
    39 void disassemble(const MacroAssemblerCodePtr<DisassemblyPtrTag>& codePtr, size_t size, const char* prefix, PrintStream& out)
     39using ThunkLabelMap = HashMap<void*, CString>;
     40LazyNeverDestroyed<ThunkLabelMap> thunkLabelMap;
     41
     42void disassemble(const MacroAssemblerCodePtr<DisassemblyPtrTag>& codePtr, size_t size, void* codeStart, void* codeEnd, const char* prefix, PrintStream& out)
    4043{
    41     if (tryToDisassemble(codePtr, size, prefix, out))
     44    if (tryToDisassemble(codePtr, size, codeStart, codeEnd, prefix, out))
    4245        return;
    4346   
     
    6669    MacroAssemblerCodeRef<DisassemblyPtrTag> codeRef;
    6770    size_t size { 0 };
     71    void* codeStart { nullptr };
     72    void* codeEnd { nullptr };
    6873    const char* prefix { nullptr };
    6974};
     
    106111
    107112            dataLog(task->header);
    108             disassemble(task->codeRef.code(), task->size, task->prefix, WTF::dataFile());
     113            disassemble(task->codeRef.code(), task->size, task->codeStart, task->codeEnd, task->prefix, WTF::dataFile());
    109114        }
    110115    }
     
    132137
    133138void disassembleAsynchronously(
    134     const CString& header, const MacroAssemblerCodeRef<DisassemblyPtrTag>& codeRef, size_t size, const char* prefix)
     139    const CString& header, const MacroAssemblerCodeRef<DisassemblyPtrTag>& codeRef, size_t size, void* codeStart, void* codeEnd, const char* prefix)
    135140{
    136141    std::unique_ptr<DisassemblyTask> task = makeUnique<DisassemblyTask>();
     
    138143    task->codeRef = codeRef;
    139144    task->size = size;
     145    task->codeStart = codeStart;
     146    task->codeEnd = codeEnd;
    140147    task->prefix = prefix;
    141148   
     
    151158}
    152159
     160static ThunkLabelMap& ensureThunkLabelMap()
     161{
     162    static std::once_flag onceKey;
     163    std::call_once(onceKey, [] {
     164        thunkLabelMap.construct();
     165    });
     166    return thunkLabelMap.get();
     167}
     168
     169void registerThunkLabel(void* thunkAddress, CString&& label)
     170{
     171    ensureThunkLabelMap().add(thunkAddress, WTFMove(label));
     172}
     173
     174const char* labelForThunk(void* thunkAddress)
     175{
     176    auto& map = ensureThunkLabelMap();
     177    auto it = map.find(thunkAddress);
     178    if (it == map.end())
     179        return nullptr;
     180    return it->value.data();
     181}
     182
    153183} // namespace JSC
    154184
  • trunk/Source/JavaScriptCore/disassembler/Disassembler.h

    r231027 r294180  
    11/*
    2  * Copyright (C) 2012-2018 Apple Inc. All rights reserved.
     2 * Copyright (C) 2012-2022 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    3838
    3939#if ENABLE(DISASSEMBLER)
    40 bool tryToDisassemble(const MacroAssemblerCodePtr<DisassemblyPtrTag>&, size_t, const char* prefix, PrintStream&);
     40bool tryToDisassemble(const MacroAssemblerCodePtr<DisassemblyPtrTag>&, size_t, void* codeStart, void* codeEnd, const char* prefix, PrintStream&);
    4141#else
    42 inline bool tryToDisassemble(const MacroAssemblerCodePtr<DisassemblyPtrTag>&, size_t, const char*, PrintStream&)
     42inline bool tryToDisassemble(const MacroAssemblerCodePtr<DisassemblyPtrTag>&, size_t, void*, void*, const char*, PrintStream&)
    4343{
    4444    return false;
     
    4646#endif
    4747
     48inline bool tryToDisassemble(const MacroAssemblerCodePtr<DisassemblyPtrTag>& code, size_t size, const char* prefix, PrintStream& out)
     49{
     50    return tryToDisassemble(code, size, nullptr, nullptr, prefix, out);
     51}
     52
    4853// Prints either the disassembly, or a line of text indicating that disassembly failed and
    4954// the range of machine code addresses.
    50 void disassemble(const MacroAssemblerCodePtr<DisassemblyPtrTag>&, size_t, const char* prefix, PrintStream& out);
     55void disassemble(const MacroAssemblerCodePtr<DisassemblyPtrTag>&, size_t, void* codeStart, void* codeEnd, const char* prefix, PrintStream& out);
    5156
    5257// Asynchronous disassembly. This happens on another thread, and calls the provided
    5358// callback when the disassembly is done.
    5459void disassembleAsynchronously(
    55     const CString& header, const MacroAssemblerCodeRef<DisassemblyPtrTag>&, size_t, const char* prefix);
     60    const CString& header, const MacroAssemblerCodeRef<DisassemblyPtrTag>&, size_t, void* codeStart, void* codeEnd, const char* prefix);
    5661
    5762JS_EXPORT_PRIVATE void waitForAsynchronousDisassembly();
    5863
     64void registerThunkLabel(void* thunkAddress, CString&& label);
     65const char* labelForThunk(void* thunkAddress);
     66
    5967} // namespace JSC
  • trunk/Source/JavaScriptCore/disassembler/RISCV64Disassembler.cpp

    r287510 r294180  
    634634} // namespace RISCV64Disassembler
    635635
    636 bool tryToDisassemble(const MacroAssemblerCodePtr<DisassemblyPtrTag>& codePtr, size_t size, const char* prefix, PrintStream& out)
     636bool tryToDisassemble(const MacroAssemblerCodePtr<DisassemblyPtrTag>& codePtr, size_t size, void*, void*, const char* prefix, PrintStream& out)
    637637{
    638638    uint32_t* currentPC = codePtr.untaggedExecutableAddress<uint32_t*>();
  • trunk/Source/JavaScriptCore/disassembler/X86Disassembler.cpp

    r287510 r294180  
    3434namespace JSC {
    3535
    36 bool tryToDisassemble(const MacroAssemblerCodePtr<DisassemblyPtrTag>& codePtr, size_t size, const char* prefix, PrintStream& out)
     36bool tryToDisassemble(const MacroAssemblerCodePtr<DisassemblyPtrTag>& codePtr, size_t size, void*, void*, const char* prefix, PrintStream& out)
    3737{
    3838    ZydisDecoder decoder;
  • trunk/Source/JavaScriptCore/ftl/FTLThunks.cpp

    r291935 r294180  
    121121    LinkBuffer patchBuffer(jit, GLOBAL_THUNK_ID, LinkBuffer::Profile::FTLThunk);
    122122    patchBuffer.link(functionCall, generationFunction.retagged<OperationPtrTag>());
    123     return FINALIZE_CODE(patchBuffer, JITThunkPtrTag, "%s", name);
     123    return FINALIZE_THUNK(patchBuffer, JITThunkPtrTag, "%s", name);
    124124}
    125125
     
    244244    if (key.callTarget())
    245245        patchBuffer.link(call, key.callTarget());
    246     return FINALIZE_CODE(patchBuffer, JITThunkPtrTag, "FTL slow path call thunk for %s", toCString(key).data());
     246    return FINALIZE_THUNK(patchBuffer, JITThunkPtrTag, "FTL slow path call thunk for %s", toCString(key).data());
    247247}
    248248
  • trunk/Source/JavaScriptCore/jit/JIT.cpp

    r293009 r294180  
    11/*
    2  * Copyright (C) 2008-2021 Apple Inc. All rights reserved.
     2 * Copyright (C) 2008-2022 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    706706
    707707    LinkBuffer patchBuffer(jit, GLOBAL_THUNK_ID, LinkBuffer::Profile::ExtraCTIThunk);
    708     return FINALIZE_CODE(patchBuffer, JITThunkPtrTag, "Baseline: generateConsistencyCheck");
     708    return FINALIZE_THUNK(patchBuffer, JITThunkPtrTag, "Baseline: generateConsistencyCheck");
    709709}
    710710
  • trunk/Source/JavaScriptCore/jit/JITCall.cpp

    r290768 r294180  
    11/*
    2  * Copyright (C) 2008-2019 Apple Inc. All rights reserved.
     2 * Copyright (C) 2008-2022 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    6464
    6565    LinkBuffer patchBuffer(jit, GLOBAL_THUNK_ID, LinkBuffer::Profile::ExtraCTIThunk);
    66     return FINALIZE_CODE(patchBuffer, JITThunkPtrTag, "Baseline: op_ret_handler");
     66    return FINALIZE_THUNK(patchBuffer, JITThunkPtrTag, "Baseline: op_ret_handler");
    6767}
    6868
  • trunk/Source/JavaScriptCore/jit/JITDisassembler.cpp

    r291417 r294180  
    11/*
    2  * Copyright (C) 2012-2018 Apple Inc. All rights reserved.
     2 * Copyright (C) 2012-2022 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    5252void JITDisassembler::dump(PrintStream& out, LinkBuffer& linkBuffer)
    5353{
     54    m_codeStart = linkBuffer.entrypoint<DisassemblyPtrTag>().untaggedExecutableAddress();
     55    m_codeEnd = bitwise_cast<uint8_t*>(m_codeStart) + linkBuffer.size();
     56
    5457    dumpHeader(out, linkBuffer);
    5558    dumpDisassembly(out, linkBuffer, m_startOfCode, m_labelForBytecodeIndexInMainPath[0]);
     
    163166    CodeLocationLabel<DisassemblyPtrTag> fromLocation = linkBuffer.locationOf<DisassemblyPtrTag>(from);
    164167    CodeLocationLabel<DisassemblyPtrTag> toLocation = linkBuffer.locationOf<DisassemblyPtrTag>(to);
    165     disassemble(fromLocation, toLocation.dataLocation<uintptr_t>() - fromLocation.dataLocation<uintptr_t>(), "        ", out);
     168    disassemble(fromLocation, toLocation.dataLocation<uintptr_t>() - fromLocation.dataLocation<uintptr_t>(), m_codeStart, m_codeEnd, "        ", out);
    166169}
    167170
  • trunk/Source/JavaScriptCore/jit/JITDisassembler.h

    r251690 r294180  
    11/*
    2  * Copyright (C) 2012 Apple Inc. All rights reserved.
     2 * Copyright (C) 2012-2022 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    8585    MacroAssembler::Label m_endOfSlowPath;
    8686    MacroAssembler::Label m_endOfCode;
     87    void* m_codeStart { nullptr };
     88    void* m_codeEnd { nullptr };
    8789};
    8890
  • trunk/Source/JavaScriptCore/jit/JITOpcodes.cpp

    r293009 r294180  
    11/*
    2  * Copyright (C) 2009-2021 Apple Inc. All rights reserved.
     2 * Copyright (C) 2009-2022 Apple Inc. All rights reserved.
    33 * Copyright (C) 2010 Patrick Gansterer <paroga@paroga.com>
    44 *
     
    479479
    480480    LinkBuffer patchBuffer(jit, GLOBAL_THUNK_ID, LinkBuffer::Profile::ExtraCTIThunk);
    481     return FINALIZE_CODE(patchBuffer, JITThunkPtrTag, "Baseline: valueIsFalsey");
     481    return FINALIZE_THUNK(patchBuffer, JITThunkPtrTag, "Baseline: valueIsFalsey");
    482482}
    483483
     
    665665
    666666    LinkBuffer patchBuffer(jit, GLOBAL_THUNK_ID, LinkBuffer::Profile::ExtraCTIThunk);
    667     return FINALIZE_CODE(patchBuffer, JITThunkPtrTag, "Baseline: valueIsTruthy");
     667    return FINALIZE_THUNK(patchBuffer, JITThunkPtrTag, "Baseline: valueIsTruthy");
    668668}
    669669
     
    735735    LinkBuffer patchBuffer(jit, GLOBAL_THUNK_ID, LinkBuffer::Profile::ExtraCTIThunk);
    736736    patchBuffer.link(operation, FunctionPtr<OperationPtrTag>(operationThrow));
    737     return FINALIZE_CODE(patchBuffer, JITThunkPtrTag, "Baseline: op_throw_handler");
     737    return FINALIZE_THUNK(patchBuffer, JITThunkPtrTag, "Baseline: op_throw_handler");
    738738}
    739739
     
    13241324        patchBuffer.link(operationOptimizeCall, FunctionPtr<OperationPtrTag>(operationOptimize));
    13251325#endif
    1326     return FINALIZE_CODE(patchBuffer, JITThunkPtrTag, "Baseline: op_enter_handler");
     1326    return FINALIZE_THUNK(patchBuffer, JITThunkPtrTag, "Baseline: op_enter_handler");
    13271327}
    13281328
     
    15691569    patchBuffer.link(operation, FunctionPtr<OperationPtrTag>(operationHandleTraps));
    15701570    patchBuffer.link(exceptionCheck, CodeLocationLabel(vm.getCTIStub(checkExceptionGenerator).retaggedCode<NoPtrTag>()));
    1571     return FINALIZE_CODE(patchBuffer, JITThunkPtrTag, "Baseline: op_check_traps_handler");
     1571    return FINALIZE_THUNK(patchBuffer, JITThunkPtrTag, "Baseline: op_check_traps_handler");
    15721572}
    15731573
  • trunk/Source/JavaScriptCore/jit/JITPropertyAccess.cpp

    r292445 r294180  
    11/*
    2  * Copyright (C) 2008-2021 Apple Inc. All rights reserved.
     2 * Copyright (C) 2008-2022 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    162162    LinkBuffer patchBuffer(jit, GLOBAL_THUNK_ID, LinkBuffer::Profile::ExtraCTIThunk);
    163163    patchBuffer.link(exceptionCheck, CodeLocationLabel(vm.getCTIStub(checkExceptionGenerator).retaggedCode<NoPtrTag>()));
    164     return FINALIZE_CODE(patchBuffer, JITThunkPtrTag, "Baseline: slow_op_get_by_val_callSlowOperationThenCheckException");
     164    return FINALIZE_THUNK(patchBuffer, JITThunkPtrTag, "Baseline: slow_op_get_by_val_callSlowOperationThenCheckException");
    165165}
    166166
     
    256256    LinkBuffer patchBuffer(jit, GLOBAL_THUNK_ID, LinkBuffer::Profile::ExtraCTIThunk);
    257257    patchBuffer.link(exceptionCheck, CodeLocationLabel(vm.getCTIStub(checkExceptionGenerator).retaggedCode<NoPtrTag>()));
    258     return FINALIZE_CODE(patchBuffer, JITThunkPtrTag, "Baseline: slow_op_get_private_name_callSlowOperationThenCheckException");
     258    return FINALIZE_THUNK(patchBuffer, JITThunkPtrTag, "Baseline: slow_op_get_private_name_callSlowOperationThenCheckException");
    259259}
    260260
     
    478478    LinkBuffer patchBuffer(jit, GLOBAL_THUNK_ID, LinkBuffer::Profile::ExtraCTIThunk);
    479479    patchBuffer.link(exceptionCheck, CodeLocationLabel(vm.getCTIStub(checkExceptionGenerator).retaggedCode<NoPtrTag>()));
    480     return FINALIZE_CODE(patchBuffer, JITThunkPtrTag, "Baseline: slow_op_put_by_val_callSlowOperationThenCheckException");
     480    return FINALIZE_THUNK(patchBuffer, JITThunkPtrTag, "Baseline: slow_op_put_by_val_callSlowOperationThenCheckException");
    481481}
    482482
     
    578578    LinkBuffer patchBuffer(jit, GLOBAL_THUNK_ID, LinkBuffer::Profile::ExtraCTIThunk);
    579579    patchBuffer.link(exceptionCheck, CodeLocationLabel(vm.getCTIStub(checkExceptionGenerator).retaggedCode<NoPtrTag>()));
    580     return FINALIZE_CODE(patchBuffer, JITThunkPtrTag, "Baseline: slow_op_put_private_name_callSlowOperationThenCheckException");
     580    return FINALIZE_THUNK(patchBuffer, JITThunkPtrTag, "Baseline: slow_op_put_private_name_callSlowOperationThenCheckException");
    581581}
    582582
     
    755755    LinkBuffer patchBuffer(jit, GLOBAL_THUNK_ID, LinkBuffer::Profile::ExtraCTIThunk);
    756756    patchBuffer.link(exceptionCheck, CodeLocationLabel(vm.getCTIStub(checkExceptionGenerator).retaggedCode<NoPtrTag>()));
    757     return FINALIZE_CODE(patchBuffer, JITThunkPtrTag, "Baseline: slow_op_del_by_id_callSlowOperationThenCheckException");
     757    return FINALIZE_THUNK(patchBuffer, JITThunkPtrTag, "Baseline: slow_op_del_by_id_callSlowOperationThenCheckException");
    758758}
    759759
     
    866866    LinkBuffer patchBuffer(jit, GLOBAL_THUNK_ID, LinkBuffer::Profile::ExtraCTIThunk);
    867867    patchBuffer.link(exceptionCheck, CodeLocationLabel(vm.getCTIStub(checkExceptionGenerator).retaggedCode<NoPtrTag>()));
    868     return FINALIZE_CODE(patchBuffer, JITThunkPtrTag, "Baseline: slow_op_del_by_val_prepareCall");
     868    return FINALIZE_THUNK(patchBuffer, JITThunkPtrTag, "Baseline: slow_op_del_by_val_prepareCall");
    869869}
    870870
     
    10911091    LinkBuffer patchBuffer(jit, GLOBAL_THUNK_ID, LinkBuffer::Profile::ExtraCTIThunk);
    10921092    patchBuffer.link(exceptionCheck, CodeLocationLabel(vm.getCTIStub(checkExceptionGenerator).retaggedCode<NoPtrTag>()));
    1093     return FINALIZE_CODE(patchBuffer, JITThunkPtrTag, "Baseline: slow_op_get_by_id_callSlowOperationThenCheckException");
     1093    return FINALIZE_THUNK(patchBuffer, JITThunkPtrTag, "Baseline: slow_op_get_by_id_callSlowOperationThenCheckException");
    10941094}
    10951095
     
    11911191    LinkBuffer patchBuffer(jit, GLOBAL_THUNK_ID, LinkBuffer::Profile::ExtraCTIThunk);
    11921192    patchBuffer.link(exceptionCheck, CodeLocationLabel(vm.getCTIStub(checkExceptionGenerator).retaggedCode<NoPtrTag>()));
    1193     return FINALIZE_CODE(patchBuffer, JITThunkPtrTag, "Baseline: slow_op_get_by_id_with_this_callSlowOperationThenCheckException");
     1193    return FINALIZE_THUNK(patchBuffer, JITThunkPtrTag, "Baseline: slow_op_get_by_id_with_this_callSlowOperationThenCheckException");
    11941194}
    11951195
     
    12991299    LinkBuffer patchBuffer(jit, GLOBAL_THUNK_ID, LinkBuffer::Profile::ExtraCTIThunk);
    13001300    patchBuffer.link(exceptionCheck, CodeLocationLabel(vm.getCTIStub(checkExceptionGenerator).retaggedCode<NoPtrTag>()));
    1301     return FINALIZE_CODE(patchBuffer, JITThunkPtrTag, "Baseline: slow_op_put_by_id_callSlowOperationThenCheckException");
     1301    return FINALIZE_THUNK(patchBuffer, JITThunkPtrTag, "Baseline: slow_op_put_by_id_callSlowOperationThenCheckException");
    13021302}
    13031303
     
    16891689    LinkBuffer patchBuffer(jit, GLOBAL_THUNK_ID, LinkBuffer::Profile::Thunk);
    16901690    patchBuffer.link(slowCase, CodeLocationLabel(vm.getCTIStub(slow_op_resolve_scopeGenerator).retaggedCode<NoPtrTag>()));
    1691     return FINALIZE_CODE(patchBuffer, JITThunkPtrTag, "resolve_scope thunk");
     1691    return FINALIZE_THUNK(patchBuffer, JITThunkPtrTag, "resolve_scope thunk");
    16921692}
    16931693
     
    17271727    patchBuffer.link(operation, FunctionPtr<OperationPtrTag>(operationResolveScopeForBaseline));
    17281728    patchBuffer.link(exceptionCheck, CodeLocationLabel(vm.getCTIStub(checkExceptionGenerator).retaggedCode<NoPtrTag>()));
    1729     return FINALIZE_CODE(patchBuffer, JITThunkPtrTag, "Baseline: slow_op_resolve_scope");
     1729    return FINALIZE_THUNK(patchBuffer, JITThunkPtrTag, "Baseline: slow_op_resolve_scope");
    17301730}
    17311731
     
    19051905    LinkBuffer patchBuffer(jit, GLOBAL_THUNK_ID, LinkBuffer::Profile::Thunk);
    19061906    patchBuffer.link(slowCase, CodeLocationLabel(vm.getCTIStub(slow_op_get_from_scopeGenerator).retaggedCode<NoPtrTag>()));
    1907     return FINALIZE_CODE(patchBuffer, JITThunkPtrTag, "get_from_scope thunk");
     1907    return FINALIZE_THUNK(patchBuffer, JITThunkPtrTag, "get_from_scope thunk");
    19081908}
    19091909
     
    19581958    auto handler = vm.getCTIStub(popThunkStackPreservesAndHandleExceptionGenerator);
    19591959    patchBuffer.link(jumpToHandler, CodeLocationLabel(handler.retaggedCode<NoPtrTag>()));
    1960     return FINALIZE_CODE(patchBuffer, JITThunkPtrTag, "Baseline: slow_op_get_from_scope");
     1960    return FINALIZE_THUNK(patchBuffer, JITThunkPtrTag, "Baseline: slow_op_get_from_scope");
    19611961}
    19621962
     
    21572157    patchBuffer.link(operation, FunctionPtr<OperationPtrTag>(operationPutToScope));
    21582158    patchBuffer.link(exceptionCheck, CodeLocationLabel(vm.getCTIStub(checkExceptionGenerator).retaggedCode<NoPtrTag>()));
    2159     return FINALIZE_CODE(patchBuffer, JITThunkPtrTag, "Baseline: slow_op_put_to_scope");
     2159    return FINALIZE_THUNK(patchBuffer, JITThunkPtrTag, "Baseline: slow_op_put_to_scope");
    21602160}
    21612161
  • trunk/Source/JavaScriptCore/jit/SlowPathCall.cpp

    r290647 r294180  
    11/*
    2  * Copyright (C) 2021 Apple Inc. All rights reserved.
     2 * Copyright (C) 2021-2022 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    9595    patchBuffer.link(call, FunctionPtr<OperationPtrTag>(slowPathFunction));
    9696    patchBuffer.link(exceptionCheck, CodeLocationLabel(vm.getCTIStub(checkExceptionGenerator).retaggedCode<NoPtrTag>()));
    97     return FINALIZE_CODE(patchBuffer, JITThunkPtrTag, "SlowPathCall");
     97    return FINALIZE_THUNK(patchBuffer, JITThunkPtrTag, "SlowPathCall");
    9898}
    9999
  • trunk/Source/JavaScriptCore/jit/SpecializedThunkJIT.h

    r277928 r294180  
    11/*
    2  * Copyright (C) 2010-2021 Apple Inc. All rights reserved.
     2 * Copyright (C) 2010-2022 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    160160            for (unsigned i = 0; i < m_calls.size(); i++)
    161161                patchBuffer.link(m_calls[i].first, m_calls[i].second);
    162             return FINALIZE_CODE(patchBuffer, JITThunkPtrTag, "Specialized thunk for %s", thunkKind);
     162            return FINALIZE_THUNK(patchBuffer, JITThunkPtrTag, "Specialized thunk for %s", thunkKind);
    163163        }
    164164
  • trunk/Source/JavaScriptCore/jit/ThunkGenerator.h

    r249175 r294180  
    11/*
    2  * Copyright (C) 2012-2019 Apple Inc. All rights reserved.
     2 * Copyright (C) 2012-2022 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    3636using ThunkGenerator = MacroAssemblerCodeRef<JITThunkPtrTag> (*)(VM&);
    3737
     38#define FINALIZE_THUNK(linkBufferReference, resultPtrTag, ...) \
     39    (linkBufferReference.setIsThunk(), FINALIZE_CODE(linkBufferReference, resultPtrTag, __VA_ARGS__))
     40
    3841} // namespace JSC
    3942
  • trunk/Source/JavaScriptCore/jit/ThunkGenerators.cpp

    r293203 r294180  
    3434#include "MaxFrameExtentForSlowPathCall.h"
    3535#include "SpecializedThunkJIT.h"
     36#include "ThunkGenerator.h"
    3637#include <wtf/InlineASM.h>
    3738#include <wtf/StdIntExtras.h>
     
    5657    LinkBuffer patchBuffer(jit, GLOBAL_THUNK_ID, LinkBuffer::Profile::ExtraCTIThunk);
    5758    patchBuffer.link(operation, FunctionPtr<OperationPtrTag>(operationLookupExceptionHandler));
    58     return FINALIZE_CODE(patchBuffer, JITThunkPtrTag, "handleException");
     59    return FINALIZE_THUNK(patchBuffer, JITThunkPtrTag, "handleException");
    5960}
    6061
     
    7273    LinkBuffer patchBuffer(jit, GLOBAL_THUNK_ID, LinkBuffer::Profile::ExtraCTIThunk);
    7374    patchBuffer.link(operation, FunctionPtr<OperationPtrTag>(operationLookupExceptionHandlerFromCallerFrame));
    74     return FINALIZE_CODE(patchBuffer, JITThunkPtrTag, "handleExceptionWithCallFrameRollback");
     75    return FINALIZE_THUNK(patchBuffer, JITThunkPtrTag, "handleExceptionWithCallFrameRollback");
    7576}
    7677
     
    8990    auto handler = vm.getCTIStub(handleExceptionGenerator);
    9091    patchBuffer.link(continuation, CodeLocationLabel(handler.retaggedCode<NoPtrTag>()));
    91     return FINALIZE_CODE(patchBuffer, JITThunkPtrTag, "popThunkStackPreservesAndHandleException");
     92    return FINALIZE_THUNK(patchBuffer, JITThunkPtrTag, "popThunkStackPreservesAndHandleException");
    9293}
    9394
     
    119120    LinkBuffer patchBuffer(jit, GLOBAL_THUNK_ID, LinkBuffer::Profile::ExtraCTIThunk);
    120121    patchBuffer.link(handleException, CodeLocationLabel(vm.getCTIStub(handlerGenerator).retaggedCode<NoPtrTag>()));
    121     return FINALIZE_CODE(patchBuffer, JITThunkPtrTag, "CheckException");
     122    return FINALIZE_THUNK(patchBuffer, JITThunkPtrTag, "CheckException");
    122123}
    123124
     
    164165
    165166    LinkBuffer patchBuffer(jit, GLOBAL_THUNK_ID, LinkBuffer::Profile::Thunk);
    166     return FINALIZE_CODE(patchBuffer, JITThunkPtrTag, "Throw exception from call slow path thunk");
     167    return FINALIZE_THUNK(patchBuffer, JITThunkPtrTag, "Throw exception from call slow path thunk");
    167168}
    168169
     
    233234
    234235    LinkBuffer patchBuffer(jit, GLOBAL_THUNK_ID, LinkBuffer::Profile::Thunk);
    235     return FINALIZE_CODE(patchBuffer, JITThunkPtrTag, "Link call slow path thunk");
     236    return FINALIZE_THUNK(patchBuffer, JITThunkPtrTag, "Link call slow path thunk");
    236237}
    237238
     
    245246
    246247    LinkBuffer patchBuffer(jit, GLOBAL_THUNK_ID, LinkBuffer::Profile::Thunk);
    247     return FINALIZE_CODE(patchBuffer, JITThunkPtrTag, "Link polymorphic call slow path thunk");
     248    return FINALIZE_THUNK(patchBuffer, JITThunkPtrTag, "Link polymorphic call slow path thunk");
    248249}
    249250
     
    334335
    335336    LinkBuffer patchBuffer(jit, GLOBAL_THUNK_ID, LinkBuffer::Profile::VirtualThunk);
    336     return FINALIZE_CODE(
     337    return FINALIZE_THUNK(
    337338        patchBuffer, JITThunkPtrTag,
    338339        "Virtual %s slow path thunk",
     
    487488
    488489    LinkBuffer patchBuffer(jit, GLOBAL_THUNK_ID, LinkBuffer::Profile::Thunk);
    489     return FINALIZE_CODE(patchBuffer, JITThunkPtrTag, "%s %s%s trampoline", thunkFunctionType == ThunkFunctionType::JSFunction ? "native" : "internal", entryType == EnterViaJumpWithSavedTags ? "Tail With Saved Tags " : entryType == EnterViaJumpWithoutSavedTags ? "Tail Without Saved Tags " : "", toCString(kind).data());
     490    return FINALIZE_THUNK(patchBuffer, JITThunkPtrTag, "%s %s%s trampoline", thunkFunctionType == ThunkFunctionType::JSFunction ? "native" : "internal", entryType == EnterViaJumpWithSavedTags ? "Tail With Saved Tags " : entryType == EnterViaJumpWithoutSavedTags ? "Tail Without Saved Tags " : "", toCString(kind).data());
    490491}
    491492
     
    666667
    667668    LinkBuffer patchBuffer(jit, GLOBAL_THUNK_ID, LinkBuffer::Profile::Thunk);
    668     return FINALIZE_CODE(patchBuffer, JITThunkPtrTag, "fixup arity");
     669    return FINALIZE_THUNK(patchBuffer, JITThunkPtrTag, "fixup arity");
    669670}
    670671
     
    676677
    677678    LinkBuffer patchBuffer(jit, GLOBAL_THUNK_ID, LinkBuffer::Profile::Thunk);
    678     return FINALIZE_CODE(patchBuffer, JITThunkPtrTag, "unreachable thunk");
     679    return FINALIZE_THUNK(patchBuffer, JITThunkPtrTag, "unreachable thunk");
    679680}
    680681
     
    727728
    728729    LinkBuffer patchBuffer(jit, GLOBAL_THUNK_ID, LinkBuffer::Profile::Thunk);
    729     return FINALIZE_CODE(patchBuffer, JITThunkPtrTag, "String get_by_val stub");
     730    return FINALIZE_THUNK(patchBuffer, JITThunkPtrTag, "String get_by_val stub");
    730731}
    731732
     
    14181419    LinkBuffer linkBuffer(jit, GLOBAL_THUNK_ID, LinkBuffer::Profile::BoundFunctionThunk);
    14191420    linkBuffer.link(noCode, CodeLocationLabel<JITThunkPtrTag>(vm.jitStubs->ctiNativeTailCallWithoutSavedTags(vm)));
    1420     return FINALIZE_CODE(
    1421         linkBuffer, JITThunkPtrTag, "Specialized thunk for bound function calls with no arguments");
     1421    return FINALIZE_THUNK(linkBuffer, JITThunkPtrTag, "Specialized thunk for bound function calls with no arguments");
    14221422}
    14231423
     
    16281628    LinkBuffer linkBuffer(jit, GLOBAL_THUNK_ID, LinkBuffer::Profile::RemoteFunctionThunk);
    16291629    linkBuffer.link(noCode, CodeLocationLabel<JITThunkPtrTag>(vm.jitStubs->ctiNativeTailCallWithoutSavedTags(vm)));
    1630     return FINALIZE_CODE(
    1631         linkBuffer, JITThunkPtrTag, "Specialized thunk for remote function calls");
     1630    return FINALIZE_THUNK(linkBuffer, JITThunkPtrTag, "Specialized thunk for remote function calls");
    16321631}
    16331632
  • trunk/Source/JavaScriptCore/llint/LLIntThunks.cpp

    r286901 r294180  
    11/*
    2  * Copyright (C) 2012-2021 Apple Inc. All rights reserved.
     2 * Copyright (C) 2012-2022 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    8383
    8484    LinkBuffer patchBuffer(jit, GLOBAL_THUNK_ID, LinkBuffer::Profile::LLIntThunk);
    85     return FINALIZE_CODE(patchBuffer, tag, "LLInt %s thunk", thunkKind);
     85    return FINALIZE_THUNK(patchBuffer, tag, "LLInt %s thunk", thunkKind);
    8686}
    8787
     
    110110
    111111    LinkBuffer patchBuffer(jit, GLOBAL_THUNK_ID, LinkBuffer::Profile::LLIntThunk);
    112     return FINALIZE_CODE(patchBuffer, tag, "LLInt %s jump to prologue thunk", thunkKind);
     112    return FINALIZE_THUNK(patchBuffer, tag, "LLInt %s jump to prologue thunk", thunkKind);
    113113}
    114114
     
    120120    jit.farJump(CCallHelpers::TrustedImmPtr(target), OperationPtrTag);
    121121    LinkBuffer patchBuffer(jit, GLOBAL_THUNK_ID, LinkBuffer::Profile::LLIntThunk);
    122     return FINALIZE_CODE(patchBuffer, tag, "LLInt %s return point thunk", thunkKind);
     122    return FINALIZE_THUNK(patchBuffer, tag, "LLInt %s return point thunk", thunkKind);
    123123}
    124124
     
    420420
    421421    LinkBuffer patchBuffer(jit, GLOBAL_THUNK_ID, LinkBuffer::Profile::LLIntThunk);
    422     return FINALIZE_CODE(patchBuffer, NativeToJITGatePtrTag, "LLInt %s call gate thunk", name);
     422    return FINALIZE_THUNK(patchBuffer, NativeToJITGatePtrTag, "LLInt %s call gate thunk", name);
    423423}
    424424
     
    432432
    433433    LinkBuffer patchBuffer(jit, GLOBAL_THUNK_ID, LinkBuffer::Profile::LLIntThunk);
    434     return FINALIZE_CODE(patchBuffer, NativeToJITGatePtrTag, "LLInt %s wasm call gate thunk", name);
     434    return FINALIZE_THUNK(patchBuffer, NativeToJITGatePtrTag, "LLInt %s wasm call gate thunk", name);
    435435}
    436436
     
    446446
    447447    LinkBuffer patchBuffer(jit, GLOBAL_THUNK_ID, LinkBuffer::Profile::LLIntThunk);
    448     return FINALIZE_CODE(patchBuffer, NativeToJITGatePtrTag, "LLInt tail call gate thunk");
     448    return FINALIZE_THUNK(patchBuffer, NativeToJITGatePtrTag, "LLInt tail call gate thunk");
    449449}
    450450
     
    537537
    538538    LinkBuffer patchBuffer(jit, GLOBAL_THUNK_ID, LinkBuffer::Profile::LLIntThunk);
    539     return FINALIZE_CODE(patchBuffer, NativeToJITGatePtrTag, "tag thunk");
     539    return FINALIZE_THUNK(patchBuffer, NativeToJITGatePtrTag, "tag thunk");
    540540}
    541541
     
    552552
    553553    LinkBuffer patchBuffer(jit, GLOBAL_THUNK_ID, LinkBuffer::Profile::LLIntThunk);
    554     return FINALIZE_CODE(patchBuffer, NativeToJITGatePtrTag, "untag thunk");
     554    return FINALIZE_THUNK(patchBuffer, NativeToJITGatePtrTag, "untag thunk");
    555555}
    556556
  • trunk/Source/JavaScriptCore/yarr/YarrDisassembler.cpp

    r234713 r294180  
    11/*
    2  * Copyright (C) 2018 Apple Inc. All rights reserved.
     2 * Copyright (C) 2018-2022 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    5959void YarrDisassembler::dump(PrintStream& out, LinkBuffer& linkBuffer)
    6060{
     61    m_codeStart = linkBuffer.entrypoint<DisassemblyPtrTag>().untaggedExecutableAddress();
     62    m_codeEnd = bitwise_cast<uint8_t*>(m_codeStart) + linkBuffer.size();
     63
    6164    dumpHeader(out, linkBuffer);
    6265    dumpDisassembly(out, indentString(), linkBuffer, m_startOfCode, m_labelForGenerateYarrOp[0]);
     
    144147    CodeLocationLabel<DisassemblyPtrTag> fromLocation = linkBuffer.locationOf<DisassemblyPtrTag>(from);
    145148    CodeLocationLabel<DisassemblyPtrTag> toLocation = linkBuffer.locationOf<DisassemblyPtrTag>(to);
    146     disassemble(fromLocation, toLocation.dataLocation<uintptr_t>() - fromLocation.dataLocation<uintptr_t>(), prefix, out);
     149    disassemble(fromLocation, toLocation.dataLocation<uintptr_t>() - fromLocation.dataLocation<uintptr_t>(), m_codeStart, m_codeEnd, prefix, out);
    147150}
    148151
  • trunk/Source/JavaScriptCore/yarr/YarrDisassembler.h

    r234713 r294180  
    11/*
    2  * Copyright (C) 2018 Apple Inc. All rights reserved.
     2 * Copyright (C) 2018-2022 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    107107    MacroAssembler::Label m_endOfBacktrack;
    108108    MacroAssembler::Label m_endOfCode;
     109    void* m_codeStart { nullptr };
     110    void* m_codeEnd { nullptr };
    109111    unsigned m_indentLevel { 0 };
    110112};
Note: See TracChangeset for help on using the changeset viewer.