changed the point where hawk_rtx_cleario() is called for cleanup

This commit is contained in:
hyung-hwan 2020-03-29 08:05:36 +00:00
parent cd7873e19a
commit abcc217dd0
2 changed files with 8 additions and 5 deletions

View File

@ -1797,8 +1797,6 @@ int Hawk::exec (Value* ret, const Value* args, hawk_oow_t nargs)
int n = (this->runctx.rtx->hawk->parse.pragma.entry[0] != '\0')? int n = (this->runctx.rtx->hawk->parse.pragma.entry[0] != '\0')?
this->call(this->runctx.rtx->hawk->parse.pragma.entry, ret, args, nargs): this->loop(ret); this->call(this->runctx.rtx->hawk->parse.pragma.entry, ret, args, nargs): this->loop(ret);
hawk_rtx_cleario (this->runctx.rtx);
#if defined(HAWK_ENABLE_GC) #if defined(HAWK_ENABLE_GC)
/* i assume this function is a usual hawk program starter. /* i assume this function is a usual hawk program starter.
* call garbage collection after a whole program finishes */ * call garbage collection after a whole program finishes */

View File

@ -1671,6 +1671,10 @@ hawk_val_t* hawk_rtx_loop (hawk_rtx_t* rtx)
/* reset the exit level */ /* reset the exit level */
rtx->exit_level = EXIT_NONE; rtx->exit_level = EXIT_NONE;
/* clear any pending io's */
hawk_rtx_cleario (rtx);
return retv; return retv;
} }
@ -1682,8 +1686,6 @@ hawk_val_t* hawk_rtx_execwithucstrarr (hawk_rtx_t* rtx, const hawk_uch_t* args[]
hawk_rtx_callwithooucstrarr(rtx, rtx->hawk->parse.pragma.entry, args, nargs): hawk_rtx_callwithooucstrarr(rtx, rtx->hawk->parse.pragma.entry, args, nargs):
hawk_rtx_loop(rtx); hawk_rtx_loop(rtx);
hawk_rtx_cleario (rtx);
#if defined(HAWK_ENABLE_GC) #if defined(HAWK_ENABLE_GC)
/* i assume this function is a usual hawk program starter. /* i assume this function is a usual hawk program starter.
* call garbage collection after a whole program finishes */ * call garbage collection after a whole program finishes */
@ -1811,7 +1813,7 @@ hawk_val_t* hawk_rtx_callfun (hawk_rtx_t* rtx, hawk_fun_t* fun, hawk_val_t* args
v = __eval_call(rtx, (hawk_nde_t*)&call, fun, push_arg_from_vals, (void*)&pafv, capture_retval_on_exit, &crdata); v = __eval_call(rtx, (hawk_nde_t*)&call, fun, push_arg_from_vals, (void*)&pafv, capture_retval_on_exit, &crdata);
if (!v) if (HAWK_UNLIKELY(!v))
{ {
/* an error occurred. let's check if it is caused by exit(). /* an error occurred. let's check if it is caused by exit().
* if so, the return value should have been captured into * if so, the return value should have been captured into
@ -1827,6 +1829,9 @@ hawk_val_t* hawk_rtx_callfun (hawk_rtx_t* rtx, hawk_fun_t* fun, hawk_val_t* args
hawk_rtx_refupval (rtx, v); hawk_rtx_refupval (rtx, v);
} }
/* clear any pending io's */
hawk_rtx_cleario (rtx);
/* return the return value with its reference count at least 1. /* return the return value with its reference count at least 1.
* the caller of this function should count down its reference. */ * the caller of this function should count down its reference. */
return v; return v;