diff options
author | Matthew Dempsky <mdempsky@google.com> | 2021-01-22 15:35:11 -0800 |
---|---|---|
committer | Matthew Dempsky <mdempsky@google.com> | 2021-01-22 16:32:37 -0800 |
commit | 6e46c8fbb5ba440cc503193220476c204100fb40 (patch) | |
tree | 67472f55b9b1f5ab66cbcfd39cf154c1f8c2011c /src/cmd/compile/internal/reflectdata/reflect.go | |
parent | e4ef30a66751c39bdd24764763531f1a4c325845 (diff) | |
parent | 7e0a81d2806b073c6455f73b10fbf2c811703f46 (diff) | |
download | go-6e46c8fbb5ba440cc503193220476c204100fb40.tar.gz go-6e46c8fbb5ba440cc503193220476c204100fb40.zip |
[dev.typeparams] all: merge dev.regabi (7e0a81d) into dev.typeparams
As with CL 285875, this required resolving some conflicts around
handling of //go:embed directives. Still further work is needed to
reject uses of //go:embed in files that don't import "embed", so this
is left as a TODO. (When this code was written for dev.typeparams, we
were still leaning towards not requiring the "embed" import.)
Also, the recent support for inlining closures (CL 283112) interacts
poorly with -G=3 mode. There are some known issues with this code
already (#43818), so for now this CL disables inlining of closures
when in -G=3 mode with a TODO to revisit this once closure inlining is
working fully.
Conflicts:
- src/cmd/compile/internal/noder/noder.go
- src/cmd/compile/internal/typecheck/dcl.go
- src/cmd/compile/internal/typecheck/func.go
- test/run.go
Merge List:
+ 2021-01-22 7e0a81d280 [dev.regabi] all: merge master (dab3e5a) into dev.regabi
+ 2021-01-22 dab3e5affe runtime: switch runtime to libc for openbsd/amd64
+ 2021-01-22 a1b53d85da cmd/go: add documentation for test and xtest fields output by go list
+ 2021-01-22 b268b60774 runtime: remove pthread_kill/pthread_self for openbsd
+ 2021-01-22 ec4051763d runtime: fix typo in mgcscavenge.go
+ 2021-01-22 7ece3a7b17 net/http: fix flaky TestDisableKeepAliveUpgrade
+ 2021-01-22 50cba0506f time: clarify Timer.Reset behavior on AfterFunc Timers
+ 2021-01-22 cf10e69f17 doc/go1.16: mention net/http.Transport.GetProxyConnectHeader
+ 2021-01-22 ec1b945265 doc/go1.16: mention path/filepath.WalkDir
+ 2021-01-22 11def3d40b doc/go1.16: mention syscall.AllThreadsSyscall
+ 2021-01-21 07b0235609 doc/go1.16: add notes about package-specific fs.FS changes
+ 2021-01-21 e2b4f1fea5 doc/go1.16: minor formatting fix
+ 2021-01-21 9f43a9e07b doc/go1.16: mention new debug/elf constants
+ 2021-01-21 3c2f11ba5b cmd/go: overwrite program name with full path
+ 2021-01-21 953d1feca9 all: introduce and use internal/execabs
+ 2021-01-21 b186e4d70d cmd/go: add test case for cgo CC setting
+ 2021-01-21 5a8a2265fb cmd/cgo: report exec errors a bit more clearly
+ 2021-01-21 46e2e2e9d9 cmd/go: pass resolved CC, GCCGO to cgo
+ 2021-01-21 3d40895e36 runtime: switch openbsd/arm64 to pthreads
+ 2021-01-21 d95ca91380 crypto/elliptic: fix P-224 field reduction
+ 2021-01-21 d7e71c01ad [dev.regabi] cmd/compile: replace ir.Name map with ir.NameSet for dwarf
+ 2021-01-21 5248f59a22 [dev.regabi] cmd/compile: replace ir.Name map with ir.NameSet for SSA
+ 2021-01-21 970d8b6cb2 [dev.regabi] cmd/compile: replace ir.Name map with ir.NameSet in inlining
+ 2021-01-21 68a4664475 [dev.regabi] cmd/compile: remove tempAssigns in walkCall1
+ 2021-01-21 fd9a391cdd [dev.regabi] cmd/compile: remove CallExpr.Rargs
+ 2021-01-21 19a6db6b63 [dev.regabi] cmd/compile: make sure mkcall* passed non-nil init
+ 2021-01-21 9f036844db [dev.regabi] cmd/compile: use ir.DoChildren directly in inlining
+ 2021-01-21 213c3905e9 [dev.regabi] cmd/compile: use node walked flag to prevent double walk for walkSelect
+ 2021-01-20 1760d736f6 [dev.regabi] cmd/compile: exporting, importing, and inlining functions with OCLOSURE
+ 2021-01-20 ecf4ebf100 cmd/internal/moddeps: check content of all modules in GOROOT
+ 2021-01-20 92cb157cf3 [dev.regabi] cmd/compile: late expansion of return values
+ 2021-01-20 d2d155d1ae runtime: don't adjust timer pp field in timerWaiting status
+ 2021-01-20 803d18fc6c cmd/go: set Incomplete field on go list output if no files match embed
+ 2021-01-20 6e243ce71d cmd/go: have go mod vendor copy embedded files in subdirs
+ 2021-01-20 be28e5abc5 cmd/go: fix mod_get_fallback test
+ 2021-01-20 928bda4f4a runtime: convert openbsd/amd64 locking to libc
+ 2021-01-19 824f2d635c cmd/go: allow go fmt to complete when embedded file is missing
+ 2021-01-19 0575e35e50 cmd/compile: require 'go 1.16' go.mod line for //go:embed
+ 2021-01-19 9423d50d53 [dev.regabi] cmd/compile: use '%q' for printing rune values less than 128
+ 2021-01-19 ccb2e90688 cmd/link: exit before Asmb2 if error
+ 2021-01-19 ca5774a5a5 embed: treat uninitialized FS as empty
+ 2021-01-19 d047c91a6c cmd/link,runtime: switch openbsd/amd64 to pthreads
+ 2021-01-19 61debffd97 runtime: factor out usesLibcall
+ 2021-01-19 9fed39d281 runtime: factor out mStackIsSystemAllocated
+ 2021-01-19 a2f825c542 [dev.regabi] cmd/compile: directly create go.map and go.track symbols
+ 2021-01-19 4a4212c0e5 [dev.regabi] cmd/compile: refactor Linksym creation
+ 2021-01-19 4f5c603c0f [dev.regabi] cmd/compile: cleanup callTargetLSym
+ 2021-01-18 dbab079835 runtime: free Windows event handles after last lock is dropped
+ 2021-01-18 5a8fbb0d2d os: do not close syscall.Stdin in TestReadStdin
+ 2021-01-18 422f38fb6c [dev.regabi] cmd/compile: move stack objects to liveness
+ 2021-01-18 6113db0bb4 [dev.regabi] cmd/compile: convert OPANIC argument to interface{} during typecheck
+ 2021-01-18 4c835f9169 [dev.regabi] cmd/compile: use LinksymOffsetExpr in TypePtr/ItabAddr
+ 2021-01-18 0ffa1ead6e [dev.regabi] cmd/compile: use *obj.LSym instead of *ir.Name for staticdata functions
+ 2021-01-17 7e0fa38aad [dev.regabi] cmd/compile: remove unneeded packages from ir.Pkgs
+ 2021-01-17 99a5db11ac [dev.regabi] cmd/compile: use LinksymOffsetExpr in walkConvInterface
+ 2021-01-17 87845d14f9 [dev.regabi] cmd/compile: add ir.TailCallStmt
+ 2021-01-17 e3027c6828 [dev.regabi] cmd/compile: fix linux-amd64-noopt builder
+ 2021-01-17 59ff93fe64 [dev.regabi] cmd/compile: rename NameOffsetExpr to LinksymOffsetExpr
+ 2021-01-17 82b9cae700 [dev.regabi] cmd/compile: change ir.NameOffsetExpr to use *obj.LSym instead of *Name
+ 2021-01-17 88956fc4b1 [dev.regabi] cmd/compile: stop analyze NameOffsetExpr.Name_ in escape analysis
+ 2021-01-17 7ce2a8383d [dev.regabi] cmd/compile: simplify stack temp initialization
+ 2021-01-17 ba0e8a92fa [dev.regabi] cmd/compile: refactor temp construction in walk
+ 2021-01-17 78e5aabcdb [dev.regabi] cmd/compile: replace Node.HasCall with walk.mayCall
+ 2021-01-16 6de9423445 [dev.regabi] cmd/compile: cleanup OAS2FUNC ordering
+ 2021-01-16 a956a0e909 [dev.regabi] cmd/compile, runtime: fix up comments/error messages from recent renames
+ 2021-01-16 ab3b67abfd [dev.regabi] cmd/compile: remove ONEWOBJ
+ 2021-01-16 c9b1445ac8 [dev.regabi] cmd/compile: remove TypeAssertExpr {Src,Dst}Type fields
+ 2021-01-15 682a1d2176 runtime: detect errors in DuplicateHandle
+ 2021-01-15 9f83418b83 cmd/link: remove GOROOT write in TestBuildForTvOS
+ 2021-01-15 ec9470162f cmd/compile: allow embed into any string or byte slice type
+ 2021-01-15 54198b04db cmd/compile: disallow embed of var inside func
+ 2021-01-15 b386c735e7 cmd/go: fix go generate docs
+ 2021-01-15 bb5075a525 syscall: remove RtlGenRandom and move it into internal/syscall
+ 2021-01-15 1deae0b597 os: invoke processKiller synchronously in testKillProcess
+ 2021-01-15 03a875137f [dev.regabi] cmd/compile: unexport reflectdata.WriteType
+ 2021-01-15 14537e6e54 [dev.regabi] cmd/compile: move stkobj symbol generation to SSA
+ 2021-01-15 ab523fc510 [dev.regabi] cmd/compile: don't promote Byval CaptureVars if Addrtaken
+ 2021-01-15 ff196c3e84 crypto/x509: update iOS bundled roots to version 55188.40.9
+ 2021-01-15 b7a698c73f [dev.regabi] test: disable test on windows because expected contains path separators.
+ 2021-01-15 4be7af23f9 [dev.regabi] cmd/compile: fix ICE during ir.Dump
+ 2021-01-14 e125ccd10e cmd/go: in 'go mod edit', validate versions given to -retract and -exclude
+ 2021-01-14 eb330020dc cmd/dist, cmd/go: pass -arch for C compilation on Darwin
+ 2021-01-14 84e8a06f62 cmd/cgo: remove unnecessary space in cgo export header
+ 2021-01-14 0c86b999c3 cmd/test2json: document passing -test.paniconexit0
+ 2021-01-14 9135795891 cmd/go/internal/load: report positions for embed errors
+ 2021-01-14 35b9c66601 [dev.regabi] cmd/compile,cmd/link: additional code review suggestions for CL 270863
+ 2021-01-14 d9b79e53bb cmd/compile: fix wrong complement for arm64 floating-point comparisons
+ 2021-01-14 c73232d08f cmd/go/internal/load: refactor setErrorPos to PackageError.setPos
+ 2021-01-14 6aa28d3e06 go/build: report positions for go:embed directives
+ 2021-01-14 9734fd482d [dev.regabi] cmd/compile: use node walked flag to prevent double walk for walkSwitch
+ 2021-01-14 f97983249a [dev.regabi] cmd/compile: move more PAUTOHEAP to SSA construction
+ 2021-01-14 4476300425 [dev.regabi] cmd/compile: use byte for CallExpr.Use
+ 2021-01-14 5a5ab24689 [dev.regabi] cmd/compile: do not rely on CallExpr.Rargs for detect already walked calls
+ 2021-01-14 983ac4b086 [dev.regabi] cmd/compile: fix ICE when initializing blank vars
+ 2021-01-13 7eb31d999c cmd/go: add hints to more missing sum error messages
+ 2021-01-13 d6d4673728 [dev.regabi] cmd/compile: fix GOEXPERIMENT=regabi builder
+ 2021-01-13 c41b999ad4 [dev.regabi] cmd/compile: refactor abiutils from "gc" into new "abi"
+ 2021-01-13 861707a8c8 [dev.regabi] cmd/compile: added limited //go:registerparams pragma for new ABI dev
+ 2021-01-13 c1370e918f [dev.regabi] cmd/compile: add code to support register ABI spills around morestack calls
+ 2021-01-13 2abd24f3b7 [dev.regabi] test: make run.go error messages slightly more informative
+ 2021-01-13 9a19481acb [dev.regabi] cmd/compile: make ordering for InvertFlags more stable
+ 2021-01-12 ba76567bc2 cmd/go/internal/modload: delete unused *mvsReqs.next method
+ 2021-01-12 665def2c11 encoding/asn1: document unmarshaling behavior for IMPLICIT string fields
+ 2021-01-11 81ea89adf3 cmd/go: fix non-script staleness checks interacting badly with GOFLAGS
+ 2021-01-11 759309029f doc: update editors.html for Go 1.16
+ 2021-01-11 c3b4c7093a cmd/internal/objfile: don't require runtime.symtab symbol for XCOFF
+ 2021-01-08 59bfc18e34 cmd/go: add hint to read 'go help vcs' to GOVCS errors
+ 2021-01-08 cd6f3a54e4 cmd/go: revise 'go help' documentation for modules
+ 2021-01-08 6192b98751 cmd/go: make hints in error messages more consistent
+ 2021-01-08 25886cf4bd cmd/go: preserve sums for indirect deps fetched by 'go mod download'
+ 2021-01-08 6250833911 runtime/metrics: mark histogram metrics as cumulative
+ 2021-01-08 8f6a9acbb3 runtime/metrics: remove unused StopTheWorld Description field
+ 2021-01-08 6598c65646 cmd/compile: fix exponential-time init-cycle reporting
+ 2021-01-08 fefad1dc85 test: fix timeout code for invoking compiler
+ 2021-01-08 6728118e0a cmd/go: pass signals forward during "go tool"
+ 2021-01-08 e65c543f3c go/build/constraint: add parser for build tag constraint expressions
+ 2021-01-08 0c5afc4fb7 testing/fstest,os: clarify racy behavior of TestFS
+ 2021-01-08 32afcc9436 runtime/metrics: change unit on *-by-size metrics to match bucket unit
+ 2021-01-08 c6513bca5a io/fs: minor corrections to Glob doc
+ 2021-01-08 304f769ffc cmd/compile: don't short-circuit copies whose source is volatile
+ 2021-01-08 ae97717133 runtime,runtime/metrics: use explicit histogram boundaries
+ 2021-01-08 a9ccd2d795 go/build: skip string literal while findEmbed
+ 2021-01-08 d92f8add32 archive/tar: fix typo in comment
+ 2021-01-08 cab1202183 cmd/link: accept extra blocks in TestFallocate
+ 2021-01-08 ee4d32249b io/fs: minor corrections to Glob release date
+ 2021-01-08 54bd1ccce2 cmd: update to latest golang.org/x/tools
+ 2021-01-07 9ec21a8f34 Revert "reflect: support multiple keys in struct tags"
+ 2021-01-07 091414b5b7 io/fs: correct WalkDirFunc documentation
+ 2021-01-07 9b55088d6b doc/go1.16: add release note for disallowing non-ASCII import paths
+ 2021-01-07 fa90aaca7d cmd/compile: fix late expand_calls leaf type for OpStructSelect/OpArraySelect
+ 2021-01-07 7cee66d4cb cmd/go: add documentation for Embed fields in go list output
+ 2021-01-07 e60cffa4ca html/template: attach functions to namespace
+ 2021-01-07 6da2d3b7d7 cmd/link: fix typo in asm.go
+ 2021-01-07 df81a15819 runtime: check mips64 VDSO clock_gettime return code
+ 2021-01-06 4787e906cf crypto/x509: rollback new CertificateRequest fields
+ 2021-01-06 c9658bee93 cmd/go: make module suggestion more friendly
+ 2021-01-06 4c668b25c6 runtime/metrics: fix panic message for Float64Histogram
+ 2021-01-06 d2131704a6 net/http/httputil: fix deadlock in DumpRequestOut
+ 2021-01-05 3e1e13ce6d cmd/go: set cfg.BuildMod to "readonly" by default with no module root
+ 2021-01-05 0b0d004983 cmd/go: pass embedcfg to gccgo if supported
+ 2021-01-05 1b85e7c057 cmd/go: don't scan gccgo standard library packages for imports
+ 2021-01-05 6b37b15d95 runtime: don't take allglock in tracebackothers
+ 2021-01-04 9eef49cfa6 math/rand: fix typo in comment
+ 2021-01-04 b01fb2af9e testing/fstest: fix typo in error message
+ 2021-01-01 3dd5867605 doc: 2021 is the Year of the Gopher
+ 2020-12-31 95ce805d14 io/fs: remove darwin/arm64 special condition
+ 2020-12-30 20d0991b86 lib/time, time/tzdata: update tzdata to 2020f
+ 2020-12-30 ed301733bb misc/cgo/testcarchive: remove special flags for Darwin/ARM
+ 2020-12-30 0ae2e032f2 misc/cgo/test: enable TestCrossPackageTests on darwin/arm64
+ 2020-12-29 780b4de16b misc/ios: fix wording for command line instructions
+ 2020-12-29 b4a71c95d2 doc/go1.16: reference misc/ios/README for how to build iOS programs
+ 2020-12-29 f83e0f6616 misc/ios: add to README how to build ios executables
+ 2020-12-28 4fd9455882 io/fs: fix typo in comment
Change-Id: If24bb93f1e1e7deb1d92ba223c85940ab93b2732
Diffstat (limited to 'src/cmd/compile/internal/reflectdata/reflect.go')
-rw-r--r-- | src/cmd/compile/internal/reflectdata/reflect.go | 147 |
1 files changed, 61 insertions, 86 deletions
diff --git a/src/cmd/compile/internal/reflectdata/reflect.go b/src/cmd/compile/internal/reflectdata/reflect.go index 30857fff6d..3ff14c87f4 100644 --- a/src/cmd/compile/internal/reflectdata/reflect.go +++ b/src/cmd/compile/internal/reflectdata/reflect.go @@ -32,7 +32,7 @@ type itabEntry struct { // symbols of each method in // the itab, sorted by byte offset; - // filled in by peekitabs + // filled in by CompileITabs entries []*obj.LSym } @@ -401,7 +401,7 @@ func dimportpath(p *types.Pkg) { } // If we are compiling the runtime package, there are two runtime packages around - // -- localpkg and Runtimepkg. We don't want to produce import path symbols for + // -- localpkg and Pkgs.Runtime. We don't want to produce import path symbols for // both of them, so just produce one for localpkg. if base.Ctxt.Pkgpath == "runtime" && p == ir.Pkgs.Runtime { return @@ -562,7 +562,7 @@ func dextratype(lsym *obj.LSym, ot int, t *types.Type, dataAdd int) int { } for _, a := range m { - WriteType(a.type_) + writeType(a.type_) } ot = dgopkgpathOff(lsym, ot, typePkg(t)) @@ -613,7 +613,7 @@ func dextratypeData(lsym *obj.LSym, ot int, t *types.Type) int { nsym := dname(a.name.Name, "", pkg, exported) ot = objw.SymPtrOff(lsym, ot, nsym) - ot = dmethodptrOff(lsym, ot, WriteType(a.mtype)) + ot = dmethodptrOff(lsym, ot, writeType(a.mtype)) ot = dmethodptrOff(lsym, ot, a.isym) ot = dmethodptrOff(lsym, ot, a.tsym) } @@ -690,7 +690,7 @@ func dcommontype(lsym *obj.LSym, t *types.Type) int { if t.Sym() != nil || methods(tptr) != nil { sptrWeak = false } - sptr = WriteType(tptr) + sptr = writeType(tptr) } gcsym, useGCProg, ptrdata := dgcsym(t) @@ -791,7 +791,7 @@ func dcommontype(lsym *obj.LSym, t *types.Type) int { // TrackSym returns the symbol for tracking use of field/method f, assumed // to be a member of struct/interface type t. func TrackSym(t *types.Type, f *types.Field) *obj.LSym { - return ir.Pkgs.Track.Lookup(t.ShortString() + "." + f.Sym.Name).Linksym() + return base.PkgLinksym("go.track", t.ShortString()+"."+f.Sym.Name, obj.ABI0) } func TypeSymPrefix(prefix string, t *types.Type) *types.Sym { @@ -811,7 +811,7 @@ func TypeSymPrefix(prefix string, t *types.Type) *types.Sym { func TypeSym(t *types.Type) *types.Sym { if t == nil || (t.IsPtr() && t.Elem() == nil) || t.IsUntyped() { - base.Fatalf("typenamesym %v", t) + base.Fatalf("TypeSym %v", t) } if t.Kind() == types.TFUNC && t.Recv() != nil { base.Fatalf("misuse of method type: %v", t) @@ -836,39 +836,22 @@ func TypeLinksym(t *types.Type) *obj.LSym { } func TypePtr(t *types.Type) *ir.AddrExpr { - s := TypeSym(t) - if s.Def == nil { - n := ir.NewNameAt(src.NoXPos, s) - n.SetType(types.Types[types.TUINT8]) - n.Class = ir.PEXTERN - n.SetTypecheck(1) - s.Def = n - } - - n := typecheck.NodAddr(ir.AsNode(s.Def)) - n.SetType(types.NewPtr(s.Def.Type())) - n.SetTypecheck(1) - return n + n := ir.NewLinksymExpr(base.Pos, TypeLinksym(t), types.Types[types.TUINT8]) + return typecheck.Expr(typecheck.NodAddr(n)).(*ir.AddrExpr) } func ITabAddr(t, itype *types.Type) *ir.AddrExpr { if t == nil || (t.IsPtr() && t.Elem() == nil) || t.IsUntyped() || !itype.IsInterface() || itype.IsEmptyInterface() { - base.Fatalf("itabname(%v, %v)", t, itype) - } - s := ir.Pkgs.Itab.Lookup(t.ShortString() + "," + itype.ShortString()) - if s.Def == nil { - n := typecheck.NewName(s) - n.SetType(types.Types[types.TUINT8]) - n.Class = ir.PEXTERN - n.SetTypecheck(1) - s.Def = n - itabs = append(itabs, itabEntry{t: t, itype: itype, lsym: n.Linksym()}) - } - - n := typecheck.NodAddr(ir.AsNode(s.Def)) - n.SetType(types.NewPtr(s.Def.Type())) - n.SetTypecheck(1) - return n + base.Fatalf("ITabAddr(%v, %v)", t, itype) + } + s, existed := ir.Pkgs.Itab.LookupOK(t.ShortString() + "," + itype.ShortString()) + if !existed { + itabs = append(itabs, itabEntry{t: t, itype: itype, lsym: s.Linksym()}) + } + + lsym := s.Linksym() + n := ir.NewLinksymExpr(base.Pos, lsym, types.Types[types.TUINT8]) + return typecheck.Expr(typecheck.NodAddr(n)).(*ir.AddrExpr) } // needkeyupdate reports whether map updates with t as a key @@ -933,10 +916,10 @@ func formalType(t *types.Type) *types.Type { return t } -func WriteType(t *types.Type) *obj.LSym { +func writeType(t *types.Type) *obj.LSym { t = formalType(t) if t.IsUntyped() { - base.Fatalf("dtypesym %v", t) + base.Fatalf("writeType %v", t) } s := types.TypeSym(t) @@ -983,9 +966,9 @@ func WriteType(t *types.Type) *obj.LSym { case types.TARRAY: // ../../../../runtime/type.go:/arrayType - s1 := WriteType(t.Elem()) + s1 := writeType(t.Elem()) t2 := types.NewSlice(t.Elem()) - s2 := WriteType(t2) + s2 := writeType(t2) ot = dcommontype(lsym, t) ot = objw.SymPtr(lsym, ot, s1, 0) ot = objw.SymPtr(lsym, ot, s2, 0) @@ -994,14 +977,14 @@ func WriteType(t *types.Type) *obj.LSym { case types.TSLICE: // ../../../../runtime/type.go:/sliceType - s1 := WriteType(t.Elem()) + s1 := writeType(t.Elem()) ot = dcommontype(lsym, t) ot = objw.SymPtr(lsym, ot, s1, 0) ot = dextratype(lsym, ot, t, 0) case types.TCHAN: // ../../../../runtime/type.go:/chanType - s1 := WriteType(t.Elem()) + s1 := writeType(t.Elem()) ot = dcommontype(lsym, t) ot = objw.SymPtr(lsym, ot, s1, 0) ot = objw.Uintptr(lsym, ot, uint64(t.ChanDir())) @@ -1009,15 +992,15 @@ func WriteType(t *types.Type) *obj.LSym { case types.TFUNC: for _, t1 := range t.Recvs().Fields().Slice() { - WriteType(t1.Type) + writeType(t1.Type) } isddd := false for _, t1 := range t.Params().Fields().Slice() { isddd = t1.IsDDD() - WriteType(t1.Type) + writeType(t1.Type) } for _, t1 := range t.Results().Fields().Slice() { - WriteType(t1.Type) + writeType(t1.Type) } ot = dcommontype(lsym, t) @@ -1037,20 +1020,20 @@ func WriteType(t *types.Type) *obj.LSym { // Array of rtype pointers follows funcType. for _, t1 := range t.Recvs().Fields().Slice() { - ot = objw.SymPtr(lsym, ot, WriteType(t1.Type), 0) + ot = objw.SymPtr(lsym, ot, writeType(t1.Type), 0) } for _, t1 := range t.Params().Fields().Slice() { - ot = objw.SymPtr(lsym, ot, WriteType(t1.Type), 0) + ot = objw.SymPtr(lsym, ot, writeType(t1.Type), 0) } for _, t1 := range t.Results().Fields().Slice() { - ot = objw.SymPtr(lsym, ot, WriteType(t1.Type), 0) + ot = objw.SymPtr(lsym, ot, writeType(t1.Type), 0) } case types.TINTER: m := imethods(t) n := len(m) for _, a := range m { - WriteType(a.type_) + writeType(a.type_) } // ../../../../runtime/type.go:/interfaceType @@ -1078,14 +1061,14 @@ func WriteType(t *types.Type) *obj.LSym { nsym := dname(a.name.Name, "", pkg, exported) ot = objw.SymPtrOff(lsym, ot, nsym) - ot = objw.SymPtrOff(lsym, ot, WriteType(a.type_)) + ot = objw.SymPtrOff(lsym, ot, writeType(a.type_)) } // ../../../../runtime/type.go:/mapType case types.TMAP: - s1 := WriteType(t.Key()) - s2 := WriteType(t.Elem()) - s3 := WriteType(MapBucketType(t)) + s1 := writeType(t.Key()) + s2 := writeType(t.Elem()) + s3 := writeType(MapBucketType(t)) hasher := genhash(t.Key()) ot = dcommontype(lsym, t) @@ -1132,7 +1115,7 @@ func WriteType(t *types.Type) *obj.LSym { } // ../../../../runtime/type.go:/ptrType - s1 := WriteType(t.Elem()) + s1 := writeType(t.Elem()) ot = dcommontype(lsym, t) ot = objw.SymPtr(lsym, ot, s1, 0) @@ -1143,7 +1126,7 @@ func WriteType(t *types.Type) *obj.LSym { case types.TSTRUCT: fields := t.Fields().Slice() for _, t1 := range fields { - WriteType(t1.Type) + writeType(t1.Type) } // All non-exported struct field names within a struct @@ -1171,7 +1154,7 @@ func WriteType(t *types.Type) *obj.LSym { for _, f := range fields { // ../../../../runtime/type.go:/structField ot = dnameField(lsym, ot, spkg, f) - ot = objw.SymPtr(lsym, ot, WriteType(f.Type), 0) + ot = objw.SymPtr(lsym, ot, writeType(f.Type), 0) offsetAnon := uint64(f.Offset) << 1 if offsetAnon>>1 != uint64(f.Offset) { base.Fatalf("%v: bad field offset for %s", t, f.Sym.Name) @@ -1275,7 +1258,7 @@ func genfun(t, it *types.Type) []*obj.LSym { } // ITabSym uses the information gathered in -// peekitabs to de-virtualize interface methods. +// CompileITabs to de-virtualize interface methods. // Since this is called by the SSA backend, it shouldn't // generate additional Nodes, Syms, etc. func ITabSym(it *obj.LSym, offset int64) *obj.LSym { @@ -1312,7 +1295,7 @@ func NeedRuntimeType(t *types.Type) { } func WriteRuntimeTypes() { - // Process signatset. Use a loop, as dtypesym adds + // Process signatset. Use a loop, as writeType adds // entries to signatset while it is being processed. signats := make([]typeAndStr, len(signatslice)) for len(signatslice) > 0 { @@ -1326,9 +1309,9 @@ func WriteRuntimeTypes() { sort.Sort(typesByString(signats)) for _, ts := range signats { t := ts.t - WriteType(t) + writeType(t) if t.Sym() != nil { - WriteType(types.NewPtr(t)) + writeType(types.NewPtr(t)) } } } @@ -1345,8 +1328,8 @@ func WriteTabs() { // _ [4]byte // fun [1]uintptr // variable sized // } - o := objw.SymPtr(i.lsym, 0, WriteType(i.itype), 0) - o = objw.SymPtr(i.lsym, o, WriteType(i.t), 0) + o := objw.SymPtr(i.lsym, 0, writeType(i.itype), 0) + o = objw.SymPtr(i.lsym, o, writeType(i.t), 0) o = objw.Uint32(i.lsym, o, types.TypeHash(i.t)) // copy of type hash o += 4 // skip unused field for _, fn := range genfun(i.t, i.itype) { @@ -1373,7 +1356,7 @@ func WriteTabs() { if p.Class != ir.PFUNC { t = types.NewPtr(t) } - tsym := WriteType(t) + tsym := writeType(t) ot = objw.SymPtrOff(s, ot, nsym) ot = objw.SymPtrOff(s, ot, tsym) // Plugin exports symbols as interfaces. Mark their types @@ -1407,16 +1390,16 @@ func WriteBasicTypes() { // but using runtime means fewer copies in object files. if base.Ctxt.Pkgpath == "runtime" { for i := types.Kind(1); i <= types.TBOOL; i++ { - WriteType(types.NewPtr(types.Types[i])) + writeType(types.NewPtr(types.Types[i])) } - WriteType(types.NewPtr(types.Types[types.TSTRING])) - WriteType(types.NewPtr(types.Types[types.TUNSAFEPTR])) + writeType(types.NewPtr(types.Types[types.TSTRING])) + writeType(types.NewPtr(types.Types[types.TUNSAFEPTR])) // emit type structs for error and func(error) string. // The latter is the type of an auto-generated wrapper. - WriteType(types.NewPtr(types.ErrorType)) + writeType(types.NewPtr(types.ErrorType)) - WriteType(types.NewSignature(types.NoPkg, nil, []*types.Field{ + writeType(types.NewSignature(types.NoPkg, nil, []*types.Field{ types.NewField(base.Pos, nil, types.ErrorType), }, []*types.Field{ types.NewField(base.Pos, nil, types.Types[types.TSTRING]), @@ -1426,11 +1409,12 @@ func WriteBasicTypes() { dimportpath(ir.Pkgs.Runtime) if base.Flag.Race { - dimportpath(ir.Pkgs.Race) + dimportpath(types.NewPkg("runtime/race", "")) } if base.Flag.MSan { - dimportpath(ir.Pkgs.Msan) + dimportpath(types.NewPkg("runtime/msan", "")) } + dimportpath(types.NewPkg("main", "")) } } @@ -1617,13 +1601,13 @@ func (p *gcProg) emit(t *types.Type, offset int64) { } switch t.Kind() { default: - base.Fatalf("GCProg.emit: unexpected type %v", t) + base.Fatalf("gcProg.emit: unexpected type %v", t) case types.TSTRING: p.w.Ptr(offset / int64(types.PtrSize)) case types.TINTER: - // Note: the first word isn't a pointer. See comment in plive.go:onebitwalktype1. + // Note: the first word isn't a pointer. See comment in typebits.Set p.w.Ptr(offset/int64(types.PtrSize) + 1) case types.TSLICE: @@ -1632,7 +1616,7 @@ func (p *gcProg) emit(t *types.Type, offset int64) { case types.TARRAY: if t.NumElem() == 0 { // should have been handled by haspointers check above - base.Fatalf("GCProg.emit: empty array") + base.Fatalf("gcProg.emit: empty array") } // Flatten array-of-array-of-array to just a big array by multiplying counts. @@ -1670,18 +1654,9 @@ func ZeroAddr(size int64) ir.Node { if ZeroSize < size { ZeroSize = size } - s := ir.Pkgs.Map.Lookup("zero") - if s.Def == nil { - x := typecheck.NewName(s) - x.SetType(types.Types[types.TUINT8]) - x.Class = ir.PEXTERN - x.SetTypecheck(1) - s.Def = x - } - z := typecheck.NodAddr(ir.AsNode(s.Def)) - z.SetType(types.NewPtr(types.Types[types.TUINT8])) - z.SetTypecheck(1) - return z + lsym := base.PkgLinksym("go.map", "zero", obj.ABI0) + x := ir.NewLinksymExpr(base.Pos, lsym, types.Types[types.TUINT8]) + return typecheck.Expr(typecheck.NodAddr(x)) } func CollectPTabs() { @@ -1794,7 +1769,7 @@ func methodWrapper(rcvr *types.Type, method *types.Field) *obj.LSym { } as := ir.NewAssignStmt(base.Pos, nthis, typecheck.ConvNop(left, rcvr)) fn.Body.Append(as) - fn.Body.Append(ir.NewBranchStmt(base.Pos, ir.ORETJMP, ir.MethodSym(methodrcvr, method.Sym))) + fn.Body.Append(ir.NewTailCallStmt(base.Pos, method.Nname.(*ir.Name))) } else { fn.SetWrapper(true) // ignore frame for panic+recover matching call := ir.NewCallExpr(base.Pos, ir.OCALL, dot, nil) |