History log of /dalvik/vm/Globals.h
Revision Date Author Comments
ed94ff793680873d2c942641ccda9ea81c95b5ad 13-Oct-2012 Elliott Hughes <enh@google.com> Revert "Don't enforce access checks for overloading for targetSdkVersion < 17."

This reverts commit 0fe885202fc2d1e7f3d34c99ae3487a9a6387be1

May be causing http://b/7343420, though I can't reproduce that crash.

Change-Id: Ia3d2a1507602d07699d1f9914e734cc813f97518
0fe885202fc2d1e7f3d34c99ae3487a9a6387be1 12-Oct-2012 Elliott Hughes <enh@google.com> Don't enforce access checks for overloading for targetSdkVersion < 17.

Still warn, and enforce the missing check for targetSdkVersion >= 17.

Bug: 7301030
Change-Id: I8189fcbf222f331b1f80a156b01082d61f1f9362
485dfb5ccb6d8b2c5d498ff6ee41b14e79103e3c 24-Sep-2012 Ian Rogers <irogers@google.com> Allow max free size of heap to be configured.

This allows the max free to be larger on devices with more memory and
thereby avoid GCs (that may be more frequent due to larger bitmaps).

b/6606849

Change-Id: I4063a303ea4be3c1f227259d699fb238a806451f
0c2dc522d0e120f346cf0a40c8cf0c93346131c2 03-Jul-2012 Dong-Yuan Chen <dong-yuan.chen@intel.com> [X86] X86 trace JIT compiler support

This patch provides a fully functional x86 trace JIT compiler for Dalvik
VM. It is built on top of the existing x86 fast interpreter
with bug fixes and needed extension to support trace JIT interface. The
x86 trace JIT code generator was developed independent of the existing
template-based code generator and thus does not share exactly the same
infrastructure. Included in this patch are:

* Deprecated and removed the x86-atom fast interpreter that is no
longer functional since ICS.
* Augmented x86 fast interpreter to provide interfaces for x86 trace JIT
compiler.
* Added x86 trace JIT code generator with full JDWP debugging support.
* Method JIT and self-verification mode are not supported.

The x86 code generator uses the x86 instruction encoder/decoder library
from the Apache Harmony project. Additional wrapper extension and bug
fixes were added to support the x86 trace JIT code generator. The x86
instruction encoder/decoder is embedded inside the x86 code generator
under the libenc subdirectory.

Change-Id: I241113681963a16c13a3562390813cbaaa6eedf0
Signed-off-by: Dong-Yuan Chen <dong-yuan.chen@intel.com>
Signed-off-by: Yixin Shou <yixin.shou@intel.com>
Signed-off-by: Johnnie Birch <johnnie.l.birch.jr@intel.com>
Signed-off-by: Udayan <udayan.banerji@intel.com>
Signed-off-by: Sushma Kyasaralli Thimmappa <sushma.kyasaralli.thimmappa@intel.com>
Signed-off-by: Bijoy Jose <bijoy.a.jose@intel.com>
Signed-off-by: Razvan A Lupusoru <razvan.a.lupusoru@intel.com>
Signed-off-by: Tim Hartley <timothy.d.hartley@intel.com>
7222596c216393e5386b260a0b19082cf4a0d0ec 13-Apr-2012 Elliott Hughes <enh@google.com> Add a -XX:mainThreadStackSize= option.

Similar to -Xss, but for the main thread only.

Bug: 6315322
Change-Id: I84bd5974f830f348fd9a0486ae972520b4a02cc4
ce6603b52e6b2ef947cb308b1d7157e357bcba02 13-Apr-2012 Elliott Hughes <enh@google.com> Add a -XX:mainThreadStackSize= option.

Similar to -Xss, but for the main thread only.

Bug: 6315322
Change-Id: I84bd5974f830f348fd9a0486ae972520b4a02cc4
f7c18055de6e7ffb3ee16a45680ea0ffd6158fbd 11-Oct-2011 Ben Cheng <bccheng@android.com> Leave up to 512 chars of gDvm.lastMessage on dvmAbort's stack frame.

Bug: 5372634
Change-Id: I019a059e5a989de3dfc9e2f5e78f7caa7168cf75
9f640af99bebc6e96f6e1e9903557e2c8f567483 20-Jul-2011 Jeff Brown <jeffbrown@android.com> Add a dual clock profiler tracing mode.

Dalvik previously supported using either the thread-cpu clock
or the real time clock as the timebase for profiler traces.
This change adds a dual clock mode where both thread-cpu time
and real time timestamps are collected.

Using dual clock mode significantly improves TraceView ability
to accurately reconstruct the global timeline of events,
particularly on SMP systems.

For now, thread-cpu mode remains the default.

Dual clock mode can be enabled by running the following command
and restarting the system server.
adb shell setprop dalvik.vm.extra-opts -Xprofile:dualclock

Change-Id: I14db2ae93325ac01efcc8ed02e8747cc0e834e29
ea333384b92db9c400be1b4c8cb6992d9ba5f14d 11-Jul-2011 Elliott Hughes <enh@google.com> Add JNI app bug workarounds.

Specifically, this hands out direct pointers for all local references,
and lets you use a JNIEnv* on the wrong thread. This is off by default,
but enabled for apps that don't have ICS as their targetSdkVersion.

Bug: 4772166
Change-Id: I20c403a8e63481a35d579d2bd3b121c80ec08f89
3f04fa049734772a945243d64d6ce9a34b39b730 30-Jun-2011 Elliott Hughes <enh@google.com> Add two new JNI debugging options.

The alwaysCheckThread option provides some backwards compatibility for apps
that misuse JNIEnv*s across threads. The logThirdPartyJni is a step towards
making it easier for third-party developers to debug their JNI errors.

Change-Id: I134374da0fe94f3fbc6b6d5aef52e3eef658aff9
949c3ec207a7720fb47f7b3ca1f84dfcfd70aaa9 25-Jun-2011 Jeff Brown <jeffbrown@google.com> Add a dual clock profiler tracing mode.

Dalvik previously supported using either the thread-cpu clock
or the real time clock as the timebase for profiler traces.
This change adds a dual clock mode where both thread-cpu time
and real time timestamps are collected.

Using dual clock mode significantly improves TraceView ability
to accurately reconstruct the global timeline of events,
particularly on SMP systems.

For now, thread-cpu mode remains the default.

Dual clock mode can be enabled by running the following command
and restarting the system server.
adb shell setprop dalvik.vm.extra-opts -Xprofile:dualclock

Change-Id: I8c0d91a99aa6829dadea328e54dc1225d9827391
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
0c32ebc544b8dd1528dc007090abda0be5f31174 09-Jun-2011 Carl Shapiro <cshapiro@google.com> Fix a minor leaks caused by failed initializations.

Change-Id: Ie0939bce7422b224f4cfde9781470f2237ede497
689cc333b7be28b8b312f91999a31a2b0bd60c62 08-Jun-2011 Elliott Hughes <enh@google.com> Fix regular exit.

Change-Id: I653658f3b6e533a235f1108d0b625b9bdff7630c
0fbb7030fff58e25718291811394487d95d95a3e 07-Jun-2011 Elliott Hughes <enh@google.com> Use std::string rather than malloc/free for saneDirName.

Also use std::vector instead of the cutils/array cruft.

Change-Id: I273147335cafbac5d336955f53b0b29d015f0589
12fc997bc0351d62e88dcb40572b46b48583c1d0 11-May-2011 Carl Shapiro <cshapiro@google.com> Remove dead code.

Change-Id: I3093925668eef9a839fc9fc490fc8260c001b777
e346f7d8f0a79f5fc53fd02c288cb7c12e23b40a 10-May-2011 Ben Cheng <bccheng@android.com> Fix a couple debugging issues involving JIT single-stepping mode.

1) Declare the jitop mask array using a defined length.
2) Fix a spurious divergence when the first instruction in the trace is
single-stepped.

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

Change-Id: I236c5a1553a51f82c9bc3eaaab042046c854d3b4
d5c80e06a771bb34336c1ec5b0d9ce8a47ec4244 27-Apr-2011 Elliott Hughes <enh@google.com> Remove the old forcecopy in favor of the new.

