Bug 945596 - Define getJitCompilerOption to confirm jit-compiler-options. r=nbp, r=h4writer

This commit is contained in:
masaya iseki 2014-01-06 10:03:41 -05:00
parent f9642f5ffd
commit 3cea2348be
4 changed files with 53 additions and 0 deletions

View File

@ -1127,6 +1127,30 @@ SetJitCompilerOption(JSContext *cx, unsigned argc, jsval *vp)
return true;
}
static bool
GetJitCompilerOptions(JSContext *cx, unsigned argc, jsval *vp)
{
RootedObject info(cx, JS_NewObject(cx, nullptr, nullptr, nullptr));
if (!info)
return false;
RootedValue value(cx);
#define JIT_COMPILER_MATCH(key, string) \
opt = JSJITCOMPILER_ ## key; \
value.setInt32(JS_GetGlobalJitCompilerOption(cx, opt)); \
if (!JS_SetProperty(cx, info, string, value)) \
return false;
JSJitCompilerOption opt = JSJITCOMPILER_NOT_AN_OPTION;
JIT_COMPILER_OPTIONS(JIT_COMPILER_MATCH);
#undef JIT_COMPILER_MATCH
*vp = ObjectValue(*info);
return true;
}
static bool
SetIonCheckGraphCoherency(JSContext *cx, unsigned argc, jsval *vp)
{
@ -1546,6 +1570,10 @@ static const JSFunctionSpecWithHelp TestingFunctions[] = {
" Returns whether asm.js compilation is currently available or whether it is disabled\n"
" (e.g., by the debugger)."),
JS_FN_HELP("getJitCompilerOptions", GetJitCompilerOptions, 0, 0,
"getCompilerOptions()",
"Return an object describing some of the JIT compiler options.\n"),
JS_FN_HELP("isAsmJSModule", IsAsmJSModule, 1, 0,
"isAsmJSModule(fn)",
" Returns whether the given value is a function containing \"use asm\" that has been\n"

View File

@ -21,6 +21,9 @@ var func = [method_A, method_B, method_C, method_D]
for (var n = 0; n < 4; ++n) {
setJitCompilerOption("baseline.enable", n & 1);
setJitCompilerOption("ion.enable", n & 2 ? 1: 0);
var opt = getJitCompilerOptions();
assertEq(opt["baseline.enable"], n & 1);
assertEq(opt["ion.enable"], n & 2 ? 1 : 0);
for (var i = 0; i < 1001; ++i)
func[n]();
}

View File

@ -6040,6 +6040,26 @@ JS_SetGlobalJitCompilerOption(JSContext *cx, JSJitCompilerOption opt, uint32_t v
#endif
}
JS_PUBLIC_API(int)
JS_GetGlobalJitCompilerOption(JSContext *cx, JSJitCompilerOption opt)
{
#ifdef JS_ION
switch (opt) {
case JSJITCOMPILER_BASELINE_USECOUNT_TRIGGER:
return jit::js_JitOptions.baselineUsesBeforeCompile;
case JSJITCOMPILER_ION_USECOUNT_TRIGGER:
return jit::js_JitOptions.forcedDefaultIonUsesBeforeCompile;
case JSJITCOMPILER_ION_ENABLE:
return JS::ContextOptionsRef(cx).ion();
case JSJITCOMPILER_BASELINE_ENABLE:
return JS::ContextOptionsRef(cx).baseline();
default:
break;
}
#endif
return 0;
}
/************************************************************************/
#if !defined(STATIC_EXPORTABLE_JS_API) && !defined(STATIC_JS_API) && defined(XP_WIN)

View File

@ -4557,6 +4557,8 @@ typedef enum JSJitCompilerOption {
extern JS_PUBLIC_API(void)
JS_SetGlobalJitCompilerOption(JSContext *cx, JSJitCompilerOption opt, uint32_t value);
extern JS_PUBLIC_API(int)
JS_GetGlobalJitCompilerOption(JSContext *cx, JSJitCompilerOption opt);
/*
* Convert a uint32_t index into a jsid.