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 1130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1141 | 1141 |
1142 | 1142 |
1143 TEST(Run_WasmFloat64Unops) { | 1143 TEST(Run_WasmFloat64Unops) { |
1144 TestFloat64UnopWithConvert(kExprF64Abs, 108, 108.125); | 1144 TestFloat64UnopWithConvert(kExprF64Abs, 108, 108.125); |
1145 TestFloat64UnopWithConvert(kExprF64Abs, 209, -209.125); | 1145 TestFloat64UnopWithConvert(kExprF64Abs, 209, -209.125); |
1146 TestFloat64UnopWithConvert(kExprF64Neg, -209, 209.125); | 1146 TestFloat64UnopWithConvert(kExprF64Neg, -209, 209.125); |
1147 TestFloat64UnopWithConvert(kExprF64Sqrt, 13, 169.4); | 1147 TestFloat64UnopWithConvert(kExprF64Sqrt, 13, 169.4); |
1148 } | 1148 } |
1149 | 1149 |
1150 | 1150 |
| 1151 TEST(Run_WasmFloat32Neg) { |
| 1152 WasmRunner<float> r(MachineType::Float32()); |
| 1153 BUILD(r, WASM_F32_NEG(WASM_GET_LOCAL(0))); |
| 1154 |
| 1155 FOR_FLOAT32_INPUTS(i) { CheckFloatEq(-(*i), r.Call(*i)); } |
| 1156 |
| 1157 // The difference between +0 and -0 matters here. |
| 1158 CHECK_EQ(bit_cast<uint32_t>(-0.0f), bit_cast<uint32_t>(r.Call(0.0f))); |
| 1159 CHECK_EQ(bit_cast<uint32_t>(0.0f), bit_cast<uint32_t>(r.Call(-0.0f))); |
| 1160 } |
| 1161 |
| 1162 |
| 1163 TEST(Run_WasmFloat64Neg) { |
| 1164 WasmRunner<double> r(MachineType::Float64()); |
| 1165 BUILD(r, WASM_F64_NEG(WASM_GET_LOCAL(0))); |
| 1166 |
| 1167 FOR_FLOAT64_INPUTS(i) { CheckDoubleEq(-(*i), r.Call(*i)); } |
| 1168 |
| 1169 // The difference between +0 and -0 matters here. |
| 1170 CHECK_EQ(bit_cast<uint64_t>(-0.0), bit_cast<uint64_t>(r.Call(0.0))); |
| 1171 CHECK_EQ(bit_cast<uint64_t>(0.0), bit_cast<uint64_t>(r.Call(-0.0))); |
| 1172 } |
| 1173 |
| 1174 |
1151 TEST(Run_Wasm_IfElse_P) { | 1175 TEST(Run_Wasm_IfElse_P) { |
1152 WasmRunner<int32_t> r(MachineType::Int32()); | 1176 WasmRunner<int32_t> r(MachineType::Int32()); |
1153 // if (p0) return 11; else return 22; | 1177 // if (p0) return 11; else return 22; |
1154 BUILD(r, WASM_IF_ELSE(WASM_GET_LOCAL(0), // -- | 1178 BUILD(r, WASM_IF_ELSE(WASM_GET_LOCAL(0), // -- |
1155 WASM_I8(11), // -- | 1179 WASM_I8(11), // -- |
1156 WASM_I8(22))); // -- | 1180 WASM_I8(22))); // -- |
1157 FOR_INT32_INPUTS(i) { | 1181 FOR_INT32_INPUTS(i) { |
1158 int32_t expected = *i ? 11 : 22; | 1182 int32_t expected = *i ? 11 : 22; |
1159 CHECK_EQ(expected, r.Call(*i)); | 1183 CHECK_EQ(expected, r.Call(*i)); |
1160 } | 1184 } |
(...skipping 2096 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3257 | 3281 |
3258 | 3282 |
3259 TEST(Run_Wasm_F32CopySign) { | 3283 TEST(Run_Wasm_F32CopySign) { |
3260 WasmRunner<float> r(MachineType::Float32(), MachineType::Float32()); | 3284 WasmRunner<float> r(MachineType::Float32(), MachineType::Float32()); |
3261 BUILD(r, WASM_F32_COPYSIGN(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); | 3285 BUILD(r, WASM_F32_COPYSIGN(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); |
3262 | 3286 |
3263 FOR_FLOAT32_INPUTS(i) { | 3287 FOR_FLOAT32_INPUTS(i) { |
3264 FOR_FLOAT32_INPUTS(j) { CheckFloatEq(copysign(*i, *j), r.Call(*i, *j)); } | 3288 FOR_FLOAT32_INPUTS(j) { CheckFloatEq(copysign(*i, *j), r.Call(*i, *j)); } |
3265 } | 3289 } |
3266 } | 3290 } |
OLD | NEW |