Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(418)

Side by Side Diff: src/mark-compact.h

Issue 6321008: Introduce conservative sweeping. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/gc
Patch Set: Created 9 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 if (Heap::InNewSpace(addr)) { 99 if (Heap::InNewSpace(addr)) {
100 uint32_t index = Heap::new_space()->Address2MarkbitIndex(addr); 100 uint32_t index = Heap::new_space()->Address2MarkbitIndex(addr);
101 new_space_bitmap_->ClearRange(index, size >> kPointerSizeLog2); 101 new_space_bitmap_->ClearRange(index, size >> kPointerSizeLog2);
102 } else { 102 } else {
103 Page *p = Page::FromAddress(addr); 103 Page *p = Page::FromAddress(addr);
104 p->markbits()->ClearRange(p->FastAddress2Markbit(addr), 104 p->markbits()->ClearRange(p->FastAddress2Markbit(addr),
105 size >> kPointerSizeLog2); 105 size >> kPointerSizeLog2);
106 } 106 }
107 } 107 }
108 108
109 INLINE(static Address FirstMarkedObject(Page* p,
110 uint32_t cell_index,
111 uint32_t cell)) {
112 ASSERT(cell != 0);
113 uint32_t bit = __builtin_ctz(cell);
Erik Corry 2011/01/19 13:46:48 We will need to make this work on non-gcc at some
Vyacheslav Egorov (Chromium) 2011/01/20 16:40:21 I create separate class for compiler intrinsics.
114 return p->Markbit2Address(
115 Page::MarkbitsBitmap::Cell2Index(cell_index) + bit);
116 }
117
118 INLINE(static Address FirstLiveObject(Address start,
119 Address limit)) {
120 ASSERT(!Heap::InNewSpace(start));
121 if (start >= limit) return start;
122
123 Page* p = Page::FromAddress(start);
Erik Corry 2011/01/19 13:46:48 can we call this variable page and the b variable
Vyacheslav Egorov (Chromium) 2011/01/20 16:40:21 Done.
124
125 // Space above linearity boundary is continious.
Erik Corry 2011/01/19 13:46:48 continious -> continuous
Vyacheslav Egorov (Chromium) 2011/01/20 16:40:21 Done.
126 if (start >= p->linearity_boundary()) return start;
Erik Corry 2011/01/19 13:46:48 how do we know an object starts here? This should
Vyacheslav Egorov (Chromium) 2011/01/20 16:40:21 Done.
127
128 Page::MarkbitsBitmap* b = p->markbits();
129 uint32_t markbit = p->Address2Markbit(start);
Erik Corry 2011/01/19 13:46:48 I'd prefer int instead of uint32_t. Firstly unsig
Vyacheslav Egorov (Chromium) 2011/01/20 16:40:21 I prefer uint32_t. Having uint32_t there and int h
130
131 // If the start address is marked return it.
132 if (b->Get(markbit)) return start;
133
134 uint32_t* cells = b->cells();
135 uint32_t cell = Page::MarkbitsBitmap::Index2Cell(markbit);
136
137 uint32_t last_cell =
138 Page::MarkbitsBitmap::Index2Cell(
139 Page::MarkbitsBitmap::CellAlignIndex(
140 p->Address2Markbit(limit)));
Erik Corry 2011/01/19 13:46:48 'To' is ! much longer than '2' and more clear2read
Vyacheslav Egorov (Chromium) 2011/01/20 16:40:21 Done.
141
142 ASSERT(cell < last_cell);
Erik Corry 2011/01/19 13:46:48 Comm /* comment */ ent?
Vyacheslav Egorov (Chromium) 2011/01/20 16:40:21 Done.
143
144 while (cell < last_cell && cells[cell] == 0) cell++;
145
146 if (cell == last_cell) return limit;
147
148 return FirstMarkedObject(p, cell, cells[cell]);
149 }
150
151 INLINE(static Address NextLiveObject(HeapObject* obj,
152 int size,
153 Address end)) {
154 ASSERT(!Heap::InNewSpace(obj));
155 Page* p = Page::FromAddress(obj->address());
156 Address watermark = p->linearity_boundary();
157 Address next_addr = obj->address() + size;
158
159 if (next_addr >= watermark) return next_addr;
160
161 Page::MarkbitsBitmap* b = p->markbits();
162 uint32_t markbit = p->Address2Markbit(next_addr);
163
164 if (b->Get(markbit)) return next_addr;
165
166 uint32_t* cells = b->cells();
167 uint32_t cell = Page::MarkbitsBitmap::Index2Cell(markbit);
Erik Corry 2011/01/19 13:46:48 Again, it's an int. Can we call it cell_index to
Vyacheslav Egorov (Chromium) 2011/01/20 16:40:21 Done.
168
169 ASSERT(IsMarked(obj));
170
171 uint32_t bit = Page::MarkbitsBitmap::Index2Bit(markbit);
172 uint32_t mask = (~1) << bit;
173 if ((cells[cell] & mask) != 0) {
174 // There are more marked objects in this cell.
175 return FirstMarkedObject(p, cell, cells[cell] & mask);
176 }
177
178 Address limit = Min(watermark, end);
179
180 uint32_t last_cell =
Erik Corry 2011/01/19 13:46:48 This is actually one past the last cell?
Vyacheslav Egorov (Chromium) 2011/01/20 16:40:21 Yes. This is frontier cell.
181 Page::MarkbitsBitmap::Index2Cell(
182 Page::MarkbitsBitmap::CellAlignIndex(
183 p->Address2Markbit(limit)));
184
185 ASSERT(cell < last_cell);
186
187 do {
188 cell++;
189 } while (cell < last_cell && cells[cell] == 0);
190
191 if (cell == last_cell) return limit;
192
193 return FirstMarkedObject(p, cell, cells[cell]);
194 }
195
196 static inline void TransferMark(Address old_start,
197 Address new_start) {
198 if (Heap::InNewSpace(old_start) ||
199 Page::FromAddress(old_start)->IsFlagSet(Page::IS_CONTINIOUS) ||
Erik Corry 2011/01/19 13:46:48 IS_CONTINIOUS -> IS_CONTINUOUS
Vyacheslav Egorov (Chromium) 2011/01/20 16:40:21 Done everywhere.
200 !IsMarked(old_start)) {
201 return;
202 }
203
204 SetMark(new_start);
205 }
206
109 static bool Setup(); 207 static bool Setup();
110 208
111 static void TearDown(); 209 static void TearDown();
112 210
113 private: 211 private:
114 class BitmapStorageDescriptor { 212 class BitmapStorageDescriptor {
115 public: 213 public:
116 INLINE(static int CellsCount(Address addr)) { 214 INLINE(static int CellsCount(Address addr)) {
117 return HeaderOf(addr)->cells_count_; 215 return HeaderOf(addr)->cells_count_;
118 } 216 }
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 // number of live objects. 489 // number of live objects.
392 static int IterateLiveObjectsInRange(Address start, Address end, 490 static int IterateLiveObjectsInRange(Address start, Address end,
393 HeapObjectCallback size_func); 491 HeapObjectCallback size_func);
394 492
395 // If we are not compacting the heap, we simply sweep the spaces except 493 // If we are not compacting the heap, we simply sweep the spaces except
396 // for the large object space, clearing mark bits and adding unmarked 494 // for the large object space, clearing mark bits and adding unmarked
397 // regions to each space's free list. 495 // regions to each space's free list.
398 static void SweepSpaces(); 496 static void SweepSpaces();
399 497
400 static void SweepNewSpace(NewSpace* space); 498 static void SweepNewSpace(NewSpace* space);
401 static void SweepSpace(PagedSpace* space); 499
500 enum SweeperType { CONSERVATIVE, PRECISE };
Erik Corry 2011/01/19 13:46:48 The style guide allows kConservative and kPrecise.
Vyacheslav Egorov (Chromium) 2011/01/20 16:40:21 I prefer kX for non trivial constants. XXX is for
501
502 static void SweepSpace(PagedSpace* space, SweeperType sweeper);
402 503
403 #ifdef DEBUG 504 #ifdef DEBUG
404 // ----------------------------------------------------------------------- 505 // -----------------------------------------------------------------------
405 // Debugging variables, functions and classes 506 // Debugging variables, functions and classes
406 // Counters used for debugging the marking phase of mark-compact or 507 // Counters used for debugging the marking phase of mark-compact or
407 // mark-sweep collection. 508 // mark-sweep collection.
408 509
409 // Size of live objects in Heap::to_space_. 510 // Size of live objects in Heap::to_space_.
410 static int live_young_objects_size_; 511 static int live_young_objects_size_;
411 512
(...skipping 23 matching lines...) Expand all
435 536
436 friend class UnmarkObjectVisitor; 537 friend class UnmarkObjectVisitor;
437 static void UnmarkObject(HeapObject* obj); 538 static void UnmarkObject(HeapObject* obj);
438 #endif 539 #endif
439 }; 540 };
440 541
441 542
442 } } // namespace v8::internal 543 } } // namespace v8::internal
443 544
444 #endif // V8_MARK_COMPACT_H_ 545 #endif // V8_MARK_COMPACT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698