runtime: add "none" garbage collector
This collector does not implement runtime.alloc, so it is a quick-and-dirty way to check where in a program memory is allocated.
Этот коммит содержится в:
родитель
c220c140ef
коммит
ef93001ab8
2 изменённых файлов: 30 добавлений и 1 удалений
2
main.go
2
main.go
|
@ -435,7 +435,7 @@ func handleCompilerError(err error) {
|
||||||
func main() {
|
func main() {
|
||||||
outpath := flag.String("o", "", "output filename")
|
outpath := flag.String("o", "", "output filename")
|
||||||
opt := flag.String("opt", "z", "optimization level: 0, 1, 2, s, z")
|
opt := flag.String("opt", "z", "optimization level: 0, 1, 2, s, z")
|
||||||
gc := flag.String("gc", "dumb", "garbage collector to use (dumb)")
|
gc := flag.String("gc", "dumb", "garbage collector to use (none, dumb)")
|
||||||
printIR := flag.Bool("printir", false, "print LLVM IR")
|
printIR := flag.Bool("printir", false, "print LLVM IR")
|
||||||
dumpSSA := flag.Bool("dumpssa", false, "dump internal Go SSA")
|
dumpSSA := flag.Bool("dumpssa", false, "dump internal Go SSA")
|
||||||
target := flag.String("target", "", "LLVM target")
|
target := flag.String("target", "", "LLVM target")
|
||||||
|
|
29
src/runtime/gc_none.go
Обычный файл
29
src/runtime/gc_none.go
Обычный файл
|
@ -0,0 +1,29 @@
|
||||||
|
// +build gc.none
|
||||||
|
|
||||||
|
package runtime
|
||||||
|
|
||||||
|
// This GC strategy provides no memory allocation at all. It can be useful to
|
||||||
|
// detect where in a program memory is allocated, or to combine this runtime
|
||||||
|
// with a separate (external) garbage collector.
|
||||||
|
|
||||||
|
import (
|
||||||
|
"unsafe"
|
||||||
|
)
|
||||||
|
|
||||||
|
func alloc(size uintptr) unsafe.Pointer
|
||||||
|
|
||||||
|
func free(ptr unsafe.Pointer) {
|
||||||
|
// Nothing to free when nothing gets allocated.
|
||||||
|
}
|
||||||
|
|
||||||
|
func GC() {
|
||||||
|
// Unimplemented.
|
||||||
|
}
|
||||||
|
|
||||||
|
func KeepAlive(x interface{}) {
|
||||||
|
// Unimplemented. Only required with SetFinalizer().
|
||||||
|
}
|
||||||
|
|
||||||
|
func SetFinalizer(obj interface{}, finalizer interface{}) {
|
||||||
|
// Unimplemented.
|
||||||
|
}
|
Загрузка…
Создание таблицы
Сослаться в новой задаче