| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "vm/flow_graph_optimizer.h" | 5 #include "vm/flow_graph_optimizer.h" |
| 6 | 6 |
| 7 #include "vm/bit_vector.h" | 7 #include "vm/bit_vector.h" |
| 8 #include "vm/cha.h" | 8 #include "vm/cha.h" |
| 9 #include "vm/flow_graph_builder.h" | 9 #include "vm/flow_graph_builder.h" |
| 10 #include "vm/flow_graph_compiler.h" | 10 #include "vm/flow_graph_compiler.h" |
| (...skipping 3529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3540 SetValue(instr, instr->value()->definition()->constant_value()); | 3540 SetValue(instr, instr->value()->definition()->constant_value()); |
| 3541 } | 3541 } |
| 3542 | 3542 |
| 3543 | 3543 |
| 3544 void ConstantPropagator::VisitInstantiateTypeArguments( | 3544 void ConstantPropagator::VisitInstantiateTypeArguments( |
| 3545 InstantiateTypeArgumentsInstr* instr) { | 3545 InstantiateTypeArgumentsInstr* instr) { |
| 3546 const Object& object = | 3546 const Object& object = |
| 3547 instr->instantiator()->definition()->constant_value(); | 3547 instr->instantiator()->definition()->constant_value(); |
| 3548 if (IsNonConstant(object)) { | 3548 if (IsNonConstant(object)) { |
| 3549 SetValue(instr, non_constant_); | 3549 SetValue(instr, non_constant_); |
| 3550 } else if (IsConstant(object)) { | 3550 return; |
| 3551 if (!object.IsNull() && | 3551 } |
| 3552 if (IsConstant(object)) { |
| 3553 const intptr_t len = instr->type_arguments().Length(); |
| 3554 if (instr->type_arguments().IsRawInstantiatedRaw(len) && |
| 3555 object.IsNull()) { |
| 3556 SetValue(instr, object); |
| 3557 return; |
| 3558 } |
| 3559 if (instr->type_arguments().IsUninstantiatedIdentity() && |
| 3560 !object.IsNull() && |
| 3552 object.IsTypeArguments() && | 3561 object.IsTypeArguments() && |
| 3553 (TypeArguments::Cast(object).Length() == | 3562 (TypeArguments::Cast(object).Length() == len)) { |
| 3554 instr->type_arguments().Length())) { | |
| 3555 SetValue(instr, object); | 3563 SetValue(instr, object); |
| 3556 } else { | 3564 return; |
| 3557 SetValue(instr, non_constant_); | |
| 3558 } | 3565 } |
| 3566 SetValue(instr, non_constant_); |
| 3559 } | 3567 } |
| 3560 } | 3568 } |
| 3561 | 3569 |
| 3562 | 3570 |
| 3563 void ConstantPropagator::VisitExtractConstructorTypeArguments( | 3571 void ConstantPropagator::VisitExtractConstructorTypeArguments( |
| 3564 ExtractConstructorTypeArgumentsInstr* instr) { | 3572 ExtractConstructorTypeArgumentsInstr* instr) { |
| 3565 SetValue(instr, non_constant_); | 3573 SetValue(instr, non_constant_); |
| 3566 } | 3574 } |
| 3567 | 3575 |
| 3568 | 3576 |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3825 for (ForwardInstructionIterator i(block); !i.Done(); i.Advance()) { | 3833 for (ForwardInstructionIterator i(block); !i.Done(); i.Advance()) { |
| 3826 Definition* defn = i.Current()->AsDefinition(); | 3834 Definition* defn = i.Current()->AsDefinition(); |
| 3827 // Replace constant-valued instructions without observable side | 3835 // Replace constant-valued instructions without observable side |
| 3828 // effects. Do this for smis only to avoid having to copy other | 3836 // effects. Do this for smis only to avoid having to copy other |
| 3829 // objects into the heap's old generation. | 3837 // objects into the heap's old generation. |
| 3830 // | 3838 // |
| 3831 // TODO(kmillikin): Extend this to handle booleans, other number | 3839 // TODO(kmillikin): Extend this to handle booleans, other number |
| 3832 // types, etc. | 3840 // types, etc. |
| 3833 if ((defn != NULL) && | 3841 if ((defn != NULL) && |
| 3834 (defn->constant_value().IsSmi() || | 3842 (defn->constant_value().IsSmi() || |
| 3843 defn->constant_value().IsNull() || |
| 3835 defn->constant_value().IsTypeArguments()) && | 3844 defn->constant_value().IsTypeArguments()) && |
| 3836 !defn->IsConstant() && | 3845 !defn->IsConstant() && |
| 3837 !defn->IsPushArgument() && | 3846 !defn->IsPushArgument() && |
| 3838 !defn->IsStoreIndexed() && | 3847 !defn->IsStoreIndexed() && |
| 3839 !defn->IsStoreInstanceField() && | 3848 !defn->IsStoreInstanceField() && |
| 3840 !defn->IsStoreStaticField() && | 3849 !defn->IsStoreStaticField() && |
| 3841 !defn->IsStoreVMField()) { | 3850 !defn->IsStoreVMField()) { |
| 3842 if (FLAG_trace_constant_propagation) { | 3851 if (FLAG_trace_constant_propagation) { |
| 3843 OS::Print("Constant v%"Pd" = %s\n", | 3852 OS::Print("Constant v%"Pd" = %s\n", |
| 3844 defn->ssa_temp_index(), | 3853 defn->ssa_temp_index(), |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3906 | 3915 |
| 3907 if (FLAG_trace_constant_propagation) { | 3916 if (FLAG_trace_constant_propagation) { |
| 3908 OS::Print("\n==== After constant propagation ====\n"); | 3917 OS::Print("\n==== After constant propagation ====\n"); |
| 3909 FlowGraphPrinter printer(*graph_); | 3918 FlowGraphPrinter printer(*graph_); |
| 3910 printer.PrintBlocks(); | 3919 printer.PrintBlocks(); |
| 3911 } | 3920 } |
| 3912 } | 3921 } |
| 3913 | 3922 |
| 3914 | 3923 |
| 3915 } // namespace dart | 3924 } // namespace dart |
| OLD | NEW |