Also remove some more half-baked multi-VM cruft, fix command-line
parsing (so -Xforcecopy-fuck-yeah won't work any more), and remove
an unused #define.

Bug: 3412449
Change-Id: If914e23dd3bbcf0ac113a445777e0f550ca05703
a5f3ed80b3b058b006ee2b09915d1400cebd0442 27-Apr-2011 Elliott Hughes <enh@google.com> Add -Xjniopts:forcecopy-unmap to catch more errors than forcecopy.

In particular, this spots the BreakIterator bug that forcecopy didn't.
It's about 2x slower than regular forcecopy mode, so I've added a new
option rather than just replace the fast-but-less-effective forcecopy.

Bug: 3412449
Change-Id: I1f226ceeab2508dff607ba25b0afee51cf9c3f83
389e258a5b9b2afb7bfaee3344c615d3310fae4e 23-Apr-2011 buzbee <buzbee@google.com> InterpBreak cleanup (part 1)

Moved the suspend count variables from the interpBreak structure. These
are already protected by a mutex, and we need the space in interpBreak
for additional subMode flags. This CL just does the move and expands
the width of subMode to 16-bits.

Change-Id: I4a6070b1ba4fb08a0f6e0aba6f150b30f9159eed
d5c36b9040bd26a81219a7f399513526f9b46324 16-Apr-2011 Carl Shapiro <cshapiro@google.com> Move the remaining non-compiler VM code into C++.

Change-Id: Id8693208d2741c55a7b0474d1264f2112019d11f
ae188c676c681e47a93ade7fdf0144099b470e03 08-Apr-2011 Carl Shapiro <cshapiro@google.com> Compile the garbage collector and heap profiler as C++.

Change-Id: I25d8fa821987a3dd6d7109d07fd42dbf2fe0e589
ce87bfed41bbe4248b2770fb1a90f34b2518f6fa 31-Mar-2011 Carl Shapiro <cshapiro@google.com> Delegate the queuing of cleared references to managed code.

Previously, the garbage collector would pass each cleared reference to
the heap worker thread for queuing. The heap worker thread would then
perform a callback into managed code for each cleared reference which
assigned the reference to its reference queue.

With this change, the garbage collector instead links together all of
the cleared references and calls back into managed code exactly once
to hand off the references for processing. This change makes the heap
worker thread and its data structures obsolete.

Change-Id: I28e02638f0877a7fd2ac96b9c3f5597a38541ebb
4b17a1da633822d7651fe854aece7ea93c1edf70 29-Mar-2011 Andy McFadden <fadden@android.com> Init classes used by DDMS

Not all call paths ensure class initialization.

Change-Id: Ic12ac5c59f3ffa2d7c04e84ea37264f65a7630be
edb595d5ee6d5b2eddf9b897efc4ccbf56ee6c12 29-Mar-2011 Jesse Wilson <jessewilson@google.com> Remove unused security manager code.

Change-Id: Iecc602b8235eb3feeac31e198bdaf61c65dd9fbf
http://b/4087759
ce1762c38447714349cfbf71a73750e7fa382c11 29-Mar-2011 Andy McFadden <fadden@android.com> Prep DDMS stuff in InitRefs

Find some methods and field offsets.

Also removed a duplicate entry.

Change-Id: I4c23af6cfe6e7d4f5e8767c5a9a30d3b441ad425
f5e6de992c4b1b9b89c5f327be453e7e8fba312b 25-Mar-2011 Andy McFadden <fadden@android.com> Yet more InitRefs-ing

Fix up some early initialization stuff.

Also, stop pretending that the top of non-main-thread stacks is a
Runnable.

Change-Id: I3e89c6320351c160cfa0bea3cf6bbfd26a5b7c12
19cd2fcb98cbefe22a76d353020cb5b0277578aa 24-Mar-2011 Andy McFadden <fadden@android.com> Some more InitRefs-ing

Uncaught exception handling and FileDescriptor.descriptor.

Change-Id: Ia7429417a47e9a3e3d327b246c3ad33c6c77dfa0
86c95935211bcb07cc2cb9dc1a6d1069f80f727c 24-Mar-2011 Andy McFadden <fadden@android.com> Various JDWP updates

More tweaks to JDWP support:

- Mask off access flags not defined by the Java programming language
from fields and methods.
- Use InitRefs to look up ThreadGroup fields.
- Use memcpy() for some 64-bit accesses.

Change-Id: I4ff9f28ad7e6f1519a2befa557ddb5cf41e0f4cf
9a3147c7412f4794434b4c2604aa2ba784867774 03-Mar-2011 buzbee <buzbee@google.com> Interpreter restructuring

This is a restructuring of the Dalvik ARM and x86 interpreters:

o Combine the old portstd and portdbg interpreters into a single
portable interpreter.
o Add debug/profiling support to the fast (mterp) interpreters.
o Delete old mechansim of switching between interpreters. Now, once
you choose an interpreter at startup, you stick with it.
o Allow JIT to co-exist with profiling & debugging (necessary for
first-class support of debugging with the JIT active).
o Adds single-step capability to the fast assembly interpreters without
slowing them down (and, in fact, measurably improves their performance).
o Remove old "polling for safe point" mechanism. Breakouts now achieved
via modifying base of interpreter handler table.
o Simplify interpeter control mechanism.
o Allow thread-granularity control for profiling & debugging

The primary motivation behind this change was to improve the responsiveness
of debugging and profiling and to make it easier to add new debugging and
profiling capabilities in the future. Instead of always bailing out to the
slow debug portable interpreter, we can now stay in the fast interpreter.

A nice side effect of the change is that the fast interpreters
got a healthy speed boost because we were able to replace the
polling safepoint check that involved a dozen or so instructions
with a single table-base reload. When combined with the two earlier CLs
related to this restructuring, we show a 5.6% performance improvement
using libdvm_interp.so on the Checkers benchmark relative to Honeycomb.

Change-Id: I8d37e866b3618def4e582fc73f1cf69ffe428f3c
f60f48e917d715fff9ec1ce24a75b7fb0d000a58 22-Mar-2011 Elliott Hughes <enh@google.com> Remove more dead SecurityManager cruft.

(Requires corresponding libcore change.)

Change-Id: I86aac9dda6708173fd2b5a1c660ef20ea11fca03
0970976b0e980be00424f93a69c2bc13ca3131f3 18-Mar-2011 Andy McFadden <fadden@android.com> Fix up some JDWP stuff

Notably:
- Claim to know about synthetic attributes (canGetSyntheticAttribute).
Set an appropriate flag in the access flags of fields and methods.
(Makes no difference that I can see in Eclipse.)
- Stop making copies of descriptor strings. That ceased to be necessary
after they were normalized in DEX (pre-1.0).
- Correct object type determination, especially w.r.t. the specially-
tagged types (strings, threads, classloaders, etc).
- Handle a FIELD_ONLY mod (not tested).
- Added a bit of debugging stuff.

Change-Id: I5651b5b76d904a9edbd051e039423795faaa1650
3475f9cdb47a6d6f8ad2ce49bbc3af46bca92f09 21-Mar-2011 Carl Shapiro <cshapiro@google.com> Move finalization out of the VM.

This change introduces a new reference class whose referent
points to instances requiring finalization. This makes the
finalization of objects possible using a reference queue and
a dedicated thread which removes objects from the queue.

Change-Id: I0ff6dd272f00ca08c6ed3aa667bf766a039a944e
46cd4fb73824ab57160994c149ce2d7a06923b83 17-Mar-2011 Ben Cheng <bccheng@android.com> Extend a trace with a backward branch into a loop.

When seeing a trace that ends with a backward branch, exhaust all code
blocks reachable from that trace and try to identify if there exists a
non-nested loop. If the derived loop is found to be too complex or only
acyclic code is seen, revert to the original compilation mechanism to
translate a simple trace.

This CL uses the whole-method parser/dataflow analysis framework to
identify such loops. No optimization/codegen are performed yet.

Bug: 4086718

Change-Id: I19ed3ee53ea1cbda33940c533de8e9220e647156
318839c0b3f912790b61c876fbe75917e1ca0378 14-Mar-2011 Dan Bornstein <danfuzz@android.com> Collate the initial class creation code.

This is just a minor shuffling of code to make it easier to
find the code that does the creation of the first classes
(first objects really) as the vm is starting up.

Change-Id: I053c5ebeea4c1808fe975dc387a9e53294ba93fe
a9c49df6714b3a37b7a7d0522932e622be2b35ac 11-Mar-2011 Dan Bornstein <danfuzz@android.com> Clean up how primitive types are handled.

The PrimitiveType enum got "promoted" to libdex, and I added a
few helper functions there. I also quashed the idea that there
is some sort of canonical ordering of the enumerated values.

In the vm (per se), I made PrimitiveType uses where it had assumed
an ordering instead switch(). This mostly made things much simpler.

I also split out the array of type classes in Globals.h into
individual ClassObject*s. This mostly made things simpler, but the gc
got a tiny bit of extra cruft because of it.

Finally, I made it so that the type classes get created explicitly
during vm startup, instead of happening implicitly the first time
they're accessed. This both simplified the code and, in particular,
made it so that the type classes didn't have to be declared volatile.

There are still a couple of related items that could stand to be
cleaned up, but I think what's here is enough for one patch.

Change-Id: Id14a6dfdb200abce9f30911c330ba32d9c2a4c3f
842947eedd492a4ddcdec7950d554415a8964293 11-Mar-2011 Dan Bornstein <danfuzz@android.com> Extract more reference inits.

In this case, the primitive array reference initialization got made
un-lazy and now happens consistently and early during vm
initialization.

Change-Id: I7477e31554bbde02dd5fc96bd7aff4af5cdac513
d8a16d35e40e2894952bd6b04036e1d4240d0bac 11-Mar-2011 Dan Bornstein <danfuzz@android.com> Kill off the doPrivileged() special case code.

We've already deprecated / disabled much of the rest of the intra-VM
security manager code, and so this code serves no real purpose anymore.

Change-Id: Ic75abc20c446d12022d19ad8807abd34f918a14b
40fcd04f6b2a776aae1d52d1a49e6652e735051f 10-Mar-2011 Dan Bornstein <danfuzz@android.com> Pull the Reference setup code into InitRefs.c.

The idea here is to make it obvious in the setup code that Reference
has to be set up specially, to make it less likely that it will get
erroneously combined with the other setup code in the future.

Since the class Reference itself isn't used, I took the opportunity
to just remove it from Globals.h.

Change-Id: I301c0ac2032e78e1e57cc3065eb0baa77f0d346f
cd380420ec1b52c3d6f0c7cc54b46ec29bb27dc0 10-Mar-2011 Dan Bornstein <danfuzz@android.com> Clean up UtfString.c, two ways.

The class and member init code got pulled out, and put it into
InitRefs.c (for further cleansing in a future change).

The instance creation code got refactored a bit, to keep things
simpler and tidier.

Change-Id: I22d8abff141ea889b3455a1cebcf51e333cd8c92
385828e36ea70effe9aa18a954d008b1f7dc1d63 05-Mar-2011 Ben Cheng <bccheng@android.com> Handle relocatable class objects in JIT'ed code.

1) Split the original literal pool into class object literals and
constants. Elements in the class object pool have to match the specicial
values perfectly (ie no +delta space optimizations) since they might be
relocated.

2) Implement dvmJitScanAllClassPointers(void (*callback)(void *))
which is the entry routine to report all memory locations in the code cache
that contain class objects (ie class object pool and predicted chaining
cells for virtual calls).

3) Major codegen changes on how/when the class object pool are populated
and how predicted chains are patched. Before this change the compiler
thread is always in the VM_WAIT state, which won't prevent GC from
running. Since the class object pointers captured by a worker thread
are no longer guaranteed to be stable at JIT time, change various
internal data structures to capture the class descriptor/loader
tuple instead. The conversion from descriptor/loader tuple to actual
class object pointers are only performed when the thread state is
RUNNING or at GC safe point.

4) Separate the class object installation phase out of the main
dvmCompilerAssembleLIR routine so that the impact to blocking GC
requests is minimal. Add new stats to report the potential block time.
For example:
Potential GC blocked by compiler: max 46 us / avg 25 us

5) Various cleanup in the trace structure walkup code. Modified the
verbose print routine to show the class descriptor in the class literal
pool. For example:

D/dalvikvm( 1450): -------- end of chaining cells (0x007c)
D/dalvikvm( 1450): 0x44020628 (00b4): .class
(Lcom/android/unit_tests/PerformanceTests$EmptyClass;)
D/dalvikvm( 1450): 0x4402062c (00b8): .word (0xaca8d1a5)
D/dalvikvm( 1450): 0x44020630 (00bc): .word (0x401abc02)
D/dalvikvm( 1450): End

Bug: 3482956

Change-Id: I2e736b00d63adc255c33067544606b8b96b72ffc
701abba5119f17a3b786fbb940aa62353a186100 09-Mar-2011 Carl Shapiro <cshapiro@google.com> Use indirect references in JNI by default.

This change removes support for direct references.

Change-Id: I2af043ecfc5811c16a7d02a5bbb6c071ec6f0a82
2ff04ab635eeba79c2dad82850c34188abcdfe62 09-Mar-2011 Andy McFadden <fadden@android.com> Fix method profiling

Moved a couple of things out of MethodTraceState so they don't get
zeroed after being initialized.

Also, rearranged the native method invocation path slightly so the
common case runs uninterrupted.

Change-Id: I0dad007a7f344d93f30444156e67f20bed6606a4
e4c3b5ef3b418ea50f577a850bdbdfaf97718601 08-Mar-2011 Carl Shapiro <cshapiro@google.com> Finish the indirect reference implementation.

