fix: add gc dummy mutex

This commit is contained in:
Haolan
2025-09-19 11:27:33 +08:00
parent 33a00dff1b
commit 66a537ad29
8 changed files with 240 additions and 16 deletions

View File

@@ -4,8 +4,6 @@
package runtime
import "runtime"
// Layout of in-memory per-function information prepared by linker
// See https://golang.org/s/go12symtab.
// Keep in sync with linker (../cmd/link/internal/ld/pcln.go:/pclntab)
@@ -30,10 +28,6 @@ func StopTrace() {
panic("todo: runtime.StopTrace")
}
func ReadMemStats(m *runtime.MemStats) {
panic("todo: runtime.ReadMemStats")
}
func SetMutexProfileFraction(rate int) int {
panic("todo: runtime.SetMutexProfileFraction")
}

View File

@@ -2,7 +2,15 @@
package runtime
import "github.com/goplus/llgo/runtime/internal/clite/bdwgc"
import (
"runtime"
"github.com/goplus/llgo/runtime/internal/clite/bdwgc"
)
func ReadMemStats(m *runtime.MemStats) {
panic("todo: runtime.ReadMemStats")
}
func GC() {
bdwgc.Gcollect()

View File

@@ -2,7 +2,25 @@
package runtime
import "github.com/goplus/llgo/runtime/internal/runtime/tinygogc"
import (
"runtime"
"github.com/goplus/llgo/runtime/internal/runtime/tinygogc"
)
func ReadMemStats(m *runtime.MemStats) {
stats := tinygogc.ReadGCStats()
m.StackInuse = stats.StackInuse
m.StackSys = stats.StackSys
m.HeapSys = stats.HeapSys
m.GCSys = stats.GCSys
m.TotalAlloc = stats.TotalAlloc
m.Mallocs = stats.Mallocs
m.Frees = stats.Frees
m.Sys = stats.Sys
m.HeapAlloc = stats.HeapAlloc
m.Alloc = stats.Alloc
}
func GC() {
tinygogc.GC()