#include "mono/metadata/debug-helpers.h"
#include "mono/metadata/threads.h"
#include "mono/metadata/monitor.h"
+#include "mono/metadata/class-internals.h"
#include "mono/metadata/metadata-internals.h"
#include "mono/metadata/domain-internals.h"
#include "mono/metadata/gc-internal.h"
mono_register_jit_icall (func, name, sig, save);
}
-static MonoMethodSignature*
-signature_dup (MonoImage *image, MonoMethodSignature *sig)
-{
- MonoMethodSignature *res;
- int sigsize;
-
- res = mono_metadata_signature_alloc (image, sig->param_count);
- sigsize = MONO_SIZEOF_METHOD_SIGNATURE + sig->param_count * sizeof (MonoType *);
- memcpy (res, sig, sigsize);
-
- return res;
-}
-
MonoMethodSignature*
mono_signature_no_pinvoke (MonoMethod *method)
{
MonoMethodSignature *sig = mono_method_signature (method);
if (sig->pinvoke) {
- sig = signature_dup (method->klass->image, sig);
+ sig = mono_metadata_signature_dup_full (method->klass->image, sig);
sig->pinvoke = FALSE;
}
#ifdef USE_COOP_GC
register_icall (mono_threads_prepare_blocking, "mono_threads_prepare_blocking", "int", FALSE);
register_icall (mono_threads_finish_blocking, "mono_threads_finish_blocking", "void int", FALSE);
- register_icall (mono_threads_reset_blocking_start, "mono_threads_reset_blocking_start","int", FALSE);
- register_icall (mono_threads_reset_blocking_end, "mono_threads_reset_blocking_end","void int", FALSE);
+ register_icall (mono_threads_reset_blocking_start, "mono_threads_reset_blocking_start","int", TRUE);
+ register_icall (mono_threads_reset_blocking_end, "mono_threads_reset_blocking_end","void int", TRUE);
#endif
}
}
MonoMarshalSpec **mspecs;
MonoMethod *invoke = mono_get_delegate_invoke (klass);
MonoMethodPInvoke piinfo;
- MonoObject *this;
+ MonoObject *this_obj;
int i;
if (use_aot_wrappers) {
wrapper = mono_marshal_get_native_func_wrapper_aot (klass);
- this = mono_value_box (mono_domain_get (), mono_defaults.int_class, &ftn);
+ this_obj = mono_value_box (mono_domain_get (), mono_defaults.int_class, &ftn);
} else {
memset (&piinfo, 0, sizeof (piinfo));
parse_unmanaged_function_pointer_attr (klass, &piinfo);
sig->hasthis = 0;
wrapper = mono_marshal_get_native_func_wrapper (klass->image, sig, &piinfo, mspecs, ftn);
- this = NULL;
+ this_obj = NULL;
for (i = mono_method_signature (invoke)->param_count; i >= 0; i--)
if (mspecs [i])
}
d = (MonoDelegate*)mono_object_new (mono_domain_get (), klass);
- mono_delegate_ctor_with_method ((MonoObject*)d, this, mono_compile_method (wrapper), wrapper);
+ mono_delegate_ctor_with_method ((MonoObject*)d, this_obj, mono_compile_method (wrapper), wrapper);
}
if (d->object.vtable->domain != mono_domain_get ())
* Check cache
*/
if (ctx) {
- cache = get_cache (&method->klass->image->delegate_begin_invoke_generic_cache, mono_aligned_addr_hash, NULL);
+ cache = get_cache (&((MonoMethodInflated*)orig_method)->owner->wrapper_caches.delegate_begin_invoke_cache, mono_aligned_addr_hash, NULL);
res = check_generic_delegate_wrapper_cache (cache, orig_method, method, ctx);
if (res)
return res;
} else {
- cache = get_cache (&method->klass->image->delegate_begin_invoke_cache,
+ cache = get_cache (&method->klass->image->wrapper_caches.delegate_begin_invoke_cache,
(GHashFunc)mono_signature_hash,
(GCompareFunc)mono_metadata_signature_equal);
if ((res = mono_marshal_find_in_cache (cache, sig)))
* Check cache
*/
if (ctx) {
- cache = get_cache (&method->klass->image->delegate_end_invoke_generic_cache, mono_aligned_addr_hash, NULL);
+ cache = get_cache (&((MonoMethodInflated*)orig_method)->owner->wrapper_caches.delegate_end_invoke_cache, mono_aligned_addr_hash, NULL);
res = check_generic_delegate_wrapper_cache (cache, orig_method, method, ctx);
if (res)
return res;
} else {
- cache = get_cache (&method->klass->image->delegate_end_invoke_cache,
+ cache = get_cache (&method->klass->image->wrapper_caches.delegate_end_invoke_cache,
(GHashFunc)mono_signature_hash,
(GCompareFunc)mono_metadata_signature_equal);
if ((res = mono_marshal_find_in_cache (cache, sig)))
* Check cache
*/
if (ctx) {
- cache = get_cache (&method->klass->image->delegate_invoke_generic_cache, mono_aligned_addr_hash, NULL);
+ cache = get_cache (&((MonoMethodInflated*)orig_method)->owner->wrapper_caches.delegate_invoke_cache, mono_aligned_addr_hash, NULL);
res = check_generic_delegate_wrapper_cache (cache, orig_method, method, ctx);
if (res)
return res;
} else if (callvirt) {
GHashTable **cache_ptr;
- cache_ptr = &method->klass->image->delegate_abstract_invoke_cache;
+ cache_ptr = &mono_method_get_wrapper_cache (method)->delegate_abstract_invoke_cache;
/* We need to cache the signature+method pair */
mono_marshal_lock ();
if (res)
return res;
} else {
- cache = get_cache (&method->klass->image->delegate_invoke_cache,
+ // Inflated methods should not be in this cache because it's not stored on the imageset.
+ g_assert (!method->is_inflated);
+ cache = get_cache (&method->klass->image->wrapper_caches.delegate_invoke_cache,
(GHashFunc)mono_signature_hash,
(GCompareFunc)mono_metadata_signature_equal);
res = mono_marshal_find_in_cache (cache, sig);
cache_key = sig;
}
- static_sig = signature_dup (method->klass->image, sig);
+ static_sig = mono_metadata_signature_dup_full (method->klass->image, sig);
static_sig->hasthis = 0;
if (!static_method_with_first_arg_bound)
invoke_sig = static_sig;
return mono_marshal_get_delegate_invoke_internal (method, callvirt, static_method_with_first_arg_bound, target_method);
}
-/*
- * signature_dup_add_this:
- *
- * Make a copy of @sig, adding an explicit this argument.
- */
-static MonoMethodSignature*
-signature_dup_add_this (MonoImage *image, MonoMethodSignature *sig, MonoClass *klass)
-{
- MonoMethodSignature *res;
- int i;
-
- res = mono_metadata_signature_alloc (image, sig->param_count + 1);
- memcpy (res, sig, MONO_SIZEOF_METHOD_SIGNATURE);
- res->param_count = sig->param_count + 1;
- res->hasthis = FALSE;
- for (i = sig->param_count - 1; i >= 0; i --)
- res->params [i + 1] = sig->params [i];
- res->params [0] = klass->valuetype ? &klass->this_arg : &klass->byval_arg;
-
- return res;
-}
-
typedef struct {
MonoMethodSignature *ctor_sig;
MonoMethodSignature *sig;
MonoMethodSignature *callsig;
CtorSigPair *cs;
- callsig = signature_dup (method->klass->image, mono_method_signature (method));
+ callsig = mono_metadata_signature_dup_full (method->klass->image, mono_method_signature (method));
callsig->ret = &mono_defaults.string_class->byval_arg;
cs = g_new (CtorSigPair, 1);
cs->sig = callsig;
if (virtual)
cache = get_cache (&method->klass->image->runtime_invoke_vcall_cache, mono_aligned_addr_hash, NULL);
else
- cache = get_cache (&method->klass->image->runtime_invoke_direct_cache, mono_aligned_addr_hash, NULL);
+ cache = get_cache (&mono_method_get_wrapper_cache (method)->runtime_invoke_direct_cache, mono_aligned_addr_hash, NULL);
+
res = mono_marshal_find_in_cache (cache, method);
if (res)
return res;
need_direct_wrapper = TRUE;
} else {
if (method_is_dynamic (method))
- callsig = signature_dup (method->klass->image, mono_method_signature (method));
+ callsig = mono_metadata_signature_dup_full (method->klass->image, mono_method_signature (method));
else
callsig = mono_method_signature (method);
}
MonoMethodSignature *tmp_sig;
callsig = mono_marshal_get_runtime_invoke_sig (callsig);
+ GHashTable **cache_table = NULL;
if (method->klass->valuetype && mono_method_signature (method)->hasthis)
- /* These have a different csig */
- cache = get_cache (&target_klass->image->runtime_invoke_vtype_cache,
- (GHashFunc)mono_signature_hash,
- (GCompareFunc)runtime_invoke_signature_equal);
+ cache_table = &mono_method_get_wrapper_cache (method)->runtime_invoke_vtype_cache;
else
- cache = get_cache (&target_klass->image->runtime_invoke_cache,
- (GHashFunc)mono_signature_hash,
+ cache_table = &mono_method_get_wrapper_cache (method)->runtime_invoke_cache;
+
+ cache = get_cache (cache_table, (GHashFunc)mono_signature_hash,
(GCompareFunc)runtime_invoke_signature_equal);
/* from mono_marshal_find_in_cache */
mono_marshal_lock ();
res = g_hash_table_lookup (cache, callsig);
if (!res) {
+ GHashTable *direct_cache;
res = newm;
g_hash_table_insert (cache, callsig, res);
/* Can't insert it into wrapper_hash since the key is a signature */
- g_hash_table_insert (method->klass->image->runtime_invoke_direct_cache, method, res);
+ direct_cache = mono_method_get_wrapper_cache (method)->runtime_invoke_direct_cache;
+
+ g_hash_table_insert (direct_cache, method, res);
} else {
mono_free_method (newm);
}
/* Add an explicit this argument */
if (sig->hasthis)
- csig2 = signature_dup_add_this (mono_defaults.corlib, sig, mono_defaults.object_class);
+ csig2 = mono_metadata_signature_dup_add_this (mono_defaults.corlib, sig, mono_defaults.object_class);
else
- csig2 = signature_dup (mono_defaults.corlib, sig);
+ csig2 = mono_metadata_signature_dup_full (mono_defaults.corlib, sig);
#ifndef DISABLE_JIT
if (sig->hasthis)
mono_mb_emit_byte (mb, CEE_RET);
#endif
- csig = signature_dup (mono_defaults.corlib, sig);
+ csig = mono_metadata_signature_dup_full (mono_defaults.corlib, sig);
csig->pinvoke = 0;
if (csig->call_convention == MONO_CALL_VARARG)
csig->call_convention = 0;
g_assert (!sig->hasthis);
param_shift += 1;
}
- csig = signature_dup (mb->method->klass->image, sig);
+ csig = mono_metadata_signature_dup_full (mb->method->klass->image, sig);
csig->pinvoke = 1;
m.csig = csig;
m.image = image;
g_assert (method != NULL);
g_assert (mono_method_signature (method)->pinvoke);
+ GHashTable **cache_ptr;
+
if (aot) {
if (check_exceptions)
- cache = get_cache (&method->klass->image->native_wrapper_aot_check_cache, mono_aligned_addr_hash, NULL);
+ cache_ptr = &mono_method_get_wrapper_cache (method)->native_wrapper_aot_check_cache;
else
- cache = get_cache (&method->klass->image->native_wrapper_aot_cache, mono_aligned_addr_hash, NULL);
+ cache_ptr = &mono_method_get_wrapper_cache (method)->native_wrapper_aot_cache;
} else {
if (check_exceptions)
- cache = get_cache (&method->klass->image->native_wrapper_check_cache, mono_aligned_addr_hash, NULL);
+ cache_ptr = &mono_method_get_wrapper_cache (method)->native_wrapper_check_cache;
else
- cache = get_cache (&method->klass->image->native_wrapper_cache, mono_aligned_addr_hash, NULL);
+ cache_ptr = &mono_method_get_wrapper_cache (method)->native_wrapper_cache;
}
+
+ cache = get_cache (cache_ptr, mono_aligned_addr_hash, NULL);
+
if ((res = mono_marshal_find_in_cache (cache, method)))
return res;
g_assert (sig->hasthis);
/* CreateString returns a value */
- csig = signature_dup (method->klass->image, sig);
+ csig = mono_metadata_signature_dup_full (method->klass->image, sig);
csig->ret = &mono_defaults.string_class->byval_arg;
csig->pinvoke = 0;
info = mono_wrapper_info_create (mb, WRAPPER_SUBTYPE_NONE);
info->d.managed_to_native.method = method;
- csig = signature_dup (method->klass->image, sig);
+ csig = mono_metadata_signature_dup_full (method->klass->image, sig);
csig->pinvoke = 0;
res = mono_mb_create_and_cache_full (cache, method, mb, csig,
csig->param_count + 16, info, NULL);
/* internal calls: we simply push all arguments and call the method (no conversions) */
if (method->iflags & (METHOD_IMPL_ATTRIBUTE_INTERNAL_CALL | METHOD_IMPL_ATTRIBUTE_RUNTIME)) {
if (sig->hasthis)
- csig = signature_dup_add_this (method->klass->image, sig, method->klass);
+ csig = mono_metadata_signature_dup_add_this (method->klass->image, sig, method->klass);
else
- csig = signature_dup (method->klass->image, sig);
+ csig = mono_metadata_signature_dup_full (method->klass->image, sig);
/* hack - string constructors returns a value */
if (method->string_ctor)
info = mono_wrapper_info_create (mb, WRAPPER_SUBTYPE_NONE);
info->d.managed_to_native.method = method;
- csig = signature_dup (method->klass->image, csig);
+ csig = mono_metadata_signature_dup_full (method->klass->image, csig);
csig->pinvoke = 0;
res = mono_mb_create_and_cache_full (cache, method, mb, csig, csig->param_count + 16,
info, NULL);
info = mono_wrapper_info_create (mb, WRAPPER_SUBTYPE_PINVOKE);
info->d.managed_to_native.method = method;
- csig = signature_dup (method->klass->image, sig);
+ csig = mono_metadata_signature_dup_full (method->klass->image, sig);
csig->pinvoke = 0;
res = mono_mb_create_and_cache_full (cache, method, mb, csig, csig->param_count + 16,
info, NULL);
key.sig = sig;
key.pointer = func;
+ // Generic types are not safe to place in MonoImage caches.
+ g_assert (!sig->is_inflated);
+
cache = get_cache (&image->native_func_wrapper_cache, signature_pointer_pair_hash, signature_pointer_pair_equal);
if ((res = mono_marshal_find_in_cache (cache, &key)))
return res;
mono_marshal_emit_native_wrapper (image, mb, sig, piinfo, mspecs, func, FALSE, TRUE, FALSE);
#endif
- csig = signature_dup (image, sig);
+ csig = mono_metadata_signature_dup_full (image, sig);
csig->pinvoke = 0;
new_key = g_new (SignaturePointerPair,1);
/*
* The wrapper is associated with the delegate type, to pick up the marshalling info etc.
*/
- cache = get_cache (&image->native_func_wrapper_aot_cache, mono_aligned_addr_hash, NULL);
+ cache = get_cache (&mono_method_get_wrapper_cache (invoke)->native_func_wrapper_aot_cache, mono_aligned_addr_hash, NULL);
+
if ((res = mono_marshal_find_in_cache (cache, invoke)))
return res;
info->d.managed_to_native.method = invoke;
g_assert (!sig->hasthis);
- csig = signature_dup_add_this (image, sig, mono_defaults.object_class);
+ csig = mono_metadata_signature_dup_add_this (image, sig, mono_defaults.object_class);
csig->pinvoke = 0;
res = mono_mb_create_and_cache_full (cache, invoke,
mb, csig, csig->param_count + 16,
* could be called with different delegates, thus different marshalling
* options.
*/
- cache = get_cache (&method->klass->image->managed_wrapper_cache, mono_aligned_addr_hash, NULL);
+ cache = get_cache (&mono_method_get_wrapper_cache (method)->managed_wrapper_cache, mono_aligned_addr_hash, NULL);
+
if (!target_handle && (res = mono_marshal_find_in_cache (cache, method)))
return res;
/* Need to free this later */
csig = mono_metadata_signature_dup (invoke_sig);
else
- csig = signature_dup (method->klass->image, invoke_sig);
+ csig = mono_metadata_signature_dup_full (method->klass->image, invoke_sig);
csig->hasthis = 0;
csig->pinvoke = 1;
info, NULL);
} else {
#ifndef DISABLE_JIT
- mb->dynamic = 1;
+ mb->dynamic = TRUE;
#endif
res = mono_mb_create (mb, csig, sig->param_count + 16, NULL);
}
mono_method_get_marshal_info (method, mspecs);
mb = mono_mb_new (method->klass, method->name, MONO_WRAPPER_NATIVE_TO_MANAGED);
- csig = signature_dup (image, sig);
+ csig = mono_metadata_signature_dup_full (image, sig);
csig->hasthis = 0;
csig->pinvoke = 1;
mono_marshal_emit_managed_wrapper (mb, sig, mspecs, &m, method, 0);
#ifndef DISABLE_JIT
- mb->dynamic = 1;
+ mb->dynamic = TRUE;
#endif
method = mono_mb_create (mb, csig, sig->param_count + 16, NULL);
mono_mb_free (mb);
mono_mb_emit_op (mb, CEE_CALL, method);
mono_mb_emit_byte (mb, CEE_RET);
- mb->dynamic = 1;
+ mb->dynamic = TRUE;
#endif
method = mono_mb_create (mb, sig, param_count, NULL);
static void PtrToStructure (IntPtr ptr, object structure);
defined in class/corlib/System.Runtime.InteropServices/Marshal.cs */
sig = mono_create_icall_signature ("void ptr object");
- sig = signature_dup (mono_defaults.corlib, sig);
+ sig = mono_metadata_signature_dup_full (mono_defaults.corlib, sig);
sig->pinvoke = 0;
mono_memory_barrier ();
ptostr = sig;
mono_mb_emit_exception_full (mb, "System", "ExecutionEngineException", "Shouldn't be called.");
mono_mb_emit_byte (mb, CEE_RET);
#endif
- sig = signature_dup (method->klass->image, mono_method_signature (method));
+ sig = mono_metadata_signature_dup_full (method->klass->image, mono_method_signature (method));
info = mono_wrapper_info_create (mb, WRAPPER_SUBTYPE_SYNCHRONIZED_INNER);
info->d.synchronized_inner.method = method;
MonoMethodBuilder *mb;
MonoMethod *res;
GHashTable *cache;
- int i, pos, this_local, ret_local = 0;
+ int i, pos, pos2, this_local, taken_local, ret_local = 0;
MonoGenericContext *ctx = NULL;
MonoMethod *orig_method = NULL;
MonoGenericContainer *container = NULL;
* Check cache
*/
if (ctx) {
- cache = get_cache (&method->klass->image->synchronized_generic_cache, mono_aligned_addr_hash, NULL);
+ cache = get_cache (&((MonoMethodInflated*)orig_method)->owner->wrapper_caches.synchronized_cache, mono_aligned_addr_hash, NULL);
res = check_generic_wrapper_cache (cache, orig_method, orig_method, method);
if (res)
return res;
} else {
- cache = get_cache (&method->klass->image->synchronized_cache, mono_aligned_addr_hash, NULL);
+ cache = get_cache (&method->klass->image->wrapper_caches.synchronized_cache, mono_aligned_addr_hash, NULL);
if ((res = mono_marshal_find_in_cache (cache, method)))
return res;
}
- sig = signature_dup (method->klass->image, mono_method_signature (method));
+ sig = mono_metadata_signature_dup_full (method->klass->image, mono_method_signature (method));
sig->pinvoke = 0;
mb = mono_mb_new (method->klass, method->name, MONO_WRAPPER_SYNCHRONIZED);
#ifndef DISABLE_JIT
+ mb->skip_visibility = 1;
/* result */
if (!MONO_TYPE_IS_VOID (sig->ret))
ret_local = mono_mb_add_local (mb, sig->ret);
#ifndef DISABLE_JIT
/* this */
this_local = mono_mb_add_local (mb, &mono_defaults.object_class->byval_arg);
+ taken_local = mono_mb_add_local (mb, &mono_defaults.boolean_class->byval_arg);
clause = mono_image_alloc0 (method->klass->image, sizeof (MonoExceptionClause));
clause->flags = MONO_EXCEPTION_CLAUSE_FINALLY;
if (!enter_method) {
MonoMethodDesc *desc;
- desc = mono_method_desc_new ("Monitor:Enter", FALSE);
+ desc = mono_method_desc_new ("Monitor:enter_with_atomic_var(object,bool&)", FALSE);
enter_method = mono_method_desc_search_in_class (desc, mono_defaults.monitor_class);
g_assert (enter_method);
mono_method_desc_free (desc);
/* Call Monitor::Enter() */
mono_mb_emit_ldloc (mb, this_local);
+ mono_mb_emit_ldloc_addr (mb, taken_local);
mono_mb_emit_managed_call (mb, enter_method, NULL);
clause->try_offset = mono_mb_get_label (mb);
clause->try_len = mono_mb_get_pos (mb) - clause->try_offset;
clause->handler_offset = mono_mb_get_label (mb);
- /* Call Monitor::Exit() */
+ /* Call Monitor::Exit() if needed */
+ mono_mb_emit_ldloc (mb, taken_local);
+ pos2 = mono_mb_emit_branch (mb, CEE_BRFALSE);
mono_mb_emit_ldloc (mb, this_local);
mono_mb_emit_managed_call (mb, exit_method, NULL);
+ mono_mb_patch_branch (mb, pos2);
mono_mb_emit_byte (mb, CEE_ENDFINALLY);
clause->handler_len = mono_mb_get_pos (mb) - clause->handler_offset;
MonoMethod *res;
GHashTable *cache;
- cache = get_cache (&method->klass->image->unbox_wrapper_cache, mono_aligned_addr_hash, NULL);
+ cache = get_cache (&mono_method_get_wrapper_cache (method)->unbox_wrapper_cache, mono_aligned_addr_hash, NULL);
+
if ((res = mono_marshal_find_in_cache (cache, method)))
return res;
return res;
}
- sig = signature_dup (method->klass->image, mono_method_signature (method));
+ sig = mono_metadata_signature_dup_full (method->klass->image, mono_method_signature (method));
sig->pinvoke = 0;
mb = mono_mb_new (method->klass, method->name, MONO_WRAPPER_UNKNOWN);
METHOD_ATTRIBUTE_NEW_SLOT | METHOD_ATTRIBUTE_HIDE_BY_SIG | METHOD_ATTRIBUTE_FINAL;
sig = mono_method_signature (method);
- csig = signature_dup (method->klass->image, sig);
+ csig = mono_metadata_signature_dup_full (method->klass->image, sig);
csig->generic_param_count = 0;
#ifndef DISABLE_JIT
GHashTable *cache;
MonoMethod *res;
int i, param_count, sig_size, pos_leave;
+#ifdef USE_COOP_GC
+ int coop_gc_var;
+#endif
g_assert (method);
klass = method->klass;
image = method->klass->image;
- cache = get_cache (&image->thunk_invoke_cache, mono_aligned_addr_hash, NULL);
+
+ cache = get_cache (&mono_method_get_wrapper_cache (method)->thunk_invoke_cache, mono_aligned_addr_hash, NULL);
+
if ((res = mono_marshal_find_in_cache (cache, method)))
return res;
if (!MONO_TYPE_IS_VOID (sig->ret))
mono_mb_add_local (mb, sig->ret);
+#ifdef USE_COOP_GC
+ /* local 4, the local to be used when calling the reset_blocking funcs */
+ /* tons of code hardcode 3 to be the return var */
+ coop_gc_var = mono_mb_add_local (mb, &mono_defaults.int_class->byval_arg);
+#endif
+
/* clear exception arg */
mono_mb_emit_ldarg (mb, param_count - 1);
mono_mb_emit_byte (mb, CEE_LDNULL);
mono_mb_emit_byte (mb, CEE_STIND_REF);
+#ifdef USE_COOP_GC
+ /* FIXME this is technically wrong as the callback itself must be executed in gc unsafe context. */
+ mono_mb_emit_icall (mb, mono_threads_reset_blocking_start);
+ mono_mb_emit_stloc (mb, coop_gc_var);
+#endif
+
/* try */
clause = mono_image_alloc0 (image, sizeof (MonoExceptionClause));
clause->try_offset = mono_mb_get_label (mb);
mono_mb_emit_op (mb, CEE_BOX, mono_class_from_mono_type (sig->ret));
}
+#ifdef USE_COOP_GC
+ /* XXX merge reset_blocking_end with detach */
+ mono_mb_emit_ldloc (mb, coop_gc_var);
+ mono_mb_emit_icall (mb, mono_threads_reset_blocking_end);
+#endif
+
mono_mb_emit_byte (mb, CEE_RET);
#endif
* FIXME: We currently leak the wrappers. Freeing them would be tricky as
* they could be shared with other methods ?
*/
- if (image->runtime_invoke_direct_cache)
- g_hash_table_remove (image->runtime_invoke_direct_cache, method);
- if (image->delegate_abstract_invoke_cache)
- g_hash_table_foreach_remove (image->delegate_abstract_invoke_cache, signature_pointer_pair_matches_pointer, method);
+ if (image->wrapper_caches.runtime_invoke_direct_cache)
+ g_hash_table_remove (image->wrapper_caches.runtime_invoke_direct_cache, method);
+ if (image->wrapper_caches.delegate_abstract_invoke_cache)
+ g_hash_table_foreach_remove (image->wrapper_caches.delegate_abstract_invoke_cache, signature_pointer_pair_matches_pointer, method);
// FIXME: Need to clear the caches in other images as well
if (image->delegate_bound_static_invoke_cache)
g_hash_table_remove (image->delegate_bound_static_invoke_cache, mono_method_signature (method));
if (marshal_mutex_initialized)
mono_marshal_unlock ();
}
-
-static gboolean
-signature_pointer_pair_matches_signature (gpointer key, gpointer value, gpointer user_data)
-{
- SignaturePointerPair *pair = (SignaturePointerPair*)key;
- MonoMethodSignature *sig = (MonoMethodSignature*)user_data;
-
- return mono_metadata_signature_equal (pair->sig, sig);
-}
-
-/*
- * mono_marshal_free_inflated_wrappers:
- *
- * Free wrappers of the inflated method METHOD.
- */
-void
-mono_marshal_free_inflated_wrappers (MonoMethod *method)
-{
- MonoMethodSignature *sig = method->signature;
-
- g_assert (method->is_inflated);
-
- /* Ignore calls occuring late during cleanup. */
- if (!marshal_mutex_initialized)
- return;
-
- mono_marshal_lock ();
- /*
- * FIXME: We currently leak the wrappers. Freeing them would be tricky as
- * they could be shared with other methods ?
- */
-
- /*
- * indexed by MonoMethodSignature
- */
- /* FIXME: This could remove unrelated wrappers as well */
- if (sig && method->klass->image->delegate_begin_invoke_cache)
- g_hash_table_remove (method->klass->image->delegate_begin_invoke_cache, sig);
- if (sig && method->klass->image->delegate_end_invoke_cache)
- g_hash_table_remove (method->klass->image->delegate_end_invoke_cache, sig);
- if (sig && method->klass->image->delegate_invoke_cache)
- g_hash_table_remove (method->klass->image->delegate_invoke_cache, sig);
- if (sig && method->klass->image->runtime_invoke_cache)
- g_hash_table_remove (method->klass->image->runtime_invoke_cache, sig);
- if (sig && method->klass->image->runtime_invoke_vtype_cache)
- g_hash_table_remove (method->klass->image->runtime_invoke_vtype_cache, sig);
-
- /*
- * indexed by SignaturePointerPair
- */
- if (sig && method->klass->image->delegate_abstract_invoke_cache)
- g_hash_table_foreach_remove (method->klass->image->delegate_abstract_invoke_cache,
- signature_pointer_pair_matches_signature, (gpointer)sig);
-
- /*
- * indexed by MonoMethod pointers
- */
- if (method->klass->image->runtime_invoke_direct_cache)
- g_hash_table_remove (method->klass->image->runtime_invoke_direct_cache, method);
- if (method->klass->image->managed_wrapper_cache)
- g_hash_table_remove (method->klass->image->managed_wrapper_cache, method);
- if (method->klass->image->native_wrapper_cache)
- g_hash_table_remove (method->klass->image->native_wrapper_cache, method);
- if (method->klass->image->remoting_invoke_cache)
- g_hash_table_remove (method->klass->image->remoting_invoke_cache, method);
- if (method->klass->image->synchronized_cache)
- g_hash_table_remove (method->klass->image->synchronized_cache, method);
- if (method->klass->image->unbox_wrapper_cache)
- g_hash_table_remove (method->klass->image->unbox_wrapper_cache, method);
- if (method->klass->image->cominterop_invoke_cache)
- g_hash_table_remove (method->klass->image->cominterop_invoke_cache, method);
- if (method->klass->image->cominterop_wrapper_cache)
- g_hash_table_remove (method->klass->image->cominterop_wrapper_cache, method);
- if (method->klass->image->thunk_invoke_cache)
- g_hash_table_remove (method->klass->image->thunk_invoke_cache, method);
- if (method->klass->image->native_func_wrapper_aot_cache)
- g_hash_table_remove (method->klass->image->native_func_wrapper_aot_cache, method);
-
- mono_marshal_unlock ();
-}