changed the position of abortion check

This commit is contained in:
hyung-hwan 2018-03-11 03:05:42 +00:00
parent 536f7fd9f2
commit f9e60cea28
2 changed files with 15 additions and 5 deletions

View File

@ -1200,12 +1200,9 @@ static int execute (hcl_t* hcl)
hcl->proc_switched = 0; hcl->proc_switched = 0;
#endif #endif
if (HCL_UNLIKELY(hcl->ip >= hcl->code.bc.len) || HCL_UNLIKELY(hcl->abort_req)) if (HCL_UNLIKELY(hcl->ip >= hcl->code.bc.len))
{ {
if (hcl->abort_req) HCL_DEBUG1 (hcl, "Stopping executeion as IP reached the end of bytecode(%zu)\n", hcl->code.bc.len);
HCL_DEBUG0 (hcl, "Stopping execution for abortion request\n");
else
HCL_DEBUG1 (hcl, "Stopping executeion as IP reached the end of bytecode(%zu)\n", hcl->code.bc.len);
return_value = hcl->_nil; return_value = hcl->_nil;
goto handle_return; goto handle_return;
} }
@ -1217,6 +1214,15 @@ static int execute (hcl_t* hcl)
/*while (bcode == HCL_CODE_NOOP) FETCH_BYTE_CODE_TO (hcl, bcode);*/ /*while (bcode == HCL_CODE_NOOP) FETCH_BYTE_CODE_TO (hcl, bcode);*/
if (hcl->vm_checkpoint_cb_count) vm_checkpoint (hcl); if (hcl->vm_checkpoint_cb_count) vm_checkpoint (hcl);
if (HCL_UNLIKELY(hcl->abort_req))
{
/* place the abortion check after vm_checkpoint
* to honor hcl_abort() if called in the callback, */
HCL_DEBUG0 (hcl, "Stopping execution for abortion request\n");
return_value = hcl->_nil;
goto handle_return;
}
#if defined(HCL_PROFILE_VM) #if defined(HCL_PROFILE_VM)
inst_counter++; inst_counter++;

View File

@ -416,6 +416,10 @@ hcl_cb_t* hcl_regcb (hcl_t* hcl, hcl_cb_t* tmpl)
actual->prev = HCL_NULL; actual->prev = HCL_NULL;
hcl->cblist = actual; hcl->cblist = actual;
/* vm_checkpoint is invoked very frequently.
* and there might be multiple vm_checkpoint callbacks registered.
* keeping the count of vm_checkpoint callbacks registered
* speeds up the check */
if (actual->vm_checkpoint) hcl->vm_checkpoint_cb_count++; if (actual->vm_checkpoint) hcl->vm_checkpoint_cb_count++;
return actual; return actual;