| 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 "src/compiler/wasm-compiler.h" | 5 #include "src/compiler/wasm-compiler.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "src/isolate-inl.h" | 9 #include "src/isolate-inl.h" |
| 10 | 10 |
| (...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 598 op = m->Float64LessThan(); | 598 op = m->Float64LessThan(); |
| 599 std::swap(left, right); | 599 std::swap(left, right); |
| 600 break; | 600 break; |
| 601 case wasm::kExprF64Ge: | 601 case wasm::kExprF64Ge: |
| 602 op = m->Float64LessThanOrEqual(); | 602 op = m->Float64LessThanOrEqual(); |
| 603 std::swap(left, right); | 603 std::swap(left, right); |
| 604 break; | 604 break; |
| 605 case wasm::kExprF32Min: | 605 case wasm::kExprF32Min: |
| 606 return BuildF32Min(left, right); | 606 return BuildF32Min(left, right); |
| 607 case wasm::kExprF64Min: | 607 case wasm::kExprF64Min: |
| 608 return BuildF64Min(left, right); | 608 op = m->Float64Min(); |
| 609 break; |
| 609 case wasm::kExprF32Max: | 610 case wasm::kExprF32Max: |
| 610 return BuildF32Max(left, right); | 611 return BuildF32Max(left, right); |
| 611 case wasm::kExprF64Max: | 612 case wasm::kExprF64Max: |
| 612 return BuildF64Max(left, right); | 613 op = m->Float64Max(); |
| 614 break; |
| 613 case wasm::kExprF64Pow: | 615 case wasm::kExprF64Pow: |
| 614 return BuildF64Pow(left, right); | 616 return BuildF64Pow(left, right); |
| 615 case wasm::kExprF64Atan2: | 617 case wasm::kExprF64Atan2: |
| 616 op = m->Float64Atan2(); | 618 op = m->Float64Atan2(); |
| 617 break; | 619 break; |
| 618 case wasm::kExprF64Mod: | 620 case wasm::kExprF64Mod: |
| 619 return BuildF64Mod(left, right); | 621 return BuildF64Mod(left, right); |
| 620 case wasm::kExprI32AsmjsDivS: | 622 case wasm::kExprI32AsmjsDivS: |
| 621 return BuildI32AsmjsDivS(left, right); | 623 return BuildI32AsmjsDivS(left, right); |
| 622 case wasm::kExprI32AsmjsDivU: | 624 case wasm::kExprI32AsmjsDivU: |
| (...skipping 636 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1259 return left_ge_right.Phi( | 1261 return left_ge_right.Phi( |
| 1260 wasm::kAstF32, left, | 1262 wasm::kAstF32, left, |
| 1261 right_gt_left.Phi( | 1263 right_gt_left.Phi( |
| 1262 wasm::kAstF32, right, | 1264 wasm::kAstF32, right, |
| 1263 left_is_not_nan.Phi( | 1265 left_is_not_nan.Phi( |
| 1264 wasm::kAstF32, | 1266 wasm::kAstF32, |
| 1265 Binop(wasm::kExprF32Mul, right, Float32Constant(1.0)), | 1267 Binop(wasm::kExprF32Mul, right, Float32Constant(1.0)), |
| 1266 Binop(wasm::kExprF32Mul, left, Float32Constant(1.0))))); | 1268 Binop(wasm::kExprF32Mul, left, Float32Constant(1.0))))); |
| 1267 } | 1269 } |
| 1268 | 1270 |
| 1269 Node* WasmGraphBuilder::BuildF64Min(Node* left, Node* right) { | |
| 1270 Diamond left_le_right(graph(), jsgraph()->common(), | |
| 1271 Binop(wasm::kExprF64Le, left, right)); | |
| 1272 | |
| 1273 Diamond right_lt_left(graph(), jsgraph()->common(), | |
| 1274 Binop(wasm::kExprF64Lt, right, left)); | |
| 1275 | |
| 1276 Diamond left_is_not_nan(graph(), jsgraph()->common(), | |
| 1277 Binop(wasm::kExprF64Eq, left, left)); | |
| 1278 | |
| 1279 return left_le_right.Phi( | |
| 1280 wasm::kAstF64, left, | |
| 1281 right_lt_left.Phi( | |
| 1282 wasm::kAstF64, right, | |
| 1283 left_is_not_nan.Phi( | |
| 1284 wasm::kAstF64, | |
| 1285 Binop(wasm::kExprF64Mul, right, Float64Constant(1.0)), | |
| 1286 Binop(wasm::kExprF64Mul, left, Float64Constant(1.0))))); | |
| 1287 } | |
| 1288 | |
| 1289 Node* WasmGraphBuilder::BuildF64Max(Node* left, Node* right) { | |
| 1290 Diamond left_ge_right(graph(), jsgraph()->common(), | |
| 1291 Binop(wasm::kExprF64Ge, left, right)); | |
| 1292 | |
| 1293 Diamond right_gt_left(graph(), jsgraph()->common(), | |
| 1294 Binop(wasm::kExprF64Lt, right, left)); | |
| 1295 | |
| 1296 Diamond left_is_not_nan(graph(), jsgraph()->common(), | |
| 1297 Binop(wasm::kExprF64Eq, left, left)); | |
| 1298 | |
| 1299 return left_ge_right.Phi( | |
| 1300 wasm::kAstF64, left, | |
| 1301 right_gt_left.Phi( | |
| 1302 wasm::kAstF64, right, | |
| 1303 left_is_not_nan.Phi( | |
| 1304 wasm::kAstF64, | |
| 1305 Binop(wasm::kExprF64Mul, right, Float64Constant(1.0)), | |
| 1306 Binop(wasm::kExprF64Mul, left, Float64Constant(1.0))))); | |
| 1307 } | |
| 1308 | |
| 1309 Node* WasmGraphBuilder::BuildI32SConvertF32(Node* input, | 1271 Node* WasmGraphBuilder::BuildI32SConvertF32(Node* input, |
| 1310 wasm::WasmCodePosition position) { | 1272 wasm::WasmCodePosition position) { |
| 1311 MachineOperatorBuilder* m = jsgraph()->machine(); | 1273 MachineOperatorBuilder* m = jsgraph()->machine(); |
| 1312 // Truncation of the input value is needed for the overflow check later. | 1274 // Truncation of the input value is needed for the overflow check later. |
| 1313 Node* trunc = Unop(wasm::kExprF32Trunc, input); | 1275 Node* trunc = Unop(wasm::kExprF32Trunc, input); |
| 1314 Node* result = graph()->NewNode(m->TruncateFloat32ToInt32(), trunc); | 1276 Node* result = graph()->NewNode(m->TruncateFloat32ToInt32(), trunc); |
| 1315 | 1277 |
| 1316 // Convert the result back to f64. If we end up at a different value than the | 1278 // Convert the result back to f64. If we end up at a different value than the |
| 1317 // truncated input value, then there has been an overflow and we trap. | 1279 // truncated input value, then there has been an overflow and we trap. |
| 1318 Node* check = Unop(wasm::kExprF32SConvertI32, result); | 1280 Node* check = Unop(wasm::kExprF32SConvertI32, result); |
| (...skipping 2177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3496 function_->code_start_offset), | 3458 function_->code_start_offset), |
| 3497 compile_ms); | 3459 compile_ms); |
| 3498 } | 3460 } |
| 3499 | 3461 |
| 3500 return code; | 3462 return code; |
| 3501 } | 3463 } |
| 3502 | 3464 |
| 3503 } // namespace compiler | 3465 } // namespace compiler |
| 3504 } // namespace internal | 3466 } // namespace internal |
| 3505 } // namespace v8 | 3467 } // namespace v8 |
| OLD | NEW |