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-12Lines changed: 15 additions & 12 deletions
Original file line number
Diff line number
Diff line change
@@ -425,13 +425,15 @@ A {{Module}} object represents a single WebAssembly module. Each {{Module}} obje
425
425
1. Let |module| be |moduleObject|.\[[Module]].
426
426
1. [=Read the imports=] of |module| with imports |importObject|, and let |imports| be the result.
427
427
If this operation throws an exception, catch it, [=reject=] |promise| with the exception, and return |promise|.
428
-
1. [=Queue a task=] to perform the following steps:
429
-
1. [=Instantiate the core of a WebAssembly module=] |module| with |imports|, and let |instance| be the result.
430
-
If this throws an exception, catch it, [=reject=] |promise| with the exception, and terminate these substeps.
431
-
1. Let |instanceObject| be a [=/new=]{{Instance}}.
432
-
1. [=initialize an instance object|Initialize=] |instanceObject| from |module| and |instance|.
433
-
If this throws an exception, catch it, [=reject=] |promise| with the exception, and terminate these substeps.
434
-
1. [=Resolve=] |promise| with |instanceObject|.
428
+
1. Run the following steps [=in parallel=]:
429
+
1. [=Queue a task=] to perform the following steps:
430
+
Note: Implementation-specific work may be performed here.
431
+
1. [=Instantiate the core of a WebAssembly module=] |module| with |imports|, and let |instance| be the result.
432
+
If this throws an exception, catch it, [=reject=] |promise| with the exception, and terminate these substeps.
433
+
1. Let |instanceObject| be a [=/new=]{{Instance}}.
434
+
1. [=initialize an instance object|Initialize=] |instanceObject| from |module| and |instance|.
435
+
If this throws an exception, catch it, [=reject=] |promise| with the exception, and terminate these substeps.
436
+
1. [=Resolve=] |promise| with |instanceObject|.
435
437
1. Return |promise|.
436
438
</div>
437
439
@@ -450,14 +452,15 @@ A {{Module}} object represents a single WebAssembly module. Each {{Module}} obje
450
452
451
453
1. Let |promise| be [=a new promise=]
452
454
1. [=Upon fulfillment=] of |promiseOfModule| with value |module|:
453
-
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.
454
-
1. Let |result| be a {{WebAssemblyInstantiatedSource}} dictionary with {{WebAssemblyInstantiatedSource/module}} set to |module| and {{WebAssemblyInstantiatedSource/instance}} set to |instance|.
455
-
1. [=Resolve=] |promise| with |result|.
455
+
1. [=asynchronously instantiate a WebAssembly module|Instantiate the WebAssembly module=] |module| importing |importObject|, and let |innerPromise| be the result.
456
+
1. [=Upon fulfillment=] of |innerPromise| with value |instance|.
457
+
1. Let |result| be a {{WebAssemblyInstantiatedSource}} dictionary with {{WebAssemblyInstantiatedSource/module}} set to |module| and {{WebAssemblyInstantiatedSource/instance}} set to |instance|.
458
+
1. [=Resolve=] |promise| with |result|.
459
+
1. [=Upon rejection=] of |innerPromise| with reason |reason|:
460
+
1. [=Reject=] |promise| with |reason|.
456
461
1. [=Upon rejection=] of |promiseOfModule| with reason |reason|:
457
462
1. [=Reject=] |promise| with |reason|.
458
463
1. Return |promise|.
459
-
460
-
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