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 583 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
594 break; | 594 break; |
595 case wasm::kExprF64Gt: | 595 case wasm::kExprF64Gt: |
596 op = m->Float64LessThan(); | 596 op = m->Float64LessThan(); |
597 std::swap(left, right); | 597 std::swap(left, right); |
598 break; | 598 break; |
599 case wasm::kExprF64Ge: | 599 case wasm::kExprF64Ge: |
600 op = m->Float64LessThanOrEqual(); | 600 op = m->Float64LessThanOrEqual(); |
601 std::swap(left, right); | 601 std::swap(left, right); |
602 break; | 602 break; |
603 case wasm::kExprF32Min: | 603 case wasm::kExprF32Min: |
604 return BuildF32Min(left, right); | 604 op = m->Float32Min(); |
| 605 break; |
605 case wasm::kExprF64Min: | 606 case wasm::kExprF64Min: |
606 op = m->Float64Min(); | 607 op = m->Float64Min(); |
607 break; | 608 break; |
608 case wasm::kExprF32Max: | 609 case wasm::kExprF32Max: |
609 return BuildF32Max(left, right); | 610 op = m->Float32Max(); |
| 611 break; |
610 case wasm::kExprF64Max: | 612 case wasm::kExprF64Max: |
611 op = m->Float64Max(); | 613 op = m->Float64Max(); |
612 break; | 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); |
(...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1183 Node* new_high_word = | 1185 Node* new_high_word = |
1184 Binop(wasm::kExprI32Ior, Binop(wasm::kExprI32And, high_word_left, | 1186 Binop(wasm::kExprI32Ior, Binop(wasm::kExprI32And, high_word_left, |
1185 jsgraph()->Int32Constant(0x7fffffff)), | 1187 jsgraph()->Int32Constant(0x7fffffff)), |
1186 Binop(wasm::kExprI32And, high_word_right, | 1188 Binop(wasm::kExprI32And, high_word_right, |
1187 jsgraph()->Int32Constant(0x80000000))); | 1189 jsgraph()->Int32Constant(0x80000000))); |
1188 | 1190 |
1189 return graph()->NewNode(m->Float64InsertHighWord32(), left, new_high_word); | 1191 return graph()->NewNode(m->Float64InsertHighWord32(), left, new_high_word); |
1190 #endif | 1192 #endif |
1191 } | 1193 } |
1192 | 1194 |
1193 Node* WasmGraphBuilder::BuildF32Min(Node* left, Node* right) { | |
1194 Diamond left_le_right(graph(), jsgraph()->common(), | |
1195 Binop(wasm::kExprF32Le, left, right)); | |
1196 | |
1197 Diamond right_lt_left(graph(), jsgraph()->common(), | |
1198 Binop(wasm::kExprF32Lt, right, left)); | |
1199 | |
1200 Diamond left_is_not_nan(graph(), jsgraph()->common(), | |
1201 Binop(wasm::kExprF32Eq, left, left)); | |
1202 | |
1203 return left_le_right.Phi( | |
1204 wasm::kAstF32, left, | |
1205 right_lt_left.Phi( | |
1206 wasm::kAstF32, right, | |
1207 left_is_not_nan.Phi( | |
1208 wasm::kAstF32, | |
1209 Binop(wasm::kExprF32Mul, right, Float32Constant(1.0)), | |
1210 Binop(wasm::kExprF32Mul, left, Float32Constant(1.0))))); | |
1211 } | |
1212 | |
1213 Node* WasmGraphBuilder::BuildF32Max(Node* left, Node* right) { | |
1214 Diamond left_ge_right(graph(), jsgraph()->common(), | |
1215 Binop(wasm::kExprF32Ge, left, right)); | |
1216 | |
1217 Diamond right_gt_left(graph(), jsgraph()->common(), | |
1218 Binop(wasm::kExprF32Gt, right, left)); | |
1219 | |
1220 Diamond left_is_not_nan(graph(), jsgraph()->common(), | |
1221 Binop(wasm::kExprF32Eq, left, left)); | |
1222 | |
1223 return left_ge_right.Phi( | |
1224 wasm::kAstF32, left, | |
1225 right_gt_left.Phi( | |
1226 wasm::kAstF32, right, | |
1227 left_is_not_nan.Phi( | |
1228 wasm::kAstF32, | |
1229 Binop(wasm::kExprF32Mul, right, Float32Constant(1.0)), | |
1230 Binop(wasm::kExprF32Mul, left, Float32Constant(1.0))))); | |
1231 } | |
1232 | |
1233 Node* WasmGraphBuilder::BuildI32SConvertF32(Node* input, | 1195 Node* WasmGraphBuilder::BuildI32SConvertF32(Node* input, |
1234 wasm::WasmCodePosition position) { | 1196 wasm::WasmCodePosition position) { |
1235 MachineOperatorBuilder* m = jsgraph()->machine(); | 1197 MachineOperatorBuilder* m = jsgraph()->machine(); |
1236 // Truncation of the input value is needed for the overflow check later. | 1198 // Truncation of the input value is needed for the overflow check later. |
1237 Node* trunc = Unop(wasm::kExprF32Trunc, input); | 1199 Node* trunc = Unop(wasm::kExprF32Trunc, input); |
1238 Node* result = graph()->NewNode(m->TruncateFloat32ToInt32(), trunc); | 1200 Node* result = graph()->NewNode(m->TruncateFloat32ToInt32(), trunc); |
1239 | 1201 |
1240 // Convert the result back to f64. If we end up at a different value than the | 1202 // Convert the result back to f64. If we end up at a different value than the |
1241 // truncated input value, then there has been an overflow and we trap. | 1203 // truncated input value, then there has been an overflow and we trap. |
1242 Node* check = Unop(wasm::kExprF32SConvertI32, result); | 1204 Node* check = Unop(wasm::kExprF32SConvertI32, result); |
(...skipping 1984 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3227 function_->code_start_offset), | 3189 function_->code_start_offset), |
3228 compile_ms); | 3190 compile_ms); |
3229 } | 3191 } |
3230 | 3192 |
3231 return code; | 3193 return code; |
3232 } | 3194 } |
3233 | 3195 |
3234 } // namespace compiler | 3196 } // namespace compiler |
3235 } // namespace internal | 3197 } // namespace internal |
3236 } // namespace v8 | 3198 } // namespace v8 |
OLD | NEW |