[arm64_32] make "Debug Mode" work on Watch series 4 with --interpreter (mono/mono...
authorBernhard Urban <lewurm@gmail.com>
Tue, 17 Sep 2019 09:15:19 +0000 (11:15 +0200)
committermonojenkins <jo.shields+jenkins@xamarin.com>
Tue, 17 Sep 2019 09:15:19 +0000 (05:15 -0400)
commitd4c0136015d9b051b550f07828b89e2d12ecd4f3
tree68704e67760558ce94bf278521809300a755d743
parentd8be73f9f169427c1f7c57285b572677ee53260b
[arm64_32] make "Debug Mode" work on Watch series 4 with --interpreter (mono/mono#16865)

[arm64_32] make "Debug Mode" work on Watch series 4 with --interpreter

Main objective for reviewers: This PR shouldn't change anything for `arm64`.

Context: "Debug Mode" on the Apple Watch allows execution of regular machine code and thus is pretty similar to FullAOT on iPhone, i.e. it doesn't require bitcode, but _still_ doesn't allow `signal(3)` so cooperative suspend is required.

Apple Watch Series 4 and onward use an ARM64 chip, but with a different ABI, also known as `arm64_32`. This PR changes the AOT compiler and related trampolines so that the AOT compiler can generate all necessary code to run the interpreter on this target.

Changes:

--------------------------------------

[arm64_32] set register size to 8 in cross compiler too

-----------------------------------------

 [machine] update `target_mgreg_t` definition

`SIZEOF_REGISTER` is usually the same as `TARGET_SIZEOF_VOID_P`, except when `MONO_ARCH_ILP32 is defined.

`target_mgreg_t` should represent the width of the hardware register, that is, `SIZEOF_REGISTER`.

---------------------------------------------

[arm64_32] fix AOT image layout

---------------------------------------------

 [arm64_32] make trampolines bitwidth aware

* replace pointer loads/stores with bitwidth-dependent macro
* reflect `specific` trampolines so that only two instructions are used for ILP32, since the related pair in the data page only needs 2 * 32bits too
* replace some `sizeof (target_mgreg_t)` with `TARGET_SIZEOF_VOID_P` (former is hardware register size, latter is pointer size)

---------------------------------------------
These regression tests are _not_ passing: https://github.com/mono/mono/issues/16864 Also some of monotouch-tests are crashing, see https://github.com/mono/mono/issues/16819

Here is a screenshot of a debug session in VSMac:
<img width="1321" alt="Screenshot 2019-09-16 at 19 13 22" src="https://user-images.githubusercontent.com/75403/64981326-1dfbc000-d8bc-11e9-9d16-48036f36b638.png">

Contributes to https://github.com/mono/mono/issues/10641

Commit migrated from https://github.com/mono/mono/commit/578e1a9dda135516d51f00680939facbc63061ba
src/mono/configure.ac
src/mono/mono/arch/arm64/arm64-codegen.h
src/mono/mono/mini/aot-compiler.c
src/mono/mono/mini/image-writer.c
src/mono/mono/mini/tramp-arm64.c
src/mono/mono/utils/mono-machine.h