diff options
author | Russ Cox <rsc@golang.org> | 2020-12-21 01:56:46 -0500 |
---|---|---|
committer | Russ Cox <rsc@golang.org> | 2020-12-21 19:23:33 +0000 |
commit | 1a523c8ab08e95ddfb7c50e19ddd6c73bb45daf5 (patch) | |
tree | 395738de0a3569f3f5cd51b4895402c17b8c358a /src/cmd/compile/internal/gc | |
parent | e999c1702250222b069691491d24dd5d020744de (diff) | |
download | go-1a523c8ab08e95ddfb7c50e19ddd6c73bb45daf5.tar.gz go-1a523c8ab08e95ddfb7c50e19ddd6c73bb45daf5.zip |
[dev.regabi] cmd/compile: separate nowritebarrierrec from main
Main knows a bit too much about nowritebarrierrec.
Abstract the API a little bit to make the package split easier.
Change-Id: I4b76bdb1fed73dfb0d44e1a6c86de8c2d29a9488
Reviewed-on: https://go-review.googlesource.com/c/go/+/279301
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Diffstat (limited to 'src/cmd/compile/internal/gc')
-rw-r--r-- | src/cmd/compile/internal/gc/dcl.go | 13 | ||||
-rw-r--r-- | src/cmd/compile/internal/gc/main.go | 12 |
2 files changed, 16 insertions, 9 deletions
diff --git a/src/cmd/compile/internal/gc/dcl.go b/src/cmd/compile/internal/gc/dcl.go index 20e5edc4cb..64b15077cd 100644 --- a/src/cmd/compile/internal/gc/dcl.go +++ b/src/cmd/compile/internal/gc/dcl.go @@ -15,7 +15,18 @@ import ( "strings" ) -// Declaration stack & operations +func EnableNoWriteBarrierRecCheck() { + nowritebarrierrecCheck = newNowritebarrierrecChecker() +} + +func NoWriteBarrierRecCheck() { + // Write barriers are now known. Check the + // call graph. + nowritebarrierrecCheck.check() + nowritebarrierrecCheck = nil +} + +var nowritebarrierrecCheck *nowritebarrierrecChecker func testdclstack() { if !types.IsDclstackValid() { diff --git a/src/cmd/compile/internal/gc/main.go b/src/cmd/compile/internal/gc/main.go index afb47cf15d..7f7cd63cdf 100644 --- a/src/cmd/compile/internal/gc/main.go +++ b/src/cmd/compile/internal/gc/main.go @@ -57,8 +57,6 @@ var Target *ir.Package // timing data for compiler phases var timings Timings -var nowritebarrierrecCheck *nowritebarrierrecChecker - // Main parses flags and Go source files specified in the command-line // arguments, type-checks the parsed Go package, compiles functions to machine // code, and finally writes the compiled package definition to disk. @@ -382,7 +380,7 @@ func Main(archInit func(*Arch)) { // We'll do the final check after write barriers are // inserted. if base.Flag.CompilingRuntime { - nowritebarrierrecCheck = newNowritebarrierrecChecker() + EnableNoWriteBarrierRecCheck() } // Phase 7: Transform closure bodies to properly reference captured variables. @@ -422,11 +420,9 @@ func Main(archInit func(*Arch)) { compileFunctions() - if nowritebarrierrecCheck != nil { - // Write barriers are now known. Check the - // call graph. - nowritebarrierrecCheck.check() - nowritebarrierrecCheck = nil + if base.Flag.CompilingRuntime { + // Write barriers are now known. Check the call graph. + NoWriteBarrierRecCheck() } // Finalize DWARF inline routine DIEs, then explicitly turn off |