Title: [189086] trunk/Source/_javascript_Core
Revision
189086
Author
[email protected]
Date
2015-08-27 22:59:44 -0700 (Thu, 27 Aug 2015)

Log Message

Add noDFG() to jsc to prevent DFG compilation of a specified function.
https://bugs.webkit.org/show_bug.cgi?id=148559

Reviewed by Geoffrey Garen and Saam Barati.

* API/JSCTestRunnerUtils.cpp:
(JSC::setNeverInline):
(JSC::setNeverOptimize):
* API/JSCTestRunnerUtils.h:
* bytecode/CodeBlock.cpp:
(JSC::CodeBlock::dumpAssumingJITType):
* dfg/DFGCapabilities.cpp:
(JSC::DFG::mightCompileEval):
(JSC::DFG::mightCompileProgram):
(JSC::DFG::mightCompileFunctionForCall):
(JSC::DFG::mightCompileFunctionForConstruct):
(JSC::DFG::mightInlineFunctionForCall):
* jsc.cpp:
(GlobalObject::finishCreation):
(functionNoDFG):
* runtime/Executable.h:
(JSC::ScriptExecutable::ecmaMode):
(JSC::ScriptExecutable::setNeverInline):
(JSC::ScriptExecutable::setNeverOptimize):
(JSC::ScriptExecutable::setDidTryToEnterInLoop):
(JSC::ScriptExecutable::neverInline):
(JSC::ScriptExecutable::neverOptimize):
(JSC::ScriptExecutable::didTryToEnterInLoop):
(JSC::ScriptExecutable::isInliningCandidate):
(JSC::ScriptExecutable::isOkToOptimize):
(JSC::ScriptExecutable::addressOfDidTryToEnterInLoop):
* runtime/TestRunnerUtils.cpp:
(JSC::setNeverInline):
(JSC::setNeverOptimize):
(JSC::optimizeNextInvocation):
* runtime/TestRunnerUtils.h:

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/API/JSCTestRunnerUtils.cpp (189085 => 189086)


--- trunk/Source/_javascript_Core/API/JSCTestRunnerUtils.cpp	2015-08-28 05:19:34 UTC (rev 189085)
+++ trunk/Source/_javascript_Core/API/JSCTestRunnerUtils.cpp	2015-08-28 05:59:44 UTC (rev 189086)
@@ -46,5 +46,12 @@
     return toRef(exec, setNeverInline(toJS(exec, theFunctionValueRef)));
 }
 
+JSValueRef setNeverOptimize(JSContextRef context, JSValueRef theFunctionValueRef)
+{
+    ExecState* exec= toJS(context);
+    JSLockHolder holder(exec);
+    return toRef(exec, setNeverOptimize(toJS(exec, theFunctionValueRef)));
+}
+
 } // namespace JSC
 

Modified: trunk/Source/_javascript_Core/API/JSCTestRunnerUtils.h (189085 => 189086)


--- trunk/Source/_javascript_Core/API/JSCTestRunnerUtils.h	2015-08-28 05:19:34 UTC (rev 189085)
+++ trunk/Source/_javascript_Core/API/JSCTestRunnerUtils.h	2015-08-28 05:59:44 UTC (rev 189086)
@@ -33,6 +33,7 @@
 
 JS_EXPORT_PRIVATE JSValueRef numberOfDFGCompiles(JSContextRef, JSValueRef theFunction);
 JS_EXPORT_PRIVATE JSValueRef setNeverInline(JSContextRef, JSValueRef theFunction);
+JS_EXPORT_PRIVATE JSValueRef setNeverOptimize(JSContextRef, JSValueRef theFunction);
 
 } // namespace JSC
 

Modified: trunk/Source/_javascript_Core/ChangeLog (189085 => 189086)


--- trunk/Source/_javascript_Core/ChangeLog	2015-08-28 05:19:34 UTC (rev 189085)
+++ trunk/Source/_javascript_Core/ChangeLog	2015-08-28 05:59:44 UTC (rev 189086)
@@ -1,3 +1,42 @@
+2015-08-27  Mark Lam  <[email protected]>
+
+        Add noDFG() to jsc to prevent DFG compilation of a specified function.
+        https://bugs.webkit.org/show_bug.cgi?id=148559
+
+        Reviewed by Geoffrey Garen and Saam Barati.
+
+        * API/JSCTestRunnerUtils.cpp:
+        (JSC::setNeverInline):
+        (JSC::setNeverOptimize):
+        * API/JSCTestRunnerUtils.h:
+        * bytecode/CodeBlock.cpp:
+        (JSC::CodeBlock::dumpAssumingJITType):
+        * dfg/DFGCapabilities.cpp:
+        (JSC::DFG::mightCompileEval):
+        (JSC::DFG::mightCompileProgram):
+        (JSC::DFG::mightCompileFunctionForCall):
+        (JSC::DFG::mightCompileFunctionForConstruct):
+        (JSC::DFG::mightInlineFunctionForCall):
+        * jsc.cpp:
+        (GlobalObject::finishCreation):
+        (functionNoDFG):
+        * runtime/Executable.h:
+        (JSC::ScriptExecutable::ecmaMode):
+        (JSC::ScriptExecutable::setNeverInline):
+        (JSC::ScriptExecutable::setNeverOptimize):
+        (JSC::ScriptExecutable::setDidTryToEnterInLoop):
+        (JSC::ScriptExecutable::neverInline):
+        (JSC::ScriptExecutable::neverOptimize):
+        (JSC::ScriptExecutable::didTryToEnterInLoop):
+        (JSC::ScriptExecutable::isInliningCandidate):
+        (JSC::ScriptExecutable::isOkToOptimize):
+        (JSC::ScriptExecutable::addressOfDidTryToEnterInLoop):
+        * runtime/TestRunnerUtils.cpp:
+        (JSC::setNeverInline):
+        (JSC::setNeverOptimize):
+        (JSC::optimizeNextInvocation):
+        * runtime/TestRunnerUtils.h:
+
 2015-08-27  Commit Queue  <[email protected]>
 
         Unreviewed, rolling out r189064 and r189084.

