From: Aleksey Demakov Date: Sun, 18 Dec 2005 17:44:54 +0000 (+0000) Subject: Implemented jit_stack_trace_get_offset() X-Git-Tag: r.0.0.6~16 X-Git-Url: https://git.unchartedbackwaters.co.uk/w/?a=commitdiff_plain;h=b3aec502013db047c7a7ccd9f31c03603045a969;p=francis%2Flibjit.git Implemented jit_stack_trace_get_offset() --- diff --git a/ChangeLog b/ChangeLog index 7384174..6d7d108 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2005-12-18 Aleksey Demakov + + * jit/jit-internal.h, jit/jit-function.c (jit_function_compile): + Add cache_start field to the jit_function struct, set it to the start + of the function code cache. + + * jit/jit-except.c (jit_stack_trace_get_offset): implement the + function. + 2005-12-15 Aleksey Demakov * jit/jit-insn.c (jit_insn_address_of): return null if the value is diff --git a/jit/jit-except.c b/jit/jit-except.c index 2f34bf7..f94cfcc 100644 --- a/jit/jit-except.c +++ b/jit/jit-except.c @@ -415,8 +415,28 @@ void *jit_stack_trace_get_pc unsigned int jit_stack_trace_get_offset (jit_context_t context, jit_stack_trace_t trace, unsigned int posn) { - /* TODO */ - return 0; + if(trace && posn < trace->size) + { + jit_cache_t cache = _jit_context_get_cache(context); + if(cache) + { + jit_function_t func = (jit_function_t) _jit_cache_get_method + (cache, trace->items[posn], 0); + if (func) + { +#ifdef JIT_PROLOG_SIZE + unsigned long offset = trace->items[posn] - func->cache_start; + return _jit_cache_get_bytecode + (cache, func->cache_start, offset, 0); +#else + unsigned long offset = trace->items[posn] - func->entry_point; + return _jit_cache_get_bytecode + (cache, func->entry_point, offset, 0); +#endif + } + } + } + return JIT_CACHE_NO_OFFSET; } /*@ diff --git a/jit/jit-function.c b/jit/jit-function.c index 54d6ad6..eb14b79 100644 --- a/jit/jit-function.c +++ b/jit/jit-function.c @@ -684,6 +684,7 @@ int jit_function_compile(jit_function_t func) end = gen.posn.ptr; #ifdef JIT_PROLOG_SIZE + func->cache_start = start; /* Back-patch the function prolog and get the real entry point */ if(have_prolog) { diff --git a/jit/jit-internal.h b/jit/jit-internal.h index e2255aa..33c3519 100644 --- a/jit/jit-internal.h +++ b/jit/jit-internal.h @@ -387,6 +387,12 @@ struct _jit_function /* The function to call to perform on-demand compilation */ jit_on_demand_func on_demand; + /* TODO: This field is used only if JIT_PROLOG_SIZE is defined. + However the header that defines it is included after this one + so "#ifdef JIT_PROLOG_SIZE" does not work here. */ + /* The start of the code cache. */ + void * cache_start; + #ifdef jit_redirector_size /* Buffer that contains the redirector for this function. Redirectors are used to support on-demand compilation */