diff --git a/document/js-api/index.bs b/document/js-api/index.bs index d6cabb20f3..2da7003776 100644 --- a/document/js-api/index.bs +++ b/document/js-api/index.bs @@ -51,6 +51,9 @@ urlPrefix: https://webassembly.github.io/spec/core/; spec: WebAssembly; type: df url: valid/modules.html#valid-module text: valid text: WebAssembly module validation + text: valid limits; url: valid/types.html#valid-limits + text: valid memtype; url: valid/types.html#valid-memtype + text: valid tabletype; url: valid/types.html#valid-tabletype text: module grammar; url: binary/modules.html#binary-module text: custom section; url: binary/modules.html#custom-section text: customsec; url: binary/modules.html#binary-customsec @@ -98,9 +101,11 @@ urlPrefix: https://webassembly.github.io/spec/core/; spec: WebAssembly; type: df text: global_write; url: appendix/embedding.html#embed-global-write text: error; url: appendix/embedding.html#embed-error text: store; url: exec/runtime.html#syntax-store + text: limits; url: syntax/types.html#syntax-limits text: table type; url: syntax/types.html#syntax-tabletype text: table address; url: exec/runtime.html#syntax-tableaddr text: function address; url: exec/runtime.html#syntax-funcaddr + text: memory type; url: syntax/types.html#syntax-memtype text: memory address; url: exec/runtime.html#syntax-memaddr text: global address; url: exec/runtime.html#syntax-globaladdr text: extern address; url: exec/runtime.html#syntax-externaddr @@ -658,8 +663,8 @@ which can be simultaneously referenced by multiple {{Instance}} objects. Each The Memory(|descriptor|) constructor, when invoked, performs the following steps: 1. Let |initial| be |descriptor|["initial"]. 1. If |descriptor|["maximum"] [=map/exists=], let |maximum| be |descriptor|["maximum"]; otherwise, let |maximum| be empty. - 1. If |maximum| is not empty and |maximum| < |initial|, throw a {{RangeError}} exception. - 1. Let |memtype| be { min |initial|, max |maximum| }. + 1. Let |memtype| be the [=memory type=] { [=limits|min=] |initial|, [=limits|max=] |maximum| }. + 1. If |memtype| is not [=valid memtype|valid=], throw a {{RangeError}} exception. 1. Let |store| be the [=surrounding agent=]'s [=associated store=]. 1. Let (|store|, |memaddr|) be [=mem_alloc=](|store|, |memtype|). If allocation fails, throw a {{RangeError}} exception. 1. Set the [=surrounding agent=]'s [=associated store=] to |store|. @@ -819,14 +824,16 @@ Each {{Table}} object has a \[[Table]] internal slot, which is a [=table address 1. [=Throw=] a {{TypeError}} exception. 1. Let |initial| be |descriptor|["initial"]. 1. If |descriptor|["maximum"] [=map/exists=], let |maximum| be |descriptor|["maximum"]; otherwise, let |maximum| be empty. - 1. If |maximum| is not empty and |maximum| < |initial|, throw a {{RangeError}} exception. + 1. Let |type| be the [=table type=] { [=limits|min=] |initial|, [=limits|max=] |maximum| } |elementType|. + 1. If |type| is not [=valid tabletype|valid=], throw a {{RangeError}} exception. + + Note: Because tables may have up to 232 - 1 elements in validation, the checks for [=limits|min=] ≤ 232 - 1 and [=limits|max=] ≤ 232 - 1 in [=valid limits|limits validation=] cannot fail. 1. If |value| is missing, 1. Let |ref| be [=DefaultValue=](|elementType|). 1. Otherwise, 1. Let |ref| be [=?=] [=ToWebAssemblyValue=](|value|, |elementType|). - 1. Let |type| be the [=table type=] {[=table type|min=] |initial|, [=table type|max=] |maximum|} |elementType|. 1. Let |store| be the [=surrounding agent=]'s [=associated store=]. - 1. Let (|store|, |tableaddr|) be [=table_alloc=](|store|, |type|, |ref|). + 1. Let (|store|, |tableaddr|) be [=table_alloc=](|store|, |type|, |ref|). If allocation fails, throw a {{RangeError}} exception. 1. Set the [=surrounding agent=]'s [=associated store=] to |store|. 1. [=initialize a table object|Initialize=] **this** from |tableaddr|.