2 ms·
Tangential, but I almost never read assembly [1], but I do read Java bytecode pretty frequently, primarily because doing that can sometimes be a good substitute
by tombert 22d ago
Tangential, but I almost never read assembly [1], but I do read Java bytecode pretty frequently, primarily because doing that can sometimes be a good substitute for benchmarking [2], which I do not enjoy.
The thing that never seems to stop tripping me up is the different “dup” codes that compile. At some point I really need to properly learn the difference between dup_x2 and dup2_x1 and dup2_x2.
[1] not out of like an ethical objection, just my career has involved almost no reverse engineering and it’s also never been a path I have been super interested in to pursue on my own.
[2] e.g. if two competing chunks of code emit the same bytecode, you don’t need to pull out JMH. My go to example for this is using if statements vs switches, which will usually emit the same code so performance arguments are moot.
- mitxela 22d agoJava has bytecode instructions for switches. You're saying the compiler doesn't use them?
- tombert 21d agoI'm saying that if statements that can be converted to switches usually are converted to switches. Something like: if (x == 5) { doSomething() } else if (x == 6) { doSomethingElse() } This can be trivially converted into a switch and generally is. Run a release build and check me if you'd like.