Page 1 of 1

Does the Java compiler optimize an unnecessary ternary operator?

Posted: Mon Jul 08, 2019 3:48 am
by kuafu
https://stackoverflow.com/questions/544 ... y-operator
The simple answer is no. The java compiler doesn't care.
Most of the optimization are not done in the Java compiler but in the Runtime. Is your target performance results or performance result without runtime optimizations
But all the javacard rumtime didn't support JIT,didn't support javacard bytecode optimization. So we need a bytecode optimize to help us .
JCIDE will integration Proguard to help you.

You are aware of Proguard? http://proguard.sourceforge.net/
This is a great bytecode optimizer which implements a lot of optimizations. See the FAQ for a list:
Evaluate constant expressions.
Remove unnecessary field accesses and method calls.
Remove unnecessary branches.
Remove unnecessary comparisons and instanceof tests.
Remove unused code blocks.
Merge identical code blocks.
Reduce variable allocation.
Remove write-only fields and unused method parameters.
Inline constant fields, method parameters, and return values.
Inline methods that are short or only called once.
Simplify tail recursion calls.
Merge classes and interfaces.
Make methods private, static, and final when possible.
Make classes static and final when possible.
Replace interfaces that have single implementations.
Perform over 200 peephole optimizations, like replacing ...*2 by ...<<1.
Optionally remove logging code.
I'm sure you can further look into the source code to understand how they are implemented.

Re: Does the Java compiler optimize an unnecessary ternary operator?

Posted: Wed Jul 10, 2019 10:24 pm
by kuafu
Hi guys .JCIDE can help you to solve the problem.
https://javacardos.com/javacardforum/vi ... 6050#p6050