Alien-LibJIT
view release on metacpan or search on metacpan
libjit/jit/jit-insn.c view on Meta::CPAN
{
return 1;
}
#endif
/* If the kinds are not the same now, then we don't have a match */
if(type1->kind != type2->kind)
{
return 0;
}
/* Structure and union types must have the same size and alignment */
if(type1->kind == JIT_TYPE_STRUCT || type1->kind == JIT_TYPE_UNION)
{
return (jit_type_get_size(type1) == jit_type_get_size(type2) &&
jit_type_get_alignment(type1) == jit_type_get_alignment(type2));
}
/* Signature types must be compared component-by-component */
if(type1->kind == JIT_TYPE_SIGNATURE)
{
if(type1->abi != type2->abi)
{
return 0;
}
if(!signature_identical(type1->sub_type, type2->sub_type))
{
return 0;
}
if(type1->num_components != type2->num_components)
{
return 0;
}
for(param = 0; param < type1->num_components; ++param)
{
if(!signature_identical(type1->components[param].type,
type2->components[param].type))
{
return 0;
}
}
}
/* If we get here, then the types are compatible */
return 1;
}
/*
* Create call setup instructions, taking tail calls into effect.
*/
static int create_call_setup_insns
(jit_function_t func, jit_function_t callee, jit_type_t signature,
jit_value_t *args, unsigned int num_args,
int is_nested, int nesting_level, jit_value_t *struct_return, int flags)
{
jit_value_t *new_args;
jit_value_t value;
unsigned int arg_num;
/* If we are performing a tail call, then duplicate the argument
values so that we don't accidentally destroy parameters in
situations like func(x, y) -> func(y, x) */
if((flags & JIT_CALL_TAIL) != 0 && num_args > 0)
{
new_args = (jit_value_t *)alloca(sizeof(jit_value_t) * num_args);
for(arg_num = 0; arg_num < num_args; ++arg_num)
{
value = args[arg_num];
if(value && value->is_parameter)
{
value = jit_insn_dup(func, value);
if(!value)
{
return 0;
}
}
new_args[arg_num] = value;
}
args = new_args;
}
/* If we are performing a tail call, then store back to our own parameters */
if((flags & JIT_CALL_TAIL) != 0)
{
for(arg_num = 0; arg_num < num_args; ++arg_num)
{
if(!jit_insn_store(func, jit_value_get_param(func, arg_num),
args[arg_num]))
{
return 0;
}
}
*struct_return = 0;
return 1;
}
/* Let the back end do the work */
return _jit_create_call_setup_insns
(func, signature, args, num_args,
is_nested, nesting_level, struct_return, flags);
}
static jit_value_t
handle_return(jit_function_t func,
jit_type_t signature,
int flags, int is_nested,
jit_value_t *args, unsigned int num_args,
jit_value_t return_value)
{
/* If the function does not return, then end the current block.
The next block does not have "entered_via_top" set so that
it will be eliminated during later code generation */
if((flags & (JIT_CALL_NORETURN | JIT_CALL_TAIL)) != 0)
{
func->builder->current_block->ends_in_dead = 1;
}
/* If the function may throw an exceptions then end the current
basic block to account for exceptional control flow */
if((flags & JIT_CALL_NOTHROW) == 0)
{
( run in 0.845 second using v1.01-cache-2.11-cpan-524268b4103 )