Changeset 271112 in webkit
- Timestamp:
- Dec 30, 2020 4:04:56 PM (19 months ago)
- Location:
- trunk
- Files:
-
- 1 added
- 17 edited
-
JSTests/ChangeLog (modified) (1 diff)
-
JSTests/stress/sampling-profiler-wasm-name-section.js (modified) (1 diff)
-
JSTests/stress/sampling-profiler-wasm.js (modified) (1 diff)
-
JSTests/wasm/js-api/test_basic_api.js (modified) (1 diff)
-
JSTests/wasm/stress/exports-object.js (added)
-
LayoutTests/imported/w3c/ChangeLog (modified) (1 diff)
-
LayoutTests/imported/w3c/web-platform-tests/wasm/jsapi/constructor/instantiate.any-expected.txt (modified) (1 diff)
-
LayoutTests/imported/w3c/web-platform-tests/wasm/jsapi/constructor/instantiate.any.worker-expected.txt (modified) (1 diff)
-
LayoutTests/imported/w3c/web-platform-tests/wasm/jsapi/instance/constructor.any-expected.txt (modified) (1 diff)
-
LayoutTests/imported/w3c/web-platform-tests/wasm/jsapi/instance/constructor.any.worker-expected.txt (modified) (1 diff)
-
LayoutTests/imported/w3c/web-platform-tests/wasm/jsapi/table/grow-reftypes.tentative.any-expected.txt (modified) (1 diff)
-
Source/JavaScriptCore/ChangeLog (modified) (1 diff)
-
Source/JavaScriptCore/wasm/js/JSWebAssembly.cpp (modified) (2 diffs)
-
Source/JavaScriptCore/wasm/js/JSWebAssemblyInstance.cpp (modified) (6 diffs)
-
Source/JavaScriptCore/wasm/js/JSWebAssemblyInstance.h (modified) (4 diffs)
-
Source/JavaScriptCore/wasm/js/WebAssemblyInstancePrototype.cpp (modified) (2 diffs)
-
Source/JavaScriptCore/wasm/js/WebAssemblyModuleRecord.cpp (modified) (8 diffs)
-
Source/JavaScriptCore/wasm/js/WebAssemblyModuleRecord.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/JSTests/ChangeLog
r271100 r271112 1 2020-12-29 Yusuke Suzuki <ysuzuki@apple.com> 2 3 [JSC] Update WebAssembly instance's exports object 4 https://bugs.webkit.org/show_bug.cgi?id=220189 5 6 Reviewed by Alexey Shvayka. 7 8 * stress/sampling-profiler-wasm-name-section.js: 9 (platformSupportsSamplingProfiler.vm.isWasmSupported): 10 * stress/sampling-profiler-wasm.js: 11 (platformSupportsSamplingProfiler.vm.isWasmSupported): 12 * wasm/js-api/test_basic_api.js: 13 (const.c.in.constructorProperties.switch): 14 * wasm/stress/exports-object.js: Added. 15 (async try): 16 (catch): 17 1 18 2020-12-27 Dmitry Bezhetskov <dbezhetskov@igalia.com> 2 19 -
trunk/JSTests/stress/sampling-profiler-wasm-name-section.js
r264304 r271112 70 70 return instance.exports._parrot(1); 71 71 }; 72 runTest(wasmEntry, ["_silly", "(unknown)", "<?>.wasm-function[_eggs]", "<?>.wasm-function[_bacon]", "<?>.wasm-function[_spam]", "<?>.wasm-function[_parrot]", "wasm-stub", " _parrot", "wasmEntry"]);72 runTest(wasmEntry, ["_silly", "(unknown)", "<?>.wasm-function[_eggs]", "<?>.wasm-function[_bacon]", "<?>.wasm-function[_spam]", "<?>.wasm-function[_parrot]", "wasm-stub", "24", "wasmEntry"]); 73 73 } -
trunk/JSTests/stress/sampling-profiler-wasm.js
r264304 r271112 9 9 return instance.exports.loop(10000000); 10 10 }; 11 runTest(wasmEntry, ["<?>.wasm-function[0]", "wasm-stub", " loop", "wasmEntry"]);11 runTest(wasmEntry, ["<?>.wasm-function[0]", "wasm-stub", "0", "wasmEntry"]); 12 12 } -
trunk/JSTests/wasm/js-api/test_basic_api.js
r247457 r271112 85 85 assert.eq(Reflect.isExtensible(instance.exports), false); 86 86 assert.eq(Symbol.iterator in instance.exports, false); 87 assert.eq(Symbol.toStringTag in instance.exports, true); 88 assert.eq(Object.getOwnPropertySymbols(instance.exports).length, 1); 89 assert.eq(Object.getOwnPropertySymbols(instance.exports)[0], Symbol.toStringTag); 87 assert.eq(Symbol.toStringTag in instance.exports, false); 88 assert.eq(Object.getOwnPropertySymbols(instance.exports).length, 0); 90 89 assert.throws(() => instance.exports[Symbol.toStringTag] = 42, TypeError, `Attempted to assign to readonly property.`); 91 90 break; -
trunk/LayoutTests/imported/w3c/ChangeLog
r271092 r271112 1 2020-12-29 Yusuke Suzuki <ysuzuki@apple.com> 2 3 [JSC] Update WebAssembly instance's exports object 4 https://bugs.webkit.org/show_bug.cgi?id=220189 5 6 Reviewed by Alexey Shvayka. 7 8 * web-platform-tests/wasm/jsapi/constructor/instantiate.any-expected.txt: 9 * web-platform-tests/wasm/jsapi/constructor/instantiate.any.worker-expected.txt: 10 * web-platform-tests/wasm/jsapi/instance/constructor.any-expected.txt: 11 * web-platform-tests/wasm/jsapi/instance/constructor.any.worker-expected.txt: 12 * web-platform-tests/wasm/jsapi/table/grow-reftypes.tentative.any-expected.txt: 13 1 14 2020-12-26 Alexey Shvayka <shvaikalesh@gmail.com> 2 15 -
trunk/LayoutTests/imported/w3c/web-platform-tests/wasm/jsapi/constructor/instantiate.any-expected.txt
r269866 r271112 14 14 PASS imports: BufferSource argument 15 15 PASS imports: Module argument 16 FAIL No imports: BufferSource argument assert_array_equals: matching export keys expected property 2 to be "table" but got "global" (expected array ["fn", "fn2", "table", "global", "global2", "memory"] got ["fn", "fn2", "global", "global2", "memory", "table"]) 17 FAIL No imports: Module argument assert_array_equals: matching export keys expected property 2 to be "table" but got "global" (expected array ["fn", "fn2", "table", "global", "global2", "memory"] got ["fn", "fn2", "global", "global2", "memory", "table"]) 18 FAIL exports and imports: BufferSource argument assert_false: fn: writable expected false got true 19 FAIL exports and imports: Module argument assert_false: fn: writable expected false got true 16 PASS No imports: BufferSource argument 17 PASS No imports: Module argument 18 PASS exports and imports: BufferSource argument 19 PASS exports and imports: Module argument 20 20 FAIL i64 exports and imports: BufferSource argument promise_test: Unhandled rejection with value: object "LinkError: imported global module:global cannot be an i64" 21 21 FAIL i64 exports and imports: Module argument promise_test: Unhandled rejection with value: object "LinkError: imported global module:global cannot be an i64" 22 FAIL import with i32-returning function: BufferSource argument assert_false: fn2: writable expected false got true 23 FAIL import with i32-returning function: Module argument assert_false: fn2: writable expected false got true 24 FAIL import with function that takes and returns i32: BufferSource argument assert_false: fn2: writable expected false got true 25 FAIL import with function that takes and returns i32: Module argument assert_false: fn2: writable expected false got true 26 FAIL import with i64-returning function: BufferSource argument assert_false: fn2: writable expected false got true 27 FAIL import with i64-returning function: Module argument assert_false: fn2: writable expected false got true 28 FAIL import with function that takes and returns i64: BufferSource argument assert_false: fn2: writable expected false got true 29 FAIL import with function that takes and returns i64: Module argument assert_false: fn2: writable expected false got true 30 FAIL import with i32-taking function: BufferSource argument assert_false: fn: writable expected false got true 31 FAIL import with i32-taking function: Module argument assert_false: fn: writable expected false got true 32 FAIL import with i64-taking function: BufferSource argument assert_false: fn: writable expected false got true 33 FAIL import with i64-taking function: Module argument assert_false: fn: writable expected false got true 34 FAIL export i64-returning function: BufferSource argument assert_false: fn: writable expected false got true 35 FAIL export i64-returning function: Module argument assert_false: fn: writable expected false got true 36 FAIL i32 mutable WebAssembly.Global import: BufferSource argument assert_false: fn: writable expected false got true 37 FAIL i32 mutable WebAssembly.Global import: Module argument assert_false: fn: writable expected false got true 22 PASS import with i32-returning function: BufferSource argument 23 PASS import with i32-returning function: Module argument 24 PASS import with function that takes and returns i32: BufferSource argument 25 PASS import with function that takes and returns i32: Module argument 26 FAIL import with i64-returning function: BufferSource argument assert_true: Should have called into JS expected true got false 27 FAIL import with i64-returning function: Module argument assert_true: Should have called into JS expected true got false 28 FAIL import with function that takes and returns i64: BufferSource argument promise_test: Unhandled rejection with value: object "RuntimeError: WebAssembly function that returns i64 can't be called from JavaScript (evaluating 'instance.exports.fn2()')" 29 FAIL import with function that takes and returns i64: Module argument promise_test: Unhandled rejection with value: object "RuntimeError: WebAssembly function that returns i64 can't be called from JavaScript (evaluating 'instance.exports.fn2()')" 30 PASS import with i32-taking function: BufferSource argument 31 PASS import with i32-taking function: Module argument 32 FAIL import with i64-taking function: BufferSource argument assert_throws_js: function "() => instance.exports.fn(6)" threw object "RuntimeError: WebAssembly function with an i64 argument can't be called from JavaScript (evaluating 'instance.exports.fn(6)')" ("RuntimeError") expected instance of function "function TypeError() { 33 [native code] 34 }" ("TypeError") 35 FAIL import with i64-taking function: Module argument assert_throws_js: function "() => instance.exports.fn(6)" threw object "RuntimeError: WebAssembly function with an i64 argument can't be called from JavaScript (evaluating 'instance.exports.fn(6)')" ("RuntimeError") expected instance of function "function TypeError() { 36 [native code] 37 }" ("TypeError") 38 FAIL export i64-returning function: BufferSource argument promise_test: Unhandled rejection with value: object "RuntimeError: WebAssembly function that returns i64 can't be called from JavaScript (evaluating 'instance.exports.fn()')" 39 FAIL export i64-returning function: Module argument promise_test: Unhandled rejection with value: object "RuntimeError: WebAssembly function that returns i64 can't be called from JavaScript (evaluating 'instance.exports.fn()')" 40 PASS i32 mutable WebAssembly.Global import: BufferSource argument 41 PASS i32 mutable WebAssembly.Global import: Module argument 38 42 FAIL i64 mutable WebAssembly.Global import: BufferSource argument WebAssembly.Global does not accept i64 initial value 39 43 FAIL i64 mutable WebAssembly.Global import: Module argument WebAssembly.Global does not accept i64 initial value 40 FAIL Multiple i64 arguments: BufferSource argument assert_false: fn: writable expected false got true41 FAIL Multiple i64 arguments: Module argument assert_false: fn: writable expected false got true44 FAIL Multiple i64 arguments: BufferSource argument promise_test: Unhandled rejection with value: object "RuntimeError: WebAssembly function with an i64 argument can't be called from JavaScript (evaluating 'fn(1n, 0n)')" 45 FAIL Multiple i64 arguments: Module argument promise_test: Unhandled rejection with value: object "RuntimeError: WebAssembly function with an i64 argument can't be called from JavaScript (evaluating 'fn(1n, 0n)')" 42 46 PASS stray argument: BufferSource argument 43 47 PASS stray argument: Module argument -
trunk/LayoutTests/imported/w3c/web-platform-tests/wasm/jsapi/constructor/instantiate.any.worker-expected.txt
r269866 r271112 14 14 PASS imports: BufferSource argument 15 15 PASS imports: Module argument 16 FAIL No imports: BufferSource argument assert_array_equals: matching export keys expected property 2 to be "table" but got "global" (expected array ["fn", "fn2", "table", "global", "global2", "memory"] got ["fn", "fn2", "global", "global2", "memory", "table"]) 17 FAIL No imports: Module argument assert_array_equals: matching export keys expected property 2 to be "table" but got "global" (expected array ["fn", "fn2", "table", "global", "global2", "memory"] got ["fn", "fn2", "global", "global2", "memory", "table"]) 18 FAIL exports and imports: BufferSource argument assert_false: fn: writable expected false got true 19 FAIL exports and imports: Module argument assert_false: fn: writable expected false got true 16 PASS No imports: BufferSource argument 17 PASS No imports: Module argument 18 PASS exports and imports: BufferSource argument 19 PASS exports and imports: Module argument 20 20 FAIL i64 exports and imports: BufferSource argument promise_test: Unhandled rejection with value: object "LinkError: imported global module:global cannot be an i64" 21 21 FAIL i64 exports and imports: Module argument promise_test: Unhandled rejection with value: object "LinkError: imported global module:global cannot be an i64" 22 FAIL import with i32-returning function: BufferSource argument assert_false: fn2: writable expected false got true 23 FAIL import with i32-returning function: Module argument assert_false: fn2: writable expected false got true 24 FAIL import with function that takes and returns i32: BufferSource argument assert_false: fn2: writable expected false got true 25 FAIL import with function that takes and returns i32: Module argument assert_false: fn2: writable expected false got true 26 FAIL import with i64-returning function: BufferSource argument assert_false: fn2: writable expected false got true 27 FAIL import with i64-returning function: Module argument assert_false: fn2: writable expected false got true 28 FAIL import with function that takes and returns i64: BufferSource argument assert_false: fn2: writable expected false got true 29 FAIL import with function that takes and returns i64: Module argument assert_false: fn2: writable expected false got true 30 FAIL import with i32-taking function: BufferSource argument assert_false: fn: writable expected false got true 31 FAIL import with i32-taking function: Module argument assert_false: fn: writable expected false got true 32 FAIL import with i64-taking function: BufferSource argument assert_false: fn: writable expected false got true 33 FAIL import with i64-taking function: Module argument assert_false: fn: writable expected false got true 34 FAIL export i64-returning function: BufferSource argument assert_false: fn: writable expected false got true 35 FAIL export i64-returning function: Module argument assert_false: fn: writable expected false got true 36 FAIL i32 mutable WebAssembly.Global import: BufferSource argument assert_false: fn: writable expected false got true 37 FAIL i32 mutable WebAssembly.Global import: Module argument assert_false: fn: writable expected false got true 22 PASS import with i32-returning function: BufferSource argument 23 PASS import with i32-returning function: Module argument 24 PASS import with function that takes and returns i32: BufferSource argument 25 PASS import with function that takes and returns i32: Module argument 26 FAIL import with i64-returning function: BufferSource argument assert_true: Should have called into JS expected true got false 27 FAIL import with i64-returning function: Module argument assert_true: Should have called into JS expected true got false 28 FAIL import with function that takes and returns i64: BufferSource argument promise_test: Unhandled rejection with value: object "RuntimeError: WebAssembly function that returns i64 can't be called from JavaScript (evaluating 'instance.exports.fn2()')" 29 FAIL import with function that takes and returns i64: Module argument promise_test: Unhandled rejection with value: object "RuntimeError: WebAssembly function that returns i64 can't be called from JavaScript (evaluating 'instance.exports.fn2()')" 30 PASS import with i32-taking function: BufferSource argument 31 PASS import with i32-taking function: Module argument 32 FAIL import with i64-taking function: BufferSource argument assert_throws_js: function "() => instance.exports.fn(6)" threw object "RuntimeError: WebAssembly function with an i64 argument can't be called from JavaScript (evaluating 'instance.exports.fn(6)')" ("RuntimeError") expected instance of function "function TypeError() { 33 [native code] 34 }" ("TypeError") 35 FAIL import with i64-taking function: Module argument assert_throws_js: function "() => instance.exports.fn(6)" threw object "RuntimeError: WebAssembly function with an i64 argument can't be called from JavaScript (evaluating 'instance.exports.fn(6)')" ("RuntimeError") expected instance of function "function TypeError() { 36 [native code] 37 }" ("TypeError") 38 FAIL export i64-returning function: BufferSource argument promise_test: Unhandled rejection with value: object "RuntimeError: WebAssembly function that returns i64 can't be called from JavaScript (evaluating 'instance.exports.fn()')" 39 FAIL export i64-returning function: Module argument promise_test: Unhandled rejection with value: object "RuntimeError: WebAssembly function that returns i64 can't be called from JavaScript (evaluating 'instance.exports.fn()')" 40 PASS i32 mutable WebAssembly.Global import: BufferSource argument 41 PASS i32 mutable WebAssembly.Global import: Module argument 38 42 FAIL i64 mutable WebAssembly.Global import: BufferSource argument WebAssembly.Global does not accept i64 initial value 39 43 FAIL i64 mutable WebAssembly.Global import: Module argument WebAssembly.Global does not accept i64 initial value 40 FAIL Multiple i64 arguments: BufferSource argument assert_false: fn: writable expected false got true41 FAIL Multiple i64 arguments: Module argument assert_false: fn: writable expected false got true44 FAIL Multiple i64 arguments: BufferSource argument promise_test: Unhandled rejection with value: object "RuntimeError: WebAssembly function with an i64 argument can't be called from JavaScript (evaluating 'fn(1n, 0n)')" 45 FAIL Multiple i64 arguments: Module argument promise_test: Unhandled rejection with value: object "RuntimeError: WebAssembly function with an i64 argument can't be called from JavaScript (evaluating 'fn(1n, 0n)')" 42 46 PASS stray argument: BufferSource argument 43 47 PASS stray argument: Module argument -
trunk/LayoutTests/imported/w3c/web-platform-tests/wasm/jsapi/instance/constructor.any-expected.txt
r269866 r271112 10 10 FAIL getter order for imports object assert_array_equals: expected property 1 to be "global1 getter" but got "memory getter" (expected array ["module getter", "global1 getter", "module2 getter", "global3 getter", "module getter", "memory getter", "module getter", "global2 getter"] got ["module getter", "memory getter", "module getter", "global1 getter", "module2 getter", "global3 getter", "module getter", "global2 getter"]) 11 11 PASS imports 12 FAIL No imports assert_array_equals: matching export keys expected property 2 to be "table" but got "global" (expected array ["fn", "fn2", "table", "global", "global2", "memory"] got ["fn", "fn2", "global", "global2", "memory", "table"]) 13 FAIL exports and imports assert_false: fn: writable expected false got true 12 PASS No imports 13 PASS exports and imports 14 14 FAIL i64 exports and imports imported global module:global cannot be an i64 (evaluating 'new WebAssembly.Instance(module, ...args)') 15 FAIL import with i32-returning function assert_false: fn2: writable expected false got true 16 FAIL import with function that takes and returns i32 assert_false: fn2: writable expected false got true 17 FAIL import with i64-returning function assert_false: fn2: writable expected false got true 18 FAIL import with function that takes and returns i64 assert_false: fn2: writable expected false got true 19 FAIL import with i32-taking function assert_false: fn: writable expected false got true 20 FAIL import with i64-taking function assert_false: fn: writable expected false got true 21 FAIL export i64-returning function assert_false: fn: writable expected false got true 22 FAIL i32 mutable WebAssembly.Global import assert_false: fn: writable expected false got true 15 PASS import with i32-returning function 16 PASS import with function that takes and returns i32 17 FAIL import with i64-returning function assert_true: Should have called into JS expected true got false 18 FAIL import with function that takes and returns i64 WebAssembly function that returns i64 can't be called from JavaScript (evaluating 'instance.exports.fn2()') 19 PASS import with i32-taking function 20 FAIL import with i64-taking function assert_throws_js: function "() => instance.exports.fn(6)" threw object "RuntimeError: WebAssembly function with an i64 argument can't be called from JavaScript (evaluating 'instance.exports.fn(6)')" ("RuntimeError") expected instance of function "function TypeError() { 21 [native code] 22 }" ("TypeError") 23 FAIL export i64-returning function WebAssembly function that returns i64 can't be called from JavaScript (evaluating 'instance.exports.fn()') 24 PASS i32 mutable WebAssembly.Global import 23 25 FAIL i64 mutable WebAssembly.Global import WebAssembly.Global does not accept i64 initial value 24 FAIL Multiple i64 arguments assert_false: fn: writable expected false got true26 FAIL Multiple i64 arguments WebAssembly function with an i64 argument can't be called from JavaScript (evaluating 'fn(1n, 0n)') 25 27 PASS stray argument 26 28 -
trunk/LayoutTests/imported/w3c/web-platform-tests/wasm/jsapi/instance/constructor.any.worker-expected.txt
r269866 r271112 10 10 FAIL getter order for imports object assert_array_equals: expected property 1 to be "global1 getter" but got "memory getter" (expected array ["module getter", "global1 getter", "module2 getter", "global3 getter", "module getter", "memory getter", "module getter", "global2 getter"] got ["module getter", "memory getter", "module getter", "global1 getter", "module2 getter", "global3 getter", "module getter", "global2 getter"]) 11 11 PASS imports 12 FAIL No imports assert_array_equals: matching export keys expected property 2 to be "table" but got "global" (expected array ["fn", "fn2", "table", "global", "global2", "memory"] got ["fn", "fn2", "global", "global2", "memory", "table"]) 13 FAIL exports and imports assert_false: fn: writable expected false got true 12 PASS No imports 13 PASS exports and imports 14 14 FAIL i64 exports and imports imported global module:global cannot be an i64 (evaluating 'new WebAssembly.Instance(module, ...args)') 15 FAIL import with i32-returning function assert_false: fn2: writable expected false got true 16 FAIL import with function that takes and returns i32 assert_false: fn2: writable expected false got true 17 FAIL import with i64-returning function assert_false: fn2: writable expected false got true 18 FAIL import with function that takes and returns i64 assert_false: fn2: writable expected false got true 19 FAIL import with i32-taking function assert_false: fn: writable expected false got true 20 FAIL import with i64-taking function assert_false: fn: writable expected false got true 21 FAIL export i64-returning function assert_false: fn: writable expected false got true 22 FAIL i32 mutable WebAssembly.Global import assert_false: fn: writable expected false got true 15 PASS import with i32-returning function 16 PASS import with function that takes and returns i32 17 FAIL import with i64-returning function assert_true: Should have called into JS expected true got false 18 FAIL import with function that takes and returns i64 WebAssembly function that returns i64 can't be called from JavaScript (evaluating 'instance.exports.fn2()') 19 PASS import with i32-taking function 20 FAIL import with i64-taking function assert_throws_js: function "() => instance.exports.fn(6)" threw object "RuntimeError: WebAssembly function with an i64 argument can't be called from JavaScript (evaluating 'instance.exports.fn(6)')" ("RuntimeError") expected instance of function "function TypeError() { 21 [native code] 22 }" ("TypeError") 23 FAIL export i64-returning function WebAssembly function that returns i64 can't be called from JavaScript (evaluating 'instance.exports.fn()') 24 PASS i32 mutable WebAssembly.Global import 23 25 FAIL i64 mutable WebAssembly.Global import WebAssembly.Global does not accept i64 initial value 24 FAIL Multiple i64 arguments assert_false: fn: writable expected false got true26 FAIL Multiple i64 arguments WebAssembly function with an i64 argument can't be called from JavaScript (evaluating 'fn(1n, 0n)') 25 27 PASS stray argument 26 28 -
trunk/LayoutTests/imported/w3c/web-platform-tests/wasm/jsapi/table/grow-reftypes.tentative.any-expected.txt
r260690 r271112 1 1 2 FAIL Grow with exported-function argument assert_equals: expected (function) function "function fn() {2 FAIL Grow with exported-function argument assert_equals: expected (function) function "function 0() { 3 3 [native code] 4 4 }" but got (object) null -
trunk/Source/JavaScriptCore/ChangeLog
r271100 r271112 1 2020-12-29 Yusuke Suzuki <ysuzuki@apple.com> 2 3 [JSC] Update WebAssembly instance's exports object 4 https://bugs.webkit.org/show_bug.cgi?id=220189 5 6 Reviewed by Alexey Shvayka. 7 8 This patch aligns the WebAssembly Instance's exports object to the updated spec. 9 10 1. exports object is a plain object which [[Prototype]] is null[1]. We were using module namespace object. Also, the object should be frozen. 11 2. exported functions' name should be index, according to the spec[2]. 12 13 [1]: https://webassembly.github.io/spec/js-api/index.html#create-an-exports-object 14 [2]: https://webassembly.github.io/spec/js-api/index.html#exported-function-exotic-objects 15 16 * wasm/js/JSWebAssembly.cpp: 17 (JSC::resolve): 18 * wasm/js/JSWebAssemblyInstance.cpp: 19 (JSC::JSWebAssemblyInstance::finishCreation): 20 (JSC::JSWebAssemblyInstance::visitChildren): 21 (JSC::JSWebAssemblyInstance::finalizeCreation): 22 (JSC::JSWebAssemblyInstance::tryCreate): 23 * wasm/js/JSWebAssemblyInstance.h: 24 * wasm/js/WebAssemblyInstancePrototype.cpp: 25 (JSC::JSC_DEFINE_HOST_FUNCTION): 26 * wasm/js/WebAssemblyModuleRecord.cpp: 27 (JSC::WebAssemblyModuleRecord::visitChildren): 28 (JSC::WebAssemblyModuleRecord::link): 29 * wasm/js/WebAssemblyModuleRecord.h: 30 1 31 2020-12-27 Dmitry Bezhetskov <dbezhetskov@igalia.com> 2 32 -
trunk/Source/JavaScriptCore/wasm/js/JSWebAssembly.cpp
r267594 r271112 46 46 #include "StructureInlines.h" 47 47 #include "ThrowScope.h" 48 #include "WebAssemblyModuleRecord.h" 48 49 49 50 namespace JSC { … … 183 184 promise->resolve(globalObject, instance); 184 185 else if (resolveKind == Resolve::WithModuleRecord) { 185 auto* moduleRecord = instance->module NamespaceObject()->moduleRecord();186 auto* moduleRecord = instance->moduleRecord(); 186 187 if (UNLIKELY(Options::dumpModuleRecord())) 187 188 moduleRecord->dump(); -
trunk/Source/JavaScriptCore/wasm/js/JSWebAssemblyInstance.cpp
r270208 r271112 58 58 } 59 59 60 void JSWebAssemblyInstance::finishCreation(VM& vm, JSWebAssemblyModule* module, JSModuleNamespaceObject* moduleNamespaceObject)60 void JSWebAssemblyInstance::finishCreation(VM& vm, JSWebAssemblyModule* module, WebAssemblyModuleRecord* moduleRecord) 61 61 { 62 62 Base::finishCreation(vm); … … 64 64 65 65 m_module.set(vm, this, module); 66 m_module NamespaceObject.set(vm, this, moduleNamespaceObject);66 m_moduleRecord.set(vm, this, moduleRecord); 67 67 68 68 vm.heap.reportExtraMemoryAllocated(m_instance->extraMemoryAllocated()); … … 82 82 visitor.append(thisObject->m_module); 83 83 visitor.append(thisObject->m_codeBlock); 84 visitor.append(thisObject->m_module NamespaceObject);84 visitor.append(thisObject->m_moduleRecord); 85 85 visitor.append(thisObject->m_memory); 86 86 for (unsigned i = 0; i < thisObject->instance().module().moduleInformation().tableCount(); ++i) … … 138 138 } 139 139 140 auto* moduleRecord = jsCast<WebAssemblyModuleRecord*>(m_moduleNamespaceObject->moduleRecord()); 141 moduleRecord->prepareLink(vm, this); 140 m_moduleRecord->prepareLink(vm, this); 142 141 143 142 if (creationMode == Wasm::CreationMode::FromJS) { 144 m oduleRecord->link(globalObject, jsNull(), importObject, creationMode);143 m_moduleRecord->link(globalObject, jsNull(), importObject, creationMode); 145 144 RETURN_IF_EXCEPTION(scope, void()); 146 145 147 JSValue startResult = m oduleRecord->evaluate(globalObject);146 JSValue startResult = m_moduleRecord->evaluate(globalObject); 148 147 UNUSED_PARAM(startResult); 149 148 RETURN_IF_EXCEPTION(scope, void()); … … 177 176 RETURN_IF_EXCEPTION(throwScope, nullptr); 178 177 179 JSModuleNamespaceObject* moduleNamespace = moduleRecord->getModuleNamespace(globalObject);180 181 178 auto storeTopCallFrame = [&vm] (void* topCallFrame) { 182 179 vm.topCallFrame = bitwise_cast<CallFrame*>(topCallFrame); … … 186 183 auto* jsInstance = new (NotNull, allocateCell<JSWebAssemblyInstance>(vm.heap)) JSWebAssemblyInstance(vm, instanceStructure, 187 184 Wasm::Instance::create(&vm.wasmContext, WTFMove(module), &vm.topEntryFrame, vm.addressOfSoftStackLimit(), WTFMove(storeTopCallFrame))); 188 jsInstance->finishCreation(vm, jsModule, module Namespace);185 jsInstance->finishCreation(vm, jsModule, moduleRecord); 189 186 RETURN_IF_EXCEPTION(throwScope, nullptr); 190 187 -
trunk/Source/JavaScriptCore/wasm/js/JSWebAssemblyInstance.h
r260415 r271112 41 41 class JSModuleNamespaceObject; 42 42 class JSWebAssemblyModule; 43 class WebAssemblyModuleRecord; 43 44 44 45 namespace Wasm { … … 68 69 69 70 Wasm::Instance& instance() { return m_instance.get(); } 70 JSModuleNamespaceObject* moduleNamespaceObject() { return m_moduleNamespaceObject.get(); }71 WebAssemblyModuleRecord* moduleRecord() { return m_moduleRecord.get(); } 71 72 72 73 JSWebAssemblyMemory* memory() { return m_memory.get(); } … … 104 105 private: 105 106 JSWebAssemblyInstance(VM&, Structure*, Ref<Wasm::Instance>&&); 106 void finishCreation(VM&, JSWebAssemblyModule*, JSModuleNamespaceObject*);107 void finishCreation(VM&, JSWebAssemblyModule*, WebAssemblyModuleRecord*); 107 108 static void visitChildren(JSCell*, SlotVisitor&); 108 109 … … 113 114 WriteBarrier<JSWebAssemblyModule> m_module; 114 115 WriteBarrier<JSWebAssemblyCodeBlock> m_codeBlock; 115 WriteBarrier< JSModuleNamespaceObject> m_moduleNamespaceObject;116 WriteBarrier<WebAssemblyModuleRecord> m_moduleRecord; 116 117 WriteBarrier<JSWebAssemblyMemory> m_memory; 117 118 Vector<WriteBarrier<JSWebAssemblyTable>> m_tables; -
trunk/Source/JavaScriptCore/wasm/js/WebAssemblyInstancePrototype.cpp
r267594 r271112 33 33 #include "JSModuleNamespaceObject.h" 34 34 #include "JSWebAssemblyInstance.h" 35 #include "WebAssemblyModuleRecord.h" 35 36 36 37 namespace JSC { … … 69 70 JSWebAssemblyInstance* instance = getInstance(globalObject, vm, callFrame->thisValue()); 70 71 RETURN_IF_EXCEPTION(throwScope, { }); 71 return JSValue::encode(instance->moduleNamespaceObject());72 RELEASE_AND_RETURN(throwScope, JSValue::encode(instance->moduleRecord()->exportsObject())); 72 73 } 73 74 -
trunk/Source/JavaScriptCore/wasm/js/WebAssemblyModuleRecord.cpp
r270965 r271112 85 85 visitor.append(thisObject->m_instance); 86 86 visitor.append(thisObject->m_startFunction); 87 visitor.append(thisObject->m_exportsObject); 87 88 } 88 89 … … 361 362 362 363 unsigned functionImportCount = codeBlock->functionImportCount(); 363 auto makeFunctionWrapper = [&] ( const String& field,uint32_t index) -> JSValue {364 auto makeFunctionWrapper = [&] (uint32_t index) -> JSValue { 364 365 // If we already made a wrapper, do not make a new one. 365 366 JSValue wrapper = m_instance->instance().getFunctionWrapper(index); … … 388 389 Wasm::SignatureIndex signatureIndex = module->signatureIndexFromFunctionIndexSpace(index); 389 390 const Wasm::Signature& signature = Wasm::SignatureInformation::get(signatureIndex); 390 WebAssemblyFunction* function = WebAssemblyFunction::create(vm, globalObject, globalObject->webAssemblyFunctionStructure(), signature.argumentCount(), field, m_instance.get(), embedderEntrypointCallee, entrypointLoadLocation, signatureIndex);391 WebAssemblyFunction* function = WebAssemblyFunction::create(vm, globalObject, globalObject->webAssemblyFunctionStructure(), signature.argumentCount(), makeString(index), m_instance.get(), embedderEntrypointCallee, entrypointLoadLocation, signatureIndex); 391 392 wrapper = function; 392 393 } … … 399 400 400 401 for (auto index : moduleInformation.referencedFunctions()) 401 makeFunctionWrapper( "Referenced function",index);402 makeFunctionWrapper(index); 402 403 403 404 // Globals … … 412 413 } else if (global.initializationType == Wasm::GlobalInformation::FromRefFunc) { 413 414 ASSERT(global.initialBitsOrImportNumber < moduleInformation.functionIndexSpaceSize()); 414 ASSERT(makeFunctionWrapper( "Global init expr",global.initialBitsOrImportNumber).isCallable(vm));415 initialBits = JSValue::encode(makeFunctionWrapper( "Global init expr",global.initialBitsOrImportNumber));415 ASSERT(makeFunctionWrapper(global.initialBitsOrImportNumber).isCallable(vm)); 416 initialBits = JSValue::encode(makeFunctionWrapper(global.initialBitsOrImportNumber)); 416 417 } else 417 418 initialBits = global.initialBitsOrImportNumber; … … 438 439 439 440 // Let exports be a list of (string, JS value) pairs that is mapped from each external value e in instance.exports as follows: 441 // https://webassembly.github.io/spec/js-api/index.html#create-an-exports-object 442 JSObject* exportsObject = constructEmptyObject(vm, globalObject->nullPrototypeObjectStructure()); 440 443 JSModuleEnvironment* moduleEnvironment = JSModuleEnvironment::create(vm, globalObject, nullptr, exportSymbolTable, JSValue(), this); 441 444 for (const auto& exp : moduleInformation.exports) { … … 443 446 switch (exp.kind) { 444 447 case Wasm::ExternalKind::Function: { 445 exportedValue = makeFunctionWrapper( String::fromUTF8(exp.field),exp.kindIndex);448 exportedValue = makeFunctionWrapper(exp.kindIndex); 446 449 ASSERT(exportedValue.isCallable(vm)); 447 ASSERT(makeFunctionWrapper( String::fromUTF8(exp.field),exp.kindIndex) == exportedValue);450 ASSERT(makeFunctionWrapper(exp.kindIndex) == exportedValue); 448 451 break; 449 452 } … … 495 498 } 496 499 500 Identifier propertyName = Identifier::fromString(vm, String::fromUTF8(exp.field)); 501 497 502 bool shouldThrowReadOnlyError = false; 498 503 bool ignoreReadOnlyErrors = true; 499 504 bool putResult = false; 500 symbolTablePutTouchWatchpointSet(moduleEnvironment, globalObject, Identifier::fromString(vm, String::fromUTF8(exp.field)), exportedValue, shouldThrowReadOnlyError, ignoreReadOnlyErrors, putResult);505 symbolTablePutTouchWatchpointSet(moduleEnvironment, globalObject, propertyName, exportedValue, shouldThrowReadOnlyError, ignoreReadOnlyErrors, putResult); 501 506 scope.assertNoException(); 502 507 RELEASE_ASSERT(putResult); 508 509 if (Optional<uint32_t> index = parseIndex(propertyName)) { 510 exportsObject->putDirectIndex(globalObject, index.value(), exportedValue); 511 RETURN_IF_EXCEPTION(scope, void()); 512 } else 513 exportsObject->putDirect(vm, propertyName, exportedValue); 503 514 } 515 516 objectConstructorFreeze(globalObject, exportsObject); 517 RETURN_IF_EXCEPTION(scope, void()); 518 m_exportsObject.set(vm, this, exportsObject); 504 519 505 520 bool hasStart = !!moduleInformation.startFunctionIndexSpace; -
trunk/Source/JavaScriptCore/wasm/js/WebAssemblyModuleRecord.h
r253237 r271112 63 63 JS_EXPORT_PRIVATE JSValue evaluate(JSGlobalObject*); 64 64 65 JSObject* exportsObject() const { return m_exportsObject.get(); } 66 65 67 private: 66 68 WebAssemblyModuleRecord(VM&, Structure*, const Identifier&); … … 72 74 WriteBarrier<JSWebAssemblyInstance> m_instance; 73 75 WriteBarrier<JSObject> m_startFunction; 76 WriteBarrier<JSObject> m_exportsObject; 74 77 }; 75 78
Note: See TracChangeset
for help on using the changeset viewer.