aboutsummaryrefslogtreecommitdiff
path: root/src/runtime
diff options
context:
space:
mode:
authorMichael Anthony Knyszek <mknyszek@google.com>2025-02-18 22:32:00 +0000
committerGopher Robot <gobot@golang.org>2025-02-19 14:25:03 -0800
commit57cd75a351a170e6ec6f3525972d16a3135b9398 (patch)
treedb87dcbfae3e71efeaf86695741102216c0e9687 /src/runtime
parent6d7cb594b358b9b22709fb7a7940abc4c9778074 (diff)
downloadgo-57cd75a351a170e6ec6f3525972d16a3135b9398.tar.xz
runtime: minor mfinal.go code cleanup
This change moves finBlockSize into mfinal.go and renames finblock to finBlock. Change-Id: I20a0bc3907e7b028a2caa5d2fe8cf3f76332c871 Reviewed-on: https://go-review.googlesource.com/c/go/+/650695 Auto-Submit: Michael Knyszek <mknyszek@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Carlos Amedee <carlos@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com>
Diffstat (limited to 'src/runtime')
-rw-r--r--src/runtime/mfinal.go27
-rw-r--r--src/runtime/mgc.go3
2 files changed, 15 insertions, 15 deletions
diff --git a/src/runtime/mfinal.go b/src/runtime/mfinal.go
index 4962a63a41..05d26e6cd6 100644
--- a/src/runtime/mfinal.go
+++ b/src/runtime/mfinal.go
@@ -14,19 +14,21 @@ import (
"unsafe"
)
-// finblock is an array of finalizers to be executed. finblocks are
-// arranged in a linked list for the finalizer queue.
+const finBlockSize = 4 * 1024
+
+// finBlock is an block of finalizers/cleanups to be executed. finBlocks
+// are arranged in a linked list for the finalizer queue.
//
-// finblock is allocated from non-GC'd memory, so any heap pointers
+// finBlock is allocated from non-GC'd memory, so any heap pointers
// must be specially handled. GC currently assumes that the finalizer
// queue does not grow during marking (but it can shrink).
-type finblock struct {
+type finBlock struct {
_ sys.NotInHeap
- alllink *finblock
- next *finblock
+ alllink *finBlock
+ next *finBlock
cnt uint32
_ int32
- fin [(_FinBlockSize - 2*goarch.PtrSize - 2*4) / unsafe.Sizeof(finalizer{})]finalizer
+ fin [(finBlockSize - 2*goarch.PtrSize - 2*4) / unsafe.Sizeof(finalizer{})]finalizer
}
var fingStatus atomic.Uint32
@@ -40,16 +42,15 @@ const (
fingWake
)
-// This runs durring the GC sweep phase. Heap memory can't be allocated while sweep is running.
var (
finlock mutex // protects the following variables
fing *g // goroutine that runs finalizers
- finq *finblock // list of finalizers that are to be executed
- finc *finblock // cache of free blocks
- finptrmask [_FinBlockSize / goarch.PtrSize / 8]byte
+ finq *finBlock // list of finalizers that are to be executed
+ finc *finBlock // cache of free blocks
+ finptrmask [finBlockSize / goarch.PtrSize / 8]byte
)
-var allfin *finblock // list of all blocks
+var allfin *finBlock // list of all blocks
// NOTE: Layout known to queuefinalizer.
type finalizer struct {
@@ -108,7 +109,7 @@ func queuefinalizer(p unsafe.Pointer, fn *funcval, nret uintptr, fint *_type, ot
lock(&finlock)
if finq == nil || finq.cnt == uint32(len(finq.fin)) {
if finc == nil {
- finc = (*finblock)(persistentalloc(_FinBlockSize, 0, &memstats.gcMiscSys))
+ finc = (*finBlock)(persistentalloc(finBlockSize, 0, &memstats.gcMiscSys))
finc.alllink = allfin
allfin = finc
if finptrmask[0] == 0 {
diff --git a/src/runtime/mgc.go b/src/runtime/mgc.go
index d10f3c09cf..25345abca9 100644
--- a/src/runtime/mgc.go
+++ b/src/runtime/mgc.go
@@ -135,8 +135,7 @@ import (
)
const (
- _DebugGC = 0
- _FinBlockSize = 4 * 1024
+ _DebugGC = 0
// concurrentSweep is a debug flag. Disabling this flag
// ensures all spans are swept while the world is stopped.