Require JSFunction::inStrictMode() callers to check for isInterpreted() first, since most already know that the function in question is interpreted. r=dmandelin

This commit is contained in:
Jeff Walden 2010-12-22 21:06:08 -05:00
parent 59814e4551
commit e2834ef56d
4 changed files with 11 additions and 7 deletions

View File

@ -1580,10 +1580,13 @@ fun_getProperty(JSContext *cx, JSObject *obj, jsid id, Value *vp)
/* Censor the caller if it is from another compartment. */
if (caller.getCompartment() != cx->compartment) {
vp->setNull();
} else if (caller.isFunction() && caller.getFunctionPrivate()->inStrictMode()) {
JS_ReportErrorFlagsAndNumber(cx, JSREPORT_ERROR, js_GetErrorMessage, NULL,
JSMSG_CALLER_IS_STRICT);
return false;
} else if (caller.isFunction()) {
JSFunction *callerFun = caller.getFunctionPrivate();
if (callerFun->isInterpreted() && callerFun->inStrictMode()) {
JS_ReportErrorFlagsAndNumber(cx, JSREPORT_ERROR, js_GetErrorMessage, NULL,
JSMSG_CALLER_IS_STRICT);
return false;
}
}
}
break;
@ -1753,7 +1756,7 @@ fun_resolve(JSContext *cx, JSObject *obj, jsid id, uintN flags,
PropertyOp getter, setter;
uintN attrs = JSPROP_PERMANENT;
if (fun->inStrictMode() || obj->isBoundFunction()) {
if (fun->isInterpreted() ? fun->inStrictMode() : obj->isBoundFunction()) {
JSObject *throwTypeError = obj->getThrowTypeError();
getter = CastAsPropertyOp(throwTypeError);

View File

@ -180,6 +180,7 @@ struct JSFunction : public JSObject_Slots2
bool isFunctionPrototype() const { return flags & JSFUN_PROTOTYPE; }
/* Returns the strictness of this function, which must be interpreted. */
inline bool inStrictMode() const;
uintN countVars() const {

View File

@ -46,7 +46,7 @@
inline bool
JSFunction::inStrictMode() const
{
return isInterpreted() && u.i.script->strictModeCode;
return script()->strictModeCode;
}
#endif /* jsfuninlines_h___ */

View File

@ -9970,7 +9970,7 @@ TraceRecorder::getThis(LIns*& this_ins)
JS_ASSERT(fp->callee().getGlobal() == globalObj);
Value& thisv = fp->thisValue();
if (fp->fun()->inStrictMode() || thisv.isObject()) {
if (thisv.isObject() || fp->fun()->inStrictMode()) {
/*
* fp->thisValue() has already been computed. Since the
* type-specialization of traces distinguishes between computed and