From 528bafa0498bb26a3b3961fa5bf50d02bd7101bb Mon Sep 17 00:00:00 2001 From: Michael Anthony Knyszek Date: Tue, 4 Mar 2025 19:02:48 +0000 Subject: 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 LUCI-TryBot-Result: Go LUCI Reviewed-by: Cherry Mui Reviewed-by: Michael Pratt --- src/runtime/mcentral.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src/runtime/mcentral.go') 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 -- cgit v1.3