| 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 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 448 | 448 |
| 449 // Get one of the heap structures for this thread. | 449 // Get one of the heap structures for this thread. |
| 450 // | 450 // |
| 451 // The heap is split into multiple heap parts based on object | 451 // The heap is split into multiple heap parts based on object |
| 452 // types. To get the index for a given type, use | 452 // types. To get the index for a given type, use |
| 453 // HeapTrait<Type>::index. | 453 // HeapTrait<Type>::index. |
| 454 BaseHeap* heap(int index) const { return m_heaps[index]; } | 454 BaseHeap* heap(int index) const { return m_heaps[index]; } |
| 455 | 455 |
| 456 // Infrastructure to determine if an address is within one of the | 456 // Infrastructure to determine if an address is within one of the |
| 457 // address ranges for the Blink heap. | 457 // address ranges for the Blink heap. |
| 458 HeapContainsCache* heapContainsCache() { return m_heapContainsCache; } | 458 HeapContainsCache* heapContainsCache() { return m_heapContainsCache.get(); } |
| 459 bool contains(Address); | 459 bool contains(Address); |
| 460 bool contains(void* pointer) { return contains(reinterpret_cast<Address>(poi
nter)); } | 460 bool contains(void* pointer) { return contains(reinterpret_cast<Address>(poi
nter)); } |
| 461 bool contains(const void* pointer) { return contains(const_cast<void*>(point
er)); } | 461 bool contains(const void* pointer) { return contains(const_cast<void*>(point
er)); } |
| 462 | 462 |
| 463 // Finds the Blink HeapPage in this thread-specific heap | 463 // Finds the Blink HeapPage in this thread-specific heap |
| 464 // corresponding to a given address. Return 0 if the address is | 464 // corresponding to a given address. Return 0 if the address is |
| 465 // not contained in any of the pages. | 465 // not contained in any of the pages. |
| 466 BaseHeapPage* heapPageFromAddress(Address); | 466 BaseHeapPage* heapPageFromAddress(Address); |
| 467 | 467 |
| 468 // List of persistent roots allocated on the given thread. | 468 // List of persistent roots allocated on the given thread. |
| 469 PersistentNode* roots() const { return m_persistents; } | 469 PersistentNode* roots() const { return m_persistents.get(); } |
| 470 | 470 |
| 471 // List of global persistent roots not owned by any particular thread. | 471 // List of global persistent roots not owned by any particular thread. |
| 472 // globalRootsMutex must be acquired before any modifications. | 472 // globalRootsMutex must be acquired before any modifications. |
| 473 static PersistentNode* globalRoots(); | 473 static PersistentNode* globalRoots(); |
| 474 static Mutex& globalRootsMutex(); | 474 static Mutex& globalRootsMutex(); |
| 475 | 475 |
| 476 // Visit local thread stack and trace all pointers conservatively. | 476 // Visit local thread stack and trace all pointers conservatively. |
| 477 void visitStack(Visitor*); | 477 void visitStack(Visitor*); |
| 478 | 478 |
| 479 // Visit all persistents allocated on this thread. | 479 // Visit all persistents allocated on this thread. |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 513 // We would like to manage lifetime of the ThreadState attached | 513 // We would like to manage lifetime of the ThreadState attached |
| 514 // to the main thread explicitly instead and still use normal | 514 // to the main thread explicitly instead and still use normal |
| 515 // constructor and destructor for the ThreadState class. | 515 // constructor and destructor for the ThreadState class. |
| 516 // For this we reserve static storage for the main ThreadState | 516 // For this we reserve static storage for the main ThreadState |
| 517 // and lazily construct ThreadState in it using placement new. | 517 // and lazily construct ThreadState in it using placement new. |
| 518 static uint8_t s_mainThreadStateStorage[]; | 518 static uint8_t s_mainThreadStateStorage[]; |
| 519 | 519 |
| 520 void trace(Visitor*); | 520 void trace(Visitor*); |
| 521 | 521 |
| 522 ThreadIdentifier m_thread; | 522 ThreadIdentifier m_thread; |
| 523 PersistentNode* m_persistents; | 523 OwnPtr<PersistentNode> m_persistents; |
| 524 StackState m_stackState; | 524 StackState m_stackState; |
| 525 intptr_t* m_startOfStack; | 525 intptr_t* m_startOfStack; |
| 526 intptr_t* m_endOfStack; | 526 intptr_t* m_endOfStack; |
| 527 void* m_safePointScopeMarker; | 527 void* m_safePointScopeMarker; |
| 528 Vector<Address> m_safePointStackCopy; | 528 Vector<Address> m_safePointStackCopy; |
| 529 bool m_atSafePoint; | 529 bool m_atSafePoint; |
| 530 Vector<Interruptor*> m_interruptors; | 530 Vector<Interruptor*> m_interruptors; |
| 531 bool m_gcRequested; | 531 bool m_gcRequested; |
| 532 volatile int m_sweepRequested; | 532 volatile int m_sweepRequested; |
| 533 bool m_sweepInProgress; | 533 bool m_sweepInProgress; |
| 534 size_t m_noAllocationCount; | 534 size_t m_noAllocationCount; |
| 535 bool m_inGC; | 535 bool m_inGC; |
| 536 BaseHeap* m_heaps[NumberOfHeaps]; | 536 BaseHeap* m_heaps[NumberOfHeaps]; |
| 537 HeapContainsCache* m_heapContainsCache; | 537 OwnPtr<HeapContainsCache> m_heapContainsCache; |
| 538 HeapStats m_stats; | 538 HeapStats m_stats; |
| 539 HeapStats m_statsAfterLastGC; | 539 HeapStats m_statsAfterLastGC; |
| 540 | 540 |
| 541 Vector<OwnPtr<CleanupTask> > m_cleanupTasks; | 541 Vector<OwnPtr<CleanupTask> > m_cleanupTasks; |
| 542 bool m_isCleaningUp; | 542 bool m_isCleaningUp; |
| 543 }; | 543 }; |
| 544 | 544 |
| 545 template<ThreadAffinity affinity> class ThreadStateFor; | 545 template<ThreadAffinity affinity> class ThreadStateFor; |
| 546 | 546 |
| 547 template<> class ThreadStateFor<MainThreadOnly> { | 547 template<> class ThreadStateFor<MainThreadOnly> { |
| 548 public: | 548 public: |
| 549 static ThreadState* state() | 549 static ThreadState* state() |
| 550 { | 550 { |
| 551 // This specialization must only be used from the main thread. | 551 // This specialization must only be used from the main thread. |
| 552 ASSERT(ThreadState::isMainThread()); | 552 ASSERT(ThreadState::isMainThread()); |
| 553 return ThreadState::mainThreadState(); | 553 return ThreadState::mainThreadState(); |
| 554 } | 554 } |
| 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 |