bridge

package
v0.4.23 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 21, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package bridge provides assembly bridges for calling JIT-compiled code from Go. This is a pure Go solution (no CGO required).

Platform Support:

  • Linux/macOS: Uses System V AMD64 ABI (args in rdi, rsi, rdx)
  • Windows: Uses Microsoft x64 ABI (args in rcx, rdx, r8, r9)

The JIT code generator (BuildFibCode) automatically generates platform-specific code for the target platform.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllocExecMem

func AllocExecMem(size int) ([]byte, error)

AllocExecMem allocates executable memory. On Unix systems, uses mmap with PROT_READ|PROT_WRITE|PROT_EXEC.

func BuildFibCode

func BuildFibCode() []byte

BuildFibCode generates x86-64 machine code for iterative Fibonacci. This version uses System V AMD64 ABI (Linux/macOS). Arguments: rdi = n, returns result in rax.

func Call0

func Call0(fn *byte) int64

Call0 calls a JIT function with no arguments. The JIT function must follow System V AMD64 ABI. Returns the result from rax.

func Call1

func Call1(fn *byte, arg1 int64) int64

Call1 calls a JIT function with 1 argument. Arguments are passed in: rdi (System V AMD64 ABI) Returns the result from rax.

func Call2

func Call2(fn *byte, arg1, arg2 int64) int64

Call2 calls a JIT function with 2 arguments. Arguments are passed in: rdi, rsi Returns the result from rax.

func Call3

func Call3(fn *byte, arg1, arg2, arg3 int64) int64

Call3 calls a JIT function with 3 arguments. Arguments are passed in: rdi, rsi, rdx Returns the result from rax.

func FreeExecMem

func FreeExecMem(mem []byte) error

FreeExecMem frees executable memory allocated by AllocExecMem.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL