Ignore:
Timestamp:
Dec 12, 2008, 1:31:33 PM (16 years ago)
Author:
[email protected]
Message:

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

Reviewed by Geoffrey Garen.

Change exception information accessors to take offsets into the bytecode
instruction buffer instead of pointers so that they can work even even
if the bytecode buffer is purged.

  • bytecode/CodeBlock.cpp: (JSC::instructionOffsetForNth): (JSC::CodeBlock::handlerForBytecodeOffset): (JSC::CodeBlock::lineNumberForBytecodeOffset): (JSC::CodeBlock::expressionRangeForBytecodeOffset):
  • bytecode/CodeBlock.h:
  • bytecode/SamplingTool.cpp: (JSC::SamplingTool::dump):
  • interpreter/Interpreter.cpp: (JSC::Interpreter::throwException): (JSC::Interpreter::privateExecute): (JSC::Interpreter::retrieveLastCaller):
  • jit/JIT.cpp: (JSC::JIT::privateCompileMainPass):
  • runtime/ExceptionHelpers.cpp: (JSC::createUndefinedVariableError): (JSC::createInvalidParamError): (JSC::createNotAConstructorError): (JSC::createNotAFunctionError): (JSC::createNotAnObjectError):
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/bytecode/CodeBlock.cpp

    r39229 r39252  
    209209    while (i < instructions.size()) {
    210210        OpcodeID currentOpcode = exec->interpreter()->getOpcodeID(instructions[i].u.opcode);
    211         if (predicate(exec->interpreter()->getOpcodeID(instructions[i].u.opcode))) {
     211        if (predicate(currentOpcode)) {
    212212            if (!--nth)
    213213                return i;
     
    13311331}
    13321332
    1333 HandlerInfo* CodeBlock::handlerForVPC(const Instruction* vPC)
     1333HandlerInfo* CodeBlock::handlerForBytecodeOffset(unsigned bytecodeOffset)
    13341334{
    13351335    if (!m_rareData)
    13361336        return 0;
    13371337
    1338     unsigned addressOffset = vPC - m_instructions.begin();
    1339     ASSERT(addressOffset < m_instructions.size());
     1338    ASSERT(bytecodeOffset < m_instructions.size());
    13401339   
    13411340    Vector<HandlerInfo>& exceptionHandlers = m_rareData->m_exceptionHandlers;
     
    13431342        // Handlers are ordered innermost first, so the first handler we encounter
    13441343        // that contains the source address is the correct handler to use.
    1345         if (exceptionHandlers[i].start <= addressOffset && exceptionHandlers[i].end >= addressOffset)
     1344        if (exceptionHandlers[i].start <= bytecodeOffset && exceptionHandlers[i].end >= bytecodeOffset)
    13461345            return &exceptionHandlers[i];
    13471346    }
     
    13501349}
    13511350
    1352 int CodeBlock::lineNumberForVPC(const Instruction* vPC)
    1353 {
    1354     unsigned instructionOffset = vPC - m_instructions.begin();
    1355     ASSERT(instructionOffset < m_instructions.size());
     1351int CodeBlock::lineNumberForBytecodeOffset(unsigned bytecodeOffset)
     1352{
     1353    ASSERT(bytecodeOffset < m_instructions.size());
    13561354
    13571355    if (!m_lineInfo.size())
     
    13621360    while (low < high) {
    13631361        int mid = low + (high - low) / 2;
    1364         if (m_lineInfo[mid].instructionOffset <= instructionOffset)
     1362        if (m_lineInfo[mid].instructionOffset <= bytecodeOffset)
    13651363            low = mid + 1;
    13661364        else
     
    13731371}
    13741372
    1375 int CodeBlock::expressionRangeForVPC(const Instruction* vPC, int& divot, int& startOffset, int& endOffset)
    1376 {
    1377     unsigned instructionOffset = vPC - m_instructions.begin();
    1378     ASSERT(instructionOffset < m_instructions.size());
     1373int CodeBlock::expressionRangeForBytecodeOffset(unsigned bytecodeOffset, int& divot, int& startOffset, int& endOffset)
     1374{
     1375    ASSERT(bytecodeOffset < m_instructions.size());
    13791376
    13801377    if (!m_expressionInfo.size()) {
     
    13831380        endOffset = 0;
    13841381        divot = 0;
    1385         return lineNumberForVPC(vPC);
     1382        return lineNumberForBytecodeOffset(bytecodeOffset);
    13861383    }
    13871384
     
    13901387    while (low < high) {
    13911388        int mid = low + (high - low) / 2;
    1392         if (m_expressionInfo[mid].instructionOffset <= instructionOffset)
     1389        if (m_expressionInfo[mid].instructionOffset <= bytecodeOffset)
    13931390            low = mid + 1;
    13941391        else
     
    14011398        endOffset = 0;
    14021399        divot = 0;
    1403         return lineNumberForVPC(vPC);
     1400        return lineNumberForBytecodeOffset(bytecodeOffset);
    14041401    }
    14051402
     
    14071404    endOffset = m_expressionInfo[low - 1].endOffset;
    14081405    divot = m_expressionInfo[low - 1].divotPoint + m_sourceOffset;
    1409     return lineNumberForVPC(vPC);
     1406    return lineNumberForBytecodeOffset(bytecodeOffset);
    14101407}
    14111408
Note: See TracChangeset for help on using the changeset viewer.