Alien-LibJIT
view release on metacpan or search on metacpan
libjit/jit/jit-internal.h view on Meta::CPAN
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
/* Buffer that contains the indirector for this function.
The indirector jumps to the address that is currently
stored in the entry_point field. Indirectors are used
to support recompilation and on-demand compilation. */
unsigned char *indirector;
#endif
};
/*
* Ensure that there is a builder associated with a function.
*/
int _jit_function_ensure_builder(jit_function_t func);
/*
* Free the builder associated with a function.
*/
void _jit_function_free_builder(jit_function_t func);
/*
* Destroy all memory associated with a function.
libjit/jit/jit-internal.h view on Meta::CPAN
jit_mutex_t builder_lock;
/* List of functions that are currently registered with the context */
jit_function_t functions;
jit_function_t last_function;
/* Metadata that is associated with the context */
jit_meta_t meta;
/* ELF binaries that have been loaded into this context */
jit_readelf_t elf_binaries;
/* Table of symbols that have been registered with this context */
jit_regsym_t *registered_symbols;
int num_registered_symbols;
/* Debugger support */
jit_debugger_hook_func debug_hook;
jit_debugger_t debugger;
/* On-demand compilation driver */
jit_on_demand_driver_func on_demand_driver;
};
void *_jit_malloc_exec(unsigned int size);
void _jit_free_exec(void *ptr, unsigned int size);
void _jit_flush_exec(void *ptr, unsigned int size);
void _jit_memory_lock(jit_context_t context);
void _jit_memory_unlock(jit_context_t context);
int _jit_memory_ensure(jit_context_t context);
void _jit_memory_destroy(jit_context_t context);
jit_function_info_t _jit_memory_find_function_info(jit_context_t context, void *pc);
jit_function_t _jit_memory_get_function(jit_context_t context, jit_function_info_t info);
void *_jit_memory_get_function_start(jit_context_t context, jit_function_info_t info);
void *_jit_memory_get_function_end(jit_context_t context, jit_function_info_t info);
jit_function_t _jit_memory_alloc_function(jit_context_t context);
void _jit_memory_free_function(jit_context_t context, jit_function_t func);
int _jit_memory_start_function(jit_context_t context, jit_function_t func);
int _jit_memory_end_function(jit_context_t context, int result);
int _jit_memory_extend_limit(jit_context_t context, int count);
void *_jit_memory_get_limit(jit_context_t context);
void *_jit_memory_get_break(jit_context_t context);
void _jit_memory_set_break(jit_context_t context, void *brk);
void *_jit_memory_alloc_trampoline(jit_context_t context);
void _jit_memory_free_trampoline(jit_context_t context, void *ptr);
void *_jit_memory_alloc_closure(jit_context_t context);
void _jit_memory_free_closure(jit_context_t context, void *ptr);
void *_jit_memory_alloc_data(jit_context_t context, jit_size_t size, jit_size_t align);
/*
* Backtrace control structure, for managing stack traces.
* These structures must be allocated on the stack.
*/
typedef struct jit_backtrace *jit_backtrace_t;
struct jit_backtrace
{
jit_backtrace_t parent;
void *pc;
void *security_object;
jit_meta_free_func free_security_object;
};
/*
* Push a new backtrace onto the stack. The fields in "trace" are filled in.
*/
void _jit_backtrace_push(jit_backtrace_t trace, void *pc);
/*
* Pop the top-most backtrace item.
*/
void _jit_backtrace_pop(void);
/*
* Reset the backtrace stack to "trace". Used in exception catch
* blocks to fix up the backtrace information.
*/
void _jit_backtrace_set(jit_backtrace_t trace);
/*
* Control information that is associated with a thread.
*/
struct jit_thread_control
{
void *last_exception;
jit_exception_func exception_handler;
jit_backtrace_t backtrace_head;
struct jit_jmp_buf *setjmp_head;
};
/*
* Initialize the block list for a function.
*/
int _jit_block_init(jit_function_t func);
/*
* Free all blocks that are associated with a function.
*/
void _jit_block_free(jit_function_t func);
/*
* Build control flow graph edges for all blocks associated with a
* function.
*/
void _jit_block_build_cfg(jit_function_t func);
/*
* Eliminate useless control flow between blocks in a function.
*/
void _jit_block_clean_cfg(jit_function_t func);
/*
* Compute block postorder for control flow graph depth first traversal.
*/
int _jit_block_compute_postorder(jit_function_t func);
/*
* Create a new block and associate it with a function.
( run in 0.387 second using v1.01-cache-2.11-cpan-3d66aa2751a )