From 0ec79ec49e5c9b033c0635121bc65f9b54ece3b9 Mon Sep 17 00:00:00 2001 From: Aleksey Kliger Date: Fri, 12 May 2017 12:30:05 -0400 Subject: [PATCH] [runtime] Use coop handles for System.Delegate.AllocDelegateLike_internal --- mono/metadata/icall-def.h | 2 +- mono/metadata/icall.c | 17 ++++++++--------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/mono/metadata/icall-def.h b/mono/metadata/icall-def.h index cd47c3abd10..51b333dce30 100644 --- a/mono/metadata/icall-def.h +++ b/mono/metadata/icall-def.h @@ -207,7 +207,7 @@ ICALL(DECIMAL_13, "ToSingle", mono_decimal_to_float) #endif ICALL_TYPE(DELEGATE, "System.Delegate", DELEGATE_1) -ICALL(DELEGATE_1, "AllocDelegateLike_internal", ves_icall_System_Delegate_AllocDelegateLike_internal) +HANDLES(ICALL(DELEGATE_1, "AllocDelegateLike_internal", ves_icall_System_Delegate_AllocDelegateLike_internal)) HANDLES(ICALL(DELEGATE_2, "CreateDelegate_internal", ves_icall_System_Delegate_CreateDelegate_internal)) HANDLES(ICALL(DELEGATE_3, "GetVirtualMethod_internal", ves_icall_System_Delegate_GetVirtualMethod_internal)) diff --git a/mono/metadata/icall.c b/mono/metadata/icall.c index 00c0e4fea11..79329f93538 100644 --- a/mono/metadata/icall.c +++ b/mono/metadata/icall.c @@ -6231,19 +6231,18 @@ ves_icall_System_Delegate_CreateDelegate_internal (MonoReflectionTypeHandle ref_ return delegate; } -ICALL_EXPORT MonoMulticastDelegate * -ves_icall_System_Delegate_AllocDelegateLike_internal (MonoDelegate *delegate) +ICALL_EXPORT MonoMulticastDelegateHandle +ves_icall_System_Delegate_AllocDelegateLike_internal (MonoDelegateHandle delegate, MonoError *error) { - MonoError error; - MonoMulticastDelegate *ret; + error_init (error); - g_assert (mono_class_has_parent (mono_object_class (delegate), mono_defaults.multicastdelegate_class)); + MonoClass *klass = mono_handle_class (delegate); + g_assert (mono_class_has_parent (klass, mono_defaults.multicastdelegate_class)); - ret = (MonoMulticastDelegate*) mono_object_new_checked (mono_object_domain (delegate), mono_object_class (delegate), &error); - if (mono_error_set_pending_exception (&error)) - return NULL; + MonoMulticastDelegateHandle ret = MONO_HANDLE_NEW (MonoMulticastDelegate, mono_object_new_checked (MONO_HANDLE_DOMAIN (delegate), klass, error)); + return_val_if_nok (error, MONO_HANDLE_CAST (MonoMulticastDelegate, NULL_HANDLE)); - ret->delegate.invoke_impl = mono_runtime_create_delegate_trampoline (mono_object_class (delegate)); + MONO_HANDLE_SETVAL (MONO_HANDLE_CAST (MonoDelegate, ret), invoke_impl, gpointer, mono_runtime_create_delegate_trampoline (klass)); return ret; } -- 2.25.1