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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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: | 95 case IrOpcode::kReferenceEqual: |
96 return ReduceReferenceEqual(node); | 96 return ReduceReferenceEqual(node); |
97 case IrOpcode::kSelect: | 97 case IrOpcode::kSelect: |
98 return ReduceSelect(node); | 98 return ReduceSelect(node); |
| 99 case IrOpcode::kSpeculativeToNumber: |
| 100 return ReduceSpeculativeToNumber(node); |
99 default: | 101 default: |
100 break; | 102 break; |
101 } | 103 } |
102 return NoChange(); | 104 return NoChange(); |
103 } | 105 } |
104 | 106 |
105 namespace { | 107 namespace { |
106 | 108 |
107 MaybeHandle<Map> GetStableMapFromObjectType(Type* object_type) { | 109 MaybeHandle<Map> GetStableMapFromObjectType(Type* object_type) { |
108 if (object_type->IsHeapConstant()) { | 110 if (object_type->IsHeapConstant()) { |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
304 Type* type = Type::Union(vtrue_type, vfalse_type, graph()->zone()); | 306 Type* type = Type::Union(vtrue_type, vfalse_type, graph()->zone()); |
305 Type* const node_type = NodeProperties::GetType(node); | 307 Type* const node_type = NodeProperties::GetType(node); |
306 if (!node_type->Is(type)) { | 308 if (!node_type->Is(type)) { |
307 type = Type::Intersect(node_type, type, graph()->zone()); | 309 type = Type::Intersect(node_type, type, graph()->zone()); |
308 NodeProperties::SetType(node, type); | 310 NodeProperties::SetType(node, type); |
309 return Changed(node); | 311 return Changed(node); |
310 } | 312 } |
311 return NoChange(); | 313 return NoChange(); |
312 } | 314 } |
313 | 315 |
| 316 Reduction TypedOptimization::ReduceSpeculativeToNumber(Node* node) { |
| 317 DCHECK_EQ(IrOpcode::kSpeculativeToNumber, node->opcode()); |
| 318 Node* const input = NodeProperties::GetValueInput(node, 0); |
| 319 Type* const input_type = NodeProperties::GetType(input); |
| 320 if (input_type->Is(Type::Number())) { |
| 321 // SpeculativeToNumber(x:number) => x |
| 322 ReplaceWithValue(node, input); |
| 323 return Replace(input); |
| 324 } |
| 325 return NoChange(); |
| 326 } |
| 327 |
314 Factory* TypedOptimization::factory() const { return isolate()->factory(); } | 328 Factory* TypedOptimization::factory() const { return isolate()->factory(); } |
315 | 329 |
316 Graph* TypedOptimization::graph() const { return jsgraph()->graph(); } | 330 Graph* TypedOptimization::graph() const { return jsgraph()->graph(); } |
317 | 331 |
318 Isolate* TypedOptimization::isolate() const { return jsgraph()->isolate(); } | 332 Isolate* TypedOptimization::isolate() const { return jsgraph()->isolate(); } |
319 | 333 |
320 SimplifiedOperatorBuilder* TypedOptimization::simplified() const { | 334 SimplifiedOperatorBuilder* TypedOptimization::simplified() const { |
321 return jsgraph()->simplified(); | 335 return jsgraph()->simplified(); |
322 } | 336 } |
323 | 337 |
324 } // namespace compiler | 338 } // namespace compiler |
325 } // namespace internal | 339 } // namespace internal |
326 } // namespace v8 | 340 } // namespace v8 |
OLD | NEW |