diff --git a/spec.html b/spec.html index 0e4df77294d..2b2a4523371 100644 --- a/spec.html +++ b/spec.html @@ -7884,8 +7884,7 @@

Processing model of WeakRef and FinalizationRegistry objects

Objectives

- 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.

@@ -7903,11 +7902,11 @@

Objectives

- 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.

- 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.

@@ -7918,7 +7917,7 @@

Liveness

For some set of objects _S_, a hypothetical WeakRef-oblivious 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*.

- 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. 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. @@ -7953,7 +7952,7 @@

Liveness

- 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. @@ -7966,10 +7965,10 @@

Execution

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]]. @@ -8018,24 +8017,24 @@

HostEnqueueFinalizationRegistryCleanupJob ( _finalizationRegistry_ )

ClearKeptObjects ( )

- 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.

The following steps are performed:

- 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.

AddToKeptObjects ( _object_ )

-

The abstract operation AddToKeptObjects takes argument _object_ (an object). The following steps are performed:

+

The abstract operation AddToKeptObjects takes argument _object_ (an Object). The following steps are performed:

- 1. Let _agent_ be the surrounding agent. + 1. Let _agentRecord_ be the surrounding agent's Agent Record. 1. Append _object_ to _agent_.[[KeptAlive]]. - 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.
@@ -38884,7 +38883,7 @@

WeakRef.prototype.deref ( )

- 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*.

@@ -39000,8 +38999,7 @@

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*.