Bug 55148 - Debugger checks type which is possibly never used (#4690)
authorDavid Karlaš <david.karlas@gmail.com>
Tue, 18 Apr 2017 05:35:23 +0000 (07:35 +0200)
committerZoltan Varga <vargaz@gmail.com>
Tue, 18 Apr 2017 05:35:23 +0000 (01:35 -0400)
mono/mini/debugger-agent.c

index 8e3691db62bf3bbadad4e51ba32de3e81b8b3a57..839494f06f7766108d27c49b61a592c4ff165f43 100644 (file)
@@ -4705,21 +4705,16 @@ get_this_async_id (StackFrame *frame)
        return get_objid (get_this (frame));
 }
 
-static MonoMethod* set_notification_method_cache = NULL;
-
 static MonoMethod*
-get_set_notification_method ()
+get_set_notification_method (MonoClass* async_builder_class)
 {
-       if(set_notification_method_cache != NULL)
-               return set_notification_method_cache;
        MonoError error;
-       MonoClass* async_builder_class = mono_class_load_from_name (mono_defaults.corlib, "System.Runtime.CompilerServices", "AsyncTaskMethodBuilder");
        GPtrArray* array = mono_class_get_methods_by_name (async_builder_class, "SetNotificationForWaitCompletion", 0x24, FALSE, FALSE, &error);
        mono_error_assert_ok (&error);
        g_assert (array->len == 1);
-       set_notification_method_cache = (MonoMethod *)g_ptr_array_index (array, 0);
+       MonoMethod* set_notification_method = (MonoMethod *)g_ptr_array_index (array, 0);
        g_ptr_array_free (array, TRUE);
-       return set_notification_method_cache;
+       return set_notification_method;
 }
 
 static void
@@ -4738,7 +4733,7 @@ set_set_notification_for_wait_completion_flag (StackFrame *frame)
        void* args [1];
        gboolean arg = TRUE;
        args [0] = &arg;
-       mono_runtime_invoke_checked (get_set_notification_method(), mono_object_unbox (builder), args, &error);
+       mono_runtime_invoke_checked (get_set_notification_method (builder->vtable->klass), mono_object_unbox (builder), args, &error);
        mono_error_assert_ok (&error);
        mono_field_set_value (obj, builder_field, mono_object_unbox (builder));
 }