| Index: runtime/vm/flow_graph.cc
|
| diff --git a/runtime/vm/flow_graph.cc b/runtime/vm/flow_graph.cc
|
| index 23edb15bf1bfba2da0c1457c65ef197b6f383cd9..ea6442a241736c316570ab4b7c9ca4b0c604f415 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 (EnvironmentIterator 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 (EnvironmentIterator 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 (EnvironmentIterator 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());
|
| @@ -510,7 +512,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.
|
| @@ -543,7 +545,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.
|
|
|