Ignore:
Timestamp:
Dec 9, 2008, 4:26:13 PM (16 years ago)
Author:
[email protected]
Message:

2008-12-09 Sam Weinig <[email protected]>

Reviewed by Geoffrey Garen.

Remove unnecessary extra lookup when throwing an exception.
We used to first lookup the target offset using getHandlerForVPC
and then we would lookup the native code stub using
nativeExceptionCodeForHandlerVPC. Instead, we can just pass around
the HandlerInfo.

  • bytecode/CodeBlock.cpp: (JSC::CodeBlock::handlerForVPC): Return the HandlerInfo.
  • bytecode/CodeBlock.h: Remove nativeExceptionCodeForHandlerVPC.
  • interpreter/Interpreter.cpp: (JSC::Interpreter::throwException): Return a HandlerInfo instead of and Instruction offset. (JSC::Interpreter::privateExecute): Get the offset from HandlerInfo. (JSC::Interpreter::cti_op_throw): Get the native code from the HandleInfo. (JSC::Interpreter::cti_vm_throw): Ditto.
  • interpreter/Interpreter.h:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/interpreter/Interpreter.cpp

    r39141 r39156  
    793793}
    794794
    795 NEVER_INLINE Instruction* Interpreter::throwException(CallFrame*& callFrame, JSValue*& exceptionValue, const Instruction* vPC, bool explicitThrow)
     795NEVER_INLINE HandlerInfo* Interpreter::throwException(CallFrame*& callFrame, JSValue*& exceptionValue, const Instruction* vPC, bool explicitThrow)
    796796{
    797797    // Set up the exception object
     
    853853    // Calculate an exception handler vPC, unwinding call frames as necessary.
    854854
    855     int scopeDepth;
    856     Instruction* handlerVPC;
    857 
    858     while (!codeBlock->getHandlerForVPC(vPC, handlerVPC, scopeDepth)) {
     855    HandlerInfo* handler = 0;
     856    while (!(handler = codeBlock->handlerForVPC(vPC))) {
    859857        if (!unwindCallFrame(callFrame, exceptionValue, vPC, codeBlock))
    860858            return 0;
     
    864862
    865863    ScopeChain sc(callFrame->scopeChain());
    866     int scopeDelta = depth(codeBlock, sc) - scopeDepth;
     864    int scopeDelta = depth(codeBlock, sc) - handler->scopeDepth;
    867865    ASSERT(scopeDelta >= 0);
    868866    while (scopeDelta--)
     
    870868    callFrame->setScopeChain(sc.node());
    871869
    872     return handlerVPC;
     870    return handler;
    873871}
    874872
     
    14811479    JSGlobalData* globalData = &callFrame->globalData();
    14821480    JSValue* exceptionValue = noValue();
    1483     Instruction* handlerVPC = 0;
     1481    HandlerInfo* handler = 0;
    14841482
    14851483    Instruction* vPC = callFrame->codeBlock()->instructions().begin();
     
    37943792        exceptionValue = callFrame[ex].jsValue(callFrame);
    37953793
    3796         handlerVPC = throwException(callFrame, exceptionValue, vPC, true);
    3797         if (!handlerVPC) {
     3794        handler = throwException(callFrame, exceptionValue, vPC, true);
     3795        if (!handler) {
    37983796            *exception = exceptionValue;
    37993797            return jsNull();
    38003798        }
    38013799
    3802         vPC = handlerVPC;
     3800        vPC = callFrame->codeBlock()->instructions().begin() + handler->target;
    38033801        NEXT_INSTRUCTION();
    38043802    }
     
    39703968            exceptionValue = createInterruptedExecutionException(globalData);
    39713969        }
    3972         handlerVPC = throwException(callFrame, exceptionValue, vPC, false);
    3973         if (!handlerVPC) {
     3970        handler = throwException(callFrame, exceptionValue, vPC, false);
     3971        if (!handler) {
    39743972            *exception = exceptionValue;
    39753973            return jsNull();
    39763974        }
    3977         vPC = handlerVPC;
     3975
     3976        vPC = callFrame->codeBlock()->instructions().begin() + handler->target;
    39783977        NEXT_INSTRUCTION();
    39793978    }
     
    57545753    ASSERT(exceptionValue);
    57555754
    5756     Instruction* handlerVPC = ARG_globalData->interpreter->throwException(callFrame, exceptionValue, codeBlock->instructions().begin() + vPCIndex, true);
    5757 
    5758     if (!handlerVPC) {
     5755    HandlerInfo* handler = ARG_globalData->interpreter->throwException(callFrame, exceptionValue, codeBlock->instructions().begin() + vPCIndex, true);
     5756
     5757    if (!handler) {
    57595758        *ARG_exception = exceptionValue;
    57605759        return JSImmediate::nullImmediate();
     
    57625761
    57635762    ARG_setCallFrame(callFrame);
    5764     void* catchRoutine = callFrame->codeBlock()->nativeExceptionCodeForHandlerVPC(handlerVPC);
     5763    void* catchRoutine = handler->nativeCode;
    57655764    ASSERT(catchRoutine);
    57665765    CTI_SET_RETURN_ADDRESS(catchRoutine);
     
    61006099    globalData->exception = noValue();
    61016100
    6102     Instruction* handlerVPC = globalData->interpreter->throwException(callFrame, exceptionValue, codeBlock->instructions().begin() + vPCIndex, false);
    6103 
    6104     if (!handlerVPC) {
     6101    HandlerInfo* handler = globalData->interpreter->throwException(callFrame, exceptionValue, codeBlock->instructions().begin() + vPCIndex, false);
     6102
     6103    if (!handler) {
    61056104        *ARG_exception = exceptionValue;
    61066105        return JSImmediate::nullImmediate();
     
    61086107
    61096108    ARG_setCallFrame(callFrame);
    6110     void* catchRoutine = callFrame->codeBlock()->nativeExceptionCodeForHandlerVPC(handlerVPC);
     6109    void* catchRoutine = handler->nativeCode;
    61116110    ASSERT(catchRoutine);
    61126111    CTI_SET_RETURN_ADDRESS(catchRoutine);
Note: See TracChangeset for help on using the changeset viewer.