Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I'm actually a little disappointed that a mature compiler like javac doesn't seem features such as escape analysis and being able to compile Enum types to primitive values (compiling them to a single byte would be enough for most constants). I might be wrong about these specific cases, but my overall impressions is that compilers like the main one for Java aren't very adventourous when it comes to compiler optimizations. They sometimes seem pretty primitive, even. It's understandable if optimizations would add a lot of time to the compilization, but I don't see why it can't be added as compiler flags at the least, to be used for shipping software.

I have never hacked compilers myself, so I might be totally off the mark on all of this. And the specific things I've mentioned might be much harder than what they seem at a cursory glance. But this post is more of an inquiry into the matter than a definitive statement about the status quo.



Keep in mind that javac is only half of the compiler, the JVM is the other half. I'm not sure you need escape analysis when you compile down to JVM bytecode. Could you show an example?


I'm talking about stuff like having a method where you make an object - let's say comprising of two ints, a coordinate - and figures out if it can instead solve the same problem with, say, just making two stack-allocated ints instead of one heap-allocated object. Maybe the programmer wanted to make an object since it looked more readable than making two ints.


Java does that, it just happens in the JVM during jit


Yes, that is the pretty standard scalar replacement of aggregates optimization.


I work on the JIT in JVM's.

javac's a very dumb compiler.

All the advanced optimizations like Escape Anaysis are applied by the JIT within the JVM.




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

Search: