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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 // { | 99 // { |
100 // m_bar->...; // It is safe to touch other on-heap objects. | 100 // m_bar->...; // It is safe to touch other on-heap objects. |
101 // } | 101 // } |
102 // Member<Bar> m_bar; | 102 // Member<Bar> m_bar; |
103 // }; | 103 // }; |
104 #define USING_PRE_FINALIZER(Class, preFinalizer) \ | 104 #define USING_PRE_FINALIZER(Class, preFinalizer) \ |
105 public: \ | 105 public: \ |
106 static bool invokePreFinalizer(void* object) \ | 106 static bool invokePreFinalizer(void* object) \ |
107 { \ | 107 { \ |
108 Class* self = reinterpret_cast<Class*>(object); \ | 108 Class* self = reinterpret_cast<Class*>(object); \ |
109 if (ThreadHeap::isHeapObjectAlive(self)) \ | 109 if (Heap::isHeapObjectAlive(self)) \ |
110 return false; \ | 110 return false; \ |
111 self->Class::preFinalizer(); \ | 111 self->Class::preFinalizer(); \ |
112 return true; \ | 112 return true; \ |
113 } \ | 113 } \ |
114 using UsingPreFinalizerMacroNeedsTrailingSemiColon = char | 114 using UsingPreFinalizerMacroNeedsTrailingSemiColon = char |
115 | 115 |
116 class PLATFORM_EXPORT ThreadState { | 116 class PLATFORM_EXPORT ThreadState { |
117 USING_FAST_MALLOC(ThreadState); | 117 USING_FAST_MALLOC(ThreadState); |
118 WTF_MAKE_NONCOPYABLE(ThreadState); | 118 WTF_MAKE_NONCOPYABLE(ThreadState); |
119 public: | 119 public: |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 bool isInGC() const { return gcState() == GCRunning; } | 248 bool isInGC() const { return gcState() == GCRunning; } |
249 bool isSweepingInProgress() const | 249 bool isSweepingInProgress() const |
250 { | 250 { |
251 return gcState() == Sweeping || gcState() == SweepingAndPreciseGCSchedul
ed || gcState() == SweepingAndIdleGCScheduled; | 251 return gcState() == Sweeping || gcState() == SweepingAndPreciseGCSchedul
ed || gcState() == SweepingAndIdleGCScheduled; |
252 } | 252 } |
253 | 253 |
254 // A GC runs in the following sequence. | 254 // A GC runs in the following sequence. |
255 // | 255 // |
256 // 1) All threads park at safe points. | 256 // 1) All threads park at safe points. |
257 // 2) The GCing thread calls preGC() for all ThreadStates. | 257 // 2) The GCing thread calls preGC() for all ThreadStates. |
258 // 3) The GCing thread calls ThreadHeap::collectGarbage(). | 258 // 3) The GCing thread calls Heap::collectGarbage(). |
259 // This does marking but doesn't do sweeping. | 259 // This does marking but doesn't do sweeping. |
260 // 4) The GCing thread calls postGC() for all ThreadStates. | 260 // 4) The GCing thread calls postGC() for all ThreadStates. |
261 // 5) The GCing thread resume all threads. | 261 // 5) The GCing thread resume all threads. |
262 // 6) Each thread calls preSweep(). | 262 // 6) Each thread calls preSweep(). |
263 // 7) Each thread runs lazy sweeping (concurrently with sweepings | 263 // 7) Each thread runs lazy sweeping (concurrently with sweepings |
264 // in other threads) and eventually calls completeSweep(). | 264 // in other threads) and eventually calls completeSweep(). |
265 // 8) Each thread calls postSweep(). | 265 // 8) Each thread calls postSweep(). |
266 // | 266 // |
267 // Notes: | 267 // Notes: |
268 // - We stop the world between 1) and 5). | 268 // - We stop the world between 1) and 5). |
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
700 | 700 |
701 template<> class ThreadStateFor<AnyThread> { | 701 template<> class ThreadStateFor<AnyThread> { |
702 STATIC_ONLY(ThreadStateFor); | 702 STATIC_ONLY(ThreadStateFor); |
703 public: | 703 public: |
704 static ThreadState* state() { return ThreadState::current(); } | 704 static ThreadState* state() { return ThreadState::current(); } |
705 }; | 705 }; |
706 | 706 |
707 } // namespace blink | 707 } // namespace blink |
708 | 708 |
709 #endif // ThreadState_h | 709 #endif // ThreadState_h |
OLD | NEW |