Skip to content

Commit

Permalink
round 3 comments
Browse files Browse the repository at this point in the history
  • Loading branch information
codehag committed Jul 14, 2020
1 parent b8f138f commit fcead87
Showing 1 changed file with 14 additions and 16 deletions.
30 changes: 14 additions & 16 deletions spec.html
Original file line number Diff line number Diff line change
Expand Up @@ -7884,8 +7884,7 @@ <h1>Processing model of WeakRef and FinalizationRegistry objects</h1>
<h1>Objectives</h1>

<p>
This specification does not make any guarantees that any object will be garbage collected.
Objects which are not live may be released after long periods of time, or never at all. For this reason, this specification uses the term "may" when describing behaviour triggered by garbage collection.
This specification does not make any guarantees that any object will be garbage collected. Objects which are not live may be released after long periods of time, or never at all. For this reason, this specification uses the term "may" when describing behaviour triggered by garbage collection.
</p>

<p>
Expand All @@ -7903,11 +7902,11 @@ <h1>Objectives</h1>
</ul>

<p>
Neither of these actions (ClearKeptObjects or CleanupFinalizationRegistry) may interrupt synchronous ECMAScript execution. Because embedding environments may assemble longer, synchronous ECMAScript execution runs, this specification defers the scheduling of ClearKeptObjects and CleanupFinalizationRegistry to the host environment.
Neither of these actions (ClearKeptObjects or CleanupFinalizationRegistry) may interrupt synchronous ECMAScript execution. Because host environments may assemble longer, synchronous ECMAScript execution runs, this specification defers the scheduling of ClearKeptObjects and CleanupFinalizationRegistry to the host environment.
</p>

<p>
Some ECMAScript implementations include garbage collector implementations which run in the background, including when ECMAScript is idle. Letting the embedding environment schedule CleanupFinalizationRegistry allows it to resume ECMAScript execution in order to run finalizer work, which may free up held values, reducing overall memory usage.
Some ECMAScript implementations include garbage collector implementations which run in the background, including when ECMAScript is idle. Letting the host environment schedule CleanupFinalizationRegistry allows it to resume ECMAScript execution in order to run finalizer work, which may free up held values, reducing overall memory usage.
</p>
</emu-clause>

Expand All @@ -7918,7 +7917,7 @@ <h1>Liveness</h1>
For some set of objects _S_, a <dfn>hypothetical WeakRef-oblivious</dfn> execution with respect to _S_ is an execution whereby `WeakRef.prototype.deref` being called on a WeakRef whose referent is an element of _S_ always returns *undefined*.
</p>
<emu-note>
WeakRef-obliviousness, together with liveness, capture two notions. One, that a WeakRef itself does not keep an object alive. Two, that cycles in liveness does not imply that an object is live. To be concrete, if determining _obj_'s liveness depends on determining the liveness of another WeakRef referent, _obj2_, _obj2_'s liveness cannot assume _obj_'s liveness, which would beg the question.
WeakRef-obliviousness, together with liveness, capture two notions. One, that a WeakRef itself does not keep an object alive. Two, that cycles in liveness does not imply that an object is live. To be concrete, if determining _obj_'s liveness depends on determining the liveness of another WeakRef referent, _obj2_, _obj2_'s liveness cannot assume _obj_'s liveness, which would be circular reasoning.
</emu-note>
<emu-note>
WeakRef-obliviousness is defined on sets of objects instead of individual objects to account for cycles. If it were defined on individual objects, then an object in a cycle will be considered live even though its Object value is only observed via WeakRefs of other objects in the cycle.
Expand Down Expand Up @@ -7953,7 +7952,7 @@ <h1>Liveness</h1>
</p>
</emu-note>
<emu-note>
Liveness is the lower bound for guaranteeing which WeakRefs that engines must not empty. In practice, liveness as defined here is undecidable and engines use conservative approximations such as reachability. There is expected to be significant implementation leeway.
Liveness is the lower bound for guaranteeing which WeakRefs that engines must not empty. Liveness as defined here is undecidable. In practice, engines use conservative approximations such as reachability. There is expected to be significant implementation leeway.
</emu-note>
</emu-clause>

