From: Zoltan Varga Date: Fri, 16 Jun 2017 21:45:41 +0000 (-0400) Subject: [runtime] Add a mono_marshal_get_runtime_invoke_full () function with an extra need_d... X-Git-Url: http://wien.tomnetworks.com/gitweb/?p=mono.git;a=commitdiff_plain;h=cf39a9cd43fab1adc4e056b277aa8437171f6c45 [runtime] Add a mono_marshal_get_runtime_invoke_full () function with an extra need_direct_wrapper argument to allow generation of runtime-invoke wrappers which directly call a method without using the 'addr' argument. (#5053) --- diff --git a/mono/metadata/marshal.c b/mono/metadata/marshal.c index 29d03b8d7ac..46c34f76a6f 100644 --- a/mono/metadata/marshal.c +++ b/mono/metadata/marshal.c @@ -4306,7 +4306,7 @@ emit_runtime_invoke_body (MonoMethodBuilder *mb, MonoImage *image, MonoMethod *m * its \p method argument. */ MonoMethod * -mono_marshal_get_runtime_invoke (MonoMethod *method, gboolean virtual_) +mono_marshal_get_runtime_invoke_full (MonoMethod *method, gboolean virtual_, gboolean need_direct_wrapper) { MonoMethodSignature *sig, *csig, *callsig; MonoMethodBuilder *mb; @@ -4317,7 +4317,6 @@ mono_marshal_get_runtime_invoke (MonoMethod *method, gboolean virtual_) static MonoMethodSignature *finalize_signature = NULL; char *name; const char *param_names [16]; - gboolean need_direct_wrapper = FALSE; WrapperInfo *info; g_assert (method); @@ -4332,9 +4331,6 @@ mono_marshal_get_runtime_invoke (MonoMethod *method, gboolean virtual_) finalize_signature->hasthis = 1; } - if (virtual_) - need_direct_wrapper = TRUE; - /* * Use a separate cache indexed by methods to speed things up and to avoid the * boundless mempool growth caused by the signature_dup stuff below. @@ -4348,21 +4344,10 @@ mono_marshal_get_runtime_invoke (MonoMethod *method, gboolean virtual_) if (res) return res; - if (method->klass->rank && (method->iflags & METHOD_IMPL_ATTRIBUTE_INTERNAL_CALL) && - (method->iflags & METHOD_IMPL_ATTRIBUTE_NATIVE)) { - /* - * Array Get/Set/Address methods. The JIT implements them using inline code - * so we need to create an invoke wrapper which calls the method directly. - */ - need_direct_wrapper = TRUE; - } - if (method->string_ctor) { callsig = lookup_string_ctor_signature (mono_method_signature (method)); if (!callsig) callsig = add_string_ctor_signature (method); - /* Can't share this as we push a string as this */ - need_direct_wrapper = TRUE; } else { if (method_is_dynamic (method)) callsig = mono_metadata_signature_dup_full (method->klass->image, mono_method_signature (method)); @@ -4490,6 +4475,31 @@ mono_marshal_get_runtime_invoke (MonoMethod *method, gboolean virtual_) return res; } +MonoMethod * +mono_marshal_get_runtime_invoke (MonoMethod *method, gboolean virtual_) +{ + gboolean need_direct_wrapper = FALSE; + + if (virtual_) + need_direct_wrapper = TRUE; + + if (method->klass->rank && (method->iflags & METHOD_IMPL_ATTRIBUTE_INTERNAL_CALL) && + (method->iflags & METHOD_IMPL_ATTRIBUTE_NATIVE)) { + /* + * Array Get/Set/Address methods. The JIT implements them using inline code + * so we need to create an invoke wrapper which calls the method directly. + */ + need_direct_wrapper = TRUE; + } + + if (method->string_ctor) { + /* Can't share this as we push a string as this */ + need_direct_wrapper = TRUE; + } + + return mono_marshal_get_runtime_invoke_full (method, virtual_, need_direct_wrapper); +} + /* * mono_marshal_get_runtime_invoke_dynamic: * diff --git a/mono/metadata/marshal.h b/mono/metadata/marshal.h index 65719385906..12f224d2ded 100644 --- a/mono/metadata/marshal.h +++ b/mono/metadata/marshal.h @@ -324,6 +324,9 @@ mono_marshal_get_delegate_invoke (MonoMethod *method, MonoDelegate *del); MonoMethod * mono_marshal_get_delegate_invoke_internal (MonoMethod *method, gboolean callvirt, gboolean static_method_with_first_arg_bound, MonoMethod *target_method); +MonoMethod * +mono_marshal_get_runtime_invoke_full (MonoMethod *method, gboolean virtual_, gboolean need_direct_wrapper); + MonoMethod * mono_marshal_get_runtime_invoke (MonoMethod *method, gboolean is_virtual);