Skip to content

Commit 0bf6ff7

Browse files
authored
wasm2js: Don't assume the existence of js assert function (#4357)
Its seems that with this emscripten change DCE is able to remove the `assert` JS runtime function making this call to assert fail with `ReferenceError: assert is not defined`.
1 parent a8dd9e8 commit 0bf6ff7

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

src/wasm2js.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2868,7 +2868,7 @@ void Wasm2JSGlue::emitSpecialSupport() {
28682868
} else if (import->base == ABI::wasm2js::ATOMIC_RMW_I64) {
28692869
out << R"(
28702870
function wasm2js_atomic_rmw_i64(op, bytes, offset, ptr, valueLow, valueHigh) {
2871-
assert(bytes == 8); // TODO: support 1, 2, 4 as well
2871+
// TODO: support bytes=1, 2, 4 as well as 8.
28722872
var view = new BigInt64Array(bufferView.buffer); // TODO cache
28732873
ptr = (ptr + offset) >> 3;
28742874
var value = BigInt(valueLow >>> 0) | (BigInt(valueHigh >>> 0) << BigInt(32));

test/wasm2js/atomics_32.2asm.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ memorySegments[1] = base64DecodeToExistingUint8Array(new Uint8Array(6), 0, "d29y
4040
}
4141

4242
function wasm2js_atomic_rmw_i64(op, bytes, offset, ptr, valueLow, valueHigh) {
43-
assert(bytes == 8); // TODO: support 1, 2, 4 as well
43+
// TODO: support bytes=1, 2, 4 as well as 8.
4444
var view = new BigInt64Array(bufferView.buffer); // TODO cache
4545
ptr = (ptr + offset) >> 3;
4646
var value = BigInt(valueLow >>> 0) | (BigInt(valueHigh >>> 0) << BigInt(32));

test/wasm2js/atomics_32.2asm.js.opt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ memorySegments[1] = base64DecodeToExistingUint8Array(new Uint8Array(6), 0, "d29y
4040
}
4141

4242
function wasm2js_atomic_rmw_i64(op, bytes, offset, ptr, valueLow, valueHigh) {
43-
assert(bytes == 8); // TODO: support 1, 2, 4 as well
43+
// TODO: support bytes=1, 2, 4 as well as 8.
4444
var view = new BigInt64Array(bufferView.buffer); // TODO cache
4545
ptr = (ptr + offset) >> 3;
4646
var value = BigInt(valueLow >>> 0) | (BigInt(valueHigh >>> 0) << BigInt(32));

0 commit comments

Comments
 (0)