| 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/generic-node-inl.h" | 5 #include "src/compiler/generic-node-inl.h" |
| 6 #include "src/compiler/js-graph.h" | 6 #include "src/compiler/js-graph.h" |
| 7 #include "src/compiler/machine-operator.h" | 7 #include "src/compiler/machine-operator.h" |
| 8 #include "src/compiler/node-matchers.h" | 8 #include "src/compiler/node-matchers.h" |
| 9 #include "src/compiler/simplified-operator-reducer.h" | 9 #include "src/compiler/simplified-operator-reducer.h" |
| 10 | 10 |
| 11 namespace v8 { | 11 namespace v8 { |
| 12 namespace internal { | 12 namespace internal { |
| 13 namespace compiler { | 13 namespace compiler { |
| 14 | 14 |
| 15 SimplifiedOperatorReducer::~SimplifiedOperatorReducer() {} | 15 SimplifiedOperatorReducer::~SimplifiedOperatorReducer() {} |
| 16 | 16 |
| 17 | 17 |
| 18 Reduction SimplifiedOperatorReducer::Reduce(Node* node) { | 18 Reduction SimplifiedOperatorReducer::Reduce(Node* node) { |
| 19 switch (node->opcode()) { | 19 switch (node->opcode()) { |
| 20 case IrOpcode::kBooleanNot: { | 20 case IrOpcode::kBooleanNot: { |
| 21 HeapObjectMatcher m(node->InputAt(0)); | 21 HeapObjectMatcher m(node->InputAt(0)); |
| 22 if (m.IsKnownGlobal(heap()->false_value())) { | 22 if (m.IsKnownGlobal(factory()->false_value())) { |
| 23 return Replace(jsgraph()->TrueConstant()); | 23 return Replace(jsgraph()->TrueConstant()); |
| 24 } | 24 } |
| 25 if (m.IsKnownGlobal(heap()->true_value())) { | 25 if (m.IsKnownGlobal(factory()->true_value())) { |
| 26 return Replace(jsgraph()->FalseConstant()); | 26 return Replace(jsgraph()->FalseConstant()); |
| 27 } | 27 } |
| 28 if (m.IsBooleanNot()) return Replace(m.node()->InputAt(0)); | 28 if (m.IsBooleanNot()) return Replace(m.node()->InputAt(0)); |
| 29 break; | 29 break; |
| 30 } | 30 } |
| 31 case IrOpcode::kChangeBitToBool: { | 31 case IrOpcode::kChangeBitToBool: { |
| 32 Int32Matcher m(node->InputAt(0)); | 32 Int32Matcher m(node->InputAt(0)); |
| 33 if (m.Is(0)) return Replace(jsgraph()->FalseConstant()); | 33 if (m.Is(0)) return Replace(jsgraph()->FalseConstant()); |
| 34 if (m.Is(1)) return Replace(jsgraph()->TrueConstant()); | 34 if (m.Is(1)) return Replace(jsgraph()->TrueConstant()); |
| 35 if (m.IsChangeBoolToBit()) return Replace(m.node()->InputAt(0)); | 35 if (m.IsChangeBoolToBit()) return Replace(m.node()->InputAt(0)); |
| 36 break; | 36 break; |
| 37 } | 37 } |
| 38 case IrOpcode::kChangeBoolToBit: { | 38 case IrOpcode::kChangeBoolToBit: { |
| 39 HeapObjectMatcher m(node->InputAt(0)); | 39 HeapObjectMatcher m(node->InputAt(0)); |
| 40 if (m.IsKnownGlobal(heap()->false_value())) return ReplaceInt32(0); | 40 if (m.IsKnownGlobal(factory()->false_value())) return ReplaceInt32(0); |
| 41 if (m.IsKnownGlobal(heap()->true_value())) return ReplaceInt32(1); | 41 if (m.IsKnownGlobal(factory()->true_value())) return ReplaceInt32(1); |
| 42 if (m.IsChangeBitToBool()) return Replace(m.node()->InputAt(0)); | 42 if (m.IsChangeBitToBool()) return Replace(m.node()->InputAt(0)); |
| 43 break; | 43 break; |
| 44 } | 44 } |
| 45 case IrOpcode::kChangeFloat64ToTagged: { | 45 case IrOpcode::kChangeFloat64ToTagged: { |
| 46 Float64Matcher m(node->InputAt(0)); | 46 Float64Matcher m(node->InputAt(0)); |
| 47 if (m.HasValue()) return ReplaceNumber(m.Value()); | 47 if (m.HasValue()) return ReplaceNumber(m.Value()); |
| 48 break; | 48 break; |
| 49 } | 49 } |
| 50 case IrOpcode::kChangeInt32ToTagged: { | 50 case IrOpcode::kChangeInt32ToTagged: { |
| 51 Int32Matcher m(node->InputAt(0)); | 51 Int32Matcher m(node->InputAt(0)); |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 | 121 |
| 122 | 122 |
| 123 Reduction SimplifiedOperatorReducer::ReplaceNumber(int32_t value) { | 123 Reduction SimplifiedOperatorReducer::ReplaceNumber(int32_t value) { |
| 124 return Replace(jsgraph()->Constant(value)); | 124 return Replace(jsgraph()->Constant(value)); |
| 125 } | 125 } |
| 126 | 126 |
| 127 | 127 |
| 128 Graph* SimplifiedOperatorReducer::graph() const { return jsgraph()->graph(); } | 128 Graph* SimplifiedOperatorReducer::graph() const { return jsgraph()->graph(); } |
| 129 | 129 |
| 130 | 130 |
| 131 Heap* SimplifiedOperatorReducer::heap() const { | 131 Factory* SimplifiedOperatorReducer::factory() const { |
| 132 return jsgraph()->isolate()->heap(); | 132 return jsgraph()->isolate()->factory(); |
| 133 } | 133 } |
| 134 | 134 |
| 135 } // namespace compiler | 135 } // namespace compiler |
| 136 } // namespace internal | 136 } // namespace internal |
| 137 } // namespace v8 | 137 } // namespace v8 |
| OLD | NEW |