Title: [164734] trunk/Source/_javascript_Core
Revision
164734
Author
mark....@apple.com
Date
2014-02-26 12:13:22 -0800 (Wed, 26 Feb 2014)

Log Message

Compilation policy management belongs in operationOptimize(), not the DFG Driver.
<https://webkit.org/b/129355>

Reviewed by Filip Pizlo.

By compilation policy, I mean the rules for determining whether to
compile, when to compile, when to attempt compilation again, etc.  The
few of these policy decisions that were previously being made in the
DFG driver are now moved to operationOptimize() where we keep the rest
of the policy logic.  Decisions that are based on the capabilities
supported by the DFG are moved to DFG capabiliityLevel().

I've run the following benchmarks:
1. the collection of jsc benchmarks on the jsc executable vs. its
   baseline.
2. Octane 2.0 in browser without the WebInspector.
3. Octane 2.0 in browser with the WebInspector open and a breakpoint
   set somewhere where it won't break.

In all of these, the results came out to be a wash as expected.

* dfg/DFGCapabilities.cpp:
(JSC::DFG::isSupported):
(JSC::DFG::mightCompileEval):
(JSC::DFG::mightCompileProgram):
(JSC::DFG::mightCompileFunctionForCall):
(JSC::DFG::mightCompileFunctionForConstruct):
(JSC::DFG::mightInlineFunctionForCall):
(JSC::DFG::mightInlineFunctionForClosureCall):
(JSC::DFG::mightInlineFunctionForConstruct):
* dfg/DFGCapabilities.h:
* dfg/DFGDriver.cpp:
(JSC::DFG::compileImpl):
* jit/JITOperations.cpp:

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (164733 => 164734)


--- trunk/Source/_javascript_Core/ChangeLog	2014-02-26 19:54:23 UTC (rev 164733)
+++ trunk/Source/_javascript_Core/ChangeLog	2014-02-26 20:13:22 UTC (rev 164734)
@@ -1,3 +1,40 @@
+2014-02-26  Mark Lam  <mark....@apple.com>
+
+        Compilation policy management belongs in operationOptimize(), not the DFG Driver.
+        <https://webkit.org/b/129355>
+
+        Reviewed by Filip Pizlo.
+
+        By compilation policy, I mean the rules for determining whether to
+        compile, when to compile, when to attempt compilation again, etc.  The
+        few of these policy decisions that were previously being made in the
+        DFG driver are now moved to operationOptimize() where we keep the rest
+        of the policy logic.  Decisions that are based on the capabilities
+        supported by the DFG are moved to DFG capabiliityLevel().
+
+        I've run the following benchmarks:
+        1. the collection of jsc benchmarks on the jsc executable vs. its
+           baseline.
+        2. Octane 2.0 in browser without the WebInspector.
+        3. Octane 2.0 in browser with the WebInspector open and a breakpoint
+           set somewhere where it won't break.
+
+        In all of these, the results came out to be a wash as expected.
+
+        * dfg/DFGCapabilities.cpp:
+        (JSC::DFG::isSupported):
+        (JSC::DFG::mightCompileEval):
+        (JSC::DFG::mightCompileProgram):
+        (JSC::DFG::mightCompileFunctionForCall):
+        (JSC::DFG::mightCompileFunctionForConstruct):
+        (JSC::DFG::mightInlineFunctionForCall):
+        (JSC::DFG::mightInlineFunctionForClosureCall):
+        (JSC::DFG::mightInlineFunctionForConstruct):
+        * dfg/DFGCapabilities.h:
+        * dfg/DFGDriver.cpp:
+        (JSC::DFG::compileImpl):
+        * jit/JITOperations.cpp:
+
 2014-02-26  Michael Saboff  <msab...@apple.com>
 
         Auto generate bytecode information for bytecode parser and LLInt

Modified: trunk/Source/_javascript_Core/dfg/DFGCapabilities.cpp (164733 => 164734)


