… | |
… | |
137 | /* the stack */ |
137 | /* the stack */ |
138 | void *sptr; |
138 | void *sptr; |
139 | long ssize; /* positive == mmap, otherwise malloc */ |
139 | long ssize; /* positive == mmap, otherwise malloc */ |
140 | |
140 | |
141 | /* cpu state */ |
141 | /* cpu state */ |
142 | void *idle_sp; /* sp of top-level transfer/schedule/cede call */ |
142 | void *idle_sp; /* sp of top-level transfer/schedule/cede call */ |
|
|
143 | JMPENV *idle_te; /* same as idle_sp, but for top_env, TODO: remove once stable */ |
143 | JMPENV *top_env; |
144 | JMPENV *top_env; |
144 | coro_context cctx; |
145 | coro_context cctx; |
145 | |
146 | |
146 | int inuse; |
147 | int inuse; |
147 | |
148 | |
… | |
… | |
708 | |
709 | |
709 | /* sometimes transfer is only called to set idle_sp */ |
710 | /* sometimes transfer is only called to set idle_sp */ |
710 | if (!next) |
711 | if (!next) |
711 | { |
712 | { |
712 | ((coro_cctx *)prev)->idle_sp = STACKLEVEL; |
713 | ((coro_cctx *)prev)->idle_sp = STACKLEVEL; |
713 | assert (((coro_cctx *)prev)->top_env = PL_top_env); /* just for the side effetc when assert is enabled */ |
714 | assert (((coro_cctx *)prev)->idle_te = PL_top_env); /* just for the side-effect when asserts are enabled */ |
714 | } |
715 | } |
715 | else if (prev != next) |
716 | else if (prev != next) |
716 | { |
717 | { |
717 | coro_cctx *prev__cctx; |
718 | coro_cctx *prev__cctx; |
718 | |
719 | |
… | |
… | |
759 | |
760 | |
760 | /* possibly "free" the cctx */ |
761 | /* possibly "free" the cctx */ |
761 | if (prev__cctx->idle_sp == STACKLEVEL) |
762 | if (prev__cctx->idle_sp == STACKLEVEL) |
762 | { |
763 | { |
763 | /* I assume that STACKLEVEL is a stronger indicator than PL_top_env changes */ |
764 | /* I assume that STACKLEVEL is a stronger indicator than PL_top_env changes */ |
764 | assert (PL_top_env == prev__cctx->top_env); |
765 | assert (("ERROR: current top_env must equal previous top_env", PL_top_env == prev__cctx->idle_te)); |
765 | |
766 | |
766 | prev->cctx = 0; |
767 | prev->cctx = 0; |
767 | |
768 | |
768 | cctx_put (prev__cctx); |
769 | cctx_put (prev__cctx); |
769 | prev__cctx->inuse = 0; |
770 | prev__cctx->inuse = 0; |