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


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.h

    r36976 r36997  
    5757#define CTI_ARGS_r 0x0F
    5858#define CTI_ARGS_scopeChain 0x10
    59 #define CTI_ARGS_codeBlock 0x11
    60 #define CTI_ARGS_exception 0x12
    61 #define CTI_ARGS_profilerReference 0x13
     59#define CTI_ARGS_exception 0x11
     60#define CTI_ARGS_profilerReference 0x12
    6261#define ARG_exec ((ExecState*)(ARGS)[CTI_ARGS_exec])
    6362#define ARG_registerFile ((RegisterFile*)(ARGS)[CTI_ARGS_registerFile])
    6463#define ARG_r ((Register*)(ARGS)[CTI_ARGS_r])
    6564#define ARG_scopeChain ((ScopeChainNode*)(ARGS)[CTI_ARGS_scopeChain])
    66 #define ARG_codeBlock ((CodeBlock*)(ARGS)[CTI_ARGS_codeBlock])
    6765#define ARG_exception ((JSValue**)(ARGS)[CTI_ARGS_exception])
    6866#define ARG_profilerReference ((Profiler**)(ARGS)[CTI_ARGS_profilerReference])
    6967
    7068#define ARG_setScopeChain(newScopeChain) (*(volatile ScopeChainNode**)&(ARGS)[CTI_ARGS_scopeChain] = newScopeChain)
    71 #define ARG_setCodeBlock(newCodeBlock) (*(volatile CodeBlock**)&(ARGS)[CTI_ARGS_codeBlock] = newCodeBlock)
    7269#define ARG_setR(newR) (*(volatile Register**)&(ARGS)[CTI_ARGS_r] = newR)
    7370#define ARG_set2ndResult(new2ndResult) (*(volatile JSValue**)&(ARGS)[CTI_ARGS_2ndResult] = new2ndResult)
     
    239236
    240237    extern "C" {
    241         JSValue* ctiTrampoline(void* code, ExecState* exec, RegisterFile* registerFile, Register* r, ScopeChainNode* scopeChain, CodeBlock* codeBlock, JSValue** exception, Profiler**);
     238        JSValue* ctiTrampoline(void* code, ExecState* exec, RegisterFile* registerFile, Register* r, ScopeChainNode* scopeChain, JSValue** exception, Profiler**);
    242239        void ctiVMThrowTrampoline();
    243240    };
     
    323320        }
    324321
    325         inline static JSValue* execute(void* code, ExecState* exec, RegisterFile* registerFile, Register* r, ScopeChainNode* scopeChain, CodeBlock* codeBlock, JSValue** exception)
    326         {
    327             JSValue* value = ctiTrampoline(code, exec, registerFile, r, scopeChain, codeBlock, exception, Profiler::enabledProfilerReference());
     322        inline static JSValue* execute(void* code, ExecState* exec, RegisterFile* registerFile, Register* r, ScopeChainNode* scopeChain, JSValue** exception)
     323        {
     324            JSValue* value = ctiTrampoline(code, exec, registerFile, r, scopeChain, exception, Profiler::enabledProfilerReference());
    328325#if ENABLE(SAMPLING_TOOL)
    329326            currentOpcodeID = static_cast<OpcodeID>(-1);
Note: See TracChangeset for help on using the changeset viewer.