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 1890 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1901 m_entries[index] = cachePage; | 1901 m_entries[index] = cachePage; |
1902 } | 1902 } |
1903 | 1903 |
1904 void Heap::flushHeapDoesNotContainCache() | 1904 void Heap::flushHeapDoesNotContainCache() |
1905 { | 1905 { |
1906 s_heapDoesNotContainCache->flush(); | 1906 s_heapDoesNotContainCache->flush(); |
1907 } | 1907 } |
1908 | 1908 |
1909 enum MarkingMode { | 1909 enum MarkingMode { |
1910 GlobalMarking, | 1910 GlobalMarking, |
1911 ThreadLocalMarking, | 1911 ThreadLocalMarking, // This works only if the thread is terminating. |
| 1912 ZombieMarking, |
1912 }; | 1913 }; |
1913 | 1914 |
1914 template <MarkingMode Mode> | 1915 template <MarkingMode Mode> |
1915 class MarkingVisitor final : public Visitor, public MarkingVisitorImpl<MarkingVi
sitor<Mode>> { | 1916 class MarkingVisitor final : public Visitor, public MarkingVisitorImpl<MarkingVi
sitor<Mode>> { |
1916 public: | 1917 public: |
1917 using Impl = MarkingVisitorImpl<MarkingVisitor<Mode>>; | 1918 using Impl = MarkingVisitorImpl<MarkingVisitor<Mode>>; |
1918 friend class MarkingVisitorImpl<MarkingVisitor<Mode>>; | 1919 friend class MarkingVisitorImpl<MarkingVisitor<Mode>>; |
1919 | 1920 |
1920 #if ENABLE(GC_PROFILING) | 1921 #if ENABLE(GC_PROFILING) |
1921 using LiveObjectSet = HashSet<uintptr_t>; | 1922 using LiveObjectSet = HashSet<uintptr_t>; |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2080 #endif | 2081 #endif |
2081 | 2082 |
2082 protected: | 2083 protected: |
2083 virtual void registerWeakCellWithCallback(void** cell, WeakPointerCallback c
allback) override | 2084 virtual void registerWeakCellWithCallback(void** cell, WeakPointerCallback c
allback) override |
2084 { | 2085 { |
2085 Impl::registerWeakCellWithCallback(cell, callback); | 2086 Impl::registerWeakCellWithCallback(cell, callback); |
2086 } | 2087 } |
2087 | 2088 |
2088 inline bool shouldMarkObject(const void* objectPointer) | 2089 inline bool shouldMarkObject(const void* objectPointer) |
2089 { | 2090 { |
2090 if (Mode != ThreadLocalMarking) | 2091 if (Mode == GlobalMarking) |
2091 return true; | 2092 return true; |
2092 | 2093 |
2093 BaseHeapPage* page = pageFromObject(objectPointer); | 2094 if (Mode == ThreadLocalMarking) { |
2094 ASSERT(!page->orphaned()); | 2095 BaseHeapPage* page = pageFromObject(objectPointer); |
2095 // When doing a thread local GC, the marker checks if | 2096 ASSERT(!page->orphaned()); |
2096 // the object resides in another thread's heap. If it | 2097 // When doing a thread local GC, the marker checks if the object |
2097 // does, the object should not be marked & traced. | 2098 // resides in another thread's heap. If it does, the object should |
2098 return page->terminating(); | 2099 // not be marked & traced. |
| 2100 return page->terminating(); |
| 2101 } |
| 2102 |
| 2103 // ZombieMarking case. Any objects must not be owned by other threads. |
| 2104 ASSERT(ThreadState::current()->findPageFromAddress(objectPointer)); |
| 2105 return true; |
2099 } | 2106 } |
2100 | 2107 |
2101 #if ENABLE(ASSERT) | 2108 #if ENABLE(ASSERT) |
2102 virtual void checkMarkingAllowed() override | 2109 virtual void checkMarkingAllowed() override |
2103 { | 2110 { |
2104 ASSERT(ThreadState::current()->isInGC()); | 2111 ASSERT(ThreadState::current()->isInGC()); |
2105 } | 2112 } |
2106 #endif | 2113 #endif |
2107 }; | 2114 }; |
2108 | 2115 |
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2429 if (Platform::current()) { | 2436 if (Platform::current()) { |
2430 Platform::current()->histogramCustomCounts("BlinkGC.CollectGarbage", WTF
::currentTimeMS() - timeStamp, 0, 10 * 1000, 50); | 2437 Platform::current()->histogramCustomCounts("BlinkGC.CollectGarbage", WTF
::currentTimeMS() - timeStamp, 0, 10 * 1000, 50); |
2431 Platform::current()->histogramCustomCounts("BlinkGC.TotalObjectSpace", H
eap::allocatedObjectSize() / 1024, 0, 4 * 1024 * 1024, 50); | 2438 Platform::current()->histogramCustomCounts("BlinkGC.TotalObjectSpace", H
eap::allocatedObjectSize() / 1024, 0, 4 * 1024 * 1024, 50); |
2432 Platform::current()->histogramCustomCounts("BlinkGC.TotalAllocatedSpace"
, Heap::allocatedSpace() / 1024, 0, 4 * 1024 * 1024, 50); | 2439 Platform::current()->histogramCustomCounts("BlinkGC.TotalAllocatedSpace"
, Heap::allocatedSpace() / 1024, 0, 4 * 1024 * 1024, 50); |
2433 } | 2440 } |
2434 | 2441 |
2435 if (state->isMainThread()) | 2442 if (state->isMainThread()) |
2436 ScriptForbiddenScope::exit(); | 2443 ScriptForbiddenScope::exit(); |
2437 } | 2444 } |
2438 | 2445 |
| 2446 void Heap::visitObjects(ThreadState* state, const HashSet<void*>& objects) |
| 2447 { |
| 2448 MarkingVisitor<ZombieMarking> visitor; |
| 2449 ThreadState::NoAllocationScope noAllocationScope(state); |
| 2450 for (void* address : objects) |
| 2451 checkAndMarkPointer(&visitor, reinterpret_cast<Address>(address)); |
| 2452 processMarkingStack(&visitor); |
| 2453 postMarkingProcessing(&visitor); |
| 2454 globalWeakProcessing(&visitor); |
| 2455 } |
| 2456 |
2439 void Heap::collectGarbageForTerminatingThread(ThreadState* state) | 2457 void Heap::collectGarbageForTerminatingThread(ThreadState* state) |
2440 { | 2458 { |
2441 // We explicitly do not enter a safepoint while doing thread specific | 2459 // We explicitly do not enter a safepoint while doing thread specific |
2442 // garbage collection since we don't want to allow a global GC at the | 2460 // garbage collection since we don't want to allow a global GC at the |
2443 // same time as a thread local GC. | 2461 // same time as a thread local GC. |
2444 { | 2462 { |
2445 MarkingVisitor<ThreadLocalMarking> markingVisitor; | 2463 MarkingVisitor<ThreadLocalMarking> markingVisitor; |
2446 ThreadState::NoAllocationScope noAllocationScope(state); | 2464 ThreadState::NoAllocationScope noAllocationScope(state); |
2447 | 2465 |
2448 state->preGC(); | 2466 state->preGC(); |
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2778 bool Heap::s_shutdownCalled = false; | 2796 bool Heap::s_shutdownCalled = false; |
2779 bool Heap::s_lastGCWasConservative = false; | 2797 bool Heap::s_lastGCWasConservative = false; |
2780 FreePagePool* Heap::s_freePagePool; | 2798 FreePagePool* Heap::s_freePagePool; |
2781 OrphanedPagePool* Heap::s_orphanedPagePool; | 2799 OrphanedPagePool* Heap::s_orphanedPagePool; |
2782 Heap::RegionTree* Heap::s_regionTree = nullptr; | 2800 Heap::RegionTree* Heap::s_regionTree = nullptr; |
2783 size_t Heap::s_allocatedObjectSize = 0; | 2801 size_t Heap::s_allocatedObjectSize = 0; |
2784 size_t Heap::s_allocatedSpace = 0; | 2802 size_t Heap::s_allocatedSpace = 0; |
2785 size_t Heap::s_markedObjectSize = 0; | 2803 size_t Heap::s_markedObjectSize = 0; |
2786 | 2804 |
2787 } // namespace blink | 2805 } // namespace blink |
OLD | NEW |