Skip to content

Remove abandoned binary AST generation and persistence - #692

Merged
lagergren merged 5 commits into
masterfrom
errs/remove-binary-ast-20261012
Oct 12, 2026
Merged

lagergren merged 5 commits into
masterfrom
errs/remove-binary-ast-20261012

Conversation

@lagergren

@lagergren lagergren commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Why?

  • The abandoned binary AST implementation still makes the compiler generate and persist a second representation alongside executable bytecode.
  • Its incomplete emission paths can reject otherwise valid source even though the interpreter and current Java JIT consume bytecode.
  • Removing it avoids maintaining an unused representation while preserving the compiler source AST used for compilation and tooling.

How?

  • Delete all 53 binary AST classes and remove their generation, constant-registration, cache and serialization plumbing.
  • Keep executable bytecode, compiler source ASTs, source information and the existing interpreter/JIT paths.
  • Remove the former metadata slot completely and advance the .xtc format to 0.20261012. Executable instructions are followed immediately by source information.

Implications

This is an independent PR against current master, including the already merged Gradle compiler-model export. It needs none of the pending embedding or LSP changes. The diff touches 128 files (+697/−8317); most changes remove binary AST generation interleaved with existing bytecode generation.

The removed Java org.xvm.asm.ast classes and associated accessors are intentionally no longer available. No active repository runtime, JIT or lang consumer uses them. This does not remove the compiler's org.xvm.compiler.ast model or the syntax/semantic model needed by the compiler-backed LSP.

This intentionally changes the binary file format. Existing .xtc modules must be rebuilt with the new compiler, and the runtime and modules must use matching formats. There is no legacy skip/write-zero compatibility shim. Real artifact checks verify that new bytecode executes and that both old-reader/new-file and new-reader/old-file combinations fail explicitly with an unsupported-version error, before method records are interpreted.

Changes

  • javatools/src/main/java/org/xvm/asm/ast/: remove the abandoned binary AST implementation.
  • Compiler expressions/statements and supporting ASM classes: remove only the associated producer, register and cache machinery.
  • javatools/src/main/java/org/xvm/asm/MethodStructure.java: persist executable method code and source information directly, with no discarded metadata slot. The forced-assembly path no longer writes the temporary registry field.
  • javatools/src/test/java/org/xvm/asm/MethodCodePersistenceTest.java: four regressions covering record boundaries, the exact emitted record layout, source/code round trips through normal and forced assembly, and early rejection of the previous file version.
  • version.properties: update the format version consumed by FileStructure through generated build information.
  • Address the review's direct returns, switch expression, loop-bound scoping, stale comments and leftover spacing.
  • Use consistent lValues/lValuesAll names in assignment-related AST nodes, including the reflective child-field metadata; compact the loop-label constants and debugger parameter-array declarations.
  • Add conservative Spotless rules for orphaned local padding and blank lines before bare control transfers or else. Rollout is explicitly limited to the 67 Java files already touched by this removal, listed in gradle/java-layout-files.txt; only 27 needed automatic formatting. No repository-wide whitespace rewrite is included. Literal/comment preservation and idempotence have regression coverage.
  • Remove stale comments and TODO text referring to the abandoned implementation.

Known follow-ups

The integration follow-up is complete in the eight prepared compiler/LSP integration and comparison branches. Atomic regressions now execute serialized bytecode and check results and receiver mutations; switch checks inspect executable instructions; partial-analysis checks assert that no executable operations were emitted. Removed classes, accessors, imports and test assertions are gone. The compiler source AST and semantic/cursor facts are retained.

The production .xtc consumers continue to use FileStructure; they need no separate metadata parser. The rebuilt compiler and packaged-server JARs contain none of the removed classes. Stacked comparison-base merges preserve the tested source trees and keep this shared removal out of each incremental feature diff.

Manual verification

After the file-format change:

  • Rebuilt the full XDK distribution. All 23 interpreter modules, the JIT suite and small-float JIT suite passed using fresh generated artifacts.
  • Standalone Java compiler/runtime tests: 390 passed, 42 skipped. Java utilities: 118 passed, 2 skipped. Results were read from JUnit XML; skips are not counted as passes and this change adds no skips.
  • All four method-persistence/version regressions passed, including both normal and forced assembly.
  • All four whitespace-formatter regressions passed; Gradle plugin validation passed. spotlessCheck passed and a repeated run reused the configuration cache.
  • Compiled and executed a fixture exercising loops, lambdas, switches and try/finally. Explicit mismatched-version rejection passed in both reader/file directions.
  • An audit of all nine affected source trees found no remaining references to the removed binary AST implementation, including in lang, tests and build logic. All shared changes are synchronized, and comparison-branch ancestry is preserved.

Fresh forced validation of the full compiler/LSP reference also passed against the new format: 2,246 LSP tests, 82 packaged-server tests, 545 compiler/runtime tests, 118 utility tests and 50 DSL tests, with zero failures/errors. The respective existing skips were 2, 0, 42, 2 and 0; these are separate from the pass counts. The 120-cycle retention workload issued 960 edit requests and observed 3,154 weak references with zero retained compiler objects after close/shutdown. Root formatting passed, and the worktree remained clean.

All 25 review threads are addressed and resolved. Review has been requested again from @ggleyzer, @cpurdy and @thegridman.

The follow-up readability cleanup in c8d4d9a98 rebuilt the XDK and passed 390 Java tests (42 existing skips), Spotless, and eight AST field-model/tree-copy checks in the synchronized compiler/LSP branch (no skips). The earlier CI failure was a VS Code version-resolution network timeout; rerun attempt 2 passed all required jobs without a source change. The cleanup commit starts a fresh CI run.

Keep executable bytecode and the compiler source AST while removing the duplicate binary tree classes, compiler construction, caches and register serialization support.

Preserve existing method records by skipping legacy metadata on read and writing an empty reserved slot. Add regression coverage for legacy payload consumption, truncation and rewriting without changing executable code.

@ggleyzer ggleyzer left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good

@lagergren
lagergren requested a review from ggleyzer October 12, 2026 16:29
@lagergren
lagergren merged commit dc14ff5 into master Oct 12, 2026
5 checks passed
@lagergren
lagergren deleted the errs/remove-binary-ast-20261012 branch October 12, 2026 18:28
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.

2 participants