This change eliminates all compilation errors and warnings when the
indirect reference feature is enabled, adds support for the indirect
reference table to the root visitor, and adds a new implementation of
jni weak global references integrated with the garbage collector.

Change-Id: Ieb4a0eb6c352b1a7dc095b0be1b5df2ad133fb64
9807b4e9412a6ce6863688c84a36ce294028ff04 04-Mar-2011 Dan Bornstein <danfuzz@android.com> Clean out now-unused exception code.

We hereby wish a fond farewell to the throw functions that took
a string name for the exception.

Bug: 3500987
Change-Id: I869ddc2b4e45d3122859249d4010e452d790fa1f
a3b3512e99ef51940b0a13e57528bd32803f72b4 04-Mar-2011 Dan Bornstein <danfuzz@android.com> More exception rework.

This includes banishing dvmThrowExceptionWithClassMessage(), in favor
of the "ByClass" version, as well as making the verification error
throwing code use class objects.

Bug: 3500987
Change-Id: I1d63cec0ffaf3a0ad17e9304ba6a21fe51072fc7
85ba81d1da57c9f19c54bee3d7907b70045dad46 03-Mar-2011 Dan Bornstein <danfuzz@android.com> Set up a few more exceptions.

I'm starting to scrape the bottom of the barrel.

Bug: 3500987
Change-Id: If9c0f922506a94e78c504ea8c58176effe5fe00c
537e29e62e2e465c8ab3b1587d726eb5bf708665 03-Mar-2011 Dan Bornstein <danfuzz@android.com> Set up a few more exceptions.

This time I *didn't* modify all the call sites, as they're not all
straightforward. However, I will do so in a separate follow-up.

Bug: 3500987
Change-Id: I7c8b4fe960704dc37e192d645be9da9d97159627
8521311b4e55847c650a87933d5a3f04618e4e69 02-Mar-2011 Dan Bornstein <danfuzz@android.com> Yak-shaving in support of the exception cleanup.

This change restructures where early class initialization happens in
the VM, moving a few chunks of it together into Init.c. The exception
classes get moved here as well as the super-core classes needed
particularly for dex optimization. This is all done to support a follow-up
change that will put more of the verifier's required exceptions into
the list. (Before this change, it would have been unsafe to do that.)

This change also paves the way for further consolidation of class and
member initialization, which I hope will make it easier to transition
the whole mess into the new copying-gc world, when that arrives on the
scene.

Bug: 3500987
Change-Id: I0caae09432a05287af53aa36a6663997ab310985
bc606f5e72b16f3759f5d414c7444204908718aa 01-Mar-2011 Dan Bornstein <danfuzz@android.com> Clean up a few more exceptions.

Bug: 3500987
Change-Id: I9d6dcf429ca67a64a81e4489b1087948f9673e07
9b598e34e2401bda77fca9c8f3a5c50e882e6d68 01-Mar-2011 Dan Bornstein <danfuzz@android.com> Clean up a few more exceptions.

This includes a fix for ExceptionInInitializerError, which previously
could have gotten thrown before itself being initialized.

Change-Id: I3f27091f79b1a7e965c6261d3ff78109e0e4a23f
7a86c44bde10b37d8df17d0613072c4ef134189c 28-Feb-2011 Dan Bornstein <danfuzz@android.com> More exception cleanup.

Most notable is that StringIndexOutOfBoundsException now gets two
argument-specific helper functions.

Change-Id: Ia4353589f1ee14ac337cdf637a66b89bca99a48a
2c8e25b2010d1bba4dca0148691bc6e1a4ee7616 26-Feb-2011 Dan Bornstein <danfuzz@android.com> More exception cleanup.

Added a few more classes to the list and tweaked
dvmThrowNegativeArraySizeException() to actually take the size as an
argument. Still pending: Changing the assembly interp files to make
better calls.

Change-Id: I3a470f5fd4c9a1f7f55fc875900096c00c4ac010
6d167a4b02f310700a55fc9a24fccce999e0fdf2 25-Feb-2011 Dan Bornstein <danfuzz@android.com> More exception cleanup.

I added a few more exception class objects, and migrated existing
uses of those exceptions away from naming the class as a string.

I left one TODO in the x86-atom interp, as there is nobody actively
maintaining that codebase.

Change-Id: I9226a2d81b0389a14f7a3770d978a9bbe98c2898
32bb3da6f05959749161ce7f9103027f11597fe3 25-Feb-2011 Dan Bornstein <danfuzz@android.com> Add a bit of structure to the Exception startup code.

This is in preparation for having a *lot* more exception classes get
looked up at startup time.

Change-Id: Id464c5b19a6a15f6779d8959f5d6397a0c6c5842
7ab74e14ed8dac0e51ce72fc6283ee2f1ffdf087 03-Feb-2011 Ben Cheng <bccheng@android.com> Add support to do suspend polling on backward branches in JIT'ed code.

The polling is expensive for now as it is done through three
instructions: ld/ld/branch. As a result, a bunch of bonus stuff has
been worked on to mitigate the extra overhead:

- Cleaned up resource flags for memory disambiguation.
- Rewrote load/store elimination and scheduler routines to hide
the ld/ld latency for GC flag. Seperate the dependency checking into
memory disambiguation part and resource conflict part.
- Allowed code motion for Dalvik/constant/non-aliasing loads to be
hoisted above branches for null/range checks.
- Created extended basic blocks following goto instructions so that
longer instruction streams can be optimized as a whole.

Without the bonus stuff, the performance dropped about ~5-10% on some
benchmarks because of the lack of headroom to hide the polling latency
in tight loops. With the bonus stuff, the performance delta is between
+/-5% with polling code generated. With the bonus stuff but disabling
polling, the new bonus stuff provides consistent performance
improvements:

CaffeineMark 3.6%
Linpack 11.1%
Scimark 9.7%
Sieve 33.0%
Checkers 6.0%

As a result, GC polling is disabled by default but can be turned on
through the -Xjitsuspendpoll flag for experimental purposes.

Change-Id: Ia81fc85de3e2b70e6cc93bc37c2b845892003cdb
49dc060d5ae9bbcc78e570ec0dd244973e920fb6 10-Feb-2011 Elliott Hughes <enh@google.com> Move more system propery handling into managed code.

Bug: 3413364
Change-Id: I044ed1b11e919bb1c589c626b613faf85157fb64
01605d2b668e8e1701cfdfa302dde847b9171fc9 01-Feb-2011 Carl Shapiro <cshapiro@google.com> Remove the unused monitor tracking and deadlock prediction code.

This feature has been in the code base for several releases but has never
been enabled.

Change-Id: Ia770b03ebc90a3dc7851c0cd8ef301f9762f50db
18fba346582c08d81aa96d9508c0e935bad5f36f 20-Jan-2011 buzbee <buzbee@google.com> Support traceview-style profiling in all builds

This change builds on an earlier bccheng change that allowed JIT'd code
to avoid reverting to the debug portable interpeter when doing traceview-style
method profiling. That CL introduced a new traceview build (libdvm_traceview)
because the performance delta was too great to enable the capability for
all builds.

In this CL, we remove the libdvm_traceview build and provide full-speed
method tracing in all builds. This is done by introducing "_PROF"
versions of invoke and return templates used by the JIT. Normally, these
templates are not used, and performace in unaffected. However, when method
profiling is enabled, all existing translation are purged and new translations
are created using the _PROF templates. These templates introduce a
smallish performance penalty above and beyond the actual tracing cost, but
again are only used when tracing has been enabled.

Strictly speaking, there is a slight burden that is placed on invokes and
returns in the non-tracing case - on the order of an additional 3 or 4
cycles per invoke/return. Those operations are already heavyweight enough
that I was unable to measure the added cost in benchmarks.

Change-Id: Ic09baf4249f1e716e136a65458f4e06cea35fc18
821fd06d4dc53f23e82074fcc8d8ffdc32ea3a51 19-Jan-2011 Carl Shapiro <cshapiro@google.com> Add an option to disable explicit GC requests.

Change-Id: Ibb2ca9d99fccfba61492a8059201777f59c81274
cb3081f675109049e63380170b60871e8275f9a8 14-Jan-2011 buzbee <buzbee@google.com> Consolidate mterp's debug/profile/suspend control

This is a step towards full debug & profiling support in JIT'd code.
Previously, the interpreter made multiple distinct checks for pending
suspend requests, debugger and profiler checks at each safe point.
This CL moves the individual controls into a single control word,
significantly speeding up the safe-point check code path in the common
fast case.

In short, any time some VM component wants control to break at a safe
point it will set a bit in gDvm.interpBreak, which will be examined
at the safe point check in footer.S. In the old code, the safe point
check consisted of 11 instructions (including 6 loads). The new sequence
is 6 instructions (4 loads - two of which are needed and two are
speculative to fill otherwise stalling slots).

This code path is hot enough in the interpreter that we actually see
some measureable speedups in benchmarks. The old sieve benchmark
improves from 252 to 256 (~1.5%).

As part of the change, global debuggerActive and activeProfilers variables
have been eliminated as redundant. Note also that there is a subtle
change in thread suspension. Thread suspend request counts are kept on
a per-thread basis, and previously each thread would only examine its own
suspend count. With this change, a bit has been allocated in interpBreak
to signify that at least one suspend request is active across all
threads. This bit is treated as "some thread is supposed to
suspend, check to see if it's me".

Change-Id: I527dc918f58d1486ef3324136080ef541a775ba8
df9f08b877ecfd8ebadea822bb9e066ee7d30433 19-Jan-2011 Carl Shapiro <cshapiro@google.com> Implement growth limits to support multiple heap configurations.

When a growth limit is in effect, allocations will be limited to
number of bytes specified by the growth limit instead of the maximum
heap size. Growth limits are specified on the command line with the
new parameter -XX:HeapGrowthLimit. A growth limit can be removed at
runtime by calling the new clearGrowthLimit method.

This is a work around until we can adjust the maximum heap size at
runtime.

Change-Id: Ic01e32823b5ca8cf29c0948fb6cd2df10967c1fb
2e152baec01433de9c63633ebc6f4adf1cea3a87 16-Dec-2010 buzbee <buzbee@google.com> [JIT] Trace profiling support

In preparation for method compilation, this CL causes all traces to
include two entry points: profiling and non-profiling. For now, the
profiling entry will only be used if dalvik is run with -Xjitprofile,
and largely works like it did before. The difference is that profiling
support no longer requires the "assert" build - it's always there now.

This will enable us to do a form of sampling profiling of
traces in order to identify hot methods or hot trace groups,
while keeping the overhead low by only switching profiling on periodically.

To turn the periodic profiling on and off, we simply unchain all existing
translations and set the appropriate global profile state. The underlying
translation lookup and chaining utilties will examine the profile state to
determine which entry point to use (i.e. - profiling or non-profiling) while
the traces naturally rechain during further execution.

