From 411ee75e7dfd4a79d303627652b32902942e5146 Mon Sep 17 00:00:00 2001 From: gambas Date: Wed, 21 Aug 2019 22:08:45 +0200 Subject: [PATCH] Fix JIT compilation when there are a lot of functions. [INTERPRETER] * BUG: Fix JIT compilation when there are a lot of functions. --- main/gbx/gbx_jit.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/main/gbx/gbx_jit.c b/main/gbx/gbx_jit.c index 716f8b47f..40f2b1ad5 100644 --- a/main/gbx/gbx_jit.c +++ b/main/gbx/gbx_jit.c @@ -186,6 +186,7 @@ static bool create_function(CLASS *class, int index) int i; int len; char *name; + int jit_index; arch = class->component ? class->component->archive : NULL; @@ -231,14 +232,15 @@ static bool create_function(CLASS *class, int index) if (!_jit_func) ARRAY_create(&_jit_func); - + + jit_index = ARRAY_count(_jit_func); jit = (JIT_FUNCTION *)ARRAY_add(&_jit_func); jit->addr = addr; jit->code = func->code; - func->code = (PCODE *)jit; - + func->code = (PCODE *)(intptr_t)jit_index; + return FALSE; } @@ -271,7 +273,7 @@ bool JIT_exec(bool ret_on_stack) FP = func; EC = NULL; - jit = (JIT_FUNCTION *)(func->code); + jit = &_jit_func[(intptr_t)func->code]; PROFILE_ENTER_FUNCTION(); @@ -327,7 +329,7 @@ bool JIT_exec(bool ret_on_stack) PCODE *JIT_get_code(FUNCTION *func) { if (func->fast_linked) - return ((JIT_FUNCTION *)(func->code))->code; + return _jit_func[(intptr_t)func->code].code; else return func->code; }