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