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/dfg/DFGDriver.cpp

    r153161 r153165  
    3232#if ENABLE(DFG_JIT)
    3333
     34#include "CodeBlock.h"
    3435#include "DFGJITCode.h"
    3536#include "DFGPlan.h"
     
    3940#include "Operations.h"
    4041#include "Options.h"
     42#include "SamplingTool.h"
    4143
    4244namespace JSC { namespace DFG {
     
    4951}
    5052
    51 static bool compile(CompileMode compileMode, ExecState* exec, CodeBlock* codeBlock, RefPtr<JSC::JITCode>& jitCode, MacroAssemblerCodePtr* jitCodeWithArityCheck, unsigned osrEntryBytecodeIndex)
     53static CompilationResult compile(CompileMode compileMode, ExecState* exec, CodeBlock* codeBlock, RefPtr<JSC::JITCode>& jitCode, MacroAssemblerCodePtr* jitCodeWithArityCheck, unsigned osrEntryBytecodeIndex)
    5254{
    5355    SamplingRegion samplingRegion("DFG Compilation (Driver)");
     
    6264
    6365    if (!Options::useDFGJIT())
    64         return false;
     66        return CompilationFailed;
    6567
    6668    if (!Options::bytecodeRangeToDFGCompile().isInRange(codeBlock->instructionCount()))
    67         return false;
     69        return CompilationFailed;
    6870
    6971    if (logCompilationChanges())
     
    9092    else
    9193        numVarsWithValues = 0;
    92     Plan plan(compileMode, codeBlock, osrEntryBytecodeIndex, numVarsWithValues);
    93     for (size_t i = 0; i < plan.mustHandleValues.size(); ++i) {
    94         int operand = plan.mustHandleValues.operandForIndex(i);
     94    RefPtr<Plan> plan = adoptRef(
     95        new Plan(compileMode, codeBlock, osrEntryBytecodeIndex, numVarsWithValues));
     96    for (size_t i = 0; i < plan->mustHandleValues.size(); ++i) {
     97        int operand = plan->mustHandleValues.operandForIndex(i);
    9598        if (operandIsArgument(operand)
    9699            && !operandToArgument(operand)
     
    101104            // but it has to be an actual value that can be grokked by subsequent DFG passes,
    102105            // so we sanitize it here by turning it into Undefined.
    103             plan.mustHandleValues[i] = jsUndefined();
     106            plan->mustHandleValues[i] = jsUndefined();
    104107        } else
    105             plan.mustHandleValues[i] = exec->uncheckedR(operand).jsValue();
     108            plan->mustHandleValues[i] = exec->uncheckedR(operand).jsValue();
    106109    }
    107110   
    108     plan.compileInThread();
    109     if (plan.finalize(jitCode, jitCodeWithArityCheck) != CompilationSuccessful)
    110         return false;
    111     return true;
     111    plan->compileInThread();
     112    return plan->finalize(jitCode, jitCodeWithArityCheck);
    112113}
    113114
    114 bool tryCompile(ExecState* exec, CodeBlock* codeBlock, RefPtr<JSC::JITCode>& jitCode, unsigned bytecodeIndex)
     115CompilationResult tryCompile(ExecState* exec, CodeBlock* codeBlock, RefPtr<JSC::JITCode>& jitCode, unsigned bytecodeIndex)
    115116{
    116117    return compile(CompileOther, exec, codeBlock, jitCode, 0, bytecodeIndex);
    117118}
    118119
    119 bool tryCompileFunction(ExecState* exec, CodeBlock* codeBlock, RefPtr<JSC::JITCode>& jitCode, MacroAssemblerCodePtr& jitCodeWithArityCheck, unsigned bytecodeIndex)
     120CompilationResult tryCompileFunction(ExecState* exec, CodeBlock* codeBlock, RefPtr<JSC::JITCode>& jitCode, MacroAssemblerCodePtr& jitCodeWithArityCheck, unsigned bytecodeIndex)
    120121{
    121122    return compile(CompileFunction, exec, codeBlock, jitCode, &jitCodeWithArityCheck, bytecodeIndex);
     123}
     124
     125CompilationResult tryFinalizePlan(PassRefPtr<Plan> plan, RefPtr<JSC::JITCode>& jitCode, MacroAssemblerCodePtr* jitCodeWithArityCheck)
     126{
     127    return plan->finalize(jitCode, jitCodeWithArityCheck);
    122128}
    123129
Note: See TracChangeset for help on using the changeset viewer.