infix
A JIT-Powered FFI Library for C
|
The core engine for JIT compiling FFI trampolines. More...
#include "common/infix_internals.h"
#include "common/utility.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/mman.h>
#include <unistd.h>
Go to the source code of this file.
Functions | |
static infix_status | _infix_reverse_create_internal (infix_reverse_t **, infix_type *, infix_type **, size_t, size_t, void *, void *, bool) |
const infix_forward_abi_spec * | get_current_forward_abi_spec () |
Gets the ABI v-table for the current target platform (forward calls). | |
const infix_reverse_abi_spec * | get_current_reverse_abi_spec () |
Gets the ABI v-table for the current target platform (reverse calls). | |
void | code_buffer_init (code_buffer *buf, infix_arena_t *arena) |
Initializes a code buffer for JIT code generation. | |
void | code_buffer_append (code_buffer *buf, const void *data, size_t len) |
Appends raw bytes to a code buffer, reallocating if necessary. | |
void | emit_byte (code_buffer *buf, uint8_t byte) |
Appends a single byte to a code buffer. | |
void | emit_int32 (code_buffer *buf, int32_t value) |
Appends a 32-bit integer to a code buffer. | |
void | emit_int64 (code_buffer *buf, int64_t value) |
Appends a 64-bit integer to a code buffer. | |
static bool | _is_type_graph_resolved (infix_type *type) |
c23_nodiscard infix_unbound_cif_func | infix_forward_get_unbound_code (infix_forward_t *trampoline) |
Retrieves the executable code pointer from an unbound forward trampoline. | |
c23_nodiscard infix_cif_func | infix_forward_get_code (infix_forward_t *trampoline) |
Retrieves the executable code pointer from a bound forward trampoline. | |
c23_nodiscard infix_status | _infix_forward_create_internal (infix_forward_t **out_trampoline, infix_type *return_type, infix_type **arg_types, size_t num_args, size_t num_fixed_args, infix_arena_t *source_arena, void *target_fn) |
The internal core logic for creating a forward trampoline. | |
c23_nodiscard infix_status | infix_forward_create_manual (infix_forward_t **out_trampoline, infix_type *return_type, infix_type **arg_types, size_t num_args, size_t num_fixed_args, void *target_function) |
Generates a bound forward-call trampoline for a given function signature. | |
c23_nodiscard infix_status | infix_forward_create_unbound_manual (infix_forward_t **out_trampoline, infix_type *return_type, infix_type **arg_types, size_t num_args, size_t num_fixed_args) |
Creates an "unbound" forward-call trampoline for a given function signature. | |
void | infix_forward_destroy (infix_forward_t *trampoline) |
Frees a forward trampoline and its associated executable memory. | |
static size_t | get_page_size () |
c23_nodiscard infix_status | infix_reverse_create_callback_manual (infix_reverse_t **out_context, infix_type *return_type, infix_type **arg_types, size_t num_args, size_t num_fixed_args, void *user_callback_fn) |
Generates a type-safe reverse-call trampoline (callback) from infix_type objects. | |
c23_nodiscard infix_status | infix_reverse_create_closure_manual (infix_reverse_t **out_context, infix_type *return_type, infix_type **arg_types, size_t num_args, size_t num_fixed_args, infix_closure_handler_fn user_callback_fn, void *user_data) |
Generates a generic reverse-call trampoline (closure) from infix_type objects. | |
void | infix_reverse_destroy (infix_reverse_t *reverse_trampoline) |
Frees a reverse trampoline, its JIT-compiled stub, and its context. | |
c23_nodiscard void * | infix_reverse_get_code (const infix_reverse_t *reverse_trampoline) |
Retrieves the executable code pointer from a reverse trampoline. | |
c23_nodiscard void * | infix_reverse_get_user_data (const infix_reverse_t *reverse_trampoline) |
Retrieves the user_data stored with a reverse trampoline. | |
c23_nodiscard infix_status | infix_forward_create (infix_forward_t **out_trampoline, const char *signature, void *target_function, infix_registry_t *registry) |
Implementation of the public infix_forward_create API function. | |
c23_nodiscard infix_status | infix_forward_create_unbound (infix_forward_t **out_trampoline, const char *signature, infix_registry_t *registry) |
Implementation of the public infix_forward_create_unbound API function. | |
c23_nodiscard infix_status | infix_reverse_create_callback (infix_reverse_t **out_context, const char *signature, void *user_callback_fn, infix_registry_t *registry) |
Implementation of the public infix_reverse_create_callback API function. | |
c23_nodiscard infix_status | infix_reverse_create_closure (infix_reverse_t **out_context, const char *signature, infix_closure_handler_fn user_callback_fn, void *user_data, infix_registry_t *registry) |
Implementation of the public infix_reverse_create_closure API function. | |
The core engine for JIT compiling FFI trampolines.
Copyright (c) 2025 Sanko Robinson
This source code is dual-licensed under the Artistic License 2.0 or the MIT License. You may choose to use this code under the terms of either license.
SPDX-License-Identifier: (Artistic-2.0 OR MIT)
The documentation blocks within this file are licensed under the Creative Commons Attribution 4.0 International License (CC BY 4.0).
SPDX-License-Identifier: CC-BY-4.0
c23_nodiscard infix_status _infix_forward_create_internal | ( | infix_forward_t ** | out_trampoline, |
infix_type * | return_type, | ||
infix_type ** | arg_types, | ||
size_t | num_args, | ||
size_t | num_fixed_args, | ||
infix_arena_t * | source_arena, | ||
void * | target_fn | ||
) |
The internal core logic for creating a forward trampoline.
|
static |
|
static |
void code_buffer_append | ( | code_buffer * | buf, |
const void * | data, | ||
size_t | len | ||
) |
Appends raw bytes to a code buffer, reallocating if necessary.
void code_buffer_init | ( | code_buffer * | buf, |
infix_arena_t * | arena | ||
) |
Initializes a code buffer for JIT code generation.
void emit_byte | ( | code_buffer * | buf, |
uint8_t | byte | ||
) |
Appends a single byte to a code buffer.
void emit_int32 | ( | code_buffer * | buf, |
int32_t | value | ||
) |
Appends a 32-bit integer to a code buffer.
void emit_int64 | ( | code_buffer * | buf, |
int64_t | value | ||
) |
Appends a 64-bit integer to a code buffer.
const infix_forward_abi_spec * get_current_forward_abi_spec | ( | void | ) |
Gets the ABI v-table for the current target platform (forward calls).
const infix_reverse_abi_spec * get_current_reverse_abi_spec | ( | void | ) |
Gets the ABI v-table for the current target platform (reverse calls).
|
static |