-
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: lay out global errors.New results in static data #30820
Comments
The compiler already does the latter part of what you described. Starting with:
The compiler generates:
|
I wonder, would there be a plan to do the same for simple global uses of Not that Which is maybe fine, but ideally we don't want developers to have to remember that distinction. |
Change https://go.dev/cl/426156 mentions this issue: |
Change https://go.dev/cl/450136 mentions this issue: |
Change https://go.dev/cl/452817 mentions this issue: |
This was disabled in CL 452676 out of an abundance of caution, but further analysis has shown that the failures were not being caused by this optimization. Instead the sequence of commits was: CL 450136 cmd/compile: handle simple inlined calls in staticinit ... CL 449937 archive/tar, archive/zip: return ErrInsecurePath for unsafe paths ... CL 451555 cmd/compile: fix static init for inlined calls The failures in question became compile failures in the first CL and started building again after the last CL. But in the interim the code had been broken by the middle CL. CL 451555 was just the first time that the tests could run and fail. For #30820. Change-Id: I65064032355b56fdb43d9731be2f9f32ef6ee600 Reviewed-on: https://go-review.googlesource.com/c/go/+/452817 Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com> Run-TryBot: Russ Cox <rsc@golang.org> Auto-Submit: Russ Cox <rsc@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
A significant fraction of init time in some programs
(notably the go command but surely others) is spent
executing lines like:
This is such a widespread use that it may well be
worth recognizing in the compiler and turning into
static data, so that it can be laid out in the data section,
discarded by the linker as appropriate, and have no
link-time overhead at all.
The specific pattern would be exactly the above
(
var foo = errors.New(constString)
) and it would turn intoThis would require that the compiler be able to lay out an
implicit interface conversion in the data section as well.
If that can't be done in general, it would suffice to special
case the "errors.errorString to error" conversion.
If this sounds like fun to someone familiar with the
compiler, please have a look. Thanks.
The text was updated successfully, but these errors were encountered: