Changeset 160890 in webkit


Ignore:
Timestamp:
Dec 19, 2013 6:38:00 PM (10 years ago)
Author:
mark.lam@apple.com
Message:

CStack: The JIT does not need a slow path stack check.
https://bugs.webkit.org/show_bug.cgi?id=126036.

Reviewed by Geoffrey Garen.

The JIT uses the C stack which is not growable. If we fail a stack
check in the function header, then a stack overflow is imminent, and
there's no need to redo the check in the slow path helper.

Hence, renamed operationStackCheck() to operationThrowStackOverflowError()
and change the JIT and DFG code to use this appropriately.

  • dfg/DFGJITCompiler.cpp:

(JSC::DFG::JITCompiler::compileFunction):

  • jit/JIT.cpp:

(JSC::JIT::privateCompile):

  • jit/JITOperations.cpp:
  • jit/JITOperations.h:
Location:
branches/jsCStack/Source/JavaScriptCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/jsCStack/Source/JavaScriptCore/ChangeLog

    r160874 r160890  
     12013-12-19  Mark Lam  <mark.lam@apple.com>
     2
     3        CStack: The JIT does not need a slow path stack check.
     4        https://bugs.webkit.org/show_bug.cgi?id=126036.
     5
     6        Reviewed by Geoffrey Garen.
     7
     8        The JIT uses the C stack which is not growable. If we fail a stack
     9        check in the function header, then a stack overflow is imminent, and
     10        there's no need to redo the check in the slow path helper.
     11
     12        Hence, renamed operationStackCheck() to operationThrowStackOverflowError()
     13        and change the JIT and DFG code to use this appropriately.
     14
     15        * dfg/DFGJITCompiler.cpp:
     16        (JSC::DFG::JITCompiler::compileFunction):
     17        * jit/JIT.cpp:
     18        (JSC::JIT::privateCompile):
     19        * jit/JITOperations.cpp:
     20        * jit/JITOperations.h:
     21
    1222013-12-19  Michael Saboff  <msaboff@apple.com>
    223
  • branches/jsCStack/Source/JavaScriptCore/dfg/DFGJITCompiler.cpp

    r160835 r160890  
    328328    // Plant a check that sufficient space is available in the JSStack.
    329329    addPtr(TrustedImm32(virtualRegisterForLocal(m_graph.requiredRegisterCountForExecutionAndExit() - 1).offset() * sizeof(Register)), GPRInfo::callFrameRegister, GPRInfo::regT1);
    330     Jump stackCheck = branchPtr(Above, AbsoluteAddress(m_vm->addressOfJSStackLimit()), GPRInfo::regT1);
    331     // Return here after stack check.
    332     Label fromStackCheck = label();
     330    Jump stackOverflow = branchPtr(Above, AbsoluteAddress(m_vm->addressOfJSStackLimit()), GPRInfo::regT1);
    333331
    334332    checkStackPointerAlignment();
     
    345343    // === Function footer code generation ===
    346344    //
    347     // Generate code to perform the slow stack check (if the fast one in
     345    // Generate code to perform the stack overflow handling (if the stack check in
    348346    // the function header fails), and generate the entry point with arity check.
    349347    //
    350     // Generate the stack check; if the fast check in the function head fails,
    351     // we need to call out to a helper function to check whether more space is available.
    352     // FIXME: change this from a cti call to a DFG style operation (normal C calling conventions).
    353     stackCheck.link(this);
     348    // Generate the stack overflow handling; if the stack check in the function head fails,
     349    // we need to call out to a helper function to throw the StackOverflowError.
     350    stackOverflow.link(this);
    354351
    355352    emitStoreCodeOrigin(CodeOrigin(0));
    356     m_speculative->callOperationWithCallFrameRollbackOnException(operationStackCheck, m_codeBlock);
    357     jump(fromStackCheck);
     353    m_speculative->callOperationWithCallFrameRollbackOnException(operationThrowStackOverflowError, m_codeBlock);
    358354   
    359355    // The fast entry point into a function does not check the correct number of arguments
  • branches/jsCStack/Source/JavaScriptCore/jit/JIT.cpp

    r160835 r160890  
    520520#endif
    521521
    522     Jump stackCheck;
     522    Jump stackOverflow;
    523523    if (m_codeBlock->codeType() == FunctionCode) {
    524524#if ENABLE(VALUE_PROFILER)
     
    543543
    544544        addPtr(TrustedImm32(stackPointerOffsetFor(m_codeBlock) * sizeof(Register)), callFrameRegister, regT1);
    545         stackCheck = branchPtr(Above, AbsoluteAddress(m_vm->addressOfJSStackLimit()), regT1);
    546     }
    547 
    548     Label functionBody = label();
     545        stackOverflow = branchPtr(Above, AbsoluteAddress(m_vm->addressOfJSStackLimit()), regT1);
     546    }
    549547
    550548    checkStackPointerAlignment();
     
    561559    Label arityCheck;
    562560    if (m_codeBlock->codeType() == FunctionCode) {
    563         stackCheck.link(this);
     561        stackOverflow.link(this);
    564562        m_bytecodeOffset = 0;
    565         // FIXME: CStack - This may need to have some stack space allocated to make the call
    566         callOperationWithCallFrameRollbackOnException(operationStackCheck, m_codeBlock);
    567 #ifndef NDEBUG
    568         m_bytecodeOffset = (unsigned)-1; // Reset this, in order to guard its use with ASSERTs.
    569 #endif
    570         jump(functionBody);
     563        callOperationWithCallFrameRollbackOnException(operationThrowStackOverflowError, m_codeBlock);
    571564
    572565        arityCheck = label();
  • branches/jsCStack/Source/JavaScriptCore/jit/JITOperations.cpp

    r160874 r160890  
    7171
    7272
    73 void JIT_OPERATION operationStackCheck(ExecState* exec, CodeBlock* codeBlock)
     73void JIT_OPERATION operationThrowStackOverflowError(ExecState* exec, CodeBlock* codeBlock)
    7474{
    7575    // We pass in our own code block, because the callframe hasn't been populated.
     
    8080
    8181    NativeCallFrameTracer tracer(vm, callerFrame);
    82 
    83 #if ENABLE(LLINT_CLOOP)
    84     JSStack& stack = vm->interpreter->stack();
    85 
    86     if (UNLIKELY(!stack.grow(&exec->registers()[codeBlock->stackPointerOffset()])))
    87         vm->throwException(callerFrame, createStackOverflowError(callerFrame));
    88 #else
    89     if (!exec->vm().isSafeToRecurse(codeBlock->frameRegisterCount() * sizeof(Register)))
    90         vm->throwException(callerFrame, createStackOverflowError(callerFrame));
    91 #endif // ENABLE(LLINT_CLOOP)
     82    vm->throwException(callerFrame, createStackOverflowError(callerFrame));
    9283}
    9384
  • branches/jsCStack/Source/JavaScriptCore/jit/JITOperations.h

    r160867 r160890  
    188188void JIT_OPERATION operationVMHandleException(ExecState*) WTF_INTERNAL;
    189189
    190 void JIT_OPERATION operationStackCheck(ExecState*, CodeBlock*) WTF_INTERNAL;
     190void JIT_OPERATION operationThrowStackOverflowError(ExecState*, CodeBlock*) WTF_INTERNAL;
    191191int32_t JIT_OPERATION operationCallArityCheck(ExecState*) WTF_INTERNAL;
    192192int32_t JIT_OPERATION operationConstructArityCheck(ExecState*) WTF_INTERNAL;
Note: See TracChangeset for help on using the changeset viewer.