File tree Expand file tree Collapse file tree 5 files changed +12
-2
lines changed Expand file tree Collapse file tree 5 files changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -37,6 +37,7 @@ import (
37
37
)
38
38
39
39
const gcDebug = false
40
+ const needsStaticHeap = true
40
41
41
42
// Some globals + constants for the entire GC.
42
43
Original file line number Diff line number Diff line change @@ -36,6 +36,8 @@ import (
36
36
"unsafe"
37
37
)
38
38
39
+ const needsStaticHeap = false
40
+
39
41
// initHeap is called when the heap is first initialized at program start.
40
42
func initHeap ()
41
43
Original file line number Diff line number Diff line change @@ -11,6 +11,8 @@ import (
11
11
"unsafe"
12
12
)
13
13
14
+ const needsStaticHeap = true
15
+
14
16
// Ever-incrementing pointer: no memory is freed.
15
17
var heapptr uintptr
16
18
Original file line number Diff line number Diff line change @@ -10,6 +10,8 @@ import (
10
10
"unsafe"
11
11
)
12
12
13
+ const needsStaticHeap = false
14
+
13
15
var gcTotalAlloc uint64 // for runtime.MemStats
14
16
var gcMallocs uint64
15
17
var gcFrees uint64
Original file line number Diff line number Diff line change @@ -79,7 +79,10 @@ var stackTop uintptr
79
79
//
80
80
//export main
81
81
func main (argc int32 , argv * unsafe.Pointer ) int {
82
- preinit ()
82
+ if needsStaticHeap {
83
+ // Allocate area for the heap if the GC needs it.
84
+ allocateHeap ()
85
+ }
83
86
84
87
// Store argc and argv for later use.
85
88
main_argc = argc
@@ -298,7 +301,7 @@ var heapMaxSize uintptr
298
301
299
302
var heapStart , heapEnd uintptr
300
303
301
- func preinit () {
304
+ func allocateHeap () {
302
305
// Allocate a large chunk of virtual memory. Because it is virtual, it won't
303
306
// really be allocated in RAM. Memory will only be allocated when it is
304
307
// first touched.
You can’t perform that action at this time.
0 commit comments