Index: src/compiler/frame.h |
diff --git a/src/compiler/frame.h b/src/compiler/frame.h |
index 9764b261efc48383dc6a6964c906718f87453973..e63619b9acdb5c3e8de0baf156fabe80879f01d3 100644 |
--- a/src/compiler/frame.h |
+++ b/src/compiler/frame.h |
@@ -16,15 +16,19 @@ namespace compiler { |
// function. Frames are usually populated by the register allocator and are used |
// by Linkage to generate code for the prologue and epilogue to compiled code. |
// |
-// Frames are divided up into three regions. The first is the fixed header, |
-// which always has a constant size and can be predicted before code generation |
-// begins depending on the type of code being generated. The second is the |
-// region for spill slots, which is immediately below the fixed header and grows |
-// as the register allocator needs to spill to the stack and asks the frame for |
-// more space. The third region, which contains the callee-saved registers must |
-// be reserved after register allocation, since its size can only be precisely |
-// determined after register allocation once the number of used callee-saved |
-// register is certain. |
+// Frames are divided up into four regions. |
+// - The first is the fixed header, which always has a constant size and can be |
+// predicted before code generation begins depending on the type of code being |
+// generated. |
+// - The second is the region for spill slots, which is immediately below the |
+// fixed header and grows as the register allocator needs to spill to the |
+// stack and asks the frame for more space. |
+// - The third region, which contains the callee-saved registers must be |
+// reserved after register allocation, since its size can only be precisely |
+// determined after register allocation once the number of used callee-saved |
+// register is certain. |
+// - The fourth region is used to pass arguments to other functions. It should |
+// be empty except when a call is being prepared. |
// |
// Every pointer in a frame has a slot id. On 32-bit platforms, doubles consume |
// two slots. |
@@ -35,10 +39,10 @@ namespace compiler { |
// for example JSFunctions store the function context and marker in the fixed |
// header, with slot index 2 corresponding to the current function context and 3 |
// corresponding to the frame marker/JSFunction. The frame region immediately |
-// below the fixed header contains spill slots starting a 4 for JsFunctions. The |
-// callee-saved frame region below that starts at 4+spilled_slot_count. Callee |
-// stack slots corresponding to parameters are accessible through negative slot |
-// ids. |
+// below the fixed header contains spill slots starting at 4 for JsFunctions. |
+// The callee-saved frame region below that starts at 4+spill_slot_count_. |
+// Callee stack slots corresponding to parameters are accessible through |
+// negative slot ids. |
// |
// Every slot of a caller or callee frame is accessible by the register |
// allocator and gap resolver with a SpillSlotOperand containing its |
@@ -47,50 +51,63 @@ namespace compiler { |
// Below an example JSFunction Frame with slot ids, frame regions and contents: |
// |
// slot JS frame |
-// +-----------------+---------------------------- |
-// -n-1 | parameter 0 | ^ |
-// |- - - - - - - - -| | |
-// -n | | Caller |
-// ... | ... | frame slots |
-// -2 | parameter n-1 | (slot < 0) |
-// |- - - - - - - - -| | |
-// -1 | parameter n | v |
-// -----+-----------------+---------------------------- |
-// 0 | return addr | ^ ^ |
-// |- - - - - - - - -| | | |
-// 1 | saved frame ptr | Fixed | |
-// |- - - - - - - - -| Header <-- frame ptr | |
-// 2 | Context | | | |
-// |- - - - - - - - -| | | |
-// 3 |JSFunction/Marker| v | |
-// +-----------------+---- | |
-// 4 | spill 1 | ^ Callee |
-// |- - - - - - - - -| | frame slots |
-// ... | ... | Spill slots (slot >= 0) |
-// |- - - - - - - - -| | | |
-// m+4 | spill m | v | |
-// +-----------------+---- | |
-// m+5 | callee-saved 1 | ^ | |
-// |- - - - - - - - -| | | |
-// | ... | Callee-saved | |
-// |- - - - - - - - -| | | |
-// m+r+4 | callee-saved r | v v |
-// -----+-----------------+----- <-- stack ptr --------- |
+// +-----------------+-------------------------------- |
+// -n-1 | parameter 0 | ^ |
+// |- - - - - - - - -| | |
+// -n | | Caller |
+// ... | ... | frame slots |
+// -2 | parameter n-1 | (slot < 0) |
+// |- - - - - - - - -| | |
+// -1 | parameter n | v |
+// -----+-----------------+-------------------------------- |
+// 0 | return addr | ^ ^ |
+// |- - - - - - - - -| | | |
+// 1 | saved frame ptr | Fixed | |
+// |- - - - - - - - -| Header <-- frame ptr | |
+// 2 | Context | | | |
+// |- - - - - - - - -| | | |
+// 3 |JSFunction/Marker| v | |
+// +-----------------+---- | |
+// 4 | spill 1 | ^ Callee |
+// |- - - - - - - - -| | frame slots |
+// ... | ... | Spill slots (slot >= 0) |
+// |- - - - - - - - -| | | |
+// m+4 | spill m | v | |
+// +-----------------+---- | |
+// m+5 | callee-saved 1 | ^ | |
+// |- - - - - - - - -| | | |
+// | ... | Callee-saved | |
+// |- - - - - - - - -| | | |
+// m+r+4 | callee-saved r | v | |
+// +-----------------+---- | |
+// | parameter 0 | ^ | |
+// |- - - - - - - - -| | | |
+// | ... | Outgoing parameters | |
+// |- - - - - - - - -| | (for function calls) | |
+// | parameter p | v v |
+// -----+-----------------+----- <-- stack ptr ------------- |
// |
class Frame : public ZoneObject { |
public: |
explicit Frame(int fixed_frame_size_in_slots); |
- inline int GetTotalFrameSlotCount() { return frame_slot_count_; } |
+ inline int GetTotalFrameSlotCount() const { return frame_slot_count_; } |
- inline int GetSavedCalleeRegisterSlotCount() { |
- return spilled_callee_register_slot_count_; |
+ inline int GetSpToFpSlotCount() const { |
+ return GetTotalFrameSlotCount() - |
+ StandardFrameConstants::kFixedSlotCountAboveFp; |
} |
- inline int GetSpillSlotCount() { return stack_slot_count_; } |
+ inline int GetOutgoingParameterSlotCount() const { |
+ return outgoing_parameter_slot_count_; |
+ } |
+ inline int GetSavedCalleeRegisterSlotCount() const { |
+ return callee_saved_slot_count_; |
+ } |
+ inline int GetSpillSlotCount() const { return spill_slot_count_; } |
inline void SetElidedFrameSizeInSlots(int slots) { |
- DCHECK_EQ(0, spilled_callee_register_slot_count_); |
- DCHECK_EQ(0, stack_slot_count_); |
+ DCHECK_EQ(0, callee_saved_slot_count_); |
+ DCHECK_EQ(0, spill_slot_count_); |
frame_slot_count_ = slots; |
} |
@@ -104,34 +121,47 @@ class Frame : public ZoneObject { |
allocated_double_registers_ = regs; |
} |
- bool DidAllocateDoubleRegisters() { |
+ bool DidAllocateDoubleRegisters() const { |
return !allocated_double_registers_->IsEmpty(); |
} |
+ void AllocateOutgoingParameterSlots(int count) { |
+ outgoing_parameter_slot_count_ += count; |
+ frame_slot_count_ += count; |
+ } |
+ |
+ void ClearOutgoingParameterSlots() { |
+ frame_slot_count_ -= outgoing_parameter_slot_count_; |
+ outgoing_parameter_slot_count_ = 0; |
+ } |
+ |
int AlignSavedCalleeRegisterSlots() { |
- DCHECK_EQ(0, spilled_callee_register_slot_count_); |
+ DCHECK_EQ(0, callee_saved_slot_count_); |
int delta = frame_slot_count_ & 1; |
frame_slot_count_ += delta; |
return delta; |
} |
void AllocateSavedCalleeRegisterSlots(int count) { |
+ DCHECK_EQ(0, outgoing_parameter_slot_count_); |
frame_slot_count_ += count; |
- spilled_callee_register_slot_count_ += count; |
+ callee_saved_slot_count_ += count; |
} |
int AllocateSpillSlot(int width) { |
- DCHECK_EQ(0, spilled_callee_register_slot_count_); |
+ DCHECK_EQ(0, outgoing_parameter_slot_count_); |
+ DCHECK_EQ(0, callee_saved_slot_count_); |
int frame_slot_count_before = frame_slot_count_; |
int slot = AllocateAlignedFrameSlot(width); |
- stack_slot_count_ += (frame_slot_count_ - frame_slot_count_before); |
+ spill_slot_count_ += (frame_slot_count_ - frame_slot_count_before); |
return slot; |
} |
int ReserveSpillSlots(size_t slot_count) { |
- DCHECK_EQ(0, spilled_callee_register_slot_count_); |
- DCHECK_EQ(0, stack_slot_count_); |
- stack_slot_count_ += static_cast<int>(slot_count); |
+ DCHECK_EQ(0, outgoing_parameter_slot_count_); |
+ DCHECK_EQ(0, callee_saved_slot_count_); |
+ DCHECK_EQ(0, spill_slot_count_); |
+ spill_slot_count_ += static_cast<int>(slot_count); |
frame_slot_count_ += static_cast<int>(slot_count); |
return frame_slot_count_ - 1; |
} |
@@ -150,8 +180,9 @@ class Frame : public ZoneObject { |
private: |
int frame_slot_count_; |
- int spilled_callee_register_slot_count_; |
- int stack_slot_count_; |
+ int outgoing_parameter_slot_count_; |
+ int callee_saved_slot_count_; |
+ int spill_slot_count_; |
BitVector* allocated_registers_; |
BitVector* allocated_double_registers_; |