Skip to content
This repository has been archived by the owner on Jan 25, 2022. It is now read-only.

Normative: When an object dies, all references die at once #122

Merged
merged 1 commit into from May 30, 2019

Conversation

littledan
Copy link
Member

This patch rephrases that logic path into an imperative algorithm,
which is described to behave atomically. The PR attempts to resolve
the issue documented in
#121 (comment)
Related issue: #105

This patch rephrases that logic path into an imperative algorithm,
which is described to behave atomically. The PR attempts to resolve
the issue documented in
tc39#121 (comment)
Related issue: tc39#105
@littledan
Copy link
Member Author

cc @mhofman

1. Set _ref_.[[Target]] to ~empty~.
1. For each FinalizationGroup _fg_ such that _fg_.[[Cells]] contains _cell_, such that _cell_.[[Target]] is _obj_,
1. Set _cell_.[[Target]] to ~empty~.
1. Optionally, perform ! HostCleanupFinalizationGroup(_fg_).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, it's calling a host hook, which later (in HTML, in a queued task) will call that.

At any time, if an object _obj_ is not live, an ECMAScript implementation may perform the following steps atomically:

<emu-alg>
1. For each WeakRef _ref_ such that _ref_.[[Target]] is _obj_,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this automatically apply to all realms in all agents, or should they be explicitly iterated?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are no cross-agent references. I don't think we have a concept of an object being "in a Realm", so I'm not sure what it would mean to enumerate them.

@littledan
Copy link
Member Author

@tschneidereit and I talked this patch over. We were both impressed by @mhofman 's good catch here--this case had not occurred to either of us. @tschneidereit said that this atomicity would hold in the planned implementation strategy for SpiderMonkey, and supported merging this patch.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants