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 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 static void shutdown(); | 231 static void shutdown(); |
232 | 232 |
233 // Trace all GC roots, called when marking the managed heap objects. | 233 // Trace all GC roots, called when marking the managed heap objects. |
234 static void visitRoots(Visitor*); | 234 static void visitRoots(Visitor*); |
235 | 235 |
236 // Associate ThreadState object with the current thread. After this | 236 // Associate ThreadState object with the current thread. After this |
237 // call thread can start using the garbage collected heap infrastructure. | 237 // call thread can start using the garbage collected heap infrastructure. |
238 // It also has to periodically check for safepoints. | 238 // It also has to periodically check for safepoints. |
239 static void attach(); | 239 static void attach(); |
240 | 240 |
241 // When ThreadState is detaching from non-main thread its | |
242 // heap is expected to be empty (because it is going away). | |
243 // Perform registered cleanup tasks and garbage collection | |
244 // to sweep away any objects that are left on this heap. | |
245 // We assert that nothing must remain after this cleanup. | |
246 // If assertion does not hold we crash as we are potentially | |
247 // in the dangling pointer situation. | |
248 void cleanup(); | |
249 | |
250 // Disassociate attached ThreadState from the current thread. The thread | 241 // Disassociate attached ThreadState from the current thread. The thread |
251 // can no longer use the garbage collected heap after this call. | 242 // can no longer use the garbage collected heap after this call. |
252 static void detach(); | 243 static void detach(); |
253 | 244 |
254 static ThreadState* current() { return **s_threadSpecific; } | 245 static ThreadState* current() { return **s_threadSpecific; } |
255 static ThreadState* mainThreadState() | 246 static ThreadState* mainThreadState() |
256 { | 247 { |
257 return reinterpret_cast<ThreadState*>(s_mainThreadStateStorage); | 248 return reinterpret_cast<ThreadState*>(s_mainThreadStateStorage); |
258 } | 249 } |
259 | 250 |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
494 friend class SafePointBarrier; | 485 friend class SafePointBarrier; |
495 | 486 |
496 void enterSafePoint(StackState, void*); | 487 void enterSafePoint(StackState, void*); |
497 NO_SANITIZE_ADDRESS void copyStackUntilSafePointScope(); | 488 NO_SANITIZE_ADDRESS void copyStackUntilSafePointScope(); |
498 void clearSafePointScopeMarker() | 489 void clearSafePointScopeMarker() |
499 { | 490 { |
500 m_safePointStackCopy.clear(); | 491 m_safePointStackCopy.clear(); |
501 m_safePointScopeMarker = 0; | 492 m_safePointScopeMarker = 0; |
502 } | 493 } |
503 | 494 |
| 495 // When ThreadState is detaching from non-main thread its |
| 496 // heap is expected to be empty (because it is going away). |
| 497 // Perform registered cleanup tasks and garbage collection |
| 498 // to sweep away any objects that are left on this heap. |
| 499 // We assert that nothing must remain after this cleanup. |
| 500 // If assertion does not hold we crash as we are potentially |
| 501 // in the dangling pointer situation. |
| 502 void cleanup(); |
| 503 |
504 static WTF::ThreadSpecific<ThreadState*>* s_threadSpecific; | 504 static WTF::ThreadSpecific<ThreadState*>* s_threadSpecific; |
505 static SafePointBarrier* s_safePointBarrier; | 505 static SafePointBarrier* s_safePointBarrier; |
506 | 506 |
507 // This variable is flipped to true after all threads are stoped | 507 // This variable is flipped to true after all threads are stoped |
508 // and outermost GC has started. | 508 // and outermost GC has started. |
509 static bool s_inGC; | 509 static bool s_inGC; |
510 | 510 |
511 // We can't create a static member of type ThreadState here | 511 // We can't create a static member of type ThreadState here |
512 // because it will introduce global constructor and destructor. | 512 // because it will introduce global constructor and destructor. |
513 // We would like to manage lifetime of the ThreadState attached | 513 // We would like to manage lifetime of the ThreadState attached |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
555 }; | 555 }; |
556 | 556 |
557 template<> class ThreadStateFor<AnyThread> { | 557 template<> class ThreadStateFor<AnyThread> { |
558 public: | 558 public: |
559 static ThreadState* state() { return ThreadState::current(); } | 559 static ThreadState* state() { return ThreadState::current(); } |
560 }; | 560 }; |
561 | 561 |
562 } | 562 } |
563 | 563 |
564 #endif // ThreadState_h | 564 #endif // ThreadState_h |
OLD | NEW |