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

Unified Diff: runtime/vm/flow_graph_optimizer.cc

Issue 25640004: Bug fix in load elimination, constant propagation for LoadClassId. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | runtime/vm/il_printer.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/flow_graph_optimizer.cc
===================================================================
--- runtime/vm/flow_graph_optimizer.cc (revision 28090)
+++ runtime/vm/flow_graph_optimizer.cc (working copy)
@@ -4148,7 +4148,7 @@
switch (instr->tag()) {
case Instruction::kLoadField: {
LoadFieldInstr* load_field = instr->AsLoadField();
- instance_ = load_field->instance()->definition();
+ instance_ = OriginalDefinition(load_field->instance()->definition());
if (load_field->field() != NULL) {
kind_ = kField;
field_ = load_field->field();
@@ -4164,7 +4164,8 @@
StoreInstanceFieldInstr* store_instance_field =
instr->AsStoreInstanceField();
kind_ = kField;
- instance_ = store_instance_field->instance()->definition();
+ instance_ =
+ OriginalDefinition(store_instance_field->instance()->definition());
field_ = &store_instance_field->field();
break;
}
@@ -4172,7 +4173,7 @@
case Instruction::kStoreVMField: {
StoreVMFieldInstr* store_vm_field = instr->AsStoreVMField();
kind_ = kVMField;
- instance_ = store_vm_field->dest()->definition();
+ instance_ = OriginalDefinition(store_vm_field->dest()->definition());
offset_in_bytes_ = store_vm_field->offset_in_bytes();
break;
}
@@ -4191,7 +4192,7 @@
case Instruction::kLoadIndexed: {
LoadIndexedInstr* load_indexed = instr->AsLoadIndexed();
kind_ = kIndexed;
- instance_ = load_indexed->array()->definition();
+ instance_ = OriginalDefinition(load_indexed->array()->definition());
index_ = load_indexed->index()->definition();
*is_load = true;
break;
@@ -4200,7 +4201,7 @@
case Instruction::kStoreIndexed: {
StoreIndexedInstr* store_indexed = instr->AsStoreIndexed();
kind_ = kIndexed;
- instance_ = store_indexed->array()->definition();
+ instance_ = OriginalDefinition(store_indexed->array()->definition());
index_ = store_indexed->index()->definition();
break;
}
@@ -4231,7 +4232,7 @@
void set_instance(Definition* def) {
ASSERT((kind_ == kField) || (kind_ == kVMField) || (kind_ == kIndexed));
- instance_ = def;
+ instance_ = OriginalDefinition(def);
}
const Field& field() const {
@@ -4302,6 +4303,13 @@
static Place* Wrap(const Place& place);
private:
+ static Definition* OriginalDefinition(Definition* defn) {
+ while (defn->IsRedefinition()) {
+ defn = defn->AsRedefinition()->value()->definition();
+ }
+ return defn;
+ }
+
bool SameField(Place* other) const {
return (kind_ == kField) ? (field().raw() == other->field().raw())
: (offset_in_bytes_ == other->offset_in_bytes_);
@@ -6280,6 +6288,16 @@
void ConstantPropagator::VisitLoadClassId(LoadClassIdInstr* instr) {
+ intptr_t cid = instr->object()->Type()->ToCid();
+ if (cid != kDynamicCid) {
+ SetValue(instr, Smi::ZoneHandle(Smi::New(cid)));
+ return;
+ }
+ const Object& object = instr->object()->definition()->constant_value();
+ if (IsConstant(object)) {
+ SetValue(instr, Smi::ZoneHandle(Smi::New(object.GetClassId())));
+ return;
+ }
SetValue(instr, non_constant_);
}
« no previous file with comments | « no previous file | runtime/vm/il_printer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698