runtime: move GC code around to prepare for precise GC

Most of the code of the conservative GC can be reused for the precise
GC. So before adding precise GC support, this commit just moves code
around to make the next commit cleaner. It is a non-functional change.
This commit is contained in:
Ayke van Laethem
2022-12-15 17:36:02 +01:00
committed by Ayke
parent 187d9c6aca
commit fb73074325
5 changed files with 675 additions and 678 deletions
+17
View File
@@ -64,6 +64,23 @@ func free(ptr unsafe.Pointer) {
// Memory is never freed.
}
// ReadMemStats populates m with memory statistics.
//
// The returned memory statistics are up to date as of the
// call to ReadMemStats. This would not do GC implicitly for you.
func ReadMemStats(m *MemStats) {
m.HeapIdle = 0
m.HeapInuse = gcTotalAlloc
m.HeapReleased = 0 // always 0, we don't currently release memory back to the OS.
m.HeapSys = m.HeapInuse + m.HeapIdle
m.GCSys = 0
m.TotalAlloc = gcTotalAlloc
m.Mallocs = gcMallocs
m.Frees = gcFrees
m.Sys = uint64(heapEnd - heapStart)
}
func GC() {
// No-op.
}