Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(84)

Side by Side Diff: runtime/vm/flow_graph_optimizer.cc

Issue 783683002: Better constant folding of length-loads in checked mode. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | runtime/vm/intermediate_language.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 = instance->definition()->OriginalDefinition()
8244 instr->instance()->definition()->AsCreateArray()->num_elements(); 8245 ->AsCreateArray()->num_elements();
8245 if (num_elements->BindsToConstant() && 8246 if (num_elements->BindsToConstant() &&
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
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
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/intermediate_language.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698