OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 if (UNLIKELY(!!freeHook)) | 74 if (UNLIKELY(!!freeHook)) |
75 freeHook(address); | 75 freeHook(address); |
76 } | 76 } |
77 | 77 |
78 private: | 78 private: |
79 static AllocationHook* m_allocationHook; | 79 static AllocationHook* m_allocationHook; |
80 static FreeHook* m_freeHook; | 80 static FreeHook* m_freeHook; |
81 }; | 81 }; |
82 | 82 |
83 class CrossThreadPersistentRegion; | 83 class CrossThreadPersistentRegion; |
| 84 class HeapCompact; |
84 template <typename T> | 85 template <typename T> |
85 class Member; | 86 class Member; |
86 template <typename T> | 87 template <typename T> |
87 class WeakMember; | 88 class WeakMember; |
88 template <typename T> | 89 template <typename T> |
89 class UntracedMember; | 90 class UntracedMember; |
90 | 91 |
91 template <typename T, bool = NeedsAdjustAndMark<T>::value> | 92 template <typename T, bool = NeedsAdjustAndMark<T>::value> |
92 class ObjectAliveTrait; | 93 class ObjectAliveTrait; |
93 | 94 |
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
374 bool popAndInvokeGlobalWeakCallback(Visitor*); | 375 bool popAndInvokeGlobalWeakCallback(Visitor*); |
375 | 376 |
376 // Register an ephemeron table for fixed-point iteration. | 377 // Register an ephemeron table for fixed-point iteration. |
377 void registerWeakTable(void* containerObject, | 378 void registerWeakTable(void* containerObject, |
378 EphemeronCallback, | 379 EphemeronCallback, |
379 EphemeronCallback); | 380 EphemeronCallback); |
380 #if ENABLE(ASSERT) | 381 #if ENABLE(ASSERT) |
381 bool weakTableRegistered(const void*); | 382 bool weakTableRegistered(const void*); |
382 #endif | 383 #endif |
383 | 384 |
| 385 // Heap compaction registration methods: |
| 386 |
| 387 // Register |slot| as containing a reference to a movable heap object. |
| 388 // |
| 389 // When compaction moves the object pointed to by |*slot| to |newAddress|, |
| 390 // |*slot| must be updated to hold |newAddress| instead. |
| 391 void registerMovingObjectReference(MovableReference*); |
| 392 |
| 393 // Register a callback to be invoked upon moving the object starting at |
| 394 // |reference|; see |MovingObjectCallback| documentation for details. |
| 395 // |
| 396 // This callback mechanism is needed to account for backing store objects |
| 397 // containing intra-object pointers, all of which must be relocated/rebased |
| 398 // with respect to the moved-to location. |
| 399 // |
| 400 // For Blink, |HeapLinkedHashSet<>| is currently the only abstraction which |
| 401 // relies on this feature. |
| 402 void registerMovingObjectCallback(MovableReference, |
| 403 MovingObjectCallback, |
| 404 void* callbackData); |
| 405 |
384 BlinkGC::GCReason lastGCReason() { return m_lastGCReason; } | 406 BlinkGC::GCReason lastGCReason() { return m_lastGCReason; } |
385 RegionTree* getRegionTree() { return m_regionTree.get(); } | 407 RegionTree* getRegionTree() { return m_regionTree.get(); } |
386 | 408 |
387 static inline size_t allocationSizeFromSize(size_t size) { | 409 static inline size_t allocationSizeFromSize(size_t size) { |
388 // Add space for header. | 410 // Add space for header. |
389 size_t allocationSize = size + sizeof(HeapObjectHeader); | 411 size_t allocationSize = size + sizeof(HeapObjectHeader); |
390 // The allocation size calculation can overflow for large sizes. | 412 // The allocation size calculation can overflow for large sizes. |
391 RELEASE_ASSERT(allocationSize > size); | 413 RELEASE_ASSERT(allocationSize > size); |
392 // Align size with allocation granularity. | 414 // Align size with allocation granularity. |
393 allocationSize = (allocationSize + allocationMask) & ~allocationMask; | 415 allocationSize = (allocationSize + allocationMask) & ~allocationMask; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
431 ASSERT(gcInfoIndex < GCInfoTable::maxIndex); | 453 ASSERT(gcInfoIndex < GCInfoTable::maxIndex); |
432 ASSERT(s_gcInfoTable); | 454 ASSERT(s_gcInfoTable); |
433 const GCInfo* info = s_gcInfoTable[gcInfoIndex]; | 455 const GCInfo* info = s_gcInfoTable[gcInfoIndex]; |
434 ASSERT(info); | 456 ASSERT(info); |
435 return info; | 457 return info; |
436 } | 458 } |
437 | 459 |
438 static void reportMemoryUsageHistogram(); | 460 static void reportMemoryUsageHistogram(); |
439 static void reportMemoryUsageForTracing(); | 461 static void reportMemoryUsageForTracing(); |
440 | 462 |
| 463 HeapCompact* compaction(); |
| 464 |
441 private: | 465 private: |
442 // Reset counters that track live and allocated-since-last-GC sizes. | 466 // Reset counters that track live and allocated-since-last-GC sizes. |
443 void resetHeapCounters(); | 467 void resetHeapCounters(); |
444 | 468 |
445 static int arenaIndexForObjectSize(size_t); | 469 static int arenaIndexForObjectSize(size_t); |
446 static bool isNormalArenaIndex(int); | 470 static bool isNormalArenaIndex(int); |
447 | 471 |
448 void commitCallbackStacks(); | 472 void commitCallbackStacks(); |
449 void decommitCallbackStacks(); | 473 void decommitCallbackStacks(); |
450 | 474 |
451 RecursiveMutex m_threadAttachMutex; | 475 RecursiveMutex m_threadAttachMutex; |
452 ThreadStateSet m_threads; | 476 ThreadStateSet m_threads; |
453 ThreadHeapStats m_stats; | 477 ThreadHeapStats m_stats; |
454 std::unique_ptr<RegionTree> m_regionTree; | 478 std::unique_ptr<RegionTree> m_regionTree; |
455 std::unique_ptr<HeapDoesNotContainCache> m_heapDoesNotContainCache; | 479 std::unique_ptr<HeapDoesNotContainCache> m_heapDoesNotContainCache; |
456 std::unique_ptr<SafePointBarrier> m_safePointBarrier; | 480 std::unique_ptr<SafePointBarrier> m_safePointBarrier; |
457 std::unique_ptr<FreePagePool> m_freePagePool; | 481 std::unique_ptr<FreePagePool> m_freePagePool; |
458 std::unique_ptr<OrphanedPagePool> m_orphanedPagePool; | 482 std::unique_ptr<OrphanedPagePool> m_orphanedPagePool; |
459 std::unique_ptr<CallbackStack> m_markingStack; | 483 std::unique_ptr<CallbackStack> m_markingStack; |
460 std::unique_ptr<CallbackStack> m_postMarkingCallbackStack; | 484 std::unique_ptr<CallbackStack> m_postMarkingCallbackStack; |
461 std::unique_ptr<CallbackStack> m_globalWeakCallbackStack; | 485 std::unique_ptr<CallbackStack> m_globalWeakCallbackStack; |
462 std::unique_ptr<CallbackStack> m_ephemeronStack; | 486 std::unique_ptr<CallbackStack> m_ephemeronStack; |
463 BlinkGC::GCReason m_lastGCReason; | 487 BlinkGC::GCReason m_lastGCReason; |
464 StackFrameDepth m_stackFrameDepth; | 488 StackFrameDepth m_stackFrameDepth; |
465 | 489 |
| 490 std::unique_ptr<HeapCompact> m_compaction; |
| 491 |
466 static ThreadHeap* s_mainThreadHeap; | 492 static ThreadHeap* s_mainThreadHeap; |
467 | 493 |
468 friend class ThreadState; | 494 friend class ThreadState; |
469 }; | 495 }; |
470 | 496 |
471 template <typename T> | 497 template <typename T> |
472 struct IsEagerlyFinalizedType { | 498 struct IsEagerlyFinalizedType { |
473 STATIC_ONLY(IsEagerlyFinalizedType); | 499 STATIC_ONLY(IsEagerlyFinalizedType); |
474 | 500 |
475 private: | 501 private: |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
670 template <typename T> | 696 template <typename T> |
671 void VisitorHelper<Derived>::handleWeakCell(Visitor* self, void* object) { | 697 void VisitorHelper<Derived>::handleWeakCell(Visitor* self, void* object) { |
672 T** cell = reinterpret_cast<T**>(object); | 698 T** cell = reinterpret_cast<T**>(object); |
673 if (*cell && !ObjectAliveTrait<T>::isHeapObjectAlive(*cell)) | 699 if (*cell && !ObjectAliveTrait<T>::isHeapObjectAlive(*cell)) |
674 *cell = nullptr; | 700 *cell = nullptr; |
675 } | 701 } |
676 | 702 |
677 } // namespace blink | 703 } // namespace blink |
678 | 704 |
679 #endif // Heap_h | 705 #endif // Heap_h |
OLD | NEW |