aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/gc/main.go
diff options
context:
space:
mode:
authorMatthew Dempsky <mdempsky@google.com>2021-06-14 16:26:26 -0700
committerMatthew Dempsky <mdempsky@google.com>2021-06-16 20:57:38 +0000
commitdd95a4e3dbe1e060b59840efd7311e8d5e82c08c (patch)
treee0f6e1be69b34bee04d9c415c0cd8ff50c95bb69 /src/cmd/compile/internal/gc/main.go
parent132ea56d292eac0226eef4bc32d784b0300c3bce (diff)
downloadgo-dd95a4e3dbe1e060b59840efd7311e8d5e82c08c.tar.gz
go-dd95a4e3dbe1e060b59840efd7311e8d5e82c08c.zip
[dev.typeparams] cmd/compile: simplify SSA devirtualization
This CL implements a few improvements to SSA devirtualization to make it simpler and more general: 1. Change reflectdata.ITabAddr to now immediately generate the wrapper functions and write out the itab symbol data. Previously, these were each handled by separate phases later on. 2. Removes the hack in typecheck where we marked itabs that we expected to need later. Instead, the calls to ITabAddr in walk now handle generating the wrappers. 3. Changes the SSA interface call devirtualization algorithm to just use the itab symbol data (namely, its relocations) to figure out what pointer is available in memory at the given offset. This decouples it somewhat from reflectdata. Change-Id: I8fe06922af8f8a1e7c93f5aff2b60ff59b8e7114 Reviewed-on: https://go-review.googlesource.com/c/go/+/327871 Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Go Bot <gobot@golang.org> Trust: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com>
Diffstat (limited to 'src/cmd/compile/internal/gc/main.go')
-rw-r--r--src/cmd/compile/internal/gc/main.go21
1 files changed, 10 insertions, 11 deletions
diff --git a/src/cmd/compile/internal/gc/main.go b/src/cmd/compile/internal/gc/main.go
index ce50cbb4c2..c0346c0206 100644
--- a/src/cmd/compile/internal/gc/main.go
+++ b/src/cmd/compile/internal/gc/main.go
@@ -181,7 +181,6 @@ func Main(archInit func(*ssagen.ArchInfo)) {
typecheck.Target = new(ir.Package)
- typecheck.NeedITab = func(t, iface *types.Type) { reflectdata.ITabAddr(t, iface) }
typecheck.NeedRuntimeType = reflectdata.NeedRuntimeType // TODO(rsc): TypeSym for lock?
base.AutogeneratedPos = makePos(src.NewFileBase("<autogenerated>", "<autogenerated>"), 1, 0)
@@ -193,6 +192,11 @@ func Main(archInit func(*ssagen.ArchInfo)) {
dwarfgen.RecordPackageName()
+ // Prepare for backend processing. This must happen before pkginit,
+ // because it generates itabs for initializing global variables.
+ typecheck.InitRuntime()
+ ssagen.InitConfig()
+
// Build init task.
if initTask := pkginit.Task(); initTask != nil {
typecheck.Export(initTask)
@@ -252,6 +256,11 @@ func Main(archInit func(*ssagen.ArchInfo)) {
base.Timer.Start("fe", "escapes")
escape.Funcs(typecheck.Target.Decls)
+ // TODO(mdempsky): This is a hack. We need a proper, global work
+ // queue for scheduling function compilation so components don't
+ // need to adjust their behavior depending on when they're called.
+ reflectdata.AfterGlobalEscapeAnalysis = true
+
// Collect information for go:nowritebarrierrec
// checking. This must happen before transforming closures during Walk
// We'll do the final check after write barriers are
@@ -260,17 +269,7 @@ func Main(archInit func(*ssagen.ArchInfo)) {
ssagen.EnableNoWriteBarrierRecCheck()
}
- // Prepare for SSA compilation.
- // This must be before CompileITabs, because CompileITabs
- // can trigger function compilation.
- typecheck.InitRuntime()
- ssagen.InitConfig()
-
- // Just before compilation, compile itabs found on
- // the right side of OCONVIFACE so that methods
- // can be de-virtualized during compilation.
ir.CurFunc = nil
- reflectdata.CompileITabs()
// Compile top level functions.
// Don't use range--walk can add functions to Target.Decls.