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 3420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3431 } | 3431 } |
3432 | 3432 |
3433 | 3433 |
3434 void ConstantPropagator::VisitStoreVMField(StoreVMFieldInstr* instr) { | 3434 void ConstantPropagator::VisitStoreVMField(StoreVMFieldInstr* instr) { |
3435 SetValue(instr, instr->value()->definition()->constant_value()); | 3435 SetValue(instr, instr->value()->definition()->constant_value()); |
3436 } | 3436 } |
3437 | 3437 |
3438 | 3438 |
3439 void ConstantPropagator::VisitInstantiateTypeArguments( | 3439 void ConstantPropagator::VisitInstantiateTypeArguments( |
3440 InstantiateTypeArgumentsInstr* instr) { | 3440 InstantiateTypeArgumentsInstr* instr) { |
3441 const Object& object = | |
3442 instr->instantiator()->definition()->constant_value(); | |
3443 if (IsNonConstant(object)) { | |
Kevin Millikin (Google)
2012/11/28 07:57:25
If the value is unknown (bottom) it should not mov
Florian Schneider
2012/11/28 13:02:59
Thanks. Done.
| |
3444 SetValue(instr, non_constant_); | |
3445 return; | |
3446 } | |
3447 if (!object.IsNull() && object.IsTypeArguments()) { | |
srdjan
2012/11/30 00:49:54
You need to handle also the case for null otherwis
Florian Schneider
2012/12/04 11:40:09
Yes, that's a good suggestion. I'll add that case.
| |
3448 const TypeArguments& instantiator = TypeArguments::Cast(object); | |
3449 if (instantiator.Length() == instr->type_arguments().Length()) { | |
3450 SetValue(instr, instantiator); | |
3451 return; | |
3452 } | |
3453 } | |
3441 SetValue(instr, non_constant_); | 3454 SetValue(instr, non_constant_); |
3442 } | 3455 } |
3443 | 3456 |
3444 | 3457 |
3445 void ConstantPropagator::VisitExtractConstructorTypeArguments( | 3458 void ConstantPropagator::VisitExtractConstructorTypeArguments( |
3446 ExtractConstructorTypeArgumentsInstr* instr) { | 3459 ExtractConstructorTypeArgumentsInstr* instr) { |
3447 SetValue(instr, non_constant_); | 3460 SetValue(instr, non_constant_); |
3448 } | 3461 } |
3449 | 3462 |
3450 | 3463 |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3706 | 3719 |
3707 for (ForwardInstructionIterator i(block); !i.Done(); i.Advance()) { | 3720 for (ForwardInstructionIterator i(block); !i.Done(); i.Advance()) { |
3708 Definition* defn = i.Current()->AsDefinition(); | 3721 Definition* defn = i.Current()->AsDefinition(); |
3709 // Replace constant-valued instructions without observable side | 3722 // Replace constant-valued instructions without observable side |
3710 // effects. Do this for smis only to avoid having to copy other | 3723 // effects. Do this for smis only to avoid having to copy other |
3711 // objects into the heap's old generation. | 3724 // objects into the heap's old generation. |
3712 // | 3725 // |
3713 // TODO(kmillikin): Extend this to handle booleans, other number | 3726 // TODO(kmillikin): Extend this to handle booleans, other number |
3714 // types, etc. | 3727 // types, etc. |
3715 if ((defn != NULL) && | 3728 if ((defn != NULL) && |
3716 defn->constant_value().IsSmi() && | 3729 (defn->constant_value().IsSmi() || |
3730 defn->constant_value().IsTypeArguments()) && | |
3717 !defn->IsConstant() && | 3731 !defn->IsConstant() && |
3718 !defn->IsPushArgument() && | 3732 !defn->IsPushArgument() && |
3719 !defn->IsStoreIndexed() && | 3733 !defn->IsStoreIndexed() && |
3720 !defn->IsStoreInstanceField() && | 3734 !defn->IsStoreInstanceField() && |
3721 !defn->IsStoreStaticField() && | 3735 !defn->IsStoreStaticField() && |
3722 !defn->IsStoreVMField()) { | 3736 !defn->IsStoreVMField()) { |
3723 if (FLAG_trace_constant_propagation) { | 3737 if (FLAG_trace_constant_propagation) { |
3724 OS::Print("Constant v%"Pd" = %s\n", | 3738 OS::Print("Constant v%"Pd" = %s\n", |
3725 defn->ssa_temp_index(), | 3739 defn->ssa_temp_index(), |
3726 defn->constant_value().ToCString()); | 3740 defn->constant_value().ToCString()); |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3787 | 3801 |
3788 if (FLAG_trace_constant_propagation) { | 3802 if (FLAG_trace_constant_propagation) { |
3789 OS::Print("\n==== After constant propagation ====\n"); | 3803 OS::Print("\n==== After constant propagation ====\n"); |
3790 FlowGraphPrinter printer(*graph_); | 3804 FlowGraphPrinter printer(*graph_); |
3791 printer.PrintBlocks(); | 3805 printer.PrintBlocks(); |
3792 } | 3806 } |
3793 } | 3807 } |
3794 | 3808 |
3795 | 3809 |
3796 } // namespace dart | 3810 } // namespace dart |
OLD | NEW |