Expand All @@ -7966,10 +7965,10 @@ <h1>Execution</h1>
1. For each _obj_ of _S_, do
1. For each WeakRef _ref_ such that _ref_.[[WeakRefTarget]] is _obj_, do
1. Set _ref_.[[WeakRefTarget]] to ~empty~.
1. For each FinalizationRegistry _fg_ such that _fg_.[[Cells]] contains _cell_, such that _cell_.[[WeakRefTarget]] is _obj_, do
1. For each FinalizationRegistry _fg_ such that _fg_.[[Cells]] contains _cell_, and _cell_.[[WeakRefTarget]] is _obj_, do
1. Set _cell_.[[WeakRefTarget]] to ~empty~.
1. Optionally, perform ! HostEnqueueFinalizationRegistryCleanupJob(_fg_).
1. For each WeakMap _map_ such that _map_.[[WeakMapData]] contains a record _r_ such that _r_.[[Key]] is _obj_, do
1. For each WeakMap _map_ such that _map_.[[WeakMapData]] contains a Record value _r_ such that _r_.[[Key]] is _obj_, do
1. Remove _r_ from _map_.[[WeakMapData]].
1. For each WeakSet _set_ such that _set_.[[WeakSetData]] contains _obj_, do
1. Remove _obj_ from _set_.[[WeakSetData]].
Expand Down Expand Up @@ -8018,24 +8017,24 @@ <h1>HostEnqueueFinalizationRegistryCleanupJob ( _finalizationRegistry_ )</h1>
<emu-clause id="sec-clear-kept-objects" aoid=ClearKeptObjects>
<h1>ClearKeptObjects ( )</h1>
<p>
The abstract operation CreateRealm takes no arguments. ECMAScript implementations are expected to call ClearKeptObjects when a synchronous sequence of ECMAScript execution completes.
The abstract operation ClearKeptObjects takes no arguments. ECMAScript implementations are expected to call ClearKeptObjects when a synchronous sequence of ECMAScript execution completes.
</p>
<p>The following steps are performed:</p>
<emu-alg>
1. Let _agent_ be the surrounding agent.
1. Let _agentRecord_ be the surrounding agent's Agent Record.
1. Set _agent_.[[KeptAlive]] to a new empty List.
</emu-alg>
</emu-clause>

<emu-clause id="sec-addtokeptobjects" aoid="AddToKeptObjects">
<h1>AddToKeptObjects ( _object_ )</h1>
<p> The abstract operation AddToKeptObjects takes argument _object_ (an object). The following steps are performed: </p>
<p> The abstract operation AddToKeptObjects takes argument _object_ (an Object). The following steps are performed: </p>
<emu-alg>
1. Let _agent_ be the surrounding agent.
1. Let _agentRecord_ be the surrounding agent's Agent Record.
1. Append _object_ to _agent_.[[KeptAlive]].
</emu-alg>
<emu-note>
When the abstract operation AddToKeptObjects is called with a target object reference, it adds the target to an identity Set that will point strongly at the target until ClearKeptObjects is called.
When the abstract operation AddToKeptObjects is called with a target object reference, it adds the target to a list that will point strongly at the target until ClearKeptObjects is called.
</emu-note>
</emu-clause>

Expand Down Expand Up @@ -38884,7 +38883,7 @@ <h1>WeakRef.prototype.deref ( )</h1>
</pre>

<p>
In the above example, if the first deref evaluates to true then the second deref can not fail.
In the above example, if the first deref evaluates to true then the second deref cannot return *undefined*.
</p>
</emu-note>
</emu-clause>
Expand Down Expand Up @@ -39000,8 +38999,7 @@ <h1>FinalizationRegistry.prototype.register ( _target_, _heldValue_ [ , _unregis
1. If Type(_unregisterToken_) is not Object, then
1. If _unregisterToken_ is not *undefined*, throw a *TypeError* exception.
1. Set _unregisterToken_ to ~empty~.
1. Let _cell_ be the Record { [[WeakRefTarget]] : _target_, [[HeldValue]]: _heldValue_,
[[UnregisterToken]]: _unregisterToken_ }.
1. Let _cell_ be the Record { [[WeakRefTarget]] : _target_, [[HeldValue]]: _heldValue_, [[UnregisterToken]]: _unregisterToken_ }.
1. Append _cell_ to _finalizationRegistry_.[[Cells]].
1. Return *undefined*.
</emu-alg>
Expand Down

0 comments on commit fcead87

Please sign in to comment.