mirror of
https://github.com/golang/go.git
synced 2024-09-21 18:38:37 +00:00
[dev.regabi] cmd/compile: separate misc for gc split
Misc cleanup for splitting package gc: API tweaks and boundary adjustments. The change in ir.NewBlockStmt makes it a drop-in replacement for liststmt. Change-Id: I9455fe8ccae7d71fe8ccf390ac96672389bf4f3d Reviewed-on: https://go-review.googlesource.com/c/go/+/279305 Trust: Russ Cox <rsc@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
This commit is contained in:
parent
572f168ed2
commit
51ba53f5c2
@ -143,10 +143,6 @@ type EscEdge struct {
|
|||||||
notes *EscNote
|
notes *EscNote
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
|
||||||
ir.EscFmt = escFmt
|
|
||||||
}
|
|
||||||
|
|
||||||
// escFmt is called from node printing to print information about escape analysis results.
|
// escFmt is called from node printing to print information about escape analysis results.
|
||||||
func escFmt(n ir.Node) string {
|
func escFmt(n ir.Node) string {
|
||||||
text := ""
|
text := ""
|
||||||
|
@ -685,6 +685,21 @@ func (r *importReader) typeExt(t *types.Type) {
|
|||||||
// so we can use index to reference the symbol.
|
// so we can use index to reference the symbol.
|
||||||
var typeSymIdx = make(map[*types.Type][2]int64)
|
var typeSymIdx = make(map[*types.Type][2]int64)
|
||||||
|
|
||||||
|
func BaseTypeIndex(t *types.Type) int64 {
|
||||||
|
tbase := t
|
||||||
|
if t.IsPtr() && t.Sym() == nil && t.Elem().Sym() != nil {
|
||||||
|
tbase = t.Elem()
|
||||||
|
}
|
||||||
|
i, ok := typeSymIdx[tbase]
|
||||||
|
if !ok {
|
||||||
|
return -1
|
||||||
|
}
|
||||||
|
if t != tbase {
|
||||||
|
return i[1]
|
||||||
|
}
|
||||||
|
return i[0]
|
||||||
|
}
|
||||||
|
|
||||||
func (r *importReader) doInline(fn *ir.Func) {
|
func (r *importReader) doInline(fn *ir.Func) {
|
||||||
if len(fn.Inl.Body) != 0 {
|
if len(fn.Inl.Body) != 0 {
|
||||||
base.Fatalf("%v already has inline body", fn)
|
base.Fatalf("%v already has inline body", fn)
|
||||||
|
@ -54,9 +54,6 @@ func hidePanic() {
|
|||||||
// Target is the package being compiled.
|
// Target is the package being compiled.
|
||||||
var Target *ir.Package
|
var Target *ir.Package
|
||||||
|
|
||||||
// timing data for compiler phases
|
|
||||||
var timings Timings
|
|
||||||
|
|
||||||
// Main parses flags and Go source files specified in the command-line
|
// Main parses flags and Go source files specified in the command-line
|
||||||
// arguments, type-checks the parsed Go package, compiles functions to machine
|
// arguments, type-checks the parsed Go package, compiles functions to machine
|
||||||
// code, and finally writes the compiled package definition to disk.
|
// code, and finally writes the compiled package definition to disk.
|
||||||
@ -189,6 +186,7 @@ func Main(archInit func(*Arch)) {
|
|||||||
logopt.LogJsonOption(base.Flag.JSON)
|
logopt.LogJsonOption(base.Flag.JSON)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ir.EscFmt = escFmt
|
||||||
IsIntrinsicCall = isIntrinsicCall
|
IsIntrinsicCall = isIntrinsicCall
|
||||||
SSADumpInline = ssaDumpInline
|
SSADumpInline = ssaDumpInline
|
||||||
initSSAEnv()
|
initSSAEnv()
|
||||||
@ -962,9 +960,11 @@ type lang struct {
|
|||||||
// any language version is supported.
|
// any language version is supported.
|
||||||
var langWant lang
|
var langWant lang
|
||||||
|
|
||||||
// langSupported reports whether language version major.minor is
|
// AllowsGoVersion reports whether a particular package
|
||||||
// supported in a particular package.
|
// is allowed to use Go version major.minor.
|
||||||
func langSupported(major, minor int, pkg *types.Pkg) bool {
|
// We assume the imported packages have all been checked,
|
||||||
|
// so we only have to check the local package against the -lang flag.
|
||||||
|
func AllowsGoVersion(pkg *types.Pkg, major, minor int) bool {
|
||||||
if pkg == nil {
|
if pkg == nil {
|
||||||
// TODO(mdempsky): Set Pkg for local types earlier.
|
// TODO(mdempsky): Set Pkg for local types earlier.
|
||||||
pkg = types.LocalPkg
|
pkg = types.LocalPkg
|
||||||
@ -973,13 +973,16 @@ func langSupported(major, minor int, pkg *types.Pkg) bool {
|
|||||||
// Assume imported packages passed type-checking.
|
// Assume imported packages passed type-checking.
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
if langWant.major == 0 && langWant.minor == 0 {
|
if langWant.major == 0 && langWant.minor == 0 {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
return langWant.major > major || (langWant.major == major && langWant.minor >= minor)
|
return langWant.major > major || (langWant.major == major && langWant.minor >= minor)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func langSupported(major, minor int, pkg *types.Pkg) bool {
|
||||||
|
return AllowsGoVersion(pkg, major, minor)
|
||||||
|
}
|
||||||
|
|
||||||
// checkLang verifies that the -lang flag holds a valid value, and
|
// checkLang verifies that the -lang flag holds a valid value, and
|
||||||
// exits if not. It initializes data used by langSupported.
|
// exits if not. It initializes data used by langSupported.
|
||||||
func checkLang() {
|
func checkLang() {
|
||||||
|
@ -127,8 +127,7 @@ func dumpdata() {
|
|||||||
addsignats(Target.Externs)
|
addsignats(Target.Externs)
|
||||||
dumpsignats()
|
dumpsignats()
|
||||||
dumptabs()
|
dumptabs()
|
||||||
ptabsLen := len(ptabs)
|
numPTabs, numITabs := CountTabs()
|
||||||
itabsLen := len(itabs)
|
|
||||||
dumpimportstrings()
|
dumpimportstrings()
|
||||||
dumpbasictypes()
|
dumpbasictypes()
|
||||||
dumpembeds()
|
dumpembeds()
|
||||||
@ -168,10 +167,11 @@ func dumpdata() {
|
|||||||
if numExports != len(Target.Exports) {
|
if numExports != len(Target.Exports) {
|
||||||
base.Fatalf("Target.Exports changed after compile functions loop")
|
base.Fatalf("Target.Exports changed after compile functions loop")
|
||||||
}
|
}
|
||||||
if ptabsLen != len(ptabs) {
|
newNumPTabs, newNumITabs := CountTabs()
|
||||||
|
if newNumPTabs != numPTabs {
|
||||||
base.Fatalf("ptabs changed after compile functions loop")
|
base.Fatalf("ptabs changed after compile functions loop")
|
||||||
}
|
}
|
||||||
if itabsLen != len(itabs) {
|
if newNumITabs != numITabs {
|
||||||
base.Fatalf("itabs changed after compile functions loop")
|
base.Fatalf("itabs changed after compile functions loop")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,6 +34,10 @@ type ptabEntry struct {
|
|||||||
t *types.Type
|
t *types.Type
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func CountTabs() (numPTabs, numITabs int) {
|
||||||
|
return len(ptabs), len(itabs)
|
||||||
|
}
|
||||||
|
|
||||||
// runtime interface and reflection data structures
|
// runtime interface and reflection data structures
|
||||||
var (
|
var (
|
||||||
signatmu sync.Mutex // protects signatset and signatslice
|
signatmu sync.Mutex // protects signatset and signatslice
|
||||||
@ -1158,13 +1162,9 @@ func dtypesym(t *types.Type) *obj.LSym {
|
|||||||
if base.Ctxt.Pkgpath != "runtime" || (tbase != types.Types[tbase.Kind()] && tbase != types.ByteType && tbase != types.RuneType && tbase != types.ErrorType) { // int, float, etc
|
if base.Ctxt.Pkgpath != "runtime" || (tbase != types.Types[tbase.Kind()] && tbase != types.ByteType && tbase != types.RuneType && tbase != types.ErrorType) { // int, float, etc
|
||||||
// named types from other files are defined only by those files
|
// named types from other files are defined only by those files
|
||||||
if tbase.Sym() != nil && tbase.Sym().Pkg != types.LocalPkg {
|
if tbase.Sym() != nil && tbase.Sym().Pkg != types.LocalPkg {
|
||||||
if i, ok := typeSymIdx[tbase]; ok {
|
if i := BaseTypeIndex(t); i >= 0 {
|
||||||
lsym.Pkg = tbase.Sym().Pkg.Prefix
|
lsym.Pkg = tbase.Sym().Pkg.Prefix
|
||||||
if t != tbase {
|
lsym.SymIdx = int32(i)
|
||||||
lsym.SymIdx = int32(i[1])
|
|
||||||
} else {
|
|
||||||
lsym.SymIdx = int32(i[0])
|
|
||||||
}
|
|
||||||
lsym.Set(obj.AttrIndexed, true)
|
lsym.Set(obj.AttrIndexed, true)
|
||||||
}
|
}
|
||||||
return lsym
|
return lsym
|
||||||
|
@ -11,6 +11,8 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var timings Timings
|
||||||
|
|
||||||
// Timings collects the execution times of labeled phases
|
// Timings collects the execution times of labeled phases
|
||||||
// which are added trough a sequence of Start/Stop calls.
|
// which are added trough a sequence of Start/Stop calls.
|
||||||
// Events may be associated with each phase via AddEvent.
|
// Events may be associated with each phase via AddEvent.
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
package ir
|
package ir
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"cmd/compile/internal/base"
|
||||||
"cmd/compile/internal/types"
|
"cmd/compile/internal/types"
|
||||||
"cmd/internal/src"
|
"cmd/internal/src"
|
||||||
)
|
)
|
||||||
@ -164,6 +165,12 @@ type BlockStmt struct {
|
|||||||
func NewBlockStmt(pos src.XPos, list []Node) *BlockStmt {
|
func NewBlockStmt(pos src.XPos, list []Node) *BlockStmt {
|
||||||
n := &BlockStmt{}
|
n := &BlockStmt{}
|
||||||
n.pos = pos
|
n.pos = pos
|
||||||
|
if !pos.IsKnown() {
|
||||||
|
n.pos = base.Pos
|
||||||
|
if len(list) > 0 {
|
||||||
|
n.pos = list[0].Pos()
|
||||||
|
}
|
||||||
|
}
|
||||||
n.op = OBLOCK
|
n.op = OBLOCK
|
||||||
n.List_.Set(list)
|
n.List_.Set(list)
|
||||||
return n
|
return n
|
||||||
|
Loading…
Reference in New Issue
Block a user