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.28k stars 720 forks source link

Enable ILValidator in OpenJ9 #8758

Open PushkarBettadpur opened 4 years ago

PushkarBettadpur commented 4 years ago

Currently, running OpenJ9 with the JIT option useIlValidator, assert fails with the following message: "Attempting to validate the IL without the ILValidator being initialized".

ILValidator is initialized in OMR in IlInjector::genIL(), however, we don't use IlInjector in OpenJ9. Further, the corresponding genIL() method in OpenJ9 does not initialize ILValidator.

It would be worthwhile to initialize ILValidator in OpenJ9 for debugging purposes and to avoid new (fix existing) type issues when generating nodes.

andrewcraik commented 4 years ago

The OMR IL Validator fails on OpenJ9 trees at present. Part of this is because of some ilformed trees that OpenJ9 relies on and, in some cases, because of limitations in the verifier that need to be handled. There are two tree verifiers - a legacy verifier (which is what OpenJ9 currently runs) and the newer, more complete and extensible verifier added to OMR by @Leonardo2718 et al and which is expected to replace the legacy verifier once the issues with verification are sorted.

While it sounds trivial to say 'well fix the ilformed trees in OpenJ9' changing the tree patterns can have a massive impact on the code gen tree evaluation across platforms as well as the optimizer (since it can look for tree patterns as part of what it is doing). That isn't to say we shouldn't tackle this, but one should not under estimate the size and complexity of the undertaking.

What were you trying to validate with the new validator that the old validator doesn't support?

PushkarBettadpur commented 4 years ago

What were you trying to validate with the new validator that the old validator doesn't support?

I was running into errors while making some changes to the IL Gen phase of compilation. On eyeballing the generated trees with @fjeremic, we spotted that some aladd nodes did not have their children with the right type (or in the right order). Using the paranoidOptCheck option doesn't work as it is guarded by useIlValidator which in turn, gives us the assert failure described above when turned on.

two tree verifiers - a legacy verifier (which is what OpenJ9 currently runs)

Is there an option or a way to trigger this legacy verifier while debugging? I'm assuming these are different to paranoidOptCheck and/or useIlValidator?

Leonardo2718 commented 4 years ago

@PushkarBettadpur

Is there an option or a way to trigger this legacy verifier while debugging? I'm assuming these are different to paranoidOptCheck and/or useIlValidator?

paranoidOptCheck just causes several validations to be run between each optimization. useIlValidator forces the JIT to use the new IlValidator because the legacy verifier is used by default. However, you have to be running a debug build of the JIT, define the TR_DEBUG="checkTypes=1" environment variable, and be generating a log file in order for the old verifier to actually report errors. For example TR_DEBUG="checkTypes=1" java -XXjitdirectory=$JITDIR -Xjit:paranoidOptCheck,log=trtrace.log -version (this breaks on my system BTW).

Also, FWIW, see https://github.com/eclipse/openj9/issues/277 and https://github.com/eclipse/openj9/issues/447 for more context on the problems with the new validator.