Skip to content

Commit

Permalink
[dev.typeparams] all: merge dev.regabi (ec741b0) into dev.typeparams
Browse files Browse the repository at this point in the history
Conflicts:

* src/cmd/compile/internal/gc/main.go

Merge List:

* 2020-12-22 ec741b0 [dev.regabi] all: merge master (c9fb4eb) into dev.regabi
* 2020-12-22 acc32ea [dev.regabi] codereview.cfg: add config for dev.regabi
* 2020-12-22 c9fb4eb cmd/link: handle grouped resource sections
* 2020-12-22 c40934b [dev.regabi] cmd/compile: adjust one case in walkexpr
* 2020-12-22 280e7fd [dev.regabi] cmd/compile: only access Func method on concrete types
* 2020-12-22 51ba53f [dev.regabi] cmd/compile: separate misc for gc split
* 2020-12-22 572f168 [dev.regabi] cmd/compile: separate various from Main
* 2020-12-22 3b12c6d [dev.regabi] cmd/compile: separate typecheck more cleanly
* 2020-12-22 7c8f535 [dev.regabi] cmd/compile: separate dowidth better
* 2020-12-22 c06a354 test: trigger SIGSEGV instead of SIGTRAP in issue11656.go
* 2020-12-22 0aa9b47 cmd/pack: r command create output file if not exist
* 2020-12-22 cb28c96 [dev.regabi] cmd/compile,cmd/link: initial support for ABI wrappers
* 2020-12-22 c8610e4 [dev.regabi] cmd/compile: add ir.BasicLit to represent literals
* 2020-12-22 3512cde [dev.regabi] cmd/compile: stop reusing Ntype for OSLICELIT length
* 2020-12-22 2755361 [dev.regabi] cmd/compile: change noder.declNames to returns ir.Names
* 2020-12-22 301af2c [dev.regabi] runtime/race: adjust test pattern match for ABI wrapper
* 2020-12-22 4d27c4c runtime: correct error handling in several FreeBSD syscall wrappers
* 2020-12-22 9b61471 cmd/pack: treat compiler's -linkobj output as "compiler object"
* 2020-12-22 306b245 [dev.regabi] runtime: fix ABI targets in runtime.panic{Index,Slice} shims
* 2020-12-21 bc7e4d9 syscall: don't generate ptrace on iOS
* 2020-12-21 94cfeca [dev.regabi] cmd/compile: stop using ONONAME with Name
* 2020-12-21 cb4898a [dev.regabi] cmd/compile: simplify declaration importing
* 2020-12-21 06915ac [dev.regabi] cmd/compile: move itabname call out of implements
* 2020-12-21 6cff874 runtime/metrics: add Read examples
* 2020-12-21 8438a57 runtime: use _exit on darwin
* 2020-12-21 cb95819 runtime: detect netbsd netpoll overrun in sysmon
* 2020-12-21 53c984d runtime: skip wakep call in wakeNetPoller on Plan 9
* 2020-12-21 9abbe27 test: skip issue11656.go on mips/mips64/ppc64

Change-Id: Ia12a1892195f5e08bb41465374124c71a1a135f6
  • Loading branch information
