-
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 10 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 |
|---|---|---|
|
|
@@ -2948,12 +2948,12 @@ MonoMethod * | |
| mono_marshal_get_aot_init_wrapper (MonoAotInitSubtype subtype) | ||
| { | ||
| MonoMethodBuilder *mb; | ||
| const char *name = mono_marshal_get_aot_init_wrapper_name (subtype); | ||
| MonoMethod *res; | ||
| WrapperInfo *info; | ||
| MonoMethodSignature *csig = NULL; | ||
| MonoType *void_type = mono_get_void_type (); | ||
| MonoType *int_type = mono_get_int_type (); | ||
| const char *name = mono_marshal_get_aot_init_wrapper_name (subtype); | ||
|
|
||
| switch (subtype) { | ||
| case AOT_INIT_METHOD: | ||
|
|
@@ -2977,6 +2977,13 @@ mono_marshal_get_aot_init_wrapper (MonoAotInitSubtype subtype) | |
|
|
||
| mb = mono_mb_new (mono_defaults.object_class, name, MONO_WRAPPER_OTHER); | ||
|
|
||
| /* Uncomment when working on https://github.com/dotnet/runtime/issues/82224 */ | ||
| #ifdef ENABLE_WIP_METHOD_NOLLVM_SELF_INIT | ||
| #ifndef ENABLE_LLVM | ||
| get_marshal_cb ()->emit_method_init (mb); | ||
| #endif | ||
|
||
| #endif | ||
|
|
||
| // Just stub out the method with a "CEE_RET" | ||
| // Our codegen backend generates other code here | ||
| get_marshal_cb ()->emit_return (mb); | ||
|
|
||
| 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); | ||
|
Member
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) { | ||
|
|
@@ -3548,6 +3554,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: | ||
| * | ||
|
|
@@ -4015,6 +4027,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); | ||
|
|
@@ -4374,6 +4390,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 | ||
|
Member
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. you used to have an arm64 target check here (and also that LLVM was disabled). but now you don't. Do you need to enable |
||
| } | ||
| } | ||
|
|
||
|
|
@@ -5934,6 +5954,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); | ||
|
Contributor
Author
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. | ||
| */ | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.