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/cpu.h" | 9 #include "vm/cpu.h" |
| 10 #include "vm/dart_entry.h" | 10 #include "vm/dart_entry.h" |
| (...skipping 8220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 8231 const Object& object = instr->object()->definition()->constant_value(); | 8231 const Object& object = instr->object()->definition()->constant_value(); |
| 8232 if (IsConstant(object)) { | 8232 if (IsConstant(object)) { |
| 8233 SetValue(instr, Smi::ZoneHandle(I, Smi::New(object.GetClassId()))); | 8233 SetValue(instr, Smi::ZoneHandle(I, Smi::New(object.GetClassId()))); |
| 8234 return; | 8234 return; |
| 8235 } | 8235 } |
| 8236 SetValue(instr, non_constant_); | 8236 SetValue(instr, non_constant_); |
| 8237 } | 8237 } |
| 8238 | 8238 |
| 8239 | 8239 |
| 8240 void ConstantPropagator::VisitLoadField(LoadFieldInstr* instr) { | 8240 void ConstantPropagator::VisitLoadField(LoadFieldInstr* instr) { |
| 8241 Value* instance = instr->instance(); | |
| 8241 if ((instr->recognized_kind() == MethodRecognizer::kObjectArrayLength) && | 8242 if ((instr->recognized_kind() == MethodRecognizer::kObjectArrayLength) && |
| 8242 (instr->instance()->definition()->IsCreateArray())) { | 8243 instance->definition()->OriginalDefinition()->IsCreateArray()) { |
| 8243 Value* num_elements = | 8244 Value* num_elements = |
| 8244 instr->instance()->definition()->AsCreateArray()->num_elements(); | 8245 instance->definition()->AsCreateArray()->num_elements(); |
| 8245 if (num_elements->BindsToConstant() && | 8246 if (num_elements->BindsToConstant() && |
|
Vyacheslav Egorov (Google)
2014/12/05 13:45:16
Maybe BindsToConstant/BoundConstant should also be
| |
| 8246 num_elements->BoundConstant().IsSmi()) { | 8247 num_elements->BoundConstant().IsSmi()) { |
| 8247 intptr_t length = Smi::Cast(num_elements->BoundConstant()).Value(); | 8248 intptr_t length = Smi::Cast(num_elements->BoundConstant()).Value(); |
| 8248 const Object& result = Smi::ZoneHandle(I, Smi::New(length)); | 8249 const Object& result = Smi::ZoneHandle(I, Smi::New(length)); |
| 8249 SetValue(instr, result); | 8250 SetValue(instr, result); |
| 8250 return; | 8251 return; |
| 8251 } | 8252 } |
| 8252 } | 8253 } |
| 8253 | 8254 |
| 8254 if (instr->IsImmutableLengthLoad()) { | 8255 if (instr->IsImmutableLengthLoad()) { |
| 8255 ConstantInstr* constant = instr->instance()->definition()->AsConstant(); | 8256 ConstantInstr* constant = |
| 8257 instance->definition()->OriginalDefinition()->AsConstant(); | |
| 8256 if (constant != NULL) { | 8258 if (constant != NULL) { |
| 8257 if (constant->value().IsString()) { | 8259 if (constant->value().IsString()) { |
| 8258 SetValue(instr, Smi::ZoneHandle(I, | 8260 SetValue(instr, Smi::ZoneHandle(I, |
| 8259 Smi::New(String::Cast(constant->value()).Length()))); | 8261 Smi::New(String::Cast(constant->value()).Length()))); |
| 8260 return; | 8262 return; |
| 8261 } | 8263 } |
| 8262 if (constant->value().IsArray()) { | 8264 if (constant->value().IsArray()) { |
| 8263 SetValue(instr, Smi::ZoneHandle(I, | 8265 SetValue(instr, Smi::ZoneHandle(I, |
| 8264 Smi::New(Array::Cast(constant->value()).Length()))); | 8266 Smi::New(Array::Cast(constant->value()).Length()))); |
| 8265 return; | 8267 return; |
| (...skipping 1796 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 10062 | 10064 |
| 10063 // Insert materializations at environment uses. | 10065 // Insert materializations at environment uses. |
| 10064 for (intptr_t i = 0; i < exits_collector_.exits().length(); i++) { | 10066 for (intptr_t i = 0; i < exits_collector_.exits().length(); i++) { |
| 10065 CreateMaterializationAt( | 10067 CreateMaterializationAt( |
| 10066 exits_collector_.exits()[i], alloc, *slots); | 10068 exits_collector_.exits()[i], alloc, *slots); |
| 10067 } | 10069 } |
| 10068 } | 10070 } |
| 10069 | 10071 |
| 10070 | 10072 |
| 10071 } // namespace dart | 10073 } // namespace dart |
| OLD | NEW |