Skip to content

Initial redline port#92

Open
andreaTP wants to merge 7 commits into
bytecodealliance:mainfrom
andreaTP:initial-redline
Open

Initial redline port#92
andreaTP wants to merge 7 commits into
bytecodealliance:mainfrom
andreaTP:initial-redline

Conversation

@andreaTP

Copy link
Copy Markdown
Contributor

I'm starting to port the redline compiler(based on Cranelift) to this repo.

This seems an initial bulk to enable the loop with the generated testsuite.

andreaTP added 7 commits July 10, 2026 13:07
Make Machine extend AutoCloseable (default no-op) and Instance implement
AutoCloseable, delegating close() to machine.close(). This enables
principled resource cleanup for native backends without wrappers.

Add redline/ module skeleton with the API module (redline-api-experimental)
containing: RedlineTarget (enum for platform detection), NativeCodeSerializer,
Interruptible, CtxBuffer (native call context layout), and TypeMapUtils
(canonical type map for call_indirect).

Activated via -Predline profile.
Port the Cranelift bridge: a Java wrapper around cranelift_bridge.wasm
(the Cranelift compiler itself compiled to Wasm and run by endive).

- CraneliftBridge: renamed from RedlineBridge, uses moduleInterface
  plugin property instead of @WasmModuleInterface annotation
- Removed WasmResource template, antrun path normalization, templating
  plugin, and annotations dependency
- Fixed getBytes() to use StandardCharsets.UTF_8
- Removed dead null check in close()
- Inlined thin wrapper methods, extracted readCompiledCode()
- Enforcer check fails with clear message if wasm binary is missing
- Rust sources in redline/wasm-build/ (cargo build --target wasm32-wasip1)
- cranelift_bridge.wasm gitignored (build with: cd redline/wasm-build && make all)
Port NativeCompiler, NativeEmitters, EmitContext, NativeValueStack from
chicory-redline. Removed NativeAnalyzer — dead code handling consolidated
into the compiler's control stack (frame.unreachable), single source of
truth. Removed scope/restore mechanism from NativeValueStack (only served
the analyzer). Updated all imports to run.endive.*, ChicoryException to
WasmEngineException, RedlineBridge to CraneliftBridge.
Port NativeMachineFactory, NativeMachine, NativeMemory, NativeTable,
NativeGlobalInstance, PanamaExecutor from chicory-redline.

Key changes from original:
- Removed Cleaner from NativeMachine and NativeMemory — direct
  AutoCloseable only, no GC safety net
- Dropped RedlineInstance wrapper — builder returns Instance directly
- Dropped NativeInstance alias and PanamaMachineFactoryProvider (no SPI)
- RedlineTarget.detectHost() now returns Optional<RedlineTarget>
- Fixed Interruptable -> Interruptible spelling
- All imports updated to run.endive.*
Wire up endive's test-gen-plugin to generate and run the WebAssembly
spec test suite against the redline native compiler + Panama runner.

28,713 tests passing (99.89% of spec suite).
32 tests excluded — all externref-related, due to the gap between
redline's i64-based ref representation and endive's Object-based
GC ref handling. To be addressed separately.

Adapter classes: NativeInstanceBuilder (compiles at runtime via
NativeCompiler), TestModule, Spectest (with NativeMemory for imports),
ArgsAdapter (from endive's runtime-tests, with GC ref support).

No RedlineInstanceTracker — Instance is AutoCloseable, cleanup is
natural via try-with-resources in the generated tests.
Separate workflow for the redline native compiler. Runs on ubuntu and
macOS with JDK 25. Installs Rust with wasm32-wasip1 target, builds
cranelift_bridge.wasm from source, then runs the full spec test suite.
All redline Java packages now include 'experimental' to clearly signal
the API stability level: run.endive.redline.experimental.api,
.bridge, .compiler.internal, .runner, .runner.internal.

Directory names under redline/ unchanged (api/, bridge/, etc.).
Artifact IDs already had -experimental suffix.
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