Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(225)

Side by Side Diff: src/globals.h

Issue 23248006: Move OS/compiler/feature detection to public v8config.h header. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Also add V8_ALIGNAS() there, required for the CPU profiler queue. Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« include/v8config.h ('K') | « src/checks.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 #include "../include/v8stdint.h"
31 32
32 // Compiler feature/bug detection. 33 // Find a working V8_INFINITY.
33 #if defined(__clang__) 34 #if V8_CC_GNU
34
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
83
84 // Unfortunately, the INFINITY macro cannot be used with the '-pedantic' 35 // Unfortunately, the INFINITY macro cannot be used with the '-pedantic'
85 // warning flag and certain versions of GCC due to a bug: 36 // warning flag and certain versions of GCC due to a bug:
86 // http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11931 37 // http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11931
87 // For now, we use the more involved template-based version from <limits>, but 38 // For now, we use the more involved template-based version from <limits>, but
88 // only when compiling with GCC versions affected by the bug (2.96.x - 4.0.x) 39 // only when compiling with GCC versions affected by the bug (2.96.x - 4.0.x)
89 # if V8_GNUC_PREREQ(2, 96, 0) && !V8_GNUC_PREREQ(4, 1, 0) 40 # if V8_GNUC_PREREQ(2, 96, 0) && !V8_GNUC_PREREQ(4, 1, 0)
90 # include <limits> 41 # include <limits> // NOLINT
91 # define V8_INFINITY std::numeric_limits<double>::infinity() 42 # define V8_INFINITY std::numeric_limits<double>::infinity()
92 # else 43 # else
93 # define V8_INFINITY INFINITY 44 # define V8_INFINITY INFINITY
94 # endif 45 # endif
95 46 #elif V8_CC_MSVC
96 #elif defined(_MSC_VER)
97
98 # define V8_GNUC_PREREQ(major, minor, patchlevel) 0
99
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 47 # define V8_INFINITY HUGE_VAL
112 48 #else
49 # define V8_INFINITY INFINITY
113 #endif 50 #endif
114 51
115
116 #include "../include/v8stdint.h"
117
118 namespace v8 { 52 namespace v8 {
119 namespace internal { 53 namespace internal {
120 54
121 // Processor architecture detection. For more info on what's defined, see: 55 // Processor architecture detection. For more info on what's defined, see:
122 // http://msdn.microsoft.com/en-us/library/b0084kay.aspx 56 // http://msdn.microsoft.com/en-us/library/b0084kay.aspx
123 // http://www.agner.org/optimize/calling_conventions.pdf 57 // http://www.agner.org/optimize/calling_conventions.pdf
124 // or with gcc, run: "echo | gcc -E -dM -" 58 // or with gcc, run: "echo | gcc -E -dM -"
125 #if defined(_M_X64) || defined(__x86_64__) 59 #if defined(_M_X64) || defined(__x86_64__)
126 #if defined(__native_client__) 60 #if defined(__native_client__)
127 // For Native Client builds of V8, use V8_TARGET_ARCH_ARM, so that V8 61 // For Native Client builds of V8, use V8_TARGET_ARCH_ARM, so that V8
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 313
380 314
381 // FUNCTION_CAST<F>(addr) casts an address into a function 315 // FUNCTION_CAST<F>(addr) casts an address into a function
382 // of type F. Used to invoke generated code from within C. 316 // of type F. Used to invoke generated code from within C.
383 template <typename F> 317 template <typename F>
384 F FUNCTION_CAST(Address addr) { 318 F FUNCTION_CAST(Address addr) {
385 return reinterpret_cast<F>(reinterpret_cast<intptr_t>(addr)); 319 return reinterpret_cast<F>(reinterpret_cast<intptr_t>(addr));
386 } 320 }
387 321
388 322
389 // A macro to specify that a method is deleted from the corresponding class.
390 // Any attempt to use the method will always produce an error at compile time
391 // when this macro can be implemented (i.e. if the compiler supports C++11).
392 // If the current compiler does not support C++11, use of the annotated method
393 // will still cause an error, but the error will most likely occur at link time
394 // rather than at compile time. As a backstop, method declarations using this
395 // macro should be private.
396 // Use like:
397 // class A {
398 // private:
399 // A(const A& other) V8_DELETE;
400 // A& operator=(const A& other) V8_DELETE;
401 // };
402 #if defined(V8_HAVE_CXX11_DELETE)
403 # define V8_DELETE = delete
404 #else
405 # define V8_DELETE /* NOT SUPPORTED */
406 #endif
407
408
409 // Annotate a virtual method indicating it must be overriding a virtual
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
415 #else
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 */
433 #endif
434
435
436 // A macro to disallow the evil copy constructor and operator= functions 323 // A macro to disallow the evil copy constructor and operator= functions
437 // This should be used in the private: declarations for a class 324 // This should be used in the private: declarations for a class
438 #define DISALLOW_COPY_AND_ASSIGN(TypeName) \ 325 #define DISALLOW_COPY_AND_ASSIGN(TypeName) \
439 TypeName(const TypeName&) V8_DELETE; \ 326 TypeName(const TypeName&) V8_DELETE; \
440 void operator=(const TypeName&) V8_DELETE 327 void operator=(const TypeName&) V8_DELETE
441 328
442 329
443 // A macro to disallow all the implicit constructors, namely the 330 // A macro to disallow all the implicit constructors, namely the
444 // default constructor, copy constructor and operator= functions. 331 // default constructor, copy constructor and operator= functions.
445 // 332 //
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
539 // the backend, so both modes are represented by the kStrictMode value. 426 // the backend, so both modes are represented by the kStrictMode value.
540 enum StrictModeFlag { 427 enum StrictModeFlag {
541 kNonStrictMode, 428 kNonStrictMode,
542 kStrictMode 429 kStrictMode
543 }; 430 };
544 431
545 432
546 } } // namespace v8::internal 433 } } // namespace v8::internal
547 434
548 #endif // V8_GLOBALS_H_ 435 #endif // V8_GLOBALS_H_
OLDNEW
« include/v8config.h ('K') | « src/checks.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698