3 ms·
And also a sad failure. Bytecodes lose most of the semantics of code - value scope and lifetime; code structure etc. So jit compilers have to reverse engineer a
by JoeAltmaier 6y ago
And also a sad failure. Bytecodes lose most of the semantics of code - value scope and lifetime; code structure etc. So jit compilers have to reverse engineer all that. They'd have been better served to simply have the source code.
I remember being intensely disappointed when I learned Java produced bytecode (Java 1.0). Even back then I knew better, that losing semantics would be a huge hurdle to be overcome.
- dehrmann 6y agoJava bytecode looks a lot like Java, and except for local variable names, Java disassemblers do a pretty good job. Maven also solved this by very strongly encouraging the distribution of source jars. It's very rare that I have issues with missing source code when I use a standard IntelliJ setup.
- JoeAltmaier 6y agoAgain, why disassemblers? Why not put semantic info only into that java file? Why on earth go through the ritual of creating bytecodes, then un-creating them? Clearly bytecodes are not what anybody wants.
- alblue 6y agoJava bytecode allows for Debug attributes, which are produced by default in most build engines, and say which field maps to which item on the stack and for how long. Even if that information is removed, the fact that you have the return value of an invokedynamic called `object.getName` means that you can often have a much better chance of redeeming the information than in other compiled languages. The key difference is that fields and methods maintain all their names in the bytecode; in C, non-public symbols are usually stripped leaving only the calls to libraries present.
- pradn 6y agoYou do bring up an important point. Have there been successful cases of taking several levels of the code at the same time? Is there a JIT that uses both the bytecode and the AST together? Some things are easier using some data, for sure.
- kaba0 6y agoGraalVM does precisely that for dynamic languages (with really really impressive speeds, graaljs’s performance can be in the same ballpark as v8 when it comes to peak performance). But as far as I know, there Java re-implementation on top of it uses byte-codes.