OLD | NEW |
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 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 // }; | 142 // }; |
143 // | 143 // |
144 // The "operator new" for B will enter the forbidden GC scope, but | 144 // The "operator new" for B will enter the forbidden GC scope, but |
145 // upon construction, two GarbageCollectedMixinConstructorMarker constructors | 145 // upon construction, two GarbageCollectedMixinConstructorMarker constructors |
146 // will run -- one for A (first) and another for B (secondly). Only | 146 // will run -- one for A (first) and another for B (secondly). Only |
147 // the second one should leave the forbidden GC scope. This is realized by | 147 // the second one should leave the forbidden GC scope. This is realized by |
148 // recording the address of B's GarbageCollectedMixinConstructorMarker | 148 // recording the address of B's GarbageCollectedMixinConstructorMarker |
149 // when the "operator new" for B runs, and leaving the forbidden GC scope | 149 // when the "operator new" for B runs, and leaving the forbidden GC scope |
150 // when the constructor of the recorded GarbageCollectedMixinConstructorMarker | 150 // when the constructor of the recorded GarbageCollectedMixinConstructorMarker |
151 // runs. | 151 // runs. |
152 #define USING_GARBAGE_COLLECTED_MIXIN(TYPE) \ | 152 #define USING_GARBAGE_COLLECTED_MIXIN(TYPE) \ |
153 IS_GARBAGE_COLLECTED_TYPE(); \ | 153 IS_GARBAGE_COLLECTED_TYPE(); \ |
154 DEFINE_GARBAGE_COLLECTED_MIXIN_METHODS(blink::Visitor*, TYPE) \ | 154 DEFINE_GARBAGE_COLLECTED_MIXIN_METHODS(blink::Visitor*, TYPE) \ |
155 DEFINE_GARBAGE_COLLECTED_MIXIN_CONSTRUCTOR_MARKER(TYPE) \ | 155 DEFINE_GARBAGE_COLLECTED_MIXIN_CONSTRUCTOR_MARKER(TYPE) \ |
156 public: \ | 156 public: \ |
157 bool isHeapObjectAlive() const override { \ | 157 bool isHeapObjectAlive() const override { \ |
158 return ThreadHeap::isHeapObjectAlive(this); \ | 158 return ThreadHeap::isHeapObjectAlive(this); \ |
159 } \ | 159 } \ |
160 \ | 160 \ |
161 private: | 161 private: |
162 | 162 |
163 // An empty class with a constructor that's arranged invoked when all derived | 163 // An empty class with a constructor that's arranged invoked when all derived |
164 // constructors of a mixin instance have completed and it is safe to allow GCs | 164 // constructors of a mixin instance have completed and it is safe to allow GCs |
165 // again. See AllocateObjectTrait<> comment for more. | 165 // again. See AllocateObjectTrait<> comment for more. |
166 // | 166 // |
167 // USING_GARBAGE_COLLECTED_MIXIN() declares a | 167 // USING_GARBAGE_COLLECTED_MIXIN() declares a |
168 // GarbageCollectedMixinConstructorMarker<> private field. By following Blink | 168 // GarbageCollectedMixinConstructorMarker<> private field. By following Blink |
169 // convention of using the macro at the top of a class declaration, its | 169 // convention of using the macro at the top of a class declaration, its |
170 // constructor will run first. | 170 // constructor will run first. |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
281 static FalseType isSizeofKnown(...); | 281 static FalseType isSizeofKnown(...); |
282 static T& t; | 282 static T& t; |
283 | 283 |
284 public: | 284 public: |
285 static const bool value = sizeof(TrueType) == sizeof(isSizeofKnown(&t)); | 285 static const bool value = sizeof(TrueType) == sizeof(isSizeofKnown(&t)); |
286 }; | 286 }; |
287 | 287 |
288 } // namespace blink | 288 } // namespace blink |
289 | 289 |
290 #endif | 290 #endif |
OLD | NEW |