summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
ccb1921)
- have all counters in a global place and initialise them in `mono_trampolines_init ()`
- use `Unlocked* ()` and `mono_trampolines_lock ()` to mark / synchronise all racy counters
#include <mono/utils/mono-membar.h>
#include <mono/utils/mono-compiler.h>
#include <mono/utils/mono-threads-coop.h>
#include <mono/utils/mono-membar.h>
#include <mono/utils/mono-compiler.h>
#include <mono/utils/mono-threads-coop.h>
+#include <mono/utils/unlocked.h>
#include "mini.h"
#include "lldb.h"
#include "mini.h"
#include "lldb.h"
static GHashTable *rgctx_lazy_fetch_trampoline_hash;
static GHashTable *rgctx_lazy_fetch_trampoline_hash_addr;
static GHashTable *rgctx_lazy_fetch_trampoline_hash;
static GHashTable *rgctx_lazy_fetch_trampoline_hash_addr;
-static guint32 trampoline_calls, jit_trampolines, unbox_trampolines, static_rgctx_trampolines;
+
+static gint32 trampoline_calls;
+static gint32 jit_trampolines;
+static gint32 unbox_trampolines;
+static gint32 static_rgctx_trampolines;
+static gint32 rgctx_unmanaged_lookups;
+static gint32 rgctx_num_lazy_fetch_trampolines;
#define mono_trampolines_lock() mono_os_mutex_lock (&trampolines_mutex)
#define mono_trampolines_unlock() mono_os_mutex_unlock (&trampolines_mutex)
#define mono_trampolines_lock() mono_os_mutex_lock (&trampolines_mutex)
#define mono_trampolines_unlock() mono_os_mutex_unlock (&trampolines_mutex)
info->m = m;
info->addr = addr;
g_hash_table_insert (domain_jit_info (domain)->static_rgctx_trampoline_hash, info, res);
info->m = m;
info->addr = addr;
g_hash_table_insert (domain_jit_info (domain)->static_rgctx_trampoline_hash, info, res);
- mono_domain_unlock (domain);
- static_rgctx_trampolines ++;
+ UnlockedIncrement (&static_rgctx_trampolines);
+ mono_domain_unlock (domain);
g_assert (mono_thread_is_gc_unsafe_mode ());
g_assert (mono_thread_is_gc_unsafe_mode ());
+ UnlockedIncrement (&trampoline_calls);
res = common_call_trampoline (regs, code, (MonoMethod *)arg, NULL, NULL, &error);
if (!is_ok (&error)) {
res = common_call_trampoline (regs, code, (MonoMethod *)arg, NULL, NULL, &error);
if (!is_ok (&error)) {
MonoError error;
gpointer addr, res = NULL;
MonoError error;
gpointer addr, res = NULL;
+ UnlockedIncrement (&trampoline_calls);
/*
* We need to obtain the following pieces of information:
/*
* We need to obtain the following pieces of information:
MonoMethod *imt_method, *declaring;
gpointer addr;
MonoMethod *imt_method, *declaring;
gpointer addr;
+ UnlockedIncrement (&trampoline_calls);
g_assert (m->is_generic);
g_assert (m->is_generic);
guint8 *plt_entry;
MonoError error;
guint8 *plt_entry;
MonoError error;
+ UnlockedIncrement (&trampoline_calls);
image = (MonoImage *)*(gpointer*)(gpointer)token_info;
token_info += sizeof (gpointer);
image = (MonoImage *)*(gpointer*)(gpointer)token_info;
token_info += sizeof (gpointer);
gpointer res;
MonoError error;
gpointer res;
MonoError error;
+ UnlockedIncrement (&trampoline_calls);
res = mono_aot_plt_resolve (aot_module, plt_info_offset, code, &error);
if (!res) {
res = mono_aot_plt_resolve (aot_module, plt_info_offset, code, &error);
if (!res) {
{
MONO_REQ_GC_UNSAFE_MODE;
{
MONO_REQ_GC_UNSAFE_MODE;
- static gboolean inited = FALSE;
- static int num_lookups = 0;
guint32 slot = GPOINTER_TO_UINT (data);
mgreg_t *r = (mgreg_t*)regs;
gpointer arg = (gpointer)(gssize)r [MONO_ARCH_VTABLE_REG];
guint32 slot = GPOINTER_TO_UINT (data);
mgreg_t *r = (mgreg_t*)regs;
gpointer arg = (gpointer)(gssize)r [MONO_ARCH_VTABLE_REG];
MonoError error;
gpointer res;
MonoError error;
gpointer res;
- trampoline_calls ++;
-
- if (!inited) {
- mono_counters_register ("RGCTX unmanaged lookups", MONO_COUNTER_GENERICS | MONO_COUNTER_INT, &num_lookups);
- inited = TRUE;
- }
-
- num_lookups++;
+ UnlockedIncrement (&trampoline_calls);
+ UnlockedIncrement (&rgctx_unmanaged_lookups);
if (mrgctx)
res = mono_method_fill_runtime_generic_context ((MonoMethodRuntimeGenericContext *)arg, index, &error);
if (mrgctx)
res = mono_method_fill_runtime_generic_context ((MonoMethodRuntimeGenericContext *)arg, index, &error);
gpointer addr, compiled_method;
gboolean is_remote = FALSE;
gpointer addr, compiled_method;
gboolean is_remote = FALSE;
+ UnlockedIncrement (&trampoline_calls);
/* Obtain the delegate object according to the calling convention */
delegate = (MonoDelegate *)mono_arch_get_this_arg_from_call (regs, code);
/* Obtain the delegate object according to the calling convention */
delegate = (MonoDelegate *)mono_arch_get_this_arg_from_call (regs, code);
mono_counters_register ("JIT trampolines", MONO_COUNTER_JIT | MONO_COUNTER_INT, &jit_trampolines);
mono_counters_register ("Unbox trampolines", MONO_COUNTER_JIT | MONO_COUNTER_INT, &unbox_trampolines);
mono_counters_register ("Static rgctx trampolines", MONO_COUNTER_JIT | MONO_COUNTER_INT, &static_rgctx_trampolines);
mono_counters_register ("JIT trampolines", MONO_COUNTER_JIT | MONO_COUNTER_INT, &jit_trampolines);
mono_counters_register ("Unbox trampolines", MONO_COUNTER_JIT | MONO_COUNTER_INT, &unbox_trampolines);
mono_counters_register ("Static rgctx trampolines", MONO_COUNTER_JIT | MONO_COUNTER_INT, &static_rgctx_trampolines);
+ mono_counters_register ("RGCTX unmanaged lookups", MONO_COUNTER_GENERICS | MONO_COUNTER_INT, &rgctx_unmanaged_lookups);
+ mono_counters_register ("RGCTX num lazy fetch trampolines", MONO_COUNTER_GENERICS | MONO_COUNTER_INT, &rgctx_num_lazy_fetch_trampolines);
mono_domain_lock (domain);
g_hash_table_insert (domain_jit_info (domain)->jit_trampoline_hash, method, tramp);
mono_domain_lock (domain);
g_hash_table_insert (domain_jit_info (domain)->jit_trampoline_hash, method, tramp);
+ UnlockedIncrement (&jit_trampolines);
mono_domain_unlock (domain);
mono_domain_unlock (domain);
tramp = mono_create_specific_trampoline (start, MONO_TRAMPOLINE_AOT, domain, NULL);
tramp = mono_create_specific_trampoline (start, MONO_TRAMPOLINE_AOT, domain, NULL);
+ UnlockedIncrement (&jit_trampolines);
gpointer
mono_create_rgctx_lazy_fetch_trampoline (guint32 offset)
{
gpointer
mono_create_rgctx_lazy_fetch_trampoline (guint32 offset)
{
- static gboolean inited = FALSE;
- static int num_trampolines = 0;
gpointer tramp, ptr;
mono_trampolines_lock ();
gpointer tramp, ptr;
mono_trampolines_lock ();
g_hash_table_insert (rgctx_lazy_fetch_trampoline_hash, GUINT_TO_POINTER (offset), ptr);
g_assert (offset != -1);
g_hash_table_insert (rgctx_lazy_fetch_trampoline_hash_addr, ptr, GUINT_TO_POINTER (offset + 1));
g_hash_table_insert (rgctx_lazy_fetch_trampoline_hash, GUINT_TO_POINTER (offset), ptr);
g_assert (offset != -1);
g_hash_table_insert (rgctx_lazy_fetch_trampoline_hash_addr, ptr, GUINT_TO_POINTER (offset + 1));
+ rgctx_num_lazy_fetch_trampolines ++;
mono_trampolines_unlock ();
mono_trampolines_unlock ();
- if (!inited) {
- mono_counters_register ("RGCTX num lazy fetch trampolines",
- MONO_COUNTER_GENERICS | MONO_COUNTER_INT, &num_trampolines);
- inited = TRUE;
- }
- num_trampolines++;
-