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 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
323 | 323 |
324 | 324 |
325 // FUNCTION_CAST<F>(addr) casts an address into a function | 325 // FUNCTION_CAST<F>(addr) casts an address into a function |
326 // of type F. Used to invoke generated code from within C. | 326 // of type F. Used to invoke generated code from within C. |
327 template <typename F> | 327 template <typename F> |
328 F FUNCTION_CAST(Address addr) { | 328 F FUNCTION_CAST(Address addr) { |
329 return reinterpret_cast<F>(reinterpret_cast<intptr_t>(addr)); | 329 return reinterpret_cast<F>(reinterpret_cast<intptr_t>(addr)); |
330 } | 330 } |
331 | 331 |
332 | 332 |
| 333 // Compiler feature detection. |
| 334 #if defined(__clang__) |
| 335 |
| 336 // Compatibility with older clang versions. |
| 337 # ifndef __has_extension |
| 338 # define __has_extension __has_feature |
| 339 # endif |
| 340 |
| 341 # if __has_extension(cxx_override_control) |
| 342 # define V8_HAVE_CXX11_FINAL |
| 343 # define V8_HAVE_CXX11_OVERRIDE |
| 344 # endif |
| 345 |
| 346 #elif defined(__GNUC__) |
| 347 |
| 348 // g++ requires -std=c++0x or -std=gnu++0x to support C++11 functionality |
| 349 // without warnings (functionality used by the macros below). These modes |
| 350 // are detectable by checking whether __GXX_EXPERIMENTAL_CXX0X__ is defined or, |
| 351 // more standardly, by checking whether __cplusplus has a C++11 or greater |
| 352 // value. Current versions of g++ do not correctly set __cplusplus, so we check |
| 353 // both for forward compatibility. |
| 354 # if defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L |
| 355 # if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7) |
| 356 # define V8_HAVE_CXX11_OVERRIDE |
| 357 # define V8_HAVE_CXX11_FINAL |
| 358 # endif |
| 359 # else |
| 360 // '__final' is a non-C++11 GCC synonym for 'final', per GCC r176655. |
| 361 # if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7) |
| 362 # define V8_HAVE_GXX_FINAL |
| 363 # endif |
| 364 # endif |
| 365 |
| 366 #elif defined(_MSC_VER) |
| 367 |
| 368 # if _MSC_VER >= 1400 |
| 369 # define V8_HAVE_CXX11_OVERRIDE |
| 370 // MSVC currently spells "final" as "sealed". |
| 371 # define V8_HAVE_MSVC_SEALED |
| 372 # endif |
| 373 |
| 374 #endif |
| 375 |
| 376 |
333 #if __cplusplus >= 201103L | 377 #if __cplusplus >= 201103L |
334 #define DISALLOW_BY_DELETE = delete | 378 #define DISALLOW_BY_DELETE = delete |
335 #else | 379 #else |
336 #define DISALLOW_BY_DELETE | 380 #define DISALLOW_BY_DELETE |
337 #endif | 381 #endif |
338 | 382 |
339 | 383 |
340 // A macro to disallow the evil copy constructor and operator= functions | 384 // A macro to disallow the evil copy constructor and operator= functions |
341 // This should be used in the private: declarations for a class | 385 // This should be used in the private: declarations for a class |
342 #define DISALLOW_COPY_AND_ASSIGN(TypeName) \ | 386 #define DISALLOW_COPY_AND_ASSIGN(TypeName) \ |
(...skipping 25 matching lines...) Expand all Loading... |
368 #endif | 412 #endif |
369 #elif defined(_MSC_VER) && !defined(DEBUG) | 413 #elif defined(_MSC_VER) && !defined(DEBUG) |
370 #define INLINE(header) __forceinline header | 414 #define INLINE(header) __forceinline header |
371 #define NO_INLINE(header) header | 415 #define NO_INLINE(header) header |
372 #else | 416 #else |
373 #define INLINE(header) inline header | 417 #define INLINE(header) inline header |
374 #define NO_INLINE(header) header | 418 #define NO_INLINE(header) header |
375 #endif | 419 #endif |
376 | 420 |
377 | 421 |
| 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 |
378 #if defined(__GNUC__) && __GNUC__ >= 4 | 449 #if defined(__GNUC__) && __GNUC__ >= 4 |
379 #define MUST_USE_RESULT __attribute__ ((warn_unused_result)) | 450 #define MUST_USE_RESULT __attribute__ ((warn_unused_result)) |
380 #else | 451 #else |
381 #define MUST_USE_RESULT | 452 #define MUST_USE_RESULT |
382 #endif | 453 #endif |
383 | 454 |
384 | 455 |
385 // Define DISABLE_ASAN macros. | 456 // Define DISABLE_ASAN macros. |
386 #if defined(__has_feature) | 457 #if defined(__has_feature) |
387 #if __has_feature(address_sanitizer) | 458 #if __has_feature(address_sanitizer) |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
443 // the backend, so both modes are represented by the kStrictMode value. | 514 // the backend, so both modes are represented by the kStrictMode value. |
444 enum StrictModeFlag { | 515 enum StrictModeFlag { |
445 kNonStrictMode, | 516 kNonStrictMode, |
446 kStrictMode | 517 kStrictMode |
447 }; | 518 }; |
448 | 519 |
449 | 520 |
450 } } // namespace v8::internal | 521 } } // namespace v8::internal |
451 | 522 |
452 #endif // V8_GLOBALS_H_ | 523 #endif // V8_GLOBALS_H_ |
OLD | NEW |