Hacker News new | past | comments | ask | show | jobs | submit login

I'm be surprised if it didn't have something related to memory allocation and free. Open64 (previously the SGI compiler) has an "arena" memory allocator to improve memory locality and make freeing scratch memory easier. Looks like LLVM uses arena allocation, too.



Some people swear by arenas, some people swear by GCs, some swear by stacks, and others swear by malloc. There are probably people who swear by things I didn't list. Compiler writers are people, too, and so they swear by many memory allocation styles.

When I first started writing compilers, I learned the craft from people who happened to also be GC zealots, and they insisted that it was not possible to write a compiler any other way.

I remember once talking to a VM hacker who wrote compilers in C++ and was shocked that it was even possible to write a compiler in Java.

Then I saw LLVM, which mostly just relies on new/delete and an intuitive ownership model. I've done that ever since.

But as a memory management nerd I have to say that there are some advantages to every approach. Arenas are cheap and intuitive. GCs mean you don't have to care about lifetimes. Malloc/free minimizes object drag. Pick what you like and don't let anyone tell you that any one of these approaches is inherently better than the others.


LLVM does it only for very particular things. Otherwise it is using malloc a lot. The ownership is interesting as well, as some pieces are "leaked" to the LLVMContext, which has some granularity: it owns the module you're working on, so can't be destroyed before you don't need the module anymore.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: