#include <mono/metadata/class-internals.h>
#include <mono/metadata/debug-helpers.h>
#include <mono/metadata/reflection.h>
-#include <mono/metadata/profiler.h>
#include <mono/metadata/profiler-private.h>
#include <mono/metadata/exception.h>
#include <mono/metadata/marshal.h>
static gboolean loader_lock_inited;
/* Statistics */
-static guint32 inflated_signatures_size;
-static guint32 memberref_sig_cache_size;
-static guint32 methods_size;
-static guint32 signatures_size;
+static gint32 inflated_signatures_size;
+static gint32 memberref_sig_cache_size;
+static gint32 methods_size;
+static gint32 signatures_size;
/*
* This TLS variable holds how many times the current thread has acquired the loader
static void dllmap_cleanup (void);
-
static void
global_loader_data_lock (void)
{
else {
g_hash_table_insert (image->memberref_signatures, GUINT_TO_POINTER (sig_idx), sig);
/* An approximation based on glib 2.18 */
- memberref_sig_cache_size += sizeof (gpointer) * 4;
+ InterlockedAdd (&memberref_sig_cache_size, sizeof (gpointer) * 4);
}
mono_image_unlock (image);
if (cached != sig)
mono_metadata_free_inflated_signature (sig);
else
- inflated_signatures_size += mono_metadata_signature_size (cached);
+ InterlockedAdd (&inflated_signatures_size, mono_metadata_signature_size (cached));
sig = cached;
}
static gboolean
is_absolute_path (const char *path)
{
-#ifdef PLATFORM_MACOSX
+#ifdef HOST_DARWIN
if (!strncmp (path, "@executable_path/", 17) || !strncmp (path, "@loader_path/", 13) ||
!strncmp (path, "@rpath/", 7))
return TRUE;
result = (MonoMethod *)mono_image_alloc0 (image, sizeof (MonoMethodPInvoke));
} else {
result = (MonoMethod *)mono_image_alloc0 (image, sizeof (MonoMethod));
- methods_size += sizeof (MonoMethod);
+ InterlockedAdd (&methods_size, sizeof (MonoMethod));
}
- mono_stats.method_count ++;
+ InterlockedIncrement (&mono_stats.method_count);
result->slot = -1;
result->klass = klass;
{
error_init (error);
- *cil_method = mono_get_method_from_token (image, token, NULL, context, NULL, error);
+ *cil_method = mono_get_method_checked (image, token, NULL, context, error);
if (!*cil_method)
return NULL;
void
mono_free_method (MonoMethod *method)
{
- if (mono_profiler_get_events () & MONO_PROFILE_METHOD_EVENTS)
- mono_profiler_method_free (method);
+ MONO_PROFILER_RAISE (method_free, (method));
/* FIXME: This hack will go away when the profiler will support freeing methods */
- if (mono_profiler_get_events () != MONO_PROFILE_NONE)
+ if (G_UNLIKELY (mono_profiler_installed ()))
return;
if (method->signature) {
if (!mono_error_ok (error))
return NULL;
- inflated_signatures_size += mono_metadata_signature_size (signature);
+ InterlockedAdd (&inflated_signatures_size, mono_metadata_signature_size (signature));
mono_image_lock (img);
mono_image_unlock (img);
}
- signatures_size += mono_metadata_signature_size (signature);
+ InterlockedAdd (&signatures_size, mono_metadata_signature_size (signature));
}
/* Verify metadata consistency */