The jit_function class provides a C++ counterpart to the C jit_function_t type.  See Functions, for more information on creating and managing functions.

The jit_function class also provides a large number of methods for creating the instructions within a function body.  See Instructions, for more information on creating and managing instructions.

 -- Constructor on jit_function: jit_function (jit_context& CONTEXT, jit_type_t SIGNATURE)
     Constructs a new function handler with the specified SIGNATURE in the given CONTEXT.  It then calls create(SIGNATURE) to create the actual function.

 -- Constructor on jit_function: jit_function (jit_context& CONTEXT)
     Constructs a new function handler in the specified CONTEXT. The actual function is not created until you call create().

 -- Constructor on jit_function: jit_function (jit_function_t FUNC)
     Constructs a new function handler and wraps it around the specified raw C jit_function_t object.  This can be useful for layering the C++ on-demand building facility on top of an existing C function.

 -- Destructor on jit_function: ~jit_function ()
     Destroy this function handler.  The raw function will persist until the context is destroyed.

 -- Method on jit_function: jit_function_t raw () const
     Get the raw C jit_function_t value that underlies this object.

 -- Method on jit_function: int is_valid () const
     Determine if the raw C jit_function_t value that underlies this object is valid.

 -- Method on jit_function: static jit_function * from_raw (jit_function_t FUNC)
     Find the C++ jit_function object that is associated with a raw C jit_function_t pointer.  Returns NULL if there is no such object.

 -- Method on jit_function: jit_type_t signature () const
     Get the signature type for this function.

 -- Method on jit_function: void create (jit_type_t SIGNATURE)
     Create this function if it doesn't already exist.

 -- Method on jit_function: void create ()
     Create this function if it doesn't already exist.  This version will call the virtual create_signature() method to obtain the signature from the subclass.

 -- Method on jit_function: int compile ()
     Compile this function explicity.  You normally don't need to use this method because the function will be compiled on-demand.  If you do choose to build the function manually, then the correct sequence of operations is as follows:

      1. Invoke the build_start method to lock down the function builder.

      2. Build the function by calling the value-related and instruction-related methods within jit_function.

      3. Compile the function with the compile method.

      4. Unlock the function builder by invoking build_end.

 -- Method on jit_function: int is_compiled () const
     Determine if this function has already been compiled.

 -- Method on jit_function: void set_optimization_level (unsigned int LEVEL)
 -- Method on jit_function: unsigned int optimization_level () const
     Set or get the optimization level for this function.

 -- Method on jit_function: static unsigned int max_optimization_level ()
     Get the maximum optimization level for libjit.

 -- Method on jit_function: void * closure () const
 -- Method on jit_function: void * vtable_pointer () const
     Get the closure or vtable pointer form of this function.

 -- Method on jit_function: int apply (void** ARGS, void* RESULT)
 -- Method on jit_function: int apply (jit_type_t SIGNATURE, void** ARGS, void* RETURN_AREA)
     Call this function, applying the specified arguments.

 -- Method on jit_function: static jit_type_t signature_helper (jit_type_t RETURN_TYPE, ...)
     You can call this method from create_signature() to help build the correct signature for your function.  The first parameter is the return type, following by zero or more types for the parameters.  The parameter list is terminated with the special value jit_function::end_params.

     A maximum of 32 parameter types can be supplied, and the signature ABI is always set to jit_abi_cdecl.

 -- Method on jit_function: void build ()
     This method is called when the function has to be build on-demand, or in response to an explicit recompile request.  You build the function by calling the value-related and instruction-related methods within jit_function that are described below.

     The default implementation of build will fail, so you must override it if you didn't build the function manually and call compile.

 -- Method on jit_function: jit_type_t create_signature ()
     This method is called by create() to create the function's signature.  The default implementation creates a signature that returns void and has no parameters.

 -- Method on jit_function: void fail ()
     This method can be called by build to fail the on-demand compilation process.  It throws an exception to unwind the build.

 -- Method on jit_function: void out_of_memory ()
     This method can be called by build to indicate that the on-demand compilation process ran out of memory.  It throws an exception to unwind the build.

 -- Method on jit_function: void build_start ()
     Start an explicit build process.  Not needed if you will be using on-demand compilation.

 -- Method on jit_function: void build_end ()
     End an explicit build process.

 -- Method on jit_function: jit_value new_value (jit_type_t TYPE)
     Create a new temporary value.  This is the C++ counterpart to jit_value_create.

 -- Method on jit_function: jit_value new_constant (jit_sbyte VALUE, jit_type_t TYPE)
 -- Method on jit_function: jit_value new_constant (jit_ubyte VALUE, jit_type_t TYPE)
 -- Method on jit_function: jit_value new_constant (jit_short VALUE, jit_type_t TYPE)
 -- Method on jit_function: jit_value new_constant (jit_ushort VALUE, jit_type_t TYPE)
 -- Method on jit_function: jit_value new_constant (jit_int VALUE, jit_type_t TYPE)
 -- Method on jit_function: jit_value new_constant (jit_uint VALUE, jit_type_t TYPE)
 -- Method on jit_function: jit_value new_constant (jit_long VALUE, jit_type_t TYPE)
 -- Method on jit_function: jit_value new_constant (jit_ulong VALUE, jit_type_t TYPE)
 -- Method on jit_function: jit_value new_constant (jit_float32 VALUE, jit_type_t TYPE)
 -- Method on jit_function: jit_value new_constant (jit_float64 VALUE, jit_type_t TYPE)
 -- Method on jit_function: jit_value new_constant (jit_nfloat VALUE, jit_type_t TYPE)
 -- Method on jit_function: jit_value new_constant (void* VALUE, jit_type_t TYPE)
 -- Method on jit_function: jit_value new_constant (const jit_constant_t& VALUE)
     Create constant values of various kinds.  See Values, for more information on creating and managing constants.

 -- Method on jit_function: jit_value get_param (unsigned int PARAM)
     Get the value that corresponds to parameter PARAM.

 -- Method on jit_function: jit_value get_struct_pointer ()
     Get the value that corresponds to the structure pointer parameter, if this function has one.  Returns an empty value if it does not.

 -- Method on jit_function: jit_label new_label ()
     Create a new label.  This is the C++ counterpart to jit_function_reserve_label.

 -- Method on jit_function: void insn_label (jit_label& LABEL)
 -- Method on jit_function: void insn_new_block ()
 -- Method on jit_function: jit_value insn_load (const jit_value& VALUE)
 -- Method on jit_function: jit_value insn_dup (const jit_value& VALUE)
 -- Method on jit_function: jit_value insn_load_small (const jit_value& VALUE)
 -- Method on jit_function: void store (const jit_value& DEST, const jit_value& VALUE)
 -- Method on jit_function: jit_value insn_load_relative (const jit_value& VALUE, jit_nint OFFSET, jit_type_t TYPE)
 -- Method on jit_function: void insn_store_relative (const jit_value& DEST, jit_nint OFFSET, const jit_value& VALUE)
 -- Method on jit_function: jit_value insn_add_relative (const jit_value& VALUE, jit_nint OFFSET)
 -- Method on jit_function: jit_value insn_load_elem (const jit_value& BASE_ADDR, const jit_value& INDEX, jit_type_t ELEM_TYPE)
 -- Method on jit_function: jit_value insn_load_elem_address (const jit_value& BASE_ADDR, const jit_value& INDEX, jit_type_t ELEM_TYPE)
 -- Method on jit_function: void insn_store_elem (const jit_value& BASE_ADDR, const jit_value& INDEX, const jit_value& VALUE)
 -- Method on jit_function: void insn_check_null (const jit_value& VALUE)
 -- Method on jit_function: jit_value insn_add (const jit_value& VALUE1, const jit_value& VALUE2)
 -- Method on jit_function: jit_value insn_add_ovf (const jit_value& VALUE1, const jit_value& VALUE2)
 -- Method on jit_function: jit_value insn_sub (const jit_value& VALUE1, const jit_value& VALUE2)
 -- Method on jit_function: jit_value insn_sub_ovf (const jit_value& VALUE1, const jit_value& VALUE2)
 -- Method on jit_function: jit_value insn_mul (const jit_value& VALUE1, const jit_value& VALUE2)
 -- Method on jit_function: jit_value insn_mul_ovf (const jit_value& VALUE1, const jit_value& VALUE2)
 -- Method on jit_function: jit_value insn_div (const jit_value& VALUE1, const jit_value& VALUE2)
 -- Method on jit_function: jit_value insn_rem (const jit_value& VALUE1, const jit_value& VALUE2)
 -- Method on jit_function: jit_value insn_rem_ieee (const jit_value& VALUE1, const jit_value& VALUE2)
 -- Method on jit_function: jit_value insn_neg (const jit_value& VALUE1)
 -- Method on jit_function: jit_value insn_and (const jit_value& VALUE1, const jit_value& VALUE2)
 -- Method on jit_function: jit_value insn_or (const jit_value& VALUE1, const jit_value& VALUE2)
 -- Method on jit_function: jit_value insn_xor (const jit_value& VALUE1, const jit_value& VALUE2)
 -- Method on jit_function: jit_value insn_not (const jit_value& VALUE1)
 -- Method on jit_function: jit_value insn_shl (const jit_value& VALUE1, const jit_value& VALUE2)
 -- Method on jit_function: jit_value insn_shr (const jit_value& VALUE1, const jit_value& VALUE2)
 -- Method on jit_function: jit_value insn_ushr (const jit_value& VALUE1, const jit_value& VALUE2)
 -- Method on jit_function: jit_value insn_sshr (const jit_value& VALUE1, const jit_value& VALUE2)
 -- Method on jit_function: jit_value insn_eq (const jit_value& VALUE1, const jit_value& VALUE2)
 -- Method on jit_function: jit_value insn_ne (const jit_value& VALUE1, const jit_value& VALUE2)
 -- Method on jit_function: jit_value insn_lt (const jit_value& VALUE1, const jit_value& VALUE2)
 -- Method on jit_function: jit_value insn_le (const jit_value& VALUE1, const jit_value& VALUE2)
 -- Method on jit_function: jit_value insn_gt (const jit_value& VALUE1, const jit_value& VALUE2)
 -- Method on jit_function: jit_value insn_ge (const jit_value& VALUE1, const jit_value& VALUE2)
 -- Method on jit_function: jit_value insn_cmpl (const jit_value& VALUE1, const jit_value& VALUE2)
 -- Method on jit_function: jit_value insn_cmpg (const jit_value& VALUE1, const jit_value& VALUE2)
 -- Method on jit_function: jit_value insn_to_bool (const jit_value& VALUE1)
 -- Method on jit_function: jit_value insn_to_not_bool (const jit_value& VALUE1)
 -- Method on jit_function: jit_value insn_acos (const jit_value& VALUE1)
 -- Method on jit_function: jit_value insn_asin (const jit_value& VALUE1)
 -- Method on jit_function: jit_value insn_atan (const jit_value& VALUE1)
 -- Method on jit_function: jit_value insn_atan2 (const jit_value& VALUE1, const jit_value& VALUE2)
 -- Method on jit_function: jit_value insn_ceil (const jit_value& VALUE1)
 -- Method on jit_function: jit_value insn_cos (const jit_value& VALUE1)
 -- Method on jit_function: jit_value insn_cosh (const jit_value& VALUE1)
 -- Method on jit_function: jit_value insn_exp (const jit_value& VALUE1)
 -- Method on jit_function: jit_value insn_floor (const jit_value& VALUE1)
 -- Method on jit_function: jit_value insn_log (const jit_value& VALUE1)
 -- Method on jit_function: jit_value insn_log10 (const jit_value& VALUE1)
 -- Method on jit_function: jit_value insn_pow (const jit_value& VALUE1, const jit_value& VALUE2)
 -- Method on jit_function: jit_value insn_rint (const jit_value& VALUE1)
 -- Method on jit_function: jit_value insn_round (const jit_value& VALUE1)
 -- Method on jit_function: jit_value insn_sin (const jit_value& VALUE1)
 -- Method on jit_function: jit_value insn_sinh (const jit_value& VALUE1)
 -- Method on jit_function: jit_value insn_sqrt (const jit_value& VALUE1)
 -- Method on jit_function: jit_value insn_tan (const jit_value& VALUE1)
 -- Method on jit_function: jit_value insn_tanh (const jit_value& VALUE1)
 -- Method on jit_function: jit_value insn_trunc (const jit_value& VALUE1)
 -- Method on jit_function: jit_value insn_is_nan (const jit_value& VALUE1)
 -- Method on jit_function: jit_value insn_is_finite (const jit_value& VALUE1)
 -- Method on jit_function: jit_value insn_is_inf (const jit_value& VALUE1)
 -- Method on jit_function: jit_value insn_abs (const jit_value& VALUE1)
 -- Method on jit_function: jit_value insn_min (const jit_value& VALUE1, const jit_value& VALUE2)
 -- Method on jit_function: jit_value insn_max (const jit_value& VALUE1, const jit_value& VALUE2)
 -- Method on jit_function: jit_value insn_sign (const jit_value& VALUE1)
 -- Method on jit_function: void insn_branch (jit_label& LABEL)
 -- Method on jit_function: void insn_branch_if (const jit_value& VALUE, jit_label& LABEL)
 -- Method on jit_function: void insn_branch_if_not (const jit_value& value, jit_label& LABEL)
 -- Method on jit_function: jit_value insn_address_of (const jit_value& VALUE1)
 -- Method on jit_function: jit_value insn_address_of_label (jit_label& LABEL)
 -- Method on jit_function: jit_value insn_convert (const jit_value& VALUE, jit_type_t TYPE, int OVERFLOW_CHECK)
 -- Method on jit_function: jit_value insn_call (const char* NAME, jit_function_t JIT_FUNC, jit_type_t SIGNATURE, jit_value_t* ARGS, unsigned int NUM_ARGS, int FLAGS)
 -- Method on jit_function: jit_value insn_call_indirect (const jit_value& VALUE, jit_type_t SIGNATURE, jit_value_t* ARGS, unsigned int NUM_ARGS, int FLAGS)
 -- Method on jit_function: jit_value insn_call_indirect_vtable (const jit_value& VALUE, jit_type_t SIGNATURE, jit_value_t * ARGS, unsigned int NUM_ARGS, int FLAGS)
 -- Method on jit_function: jit_value insn_call_native (const char* NAME, void* NATIVE_FUNC, jit_type_t SIGNATURE, jit_value_t* ARGS, unsigned int NUM_ARGS, int FLAGS)
 -- Method on jit_function: jit_value insn_call_intrinsic (const char* NAME, void* INTRINSIC_FUNC, const jit_intrinsic_descr_t& DESCRIPTOR, const jit_value& ARG1, const jit_value& ARG2)
 -- Method on jit_function: void insn_incoming_reg (const jit_value& VALUE, int REG)
 -- Method on jit_function: void insn_incoming_frame_posn (const jit_value& VALUE, jit_nint POSN)
 -- Method on jit_function: void insn_outgoing_reg (const jit_value& VALUE, int REG)
 -- Method on jit_function: void insn_outgoing_frame_posn (const jit_value& VALUE, jit_nint POSN)
 -- Method on jit_function: void insn_return_reg (const jit_value& VALUE, int REG)
 -- Method on jit_function: void insn_setup_for_nested (int NESTED_LEVEL, int REG)
 -- Method on jit_function: void insn_flush_struct (const jit_value& VALUE)
 -- Method on jit_function: jit_value insn_import (jit_value VALUE)
 -- Method on jit_function: void insn_push (const jit_value& VALUE)
 -- Method on jit_function: void insn_push_ptr (const jit_value& VALUE, jit_type_t TYPE)
 -- Method on jit_function: void insn_set_param (const jit_value& VALUE, jit_nint OFFSET)
 -- Method on jit_function: void insn_set_param_ptr (const jit_value& VALUE, jit_type_t TYPE, jit_nint OFFSET)
 -- Method on jit_function: void insn_push_return_area_ptr ()
 -- Method on jit_function: void insn_return (const jit_value& VALUE)
 -- Method on jit_function: void insn_return ()
 -- Method on jit_function: void insn_return_ptr (const jit_value& VALUE, jit_type_t TYPE)
 -- Method on jit_function: void insn_default_return ()
 -- Method on jit_function: void insn_throw (const jit_value& VALUE)
 -- Method on jit_function: jit_value insn_get_call_stack ()
 -- Method on jit_function: jit_value insn_thrown_exception ()
 -- Method on jit_function: void insn_uses_catcher ()
 -- Method on jit_function: jit_value insn_start_catcher ()
 -- Method on jit_function: void insn_branch_if_pc_not_in_range (const jit_label& START_LABEL, const jit_label& END_LABEL, jit_label& LABEL)
 -- Method on jit_function: void insn_rethrow_unhandled ()
 -- Method on jit_function: void insn_start_finally (jit_label& LABEL)
 -- Method on jit_function: void insn_return_from_finally ()
 -- Method on jit_function: void insn_call_finally (jit_label& LABEL)
 -- Method on jit_function: jit_value insn_start_filter (jit_label& LABEL, jit_type_t TYPE)
 -- Method on jit_function: void insn_return_from_filter (const jit_value& VALUE)
 -- Method on jit_function: jit_value insn_call_filter (jit_label& LABEL, const jit_value& VALUE, jit_type_t TYPE)
 -- Method on jit_function: void insn_memcpy (const jit_value& DEST, const jit_value& SRC, const jit_value& SIZE)
 -- Method on jit_function: void insn_memmove (const jit_value& DEST, const jit_value& SRC, const jit_value& SIZE)
 -- Method on jit_function: void jit_insn_memset (const jit_value& DEST, const jit_value& VALUE, const jit_value& SIZE)
 -- Method on jit_function: jit_value jit_insn_alloca (const jit_value& SIZE)
 -- Method on jit_function: void insn_move_blocks_to_end (const jit_label& FROM_LABEL, const jit_label& TO_LABEL)
 -- Method on jit_function: void insn_move_blocks_to_start (const jit_label& FROM_LABEL, const jit_label& TO_LABEL)
 -- Method on jit_function: void insn_mark_offset (jit_int OFFSET)
 -- Method on jit_function: void insn_mark_breakpoint (jit_nint DATA1, jit_nint DATA2)
     Create instructions of various kinds.  See Instructions, for more information on the individual instructions and their arguments.