Skip to content

Commit bc2b9d3

Browse files
committed
Fix some embind tests under >2gb addressing
This fixes a bug in `handleI64Signatures` which was using `receiveI64ParamAsI53` erroneously for incoming pointers under wasm32.
1 parent fffa523 commit bc2b9d3

File tree

4 files changed

+9
-6
lines changed

4 files changed

+9
-6
lines changed

.circleci/config.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -619,6 +619,8 @@ jobs:
619619
wasm64_4gb.test_async_main
620620
wasm64_4gb.*embind*
621621
core_2gb.test_em_asm
622+
core_2gb.test_embind_unsigned_bigint
623+
core_2gb.test_embind_no_rtti
622624
wasm64l.test_bigswitch
623625
other.test_memory64_proxies
624626
other.test_failing_growth_wasm64"

src/jsifier.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,10 +140,8 @@ function runJSify() {
140140
error(`handleI64Signatures: missing name for argument ${i} in ${symbol}`);
141141
return snippet;
142142
}
143-
if (WASM_BIGINT) {
144-
if (sig[i] == 'p' || (sig[i] == 'j' && i53abi)) {
145-
argConvertions += ` ${receiveI64ParamAsI53(name, undefined, false)}\n`;
146-
}
143+
if (WASM_BIGINT && ((MEMORY64 && sig[i] == 'p') || (i53abi && sig[i] == 'j'))) {
144+
argConvertions += ` ${receiveI64ParamAsI53(name, undefined, false)}\n`;
147145
} else {
148146
if (sig[i] == 'j' && i53abi) {
149147
argConvertions += ` ${receiveI64ParamAsI53(name, undefined, false)}\n`;

src/parseTools.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,8 @@ function getHeapOffset(offset, type) {
296296
const shifts = Math.log(sz) / Math.LN2;
297297
if (MEMORY64 == 1) {
298298
return `((${offset})/${2 ** shifts})`;
299+
} else if (CAN_ADDRESS_2GB) {
300+
return `((${offset})>>>${shifts})`;
299301
} else {
300302
return `((${offset})>>${shifts})`;
301303
}
@@ -422,7 +424,8 @@ function makeSetValueImpl(ptr, pos, value, type) {
422424

423425
function makeHEAPView(which, start, end) {
424426
const size = parseInt(which.replace('U', '').replace('F', '')) / 8;
425-
const mod = size == 1 ? '' : ('>>' + Math.log2(size));
427+
const shift = Math.log2(size);
428+
const mod = size == 1 ? '' : CAN_ADDRESS_2GB ? ('>>>' + shift) : ('>>' + shift);
426429
return `HEAP${which}.subarray((${start})${mod}, (${end})${mod})`;
427430
}
428431

tools/extract_metadata.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ def extract_metadata(filename):
320320
if e.kind == webassembly.ExternType.GLOBAL and e.name.startswith('__em_js__'):
321321
name = utils.removeprefix(e.name, '__em_js__')
322322
globl = module.get_global(e.index)
323-
string_address = get_global_value(globl)
323+
string_address = to_unsigned(get_global_value(globl))
324324
em_js_funcs[name] = get_string_at(module, string_address)
325325

326326
for i in imports:

0 commit comments

Comments
 (0)