Changeset 39720 in webkit for trunk/JavaScriptCore/interpreter


Ignore:
Timestamp:
Jan 8, 2009, 2:51:19 PM (16 years ago)
Author:
[email protected]
Message:

2009-01-08 Sam Weinig <[email protected]>

Reviewed by Oliver Hunt.

Fix for https://bugs.webkit.org/show_bug.cgi?id=23197
Delay creating the PCVector until an exception is thrown
Part of <rdar://problem/6469060>
Don't store exception information for a CodeBlock until first exception is thrown

  • Change the process for re-parsing/re-generating bytecode for exception information to use data from the original CodeBlock (offsets of GlobalResolve instructions) to aid in creating an identical instruction stream on re-parse, instead of padding interchangeable opcodes, which would result in different JITed code.
  • Fix bug where the wrong ScopeChainNode was used when re-parsing/regenerating from within some odd modified scope chains.
  • Lazily create the pcVector by re-JITing the regenerated CodeBlock and stealing the the pcVector from it.

Saves ~2MB on Membuster head.

  • bytecode/CodeBlock.cpp: (JSC::CodeBlock::dump): (JSC::CodeBlock::reparseForExceptionInfoIfNecessary): (JSC::CodeBlock::hasGlobalResolveInstructionAtBytecodeOffset): (JSC::CodeBlock::hasGlobalResolveInfoAtBytecodeOffset):
  • bytecode/CodeBlock.h: (JSC::JITCodeRef::JITCodeRef): (JSC::GlobalResolveInfo::GlobalResolveInfo): (JSC::CodeBlock::getBytecodeIndex): (JSC::CodeBlock::addGlobalResolveInstruction): (JSC::CodeBlock::addGlobalResolveInfo): (JSC::CodeBlock::addFunctionRegisterInfo): (JSC::CodeBlock::hasExceptionInfo): (JSC::CodeBlock::pcVector): (JSC::EvalCodeBlock::EvalCodeBlock): (JSC::EvalCodeBlock::baseScopeDepth):
  • bytecode/Opcode.h:
  • bytecompiler/BytecodeGenerator.cpp: (JSC::BytecodeGenerator::BytecodeGenerator): (JSC::BytecodeGenerator::emitResolve): (JSC::BytecodeGenerator::emitGetScopedVar):
  • bytecompiler/BytecodeGenerator.h: (JSC::BytecodeGenerator::setRegeneratingForExceptionInfo):
  • interpreter/Interpreter.cpp: (JSC::bytecodeOffsetForPC): (JSC::Interpreter::unwindCallFrame): (JSC::Interpreter::privateExecute): (JSC::Interpreter::retrieveLastCaller): (JSC::Interpreter::cti_op_instanceof): (JSC::Interpreter::cti_op_call_NotJSFunction): (JSC::Interpreter::cti_op_resolve): (JSC::Interpreter::cti_op_construct_NotJSConstruct): (JSC::Interpreter::cti_op_resolve_func): (JSC::Interpreter::cti_op_resolve_skip): (JSC::Interpreter::cti_op_resolve_global): (JSC::Interpreter::cti_op_resolve_with_base): (JSC::Interpreter::cti_op_throw): (JSC::Interpreter::cti_op_in): (JSC::Interpreter::cti_vm_throw):
  • jit/JIT.cpp: (JSC::JIT::privateCompile):
  • parser/Nodes.cpp: (JSC::EvalNode::generateBytecode): (JSC::EvalNode::bytecodeForExceptionInfoReparse): (JSC::FunctionBodyNode::bytecodeForExceptionInfoReparse):
  • parser/Nodes.h:
File:
1 edited

