aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/mcentral.go
diff options
context:
space:
mode:
authorMichael Anthony Knyszek <mknyszek@google.com>2025-03-04 19:02:48 +0000
committerGopher Robot <gobot@golang.org>2025-04-23 08:00:33 -0700
commit528bafa0498bb26a3b3961fa5bf50d02bd7101bb (patch)
treeeb72406f4a0ce690d368b2377e2df031457775ca /src/runtime/mcentral.go
parentecdd429a3be7abde6e169b79da13bffdba064cb4 (diff)
downloadgo-528bafa0498bb26a3b3961fa5bf50d02bd7101bb.tar.xz
runtime: move sizeclass defs to new package internal/runtime/gc
We will want to reference these definitions from new generator programs, and this is a good opportunity to cleanup all these old C-style names. Change-Id: Ifb06f0afc381e2697e7877f038eca786610c96de Reviewed-on: https://go-review.googlesource.com/c/go/+/655275 Auto-Submit: Michael Knyszek <mknyszek@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Michael Pratt <mpratt@google.com>
Diffstat (limited to 'src/runtime/mcentral.go')
-rw-r--r--src/runtime/mcentral.go11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/runtime/mcentral.go b/src/runtime/mcentral.go
index 08ff0a5c5d..21731f3fec 100644
--- a/src/runtime/mcentral.go
+++ b/src/runtime/mcentral.go
@@ -14,6 +14,7 @@ package runtime
import (
"internal/runtime/atomic"
+ "internal/runtime/gc"
"internal/runtime/sys"
)
@@ -80,7 +81,7 @@ func (c *mcentral) fullSwept(sweepgen uint32) *spanSet {
// Allocate a span to use in an mcache.
func (c *mcentral) cacheSpan() *mspan {
// Deduct credit for this span allocation and sweep if necessary.
- spanBytes := uintptr(class_to_allocnpages[c.spanclass.sizeclass()]) * _PageSize
+ spanBytes := uintptr(gc.SizeClassToNPages[c.spanclass.sizeclass()]) * pageSize
deductSweepCredit(spanBytes, 0)
traceDone := false
@@ -248,8 +249,8 @@ func (c *mcentral) uncacheSpan(s *mspan) {
// grow allocates a new empty span from the heap and initializes it for c's size class.
func (c *mcentral) grow() *mspan {
- npages := uintptr(class_to_allocnpages[c.spanclass.sizeclass()])
- size := uintptr(class_to_size[c.spanclass.sizeclass()])
+ npages := uintptr(gc.SizeClassToNPages[c.spanclass.sizeclass()])
+ size := uintptr(gc.SizeClassToSize[c.spanclass.sizeclass()])
s := mheap_.alloc(npages, c.spanclass)
if s == nil {
@@ -257,8 +258,8 @@ func (c *mcentral) grow() *mspan {
}
// Use division by multiplication and shifts to quickly compute:
- // n := (npages << _PageShift) / size
- n := s.divideByElemSize(npages << _PageShift)
+ // n := (npages << gc.PageShift) / size
+ n := s.divideByElemSize(npages << gc.PageShift)
s.limit = s.base() + size*n
s.initHeapBits()
return s