Changeset 37386 in webkit for trunk/JavaScriptCore/VM/CTI.cpp


Ignore:
Timestamp:
Oct 7, 2008, 1:27:50 PM (17 years ago)
Author:
[email protected]
Message:

2008-10-07 Gavin Barraclough <[email protected]>

Reviewed by Oliver Hunt.

Move callframe initialization into JIT code, again.


As a part of the restructuring the second result from functions is now
returned in edx, allowing the new value of 'r' to be returned via a
register, and stored to the stack from JIT code, too.

4.5% progression on v8-tests. (3% in their harness)

  • VM/CTI.cpp: (JSC::): (JSC::CTI::emitCall): (JSC::CTI::compileOpCall): (JSC::CTI::privateCompileMainPass): (JSC::CTI::privateCompileSlowCases): (JSC::CTI::privateCompile):
  • VM/CTI.h: (JSC::CallRecord::CallRecord):
  • VM/Machine.cpp: (JSC::Machine::cti_op_call_JSFunction): (JSC::Machine::cti_op_construct_JSConstruct): (JSC::Machine::cti_op_resolve_func): (JSC::Machine::cti_op_post_inc): (JSC::Machine::cti_op_resolve_with_base): (JSC::Machine::cti_op_post_dec):
  • VM/Machine.h:
  • kjs/JSFunction.h:
  • kjs/ScopeChain.h:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/VM/CTI.cpp

    r37381 r37386  
    3131#include "CodeBlock.h"
    3232#include "JSArray.h"
     33#include "JSFunction.h"
    3334#include "Machine.h"
    3435#include "wrec/WREC.h"
     
    8384    "subl $0x24, %esp" "\n"
    8485    "movl $512, %esi" "\n"
     86    "movl 0x38(%esp), %edi" "\n" // Ox38 = 0x0E * 4, 0x0E = CTI_ARGS_r
    8587    "call *0x30(%esp)" "\n" // Ox30 = 0x0C * 4, 0x0C = CTI_ARGS_code
    8688    "addl $0x24, %esp" "\n"
     
    112114            mov esi, 512;
    113115            mov [esp], esp;
     116            mov edi, [esp + 0x38];
    114117            call [esp + 0x30];
    115118            add esp, 0x24;
     
    363366}
    364367
     368ALWAYS_INLINE X86Assembler::JmpSrc CTI::emitCall(unsigned opcodeIndex, CTIHelper_2 helper)
     369{
     370#if ENABLE(SAMPLING_TOOL)
     371    m_jit.movl_i32m(1, &inCalledCode);
     372#endif
     373    m_jit.emitRestoreArgumentReference();
     374    X86Assembler::JmpSrc call = m_jit.emitCall();
     375    m_calls.append(CallRecord(call, helper, opcodeIndex));
     376#if ENABLE(SAMPLING_TOOL)
     377    m_jit.movl_i32m(0, &inCalledCode);
     378#endif
     379
     380    return call;
     381}
     382
    365383ALWAYS_INLINE void CTI::emitJumpSlowCaseIfNotJSCell(X86Assembler::RegisterID reg, unsigned opcodeIndex)
    366384{
     
    461479#endif
    462480
     481void CTI::compileOpCallInitializeCallFrame(unsigned callee, unsigned argCount)
     482{
     483    emitGetArg(callee, X86::ecx); // Load callee JSFunction into ecx
     484    m_jit.movl_rm(X86::eax, RegisterFile::CodeBlock * static_cast<int>(sizeof(Register)), X86::edx); // callee CodeBlock was returned in eax
     485    m_jit.movl_i32m(reinterpret_cast<unsigned>(nullJSValue), RegisterFile::OptionalCalleeArguments * static_cast<int>(sizeof(Register)), X86::edx);
     486    m_jit.movl_rm(X86::ecx, RegisterFile::Callee * static_cast<int>(sizeof(Register)), X86::edx);
     487
     488    m_jit.movl_mr(OBJECT_OFFSET(JSFunction, m_scopeChain) + OBJECT_OFFSET(ScopeChain, m_node), X86::ecx, X86::ecx); // newScopeChain
     489    m_jit.movl_i32m(argCount, RegisterFile::ArgumentCount * static_cast<int>(sizeof(Register)), X86::edx);
     490    m_jit.movl_rm(X86::edi, RegisterFile::CallerRegisters * static_cast<int>(sizeof(Register)), X86::edx);
     491    m_jit.movl_rm(X86::ecx, RegisterFile::ScopeChain * static_cast<int>(sizeof(Register)), X86::edx);
     492}
     493
    463494void CTI::compileOpCall(Instruction* instruction, unsigned i, CompileOpCallType type)
    464495{
    465496    int dst = instruction[i + 1].u.operand;
     497    int callee = instruction[i + 2].u.operand;
    466498    int firstArg = instruction[i + 4].u.operand;
    467499    int argCount = instruction[i + 5].u.operand;
     
    494526    X86Assembler::JmpSrc wasEval;
    495527    if (type == OpCallEval) {
    496         emitGetPutArg(instruction[i + 2].u.operand, 0, X86::ecx);
     528        emitGetPutArg(callee, 0, X86::ecx);
    497529        emitCall(i, Machine::cti_op_call_eval);
    498 
    499         emitGetCTIParam(CTI_ARGS_r, X86::edi); // edi := r
    500530
    501531        m_jit.cmpl_i32r(reinterpret_cast<unsigned>(JSImmediate::impossibleValue()), X86::eax);
     
    503533
    504534        // this sets up the first arg to op_cti_call (func), and explicitly leaves the value in ecx (checked just below).
    505         emitGetArg(instruction[i + 2].u.operand, X86::ecx);
     535        emitGetArg(callee, X86::ecx);
    506536    } else {
    507537        // this sets up the first arg to op_cti_call (func), and explicitly leaves the value in ecx (checked just below).
    508         emitGetPutArg(instruction[i + 2].u.operand, 0, X86::ecx);
     538        emitGetPutArg(callee, 0, X86::ecx);
    509539    }
    510540
     
    523553
    524554    // This handles JSFunctions
    525     emitCall(i, ((type == OpConstruct) ? Machine::cti_op_construct_JSConstruct : Machine::cti_op_call_JSFunction));
     555    emitCall(i, (type == OpConstruct) ? Machine::cti_op_construct_JSConstruct : Machine::cti_op_call_JSFunction);
     556
     557    compileOpCallInitializeCallFrame(callee, argCount);
     558
     559    // load ctiCode from the new codeBlock.
     560    m_jit.movl_mr(OBJECT_OFFSET(CodeBlock, ctiCode), X86::eax, X86::eax);
     561
     562    // Setup the new value of 'r' in edi, and on the stack, too.
     563    emitPutCTIParam(X86::edx, CTI_ARGS_r);
     564    m_jit.movl_rr(X86::edx, X86::edi);
    526565
    527566    // Check the ctiCode has been generated - if not, this is handled in a slow case.
     
    12801319            emitCall(i, Machine::cti_op_resolve_func);
    12811320            emitPutResult(instruction[i + 1].u.operand);
    1282             emitGetCTIParam(CTI_ARGS_2ndResult, X86::eax);
    1283             emitPutResult(instruction[i + 2].u.operand);
     1321            emitPutResult(instruction[i + 2].u.operand, X86::edx);
    12841322            i += 4;
    12851323            break;
     
    15651603            emitCall(i, Machine::cti_op_resolve_with_base);
    15661604            emitPutResult(instruction[i + 1].u.operand);
    1567             emitGetCTIParam(CTI_ARGS_2ndResult, X86::eax);
    1568             emitPutResult(instruction[i + 2].u.operand);
     1605            emitPutResult(instruction[i + 2].u.operand, X86::edx);
    15691606            i += 4;
    15701607            break;
     
    23282365            emitCall(i, Machine::cti_op_post_inc);
    23292366            emitPutResult(instruction[i + 1].u.operand);
    2330             emitGetCTIParam(CTI_ARGS_2ndResult, X86::eax);
    2331             emitPutResult(srcDst);
     2367            emitPutResult(srcDst, X86::edx);
    23322368            i += 3;
    23332369            break;
     
    23842420            emitCall(i, Machine::cti_op_post_dec);
    23852421            emitPutResult(instruction[i + 1].u.operand);
    2386             emitGetCTIParam(CTI_ARGS_2ndResult, X86::eax);
    2387             emitPutResult(srcDst);
     2422            emitPutResult(srcDst, X86::edx);
    23882423            i += 3;
    23892424            break;
     
    25002535    // Could use a popl_m, but would need to offset the following instruction if so.
    25012536    m_jit.popl_r(X86::ecx);
    2502     emitGetCTIParam(CTI_ARGS_r, X86::edi); // edi := r
    25032537    emitPutToCallFrameHeader(X86::ecx, RegisterFile::ReturnPC);
    25042538
Note: See TracChangeset for help on using the changeset viewer.