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
[jsapi] Normative: Always queue a task during asynchronous instantiation
JSC will have to do asynchronous compilation work during some instantiations.
To be consistent, this PR always queues a task to complete instantiation,
except through the synchronous Instance(module) API, to ensure consistency
across platforms.
This patch also cleans up the specification in various surrounding ways:
- Include notes about APIs whose use is discouraged/may be limited
Closes#741
See also webpack/webpack#6433
Copy file name to clipboardExpand all lines: document/js-api/index.bs
+15-12
Original file line number
Diff line number
Diff line change
@@ -474,13 +474,15 @@ The verification of WebAssembly type requirements is deferred to the
474
474
1. Let |module| be |moduleObject|.\[[Module]].
475
475
1. [=Read the imports=] of |module| with imports |importObject|, and let |imports| be the result.
476
476
If this operation throws an exception, catch it, [=reject=] |promise| with the exception, and return |promise|.
477
-
1. [=Queue a task=] to perform the following steps:
478
-
1. [=Instantiate the core of a WebAssembly module=] |module| with |imports|, and let |instance| be the result.
479
-
If this throws an exception, catch it, [=reject=] |promise| with the exception, and terminate these substeps.
480
-
1. Let |instanceObject| be a [=/new=]{{Instance}}.
481
-
1. [=initialize an instance object|Initialize=] |instanceObject| from |module| and |instance|.
482
-
If this throws an exception, catch it, [=reject=] |promise| with the exception, and terminate these substeps.
483
-
1. [=Resolve=] |promise| with |instanceObject|.
477
+
1. Run the following steps [=in parallel=]:
478
+
1. [=Queue a task=] to perform the following steps:
479
+
Note: Implementation-specific work may be performed here.
480
+
1. [=Instantiate the core of a WebAssembly module=] |module| with |imports|, and let |instance| be the result.
481
+
If this throws an exception, catch it, [=reject=] |promise| with the exception, and terminate these substeps.
482
+
1. Let |instanceObject| be a [=/new=]{{Instance}}.
483
+
1. [=initialize an instance object|Initialize=] |instanceObject| from |module| and |instance|.
484
+
If this throws an exception, catch it, [=reject=] |promise| with the exception, and terminate these substeps.
485
+
1. [=Resolve=] |promise| with |instanceObject|.
484
486
1. Return |promise|.
485
487
</div>
486
488
@@ -499,14 +501,15 @@ The verification of WebAssembly type requirements is deferred to the
499
501
500
502
1. Let |promise| be [=a new promise=].
501
503
1. [=Upon fulfillment=] of |promiseOfModule| with value |module|:
502
-
1. [=synchronously instantiate a WebAssembly module|Synchronously instantiate the WebAssembly module=] |module| importing |importObject|, and let |instance| be the result. If this throws an exception, catch it, [=reject=] |promise| with the exception, and abort these substeps.
503
-
1. Let |result| be the {{WebAssemblyInstantiatedSource}} value «[ "{{WebAssemblyInstantiatedSource/module}}" → |module|, "{{WebAssemblyInstantiatedSource/instance}}" → |instance| ]».
504
-
1. [=Resolve=] |promise| with |result|.
504
+
1. [=asynchronously instantiate a WebAssembly module|Instantiate the WebAssembly module=] |module| importing |importObject|, and let |innerPromise| be the result.
505
+
1. [=Upon fulfillment=] of |innerPromise| with value |instance|.
506
+
1. Let |result| be the {{WebAssemblyInstantiatedSource}} value «[ "{{WebAssemblyInstantiatedSource/module}}" → |module|, "{{WebAssemblyInstantiatedSource/instance}}" → |instance| ]».
507
+
1. [=Resolve=] |promise| with |result|.
508
+
1. [=Upon rejection=] of |innerPromise| with reason |reason|:
509
+
1. [=Reject=] |promise| with |reason|.
505
510
1. [=Upon rejection=] of |promiseOfModule| with reason |reason|:
506
511
1. [=Reject=] |promise| with |reason|.
507
512
1. Return |promise|.
508
-
509
-
Note: It would be valid to perform certain parts of the instantiation [=in parallel=], but several parts need to happen in the event loop, including JavaScript operations to access the |importObject| and execution of the start function.
0 commit comments