mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1246403: Implement call_import when caller returns float32; r=luke
This commit is contained in:
parent
93cadf3a5a
commit
43d568d2ac
@ -407,7 +407,12 @@ GenerateInterpExitStub(ModuleGenerator& mg, unsigned importIndex, ProfilingOffse
|
||||
case ExprType::I64:
|
||||
MOZ_CRASH("no int64 in asm.js");
|
||||
case ExprType::F32:
|
||||
MOZ_CRASH("Float32 shouldn't be returned from a FFI");
|
||||
MOZ_ASSERT(!mg.isAsmJS(), "import can't return float32 in asm.js");
|
||||
masm.call(SymbolicAddress::InvokeImport_F64);
|
||||
masm.branchTest32(Assembler::Zero, ReturnReg, ReturnReg, JumpTarget::Throw);
|
||||
masm.loadDouble(argv, ReturnDoubleReg);
|
||||
masm.convertDoubleToFloat32(ReturnDoubleReg, ReturnFloat32Reg);
|
||||
break;
|
||||
case ExprType::F64:
|
||||
masm.call(SymbolicAddress::InvokeImport_F64);
|
||||
masm.branchTest32(Assembler::Zero, ReturnReg, ReturnReg, JumpTarget::Throw);
|
||||
@ -658,7 +663,9 @@ GenerateJitExitStub(ModuleGenerator& mg, unsigned importIndex, ProfilingOffsets*
|
||||
case ExprType::I64:
|
||||
MOZ_CRASH("no int64 in asm.js");
|
||||
case ExprType::F32:
|
||||
MOZ_CRASH("Float shouldn't be returned from an import");
|
||||
MOZ_ASSERT(!mg.isAsmJS(), "import can't return float32 in asm.js");
|
||||
masm.convertValueToFloat(JSReturnOperand, ReturnFloat32Reg, &oolConvert);
|
||||
break;
|
||||
case ExprType::F64:
|
||||
masm.convertValueToDouble(JSReturnOperand, ReturnDoubleReg, &oolConvert);
|
||||
break;
|
||||
@ -720,6 +727,13 @@ GenerateJitExitStub(ModuleGenerator& mg, unsigned importIndex, ProfilingOffsets*
|
||||
masm.branchTest32(Assembler::Zero, ReturnReg, ReturnReg, JumpTarget::Throw);
|
||||
masm.loadDouble(Address(masm.getStackPointer(), offsetToCoerceArgv), ReturnDoubleReg);
|
||||
break;
|
||||
case ExprType::F32:
|
||||
MOZ_ASSERT(!mg.isAsmJS(), "import can't return float32 in asm.js");
|
||||
masm.call(SymbolicAddress::CoerceInPlace_ToNumber);
|
||||
masm.branchTest32(Assembler::Zero, ReturnReg, ReturnReg, JumpTarget::Throw);
|
||||
masm.loadDouble(Address(masm.getStackPointer(), offsetToCoerceArgv), ReturnDoubleReg);
|
||||
masm.convertDoubleToFloat32(ReturnDoubleReg, ReturnFloat32Reg);
|
||||
break;
|
||||
default:
|
||||
MOZ_CRASH("Unsupported convert type");
|
||||
}
|
||||
|
@ -118,6 +118,10 @@ var code = '(module (import "a" "") (import "b" "c") (import "c" ""))';
|
||||
assertErrorMessage(() => wasmEvalText(code, {a:()=>{}, b:{c:()=>{}}, c:{}}), TypeError, notFunction);
|
||||
wasmEvalText(code, {a:()=>{}, b:{c:()=>{}}, c:()=>{}});
|
||||
|
||||
wasmEvalText('(module (import "a" "" (result i32)))', {a: ()=> {}});
|
||||
wasmEvalText('(module (import "a" "" (result f32)))', {a: ()=> {}});
|
||||
wasmEvalText('(module (import "a" "" (result f64)))', {a: ()=> {}});
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// memory
|
||||
|
||||
@ -254,6 +258,15 @@ assertErrorMessage(() => wasmEvalText('(module (import "a" "") (func (call_impor
|
||||
wasmEvalText('(module (import "a" "") (func (call_import 0)))', {a:()=>{}});
|
||||
wasmEvalText('(module (import "a" "" (param i32)) (func (call_import 0 (i32.const 0))))', {a:()=>{}});
|
||||
|
||||
function checkF32CallImport(v) {
|
||||
assertEq(wasmEvalText('(module (import "a" "" (result f32)) (func (result f32) (call_import 0)) (export "" 0))', {a:()=>{ return v; }})(), Math.fround(v));
|
||||
}
|
||||
checkF32CallImport(13.37);
|
||||
checkF32CallImport(NaN);
|
||||
checkF32CallImport(-Infinity);
|
||||
checkF32CallImport(-0);
|
||||
checkF32CallImport(Math.pow(2, 32) - 1);
|
||||
|
||||
var f = wasmEvalText('(module (import "inc" "") (func (call_import 0)) (export "" 0))', {inc:()=>counter++});
|
||||
var g = wasmEvalText('(module (import "f" "") (func (block (call_import 0) (call_import 0))) (export "" 0))', {f});
|
||||
var counter = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user