Alien-LibJIT
view release on metacpan or search on metacpan
libjit/jit/jit-rules-interp.c view on Meta::CPAN
#define jit_cache_add_n(gen,buf,size) \
do { \
unsigned int __size = \
((size) + sizeof(void *) - 1) & ~(sizeof(void *) - 1); \
_jit_gen_check_space((gen), __size); \
jit_memcpy((gen)->ptr, (buf), (size)); \
(gen)->ptr += __size; \
} while (0)
/*
* Adjust the height of the working area.
*/
#define adjust_working(gen,adjust) \
do { \
(gen)->working_area += (adjust); \
if((gen)->working_area > (gen)->max_working_area) \
{ \
(gen)->max_working_area = (gen)->working_area; \
} \
} while (0)
/*@
* @deftypefun void _jit_init_backend (void)
* Initialize the backend. This is normally used to configure registers
* that may not appear on all CPU's in a given family. For example, only
* some ARM cores have floating-point registers.
* @end deftypefun
@*/
void _jit_init_backend(void)
{
/* Nothing to do here for the interpreter */
}
/*@
* @deftypefun void _jit_gen_get_elf_info (jit_elf_info_t *@var{info})
* Get the ELF machine and ABI type information for this platform.
* The @code{machine} field should be set to one of the @code{EM_*}
* values in @code{jit-elf-defs.h}. The @code{abi} field should
* be set to one of the @code{ELFOSABI_*} values in @code{jit-elf-defs.h}
* (@code{ELFOSABI_SYSV} will normally suffice if you are unsure).
* The @code{abi_version} field should be set to the ABI version,
* which is usually zero.
* @end deftypefun
@*/
void _jit_gen_get_elf_info(jit_elf_info_t *info)
{
/* The interpreter's ELF machine type is defined to be "Lj",
which hopefully won't clash with any standard types */
info->machine = 0x4C6A;
info->abi = 0;
info->abi_version = JIT_OPCODE_VERSION;
}
/*@
* @deftypefun int _jit_create_entry_insns (jit_function_t @var{func})
* Create instructions in the entry block to initialize the
* registers and frame offsets that contain the parameters.
* Returns zero if out of memory.
*
* This function is called when a builder is initialized. It should
* scan the signature and decide which register or frame position
* contains each of the parameters and then call either
* @code{jit_insn_incoming_reg} or @code{jit_insn_incoming_frame_posn}
* to notify @code{libjit} of the location.
* @end deftypefun
@*/
int _jit_create_entry_insns(jit_function_t func)
{
jit_type_t signature = func->signature;
jit_type_t type;
jit_nint offset;
jit_value_t value;
unsigned int num_params;
unsigned int param;
/* Reset the frame size for this function */
func->builder->frame_size = 0;
/* The starting parameter offset. We use negative offsets to indicate
an offset into the "args" block, and positive offsets to indicate
an offset into the "frame" block. The negative values will be
flipped when we output the argument opcodes for interpretation */
offset = -1;
/* If the function is nested, then we need two extra parameters
to pass the pointer to the parent's local variables and arguments */
if(func->nested_parent)
{
offset -= 2;
}
/* Allocate the structure return pointer */
value = jit_value_get_struct_pointer(func);
if(value)
{
if(!jit_insn_incoming_frame_posn(func, value, offset))
{
return 0;
}
--offset;
}
/* Allocate the parameter offsets */
num_params = jit_type_num_params(signature);
for(param = 0; param < num_params; ++param)
{
value = jit_value_get_param(func, param);
if(!value)
{
continue;
}
type = jit_type_normalize(jit_value_get_type(value));
switch(type->kind)
{
case JIT_TYPE_SBYTE:
case JIT_TYPE_UBYTE:
{
if(!jit_insn_incoming_frame_posn
(func, value, offset - _jit_int_lowest_byte()))
{
return 0;
( run in 2.273 seconds using v1.01-cache-2.11-cpan-524268b4103 )