Changeset 154814 in webkit


Ignore:
Timestamp:
Aug 29, 2013 9:41:07 AM (11 years ago)
Author:
commit-queue@webkit.org
Message:

Unreviewed, rolling out r154804.
http://trac.webkit.org/changeset/154804
https://bugs.webkit.org/show_bug.cgi?id=120477

Broke Windows build (assumes LLInt features not enabled on
this build) (Requested by bfulgham on #webkit).

  • CMakeLists.txt:
  • GNUmakefile.list.am:
  • JavaScriptCore.vcxproj/JavaScriptCore.vcxproj:
  • JavaScriptCore.xcodeproj/project.pbxproj:
  • Target.pri:
  • bytecode/CodeBlock.cpp:

(JSC::CodeBlock::linkIncomingCall):
(JSC::CodeBlock::unlinkIncomingCalls):
(JSC::CodeBlock::reoptimize):
(JSC::ProgramCodeBlock::replacement):
(JSC::EvalCodeBlock::replacement):
(JSC::FunctionCodeBlock::replacement):
(JSC::ProgramCodeBlock::compileOptimized):
(JSC::ProgramCodeBlock::replaceWithDeferredOptimizedCode):
(JSC::EvalCodeBlock::compileOptimized):
(JSC::EvalCodeBlock::replaceWithDeferredOptimizedCode):
(JSC::FunctionCodeBlock::compileOptimized):
(JSC::FunctionCodeBlock::replaceWithDeferredOptimizedCode):
(JSC::ProgramCodeBlock::jitCompileImpl):
(JSC::EvalCodeBlock::jitCompileImpl):
(JSC::FunctionCodeBlock::jitCompileImpl):

  • bytecode/CodeBlock.h:

(JSC::CodeBlock::jitType):
(JSC::CodeBlock::jitCompile):

  • bytecode/DeferredCompilationCallback.cpp: Removed.
  • bytecode/DeferredCompilationCallback.h: Removed.
  • dfg/DFGDriver.cpp:

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

  • dfg/DFGDriver.h:

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

  • dfg/DFGFailedFinalizer.cpp:

(JSC::DFG::FailedFinalizer::finalize):
(JSC::DFG::FailedFinalizer::finalizeFunction):

  • dfg/DFGFailedFinalizer.h:
  • dfg/DFGFinalizer.h:
  • dfg/DFGJITFinalizer.cpp:

(JSC::DFG::JITFinalizer::finalize):
(JSC::DFG::JITFinalizer::finalizeFunction):

  • dfg/DFGJITFinalizer.h:
  • dfg/DFGOSRExitPreparation.cpp:

(JSC::DFG::prepareCodeOriginForOSRExit):

  • dfg/DFGOperations.cpp:
  • dfg/DFGPlan.cpp:

(JSC::DFG::Plan::Plan):
(JSC::DFG::Plan::compileInThreadImpl):
(JSC::DFG::Plan::finalize):

  • dfg/DFGPlan.h:
  • dfg/DFGSpeculativeJIT32_64.cpp:

(JSC::DFG::SpeculativeJIT::compile):

  • dfg/DFGWorklist.cpp:

(JSC::DFG::Worklist::completeAllReadyPlansForVM):
(JSC::DFG::Worklist::runThread):

  • ftl/FTLJITFinalizer.cpp:

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

  • ftl/FTLJITFinalizer.h:
  • heap/Heap.h:
  • interpreter/Interpreter.cpp:

(JSC::Interpreter::execute):
(JSC::Interpreter::executeCall):
(JSC::Interpreter::executeConstruct):
(JSC::Interpreter::prepareForRepeatCall):

  • jit/JITDriver.h: Added.

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

  • jit/JITStubs.cpp:

(JSC::DEFINE_STUB_FUNCTION):
(JSC::jitCompileFor):
(JSC::lazyLinkFor):

  • jit/JITToDFGDeferredCompilationCallback.cpp: Removed.
  • jit/JITToDFGDeferredCompilationCallback.h: Removed.
  • llint/LLIntEntrypoints.cpp:

(JSC::LLInt::getFunctionEntrypoint):
(JSC::LLInt::getEvalEntrypoint):
(JSC::LLInt::getProgramEntrypoint):

  • llint/LLIntEntrypoints.h:

(JSC::LLInt::getEntrypoint):

  • llint/LLIntSlowPaths.cpp:

(JSC::LLInt::jitCompileAndSetHeuristics):
(JSC::LLInt::setUpCall):

  • runtime/ArrayPrototype.cpp:

(JSC::isNumericCompareFunction):

  • runtime/CommonSlowPaths.cpp:
  • runtime/CompilationResult.cpp:

(WTF::printInternal):

  • runtime/CompilationResult.h:
  • runtime/Executable.cpp:

(JSC::EvalExecutable::compileOptimized):
(JSC::EvalExecutable::jitCompile):
(JSC::EvalExecutable::compileInternal):
(JSC::EvalExecutable::replaceWithDeferredOptimizedCode):
(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::produceCodeBlockFor):
(JSC::FunctionExecutable::compileForCallInternal):
(JSC::FunctionExecutable::replaceWithDeferredOptimizedCodeForCall):
(JSC::FunctionExecutable::compileForConstructInternal):
(JSC::FunctionExecutable::replaceWithDeferredOptimizedCodeForConstruct):

  • runtime/Executable.h:

(JSC::ExecutableBase::offsetOfJITCodeWithArityCheckFor):
(JSC::ExecutableBase::offsetOfNumParametersFor):
(JSC::ExecutableBase::catchRoutineFor):
(JSC::EvalExecutable::compile):
(JSC::ProgramExecutable::compile):
(JSC::FunctionExecutable::compileForCall):
(JSC::FunctionExecutable::compileForConstruct):
(JSC::FunctionExecutable::compileFor):
(JSC::FunctionExecutable::compileOptimizedFor):
(JSC::FunctionExecutable::replaceWithDeferredOptimizedCodeFor):
(JSC::FunctionExecutable::jitCompileFor):

  • runtime/ExecutionHarness.h: Added.

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

Location:
trunk/Source/JavaScriptCore
Files:
2 added
4 deleted
35 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/CMakeLists.txt

    r154804 r154814  
    5454    bytecode/CodeType.cpp
    5555    bytecode/DFGExitProfile.cpp
    56     bytecode/DeferredCompilationCallback.cpp
    5756    bytecode/ExecutionCounter.cpp
    5857    bytecode/ExitKind.cpp
     
    245244    jit/JITStubs.cpp
    246245    jit/JITThunks.cpp
    247     jit/JITToDFGDeferredCompilationCallback.cpp
    248246    jit/JumpReplacementWatchpoint.cpp
    249247    jit/ThunkGenerators.cpp
  • trunk/Source/JavaScriptCore/ChangeLog

    r154804 r154814  
     12013-08-29  Commit Queue  <commit-queue@webkit.org>
     2
     3        Unreviewed, rolling out r154804.
     4        http://trac.webkit.org/changeset/154804
     5        https://bugs.webkit.org/show_bug.cgi?id=120477
     6
     7        Broke Windows build (assumes LLInt features not enabled on
     8        this build) (Requested by bfulgham on #webkit).
     9
     10        * CMakeLists.txt:
     11        * GNUmakefile.list.am:
     12        * JavaScriptCore.vcxproj/JavaScriptCore.vcxproj:
     13        * JavaScriptCore.xcodeproj/project.pbxproj:
     14        * Target.pri:
     15        * bytecode/CodeBlock.cpp:
     16        (JSC::CodeBlock::linkIncomingCall):
     17        (JSC::CodeBlock::unlinkIncomingCalls):
     18        (JSC::CodeBlock::reoptimize):
     19        (JSC::ProgramCodeBlock::replacement):
     20        (JSC::EvalCodeBlock::replacement):
     21        (JSC::FunctionCodeBlock::replacement):
     22        (JSC::ProgramCodeBlock::compileOptimized):
     23        (JSC::ProgramCodeBlock::replaceWithDeferredOptimizedCode):
     24        (JSC::EvalCodeBlock::compileOptimized):
     25        (JSC::EvalCodeBlock::replaceWithDeferredOptimizedCode):
     26        (JSC::FunctionCodeBlock::compileOptimized):
     27        (JSC::FunctionCodeBlock::replaceWithDeferredOptimizedCode):
     28        (JSC::ProgramCodeBlock::jitCompileImpl):
     29        (JSC::EvalCodeBlock::jitCompileImpl):
     30        (JSC::FunctionCodeBlock::jitCompileImpl):
     31        * bytecode/CodeBlock.h:
     32        (JSC::CodeBlock::jitType):
     33        (JSC::CodeBlock::jitCompile):
     34        * bytecode/DeferredCompilationCallback.cpp: Removed.
     35        * bytecode/DeferredCompilationCallback.h: Removed.
     36        * dfg/DFGDriver.cpp:
     37        (JSC::DFG::compile):
     38        (JSC::DFG::tryCompile):
     39        (JSC::DFG::tryCompileFunction):
     40        (JSC::DFG::tryFinalizePlan):
     41        * dfg/DFGDriver.h:
     42        (JSC::DFG::tryCompile):
     43        (JSC::DFG::tryCompileFunction):
     44        (JSC::DFG::tryFinalizePlan):
     45        * dfg/DFGFailedFinalizer.cpp:
     46        (JSC::DFG::FailedFinalizer::finalize):
     47        (JSC::DFG::FailedFinalizer::finalizeFunction):
     48        * dfg/DFGFailedFinalizer.h:
     49        * dfg/DFGFinalizer.h:
     50        * dfg/DFGJITFinalizer.cpp:
     51        (JSC::DFG::JITFinalizer::finalize):
     52        (JSC::DFG::JITFinalizer::finalizeFunction):
     53        * dfg/DFGJITFinalizer.h:
     54        * dfg/DFGOSRExitPreparation.cpp:
     55        (JSC::DFG::prepareCodeOriginForOSRExit):
     56        * dfg/DFGOperations.cpp:
     57        * dfg/DFGPlan.cpp:
     58        (JSC::DFG::Plan::Plan):
     59        (JSC::DFG::Plan::compileInThreadImpl):
     60        (JSC::DFG::Plan::finalize):
     61        * dfg/DFGPlan.h:
     62        * dfg/DFGSpeculativeJIT32_64.cpp:
     63        (JSC::DFG::SpeculativeJIT::compile):
     64        * dfg/DFGWorklist.cpp:
     65        (JSC::DFG::Worklist::completeAllReadyPlansForVM):
     66        (JSC::DFG::Worklist::runThread):
     67        * ftl/FTLJITFinalizer.cpp:
     68        (JSC::FTL::JITFinalizer::finalize):
     69        (JSC::FTL::JITFinalizer::finalizeFunction):
     70        * ftl/FTLJITFinalizer.h:
     71        * heap/Heap.h:
     72        * interpreter/Interpreter.cpp:
     73        (JSC::Interpreter::execute):
     74        (JSC::Interpreter::executeCall):
     75        (JSC::Interpreter::executeConstruct):
     76        (JSC::Interpreter::prepareForRepeatCall):
     77        * jit/JITDriver.h: Added.
     78        (JSC::jitCompileIfAppropriateImpl):
     79        (JSC::jitCompileFunctionIfAppropriateImpl):
     80        (JSC::jitCompileIfAppropriate):
     81        (JSC::jitCompileFunctionIfAppropriate):
     82        * jit/JITStubs.cpp:
     83        (JSC::DEFINE_STUB_FUNCTION):
     84        (JSC::jitCompileFor):
     85        (JSC::lazyLinkFor):
     86        * jit/JITToDFGDeferredCompilationCallback.cpp: Removed.
     87        * jit/JITToDFGDeferredCompilationCallback.h: Removed.
     88        * llint/LLIntEntrypoints.cpp:
     89        (JSC::LLInt::getFunctionEntrypoint):
     90        (JSC::LLInt::getEvalEntrypoint):
     91        (JSC::LLInt::getProgramEntrypoint):
     92        * llint/LLIntEntrypoints.h:
     93        (JSC::LLInt::getEntrypoint):
     94        * llint/LLIntSlowPaths.cpp:
     95        (JSC::LLInt::jitCompileAndSetHeuristics):
     96        (JSC::LLInt::setUpCall):
     97        * runtime/ArrayPrototype.cpp:
     98        (JSC::isNumericCompareFunction):
     99        * runtime/CommonSlowPaths.cpp:
     100        * runtime/CompilationResult.cpp:
     101        (WTF::printInternal):
     102        * runtime/CompilationResult.h:
     103        * runtime/Executable.cpp:
     104        (JSC::EvalExecutable::compileOptimized):
     105        (JSC::EvalExecutable::jitCompile):
     106        (JSC::EvalExecutable::compileInternal):
     107        (JSC::EvalExecutable::replaceWithDeferredOptimizedCode):
     108        (JSC::ProgramExecutable::compileOptimized):
     109        (JSC::ProgramExecutable::jitCompile):
     110        (JSC::ProgramExecutable::compileInternal):
     111        (JSC::ProgramExecutable::replaceWithDeferredOptimizedCode):
     112        (JSC::FunctionExecutable::compileOptimizedForCall):
     113        (JSC::FunctionExecutable::compileOptimizedForConstruct):
     114        (JSC::FunctionExecutable::jitCompileForCall):
     115        (JSC::FunctionExecutable::jitCompileForConstruct):
     116        (JSC::FunctionExecutable::produceCodeBlockFor):
     117        (JSC::FunctionExecutable::compileForCallInternal):
     118        (JSC::FunctionExecutable::replaceWithDeferredOptimizedCodeForCall):
     119        (JSC::FunctionExecutable::compileForConstructInternal):
     120        (JSC::FunctionExecutable::replaceWithDeferredOptimizedCodeForConstruct):
     121        * runtime/Executable.h:
     122        (JSC::ExecutableBase::offsetOfJITCodeWithArityCheckFor):
     123        (JSC::ExecutableBase::offsetOfNumParametersFor):
     124        (JSC::ExecutableBase::catchRoutineFor):
     125        (JSC::EvalExecutable::compile):
     126        (JSC::ProgramExecutable::compile):
     127        (JSC::FunctionExecutable::compileForCall):
     128        (JSC::FunctionExecutable::compileForConstruct):
     129        (JSC::FunctionExecutable::compileFor):
     130        (JSC::FunctionExecutable::compileOptimizedFor):
     131        (JSC::FunctionExecutable::replaceWithDeferredOptimizedCodeFor):
     132        (JSC::FunctionExecutable::jitCompileFor):
     133        * runtime/ExecutionHarness.h: Added.
     134        (JSC::prepareForExecutionImpl):
     135        (JSC::prepareFunctionForExecutionImpl):
     136        (JSC::installOptimizedCode):
     137        (JSC::prepareForExecution):
     138        (JSC::prepareFunctionForExecution):
     139        (JSC::replaceWithDeferredOptimizedCode):
     140
    11412013-08-28  Filip Pizlo  <fpizlo@apple.com>
    2142
  • trunk/Source/JavaScriptCore/GNUmakefile.list.am

    r154804 r154814  
    114114        Source/JavaScriptCore/bytecode/CodeOrigin.cpp \
    115115        Source/JavaScriptCore/bytecode/CodeOrigin.h \
     116        Source/JavaScriptCore/bytecode/DataFormat.h \
    116117        Source/JavaScriptCore/bytecode/DFGExitProfile.cpp \
    117118        Source/JavaScriptCore/bytecode/DFGExitProfile.h \
    118         Source/JavaScriptCore/bytecode/DataFormat.h \
    119         Source/JavaScriptCore/bytecode/DeferredCompilationCallback.cpp \
    120         Source/JavaScriptCore/bytecode/DeferredCompilationCallback.h \
    121119        Source/JavaScriptCore/bytecode/EvalCodeCache.h \
    122120        Source/JavaScriptCore/bytecode/ExecutionCounter.cpp \
     
    607605        Source/JavaScriptCore/jit/JITDisassembler.cpp \
    608606        Source/JavaScriptCore/jit/JITDisassembler.h \
     607        Source/JavaScriptCore/jit/JITDriver.h \
    609608        Source/JavaScriptCore/jit/JIT.cpp \
    610609        Source/JavaScriptCore/jit/JIT.h \
     
    630629        Source/JavaScriptCore/jit/JITThunks.cpp \
    631630        Source/JavaScriptCore/jit/JITThunks.h \
    632         Source/JavaScriptCore/jit/JITToDFGDeferredCompilationCallback.cpp \
    633         Source/JavaScriptCore/jit/JITToDFGDeferredCompilationCallback.h \
    634631        Source/JavaScriptCore/jit/JITWriteBarrier.h \
    635632        Source/JavaScriptCore/jit/JSInterfaceJIT.h \
     
    787784        Source/JavaScriptCore/runtime/Executable.cpp \
    788785        Source/JavaScriptCore/runtime/Executable.h \
     786        Source/JavaScriptCore/runtime/ExecutionHarness.h \
    789787        Source/JavaScriptCore/runtime/Float32Array.h \
    790788        Source/JavaScriptCore/runtime/Float64Array.h \
  • trunk/Source/JavaScriptCore/JavaScriptCore.vcxproj/JavaScriptCore.vcxproj

    r154804 r154814  
    303303    <ClCompile Include="..\bytecode\CodeOrigin.cpp" />
    304304    <ClCompile Include="..\bytecode\CodeType.cpp" />
    305     <ClCompile Include="..\bytecode\DeferredCompilationCallback.cpp" />
    306305    <ClCompile Include="..\bytecode\ExecutionCounter.cpp" />
    307306    <ClCompile Include="..\bytecode\ExitKind.cpp" />
     
    379378    <ClCompile Include="..\jit\JITStubs.cpp" />
    380379    <ClCompile Include="..\jit\JITThunks.cpp" />
    381     <ClCompile Include="..\jit\JITToDFGDeferredCompilationCallback.cpp" />
    382380    <ClCompile Include="..\jit\JumpReplacementWatchpoint.cpp" />
    383381    <ClCompile Include="..\jit\ThunkGenerators.cpp" />
     
    626624    <ClInclude Include="..\bytecode\Comment.h" />
    627625    <ClInclude Include="..\bytecode\DataFormat.h" />
    628     <ClInclude Include="..\bytecode\DeferredCompilationCallback.h" />
    629626    <ClInclude Include="..\bytecode\EvalCodeCache.h" />
    630627    <ClInclude Include="..\bytecode\ExecutionCounter.h" />
     
    744741    <ClInclude Include="..\jit\JITCompilationEffort.h" />
    745742    <ClInclude Include="..\jit\JITDisassembler.h" />
     743    <ClInclude Include="..\jit\JITDriver.h" />
    746744    <ClInclude Include="..\jit\JITExceptions.h" />
    747745    <ClInclude Include="..\jit\JITInlines.h" />
     
    753751    <ClInclude Include="..\jit\JITStubsX86_64.h" />
    754752    <ClInclude Include="..\jit\JITThunks.h" />
    755     <ClInclude Include="..\jit\JITToDFGDeferredCompilationCallback.h" />
    756753    <ClInclude Include="..\jit\JITWriteBarrier.h" />
    757754    <ClInclude Include="..\jit\JSInterfaceJIT.h" />
     
    841838    <ClInclude Include="..\runtime\ExceptionHelpers.h" />
    842839    <ClInclude Include="..\runtime\Executable.h" />
     840    <ClInclude Include="..\runtime\ExecutionHarness.h" />
    843841    <ClInclude Include="..\runtime\Float32Array.h" />
    844842    <ClInclude Include="..\runtime\Float64Array.h" />
  • trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj

    r154804 r154814  
    8787                0F1E3A471534CBB9000F9456 /* DFGDoubleFormatState.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F1E3A441534CBAD000F9456 /* DFGDoubleFormatState.h */; settings = {ATTRIBUTES = (Private, ); }; };
    8888                0F1E3A67153A21E2000F9456 /* DFGSilentRegisterSavePlan.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F1E3A65153A21DF000F9456 /* DFGSilentRegisterSavePlan.h */; settings = {ATTRIBUTES = (Private, ); }; };
     89                0F21C26814BE5F6800ADC64B /* JITDriver.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F21C26614BE5F5E00ADC64B /* JITDriver.h */; settings = {ATTRIBUTES = (Private, ); }; };
     90                0F21C27C14BE727600ADC64B /* ExecutionHarness.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F21C27A14BE727300ADC64B /* ExecutionHarness.h */; settings = {ATTRIBUTES = (Private, ); }; };
    8991                0F21C27D14BE727A00ADC64B /* CodeSpecializationKind.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F21C27914BE727300ADC64B /* CodeSpecializationKind.h */; settings = {ATTRIBUTES = (Private, ); }; };
    9092                0F21C27F14BEAA8200ADC64B /* BytecodeConventions.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F21C27E14BEAA8000ADC64B /* BytecodeConventions.h */; settings = {ATTRIBUTES = (Private, ); }; };
     
    346348                0FC097A1146B28CA00CF2442 /* DFGThunks.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0FC0979F146B28C700CF2442 /* DFGThunks.cpp */; };
    347349                0FC097A2146B28CC00CF2442 /* DFGThunks.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FC097A0146B28C700CF2442 /* DFGThunks.h */; settings = {ATTRIBUTES = (Private, ); }; };
    348                 0FC712DE17CD8779008CC93C /* DeferredCompilationCallback.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0FC712DC17CD8778008CC93C /* DeferredCompilationCallback.cpp */; };
    349                 0FC712DF17CD877C008CC93C /* DeferredCompilationCallback.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FC712DD17CD8778008CC93C /* DeferredCompilationCallback.h */; settings = {ATTRIBUTES = (Private, ); }; };
    350                 0FC712E217CD8791008CC93C /* JITToDFGDeferredCompilationCallback.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0FC712E017CD878F008CC93C /* JITToDFGDeferredCompilationCallback.cpp */; };
    351                 0FC712E317CD8793008CC93C /* JITToDFGDeferredCompilationCallback.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FC712E117CD878F008CC93C /* JITToDFGDeferredCompilationCallback.h */; settings = {ATTRIBUTES = (Private, ); }; };
    352350                0FC8150A14043BF500CFA603 /* WriteBarrierSupport.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FC8150914043BD200CFA603 /* WriteBarrierSupport.h */; settings = {ATTRIBUTES = (Private, ); }; };
    353351                0FC8150B14043C0E00CFA603 /* WriteBarrierSupport.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0FC8150814043BCA00CFA603 /* WriteBarrierSupport.cpp */; };
     
    12461244                0F1E3A501537C2CB000F9456 /* DFGSlowPathGenerator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DFGSlowPathGenerator.h; path = dfg/DFGSlowPathGenerator.h; sourceTree = "<group>"; };
    12471245                0F1E3A65153A21DF000F9456 /* DFGSilentRegisterSavePlan.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DFGSilentRegisterSavePlan.h; path = dfg/DFGSilentRegisterSavePlan.h; sourceTree = "<group>"; };
     1246                0F21C26614BE5F5E00ADC64B /* JITDriver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JITDriver.h; sourceTree = "<group>"; };
    12481247                0F21C27914BE727300ADC64B /* CodeSpecializationKind.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CodeSpecializationKind.h; sourceTree = "<group>"; };
     1248                0F21C27A14BE727300ADC64B /* ExecutionHarness.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ExecutionHarness.h; sourceTree = "<group>"; };
    12491249                0F21C27E14BEAA8000ADC64B /* BytecodeConventions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BytecodeConventions.h; sourceTree = "<group>"; };
    12501250                0F235BBB17178E1C00690C7F /* FTLCArgumentGetter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = FTLCArgumentGetter.cpp; path = ftl/FTLCArgumentGetter.cpp; sourceTree = "<group>"; };
     
    15151515                0FC0979F146B28C700CF2442 /* DFGThunks.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = DFGThunks.cpp; path = dfg/DFGThunks.cpp; sourceTree = "<group>"; };
    15161516                0FC097A0146B28C700CF2442 /* DFGThunks.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DFGThunks.h; path = dfg/DFGThunks.h; sourceTree = "<group>"; };
    1517                 0FC712DC17CD8778008CC93C /* DeferredCompilationCallback.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = DeferredCompilationCallback.cpp; sourceTree = "<group>"; };
    1518                 0FC712DD17CD8778008CC93C /* DeferredCompilationCallback.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DeferredCompilationCallback.h; sourceTree = "<group>"; };
    1519                 0FC712E017CD878F008CC93C /* JITToDFGDeferredCompilationCallback.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = JITToDFGDeferredCompilationCallback.cpp; sourceTree = "<group>"; };
    1520                 0FC712E117CD878F008CC93C /* JITToDFGDeferredCompilationCallback.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = JITToDFGDeferredCompilationCallback.h; sourceTree = "<group>"; };
    15211517                0FC8150814043BCA00CFA603 /* WriteBarrierSupport.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WriteBarrierSupport.cpp; sourceTree = "<group>"; };
    15221518                0FC8150914043BD200CFA603 /* WriteBarrierSupport.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WriteBarrierSupport.h; sourceTree = "<group>"; };
     
    26412637                                0FAF7EFA165BA919000C8455 /* JITDisassembler.cpp */,
    26422638                                0FAF7EFB165BA919000C8455 /* JITDisassembler.h */,
     2639                                0F21C26614BE5F5E00ADC64B /* JITDriver.h */,
    26432640                                0F46807F14BA572700BFE272 /* JITExceptions.cpp */,
    26442641                                0F46808014BA572700BFE272 /* JITExceptions.h */,
     
    26622659                                0F5EF91B16878F78003E5C25 /* JITThunks.cpp */,
    26632660                                0F5EF91C16878F78003E5C25 /* JITThunks.h */,
    2664                                 0FC712E017CD878F008CC93C /* JITToDFGDeferredCompilationCallback.cpp */,
    2665                                 0FC712E117CD878F008CC93C /* JITToDFGDeferredCompilationCallback.h */,
    26662661                                A76F54A213B28AAB00EF2BCE /* JITWriteBarrier.h */,
    26672662                                A76C51741182748D00715B05 /* JSInterfaceJIT.h */,
     
    30463041                                86CA032D1038E8440028A609 /* Executable.cpp */,
    30473042                                86CAFEE21035DDE60028A609 /* Executable.h */,
     3043                                0F21C27A14BE727300ADC64B /* ExecutionHarness.h */,
    30483044                                A7A8AF2917ADB5F3005AB174 /* Float32Array.h */,
    30493045                                A7A8AF2A17ADB5F3005AB174 /* Float64Array.h */,
     
    36533649                                0F0B83A514BCF50400885B4F /* CodeType.h */,
    36543650                                0F426A4A1460CD6B00131F8F /* DataFormat.h */,
    3655                                 0FC712DC17CD8778008CC93C /* DeferredCompilationCallback.cpp */,
    3656                                 0FC712DD17CD8778008CC93C /* DeferredCompilationCallback.h */,
    36573651                                0FBC0AE41496C7C100D4FBDD /* DFGExitProfile.cpp */,
    36583652                                0FBC0AE51496C7C100D4FBDD /* DFGExitProfile.h */,
     
    38033797                                0F426A4B1460CD6E00131F8F /* DataFormat.h in Headers */,
    38043798                                0F2B66DF17B6B5AB00A7AE3F /* DataView.h in Headers */,
    3805                                 0FC712DF17CD877C008CC93C /* DeferredCompilationCallback.h in Headers */,
    38063799                                BCD2034A0E17135E002C7E82 /* DateConstructor.h in Headers */,
    38073800                                41359CF30FDD89AD00206180 /* DateConversion.h in Headers */,
     
    39453938                                A766B44F0EE8DCD1009518CA /* ExecutableAllocator.h in Headers */,
    39463939                                0F56A1D315000F35002992B1 /* ExecutionCounter.h in Headers */,
     3940                                0F21C27C14BE727600ADC64B /* ExecutionHarness.h in Headers */,
    39473941                                0FB105861675481200F8AB6E /* ExitKind.h in Headers */,
    39483942                                0F0B83AB14BCF5BB00885B4F /* ExpressionRangeInfo.h in Headers */,
     
    40334027                                0F0776BF14FF002B00102332 /* JITCompilationEffort.h in Headers */,
    40344028                                0FAF7EFE165BA91F000C8455 /* JITDisassembler.h in Headers */,
     4029                                0F21C26814BE5F6800ADC64B /* JITDriver.h in Headers */,
    40354030                                0F46808214BA572D00BFE272 /* JITExceptions.h in Headers */,
    40364031                                86CC85A10EE79A4700288682 /* JITInlines.h in Headers */,
     
    41024097                                BC18C4250E16F5CD00B34460 /* JSObjectRef.h in Headers */,
    41034098                                A7280A2811557E3000D56957 /* JSObjectRefPrivate.h in Headers */,
    4104                                 0FC712E317CD8793008CC93C /* JITToDFGDeferredCompilationCallback.h in Headers */,
    41054099                                A7F9935F0FD7325100A0B2D0 /* JSONObject.h in Headers */,
    41064100                                BC87CDB910712AD4000614CF /* JSONObject.lut.h in Headers */,
     
    50165010                                148F21BC107EC54D0042EC2C /* Parser.cpp in Sources */,
    50175011                                93052C340FB792190048FDC3 /* ParserArena.cpp in Sources */,
    5018                                 0FC712E217CD8791008CC93C /* JITToDFGDeferredCompilationCallback.cpp in Sources */,
    50195012                                0F9FC8C314E1B5FE00D52AE0 /* PolymorphicPutByIdList.cpp in Sources */,
    50205013                                0F98206016BFE38100240D02 /* PreciseJumpTargets.cpp in Sources */,
     
    50955088                                14F7256514EE265E00B1652B /* WeakHandleOwner.cpp in Sources */,
    50965089                                14E84FA014EE1ACC00D6D5D4 /* WeakSet.cpp in Sources */,
    5097                                 0FC712DE17CD8779008CC93C /* DeferredCompilationCallback.cpp in Sources */,
    50985090                                0F6E5C191724AF3D005C574F /* WebKitLLVMLibraryAnchor.cpp in Sources */,
    50995091                                0FC8150B14043C0E00CFA603 /* WriteBarrierSupport.cpp in Sources */,
  • trunk/Source/JavaScriptCore/Target.pri

    r154804 r154814  
    6262    bytecode/CodeType.cpp \
    6363    bytecode/DFGExitProfile.cpp \
    64     bytecode/DeferredCompilationCallback.cpp \
    6564    bytecode/ExecutionCounter.cpp \
    6665    bytecode/ExitKind.cpp \
     
    223222    jit/JITStubs.cpp \
    224223    jit/JITThunks.cpp \
    225     jit/JITToDFGDeferredCompilationCallback.cpp \
    226224    jit/JumpReplacementWatchpoint.cpp \
    227225    jit/ThunkGenerators.cpp \
  • trunk/Source/JavaScriptCore/bytecode/CodeBlock.cpp

    r154804 r154814  
    3535#include "DFGCapabilities.h"
    3636#include "DFGCommon.h"
    37 #include "DFGDriver.h"
    3837#include "DFGNode.h"
    3938#include "DFGRepatch.h"
     
    4746#include "JSFunction.h"
    4847#include "JSNameScope.h"
    49 #include "LLIntEntrypoints.h"
    5048#include "LowLevelInterpreter.h"
    5149#include "Operations.h"
     
    25392537    m_incomingCalls.push(incoming);
    25402538}
    2541 #endif // ENABLE(JIT)
    25422539
    25432540void CodeBlock::unlinkIncomingCalls()
     
    25462543    while (m_incomingLLIntCalls.begin() != m_incomingLLIntCalls.end())
    25472544        m_incomingLLIntCalls.begin()->unlink();
    2548 #endif // ENABLE(LLINT)
    2549 #if ENABLE(JIT)
     2545#endif
    25502546    if (m_incomingCalls.isEmpty())
    25512547        return;
     
    25532549    while (m_incomingCalls.begin() != m_incomingCalls.end())
    25542550        m_incomingCalls.begin()->unlink(*m_vm, repatchBuffer);
     2551}
    25552552#endif // ENABLE(JIT)
    2556 }
    25572553
    25582554#if ENABLE(LLINT)
     
    26942690}
    26952691
    2696 CompilationResult CodeBlock::prepareForExecutionImpl(
    2697     ExecState* exec, JITCode::JITType jitType, JITCompilationEffort effort,
    2698     unsigned bytecodeIndex, PassRefPtr<DeferredCompilationCallback> callback)
    2699 {
    2700     VM& vm = exec->vm();
    2701    
    2702     if (jitType == JITCode::InterpreterThunk) {
    2703         switch (codeType()) {
    2704         case GlobalCode:
    2705             LLInt::setProgramEntrypoint(vm, static_cast<ProgramCodeBlock*>(this));
    2706             break;
    2707         case EvalCode:
    2708             LLInt::setEvalEntrypoint(vm, static_cast<EvalCodeBlock*>(this));
    2709             break;
    2710         case FunctionCode:
    2711             LLInt::setFunctionEntrypoint(vm, static_cast<FunctionCodeBlock*>(this));
    2712             break;
    2713         }
    2714         return CompilationSuccessful;
    2715     }
    2716    
    2717 #if ENABLE(JIT)
    2718     if (JITCode::isOptimizingJIT(jitType)) {
    2719         ASSERT(effort == JITCompilationCanFail);
    2720         bool hadCallback = !!callback;
    2721         CompilationResult result = DFG::tryCompile(exec, this, bytecodeIndex, callback);
    2722         ASSERT_UNUSED(hadCallback, result != CompilationDeferred || hadCallback);
    2723         return result;
    2724     }
    2725    
    2726     MacroAssemblerCodePtr jitCodeWithArityCheck;
    2727     RefPtr<JITCode> jitCode = JIT::compile(&vm, this, effort, &jitCodeWithArityCheck);
    2728     if (!jitCode)
    2729         return CompilationFailed;
    2730     setJITCode(jitCode, jitCodeWithArityCheck);
    2731     return CompilationSuccessful;
    2732 #else
    2733     UNUSED_PARAM(effort);
    2734     UNUSED_PARAM(bytecodeIndex);
    2735     UNUSED_PARAM(callback);
    2736     return CompilationFailed;
    2737 #endif // ENABLE(JIT)
    2738 }
    2739 
    2740 CompilationResult CodeBlock::prepareForExecution(
    2741     ExecState* exec, JITCode::JITType jitType,
    2742     JITCompilationEffort effort, unsigned bytecodeIndex)
    2743 {
    2744     CompilationResult result =
    2745         prepareForExecutionImpl(exec, jitType, effort, bytecodeIndex, 0);
    2746     ASSERT(result != CompilationDeferred);
    2747     return result;
    2748 }
    2749 
    2750 CompilationResult CodeBlock::prepareForExecutionAsynchronously(
    2751     ExecState* exec, JITCode::JITType jitType,
    2752     PassRefPtr<DeferredCompilationCallback> passedCallback,
    2753     JITCompilationEffort effort, unsigned bytecodeIndex)
    2754 {
    2755     RefPtr<DeferredCompilationCallback> callback = passedCallback;
    2756     CompilationResult result =
    2757         prepareForExecutionImpl(exec, jitType, effort, bytecodeIndex, callback);
    2758     if (result != CompilationDeferred)
    2759         callback->compilationDidComplete(this, result);
    2760     return result;
    2761 }
    2762 
    2763 void CodeBlock::install()
    2764 {
    2765     ownerExecutable()->installCode(this);
    2766 }
    2767 
    2768 PassRefPtr<CodeBlock> CodeBlock::newReplacement()
    2769 {
    2770     return ownerExecutable()->newReplacementCodeBlockFor(specializationKind());
    2771 }
    2772 
    27732692#if ENABLE(JIT)
    27742693void CodeBlock::reoptimize()
     
    27962715    return &static_cast<FunctionExecutable*>(ownerExecutable())->generatedBytecodeFor(m_isConstructor ? CodeForConstruct : CodeForCall);
    27972716}
     2717
     2718#if ENABLE(DFG_JIT)
     2719JSObject* ProgramCodeBlock::compileOptimized(ExecState* exec, JSScope* scope, CompilationResult& result, unsigned bytecodeIndex)
     2720{
     2721    if (JITCode::isHigherTier(replacement()->jitType(), jitType())) {
     2722        result = CompilationNotNeeded;
     2723        return 0;
     2724    }
     2725    JSObject* error = static_cast<ProgramExecutable*>(ownerExecutable())->compileOptimized(exec, scope, result, bytecodeIndex);
     2726    return error;
     2727}
     2728
     2729CompilationResult ProgramCodeBlock::replaceWithDeferredOptimizedCode(PassRefPtr<DFG::Plan> plan)
     2730{
     2731    return static_cast<ProgramExecutable*>(ownerExecutable())->replaceWithDeferredOptimizedCode(plan);
     2732}
     2733
     2734JSObject* EvalCodeBlock::compileOptimized(ExecState* exec, JSScope* scope, CompilationResult& result, unsigned bytecodeIndex)
     2735{
     2736    if (JITCode::isHigherTier(replacement()->jitType(), jitType())) {
     2737        result = CompilationNotNeeded;
     2738        return 0;
     2739    }
     2740    JSObject* error = static_cast<EvalExecutable*>(ownerExecutable())->compileOptimized(exec, scope, result, bytecodeIndex);
     2741    return error;
     2742}
     2743
     2744CompilationResult EvalCodeBlock::replaceWithDeferredOptimizedCode(PassRefPtr<DFG::Plan> plan)
     2745{
     2746    return static_cast<EvalExecutable*>(ownerExecutable())->replaceWithDeferredOptimizedCode(plan);
     2747}
     2748
     2749JSObject* FunctionCodeBlock::compileOptimized(ExecState* exec, JSScope* scope, CompilationResult& result, unsigned bytecodeIndex)
     2750{
     2751    if (JITCode::isHigherTier(replacement()->jitType(), jitType())) {
     2752        result = CompilationNotNeeded;
     2753        return 0;
     2754    }
     2755    JSObject* error = static_cast<FunctionExecutable*>(ownerExecutable())->compileOptimizedFor(exec, scope, result, bytecodeIndex, m_isConstructor ? CodeForConstruct : CodeForCall);
     2756    return error;
     2757}
     2758
     2759CompilationResult FunctionCodeBlock::replaceWithDeferredOptimizedCode(PassRefPtr<DFG::Plan> plan)
     2760{
     2761    return static_cast<FunctionExecutable*>(ownerExecutable())->replaceWithDeferredOptimizedCodeFor(plan, m_isConstructor ? CodeForConstruct : CodeForCall);
     2762}
     2763#endif // ENABLE(DFG_JIT)
    27982764
    27992765DFG::CapabilityLevel ProgramCodeBlock::capabilityLevelInternal()
     
    28382804{
    28392805    static_cast<FunctionExecutable*>(ownerExecutable())->jettisonOptimizedCodeFor(*vm(), m_isConstructor ? CodeForConstruct : CodeForCall);
     2806}
     2807
     2808CompilationResult ProgramCodeBlock::jitCompileImpl(ExecState* exec)
     2809{
     2810    ASSERT(jitType() == JITCode::InterpreterThunk);
     2811    ASSERT(this == replacement());
     2812    return static_cast<ProgramExecutable*>(ownerExecutable())->jitCompile(exec);
     2813}
     2814
     2815CompilationResult EvalCodeBlock::jitCompileImpl(ExecState* exec)
     2816{
     2817    ASSERT(jitType() == JITCode::InterpreterThunk);
     2818    ASSERT(this == replacement());
     2819    return static_cast<EvalExecutable*>(ownerExecutable())->jitCompile(exec);
     2820}
     2821
     2822CompilationResult FunctionCodeBlock::jitCompileImpl(ExecState* exec)
     2823{
     2824    ASSERT(jitType() == JITCode::InterpreterThunk);
     2825    ASSERT(this == replacement());
     2826    return static_cast<FunctionExecutable*>(ownerExecutable())->jitCompileFor(exec, m_isConstructor ? CodeForConstruct : CodeForCall);
    28402827}
    28412828#endif
  • trunk/Source/JavaScriptCore/bytecode/CodeBlock.h

    r154804 r154814  
    4949#include "DFGOSRExit.h"
    5050#include "DFGVariableEventStream.h"
    51 #include "DeferredCompilationCallback.h"
    5251#include "EvalCodeCache.h"
    5352#include "ExecutionCounter.h"
     
    204203    unsigned bytecodeOffset(ExecState*, ReturnAddressPtr);
    205204
    206     void unlinkIncomingCalls();
    207 
    208205#if ENABLE(JIT)
    209206    unsigned bytecodeOffsetForCallAtIndex(unsigned index)
     
    235232#endif // ENABLE(LLINT)
    236233
     234    void unlinkIncomingCalls();
     235
    237236#if ENABLE(DFG_JIT) || ENABLE(LLINT)
    238237    void setJITCodeMap(PassOwnPtr<CompactJITCodeMap> jitCodeMap)
     
    266265    int argumentIndexAfterCapture(size_t argument);
    267266
    268     // Prepares this code block for execution. This is synchronous. This compile
    269     // may fail, if you passed JITCompilationCanFail.
    270     CompilationResult prepareForExecution(
    271         ExecState*, JITCode::JITType,
    272         JITCompilationEffort = JITCompilationMustSucceed,
    273         unsigned bytecodeIndex = UINT_MAX);
    274    
    275     // Use this method for asynchronous compiles. This will do a compile at some
    276     // point in time between when you called into this method and some point in the
    277     // future. If you're lucky then it might complete before this method returns.
    278     // Once it completes, the callback is called with the result. If the compile
    279     // did happen to complete before the method returns, the result of the compile
    280     // may be returned. If the compile didn't happen to complete yet, or if we
    281     // didn't happen to notice that the compile already completed, we return
    282     // CompilationDeferred.
    283     //
    284     // Note that asynchronous compiles don't actually complete unless you call into
    285     // DFG::Worklist::completeAllReadyPlansForVM(). You usually force a call to
    286     // this on the main thread by listening to the callback's
    287     // compilationDidBecomeReadyAsynchronously() notification. Note that this call
    288     // happens on another thread.
    289     CompilationResult prepareForExecutionAsynchronously(
    290         ExecState*, JITCode::JITType, PassRefPtr<DeferredCompilationCallback>,
    291         JITCompilationEffort = JITCompilationMustSucceed,
    292         unsigned bytecodeIndex = UINT_MAX);
    293    
    294     // Exactly equivalent to codeBlock->ownerExecutable()->installCode(codeBlock);
    295     void install();
    296    
    297     // Exactly equivalent to codeBlock->ownerExecutable()->newReplacementCodeBlockFor(codeBlock->specializationKind())
    298     PassRefPtr<CodeBlock> newReplacement();
    299    
     267#if ENABLE(JIT)
    300268    void setJITCode(PassRefPtr<JITCode> code, MacroAssemblerCodePtr codeWithArityCheck)
    301269    {
     
    319287        return result;
    320288    }
    321 
    322 #if ENABLE(JIT)
    323289    bool hasBaselineJITProfiling() const
    324290    {
    325291        return jitType() == JITCode::BaselineJIT;
    326292    }
     293#if ENABLE(DFG_JIT)
     294    virtual JSObject* compileOptimized(ExecState*, JSScope*, CompilationResult&, unsigned bytecodeIndex) = 0;
     295    virtual CompilationResult replaceWithDeferredOptimizedCode(PassRefPtr<DFG::Plan>) = 0;
     296#endif // ENABLE(DFG_JIT)
    327297    void jettison();
    328    
     298    CompilationResult jitCompile(ExecState* exec)
     299    {
     300        if (jitType() != JITCode::InterpreterThunk) {
     301            ASSERT(jitType() == JITCode::BaselineJIT);
     302            return CompilationNotNeeded;
     303        }
     304        return jitCompileImpl(exec);
     305    }
    329306    virtual CodeBlock* replacement() = 0;
    330307
     
    339316
    340317    bool hasOptimizedReplacement();
     318#else
     319    JITCode::JITType jitType() const { return JITCode::InterpreterThunk; }
    341320#endif
    342321
     
    991970protected:
    992971#if ENABLE(JIT)
     972    virtual CompilationResult jitCompileImpl(ExecState*) = 0;
    993973    virtual void jettisonImpl() = 0;
    994974#endif
     
    1004984private:
    1005985    friend class DFGCodeBlocks;
    1006    
    1007     CompilationResult prepareForExecutionImpl(
    1008         ExecState*, JITCode::JITType, JITCompilationEffort, unsigned bytecodeIndex,
    1009         PassRefPtr<DeferredCompilationCallback>);
    1010986   
    1011987    void noticeIncomingCall(ExecState* callerFrame);
     
    11101086    SentinelLinkedList<LLIntCallLinkInfo, BasicRawSentinelNode<LLIntCallLinkInfo> > m_incomingLLIntCalls;
    11111087#endif
    1112     RefPtr<JITCode> m_jitCode;
    1113     MacroAssemblerCodePtr m_jitCodeWithArityCheck;
    11141088#if ENABLE(JIT)
    11151089    Vector<StructureStubInfo> m_structureStubInfos;
    11161090    Vector<ByValInfo> m_byValInfos;
    11171091    Vector<CallLinkInfo> m_callLinkInfos;
     1092    RefPtr<JITCode> m_jitCode;
     1093    MacroAssemblerCodePtr m_jitCodeWithArityCheck;
    11181094    SentinelLinkedList<CallLinkInfo, BasicRawSentinelNode<CallLinkInfo> > m_incomingCalls;
    11191095#endif
     
    12191195#if ENABLE(JIT)
    12201196protected:
     1197#if ENABLE(DFG_JIT)
     1198    virtual JSObject* compileOptimized(ExecState*, JSScope*, CompilationResult&, unsigned bytecodeIndex);
     1199    virtual CompilationResult replaceWithDeferredOptimizedCode(PassRefPtr<DFG::Plan>);
     1200#endif // ENABLE(DFG_JIT)
     1201
    12211202    virtual void jettisonImpl();
     1203    virtual CompilationResult jitCompileImpl(ExecState*);
    12221204    virtual CodeBlock* replacement();
    12231205    virtual DFG::CapabilityLevel capabilityLevelInternal();
     
    12421224#if ENABLE(JIT)
    12431225protected:
     1226#if ENABLE(DFG_JIT)
     1227    virtual JSObject* compileOptimized(ExecState*, JSScope*, CompilationResult&, unsigned bytecodeIndex);
     1228    virtual CompilationResult replaceWithDeferredOptimizedCode(PassRefPtr<DFG::Plan>);
     1229#endif // ENABLE(DFG_JIT)
     1230
    12441231    virtual void jettisonImpl();
     1232    virtual CompilationResult jitCompileImpl(ExecState*);
    12451233    virtual CodeBlock* replacement();
    12461234    virtual DFG::CapabilityLevel capabilityLevelInternal();
     
    12651253#if ENABLE(JIT)
    12661254protected:
     1255#if ENABLE(DFG_JIT)
     1256    virtual JSObject* compileOptimized(ExecState*, JSScope*, CompilationResult&, unsigned bytecodeIndex);
     1257    virtual CompilationResult replaceWithDeferredOptimizedCode(PassRefPtr<DFG::Plan>);
     1258#endif // ENABLE(DFG_JIT)
     1259
    12671260    virtual void jettisonImpl();
     1261    virtual CompilationResult jitCompileImpl(ExecState*);
    12681262    virtual CodeBlock* replacement();
    12691263    virtual DFG::CapabilityLevel capabilityLevelInternal();
  • trunk/Source/JavaScriptCore/dfg/DFGDriver.cpp

    r154804 r154814  
    5656}
    5757
    58 CompilationResult tryCompile(ExecState* exec, CodeBlock* codeBlock, unsigned osrEntryBytecodeIndex, PassRefPtr<DeferredCompilationCallback> callback)
     58static CompilationResult compile(CompileMode compileMode, ExecState* exec, CodeBlock* codeBlock, RefPtr<JSC::JITCode>& jitCode, MacroAssemblerCodePtr* jitCodeWithArityCheck, unsigned osrEntryBytecodeIndex)
    5959{
    6060    SamplingRegion samplingRegion("DFG Compilation (Driver)");
     
    100100        numVarsWithValues = 0;
    101101    RefPtr<Plan> plan = adoptRef(
    102         new Plan(codeBlock, osrEntryBytecodeIndex, numVarsWithValues));
     102        new Plan(compileMode, codeBlock, osrEntryBytecodeIndex, numVarsWithValues));
    103103    for (size_t i = 0; i < plan->mustHandleValues.size(); ++i) {
    104104        int operand = plan->mustHandleValues.operandForIndex(i);
    105105        if (operandIsArgument(operand)
    106106            && !operandToArgument(operand)
    107             && codeBlock->codeType() == FunctionCode
     107            && compileMode == CompileFunction
    108108            && codeBlock->specializationKind() == CodeForConstruct) {
    109109            // Ugh. If we're in a constructor, the 'this' argument may hold garbage. It will
     
    116116    }
    117117   
    118     if (enableConcurrentJIT() && callback) {
    119         plan->callback = callback;
     118    if (enableConcurrentJIT()) {
    120119        if (!vm.worklist)
    121120            vm.worklist = globalWorklist();
     
    127126   
    128127    plan->compileInThread(*vm.dfgState);
    129     return plan->finalizeWithoutNotifyingCallback();
     128    return plan->finalize(jitCode, jitCodeWithArityCheck);
     129}
     130
     131CompilationResult tryCompile(ExecState* exec, CodeBlock* codeBlock, RefPtr<JSC::JITCode>& jitCode, unsigned bytecodeIndex)
     132{
     133    return compile(CompileOther, exec, codeBlock, jitCode, 0, bytecodeIndex);
     134}
     135
     136CompilationResult tryCompileFunction(ExecState* exec, CodeBlock* codeBlock, RefPtr<JSC::JITCode>& jitCode, MacroAssemblerCodePtr& jitCodeWithArityCheck, unsigned bytecodeIndex)
     137{
     138    return compile(CompileFunction, exec, codeBlock, jitCode, &jitCodeWithArityCheck, bytecodeIndex);
     139}
     140
     141CompilationResult tryFinalizePlan(PassRefPtr<Plan> plan, RefPtr<JSC::JITCode>& jitCode, MacroAssemblerCodePtr* jitCodeWithArityCheck)
     142{
     143    return plan->finalize(jitCode, jitCodeWithArityCheck);
    130144}
    131145
  • trunk/Source/JavaScriptCore/dfg/DFGDriver.h

    r154804 r154814  
    4343
    4444#if ENABLE(DFG_JIT)
    45 CompilationResult tryCompile(ExecState*, CodeBlock*, unsigned osrEntryBytecodeIndex, PassRefPtr<DeferredCompilationCallback>);
     45CompilationResult tryCompile(ExecState*, CodeBlock*, RefPtr<JSC::JITCode>&, unsigned bytecodeIndex);
     46CompilationResult tryCompileFunction(ExecState*, CodeBlock*, RefPtr<JSC::JITCode>&, MacroAssemblerCodePtr& jitCodeWithArityCheck, unsigned bytecodeIndex);
     47CompilationResult tryFinalizePlan(PassRefPtr<Plan>, RefPtr<JSC::JITCode>&, MacroAssemblerCodePtr* jitCodeWithArityCheck);
    4648#else
    47 inline CompilationResult tryCompile(ExecState*, CodeBlock*, unsigned, PassRefPtr<DeferredCompilationCallback>) { return CompilationFailed; }
     49inline CompilationResult tryCompile(ExecState*, CodeBlock*, RefPtr<JSC::JITCode>&, unsigned) { return CompilationFailed; }
     50inline CompilationResult tryCompileFunction(ExecState*, CodeBlock*, RefPtr<JSC::JITCode>&, MacroAssemblerCodePtr&, unsigned) { return CompilationFailed; }
     51inline CompilationResult tryFinalizePlan(PassRefPtr<Plan>, RefPtr<JSC::JITCode>&, MacroAssemblerCodePtr*)
     52{
     53    UNREACHABLE_FOR_PLATFORM();
     54    return CompilationFailed;
     55}
    4856#endif
    4957
  • trunk/Source/JavaScriptCore/dfg/DFGFailedFinalizer.cpp

    r154804 r154814  
    4040}
    4141
    42 bool FailedFinalizer::finalize()
     42bool FailedFinalizer::finalize(RefPtr<JSC::JITCode>&)
    4343{
    4444    return false;
    4545}
    4646
    47 bool FailedFinalizer::finalizeFunction()
     47bool FailedFinalizer::finalizeFunction(RefPtr<JSC::JITCode>&, MacroAssemblerCodePtr&)
    4848{
    4949    return false;
  • trunk/Source/JavaScriptCore/dfg/DFGFailedFinalizer.h

    r154804 r154814  
    4040    virtual ~FailedFinalizer();
    4141   
    42     bool finalize();
    43     bool finalizeFunction();
     42    bool finalize(RefPtr<JSC::JITCode>& entry);
     43    bool finalizeFunction(RefPtr<JSC::JITCode>& entry, MacroAssemblerCodePtr& withArityCheck);
    4444};
    4545
  • trunk/Source/JavaScriptCore/dfg/DFGFinalizer.h

    r154804 r154814  
    4747    virtual ~Finalizer();
    4848   
    49     virtual bool finalize() = 0;
    50     virtual bool finalizeFunction() = 0;
     49    virtual bool finalize(RefPtr<JSC::JITCode>& entry) = 0;
     50    virtual bool finalizeFunction(RefPtr<JSC::JITCode>& entry, MacroAssemblerCodePtr& withArityCheck) = 0;
    5151
    5252protected:
  • trunk/Source/JavaScriptCore/dfg/DFGJITFinalizer.cpp

    r154804 r154814  
    2929#if ENABLE(DFG_JIT)
    3030
    31 #include "CodeBlock.h"
    3231#include "DFGCommon.h"
    3332#include "DFGPlan.h"
     
    4746}
    4847
    49 bool JITFinalizer::finalize()
     48bool JITFinalizer::finalize(RefPtr<JSC::JITCode>& entry)
    5049{
    5150    finalizeCommon();
    5251   
    5352    m_jitCode->initializeCodeRef(m_linkBuffer->finalizeCodeWithoutDisassembly());
    54     m_plan.codeBlock->setJITCode(m_jitCode, MacroAssemblerCodePtr());
     53    entry = m_jitCode;
    5554   
    5655    return true;
    5756}
    5857
    59 bool JITFinalizer::finalizeFunction()
     58bool JITFinalizer::finalizeFunction(RefPtr<JSC::JITCode>& entry, MacroAssemblerCodePtr& withArityCheck)
    6059{
    6160    finalizeCommon();
    6261   
    63     MacroAssemblerCodePtr withArityCheck = m_linkBuffer->locationOf(m_arityCheck);
     62    withArityCheck = m_linkBuffer->locationOf(m_arityCheck);
    6463    m_jitCode->initializeCodeRef(m_linkBuffer->finalizeCodeWithoutDisassembly());
    65     m_plan.codeBlock->setJITCode(m_jitCode, withArityCheck);
     64    entry = m_jitCode;
    6665   
    6766    return true;
  • trunk/Source/JavaScriptCore/dfg/DFGJITFinalizer.h

    r154804 r154814  
    4343    virtual ~JITFinalizer();
    4444   
    45     bool finalize();
    46     bool finalizeFunction();
     45    bool finalize(RefPtr<JSC::JITCode>& entry);
     46    bool finalizeFunction(RefPtr<JSC::JITCode>& entry, MacroAssemblerCodePtr& withArityCheck);
    4747
    4848private:
  • trunk/Source/JavaScriptCore/dfg/DFGOSRExitPreparation.cpp

    r154804 r154814  
    3131#include "CodeBlock.h"
    3232#include "Executable.h"
    33 #include "JITCode.h"
    3433#include "Operations.h"
    3534
     
    3837void prepareCodeOriginForOSRExit(ExecState* exec, CodeOrigin codeOrigin)
    3938{
    40     DeferGC deferGC(exec->vm().heap);
    41    
    4239    for (; codeOrigin.inlineCallFrame; codeOrigin = codeOrigin.inlineCallFrame->caller) {
    4340        FunctionExecutable* executable =
     
    4643            codeOrigin.inlineCallFrame->isCall ? CodeForCall : CodeForConstruct);
    4744       
    48         if (codeBlock->jitType() == JSC::JITCode::BaselineJIT)
    49             continue;
    50         ASSERT(codeBlock->jitType() == JSC::JITCode::InterpreterThunk);
    51         CompilationResult result = codeBlock->prepareForExecution(
    52             exec, JSC::JITCode::BaselineJIT, JITCompilationMustSucceed);
    53         ASSERT_UNUSED(result, result == CompilationSuccessful);
    54         codeBlock->install();
     45        codeBlock->jitCompile(exec);
    5546    }
    5647}
  • trunk/Source/JavaScriptCore/dfg/DFGOperations.cpp

    r154804 r154814  
    12821282    else {
    12831283        FunctionExecutable* functionExecutable = static_cast<FunctionExecutable*>(executable);
    1284         JSObject* error = functionExecutable->prepareForExecution(execCallee, callee->scope(), kind);
     1284        JSObject* error = functionExecutable->compileFor(execCallee, callee->scope(), kind);
    12851285        if (error) {
    12861286            vm->throwException(exec, createStackOverflowError(exec));
     
    13271327    if (UNLIKELY(!executable->hasJITCodeFor(kind))) {
    13281328        FunctionExecutable* functionExecutable = static_cast<FunctionExecutable*>(executable);
    1329         JSObject* error = functionExecutable->prepareForExecution(execCallee, function->scope(), kind);
     1329        JSObject* error = functionExecutable->compileFor(execCallee, function->scope(), kind);
    13301330        if (error) {
    13311331            exec->vm().throwException(execCallee, error);
  • trunk/Source/JavaScriptCore/dfg/DFGPlan.cpp

    r154804 r154814  
    8181
    8282Plan::Plan(
    83     PassRefPtr<CodeBlock> passedCodeBlock, unsigned osrEntryBytecodeIndex,
     83    CompileMode compileMode, PassRefPtr<CodeBlock> passedCodeBlock, unsigned osrEntryBytecodeIndex,
    8484    unsigned numVarsWithValues)
    85     : vm(*passedCodeBlock->vm())
     85    : compileMode(compileMode)
     86    , vm(*passedCodeBlock->vm())
    8687    , codeBlock(passedCodeBlock)
    8788    , osrEntryBytecodeIndex(osrEntryBytecodeIndex)
     
    208209#if ENABLE(FTL_JIT)
    209210    if (Options::useExperimentalFTL()
    210         && codeBlock->codeType() == FunctionCode
     211        && compileMode == CompileFunction
    211212        && FTL::canCompile(dfg)) {
    212213       
     
    255256
    256257    JITCompiler dataFlowJIT(dfg);
    257     if (codeBlock->codeType() == FunctionCode) {
     258    if (compileMode == CompileFunction) {
    258259        dataFlowJIT.compileFunction();
    259260        dataFlowJIT.linkFunction();
    260261    } else {
     262        ASSERT(compileMode == CompileOther);
     263       
    261264        dataFlowJIT.compile();
    262265        dataFlowJIT.link();
     
    281284}
    282285
    283 void Plan::notifyReady()
    284 {
    285     callback->compilationDidBecomeReadyAsynchronously(codeBlock.get());
    286     isCompiled = true;
    287 }
    288 
    289 CompilationResult Plan::finalizeWithoutNotifyingCallback()
     286CompilationResult Plan::finalize(RefPtr<JSC::JITCode>& jitCode, MacroAssemblerCodePtr* jitCodeWithArityCheck)
    290287{
    291288    if (!isStillValid())
     
    293290   
    294291    bool result;
    295     if (codeBlock->codeType() == FunctionCode)
    296         result = finalizer->finalizeFunction();
     292    if (compileMode == CompileFunction)
     293        result = finalizer->finalizeFunction(jitCode, *jitCodeWithArityCheck);
    297294    else
    298         result = finalizer->finalize();
     295        result = finalizer->finalize(jitCode);
    299296   
    300297    if (!result)
    301298        return CompilationFailed;
    302299   
    303     reallyAdd(codeBlock->jitCode()->dfgCommon());
     300    reallyAdd(jitCode->dfgCommon());
    304301   
    305302    return CompilationSuccessful;
    306303}
    307304
    308 void Plan::finalizeAndNotifyCallback()
    309 {
    310     callback->compilationDidComplete(codeBlock.get(), finalizeWithoutNotifyingCallback());
    311 }
    312 
    313305CodeBlock* Plan::key()
    314306{
  • trunk/Source/JavaScriptCore/dfg/DFGPlan.h

    r154804 r154814  
    3737#include "DFGDesiredWriteBarriers.h"
    3838#include "DFGFinalizer.h"
    39 #include "DeferredCompilationCallback.h"
    4039#include "Operands.h"
    4140#include "ProfilerCompilation.h"
     
    5049class LongLivedState;
    5150
     51enum CompileMode { CompileFunction, CompileOther };
     52
    5253#if ENABLE(DFG_JIT)
    5354
    5455struct Plan : public ThreadSafeRefCounted<Plan> {
    5556    Plan(
    56         PassRefPtr<CodeBlock>, unsigned osrEntryBytecodeIndex, unsigned numVarsWithValues);
     57        CompileMode compileMode, PassRefPtr<CodeBlock> codeBlock,
     58        unsigned osrEntryBytecodeIndex, unsigned numVarsWithValues);
    5759    ~Plan();
    5860   
    5961    void compileInThread(LongLivedState&);
    6062   
    61     CompilationResult finalizeWithoutNotifyingCallback();
    62     void finalizeAndNotifyCallback();
    63    
    64     void notifyReady();
     63    CompilationResult finalize(RefPtr<JSC::JITCode>& jitCode, MacroAssemblerCodePtr* jitCodeWithArityCheck);
    6564   
    6665    CodeBlock* key();
    6766   
     67    const CompileMode compileMode;
    6868    VM& vm;
    6969    RefPtr<CodeBlock> codeBlock;
     
    8787    bool isCompiled;
    8888
    89     RefPtr<DeferredCompilationCallback> callback;
    90 
    9189private:
    9290    enum CompilationPath { FailPath, DFGPath, FTLPath };
  • trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT32_64.cpp

    r154804 r154814  
    38383838        }
    38393839       
    3840         switch (node->child1().useKind()) {
    3841         case CellUse: {
     3840        if (isCellSpeculation(node->child1()->prediction())) {
    38423841            SpeculateCellOperand base(this, node->child1());
    38433842            GPRTemporary resultTag(this, base);
     
    38563855        }
    38573856       
    3858         case UntypedUse: {
    3859             JSValueOperand base(this, node->child1());
    3860             GPRTemporary resultTag(this, base);
    3861             GPRTemporary resultPayload(this);
    3862        
    3863             GPRReg baseTagGPR = base.tagGPR();
    3864             GPRReg basePayloadGPR = base.payloadGPR();
    3865             GPRReg resultTagGPR = resultTag.gpr();
    3866             GPRReg resultPayloadGPR = resultPayload.gpr();
    3867        
    3868             base.use();
    3869        
    3870             JITCompiler::Jump notCell = m_jit.branch32(JITCompiler::NotEqual, baseTagGPR, TrustedImm32(JSValue::CellTag));
    3871        
    3872             cachedGetById(node->codeOrigin, baseTagGPR, basePayloadGPR, resultTagGPR, resultPayloadGPR, node->identifierNumber(), notCell);
    3873        
    3874             jsValueResult(resultTagGPR, resultPayloadGPR, node, UseChildrenCalledExplicitly);
    3875             break;
    3876         }
    3877            
    3878         default:
    3879             RELEASE_ASSERT_NOT_REACHED();
    3880             break;
    3881         }
     3857        JSValueOperand base(this, node->child1());
     3858        GPRTemporary resultTag(this, base);
     3859        GPRTemporary resultPayload(this);
     3860       
     3861        GPRReg baseTagGPR = base.tagGPR();
     3862        GPRReg basePayloadGPR = base.payloadGPR();
     3863        GPRReg resultTagGPR = resultTag.gpr();
     3864        GPRReg resultPayloadGPR = resultPayload.gpr();
     3865       
     3866        base.use();
     3867       
     3868        JITCompiler::Jump notCell = m_jit.branch32(JITCompiler::NotEqual, baseTagGPR, TrustedImm32(JSValue::CellTag));
     3869       
     3870        cachedGetById(node->codeOrigin, baseTagGPR, basePayloadGPR, resultTagGPR, resultPayloadGPR, node->identifierNumber(), notCell);
     3871       
     3872        jsValueResult(resultTagGPR, resultPayloadGPR, node, UseChildrenCalledExplicitly);
    38823873        break;
    38833874    }
  • trunk/Source/JavaScriptCore/dfg/DFGWorklist.cpp

    r154804 r154814  
    166166        RELEASE_ASSERT(plan->isCompiled);
    167167       
    168         plan->finalizeAndNotifyCallback();
     168        CompilationResult compilationResult =
     169            profiledBlock->replaceWithDeferredOptimizedCode(plan);
     170        RELEASE_ASSERT(compilationResult != CompilationDeferred);
     171        profiledBlock->setOptimizationThresholdBasedOnCompilationResult(compilationResult);
    169172       
    170173        if (profiledBlock == requestedProfiledBlock)
     
    241244        {
    242245            MutexLocker locker(m_lock);
    243             plan->notifyReady();
     246            plan->key()->forceOptimizationSlowPathConcurrently();
     247            plan->isCompiled = true;
    244248           
    245249            if (Options::verboseCompilationQueue()) {
  • trunk/Source/JavaScriptCore/ftl/FTLJITFinalizer.cpp

    r154804 r154814  
    4545}
    4646
    47 bool JITFinalizer::finalize()
     47bool JITFinalizer::finalize(RefPtr<JSC::JITCode>&)
    4848{
    4949    RELEASE_ASSERT_NOT_REACHED();
     
    5151}
    5252
    53 bool JITFinalizer::finalizeFunction()
     53bool JITFinalizer::finalizeFunction(RefPtr<JSC::JITCode>& entry, MacroAssemblerCodePtr& withArityCheck)
    5454{
    5555    for (unsigned i = m_jitCode->handles().size(); i--;) {
     
    6565    } // else this function had no OSR exits, so no exit thunks.
    6666   
    67     MacroAssemblerCodePtr withArityCheck = m_entrypointLinkBuffer->locationOf(m_arityCheck);
     67    withArityCheck = m_entrypointLinkBuffer->locationOf(m_arityCheck);
    6868    m_jitCode->initializeCode(
    6969        FINALIZE_DFG_CODE(
    7070            *m_entrypointLinkBuffer,
    7171            ("FTL entrypoint thunk for %s with LLVM generated code at %p", toCString(CodeBlockWithJITType(m_plan.codeBlock.get(), JITCode::FTLJIT)).data(), m_function)));
    72    
    73     m_plan.codeBlock->setJITCode(m_jitCode, withArityCheck);
     72    entry = m_jitCode;
    7473   
    7574    return true;
  • trunk/Source/JavaScriptCore/ftl/FTLJITFinalizer.h

    r154804 r154814  
    6666    }
    6767   
    68     bool finalize();
    69     bool finalizeFunction();
     68    bool finalize(RefPtr<JSC::JITCode>& entry);
     69    bool finalizeFunction(RefPtr<JSC::JITCode>& entry, MacroAssemblerCodePtr& withArityCheck);
    7070
    7171private:
  • trunk/Source/JavaScriptCore/heap/Heap.h

    r154804 r154814  
    185185       
    186186        void addReference(JSCell*, ArrayBuffer*);
    187        
    188         bool isDeferred() const { return !!m_deferralDepth; }
    189187
    190188    private:
  • trunk/Source/JavaScriptCore/interpreter/Interpreter.cpp

    r154804 r154814  
    735735        return checkedReturn(callFrame->vm().throwException(callFrame, error));
    736736
    737     if (JSObject* error = program->prepareForExecution(callFrame, scope, CodeForCall))
     737    if (JSObject* error = program->compile(callFrame, scope))
    738738        return checkedReturn(callFrame->vm().throwException(callFrame, error));
    739739
     
    804804    if (isJSCall) {
    805805        // Compile the callee:
    806         JSObject* compileError = callData.js.functionExecutable->prepareForExecution(callFrame, scope, CodeForCall);
     806        JSObject* compileError = callData.js.functionExecutable->compileForCall(callFrame, scope);
    807807        if (UNLIKELY(!!compileError)) {
    808808            return checkedReturn(callFrame->vm().throwException(callFrame, compileError));
     
    883883    if (isJSConstruct) {
    884884        // Compile the callee:
    885         JSObject* compileError = constructData.js.functionExecutable->prepareForExecution(callFrame, scope, CodeForConstruct);
     885        JSObject* compileError = constructData.js.functionExecutable->compileForConstruct(callFrame, scope);
    886886        if (UNLIKELY(!!compileError)) {
    887887            return checkedReturn(callFrame->vm().throwException(callFrame, compileError));
     
    957957
    958958    // Compile the callee:
    959     JSObject* error = functionExecutable->prepareForExecution(callFrame, scope, CodeForCall);
     959    JSObject* error = functionExecutable->compileForCall(callFrame, scope);
    960960    if (error) {
    961961        callFrame->vm().throwException(callFrame, error);
     
    10731073    }
    10741074
    1075     JSObject* compileError = eval->prepareForExecution(callFrame, scope, CodeForCall);
     1075    JSObject* compileError = eval->compile(callFrame, scope);
    10761076    if (UNLIKELY(!!compileError))
    10771077        return checkedReturn(callFrame->vm().throwException(callFrame, compileError));
  • trunk/Source/JavaScriptCore/jit/JITStubs.cpp

    r154804 r154814  
    5252#include "JIT.h"
    5353#include "JITExceptions.h"
    54 #include "JITToDFGDeferredCompilationCallback.h"
    5554#include "JSActivation.h"
    5655#include "JSArray.h"
     
    1000999            dataLog("Considering OSR ", *codeBlock, " -> ", *codeBlock->replacement(), ".\n");
    10011000        // If we have an optimized replacement, then it must be the case that we entered
    1002         // cti_optimize from a loop. That's because if there's an optimized replacement,
     1001        // cti_optimize from a loop. That's because is there's an optimized replacement,
    10031002        // then all calls to this function will be relinked to the replacement and so
    10041003        // the prologue OSR will never fire.
     
    10341033            dataLog("Triggering optimized compilation of ", *codeBlock, "\n");
    10351034       
    1036         RefPtr<DeferredCompilationCallback> callback =
    1037             JITToDFGDeferredCompilationCallback::create();
    1038         RefPtr<CodeBlock> newCodeBlock = codeBlock->newReplacement();
    1039         CompilationResult result = newCodeBlock->prepareForExecutionAsynchronously(
    1040             callFrame, JITCode::DFGJIT, callback, JITCompilationCanFail, bytecodeIndex);
     1035        JSScope* scope = callFrame->scope();
     1036        CompilationResult result;
     1037        JSObject* error = codeBlock->compileOptimized(callFrame, scope, result, bytecodeIndex);
     1038        if (Options::verboseOSR()) {
     1039            dataLog("Optimizing compilation of ", *codeBlock, " result: ", result, "\n");
     1040            if (error)
     1041                dataLog("WARNING: optimized compilation failed with a JS error.\n");
     1042        }
    10411043       
     1044        codeBlock->setOptimizationThresholdBasedOnCompilationResult(result);
    10421045        if (result != CompilationSuccessful)
    10431046            return;
     
    11661169    FunctionExecutable* executable = function->jsExecutable();
    11671170    JSScope* callDataScopeChain = function->scope();
    1168     JSObject* error = executable->prepareForExecution(callFrame, callDataScopeChain, kind);
     1171    JSObject* error = executable->compileFor(callFrame, callDataScopeChain, kind);
    11691172    if (!error)
    11701173        return function;
     
    12651268    else {
    12661269        FunctionExecutable* functionExecutable = static_cast<FunctionExecutable*>(executable);
    1267         if (JSObject* error = functionExecutable->prepareForExecution(callFrame, callee->scope(), kind)) {
     1270        if (JSObject* error = functionExecutable->compileFor(callFrame, callee->scope(), kind)) {
    12681271            callFrame->vm().throwException(callFrame, error);
    12691272            return 0;
     
    13421345        FunctionExecutable* functionExecutable = jsCast<FunctionExecutable*>(executable);
    13431346        JSScope* scopeChain = callee->scope();
    1344         JSObject* error = functionExecutable->prepareForExecution(callFrame, scopeChain, CodeForCall);
     1347        JSObject* error = functionExecutable->compileFor(callFrame, scopeChain, CodeForCall);
    13451348        if (error) {
    13461349            callFrame->vm().throwException(callFrame, error);
  • trunk/Source/JavaScriptCore/llint/LLIntEntrypoints.cpp

    r154804 r154814  
    11/*
    2  * Copyright (C) 2012, 2013 Apple Inc. All rights reserved.
     2 * Copyright (C) 2012 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2929#if ENABLE(LLINT)
    3030
    31 #include "CodeBlock.h"
    3231#include "JITCode.h"
     32#include "VM.h"
    3333#include "JSObject.h"
    3434#include "LLIntThunks.h"
    3535#include "LowLevelInterpreter.h"
    36 #include "VM.h"
    3736
    3837
    3938namespace JSC { namespace LLInt {
    4039
    41 void setFunctionEntrypoint(VM& vm, FunctionCodeBlock* codeBlock)
     40void getFunctionEntrypoint(VM& vm, CodeSpecializationKind kind, RefPtr<JITCode>& jitCode, MacroAssemblerCodePtr& arityCheck)
    4241{
    43     CodeSpecializationKind kind = codeBlock->specializationKind();
    44    
    4542    if (!vm.canUseJIT()) {
    4643        if (kind == CodeForCall) {
    47             codeBlock->setJITCode(
    48                 adoptRef(new DirectJITCode(MacroAssemblerCodeRef::createLLIntCodeRef(llint_function_for_call_prologue), JITCode::InterpreterThunk)),
    49                 MacroAssemblerCodePtr::createLLIntCodePtr(llint_function_for_call_arity_check));
     44            jitCode = adoptRef(new DirectJITCode(MacroAssemblerCodeRef::createLLIntCodeRef(llint_function_for_call_prologue), JITCode::InterpreterThunk));
     45            arityCheck = MacroAssemblerCodePtr::createLLIntCodePtr(llint_function_for_call_arity_check);
    5046            return;
    5147        }
    5248
    5349        ASSERT(kind == CodeForConstruct);
    54         codeBlock->setJITCode(
    55             adoptRef(new DirectJITCode(MacroAssemblerCodeRef::createLLIntCodeRef(llint_function_for_construct_prologue), JITCode::InterpreterThunk)),
    56             MacroAssemblerCodePtr::createLLIntCodePtr(llint_function_for_construct_arity_check));
     50        jitCode = adoptRef(new DirectJITCode(MacroAssemblerCodeRef::createLLIntCodeRef(llint_function_for_construct_prologue), JITCode::InterpreterThunk));
     51        arityCheck = MacroAssemblerCodePtr::createLLIntCodePtr(llint_function_for_construct_arity_check);
    5752        return;
    5853    }
     
    6055#if ENABLE(JIT)
    6156    if (kind == CodeForCall) {
    62         codeBlock->setJITCode(
    63             adoptRef(new DirectJITCode(vm.getCTIStub(functionForCallEntryThunkGenerator), JITCode::InterpreterThunk)),
    64             vm.getCTIStub(functionForCallArityCheckThunkGenerator).code());
     57        jitCode = adoptRef(new DirectJITCode(vm.getCTIStub(functionForCallEntryThunkGenerator), JITCode::InterpreterThunk));
     58        arityCheck = vm.getCTIStub(functionForCallArityCheckThunkGenerator).code();
    6559        return;
    6660    }
    6761
    6862    ASSERT(kind == CodeForConstruct);
    69     codeBlock->setJITCode(
    70         adoptRef(new DirectJITCode(vm.getCTIStub(functionForConstructEntryThunkGenerator), JITCode::InterpreterThunk)),
    71         vm.getCTIStub(functionForConstructArityCheckThunkGenerator).code());
     63    jitCode = adoptRef(new DirectJITCode(vm.getCTIStub(functionForConstructEntryThunkGenerator), JITCode::InterpreterThunk));
     64    arityCheck = vm.getCTIStub(functionForConstructArityCheckThunkGenerator).code();
    7265#endif // ENABLE(JIT)
    7366}
    7467
    75 void setEvalEntrypoint(VM& vm, EvalCodeBlock* codeBlock)
     68void getEvalEntrypoint(VM& vm, RefPtr<JITCode>& jitCode)
    7669{
    7770    if (!vm.canUseJIT()) {
    78         codeBlock->setJITCode(
    79             adoptRef(new DirectJITCode(MacroAssemblerCodeRef::createLLIntCodeRef(llint_eval_prologue), JITCode::InterpreterThunk)),
    80             MacroAssemblerCodePtr());
     71        jitCode = adoptRef(new DirectJITCode(MacroAssemblerCodeRef::createLLIntCodeRef(llint_eval_prologue), JITCode::InterpreterThunk));
     72        return;
     73    }
     74#if ENABLE(JIT)   
     75    jitCode = adoptRef(new DirectJITCode(vm.getCTIStub(evalEntryThunkGenerator), JITCode::InterpreterThunk));
     76#endif
     77}
     78
     79void getProgramEntrypoint(VM& vm, RefPtr<JITCode>& jitCode)
     80{
     81    if (!vm.canUseJIT()) {
     82        jitCode = adoptRef(new DirectJITCode(MacroAssemblerCodeRef::createLLIntCodeRef(llint_program_prologue), JITCode::InterpreterThunk));
    8183        return;
    8284    }
    8385#if ENABLE(JIT)
    84     codeBlock->setJITCode(
    85         adoptRef(new DirectJITCode(vm.getCTIStub(evalEntryThunkGenerator), JITCode::InterpreterThunk)),
    86         MacroAssemblerCodePtr());
    87 #endif
    88 }
    89 
    90 void setProgramEntrypoint(VM& vm, ProgramCodeBlock* codeBlock)
    91 {
    92     if (!vm.canUseJIT()) {
    93         codeBlock->setJITCode(
    94             adoptRef(new DirectJITCode(MacroAssemblerCodeRef::createLLIntCodeRef(llint_program_prologue), JITCode::InterpreterThunk)),
    95             MacroAssemblerCodePtr());
    96         return;
    97     }
    98 #if ENABLE(JIT)
    99     codeBlock->setJITCode(
    100         adoptRef(new DirectJITCode(vm.getCTIStub(programEntryThunkGenerator), JITCode::InterpreterThunk)),
    101         MacroAssemblerCodePtr());
     86    jitCode = adoptRef(new DirectJITCode(vm.getCTIStub(programEntryThunkGenerator), JITCode::InterpreterThunk));
    10287#endif
    10388}
  • trunk/Source/JavaScriptCore/llint/LLIntEntrypoints.h

    r154804 r154814  
    11/*
    2  * Copyright (C) 2012, 2013 Apple Inc. All rights reserved.
     2 * Copyright (C) 2012 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    3838
    3939class EvalCodeBlock;
    40 class FunctionCodeBlock;
    4140class VM;
    4241class MacroAssemblerCodePtr;
     
    4645namespace LLInt {
    4746
    48 void setFunctionEntrypoint(VM&, FunctionCodeBlock*);
    49 void setEvalEntrypoint(VM&, EvalCodeBlock*);
    50 void setProgramEntrypoint(VM&, ProgramCodeBlock*);
     47void getFunctionEntrypoint(VM&, CodeSpecializationKind, RefPtr<JITCode>&, MacroAssemblerCodePtr& arityCheck);
     48void getEvalEntrypoint(VM&, RefPtr<JITCode>&);
     49void getProgramEntrypoint(VM&, RefPtr<JITCode>&);
     50
     51inline void getEntrypoint(VM& vm, EvalCodeBlock*, RefPtr<JITCode>& jitCode)
     52{
     53    getEvalEntrypoint(vm, jitCode);
     54}
     55
     56inline void getEntrypoint(VM& vm, ProgramCodeBlock*, RefPtr<JITCode>& jitCode)
     57{
     58    getProgramEntrypoint(vm, jitCode);
     59}
    5160
    5261} } // namespace JSC::LLInt
  • trunk/Source/JavaScriptCore/llint/LLIntSlowPaths.cpp

    r154804 r154814  
    3838#include "Interpreter.h"
    3939#include "JIT.h"
     40#include "JITDriver.h"
    4041#include "JSActivation.h"
    4142#include "JSCJSValue.h"
     
    280281inline bool jitCompileAndSetHeuristics(CodeBlock* codeBlock, ExecState* exec)
    281282{
    282     DeferGC deferGC(exec->vm().heap);
    283    
    284283    codeBlock->updateAllValueProfilePredictions();
    285284   
     
    290289    }
    291290   
    292     switch (codeBlock->jitType()) {
    293     case JITCode::BaselineJIT: {
     291    CompilationResult result = codeBlock->jitCompile(exec);
     292    switch (result) {
     293    case CompilationNotNeeded:
    294294        if (Options::verboseOSR())
    295295            dataLogF("    Code was already compiled.\n");
    296296        codeBlock->jitSoon();
    297297        return true;
    298     }
    299     case JITCode::InterpreterThunk: {
    300         CompilationResult result = codeBlock->prepareForExecution(
    301             exec, JITCode::BaselineJIT, JITCompilationCanFail);
    302         switch (result) {
    303         case CompilationFailed:
    304             if (Options::verboseOSR())
    305                 dataLogF("    JIT compilation failed.\n");
    306             codeBlock->dontJITAnytimeSoon();
    307             return false;
    308         case CompilationSuccessful:
    309             if (Options::verboseOSR())
    310                 dataLogF("    JIT compilation successful.\n");
    311             codeBlock->install();
    312             codeBlock->jitSoon();
    313             return true;
    314         default:
    315             RELEASE_ASSERT_NOT_REACHED();
    316             return false;
    317         }
    318     }
     298    case CompilationFailed:
     299        if (Options::verboseOSR())
     300            dataLogF("    JIT compilation failed.\n");
     301        codeBlock->dontJITAnytimeSoon();
     302        return false;
     303    case CompilationSuccessful:
     304        if (Options::verboseOSR())
     305            dataLogF("    JIT compilation successful.\n");
     306        codeBlock->jitSoon();
     307        return true;
    319308    default:
    320309        RELEASE_ASSERT_NOT_REACHED();
     
    10161005    else {
    10171006        FunctionExecutable* functionExecutable = static_cast<FunctionExecutable*>(executable);
    1018         JSObject* error = functionExecutable->prepareForExecution(execCallee, callee->scope(), kind);
     1007        JSObject* error = functionExecutable->compileFor(execCallee, callee->scope(), kind);
    10191008        if (error)
    10201009            LLINT_CALL_THROW(execCallee->callerFrame(), pc, error);
  • trunk/Source/JavaScriptCore/runtime/ArrayPrototype.cpp

    r154804 r154814  
    7979    FunctionExecutable* executable = callData.js.functionExecutable;
    8080
    81     JSObject* error = executable->prepareForExecution(exec, callData.js.scope, CodeForCall);
     81    JSObject* error = executable->compileForCall(exec, callData.js.scope);
    8282    if (error)
    8383        return false;
  • trunk/Source/JavaScriptCore/runtime/CommonSlowPaths.cpp

    r154804 r154814  
    3838#include "Interpreter.h"
    3939#include "JIT.h"
     40#include "JITDriver.h"
    4041#include "JITStubs.h"
    4142#include "JSActivation.h"
  • trunk/Source/JavaScriptCore/runtime/CompilationResult.cpp

    r154804 r154814  
    4343        out.print("CompilationSuccessful");
    4444        return;
     45    case CompilationNotNeeded:
     46        out.print("CompilationNotNeeded");
     47        return;
    4548    case CompilationDeferred:
    4649        out.print("CompilationDeferred");
  • trunk/Source/JavaScriptCore/runtime/CompilationResult.h

    r154804 r154814  
    3131namespace JSC {
    3232
    33 enum CompilationResult {
    34     // We tried to compile the code, but we couldn't compile it. This could be
    35     // because we ran out of memory, or because the compiler encountered an
    36     // internal error and decided to bail out gracefully. Either way, this implies
    37     // that we shouldn't try to compile this code block again.
    38     CompilationFailed,
    39    
    40     // The profiling assumptions that were fed into the compiler were invalidated
    41     // even before we finished compiling. This means we should try again: in such
    42     // cases the profiling will now be updated and the next compilation won't
    43     // encounter the same problem. But it does mean that we should exercise
    44     // exponential back-off, to get even more profiling so that new profiling
    45     // pathologies aren't encountered.
    46     CompilationInvalidated,
    47    
    48     // The compilation succeeded and the code block now has JITCode for the newly
    49     // compiled code. However, compilation success doesn't mean that the CodeBlock
    50     // will execute yet; you typically have to install it first, unless you plan
    51     // on invoking it manually (something that *could* be done for some kinds of
    52     // OSR entry).
    53     CompilationSuccessful,
    54    
    55     // We decided to do the compilation asynchronously. This means that we haven't
    56     // yet compiled the code. This only happens when you pass a
    57     // DeferredCompilationCallback. That callback will get called with some
    58     // interesting result, once compilation completes.
    59     CompilationDeferred
    60 };
     33enum CompilationResult { CompilationFailed, CompilationInvalidated, CompilationSuccessful, CompilationNotNeeded, CompilationDeferred };
    6134
    6235} // namespace JSC
  • trunk/Source/JavaScriptCore/runtime/Executable.cpp

    r154804 r154814  
    11/*
    2  * Copyright (C) 2009, 2010, 2013 Apple Inc. All rights reserved.
     2 * Copyright (C) 2009, 2010 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    3131#include "CodeBlock.h"
    3232#include "DFGDriver.h"
     33#include "ExecutionHarness.h"
    3334#include "JIT.h"
     35#include "JITDriver.h"
    3436#include "Operations.h"
    3537#include "Parser.h"
     
    113115#endif
    114116
    115 void ScriptExecutable::installCode(CodeBlock* genericCodeBlock)
    116 {
    117     RELEASE_ASSERT(genericCodeBlock->ownerExecutable() == this);
    118    
    119     VM& vm = *genericCodeBlock->vm();
    120    
    121     if (vm.m_perBytecodeProfiler)
    122         vm.m_perBytecodeProfiler->ensureBytecodesFor(genericCodeBlock);
    123    
    124     ASSERT(vm.heap.isDeferred());
    125    
    126     if (JITCode::isJIT(genericCodeBlock->jitType())) {
    127         vm.heap.reportExtraMemoryCost(
    128             sizeof(CodeBlock) + genericCodeBlock->jitCode()->size());
    129     } else
    130         vm.heap.reportExtraMemoryCost(sizeof(CodeBlock));
    131    
    132     CodeSpecializationKind kind = genericCodeBlock->specializationKind();
    133    
    134     RefPtr<CodeBlock> oldCodeBlock;
    135    
    136     switch (kind) {
    137     case CodeForCall:
    138         m_jitCodeForCall = genericCodeBlock->jitCode();
    139         m_jitCodeForCallWithArityCheck = genericCodeBlock->jitCodeWithArityCheck();
    140         m_numParametersForCall = genericCodeBlock->numParameters();
    141         break;
    142     case CodeForConstruct:
    143         m_jitCodeForConstruct = genericCodeBlock->jitCode();
    144         m_jitCodeForConstructWithArityCheck = genericCodeBlock->jitCodeWithArityCheck();
    145         m_numParametersForConstruct = genericCodeBlock->numParameters();
    146         break;
    147     }
    148    
    149     switch (genericCodeBlock->codeType()) {
    150     case GlobalCode: {
    151         ProgramExecutable* executable = jsCast<ProgramExecutable*>(this);
    152         ProgramCodeBlock* codeBlock = static_cast<ProgramCodeBlock*>(genericCodeBlock);
    153        
    154         ASSERT(!codeBlock->jitCodeWithArityCheck());
    155         ASSERT(kind == CodeForCall);
    156        
    157         oldCodeBlock = executable->m_programCodeBlock;
    158         executable->m_programCodeBlock = codeBlock;
    159         break;
    160     }
    161        
    162     case EvalCode: {
    163         EvalExecutable* executable = jsCast<EvalExecutable*>(this);
    164         EvalCodeBlock* codeBlock = static_cast<EvalCodeBlock*>(genericCodeBlock);
    165        
    166         ASSERT(!codeBlock->jitCodeWithArityCheck());
    167         ASSERT(kind == CodeForCall);
    168        
    169         oldCodeBlock = executable->m_evalCodeBlock;
    170         executable->m_evalCodeBlock = codeBlock;
    171         break;
    172     }
    173        
    174     case FunctionCode: {
    175         FunctionExecutable* executable = jsCast<FunctionExecutable*>(this);
    176         FunctionCodeBlock* codeBlock = static_cast<FunctionCodeBlock*>(genericCodeBlock);
    177        
    178         switch (kind) {
    179         case CodeForCall:
    180             oldCodeBlock = executable->m_codeBlockForCall;
    181             executable->m_codeBlockForCall = codeBlock;
    182             break;
    183         case CodeForConstruct:
    184             oldCodeBlock = executable->m_codeBlockForConstruct;
    185             executable->m_codeBlockForConstruct = codeBlock;
    186             break;
    187         }
    188         break;
    189     } }
    190 
    191     if (oldCodeBlock)
    192         oldCodeBlock->unlinkIncomingCalls();
    193 }
    194 
    195 PassRefPtr<CodeBlock> ScriptExecutable::newCodeBlockFor(
    196     CodeSpecializationKind kind, JSScope* scope, JSObject*& exception)
    197 {
    198     VM* vm = scope->vm();
    199 
    200     ASSERT(vm->heap.isDeferred());
    201    
    202     if (classInfo() == EvalExecutable::info()) {
    203         EvalExecutable* executable = jsCast<EvalExecutable*>(this);
    204         RELEASE_ASSERT(kind == CodeForCall);
    205         RELEASE_ASSERT(!executable->m_evalCodeBlock);
    206         return adoptRef(new EvalCodeBlock(
    207             executable, executable->m_unlinkedEvalCodeBlock.get(), scope,
    208             executable->source().provider()));
    209     }
    210    
    211     if (classInfo() == ProgramExecutable::info()) {
    212         ProgramExecutable* executable = jsCast<ProgramExecutable*>(this);
    213         RELEASE_ASSERT(kind == CodeForCall);
    214         RELEASE_ASSERT(!executable->m_programCodeBlock);
    215         return adoptRef(new ProgramCodeBlock(
    216             executable, executable->m_unlinkedProgramCodeBlock.get(), scope,
    217             executable->source().provider(), executable->source().startColumn()));
    218     }
    219    
    220     RELEASE_ASSERT(classInfo() == FunctionExecutable::info());
    221     FunctionExecutable* executable = jsCast<FunctionExecutable*>(this);
    222     RELEASE_ASSERT(!executable->codeBlockFor(kind));
    223     JSGlobalObject* globalObject = scope->globalObject();
    224     ParserError error;
    225     DebuggerMode debuggerMode = globalObject->hasDebugger() ? DebuggerOn : DebuggerOff;
    226     ProfilerMode profilerMode = globalObject->hasProfiler() ? ProfilerOn : ProfilerOff;
    227     UnlinkedFunctionCodeBlock* unlinkedCodeBlock =
    228         executable->m_unlinkedExecutable->codeBlockFor(
    229             *vm, executable->m_source, kind, debuggerMode, profilerMode, error);
    230     if (!unlinkedCodeBlock) {
    231         exception = vm->throwException(
    232             globalObject->globalExec(),
    233             error.toErrorObject(globalObject, executable->m_source));
    234         return 0;
    235     }
    236    
    237     SourceProvider* provider = executable->source().provider();
    238     unsigned sourceOffset = executable->source().startOffset();
    239     unsigned startColumn = executable->source().startColumn();
    240 
    241     return adoptRef(new FunctionCodeBlock(
    242         executable, unlinkedCodeBlock, scope, provider, sourceOffset, startColumn));
    243 }
    244 
    245 PassRefPtr<CodeBlock> ScriptExecutable::newReplacementCodeBlockFor(
    246     CodeSpecializationKind kind)
    247 {
    248     if (classInfo() == EvalExecutable::info()) {
    249         RELEASE_ASSERT(kind == CodeForCall);
    250         EvalExecutable* executable = jsCast<EvalExecutable*>(this);
    251         RefPtr<EvalCodeBlock> result = adoptRef(new EvalCodeBlock(
    252             CodeBlock::CopyParsedBlock, *executable->m_evalCodeBlock));
    253         result->setAlternative(executable->m_evalCodeBlock);
    254         return result;
    255     }
    256    
    257     if (classInfo() == ProgramExecutable::info()) {
    258         RELEASE_ASSERT(kind == CodeForCall);
    259         ProgramExecutable* executable = jsCast<ProgramExecutable*>(this);
    260         RefPtr<ProgramCodeBlock> result = adoptRef(new ProgramCodeBlock(
    261             CodeBlock::CopyParsedBlock, *executable->m_programCodeBlock));
    262         result->setAlternative(executable->m_programCodeBlock);
    263         return result;
    264     }
    265 
    266     RELEASE_ASSERT(classInfo() == FunctionExecutable::info());
    267     FunctionExecutable* executable = jsCast<FunctionExecutable*>(this);
    268     RefPtr<FunctionCodeBlock> result = adoptRef(new FunctionCodeBlock(
    269         CodeBlock::CopyParsedBlock, *executable->codeBlockFor(kind)));
    270     result->setAlternative(executable->codeBlockFor(kind));
    271     return result;
    272 }
    273 
    274 JSObject* ScriptExecutable::prepareForExecutionImpl(
    275     ExecState* exec, JSScope* scope, CodeSpecializationKind kind)
    276 {
    277     VM& vm = exec->vm();
    278     DeferGC deferGC(vm.heap);
    279    
    280     JSObject* exception = 0;
    281     RefPtr<CodeBlock> codeBlock = newCodeBlockFor(kind, scope, exception);
    282     if (!codeBlock) {
    283         RELEASE_ASSERT(exception);
    284         return exception;
    285     }
    286    
    287     JITCode::JITType jitType;
    288 #if ENABLE(LLINT)
    289     jitType = JITCode::InterpreterThunk;
    290 #else
    291     jitType = JITCode::BaselineJIT;
    292 #endif
    293     codeBlock->prepareForExecution(exec, jitType);
    294 
    295     installCode(codeBlock.get());
    296     return 0;
    297 }
    298 
    299117const ClassInfo EvalExecutable::s_info = { "EvalExecutable", &ScriptExecutable::s_info, 0, 0, CREATE_METHOD_TABLE(EvalExecutable) };
    300118
     
    358176    static_cast<FunctionExecutable*>(cell)->FunctionExecutable::~FunctionExecutable();
    359177}
     178
     179#if ENABLE(DFG_JIT)
     180JSObject* EvalExecutable::compileOptimized(ExecState* exec, JSScope* scope, CompilationResult& result, unsigned bytecodeIndex)
     181{
     182    ASSERT(exec->vm().dynamicGlobalObject);
     183    ASSERT(!!m_evalCodeBlock);
     184    JSObject* error = 0;
     185    if (!JITCode::isOptimizingJIT(m_evalCodeBlock->jitType()))
     186        error = compileInternal(exec, scope, JITCode::nextTierJIT(m_evalCodeBlock->jitType()), &result, bytecodeIndex);
     187    else
     188        result = CompilationNotNeeded;
     189    ASSERT(!!m_evalCodeBlock);
     190    return error;
     191}
     192#endif // ENABLE(DFG_JIT)
     193
     194#if ENABLE(JIT)
     195CompilationResult EvalExecutable::jitCompile(ExecState* exec)
     196{
     197    return jitCompileIfAppropriate(exec, m_evalCodeBlock.get(), m_jitCodeForCall, JITCode::bottomTierJIT(), UINT_MAX, JITCompilationCanFail);
     198}
     199#endif
    360200
    361201inline const char* samplingDescription(JITCode::JITType jitType)
     
    376216}
    377217
     218JSObject* EvalExecutable::compileInternal(ExecState* exec, JSScope* scope, JITCode::JITType jitType, CompilationResult* result, unsigned bytecodeIndex)
     219{
     220    SamplingRegion samplingRegion(samplingDescription(jitType));
     221   
     222    if (result)
     223        *result = CompilationFailed;
     224   
     225    RefPtr<EvalCodeBlock> newCodeBlock;
     226   
     227    if (!!m_evalCodeBlock) {
     228        newCodeBlock = adoptRef(new EvalCodeBlock(CodeBlock::CopyParsedBlock, *m_evalCodeBlock));
     229        newCodeBlock->setAlternative(static_pointer_cast<CodeBlock>(m_evalCodeBlock));
     230    } else {
     231        newCodeBlock = adoptRef(new EvalCodeBlock(this, m_unlinkedEvalCodeBlock.get(), scope, source().provider()));
     232        ASSERT((jitType == JITCode::bottomTierJIT()) == !m_evalCodeBlock);
     233    }
     234
     235    CompilationResult theResult = prepareForExecution(
     236        exec, m_evalCodeBlock, newCodeBlock.get(), m_jitCodeForCall, jitType, bytecodeIndex);
     237    if (result)
     238        *result = theResult;
     239
     240    return 0;
     241}
     242
     243#if ENABLE(DFG_JIT)
     244CompilationResult EvalExecutable::replaceWithDeferredOptimizedCode(PassRefPtr<DFG::Plan> plan)
     245{
     246    return JSC::replaceWithDeferredOptimizedCode(
     247        plan, m_evalCodeBlock, m_jitCodeForCall, 0, 0);
     248}
     249#endif // ENABLE(DFG_JIT)
     250
    378251#if ENABLE(JIT)
    379252void EvalExecutable::jettisonOptimizedCode(VM& vm)
     
    426299}
    427300
     301#if ENABLE(DFG_JIT)
     302JSObject* ProgramExecutable::compileOptimized(ExecState* exec, JSScope* scope, CompilationResult& result, unsigned bytecodeIndex)
     303{
     304    RELEASE_ASSERT(exec->vm().dynamicGlobalObject);
     305    ASSERT(!!m_programCodeBlock);
     306    JSObject* error = 0;
     307    if (!JITCode::isOptimizingJIT(m_programCodeBlock->jitType()))
     308        error = compileInternal(exec, scope, JITCode::nextTierJIT(m_programCodeBlock->jitType()), &result, bytecodeIndex);
     309    else
     310        result = CompilationNotNeeded;
     311    ASSERT(!!m_programCodeBlock);
     312    return error;
     313}
     314#endif // ENABLE(DFG_JIT)
     315
     316#if ENABLE(JIT)
     317CompilationResult ProgramExecutable::jitCompile(ExecState* exec)
     318{
     319    return jitCompileIfAppropriate(exec, m_programCodeBlock.get(), m_jitCodeForCall, JITCode::bottomTierJIT(), UINT_MAX, JITCompilationCanFail);
     320}
     321#endif
     322
     323JSObject* ProgramExecutable::compileInternal(ExecState* exec, JSScope* scope, JITCode::JITType jitType, CompilationResult* result, unsigned bytecodeIndex)
     324{
     325    SamplingRegion samplingRegion(samplingDescription(jitType));
     326   
     327    if (result)
     328        *result = CompilationFailed;
     329   
     330    RefPtr<ProgramCodeBlock> newCodeBlock;
     331   
     332    if (!!m_programCodeBlock) {
     333        newCodeBlock = adoptRef(new ProgramCodeBlock(CodeBlock::CopyParsedBlock, *m_programCodeBlock));
     334        newCodeBlock->setAlternative(static_pointer_cast<CodeBlock>(m_programCodeBlock));
     335    } else {
     336        newCodeBlock = adoptRef(new ProgramCodeBlock(this, m_unlinkedProgramCodeBlock.get(), scope, source().provider(), source().startColumn()));
     337    }
     338
     339    CompilationResult theResult = prepareForExecution(
     340        exec, m_programCodeBlock, newCodeBlock.get(), m_jitCodeForCall, jitType, bytecodeIndex);
     341    if (result)
     342        *result = theResult;
     343
     344    return 0;
     345}
     346
     347#if ENABLE(DFG_JIT)
     348CompilationResult ProgramExecutable::replaceWithDeferredOptimizedCode(PassRefPtr<DFG::Plan> plan)
     349{
     350    return JSC::replaceWithDeferredOptimizedCode(
     351        plan, m_programCodeBlock, m_jitCodeForCall, 0, 0);
     352}
     353#endif // ENABLE(DFG_JIT)
     354
    428355#if ENABLE(JIT)
    429356void ProgramExecutable::jettisonOptimizedCode(VM& vm)
     
    517444    return result;
    518445}
     446
     447#if ENABLE(DFG_JIT)
     448JSObject* FunctionExecutable::compileOptimizedForCall(ExecState* exec, JSScope* scope, CompilationResult& result, unsigned bytecodeIndex)
     449{
     450    RELEASE_ASSERT(exec->vm().dynamicGlobalObject);
     451    ASSERT(!!m_codeBlockForCall);
     452    JSObject* error = 0;
     453    if (!JITCode::isOptimizingJIT(m_codeBlockForCall->jitType()))
     454        error = compileForCallInternal(exec, scope, JITCode::nextTierJIT(m_codeBlockForCall->jitType()), &result, bytecodeIndex);
     455    else
     456        result = CompilationNotNeeded;
     457    ASSERT(!!m_codeBlockForCall);
     458    return error;
     459}
     460
     461JSObject* FunctionExecutable::compileOptimizedForConstruct(ExecState* exec, JSScope* scope, CompilationResult& result, unsigned bytecodeIndex)
     462{
     463    RELEASE_ASSERT(exec->vm().dynamicGlobalObject);
     464    ASSERT(!!m_codeBlockForConstruct);
     465    JSObject* error = 0;
     466    if (!JITCode::isOptimizingJIT(m_codeBlockForConstruct->jitType()))
     467        error = compileForConstructInternal(exec, scope, JITCode::nextTierJIT(m_codeBlockForConstruct->jitType()), &result, bytecodeIndex);
     468    else
     469        result = CompilationNotNeeded;
     470    ASSERT(!!m_codeBlockForConstruct);
     471    return error;
     472}
     473#endif // ENABLE(DFG_JIT)
     474
     475#if ENABLE(JIT)
     476CompilationResult FunctionExecutable::jitCompileForCall(ExecState* exec)
     477{
     478    return jitCompileFunctionIfAppropriate(exec, m_codeBlockForCall.get(), m_jitCodeForCall, m_jitCodeForCallWithArityCheck, JITCode::bottomTierJIT(), UINT_MAX, JITCompilationCanFail);
     479}
     480
     481CompilationResult FunctionExecutable::jitCompileForConstruct(ExecState* exec)
     482{
     483    return jitCompileFunctionIfAppropriate(exec, m_codeBlockForConstruct.get(), m_jitCodeForConstruct, m_jitCodeForConstructWithArityCheck, JITCode::bottomTierJIT(), UINT_MAX, JITCompilationCanFail);
     484}
     485#endif
     486
     487PassRefPtr<FunctionCodeBlock> FunctionExecutable::produceCodeBlockFor(JSScope* scope, CodeSpecializationKind specializationKind, JSObject*& exception)
     488{
     489    RefPtr<FunctionCodeBlock> alternative = codeBlockFor(specializationKind);
     490   
     491    if (!!alternative) {
     492        RefPtr<FunctionCodeBlock> result = adoptRef(new FunctionCodeBlock(CodeBlock::CopyParsedBlock, *codeBlockFor(specializationKind)));
     493        result->setAlternative(alternative);
     494        return result.release();
     495    }
     496
     497    VM* vm = scope->vm();
     498    JSGlobalObject* globalObject = scope->globalObject();
     499    ParserError error;
     500    DebuggerMode debuggerMode = globalObject->hasDebugger() ? DebuggerOn : DebuggerOff;
     501    ProfilerMode profilerMode = globalObject->hasProfiler() ? ProfilerOn : ProfilerOff;
     502    UnlinkedFunctionCodeBlock* unlinkedCodeBlock = m_unlinkedExecutable->codeBlockFor(*vm, m_source, specializationKind, debuggerMode, profilerMode, error);
     503    recordParse(m_unlinkedExecutable->features(), m_unlinkedExecutable->hasCapturedVariables(), lineNo(), lastLine(), startColumn());
     504
     505    if (!unlinkedCodeBlock) {
     506        exception = vm->throwException(globalObject->globalExec(), error.toErrorObject(globalObject, m_source));
     507        return 0;
     508    }
     509
     510    SourceProvider* provider = source().provider();
     511    unsigned sourceOffset = source().startOffset();
     512    unsigned startColumn = source().startColumn();
     513
     514    return adoptRef(new FunctionCodeBlock(this, unlinkedCodeBlock, scope, provider, sourceOffset, startColumn));
     515}
     516
     517
     518JSObject* FunctionExecutable::compileForCallInternal(ExecState* exec, JSScope* scope, JITCode::JITType jitType, CompilationResult* result, unsigned bytecodeIndex)
     519{
     520    SamplingRegion samplingRegion(samplingDescription(jitType));
     521   
     522    if (result)
     523        *result = CompilationFailed;
     524   
     525    ASSERT((jitType == JITCode::bottomTierJIT()) == !m_codeBlockForCall);
     526    JSObject* exception = 0;
     527   
     528    RefPtr<FunctionCodeBlock> newCodeBlock = produceCodeBlockFor(scope, CodeForCall, exception);
     529    if (!newCodeBlock)
     530        return exception;
     531   
     532    CompilationResult theResult = prepareFunctionForExecution(
     533        exec, m_codeBlockForCall, newCodeBlock.get(), m_jitCodeForCall,
     534        m_jitCodeForCallWithArityCheck, m_numParametersForCall, jitType,
     535        bytecodeIndex, CodeForCall);
     536    if (result)
     537        *result = theResult;
     538    return 0;
     539}
     540
     541#if ENABLE(DFG_JIT)
     542CompilationResult FunctionExecutable::replaceWithDeferredOptimizedCodeForCall(PassRefPtr<DFG::Plan> plan)
     543{
     544    return JSC::replaceWithDeferredOptimizedCode(
     545        plan, m_codeBlockForCall, m_jitCodeForCall, &m_jitCodeForCallWithArityCheck,
     546        &m_numParametersForCall);
     547}
     548#endif // ENABLE(DFG_JIT)
     549
     550JSObject* FunctionExecutable::compileForConstructInternal(ExecState* exec, JSScope* scope, JITCode::JITType jitType, CompilationResult* result, unsigned bytecodeIndex)
     551{
     552    SamplingRegion samplingRegion(samplingDescription(jitType));
     553   
     554    if (result)
     555        *result = CompilationFailed;
     556   
     557    ASSERT((jitType == JITCode::bottomTierJIT()) == !m_codeBlockForConstruct);
     558    JSObject* exception = 0;
     559    RefPtr<FunctionCodeBlock> newCodeBlock = produceCodeBlockFor(scope, CodeForConstruct, exception);
     560    if (!newCodeBlock)
     561        return exception;
     562
     563    CompilationResult theResult = prepareFunctionForExecution(
     564        exec, m_codeBlockForConstruct, newCodeBlock.get(), m_jitCodeForConstruct,
     565        m_jitCodeForConstructWithArityCheck, m_numParametersForConstruct, jitType,
     566        bytecodeIndex, CodeForConstruct);
     567    if (result)
     568        *result = theResult;
     569
     570    return 0;
     571}
     572
     573#if ENABLE(DFG_JIT)
     574CompilationResult FunctionExecutable::replaceWithDeferredOptimizedCodeForConstruct(PassRefPtr<DFG::Plan> plan)
     575{
     576    return JSC::replaceWithDeferredOptimizedCode(
     577        plan, m_codeBlockForConstruct, m_jitCodeForConstruct,
     578        &m_jitCodeForConstructWithArityCheck, &m_numParametersForConstruct);
     579}
     580#endif // ENABLE(DFG_JIT)
    519581
    520582#if ENABLE(JIT)
  • trunk/Source/JavaScriptCore/runtime/Executable.h

    r154804 r154814  
    162162    }
    163163       
     164    bool hasJITCodeForCall() const
     165    {
     166        return m_numParametersForCall >= 0;
     167    }
     168       
     169    bool hasJITCodeForConstruct() const
     170    {
     171        return m_numParametersForConstruct >= 0;
     172    }
     173       
     174    bool hasJITCodeFor(CodeSpecializationKind kind) const
     175    {
     176        if (kind == CodeForCall)
     177            return hasJITCodeForCall();
     178        ASSERT(kind == CodeForConstruct);
     179        return hasJITCodeForConstruct();
     180    }
     181
    164182    static ptrdiff_t offsetOfJITCodeWithArityCheckFor(CodeSpecializationKind kind)
    165183    {
     
    178196    }
    179197#endif // ENABLE(JIT)
    180 
    181     bool hasJITCodeForCall() const
    182     {
    183         return m_numParametersForCall >= 0;
    184     }
    185        
    186     bool hasJITCodeForConstruct() const
    187     {
    188         return m_numParametersForConstruct >= 0;
    189     }
    190        
    191     bool hasJITCodeFor(CodeSpecializationKind kind) const
    192     {
    193         if (kind == CodeForCall)
    194             return hasJITCodeForCall();
    195         ASSERT(kind == CodeForConstruct);
    196         return hasJITCodeForConstruct();
    197     }
    198198
    199199    // Intrinsics are only for calls, currently.
     
    245245#endif
    246246    }
    247    
    248247#endif // ENABLE(JIT || ENABLE(LLINT_C_LOOP)
    249248
     
    404403    }
    405404
    406     void installCode(CodeBlock*);
    407     PassRefPtr<CodeBlock> newCodeBlockFor(CodeSpecializationKind, JSScope*, JSObject*& exception);
    408     PassRefPtr<CodeBlock> newReplacementCodeBlockFor(CodeSpecializationKind);
    409    
    410     JSObject* prepareForExecution(ExecState* exec, JSScope* scope, CodeSpecializationKind kind)
    411     {
    412         if (hasJITCodeFor(kind))
    413             return 0;
    414         return prepareForExecutionImpl(exec, scope, kind);
    415     }
    416 
    417 private:
    418     JSObject* prepareForExecutionImpl(ExecState*, JSScope*, CodeSpecializationKind);
    419 
    420405protected:
    421406    void finishCreation(VM& vm)
     
    446431    static void destroy(JSCell*);
    447432
     433    JSObject* compile(ExecState* exec, JSScope* scope)
     434    {
     435        RELEASE_ASSERT(exec->vm().dynamicGlobalObject);
     436        JSObject* error = 0;
     437        if (!m_evalCodeBlock)
     438            error = compileInternal(exec, scope, JITCode::bottomTierJIT());
     439        ASSERT(!error == !!m_evalCodeBlock);
     440        return error;
     441    }
     442       
     443#if ENABLE(DFG_JIT)
     444    JSObject* compileOptimized(ExecState*, JSScope*, CompilationResult&, unsigned bytecodeIndex);
     445    CompilationResult replaceWithDeferredOptimizedCode(PassRefPtr<DFG::Plan>);
     446#endif // ENABLE(DFG_JIT)
     447       
    448448#if ENABLE(JIT)
    449449    void jettisonOptimizedCode(VM&);
     450    CompilationResult jitCompile(ExecState*);
    450451#endif
    451452
     
    481482
    482483private:
    483     friend class ScriptExecutable;
    484484    static const unsigned StructureFlags = OverridesVisitChildren | ScriptExecutable::StructureFlags;
    485485    EvalExecutable(ExecState*, const SourceCode&, bool);
    486486
     487    JSObject* compileInternal(ExecState*, JSScope*, JITCode::JITType, CompilationResult* = 0, unsigned bytecodeIndex = UINT_MAX);
    487488    static void visitChildren(JSCell*, SlotVisitor&);
    488489
     
    508509    static void destroy(JSCell*);
    509510
     511    JSObject* compile(ExecState* exec, JSScope* scope)
     512    {
     513        RELEASE_ASSERT(exec->vm().dynamicGlobalObject);
     514        JSObject* error = 0;
     515        if (!m_programCodeBlock)
     516            error = compileInternal(exec, scope, JITCode::bottomTierJIT());
     517        ASSERT(!error == !!m_programCodeBlock);
     518        return error;
     519    }
     520
     521#if ENABLE(DFG_JIT)
     522    JSObject* compileOptimized(ExecState*, JSScope*, CompilationResult&, unsigned bytecodeIndex);
     523    CompilationResult replaceWithDeferredOptimizedCode(PassRefPtr<DFG::Plan>);
     524#endif // ENABLE(DFG_JIT)
     525       
    510526#if ENABLE(JIT)
    511527    void jettisonOptimizedCode(VM&);
     528    CompilationResult jitCompile(ExecState*);
    512529#endif
    513530
     
    541558
    542559private:
    543     friend class ScriptExecutable;
    544    
    545560    static const unsigned StructureFlags = OverridesVisitChildren | ScriptExecutable::StructureFlags;
    546561
    547562    ProgramExecutable(ExecState*, const SourceCode&);
    548563
     564    JSObject* compileInternal(ExecState*, JSScope*, JITCode::JITType, CompilationResult* = 0, unsigned bytecodeIndex = UINT_MAX);
    549565    static void visitChildren(JSCell*, SlotVisitor&);
    550566
     
    585601    }
    586602       
     603    PassRefPtr<FunctionCodeBlock> produceCodeBlockFor(JSScope*, CodeSpecializationKind, JSObject*& exception);
     604
     605    JSObject* compileForCall(ExecState* exec, JSScope* scope)
     606    {
     607        RELEASE_ASSERT(exec->vm().dynamicGlobalObject);
     608        JSObject* error = 0;
     609        if (!m_codeBlockForCall)
     610            error = compileForCallInternal(exec, scope, JITCode::bottomTierJIT());
     611        ASSERT(!error == !!m_codeBlockForCall);
     612        return error;
     613    }
     614
     615#if ENABLE(DFG_JIT)
     616    JSObject* compileOptimizedForCall(ExecState*, JSScope*, CompilationResult&, unsigned bytecodeIndex);
     617    CompilationResult replaceWithDeferredOptimizedCodeForCall(PassRefPtr<DFG::Plan>);
     618#endif // ENABLE(DFG_JIT)
     619       
    587620#if ENABLE(JIT)
    588621    void jettisonOptimizedCodeForCall(VM&);
     622    CompilationResult jitCompileForCall(ExecState*);
    589623#endif
    590624
     
    600634    }
    601635
     636    JSObject* compileForConstruct(ExecState* exec, JSScope* scope)
     637    {
     638        RELEASE_ASSERT(exec->vm().dynamicGlobalObject);
     639        JSObject* error = 0;
     640        if (!m_codeBlockForConstruct)
     641            error = compileForConstructInternal(exec, scope, JITCode::bottomTierJIT());
     642        ASSERT(!error == !!m_codeBlockForConstruct);
     643        return error;
     644    }
     645
     646#if ENABLE(DFG_JIT)
     647    JSObject* compileOptimizedForConstruct(ExecState*, JSScope*, CompilationResult&, unsigned bytecodeIndex);
     648    CompilationResult replaceWithDeferredOptimizedCodeForConstruct(PassRefPtr<DFG::Plan>);
     649#endif // ENABLE(DFG_JIT)
     650       
    602651#if ENABLE(JIT)
    603652    void jettisonOptimizedCodeForConstruct(VM&);
     653    CompilationResult jitCompileForConstruct(ExecState*);
    604654#endif
    605655
     
    615665    }
    616666       
     667    JSObject* compileFor(ExecState* exec, JSScope* scope, CodeSpecializationKind kind)
     668    {
     669        ASSERT(exec->callee());
     670        ASSERT(exec->callee()->inherits(JSFunction::info()));
     671        ASSERT(jsCast<JSFunction*>(exec->callee())->jsExecutable() == this);
     672
     673        if (kind == CodeForCall)
     674            return compileForCall(exec, scope);
     675        ASSERT(kind == CodeForConstruct);
     676        return compileForConstruct(exec, scope);
     677    }
     678       
     679#if ENABLE(DFG_JIT)
     680    JSObject* compileOptimizedFor(ExecState* exec, JSScope* scope, CompilationResult& result, unsigned bytecodeIndex, CodeSpecializationKind kind)
     681    {
     682        ASSERT(exec->callee());
     683        ASSERT(exec->callee()->inherits(JSFunction::info()));
     684        ASSERT(jsCast<JSFunction*>(exec->callee())->jsExecutable() == this);
     685           
     686        if (kind == CodeForCall)
     687            return compileOptimizedForCall(exec, scope, result, bytecodeIndex);
     688        ASSERT(kind == CodeForConstruct);
     689        return compileOptimizedForConstruct(exec, scope, result, bytecodeIndex);
     690    }
     691       
     692    CompilationResult replaceWithDeferredOptimizedCodeFor(PassRefPtr<DFG::Plan> plan, CodeSpecializationKind kind)
     693    {
     694        if (kind == CodeForCall)
     695            return replaceWithDeferredOptimizedCodeForCall(plan);
     696        return replaceWithDeferredOptimizedCodeForConstruct(plan);
     697    }
     698#endif // ENABLE(DFG_JIT)
     699
    617700#if ENABLE(JIT)
    618701    void jettisonOptimizedCodeFor(VM& vm, CodeSpecializationKind kind)
     
    625708        }
    626709    }
     710       
     711    CompilationResult jitCompileFor(ExecState* exec, CodeSpecializationKind kind)
     712    {
     713        if (kind == CodeForCall)
     714            return jitCompileForCall(exec);
     715        ASSERT(kind == CodeForConstruct);
     716        return jitCompileForConstruct(exec);
     717    }
    627718#endif
    628719       
     
    674765    FunctionExecutable(VM&, const SourceCode&, UnlinkedFunctionExecutable*, unsigned firstLine, unsigned lastLine, unsigned startColumn);
    675766
     767    JSObject* compileForCallInternal(ExecState*, JSScope*, JITCode::JITType, CompilationResult* = 0, unsigned bytecodeIndex = UINT_MAX);
     768    JSObject* compileForConstructInternal(ExecState*, JSScope*, JITCode::JITType, CompilationResult* = 0, unsigned bytecodeIndex = UINT_MAX);
     769       
    676770    RefPtr<FunctionCodeBlock>& codeBlockFor(CodeSpecializationKind kind)
    677771    {
     
    692786        return false;
    693787    }
    694 
    695     friend class ScriptExecutable;
    696788
    697789    static const unsigned StructureFlags = OverridesVisitChildren | ScriptExecutable::StructureFlags;
Note: See TracChangeset for help on using the changeset viewer.