+2005-12-18 Aleksey Demakov <ademakov@gmail.com>
+
+ * 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 <ademakov@gmail.com>
* jit/jit-insn.c (jit_insn_address_of): return null if the value is
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;
}
/*@
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)
{
/* 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 */