mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 958172 - Only set the environment while cloning a JSFunction. r=jorendorff
This commit is contained in:
parent
bf34cdd211
commit
7dee273c57
@ -1247,17 +1247,13 @@ Parser<ParseHandler>::newFunction(GenericParseContext *pc, HandleAtom atom,
|
||||
while (pc->parent)
|
||||
pc = pc->parent;
|
||||
|
||||
RootedObject parent(context);
|
||||
if (!pc->sc->isFunctionBox() && options().compileAndGo)
|
||||
parent = pc->sc->asGlobalSharedContext()->scopeChain();
|
||||
|
||||
RootedFunction fun(context);
|
||||
JSFunction::Flags flags = (kind == Expression)
|
||||
? JSFunction::INTERPRETED_LAMBDA
|
||||
: (kind == Arrow)
|
||||
? JSFunction::INTERPRETED_LAMBDA_ARROW
|
||||
: JSFunction::INTERPRETED;
|
||||
fun = NewFunctionWithProto(context, NullPtr(), nullptr, 0, flags, parent, atom, proto,
|
||||
fun = NewFunctionWithProto(context, NullPtr(), nullptr, 0, flags, NullPtr(), atom, proto,
|
||||
JSFunction::FinalizeKind, MaybeSingletonObject);
|
||||
if (!fun)
|
||||
return nullptr;
|
||||
|
@ -409,6 +409,13 @@ js::XDRInterpretedFunction(XDRState<mode> *xdr, HandleObject enclosingScope, Han
|
||||
|
||||
atom = fun->displayAtom();
|
||||
flagsword = (fun->nargs() << 16) | fun->flags();
|
||||
|
||||
// The environment of any function which is not reused will always be
|
||||
// null, it is later defined when a function is cloned or reused to
|
||||
// mirror the scope chain.
|
||||
JS_ASSERT_IF(fun->hasSingletonType() &&
|
||||
!((lazy && lazy->hasBeenCloned()) || (script && script->hasBeenCloned())),
|
||||
fun->environment() == nullptr);
|
||||
}
|
||||
|
||||
if (!xdr->codeUint32(&firstword))
|
||||
@ -421,8 +428,9 @@ js::XDRInterpretedFunction(XDRState<mode> *xdr, HandleObject enclosingScope, Han
|
||||
if (!proto)
|
||||
return false;
|
||||
}
|
||||
|
||||
fun = NewFunctionWithProto(cx, NullPtr(), nullptr, 0, JSFunction::INTERPRETED,
|
||||
NullPtr(), NullPtr(), proto,
|
||||
/* parent = */ NullPtr(), NullPtr(), proto,
|
||||
JSFunction::FinalizeKind, TenuredObject);
|
||||
if (!fun)
|
||||
return false;
|
||||
|
Loading…
Reference in New Issue
Block a user