@@ -199,11 +199,10 @@ function, global, memory and table imports):
199
199
throw a [ ` TypeError ` ] ( https://tc39.github.io/ecma262/#sec-native-error-types-used-in-this-standard-typeerror ) .
200
200
* Otherwise, append ` v.[[Table]] ` to ` imports ` .
201
201
202
- Let ` instance ` be the result of evaluating
203
- [ ` Eval.init ` ] ( https://github.com/WebAssembly/spec/blob/master/ml-proto/spec/eval.ml#L319 )
204
- with arguments ` module ` and ` imports ` .
205
- Note: this synchronously executes the [ ` start ` ] ( Modules.md#module-start-function )
206
- function, if present.
202
+ Let ` instance ` be the result of creating a new
203
+ [ ` Eval.instance ` ] ( https://github.com/WebAssembly/spec/blob/master/ml-proto/spec/eval.ml#L15 )
204
+ given ` module ` and ` imports ` . Note: this step does not mutate imported memories
205
+ or tables.
207
206
208
207
Let ` exports ` be a list of (string, JS value) pairs that is mapped from
209
208
` module.exports ` as follows (assuming the ML spec
@@ -215,11 +214,12 @@ has been modified so that each export simply has a `name`, `type` and `index`:
215
214
* If the ` type ` is function, then export an
216
215
[ Exported Function Exotic Object] ( #exported-function-exotic-objects ) ,
217
216
reusing an existing object if one exists for the given function definition,
218
- otherwise creating a new object.
217
+ otherwise creating a new object given ` instance ` and ` index ` .
219
218
* If the ` type ` is global:
220
- * If the global is not immutable, then throw a [ ` TypeError ` ] ( https://tc39.github.io/ecma262/#sec-native-error-types-used-in-this-standard-typeerror ) .
219
+ * [ Assert] ( https://tc39.github.io/ecma262/#assert ) : the global is immutable
220
+ by MVP validation constraint.
221
221
* Let ` v ` be the global variable's initialized value.
222
- * Otherwise, export [ ` ToJSValue ` ] ( #tojsvalue ) ` (v) ` .
222
+ * Export [ ` ToJSValue ` ] ( #tojsvalue ) ` (v) ` .
223
223
* If the ` type ` is memory, then export a ` WebAssembly.Memory ` object, reusing
224
224
an existing object if one exists for the given memory definition, otherwise
225
225
creating a new object via [ ` CreateMemoryObject ` ] ( #creatememoryobject ) .
@@ -243,8 +243,30 @@ of `exports`. Let `moduleNamespace` be the result of calling
243
243
[ ` ModuleNamespaceCreate(moduleRecord, exportStrings) ` ] ( http://tc39.github.io/ecma262/#sec-modulenamespacecreate ) .
244
244
Set ` moduleRecord.[[Namespace]] ` to ` moduleNamespace ` .
245
245
246
- Return a new ` WebAssembly.Instance ` object setting ` [[Instance]] ` to ` instance `
247
- and ` exports ` to ` moduleNamespace ` .
246
+ Let ` instanceObject ` be a new ` WebAssembly.Instance ` object setting
247
+ ` [[Instance]] ` to ` instance ` and ` exports ` to ` moduleNamespace ` .
248
+
249
+ If any of the elements of an [ Elements section] ( Modules.md#elements-section )
250
+ refers to an imported function which is not an
251
+ [ Exported Function Exotic Object] ( #exported-function-exotic-objects ) , throw a
252
+ [ ` TypeError ` ] ( https://tc39.github.io/ecma262/#sec-native-error-types-used-in-this-standard-typeerror ) .
253
+
254
+ If, after evaluating the ` offset ` [ initializer expression] ( Modules.md#initializer-expression )
255
+ of every [ Data] ( Modules.md#data-section ) and [ Element] ( Modules.md#elements-section )
256
+ Segment, any of the segments do not fit in their respective Memory or Table, throw a
257
+ [ ` RangeError ` ] ( https://tc39.github.io/ecma262/#sec-native-error-types-used-in-this-standard-rangeerror ) .
258
+
259
+ Apply all Data and Element segments to their respective Memory or Table in the
260
+ order in which they appear in the module. Segments may overlap and, if they do,
261
+ the final value is the last value written in order. Note: there should be no
262
+ errors possible that would cause this operation to fail partway through. After
263
+ this operation completes, elements of ` instance ` are visible and callable
264
+ through [ imported Tables] ( Modules.md#imports ) , even if ` start ` fails.
265
+
266
+ If a [ ` start ` ] ( Modules.md#module-start-function ) is present, it is evaluated
267
+ given ` instance ` . Any errors thrown by ` start ` are propagated to the caller.
268
+
269
+ Return ` instanceObject ` .
248
270
249
271
### WebAssembly Module Record
250
272
0 commit comments