From 66998aa42992c94fc88c7f32be3c75dd4282662b Mon Sep 17 00:00:00 2001 From: Stephan Hadinger Date: Mon, 30 Aug 2021 19:10:17 +0200 Subject: [PATCH] Berry constant search size --- lib/libesp32/Berry/default/berry_conf.h | 10 ++++++++++ lib/libesp32/Berry/src/be_code.c | 4 ++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/libesp32/Berry/default/berry_conf.h b/lib/libesp32/Berry/default/berry_conf.h index e51ebd1a7..6f0f4a807 100644 --- a/lib/libesp32/Berry/default/berry_conf.h +++ b/lib/libesp32/Berry/default/berry_conf.h @@ -85,6 +85,16 @@ **/ #define BE_STACK_FREE_MIN 20 +/* Macro: BE_CONST_SEARCH_SIZE + * Constants in function are limited to 255. However the compiler + * will look for a maximum of pre-existing constants to avoid + * performance degradation. This may cause the number of constants + * to be higher than required. + * Increase is you need to solidify functions. + * Default: 50 + **/ +#define BE_CONST_SEARCH_SIZE 150 + /* Macro: BE_STACK_FREE_MIN * The short string will hold the hash value when the value is * true. It may be faster but requires more RAM. diff --git a/lib/libesp32/Berry/src/be_code.c b/lib/libesp32/Berry/src/be_code.c index cf1a265b3..b0feff4e1 100644 --- a/lib/libesp32/Berry/src/be_code.c +++ b/lib/libesp32/Berry/src/be_code.c @@ -251,7 +251,7 @@ static int newconst(bfuncinfo *finfo, bvalue *k) } /* Find constant by value and return constant number, or -1 if constant does not exist */ -/* The search is linear and limited to 100 elements for performance reasons */ +/* The search is linear and limited to BE_CONST_SEARCH_SIZE elements for performance reasons */ static int findconst(bfuncinfo *finfo, bexpdesc *e) { int i, count = be_vector_count(&finfo->kvec); @@ -260,7 +260,7 @@ static int findconst(bfuncinfo *finfo, bexpdesc *e) * so only search the constant table for the * previous value. **/ - count = count < 100 ? count : 100; + count = count < BE_CONST_SEARCH_SIZE ? count : BE_CONST_SEARCH_SIZE; for (i = 0; i < count; ++i) { bvalue *k = be_vector_at(&finfo->kvec, i); switch (e->type) {