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 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 size_t m_objectSizeAtLastGC; | 213 size_t m_objectSizeAtLastGC; |
214 size_t m_markedObjectSize; | 214 size_t m_markedObjectSize; |
215 size_t m_markedObjectSizeAtLastCompleteSweep; | 215 size_t m_markedObjectSizeAtLastCompleteSweep; |
216 size_t m_wrapperCount; | 216 size_t m_wrapperCount; |
217 size_t m_wrapperCountAtLastGC; | 217 size_t m_wrapperCountAtLastGC; |
218 size_t m_collectedWrapperCount; | 218 size_t m_collectedWrapperCount; |
219 size_t m_partitionAllocSizeAtLastGC; | 219 size_t m_partitionAllocSizeAtLastGC; |
220 double m_estimatedMarkingTimePerByte; | 220 double m_estimatedMarkingTimePerByte; |
221 }; | 221 }; |
222 | 222 |
223 using ThreadStateSet = HashSet<ThreadState*>; | |
224 | |
225 class PLATFORM_EXPORT ThreadHeap { | 223 class PLATFORM_EXPORT ThreadHeap { |
226 public: | 224 public: |
227 ThreadHeap(); | 225 explicit ThreadHeap(ThreadState*); |
228 ~ThreadHeap(); | 226 ~ThreadHeap(); |
229 | 227 |
230 // Returns true for main thread's heap. | 228 // Returns true for main thread's heap. |
231 // TODO(keishi): Per-thread-heap will return false. | 229 // TODO(keishi): Per-thread-heap will return false. |
232 bool isMainThreadHeap() { return this == ThreadHeap::mainThreadHeap(); } | 230 bool isMainThreadHeap() { return this == ThreadHeap::mainThreadHeap(); } |
233 static ThreadHeap* mainThreadHeap() { return s_mainThreadHeap; } | 231 static ThreadHeap* mainThreadHeap() { return s_mainThreadHeap; } |
234 | 232 |
235 #if DCHECK_IS_ON() | 233 #if DCHECK_IS_ON() |
236 bool isAtSafePoint(); | 234 bool isAtSafePoint(); |
237 BasePage* findPageFromAddress(Address); | 235 BasePage* findPageFromAddress(Address); |
(...skipping 26 matching lines...) Expand all Loading... |
264 static inline bool isHeapObjectAlive(const WeakMember<T>& member) { | 262 static inline bool isHeapObjectAlive(const WeakMember<T>& member) { |
265 return isHeapObjectAlive(member.get()); | 263 return isHeapObjectAlive(member.get()); |
266 } | 264 } |
267 template <typename T> | 265 template <typename T> |
268 static inline bool isHeapObjectAlive(const UntracedMember<T>& member) { | 266 static inline bool isHeapObjectAlive(const UntracedMember<T>& member) { |
269 return isHeapObjectAlive(member.get()); | 267 return isHeapObjectAlive(member.get()); |
270 } | 268 } |
271 | 269 |
272 StackFrameDepth& stackFrameDepth() { return m_stackFrameDepth; } | 270 StackFrameDepth& stackFrameDepth() { return m_stackFrameDepth; } |
273 | 271 |
274 RecursiveMutex& threadAttachMutex() { return m_threadAttachMutex; } | |
275 const ThreadStateSet& threads() const { return m_threads; } | |
276 ThreadHeapStats& heapStats() { return m_stats; } | 272 ThreadHeapStats& heapStats() { return m_stats; } |
277 SafePointBarrier* safePointBarrier() { return m_safePointBarrier.get(); } | 273 SafePointBarrier* safePointBarrier() { return m_safePointBarrier.get(); } |
278 CallbackStack* markingStack() const { return m_markingStack.get(); } | 274 CallbackStack* markingStack() const { return m_markingStack.get(); } |
279 CallbackStack* postMarkingCallbackStack() const { | 275 CallbackStack* postMarkingCallbackStack() const { |
280 return m_postMarkingCallbackStack.get(); | 276 return m_postMarkingCallbackStack.get(); |
281 } | 277 } |
282 CallbackStack* globalWeakCallbackStack() const { | 278 CallbackStack* globalWeakCallbackStack() const { |
283 return m_globalWeakCallbackStack.get(); | 279 return m_globalWeakCallbackStack.get(); |
284 } | 280 } |
285 CallbackStack* ephemeronStack() const { return m_ephemeronStack.get(); } | 281 CallbackStack* ephemeronStack() const { return m_ephemeronStack.get(); } |
286 | 282 |
287 void attach(ThreadState*); | |
288 void detach(ThreadState*); | |
289 void lockThreadAttachMutex(); | |
290 void unlockThreadAttachMutex(); | |
291 | |
292 void visitPersistentRoots(Visitor*); | 283 void visitPersistentRoots(Visitor*); |
293 void visitStackRoots(Visitor*); | 284 void visitStackRoots(Visitor*); |
294 void enterSafePoint(ThreadState*); | 285 void enterSafePoint(ThreadState*); |
295 void leaveSafePoint(); | 286 void leaveSafePoint(); |
296 | 287 |
297 static RecursiveMutex& allHeapsMutex(); | 288 static RecursiveMutex& allHeapsMutex(); |
298 static HashSet<ThreadHeap*>& allHeaps(); | 289 static HashSet<ThreadHeap*>& allHeaps(); |
299 | 290 |
300 // Is the finalizable GC object still alive, but slated for lazy sweeping? | 291 // Is the finalizable GC object still alive, but slated for lazy sweeping? |
301 // If a lazy sweep is in progress, returns true if the object was found | 292 // If a lazy sweep is in progress, returns true if the object was found |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
452 private: | 443 private: |
453 // Reset counters that track live and allocated-since-last-GC sizes. | 444 // Reset counters that track live and allocated-since-last-GC sizes. |
454 void resetHeapCounters(); | 445 void resetHeapCounters(); |
455 | 446 |
456 static int arenaIndexForObjectSize(size_t); | 447 static int arenaIndexForObjectSize(size_t); |
457 static bool isNormalArenaIndex(int); | 448 static bool isNormalArenaIndex(int); |
458 | 449 |
459 void commitCallbackStacks(); | 450 void commitCallbackStacks(); |
460 void decommitCallbackStacks(); | 451 void decommitCallbackStacks(); |
461 | 452 |
462 RecursiveMutex m_threadAttachMutex; | 453 ThreadState* m_threadState; |
463 ThreadStateSet m_threads; | |
464 ThreadHeapStats m_stats; | 454 ThreadHeapStats m_stats; |
465 std::unique_ptr<RegionTree> m_regionTree; | 455 std::unique_ptr<RegionTree> m_regionTree; |
466 std::unique_ptr<HeapDoesNotContainCache> m_heapDoesNotContainCache; | 456 std::unique_ptr<HeapDoesNotContainCache> m_heapDoesNotContainCache; |
467 std::unique_ptr<SafePointBarrier> m_safePointBarrier; | 457 std::unique_ptr<SafePointBarrier> m_safePointBarrier; |
468 std::unique_ptr<PagePool> m_freePagePool; | 458 std::unique_ptr<PagePool> m_freePagePool; |
469 std::unique_ptr<CallbackStack> m_markingStack; | 459 std::unique_ptr<CallbackStack> m_markingStack; |
470 std::unique_ptr<CallbackStack> m_postMarkingCallbackStack; | 460 std::unique_ptr<CallbackStack> m_postMarkingCallbackStack; |
471 std::unique_ptr<CallbackStack> m_globalWeakCallbackStack; | 461 std::unique_ptr<CallbackStack> m_globalWeakCallbackStack; |
472 std::unique_ptr<CallbackStack> m_ephemeronStack; | 462 std::unique_ptr<CallbackStack> m_ephemeronStack; |
473 BlinkGC::GCReason m_lastGCReason; | 463 BlinkGC::GCReason m_lastGCReason; |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
683 T** cell = reinterpret_cast<T**>(object); | 673 T** cell = reinterpret_cast<T**>(object); |
684 if (*cell && !ObjectAliveTrait<T>::isHeapObjectAlive(*cell)) | 674 if (*cell && !ObjectAliveTrait<T>::isHeapObjectAlive(*cell)) |
685 *cell = nullptr; | 675 *cell = nullptr; |
686 } | 676 } |
687 | 677 |
688 } // namespace blink | 678 } // namespace blink |
689 | 679 |
690 #include "platform/heap/VisitorImpl.h" | 680 #include "platform/heap/VisitorImpl.h" |
691 | 681 |
692 #endif // Heap_h | 682 #endif // Heap_h |
OLD | NEW |