Index: src/lithium-codegen.cc |
diff --git a/src/lithium-codegen.cc b/src/lithium-codegen.cc |
index 93ae3101a7779e50b21fe4e542334974bc75758e..1ee23947426d0ce60c69ca26f35098ae206d8b5f 100644 |
--- a/src/lithium-codegen.cc |
+++ b/src/lithium-codegen.cc |
@@ -124,18 +124,22 @@ bool LCodeGenBase::GenerateBody() { |
void LCodeGenBase::CheckEnvironmentUsage() { |
#ifdef DEBUG |
- bool live_block = true; |
+ bool dead_block = false; |
for (int i = 0; i < instructions_->length(); i++) { |
LInstruction* instr = instructions_->at(i); |
- if (instr->IsLabel()) live_block = !LLabel::cast(instr)->HasReplacement(); |
- if (live_block && |
- instr->hydrogen_value()->block()->IsReachable() && |
- instr->HasEnvironment() && |
- !instr->environment()->has_been_used()) { |
- FunctionLiteral* lit = info_->function(); |
- V8_Fatal(__FILE__, __LINE__, "unused environment in %s <@%d,#%d> %s\n", |
- lit == NULL ? "<UNKNOWN>" : lit->name()->ToCString().get(), |
- i, instr->hydrogen_value()->id(), instr->Mnemonic()); |
+ HValue* hval = instr->hydrogen_value(); |
+ if (instr->IsLabel()) dead_block = LLabel::cast(instr)->HasReplacement(); |
+ if (dead_block || !hval->block()->IsReachable()) continue; |
+ |
+ HInstruction* hinstr = HInstruction::cast(hval); |
+ if (!hinstr->CanDeoptimize() && instr->HasEnvironment()) { |
+ V8_Fatal(__FILE__, __LINE__, "CanDeoptimize is wrong for %s (%s)\n", |
+ hinstr->Mnemonic(), instr->Mnemonic()); |
+ } |
+ |
+ if (instr->HasEnvironment() && !instr->environment()->has_been_used()) { |
+ V8_Fatal(__FILE__, __LINE__, "unused environment for %s (%s)\n", |
+ hinstr->Mnemonic(), instr->Mnemonic()); |
} |
} |
#endif |