]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: make _TinySizeClass an int8 to prevent use as spanClass
authorAustin Clements <austin@google.com>
Fri, 17 Jun 2016 13:33:33 +0000 (09:33 -0400)
committerAustin Clements <austin@google.com>
Fri, 28 Apr 2017 22:50:39 +0000 (22:50 +0000)
Currently _TinySizeClass is untyped, which means it can accidentally
be used as a spanClass (not that I would know this from experience or
anything). Make it an int8 to avoid this mix up.

This is a cherry-pick of dev.garbage commit 81b74bf9c5.

Change-Id: I1e69eccee436ea5aa45e9a9828a013e369e03f1a
Reviewed-on: https://go-review.googlesource.com/41254
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rick Hudson <rlh@golang.org>
src/runtime/malloc.go
src/runtime/mheap.go

index ea0d585ed9d64e61ce6c4756c3d58abb3a289223..3a533d91007587b9f47320718bfcd255dc4ba15e 100644 (file)
@@ -111,7 +111,7 @@ const (
 
        // Tiny allocator parameters, see "Tiny allocator" comment in malloc.go.
        _TinySize      = 16
-       _TinySizeClass = 2
+       _TinySizeClass = int8(2)
 
        _FixAllocChunk  = 16 << 10               // Chunk size for FixAlloc
        _MaxMHeapList   = 1 << (20 - _PageShift) // Maximum page length for fixed-size list in MHeap.
index f237ec26aae3f8c8ad6dc797580a05ea1c5aed03..a61ea5420c887f18abc701bf14dc574f91124e01 100644 (file)
@@ -326,7 +326,7 @@ type spanClass uint8
 
 const (
        numSpanClasses = _NumSizeClasses << 1
-       tinySpanClass  = tinySizeClass<<1 | 1
+       tinySpanClass  = spanClass(tinySizeClass<<1 | 1)
 )
 
 func makeSpanClass(sizeclass uint8, noscan bool) spanClass {