From c1ffc899fe7fadfee621fa6eae82a6a39fefd648 Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Wed, 25 Mar 2020 06:22:25 +0000 Subject: [PATCH] some more code cleanup --- hawk/lib/Hawk.cpp | 2 +- hawk/lib/hawk-prv.h | 61 ++++++++------- hawk/lib/parse.c | 14 ++-- hawk/lib/rec.c | 2 +- hawk/lib/run.c | 175 ++++++++++++++++++++++---------------------- hawk/lib/val-prv.h | 4 +- hawk/lib/val.c | 46 ++++++------ 7 files changed, 158 insertions(+), 146 deletions(-) diff --git a/hawk/lib/Hawk.cpp b/hawk/lib/Hawk.cpp index 99fd64e2..b0e983d0 100644 --- a/hawk/lib/Hawk.cpp +++ b/hawk/lib/Hawk.cpp @@ -1966,7 +1966,7 @@ int Hawk::dispatch_function (Run* run, const hawk_fnc_info_t* fi) case hawk_val_ref_t::HAWK_VAL_REF_GBL: { hawk_oow_t idx = (hawk_oow_t)ref->adr; - hawk_val_t* val = (hawk_val_t*)RTX_STACK_GBL(run->rtx, idx); + hawk_val_t* val = (hawk_val_t*)HAWK_RTX_STACK_GBL(run->rtx, idx); xx = args[i].setVal (run, val); break; } diff --git a/hawk/lib/hawk-prv.h b/hawk/lib/hawk-prv.h index 03892c37..6fa89ea6 100644 --- a/hawk/lib/hawk-prv.h +++ b/hawk/lib/hawk-prv.h @@ -51,15 +51,6 @@ typedef struct hawk_tree_t hawk_tree_t; #define HAWK_ENABLE_GC #define HAWK_ENABLE_STR_CACHE #define HAWK_ENABLE_MBS_CACHE - -#define HAWK_STR_CACHE_NUM_BLOCKS 16 -#define HAWK_STR_CACHE_BLOCK_UNIT 16 -#define HAWK_STR_CACHE_BLOCK_SIZE 128 - -#define HAWK_MBS_CACHE_NUM_BLOCKS 16 -#define HAWK_MBS_CACHE_BLOCK_UNIT 16 -#define HAWK_MBS_CACHE_BLOCK_SIZE 128 - /* [NOTE] the function value support implemented is very limited. * it supports very primitive way to call a function via a variable. * only user-defined functions are supported. neither builtin functions @@ -74,20 +65,41 @@ typedef struct hawk_tree_t hawk_tree_t; * function show(printer, a,b,c) { printer(a, b, c); } * BEGIN { show(__printer, 10, 20, 30); } ## passing the function value as an argumnet is ok. */ -#define ENABLE_FEATURE_FUN_AS_VALUE +#define HAWK_ENABLE_FUN_AS_VALUE -#define HAWK_MAX_GBLS 9999 -#define HAWK_MAX_LCLS 9999 -#define HAWK_MAX_PARAMS 9999 +/* ------------------------------------------------------------------------ */ -#define HAWK_DFL_RTX_STACK_LIMIT 5120 -#define HAWK_MIN_RTX_STACK_LIMIT 512 +/* gc configuration */ +#define HAWK_GC_NUM_GENS (3) + +/* string cache configuration */ +#define HAWK_STR_CACHE_NUM_BLOCKS (16) +#define HAWK_STR_CACHE_BLOCK_UNIT (16) +#define HAWK_STR_CACHE_BLOCK_SIZE (128) + +/* byte string cache configuration */ +#define HAWK_MBS_CACHE_NUM_BLOCKS (16) +#define HAWK_MBS_CACHE_BLOCK_UNIT (16) +#define HAWK_MBS_CACHE_BLOCK_SIZE (128) + +/* maximum number of globals, locals, parameters allowed in parsing */ +#define HAWK_MAX_GBLS (9999) +#define HAWK_MAX_LCLS (9999) +#define HAWK_MAX_PARAMS (9999) + + +/* runtime stack limit */ +#define HAWK_DFL_RTX_STACK_LIMIT (5120) +#define HAWK_MIN_RTX_STACK_LIMIT (512) #if (HAWK_SIZEOF_VOID_P <= 4) # define HAWK_MAX_RTX_STACK_LIMIT ((hawk_oow_t)1 << (HAWK_SIZEOF_VOID_P * 4 + 1)) #else # define HAWK_MAX_RTX_STACK_LIMIT ((hawk_oow_t)1 << (HAWK_SIZEOF_VOID_P * 4)) #endif +/* ------------------------------------------------------------------------ */ + + #define HAWK_BYTE_PRINTABLE(x) ((x) <= 0x7F && (x) != '\\' && hawk_is_bch_print(x)) #if defined(__has_builtin) @@ -350,13 +362,13 @@ struct hawk_chain_t hawk_chain_t* next; }; -#define RTX_STACK_AT(rtx,n) ((rtx)->stack[(rtx)->stack_base+(n)]) -#define RTX_STACK_NARGS(rtx) RTX_STACK_AT(rtx,3) -#define RTX_STACK_ARG(rtx,n) RTX_STACK_AT(rtx,3+1+(n)) -#define RTX_STACK_LCL(rtx,n) RTX_STACK_AT(rtx,3+(hawk_oow_t)RTX_STACK_NARGS(rtx)+1+(n)) -#define RTX_STACK_RETVAL(rtx) RTX_STACK_AT(rtx,2) -#define RTX_STACK_GBL(rtx,n) ((rtx)->stack[(n)]) -#define RTX_STACK_RETVAL_GBL(rtx) ((rtx)->stack[(rtx)->hawk->tree.ngbls+2]) +#define HAWK_RTX_STACK_AT(rtx,n) ((rtx)->stack[(rtx)->stack_base+(n)]) +#define HAWK_RTX_STACK_NARGS(rtx) HAWK_RTX_STACK_AT(rtx,3) +#define HAWK_RTX_STACK_ARG(rtx,n) HAWK_RTX_STACK_AT(rtx,3+1+(n)) +#define HAWK_RTX_STACK_LCL(rtx,n) HAWK_RTX_STACK_AT(rtx,3+(hawk_oow_t)HAWK_RTX_STACK_NARGS(rtx)+1+(n)) +#define HAWK_RTX_STACK_RETVAL(rtx) HAWK_RTX_STACK_AT(rtx,2) +#define HAWK_RTX_STACK_GBL(rtx,n) ((rtx)->stack[(n)]) +#define HAWK_RTX_STACK_RETVAL_GBL(rtx) ((rtx)->stack[(rtx)->hawk->tree.ngbls+2]) struct hawk_rtx_t { @@ -394,9 +406,8 @@ struct hawk_rtx_t struct { int collecting; - hawk_oow_t all_count; - hawk_gch_t all; /* allocated objects */ - hawk_gch_t saved; /* objects to preserve */ + hawk_oow_t c[HAWK_GC_NUM_GENS]; + hawk_gch_t g[HAWK_GC_NUM_GENS]; } gc; hawk_nde_blk_t* active_block; diff --git a/hawk/lib/parse.c b/hawk/lib/parse.c index 83827357..459f8ad0 100644 --- a/hawk/lib/parse.c +++ b/hawk/lib/parse.c @@ -5254,7 +5254,7 @@ static hawk_nde_t* parse_variable (hawk_t* awk, const hawk_loc_t* xloc, hawk_nde if (MATCH(awk,TOK_LPAREN)) { - #if defined(ENABLE_FEATURE_FUN_AS_VALUE) + #if defined(HAWK_ENABLE_FUN_AS_VALUE) /* if (MATCH(awk,TOK_LPAREN) && (!(awk->opt.trait & HAWK_BLANKCONCAT) || @@ -5296,7 +5296,7 @@ static hawk_nde_t* parse_variable (hawk_t* awk, const hawk_loc_t* xloc, hawk_nde nde->id.idxa = idxa; nde->idx = HAWK_NULL; -#if defined(ENABLE_FEATURE_FUN_AS_VALUE) +#if defined(HAWK_ENABLE_FUN_AS_VALUE) if (!is_fcv) return (hawk_nde_t*)nde; return parse_fncall(awk, (const hawk_oocs_t*)nde, HAWK_NULL, xloc, FNCALL_FLAG_VAR); #else @@ -5357,7 +5357,7 @@ oops: return -1; } -#if defined(ENABLE_FEATURE_FUN_AS_VALUE) +#if defined(HAWK_ENABLE_FUN_AS_VALUE) static hawk_nde_t* parse_fun_as_value (hawk_t* awk, const hawk_oocs_t* name, const hawk_loc_t* xloc, hawk_fun_t* funptr) { hawk_nde_fun_t* nde; @@ -5461,7 +5461,7 @@ static hawk_nde_t* parse_primary_ident_noseg (hawk_t* awk, const hawk_loc_t* xlo else { /* function name appeared without (). used as a value without invocation */ - #if defined(ENABLE_FEATURE_FUN_AS_VALUE) + #if defined(HAWK_ENABLE_FUN_AS_VALUE) nde = parse_fun_as_value(awk, name, xloc, funptr); #else hawk_seterrfmt (awk, xloc, HAWK_EFUNRED, HAWK_T("function '%.*js' redefined"), name->len, name->ptr); @@ -5490,7 +5490,7 @@ static hawk_nde_t* parse_primary_ident_noseg (hawk_t* awk, const hawk_loc_t* xlo if (hawk_htb_search(awk->parse.named, name->ptr, name->len) != HAWK_NULL) { /* the function call conflicts with a named variable */ - #if defined(ENABLE_FEATURE_FUN_AS_VALUE) + #if defined(HAWK_ENABLE_FUN_AS_VALUE) is_fncall_var = 1; goto named_var; #else @@ -5506,7 +5506,7 @@ static hawk_nde_t* parse_primary_ident_noseg (hawk_t* awk, const hawk_loc_t* xlo { hawk_nde_var_t* tmp; - #if defined(ENABLE_FEATURE_FUN_AS_VALUE) + #if defined(HAWK_ENABLE_FUN_AS_VALUE) named_var: #endif @@ -5535,7 +5535,7 @@ static hawk_nde_t* parse_primary_ident_noseg (hawk_t* awk, const hawk_loc_t* xlo tmp->idx = HAWK_NULL; nde = (hawk_nde_t*)tmp; - #if defined(ENABLE_FEATURE_FUN_AS_VALUE) + #if defined(HAWK_ENABLE_FUN_AS_VALUE) if (is_fncall_var) nde = parse_fncall(awk, (const hawk_oocs_t*)nde, HAWK_NULL, xloc, FNCALL_FLAG_VAR); #endif diff --git a/hawk/lib/rec.c b/hawk/lib/rec.c index a38a70b0..c64f9930 100644 --- a/hawk/lib/rec.c +++ b/hawk/lib/rec.c @@ -499,7 +499,7 @@ int hawk_rtx_truncrec (hawk_rtx_t* rtx, hawk_oow_t nflds) if (nflds > 1) { - v = RTX_STACK_GBL(rtx, HAWK_GBL_OFS); + v = HAWK_RTX_STACK_GBL(rtx, HAWK_GBL_OFS); hawk_rtx_refupval (rtx, v); vtype = HAWK_RTX_GETVALTYPE(rtx, v); diff --git a/hawk/lib/run.c b/hawk/lib/run.c index 469c53cc..f6900ca2 100644 --- a/hawk/lib/run.c +++ b/hawk/lib/run.c @@ -30,7 +30,7 @@ #define CMP_ERROR -99 #define DEF_BUF_CAPA 256 -#define RTX_STACK_INCREMENT 512 +#define HAWK_RTX_STACK_INCREMENT 512 /* Don't forget to grow IDXBUFSIZE if hawk_int_t is very large */ #if (HAWK_SIZEOF_INT_T <= 16) /* 128 bits */ @@ -216,18 +216,18 @@ typedef hawk_val_t* (*eval_expr_t) (hawk_rtx_t* rtx, hawk_nde_t* nde); HAWK_INLINE hawk_oow_t hawk_rtx_getnargs (hawk_rtx_t* rtx) { - return (hawk_oow_t) RTX_STACK_NARGS(rtx); + return (hawk_oow_t) HAWK_RTX_STACK_NARGS(rtx); } HAWK_INLINE hawk_val_t* hawk_rtx_getarg (hawk_rtx_t* rtx, hawk_oow_t idx) { - return RTX_STACK_ARG(rtx, idx); + return HAWK_RTX_STACK_ARG(rtx, idx); } HAWK_INLINE hawk_val_t* hawk_rtx_getgbl (hawk_rtx_t* rtx, int id) { HAWK_ASSERT (id >= 0 && id < (int)HAWK_ARR_SIZE(rtx->hawk->parse.gbls)); - return RTX_STACK_GBL(rtx, id); + return HAWK_RTX_STACK_GBL(rtx, id); } const hawk_oocs_t* hawk_rtx_getsubsep (hawk_rtx_t* rtx) @@ -244,7 +244,7 @@ static int set_global (hawk_rtx_t* rtx, int idx, hawk_nde_var_t* var, hawk_val_t hawk_rtx_ecb_t* ecb; hawk_val_type_t vtype, old_vtype; - old = RTX_STACK_GBL (rtx, idx); + old = HAWK_RTX_STACK_GBL (rtx, idx); vtype = HAWK_RTX_GETVALTYPE (rtx, val); old_vtype = HAWK_RTX_GETVALTYPE (rtx, old); @@ -645,7 +645,7 @@ static int set_global (hawk_rtx_t* rtx, int idx, hawk_nde_var_t* var, hawk_val_t } hawk_rtx_refdownval (rtx, old); - RTX_STACK_GBL(rtx,idx) = val; + HAWK_RTX_STACK_GBL(rtx,idx) = val; hawk_rtx_refupval (rtx, val); for (ecb = (rtx)->ecb; ecb; ecb = ecb->next) @@ -658,8 +658,8 @@ static int set_global (hawk_rtx_t* rtx, int idx, hawk_nde_var_t* var, hawk_val_t HAWK_INLINE void hawk_rtx_setretval (hawk_rtx_t* rtx, hawk_val_t* val) { - hawk_rtx_refdownval (rtx, RTX_STACK_RETVAL(rtx)); - RTX_STACK_RETVAL(rtx) = val; + hawk_rtx_refdownval (rtx, HAWK_RTX_STACK_RETVAL(rtx)); + HAWK_RTX_STACK_RETVAL(rtx) = val; /* should use the same trick as run_return */ hawk_rtx_refupval (rtx, val); } @@ -1010,7 +1010,7 @@ static int init_rtx (hawk_rtx_t* rtx, hawk_t* awk, hawk_rio_cbs_t* rio) HAWK_HTB_SIZER_DEFAULT, HAWK_HTB_HASHER_DEFAULT }; - hawk_oow_t stack_limit; + hawk_oow_t stack_limit, i; rtx->_gem = awk->_gem; rtx->hawk = awk; @@ -1034,11 +1034,12 @@ static int init_rtx (hawk_rtx_t* rtx, hawk_t* awk, hawk_rio_cbs_t* rio) /* initialize circular doubly-linked list */ rtx->gc.collecting = 0; - rtx->gc.all_count = 0; - rtx->gc.all.gc_next = &rtx->gc.all; - rtx->gc.all.gc_prev = &rtx->gc.all; - rtx->gc.saved.gc_next = &rtx->gc.saved; - rtx->gc.saved.gc_prev = &rtx->gc.saved; + for (i = 0; i < HAWK_COUNTOF(rtx->gc.g); i++) + { + rtx->gc.c[i] = 0; + rtx->gc.g[i].gc_next = &rtx->gc.g[i]; + rtx->gc.g[i].gc_prev = &rtx->gc.g[i]; + } rtx->inrec.buf_pos = 0; rtx->inrec.buf_len = 0; @@ -1338,7 +1339,7 @@ static HAWK_INLINE int __raw_push (hawk_rtx_t* rtx, void* val) void** tmp; hawk_oow_t n; - n = rtx->stack_limit + RTX_STACK_INCREMENT; + n = rtx->stack_limit + HAWK_RTX_STACK_INCREMENT; tmp = (void**)hawk_rtx_reallocmem(rtx, rtx->stack, n * HAWK_SIZEOF(void*)); if (!tmp) return -1; @@ -1438,7 +1439,7 @@ static int defaultify_globals (hawk_rtx_t* rtx) hawk_rtx_refupval (rtx, tmp); - HAWK_ASSERT (RTX_STACK_GBL(rtx,gtab[i].idx) == hawk_val_nil); + HAWK_ASSERT (HAWK_RTX_STACK_GBL(rtx,gtab[i].idx) == hawk_val_nil); if (hawk_rtx_setgbl(rtx, gtab[i].idx, tmp) == -1) { @@ -1465,9 +1466,9 @@ static void refdown_globals (hawk_rtx_t* rtx, int pop) while (ngbls > 0) { --ngbls; - hawk_rtx_refdownval (rtx, RTX_STACK_GBL(rtx,ngbls)); + hawk_rtx_refdownval (rtx, HAWK_RTX_STACK_GBL(rtx,ngbls)); if (pop) __raw_pop (rtx); - else RTX_STACK_GBL(rtx,ngbls) = hawk_val_nil; + else HAWK_RTX_STACK_GBL(rtx,ngbls) = hawk_val_nil; } } @@ -1497,7 +1498,7 @@ static void capture_retval_on_exit (void* arg) struct capture_retval_data_t* data; data = (struct capture_retval_data_t*)arg; - data->val = RTX_STACK_RETVAL(data->rtx); + data->val = HAWK_RTX_STACK_RETVAL(data->rtx); hawk_rtx_refupval (data->rtx, data->val); } @@ -1517,7 +1518,7 @@ static int enter_stack_frame (hawk_rtx_t* rtx) /* secure space for a return value */ if (HAWK_UNLIKELY(__raw_push(rtx,hawk_val_nil) <= -1)) goto oops; - /* secure space for RTX_STACK_NARGS */ + /* secure space for HAWK_RTX_STACK_NARGS */ if (HAWK_UNLIKELY(__raw_push(rtx,hawk_val_nil) <= -1)) goto oops; /* let the stack top remembered be the base of a new stack frame */ @@ -1551,7 +1552,7 @@ static hawk_val_t* run_bpae_loop (hawk_rtx_t* rtx) /* set nargs to zero */ nargs = 0; - RTX_STACK_NARGS(rtx) = (void*)nargs; + HAWK_RTX_STACK_NARGS(rtx) = (void*)nargs; /* execute the BEGIN block */ for (nde = rtx->hawk->tree.begin; @@ -1632,13 +1633,13 @@ static hawk_val_t* run_bpae_loop (hawk_rtx_t* rtx) /* derefrence all arguments. however, there should be no arguments * pushed to the stack as asserted below. we didn't push any arguments * for BEGIN/pattern action/END block execution.*/ - nargs = (hawk_oow_t)RTX_STACK_NARGS(rtx); + nargs = (hawk_oow_t)HAWK_RTX_STACK_NARGS(rtx); HAWK_ASSERT (nargs == 0); for (i = 0; i < nargs; i++) - hawk_rtx_refdownval (rtx, RTX_STACK_ARG(rtx,i)); + hawk_rtx_refdownval (rtx, HAWK_RTX_STACK_ARG(rtx,i)); /* get the return value in the current stack frame */ - retv = RTX_STACK_RETVAL(rtx); + retv = HAWK_RTX_STACK_RETVAL(rtx); if (ret <= -1) { @@ -2189,7 +2190,7 @@ static HAWK_INLINE int run_block0 (hawk_rtx_t* rtx, hawk_nde_blk_t* nde) while (nlcls > 0) { --nlcls; - hawk_rtx_refdownval (rtx, RTX_STACK_LCL(rtx, nlcls)); + hawk_rtx_refdownval (rtx, HAWK_RTX_STACK_LCL(rtx, nlcls)); __raw_pop (rtx); } @@ -2722,8 +2723,8 @@ static int run_return (hawk_rtx_t* rtx, hawk_nde_return_t* nde) } } - hawk_rtx_refdownval (rtx, RTX_STACK_RETVAL(rtx)); - RTX_STACK_RETVAL(rtx) = val; + hawk_rtx_refdownval (rtx, HAWK_RTX_STACK_RETVAL(rtx)); + HAWK_RTX_STACK_RETVAL(rtx) = val; /* NOTE: see eval_call() for the trick */ hawk_rtx_refupval (rtx, val); @@ -2746,8 +2747,8 @@ static int run_exit (hawk_rtx_t* rtx, hawk_nde_exit_t* nde) val = eval_expression(rtx, nde->val); if (HAWK_UNLIKELY(!val)) return -1; - hawk_rtx_refdownval (rtx, RTX_STACK_RETVAL_GBL(rtx)); - RTX_STACK_RETVAL_GBL(rtx) = val; /* global return value */ + hawk_rtx_refdownval (rtx, HAWK_RTX_STACK_RETVAL_GBL(rtx)); + HAWK_RTX_STACK_RETVAL_GBL(rtx) = val; /* global return value */ hawk_rtx_refupval (rtx, val); } @@ -2945,16 +2946,16 @@ static int run_delete_unnamed (hawk_rtx_t* rtx, hawk_nde_var_t* var) { case HAWK_NDE_GBL: case HAWK_NDE_GBLIDX: - val = RTX_STACK_GBL(rtx,var->id.idxa); + val = HAWK_RTX_STACK_GBL(rtx,var->id.idxa); break; case HAWK_NDE_LCL: case HAWK_NDE_LCLIDX: - val = RTX_STACK_LCL(rtx,var->id.idxa); + val = HAWK_RTX_STACK_LCL(rtx,var->id.idxa); break; default: - val = RTX_STACK_ARG(rtx,var->id.idxa); + val = HAWK_RTX_STACK_ARG(rtx,var->id.idxa); break; } @@ -2998,12 +2999,12 @@ static int run_delete_unnamed (hawk_rtx_t* rtx, hawk_nde_var_t* var) case HAWK_NDE_LCL: case HAWK_NDE_LCLIDX: - RTX_STACK_LCL(rtx,var->id.idxa) = tmp; + HAWK_RTX_STACK_LCL(rtx,var->id.idxa) = tmp; hawk_rtx_refupval (rtx, tmp); break; default: - RTX_STACK_ARG(rtx,var->id.idxa) = tmp; + HAWK_RTX_STACK_ARG(rtx,var->id.idxa) = tmp; hawk_rtx_refupval (rtx, tmp); break; } @@ -3086,15 +3087,15 @@ static int reset_variable (hawk_rtx_t* rtx, hawk_nde_var_t* var) switch (var->type) { case HAWK_NDE_GBL: - val = RTX_STACK_GBL(rtx,var->id.idxa); + val = HAWK_RTX_STACK_GBL(rtx,var->id.idxa); break; case HAWK_NDE_LCL: - val = RTX_STACK_LCL(rtx,var->id.idxa); + val = HAWK_RTX_STACK_LCL(rtx,var->id.idxa); break; case HAWK_NDE_ARG: - val = RTX_STACK_ARG(rtx,var->id.idxa); + val = HAWK_RTX_STACK_ARG(rtx,var->id.idxa); break; } @@ -3106,15 +3107,15 @@ static int reset_variable (hawk_rtx_t* rtx, hawk_nde_var_t* var) switch (var->type) { case HAWK_NDE_GBL: - RTX_STACK_GBL(rtx,var->id.idxa) = hawk_val_nil; + HAWK_RTX_STACK_GBL(rtx,var->id.idxa) = hawk_val_nil; break; case HAWK_NDE_LCL: - RTX_STACK_LCL(rtx,var->id.idxa) = hawk_val_nil; + HAWK_RTX_STACK_LCL(rtx,var->id.idxa) = hawk_val_nil; break; case HAWK_NDE_ARG: - RTX_STACK_ARG(rtx,var->id.idxa) = hawk_val_nil; + HAWK_RTX_STACK_ARG(rtx,var->id.idxa) = hawk_val_nil; break; } } @@ -3825,7 +3826,7 @@ static hawk_val_t* do_assignment_nonidx (hawk_rtx_t* rtx, hawk_nde_var_t* var, h case HAWK_NDE_LCL: { - hawk_val_t* old = RTX_STACK_LCL(rtx,var->id.idxa); + hawk_val_t* old = HAWK_RTX_STACK_LCL(rtx,var->id.idxa); if (!(rtx->hawk->opt.trait & HAWK_FLEXMAP)) { @@ -3848,14 +3849,14 @@ static hawk_val_t* do_assignment_nonidx (hawk_rtx_t* rtx, hawk_nde_var_t* var, h } hawk_rtx_refdownval (rtx, old); - RTX_STACK_LCL(rtx,var->id.idxa) = val; + HAWK_RTX_STACK_LCL(rtx,var->id.idxa) = val; hawk_rtx_refupval (rtx, val); break; } case HAWK_NDE_ARG: { - hawk_val_t* old = RTX_STACK_ARG(rtx,var->id.idxa); + hawk_val_t* old = HAWK_RTX_STACK_ARG(rtx,var->id.idxa); if (!(rtx->hawk->opt.trait & HAWK_FLEXMAP)) { @@ -3878,7 +3879,7 @@ static hawk_val_t* do_assignment_nonidx (hawk_rtx_t* rtx, hawk_nde_var_t* var, h } hawk_rtx_refdownval (rtx, old); - RTX_STACK_ARG(rtx,var->id.idxa) = val; + HAWK_RTX_STACK_ARG(rtx,var->id.idxa) = val; hawk_rtx_refupval (rtx, val); break; } @@ -3917,15 +3918,15 @@ retry: } case HAWK_NDE_GBLIDX: - map = (hawk_val_map_t*)RTX_STACK_GBL(rtx,var->id.idxa); + map = (hawk_val_map_t*)HAWK_RTX_STACK_GBL(rtx,var->id.idxa); break; case HAWK_NDE_LCLIDX: - map = (hawk_val_map_t*)RTX_STACK_LCL(rtx,var->id.idxa); + map = (hawk_val_map_t*)HAWK_RTX_STACK_LCL(rtx,var->id.idxa); break; default: /* HAWK_NDE_ARGIDX */ - map = (hawk_val_map_t*)RTX_STACK_ARG(rtx,var->id.idxa); + map = (hawk_val_map_t*)HAWK_RTX_STACK_ARG(rtx,var->id.idxa); break; } @@ -3977,13 +3978,13 @@ retry: case HAWK_NDE_LCLIDX: hawk_rtx_refdownval (rtx, (hawk_val_t*)map); - RTX_STACK_LCL(rtx,var->id.idxa) = tmp; + HAWK_RTX_STACK_LCL(rtx,var->id.idxa) = tmp; hawk_rtx_refupval (rtx, tmp); break; default: /* HAWK_NDE_ARGIDX */ hawk_rtx_refdownval (rtx, (hawk_val_t*)map); - RTX_STACK_ARG(rtx,var->id.idxa) = tmp; + HAWK_RTX_STACK_ARG(rtx,var->id.idxa) = tmp; hawk_rtx_refupval (rtx, tmp); break; } @@ -6078,9 +6079,9 @@ static hawk_val_t* eval_fncall_var (hawk_rtx_t* rtx, hawk_nde_t* nde) } /* run->stack_base has not been set for this - * stack frame. so the RTX_STACK_ARG macro cannot be used as in - * hawk_rtx_refdownval (run, RTX_STACK_ARG(run,nargs));*/ -#define UNWIND_RTX_STACK_ARG(rtx,nargs) \ + * stack frame. so the HAWK_RTX_STACK_ARG macro cannot be used as in + * hawk_rtx_refdownval (run, HAWK_RTX_STACK_ARG(run,nargs));*/ +#define UNWIND_HAWK_RTX_STACK_ARG(rtx,nargs) \ do { \ while ((nargs) > 0) \ { \ @@ -6090,7 +6091,7 @@ static hawk_val_t* eval_fncall_var (hawk_rtx_t* rtx, hawk_nde_t* nde) } \ } while (0) -#define UNWIND_RTX_STACK_BASE(rtx) \ +#define UNWIND_HAWK_RTX_STACK_BASE(rtx) \ do { \ __raw_pop (rtx); /* nargs */ \ __raw_pop (rtx); /* return */ \ @@ -6100,8 +6101,8 @@ static hawk_val_t* eval_fncall_var (hawk_rtx_t* rtx, hawk_nde_t* nde) #define UNWIND_RTX_STACK(rtx,nargs) \ do { \ - UNWIND_RTX_STACK_ARG (rtx,nargs); \ - UNWIND_RTX_STACK_BASE (rtx); \ + UNWIND_HAWK_RTX_STACK_ARG (rtx,nargs); \ + UNWIND_HAWK_RTX_STACK_BASE (rtx); \ } while (0) static hawk_val_t* __eval_call ( @@ -6200,7 +6201,7 @@ static hawk_val_t* __eval_call ( nargs = argpusher(rtx, call, apdata); if (nargs == (hawk_oow_t)-1) { - UNWIND_RTX_STACK_BASE (rtx); + UNWIND_HAWK_RTX_STACK_BASE (rtx); return HAWK_NULL; } @@ -6247,7 +6248,7 @@ static hawk_val_t* __eval_call ( } rtx->stack_base = saved_stack_top; - RTX_STACK_NARGS(rtx) = (void*)nargs; + HAWK_RTX_STACK_NARGS(rtx) = (void*)nargs; #if defined(DEBUG_RUN) hawk_logfmt (hawk_rtx_gethawk(rtx), HAWK_T("running function body\n")); @@ -6279,7 +6280,7 @@ static hawk_val_t* __eval_call ( } /* refdown args in the rtx.stack */ - nargs = (hawk_oow_t)RTX_STACK_NARGS(rtx); + nargs = (hawk_oow_t)HAWK_RTX_STACK_NARGS(rtx); #if defined(DEBUG_RUN) hawk_logfmt (hawk_rtx_gethawk(rtx), HAWK_T("block rtx complete nargs = %d\n"), (int)nargs); #endif @@ -6318,23 +6319,23 @@ static hawk_val_t* __eval_call ( rtx->stack_base = cur_stack_base; /* UGLY */ HAWK_RTX_INIT_REF_VAL (&refv, p->type - HAWK_NDE_NAMED, ref, 9); /* initialize a fake reference variable. 9 chosen randomly */ - hawk_rtx_setrefval (rtx, &refv, RTX_STACK_ARG(rtx, i)); + hawk_rtx_setrefval (rtx, &refv, HAWK_RTX_STACK_ARG(rtx, i)); } - hawk_rtx_refdownval (rtx, RTX_STACK_ARG(rtx,i)); + hawk_rtx_refdownval (rtx, HAWK_RTX_STACK_ARG(rtx,i)); p = p->next; } for (; i < nargs; i++) { - hawk_rtx_refdownval (rtx, RTX_STACK_ARG(rtx,i)); + hawk_rtx_refdownval (rtx, HAWK_RTX_STACK_ARG(rtx,i)); } } else { for (i = 0; i < nargs; i++) { - hawk_rtx_refdownval (rtx, RTX_STACK_ARG(rtx,i)); + hawk_rtx_refdownval (rtx, HAWK_RTX_STACK_ARG(rtx,i)); } } @@ -6342,7 +6343,7 @@ static hawk_val_t* __eval_call ( hawk_logfmt (hawk_rtx_gethawk(rtx), HAWK_T("got return value\n")); #endif - v = RTX_STACK_RETVAL(rtx); + v = HAWK_RTX_STACK_RETVAL(rtx); if (n == -1) { if (hawk_rtx_geterrnum(rtx) == HAWK_ENOERR && errhandler != HAWK_NULL) @@ -6351,19 +6352,19 @@ static hawk_val_t* __eval_call ( * invoked from hawk_rtx_call(). Under this * circumstance, this stack frame is the first * activated and the stack base is the first element - * after the global variables. so RTX_STACK_RETVAL(rtx) - * effectively becomes RTX_STACK_RETVAL_GBL(rtx). + * after the global variables. so HAWK_RTX_STACK_RETVAL(rtx) + * effectively becomes HAWK_RTX_STACK_RETVAL_GBL(rtx). * As __eval_call() returns HAWK_NULL on error and - * the reference count of RTX_STACK_RETVAL(rtx) should be + * the reference count of HAWK_RTX_STACK_RETVAL(rtx) should be * decremented, it can't get the return value * if it turns out to be terminated by exit(). * The return value could be destroyed by then. * Unlikely, rtx_bpae_loop() just checks if rtx->errinf.num - * is HAWK_ENOERR and gets RTX_STACK_RETVAL_GBL(rtx) + * is HAWK_ENOERR and gets HAWK_RTX_STACK_RETVAL_GBL(rtx) * to determine if it is terminated by exit(). * * The handler capture_retval_on_exit() - * increments the reference of RTX_STACK_RETVAL(rtx) + * increments the reference of HAWK_RTX_STACK_RETVAL(rtx) * and stores the pointer into accompanying space. * This way, the return value is preserved upon * termination by exit() out to the caller. @@ -6375,7 +6376,7 @@ static hawk_val_t* __eval_call ( * has to return a error, the return value is just * destroyed and replaced by nil */ hawk_rtx_refdownval (rtx, v); - RTX_STACK_RETVAL(rtx) = hawk_val_nil; + HAWK_RTX_STACK_RETVAL(rtx) = hawk_val_nil; } else { @@ -6415,7 +6416,7 @@ static hawk_oow_t push_arg_from_vals (hawk_rtx_t* rtx, hawk_nde_fncall_t* call, v = hawk_rtx_makerefval(rtx, HAWK_VAL_REF_LCL, ref); /* this type(HAWK_VAL_REF_LCL) is fake */ if (!v) { - UNWIND_RTX_STACK_ARG (rtx, nargs); + UNWIND_HAWK_RTX_STACK_ARG (rtx, nargs); ADJERR_LOC (rtx, &call->loc); return (hawk_oow_t)-1; } @@ -6425,7 +6426,7 @@ static hawk_oow_t push_arg_from_vals (hawk_rtx_t* rtx, hawk_nde_fncall_t* call, hawk_rtx_refupval (rtx, v); hawk_rtx_refdownval (rtx, v); - UNWIND_RTX_STACK_ARG (rtx, nargs); + UNWIND_HAWK_RTX_STACK_ARG (rtx, nargs); ADJERR_LOC (rtx, &call->loc); return (hawk_oow_t)-1; } @@ -6444,7 +6445,7 @@ static hawk_oow_t push_arg_from_vals (hawk_rtx_t* rtx, hawk_nde_fncall_t* call, hawk_rtx_refupval (rtx, pafv->args[nargs]); hawk_rtx_refdownval (rtx, pafv->args[nargs]); - UNWIND_RTX_STACK_ARG (rtx, nargs); + UNWIND_HAWK_RTX_STACK_ARG (rtx, nargs); ADJERR_LOC (rtx, &call->loc); return (hawk_oow_t)-1; } @@ -6490,7 +6491,7 @@ static hawk_oow_t push_arg_from_nde (hawk_rtx_t* rtx, hawk_nde_fncall_t* call, v if (get_reference(rtx, p, &ref) <= -1) { - UNWIND_RTX_STACK_ARG (rtx, nargs); + UNWIND_HAWK_RTX_STACK_ARG (rtx, nargs); return (hawk_oow_t)-1; } @@ -6509,7 +6510,7 @@ static hawk_oow_t push_arg_from_nde (hawk_rtx_t* rtx, hawk_nde_fncall_t* call, v if (!v) { - UNWIND_RTX_STACK_ARG (rtx, nargs); + UNWIND_HAWK_RTX_STACK_ARG (rtx, nargs); return (hawk_oow_t)-1; } @@ -6523,7 +6524,7 @@ static hawk_oow_t push_arg_from_nde (hawk_rtx_t* rtx, hawk_nde_fncall_t* call, v hawk_rtx_refupval (rtx, v); hawk_rtx_refdownval (rtx, v); - UNWIND_RTX_STACK_ARG (rtx, nargs); + UNWIND_HAWK_RTX_STACK_ARG (rtx, nargs); ADJERR_LOC (rtx, &call->loc); return (hawk_oow_t)-1; } @@ -6566,16 +6567,16 @@ static int get_reference (hawk_rtx_t* rtx, hawk_nde_t* nde, hawk_val_t*** ref) } case HAWK_NDE_GBL: - /* *ref = (hawk_val_t**)&RTX_STACK_GBL(rtx,tgt->id.idxa); */ + /* *ref = (hawk_val_t**)&HAWK_RTX_STACK_GBL(rtx,tgt->id.idxa); */ *ref = (hawk_val_t**)((hawk_oow_t)tgt->id.idxa); return 0; case HAWK_NDE_LCL: - *ref = (hawk_val_t**)&RTX_STACK_LCL(rtx,tgt->id.idxa); + *ref = (hawk_val_t**)&HAWK_RTX_STACK_LCL(rtx,tgt->id.idxa); return 0; case HAWK_NDE_ARG: - *ref = (hawk_val_t**)&RTX_STACK_ARG(rtx,tgt->id.idxa); + *ref = (hawk_val_t**)&HAWK_RTX_STACK_ARG(rtx,tgt->id.idxa); return 0; case HAWK_NDE_NAMEDIDX: @@ -6600,19 +6601,19 @@ static int get_reference (hawk_rtx_t* rtx, hawk_nde_t* nde, hawk_val_t*** ref) } case HAWK_NDE_GBLIDX: - tmp = get_reference_indexed(rtx, tgt, (hawk_val_t**)&RTX_STACK_GBL(rtx,tgt->id.idxa)); + tmp = get_reference_indexed(rtx, tgt, (hawk_val_t**)&HAWK_RTX_STACK_GBL(rtx,tgt->id.idxa)); if (tmp == HAWK_NULL) return -1; *ref = tmp; return 0; case HAWK_NDE_LCLIDX: - tmp = get_reference_indexed(rtx, tgt, (hawk_val_t**)&RTX_STACK_LCL(rtx,tgt->id.idxa)); + tmp = get_reference_indexed(rtx, tgt, (hawk_val_t**)&HAWK_RTX_STACK_LCL(rtx,tgt->id.idxa)); if (tmp == HAWK_NULL) return -1; *ref = tmp; return 0; case HAWK_NDE_ARGIDX: - tmp = get_reference_indexed(rtx, tgt, (hawk_val_t**)&RTX_STACK_ARG(rtx,tgt->id.idxa)); + tmp = get_reference_indexed(rtx, tgt, (hawk_val_t**)&HAWK_RTX_STACK_ARG(rtx,tgt->id.idxa)); if (tmp == HAWK_NULL) return -1; *ref = tmp; return 0; @@ -6793,17 +6794,17 @@ static hawk_val_t* eval_named (hawk_rtx_t* rtx, hawk_nde_t* nde) static hawk_val_t* eval_gbl (hawk_rtx_t* rtx, hawk_nde_t* nde) { - return RTX_STACK_GBL(rtx,((hawk_nde_var_t*)nde)->id.idxa); + return HAWK_RTX_STACK_GBL(rtx,((hawk_nde_var_t*)nde)->id.idxa); } static hawk_val_t* eval_lcl (hawk_rtx_t* rtx, hawk_nde_t* nde) { - return RTX_STACK_LCL(rtx,((hawk_nde_var_t*)nde)->id.idxa); + return HAWK_RTX_STACK_LCL(rtx,((hawk_nde_var_t*)nde)->id.idxa); } static hawk_val_t* eval_arg (hawk_rtx_t* rtx, hawk_nde_t* nde) { - return RTX_STACK_ARG(rtx,((hawk_nde_var_t*)nde)->id.idxa); + return HAWK_RTX_STACK_ARG(rtx,((hawk_nde_var_t*)nde)->id.idxa); } static hawk_val_t* eval_indexed (hawk_rtx_t* rtx, hawk_nde_var_t* nde, hawk_val_t** val) @@ -6873,17 +6874,17 @@ static hawk_val_t* eval_namedidx (hawk_rtx_t* rtx, hawk_nde_t* nde) static hawk_val_t* eval_gblidx (hawk_rtx_t* rtx, hawk_nde_t* nde) { - return eval_indexed(rtx, (hawk_nde_var_t*)nde, (hawk_val_t**)&RTX_STACK_GBL(rtx,((hawk_nde_var_t*)nde)->id.idxa)); + return eval_indexed(rtx, (hawk_nde_var_t*)nde, (hawk_val_t**)&HAWK_RTX_STACK_GBL(rtx,((hawk_nde_var_t*)nde)->id.idxa)); } static hawk_val_t* eval_lclidx (hawk_rtx_t* rtx, hawk_nde_t* nde) { - return eval_indexed(rtx, (hawk_nde_var_t*)nde, (hawk_val_t**)&RTX_STACK_LCL(rtx,((hawk_nde_var_t*)nde)->id.idxa)); + return eval_indexed(rtx, (hawk_nde_var_t*)nde, (hawk_val_t**)&HAWK_RTX_STACK_LCL(rtx,((hawk_nde_var_t*)nde)->id.idxa)); } static hawk_val_t* eval_argidx (hawk_rtx_t* rtx, hawk_nde_t* nde) { - return eval_indexed(rtx, (hawk_nde_var_t*)nde, (hawk_val_t**)&RTX_STACK_ARG(rtx,((hawk_nde_var_t*)nde)->id.idxa)); + return eval_indexed(rtx, (hawk_nde_var_t*)nde, (hawk_val_t**)&HAWK_RTX_STACK_ARG(rtx,((hawk_nde_var_t*)nde)->id.idxa)); } static hawk_val_t* eval_pos (hawk_rtx_t* rtx, hawk_nde_t* nde) diff --git a/hawk/lib/val-prv.h b/hawk/lib/val-prv.h index 241aaff2..7f8f7fe4 100644 --- a/hawk/lib/val-prv.h +++ b/hawk/lib/val-prv.h @@ -66,9 +66,9 @@ struct hawk_val_rchunk_t * add a field to indicate if a value is static. * -#define IS_STATICVAL(val) ((val) == HAWK_NULL || (val) == hawk_val_nil || (val) == hawk_val_zls || (val) == hawk_val_zlm) +#define HAWK_IS_STATICVAL(val) ((val) == HAWK_NULL || (val) == hawk_val_nil || (val) == hawk_val_zls || (val) == hawk_val_zlm) */ -#define IS_STATICVAL(val) ((val)->v_static) +#define HAWK_IS_STATICVAL(val) ((val)->v_static) /* hawk_val_t pointer encoding assumes the pointer is an even number. diff --git a/hawk/lib/val.c b/hawk/lib/val.c index 60b54c41..e48ec4f3 100644 --- a/hawk/lib/val.c +++ b/hawk/lib/val.c @@ -230,7 +230,7 @@ static void gc_dump_refs (hawk_rtx_t* rtx, hawk_gch_t* list) hawk_logbfmt (hawk_rtx_gethawk(rtx), HAWK_LOG_STDERR, "[GC] GCH %p gc_refs %d\n", gch, (int)gch->gc_refs); gch = gch->gc_next; } - hawk_logbfmt (hawk_rtx_gethawk(rtx), HAWK_LOG_STDERR, "[GC] all_count => %d\n", (int)rtx->gc.all_count); + hawk_logbfmt (hawk_rtx_gethawk(rtx), HAWK_LOG_STDERR, "[GC] all_count => %d\n", (int)rtx->gc.c[0]); } static void gc_move_reachables (hawk_gch_t* list, hawk_gch_t* reachable_list) @@ -318,7 +318,7 @@ static void gc_free_unreachables (hawk_rtx_t* rtx, hawk_gch_t* list) hawk_logbfmt (hawk_rtx_gethawk(rtx), HAWK_LOG_STDERR, "[GC] FREEING UNREACHABLE GCH %p gc_refs %zu v_refs %zu\n", gch, gch->gc_refs, hawk_gch_to_val(gch)->v_refs); #endif /* do what hawk_rtx_freeval() would do without HAWK_RTX_FREEVAL_GC_PRESERVE */ - rtx->gc.all_count--; + rtx->gc.c[0]--; gc_unchain_gch (gch); hawk_rtx_freemem (rtx, gch); } @@ -331,20 +331,20 @@ void hawk_rtx_gc (hawk_rtx_t* rtx) #if defined(DEBUG_GC) hawk_logbfmt (hawk_rtx_gethawk(rtx), HAWK_LOG_STDERR, "[GC] **started**\n"); #endif - gc_trace_refs (&rtx->gc.all); + gc_trace_refs (&rtx->gc.g[0]); reachable.gc_prev = &reachable; reachable.gc_next = &reachable; - gc_move_reachables (&rtx->gc.all, &reachable); + gc_move_reachables (&rtx->gc.g[0], &reachable); - /* only unreachables are left in rtx->gc.all */ -//gc_dump_refs (rtx, &rtx->gc.all); - gc_free_unreachables (rtx, &rtx->gc.all); -//gc_dump_refs (rtx, &rtx->gc.all); - HAWK_ASSERT (rtx->gc.all.gc_next == &rtx->gc.all); + /* only unreachables are left in rtx->gc.g[0] */ +//gc_dump_refs (rtx, &rtx->gc.g[0]); + gc_free_unreachables (rtx, &rtx->gc.g[0]); +//gc_dump_refs (rtx, &rtx->gc.g[0]); + HAWK_ASSERT (rtx->gc.g[0].gc_next == &rtx->gc.g[0]); /* move all reachables back to the main list */ - gc_move_all_gchs (&reachable, &rtx->gc.all); + gc_move_all_gchs (&reachable, &rtx->gc.g[0]); #if defined(DEBUG_GC) hawk_logbfmt (hawk_rtx_gethawk(rtx), HAWK_LOG_STDERR, "[GC] **ended**\n"); @@ -913,8 +913,8 @@ hawk_rtx_gc(rtx); hawk_map_setstyle (val->map, &style); #if defined(HAWK_ENABLE_GC) - gc_chain_val (&rtx->gc.all, (hawk_val_t*)val); - rtx->gc.all_count++; + gc_chain_val (&rtx->gc.g[0], (hawk_val_t*)val); + rtx->gc.c[0]++; val->v_gc = 1; #if defined(DEBUG_GC) hawk_logbfmt (hawk_rtx_gethawk(rtx), HAWK_LOG_STDERR, "[GC] MADE GCH %p VAL %p\n", hawk_val_to_gch(val), val); @@ -1092,7 +1092,7 @@ hawk_val_t* hawk_rtx_makefunval (hawk_rtx_t* rtx, const hawk_fun_t* fun) int HAWK_INLINE hawk_rtx_isstaticval (hawk_rtx_t* rtx, hawk_val_t* val) { - return HAWK_VTR_IS_POINTER(val) && IS_STATICVAL(val); + return HAWK_VTR_IS_POINTER(val) && HAWK_IS_STATICVAL(val); } int hawk_rtx_getvaltype (hawk_rtx_t* rtx, hawk_val_t* val) @@ -1131,7 +1131,7 @@ void hawk_rtx_freeval (hawk_rtx_t* rtx, hawk_val_t* val, int flags) if (HAWK_VTR_IS_POINTER(val)) { - if (IS_STATICVAL(val)) return; + if (HAWK_IS_STATICVAL(val)) return; #if defined(DEBUG_VAL) hawk_logfmt (hawk_rtx_gethawk(rtx), HAWK_LOG_STDERR, HAWK_T("freeing [cache=%d] - [%O]\n"), cache, val); @@ -1238,7 +1238,7 @@ void hawk_rtx_freeval (hawk_rtx_t* rtx, hawk_val_t* val, int flags) hawk_map_fini (((hawk_val_map_t*)val)->map); if (!(flags & HAWK_RTX_FREEVAL_GC_PRESERVE)) { - rtx->gc.all_count--; + rtx->gc.c[0]--; gc_unchain_val (val); hawk_rtx_freemem (rtx, hawk_val_to_gch(val)); } @@ -1263,7 +1263,7 @@ void hawk_rtx_refupval (hawk_rtx_t* rtx, hawk_val_t* val) { if (HAWK_VTR_IS_POINTER(val)) { - if (IS_STATICVAL(val)) return; + if (HAWK_IS_STATICVAL(val)) return; #if defined(DEBUG_VAL) hawk_logfmt (hawk_rtx_gethawk(rtx), HAWK_LOG_STDERR, HAWK_T("ref up [ptr=%p] [count=%d] - [%O]\n"), val, (int)val->v_refs, val); @@ -1276,7 +1276,7 @@ void hawk_rtx_refdownval (hawk_rtx_t* rtx, hawk_val_t* val) { if (HAWK_VTR_IS_POINTER(val)) { - if (IS_STATICVAL(val)) return; + if (HAWK_IS_STATICVAL(val)) return; #if defined(DEBUG_VAL) hawk_logfmt (hawk_rtx_gethawk(rtx), HAWK_LOG_STDERR, HAWK_T("ref down [ptr=%p] [count=%d] - [%O]\n"), val, (int)val->v_refs, val); @@ -1297,7 +1297,7 @@ void hawk_rtx_refdownval_nofree (hawk_rtx_t* rtx, hawk_val_t* val) { if (HAWK_VTR_IS_POINTER(val)) { - if (IS_STATICVAL(val)) return; + if (HAWK_IS_STATICVAL(val)) return; /* the reference count of a value should be greater than zero for it to be decremented. check the source code for any bugs */ HAWK_ASSERT (val->v_refs > 0); @@ -1344,7 +1344,7 @@ static int val_ref_to_bool (hawk_rtx_t* rtx, const hawk_val_ref_t* ref) { hawk_oow_t idx; idx = (hawk_oow_t)ref->adr; - return hawk_rtx_valtobool(rtx, RTX_STACK_GBL (rtx, idx)); + return hawk_rtx_valtobool(rtx, HAWK_RTX_STACK_GBL (rtx, idx)); } default: @@ -1762,7 +1762,7 @@ static int val_ref_to_str (hawk_rtx_t* rtx, const hawk_val_ref_t* ref, hawk_rtx_ case HAWK_VAL_REF_GBL: { hawk_oow_t idx = (hawk_oow_t)ref->adr; - return hawk_rtx_valtostr(rtx, RTX_STACK_GBL (rtx, idx), out); + return hawk_rtx_valtostr(rtx, HAWK_RTX_STACK_GBL (rtx, idx), out); } default: @@ -2100,7 +2100,7 @@ static int val_ref_to_num (hawk_rtx_t* rtx, const hawk_val_ref_t* ref, hawk_int_ case HAWK_VAL_REF_GBL: { hawk_oow_t idx = (hawk_oow_t)ref->adr; - return hawk_rtx_valtonum(rtx, RTX_STACK_GBL (rtx, idx), l, r); + return hawk_rtx_valtonum(rtx, HAWK_RTX_STACK_GBL (rtx, idx), l, r); } default: @@ -2297,7 +2297,7 @@ hawk_val_type_t hawk_rtx_getrefvaltype (hawk_rtx_t* rtx, hawk_val_ref_t* ref) hawk_oow_t idx; hawk_val_t* v; idx = (hawk_oow_t)ref->adr; - v = RTX_STACK_GBL(rtx, idx); + v = HAWK_RTX_STACK_GBL(rtx, idx); return HAWK_RTX_GETVALTYPE(rtx, v); } @@ -2343,7 +2343,7 @@ hawk_val_t* hawk_rtx_getrefval (hawk_rtx_t* rtx, hawk_val_ref_t* ref) { hawk_oow_t idx; idx = (hawk_oow_t)ref->adr; - return RTX_STACK_GBL(rtx, idx); + return HAWK_RTX_STACK_GBL(rtx, idx); } default: