Index: src/ia32/lithium-codegen-ia32.cc |
=================================================================== |
--- src/ia32/lithium-codegen-ia32.cc (revision 10131) |
+++ src/ia32/lithium-codegen-ia32.cc (working copy) |
@@ -4554,23 +4554,43 @@ |
LStackCheck* instr_; |
}; |
- DeferredStackCheck* deferred_stack_check = |
- new DeferredStackCheck(this, instr); |
- ExternalReference stack_limit = |
- ExternalReference::address_of_stack_limit(isolate()); |
- __ cmp(esp, Operand::StaticVariable(stack_limit)); |
- __ j(below, deferred_stack_check->entry()); |
- EnsureSpaceForLazyDeopt(); |
- __ bind(instr->done_label()); |
- deferred_stack_check->SetExit(instr->done_label()); |
+ ASSERT(instr->HasEnvironment()); |
+ LEnvironment* env = instr->environment(); |
// There is no LLazyBailout instruction for stack-checks. We have to |
// prepare for lazy deoptimization explicitly here. |
- ASSERT(instr->HasEnvironment()); |
- LEnvironment* env = instr->environment(); |
- RegisterEnvironmentForDeoptimization(env, Safepoint::kLazyDeopt); |
- // Don't record a deoptimization index for the safepoint here. |
- // This will be done explicitly when emitting call and the safepoint in |
- // the deferred code. |
+ if (instr->hydrogen()->is_function_entry()) { |
+ // Perform stack overflow check. |
+ Label done; |
+ ExternalReference stack_limit = |
+ ExternalReference::address_of_stack_limit(isolate()); |
+ __ cmp(esp, Operand::StaticVariable(stack_limit)); |
+ __ j(above_equal, &done, Label::kNear); |
+ |
+ ASSERT(instr->context()->IsRegister()); |
+ ASSERT(ToRegister(instr->context()).is(esi)); |
+ StackCheckStub stub; |
+ CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr); |
+ EnsureSpaceForLazyDeopt(); |
+ __ bind(&done); |
+ RegisterEnvironmentForDeoptimization(env, Safepoint::kLazyDeopt); |
+ safepoints_.RecordLazyDeoptimizationIndex(env->deoptimization_index()); |
+ } else { |
+ ASSERT(instr->hydrogen()->is_backwards_branch()); |
+ // Perform stack overflow check if this goto needs it before jumping. |
+ DeferredStackCheck* deferred_stack_check = |
+ new DeferredStackCheck(this, instr); |
+ ExternalReference stack_limit = |
+ ExternalReference::address_of_stack_limit(isolate()); |
+ __ cmp(esp, Operand::StaticVariable(stack_limit)); |
+ __ j(below, deferred_stack_check->entry()); |
+ EnsureSpaceForLazyDeopt(); |
+ __ bind(instr->done_label()); |
+ deferred_stack_check->SetExit(instr->done_label()); |
+ RegisterEnvironmentForDeoptimization(env, Safepoint::kLazyDeopt); |
+ // Don't record a deoptimization index for the safepoint here. |
+ // This will be done explicitly when emitting call and the safepoint in |
+ // the deferred code. |
+ } |
} |