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

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

Issue 24096018: Fix bug in field type tracking and polymorphic inlining. (Closed) Base URL: http://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.h ('k') | tests/language/vm/optimized_guarded_field_test.dart » ('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/dart_entry.h" 9 #include "vm/dart_entry.h"
10 #include "vm/flow_graph_builder.h" 10 #include "vm/flow_graph_builder.h"
(...skipping 1364 matching lines...) Expand 10 before | Expand all | Expand 10 after
1375 callee_receiver->IsParameter() && 1375 callee_receiver->IsParameter() &&
1376 (callee_receiver->AsParameter()->index() == 0)) { 1376 (callee_receiver->AsParameter()->index() == 0)) {
1377 const String& field_name = 1377 const String& field_name =
1378 String::Handle(Field::NameFromGetter(call->function_name())); 1378 String::Handle(Field::NameFromGetter(call->function_name()));
1379 return CHA::HasOverride(Class::Handle(function.Owner()), field_name); 1379 return CHA::HasOverride(Class::Handle(function.Owner()), field_name);
1380 } 1380 }
1381 return true; 1381 return true;
1382 } 1382 }
1383 1383
1384 1384
1385 void FlowGraphOptimizer::AddToGuardedFields(const Field& field) {
1386 if ((field.guarded_cid() == kDynamicCid) ||
1387 (field.guarded_cid() == kIllegalCid)) {
1388 return;
1389 }
1390 for (intptr_t j = 0; j < guarded_fields_->length(); j++) {
1391 if ((*guarded_fields_)[j]->raw() == field.raw()) {
1392 return;
1393 }
1394 }
1395 guarded_fields_->Add(&field);
1396 }
1397
1398
1399 void FlowGraphOptimizer::InlineImplicitInstanceGetter(InstanceCallInstr* call) { 1385 void FlowGraphOptimizer::InlineImplicitInstanceGetter(InstanceCallInstr* call) {
1400 ASSERT(call->HasICData()); 1386 ASSERT(call->HasICData());
1401 const ICData& ic_data = *call->ic_data(); 1387 const ICData& ic_data = *call->ic_data();
1402 Function& target = Function::Handle(); 1388 Function& target = Function::Handle();
1403 GrowableArray<intptr_t> class_ids; 1389 GrowableArray<intptr_t> class_ids;
1404 ic_data.GetCheckAt(0, &class_ids, &target); 1390 ic_data.GetCheckAt(0, &class_ids, &target);
1405 ASSERT(class_ids.length() == 1); 1391 ASSERT(class_ids.length() == 1);
1406 // Inline implicit instance getter. 1392 // Inline implicit instance getter.
1407 const String& field_name = 1393 const String& field_name =
1408 String::Handle(Field::NameFromGetter(call->function_name())); 1394 String::Handle(Field::NameFromGetter(call->function_name()));
1409 const Field& field = Field::ZoneHandle(GetField(class_ids[0], field_name)); 1395 const Field& field = Field::ZoneHandle(GetField(class_ids[0], field_name));
1410 ASSERT(!field.IsNull()); 1396 ASSERT(!field.IsNull());
1411 1397
1412 if (InstanceCallNeedsClassCheck(call)) { 1398 if (InstanceCallNeedsClassCheck(call)) {
1413 AddReceiverCheck(call); 1399 AddReceiverCheck(call);
1414 } 1400 }
1415 LoadFieldInstr* load = new LoadFieldInstr( 1401 LoadFieldInstr* load = new LoadFieldInstr(
1416 new Value(call->ArgumentAt(0)), 1402 new Value(call->ArgumentAt(0)),
1417 field.Offset(), 1403 field.Offset(),
1418 AbstractType::ZoneHandle(field.type()), 1404 AbstractType::ZoneHandle(field.type()),
1419 field.is_final()); 1405 field.is_final());
1420 load->set_field(&field); 1406 load->set_field(&field);
1421 if (field.guarded_cid() != kIllegalCid) { 1407 if (field.guarded_cid() != kIllegalCid) {
1422 if (!field.is_nullable() || (field.guarded_cid() == kNullCid)) { 1408 if (!field.is_nullable() || (field.guarded_cid() == kNullCid)) {
1423 load->set_result_cid(field.guarded_cid()); 1409 load->set_result_cid(field.guarded_cid());
1424 } 1410 }
1425 AddToGuardedFields(field); 1411 flow_graph_->builder().AddToGuardedFields(field);
1426 } 1412 }
1427 1413
1428 // Discard the environment from the original instruction because the load 1414 // Discard the environment from the original instruction because the load
1429 // can't deoptimize. 1415 // can't deoptimize.
1430 call->RemoveEnvironment(); 1416 call->RemoveEnvironment();
1431 ReplaceCall(call, load); 1417 ReplaceCall(call, load);
1432 1418
1433 if (load->result_cid() != kDynamicCid) { 1419 if (load->result_cid() != kDynamicCid) {
1434 // Reset value types if guarded_cid was used. 1420 // Reset value types if guarded_cid was used.
1435 for (Value::Iterator it(load->input_use_list()); 1421 for (Value::Iterator it(load->input_use_list());
(...skipping 6047 matching lines...) Expand 10 before | Expand all | Expand 10 after
7483 } 7469 }
7484 7470
7485 // Insert materializations at environment uses. 7471 // Insert materializations at environment uses.
7486 for (intptr_t i = 0; i < exits.length(); i++) { 7472 for (intptr_t i = 0; i < exits.length(); i++) {
7487 CreateMaterializationAt(exits[i], alloc, alloc->cls(), *fields); 7473 CreateMaterializationAt(exits[i], alloc, alloc->cls(), *fields);
7488 } 7474 }
7489 } 7475 }
7490 7476
7491 7477
7492 } // namespace dart 7478 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/flow_graph_optimizer.h ('k') | tests/language/vm/optimized_guarded_field_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698