gc: drop support for 'precise' globals

Precise globals require a whole program optimization pass that is hard
to support when building packages separately. This patch removes support
for these globals by converting the last use (Linux) to use
linker-defined symbols instead.

For details, see: https://github.com/tinygo-org/tinygo/issues/2870
This commit is contained in:
Ayke van Laethem
2022-05-30 13:47:09 +02:00
committed by Ron Evans
parent 5c488e3145
commit 2d61972475
9 changed files with 39 additions and 244 deletions
+24 -2
View File
@@ -1,8 +1,13 @@
//go:build linux
// +build linux
//go:build linux && !baremetal && !nintendoswitch && !wasi
// +build linux,!baremetal,!nintendoswitch,!wasi
package runtime
// This file is for systems that are _actually_ Linux (not systems that pretend
// to be Linux, like baremetal systems).
import "unsafe"
const GOOS = "linux"
const (
@@ -18,3 +23,20 @@ const (
clock_REALTIME = 0
clock_MONOTONIC_RAW = 4
)
//go:extern _edata
var globalsStartSymbol [0]byte
//go:extern _end
var globalsEndSymbol [0]byte
// markGlobals marks all globals, which are reachable by definition.
//
// This implementation marks all globals conservatively and assumes it can use
// linker-defined symbols for the start and end of the .data section.
func markGlobals() {
start := uintptr(unsafe.Pointer(&globalsStartSymbol))
end := uintptr(unsafe.Pointer(&globalsEndSymbol))
start = (start + unsafe.Alignof(uintptr(0)) - 1) &^ (unsafe.Alignof(uintptr(0)) - 1) // align on word boundary
markRoots(start, end)
}