Skip to content

Commit

Permalink
[aot] use unbox arbitrary trampolines for "slim" mscorlib (mono/mono#…
Browse files Browse the repository at this point in the history
…13139)

We need the recently introduced "unbox arbitrary" trampolines in one more
scenario: non-mscorlib AOT code calls a method from mscorlib with
interpreter. Before we just relied on the amodule not being available,
but mscorlib amodule is always present due to wrappers, trampolines,
etc.

Commit migrated from mono/mono@49b6628
  • Loading branch information
luhenry authored Feb 22, 2019
2 parents 0779407 + 9d20ae7 commit 3c61028
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/mono/mono/mini/aot-runtime.c
Original file line number Diff line number Diff line change
Expand Up @@ -5883,6 +5883,20 @@ i16_idx_comparer (const void *key, const void *member)
return idx1 - idx2;
}

static gboolean
aot_is_slim_amodule (MonoAotModule *amodule)
{
if (!amodule)
return FALSE;

/* "slim" only applies to mscorlib.dll */
if (strcmp (amodule->aot_name, "mscorlib"))
return FALSE;

guint32 f = amodule->info.flags;
return (f & MONO_AOT_FILE_FLAG_INTERP) && !(f & MONO_AOT_FILE_FLAG_FULL_AOT);
}

gpointer
mono_aot_get_unbox_trampoline (MonoMethod *method, gpointer addr)
{
Expand Down Expand Up @@ -5910,7 +5924,7 @@ mono_aot_get_unbox_trampoline (MonoMethod *method, gpointer addr)
} else
amodule = m_class_get_image (method->klass)->aot_module;

if (amodule == NULL || method_index == 0xffffff) {
if (amodule == NULL || method_index == 0xffffff || aot_is_slim_amodule (amodule)) {
/* couldn't find unbox trampoline specifically generated for that
* method. this should only happen when an unbox trampoline is needed
* for `fullAOT code -> native-to-interp -> interp` transition if
Expand Down

0 comments on commit 3c61028

Please sign in to comment.