Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Free stack memory at end of fiber #6233

Merged
merged 1 commit into from
Apr 11, 2024
Merged

Conversation

dearblue
Copy link
Contributor

@dearblue dearblue commented Apr 9, 2024

Immediately frees the call stack and data stack at the end of a non-root fiber.
If the env object needs to be detached, the data stack is reused through mrb_realloc().

Previously, it was not necessary to take into account that c->cibase could be NULL.
Note that this is no longer the case due to this patch.
In fact, changes to "mruby-fiber" are now required.

Immediately frees the call stack and data stack at the end of a non-root fiber.
If the env object needs to be detached, the data stack is reused through `mrb_realloc()`.

Previously, it was not necessary to take into account that `c->cibase` could be `NULL`.
Note that this is no longer the case due to this patch.
In fact, changes to "mruby-fiber" are now required.
}
else {
mrb_assert(stack == env->stack);
mrb_write_barrier(mrb, (struct RBasic*)env);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need mrb_write_barrier() here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your review.

I am not sure exactly.
This fiber_terminate() is based on mrb_env_unshare().

It was removed from mrb_env_unshare() once, but was reintroduced in commit 93648fc, so I added it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I see. I investigated and found out we need it. Thank you.

@matz matz merged commit d761561 into mruby:master Apr 11, 2024
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants