Skip to content

Commit

Permalink
[release/8.0] [Mono] Fix unsafe accessor related issue for full AOT (#…
Browse files Browse the repository at this point in the history
…91270)

* Fix unsafe accessor related issue for full aot

* Only skip for WRAPPER_SUBTYPE_UNSAFE_ACCESSOR

---------

Co-authored-by: Fan Yang <yangfan@microsoft.com>
  • Loading branch information
github-actions[bot] and fanyang-mono authored Aug 29, 2023
1 parent 2ec0bc7 commit c3a8740
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
10 changes: 6 additions & 4 deletions src/mono/mono/mini/aot-compiler.c
Original file line number Diff line number Diff line change
Expand Up @@ -3844,10 +3844,12 @@ encode_method_ref (MonoAotCompile *acfg, MonoMethod *method, guint8 *buf, guint8
else if (info->subtype == WRAPPER_SUBTYPE_UNSAFE_ACCESSOR) {
encode_method_ref (acfg, info->d.unsafe_accessor.method, p, &p);
encode_value (info->d.unsafe_accessor.kind, p, &p);
/* WISH: is there some kind of string heap token we could use here? */
uint32_t len = (uint32_t) strlen (info->d.unsafe_accessor.member_name);
encode_value (len, p, &p);
encode_string (info->d.unsafe_accessor.member_name, p, &p);
if (info->d.unsafe_accessor.member_name) {
/* WISH: is there some kind of string heap token we could use here? */
uint32_t len = (uint32_t) strlen (info->d.unsafe_accessor.member_name);
encode_value (len, p, &p);
encode_string (info->d.unsafe_accessor.member_name, p, &p);
}
}
else if (info->subtype == WRAPPER_SUBTYPE_INTERP_IN)
encode_signature (acfg, info->d.interp_in.sig, p, &p);
Expand Down
14 changes: 12 additions & 2 deletions src/mono/mono/mini/method-to-ir.c
Original file line number Diff line number Diff line change
Expand Up @@ -6452,8 +6452,18 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
generic_context = &generic_container->context;
cfg->generic_context = generic_context;

if (!cfg->gshared)
g_assert (!sig->has_type_parameters);
if (!cfg->gshared) {
gboolean check_type_parameter = TRUE;
if (method->wrapper_type == MONO_WRAPPER_OTHER) {
WrapperInfo *info = mono_marshal_get_wrapper_info (method);
g_assert (info);
if (info->subtype == WRAPPER_SUBTYPE_UNSAFE_ACCESSOR)
check_type_parameter = FALSE;
}

if (check_type_parameter)
g_assert (!sig->has_type_parameters);
}

if (sig->generic_param_count && method->wrapper_type == MONO_WRAPPER_NONE) {
g_assert (method->is_inflated);
Expand Down

0 comments on commit c3a8740

Please sign in to comment.