mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-14 10:43:24 +00:00
Bug 515233: Make the static level its own parameter to JSCompiler::compileScript. r=igor
Pre-patch, the initial static level at which a script should be compiled to run is passed in the upper sixteen bits of the tcflags parameter to JSCompiler::compileScript; because JSTreeContext::tcflags is a uint16, while the tcflags parameter is a uint32, we know the parameter's upper bits are free. However, we would like to enlarge JSTreeContext::tcflags to 32 bits, as we already have a handful of new flags that belong there. This patch moves the static level to its own parameter, which has a default argument.
This commit is contained in:
parent
fb40bfec5a
commit
2b9bcea9dc
@ -1267,10 +1267,8 @@ JS_EvaluateUCInStackFrame(JSContext *cx, JSStackFrame *fp,
|
||||
* variable references made by this frame.
|
||||
*/
|
||||
script = JSCompiler::compileScript(cx, scobj, fp, JS_StackFramePrincipals(cx, fp),
|
||||
TCF_COMPILE_N_GO |
|
||||
TCF_PUT_STATIC_LEVEL(JS_DISPLAY_SIZE),
|
||||
chars, length, NULL,
|
||||
filename, lineno);
|
||||
TCF_COMPILE_N_GO, chars, length, NULL,
|
||||
filename, lineno, NULL, JS_DISPLAY_SIZE);
|
||||
|
||||
if (!script)
|
||||
return JS_FALSE;
|
||||
|
@ -277,14 +277,6 @@ struct JSTreeContext { /* tree context for semantic checks */
|
||||
TCF_FUN_USES_OWN_NAME | \
|
||||
TCF_HAS_SHARPS)
|
||||
|
||||
/*
|
||||
* Flags field, not stored in JSTreeContext.flags, for passing a static level
|
||||
* into js_CompileScript.
|
||||
*/
|
||||
#define TCF_STATIC_LEVEL_MASK 0xffff0000
|
||||
#define TCF_GET_STATIC_LEVEL(f) ((uint32)(f) >> 16)
|
||||
#define TCF_PUT_STATIC_LEVEL(d) ((uint16)(d) << 16)
|
||||
|
||||
/*
|
||||
* Span-dependent instructions are jumps whose span (from the jump bytecode to
|
||||
* the jump target) may require 2 or 4 bytes of immediate operand.
|
||||
|
@ -1243,7 +1243,6 @@ obj_eval(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
JSStackFrame *fp, *caller, *callerFrame;
|
||||
JSBool indirectCall;
|
||||
uint32 tcflags;
|
||||
JSPrincipals *principals;
|
||||
const char *file;
|
||||
uintN line;
|
||||
@ -1404,7 +1403,6 @@ obj_eval(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
goto out;
|
||||
}
|
||||
|
||||
tcflags = TCF_COMPILE_N_GO | TCF_PUT_STATIC_LEVEL(staticLevel);
|
||||
principals = JS_EvalFramePrincipals(cx, fp, caller);
|
||||
file = js_ComputeFilename(cx, caller, principals, &line);
|
||||
|
||||
@ -1485,9 +1483,9 @@ obj_eval(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
callerFrame = (staticLevel != 0) ? caller : NULL;
|
||||
if (!script) {
|
||||
script = JSCompiler::compileScript(cx, scopeobj, callerFrame,
|
||||
principals, tcflags,
|
||||
principals, TCF_COMPILE_N_GO,
|
||||
str->chars(), str->length(),
|
||||
NULL, file, line, str);
|
||||
NULL, file, line, str, staticLevel);
|
||||
if (!script) {
|
||||
ok = JS_FALSE;
|
||||
goto out;
|
||||
|
@ -788,7 +788,8 @@ JSCompiler::compileScript(JSContext *cx, JSObject *scopeChain, JSStackFrame *cal
|
||||
JSPrincipals *principals, uint32 tcflags,
|
||||
const jschar *chars, size_t length,
|
||||
FILE *file, const char *filename, uintN lineno,
|
||||
JSString *source /* = NULL */)
|
||||
JSString *source /* = NULL */,
|
||||
unsigned staticLevel /* = 0 */)
|
||||
{
|
||||
JSCompiler jsc(cx, principals, callerFrame);
|
||||
JSArenaPool codePool, notePool;
|
||||
@ -800,15 +801,14 @@ JSCompiler::compileScript(JSContext *cx, JSObject *scopeChain, JSStackFrame *cal
|
||||
void *sbrk(ptrdiff_t), *before = sbrk(0);
|
||||
#endif
|
||||
|
||||
JS_ASSERT(!(tcflags & ~(TCF_COMPILE_N_GO | TCF_NO_SCRIPT_RVAL |
|
||||
TCF_STATIC_LEVEL_MASK)));
|
||||
JS_ASSERT(!(tcflags & ~(TCF_COMPILE_N_GO | TCF_NO_SCRIPT_RVAL)));
|
||||
|
||||
/*
|
||||
* The scripted callerFrame can only be given for compile-and-go scripts
|
||||
* and non-zero static level requires callerFrame.
|
||||
*/
|
||||
JS_ASSERT_IF(callerFrame, tcflags & TCF_COMPILE_N_GO);
|
||||
JS_ASSERT_IF(TCF_GET_STATIC_LEVEL(tcflags) != 0, callerFrame);
|
||||
JS_ASSERT_IF(staticLevel != 0, callerFrame);
|
||||
|
||||
if (!jsc.init(chars, length, file, filename, lineno))
|
||||
return NULL;
|
||||
@ -827,7 +827,7 @@ JSCompiler::compileScript(JSContext *cx, JSObject *scopeChain, JSStackFrame *cal
|
||||
|
||||
cg.flags |= uint16(tcflags);
|
||||
cg.scopeChain = scopeChain;
|
||||
if (!SetStaticLevel(&cg, TCF_GET_STATIC_LEVEL(tcflags)))
|
||||
if (!SetStaticLevel(&cg, staticLevel))
|
||||
goto out;
|
||||
|
||||
/*
|
||||
|
@ -885,7 +885,8 @@ struct JSCompiler {
|
||||
JSPrincipals *principals, uint32 tcflags,
|
||||
const jschar *chars, size_t length,
|
||||
FILE *file, const char *filename, uintN lineno,
|
||||
JSString *source = NULL);
|
||||
JSString *source = NULL,
|
||||
unsigned staticLevel = 0);
|
||||
};
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user