From a949686ee7f18ecf2020025d62caf7aa7ccf834d Mon Sep 17 00:00:00 2001 From: monojenkins Date: Tue, 18 Aug 2020 14:24:07 -0400 Subject: [PATCH] [aot] Fix the lookup of jit info for WASM. On wasm, methods have no size, so only the method address can be looked up, jinfo->code_size is set to 1. (#40969) Fixes https://github.com/mono/mono/issues/20256. Co-authored-by: vargaz --- src/mono/mono/mini/aot-runtime.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/mono/mono/mini/aot-runtime.c b/src/mono/mono/mini/aot-runtime.c index 371cbe7..27d27ad 100644 --- a/src/mono/mono/mini/aot-runtime.c +++ b/src/mono/mono/mini/aot-runtime.c @@ -3691,10 +3691,14 @@ mono_aot_find_jit_info (MonoDomain *domain, MonoImage *image, gpointer addr) code1 = (guint8 *)methods [pos]; if (pos + 1 == methods_len) { +#ifdef HOST_WASM + code2 = code1 + 1; +#else if (code1 >= amodule->jit_code_start && code1 < amodule->jit_code_end) code2 = amodule->jit_code_end; else code2 = amodule->llvm_code_end; +#endif } else { code2 = (guint8 *)methods [pos + 1]; } @@ -3707,6 +3711,11 @@ mono_aot_find_jit_info (MonoDomain *domain, MonoImage *image, gpointer addr) break; } +#ifdef HOST_WASM + if (addr != methods [pos]) + return NULL; +#endif + g_assert (addr >= methods [pos]); if (pos + 1 < methods_len) g_assert (addr < methods [pos + 1]); @@ -3729,6 +3738,10 @@ mono_aot_find_jit_info (MonoDomain *domain, MonoImage *image, gpointer addr) code = (guint8 *)amodule->methods [method_index]; ex_info = &amodule->blob [mono_aot_get_offset (amodule->ex_info_offsets, method_index)]; +#ifdef HOST_WASM + /* WASM methods have no length, can only look up the method address */ + code_len = 1; +#else if (pos == methods_len - 1) { if (code >= amodule->jit_code_start && code < amodule->jit_code_end) code_len = amodule->jit_code_end - code; @@ -3737,6 +3750,7 @@ mono_aot_find_jit_info (MonoDomain *domain, MonoImage *image, gpointer addr) } else { code_len = (guint8*)methods [pos + 1] - (guint8*)methods [pos]; } +#endif g_assert ((guint8*)code <= (guint8*)addr && (guint8*)addr < (guint8*)code + code_len); -- 2.7.4