aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/msize.go
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2015-02-19 13:38:46 -0500
committerRuss Cox <rsc@golang.org>2015-02-19 20:17:01 +0000
commit484f801ff4125d86f8c4072f070611afea9c79f7 (patch)
tree6609ead9e0e6dabd5565800a5c5f80a89211ef75 /src/runtime/msize.go
parentd384545a4580cf1f6990efee5f0047ec60f4258d (diff)
downloadgo-484f801ff4125d86f8c4072f070611afea9c79f7.tar.gz
go-484f801ff4125d86f8c4072f070611afea9c79f7.zip
runtime: reorganize memory code
Move code from malloc1.go, malloc2.go, mem.go, mgc0.go into appropriate locations. Factor mgc.go into mgc.go, mgcmark.go, mgcsweep.go, mstats.go. A lot of this code was in certain files because the right place was in a C file but it was written in Go, or vice versa. This is one step toward making things actually well-organized again. Change-Id: I6741deb88a7cfb1c17ffe0bcca3989e10207968f Reviewed-on: https://go-review.googlesource.com/5300 Reviewed-by: Austin Clements <austin@google.com> Reviewed-by: Rick Hudson <rlh@golang.org>
Diffstat (limited to 'src/runtime/msize.go')
-rw-r--r--src/runtime/msize.go18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/runtime/msize.go b/src/runtime/msize.go
index a113b0d963..370cae629e 100644
--- a/src/runtime/msize.go
+++ b/src/runtime/msize.go
@@ -27,8 +27,15 @@
package runtime
-//var class_to_size [_NumSizeClasses]int32
-//var class_to_allocnpages [_NumSizeClasses]int32
+// Size classes. Computed and initialized by InitSizes.
+//
+// SizeToClass(0 <= n <= MaxSmallSize) returns the size class,
+// 1 <= sizeclass < NumSizeClasses, for n.
+// Size class 0 is reserved to mean "not small".
+//
+// class_to_size[i] = largest size in class i
+// class_to_allocnpages[i] = number of pages to allocate when
+// making new objects in class i
// The SizeToClass lookup is implemented using two arrays,
// one mapping sizes <= 1024 to their class and one mapping
@@ -38,8 +45,11 @@ package runtime
// are 128-aligned, so the second array is indexed by the
// size divided by 128 (rounded up). The arrays are filled in
// by InitSizes.
-//var size_to_class8 [1024/8 + 1]int8
-//var size_to_class128 [(_MaxSmallSize-1024)/128 + 1]int8
+
+var class_to_size [_NumSizeClasses]int32
+var class_to_allocnpages [_NumSizeClasses]int32
+var size_to_class8 [1024/8 + 1]int8
+var size_to_class128 [(_MaxSmallSize-1024)/128 + 1]int8
func sizeToClass(size int32) int32 {
if size > _MaxSmallSize {