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

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

Issue 1909803002: Add per thread heap enabled MarkingVisitorImpl Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/platform/heap/MarkingVisitorImpl.h
diff --git a/third_party/WebKit/Source/platform/heap/MarkingVisitorImpl.h b/third_party/WebKit/Source/platform/heap/MarkingVisitorImpl.h
index 346e336b29024b01bb43d3577f6c12fa7fcec9b5..1f40fa1e3f78515f7f25e6c79b85ab1c56b9c94d 100644
--- a/third_party/WebKit/Source/platform/heap/MarkingVisitorImpl.h
+++ b/third_party/WebKit/Source/platform/heap/MarkingVisitorImpl.h
@@ -16,7 +16,28 @@
namespace blink {
-template <typename Derived>
+template <typename Derived, bool PerThreadHeapEnabled>
+struct HeapAccessor {
+ static ThreadHeap* heap(Derived* visitor);
+};
+
+template<typename Derived>
+struct HeapAccessor<Derived, true> {
+ static ThreadHeap* heap(Derived* visitor)
+ {
+ return &visitor->heap();
+ }
+};
+
+template<typename Derived>
+struct HeapAccessor<Derived, false> {
+ static ThreadHeap* heap(Derived* visitor)
+ {
+ return ThreadHeap::mainThreadHeap();
+ }
+};
+
+template <typename Derived, bool PerThreadHeapEnabled>
class MarkingVisitorImpl {
USING_FAST_MALLOC(MarkingVisitorImpl);
protected:
@@ -44,7 +65,7 @@ protected:
header->mark();
if (callback)
- ThreadHeap::mainThreadHeap()->pushTraceCallback(const_cast<void*>(objectPointer), callback);
+ getThreadHeap()->pushTraceCallback(const_cast<void*>(objectPointer), callback);
}
inline void mark(const void* objectPointer, TraceCallback callback)
@@ -58,7 +79,7 @@ protected:
inline void registerDelayedMarkNoTracing(const void* objectPointer)
{
ASSERT(toDerived()->getMarkingMode() != Visitor::WeakProcessing);
- ThreadHeap::mainThreadHeap()->pushPostMarkingCallback(const_cast<void*>(objectPointer), &markNoTracingCallback);
+ getThreadHeap()->pushPostMarkingCallback(const_cast<void*>(objectPointer), &markNoTracingCallback);
}
inline void registerWeakMembers(const void* closure, const void* objectPointer, WeakCallback callback)
@@ -67,19 +88,19 @@ protected:
// We don't want to run weak processings when taking a snapshot.
if (toDerived()->getMarkingMode() == Visitor::SnapshotMarking)
return;
- ThreadHeap::mainThreadHeap()->pushThreadLocalWeakCallback(const_cast<void*>(closure), const_cast<void*>(objectPointer), callback);
+ getThreadHeap()->pushThreadLocalWeakCallback(const_cast<void*>(closure), const_cast<void*>(objectPointer), callback);
}
inline void registerWeakTable(const void* closure, EphemeronCallback iterationCallback, EphemeronCallback iterationDoneCallback)
{
ASSERT(toDerived()->getMarkingMode() != Visitor::WeakProcessing);
- ThreadHeap::mainThreadHeap()->registerWeakTable(const_cast<void*>(closure), iterationCallback, iterationDoneCallback);
+ getThreadHeap()->registerWeakTable(const_cast<void*>(closure), iterationCallback, iterationDoneCallback);
}
#if ENABLE(ASSERT)
inline bool weakTableRegistered(const void* closure)
{
- return ThreadHeap::mainThreadHeap()->weakTableRegistered(closure);
+ return getThreadHeap()->weakTableRegistered(closure);
}
#endif
@@ -110,6 +131,11 @@ protected:
return static_cast<Derived*>(this);
}
+ ThreadHeap* getThreadHeap()
+ {
+ return HeapAccessor<Derived, PerThreadHeapEnabled>::heap(toDerived());
+ }
+
protected:
inline void registerWeakCellWithCallback(void** cell, WeakCallback callback)
{
@@ -117,7 +143,7 @@ protected:
// We don't want to run weak processings when taking a snapshot.
if (toDerived()->getMarkingMode() == Visitor::SnapshotMarking)
return;
- ThreadHeap::mainThreadHeap()->pushGlobalWeakCallback(cell, callback);
+ getThreadHeap()->pushGlobalWeakCallback(cell, callback);
}
private:
« no previous file with comments | « third_party/WebKit/Source/platform/heap/MarkingVisitor.h ('k') | third_party/WebKit/Source/platform/heap/Visitor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698