JonasKruckenberg opened PR #9992 from JonasKruckenberg:jonas/static-machine-env
to bytecodealliance:main
:
This PR is another attempt at #8489 (superseding it) this time by making the necessary changes in
regalloc2
(see here) to allowMachineEnv
to be created in const expressions and therefore placed into statics without the need for lazy initialization (as mentioned in this comment)
This PR also makes the necessary changes in register creation functions to make themconst
.While I agree with @cfallin that this is the "correct" move, it is slightly annoying that Rusts const limitation makes the static initializers so verbose where a
1..=16
range iterator was used previously :/
JonasKruckenberg requested fitzgen for a review on PR #9992.
JonasKruckenberg requested wasmtime-compiler-reviewers for a review on PR #9992.
JonasKruckenberg requested wasmtime-default-reviewers for a review on PR #9992.
JonasKruckenberg edited PR #9992:
This PR is another attempt at #8489 (superseding it) this time by making the necessary changes in
regalloc2
(see here) to allowMachineEnv
to be created in const expressions and therefore placed into statics without the need for lazy initialization (as mentioned in this comment)
This PR also makes the necessary changes in register creation functions to make themconst
.While I agree with @cfallin that this is the "correct" move, it is slightly annoying that Rusts const limitation makes the static initializers so verbose where a
1..=16
range iterator was used previously, any ideas here are welcome :/Edit: marked the PR as draft until the regalloc2 upstream PR is merged
JonasKruckenberg updated PR #9992.
cfallin requested cfallin for a review on PR #9992.
cfallin created PR review comment:
This probably goes in the
PINNED_MACHINE_ENV
above, no? (It's load-bearing there that we get it right, because we excluded the pinned register from allocation; the default environment is used when pinning is disabled so doesn't care what the pinned reg is)
cfallin created PR review comment:
Can you say more here -- I'm not that familiar with the current state of constification of everything; is there some feature this is waiting on to stabilize or...?
cfallin submitted PR review:
Thanks a bunch for working on this! This all looks like the shape I expected; I'm glad there were no other hidden snags. A few minor comments below but otherwise happy to see this merged once we get the RA2 PR merged and released.
JonasKruckenberg submitted PR review.
JonasKruckenberg created PR review comment:
well, the feature that would be waiting for is const associated functions in traits (therefore allowing
From::from
to be const) but that afaik is in "never type land". I can remove the note as it doesn't make much sense to hold our breath on it
cfallin submitted PR review.
cfallin created PR review comment:
Yeah, I think that's best -- usually when we have a FIXME we want it to be actionable, or at least give sufficient context so that we know what we're waiting on (i.e.: if someone else walked up to this code tomorrow, would they know what they need in order to fix it?). It's fine to evaluate questions like this once new Rust features land in the future.
JonasKruckenberg submitted PR review.
JonasKruckenberg created PR review comment:
the issue with constness is that theres no good way to detect constness workarounds after the fact (the whole reason for the const-hack comments) but usually you'd tie them to specific RFCs yeah
JonasKruckenberg edited PR review comment.
JonasKruckenberg edited PR review comment.
hanna-kruppe submitted PR review.
hanna-kruppe created PR review comment:
Relevant RFC fresh off the press: https://github.com/rust-lang/rfcs/pull/3762
Last updated: Jan 24 2025 at 00:11 UTC