Legend:

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

    r39697 r39720  
    9090static const int preferredScriptCheckTimeInterval = 1000;
    9191
    92 static ALWAYS_INLINE unsigned bytecodeOffsetForPC(CodeBlock* codeBlock, void* pc)
     92static ALWAYS_INLINE unsigned bytecodeOffsetForPC(CallFrame* callFrame, CodeBlock* codeBlock, void* pc)
    9393{
    9494#if ENABLE(JIT)
    95     return codeBlock->getBytecodeIndex(pc);
     95    return codeBlock->getBytecodeIndex(callFrame, pc);
    9696#else
     97    UNUSED_PARAM(callFrame);
    9798    return static_cast<Instruction*>(pc) - codeBlock->instructions().begin();
    9899#endif
     
    773774
    774775    codeBlock = callFrame->codeBlock();
    775     bytecodeOffset = bytecodeOffsetForPC(codeBlock, returnPC);
     776    bytecodeOffset = bytecodeOffsetForPC(callFrame, codeBlock, returnPC);
    776777    return true;
    777778}
     
    23492350    }
    23502351    DEFINE_OPCODE(op_get_global_var) {
    2351         /* get_global_var dst(r) globalObject(c) index(n) nop(n) nop(n)
     2352        /* get_global_var dst(r) globalObject(c) index(n)
    23522353
    23532354           Gets the global var at global slot index and places it in register dst.
     
    40334034        return;
    40344035
    4035     unsigned bytecodeOffset = bytecodeOffsetForPC(callerCodeBlock, callFrame->returnPC());
     4036    unsigned bytecodeOffset = bytecodeOffsetForPC(callerFrame, callerCodeBlock, callFrame->returnPC());
    40364037    lineNumber = callerCodeBlock->lineNumberForBytecodeOffset(callerFrame, bytecodeOffset - 1);
    40374038    sourceID = callerCodeBlock->ownerNode()->sourceID();
     
    47404741        CallFrame* callFrame = ARG_callFrame;
    47414742        CodeBlock* codeBlock = callFrame->codeBlock();
    4742         unsigned vPCIndex = codeBlock->getBytecodeIndex(STUB_RETURN_ADDRESS);
     4743        unsigned vPCIndex = codeBlock->getBytecodeIndex(callFrame, STUB_RETURN_ADDRESS);
    47434744        ARG_globalData->exception = createInvalidParamError(callFrame, "instanceof", baseVal, vPCIndex, codeBlock);
    47444745        VM_THROW_EXCEPTION();
     
    49434944    ASSERT(callType == CallTypeNone);
    49444945
    4945     CodeBlock* codeBlock = ARG_callFrame->codeBlock();
    4946     unsigned vPCIndex = codeBlock->getBytecodeIndex(STUB_RETURN_ADDRESS);
     4946    CallFrame* callFrame = ARG_callFrame;
     4947    CodeBlock* codeBlock = callFrame->codeBlock();
     4948    unsigned vPCIndex = codeBlock->getBytecodeIndex(callFrame, STUB_RETURN_ADDRESS);
    49474949    ARG_globalData->exception = createNotAFunctionError(ARG_callFrame, funcVal, vPCIndex, codeBlock);
    49484950    VM_THROW_EXCEPTION();
     
    50385040
    50395041    CodeBlock* codeBlock = callFrame->codeBlock();
    5040     unsigned vPCIndex = codeBlock->getBytecodeIndex(STUB_RETURN_ADDRESS);
     5042    unsigned vPCIndex = codeBlock->getBytecodeIndex(callFrame, STUB_RETURN_ADDRESS);
    50415043    ARG_globalData->exception = createUndefinedVariableError(callFrame, ident, vPCIndex, codeBlock);
    50425044    VM_THROW_EXCEPTION();
     
    50895091
    50905092    CodeBlock* codeBlock = callFrame->codeBlock();
    5091     unsigned vPCIndex = codeBlock->getBytecodeIndex(STUB_RETURN_ADDRESS);
     5093    unsigned vPCIndex = codeBlock->getBytecodeIndex(callFrame, STUB_RETURN_ADDRESS);
    50925094    ARG_globalData->exception = createNotAConstructorError(callFrame, constrVal, vPCIndex, codeBlock);
    50935095    VM_THROW_EXCEPTION();
     
    51675169
    51685170    CodeBlock* codeBlock = callFrame->codeBlock();
    5169     unsigned vPCIndex = codeBlock->getBytecodeIndex(STUB_RETURN_ADDRESS);
     5171    unsigned vPCIndex = codeBlock->getBytecodeIndex(callFrame, STUB_RETURN_ADDRESS);
    51705172    ARG_globalData->exception = createUndefinedVariableError(callFrame, ident, vPCIndex, codeBlock);
    51715173    VM_THROW_EXCEPTION_2();
     
    53355337
    53365338    CodeBlock* codeBlock = callFrame->codeBlock();
    5337     unsigned vPCIndex = codeBlock->getBytecodeIndex(STUB_RETURN_ADDRESS);
     5339    unsigned vPCIndex = codeBlock->getBytecodeIndex(callFrame, STUB_RETURN_ADDRESS);
    53385340    ARG_globalData->exception = createUndefinedVariableError(callFrame, ident, vPCIndex, codeBlock);
    53395341    VM_THROW_EXCEPTION();
     
    53675369    }
    53685370
    5369     unsigned vPCIndex = ARG_callFrame->codeBlock()->getBytecodeIndex(STUB_RETURN_ADDRESS);
     5371    unsigned vPCIndex = callFrame->codeBlock()->getBytecodeIndex(callFrame, STUB_RETURN_ADDRESS);
    53705372    ARG_globalData->exception = createUndefinedVariableError(callFrame, ident, vPCIndex, callFrame->codeBlock());
    53715373    VM_THROW_EXCEPTION();
     
    55735575
    55745576    CodeBlock* codeBlock = callFrame->codeBlock();
    5575     unsigned vPCIndex = codeBlock->getBytecodeIndex(STUB_RETURN_ADDRESS);
     5577    unsigned vPCIndex = codeBlock->getBytecodeIndex(callFrame, STUB_RETURN_ADDRESS);
    55765578    ARG_globalData->exception = createUndefinedVariableError(callFrame, ident, vPCIndex, codeBlock);
    55775579    VM_THROW_EXCEPTION_2();
     
    57295731    CodeBlock* codeBlock = callFrame->codeBlock();
    57305732
    5731     unsigned vPCIndex = codeBlock->getBytecodeIndex(STUB_RETURN_ADDRESS);
     5733    unsigned vPCIndex = codeBlock->getBytecodeIndex(callFrame, STUB_RETURN_ADDRESS);
    57325734
    57335735    JSValuePtr exceptionValue = ARG_src1;
     
    58835885        CallFrame* callFrame = ARG_callFrame;
    58845886        CodeBlock* codeBlock = callFrame->codeBlock();
    5885         unsigned vPCIndex = codeBlock->getBytecodeIndex(STUB_RETURN_ADDRESS);
     5887        unsigned vPCIndex = codeBlock->getBytecodeIndex(callFrame, STUB_RETURN_ADDRESS);
    58865888        ARG_globalData->exception = createInvalidParamError(callFrame, "in", baseVal, vPCIndex, codeBlock);
    58875889        VM_THROW_EXCEPTION();
     
    60746076    JSGlobalData* globalData = ARG_globalData;
    60756077
    6076     unsigned vPCIndex = codeBlock->getBytecodeIndex(globalData->exceptionLocation);
     6078    unsigned vPCIndex = codeBlock->getBytecodeIndex(callFrame, globalData->exceptionLocation);
    60776079
    60786080    JSValuePtr exceptionValue = globalData->exception;
Note: See TracChangeset for help on using the changeset viewer.