[utils] Use MONO_ALWAYS_INLINE + Add MONO_NEVER_INLINE
authorLudovic Henry <ludovic.henry@xamarin.com>
Thu, 18 Sep 2014 20:39:53 +0000 (16:39 -0400)
committerLudovic Henry <ludovic.henry@xamarin.com>
Thu, 18 Sep 2014 20:42:00 +0000 (16:42 -0400)
mono/metadata/sgen-copy-object.h
mono/metadata/sgen-minor-copy-object.h
mono/mini/exceptions-arm.c
mono/mini/mini-trampolines.c
mono/mini/xdebug.c
mono/profiler/perf_event.h
mono/utils/mono-compiler.h
mono/utils/mono-threads-windows.c

index dec0d073fe0055530f5bb9cae12fdc79caebd6cb..3c5abaca7c5a569baf85fd5296a4877fbef62cf2 100644 (file)
@@ -18,6 +18,9 @@
  * License 2.0 along with this library; if not, write to the Free
  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
+
+#include "mono/utils/mono-compiler.h"
+
 extern long long stat_copy_object_called_nursery;
 extern long long stat_objects_copied_nursery;
 
@@ -31,7 +34,7 @@ extern long long stat_slots_allocated_in_vain;
  * This function can be used even if the vtable of obj is not valid
  * anymore, which is the case in the parallel collector.
  */
