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 3346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3357 if (!type.IsInstantiated() || type.IsMalformedOrMalbounded()) { | 3357 if (!type.IsInstantiated() || type.IsMalformedOrMalbounded()) { |
3358 return Bool::null(); | 3358 return Bool::null(); |
3359 } | 3359 } |
3360 const Class& type_class = Class::Handle(type.type_class()); | 3360 const Class& type_class = Class::Handle(type.type_class()); |
3361 const intptr_t num_type_args = type_class.NumTypeArguments(); | 3361 const intptr_t num_type_args = type_class.NumTypeArguments(); |
3362 if (num_type_args > 0) { | 3362 if (num_type_args > 0) { |
3363 // Only raw types can be directly compared, thus disregarding type | 3363 // Only raw types can be directly compared, thus disregarding type |
3364 // arguments. | 3364 // arguments. |
3365 const intptr_t num_type_params = type_class.NumTypeParameters(); | 3365 const intptr_t num_type_params = type_class.NumTypeParameters(); |
3366 const intptr_t from_index = num_type_args - num_type_params; | 3366 const intptr_t from_index = num_type_args - num_type_params; |
3367 const AbstractTypeArguments& type_arguments = | 3367 const TypeArguments& type_arguments = |
3368 AbstractTypeArguments::Handle(type.arguments()); | 3368 TypeArguments::Handle(type.arguments()); |
3369 const bool is_raw_type = type_arguments.IsNull() || | 3369 const bool is_raw_type = type_arguments.IsNull() || |
3370 type_arguments.IsRaw(from_index, num_type_params); | 3370 type_arguments.IsRaw(from_index, num_type_params); |
3371 if (!is_raw_type) { | 3371 if (!is_raw_type) { |
3372 // Unknown result. | 3372 // Unknown result. |
3373 return Bool::null(); | 3373 return Bool::null(); |
3374 } | 3374 } |
3375 } | 3375 } |
3376 const ClassTable& class_table = *Isolate::Current()->class_table(); | 3376 const ClassTable& class_table = *Isolate::Current()->class_table(); |
3377 Bool& prev = Bool::Handle(); | 3377 Bool& prev = Bool::Handle(); |
3378 Class& cls = Class::Handle(); | 3378 Class& cls = Class::Handle(); |
(...skipping 3737 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7116 // TODO(kmillikin): Treat closures as constants. | 7116 // TODO(kmillikin): Treat closures as constants. |
7117 SetValue(instr, non_constant_); | 7117 SetValue(instr, non_constant_); |
7118 } | 7118 } |
7119 | 7119 |
7120 | 7120 |
7121 void ConstantPropagator::VisitAllocateObject(AllocateObjectInstr* instr) { | 7121 void ConstantPropagator::VisitAllocateObject(AllocateObjectInstr* instr) { |
7122 SetValue(instr, non_constant_); | 7122 SetValue(instr, non_constant_); |
7123 } | 7123 } |
7124 | 7124 |
7125 | 7125 |
7126 void ConstantPropagator::VisitAllocateObjectWithBoundsCheck( | |
7127 AllocateObjectWithBoundsCheckInstr* instr) { | |
7128 SetValue(instr, non_constant_); | |
7129 } | |
7130 | |
7131 | |
7132 void ConstantPropagator::VisitLoadUntagged(LoadUntaggedInstr* instr) { | 7126 void ConstantPropagator::VisitLoadUntagged(LoadUntaggedInstr* instr) { |
7133 SetValue(instr, non_constant_); | 7127 SetValue(instr, non_constant_); |
7134 } | 7128 } |
7135 | 7129 |
7136 | 7130 |
7137 void ConstantPropagator::VisitLoadClassId(LoadClassIdInstr* instr) { | 7131 void ConstantPropagator::VisitLoadClassId(LoadClassIdInstr* instr) { |
7138 intptr_t cid = instr->object()->Type()->ToCid(); | 7132 intptr_t cid = instr->object()->Type()->ToCid(); |
7139 if (cid != kDynamicCid) { | 7133 if (cid != kDynamicCid) { |
7140 SetValue(instr, Smi::ZoneHandle(Smi::New(cid))); | 7134 SetValue(instr, Smi::ZoneHandle(Smi::New(cid))); |
7141 return; | 7135 return; |
(...skipping 1338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8480 } | 8474 } |
8481 | 8475 |
8482 // Insert materializations at environment uses. | 8476 // Insert materializations at environment uses. |
8483 for (intptr_t i = 0; i < exits.length(); i++) { | 8477 for (intptr_t i = 0; i < exits.length(); i++) { |
8484 CreateMaterializationAt(exits[i], alloc, alloc->cls(), *fields); | 8478 CreateMaterializationAt(exits[i], alloc, alloc->cls(), *fields); |
8485 } | 8479 } |
8486 } | 8480 } |
8487 | 8481 |
8488 | 8482 |
8489 } // namespace dart | 8483 } // namespace dart |
OLD | NEW |