Modified: trunk/Source/_javascript_Core/bytecode/CodeBlock.cpp (189085 => 189086)


--- trunk/Source/_javascript_Core/bytecode/CodeBlock.cpp	2015-08-28 05:19:34 UTC (rev 189085)
+++ trunk/Source/_javascript_Core/bytecode/CodeBlock.cpp	2015-08-28 05:59:44 UTC (rev 189086)
@@ -157,6 +157,8 @@
         out.print(" (ShouldAlwaysBeInlined)");
     if (ownerExecutable()->neverInline())
         out.print(" (NeverInline)");
+    if (ownerExecutable()->neverOptimize())
+        out.print(" (NeverOptimize)");
     if (ownerExecutable()->didTryToEnterInLoop())
         out.print(" (DidTryToEnterInLoop)");
     if (ownerExecutable()->isStrictMode())

Modified: trunk/Source/_javascript_Core/dfg/DFGCapabilities.cpp (189085 => 189086)


--- trunk/Source/_javascript_Core/dfg/DFGCapabilities.cpp	2015-08-28 05:19:34 UTC (rev 189085)
+++ trunk/Source/_javascript_Core/dfg/DFGCapabilities.cpp	2015-08-28 05:59:44 UTC (rev 189086)
@@ -50,22 +50,26 @@
 bool mightCompileEval(CodeBlock* codeBlock)
 {
     return isSupported()
-        && codeBlock->instructionCount() <= Options::maximumOptimizationCandidateInstructionCount();
+        && codeBlock->instructionCount() <= Options::maximumOptimizationCandidateInstructionCount()
+        && codeBlock->ownerExecutable()->isOkToOptimize();
 }
 bool mightCompileProgram(CodeBlock* codeBlock)
 {
     return isSupported()
-        && codeBlock->instructionCount() <= Options::maximumOptimizationCandidateInstructionCount();
+        && codeBlock->instructionCount() <= Options::maximumOptimizationCandidateInstructionCount()
+        && codeBlock->ownerExecutable()->isOkToOptimize();
 }
 bool mightCompileFunctionForCall(CodeBlock* codeBlock)
 {
     return isSupported()
-        && codeBlock->instructionCount() <= Options::maximumOptimizationCandidateInstructionCount();
+        && codeBlock->instructionCount() <= Options::maximumOptimizationCandidateInstructionCount()
+        && codeBlock->ownerExecutable()->isOkToOptimize();
 }
 bool mightCompileFunctionForConstruct(CodeBlock* codeBlock)
 {
     return isSupported()
-        && codeBlock->instructionCount() <= Options::maximumOptimizationCandidateInstructionCount();
+        && codeBlock->instructionCount() <= Options::maximumOptimizationCandidateInstructionCount()
+        && codeBlock->ownerExecutable()->isOkToOptimize();
 }
 
 bool mightInlineFunctionForCall(CodeBlock* codeBlock)

Modified: trunk/Source/_javascript_Core/jsc.cpp (189085 => 189086)


--- trunk/Source/_javascript_Core/jsc.cpp	2015-08-28 05:19:34 UTC (rev 189085)
+++ trunk/Source/_javascript_Core/jsc.cpp	2015-08-28 05:59:44 UTC (rev 189086)
@@ -473,6 +473,7 @@
 static EncodedJSValue JSC_HOST_CALL functionReadline(ExecState*);
 static EncodedJSValue JSC_HOST_CALL functionPreciseTime(ExecState*);
 static EncodedJSValue JSC_HOST_CALL functionNeverInlineFunction(ExecState*);
+static EncodedJSValue JSC_HOST_CALL functionNoDFG(ExecState*);
 static EncodedJSValue JSC_HOST_CALL functionOptimizeNextInvocation(ExecState*);
 static EncodedJSValue JSC_HOST_CALL functionNumberOfDFGCompiles(ExecState*);
 static EncodedJSValue JSC_HOST_CALL functionReoptimizationRetryCount(ExecState*);