--- trunk/Source/_javascript_Core/dfg/DFGCapabilities.cpp	2014-02-26 19:54:23 UTC (rev 164733)
+++ trunk/Source/_javascript_Core/dfg/DFGCapabilities.cpp	2014-02-26 20:13:22 UTC (rev 164734)
@@ -32,41 +32,56 @@
 #include "DFGCommon.h"
 #include "Interpreter.h"
 #include "JSCInlines.h"
+#include "Options.h"
 
 namespace JSC { namespace DFG {
 
+bool isSupported(CodeBlock* codeBlock)
+{
+    return Options::useDFGJIT()
+        && MacroAssembler::supportsFloatingPoint()
+        && Options::bytecodeRangeToDFGCompile().isInRange(codeBlock->instructionCount());
+}
+
 bool mightCompileEval(CodeBlock* codeBlock)
 {
-    return codeBlock->instructionCount() <= Options::maximumOptimizationCandidateInstructionCount();
+    return isSupported(codeBlock)
+        && codeBlock->instructionCount() <= Options::maximumOptimizationCandidateInstructionCount();
 }
 bool mightCompileProgram(CodeBlock* codeBlock)
 {
-    return codeBlock->instructionCount() <= Options::maximumOptimizationCandidateInstructionCount();
+    return isSupported(codeBlock)
+        && codeBlock->instructionCount() <= Options::maximumOptimizationCandidateInstructionCount();
 }
 bool mightCompileFunctionForCall(CodeBlock* codeBlock)
 {
-    return codeBlock->instructionCount() <= Options::maximumOptimizationCandidateInstructionCount();
+    return isSupported(codeBlock)
+        && codeBlock->instructionCount() <= Options::maximumOptimizationCandidateInstructionCount();
 }
 bool mightCompileFunctionForConstruct(CodeBlock* codeBlock)
 {
-    return codeBlock->instructionCount() <= Options::maximumOptimizationCandidateInstructionCount();
+    return isSupported(codeBlock)
+        && codeBlock->instructionCount() <= Options::maximumOptimizationCandidateInstructionCount();
 }
 
 bool mightInlineFunctionForCall(CodeBlock* codeBlock)
 {
-    return codeBlock->instructionCount() <= Options::maximumFunctionForCallInlineCandidateInstructionCount()
+    return isSupported(codeBlock) 
+        && codeBlock->instructionCount() <= Options::maximumFunctionForCallInlineCandidateInstructionCount()
         && !codeBlock->ownerExecutable()->needsActivation()
         && codeBlock->ownerExecutable()->isInliningCandidate();
 }
 bool mightInlineFunctionForClosureCall(CodeBlock* codeBlock)
 {
-    return codeBlock->instructionCount() <= Options::maximumFunctionForClosureCallInlineCandidateInstructionCount()
+    return isSupported(codeBlock) 
+        && codeBlock->instructionCount() <= Options::maximumFunctionForClosureCallInlineCandidateInstructionCount()
         && !codeBlock->ownerExecutable()->needsActivation()
         && codeBlock->ownerExecutable()->isInliningCandidate();
 }
 bool mightInlineFunctionForConstruct(CodeBlock* codeBlock)
 {
-    return codeBlock->instructionCount() <= Options::maximumFunctionForConstructInlineCandidateInstructionCount()
+    return isSupported(codeBlock) 
+        && codeBlock->instructionCount() <= Options::maximumFunctionForConstructInlineCandidateInstructionCount()
         && !codeBlock->ownerExecutable()->needsActivation()
         && codeBlock->ownerExecutable()->isInliningCandidate();
 }

Modified: trunk/Source/_javascript_Core/dfg/DFGCapabilities.h (164733 => 164734)


--- trunk/Source/_javascript_Core/dfg/DFGCapabilities.h	2014-02-26 19:54:23 UTC (rev 164733)
+++ trunk/Source/_javascript_Core/dfg/DFGCapabilities.h	2014-02-26 20:13:22 UTC (rev 164734)
@@ -39,6 +39,7 @@
 #if ENABLE(DFG_JIT)
 // Fast check functions; if they return true it is still necessary to
 // check opcodes.
+bool isSupported(CodeBlock*);
 bool mightCompileEval(CodeBlock*);
 bool mightCompileProgram(CodeBlock*);
 bool mightCompileFunctionForCall(CodeBlock*);

Modified: trunk/Source/_javascript_Core/dfg/DFGDriver.cpp (164733 => 164734)


--- trunk/Source/_javascript_Core/dfg/DFGDriver.cpp	2014-02-26 19:54:23 UTC (rev 164733)
+++ trunk/Source/_javascript_Core/dfg/DFGDriver.cpp	2014-02-26 20:13:22 UTC (rev 164734)
@@ -34,7 +34,6 @@
 #include "DFGPlan.h"
 #include "DFGThunks.h"
 #include "DFGWorklist.h"
-#include "Debugger.h"
 #include "JITCode.h"
 #include "JSCInlines.h"
 #include "Options.h"
@@ -69,19 +68,6 @@
     ASSERT(codeBlock->alternative()->jitType() == JITCode::BaselineJIT);
     ASSERT(!profiledDFGCodeBlock || profiledDFGCodeBlock->jitType() == JITCode::DFGJIT);
     
-    if (!Options::useDFGJIT() || !MacroAssembler::supportsFloatingPoint())
-        return CompilationFailed;
-
-    if (!Options::bytecodeRangeToDFGCompile().isInRange(codeBlock->instructionCount()))
-        return CompilationFailed;
-    
-    if (vm.enabledProfiler())
-        return CompilationInvalidated;
-
-    Debugger* debugger = codeBlock->globalObject()->debugger();
-    if (debugger && (debugger->isStepping() || codeBlock->baselineAlternative()->hasDebuggerRequests()))
-        return CompilationInvalidated;
-
     if (logCompilationChanges(mode))
         dataLog("DFG(Driver) compiling ", *codeBlock, " with ", mode, ", number of instructions = ", codeBlock->instructionCount(), "\n");
     

Modified: trunk/Source/_javascript_Core/jit/JITOperations.cpp (164733 => 164734)


--- trunk/Source/_javascript_Core/jit/JITOperations.cpp	2014-02-26 19:54:23 UTC (rev 164733)
+++ trunk/Source/_javascript_Core/jit/JITOperations.cpp	2014-02-26 20:13:22 UTC (rev 164734)
@@ -35,6 +35,7 @@
 #include "DFGOSREntry.h"
 #include "DFGThunks.h"
 #include "DFGWorklist.h"
+#include "Debugger.h"
 #include "Error.h"
 #include "ErrorHandlingScope.h"
 #include "GetterSetter.h"
@@ -1007,6 +1008,12 @@
 }
 
 #if ENABLE(DFG_JIT)
+static void updateAllPredictionsAndOptimizeAfterWarmUp(CodeBlock* codeBlock)
+{
+    codeBlock->updateAllPredictions();
+    codeBlock->optimizeAfterWarmUp();
+}
+
 SlowPathReturnType JIT_OPERATION operationOptimize(ExecState* exec, int32_t bytecodeIndex)
 {
     VM& vm = exec->vm();
@@ -1060,9 +1067,19 @@
         return encodeResult(0, 0);
     }
     
+    if (vm.enabledProfiler()) {
+        updateAllPredictionsAndOptimizeAfterWarmUp(codeBlock);
+        return encodeResult(0, 0);
+    }
+
+    Debugger* debugger = codeBlock->globalObject()->debugger();
+    if (debugger && (debugger->isStepping() || codeBlock->baselineAlternative()->hasDebuggerRequests())) {
+        updateAllPredictionsAndOptimizeAfterWarmUp(codeBlock);
+        return encodeResult(0, 0);
+    }
+
     if (codeBlock->m_shouldAlwaysBeInlined) {
-        codeBlock->updateAllPredictions();
-        codeBlock->optimizeAfterWarmUp();
+        updateAllPredictionsAndOptimizeAfterWarmUp(codeBlock);
         if (Options::verboseOSR())
             dataLog("Choosing not to optimize ", *codeBlock, " yet, because m_shouldAlwaysBeInlined == true.\n");
         return encodeResult(0, 0);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to