-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Use InternPool for all types and constant values #15569
Conversation
/// This is handy if you have a u32 and want a u32 and don't want to take a | ||
/// detour through many layers of abstraction elsewhere in the std.hash | ||
/// namespace. | ||
/// Copied from https://nullprogram.com/blog/2018/07/31/ |
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.
This article was updated to point to skeeto/hash-prospector#19 for an improved function - skeeto/hash-prospector#19 (comment) or the previous comment on that issue seem to be the latest and greatest:
pub fn uint32(input: u32) u32 {
var x: u32 = input;
x ^= x >> 16;
x *%= 0x21f0aaad;
x ^= x >> 15;
x *%= 0x735a2d97; // or 0xf35a2d97
x ^= x >> 15;
return x;
}
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.
Thanks!
1467d31
to
969ad6a
Compare
7c86b48
to
dc15fa8
Compare
Instead of doing everything at once which is a hopelessly large task, this introduces a piecemeal transition that can be done in small increments at a time. This is a minimal changeset that keeps the compiler compiling. It only uses the InternPool for a small set of types. Behavior tests are not passing. Air.Inst.Ref and Zir.Inst.Ref are separated into different enums but compile-time verified to have the same fields in the same order. The large set of changes is mainly to deal with the fact that most Type and Value methods now require a Module to be passed in, so that the InternPool object can be accessed.
* hashing * equality * encoding
This required additionally passing the `InternPool` into some AIR methods. Also, implement `Type.isNoReturn` for interned types.
Hopefully this also fixes the non-reproducing CI failures.
This avoids having dangling pointers into `InternPool.string_bytes`.
You must now write '_ = &f' rather than just '_ = f' to ensure a function is compiled into a binary.
These are frequently invalidated whenever a string is interned, so avoid creating pointers to `string_bytes` wherever possible. This is an attempt to fix random CI failures.
Here's a regression not covered by behavior tests:
|
This is useful for development, as it speeds up the process of getting semantic analysis errors significantly.
Another one. Unfortunately requires git lfs to reproduce:
|
Another one:
|
perf data point on 2pew:
|
perf data point for ghostty:
|
By correctly handling comptime-only types appearing in non-comptime parameters (when the parameter is either anytype or generic), this avoids an index out of bounds later when later filling out `monomorphed_args` using what used to be slightly different logic.
perf data point for legend-of-swarkland: peak rss:
perf:
|
Long term, linker backends will need to manage their own string tables for things like this because my mandate is: no long-lived pointers allowed in any of the codepaths touched by incremental compilation, so that we can serialize and deserialize trivially. Short term, I solved this with a couple calls to Allocator.dupe, incurring some harmless leaks.
perf data point for groove basin: peak RSS:
|
This changeset is centered around the
InternPool
data structure. Unfortunately, it required reworking a lot of compiler code.The goal of this branch is to get to a mergeable state as soon as possible, so as to stop accumulating conflicts with master branch.
Follow-up enhancements will include:
legacy
field from ValueAir.Inst.Ref
can even store InternPool indexes directly, eliminating the AIR tags for constants.val.toAllocatedBytes
- likely each callsite can avoid a copy thanks to the intern pool.