Change-Id: I9ee33e69e33869b9fab3a57e88f9bc524175172b
3b55675a442a173eb1337ba3c5866cd30cefb504 14-Dec-2010 Brad Fitzpatrick <bradfitz@android.com> Add a new, optional "is sensitive thread?" hook.

The Android framework implements this hook in Ie6f58d130a29.

Bug: 3226270
Change-Id: I7342248e5699a22b71647e7cfeec52ec871cefaf
701d2720fa693621a3c0c4d0bdf9e32e3eb8e731 02-Dec-2010 Andy McFadden <fadden@android.com> Progress on liveness analysis.

Compute basic blocks and their predecessors, necessary for backward flow
analysis. This is a work in progress and isn't yet enabled.

(When enabled, verification takes 20% longer, so there's some room for
improvement on performance.)

Also, this changes the "generate register maps" setting to be enabled
by default, and allows a "no" prefix on -Xgenregmap to disable it.

Bug 2534655

Change-Id: Id2e8512f53fc454ce2184879ab663ed7121274b6
ccaab18ae6d203108445fef7682065dfbb007657 04-Dec-2010 Dan Bornstein <danfuzz@android.com> Another clarifying rename and a bit more automation.

kNumDalvikInstructions is now kNumPackedOpcodes, there is a new
kMaxOpcodeValue, and both are generated by opcode-gen.

Change-Id: Ic46f1f52d2d21382452c8e777024f4a985ad31d3
Bonus: Reworded the switch and array data comment for clarity.
3f64a024dec2c080b9abde74502826b29263152a 13-Nov-2010 Andy McFadden <fadden@android.com> Check monitors during bytecode verification

This adds tracking of monitor-enter and monitor-exit instructions
to the bytecode verifier. The idea is to guarantee that all lock
operations in a method are paired with unlock operations, whether
the method completes normally or abnormally.

Because of an issue in "dx", the code only verifies that the operation
stack has the right size at all times. We do not yet confirm that
the correct monitor is being unlocked by monitor-exit (the code is
present but ifdefed out). Also, when monitor verification is enabled,
we do not add the "can throw" path from monitor-exit to the work list,
potentially causing some "dead code" warnings. (Not coincidentally,
"dead code" checking is now only enabled in libdvm_assert.so.)

Overall increase in bootstrap verification time is about 9%, dropping
to 6% when the new checks are disabled.

The feature is currently disabled by default. -Xverifyopt:checkmon
enables it.

Bug 2534655

Change-Id: I0eac54ce2623fb1d48cc80889fcdb4fd69de3231
675b642510ed79e8a7a3f23126dfac7679fd65b9 20-Nov-2010 Dan Bornstein <danfuzz@android.com> Say kNumDalvikInstructions when appropriate.

In particular, use it instead of just saying 256, and similarly for
255. The number of opcodes will be changing soon.

Change-Id: Icc77120c2673968dddd6b4003f717245d46e4159
41e286c0623dcb4efc6243c94ba14e7febed4b25 19-Nov-2010 Dan Bornstein <danfuzz@android.com> Get rid of the copies of the opcode table pointers.

This inclduded fixing all the accessor functions to refer to the
global ones defined in InstrUtils.[ch] instead of taking separate
"table pointer" arguments.

This did end up adding a few more truly global references to some of
the code paths, particularly when performing dex optimization, so I
went ahead and measured the time to do a cold first-boot both before
and after the change (on real hardware). The times were identical (to
one-second granularity), so I'm reasonably comfortable making this
change.

Change-Id: I604d9f7882bad4245bb11371218d13b06c3a5375
44a38f4a6a1cde0490e78b7de3b27906c6c81078 11-Nov-2010 Dan Bornstein <danfuzz@android.com> Add a new index type table for instruction decoding.

This is in prep for -- recurring theme here -- adding the new extended
opcode formats. It turns out that we can avoid a lot of duplicated code
if we determine the type of thing referred to in index-bearing instructions
inside the general instruction decoder. To do so straightforwardly, this
means adding a new opcode info table and then passing it into the decoder.
Rather than add another argument to the decoder, I defined a struct to
contain all the info tables together, and a pointer to that can get passed
in.

I simplified the setting up of the info tables, too, so all the
allocation is handled within InstrUtils, rather than being (partially)
duplicated in a couple places. The only downside is that dexdump will
construct one more table than it actually needs, but given that
construction is quick and the table is only 256 bytes (though will
soon be growing to -- gasp! -- 294 bytes), I figure it's not such a
big deal.

Most of the files that changed only had edits for how to refer to these
info tables.

Change-Id: Ia6f1cb25da6e558ac90c6dd3af6bce36b82a6b4d
470cbbbe39cffd9b1cf52562048c60be543004c6 05-Nov-2010 Andy McFadden <fadden@android.com> Move some verifier stuff around.

Once upon a time we started down the road of "just in time" register
map generation, which was intended to save flash and RAM storage by
generating register maps for methods as the GC needed them (rather than
doing them all up front, or on first load of a class). This required
a lot of duplication of code, and in the end just wasn't worth it.

This removes the (#ifdefed-out) partial implementation. Some functions
that were moved into VerifySubs to be shared with RegisterMap.c are
moved back to their previous homes.

Some temporary VERIFIER_STATS stuff is also getting checked in (#ifdefed
out).

Added an assert, tweaked a couple of comments. No changes in behavior
are expected.

Change-Id: I20b915992add9906cb3638ac9432c910443a9a47
202e3d9948a658324e339d58c70adb82cb75efcd 02-Nov-2010 Carl Shapiro <cshapiro@google.com> Remove allocation limit checking.

Change-Id: Ie9a23da2baf201c50cad5ba0d0992cec9bcace54
a8f488dd018ef306e09bc1f7c3ee36da1146265c 27-Oct-2010 Elliott Hughes <enh@google.com> Remove nio cruft.

Change-Id: Ie0dd478f499e9fa40a4af8f10b81df7144a3e813
5183a199a15451a31b32a293fcd0e96a7321b0c5 23-Oct-2010 Andy McFadden <fadden@android.com> Allow nested instruction counting.

It is traditional to store counts in variables with more than one
bit of storage.

Also, fixed some of the decorations.

Bug 2863796.

Change-Id: I167d6803e955159e35e75d1e2924754145ea1361
0477139e2b3e614c6bc20d15c43e5e9b28ae9c13 08-Oct-2010 Andy McFadden <fadden@android.com> Avoid lookup of loadClass().

Fix a TODO item: do the lookup of ClassLoader.loadClass() during init
instead of on every class load through a non-bootstrap loader.

Change-Id: Iebd145a721937bec7c09b0a7b7dbd78da8083cbe
8552f4498a720a6fcb34ebab69d6e3c34bee491d 17-Sep-2010 Andy McFadden <fadden@android.com> Use Throwable.getMessage() when logging exceptions.

The VM's internal exception logger was pulling the exception's detail
message out of a field in Throwable. This gets the wrong answer when
the exception overrides getMessage().

The VM now invokes the appropriate getMessage() method and displays
that instead. This is of particular interest in CheckJNI failure
messages.

Also, don't assert that switching from "running" to "running" is
a problem. It's a bit weird, but there's nothing wrong with it,
and there's a fair chance that the updated exception log function
will do it.

Bug 2845581

Change-Id: Id8d77221129ae7b45473e700a79a335164049362
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
c58b9ef90319c4edad93300151c088434092e9e0 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.

Change-Id: If20aa6f513896fd8b35394388eaca6214f0449a7
1f19988bf882269b7e1210e3a6514d702abd1d8b 07-Sep-2010 Elliott Hughes <enh@google.com> Stop using getEffectiveAddress.

The corresponding field is now set in the constructor, thanks to:
https://android-git.corp.google.com/g/64867

Bug: 2935622
Change-Id: Ifcd77b3e83e046eb7ba6aa2d917aa434e508f3e8
f30a7dc9a63e8bae2a738d343870a34c1a01460e 03-Sep-2010 Elliott Hughes <enh@google.com> Do less work in NewDirectByteBuffer.

There's no obvious reason to be duplicating Java code in C, and incurring
the cost of repeated crossings of the JNI boundary. Plus I want to
change/remove the Java code...

Bug: 2935622
Change-Id: I4eb25dd4b83cdbefaeed7593d3a5bbdb6cc06ced
34d192bd77a41a63a0a30c5a54b220792fab4ba3 02-Sep-2010 Elliott Hughes <enh@google.com> Update the GetDirectBufferAddress implementation.

This change is the dalvik change corresponding to the following libcore change:
https://android-git.corp.google.com/g/64326

Bug: 2935622
Change-Id: If3687e3efcc322e651c685885f6701726b5d9efc
fe1d6d586614fa51d82857e09128d6671be21d56 25-Aug-2010 Andy McFadden <fadden@android.com> Add option for specifying wall-clock in method profiling.

Normally you want to use the per-thread CPU clock rather than the wall
clock, because (a) it's more useful and (b) traceview goes a little nuts
if you don't. However, it's useful for some performance testing.

The command-line option allows you to switch modes like this:

% adb shell stop
% adb shell setprop dalvik.vm.extra-opts -Xprofile:wallclock
% adb shell start

This also changes the somewhat nebulous "clock=global" trace header line
to "clock=wall". Nothing looks at this anyway so I'm not worried
about breaking compatibility.

While I was in here, I fixed a couple of problems caused by failure to
initialize data structures that made dmtracedump crash (yay valgrind).

Bug 2943229.

(cherry-pick from dalvik-dev)

Change-Id: I2f6657f7abe02f2a17784588d922b88397639a47
ea4143449084917fb5ec25b1f3b29a1130284432 25-Aug-2010 Andy McFadden <fadden@android.com> Add option for specifying wall-clock in method profiling.

Normally you want to use the per-thread CPU clock rather than the wall
clock, because (a) it's more useful and (b) traceview goes a little nuts
if you don't. However, it's useful for some performance testing.

The command-line option allows you to switch modes like this:

% adb shell stop
% adb shell setprop dalvik.vm.extra-opts -Xprofile:wallclock
% adb shell start

This also changes the somewhat nebulous "clock=global" trace header line
to "clock=wall". Nothing looks at this anyway so I'm not worried
about breaking compatibility.

While I was in here, I fixed a couple of problems caused by failure to
initialize data structures that made dmtracedump crash (yay valgrind).

Bug 2943229.

Change-Id: Ib8884027c0a7e93044a3284802b176ea991387b5
df5347251f823e313d14a5b3fb6cd07414459945 20-Aug-2010 Elliott Hughes <enh@google.com> Minor nio cleanup.

Remove an unused cached jmethodID from "Jni.c", and change "CheckJni.c" to
use the same direct field access that "Jni.c" was already using. (I noticed
this when removing the otherwise unused PlatformAddress.toLong method from
libcore.)

Also remove the now-meaningless double check that the direct field access
works.

Change-Id: I9ef3d5a0e2fd4feafc3925004cacb46fa9f28c17
0d615c3ce5bf97ae65b9347ee77968f38620d5e8 18-Aug-2010 Andy McFadden <fadden@android.com> Always support debugging and profiling.

This eliminates the use of the WITH_DEBUGGER and WITH_PROFILER
conditional compilation flags. We've never shipped a device without
these features, and it's unlikely we ever will. They're not worth
the code clutter they cause.

As usual, since I can't test the x86-atom code I left that alone and
added an item to the TODO list.

Bug 2923442.

Change-Id: I335ebd5193bc86f7641513b1b41c0378839be1fe
fc3d31683a0120ba005f45f98dcbe1001064dafb 05-Aug-2010 Andy McFadden <fadden@android.com> More SMP fixes.

Convert some ANDROID_MEMBAR_FULL uses into equivalent atomic ops. A
couple of "bool" had to convert to "int" since we don't have atomic
ops for bools.

Replaced a local implementation of atomic inc with a call to the
atomic inc function.

Change-Id: I948b8080d743552bde014d3a6e716ed2c30ebef8
b0691476e24deae014dadbdbbceabc72d5a96ae6 06-Aug-2010 Carl Shapiro <cshapiro@google.com> Remove stale overwritefree flag.

Change-Id: If14998128245245c908b2390acfe28b82339f8bf
7a2697d327936e20ef5484f7819e2e4bf91c891f 07-Jun-2010 Ben Cheng <bccheng@android.com> Implement method inlining for getters/setters

Changes include:
1) Force the trace that ends with an invoke instruction to include
the next instruction if it is a move-result (because both need
to be turned into no-ops if callee is inlined).
2) Interpreter entry point/trace builder changes so that return
target won't automatically be considered as trace starting points
(to avoid duplicate traces that include the move result
instructions).
3) Codegen changes to handle getters/setters invoked from both
monomorphic and polymorphic callsites.
4) Extend/fix self-verification to form identical trace regions and
handle traces with inlined callees.
5) Apply touchups to the method based parsing - still not in use.

