From f117fd69b9568aa31fd4b78b9ce0413220f4eb40 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Thu, 5 Nov 2015 10:49:32 -0800 Subject: nan reinterpretation --- src/wasm-interpreter.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/wasm-interpreter.h') diff --git a/src/wasm-interpreter.h b/src/wasm-interpreter.h index b93832d03..f3f6d6986 100644 --- a/src/wasm-interpreter.h +++ b/src/wasm-interpreter.h @@ -385,7 +385,10 @@ public: return Flow(Literal(converted)); } } - case ReinterpretFloat: return curr->type == i32 ? Flow(Literal(value.reinterpreti32())) : Flow(Literal(value.reinterpreti64())); + case ReinterpretFloat: { + if (value.type == f64 && isnan(value.getf64())) return Flow(Literal((int64_t)0x7ff8000000000000)); // canonicalized + return curr->type == i32 ? Flow(Literal(value.reinterpreti32())) : Flow(Literal(value.reinterpreti64())); + } case ConvertUInt32: return curr->type == f32 ? Flow(Literal(float(uint32_t(value.geti32())))) : Flow(Literal(double(uint32_t(value.geti32())))); case ConvertSInt32: return curr->type == f32 ? Flow(Literal(float(int32_t(value.geti32())))) : Flow(Literal(double(int32_t(value.geti32())))); case ConvertUInt64: return curr->type == f32 ? Flow(Literal(float((uint64_t)value.geti64()))) : Flow(Literal(double((uint64_t)value.geti64()))); -- cgit v1.2.3