Bug 880330 - Remove the old options API; r=bholley

This commit is contained in:
Eddy Bruel 2013-10-28 12:59:04 +01:00
parent 5f638b637c
commit 726f5c9f8b
3 changed files with 14 additions and 175 deletions

View File

@ -496,16 +496,15 @@ JavaScriptChild::AnswerCall(const ObjectId &objId, const nsTArray<JSParam> &argv
}
}
uint32_t oldOpts =
JS_SetOptions(cx, JS_GetOptions(cx) | JSOPTION_DONT_REPORT_UNCAUGHT);
RootedValue rval(cx);
bool success = JS::Call(cx, vals[1], vals[0], vals.length() - 2, vals.begin() + 2, &rval);
{
AutoSaveContextOptions asco(cx);
ContextOptionsRef(cx).setDontReportUncaught(true);
JS_SetOptions(cx, oldOpts);
if (!success)
return fail(cx, rs);
bool success = JS::Call(cx, vals[1], vals[0], vals.length() - 2, vals.begin() + 2, &rval);
if (!success)
return fail(cx, rs);
}
if (!toVariant(cx, rval, result))
return fail(cx, rs);

View File

@ -957,89 +957,6 @@ JS_StringToVersion(const char *string)
return JSVERSION_UNKNOWN;
}
static unsigned
GetOptionsCommon(JSContext *cx)
{
return (cx->options().extraWarnings() ? JSOPTION_EXTRA_WARNINGS : 0)
| (cx->options().werror() ? JSOPTION_WERROR : 0)
| (cx->options().varObjFix() ? JSOPTION_VAROBJFIX : 0)
| (cx->options().privateIsNSISupports() ? JSOPTION_PRIVATE_IS_NSISUPPORTS : 0)
| (cx->options().compileAndGo() ? JSOPTION_COMPILE_N_GO : 0)
| (cx->options().dontReportUncaught() ? JSOPTION_DONT_REPORT_UNCAUGHT : 0)
| (cx->options().noDefaultCompartmentObject() ? JSOPTION_NO_DEFAULT_COMPARTMENT_OBJECT : 0)
| (cx->options().noScriptRval() ? JSOPTION_NO_SCRIPT_RVAL : 0)
| (cx->options().baseline() ? JSOPTION_BASELINE : 0)
| (cx->options().typeInference() ? JSOPTION_TYPE_INFERENCE : 0)
| (cx->options().strictMode() ? JSOPTION_STRICT_MODE : 0)
| (cx->options().ion() ? JSOPTION_ION : 0)
| (cx->options().asmJS() ? JSOPTION_ASMJS : 0);
}
static unsigned
SetOptionsCommon(JSContext *cx, unsigned newopts)
{
JS_ASSERT((newopts & JSOPTION_MASK) == newopts);
unsigned oldopts = GetOptionsCommon(cx);
cx->options().setExtraWarnings(newopts & JSOPTION_EXTRA_WARNINGS);
cx->options().setWerror(newopts & JSOPTION_WERROR);
cx->options().setVarObjFix(newopts & JSOPTION_VAROBJFIX);
cx->options().setPrivateIsNSISupports(newopts & JSOPTION_PRIVATE_IS_NSISUPPORTS);
cx->options().setCompileAndGo(newopts & JSOPTION_COMPILE_N_GO);
cx->options().setDontReportUncaught(newopts & JSOPTION_DONT_REPORT_UNCAUGHT);
cx->options().setNoDefaultCompartmentObject(newopts & JSOPTION_NO_DEFAULT_COMPARTMENT_OBJECT);
cx->options().setNoScriptRval(newopts & JSOPTION_NO_SCRIPT_RVAL);
cx->options().setBaseline(newopts & JSOPTION_BASELINE);
cx->options().setTypeInference(newopts & JSOPTION_TYPE_INFERENCE);
cx->options().setStrictMode(newopts & JSOPTION_STRICT_MODE);
cx->options().setIon(newopts & JSOPTION_ION);
cx->options().setAsmJS(newopts & JSOPTION_ASMJS);
cx->updateJITEnabled();
return oldopts;
}
JS_PUBLIC_API(uint32_t)
JS_GetOptions(JSContext *cx)
{
/*
* Can't check option/version synchronization here.
* We may have been synchronized with a script version that was formerly on
* the stack, but has now been popped.
*/
return GetOptionsCommon(cx);
}
JS_PUBLIC_API(uint32_t)
JS_SetOptions(JSContext *cx, uint32_t options)
{
return SetOptionsCommon(cx, options);
}
JS_PUBLIC_API(uint32_t)
JS_DisableOptions(JSContext *cx, uint32_t options)
{
unsigned oldopts = GetOptionsCommon(cx);
unsigned newopts = oldopts & ~options;
return SetOptionsCommon(cx, newopts);
}
JS_PUBLIC_API(uint32_t)
JS_EnableOptions(JSContext *cx, uint32_t options)
{
unsigned oldopts = GetOptionsCommon(cx);
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 &)
JS::ContextOptionsRef(JSContext *cx)
{
@ -6097,19 +6014,19 @@ JS_SetGlobalJitCompilerOption(JSContext *cx, JSJitCompilerOption opt, uint32_t v
break;
case JSJITCOMPILER_ION_ENABLE:
if (value == 1) {
JS_EnableOptions(cx, JSOPTION_ION);
JS::ContextOptionsRef(cx).setIon(true);
IonSpew(js::jit::IonSpew_Scripts, "Enable ion");
} else if (value == 0) {
JS_DisableOptions(cx, JSOPTION_ION);
JS::ContextOptionsRef(cx).setIon(false);
IonSpew(js::jit::IonSpew_Scripts, "Disable ion");
}
break;
case JSJITCOMPILER_BASELINE_ENABLE:
if (value == 1) {
JS_EnableOptions(cx, JSOPTION_BASELINE);
JS::ContextOptionsRef(cx).setBaseline(true);
IonSpew(js::jit::IonSpew_BaselineScripts, "Enable baseline");
} else if (value == 0) {
JS_DisableOptions(cx, JSOPTION_BASELINE);
JS::ContextOptionsRef(cx).setBaseline(false);
IonSpew(js::jit::IonSpew_BaselineScripts, "Disable baseline");
}
break;

View File

@ -1468,81 +1468,6 @@ JS_VersionToString(JSVersion version);
extern JS_PUBLIC_API(JSVersion)
JS_StringToVersion(const char *string);
/*
* JS options are orthogonal to version, and may be freely composed with one
* another as well as with version.
*
* JSOPTION_VAROBJFIX is recommended -- see the comments associated with the
* prototypes for JS_ExecuteScript, JS_EvaluateScript, etc.
*/
#define JSOPTION_EXTRA_WARNINGS JS_BIT(0) /* warn on dubious practices */
#define JSOPTION_WERROR JS_BIT(1) /* convert warning to error */
#define JSOPTION_VAROBJFIX JS_BIT(2) /* make JS_EvaluateScript use
the last object on its 'obj'
param's scope chain as the
ECMA 'variables object' */
#define JSOPTION_PRIVATE_IS_NSISUPPORTS \
JS_BIT(3) /* context private data points
to an nsISupports subclass */
#define JSOPTION_COMPILE_N_GO JS_BIT(4) /* caller of JS_Compile*Script
promises to execute compiled
script once only; enables
compile-time scope chain
resolution of consts. */
/* JS_BIT(5) is currently unused. */
/* JS_BIT(6) is currently unused. */
/* JS_BIT(7) is currently unused. */
#define JSOPTION_DONT_REPORT_UNCAUGHT \
JS_BIT(8) /* When returning from the
outermost API call, prevent
uncaught exceptions from
being converted to error
reports */
/* JS_BIT(9) is currently unused. */
/* JS_BIT(10) is currently unused. */
#define JSOPTION_NO_DEFAULT_COMPARTMENT_OBJECT JS_BIT(11) /* This JSContext does not use a
default compartment object. Such
an object will not be set implicitly,
and attempts to get or set it will
assert. */
#define JSOPTION_NO_SCRIPT_RVAL JS_BIT(12) /* A promise to the compiler
that a null rval out-param
will be passed to each call
to JS_ExecuteScript. */
/* JS_BIT(13) is currently unused. */
#define JSOPTION_BASELINE JS_BIT(14) /* Baseline compiler. */
#define JSOPTION_TYPE_INFERENCE JS_BIT(16) /* Perform type inference. */
#define JSOPTION_STRICT_MODE JS_BIT(17) /* Provides a way to force
strict mode for all code
without requiring
"use strict" annotations. */
#define JSOPTION_ION JS_BIT(18) /* IonMonkey */
#define JSOPTION_ASMJS JS_BIT(19) /* optimizingasm.js compiler */
#define JSOPTION_MASK JS_BITMASK(20)
extern JS_PUBLIC_API(uint32_t)
JS_GetOptions(JSContext *cx);
extern JS_PUBLIC_API(uint32_t)
JS_SetOptions(JSContext *cx, uint32_t options);
extern JS_PUBLIC_API(uint32_t)
JS_ToggleOptions(JSContext *cx, uint32_t options);
namespace JS {
class JS_PUBLIC_API(ContextOptions) {
@ -3571,11 +3496,9 @@ JS_DecompileFunctionBody(JSContext *cx, JSFunction *fun, unsigned indent);
* non-ECMA explicit vs. implicit variable creation.
*
* Caveat embedders: unless you already depend on this buggy variables object
* binding behavior, you should call JS_SetOptions(cx, JSOPTION_VAROBJFIX) or
* JS_SetOptions(cx, JS_GetOptions(cx) | JSOPTION_VAROBJFIX) -- the latter if
* someone may have set other options on cx already -- for each context in the
* application, if you pass parented objects as the obj parameter, or may ever
* pass such objects in the future.
* binding behavior, you should call ContextOptionsRef(cx).setVarObjFix(true)
* for each context in the application, if you pass parented objects as the obj
* parameter, or may ever pass such objects in the future.
*
* Why a runtime option? The alternative is to add six or so new API entry
* points with signatures matching the following six, and that doesn't seem