]> git.unchartedbackwaters.co.uk Git - francis/libjit.git/commitdiff
add jit_cache_get_start_method() and remove jit_function.start_address field
authorAleksey Demakov <ademakov@gmail.com>
Sat, 24 Dec 2005 06:55:13 +0000 (06:55 +0000)
committerAleksey Demakov <ademakov@gmail.com>
Sat, 24 Dec 2005 06:55:13 +0000 (06:55 +0000)
ChangeLog
jit/jit-cache.c
jit/jit-cache.h
jit/jit-except.c
jit/jit-internal.h

index 18de454a5dd4e2c3d76034a39794857d0415dad7..706bd42f5c1f654121a8653626421b40c7d6fa39 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
        * dpas/dpas-parser.y (throw_builtin_exception): add static function
        that makes jit_exception_builtin call.
 
+       * jit/jit-cache.c (_jit_cache_get_start_method): add function that
+       for an address in cache returns the start address of the block that
+       contains it.
+       * jit/jit-except.c (jit_stack_trace_get_offset): use
+       _jit_cache_get_start_method function instead of cache_start field.
+       * jit/jit-internal.h, jit/jit-function.c (jit_function_compile):
+       remove cache_start field to the jit_function struct.
+
 2005-12-22  Aleksey Demakov  <ademakov@gmail.com>
 
        * jit/jit-rules-x86.sel: implement JIT_OP_MEMSET and JIT_OP_MEMCPY
index 4114bd7801a0defbfab4051b3790f40c85b1e5be..5060b0abfc7d07d59b97cbe4139ee7ad804c6c86 100644 (file)
@@ -1014,6 +1014,28 @@ static int add_parent(jit_cache_method_t *parent_buf,
        return 1;
 }
 
+void *_jit_cache_get_start_method(jit_cache_t cache, void *pc)
+{
+       /* TODO: This function is not currently aware of multiple regions. */
+       jit_cache_method_t node = cache->head.right;
+       while(node != &(cache->nil))
+       {
+               if(((unsigned char *)pc) < node->start)
+               {
+                       node = GetLeft(node);
+               }
+               else if(((unsigned char *)pc) >= node->end)
+               {
+                       node = GetRight(node);
+               }
+               else
+               {
+                       return node->start;
+               }
+       }
+       return 0;
+}
+
 void *_jit_cache_get_end_method(jit_cache_t cache, void *pc)
 {
        jit_cache_method_t parent_buf[16];
index 25cf30568c376ebf4073ae5fd952e1e984a7e6d8..926b20584985c88eb253cd51fb186e5b4b9c9ef6 100644 (file)
@@ -129,6 +129,16 @@ void _jit_cache_set_cookie(jit_cache_posn *posn, void *cookie);
  */
 void *_jit_cache_get_method(jit_cache_t cache, void *pc, void **cookie);
 
+/*
+ * Get the start of a method with a particular starting PC.
+ * Returns NULL if the PC could not be located.
+ * NOTE: This function is not currently aware of the
+ * possibility of multiple regions per function. To ensure
+ * correct results the ``pc'' argument has to be in the
+ * first region.
+ */
+void *_jit_cache_get_start_method(jit_cache_t cache, void *pc);
+
 /*
  * Get the end of a method with a particular starting PC.
  * Returns NULL if the PC could not be located.
index 942900a75da085989a4defbe8832359a4dacab48..5183d85b4089916543cf96d5dee109024e206072 100644 (file)
@@ -426,14 +426,13 @@ unsigned int jit_stack_trace_get_offset
                        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);
+                               void *start = _jit_cache_get_start_method
+                                       (cache, func->entry_point);
 #else
-                               unsigned long offset = trace->items[posn] - func->entry_point;
-                               return _jit_cache_get_bytecode
-                                       (cache, func->entry_point, offset, 0);
+                               void *start = func->entry_point;
 #endif
+                               unsigned long offset = trace->items[posn] - start;
+                               return _jit_cache_get_bytecode(cache, start, offset, 0);
                        }
                }
        }
index 33c351956b4084613ea8c7d64cb0a97126d0da85..e2255aa92290dd2785ff1e3f28abe1945ba79533 100644 (file)
@@ -387,12 +387,6 @@ 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 */