Ignore:
Timestamp:
May 12, 2010, 9:01:56 PM (15 years ago)
Author:
[email protected]
Message:

https://bugs.webkit.org/show_bug.cgi?id=39039
Provide support for separate bytecode/JIT code translations for call/construct usage
This will allow us to produce code generated specifically for use as a constructor, not for general function use.

Reviewed by Oliver Hunt.

  • bytecode/CodeBlock.cpp:

(JSC::CodeBlock::CodeBlock):
(JSC::CodeBlock::unlinkCallers):

  • bytecode/CodeBlock.h:

(JSC::CodeBlock::getBytecodeIndex):
(JSC::CodeBlock::getJITCode):
(JSC::CodeBlock::executablePool):
(JSC::GlobalCodeBlock::GlobalCodeBlock):
(JSC::FunctionCodeBlock::FunctionCodeBlock):

  • interpreter/Interpreter.cpp:

(JSC::Interpreter::executeCall):
(JSC::Interpreter::executeConstruct):
(JSC::Interpreter::prepareForRepeatCall):
(JSC::Interpreter::execute):
(JSC::Interpreter::privateExecute):

  • interpreter/Interpreter.h:
  • jit/JIT.cpp:

(JSC::JIT::unlinkCallOrConstruct):
(JSC::JIT::linkConstruct):

  • jit/JIT.h:
  • jit/JITCall.cpp:

(JSC::JIT::compileOpCall):
(JSC::JIT::compileOpCallSlowCase):

  • jit/JITOpcodes.cpp:

(JSC::JIT::privateCompileCTIMachineTrampolines):

  • jit/JITOpcodes32_64.cpp:

(JSC::JIT::privateCompileCTIMachineTrampolines):

  • jit/JITPropertyAccess.cpp:

(JSC::JIT::emitSlow_op_get_by_val):

  • jit/JITPropertyAccess32_64.cpp:

(JSC::JIT::emitSlow_op_get_by_val):

  • jit/JITStubs.cpp:

(JSC::DEFINE_STUB_FUNCTION):

  • jit/JITStubs.h:

(JSC::JITThunks::ctiVirtualConstructLink):
(JSC::JITThunks::ctiVirtualConstruct):
(JSC::):

  • jit/SpecializedThunkJIT.h:

(JSC::SpecializedThunkJIT::finalize):

  • runtime/Arguments.h:

(JSC::JSActivation::copyRegisters):

  • runtime/ArrayPrototype.cpp:

(JSC::isNumericCompareFunction):

  • runtime/Executable.cpp:

(JSC::FunctionExecutable::~FunctionExecutable):
(JSC::FunctionExecutable::compileForCall):
(JSC::FunctionExecutable::compileForConstruct):
(JSC::EvalExecutable::generateJITCode):
(JSC::ProgramExecutable::generateJITCode):
(JSC::FunctionExecutable::generateJITCodeForCall):
(JSC::FunctionExecutable::generateJITCodeForConstruct):
(JSC::FunctionExecutable::markAggregate):
(JSC::FunctionExecutable::reparseExceptionInfo):
(JSC::EvalExecutable::reparseExceptionInfo):
(JSC::FunctionExecutable::recompile):

  • runtime/Executable.h:

(JSC::ExecutableBase::ExecutableBase):
(JSC::ExecutableBase::isHostFunction):
(JSC::ExecutableBase::generatedJITCodeForCall):
(JSC::ExecutableBase::generatedJITCodeForConstruct):
(JSC::NativeExecutable::NativeExecutable):
(JSC::EvalExecutable::jitCode):
(JSC::ProgramExecutable::jitCode):
(JSC::FunctionExecutable::bytecodeForCall):
(JSC::FunctionExecutable::isGeneratedForCall):
(JSC::FunctionExecutable::generatedBytecodeForCall):
(JSC::FunctionExecutable::bytecodeForConstruct):
(JSC::FunctionExecutable::isGeneratedForConstruct):
(JSC::FunctionExecutable::generatedBytecodeForConstruct):
(JSC::FunctionExecutable::symbolTable):
(JSC::FunctionExecutable::FunctionExecutable):
(JSC::FunctionExecutable::jitCodeForCall):
(JSC::FunctionExecutable::jitCodeForConstruct):

  • runtime/JSActivation.h:

(JSC::JSActivation::JSActivationData::JSActivationData):

  • runtime/JSFunction.cpp:

(JSC::JSFunction::~JSFunction):
(JSC::JSFunction::call):
(JSC::JSFunction::construct):

  • runtime/JSGlobalData.cpp:

(JSC::JSGlobalData::numericCompareFunction):

File:
1 edited

Legend:

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

    r59334 r59339  
    7878    loadPtr(Address(regT0, OBJECT_OFFSETOF(JSFunction, m_executable)), regT2);
    7979
    80     Jump isNativeFunc2 = branch32(Equal, Address(regT2, OBJECT_OFFSETOF(FunctionExecutable, m_numParameters)), Imm32(0));
    81 
    82     Jump hasCodeBlock2 = branch32(GreaterThan, Address(regT2, OBJECT_OFFSETOF(FunctionExecutable, m_numParameters)), Imm32(0));
     80    Jump isNativeFunc1 = branch32(Equal, Address(regT2, OBJECT_OFFSETOF(FunctionExecutable, m_numParametersForCall)), Imm32(0));
     81
     82    Jump hasCodeBlock1 = branch32(GreaterThan, Address(regT2, OBJECT_OFFSETOF(FunctionExecutable, m_numParametersForCall)), Imm32(0));
     83    preserveReturnAddressAfterCall(regT3);
     84    restoreArgumentReference();
     85    Call callJSFunction1 = call();
     86    loadPtr(Address(regT0, OBJECT_OFFSETOF(JSFunction, m_executable)), regT2);
     87    emitGetJITStubArg(2, regT1); // argCount
     88    restoreReturnAddressBeforeReturn(regT3);
     89    hasCodeBlock1.link(this);
     90
     91    // Check argCount matches callee arity.
     92    Jump arityCheckOkay1 = branch32(Equal, Address(regT2, OBJECT_OFFSETOF(FunctionExecutable, m_numParametersForCall)), regT1);
     93    preserveReturnAddressAfterCall(regT3);
     94    emitPutJITStubArg(regT3, 1); // return address
     95    restoreArgumentReference();
     96    Call callArityCheck1 = call();
     97    move(regT1, callFrameRegister);
     98    emitGetJITStubArg(2, regT1); // argCount
     99    restoreReturnAddressBeforeReturn(regT3);
     100    arityCheckOkay1.link(this);
     101
     102    isNativeFunc1.link(this);
     103
     104    compileOpCallInitializeCallFrame();
     105    preserveReturnAddressAfterCall(regT3);
     106    emitPutJITStubArg(regT3, 1); // return address
     107    restoreArgumentReference();
     108    Call callLazyLinkCall1 = call();
     109    restoreReturnAddressBeforeReturn(regT3);
     110    jump(regT0);
     111
     112    // VirtualConstructLink Trampoline
     113    // regT0 holds callee, regT1 holds argCount.  regT2 will hold the FunctionExecutable.
     114    Label virtualConstructLinkBegin = align();
     115    loadPtr(Address(regT0, OBJECT_OFFSETOF(JSFunction, m_executable)), regT2);
     116
     117    Jump isNativeFunc2 = branch32(Equal, Address(regT2, OBJECT_OFFSETOF(FunctionExecutable, m_numParametersForConstruct)), Imm32(0));
     118
     119    Jump hasCodeBlock2 = branch32(GreaterThan, Address(regT2, OBJECT_OFFSETOF(FunctionExecutable, m_numParametersForConstruct)), Imm32(0));
    83120    preserveReturnAddressAfterCall(regT3);
    84121    restoreArgumentReference();
     
    90127
    91128    // Check argCount matches callee arity.
    92     Jump arityCheckOkay2 = branch32(Equal, Address(regT2, OBJECT_OFFSETOF(FunctionExecutable, m_numParameters)), regT1);
     129    Jump arityCheckOkay2 = branch32(Equal, Address(regT2, OBJECT_OFFSETOF(FunctionExecutable, m_numParametersForConstruct)), regT1);
    93130    preserveReturnAddressAfterCall(regT3);
    94131    emitPutJITStubArg(regT3, 1); // return address
     
    106143    emitPutJITStubArg(regT3, 1); // return address
    107144    restoreArgumentReference();
    108     Call callLazyLinkCall = call();
     145    Call callLazyLinkCall2 = call();
    109146    restoreReturnAddressBeforeReturn(regT3);
    110147    jump(regT0);
     
    115152    loadPtr(Address(regT0, OBJECT_OFFSETOF(JSFunction, m_executable)), regT2);
    116153
    117     Jump isNativeFunc3 = branch32(Equal, Address(regT2, OBJECT_OFFSETOF(FunctionExecutable, m_numParameters)), Imm32(0));
    118 
    119     Jump hasCodeBlock3 = branch32(GreaterThan, Address(regT2, OBJECT_OFFSETOF(FunctionExecutable, m_numParameters)), Imm32(0));
     154    Jump isNativeFunc3 = branch32(Equal, Address(regT2, OBJECT_OFFSETOF(FunctionExecutable, m_numParametersForCall)), Imm32(0));
     155
     156    Jump hasCodeBlock3 = branch32(GreaterThan, Address(regT2, OBJECT_OFFSETOF(FunctionExecutable, m_numParametersForCall)), Imm32(0));
    120157    preserveReturnAddressAfterCall(regT3);
    121158    restoreArgumentReference();
    122     Call callJSFunction1 = call();
     159    Call callJSFunction3 = call();
    123160    emitGetJITStubArg(2, regT1); // argCount
    124161    restoreReturnAddressBeforeReturn(regT3);
     
    127164   
    128165    // Check argCount matches callee arity.
    129     Jump arityCheckOkay3 = branch32(Equal, Address(regT2, OBJECT_OFFSETOF(FunctionExecutable, m_numParameters)), regT1);
     166    Jump arityCheckOkay3 = branch32(Equal, Address(regT2, OBJECT_OFFSETOF(FunctionExecutable, m_numParametersForCall)), regT1);
    130167    preserveReturnAddressAfterCall(regT3);
    131168    emitPutJITStubArg(regT3, 1); // return address
    132169    restoreArgumentReference();
    133     Call callArityCheck1 = call();
     170    Call callArityCheck3 = call();
    134171    move(regT1, callFrameRegister);
    135172    emitGetJITStubArg(2, regT1); // argCount
     
    141178
    142179    compileOpCallInitializeCallFrame();
    143     loadPtr(Address(regT2, OBJECT_OFFSETOF(FunctionExecutable, m_jitCode)), regT0);
     180    loadPtr(Address(regT2, OBJECT_OFFSETOF(FunctionExecutable, m_jitCodeForCall)), regT0);
    144181    jump(regT0);
    145182
     183    // VirtualConstruct Trampoline
     184    // regT0 holds callee, regT1 holds argCount.  regT2 will hold the FunctionExecutable.
     185    Label virtualConstructBegin = align();
     186    loadPtr(Address(regT0, OBJECT_OFFSETOF(JSFunction, m_executable)), regT2);
     187
     188    Jump isNativeFunc4 = branch32(Equal, Address(regT2, OBJECT_OFFSETOF(FunctionExecutable, m_numParametersForConstruct)), Imm32(0));
     189
     190    Jump hasCodeBlock4 = branch32(GreaterThan, Address(regT2, OBJECT_OFFSETOF(FunctionExecutable, m_numParametersForConstruct)), Imm32(0));
     191    preserveReturnAddressAfterCall(regT3);
     192    restoreArgumentReference();
     193    Call callJSFunction4 = call();
     194    emitGetJITStubArg(2, regT1); // argCount
     195    restoreReturnAddressBeforeReturn(regT3);
     196    loadPtr(Address(regT0, OBJECT_OFFSETOF(JSFunction, m_executable)), regT2);
     197    hasCodeBlock4.link(this);
     198   
     199    // Check argCount matches callee arity.
     200    Jump arityCheckOkay4 = branch32(Equal, Address(regT2, OBJECT_OFFSETOF(FunctionExecutable, m_numParametersForConstruct)), regT1);
     201    preserveReturnAddressAfterCall(regT3);
     202    emitPutJITStubArg(regT3, 1); // return address
     203    restoreArgumentReference();
     204    Call callArityCheck4 = call();
     205    move(regT1, callFrameRegister);
     206    emitGetJITStubArg(2, regT1); // argCount
     207    restoreReturnAddressBeforeReturn(regT3);
     208    loadPtr(Address(regT0, OBJECT_OFFSETOF(JSFunction, m_executable)), regT2);
     209    arityCheckOkay4.link(this);
     210
     211    isNativeFunc4.link(this);
     212
     213    compileOpCallInitializeCallFrame();
     214    loadPtr(Address(regT2, OBJECT_OFFSETOF(FunctionExecutable, m_jitCodeForConstruct)), regT0);
     215    jump(regT0);
     216
     217    // NativCall Trampoline
    146218    Label nativeCallThunk = align();
    147219    preserveReturnAddressAfterCall(regT0);
     
    444516    patchBuffer.link(string_failureCases3Call, FunctionPtr(cti_op_get_by_id_string_fail));
    445517#endif
     518#if ENABLE(JIT_OPTIMIZE_CALL)
    446519    patchBuffer.link(callArityCheck1, FunctionPtr(cti_op_call_arityCheck));
    447     patchBuffer.link(callJSFunction1, FunctionPtr(cti_op_call_JSFunction));
    448 #if ENABLE(JIT_OPTIMIZE_CALL)
    449     patchBuffer.link(callArityCheck2, FunctionPtr(cti_op_call_arityCheck));
    450     patchBuffer.link(callJSFunction2, FunctionPtr(cti_op_call_JSFunction));
    451     patchBuffer.link(callLazyLinkCall, FunctionPtr(cti_vm_lazyLinkCall));
     520    patchBuffer.link(callJSFunction1, FunctionPtr(cti_op_call_jitCompile));
     521    patchBuffer.link(callLazyLinkCall1, FunctionPtr(cti_vm_lazyLinkCall));
     522    patchBuffer.link(callArityCheck2, FunctionPtr(cti_op_construct_arityCheck));
     523    patchBuffer.link(callJSFunction2, FunctionPtr(cti_op_construct_jitCompile));
     524    patchBuffer.link(callLazyLinkCall2, FunctionPtr(cti_vm_lazyLinkConstruct));
    452525#endif
     526    patchBuffer.link(callArityCheck3, FunctionPtr(cti_op_call_arityCheck));
     527    patchBuffer.link(callJSFunction3, FunctionPtr(cti_op_call_jitCompile));
     528    patchBuffer.link(callArityCheck4, FunctionPtr(cti_op_construct_arityCheck));
     529    patchBuffer.link(callJSFunction4, FunctionPtr(cti_op_construct_jitCompile));
    453530
    454531    CodeRef finalCode = patchBuffer.finalizeCode();
     
    456533
    457534    trampolines->ctiVirtualCallLink = trampolineAt(finalCode, virtualCallLinkBegin);
     535    trampolines->ctiVirtualConstructLink = trampolineAt(finalCode, virtualConstructLinkBegin);
    458536    trampolines->ctiVirtualCall = trampolineAt(finalCode, virtualCallBegin);
     537    trampolines->ctiVirtualConstruct = trampolineAt(finalCode, virtualConstructBegin);
    459538    trampolines->ctiNativeCallThunk = adoptRef(new NativeExecutable(JITCode(JITCode::HostFunction(trampolineAt(finalCode, nativeCallThunk)))));
    460539#if ENABLE(JIT_OPTIMIZE_MOD)
Note: See TracChangeset for help on using the changeset viewer.