Add "noInline" to $vm
authormsaboff@apple.com <msaboff@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 4 Jan 2018 00:55:41 +0000 (00:55 +0000)
committermsaboff@apple.com <msaboff@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 4 Jan 2018 00:55:41 +0000 (00:55 +0000)
https://bugs.webkit.org/show_bug.cgi?id=181265

Reviewed by Mark Lam.

This would be useful for web based tests.

* tools/JSDollarVM.cpp:
(JSC::getExecutableForFunction):
(JSC::functionNoInline):
(JSC::JSDollarVM::finishCreation):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@226384 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/tools/JSDollarVM.cpp

index 4f87717..1db3c36 100644 (file)
@@ -1,5 +1,19 @@
 2018-01-03  Michael Saboff  <msaboff@apple.com>
 
+        Add "noInline" to $vm
+        https://bugs.webkit.org/show_bug.cgi?id=181265
+
+        Reviewed by Mark Lam.
+
+        This would be useful for web based tests.
+
+        * tools/JSDollarVM.cpp:
+        (JSC::getExecutableForFunction):
+        (JSC::functionNoInline):
+        (JSC::JSDollarVM::finishCreation):
+
+2018-01-03  Michael Saboff  <msaboff@apple.com>
+
         Remove unnecessary flushing of Butterfly pointer in functionCpuClflush()
         https://bugs.webkit.org/show_bug.cgi?id=181263
 
index 6bb92f1..da96657 100644 (file)
@@ -1159,6 +1159,22 @@ private:
     mutable JITCode::JITType m_jitType;
 };
 
+static FunctionExecutable* getExecutableForFunction(JSValue theFunctionValue)
+{
+    if (!theFunctionValue.isCell())
+        return nullptr;
+    
+    VM& vm = *theFunctionValue.asCell()->vm();
+    JSFunction* theFunction = jsDynamicCast<JSFunction*>(vm, theFunctionValue);
+    if (!theFunction)
+        return nullptr;
+    
+    FunctionExecutable* executable = jsDynamicCast<FunctionExecutable*>(vm,
+        theFunction->executable());
+
+    return executable;
+}
+
 // Returns true if the current frame is a LLInt frame.
 // Usage: isLLInt = $vm.llintTrue()
 static EncodedJSValue JSC_HOST_CALL functionLLintTrue(ExecState* exec)
@@ -1181,6 +1197,23 @@ static EncodedJSValue JSC_HOST_CALL functionJITTrue(ExecState* exec)
     return JSValue::encode(jsBoolean(functor.jitType() == JITCode::BaselineJIT));
 }
 
+// Set that the argument function should not be inlined.
+// Usage:
+// function f() { };
+// $vm.noInline(f);
+static EncodedJSValue JSC_HOST_CALL functionNoInline(ExecState* exec)
+{
+    if (exec->argumentCount() < 1)
+        return JSValue::encode(jsUndefined());
+    
+    JSValue theFunctionValue = exec->uncheckedArgument(0);
+
+    if (FunctionExecutable* executable = getExecutableForFunction(theFunctionValue))
+        executable->setNeverInline(true);
+    
+    return JSValue::encode(jsUndefined());
+}
+
 // Runs a full GC synchronously.
 // Usage: $vm.gc()
 static EncodedJSValue JSC_HOST_CALL functionGC(ExecState* exec)
@@ -1736,6 +1769,8 @@ void JSDollarVM::finishCreation(VM& vm)
     addFunction(vm, "llintTrue", functionLLintTrue, 0);
     addFunction(vm, "jitTrue", functionJITTrue, 0);
 
+    addFunction(vm, "noInline", functionNoInline, 1);
+
     addFunction(vm, "gc", functionGC, 0);
     addFunction(vm, "edenGC", functionEdenGC, 0);