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/JITStubs.cpp

    r59064 r59339  
    17781778}
    17791779
    1780 DEFINE_STUB_FUNCTION(void*, op_call_JSFunction)
     1780DEFINE_STUB_FUNCTION(void*, op_call_jitCompile)
    17811781{
    17821782    STUB_INIT_STACK_FRAME(stackFrame);
     
    17911791    FunctionExecutable* executable = function->jsExecutable();
    17921792    ScopeChainNode* callDataScopeChain = function->scope().node();
    1793     executable->jitCode(stackFrame.callFrame, callDataScopeChain);
     1793    executable->jitCodeForCall(stackFrame.callFrame, callDataScopeChain);
     1794
     1795    return function;
     1796}
     1797
     1798DEFINE_STUB_FUNCTION(void*, op_construct_jitCompile)
     1799{
     1800    STUB_INIT_STACK_FRAME(stackFrame);
     1801
     1802#if !ASSERT_DISABLED
     1803    CallData callData;
     1804    ASSERT(stackFrame.args[0].jsValue().getCallData(callData) == CallTypeJS);
     1805#endif
     1806
     1807    JSFunction* function = asFunction(stackFrame.args[0].jsValue());
     1808    ASSERT(!function->isHostFunction());
     1809    FunctionExecutable* executable = function->jsExecutable();
     1810    ScopeChainNode* callDataScopeChain = function->scope().node();
     1811    executable->jitCodeForConstruct(stackFrame.callFrame, callDataScopeChain);
    17941812
    17951813    return function;
     
    18031821    JSFunction* callee = asFunction(stackFrame.args[0].jsValue());
    18041822    ASSERT(!callee->isHostFunction());
    1805     CodeBlock* newCodeBlock = &callee->jsExecutable()->generatedBytecode();
     1823    CodeBlock* newCodeBlock = &callee->jsExecutable()->generatedBytecodeForCall();
    18061824    int argCount = stackFrame.args[2].int32();
    18071825
     
    18431861}
    18441862
     1863DEFINE_STUB_FUNCTION(VoidPtrPair, op_construct_arityCheck)
     1864{
     1865    STUB_INIT_STACK_FRAME(stackFrame);
     1866
     1867    CallFrame* callFrame = stackFrame.callFrame;
     1868    JSFunction* callee = asFunction(stackFrame.args[0].jsValue());
     1869    ASSERT(!callee->isHostFunction());
     1870    CodeBlock* newCodeBlock = &callee->jsExecutable()->generatedBytecodeForConstruct();
     1871    int argCount = stackFrame.args[2].int32();
     1872
     1873    ASSERT(argCount != newCodeBlock->m_numParameters);
     1874
     1875    CallFrame* oldCallFrame = callFrame->callerFrame();
     1876
     1877    if (argCount > newCodeBlock->m_numParameters) {
     1878        size_t numParameters = newCodeBlock->m_numParameters;
     1879        Register* r = callFrame->registers() + numParameters;
     1880
     1881        Register* argv = r - RegisterFile::CallFrameHeaderSize - numParameters - argCount;
     1882        for (size_t i = 0; i < numParameters; ++i)
     1883            argv[i + argCount] = argv[i];
     1884
     1885        callFrame = CallFrame::create(r);
     1886        callFrame->setCallerFrame(oldCallFrame);
     1887    } else {
     1888        size_t omittedArgCount = newCodeBlock->m_numParameters - argCount;
     1889        Register* r = callFrame->registers() + omittedArgCount;
     1890        Register* newEnd = r + newCodeBlock->m_numCalleeRegisters;
     1891        if (!stackFrame.registerFile->grow(newEnd)) {
     1892            // Rewind to the previous call frame because op_call already optimistically
     1893            // moved the call frame forward.
     1894            stackFrame.callFrame = oldCallFrame;
     1895            throwStackOverflowError(oldCallFrame, stackFrame.globalData, stackFrame.args[1].returnAddress(), STUB_RETURN_ADDRESS);
     1896            RETURN_POINTER_PAIR(0, 0);
     1897        }
     1898
     1899        Register* argv = r - RegisterFile::CallFrameHeaderSize - omittedArgCount;
     1900        for (size_t i = 0; i < omittedArgCount; ++i)
     1901            argv[i] = jsUndefined();
     1902
     1903        callFrame = CallFrame::create(r);
     1904        callFrame->setCallerFrame(oldCallFrame);
     1905    }
     1906
     1907    RETURN_POINTER_PAIR(callee, callFrame);
     1908}
     1909
    18451910#if ENABLE(JIT_OPTIMIZE_CALL)
    18461911DEFINE_STUB_FUNCTION(void*, vm_lazyLinkCall)
     
    18491914    JSFunction* callee = asFunction(stackFrame.args[0].jsValue());
    18501915    ExecutableBase* executable = callee->executable();
    1851     JITCode& jitCode = executable->generatedJITCode();
     1916    JITCode& jitCode = executable->generatedJITCodeForCall();
    18521917   
    18531918    CodeBlock* codeBlock = 0;
    18541919    if (!executable->isHostFunction())
    1855         codeBlock = &static_cast<FunctionExecutable*>(executable)->bytecode(stackFrame.callFrame, callee->scope().node());
     1920        codeBlock = &static_cast<FunctionExecutable*>(executable)->bytecodeForCall(stackFrame.callFrame, callee->scope().node());
    18561921    CallLinkInfo* callLinkInfo = &stackFrame.callFrame->callerFrame()->codeBlock()->getCallLinkInfo(stackFrame.args[1].returnAddress());
    18571922
     
    18601925    else
    18611926        JIT::linkCall(callee, stackFrame.callFrame->callerFrame()->codeBlock(), codeBlock, jitCode, callLinkInfo, stackFrame.args[2].int32(), stackFrame.globalData);
     1927
     1928    return jitCode.addressForCall().executableAddress();
     1929}
     1930
     1931DEFINE_STUB_FUNCTION(void*, vm_lazyLinkConstruct)
     1932{
     1933    STUB_INIT_STACK_FRAME(stackFrame);
     1934    JSFunction* callee = asFunction(stackFrame.args[0].jsValue());
     1935    ExecutableBase* executable = callee->executable();
     1936    JITCode& jitCode = executable->generatedJITCodeForConstruct();
     1937   
     1938    CodeBlock* codeBlock = 0;
     1939    if (!executable->isHostFunction())
     1940        codeBlock = &static_cast<FunctionExecutable*>(executable)->bytecodeForConstruct(stackFrame.callFrame, callee->scope().node());
     1941    CallLinkInfo* callLinkInfo = &stackFrame.callFrame->callerFrame()->codeBlock()->getCallLinkInfo(stackFrame.args[1].returnAddress());
     1942
     1943    if (!callLinkInfo->seenOnce())
     1944        callLinkInfo->setSeen();
     1945    else
     1946        JIT::linkConstruct(callee, stackFrame.callFrame->callerFrame()->codeBlock(), codeBlock, jitCode, callLinkInfo, stackFrame.args[2].int32(), stackFrame.globalData);
    18621947
    18631948    return jitCode.addressForCall().executableAddress();
Note: See TracChangeset for help on using the changeset viewer.