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

This does happen partially with escape analysis within a function. Objects/primitives could be allocated on the stack instead. I totally agree that this should be an area that could be explored more in depth.



Not just stack allocation. Pool allocation also, especially when one has many threads. And inserting destructor calls directly into code, etc, etc. There are a lot of optimizations here.

Take Java. One of the concepts of Java was that you didn't need to worry about the stack / heap distinction - the JVM handles where to put things. But in practice, all this ends up doing is making (almost) everything ends up on the heap. And then people wonder why it's slower and more memory-hungry.

(Also: I wish compilers would be smarter about function boundaries. Have functions be source-level constructs, that get turned into a single global control flow graph, which the compiler then inspects to determine where function boundaries "make sense". With manual overrides of course.)




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

Search: