-
Notifications
You must be signed in to change notification settings - Fork 35
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
Discussion: Pin Ruby values to the stack #101
Comments
|
I've not thought about this in a while, but I think this is the chain of reasoning I had for not trying this out: There the It's possible I missed something, or there's another approach that'd work. I do have in the back of my mind a way to, behind the scenes, keep values on the stack as part of the automatic type conversion when binding Rust functions to Ruby methods. So that you could bind functions taking |
There are ways to check if a value is on the stack, but that seems more like something that can be provided as a verification step, as I can imagine this would create a decent amount of overhead. |
The best I've come up with is to have something like a My memory is a little fuzzy, but when I did this a long time ago this prevented LLVM from optimizing values off of the stack. However, requires that:
This kills the ergonomics of the said library, and IMO is not worth the trade-off. Maybe there's another way with |
I think we can keep a reference on the Ruby side to avoid this. Here is an example:
The But this is not enough, as the objects can be moved during GC, so we need to pin those objects. And Fiddle::Pinned can achieve. But I'm not sure if there is a better solution. |
I was wondering if you considered stack pinning for arguments as an alternative solution for ensuring Ruby values are not removed from the stack?
I am trying to prototype it a bit and I am not sure this is possible without breaking existing code, but it seems like something that would be helpful?
Maybe you tried / considered and found good reasons to not do this?
The text was updated successfully, but these errors were encountered: