Merged
Conversation
This commit promotes "big" constants i.e. those in the constant pool. This is possible thanks to 60c3e59, but still requires some work: in particular, we have to create different codepaths to ensure that whenever we load something out of the constant pool we do so via an idempotent function. Fortunately, by introducing "K" variants of some macros, we can do this in a way that doesn't cause much code corruption. Speeds up cd/json/storage by ~2%.
vext01
reviewed
Mar 24, 2026
| NOOPT_VAL(o); | ||
| uint64_t x; | ||
| // FIXME: We currently have to use memcpy to bitcast from lua_Number to uint64_t | ||
| memcpy(&x, &o->value_.n, sizeof(lua_Number)); |
Contributor
There was a problem hiding this comment.
llvm will probably eliminate the memcpy anyway.
Contributor
Author
There was a problem hiding this comment.
It becomes a bitcast (but this is an ugly, and obsucatory, way to have to do it! But there's nothing better in C AFAIK).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This commit promotes "big" constants i.e. those in the constant pool. This is possible thanks to 60c3e59, but still requires some work: in particular, we have to create different codepaths to ensure that whenever we load something out of the constant pool we do so via an idempotent function. Fortunately, by introducing "K" variants of some macros, we can do this in a way that doesn't cause much code corruption. Speeds up cd/json/storage by ~2%.
@vext01 You'll notice I've had to hack around
idempotent_promotenot supporting floats/doubles here. It's not a big deal, but is a bit icky. It also makes me realise that if we hadyk_idempotent_promote(x)as a function we could do the same ABI "are we tracing" trick in a way that would remove a whole load of these idempotent_promote calls. Would it make much performance difference? Hard to say!