Skip to content
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

[2018-04] unbreak interp-only mode in Xamarin.iOS #9266

Merged
merged 4 commits into from
Jun 25, 2018

Conversation

lewurm
Copy link
Contributor

@lewurm lewurm commented Jun 22, 2018

Context: xamarin/xamarin-macios#3856 (comment)

This PR

  • backports [interp] fullAOT mixed mode #8838 (already exists on master and 2018-06)
  • fixes an AOT compiler regression for interp support due to 67e995c (this needs to be forward ported to master and 2018-06)
  • adding two workarounds to force interp-only execution. This is fine for this branch, because we aren't there yet regarding mixed mode execution, but I need to work on a better solution for master/2018-06.

Once approved, I'm going to propagate fixes to the other branches.

lewurm and others added 4 commits June 21, 2018 22:36
* [jit] Move the handling of special methods like pinvoke etc. into mini-runtime.c, since they are not handled by the JIT.

* [jit] Add a --full-aot-interp command line argument which is the same as --full-aot with a fallback to the interpreter.

* [jit] Implement fallback to the interpreter in full-aot+interp mode.

* [jit] Add a 'methods using the interpreter' stat.
…ges broke them. we need to fix it properly on master
@lewurm lewurm added this to the 2018-04 (5.14.xx) milestone Jun 22, 2018
@lewurm lewurm requested a review from vargaz June 22, 2018 13:10
@@ -4329,7 +4329,8 @@ init_method (MonoAotModule *amodule, guint32 method_index, MonoMethod *method, M
} else {
llvm = TRUE;
got = amodule->llvm_got;
g_assert (got);
if (!got)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this needed ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With mixed mode logic we try to load AOT methods first; the AOT runtime tries to initialize methods from the AOT image, but fails because the requested method isn't available in the AOT image. Failing gracefully we allow the mini-runtime to try another execution engine (i.e. interp). Here's the native stack trace:

(lldb) mbt
* thread #1
    frame #0: 0x000000018173d2ec libsystem_kernel.dylib`__pthread_kill + 8
    frame #1: 0x00000001818de288 libsystem_pthread.dylib`pthread_kill$VARIANT$mp + 376
    frame #2: 0x00000001816abd0c libsystem_c.dylib`abort + 140
    frame #3: 0x0000000100baa584 nsarrayfilter`mono_log_write_asl(log_domain=0x0000000000000000, level=G_LOG_LEVEL_ERROR, hdr=0, message="* Assertion at ../../../../../mono/mini/aot-runtime.c:4333, condition `got' not met\n") at mono-log-darwin.c:41
    frame #4: 0x0000000100bab16c nsarrayfilter`structured_log_adapter(log_domain=0x0000000000000000, log_level=G_LOG_LEVEL_ERROR, message="* Assertion at ../../../../../mono/mini/aot-runtime.c:4333, condition `got' not met\n", user_data=0x0000000000000000) at mono-logger.c:458
    frame #5: 0x0000000100bc32b4 nsarrayfilter`monoeg_g_logv(log_domain=0x0000000000000000, log_level=G_LOG_LEVEL_ERROR, format="* Assertion at %s:%d, condition `%s' not met\n", args="��") at goutput.c:115
    frame #6: 0x0000000100bc33e0 nsarrayfilter`monoeg_assertion_message(format="* Assertion at %s:%d, condition `%s' not met\n") at goutput.c:146
  * frame #7: 0x000000010099c068 nsarrayfilter`init_method(amodule=0x000000010180b400, method_index=1034, method=0x000000010181a128, init_class=0x0000000000000000, context=0x0000000000000000, error=0x000000016f492eb0) at aot-runtime.c:4333
    frame #8: 0x00000001009939c8 nsarrayfilter`load_method(domain=0x0000000100f009a0, amodule=0x000000010180b400, image=0x0000000101806000, method=0x000000010181a128, token=100664331, method_index=1034, error=0x000000016f492eb0) at aot-runtime.c:4056
    frame #9: 0x00000001009933ec nsarrayfilter`mono_aot_get_method(domain=0x0000000100f009a0, method=0x000000010181a128, error=0x000000016f492eb0) at aot-runtime.c:4767
    frame #10: 0x00000001009e2b9c nsarrayfilter`mono_jit_compile_method_with_opt(method=0x000000010181a128, opt=374417919, jit_only=0, error=0x000000016f492eb0) at mini-runtime.c:2343
    frame #11: 0x00000001009e25c0 nsarrayfilter`mono_jit_compile_method(method=0x000000010181a128, error=0x000000016f492eb0) at mini-runtime.c:2440
    frame #12: 0x00000001009e565c nsarrayfilter`mono_jit_runtime_invoke(method=0x000000010181a128, obj=0x0000000101200048, params=0x000000016f492dd8, exc=0x0000000000000000, error=0x000000016f492eb0) at mini-runtime.c:2954
    frame #13: 0x0000000100aa62f4 nsarrayfilter`do_runtime_invoke(method=0x000000010181a128, obj=0x0000000101200048, params=0x000000016f492dd8, exc=0x0000000000000000, error=0x000000016f492eb0) at object.c:2942
    frame #14: 0x0000000100aa1018 nsarrayfilter`mono_runtime_invoke_checked(method=0x000000010181a128, obj=0x0000000101200048, params=0x000000016f492dd8, error=0x000000016f492eb0) at object.c:3095
    frame #15: 0x0000000100a3a968 nsarrayfilter`create_exception_two_strings(klass=0x0000000101819990, a1=0x0000000101200018, a2=0x0000000000000000, error=0x000000016f492eb0) at exception.c:222
    frame #16: 0x0000000100a3a780 nsarrayfilter`mono_exception_from_name_two_strings_checked(image=0x0000000101806000, name_space="System", name="OutOfMemoryException", a1=0x0000000101200018, a2=0x0000000000000000, error=0x000000016f492eb0) at exception.c:278
    frame #17: 0x00000001009f6c60 nsarrayfilter`create_domain_objects(domain=0x0000000100f009a0) at appdomain.c:209
    frame #18: 0x00000001009f6250 nsarrayfilter`mono_runtime_init_checked(domain=0x0000000100f009a0, start_cb=(nsarrayfilter`mono_thread_start_cb at mini-runtime.c:949), attach_cb=(nsarrayfilter`mono_thread_attach_cb at mini-runtime.c:972), error=0x000000016f493158) at appdomain.c:304
    frame #19: 0x00000001009e4f60 nsarrayfilter`mini_init(filename="MonoTouch", runtime_version="mobile") at mini-runtime.c:4363
    frame #20: 0x00000001009bf1a8 nsarrayfilter`mono_jit_init_version(domain_name="MonoTouch", runtime_version="mobile") at driver.g.c:2590
    frame #21: 0x0000000100bd16a8 nsarrayfilter`::xamarin_main(argc=<unavailable>, argv=<unavailable>, launch_mode=<unavailable>) at monotouch-main.m:421 [opt]
    frame #22: 0x0000000100971d88 nsarrayfilter`main(argc=1, argv=0x000000016f493b38) at main.m:45
    frame #23: 0x000000018160dfc0 libdyld.dylib`start + 4
(lldb) p amodule->aot_name
(char *) $6 = 0x00000001c0017a00 "mscorlib"
(lldb) p method->name
(const char *) $4 = 0x000000010131ff0d ".ctor"

However, for 2018-04, with the workarounds in 8ae79f2 this wouldn't be needed anymore. But we are going to need it in master (#9295 )

monojenkins pushed a commit that referenced this pull request Jul 9, 2018
[mini] make interp work with AOT image generated with aot=interp

[aot-compiler] use mono_aot_mode_is_interp instead of directly using the flag

---------
[interp] add FULL_AOT flags to AOT image when `--aot=interp` is used

fixes regression from 67e995c

---------
partial forward port of #9266

needs backporting to `2018-06`
picenka21 pushed a commit to picenka21/runtime that referenced this pull request Feb 18, 2022
…o/mono#9295)

[mini] make interp work with AOT image generated with aot=interp

[aot-compiler] use mono_aot_mode_is_interp instead of directly using the flag

---------
[interp] add FULL_AOT flags to AOT image when `--aot=interp` is used

fixes regression from mono/mono@67e995c

---------
partial forward port of mono/mono#9266

needs backporting to `2018-06`



Commit migrated from mono/mono@6062fa3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants