Reviewers: ulan,
Message:
Ulan, could you please take a look.
Background of this CL is that during the OOL constant pool work I have spent
many hours tracking down all the constnat literals which need to be changed
if
changing the stack frame size. After this CL, only the
kFixedFrameSizeFromFp
constant should need to be changed.
If this looks reasonable, I will update the CL for other architectures.
Description:
Replace hard-coded stack frame size literals with
StandardFrameConstants::kFixedFrameSizeFromFp
Please review this at https://codereview.chromium.org/60763006/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files (+50, -34 lines):
M src/arm/builtins-arm.cc
M src/arm/codegen-arm.cc
M src/arm/frames-arm.h
M src/arm/lithium-codegen-arm.cc
M src/arm/macro-assembler-arm.cc
M src/deoptimizer.cc
M src/frames.h
M src/lithium.cc
Index: src/arm/builtins-arm.cc
diff --git a/src/arm/builtins-arm.cc b/src/arm/builtins-arm.cc
index
ae50d7965bd663d8e53792515d231e873d025032..113aa8a47df07448ab7b5b57612e116cf6396d8d
100644
--- a/src/arm/builtins-arm.cc
+++ b/src/arm/builtins-arm.cc
@@ -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,11 +1177,13 @@ void
Builtins::Generate_FunctionCall(MacroAssembler* masm) {
void Builtins::Generate_FunctionApply(MacroAssembler* masm) {
- const int kIndexOffset = -5 * kPointerSize;
- const int kLimitOffset = -4 * kPointerSize;
- const int kArgsOffset = 2 * kPointerSize;
- const int kRecvOffset = 3 * kPointerSize;
- const int kFunctionOffset = 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;
{
FrameScope frame_scope(masm, StackFrame::INTERNAL);
@@ -1342,6 +1344,8 @@ static void
EnterArgumentsAdaptorFrame(MacroAssembler* masm) {
__ 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 +1355,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 +1443,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);
Index: src/arm/codegen-arm.cc
diff --git a/src/arm/codegen-arm.cc b/src/arm/codegen-arm.cc
index
85cb610679a6c331c07dd952bd5d7ddfd1cd0b39..238d34ed27e3bb6bdba2d7582652c2747cead720
100644
--- a/src/arm/codegen-arm.cc
+++ b/src/arm/codegen-arm.cc
@@ -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;
Index: src/arm/frames-arm.h
diff --git a/src/arm/frames-arm.h b/src/arm/frames-arm.h
index
64a718e89f71e49ac362d71aeb55741c265ecfa9..6c9ec4ab5e4f1fdc5104f5f627002d049bb2c88d
100644
--- a/src/arm/frames-arm.h
+++ b/src/arm/frames-arm.h
@@ -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);
};
Index: src/arm/lithium-codegen-arm.cc
diff --git a/src/arm/lithium-codegen-arm.cc b/src/arm/lithium-codegen-arm.cc
index
56717a29e129e19071133d6fecb60db19bfbad56..e718d10cd87ca6daef1100dea515a123cf18c029
100644
--- a/src/arm/lithium-codegen-arm.cc
+++ b/src/arm/lithium-codegen-arm.cc
@@ -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);
}
Index: src/arm/macro-assembler-arm.cc
diff --git a/src/arm/macro-assembler-arm.cc b/src/arm/macro-assembler-arm.cc
index
bcc985ac5a074e9ae14892d159e5c7cd1afd52b4..e2216d10c8344840c119ae23c753d64041ea11c8
100644
--- a/src/arm/macro-assembler-arm.cc
+++ b/src/arm/macro-assembler-arm.cc
@@ -863,7 +863,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);
@@ -879,7 +879,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));
}
}
}
@@ -892,7 +892,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));
}
Index: src/deoptimizer.cc
diff --git a/src/deoptimizer.cc b/src/deoptimizer.cc
index
2f4d7dc79e0c1b0ec996447d6d13d18be5394032..e39c3455f0b7901d66657717aac58371411453d6
100644
--- a/src/deoptimizer.cc
+++ b/src/deoptimizer.cc
@@ -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,14 +1305,14 @@ 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 +
- (is_setter_stub_frame ? 1 : 0);
+ 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();
Index: src/frames.h
diff --git a/src/frames.h b/src/frames.h
index
d2dbfe2815ba39fd116a4c25c130d9f5e2b2dfb3..230144d6800a9f4c8134c1903421aa6f3a6e8e28
100644
--- a/src/frames.h
+++ b/src/frames.h
@@ -170,14 +170,15 @@ class StandardFrameConstants : public AllStatic {
// context and function.
// StandardFrame::IterateExpressions assumes that kContextOffset is the
last
// object pointer.
- static const int kFixedFrameSize = kPCOnStackSize + kFPOnStackSize +
- 2 * kPointerSize;
- static const int kExpressionsOffset = -3 * kPointerSize;
- static const int kMarkerOffset = -2 * kPointerSize;
- static const int kContextOffset = -1 * kPointerSize;
- static const int kCallerFPOffset = 0 * kPointerSize;
- static const int kCallerPCOffset = +1 * kFPOnStackSize;
- static const int kCallerSPOffset = kCallerPCOffset + 1 *
kPCOnStackSize;
+ static const int kFixedFrameSizeFromFp = 2 * kPointerSize;
+ static const int kFixedFrameSize = kPCOnStackSize +
kFPOnStackSize +
+ kFixedFrameSizeFromFp;
+ static const int kExpressionsOffset = -3 * kPointerSize;
+ static const int kMarkerOffset = -2 * kPointerSize;
+ static const int kContextOffset = -1 * kPointerSize;
+ static const int kCallerFPOffset = 0 * kPointerSize;
+ static const int kCallerPCOffset = +1 * kFPOnStackSize;
+ static const int kCallerSPOffset = kCallerPCOffset + 1 *
kPCOnStackSize;
};
Index: src/lithium.cc
diff --git a/src/lithium.cc b/src/lithium.cc
index
ee8ea3e711ed95de247ae0ef2afdf921a0a46fe8..414d5f4edeb5bec2a608d727dc2a1c0b503082b4
100644
--- a/src/lithium.cc
+++ b/src/lithium.cc
@@ -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;
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.