Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Normative: Spec liveness constraint for template objects #2957

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

syg
Copy link
Contributor

@syg syg commented Nov 12, 2022

The Lit framework depends on the identity of template arrays being stable (and not being recreated) so long as the site might still get evaluated in the future.

This PR removes the incorrect note about observability of template array objects and tries to spec normative liveness constraints. Firstly, the collection of template objects is most definitely now observable because of WeakRefs. The intention IIRC was that so long as the template site could still be evaluated, we can't GC the template object, but if the template site could no longer be evaluated (what I understand to be meant by "the Parse Node is unreachable), then we can GC it.

Instead of depending on this misleading note about observability, this PR specs the liveness of Parse Nodes, and directly specs the removal from the template registry if the Parse Nodes are no longer live.

cc @LeszekSwirski and @justinfagnani

Also see v8:13190

@ljharb ljharb added the normative change Affects behavior required to correctly evaluate some ECMAScript source text label Nov 13, 2022
@syg
Copy link
Contributor Author

syg commented Nov 14, 2022

Would appreciate reviews from Kevin and Waldemar, who've thought deeply about our liveness definition in the past.

@waldemarhorwat
Copy link

What does it mean to "observe the identity" of a Parse Node in any valid Future Execution? If this means "same Parse Node" comparisons, then GetTemplateObject always observes the identities of all Parse Nodes in a Realm, so how can any cease to be live?

@syg
Copy link
Contributor Author

syg commented Nov 22, 2022

@waldemarhorwat I had intended "observe the identity" of a Parse Node to mean the "same Parse Node" comparison. But that indeed is buggy as written, because the template registry is specced as an associative list, this means GetTemplateObject observes the identity of every Parse Node in the [[TemplateMap]].

My intention here was to only count the Parse Node passed as the argument to GetTemplateObject as "observed". I am not sure what the best way to capture that intention is currently.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
normative change Affects behavior required to correctly evaluate some ECMAScript source text
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants