JavaScript: roll back every object of a family after a failed class install

main's failed-install roll back (#10544) read one object for each family
and handle, while this branch keeps one for each branch of the family.
The install now records the class and prototype of each of those objects
and the roll back puts each one back, so the merged tree builds again.
This commit is contained in:
dotCooCoo committed 2026-12-02 01:42:49 -08:00
1 parent 4bcdc5d77c
commit 622459dd4b
1 file changed
+13 -11
+13 -11
View File
@@ -485,9 +485,9 @@ struct Undo {
/// replaced values stay in the interpreter's temporary roots until [`install`] returns, so a
/// collection during the call does not free them.
globals: Vec<(Key, Option<Prop>)>,
/// The class and prototype of the object made for each family and handle before the call. An
/// The class and prototype of each object made for a family and handle before the call. An
/// instance of the call can give such an object one of the call's classes.
objects: Vec<(MadeKey, u32, Option<ObjId>)>,
objects: Vec<(MadeKey, ObjId, u32, Option<ObjId>)>,
}
impl Undo {
@@ -519,9 +519,9 @@ impl Undo {
}
}
}
for (made, class, proto) in self.objects {
let Some(&id) = i.host_objects.get(&made) else { continue };
if is_made(&i.heap, &i.host_classes, id, &made)
for (made, id, class, proto) in self.objects {
if i.host_objects.get(&made).is_some_and(|ids| ids.contains(&id))
&& is_made(&i.heap, &i.host_classes, id, &made)
&& let Ok(o) = i.object_mut(id)
&& let Class::Host(h) = &mut o.class
{
@@ -567,12 +567,14 @@ fn install_checked(
install_class(i, class, members, undo)?;
}
if !instances.is_empty() {
for (made, &id) in &i.host_objects {
if is_made(&i.heap, &i.host_classes, id, made)
&& let Ok(o) = i.object(id)
&& let Class::Host(h) = &o.class
{
undo.objects.push((made.clone(), h.class, o.proto));
for (made, ids) in &i.host_objects {
for &id in ids {
if is_made(&i.heap, &i.host_classes, id, made)
&& let Ok(o) = i.object(id)
&& let Class::Host(h) = &o.class
{
undo.objects.push((made.clone(), id, h.class, o.proto));
}
}
}
}