Some of the instruction rewriting performed by dexopt
cannot be disabled. For example, accesses to volatile long
fields must be handled differently from access to long
fields, and the specialization is handled by replacing the field-get instruction with a different instruction.
The optimizations performed by dexopt
take the form of instruction replacement, usually some sort of "quickening" that allows the VM to do a little less work. All such optimizations are performed statically, ahead of time, not dynamically at run time, so you will get consistent behavior. Enabling the dexopt
optimizations doesn't introduce unknowns, it just changes from one set of knowns to a different set of knowns.
The biggest source of variation is going to be Dalvik's JIT compiler, which you can disable with -Xint:fast
. See this slightly outdated doc for notes on how to configure this system-wide.