Ignore:
Timestamp:
Oct 24, 2019, 1:27:38 PM (6 years ago)
Author:
[email protected]
Message:

[JSC] Remove LLInt's Callee size assumption
https://bugs.webkit.org/show_bug.cgi?id=203282

Reviewed by Mark Lam.

LLInt code still assumes that Callee is always allocated in non-LargeAllocation.
This patch removes this assumption by following three changes.

  1. If we can get CodeBlock, we get VM& from CodeBlock.
  2. In nativeCallTrampoline and internalFunctionCallTrampoline, we get VM& from JSGlobalObject. It involves one more pointer-chasing but it is OK since this JSGlobalObject's VM* field will be touched in called native functions anyway. And this code is only used when we are not using JIT.
  3. In exception handling code in LLInt, we get VM& from callee by checking LargeAllocation possibility. This is OK since it is only executed when exception unwinding happens, and which is an expensive operation anyway.
  • heap/LargeAllocation.h:

(JSC::LargeAllocation::headerSize):

  • heap/WeakSet.h:

(JSC::WeakSet::WeakSet):
(JSC::WeakSet::vm const):

  • llint/LowLevelInterpreter.asm:
  • llint/LowLevelInterpreter32_64.asm:
  • llint/LowLevelInterpreter64.asm:
  • runtime/JSGlobalObject.cpp:

(JSC::JSGlobalObject::JSGlobalObject):
(JSC::JSGlobalObject::init):

  • runtime/JSGlobalObject.h:

(JSC::JSGlobalObject::vm const):
(JSC::JSGlobalObject::defaultCodeGenerationMode const):

  • runtime/VM.h:

