Posts

Showing posts from November, 2009

Google's Go programming language

Google recently released a "systems" programming language called Go (not to be confused with the existing programming language called Go! ) that is designed to be simple, fast, safe and concurrent. Google give an impressive feature list: Accurate concurrent garbage collection. Goroutines and channels for parallelism and concurrency. Multiple return values. Fast compilation times. Structurally-typed object oriented programming. First-class functions. There are two different kinds of compiler available to Go programmers. The more common 8g and 6g compilers for the x86 and x86-64 architectures, respectively, are simple "splat" compilers that translate source directly into assembler. These compilers offer fast compilation but the generated code is not optimized and is generally quite slow, often several times slower than C. Moreover, in the absence of an accurate way to traverse the heap, these compilers use a GC that resorts to conservative collection (blindly travers...

How does HLVM's GC work?

HLVM injects code into managed user-code functions that keep two data structures up to date: The shadow stack lists all references held on the stack or in registers and acts as the set of global roots into the heap. If a function accepts an argument of a reference type or allocates then the value is pushed onto the shadow stack. On function exit, the shadow stack is reset back to the way it was when the function was entered. The allocated list gives all of the references that have been allocated by the program. When a function allocates, the value is appended onto the allocated list. When the allocation quota is exceeeded a garbage collection occurs. This is composed of two phases: Mark. Starting from the global roots on the shadow stack, all reachable data in the heap are marked as reachable (and the rest left marked as unreachable). Sweep. The allocated list is traversed, unreachable values are freed and all values have their mark state set back to unreachable. This functionality ...