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 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 // Initialize threading infrastructure. Should be called from the main | 238 // Initialize threading infrastructure. Should be called from the main |
239 // thread. | 239 // thread. |
240 static void init(); | 240 static void init(); |
241 static void shutdown(); | 241 static void shutdown(); |
242 static void shutdownHeapIfNecessary(); | 242 static void shutdownHeapIfNecessary(); |
243 bool isTerminating() { return m_isTerminating; } | 243 bool isTerminating() { return m_isTerminating; } |
244 | 244 |
245 static void attachMainThread(); | 245 static void attachMainThread(); |
246 static void detachMainThread(); | 246 static void detachMainThread(); |
247 | 247 |
248 // Trace all GC roots, called when marking the managed heap objects. | 248 // Trace all persistent roots, called when marking the managed heap objects. |
249 static void visitRoots(Visitor*); | 249 static void visitPersistentRoots(Visitor*); |
| 250 |
| 251 // Trace all objects found on the stack, used when doing conservative GCs. |
| 252 static void visitStackRoots(Visitor*); |
250 | 253 |
251 // Associate ThreadState object with the current thread. After this | 254 // Associate ThreadState object with the current thread. After this |
252 // call thread can start using the garbage collected heap infrastructure. | 255 // call thread can start using the garbage collected heap infrastructure. |
253 // It also has to periodically check for safepoints. | 256 // It also has to periodically check for safepoints. |
254 static void attach(); | 257 static void attach(); |
255 | 258 |
256 // Disassociate attached ThreadState from the current thread. The thread | 259 // Disassociate attached ThreadState from the current thread. The thread |
257 // can no longer use the garbage collected heap after this call. | 260 // can no longer use the garbage collected heap after this call. |
258 static void detach(); | 261 static void detach(); |
259 | 262 |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
503 #endif | 506 #endif |
504 | 507 |
505 void pushWeakObjectPointerCallback(void*, WeakPointerCallback); | 508 void pushWeakObjectPointerCallback(void*, WeakPointerCallback); |
506 bool popAndInvokeWeakPointerCallback(Visitor*); | 509 bool popAndInvokeWeakPointerCallback(Visitor*); |
507 | 510 |
508 void getStats(HeapStats&); | 511 void getStats(HeapStats&); |
509 HeapStats& stats() { return m_stats; } | 512 HeapStats& stats() { return m_stats; } |
510 HeapStats& statsAfterLastGC() { return m_statsAfterLastGC; } | 513 HeapStats& statsAfterLastGC() { return m_statsAfterLastGC; } |
511 | 514 |
512 void setupHeapsForTermination(); | 515 void setupHeapsForTermination(); |
513 void visitLocalRoots(Visitor*); | |
514 | 516 |
515 private: | 517 private: |
516 explicit ThreadState(); | 518 explicit ThreadState(); |
517 ~ThreadState(); | 519 ~ThreadState(); |
518 | 520 |
519 friend class SafePointBarrier; | 521 friend class SafePointBarrier; |
520 friend class SafePointAwareMutexLocker; | 522 friend class SafePointAwareMutexLocker; |
521 | 523 |
522 void enterSafePoint(StackState, void*); | 524 void enterSafePoint(StackState, void*); |
523 NO_SANITIZE_ADDRESS void copyStackUntilSafePointScope(); | 525 NO_SANITIZE_ADDRESS void copyStackUntilSafePointScope(); |
(...skipping 30 matching lines...) Expand all Loading... |
554 | 556 |
555 // We can't create a static member of type ThreadState here | 557 // We can't create a static member of type ThreadState here |
556 // because it will introduce global constructor and destructor. | 558 // because it will introduce global constructor and destructor. |
557 // We would like to manage lifetime of the ThreadState attached | 559 // We would like to manage lifetime of the ThreadState attached |
558 // to the main thread explicitly instead and still use normal | 560 // to the main thread explicitly instead and still use normal |
559 // constructor and destructor for the ThreadState class. | 561 // constructor and destructor for the ThreadState class. |
560 // For this we reserve static storage for the main ThreadState | 562 // For this we reserve static storage for the main ThreadState |
561 // and lazily construct ThreadState in it using placement new. | 563 // and lazily construct ThreadState in it using placement new. |
562 static uint8_t s_mainThreadStateStorage[]; | 564 static uint8_t s_mainThreadStateStorage[]; |
563 | 565 |
564 void trace(Visitor*); | |
565 | |
566 ThreadIdentifier m_thread; | 566 ThreadIdentifier m_thread; |
567 OwnPtr<PersistentNode> m_persistents; | 567 OwnPtr<PersistentNode> m_persistents; |
568 StackState m_stackState; | 568 StackState m_stackState; |
569 intptr_t* m_startOfStack; | 569 intptr_t* m_startOfStack; |
570 intptr_t* m_endOfStack; | 570 intptr_t* m_endOfStack; |
571 void* m_safePointScopeMarker; | 571 void* m_safePointScopeMarker; |
572 Vector<Address> m_safePointStackCopy; | 572 Vector<Address> m_safePointStackCopy; |
573 bool m_atSafePoint; | 573 bool m_atSafePoint; |
574 Vector<Interruptor*> m_interruptors; | 574 Vector<Interruptor*> m_interruptors; |
575 bool m_gcRequested; | 575 bool m_gcRequested; |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
712 // HeapPage header. We use some of the bits to determine | 712 // HeapPage header. We use some of the bits to determine |
713 // whether the page is part of a terminting thread or | 713 // whether the page is part of a terminting thread or |
714 // if the page is traced after being terminated (orphaned). | 714 // if the page is traced after being terminated (orphaned). |
715 uintptr_t m_terminating : 1; | 715 uintptr_t m_terminating : 1; |
716 uintptr_t m_tracedAfterOrphaned : 1; | 716 uintptr_t m_tracedAfterOrphaned : 1; |
717 }; | 717 }; |
718 | 718 |
719 } | 719 } |
720 | 720 |
721 #endif // ThreadState_h | 721 #endif // ThreadState_h |
OLD | NEW |