bjorn3 opened PR #3793 from vmoffset_cleanup
to main
:
This should reduce the risk of making a mistake when changing it. Also fixes a typo and moves
builtin_functions
earlier in theVMContext
to make it's offset known at compile time.
alexcrichton submitted PR review.
alexcrichton submitted PR review.
alexcrichton created PR review comment:
This comment I think is fine to drop because it basically references something not existent in the code after this PR.
alexcrichton created PR review comment:
Personally I find this macro pretty hard to read and the syntax feels pretty odd. Could this perhaps be improved with something like:
fields! { size(interrupts) = ret.ptr.size(), size(epoch_ptr) = ret.ptr.size(), // ... }
I think it might be helpful for the macro to automatically insert
u32::from
everywhere to avoid having to explicitly call it as well. Furthermore I think it's best to avoidcmul
andcadd
aliases and instead just have the.checked_mul
inline since at least for me I think that's easier to read.
bjorn3 submitted PR review.
bjorn3 created PR review comment:
Personally I find this macro pretty hard to read and the syntax feels pretty odd.
I guess so. I like your suggestion.
Furthermore I think it's best to avoid cmul and cadd aliases and instead just have the .checked_mul inline since at least for me I think that's easier to read.
a.checked_mul(b).unwrap()
is harder to read thancmul(a, b)
IMHO. Especially as the former often requires wrapping to stay below 100 characters. Also as noted in the comment above their definition it increases binary size a bit due to unique caller locations passed to.unwrap()
. If you aren't convinced I will drop it.
bjorn3 updated PR #3793 from vmoffset_cleanup
to main
.
bjorn3 submitted PR review.
bjorn3 created PR review comment:
Personally I find this macro pretty hard to read and the syntax feels pretty odd. Could this perhaps be improved with something like:
How should align be handled?
defined_globals
needs to be aligned to 16 bytes.
bjorn3 edited PR review comment.
alexcrichton submitted PR review.
alexcrichton created PR review comment:
I'm personally not a huge fan of one-off functions with short names like "cmul" purely to save some characters on a few lines. Others may feel differently.
For alignment I would naively think that
align(the_field) = align
could be a macro argument which simply aligns up the current offset and implicitly the alignment is always specified after the size. (or before the size? something like that)
bjorn3 submitted PR review.
bjorn3 created PR review comment:
Maybe something like
fields! { size(interrupts) = ret.ptr.size(), size(epoch_ptr) = ret.ptr.size(), // ... align(16), size(defined_globals) = ..., // ... }
alexcrichton submitted PR review.
alexcrichton created PR review comment:
That seems reasonable too, yeah.
bjorn3 updated PR #3793 from vmoffset_cleanup
to main
.
bjorn3 submitted PR review.
bjorn3 created PR review comment:
Pushed the new macro syntax.
alexcrichton submitted PR review.
alexcrichton merged PR #3793.
Last updated: Nov 22 2024 at 16:03 UTC