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