Bug 909997 - Add JS compiler options at runtime to expand differential testing. r=nbp

This commit is contained in:
masaya iseki 2013-10-17 14:37:57 -04:00
parent 3636dfe0e3
commit d9097f467a
3 changed files with 57 additions and 2 deletions

View File

@ -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]();
}
}

View File

@ -1023,6 +1023,14 @@ 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)
{
@ -6085,7 +6093,24 @@ JS_SetGlobalJitCompilerOption(JSContext *cx, JSJitCompilerOption opt, uint32_t v
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;
}

View File

@ -4426,7 +4426,9 @@ 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) \