blob: 11d6627e11032fcb8b8070716bbc65b23db756dd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
|
// Copyright 2010 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 definitions of internal structures. Master is malloc.h
package runtime
import "unsafe"
const (
pageShift = 12
pageSize = 1 << pageShift
pageMask = pageSize - 1
)
type pageID uintptr
const (
numSizeClasses = 67
maxSmallSize = 32 << 10
fixAllocChunk = 128 << 10
maxMCacheListLen = 256
maxMCacheSize = 2 << 20
maxMHeapList = 1 << 8 // 1 << (20 - pageShift)
heapAllocChunk = 1 << 20
)
type mLink struct {
next *mLink
}
type fixAlloc struct {
size uintptr
alloc func(uintptr)
first func(unsafe.Pointer, *byte)
arg unsafe.Pointer
list *mLink
chunk *byte
nchunk uint32
inuse uintptr
sys uintptr
}
// MStats? used to be in extern.go
type mCacheList struct {
list *mLink
nlist uint32
nlistmin uint32
}
type mCache struct {
list [numSizeClasses]mCacheList
size uint64
local_alloc int64
local_objects int64
next_sample int32
}
type mSpan struct {
next *mSpan
prev *mSpan
allnext *mSpan
start pageID
npages uintptr
freelist *mLink
ref uint32
sizeclass uint32
state uint32
// union {
gcref *uint32 // sizeclass > 0
// gcref0 uint32; // sizeclass == 0
// }
}
type mCentral struct {
// lock
sizeclass int32
nonempty mSpan
empty mSpan
nfree int32
}
type mHeap struct {
// lock
free [maxMHeapList]mSpan
large mSpan
allspans *mSpan
// map_ mHeapMap
min *byte
max *byte
closure_min *byte
closure_max *byte
central [numSizeClasses]struct {
pad [64]byte
// union: mCentral
}
spanalloc fixAlloc
cachealloc fixAlloc
}
const (
refFree = iota
refStack
refNone
refSome
refcountOverhead = 4
refNoPointers = 0x80000000
refHasFinalizer = 0x40000000
refProfiled = 0x20000000
refNoProfiling = 0x10000000
refFlags = 0xFFFF0000
)
const (
mProf_None = iota
mProf_Sample
mProf_All
)
type finalizer struct {
next *finalizer
fn func(unsafe.Pointer)
arg unsafe.Pointer
nret int32
}
|