Diff
Modified: trunk/JSTests/ChangeLog (274398 => 274399)
--- trunk/JSTests/ChangeLog 2021-03-14 14:46:34 UTC (rev 274398)
+++ trunk/JSTests/ChangeLog 2021-03-14 18:19:00 UTC (rev 274399)
@@ -1,3 +1,14 @@
+2021-03-14 Yusuke Suzuki <[email protected]>
+
+ [JSC] wasm atomic wait offset is not index
+ https://bugs.webkit.org/show_bug.cgi?id=223159
+
+ Reviewed by Mark Lam.
+
+ * wasm.yaml:
+ * wasm/threads-spec-tests/resources/wait-large.wast: Added.
+ * wasm/threads-spec-tests/wait-large.wast.js: Added.
+
2021-03-11 Tadeu Zagallo <[email protected]>
AI validator patchpoint should read heap top
Added: trunk/JSTests/wasm/threads-spec-tests/resources/wait-large.wast (0 => 274399)
--- trunk/JSTests/wasm/threads-spec-tests/resources/wait-large.wast (rev 0)
+++ trunk/JSTests/wasm/threads-spec-tests/resources/wait-large.wast 2021-03-14 18:19:00 UTC (rev 274399)
@@ -0,0 +1,17 @@
+(module
+ (memory 8192 8192 shared)
+
+ (func (export "init") (param $value i64) (i64.store (i32.const 134217720) (local.get $value)))
+
+ (func (export "memory.atomic.notify") (param $addr i32) (param $count i32) (result i32)
+ (memory.atomic.notify (local.get 0) (local.get 1)))
+ (func (export "memory.atomic.wait32") (param $addr i32) (param $expected i32) (param $timeout i64) (result i32)
+ (memory.atomic.wait32 (local.get 0) (local.get 1) (local.get 2)))
+ (func (export "memory.atomic.wait64") (param $addr i32) (param $expected i64) (param $timeout i64) (result i32)
+ (memory.atomic.wait64 (local.get 0) (local.get 1) (local.get 2)))
+)
+
+(invoke "init" (i64.const 0xffffffffffff))
+(assert_return (invoke "memory.atomic.wait32" (i32.const 134217720) (i32.const 0) (i64.const 0)) (i32.const 1))
+(assert_return (invoke "memory.atomic.wait64" (i32.const 134217720) (i64.const 0) (i64.const 0)) (i32.const 1))
+(assert_return (invoke "memory.atomic.notify" (i32.const 134217720) (i32.const 0)) (i32.const 0))
Added: trunk/JSTests/wasm/threads-spec-tests/wait-large.wast.js (0 => 274399)
--- trunk/JSTests/wasm/threads-spec-tests/wait-large.wast.js (rev 0)
+++ trunk/JSTests/wasm/threads-spec-tests/wait-large.wast.js 2021-03-14 18:19:00 UTC (rev 274399)
@@ -0,0 +1,15 @@
+
+// wait-large.wast:1
+let $1 = instance("\x00\x61\x73\x6d\x01\x00\x00\x00\x01\x99\x80\x80\x80\x00\x04\x60\x01\x7e\x00\x60\x02\x7f\x7f\x01\x7f\x60\x03\x7f\x7f\x7e\x01\x7f\x60\x03\x7f\x7e\x7e\x01\x7f\x03\x85\x80\x80\x80\x00\x04\x00\x01\x02\x03\x05\x86\x80\x80\x80\x00\x01\x03\x80\x40\x80\x40\x07\xcd\x80\x80\x80\x00\x04\x04\x69\x6e\x69\x74\x00\x00\x14\x6d\x65\x6d\x6f\x72\x79\x2e\x61\x74\x6f\x6d\x69\x63\x2e\x6e\x6f\x74\x69\x66\x79\x00\x01\x14\x6d\x65\x6d\x6f\x72\x79\x2e\x61\x74\x6f\x6d\x69\x63\x2e\x77\x61\x69\x74\x33\x32\x00\x02\x14\x6d\x65\x6d\x6f\x72\x79\x2e\x61\x74\x6f\x6d\x69\x63\x2e\x77\x61\x69\x74\x36\x34\x00\x03\x0a\xc3\x80\x80\x80\x00\x04\x8c\x80\x80\x80\x00\x00\x41\xf8\xff\xff\x3f\x20\x00\x37\x03\x00\x0b\x8a\x80\x80\x80\x00\x00\x20\x00\x20\x01\xfe\x00\x02\x00\x0b\x8c\x80\x80\x80\x00\x00\x20\x00\x20\x01\x20\x02\xfe\x01\x02\x00\x0b\x8c\x80\x80\x80\x00\x00\x20\x00\x20\x01\x20\x02\xfe\x02\x03\x00\x0b");
+
+// wait-large.wast:14
+run(() => call(instance("\x00\x61\x73\x6d\x01\x00\x00\x00\x01\x88\x80\x80\x80\x00\x02\x60\x00\x00\x60\x01\x7e\x00\x02\x8b\x80\x80\x80\x00\x01\x02\x24\x31\x04\x69\x6e\x69\x74\x00\x01\x03\x82\x80\x80\x80\x00\x01\x00\x07\x87\x80\x80\x80\x00\x01\x03\x72\x75\x6e\x00\x01\x0a\x97\x80\x80\x80\x00\x01\x91\x80\x80\x80\x00\x00\x02\x40\x42\xff\xff\xff\xff\xff\xff\x3f\x10\x00\x0f\x0b\x00\x0b", exports("$1", $1)), "run", [])); // run(() => call($1, "init", [int64("281_474_976_710_655")]))
+
+// wait-large.wast:15
+run(() => call(instance("\x00\x61\x73\x6d\x01\x00\x00\x00\x01\x8b\x80\x80\x80\x00\x02\x60\x00\x00\x60\x03\x7f\x7f\x7e\x01\x7f\x02\x9b\x80\x80\x80\x00\x01\x02\x24\x31\x14\x6d\x65\x6d\x6f\x72\x79\x2e\x61\x74\x6f\x6d\x69\x63\x2e\x77\x61\x69\x74\x33\x32\x00\x01\x03\x82\x80\x80\x80\x00\x01\x00\x07\x87\x80\x80\x80\x00\x01\x03\x72\x75\x6e\x00\x01\x0a\xa0\x80\x80\x80\x00\x01\x9a\x80\x80\x80\x00\x00\x02\x40\x41\xf8\xff\xff\x3f\x41\x00\x42\x00\x10\x00\x01\x41\x01\x01\x46\x45\x0d\x00\x0f\x0b\x00\x0b", exports("$1", $1)), "run", [])); // assert_return(() => call($1, "memory.atomic.wait32", [134_217_720, 0, int64("0")]), 1)
+
+// wait-large.wast:16
+run(() => call(instance("\x00\x61\x73\x6d\x01\x00\x00\x00\x01\x8b\x80\x80\x80\x00\x02\x60\x00\x00\x60\x03\x7f\x7e\x7e\x01\x7f\x02\x9b\x80\x80\x80\x00\x01\x02\x24\x31\x14\x6d\x65\x6d\x6f\x72\x79\x2e\x61\x74\x6f\x6d\x69\x63\x2e\x77\x61\x69\x74\x36\x34\x00\x01\x03\x82\x80\x80\x80\x00\x01\x00\x07\x87\x80\x80\x80\x00\x01\x03\x72\x75\x6e\x00\x01\x0a\xa0\x80\x80\x80\x00\x01\x9a\x80\x80\x80\x00\x00\x02\x40\x41\xf8\xff\xff\x3f\x42\x00\x42\x00\x10\x00\x01\x41\x01\x01\x46\x45\x0d\x00\x0f\x0b\x00\x0b", exports("$1", $1)), "run", [])); // assert_return(() => call($1, "memory.atomic.wait64", [134_217_720, int64("0"), int64("0")]), 1)
+
+// wait-large.wast:17
+assert_return(() => call($1, "memory.atomic.notify", [134_217_720, 0]), 0);
Modified: trunk/JSTests/wasm.yaml (274398 => 274399)
--- trunk/JSTests/wasm.yaml 2021-03-14 14:46:34 UTC (rev 274398)
+++ trunk/JSTests/wasm.yaml 2021-03-14 18:19:00 UTC (rev 274399)
@@ -130,6 +130,8 @@
cmd: runWebAssemblySpecTest :normal
- path: wasm/threads-spec-tests/atomic-signed.wast.js
cmd: runWebAssemblySpecTest :normal
+- path: wasm/threads-spec-tests/wait-large.wast.js
+ cmd: runWebAssemblySpecTest :normal
- path: wasm/spec-tests/address.wast.js
cmd: runWebAssemblySpecTest :normal
Modified: trunk/Source/_javascript_Core/ChangeLog (274398 => 274399)
--- trunk/Source/_javascript_Core/ChangeLog 2021-03-14 14:46:34 UTC (rev 274398)
+++ trunk/Source/_javascript_Core/ChangeLog 2021-03-14 18:19:00 UTC (rev 274399)
@@ -1,3 +1,17 @@
+2021-03-14 Yusuke Suzuki <[email protected]>
+
+ [JSC] wasm atomic wait offset is not index
+ https://bugs.webkit.org/show_bug.cgi?id=223159
+
+ Reviewed by Mark Lam.
+
+ While JS Atomics.wait's argument is "index" in the typed-array, argument of wasm wait and notify is address.
+ But we are handling it as an index incorrectly.
+ This patch uses it as an address.
+
+ * wasm/WasmOperations.cpp:
+ (JSC::Wasm::JSC_DEFINE_JIT_OPERATION):
+
2021-03-13 Commit Queue <[email protected]>
Unreviewed, reverting r274379.
Modified: trunk/Source/_javascript_Core/wasm/WasmOperations.cpp (274398 => 274399)
--- trunk/Source/_javascript_Core/wasm/WasmOperations.cpp 2021-03-14 14:46:34 UTC (rev 274398)
+++ trunk/Source/_javascript_Core/wasm/WasmOperations.cpp 2021-03-14 18:19:00 UTC (rev 274399)
@@ -866,7 +866,7 @@
return -1;
if (!vm.m_typedArrayController->isAtomicsWaitAllowedOnCurrentThread())
return -1;
- uint32_t* pointer = bitwise_cast<uint32_t*>(instance->memory()->memory()) + offsetInMemory;
+ uint32_t* pointer = bitwise_cast<uint32_t*>(bitwise_cast<uint8_t*>(instance->memory()->memory()) + offsetInMemory);
return wait<uint32_t>(vm, pointer, value, timeoutInNanoseconds);
}
@@ -884,7 +884,7 @@
return -1;
if (!vm.m_typedArrayController->isAtomicsWaitAllowedOnCurrentThread())
return -1;
- uint64_t* pointer = bitwise_cast<uint64_t*>(instance->memory()->memory()) + offsetInMemory;
+ uint64_t* pointer = bitwise_cast<uint64_t*>(bitwise_cast<uint8_t*>(instance->memory()->memory()) + offsetInMemory);
return wait<uint64_t>(vm, pointer, value, timeoutInNanoseconds);
}