OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 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/typed-optimization.h" | 5 #include "src/compiler/typed-optimization.h" |
6 | 6 |
7 #include "src/compilation-dependencies.h" | 7 #include "src/compilation-dependencies.h" |
8 #include "src/compiler/js-graph.h" | 8 #include "src/compiler/js-graph.h" |
9 #include "src/compiler/node-properties.h" | 9 #include "src/compiler/node-properties.h" |
10 #include "src/compiler/simplified-operator.h" | 10 #include "src/compiler/simplified-operator.h" |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 case IrOpcode::kNumberCeil: | 85 case IrOpcode::kNumberCeil: |
86 case IrOpcode::kNumberRound: | 86 case IrOpcode::kNumberRound: |
87 case IrOpcode::kNumberTrunc: | 87 case IrOpcode::kNumberTrunc: |
88 return ReduceNumberRoundop(node); | 88 return ReduceNumberRoundop(node); |
89 case IrOpcode::kNumberFloor: | 89 case IrOpcode::kNumberFloor: |
90 return ReduceNumberFloor(node); | 90 return ReduceNumberFloor(node); |
91 case IrOpcode::kNumberToUint8Clamped: | 91 case IrOpcode::kNumberToUint8Clamped: |
92 return ReduceNumberToUint8Clamped(node); | 92 return ReduceNumberToUint8Clamped(node); |
93 case IrOpcode::kPhi: | 93 case IrOpcode::kPhi: |
94 return ReducePhi(node); | 94 return ReducePhi(node); |
| 95 case IrOpcode::kReferenceEqual: |
| 96 return ReduceReferenceEqual(node); |
95 case IrOpcode::kSelect: | 97 case IrOpcode::kSelect: |
96 return ReduceSelect(node); | 98 return ReduceSelect(node); |
97 default: | 99 default: |
98 break; | 100 break; |
99 } | 101 } |
100 return NoChange(); | 102 return NoChange(); |
101 } | 103 } |
102 | 104 |
103 namespace { | 105 namespace { |
104 | 106 |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 } | 253 } |
252 Type* const node_type = NodeProperties::GetType(node); | 254 Type* const node_type = NodeProperties::GetType(node); |
253 if (!node_type->Is(type)) { | 255 if (!node_type->Is(type)) { |
254 type = Type::Intersect(node_type, type, graph()->zone()); | 256 type = Type::Intersect(node_type, type, graph()->zone()); |
255 NodeProperties::SetType(node, type); | 257 NodeProperties::SetType(node, type); |
256 return Changed(node); | 258 return Changed(node); |
257 } | 259 } |
258 return NoChange(); | 260 return NoChange(); |
259 } | 261 } |
260 | 262 |
| 263 Reduction TypedOptimization::ReduceReferenceEqual(Node* node) { |
| 264 DCHECK_EQ(IrOpcode::kReferenceEqual, node->opcode()); |
| 265 Node* const lhs = NodeProperties::GetValueInput(node, 0); |
| 266 Node* const rhs = NodeProperties::GetValueInput(node, 1); |
| 267 Type* const lhs_type = NodeProperties::GetType(lhs); |
| 268 Type* const rhs_type = NodeProperties::GetType(rhs); |
| 269 if (!lhs_type->Maybe(rhs_type)) { |
| 270 return Replace(jsgraph()->FalseConstant()); |
| 271 } |
| 272 return NoChange(); |
| 273 } |
| 274 |
261 Reduction TypedOptimization::ReduceSelect(Node* node) { | 275 Reduction TypedOptimization::ReduceSelect(Node* node) { |
262 DCHECK_EQ(IrOpcode::kSelect, node->opcode()); | 276 DCHECK_EQ(IrOpcode::kSelect, node->opcode()); |
263 Node* const condition = NodeProperties::GetValueInput(node, 0); | 277 Node* const condition = NodeProperties::GetValueInput(node, 0); |
264 Type* const condition_type = NodeProperties::GetType(condition); | 278 Type* const condition_type = NodeProperties::GetType(condition); |
265 Node* const vtrue = NodeProperties::GetValueInput(node, 1); | 279 Node* const vtrue = NodeProperties::GetValueInput(node, 1); |
266 Type* const vtrue_type = NodeProperties::GetType(vtrue); | 280 Type* const vtrue_type = NodeProperties::GetType(vtrue); |
267 Node* const vfalse = NodeProperties::GetValueInput(node, 2); | 281 Node* const vfalse = NodeProperties::GetValueInput(node, 2); |
268 Type* const vfalse_type = NodeProperties::GetType(vfalse); | 282 Type* const vfalse_type = NodeProperties::GetType(vfalse); |
269 if (condition_type->Is(true_type_)) { | 283 if (condition_type->Is(true_type_)) { |
270 // Select(condition:true, vtrue, vfalse) => vtrue | 284 // Select(condition:true, vtrue, vfalse) => vtrue |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 | 316 |
303 Isolate* TypedOptimization::isolate() const { return jsgraph()->isolate(); } | 317 Isolate* TypedOptimization::isolate() const { return jsgraph()->isolate(); } |
304 | 318 |
305 SimplifiedOperatorBuilder* TypedOptimization::simplified() const { | 319 SimplifiedOperatorBuilder* TypedOptimization::simplified() const { |
306 return jsgraph()->simplified(); | 320 return jsgraph()->simplified(); |
307 } | 321 } |
308 | 322 |
309 } // namespace compiler | 323 } // namespace compiler |
310 } // namespace internal | 324 } // namespace internal |
311 } // namespace v8 | 325 } // namespace v8 |
OLD | NEW |