| 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 18 matching lines...) Expand all Loading... |
| 29 #define V8_MARK_COMPACT_H_ | 29 #define V8_MARK_COMPACT_H_ |
| 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. | |
| 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, | |
| 45 bool last_on_page); | |
| 46 | |
| 47 | |
| 48 // Forward declarations. | 39 // Forward declarations. |
| 49 class RootMarkingVisitor; | 40 class RootMarkingVisitor; |
| 50 class MarkingVisitor; | 41 class MarkingVisitor; |
| 51 | 42 |
| 52 | 43 |
| 53 // ------------------------------------------------------------------------- | 44 // ------------------------------------------------------------------------- |
| 54 // Mark-Compact collector | 45 // Mark-Compact collector |
| 55 // | 46 // |
| 56 // All methods are static. | 47 // All methods are static. |
| 57 | 48 |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 316 // to a callback function which returns the heap size of the object. | 307 // to a callback function which returns the heap size of the object. |
| 317 // Returns the number of live objects iterated. | 308 // Returns the number of live objects iterated. |
| 318 static int IterateLiveObjects(NewSpace* space, HeapObjectCallback size_f); | 309 static int IterateLiveObjects(NewSpace* space, HeapObjectCallback size_f); |
| 319 static int IterateLiveObjects(PagedSpace* space, HeapObjectCallback size_f); | 310 static int IterateLiveObjects(PagedSpace* space, HeapObjectCallback size_f); |
| 320 | 311 |
| 321 // Iterates the live objects between a range of addresses, returning the | 312 // Iterates the live objects between a range of addresses, returning the |
| 322 // number of live objects. | 313 // number of live objects. |
| 323 static int IterateLiveObjectsInRange(Address start, Address end, | 314 static int IterateLiveObjectsInRange(Address start, Address end, |
| 324 HeapObjectCallback size_func); | 315 HeapObjectCallback size_func); |
| 325 | 316 |
| 326 // Callback functions for deallocating non-live blocks in the old | |
| 327 // generation. | |
| 328 static void DeallocateOldPointerBlock(Address start, | |
| 329 int size_in_bytes, | |
| 330 bool add_to_freelist, | |
| 331 bool last_on_page); | |
| 332 | |
| 333 static void DeallocateOldDataBlock(Address start, | |
| 334 int size_in_bytes, | |
| 335 bool add_to_freelist, | |
| 336 bool last_on_page); | |
| 337 | |
| 338 static void DeallocateCodeBlock(Address start, | |
| 339 int size_in_bytes, | |
| 340 bool add_to_freelist, | |
| 341 bool last_on_page); | |
| 342 | |
| 343 static void DeallocateMapBlock(Address start, | |
| 344 int size_in_bytes, | |
| 345 bool add_to_freelist, | |
| 346 bool last_on_page); | |
| 347 | |
| 348 static void DeallocateCellBlock(Address start, | |
| 349 int size_in_bytes, | |
| 350 bool add_to_freelist, | |
| 351 bool last_on_page); | |
| 352 | |
| 353 // If we are not compacting the heap, we simply sweep the spaces except | 317 // If we are not compacting the heap, we simply sweep the spaces except |
| 354 // for the large object space, clearing mark bits and adding unmarked | 318 // for the large object space, clearing mark bits and adding unmarked |
| 355 // regions to each space's free list. | 319 // regions to each space's free list. |
| 356 static void SweepSpaces(); | 320 static void SweepSpaces(); |
| 357 | 321 |
| 358 // ----------------------------------------------------------------------- | 322 // ----------------------------------------------------------------------- |
| 359 // Phase 3: Updating pointers in live objects. | 323 // Phase 3: Updating pointers in live objects. |
| 360 // | 324 // |
| 361 // Before: Same as after phase 2 (compacting collection). | 325 // Before: Same as after phase 2 (compacting collection). |
| 362 // | 326 // |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 450 | 414 |
| 451 friend class UnmarkObjectVisitor; | 415 friend class UnmarkObjectVisitor; |
| 452 static void UnmarkObject(HeapObject* obj); | 416 static void UnmarkObject(HeapObject* obj); |
| 453 #endif | 417 #endif |
| 454 }; | 418 }; |
| 455 | 419 |
| 456 | 420 |
| 457 } } // namespace v8::internal | 421 } } // namespace v8::internal |
| 458 | 422 |
| 459 #endif // V8_MARK_COMPACT_H_ | 423 #endif // V8_MARK_COMPACT_H_ |
| OLD | NEW |