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

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

Issue 23583054: Revert (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 1552 matching lines...) Expand 10 before | Expand all | Expand 10 after
1563 callee_receiver->IsParameter() && 1563 callee_receiver->IsParameter() &&
1564 (callee_receiver->AsParameter()->index() == 0)) { 1564 (callee_receiver->AsParameter()->index() == 0)) {
1565 const String& field_name = 1565 const String& field_name =
1566 String::Handle(Field::NameFromGetter(call->function_name())); 1566 String::Handle(Field::NameFromGetter(call->function_name()));
1567 return CHA::HasOverride(Class::Handle(function.Owner()), field_name); 1567 return CHA::HasOverride(Class::Handle(function.Owner()), field_name);
1568 } 1568 }
1569 return true; 1569 return true;
1570 } 1570 }
1571 1571
1572 1572
1573 void FlowGraphOptimizer::AddToGuardedFields(const Field& field) {
1574 if ((field.guarded_cid() == kDynamicCid) ||
1575 (field.guarded_cid() == kIllegalCid)) {
1576 return;
1577 }
1578 for (intptr_t j = 0; j < guarded_fields_->length(); j++) {
1579 if ((*guarded_fields_)[j]->raw() == field.raw()) {
1580 return;
1581 }
1582 }
1583 guarded_fields_->Add(&field);
1584 }
1585
1586
1573 void FlowGraphOptimizer::InlineImplicitInstanceGetter(InstanceCallInstr* call) { 1587 void FlowGraphOptimizer::InlineImplicitInstanceGetter(InstanceCallInstr* call) {
1574 ASSERT(call->HasICData()); 1588 ASSERT(call->HasICData());
1575 const ICData& ic_data = *call->ic_data(); 1589 const ICData& ic_data = *call->ic_data();
1576 Function& target = Function::Handle(); 1590 Function& target = Function::Handle();
1577 GrowableArray<intptr_t> class_ids; 1591 GrowableArray<intptr_t> class_ids;
1578 ic_data.GetCheckAt(0, &class_ids, &target); 1592 ic_data.GetCheckAt(0, &class_ids, &target);
1579 ASSERT(class_ids.length() == 1); 1593 ASSERT(class_ids.length() == 1);
1580 // Inline implicit instance getter. 1594 // Inline implicit instance getter.
1581 const String& field_name = 1595 const String& field_name =
1582 String::Handle(Field::NameFromGetter(call->function_name())); 1596 String::Handle(Field::NameFromGetter(call->function_name()));
1583 const Field& field = Field::ZoneHandle(GetField(class_ids[0], field_name)); 1597 const Field& field = Field::ZoneHandle(GetField(class_ids[0], field_name));
1584 ASSERT(!field.IsNull()); 1598 ASSERT(!field.IsNull());
1585 1599
1586 if (InstanceCallNeedsClassCheck(call)) { 1600 if (InstanceCallNeedsClassCheck(call)) {
1587 AddReceiverCheck(call); 1601 AddReceiverCheck(call);
1588 } 1602 }
1589 LoadFieldInstr* load = new LoadFieldInstr( 1603 LoadFieldInstr* load = new LoadFieldInstr(
1590 new Value(call->ArgumentAt(0)), 1604 new Value(call->ArgumentAt(0)),
1591 field.Offset(), 1605 field.Offset(),
1592 AbstractType::ZoneHandle(field.type()), 1606 AbstractType::ZoneHandle(field.type()),
1593 field.is_final()); 1607 field.is_final());
1594 load->set_field(&field); 1608 load->set_field(&field);
1595 if (field.guarded_cid() != kIllegalCid) { 1609 if (field.guarded_cid() != kIllegalCid) {
1596 if (!field.is_nullable() || (field.guarded_cid() == kNullCid)) { 1610 if (!field.is_nullable() || (field.guarded_cid() == kNullCid)) {
1597 load->set_result_cid(field.guarded_cid()); 1611 load->set_result_cid(field.guarded_cid());
1598 } 1612 }
1599 flow_graph_->builder().AddToGuardedFields(field); 1613 AddToGuardedFields(field);
1600 } 1614 }
1601 1615
1602 // Discard the environment from the original instruction because the load 1616 // Discard the environment from the original instruction because the load
1603 // can't deoptimize. 1617 // can't deoptimize.
1604 call->RemoveEnvironment(); 1618 call->RemoveEnvironment();
1605 ReplaceCall(call, load); 1619 ReplaceCall(call, load);
1606 1620
1607 if (load->result_cid() != kDynamicCid) { 1621 if (load->result_cid() != kDynamicCid) {
1608 // Reset value types if guarded_cid was used. 1622 // Reset value types if guarded_cid was used.
1609 for (Value::Iterator it(load->input_use_list()); 1623 for (Value::Iterator it(load->input_use_list());
(...skipping 6047 matching lines...) Expand 10 before | Expand all | Expand 10 after
7657 } 7671 }
7658 7672
7659 // Insert materializations at environment uses. 7673 // Insert materializations at environment uses.
7660 for (intptr_t i = 0; i < exits.length(); i++) { 7674 for (intptr_t i = 0; i < exits.length(); i++) {
7661 CreateMaterializationAt(exits[i], alloc, alloc->cls(), *fields); 7675 CreateMaterializationAt(exits[i], alloc, alloc->cls(), *fields);
7662 } 7676 }
7663 } 7677 }
7664 7678
7665 7679
7666 } // namespace dart 7680 } // 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