You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There's a section in the README about the hypothetical freezing allocator we can use to make sure closure environments are safe to inline by forcing them to be immutable (at the cost of runtime segfaults...)
We can actually do slightly better, and put off implementing that for a bit: Rust has automatic marker traits like Send and Sync that are implemented for any type that only contains fields already marked with that trait. The Rust compiler has an internal marker trait Freeze that's used for marking interior immutability - which is the exact same thing we care about. Magically, marker traits are also implemented for Fn trait objects automatically too, so we can 1) verbatim copy Freeze out of the stdlib (or maybe use https://crates.io/crates/freeze-macros which seems to do exactly that??) 2) change Jit::speedup<F> to be Jit::speedup<F: Freeze> to only accept closures that are interior immutable. This gives us compile-time errors instead of runtime segfaults, which is a bonus.
The text was updated successfully, but these errors were encountered:
I removed the freezing part from the readme, since we'd probably implement the marker trait solution along with whatever initial implementation, and there's no reason to lie about the freezing design if it isn't even implemented yet.
There's a section in the README about the hypothetical freezing allocator we can use to make sure closure environments are safe to inline by forcing them to be immutable (at the cost of runtime segfaults...)
We can actually do slightly better, and put off implementing that for a bit: Rust has automatic marker traits like Send and Sync that are implemented for any type that only contains fields already marked with that trait. The Rust compiler has an internal marker trait Freeze that's used for marking interior immutability - which is the exact same thing we care about. Magically, marker traits are also implemented for
Fn
trait objects automatically too, so we can 1) verbatim copy Freeze out of the stdlib (or maybe use https://crates.io/crates/freeze-macros which seems to do exactly that??) 2) changeJit::speedup<F>
to beJit::speedup<F: Freeze>
to only accept closures that are interior immutable. This gives us compile-time errors instead of runtime segfaults, which is a bonus.The text was updated successfully, but these errors were encountered: