Skip to content
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion runtime/trampolines.m
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,17 @@
}
}
} else {
xamarin_assertion_message ("Don't know how to marshal a return value of type '%s.%s'. Please file a bug with a test case at https://github.com/xamarin/xamarin-macios/issues/new\n", mono_class_get_namespace (r_klass), mono_class_get_name (r_klass));
char *fullname = xamarin_class_get_full_name (r_klass, exception_gchandle);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

last little bit - since fullname is only used in the error and @rolfbjarne implies that it's more costly than the xamarin_is_class_ tests, how about moving the allocation and deallocation into the else clause so that the price only gets paid in the failing case.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reverted the assertion to the original code as it did not need (extra) allocation, inside the caller, and still produced the same output.

#if DOTNET
if (!strcmp (fullname, "System.IntPtr") || !strcmp (fullname, "ObjCRuntime.NativeHandle")) {
#else
if (!strcmp (fullname, "System.IntPtr")) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are two functions that are much faster and simpler: xamarin_is_class_intptr and xamarin_is_class_nativehandle, no need to compute a full type name nor compare strings.

#endif
returnValue = *(void **) mono_object_unbox (retval);
} else {
xamarin_assertion_message ("Don't know how to marshal a return value of type '%s'. Please file a bug with a test case at https://github.com/xamarin/xamarin-macios/issues/new\n", fullname);
}
xamarin_free (fullname);
}

xamarin_mono_object_release (&r_klass);
Expand Down