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/bytecode/CodeBlock.cpp

    r39123 r39156  
    11951195}
    11961196
    1197 bool CodeBlock::getHandlerForVPC(const Instruction* vPC, Instruction*& target, int& scopeDepth)
     1197HandlerInfo* CodeBlock::handlerForVPC(const Instruction* vPC)
    11981198{
    11991199    if (!m_rareData)
    1200         return false;
    1201 
    1202     Vector<HandlerInfo>::iterator ptr = m_rareData->m_exceptionHandlers.begin();
    1203     Vector<HandlerInfo>::iterator end = m_rareData->m_exceptionHandlers.end();
     1200        return 0;
     1201
    12041202    unsigned addressOffset = vPC - m_instructions.begin();
    12051203    ASSERT(addressOffset < m_instructions.size());
    12061204   
    1207     for (; ptr != end; ++ptr) {
     1205    Vector<HandlerInfo>& exceptionHandlers = m_rareData->m_exceptionHandlers;
     1206    for (size_t i = 0; i < exceptionHandlers.size(); ++i) {
    12081207        // Handlers are ordered innermost first, so the first handler we encounter
    12091208        // that contains the source address is the correct handler to use.
    1210         if (ptr->start <= addressOffset && ptr->end >= addressOffset) {
    1211             scopeDepth = ptr->scopeDepth;
    1212             target = m_instructions.begin() + ptr->target;
    1213             return true;
    1214         }
    1215     }
    1216     return false;
    1217 }
    1218 
    1219 void* CodeBlock::nativeExceptionCodeForHandlerVPC(const Instruction* handlerVPC)
    1220 {
    1221     if (!m_rareData)
    1222         return 0;
    1223 
    1224     Vector<HandlerInfo>::iterator ptr = m_rareData->m_exceptionHandlers.begin();
    1225     Vector<HandlerInfo>::iterator end = m_rareData->m_exceptionHandlers.end();
    1226    
    1227     for (; ptr != end; ++ptr) {
    1228         Instruction*target = m_instructions.begin() + ptr->target;
    1229         if (handlerVPC == target)
    1230             return ptr->nativeCode;
     1209        if (exceptionHandlers[i].start <= addressOffset && exceptionHandlers[i].end >= addressOffset)
     1210            return &exceptionHandlers[i];
    12311211    }
    12321212
Note: See TracChangeset for help on using the changeset viewer.