This reduces memory required for System.out.println() from 316 MiB to 286 MiB.
Signed-off-by: Tomek Grabiec <tgrab...@gmail.com> --- arch/x86/stack-frame.c | 3 +-- include/jit/compilation-unit.h | 2 ++ jit/compilation-unit.c | 20 +++++++++++--------- jit/emit.c | 3 +++ 4 files changed, 17 insertions(+), 11 deletions(-) diff --git a/arch/x86/stack-frame.c b/arch/x86/stack-frame.c index 4eba71f..5f207df 100644 --- a/arch/x86/stack-frame.c +++ b/arch/x86/stack-frame.c @@ -109,8 +109,7 @@ unsigned long frame_locals_size(struct stack_frame *frame) */ unsigned long cu_frame_locals_offset(struct compilation_unit *cu) { - unsigned long frame_size = frame_locals_size(cu->stack_frame); - return frame_size * sizeof(unsigned long); + return cu->frame_size; } /* diff --git a/include/jit/compilation-unit.h b/include/jit/compilation-unit.h index 4e56868..ec1047c 100644 --- a/include/jit/compilation-unit.h +++ b/include/jit/compilation-unit.h @@ -102,6 +102,8 @@ struct compilation_unit { * attribute. */ void **exception_handlers; + + unsigned long frame_size; /* Used at run-time by unwind code. */ }; struct compilation_unit *compilation_unit_alloc(struct vm_method *); diff --git a/jit/compilation-unit.c b/jit/compilation-unit.c index 5dce9f3..147c880 100644 --- a/jit/compilation-unit.c +++ b/jit/compilation-unit.c @@ -171,28 +171,30 @@ static void free_lir_insn_map(struct compilation_unit *cu) /* Free everything that is not required at run-time. */ void shrink_compilation_unit(struct compilation_unit *cu) { + struct basic_block *bb, *tmp_bb; + + list_for_each_entry_safe(bb, tmp_bb, &cu->bb_list, bb_list_node) + free_basic_block(bb); + + free_basic_block(cu->exit_bb); + free_basic_block(cu->unwind_bb); + free_var_infos(cu->var_infos); cu->var_infos = NULL; + + free_lir_insn_map(cu); + free_stack_frame(cu->stack_frame); } void free_compilation_unit(struct compilation_unit *cu) { - struct basic_block *bb, *tmp_bb; - shrink_compilation_unit(cu); - list_for_each_entry_safe(bb, tmp_bb, &cu->bb_list, bb_list_node) - free_basic_block(bb); - pthread_mutex_destroy(&cu->mutex); - free_basic_block(cu->exit_bb); - free_basic_block(cu->unwind_bb); free_buffer(cu->objcode); - free_stack_frame(cu->stack_frame); free_bc_offset_map(cu->bc_offset_map); free_lookupswitch_list(cu); free_tableswitch_list(cu); - free_lir_insn_map(cu); free(cu->exception_handlers); free(cu); diff --git a/jit/emit.c b/jit/emit.c index fb049e2..934765b 100644 --- a/jit/emit.c +++ b/jit/emit.c @@ -228,6 +228,9 @@ int emit_machine_code(struct compilation_unit *cu) cu->exit_bb_ptr = bb_native_ptr(cu->exit_bb); cu->unwind_bb_ptr = bb_native_ptr(cu->unwind_bb); + cu->frame_size = frame_locals_size(cu->stack_frame) + * sizeof(unsigned long); + jit_text_reserve(buffer_offset(cu->objcode)); jit_text_unlock(); -- 1.6.0.6 ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ Jatovm-devel mailing list Jatovm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jatovm-devel