Chromium Code Reviews| Index: src/assembler.cc |
| diff --git a/src/assembler.cc b/src/assembler.cc |
| index 5c8c2ce16d97cf646fd774a4b8c1bcc960c75702..3fbff975c610aaec2f876858f061fe912e986563 100644 |
| --- a/src/assembler.cc |
| +++ b/src/assembler.cc |
| @@ -1147,66 +1147,112 @@ ExternalReference ExternalReference::compute_output_frames_function( |
| Redirect(isolate, FUNCTION_ADDR(Deoptimizer::ComputeOutputFrames))); |
| } |
| -static void f32_trunc_wrapper(float* param) { *param = truncf(*param); } |
| +static void wasm_f32_trunc_wrapper(float* param) { *param = truncf(*param); } |
|
titzer
2016/02/28 15:26:03
Can we extract these wrappers to a header/cc file
ahaas
2016/03/02 14:02:56
Done.
I only extracted the static functions, the o
titzer
2016/03/02 14:06:20
The goal there is to introduce an interface betwee
|
| -ExternalReference ExternalReference::f32_trunc_wrapper_function( |
| - Isolate* isolate) { |
| - return ExternalReference(Redirect(isolate, FUNCTION_ADDR(f32_trunc_wrapper))); |
| +ExternalReference ExternalReference::wasm_f32_trunc(Isolate* isolate) { |
| + return ExternalReference( |
| + Redirect(isolate, FUNCTION_ADDR(wasm_f32_trunc_wrapper))); |
| } |
| -static void f32_floor_wrapper(float* param) { *param = floorf(*param); } |
| +static void wasm_f32_floor_wrapper(float* param) { *param = floorf(*param); } |
| -ExternalReference ExternalReference::f32_floor_wrapper_function( |
| - Isolate* isolate) { |
| - return ExternalReference(Redirect(isolate, FUNCTION_ADDR(f32_floor_wrapper))); |
| +ExternalReference ExternalReference::wasm_f32_floor(Isolate* isolate) { |
| + return ExternalReference( |
| + Redirect(isolate, FUNCTION_ADDR(wasm_f32_floor_wrapper))); |
| } |
| -static void f32_ceil_wrapper(float* param) { *param = ceilf(*param); } |
| +static void wasm_f32_ceil_wrapper(float* param) { *param = ceilf(*param); } |
| -ExternalReference ExternalReference::f32_ceil_wrapper_function( |
| - Isolate* isolate) { |
| - return ExternalReference(Redirect(isolate, FUNCTION_ADDR(f32_ceil_wrapper))); |
| +ExternalReference ExternalReference::wasm_f32_ceil(Isolate* isolate) { |
| + return ExternalReference( |
| + Redirect(isolate, FUNCTION_ADDR(wasm_f32_ceil_wrapper))); |
| } |
| -static void f32_nearest_int_wrapper(float* param) { |
| +static void wasm_f32_nearest_int_wrapper(float* param) { |
| *param = nearbyintf(*param); |
| } |
| -ExternalReference ExternalReference::f32_nearest_int_wrapper_function( |
| - Isolate* isolate) { |
| +ExternalReference ExternalReference::wasm_f32_nearest_int(Isolate* isolate) { |
| return ExternalReference( |
| - Redirect(isolate, FUNCTION_ADDR(f32_nearest_int_wrapper))); |
| + Redirect(isolate, FUNCTION_ADDR(wasm_f32_nearest_int_wrapper))); |
| } |
| -static void f64_trunc_wrapper(double* param) { *param = trunc(*param); } |
| +static void wasm_f64_trunc_wrapper(double* param) { *param = trunc(*param); } |
| -ExternalReference ExternalReference::f64_trunc_wrapper_function( |
| - Isolate* isolate) { |
| - return ExternalReference(Redirect(isolate, FUNCTION_ADDR(f64_trunc_wrapper))); |
| +ExternalReference ExternalReference::wasm_f64_trunc(Isolate* isolate) { |
| + return ExternalReference( |
| + Redirect(isolate, FUNCTION_ADDR(wasm_f64_trunc_wrapper))); |
| } |
| -static void f64_floor_wrapper(double* param) { *param = floor(*param); } |
| +static void wasm_f64_floor_wrapper(double* param) { *param = floor(*param); } |
| -ExternalReference ExternalReference::f64_floor_wrapper_function( |
| - Isolate* isolate) { |
| - return ExternalReference(Redirect(isolate, FUNCTION_ADDR(f64_floor_wrapper))); |
| +ExternalReference ExternalReference::wasm_f64_floor(Isolate* isolate) { |
| + return ExternalReference( |
| + Redirect(isolate, FUNCTION_ADDR(wasm_f64_floor_wrapper))); |
| } |
| -static void f64_ceil_wrapper(double* param) { *param = ceil(*param); } |
| +static void wasm_f64_ceil_wrapper(double* param) { *param = ceil(*param); } |
| -ExternalReference ExternalReference::f64_ceil_wrapper_function( |
| - Isolate* isolate) { |
| - return ExternalReference(Redirect(isolate, FUNCTION_ADDR(f64_ceil_wrapper))); |
| +ExternalReference ExternalReference::wasm_f64_ceil(Isolate* isolate) { |
| + return ExternalReference( |
| + Redirect(isolate, FUNCTION_ADDR(wasm_f64_ceil_wrapper))); |
| } |
| -static void f64_nearest_int_wrapper(double* param) { |
| +static void wasm_f64_nearest_int_wrapper(double* param) { |
| *param = nearbyint(*param); |
| } |
| -ExternalReference ExternalReference::f64_nearest_int_wrapper_function( |
| - Isolate* isolate) { |
| +ExternalReference ExternalReference::wasm_f64_nearest_int(Isolate* isolate) { |
| + return ExternalReference( |
| + Redirect(isolate, FUNCTION_ADDR(wasm_f64_nearest_int_wrapper))); |
| +} |
| + |
| +static void wasm_int64_to_float32_wrapper(int64_t* input, float* output) { |
| + *output = static_cast<float>(*input); |
| +} |
| + |
| +ExternalReference ExternalReference::wasm_int64_to_float32(Isolate* isolate) { |
| + return ExternalReference( |
| + Redirect(isolate, FUNCTION_ADDR(wasm_int64_to_float32_wrapper))); |
| +} |
| + |
| +static void wasm_uint64_to_float32_wrapper(uint64_t* input, float* output) { |
| + uint64_t value = *input; |
| + |
| +#if V8_CC_MSVC |
| + // static_cast<float> is compiled to static_cast<float>(static_cast<double>) |
| + // by MSVC. Since static_cast<double> can loose information which may be |
| + // required for correct rounding, we take the OR of the 11 LSB and store them |
| + // the resulting value in a bit which is representable in float64 but not |
| + // representable in float32 (I picked 30 because it sounded good). |
| + if (value & 0x8000000000000000) { |
| + value |= (((value & 0x7ff) != 0 ? 1 : 0) << 30); |
| + } |
| +#endif |
| + *output = static_cast<float>(value); |
| +} |
| + |
| +ExternalReference ExternalReference::wasm_uint64_to_float32(Isolate* isolate) { |
| + return ExternalReference( |
| + Redirect(isolate, FUNCTION_ADDR(wasm_uint64_to_float32_wrapper))); |
| +} |
| + |
| +static void wasm_int64_to_float64_wrapper(int64_t* input, double* output) { |
| + *output = static_cast<double>(*input); |
| +} |
| + |
| +ExternalReference ExternalReference::wasm_int64_to_float64(Isolate* isolate) { |
| + return ExternalReference( |
| + Redirect(isolate, FUNCTION_ADDR(wasm_int64_to_float64_wrapper))); |
| +} |
| + |
| +static void wasm_uint64_to_float64_wrapper(uint64_t* input, double* output) { |
| + *output = static_cast<double>(*input); |
| +} |
| + |
| +ExternalReference ExternalReference::wasm_uint64_to_float64(Isolate* isolate) { |
| return ExternalReference( |
| - Redirect(isolate, FUNCTION_ADDR(f64_nearest_int_wrapper))); |
| + Redirect(isolate, FUNCTION_ADDR(wasm_uint64_to_float64_wrapper))); |
| } |
| ExternalReference ExternalReference::log_enter_external_function( |