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

Unified Diff: Source/heap/ThreadState.h

Issue 171743004: Oilpan: mark ThreadAffinity as MainThreadOnly for Node or CSSValue inheriting classes. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/heap/ThreadState.h
diff --git a/Source/heap/ThreadState.h b/Source/heap/ThreadState.h
index 026d9e5cead408e9aab2fdc581a7913004ba25e6..957cd178112aa84de190039e8248ea3fcf85de53 100644
--- a/Source/heap/ThreadState.h
+++ b/Source/heap/ThreadState.h
@@ -71,12 +71,42 @@ enum ThreadAffinity {
MainThreadOnly,
};
-// By default all types are considered to be used on the main thread only.
+class Node;
+class CSSValue;
+
template<typename T>
-struct ThreadingTrait {
+class DerivesNodeOrCSSValue {
+private:
+ typedef char YesType;
+ struct NoType {
+ char padding[8];
+ };
+
+ static YesType check(Node*);
+ static YesType check(CSSValue*);
+ static NoType check(void*);
+
+public:
+ static const bool value = sizeof(check(static_cast<T*>(0))) == sizeof(YesType);
+};
+
+template<typename T, bool derivesNodeOrCSSValue = DerivesNodeOrCSSValue<T>::value > class DefaultThreadingTrait;
zerny-chromium 2014/02/21 07:04:54 I think this can use: derivesNodeOrCSSValue = I
+
+template<typename T>
+struct DefaultThreadingTrait<T, false> {
haraken 2014/02/21 06:51:08 Would you add a comment to mention that only Node
static const ThreadAffinity Affinity = MainThreadOnly;
};
+template<typename T>
+struct DefaultThreadingTrait<T, true> {
+ static const ThreadAffinity Affinity = AnyThread;
+};
+
+template<typename T>
+struct ThreadingTrait {
+ static const ThreadAffinity Affinity = DefaultThreadingTrait<T>::Affinity;
+};
+
// Marks the specified class as being used from multiple threads. When
// a class is used from multiple threads we go through thread local
// storage to get the heap in which to allocate an object of that type
@@ -545,6 +575,7 @@ public:
static ThreadState* state() { return ThreadState::current(); }
};
+/*
// FIXME: Experiment if the threading affinity really matters for performance.
// FIXME: Move these macros and other related structures to a separate file.
USED_FROM_MULTIPLE_THREADS(Algorithm);
@@ -576,6 +607,7 @@ USED_FROM_MULTIPLE_THREADS(XPathExpression);
USED_FROM_MULTIPLE_THREADS(XPathNSResolver);
USED_FROM_MULTIPLE_THREADS(XPathResult);
USED_FROM_MULTIPLE_THREADS(XSLTProcessor);
+*/
}
« 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