Ignore:
Timestamp:
Jul 24, 2013, 9:00:22 PM (12 years ago)
Author:
[email protected]
Message:

fourthTier: Executable and CodeBlock should be aware of DFG::Plans that complete asynchronously
https://bugs.webkit.org/show_bug.cgi?id=116350

Reviewed by Oliver Hunt.

This refactors compilation so that:

  • JITStubs knows exactly what the result of compilation was. For example, if compilation was deferred, it will now know this.
  • The set of things that has to happen to install compiled code is now factored out into JSC::installOptimizedCode().
  • A bunch of the code in Executable.cpp is now made more common to reduce code duplication. For example, the heap heuristics stuff is now in one place.

(JSC::ProgramCodeBlock::compileOptimized):
(JSC::ProgramCodeBlock::replaceWithDeferredOptimizedCode):
(JSC):
(JSC::EvalCodeBlock::compileOptimized):
(JSC::EvalCodeBlock::replaceWithDeferredOptimizedCode):
(JSC::FunctionCodeBlock::compileOptimized):
(JSC::FunctionCodeBlock::replaceWithDeferredOptimizedCode):
(JSC::ProgramCodeBlock::jitCompileImpl):
(JSC::EvalCodeBlock::jitCompileImpl):
(JSC::FunctionCodeBlock::jitCompileImpl):

  • bytecode/CodeBlock.h:

(CodeBlock):
(JSC::CodeBlock::jitCompile):
(ProgramCodeBlock):
(EvalCodeBlock):
(FunctionCodeBlock):

  • dfg/DFGDesiredIdentifiers.cpp:

(JSC::DFG::DesiredIdentifiers::numberOfIdentifiers):
(DFG):
(JSC::DFG::DesiredIdentifiers::at):

  • dfg/DFGDesiredIdentifiers.h:

(JSC):
(DesiredIdentifiers):

  • dfg/DFGDriver.cpp:

(JSC::DFG::compile):
(JSC::DFG::tryCompile):
(JSC::DFG::tryCompileFunction):
(JSC::DFG::tryFinalizePlan):
(DFG):

  • dfg/DFGDriver.h:

(DFG):
(JSC::DFG::tryCompile):
(JSC::DFG::tryCompileFunction):
(JSC::DFG::tryFinalizePlan):

  • dfg/DFGGraph.cpp:

(JSC::DFG::Graph::Graph):

  • dfg/DFGJITFinalizer.cpp:

(JSC::DFG::JITFinalizer::finalizeCommon):

  • dfg/DFGPlan.cpp:

(JSC::DFG::Plan::Plan):
(JSC::DFG::Plan::compileInThread):
(JSC::DFG::Plan::reallyAdd):

  • dfg/DFGPlan.h:

(JSC):
(Plan):
(DFG):

  • ftl/FTLJITFinalizer.cpp:

(JSC::FTL::JITFinalizer::finalizeFunction):

  • jit/JITDriver.h:

(JSC::jitCompileIfAppropriateImpl):
(JSC::jitCompileFunctionIfAppropriateImpl):
(JSC):
(JSC::jitCompileIfAppropriate):
(JSC::jitCompileFunctionIfAppropriate):

  • jit/JITStubs.cpp:

(JSC::DEFINE_STUB_FUNCTION):

  • llint/LLIntSlowPaths.cpp:

(JSC::LLInt::jitCompileAndSetHeuristics):

  • runtime/CompilationResult.cpp: Added.

(WTF):
(WTF::printInternal):

  • runtime/CompilationResult.h: Added.

(JSC):
(WTF):

  • runtime/Executable.cpp:

(JSC::EvalExecutable::compileOptimized):
(JSC::EvalExecutable::jitCompile):
(JSC::EvalExecutable::compileInternal):
(JSC::EvalExecutable::replaceWithDeferredOptimizedCode):
(JSC):
(JSC::ProgramExecutable::compileOptimized):
(JSC::ProgramExecutable::jitCompile):
(JSC::ProgramExecutable::compileInternal):
(JSC::ProgramExecutable::replaceWithDeferredOptimizedCode):
(JSC::FunctionExecutable::compileOptimizedForCall):
(JSC::FunctionExecutable::compileOptimizedForConstruct):
(JSC::FunctionExecutable::jitCompileForCall):
(JSC::FunctionExecutable::jitCompileForConstruct):
(JSC::FunctionExecutable::compileForCallInternal):
(JSC::FunctionExecutable::replaceWithDeferredOptimizedCodeForCall):
(JSC::FunctionExecutable::compileForConstructInternal):
(JSC::FunctionExecutable::replaceWithDeferredOptimizedCodeForConstruct):

  • runtime/Executable.h:

(ScriptExecutable):
(EvalExecutable):
(ProgramExecutable):
(FunctionExecutable):
(JSC::FunctionExecutable::compileOptimizedFor):
(JSC::FunctionExecutable::replaceWithDeferredOptimizedCodeFor):
(JSC::FunctionExecutable::jitCompileFor):

  • runtime/ExecutionHarness.h:

