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 1928 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1939 m_entries[index] = cachePage; | 1939 m_entries[index] = cachePage; |
1940 } | 1940 } |
1941 | 1941 |
1942 void Heap::flushHeapDoesNotContainCache() | 1942 void Heap::flushHeapDoesNotContainCache() |
1943 { | 1943 { |
1944 s_heapDoesNotContainCache->flush(); | 1944 s_heapDoesNotContainCache->flush(); |
1945 } | 1945 } |
1946 | 1946 |
1947 enum MarkingMode { | 1947 enum MarkingMode { |
1948 GlobalMarking, | 1948 GlobalMarking, |
1949 ThreadLocalMarking, | 1949 ThreadLocalMarking, // This works only if the thread is terminating. |
| 1950 ZombieMarking, |
1950 }; | 1951 }; |
1951 | 1952 |
1952 template <MarkingMode Mode> | 1953 template <MarkingMode Mode> |
1953 class MarkingVisitor final : public Visitor, public MarkingVisitorImpl<MarkingVi
sitor<Mode>> { | 1954 class MarkingVisitor final : public Visitor, public MarkingVisitorImpl<MarkingVi
sitor<Mode>> { |
1954 public: | 1955 public: |
1955 using Impl = MarkingVisitorImpl<MarkingVisitor<Mode>>; | 1956 using Impl = MarkingVisitorImpl<MarkingVisitor<Mode>>; |
1956 friend class MarkingVisitorImpl<MarkingVisitor<Mode>>; | 1957 friend class MarkingVisitorImpl<MarkingVisitor<Mode>>; |
1957 | 1958 |
1958 #if ENABLE(GC_PROFILING) | 1959 #if ENABLE(GC_PROFILING) |
1959 using LiveObjectSet = HashSet<uintptr_t>; | 1960 using LiveObjectSet = HashSet<uintptr_t>; |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2118 #endif | 2119 #endif |
2119 | 2120 |
2120 protected: | 2121 protected: |
2121 virtual void registerWeakCellWithCallback(void** cell, WeakPointerCallback c
allback) override | 2122 virtual void registerWeakCellWithCallback(void** cell, WeakPointerCallback c
allback) override |
2122 { | 2123 { |
2123 Impl::registerWeakCellWithCallback(cell, callback); | 2124 Impl::registerWeakCellWithCallback(cell, callback); |
2124 } | 2125 } |
2125 | 2126 |
2126 inline bool shouldMarkObject(const void* objectPointer) | 2127 inline bool shouldMarkObject(const void* objectPointer) |
2127 { | 2128 { |
2128 if (Mode != ThreadLocalMarking) | 2129 if (Mode == GlobalMarking) |
2129 return true; | 2130 return true; |
2130 | 2131 |
2131 BasePage* page = pageFromObject(objectPointer); | 2132 if (Mode == ThreadLocalMarking) { |
2132 ASSERT(!page->orphaned()); | 2133 BasePage* page = pageFromObject(objectPointer); |
2133 // When doing a thread local GC, the marker checks if | 2134 ASSERT(!page->orphaned()); |
2134 // the object resides in another thread's heap. If it | 2135 // When doing a thread local GC, the marker checks if the object |
2135 // does, the object should not be marked & traced. | 2136 // resides in another thread's heap. If it does, the object should |
2136 return page->terminating(); | 2137 // not be marked & traced. |
| 2138 return page->terminating(); |
| 2139 } |
| 2140 |
| 2141 // ZombieMarking case. Any objects must not be owned by other threads. |
| 2142 ASSERT(ThreadState::current()->findPageFromAddress(objectPointer)); |
| 2143 return true; |
2137 } | 2144 } |
2138 | 2145 |
2139 #if ENABLE(ASSERT) | 2146 #if ENABLE(ASSERT) |
2140 virtual void checkMarkingAllowed() override | 2147 virtual void checkMarkingAllowed() override |
2141 { | 2148 { |
2142 ASSERT(ThreadState::current()->isInGC()); | 2149 ASSERT(ThreadState::current()->isInGC()); |
2143 } | 2150 } |
2144 #endif | 2151 #endif |
2145 }; | 2152 }; |
2146 | 2153 |
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2469 if (Platform::current()) { | 2476 if (Platform::current()) { |
2470 Platform::current()->histogramCustomCounts("BlinkGC.CollectGarbage", WTF
::currentTimeMS() - timeStamp, 0, 10 * 1000, 50); | 2477 Platform::current()->histogramCustomCounts("BlinkGC.CollectGarbage", WTF
::currentTimeMS() - timeStamp, 0, 10 * 1000, 50); |
2471 Platform::current()->histogramCustomCounts("BlinkGC.TotalObjectSpace", H
eap::allocatedObjectSize() / 1024, 0, 4 * 1024 * 1024, 50); | 2478 Platform::current()->histogramCustomCounts("BlinkGC.TotalObjectSpace", H
eap::allocatedObjectSize() / 1024, 0, 4 * 1024 * 1024, 50); |
2472 Platform::current()->histogramCustomCounts("BlinkGC.TotalAllocatedSpace"
, Heap::allocatedSpace() / 1024, 0, 4 * 1024 * 1024, 50); | 2479 Platform::current()->histogramCustomCounts("BlinkGC.TotalAllocatedSpace"
, Heap::allocatedSpace() / 1024, 0, 4 * 1024 * 1024, 50); |
2473 } | 2480 } |
2474 | 2481 |
2475 if (state->isMainThread()) | 2482 if (state->isMainThread()) |
2476 ScriptForbiddenScope::exit(); | 2483 ScriptForbiddenScope::exit(); |
2477 } | 2484 } |
2478 | 2485 |
| 2486 void Heap::visitObjects(ThreadState* state, const HashSet<void*>& objects) |
| 2487 { |
| 2488 MarkingVisitor<ZombieMarking> visitor; |
| 2489 ThreadState::NoAllocationScope noAllocationScope(state); |
| 2490 for (void* address : objects) |
| 2491 checkAndMarkPointer(&visitor, reinterpret_cast<Address>(address)); |
| 2492 processMarkingStack(&visitor); |
| 2493 postMarkingProcessing(&visitor); |
| 2494 globalWeakProcessing(&visitor); |
| 2495 } |
| 2496 |
2479 void Heap::collectGarbageForTerminatingThread(ThreadState* state) | 2497 void Heap::collectGarbageForTerminatingThread(ThreadState* state) |
2480 { | 2498 { |
2481 // We explicitly do not enter a safepoint while doing thread specific | 2499 // We explicitly do not enter a safepoint while doing thread specific |
2482 // garbage collection since we don't want to allow a global GC at the | 2500 // garbage collection since we don't want to allow a global GC at the |
2483 // same time as a thread local GC. | 2501 // same time as a thread local GC. |
2484 { | 2502 { |
2485 MarkingVisitor<ThreadLocalMarking> markingVisitor; | 2503 MarkingVisitor<ThreadLocalMarking> markingVisitor; |
2486 ThreadState::NoAllocationScope noAllocationScope(state); | 2504 ThreadState::NoAllocationScope noAllocationScope(state); |
2487 | 2505 |
2488 state->preGC(); | 2506 state->preGC(); |
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2806 bool Heap::s_shutdownCalled = false; | 2824 bool Heap::s_shutdownCalled = false; |
2807 bool Heap::s_lastGCWasConservative = false; | 2825 bool Heap::s_lastGCWasConservative = false; |
2808 FreePagePool* Heap::s_freePagePool; | 2826 FreePagePool* Heap::s_freePagePool; |
2809 OrphanedPagePool* Heap::s_orphanedPagePool; | 2827 OrphanedPagePool* Heap::s_orphanedPagePool; |
2810 Heap::RegionTree* Heap::s_regionTree = nullptr; | 2828 Heap::RegionTree* Heap::s_regionTree = nullptr; |
2811 size_t Heap::s_allocatedObjectSize = 0; | 2829 size_t Heap::s_allocatedObjectSize = 0; |
2812 size_t Heap::s_allocatedSpace = 0; | 2830 size_t Heap::s_allocatedSpace = 0; |
2813 size_t Heap::s_markedObjectSize = 0; | 2831 size_t Heap::s_markedObjectSize = 0; |
2814 | 2832 |
2815 } // namespace blink | 2833 } // namespace blink |
OLD | NEW |