-
Notifications
You must be signed in to change notification settings - Fork 5.2k
[DRAFT][mono][aot] Implementation of nollvm init method #89074
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
a6b88f9
c6fc40a
95a8470
03e1389
9140661
aad02cc
9976eaf
49dcf2e
1dbcc28
2bad646
0e4b036
00a9b41
f5eee3e
bfe9c5e
73537b5
cc43423
406e5bd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -152,6 +152,7 @@ struct MonoAotModule { | |
| guint8 *unwind_info; | ||
| /* Maps method index -> unbox tramp */ | ||
| gpointer *unbox_tramp_per_method; | ||
| MonoBitSet *mono_inited; | ||
|
|
||
| /* Points to the mono EH data created by LLVM */ | ||
| guint8 *mono_eh_frame; | ||
|
|
@@ -2237,6 +2238,11 @@ load_aot_module (MonoAssemblyLoadContext *alc, MonoAssembly *assembly, gpointer | |
| mscorlib_aot_module = amodule; | ||
| } | ||
|
|
||
| /* | ||
| * Methods init bitset used for initialization during the runtime | ||
| */ | ||
| amodule->mono_inited = mono_bitset_new (amodule->info.nmethods, 0); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As we discussed offline, would be good to think of memory leaks. Is it allocated within the mempool? |
||
|
|
||
| /* Compute method addresses */ | ||
| amodule->methods = (void **)g_malloc0 (amodule->info.nmethods * sizeof (gpointer)); | ||
| for (guint32 i = 0; i < amodule->info.nmethods; ++i) { | ||
|
|
@@ -3546,6 +3552,12 @@ sort_methods (MonoAotModule *amodule) | |
| g_free (method_indexes); | ||
| } | ||
|
|
||
| MonoBitSet* | ||
| mono_aot_get_mono_inited (MonoAotModule *amodule) | ||
| { | ||
| return amodule->mono_inited; | ||
| } | ||
|
|
||
| /* | ||
| * mono_aot_find_jit_info: | ||
| * | ||
|
|
@@ -4013,6 +4025,10 @@ decode_patch (MonoAotModule *aot_module, MonoMemPool *mp, MonoJumpInfo *ji, guin | |
| case MONO_PATCH_INFO_AOT_MODULE: | ||
| case MONO_PATCH_INFO_MSCORLIB_GOT_ADDR: | ||
| break; | ||
| case MONO_PATCH_INFO_INIT_BITSET: { | ||
| ji->data.target = aot_module->mono_inited; | ||
| break; | ||
| } | ||
| case MONO_PATCH_INFO_SIGNATURE: | ||
| case MONO_PATCH_INFO_GSHAREDVT_IN_WRAPPER: | ||
| ji->data.target = decode_signature (aot_module, p, &p); | ||
|
|
@@ -4372,6 +4388,10 @@ load_method (MonoAotModule *amodule, MonoImage *image, MonoMethod *method, guint | |
| res = init_method (amodule, NULL, method_index, method, NULL, error); | ||
| if (!res) | ||
| goto cleanup; | ||
| #ifdef ENABLE_WIP_METHOD_NOLLVM_SELF_INIT | ||
| else | ||
| mono_bitset_set (mono_aot_get_mono_inited (amodule), method_index); | ||
| #endif | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -5932,6 +5952,20 @@ no_specific_trampoline (void) | |
| g_assert_not_reached (); | ||
| } | ||
|
|
||
| void | ||
| mini_nollvm_init_method (MonoAotModule* amodule, guint32 method_index) | ||
| { | ||
| MonoBitSet *inited_bitset = mono_aot_get_mono_inited (amodule); | ||
|
|
||
| ERROR_DECL (error); | ||
| if (!mono_bitset_test (inited_bitset, method_index)) { | ||
| if (init_method (amodule, NULL, method_index, NULL, NULL, error)) { | ||
| mono_bitset_set (inited_bitset, method_index); | ||
| } | ||
| } | ||
| mono_error_assert_ok (error); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @vargaz do we want to propagate this error? |
||
| } | ||
|
|
||
| /* | ||
| * Return a specific trampoline from the AOT file. | ||
| */ | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -5990,6 +5990,15 @@ mono_arch_emit_prolog (MonoCompile *cfg) | |||
| code = emit_addx_imm (code, cfg->arch.args_reg, ARMREG_FP, cfg->stack_offset); | ||||
| } | ||||
|
|
||||
| /* Call the init wrapper which checks if the method needs to be initialised or not */ | ||||
| /* https://github.com/dotnet/runtime/pull/82711, https://github.com/dotnet/runtime/issues/83378, https://github.com/dotnet/runtime/issues/83379 */ | ||||
| #ifdef ENABLE_WIP_METHOD_NOLLVM_SELF_INIT | ||||
| if (cfg->compile_aot && !COMPILE_LLVM (cfg)) { | ||||
| code = emit_imm (code, ARMREG_R0, cfg->method_index); | ||||
| code = emit_call (cfg, code, MONO_PATCH_INFO_METHOD, (gconstpointer) mono_marshal_get_aot_init_wrapper (AOT_INIT_METHOD)); | ||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not sure if this is a correct way to invoke wrappers generated in: runtime/src/mono/mono/mini/aot-compiler.c Line 4470 in 6229f5f
During the native linking, there is an undefined symbols for architecture arm64: I think it comes from method prolog trying to invoke the init wrapper, but I would expect invocation of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. FWIW, I am not 100% how this should work but I think the body of |
||||
| } | ||||
| #endif | ||||
|
|
||||
| /* Save return area addr received in R8 */ | ||||
| if (cfg->vret_addr) { | ||||
| MonoInst *ins = cfg->vret_addr; | ||||
|
|
||||
Uh oh!
There was an error while loading. Please reload this page.