diff --git a/src/arm/lithium-arm.cc b/src/arm/lithium-arm.cc index 7c02a62c46..4ecea705cf 100644 --- a/src/arm/lithium-arm.cc +++ b/src/arm/lithium-arm.cc @@ -2435,8 +2435,7 @@ LInstruction* LChunkBuilder::DoArgumentsObject(HArgumentsObject* instr) { LInstruction* LChunkBuilder::DoCapturedObject(HCapturedObject* instr) { - HEnvironment* env = current_block_->last_environment(); - instr->ReplayEnvironment(env); + instr->ReplayEnvironment(current_block_->last_environment()); // There are no real uses of a captured object. return NULL; @@ -2484,20 +2483,7 @@ LInstruction* LChunkBuilder::DoIsConstructCallAndBranch( LInstruction* LChunkBuilder::DoSimulate(HSimulate* instr) { - HEnvironment* env = current_block_->last_environment(); - ASSERT(env != NULL); - - env->set_ast_id(instr->ast_id()); - - env->Drop(instr->pop_count()); - for (int i = instr->values()->length() - 1; i >= 0; --i) { - HValue* value = instr->values()->at(i); - if (instr->HasAssignedIndexAt(i)) { - env->Bind(instr->GetAssignedIndexAt(i), value); - } else { - env->Push(value); - } - } + instr->ReplayEnvironment(current_block_->last_environment()); // If there is an instruction pending deoptimization environment create a // lazy bailout instruction to capture the environment. diff --git a/src/hydrogen-instructions.cc b/src/hydrogen-instructions.cc index 7c419dc814..45e2578b4b 100644 --- a/src/hydrogen-instructions.cc +++ b/src/hydrogen-instructions.cc @@ -2289,6 +2289,21 @@ void HSimulate::PrintDataTo(StringStream* stream) { } +void HSimulate::ReplayEnvironment(HEnvironment* env) { + ASSERT(env != NULL); + env->set_ast_id(ast_id()); + env->Drop(pop_count()); + for (int i = values()->length() - 1; i >= 0; --i) { + HValue* value = values()->at(i); + if (HasAssignedIndexAt(i)) { + env->Bind(GetAssignedIndexAt(i), value); + } else { + env->Push(value); + } + } +} + + // Replay captured objects by replacing all captured objects with the // same capture id in the current and all outer environments. void HCapturedObject::ReplayEnvironment(HEnvironment* env) { diff --git a/src/hydrogen-instructions.h b/src/hydrogen-instructions.h index 47bd75806b..20c284c1d0 100644 --- a/src/hydrogen-instructions.h +++ b/src/hydrogen-instructions.h @@ -1676,6 +1676,9 @@ class HSimulate V8_FINAL : public HInstruction { void MergeWith(ZoneList* list); bool is_candidate_for_removal() { return removable_ == REMOVABLE_SIMULATE; } + // Replay effects of this instruction on the given environment. + void ReplayEnvironment(HEnvironment* env); + DECLARE_CONCRETE_INSTRUCTION(Simulate) #ifdef DEBUG diff --git a/src/ia32/lithium-ia32.cc b/src/ia32/lithium-ia32.cc index 2fdbb9858b..ba1abdc632 100644 --- a/src/ia32/lithium-ia32.cc +++ b/src/ia32/lithium-ia32.cc @@ -2564,8 +2564,7 @@ LInstruction* LChunkBuilder::DoArgumentsObject(HArgumentsObject* instr) { LInstruction* LChunkBuilder::DoCapturedObject(HCapturedObject* instr) { - HEnvironment* env = current_block_->last_environment(); - instr->ReplayEnvironment(env); + instr->ReplayEnvironment(current_block_->last_environment()); // There are no real uses of a captured object. return NULL; @@ -2615,20 +2614,7 @@ LInstruction* LChunkBuilder::DoIsConstructCallAndBranch( LInstruction* LChunkBuilder::DoSimulate(HSimulate* instr) { - HEnvironment* env = current_block_->last_environment(); - ASSERT(env != NULL); - - env->set_ast_id(instr->ast_id()); - - env->Drop(instr->pop_count()); - for (int i = instr->values()->length() - 1; i >= 0; --i) { - HValue* value = instr->values()->at(i); - if (instr->HasAssignedIndexAt(i)) { - env->Bind(instr->GetAssignedIndexAt(i), value); - } else { - env->Push(value); - } - } + instr->ReplayEnvironment(current_block_->last_environment()); // If there is an instruction pending deoptimization environment create a // lazy bailout instruction to capture the environment. diff --git a/src/mips/lithium-mips.cc b/src/mips/lithium-mips.cc index 8025d8ef5f..18e89ddd5c 100644 --- a/src/mips/lithium-mips.cc +++ b/src/mips/lithium-mips.cc @@ -2361,8 +2361,7 @@ LInstruction* LChunkBuilder::DoArgumentsObject(HArgumentsObject* instr) { LInstruction* LChunkBuilder::DoCapturedObject(HCapturedObject* instr) { - HEnvironment* env = current_block_->last_environment(); - instr->ReplayEnvironment(env); + instr->ReplayEnvironment(current_block_->last_environment()); // There are no real uses of a captured object. return NULL; @@ -2410,20 +2409,7 @@ LInstruction* LChunkBuilder::DoIsConstructCallAndBranch( LInstruction* LChunkBuilder::DoSimulate(HSimulate* instr) { - HEnvironment* env = current_block_->last_environment(); - ASSERT(env != NULL); - - env->set_ast_id(instr->ast_id()); - - env->Drop(instr->pop_count()); - for (int i = instr->values()->length() - 1; i >= 0; --i) { - HValue* value = instr->values()->at(i); - if (instr->HasAssignedIndexAt(i)) { - env->Bind(instr->GetAssignedIndexAt(i), value); - } else { - env->Push(value); - } - } + instr->ReplayEnvironment(current_block_->last_environment()); // If there is an instruction pending deoptimization environment create a // lazy bailout instruction to capture the environment. diff --git a/src/x64/lithium-x64.cc b/src/x64/lithium-x64.cc index 96fa71954e..31a06df082 100644 --- a/src/x64/lithium-x64.cc +++ b/src/x64/lithium-x64.cc @@ -2374,8 +2374,7 @@ LInstruction* LChunkBuilder::DoArgumentsObject(HArgumentsObject* instr) { LInstruction* LChunkBuilder::DoCapturedObject(HCapturedObject* instr) { - HEnvironment* env = current_block_->last_environment(); - instr->ReplayEnvironment(env); + instr->ReplayEnvironment(current_block_->last_environment()); // There are no real uses of a captured object. return NULL; @@ -2423,20 +2422,7 @@ LInstruction* LChunkBuilder::DoIsConstructCallAndBranch( LInstruction* LChunkBuilder::DoSimulate(HSimulate* instr) { - HEnvironment* env = current_block_->last_environment(); - ASSERT(env != NULL); - - env->set_ast_id(instr->ast_id()); - - env->Drop(instr->pop_count()); - for (int i = instr->values()->length() - 1; i >= 0; --i) { - HValue* value = instr->values()->at(i); - if (instr->HasAssignedIndexAt(i)) { - env->Bind(instr->GetAssignedIndexAt(i), value); - } else { - env->Push(value); - } - } + instr->ReplayEnvironment(current_block_->last_environment()); // If there is an instruction pending deoptimization environment create a // lazy bailout instruction to capture the environment.