 Chromium Code Reviews
 Chromium Code Reviews Issue 2624183002:
  [compiler] Allow for StackSlots of arbitrary size  (Closed)
    
  
    Issue 2624183002:
  [compiler] Allow for StackSlots of arbitrary size  (Closed) 
  | OLD | NEW | 
|---|---|
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. | 
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be | 
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. | 
| 4 | 4 | 
| 5 #ifndef V8_COMPILER_FRAME_H_ | 5 #ifndef V8_COMPILER_FRAME_H_ | 
| 6 #define V8_COMPILER_FRAME_H_ | 6 #define V8_COMPILER_FRAME_H_ | 
| 7 | 7 | 
| 8 #include "src/bit-vector.h" | 8 #include "src/bit-vector.h" | 
| 9 #include "src/frames.h" | 9 #include "src/frames.h" | 
| 10 | 10 | 
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 105 frame_slot_count_ += delta; | 105 frame_slot_count_ += delta; | 
| 106 } | 106 } | 
| 107 spill_slot_count_ += delta; | 107 spill_slot_count_ += delta; | 
| 108 } | 108 } | 
| 109 | 109 | 
| 110 void AllocateSavedCalleeRegisterSlots(int count) { | 110 void AllocateSavedCalleeRegisterSlots(int count) { | 
| 111 frame_slot_count_ += count; | 111 frame_slot_count_ += count; | 
| 112 } | 112 } | 
| 113 | 113 | 
| 114 int AllocateSpillSlot(int width) { | 114 int AllocateSpillSlot(int width) { | 
| 115 int frame_slot_count_before = frame_slot_count_; | 115 int new_frame_slots = NumAlignedFrameSlots(width); | 
| 116 int slot = AllocateAlignedFrameSlot(width); | 116 spill_slot_count_ += new_frame_slots; | 
| 117 spill_slot_count_ += (frame_slot_count_ - frame_slot_count_before); | 117 frame_slot_count_ += new_frame_slots; | 
| 118 return slot; | 118 return frame_slot_count_ - 1; | 
| 119 } | 119 } | 
| 120 | 120 | 
| 121 int AlignFrame(int alignment = kDoubleSize); | 121 int AlignFrame(int alignment = kDoubleSize); | 
| 122 | 122 | 
| 123 int ReserveSpillSlots(size_t slot_count) { | 123 int ReserveSpillSlots(size_t slot_count) { | 
| 124 DCHECK_EQ(0, spill_slot_count_); | 124 DCHECK_EQ(0, spill_slot_count_); | 
| 125 spill_slot_count_ += static_cast<int>(slot_count); | 125 spill_slot_count_ += static_cast<int>(slot_count); | 
| 126 frame_slot_count_ += static_cast<int>(slot_count); | 126 frame_slot_count_ += static_cast<int>(slot_count); | 
| 127 return frame_slot_count_ - 1; | 127 return frame_slot_count_ - 1; | 
| 128 } | 128 } | 
| 129 | 129 | 
| 130 static const int kContextSlot = 2 + StandardFrameConstants::kCPSlotCount; | 130 static const int kContextSlot = 2 + StandardFrameConstants::kCPSlotCount; | 
| 131 static const int kJSFunctionSlot = 3 + StandardFrameConstants::kCPSlotCount; | 131 static const int kJSFunctionSlot = 3 + StandardFrameConstants::kCPSlotCount; | 
| 132 | 132 | 
| 133 private: | 133 private: | 
| 134 int AllocateAlignedFrameSlot(int width) { | 134 int NumAlignedFrameSlots(int width) { | 
| 135 DCHECK(width == 4 || width == 8 || width == 16); | 135 int new_frame_slots = (width + kPointerSize - 1) / kPointerSize; | 
| 136 if (kPointerSize == 4) { | 136 // Align to 8 bytes if width is a multiple of 8 bytes. | 
| 137 // Skip one slot if necessary. | 137 if (kPointerSize == 4 && width >= 8 && (width & 7) == 0 && | 
| 
titzer
2017/01/11 15:13:40
Why not just alignSize = (width & 7) == 0 ? 8 : kP
 
Clemens Hammacher
2017/01/11 15:41:34
It wasn't there before, but sounds like a good ide
 | |
| 138 if (width > kPointerSize) { | 138 ((frame_slot_count_ + new_frame_slots) & 1) != 0) { | 
| 139 frame_slot_count_++; | 139 ++new_frame_slots; | 
| 140 frame_slot_count_ |= 1; | |
| 141 // 2 extra slots if width == 16. | |
| 142 frame_slot_count_ += (width & 16) / 8; | |
| 143 } | |
| 144 } else { | |
| 145 // No alignment when slots are 8 bytes. | |
| 146 DCHECK_EQ(8, kPointerSize); | |
| 147 // 1 extra slot if width == 16. | |
| 148 frame_slot_count_ += (width & 16) / 16; | |
| 149 } | 140 } | 
| 150 return frame_slot_count_++; | 141 DCHECK_GT(kMaxInt - frame_slot_count_, new_frame_slots); | 
| 142 return new_frame_slots; | |
| 151 } | 143 } | 
| 152 | 144 | 
| 153 private: | 145 private: | 
| 154 int frame_slot_count_; | 146 int frame_slot_count_; | 
| 155 int spill_slot_count_; | 147 int spill_slot_count_; | 
| 156 BitVector* allocated_registers_; | 148 BitVector* allocated_registers_; | 
| 157 BitVector* allocated_double_registers_; | 149 BitVector* allocated_double_registers_; | 
| 158 | 150 | 
| 159 DISALLOW_COPY_AND_ASSIGN(Frame); | 151 DISALLOW_COPY_AND_ASSIGN(Frame); | 
| 160 }; | 152 }; | 
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 231 const Frame* const frame_; | 223 const Frame* const frame_; | 
| 232 bool access_frame_with_fp_; | 224 bool access_frame_with_fp_; | 
| 233 int sp_delta_; | 225 int sp_delta_; | 
| 234 bool has_frame_; | 226 bool has_frame_; | 
| 235 }; | 227 }; | 
| 236 } // namespace compiler | 228 } // namespace compiler | 
| 237 } // namespace internal | 229 } // namespace internal | 
| 238 } // namespace v8 | 230 } // namespace v8 | 
| 239 | 231 | 
| 240 #endif // V8_COMPILER_FRAME_H_ | 232 #endif // V8_COMPILER_FRAME_H_ | 
| OLD | NEW |