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

Unified Diff: runtime/vm/flow_graph_builder.cc

Issue 10832126: Store pointer instead of reference to LocalVariable in ast and flow graph. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 5 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
Index: runtime/vm/flow_graph_builder.cc
===================================================================
--- runtime/vm/flow_graph_builder.cc (revision 10207)
+++ runtime/vm/flow_graph_builder.cc (working copy)
@@ -206,11 +206,11 @@
}
-Computation* EffectGraphVisitor::BuildStoreLocal(
- const LocalVariable& local, Value* value) {
- if (local.is_captured()) {
+Computation* EffectGraphVisitor::BuildStoreLocal(const LocalVariable* local,
+ Value* value) {
+ if (local->is_captured()) {
intptr_t delta = owner()->context_level() -
- local.owner()->context_level();
+ local->owner()->context_level();
ASSERT(delta >= 0);
Value* context = Bind(new CurrentContextComp());
while (delta-- > 0) {
@@ -219,19 +219,19 @@
}
return new StoreVMFieldComp(
context,
- Context::variable_offset(local.index()),
+ Context::variable_offset(local->index()),
value,
- local.type());
+ local->type());
} else {
return new StoreLocalComp(local, value, owner()->context_level());
}
}
-Computation* EffectGraphVisitor::BuildLoadLocal(const LocalVariable& local) {
- if (local.is_captured()) {
+Computation* EffectGraphVisitor::BuildLoadLocal(const LocalVariable* local) {
+ if (local->is_captured()) {
intptr_t delta = owner()->context_level() -
- local.owner()->context_level();
+ local->owner()->context_level();
ASSERT(delta >= 0);
Value* context = Bind(new CurrentContextComp());
while (delta-- > 0) {
@@ -239,8 +239,8 @@
context, Context::parent_offset(), Type::ZoneHandle()));
}
return new LoadVMFieldComp(context,
- Context::variable_offset(local.index()),
- local.type());
+ Context::variable_offset(local->index()),
+ local->type());
} else {
return new LoadLocalComp(local, owner()->context_level());
}
@@ -248,14 +248,14 @@
// Stores current context into the 'variable'
-void EffectGraphVisitor::BuildStoreContext(const LocalVariable& variable) {
+void EffectGraphVisitor::BuildStoreContext(const LocalVariable* variable) {
Value* context = Bind(new CurrentContextComp());
Do(BuildStoreLocal(variable, context));
}
// Loads context saved in 'context_variable' into the current context.
-void EffectGraphVisitor::BuildLoadContext(const LocalVariable& variable) {
+void EffectGraphVisitor::BuildLoadContext(const LocalVariable* variable) {
Value* load_saved_context = Bind(BuildLoadLocal(variable));
Do(new StoreContextComp(load_saved_context));
}
@@ -374,7 +374,7 @@
ASSERT(current_context_level >= 0);
if (owner()->parsed_function().saved_context_var() != NULL) {
// CTX on entry was saved, but not linked as context parent.
- BuildLoadContext(*owner()->parsed_function().saved_context_var());
+ BuildLoadContext(owner()->parsed_function().saved_context_var());
} else {
while (current_context_level-- > 0) {
UnchainContext();
@@ -547,14 +547,14 @@
right_value,
constant_true));
for_right.Do(BuildStoreLocal(
- *owner()->parsed_function().expression_temp_var(),
+ owner()->parsed_function().expression_temp_var(),
compare));
if (node->kind() == Token::kAND) {
ValueGraphVisitor for_false(owner(), temp_index());
Value* constant_false = for_false.Bind(new ConstantVal(bool_false));
for_false.Do(BuildStoreLocal(
- *owner()->parsed_function().expression_temp_var(),
+ owner()->parsed_function().expression_temp_var(),
constant_false));
Join(for_test, for_right, for_false);
} else {
@@ -562,12 +562,12 @@
ValueGraphVisitor for_true(owner(), temp_index());
Value* constant_true = for_true.Bind(new ConstantVal(bool_true));
for_true.Do(BuildStoreLocal(
- *owner()->parsed_function().expression_temp_var(),
+ owner()->parsed_function().expression_temp_var(),
constant_true));
Join(for_test, for_true, for_right);
}
ReturnComputation(
- BuildLoadLocal(*owner()->parsed_function().expression_temp_var()));
+ BuildLoadLocal(owner()->parsed_function().expression_temp_var()));
return;
}
EffectGraphVisitor::VisitBinaryOpNode(node);
@@ -592,8 +592,8 @@
BuildInstantiatorTypeArguments(token_pos, NULL);
} else {
// Preserve instantiator.
- const LocalVariable& expr_temp =
- *owner()->parsed_function().expression_temp_var();
+ const LocalVariable* expr_temp =
+ owner()->parsed_function().expression_temp_var();
instantiator = Bind(BuildStoreLocal(expr_temp, instantiator));
Value* loaded = Bind(BuildLoadLocal(expr_temp));
instantiator_type_arguments =
@@ -887,17 +887,17 @@
node->true_expr()->Visit(&for_true);
ASSERT(for_true.is_open());
for_true.Do(BuildStoreLocal(
- *owner()->parsed_function().expression_temp_var(), for_true.value()));
+ owner()->parsed_function().expression_temp_var(), for_true.value()));
ValueGraphVisitor for_false(owner(), temp_index());
node->false_expr()->Visit(&for_false);
ASSERT(for_false.is_open());
for_false.Do(BuildStoreLocal(
- *owner()->parsed_function().expression_temp_var(), for_false.value()));
+ owner()->parsed_function().expression_temp_var(), for_false.value()));
Join(for_test, for_true, for_false);
ReturnComputation(
- BuildLoadLocal(*owner()->parsed_function().expression_temp_var()));
+ BuildLoadLocal(owner()->parsed_function().expression_temp_var()));
}
@@ -1412,7 +1412,7 @@
BuildPushArguments(*node->arguments(), arguments);
// Save context around the call.
- BuildStoreContext(*owner()->parsed_function().expression_temp_var());
+ BuildStoreContext(owner()->parsed_function().expression_temp_var());
return new ClosureCallComp(node, owner()->try_index(), arguments);
}
@@ -1420,14 +1420,14 @@
void EffectGraphVisitor::VisitClosureCallNode(ClosureCallNode* node) {
Do(BuildClosureCall(node));
// Restore context from saved location.
- BuildLoadContext(*owner()->parsed_function().expression_temp_var());
+ BuildLoadContext(owner()->parsed_function().expression_temp_var());
}
void ValueGraphVisitor::VisitClosureCallNode(ClosureCallNode* node) {
Value* result = Bind(BuildClosureCall(node));
// Restore context from temp.
- BuildLoadContext(*owner()->parsed_function().expression_temp_var());
+ BuildLoadContext(owner()->parsed_function().expression_temp_var());
ReturnValue(result);
}
@@ -1644,8 +1644,8 @@
// Use expression_temp_var and node->allocated_object_var() locals to keep
// intermediate results around (t1 and t2 above).
ASSERT(owner()->parsed_function().expression_temp_var() != NULL);
- const LocalVariable& t1 = *owner()->parsed_function().expression_temp_var();
- const LocalVariable& t2 = node->allocated_object_var();
+ const LocalVariable* t1 = owner()->parsed_function().expression_temp_var();
+ const LocalVariable* t2 = node->allocated_object_var();
Value* instantiator_type_arguments = BuildInstantiatorTypeArguments(
node->token_pos(), NULL);
ASSERT(instantiator_type_arguments->IsUse());
@@ -1737,7 +1737,7 @@
Value* value = NULL;
if (result_is_needed) {
value = Bind(
- BuildStoreLocal(*owner()->parsed_function().expression_temp_var(),
+ BuildStoreLocal(owner()->parsed_function().expression_temp_var(),
for_value.value()));
} else {
value = for_value.value();
@@ -1768,7 +1768,7 @@
node->field_name(),
arguments));
ReturnComputation(
- BuildLoadLocal(*owner()->parsed_function().expression_temp_var()));
+ BuildLoadLocal(owner()->parsed_function().expression_temp_var()));
}
@@ -1846,8 +1846,8 @@
if (FLAG_enable_type_checks) {
store_value = BuildAssignableValue(node->value()->token_pos(),
store_value,
- node->local().type(),
- node->local().name());
+ node->local()->type(),
+ node->local()->name());
}
Computation* store = BuildStoreLocal(node->local(), store_value);
ReturnComputation(store);
@@ -1970,7 +1970,7 @@
Value *array, *index, *value;
BuildStoreIndexedValues(node, &array, &index, &value);
Value* saved_value = Bind(
- BuildStoreLocal(*owner()->parsed_function().expression_temp_var(),
+ BuildStoreLocal(owner()->parsed_function().expression_temp_var(),
value));
Do(new StoreIndexedComp(node->token_pos(),
owner()->try_index(),
@@ -1978,7 +1978,7 @@
index,
saved_value));
ReturnComputation(
- BuildLoadLocal(*owner()->parsed_function().expression_temp_var()));
+ BuildLoadLocal(owner()->parsed_function().expression_temp_var()));
}
@@ -2021,7 +2021,7 @@
// save it in a pre-allocated variable and restore it on exit.
if (MustSaveRestoreContext(node)) {
Value* current_context = Bind(new CurrentContextComp());
- Do(BuildStoreLocal(*owner()->parsed_function().saved_context_var(),
+ Do(BuildStoreLocal(owner()->parsed_function().saved_context_var(),
current_context));
Value* null_context = Bind(new ConstantVal(Object::ZoneHandle()));
Do(new StoreContextComp(null_context));
@@ -2039,12 +2039,12 @@
int param_frame_index = (num_params == function.num_fixed_parameters()) ?
(1 + num_params) : ParsedFunction::kFirstLocalSlotIndex;
for (int pos = 0; pos < num_params; param_frame_index--, pos++) {
- const LocalVariable& parameter = *scope->VariableAt(pos);
- ASSERT(parameter.owner() == scope);
- if (parameter.is_captured()) {
+ const LocalVariable* parameter = scope->VariableAt(pos);
+ ASSERT(parameter->owner() == scope);
+ if (parameter->is_captured()) {
// Create a temporary local describing the original position.
const String& temp_name = String::ZoneHandle(String::Concat(
- parameter.name(), String::Handle(Symbols::New("-orig"))));
+ parameter->name(), String::Handle(Symbols::New("-orig"))));
LocalVariable* temp_local = new LocalVariable(
0, // Token index.
temp_name,
@@ -2052,13 +2052,13 @@
temp_local->set_index(param_frame_index);
// Copy parameter from local frame to current context.
- Value* load = Bind(BuildLoadLocal(*temp_local));
+ Value* load = Bind(BuildLoadLocal(temp_local));
Do(BuildStoreLocal(parameter, load));
// Write NULL to the source location to detect buggy accesses and
// allow GC of passed value if it gets overwritten by a new value in
// the function.
Value* null_constant = Bind(new ConstantVal(Object::ZoneHandle()));
- Do(BuildStoreLocal(*temp_local, null_constant));
+ Do(BuildStoreLocal(temp_local, null_constant));
}
}
}
@@ -2078,17 +2078,17 @@
pos = 1;
}
while (pos < num_params) {
- const LocalVariable& parameter = *scope->VariableAt(pos);
- ASSERT(parameter.owner() == scope);
- if (!CanSkipTypeCheck(parameter.token_pos(),
+ const LocalVariable* parameter = scope->VariableAt(pos);
+ ASSERT(parameter->owner() == scope);
+ if (!CanSkipTypeCheck(parameter->token_pos(),
NULL,
- parameter.type(),
- parameter.name())) {
+ parameter->type(),
+ parameter->name())) {
Value* load = Bind(BuildLoadLocal(parameter));
- Do(BuildAssertAssignable(parameter.token_pos(),
+ Do(BuildAssertAssignable(parameter->token_pos(),
load,
- parameter.type(),
- parameter.name()));
+ parameter->type(),
+ parameter->name()));
}
pos++;
}
@@ -2108,7 +2108,7 @@
if (is_open()) {
if (MustSaveRestoreContext(node)) {
ASSERT(num_context_variables > 0);
- BuildLoadContext(*owner()->parsed_function().saved_context_var());
+ BuildLoadContext(owner()->parsed_function().saved_context_var());
} else if (num_context_variables > 0) {
UnchainContext();
}
@@ -2590,7 +2590,7 @@
if ((as_bind != NULL) && as_bind->computation()->IsLoadLocal()) {
Computation* comp = as_bind->computation();
intptr_t index =
- comp->AsLoadLocal()->local().BitIndexIn(fixed_parameter_count);
+ comp->AsLoadLocal()->local()->BitIndexIn(fixed_parameter_count);
current->SetInputAt(i, CopyValue((*env)[index]));
}
if ((as_bind != NULL) && as_bind->computation()->IsStoreLocal()) {
@@ -2598,7 +2598,7 @@
// environment.
Computation* comp = as_bind->computation();
intptr_t index =
- comp->AsStoreLocal()->local().BitIndexIn(fixed_parameter_count);
+ comp->AsStoreLocal()->local()->BitIndexIn(fixed_parameter_count);
current->SetInputAt(i, CopyValue((*env)[index]));
}
}
@@ -2618,14 +2618,14 @@
if ((load != NULL) || (store != NULL)) {
intptr_t index;
if (store != NULL) {
- index = store->local().BitIndexIn(fixed_parameter_count);
+ index = store->local()->BitIndexIn(fixed_parameter_count);
// Update renaming environment.
(*env)[index] = store->value();
} else {
// The graph construction ensures we do not have an unused LoadLocal
// computation.
ASSERT(bind->is_used());
- index = load->local().BitIndexIn(fixed_parameter_count);
+ index = load->local()->BitIndexIn(fixed_parameter_count);
}
// Update expression stack and remove from graph.
if (bind->is_used()) {

Powered by Google App Engine
This is Rietveld 408576698