diff --git a/test/common/wasm/wasm-interpreter.cc b/test/common/wasm/wasm-interpreter.cc index 2e15dfa1e9..f79dd61018 100644 --- a/test/common/wasm/wasm-interpreter.cc +++ b/test/common/wasm/wasm-interpreter.cc @@ -451,19 +451,6 @@ int_type ExecuteConvert(float_type a, TrapReason* trap) { return 0; } -template -int_type ExecuteConvertSaturate(float_type a) { - TrapReason base_trap = kTrapCount; - int32_t val = ExecuteConvert(a, &base_trap); - if (base_trap == kTrapCount) { - return val; - } - return std::isnan(a) ? 0 - : (a < static_cast(0.0) - ? std::numeric_limits::min() - : std::numeric_limits::max()); -} - template dst_type CallExternalIntToFloatFunction(src_type input) { uint8_t data[std::max(sizeof(dst_type), sizeof(src_type))]; @@ -491,65 +478,21 @@ int64_t ExecuteI64SConvertF32(float a, TrapReason* trap) { float32_to_int64_wrapper>(a, trap); } -int64_t ExecuteI64SConvertSatF32(float a) { - TrapReason base_trap = kTrapCount; - int64_t val = ExecuteI64SConvertF32(a, &base_trap); - if (base_trap == kTrapCount) { - return val; - } - return std::isnan(a) ? 0 - : (a < 0.0 ? std::numeric_limits::min() - : std::numeric_limits::max()); -} - int64_t ExecuteI64SConvertF64(double a, TrapReason* trap) { return CallExternalFloatToIntFunction(a, trap); } -int64_t ExecuteI64SConvertSatF64(double a) { - TrapReason base_trap = kTrapCount; - int64_t val = ExecuteI64SConvertF64(a, &base_trap); - if (base_trap == kTrapCount) { - return val; - } - return std::isnan(a) ? 0 - : (a < 0.0 ? std::numeric_limits::min() - : std::numeric_limits::max()); -} - uint64_t ExecuteI64UConvertF32(float a, TrapReason* trap) { return CallExternalFloatToIntFunction(a, trap); } -uint64_t ExecuteI64UConvertSatF32(float a) { - TrapReason base_trap = kTrapCount; - uint64_t val = ExecuteI64UConvertF32(a, &base_trap); - if (base_trap == kTrapCount) { - return val; - } - return std::isnan(a) ? 0 - : (a < 0.0 ? std::numeric_limits::min() - : std::numeric_limits::max()); -} - uint64_t ExecuteI64UConvertF64(double a, TrapReason* trap) { return CallExternalFloatToIntFunction(a, trap); } -uint64_t ExecuteI64UConvertSatF64(double a) { - TrapReason base_trap = kTrapCount; - int64_t val = ExecuteI64UConvertF64(a, &base_trap); - if (base_trap == kTrapCount) { - return val; - } - return std::isnan(a) ? 0 - : (a < 0.0 ? std::numeric_limits::min() - : std::numeric_limits::max()); -} - int64_t ExecuteI64SConvertI32(int32_t a, TrapReason* trap) { return static_cast(a); } @@ -1634,28 +1577,28 @@ class WasmInterpreterInternals { InterpreterCode* code, pc_t pc, int* const len) { switch (opcode) { case kExprI32SConvertSatF32: - Push(WasmValue(ExecuteConvertSaturate(Pop().to()))); + Push(WasmValue(base::saturated_cast(Pop().to()))); return true; case kExprI32UConvertSatF32: - Push(WasmValue(ExecuteConvertSaturate(Pop().to()))); + Push(WasmValue(base::saturated_cast(Pop().to()))); return true; case kExprI32SConvertSatF64: - Push(WasmValue(ExecuteConvertSaturate(Pop().to()))); + Push(WasmValue(base::saturated_cast(Pop().to()))); return true; case kExprI32UConvertSatF64: - Push(WasmValue(ExecuteConvertSaturate(Pop().to()))); + Push(WasmValue(base::saturated_cast(Pop().to()))); return true; case kExprI64SConvertSatF32: - Push(WasmValue(ExecuteI64SConvertSatF32(Pop().to()))); + Push(WasmValue(base::saturated_cast(Pop().to()))); return true; case kExprI64UConvertSatF32: - Push(WasmValue(ExecuteI64UConvertSatF32(Pop().to()))); + Push(WasmValue(base::saturated_cast(Pop().to()))); return true; case kExprI64SConvertSatF64: - Push(WasmValue(ExecuteI64SConvertSatF64(Pop().to()))); + Push(WasmValue(base::saturated_cast(Pop().to()))); return true; case kExprI64UConvertSatF64: - Push(WasmValue(ExecuteI64UConvertSatF64(Pop().to()))); + Push(WasmValue(base::saturated_cast(Pop().to()))); return true; case kExprMemoryInit: { MemoryInitImmediate imm(decoder,