I know that
javac compiles the
*.java files into
*.class files , the content of these files is called bytecode.
I assumed each bytecode was translated to an assembler equivalent like ADD or SUB or whatever. If this is true then the final result of the JIT and my intepreter should be the same assembler instructions and at this point I don't see why I would need my
Please correct if any of my statement is wrong.
Best How To :
Java bytecode is a fairly high level language and there's far from a 1-to-1 relation to assembly instructions. Here are a few things that come to mind:
- Garbage collection - This is a guarantee of the JVM and typically not considered when talking about programs written natively.
- Array index checks - Each array access needs to (directly or indirectly) be governed by out of bounds checks. A high level feature that must be dealt with by the VM.
- Null pointer checks - Many bytecode instructions can implicitly throw nice exceptions such as
NullPointerException. The "native counterpart" is to fail silently or segfault.
- Exception handling - Exception handling in general have performance implications. Sure, native languages such as C++ do support exceptions, but many C++ projects avoid using them for performance considerations.