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

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

Issue 10911277: Optimize code for bound checks if array is constant. Skip unnecessary Smi checks if they still surv… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 3 months 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_ia32.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) 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/hash_map.h" 10 #include "vm/hash_map.h"
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 case kGrowableObjectArrayCid: { 356 case kGrowableObjectArrayCid: {
357 Value* array = call->ArgumentAt(0)->value(); 357 Value* array = call->ArgumentAt(0)->value();
358 Value* index = call->ArgumentAt(1)->value(); 358 Value* index = call->ArgumentAt(1)->value();
359 // Insert class check and index smi checks and attach a copy of the 359 // Insert class check and index smi checks and attach a copy of the
360 // original environment because the operation can still deoptimize. 360 // original environment because the operation can still deoptimize.
361 AddCheckClass(call, array->Copy()); 361 AddCheckClass(call, array->Copy());
362 InsertBefore(call, 362 InsertBefore(call,
363 new CheckSmiInstr(index->Copy(), call->deopt_id()), 363 new CheckSmiInstr(index->Copy(), call->deopt_id()),
364 call->env(), 364 call->env(),
365 Definition::kEffect); 365 Definition::kEffect);
366 // Insert array bounds check. 366 // If both index and array are constants, then the bound check always
367 InsertBefore(call, 367 // succeeded.
368 new CheckArrayBoundInstr(array->Copy(), 368 // TODO(srdjan): Remove once constant propagation lands.
369 index->Copy(), 369 if (!(array->BindsToConstant() && index->BindsToConstant())) {
370 class_id, 370 // Insert array bounds check.
371 call), 371 InsertBefore(call,
372 call->env(), 372 new CheckArrayBoundInstr(array->Copy(),
373 Definition::kEffect); 373 index->Copy(),
374 class_id,
375 call),
376 call->env(),
377 Definition::kEffect);
378 }
374 if (class_id == kGrowableObjectArrayCid) { 379 if (class_id == kGrowableObjectArrayCid) {
375 // Insert data elements load. 380 // Insert data elements load.
376 LoadFieldInstr* elements = 381 LoadFieldInstr* elements =
377 new LoadFieldInstr(array->Copy(), 382 new LoadFieldInstr(array->Copy(),
378 GrowableObjectArray::data_offset(), 383 GrowableObjectArray::data_offset(),
379 Type::ZoneHandle(Type::DynamicType())); 384 Type::ZoneHandle(Type::DynamicType()));
380 elements->set_result_cid(kArrayCid); 385 elements->set_result_cid(kArrayCid);
381 InsertBefore(call, elements, NULL, Definition::kValue); 386 InsertBefore(call, elements, NULL, Definition::kValue);
382 array = new Value(elements); 387 array = new Value(elements);
383 } 388 }
(...skipping 1183 matching lines...) Expand 10 before | Expand all | Expand 10 after
1567 DirectChainedHashMap<Definition*> child_map(*map); // Copy map. 1572 DirectChainedHashMap<Definition*> child_map(*map); // Copy map.
1568 OptimizeRecursive(child, &child_map); 1573 OptimizeRecursive(child, &child_map);
1569 } else { 1574 } else {
1570 OptimizeRecursive(child, map); // Reuse map for the last child. 1575 OptimizeRecursive(child, map); // Reuse map for the last child.
1571 } 1576 }
1572 } 1577 }
1573 } 1578 }
1574 1579
1575 1580
1576 } // namespace dart 1581 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/intermediate_language_ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698