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


Ignore:
Timestamp:
Oct 4, 2008, 2:12:54 PM (17 years ago)
Author:
Darin Adler
Message:

JavaScriptCore:

2008-10-04 Darin Adler <Darin Adler>

Reviewed by Cameron Zwarich.

10% faster on Richards; other v8 benchmarks faster too.
A wash on SunSpider.

This does the minimum necessary to get the speedup. Next step in
cleaning this up is to replace ExecState with a CallFrame class,
and be more judicious about when to pass a call frame and when
to pass a global data pointer, global object pointer, or perhaps
something else entirely.

  • VM/CTI.cpp: Remove the debug-only check of the exception in ctiVMThrowTrampoline -- already checked in the code the trampoline jumps to, so not all that useful. Removed the exec argument from ctiTrampoline. Removed emitDebugExceptionCheck -- no longer needed. (JSC::CTI::emitCall): Removed code to set ExecState::m_callFrame. (JSC::CTI::privateCompileMainPass): Removed code in catch to extract the exception from ExecState::m_exception; instead, the code that jumps into catch will make sure the exception is already in eax.
  • VM/CTI.h: Removed exec from the ctiTrampoline. Also removed the non-helpful "volatile". Temporarily left ARG_exec in as a synonym for ARG_r; I'll change that on a future cleanup pass when introducing more use of the CallFrame type. (JSC::CTI::execute): Removed the ExecState* argument.
  • VM/ExceptionHelpers.cpp: (JSC::InterruptedExecutionError::InterruptedExecutionError): Take JSGlobalData* instead of ExecState*. (JSC::createInterruptedExecutionException): Ditto.
  • VM/ExceptionHelpers.h: Ditto. Also removed an unneeded include.
  • VM/Machine.cpp: (JSC::slideRegisterWindowForCall): Removed the exec and exceptionValue arguments. Changed to return 0 when there's a stack overflow rather than using a separate exception argument to cut down on memory accesses in the calling convention. (JSC::Machine::unwindCallFrame): Removed the exec argument when constructing a DebuggerCallFrame. Also removed code to set ExecState::m_callFrame. (JSC::Machine::throwException): Removed the exec argument when construction a DebuggerCallFrame. (JSC::Machine::execute): Updated to use the register instead of ExecState and also removed various uses of ExecState. (JSC::Machine::debug): (JSC::Machine::privateExecute): Put globalData into a local variable so it can be used throughout the interpreter. Changed the VM_CHECK_EXCEPTION to get the exception in globalData instead of through ExecState. (JSC::Machine::retrieveLastCaller): Turn exec into a registers pointer by calling registers() instead of by getting m_callFrame. (JSC::Machine::callFrame): Ditto. Tweaked exception macros. Made new versions for when you know you have an exception. Get at global exception with ARG_globalData. Got rid of the need to pass in the return value type. (JSC::Machine::cti_op_add): Update to use new version of exception macros. (JSC::Machine::cti_op_pre_inc): Ditto. (JSC::Machine::cti_timeout_check): Ditto. (JSC::Machine::cti_op_instanceof): Ditto. (JSC::Machine::cti_op_new_func): Ditto. (JSC::Machine::cti_op_call_JSFunction): Optimized by using the ARG values directly instead of through local variables -- this gets rid of code that just shuffles things around in the stack frame. Also get rid of ExecState and update for the new way exceptions are handled in slideRegisterWindowForCall. (JSC::Machine::cti_vm_compile): Update to make exec out of r since they are both the same thing now. (JSC::Machine::cti_op_call_NotJSFunction): Ditto. (JSC::Machine::cti_op_init_arguments): Ditto. (JSC::Machine::cti_op_resolve): Ditto. (JSC::Machine::cti_op_construct_JSConstruct): Ditto. (JSC::Machine::cti_op_construct_NotJSConstruct): Ditto. (JSC::Machine::cti_op_resolve_func): Ditto. (JSC::Machine::cti_op_put_by_val): Ditto. (JSC::Machine::cti_op_put_by_val_array): Ditto. (JSC::Machine::cti_op_resolve_skip): Ditto. (JSC::Machine::cti_op_resolve_global): Ditto. (JSC::Machine::cti_op_post_inc): Ditto. (JSC::Machine::cti_op_resolve_with_base): Ditto. (JSC::Machine::cti_op_post_dec): Ditto. (JSC::Machine::cti_op_call_eval): Ditto. (JSC::Machine::cti_op_throw): Ditto. Also rearranged to return the exception value as the return value so it can be used by op_catch. (JSC::Machine::cti_op_push_scope): Ditto. (JSC::Machine::cti_op_in): Ditto. (JSC::Machine::cti_op_del_by_val): Ditto. (JSC::Machine::cti_vm_throw): Ditto. Also rearranged to return the exception value as the return value so it can be used by op_catch.
  • kjs/DebuggerCallFrame.cpp: (JSC::DebuggerCallFrame::functionName): Pass globalData. (JSC::DebuggerCallFrame::evaluate): Eliminated code to make a new ExecState.
  • kjs/DebuggerCallFrame.h: Removed ExecState argument from constructor.
  • kjs/ExecState.h: Eliminated all data members and made ExecState inherit privately from Register instead. Also added a typedef to the future name for this class, which is CallFrame. It's just a Register* that knows it's a pointer at a call frame. The new class can't be constructed or copied. Changed all functions to use the this pointer instead of m_callFrame. Changed exception-related functions to access an exception in JSGlobalData. Removed functions used by CTI to pass the return address to the throw machinery -- this is now done directly with a global in the global data.
  • kjs/FunctionPrototype.cpp: (JSC::functionProtoFuncToString): Pass globalData instead of exec.
  • kjs/InternalFunction.cpp: (JSC::InternalFunction::name): Take globalData instead of exec.
  • kjs/InternalFunction.h: Ditto.
  • kjs/JSGlobalData.cpp: Initialize the new exception global to 0.
  • kjs/JSGlobalData.h: Declare two new globals. One for the current exception and another for the return address used by CTI to implement the throw operation.
  • kjs/JSGlobalObject.cpp: (JSC::JSGlobalObject::init): Removed code to set up globalExec, which is now the same thing as globalCallFrame. (JSC::JSGlobalObject::reset): Get globalExec from our globalExec function so we don't have to repeat the logic twice. (JSC::JSGlobalObject::mark): Removed code to mark the exception; the exception is now stored in JSGlobalData and marked there. (JSC::JSGlobalObject::globalExec): Return a pointer to the end of the global call frame.
  • kjs/JSGlobalObject.h: Removed the globalExec data member.
  • kjs/JSObject.cpp: (JSC::JSObject::putDirectFunction): Pass globalData instead of exec.
  • kjs/collector.cpp: (JSC::Heap::collect): Mark the global exception.
  • profiler/ProfileGenerator.cpp: (JSC::ProfileGenerator::addParentForConsoleStart): Pass globalData instead of exec to createCallIdentifier.
  • profiler/Profiler.cpp: (JSC::Profiler::willExecute): Pass globalData instead of exec to createCallIdentifier. (JSC::Profiler::didExecute): Ditto. (JSC::Profiler::createCallIdentifier): Take globalData instead of exec. (JSC::createCallIdentifierFromFunctionImp): Ditto.
  • profiler/Profiler.h: Change interface to take a JSGlobalData instead of an ExecState.

