From 44d7c093c2c9a14ce46824c077637d32f88edb5a Mon Sep 17 00:00:00 2001 From: Aleksey Demakov Date: Sat, 24 Dec 2005 06:55:13 +0000 Subject: [PATCH] add jit_cache_get_start_method() and remove jit_function.start_address field --- ChangeLog | 8 ++++++++ jit/jit-cache.c | 22 ++++++++++++++++++++++ jit/jit-cache.h | 10 ++++++++++ jit/jit-except.c | 11 +++++------ jit/jit-internal.h | 6 ------ 5 files changed, 45 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index 18de454..706bd42 100644 --- a/ChangeLog +++ b/ChangeLog @@ -11,6 +11,14 @@ * 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 * jit/jit-rules-x86.sel: implement JIT_OP_MEMSET and JIT_OP_MEMCPY diff --git a/jit/jit-cache.c b/jit/jit-cache.c index 4114bd7..5060b0a 100644 --- a/jit/jit-cache.c +++ b/jit/jit-cache.c @@ -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]; diff --git a/jit/jit-cache.h b/jit/jit-cache.h index 25cf305..926b205 100644 --- a/jit/jit-cache.h +++ b/jit/jit-cache.h @@ -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. diff --git a/jit/jit-except.c b/jit/jit-except.c index 942900a..5183d85 100644 --- a/jit/jit-except.c +++ b/jit/jit-except.c @@ -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); } } } diff --git a/jit/jit-internal.h b/jit/jit-internal.h index 33c3519..e2255aa 100644 --- a/jit/jit-internal.h +++ b/jit/jit-internal.h @@ -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 */ -- 2.47.3