Lines Matching refs:segment
47 // chained together forming a LIFO structure with the newest segment
51 class Segment {
53 void Initialize(Segment* next, size_t size) {
58 Segment* next() const { return next_; }
62 size_t capacity() const { return size_ - sizeof(Segment); }
64 Address start() const { return address(sizeof(Segment)); }
68 // Computes the address of the nth byte in this segment.
71 Segment* next_;
131 // Find a segment with a suitable size to keep around.
132 Segment* keep = nullptr;
134 // and freeing every segment except the one we wish to keep.
135 for (Segment* current = segment_head_; current;) {
136 Segment* next = current->next();
138 // Unlink the segment we wish to keep from the list.
146 // Zap the entire current segment (including the header).
154 // If we have found a segment we want to keep, we must recompute the
157 // force a new segment to be allocated on demand.
162 // Un-poison so we can re-use the segment later.
165 // Zap the contents of the kept segment (but not the header).
173 // Update the head segment to be the kept segment (if any).
190 // Zap the entire kept segment (including the header).
201 // Creates a new segment, sets it size, and pushes it to the front
202 // of the segment chain. Returns the new segment.
203 Segment* Zone::NewSegment(size_t size) {
204 Segment* result = reinterpret_cast<Segment*>(Malloced::New(size));
214 // Deletes the given segment. Does not touch the segment chain.
215 void Zone::DeleteSegment(Segment* segment, size_t size) {
217 Malloced::Delete(segment);
227 // Compute the new segment size. We use a 'high water mark'
228 // strategy, where we increase the segment size every time we expand
229 // except that we employ a maximum segment size when we delete. This
231 Segment* head = segment_head_;
233 static const size_t kSegmentOverhead = sizeof(Segment) + kAlignment;
245 // Limit the size of new segments to avoid growing the segment size
247 // All the while making sure to allocate a segment large enough to hold the
255 Segment* segment = NewSegment(new_size);
256 if (segment == nullptr) {
261 // Recompute 'top' and 'limit' based on the new segment.
262 Address result = RoundUp(segment->start(), kAlignment);
265 // (Should not happen since the segment is guaranteed to accomodate
269 limit_ = segment->end();