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

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

Issue 1964013002: Handle overlapping CrossThreadPersistent<> releases. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: drop unneeded PLATFORM_EXPORTs Created 4 years, 7 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 | third_party/WebKit/Source/platform/heap/PersistentNode.h » ('j') | 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 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 220
221 NO_LAZY_SWEEP_SANITIZE_ADDRESS 221 NO_LAZY_SWEEP_SANITIZE_ADDRESS
222 void initialize() 222 void initialize()
223 { 223 {
224 ASSERT(!m_persistentNode); 224 ASSERT(!m_persistentNode);
225 if (!m_raw) 225 if (!m_raw)
226 return; 226 return;
227 227
228 TraceCallback traceCallback = TraceMethodDelegate<PersistentBase<T, weak nessConfiguration, crossThreadnessConfiguration>, &PersistentBase<T, weaknessCon figuration, crossThreadnessConfiguration>::trace>::trampoline; 228 TraceCallback traceCallback = TraceMethodDelegate<PersistentBase<T, weak nessConfiguration, crossThreadnessConfiguration>, &PersistentBase<T, weaknessCon figuration, crossThreadnessConfiguration>::trace>::trampoline;
229 if (crossThreadnessConfiguration == CrossThreadPersistentConfiguration) { 229 if (crossThreadnessConfiguration == CrossThreadPersistentConfiguration) {
230 m_persistentNode = ProcessHeap::crossThreadPersistentRegion().alloca tePersistentNode(this, traceCallback); 230 ProcessHeap::crossThreadPersistentRegion().allocatePersistentNode(m_ persistentNode, this, traceCallback);
231 } else { 231 return;
232 ThreadState* state = ThreadStateFor<ThreadingTrait<T>::Affinity>::st ate(); 232 }
233 ASSERT(state->checkThread()); 233 ThreadState* state = ThreadStateFor<ThreadingTrait<T>::Affinity>::state( );
234 m_persistentNode = state->getPersistentRegion()->allocatePersistentN ode(this, traceCallback); 234 ASSERT(state->checkThread());
235 m_persistentNode = state->getPersistentRegion()->allocatePersistentNode( this, traceCallback);
235 #if ENABLE(ASSERT) 236 #if ENABLE(ASSERT)
236 m_state = state; 237 m_state = state;
237 #endif 238 #endif
238 }
239 } 239 }
240 240
241 void uninitialize() 241 void uninitialize()
242 { 242 {
243 if (!m_persistentNode) 243 if (!m_persistentNode)
244 return; 244 return;
245 245
246 if (crossThreadnessConfiguration == CrossThreadPersistentConfiguration) { 246 if (crossThreadnessConfiguration == CrossThreadPersistentConfiguration) {
247 ProcessHeap::crossThreadPersistentRegion().freePersistentNode(m_pers istentNode); 247 ProcessHeap::crossThreadPersistentRegion().freePersistentNode(m_pers istentNode);
248 } else { 248 return;
249 ThreadState* state = ThreadStateFor<ThreadingTrait<T>::Affinity>::st ate();
250 ASSERT(state->checkThread());
251 // Persistent handle must be created and destructed in the same thre ad.
252 ASSERT(m_state == state);
253 state->freePersistentNode(m_persistentNode);
254 } 249 }
250 ThreadState* state = ThreadStateFor<ThreadingTrait<T>::Affinity>::state( );
251 ASSERT(state->checkThread());
252 // Persistent handle must be created and destructed in the same thread.
253 ASSERT(m_state == state);
254 state->freePersistentNode(m_persistentNode);
255 m_persistentNode = nullptr; 255 m_persistentNode = nullptr;
256 } 256 }
257 257
258 void checkPointer() 258 void checkPointer()
259 { 259 {
260 #if ENABLE(ASSERT) && defined(ADDRESS_SANITIZER) 260 #if ENABLE(ASSERT) && defined(ADDRESS_SANITIZER)
261 if (!m_raw) 261 if (!m_raw)
262 return; 262 return;
263 263
264 // ThreadHeap::isHeapObjectAlive(m_raw) checks that m_raw is a traceable 264 // ThreadHeap::isHeapObjectAlive(m_raw) checks that m_raw is a traceable
(...skipping 948 matching lines...) Expand 10 before | Expand all | Expand 10 after
1213 // into it. 1213 // into it.
1214 // 1214 //
1215 // TODO(sof): remove this hack once wtf/Functional.h can also work with a ty pe like 1215 // TODO(sof): remove this hack once wtf/Functional.h can also work with a ty pe like
1216 // CrossThreadWeakPersistent<>. 1216 // CrossThreadWeakPersistent<>.
1217 static WeakPtr<T> unwrap(const StorageType& value) { return WeakPtr<T>(WeakR eference<T>::create(value.get())); } 1217 static WeakPtr<T> unwrap(const StorageType& value) { return WeakPtr<T>(WeakR eference<T>::create(value.get())); }
1218 }; 1218 };
1219 1219
1220 } // namespace WTF 1220 } // namespace WTF
1221 1221
1222 #endif 1222 #endif
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/platform/heap/PersistentNode.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698