[gjs/gnome-3-24] jsapi-util-args: Mark functions as always-inline



commit c3b916b1a4d4e8a8b04b9883f0325e69b27cb7da
Author: Philip Chimento <philip endlessm com>
Date:   Tue Apr 25 11:46:38 2017 -0700

    jsapi-util-args: Mark functions as always-inline
    
    On GCC, we get warnings about the inline functions causing too much code
    growth. However, we do want these functions always inlined, since they're
    in a header file.
    
    Previously we dealt with the warnings by increasing --param
    inline-unit-growth, but that causes other warnings on Clang since Clang
    doesn't have that parameter. I also noticed that it requires different
    values on other versions of GCC, so it's not a very good solution.
    
    Instead, we use the always_inline attribute on GCC, which causes the
    functions to be inlined regardless of the compiler's inlining heuristics.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=780350

 configure.ac          |    2 --
 gjs/jsapi-util-args.h |   18 +++++++++++++++++-
 2 files changed, 17 insertions(+), 3 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index c52daed..ed7e35b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -217,8 +217,6 @@ AS_IF([test "x$with_dbus_tests" != "xno"], [
 ])
 AM_CONDITIONAL([DBUS_TESTS], [test "x$with_dbus_tests" != "xno"])
 
-AX_APPEND_COMPILE_FLAGS(['--param inline-unit-growth=50'])
-
 AC_SUBST([gjsjsdir], [\${datadir}/gjs-1.0])
 
 dnl automake 1.11/1.12 defines this but does not substitute it
diff --git a/gjs/jsapi-util-args.h b/gjs/jsapi-util-args.h
index c4f4b70..fb68c39 100644
--- a/gjs/jsapi-util-args.h
+++ b/gjs/jsapi-util-args.h
@@ -30,6 +30,13 @@
 #include "jsapi-util.h"
 #include "jsapi-wrapper.h"
 
+#ifdef __GNUC__
+#define GNUC_ALWAYS_INLINE __attribute__((always_inline))
+#else
+#define GNUC_ALWAYS_INLINE
+#endif
+
+GNUC_ALWAYS_INLINE
 static inline bool
 check_nullable(const char*& fchar,
                const char*& fmt_string)
@@ -46,6 +53,7 @@ check_nullable(const char*& fchar,
 
 /* This preserves the previous behaviour of gjs_parse_args(), but maybe we want
  * to use JS::ToBoolean instead? */
+GNUC_ALWAYS_INLINE
 static inline void
 assign(JSContext      *cx,
        char            c,
@@ -64,6 +72,7 @@ assign(JSContext      *cx,
 
 /* This preserves the previous behaviour of gjs_parse_args(), but maybe we want
  * to box primitive types instead of throwing? */
+GNUC_ALWAYS_INLINE
 static inline void
 assign(JSContext              *cx,
        char                    c,
@@ -82,6 +91,7 @@ assign(JSContext              *cx,
     ref.set(&value.toObject());
 }
 
+GNUC_ALWAYS_INLINE
 static inline void
 assign(JSContext      *cx,
        char            c,
@@ -103,7 +113,7 @@ assign(JSContext      *cx,
         throw g_strdup_printf("Wrong type for %c, got char**", c);
     }
 }
-
+GNUC_ALWAYS_INLINE
 static inline void
 assign(JSContext      *cx,
        char            c,
@@ -119,6 +129,7 @@ assign(JSContext      *cx,
         throw g_strdup("Couldn't convert to integer");
 }
 
+GNUC_ALWAYS_INLINE
 static inline void
 assign(JSContext      *cx,
        char            c,
@@ -139,6 +150,7 @@ assign(JSContext      *cx,
     *ref = num;
 }
 
+GNUC_ALWAYS_INLINE
 static inline void
 assign(JSContext      *cx,
        char            c,
@@ -154,6 +166,7 @@ assign(JSContext      *cx,
         throw g_strdup("Couldn't convert to 64-bit integer");
 }
 
+GNUC_ALWAYS_INLINE
 static inline void
 assign(JSContext      *cx,
        char            c,
@@ -173,6 +186,7 @@ assign(JSContext      *cx,
  * prevent instantiation for any other types besides pointer-to-enum */
 template<typename T,
          typename std::enable_if<std::is_enum<T>::value, int>::type = 0>
+GNUC_ALWAYS_INLINE
 static inline void
 assign(JSContext      *cx,
        char            c,
@@ -198,6 +212,7 @@ template<typename T,
 static inline void
 free_if_necessary(T param_ref) {}
 
+GNUC_ALWAYS_INLINE
 static inline void
 free_if_necessary(JS::MutableHandleObject param_ref)
 {
@@ -207,6 +222,7 @@ free_if_necessary(JS::MutableHandleObject param_ref)
     param_ref.set(NULL);
 }
 
+GNUC_ALWAYS_INLINE
 static inline void
 free_if_necessary(char **param_ref)
 {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]