| 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 15 matching lines...) Expand all Loading... |
| 26 false_type_(Type::Constant(factory()->false_value(), graph()->zone())), | 26 false_type_(Type::Constant(factory()->false_value(), graph()->zone())), |
| 27 type_cache_(TypeCache::Get()) {} | 27 type_cache_(TypeCache::Get()) {} |
| 28 | 28 |
| 29 TypedOptimization::~TypedOptimization() {} | 29 TypedOptimization::~TypedOptimization() {} |
| 30 | 30 |
| 31 Reduction TypedOptimization::Reduce(Node* node) { | 31 Reduction TypedOptimization::Reduce(Node* node) { |
| 32 // Check if the output type is a singleton. In that case we already know the | 32 // Check if the output type is a singleton. In that case we already know the |
| 33 // result value and can simply replace the node if it's eliminable. | 33 // result value and can simply replace the node if it's eliminable. |
| 34 if (!NodeProperties::IsConstant(node) && NodeProperties::IsTyped(node) && | 34 if (!NodeProperties::IsConstant(node) && NodeProperties::IsTyped(node) && |
| 35 node->op()->HasProperty(Operator::kEliminatable)) { | 35 node->op()->HasProperty(Operator::kEliminatable)) { |
| 36 // TODO(v8:5303): We must not eliminate FinishRegion here. This special |
| 37 // case can be removed once we have separate operators for value and |
| 38 // effect regions. |
| 39 if (node->opcode() == IrOpcode::kFinishRegion) return NoChange(); |
| 36 // We can only constant-fold nodes here, that are known to not cause any | 40 // We can only constant-fold nodes here, that are known to not cause any |
| 37 // side-effect, may it be a JavaScript observable side-effect or a possible | 41 // side-effect, may it be a JavaScript observable side-effect or a possible |
| 38 // eager deoptimization exit (i.e. {node} has an operator that doesn't have | 42 // eager deoptimization exit (i.e. {node} has an operator that doesn't have |
| 39 // the Operator::kNoDeopt property). | 43 // the Operator::kNoDeopt property). |
| 40 Type* upper = NodeProperties::GetType(node); | 44 Type* upper = NodeProperties::GetType(node); |
| 41 if (upper->IsInhabited()) { | 45 if (upper->IsInhabited()) { |
| 42 if (upper->IsConstant()) { | 46 if (upper->IsConstant()) { |
| 43 Node* replacement = jsgraph()->Constant(upper->AsConstant()->Value()); | 47 Node* replacement = jsgraph()->Constant(upper->AsConstant()->Value()); |
| 44 ReplaceWithValue(node, replacement); | 48 ReplaceWithValue(node, replacement); |
| 45 return Changed(replacement); | 49 return Changed(replacement); |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 | 252 |
| 249 Isolate* TypedOptimization::isolate() const { return jsgraph()->isolate(); } | 253 Isolate* TypedOptimization::isolate() const { return jsgraph()->isolate(); } |
| 250 | 254 |
| 251 SimplifiedOperatorBuilder* TypedOptimization::simplified() const { | 255 SimplifiedOperatorBuilder* TypedOptimization::simplified() const { |
| 252 return jsgraph()->simplified(); | 256 return jsgraph()->simplified(); |
| 253 } | 257 } |
| 254 | 258 |
| 255 } // namespace compiler | 259 } // namespace compiler |
| 256 } // namespace internal | 260 } // namespace internal |
| 257 } // namespace v8 | 261 } // namespace v8 |
| OLD | NEW |