Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(425)

Side by Side Diff: Source/platform/heap/ThreadState.h

Issue 802593004: WebAudio: Fix AudioNode leak in a case that AudioNode is not disconnected from the graph explicitly. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: rebase Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/platform/heap/HeapTest.cpp ('k') | Source/platform/heap/ThreadState.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 458 matching lines...) Expand 10 before | Expand all | Expand 10 after
469 } 469 }
470 470
471 // Should only be called under protection of threadAttachMutex(). 471 // Should only be called under protection of threadAttachMutex().
472 const Vector<Interruptor*>& interruptors() const { return m_interruptors; } 472 const Vector<Interruptor*>& interruptors() const { return m_interruptors; }
473 473
474 void recordStackEnd(intptr_t* endOfStack) 474 void recordStackEnd(intptr_t* endOfStack)
475 { 475 {
476 m_endOfStack = endOfStack; 476 m_endOfStack = endOfStack;
477 } 477 }
478 478
479 // MarkingTask functions are called before and after marking live objects.
480 // They might be called on threads other than the thread associated to this
481 // ThreadState.
482 class MarkingTask {
483 public:
484 virtual ~MarkingTask() { }
485 virtual void willStartMarking(ThreadState&) { }
486 virtual void didFinishMarking(ThreadState&) { }
487 };
488 // A caller is responsible to call removeMarkingTask before deleting the
489 // specified task.
490 void addMarkingTask(MarkingTask*);
491 void removeMarkingTask(MarkingTask*);
492
479 // Get one of the heap structures for this thread. 493 // Get one of the heap structures for this thread.
480 // 494 //
481 // The heap is split into multiple heap parts based on object 495 // The heap is split into multiple heap parts based on object
482 // types. To get the index for a given type, use 496 // types. To get the index for a given type, use
483 // HeapIndexTrait<Type>::index. 497 // HeapIndexTrait<Type>::index.
484 BaseHeap* heap(int heapIndex) const { return m_heaps[heapIndex]; } 498 BaseHeap* heap(int heapIndex) const { return m_heaps[heapIndex]; }
485 499
486 #if ENABLE(ASSERT) || ENABLE(GC_PROFILING) 500 #if ENABLE(ASSERT) || ENABLE(GC_PROFILING)
487 // Infrastructure to determine if an address is within one of the 501 // Infrastructure to determine if an address is within one of the
488 // address ranges for the Blink heap. If the address is in the Blink 502 // address ranges for the Blink heap. If the address is in the Blink
489 // heap the containing heap page is returned. 503 // heap the containing heap page is returned.
490 BasePage* findPageFromAddress(Address); 504 BasePage* findPageFromAddress(Address);
491 BasePage* findPageFromAddress(void* pointer) { return findPageFromAddress(re interpret_cast<Address>(pointer)); } 505 BasePage* findPageFromAddress(const void* pointer) { return findPageFromAddr ess(reinterpret_cast<Address>(const_cast<void*>(pointer))); }
492 #endif 506 #endif
493 507
494 // List of persistent roots allocated on the given thread. 508 // List of persistent roots allocated on the given thread.
495 PersistentNode* roots() const { return m_persistents.get(); } 509 PersistentNode* roots() const { return m_persistents.get(); }
496 510
497 // List of global persistent roots not owned by any particular thread. 511 // List of global persistent roots not owned by any particular thread.
498 // globalRootsMutex must be acquired before any modifications. 512 // globalRootsMutex must be acquired before any modifications.
499 static PersistentNode& globalRoots(); 513 static PersistentNode& globalRoots();
500 static Mutex& globalRootsMutex(); 514 static Mutex& globalRootsMutex();
501 515
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
575 // Cancel above requests. The argument should be |*this|. This function is 589 // Cancel above requests. The argument should be |*this|. This function is
576 // ignored if it is called in pre-finalizer functions. 590 // ignored if it is called in pre-finalizer functions.
577 template<typename T> 591 template<typename T>
578 void unregisterPreFinalizer(T& target) 592 void unregisterPreFinalizer(T& target)
579 { 593 {
580 checkThread(); 594 checkThread();
581 ASSERT(&T::invokePreFinalizer); 595 ASSERT(&T::invokePreFinalizer);
582 unregisterPreFinalizerInternal(&target); 596 unregisterPreFinalizerInternal(&target);
583 } 597 }
584 598
599 // Mark an on-heap object as a zombie. The object won't be swept until
600 // purifyZombies(). It's ok to call markAsZombie() during weak processing.
601 // The specified object must not have references to objects owned by other
602 // threads.
603 // Do not use this function. This feature is a temporal workaround for
tkent 2015/02/17 08:24:39 Clarified "temporal workaround"
604 // WebAudio, and will be removed soon.
605 void markAsZombie(void*);
606 // Purify all of zombie objects marked before calling purifyZombies().
607 void purifyZombies();
608
585 Vector<PageMemoryRegion*>& allocatedRegionsSinceLastGC() { return m_allocate dRegionsSinceLastGC; } 609 Vector<PageMemoryRegion*>& allocatedRegionsSinceLastGC() { return m_allocate dRegionsSinceLastGC; }
586 610
587 void shouldFlushHeapDoesNotContainCache() { m_shouldFlushHeapDoesNotContainC ache = true; } 611 void shouldFlushHeapDoesNotContainCache() { m_shouldFlushHeapDoesNotContainC ache = true; }
588 612
589 void registerTraceDOMWrappers(v8::Isolate* isolate, void (*traceDOMWrappers) (v8::Isolate*, Visitor*)) 613 void registerTraceDOMWrappers(v8::Isolate* isolate, void (*traceDOMWrappers) (v8::Isolate*, Visitor*))
590 { 614 {
591 m_isolate = isolate; 615 m_isolate = isolate;
592 m_traceDOMWrappers = traceDOMWrappers; 616 m_traceDOMWrappers = traceDOMWrappers;
593 } 617 }
594 618
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
626 // Perform registered cleanup tasks and garbage collection 650 // Perform registered cleanup tasks and garbage collection
627 // to sweep away any objects that are left on this heap. 651 // to sweep away any objects that are left on this heap.
628 // We assert that nothing must remain after this cleanup. 652 // We assert that nothing must remain after this cleanup.
629 // If assertion does not hold we crash as we are potentially 653 // If assertion does not hold we crash as we are potentially
630 // in the dangling pointer situation. 654 // in the dangling pointer situation.
631 void cleanup(); 655 void cleanup();
632 void cleanupPages(); 656 void cleanupPages();
633 657
634 void unregisterPreFinalizerInternal(void*); 658 void unregisterPreFinalizerInternal(void*);
635 void invokePreFinalizers(Visitor&); 659 void invokePreFinalizers(Visitor&);
660 void invokePreMarkingTasks();
661 void invokePostMarkingTasks();
636 662
637 #if ENABLE(GC_PROFILING) 663 #if ENABLE(GC_PROFILING)
638 void snapshotFreeList(); 664 void snapshotFreeList();
639 #endif 665 #endif
640 666
641 static WTF::ThreadSpecific<ThreadState*>* s_threadSpecific; 667 static WTF::ThreadSpecific<ThreadState*>* s_threadSpecific;
642 static uintptr_t s_mainThreadStackStart; 668 static uintptr_t s_mainThreadStackStart;
643 static uintptr_t s_mainThreadUnderestimatedStackSize; 669 static uintptr_t s_mainThreadUnderestimatedStackSize;
644 static SafePointBarrier* s_safePointBarrier; 670 static SafePointBarrier* s_safePointBarrier;
645 671
(...skipping 17 matching lines...) Expand all
663 Vector<Interruptor*> m_interruptors; 689 Vector<Interruptor*> m_interruptors;
664 bool m_hasPendingIdleTask; 690 bool m_hasPendingIdleTask;
665 bool m_didV8GCAfterLastGC; 691 bool m_didV8GCAfterLastGC;
666 bool m_sweepForbidden; 692 bool m_sweepForbidden;
667 size_t m_noAllocationCount; 693 size_t m_noAllocationCount;
668 size_t m_allocatedObjectSizeBeforeGC; 694 size_t m_allocatedObjectSizeBeforeGC;
669 BaseHeap* m_heaps[NumberOfHeaps]; 695 BaseHeap* m_heaps[NumberOfHeaps];
670 696
671 Vector<OwnPtr<CleanupTask>> m_cleanupTasks; 697 Vector<OwnPtr<CleanupTask>> m_cleanupTasks;
672 bool m_isTerminating; 698 bool m_isTerminating;
699 Vector<MarkingTask*> m_markingTasks;
673 700
674 bool m_shouldFlushHeapDoesNotContainCache; 701 bool m_shouldFlushHeapDoesNotContainCache;
675 double m_collectionRate; 702 double m_collectionRate;
676 GCState m_gcState; 703 GCState m_gcState;
677 704
678 CallbackStack* m_weakCallbackStack; 705 CallbackStack* m_weakCallbackStack;
679 HashMap<void*, bool (*)(void*, Visitor&)> m_preFinalizers; 706 HashMap<void*, bool (*)(void*, Visitor&)> m_preFinalizers;
680 707 HashSet<void*> m_zombies;
haraken 2015/02/17 08:37:03 Another idea (that will reduce the complexity you
tkent 2015/02/17 23:43:56 Your idea would be much complex. - ThreadState ne
681 v8::Isolate* m_isolate; 708 v8::Isolate* m_isolate;
682 void (*m_traceDOMWrappers)(v8::Isolate*, Visitor*); 709 void (*m_traceDOMWrappers)(v8::Isolate*, Visitor*);
683 710
684 #if defined(ADDRESS_SANITIZER) 711 #if defined(ADDRESS_SANITIZER)
685 void* m_asanFakeStack; 712 void* m_asanFakeStack;
686 #endif 713 #endif
687 714
688 Vector<PageMemoryRegion*> m_allocatedRegionsSinceLastGC; 715 Vector<PageMemoryRegion*> m_allocatedRegionsSinceLastGC;
689 716
690 #if ENABLE(GC_PROFILING) 717 #if ENABLE(GC_PROFILING)
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
760 m_locked = false; 787 m_locked = false;
761 } 788 }
762 789
763 MutexBase& m_mutex; 790 MutexBase& m_mutex;
764 bool m_locked; 791 bool m_locked;
765 }; 792 };
766 793
767 } // namespace blink 794 } // namespace blink
768 795
769 #endif // ThreadState_h 796 #endif // ThreadState_h
OLDNEW
« no previous file with comments | « Source/platform/heap/HeapTest.cpp ('k') | Source/platform/heap/ThreadState.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698