Index: src/x64/lithium-codegen-x64.cc |
diff --git a/src/x64/lithium-codegen-x64.cc b/src/x64/lithium-codegen-x64.cc |
index 3a621823e5a407f444f594a8066da9cf668895a6..f83fdc24c7438c7b415b7bd712aed480cbfd97d7 100644 |
--- a/src/x64/lithium-codegen-x64.cc |
+++ b/src/x64/lithium-codegen-x64.cc |
@@ -1425,44 +1425,17 @@ void LCodeGen::DoBranch(LBranch* instr) { |
} |
-void LCodeGen::EmitGoto(int block, LDeferredCode* deferred_stack_check) { |
+void LCodeGen::EmitGoto(int block) { |
block = chunk_->LookupDestination(block); |
int next_block = GetNextEmittedBlock(current_block_); |
if (block != next_block) { |
- // Perform stack overflow check if this goto needs it before jumping. |
- if (deferred_stack_check != NULL) { |
- __ CompareRoot(rsp, Heap::kStackLimitRootIndex); |
- __ j(above_equal, chunk_->GetAssemblyLabel(block)); |
- __ jmp(deferred_stack_check->entry()); |
- deferred_stack_check->SetExit(chunk_->GetAssemblyLabel(block)); |
- } else { |
- __ jmp(chunk_->GetAssemblyLabel(block)); |
- } |
+ __ jmp(chunk_->GetAssemblyLabel(block)); |
} |
} |
-void LCodeGen::DoDeferredStackCheck(LGoto* instr) { |
- PushSafepointRegistersScope scope(this); |
- CallRuntimeFromDeferred(Runtime::kStackGuard, 0, instr); |
-} |
- |
- |
void LCodeGen::DoGoto(LGoto* instr) { |
- class DeferredStackCheck: public LDeferredCode { |
- public: |
- DeferredStackCheck(LCodeGen* codegen, LGoto* instr) |
- : LDeferredCode(codegen), instr_(instr) { } |
- virtual void Generate() { codegen()->DoDeferredStackCheck(instr_); } |
- private: |
- LGoto* instr_; |
- }; |
- |
- DeferredStackCheck* deferred = NULL; |
- if (instr->include_stack_check()) { |
- deferred = new DeferredStackCheck(this, instr); |
- } |
- EmitGoto(instr->block_id(), deferred); |
+ EmitGoto(instr->block_id()); |
} |
@@ -4290,15 +4263,40 @@ void LCodeGen::DoIn(LIn* instr) { |
} |
+void LCodeGen::DoDeferredStackCheck(LStackCheck* instr) { |
+ PushSafepointRegistersScope scope(this); |
+ CallRuntimeFromDeferred(Runtime::kStackGuard, 0, instr); |
+} |
+ |
+ |
void LCodeGen::DoStackCheck(LStackCheck* instr) { |
- // Perform stack overflow check. |
- Label done; |
- __ CompareRoot(rsp, Heap::kStackLimitRootIndex); |
- __ j(above_equal, &done, Label::kNear); |
+ class DeferredStackCheck: public LDeferredCode { |
+ public: |
+ DeferredStackCheck(LCodeGen* codegen, LStackCheck* instr) |
+ : LDeferredCode(codegen), instr_(instr) { } |
+ virtual void Generate() { codegen()->DoDeferredStackCheck(instr_); } |
+ private: |
+ LStackCheck* instr_; |
+ }; |
- StackCheckStub stub; |
- CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr); |
- __ bind(&done); |
+ if (instr->hydrogen()->is_function_entry()) { |
+ // Perform stack overflow check. |
+ Label done; |
+ __ CompareRoot(rsp, Heap::kStackLimitRootIndex); |
+ __ j(above_equal, &done, Label::kNear); |
+ StackCheckStub stub; |
+ CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr); |
+ __ bind(&done); |
+ } 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); |
+ __ CompareRoot(rsp, Heap::kStackLimitRootIndex); |
+ __ j(below, deferred_stack_check->entry()); |
+ __ bind(instr->done_label()); |
+ deferred_stack_check->SetExit(instr->done_label()); |
+ } |
} |