diff options
| author | Michael Anthony Knyszek <mknyszek@google.com> | 2023-10-28 16:17:02 +0000 |
|---|---|---|
| committer | Michael Knyszek <mknyszek@google.com> | 2023-11-09 19:57:50 +0000 |
| commit | 25867485a748bbefc938e66330912cd88c2f4acb (patch) | |
| tree | 756da3ce458147b073d5f706ed13b7dc0d8f8e49 /src/runtime/msize_allocheaders.go | |
| parent | 9f63534858552faa3928ea3ff4c4f12302cb22f9 (diff) | |
| download | go-25867485a748bbefc938e66330912cd88c2f4acb.tar.xz | |
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 <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@golang.org>
Diffstat (limited to 'src/runtime/msize_allocheaders.go')
| -rw-r--r-- | src/runtime/msize_allocheaders.go | 27 |
1 files changed, 27 insertions, 0 deletions
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) +} |
