-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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: Constrain all host hooks to return either normal or throw completions #2442
Conversation
cc @jugglinmike |
spec.html
Outdated
@@ -10543,7 +10545,8 @@ <h1>Host Hooks</h1> | |||
|
|||
<emu-clause id="sec-host-cleanup-finalization-registry" aoid="HostEnqueueFinalizationRegistryCleanupJob"> | |||
<h1>HostEnqueueFinalizationRegistryCleanupJob ( _finalizationRegistry_ )</h1> | |||
<p>The abstract operation HostEnqueueFinalizationRegistryCleanupJob takes argument _finalizationRegistry_ (a FinalizationRegistry). HostEnqueueFinalizationRegistryCleanupJob is an implementation-defined abstract operation that is expected to call CleanupFinalizationRegistry(_finalizationRegistry_) at some point in the future, if possible. The host's responsibility is to make this call at a time which does not interrupt synchronous ECMAScript code execution.</p> | |||
<p>The abstract operation HostEnqueueFinalizationRegistryCleanupJob takes argument _finalizationRegistry_ (a FinalizationRegistry). HostEnqueueFinalizationRegistryCleanupJob is an implementation-defined abstract operation that is expected to call CleanupFinalizationRegistry(_finalizationRegistry_) at some point in the future, if possible.</p> | |||
<p>An implementation of HostEnqueueFinalizationRegistryCleanupJob must conform to the requirements in <emu-xref href="#sec-jobs"></emu-xref>.</p> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The host's responsibility is to make this call at a time which does not interrupt synchronous ECMAScript code execution.
At first glance, I thought the new requirement on host hooks obviated this statement. On second thought, it doesn't seem like it applies to the behavior of an abstract operation invoked after the host hook has returned. Is there some other justification for removing the statement?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The intention here was the "must not interrupt synchronous execution" is more precisely captured by the requirements in #sec-jobs
, specifically the stuff around waiting for the execution context stack to be empty. No job queued by a job-queuing host defined AO in ecma262 is allowed to interrupt synchronous execution.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, a strict reading of the #sec-jobs
restriction only applies to Job Abstract Closures, which HostEnqueueFinalizationRegistryCleanupJob doesn't explicitly spell out. I'll spell that out so it's clear that it applies.
3d0c24c
to
7a79833
Compare
<p>A <dfn id="host-hook">host hook</dfn> is an abstract operation that is defined in whole or in part by an external source. All host hooks must be listed in Annex <emu-xref href="#sec-host-layering-points"></emu-xref>.</p> | ||
<p>A <dfn id="host-hook">host hook</dfn> is an abstract operation that is defined in whole or in part by an external source. All host hooks must be listed in Annex <emu-xref href="#sec-host-layering-points"></emu-xref>. A host hook must conform to at least the following requirements:</p> | ||
<ul> | ||
<li>It must return either a normal completion or a throw completion.</li> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although it's currently used twice, I don't think we've defined the term "throw completion". We should probably address those existing uses similarly to my suggestion below:
<li>It must return either a normal completion or a throw completion.</li> | |
<li>It must return a completion with a [[Type]] value of ~normal~ or ~throw~.</li> |
This is the same form used in #2448. Perhaps we want to define a term "callable completion" or something that can be used in all of these cases?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer not to unless we start referring to this disjunction in more places. Otherwise it's just another thing to look up when the full definition isn't very long.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll define a generic shorthand, like "foo completion means a completion with a [[Type]] value of ~foo~
".
9475b14
to
aa2b28c
Compare
@@ -171,7 +171,7 @@ <h1>Hosts and Implementations</h1> | |||
<p>A <dfn id="host">host</dfn> is an external source that further defines facilities listed in Annex <emu-xref href="#sec-host-layering-points"></emu-xref> but does not further define other implementation-defined or implementation-approximated facilities. In informal use, a host refers to the set of all implementations, such as the set of all web browsers, that interface with this specification in the same way via Annex <emu-xref href="#sec-host-layering-points"></emu-xref>. A host is often an external specification, such as WHATWG HTML (<a href="https://html.spec.whatwg.org/">https://html.spec.whatwg.org/</a>). In other words, facilities that are host-defined are often further defined in external specifications.</p> | |||
<p>A <dfn id="host-hook">host hook</dfn> is an abstract operation that is defined in whole or in part by an external source. All host hooks must be listed in Annex <emu-xref href="#sec-host-layering-points"></emu-xref>. A host hook must conform to at least the following requirements:</p> | |||
<ul> | |||
<li>It must return either a normal completion or a throw completion.</li> | |||
<li>It must return a completion with a [[Type]] value of ~normal~ or ~throw~.</li> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now that you've defined the shorthands, you don't need to make this change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made it to be consistent with #2448 as you pointed out. Any preference on going with this or staying with "normal or throw completion" for both?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"normal completion or throw completion" for both seems best to me. It means your addition of the definitions of those terms will race. Maybe just split it out and we get that in now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's just sequence this one before the other -- meeting's in 2 days and we should get consensus for the other one by then.
@syg this will need a rebase before it's mergeable |
6979282
to
f811ffc
Compare
Rebased against structured headers. |
…completions (tc39#2442) This PR also makes the prose around requirements for host hook implementations consistent to the template "An implementation of HostHook must conform to the following requirements:".
f811ffc
to
61f7950
Compare
…completions (tc39#2442) This PR also makes the prose around requirements for host hook implementations consistent to the template "An implementation of HostHook must conform to the following requirements:".
This supersedes #2433.
This PR also makes the prose around requirements for host hook
implementations consistent to the template "An implementation of
HostHook must conform to the following requirements:".