Changeset 59339 in webkit for trunk/JavaScriptCore/interpreter


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):

Location:
trunk/JavaScriptCore/interpreter
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/interpreter/Interpreter.cpp

    r59064 r59339  
    708708}
    709709
    710 JSValue Interpreter::execute(FunctionExecutable* functionExecutable, CallFrame* callFrame, JSFunction* function, JSObject* thisObj, const ArgList& args, ScopeChainNode* scopeChain, JSValue* exception)
     710JSValue Interpreter::executeCall(FunctionExecutable* functionExecutable, CallFrame* callFrame, JSFunction* function, JSObject* thisObj, const ArgList& args, ScopeChainNode* scopeChain, JSValue* exception)
    711711{
    712712    ASSERT(!scopeChain->globalData->exception);
     
    736736        newCallFrame->r(++dst) = *it;
    737737
    738     CodeBlock* codeBlock = &functionExecutable->bytecode(callFrame, scopeChain);
     738    CodeBlock* codeBlock = &functionExecutable->bytecodeForCall(callFrame, scopeChain);
    739739    newCallFrame = slideRegisterWindowForCall(codeBlock, &m_registerFile, newCallFrame, argc + RegisterFile::CallFrameHeaderSize, argc);
    740740    if (UNLIKELY(!newCallFrame)) {
     
    756756        m_reentryDepth++;
    757757#if ENABLE(JIT)
    758         result = functionExecutable->jitCode(newCallFrame, scopeChain).execute(&m_registerFile, newCallFrame, scopeChain->globalData, exception);
     758        result = functionExecutable->jitCodeForCall(newCallFrame, scopeChain).execute(&m_registerFile, newCallFrame, scopeChain->globalData, exception);
     759#else
     760        result = privateExecute(Normal, &m_registerFile, newCallFrame, exception);
     761#endif
     762        m_reentryDepth--;
     763    }
     764
     765    if (*profiler)
     766        (*profiler)->didExecute(callFrame, function);
     767
     768    m_registerFile.shrink(oldEnd);
     769    return result;
     770}
     771
     772JSValue Interpreter::executeConstruct(FunctionExecutable* functionExecutable, CallFrame* callFrame, JSFunction* function, JSObject* thisObj, const ArgList& args, ScopeChainNode* scopeChain, JSValue* exception)
     773{
     774    ASSERT(!scopeChain->globalData->exception);
     775
     776    if (m_reentryDepth >= MaxSmallThreadReentryDepth) {
     777        if (m_reentryDepth >= callFrame->globalData().maxReentryDepth) {
     778            *exception = createStackOverflowError(callFrame);
     779            return jsNull();
     780        }
     781    }
     782
     783    Register* oldEnd = m_registerFile.end();
     784    int argc = 1 + args.size(); // implicit "this" parameter
     785
     786    if (!m_registerFile.grow(oldEnd + argc)) {
     787        *exception = createStackOverflowError(callFrame);
     788        return jsNull();
     789    }
     790
     791    DynamicGlobalObjectScope globalObjectScope(callFrame, scopeChain->globalObject);
     792
     793    CallFrame* newCallFrame = CallFrame::create(oldEnd);
     794    size_t dst = 0;
     795    newCallFrame->r(0) = JSValue(thisObj);
     796    ArgList::const_iterator end = args.end();
     797    for (ArgList::const_iterator it = args.begin(); it != end; ++it)
     798        newCallFrame->r(++dst) = *it;
     799
     800    CodeBlock* codeBlock = &functionExecutable->bytecodeForConstruct(callFrame, scopeChain);
     801    newCallFrame = slideRegisterWindowForCall(codeBlock, &m_registerFile, newCallFrame, argc + RegisterFile::CallFrameHeaderSize, argc);
     802    if (UNLIKELY(!newCallFrame)) {
     803        *exception = createStackOverflowError(callFrame);
     804        m_registerFile.shrink(oldEnd);
     805        return jsNull();
     806    }
     807    // a 0 codeBlock indicates a built-in caller
     808    newCallFrame->init(codeBlock, 0, scopeChain, callFrame->addHostCallFrameFlag(), 0, argc, function);
     809
     810    Profiler** profiler = Profiler::enabledProfilerReference();
     811    if (*profiler)
     812        (*profiler)->willExecute(callFrame, function);
     813
     814    JSValue result;
     815    {
     816        SamplingTool::CallRecord callRecord(m_sampler.get());
     817
     818        m_reentryDepth++;
     819#if ENABLE(JIT)
     820        result = functionExecutable->jitCodeForConstruct(newCallFrame, scopeChain).execute(&m_registerFile, newCallFrame, scopeChain->globalData, exception);
    759821#else
    760822        result = privateExecute(Normal, &m_registerFile, newCallFrame, exception);
     
    794856        newCallFrame->r(++dst) = jsUndefined();
    795857   
    796     CodeBlock* codeBlock = &FunctionExecutable->bytecode(callFrame, scopeChain);
     858    CodeBlock* codeBlock = &FunctionExecutable->bytecodeForCall(callFrame, scopeChain);
    797859    newCallFrame = slideRegisterWindowForCall(codeBlock, &m_registerFile, newCallFrame, argc + RegisterFile::CallFrameHeaderSize, argc);
    798860    if (UNLIKELY(!newCallFrame)) {
     
    804866    newCallFrame->init(codeBlock, 0, scopeChain, callFrame->addHostCallFrameFlag(), 0, argc, function);
    805867#if ENABLE(JIT)
    806     FunctionExecutable->jitCode(newCallFrame, scopeChain);
     868    FunctionExecutable->jitCodeForCall(newCallFrame, scopeChain);
    807869#endif
    808870
     
    824886        m_reentryDepth++;
    825887#if ENABLE(JIT)
    826         result = closure.functionExecutable->generatedJITCode().execute(&m_registerFile, closure.newCallFrame, closure.globalData, exception);
     888        result = closure.functionExecutable->generatedJITCodeForCall().execute(&m_registerFile, closure.newCallFrame, closure.globalData, exception);
    827889#else
    828890        result = privateExecute(Normal, &m_registerFile, closure.newCallFrame, exception);
     
    35083570        if (callType == CallTypeJS) {
    35093571            ScopeChainNode* callDataScopeChain = callData.js.scopeChain;
    3510             CodeBlock* newCodeBlock = &callData.js.functionExecutable->bytecode(callFrame, callDataScopeChain);
     3572            CodeBlock* newCodeBlock = &callData.js.functionExecutable->bytecodeForCall(callFrame, callDataScopeChain);
    35113573
    35123574            CallFrame* previousCallFrame = callFrame;
     
    36623724        if (callType == CallTypeJS) {
    36633725            ScopeChainNode* callDataScopeChain = callData.js.scopeChain;
    3664             CodeBlock* newCodeBlock = &callData.js.functionExecutable->bytecode(callFrame, callDataScopeChain);
     3726            CodeBlock* newCodeBlock = &callData.js.functionExecutable->bytecodeForCall(callFrame, callDataScopeChain);
    36653727           
    36663728            CallFrame* previousCallFrame = callFrame;
     
    39103972        if (constructType == ConstructTypeJS) {
    39113973            ScopeChainNode* callDataScopeChain = constructData.js.scopeChain;
    3912             CodeBlock* newCodeBlock = &constructData.js.functionExecutable->bytecode(callFrame, callDataScopeChain);
     3974            CodeBlock* newCodeBlock = &constructData.js.functionExecutable->bytecodeForConstruct(callFrame, callDataScopeChain);
    39133975
    39143976            Structure* structure;
  • trunk/JavaScriptCore/interpreter/Interpreter.h

    r58986 r59339  
    9797       
    9898        JSValue execute(ProgramExecutable*, CallFrame*, ScopeChainNode*, JSObject* thisObj, JSValue* exception);
    99         JSValue execute(FunctionExecutable*, CallFrame*, JSFunction*, JSObject* thisObj, const ArgList& args, ScopeChainNode*, JSValue* exception);
     99        JSValue executeCall(FunctionExecutable*, CallFrame*, JSFunction*, JSObject* thisObj, const ArgList& args, ScopeChainNode*, JSValue* exception);
     100        JSValue executeConstruct(FunctionExecutable*, CallFrame*, JSFunction*, JSObject* thisObj, const ArgList& args, ScopeChainNode*, JSValue* exception);
    100101        JSValue execute(EvalExecutable* evalNode, CallFrame* exec, JSObject* thisObj, ScopeChainNode* scopeChain, JSValue* exception);
    101102
Note: See TracChangeset for help on using the changeset viewer.