Bug 478075: Remove parent argument to js_GetCallObject. r=brendan

This commit is contained in:
Jim Blandy 2009-02-18 23:57:24 -08:00
parent d7b3542b7c
commit e7ae601acc
7 changed files with 28 additions and 24 deletions

View File

@ -1109,7 +1109,7 @@ JS_GetFrameCallObject(JSContext *cx, JSStackFrame *fp)
* XXX ill-defined: null return here means error was reported, unlike a
* null returned above or in the #else
*/
return js_GetCallObject(cx, fp, NULL);
return js_GetCallObject(cx, fp);
}
JS_PUBLIC_API(JSObject *)

View File

@ -591,9 +591,9 @@ JSClass js_ArgumentsClass = {
#define CALL_CLASS_FIXED_RESERVED_SLOTS 2
JSObject *
js_GetCallObject(JSContext *cx, JSStackFrame *fp, JSObject *parent)
js_GetCallObject(JSContext *cx, JSStackFrame *fp)
{
JSObject *callobj, *funobj;
JSObject *callobj;
/* Create a call object for fp only if it lacks one. */
JS_ASSERT(fp->fun);
@ -601,15 +601,18 @@ js_GetCallObject(JSContext *cx, JSStackFrame *fp, JSObject *parent)
if (callobj)
return callobj;
/* The default call parent is its function's parent (static link). */
if (!parent) {
funobj = fp->callee;
if (funobj)
parent = OBJ_GET_PARENT(cx, funobj);
}
#ifdef DEBUG
/* A call object should be a frame's outermost scope chain element. */
JSClass *classp = OBJ_GET_CLASS(cx, fp->scopeChain);
if (classp == &js_WithClass || classp == &js_BlockClass || classp == &js_CallClass)
JS_ASSERT(OBJ_GET_PRIVATE(cx, fp->scopeChain) != fp);
#endif
/* Create the call object and link it to its stack frame. */
callobj = js_NewObject(cx, &js_CallClass, NULL, parent, 0);
/*
* Create the call object, using the frame's enclosing scope as
* its parent, and link the call to its stack frame.
*/
callobj = js_NewObject(cx, &js_CallClass, NULL, fp->scopeChain, 0);
if (!callobj)
return NULL;
@ -618,8 +621,10 @@ js_GetCallObject(JSContext *cx, JSStackFrame *fp, JSObject *parent)
OBJECT_TO_JSVAL(FUN_OBJECT(fp->fun)));
fp->callobj = callobj;
/* Make callobj be the scope chain and the variables object. */
JS_ASSERT(fp->scopeChain == parent);
/*
* Push callobj on the top of the scope chain, and make it the
* variables object.
*/
fp->scopeChain = callobj;
fp->varobj = callobj;
return callobj;

View File

@ -204,7 +204,7 @@ extern void
js_ReportIsNotFunction(JSContext *cx, jsval *vp, uintN flags);
extern JSObject *
js_GetCallObject(JSContext *cx, JSStackFrame *fp, JSObject *parent);
js_GetCallObject(JSContext *cx, JSStackFrame *fp);
extern JS_FRIEND_API(JSBool)
js_PutCallObject(JSContext *cx, JSStackFrame *fp);

View File

@ -688,7 +688,7 @@ js_GetScopeChain(JSContext *cx, JSStackFrame *fp)
if (fp->fun && !fp->callobj) {
JS_ASSERT(OBJ_GET_CLASS(cx, fp->scopeChain) != &js_BlockClass ||
OBJ_GET_PRIVATE(cx, fp->scopeChain) != fp);
if (!js_GetCallObject(cx, fp, fp->scopeChain))
if (!js_GetCallObject(cx, fp))
return NULL;
}
@ -1325,7 +1325,7 @@ have_fun:
frame.scopeChain = parent;
if (JSFUN_HEAVYWEIGHT_TEST(fun->flags)) {
/* Scope with a call object parented by the callee's parent. */
if (!js_GetCallObject(cx, &frame, parent)) {
if (!js_GetCallObject(cx, &frame)) {
ok = JS_FALSE;
goto out;
}
@ -4932,7 +4932,7 @@ js_Interpret(JSContext *cx)
/* Scope with a call object parented by callee's parent. */
if (JSFUN_HEAVYWEIGHT_TEST(fun->flags) &&
!js_GetCallObject(cx, &newifp->frame, parent)) {
!js_GetCallObject(cx, &newifp->frame)) {
goto bad_inline_call;
}

View File

@ -1280,7 +1280,7 @@ obj_eval(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
* object, then we need to provide one for the compiler to stick any
* declared (var) variables into.
*/
if (caller && !caller->varobj && !js_GetCallObject(cx, caller, NULL))
if (caller && !caller->varobj && !js_GetCallObject(cx, caller))
return JS_FALSE;
/* Accept an optional trailing argument that overrides the scope object. */

View File

@ -311,7 +311,7 @@ static JSBool
script_exec_sub(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
jsval *rval)
{
JSObject *scopeobj, *parent;
JSObject *scopeobj;
JSStackFrame *caller;
JSPrincipals *principals;
JSScript *script;
@ -344,9 +344,8 @@ script_exec_sub(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
/* Called from a lightweight function. */
JS_ASSERT(caller->fun && !JSFUN_HEAVYWEIGHT_TEST(caller->fun->flags));
/* Scope chain links from Call object to callee's parent. */
parent = OBJ_GET_PARENT(cx, caller->callee);
if (!js_GetCallObject(cx, caller, parent))
/* Scope chain links from Call object to caller's scope chain. */
if (!js_GetCallObject(cx, caller))
return JS_FALSE;
}
@ -363,7 +362,7 @@ script_exec_sub(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
} else {
/*
* Called from native code, so we don't know what scope object to
* use. We could use parent (see above), but Script.prototype.exec
* use. We could use the caller's scope chain (see above), but Script.prototype.exec
* might be a shared/sealed "superglobal" method. A more general
* approach would use cx->globalObject, which will be the same as
* exec.__parent__ in the non-superglobal case. In the superglobal

View File

@ -3205,7 +3205,7 @@ js_SynthesizeFrame(JSContext* cx, const FrameInfo& fi)
#ifdef DEBUG
JSObject *obj =
#endif
js_GetCallObject(cx, &newifp->frame, newifp->frame.scopeChain);
js_GetCallObject(cx, &newifp->frame);
JS_ASSERT(obj);
JS_TRACE_MONITOR(cx).useReservedObjects = JS_FALSE;
}