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

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

Issue 1670813004: Avoid data race on CrossThreadPersistents during thread detachment. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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.cpp » ('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 21 matching lines...) Expand all
32 #define Handle_h 32 #define Handle_h
33 33
34 #include "platform/heap/Heap.h" 34 #include "platform/heap/Heap.h"
35 #include "platform/heap/HeapAllocator.h" 35 #include "platform/heap/HeapAllocator.h"
36 #include "platform/heap/InlinedGlobalMarkingVisitor.h" 36 #include "platform/heap/InlinedGlobalMarkingVisitor.h"
37 #include "platform/heap/PersistentNode.h" 37 #include "platform/heap/PersistentNode.h"
38 #include "platform/heap/ThreadState.h" 38 #include "platform/heap/ThreadState.h"
39 #include "platform/heap/TraceTraits.h" 39 #include "platform/heap/TraceTraits.h"
40 #include "platform/heap/Visitor.h" 40 #include "platform/heap/Visitor.h"
41 #include "wtf/Allocator.h" 41 #include "wtf/Allocator.h"
42 #include "wtf/Atomics.h"
42 #include "wtf/Functional.h" 43 #include "wtf/Functional.h"
43 #include "wtf/HashFunctions.h" 44 #include "wtf/HashFunctions.h"
44 #include "wtf/Locker.h" 45 #include "wtf/Locker.h"
45 #include "wtf/MainThread.h" 46 #include "wtf/MainThread.h"
46 #include "wtf/RawPtr.h" 47 #include "wtf/RawPtr.h"
47 #include "wtf/RefCounted.h" 48 #include "wtf/RefCounted.h"
48 #include "wtf/TypeTraits.h" 49 #include "wtf/TypeTraits.h"
49 50
50 #if defined(LEAK_SANITIZER) 51 #if defined(LEAK_SANITIZER)
51 #include "wtf/LeakAnnotations.h" 52 #include "wtf/LeakAnnotations.h"
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 { 204 {
204 if (m_persistentNode) { 205 if (m_persistentNode) {
205 ASSERT(ThreadState::current()); 206 ASSERT(ThreadState::current());
206 ThreadState::current()->registerStaticPersistentNode(m_persistentNod e); 207 ThreadState::current()->registerStaticPersistentNode(m_persistentNod e);
207 LEAK_SANITIZER_IGNORE_OBJECT(this); 208 LEAK_SANITIZER_IGNORE_OBJECT(this);
208 } 209 }
209 return this; 210 return this;
210 } 211 }
211 #endif 212 #endif
212 213
214 protected:
215 T* atomicGet() { return reinterpret_cast<T*>(acquireLoad(reinterpret_cast<vo id* volatile*>(&m_raw))); }
216
213 private: 217 private:
214 NO_LAZY_SWEEP_SANITIZE_ADDRESS 218 NO_LAZY_SWEEP_SANITIZE_ADDRESS
215 void assign(T* ptr) 219 void assign(T* ptr)
216 { 220 {
217 m_raw = ptr; 221 if (crossThreadnessConfiguration == CrossThreadPersistentConfiguration)
222 releaseStore(reinterpret_cast<void* volatile*>(&m_raw), ptr);
223 else
224 m_raw = ptr;
218 checkPointer(); 225 checkPointer();
219 if (m_raw) { 226 if (m_raw) {
220 if (!m_persistentNode) 227 if (!m_persistentNode)
221 initialize(); 228 initialize();
222 return; 229 return;
223 } 230 }
224 if (m_persistentNode && crossThreadnessConfiguration != CrossThreadPersi stentConfiguration) 231 if (m_persistentNode && crossThreadnessConfiguration != CrossThreadPersi stentConfiguration)
225 uninitialize(); 232 uninitialize();
226 } 233 }
227 234
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 CrossThreadPersistent(T* raw) : Parent(raw) { } 437 CrossThreadPersistent(T* raw) : Parent(raw) { }
431 CrossThreadPersistent(T& raw) : Parent(raw) { } 438 CrossThreadPersistent(T& raw) : Parent(raw) { }
432 CrossThreadPersistent(const CrossThreadPersistent& other) : Parent(other) { } 439 CrossThreadPersistent(const CrossThreadPersistent& other) : Parent(other) { }
433 template<typename U> 440 template<typename U>
434 CrossThreadPersistent(const CrossThreadPersistent<U>& other) : Parent(other) { } 441 CrossThreadPersistent(const CrossThreadPersistent<U>& other) : Parent(other) { }
435 template<typename U> 442 template<typename U>
436 CrossThreadPersistent(const Member<U>& other) : Parent(other) { } 443 CrossThreadPersistent(const Member<U>& other) : Parent(other) { }
437 template<typename U> 444 template<typename U>
438 CrossThreadPersistent(const RawPtr<U>& other) : Parent(other.get()) { } 445 CrossThreadPersistent(const RawPtr<U>& other) : Parent(other.get()) { }
439 446
447 T* atomicGet() { return Parent::atomicGet(); }
448
440 template<typename U> 449 template<typename U>
441 CrossThreadPersistent& operator=(U* other) 450 CrossThreadPersistent& operator=(U* other)
442 { 451 {
443 Parent::operator=(other); 452 Parent::operator=(other);
444 return *this; 453 return *this;
445 } 454 }
446 455
447 CrossThreadPersistent& operator=(std::nullptr_t) 456 CrossThreadPersistent& operator=(std::nullptr_t)
448 { 457 {
449 Parent::operator=(nullptr); 458 Parent::operator=(nullptr);
(...skipping 1007 matching lines...) Expand 10 before | Expand all | Expand 10 after
1457 // into it. 1466 // into it.
1458 // 1467 //
1459 // TODO(sof): remove this hack once wtf/Functional.h can also work with a ty pe like 1468 // TODO(sof): remove this hack once wtf/Functional.h can also work with a ty pe like
1460 // CrossThreadWeakPersistent<>. 1469 // CrossThreadWeakPersistent<>.
1461 static WeakPtr<T> unwrap(const StorageType& value) { return WeakPtr<T>(WeakR eference<T>::create(value.get())); } 1470 static WeakPtr<T> unwrap(const StorageType& value) { return WeakPtr<T>(WeakR eference<T>::create(value.get())); }
1462 }; 1471 };
1463 1472
1464 } // namespace WTF 1473 } // namespace WTF
1465 1474
1466 #endif 1475 #endif
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/platform/heap/PersistentNode.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698