You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: document/js-api/index.bs
+32-26
Original file line number
Diff line number
Diff line change
@@ -1425,36 +1425,41 @@ interface Suspending {
1425
1425
The algorithm to <dfn>run a Promising function</dfn> from the JavaScript object |wasmFunc| and a [=list=] of [=WebAssembly values=] |arguments| consists of the following steps:
1426
1426
1. Let |promise| be a new [=PromiseCapabilityRecord=].
1427
1427
1. Let |funcaddr| be the value of |wasmFunc|'s \[[FunctionAddress]] internal slot.
1428
-
1. Let |runner| be a new [=AbstractClosure=] with no arguments that captures |promise|, |funcaddr|, and |arguments| that performs the following steps when called:
1429
-
1. Let |store| be the [=surrounding agent=]'s [=associated store=].
1430
-
1. Let |functype| be [=func_type=](|store|, |funcaddr|).
1431
-
1. Let |args| be the result of [=coerce JavaScript arguments|coercing arguments=] (|functype|,|arguments|)
1432
-
1. Let |map| be the [=surrounding agent=]'s associated [=Execution Context Status map=].
1433
-
1. Let |ec| be the currently executing [=execution context=], i.e., the [=execution context=] that is at the top of the [=surrounding agent=]'s current [=execution context stack=].
1434
-
1. Assert: |map| does not contain any entry for |ec|.
1435
-
1. Add an entry mapping |ec| to [=active=] in |map|.
1436
-
1. Let (|store|, |result|) be the result of [=func_invoke=](|store|, |funcaddr|, |args|).
1437
-
1. Assert: if control reaches here, we have done waiting for suspended imports
1438
-
1. If the entry for |ec| in |map| is not [=active=] then trap. Otherwise, remove the entry for |ec| from [=map=].
1439
-
1. Set the [=surrounding agent=]'s [=associated store=] to |store|.
1440
-
1. If |result| is [=error=], throw an exception. This exception should be a WebAssembly {{RuntimeError}} exception, unless otherwise indicated by <a href="#errors">the WebAssembly error mapping</a>.
1441
-
1. Otherwise, if |result| is of the form [=throw=] exnaddr,
1. Let |runner| be a new [=AbstractClosure=] with no arguments that captures |promise|, |funcaddr|, and |arguments| that performs [=evaluate a Promising function=](|promise|,|funcaddr|,|arguments|)
1453
1429
1. Let |con| be [=CreateBuiltinFunction=](|runner|,0,"",<<>>)
1454
1430
1. Perform [$Call$](|con|, undefined, <<>>)
1455
1431
1. Returns |promise|
1456
1432
</div>
1457
1433
1434
+
<div algorithm>
1435
+
The algorithm to <dfn>evaluate a Promising function</dfn>(|promise|, |funcaddr|, |arguments|) consists of the following steps:
1436
+
1. Let |store| be the [=surrounding agent=]'s [=associated store=].
1437
+
1. Let |functype| be [=func_type=](|store|, |funcaddr|).
1438
+
1. Let |args| be the result of [=coerce JavaScript arguments|coercing arguments=] (|functype|,|arguments|)
1439
+
1. Let |map| be the [=surrounding agent=]'s associated [=Execution Context Status map=].
1440
+
1. Let |ec| be the currently executing [=execution context=], i.e., the [=execution context=] that is at the top of the [=surrounding agent=]'s current [=execution context stack=].
1441
+
1. Assert: |map| does not contain any entry for |ec|.
1442
+
1. Add an entry mapping |ec| to [=active=] in |map|.
1443
+
1. Let (|store|, |result|) be the result of [=func_invoke=](|store|, |funcaddr|, |args|).
1444
+
1. Assert: if control reaches here, we have done waiting for suspended imports
1445
+
1. If the entry for |ec| in |map| is not [=active=] then trap. Otherwise, remove the entry for |ec| from [=map=].
1446
+
1. Set the [=surrounding agent=]'s [=associated store=] to |store|.
1447
+
1. If |result| is [=error=], throw an exception. This exception should be a WebAssembly {{RuntimeError}} exception, unless otherwise indicated by <a href="#errors">the WebAssembly error mapping</a>.
1448
+
1. Otherwise, if |result| is of the form [=throw=] exnaddr,
Note: The extra |$Call$| in the above algorithm ensures that the creation of the Promise is separated from the fullfilling of that Promise. In effect, this allows suspension of the fullfillment to occur whilst allowing the creation of the Promise itself to continue.
1459
1464
1460
1465
<div algorithm>
@@ -1499,7 +1504,8 @@ To <dfn>create a suspending function</dfn> from a JavaScript function |func|, wi
1499
1504
1. Let |rejected| be an [=AbstractClosure=] with parameters (|e|) that captures |async_context| and performs the following steps when called:
1500
1505
1. Perform the [=Reject=] procedure, passing it the captured continuation |k| the exception value |e| and |async_context|.
1501
1506
1. Let |onRejected| be [=CreateBuiltinFunction=](|rejected|,1,"",[])
0 commit comments