OLD | NEW |
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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 template<typename T> | 105 template<typename T> |
106 struct DefaultThreadingTrait<T, true> { | 106 struct DefaultThreadingTrait<T, true> { |
107 static const ThreadAffinity Affinity = MainThreadOnly; | 107 static const ThreadAffinity Affinity = MainThreadOnly; |
108 }; | 108 }; |
109 | 109 |
110 template<typename T> | 110 template<typename T> |
111 struct ThreadingTrait { | 111 struct ThreadingTrait { |
112 static const ThreadAffinity Affinity = DefaultThreadingTrait<T>::Affinity; | 112 static const ThreadAffinity Affinity = DefaultThreadingTrait<T>::Affinity; |
113 }; | 113 }; |
114 | 114 |
115 // Marks the specified class as being used from multiple threads. When | |
116 // a class is used from multiple threads we go through thread local | |
117 // storage to get the heap in which to allocate an object of that type | |
118 // and when allocating a Persistent handle for an object with that | |
119 // type. Notice that marking the base class does not automatically | |
120 // mark its descendants and they have to be explicitly marked. | |
121 #define USED_FROM_MULTIPLE_THREADS(Class) \ | |
122 class Class; \ | |
123 template<> struct ThreadingTrait<Class> { \ | |
124 static const ThreadAffinity Affinity = AnyThread; \ | |
125 } | |
126 | |
127 #define USED_FROM_MULTIPLE_THREADS_NAMESPACE(Namespace, Class) \ | |
128 namespace Namespace { \ | |
129 class Class; \ | |
130 } \ | |
131 namespace blink { \ | |
132 template<> struct ThreadingTrait<Namespace::Class> { \ | |
133 static const ThreadAffinity Affinity = AnyThread; \ | |
134 }; \ | |
135 } | |
136 | |
137 template<typename U> class ThreadingTrait<const U> : public ThreadingTrait<U> {
}; | 115 template<typename U> class ThreadingTrait<const U> : public ThreadingTrait<U> {
}; |
138 | 116 |
139 // Declare that a class has a pre-finalizer function. The function is called in | 117 // Declare that a class has a pre-finalizer function. The function is called in |
140 // the object's owner thread, and can access Member<>s to other | 118 // the object's owner thread, and can access Member<>s to other |
141 // garbage-collected objects allocated in the thread. However we must not | 119 // garbage-collected objects allocated in the thread. However we must not |
142 // allocate new garbage-collected objects, nor update Member<> and Persistent<> | 120 // allocate new garbage-collected objects, nor update Member<> and Persistent<> |
143 // pointers. | 121 // pointers. |
144 // | 122 // |
145 // This feature is similar to the HeapHashMap<WeakMember<Foo>, OwnPtr<Disposer>> | 123 // This feature is similar to the HeapHashMap<WeakMember<Foo>, OwnPtr<Disposer>> |
146 // idiom. The difference between this and the idiom is that pre-finalizer | 124 // idiom. The difference between this and the idiom is that pre-finalizer |
(...skipping 796 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
943 // whether the page is part of a terminting thread or | 921 // whether the page is part of a terminting thread or |
944 // if the page is traced after being terminated (orphaned). | 922 // if the page is traced after being terminated (orphaned). |
945 uintptr_t m_terminating : 1; | 923 uintptr_t m_terminating : 1; |
946 uintptr_t m_tracedAfterOrphaned : 1; | 924 uintptr_t m_tracedAfterOrphaned : 1; |
947 uintptr_t m_promptlyFreedSize : 17; // == blinkPageSizeLog2 | 925 uintptr_t m_promptlyFreedSize : 17; // == blinkPageSizeLog2 |
948 }; | 926 }; |
949 | 927 |
950 } | 928 } |
951 | 929 |
952 #endif // ThreadState_h | 930 #endif // ThreadState_h |
OLD | NEW |