| 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 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 337 | 337 |
| 338 | 338 |
| 339 // FUNCTION_CAST<F>(addr) casts an address into a function | 339 // FUNCTION_CAST<F>(addr) casts an address into a function |
| 340 // of type F. Used to invoke generated code from within C. | 340 // of type F. Used to invoke generated code from within C. |
| 341 template <typename F> | 341 template <typename F> |
| 342 F FUNCTION_CAST(Address addr) { | 342 F FUNCTION_CAST(Address addr) { |
| 343 return reinterpret_cast<F>(reinterpret_cast<intptr_t>(addr)); | 343 return reinterpret_cast<F>(reinterpret_cast<intptr_t>(addr)); |
| 344 } | 344 } |
| 345 | 345 |
| 346 | 346 |
| 347 // Compiler feature detection. |
| 348 #if defined(__clang__) |
| 349 |
| 350 # if __has_feature(cxx_override_control) |
| 351 # define V8_HAVE_CXX11_FINAL |
| 352 # define V8_HAVE_CXX11_OVERRIDE |
| 353 # endif |
| 354 |
| 355 #elif defined(__GNUC__) |
| 356 |
| 357 // g++ requires -std=c++0x or -std=gnu++0x to support C++11 functionality |
| 358 // without warnings (functionality used by the macros below). These modes |
| 359 // are detectable by checking whether __GXX_EXPERIMENTAL_CXX0X__ is defined or, |
| 360 // more standardly, by checking whether __cplusplus has a C++11 or greater |
| 361 // value. Current versions of g++ do not correctly set __cplusplus, so we check |
| 362 // both for forward compatibility. |
| 363 # if defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L |
| 364 # if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7) |
| 365 # define V8_HAVE_CXX11_OVERRIDE |
| 366 # define V8_HAVE_CXX11_FINAL |
| 367 # endif |
| 368 # else |
| 369 // '__final' is a non-C++11 GCC synonym for 'final', per GCC r176655. |
| 370 # if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7) |
| 371 # define V8_HAVE_GXX_FINAL |
| 372 # endif |
| 373 # endif |
| 374 |
| 375 #elif defined(_MSC_VER) |
| 376 |
| 377 // Override control was added with Visual Studio 2005. |
| 378 # if _MSC_VER >= 1400 |
| 379 # if _MSC_VER >= 1700 |
| 380 # define V8_HAVE_CXX11_FINAL |
| 381 # else |
| 382 // Visual Studio 2010 and earlier spell "final" as "sealed". |
| 383 # define V8_HAVE_MSVC_SEALED |
| 384 # endif |
| 385 # define V8_HAVE_CXX11_OVERRIDE |
| 386 # endif |
| 387 |
| 388 #endif |
| 389 |
| 390 |
| 347 #if __cplusplus >= 201103L | 391 #if __cplusplus >= 201103L |
| 348 #define DISALLOW_BY_DELETE = delete | 392 #define DISALLOW_BY_DELETE = delete |
| 349 #else | 393 #else |
| 350 #define DISALLOW_BY_DELETE | 394 #define DISALLOW_BY_DELETE |
| 351 #endif | 395 #endif |
| 352 | 396 |
| 353 | 397 |
| 354 // A macro to disallow the evil copy constructor and operator= functions | 398 // A macro to disallow the evil copy constructor and operator= functions |
| 355 // This should be used in the private: declarations for a class | 399 // This should be used in the private: declarations for a class |
| 356 #define DISALLOW_COPY_AND_ASSIGN(TypeName) \ | 400 #define DISALLOW_COPY_AND_ASSIGN(TypeName) \ |
| (...skipping 25 matching lines...) Expand all Loading... |
| 382 #endif | 426 #endif |
| 383 #elif defined(_MSC_VER) && !defined(DEBUG) | 427 #elif defined(_MSC_VER) && !defined(DEBUG) |
| 384 #define INLINE(header) __forceinline header | 428 #define INLINE(header) __forceinline header |
| 385 #define NO_INLINE(header) header | 429 #define NO_INLINE(header) header |
| 386 #else | 430 #else |
| 387 #define INLINE(header) inline header | 431 #define INLINE(header) inline header |
| 388 #define NO_INLINE(header) header | 432 #define NO_INLINE(header) header |
| 389 #endif | 433 #endif |
| 390 | 434 |
| 391 | 435 |
| 436 // Annotate a virtual method indicating it must be overriding a virtual |
| 437 // method in the parent class. |
| 438 // Use like: |
| 439 // virtual void bar() V8_OVERRIDE; |
| 440 #if defined(V8_HAVE_CXX11_OVERRIDE) |
| 441 #define V8_OVERRIDE override |
| 442 #else |
| 443 #define V8_OVERRIDE |
| 444 #endif |
| 445 |
| 446 |
| 447 // Annotate a virtual method indicating that subclasses must not override it, |
| 448 // or annotate a class to indicate that it cannot be subclassed. |
| 449 // Use like: |
| 450 // class B V8_FINAL : public A {}; |
| 451 // virtual void bar() V8_FINAL; |
| 452 #if defined(V8_HAVE_CXX11_FINAL) |
| 453 #define V8_FINAL final |
| 454 #elif defined(V8_HAVE_GXX_FINAL) |
| 455 #define V8_FINAL __final |
| 456 #elif defined(V8_HAVE_MSVC_SEALED) |
| 457 #define V8_FINAL sealed |
| 458 #else |
| 459 #define V8_FINAL |
| 460 #endif |
| 461 |
| 462 |
| 392 #if defined(__GNUC__) && __GNUC__ >= 4 | 463 #if defined(__GNUC__) && __GNUC__ >= 4 |
| 393 #define MUST_USE_RESULT __attribute__ ((warn_unused_result)) | 464 #define MUST_USE_RESULT __attribute__ ((warn_unused_result)) |
| 394 #else | 465 #else |
| 395 #define MUST_USE_RESULT | 466 #define MUST_USE_RESULT |
| 396 #endif | 467 #endif |
| 397 | 468 |
| 398 | 469 |
| 399 // Define DISABLE_ASAN macros. | 470 // Define DISABLE_ASAN macros. |
| 400 #if defined(__has_feature) | 471 #if defined(__has_feature) |
| 401 #if __has_feature(address_sanitizer) | 472 #if __has_feature(address_sanitizer) |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 457 // the backend, so both modes are represented by the kStrictMode value. | 528 // the backend, so both modes are represented by the kStrictMode value. |
| 458 enum StrictModeFlag { | 529 enum StrictModeFlag { |
| 459 kNonStrictMode, | 530 kNonStrictMode, |
| 460 kStrictMode | 531 kStrictMode |
| 461 }; | 532 }; |
| 462 | 533 |
| 463 | 534 |
| 464 } } // namespace v8::internal | 535 } } // namespace v8::internal |
| 465 | 536 |
| 466 #endif // V8_GLOBALS_H_ | 537 #endif // V8_GLOBALS_H_ |
| OLD | NEW |