| 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 631 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 642 break; | 642 break; |
| 643 case wasm::kExprF64Gt: | 643 case wasm::kExprF64Gt: |
| 644 op = m->Float64LessThan(); | 644 op = m->Float64LessThan(); |
| 645 std::swap(left, right); | 645 std::swap(left, right); |
| 646 break; | 646 break; |
| 647 case wasm::kExprF64Ge: | 647 case wasm::kExprF64Ge: |
| 648 op = m->Float64LessThanOrEqual(); | 648 op = m->Float64LessThanOrEqual(); |
| 649 std::swap(left, right); | 649 std::swap(left, right); |
| 650 break; | 650 break; |
| 651 case wasm::kExprF32Min: | 651 case wasm::kExprF32Min: |
| 652 return BuildF32Min(left, right); | 652 op = m->Float32Min(); |
| 653 break; |
| 653 case wasm::kExprF64Min: | 654 case wasm::kExprF64Min: |
| 654 op = m->Float64Min(); | 655 op = m->Float64Min(); |
| 655 break; | 656 break; |
| 656 case wasm::kExprF32Max: | 657 case wasm::kExprF32Max: |
| 657 return BuildF32Max(left, right); | 658 op = m->Float32Max(); |
| 659 break; |
| 658 case wasm::kExprF64Max: | 660 case wasm::kExprF64Max: |
| 659 op = m->Float64Max(); | 661 op = m->Float64Max(); |
| 660 break; | 662 break; |
| 661 case wasm::kExprF64Pow: | 663 case wasm::kExprF64Pow: |
| 662 return BuildF64Pow(left, right); | 664 return BuildF64Pow(left, right); |
| 663 case wasm::kExprF64Atan2: | 665 case wasm::kExprF64Atan2: |
| 664 op = m->Float64Atan2(); | 666 op = m->Float64Atan2(); |
| 665 break; | 667 break; |
| 666 case wasm::kExprF64Mod: | 668 case wasm::kExprF64Mod: |
| 667 return BuildF64Mod(left, right); | 669 return BuildF64Mod(left, right); |
| (...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1231 Node* new_high_word = | 1233 Node* new_high_word = |
| 1232 Binop(wasm::kExprI32Ior, Binop(wasm::kExprI32And, high_word_left, | 1234 Binop(wasm::kExprI32Ior, Binop(wasm::kExprI32And, high_word_left, |
| 1233 jsgraph()->Int32Constant(0x7fffffff)), | 1235 jsgraph()->Int32Constant(0x7fffffff)), |
| 1234 Binop(wasm::kExprI32And, high_word_right, | 1236 Binop(wasm::kExprI32And, high_word_right, |
| 1235 jsgraph()->Int32Constant(0x80000000))); | 1237 jsgraph()->Int32Constant(0x80000000))); |
| 1236 | 1238 |
| 1237 return graph()->NewNode(m->Float64InsertHighWord32(), left, new_high_word); | 1239 return graph()->NewNode(m->Float64InsertHighWord32(), left, new_high_word); |
| 1238 #endif | 1240 #endif |
| 1239 } | 1241 } |
| 1240 | 1242 |
| 1241 Node* WasmGraphBuilder::BuildF32Min(Node* left, Node* right) { | |
| 1242 Diamond left_le_right(graph(), jsgraph()->common(), | |
| 1243 Binop(wasm::kExprF32Le, left, right)); | |
| 1244 | |
| 1245 Diamond right_lt_left(graph(), jsgraph()->common(), | |
| 1246 Binop(wasm::kExprF32Lt, right, left)); | |
| 1247 | |
| 1248 Diamond left_is_not_nan(graph(), jsgraph()->common(), | |
| 1249 Binop(wasm::kExprF32Eq, left, left)); | |
| 1250 | |
| 1251 return left_le_right.Phi( | |
| 1252 wasm::kAstF32, left, | |
| 1253 right_lt_left.Phi( | |
| 1254 wasm::kAstF32, right, | |
| 1255 left_is_not_nan.Phi( | |
| 1256 wasm::kAstF32, | |
| 1257 Binop(wasm::kExprF32Mul, right, Float32Constant(1.0)), | |
| 1258 Binop(wasm::kExprF32Mul, left, Float32Constant(1.0))))); | |
| 1259 } | |
| 1260 | |
| 1261 Node* WasmGraphBuilder::BuildF32Max(Node* left, Node* right) { | |
| 1262 Diamond left_ge_right(graph(), jsgraph()->common(), | |
| 1263 Binop(wasm::kExprF32Ge, left, right)); | |
| 1264 | |
| 1265 Diamond right_gt_left(graph(), jsgraph()->common(), | |
| 1266 Binop(wasm::kExprF32Gt, right, left)); | |
| 1267 | |
| 1268 Diamond left_is_not_nan(graph(), jsgraph()->common(), | |
| 1269 Binop(wasm::kExprF32Eq, left, left)); | |
| 1270 | |
| 1271 return left_ge_right.Phi( | |
| 1272 wasm::kAstF32, left, | |
| 1273 right_gt_left.Phi( | |
| 1274 wasm::kAstF32, right, | |
| 1275 left_is_not_nan.Phi( | |
| 1276 wasm::kAstF32, | |
| 1277 Binop(wasm::kExprF32Mul, right, Float32Constant(1.0)), | |
| 1278 Binop(wasm::kExprF32Mul, left, Float32Constant(1.0))))); | |
| 1279 } | |
| 1280 | |
| 1281 Node* WasmGraphBuilder::BuildI32SConvertF32(Node* input, | 1243 Node* WasmGraphBuilder::BuildI32SConvertF32(Node* input, |
| 1282 wasm::WasmCodePosition position) { | 1244 wasm::WasmCodePosition position) { |
| 1283 MachineOperatorBuilder* m = jsgraph()->machine(); | 1245 MachineOperatorBuilder* m = jsgraph()->machine(); |
| 1284 // Truncation of the input value is needed for the overflow check later. | 1246 // Truncation of the input value is needed for the overflow check later. |
| 1285 Node* trunc = Unop(wasm::kExprF32Trunc, input); | 1247 Node* trunc = Unop(wasm::kExprF32Trunc, input); |
| 1286 Node* result = graph()->NewNode(m->TruncateFloat32ToInt32(), trunc); | 1248 Node* result = graph()->NewNode(m->TruncateFloat32ToInt32(), trunc); |
| 1287 | 1249 |
| 1288 // Convert the result back to f64. If we end up at a different value than the | 1250 // Convert the result back to f64. If we end up at a different value than the |
| 1289 // truncated input value, then there has been an overflow and we trap. | 1251 // truncated input value, then there has been an overflow and we trap. |
| 1290 Node* check = Unop(wasm::kExprF32SConvertI32, result); | 1252 Node* check = Unop(wasm::kExprF32SConvertI32, result); |
| (...skipping 1975 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3266 function_->code_start_offset), | 3228 function_->code_start_offset), |
| 3267 compile_ms); | 3229 compile_ms); |
| 3268 } | 3230 } |
| 3269 | 3231 |
| 3270 return code; | 3232 return code; |
| 3271 } | 3233 } |
| 3272 | 3234 |
| 3273 } // namespace compiler | 3235 } // namespace compiler |
| 3274 } // namespace internal | 3236 } // namespace internal |
| 3275 } // namespace v8 | 3237 } // namespace v8 |
| OLD | NEW |