From 25867485a748bbefc938e66330912cd88c2f4acb Mon Sep 17 00:00:00 2001 From: Michael Anthony Knyszek Date: Sat, 28 Oct 2023 16:17:02 +0000 Subject: runtime: add the allocation headers GOEXPERIMENT and fork files This change adds the allocation headers GOEXPERIMENT which is a no-op. It forks two runtime files temporarily to make the GOEXPERIMENT easier to maintain. The forked files are mbitmap.go and msize.go. Change-Id: I60202c00e614e4517de7dd000029cf80dd0121ef Reviewed-on: https://go-review.googlesource.com/c/go/+/537980 Reviewed-by: Cherry Mui LUCI-TryBot-Result: Go LUCI Reviewed-by: Keith Randall --- src/runtime/msize_allocheaders.go | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 src/runtime/msize_allocheaders.go (limited to 'src/runtime/msize_allocheaders.go') diff --git a/src/runtime/msize_allocheaders.go b/src/runtime/msize_allocheaders.go new file mode 100644 index 0000000000..11b6c2ff6d --- /dev/null +++ b/src/runtime/msize_allocheaders.go @@ -0,0 +1,27 @@ +// Copyright 2009 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build goexperiment.allocheaders + +// Malloc small size classes. +// +// See malloc.go for overview. +// See also mksizeclasses.go for how we decide what size classes to use. + +package runtime + +// Returns size of the memory block that mallocgc will allocate if you ask for the size. +func roundupsize(size uintptr) uintptr { + if size < _MaxSmallSize { + if size <= smallSizeMax-8 { + return uintptr(class_to_size[size_to_class8[divRoundUp(size, smallSizeDiv)]]) + } else { + return uintptr(class_to_size[size_to_class128[divRoundUp(size-smallSizeMax, largeSizeDiv)]]) + } + } + if size+_PageSize < size { + return size + } + return alignUp(size, _PageSize) +} -- cgit v1.3-5-g9baa