From aff8342de505ffdbcfc0f89e3e88dd9cc646630d Mon Sep 17 00:00:00 2001 From: Ashley Claymore Date: Mon, 16 May 2022 21:54:53 +0100 Subject: [PATCH] include liveness of symbols in more descriptions --- spec.html | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/spec.html b/spec.html index 8492e27505b..712e97b963f 100644 --- a/spec.html +++ b/spec.html @@ -12322,12 +12322,12 @@

Forward Progress

-

Processing Model of WeakRef and FinalizationRegistry Values

+

Processing Model of WeakRef and FinalizationRegistry Targets

Objectives

-

This specification does not make any guarantees that any object will be garbage collected. Objects or symbols 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 or symbol will be garbage collected. Objects or symbols 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.

The semantics of WeakRefs and FinalizationRegistrys is based on two operations which happen at particular points in time:

@@ -12337,7 +12337,7 @@

Objectives

  • - When an object which is registered with a FinalizationRegistry becomes unreachable, a call of the FinalizationRegistry's cleanup callback may eventually be made, after synchronous ECMAScript execution completes. The FinalizationRegistry cleanup is performed with the CleanupFinalizationRegistry abstract operation. + When an object or symbol which is registered with a FinalizationRegistry becomes unreachable, a call of the FinalizationRegistry's cleanup callback may eventually be made, after synchronous ECMAScript execution completes. The FinalizationRegistry cleanup is performed with the CleanupFinalizationRegistry abstract operation.
  • @@ -12361,18 +12361,18 @@

    Liveness

    Colloquially, we say that an individual symbol or object is live if every set of symbols and/or objects containing it is live. -

    At any point during evaluation, a set of symbols and/or _S_ is considered live if either of the following conditions is met:

    +

    At any point during evaluation, a set of symbols and/or objects _S_ is considered live if either of the following conditions is met:

    • Any element in _S_ is included in any agent's [[KeptAlive]] List.
    • - There exists a valid future hypothetical WeakRef-oblivious execution with respect to _S_ that observes the value of any symbol or object in _S_. + There exists a valid future hypothetical WeakRef-oblivious execution with respect to _S_ that observes any value in _S_.
    - The second condition above intends to capture the intuition that a reference is live if its identity is observable via non-WeakRef means. An reference value's identity may be observed by observing a strict equality comparison or observing the value being used as key in a Map. + The second condition above intends to capture the intuition that a reference is live if its identity is observable via non-WeakRef means. A reference value's identity may be observed by observing a strict equality comparison or observing the value being used as key in a Map.

    Presence of a symbol or an object in a field, an internal slot, or a property does not imply that the reference is live. For example if the reference in question is never passed back to the program, then it cannot be observed.

    @@ -12381,9 +12381,6 @@

    Liveness

    The above definition implies that, if a key in a WeakMap is not live, then its corresponding value is not necessarily live either.

    - - Presence of a symbol in the GlobalSymbolRegistry List might keep the reference alive. Symbol values might have their liveness compromised if contained in the GlobalSymbolRegistry List as it is globablly avaialble and shared by all realms. - Liveness is the lower bound for guaranteeing which WeakRefs 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. @@ -12418,8 +12415,8 @@

    Execution

    Because calling HostEnqueueFinalizationRegistryCleanupJob is optional, registered objects in a FinalizationRegistry do not necessarily hold that FinalizationRegistry live. Implementations may omit FinalizationRegistry callbacks for any reason, e.g., if the FinalizationRegistry itself becomes dead, or if the application is shutting down.

    -

    Implementations are not obligated to empty WeakRefs for maximal sets of non-live objects ir symbols.

    -

    If an implementation chooses a non-live set _S_ in which to empty WeakRefs, it must empty WeakRefs for all objects in _S_ simultaneously. In other words, an implementation must not empty a WeakRef pointing to an object _obj_ without emptying out other WeakRefs that, if not emptied, could result in an execution that observes the Object value of _obj_.

    +

    Implementations are not obligated to empty WeakRefs for maximal sets of non-live objects or symbols.

    +

    If an implementation chooses a non-live set _S_ in which to empty WeakRefs, it must empty WeakRefs for all values in _S_ simultaneously. In other words, an implementation must not empty a WeakRef pointing to a value _v_ without emptying out other WeakRefs that, if not emptied, could result in an execution that observes the value of _v_.

    @@ -12472,7 +12469,7 @@

    1. Return ~unused~. - When the abstract operation AddToKeptObjects is called with a target object, or symbol, reference, it adds the target to a list that will point strongly at the target until ClearKeptObjects is called. + When the abstract operation AddToKeptObjects is called with a target object or symbol reference, it adds the target to a list that will point strongly at the target until ClearKeptObjects is called. @@ -42710,7 +42707,7 @@

    Managing Memory

    WeakRef Objects

    -

    A WeakRef is an object that is used to refer to a target object without preserving it from garbage collection. WeakRefs can be dereferenced to allow access to the target object, if the target object hasn't been reclaimed by garbage collection.

    +

    A WeakRef is an object that is used to refer to a target object or symbol without preserving it from garbage collection. WeakRefs can be dereferenced to allow access to the target value, if the target hasn't been reclaimed by garbage collection.

    The WeakRef Constructor

    @@ -42792,7 +42789,7 @@

    WeakRef.prototype.deref ( )

    -

    If the WeakRef returns a _target_ value that is not *undefined*, then this _target_ object should not be garbage collected until the current execution of ECMAScript code has completed. The AddToKeptObjects operation makes sure read consistency is maintained.

    +

    If the WeakRef returns a _target_ value that is not *undefined*, then this _target_ value should not be garbage collected until the current execution of ECMAScript code has completed. The AddToKeptObjects operation makes sure read consistency is maintained.

    
                 target = { foo: function() {} };
    @@ -42848,7 +42845,7 @@ 

    Properties of WeakRef Instances

    FinalizationRegistry Objects

    -

    A FinalizationRegistry is an object that manages registration and unregistration of cleanup operations that are performed when target objects are garbage collected.

    +

    A FinalizationRegistry is an object that manages registration and unregistration of cleanup operations that are performed when target objects and symbols are garbage collected.

    The FinalizationRegistry Constructor