-
Notifications
You must be signed in to change notification settings - Fork 19.1k
cmd/compile: use mapaccess1_fast64 for small keys #66446
Copy link
Copy link
Open
Labels
NeedsDecisionFeedback is required from experts, contributors, and/or the community before a change can be made.Feedback is required from experts, contributors, and/or the community before a change can be made.compiler/runtimeIssues related to the Go compiler and/or runtime.Issues related to the Go compiler and/or runtime.
Milestone
Metadata
Metadata
Assignees
Labels
NeedsDecisionFeedback is required from experts, contributors, and/or the community before a change can be made.Feedback is required from experts, contributors, and/or the community before a change can be made.compiler/runtimeIssues related to the Go compiler and/or runtime.Issues related to the Go compiler and/or runtime.
Type
Fields
Give feedbackNo fields configured for issues without a type.
Projects
StatusShow more project fields
Todo
Go version
go1.22
Output of
go envin your module/workspace:What did you do?
Compile the following program:
What did you see happen?
The compiler output:
What did you expect to see?
runtime.mapaccess1_fast64being used on both since thekeytype is smaller than a uint64.That said, there is some complications. For example, through
unsafe, someone could writes values to the padding in-between theboolfield and theuint32. Also, someone usingunsafecould write a bit pattern to the bool that isn't 0 or 1.It isn't clear to me that this is something that someone can rely on.
However, even if we make the
keystruct exactly 64-bits wide with no padding and no bools, it still doesn't useruntime.mapaccess1_fast64.