Alien-LibJIT
view release on metacpan or search on metacpan
libjit/jit/jit-except.c view on Meta::CPAN
if(trace && posn < trace->size)
{
return trace->items[posn];
}
else
{
return 0;
}
}
/*@
* @deftypefun {unsigned int} jit_stack_trace_get_offset (jit_stack_trace_t @var{trace}, unsigned int @var{posn})
* Get the bytecode offset that is recorded for position @var{posn}
* within a stack trace. This will be @code{JIT_NO_OFFSET} if there
* is no bytecode offset associated with @var{posn}.
* @end deftypefun
@*/
unsigned int
jit_stack_trace_get_offset(jit_context_t context, jit_stack_trace_t trace, unsigned int posn)
{
void *func_info;
jit_function_t func;
if(!trace || posn >= trace->size)
{
return JIT_NO_OFFSET;
}
func_info = _jit_memory_find_function_info(context, trace->items[posn]);
if(!func_info)
{
return JIT_NO_OFFSET;
}
func = _jit_memory_get_function(context, func_info);
if(!func)
{
return JIT_NO_OFFSET;
}
return _jit_function_get_bytecode(func, func_info, trace->items[posn], 0);
}
/*@
* @deftypefun void jit_stack_trace_free (jit_stack_trace_t @var{trace})
* Free the memory associated with a stack trace.
* @end deftypefun
@*/
void jit_stack_trace_free(jit_stack_trace_t trace)
{
if(trace)
{
jit_free(trace);
}
}
void _jit_backtrace_push(jit_backtrace_t trace, void *pc)
{
jit_thread_control_t control = _jit_thread_get_control();
if(control)
{
trace->parent = control->backtrace_head;
trace->pc = pc;
trace->security_object = 0;
trace->free_security_object = 0;
control->backtrace_head = trace;
}
else
{
trace->parent = 0;
trace->pc = pc;
trace->security_object = 0;
trace->free_security_object = 0;
}
}
void _jit_backtrace_pop(void)
{
jit_thread_control_t control = _jit_thread_get_control();
jit_backtrace_t trace;
if(control)
{
trace = control->backtrace_head;
if(trace)
{
control->backtrace_head = trace->parent;
if(trace->security_object && trace->free_security_object)
{
(*(trace->free_security_object))(trace->security_object);
}
}
}
}
void _jit_backtrace_set(jit_backtrace_t trace)
{
jit_thread_control_t control = _jit_thread_get_control();
if(control)
{
control->backtrace_head = trace;
}
}
void _jit_unwind_push_setjmp(jit_jmp_buf *jbuf)
{
jit_thread_control_t control = _jit_thread_get_control();
if(control)
{
jbuf->trace = control->backtrace_head;
jbuf->catch_pc = 0;
jbuf->parent = control->setjmp_head;
control->setjmp_head = jbuf;
}
}
void _jit_unwind_pop_setjmp(void)
{
jit_thread_control_t control = _jit_thread_get_control();
if(control && control->setjmp_head)
{
control->backtrace_head = control->setjmp_head->trace;
control->setjmp_head = control->setjmp_head->parent;
}
}
void _jit_unwind_pop_and_rethrow(void)
{
_jit_unwind_pop_setjmp();
jit_exception_throw(jit_exception_get_last());
}
( run in 0.854 second using v1.01-cache-2.11-cpan-4991d5b9bd9 )