2015-02-13 14:40:36 -05:00
|
|
|
// Derived from Inferno utils/6c/txt.c
|
2016-08-28 17:04:46 -07:00
|
|
|
// https://bitbucket.org/inferno-os/inferno-os/src/default/utils/6c/txt.c
|
2015-02-13 14:40:36 -05:00
|
|
|
//
|
|
|
|
|
// Copyright © 1994-1999 Lucent Technologies Inc. All rights reserved.
|
|
|
|
|
// Portions Copyright © 1995-1997 C H Forsyth (forsyth@terzarima.net)
|
|
|
|
|
// Portions Copyright © 1997-1999 Vita Nuova Limited
|
|
|
|
|
// Portions Copyright © 2000-2007 Vita Nuova Holdings Limited (www.vitanuova.com)
|
|
|
|
|
// Portions Copyright © 2004,2006 Bruce Ellis
|
|
|
|
|
// Portions Copyright © 2005-2007 C H Forsyth (forsyth@terzarima.net)
|
|
|
|
|
// Revisions Copyright © 2000-2007 Lucent Technologies Inc. and others
|
2016-04-10 14:32:26 -07:00
|
|
|
// Portions Copyright © 2009 The Go Authors. All rights reserved.
|
2015-02-13 14:40:36 -05:00
|
|
|
//
|
|
|
|
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
|
// of this software and associated documentation files (the "Software"), to deal
|
|
|
|
|
// in the Software without restriction, including without limitation the rights
|
|
|
|
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
|
// copies of the Software, and to permit persons to whom the Software is
|
|
|
|
|
// furnished to do so, subject to the following conditions:
|
|
|
|
|
//
|
|
|
|
|
// The above copyright notice and this permission notice shall be included in
|
|
|
|
|
// all copies or substantial portions of the Software.
|
|
|
|
|
//
|
|
|
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
|
// THE SOFTWARE.
|
|
|
|
|
|
|
|
|
|
package gc
|
|
|
|
|
|
2017-03-22 16:43:42 -07:00
|
|
|
import (
|
cmd/compile: factor out Pkg, Sym, and Type into package types
- created new package cmd/compile/internal/types
- moved Pkg, Sym, Type to new package
- to break cycles, for now we need the (ugly) types/utils.go
file which contains a handful of functions that must be installed
early by the gc frontend
- to break cycles, for now we need two functions to convert between
*gc.Node and *types.Node (the latter is a dummy type)
- adjusted the gc's code to use the new package and the conversion
functions as needed
- made several Pkg, Sym, and Type methods functions as needed
- renamed constructors typ, typPtr, typArray, etc. to types.New,
types.NewPtr, types.NewArray, etc.
Passes toolstash-check -all.
Change-Id: I8adfa5e85c731645d0a7fd2030375ed6ebf54b72
Reviewed-on: https://go-review.googlesource.com/39855
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2017-04-04 17:54:02 -07:00
|
|
|
"cmd/compile/internal/types"
|
2017-03-22 16:43:42 -07:00
|
|
|
"cmd/internal/obj"
|
2017-04-18 12:53:25 -07:00
|
|
|
"cmd/internal/objabi"
|
2017-03-22 16:43:42 -07:00
|
|
|
"cmd/internal/src"
|
|
|
|
|
)
|
2015-02-13 14:40:36 -05:00
|
|
|
|
2017-04-21 06:49:29 -07:00
|
|
|
var sharedProgArray *[10000]obj.Prog = new([10000]obj.Prog) // *T instead of T to work around issue 19839
|
2017-04-05 07:05:35 -07:00
|
|
|
|
2017-03-22 16:43:42 -07:00
|
|
|
// Progs accumulates Progs for a function and converts them into machine code.
|
|
|
|
|
type Progs struct {
|
2017-04-05 07:05:35 -07:00
|
|
|
Text *obj.Prog // ATEXT Prog for this function
|
|
|
|
|
next *obj.Prog // next Prog
|
|
|
|
|
pc int64 // virtual PC; count of Progs
|
|
|
|
|
pos src.XPos // position to use for new Progs
|
|
|
|
|
curfn *Node // fn these Progs are for
|
|
|
|
|
progcache []obj.Prog // local progcache
|
|
|
|
|
cacheidx int // first free element of progcache
|
2017-03-22 16:43:42 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// newProgs returns a new Progs for fn.
|
|
|
|
|
func newProgs(fn *Node) *Progs {
|
|
|
|
|
pp := new(Progs)
|
2017-04-05 07:05:35 -07:00
|
|
|
if Ctxt.CanReuseProgs() {
|
|
|
|
|
pp.progcache = sharedProgArray[:]
|
|
|
|
|
}
|
2017-03-23 16:39:04 -07:00
|
|
|
pp.curfn = fn
|
2017-03-22 16:43:42 -07:00
|
|
|
|
|
|
|
|
// prime the pump
|
2017-04-05 07:05:35 -07:00
|
|
|
pp.next = pp.NewProg()
|
2017-03-22 16:43:42 -07:00
|
|
|
pp.clearp(pp.next)
|
2015-02-13 14:40:36 -05:00
|
|
|
|
2017-03-22 16:43:42 -07:00
|
|
|
pp.pos = fn.Pos
|
|
|
|
|
pp.settext(fn)
|
|
|
|
|
return pp
|
|
|
|
|
}
|
|
|
|
|
|
2017-04-05 07:05:35 -07:00
|
|
|
func (pp *Progs) NewProg() *obj.Prog {
|
|
|
|
|
if pp.cacheidx < len(pp.progcache) {
|
|
|
|
|
p := &pp.progcache[pp.cacheidx]
|
|
|
|
|
p.Ctxt = Ctxt
|
|
|
|
|
pp.cacheidx++
|
|
|
|
|
return p
|
|
|
|
|
}
|
|
|
|
|
p := new(obj.Prog)
|
|
|
|
|
p.Ctxt = Ctxt
|
|
|
|
|
return p
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-22 16:43:42 -07:00
|
|
|
// Flush converts from pp to machine code.
|
|
|
|
|
func (pp *Progs) Flush() {
|
2017-03-23 16:39:04 -07:00
|
|
|
plist := &obj.Plist{Firstpc: pp.Text, Curfn: pp.curfn}
|
2017-04-05 07:05:35 -07:00
|
|
|
obj.Flushplist(Ctxt, plist, pp.NewProg)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Free clears pp and any associated resources.
|
|
|
|
|
func (pp *Progs) Free() {
|
|
|
|
|
if Ctxt.CanReuseProgs() {
|
|
|
|
|
// Clear progs to enable GC and avoid abuse.
|
|
|
|
|
s := pp.progcache[:pp.cacheidx]
|
|
|
|
|
for i := range s {
|
|
|
|
|
s[i] = obj.Prog{}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// Clear pp to avoid abuse.
|
2017-03-22 16:43:42 -07:00
|
|
|
*pp = Progs{}
|
|
|
|
|
}
|
2015-02-13 14:40:36 -05:00
|
|
|
|
2017-03-22 16:43:42 -07:00
|
|
|
// Prog adds a Prog with instruction As to pp.
|
|
|
|
|
func (pp *Progs) Prog(as obj.As) *obj.Prog {
|
|
|
|
|
p := pp.next
|
2017-04-05 07:05:35 -07:00
|
|
|
pp.next = pp.NewProg()
|
2017-03-22 16:43:42 -07:00
|
|
|
pp.clearp(pp.next)
|
|
|
|
|
p.Link = pp.next
|
|
|
|
|
|
|
|
|
|
if !pp.pos.IsKnown() && Debug['K'] != 0 {
|
2016-12-07 16:02:42 -08:00
|
|
|
Warn("prog: unknown position (line 0)")
|
2015-02-13 14:40:36 -05:00
|
|
|
}
|
|
|
|
|
|
2016-03-07 18:00:08 -08:00
|
|
|
p.As = as
|
2017-03-22 16:43:42 -07:00
|
|
|
p.Pos = pp.pos
|
2015-02-13 14:40:36 -05:00
|
|
|
return p
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-22 16:43:42 -07:00
|
|
|
func (pp *Progs) clearp(p *obj.Prog) {
|
2015-02-13 14:40:36 -05:00
|
|
|
obj.Nopout(p)
|
|
|
|
|
p.As = obj.AEND
|
2017-03-22 16:43:42 -07:00
|
|
|
p.Pc = pp.pc
|
|
|
|
|
pp.pc++
|
2015-02-13 14:40:36 -05:00
|
|
|
}
|
|
|
|
|
|
2017-03-22 16:43:42 -07:00
|
|
|
func (pp *Progs) Appendpp(p *obj.Prog, as obj.As, ftype obj.AddrType, freg int16, foffset int64, ttype obj.AddrType, treg int16, toffset int64) *obj.Prog {
|
2017-04-05 07:05:35 -07:00
|
|
|
q := pp.NewProg()
|
2017-03-22 16:43:42 -07:00
|
|
|
pp.clearp(q)
|
2016-09-15 00:34:35 -07:00
|
|
|
q.As = as
|
2016-12-09 14:30:40 -05:00
|
|
|
q.Pos = p.Pos
|
2016-09-15 00:34:35 -07:00
|
|
|
q.From.Type = ftype
|
|
|
|
|
q.From.Reg = freg
|
|
|
|
|
q.From.Offset = foffset
|
|
|
|
|
q.To.Type = ttype
|
|
|
|
|
q.To.Reg = treg
|
|
|
|
|
q.To.Offset = toffset
|
|
|
|
|
q.Link = p.Link
|
|
|
|
|
p.Link = q
|
|
|
|
|
return q
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-22 16:43:42 -07:00
|
|
|
func (pp *Progs) settext(fn *Node) {
|
|
|
|
|
if pp.Text != nil {
|
|
|
|
|
Fatalf("Progs.settext called twice")
|
|
|
|
|
}
|
|
|
|
|
ptxt := pp.Prog(obj.ATEXT)
|
2017-04-12 13:23:07 -07:00
|
|
|
pp.Text = ptxt
|
2017-04-14 06:35:53 -07:00
|
|
|
|
|
|
|
|
if fn.Func.lsym == nil {
|
|
|
|
|
// func _() { }
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
2017-04-18 10:18:34 -07:00
|
|
|
fn.Func.lsym.Func.Text = ptxt
|
2017-04-14 06:35:53 -07:00
|
|
|
ptxt.From.Type = obj.TYPE_MEM
|
|
|
|
|
ptxt.From.Name = obj.NAME_EXTERN
|
|
|
|
|
ptxt.From.Sym = fn.Func.lsym
|
|
|
|
|
|
|
|
|
|
p := pp.Prog(obj.AFUNCDATA)
|
2017-04-18 12:53:25 -07:00
|
|
|
Addrconst(&p.From, objabi.FUNCDATA_ArgsPointerMaps)
|
2017-04-14 06:35:53 -07:00
|
|
|
p.To.Type = obj.TYPE_MEM
|
|
|
|
|
p.To.Name = obj.NAME_EXTERN
|
2017-04-18 10:18:34 -07:00
|
|
|
p.To.Sym = &fn.Func.lsym.Func.GCArgs
|
2017-04-14 06:35:53 -07:00
|
|
|
|
|
|
|
|
p = pp.Prog(obj.AFUNCDATA)
|
2017-04-18 12:53:25 -07:00
|
|
|
Addrconst(&p.From, objabi.FUNCDATA_LocalsPointerMaps)
|
2017-04-14 06:35:53 -07:00
|
|
|
p.To.Type = obj.TYPE_MEM
|
|
|
|
|
p.To.Name = obj.NAME_EXTERN
|
2017-04-18 10:18:34 -07:00
|
|
|
p.To.Sym = &fn.Func.lsym.Func.GCLocals
|
2017-04-12 13:23:07 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (f *Func) initLSym() {
|
|
|
|
|
if f.lsym != nil {
|
|
|
|
|
Fatalf("Func.initLSym called twice")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if nam := f.Nname; !isblank(nam) {
|
2017-04-21 07:51:41 -07:00
|
|
|
f.lsym = nam.Sym.Linksym()
|
2017-04-12 13:23:07 -07:00
|
|
|
if f.Pragma&Systemstack != 0 {
|
|
|
|
|
f.lsym.Set(obj.AttrCFunc, true)
|
2017-03-22 16:43:42 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
cmd/internal/obj: stop storing Text flags in From3
Prior to this CL, flags such as NOSPLIT
on ATEXT Progs were stored in From3.Offset.
Some but not all of those flags were also
duplicated into From.Sym.Attribute.
This CL migrates all of those flags into
From.Sym.Attribute and stops creating a From3.
A side-effect of this is that printing an
ATEXT Prog can no longer simply dump From3.Offset.
That's kind of good, since the raw flag value
wasn't very informative anyway, but it did
necessitate a bunch of updates to the cmd/asm tests.
The reason I'm doing this work now is that
avoiding storing flags in both From.Sym and From3.Offset
simplifies some other changes to fix the data
race first described in CL 40254.
This CL almost passes toolstash-check -all.
The only changes are in cases where the assembler
has decided that a function's flags may be altered,
e.g. to make a function with no calls in it NOSPLIT.
Prior to this CL, that information was not printed.
Sample before:
"".Ctz64 t=1 size=63 args=0x10 locals=0x0
0x0000 00000 (/Users/josh/go/tip/src/runtime/internal/sys/intrinsics.go:35) TEXT "".Ctz64(SB), $0-16
0x0000 00000 (/Users/josh/go/tip/src/runtime/internal/sys/intrinsics.go:35) FUNCDATA $0, gclocals·f207267fbf96a0178e8758c6e3e0ce28(SB)
Sample after:
"".Ctz64 t=1 nosplit size=63 args=0x10 locals=0x0
0x0000 00000 (/Users/josh/go/tip/src/runtime/internal/sys/intrinsics.go:35) TEXT "".Ctz64(SB), NOSPLIT, $0-16
0x0000 00000 (/Users/josh/go/tip/src/runtime/internal/sys/intrinsics.go:35) FUNCDATA $0, gclocals·f207267fbf96a0178e8758c6e3e0ce28(SB)
Observe the additional "nosplit" in the first line
and the additional "NOSPLIT" in the second line.
Updates #15756
Change-Id: I5c59bd8f3bdc7c780361f801d94a261f0aef3d13
Reviewed-on: https://go-review.googlesource.com/40495
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-04-11 15:15:04 -07:00
|
|
|
var flag int
|
2017-04-12 13:23:07 -07:00
|
|
|
if f.Dupok() {
|
cmd/internal/obj: stop storing Text flags in From3
Prior to this CL, flags such as NOSPLIT
on ATEXT Progs were stored in From3.Offset.
Some but not all of those flags were also
duplicated into From.Sym.Attribute.
This CL migrates all of those flags into
From.Sym.Attribute and stops creating a From3.
A side-effect of this is that printing an
ATEXT Prog can no longer simply dump From3.Offset.
That's kind of good, since the raw flag value
wasn't very informative anyway, but it did
necessitate a bunch of updates to the cmd/asm tests.
The reason I'm doing this work now is that
avoiding storing flags in both From.Sym and From3.Offset
simplifies some other changes to fix the data
race first described in CL 40254.
This CL almost passes toolstash-check -all.
The only changes are in cases where the assembler
has decided that a function's flags may be altered,
e.g. to make a function with no calls in it NOSPLIT.
Prior to this CL, that information was not printed.
Sample before:
"".Ctz64 t=1 size=63 args=0x10 locals=0x0
0x0000 00000 (/Users/josh/go/tip/src/runtime/internal/sys/intrinsics.go:35) TEXT "".Ctz64(SB), $0-16
0x0000 00000 (/Users/josh/go/tip/src/runtime/internal/sys/intrinsics.go:35) FUNCDATA $0, gclocals·f207267fbf96a0178e8758c6e3e0ce28(SB)
Sample after:
"".Ctz64 t=1 nosplit size=63 args=0x10 locals=0x0
0x0000 00000 (/Users/josh/go/tip/src/runtime/internal/sys/intrinsics.go:35) TEXT "".Ctz64(SB), NOSPLIT, $0-16
0x0000 00000 (/Users/josh/go/tip/src/runtime/internal/sys/intrinsics.go:35) FUNCDATA $0, gclocals·f207267fbf96a0178e8758c6e3e0ce28(SB)
Observe the additional "nosplit" in the first line
and the additional "NOSPLIT" in the second line.
Updates #15756
Change-Id: I5c59bd8f3bdc7c780361f801d94a261f0aef3d13
Reviewed-on: https://go-review.googlesource.com/40495
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-04-11 15:15:04 -07:00
|
|
|
flag |= obj.DUPOK
|
2017-03-22 16:43:42 -07:00
|
|
|
}
|
2017-04-12 13:23:07 -07:00
|
|
|
if f.Wrapper() {
|
cmd/internal/obj: stop storing Text flags in From3
Prior to this CL, flags such as NOSPLIT
on ATEXT Progs were stored in From3.Offset.
Some but not all of those flags were also
duplicated into From.Sym.Attribute.
This CL migrates all of those flags into
From.Sym.Attribute and stops creating a From3.
A side-effect of this is that printing an
ATEXT Prog can no longer simply dump From3.Offset.
That's kind of good, since the raw flag value
wasn't very informative anyway, but it did
necessitate a bunch of updates to the cmd/asm tests.
The reason I'm doing this work now is that
avoiding storing flags in both From.Sym and From3.Offset
simplifies some other changes to fix the data
race first described in CL 40254.
This CL almost passes toolstash-check -all.
The only changes are in cases where the assembler
has decided that a function's flags may be altered,
e.g. to make a function with no calls in it NOSPLIT.
Prior to this CL, that information was not printed.
Sample before:
"".Ctz64 t=1 size=63 args=0x10 locals=0x0
0x0000 00000 (/Users/josh/go/tip/src/runtime/internal/sys/intrinsics.go:35) TEXT "".Ctz64(SB), $0-16
0x0000 00000 (/Users/josh/go/tip/src/runtime/internal/sys/intrinsics.go:35) FUNCDATA $0, gclocals·f207267fbf96a0178e8758c6e3e0ce28(SB)
Sample after:
"".Ctz64 t=1 nosplit size=63 args=0x10 locals=0x0
0x0000 00000 (/Users/josh/go/tip/src/runtime/internal/sys/intrinsics.go:35) TEXT "".Ctz64(SB), NOSPLIT, $0-16
0x0000 00000 (/Users/josh/go/tip/src/runtime/internal/sys/intrinsics.go:35) FUNCDATA $0, gclocals·f207267fbf96a0178e8758c6e3e0ce28(SB)
Observe the additional "nosplit" in the first line
and the additional "NOSPLIT" in the second line.
Updates #15756
Change-Id: I5c59bd8f3bdc7c780361f801d94a261f0aef3d13
Reviewed-on: https://go-review.googlesource.com/40495
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-04-11 15:15:04 -07:00
|
|
|
flag |= obj.WRAPPER
|
2017-03-22 16:43:42 -07:00
|
|
|
}
|
2017-04-12 13:23:07 -07:00
|
|
|
if f.NoFramePointer() {
|
cmd/internal/obj: stop storing Text flags in From3
Prior to this CL, flags such as NOSPLIT
on ATEXT Progs were stored in From3.Offset.
Some but not all of those flags were also
duplicated into From.Sym.Attribute.
This CL migrates all of those flags into
From.Sym.Attribute and stops creating a From3.
A side-effect of this is that printing an
ATEXT Prog can no longer simply dump From3.Offset.
That's kind of good, since the raw flag value
wasn't very informative anyway, but it did
necessitate a bunch of updates to the cmd/asm tests.
The reason I'm doing this work now is that
avoiding storing flags in both From.Sym and From3.Offset
simplifies some other changes to fix the data
race first described in CL 40254.
This CL almost passes toolstash-check -all.
The only changes are in cases where the assembler
has decided that a function's flags may be altered,
e.g. to make a function with no calls in it NOSPLIT.
Prior to this CL, that information was not printed.
Sample before:
"".Ctz64 t=1 size=63 args=0x10 locals=0x0
0x0000 00000 (/Users/josh/go/tip/src/runtime/internal/sys/intrinsics.go:35) TEXT "".Ctz64(SB), $0-16
0x0000 00000 (/Users/josh/go/tip/src/runtime/internal/sys/intrinsics.go:35) FUNCDATA $0, gclocals·f207267fbf96a0178e8758c6e3e0ce28(SB)
Sample after:
"".Ctz64 t=1 nosplit size=63 args=0x10 locals=0x0
0x0000 00000 (/Users/josh/go/tip/src/runtime/internal/sys/intrinsics.go:35) TEXT "".Ctz64(SB), NOSPLIT, $0-16
0x0000 00000 (/Users/josh/go/tip/src/runtime/internal/sys/intrinsics.go:35) FUNCDATA $0, gclocals·f207267fbf96a0178e8758c6e3e0ce28(SB)
Observe the additional "nosplit" in the first line
and the additional "NOSPLIT" in the second line.
Updates #15756
Change-Id: I5c59bd8f3bdc7c780361f801d94a261f0aef3d13
Reviewed-on: https://go-review.googlesource.com/40495
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-04-11 15:15:04 -07:00
|
|
|
flag |= obj.NOFRAME
|
2017-03-22 16:43:42 -07:00
|
|
|
}
|
2017-04-12 13:23:07 -07:00
|
|
|
if f.Needctxt() {
|
cmd/internal/obj: stop storing Text flags in From3
Prior to this CL, flags such as NOSPLIT
on ATEXT Progs were stored in From3.Offset.
Some but not all of those flags were also
duplicated into From.Sym.Attribute.
This CL migrates all of those flags into
From.Sym.Attribute and stops creating a From3.
A side-effect of this is that printing an
ATEXT Prog can no longer simply dump From3.Offset.
That's kind of good, since the raw flag value
wasn't very informative anyway, but it did
necessitate a bunch of updates to the cmd/asm tests.
The reason I'm doing this work now is that
avoiding storing flags in both From.Sym and From3.Offset
simplifies some other changes to fix the data
race first described in CL 40254.
This CL almost passes toolstash-check -all.
The only changes are in cases where the assembler
has decided that a function's flags may be altered,
e.g. to make a function with no calls in it NOSPLIT.
Prior to this CL, that information was not printed.
Sample before:
"".Ctz64 t=1 size=63 args=0x10 locals=0x0
0x0000 00000 (/Users/josh/go/tip/src/runtime/internal/sys/intrinsics.go:35) TEXT "".Ctz64(SB), $0-16
0x0000 00000 (/Users/josh/go/tip/src/runtime/internal/sys/intrinsics.go:35) FUNCDATA $0, gclocals·f207267fbf96a0178e8758c6e3e0ce28(SB)
Sample after:
"".Ctz64 t=1 nosplit size=63 args=0x10 locals=0x0
0x0000 00000 (/Users/josh/go/tip/src/runtime/internal/sys/intrinsics.go:35) TEXT "".Ctz64(SB), NOSPLIT, $0-16
0x0000 00000 (/Users/josh/go/tip/src/runtime/internal/sys/intrinsics.go:35) FUNCDATA $0, gclocals·f207267fbf96a0178e8758c6e3e0ce28(SB)
Observe the additional "nosplit" in the first line
and the additional "NOSPLIT" in the second line.
Updates #15756
Change-Id: I5c59bd8f3bdc7c780361f801d94a261f0aef3d13
Reviewed-on: https://go-review.googlesource.com/40495
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-04-11 15:15:04 -07:00
|
|
|
flag |= obj.NEEDCTXT
|
2017-03-22 16:43:42 -07:00
|
|
|
}
|
2017-04-12 13:23:07 -07:00
|
|
|
if f.Pragma&Nosplit != 0 {
|
cmd/internal/obj: stop storing Text flags in From3
Prior to this CL, flags such as NOSPLIT
on ATEXT Progs were stored in From3.Offset.
Some but not all of those flags were also
duplicated into From.Sym.Attribute.
This CL migrates all of those flags into
From.Sym.Attribute and stops creating a From3.
A side-effect of this is that printing an
ATEXT Prog can no longer simply dump From3.Offset.
That's kind of good, since the raw flag value
wasn't very informative anyway, but it did
necessitate a bunch of updates to the cmd/asm tests.
The reason I'm doing this work now is that
avoiding storing flags in both From.Sym and From3.Offset
simplifies some other changes to fix the data
race first described in CL 40254.
This CL almost passes toolstash-check -all.
The only changes are in cases where the assembler
has decided that a function's flags may be altered,
e.g. to make a function with no calls in it NOSPLIT.
Prior to this CL, that information was not printed.
Sample before:
"".Ctz64 t=1 size=63 args=0x10 locals=0x0
0x0000 00000 (/Users/josh/go/tip/src/runtime/internal/sys/intrinsics.go:35) TEXT "".Ctz64(SB), $0-16
0x0000 00000 (/Users/josh/go/tip/src/runtime/internal/sys/intrinsics.go:35) FUNCDATA $0, gclocals·f207267fbf96a0178e8758c6e3e0ce28(SB)
Sample after:
"".Ctz64 t=1 nosplit size=63 args=0x10 locals=0x0
0x0000 00000 (/Users/josh/go/tip/src/runtime/internal/sys/intrinsics.go:35) TEXT "".Ctz64(SB), NOSPLIT, $0-16
0x0000 00000 (/Users/josh/go/tip/src/runtime/internal/sys/intrinsics.go:35) FUNCDATA $0, gclocals·f207267fbf96a0178e8758c6e3e0ce28(SB)
Observe the additional "nosplit" in the first line
and the additional "NOSPLIT" in the second line.
Updates #15756
Change-Id: I5c59bd8f3bdc7c780361f801d94a261f0aef3d13
Reviewed-on: https://go-review.googlesource.com/40495
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-04-11 15:15:04 -07:00
|
|
|
flag |= obj.NOSPLIT
|
2017-03-22 16:43:42 -07:00
|
|
|
}
|
2017-04-12 13:23:07 -07:00
|
|
|
if f.ReflectMethod() {
|
cmd/internal/obj: stop storing Text flags in From3
Prior to this CL, flags such as NOSPLIT
on ATEXT Progs were stored in From3.Offset.
Some but not all of those flags were also
duplicated into From.Sym.Attribute.
This CL migrates all of those flags into
From.Sym.Attribute and stops creating a From3.
A side-effect of this is that printing an
ATEXT Prog can no longer simply dump From3.Offset.
That's kind of good, since the raw flag value
wasn't very informative anyway, but it did
necessitate a bunch of updates to the cmd/asm tests.
The reason I'm doing this work now is that
avoiding storing flags in both From.Sym and From3.Offset
simplifies some other changes to fix the data
race first described in CL 40254.
This CL almost passes toolstash-check -all.
The only changes are in cases where the assembler
has decided that a function's flags may be altered,
e.g. to make a function with no calls in it NOSPLIT.
Prior to this CL, that information was not printed.
Sample before:
"".Ctz64 t=1 size=63 args=0x10 locals=0x0
0x0000 00000 (/Users/josh/go/tip/src/runtime/internal/sys/intrinsics.go:35) TEXT "".Ctz64(SB), $0-16
0x0000 00000 (/Users/josh/go/tip/src/runtime/internal/sys/intrinsics.go:35) FUNCDATA $0, gclocals·f207267fbf96a0178e8758c6e3e0ce28(SB)
Sample after:
"".Ctz64 t=1 nosplit size=63 args=0x10 locals=0x0
0x0000 00000 (/Users/josh/go/tip/src/runtime/internal/sys/intrinsics.go:35) TEXT "".Ctz64(SB), NOSPLIT, $0-16
0x0000 00000 (/Users/josh/go/tip/src/runtime/internal/sys/intrinsics.go:35) FUNCDATA $0, gclocals·f207267fbf96a0178e8758c6e3e0ce28(SB)
Observe the additional "nosplit" in the first line
and the additional "NOSPLIT" in the second line.
Updates #15756
Change-Id: I5c59bd8f3bdc7c780361f801d94a261f0aef3d13
Reviewed-on: https://go-review.googlesource.com/40495
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-04-11 15:15:04 -07:00
|
|
|
flag |= obj.REFLECTMETHOD
|
2017-03-22 16:43:42 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Clumsy but important.
|
|
|
|
|
// See test/recover.go for test cases and src/reflect/value.go
|
|
|
|
|
// for the actual functions being considered.
|
|
|
|
|
if myimportpath == "reflect" {
|
2017-04-12 13:23:07 -07:00
|
|
|
switch f.Nname.Sym.Name {
|
2017-03-22 16:43:42 -07:00
|
|
|
case "callReflect", "callMethod":
|
cmd/internal/obj: stop storing Text flags in From3
Prior to this CL, flags such as NOSPLIT
on ATEXT Progs were stored in From3.Offset.
Some but not all of those flags were also
duplicated into From.Sym.Attribute.
This CL migrates all of those flags into
From.Sym.Attribute and stops creating a From3.
A side-effect of this is that printing an
ATEXT Prog can no longer simply dump From3.Offset.
That's kind of good, since the raw flag value
wasn't very informative anyway, but it did
necessitate a bunch of updates to the cmd/asm tests.
The reason I'm doing this work now is that
avoiding storing flags in both From.Sym and From3.Offset
simplifies some other changes to fix the data
race first described in CL 40254.
This CL almost passes toolstash-check -all.
The only changes are in cases where the assembler
has decided that a function's flags may be altered,
e.g. to make a function with no calls in it NOSPLIT.
Prior to this CL, that information was not printed.
Sample before:
"".Ctz64 t=1 size=63 args=0x10 locals=0x0
0x0000 00000 (/Users/josh/go/tip/src/runtime/internal/sys/intrinsics.go:35) TEXT "".Ctz64(SB), $0-16
0x0000 00000 (/Users/josh/go/tip/src/runtime/internal/sys/intrinsics.go:35) FUNCDATA $0, gclocals·f207267fbf96a0178e8758c6e3e0ce28(SB)
Sample after:
"".Ctz64 t=1 nosplit size=63 args=0x10 locals=0x0
0x0000 00000 (/Users/josh/go/tip/src/runtime/internal/sys/intrinsics.go:35) TEXT "".Ctz64(SB), NOSPLIT, $0-16
0x0000 00000 (/Users/josh/go/tip/src/runtime/internal/sys/intrinsics.go:35) FUNCDATA $0, gclocals·f207267fbf96a0178e8758c6e3e0ce28(SB)
Observe the additional "nosplit" in the first line
and the additional "NOSPLIT" in the second line.
Updates #15756
Change-Id: I5c59bd8f3bdc7c780361f801d94a261f0aef3d13
Reviewed-on: https://go-review.googlesource.com/40495
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-04-11 15:15:04 -07:00
|
|
|
flag |= obj.WRAPPER
|
2017-03-22 16:43:42 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-04-12 13:23:07 -07:00
|
|
|
Ctxt.InitTextSym(f.lsym, flag)
|
2017-03-22 16:43:42 -07:00
|
|
|
}
|
|
|
|
|
|
2015-02-13 14:40:36 -05:00
|
|
|
func ggloblnod(nam *Node) {
|
2017-04-21 07:51:41 -07:00
|
|
|
s := nam.Sym.Linksym()
|
|
|
|
|
s.Gotype = ngotype(nam).Linksym()
|
2016-09-16 15:31:04 -07:00
|
|
|
flags := 0
|
2017-02-27 19:56:38 +02:00
|
|
|
if nam.Name.Readonly() {
|
2016-09-16 15:31:04 -07:00
|
|
|
flags = obj.RODATA
|
2015-02-13 14:40:36 -05:00
|
|
|
}
|
cmd/compile: factor out Pkg, Sym, and Type into package types
- created new package cmd/compile/internal/types
- moved Pkg, Sym, Type to new package
- to break cycles, for now we need the (ugly) types/utils.go
file which contains a handful of functions that must be installed
early by the gc frontend
- to break cycles, for now we need two functions to convert between
*gc.Node and *types.Node (the latter is a dummy type)
- adjusted the gc's code to use the new package and the conversion
functions as needed
- made several Pkg, Sym, and Type methods functions as needed
- renamed constructors typ, typPtr, typArray, etc. to types.New,
types.NewPtr, types.NewArray, etc.
Passes toolstash-check -all.
Change-Id: I8adfa5e85c731645d0a7fd2030375ed6ebf54b72
Reviewed-on: https://go-review.googlesource.com/39855
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2017-04-04 17:54:02 -07:00
|
|
|
if nam.Type != nil && !types.Haspointers(nam.Type) {
|
2016-09-16 15:31:04 -07:00
|
|
|
flags |= obj.NOPTR
|
2015-02-13 14:40:36 -05:00
|
|
|
}
|
2016-09-16 15:31:04 -07:00
|
|
|
Ctxt.Globl(s, nam.Type.Width, flags)
|
2015-02-13 14:40:36 -05:00
|
|
|
}
|
|
|
|
|
|
2017-04-21 14:20:54 -07:00
|
|
|
func ggloblsym(s *obj.LSym, width int32, flags int16) {
|
2015-04-18 08:14:08 +12:00
|
|
|
if flags&obj.LOCAL != 0 {
|
2016-10-24 23:15:41 +03:00
|
|
|
s.Set(obj.AttrLocal, true)
|
2016-03-29 14:09:22 +02:00
|
|
|
flags &^= obj.LOCAL
|
2015-04-18 08:14:08 +12:00
|
|
|
}
|
2016-09-16 15:31:04 -07:00
|
|
|
Ctxt.Globl(s, int64(width), int(flags))
|
2015-02-13 14:40:36 -05:00
|
|
|
}
|
|
|
|
|
|
cmd/compile: factor out Pkg, Sym, and Type into package types
- created new package cmd/compile/internal/types
- moved Pkg, Sym, Type to new package
- to break cycles, for now we need the (ugly) types/utils.go
file which contains a handful of functions that must be installed
early by the gc frontend
- to break cycles, for now we need two functions to convert between
*gc.Node and *types.Node (the latter is a dummy type)
- adjusted the gc's code to use the new package and the conversion
functions as needed
- made several Pkg, Sym, and Type methods functions as needed
- renamed constructors typ, typPtr, typArray, etc. to types.New,
types.NewPtr, types.NewArray, etc.
Passes toolstash-check -all.
Change-Id: I8adfa5e85c731645d0a7fd2030375ed6ebf54b72
Reviewed-on: https://go-review.googlesource.com/39855
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2017-04-04 17:54:02 -07:00
|
|
|
func isfat(t *types.Type) bool {
|
2015-02-13 14:40:36 -05:00
|
|
|
if t != nil {
|
|
|
|
|
switch t.Etype {
|
2016-04-18 14:02:08 -07:00
|
|
|
case TSTRUCT, TARRAY, TSLICE, TSTRING,
|
2015-02-13 14:40:36 -05:00
|
|
|
TINTER: // maybe remove later
|
2015-02-17 22:13:49 -05:00
|
|
|
return true
|
2015-02-13 14:40:36 -05:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-02-17 22:13:49 -05:00
|
|
|
return false
|
2015-02-13 14:40:36 -05:00
|
|
|
}
|
|
|
|
|
|
2016-09-29 16:22:43 -07:00
|
|
|
func Addrconst(a *obj.Addr, v int64) {
|
|
|
|
|
a.Sym = nil
|
|
|
|
|
a.Type = obj.TYPE_CONST
|
|
|
|
|
a.Offset = v
|
2015-02-13 14:40:36 -05:00
|
|
|
}
|
|
|
|
|
|
2016-05-25 10:01:58 -04:00
|
|
|
// nodarg returns a Node for the function argument denoted by t,
|
cmd/compile: factor out Pkg, Sym, and Type into package types
- created new package cmd/compile/internal/types
- moved Pkg, Sym, Type to new package
- to break cycles, for now we need the (ugly) types/utils.go
file which contains a handful of functions that must be installed
early by the gc frontend
- to break cycles, for now we need two functions to convert between
*gc.Node and *types.Node (the latter is a dummy type)
- adjusted the gc's code to use the new package and the conversion
functions as needed
- made several Pkg, Sym, and Type methods functions as needed
- renamed constructors typ, typPtr, typArray, etc. to types.New,
types.NewPtr, types.NewArray, etc.
Passes toolstash-check -all.
Change-Id: I8adfa5e85c731645d0a7fd2030375ed6ebf54b72
Reviewed-on: https://go-review.googlesource.com/39855
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2017-04-04 17:54:02 -07:00
|
|
|
// which is either the entire function argument or result struct (t is a struct *types.Type)
|
|
|
|
|
// or a specific argument (t is a *types.Field within a struct *types.Type).
|
2015-10-08 12:39:56 -04:00
|
|
|
//
|
2016-05-25 10:01:58 -04:00
|
|
|
// If fp is 0, the node is for use by a caller invoking the given
|
|
|
|
|
// function, preparing the arguments before the call
|
|
|
|
|
// or retrieving the results after the call.
|
|
|
|
|
// In this case, the node will correspond to an outgoing argument
|
|
|
|
|
// slot like 8(SP).
|
|
|
|
|
//
|
|
|
|
|
// If fp is 1, the node is for use by the function itself
|
|
|
|
|
// (the callee), to retrieve its arguments or write its results.
|
|
|
|
|
// In this case the node will be an ONAME with an appropriate
|
|
|
|
|
// type and offset.
|
2016-03-14 01:20:49 -07:00
|
|
|
func nodarg(t interface{}, fp int) *Node {
|
2015-02-13 14:40:36 -05:00
|
|
|
var n *Node
|
|
|
|
|
|
cmd/compile: factor out Pkg, Sym, and Type into package types
- created new package cmd/compile/internal/types
- moved Pkg, Sym, Type to new package
- to break cycles, for now we need the (ugly) types/utils.go
file which contains a handful of functions that must be installed
early by the gc frontend
- to break cycles, for now we need two functions to convert between
*gc.Node and *types.Node (the latter is a dummy type)
- adjusted the gc's code to use the new package and the conversion
functions as needed
- made several Pkg, Sym, and Type methods functions as needed
- renamed constructors typ, typPtr, typArray, etc. to types.New,
types.NewPtr, types.NewArray, etc.
Passes toolstash-check -all.
Change-Id: I8adfa5e85c731645d0a7fd2030375ed6ebf54b72
Reviewed-on: https://go-review.googlesource.com/39855
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2017-04-04 17:54:02 -07:00
|
|
|
var funarg types.Funarg
|
2016-03-14 01:20:49 -07:00
|
|
|
switch t := t.(type) {
|
2016-05-25 10:01:58 -04:00
|
|
|
default:
|
|
|
|
|
Fatalf("bad nodarg %T(%v)", t, t)
|
|
|
|
|
|
cmd/compile: factor out Pkg, Sym, and Type into package types
- created new package cmd/compile/internal/types
- moved Pkg, Sym, Type to new package
- to break cycles, for now we need the (ugly) types/utils.go
file which contains a handful of functions that must be installed
early by the gc frontend
- to break cycles, for now we need two functions to convert between
*gc.Node and *types.Node (the latter is a dummy type)
- adjusted the gc's code to use the new package and the conversion
functions as needed
- made several Pkg, Sym, and Type methods functions as needed
- renamed constructors typ, typPtr, typArray, etc. to types.New,
types.NewPtr, types.NewArray, etc.
Passes toolstash-check -all.
Change-Id: I8adfa5e85c731645d0a7fd2030375ed6ebf54b72
Reviewed-on: https://go-review.googlesource.com/39855
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2017-04-04 17:54:02 -07:00
|
|
|
case *types.Type:
|
2016-05-25 10:01:58 -04:00
|
|
|
// Entire argument struct, not just one arg
|
2016-04-05 16:44:07 -07:00
|
|
|
if !t.IsFuncArgStruct() {
|
2016-03-14 01:20:49 -07:00
|
|
|
Fatalf("nodarg: bad type %v", t)
|
|
|
|
|
}
|
2016-05-25 10:01:58 -04:00
|
|
|
funarg = t.StructType().Funarg
|
|
|
|
|
|
|
|
|
|
// Build fake variable name for whole arg struct.
|
2017-03-24 15:57:12 -07:00
|
|
|
n = newname(lookup(".args"))
|
2015-02-13 14:40:36 -05:00
|
|
|
n.Type = t
|
2016-03-09 20:45:18 -08:00
|
|
|
first := t.Field(0)
|
2015-02-13 14:40:36 -05:00
|
|
|
if first == nil {
|
2015-08-30 23:10:03 +02:00
|
|
|
Fatalf("nodarg: bad struct")
|
2015-02-13 14:40:36 -05:00
|
|
|
}
|
2016-03-28 09:40:53 -07:00
|
|
|
if first.Offset == BADWIDTH {
|
2015-08-30 23:10:03 +02:00
|
|
|
Fatalf("nodarg: offset not computed for %v", t)
|
2015-02-13 14:40:36 -05:00
|
|
|
}
|
2016-03-28 09:40:53 -07:00
|
|
|
n.Xoffset = first.Offset
|
2016-05-25 10:01:58 -04:00
|
|
|
|
cmd/compile: factor out Pkg, Sym, and Type into package types
- created new package cmd/compile/internal/types
- moved Pkg, Sym, Type to new package
- to break cycles, for now we need the (ugly) types/utils.go
file which contains a handful of functions that must be installed
early by the gc frontend
- to break cycles, for now we need two functions to convert between
*gc.Node and *types.Node (the latter is a dummy type)
- adjusted the gc's code to use the new package and the conversion
functions as needed
- made several Pkg, Sym, and Type methods functions as needed
- renamed constructors typ, typPtr, typArray, etc. to types.New,
types.NewPtr, types.NewArray, etc.
Passes toolstash-check -all.
Change-Id: I8adfa5e85c731645d0a7fd2030375ed6ebf54b72
Reviewed-on: https://go-review.googlesource.com/39855
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2017-04-04 17:54:02 -07:00
|
|
|
case *types.Field:
|
2016-05-25 10:01:58 -04:00
|
|
|
funarg = t.Funarg
|
|
|
|
|
if fp == 1 {
|
|
|
|
|
// NOTE(rsc): This should be using t.Nname directly,
|
|
|
|
|
// except in the case where t.Nname.Sym is the blank symbol and
|
|
|
|
|
// so the assignment would be discarded during code generation.
|
|
|
|
|
// In that case we need to make a new node, and there is no harm
|
|
|
|
|
// in optimization passes to doing so. But otherwise we should
|
|
|
|
|
// definitely be using the actual declaration and not a newly built node.
|
|
|
|
|
// The extra Fatalf checks here are verifying that this is the case,
|
|
|
|
|
// without changing the actual logic (at time of writing, it's getting
|
|
|
|
|
// toward time for the Go 1.7 beta).
|
|
|
|
|
// At some quieter time (assuming we've never seen these Fatalfs happen)
|
|
|
|
|
// we could change this code to use "expect" directly.
|
cmd/compile: factor out Pkg, Sym, and Type into package types
- created new package cmd/compile/internal/types
- moved Pkg, Sym, Type to new package
- to break cycles, for now we need the (ugly) types/utils.go
file which contains a handful of functions that must be installed
early by the gc frontend
- to break cycles, for now we need two functions to convert between
*gc.Node and *types.Node (the latter is a dummy type)
- adjusted the gc's code to use the new package and the conversion
functions as needed
- made several Pkg, Sym, and Type methods functions as needed
- renamed constructors typ, typPtr, typArray, etc. to types.New,
types.NewPtr, types.NewArray, etc.
Passes toolstash-check -all.
Change-Id: I8adfa5e85c731645d0a7fd2030375ed6ebf54b72
Reviewed-on: https://go-review.googlesource.com/39855
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2017-04-04 17:54:02 -07:00
|
|
|
expect := asNode(t.Nname)
|
2016-05-25 10:01:58 -04:00
|
|
|
if expect.isParamHeapCopy() {
|
|
|
|
|
expect = expect.Name.Param.Stackcopy
|
|
|
|
|
}
|
|
|
|
|
|
2016-03-14 01:20:49 -07:00
|
|
|
for _, n := range Curfn.Func.Dcl {
|
2017-04-25 18:14:12 -07:00
|
|
|
if (n.Class() == PPARAM || n.Class() == PPARAMOUT) && !t.Sym.IsBlank() && n.Sym == t.Sym {
|
2016-05-25 10:01:58 -04:00
|
|
|
if n != expect {
|
cmd/compile: factor out Pkg, Sym, and Type into package types
- created new package cmd/compile/internal/types
- moved Pkg, Sym, Type to new package
- to break cycles, for now we need the (ugly) types/utils.go
file which contains a handful of functions that must be installed
early by the gc frontend
- to break cycles, for now we need two functions to convert between
*gc.Node and *types.Node (the latter is a dummy type)
- adjusted the gc's code to use the new package and the conversion
functions as needed
- made several Pkg, Sym, and Type methods functions as needed
- renamed constructors typ, typPtr, typArray, etc. to types.New,
types.NewPtr, types.NewArray, etc.
Passes toolstash-check -all.
Change-Id: I8adfa5e85c731645d0a7fd2030375ed6ebf54b72
Reviewed-on: https://go-review.googlesource.com/39855
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2017-04-04 17:54:02 -07:00
|
|
|
Fatalf("nodarg: unexpected node: %v (%p %v) vs %v (%p %v)", n, n, n.Op, asNode(t.Nname), asNode(t.Nname), asNode(t.Nname).Op)
|
2016-05-25 10:01:58 -04:00
|
|
|
}
|
2016-03-14 01:20:49 -07:00
|
|
|
return n
|
|
|
|
|
}
|
2015-02-13 14:40:36 -05:00
|
|
|
}
|
2016-05-25 10:01:58 -04:00
|
|
|
|
2017-04-21 07:51:41 -07:00
|
|
|
if !expect.Sym.IsBlank() {
|
2016-05-25 10:01:58 -04:00
|
|
|
Fatalf("nodarg: did not find node in dcl list: %v", expect)
|
|
|
|
|
}
|
2015-02-13 14:40:36 -05:00
|
|
|
}
|
|
|
|
|
|
2016-05-25 10:01:58 -04:00
|
|
|
// Build fake name for individual variable.
|
|
|
|
|
// This is safe because if there was a real declared name
|
|
|
|
|
// we'd have used it above.
|
2017-03-24 15:57:12 -07:00
|
|
|
n = newname(lookup("__"))
|
2016-03-14 01:20:49 -07:00
|
|
|
n.Type = t.Type
|
2016-03-28 09:40:53 -07:00
|
|
|
if t.Offset == BADWIDTH {
|
2016-03-14 01:20:49 -07:00
|
|
|
Fatalf("nodarg: offset not computed for %v", t)
|
|
|
|
|
}
|
2016-03-28 09:40:53 -07:00
|
|
|
n.Xoffset = t.Offset
|
cmd/compile: factor out Pkg, Sym, and Type into package types
- created new package cmd/compile/internal/types
- moved Pkg, Sym, Type to new package
- to break cycles, for now we need the (ugly) types/utils.go
file which contains a handful of functions that must be installed
early by the gc frontend
- to break cycles, for now we need two functions to convert between
*gc.Node and *types.Node (the latter is a dummy type)
- adjusted the gc's code to use the new package and the conversion
functions as needed
- made several Pkg, Sym, and Type methods functions as needed
- renamed constructors typ, typPtr, typArray, etc. to types.New,
types.NewPtr, types.NewArray, etc.
Passes toolstash-check -all.
Change-Id: I8adfa5e85c731645d0a7fd2030375ed6ebf54b72
Reviewed-on: https://go-review.googlesource.com/39855
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2017-04-04 17:54:02 -07:00
|
|
|
n.Orig = asNode(t.Nname)
|
2015-02-13 14:40:36 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Rewrite argument named _ to __,
|
|
|
|
|
// or else the assignment to _ will be
|
|
|
|
|
// discarded during code generation.
|
|
|
|
|
if isblank(n) {
|
2016-09-15 15:45:10 +10:00
|
|
|
n.Sym = lookup("__")
|
2015-02-13 14:40:36 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
switch fp {
|
2016-05-25 10:01:58 -04:00
|
|
|
default:
|
|
|
|
|
Fatalf("bad fp")
|
2015-02-13 14:40:36 -05:00
|
|
|
|
2016-05-25 10:01:58 -04:00
|
|
|
case 0: // preparing arguments for call
|
2016-10-24 14:33:22 -07:00
|
|
|
n.Op = OINDREGSP
|
2015-10-08 22:13:44 +13:00
|
|
|
n.Xoffset += Ctxt.FixedFrameSize()
|
2015-02-13 14:40:36 -05:00
|
|
|
|
2016-05-25 10:01:58 -04:00
|
|
|
case 1: // reading arguments inside call
|
2017-04-25 18:14:12 -07:00
|
|
|
n.SetClass(PPARAM)
|
cmd/compile: factor out Pkg, Sym, and Type into package types
- created new package cmd/compile/internal/types
- moved Pkg, Sym, Type to new package
- to break cycles, for now we need the (ugly) types/utils.go
file which contains a handful of functions that must be installed
early by the gc frontend
- to break cycles, for now we need two functions to convert between
*gc.Node and *types.Node (the latter is a dummy type)
- adjusted the gc's code to use the new package and the conversion
functions as needed
- made several Pkg, Sym, and Type methods functions as needed
- renamed constructors typ, typPtr, typArray, etc. to types.New,
types.NewPtr, types.NewArray, etc.
Passes toolstash-check -all.
Change-Id: I8adfa5e85c731645d0a7fd2030375ed6ebf54b72
Reviewed-on: https://go-review.googlesource.com/39855
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2017-04-04 17:54:02 -07:00
|
|
|
if funarg == types.FunargResults {
|
2017-04-25 18:14:12 -07:00
|
|
|
n.SetClass(PPARAMOUT)
|
2016-05-25 10:01:58 -04:00
|
|
|
}
|
2015-02-13 14:40:36 -05:00
|
|
|
}
|
|
|
|
|
|
2017-04-25 18:02:43 -07:00
|
|
|
n.SetTypecheck(1)
|
2017-02-27 19:56:38 +02:00
|
|
|
n.SetAddrtaken(true) // keep optimizers at bay
|
2015-02-13 14:40:36 -05:00
|
|
|
return n
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func Patch(p *obj.Prog, to *obj.Prog) {
|
|
|
|
|
if p.To.Type != obj.TYPE_BRANCH {
|
2015-08-30 23:10:03 +02:00
|
|
|
Fatalf("patch: not a branch")
|
2015-02-13 14:40:36 -05:00
|
|
|
}
|
2015-03-16 15:54:44 -04:00
|
|
|
p.To.Val = to
|
2015-02-13 14:40:36 -05:00
|
|
|
p.To.Offset = to.Pc
|
|
|
|
|
}
|