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

Unified Diff: third_party/WebKit/Source/platform/heap/Handle.h

Issue 1477023003: Refactor the Heap into ThreadHeap to prepare for per thread heaps Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/platform/heap/Handle.h
diff --git a/third_party/WebKit/Source/platform/heap/Handle.h b/third_party/WebKit/Source/platform/heap/Handle.h
index 64e43fd71243011277fb2052e26dfe146148b0dc..478d7635dec2c327821610fbaa06ef3101c704ac 100644
--- a/third_party/WebKit/Source/platform/heap/Handle.h
+++ b/third_party/WebKit/Source/platform/heap/Handle.h
@@ -55,7 +55,8 @@ enum WeaknessPersistentConfiguration {
enum CrossThreadnessPersistentConfiguration {
SingleThreadPersistentConfiguration,
- CrossThreadPersistentConfiguration
+ CrossThreadPersistentConfiguration,
+ XThreadPersistentConfiguration
};
template<typename T, WeaknessPersistentConfiguration weaknessConfiguration, CrossThreadnessPersistentConfiguration crossThreadnessConfiguration>
@@ -207,7 +208,12 @@ private:
return;
TraceCallback traceCallback = TraceMethodDelegate<PersistentBase<T, weaknessConfiguration, crossThreadnessConfiguration>, &PersistentBase<T, weaknessConfiguration, crossThreadnessConfiguration>::trace>::trampoline;
- if (crossThreadnessConfiguration == CrossThreadPersistentConfiguration) {
+ if (crossThreadnessConfiguration == XThreadPersistentConfiguration) {
+ BasePage* page = pageFromObject(m_raw);
+ if (!page)
+ return;
+ m_persistentNode = page->heap()->threadState()->xThreadPersistentRegion()->allocatePersistentNode(this, traceCallback);
+ } else if (crossThreadnessConfiguration == CrossThreadPersistentConfiguration) {
m_persistentNode = ThreadState::crossThreadPersistentRegion().allocatePersistentNode(this, traceCallback);
} else {
ThreadState* state = ThreadStateFor<ThreadingTrait<T>::Affinity>::state();
@@ -224,7 +230,11 @@ private:
if (!m_persistentNode)
return;
- if (crossThreadnessConfiguration == CrossThreadPersistentConfiguration) {
+ if (crossThreadnessConfiguration == XThreadPersistentConfiguration) {
+ BasePage* page = pageFromObject(m_raw);
+ ASSERT(page);
+ page->heap()->threadState()->xThreadPersistentRegion()->freePersistentNode(m_persistentNode);
+ } else if (crossThreadnessConfiguration == CrossThreadPersistentConfiguration) {
ThreadState::crossThreadPersistentRegion().freePersistentNode(m_persistentNode);
} else {
ThreadState* state = ThreadStateFor<ThreadingTrait<T>::Affinity>::state();
@@ -510,6 +520,63 @@ public:
}
};
+template<typename T>
+class XThreadPersistent : public PersistentBase<T, NonWeakPersistentConfiguration, XThreadPersistentConfiguration> {
+ typedef PersistentBase<T, NonWeakPersistentConfiguration, XThreadPersistentConfiguration> Parent;
+public:
+ XThreadPersistent() : Parent() { }
+ XThreadPersistent(std::nullptr_t) : Parent(nullptr) { }
+ XThreadPersistent(T* raw) : Parent(raw) { }
+ XThreadPersistent(T& raw) : Parent(raw) { }
+ XThreadPersistent(const XThreadPersistent& other) : Parent(other) { }
+ template<typename U>
+ XThreadPersistent(const XThreadPersistent<U>& other) : Parent(other) { }
+ template<typename U>
+ XThreadPersistent(const Member<U>& other) : Parent(other) { }
+ template<typename U>
+ XThreadPersistent(const RawPtr<U>& other) : Parent(other.get()) { }
+
+ template<typename U>
+ XThreadPersistent& operator=(U* other)
+ {
+ Parent::operator=(other);
+ return *this;
+ }
+
+ XThreadPersistent& operator=(std::nullptr_t)
+ {
+ Parent::operator=(nullptr);
+ return *this;
+ }
+
+ XThreadPersistent& operator=(const XThreadPersistent& other)
+ {
+ Parent::operator=(other);
+ return *this;
+ }
+
+ template<typename U>
+ XThreadPersistent& operator=(const XThreadPersistent<U>& other)
+ {
+ Parent::operator=(other);
+ return *this;
+ }
+
+ template<typename U>
+ XThreadPersistent& operator=(const Member<U>& other)
+ {
+ Parent::operator=(other);
+ return *this;
+ }
+
+ template<typename U>
+ XThreadPersistent& operator=(const RawPtr<U>& other)
+ {
+ Parent::operator=(other);
+ return *this;
+ }
+};
+
template<typename Collection>
class PersistentHeapCollectionBase : public Collection {
// We overload the various new and delete operators with using the WTF PartitionAllocator to ensure persistent
@@ -1477,7 +1544,7 @@ struct PointerParamStorageTraits<T*, false> {
template<typename T>
struct PointerParamStorageTraits<T*, true> {
static_assert(sizeof(T), "T must be fully defined");
- using StorageType = blink::CrossThreadPersistent<T>;
+ using StorageType = blink::XThreadPersistent<T>;
static StorageType wrap(T* value) { return value; }
static T* unwrap(const StorageType& value) { return value.get(); }

Powered by Google App Engine
This is Rietveld 408576698