OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. | 2 * Copyright (C) 2008 Apple 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 | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 | 73 |
74 static T& unwrap(T* singleton) { return *singleton; } | 74 static T& unwrap(T* singleton) { return *singleton; } |
75 }; | 75 }; |
76 | 76 |
77 template <typename T> | 77 template <typename T> |
78 class StaticLocalWrapper<T, true> { | 78 class StaticLocalWrapper<T, true> { |
79 public: | 79 public: |
80 using WrapType = blink::Persistent<T>; | 80 using WrapType = blink::Persistent<T>; |
81 | 81 |
82 static T& unwrap(blink::Persistent<T>* singleton) { | 82 static T& unwrap(blink::Persistent<T>* singleton) { |
83 ASSERT(singleton); | 83 DCHECK(singleton); |
84 // If this assert triggers, you're supplying an empty ("()") 'Arguments' | 84 // If this assert triggers, you're supplying an empty ("()") 'Arguments' |
85 // argument to DEFINE_STATIC_LOCAL() - it must be the heap object you wish | 85 // argument to DEFINE_STATIC_LOCAL() - it must be the heap object you wish |
86 // to create as a static singleton and wrapped up with a Persistent | 86 // to create as a static singleton and wrapped up with a Persistent |
87 // reference. | 87 // reference. |
88 ASSERT(*singleton); | 88 DCHECK(*singleton); |
89 return **singleton; | 89 return **singleton; |
90 } | 90 } |
91 }; | 91 }; |
92 | 92 |
93 #if DCHECK_IS_ON() | 93 #if DCHECK_IS_ON() |
94 #define DEFINE_STATIC_LOCAL_CHECK_THREADSAFE_ACCESS(Name) \ | 94 #define DEFINE_STATIC_LOCAL_CHECK_THREADSAFE_ACCESS(Name) \ |
95 static StaticLocalVerifier Name##StaticLocalVerifier; \ | 95 static StaticLocalVerifier Name##StaticLocalVerifier; \ |
96 ASSERT(Name##StaticLocalVerifier.isNotRacy()) | 96 DCHECK(Name##StaticLocalVerifier.isNotRacy()) |
97 #else | 97 #else |
98 #define DEFINE_STATIC_LOCAL_CHECK_THREADSAFE_ACCESS(Name) | 98 #define DEFINE_STATIC_LOCAL_CHECK_THREADSAFE_ACCESS(Name) |
99 #endif | 99 #endif |
100 | 100 |
101 // Use DEFINE_STATIC_LOCAL() to declare and define a static local variable | 101 // Use DEFINE_STATIC_LOCAL() to declare and define a static local variable |
102 // (static T;) so that it is leaked and its destructors are not called at exit. | 102 // (static T;) so that it is leaked and its destructors are not called at exit. |
103 // T may also be a Blink garbage collected object, in which case it is | 103 // T may also be a Blink garbage collected object, in which case it is |
104 // wrapped up by an off-heap Persistent<T> reference to the object, keeping | 104 // wrapped up by an off-heap Persistent<T> reference to the object, keeping |
105 // it alive across GCs. | 105 // it alive across GCs. |
106 // | 106 // |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 * - http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43976 | 138 * - http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43976 |
139 */ | 139 */ |
140 #if CPU(ARM) && COMPILER(GCC) | 140 #if CPU(ARM) && COMPILER(GCC) |
141 template <typename Type> | 141 template <typename Type> |
142 bool isPointerTypeAlignmentOkay(Type* ptr) { | 142 bool isPointerTypeAlignmentOkay(Type* ptr) { |
143 return !(reinterpret_cast<intptr_t>(ptr) % __alignof__(Type)); | 143 return !(reinterpret_cast<intptr_t>(ptr) % __alignof__(Type)); |
144 } | 144 } |
145 | 145 |
146 template <typename TypePtr> | 146 template <typename TypePtr> |
147 TypePtr reinterpret_cast_ptr(void* ptr) { | 147 TypePtr reinterpret_cast_ptr(void* ptr) { |
148 ASSERT(isPointerTypeAlignmentOkay(reinterpret_cast<TypePtr>(ptr))); | 148 DCHECK(isPointerTypeAlignmentOkay(reinterpret_cast<TypePtr>(ptr))); |
149 return reinterpret_cast<TypePtr>(ptr); | 149 return reinterpret_cast<TypePtr>(ptr); |
150 } | 150 } |
151 | 151 |
152 template <typename TypePtr> | 152 template <typename TypePtr> |
153 TypePtr reinterpret_cast_ptr(const void* ptr) { | 153 TypePtr reinterpret_cast_ptr(const void* ptr) { |
154 ASSERT(isPointerTypeAlignmentOkay(reinterpret_cast<TypePtr>(ptr))); | 154 DCHECK(isPointerTypeAlignmentOkay(reinterpret_cast<TypePtr>(ptr))); |
155 return reinterpret_cast<TypePtr>(ptr); | 155 return reinterpret_cast<TypePtr>(ptr); |
156 } | 156 } |
157 #else | 157 #else |
158 template <typename Type> | 158 template <typename Type> |
159 bool isPointerTypeAlignmentOkay(Type*) { | 159 bool isPointerTypeAlignmentOkay(Type*) { |
160 return true; | 160 return true; |
161 } | 161 } |
162 #define reinterpret_cast_ptr reinterpret_cast | 162 #define reinterpret_cast_ptr reinterpret_cast |
163 #endif | 163 #endif |
164 | 164 |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 template <typename T> | 230 template <typename T> |
231 char (&ArrayLengthHelperFunction(T (&)[0]))[0]; | 231 char (&ArrayLengthHelperFunction(T (&)[0]))[0]; |
232 #endif | 232 #endif |
233 #define WTF_ARRAY_LENGTH(array) sizeof(::WTF::ArrayLengthHelperFunction(array)) | 233 #define WTF_ARRAY_LENGTH(array) sizeof(::WTF::ArrayLengthHelperFunction(array)) |
234 | 234 |
235 } // namespace WTF | 235 } // namespace WTF |
236 | 236 |
237 // This version of placement new omits a 0 check. | 237 // This version of placement new omits a 0 check. |
238 enum NotNullTag { NotNull }; | 238 enum NotNullTag { NotNull }; |
239 inline void* operator new(size_t, NotNullTag, void* location) { | 239 inline void* operator new(size_t, NotNullTag, void* location) { |
240 ASSERT(location); | 240 DCHECK(location); |
241 return location; | 241 return location; |
242 } | 242 } |
243 | 243 |
244 using WTF::bitwiseCast; | 244 using WTF::bitwiseCast; |
245 using WTF::safeCast; | 245 using WTF::safeCast; |
246 | 246 |
247 #endif // WTF_StdLibExtras_h | 247 #endif // WTF_StdLibExtras_h |
OLD | NEW |