Change-Id: I116b934df01bf9ada6d5a25187510e352bccd13c
bb1e0e904b8dc159ad6ca680419b00c5938cd2b8 21-Jul-2010 Carl Shapiro <cshapiro@google.com> New string intern table without immortal bits.

The old implementation of the intern table stole the lsb to denote
that a string was "immortal" meaning that it was loaded from a dex
file. Before clients can use strings from this table they must be
aware of the bit and clear it before chasing the pointer.

The new intern table separates strings that are interned by a call to
String.intern and strings that are interned by the class loader. This
adds a small cost to each intern call. Fortunately, there is a
payback in the garbage collector as we can scan just the literal
strings during root marking and scan just the user interned strings
before sweeping to clear them. Also we no longer have to special case
walking through reference-containing locations in the intern table.

Change-Id: I1192fdcc99e1bb2c606f74f54b3056ec60b6f39b
8afa9dfe04354e5b3917e31e3e2772885f507580 07-Jul-2010 Elliott Hughes <enh@google.com> Tracing for developers of native methods.

The existing -verbose:jni is mainly useful for VM developers hacking on the JNI
implementation; this is intended to replace the ad hoc logging developers of
native methods need to write.

Use "-Xint:portable -Xjnitrace:ClassNameSubstring" on the command line. To
trace all native methods (mainly useful for testing the tracing), use
"-Xjnitrace:"; to trace just methods in java.util.regex.Matcher, use
"-Xjnitrace:Matcher" or "-Xjnitrace:Ljava/util/regex/Matcher;" or whatever.
To trace all the methods in Matcher and Pattern, you have to use something
like "-Xjnitrace:java/util/regex/". There's no facility for tracing an
individual method or group of methods because I haven't needed such a thing.

Here's a basic example:

