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 "src/isolate-inl.h" | 7 #include "src/isolate-inl.h" |
8 | 8 |
9 #include "src/base/platform/platform.h" | 9 #include "src/base/platform/platform.h" |
10 | 10 |
(...skipping 1017 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1028 Binop(wasm::kExprF32Le, left, right)); | 1028 Binop(wasm::kExprF32Le, left, right)); |
1029 | 1029 |
1030 Diamond right_lt_left(graph(), jsgraph()->common(), | 1030 Diamond right_lt_left(graph(), jsgraph()->common(), |
1031 Binop(wasm::kExprF32Lt, right, left)); | 1031 Binop(wasm::kExprF32Lt, right, left)); |
1032 | 1032 |
1033 Diamond left_is_not_nan(graph(), jsgraph()->common(), | 1033 Diamond left_is_not_nan(graph(), jsgraph()->common(), |
1034 Binop(wasm::kExprF32Eq, left, left)); | 1034 Binop(wasm::kExprF32Eq, left, left)); |
1035 | 1035 |
1036 return left_le_right.Phi( | 1036 return left_le_right.Phi( |
1037 wasm::kAstF32, left, | 1037 wasm::kAstF32, left, |
1038 right_lt_left.Phi(wasm::kAstF32, right, | 1038 right_lt_left.Phi( |
1039 left_is_not_nan.Phi(wasm::kAstF32, right, left))); | 1039 wasm::kAstF32, right, |
| 1040 left_is_not_nan.Phi( |
| 1041 wasm::kAstF32, |
| 1042 Binop(wasm::kExprF32Mul, right, Float32Constant(1.0)), |
| 1043 Binop(wasm::kExprF32Mul, left, Float32Constant(1.0))))); |
1040 } | 1044 } |
1041 | 1045 |
1042 | 1046 |
1043 Node* WasmGraphBuilder::BuildF32Max(Node* left, Node* right) { | 1047 Node* WasmGraphBuilder::BuildF32Max(Node* left, Node* right) { |
1044 Diamond left_ge_right(graph(), jsgraph()->common(), | 1048 Diamond left_ge_right(graph(), jsgraph()->common(), |
1045 Binop(wasm::kExprF32Ge, left, right)); | 1049 Binop(wasm::kExprF32Ge, left, right)); |
1046 | 1050 |
1047 Diamond right_gt_left(graph(), jsgraph()->common(), | 1051 Diamond right_gt_left(graph(), jsgraph()->common(), |
1048 Binop(wasm::kExprF32Gt, right, left)); | 1052 Binop(wasm::kExprF32Gt, right, left)); |
1049 | 1053 |
1050 Diamond left_is_not_nan(graph(), jsgraph()->common(), | 1054 Diamond left_is_not_nan(graph(), jsgraph()->common(), |
1051 Binop(wasm::kExprF32Eq, left, left)); | 1055 Binop(wasm::kExprF32Eq, left, left)); |
1052 | 1056 |
1053 return left_ge_right.Phi( | 1057 return left_ge_right.Phi( |
1054 wasm::kAstF32, left, | 1058 wasm::kAstF32, left, |
1055 right_gt_left.Phi(wasm::kAstF32, right, | 1059 right_gt_left.Phi( |
1056 left_is_not_nan.Phi(wasm::kAstF32, right, left))); | 1060 wasm::kAstF32, right, |
| 1061 left_is_not_nan.Phi( |
| 1062 wasm::kAstF32, |
| 1063 Binop(wasm::kExprF32Mul, right, Float32Constant(1.0)), |
| 1064 Binop(wasm::kExprF32Mul, left, Float32Constant(1.0))))); |
1057 } | 1065 } |
1058 | 1066 |
1059 | 1067 |
1060 Node* WasmGraphBuilder::BuildF64Min(Node* left, Node* right) { | 1068 Node* WasmGraphBuilder::BuildF64Min(Node* left, Node* right) { |
1061 Diamond left_le_right(graph(), jsgraph()->common(), | 1069 Diamond left_le_right(graph(), jsgraph()->common(), |
1062 Binop(wasm::kExprF64Le, left, right)); | 1070 Binop(wasm::kExprF64Le, left, right)); |
1063 | 1071 |
1064 Diamond right_lt_left(graph(), jsgraph()->common(), | 1072 Diamond right_lt_left(graph(), jsgraph()->common(), |
1065 Binop(wasm::kExprF64Lt, right, left)); | 1073 Binop(wasm::kExprF64Lt, right, left)); |
1066 | 1074 |
1067 Diamond left_is_not_nan(graph(), jsgraph()->common(), | 1075 Diamond left_is_not_nan(graph(), jsgraph()->common(), |
1068 Binop(wasm::kExprF64Eq, left, left)); | 1076 Binop(wasm::kExprF64Eq, left, left)); |
1069 | 1077 |
1070 return left_le_right.Phi( | 1078 return left_le_right.Phi( |
1071 wasm::kAstF64, left, | 1079 wasm::kAstF64, left, |
1072 right_lt_left.Phi(wasm::kAstF64, right, | 1080 right_lt_left.Phi( |
1073 left_is_not_nan.Phi(wasm::kAstF64, right, left))); | 1081 wasm::kAstF64, right, |
| 1082 left_is_not_nan.Phi( |
| 1083 wasm::kAstF64, |
| 1084 Binop(wasm::kExprF64Mul, right, Float64Constant(1.0)), |
| 1085 Binop(wasm::kExprF64Mul, left, Float64Constant(1.0))))); |
1074 } | 1086 } |
1075 | 1087 |
1076 | 1088 |
1077 Node* WasmGraphBuilder::BuildF64Max(Node* left, Node* right) { | 1089 Node* WasmGraphBuilder::BuildF64Max(Node* left, Node* right) { |
1078 Diamond left_ge_right(graph(), jsgraph()->common(), | 1090 Diamond left_ge_right(graph(), jsgraph()->common(), |
1079 Binop(wasm::kExprF64Ge, left, right)); | 1091 Binop(wasm::kExprF64Ge, left, right)); |
1080 | 1092 |
1081 Diamond right_gt_left(graph(), jsgraph()->common(), | 1093 Diamond right_gt_left(graph(), jsgraph()->common(), |
1082 Binop(wasm::kExprF64Lt, right, left)); | 1094 Binop(wasm::kExprF64Lt, right, left)); |
1083 | 1095 |
1084 Diamond left_is_not_nan(graph(), jsgraph()->common(), | 1096 Diamond left_is_not_nan(graph(), jsgraph()->common(), |
1085 Binop(wasm::kExprF64Eq, left, left)); | 1097 Binop(wasm::kExprF64Eq, left, left)); |
1086 | 1098 |
1087 return left_ge_right.Phi( | 1099 return left_ge_right.Phi( |
1088 wasm::kAstF64, left, | 1100 wasm::kAstF64, left, |
1089 right_gt_left.Phi(wasm::kAstF64, right, | 1101 right_gt_left.Phi( |
1090 left_is_not_nan.Phi(wasm::kAstF64, right, left))); | 1102 wasm::kAstF64, right, |
| 1103 left_is_not_nan.Phi( |
| 1104 wasm::kAstF64, |
| 1105 Binop(wasm::kExprF64Mul, right, Float64Constant(1.0)), |
| 1106 Binop(wasm::kExprF64Mul, left, Float64Constant(1.0))))); |
1091 } | 1107 } |
1092 | 1108 |
1093 | 1109 |
1094 Node* WasmGraphBuilder::BuildI32SConvertF32(Node* input) { | 1110 Node* WasmGraphBuilder::BuildI32SConvertF32(Node* input) { |
1095 MachineOperatorBuilder* m = jsgraph()->machine(); | 1111 MachineOperatorBuilder* m = jsgraph()->machine(); |
1096 // Truncation of the input value is needed for the overflow check later. | 1112 // Truncation of the input value is needed for the overflow check later. |
1097 Node* trunc = Unop(wasm::kExprF32Trunc, input); | 1113 Node* trunc = Unop(wasm::kExprF32Trunc, input); |
1098 Node* result = graph()->NewNode(m->TruncateFloat32ToInt32(), trunc); | 1114 Node* result = graph()->NewNode(m->TruncateFloat32ToInt32(), trunc); |
1099 | 1115 |
1100 // Convert the result back to f64. If we end up at a different value than the | 1116 // Convert the result back to f64. If we end up at a different value than the |
(...skipping 1036 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2137 module_env->module->GetName(function.name_offset)); | 2153 module_env->module->GetName(function.name_offset)); |
2138 } | 2154 } |
2139 | 2155 |
2140 return code; | 2156 return code; |
2141 } | 2157 } |
2142 | 2158 |
2143 | 2159 |
2144 } // namespace compiler | 2160 } // namespace compiler |
2145 } // namespace internal | 2161 } // namespace internal |
2146 } // namespace v8 | 2162 } // namespace v8 |
OLD | NEW |