Revision: 10118
Author: [email protected]
Date: Thu Dec 1 01:54:05 2011
Log: Simplify stack check instruction in Crankshaft.
So far we had two types of stack checks: one used for function entries
and one used at loop back edges which uses a deferred code object to
avoid spilling of registers in the loop.
After refactoring lazy deoptimization the first stack check can also
use deferred code. This change removes the first type of stack check
instruction in Crankshaft and uses a deferred stack check in all
places.
Review URL: http://codereview.chromium.org/8775002
http://code.google.com/p/v8/source/detail?r=10118
Modified:
/branches/bleeding_edge/src/arm/lithium-arm.cc
/branches/bleeding_edge/src/arm/lithium-codegen-arm.cc
/branches/bleeding_edge/src/hydrogen-instructions.h
/branches/bleeding_edge/src/hydrogen.cc
/branches/bleeding_edge/src/ia32/lithium-codegen-ia32.cc
/branches/bleeding_edge/src/ia32/lithium-ia32.cc
/branches/bleeding_edge/src/ia32/lithium-ia32.h
/branches/bleeding_edge/src/x64/lithium-codegen-x64.cc
/branches/bleeding_edge/src/x64/lithium-x64.cc
=======================================
--- /branches/bleeding_edge/src/arm/lithium-arm.cc Thu Nov 24 05:42:52 2011
+++ /branches/bleeding_edge/src/arm/lithium-arm.cc Thu Dec 1 01:54:05 2011
@@ -2202,12 +2202,7 @@
LInstruction* LChunkBuilder::DoStackCheck(HStackCheck* instr) {
- if (instr->is_function_entry()) {
- return MarkAsCall(new LStackCheck, instr);
- } else {
- ASSERT(instr->is_backwards_branch());
- return AssignEnvironment(AssignPointerMap(new LStackCheck));
- }
+ return AssignEnvironment(AssignPointerMap(new LStackCheck));
}
=======================================
--- /branches/bleeding_edge/src/arm/lithium-codegen-arm.cc Tue Nov 29
04:39:28 2011
+++ /branches/bleeding_edge/src/arm/lithium-codegen-arm.cc Thu Dec 1
01:54:05 2011
@@ -4649,38 +4649,22 @@
LStackCheck* instr_;
};
- ASSERT(instr->HasEnvironment());
- LEnvironment* env = instr->environment();
+ DeferredStackCheck* deferred_stack_check =
+ new DeferredStackCheck(this, instr);
+ __ LoadRoot(ip, Heap::kStackLimitRootIndex);
+ __ cmp(sp, Operand(ip));
+ __ b(lo, deferred_stack_check->entry());
+ EnsureSpaceForLazyDeopt();
+ __ bind(instr->done_label());
+ deferred_stack_check->SetExit(instr->done_label());
// There is no LLazyBailout instruction for stack-checks. We have to
// prepare for lazy deoptimization explicitly here.
- if (instr->hydrogen()->is_function_entry()) {
- // Perform stack overflow check.
- Label done;
- __ LoadRoot(ip, Heap::kStackLimitRootIndex);
- __ cmp(sp, Operand(ip));
- __ b(hs, &done);
- 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);
- __ LoadRoot(ip, Heap::kStackLimitRootIndex);
- __ cmp(sp, Operand(ip));
- __ b(lo, 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.
- }
+ 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.
}
=======================================
--- /branches/bleeding_edge/src/hydrogen-instructions.h Tue Nov 29 02:56:11
2011
+++ /branches/bleeding_edge/src/hydrogen-instructions.h Thu Dec 1 01:54:05
2011
@@ -1271,12 +1271,7 @@
class HStackCheck: public HTemplateInstruction<1> {
public:
- enum Type {
- kFunctionEntry,
- kBackwardsBranch
- };
-
- HStackCheck(HValue* context, Type type) : type_(type) {
+ explicit HStackCheck(HValue* context) {
SetOperandAt(0, context);
}
@@ -1293,14 +1288,8 @@
DeleteFromGraph();
}
}
-
- bool is_function_entry() { return type_ == kFunctionEntry; }
- bool is_backwards_branch() { return type_ == kBackwardsBranch; }
DECLARE_CONCRETE_INSTRUCTION(StackCheck)
-
- private:
- Type type_;
};
=======================================
--- /branches/bleeding_edge/src/hydrogen.cc Fri Nov 25 05:15:31 2011
+++ /branches/bleeding_edge/src/hydrogen.cc Thu Dec 1 01:54:05 2011
@@ -2333,8 +2333,7 @@
AddSimulate(AstNode::kDeclarationsId);
HValue* context = environment()->LookupContext();
- AddInstruction(
- new(zone()) HStackCheck(context, HStackCheck::kFunctionEntry));
+ AddInstruction(new(zone()) HStackCheck(context));
VisitStatements(info()->function()->body());
if (HasStackOverflow()) return NULL;
@@ -2922,8 +2921,7 @@
BreakAndContinueScope push(break_info, this);
AddSimulate(stmt->StackCheckId());
HValue* context = environment()->LookupContext();
- HStackCheck* stack_check =
- new(zone()) HStackCheck(context, HStackCheck::kBackwardsBranch);
+ HStackCheck* stack_check = new(zone()) HStackCheck(context);
AddInstruction(stack_check);
ASSERT(loop_entry->IsLoopHeader());
loop_entry->loop_information()->set_stack_check(stack_check);
=======================================
--- /branches/bleeding_edge/src/ia32/lithium-codegen-ia32.cc Tue Nov 29
04:39:28 2011
+++ /branches/bleeding_edge/src/ia32/lithium-codegen-ia32.cc Thu Dec 1
01:54:05 2011
@@ -4554,43 +4554,23 @@
LStackCheck* instr_;
};
- ASSERT(instr->HasEnvironment());
- LEnvironment* env = instr->environment();
+ 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());
// There is no LLazyBailout instruction for stack-checks. We have to
// prepare for lazy deoptimization explicitly here.
- 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.
- }
+ 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.
}
=======================================
--- /branches/bleeding_edge/src/ia32/lithium-ia32.cc Thu Nov 24 05:42:52
2011
+++ /branches/bleeding_edge/src/ia32/lithium-ia32.cc Thu Dec 1 01:54:05
2011
@@ -2328,15 +2328,9 @@
LInstruction* LChunkBuilder::DoStackCheck(HStackCheck* instr) {
- if (instr->is_function_entry()) {
- LOperand* context = UseFixed(instr->context(), esi);
- return MarkAsCall(new(zone()) LStackCheck(context), instr);
- } else {
- ASSERT(instr->is_backwards_branch());
- LOperand* context = UseAny(instr->context());
- return AssignEnvironment(
- AssignPointerMap(new(zone()) LStackCheck(context)));
- }
+ LOperand* context = UseAny(instr->context());
+ return AssignEnvironment(
+ AssignPointerMap(new(zone()) LStackCheck(context)));
}
=======================================
--- /branches/bleeding_edge/src/ia32/lithium-ia32.h Thu Nov 24 07:17:04 2011
+++ /branches/bleeding_edge/src/ia32/lithium-ia32.h Thu Dec 1 01:54:05 2011
@@ -227,7 +227,6 @@
void set_pointer_map(LPointerMap* p) { pointer_map_.set(p); }
LPointerMap* pointer_map() const { return pointer_map_.get(); }
bool HasPointerMap() const { return pointer_map_.is_set(); }
-
void set_hydrogen_value(HValue* value) { hydrogen_value_ = value; }
HValue* hydrogen_value() const { return hydrogen_value_; }
=======================================
--- /branches/bleeding_edge/src/x64/lithium-codegen-x64.cc Tue Nov 29
04:39:28 2011
+++ /branches/bleeding_edge/src/x64/lithium-codegen-x64.cc Thu Dec 1
01:54:05 2011
@@ -4261,36 +4261,21 @@
LStackCheck* instr_;
};
- ASSERT(instr->HasEnvironment());
- LEnvironment* env = instr->environment();
+ DeferredStackCheck* deferred_stack_check =
+ new DeferredStackCheck(this, instr);
+ __ CompareRoot(rsp, Heap::kStackLimitRootIndex);
+ __ j(below, deferred_stack_check->entry());
+ EnsureSpaceForLazyDeopt();
+ __ bind(instr->done_label());
+ deferred_stack_check->SetExit(instr->done_label());
// There is no LLazyBailout instruction for stack-checks. We have to
// prepare for lazy deoptimization explicitly here.
- 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);
- 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);
- __ CompareRoot(rsp, Heap::kStackLimitRootIndex);
- __ 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.
- }
+ 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.
}
=======================================
--- /branches/bleeding_edge/src/x64/lithium-x64.cc Thu Nov 24 05:42:52 2011
+++ /branches/bleeding_edge/src/x64/lithium-x64.cc Thu Dec 1 01:54:05 2011
@@ -2203,12 +2203,7 @@
LInstruction* LChunkBuilder::DoStackCheck(HStackCheck* instr) {
- if (instr->is_function_entry()) {
- return MarkAsCall(new LStackCheck, instr);
- } else {
- ASSERT(instr->is_backwards_branch());
- return AssignEnvironment(AssignPointerMap(new LStackCheck));
- }
+ return AssignEnvironment(AssignPointerMap(new LStackCheck));
}
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev