mrb_env_unshare() to break the link to fiber

Currently `e->cxt` is used exclusively to check for `break` / `return` availability.
In other words, there is no need to maintain a reference to a fiber that has reached its end.
This commit is contained in:
dearblue
2024-04-03 21:54:53 +09:00
parent 88004e44af
commit 96d56debc7
+2
View File
@@ -387,6 +387,8 @@ mrb_env_unshare(mrb_state *mrb, struct REnv *e, mrb_bool noraise)
if (e->cxt != mrb->c) return TRUE;
if (e == CI_ENV(mrb->c->cibase)) return TRUE; /* for mirb */
e->cxt = NULL; /* make possible to GC the fiber that generated the env */
size_t len = (size_t)MRB_ENV_LEN(e);
if (len == 0) {
e->stack = NULL;