-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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
cmd/compile: reuse boxed primitive in slice literals of interfaces #29574
Comments
The backing store for each interface data item is currently its own static temp. As a side note, we could use the zero value (runtime.zeroVal) for this particular case. |
BTW, these are not heap-allocated elements, but statically allocated elements (in the data section). |
Another observation. Here's a snippet of asm:
We are painstakingly filling out For some sizes and types of |
Ah, @randall77 made that same suggestion over at
FWIW, I tried this in https://go-review.googlesource.com/c/go/+/42170/ and got stuck. So that's a starting place if anyone wants to tackle this. |
And this is #23948. We keep re-discovering this whole suit of issues and possible solutions. We just haven't fixed them. :P |
Using
go1.12
Consider the following snippet:
This currently prints:
Which is indicative that each boxed integer is getting it's own heap allocated element (since the data pointer is different for every element). It seems that the compiler should be able to reuse boxed elements that are of the same value.
Furthermore, I would expect this work across different types with the same underlying kind. Thus, I would also expect:
to all share the same boxed element since all three types are of the
int32
kind.\cc @randall77
The text was updated successfully, but these errors were encountered: