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

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

Issue 383743002: Oilpan: GC profiling. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: TracedValue update Created 6 years, 4 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/ThreadState.cpp ('k') | Source/wtf/InstanceCounter.h » ('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 25 matching lines...) Expand all
36 #include "wtf/Assertions.h" 36 #include "wtf/Assertions.h"
37 #include "wtf/Deque.h" 37 #include "wtf/Deque.h"
38 #include "wtf/Forward.h" 38 #include "wtf/Forward.h"
39 #include "wtf/HashMap.h" 39 #include "wtf/HashMap.h"
40 #include "wtf/HashTraits.h" 40 #include "wtf/HashTraits.h"
41 #include "wtf/InstanceCounter.h" 41 #include "wtf/InstanceCounter.h"
42 #include "wtf/OwnPtr.h" 42 #include "wtf/OwnPtr.h"
43 #include "wtf/RefPtr.h" 43 #include "wtf/RefPtr.h"
44 #include "wtf/TypeTraits.h" 44 #include "wtf/TypeTraits.h"
45 #include "wtf/WeakPtr.h" 45 #include "wtf/WeakPtr.h"
46 #if ENABLE(GC_TRACING) 46 #if ENABLE(GC_PROFILING)
47 #include "wtf/text/WTFString.h" 47 #include "wtf/text/WTFString.h"
48 #endif 48 #endif
49 49
50 #if ENABLE(ASSERT) 50 #if ENABLE(ASSERT)
51 #define DEBUG_ONLY(x) x 51 #define DEBUG_ONLY(x) x
52 #else 52 #else
53 #define DEBUG_ONLY(x) 53 #define DEBUG_ONLY(x)
54 #endif 54 #endif
55 55
56 namespace blink { 56 namespace blink {
(...skipping 25 matching lines...) Expand all
82 // the garbage collector determines that the object is no longer 82 // the garbage collector determines that the object is no longer
83 // reachable. There is a GCInfo struct for each class that directly 83 // reachable. There is a GCInfo struct for each class that directly
84 // inherits from GarbageCollected or GarbageCollectedFinalized. 84 // inherits from GarbageCollected or GarbageCollectedFinalized.
85 struct GCInfo { 85 struct GCInfo {
86 bool hasFinalizer() const { return m_nonTrivialFinalizer; } 86 bool hasFinalizer() const { return m_nonTrivialFinalizer; }
87 bool hasVTable() const { return m_hasVTable; } 87 bool hasVTable() const { return m_hasVTable; }
88 TraceCallback m_trace; 88 TraceCallback m_trace;
89 FinalizationCallback m_finalize; 89 FinalizationCallback m_finalize;
90 bool m_nonTrivialFinalizer; 90 bool m_nonTrivialFinalizer;
91 bool m_hasVTable; 91 bool m_hasVTable;
92 #if ENABLE(GC_TRACING) 92 #if ENABLE(GC_PROFILING)
93 // |m_className| is held as a reference to prevent dtor being called at exit . 93 // |m_className| is held as a reference to prevent dtor being called at exit .
94 const String& m_className; 94 const String& m_className;
95 #endif 95 #endif
96 }; 96 };
97 97
98 // The FinalizerTraitImpl specifies how to finalize objects. Object 98 // The FinalizerTraitImpl specifies how to finalize objects. Object
99 // that inherit from GarbageCollectedFinalized are finalized by 99 // that inherit from GarbageCollectedFinalized are finalized by
100 // calling their 'finalize' method which by default will call the 100 // calling their 'finalize' method which by default will call the
101 // destructor on the object. 101 // destructor on the object.
102 template<typename T, bool isGarbageCollectedFinalized> 102 template<typename T, bool isGarbageCollectedFinalized>
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
409 409
410 // Macro to declare methods needed for each typed heap. 410 // Macro to declare methods needed for each typed heap.
411 #define DECLARE_VISITOR_METHODS(Type) \ 411 #define DECLARE_VISITOR_METHODS(Type) \
412 DEBUG_ONLY(void checkGCInfo(const Type*, const GCInfo*);) \ 412 DEBUG_ONLY(void checkGCInfo(const Type*, const GCInfo*);) \
413 virtual void mark(const Type*, TraceCallback) = 0; \ 413 virtual void mark(const Type*, TraceCallback) = 0; \
414 virtual bool isMarked(const Type*) = 0; 414 virtual bool isMarked(const Type*) = 0;
415 415
416 FOR_EACH_TYPED_HEAP(DECLARE_VISITOR_METHODS) 416 FOR_EACH_TYPED_HEAP(DECLARE_VISITOR_METHODS)
417 #undef DECLARE_VISITOR_METHODS 417 #undef DECLARE_VISITOR_METHODS
418 418
419 #if ENABLE(GC_TRACING) 419 #if ENABLE(GC_PROFILE_MARKING)
420 void setHostInfo(void* object, const String& name) 420 void setHostInfo(void* object, const String& name)
421 { 421 {
422 m_hostObject = object; 422 m_hostObject = object;
423 m_hostName = name; 423 m_hostName = name;
424 } 424 }
425 #endif 425 #endif
426 426
427 protected: 427 protected:
428 virtual void registerWeakCell(void**, WeakPointerCallback) = 0; 428 virtual void registerWeakCell(void**, WeakPointerCallback) = 0;
429 #if ENABLE(GC_TRACING) 429 #if ENABLE(GC_PROFILE_MARKING)
430 void* m_hostObject; 430 void* m_hostObject;
431 String m_hostName; 431 String m_hostName;
432 #endif 432 #endif
433 433
434 private: 434 private:
435 template<typename T> 435 template<typename T>
436 static void handleWeakCell(Visitor* self, void* obj) 436 static void handleWeakCell(Visitor* self, void* obj)
437 { 437 {
438 T** cell = reinterpret_cast<T**>(obj); 438 T** cell = reinterpret_cast<T**>(obj);
439 if (*cell && !self->isAlive(*cell)) 439 if (*cell && !self->isAlive(*cell))
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
589 return visitor->isAlive(this); \ 589 return visitor->isAlive(this); \
590 } \ 590 } \
591 private: 591 private:
592 592
593 #if ENABLE(OILPAN) 593 #if ENABLE(OILPAN)
594 #define WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(TYPE) USING_GARBAGE_COLLECTED_MIXI N(TYPE) 594 #define WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(TYPE) USING_GARBAGE_COLLECTED_MIXI N(TYPE)
595 #else 595 #else
596 #define WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(TYPE) 596 #define WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(TYPE)
597 #endif 597 #endif
598 598
599 #if ENABLE(GC_TRACING) 599 #if ENABLE(GC_PROFILING)
600 template<typename T> 600 template<typename T>
601 struct TypenameStringTrait { 601 struct TypenameStringTrait {
602 static const String& get() 602 static const String& get()
603 { 603 {
604 DEFINE_STATIC_LOCAL(String, typenameString, (WTF::extractTypeNameFromFun ctionName(WTF::extractNameFunction<T>()))); 604 DEFINE_STATIC_LOCAL(String, typenameString, (WTF::extractTypeNameFromFun ctionName(WTF::extractNameFunction<T>())));
605 return typenameString; 605 return typenameString;
606 } 606 }
607 }; 607 };
608 #endif 608 #endif
609 609
610 template<typename T> 610 template<typename T>
611 struct GCInfoAtBase { 611 struct GCInfoAtBase {
612 static const GCInfo* get() 612 static const GCInfo* get()
613 { 613 {
614 static const GCInfo gcInfo = { 614 static const GCInfo gcInfo = {
615 TraceTrait<T>::trace, 615 TraceTrait<T>::trace,
616 FinalizerTrait<T>::finalize, 616 FinalizerTrait<T>::finalize,
617 FinalizerTrait<T>::nonTrivialFinalizer, 617 FinalizerTrait<T>::nonTrivialFinalizer,
618 WTF::IsPolymorphic<T>::value, 618 WTF::IsPolymorphic<T>::value,
619 #if ENABLE(GC_TRACING) 619 #if ENABLE(GC_PROFILING)
620 TypenameStringTrait<T>::get() 620 TypenameStringTrait<T>::get()
621 #endif 621 #endif
622 }; 622 };
623 return &gcInfo; 623 return &gcInfo;
624 } 624 }
625 }; 625 };
626 626
627 template<typename T> class GarbageCollected; 627 template<typename T> class GarbageCollected;
628 template<typename T, bool = WTF::IsSubclassOfTemplate<typename WTF::RemoveConst< T>::Type, GarbageCollected>::value> struct GetGarbageCollectedBase; 628 template<typename T, bool = WTF::IsSubclassOfTemplate<typename WTF::RemoveConst< T>::Type, GarbageCollected>::value> struct GetGarbageCollectedBase;
629 629
(...skipping 11 matching lines...) Expand all
641 struct GCInfoTrait { 641 struct GCInfoTrait {
642 static const GCInfo* get() 642 static const GCInfo* get()
643 { 643 {
644 return GCInfoAtBase<typename GetGarbageCollectedBase<T>::type>::get(); 644 return GCInfoAtBase<typename GetGarbageCollectedBase<T>::type>::get();
645 } 645 }
646 }; 646 };
647 647
648 } 648 }
649 649
650 #endif 650 #endif
OLDNEW
« no previous file with comments | « Source/platform/heap/ThreadState.cpp ('k') | Source/wtf/InstanceCounter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698