diff options
author | Philip Chimento <philip@endlessm.com> | 2017-04-25 11:46:38 -0700 |
---|---|---|
committer | Philip Chimento <philip.chimento@gmail.com> | 2017-04-30 21:41:01 -0700 |
commit | bdbf7179bca6fba1ac9ce69256b5121f81305507 (patch) | |
tree | 43c8b4e18cc19505b7a855bc180a1de7e8450739 | |
parent | 854a2bcd879f02ec2ff544f48b70fc43a5132914 (diff) | |
download | gjs-bdbf7179bca6fba1ac9ce69256b5121f81305507.tar.gz |
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
-rw-r--r-- | configure.ac | 2 | ||||
-rw-r--r-- | gjs/jsapi-util-args.h | 18 |
2 files changed, 17 insertions, 3 deletions
diff --git a/configure.ac b/configure.ac index 42526d78..43e1e3de 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 7cd39261..c572fab0 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) { |