OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
290 static const uint32_t kMultiFreeEncoding = 1; | 290 static const uint32_t kMultiFreeEncoding = 1; |
291 | 291 |
292 inline bool IsMarked(Object* obj); | 292 inline bool IsMarked(Object* obj); |
293 | 293 |
294 inline Heap* heap() const { return heap_; } | 294 inline Heap* heap() const { return heap_; } |
295 | 295 |
296 CodeFlusher* code_flusher() { return code_flusher_; } | 296 CodeFlusher* code_flusher() { return code_flusher_; } |
297 inline bool is_code_flushing_enabled() const { return code_flusher_ != NULL; } | 297 inline bool is_code_flushing_enabled() const { return code_flusher_ != NULL; } |
298 void EnableCodeFlushing(bool enable); | 298 void EnableCodeFlushing(bool enable); |
299 | 299 |
| 300 enum SweeperType { |
| 301 CONSERVATIVE, |
| 302 LAZY_CONSERVATIVE, |
| 303 PRECISE |
| 304 }; |
| 305 |
| 306 // Sweep a single page from the given space conservatively. |
| 307 // Return a number of reclaimed bytes. |
| 308 static int SweepConservatively(PagedSpace* space, Page* p); |
| 309 |
300 private: | 310 private: |
301 MarkCompactCollector(); | 311 MarkCompactCollector(); |
302 ~MarkCompactCollector(); | 312 ~MarkCompactCollector(); |
303 | 313 |
304 #ifdef DEBUG | 314 #ifdef DEBUG |
305 enum CollectorState { | 315 enum CollectorState { |
306 IDLE, | 316 IDLE, |
307 PREPARE_GC, | 317 PREPARE_GC, |
308 MARK_LIVE_OBJECTS, | 318 MARK_LIVE_OBJECTS, |
309 SWEEP_SPACES, | 319 SWEEP_SPACES, |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
452 int IterateLiveObjectsInRange(Address start, Address end, | 462 int IterateLiveObjectsInRange(Address start, Address end, |
453 LiveObjectCallback size_func); | 463 LiveObjectCallback size_func); |
454 | 464 |
455 // If we are not compacting the heap, we simply sweep the spaces except | 465 // If we are not compacting the heap, we simply sweep the spaces except |
456 // for the large object space, clearing mark bits and adding unmarked | 466 // for the large object space, clearing mark bits and adding unmarked |
457 // regions to each space's free list. | 467 // regions to each space's free list. |
458 void SweepSpaces(); | 468 void SweepSpaces(); |
459 | 469 |
460 void SweepNewSpace(NewSpace* space); | 470 void SweepNewSpace(NewSpace* space); |
461 | 471 |
462 enum SweeperType { CONSERVATIVE, PRECISE }; | |
463 | 472 |
464 void SweepSpace(PagedSpace* space, SweeperType sweeper); | 473 void SweepSpace(PagedSpace* space, SweeperType sweeper); |
465 | 474 |
| 475 |
466 #ifdef DEBUG | 476 #ifdef DEBUG |
467 // ----------------------------------------------------------------------- | 477 // ----------------------------------------------------------------------- |
468 // Debugging variables, functions and classes | 478 // Debugging variables, functions and classes |
469 // Counters used for debugging the marking phase of mark-compact or | 479 // Counters used for debugging the marking phase of mark-compact or |
470 // mark-sweep collection. | 480 // mark-sweep collection. |
471 | 481 |
472 // Size of live objects in Heap::to_space_. | 482 // Size of live objects in Heap::to_space_. |
473 int live_young_objects_size_; | 483 int live_young_objects_size_; |
474 | 484 |
475 // Size of live objects in Heap::old_pointer_space_. | 485 // Size of live objects in Heap::old_pointer_space_. |
(...skipping 29 matching lines...) Expand all Loading... |
505 CodeFlusher* code_flusher_; | 515 CodeFlusher* code_flusher_; |
506 | 516 |
507 friend class Heap; | 517 friend class Heap; |
508 friend class OverflowedObjectsScanner; | 518 friend class OverflowedObjectsScanner; |
509 }; | 519 }; |
510 | 520 |
511 | 521 |
512 } } // namespace v8::internal | 522 } } // namespace v8::internal |
513 | 523 |
514 #endif // V8_MARK_COMPACT_H_ | 524 #endif // V8_MARK_COMPACT_H_ |
OLD | NEW |