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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 return ReduceCheckMaps(node); | 80 return ReduceCheckMaps(node); |
81 case IrOpcode::kCheckString: | 81 case IrOpcode::kCheckString: |
82 return ReduceCheckString(node); | 82 return ReduceCheckString(node); |
83 case IrOpcode::kLoadField: | 83 case IrOpcode::kLoadField: |
84 return ReduceLoadField(node); | 84 return ReduceLoadField(node); |
85 case IrOpcode::kNumberCeil: | 85 case IrOpcode::kNumberCeil: |
86 case IrOpcode::kNumberFloor: | 86 case IrOpcode::kNumberFloor: |
87 case IrOpcode::kNumberRound: | 87 case IrOpcode::kNumberRound: |
88 case IrOpcode::kNumberTrunc: | 88 case IrOpcode::kNumberTrunc: |
89 return ReduceNumberRoundop(node); | 89 return ReduceNumberRoundop(node); |
| 90 case IrOpcode::kNumberToUint8Clamped: |
| 91 return ReduceNumberToUint8Clamped(node); |
90 case IrOpcode::kPhi: | 92 case IrOpcode::kPhi: |
91 return ReducePhi(node); | 93 return ReducePhi(node); |
92 case IrOpcode::kSelect: | 94 case IrOpcode::kSelect: |
93 return ReduceSelect(node); | 95 return ReduceSelect(node); |
94 default: | 96 default: |
95 break; | 97 break; |
96 } | 98 } |
97 return NoChange(); | 99 return NoChange(); |
98 } | 100 } |
99 | 101 |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 | 187 |
186 Reduction TypedOptimization::ReduceNumberRoundop(Node* node) { | 188 Reduction TypedOptimization::ReduceNumberRoundop(Node* node) { |
187 Node* const input = NodeProperties::GetValueInput(node, 0); | 189 Node* const input = NodeProperties::GetValueInput(node, 0); |
188 Type* const input_type = NodeProperties::GetType(input); | 190 Type* const input_type = NodeProperties::GetType(input); |
189 if (input_type->Is(type_cache_.kIntegerOrMinusZeroOrNaN)) { | 191 if (input_type->Is(type_cache_.kIntegerOrMinusZeroOrNaN)) { |
190 return Replace(input); | 192 return Replace(input); |
191 } | 193 } |
192 return NoChange(); | 194 return NoChange(); |
193 } | 195 } |
194 | 196 |
| 197 Reduction TypedOptimization::ReduceNumberToUint8Clamped(Node* node) { |
| 198 Node* const input = NodeProperties::GetValueInput(node, 0); |
| 199 Type* const input_type = NodeProperties::GetType(input); |
| 200 if (input_type->Is(type_cache_.kUint8)) { |
| 201 return Replace(input); |
| 202 } |
| 203 return NoChange(); |
| 204 } |
| 205 |
195 Reduction TypedOptimization::ReducePhi(Node* node) { | 206 Reduction TypedOptimization::ReducePhi(Node* node) { |
196 // Try to narrow the type of the Phi {node}, which might be more precise now | 207 // Try to narrow the type of the Phi {node}, which might be more precise now |
197 // after lowering based on types, i.e. a SpeculativeNumberAdd has a more | 208 // after lowering based on types, i.e. a SpeculativeNumberAdd has a more |
198 // precise type than the JSAdd that was in the graph when the Typer was run. | 209 // precise type than the JSAdd that was in the graph when the Typer was run. |
199 DCHECK_EQ(IrOpcode::kPhi, node->opcode()); | 210 DCHECK_EQ(IrOpcode::kPhi, node->opcode()); |
200 int arity = node->op()->ValueInputCount(); | 211 int arity = node->op()->ValueInputCount(); |
201 Type* type = NodeProperties::GetType(node->InputAt(0)); | 212 Type* type = NodeProperties::GetType(node->InputAt(0)); |
202 for (int i = 1; i < arity; ++i) { | 213 for (int i = 1; i < arity; ++i) { |
203 type = Type::Union(type, NodeProperties::GetType(node->InputAt(i)), | 214 type = Type::Union(type, NodeProperties::GetType(node->InputAt(i)), |
204 graph()->zone()); | 215 graph()->zone()); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
256 | 267 |
257 Isolate* TypedOptimization::isolate() const { return jsgraph()->isolate(); } | 268 Isolate* TypedOptimization::isolate() const { return jsgraph()->isolate(); } |
258 | 269 |
259 SimplifiedOperatorBuilder* TypedOptimization::simplified() const { | 270 SimplifiedOperatorBuilder* TypedOptimization::simplified() const { |
260 return jsgraph()->simplified(); | 271 return jsgraph()->simplified(); |
261 } | 272 } |
262 | 273 |
263 } // namespace compiler | 274 } // namespace compiler |
264 } // namespace internal | 275 } // namespace internal |
265 } // namespace v8 | 276 } // namespace v8 |
OLD | NEW |