Cleanups in include/jit/exception.h, jit/exception.c, jit/cfg-analyzer.c. Signed-off-by: Tomek Grabiec <tgrab...@gmail.com> --- include/jit/exception.h | 22 ++++++++---------- jit/cfg-analyzer.c | 8 ++---- jit/exception.c | 54 +++++++++++++++++++++++++--------------------- 3 files changed, 42 insertions(+), 42 deletions(-)
diff --git a/include/jit/exception.h b/include/jit/exception.h index 775108d..bd9b63e 100644 --- a/include/jit/exception.h +++ b/include/jit/exception.h @@ -34,23 +34,15 @@ extern void *trampoline_exceptions_guard_page; */ extern __thread struct object *exception_holder; -struct exception_table_entry *exception_find_entry(struct methodblock *, - unsigned long); - -static inline bool exception_covers(struct exception_table_entry *eh, - unsigned long offset) -{ - return eh->start_pc <= offset && offset < eh->end_pc; -} +struct exception_table_entry *lookup_eh_entry(struct methodblock *method, + unsigned long target); unsigned char *throw_exception_from(struct compilation_unit *cu, struct jit_stack_frame *frame, unsigned char *native_ptr); -int insert_exception_spill_insns(struct compilation_unit *cu); -/* This should be called only by JIT compiled native code */ -unsigned char *throw_exception(struct compilation_unit *cu, - struct object *exception); +int insert_exception_spill_insns(struct compilation_unit *cu); +unsigned char *throw_exception(struct compilation_unit *, struct object *); void throw_exception_from_signal(void *ctx, struct object *exception); void throw_exception_from_trampoline(void *ctx, struct object *exception); void unwind(void); @@ -60,6 +52,12 @@ void clear_exception(void); void init_exceptions(void); void thread_init_exceptions(void); +static inline bool +exception_covers(struct exception_table_entry *eh, unsigned long offset) +{ + return eh->start_pc <= offset && offset < eh->end_pc; +} + static inline struct object *exception_occurred(void) { return exception_holder; diff --git a/jit/cfg-analyzer.c b/jit/cfg-analyzer.c index f8f7a0d..c3d06cf 100644 --- a/jit/cfg-analyzer.c +++ b/jit/cfg-analyzer.c @@ -21,17 +21,15 @@ static bool is_exception_handler(struct basic_block *bb) { - return exception_find_entry(bb->b_parent->method, bb->start) != NULL; + return lookup_eh_entry(bb->b_parent->method, bb->start) != NULL; } static void detect_exception_handlers(struct compilation_unit *cu) { struct basic_block *bb; - for_each_basic_block(bb, &cu->bb_list) { - if (is_exception_handler(bb)) - bb->is_eh = true; - } + for_each_basic_block(bb, &cu->bb_list) + bb->is_eh = is_exception_handler(bb); } static int update_branch_successors(struct compilation_unit *cu) diff --git a/jit/exception.c b/jit/exception.c index 93ca53d..67712c1 100644 --- a/jit/exception.c +++ b/jit/exception.c @@ -103,14 +103,15 @@ void clear_exception(void) exception_holder = NULL; } -struct exception_table_entry *exception_find_entry(struct methodblock *method, - unsigned long target) +struct exception_table_entry * +lookup_eh_entry(struct methodblock *method, unsigned long target) { int i; for (i = 0; i < method->exception_table_size; i++) { - struct exception_table_entry *eh = &method->exception_table[i]; + struct exception_table_entry *eh; + eh = &method->exception_table[i]; if (eh->handler_pc == target) return eh; } @@ -118,11 +119,12 @@ struct exception_table_entry *exception_find_entry(struct methodblock *method, return NULL; } -static unsigned char *eh_native_ptr(struct compilation_unit *cu, - struct exception_table_entry *eh) +static unsigned char * +eh_native_ptr(struct compilation_unit *cu, struct exception_table_entry *eh) { - struct basic_block *bb = find_bb(cu, eh->handler_pc); + struct basic_block *bb; + bb = find_bb(cu, eh->handler_pc); assert(bb != NULL); return bb_native_ptr(bb); @@ -132,31 +134,33 @@ static unsigned char *eh_native_ptr(struct compilation_unit *cu, * find_handler - return native pointer to exception handler for given * @exception_class and @bc_offset of source. */ -static unsigned char *find_handler(struct compilation_unit *cu, - Class *exception_class, - unsigned long bc_offset) +static unsigned char * +find_handler(struct compilation_unit *cu, struct object *exception_class, + unsigned long bc_offset) { struct exception_table_entry *eh; - struct methodblock *method = cu->method; - int size = method->exception_table_size; + struct methodblock *mb; + int size; int i; + mb = cu->method; + size = mb->exception_table_size; + for (i = 0; i < size; i++) { - eh = &method->exception_table[i]; + struct object *catch_class; - if (exception_covers(eh, bc_offset)) { - Class *catch_class; + eh = &mb->exception_table[i]; - if (eh->catch_type == 0) - break; /* It's a finally block */ + if (!exception_covers(eh, bc_offset)) + continue; - catch_class = resolveClass(method->class, - eh->catch_type, - false); + if (eh->catch_type == 0) + break; /* This matches to everything. */ - if (isInstanceOf(catch_class, exception_class)) - break; - } + catch_class = resolveClass(mb->class, eh->catch_type, false); + + if (isInstanceOf(catch_class, exception_class)) + break; } if (i < size) @@ -193,9 +197,9 @@ is_inside_unwind_unlock(struct compilation_unit *cu, unsigned char *ptr) * @frame: frame pointer of method throwing exception * @native_ptr: pointer to instruction that caused exception */ -unsigned char *throw_exception_from(struct compilation_unit *cu, - struct jit_stack_frame *frame, - unsigned char *native_ptr) +unsigned char * +throw_exception_from(struct compilation_unit *cu, struct jit_stack_frame *frame, + unsigned char *native_ptr) { struct object *exception; unsigned long bc_offset; -- 1.6.0.6 ------------------------------------------------------------------------------ Are you an open source citizen? Join us for the Open Source Bridge conference! Portland, OR, June 17-19. Two days of sessions, one day of unconference: $250. Need another reason to go? 24-hour hacker lounge. Register today! http://ad.doubleclick.net/clk;215844324;13503038;v?http://opensourcebridge.org _______________________________________________ Jatovm-devel mailing list Jatovm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jatovm-devel