]> git.unchartedbackwaters.co.uk Git - francis/libjit.git/commitdiff
Implemented jit_stack_trace_get_offset()
authorAleksey Demakov <ademakov@gmail.com>
Sun, 18 Dec 2005 17:44:54 +0000 (17:44 +0000)
committerAleksey Demakov <ademakov@gmail.com>
Sun, 18 Dec 2005 17:44:54 +0000 (17:44 +0000)
ChangeLog
jit/jit-except.c
jit/jit-function.c
jit/jit-internal.h

index 7384174994fb5b2e4efe3cd78a80b8fd816e6c38..6d7d108861952ac15439e08d788d780bdfafd099 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+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
index 2f34bf76d9b5d622c2f22f2a616eb147cd7a29dd..f94cfcc4a5244035f7679457fd98a8e1da41aeae 100644 (file)
@@ -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;
 }
 
 /*@
index 54d6ad67f42caf1c5b807e503621a207c973c6e6..eb14b7916a515ff350f9ef4516a49b9d1e2d9ddc 100644 (file)
@@ -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)
                {
index e2255aa92290dd2785ff1e3f28abe1945ba79533..33c351956b4084613ea8c7d64cb0a97126d0da85 100644 (file)
@@ -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 */