Skip to content

Commit

Permalink
Merge pull request #1773 from actonlang/fix-exception-jump0-in-wctx
Browse files Browse the repository at this point in the history
Place jump0 in wctx
  • Loading branch information
plajjan authored Apr 5, 2024
2 parents c0044a4 + 2ed7582 commit e26fa33
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
14 changes: 7 additions & 7 deletions base/rts/rts.c
Original file line number Diff line number Diff line change
Expand Up @@ -1500,7 +1500,6 @@ void wt_wake_cb(uv_async_t *ev) {
void wt_work_cb(uv_check_t *ev) {
WorkerCtx wctx = (WorkerCtx)pthread_getspecific(pkey_wctx);
assert(wctx->id >= 0 && wctx->id < 256);
volatile JumpBuf jump0 = NULL;

struct timespec ts_start, ts1, ts2, ts3;
long long int runtime = 0;
Expand All @@ -1525,9 +1524,9 @@ void wt_work_cb(uv_check_t *ev) {
wt_stats[wctx->id].state = WT_Working;

$R r;
if (jump0 || $PUSH()) { // Normal path
if (!jump0) {
jump0 = wctx->jump_top;
if (wctx->jump0 || $PUSH()) { // Normal path
if (!wctx->jump0) {
wctx->jump0 = wctx->jump_top;
}
rtsd_printf("## Running actor %ld : %s", current->$globkey, current->$class->$GCINFO);
r = cont->$class->__call__(cont, val);
Expand All @@ -1550,9 +1549,9 @@ void wt_work_cb(uv_check_t *ev) {
else if (diff < (long long int)100 * 1000000000) { wt_stats[wctx->id].conts_100s++; }
else { wt_stats[wctx->id].conts_inf++; }
} else { // Exceptional path
assert(jump0 != NULL);
assert(jump0->xval != NULL);
B_BaseException ex = jump0->xval;
assert(wctx->jump0 != NULL);
assert(wctx->jump0->xval != NULL);
B_BaseException ex = wctx->jump0->xval;
rtsd_printf("## (%d) Actor %ld : %s longjmp exception: %s", wctx->id, current->$globkey, current->$class->$GCINFO, ex->$class->$GCINFO);
r = $R_FAIL(ex);
}
Expand Down Expand Up @@ -1704,6 +1703,7 @@ void *main_loop(void *idx) {
wctx->id = (long)idx;
wctx->uv_loop = uv_loops[wctx->id];
wctx->jump_top = NULL;
wctx->jump0 = NULL;
pthread_setspecific(pkey_wctx, (void *)wctx);

char tname[11]; // Enough for "Worker XXX\0"
Expand Down
1 change: 1 addition & 0 deletions base/rts/rts.h
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ struct WorkerCtx {
long id;
uv_loop_t *uv_loop;
volatile JumpBuf jump_top;
volatile JumpBuf jump0;
};

JumpBuf $PUSH_BUF();
Expand Down

0 comments on commit e26fa33

Please sign in to comment.