-static inline void
+static MONO_ALWAYS_INLINE void
 par_copy_object_no_checks (char *destination, MonoVTable *vt, void *obj, mword objsize, SgenGrayQueue *queue)
 {
 #ifdef __GNUC__
@@ -99,11 +102,7 @@ par_copy_object_no_checks (char *destination, MonoVTable *vt, void *obj, mword o
 /*
  * This can return OBJ itself on OOM.
  */
-#ifdef _MSC_VER
-static __declspec(noinline) void*
-#else
-static G_GNUC_UNUSED void* __attribute__((noinline))
-#endif
+static MONO_NEVER_INLINE void*
 copy_object_no_checks (void *obj, SgenGrayQueue *queue)
 {
        MonoVTable *vt = ((MonoObject*)obj)->vtable;
index 782bbdf8de2dfe8b9994ccd92034b261a06cd250..187988e7def5fe723b6af95d294d87af839817ad 100644 (file)
@@ -25,6 +25,8 @@
 
 extern long long stat_nursery_copy_object_failed_to_space; /* from sgen-gc.c */
 
+#include "mono/utils/mono-compiler.h"
+
 #include "sgen-copy-object.h"
 
 /*
@@ -47,11 +49,7 @@ extern long long stat_nursery_copy_object_failed_to_space; /* from sgen-gc.c */
  * copy_object could be made into a macro once debugged (use inline for now).
  */
 
-#ifdef _MSC_VER
-static __forceinline void
-#else
-static inline void __attribute__((always_inline))
-#endif
+static MONO_ALWAYS_INLINE void
 SERIAL_COPY_OBJECT (void **obj_slot, SgenGrayQueue *queue) 
 {
        char *forwarded;
@@ -107,11 +105,7 @@ SERIAL_COPY_OBJECT (void **obj_slot, SgenGrayQueue *queue)
  *
  *   Similar to SERIAL_COPY_OBJECT, but assumes that OBJ_SLOT is part of an object, so it handles global remsets as well.
  */
-#ifdef _MSC_VER
-static __forceinline void
-#else
-static inline void __attribute__((always_inline))
-#endif
+static MONO_ALWAYS_INLINE void
 SERIAL_COPY_OBJECT_FROM_OBJ (void **obj_slot, SgenGrayQueue *queue) 
 {
        char *forwarded;
index d7fd3318f3d1e45a5a27693114a4ab2dbbf551c6..e39248ceda12e75453048aa4d042450f7d4b20cd 100644 (file)
@@ -36,6 +36,7 @@
 #include "mini.h"
 #include "mini-arm.h"
 #include "mono/utils/mono-sigcontext.h"
+#include "mono/utils/mono-compiler.h"
 
 /*
  * arch_get_restore_context:
@@ -536,10 +537,7 @@ handle_signal_exception (gpointer obj)
  * This works around a gcc 4.5 bug:
  * https://bugs.launchpad.net/ubuntu/+source/gcc-4.5/+bug/721531
  */
-#if defined(__GNUC__)
-__attribute__((noinline))
-#endif
-static gpointer
+static MONO_NEVER_INLINE gpointer
 get_handle_signal_exception_addr (void)
 {
        return handle_signal_exception;
index f65dab8c1e77f6220613e59111a84dd927597b90..4434564ee791c374fbce341e328e96b9e66842c3 100644 (file)
@@ -13,6 +13,7 @@
 #include <mono/utils/mono-counters.h>
 #include <mono/utils/mono-error-internals.h>
 #include <mono/utils/mono-membar.h>
+#include <mono/utils/mono-compiler.h>
 
 #include "mini.h"
 
@@ -140,18 +141,15 @@ mono_create_static_rgctx_trampoline (MonoMethod *m, gpointer addr)
 
 /*
  * Either IMPL_METHOD or AOT_ADDR will be set on return.
- */
-static gpointer*
-#ifdef __GNUC__
-/*
+ *
+ * MONO_NEVER_INLINE :
  * This works against problems when compiling with gcc 4.6 on arm. The 'then' part of
  * this line gets executed, even when the condition is false:
  *             if (impl && mono_method_needs_static_rgctx_invoke (impl, FALSE))
  *                     *need_rgctx_tramp = TRUE;
  */
-__attribute__ ((noinline))
-#endif
-       mono_convert_imt_slot_to_vtable_slot (gpointer* slot, mgreg_t *regs, guint8 *code, MonoMethod *method, gboolean lookup_aot, MonoMethod **impl_method, gboolean *need_rgctx_tramp, gboolean *variance_used, gpointer *aot_addr)
+static MONO_NEVER_INLINE gpointer*
+mono_convert_imt_slot_to_vtable_slot (gpointer* slot, mgreg_t *regs, guint8 *code, MonoMethod *method, gboolean lookup_aot, MonoMethod **impl_method, gboolean *need_rgctx_tramp, gboolean *variance_used, gpointer *aot_addr)
 {
        MonoObject *this_argument = mono_arch_get_this_arg_from_call (regs, code);
        MonoVTable *vt = this_argument->vtable;
index 9e415ca339092ac0da6eb5ae8a14828f46e08217..167b2b9e2b74b4702849aa58139508437c3ccfc8 100644 (file)
@@ -51,6 +51,8 @@
 #include "image-writer.h"
 #include "dwarfwriter.h"
 
+#include "mono/utils/mono-compiler.h"
+
 #define USE_GDB_JIT_INTERFACE
 
 /* The recommended gdb macro is: */
@@ -95,15 +97,8 @@ struct jit_descriptor
   struct jit_code_entry *first_entry;
 };
 
-
-#ifdef _MSC_VER
-#define MONO_NOINLINE __declspec (noinline)
-#else
-#define MONO_NOINLINE __attribute__((noinline))
-#endif
-
 /* GDB puts a breakpoint in this function.  */
-void MONO_NOINLINE __jit_debug_register_code(void);
+void MONO_NEVER_INLINE __jit_debug_register_code(void);
 
 #if !defined(MONO_LLVM_LOADED) && defined(ENABLE_LLVM) && !defined(MONO_CROSS_COMPILE)
 
@@ -114,7 +109,7 @@ extern struct jit_descriptor __jit_debug_descriptor;
 #else
 
 /* gcc seems to inline/eliminate calls to noinline functions, thus the asm () */
-void MONO_NOINLINE __jit_debug_register_code(void) {
+void MONO_NEVER_INLINE __jit_debug_register_code(void) {
 #if defined(__GNUC__)
        asm ("");
 #endif
index 057bf22a8323463a6bd9279d6928d3fea7ed8eb8..3137aea79800778a1d143994854d253bdf7d1704 100644 (file)
@@ -18,6 +18,8 @@
 #include <linux/ioctl.h>
 #include <asm/byteorder.h>
 
+#include "mono/utils/mono-compiler.h"
+
 /*
  * User-space ABI bits:
  */
@@ -1004,7 +1006,7 @@ static inline void perf_fetch_caller_regs(struct pt_regs *regs)
        perf_arch_fetch_caller_regs(regs, CALLER_ADDR0);
 }
 
-static __always_inline void
+static MONO_ALWAYS_INLINE void
 perf_sw_event(u32 event_id, u64 nr, int nmi, struct pt_regs *regs, u64 addr)
 {
        struct pt_regs hot_regs;
index 2b330b9bb9dfcc21decaf4a81e359a6241aaf5e1..e8a6a27cc7b635612bb4a38d69d13e448d273589 100644 (file)
@@ -247,5 +247,13 @@ typedef SSIZE_T ssize_t;
 #define MONO_ALWAYS_INLINE
 #endif
 
+#ifdef __GNUC__
+#define MONO_NEVER_INLINE __attribute__((noinline))
+#elif defined(_MSC_VER)
+#define MONO_NEVER_INLINE __declspec(noinline)
+#else
+#define MONO_NEVER_INLINE
+#endif
+
 #endif /* __UTILS_MONO_COMPILER_H__*/
 
index 892a8f5dc5c6c65a81bbeb7f4291aa39e5c0c982..69e1ac0e9f8c1b27d623bea778e1ee8c5c6daafb 100755 (executable)
@@ -12,6 +12,7 @@
 #if defined(HOST_WIN32)
 
 #include <mono/utils/mono-threads.h>
+#include <mono/utils/mono-compiler.h>
 #include <limits.h>
 
 
@@ -248,8 +249,7 @@ mono_threads_core_resume_created (MonoThreadInfo *info, MonoNativeThreadId tid)
 }
 
 #if HAVE_DECL___READFSDWORD==0
-static __inline__ __attribute__((always_inline))
-unsigned long long
+static MONO_ALWAYS_INLINE unsigned long long
 __readfsdword (unsigned long offset)
 {
        unsigned long value;