Bug 909997 - Add JS compiler options at runtime to expand differential testing. r=nbp
☠☠ backed out by a88f40be25e7 ☠ ☠
authormasaya iseki <iseki.m.aa@gmail.com>
Thu, 17 Oct 2013 14:37:57 -0400
changeset 165914 79a1f60d83dfe343308ab19d491a22d9f4d68078
parent 165913 899981761c7dbdaeb65e590fec729241ec0e5721
child 165915 fa7709266585498718027f85d0a299df47af58ec
push id428
push userbbajaj@mozilla.com
push dateTue, 28 Jan 2014 00:16:25 +0000
treeherdermozilla-release@cd72a7ff3a75 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnbp
bugs909997
milestone27.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 909997 - Add JS compiler options at runtime to expand differential testing. r=nbp
js/src/jit-test/tests/ion/bug909997.js
js/src/jsapi.cpp
js/src/jsapi.h
new file mode 100644
--- /dev/null
+++ b/js/src/jit-test/tests/ion/bug909997.js
@@ -0,0 +1,28 @@
+var wait = 100;
+
+var method_A = function() {
+    for (var t = 0; t < wait; ++t) {}
+}
+
+var method_B = function() {
+    for (var t = 0; t < wait; ++t) {}
+}
+
+var method_C = function() {
+    for (var t = 0; t < wait; ++t) {}
+}
+
+var method_D = function() {
+    for (var t = 0; t < wait; ++t) {}
+}
+
+var func = [method_A, method_B, method_C, method_D]
+var opts = ["baseline.enable", "ion.enable"];
+
+for (var n = 0; n < opts.length; ++n) {
+    for (var m = 0; m < 2; ++m) {
+        setJitCompilerOption(opts[n], m & 1);
+        for (var i = 0; i < 1001; ++i)
+            func[n*2+m]();
+    }
+}
\ No newline at end of file
--- a/js/src/jsapi.cpp
+++ b/js/src/jsapi.cpp
@@ -1019,16 +1019,24 @@ JS_GetOptions(JSContext *cx)
 
 JS_PUBLIC_API(uint32_t)
 JS_SetOptions(JSContext *cx, uint32_t options)
 {
     return SetOptionsCommon(cx, options);
 }
 
 JS_PUBLIC_API(uint32_t)
+JS_ResetOptions(JSContext *cx, uint32_t options)
+{
+    unsigned oldopts = cx->options();
+    unsigned newopts = oldopts & ~options;
+    return SetOptionsCommon(cx, newopts);
+}
+
+JS_PUBLIC_API(uint32_t)
 JS_ToggleOptions(JSContext *cx, uint32_t options)
 {
     unsigned oldopts = GetOptionsCommon(cx);
     unsigned newopts = oldopts ^ options;
     return SetOptionsCommon(cx, newopts);
 }
 
 JS_PUBLIC_API(JS::ContextOptions &)
@@ -6080,17 +6088,34 @@ JS_SetGlobalJitCompilerOption(JSContext 
         break;
       case JSJITCOMPILER_ION_USECOUNT_TRIGGER:
         if (value == uint32_t(-1))
             value = defaultValues.usesBeforeCompile;
         jit::js_IonOptions.usesBeforeCompile = value;
         if (value == 0)
             jit::js_IonOptions.setEagerCompilation();
         break;
-
+      case JSJITCOMPILER_ION_ENABLE:
+        if (value == 1) {
+            JS_SetOptions(cx, JSOPTION_BASELINE | JSOPTION_ION);
+            IonSpew(js::jit::IonSpew_Scripts, "Enable ion");
+        } else if (value == 0) {
+            JS_ResetOptions(cx, JSOPTION_BASELINE | JSOPTION_ION);
+            IonSpew(js::jit::IonSpew_Scripts, "Disable ion");
+        }
+        break;
+      case JSJITCOMPILER_BASELINE_ENABLE:
+        if (value == 1) {
+            JS_SetOptions(cx, JSOPTION_BASELINE);
+            IonSpew(js::jit::IonSpew_BaselineScripts, "Enable baseline");
+        } else if (value == 0) {
+            JS_ResetOptions(cx, JSOPTION_BASELINE);
+            IonSpew(js::jit::IonSpew_BaselineScripts, "Disable baseline");
+        }
+        break;
       default:
         break;
     }
 #endif
 }
 
 /************************************************************************/
 
--- a/js/src/jsapi.h
+++ b/js/src/jsapi.h
@@ -4421,17 +4421,19 @@ JS_ScheduleGC(JSContext *cx, uint32_t co
 extern JS_PUBLIC_API(void)
 JS_SetParallelParsingEnabled(JSContext *cx, bool enabled);
 
 extern JS_PUBLIC_API(void)
 JS_SetParallelIonCompilationEnabled(JSContext *cx, bool enabled);
 
 #define JIT_COMPILER_OPTIONS(Register)                             \
   Register(BASELINE_USECOUNT_TRIGGER, "baseline.usecount.trigger") \
-  Register(ION_USECOUNT_TRIGGER, "ion.usecount.trigger")
+  Register(ION_USECOUNT_TRIGGER, "ion.usecount.trigger")           \
+  Register(ION_ENABLE, "ion.enable")                               \
+  Register(BASELINE_ENABLE, "baseline.enable")
 
 typedef enum JSJitCompilerOption {
 #define JIT_COMPILER_DECLARE(key, str) \
     JSJITCOMPILER_ ## key,
 
     JIT_COMPILER_OPTIONS(JIT_COMPILER_DECLARE)
 #undef JIT_COMPILER_DECLARE