|
infix
A JIT-Powered FFI Library for C
|
Defines the ABI-specific implementation interface for forward trampolines. More...
#include <infix_internals.h>
Public Attributes | |
| infix_status(* | prepare_forward_call_frame )(infix_arena_t *arena, infix_call_frame_layout **out_layout, infix_type *ret_type, infix_type **arg_types, size_t num_args, size_t num_fixed_args, void *target_fn) |
| Analyzes a function signature to create a complete call frame layout. | |
| infix_status(* | generate_forward_prologue )(code_buffer *buf, infix_call_frame_layout *layout) |
| Generates the function prologue (stack setup, saving registers). | |
| infix_status(* | generate_forward_argument_moves )(code_buffer *buf, infix_call_frame_layout *layout, infix_type **arg_types, size_t num_args, size_t num_fixed_args) |
Generates code to move arguments from the void** array into registers and/or the stack. | |
| infix_status(* | generate_forward_call_instruction )(code_buffer *buf, infix_call_frame_layout *layout) |
Generates the call instruction to the target function. | |
| infix_status(* | generate_forward_epilogue )(code_buffer *buf, infix_call_frame_layout *layout, infix_type *ret_type) |
| Generates the function epilogue (handling return value, restoring stack, returning). | |
Defines the ABI-specific implementation interface for forward trampolines.
This structure is a virtual function table (v-table) that decouples the platform-agnostic JIT engine (trampoline.c) from the platform-specific code generation logic (arch/...). Each supported ABI (e.g., SysV x64, Win x64, AArch64) provides a concrete implementation of this interface.
The JIT pipeline for a forward call proceeds in a well-defined order:
prepare_forward_call_frame is called first to analyze the function signature and produce a complete infix_call_frame_layout blueprint.generate_* functions are then called in sequence, consuming the layout blueprint to emit the corresponding machine code into a code_buffer. | infix_status(* infix_forward_abi_spec::generate_forward_argument_moves) (code_buffer *buf, infix_call_frame_layout *layout, infix_type **arg_types, size_t num_args, size_t num_fixed_args) |
Generates code to move arguments from the void** array into registers and/or the stack.
| [in,out] | buf | The code buffer. |
| [in] | layout | The layout blueprint. |
| [in] | arg_types | The array of argument types. |
| [in] | num_args | Total number of arguments. |
| [in] | num_fixed_args | Number of fixed arguments. |
INFIX_SUCCESS on success. | infix_status(* infix_forward_abi_spec::generate_forward_call_instruction) (code_buffer *buf, infix_call_frame_layout *layout) |
Generates the call instruction to the target function.
| [in,out] | buf | The code buffer. |
| [in] | layout | The layout blueprint. |
INFIX_SUCCESS on success. | infix_status(* infix_forward_abi_spec::generate_forward_epilogue) (code_buffer *buf, infix_call_frame_layout *layout, infix_type *ret_type) |
Generates the function epilogue (handling return value, restoring stack, returning).
| [in,out] | buf | The code buffer. |
| [in] | layout | The layout blueprint. |
| [in] | ret_type | The function's return type. |
INFIX_SUCCESS on success. | infix_status(* infix_forward_abi_spec::generate_forward_prologue) (code_buffer *buf, infix_call_frame_layout *layout) |
Generates the function prologue (stack setup, saving registers).
| [in,out] | buf | The code buffer to append machine code to. |
| [in] | layout | The layout blueprint from the previous step. |
INFIX_SUCCESS on success. | infix_status(* infix_forward_abi_spec::prepare_forward_call_frame) (infix_arena_t *arena, infix_call_frame_layout **out_layout, infix_type *ret_type, infix_type **arg_types, size_t num_args, size_t num_fixed_args, void *target_fn) |
Analyzes a function signature to create a complete call frame layout.
This is the "classification" stage. It determines where each argument and the return value will be placed (in which registers or on what stack offset) according to the target ABI's rules. The resulting layout is a complete plan for the code emitters.
| [in] | arena | A temporary arena for allocating the layout struct. |
| [out] | out_layout | Receives the newly created layout blueprint. |
| [in] | ret_type | The function's return type. |
| [in] | arg_types | Array of argument types. |
| [in] | num_args | Total number of arguments. |
| [in] | num_fixed_args | Number of non-variadic arguments. |
| [in] | target_fn | The target function address. |
INFIX_SUCCESS on success.