Reviewers: Jakob, danno,

Message:
PTAL

Description:
Add V8_NOINLINE() and define INLINE()/NO_INLINE() in terms of their V8_*()
counterparts.

Please review this at https://codereview.chromium.org/23414003/

SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge

Affected files:
  M include/v8config.h
  M src/globals.h


Index: include/v8config.h
diff --git a/include/v8config.h b/include/v8config.h
index aa24eebff50bb193543295723c9195ece613b8ec..4326caaedf26c363dc9b64ad8ab2b4632cb7e86f 100644
--- a/include/v8config.h
+++ b/include/v8config.h
@@ -107,10 +107,12 @@
// V8_HAS_ATTRIBUTE___ALIGNED__ - __attribute__((__aligned__(n))) supported // V8_HAS_ATTRIBUTE_ALWAYS_INLINE - __attribute__((always_inline)) supported
 //  V8_HAS_ATTRIBUTE_DEPRECATED     - __attribute__((deprecated)) supported
+//  V8_HAS_ATTRIBUTE_NOINLINE       - __attribute__((noinline)) supported
 //  V8_HAS_ATTRIBUTE_VISIBILITY     - __attribute__((visibility)) supported
 //  V8_HAS_BUILTIN_EXPECT           - __builtin_expect() supported
 //  V8_HAS_DECLSPEC_ALIGN           - __declspec(align(n)) supported
 //  V8_HAS_DECLSPEC_DEPRECATED      - __declspec(deprecated) supported
+//  V8_HAS_DECLSPEC_NOINLINE        - __declspec(noinline) supported
 //  V8_HAS___FINAL                  - __final supported in non-C++11 mode
 //  V8_HAS___FORCEINLINE            - __forceinline supported
 //  V8_HAS_SEALED                   - MSVC style sealed marker supported
@@ -125,6 +127,7 @@
 # define V8_HAS_ATTRIBUTE___ALIGNED__ (__has_attribute(__aligned__))
 # define V8_HAS_ATTRIBUTE_ALWAYS_INLINE (__has_attribute(always_inline))
 # define V8_HAS_ATTRIBUTE_DEPRECATED (__has_attribute(deprecated))
+# define V8_HAS_ATTRIBUTE_NOINLINE (__has_attribute(noinline))
 # define V8_HAS_ATTRIBUTE_VISIBILITY (__has_attribute(visibility))

 # define V8_HAS_BUILTIN_EXPECT (__has_builtin(__builtin_expect))
@@ -152,6 +155,7 @@
 // older compilers.
 # define V8_HAS_ATTRIBUTE_ALWAYS_INLINE (V8_GNUC_PREREQ(4, 4, 0))
 # define V8_HAS_ATTRIBUTE_DEPRECATED (V8_GNUC_PREREQ(3, 4, 0))
+# define V8_HAS_ATTRIBUTE_NOINLINE (V8_GNUC_PREREQ(3, 4, 0))
 # define V8_HAS_ATTRIBUTE_VISIBILITY (V8_GNUC_PREREQ(4, 3, 0))

 # define V8_HAS_BUILTIN_EXPECT (V8_GNUC_PREREQ(2, 96, 0))
@@ -187,6 +191,7 @@

 # define V8_HAS_DECLSPEC_ALIGN 1
 # define V8_HAS_DECLSPEC_DEPRECATED (_MSC_VER >= 1300)
+# define V8_HAS_DECLSPEC_NOINLINE 1

 # define V8_HAS___FORCEINLINE 1

@@ -206,6 +211,17 @@
 #endif


+// A macro used to tell the compiler to never inline a particular function.
+// Don't bother for debug builds.
+#if !defined(DEBUG) && V8_HAS_ATTRIBUTE_NOINLINE
+# define V8_NOINLINE(declarator) __attribute__((noinline)) declarator
+#elif !defined(DEBUG) && V8_HAS_DECLSPEC_NOINLINE
+# define V8_NOINLINE(declarator) __declspec(noinline) declarator
+#else
+# define V8_NOINLINE(declarator) declarator
+#endif
+
+
 // A macro to mark classes or functions as deprecated.
 #if !V8_DISABLE_DEPRECATIONS && V8_HAS_ATTRIBUTE_DEPRECATED
 # define V8_DEPRECATED(declarator) declarator __attribute__((deprecated))
Index: src/globals.h
diff --git a/src/globals.h b/src/globals.h
index 478395aafd7e0c0fa2e60cc069ad4a87fca78a76..0198336177e045cda338fa29fc57655d89d5c272 100644
--- a/src/globals.h
+++ b/src/globals.h
@@ -342,24 +342,9 @@ F FUNCTION_CAST(Address addr) {
   DISALLOW_COPY_AND_ASSIGN(TypeName)


-// Define used for helping GCC to make better inlining. Don't bother for debug -// builds. On GCC 3.4.5 using __attribute__((always_inline)) causes compilation
-// errors in debug build.
-#if defined(__GNUC__) && !defined(DEBUG)
-#if (__GNUC__ >= 4)
-#define INLINE(header) inline header  __attribute__((always_inline))
-#define NO_INLINE(header) header __attribute__((noinline))
-#else
-#define INLINE(header) inline __attribute__((always_inline)) header
-#define NO_INLINE(header) __attribute__((noinline)) header
-#endif
-#elif defined(_MSC_VER) && !defined(DEBUG)
-#define INLINE(header) __forceinline header
-#define NO_INLINE(header) header
-#else
-#define INLINE(header) inline header
-#define NO_INLINE(header) header
-#endif
+// Newly written code should use V8_INLINE() and V8_NOINLINE() directly.
+#define INLINE(declarator)    V8_INLINE(declarator)
+#define NO_INLINE(declarator) V8_NOINLINE(declarator)


 #if defined(__GNUC__) && __GNUC__ >= 4


--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to