rsc committed Dec 22, 2020
2 parents e02a007 + ec741b0 commit 91cc51e
Show file tree
Hide file tree
Showing 78 changed files with 1,436 additions and 660 deletions.
1 change: 1 addition & 0 deletions src/cmd/compile/internal/base/debug.go
Expand Up @@ -51,6 +51,7 @@ type DebugFlags struct {
TypeAssert int `help:"print information about type assertion inlining"`
TypecheckInl int `help:"eager typechecking of inline function bodies"`
WB int `help:"print information about write barriers"`
ABIWrap int `help:"print information about ABI wrapper generation"`

any bool // set when any of the values have been set
}
Expand Down
3 changes: 3 additions & 0 deletions src/cmd/compile/internal/base/flag.go
Expand Up @@ -82,6 +82,8 @@ type CmdFlags struct {
CompilingRuntime bool "flag:\"+\" help:\"compiling runtime\""

// Longer names
ABIWrap bool "help:\"enable generation of ABI wrappers\""
ABIWrapLimit int "help:\"emit at most N ABI wrappers (for debugging)\""
AsmHdr string "help:\"write assembly header to `file`\""
Bench string "help:\"append benchmark times to `file`\""
BlockProfile string "help:\"write block profile to `file`\""
Expand Down Expand Up @@ -141,6 +143,7 @@ func ParseFlags() {
Flag.LowerP = &Ctxt.Pkgpath
Flag.LowerV = &Ctxt.Debugvlog

Flag.ABIWrap = objabi.Regabi_enabled != 0
Flag.Dwarf = objabi.GOARCH != "wasm"
Flag.DwarfBASEntries = &Ctxt.UseBASEntries
Flag.DwarfLocationLists = &Ctxt.Flag_locationlists
Expand Down
9 changes: 8 additions & 1 deletion src/cmd/compile/internal/gc/abiutils_test.go
Expand Up @@ -29,13 +29,20 @@ func TestMain(m *testing.M) {
thearch.LinkArch = &x86.Linkamd64
thearch.REGSP = x86.REGSP
thearch.MAXWIDTH = 1 << 50
MaxWidth = thearch.MAXWIDTH
base.Ctxt = obj.Linknew(thearch.LinkArch)
base.Ctxt.DiagFunc = base.Errorf
base.Ctxt.DiagFlush = base.FlushErrors
base.Ctxt.Bso = bufio.NewWriter(os.Stdout)
Widthptr = thearch.LinkArch.PtrSize
Widthreg = thearch.LinkArch.RegSize
initializeTypesPackage()
types.TypeLinkSym = func(t *types.Type) *obj.LSym {
return typenamesym(t).Linksym()
}
types.TypeLinkSym = func(t *types.Type) *obj.LSym {
return typenamesym(t).Linksym()
}
TypecheckInit()
os.Exit(m.Run())
}

Expand Down
4 changes: 2 additions & 2 deletions src/cmd/compile/internal/gc/alg.go
Expand Up @@ -816,7 +816,7 @@ func eqstring(s, t ir.Node) (eqlen *ir.BinaryExpr, eqmem *ir.CallExpr) {
fn := syslook("memequal")
fn = substArgTypes(fn, types.Types[types.TUINT8], types.Types[types.TUINT8])
call := ir.NewCallExpr(base.Pos, ir.OCALL, fn, []ir.Node{sptr, tptr, ir.Copy(slen)})
call = typecheck(call, ctxExpr|ctxMultiOK).(*ir.CallExpr)
TypecheckCall(call)

cmp := ir.NewBinaryExpr(base.Pos, ir.OEQ, slen, tlen)
cmp = typecheck(cmp, ctxExpr).(*ir.BinaryExpr)
Expand Down Expand Up @@ -853,7 +853,7 @@ func eqinterface(s, t ir.Node) (eqtab *ir.BinaryExpr, eqdata *ir.CallExpr) {
tdata.SetTypecheck(1)

call := ir.NewCallExpr(base.Pos, ir.OCALL, fn, []ir.Node{stab, sdata, tdata})
call = typecheck(call, ctxExpr|ctxMultiOK).(*ir.CallExpr)
TypecheckCall(call)

cmp := ir.NewBinaryExpr(base.Pos, ir.OEQ, stab, ttab)
cmp = typecheck(cmp, ctxExpr).(*ir.BinaryExpr)
Expand Down
29 changes: 16 additions & 13 deletions src/cmd/compile/internal/gc/align.go
Expand Up @@ -7,12 +7,14 @@ package gc
import (
"bytes"
"cmd/compile/internal/base"
"cmd/compile/internal/ir"
"cmd/compile/internal/types"
"fmt"
"sort"
)

// MaxWidth is the maximum size of a value on the target architecture.
var MaxWidth int64

// sizeCalculationDisabled indicates whether it is safe
// to calculate Types' widths and alignments. See dowidth.
var sizeCalculationDisabled bool
Expand Down Expand Up @@ -84,7 +86,7 @@ func expandiface(t *types.Type) {

sort.Sort(methcmp(methods))

if int64(len(methods)) >= thearch.MAXWIDTH/int64(Widthptr) {
if int64(len(methods)) >= MaxWidth/int64(Widthptr) {
base.ErrorfAt(typePos(t), "interface too large")
}
for i, m := range methods {
Expand Down Expand Up @@ -118,21 +120,15 @@ func widstruct(errtype *types.Type, t *types.Type, o int64, flag int) int64 {
o = Rnd(o, int64(f.Type.Align))
}
f.Offset = o
if n := ir.AsNode(f.Nname); n != nil {
n := n.Name()
if f.Nname != nil {
// addrescapes has similar code to update these offsets.
// Usually addrescapes runs after widstruct,
// in which case we could drop this,
// but function closure functions are the exception.
// NOTE(rsc): This comment may be stale.
// It's possible the ordering has changed and this is
// now the common case. I'm not sure.
if n.Name().Stackcopy != nil {
n.Name().Stackcopy.SetFrameOffset(o)
n.SetFrameOffset(0)
} else {
n.SetFrameOffset(o)
}
f.Nname.(types.VarObject).RecordFrameOffset(o)
}

w := f.Type.Width
Expand All @@ -143,7 +139,7 @@ func widstruct(errtype *types.Type, t *types.Type, o int64, flag int) int64 {
lastzero = o
}
o += w
maxwidth := thearch.MAXWIDTH
maxwidth := MaxWidth
// On 32-bit systems, reflect tables impose an additional constraint
// that each field start offset must fit in 31 bits.
if maxwidth < 1<<32 {
Expand Down Expand Up @@ -206,7 +202,7 @@ func findTypeLoop(t *types.Type, path *[]*types.Type) bool {
}

*path = append(*path, t)
if findTypeLoop(t.Obj().(*ir.Name).Ntype.Type(), path) {
if findTypeLoop(t.Obj().(types.TypeObject).TypeDefn(), path) {
return true
}
*path = (*path)[:len(*path)-1]
Expand Down Expand Up @@ -419,7 +415,7 @@ func dowidth(t *types.Type) {

dowidth(t.Elem())
if t.Elem().Width != 0 {
cap := (uint64(thearch.MAXWIDTH) - 1) / uint64(t.Elem().Width)
cap := (uint64(MaxWidth) - 1) / uint64(t.Elem().Width)
if uint64(t.NumElem()) > cap {
base.ErrorfAt(typePos(t), "type %L larger than address space", t)
}
Expand Down Expand Up @@ -479,6 +475,13 @@ func dowidth(t *types.Type) {
resumecheckwidth()
}

// CalcStructSize calculates the size of s,
// filling in s.Width and s.Align,
// even if size calculation is otherwise disabled.
func CalcStructSize(s *types.Type) {
s.Width = widstruct(s, s, 0, 1) // sets align
}

// when a type's width should be known, we call checkwidth
// to compute it. during a declaration like
//
Expand Down
8 changes: 4 additions & 4 deletions src/cmd/compile/internal/gc/closure.go
Expand Up @@ -76,7 +76,7 @@ func (p *noder) funcLit(expr *syntax.FuncLit) ir.Node {
// function associated with the closure.
// TODO: This creation of the named function should probably really be done in a
// separate pass from type-checking.
func typecheckclosure(clo ir.Node, top int) {
func typecheckclosure(clo *ir.ClosureExpr, top int) {
fn := clo.Func()
// Set current associated iota value, so iota can be used inside
// function in ConstSpec, see issue #22344
Expand Down Expand Up @@ -327,13 +327,13 @@ func transformclosure(fn *ir.Func) {

// hasemptycvars reports whether closure clo has an
// empty list of captured vars.
func hasemptycvars(clo ir.Node) bool {
func hasemptycvars(clo *ir.ClosureExpr) bool {
return len(clo.Func().ClosureVars) == 0
}

// closuredebugruntimecheck applies boilerplate checks for debug flags
// and compiling runtime
func closuredebugruntimecheck(clo ir.Node) {
func closuredebugruntimecheck(clo *ir.ClosureExpr) {
if base.Debug.Closure > 0 {
if clo.Esc() == EscHeap {
base.WarnfAt(clo.Pos(), "heap closure, captured vars = %v", clo.Func().ClosureVars)
Expand All @@ -349,7 +349,7 @@ func closuredebugruntimecheck(clo ir.Node) {
// closureType returns the struct type used to hold all the information
// needed in the closure for clo (clo must be a OCLOSURE node).
// The address of a variable of the returned type can be cast to a func.
func closureType(clo ir.Node) *types.Type {
func closureType(clo *ir.ClosureExpr) *types.Type {
// Create closure in the form of a composite literal.
// supposing the closure captures an int i and a string s
// and has one float64 argument and no results,
Expand Down
29 changes: 15 additions & 14 deletions src/cmd/compile/internal/gc/dcl.go
Expand Up @@ -130,18 +130,16 @@ func declare(n *ir.Name, ctxt ir.Class) {

// declare variables from grammar
// new_name_list (type | [type] = expr_list)
func variter(vl []ir.Node, t ir.Ntype, el []ir.Node) []ir.Node {
func variter(vl []*ir.Name, t ir.Ntype, el []ir.Node) []ir.Node {
var init []ir.Node
doexpr := len(el) > 0

if len(el) == 1 && len(vl) > 1 {
e := el[0]
as2 := ir.Nod(ir.OAS2, nil, nil)
as2.PtrList().Set(vl)
as2.PtrRlist().Set1(e)
for _, v := range vl {
v := v.(*ir.Name)
v.SetOp(ir.ONAME)
as2.PtrList().Append(v)
declare(v, dclcontext)
v.Ntype = t
v.Defn = as2
Expand All @@ -153,20 +151,16 @@ func variter(vl []ir.Node, t ir.Ntype, el []ir.Node) []ir.Node {
return append(init, as2)
}

nel := len(el)
for _, v := range vl {
v := v.(*ir.Name)
for i, v := range vl {
var e ir.Node
if doexpr {
if len(el) == 0 {
base.Errorf("assignment mismatch: %d variables but %d values", len(vl), nel)
if i >= len(el) {
base.Errorf("assignment mismatch: %d variables but %d values", len(vl), len(el))
break
}
e = el[0]
el = el[1:]
e = el[i]
}

v.SetOp(ir.ONAME)
declare(v, dclcontext)
v.Ntype = t

Expand All @@ -182,8 +176,8 @@ func variter(vl []ir.Node, t ir.Ntype, el []ir.Node) []ir.Node {
}
}

if len(el) != 0 {
base.Errorf("assignment mismatch: %d variables but %d values", len(vl), nel)
if len(el) > len(vl) {
base.Errorf("assignment mismatch: %d variables but %d values", len(vl), len(el))
}
return init
}
Expand Down Expand Up @@ -448,6 +442,12 @@ type funcStackEnt struct {
dclcontext ir.Class
}

func CheckFuncStack() {
if len(funcStack) != 0 {
base.Fatalf("funcStack is non-empty: %v", len(funcStack))
}
}

// finish the body.
// called in auto-declaration context.
// returns in extern-declaration context.
Expand Down Expand Up @@ -892,6 +892,7 @@ func (c *nowritebarrierrecChecker) findExtraCalls(nn ir.Node) {
case ir.ONAME:
callee = arg.Name().Defn.(*ir.Func)
case ir.OCLOSURE:
arg := arg.(*ir.ClosureExpr)
callee = arg.Func()
default:
base.Fatalf("expected ONAME or OCLOSURE node, got %+v", arg)
Expand Down
4 changes: 2 additions & 2 deletions src/cmd/compile/internal/gc/embed.go
Expand Up @@ -24,7 +24,7 @@ const (
embedFiles
)

func varEmbed(p *noder, names []ir.Node, typ ir.Ntype, exprs []ir.Node, embeds []PragmaEmbed) (newExprs []ir.Node) {
func varEmbed(p *noder, names []*ir.Name, typ ir.Ntype, exprs []ir.Node, embeds []PragmaEmbed) (newExprs []ir.Node) {
haveEmbed := false
for _, decl := range p.file.DeclList {
imp, ok := decl.(*syntax.ImportDecl)
Expand Down Expand Up @@ -66,7 +66,7 @@ func varEmbed(p *noder, names []ir.Node, typ ir.Ntype, exprs []ir.Node, embeds [
return exprs
}

v := names[0].(*ir.Name)
v := names[0]
Target.Embeds = append(Target.Embeds, v)
v.Embed = new([]ir.Embed)
for _, e := range embeds {
Expand Down
9 changes: 3 additions & 6 deletions src/cmd/compile/internal/gc/escape.go
Expand Up @@ -143,10 +143,6 @@ type EscEdge struct {
notes *EscNote
}

func init() {
ir.EscFmt = escFmt
}

// escFmt is called from node printing to print information about escape analysis results.
func escFmt(n ir.Node) string {
text := ""
Expand Down Expand Up @@ -682,6 +678,7 @@ func (e *Escape) exprSkipInit(k EscHole, n ir.Node) {
}

case ir.OCLOSURE:
n := n.(*ir.ClosureExpr)
k = e.spill(k, n)

// Link addresses of captured variables to closure.
Expand Down Expand Up @@ -883,7 +880,7 @@ func (e *Escape) call(ks []EscHole, call, where ir.Node) {
case v.Op() == ir.ONAME && v.(*ir.Name).Class() == ir.PFUNC:
fn = v.(*ir.Name)
case v.Op() == ir.OCLOSURE:
fn = v.Func().Nname
fn = v.(*ir.ClosureExpr).Func().Nname
}
case ir.OCALLMETH:
fn = methodExprName(call.Left())
Expand Down Expand Up @@ -1887,7 +1884,7 @@ func heapAllocReason(n ir.Node) string {
return "too large for stack"
}

if n.Op() == ir.OCLOSURE && closureType(n).Size() >= maxImplicitStackVarSize {
if n.Op() == ir.OCLOSURE && closureType(n.(*ir.ClosureExpr)).Size() >= maxImplicitStackVarSize {
return "too large for stack"
}
if n.Op() == ir.OCALLPART && partialCallType(n.(*ir.CallPartExpr)).Size() >= maxImplicitStackVarSize {
Expand Down

0 comments on commit 91cc51e

Please sign in to comment.