| 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 2672 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2683 { | 2683 { |
| 2684 for (HeapPage<Header>* page = m_firstPage; page; page = page->next()) { | 2684 for (HeapPage<Header>* page = m_firstPage; page; page = page->next()) { |
| 2685 page->setTerminating(); | 2685 page->setTerminating(); |
| 2686 } | 2686 } |
| 2687 for (LargeHeapObject<Header>* current = m_firstLargeHeapObject; current; cur
rent = current->next()) { | 2687 for (LargeHeapObject<Header>* current = m_firstLargeHeapObject; current; cur
rent = current->next()) { |
| 2688 current->setTerminating(); | 2688 current->setTerminating(); |
| 2689 } | 2689 } |
| 2690 } | 2690 } |
| 2691 | 2691 |
| 2692 template<typename Header> | 2692 template<typename Header> |
| 2693 BaseHeap* ThreadHeap<Header>::split(int numberOfNormalPages) | 2693 PassOwnPtr<BaseHeap> ThreadHeap<Header>::split(int numberOfNormalPages) |
| 2694 { | 2694 { |
| 2695 // Create a new split off thread heap containing | 2695 // Create a new split off thread heap containing |
| 2696 // |numberOfNormalPages| of the pages of this ThreadHeap for | 2696 // |numberOfNormalPages| of the pages of this ThreadHeap for |
| 2697 // parallel sweeping. The split off thread heap will be merged | 2697 // parallel sweeping. The split off thread heap will be merged |
| 2698 // with this heap at the end of sweeping and the temporary | 2698 // with this heap at the end of sweeping and the temporary |
| 2699 // ThreadHeap object will be deallocated after the merge. | 2699 // ThreadHeap object will be deallocated after the merge. |
| 2700 ASSERT(numberOfNormalPages > 0); | 2700 ASSERT(numberOfNormalPages > 0); |
| 2701 ThreadHeap<Header>* splitOff = new ThreadHeap(m_threadState, m_index); | 2701 OwnPtr<ThreadHeap<Header>> splitOff = adoptPtr(new ThreadHeap(m_threadState,
m_index)); |
| 2702 HeapPage<Header>* splitPoint = m_firstPage; | 2702 HeapPage<Header>* splitPoint = m_firstPage; |
| 2703 for (int i = 1; i < numberOfNormalPages; i++) | 2703 for (int i = 1; i < numberOfNormalPages; i++) |
| 2704 splitPoint = splitPoint->next(); | 2704 splitPoint = splitPoint->next(); |
| 2705 splitOff->m_firstPage = m_firstPage; | 2705 splitOff->m_firstPage = m_firstPage; |
| 2706 m_firstPage = splitPoint->m_next; | 2706 m_firstPage = splitPoint->m_next; |
| 2707 splitOff->m_mergePoint = splitPoint; | 2707 splitOff->m_mergePoint = splitPoint; |
| 2708 splitOff->m_numberOfNormalPages = numberOfNormalPages; | 2708 splitOff->m_numberOfNormalPages = numberOfNormalPages; |
| 2709 m_numberOfNormalPages -= numberOfNormalPages; | 2709 m_numberOfNormalPages -= numberOfNormalPages; |
| 2710 splitPoint->m_next = 0; | 2710 splitPoint->m_next = 0; |
| 2711 return splitOff; | 2711 return splitOff.release(); |
| 2712 } | 2712 } |
| 2713 | 2713 |
| 2714 template<typename Header> | 2714 template<typename Header> |
| 2715 void ThreadHeap<Header>::merge(BaseHeap* splitOffBase) | 2715 void ThreadHeap<Header>::merge(PassOwnPtr<BaseHeap> splitOffBase) |
| 2716 { | 2716 { |
| 2717 ThreadHeap<Header>* splitOff = static_cast<ThreadHeap<Header>*>(splitOffBase
); | 2717 ThreadHeap<Header>* splitOff = static_cast<ThreadHeap<Header>*>(splitOffBase
.get()); |
| 2718 // If the mergePoint is zero all split off pages became empty in | 2718 // If the mergePoint is zero all split off pages became empty in |
| 2719 // this round and we don't have to merge. There are no pages and | 2719 // this round and we don't have to merge. There are no pages and |
| 2720 // nothing on the freelists. | 2720 // nothing on the freelists. |
| 2721 ASSERT(splitOff->m_mergePoint || splitOff->m_numberOfNormalPages == 0); | 2721 ASSERT(splitOff->m_mergePoint || splitOff->m_numberOfNormalPages == 0); |
| 2722 if (splitOff->m_mergePoint) { | 2722 if (splitOff->m_mergePoint) { |
| 2723 // Link the split off pages into the beginning of the list again. | 2723 // Link the split off pages into the beginning of the list again. |
| 2724 splitOff->m_mergePoint->m_next = m_firstPage; | 2724 splitOff->m_mergePoint->m_next = m_firstPage; |
| 2725 m_firstPage = splitOff->m_firstPage; | 2725 m_firstPage = splitOff->m_firstPage; |
| 2726 m_numberOfNormalPages += splitOff->m_numberOfNormalPages; | 2726 m_numberOfNormalPages += splitOff->m_numberOfNormalPages; |
| 2727 splitOff->m_firstPage = 0; | 2727 splitOff->m_firstPage = 0; |
| 2728 // Merge free lists. | 2728 // Merge free lists. |
| 2729 for (size_t i = 0; i < blinkPageSizeLog2; i++) { | 2729 for (size_t i = 0; i < blinkPageSizeLog2; i++) { |
| 2730 if (!m_freeLists[i]) { | 2730 if (!m_freeLists[i]) { |
| 2731 m_freeLists[i] = splitOff->m_freeLists[i]; | 2731 m_freeLists[i] = splitOff->m_freeLists[i]; |
| 2732 } else if (splitOff->m_freeLists[i]) { | 2732 } else if (splitOff->m_freeLists[i]) { |
| 2733 m_lastFreeListEntries[i]->append(splitOff->m_freeLists[i]); | 2733 m_lastFreeListEntries[i]->append(splitOff->m_freeLists[i]); |
| 2734 m_lastFreeListEntries[i] = splitOff->m_lastFreeListEntries[i]; | 2734 m_lastFreeListEntries[i] = splitOff->m_lastFreeListEntries[i]; |
| 2735 } | 2735 } |
| 2736 } | 2736 } |
| 2737 } | 2737 } |
| 2738 delete splitOffBase; | |
| 2739 } | 2738 } |
| 2740 | 2739 |
| 2741 void Heap::getHeapSpaceSize(uint64_t* objectSpaceSize, uint64_t* allocatedSpaceS
ize) | 2740 void Heap::getHeapSpaceSize(uint64_t* objectSpaceSize, uint64_t* allocatedSpaceS
ize) |
| 2742 { | 2741 { |
| 2743 *objectSpaceSize = 0; | 2742 *objectSpaceSize = 0; |
| 2744 *allocatedSpaceSize = 0; | 2743 *allocatedSpaceSize = 0; |
| 2745 ASSERT(ThreadState::isAnyThreadInGC()); | 2744 ASSERT(ThreadState::isAnyThreadInGC()); |
| 2746 ThreadState::AttachedThreadStateSet& threads = ThreadState::attachedThreads(
); | 2745 ThreadState::AttachedThreadStateSet& threads = ThreadState::attachedThreads(
); |
| 2747 typedef ThreadState::AttachedThreadStateSet::iterator ThreadStateIterator; | 2746 typedef ThreadState::AttachedThreadStateSet::iterator ThreadStateIterator; |
| 2748 for (ThreadStateIterator it = threads.begin(), end = threads.end(); it != en
d; ++it) { | 2747 for (ThreadStateIterator it = threads.begin(), end = threads.end(); it != en
d; ++it) { |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2915 CallbackStack* Heap::s_weakCallbackStack; | 2914 CallbackStack* Heap::s_weakCallbackStack; |
| 2916 CallbackStack* Heap::s_ephemeronStack; | 2915 CallbackStack* Heap::s_ephemeronStack; |
| 2917 HeapDoesNotContainCache* Heap::s_heapDoesNotContainCache; | 2916 HeapDoesNotContainCache* Heap::s_heapDoesNotContainCache; |
| 2918 bool Heap::s_shutdownCalled = false; | 2917 bool Heap::s_shutdownCalled = false; |
| 2919 bool Heap::s_lastGCWasConservative = false; | 2918 bool Heap::s_lastGCWasConservative = false; |
| 2920 FreePagePool* Heap::s_freePagePool; | 2919 FreePagePool* Heap::s_freePagePool; |
| 2921 OrphanedPagePool* Heap::s_orphanedPagePool; | 2920 OrphanedPagePool* Heap::s_orphanedPagePool; |
| 2922 Heap::RegionTree* Heap::s_regionTree = 0; | 2921 Heap::RegionTree* Heap::s_regionTree = 0; |
| 2923 | 2922 |
| 2924 } | 2923 } |
| OLD | NEW |