Source file src/runtime/msize_noallocheaders.go

     1  // Copyright 2009 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  //go:build !goexperiment.allocheaders
     6  
     7  // Malloc small size classes.
     8  //
     9  // See malloc.go for overview.
    10  // See also mksizeclasses.go for how we decide what size classes to use.
    11  
    12  package runtime
    13  
    14  // Returns size of the memory block that mallocgc will allocate if you ask for the size.
    15  //
    16  // The noscan argument is purely for compatibility with goexperiment.AllocHeaders.
    17  func roundupsize(size uintptr, noscan bool) uintptr {
    18  	if size < _MaxSmallSize {
    19  		if size <= smallSizeMax-8 {
    20  			return uintptr(class_to_size[size_to_class8[divRoundUp(size, smallSizeDiv)]])
    21  		} else {
    22  			return uintptr(class_to_size[size_to_class128[divRoundUp(size-smallSizeMax, largeSizeDiv)]])
    23  		}
    24  	}
    25  	if size+_PageSize < size {
    26  		return size
    27  	}
    28  	return alignUp(size, _PageSize)
    29  }
    30  

View as plain text