mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-09 17:31:47 +09:00
Use canonical function in TypeNewScript::rollbackPartiallyInitializedObjects.
This commit is contained in:
parent
e9bdcb12f3
commit
518106945b
3 changed files with 26 additions and 7 deletions
|
|
@ -460,6 +460,19 @@ class JSFunction : public js::NativeObject
|
|||
return nonLazyScript();
|
||||
}
|
||||
|
||||
// If this is a scripted function, returns its canonical function (the
|
||||
// original function allocated by the frontend). Note that lazy self-hosted
|
||||
// builtins don't have a lazy script so in that case we also return nullptr.
|
||||
JSFunction* maybeCanonicalFunction() const {
|
||||
if (hasScript()) {
|
||||
return nonLazyScript()->functionNonDelazifying();
|
||||
}
|
||||
if (isInterpretedLazy() && !isSelfHostedBuiltin()) {
|
||||
return lazyScript()->functionNonDelazifying();
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// The state of a JSFunction whose script errored out during bytecode
|
||||
// compilation. Such JSFunctions are only reachable via GC iteration and
|
||||
// not from script.
|
||||
|
|
|
|||
|
|
@ -496,12 +496,7 @@ ObjectGroup::defaultNewGroup(ExclusiveContext* cx, const Class* clasp,
|
|||
|
||||
// Canonicalize new functions to use the original one associated with its script.
|
||||
JSFunction* fun = &associated->as<JSFunction>();
|
||||
if (fun->hasScript())
|
||||
associated = fun->nonLazyScript()->functionNonDelazifying();
|
||||
else if (fun->isInterpretedLazy() && !fun->isSelfHostedBuiltin())
|
||||
associated = fun->lazyScript()->functionNonDelazifying();
|
||||
else
|
||||
associated = nullptr;
|
||||
associated = associated->as<JSFunction>().maybeCanonicalFunction();
|
||||
|
||||
// If we have previously cleared the 'new' script information for this
|
||||
// function, don't try to construct another one.
|
||||
|
|
|
|||
|
|
@ -3603,6 +3603,10 @@ TypeNewScript::make(JSContext* cx, ObjectGroup* group, JSFunction* fun)
|
|||
MOZ_ASSERT(!group->newScript());
|
||||
MOZ_ASSERT(!group->maybeUnboxedLayout());
|
||||
|
||||
// rollbackPartiallyInitializedObjects expects function_ to be
|
||||
// canonicalized.
|
||||
MOZ_ASSERT(fun->maybeCanonicalFunction() == fun);
|
||||
|
||||
if (group->unknownProperties())
|
||||
return true;
|
||||
|
||||
|
|
@ -3958,8 +3962,15 @@ TypeNewScript::rollbackPartiallyInitializedObjects(JSContext* cx, ObjectGroup* g
|
|||
oomUnsafe.crash("rollbackPartiallyInitializedObjects");
|
||||
}
|
||||
|
||||
if (!iter.isConstructing() || !iter.matchCallee(cx, function))
|
||||
if (!iter.isConstructing()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
MOZ_ASSERT(iter.calleeTemplate()->maybeCanonicalFunction());
|
||||
|
||||
if (iter.calleeTemplate()->maybeCanonicalFunction() != function) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Derived class constructors initialize their this-binding later and
|
||||
// we shouldn't run the definite properties analysis on them.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue