mirror of
https://github.com/golang/go
synced 2024-11-23 00:20:12 -07:00
[dev.typeparams] cmd/compile, runtime: remove _defer.siz field
As deferred function now always has zero arguments, _defer.siz is always 0 and can be removed. Change-Id: Ibb89f65b2f9d2ba4aeabe50438cc3d4b6a88320b Reviewed-on: https://go-review.googlesource.com/c/go/+/325921 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
b80a4c56f0
commit
74b0b2772a
@ -4940,24 +4940,20 @@ func (s *state) call(n *ir.CallExpr, k callKind, returnResultAddr bool) *ssa.Val
|
|||||||
addr := s.addr(d)
|
addr := s.addr(d)
|
||||||
|
|
||||||
// Must match deferstruct() below and src/runtime/runtime2.go:_defer.
|
// Must match deferstruct() below and src/runtime/runtime2.go:_defer.
|
||||||
// 0: siz
|
// 0: started, set in deferprocStack
|
||||||
s.store(types.Types[types.TUINT32],
|
// 1: heap, set in deferprocStack
|
||||||
s.newValue1I(ssa.OpOffPtr, types.Types[types.TUINT32].PtrTo(), t.FieldOff(0), addr),
|
// 2: openDefer
|
||||||
s.constInt32(types.Types[types.TUINT32], 0))
|
// 3: sp, set in deferprocStack
|
||||||
// 1: started, set in deferprocStack
|
// 4: pc, set in deferprocStack
|
||||||
// 2: heap, set in deferprocStack
|
// 5: fn
|
||||||
// 3: openDefer
|
|
||||||
// 4: sp, set in deferprocStack
|
|
||||||
// 5: pc, set in deferprocStack
|
|
||||||
// 6: fn
|
|
||||||
s.store(closure.Type,
|
s.store(closure.Type,
|
||||||
s.newValue1I(ssa.OpOffPtr, closure.Type.PtrTo(), t.FieldOff(6), addr),
|
s.newValue1I(ssa.OpOffPtr, closure.Type.PtrTo(), t.FieldOff(5), addr),
|
||||||
closure)
|
closure)
|
||||||
// 7: panic, set in deferprocStack
|
// 6: panic, set in deferprocStack
|
||||||
// 8: link, set in deferprocStack
|
// 7: link, set in deferprocStack
|
||||||
// 9: framepc
|
// 8: fd
|
||||||
// 10: varp
|
// 9: varp
|
||||||
// 11: fd
|
// 10: framepc
|
||||||
|
|
||||||
// Call runtime.deferprocStack with pointer to _defer record.
|
// Call runtime.deferprocStack with pointer to _defer record.
|
||||||
ACArgs = append(ACArgs, types.Types[types.TUINTPTR])
|
ACArgs = append(ACArgs, types.Types[types.TUINTPTR])
|
||||||
@ -7583,7 +7579,6 @@ func deferstruct() *types.Type {
|
|||||||
// These fields must match the ones in runtime/runtime2.go:_defer and
|
// These fields must match the ones in runtime/runtime2.go:_defer and
|
||||||
// (*state).call above.
|
// (*state).call above.
|
||||||
fields := []*types.Field{
|
fields := []*types.Field{
|
||||||
makefield("siz", types.Types[types.TUINT32]),
|
|
||||||
makefield("started", types.Types[types.TBOOL]),
|
makefield("started", types.Types[types.TBOOL]),
|
||||||
makefield("heap", types.Types[types.TBOOL]),
|
makefield("heap", types.Types[types.TBOOL]),
|
||||||
makefield("openDefer", types.Types[types.TBOOL]),
|
makefield("openDefer", types.Types[types.TBOOL]),
|
||||||
@ -7595,9 +7590,9 @@ func deferstruct() *types.Type {
|
|||||||
makefield("fn", types.Types[types.TUINTPTR]),
|
makefield("fn", types.Types[types.TUINTPTR]),
|
||||||
makefield("_panic", types.Types[types.TUINTPTR]),
|
makefield("_panic", types.Types[types.TUINTPTR]),
|
||||||
makefield("link", types.Types[types.TUINTPTR]),
|
makefield("link", types.Types[types.TUINTPTR]),
|
||||||
makefield("framepc", types.Types[types.TUINTPTR]),
|
|
||||||
makefield("varp", types.Types[types.TUINTPTR]),
|
|
||||||
makefield("fd", types.Types[types.TUINTPTR]),
|
makefield("fd", types.Types[types.TUINTPTR]),
|
||||||
|
makefield("varp", types.Types[types.TUINTPTR]),
|
||||||
|
makefield("framepc", types.Types[types.TUINTPTR]),
|
||||||
}
|
}
|
||||||
|
|
||||||
// build struct holding the above fields
|
// build struct holding the above fields
|
||||||
|
@ -258,7 +258,7 @@ func deferproc(fn func()) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// deferprocStack queues a new deferred function with a defer record on the stack.
|
// deferprocStack queues a new deferred function with a defer record on the stack.
|
||||||
// The defer record must have its siz and fn fields initialized.
|
// The defer record must have its fn field initialized.
|
||||||
// All other fields can contain junk.
|
// All other fields can contain junk.
|
||||||
// The defer record must be immediately followed in memory by
|
// The defer record must be immediately followed in memory by
|
||||||
// the arguments of the defer.
|
// the arguments of the defer.
|
||||||
@ -271,10 +271,7 @@ func deferprocStack(d *_defer) {
|
|||||||
// 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 d.siz != 0 {
|
// fn is already set.
|
||||||
throw("defer with non-empty frame")
|
|
||||||
}
|
|
||||||
// siz and fn are already set.
|
|
||||||
// The other fields are junk on entry to deferprocStack and
|
// The other fields are junk on entry to deferprocStack and
|
||||||
// are initialized here.
|
// are initialized here.
|
||||||
d.started = false
|
d.started = false
|
||||||
@ -406,7 +403,6 @@ func newdefer(siz int32) *_defer {
|
|||||||
d = (*_defer)(mallocgc(total, deferType, true))
|
d = (*_defer)(mallocgc(total, deferType, true))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
d.siz = siz
|
|
||||||
d.heap = true
|
d.heap = true
|
||||||
return d
|
return d
|
||||||
}
|
}
|
||||||
@ -428,7 +424,7 @@ func freedefer(d *_defer) {
|
|||||||
if !d.heap {
|
if !d.heap {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
sc := deferclass(uintptr(d.siz))
|
sc := deferclass(0)
|
||||||
if sc >= uintptr(len(p{}.deferpool)) {
|
if sc >= uintptr(len(p{}.deferpool)) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -461,7 +457,6 @@ func freedefer(d *_defer) {
|
|||||||
|
|
||||||
// These lines used to be simply `*d = _defer{}` but that
|
// These lines used to be simply `*d = _defer{}` but that
|
||||||
// started causing a nosplit stack overflow via typedmemmove.
|
// started causing a nosplit stack overflow via typedmemmove.
|
||||||
d.siz = 0
|
|
||||||
d.started = false
|
d.started = false
|
||||||
d.openDefer = false
|
d.openDefer = false
|
||||||
d.sp = 0
|
d.sp = 0
|
||||||
|
@ -940,14 +940,13 @@ func extendRandom(r []byte, n int) {
|
|||||||
|
|
||||||
// A _defer holds an entry on the list of deferred calls.
|
// A _defer holds an entry on the list of deferred calls.
|
||||||
// If you add a field here, add code to clear it in freedefer and deferProcStack
|
// If you add a field here, add code to clear it in freedefer and deferProcStack
|
||||||
// This struct must match the code in cmd/compile/internal/gc/reflect.go:deferstruct
|
// This struct must match the code in cmd/compile/internal/ssagen/ssa.go:deferstruct
|
||||||
// and cmd/compile/internal/gc/ssa.go:(*state).call.
|
// and cmd/compile/internal/ssagen/ssa.go:(*state).call.
|
||||||
// Some defers will be allocated on the stack and some on the heap.
|
// Some defers will be allocated on the stack and some on the heap.
|
||||||
// All defers are logically part of the stack, so write barriers to
|
// All defers are logically part of the stack, so write barriers to
|
||||||
// initialize them are not required. All defers must be manually scanned,
|
// initialize them are not required. All defers must be manually scanned,
|
||||||
// and for heap defers, marked.
|
// and for heap defers, marked.
|
||||||
type _defer struct {
|
type _defer struct {
|
||||||
siz int32 // includes both arguments and results
|
|
||||||
started bool
|
started bool
|
||||||
heap bool
|
heap bool
|
||||||
// openDefer indicates that this _defer is for a frame with open-coded
|
// openDefer indicates that this _defer is for a frame with open-coded
|
||||||
|
Loading…
Reference in New Issue
Block a user