From 073a6d9e9064dc99495787636d963ac077c54054 Mon Sep 17 00:00:00 2001 From: Emil Lenngren Date: Thu, 24 May 2012 12:27:16 +0000 Subject: [PATCH] [INTERPRETER] * OPT: Don't allocate array for jit functions if not necessary. git-svn-id: svn://localhost/gambas/trunk@4770 867c0c6c-44f3-4631-809d-bfa615b0a4ec --- main/gbx/gbx_class.c | 3 ++- main/gbx/gbx_class_load.c | 12 +++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/main/gbx/gbx_class.c b/main/gbx/gbx_class.c index d8cd78013..5183a449c 100644 --- a/main/gbx/gbx_class.c +++ b/main/gbx/gbx_class.c @@ -157,7 +157,8 @@ static void unload_class(CLASS *class) #endif - FREE(&class->jit_functions, "unload_class"); + if (class->jit_functions) + FREE(&class->jit_functions, "unload_class"); FREE(&class->load, "unload_class"); if (!class->mmapped) diff --git a/main/gbx/gbx_class_load.c b/main/gbx/gbx_class_load.c index e91e54cd5..832af88a8 100644 --- a/main/gbx/gbx_class_load.c +++ b/main/gbx/gbx_class_load.c @@ -494,6 +494,7 @@ static void load_and_relocate(CLASS *class, int len_data, CLASS_DESC **pstart, i int size; char *name; int len; + bool have_jit_functions = FALSE; ALLOC_ZERO(&class->load, sizeof(CLASS_LOAD), "CLASS_load"); @@ -576,6 +577,8 @@ static void load_and_relocate(CLASS *class, int len_data, CLASS_DESC **pstart, i func->code = (ushort *)get_section("code", §ion, NULL, _s); if (func->fast) func->fast = JIT_load(); + if (func->fast) + have_jit_functions = TRUE; } /* Creation flags */ @@ -886,10 +889,13 @@ static void load_and_relocate(CLASS *class, int len_data, CLASS_DESC **pstart, i /* JIT function pointers */ - ALLOC_ZERO(&class->jit_functions, sizeof(void(*)(void)) * class->load->n_func, "CLASS_load"); - for(i = 0; i < class->load->n_func; i++) + if (have_jit_functions) { - class->jit_functions[i] = JIT_default_jit_function; + ALLOC_ZERO(&class->jit_functions, sizeof(void(*)(void)) * class->load->n_func, "CLASS_load"); + for(i = 0; i < class->load->n_func; i++) + { + class->jit_functions[i] = JIT_default_jit_function; + } } }