Skip to content
Merged
Changes from 1 commit
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
4 changes: 2 additions & 2 deletions src/mono/mono/mini/interp/transform.c
Original file line number Diff line number Diff line change
Expand Up @@ -4486,8 +4486,6 @@ interp_method_compute_offsets (TransformData *td, InterpMethod *imethod, MonoMet
#ifdef MONO_ARCH_HAVE_SWIFTCALL
int swift_error_index = -1;
imethod->swift_error_offset = -1;
MonoClass *swift_error = mono_class_try_get_swift_error_class ();
MonoClass *swift_error_ptr = mono_class_create_ptr (m_class_get_this_arg (swift_error));
#endif

/*
Expand Down Expand Up @@ -4517,6 +4515,8 @@ interp_method_compute_offsets (TransformData *td, InterpMethod *imethod, MonoMet

#ifdef MONO_ARCH_HAVE_SWIFTCALL
if (swift_error_index < 0 && mono_method_signature_has_ext_callconv (sig, MONO_EXT_CALLCONV_SWIFTCALL)) {
MonoClass *swift_error = mono_class_try_get_swift_error_class ();
MonoClass *swift_error_ptr = mono_class_create_ptr (m_class_get_this_arg (swift_error));
Copy link
Member

Choose a reason for hiding this comment

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

I think we should still do a null check here in case there are CallConvSwift calls without any usages of SwiftError.

Copy link
Member

Choose a reason for hiding this comment

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

Note, we have the same pattern in marshal.c, and mini-<arch>.c files.

However, if I understand it correctly, error here would mean that CallConvSwift is set and System.Runtime.InteropServices.Swift got trimmed out. Sounds unlikely but perhaps possible...

Copy link
Member

Choose a reason for hiding this comment

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

If there is a common pattern, it might be good to extract it into a function which would also do a null / error checks, so that a better error message is displayed in case a type is not found in the source assemblies.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks, added. I don't think it should report any error message since it will just skip the swift_error path.

MonoClass *klass = mono_class_from_mono_type_internal (type);
if (klass == swift_error_ptr)
swift_error_index = i;
Expand Down