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/runtime/Executable.cpp

    r54571 r59339  
    5858FunctionExecutable::~FunctionExecutable()
    5959{
    60     delete m_codeBlock;
     60    delete m_codeBlockForCall;
     61    delete m_codeBlockForConstruct;
    6162}
    6263
     
    113114}
    114115
    115 void FunctionExecutable::compile(ExecState*, ScopeChainNode* scopeChainNode)
     116void FunctionExecutable::compileForCall(ExecState*, ScopeChainNode* scopeChainNode)
    116117{
    117118    JSGlobalData* globalData = scopeChainNode->globalData;
     
    125126    JSGlobalObject* globalObject = scopeChain.globalObject();
    126127
    127     ASSERT(!m_codeBlock);
    128     m_codeBlock = new FunctionCodeBlock(this, FunctionCode, source().provider(), source().startOffset());
    129     OwnPtr<BytecodeGenerator> generator(new BytecodeGenerator(body.get(), globalObject->debugger(), scopeChain, m_codeBlock->symbolTable(), m_codeBlock));
    130     generator->generate();
    131     m_numParameters = m_codeBlock->m_numParameters;
    132     ASSERT(m_numParameters);
    133     m_numVariables = m_codeBlock->m_numVars;
     128    ASSERT(!m_codeBlockForCall);
     129    m_codeBlockForCall = new FunctionCodeBlock(this, FunctionCode, source().provider(), source().startOffset(), false);
     130    OwnPtr<BytecodeGenerator> generator(new BytecodeGenerator(body.get(), globalObject->debugger(), scopeChain, m_codeBlockForCall->symbolTable(), m_codeBlockForCall));
     131    generator->generate();
     132    m_numParametersForCall = m_codeBlockForCall->m_numParameters;
     133    ASSERT(m_numParametersForCall);
     134    m_numVariables = m_codeBlockForCall->m_numVars;
     135    m_symbolTable = m_codeBlockForCall->sharedSymbolTable();
    134136
    135137    body->destroyData();
    136138}
    137139
     140void FunctionExecutable::compileForConstruct(ExecState*, ScopeChainNode* scopeChainNode)
     141{
     142    JSGlobalData* globalData = scopeChainNode->globalData;
     143    RefPtr<FunctionBodyNode> body = globalData->parser->parse<FunctionBodyNode>(globalData, 0, 0, m_source);
     144    if (m_forceUsesArguments)
     145        body->setUsesArguments();
     146    body->finishParsing(m_parameters, m_name);
     147    recordParse(body->features(), body->lineNo(), body->lastLine());
     148
     149    ScopeChain scopeChain(scopeChainNode);
     150    JSGlobalObject* globalObject = scopeChain.globalObject();
     151
     152    ASSERT(!m_codeBlockForConstruct);
     153    m_codeBlockForConstruct = new FunctionCodeBlock(this, FunctionCode, source().provider(), source().startOffset(), true);
     154    OwnPtr<BytecodeGenerator> generator(new BytecodeGenerator(body.get(), globalObject->debugger(), scopeChain, m_codeBlockForConstruct->symbolTable(), m_codeBlockForConstruct));
     155    generator->generate();
     156    m_numParametersForConstruct = m_codeBlockForConstruct->m_numParameters;
     157    ASSERT(m_numParametersForConstruct);
     158    m_numVariables = m_codeBlockForConstruct->m_numVars;
     159    m_symbolTable = m_codeBlockForConstruct->sharedSymbolTable();
     160
     161    body->destroyData();
     162}
     163
    138164#if ENABLE(JIT)
    139165
     
    141167{
    142168    CodeBlock* codeBlock = &bytecode(exec, scopeChainNode);
    143     m_jitCode = JIT::compile(scopeChainNode->globalData, codeBlock);
     169    m_jitCodeForCall = JIT::compile(scopeChainNode->globalData, codeBlock);
    144170
    145171#if !ENABLE(OPCODE_SAMPLING)
     
    152178{
    153179    CodeBlock* codeBlock = &bytecode(exec, scopeChainNode);
    154     m_jitCode = JIT::compile(scopeChainNode->globalData, codeBlock);
     180    m_jitCodeForCall = JIT::compile(scopeChainNode->globalData, codeBlock);
    155181
    156182#if !ENABLE(OPCODE_SAMPLING)
     
    160186}
    161187
    162 void FunctionExecutable::generateJITCode(ExecState* exec, ScopeChainNode* scopeChainNode)
    163 {
    164     CodeBlock* codeBlock = &bytecode(exec, scopeChainNode);
    165     m_jitCode = JIT::compile(scopeChainNode->globalData, codeBlock);
     188void FunctionExecutable::generateJITCodeForCall(ExecState* exec, ScopeChainNode* scopeChainNode)
     189{
     190    CodeBlock* codeBlock = &bytecodeForCall(exec, scopeChainNode);
     191    m_jitCodeForCall = JIT::compile(scopeChainNode->globalData, codeBlock);
    166192
    167193#if !ENABLE(OPCODE_SAMPLING)
     
    171197}
    172198
     199void FunctionExecutable::generateJITCodeForConstruct(ExecState* exec, ScopeChainNode* scopeChainNode)
     200{
     201    CodeBlock* codeBlock = &bytecodeForConstruct(exec, scopeChainNode);
     202    m_jitCodeForConstruct = JIT::compile(scopeChainNode->globalData, codeBlock);
     203
     204#if !ENABLE(OPCODE_SAMPLING)
     205    if (!BytecodeGenerator::dumpsGeneratedCode())
     206        codeBlock->discardBytecode();
     207#endif
     208}
     209
    173210#endif
    174211
    175212void FunctionExecutable::markAggregate(MarkStack& markStack)
    176213{
    177     if (m_codeBlock)
    178         m_codeBlock->markAggregate(markStack);
     214    if (m_codeBlockForCall)
     215        m_codeBlockForCall->markAggregate(markStack);
     216    if (m_codeBlockForConstruct)
     217        m_codeBlockForConstruct->markAggregate(markStack);
    179218}
    180219
     
    189228    JSGlobalObject* globalObject = scopeChain.globalObject();
    190229
    191     OwnPtr<CodeBlock> newCodeBlock(new FunctionCodeBlock(this, FunctionCode, source().provider(), source().startOffset()));
     230    OwnPtr<CodeBlock> newCodeBlock(new FunctionCodeBlock(this, FunctionCode, source().provider(), source().startOffset(), codeBlock->m_isConstructor));
    192231    globalData->functionCodeBlockBeingReparsed = newCodeBlock.get();
    193232
     
    200239#if ENABLE(JIT)
    201240    JITCode newJITCode = JIT::compile(globalData, newCodeBlock.get());
    202     ASSERT(newJITCode.size() == generatedJITCode().size());
     241    ASSERT(codeBlock->m_isConstructor ? newJITCode.size() == generatedJITCodeForConstruct().size() : newJITCode.size() == generatedJITCodeForCall().size());
    203242#endif
    204243
     
    225264#if ENABLE(JIT)
    226265    JITCode newJITCode = JIT::compile(globalData, newCodeBlock.get());
    227     ASSERT(newJITCode.size() == generatedJITCode().size());
     266    ASSERT(newJITCode.size() == generatedJITCodeForCall().size());
    228267#endif
    229268
     
    233272void FunctionExecutable::recompile(ExecState*)
    234273{
    235     delete m_codeBlock;
    236     m_codeBlock = 0;
    237     m_numParameters = NUM_PARAMETERS_NOT_COMPILED;
    238 #if ENABLE(JIT)
    239     m_jitCode = JITCode();
     274    delete m_codeBlockForCall;
     275    m_codeBlockForCall = 0;
     276    delete m_codeBlockForConstruct;
     277    m_codeBlockForConstruct = 0;
     278    m_numParametersForCall = NUM_PARAMETERS_NOT_COMPILED;
     279    m_numParametersForConstruct = NUM_PARAMETERS_NOT_COMPILED;
     280#if ENABLE(JIT)
     281    m_jitCodeForCall = JITCode();
     282    m_jitCodeForConstruct = JITCode();
    240283#endif
    241284}
Note: See TracChangeset for help on using the changeset viewer.