summaryrefslogtreecommitdiff
path: root/src/runtime/malloc.go
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2014-09-16 10:22:15 -0400
committerRuss Cox <rsc@golang.org>2014-09-16 10:22:15 -0400
commit5819f77545053174374fc02ff3e09b6a6591c22c (patch)
treec7698f0ca27a64cd0de49e36c5d0501ab187ddd7 /src/runtime/malloc.go
parentf1e298b92fb8286ed1b9aa24f3cdfa5dd9e0841b (diff)
downloadgo-5819f77545053174374fc02ff3e09b6a6591c22c.tar.gz
runtime: remove duplicated Go constants
The C header files are the single point of truth: every C enum constant Foo is available to Go as _Foo. Remove or redirect duplicate Go declarations so they cannot be out of sync. Eventually we will need to put constants in Go, but for now having them be out of sync with C is too risky. These predate the build support for auto-generating Go constants from the C definitions. LGTM=iant R=iant CC=golang-codereviews https://codereview.appspot.com/141510043
Diffstat (limited to 'src/runtime/malloc.go')
-rw-r--r--src/runtime/malloc.go48
1 files changed, 20 insertions, 28 deletions
diff --git a/src/runtime/malloc.go b/src/runtime/malloc.go
index d6f1a1a4a..7bb85057f 100644
--- a/src/runtime/malloc.go
+++ b/src/runtime/malloc.go
@@ -11,49 +11,41 @@ import (
const (
debugMalloc = false
- flagNoScan = 1 << 0 // GC doesn't have to scan object
- flagNoZero = 1 << 1 // don't zero memory
+ flagNoScan = _FlagNoScan
+ flagNoZero = _FlagNoZero
- maxTinySize = 16
- tinySizeClass = 2
- maxSmallSize = 32 << 10
+ maxTinySize = _TinySize
+ tinySizeClass = _TinySizeClass
+ maxSmallSize = _MaxSmallSize
- pageShift = 13
- pageSize = 1 << pageShift
- pageMask = pageSize - 1
+ pageShift = _PageShift
+ pageSize = _PageSize
+ pageMask = _PageMask
- bitsPerPointer = 2
- bitsMask = 1<<bitsPerPointer - 1
- pointersPerByte = 8 / bitsPerPointer
- bitPtrMask = bitsMask << 2
- maxGCMask = 64
- bitsDead = 0
- bitsPointer = 2
+ bitsPerPointer = _BitsPerPointer
+ bitsMask = _BitsMask
+ pointersPerByte = _PointersPerByte
+ maxGCMask = _MaxGCMask
+ bitsDead = _BitsDead
+ bitsPointer = _BitsPointer
- bitBoundary = 1
- bitMarked = 2
- bitMask = bitBoundary | bitMarked
+ mSpanInUse = _MSpanInUse
- mSpanInUse = 0
-
- concurrentSweep = true
+ concurrentSweep = _ConcurrentSweep != 0
)
// Page number (address>>pageShift)
type pageID uintptr
-// All zero-sized allocations return a pointer to this byte.
-var zeroObject byte
-
-// Maximum possible heap size.
-var maxMem uintptr
+// base address for all 0-byte allocations
+var zerobase uintptr
// Allocate an object of size bytes.
// Small objects are allocated from the per-P cache's free lists.
// Large objects (> 32 kB) are allocated straight from the heap.
func mallocgc(size uintptr, typ *_type, flags int) unsafe.Pointer {
if size == 0 {
- return unsafe.Pointer(&zeroObject)
+ return unsafe.Pointer(&zerobase)
}
size0 := size
@@ -357,7 +349,7 @@ func newarray(typ *_type, n uintptr) unsafe.Pointer {
if typ.kind&kindNoPointers != 0 {
flags |= flagNoScan
}
- if int(n) < 0 || (typ.size > 0 && n > maxMem/uintptr(typ.size)) {
+ if int(n) < 0 || (typ.size > 0 && n > maxmem/uintptr(typ.size)) {
panic("runtime: allocation size out of range")
}
return mallocgc(uintptr(typ.size)*n, typ, flags)