@@ -631,6 +632,7 @@
         addFunction(vm, "preciseTime", functionPreciseTime, 0);
         addFunction(vm, "neverInlineFunction", functionNeverInlineFunction, 1);
         addFunction(vm, "noInline", functionNeverInlineFunction, 1);
+        addFunction(vm, "noDFG", functionNoDFG, 1);
         addFunction(vm, "numberOfDFGCompiles", functionNumberOfDFGCompiles, 1);
         addFunction(vm, "optimizeNextInvocation", functionOptimizeNextInvocation, 1);
         addFunction(vm, "reoptimizationRetryCount", functionReoptimizationRetryCount, 1);
@@ -1179,6 +1181,11 @@
     return JSValue::encode(setNeverInline(exec));
 }
 
+EncodedJSValue JSC_HOST_CALL functionNoDFG(ExecState* exec)
+{
+    return JSValue::encode(setNeverOptimize(exec));
+}
+
 EncodedJSValue JSC_HOST_CALL functionOptimizeNextInvocation(ExecState* exec)
 {
     return JSValue::encode(optimizeNextInvocation(exec));

Modified: trunk/Source/_javascript_Core/runtime/Executable.h (189085 => 189086)


--- trunk/Source/_javascript_Core/runtime/Executable.h	2015-08-28 05:19:34 UTC (rev 189085)
+++ trunk/Source/_javascript_Core/runtime/Executable.h	2015-08-28 05:59:44 UTC (rev 189086)
@@ -374,10 +374,13 @@
     ECMAMode ecmaMode() const { return isStrictMode() ? StrictMode : NotStrictMode; }
         
     void setNeverInline(bool value) { m_neverInline = value; }
+    void setNeverOptimize(bool value) { m_neverOptimize = value; }
     void setDidTryToEnterInLoop(bool value) { m_didTryToEnterInLoop = value; }
     bool neverInline() const { return m_neverInline; }
+    bool neverOptimize() const { return m_neverOptimize; }
     bool didTryToEnterInLoop() const { return m_didTryToEnterInLoop; }
     bool isInliningCandidate() const { return !neverInline(); }
+    bool isOkToOptimize() const { return !neverOptimize(); }
     
     bool* addressOfDidTryToEnterInLoop() { return &m_didTryToEnterInLoop; }
 
@@ -431,6 +434,7 @@
     CodeFeatures m_features;
     bool m_hasCapturedVariables;
     bool m_neverInline;
+    bool m_neverOptimize { false };
     bool m_didTryToEnterInLoop;
     int m_overrideLineNumber;
     int m_firstLine;

Modified: trunk/Source/_javascript_Core/runtime/TestRunnerUtils.cpp (189085 => 189086)


--- trunk/Source/_javascript_Core/runtime/TestRunnerUtils.cpp	2015-08-28 05:19:34 UTC (rev 189085)
+++ trunk/Source/_javascript_Core/runtime/TestRunnerUtils.cpp	2015-08-28 05:59:44 UTC (rev 189086)
@@ -83,6 +83,14 @@
     return jsUndefined();
 }
 
+JSValue setNeverOptimize(JSValue theFunctionValue)
+{
+    if (FunctionExecutable* executable = getExecutableForFunction(theFunctionValue))
+        executable->setNeverOptimize(true);
+    
+    return jsUndefined();
+}
+
 JSValue optimizeNextInvocation(JSValue theFunctionValue)
 {
 #if ENABLE(JIT)
@@ -109,6 +117,13 @@
     return setNeverInline(exec->uncheckedArgument(0));
 }
 
+JSValue setNeverOptimize(ExecState* exec)
+{
+    if (exec->argumentCount() < 1)
+        return jsUndefined();
+    return setNeverOptimize(exec->uncheckedArgument(0));
+}
+
 JSValue optimizeNextInvocation(ExecState* exec)
 {
     if (exec->argumentCount() < 1)

Modified: trunk/Source/_javascript_Core/runtime/TestRunnerUtils.h (189085 => 189086)


--- trunk/Source/_javascript_Core/runtime/TestRunnerUtils.h	2015-08-28 05:19:34 UTC (rev 189085)
+++ trunk/Source/_javascript_Core/runtime/TestRunnerUtils.h	2015-08-28 05:59:44 UTC (rev 189086)
@@ -38,10 +38,12 @@
 
 JS_EXPORT_PRIVATE JSValue numberOfDFGCompiles(JSValue function);
 JS_EXPORT_PRIVATE JSValue setNeverInline(JSValue function);
+JS_EXPORT_PRIVATE JSValue setNeverOptimize(JSValue function);
 JS_EXPORT_PRIVATE JSValue optimizeNextInvocation(JSValue function);
 
 JS_EXPORT_PRIVATE JSValue numberOfDFGCompiles(ExecState*);
 JS_EXPORT_PRIVATE JSValue setNeverInline(ExecState*);
+JS_EXPORT_PRIVATE JSValue setNeverOptimize(ExecState*);
 JS_EXPORT_PRIVATE JSValue optimizeNextInvocation(ExecState*);
 
 JS_EXPORT_PRIVATE unsigned numberOfExceptionFuzzChecks();
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to