| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 10 matching lines...) Expand all Loading... |
| 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | 27 |
| 28 #ifndef V8_GLOBALS_H_ | 28 #ifndef V8_GLOBALS_H_ |
| 29 #define V8_GLOBALS_H_ | 29 #define V8_GLOBALS_H_ |
| 30 | 30 |
| 31 // Define V8_INFINITY | |
| 32 #define V8_INFINITY INFINITY | |
| 33 | 31 |
| 34 // GCC specific stuff | 32 // Compiler feature/bug detection. |
| 35 #ifdef __GNUC__ | 33 #if defined(__clang__) |
| 36 | 34 |
| 37 #define __GNUC_VERSION_FOR_INFTY__ (__GNUC__ * 10000 + __GNUC_MINOR__ * 100) | 35 // Don't treat clang as GCC. |
| 36 # define V8_GNUC_PREREQ(major, minor, patchlevel) 0 |
| 37 |
| 38 # if __has_feature(cxx_deleted_functions) |
| 39 # define V8_HAVE_CXX11_DELETE |
| 40 # endif |
| 41 |
| 42 # if __has_feature(cxx_override_control) |
| 43 # define V8_HAVE_CXX11_FINAL |
| 44 # define V8_HAVE_CXX11_OVERRIDE |
| 45 # endif |
| 46 |
| 47 # if __has_feature(cxx_static_assert) |
| 48 # define V8_HAVE_CXX11_STATIC_ASSERT |
| 49 # endif |
| 50 |
| 51 # define V8_INFINITY INFINITY |
| 52 |
| 53 #elif defined(__GNUC__) |
| 54 |
| 55 // GCC version detection. |
| 56 # define V8_GNUC_PREREQ(major, minor, patchlevel) \ |
| 57 ((__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) >= \ |
| 58 ((major) * 10000 + (minor) * 100 + (patchlevel))) |
| 59 |
| 60 // g++ requires -std=c++0x or -std=gnu++0x to support C++11 functionality |
| 61 // without warnings (functionality used by the macros below). These modes |
| 62 // are detectable by checking whether __GXX_EXPERIMENTAL_CXX0X__ is defined or, |
| 63 // more standardly, by checking whether __cplusplus has a C++11 or greater |
| 64 // value. Current versions of g++ do not correctly set __cplusplus, so we check |
| 65 // both for forward compatibility. |
| 66 # if defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L |
| 67 # if V8_GNUC_PREREQ(4, 3, 0) |
| 68 # define V8_HAVE_CXX11_STATIC_ASSERT |
| 69 # endif |
| 70 # if V8_GNUC_PREREQ(4, 4, 0) |
| 71 # define V8_HAVE_CXX11_DELETE |
| 72 # endif |
| 73 # if V8_GNUC_PREREQ(4, 7, 0) |
| 74 # define V8_HAVE_CXX11_OVERRIDE |
| 75 # define V8_HAVE_CXX11_FINAL |
| 76 # endif |
| 77 # else |
| 78 // '__final' is a non-C++11 GCC synonym for 'final', per GCC r176655. |
| 79 # if V8_GNUC_PREREQ(4, 7, 0) |
| 80 # define V8_HAVE_GXX_FINAL |
| 81 # endif |
| 82 # endif |
| 38 | 83 |
| 39 // Unfortunately, the INFINITY macro cannot be used with the '-pedantic' | 84 // Unfortunately, the INFINITY macro cannot be used with the '-pedantic' |
| 40 // warning flag and certain versions of GCC due to a bug: | 85 // warning flag and certain versions of GCC due to a bug: |
| 41 // http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11931 | 86 // http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11931 |
| 42 // For now, we use the more involved template-based version from <limits>, but | 87 // For now, we use the more involved template-based version from <limits>, but |
| 43 // only when compiling with GCC versions affected by the bug (2.96.x - 4.0.x) | 88 // only when compiling with GCC versions affected by the bug (2.96.x - 4.0.x) |
| 44 // __GNUC_PREREQ is not defined in GCC for Mac OS X, so we define our own macro | 89 # if V8_GNUC_PREREQ(2, 96, 0) && !V8_GNUC_PREREQ(4, 1, 0) |
| 45 #if __GNUC_VERSION_FOR_INFTY__ >= 29600 && __GNUC_VERSION_FOR_INFTY__ < 40100 | 90 # include <limits> |
| 46 #include <limits> | 91 # define V8_INFINITY std::numeric_limits<double>::infinity() |
| 47 #undef V8_INFINITY | 92 # else |
| 48 #define V8_INFINITY std::numeric_limits<double>::infinity() | 93 # define V8_INFINITY INFINITY |
| 49 #endif | 94 # endif |
| 50 #undef __GNUC_VERSION_FOR_INFTY__ | |
| 51 | 95 |
| 52 #endif // __GNUC__ | 96 #elif defined(_MSC_VER) |
| 53 | 97 |
| 54 #ifdef _MSC_VER | 98 # define V8_GNUC_PREREQ(major, minor, patchlevel) 0 |
| 55 #undef V8_INFINITY | 99 |
| 56 #define V8_INFINITY HUGE_VAL | 100 // Override control was added with Visual Studio 2005. |
| 101 # if _MSC_VER >= 1400 |
| 102 # if _MSC_VER >= 1700 |
| 103 # define V8_HAVE_CXX11_FINAL |
| 104 # else |
| 105 // Visual Studio 2010 and earlier spell "final" as "sealed". |
| 106 # define V8_HAVE_MSVC_SEALED |
| 107 # endif |
| 108 # define V8_HAVE_CXX11_OVERRIDE |
| 109 # endif |
| 110 |
| 111 # define V8_INFINITY HUGE_VAL |
| 112 |
| 57 #endif | 113 #endif |
| 58 | 114 |
| 59 | 115 |
| 60 #include "../include/v8stdint.h" | 116 #include "../include/v8stdint.h" |
| 61 | 117 |
| 62 namespace v8 { | 118 namespace v8 { |
| 63 namespace internal { | 119 namespace internal { |
| 64 | 120 |
| 65 // Processor architecture detection. For more info on what's defined, see: | 121 // Processor architecture detection. For more info on what's defined, see: |
| 66 // http://msdn.microsoft.com/en-us/library/b0084kay.aspx | 122 // http://msdn.microsoft.com/en-us/library/b0084kay.aspx |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 323 | 379 |
| 324 | 380 |
| 325 // FUNCTION_CAST<F>(addr) casts an address into a function | 381 // FUNCTION_CAST<F>(addr) casts an address into a function |
| 326 // of type F. Used to invoke generated code from within C. | 382 // of type F. Used to invoke generated code from within C. |
| 327 template <typename F> | 383 template <typename F> |
| 328 F FUNCTION_CAST(Address addr) { | 384 F FUNCTION_CAST(Address addr) { |
| 329 return reinterpret_cast<F>(reinterpret_cast<intptr_t>(addr)); | 385 return reinterpret_cast<F>(reinterpret_cast<intptr_t>(addr)); |
| 330 } | 386 } |
| 331 | 387 |
| 332 | 388 |
| 333 // Compiler feature detection. | 389 // A macro to specify that a method is deleted from the corresponding class. |
| 334 #if defined(__clang__) | 390 // Any attempt to use the method will always produce an error at compile time |
| 335 | 391 // when this macro can be implemented (i.e. if the compiler supports C++11). |
| 336 # if __has_feature(cxx_override_control) | 392 // If the current compiler does not support C++11, use of the annotated method |
| 337 # define V8_HAVE_CXX11_FINAL | 393 // will still cause an error, but the error will most likely occur at link time |
| 338 # define V8_HAVE_CXX11_OVERRIDE | 394 // rather than at compile time. As a backstop, method declarations using this |
| 339 # endif | 395 // macro should be private. |
| 340 | 396 // Use like: |
| 341 #elif defined(__GNUC__) | 397 // class A { |
| 342 | 398 // private: |
| 343 // g++ requires -std=c++0x or -std=gnu++0x to support C++11 functionality | 399 // A(const A& other) V8_DELETE; |
| 344 // without warnings (functionality used by the macros below). These modes | 400 // A& operator=(const A& other) V8_DELETE; |
| 345 // are detectable by checking whether __GXX_EXPERIMENTAL_CXX0X__ is defined or, | 401 // }; |
| 346 // more standardly, by checking whether __cplusplus has a C++11 or greater | 402 #if defined(V8_HAVE_CXX11_DELETE) |
| 347 // value. Current versions of g++ do not correctly set __cplusplus, so we check | 403 # define V8_DELETE = delete |
| 348 // both for forward compatibility. | 404 #else |
| 349 # if defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L | 405 # define V8_DELETE /* NOT SUPPORTED */ |
| 350 # if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7) | |
| 351 # define V8_HAVE_CXX11_OVERRIDE | |
| 352 # define V8_HAVE_CXX11_FINAL | |
| 353 # endif | |
| 354 # else | |
| 355 // '__final' is a non-C++11 GCC synonym for 'final', per GCC r176655. | |
| 356 # if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7) | |
| 357 # define V8_HAVE_GXX_FINAL | |
| 358 # endif | |
| 359 # endif | |
| 360 | |
| 361 #elif defined(_MSC_VER) | |
| 362 | |
| 363 // Override control was added with Visual Studio 2005. | |
| 364 # if _MSC_VER >= 1400 | |
| 365 # if _MSC_VER >= 1700 | |
| 366 # define V8_HAVE_CXX11_FINAL | |
| 367 # else | |
| 368 // Visual Studio 2010 and earlier spell "final" as "sealed". | |
| 369 # define V8_HAVE_MSVC_SEALED | |
| 370 # endif | |
| 371 # define V8_HAVE_CXX11_OVERRIDE | |
| 372 # endif | |
| 373 | |
| 374 #endif | 406 #endif |
| 375 | 407 |
| 376 | 408 |
| 377 #if __cplusplus >= 201103L | 409 // Annotate a virtual method indicating it must be overriding a virtual |
| 378 #define DISALLOW_BY_DELETE = delete | 410 // method in the parent class. |
| 411 // Use like: |
| 412 // virtual void bar() V8_OVERRIDE; |
| 413 #if defined(V8_HAVE_CXX11_OVERRIDE) |
| 414 # define V8_OVERRIDE override |
| 379 #else | 415 #else |
| 380 #define DISALLOW_BY_DELETE | 416 # define V8_OVERRIDE /* NOT SUPPORTED */ |
| 417 #endif |
| 418 |
| 419 |
| 420 // Annotate a virtual method indicating that subclasses must not override it, |
| 421 // or annotate a class to indicate that it cannot be subclassed. |
| 422 // Use like: |
| 423 // class B V8_FINAL : public A {}; |
| 424 // virtual void bar() V8_FINAL; |
| 425 #if defined(V8_HAVE_CXX11_FINAL) |
| 426 # define V8_FINAL final |
| 427 #elif defined(V8_HAVE_GXX_FINAL) |
| 428 # define V8_FINAL __final |
| 429 #elif defined(V8_HAVE_MSVC_SEALED) |
| 430 # define V8_FINAL sealed |
| 431 #else |
| 432 # define V8_FINAL /* NOT SUPPORTED */ |
| 381 #endif | 433 #endif |
| 382 | 434 |
| 383 | 435 |
| 384 // A macro to disallow the evil copy constructor and operator= functions | 436 // A macro to disallow the evil copy constructor and operator= functions |
| 385 // This should be used in the private: declarations for a class | 437 // This should be used in the private: declarations for a class |
| 386 #define DISALLOW_COPY_AND_ASSIGN(TypeName) \ | 438 #define DISALLOW_COPY_AND_ASSIGN(TypeName) \ |
| 387 TypeName(const TypeName&) DISALLOW_BY_DELETE; \ | 439 TypeName(const TypeName&) V8_DELETE; \ |
| 388 void operator=(const TypeName&) DISALLOW_BY_DELETE | 440 void operator=(const TypeName&) V8_DELETE |
| 389 | 441 |
| 390 | 442 |
| 391 // A macro to disallow all the implicit constructors, namely the | 443 // A macro to disallow all the implicit constructors, namely the |
| 392 // default constructor, copy constructor and operator= functions. | 444 // default constructor, copy constructor and operator= functions. |
| 393 // | 445 // |
| 394 // This should be used in the private: declarations for a class | 446 // This should be used in the private: declarations for a class |
| 395 // that wants to prevent anyone from instantiating it. This is | 447 // that wants to prevent anyone from instantiating it. This is |
| 396 // especially useful for classes containing only static methods. | 448 // especially useful for classes containing only static methods. |
| 397 #define DISALLOW_IMPLICIT_CONSTRUCTORS(TypeName) \ | 449 #define DISALLOW_IMPLICIT_CONSTRUCTORS(TypeName) \ |
| 398 TypeName() DISALLOW_BY_DELETE; \ | 450 TypeName() V8_DELETE; \ |
| 399 DISALLOW_COPY_AND_ASSIGN(TypeName) | 451 DISALLOW_COPY_AND_ASSIGN(TypeName) |
| 400 | 452 |
| 401 | 453 |
| 402 // Define used for helping GCC to make better inlining. Don't bother for debug | 454 // Define used for helping GCC to make better inlining. Don't bother for debug |
| 403 // builds. On GCC 3.4.5 using __attribute__((always_inline)) causes compilation | 455 // builds. On GCC 3.4.5 using __attribute__((always_inline)) causes compilation |
| 404 // errors in debug build. | 456 // errors in debug build. |
| 405 #if defined(__GNUC__) && !defined(DEBUG) | 457 #if defined(__GNUC__) && !defined(DEBUG) |
| 406 #if (__GNUC__ >= 4) | 458 #if (__GNUC__ >= 4) |
| 407 #define INLINE(header) inline header __attribute__((always_inline)) | 459 #define INLINE(header) inline header __attribute__((always_inline)) |
| 408 #define NO_INLINE(header) header __attribute__((noinline)) | 460 #define NO_INLINE(header) header __attribute__((noinline)) |
| 409 #else | 461 #else |
| 410 #define INLINE(header) inline __attribute__((always_inline)) header | 462 #define INLINE(header) inline __attribute__((always_inline)) header |
| 411 #define NO_INLINE(header) __attribute__((noinline)) header | 463 #define NO_INLINE(header) __attribute__((noinline)) header |
| 412 #endif | 464 #endif |
| 413 #elif defined(_MSC_VER) && !defined(DEBUG) | 465 #elif defined(_MSC_VER) && !defined(DEBUG) |
| 414 #define INLINE(header) __forceinline header | 466 #define INLINE(header) __forceinline header |
| 415 #define NO_INLINE(header) header | 467 #define NO_INLINE(header) header |
| 416 #else | 468 #else |
| 417 #define INLINE(header) inline header | 469 #define INLINE(header) inline header |
| 418 #define NO_INLINE(header) header | 470 #define NO_INLINE(header) header |
| 419 #endif | 471 #endif |
| 420 | 472 |
| 421 | 473 |
| 422 // Annotate a virtual method indicating it must be overriding a virtual | |
| 423 // method in the parent class. | |
| 424 // Use like: | |
| 425 // virtual void bar() V8_OVERRIDE; | |
| 426 #if defined(V8_HAVE_CXX11_OVERRIDE) | |
| 427 #define V8_OVERRIDE override | |
| 428 #else | |
| 429 #define V8_OVERRIDE | |
| 430 #endif | |
| 431 | |
| 432 | |
| 433 // Annotate a virtual method indicating that subclasses must not override it, | |
| 434 // or annotate a class to indicate that it cannot be subclassed. | |
| 435 // Use like: | |
| 436 // class B V8_FINAL : public A {}; | |
| 437 // virtual void bar() V8_FINAL; | |
| 438 #if defined(V8_HAVE_CXX11_FINAL) | |
| 439 #define V8_FINAL final | |
| 440 #elif defined(V8_HAVE_GXX_FINAL) | |
| 441 #define V8_FINAL __final | |
| 442 #elif defined(V8_HAVE_MSVC_SEALED) | |
| 443 #define V8_FINAL sealed | |
| 444 #else | |
| 445 #define V8_FINAL | |
| 446 #endif | |
| 447 | |
| 448 | |
| 449 #if defined(__GNUC__) && __GNUC__ >= 4 | 474 #if defined(__GNUC__) && __GNUC__ >= 4 |
| 450 #define MUST_USE_RESULT __attribute__ ((warn_unused_result)) | 475 #define MUST_USE_RESULT __attribute__ ((warn_unused_result)) |
| 451 #else | 476 #else |
| 452 #define MUST_USE_RESULT | 477 #define MUST_USE_RESULT |
| 453 #endif | 478 #endif |
| 454 | 479 |
| 455 | 480 |
| 456 // Define DISABLE_ASAN macros. | 481 // Define DISABLE_ASAN macros. |
| 457 #if defined(__has_feature) | 482 #if defined(__has_feature) |
| 458 #if __has_feature(address_sanitizer) | 483 #if __has_feature(address_sanitizer) |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 514 // the backend, so both modes are represented by the kStrictMode value. | 539 // the backend, so both modes are represented by the kStrictMode value. |
| 515 enum StrictModeFlag { | 540 enum StrictModeFlag { |
| 516 kNonStrictMode, | 541 kNonStrictMode, |
| 517 kStrictMode | 542 kStrictMode |
| 518 }; | 543 }; |
| 519 | 544 |
| 520 | 545 |
| 521 } } // namespace v8::internal | 546 } } // namespace v8::internal |
| 522 | 547 |
| 523 #endif // V8_GLOBALS_H_ | 548 #endif // V8_GLOBALS_H_ |
| OLD | NEW |