Skip to content

Commit 55ba585

Browse files
committed
The most significant 32 bits of a 64 bit long return value get passed in the global tempRet0, but this fails when asm.js and/or closure are enabled as tempRet0 was declared again inside the asm closure. This fix exports tempRet0 via an accessor method Runtime.getTempRet0() which is visible with or without optimisations being enabled
1 parent 9094042 commit 55ba585

File tree

4 files changed

+29
-0
lines changed

4 files changed

+29
-0
lines changed

tests/return64bit/test.c

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
// This is just a trivial test function, the key bit of interest is that it returns a 64 bit long.
3+
long long test() {
4+
long long x = ((long long)1234 << 32) + 5678;
5+
return x;
6+
}

tests/return64bit/testbind.js

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// This code represents a simple native JavaScript binding to a test C function
2+
// that returns a 64 bit long. Notice that the least significant 32 bits are
3+
// returned in the normal return value, but the most significant 32 bits are
4+
// returned via the accessor method Runtime.getTempRet0()
5+
6+
var Module = {
7+
'noExitRuntime' : true
8+
};
9+
10+
Module['runtest'] = function() {
11+
var low = _test();
12+
var high = Runtime.getTempRet0();
13+
14+
console.log("low = " + low);
15+
console.log("high = " + high);
16+
};
17+
18+

tests/return64bit/testbindend.js

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
2+
})(); // End of self calling lambda used to wrap library.

tests/return64bit/testbindstart.js

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2+
(function() { // Start of self-calling lambda used to avoid polluting global namespace.
3+

0 commit comments

Comments
 (0)