Commit df38e6f9 authored by rmcilroy@chromium.org's avatar rmcilroy@chromium.org

Replace hard-coded stack frame size literals with StandardFrameConstants::kFixedFrameSizeFromFp

R=ulan@chromium.org

Review URL: https://codereview.chromium.org/60763006

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@17925 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 2b1aeec5
......@@ -844,7 +844,7 @@ void Builtins::Generate_MarkCodeAsExecutedOnce(MacroAssembler* masm) {
// Perform prologue operations usually performed by the young code stub.
__ stm(db_w, sp, r1.bit() | cp.bit() | fp.bit() | lr.bit());
__ add(fp, sp, Operand(2 * kPointerSize));
__ add(fp, sp, Operand(StandardFrameConstants::kFixedFrameSizeFromFp));
// Jump to point after the code-age stub.
__ add(r0, r0, Operand(kNoCodeAgeSequenceLength * Assembler::kInstrSize));
......@@ -1177,8 +1177,10 @@ void Builtins::Generate_FunctionCall(MacroAssembler* masm) {
void Builtins::Generate_FunctionApply(MacroAssembler* masm) {
const int kIndexOffset = -5 * kPointerSize;
const int kLimitOffset = -4 * kPointerSize;
const int kIndexOffset =
StandardFrameConstants::kExpressionsOffset - (2 * kPointerSize);
const int kLimitOffset =
StandardFrameConstants::kExpressionsOffset - (1 * kPointerSize);
const int kArgsOffset = 2 * kPointerSize;
const int kRecvOffset = 3 * kPointerSize;
const int kFunctionOffset = 4 * kPointerSize;
......@@ -1341,7 +1343,8 @@ static void EnterArgumentsAdaptorFrame(MacroAssembler* masm) {
__ SmiTag(r0);
__ mov(r4, Operand(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR)));
__ stm(db_w, sp, r0.bit() | r1.bit() | r4.bit() | fp.bit() | lr.bit());
__ add(fp, sp, Operand(3 * kPointerSize));
__ add(fp, sp,
Operand(StandardFrameConstants::kFixedFrameSizeFromFp + kPointerSize));
}
......@@ -1351,7 +1354,8 @@ static void LeaveArgumentsAdaptorFrame(MacroAssembler* masm) {
// -----------------------------------
// Get the number of arguments passed (as a smi), tear down the frame and
// then tear down the parameters.
__ ldr(r1, MemOperand(fp, -3 * kPointerSize));
__ ldr(r1, MemOperand(fp, -(StandardFrameConstants::kFixedFrameSizeFromFp +
kPointerSize)));
__ mov(sp, fp);
__ ldm(ia_w, sp, fp.bit() | lr.bit());
__ add(sp, sp, Operand::PointerOffsetFromSmiKey(r1));
......@@ -1438,7 +1442,9 @@ void Builtins::Generate_ArgumentsAdaptorTrampoline(MacroAssembler* masm) {
// r3: code entry to call
__ LoadRoot(ip, Heap::kUndefinedValueRootIndex);
__ sub(r2, fp, Operand(r2, LSL, kPointerSizeLog2));
__ sub(r2, r2, Operand(4 * kPointerSize)); // Adjust for frame.
// Adjust for frame.
__ sub(r2, r2, Operand(StandardFrameConstants::kFixedFrameSizeFromFp +
2 * kPointerSize));
Label fill;
__ bind(&fill);
......
......@@ -851,7 +851,8 @@ static byte* GetNoCodeAgeSequence(uint32_t* length) {
PredictableCodeSizeScope scope(patcher.masm(), *length);
patcher.masm()->stm(db_w, sp, r1.bit() | cp.bit() | fp.bit() | lr.bit());
patcher.masm()->nop(ip.code());
patcher.masm()->add(fp, sp, Operand(2 * kPointerSize));
patcher.masm()->add(fp, sp,
Operand(StandardFrameConstants::kFixedFrameSizeFromFp));
initialized = true;
}
return byte_sequence;
......
......@@ -102,7 +102,8 @@ const int kNumSafepointSavedRegisters = kNumJSCallerSaved + kNumCalleeSaved;
class EntryFrameConstants : public AllStatic {
public:
static const int kCallerFPOffset = -3 * kPointerSize;
static const int kCallerFPOffset =
-(StandardFrameConstants::kFixedFrameSizeFromFp + kPointerSize);
};
......
......@@ -260,7 +260,7 @@ bool LCodeGen::GenerateDeferredCode() {
__ stm(db_w, sp, cp.bit() | fp.bit() | lr.bit());
__ mov(scratch0(), Operand(Smi::FromInt(StackFrame::STUB)));
__ push(scratch0());
__ add(fp, sp, Operand(2 * kPointerSize));
__ add(fp, sp, Operand(StandardFrameConstants::kFixedFrameSizeFromFp));
Comment(";;; Deferred code");
}
code->Generate();
......@@ -325,7 +325,7 @@ bool LCodeGen::GenerateDeoptJumpTable() {
ASSERT(info()->IsStub());
__ mov(scratch0(), Operand(Smi::FromInt(StackFrame::STUB)));
__ push(scratch0());
__ add(fp, sp, Operand(2 * kPointerSize));
__ add(fp, sp, Operand(StandardFrameConstants::kFixedFrameSizeFromFp));
__ mov(lr, Operand(pc), LeaveCC, al);
__ mov(pc, ip);
}
......
......@@ -867,7 +867,7 @@ void MacroAssembler::Prologue(PrologueFrameMode frame_mode) {
stm(db_w, sp, cp.bit() | fp.bit() | lr.bit());
Push(Smi::FromInt(StackFrame::STUB));
// Adjust FP to point to saved FP.
add(fp, sp, Operand(2 * kPointerSize));
add(fp, sp, Operand(StandardFrameConstants::kFixedFrameSizeFromFp));
} else {
PredictableCodeSizeScope predictible_code_size_scope(
this, kNoCodeAgeSequenceLength * Assembler::kInstrSize);
......@@ -883,7 +883,7 @@ void MacroAssembler::Prologue(PrologueFrameMode frame_mode) {
stm(db_w, sp, r1.bit() | cp.bit() | fp.bit() | lr.bit());
nop(ip.code());
// Adjust FP to point to saved FP.
add(fp, sp, Operand(2 * kPointerSize));
add(fp, sp, Operand(StandardFrameConstants::kFixedFrameSizeFromFp));
}
}
}
......@@ -896,7 +896,9 @@ void MacroAssembler::EnterFrame(StackFrame::Type type) {
push(ip);
mov(ip, Operand(CodeObject()));
push(ip);
add(fp, sp, Operand(3 * kPointerSize)); // Adjust FP to point to saved FP.
// Adjust FP to point to saved FP.
add(fp, sp,
Operand(StandardFrameConstants::kFixedFrameSizeFromFp + kPointerSize));
}
......
......@@ -181,7 +181,8 @@ DeoptimizedFrameInfo* Deoptimizer::DebuggerInspectableFrame(
// Always use the actual stack slots when calculating the fp to sp
// delta adding two for the function and context.
unsigned stack_slots = code->stack_slots();
unsigned fp_to_sp_delta = ((stack_slots + 2) * kPointerSize);
unsigned fp_to_sp_delta = (stack_slots * kPointerSize) +
StandardFrameConstants::kFixedFrameSizeFromFp;
Deoptimizer* deoptimizer = new Deoptimizer(isolate,
function,
......@@ -890,7 +891,8 @@ void Deoptimizer::DoComputeJSFrame(TranslationIterator* iterator,
// If the optimized frame had alignment padding, adjust the frame pointer
// to point to the new position of the old frame pointer after padding
// is removed. Subtract 2 * kPointerSize for the context and function slots.
top_address = input_->GetRegister(fp_reg.code()) - (2 * kPointerSize) -
top_address = input_->GetRegister(fp_reg.code()) -
StandardFrameConstants::kFixedFrameSizeFromFp -
height_in_bytes + has_alignment_padding_ * kPointerSize;
} else {
top_address = output_[frame_index - 1]->GetTop() - output_frame_size;
......@@ -1303,13 +1305,13 @@ void Deoptimizer::DoComputeAccessorStubFrame(TranslationIterator* iterator,
" translating %s stub => height=%u\n", kind, height_in_bytes);
}
// We need 1 stack entry for the return address + 4 stack entries from
// StackFrame::INTERNAL (FP, context, frame type, code object, see
// We need 1 stack entry for the return address and enough entries for the
// StackFrame::INTERNAL (FP, context, frame type and code object - see
// MacroAssembler::EnterFrame). For a setter stub frame we need one additional
// entry for the implicit return value, see
// StoreStubCompiler::CompileStoreViaSetter.
unsigned fixed_frame_entries = (kPCOnStackSize / kPointerSize) +
(kFPOnStackSize / kPointerSize) + 3 +
unsigned fixed_frame_entries =
(StandardFrameConstants::kFixedFrameSize / kPointerSize) + 1 +
(is_setter_stub_frame ? 1 : 0);
unsigned fixed_frame_size = fixed_frame_entries * kPointerSize;
unsigned output_frame_size = height_in_bytes + fixed_frame_size;
......@@ -1483,7 +1485,7 @@ void Deoptimizer::DoComputeCompiledStubFrame(TranslationIterator* iterator,
// context and function slots.
Register fp_reg = StubFailureTrampolineFrame::fp_register();
intptr_t top_address = input_->GetRegister(fp_reg.code()) -
(2 * kPointerSize) - height_in_bytes;
StandardFrameConstants::kFixedFrameSizeFromFp - height_in_bytes;
output_frame->SetTop(top_address);
// Read caller's PC (JSFunction continuation) from the input frame.
......@@ -2454,8 +2456,9 @@ void Deoptimizer::DoTranslateCommand(TranslationIterator* iterator,
unsigned Deoptimizer::ComputeInputFrameSize() const {
unsigned fixed_size = ComputeFixedSize(function_);
// The fp-to-sp delta already takes the context and the function
// into account so we have to avoid double counting them (-2).
unsigned result = fixed_size + fp_to_sp_delta_ - (2 * kPointerSize);
// into account so we have to avoid double counting them.
unsigned result = fixed_size + fp_to_sp_delta_ -
StandardFrameConstants::kFixedFrameSizeFromFp;
#ifdef DEBUG
if (compiled_code_->kind() == Code::OPTIMIZED_FUNCTION) {
unsigned stack_slots = compiled_code_->stack_slots();
......
......@@ -170,8 +170,9 @@ class StandardFrameConstants : public AllStatic {
// context and function.
// StandardFrame::IterateExpressions assumes that kContextOffset is the last
// object pointer.
static const int kFixedFrameSizeFromFp = 2 * kPointerSize;
static const int kFixedFrameSize = kPCOnStackSize + kFPOnStackSize +
2 * kPointerSize;
kFixedFrameSizeFromFp;
static const int kExpressionsOffset = -3 * kPointerSize;
static const int kMarkerOffset = -2 * kPointerSize;
static const int kContextOffset = -1 * kPointerSize;
......
......@@ -237,7 +237,8 @@ int StackSlotOffset(int index) {
if (index >= 0) {
// Local or spill slot. Skip the frame pointer, function, and
// context in the fixed part of the frame.
return -(index + 3) * kPointerSize;
return -(index + 1) * kPointerSize -
StandardFrameConstants::kFixedFrameSizeFromFp;
} else {
// Incoming parameter. Skip the return address.
return -(index + 1) * kPointerSize + kFPOnStackSize + kPCOnStackSize;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment