You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Wasm64] Fix EM_ASM for addresses >4GB addresses (#19980)
This change use makeGetValue helper macros to avoid direct heap access.
This does come with a 6 byte code size cost (I measured the size of the
JS code generated for wasm64.test_em_asm with -O2 going from 9275 to
9281).
Copy file name to clipboardExpand all lines: src/library.js
+9-10
Original file line number
Diff line number
Diff line change
@@ -2869,7 +2869,6 @@ addToLibrary({
2869
2869
varch;
2870
2870
// Most arguments are i32s, so shift the buffer pointer so it is a plain
2871
2871
// index into HEAP32.
2872
-
buf>>=2;
2873
2872
while(ch=HEAPU8[sigPtr++]){
2874
2873
#if ASSERTIONS
2875
2874
varchr=String.fromCharCode(ch);
@@ -2885,22 +2884,22 @@ addToLibrary({
2885
2884
#endif
2886
2885
assert(validChars.includes(chr),`Invalid character ${ch}("${chr}") in readEmAsmArgs! Use only [${validChars}], and do not specify "v" for void return argument.`);
2887
2886
#endif
2888
-
// Floats are always passed as doubles, and doubles and int64s take up 8
2889
-
// bytes (two 32-bit slots) in memory, align reads to these:
2890
-
buf+=(ch!={{{charCode('i')}}})&buf;
2887
+
// Floats are always passed as doubles, so all types except for 'i'
2888
+
// are 8 bytes and require alignment.
2889
+
buf+=(ch!={{{charCode('i')}}})&&buf%8 ? 4 : 0;
2891
2890
readEmAsmArgsArray.push(
2892
-
ch=={{{charCode('i')}}} ? HEAP32[buf] :
2893
2891
#if MEMORY64
2894
2892
// Special case for pointers under wasm64 which we read as int53 Numbers.
0 commit comments