(JSC::WeakSet::heap const):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/llint/LowLevelInterpreter64.asm

    r251106 r251556  
    330330op(handleUncaughtException, macro ()
    331331    loadp Callee[cfr], t3
    332     andp MarkedBlockMask, t3
    333     loadp MarkedBlockFooterOffset + MarkedBlock::Footer::m_vm[t3], t3
     332    convertCalleeToVM(t3)
    334333    restoreCalleeSavesFromVMEntryFrameCalleeSavesBuffer(t3, t0)
    335334    storep 0, VM::callFrameForCatch[t3]
     
    682681end
    683682
    684 macro branchIfException(label)
    685     loadp Callee[cfr], t3
    686     andp MarkedBlockMask, t3
    687     loadp MarkedBlockFooterOffset + MarkedBlock::Footer::m_vm[t3], t3
    688     btpz VM::m_exception[t3], .noException
    689     jmp label
    690 .noException:
    691 end
    692 
    693683# Instruction implementations
     684
    694685_llint_op_enter:
    695686    traceExecution()
     
    20692060    # and have set VM::targetInterpreterPCForThrow.
    20702061    loadp Callee[cfr], t3
    2071     andp MarkedBlockMask, t3
    2072     loadp MarkedBlockFooterOffset + MarkedBlock::Footer::m_vm[t3], t3
     2062    convertCalleeToVM(t3)
    20732063    restoreCalleeSavesFromVMEntryFrameCalleeSavesBuffer(t3, t0)
    20742064    loadp VM::callFrameForCatch[t3], cfr
     
    20872077
    20882078.isCatchableException:
    2089     loadp Callee[cfr], t3
    2090     andp MarkedBlockMask, t3
    2091     loadp MarkedBlockFooterOffset + MarkedBlock::Footer::m_vm[t3], t3
     2079    loadp CodeBlock[cfr], t3
     2080    loadp CodeBlock::m_vm[t3], t3
    20922081
    20932082    loadp VM::m_exception[t3], t0
     
    21192108op(llint_throw_from_slow_path_trampoline, macro ()
    21202109    loadp Callee[cfr], t1
    2121     andp MarkedBlockMask, t1
    2122     loadp MarkedBlockFooterOffset + MarkedBlock::Footer::m_vm[t1], t1
     2110    convertCalleeToVM(t1)
    21232111    copyCalleeSavesToVMEntryFrameCalleeSavesBuffer(t1, t2)
    21242112
     
    21292117    # This essentially emulates the JIT's throwing protocol.
    21302118    loadp Callee[cfr], t1
    2131     andp MarkedBlockMask, t1
    2132     loadp MarkedBlockFooterOffset + MarkedBlock::Footer::m_vm[t1], t1
     2119    convertCalleeToVM(t1)
    21332120    jmp VM::targetMachinePCForThrow[t1], ExceptionHandlerPtrTag
    21342121end)
     
    21422129
    21432130macro nativeCallTrampoline(executableOffsetToFunction)
    2144 
    21452131    functionPrologue()
    21462132    storep 0, CodeBlock[cfr]
    2147     loadp Callee[cfr], t0
    2148     andp MarkedBlockMask, t0, t1
    2149     loadp MarkedBlockFooterOffset + MarkedBlock::Footer::m_vm[t1], t1
    2150     storep cfr, VM::topCallFrame[t1]
    2151     if ARM64 or ARM64E or C_LOOP or C_LOOP_WIN
    2152         storep lr, ReturnPC[cfr]
    2153     end
    2154     move cfr, a1
    21552133    loadp Callee[cfr], a0
    21562134    loadp JSFunction::m_executable[a0], a2
    21572135    loadp JSFunction::m_globalObject[a0], a0
     2136    loadp JSGlobalObject::m_vm[a0], a1
     2137    storep cfr, VM::topCallFrame[a1]
     2138    if ARM64 or ARM64E or C_LOOP or C_LOOP_WIN
     2139        storep lr, ReturnPC[cfr]
     2140    end
     2141    move cfr, a1
    21582142    checkStackPointerAlignment(t3, 0xdead0001)
    21592143    if C_LOOP or C_LOOP_WIN
     
    21702154
    21712155    loadp Callee[cfr], t3
    2172     andp MarkedBlockMask, t3
    2173     loadp MarkedBlockFooterOffset + MarkedBlock::Footer::m_vm[t3], t3
     2156    loadp JSFunction::m_globalObject[t3], t3
     2157    loadp JSGlobalObject::m_vm[t3], t3
    21742158
    21752159    btpnz VM::m_exception[t3], .handleException
     
    21862170    functionPrologue()
    21872171    storep 0, CodeBlock[cfr]
    2188     loadp Callee[cfr], t0
    2189     andp MarkedBlockMask, t0, t1
    2190     loadp MarkedBlockFooterOffset + MarkedBlock::Footer::m_vm[t1], t1
    2191     storep cfr, VM::topCallFrame[t1]
     2172    loadp Callee[cfr], a2
     2173    loadp InternalFunction::m_globalObject[a2], a0
     2174    loadp JSGlobalObject::m_vm[a0], a1
     2175    storep cfr, VM::topCallFrame[a1]
    21922176    if ARM64 or ARM64E or C_LOOP or C_LOOP_WIN
    21932177        storep lr, ReturnPC[cfr]
    21942178    end
    21952179    move cfr, a1
    2196     loadp Callee[cfr], a2
    2197     loadp InternalFunction::m_globalObject[a2], a0
    21982180    checkStackPointerAlignment(t3, 0xdead0001)
    21992181    if C_LOOP or C_LOOP_WIN
     
    22102192
    22112193    loadp Callee[cfr], t3
    2212     andp MarkedBlockMask, t3
    2213     loadp MarkedBlockFooterOffset + MarkedBlock::Footer::m_vm[t3], t3
     2194    loadp InternalFunction::m_globalObject[t3], t3
     2195    loadp JSGlobalObject::m_vm[t3], t3
    22142196
    22152197    btpnz VM::m_exception[t3], .handleException
Note: See TracChangeset for help on using the changeset viewer.