Skip to content

[DO NOT MERGE] Source compiler#1200

Draft
andreaTP wants to merge 36 commits intodylibso:mainfrom
andreaTP:source-compiler-wip
Draft

[DO NOT MERGE] Source compiler#1200
andreaTP wants to merge 36 commits intodylibso:mainfrom
andreaTP:source-compiler-wip

Conversation

@andreaTP
Copy link
Copy Markdown
Collaborator

Opening just for visibility, do not merge, this is debugging work done for:

People from the JDK are asking for a .java sources reproducer.
With the help of LLM and re-using most of the instruments we have in this repository(test-gen etc.), we built a compiler to Java sources(in source-compiler) it already passes 25K tests from the testsuite and all the wasi tests too.
It has been used to generate the source compiled Machine of Wat2Wasm in decompiled-wabt(it's actually compiled, not de-compiled 😅 all decompiler failed on the .class files).

This produces a blob of 11Mb of Java source code file that does reproduce the JDK issue.
Hopefully we get it fixed sometime soon.

For the curious, porting highlights:

  • hooking up the testsuite as soon as possible was a blessing
  • being able to continuously monitor the results(source-dump) of the generated code was great for both LLM and me
  • LLM is really good at following patterns and doing the ground mechanical work, such as porting opcodes
  • the control flow(labels + goto) we are using in the compiler cannot be expressed in Java source code, it took a bit of time and steering to get it right
  • in Java sources we are hitting limitations much earlier than in bytecode, so we had to implement method splitting, it kinda of works but took long and is just patches on patches

Despite the high coverage of testsuite tests we don't want to maintain this code, I see no use cases where generating sources would be better than generating .class files apart from hard core debugging.
I'm opening this PR just for tracking purposes and to share what's possible.

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.

1 participant