| 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 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 293 // bits per map word for the forwarding address. | 293 // bits per map word for the forwarding address. |
| 294 // | 294 // |
| 295 // The Page::mc_first_forwarded field contains the (nonencoded) | 295 // The Page::mc_first_forwarded field contains the (nonencoded) |
| 296 // forwarding address of the first live object in the page. | 296 // forwarding address of the first live object in the page. |
| 297 // | 297 // |
| 298 // In both the new space and the paged spaces, a linked list | 298 // In both the new space and the paged spaces, a linked list |
| 299 // of live regions is constructructed (linked through | 299 // of live regions is constructructed (linked through |
| 300 // pointers in the non-live region immediately following each | 300 // pointers in the non-live region immediately following each |
| 301 // live region) to speed further passes of the collector. | 301 // live region) to speed further passes of the collector. |
| 302 | 302 |
| 303 #ifndef BASELINE_GC |
| 303 // Encodes forwarding addresses of objects in compactable parts of the | 304 // Encodes forwarding addresses of objects in compactable parts of the |
| 304 // heap. | 305 // heap. |
| 305 static void EncodeForwardingAddresses(); | 306 static void EncodeForwardingAddresses(); |
| 306 | 307 |
| 307 // Encodes the forwarding addresses of objects in new space. | 308 // Encodes the forwarding addresses of objects in new space. |
| 308 static void EncodeForwardingAddressesInNewSpace(); | 309 static void EncodeForwardingAddressesInNewSpace(); |
| 309 | 310 |
| 310 // Function template to encode the forwarding addresses of objects in | 311 // Function template to encode the forwarding addresses of objects in |
| 311 // paged spaces, parameterized by allocation and non-live processing | 312 // paged spaces, parameterized by allocation and non-live processing |
| 312 // functions. | 313 // functions. |
| 313 template<AllocationFunction Alloc, ProcessNonLiveFunction ProcessNonLive> | 314 template<AllocationFunction Alloc, ProcessNonLiveFunction ProcessNonLive> |
| 314 static void EncodeForwardingAddressesInPagedSpace(PagedSpace* space); | 315 static void EncodeForwardingAddressesInPagedSpace(PagedSpace* space); |
| 316 #endif |
| 315 | 317 |
| 316 // Iterates live objects in a space, passes live objects | 318 // Iterates live objects in a space, passes live objects |
| 317 // to a callback function which returns the heap size of the object. | 319 // to a callback function which returns the heap size of the object. |
| 318 // Returns the number of live objects iterated. | 320 // Returns the number of live objects iterated. |
| 319 static int IterateLiveObjects(NewSpace* space, HeapObjectCallback size_f); | 321 static int IterateLiveObjects(NewSpace* space, HeapObjectCallback size_f); |
| 320 static int IterateLiveObjects(PagedSpace* space, HeapObjectCallback size_f); | 322 static int IterateLiveObjects(PagedSpace* space, HeapObjectCallback size_f); |
| 321 | 323 |
| 322 // Iterates the live objects between a range of addresses, returning the | 324 // Iterates the live objects between a range of addresses, returning the |
| 323 // number of live objects. | 325 // number of live objects. |
| 324 static int IterateLiveObjectsInRange(Address start, Address end, | 326 static int IterateLiveObjectsInRange(Address start, Address end, |
| 325 HeapObjectCallback size_func); | 327 HeapObjectCallback size_func); |
| 326 | 328 |
| 327 // If we are not compacting the heap, we simply sweep the spaces except | 329 // If we are not compacting the heap, we simply sweep the spaces except |
| 328 // for the large object space, clearing mark bits and adding unmarked | 330 // for the large object space, clearing mark bits and adding unmarked |
| 329 // regions to each space's free list. | 331 // regions to each space's free list. |
| 330 static void SweepSpaces(); | 332 static void SweepSpaces(); |
| 331 | 333 |
| 334 #ifndef BASELINE_GC |
| 332 // ----------------------------------------------------------------------- | 335 // ----------------------------------------------------------------------- |
| 333 // Phase 3: Updating pointers in live objects. | 336 // Phase 3: Updating pointers in live objects. |
| 334 // | 337 // |
| 335 // Before: Same as after phase 2 (compacting collection). | 338 // Before: Same as after phase 2 (compacting collection). |
| 336 // | 339 // |
| 337 // After: All pointers in live objects, including encoded map | 340 // After: All pointers in live objects, including encoded map |
| 338 // pointers, are updated to point to their target's new | 341 // pointers, are updated to point to their target's new |
| 339 // location. | 342 // location. |
| 340 | 343 |
| 341 friend class UpdatingVisitor; // helper for updating visited objects | 344 friend class UpdatingVisitor; // helper for updating visited objects |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 381 | 384 |
| 382 // Helper function. | 385 // Helper function. |
| 383 static inline int RelocateOldNonCodeObject(HeapObject* obj, | 386 static inline int RelocateOldNonCodeObject(HeapObject* obj, |
| 384 PagedSpace* space); | 387 PagedSpace* space); |
| 385 | 388 |
| 386 // Relocates an object in the code space. | 389 // Relocates an object in the code space. |
| 387 static int RelocateCodeObject(HeapObject* obj); | 390 static int RelocateCodeObject(HeapObject* obj); |
| 388 | 391 |
| 389 // Copy a new object. | 392 // Copy a new object. |
| 390 static int RelocateNewObject(HeapObject* obj); | 393 static int RelocateNewObject(HeapObject* obj); |
| 394 #endif |
| 391 | 395 |
| 392 #ifdef DEBUG | 396 #ifdef DEBUG |
| 393 // ----------------------------------------------------------------------- | 397 // ----------------------------------------------------------------------- |
| 394 // Debugging variables, functions and classes | 398 // Debugging variables, functions and classes |
| 395 // Counters used for debugging the marking phase of mark-compact or | 399 // Counters used for debugging the marking phase of mark-compact or |
| 396 // mark-sweep collection. | 400 // mark-sweep collection. |
| 397 | 401 |
| 398 // Size of live objects in Heap::to_space_. | 402 // Size of live objects in Heap::to_space_. |
| 399 static int live_young_objects_size_; | 403 static int live_young_objects_size_; |
| 400 | 404 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 424 | 428 |
| 425 friend class UnmarkObjectVisitor; | 429 friend class UnmarkObjectVisitor; |
| 426 static void UnmarkObject(HeapObject* obj); | 430 static void UnmarkObject(HeapObject* obj); |
| 427 #endif | 431 #endif |
| 428 }; | 432 }; |
| 429 | 433 |
| 430 | 434 |
| 431 } } // namespace v8::internal | 435 } } // namespace v8::internal |
| 432 | 436 |
| 433 #endif // V8_MARK_COMPACT_H_ | 437 #endif // V8_MARK_COMPACT_H_ |
| OLD | NEW |