Ignore:
Timestamp:
Dec 12, 2008, 7:03:07 PM (16 years ago)
Author:
[email protected]
Message:

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

Reviewed by Cameron Zwarich.

<rdar://problem/6428342> Look into feasibility of discarding bytecode after native codegen

Move more JIT functionality to using offsets into the Instruction buffer
instead of raw pointers. Two to go!

  • interpreter/Interpreter.cpp: (JSC::bytecodeOffsetForPC): Rename from vPCForPC. (JSC::Interpreter::resolve): Pass offset to exception helper. (JSC::Interpreter::resolveSkip): Ditto. (JSC::Interpreter::resolveGlobal): Ditto. (JSC::Interpreter::resolveBaseAndProperty): Ditto. (JSC::Interpreter::resolveBaseAndFunc): Ditto. (JSC::isNotObject): Ditto. (JSC::Interpreter::unwindCallFrame): Call bytecodeOffsetForPC. (JSC::Interpreter::throwException): Use offsets instead of vPCs. (JSC::Interpreter::privateExecute): Pass offset to exception helper. (JSC::Interpreter::retrieveLastCaller): Ditto. (JSC::Interpreter::cti_op_instanceof): Ditto. (JSC::Interpreter::cti_op_call_NotJSFunction): Ditto. (JSC::Interpreter::cti_op_resolve): Pass offset to exception helper. (JSC::Interpreter::cti_op_construct_NotJSConstruct): Ditto. (JSC::Interpreter::cti_op_resolve_func): Ditto. (JSC::Interpreter::cti_op_resolve_skip): Ditto. (JSC::Interpreter::cti_op_resolve_global): Ditto. (JSC::Interpreter::cti_op_resolve_with_base): Ditto. (JSC::Interpreter::cti_op_throw): Ditto. (JSC::Interpreter::cti_op_in): Ditto. (JSC::Interpreter::cti_vm_throw): Ditto.
  • interpreter/Interpreter.h:
  • jit/JIT.cpp: (JSC::JIT::privateCompileMainPass): Don't pass unnecessary vPC to stub.
  • jit/JIT.h: Remove ARG_instr1 - ARG_instr3 and ARG_instr5 - ARG_instr6.
  • jit/JITCall.cpp: (JSC::JIT::compileOpCallEvalSetupArgs): Don't pass unnecessary vPC to stub.. (JSC::JIT::compileOpConstructSetupArgs): Ditto.
  • runtime/ExceptionHelpers.cpp: (JSC::createUndefinedVariableError): Take an offset instead of vPC. (JSC::createInvalidParamError): Ditto. (JSC::createNotAConstructorError): Ditto. (JSC::createNotAFunctionError): Ditto. (JSC::createNotAnObjectError): Ditto.
  • runtime/ExceptionHelpers.h:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/runtime/ExceptionHelpers.cpp

    r39255 r39265  
    8888}
    8989
    90 JSValue* createUndefinedVariableError(ExecState* exec, const Identifier& ident, const Instruction* vPC, CodeBlock* codeBlock)
    91 {
    92     int startOffset = 0;
    93     int endOffset = 0;
    94     int divotPoint = 0;
    95     int line = codeBlock->expressionRangeForBytecodeOffset(vPC - codeBlock->instructions().begin(), divotPoint, startOffset, endOffset);
     90JSValue* createUndefinedVariableError(ExecState* exec, const Identifier& ident, unsigned bytecodeOffset, CodeBlock* codeBlock)
     91{
     92    int startOffset = 0;
     93    int endOffset = 0;
     94    int divotPoint = 0;
     95    int line = codeBlock->expressionRangeForBytecodeOffset(bytecodeOffset, divotPoint, startOffset, endOffset);
    9696    UString message = "Can't find variable: ";
    9797    message.append(ident.ustring());
     
    149149}
    150150
    151 JSObject* createInvalidParamError(ExecState* exec, const char* op, JSValue* value, const Instruction* vPC, CodeBlock* codeBlock)
     151JSObject* createInvalidParamError(ExecState* exec, const char* op, JSValue* value, unsigned bytecodeOffset, CodeBlock* codeBlock)
    152152{
    153153    UString message = "not a valid argument for '";
     
    158158    int endOffset = 0;
    159159    int divotPoint = 0;
    160     int line = codeBlock->expressionRangeForBytecodeOffset(vPC - codeBlock->instructions().begin(), divotPoint, startOffset, endOffset);
     160    int line = codeBlock->expressionRangeForBytecodeOffset(bytecodeOffset, divotPoint, startOffset, endOffset);
    161161    UString errorMessage = createErrorMessage(exec, codeBlock, line, divotPoint, divotPoint + endOffset, value, message);
    162162    JSObject* exception = Error::create(exec, TypeError, errorMessage, line, codeBlock->ownerNode()->sourceID(), codeBlock->ownerNode()->sourceURL());
     
    167167}
    168168
    169 JSObject* createNotAConstructorError(ExecState* exec, JSValue* value, const Instruction* vPC, CodeBlock* codeBlock)
    170 {
    171     int startOffset = 0;
    172     int endOffset = 0;
    173     int divotPoint = 0;
    174     int line = codeBlock->expressionRangeForBytecodeOffset(vPC - codeBlock->instructions().begin(), divotPoint, startOffset, endOffset);
     169JSObject* createNotAConstructorError(ExecState* exec, JSValue* value, unsigned bytecodeOffset, CodeBlock* codeBlock)
     170{
     171    int startOffset = 0;
     172    int endOffset = 0;
     173    int divotPoint = 0;
     174    int line = codeBlock->expressionRangeForBytecodeOffset(bytecodeOffset, divotPoint, startOffset, endOffset);
    175175
    176176    // We're in a "new" expression, so we need to skip over the "new.." part
     
    188188}
    189189
    190 JSValue* createNotAFunctionError(ExecState* exec, JSValue* value, const Instruction* vPC, CodeBlock* codeBlock)
    191 {
    192     int startOffset = 0;
    193     int endOffset = 0;
    194     int divotPoint = 0;
    195     int line = codeBlock->expressionRangeForBytecodeOffset(vPC - codeBlock->instructions().begin(), divotPoint, startOffset, endOffset);
     190JSValue* createNotAFunctionError(ExecState* exec, JSValue* value, unsigned bytecodeOffset, CodeBlock* codeBlock)
     191{
     192    int startOffset = 0;
     193    int endOffset = 0;
     194    int divotPoint = 0;
     195    int line = codeBlock->expressionRangeForBytecodeOffset(bytecodeOffset, divotPoint, startOffset, endOffset);
    196196    UString errorMessage = createErrorMessage(exec, codeBlock, line, divotPoint - startOffset, divotPoint, value, "not a function");
    197197    JSObject* exception = Error::create(exec, TypeError, errorMessage, line, codeBlock->ownerNode()->sourceID(), codeBlock->ownerNode()->sourceURL());   
     
    207207}
    208208
    209 JSObject* createNotAnObjectError(ExecState* exec, JSNotAnObjectErrorStub* error, const Instruction* vPC, CodeBlock* codeBlock)
     209JSObject* createNotAnObjectError(ExecState* exec, JSNotAnObjectErrorStub* error, unsigned bytecodeOffset, CodeBlock* codeBlock)
    210210{
    211211    // Both op_construct and op_instanceof require a use of op_get_by_id to get
     
    213213    // thrown by these instances op_get_by_id need to reflect this.
    214214    OpcodeID followingOpcodeID;
    215     if (codeBlock->getByIdExceptionInfoForBytecodeOffset(vPC - codeBlock->instructions().begin(), followingOpcodeID)) {
     215    if (codeBlock->getByIdExceptionInfoForBytecodeOffset(bytecodeOffset, followingOpcodeID)) {
    216216        ASSERT(followingOpcodeID == op_construct || followingOpcodeID == op_instanceof);
    217217        if (followingOpcodeID == op_construct)
    218             return createNotAConstructorError(exec, error->isNull() ? jsNull() : jsUndefined(), vPC, codeBlock);
    219         return createInvalidParamError(exec, "instanceof", error->isNull() ? jsNull() : jsUndefined(), vPC, codeBlock);
    220     }
    221 
    222     int startOffset = 0;
    223     int endOffset = 0;
    224     int divotPoint = 0;
    225     int line = codeBlock->expressionRangeForBytecodeOffset(vPC - codeBlock->instructions().begin(), divotPoint, startOffset, endOffset);
     218            return createNotAConstructorError(exec, error->isNull() ? jsNull() : jsUndefined(), bytecodeOffset, codeBlock);
     219        return createInvalidParamError(exec, "instanceof", error->isNull() ? jsNull() : jsUndefined(), bytecodeOffset, codeBlock);
     220    }
     221
     222    int startOffset = 0;
     223    int endOffset = 0;
     224    int divotPoint = 0;
     225    int line = codeBlock->expressionRangeForBytecodeOffset(bytecodeOffset, divotPoint, startOffset, endOffset);
    226226    UString errorMessage = createErrorMessage(exec, codeBlock, line, divotPoint - startOffset, divotPoint, error->isNull() ? jsNull() : jsUndefined(), "not an object");
    227227    JSObject* exception = Error::create(exec, TypeError, errorMessage, line, codeBlock->ownerNode()->sourceID(), codeBlock->ownerNode()->sourceURL());
Note: See TracChangeset for help on using the changeset viewer.