The exclusive promotional activities on JCOP J3H145 card and Feitian R301 Smartcard Reader are in full swing. Please check this page for details.

Does the Java compiler optimize an unnecessary ternary operator?

JavaCard Applet Development Related Questions and Answers.
kuafu
Posts: 181
Joined: Thu Jun 25, 2015 2:09 am
Points :1991
Contact:

Does the Java compiler optimize an unnecessary ternary operator?

Post by kuafu » Mon Jul 08, 2019 3:48 am

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.
well

kuafu
Posts: 181
Joined: Thu Jun 25, 2015 2:09 am
Points :1991
Contact:

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

Post by kuafu » Wed Jul 10, 2019 10:24 pm

Hi guys .JCIDE can help you to solve the problem.
https://javacardos.com/javacardforum/vi ... 6050#p6050
well

Post Reply Previous topicNext topic

Who is online

Users browsing this forum: No registered users and 7 guests

JavaCard OS : Disclaimer