runtime: allow custom-gc SetFinalizer and clarify KeepAlive

Этот коммит содержится в:
Anuraag Agrawal 2023-02-17 08:51:51 +09:00 коммит произвёл GitHub
родитель e0a5fc2555
коммит f6df276118
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
5 изменённых файлов: 19 добавлений и 4 удалений

Просмотреть файл

@ -687,3 +687,7 @@ func ReadMemStats(m *MemStats) {
m.Frees = gcFrees
m.Sys = uint64(heapEnd - heapStart)
}
func SetFinalizer(obj interface{}, finalizer interface{}) {
// Unimplemented.
}

Просмотреть файл

@ -20,6 +20,7 @@ package runtime
// - func free(ptr unsafe.Pointer)
// - func markRoots(start, end uintptr)
// - func GC()
// - func SetFinalizer(obj interface{}, finalizer interface{})
// - func ReadMemStats(ms *runtime.MemStats)
//
//
@ -51,6 +52,9 @@ func markRoots(start, end uintptr)
// GC is called to explicitly run garbage collection.
func GC()
// SetFinalizer registers a finalizer.
func SetFinalizer(obj interface{}, finalizer interface{})
// ReadMemStats populates m with memory statistics.
func ReadMemStats(ms *MemStats)

Просмотреть файл

@ -85,6 +85,10 @@ func GC() {
// No-op.
}
func SetFinalizer(obj interface{}, finalizer interface{}) {
// No-op.
}
func initHeap() {
// preinit() may have moved heapStart; reset heapptr
heapptr = heapStart

Просмотреть файл

@ -26,6 +26,10 @@ func GC() {
// Unimplemented.
}
func SetFinalizer(obj interface{}, finalizer interface{}) {
// Unimplemented.
}
func initHeap() {
// Nothing to initialize.
}

Просмотреть файл

@ -89,11 +89,10 @@ func UnlockOSThread() {
}
func KeepAlive(x interface{}) {
// Unimplemented. Only required with SetFinalizer().
}
func SetFinalizer(obj interface{}, finalizer interface{}) {
// Unimplemented.
// TODO: This function needs to be implemented in a way that LLVM doesn't optimize away the x
// parameter. This will likely need either a volatile operation or calling an assembly stub
// that simply returns.
}
var godebugUpdate func(string, string)