]> Cypherpunks repositories - gostls13.git/commit
cmd/compile/internal/pkginit: separate "init" and "inittask" logic
authorMatthew Dempsky <mdempsky@google.com>
Tue, 31 Aug 2021 20:21:11 +0000 (13:21 -0700)
committerMatthew Dempsky <mdempsky@google.com>
Wed, 1 Sep 2021 18:16:17 +0000 (18:16 +0000)
commit6c5f0282422043b913bb7908efb8849905777c8b
treeb633401893e126f439a65f677d74ff3e87b17df5
parent8f397bc1183b1094f8d0c702668b1e2b43dc8797
cmd/compile/internal/pkginit: separate "init" and "inittask" logic

This CL splits the creation of the "init" function responsible for
executing package-scope variable initialization statemens from the
creation of the "inittask" record that tells the runtime how to
sequence all program-wide package initialization.

Longer term, this is desirable because sorting variable initialization
is already handled by types2 (with Info.InitOrder), so we might as
well reuse that.

As a more immediate impetus, for unified IR, I want to defer method
wrapper generation until after inlining (to know which wrappers are
needed). But the staticinit optimization used to decide whether to
emit the inittask calls into reflectdata, which in turn tries to
generate its own method wrappers. So separating the work allows to
create the "init" function early and then emit "inittask" after
inlining is done.

Change-Id: Ice1d421f92feecaaeafdf7da6b9647c0f27e3571
Reviewed-on: https://go-review.googlesource.com/c/go/+/346629
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
src/cmd/compile/internal/gc/main.go
src/cmd/compile/internal/pkginit/init.go
src/cmd/compile/internal/pkginit/initorder.go