Skip to content

Commit fca2de2

Browse files
dgryskideadprogram
authored andcommitted
runtime: make gc and scheduler asserts settable with build tags
1 parent 107b1c2 commit fca2de2

File tree

5 files changed

+19
-9
lines changed

5 files changed

+19
-9
lines changed

src/runtime/build_asserts.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
//go:build runtime_asserts
2+
3+
package runtime
4+
5+
// enable assertions for the garbage collector
6+
const gcAsserts = true
7+
8+
// enable asserts for the scheduler
9+
const schedulerAsserts = true

src/runtime/build_noasserts.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
//go:build !runtime_asserts
2+
3+
package runtime
4+
5+
// disable assertions for the garbage collector
6+
const gcAsserts = false
7+
8+
// disable assertions for the scheduler
9+
const schedulerAsserts = false

src/runtime/gc_conservative.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,7 @@ import (
3737
"unsafe"
3838
)
3939

40-
// Set gcDebug to true to print debug information.
41-
const (
42-
gcDebug = false // print debug info
43-
gcAsserts = gcDebug // perform sanity checks
44-
)
40+
const gcDebug = false
4541

4642
// Some globals + constants for the entire GC.
4743

src/runtime/gc_leaking.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ import (
1111
"unsafe"
1212
)
1313

14-
const gcAsserts = false // perform sanity checks
15-
1614
// Ever-incrementing pointer: no memory is freed.
1715
var heapptr = heapStart
1816

src/runtime/gc_none.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ import (
1111
"unsafe"
1212
)
1313

14-
const gcAsserts = false // perform sanity checks
15-
1614
var gcTotalAlloc uint64 // for runtime.MemStats
1715
var gcMallocs uint64
1816
var gcFrees uint64

0 commit comments

Comments
 (0)