WebKit/mac:

2008-10-04 Darin Adler <Darin Adler>

Reviewed by Cameron Zwarich.

  • WebView/WebScriptDebugger.mm: (WebScriptDebugger::WebScriptDebugger): Remove 0 passed for ExecState.
File:
1 edited

Legend:

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

    r37294 r37297  
    7575
    7676#if COMPILER(GCC) && PLATFORM(X86)
     77
    7778asm(
    7879".globl _ctiTrampoline" "\n"
     
    8283    "subl $0x24, %esp" "\n"
    8384    "movl $512, %esi" "\n"
    84     "call *0x30(%esp)" "\n" //Ox30 = 0x0C * 4, 0x0C = CTI_ARGS_code
     85    "call *0x30(%esp)" "\n" // Ox30 = 0x0C * 4, 0x0C = CTI_ARGS_code
    8586    "addl $0x24, %esp" "\n"
    8687    "popl %edi" "\n"
     
    9293".globl _ctiVMThrowTrampoline" "\n"
    9394"_ctiVMThrowTrampoline:" "\n"
    94 #ifndef NDEBUG
    95     "movl 0x34(%esp), %ecx" "\n" //Ox34 = 0x0D * 4, 0x0D = CTI_ARGS_exec
    96     "cmpl $0, 8(%ecx)" "\n"
    97     "jne 1f" "\n"
    98     "int3" "\n"
    99     "1:" "\n"
    100 #endif
    10195    "call __ZN3JSC7Machine12cti_vm_throwEPv" "\n"
    10296    "addl $0x24, %esp" "\n"
     
    107101   
    108102#elif COMPILER(MSVC)
    109 extern "C"
    110 {
     103
     104extern "C" {
    111105   
    112     __declspec(naked) JSValue* ctiTrampoline(void* code, ExecState* exec, RegisterFile* registerFile, Register* r, JSValue** exception, Profiler**, JSGlobalData*)
     106    __declspec(naked) JSValue* ctiTrampoline(void* code, RegisterFile*, Register*, JSValue** exception, Profiler**, JSGlobalData*)
    113107    {
    114108        __asm {
     
    129123    {
    130124        __asm {
    131            mov [esp], esp;
     125            mov [esp], esp;
    132126            call JSC::Machine::cti_vm_throw;
    133127            add esp, 0x24;
     
    247241}
    248242
    249 #ifdef NDEBUG
    250 
    251 ALWAYS_INLINE void CTI::emitDebugExceptionCheck()
    252 {
    253 }
    254 
    255 #else
    256 
    257 ALWAYS_INLINE void CTI::emitDebugExceptionCheck()
    258 {
    259     emitGetCTIParam(CTI_ARGS_exec, X86::ecx);
    260     m_jit.cmpl_i32m(0, OBJECT_OFFSET(ExecState, m_exception), X86::ecx);
    261     X86Assembler::JmpSrc noException = m_jit.emitUnlinkedJe();
    262     m_jit.emitInt3();
    263     m_jit.link(noException, m_jit.label());
    264 }
     243#ifndef NDEBUG
    265244
    266245void CTI::printOpcodeOperandTypes(unsigned src1, unsigned src2)
     
    305284    X86Assembler::JmpSrc call = m_jit.emitCall(r);
    306285    m_calls.append(CallRecord(call, opcodeIndex));
    307     emitDebugExceptionCheck();
    308286
    309287    return call;
     
    318296    X86Assembler::JmpSrc call = m_jit.emitCall();
    319297    m_calls.append(CallRecord(call, helper, opcodeIndex));
    320     emitDebugExceptionCheck();
    321298#if ENABLE(SAMPLING_TOOL)
    322299    m_jit.movl_i32m(0, &inCalledCode);
     
    334311    X86Assembler::JmpSrc call = m_jit.emitCall();
    335312    m_calls.append(CallRecord(call, helper, opcodeIndex));
    336     emitDebugExceptionCheck();
    337313#if ENABLE(SAMPLING_TOOL)
    338314    m_jit.movl_i32m(0, &inCalledCode);
     
    350326    X86Assembler::JmpSrc call = m_jit.emitCall();
    351327    m_calls.append(CallRecord(call, helper, opcodeIndex));
    352     emitDebugExceptionCheck();
    353328#if ENABLE(SAMPLING_TOOL)
    354329    m_jit.movl_i32m(0, &inCalledCode);
     
    366341    X86Assembler::JmpSrc call = m_jit.emitCall();
    367342    m_calls.append(CallRecord(call, helper, opcodeIndex));
    368     emitDebugExceptionCheck();
    369343#if ENABLE(SAMPLING_TOOL)
    370344    m_jit.movl_i32m(0, &inCalledCode);
     
    382356    X86Assembler::JmpSrc call = m_jit.emitCall();
    383357    m_calls.append(CallRecord(call, helper, opcodeIndex));
    384     emitDebugExceptionCheck();
    385358#if ENABLE(SAMPLING_TOOL)
    386359    m_jit.movl_i32m(0, &inCalledCode);
     
    12241197
    12251198            // Restore our caller's "r".
    1226             emitGetCTIParam(CTI_ARGS_exec, X86::ecx);
    12271199            emitGetArg(RegisterFile::CallerRegisters, X86::edi);
    12281200            emitPutCTIParam(X86::edi, CTI_ARGS_r);
    1229             m_jit.movl_rm(X86::edi, OBJECT_OFFSET(ExecState, m_callFrame), X86::ecx);
    12301201
    12311202            // Return.
     
    17871758        case op_catch: {
    17881759            emitGetCTIParam(CTI_ARGS_r, X86::edi); // edi := r
    1789             emitGetCTIParam(CTI_ARGS_exec, X86::ecx);
    1790             m_jit.movl_mr(OBJECT_OFFSET(ExecState, m_exception), X86::ecx, X86::eax);
    1791             m_jit.movl_i32m(0, OBJECT_OFFSET(ExecState, m_exception), X86::ecx);
    17921760            emitPutResult(instruction[i + 1].u.operand);
    17931761            i += 2;
Note: See TracChangeset for help on using the changeset viewer.