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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | 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) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 // 64 //
65 // FIXME: We should evaluate the performance gain. Having 65 // FIXME: We should evaluate the performance gain. Having
66 // ThreadAffinity is complicating the implementation and we should get 66 // ThreadAffinity is complicating the implementation and we should get
67 // rid of it if it is fast enough to go through thread-local storage 67 // rid of it if it is fast enough to go through thread-local storage
68 // always. 68 // always.
69 enum ThreadAffinity { 69 enum ThreadAffinity {
70 AnyThread, 70 AnyThread,
71 MainThreadOnly, 71 MainThreadOnly,
72 }; 72 };
73 73
74 // By default all types are considered to be used on the main thread only. 74 class Node;
75 class CSSValue;
76
77 template<typename T>
78 class DerivesNodeOrCSSValue {
79 private:
80 typedef char YesType;
81 struct NoType {
82 char padding[8];
83 };
84
85 static YesType check(Node*);
86 static YesType check(CSSValue*);
87 static NoType check(void*);
88
89 public:
90 static const bool value = sizeof(check(static_cast<T*>(0))) == sizeof(YesTyp e);
91 };
92
93 template<typename T, bool derivesNodeOrCSSValue = DerivesNodeOrCSSValue<T>::valu e > class DefaultThreadingTrait;
zerny-chromium 2014/02/21 07:04:54 I think this can use: derivesNodeOrCSSValue = I
94
95 template<typename T>
96 struct DefaultThreadingTrait<T, false> {
haraken 2014/02/21 06:51:08 Would you add a comment to mention that only Node
97 static const ThreadAffinity Affinity = MainThreadOnly;
98 };
99
100 template<typename T>
101 struct DefaultThreadingTrait<T, true> {
102 static const ThreadAffinity Affinity = AnyThread;
103 };
104
75 template<typename T> 105 template<typename T>
76 struct ThreadingTrait { 106 struct ThreadingTrait {
77 static const ThreadAffinity Affinity = MainThreadOnly; 107 static const ThreadAffinity Affinity = DefaultThreadingTrait<T>::Affinity;
78 }; 108 };
79 109
80 // Marks the specified class as being used from multiple threads. When 110 // Marks the specified class as being used from multiple threads. When
81 // a class is used from multiple threads we go through thread local 111 // a class is used from multiple threads we go through thread local
82 // storage to get the heap in which to allocate an object of that type 112 // storage to get the heap in which to allocate an object of that type
83 // and when allocating a Persistent handle for an object with that 113 // and when allocating a Persistent handle for an object with that
84 // type. Notice that marking the base class does not automatically 114 // type. Notice that marking the base class does not automatically
85 // mark its descendants and they have to be explicitly marked. 115 // mark its descendants and they have to be explicitly marked.
86 #define USED_FROM_MULTIPLE_THREADS(Class) \ 116 #define USED_FROM_MULTIPLE_THREADS(Class) \
87 class Class; \ 117 class Class; \
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after
538 ASSERT(ThreadState::isMainThread()); 568 ASSERT(ThreadState::isMainThread());
539 return ThreadState::mainThreadState(); 569 return ThreadState::mainThreadState();
540 } 570 }
541 }; 571 };
542 572
543 template<> class ThreadStateFor<AnyThread> { 573 template<> class ThreadStateFor<AnyThread> {
544 public: 574 public:
545 static ThreadState* state() { return ThreadState::current(); } 575 static ThreadState* state() { return ThreadState::current(); }
546 }; 576 };
547 577
578 /*
548 // FIXME: Experiment if the threading affinity really matters for performance. 579 // FIXME: Experiment if the threading affinity really matters for performance.
549 // FIXME: Move these macros and other related structures to a separate file. 580 // FIXME: Move these macros and other related structures to a separate file.
550 USED_FROM_MULTIPLE_THREADS(Algorithm); 581 USED_FROM_MULTIPLE_THREADS(Algorithm);
551 USED_FROM_MULTIPLE_THREADS(Crypto); 582 USED_FROM_MULTIPLE_THREADS(Crypto);
552 USED_FROM_MULTIPLE_THREADS(DOMParser); 583 USED_FROM_MULTIPLE_THREADS(DOMParser);
553 USED_FROM_MULTIPLE_THREADS(DeprecatedStorageQuota); 584 USED_FROM_MULTIPLE_THREADS(DeprecatedStorageQuota);
554 USED_FROM_MULTIPLE_THREADS(Key); 585 USED_FROM_MULTIPLE_THREADS(Key);
555 USED_FROM_MULTIPLE_THREADS(KeyPair); 586 USED_FROM_MULTIPLE_THREADS(KeyPair);
556 USED_FROM_MULTIPLE_THREADS(MemoryInfo); 587 USED_FROM_MULTIPLE_THREADS(MemoryInfo);
557 USED_FROM_MULTIPLE_THREADS(Notification); 588 USED_FROM_MULTIPLE_THREADS(Notification);
(...skipping 11 matching lines...) Expand all
569 USED_FROM_MULTIPLE_THREADS(WebKitNotification); 600 USED_FROM_MULTIPLE_THREADS(WebKitNotification);
570 USED_FROM_MULTIPLE_THREADS(WorkerCrypto); 601 USED_FROM_MULTIPLE_THREADS(WorkerCrypto);
571 USED_FROM_MULTIPLE_THREADS(WorkerPerformance); 602 USED_FROM_MULTIPLE_THREADS(WorkerPerformance);
572 USED_FROM_MULTIPLE_THREADS(XMLHttpRequest); 603 USED_FROM_MULTIPLE_THREADS(XMLHttpRequest);
573 USED_FROM_MULTIPLE_THREADS(XMLSerializer); 604 USED_FROM_MULTIPLE_THREADS(XMLSerializer);
574 USED_FROM_MULTIPLE_THREADS(XPathEvaluator); 605 USED_FROM_MULTIPLE_THREADS(XPathEvaluator);
575 USED_FROM_MULTIPLE_THREADS(XPathExpression); 606 USED_FROM_MULTIPLE_THREADS(XPathExpression);
576 USED_FROM_MULTIPLE_THREADS(XPathNSResolver); 607 USED_FROM_MULTIPLE_THREADS(XPathNSResolver);
577 USED_FROM_MULTIPLE_THREADS(XPathResult); 608 USED_FROM_MULTIPLE_THREADS(XPathResult);
578 USED_FROM_MULTIPLE_THREADS(XSLTProcessor); 609 USED_FROM_MULTIPLE_THREADS(XSLTProcessor);
610 */
579 611
580 } 612 }
581 613
582 #endif // ThreadState_h 614 #endif // ThreadState_h
OLDNEW
« 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