OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <stdlib.h> | 5 #include <stdlib.h> |
6 #include <string.h> | 6 #include <string.h> |
7 | 7 |
8 #include "src/compiler/graph-visualizer.h" | 8 #include "src/compiler/graph-visualizer.h" |
9 #include "src/compiler/js-graph.h" | 9 #include "src/compiler/js-graph.h" |
10 #include "src/compiler/wasm-compiler.h" | 10 #include "src/compiler/wasm-compiler.h" |
(...skipping 3150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3161 FOR_FLOAT64_INPUTS(i) { CheckDoubleEq(nearbyint(*i), r.Call(*i)); } | 3161 FOR_FLOAT64_INPUTS(i) { CheckDoubleEq(nearbyint(*i), r.Call(*i)); } |
3162 } | 3162 } |
3163 | 3163 |
3164 | 3164 |
3165 TEST(Run_Wasm_F32Min) { | 3165 TEST(Run_Wasm_F32Min) { |
3166 WasmRunner<float> r(MachineType::Float32(), MachineType::Float32()); | 3166 WasmRunner<float> r(MachineType::Float32(), MachineType::Float32()); |
3167 BUILD(r, WASM_F32_MIN(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); | 3167 BUILD(r, WASM_F32_MIN(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); |
3168 | 3168 |
3169 FOR_FLOAT32_INPUTS(i) { | 3169 FOR_FLOAT32_INPUTS(i) { |
3170 FOR_FLOAT32_INPUTS(j) { | 3170 FOR_FLOAT32_INPUTS(j) { |
3171 float expected = *i < *j ? *i : *j; | 3171 float expected; |
| 3172 if (*i < *j) { |
| 3173 expected = *i; |
| 3174 } else if (*j < *i) { |
| 3175 expected = *j; |
| 3176 } else if (*i != *i) { |
| 3177 // If *i or *j is NaN, then the result is NaN. |
| 3178 expected = *i; |
| 3179 } else { |
| 3180 expected = *j; |
| 3181 } |
| 3182 |
3172 CheckFloatEq(expected, r.Call(*i, *j)); | 3183 CheckFloatEq(expected, r.Call(*i, *j)); |
3173 } | 3184 } |
3174 } | 3185 } |
3175 } | 3186 } |
3176 | 3187 |
3177 | 3188 |
3178 TEST(Run_Wasm_F64Min) { | 3189 TEST(Run_Wasm_F64Min) { |
3179 WasmRunner<double> r(MachineType::Float64(), MachineType::Float64()); | 3190 WasmRunner<double> r(MachineType::Float64(), MachineType::Float64()); |
3180 BUILD(r, WASM_F64_MIN(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); | 3191 BUILD(r, WASM_F64_MIN(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); |
3181 | 3192 |
3182 FOR_FLOAT64_INPUTS(i) { | 3193 FOR_FLOAT64_INPUTS(i) { |
3183 FOR_FLOAT64_INPUTS(j) { | 3194 FOR_FLOAT64_INPUTS(j) { |
3184 double expected = *i < *j ? *i : *j; | 3195 double expected; |
| 3196 if (*i < *j) { |
| 3197 expected = *i; |
| 3198 } else if (*j < *i) { |
| 3199 expected = *j; |
| 3200 } else if (*i != *i) { |
| 3201 // If *i or *j is NaN, then the result is NaN. |
| 3202 expected = *i; |
| 3203 } else { |
| 3204 expected = *j; |
| 3205 } |
| 3206 |
3185 CheckDoubleEq(expected, r.Call(*i, *j)); | 3207 CheckDoubleEq(expected, r.Call(*i, *j)); |
3186 } | 3208 } |
3187 } | 3209 } |
3188 } | 3210 } |
3189 | 3211 |
3190 | 3212 |
3191 TEST(Run_Wasm_F32Max) { | 3213 TEST(Run_Wasm_F32Max) { |
3192 WasmRunner<float> r(MachineType::Float32(), MachineType::Float32()); | 3214 WasmRunner<float> r(MachineType::Float32(), MachineType::Float32()); |
3193 BUILD(r, WASM_F32_MAX(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); | 3215 BUILD(r, WASM_F32_MAX(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); |
3194 | 3216 |
3195 FOR_FLOAT32_INPUTS(i) { | 3217 FOR_FLOAT32_INPUTS(i) { |
3196 FOR_FLOAT32_INPUTS(j) { | 3218 FOR_FLOAT32_INPUTS(j) { |
3197 float expected = *i > *j ? *i : *j; | 3219 float expected; |
| 3220 if (*i > *j) { |
| 3221 expected = *i; |
| 3222 } else if (*j > *i) { |
| 3223 expected = *j; |
| 3224 } else if (*i != *i) { |
| 3225 // If *i or *j is NaN, then the result is NaN. |
| 3226 expected = *i; |
| 3227 } else { |
| 3228 expected = *j; |
| 3229 } |
| 3230 |
3198 CheckFloatEq(expected, r.Call(*i, *j)); | 3231 CheckFloatEq(expected, r.Call(*i, *j)); |
3199 } | 3232 } |
3200 } | 3233 } |
3201 } | 3234 } |
3202 | 3235 |
3203 | 3236 |
3204 TEST(Run_Wasm_F64Max) { | 3237 TEST(Run_Wasm_F64Max) { |
3205 WasmRunner<double> r(MachineType::Float64(), MachineType::Float64()); | 3238 WasmRunner<double> r(MachineType::Float64(), MachineType::Float64()); |
3206 BUILD(r, WASM_F64_MAX(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); | 3239 BUILD(r, WASM_F64_MAX(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); |
3207 | 3240 |
3208 FOR_FLOAT64_INPUTS(i) { | 3241 FOR_FLOAT64_INPUTS(i) { |
3209 FOR_FLOAT64_INPUTS(j) { | 3242 FOR_FLOAT64_INPUTS(j) { |
3210 double expected = *i > *j ? *i : *j; | 3243 double expected; |
| 3244 if (*i > *j) { |
| 3245 expected = *i; |
| 3246 } else if (*j > *i) { |
| 3247 expected = *j; |
| 3248 } else if (*i != *i) { |
| 3249 // If *i or *j is NaN, then the result is NaN. |
| 3250 expected = *i; |
| 3251 } else { |
| 3252 expected = *j; |
| 3253 } |
| 3254 |
3211 CheckDoubleEq(expected, r.Call(*i, *j)); | 3255 CheckDoubleEq(expected, r.Call(*i, *j)); |
3212 } | 3256 } |
3213 } | 3257 } |
3214 } | 3258 } |
3215 | 3259 |
3216 | 3260 |
3217 #if WASM_64 | 3261 #if WASM_64 |
3218 TEST(Run_Wasm_F32SConvertI64) { | 3262 TEST(Run_Wasm_F32SConvertI64) { |
3219 WasmRunner<float> r(MachineType::Int64()); | 3263 WasmRunner<float> r(MachineType::Int64()); |
3220 BUILD(r, WASM_F32_SCONVERT_I64(WASM_GET_LOCAL(0))); | 3264 BUILD(r, WASM_F32_SCONVERT_I64(WASM_GET_LOCAL(0))); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3257 | 3301 |
3258 | 3302 |
3259 TEST(Run_Wasm_F32CopySign) { | 3303 TEST(Run_Wasm_F32CopySign) { |
3260 WasmRunner<float> r(MachineType::Float32(), MachineType::Float32()); | 3304 WasmRunner<float> r(MachineType::Float32(), MachineType::Float32()); |
3261 BUILD(r, WASM_F32_COPYSIGN(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); | 3305 BUILD(r, WASM_F32_COPYSIGN(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); |
3262 | 3306 |
3263 FOR_FLOAT32_INPUTS(i) { | 3307 FOR_FLOAT32_INPUTS(i) { |
3264 FOR_FLOAT32_INPUTS(j) { CheckFloatEq(copysign(*i, *j), r.Call(*i, *j)); } | 3308 FOR_FLOAT32_INPUTS(j) { CheckFloatEq(copysign(*i, *j), r.Call(*i, *j)); } |
3265 } | 3309 } |
3266 } | 3310 } |
OLD | NEW |