performance - Java bytecode "excessive" number of dup considered "poor" code? -
this 2 part question, wouldn't create sense individual pieces. big number of dup
instructions within bytecode output indicator of poorly written code? big defined percentage of bytecode instructions. farther how 1 go rewriting code generates dup
instruction?
are talking javac
output analyzing or own compiler/generator? if concerned quality of java code perspective of javac
produces - forget it. first of javac
produces suboptimal bytecode , relies on jvm/jit optimizations (very choice). still bytecode much improve 1 can come quickly. it's similar asking quality of assembly code generated c compiler.
if generating bytecode yourself, excessive number of dup
may bad, might not have any impact on performance. remember bytecode translated assembly on target machine. jvm stack machine architectures these days register based. fact dup
used because bytecode instructions destructive (pop value operand stack when reading). doesn't happen registers - can read them many times want. take next code example:
new java/lang/object dup invokespecial java/lang/object <init> ()v
dup
must used here because invokespecial
pops top of operand stack. creating object loose reference after calling constructor sounds bad idea. in assembly there no dup
, no info copying , duplication. have single cpu registry pointing java/lang/object
.
in other words suboptimal bytecode translated "more optimal" assembly on fly. just... don't bother.
java performance optimization bytecode
No comments:
Post a Comment