Skip to content
Permalink
Browse files

i64 marshalling; fix for floats in asm.js mode

note the test suite currently ends up running in asm.js mode
instead of wasm, and floats get promoted to doubles in the asm.js
abi but not in the wasm abi. Confusing!
  • Loading branch information...
brion committed May 27, 2018
1 parent 60776e7 commit 91269cf351ed9b25b6c5e82351c6a93b437e13e3
Showing with 15 additions and 4 deletions.
  1. +14 −3 src/wasm32/ffi.c
  2. +1 −1 testsuite/lib/libffi.exp
@@ -64,6 +64,7 @@ ffi_call (ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue)
// via name here...
var args = [fn];
var sig = '';
var sigFloat = Module['usingWasm'] ? 'f' : 'd';

var rtype = HEAPU16[(cif_rtype + 6 /* rtype->type*/ ) >> 1];
//console.error('rtype is', rtype);
@@ -79,7 +80,7 @@ ffi_call (ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue)
rtype === /* FFI_TYPE_POINTER */ 14) {
sig = 'i';
} else if (rtype === /* FFI_TYPE_FLOAT */ 2) {
sig = 'f';
sig = sigFloat;
} else if (rtype === /* FFI_TYPE_DOUBLE */ 3 ||
rtype === /* FFI_TYPE_LONGDOUBLE */ 4) {
sig = 'd';
@@ -107,7 +108,7 @@ ffi_call (ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue)
sig += 'i';
} else if (typ === /* FFI_TYPE_FLOAT */ 2) {
args.push(HEAPF32[ptr >> 2]);
sig += 'f';
sig += sigFloat;
} else if (typ === /* FFI_TYPE_DOUBLE */ 3 || typ === /* FFI_TYPE_LONGDOUBLE */ 4) {
args.push(HEAPF64[ptr >> 3]);
sig += 'd';
@@ -146,7 +147,17 @@ ffi_call (ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue)
var func = Module['dynCall_' + sig];
//console.error('func is', func);
//console.error('args is', args);
var result = func.apply(null, args);
if (func) {
var result = func.apply(null, args);
} else {
console.error('fn is', fn);
console.error('sig is', sig);
console.error('args is', args);
for (var x in Module) {
console.error('-- ' + x);
}
throw new Error('invalid function pointer in ffi_call');
}
//console.error('result is',result);

if (rtype === 0) {
@@ -395,7 +395,7 @@ proc check-flags { args } {
# compare them to the actual options.
if { [string compare [lindex $args 2] "*"] == 0
&& [string compare [lindex $args 3] "" ] == 0 } {
set result 1
set result 1
} else {
# The target list might be an effective-target keyword, so replace
# the original list with "*-*-*", since we already know it matches.

0 comments on commit 91269cf

Please sign in to comment.
You can’t perform that action at this time.