| 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-operator-reducer.h" | 5 #include "src/compiler/simplified-operator-reducer.h" |
| 6 | 6 |
| 7 #include "src/compiler/js-graph.h" | 7 #include "src/compiler/js-graph.h" |
| 8 #include "src/compiler/machine-operator.h" | 8 #include "src/compiler/machine-operator.h" |
| 9 #include "src/compiler/node-matchers.h" | 9 #include "src/compiler/node-matchers.h" |
| 10 #include "src/compiler/operator-properties.h" | 10 #include "src/compiler/operator-properties.h" |
| 11 | 11 |
| 12 namespace v8 { | 12 namespace v8 { |
| 13 namespace internal { | 13 namespace internal { |
| 14 namespace compiler { | 14 namespace compiler { |
| 15 | 15 |
| 16 SimplifiedOperatorReducer::SimplifiedOperatorReducer(JSGraph* jsgraph) | 16 SimplifiedOperatorReducer::SimplifiedOperatorReducer(JSGraph* jsgraph) |
| 17 : jsgraph_(jsgraph), simplified_(jsgraph->zone()) {} | 17 : jsgraph_(jsgraph), simplified_(jsgraph->zone()) {} |
| 18 | 18 |
| 19 | 19 |
| 20 SimplifiedOperatorReducer::~SimplifiedOperatorReducer() {} | 20 SimplifiedOperatorReducer::~SimplifiedOperatorReducer() {} |
| 21 | 21 |
| 22 | 22 |
| 23 Reduction SimplifiedOperatorReducer::Reduce(Node* node) { | 23 Reduction SimplifiedOperatorReducer::Reduce(Node* node) { |
| 24 switch (node->opcode()) { | 24 switch (node->opcode()) { |
| 25 case IrOpcode::kBooleanNot: { | 25 case IrOpcode::kBooleanNot: { |
| 26 HeapObjectMatcher m(node->InputAt(0)); | 26 HeapObjectMatcher m(node->InputAt(0)); |
| 27 if (m.HasValue()) { | 27 if (m.HasValue()) { |
| 28 return Replace( | 28 return Replace(jsgraph()->BooleanConstant(!m.Value()->BooleanValue())); |
| 29 jsgraph()->BooleanConstant(!m.Value().handle()->BooleanValue())); | |
| 30 } | 29 } |
| 31 if (m.IsBooleanNot()) return Replace(m.InputAt(0)); | 30 if (m.IsBooleanNot()) return Replace(m.InputAt(0)); |
| 32 break; | 31 break; |
| 33 } | 32 } |
| 34 case IrOpcode::kChangeBitToBool: { | 33 case IrOpcode::kChangeBitToBool: { |
| 35 Int32Matcher m(node->InputAt(0)); | 34 Int32Matcher m(node->InputAt(0)); |
| 36 if (m.Is(0)) return Replace(jsgraph()->FalseConstant()); | 35 if (m.Is(0)) return Replace(jsgraph()->FalseConstant()); |
| 37 if (m.Is(1)) return Replace(jsgraph()->TrueConstant()); | 36 if (m.Is(1)) return Replace(jsgraph()->TrueConstant()); |
| 38 if (m.IsChangeBoolToBit()) return Replace(m.InputAt(0)); | 37 if (m.IsChangeBoolToBit()) return Replace(m.InputAt(0)); |
| 39 break; | 38 break; |
| 40 } | 39 } |
| 41 case IrOpcode::kChangeBoolToBit: { | 40 case IrOpcode::kChangeBoolToBit: { |
| 42 HeapObjectMatcher m(node->InputAt(0)); | 41 HeapObjectMatcher m(node->InputAt(0)); |
| 43 if (m.HasValue()) return ReplaceInt32(m.Value().handle()->BooleanValue()); | 42 if (m.HasValue()) return ReplaceInt32(m.Value()->BooleanValue()); |
| 44 if (m.IsChangeBitToBool()) return Replace(m.InputAt(0)); | 43 if (m.IsChangeBitToBool()) return Replace(m.InputAt(0)); |
| 45 break; | 44 break; |
| 46 } | 45 } |
| 47 case IrOpcode::kChangeFloat64ToTagged: { | 46 case IrOpcode::kChangeFloat64ToTagged: { |
| 48 Float64Matcher m(node->InputAt(0)); | 47 Float64Matcher m(node->InputAt(0)); |
| 49 if (m.HasValue()) return ReplaceNumber(m.Value()); | 48 if (m.HasValue()) return ReplaceNumber(m.Value()); |
| 50 break; | 49 break; |
| 51 } | 50 } |
| 52 case IrOpcode::kChangeInt32ToTagged: { | 51 case IrOpcode::kChangeInt32ToTagged: { |
| 53 Int32Matcher m(node->InputAt(0)); | 52 Int32Matcher m(node->InputAt(0)); |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 Graph* SimplifiedOperatorReducer::graph() const { return jsgraph()->graph(); } | 128 Graph* SimplifiedOperatorReducer::graph() const { return jsgraph()->graph(); } |
| 130 | 129 |
| 131 | 130 |
| 132 MachineOperatorBuilder* SimplifiedOperatorReducer::machine() const { | 131 MachineOperatorBuilder* SimplifiedOperatorReducer::machine() const { |
| 133 return jsgraph()->machine(); | 132 return jsgraph()->machine(); |
| 134 } | 133 } |
| 135 | 134 |
| 136 } // namespace compiler | 135 } // namespace compiler |
| 137 } // namespace internal | 136 } // namespace internal |
| 138 } // namespace v8 | 137 } // namespace v8 |
| OLD | NEW |