From 0a521d306390894f1eb3376c734df98ce778b5d7 Mon Sep 17 00:00:00 2001 From: Michael Dyck Date: Tue, 9 May 2023 09:04:26 -0400 Subject: [PATCH] Editorial: Refactor HostEnqueueFinalizationRegistryCleanupJob to take a Job ... by hoisting the job-internal steps out to the caller. This brings it in line with the statement (in "9.5 Jobs and Host Operations to Enqueue Jobs") that job-scheduling host hooks "accept a Job Abstract Closure as the parameter". See https://github.com/tc39/ecma262/pull/3049#issuecomment-1536758487 and following. --- spec.html | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/spec.html b/spec.html index 12d6d369ba..57ed70ca8a 100644 --- a/spec.html +++ b/spec.html @@ -12244,7 +12244,12 @@

Execution

1. Set _ref_.[[WeakRefTarget]] to ~empty~. 1. For each FinalizationRegistry _fg_ such that _fg_.[[Cells]] contains a Record _cell_ such that _cell_.[[WeakRefTarget]] is _value_, do 1. Set _cell_.[[WeakRefTarget]] to ~empty~. - 1. Optionally, perform HostEnqueueFinalizationRegistryCleanupJob(_fg_). + 1. Optionally, perform the following steps: + 1. Let _cleanupJob_ be a new Job Abstract Closure with no parameters that captures _fg_ and performs the following steps when called: + 1. Let _cleanupResult_ be Completion(CleanupFinalizationRegistry(_fg_)). + 1. If _cleanupResult_ is an abrupt completion, perform any host-defined steps for reporting the error. + 1. Return ~unused~. + 1. Perform HostEnqueueFinalizationRegistryCleanupJob(_cleanupJob_). 1. For each WeakMap _map_ such that _map_.[[WeakMapData]] contains a Record _r_ such that _r_.[[Key]] is _value_, do 1. Set _r_.[[Key]] to ~empty~. 1. Set _r_.[[Value]] to ~empty~. @@ -12273,17 +12278,11 @@

Host Hooks

HostEnqueueFinalizationRegistryCleanupJob ( - _finalizationRegistry_: a FinalizationRegistry, + _cleanupJob_: a Job Abstract Closure, ): ~unused~

-

Let _cleanupJob_ be a new Job Abstract Closure with no parameters that captures _finalizationRegistry_ and performs the following steps when called:

- - 1. Let _cleanupResult_ be Completion(CleanupFinalizationRegistry(_finalizationRegistry_)). - 1. If _cleanupResult_ is an abrupt completion, perform any host-defined steps for reporting the error. - 1. Return ~unused~. -

An implementation of HostEnqueueFinalizationRegistryCleanupJob schedules _cleanupJob_ to be performed at some future time, if possible. It must also conform to the requirements in .