Skip to content

Commit 303607c

Browse files
committed
runtime (gc): add a new "list" GC
This memory manager uses a simple linked list to track active allocations, and measures the gaps between them to find available memory. Performance is not great for large heaps, but is sufficient for microcontrollers with single-digit kilobytes of memory.
1 parent b40703e commit 303607c

File tree

10 files changed

+476
-9
lines changed

10 files changed

+476
-9
lines changed

compileopts/options.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
)
88

99
var (
10-
validGCOptions = []string{"none", "leaking", "extalloc", "conservative"}
10+
validGCOptions = []string{"none", "leaking", "extalloc", "conservative", "list"}
1111
validSchedulerOptions = []string{"none", "tasks", "coroutines"}
1212
validSerialOptions = []string{"none", "uart", "usb"}
1313
validPrintSizeOptions = []string{"none", "short", "full"}

compileopts/options_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99

1010
func TestVerifyOptions(t *testing.T) {
1111

12-
expectedGCError := errors.New(`invalid gc option 'incorrect': valid values are none, leaking, extalloc, conservative`)
12+
expectedGCError := errors.New(`invalid gc option 'incorrect': valid values are none, leaking, extalloc, conservative, list`)
1313
expectedSchedulerError := errors.New(`invalid scheduler option 'incorrect': valid values are none, tasks, coroutines`)
1414
expectedPrintSizeError := errors.New(`invalid size option 'incorrect': valid values are none, short, full`)
1515
expectedPanicStrategyError := errors.New(`invalid panic option 'incorrect': valid values are print, trap`)

main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1006,7 +1006,7 @@ func main() {
10061006
command := os.Args[1]
10071007

10081008
opt := flag.String("opt", "z", "optimization level: 0, 1, 2, s, z")
1009-
gc := flag.String("gc", "", "garbage collector to use (none, leaking, extalloc, conservative)")
1009+
gc := flag.String("gc", "", "garbage collector to use (none, leaking, extalloc, conservative, list)")
10101010
panicStrategy := flag.String("panic", "print", "panic strategy (print, trap)")
10111011
scheduler := flag.String("scheduler", "", "which scheduler to use (none, coroutines, tasks)")
10121012
serial := flag.String("serial", "", "which serial output to use (none, uart, usb)")

src/runtime/gc_globals_conservative.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// +build gc.conservative gc.extalloc
1+
// +build gc.conservative gc.extalloc gc.list
22
// +build baremetal tinygo.wasm
33

44
package runtime

src/runtime/gc_globals_precise.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// +build gc.conservative gc.extalloc
1+
// +build gc.conservative gc.extalloc gc.list
22
// +build !baremetal,!tinygo.wasm
33

44
package runtime

0 commit comments

Comments
 (0)