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/Assertions.h" | 9 #include "wtf/Assertions.h" |
10 #include "wtf/ListHashSet.h" | 10 #include "wtf/ListHashSet.h" |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 // derived constructors have run, it will invoke the constructor | 155 // derived constructors have run, it will invoke the constructor |
156 // for a field whose only purpose is to leave the GC scope. | 156 // for a field whose only purpose is to leave the GC scope. |
157 // GarbageCollectedMixinConstructorMarker's constructor takes care of | 157 // GarbageCollectedMixinConstructorMarker's constructor takes care of |
158 // this and the field is declared by way of USING_GARBAGE_COLLECTED_MIXIN(). | 158 // this and the field is declared by way of USING_GARBAGE_COLLECTED_MIXIN(). |
159 | 159 |
160 #define DEFINE_GARBAGE_COLLECTED_MIXIN_CONSTRUCTOR_MARKER(TYPE)
\ | 160 #define DEFINE_GARBAGE_COLLECTED_MIXIN_CONSTRUCTOR_MARKER(TYPE)
\ |
161 public:
\ | 161 public:
\ |
162 GC_PLUGIN_IGNORE("crbug.com/456823") NO_SANITIZE_UNRELATED_CAST
\ | 162 GC_PLUGIN_IGNORE("crbug.com/456823") NO_SANITIZE_UNRELATED_CAST
\ |
163 void* operator new(size_t size)
\ | 163 void* operator new(size_t size)
\ |
164 {
\ | 164 {
\ |
165 void* object = TYPE::allocateObject(size);
\ | 165 void* object = TYPE::allocateObject(size, IsEagerlyFinalizedType<TYPE>::
value); \ |
166 ThreadState* state = ThreadStateFor<ThreadingTrait<TYPE>::Affinity>::sta
te(); \ | 166 ThreadState* state = ThreadStateFor<ThreadingTrait<TYPE>::Affinity>::sta
te(); \ |
167 state->enterGCForbiddenScopeIfNeeded(&(reinterpret_cast<TYPE*>(object)->
m_mixinConstructorMarker)); \ | 167 state->enterGCForbiddenScopeIfNeeded(&(reinterpret_cast<TYPE*>(object)->
m_mixinConstructorMarker)); \ |
168 return object;
\ | 168 return object;
\ |
169 }
\ | 169 }
\ |
170 GarbageCollectedMixinConstructorMarker m_mixinConstructorMarker;
\ | 170 GarbageCollectedMixinConstructorMarker m_mixinConstructorMarker;
\ |
171 private: | 171 private: |
172 | 172 |
173 // Mixins that wrap/nest others requires extra handling: | 173 // Mixins that wrap/nest others requires extra handling: |
174 // | 174 // |
175 // class A : public GarbageCollected<A>, public GarbageCollectedMixin { | 175 // class A : public GarbageCollected<A>, public GarbageCollectedMixin { |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
399 #define GC_PLUGIN_IGNORE(bug) \ | 399 #define GC_PLUGIN_IGNORE(bug) \ |
400 __attribute__((annotate("blink_gc_plugin_ignore"))) | 400 __attribute__((annotate("blink_gc_plugin_ignore"))) |
401 #else | 401 #else |
402 #define STACK_ALLOCATED() DISALLOW_ALLOCATION() | 402 #define STACK_ALLOCATED() DISALLOW_ALLOCATION() |
403 #define GC_PLUGIN_IGNORE(bug) | 403 #define GC_PLUGIN_IGNORE(bug) |
404 #endif | 404 #endif |
405 | 405 |
406 } // namespace blink | 406 } // namespace blink |
407 | 407 |
408 #endif | 408 #endif |
OLD | NEW |