Ignore:
Timestamp:
May 8, 2009, 1:51:53 PM (16 years ago)
Author:
[email protected]
Message:

2009-05-08 Geoffrey Garen <[email protected]>

Reviewed by Gavin Barraclough.


More abstraction for JITStub calls from JITed code.


Added a JITStubCall class that automatically handles things like assigning
arguments to different stack slots and storing return values. Deployed
the class in about a billion places. A bunch more places remain to be
fixed up, but this is a good stopping point for now.

  • jit/JIT.cpp: (JSC::JIT::emitTimeoutCheck): (JSC::JIT::privateCompileMainPass): (JSC::JIT::privateCompileSlowCases): (JSC::JIT::privateCompile):
  • jit/JIT.h: (JSC::JIT::JSRInfo::JSRInfo): (JSC::JITStubCall::JITStubCall): (JSC::JITStubCall::addArgument): (JSC::JITStubCall::call): (JSC::JITStubCall::): (JSC::CallEvalJITStub::CallEvalJITStub):
  • jit/JITArithmetic.cpp: (JSC::JIT::compileFastArithSlow_op_lshift): (JSC::JIT::compileFastArithSlow_op_rshift): (JSC::JIT::compileFastArithSlow_op_jnless): (JSC::JIT::compileFastArithSlow_op_bitand): (JSC::JIT::compileFastArithSlow_op_mod): (JSC::JIT::compileFastArith_op_mod): (JSC::JIT::compileFastArithSlow_op_post_inc): (JSC::JIT::compileFastArithSlow_op_post_dec): (JSC::JIT::compileFastArithSlow_op_pre_inc): (JSC::JIT::compileFastArithSlow_op_pre_dec): (JSC::JIT::compileFastArith_op_add): (JSC::JIT::compileFastArith_op_mul): (JSC::JIT::compileFastArith_op_sub): (JSC::JIT::compileBinaryArithOpSlowCase): (JSC::JIT::compileFastArithSlow_op_add): (JSC::JIT::compileFastArithSlow_op_mul):
  • jit/JITCall.cpp: (JSC::JIT::compileOpCall): (JSC::):
  • jit/JITPropertyAccess.cpp: (JSC::JIT::compileGetByIdHotPath): (JSC::JIT::compilePutByIdHotPath): (JSC::JIT::compileGetByIdSlowCase): (JSC::JIT::compilePutByIdSlowCase):
  • jit/JITStubs.cpp: (JSC::JITStubs::cti_op_resolve_func): (JSC::JITStubs::cti_op_resolve_with_base):
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/jit/JITCall.cpp

    r43220 r43409  
    105105}
    106106
    107 void JIT::compileOpCallEvalSetupArgs(Instruction* instruction)
    108 {
    109     int argCount = instruction[3].u.operand;
    110     int registerOffset = instruction[4].u.operand;
    111 
    112     // ecx holds func
    113     emitPutJITStubArg(regT2, 1);
    114     emitPutJITStubArgConstant(registerOffset, 2);
    115     emitPutJITStubArgConstant(argCount, 3);
    116 }
    117 
    118107void JIT::compileOpConstructSetupArgs(Instruction* instruction)
    119108{
     
    143132    Jump wasEval;
    144133    if (opcodeID == op_call_eval) {
    145         emitGetVirtualRegister(callee, regT2);
    146         compileOpCallEvalSetupArgs(instruction);
    147 
    148         emitCTICall(JITStubs::cti_op_call_eval);
     134        CallEvalJITStub(this, instruction).call();
    149135        wasEval = branchPtr(NotEqual, regT0, ImmPtr(JSValue::encode(JSValue())));
    150136    }
     
    163149    // First, in the case of a construct, allocate the new object.
    164150    if (opcodeID == op_construct) {
    165         emitCTICall(JITStubs::cti_op_construct_JSConstruct);
    166         emitPutVirtualRegister(registerOffset - RegisterFile::CallFrameHeaderSize - argCount);
     151        JITStubCall(JITStubs::cti_op_construct_JSConstruct.call(registerOffset - RegisterFile::CallFrameHeaderSize - argCount);
    167152        emitGetVirtualRegister(callee, regT2);
    168153    }
     
    190175    linkSlowCase(iter);
    191176    linkSlowCase(iter);
    192 
    193     // This handles host functions
    194     emitCTICall(((opcodeID == op_construct) ? JITStubs::cti_op_construct_NotJSConstruct : JITStubs::cti_op_call_NotJSFunction));
    195     // Put the return value in dst. In the interpreter, op_ret does this.
    196     emitPutVirtualRegister(dst);
     177    JITStubCall stubCall(opcodeID == op_construct ? JITStubs::cti_op_construct_NotJSConstruct : JITStubs::cti_op_call_NotJSFunction);
     178    stubCall.call(dst); // In the interpreter, the callee puts the return value in dst.
    197179
    198180    sampleCodeBlock(m_codeBlock);
     
    211193    Jump wasEval;
    212194    if (opcodeID == op_call_eval) {
    213         emitGetVirtualRegister(callee, regT2);
    214         compileOpCallEvalSetupArgs(instruction);
    215 
    216         emitCTICall(JITStubs::cti_op_call_eval);
     195        CallEvalJITStub(this, instruction).call();
    217196        wasEval = branchPtr(NotEqual, regT0, ImmPtr(JSValue::encode(JSValue())));
    218197    }
     
    236215        emitPutJITStubArg(regT2, 1);
    237216        emitPutJITStubArgFromVirtualRegister(proto, 4, regT0);
    238         emitCTICall(JITStubs::cti_op_construct_JSConstruct);
    239         emitPutVirtualRegister(thisRegister);
     217        JITStubCall stubCall(this, JITStubs::cti_op_construct_JSConstruct);
     218        stubCall.call(thisRegister);
    240219        emitGetVirtualRegister(callee, regT2);
    241220    }
     
    284263    // First, in the case of a construct, allocate the new object.
    285264    if (opcodeID == op_construct) {
    286         emitCTICall(JITStubs::cti_op_construct_JSConstruct);
    287         emitPutVirtualRegister(registerOffset - RegisterFile::CallFrameHeaderSize - argCount);
     265        JITStubCall(this, JITStubs::cti_op_construct_JSConstruct).call(registerOffset - RegisterFile::CallFrameHeaderSize - argCount);
    288266        emitGetVirtualRegister(callee, regT2);
    289267    }
     
    318296    callLinkFailNotObject.link(this);
    319297    callLinkFailNotJSFunction.link(this);
    320     emitCTICall(((opcodeID == op_construct) ? JITStubs::cti_op_construct_NotJSConstruct : JITStubs::cti_op_call_NotJSFunction));
     298    JITStubCall stubCall(this, opcodeID == op_construct ? JITStubs::cti_op_construct_NotJSConstruct : JITStubs::cti_op_call_NotJSFunction);
     299    stubCall.call();
    321300    Jump wasNotJSFunction = jump();
    322301
     
    326305    // First, in the case of a construct, allocate the new object.
    327306    if (opcodeID == op_construct) {
    328         emitCTICall(JITStubs::cti_op_construct_JSConstruct);
    329         emitPutVirtualRegister(registerOffset - RegisterFile::CallFrameHeaderSize - argCount);
     307        JITStubCall stubCall(this, JITStubs::cti_op_construct_JSConstruct);
     308        stubCall.call(registerOffset - RegisterFile::CallFrameHeaderSize - argCount);
    330309        emitGetVirtualRegister(callee, regT2);
    331310    }
     
    383362    linkSlowCase(iter);
    384363    linkSlowCase(iter);
    385    
    386     // This handles host functions
    387     emitCTICall(JITStubs::cti_op_call_NotJSFunction);
    388     // Put the return value in dst. In the interpreter, op_ret does this.
    389     emitPutVirtualRegister(dst);
     364    JITStubCall stubCall(this, JITStubs::cti_op_call_NotJSFunction);
     365    stubCall.call(dst); // In the interpreter, the callee puts the return value in dst.
    390366   
    391367    sampleCodeBlock(m_codeBlock);
Note: See TracChangeset for help on using the changeset viewer.