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

Side by Side Diff: Source/platform/heap/Handle.h

Issue 1089763002: Oilpan: assert that new Persistents belong to Oilpan threads. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 8 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2014 Google Inc. All rights reserved. 2 * Copyright (C) 2014 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 }; 156 };
157 157
158 // Base class for persistent handles. RootsAccessor specifies which list to 158 // Base class for persistent handles. RootsAccessor specifies which list to
159 // link resulting handle into. Owner specifies the class containing trace 159 // link resulting handle into. Owner specifies the class containing trace
160 // method. 160 // method.
161 template<typename RootsAccessor, typename Owner> 161 template<typename RootsAccessor, typename Owner>
162 class PersistentBase : public PersistentNode { 162 class PersistentBase : public PersistentNode {
163 public: 163 public:
164 ~PersistentBase() 164 ~PersistentBase()
165 { 165 {
166 ASSERT(ThreadState::current());
sof 2015/04/16 11:08:46 The assert in the dtor cannot be used, as the Thre
166 typename RootsAccessor::Lock lock; 167 typename RootsAccessor::Lock lock;
167 ASSERT(m_roots == RootsAccessor::roots()); // Check that the thread is u sing the same roots list. 168 ASSERT(m_roots == RootsAccessor::roots()); // Check that the thread is u sing the same roots list.
168 ASSERT(isHeapObjectAlive()); 169 ASSERT(isHeapObjectAlive());
169 ASSERT(m_next->isHeapObjectAlive()); 170 ASSERT(m_next->isHeapObjectAlive());
170 ASSERT(m_prev->isHeapObjectAlive()); 171 ASSERT(m_prev->isHeapObjectAlive());
171 m_next->m_prev = m_prev; 172 m_next->m_prev = m_prev;
172 m_prev->m_next = m_next; 173 m_prev->m_next = m_next;
173 } 174 }
174 175
175 protected: 176 protected:
176 inline PersistentBase() 177 inline PersistentBase()
177 : PersistentNode(TraceMethodDelegate<Owner, &Owner::trace>::trampoline) 178 : PersistentNode(TraceMethodDelegate<Owner, &Owner::trace>::trampoline)
178 #if ENABLE(ASSERT) 179 #if ENABLE(ASSERT)
179 , m_roots(RootsAccessor::roots()) 180 , m_roots(RootsAccessor::roots())
180 #endif 181 #endif
181 { 182 {
183 // Persistent must belong to a thread that will GC it.
184 ASSERT(m_roots == GlobalPersistents::roots() || ThreadState::current());
182 typename RootsAccessor::Lock lock; 185 typename RootsAccessor::Lock lock;
183 m_prev = RootsAccessor::roots(); 186 m_prev = RootsAccessor::roots();
184 m_next = m_prev->m_next; 187 m_next = m_prev->m_next;
185 m_prev->m_next = this; 188 m_prev->m_next = this;
186 m_next->m_prev = this; 189 m_next->m_prev = this;
187 } 190 }
188 191
189 inline explicit PersistentBase(const PersistentBase& otherref) 192 inline explicit PersistentBase(const PersistentBase& otherref)
190 : PersistentNode(otherref.m_trace) 193 : PersistentNode(otherref.m_trace)
191 #if ENABLE(ASSERT) 194 #if ENABLE(ASSERT)
192 , m_roots(RootsAccessor::roots()) 195 , m_roots(RootsAccessor::roots())
193 #endif 196 #endif
194 { 197 {
198 ASSERT(m_roots == GlobalPersistents::roots() || ThreadState::current());
195 // We don't support allocation of thread local Persistents while doing 199 // We don't support allocation of thread local Persistents while doing
196 // thread shutdown/cleanup. 200 // thread shutdown/cleanup.
197 ASSERT(!ThreadState::current()->isTerminating()); 201 ASSERT(!ThreadState::current()->isTerminating());
198 typename RootsAccessor::Lock lock; 202 typename RootsAccessor::Lock lock;
199 ASSERT(otherref.m_roots == m_roots); // Handles must belong to the same list. 203 ASSERT(otherref.m_roots == m_roots); // Handles must belong to the same list.
200 PersistentBase* other = const_cast<PersistentBase*>(&otherref); 204 PersistentBase* other = const_cast<PersistentBase*>(&otherref);
201 m_prev = other; 205 m_prev = other;
202 m_next = other->m_next; 206 m_next = other->m_next;
203 other->m_next = this; 207 other->m_next = this;
204 m_next->m_prev = this; 208 m_next->m_prev = this;
(...skipping 907 matching lines...) Expand 10 before | Expand all | Expand 10 after
1112 template<typename T> 1116 template<typename T>
1113 struct ParamStorageTraits<RawPtr<T>> : public PointerParamStorageTraits<T*, blin k::IsGarbageCollectedType<T>::value> { 1117 struct ParamStorageTraits<RawPtr<T>> : public PointerParamStorageTraits<T*, blin k::IsGarbageCollectedType<T>::value> {
1114 }; 1118 };
1115 1119
1116 template<typename T> 1120 template<typename T>
1117 PassRefPtr<T> adoptRef(blink::RefCountedGarbageCollected<T>*) = delete; 1121 PassRefPtr<T> adoptRef(blink::RefCountedGarbageCollected<T>*) = delete;
1118 1122
1119 } // namespace WTF 1123 } // namespace WTF
1120 1124
1121 #endif 1125 #endif
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698