Alien-LibJIT
view release on metacpan or search on metacpan
libjit/jit/jit-internal.h view on Meta::CPAN
#define _JIT_EDGE_RETURN 2
#define _JIT_EDGE_EXCEPT 3
/*
* Internal structure of a basic block.
*/
struct _jit_block
{
jit_function_t func;
jit_label_t label;
/* List of all instructions in this block */
jit_insn_t insns;
int num_insns;
int max_insns;
/* Next and previous blocks in the function's linear block list */
jit_block_t next;
jit_block_t prev;
/* Edges to successor blocks in control flow graph */
_jit_edge_t *succs;
int num_succs;
/* Edges to predecessor blocks in control flow graph */
_jit_edge_t *preds;
int num_preds;
/* Control flow flags */
unsigned visited : 1;
unsigned ends_in_dead : 1;
unsigned address_of : 1;
/* Metadata */
jit_meta_t meta;
/* Code generation data */
void *address;
void *fixup_list;
void *fixup_absolute_list;
};
/*
* Internal structure of a value.
*/
struct _jit_value
{
jit_block_t block;
jit_type_t type;
unsigned is_temporary : 1;
unsigned is_local : 1;
unsigned is_volatile : 1;
unsigned is_addressable : 1;
unsigned is_constant : 1;
unsigned is_nint_constant : 1;
unsigned is_parameter : 1;
unsigned is_reg_parameter : 1;
unsigned has_address : 1;
unsigned free_address : 1;
unsigned in_register : 1;
unsigned in_frame : 1;
unsigned in_global_register : 1;
unsigned live : 1;
unsigned next_use : 1;
unsigned has_frame_offset : 1;
unsigned global_candidate : 1;
unsigned has_global_register : 1;
short reg;
short global_reg;
jit_nint address;
jit_nint frame_offset;
jit_nuint usage_count;
int index;
};
#define JIT_INVALID_FRAME_OFFSET ((jit_nint)0x7FFFFFFF)
/*
* Free the structures that are associated with a value.
*/
void _jit_value_free(void *value);
/*
* Add references to all of the parameter values in a function.
* This is used when the initialization block is split during a
* "jit_insn_move_blocks_to_start" instruction.
*/
void _jit_value_ref_params(jit_function_t func);
/*
* Internal structure of an instruction.
*/
struct _jit_insn
{
short opcode;
short flags;
jit_value_t dest;
jit_value_t value1;
jit_value_t value2;
};
/*
* Instruction flags.
*/
#define JIT_INSN_DEST_LIVE 0x0001
#define JIT_INSN_DEST_NEXT_USE 0x0002
#define JIT_INSN_VALUE1_LIVE 0x0004
#define JIT_INSN_VALUE1_NEXT_USE 0x0008
#define JIT_INSN_VALUE2_LIVE 0x0010
#define JIT_INSN_VALUE2_NEXT_USE 0x0020
#define JIT_INSN_LIVENESS_FLAGS 0x003F
#define JIT_INSN_DEST_IS_LABEL 0x0040
#define JIT_INSN_DEST_IS_FUNCTION 0x0080
#define JIT_INSN_DEST_IS_NATIVE 0x0100
#define JIT_INSN_DEST_OTHER_FLAGS 0x01C0
#define JIT_INSN_VALUE1_IS_NAME 0x0200
#define JIT_INSN_VALUE1_IS_LABEL 0x0400
#define JIT_INSN_VALUE1_OTHER_FLAGS 0x0600
#define JIT_INSN_VALUE2_IS_SIGNATURE 0x0800
#define JIT_INSN_VALUE2_OTHER_FLAGS 0x0800
#define JIT_INSN_DEST_IS_VALUE 0x1000
/*
* Information about each label associated with a function.
*
* Multiple labels may belong to the same basic block. Such labels are
* linked into list.
*/
typedef struct _jit_label_info _jit_label_info_t;
struct _jit_label_info
{
/* Block the label assigned to */
jit_block_t block;
/* Next label that might belong to the same block */
jit_label_t alias;
/* Label flags */
int flags;
};
#define JIT_LABEL_ADDRESS_OF 0x0001
/*
* Information that is associated with a function for building
* the instructions and values. This structure can be discarded
* once the function has been fully compiled.
*/
typedef struct _jit_builder *jit_builder_t;
struct _jit_builder
{
/* Entry point for the function (and the head of the block list) */
jit_block_t entry_block;
/* Exit point for the function (and the tail of the block list) */
jit_block_t exit_block;
/* The position to insert initialization blocks */
jit_block_t init_block;
/* The current block that is being constructed */
jit_block_t current_block;
/* The list of deleted blocks */
jit_block_t deleted_blocks;
/* Blocks sorted in order required by an optimization pass */
jit_block_t *block_order;
int num_block_order;
/* The next block label to be allocated */
jit_label_t next_label;
/* Mapping from label numbers to blocks */
_jit_label_info_t *label_info;
jit_label_t max_label_info;
/* Exception handling definitions for the function */
jit_value_t setjmp_value;
jit_value_t thrown_exception;
jit_value_t thrown_pc;
jit_label_t catcher_label;
jit_value_t eh_frame_info;
/* Flag that is set to indicate that this function is not a leaf */
unsigned non_leaf : 1;
/* Flag that indicates if we've seen code that may throw an exception */
unsigned may_throw : 1;
/* Flag that indicates if the function has an ordinary return */
unsigned ordinary_return : 1;
/* Flag that indicates that the current function contains a tail call */
unsigned has_tail_call : 1;
/* Generate position-independent code */
unsigned position_independent : 1;
/* Memory pools that contain values, instructions, and metadata blocks */
jit_memory_pool value_pool;
jit_memory_pool edge_pool;
jit_memory_pool meta_pool;
/* Common constants that have been cached */
jit_value_t null_constant;
jit_value_t zero_constant;
/* The values for the parameters, structure return, and parent frame */
jit_value_t *param_values;
jit_value_t struct_return;
jit_value_t parent_frame;
/* Metadata that is stored only while the function is being built */
jit_meta_t meta;
/* Current size of the local variable frame (used by the back end) */
jit_nint frame_size;
/* Number of stack items that are queued for a deferred pop */
jit_nint deferred_items;
/* Size of the outgoing parameter area in the frame */
jit_nint param_area_size;
#ifdef _JIT_COMPILE_DEBUG
int block_count;
int insn_count;
#endif
};
/*
* Internal structure of a function.
*/
struct _jit_function
{
/* The context that the function is associated with */
jit_context_t context;
jit_function_t next;
jit_function_t prev;
/* Containing function in a nested context */
jit_function_t nested_parent;
/* Metadata that survives once the builder is discarded */
jit_meta_t meta;
/* The signature for this function */
jit_type_t signature;
/* The builder information for this function */
jit_builder_t builder;
/* Debug information for this function */
jit_varint_data_t bytecode_offset;
/* Cookie value for this function */
void *cookie;
/* Flag bits for this function */
unsigned is_recompilable : 1;
unsigned is_optimized : 1;
unsigned no_throw : 1;
unsigned no_return : 1;
unsigned has_try : 1;
unsigned optimization_level : 8;
/* Flag set once the function is compiled */
int volatile is_compiled;
/* The entry point for the function's compiled code */
void * volatile entry_point;
/* The function to call to perform on-demand compilation */
jit_on_demand_func on_demand;
#ifndef JIT_BACKEND_INTERP
# ifdef jit_redirector_size
/* Buffer that contains the redirector for this function.
Redirectors are used to support on-demand compilation */
unsigned char *redirector;
# endif
( run in 0.678 second using v1.01-cache-2.11-cpan-df04353d9ac )