mirror of
https://github.com/golang/go
synced 2024-09-15 14:10:17 +00:00
[dev.typeparams] cmd/compile, runtime: remove the siz argument of newproc/deferproc
newproc/deferproc takes a siz argument for the go'd/deferred function's argument size. Now it is always zero. Remove the argument. Change-Id: If1bb8d427e34015ccec0ba10dbccaae96757fa8c Reviewed-on: https://go-review.googlesource.com/c/go/+/325917 Trust: Cherry Mui <cherryyz@google.com> Run-TryBot: Cherry Mui <cherryyz@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Michael Knyszek <mknyszek@google.com>
This commit is contained in:
parent
00d01b5786
commit
8e5304f729
|
@ -4972,14 +4972,11 @@ func (s *state) call(n *ir.CallExpr, k callKind, returnResultAddr bool) *ssa.Val
|
||||||
argStart := base.Ctxt.FixedFrameSize()
|
argStart := base.Ctxt.FixedFrameSize()
|
||||||
// Defer/go args.
|
// Defer/go args.
|
||||||
if k != callNormal {
|
if k != callNormal {
|
||||||
// Write argsize and closure (args to newproc/deferproc).
|
// Write closure (arg to newproc/deferproc).
|
||||||
argsize := s.constInt32(types.Types[types.TUINT32], int32(stksize))
|
ACArgs = append(ACArgs, types.Types[types.TUINTPTR]) // not argExtra
|
||||||
ACArgs = append(ACArgs, types.Types[types.TUINT32]) // not argExtra
|
|
||||||
callArgs = append(callArgs, argsize)
|
|
||||||
ACArgs = append(ACArgs, types.Types[types.TUINTPTR])
|
|
||||||
callArgs = append(callArgs, closure)
|
callArgs = append(callArgs, closure)
|
||||||
stksize += 2 * int64(types.PtrSize)
|
stksize += int64(types.PtrSize)
|
||||||
argStart += 2 * int64(types.PtrSize)
|
argStart += int64(types.PtrSize)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set receiver (for interface calls).
|
// Set receiver (for interface calls).
|
||||||
|
|
|
@ -244,10 +244,8 @@ ok:
|
||||||
|
|
||||||
// create a new goroutine to start program
|
// create a new goroutine to start program
|
||||||
PUSHL $runtime·mainPC(SB) // entry
|
PUSHL $runtime·mainPC(SB) // entry
|
||||||
PUSHL $0 // arg size
|
|
||||||
CALL runtime·newproc(SB)
|
CALL runtime·newproc(SB)
|
||||||
POPL AX
|
POPL AX
|
||||||
POPL AX
|
|
||||||
|
|
||||||
// start this M
|
// start this M
|
||||||
CALL runtime·mstart(SB)
|
CALL runtime·mstart(SB)
|
||||||
|
|
|
@ -214,10 +214,8 @@ ok:
|
||||||
// create a new goroutine to start program
|
// create a new goroutine to start program
|
||||||
MOVQ $runtime·mainPC(SB), AX // entry
|
MOVQ $runtime·mainPC(SB), AX // entry
|
||||||
PUSHQ AX
|
PUSHQ AX
|
||||||
PUSHQ $0 // arg size
|
|
||||||
CALL runtime·newproc(SB)
|
CALL runtime·newproc(SB)
|
||||||
POPQ AX
|
POPQ AX
|
||||||
POPQ AX
|
|
||||||
|
|
||||||
// start this M
|
// start this M
|
||||||
CALL runtime·mstart(SB)
|
CALL runtime·mstart(SB)
|
||||||
|
|
|
@ -168,14 +168,13 @@ TEXT runtime·rt0_go(SB),NOSPLIT|NOFRAME|TOPFRAME,$0
|
||||||
BL runtime·schedinit(SB)
|
BL runtime·schedinit(SB)
|
||||||
|
|
||||||
// create a new goroutine to start program
|
// create a new goroutine to start program
|
||||||
SUB $12, R13
|
SUB $8, R13
|
||||||
MOVW $runtime·mainPC(SB), R0
|
MOVW $runtime·mainPC(SB), R0
|
||||||
MOVW R0, 8(R13) // arg 2: fn
|
MOVW R0, 4(R13) // arg 1: fn
|
||||||
MOVW $0, R0
|
MOVW $0, R0
|
||||||
MOVW R0, 4(R13) // arg 1: siz
|
|
||||||
MOVW R0, 0(R13) // dummy LR
|
MOVW R0, 0(R13) // dummy LR
|
||||||
BL runtime·newproc(SB)
|
BL runtime·newproc(SB)
|
||||||
ADD $12, R13 // pop args and LR
|
ADD $8, R13 // pop args and LR
|
||||||
|
|
||||||
// start this M
|
// start this M
|
||||||
BL runtime·mstart(SB)
|
BL runtime·mstart(SB)
|
||||||
|
|
|
@ -87,14 +87,11 @@ nocgo:
|
||||||
|
|
||||||
// create a new goroutine to start program
|
// create a new goroutine to start program
|
||||||
MOVD $runtime·mainPC(SB), R0 // entry
|
MOVD $runtime·mainPC(SB), R0 // entry
|
||||||
MOVD RSP, R7
|
SUB $16, RSP
|
||||||
MOVD.W $0, -8(R7)
|
MOVD R0, 8(RSP) // arg
|
||||||
MOVD.W R0, -8(R7)
|
MOVD $0, 0(RSP) // dummy LR
|
||||||
MOVD.W $0, -8(R7)
|
|
||||||
MOVD.W $0, -8(R7)
|
|
||||||
MOVD R7, RSP
|
|
||||||
BL runtime·newproc(SB)
|
BL runtime·newproc(SB)
|
||||||
ADD $32, RSP
|
ADD $16, RSP
|
||||||
|
|
||||||
// start this M
|
// start this M
|
||||||
BL runtime·mstart(SB)
|
BL runtime·mstart(SB)
|
||||||
|
|
|
@ -63,12 +63,11 @@ nocgo:
|
||||||
|
|
||||||
// create a new goroutine to start program
|
// create a new goroutine to start program
|
||||||
MOVV $runtime·mainPC(SB), R1 // entry
|
MOVV $runtime·mainPC(SB), R1 // entry
|
||||||
ADDV $-24, R29
|
ADDV $-16, R29
|
||||||
MOVV R1, 16(R29)
|
MOVV R1, 8(R29)
|
||||||
MOVV R0, 8(R29)
|
|
||||||
MOVV R0, 0(R29)
|
MOVV R0, 0(R29)
|
||||||
JAL runtime·newproc(SB)
|
JAL runtime·newproc(SB)
|
||||||
ADDV $24, R29
|
ADDV $16, R29
|
||||||
|
|
||||||
// start this M
|
// start this M
|
||||||
JAL runtime·mstart(SB)
|
JAL runtime·mstart(SB)
|
||||||
|
|
|
@ -64,12 +64,11 @@ nocgo:
|
||||||
|
|
||||||
// create a new goroutine to start program
|
// create a new goroutine to start program
|
||||||
MOVW $runtime·mainPC(SB), R1 // entry
|
MOVW $runtime·mainPC(SB), R1 // entry
|
||||||
ADDU $-12, R29
|
ADDU $-8, R29
|
||||||
MOVW R1, 8(R29)
|
MOVW R1, 4(R29)
|
||||||
MOVW R0, 4(R29)
|
|
||||||
MOVW R0, 0(R29)
|
MOVW R0, 0(R29)
|
||||||
JAL runtime·newproc(SB)
|
JAL runtime·newproc(SB)
|
||||||
ADDU $12, R29
|
ADDU $8, R29
|
||||||
|
|
||||||
// start this M
|
// start this M
|
||||||
JAL runtime·mstart(SB)
|
JAL runtime·mstart(SB)
|
||||||
|
|
|
@ -94,9 +94,8 @@ nocgo:
|
||||||
MOVDU R0, -8(R1)
|
MOVDU R0, -8(R1)
|
||||||
MOVDU R0, -8(R1)
|
MOVDU R0, -8(R1)
|
||||||
MOVDU R0, -8(R1)
|
MOVDU R0, -8(R1)
|
||||||
MOVDU R0, -8(R1)
|
|
||||||
BL runtime·newproc(SB)
|
BL runtime·newproc(SB)
|
||||||
ADD $(16+FIXED_FRAME), R1
|
ADD $(8+FIXED_FRAME), R1
|
||||||
|
|
||||||
// start this M
|
// start this M
|
||||||
BL runtime·mstart(SB)
|
BL runtime·mstart(SB)
|
||||||
|
|
|
@ -57,12 +57,11 @@ nocgo:
|
||||||
|
|
||||||
// create a new goroutine to start program
|
// create a new goroutine to start program
|
||||||
MOV $runtime·mainPC(SB), T0 // entry
|
MOV $runtime·mainPC(SB), T0 // entry
|
||||||
ADD $-24, X2
|
ADD $-16, X2
|
||||||
MOV T0, 16(X2)
|
MOV T0, 8(X2)
|
||||||
MOV ZERO, 8(X2)
|
|
||||||
MOV ZERO, 0(X2)
|
MOV ZERO, 0(X2)
|
||||||
CALL runtime·newproc(SB)
|
CALL runtime·newproc(SB)
|
||||||
ADD $24, X2
|
ADD $16, X2
|
||||||
|
|
||||||
// start this M
|
// start this M
|
||||||
CALL runtime·mstart(SB)
|
CALL runtime·mstart(SB)
|
||||||
|
|
|
@ -147,12 +147,11 @@ nocgo:
|
||||||
|
|
||||||
// create a new goroutine to start program
|
// create a new goroutine to start program
|
||||||
MOVD $runtime·mainPC(SB), R2 // entry
|
MOVD $runtime·mainPC(SB), R2 // entry
|
||||||
SUB $24, R15
|
SUB $16, R15
|
||||||
MOVD R2, 16(R15)
|
MOVD R2, 8(R15)
|
||||||
MOVD $0, 8(R15)
|
|
||||||
MOVD $0, 0(R15)
|
MOVD $0, 0(R15)
|
||||||
BL runtime·newproc(SB)
|
BL runtime·newproc(SB)
|
||||||
ADD $24, R15
|
ADD $16, R15
|
||||||
|
|
||||||
// start this M
|
// start this M
|
||||||
BL runtime·mstart(SB)
|
BL runtime·mstart(SB)
|
||||||
|
|
|
@ -18,8 +18,7 @@ TEXT runtime·rt0_go(SB), NOSPLIT|NOFRAME|TOPFRAME, $0
|
||||||
CALLNORESUME runtime·args(SB)
|
CALLNORESUME runtime·args(SB)
|
||||||
CALLNORESUME runtime·osinit(SB)
|
CALLNORESUME runtime·osinit(SB)
|
||||||
CALLNORESUME runtime·schedinit(SB)
|
CALLNORESUME runtime·schedinit(SB)
|
||||||
MOVD $0, 0(SP)
|
MOVD $runtime·mainPC(SB), 0(SP)
|
||||||
MOVD $runtime·mainPC(SB), 8(SP)
|
|
||||||
CALLNORESUME runtime·newproc(SB)
|
CALLNORESUME runtime·newproc(SB)
|
||||||
CALL runtime·mstart(SB) // WebAssembly stack will unwind when switching to another goroutine
|
CALL runtime·mstart(SB) // WebAssembly stack will unwind when switching to another goroutine
|
||||||
UNDEF
|
UNDEF
|
||||||
|
|
|
@ -112,7 +112,7 @@ func debugCallWrap(dispatch uintptr) {
|
||||||
// closure and start the goroutine with that closure, but the compiler disallows
|
// closure and start the goroutine with that closure, but the compiler disallows
|
||||||
// implicit closure allocation in the runtime.
|
// implicit closure allocation in the runtime.
|
||||||
fn := debugCallWrap1
|
fn := debugCallWrap1
|
||||||
newg := newproc1(*(**funcval)(unsafe.Pointer(&fn)), nil, 0, gp, callerpc)
|
newg := newproc1(*(**funcval)(unsafe.Pointer(&fn)), gp, callerpc)
|
||||||
args := &debugCallWrapArgs{
|
args := &debugCallWrapArgs{
|
||||||
dispatch: dispatch,
|
dispatch: dispatch,
|
||||||
callingG: gp,
|
callingG: gp,
|
||||||
|
|
|
@ -224,21 +224,16 @@ func panicmemAddr(addr uintptr) {
|
||||||
panic(errorAddressString{msg: "invalid memory address or nil pointer dereference", addr: addr})
|
panic(errorAddressString{msg: "invalid memory address or nil pointer dereference", addr: addr})
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a new deferred function fn with siz bytes of arguments.
|
// Create a new deferred function fn, which has no arguments and results.
|
||||||
// The compiler turns a defer statement into a call to this.
|
// The compiler turns a defer statement into a call to this.
|
||||||
//go:nosplit
|
//go:nosplit
|
||||||
func deferproc(siz int32, fn *funcval) { // arguments of fn follow fn
|
func deferproc(fn *funcval) { // TODO: Make deferproc just take a func().
|
||||||
gp := getg()
|
gp := getg()
|
||||||
if gp.m.curg != gp {
|
if gp.m.curg != gp {
|
||||||
// go code on the system stack can't defer
|
// go code on the system stack can't defer
|
||||||
throw("defer on system stack")
|
throw("defer on system stack")
|
||||||
}
|
}
|
||||||
|
|
||||||
if siz != 0 {
|
|
||||||
// TODO: Make deferproc just take a func().
|
|
||||||
throw("defer with non-empty frame")
|
|
||||||
}
|
|
||||||
|
|
||||||
// the arguments of fn are in a perilous state. The stack map
|
// the arguments of fn are in a perilous state. The stack map
|
||||||
// for deferproc does not describe them. So we can't let garbage
|
// for deferproc does not describe them. So we can't let garbage
|
||||||
// collection or stack copying trigger until we've copied them out
|
// collection or stack copying trigger until we've copied them out
|
||||||
|
|
|
@ -4217,7 +4217,7 @@ func malg(stacksize int32) *g {
|
||||||
return newg
|
return newg
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a new g running fn with siz bytes of arguments.
|
// Create a new g running fn.
|
||||||
// Put it on the queue of g's waiting to run.
|
// Put it on the queue of g's waiting to run.
|
||||||
// The compiler turns a go statement into a call to this.
|
// The compiler turns a go statement into a call to this.
|
||||||
//
|
//
|
||||||
|
@ -4232,12 +4232,11 @@ func malg(stacksize int32) *g {
|
||||||
// be able to adjust them and stack splits won't be able to copy them.
|
// be able to adjust them and stack splits won't be able to copy them.
|
||||||
//
|
//
|
||||||
//go:nosplit
|
//go:nosplit
|
||||||
func newproc(siz int32, fn *funcval) {
|
func newproc(fn *funcval) {
|
||||||
argp := add(unsafe.Pointer(&fn), sys.PtrSize)
|
|
||||||
gp := getg()
|
gp := getg()
|
||||||
pc := getcallerpc()
|
pc := getcallerpc()
|
||||||
systemstack(func() {
|
systemstack(func() {
|
||||||
newg := newproc1(fn, argp, siz, gp, pc)
|
newg := newproc1(fn, gp, pc)
|
||||||
|
|
||||||
_p_ := getg().m.p.ptr()
|
_p_ := getg().m.p.ptr()
|
||||||
runqput(_p_, newg, true)
|
runqput(_p_, newg, true)
|
||||||
|
@ -4248,23 +4247,19 @@ func newproc(siz int32, fn *funcval) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a new g in state _Grunnable, starting at fn, with narg bytes
|
// Create a new g in state _Grunnable, starting at fn. callerpc is the
|
||||||
// of arguments starting at argp. callerpc is the address of the go
|
// address of the go statement that created this. The caller is responsible
|
||||||
// statement that created this. The caller is responsible for adding
|
// for adding the new g to the scheduler.
|
||||||
// the new g to the scheduler.
|
|
||||||
//
|
//
|
||||||
// This must run on the system stack because it's the continuation of
|
// This must run on the system stack because it's the continuation of
|
||||||
// newproc, which cannot split the stack.
|
// newproc, which cannot split the stack.
|
||||||
//
|
//
|
||||||
//go:systemstack
|
//go:systemstack
|
||||||
func newproc1(fn *funcval, argp unsafe.Pointer, narg int32, callergp *g, callerpc uintptr) *g {
|
func newproc1(fn *funcval, callergp *g, callerpc uintptr) *g {
|
||||||
if narg != 0 {
|
|
||||||
// TODO: When we commit to GOEXPERIMENT=regabidefer,
|
// TODO: When we commit to GOEXPERIMENT=regabidefer,
|
||||||
// rewrite the comments for newproc and newproc1.
|
// rewrite the comments for newproc and newproc1.
|
||||||
// newproc will no longer have a funny stack layout or
|
// newproc will no longer have a funny stack layout or
|
||||||
// need to be nosplit.
|
// need to be nosplit.
|
||||||
throw("go with non-empty frame")
|
|
||||||
}
|
|
||||||
|
|
||||||
_g_ := getg()
|
_g_ := getg()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue