| 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 BasePage* findPageFromAddress(Address); | 234 BasePage* findPageFromAddress(Address); |
| 237 #endif | 235 #endif |
| (...skipping 25 matching lines...) Expand all Loading... |
| 263 static inline bool isHeapObjectAlive(const WeakMember<T>& member) { | 261 static inline bool isHeapObjectAlive(const WeakMember<T>& member) { |
| 264 return isHeapObjectAlive(member.get()); | 262 return isHeapObjectAlive(member.get()); |
| 265 } | 263 } |
| 266 template <typename T> | 264 template <typename T> |
| 267 static inline bool isHeapObjectAlive(const UntracedMember<T>& member) { | 265 static inline bool isHeapObjectAlive(const UntracedMember<T>& member) { |
| 268 return isHeapObjectAlive(member.get()); | 266 return isHeapObjectAlive(member.get()); |
| 269 } | 267 } |
| 270 | 268 |
| 271 StackFrameDepth& stackFrameDepth() { return m_stackFrameDepth; } | 269 StackFrameDepth& stackFrameDepth() { return m_stackFrameDepth; } |
| 272 | 270 |
| 273 RecursiveMutex& threadAttachMutex() { return m_threadAttachMutex; } | |
| 274 const ThreadStateSet& threads() const { return m_threads; } | |
| 275 ThreadHeapStats& heapStats() { return m_stats; } | 271 ThreadHeapStats& heapStats() { return m_stats; } |
| 276 CallbackStack* markingStack() const { return m_markingStack.get(); } | 272 CallbackStack* markingStack() const { return m_markingStack.get(); } |
| 277 CallbackStack* postMarkingCallbackStack() const { | 273 CallbackStack* postMarkingCallbackStack() const { |
| 278 return m_postMarkingCallbackStack.get(); | 274 return m_postMarkingCallbackStack.get(); |
| 279 } | 275 } |
| 280 CallbackStack* globalWeakCallbackStack() const { | 276 CallbackStack* globalWeakCallbackStack() const { |
| 281 return m_globalWeakCallbackStack.get(); | 277 return m_globalWeakCallbackStack.get(); |
| 282 } | 278 } |
| 283 CallbackStack* ephemeronStack() const { return m_ephemeronStack.get(); } | 279 CallbackStack* ephemeronStack() const { return m_ephemeronStack.get(); } |
| 284 | 280 |
| 285 void attach(ThreadState*); | |
| 286 void detach(ThreadState*); | |
| 287 void lockThreadAttachMutex(); | |
| 288 void unlockThreadAttachMutex(); | |
| 289 | |
| 290 void visitPersistentRoots(Visitor*); | 281 void visitPersistentRoots(Visitor*); |
| 291 void visitStackRoots(Visitor*); | 282 void visitStackRoots(Visitor*); |
| 292 void enterSafePoint(ThreadState*); | 283 void enterSafePoint(ThreadState*); |
| 293 void leaveSafePoint(); | 284 void leaveSafePoint(); |
| 294 | 285 |
| 295 // Is the finalizable GC object still alive, but slated for lazy sweeping? | 286 // Is the finalizable GC object still alive, but slated for lazy sweeping? |
| 296 // If a lazy sweep is in progress, returns true if the object was found | 287 // If a lazy sweep is in progress, returns true if the object was found |
| 297 // to be not reachable during the marking phase, but it has yet to be swept | 288 // to be not reachable during the marking phase, but it has yet to be swept |
| 298 // and finalized. The predicate returns false in all other cases. | 289 // and finalized. The predicate returns false in all other cases. |
| 299 // | 290 // |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 447 private: | 438 private: |
| 448 // Reset counters that track live and allocated-since-last-GC sizes. | 439 // Reset counters that track live and allocated-since-last-GC sizes. |
| 449 void resetHeapCounters(); | 440 void resetHeapCounters(); |
| 450 | 441 |
| 451 static int arenaIndexForObjectSize(size_t); | 442 static int arenaIndexForObjectSize(size_t); |
| 452 static bool isNormalArenaIndex(int); | 443 static bool isNormalArenaIndex(int); |
| 453 | 444 |
| 454 void commitCallbackStacks(); | 445 void commitCallbackStacks(); |
| 455 void decommitCallbackStacks(); | 446 void decommitCallbackStacks(); |
| 456 | 447 |
| 457 RecursiveMutex m_threadAttachMutex; | 448 ThreadState* m_threadState; |
| 458 ThreadStateSet m_threads; | |
| 459 ThreadHeapStats m_stats; | 449 ThreadHeapStats m_stats; |
| 460 std::unique_ptr<RegionTree> m_regionTree; | 450 std::unique_ptr<RegionTree> m_regionTree; |
| 461 std::unique_ptr<HeapDoesNotContainCache> m_heapDoesNotContainCache; | 451 std::unique_ptr<HeapDoesNotContainCache> m_heapDoesNotContainCache; |
| 462 std::unique_ptr<PagePool> m_freePagePool; | 452 std::unique_ptr<PagePool> m_freePagePool; |
| 463 std::unique_ptr<CallbackStack> m_markingStack; | 453 std::unique_ptr<CallbackStack> m_markingStack; |
| 464 std::unique_ptr<CallbackStack> m_postMarkingCallbackStack; | 454 std::unique_ptr<CallbackStack> m_postMarkingCallbackStack; |
| 465 std::unique_ptr<CallbackStack> m_globalWeakCallbackStack; | 455 std::unique_ptr<CallbackStack> m_globalWeakCallbackStack; |
| 466 std::unique_ptr<CallbackStack> m_ephemeronStack; | 456 std::unique_ptr<CallbackStack> m_ephemeronStack; |
| 467 BlinkGC::GCReason m_lastGCReason; | 457 BlinkGC::GCReason m_lastGCReason; |
| 468 StackFrameDepth m_stackFrameDepth; | 458 StackFrameDepth m_stackFrameDepth; |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 677 T** cell = reinterpret_cast<T**>(object); | 667 T** cell = reinterpret_cast<T**>(object); |
| 678 if (*cell && !ObjectAliveTrait<T>::isHeapObjectAlive(*cell)) | 668 if (*cell && !ObjectAliveTrait<T>::isHeapObjectAlive(*cell)) |
| 679 *cell = nullptr; | 669 *cell = nullptr; |
| 680 } | 670 } |
| 681 | 671 |
| 682 } // namespace blink | 672 } // namespace blink |
| 683 | 673 |
| 684 #include "platform/heap/VisitorImpl.h" | 674 #include "platform/heap/VisitorImpl.h" |
| 685 | 675 |
| 686 #endif // Heap_h | 676 #endif // Heap_h |
| OLD | NEW |