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/common-operator.h" | 5 #include "src/compiler/common-operator.h" |
6 #include "src/compiler/control-reducer.h" | 6 #include "src/compiler/control-reducer.h" |
7 #include "src/compiler/graph.h" | 7 #include "src/compiler/graph.h" |
8 #include "src/compiler/graph-reducer.h" | 8 #include "src/compiler/graph-reducer.h" |
9 #include "src/compiler/js-graph.h" | 9 #include "src/compiler/js-graph.h" |
10 #include "src/compiler/node-marker.h" | 10 #include "src/compiler/node-marker.h" |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 return result == node ? NoChange() : Replace(result); | 86 return result == node ? NoChange() : Replace(result); |
87 } | 87 } |
88 | 88 |
89 // Try to statically fold a condition. | 89 // Try to statically fold a condition. |
90 Decision DecideCondition(Node* cond, bool recurse = true) { | 90 Decision DecideCondition(Node* cond, bool recurse = true) { |
91 switch (cond->opcode()) { | 91 switch (cond->opcode()) { |
92 case IrOpcode::kInt32Constant: | 92 case IrOpcode::kInt32Constant: |
93 return Int32Matcher(cond).Is(0) ? kFalse : kTrue; | 93 return Int32Matcher(cond).Is(0) ? kFalse : kTrue; |
94 case IrOpcode::kInt64Constant: | 94 case IrOpcode::kInt64Constant: |
95 return Int64Matcher(cond).Is(0) ? kFalse : kTrue; | 95 return Int64Matcher(cond).Is(0) ? kFalse : kTrue; |
96 case IrOpcode::kNumberConstant: | |
97 return NumberMatcher(cond).Is(0) ? kFalse : kTrue; | |
98 case IrOpcode::kHeapConstant: { | 96 case IrOpcode::kHeapConstant: { |
99 Handle<Object> object = | 97 Handle<Object> object = |
100 HeapObjectMatcher<Object>(cond).Value().handle(); | 98 HeapObjectMatcher<Object>(cond).Value().handle(); |
101 return object->BooleanValue() ? kTrue : kFalse; | 99 return object->BooleanValue() ? kTrue : kFalse; |
102 } | 100 } |
103 case IrOpcode::kPhi: { | 101 case IrOpcode::kPhi: { |
104 if (!recurse) return kUnknown; // Only go one level deep checking phis. | 102 if (!recurse) return kUnknown; // Only go one level deep checking phis. |
105 Decision result = kUnknown; | 103 Decision result = kUnknown; |
106 // Check if all inputs to a phi result in the same decision. | 104 // Check if all inputs to a phi result in the same decision. |
107 for (int i = cond->op()->ValueInputCount() - 1; i >= 0; i--) { | 105 for (int i = cond->op()->ValueInputCount() - 1; i >= 0; i--) { |
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
375 case IrOpcode::kIfFalse: | 373 case IrOpcode::kIfFalse: |
376 return impl.ReduceIfProjection(node, kFalse); | 374 return impl.ReduceIfProjection(node, kFalse); |
377 default: | 375 default: |
378 return node; | 376 return node; |
379 } | 377 } |
380 } | 378 } |
381 | 379 |
382 } // namespace compiler | 380 } // namespace compiler |
383 } // namespace internal | 381 } // namespace internal |
384 } // namespace v8 | 382 } // namespace v8 |
OLD | NEW |