Skip to content

Commit

Permalink
Switch to extalloc GC to use the external allocator
Browse files Browse the repository at this point in the history
  • Loading branch information
radkomih committed Jan 4, 2023
1 parent 293d0de commit d930b4c
Show file tree
Hide file tree
Showing 8 changed files with 640 additions and 7 deletions.
2 changes: 1 addition & 1 deletion build-polkawasm.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/usr/bin/env bash

docker build --tag polkawasm/tinygo:dev -f Dockerfile.polkawasm .
docker build --tag polkawasm/tinygo:dev-ext -f Dockerfile.polkawasm .
9 changes: 7 additions & 2 deletions compileopts/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,19 @@ func (c *Config) GC() string {
if c.Target.GC != "" {
return c.Target.GC
}
return "conservative"
for _, tag := range c.Target.BuildTags {
if tag == "baremetal" || tag == "wasm" {
return "conservative"
}
}
return "extalloc"
}

// NeedsStackObjects returns true if the compiler should insert stack objects
// that can be traced by the garbage collector.
func (c *Config) NeedsStackObjects() bool {
switch c.GC() {
case "conservative":
case "conservative", "extalloc":
for _, tag := range c.BuildTags() {
if tag == "tinygo.wasm" {
return true
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -1369,7 +1369,7 @@ func main() {
command := os.Args[1]

opt := flag.String("opt", "z", "optimization level: 0, 1, 2, s, z")
gc := flag.String("gc", "", "garbage collector to use (none, leaking, conservative)")
gc := flag.String("gc", "", "garbage collector to use (none, leaking, conservative, extalloc)")
panicStrategy := flag.String("panic", "print", "panic strategy (print, trap)")
scheduler := flag.String("scheduler", "", "which scheduler to use (none, tasks, asyncify)")
serial := flag.String("serial", "", "which serial output to use (none, uart, usb)")
Expand Down
Loading

0 comments on commit d930b4c

Please sign in to comment.