Factor out HSimulate::ReplayEnvironment.

R=titzer@chromium.org

Review URL: https://codereview.chromium.org/23005027

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@16340 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent c7e262dc
...@@ -2435,8 +2435,7 @@ LInstruction* LChunkBuilder::DoArgumentsObject(HArgumentsObject* instr) { ...@@ -2435,8 +2435,7 @@ LInstruction* LChunkBuilder::DoArgumentsObject(HArgumentsObject* instr) {
LInstruction* LChunkBuilder::DoCapturedObject(HCapturedObject* instr) { LInstruction* LChunkBuilder::DoCapturedObject(HCapturedObject* instr) {
HEnvironment* env = current_block_->last_environment(); instr->ReplayEnvironment(current_block_->last_environment());
instr->ReplayEnvironment(env);
// There are no real uses of a captured object. // There are no real uses of a captured object.
return NULL; return NULL;
...@@ -2484,20 +2483,7 @@ LInstruction* LChunkBuilder::DoIsConstructCallAndBranch( ...@@ -2484,20 +2483,7 @@ LInstruction* LChunkBuilder::DoIsConstructCallAndBranch(
LInstruction* LChunkBuilder::DoSimulate(HSimulate* instr) { LInstruction* LChunkBuilder::DoSimulate(HSimulate* instr) {
HEnvironment* env = current_block_->last_environment(); instr->ReplayEnvironment(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);
}
}
// If there is an instruction pending deoptimization environment create a // If there is an instruction pending deoptimization environment create a
// lazy bailout instruction to capture the environment. // lazy bailout instruction to capture the environment.
......
...@@ -2289,6 +2289,21 @@ void HSimulate::PrintDataTo(StringStream* stream) { ...@@ -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 // Replay captured objects by replacing all captured objects with the
// same capture id in the current and all outer environments. // same capture id in the current and all outer environments.
void HCapturedObject::ReplayEnvironment(HEnvironment* env) { void HCapturedObject::ReplayEnvironment(HEnvironment* env) {
......
...@@ -1676,6 +1676,9 @@ class HSimulate V8_FINAL : public HInstruction { ...@@ -1676,6 +1676,9 @@ class HSimulate V8_FINAL : public HInstruction {
void MergeWith(ZoneList<HSimulate*>* list); void MergeWith(ZoneList<HSimulate*>* list);
bool is_candidate_for_removal() { return removable_ == REMOVABLE_SIMULATE; } 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) DECLARE_CONCRETE_INSTRUCTION(Simulate)
#ifdef DEBUG #ifdef DEBUG
......
...@@ -2564,8 +2564,7 @@ LInstruction* LChunkBuilder::DoArgumentsObject(HArgumentsObject* instr) { ...@@ -2564,8 +2564,7 @@ LInstruction* LChunkBuilder::DoArgumentsObject(HArgumentsObject* instr) {
LInstruction* LChunkBuilder::DoCapturedObject(HCapturedObject* instr) { LInstruction* LChunkBuilder::DoCapturedObject(HCapturedObject* instr) {
HEnvironment* env = current_block_->last_environment(); instr->ReplayEnvironment(current_block_->last_environment());
instr->ReplayEnvironment(env);
// There are no real uses of a captured object. // There are no real uses of a captured object.
return NULL; return NULL;
...@@ -2615,20 +2614,7 @@ LInstruction* LChunkBuilder::DoIsConstructCallAndBranch( ...@@ -2615,20 +2614,7 @@ LInstruction* LChunkBuilder::DoIsConstructCallAndBranch(
LInstruction* LChunkBuilder::DoSimulate(HSimulate* instr) { LInstruction* LChunkBuilder::DoSimulate(HSimulate* instr) {
HEnvironment* env = current_block_->last_environment(); instr->ReplayEnvironment(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);
}
}
// If there is an instruction pending deoptimization environment create a // If there is an instruction pending deoptimization environment create a
// lazy bailout instruction to capture the environment. // lazy bailout instruction to capture the environment.
......
...@@ -2361,8 +2361,7 @@ LInstruction* LChunkBuilder::DoArgumentsObject(HArgumentsObject* instr) { ...@@ -2361,8 +2361,7 @@ LInstruction* LChunkBuilder::DoArgumentsObject(HArgumentsObject* instr) {
LInstruction* LChunkBuilder::DoCapturedObject(HCapturedObject* instr) { LInstruction* LChunkBuilder::DoCapturedObject(HCapturedObject* instr) {
HEnvironment* env = current_block_->last_environment(); instr->ReplayEnvironment(current_block_->last_environment());
instr->ReplayEnvironment(env);
// There are no real uses of a captured object. // There are no real uses of a captured object.
return NULL; return NULL;
...@@ -2410,20 +2409,7 @@ LInstruction* LChunkBuilder::DoIsConstructCallAndBranch( ...@@ -2410,20 +2409,7 @@ LInstruction* LChunkBuilder::DoIsConstructCallAndBranch(
LInstruction* LChunkBuilder::DoSimulate(HSimulate* instr) { LInstruction* LChunkBuilder::DoSimulate(HSimulate* instr) {
HEnvironment* env = current_block_->last_environment(); instr->ReplayEnvironment(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);
}
}
// If there is an instruction pending deoptimization environment create a // If there is an instruction pending deoptimization environment create a
// lazy bailout instruction to capture the environment. // lazy bailout instruction to capture the environment.
......
...@@ -2374,8 +2374,7 @@ LInstruction* LChunkBuilder::DoArgumentsObject(HArgumentsObject* instr) { ...@@ -2374,8 +2374,7 @@ LInstruction* LChunkBuilder::DoArgumentsObject(HArgumentsObject* instr) {
LInstruction* LChunkBuilder::DoCapturedObject(HCapturedObject* instr) { LInstruction* LChunkBuilder::DoCapturedObject(HCapturedObject* instr) {
HEnvironment* env = current_block_->last_environment(); instr->ReplayEnvironment(current_block_->last_environment());
instr->ReplayEnvironment(env);
// There are no real uses of a captured object. // There are no real uses of a captured object.
return NULL; return NULL;
...@@ -2423,20 +2422,7 @@ LInstruction* LChunkBuilder::DoIsConstructCallAndBranch( ...@@ -2423,20 +2422,7 @@ LInstruction* LChunkBuilder::DoIsConstructCallAndBranch(
LInstruction* LChunkBuilder::DoSimulate(HSimulate* instr) { LInstruction* LChunkBuilder::DoSimulate(HSimulate* instr) {
HEnvironment* env = current_block_->last_environment(); instr->ReplayEnvironment(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);
}
}
// If there is an instruction pending deoptimization environment create a // If there is an instruction pending deoptimization environment create a
// lazy bailout instruction to capture the environment. // lazy bailout instruction to capture the environment.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment