OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 // | 180 // |
181 // Compiler-specific feature detection | 181 // Compiler-specific feature detection |
182 // | 182 // |
183 // V8_HAS___ALIGNOF - __alignof(type) operator supported | 183 // V8_HAS___ALIGNOF - __alignof(type) operator supported |
184 // V8_HAS___ALIGNOF__ - __alignof__(type) operator supported | 184 // V8_HAS___ALIGNOF__ - __alignof__(type) operator supported |
185 // V8_HAS_ATTRIBUTE_ALIGNED - __attribute__((aligned(n))) supported | 185 // V8_HAS_ATTRIBUTE_ALIGNED - __attribute__((aligned(n))) supported |
186 // V8_HAS_ATTRIBUTE_ALWAYS_INLINE - __attribute__((always_inline)) | 186 // V8_HAS_ATTRIBUTE_ALWAYS_INLINE - __attribute__((always_inline)) |
187 // supported | 187 // supported |
188 // V8_HAS_ATTRIBUTE_DEPRECATED - __attribute__((deprecated)) supported | 188 // V8_HAS_ATTRIBUTE_DEPRECATED - __attribute__((deprecated)) supported |
189 // V8_HAS_ATTRIBUTE_NOINLINE - __attribute__((noinline)) supported | 189 // V8_HAS_ATTRIBUTE_NOINLINE - __attribute__((noinline)) supported |
| 190 // V8_HAS_ATTRIBUTE_PURE - __attribute__((pure)) supported |
190 // V8_HAS_ATTRIBUTE_VISIBILITY - __attribute__((visibility)) supported | 191 // V8_HAS_ATTRIBUTE_VISIBILITY - __attribute__((visibility)) supported |
191 // V8_HAS_ATTRIBUTE_WARN_UNUSED_RESULT - __attribute__((warn_unused_result)) | 192 // V8_HAS_ATTRIBUTE_WARN_UNUSED_RESULT - __attribute__((warn_unused_result)) |
192 // supported | 193 // supported |
193 // V8_HAS_BUILTIN_EXPECT - __builtin_expect() supported | 194 // V8_HAS_BUILTIN_EXPECT - __builtin_expect() supported |
194 // V8_HAS_DECLSPEC_ALIGN - __declspec(align(n)) supported | 195 // V8_HAS_DECLSPEC_ALIGN - __declspec(align(n)) supported |
195 // V8_HAS_DECLSPEC_DEPRECATED - __declspec(deprecated) supported | 196 // V8_HAS_DECLSPEC_DEPRECATED - __declspec(deprecated) supported |
196 // V8_HAS_DECLSPEC_NOINLINE - __declspec(noinline) supported | 197 // V8_HAS_DECLSPEC_NOINLINE - __declspec(noinline) supported |
197 // V8_HAS___FINAL - __final supported in non-C++11 mode | 198 // V8_HAS___FINAL - __final supported in non-C++11 mode |
198 // V8_HAS___FORCEINLINE - __forceinline supported | 199 // V8_HAS___FORCEINLINE - __forceinline supported |
199 // V8_HAS_SEALED - MSVC style sealed marker supported | 200 // V8_HAS_SEALED - MSVC style sealed marker supported |
200 // | 201 // |
201 // Note that testing for compilers and/or features must be done using #if | 202 // Note that testing for compilers and/or features must be done using #if |
202 // not #ifdef. For example, to test for Intel C++ Compiler, use: | 203 // not #ifdef. For example, to test for Intel C++ Compiler, use: |
203 // #if V8_CC_INTEL | 204 // #if V8_CC_INTEL |
204 // ... | 205 // ... |
205 // #endif | 206 // #endif |
206 | 207 |
207 #if defined(__clang__) | 208 #if defined(__clang__) |
208 | 209 |
209 # define V8_CC_CLANG 1 | 210 # define V8_CC_CLANG 1 |
210 | 211 |
211 // Clang defines __alignof__ as alias for __alignof | 212 // Clang defines __alignof__ as alias for __alignof |
212 # define V8_HAS___ALIGNOF 1 | 213 # define V8_HAS___ALIGNOF 1 |
213 # define V8_HAS___ALIGNOF__ V8_HAS___ALIGNOF | 214 # define V8_HAS___ALIGNOF__ V8_HAS___ALIGNOF |
214 | 215 |
215 # define V8_HAS_ATTRIBUTE_ALIGNED (__has_attribute(aligned)) | 216 # define V8_HAS_ATTRIBUTE_ALIGNED (__has_attribute(aligned)) |
216 # define V8_HAS_ATTRIBUTE_ALWAYS_INLINE (__has_attribute(always_inline)) | 217 # define V8_HAS_ATTRIBUTE_ALWAYS_INLINE (__has_attribute(always_inline)) |
217 # define V8_HAS_ATTRIBUTE_DEPRECATED (__has_attribute(deprecated)) | 218 # define V8_HAS_ATTRIBUTE_DEPRECATED (__has_attribute(deprecated)) |
218 # define V8_HAS_ATTRIBUTE_NOINLINE (__has_attribute(noinline)) | 219 # define V8_HAS_ATTRIBUTE_NOINLINE (__has_attribute(noinline)) |
| 220 # define V8_HAS_ATTRIBUTE_PURE (__has_attribute(pure)) |
219 # define V8_HAS_ATTRIBUTE_VISIBILITY (__has_attribute(visibility)) | 221 # define V8_HAS_ATTRIBUTE_VISIBILITY (__has_attribute(visibility)) |
220 # define V8_HAS_ATTRIBUTE_WARN_UNUSED_RESULT \ | 222 # define V8_HAS_ATTRIBUTE_WARN_UNUSED_RESULT \ |
221 (__has_attribute(warn_unused_result)) | 223 (__has_attribute(warn_unused_result)) |
222 | 224 |
223 # define V8_HAS_BUILTIN_EXPECT (__has_builtin(__builtin_expect)) | 225 # define V8_HAS_BUILTIN_EXPECT (__has_builtin(__builtin_expect)) |
224 | 226 |
225 # define V8_HAS_CXX11_ALIGNAS (__has_feature(cxx_alignas)) | 227 # define V8_HAS_CXX11_ALIGNAS (__has_feature(cxx_alignas)) |
226 # define V8_HAS_CXX11_STATIC_ASSERT (__has_feature(cxx_static_assert)) | 228 # define V8_HAS_CXX11_STATIC_ASSERT (__has_feature(cxx_static_assert)) |
227 # define V8_HAS_CXX11_DELETE (__has_feature(cxx_deleted_functions)) | 229 # define V8_HAS_CXX11_DELETE (__has_feature(cxx_deleted_functions)) |
228 # define V8_HAS_CXX11_FINAL (__has_feature(cxx_override_control)) | 230 # define V8_HAS_CXX11_FINAL (__has_feature(cxx_override_control)) |
(...skipping 10 matching lines...) Expand all Loading... |
239 | 241 |
240 # define V8_HAS___ALIGNOF__ (V8_GNUC_PREREQ(4, 3, 0)) | 242 # define V8_HAS___ALIGNOF__ (V8_GNUC_PREREQ(4, 3, 0)) |
241 | 243 |
242 # define V8_HAS_ATTRIBUTE_ALIGNED (V8_GNUC_PREREQ(2, 95, 0)) | 244 # define V8_HAS_ATTRIBUTE_ALIGNED (V8_GNUC_PREREQ(2, 95, 0)) |
243 // always_inline is available in gcc 4.0 but not very reliable until 4.4. | 245 // always_inline is available in gcc 4.0 but not very reliable until 4.4. |
244 // Works around "sorry, unimplemented: inlining failed" build errors with | 246 // Works around "sorry, unimplemented: inlining failed" build errors with |
245 // older compilers. | 247 // older compilers. |
246 # define V8_HAS_ATTRIBUTE_ALWAYS_INLINE (V8_GNUC_PREREQ(4, 4, 0)) | 248 # define V8_HAS_ATTRIBUTE_ALWAYS_INLINE (V8_GNUC_PREREQ(4, 4, 0)) |
247 # define V8_HAS_ATTRIBUTE_DEPRECATED (V8_GNUC_PREREQ(3, 4, 0)) | 249 # define V8_HAS_ATTRIBUTE_DEPRECATED (V8_GNUC_PREREQ(3, 4, 0)) |
248 # define V8_HAS_ATTRIBUTE_NOINLINE (V8_GNUC_PREREQ(3, 4, 0)) | 250 # define V8_HAS_ATTRIBUTE_NOINLINE (V8_GNUC_PREREQ(3, 4, 0)) |
| 251 # define V8_HAS_ATTRIBUTE_PURE (V8_GNUC_PREREQ(2, 96, 0)) |
249 # define V8_HAS_ATTRIBUTE_VISIBILITY (V8_GNUC_PREREQ(4, 3, 0)) | 252 # define V8_HAS_ATTRIBUTE_VISIBILITY (V8_GNUC_PREREQ(4, 3, 0)) |
250 # define V8_HAS_ATTRIBUTE_WARN_UNUSED_RESULT \ | 253 # define V8_HAS_ATTRIBUTE_WARN_UNUSED_RESULT \ |
251 (!V8_CC_INTEL && V8_GNUC_PREREQ(4, 1, 0)) | 254 (!V8_CC_INTEL && V8_GNUC_PREREQ(4, 1, 0)) |
252 | 255 |
253 # define V8_HAS_BUILTIN_EXPECT (V8_GNUC_PREREQ(2, 96, 0)) | 256 # define V8_HAS_BUILTIN_EXPECT (V8_GNUC_PREREQ(2, 96, 0)) |
254 | 257 |
255 // g++ requires -std=c++0x or -std=gnu++0x to support C++11 functionality | 258 // g++ requires -std=c++0x or -std=gnu++0x to support C++11 functionality |
256 // without warnings (functionality used by the macros below). These modes | 259 // without warnings (functionality used by the macros below). These modes |
257 // are detectable by checking whether __GXX_EXPERIMENTAL_CXX0X__ is defined or, | 260 // are detectable by checking whether __GXX_EXPERIMENTAL_CXX0X__ is defined or, |
258 // more standardly, by checking whether __cplusplus has a C++11 or greater | 261 // more standardly, by checking whether __cplusplus has a C++11 or greater |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
318 // A macro to mark classes or functions as deprecated. | 321 // A macro to mark classes or functions as deprecated. |
319 #if !V8_DISABLE_DEPRECATIONS && V8_HAS_ATTRIBUTE_DEPRECATED | 322 #if !V8_DISABLE_DEPRECATIONS && V8_HAS_ATTRIBUTE_DEPRECATED |
320 # define V8_DEPRECATED(declarator) declarator __attribute__((deprecated)) | 323 # define V8_DEPRECATED(declarator) declarator __attribute__((deprecated)) |
321 #elif !V8_DISABLE_DEPRECATIONS && V8_HAS_DECLSPEC_DEPRECATED | 324 #elif !V8_DISABLE_DEPRECATIONS && V8_HAS_DECLSPEC_DEPRECATED |
322 # define V8_DEPRECATED(declarator) __declspec(deprecated) declarator | 325 # define V8_DEPRECATED(declarator) __declspec(deprecated) declarator |
323 #else | 326 #else |
324 # define V8_DEPRECATED(declarator) declarator | 327 # define V8_DEPRECATED(declarator) declarator |
325 #endif | 328 #endif |
326 | 329 |
327 | 330 |
| 331 // Many functions have no effects except the return value and their return value |
| 332 // depends only on the parameters and/or global variables. Such a function can |
| 333 // be subject to common subexpression elimination and loop optimization just as |
| 334 // an arithmetic operator would be. These functions should be declared with the |
| 335 // attribute V8_PURE. For example, |
| 336 // |
| 337 // int square (int) V8_PURE; |
| 338 // |
| 339 // says that the hypothetical function square is safe to call fewer times than |
| 340 // the program says. |
| 341 // |
| 342 // Some of common examples of pure functions are strlen or memcmp. Interesting |
| 343 // non-V8_PURE functions are functions with infinite loops or those depending |
| 344 // on volatile memory or other system resource, that may change between two |
| 345 // consecutive calls (such as feof in a multithreaded environment). |
| 346 #if V8_HAS_ATTRIBUTE_PURE |
| 347 # define V8_PURE __attribute__((pure)) |
| 348 #else |
| 349 # define V8_PURE /* NOT SUPPORTED */ |
| 350 #endif |
| 351 |
| 352 |
328 // Annotate a function indicating the caller must examine the return value. | 353 // Annotate a function indicating the caller must examine the return value. |
329 // Use like: | 354 // Use like: |
330 // int foo() V8_WARN_UNUSED_RESULT; | 355 // int foo() V8_WARN_UNUSED_RESULT; |
331 #if V8_HAS_ATTRIBUTE_WARN_UNUSED_RESULT | 356 #if V8_HAS_ATTRIBUTE_WARN_UNUSED_RESULT |
332 # define V8_WARN_UNUSED_RESULT __attribute__((warn_unused_result)) | 357 # define V8_WARN_UNUSED_RESULT __attribute__((warn_unused_result)) |
333 #else | 358 #else |
334 # define V8_WARN_UNUSED_RESULT /* NOT SUPPORTED */ | 359 # define V8_WARN_UNUSED_RESULT /* NOT SUPPORTED */ |
335 #endif | 360 #endif |
336 | 361 |
337 | 362 |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
438 # define V8_ALIGNOF(type) __alignof__(type) | 463 # define V8_ALIGNOF(type) __alignof__(type) |
439 #else | 464 #else |
440 // Note that alignment of a type within a struct can be less than the | 465 // Note that alignment of a type within a struct can be less than the |
441 // alignment of the type stand-alone (because of ancient ABIs), so this | 466 // alignment of the type stand-alone (because of ancient ABIs), so this |
442 // should only be used as a last resort. | 467 // should only be used as a last resort. |
443 namespace v8 { template <typename T> class AlignOfHelper { char c; T t; }; } | 468 namespace v8 { template <typename T> class AlignOfHelper { char c; T t; }; } |
444 # define V8_ALIGNOF(type) (sizeof(::v8::AlignOfHelper<type>) - sizeof(type)) | 469 # define V8_ALIGNOF(type) (sizeof(::v8::AlignOfHelper<type>) - sizeof(type)) |
445 #endif | 470 #endif |
446 | 471 |
447 #endif // V8CONFIG_H_ | 472 #endif // V8CONFIG_H_ |
OLD | NEW |