[runtime] make rounding computations more explicit#13117
Conversation
gasche
left a comment
There was a problem hiding this comment.
In a typical bikeshedding fashion: this is fine except for the name. caml_mem_round_up(value, alignment): I don't see a reason for the mem prefix here, except for the fact that this happens to be used in caml_mem_round_up_pages which is really a memory-subsystem-specific function. I would call this caml_round_up and move it to misc.h, which has integer-operations-with-overflow functions for example.
|
Sure, done. |
|
The CI reports a MSCV 32bit failure, the first invocation of |
|
The msvc32 CI is still failing. @dustanddreams, can you figure out why? |
|
I'm afraid I can't help much here - the logs are unhelpful and I don't have the ability to tinker with MSVC - which means I can't rule out a regression introduced by this PR. |
|
I confirm that I get the build failure with this PR on msvc32 locally too, and that trunk builds fine. This is a regression. |
|
I think I found the reason why it doesn't work with MSVC. We are allocating I'll fix this ASAP. |
|
My current reviewer state is the following:
In particular, I wonder if we change the behavior compared to the trunk code, and whether this is a good change. (My guess: we do pessimize the behavior slightly, but we are talking about very small amount of wasted space, and most configurations use mmap anyway where there is no change.) I tried to read the explanations of @damiendoligez in #11779, but honestly this reads like gibberish to me. @dustanddreams, can you confirm that you do understand (2), and comment on the change of behavior between trunk and your PR? |
|
The trunk code always asks for an extra 8 bytes in When using When not using |
|
I'm convinced, but this has gone from "simple refactoring" to "why are there so many snakes?", so I think this needs a Changes entry. |
Use it in alloc_for_stack and alloc_size_class_stack_noexc in order to make sure the top of stack will have the expected 16-byte alignment. Closes: #11779
|
There can't be snakes, Saint Patrick drove them out! |
This PR intends to fix #11779, by making stack rounding computations correct and explicit.
The first concern of #11779 had been addressed in #12434; this PR cleans up a bit and addresses the second concern.