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" |
(...skipping 25 matching lines...) Expand all Loading... |
36 JSGraph* jsgraph) | 36 JSGraph* jsgraph) |
37 : AdvancedReducer(editor), jsgraph_(jsgraph) {} | 37 : AdvancedReducer(editor), jsgraph_(jsgraph) {} |
38 | 38 |
39 SimplifiedOperatorReducer::~SimplifiedOperatorReducer() {} | 39 SimplifiedOperatorReducer::~SimplifiedOperatorReducer() {} |
40 | 40 |
41 | 41 |
42 Reduction SimplifiedOperatorReducer::Reduce(Node* node) { | 42 Reduction SimplifiedOperatorReducer::Reduce(Node* node) { |
43 switch (node->opcode()) { | 43 switch (node->opcode()) { |
44 case IrOpcode::kBooleanNot: { | 44 case IrOpcode::kBooleanNot: { |
45 HeapObjectMatcher m(node->InputAt(0)); | 45 HeapObjectMatcher m(node->InputAt(0)); |
46 if (m.HasValue()) { | 46 if (m.Is(factory()->true_value())) return ReplaceBoolean(false); |
47 return Replace(jsgraph()->BooleanConstant(!m.Value()->BooleanValue())); | 47 if (m.Is(factory()->false_value())) return ReplaceBoolean(true); |
48 } | |
49 if (m.IsBooleanNot()) return Replace(m.InputAt(0)); | 48 if (m.IsBooleanNot()) return Replace(m.InputAt(0)); |
50 break; | 49 break; |
51 } | 50 } |
52 case IrOpcode::kChangeBitToTagged: { | 51 case IrOpcode::kChangeBitToTagged: { |
53 Int32Matcher m(node->InputAt(0)); | 52 Int32Matcher m(node->InputAt(0)); |
54 if (m.Is(0)) return Replace(jsgraph()->FalseConstant()); | 53 if (m.Is(0)) return Replace(jsgraph()->FalseConstant()); |
55 if (m.Is(1)) return Replace(jsgraph()->TrueConstant()); | 54 if (m.Is(1)) return Replace(jsgraph()->TrueConstant()); |
56 if (m.IsChangeTaggedToBit()) return Replace(m.InputAt(0)); | 55 if (m.IsChangeTaggedToBit()) return Replace(m.InputAt(0)); |
57 break; | 56 break; |
58 } | 57 } |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 if (m.HasValue()) return ReplaceInt32(DoubleToInt32(m.Value())); | 119 if (m.HasValue()) return ReplaceInt32(DoubleToInt32(m.Value())); |
121 if (m.IsChangeInt31ToTaggedSigned() || m.IsChangeInt32ToTagged() || | 120 if (m.IsChangeInt31ToTaggedSigned() || m.IsChangeInt32ToTagged() || |
122 m.IsChangeUint32ToTagged()) { | 121 m.IsChangeUint32ToTagged()) { |
123 return Replace(m.InputAt(0)); | 122 return Replace(m.InputAt(0)); |
124 } | 123 } |
125 if (m.IsChangeFloat64ToTagged()) { | 124 if (m.IsChangeFloat64ToTagged()) { |
126 return Change(node, machine()->TruncateFloat64ToWord32(), m.InputAt(0)); | 125 return Change(node, machine()->TruncateFloat64ToWord32(), m.InputAt(0)); |
127 } | 126 } |
128 break; | 127 break; |
129 } | 128 } |
| 129 case IrOpcode::kCheckIf: { |
| 130 HeapObjectMatcher m(node->InputAt(0)); |
| 131 if (m.Is(factory()->true_value())) { |
| 132 Node* const effect = NodeProperties::GetEffectInput(node); |
| 133 return Replace(effect); |
| 134 } |
| 135 break; |
| 136 } |
130 case IrOpcode::kCheckTaggedPointer: { | 137 case IrOpcode::kCheckTaggedPointer: { |
131 Node* const input = node->InputAt(0); | 138 Node* const input = node->InputAt(0); |
132 if (DecideObjectIsSmi(input) == Decision::kFalse) { | 139 if (DecideObjectIsSmi(input) == Decision::kFalse) { |
133 ReplaceWithValue(node, input); | 140 ReplaceWithValue(node, input); |
134 return Replace(input); | 141 return Replace(input); |
135 } | 142 } |
136 break; | 143 break; |
137 } | 144 } |
138 case IrOpcode::kCheckTaggedSigned: { | 145 case IrOpcode::kCheckTaggedSigned: { |
139 Node* const input = node->InputAt(0); | 146 Node* const input = node->InputAt(0); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 | 203 |
197 Reduction SimplifiedOperatorReducer::ReplaceNumber(double value) { | 204 Reduction SimplifiedOperatorReducer::ReplaceNumber(double value) { |
198 return Replace(jsgraph()->Constant(value)); | 205 return Replace(jsgraph()->Constant(value)); |
199 } | 206 } |
200 | 207 |
201 | 208 |
202 Reduction SimplifiedOperatorReducer::ReplaceNumber(int32_t value) { | 209 Reduction SimplifiedOperatorReducer::ReplaceNumber(int32_t value) { |
203 return Replace(jsgraph()->Constant(value)); | 210 return Replace(jsgraph()->Constant(value)); |
204 } | 211 } |
205 | 212 |
| 213 Factory* SimplifiedOperatorReducer::factory() const { |
| 214 return isolate()->factory(); |
| 215 } |
206 | 216 |
207 Graph* SimplifiedOperatorReducer::graph() const { return jsgraph()->graph(); } | 217 Graph* SimplifiedOperatorReducer::graph() const { return jsgraph()->graph(); } |
208 | 218 |
| 219 Isolate* SimplifiedOperatorReducer::isolate() const { |
| 220 return jsgraph()->isolate(); |
| 221 } |
209 | 222 |
210 MachineOperatorBuilder* SimplifiedOperatorReducer::machine() const { | 223 MachineOperatorBuilder* SimplifiedOperatorReducer::machine() const { |
211 return jsgraph()->machine(); | 224 return jsgraph()->machine(); |
212 } | 225 } |
213 | 226 |
214 } // namespace compiler | 227 } // namespace compiler |
215 } // namespace internal | 228 } // namespace internal |
216 } // namespace v8 | 229 } // namespace v8 |
OLD | NEW |