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

Side by Side Diff: third_party/WebKit/Source/platform/heap/GarbageCollected.h

Issue 2084513002: Store raw pointers in ScriptWrappableVisitor markind deque (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Cleanup Created 4 years, 6 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef GarbageCollected_h 5 #ifndef GarbageCollected_h
6 #define GarbageCollected_h 6 #define GarbageCollected_h
7 7
8 #include "platform/heap/ThreadState.h" 8 #include "platform/heap/ThreadState.h"
9 #include "wtf/Allocator.h" 9 #include "wtf/Allocator.h"
10 #include "wtf/Assertions.h" 10 #include "wtf/Assertions.h"
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 // 67 //
68 class PLATFORM_EXPORT GarbageCollectedMixin { 68 class PLATFORM_EXPORT GarbageCollectedMixin {
69 public: 69 public:
70 typedef int IsGarbageCollectedMixinMarker; 70 typedef int IsGarbageCollectedMixinMarker;
71 virtual void adjustAndMark(Visitor*) const = 0; 71 virtual void adjustAndMark(Visitor*) const = 0;
72 virtual void trace(Visitor*) { } 72 virtual void trace(Visitor*) { }
73 virtual void adjustAndMark(InlinedGlobalMarkingVisitor) const = 0; 73 virtual void adjustAndMark(InlinedGlobalMarkingVisitor) const = 0;
74 virtual void trace(InlinedGlobalMarkingVisitor); 74 virtual void trace(InlinedGlobalMarkingVisitor);
75 virtual void adjustAndMarkWrapper(const WrapperVisitor*) const = 0; 75 virtual void adjustAndMarkWrapper(const WrapperVisitor*) const = 0;
76 virtual bool isHeapObjectAlive() const = 0; 76 virtual bool isHeapObjectAlive() const = 0;
77 virtual HeapObjectHeader* adjustAndGetHeapObjectHeader() const = 0;
77 }; 78 };
78 79
79 #define DEFINE_GARBAGE_COLLECTED_MIXIN_METHODS(VISITOR, TYPE) \ 80 #define DEFINE_GARBAGE_COLLECTED_MIXIN_METHODS(VISITOR, TYPE) \
80 public: \ 81 public: \
81 void adjustAndMark(VISITOR visitor) const override \ 82 void adjustAndMark(VISITOR visitor) const override \
82 { \ 83 { \
83 typedef WTF::IsSubclassOfTemplate<typename std::remove_const<TYPE>::type , blink::GarbageCollected> IsSubclassOfGarbageCollected; \ 84 typedef WTF::IsSubclassOfTemplate<typename std::remove_const<TYPE>::type , blink::GarbageCollected> IsSubclassOfGarbageCollected; \
84 static_assert(IsSubclassOfGarbageCollected::value, "only garbage collect ed objects can have garbage collected mixins"); \ 85 static_assert(IsSubclassOfGarbageCollected::value, "only garbage collect ed objects can have garbage collected mixins"); \
85 if (TraceEagerlyTrait<TYPE>::value) { \ 86 if (TraceEagerlyTrait<TYPE>::value) { \
86 if (visitor->ensureMarked(static_cast<const TYPE*>(this))) \ 87 if (visitor->ensureMarked(static_cast<const TYPE*>(this))) \
87 TraceTrait<TYPE>::trace(visitor, const_cast<TYPE*>(this)); \ 88 TraceTrait<TYPE>::trace(visitor, const_cast<TYPE*>(this)); \
88 return; \ 89 return; \
89 } \ 90 } \
90 visitor->mark(static_cast<const TYPE*>(this), &blink::TraceTrait<TYPE>:: trace); \ 91 visitor->mark(static_cast<const TYPE*>(this), &blink::TraceTrait<TYPE>:: trace); \
91 } \ 92 } \
92 private: 93 private:
93 94
94 #define DEFINE_GARBAGE_COLLECTED_MIXIN_WRAPPER_METHODS(TYPE) \ 95 #define DEFINE_GARBAGE_COLLECTED_MIXIN_WRAPPER_METHODS(TYPE) \
95 public: \ 96 public: \
96 void adjustAndMarkWrapper(const WrapperVisitor* visitor) const override \ 97 void adjustAndMarkWrapper(const WrapperVisitor* visitor) const override \
97 { \ 98 { \
98 typedef WTF::IsSubclassOfTemplate<typename std::remove_const<TYPE>::type , blink::GarbageCollected> IsSubclassOfGarbageCollected; \ 99 typedef WTF::IsSubclassOfTemplate<typename std::remove_const<TYPE>::type , blink::GarbageCollected> IsSubclassOfGarbageCollected; \
99 static_assert(IsSubclassOfGarbageCollected::value, "only garbage collect ed objects can have garbage collected mixins"); \ 100 static_assert(IsSubclassOfGarbageCollected::value, "only garbage collect ed objects can have garbage collected mixins"); \
100 if (visitor->markWrapperHeader(static_cast<const TYPE*>(this))) { \ 101 TraceTrait<TYPE>::markWrapper(visitor, static_cast<const TYPE*>(this)); \
101 visitor->dispatchTraceWrappers(static_cast<const TYPE*>(this)); \ 102 } \
102 } \ 103 HeapObjectHeader* adjustAndGetHeapObjectHeader() const override \
104 { \
105 typedef WTF::IsSubclassOfTemplate<typename std::remove_const<TYPE>::type , blink::GarbageCollected> IsSubclassOfGarbageCollected; \
106 static_assert(IsSubclassOfGarbageCollected::value, "only garbage collect ed objects can have garbage collected mixins"); \
107 return TraceTrait<TYPE>::heapObjectHeader(static_cast<const TYPE*>(this) ); \
103 } \ 108 } \
104 private: 109 private:
105 110
106 // A C++ object's vptr will be initialized to its leftmost base's vtable after 111 // A C++ object's vptr will be initialized to its leftmost base's vtable after
107 // the constructors of all its subclasses have run, so if a subclass constructor 112 // the constructors of all its subclasses have run, so if a subclass constructor
108 // tries to access any of the vtbl entries of its leftmost base prematurely, 113 // tries to access any of the vtbl entries of its leftmost base prematurely,
109 // it'll find an as-yet incorrect vptr and fail. Which is exactly what a 114 // it'll find an as-yet incorrect vptr and fail. Which is exactly what a
110 // garbage collector will try to do if it tries to access the leftmost base 115 // garbage collector will try to do if it tries to access the leftmost base
111 // while one of the subclass constructors of a GC mixin object triggers a GC. 116 // while one of the subclass constructors of a GC mixin object triggers a GC.
112 // It is consequently not safe to allow any GCs while these objects are under 117 // It is consequently not safe to allow any GCs while these objects are under
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 template<typename U, size_t sz = sizeof(U)> static TrueType isSizeofKnown(U* ); 266 template<typename U, size_t sz = sizeof(U)> static TrueType isSizeofKnown(U* );
262 static FalseType isSizeofKnown(...); 267 static FalseType isSizeofKnown(...);
263 static T& t; 268 static T& t;
264 public: 269 public:
265 static const bool value = sizeof(TrueType) == sizeof(isSizeofKnown(&t)); 270 static const bool value = sizeof(TrueType) == sizeof(isSizeofKnown(&t));
266 }; 271 };
267 272
268 } // namespace blink 273 } // namespace blink
269 274
270 #endif 275 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698