Redline: trampolines must be precomputed at build time; the Cranelift bridge must not be a runtime dependency
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 25/100
- Issue type
- Refactor
- Clarity
- Needs clarification
- Activity status
- Active
- Tech stack
- java, wasm
- Domain
- backend, build-system
Research direction
Trace JffiNativeMachine, the Panama NativeMachine, CraneliftBridge, and NativeCodeSerializer to map where trampolines are compiled and serialized. Start by comparing constructor-time compilation with the .native payload and runner dependencies. Done means all listed trampoline sets are available from build-time output, instance-specific addresses are handled by indirection or relocations, and both runner modules no longer require the bridge at runtime.
Written by the indexing model from the issue text.
Description
Both native machines (JffiNativeMachine and the Panama NativeMachine) compile their ABI trampolines in the constructor, i.e. once per instance:
try (var bridge = new CraneliftBridge()) { // Instance.builder(Cranelift.load())...build()
bridge.init(RedlineTarget.detectHost()...triple());
var trampolines = bridge.compileTrampolines(compiledCode, funcTypesByBody, importTypes, importStubAddrs, ...);
CraneliftBridge() instantiates the Cranelift compiler (the 2.5 MB cranelift_bridge.wasm, on the bytecode compiler) every time. The build-time output (NativeCodeSerializer) only contains the function bodies, no trampolines. Measured with quickjs4j (Endive 1.1.0, javy module): 0.8–2.9 s and ~+26 MB RSS per Instance, versus ~0.1 s for the build-time compiled bytecode. Anything that creates instances regularly (camel-quickjs recycles an engine every few thousand evaluations) is dominated by this.
Expected design: everything is precomputed at build time. The runners only load and link, and redline-bridge-experimental (the Cranelift compiler) must not be a runtime dependency of redline-runner-experimental / redline-runner-jffi-experimental at all; today both declare it in compile scope.
Concretely:
- the build-time compiler emits the entry trampolines, import trampolines, internal stub trampolines and memmove/memset trampolines next to the function bodies (one set per target), in the
.nativepayload; - the per-instance addresses they embed today (import closure stubs, watchdog/memgrow stubs, memmove/memset) are either read indirectly from the ctx buffer / function table, so the trampolines are position-independent, or patched at load time through a small relocation table in the payload;
- the runners drop the dependency on the bridge; the bridge stays a build-time-only artifact.
🤖 Generated with Claude Code
- Dominant language
- Java
- Stars
- 306
- Forks
- 20
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 35
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from bytecodealliance/endive
-
Difficulty 4/5 3-5 days Newbie friendliness 45/100
bytecodealliance/endive#211 ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 48/100
bytecodealliance/endive#203 ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 55/100
bytecodealliance/endive#201 ·
Maintainers usually reply within 1 day
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
bytecodealliance/endive#181 · 3 comments · 1 reaction ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 52/100
bytecodealliance/endive#175 ·
Maintainers usually reply within 1 day
All issues in bytecodealliance/endive
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
apache/rocketmq-dashboard#5358 ·
Maintainers usually reply within 3 days
-
area:cpan-port area:database bug
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
fglock/PerlOnJava#1605 ·
Maintainers usually reply within 1 day
-
1.0.0-rc2
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
wso2/dpdp-accelerator#377 ·
Maintainers usually reply within 1 day
-
area/dependencies backport/26.4 kind/cve severity/high source/scan-dependencies status/triage
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day