diff --git a/ase/awk/awk_i.h b/ase/awk/awk_i.h index c4e17861..95e62e20 100644 --- a/ase/awk/awk_i.h +++ b/ase/awk/awk_i.h @@ -255,6 +255,9 @@ struct ase_awk_run_t /*ase_size_t scache32_count; ase_size_t scache64_count;*/ + ase_awk_val_int_t* ifree; + ase_awk_val_chunk_t* ichunk; + ase_awk_nde_blk_t* active_block; ase_byte_t* pattern_range_state; diff --git a/ase/awk/run.c b/ase/awk/run.c index 546b087b..c00e5153 100644 --- a/ase/awk/run.c +++ b/ase/awk/run.c @@ -747,6 +747,8 @@ static int init_run ( run->fcache_count = 0; /*run->scache32_count = 0; run->scache64_count = 0;*/ + run->ichunk = ASE_NULL; + run->ifree = ASE_NULL; run->errnum = ASE_AWK_ENOERR; run->errlin = 0; @@ -976,6 +978,13 @@ static void deinit_run (ase_awk_run_t* run) ase_awk_val_str_t* tmp = run->scache64[--run->scache64_count]; ase_awk_freeval (run, (ase_awk_val_t*)tmp, ase_false); }*/ + + while (run->ichunk != ASE_NULL) + { + ase_awk_val_pool_t* next = run->ichunk->next; + ASE_AWK_FREE (run->awk, run->ichunk); + run->ichunk = next; + } } static int build_runarg ( diff --git a/ase/awk/val.c b/ase/awk/val.c index 7c8385e5..3d9767fb 100644 --- a/ase/awk/val.c +++ b/ase/awk/val.c @@ -68,6 +68,7 @@ ase_awk_val_t* ase_awk_makeintval (ase_awk_run_t* run, ase_long_t v) return (ase_awk_val_t*)&awk_int[v-awk_int[0].val]; } + /* if (run->icache_count > 0) { val = run->icache[--run->icache_count]; @@ -82,6 +83,35 @@ ase_awk_val_t* ase_awk_makeintval (ase_awk_run_t* run, ase_long_t v) return ASE_NULL; } } + */ + ase_awk_val_pool_t* p = run->ipool; + ase_awk_val_int_t* f = run->ifree; + + if (f = ASE_NULL) + { + ase_awk_val_int_t* x; + ase_size_t i; + + p = ASE_AWK_MALLOC (run->awk, + ASE_SIZEOF(ase_awk_val_pool_t)+ + ASE_SIZEOF(ase_awk_val_int_t)*100); + if (p == ASE_NULL) + { + ase_awk_setrunerrnum (run, ASE_AWK_ENOMEM); + return ASE_NULL; + } + + x = (ase_awk_val_int_t*)(p + 1); + for (i = 0; i < 100-1; i++) f + x[i].nde = (ase_awk_nde_int_t*)&x[i+1]; + x[i].nde = ASE_NULL; + + run->ifree = &f[0]; + p->next = run->ipool; + } + + val = run->ifree; + p->ifree = (ase_awk_val_int_t*)p->ifree->nde; val->type = ASE_AWK_VAL_INT; val->ref = 0; @@ -385,12 +415,20 @@ void ase_awk_freeval (ase_awk_run_t* run, ase_awk_val_t* val, ase_bool_t cache) } else if (val->type == ASE_AWK_VAL_INT) { + /* if (cache && run->icache_count < ASE_COUNTOF(run->icache)) { run->icache[run->icache_count++] = (ase_awk_val_int_t*)val; } else ASE_AWK_FREE (run->awk, val); + */ + if (cache) + { + val->nde = (ase_awk_val_nde_t*)run->ifree; + run->ifree = val; + } + else ASE_AWK_FREE (run->awk, val); } else if (val->type == ASE_AWK_VAL_REAL) { diff --git a/ase/awk/val.h b/ase/awk/val.h index 06dd6f2a..f47551b0 100644 --- a/ase/awk/val.h +++ b/ase/awk/val.h @@ -59,6 +59,9 @@ typedef struct ase_awk_val_rex_t ase_awk_val_rex_t; typedef struct ase_awk_val_map_t ase_awk_val_map_t; typedef struct ase_awk_val_ref_t ase_awk_val_ref_t; +/* this is not a value. it is just a value holder */ +typedef struct ase_awk_val_chunk_t ase_awk_val_chunk_t; + #if ASE_SIZEOF_INT == 2 #define ASE_AWK_VAL_HDR \ unsigned int type: 3; \ @@ -149,6 +152,11 @@ struct ase_awk_val_ref_t ase_awk_val_t** adr; }; +struct ase_awk_val_chunk_t +{ + ase_awk_val_chunk_t* next; +}; + #ifdef __cplusplus extern "C" { #endif