| 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 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 TYPE) \ | 184 TYPE) \ |
| 185 DEFINE_GARBAGE_COLLECTED_MIXIN_WRAPPER_METHODS(TYPE) \ | 185 DEFINE_GARBAGE_COLLECTED_MIXIN_WRAPPER_METHODS(TYPE) \ |
| 186 DEFINE_GARBAGE_COLLECTED_MIXIN_CONSTRUCTOR_MARKER(TYPE) \ | 186 DEFINE_GARBAGE_COLLECTED_MIXIN_CONSTRUCTOR_MARKER(TYPE) \ |
| 187 public: \ | 187 public: \ |
| 188 bool isHeapObjectAlive() const override { \ | 188 bool isHeapObjectAlive() const override { \ |
| 189 return ThreadHeap::isHeapObjectAlive(this); \ | 189 return ThreadHeap::isHeapObjectAlive(this); \ |
| 190 } \ | 190 } \ |
| 191 \ | 191 \ |
| 192 private: | 192 private: |
| 193 | 193 |
| 194 // An empty class with a constructor that's arranged invoked when all derived co
nstructors | 194 // An empty class with a constructor that's arranged invoked when all derived |
| 195 // of a mixin instance have completed and it is safe to allow GCs again. See | 195 // constructors of a mixin instance have completed and it is safe to allow GCs |
| 196 // AllocateObjectTrait<> comment for more. | 196 // again. See AllocateObjectTrait<> comment for more. |
| 197 // | 197 // |
| 198 // USING_GARBAGE_COLLECTED_MIXIN() declares a GarbageCollectedMixinConstructorMa
rker<> private | 198 // USING_GARBAGE_COLLECTED_MIXIN() declares a |
| 199 // field. By following Blink convention of using the macro at the top of a class
declaration, | 199 // GarbageCollectedMixinConstructorMarker<> private field. By following Blink |
| 200 // its constructor will run first. | 200 // convention of using the macro at the top of a class declaration, its |
| 201 // constructor will run first. |
| 201 class GarbageCollectedMixinConstructorMarker { | 202 class GarbageCollectedMixinConstructorMarker { |
| 202 public: | 203 public: |
| 203 GarbageCollectedMixinConstructorMarker() { | 204 GarbageCollectedMixinConstructorMarker() { |
| 204 // FIXME: if prompt conservative GCs are needed, forced GCs that | 205 // FIXME: if prompt conservative GCs are needed, forced GCs that |
| 205 // were denied while within this scope, could now be performed. | 206 // were denied while within this scope, could now be performed. |
| 206 // For now, assume the next out-of-line allocation request will | 207 // For now, assume the next out-of-line allocation request will |
| 207 // happen soon enough and take care of it. Mixin objects aren't | 208 // happen soon enough and take care of it. Mixin objects aren't |
| 208 // overly common. | 209 // overly common. |
| 209 ThreadState* state = ThreadState::current(); | 210 ThreadState* state = ThreadState::current(); |
| 210 state->leaveGCForbiddenScopeIfNeeded(this); | 211 state->leaveGCForbiddenScopeIfNeeded(this); |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 static FalseType isSizeofKnown(...); | 295 static FalseType isSizeofKnown(...); |
| 295 static T& t; | 296 static T& t; |
| 296 | 297 |
| 297 public: | 298 public: |
| 298 static const bool value = sizeof(TrueType) == sizeof(isSizeofKnown(&t)); | 299 static const bool value = sizeof(TrueType) == sizeof(isSizeofKnown(&t)); |
| 299 }; | 300 }; |
| 300 | 301 |
| 301 } // namespace blink | 302 } // namespace blink |
| 302 | 303 |
| 303 #endif | 304 #endif |
| OLD | NEW |