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

Unified Diff: runtime/vm/flow_graph_optimizer.cc

Issue 10868013: Factor out code for insertin class checks. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 4 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 | no next file » | 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 11116)
+++ runtime/vm/flow_graph_optimizer.cc (working copy)
@@ -194,6 +194,22 @@
}
+static void AddCheckClass(BindInstr* instr,
+ InstanceCallComp* comp,
+ Value* value) {
+ // Type propagation has not run yet, we cannot eliminate the check.
+ CheckClassComp* check = new CheckClassComp(value, comp);
+ const ICData& unary_checks =
+ ICData::ZoneHandle(comp->ic_data()->AsUnaryClassChecks());
+ check->set_ic_data(&unary_checks);
+ BindInstr* check_instr = new BindInstr(BindInstr::kUnused, check);
+ ASSERT(instr->env() != NULL); // Always the case with SSA.
+ // Attach the original environment to the check instruction.
+ check_instr->set_env(instr->env());
+ check_instr->InsertBefore(instr);
+}
+
+
bool FlowGraphOptimizer::TryReplaceWithArrayOp(BindInstr* instr,
InstanceCallComp* comp,
Token::Kind op_kind) {
@@ -211,16 +227,16 @@
case kGrowableObjectArrayCid: {
Computation* array_op = NULL;
if (op_kind == Token::kINDEX) {
- array_op = new LoadIndexedComp(comp->ArgumentAt(0)->value(),
- comp->ArgumentAt(1)->value(),
- class_id,
- comp);
+ array_op = new LoadIndexedComp(comp->ArgumentAt(0)->value(),
+ comp->ArgumentAt(1)->value(),
+ class_id,
+ comp);
} else {
- array_op = new StoreIndexedComp(comp->ArgumentAt(0)->value(),
- comp->ArgumentAt(1)->value(),
- comp->ArgumentAt(2)->value(),
- class_id,
- comp);
+ array_op = new StoreIndexedComp(comp->ArgumentAt(0)->value(),
+ comp->ArgumentAt(1)->value(),
+ comp->ArgumentAt(2)->value(),
+ class_id,
+ comp);
}
array_op->set_ic_data(comp->ic_data());
instr->set_computation(array_op);
@@ -366,19 +382,8 @@
String::Handle(Field::NameFromGetter(comp->function_name()));
const Field& field = Field::Handle(GetField(class_ids[0], field_name));
ASSERT(!field.IsNull());
-
- // Type propagation has not run yet, we cannot eliminate the check.
- CheckClassComp* check =
- new CheckClassComp(comp->ArgumentAt(0)->value(), comp);
- const ICData& unary_checks =
- ICData::ZoneHandle(comp->ic_data()->AsUnaryClassChecks());
- check->set_ic_data(&unary_checks);
- BindInstr* check_instr = new BindInstr(BindInstr::kUnused, check);
- ASSERT(instr->env() != NULL); // Always the case with SSA.
- // Attach the original environment to the check instruction.
- check_instr->set_env(instr->env());
+ AddCheckClass(instr, comp, comp->ArgumentAt(0)->value());
instr->set_env(NULL);
- check_instr->InsertBefore(instr);
LoadInstanceFieldComp* load =
new LoadInstanceFieldComp(field,
comp->ArgumentAt(0)->value(),
@@ -558,18 +563,8 @@
const Field& field = Field::Handle(GetField(class_id, field_name));
ASSERT(!field.IsNull());
- // Type propagation has not run yet, we cannot eliminate the check.
- CheckClassComp* check =
- new CheckClassComp(comp->ArgumentAt(0)->value(), comp);
- const ICData& unary_checks =
- ICData::ZoneHandle(comp->ic_data()->AsUnaryClassChecks());
- check->set_ic_data(&unary_checks);
- BindInstr* check_instr = new BindInstr(BindInstr::kUnused, check);
- ASSERT(instr->env() != NULL); // Always the case with SSA.
- // Attach the original environment to the check instruction.
- check_instr->set_env(instr->env());
+ AddCheckClass(instr, comp, comp->ArgumentAt(0)->value());
instr->set_env(NULL);
- check_instr->InsertBefore(instr);
StoreInstanceFieldComp* store = new StoreInstanceFieldComp(
field,
comp->ArgumentAt(0)->value(),
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698