| 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 }; | 52 }; |
| 53 | 53 |
| 54 namespace blink { | 54 namespace blink { |
| 55 | 55 |
| 56 class BasePage; | 56 class BasePage; |
| 57 class CallbackStack; | 57 class CallbackStack; |
| 58 class GarbageCollectedMixinConstructorMarker; | 58 class GarbageCollectedMixinConstructorMarker; |
| 59 class PersistentNode; | 59 class PersistentNode; |
| 60 class PersistentRegion; | 60 class PersistentRegion; |
| 61 class BaseArena; | 61 class BaseArena; |
| 62 class SafePointAwareMutexLocker; | |
| 63 class SafePointBarrier; | 62 class SafePointBarrier; |
| 64 class ThreadHeap; | 63 class ThreadHeap; |
| 65 class ThreadState; | 64 class ThreadState; |
| 66 class Visitor; | 65 class Visitor; |
| 67 | 66 |
| 68 // Declare that a class has a pre-finalizer. The pre-finalizer is called | 67 // Declare that a class has a pre-finalizer. The pre-finalizer is called |
| 69 // before any object gets swept, so it is safe to touch on-heap objects | 68 // before any object gets swept, so it is safe to touch on-heap objects |
| 70 // that may be collected in the same GC cycle. If you cannot avoid touching | 69 // that may be collected in the same GC cycle. If you cannot avoid touching |
| 71 // on-heap objects in a destructor (which is not allowed), you can consider | 70 // on-heap objects in a destructor (which is not allowed), you can consider |
| 72 // using the pre-finalizer. The only restriction is that the pre-finalizer | 71 // using the pre-finalizer. The only restriction is that the pre-finalizer |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 // that have no calls to safePoint and are not wrapped in a SafePointScope | 328 // that have no calls to safePoint and are not wrapped in a SafePointScope |
| 330 // (e.g. BlinkGCInterruptor for JavaScript code) | 329 // (e.g. BlinkGCInterruptor for JavaScript code) |
| 331 // | 330 // |
| 332 | 331 |
| 333 // Check if GC is requested by another thread and pause this thread if this is | 332 // Check if GC is requested by another thread and pause this thread if this is |
| 334 // the case. Can only be called when current thread is in a consistent state. | 333 // the case. Can only be called when current thread is in a consistent state. |
| 335 void safePoint(BlinkGC::StackState); | 334 void safePoint(BlinkGC::StackState); |
| 336 | 335 |
| 337 // Mark current thread as running inside safepoint. | 336 // Mark current thread as running inside safepoint. |
| 338 void enterSafePoint(BlinkGC::StackState, void*); | 337 void enterSafePoint(BlinkGC::StackState, void*); |
| 339 void leaveSafePoint(SafePointAwareMutexLocker* = nullptr); | 338 void leaveSafePoint(); |
| 340 bool isAtSafePoint() const { return m_atSafePoint; } | 339 bool isAtSafePoint() const { return m_atSafePoint; } |
| 341 | 340 |
| 342 void addInterruptor(std::unique_ptr<BlinkGCInterruptor>); | 341 void addInterruptor(std::unique_ptr<BlinkGCInterruptor>); |
| 343 | 342 |
| 344 void recordStackEnd(intptr_t* endOfStack) { m_endOfStack = endOfStack; } | 343 void recordStackEnd(intptr_t* endOfStack) { m_endOfStack = endOfStack; } |
| 345 | 344 |
| 346 // Get one of the heap structures for this thread. | 345 // Get one of the heap structures for this thread. |
| 347 // The thread heap is split into multiple heap parts based on object types | 346 // The thread heap is split into multiple heap parts based on object types |
| 348 // and object sizes. | 347 // and object sizes. |
| 349 BaseArena* arena(int arenaIndex) const { | 348 BaseArena* arena(int arenaIndex) const { |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 617 int arenaIndexOfVectorArenaLeastRecentlyExpanded(int beginArenaIndex, | 616 int arenaIndexOfVectorArenaLeastRecentlyExpanded(int beginArenaIndex, |
| 618 int endArenaIndex); | 617 int endArenaIndex); |
| 619 | 618 |
| 620 void reportMemoryToV8(); | 619 void reportMemoryToV8(); |
| 621 | 620 |
| 622 // Should only be called under protection of threadAttachMutex(). | 621 // Should only be called under protection of threadAttachMutex(). |
| 623 const Vector<std::unique_ptr<BlinkGCInterruptor>>& interruptors() const { | 622 const Vector<std::unique_ptr<BlinkGCInterruptor>>& interruptors() const { |
| 624 return m_interruptors; | 623 return m_interruptors; |
| 625 } | 624 } |
| 626 | 625 |
| 627 friend class SafePointAwareMutexLocker; | |
| 628 friend class SafePointBarrier; | 626 friend class SafePointBarrier; |
| 629 friend class SafePointScope; | 627 friend class SafePointScope; |
| 630 | 628 |
| 631 static WTF::ThreadSpecific<ThreadState*>* s_threadSpecific; | 629 static WTF::ThreadSpecific<ThreadState*>* s_threadSpecific; |
| 632 | 630 |
| 633 // We can't create a static member of type ThreadState here | 631 // We can't create a static member of type ThreadState here |
| 634 // because it will introduce global constructor and destructor. | 632 // because it will introduce global constructor and destructor. |
| 635 // We would like to manage lifetime of the ThreadState attached | 633 // We would like to manage lifetime of the ThreadState attached |
| 636 // to the main thread explicitly instead and still use normal | 634 // to the main thread explicitly instead and still use normal |
| 637 // constructor and destructor for the ThreadState class. | 635 // constructor and destructor for the ThreadState class. |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 730 class ThreadStateFor<AnyThread> { | 728 class ThreadStateFor<AnyThread> { |
| 731 STATIC_ONLY(ThreadStateFor); | 729 STATIC_ONLY(ThreadStateFor); |
| 732 | 730 |
| 733 public: | 731 public: |
| 734 static ThreadState* state() { return ThreadState::current(); } | 732 static ThreadState* state() { return ThreadState::current(); } |
| 735 }; | 733 }; |
| 736 | 734 |
| 737 } // namespace blink | 735 } // namespace blink |
| 738 | 736 |
| 739 #endif // ThreadState_h | 737 #endif // ThreadState_h |
| OLD | NEW |