OLD | NEW |
---|---|
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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/simplified-lowering.h" | 5 #include "src/compiler/simplified-lowering.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 | 8 |
9 #include "src/address-map.h" | 9 #include "src/address-map.h" |
10 #include "src/base/bits.h" | 10 #include "src/base/bits.h" |
(...skipping 1020 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1031 } | 1031 } |
1032 } | 1032 } |
1033 } | 1033 } |
1034 | 1034 |
1035 void ChangeToInt32OverflowOp(Node* node, const Operator* op) { | 1035 void ChangeToInt32OverflowOp(Node* node, const Operator* op) { |
1036 Node* effect = NodeProperties::GetEffectInput(node); | 1036 Node* effect = NodeProperties::GetEffectInput(node); |
1037 Node* control = NodeProperties::GetControlInput(node); | 1037 Node* control = NodeProperties::GetControlInput(node); |
1038 Node* frame_state = NodeProperties::FindFrameStateBefore(node); | 1038 Node* frame_state = NodeProperties::FindFrameStateBefore(node); |
1039 Node* arith = graph()->NewNode(op, node->InputAt(0), node->InputAt(1)); | 1039 Node* arith = graph()->NewNode(op, node->InputAt(0), node->InputAt(1)); |
1040 Node* overflow = graph()->NewNode(common()->Projection(1), arith); | 1040 Node* overflow = graph()->NewNode(common()->Projection(1), arith); |
1041 control = effect = graph()->NewNode(common()->DeoptimizeIf(), overflow, | |
1042 frame_state, effect, control); | |
1043 | 1041 |
1042 // Deoptimize on overflow. | |
Benedikt Meurer
2016/06/07 04:11:00
This change doesn't seem related to comparisons?
Jarin
2016/06/09 13:37:32
Done.
| |
1043 Node* branch = graph()->NewNode(common()->Branch(BranchHint::kFalse), | |
1044 overflow, control); | |
1045 Node* if_true = graph()->NewNode(common()->IfTrue(), branch); | |
1046 Node* deoptimize = | |
1047 graph()->NewNode(common()->Deoptimize(DeoptimizeKind::kEager), | |
1048 frame_state, effect, if_true); | |
1049 NodeProperties::MergeControlToEnd(graph(), common(), deoptimize); | |
1050 | |
1051 control = graph()->NewNode(common()->IfFalse(), branch); | |
1044 Node* value = graph()->NewNode(common()->Projection(0), arith); | 1052 Node* value = graph()->NewNode(common()->Projection(0), arith); |
1045 ReplaceEffectControlUses(node, effect, control); | 1053 ReplaceEffectControlUses(node, effect, control); |
1046 DeferReplacement(node, value); | 1054 DeferReplacement(node, value); |
1047 } | 1055 } |
1048 | 1056 |
1049 void VisitSpeculativeAdditiveOp(Node* node, Truncation truncation, | 1057 void VisitSpeculativeAdditiveOp(Node* node, Truncation truncation, |
1050 SimplifiedLowering* lowering) { | 1058 SimplifiedLowering* lowering) { |
1051 if (BothInputsAre(node, Type::Signed32()) && | 1059 if (BothInputsAre(node, Type::Signed32()) && |
1052 NodeProperties::GetType(node)->Is(Type::Signed32())) { | 1060 NodeProperties::GetType(node)->Is(Type::Signed32())) { |
1053 // int32 + int32 = int32 ==> signed Int32Add/Sub | 1061 // int32 + int32 = int32 ==> signed Int32Add/Sub |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1212 // No input representation requirement; adapt during lowering. | 1220 // No input representation requirement; adapt during lowering. |
1213 ProcessInput(node, 0, UseInfo::AnyTruncatingToBool()); | 1221 ProcessInput(node, 0, UseInfo::AnyTruncatingToBool()); |
1214 SetOutput(node, MachineRepresentation::kWord32); | 1222 SetOutput(node, MachineRepresentation::kWord32); |
1215 } | 1223 } |
1216 return; | 1224 return; |
1217 } | 1225 } |
1218 case IrOpcode::kNumberEqual: | 1226 case IrOpcode::kNumberEqual: |
1219 case IrOpcode::kNumberLessThan: | 1227 case IrOpcode::kNumberLessThan: |
1220 case IrOpcode::kNumberLessThanOrEqual: { | 1228 case IrOpcode::kNumberLessThanOrEqual: { |
1221 // Number comparisons reduce to integer comparisons for integer inputs. | 1229 // Number comparisons reduce to integer comparisons for integer inputs. |
1222 if (BothInputsAreSigned32(node)) { | 1230 if (TypeOf(node->InputAt(0))->Is(Type::Signed32()) && |
1231 TypeOf(node->InputAt(1))->Is(Type::Signed32())) { | |
1223 // => signed Int32Cmp | 1232 // => signed Int32Cmp |
1224 VisitInt32Cmp(node); | 1233 VisitInt32Cmp(node); |
1225 if (lower()) NodeProperties::ChangeOp(node, Int32Op(node)); | 1234 if (lower()) NodeProperties::ChangeOp(node, Int32Op(node)); |
1226 } else if (BothInputsAreUnsigned32(node)) { | 1235 } else if (TypeOf(node->InputAt(0))->Is(Type::Unsigned32()) && |
1236 TypeOf(node->InputAt(1))->Is(Type::Unsigned32())) { | |
1227 // => unsigned Int32Cmp | 1237 // => unsigned Int32Cmp |
1228 VisitUint32Cmp(node); | 1238 VisitUint32Cmp(node); |
1229 if (lower()) NodeProperties::ChangeOp(node, Uint32Op(node)); | 1239 if (lower()) NodeProperties::ChangeOp(node, Uint32Op(node)); |
1230 } else { | 1240 } else { |
1231 // => Float64Cmp | 1241 // => Float64Cmp |
1232 VisitFloat64Cmp(node); | 1242 VisitFloat64Cmp(node); |
1233 if (lower()) NodeProperties::ChangeOp(node, Float64Op(node)); | 1243 if (lower()) NodeProperties::ChangeOp(node, Float64Op(node)); |
1234 } | 1244 } |
1235 return; | 1245 return; |
1236 } | 1246 } |
1237 | 1247 |
1238 case IrOpcode::kSpeculativeNumberAdd: | 1248 case IrOpcode::kSpeculativeNumberAdd: |
1239 case IrOpcode::kSpeculativeNumberSubtract: | 1249 case IrOpcode::kSpeculativeNumberSubtract: |
1240 return VisitSpeculativeAdditiveOp(node, truncation, lowering); | 1250 return VisitSpeculativeAdditiveOp(node, truncation, lowering); |
1241 | 1251 |
1252 case IrOpcode::kSpeculativeNumberLessThan: | |
1253 case IrOpcode::kSpeculativeNumberLessThanOrEqual: | |
1254 case IrOpcode::kSpeculativeNumberEqual: { | |
1255 // Number comparisons reduce to integer comparisons for integer inputs. | |
1256 if (TypeOf(node->InputAt(0))->Is(Type::Signed32()) && | |
1257 TypeOf(node->InputAt(1))->Is(Type::Signed32())) { | |
1258 // => signed Int32Cmp | |
1259 VisitInt32Cmp(node); | |
1260 if (lower()) ChangeToPureOp(node, Int32Op(node)); | |
1261 return; | |
1262 } else if (TypeOf(node->InputAt(0))->Is(Type::Unsigned32()) && | |
1263 TypeOf(node->InputAt(1))->Is(Type::Unsigned32())) { | |
1264 // => unsigned Int32Cmp | |
1265 VisitUint32Cmp(node); | |
1266 if (lower()) ChangeToPureOp(node, Uint32Op(node)); | |
1267 return; | |
1268 } | |
1269 // Try to use type feedback. | |
1270 CompareOperationHints::Hint hint = CompareOperationHintOf(node->op()); | |
1271 | |
1272 if (hint == CompareOperationHints::kSignedSmall || | |
1273 hint == CompareOperationHints::kSigned32) { | |
1274 VisitBinop(node, UseInfo::CheckedSigned32AsWord32(), | |
1275 MachineRepresentation::kBit); | |
1276 if (lower()) ChangeToPureOp(node, Int32Op(node)); | |
1277 return; | |
1278 } | |
1279 DCHECK_EQ(CompareOperationHints::kNumberOrUndefined, hint); | |
1280 // default case => Float64 comparison | |
1281 VisitBinop(node, UseInfo::CheckedNumberOrUndefinedAsFloat64(), | |
1282 MachineRepresentation::kBit); | |
1283 if (lower()) ChangeToPureOp(node, Float64Op(node)); | |
1284 return; | |
1285 } | |
1286 | |
1242 case IrOpcode::kNumberAdd: | 1287 case IrOpcode::kNumberAdd: |
1243 case IrOpcode::kNumberSubtract: { | 1288 case IrOpcode::kNumberSubtract: { |
1244 if (BothInputsAre(node, Type::Signed32()) && | 1289 if (BothInputsAre(node, Type::Signed32()) && |
1245 NodeProperties::GetType(node)->Is(Type::Signed32())) { | 1290 NodeProperties::GetType(node)->Is(Type::Signed32())) { |
1246 // int32 + int32 = int32 | 1291 // int32 + int32 = int32 |
1247 // => signed Int32Add/Sub | 1292 // => signed Int32Add/Sub |
1248 VisitInt32Binop(node); | 1293 VisitInt32Binop(node); |
1249 if (lower()) NodeProperties::ChangeOp(node, Int32Op(node)); | 1294 if (lower()) NodeProperties::ChangeOp(node, Int32Op(node)); |
1250 } else if (BothInputsAre(node, type_cache_.kAdditiveSafeInteger) && | 1295 } else if (BothInputsAre(node, type_cache_.kAdditiveSafeInteger) && |
1251 truncation.TruncatesToWord32()) { | 1296 truncation.TruncatesToWord32()) { |
(...skipping 1568 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2820 isolate(), graph()->zone(), callable.descriptor(), 0, flags, | 2865 isolate(), graph()->zone(), callable.descriptor(), 0, flags, |
2821 Operator::kNoProperties); | 2866 Operator::kNoProperties); |
2822 to_number_operator_.set(common()->Call(desc)); | 2867 to_number_operator_.set(common()->Call(desc)); |
2823 } | 2868 } |
2824 return to_number_operator_.get(); | 2869 return to_number_operator_.get(); |
2825 } | 2870 } |
2826 | 2871 |
2827 } // namespace compiler | 2872 } // namespace compiler |
2828 } // namespace internal | 2873 } // namespace internal |
2829 } // namespace v8 | 2874 } // namespace v8 |
OLD | NEW |