Move stack check into AllocateStackSlots so the load delay can be

interleaved with other instructions.  Reorder the stack check
slightly to avoid some load delay. The end result is almost
imperceptible.
Review URL: http://codereview.chromium.org/181019

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@2784 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
erik.corry@gmail.com 2009-08-31 10:38:00 +00:00
parent 369214c159
commit fcf8293df2
2 changed files with 33 additions and 7 deletions

View File

@ -176,7 +176,8 @@ void CodeGenerator::GenCode(FunctionLiteral* fun) {
}
#endif
// Allocate space for locals and initialize them.
// Allocate space for locals and initialize them. This also checks
// for stack overflow.
frame_->AllocateStackSlots();
// Initialize the function return target after the locals are set
// up, because it needs the expected frame height from the frame.
@ -278,7 +279,6 @@ void CodeGenerator::GenCode(FunctionLiteral* fun) {
frame_->CallRuntime(Runtime::kTraceEnter, 0);
// Ignore the return value.
}
CheckStack();
// Compile the body of the function in a vanilla state. Don't
// bother compiling all the code if the scope has an illegal
@ -1111,9 +1111,18 @@ void CodeGenerator::CheckStack() {
if (FLAG_check_stack) {
Comment cmnt(masm_, "[ check stack");
__ LoadRoot(ip, Heap::kStackLimitRootIndex);
__ cmp(sp, Operand(ip));
// Put the lr setup instruction in the delay slot. The 'sizeof(Instr)' is
// added to the implicit 8 byte offset that always applies to operations
// with pc and gives a return address 12 bytes down.
masm_->add(lr, pc, Operand(sizeof(Instr)));
masm_->cmp(sp, Operand(ip));
StackCheckStub stub;
__ CallStub(&stub, lo); // Call the stub if lower.
// Call the stub if lower.
masm_->mov(pc,
Operand(reinterpret_cast<intptr_t>(stub.GetCode().location()),
RelocInfo::CODE_TARGET),
LeaveCC,
lo);
}
}

View File

@ -141,9 +141,26 @@ void VirtualFrame::AllocateStackSlots() {
Adjust(count);
// Initialize stack slots with 'undefined' value.
__ LoadRoot(ip, Heap::kUndefinedValueRootIndex);
for (int i = 0; i < count; i++) {
__ push(ip);
}
}
if (FLAG_check_stack) {
__ LoadRoot(r2, Heap::kStackLimitRootIndex);
}
for (int i = 0; i < count; i++) {
__ push(ip);
}
if (FLAG_check_stack) {
// Put the lr setup instruction in the delay slot. The 'sizeof(Instr)' is
// added to the implicit 8 byte offset that always applies to operations
// with pc and gives a return address 12 bytes down.
masm()->add(lr, pc, Operand(sizeof(Instr)));
masm()->cmp(sp, Operand(r2));
StackCheckStub stub;
// Call the stub if lower.
masm()->mov(pc,
Operand(reinterpret_cast<intptr_t>(stub.GetCode().location()),
RelocInfo::CODE_TARGET),
LeaveCC,
lo);
}
}