|
| 1 | +<pre class='metadata'> |
| 2 | +Title: WebAssembly JavaScript Interface |
| 3 | +Shortname: wasm-js-api |
| 4 | +Group: wasm |
| 5 | +Status: ED |
| 6 | +Level: 1 |
| 7 | +TR: https://www.w3.org/TR/wasm-js-api-1/ |
| 8 | +ED: https://webassembly.github.io/spec/js-api/ |
| 9 | +Editor: Ms2ger (Igalia) |
| 10 | +Repository: WebAssembly/spec |
| 11 | +Markup Shorthands: css no, markdown yes |
| 12 | +Abstract: This document provides an explicit JavaScript API for interacting with WebAssembly. |
| 13 | +Prepare For TR: true |
| 14 | +</pre> |
| 15 | + |
| 16 | +<pre class='biblio'> |
| 17 | +{ |
| 18 | + "WEBASSEMBLY": { |
| 19 | + "href": "https://webassembly.github.io/spec/core/", |
| 20 | + "title": "WebAssembly Core Specification", |
| 21 | + "publisher": "W3C WebAssembly Community Group", |
| 22 | + "status": "Draft" |
| 23 | + } |
| 24 | +} |
| 25 | +</pre> |
| 26 | + |
| 27 | +<pre class="anchors"> |
| 28 | +urlPrefix: https://tc39.github.io/ecma262/; spec: ECMASCRIPT |
| 29 | + type: interface; for: ECMAScript |
| 30 | + text: ArrayBuffer; url: sec-arraybuffer-objects |
| 31 | + type: exception; for: ECMAScript |
| 32 | + text: Error; url: sec-error-objects |
| 33 | + text: NativeError; url: sec-nativeerror-constructors |
| 34 | + text: TypeError; url: sec-native-error-types-used-in-this-standard-typeerror |
| 35 | + text: RangeError; url: sec-native-error-types-used-in-this-standard-rangeerror |
| 36 | + type: dfn |
| 37 | + text: agent cluster; url: sec-agent-clusters |
| 38 | + text: agent; url: agent |
| 39 | + text: data block; url: sec-data-blocks |
| 40 | + text: Bound Function; url: sec-bound-function-exotic-objects |
| 41 | + text: NumericLiteral; url: sec-literals-numeric-literals |
| 42 | + text: surrounding agent; url: surrounding-agent |
| 43 | + text: ToNumber; url: sec-tonumber |
| 44 | + text: ToInt32; url: sec-toint32 |
| 45 | + text: ToString; url: sec-tostring |
| 46 | + url: sec-ecmascript-data-types-and-values |
| 47 | + text: Type |
| 48 | + text: Type(x) |
| 49 | + url: sec-iscallable |
| 50 | + text: IsCallable |
| 51 | + text: callable; for: ECMAScript |
| 52 | + url: sec-well-known-intrinsic-objects |
| 53 | + text: %ErrorPrototype% |
| 54 | + text: %ObjectPrototype%; url: sec-properties-of-the-object-prototype-object |
| 55 | + text: %FunctionPrototype%; url: sec-properties-of-the-function-prototype-object |
| 56 | + text: %Promise%; url: sec-promise-constructor |
| 57 | + text: Property Descriptor; url: sec-property-descriptor-specification-type |
| 58 | + text: array index; url: sec-array-exotic-objects |
| 59 | + text: OrdinaryGetOwnProperty; url: sec-ordinarygetownproperty |
| 60 | + text: OrdinaryDefineOwnProperty; url: sec-ordinarydefineownproperty |
| 61 | + text: OrdinaryPreventExtensions; url: sec-ordinarypreventextensions |
| 62 | + text: OrdinarySet; url: sec-ordinaryset |
| 63 | + text: equally close values; url: sec-ecmascript-language-types-number-type |
| 64 | + text: internal slot; url: sec-object-internal-methods-and-internal-slots |
| 65 | + text: JavaScript execution context stack; url: execution-context-stack |
| 66 | + text: running JavaScript execution context; url: running-execution-context |
| 67 | + text: GetIterator; url: sec-getiterator |
| 68 | + text: IteratorStep; url: sec-iteratorstep |
| 69 | + text: NormalCompletion; url: sec-normalcompletion |
| 70 | + text: IteratorValue; url: sec-iteratorvalue |
| 71 | + url: sec-well-known-symbols |
| 72 | + text: @@iterator |
| 73 | + text: @@toStringTag |
| 74 | + text: CreateDataProperty; url: sec-createdataproperty |
| 75 | + text: DetachArrayBuffer; url: sec-detacharraybuffer |
| 76 | + text: SetIntegrityLevel; url: sec-setintegritylevel |
| 77 | + text: Call; url: sec-call |
| 78 | + text: Get; url: sec-get-o-p |
| 79 | + text: DefinePropertyOrThrow; url: sec-definepropertyorthrow |
| 80 | + text: current Realm; url: current-realm |
| 81 | + text: ObjectCreate; url: sec-objectcreate |
| 82 | + text: CreateBuiltinFunction; url: sec-createbuiltinfunction |
| 83 | + text: SetFunctionName; url: sec-setfunctionname |
| 84 | + text: SetFunctionLength; url: sec-setfunctionlength |
| 85 | + text: the Number value; url: sec-ecmascript-language-types-number-type |
| 86 | + text: NumberToRawBytes; url: sec-numbertorawbytes |
| 87 | + text: Built-in Function Objects; url: sec-built-in-function-objects |
| 88 | + text: NativeError Object Structure; url: sec-nativeerror-object-structure |
| 89 | + text: CreateArrayFromList; url: sec-createarrayfromlist |
| 90 | + text: GetMethod; url: sec-getmethod |
| 91 | + text: IterableToList; url: sec-iterabletolist |
| 92 | + text: ToBigInt64; url: #sec-tobigint64 |
| 93 | + text: BigInt; url: #sec-ecmascript-language-types-bigint-type |
| 94 | + type: abstract-op |
| 95 | + text: CreateMethodProperty; url: sec-createmethodproperty |
| 96 | +urlPrefix: https://webassembly.github.io/spec/core/; spec: WebAssembly; type: dfn |
| 97 | + url: valid/modules.html#valid-module |
| 98 | + text: valid |
| 99 | + text: WebAssembly module validation |
| 100 | + text: module grammar; url: binary/modules.html#binary-module |
| 101 | + text: custom section; url: binary/modules.html#custom-section |
| 102 | + text: customsec; url: binary/modules.html#binary-customsec |
| 103 | + text: memory instance; url: exec/runtime.html#memory-instances |
| 104 | + text: table instance; url: exec/runtime.html#table-instances |
| 105 | + text: global instance; url: exec/runtime.html#global-instances |
| 106 | + text: trap; url: exec/runtime.html#syntax-trap |
| 107 | + url: exec/runtime.html#values |
| 108 | + text: WebAssembly value |
| 109 | + text: i64.const |
| 110 | + text: i32.const |
| 111 | + text: f32.const |
| 112 | + text: f64.const |
| 113 | + text: ref.null |
| 114 | + text: ref.func |
| 115 | + text: ref.extern |
| 116 | + text: function index; url: syntax/modules.html#syntax-funcidx |
| 117 | + text: function instance; url: exec/runtime.html#function-instances |
| 118 | + text: store_init; url: appendix/embedding.html#embed-store-init |
| 119 | + text: module_decode; url: appendix/embedding.html#embed-module-decode |
| 120 | + text: module_validate; url: appendix/embedding.html#embed-module-validate |
| 121 | + text: module_instantiate; url: appendix/embedding.html#embed-module-instantiate |
| 122 | + text: module_imports; url: appendix/embedding.html#embed-module-imports |
| 123 | + text: module_exports; url: appendix/embedding.html#embed-module-exports |
| 124 | + text: instance_export; url: appendix/embedding.html#embed-instance-export |
| 125 | + text: func_alloc; url: appendix/embedding.html#embed-func-alloc |
| 126 | + text: func_type; url: appendix/embedding.html#embed-func-type |
| 127 | + text: func_invoke; url: appendix/embedding.html#embed-func-invoke |
| 128 | + text: table_alloc; url: appendix/embedding.html#embed-table-alloc |
| 129 | + text: table_type; url: appendix/embedding.html#embed-table-type |
| 130 | + text: table_read; url: appendix/embedding.html#embed-table-read |
| 131 | + text: table_write; url: appendix/embedding.html#embed-table-write |
| 132 | + text: table_size; url: appendix/embedding.html#embed-table-size |
| 133 | + text: table_grow; url: appendix/embedding.html#embed-table-grow |
| 134 | + text: mem_alloc; url: appendix/embedding.html#embed-mem-alloc |
| 135 | + text: mem_type; url: appendix/embedding.html#embed-mem-type |
| 136 | + text: mem_read; url: appendix/embedding.html#embed-mem-read |
| 137 | + text: mem_write; url: appendix/embedding.html#embed-mem-write |
| 138 | + text: mem_size; url: appendix/embedding.html#embed-mem-size |
| 139 | + text: mem_grow; url: appendix/embedding.html#embed-mem-grow |
| 140 | + text: global_alloc; url: appendix/embedding.html#embed-global-alloc |
| 141 | + text: global_type; url: appendix/embedding.html#embed-global-type |
| 142 | + text: global_read; url: appendix/embedding.html#embed-global-read |
| 143 | + text: global_write; url: appendix/embedding.html#embed-global-write |
| 144 | + text: error; url: appendix/embedding.html#embed-error |
| 145 | + text: store; url: exec/runtime.html#syntax-store |
| 146 | + text: table type; url: syntax/types.html#syntax-tabletype |
| 147 | + text: table address; url: exec/runtime.html#syntax-tableaddr |
| 148 | + text: function address; url: exec/runtime.html#syntax-funcaddr |
| 149 | + text: memory address; url: exec/runtime.html#syntax-memaddr |
| 150 | + text: global address; url: exec/runtime.html#syntax-globaladdr |
| 151 | + text: extern address; url: exec/runtime.html#syntax-externaddr |
| 152 | + url: syntax/types.html#syntax-numtype |
| 153 | + text: i32 |
| 154 | + text: i64 |
| 155 | + text: f32 |
| 156 | + text: f64 |
| 157 | + url: syntax/types.html#syntax-reftype |
| 158 | + text: reftype |
| 159 | + text: funcref |
| 160 | + text: externref |
| 161 | + text: function element; url: exec/runtime.html#syntax-funcelem |
| 162 | + text: import component; url: syntax/modules.html#imports |
| 163 | + text: external value; url: exec/runtime.html#syntax-externval |
| 164 | + text: host function; url: exec/runtime.html#syntax-hostfunc |
| 165 | + text: the instantiation algorithm; url: exec/modules.html#instantiation |
| 166 | + text: module; url: syntax/modules.html#syntax-module |
| 167 | + text: imports; url: syntax/modules.html#syntax-module |
| 168 | + text: import; url: syntax/modules.html#syntax-import |
| 169 | + url: syntax/types.html#external-types |
| 170 | + text: external type |
| 171 | + text: func |
| 172 | + text: table |
| 173 | + text: mem |
| 174 | + text: global |
| 175 | + text: global type; url: syntax/types.html#syntax-globaltype |
| 176 | + url: syntax/types.html#syntax-mut |
| 177 | + text: var |
| 178 | + text: const |
| 179 | + text: address; url: exec/runtime.html#addresses |
| 180 | + text: signed_32; url: exec/numerics.html#aux-signed |
| 181 | + text: memory.grow; url: exec/instructions.html#exec-memory-grow |
| 182 | + text: current frame; url: exec/conventions.html#exec-notation-textual |
| 183 | + text: module; for: frame; url: exec/runtime.html#syntax-frame |
| 184 | + text: memaddrs; for: moduleinst; url: exec/runtime.html#syntax-moduleinst |
| 185 | + text: signed_64; url: exec/numerics.html#aux-signed |
| 186 | + text: sequence; url: syntax/conventions.html#grammar-notation |
| 187 | +urlPrefix: https://heycam.github.io/webidl/; spec: WebIDL |
| 188 | + type: dfn |
| 189 | + text: create a namespace object; url: create-a-namespace-object |
| 190 | +</pre> |
| 191 | + |
| 192 | +<pre class='link-defaults'> |
| 193 | +spec:infra; type:dfn; text:list |
| 194 | +spec:ecma-262; type:exception; for:ECMAScript; text:Error |
| 195 | +spec:ecmascript; type:exception; for:ECMAScript; text:TypeError |
| 196 | +spec:ecmascript; type:exception; for:ECMAScript; text:RangeError |
| 197 | +spec:ecmascript; type:interface; for:ECMAScript; text:ArrayBuffer |
| 198 | +spec:webidl; type:dfn; text:resolve |
| 199 | +</pre> |
| 200 | + |
| 201 | +<style> |
| 202 | +emu-const { |
| 203 | + font-family: serif; |
| 204 | +} |
| 205 | +</style> |
| 206 | + |
| 207 | +This API provides a way to access WebAssembly [[WEBASSEMBLY]] through a bridge to explicitly construct modules from JavaScript [[ECMASCRIPT]]. |
| 208 | + |
| 209 | +<h2 id="sample">Sample API Usage</h2> |
| 210 | + |
| 211 | +<p><em>This section is non-normative.</em></p> |
0 commit comments