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 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
461 } | 461 } |
462 | 462 |
463 // Should only be called under protection of threadAttachMutex(). | 463 // Should only be called under protection of threadAttachMutex(). |
464 const Vector<Interruptor*>& interruptors() const { return m_interruptors; } | 464 const Vector<Interruptor*>& interruptors() const { return m_interruptors; } |
465 | 465 |
466 void recordStackEnd(intptr_t* endOfStack) | 466 void recordStackEnd(intptr_t* endOfStack) |
467 { | 467 { |
468 m_endOfStack = endOfStack; | 468 m_endOfStack = endOfStack; |
469 } | 469 } |
470 | 470 |
| 471 // MarkingTask functions are called before and after marking live objects. |
| 472 // They might be called on threads other than the thread associated to this |
| 473 // ThreadState. |
| 474 class MarkingTask { |
| 475 public: |
| 476 virtual ~MarkingTask() { } |
| 477 virtual void willStartMarking(ThreadState&) { } |
| 478 virtual void didFinishMarking(ThreadState&) { } |
| 479 }; |
| 480 // A caller is responsible to call removeMarkingTask before deleting the |
| 481 // specified task. |
| 482 void addMarkingTask(MarkingTask*); |
| 483 void removeMarkingTask(MarkingTask*); |
| 484 |
471 // Get one of the heap structures for this thread. | 485 // Get one of the heap structures for this thread. |
472 // | 486 // |
473 // The heap is split into multiple heap parts based on object | 487 // The heap is split into multiple heap parts based on object |
474 // types. To get the index for a given type, use | 488 // types. To get the index for a given type, use |
475 // HeapTypeTrait<Type>::index. | 489 // HeapTypeTrait<Type>::index. |
476 ThreadHeap* heap(int index) const { return m_heaps[index]; } | 490 ThreadHeap* heap(int index) const { return m_heaps[index]; } |
477 | 491 |
478 #if ENABLE(ASSERT) || ENABLE(GC_PROFILING) | 492 #if ENABLE(ASSERT) || ENABLE(GC_PROFILING) |
479 // Infrastructure to determine if an address is within one of the | 493 // Infrastructure to determine if an address is within one of the |
480 // address ranges for the Blink heap. If the address is in the Blink | 494 // address ranges for the Blink heap. If the address is in the Blink |
481 // heap the containing heap page is returned. | 495 // heap the containing heap page is returned. |
482 BaseHeapPage* findPageFromAddress(Address); | 496 BaseHeapPage* findPageFromAddress(Address); |
483 BaseHeapPage* findPageFromAddress(void* pointer) { return findPageFromAddres
s(reinterpret_cast<Address>(pointer)); } | 497 BaseHeapPage* findPageFromAddress(const void* pointer) { return findPageFrom
Address(reinterpret_cast<Address>(const_cast<void*>(pointer))); } |
484 #endif | 498 #endif |
485 | 499 |
486 // List of persistent roots allocated on the given thread. | 500 // List of persistent roots allocated on the given thread. |
487 PersistentNode* roots() const { return m_persistents.get(); } | 501 PersistentNode* roots() const { return m_persistents.get(); } |
488 | 502 |
489 // List of global persistent roots not owned by any particular thread. | 503 // List of global persistent roots not owned by any particular thread. |
490 // globalRootsMutex must be acquired before any modifications. | 504 // globalRootsMutex must be acquired before any modifications. |
491 static PersistentNode& globalRoots(); | 505 static PersistentNode& globalRoots(); |
492 static Mutex& globalRootsMutex(); | 506 static Mutex& globalRootsMutex(); |
493 | 507 |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
563 // Cancel above requests. The argument should be |*this|. This function is | 577 // Cancel above requests. The argument should be |*this|. This function is |
564 // ignored if it is called in pre-finalizer functions. | 578 // ignored if it is called in pre-finalizer functions. |
565 template<typename T> | 579 template<typename T> |
566 void unregisterPreFinalizer(T& target) | 580 void unregisterPreFinalizer(T& target) |
567 { | 581 { |
568 checkThread(); | 582 checkThread(); |
569 ASSERT(&T::invokePreFinalizer); | 583 ASSERT(&T::invokePreFinalizer); |
570 unregisterPreFinalizerInternal(&target); | 584 unregisterPreFinalizerInternal(&target); |
571 } | 585 } |
572 | 586 |
| 587 // Mark an on-heap object as a zombie. The object won't be swept until |
| 588 // purifyZombies(). It's ok to call markAsZombie() during weak processing. |
| 589 // The specified object must not have references to objects owned by other |
| 590 // threads. |
| 591 // Do not use this function. This is only for WebAudio. |
| 592 void markAsZombie(void*); |
| 593 // Purify all of zombie objects marked before calling purifyZombies(). |
| 594 void purifyZombies(); |
| 595 |
573 Vector<PageMemoryRegion*>& allocatedRegionsSinceLastGC() { return m_allocate
dRegionsSinceLastGC; } | 596 Vector<PageMemoryRegion*>& allocatedRegionsSinceLastGC() { return m_allocate
dRegionsSinceLastGC; } |
574 | 597 |
575 void shouldFlushHeapDoesNotContainCache() { m_shouldFlushHeapDoesNotContainC
ache = true; } | 598 void shouldFlushHeapDoesNotContainCache() { m_shouldFlushHeapDoesNotContainC
ache = true; } |
576 | 599 |
577 void registerTraceDOMWrappers(v8::Isolate* isolate, void (*traceDOMWrappers)
(v8::Isolate*, Visitor*)) | 600 void registerTraceDOMWrappers(v8::Isolate* isolate, void (*traceDOMWrappers)
(v8::Isolate*, Visitor*)) |
578 { | 601 { |
579 m_isolate = isolate; | 602 m_isolate = isolate; |
580 m_traceDOMWrappers = traceDOMWrappers; | 603 m_traceDOMWrappers = traceDOMWrappers; |
581 } | 604 } |
582 | 605 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
614 // Perform registered cleanup tasks and garbage collection | 637 // Perform registered cleanup tasks and garbage collection |
615 // to sweep away any objects that are left on this heap. | 638 // to sweep away any objects that are left on this heap. |
616 // We assert that nothing must remain after this cleanup. | 639 // We assert that nothing must remain after this cleanup. |
617 // If assertion does not hold we crash as we are potentially | 640 // If assertion does not hold we crash as we are potentially |
618 // in the dangling pointer situation. | 641 // in the dangling pointer situation. |
619 void cleanup(); | 642 void cleanup(); |
620 void cleanupPages(); | 643 void cleanupPages(); |
621 | 644 |
622 void unregisterPreFinalizerInternal(void*); | 645 void unregisterPreFinalizerInternal(void*); |
623 void invokePreFinalizers(Visitor&); | 646 void invokePreFinalizers(Visitor&); |
| 647 void invokePreMarkingTasks(); |
| 648 void invokePostMarkingTasks(); |
624 | 649 |
625 #if ENABLE(GC_PROFILING) | 650 #if ENABLE(GC_PROFILING) |
626 void snapshotFreeList(); | 651 void snapshotFreeList(); |
627 #endif | 652 #endif |
628 | 653 |
629 static WTF::ThreadSpecific<ThreadState*>* s_threadSpecific; | 654 static WTF::ThreadSpecific<ThreadState*>* s_threadSpecific; |
630 static uintptr_t s_mainThreadStackStart; | 655 static uintptr_t s_mainThreadStackStart; |
631 static uintptr_t s_mainThreadUnderestimatedStackSize; | 656 static uintptr_t s_mainThreadUnderestimatedStackSize; |
632 static SafePointBarrier* s_safePointBarrier; | 657 static SafePointBarrier* s_safePointBarrier; |
633 | 658 |
(...skipping 17 matching lines...) Expand all Loading... |
651 Vector<Interruptor*> m_interruptors; | 676 Vector<Interruptor*> m_interruptors; |
652 bool m_hasPendingIdleTask; | 677 bool m_hasPendingIdleTask; |
653 bool m_didV8GCAfterLastGC; | 678 bool m_didV8GCAfterLastGC; |
654 bool m_sweepForbidden; | 679 bool m_sweepForbidden; |
655 size_t m_noAllocationCount; | 680 size_t m_noAllocationCount; |
656 size_t m_allocatedObjectSizeBeforeGC; | 681 size_t m_allocatedObjectSizeBeforeGC; |
657 ThreadHeap* m_heaps[NumberOfHeaps]; | 682 ThreadHeap* m_heaps[NumberOfHeaps]; |
658 | 683 |
659 Vector<OwnPtr<CleanupTask>> m_cleanupTasks; | 684 Vector<OwnPtr<CleanupTask>> m_cleanupTasks; |
660 bool m_isTerminating; | 685 bool m_isTerminating; |
| 686 Vector<MarkingTask*> m_markingTasks; |
661 | 687 |
662 bool m_shouldFlushHeapDoesNotContainCache; | 688 bool m_shouldFlushHeapDoesNotContainCache; |
663 double m_collectionRate; | 689 double m_collectionRate; |
664 GCState m_gcState; | 690 GCState m_gcState; |
665 | 691 |
666 CallbackStack* m_weakCallbackStack; | 692 CallbackStack* m_weakCallbackStack; |
667 HashMap<void*, bool (*)(void*, Visitor&)> m_preFinalizers; | 693 HashMap<void*, bool (*)(void*, Visitor&)> m_preFinalizers; |
668 | 694 HashSet<void*> m_zombies; |
669 v8::Isolate* m_isolate; | 695 v8::Isolate* m_isolate; |
670 void (*m_traceDOMWrappers)(v8::Isolate*, Visitor*); | 696 void (*m_traceDOMWrappers)(v8::Isolate*, Visitor*); |
671 | 697 |
672 #if defined(ADDRESS_SANITIZER) | 698 #if defined(ADDRESS_SANITIZER) |
673 void* m_asanFakeStack; | 699 void* m_asanFakeStack; |
674 #endif | 700 #endif |
675 | 701 |
676 Vector<PageMemoryRegion*> m_allocatedRegionsSinceLastGC; | 702 Vector<PageMemoryRegion*> m_allocatedRegionsSinceLastGC; |
677 | 703 |
678 #if ENABLE(GC_PROFILING) | 704 #if ENABLE(GC_PROFILING) |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
748 m_locked = false; | 774 m_locked = false; |
749 } | 775 } |
750 | 776 |
751 MutexBase& m_mutex; | 777 MutexBase& m_mutex; |
752 bool m_locked; | 778 bool m_locked; |
753 }; | 779 }; |
754 | 780 |
755 } // namespace blink | 781 } // namespace blink |
756 | 782 |
757 #endif // ThreadState_h | 783 #endif // ThreadState_h |
OLD | NEW |