Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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/dart_entry.h" | 9 #include "vm/dart_entry.h" |
| 10 #include "vm/flow_graph_builder.h" | 10 #include "vm/flow_graph_builder.h" |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 89 if (compare->IsStrictCompare()) { | 89 if (compare->IsStrictCompare()) { |
| 90 VisitStrictCompare(compare->AsStrictCompare()); | 90 VisitStrictCompare(compare->AsStrictCompare()); |
| 91 } | 91 } |
| 92 } | 92 } |
| 93 } | 93 } |
| 94 current_iterator_ = NULL; | 94 current_iterator_ = NULL; |
| 95 } | 95 } |
| 96 } | 96 } |
| 97 | 97 |
| 98 | 98 |
| 99 static bool NoneIsDynamic(const GrowableArray<intptr_t>& cids) { | |
| 100 for (intptr_t i = 0; i < cids.length(); i++) { | |
| 101 if (cids[i] == kDynamicCid) { | |
| 102 return false; | |
| 103 } | |
| 104 } | |
| 105 return true; | |
| 106 } | |
| 107 | |
| 108 | |
| 99 // Attempt to build ICData for call using propagated class-ids. | 109 // Attempt to build ICData for call using propagated class-ids. |
| 100 bool FlowGraphOptimizer::TryCreateICData(InstanceCallInstr* call) { | 110 bool FlowGraphOptimizer::TryCreateICData(InstanceCallInstr* call) { |
| 101 ASSERT(call->HasICData()); | 111 ASSERT(call->HasICData()); |
| 102 if (call->ic_data()->NumberOfChecks() > 0) { | 112 if (call->ic_data()->NumberOfChecks() > 0) { |
| 103 // This occurs when an instance call has too many checks. | 113 // This occurs when an instance call has too many checks. |
| 104 // TODO(srdjan): Replace IC call with megamorphic call. | |
| 105 return false; | 114 return false; |
| 106 } | 115 } |
| 107 GrowableArray<intptr_t> class_ids(call->ic_data()->num_args_tested()); | 116 GrowableArray<intptr_t> class_ids(call->ic_data()->num_args_tested()); |
| 108 ASSERT(call->ic_data()->num_args_tested() <= call->ArgumentCount()); | 117 ASSERT(call->ic_data()->num_args_tested() <= call->ArgumentCount()); |
| 109 for (intptr_t i = 0; i < call->ic_data()->num_args_tested(); i++) { | 118 for (intptr_t i = 0; i < call->ic_data()->num_args_tested(); i++) { |
| 110 intptr_t cid = call->PushArgumentAt(i)->value()->Type()->ToCid(); | 119 intptr_t cid = call->PushArgumentAt(i)->value()->Type()->ToCid(); |
| 111 class_ids.Add(cid); | 120 class_ids.Add(cid); |
| 112 } | 121 } |
| 113 if (class_ids[0] != kDynamicCid) { | 122 if (NoneIsDynamic(class_ids)) { |
|
Florian Schneider
2013/12/11 10:41:08
I'd prefer naming this helper the opposite: e.g. O
srdjan
2013/12/11 21:54:59
Aggreed. However, decided to inline the loop and e
| |
| 114 ArgumentsDescriptor args_desc( | 123 ArgumentsDescriptor args_desc( |
| 115 Array::Handle(ArgumentsDescriptor::New(call->ArgumentCount(), | 124 Array::Handle(ArgumentsDescriptor::New(call->ArgumentCount(), |
| 116 call->argument_names()))); | 125 call->argument_names()))); |
| 117 const Class& receiver_class = Class::Handle( | 126 const Class& receiver_class = Class::Handle( |
| 118 Isolate::Current()->class_table()->At(class_ids[0])); | 127 Isolate::Current()->class_table()->At(class_ids[0])); |
| 119 const Function& function = Function::Handle( | 128 const Function& function = Function::Handle( |
| 120 Resolver::ResolveDynamicForReceiverClass( | 129 Resolver::ResolveDynamicForReceiverClass( |
| 121 receiver_class, | 130 receiver_class, |
| 122 call->function_name(), | 131 call->function_name(), |
| 123 args_desc)); | 132 args_desc)); |
| (...skipping 6775 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6899 SetValue(instr, non_constant_); | 6908 SetValue(instr, non_constant_); |
| 6900 } | 6909 } |
| 6901 | 6910 |
| 6902 | 6911 |
| 6903 void ConstantPropagator::VisitUnboxInteger(UnboxIntegerInstr* instr) { | 6912 void ConstantPropagator::VisitUnboxInteger(UnboxIntegerInstr* instr) { |
| 6904 // TODO(kmillikin): Handle unbox operation. | 6913 // TODO(kmillikin): Handle unbox operation. |
| 6905 SetValue(instr, non_constant_); | 6914 SetValue(instr, non_constant_); |
| 6906 } | 6915 } |
| 6907 | 6916 |
| 6908 | 6917 |
| 6909 void ConstantPropagator::VisitBinaryMintOp( | 6918 void ConstantPropagator::VisitBinaryMintOp(BinaryMintOpInstr* instr) { |
| 6910 BinaryMintOpInstr* instr) { | |
| 6911 HandleBinaryOp(instr, instr->op_kind(), *instr->left(), *instr->right()); | 6919 HandleBinaryOp(instr, instr->op_kind(), *instr->left(), *instr->right()); |
| 6912 } | 6920 } |
| 6913 | 6921 |
| 6914 | 6922 |
| 6915 void ConstantPropagator::VisitShiftMintOp( | 6923 void ConstantPropagator::VisitShiftMintOp(ShiftMintOpInstr* instr) { |
| 6916 ShiftMintOpInstr* instr) { | |
| 6917 HandleBinaryOp(instr, instr->op_kind(), *instr->left(), *instr->right()); | 6924 HandleBinaryOp(instr, instr->op_kind(), *instr->left(), *instr->right()); |
| 6918 } | 6925 } |
| 6919 | 6926 |
| 6920 | 6927 |
| 6921 void ConstantPropagator::VisitUnaryMintOp( | 6928 void ConstantPropagator::VisitUnaryMintOp(UnaryMintOpInstr* instr) { |
| 6922 UnaryMintOpInstr* instr) { | |
| 6923 // TODO(kmillikin): Handle unary operations. | 6929 // TODO(kmillikin): Handle unary operations. |
| 6924 SetValue(instr, non_constant_); | 6930 SetValue(instr, non_constant_); |
| 6925 } | 6931 } |
| 6926 | 6932 |
| 6927 | 6933 |
| 6928 void ConstantPropagator::VisitUnarySmiOp(UnarySmiOpInstr* instr) { | 6934 void ConstantPropagator::VisitUnarySmiOp(UnarySmiOpInstr* instr) { |
| 6929 const Object& value = instr->value()->definition()->constant_value(); | 6935 const Object& value = instr->value()->definition()->constant_value(); |
| 6930 if (IsNonConstant(value)) { | 6936 if (IsNonConstant(value)) { |
| 6931 SetValue(instr, non_constant_); | 6937 SetValue(instr, non_constant_); |
| 6932 } else if (IsConstant(value)) { | 6938 } else if (IsConstant(value)) { |
| (...skipping 1113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 8046 } | 8052 } |
| 8047 | 8053 |
| 8048 // Insert materializations at environment uses. | 8054 // Insert materializations at environment uses. |
| 8049 for (intptr_t i = 0; i < exits.length(); i++) { | 8055 for (intptr_t i = 0; i < exits.length(); i++) { |
| 8050 CreateMaterializationAt(exits[i], alloc, alloc->cls(), *fields); | 8056 CreateMaterializationAt(exits[i], alloc, alloc->cls(), *fields); |
| 8051 } | 8057 } |
| 8052 } | 8058 } |
| 8053 | 8059 |
| 8054 | 8060 |
| 8055 } // namespace dart | 8061 } // namespace dart |
| OLD | NEW |