infix
A JIT-Powered FFI Library for C
Loading...
Searching...
No Matches
infix_forward_abi_spec Struct Reference

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).
 

Detailed Description

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:

  1. prepare_forward_call_frame is called first to analyze the function signature and produce a complete infix_call_frame_layout blueprint.
  2. The generate_* functions are then called in sequence, consuming the layout blueprint to emit the corresponding machine code into a code_buffer.

Member Data Documentation

◆ generate_forward_argument_moves

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.

Parameters
[in,out]bufThe code buffer.
[in]layoutThe layout blueprint.
[in]arg_typesThe array of argument types.
[in]num_argsTotal number of arguments.
[in]num_fixed_argsNumber of fixed arguments.
Returns
INFIX_SUCCESS on success.

◆ generate_forward_call_instruction

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.

Parameters
[in,out]bufThe code buffer.
[in]layoutThe layout blueprint.
Returns
INFIX_SUCCESS on success.

◆ generate_forward_epilogue

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).

Parameters
[in,out]bufThe code buffer.
[in]layoutThe layout blueprint.
[in]ret_typeThe function's return type.
Returns
INFIX_SUCCESS on success.

◆ generate_forward_prologue

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).

Parameters
[in,out]bufThe code buffer to append machine code to.
[in]layoutThe layout blueprint from the previous step.
Returns
INFIX_SUCCESS on success.

◆ prepare_forward_call_frame

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.

Parameters
[in]arenaA temporary arena for allocating the layout struct.
[out]out_layoutReceives the newly created layout blueprint.
[in]ret_typeThe function's return type.
[in]arg_typesArray of argument types.
[in]num_argsTotal number of arguments.
[in]num_fixed_argsNumber of non-variadic arguments.
[in]target_fnThe target function address.
Returns
INFIX_SUCCESS on success.

The documentation for this struct was generated from the following file: