From 9c89c293340ca8c3fdcfb2738438c54923ad679c Mon Sep 17 00:00:00 2001 From: Zoltan Varga Date: Sat, 14 Jan 2023 05:36:26 -0500 Subject: [PATCH] [mono][wasm] Avoid emitting the eh info table, its not used on wasm. --- src/mono/mono/mini/aot-compiler.c | 20 ++++++++++++------ src/mono/mono/mini/aot-runtime.c | 34 +++++++++++++++++++++++-------- 2 files changed, 40 insertions(+), 14 deletions(-) diff --git a/src/mono/mono/mini/aot-compiler.c b/src/mono/mono/mini/aot-compiler.c index 55a1f05f7ca605..8a608d63f1633c 100644 --- a/src/mono/mono/mini/aot-compiler.c +++ b/src/mono/mono/mini/aot-compiler.c @@ -7224,7 +7224,7 @@ emit_exception_debug_info (MonoAotCompile *acfg, MonoCompile *cfg, gboolean stor code = cfg->native_code; header = cfg->header; - if (!acfg->aot_opts.nodebug) { + if (!acfg->aot_opts.nodebug && !acfg->aot_opts.llvm_only) { mono_debug_serialize_debug_info (cfg, &debug_info, &debug_info_size); } else { debug_info = NULL; @@ -7245,7 +7245,6 @@ emit_exception_debug_info (MonoAotCompile *acfg, MonoCompile *cfg, gboolean stor use_unwind_ops = cfg->unwind_ops != NULL; flags = (jinfo->has_generic_jit_info ? 1 : 0) | (use_unwind_ops ? 2 : 0) | (header->num_clauses ? 4 : 0) | (seq_points_size ? 8 : 0) | (cfg->compile_llvm ? 16 : 0) | (jinfo->has_try_block_holes ? 32 : 0) | (cfg->gc_map ? 64 : 0) | (jinfo->has_arch_eh_info ? 128 : 0); - encode_value (flags, p, &p); if (use_unwind_ops) { @@ -7279,7 +7278,9 @@ emit_exception_debug_info (MonoAotCompile *acfg, MonoCompile *cfg, gboolean stor } /* Exception table */ - if (cfg->compile_llvm) { + if (cfg->llvm_only) { + /* Unused */ + } else if (cfg->compile_llvm) { /* * When using LLVM, we can't emit some data, like pc offsets, this reg/offset etc., * since the information is only available to llc. Instead, we let llc save the data @@ -7470,8 +7471,10 @@ emit_exception_debug_info (MonoAotCompile *acfg, MonoCompile *cfg, gboolean stor g_assert (p - buf < buf_size); /* Emit info */ - /* The GC Map requires 4 byte alignment */ - cfg->ex_info_offset = add_to_blob_aligned (acfg, buf, GPTRDIFF_TO_UINT32 (p - buf), cfg->gc_map ? 4 : 1); + if (!cfg->llvm_only) { + /* The GC Map requires 4 byte alignment */ + cfg->ex_info_offset = add_to_blob_aligned (acfg, buf, GPTRDIFF_TO_UINT32 (p - buf), cfg->gc_map ? 4 : 1); + } g_free (buf); } @@ -11145,7 +11148,12 @@ emit_exception_info (MonoAotCompile *acfg) g_free (aot_file_path); } - acfg->stats.offsets_size += emit_offset_table (acfg, "ex_info_offsets", MONO_AOT_TABLE_EX_INFO_OFFSETS, acfg->nmethods, 10, offsets); + if (mono_llvm_only) { + /* Unused */ + emit_aot_data (acfg, MONO_AOT_TABLE_EX_INFO_OFFSETS, "ex_info_offsets", NULL, 0); + } else { + acfg->stats.offsets_size += emit_offset_table (acfg, "ex_info_offsets", MONO_AOT_TABLE_EX_INFO_OFFSETS, acfg->nmethods, 10, offsets); + } g_free (offsets); } diff --git a/src/mono/mono/mini/aot-runtime.c b/src/mono/mono/mini/aot-runtime.c index cb502f8a0ee390..fd4fb5d7c5aee8 100644 --- a/src/mono/mono/mini/aot-runtime.c +++ b/src/mono/mono/mini/aot-runtime.c @@ -3049,16 +3049,19 @@ decode_exception_debug_info (MonoAotModule *amodule, } /* Exception table */ - if (has_clauses) - num_clauses = decode_value (p, &p); - else - num_clauses = 0; - - if (from_llvm) { + if (mono_llvm_only) { + /* Handled by the caller */ + g_assert_not_reached (); + } else if (from_llvm) { int len; MonoJitExceptionInfo *clauses; GSList **nesting; + if (has_clauses) + num_clauses = decode_value (p, &p); + else + num_clauses = 0; + /* * Part of the info is encoded by the AOT compiler, the rest is in the .eh_frame * section. @@ -3134,6 +3137,11 @@ decode_exception_debug_info (MonoAotModule *amodule, } jinfo->from_llvm = 1; } else { + if (has_clauses) + num_clauses = decode_value (p, &p); + else + num_clauses = 0; + int len = mono_jit_info_size (flags, num_clauses, num_holes); jinfo = (MonoJitInfo *)alloc0_jit_info_data (mem_manager, len, async); /* The jit info table needs to sort addresses so it contains non-authenticated pointers on arm64e */ @@ -3551,7 +3559,10 @@ mono_aot_find_jit_info (MonoImage *image, gpointer addr) } code = (guint8 *)amodule->methods [method_index]; - ex_info = &amodule->blob [mono_aot_get_offset (amodule->ex_info_offsets, method_index)]; + if (mono_llvm_only) + ex_info = NULL; + else + 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 */ @@ -3635,7 +3646,14 @@ mono_aot_find_jit_info (MonoImage *image, gpointer addr) //printf ("F: %s\n", mono_method_full_name (method, TRUE)); - jinfo = decode_exception_debug_info (amodule, method, ex_info, code, GPTRDIFF_TO_UINT32 (code_len)); + if (mono_llvm_only) { + /* Unused */ + int len = mono_jit_info_size (0, 0, 0); + jinfo = (MonoJitInfo *)alloc0_jit_info_data (mem_manager, len, async); + mono_jit_info_init (jinfo, method, code, code_len, 0, 0, 0); + } else { + jinfo = decode_exception_debug_info (amodule, method, ex_info, code, GPTRDIFF_TO_UINT32 (code_len)); + } g_assert ((guint8*)addr >= (guint8*)jinfo->code_start);