-
Notifications
You must be signed in to change notification settings - Fork 37
Refactor - Simplify CoW in MemoryMapping #37
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
Conversation
6da3754 to
cceb6ba
Compare
cceb6ba to
5feb4c3
Compare
src/memory_region.rs
Outdated
| pub type AccessViolationHandler = Box<dyn Fn(u32) -> Result<u64, ()>>; | ||
| /// Fail always | ||
| #[allow(clippy::result_unit_err)] | ||
| pub fn default_access_violation_handler(_: u32) -> Result<u64, ()> { | ||
| Err(()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The usage of the function is to try to write to the memory and copy if it is readonly, right? I believe the old name MemoryCowCallback (or something related) is clearer on the intentions of this function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can split the renaming into a separate PR. But in the future it is not only for CoW (readonly to writable) but also to map in unmapped address space (for growing the realloc padding).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, another PR is good.
but also to map in unmapped address space
MemoryCowCallback isn't the best option considering that, but I still prefer it to describe what the function does, instead of the error it might return when it can't do what it is supposed to.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well the naming scheme is similar to the signal segmentation fault (SIGSEGV) signal handler. That one is also named after the signal / error message.
5feb4c3 to
1b8335b
Compare
1b8335b to
6920d29
Compare
MemoryCowCallbackis alwaysSome()in production, thus remove theOption<>.cow_cbparameter to be last innew_with_cowconstructors for consistency with thenewconstructors.cow_callback_payloadindependent of theMemoryState. This will later allow writable regions to be identifiable inside theMemoryCowCallbackas well.MemoryStateby boolean flagwritable.cow_callback_payloadfromu64tou32.