4 ms·
They just use the implementation from the last version of the compiler, which you can follow back in a long chain to the first implementation. As for the implem
by James_K 2y ago
They just use the implementation from the last version of the compiler, which you can follow back in a long chain to the first implementation. As for the implementation of the garbage collector, it probably just doesn't allocate anything. The basics of a garbage collector are a function "alloc" and another one "collect". The function to allocate memory usually looks something like this:
char heap[100000000];
int heap_end;
void *alloc(int n_bytes) {
void *out = &heap[heap_end]
heap_end += n_bytes;
return out;
}
As you can see, it doesn't need to allocate any memory to do this.
- School-Cotton 2y ago> They just use the implementation from the last version of the compiler The garbage collector isn’t part of the compiler, it’s part of the runtime. It’s worth being clear about this distinction because I think it’s the root of the OP’s confusion.
- wrs 2y agoSure, but what’ll really bake OP’s noodle is that Go’s GC is written in Go too. :) [0] [0] https://go.dev/src/runtime/mgc.go https://go.dev/src/runtime/mgc.go