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

Unified Diff: runtime/vm/flow_graph.cc

Issue 10909168: Introduce nested deoptimization environments. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | runtime/vm/flow_graph_allocator.cc » ('j') | runtime/vm/intermediate_language.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/flow_graph.cc
diff --git a/runtime/vm/flow_graph.cc b/runtime/vm/flow_graph.cc
index 71c6c31ad2f070f2584d6c781551e7281c022cbb..583858919d4a855f43c83d7728ece5a2181f291f 100644
--- a/runtime/vm/flow_graph.cc
+++ b/runtime/vm/flow_graph.cc
@@ -94,8 +94,8 @@ static void ResetUseListsInInstruction(Instruction* instr) {
use->set_next_use(NULL);
}
if (instr->env() != NULL) {
- for (intptr_t i = 0; i < instr->env()->values().length(); ++i) {
- Value* use = instr->env()->values()[i];
+ for (Environment::DeepIterator it(instr->env()); !it.Done(); it.Advance()) {
+ Value* use = it.CurrentValue();
use->set_instruction(NULL);
use->set_use_index(-1);
use->set_next_use(NULL);
@@ -109,8 +109,8 @@ bool FlowGraph::ResetUseLists() {
ResetUseListsInInstruction(graph_entry_->constant_null());
// Reset definitions referenced from the start environment.
- for (intptr_t i = 0; i < graph_entry_->start_env()->values().length(); ++i) {
- Value* env_use = graph_entry_->start_env()->values()[i];
+ for (intptr_t i = 0; i < graph_entry_->start_env()->Length(); ++i) {
+ Value* env_use = graph_entry_->start_env()->ValueAt(i);
ResetUseListsInInstruction(env_use->definition());
}
@@ -140,11 +140,11 @@ static void ValidateUseListsInInstruction(Instruction* instr) {
ASSERT(use->use_index() == i);
ASSERT(1 == MembershipCount(use, use->definition()->input_use_list()));
}
- Environment* env = instr->env();
- if (env != NULL) {
- for (intptr_t i = 0; i < env->values().length(); ++i) {
- Value* use = env->values()[i];
- ASSERT(use->use_index() == i);
+ if (instr->env() != NULL) {
+ intptr_t use_index = 0;
+ for (Environment::DeepIterator it(instr->env()); !it.Done(); it.Advance()) {
+ Value* use = it.CurrentValue();
+ ASSERT(use->use_index() == use_index++);
ASSERT(1 == MembershipCount(use, use->definition()->env_use_list()));
}
}
@@ -160,7 +160,8 @@ static void ValidateUseListsInInstruction(Instruction* instr) {
use != NULL;
use = use->next_use()) {
ASSERT(defn == use->definition());
- ASSERT(use == use->instruction()->env()->values()[use->use_index()]);
+ ASSERT(use ==
+ use->instruction()->env()->ValueAtUseIndex(use->use_index()));
}
}
}
@@ -171,8 +172,8 @@ bool FlowGraph::ValidateUseLists() {
ValidateUseListsInInstruction(graph_entry_->constant_null());
// Validate definitions referenced from the start environment.
- for (intptr_t i = 0; i < graph_entry_->start_env()->values().length(); ++i) {
- Value* env_use = graph_entry_->start_env()->values()[i];
+ for (intptr_t i = 0; i < graph_entry_->start_env()->Length(); ++i) {
+ Value* env_use = graph_entry_->start_env()->ValueAt(i);
ValidateUseListsInInstruction(env_use->definition());
}
@@ -223,14 +224,15 @@ static void RecordInputUses(Instruction* instr) {
static void RecordEnvUses(Instruction* instr) {
ASSERT(instr != NULL);
if (instr->env() == NULL) return;
- for (intptr_t i = 0; i < instr->env()->values().length(); ++i) {
- Value* use = instr->env()->values()[i];
+ intptr_t use_index = 0;
+ for (Environment::DeepIterator it(instr->env()); !it.Done(); it.Advance()) {
+ Value* use = it.CurrentValue();
DEBUG_ASSERT(use->instruction() == NULL);
DEBUG_ASSERT(use->use_index() == -1);
DEBUG_ASSERT(use->next_use() == NULL);
DEBUG_ASSERT(0 == MembershipCount(use, use->definition()->env_use_list()));
use->set_instruction(instr);
- use->set_use_index(i);
+ use->set_use_index(use_index++);
use->AddToEnvUseList();
}
}
@@ -286,8 +288,8 @@ void FlowGraph::ComputeUseLists() {
DEBUG_ASSERT(ResetUseLists());
// Clear global constants and definitions in the start environment.
ClearUseLists(graph_entry_->constant_null());
- for (intptr_t i = 0; i < graph_entry_->start_env()->values().length(); ++i) {
- ClearUseLists(graph_entry_->start_env()->values()[i]->definition());
+ for (intptr_t i = 0; i < graph_entry_->start_env()->Length(); ++i) {
+ ClearUseLists(graph_entry_->start_env()->ValueAt(i)->definition());
}
ComputeUseListsRecursive(graph_entry_);
DEBUG_ASSERT(ValidateUseLists());
@@ -512,7 +514,7 @@ void FlowGraph::Rename(GrowableArray<PhiInstr*>* live_phis) {
start_env.Add(graph_entry_->constant_null());
}
graph_entry_->set_start_env(
- new Environment(start_env, num_non_copied_params_));
+ Environment::From(start_env, num_non_copied_params_, NULL));
BlockEntryInstr* normal_entry = graph_entry_->SuccessorAt(0);
ASSERT(normal_entry != NULL); // Must have entry.
@@ -545,7 +547,8 @@ void FlowGraph::RenameRecursive(BlockEntryInstr* block_entry,
// Attach current environment to the instruction. First, each instruction
// gets a full copy of the environment. Later we optimize this by
// eliminating unnecessary environments.
- current->set_env(new Environment(*env, num_non_copied_params_));
+ current->set_env(
+ Environment::From(*env, num_non_copied_params_, NULL));
// 2a. Handle uses:
// Update expression stack environment for each use.
« no previous file with comments | « no previous file | runtime/vm/flow_graph_allocator.cc » ('j') | runtime/vm/intermediate_language.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698