Don't force optimizations during class init in dexopt.

Some "optimizations" are mandatory, notably those having to do with
access to volatile fields.  We get into an odd situation in dexopt
where we have to initialize and execute <clinit> in a few classes
(primarily Class and Object), but if optimizations are disabled we
don't want to write optimized instructions into the output DEX.

This modifies the class init code to skip the mandatory optimizations
if we're in dexopt.  Either the optimization will happen as a normal
part of dexopt operation, or it won't (in which case it'll be applied
when the class is first loaded in a normal VM).

Bug 3099161.

Change-Id: I11ee5affd5e3ac5a1e8583241acdf3c4de033a96
2 files changed