Hi Jonathan,
The JIT isn't using these functions for method look-ups.
mono_method_descs are mainly for embedders (and for
trivial method look-ups at some places inside the runtime).
They come handy when you want to get an overloaded
MonoMethod in C/C++:
easy:
desc = mono_method_desc_new (":Method(int, string, int)");
method = mono_method_desc_search_in_class (desc, class);
mono_method_desc_free (desc);
versus hard:
- enum methods with mono_class_get_methods ()
- check method name
- check param count
- check param types
...
If you're generating stubs automatically and don't
have a string description of the methods up front,
the hard way involving mono_class_get_methods () might
be better and faster.
You may want to file a bug, though.
Robert
On 03.03.2016 19:28, Jonathan Mitchell wrote:
HI Robert
Thanks for that.
I think you are right.
I call hundreds of methods that take Obj`1<T> arguments with out issue but I see that
I have had to construct a number of helper methods to deal with cases of Obj`2<T, K>
which failed signature resolution.
I presume that managed code execution doesn’t involve calls to
mono_method_desc_new() - are thunks used instead?
One of the difficulties, I find, of working with the embedded API is trying to
visualise just how a particular managed code statement is implemented within
the runtime.
I was hoping to be able to call the constructor from C with a pointer to a
static (MonoString *)fund(MonoString *).
Not sure if that would even fly.
As a work around I will use an internal call.
Shall I log this as a bug and reference this thread?
Thanks a lot for replying.
Jonathan
On 3 Mar 2016, at 18:02, Robert Jordan <robe...@gmx.net> wrote:
On 03.03.2016 14:36, Jonathan Mitchell wrote:
HI
I want to call the following constructor via the embedded API:
public CloudClient(Func<string, string> filePathCallback)
All my other embedded method and constructor calls work okay but there is an issue
with this one - it is the only place I use a System.Func<T>.
The API reports that a method cannot be found for signature
.ctor(System.Func`2<string, string>)
When I dump out the class method names I see .ctor(System.Func`2<string,
string>) listed.
Any ideas on this one?
It looks like a bug in mono_method_desc_new ():
https://github.com/mono/mono/blob/master/mono/metadata/debug-helpers.c#L378
The function is treating
.ctor(System.Func`2<string, string>)
like a method with 2 arguments:
arg0 = System.Func`2<string
arg1 = string>
This is obviously wrong :)
The function is then storing the (wrong) argument count
for optimization purposes, and the comparison of methods
is starting to fail:
https://github.com/mono/mono/blob/master/mono/metadata/debug-helpers.c#L447
Robert
_______________________________________________
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list