History log of /dalvik/vm/analysis/Optimize.h
Revision Date Author Comments
375fb116bcb817b37509ab579dbd55cdbb765cbf 15-Jun-2011 Carl Shapiro <cshapiro@google.com> Normalize the include guard style.

An leading underscore followed by a capital letter is a reserved
name space in C and C++.

This change also moves any #include directives within the include
guard in some of the compiler/codegen/arm header files.

Change-Id: I9715e2c5301699d31886e61d0fe6e29483555a2a
d862faa2ceae186da5518607505eb942d634ced9 28-Apr-2011 Carl Shapiro <cshapiro@google.com> Get rid of uneeded extern, enum, typedef and struct qualifiers.

Change-Id: I236c5a1553a51f82c9bc3eaaab042046c854d3b4
dabd15a98449c6554579457aa4639bcdc3434eaa 14-Apr-2011 Carl Shapiro <cshapiro@google.com> Move fundamental object definitions and operations to C++

Change-Id: Ibc3766edfbf7fdbde2d762d6e88a0bb02df2be31
57fd399d1265ec627d28a15b3d4b98e5f239ac88 04-Mar-2011 Andy McFadden <fadden@android.com> Low-level support for in-memory DEX

We want to be able to load classes from a DEX file in memory,
rather than insisting that they always be loaded from disk. This
provides the underpinnings.

The code was previously using the "are we in dexopt" flag to
decide if it needed to mprotect(RW) DEX data before altering it.
We now have an explicit flag.

Also, scraped off some "opt header flags" checks that never did much.

Bug 1338213

Change-Id: If7128bf246992156662e089a2a87cebf475a6f2a
65a54dc66d2c7b6e16fc24a6ce66e50483620745 28-Jan-2011 Andy McFadden <fadden@android.com> Make more DEX optimizations "essential"

This shifts two dexopt optimizations from the "non-essential" category
to "essential", which means they will be performed at class load time
for classes that did not successfully verify in dexopt. (This has an
impact on memory and start time, but measurements have indicated that
it's negligible because dexopt usually succeeds.)

First, invoke-direct --> invoke-direct-empty. This is part of the
work needed for bug 3342343, which needs to do a little extra work
when returning from Object.<init> in a finalizable class.

Second, invoke-* --> execute-inline. We currently have three copies
of methods like String.length(): one in libcore, one in InlineNatives.c,
and one in the JIT's code generator. If we guarantee inlining, we can
get rid of the copy in libcore. We also ensure that certain libcore
tests (which are organized in a way that makes dexopt unhappy) are
using the version that will most likely be used on production.

Note there is currently no support for "jumbo" opcodes here.

Also, made the inline method lookup abort-on-failure. Once upon a time
these were "best effort" optimizations, but now they're mandatory. And
seriously, if you don't have String.length() and Math.min() you
shouldn't be trying to run anyway. dvmInlineNativeCheck() is now
redundant and has been removed.

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

Change-Id: I0c0edb3ebf0d5e040d6bbbf60269fab0deb70ef9
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