From 009da3defeeac31c26a9bd2eceb8a4277eabdafc Mon Sep 17 00:00:00 2001 From: Chengzhong Wu Date: Fri, 13 Oct 2023 17:28:16 +0800 Subject: [PATCH] Nomative: save active scriptOrModule in JobRecord --- spec.html | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/spec.html b/spec.html index 9823aaa49e..dcea3ecac0 100644 --- a/spec.html +++ b/spec.html @@ -12009,6 +12009,17 @@

JobCallback Records

The function to invoke when the Job is invoked. + + + [[ScriptOrModule]] + + + a Script Record or a Module Record + + + The script or module in which the Job was created. + + [[HostDefined]] @@ -12034,11 +12045,12 @@

An implementation of HostMakeJobCallback must conform to the following requirements:

The default implementation of HostMakeJobCallback performs the following steps when called:

- 1. Return the JobCallback Record { [[Callback]]: _callback_, [[HostDefined]]: ~empty~ }. + 1. Let _scriptOrModule_ be GetActiveScriptOrModule(). + 1. Return the JobCallback Record { [[Callback]]: _callback_, [[ScriptOrModule]]: _scriptOrModule_, [[HostDefined]]: ~empty~ }.

ECMAScript hosts that are not web browsers must use the default implementation of HostMakeJobCallback.

@@ -12058,6 +12070,7 @@

An implementation of HostCallJobCallback must conform to the following requirements:

    +
  • It must perform implementation-defined steps such that _jobCallback_.[[ScriptOrModule]] is the active script or module at the time of _job_'s invocation.
  • It must perform and return the result of Call(_jobCallback_.[[Callback]], _V_, _argumentsList_).
@@ -12066,7 +12079,17 @@

The default implementation of HostCallJobCallback performs the following steps when called:

1. Assert: IsCallable(_jobCallback_.[[Callback]]) is *true*. - 1. Return ? Call(_jobCallback_.[[Callback]], _V_, _argumentsList_). + 1. Let _callerContext_ be the running execution context. + 1. If _callerContext_ is not already suspended, suspend _callerContext_. + 1. Let _jobContext_ be a new execution context. + 1. Let _scriptOrModule_ be _jobCallback_.[[ScriptOrModule]]. + 1. If _scriptOrModule_ is not *null*, then + 1. Set the Realm of _jobContext_ to _scriptOrModule_.[[Realm]]. + 1. Set the ScriptOrModule of _jobContext_ to _scriptOrModule_. + 1. Perform any necessary implementation-defined initialization of _jobContext_. + 1. Let _result_ be Completion(Call(_jobCallback_.[[Callback]], _V_, _argumentsList_)). + 1. Remove _jobContext_ from the execution context stack and restore _callerContext_ as the running execution context. + 1. Return ? _result_.

ECMAScript hosts that are not web browsers must use the default implementation of HostCallJobCallback.

@@ -12100,7 +12123,6 @@

An implementation of HostEnqueuePromiseJob must conform to the requirements in as well as the following:

  • If _realm_ is not *null*, each time _job_ is invoked the implementation must perform implementation-defined steps such that execution is prepared to evaluate ECMAScript code at the time of _job_'s invocation.
  • -
  • Let _scriptOrModule_ be GetActiveScriptOrModule() at the time HostEnqueuePromiseJob is invoked. If _realm_ is not *null*, each time _job_ is invoked the implementation must perform implementation-defined steps such that _scriptOrModule_ is the active script or module at the time of _job_'s invocation.
  • Jobs must run in the same order as the HostEnqueuePromiseJob invocations that scheduled them.