-> Ljava/nio/charset/Charsets;.toUtf8Bytes([CII)[B (0x400474b8, 0, 5)
<- Ljava/nio/charset/Charsets;.toUtf8Bytes([CII)[B returned 0x40047548

Here's an example of a non-static native method:

-> Lorg/apache/harmony/luni/platform/OSFileSystem;.writeImpl(I[BII)J this=0x40012e78 (1, 0x400476d0, 0, 5)
<- Lorg/apache/harmony/luni/platform/OSFileSystem;.writeImpl(I[BII)J returned 5

Here's an interesting example showing another native method being called, and
an exception being thrown by a native method:

-> Ljava/lang/VMClassLoader;.loadClass(Ljava/lang/String;Z)Ljava/lang/Class; (0x400466b8, false)
-> Ljava/lang/Throwable;.nativeFillInStackTrace()Ljava/lang/Object; ()
<- Ljava/lang/Throwable;.nativeFillInStackTrace()Ljava/lang/Object; returned 0x400467c8
<- Ljava/lang/VMClassLoader;.loadClass(Ljava/lang/String;Z)Ljava/lang/Class; threw Ljava/lang/ClassNotFoundException;

(This functionality needs to be enabled at compile time. A later patch will
address that.)

Change-Id: I6da8930bd4b4f228e07b05cc59a3aea331c5cee1
4496ed9ef85e19447e697481d16842f47d265756 12-Jul-2010 Barry Hayes <bhayes@google.com> Move the biasedCardTableBase out of the non-public GcHeap structure,
and back to DvmGlobals where it can be found. Create dvmIsValidCard to
access the values hidden in the GcHeap.

This is a half-step to inlining dvmMarkCard and dvmCardFromAddr.

Change-Id: I50158915802d7f08ddadb60ca6907afd279df2a8
2a6f4846b2a9e252c914e5103270fc86cc786859 10-Jul-2010 Carl Shapiro <cshapiro@google.com> Use the new pendingNext field to thread pending references.

Presently, the garbage collector uses the queueNext field to thread
references discovered during a trace. This is unsafe as a user may
simultaniously call enqueue on a discovered reference which will alias
the queue of pending references to the queue of a reference queue.

To avoid this problem, the garbage collector uses the pendingNext
field to thread together pending references. If, during reference
processing, the garbage collector discovers that an object has been
enqueued by the user, it will short circuit referencing processing for
that object.

As part of this change, the the reference object processing routines
have been reorganized to eliminate the macrology used by the pending
reference queueing. In addition, the pending reference lists are now
circular to ensure pendingNext of a pending reference is never NULL.

Change-Id: Id855aa295dd835eacc8d5e765f4edbb869c104b7
6e5cf6021b2f3e00e18ab402f23ab93b27c6061b 22-Jun-2010 Barry Hayes <bhayes@google.com> Quicker partial collection by using card marking.

Add calls to the card marking from the write barrier routines, so that
a write to an Object marks the appropriate card. Add code in the GC to
use and rebuild the cards at a partial GC, clearing cards in the
Zygote heap which do not in fact contain references to the application
heap.

Change-Id: Ie6f29fd096e029f48085715b282b6db8a7122555
ec47e2e081dcd43dca10d5e2c6856f73e94b0460 02-Jul-2010 Carl Shapiro <cshapiro@google.com> Allow allocation during a concurrent GC.

Previously, any thread performing a GC held the heap lock for the
entire GC. If the GC performed was a concurrent GC, mutator threads
that allocate during the GC would be blocked until the GC completed.

With this change, if the GC performed is a concurrent GC, the heap
lock is released while the roots are being traced. If a mutator
thread allocates an object from available storage, the allocation
proceeds. If a mutator thread attempts to allocate an object larger
than available storage, the thread will block until the GC completes.

Change-Id: I91a04179c6f583f878b685405a6fdd16b9995017
ec805eaed940e40212e85b58b163c7649feaca56 29-Jun-2010 Carl Shapiro <cshapiro@google.com> Add a mode for concurrently marking and sweeping.

When enabled, the mutator threads will be resumed while tracing
proceeds from the roots. After the trace completes the mutator
threads are suspended, the roots are remarked, and marked objects
are scanned for updates and re-marked.

There are two limitations to this implementation. For the sake
of expediency, mutators are not permitted to allocate during the
concurrent marking phase. This will be addressed in a subsequent
change. As there is no write barrier, all objects, rather than
just those objects assigned to during the concurrent phase, are
scanned for updates. This will be addressed after a write barrier
is implemented.

Change-Id: I82dba23b58a1cf985589ed21ec0cffb5ebf48aae
697b5a942503b14fcd537d528edfc05460f144eb 23-Jun-2010 Barry Hayes <bhayes@google.com> Use the queueNext field of java.lang.ref.Reference for lists of
Reference objects in the GC, rather than the vmData field.

Change-Id: I94e23fcce5cc38f4dcdd17c07b8c30b47f2f9d0e
deeeeb264fc6f4ab7f5cb6e01b9dd76f487ff914 16-Jun-2010 Andy McFadden <fadden@android.com> Dalvik SMP update

Fix some SMP correctness issues in the VM:

- Correct AtomicCache implementation, inserting barriers where needed
and correcting existing usage.
- Emphasize that String startup isn't expected to be reentrant, and
use atomic ops to ensure that we explode if anybody tries it.
- Use 64-bit quasiatomic ops to manage the "last activity" timer in
JDWP. (Also, provide some documented but unimplemented behavior.)
- Updated the volatile operations in sun.misc.Unsafe to include
appropriate barriers.

(This does not purport to correct all SMP issues, just some of the
more obvious ones.)

Change-Id: I06957ebcf2724fe7a228b30d00194b9b4808fae0
c49db8554956f8d43eb487709bc1dccfe0496ad2 14-May-2010 Barry Hayes <bhayes@google.com> Send unlinkedClass back to hell, as requested.

The GC and Verify routines now can look inside classes better as well.

Basic ideas:
1) Pre-allocate the java.lang.Class class, and explicitly
set its clazz field to itself.

2) Put ClassObjects in status CLASS_IDX when their super and interface
array contain Dex indexes rather than object pointers. The GC
understands this, and uses that status to decide on marking those
fields or not.

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

Change-Id: I0c0edb3ebf0d5e040d6bbbf60269fab0deb70ef9
b88ec3cbb419b5eac23508dc6b73de2620d7521a 17-May-2010 Ben Cheng <bccheng@android.com> Remove the write permission for the JIT code cache when not needed

To support the feature, redesigned the predicted chaining mechanism so that the
profile count is shared globally in InterpState.

Bug: 2690371
Change-Id: Ifed427e8b1fa4f6c670f19e0761e45e2d4afdbb6
bd0472480c6e876198fe19c4ffa22350c0ce57da 13-May-2010 Bill Buzbee <buzbee@google.com> JIT: Fix for [Issue 2675245] FRF40 monkey crash in jit-cache

The JIT's chaining mechanism suffered from a narrow window that
could result in i-cache inconsistency. One of the forms of chaining
cell consisted of a two 16-bit thumb instruction sequence. If a thread were
interrupted between the execution of those two instructions *and*
another thread picked that moment to convert that cell's
chained/unchained state, then bad things happen.

This CL alters the chain/unchain model somewhat to avoid this case.
Chainable chaining cells grow by 4 bytes each, and instead of rewriting
a 32-bit cell to chain/unchain, we switch between chained and unchained
state by [re]writing the first 16-bits of the cell as either a 16-bit
Thumb unconditional branch (unchained mode) or the first half of a
32-bit Thumb branch. The 2nd 16-bits of the cell will never change once
the cell moves from its inital state - thus avoiding the possibility of it
becoming inconsistent.

This adds a trivial execution penalty on the slow path, but will add
about a kByte of memory usage to a typical process.

Change-Id: Id8b99802e11386cfbab23da6abae10e2d9fc4065
978738d2cbf9d08fa78c65762eaac3351ab76b9a 13-May-2010 Ben Cheng <bccheng@android.com> Add counters to track JIT inline cache hit rate and code cache patch counts.

Also did some WITH_JIT_TUNING cleanup.

Change-Id: I8bb2d681a06b0f2af1f976a007326825a88cea38
452efba773098c070c6bd623124e1fed21342ba4 01-May-2010 Ben Cheng <bccheng@android.com> Fix a memory ordering bug when updating the inline cache for predicted chaining.

Also collect the statistics about fast/queued/dropped IC update. Example
output:

D/dalvikvm( 86): JIT: ICPatch: 603 fast, 6 queued; 0 dropped

Bug: 2642019

Change-Id: I8cffdc9e422189bfd94bf845bcb2cff516f37077
b8fcf57f13b4d37950cfbd72a6af401941d7bdd8 17-Apr-2010 Carl Shapiro <cshapiro@google.com> Fix remaining small issues with the lock sampling.

* Eliminate the now unused lockprofsample flag. The sample percentage
has been a function of the wait time an threshold since the previous
change.

* Eliminate some trailing whitespace that creeped into the previous
change.

* Eliminate the trailing newline from the event buffer. Because the
buffer pointer was not incremented this character was not seen in
the event log anyway.

* Document the lockProfThreshold global.

Change-Id: Ia1c1fcf862d76f5631601e05e7941e5171fab097
6b4ba58ec937bfacba626112c46ebd003efbed21 10-Apr-2010 Carl Shapiro <cshapiro@google.com> Add a mechanism to long a sample of long running lock acquisitions.
f0c514ce8c64a441375af4a7e364282a3d803c45 10-Apr-2010 Carl Shapiro <cshapiro@google.com> Add a mechanism to long a sample of long running lock acquisitions.

Change-Id: Ic91c5f213bcfd72c6f630ef5102da2c6c7cc8ce4
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
2954074adc6a9793f38c0c58d03ec1dc057406eb 26-Mar-2010 Carl Shapiro <cshapiro@google.com> Reference class handling overhaul.

* Do not mark through soft-reachable referents when scanning f-
reachable objects.

* Make the SoftReference clearing policy local to better conform to
developer expecataions.

* Eliminate SCHEDULED_REFERENCE_MAGIC, a hold-over from a previous
reference management algorithm.

* Move soft, weak and phantom reference processing into their own
subroutines.

Change-Id: I992788d58f10fa08336e6ac3f0a4dbfa3fc2086f
962adba4e5db286a36bc8024f5c023bcf6f29312 17-Mar-2010 Barry Hayes <bhayes@google.com> Added flags to the vm:
-Xgc:[no]preverify
-Xgc:[no]postverify
to run verify routines over the heap pre- and post-gc.

Changed the Verify.h interface. It now publishes an entry point for
verifying a HeapBitmap, rather than the HeapBitmap callback.

Added a dvmHeapSuspendAndVerify to Heap.h for verification outside of
the GC.

Added callbacks before and after GC, under the locks, under flag control.
Processing of properties to produce flags is in a different project,
frameworks/base

Change-Id: I3f3896583fe9e7239bbe2f374d7ed4c5dd5d3e82
dca714364abf3111fc18c1ac49c2760392fb7c9b 17-Mar-2010 Ben Cheng <bccheng@android.com> Implement signature-based breakpoint for the JIT compiler.

The JIT compiler will replay itself with verbose printing if the compiled
instruction stream matches the customized signature from memory dump in the
bugreports.

Change-Id: I024082c5744903273b24a0a73468b9c0d3588ad5
86717f79d9b018f4d69cc991075fa36611f234e5 06-Mar-2010 Ben Cheng <bccheng@android.com> Collect more JIT stats in the assert build.

New stuff includes breakdown of callsite types (ie monomorphic vs polymorphic
vs monoporphic resolved to native), total time spent in JIT'ing, and average
JIT time per compilation.

Example output:
D/dalvikvm( 840): 4042 compilations using 1976 + 329108 bytes
D/dalvikvm( 840): Compiler arena uses 10 blocks (8100 bytes each)
D/dalvikvm( 840): Compiler work queue length is 0/36
D/dalvikvm( 840): size if 8192, entries used is 4137
D/dalvikvm( 840): JIT: 4137 traces, 8192 slots, 1099 chains, 40 thresh, Non-blocking
D/dalvikvm( 840): JIT: Lookups: 1128780 hits, 168564 misses; 179520 normal, 6 punt
D/dalvikvm( 840): JIT: noChainExit: 528464 IC miss, 194708 interp callsite, 0 switch overflow
D/dalvikvm( 840): JIT: Invoke: 507 mono, 988 poly, 72 native, 1038 return
D/dalvikvm( 840): JIT: Total compilation time: 2342 ms
D/dalvikvm( 840): JIT: Avg unit compilation time: 579 us
D/dalvikvm( 840): JIT: 3357 Translation chains, 97 interp stubs
D/dalvikvm( 840): dalvik.vm.jit.op = 0-2,4-5,7-8,a-c,e-16,19-1a,1c-23,26,28-29,2b-2f,31-3d,44-4b,4d-51,60,62-63,68-69,70-72,76-78,7b,81-82,84,87,89,8d-93,95-98,a1,a3,a6,a8-a9,b0-b3,b5-b6,bb-bf,c6-c8,d0,d2-d6,d8,da-e2,ee-f0,f2-fb,
D/dalvikvm( 840): Code size stats: 50666/105126 (compiled/total Dalvik), 329108 (native)
4dc2ab9f91ac94ab4d725b119141769a2e23975b 01-Mar-2010 Barry Hayes <bhayes@google.com> Move allocation of the uninitialized class object on to the object heap.
88a0f970e47dc0091d2c9965aa9bd06667e5f4b7 25-Feb-2010 Ben Cheng <bccheng@google.com> Enhance the jit profiler to print more statistics and be more verbose.

Specifically, the per-trace invocation percentage is printed now.

D/dalvikvm( 671): TRACEPROFILE 0x42b6eed8 15449863 2.13% [0(+2), 253] Ljava/nio/Buffer;position;()I
D/dalvikvm( 671): TRACEPROFILE 0x42b7b3ac 15410023 2.13% [0x4(+3), 450] Lorg/apache/xml/serializer/CharInfo;shouldMapTextChar;(I)Z
D/dalvikvm( 671): TRACEPROFILE 0x42b7b2cc 15346582 2.12% [0(+2), 449] Lorg/apache/xml/serializer/CharInfo;shouldMapTextChar;(I)Z
D/dalvikvm( 671): TRACEPROFILE 0x42b7b40c 15013650 2.07% [0xb4(+2), 1527] Lorg/apache/xml/serializer/ToStream;characters;([CII)V
D/dalvikvm( 671): TRACEPROFILE 0x42b7b4f0 14907957 2.06% [0xc7(+2), 1537] Lorg/apache/xml/serializer/ToStream;characters;([CII)V
D/dalvikvm( 671): TRACEPROFILE 0x42b7b308 14898588 2.06% [0xad(+3), 1525] Lorg/apache/xml/serializer/ToStream;characters;([CII)V
D/dalvikvm( 671): TRACEPROFILE 0x42b7b52c 14798762 2.04% [0xc4(+2), 1523] Lorg/apache/xml/serializer/ToStream;characters;([CII)V
D/dalvikvm( 671): TRACEPROFILE 0x42b7b570 14763770 2.04% [0xf3(+2), 1577] Lorg/apache/xml/serializer/ToStream;characters;([CII)V

And the top 10 traces will be recompiled in verbose mode to facilitate code
quality analysis.
5cbb23083f53e94204e802930b0923aeb3fb07c8 02-Feb-2010 Barry Hayes <bhayes@google.com> Add the "-Xgc:[no]overwritefree" flags. When set, the GC will clobber the
memory of freed objects.
c5285b33048808a725498556f3f5a366588f4b80 15-Feb-2010 Ben Cheng <bccheng@android.com> Detect system-wide safe mode and configure the VM accordingly.

Use pthread_cond_wait instead of timed wait for the system_server process to
wait on the go-ahead JIT signal. If the phone is booted under system-wide safe
mode, such signal will never come so all VM instances (including the system
server) will run in the interpreter-only mode.

Bug: 2267590
f30acbb249b137b049500f136d2bb273c0b6221a 15-Feb-2010 Ben Cheng <bccheng@android.com> Detect system-wide safe mode and configure the VM accordingly.

Use pthread_cond_wait instead of timed wait for the system_server process to
wait on the go-ahead JIT signal. If the phone is booted under system-wide safe
mode, such signal will never come so all VM instances (including the system
server) will run in the interpreter-only mode.

Bug: 2267590
94e79ebaa340e8ba3bb4d13f5e908fef6d9d5eed 05-Feb-2010 Ben Cheng <bccheng@android.com> Enable JIT parameters to be initialized in an architecture dependent way.

The search for optimial value is still ongoing. The current settings are:

v5 v7
JIT profile table 512 2048
JIT code cache 512K 1M
JIT threshold 200 40
fccb31dd58e5cb9f7a3f6e128d481f0ff35a51f0 05-Feb-2010 Bill Buzbee <buzbee@google.com> Jit: Start the Jit when framework signals on first screen draw

Cleanup of delayed start - introduce dvmRelativeCondWait in Sync.c.
Additionally, support for deadman timer to start Jit when no screen draws
happen, and to start immediately when running stand-alone.

Fixed bug in assert variant of libdvm - recent MONITOR change had neglected
to add a new type of exit to the exit stats.
7b133ef7c84e68c3c4042176d830ea5b52e84139 05-Feb-2010 Ben Cheng <bccheng@android.com> Enable JIT parameters to be initialized in an architecture dependent way.

The search for optimial value is still ongoing. The current settings are:

v5 v7
JIT profile table 512 2048
JIT code cache 512K 1M
JIT threshold 200 40
eb695c6f814f6b0bdbba0e837555d3fe5ad23104 05-Feb-2010 Bill Buzbee <buzbee@google.com> Jit: Start the Jit when framework signals on first screen draw

Cleanup of delayed start - introduce dvmRelativeCondWait in Sync.c.
Additionally, support for deadman timer to start Jit when no screen draws
happen, and to start immediately when running stand-alone.

Fixed bug in assert variant of libdvm - recent MONITOR change had neglected
to add a new type of exit to the exit stats.
c3b92b26df6416d3179e865adccb283ee4170ab1 27-Jan-2010 Ben Cheng <bccheng@android.com> Fix performance issues related to chaining and unchaining.

1) Patching requests for predicted chaining cells (used by virtual/interface
methods) are now batched in a queue and processed when the VM is paused for GC.

2) When the code cache is full the reset operation is also conducted at the
end of GC pauses so this totally eliminates the need for the compiler thread
to issue suspend-all requests. This is a very rare event and when happening it
takes less than 5ms to finish.

3) Change the initial value of the branch in a predicted chaining cell from 0
(ie lsl r0, r0, #0) to 0xe7fe (ie branch to self) so that initializing a
predicted chaining cell doesn't need to suspend all threads. Together with 1)
seeing 20% speedup on some benchmarks.

4) Add TestCompability.c where defining "TEST_VM_IN_ECLAIR := true" in
buildspec.mk will activate dummy symbols needed to run libdvm.so in older
releases.

Bug: 2397689
Bug: 2396513
Bug: 2331313
4fbba1f95b3e27bdc5f5572bb0420b5f928aa54e 03-Feb-2010 Andy McFadden <fadden@android.com> Fix stack overflow edge case.

When a stack overflows, Dalvik allows the stack to expand into a
"reserved" area, so that it has enough room to create and initialize the
StackOverflowError object. While the stack is expanded we also do the
search for an appropriate "catch" block, which may require resolving
some exception classes.

As it happens, things go badly when the "catch" resolution throws an
exception. The VM tries to shrink the stack back down after the second
exception is finished, rather than waiting for the initial SOE to
finish. Since we still have some additional frames on the stack, we're
still occupying the "reserved" area, and the VM aborts when it detects
the situation.

This changes the stack cleanup to wait until the SOE is being dealt
with.

For bug 2398031.
6999d84e2c55dc4a46a6c311b55bd5811336d9c4 27-Jan-2010 Ben Cheng <bccheng@android.com> Fix performance issues related to chaining and unchaining.

1) Patching requests for predicted chaining cells (used by virtual/interface
methods) are now batched in a queue and processed when the VM is paused for GC.

2) When the code cache is full the reset operation is also conducted at the
end of GC pauses so this totally eliminates the need for the compiler thread
to issue suspend-all requests. This is a very rare event and when happening it
takes less than 5ms to finish.

3) Change the initial value of the branch in a predicted chaining cell from 0
(ie lsl r0, r0, #0) to 0xe7fe (ie branch to self) so that initializing a
predicted chaining cell doesn't need to suspend all threads. Together with 1)
seeing 20% speedup on some benchmarks.

4) Add TestCompability.c where defining "TEST_VM_IN_ECLAIR := true" in
buildspec.mk will activate dummy symbols needed to run libdvm.so in older
releases.

Bug: 2397689
Bug: 2396513
Bug: 2331313
43eb5015ca8bc0c859100b659d9c12934011a42e 02-Feb-2010 Andy McFadden <fadden@android.com> Reduce VM shutdown verbosity.

Adds -verbose:shutdown flag, defaulted to "false". Cuts out most of the
log noise associated with shell commands.
06bb83906737fec543c86ab36f450cc62066b58a 01-Feb-2010 Bill Buzbee <buzbee@google.com> Jit: MethodTrace + Jit fix

Add checks for debug & trace mode to avoid re-entering Jit'd code.
This is the conversative solution - we'll eventually want the Jit
to integrate support for tracing and debug into Jit'd code.
7a0bcd0de6c4da6499a088a18d1750e51204c2a6 23-Jan-2010 Ben Cheng <bccheng@android.com> Tighten the safe points for code cache resets to happen.

Add a new flag in the Thread struct to track the whereabout of the top frame
in each Java thread. It is not safe to blow away the code cache if any thread
is in the JIT'ed land.
33672456e19bff9913b4a3459e6b8472f4c26c84 12-Jan-2010 Ben Cheng <bccheng@google.com> Integrate call-graph information into JIT method blacklist.

The new flag is -Xjitcheckcg which will crawl the stack frame of the
translation requesting thread.

Bug: 2368995
6930a11fd75071fa2f04fcfe11c322e2518cf503 22-Dec-2009 Barry Hayes <bhayes@google.com> The FANCY_REFERENCE_SUBCLASS code is based on a misconception of what the VM
is permitted to do, and it would be buggy to ever turn it on.
b1d8044ee3a7503b94eb54459f3077d7200cd675 17-Dec-2009 Bill Buzbee <buzbee@google.com> Jit: Briefly delay start of Jit'ng in attempt to avoid compiling init code

Via subjective manual side-by-side testing of jit vs. no-jit, the mterp
version looked like it tended to reach first screen on application launch
very slightly before the Jit version. This change adds an old and
commonly-used Jit trick to delay jit startup in an attempt to avoid wasting
effort compiling initialization code.

Also, deletes some code no longer in use.
96516932f1557d8f48a8b2dbbb885af01a11ef6e 29-Oct-2009 Andy McFadden <fadden@android.com> Change the way breakpoints work.

This replaces the breakpoint mechanism with a more efficient approach.
We now insert breakpoint instructions into the bytecode stream instead of
maintaining a table. This requires mapping DEX files as private instead
of shared, which allows copy-on-write to work. mprotect() is used to
guard the pages against inadvertent writes.

Unused opcode EC is now OP_BREAKPOINT. It's not recognized by dexdump or
any interpreter except portdbg, but it can be encountered by the bytecode
verifier (the debugger can request breakpoints in unverified code).
Breakpoint changes are blocked while the verifier runs to avoid races.

This eliminates method->debugBreakpointCount, which is no longer needed.
(Also, it clashed with LinearAlloc's read-only mode.)

The deferred verification error mechanism was using a code-copying
approach to modify the bytecode stream. That has been changed to use
the same copy-on-write modification mechanism.

Also, normalized all PAGE_SIZE/PAGESIZE references to a single
SYSTEM_PAGE_SIZE define.

Simple Fibonacci computation test times (opal-eng):
JIT, no debugger: 10.6ms
Fast interp, no debugger: 36ms
Portable interp, no debugger: 43.8ms

ORIG debug interp, no breakpoints set: 458ms
ORIG debug interp, breakpoint set nearby: 697ms

NEW debug interp, no breakpoints set: 341ms
NEW debug interp, breakpoints set nearby: 341ms

Where "nearby" means there's a breakpoint in the method doing the
computation that isn't actually hit -- the VM had an optimization where
it flagged methods with breakpoints and skipped some of the processing
when possible.

The bottom line is that code should run noticeably faster while a
debugger is attached.
72e93344b4d1ffc71e9c832ec23de0657e5b04a5 13-Nov-2009 Jean-Baptiste Queru <jbq@google.com> eclair snapshot
9a8c75adb2abf551d06dbf757bff558c1feded08 08-Nov-2009 Bill Buzbee <buzbee@google.com> Introduce "just interpret" chainable pseudo-translation.

This is the first step towards enabling translation & self-cosim stress modes.
When trace selection begins, the trace head address is pinned and
remains in a limbo state until the translation is complete. Previously,
if the trace selected aborted for any reason, the trace head would remain
forever in limbo. This was not a correctness problem, but caused some
small performance anomolies and made life more difficult for self-cosimulation
mode.

This CL introduces a pseudo-translation that simply routes control to
the interpreter. When we detect that a trace selection attempt has
failed, the trace head is associated with this fully-chainable
pseudo-translation. This also has the benefit for self-cosimulation that
we are guaranteed forward progress.
6c10a977ec892c26c8e306356491833bbb073d40 29-Oct-2009 Ben Cheng <bccheng@google.com> Implement chaining up to the first 64 cases in a switch statement.
b18992f6e3c168742bc7c7d19d662d7719aef5dd 25-Sep-2009 Andy McFadden <fadden@android.com> Implement JNI "weak global" references.

The VM now supports the NewWeakGlobalRef and DeleteWeakGlobalRef calls,
which create a kind of weak reference that's directly visible to native
code. While the JNI spec says that these can be used directly, the only
safe way to use them is to convert them to a strong local or global
reference first, so this is enforced.

The net result is very similar to manually creating a global reference to
a WeakReference object and manipulating it with method calls from native
code, but the JNI calls are faster and more convenient.
dcf3e5d43a1831a166f70cb9e0694cd4b0b356b0 11-Sep-2009 Ben Cheng <bccheng@google.com> Model resource usage for each Thumb/Thumb2 instrution.

This is an mid-point checkin to avoid future merge nightmare for the register
allocator work.
894dd4668c4b5c5f4259fd2d84ed4deaa5611efd 09-Sep-2009 San Mehat <san@google.com> vm: Add support for using scheduler policies instead of cgroups

Signed-off-by: San Mehat <san@google.com>
bcdc1ded149faa8dec51778db4047cae0862027f 22-Aug-2009 Ben Cheng <bccheng@google.com> Updated expected outputs in dalvik benchmarks. Improved debugging output and added spin loop on detection of divergence in self verification tool.
d5ab726b65d7271be261864c7e224fb90bfe06e0 25-Aug-2009 Andy McFadden <fadden@android.com> Another round of scary indirect ref changes.

This change adds a not-really-working implementation to Jni.c, with
various changes #ifdefed throughout the code. The ifdef is currently
disabled, so the old behavior should continue. Eventually the old
version will be stripped out and the ifdefs removed.

This renames the stack's "localRefTop" field, which nudged a bunch of
code. The name wasn't really right before (it's the *bottom* of the
local references), and it's even less right now. This and one other
mterp-visible constant were changed, which caused some ripples through
mterp and the JIT, but the ifdeffing was limited to one in
asm-constants.h (and the constant is the same both ways, so toggling the
ifdef won't require rebuilding asm sources).

Some comments and arg names in ReferenceTable were updated for the
correct orientation of bottom vs. top.

Some adjustments were made to the JNI code, e.g. dvmCallMethod now needs
to understand if it needs to convert reference arguments from
local/global refs to pointers (it's called from various places
throughout the VM).
c26bb63b50c7a855d25b396b1bf23a3aa6929b48 21-Aug-2009 Andy McFadden <fadden@android.com> Move array pinning out of global references table.

We have to pin primitive arrays for certain JNI operations (it's that or
return a copy of the contents). We don't move objects around in the
virtual heap, so simply creating a global reference is enough to ensure
the correct behavior of the calls.

The global reference implementation is changing in a way that makes
this approach inconvenient, so we now have a separate table for pinned
primitive arrays.

As a bonus, if GREF tracking is enabled, we will scan through the table
when a pin entry is added. If there are 10 or more entries for the same
array, a complaint is logged. This should allow us to find mismatched
Get/Release sequences much more easily (before you had to wait until the
global reference table exploded).

We currently scan pin table entries at the same time as the JNI global
references, so they'll still show up in hprof dumps as such. (Could
also add a new Android-specific hprof root category, but that seems like
more trouble than it's worth.)
d51370ff814e88b63baa3b1f5300b6560330c12d 06-Aug-2009 Andy McFadden <fadden@android.com> Switch to <stdbool.h> in the VM.

We were using an enum that made the compiler unhappy on MacOS X. This
switches us to using <stdbool.h> when it's available.

The size of a "bool" is either sizeof(_Bool) or sizeof(enum bool), and
the assembly sources dislike ambiguity, so this also changes
gDvm.debuggerActive to always be a single byte. The ARM and x86 code
was already assuming that -- held over from when enums were
variable-width, and never fixed because we get the right answer on
little-endian platforms -- so it doesn't look like we need to change
anything in mterp.
8e696dc0271299433cb3297e7aafc7bd0ee1b2b7 25-Jul-2009 Andy McFadden <fadden@android.com> JNI direct buffer function speedup, part 3.

This caches the effective address in a new field in the base Buffer
object. The first time something calls through one of the various
getEffectiveAddress calls, the value is set. (This seemed easier than
chasing down the constructors and factories, and also prevents bit rot
on the "slow path" in the VM.)
8e5c78470229fd2f5474574081eaa4a2286aafea 24-Jul-2009 Andy McFadden <fadden@android.com> JNI direct buffer function speedup, part 2.

This converts the three direct buffer functions from JNI to internal VM
calls. As a bonus, we grab PlatformAddress.osaddr directly instead of
retrieving it with PlatformAddress.toLong().

We're still calling through getEffectiveAddress(), which is where most
of the complexity lies.

Nudged a couple of comments.
5f612b82bbc2fcfb13865acd3c3835febab23466 23-Jul-2009 Andy McFadden <fadden@android.com> JNI direct buffer function speedup, part 1.

This is a fairly straightforward improvement to GetDirectBufferAddress,
caching classes and methodIDs instead of looking them up on every call.
This is the best we can do without making the function more vulnerable
to internal changes to Harmony's NIO implementation.

It looks like we need to take this farther, but this way we have a
relatively fast and relatively safe version to fall back on.

For internal bug 1943379.
7fc3ce8f0223a90006ad2c431a43b0bc841ee3c2 15-Jul-2009 Andy McFadden <fadden@android.com> Throw a pre-fabricated NoClassDefFoundError.

When a class loader tries to load a class, it first asks its parent to
look for it. This continues up the chain until the bootstrap class loader
is reached. If the class can't be found, the bootstrap loader throws a
NoClassDefFoundError. As a result, we're throwing at least one exception
for every class we load that doesn't come from the bootstrap path.

This change creates a "stock" NoClassDefFoundError exception with a trivial
stack trace and throws that instead, saving the overhead of creating and
initializing the exception object.

I think the only way that anyone will see this is if they try to
load a class directly from the bootstrap loader, in which case the
ClassNotFoundException will show the canned NCDFE as the cause. I
don't think any useful diagnostic information is being lost.
38329f5678fd7a4879528b02a0ab60322d38a897 07-Jul-2009 Ben Cheng <bccheng@android.com> Improved method invocation performance: 1.5x for virtual and 2.8x for interface.

- Implemented predicted chaining for invoke virtual and interface.
- Eliminated a little bit of fat for invoke native.
- Added 078-polymorphic-virtual for stress tests.
d5a9659f74fc3ac23cecf1db70886b919bf98ff9 18-Jun-2009 Andy McFadden <fadden@android.com> Reduce VM aborts during high CPU stress.

(This was cherry-picked from master 2aa43610 for internal bug 1952616.)

The VM has some timeouts that are meant to kill the current process if
something gets stuck (e.g. a thread grabs a lock and then manages to die
while the rest of the process continues on). These were tripping a
little too easily during some high-load situations.

This changes the order of operations so that we now unlock the "thread
suspend" lock before sending a wakeup broadcast to the condition variable
that threads sleep on. This should make it less likely for a thread to
be running for an extended period while the lock is held. (Relates to
internal bug 1664687.)

This also wraps a couple of things (pthread_create, dlopen) with a state
change to VMWAIT. During high load situations these can take a while to
complete, and we would (with the K-Means Visualizer load generator
running) very occasionally time out.

Augmented the debug output in a couple of minor ways. Updated comments.
8b258bfd8562edf1306ea6a5642595186f1f3f36 25-Jun-2009 Ben Cheng <bccheng@android.com> Collect per-method code size statistics to show compiled vs overall Dalvik portion and total native code size.
6e963e1cfbaeac377fed3ba8d5715c1dccfc1a57 18-Jun-2009 Bill Buzbee <buzbee@google.com> Trace profiling support for the jit
2aa43610c391868eb6ef80bf3b1f947776defcca 18-Jun-2009 Andy McFadden <fadden@android.com> Reduce VM aborts during high CPU stress.

The VM has some timeouts that are meant to kill the current process if
something gets stuck (e.g. a thread grabs a lock and then manages to die
while the rest of the process continues on). These were tripping a
little too easily during some high-load situations.

This changes the order of operations so that we now unlock the "thread
suspend" lock before sending a wakeup broadcast to the condition variable
that threads sleep on. This should make it less likely for a thread to
be running for an extended period while the lock is held. (Relates to
internal bug 1664687.)

This also wraps a couple of things (pthread_create, dlopen) with a state
change to VMWAIT. During high load situations these can take a while to
complete, and we would (with the K-Means Visualizer load generator
running) very occasionally time out.

Augmented the debug output in a couple of minor ways. Updated comments.
2717622484eb0f7ad537275f7260b2f93324eda2 09-Jun-2009 Bill Buzbee <buzbee@google.com> Makes the primary Jit table growable. Also includes a change suggested earlier by Dan to use a pre-defined mask in the hash function. Reduce the default JitTable size from 2048 entries to 512 entries.
Update per Ben's comments.
1efc9c5e4c5c4c2fccde18e5771c68d064c33bd3 09-Jun-2009 Ben Cheng <bccheng@android.com> Fix two codegen problems: out-of-bound PC-relative addresses and missing branch to the chaining cell at the end of non-branch-ending basic blocks.
46cd5b63c29d3284a9ff3e0d0711fb136f409313 06-Jun-2009 Bill Buzbee <buzbee@google.com> Support for stopping all threads in a Jit environment.
ba4fc8bfc1bccae048403bd1cea3b869dca61dd7 01-Jun-2009 Ben Cheng <bccheng@android.com> Initial port of the Dalvik JIT enging to the internal repository.
Fixed files with trailing spaces.
Addressed review comments from Dan.
Addressed review comments from fadden.
Addressed review comments from Dan x 2.
Addressed review comments from Dan x 3.
2c98747b403970ef4b3352e271633f93935b9825 06-Apr-2009 Barry Hayes <bhayes@google.com> Improve zygote heap sharing.

[ This is bhayes change 9488 in external "master" ]

Lots of ClassObject structures are unshared [and thus make whole pages
unshared]. A big contributor to this is the initializing class loader
logic, which has two writable words in a ClassObject and does indeed
seem to write them a lot.

Class which are created "early" have a low serial number and are
probably being created by the zygote, and would benefit from better
sharing. This change move the two words for classes with a low serial
number to a global, making the two words in those ClassObjects unused,
and thus more likely to be shared across apps.

Measured increase in sharing is c 100K per app, at a cost of c 32K
increase in unshared globals.

This might be better as a Set<Pair<Class,ClassLoader>> or
something. Many ClassObjects have zero loaders, and the typical count
seems to be very small. It should be possible to remove the two words
from the ClassObject and at the same time have a smaller global data
structure.

Respond to reviewer's comments.
Moved the "external" InitiatingLoaderList[] from gDvm to allocated storage.
Made the warning for the "const" go away.
Remove "vm/Init.c" from the commit
Revert Globals.h to not contain ZYGOTE_CLASS_CUTOFF
Use calloc rather than malloc/clear
9b0e83401b0ade80e1943c2cc16ef5ec9b46eef5 06-Apr-2009 Barry Hayes <bhayes@google.com> Improve zygote heap sharing.

Lots of ClassObject structures are unshared [and thus make whole pages
unshared]. A big contributor to this is the initializing class loader
logic, which has two writable words in a ClassObject and does indeed
seem to write them a lot.

Class which are created "early" have a low serial number and are
probably being created by the zygote, and would benefit from better
sharing. This change move the two words for classes with a low serial
number to a global, making the two words in those ClassObjects unused,
and thus more likely to be shared across apps.

Measured increase in sharing is c 100K per app, at a cost of c 32K
increase in unshared globals.

This might be better as a Set<Pair<Class,ClassLoader>> or
something. Many ClassObjects have zero loaders, and the typical count
seems to be very small. It should be possible to remove the two words
from the ClassObject and at the same time have a smaller global data
structure.

Respond to reviewer's comments.
Moved the "external" InitiatingLoaderList[] from gDvm to allocated storage.
Made the warning for the "const" go away.
Remove "vm/Init.c" from the commit
Revert Globals.h to not contain ZYGOTE_CLASS_CUTOFF
Use calloc rather than malloc/clear
e6e8c96dc62781d214554b8579363f2d122855c1 25-Mar-2009 Andy McFadden <> Automated import from //branches/donutburger/...@140653,140653
3b5fe2883109da9470a8baf20e6700aba0d78193 20-Mar-2009 The Android Open Source Project <initial-contribution@android.com> auto import from //branches/cupcake_rel/...@141571
99409883d9c4c0ffb49b070ce307bb33a9dfe9f1 19-Mar-2009 The Android Open Source Project <initial-contribution@android.com> auto import //branches/master/...@140412
f6c387128427e121477c1b32ad35cdcaa5101ba3 04-Mar-2009 The Android Open Source Project <initial-contribution@android.com> auto import from //depot/cupcake/@135843
f72d5de56a522ac3be03873bdde26f23a5eeeb3c 04-Mar-2009 The Android Open Source Project <initial-contribution@android.com> auto import from //depot/cupcake/@135843
5d709784bbf5001012d7f25172927d46f6c1abe1 11-Feb-2009 The Android Open Source Project <initial-contribution@android.com> auto import from //branches/cupcake/...@130745
bcd637a94f10b49d18b87a74a015f9d3453ed77a 22-Jan-2009 The Android Open Source Project <initial-contribution@android.com> auto import from //branches/cupcake/...@127436
cc05ad238516f1303687aba4a978e24e57c0c07a 10-Jan-2009 The Android Open Source Project <initial-contribution@android.com> auto import from //branches/cupcake/...@125939
89c1feb0a69a7707b271086e749975b3f7acacf7 18-Dec-2008 The Android Open Source Project <initial-contribution@android.com> Code drop from //branches/cupcake/...@124589
2ad60cfc28e14ee8f0bb038720836a4696c478ad 21-Oct-2008 The Android Open Source Project <initial-contribution@android.com> Initial Contribution