[code-reflection] RFR: Testing BytecodeLift and BytecodeGenerator roundtrip stability

Adam Sotona asotona at openjdk.org
Thu Feb 15 08:54:19 UTC 2024


Hi,
I've added `TestLiftSmallCorpus::testDoubleRoundtripStability` to test stability of the `BytecodeLift` and `BytecodeGenerator` roundtrip on JDK classes (aka "Small Corpus"). 

The test takes ~40k methods from JDK classes and tries to lift them from bytecode, generate, lift again and generate again. Only about 4300 methods pass the roundtrip now, because `BytecodeLift` and `BytecodeGenerator` are still under construction.

The test then compares "normalized" bytecode from the first round and the second round and fails with printed details if differ. The test actually contains a non-zero error threshold before failure. This threshold can be manually adjusted when working on `BytecodeLift` and `BytecodeGenerator` improvements.
This approach allows to incrementally fix `BytecodeLift` and `BytecodeGenerator` roundtrip, as well as to extend their coverage.

This patch also includes several fixes of bugs discovered during work on `TestLiftSmallCorpus`:
- conditional branches are unwound to avoid growing number of blocks during the round trip
- conditional branches are inverted to fix roundtrip stability
- partial fix of block parameters construction
- partial fix of the locals overrides

Partial fix means it significantly reduced the error threshold (in order of magnitudes), however there are still some cases failing.

I would like to integrate this patch, because it introduces a tool to allow subsequent incremental progress.

Please review.

Thank you,
Adam

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

Commit messages:
 - Update TestSimple.java
 - work in progress
 - Merge branch 'code-reflection' into bytecode-small-corpus-tests
 - work in progress
 - work in progress
 - work in progress
 - work in progress
 - inversed conditional branches
 - unwound redundant conditional double-jumps in BytecodeGenerator
 - work in progress
 - ... and 2 more: https://git.openjdk.org/babylon/compare/75cc28c1...c50f521e

Changes: https://git.openjdk.org/babylon/pull/24/files
 Webrev: https://webrevs.openjdk.org/?repo=babylon&pr=24&range=00
  Stats: 336 lines in 5 files changed: 264 ins; 37 del; 35 mod
  Patch: https://git.openjdk.org/babylon/pull/24.diff
  Fetch: git fetch https://git.openjdk.org/babylon.git pull/24/head:pull/24

PR: https://git.openjdk.org/babylon/pull/24


More information about the babylon-dev mailing list