eclipse-openj9 / openj9

Eclipse OpenJ9: A Java Virtual Machine for OpenJDK that's optimized for small footprint, fast start-up, and high throughput. Builds on Eclipse OMR (https://github.com/eclipse/omr) and combines with the Extensions for OpenJDK for OpenJ9 repo.
Other
3.27k stars 721 forks source link

Enable Symbol Validation Manager on all platforms #3028

Open dsouzai opened 5 years ago

dsouzai commented 5 years ago
dsouzai commented 5 years ago

I've started working on cleaning up the AOT infrastructure (https://github.com/eclipse/openj9/issues/3031) . I decided not to work on getting support for other platforms first, because it would end up being a bunch of extra work for me to add the relocations only for them to get cleaned up. Additionally, it will take me some time (since I'm not really familiar with any of the codegens). Thus the plan is to clean up the infrastructure, and once there's a single canonical version of the AOT infrastructure, I can start to take a look at the other platforms.

That said, if anyone wishes to work on the other platforms, this is what's needed (at least what I can think of):

  1. The code that writes the Relocation Header needs to be copied over to J9AheadOfTimeCompile (https://github.com/eclipse/openj9/pull/2919/commits/b9efceb36e19e9b8bfe8d9183c1c163dd01d86ac#diff-3f1aba0052032c44a8f47c99b97e30e2)

  2. Initially disable string peepholes (https://github.com/eclipse/openj9/pull/2919/commits/97b11cc58100a86cf4886c3316891ea7b7d0900c)

  3. Do not remove the devirtualized check (https://github.com/eclipse/openj9/pull/2919/commits/c4be204565658d0219d540005d5623d9dedcf07f#diff-bc6d5bca24d2675b48424ae7ce17bb9c)

  4. Enable Abstrct Method Inlining (https://github.com/eclipse/omr/pull/2978/commits/2347110d9559740fc3195d340e871898e3cb2d52)

  5. Intially disable the code added in https://github.com/eclipse/omr/pull/3074

  6. When using the symbol validation manager, for AOT compiles, the compiler thinks all methods are interpreted. Therefore, when the method is also resolved, a resolved interpreter call snippet is generated. However, if this code is guarded with forceUnresolvedDispatch then that guard needs to be removed (https://github.com/eclipse/openj9/pull/2919/commits/c4be204565658d0219d540005d5623d9dedcf07f#diff-6f742cfd99927bbd8a989b86c42da43e)

  7. Because with the symbol validation manager more things are resolved (including new), object allocation inlining needs to account for the fact that the loadaddr is no longer anchored by a resolvechk. (https://github.com/eclipse/openj9/pull/2919/commits/c4be204565658d0219d540005d5623d9dedcf07f#diff-11e7eccbbf8ec3cf2e4f26d5b7357efe) . Also, you need to make sure you add the relocation for the object allocation inlining as done here https://github.com/eclipse/openj9/pull/2919/commits/b9efceb36e19e9b8bfe8d9183c1c163dd01d86ac#diff-11e7eccbbf8ec3cf2e4f26d5b7357efeR7710

  8. Update relocations for RamMethod, MethodPointer, ClassAddress, and ClassPointer to get the symbol from the SVM rather than through the cpIndex (https://github.com/eclipse/omr/pull/2978/commits/34f7416180295904e6a0e3ec051eb0c713857b19 and https://github.com/eclipse/omr/pull/2978/commits/1520ed098d17ca76238e9a9fc0591f22d41f98cd)

  9. Enable 2 and 5

  10. Enable CheckCast and InstanceOf inlining (https://github.com/eclipse/openj9/pull/2919/commits/b4604318ec47dac64677abff6c80bd34c57c7518)

Initially, run with disabling object allocation inlining and disabling checkcast and instanceof inlining via cmd line options. Once 7 is done, you can enable object allocation inlining. One 10 is done, you can enable checkcast and instanceof inlining. When running, make sure you only add enableSymbolValidationManager to the -Xaot options.

I would also comment out https://github.com/eclipse/openj9/blob/d762f281be4546b8ecefd2a46cccb9be32a5b20e/runtime/compiler/control/CompilationThread.cpp#L7426-L7429 as it will ensure that the new AOT gets used also during startup.

Fyi @gita-omr @fjeremic