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


Ignore:
Timestamp:
Sep 27, 2008, 10:19:39 AM (17 years ago)
Author:
[email protected]
Message:

2008-09-27 Geoffrey Garen <[email protected]>

Reviewed by Cameron Zwarich.


Store the callee CodeBlock, not the caller CodeBlock, in the call frame
header. Nix the "codeBlock" local variable, and access the callee
CodeBlock through the call frame header instead.


Profit: call + return are simpler, because they don't have to update the
"codeBlock" local variable.


Because CTI keeps "r" in a register, reading the callee CodeBlock relative
to "r" can be very fast, in any cases we care to optimize. Presently,
no such cases seem important.


Also, stop writing "dst" to the call frame header. CTI doesn't use it.


21.6% speedup on empty function call benchmark.
3.8% speedup on SunSpider --v8.
2.1% speedup on v8 benchmark.
0.7% speedup on SunSpider (6% speedup on controlflow-recursive).


Small regression in bytecode, because currently every op_ret reads the
callee CodeBlock to check needsFullScopeChain, and bytecode does not
keep "r" in a register. On-balance, this is probably OK, since CTI is
our high-performance execution model. Also, this should go away once
we make needsFullScopeChain statically determinable at parse time.

  • VM/CTI.cpp: (JSC::CTI::compileOpCall): The speedup! (JSC::CTI::privateCompileSlowCases): ditto
  • VM/CTI.h: (JSC::): Fixed up magic trampoline constants to account for the nixed "codeBlock" argument. (JSC::CTI::execute): Changed trampoline function not to take a "codeBlock" argument, since codeBlock is now stored in the call frame header.


  • VM/Machine.cpp: Read the callee CodeBlock from the register file. Use a NULL CallerRegisters in the call frame header to signal a built-in caller, since CodeBlock is now never NULL.
  • VM/Machine.h: Made some stand-alone functions Machine member functions so they could call the private codeBlock() accessor in the Register class, of which Machine is a friend. Renamed "CallerCodeBlock" to "CodeBlock", since it's no longer the caller's CodeBlock.
  • VM/RegisterFile.h: Marked some methods const to accommodate a const RegisterFile* being passed around in Machine.cpp.
File:
1 edited

Legend:

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

    r36976 r36997  
    538538    emitCall(i, ((type == OpConstruct) ? Machine::cti_op_construct_JSConstruct : Machine::cti_op_call_JSFunction));
    539539
    540     // Initialize the parts of the call frame that have not already been initialized.
    541     emitGetCTIParam(CTI_ARGS_r, X86::edi);
    542     m_jit.movl_i32m(reinterpret_cast<unsigned>(m_codeBlock), RegisterFile::CallerCodeBlock * static_cast<int>(sizeof(Register)), X86::edi);
    543     m_jit.movl_i32m(dst, RegisterFile::ReturnValueRegister * static_cast<int>(sizeof(Register)), X86::edi);
    544 
    545540    // Check the ctiCode has been generated - if not, this is handled in a slow case.
    546541    m_jit.testl_rr(X86::eax, X86::eax);
     
    548543    emitCall(i, X86::eax);
    549544   
    550     // Restore CTI_ARGS_codeBlock. In the interpreter, op_ret does this.
    551     emitPutCTIParam(m_codeBlock, CTI_ARGS_codeBlock);
    552 
    553545    X86Assembler::JmpDst end = m_jit.label();
    554546    m_jit.link(wasNotJSFunction, end);
     
    24892481            // Instead of checking for 0 we could initialize the CodeBlock::ctiCode to point to a trampoline that would trigger the translation.
    24902482
    2491             // Restore CTI_ARGS_codeBlock. In the interpreter, op_ret does this.
    2492             emitPutCTIParam(m_codeBlock, CTI_ARGS_codeBlock);
    2493 
    24942483            // Put the return value in dst. In the interpreter, op_ret does this.
    24952484            emitPutResult(instruction[i + 1].u.operand);
Note: See TracChangeset for help on using the changeset viewer.