Chromium Code Reviews| Index: third_party/WebKit/Source/platform/heap/Heap.h |
| diff --git a/third_party/WebKit/Source/platform/heap/Heap.h b/third_party/WebKit/Source/platform/heap/Heap.h |
| index 67a8bc873ef643166d19459cecc0c07fab89dab3..73a9105140699ecef8df2c624d1e3b37bac6a0e7 100644 |
| --- a/third_party/WebKit/Source/platform/heap/Heap.h |
| +++ b/third_party/WebKit/Source/platform/heap/Heap.h |
| @@ -47,6 +47,8 @@ template<typename T> class Member; |
| template<typename T> class WeakMember; |
| template<typename T> class UntracedMember; |
| +// TODO(peria): Refactor following two sets of template. |
| + |
| template<typename T, bool = NeedsAdjustAndMark<T>::value> class ObjectAliveTrait; |
| template<typename T> |
| @@ -69,6 +71,38 @@ public: |
| } |
| }; |
| +template<typename T, bool = IsGarbageCollectedMixin<T>::value> class GarbageCollectedMixinTrait; |
| + |
| +template<typename T> |
| +class GarbageCollectedMixinTrait<T, true> { |
|
haraken
2015/11/11 10:03:16
I'd rename this to HeapObjectHeaderTrait since thi
peria
2015/11/12 14:38:41
Done.
|
| +public: |
| + static HeapObjectHeader* heapObjectHeader(T* obj) |
| + { |
|
haraken
2015/11/11 10:03:16
Add ASSERT(!ThreadState::current()->isConstructing
peria
2015/11/12 14:38:42
This method may be called in Member<>::get(), and
haraken
2015/11/16 06:20:30
Isn't it unsafe? If obj->heapObjectHeader() is cal
peria
2015/11/16 07:04:42
If an object which is being constructed is an argu
|
| + return obj->heapObjectHeader(); |
| + } |
| + static uint32_t gcGeneration(T* obj) |
| + { |
| + // While constructing GarbageCollectedMixin classes, we skip looking |
| + // for gcGeneration, because the object may not be fully allocated. |
| + if (ThreadState::current()->isConstructingGCMixin()) |
| + return 0; |
| + return heapObjectHeader(obj)->gcGeneration(); |
| + } |
| +}; |
| + |
| +template<typename T> |
| +class GarbageCollectedMixinTrait<T, false> { |
| +public: |
| + static HeapObjectHeader* heapObjectHeader(T* obj) |
| + { |
|
haraken
2015/11/11 10:03:16
Add ASSERT(!ThreadState::current()->isConstructing
peria
2015/11/12 14:38:42
ditto.
|
| + return HeapObjectHeader::fromPayload(obj); |
| + } |
| + static uint32_t gcGeneration(T* obj) |
| + { |
| + return heapObjectHeader(obj)->gcGeneration(); |
| + } |
| +}; |
| + |
| class PLATFORM_EXPORT Heap { |
| public: |
| static void init(); |
| @@ -96,17 +130,17 @@ public: |
| template<typename T> |
| static inline bool isHeapObjectAlive(const Member<T>& member) |
| { |
| - return isHeapObjectAlive(member.get()); |
| + return isHeapObjectAlive(member.unsafeGet()); |
| } |
| template<typename T> |
| static inline bool isHeapObjectAlive(const WeakMember<T>& member) |
| { |
| - return isHeapObjectAlive(member.get()); |
| + return isHeapObjectAlive(member.unsafeGet()); |
| } |
| template<typename T> |
| static inline bool isHeapObjectAlive(const UntracedMember<T>& member) |
| { |
| - return isHeapObjectAlive(member.get()); |
| + return isHeapObjectAlive(member.unsafeGet()); |
| } |
| template<typename T> |
| static inline bool isHeapObjectAlive(const RawPtr<T>& ptr) |
| @@ -260,7 +294,7 @@ public: |
| static void reportMemoryUsageForTracing(); |
| #if ENABLE(ASSERT) |
| - static uint16_t gcGeneration() { return s_gcGeneration; } |
| + static uint32_t gcGeneration() { return s_gcGeneration; } |
| #endif |
| private: |
| @@ -309,7 +343,7 @@ private: |
| static size_t s_partitionAllocSizeAtLastGC; |
| static double s_estimatedMarkingTimePerByte; |
| #if ENABLE(ASSERT) |
| - static uint16_t s_gcGeneration; |
| + static uint32_t s_gcGeneration; |
| #endif |
| friend class ThreadState; |