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

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

Issue 23584002: Replace guarded list length field loads with constants (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 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 | « runtime/vm/flow_graph_optimizer.cc ('k') | no next file » | 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/intermediate_language.h" 5 #include "vm/intermediate_language.h"
6 6
7 #include "vm/bigint_operations.h" 7 #include "vm/bigint_operations.h"
8 #include "vm/bit_vector.h" 8 #include "vm/bit_vector.h"
9 #include "vm/dart_entry.h" 9 #include "vm/dart_entry.h"
10 #include "vm/flow_graph_allocator.h" 10 #include "vm/flow_graph_allocator.h"
(...skipping 1350 matching lines...) Expand 10 before | Expand all | Expand 10 after
1361 1361
1362 // For fixed length arrays if the array is the result of a known constructor 1362 // For fixed length arrays if the array is the result of a known constructor
1363 // call we can replace the length load with the length argument passed to 1363 // call we can replace the length load with the length argument passed to
1364 // the constructor. 1364 // the constructor.
1365 StaticCallInstr* call = instance()->definition()->AsStaticCall(); 1365 StaticCallInstr* call = instance()->definition()->AsStaticCall();
1366 if ((call != NULL) && 1366 if ((call != NULL) &&
1367 call->is_known_list_constructor() && 1367 call->is_known_list_constructor() &&
1368 IsFixedLengthArrayCid(call->Type()->ToCid())) { 1368 IsFixedLengthArrayCid(call->Type()->ToCid())) {
1369 return call->ArgumentAt(1); 1369 return call->ArgumentAt(1);
1370 } 1370 }
1371 // For arrays with guarded lengths, replace the length load
1372 // with a constant.
1373 LoadFieldInstr* load_array = instance()->definition()->AsLoadField();
1374 if (load_array != NULL) {
1375 const Field* field = load_array->field();
1376 if ((field != NULL) && (field->guarded_list_length() >= 0)) {
1377 return flow_graph->GetConstant(
1378 Smi::Handle(Smi::New(field->guarded_list_length())));
1379 }
1380 }
1371 return this; 1381 return this;
1372 } 1382 }
1373 1383
1374 1384
1375 Definition* AssertBooleanInstr::Canonicalize(FlowGraph* flow_graph) { 1385 Definition* AssertBooleanInstr::Canonicalize(FlowGraph* flow_graph) {
1376 if (FLAG_eliminate_type_checks && (value()->Type()->ToCid() == kBoolCid)) { 1386 if (FLAG_eliminate_type_checks && (value()->Type()->ToCid() == kBoolCid)) {
1377 return value()->definition(); 1387 return value()->definition();
1378 } 1388 }
1379 1389
1380 return this; 1390 return this;
(...skipping 1277 matching lines...) Expand 10 before | Expand all | Expand 10 after
2658 return kCosRuntimeEntry; 2668 return kCosRuntimeEntry;
2659 default: 2669 default:
2660 UNREACHABLE(); 2670 UNREACHABLE();
2661 } 2671 }
2662 return kSinRuntimeEntry; 2672 return kSinRuntimeEntry;
2663 } 2673 }
2664 2674
2665 #undef __ 2675 #undef __
2666 2676
2667 } // namespace dart 2677 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/flow_graph_optimizer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698