(JSC::prepareForExecutionImpl):
(JSC::prepareFunctionForExecutionImpl):
(JSC):
(JSC::installOptimizedCode):
(JSC::prepareForExecution):
(JSC::prepareFunctionForExecution):
(JSC::replaceWithDeferredOptimizedCode):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/jit/JITDriver.h

    r153147 r153165  
    3232
    3333#include "BytecodeGenerator.h"
     34#include "CompilationResult.h"
    3435#include "DFGDriver.h"
    3536#include "JIT.h"
     
    3940
    4041template<typename CodeBlockType>
    41 inline bool jitCompileIfAppropriate(ExecState* exec, CodeBlockType* codeBlock, RefPtr<JITCode>& jitCode, JITCode::JITType jitType, unsigned bytecodeIndex, JITCompilationEffort effort)
     42inline CompilationResult jitCompileIfAppropriateImpl(
     43    ExecState* exec, CodeBlockType* codeBlock, RefPtr<JITCode>& jitCode,
     44    JITCode::JITType jitType, unsigned bytecodeIndex, JITCompilationEffort effort)
    4245{
    4346    VM& vm = exec->vm();
    4447   
    4548    if (jitType == codeBlock->getJITType())
    46         return true;
     49        return CompilationNotNeeded;
    4750   
    4851    if (!vm.canUseJIT())
    49         return true;
     52        return CompilationNotNeeded; // FIXME: Investigate if this is right. https://bugs.webkit.org/show_bug.cgi?id=116246
    5053   
    5154    codeBlock->unlinkIncomingCalls();
     
    5457   
    5558    if (JITCode::isOptimizingJIT(jitType)) {
    56         if (DFG::tryCompile(exec, codeBlock, jitCode, bytecodeIndex))
     59        CompilationResult result =
     60            DFG::tryCompile(exec, codeBlock, jitCode, bytecodeIndex);
     61        if (result == CompilationSuccessful)
    5762            codeBlock->alternative()->unlinkIncomingCalls();
    5863        else {
    5964            ASSERT(oldJITCode == jitCode);
    60             return false;
     65            return result;
    6166        }
    6267    } else {
     
    6570            jitCode = result;
    6671        else
    67             return false;
     72            return CompilationFailed;
    6873    }
    6974   
    70     codeBlock->setJITCode(jitCode, MacroAssemblerCodePtr());
    71    
    72     return true;
     75    return CompilationSuccessful;
    7376}
    7477
    75 inline bool jitCompileFunctionIfAppropriate(ExecState* exec, FunctionCodeBlock* codeBlock, RefPtr<JITCode>& jitCode, MacroAssemblerCodePtr& jitCodeWithArityCheck, JITCode::JITType jitType, unsigned bytecodeIndex, JITCompilationEffort effort)
     78inline CompilationResult jitCompileFunctionIfAppropriateImpl(
     79    ExecState* exec, FunctionCodeBlock* codeBlock, RefPtr<JITCode>& jitCode,
     80    MacroAssemblerCodePtr& jitCodeWithArityCheck, JITCode::JITType jitType,
     81    unsigned bytecodeIndex, JITCompilationEffort effort)
    7682{
    7783    VM& vm = exec->vm();
    7884   
    7985    if (jitType == codeBlock->getJITType())
    80         return true;
     86        return CompilationNotNeeded;
    8187   
    8288    if (!vm.canUseJIT())
    83         return true;
     89        return CompilationNotNeeded; // FIXME: Investigate if this is right. https://bugs.webkit.org/show_bug.cgi?id=116246
    8490   
    8591    codeBlock->unlinkIncomingCalls();
     
    8995   
    9096    if (JITCode::isOptimizingJIT(jitType)) {
    91         if (DFG::tryCompileFunction(exec, codeBlock, jitCode, jitCodeWithArityCheck, bytecodeIndex))
     97        CompilationResult result = DFG::tryCompileFunction(
     98            exec, codeBlock, jitCode, jitCodeWithArityCheck, bytecodeIndex);
     99        if (result == CompilationSuccessful)
    92100            codeBlock->alternative()->unlinkIncomingCalls();
    93101        else {
    94102            ASSERT(oldJITCode == jitCode);
    95103            ASSERT_UNUSED(oldJITCodeWithArityCheck, oldJITCodeWithArityCheck == jitCodeWithArityCheck);
    96             return false;
     104            return result;
    97105        }
    98106    } else {
     
    103111        else {
    104112            ASSERT_UNUSED(oldJITCodeWithArityCheck, oldJITCodeWithArityCheck == jitCodeWithArityCheck);
    105             return false;
     113            return CompilationFailed;
    106114        }
    107115    }
    108116
    109     codeBlock->setJITCode(jitCode, jitCodeWithArityCheck);
    110    
    111     return true;
     117    return CompilationSuccessful;
     118}
     119
     120template<typename CodeBlockType>
     121inline CompilationResult jitCompileIfAppropriate(
     122    ExecState* exec, CodeBlockType* codeBlock, RefPtr<JITCode>& jitCode,
     123    JITCode::JITType jitType, unsigned bytecodeIndex, JITCompilationEffort effort)
     124{
     125    CompilationResult result = jitCompileIfAppropriateImpl(
     126        exec, codeBlock, jitCode, jitType, bytecodeIndex, effort);
     127    if (result == CompilationSuccessful) {
     128        codeBlock->setJITCode(jitCode, MacroAssemblerCodePtr());
     129        codeBlock->vm()->heap.reportExtraMemoryCost(jitCode->size());
     130    }
     131    return result;
     132}   
     133
     134inline CompilationResult jitCompileFunctionIfAppropriate(
     135    ExecState* exec, FunctionCodeBlock* codeBlock, RefPtr<JITCode>& jitCode,
     136    MacroAssemblerCodePtr& jitCodeWithArityCheck, JITCode::JITType jitType,
     137    unsigned bytecodeIndex, JITCompilationEffort effort)
     138{
     139    CompilationResult result = jitCompileFunctionIfAppropriateImpl(
     140        exec, codeBlock, jitCode, jitCodeWithArityCheck, jitType, bytecodeIndex, effort);
     141    if (result == CompilationSuccessful) {
     142        codeBlock->setJITCode(jitCode, jitCodeWithArityCheck);
     143        codeBlock->vm()->heap.reportExtraMemoryCost(jitCode->size());
     144    }
     145    return result;
    112146}
    113147
Note: See TracChangeset for help on using the changeset viewer.