5 #ifndef V8_COMPILER_FRAME_H_ 6 #define V8_COMPILER_FRAME_H_ 8 #include "src/bit-vector.h" 9 #include "src/frame-constants.h" 91 explicit Frame(
int fixed_frame_size_in_slots);
93 inline int GetTotalFrameSlotCount()
const {
return frame_slot_count_; }
94 inline int GetFixedSlotCount()
const {
return fixed_slot_count_; }
95 inline int GetSpillSlotCount()
const {
return spill_slot_count_; }
96 inline int GetReturnSlotCount()
const {
return return_slot_count_; }
98 void SetAllocatedRegisters(
BitVector* regs) {
99 DCHECK_NULL(allocated_registers_);
100 allocated_registers_ = regs;
103 void SetAllocatedDoubleRegisters(
BitVector* regs) {
104 DCHECK_NULL(allocated_double_registers_);
105 allocated_double_registers_ = regs;
108 bool DidAllocateDoubleRegisters()
const {
109 return !allocated_double_registers_->IsEmpty();
112 void AlignSavedCalleeRegisterSlots(
int alignment = kDoubleSize) {
113 int alignment_slots = alignment / kPointerSize;
114 int delta = alignment_slots - (frame_slot_count_ & (alignment_slots - 1));
115 if (delta != alignment_slots) {
116 frame_slot_count_ += delta;
118 spill_slot_count_ += delta;
121 void AllocateSavedCalleeRegisterSlots(
int count) {
122 frame_slot_count_ += count;
125 int AllocateSpillSlot(
int width,
int alignment = 0) {
126 DCHECK_EQ(frame_slot_count_,
127 fixed_slot_count_ + spill_slot_count_ + return_slot_count_);
128 int frame_slot_count_before = frame_slot_count_;
129 if (alignment > kPointerSize) {
132 width += alignment - kPointerSize;
134 AllocateAlignedFrameSlots(width);
135 spill_slot_count_ += frame_slot_count_ - frame_slot_count_before;
136 return frame_slot_count_ - return_slot_count_ - 1;
139 void EnsureReturnSlots(
int count) {
140 if (count > return_slot_count_) {
141 count -= return_slot_count_;
142 frame_slot_count_ += count;
143 return_slot_count_ += count;
147 int AlignFrame(
int alignment = kDoubleSize);
149 int ReserveSpillSlots(
size_t slot_count) {
150 DCHECK_EQ(0, spill_slot_count_);
151 spill_slot_count_ +=
static_cast<int>(slot_count);
152 frame_slot_count_ +=
static_cast<int>(slot_count);
153 return frame_slot_count_ - 1;
157 void AllocateAlignedFrameSlots(
int width) {
159 int new_frame_slots = (width + kPointerSize - 1) / kPointerSize;
162 int align_to = (width & 15) == 0 ? 16 : (width & 7) == 0 ? 8 : kPointerSize;
164 RoundUp(frame_slot_count_ + new_frame_slots, align_to / kPointerSize);
165 DCHECK_LT(0, frame_slot_count_);
169 int fixed_slot_count_;
170 int frame_slot_count_;
171 int spill_slot_count_;
172 int return_slot_count_;
176 DISALLOW_COPY_AND_ASSIGN(
Frame);
183 inline bool from_stack_pointer() {
return (offset_ & 1) == kFromSp; }
184 inline bool from_frame_pointer() {
return (offset_ & 1) == kFromFp; }
185 inline int offset() {
return offset_ & ~1; }
187 inline static FrameOffset FromStackPointer(
int offset) {
188 DCHECK_EQ(0, offset & 1);
192 inline static FrameOffset FromFramePointer(
int offset) {
193 DCHECK_EQ(0, offset & 1);
198 explicit FrameOffset(
int offset) : offset_(offset) {}
202 static const int kFromSp = 1;
203 static const int kFromFp = 0;
212 access_frame_with_fp_(
false),
216 const Frame* frame()
const {
return frame_; }
217 void MarkHasFrame(
bool state);
219 int sp_delta()
const {
return sp_delta_; }
220 void ClearSPDelta() { sp_delta_ = 0; }
221 void IncreaseSPDelta(
int amount) { sp_delta_ += amount; }
223 bool access_frame_with_fp()
const {
return access_frame_with_fp_; }
227 bool has_frame()
const {
return has_frame_; }
229 void SetFrameAccessToDefault();
230 void SetFrameAccessToFP() { access_frame_with_fp_ =
true; }
231 void SetFrameAccessToSP() { access_frame_with_fp_ =
false; }
233 int GetSPToFPSlotCount()
const {
234 int frame_slot_count =
235 (has_frame() ? frame()->GetTotalFrameSlotCount() : kElidedFrameSlots) -
236 StandardFrameConstants::kFixedSlotCountAboveFp;
237 return frame_slot_count + sp_delta();
239 int GetSPToFPOffset()
const {
return GetSPToFPSlotCount() * kPointerSize; }
248 const Frame*
const frame_;
249 bool access_frame_with_fp_;
257 #endif // V8_COMPILER_FRAME_H_