Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(55)

Side by Side Diff: third_party/WebKit/Source/platform/heap/Heap.cpp

Issue 1804863002: Refactor RegionTree (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixed Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 delete s_orphanedPagePool; 154 delete s_orphanedPagePool;
155 s_orphanedPagePool = nullptr; 155 s_orphanedPagePool = nullptr;
156 delete s_globalWeakCallbackStack; 156 delete s_globalWeakCallbackStack;
157 s_globalWeakCallbackStack = nullptr; 157 s_globalWeakCallbackStack = nullptr;
158 delete s_postMarkingCallbackStack; 158 delete s_postMarkingCallbackStack;
159 s_postMarkingCallbackStack = nullptr; 159 s_postMarkingCallbackStack = nullptr;
160 delete s_markingStack; 160 delete s_markingStack;
161 s_markingStack = nullptr; 161 s_markingStack = nullptr;
162 delete s_ephemeronStack; 162 delete s_ephemeronStack;
163 s_ephemeronStack = nullptr; 163 s_ephemeronStack = nullptr;
164 delete s_regionTree;
165 s_regionTree = nullptr;
166 GCInfoTable::shutdown(); 164 GCInfoTable::shutdown();
167 ThreadState::shutdown(); 165 ThreadState::shutdown();
168 ASSERT(Heap::allocatedSpace() == 0); 166 ASSERT(Heap::allocatedSpace() == 0);
169 } 167 }
170 168
171 CrossThreadPersistentRegion& Heap::crossThreadPersistentRegion() 169 CrossThreadPersistentRegion& Heap::crossThreadPersistentRegion()
172 { 170 {
173 DEFINE_THREAD_SAFE_STATIC_LOCAL(CrossThreadPersistentRegion, persistentRegio n, new CrossThreadPersistentRegion()); 171 DEFINE_THREAD_SAFE_STATIC_LOCAL(CrossThreadPersistentRegion, persistentRegio n, new CrossThreadPersistentRegion());
174 return persistentRegion; 172 return persistentRegion;
175 } 173 }
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after
611 state->setGCState(ThreadState::GCRunning); 609 state->setGCState(ThreadState::GCRunning);
612 state->makeConsistentForGC(); 610 state->makeConsistentForGC();
613 objectPayloadSize += state->objectPayloadSizeForTesting(); 611 objectPayloadSize += state->objectPayloadSizeForTesting();
614 state->setGCState(ThreadState::EagerSweepScheduled); 612 state->setGCState(ThreadState::EagerSweepScheduled);
615 state->setGCState(ThreadState::Sweeping); 613 state->setGCState(ThreadState::Sweeping);
616 state->setGCState(ThreadState::NoGCScheduled); 614 state->setGCState(ThreadState::NoGCScheduled);
617 } 615 }
618 return objectPayloadSize; 616 return objectPayloadSize;
619 } 617 }
620 618
619 RegionTree* Heap::getRegionTree()
620 {
621 DEFINE_THREAD_SAFE_STATIC_LOCAL(RegionTree, tree, new RegionTree);
622 return &tree;
623 }
624
621 BasePage* Heap::lookup(Address address) 625 BasePage* Heap::lookup(Address address)
622 { 626 {
623 ASSERT(ThreadState::current()->isInGC()); 627 ASSERT(ThreadState::current()->isInGC());
624 if (!s_regionTree) 628 if (PageMemoryRegion* region = Heap::getRegionTree()->lookup(address)) {
625 return nullptr;
626 if (PageMemoryRegion* region = s_regionTree->lookup(address)) {
627 BasePage* page = region->pageFromAddress(address); 629 BasePage* page = region->pageFromAddress(address);
628 return page && !page->orphaned() ? page : nullptr; 630 return page && !page->orphaned() ? page : nullptr;
629 } 631 }
630 return nullptr; 632 return nullptr;
631 } 633 }
632 634
633 static Mutex& regionTreeMutex()
634 {
635 DEFINE_THREAD_SAFE_STATIC_LOCAL(Mutex, mutex, new Mutex);
636 return mutex;
637 }
638
639 void Heap::removePageMemoryRegion(PageMemoryRegion* region)
640 {
641 // Deletion of large objects (and thus their regions) can happen
642 // concurrently on sweeper threads. Removal can also happen during thread
643 // shutdown, but that case is safe. Regardless, we make all removals
644 // mutually exclusive.
645 MutexLocker locker(regionTreeMutex());
646 RegionTree::remove(region, &s_regionTree);
647 }
648
649 void Heap::addPageMemoryRegion(PageMemoryRegion* region)
650 {
651 MutexLocker locker(regionTreeMutex());
652 RegionTree::add(new RegionTree(region), &s_regionTree);
653 }
654
655 void Heap::resetHeapCounters() 635 void Heap::resetHeapCounters()
656 { 636 {
657 ASSERT(ThreadState::current()->isInGC()); 637 ASSERT(ThreadState::current()->isInGC());
658 638
659 Heap::reportMemoryUsageForTracing(); 639 Heap::reportMemoryUsageForTracing();
660 640
661 s_objectSizeAtLastGC = s_allocatedObjectSize + s_markedObjectSize; 641 s_objectSizeAtLastGC = s_allocatedObjectSize + s_markedObjectSize;
662 s_partitionAllocSizeAtLastGC = WTF::Partitions::totalSizeOfCommittedPages(); 642 s_partitionAllocSizeAtLastGC = WTF::Partitions::totalSizeOfCommittedPages();
663 s_allocatedObjectSize = 0; 643 s_allocatedObjectSize = 0;
664 s_markedObjectSize = 0; 644 s_markedObjectSize = 0;
665 s_wrapperCountAtLastGC = s_wrapperCount; 645 s_wrapperCountAtLastGC = s_wrapperCount;
666 s_collectedWrapperCount = 0; 646 s_collectedWrapperCount = 0;
667 for (ThreadState* state : ThreadState::attachedThreads()) 647 for (ThreadState* state : ThreadState::attachedThreads())
668 state->resetHeapCounters(); 648 state->resetHeapCounters();
669 } 649 }
670 650
671 CallbackStack* Heap::s_markingStack; 651 CallbackStack* Heap::s_markingStack;
672 CallbackStack* Heap::s_postMarkingCallbackStack; 652 CallbackStack* Heap::s_postMarkingCallbackStack;
673 CallbackStack* Heap::s_globalWeakCallbackStack; 653 CallbackStack* Heap::s_globalWeakCallbackStack;
674 CallbackStack* Heap::s_ephemeronStack; 654 CallbackStack* Heap::s_ephemeronStack;
675 HeapDoesNotContainCache* Heap::s_heapDoesNotContainCache; 655 HeapDoesNotContainCache* Heap::s_heapDoesNotContainCache;
676 FreePagePool* Heap::s_freePagePool; 656 FreePagePool* Heap::s_freePagePool;
677 OrphanedPagePool* Heap::s_orphanedPagePool; 657 OrphanedPagePool* Heap::s_orphanedPagePool;
678 RegionTree* Heap::s_regionTree = nullptr;
679 size_t Heap::s_allocatedSpace = 0; 658 size_t Heap::s_allocatedSpace = 0;
680 size_t Heap::s_allocatedObjectSize = 0; 659 size_t Heap::s_allocatedObjectSize = 0;
681 size_t Heap::s_objectSizeAtLastGC = 0; 660 size_t Heap::s_objectSizeAtLastGC = 0;
682 size_t Heap::s_markedObjectSize = 0; 661 size_t Heap::s_markedObjectSize = 0;
683 size_t Heap::s_markedObjectSizeAtLastCompleteSweep = 0; 662 size_t Heap::s_markedObjectSizeAtLastCompleteSweep = 0;
684 size_t Heap::s_wrapperCount = 0; 663 size_t Heap::s_wrapperCount = 0;
685 size_t Heap::s_wrapperCountAtLastGC = 0; 664 size_t Heap::s_wrapperCountAtLastGC = 0;
686 size_t Heap::s_collectedWrapperCount = 0; 665 size_t Heap::s_collectedWrapperCount = 0;
687 size_t Heap::s_partitionAllocSizeAtLastGC = 0; 666 size_t Heap::s_partitionAllocSizeAtLastGC = 0;
688 double Heap::s_estimatedMarkingTimePerByte = 0.0; 667 double Heap::s_estimatedMarkingTimePerByte = 0.0;
689 bool Heap::s_isLowEndDevice = false; 668 bool Heap::s_isLowEndDevice = false;
690 BlinkGC::GCReason Heap::s_lastGCReason = BlinkGC::NumberOfGCReason; 669 BlinkGC::GCReason Heap::s_lastGCReason = BlinkGC::NumberOfGCReason;
691 #if ENABLE(ASSERT) 670 #if ENABLE(ASSERT)
692 uint16_t Heap::s_gcGeneration = 0; 671 uint16_t Heap::s_gcGeneration = 0;
693 #endif 672 #endif
694 673
695 } // namespace blink 674 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/heap/Heap.h ('k') | third_party/WebKit/Source/platform/heap/HeapPage.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698