| OLD | NEW |
| 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 19 matching lines...) Expand all Loading... |
| 30 | 30 |
| 31 namespace v8 { | 31 namespace v8 { |
| 32 namespace internal { | 32 namespace internal { |
| 33 | 33 |
| 34 // Callback function, returns whether an object is alive. The heap size | 34 // Callback function, returns whether an object is alive. The heap size |
| 35 // of the object is returned in size. It optionally updates the offset | 35 // of the object is returned in size. It optionally updates the offset |
| 36 // to the first live object in the page (only used for old and map objects). | 36 // to the first live object in the page (only used for old and map objects). |
| 37 typedef bool (*IsAliveFunction)(HeapObject* obj, int* size, int* offset); | 37 typedef bool (*IsAliveFunction)(HeapObject* obj, int* size, int* offset); |
| 38 | 38 |
| 39 // Callback function for non-live blocks in the old generation. | 39 // Callback function for non-live blocks in the old generation. |
| 40 typedef void (*DeallocateFunction)(Address start, int size_in_bytes); | 40 // If add_to_freelist is false then just accounting stats are updated and |
| 41 // no attempt to add area to free list is made. |
| 42 typedef void (*DeallocateFunction)(Address start, |
| 43 int size_in_bytes, |
| 44 bool add_to_freelist); |
| 41 | 45 |
| 42 | 46 |
| 43 // Forward declarations. | 47 // Forward declarations. |
| 44 class RootMarkingVisitor; | 48 class RootMarkingVisitor; |
| 45 class MarkingVisitor; | 49 class MarkingVisitor; |
| 46 | 50 |
| 47 | 51 |
| 48 // ------------------------------------------------------------------------- | 52 // ------------------------------------------------------------------------- |
| 49 // Mark-Compact collector | 53 // Mark-Compact collector |
| 50 // | 54 // |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 306 static int IterateLiveObjects(NewSpace* space, HeapObjectCallback size_f); | 310 static int IterateLiveObjects(NewSpace* space, HeapObjectCallback size_f); |
| 307 static int IterateLiveObjects(PagedSpace* space, HeapObjectCallback size_f); | 311 static int IterateLiveObjects(PagedSpace* space, HeapObjectCallback size_f); |
| 308 | 312 |
| 309 // Iterates the live objects between a range of addresses, returning the | 313 // Iterates the live objects between a range of addresses, returning the |
| 310 // number of live objects. | 314 // number of live objects. |
| 311 static int IterateLiveObjectsInRange(Address start, Address end, | 315 static int IterateLiveObjectsInRange(Address start, Address end, |
| 312 HeapObjectCallback size_func); | 316 HeapObjectCallback size_func); |
| 313 | 317 |
| 314 // Callback functions for deallocating non-live blocks in the old | 318 // Callback functions for deallocating non-live blocks in the old |
| 315 // generation. | 319 // generation. |
| 316 static void DeallocateOldPointerBlock(Address start, int size_in_bytes); | 320 static void DeallocateOldPointerBlock(Address start, |
| 317 static void DeallocateOldDataBlock(Address start, int size_in_bytes); | 321 int size_in_bytes, |
| 318 static void DeallocateCodeBlock(Address start, int size_in_bytes); | 322 bool add_to_freelist); |
| 319 static void DeallocateMapBlock(Address start, int size_in_bytes); | 323 |
| 320 static void DeallocateCellBlock(Address start, int size_in_bytes); | 324 static void DeallocateOldDataBlock(Address start, |
| 325 int size_in_bytes, |
| 326 bool add_to_freelist); |
| 327 |
| 328 static void DeallocateCodeBlock(Address start, |
| 329 int size_in_bytes, |
| 330 bool add_to_freelist); |
| 331 |
| 332 static void DeallocateMapBlock(Address start, |
| 333 int size_in_bytes, |
| 334 bool add_to_freelist); |
| 335 |
| 336 static void DeallocateCellBlock(Address start, |
| 337 int size_in_bytes, |
| 338 bool add_to_freelist); |
| 321 | 339 |
| 322 // If we are not compacting the heap, we simply sweep the spaces except | 340 // If we are not compacting the heap, we simply sweep the spaces except |
| 323 // for the large object space, clearing mark bits and adding unmarked | 341 // for the large object space, clearing mark bits and adding unmarked |
| 324 // regions to each space's free list. | 342 // regions to each space's free list. |
| 325 static void SweepSpaces(); | 343 static void SweepSpaces(); |
| 326 | 344 |
| 327 // ----------------------------------------------------------------------- | 345 // ----------------------------------------------------------------------- |
| 328 // Phase 3: Updating pointers in live objects. | 346 // Phase 3: Updating pointers in live objects. |
| 329 // | 347 // |
| 330 // Before: Same as after phase 2 (compacting collection). | 348 // Before: Same as after phase 2 (compacting collection). |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 436 | 454 |
| 437 friend class UnmarkObjectVisitor; | 455 friend class UnmarkObjectVisitor; |
| 438 static void UnmarkObject(HeapObject* obj); | 456 static void UnmarkObject(HeapObject* obj); |
| 439 #endif | 457 #endif |
| 440 }; | 458 }; |
| 441 | 459 |
| 442 | 460 |
| 443 } } // namespace v8::internal | 461 } } // namespace v8::internal |
| 444 | 462 |
| 445 #endif // V8_MARK_COMPACT_H_ | 463 #endif // V8_MARK_COMPACT_H_ |
| OLD | NEW |