| Index: src/wasm/wasm-external-refs.h
|
| diff --git a/src/wasm/wasm-external-refs.h b/src/wasm/wasm-external-refs.h
|
| index 409f199fbba82f3cee08ab05691188322165f9b0..1004f50e4c2b8e7b89257d2505ad74fbb9081df5 100644
|
| --- a/src/wasm/wasm-external-refs.h
|
| +++ b/src/wasm/wasm-external-refs.h
|
| @@ -92,6 +92,53 @@ static void uint64_to_float64_wrapper(uint64_t* input, double* output) {
|
| #endif
|
| }
|
|
|
| +static int32_t float32_to_int64_wrapper(float* input, int64_t* output) {
|
| + // We use "<" here to check the upper bound because of rounding problems: With
|
| + // "<=" some inputs would be considered within int64 range which are actually
|
| + // not within int64 range.
|
| + if (*input >= static_cast<float>(std::numeric_limits<int64_t>::min()) &&
|
| + *input < static_cast<float>(std::numeric_limits<int64_t>::max())) {
|
| + *output = static_cast<int64_t>(*input);
|
| + return 1;
|
| + }
|
| + return 0;
|
| +}
|
| +
|
| +static int32_t float32_to_uint64_wrapper(float* input, uint64_t* output) {
|
| + // We use "<" here to check the upper bound because of rounding problems: With
|
| + // "<=" some inputs would be considered within uint64 range which are actually
|
| + // not within uint64 range.
|
| + if (*input > -1.0 &&
|
| + *input < static_cast<float>(std::numeric_limits<uint64_t>::max())) {
|
| + *output = static_cast<uint64_t>(*input);
|
| + return 1;
|
| + }
|
| + return 0;
|
| +}
|
| +
|
| +static int32_t float64_to_int64_wrapper(double* input, int64_t* output) {
|
| + // We use "<" here to check the upper bound because of rounding problems: With
|
| + // "<=" some inputs would be considered within int64 range which are actually
|
| + // not within int64 range.
|
| + if (*input >= static_cast<double>(std::numeric_limits<int64_t>::min()) &&
|
| + *input < static_cast<double>(std::numeric_limits<int64_t>::max())) {
|
| + *output = static_cast<int64_t>(*input);
|
| + return 1;
|
| + }
|
| + return 0;
|
| +}
|
| +
|
| +static int32_t float64_to_uint64_wrapper(double* input, uint64_t* output) {
|
| + // We use "<" here to check the upper bound because of rounding problems: With
|
| + // "<=" some inputs would be considered within uint64 range which are actually
|
| + // not within uint64 range.
|
| + if (*input > -1.0 &&
|
| + *input < static_cast<double>(std::numeric_limits<uint64_t>::max())) {
|
| + *output = static_cast<uint64_t>(*input);
|
| + return 1;
|
| + }
|
| + return 0;
|
| +}
|
| } // namespace wasm
|
| } // namespace internal
|
| } // namespace v8
|
|
|