History log of /dalvik/vm/analysis/Optimize.c
Revision Date Author Comments
139bd97804a69634e7c4cecf06910a050a4ac093 09-Sep-2010 Andy McFadden <fadden@android.com> Added "dexopt for SMP" flag.

Currently, dexopt always runs on the target device, which means that
decisions about whether or not to convert certain opcodes to SMP-safe
variants could be made based on #ifdefs.

Since we are planning to run dexopt on the host, we need to be able
to configure SMP-mode independently. This change adds a global variable
that the dexopt code can check.

There is currently no command-line argument to set this, since it will
be set by "dexopt" rather than "dalvikvm", and the exact method of
launching dexopt from the host build is still mildly TBD.

Bug 2981136.

(cherry-pick from dalvik-dev)

Change-Id: I7474f79a25368223ecf1e491458f4a82e85db01f
139516ee8f527aca18ae658087f28d825bfdf1c9 07-Jul-2010 Andy McFadden <fadden@android.com> Only emit cat1 volatile ops in SMP builds.

After consultation with the JITSquad, we no longer emit volatile
field access instructions for category 1 values unless ANDROID_SMP
is nonzero.

See also bug 2781881.

Change-Id: I58041572f6cf9308a8a125200dc419ce9d3d8d12
fb119e6cf8b47d53f024cae889487a17eacbf19f 29-Jun-2010 Andy McFadden <fadden@android.com> Emit volatile field access instructions.

Easier said than done. The trick is that we need to ensure that the
instruction replacement happens even if the verifier and optimizer
are not enabled in dexopt.

We're currently doing the -wide-volatile replacement during
verification, but that's not so great, since we collapse things like
iget-byte and iget-char into a single iget-volatile, losing the field
width. We could recover it from the field declaration, but doing it
during verification is really just sort of wrong to begin with.

The substitution isn't technically an "optimization", but it's easiest
to do it during the opt pass, and we already have a convenient "is
optimized" flag that helps ensure that we do the replacement pass
exactly once.

Optimizing at run time means making a private copy of shared pages,
because the pages are mapped shared/read-only out of the DEX file.
We could use up a lot of physical memory if we applied all possible
optimizations, so we need a notion of "essential" and "non-essential"
optimizations. If we're not running in dexopt, we only do the
essential ones, which should leave most methods untouched.

Replacement of 32-bit instructions is only strictly necessary when
we're building for SMP. On a uniprocessor, the 32-bit operations
are inherently atomic, and memory barriers aren't required. However,
the JIT may benefit from having volatile accesses identified by opcode.
Since the current branch doesn't support any SMP products, I'm enabling
the instruction generation for all platforms so that we can give it
some exercise.

While making this change I noticed that the exclusion mechanism for
breakpoints and optimization/verification was only serving to avoid
a data race (e.g. breakpoint being overwritten by an instruction
rewrite). It wasn't guaranteed to prevent races when two threads
toggled pages between read-write and read-only while making an update,
since a 4K page can hold code for more than one class. This has been
corrected by adding a mutex.

This change:
- Introduces the notion of essential vs. non-essential optimizations.
- Adds generation of 32-bit *-volatile instructions for all platforms.
- Moves generation of *-wide-volatile from the verifier to the optimizer.
- Allows the optimizer to modify code at run time.
- Tweaks optimizeMethod() for "best effort" rather than "fail early".
- Adds a DEX-granularity mutex to the bytecode update functions.

This also begins the removal of PROFILE_FIELD_ACCESS, which hasn't been
used for much and is mostly just in the way.

Change-Id: I4ac9fa5e1ac5f9a1d106c662c3deee90d62895aa
228a6b01918304f2cd1213c722e028a6e25252bb 05-May-2010 Andy McFadden <fadden@android.com> Forward progress on verifier.

Promoted VerifierData to a more prominent role in passing state around.
This will (a) allow us to pass fewer explicit arguments around in the
core of the verifier, and (b) make it easier to maintain some fancier
data structures that we will need shortly.

Made use of dexGetInstrOrTableWidthAbs() in a couple of places where
we were still explicitly calculating the sizes of NOP data chunks.

Converted some things from int to size_t.

Change-Id: I206f588bf1fc116a9d1f50fb631a9af33479b291
7365493ad8d360c1dcf9cd8b6eee62747af01cae 09-Jun-2010 Carl Shapiro <cshapiro@google.com> Remove repeated newlines at the end of files.

Change-Id: I1e3d103a7b932ef21acedb6438c0f26b315df28f
fbdcfb9ea9e2a78f295834424c3f24986ea45dac 29-May-2010 Brian Carlstrom <bdc@google.com> Merge remote branch 'goog/dalvik-dev' into dalvik-dev-to-master

Change-Id: I0c0edb3ebf0d5e040d6bbbf60269fab0deb70ef9
e3c01dac83e6eea7f82fe81ed89cfbdd9791dbc9 21-May-2010 Carl Shapiro <cshapiro@google.com> Remove unused labels, variables, and functions. Enable warnings.

Change-Id: Icbe24eaf1ad499f28b68b6a5f05368271a0a7e86
cb3c542b8712b7ef005aabc4b8139c667afc7a9d 08-Apr-2010 Andy McFadden <fadden@android.com> Move the furniture around some more.

Mostly just moving things around, with minor changes to behavior.

- Instead of walking through all classes twice (once for verification,
once for optimization), we now walk through them once and do both
operations on a given class before moving on to the next.
- If verification and optimization were disabled, the VM used a special
"no fork + exec" path. It adds complexity for little benefit, so
it's gone.
- Reduced the amount of stuff being passed as arguments through multiple
layers of functions. Notably, a pointer to a read-only lookup table
is now accessed via a global.
- The PROFILE_FIELD_ACCESS define now just blocks the quickening of
field accesses instead of blocking all optimizations. (Not sure this
is worth keeping around.)

Change-Id: I7f7c658e3b682c7251cdf17cae58d79bd04ba2a0
2e1ee50a08cc3dd07ce4e956b925c1f0f28cf329 24-Mar-2010 Andy McFadden <fadden@android.com> Rearrange some things.

This splits DexOptimize into DexPrepare (which deals with file shuffling
and fork/exec) and Optimize (which does the actual quickening of
instructions). The Optimize functions are now effectively private to
the "analysis" directory.

Twiddled some comments.

No substantive code changes.

Change-Id: Ia51865b259fb32822132e2373997866e360ca86a