diff options
| author | rossberg-chromium <rossberg@chromium.org> | 2017-05-15 11:17:30 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-05-15 11:17:30 +0200 |
| commit | bc1ccfc751c5cac5f225996a9439e761088c3c2d (patch) | |
| tree | 5fdb5e62124c46fdc140c1028073869d17e171d6 | |
| parent | e330cb8d3c30ad4d1e2522b1b3ad5c829dd01c0d (diff) | |
Clarify generativity of JS host functions values (#987)
| -rw-r--r-- | JS.md | 15 |
1 files changed, 8 insertions, 7 deletions
@@ -309,6 +309,12 @@ is thrown. If the list of is not empty and `Type(importObject)` is not Object, a [`TypeError`](https://tc39.github.io/ecma262/#sec-native-error-types-used-in-this-standard-typeerror) is thrown. +Note: Imported JavaScript functions are wrapped as [host function](https://github.com/WebAssembly/spec/blob/master/interpreter/spec/instance.ml#L9) values in the following algorithm. For the purpose of the algorithm, a _new_ [host function](https://github.com/WebAssembly/spec/blob/master/interpreter/spec/instance.ml#L9) value is always generated fresh and considered distinct from any other previously created host function value, including those wrapping the same JavaScript function object. +Consequently, two [closure](https://github.com/WebAssembly/spec/blob/master/interpreter/spec/instance.ml#L7) values are considered equal if and only if: + +* Either they are both WebAssembly functions for the same instance and referring to the same function definition. +* Or they are the same host function value. + Let `funcs`, `memories` and `tables` be initially-empty lists of callable JavaScript objects, `WebAssembly.Memory` objects and `WebAssembly.Table` objects, respectively. Let `imports` be an initially-empty list of [`external`](https://github.com/WebAssembly/spec/blob/master/interpreter/spec/instance.ml#L11) values. @@ -329,8 +335,8 @@ For each [`import`](https://github.com/WebAssembly/spec/blob/master/interpreter/ by `Eval.init` below.) 1. Let `closure` be `v.[[Closure]]`. 1. Otherwise: - 1. Let `closure` be a new [host function](https://github.com/WebAssembly/spec/blob/master/interpreter/spec/instance.ml#L9) - of the given signature: + 1. Let `closure` be a new [host function](https://github.com/WebAssembly/spec/blob/master/interpreter/spec/instance.ml#L9) value + of the given signature and the following behavior: 1. If the signature contains an `i64` (as argument or result), the host function immediately throws a [`TypeError`](https://tc39.github.io/ecma262/#sec-native-error-types-used-in-this-standard-typeerror) when called. @@ -437,11 +443,6 @@ each [external](https://github.com/WebAssembly/spec/blob/master/interpreter/spec 1. Assert: There is an element `table` in `tables` whose `table.[[Table]]` is `t`. 1. Return that `table`. -Note: For the purpose of the above algorithm, two [closure](https://github.com/WebAssembly/spec/blob/master/interpreter/spec/instance.ml#L7) values are considered equal if and only if: - -* Either they are both WebAssembly functions for the same instance and referring to the same function definition. -* Or they are identical host functions (i.e., each host function value created from a JavaScript function is considered fresh). - Let `exportsObject` be a new [frozen](https://tc39.github.io/ecma262/#sec-object.freeze) plain JS object with [[Prototype]] set to Null and with properties defined by mapping each export in `exports` to an enumerable, non-writable, |
