Skip to content

Precompile Redline trampolines and drop the bridge from the runners - #228

Merged
andreaTP merged 2 commits into
bytecodealliance:mainfrom
andreaTP:redline-precompiled-trampolines
Oct 8, 2026
Merged

andreaTP merged 2 commits into
bytecodealliance:mainfrom
andreaTP:redline-precompiled-trampolines

Conversation

@andreaTP

@andreaTP andreaTP commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

Both runners created the Cranelift bridge in every machine to compile their ABI trampolines. The build-time compiler now emits them with the function bodies, and the runners only load and link:

  • function bodies call memory.grow, memmove/memset and the table stub directly with the platform ABI, so their trampolines are gone
  • entry trampolines take the function pointer as a parameter and are compiled once per function type
  • import trampolines leave an 8-byte slot for the host stub address, which the runner fills before making the code executable; a shared table can call them with another instance's ctx, so they cannot read it from the ctx

NativeCode, written as .native format version 2, replaces byte[][], withCompilerFunction is removed, and an enforcer rule keeps the bridge and the compiler out of both runners' dependencies.

Fixes #202

Both runners created the Cranelift bridge in every machine to compile
their ABI trampolines. The build-time compiler now emits them with the
function bodies, and the runners only load and link:

- function bodies call memory.grow, memmove/memset and the table stub
  directly with the platform ABI, so their trampolines are gone
- entry trampolines take the function pointer as a parameter and are
  compiled once per function type
- import trampolines leave an 8-byte slot for the host stub address,
  which the runner fills before making the code executable; a shared
  table can call them with another instance's ctx, so they cannot read
  it from the ctx

NativeCode, written as .native format version 2, replaces byte[][],
withCompilerFunction is removed, and an enforcer rule keeps the bridge
and the compiler out of both runners' dependencies.

Fixes bytecodealliance#202
@andreaTP

andreaTP commented Oct 7, 2026

Copy link
Copy Markdown
Contributor Author

@headius this should fix some of your observations, especially regarding upfront resources consumption:

on quickjs:

main this branch
time 358 ms 19 ms
Java heap allocated 157 MB 6.2 MB
first instance 1.1 s 0.48 s

@headius

headius commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

@andreaTP I can give a HEAD build a try later today with my JRuby + Prism integration branch. I assume this branch includes #210?

@andreaTP

andreaTP commented Oct 7, 2026

Copy link
Copy Markdown
Contributor Author

Yes 210 is included, but let me close also 203 and do a final review before trying things out, we'll get there!

@andreaTP
andreaTP merged commit 0be4e6f into bytecodealliance:main Oct 8, 2026
25 checks passed
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.

Redline: trampolines must be precomputed at build time; the Cranelift bridge must not be a runtime dependency

2 participants