History log of /dalvik/vm/oo/
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
95b0899ad3412596baa600b22ea2ecd7dd1acc43 04-Apr-2012 Evgeniy Stepanov <eugenis@google.com> Support building Dalvik with AddressSanitizer.

Change-Id: I007c5080081a4a66b39fa6b539afd8f00fd8ce0f
bject.h
09153feb3c522f578a581d8b9d9d29aa00df20fc 18-Jan-2012 Jean-Baptiste Queru <jbq@google.com> am 9e8b05e4: am a669206d: Merge "cleanup redundant interfaces from iftable to avoid excessive LinearAlloc use"

* commit '9e8b05e4529c4f9bf66d3db21ae79ccbbe97a1dc':
cleanup redundant interfaces from iftable to avoid excessive LinearAlloc use
d8a81cfd749c629de84db32eee3703cc5e0dc28f 13-Jan-2012 Johannes Rudolph <johannes.rudolph@gmail.com> cleanup redundant interfaces from iftable to avoid excessive LinearAlloc use

In deep interface hierarchies super-interfaces are recursively concatenated
to create the iftable. There was no checking for duplicated entries so that the
iftable could get pretty large with just a few layers of interfaces up to the
point where the LinearAlloc was exceeded completely.

This change scans the iftable linearly for existing entries before it adds another
one.

Issue: http://code.google.com/p/android/issues/detail?id=22586
Change-Id: Idb4a13ca7a52f390661629cf2539930242526876
Signed-off-by: Johannes Rudolph <johannes.rudolph@gmail.com>
lass.cpp
c1a4ab9c313d8a3d12007f2dbef7b5a6fa4ac2ef 06-Jan-2012 Steve Block <steveblock@google.com> Rename (IF_)LOGE(_IF) to (IF_)ALOGE(_IF) DO NOT MERGE

See https://android-git.corp.google.com/g/#/c/157220

Also fix an occurrence of LOGW missed in an earlier change.

Bug: 5449033
Change-Id: I2e3b23839e6dcd09015d6402280e9300c75e3406
rray.cpp
lass.cpp
e8e1ddccd616e8226b7cc1e4e9fdb327429249e8 06-Jan-2012 Steve Block <steveblock@google.com> Rename (IF_)LOGW(_IF) to (IF_)ALOGW(_IF) DO NOT MERGE

See https://android-git.corp.google.com/g/157065

Bug: 5449033
Change-Id: Ia5d301248024df26c2a29dabdfe738e39ec87c82
rray.cpp
lass.cpp
bject.cpp
esolve.cpp
4308417beec548c2b2c06ecec4f7f4a965b09fb2 04-Jan-2012 Steve Block <steveblock@google.com> Rename (IF_)LOGI(_IF) to (IF_)ALOGI(_IF) DO NOT MERGE

See https://android-git.corp.google.com/g/156801

Bug: 5449033
Change-Id: Ic558031c75b3702d90eb78bd730501ae5d3c077b
ccessCheck.cpp
lass.cpp
062bf509a77fce9dfcb7e7b2e401cf2a124d83d5 20-Dec-2011 Steve Block <steveblock@google.com> Rename (IF_)LOGD(_IF) to (IF_)ALOGD(_IF) DO NOT MERGE

See https://android-git.corp.google.com/g/156016

Bug: 5449033
Change-Id: Ic663376d1ad6a6cb14bf81405ad9afd247cf2f60
lass.cpp
bject.cpp
92c1f6f1b4249e4e379452ee7b49f027052bf4ce 20-Oct-2011 Steve Block <steveblock@google.com> Rename (IF_)LOGV(_IF) to (IF_)ALOGV(_IF) DO NOT MERGE

See https://android-git.corp.google.com/g/#/c/143865

Bug: 5449033
Change-Id: I8bd96961e369a08e86ff78b82d90f20f42787eb1
rray.cpp
lass.cpp
1663a6c12fdf4732d7ea0a0406af6085b3c408e4 12-Oct-2011 Steve Block <steveblock@google.com> Rename (IF_)LOG() to (IF_)ALOG() DO NOT MERGE

See https://android-git.corp.google.com/g/#/c/141576

Bug: 5449033
Change-Id: Ie3bc0d5436218ea05f98cb0373ecf5924f78db05
lass.cpp
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
lass.cpp
4185972e211b0c84b9fe7d90c56b28cc15e474fa 27-Sep-2011 buzbee <buzbee@google.com> Fix memory barriers (Issue 3338450)

Add extra memory barrier on volatile stores.

Change-Id: Id4a4750cdfc910eda2f0b44ead0af2a569b5735e
bjectInlines.h
a6e94ff55517438569d207e3ed552c8c127bcac9 30-Jun-2011 Elliott Hughes <enh@google.com> Fix native method logging to show local references rather than direct pointers.

This is necessary (but not sufficient) for debugging third-party JNI bugs.
It's the second half of the logging story, but still doesn't address the
question of "how does the developer turn on the logging?".

This removes the variant JNI bridges at the cost of adding a couple of
booleans to struct Method. Performance is about the same, except synchronized
native methods are quite a bit faster after the change.

Before:
benchmark ns linear runtime
_emptyJniMethod0 333 ==========
_emptyJniMethod6 367 ===========
_emptyJniMethod6L 921 ==============================
_emptyJniStaticMethod0 259 ========
_emptyJniStaticMethod6 287 =========
_emptyJniStaticMethod6L 873 ============================
_emptyJniStaticSynchronizedMethod0 404 =============
_emptyJniSynchronizedMethod0 452 ==============

After:
benchmark ns linear runtime
_emptyJniMethod0 344 ==========
_emptyJniMethod6 348 ==========
_emptyJniMethod6L 969 ==============================
_emptyJniStaticMethod0 265 ========
_emptyJniStaticMethod6 293 =========
_emptyJniStaticMethod6L 968 =============================
_emptyJniStaticSynchronizedMethod0 265 ========
_emptyJniSynchronizedMethod0 323 ==========

A better optimization for the case where there are reference arguments
would be to keep a list of argument indexes in the struct Method, so we
could iterate directly over those arguments that need converting to
local references. That would also let us do something about the overhead
of repeatedly looking up which local reference table and cookie to use.

But now is not the time.

Change-Id: Ie32daca1b31be057a44f1ed4b5d28d1634380e1d
bject.h
1a87dec67db6c5a37442c1338d9b8c626c95a545 23-Jun-2011 Elliott Hughes <enh@google.com> Fix native methods that weren't registered via RegisterNatives.

Cherry pick of a64af4aabf261d34eac8b5a9d92992ee70051829.

Change-Id: I43df4e33e39ccaf9e26c842f22da3391cfa17e2b
bject.h
d8a3f9fa1951e552f5f65c2914689083cc0c46c2 18-Jun-2011 Elliott Hughes <enh@google.com> Make some of the StringObject functions member functions.

Change-Id: I72ed13c16f0cb24498772c453ba268a0f65f208a
bject.h
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
ccessCheck.h
rray.h
lass.h
bject.h
bjectInlines.h
esolve.h
ypeCheck.h
65852761e37f938409b85a901a0fb1d98d361023 14-Jun-2011 Elliott Hughes <enh@google.com> Allow native methods to declare they don't need a JNIEnv*.

Bug: 3069458
Change-Id: Ic9a6c562c5abf9607dd4c8a71b0d1e389e6d340b
bject.h
b08e2b6017770e887f6072c1520b2d7f2ef6916c 07-Jun-2011 Elliott Hughes <enh@google.com> Switch dvmHumanReadableDescriptor over to std::string.

(Prep work before making a change to stack dumps.)

Change-Id: I0af49b920f450fd2611e4b96e717a637483122d6
rray.cpp
6f9edbe7d3a83f7741c4d56f9f5be1414ecabc9f 02-Jun-2011 Dan Bornstein <danfuzz@android.com> Add some error checking and clean out some cruft.

Error checking #1: When a cached dex file can't be created, do extra
analysis to figure out (and report) why.

Error checking #2: When opening classpath entries, become sensitive
to the file extension, only trying to open files with the right
extensions and complaining explicitly if it's unrecognized.

Cruft cleaning: We've never supported finding class files in directory
hierarchies in Dalvik. Fix some related comments and clean out some
code that tried (in vain) to implement a piece of that.

Bug: 4523201
Change-Id: I05b7a8570f147955cd62229fca72b50d36703752
lass.cpp
lass.h
6f3c21fb026d9489e5046416bcd5a84fa8e4615b 26-May-2011 Dan Bornstein <danfuzz@android.com> More LOG newline cleanup.

This changes all the places I could find where the log string was on the
line after its LOG call.

Change-Id: Iac6a9fcc64f46631fb093824ab60237dce1a5241
lass.cpp
esolve.cpp
291c84f60853d30e1c0d79dd08c5e5164f588e26 26-May-2011 Dan Bornstein <danfuzz@android.com> Prefer printf format "%#x" over "0x%x".

I exist to serve.

Change-Id: I8e2880b20eefd466da8515d5b6b0c5cb75d56169
ccessCheck.cpp
60fc806b679a3655c228b4093058c59941a49cfe 26-May-2011 Dan Bornstein <danfuzz@android.com> Further conservation of newlines.

Friends don't let friends end LOG() strings with newlines.

Change-Id: I5a18c766c90c4ab5f03caa6acd601d34d91beb00
ccessCheck.cpp
rray.cpp
lass.cpp
bject.cpp
esolve.cpp
d8d251136b7c63e1006da35197fc1962e56ae473 14-May-2011 Elliott Hughes <enh@google.com> Dump the pending exception before aborting in FindClass.

CheckJNI already does this, but since we're about to abort, we should do this
even without CheckJNI.

Bug: http://code.google.com/p/android/issues/detail?id=16758
Change-Id: Ief5e8d836ad16d342eead8db9e44ae5af7983c3a
lass.cpp
9c6f0a6a36fcce4a55e3764db45c6c7cced077a5 10-May-2011 Carl Shapiro <cshapiro@google.com> Fixes to allow the debug VM configuration to build.

Change-Id: Ifbe6acf84beb75014303152d20153072e7e50c55
bject.h
a7323974309c3b81cfe342db635d0bf30f36ff62 07-May-2011 Carl Shapiro <cshapiro@google.com> Establish a subclass relationships among the field types.

Change-Id: Id349b359489bb6b1bbb4ab78d29d85c0e6b33799
lass.cpp
bject.cpp
bject.h
bjectInlines.h
esolve.cpp
dc2a1881fe75a8dd961fb24509621c7c97694c9a 06-May-2011 Carl Shapiro <cshapiro@google.com> Establish a subclass relationship between ClassObject and Object.

Change-Id: I9fb5d33f23ec7aeb2b9a3908d4125b34be0599ae
rray.cpp
lass.cpp
bject.h
dc9e44cc0af797679822484d88ef76bff15ffc98 06-May-2011 Carl Shapiro <cshapiro@google.com> Make interned strings non-movable.

At present objects referenced from dex files must have stable reference
values. With this change, only non-moving strings are interned. If a
user interns a movable string a non-moving copy is made and the copy is
added to the intern table.

As part of this change, the internal string hash code access routine will
update the hash code slot of a string object. In addition, StringObject
has been made a subclass of Object eliminating various down-casts that
would otherwise be explicitly required.

Change-Id: I6b015b972aac44948470c0034ad17e5eef456aeb
bject.h
a62c3a0ab3fcdde37f47d16e9699a935ae7a8e88 04-May-2011 Carl Shapiro <cshapiro@google.com> Establish a subclass relationship between ArrayObject and Object.

Change-Id: I9f9fe52bd4ceebb6dde48251a89190ba6bb00ce4
rray.cpp
rray.h
bject.h
7cc095f8e3ec52ba94d91e1d327354f61236496a 03-May-2011 Carl Shapiro <cshapiro@google.com> Establish a subclass relationship between DataObject and Object.

Change-Id: Ifd0e364f7789d9e13f769f8d6a65c3c573915fd3
lass.cpp
bject.h
92a3b69286a757afff76402d8a0d5ec04d7f177c 30-Apr-2011 Carl Shapiro <cshapiro@google.com> Type the reference member of JValue as an Object pointer.

Previously this had been a void pointer. To avoid adding lots of
casts from the logical Object subtypes to Object the RETURN_PTR macro
silently casts its argument to an Object* before performing an
assignment to the JValue return value. After an inheritance
relationship is established between Object and its subtypes this cast
can be removed.

Change-Id: Id05e5c11e57e2a9afd12bad0be095f1dfe9e1f51
bjectInlines.h
5584c2b061d185764f5910f74c78301bbb7abd3b 28-Apr-2011 Carl Shapiro <cshapiro@google.com> Merge "Add a non-moving option to dvmMalloc and make use of it." into dalvik-dev
d862faa2ceae186da5518607505eb942d634ced9 28-Apr-2011 Carl Shapiro <cshapiro@google.com> Get rid of uneeded extern, enum, typedef and struct qualifiers.

Change-Id: I236c5a1553a51f82c9bc3eaaab042046c854d3b4
ccessCheck.h
rray.h
lass.cpp
lass.h
bject.h
bjectInlines.h
esolve.h
ypeCheck.h
52e2626eb3bf620c53459a90d912733de2ce0369 28-Apr-2011 Carl Shapiro <cshapiro@google.com> Add a non-moving option to dvmMalloc and make use of it.

At present, class objects, non-moving arrays, and interned strings have
location dependencies in native code. Allocating non-moving is a no-op
for the present heap, but this option will have an effect after the
copying collector is integrated.

Change-Id: I674f83a086ac65db303baab0599831f80f52a4a5
rray.cpp
lass.cpp
c67c23bc6f5f3621f31c41bd48553b196ab0325e 28-Apr-2011 Carl Shapiro <cshapiro@google.com> Eliminate the PROFILE_FIELD_ACCESS feature.

Change-Id: I27bf2d18c4c0735913ea8698825b05e393b046b2
lass.cpp
lass.h
bject.h
122dac5b92c649b5d3182b163d7fce35e8c69d76 21-Apr-2011 Carl Shapiro <cshapiro@google.com> Remove DVM_LOCK_INIT and DVM_LOCK_INITIAL_THIN_VALUE.

The original implementation for thin locks used a magic non-zero value
to encode the initial thin lock state. This magic value was kept
around in DVM_LOCK_INITIAL_THIN_VALUE and stored into the lock word of
newly allocated objects. A later revision to the thin locking code
made the initial thin lock value be 0. That change eliminated the
requirement that lock words be explicitly initialized as the allocator
always returns zero-filled memory.

Change-Id: I34e0b43b4c4db0f45cf7cf524e15d4a6096c1365
bject.h
1e1433e78f560a01744e870c19c162ab88df9dc1 21-Apr-2011 Carl Shapiro <cshapiro@google.com> Remove unneeded void argument list declarations.

Change-Id: Ica749f6defa890363ec531b29e25bc415dc2cbb9
lass.cpp
ypeCheck.cpp
d52d4b1e08009c57f1fdc6e13b90cb8948a60102 19-Apr-2011 Carl Shapiro <cshapiro@google.com> Replace public uses of dvmAllocArray with dvmAllocArrayByClass.

Change-Id: Ica5d457566ebf1196af5c0ef260ddeb95f569b81
rray.cpp
rray.h
a4f4a73edf03cd08b5b2d775913bcac674a117bb 19-Apr-2011 Carl Shapiro <cshapiro@google.com> Remove dvmAllocObjectArray and all of its uses.

This replaces uses of dvmAllocObjectArray with equivalent but safer
calls to dvmAllocArrayByClass. dvmAllocObjectArray performed no type
checking of its arguments and was easy to use incorrectly.

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

Change-Id: Ibc3766edfbf7fdbde2d762d6e88a0bb02df2be31
ccessCheck.c
ccessCheck.cpp
rray.c
rray.cpp
lass.c
lass.cpp
lass.h
bject.c
bject.cpp
esolve.c
esolve.cpp
ypeCheck.c
ypeCheck.cpp
c6d2470eec726ae0ad95e4fd2d9d7da7cb2cdcba 12-Apr-2011 Dan Bornstein <danfuzz@android.com> Add a class flag CLASS_ISCLASS.

This flag is only turned on for the unique class Class, and it is
meant to make it possible to quickly test objects for "classiness" as
well as trivially figure out if one is looking at the class Class
itself.

Bonus: Made a few places that directly set class->accessFlags use
the prescribed macro for doing same.

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

Change-Id: I25d8fa821987a3dd6d7109d07fd42dbf2fe0e589
ccessCheck.h
rray.h
lass.h
bject.h
bjectInlines.h
esolve.h
ypeCheck.h
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
lass.c
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
lass.c
c399ea527d0d50c6e2b4ae15fc4a3e9a18f3f1f1 22-Mar-2011 Dan Bornstein <danfuzz@android.com> Pull the globals iteration into InitRefs.

This gives the new GC a way to iterate over the global object refs
defined in Globals.h, without having to have detailed knowledge of the
list of such refs. However, this change doesn't actually modify the GC
code in question, since it is not currently in a working state anyway.

InitRefs.c probably wants a slightly different name. Suggestions welcome.

Bonus: Cleaned up a vaguely-related clause in Class.c.

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

(Requires corresponding libcore change.)

Change-Id: I86aac9dda6708173fd2b5a1c660ef20ea11fca03
lass.c
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
lass.c
bject.h
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
lass.c
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
rray.c
rray.h
lass.c
lass.h
bject.h
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
rray.c
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
lass.c
3111b0c80ca3f90e966371cbab606ac38ed17cad 07-Mar-2011 Dan Bornstein <danfuzz@android.com> Collate more of the low-level class lookups.

I pulled out all the initialization code that I could find that was
merely looking up class and member names during early VM initialization,
putting them all in a new file, InitRefs.c. I didn't do any real restructuring
of the code, though. That will come in a follow-up.

This was instigated by discussion surrounding bug #3500987, but it's not
directly related to it.

Change-Id: I59e93e552d29a5518f2cc4e1e30c4a8d51750d7b
lass.c
lass.h
0b8b293f228b3d341054bc1fad8a92d6e533b4dd 04-Mar-2011 Dan Bornstein <danfuzz@android.com> Rename some of the exception functions.

Since the there is no longer a "ByClass" vs. not distinction, remove
all the "ByClass"es.

Bug: 3500987
Change-Id: I6bdaf5a31e8166b47c333dbbb394dc811f321c5d
rray.c
lass.c
56da263459076b82092dcf783f179da7e85b143b 04-Mar-2011 Dan Bornstein <danfuzz@android.com> More exception rework.

I believe this change gets rid of the remaining throw calls that
used quoted strings for the excpetion type argument.

Bug: 3500987
Change-Id: Id4f905883c1a4e4e5608a2c59986cbd602d416cc
rray.c
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
lass.c
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
lass.c
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
lass.c
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
lass.c
a24bbd1003607afc493a8043e51eee3cf09d0227 28-Feb-2011 Andy McFadden <fadden@android.com> Merge "Update dexopt control logic" into dalvik-dev
d18fcbcee7115ff99673222650fda0f7e982c60a 25-Feb-2011 Andy McFadden <fadden@android.com> Update dexopt control logic

This adds a new mode, -Xdexopt:full. In most ways it behaves like
-Xdexopt:verified (the default), but when an un-optimized class is
loaded we will do a full set of optimizations instead of just the
"essential" set.

For classes that are verified and optimized by dexopt (which is to
say, most of them), this has no effect. For the others, this trades
off speed for space, substituting quickened instructions but causing
copy-on-write of pages mapped from the DEX file.

This also demotes the substitution of execute-inline opcodes to
"non-essential" status.

Change-Id: I392fb2ff0bf0af83c000937079895d25ce7f0cb1
lass.c
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
lass.c
ef990c53d65b84c6c19fce59e211397d2d3c391b 23-Feb-2011 Dan Bornstein <danfuzz@android.com> Merge "Round two." into dalvik-dev
70b00abc45d7d04342a96a03749f993028b060f7 23-Feb-2011 Dan Bornstein <danfuzz@android.com> Round two.

This gets most of the rest of the cases where a simple(ish) message
is included with a throw.

Change-Id: Id081966e5c505063c4d4dcf936037cf4d55fc8bf
lass.c
bject.c
esolve.c
5a023aab73158b34b6c329c42318736d115c0742 23-Feb-2011 Jesse Wilson <jessewilson@google.com> am 5945bc11: Merge "Optimize Class.getMethod() by loading only one method."

* commit '5945bc11f354083d24f952992dc579a1fd77dba8':
Optimize Class.getMethod() by loading only one method.
d27f3cf3e7b373487f39e035fc4b55168d55c454 23-Feb-2011 Dan Bornstein <danfuzz@android.com> Factor out class names from throw statements.

Most exception throwing now happens via purpose-built wrapper
functions, each of which encapsulates the actual exception class name,
reducing one source of error (examples of which I fixed during this
exercise) and generally tidying things up.

This change doesn't fix all uses of exception class names, nor even
all throws, because (a) there were classes I didn't get to; (b)
because I didn't make wrappers for all the possible throw function
variants (e.g. the one that takes a cause, the one that takes varargs
for string formatting, etc.); and (c) there are uses of exception
classes in contexts other than throwing. But this change at least makes
a dent in the problem.

Change-Id: I6586ddd3e66ac0fc32c23181b17600ded0b914b2
rray.c
lass.c
bject.c
esolve.c
3c6f4c012e0a314dc9f9f540b9374dbf530d03b0 23-Feb-2011 Jesse Wilson <jessewilson@google.com> Optimize Class.getMethod() by loading only one method.

Change-Id: Ia2cd776c0a14914264e8d94e978d55854ed75623
http://b/3431686
bject.h
ca02b580a542e97f273e1adfb6d26e7b20cc99a0 15-Feb-2011 Andy McFadden <fadden@android.com> Barrier after construction of finalizable object

If thread 1 creates an object, and thread 2 executes the finalizer,
then thread 2 must be guaranteed to see a fully-constructed object.
To this end, we need to emit a store/store barrier before returning
from the object's constructor.

We already do this for objects with final fields, so this is a
minor tweak.

While working on this I noticed that Enum overrides finalize()
(for the explicit purpose of making sure that no subclass can do
so), which the VM was taking as a signal that all enumerated types
are finalizable. In practice this doesn't matter, since the only
instances are the enum elements themselves, and we'd only GC them
if the enum class itself went away. However, setting it correctly
means less work for dexopt and has no measurable impact on class
loading time.

Bug 3403518

Change-Id: Ifa890b5e7ef1cda2a554ba54f25c4148272c3537
lass.c
3453a36d129597ecfe7e6bb699ce3ecdaee01cb1 11-Feb-2011 Carl Shapiro <cshapiro@google.com> Fast fail impossible allocations.

If the size_t type cannot be used to represent any component of an
array size the allocation is be rejected. With this change, overflow
is checked for in the element size computation and total array size
computation. More preconditions are checked by asserts. Misleading
comments have been removed.

Change-Id: I067869c3404b9da591939555c6f9904f52ca7bd7
rray.c
440ec64e5562096d132486e1f1bd9d48b184024a 09-Feb-2011 Carl Shapiro <cshapiro@google.com> Let tryMalloc field over-sized allocation errors.

Change-Id: I691b8eeca74b7e018f86753b00b7f117d5872916
rray.c
83ff618a3e5a63b1930ed546c3d2ef194d29d642 01-Feb-2011 Carl Shapiro <cshapiro@google.com> Remove the HPROF stack trace collection feature.

Change-Id: I0eab9c496b07212fb2c86fe122dc422e70af891e
rray.c
9238eb89ea5f0564047a2a2f040a2229d42f6f63 19-Jan-2011 buzbee <buzbee@google.com> Merge "Consolidate mterp's debug/profile/suspend control" into dalvik-dev
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
lass.c
05d2f14a1012101922ac3a5d646087d7781961a1 15-Jan-2011 Andy McFadden <fadden@android.com> Merge "Fix JNI invocation of constructors." into dalvik-dev
f24a7f125b9407364b2153524e43fb5f50d8d56d 14-Jan-2011 Andy McFadden <fadden@android.com> Fix JNI invocation of constructors.

The code that "virtualizes" method invocations was attempting to
virtualize a call to a constructor. Constructors are direct methods,
so this resulted in a spurious CloneNotSupportedException.

Bug 3354578

(cherry-pick from dalvik-dev)

Change-Id: Ib158ab7fc6b2874eba1fc2afa45fd5436c1f2a8a
bject.c
c020016053b09a718ed94b8fe11b964cda891ec6 14-Jan-2011 Andy McFadden <fadden@android.com> Fix JNI invocation of constructors.

The code that "virtualizes" method invocations was attempting to
virtualize a call to a constructor. Constructors are direct methods,
so this resulted in a spurious CloneNotSupportedException.

Bug 3354578

Change-Id: Icac922593f1d872fffaf3bce98c8e24e287bf7af
bject.c
525c135c123530dd116fdf3667220f517dbd1afe 14-Jan-2011 Andy McFadden <fadden@android.com> resolved conflicts for merge of ae08dca2 to dalvik-dev

Change-Id: I5f35e811bf96f54b45dea7e330a0ecf6a842365f
dcc5a45b820c16bd78a327adf8d57f9e9ea970ea 13-Jan-2011 Andy McFadden <fadden@android.com> Fix implementation of volatile stores

Volatile stores are synchronization actions, not merely releasing
stores, so an additional barrier is required. We also have the
option of using atomic operations, but that's not recommended (except
for 64-bit fields, where we don't have a choice).

Bug 3338450

Change-Id: Ibfa3486eb89af7769c81bcf892b3fee50d2028d4
bjectInlines.h
fc8044d08d4ee33f0f6938c5d97a376146af4225 07-Jan-2011 Andy McFadden <fadden@android.com> Fix JNI GetMethodID on interfaces

The GetMethodID call was only searching through methods declared by
classes and superclasses. If you passed it an interface class and
asked for a method declared in a superinterface, the call would fail.
We now have separate code for handling lookups on interfaces.

This also refactors some similar code in the interface method resolver.

Bug 3329492

(Cherry-pick from dalvik-dev)

Change-Id: Icaf744b9e75a1fd6d99f47281002cc6b3c36e368
bject.c
bject.h
esolve.c
da7334a4ba1bbffe40d3838f463565af46e716d9 07-Jan-2011 Andy McFadden <fadden@android.com> Fix JNI GetMethodID on interfaces

The GetMethodID call was only searching through methods declared by
classes and superclasses. If you passed it an interface class and
asked for a method declared in a superinterface, the call would fail.
We now have separate code for handling lookups on interfaces.

This also refactors some similar code in the interface method resolver.

Bug 3329492

Change-Id: I4db505231501ef089cd1c406b4654e897bd77d48
bject.c
bject.h
esolve.c
fc75f3ed87b55d625b6054e18645da5cbdba31c6 07-Dec-2010 Carl Shapiro <cshapiro@google.com> Fix implicit conversions, rename reserved works, enable -Wc++-compat.

Change-Id: I06292964a6882ea2d0c17c5c962db95e46b01543
rray.c
lass.c
bjectInlines.h
6d4ce5e7162ae14638d1b094b44e60fb931c64ea 03-Dec-2010 Carl Shapiro <cshapiro@google.com> Drive all root scanning by the root visitor.

The root visitor has been used by the concurrent collector during the
re-mark phase. This change makes both the initial mark use the same
visitor routine and obsoletes all of the one-off markers scattered
throughout the runtime sources.

Change-Id: I08ea86d875f235cc628754240ad30ea5dfe2ce70
rray.c
lass.c
c4ae06fe78cffa815225f9bcd26c19e6714db572 04-Nov-2010 Andy McFadden <fadden@android.com> Rename wrap/unwrap --> box/unbox

Use the correct term when moving primitive values in and out of
their parallel reference types.

Also, turn off the verifyCount check in dvmInvokeMethod unless
assertions are enabled. The verifier guarantees this.

Change-Id: I47629835784b5e770089ab3ca5410ee1c42820d9
rray.c
a5a46928b486725ed624fa0ae6c469645a209e87 01-Nov-2010 Carl Shapiro <cshapiro@google.com> HPROF is here to stay, make WITH_HPROF the default.

Change-Id: Ic9947461daa21641fd9d34d52b6c7998716d8ab2
rray.c
ef22d6fa4d6e574a00669a0d2058c2d7cfa463b1 22-Oct-2010 Andy McFadden <fadden@android.com> Don't force optimizations during class init in dexopt.

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

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

Bug 3099161.

Change-Id: I11ee5affd5e3ac5a1e8583241acdf3c4de033a96
lass.c
50cab51bb381c5da01adfd61954ddca37607f51e 08-Oct-2010 Andy McFadden <fadden@android.com> Track result from dvmCallMethod

When dvmCallMethod returns an object reference, we need to ensure
that the GC doesn't release or relocate the storage. Unless we have
a clear view of how the object is used, we need to explicitly track
and release it.

This adds additional tracking, or comments indicating that explicit
tracking is not necessary.

On a similar note, clearing/restoring a pending exception requires
explicit tracking of that exception, since there's a fair chance
that it's no longer in the root set. That needed fixing in a couple
of places.

Bug 3009076.

Change-Id: I39def8c3a5a628f0ee86fc094e34d7c69248c28b
lass.c
a7f5f9043f1ec312b3020ddae9b98937c9d462d3 08-Oct-2010 Andy McFadden <fadden@android.com> Don't do ClassLoader prep in dexopt.

The code to cache the method info for ClassLoader.loadClass() was
happening in dexopt, which is a problem when you're optimizing core.jar.
This splits it out into a different function, which the dexopt startup
doesn't call.

Change-Id: I0bd5b9323b65e8f152b2ab4ea8e58fcf0039e53c
lass.c
lass.h
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
lass.c
10cac709fe47e458cad9a6657a4a89637bac99fa 07-Oct-2010 Andy McFadden <fadden@android.com> Fix clazz->initThreadId ordering

We want to make sure that, if the class we're interested in is in
CLASS_INITIALIZING, we're not loading a stale value for initThreadId.
This is an issue in dvmIsClassInitializing, which reads the value
without holding a lock.

Bug 3069119

Change-Id: I5b492249429cd7a8fbffd526b9a546fb5fb8e6bd
lass.c
9ef5ca666a214f2a96b16e0830e19d37742ab8ca 06-Oct-2010 Andy McFadden <fadden@android.com> Change handling of edge case.

Generally speaking, you can't create an instance of a class before
the class is initialized. When you're talking about java.lang.Class
itself, this doesn't apply. We were trying to sneak in a just-in-time
initialization, but the recent addition of SMP-mandated opcode rewrites
screwed things up a bit.

Happily, the creation of the java.lang.Class class object now happens
at a known time, which means we can explicitly initialize the class
at the right time (when it's far enough along to be able to execute
the class initializer, but before anything tries to use a virtual
method or instance field in java.lang.Class).

Also, changed a LOGE+abort to a simple assert. The test in question is
performed earlier during linking, so this doesn't merit more than an
assertion.

Bug 3045762.

Change-Id: Ifffb5083a3de108e1d91b3de7b75fd5e97705912
lass.c
6f3a90d94a46d5d42a885c07b8d06ff75f7b270b 01-Oct-2010 Carl Shapiro <cshapiro@google.com> am 5163f62f: am 7d3f633d: Merge "Include static fields when dumping class objects." into gingerbread

Merge commit '5163f62f7048c4b651a425b4b7a3a1b0fb227eb6'

* commit '5163f62f7048c4b651a425b4b7a3a1b0fb227eb6':
Include static fields when dumping class objects.
880d296b2fe7325cb71175a83627bb020d282b03 01-Oct-2010 Carl Shapiro <cshapiro@google.com> Include static fields when dumping class objects.

Change-Id: I8e7b1d1ef7ca205b489744dcbf0f210c1f2443c4
bject.c
95a884f7844a6e7bdd820489742254f3fd002f6d 22-Sep-2010 Andy McFadden <fadden@android.com> Fix computation of primitive array widths.

The code was comparing class pointers, but the class objects for arrays
of primitives are initialized on demand. If the class wasn't yet
instantiated, the array width code was returning a default value of 4.
This meant the "write values to an array of longs through the unsafe
methods" code was actually scribbling on the wrong part of the array,
which went unnoticed until recently. (The new-ish ldrexd/strexd code
requires 64-bit alignment.)

We now use the existing array element width computation function. The
code needed a bit of rearranging since it expected an instance of the
class rather than the class.

Bug 3023981.

(cherry-pick from dalvik-dev)

Change-Id: Ife3258eb6798f8e7eaee7c7b6793a16137de389b
rray.c
rray.h
34f91a12d8ac8cd6c0b36dec5b927f63c076f14e 22-Sep-2010 Andy McFadden <fadden@android.com> Fix computation of primitive array widths.

The code was comparing class pointers, but the class objects for arrays
of primitives are initialized on demand. If the class wasn't yet
instantiated, the array width code was returning a default value of 4.
This meant the "write values to an array of longs through the unsafe
methods" code was actually scribbling on the wrong part of the array,
which went unnoticed until recently. (The new-ish ldrexd/strexd code
requires 64-bit alignment.)

We now use the existing array element width computation function. The
code needed a bit of rearranging since it expected an instance of the
class rather than the class.

Bug 3023981.

Change-Id: I51462978362b6a4fce26e13eda17e1bbc0eac192
rray.c
rray.h
bbf9d73a5677de73eaa3b4e1f6de94a24697aad1 15-Sep-2010 Dan Bornstein <danfuzz@android.com> resolved conflicts for merge of a5d99892 to dalvik-dev

Change-Id: I3c030a6b19416a2ac3ca709cdbcbc6b41e6379d3
5170ba5e38ff9e1410fcbb65dc67ea6a6d5b4b17 15-Sep-2010 Andy McFadden <fadden@android.com> No longer exciting.

Bug 3001709.

Change-Id: I7cb2033265f419b8a0cfc148cbc8e976686489d9
rray.c
32bc0787307ba57e92fa74c52da550e2ca22af7f 14-Sep-2010 Dan Bornstein <danfuzz@android.com> Add use of sentinel in BOOTCLASSPATH entries during preopt.

This change introduces the use of the sentinel string "/./" inside
BOOTCLASSPATH entries to signal the start of the portion of the paths
that should be preserved in optimized dex file dependency lists. It's
a little grotty, but it does serve the purpose of allowing host side
dexopt to do its thing inside a build directory without letting the
host path leading up to that build directory to leak into the results.

This change also makes it an error (instead of just a warning) for
there to be BOOTCLASSPATH entries that are not absolute paths (either
truly absolute or ones with the sentinels as per above).

FWIW, dx uses this sentinel in a similar way.

Change-Id: Ic8d0533d3ee0bd7a1d4d06fcf9232c56f0a60abf
lass.c
f16cfefc199d1416c5f83446c1d299786accc737 19-Aug-2010 Andy McFadden <fadden@android.com> Properly handle volatile field accesses from JNI.

For uniprocessors, we need to use the 64-bit quasiatomic functions. For
SMP, we need to do that and also issue barriers on all operations.

This was mostly a matter of adding a bunch of inline getter/setter
functions and then calling the right one based on whether or not the
field is declared volatile.

Also, corrected the output for a failing CHECK_CLASS test in CheckJNI.

Bug 2890631.

(cherry-pick from dalvik-dev)

Change-Id: I3da3b70c906eddd5934347caea83ab041d22cd68
bjectInlines.h
9197746491686dd774d556d28a82c5b6e0ff7b09 19-Aug-2010 Andy McFadden <fadden@android.com> Properly handle volatile field accesses from JNI.

For uniprocessors, we need to use the 64-bit quasiatomic functions. For
SMP, we need to do that and also issue barriers on all operations.

This was mostly a matter of adding a bunch of inline getter/setter
functions and then calling the right one based on whether or not the
field is declared volatile.

Also, corrected the output for a failing CHECK_CLASS test in CheckJNI.

Bug 2890631.

Change-Id: Ib18ed1ce136eef03120ae70cacc39aa33df1490a
bjectInlines.h
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
lass.c
bject.h
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
lass.c
a0b525d50b8b514e1e8f5c9b2852ce056a5eb89d 04-Aug-2010 Andy McFadden <fadden@android.com> Move dvmFreeClassInnards responsibility.

The GC has been responsible for ensuring that the "innards" of a
class object are freed before the ClassObject itself is discarded.
Since we don't currently unload classes, this situation can only arise
if something went wrong during the loading of a class (e.g. memory
alloc failure part way through), or another thread loaded the same
class at the same time and won the race. It makes more sense to
have the cleanup occur at the point we decide that our class object
is not useful.

For the most part this was already being done, but there were a couple
of places where it wasn't.

This change
- adds the missing dvmFreeClassInnards calls
- changes the GC code to warn without taking action
- enables the GC code only when assertions are enabled

The code in MarkSweep.c looks like it merits further rearranging, but
I'll leave that to Team GC.

Also, "dalvik_assert" is now only printed on the VM features line when
assertions are enabled.

For bug 2751668.

Change-Id: I90e4455e830766f94f921c7f23b44b423bce3321
lass.c
22680eee4aa012c839568d83a132b2b20ff39525 21-Jul-2010 Elliott Hughes <enh@google.com> Be less misleading when something goes wrong early.

In the recent icu4c breakage, we misinterpreted the "thrown during ...<clinit>"
to mean that <clinit> was the method that threw. This patch makes the wording
less easy to misinterpret.

The other thing that was confusing was the lack of a stack trace. It turns out
that dalvikvm tried to output a stack trace when the thread died, but it was
using LOGI. We'd have seen that on the device (which logs everything), but it
was filtered out by the host build's liblog. (Our ANDROID_LOG_TAGS was set to
"*:w".)

Change-Id: Ib46b3c7addc75aed103a3eb9fa010234f4444fbe
lass.c
1e83b4d026199073c057edcb7836d06ae0716390 16-Jul-2010 Andy McFadden <fadden@android.com> Implement JNI UnregisterNatives.

This function is of limited use, but one of our partners found a need
for it, so it's finally getting implemented. It clears all JNI native
method bindings in a given class.

It turns out there are some interesting potential races which can be
avoided by treading lightly. The utility function that updates the
Method struct has been modified appropriately.

(There's a race on ARM SMP in the original implementation, in which
we could still observe "insns" as NULL after nativeFunc is pointing at
the JNI bridge. Handled in this change with an explicit full barrier,
which is overkill. We can make it better as part of the general
barrier-removal pass in bug 2781972 -- really wants an acquiring load
on nativeFunc, though that's a waste for internal native calls.)

Also, stifled an unnecessary warning about redefining a native method
implementation (which is explicitly allowed). Limited the scope of
an inappropriate "const" declaration.

Bug 2697885.

Change-Id: Ie406e25de3f77d00fe3e9130b406abcb45c3d60e
lass.c
lass.h
4ac66a9db181df9ab3a12e2c3f928e43bb962344 09-Jul-2010 Barry Hayes <bhayes@google.com> Make the write barrier calls in ObjectInlines conditional; if the
value being stored is NULL, no write barrier call is needed.

Change-Id: I608f9706c233717b4fa0f79f78f152a2a360ee78
bjectInlines.h
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
lass.c
d0f0ee6929af654a42b290e6886d4d9d19ae9ee8 09-Jul-2010 Andy McFadden <fadden@android.com> Handle NULL return from class loader.

The VM was asserting that it couldn't happen, when it fact it can quite
easily if a class loader is broken.

Bug 2817346.

Change-Id: Id2a4edab428a0ef0fa9aabc8e4a7f6a4d614fb9e
lass.c
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
lass.c
33a192e2096cff25029ae339de84d33a443e7c8e 29-Jun-2010 Barry Hayes <bhayes@google.com> Bullet-proof dvmFreeClassInnards from unexpected or NULL descriptor.

Change-Id: I1641dcedf502ce5936c5f9c07206401ddcbcf999
lass.c
d2cc7342f7705e0b10d79b5f8185c1094b108eca 25-Jun-2010 Barry Hayes <bhayes@google.com> Merge "Fixing up #ifndef inlcude name." into dalvik-dev
0dfa7bff98a5ec755536d54e65362ec3a2b5c49a 25-Jun-2010 Barry Hayes <bhayes@google.com> Fixing up #ifndef inlcude name.

Change-Id: I0dd2f8c18aaaf4cea7b7a6df44e42f889af90ed6
bjectInlines.h
4e3c48968f8b2e29cf95eb05a25ead849d6b266d 25-Jun-2010 Barry Hayes <bhayes@google.com> Merge "Move WriteBarrier operations into their own header file. Split Object.h" into dalvik-dev
7ef0755c91caeea2cc89d886e566e71dc626abed 25-Jun-2010 Barry Hayes <bhayes@google.com> Move WriteBarrier operations into their own header file. Split Object.h

The write barrier routines will soon be INLINE and non-null. Buried
in the middle of Object.h, which is early in Dalvik.h, it would be
hard for them to make use of definitions in other .h files.

Change-Id: I3c0eb59cb6ef29c2bacd0432cf59aaca4c3d031c
bject.h
bjectInlines.h
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
lass.c
364f9d924cbd9d392744a66f80cc084c3d80caf0 12-Jun-2010 Barry Hayes <bhayes@google.com> Put wrappers on all stores of Object pointers into heap Objects.

Also:
Changed ++ loops to [i] loops where I'm touching.
Added some asserts.
Added dvmHeapSourceContainsAddress
Added dvmIsValidObjectAddress

Change-Id: I6586688246064aecabb1e22e1dca276fecee7795
rray.c
lass.c
bject.h
1145f22c92b0fb2c3bfc4de2d0d38bd54046127c 21-Jun-2010 Andy McFadden <fadden@android.com> Fix ENFORCE_READ_ONLY mode for LinearAlloc.

Just need to wrap a memset call that zeroes out the interface indices
before the class is marked GC-able.

Change-Id: I734985f668d224f674d95faa4854db4d4978a4d0
lass.c
81f3ebe03cd33c9003641084bece0604ee68bf88 16-Jun-2010 Barry Hayes <bhayes@google.com> Remove the "allocFlags" parameter from dvmCreateStringFromCstr and
dvmCreateStringFromCstrAndLength.

The only valid argument would be ALLOC_DEFAULT, so drop the parameter.

Change-Id: Idf469ef0ec12b0743792fc525e0c53fc7486eab6
lass.c
esolve.c
c35a2ef53d0cccd6f924eeba36633220ec67c32e 17-Jun-2010 Andy McFadden <fadden@android.com> Add opcodes for volatile field accesses

This adds instructions for {i,s}{get,put}{,-object}-volatile, for a
total of eight new instructions.

On SMP systems, these instructions will be substituted in for existing
field access instructions, either by dexopt or during just-in-time
verification. Unlike the wide-volatile instructions, these will not be
used at all when the VM is not built for SMP.

(Ideally we'd omit the volatile instruction implementations entirely on
non-SMP builds, but that requires a little work in gen-mterp.py.)

The change defines and implements the opcodes and support methods, but
does not cause them to be used.

Also, changed dvmQuasiAtomicRead64's argument to be const.

Change-Id: I9e44fe881e87f27aa41f6c6e898ec4402cb5493e
bject.h
6e10b9aaa72425a4825a25f0043533d0c6fdbba4 15-Jun-2010 Andy McFadden <fadden@android.com> Atomic op cleanup.

Replaced VM-local macros for barrier and CAS calls with the actual
versions provided by cutils.

ATOMIC_CMP_SWAP(addr,old,new) --> android_atomic_release_cas(old,new,addr)

MEM_BARRIER --> ANDROID_MEMBAR_FULL

Renamed android_quasiatomic* to dvmQuasiAtomic*.

Didn't change how anything works, just the names.

Change-Id: I8c68f28e1f7c9cb832183e0918d097dfe6a2cac8
rray.c
lass.c
bject.h
228a6b01918304f2cd1213c722e028a6e25252bb 05-May-2010 Andy McFadden <fadden@android.com> Forward progress on verifier.

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

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

Converted some things from int to size_t.

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

Change-Id: I1e3d103a7b932ef21acedb6438c0f26b315df28f
ccessCheck.c
ypeCheck.c
de75089fb7216d19e9c22cce4dc62a49513477d3 09-Jun-2010 Carl Shapiro <cshapiro@google.com> Remove trailing whitespace.

Change-Id: I95534bb2b88eaf48f2329282041118cd034c812b
rray.c
lass.h
bject.c
bject.h
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
rray.c
lass.c
lass.h
bject.h
3595a09a6fff5483f69f0f714128646c17a03216 24-May-2010 Barry Hayes <bhayes@google.com> Check the number of slots in the Class.java definition against the number assumed by the VM, and abort if the Class has too many.

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

Change-Id: Icbe24eaf1ad499f28b68b6a5f05368271a0a7e86
lass.c
77514abeade6960daf67f5fec3a865df29ea0256 06-May-2010 Andy McFadden <fadden@android.com> Plug leak in class initialization.

Don't add static fields and methods to the resolved-items table if the
defining class is still being initialized. If we do, other threads can
then access those fields and methods without first performing an "is the
class initialized" test.

We will end up performing static field and method resolution more often
now than before. On a Nexus One, zygote class preload time went from
2227ms to 2239ms (i.e. the performance difference is in the noise).

Bug 2655384.

(Re-applying this after the JIT fix.)

Change-Id: I14846865313730f705b819c5893456e342316e2e
lass.c
esolve.c
b4997c358f107acb20c9e3216e3153df57bd0017 07-May-2010 Dan Egnor <egnor@google.com> am 030dc99b: am b463bd41: am 645689db: am 42b68d1a: am 818164b8: Revert "Plug leak in class initialization."

Merge commit '030dc99b8ca387adb3377830d65eea76de3adacd' into dalvik-dev

* commit '030dc99b8ca387adb3377830d65eea76de3adacd':
Revert "Plug leak in class initialization."
818164b87a9c08a938c371d8b47987a3af06d6f6 07-May-2010 Dan Egnor <egnor@google.com> Revert "Plug leak in class initialization."

This reverts commit d07cf9d69dddeebb91386a88f7b6d2323cf125a9.
Bug: 2664424

Change-Id: I1a36469757f2f20fb29b3bcf04e2a23aa7b72dca
lass.c
esolve.c
7c71561148b4f153e9f7af23ef6b5aa007f7de75 07-May-2010 Jean-Baptiste Queru <jbq@google.com> am ac2a3585: am 206edb63: am 71c9526e: am 99632b11: manual merge from froyo

Merge commit 'ac2a358546cf2b5bab43a39eb40549d31932c64d' into dalvik-dev

* commit 'ac2a358546cf2b5bab43a39eb40549d31932c64d':
Plug leak in class initialization.
d07cf9d69dddeebb91386a88f7b6d2323cf125a9 06-May-2010 Andy McFadden <fadden@android.com> Plug leak in class initialization.

Don't add static fields and methods to the resolved-items table if the
defining class is still being initialized. If we do, other threads can
then access those fields and methods without first performing an "is the
class initialized" test.

We will end up performing static field and method resolution more often
now than before. On a Nexus One, zygote class preload time went from
2227ms to 2239ms (i.e. the performance difference is in the noise).

Bug 2655384.

Change-Id: Ib0c285ef23d58ae709be65f09efb68e73f982084
lass.c
esolve.c
c95e0fbce4f77b2b08eb48205e405793de0d4248 29-Apr-2010 Andy McFadden <fadden@android.com> Rework common_periodicChecks.

The function was rewritten to optimize the common path. The control flow
now matches the C version, which tests for debugger/profiler even if the
previous test for suspension came up true.

This also adds a minor optimization on the test for debugger attachment,
allowing us to skip a load from memory if the process is simply not
debuggable. (The optimization isn't yet enabled because a similar change
must be made to the x86 asm code.)

The VM apparently hadn't been built without debugging/profiling support
for a while, so this fixes those places (necessary to be able to test
all forms of the new code).

Bug 2634642.

Change-Id: I096b58c961bb73ee0d128ba776d68dbf29bba924
lass.c
6efd446399ba7a9bb68bf8ddb5a458072a1381b0 23-Apr-2010 Andy McFadden <fadden@android.com> Fix a deadlock in the breakpoint code.

In froyo we started using "hard" breakpoints, where we replace the
existing opcodes with breakpoint instructions. This requires some
coordination to avoid confusing the verifier. The previous approach
allowed the breakpoints to be inserted, and "undid" them while the
verifier ran; this worked, but caused us to be holding a lock for
an extended period.

The new approach just avoids altering the bytecode of unverified
classes, and then "flushes" the breakpoint set out between the time
when verification completes and class initialization starts. This
removes the possibility of blocking with the lock held, and makes
everything much simpler.

For bug 2615063.

(cherry-pick from dalvik-dev)

Change-Id: I75f19b0cc71fc0babb50ab299c6c5a865e06c919
lass.c
d22748a8ddc8f6a7d2e82868b46e9a7739f2e8e5 23-Apr-2010 Andy McFadden <fadden@android.com> Fix a deadlock in the breakpoint code.

In froyo we started using "hard" breakpoints, where we replace the
existing opcodes with breakpoint instructions. This requires some
coordination to avoid confusing the verifier. The previous approach
allowed the breakpoints to be inserted, and "undid" them while the
verifier ran; this worked, but caused us to be holding a lock for
an extended period.

The new approach just avoids altering the bytecode of unverified
classes, and then "flushes" the breakpoint set out between the time
when verification completes and class initialization starts. This
removes the possibility of blocking with the lock held, and makes
everything much simpler.

For bug 2615063.

Change-Id: I7f43e09a755fba27b335454659b3f04e8b2179ac
lass.c
bfe4dcc3bd3d4d85a07fd3d63da537b51342b6eb 17-Apr-2010 Carl Shapiro <cshapiro@google.com> Refinements to array and class object size computation.

* Rename dvmArrayObjectLength to dvmArrayObjectSize. In the context
of arrays length may refer to the length of the array data and not
the size of the array object instance.

* Add a new method dvmClassObjectSize which computes the total size of
a class object including its static fields.

Change-Id: I693ec8e66dfa5df35c9f35474c80411ea917c899
rray.c
rray.h
lass.c
lass.h
1e714bbd8230ac6fb9e3a8e9e25bca687132c82a 16-Mar-2010 Carl Shapiro <cshapiro@google.com> Import the heap verification code from the copying collector. The
reference verification routine adds an extra argument so the base
address of an object can be passed to the verification code without
provoking a warning from GCC about breaking alias analysis.

Change-Id: Idd921bcc0e084c18bff1e209a8591ef55f57843a
rray.c
rray.h
861b33855aff080278ea5125e4372a2d4bf8aef5 06-Mar-2010 Andy McFadden <fadden@android.com> Make wide-volatile loads and stores atomic.

This implements the four wide-volatile instructions added in a previous
change, and modifies the verifier to substitute the opcodes into the
instruction stream when appropriate.

For mterp, the ARM wide get/put instructions now have conditional code
that replaces ldrd/strd with a call to the quasiatomic functions. The
C version does essentially the same thing. ARMv4T lacks ldrd/stdrd, and
uses separate implementations for the wide field accesses, so those were
updated as well. x86 will just use stubs.

The JIT should punt these to the interpreter.

Change-Id: Ife88559ed1a698c3267d43c454896f6b12081c0f
Also:
- We don't seem to be using the negative widths in the instruction
table. Not sure they're useful anymore.
- Tabs -> spaces in x86-atom throw-verification-error impl.
rray.c
bject.h
929ebe2699524f0908abc9dd1fabd82d1ba13d02 11-Mar-2010 Andy McFadden <fadden@android.com> Minor fixes.

Quieted a couple of warnings about constness.

Added "synchronized" to BootClassLoader.getInstance(), which creates the
instance on first use.

Change-Id: I4a521bb2c6853b1ad8a118aa53f697be18b69280
bject.c
03aa70ae413c6c5fb2ee4424afd30608bfb465ee 02-Mar-2010 Barry Hayes <bhayes@google.com> Change Class layout to allocate an array of StaticField objects
immediately after the ClassObject, rather than use calloc.

This has the rather surprising and pleasing effect of increasing
charing about 150K per zygote-launced application, as measured at
start-up, after waiting and no-touching.

Change-Id: I6a6c9079f946eb99111326ed45f13ecfe544e4bb
lass.c
bject.c
bject.h
4dc2ab9f91ac94ab4d725b119141769a2e23975b 01-Mar-2010 Barry Hayes <bhayes@google.com> Move allocation of the uninitialized class object on to the object heap.
lass.c
e15a8eb2653da80c1c3816ddce8186746b57b4a3 23-Feb-2010 Andy McFadden <fadden@android.com> Add class init stats to alloc counters (API change).

Add calls to retrieve class initialization stats via the allocation
count mechanism.

Also: deprecate a method that is never used, and a redundantly declared
default filename that begins with "/sdcard".

For bug 2461549.
lass.c
30aa99778069baf0dab767f0fc1f5b1d51d110ff 14-Jan-2010 Carl Shapiro <cshapiro@google.com> Update the hash state bits when an identity hash code is computed.
rray.h
4bc10cc26f856f2447bb23316e6729bcd20c2bf4 13-Jan-2010 Andy McFadden <fadden@android.com> Support primitive array elements in annotations.

Annotations that include primitive array elements are stored internally
as arrays of boxed primitives. The VM didn't know how to un-box them
when somebody requested the contents.

For bug 2370144.
rray.c
rray.h
7c70b3f1c2e92364ea44ece3843a64fe69274427 12-Jan-2010 Carl Shapiro <cshapiro@google.com> Delete remaining FANCY_REFERENCE_SUBCLASS code. According to find and
grep, this is the last use of that macro in Dalvik.
lass.c
8d7f9b2cd9fe252399ae96a36781bba1242fb93c 22-Dec-2009 Carl Shapiro <cshapiro@google.com> Supersede the Lock union type with a word-sized integer in the object
instance header. An object's lock member is now just a bit-field.
bject.h
fcccb3bfa5f42fc728c307cfcf77db4d685583c0 30-Oct-2009 Barry Hayes <bhayes@google.com> Remove arrayClass from ClassObject. It seems to get only dozens of hits in
all of Zygote start-up.

There doesn't seem to be a measurable difference in the time printed in:
I/Zygote ( 2247): ...preloaded 1147 classes in NNNNms.
rray.c
bject.h
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.
lass.c
bject.h
beea0b72181a13e6e0850704a2a5de2df00e15c3 13-Nov-2009 Elliott Hughes <enh@google.com> If we have a Class object in the "monitors held:" output, show which class.

Bug: 2187020
bject.h
504e9f4441c3a013047931d24a978523a26fde2d 16-Sep-2009 Andy McFadden <fadden@android.com> Speling.
lass.c
2fbe6d15ed8d266ed55fb76e97f866dbd07d5fa6 05-Sep-2009 Andy McFadden <fadden@android.com> Reduce a log message, stifle a gcc warning.
lass.c
9c92c48fee7d97e9218e780d32b872eb97962629 01-Sep-2009 Jean-Baptiste Queru <jbq@google.com> merge from open-source master
6daaac12e5de630749f94ff5f15e902e7b18d8e7 08-Jul-2009 Barry Hayes <bhayes@google.com> Add a bit-map encoding of Object-reference field offsets to ClassObject.

Class.c populates a new field with a bit for each of the first 32 instance
fields, to show if it is a reference or not, and an escape value if there is a
reference field beyond 32.

The GC uses the encoded bitmap -- if available -- to extract Object refererences
from DataObjects.
lass.c
bject.h
e2729683dc78022e033c7bac36e061baff7cd3c5 21-Aug-2009 Andy McFadden <fadden@android.com> Fix a couple of compiler warnings.
lass.c
be323ec573918ef1674e4883c8766ddc4ee2a10c 10-Aug-2009 Jean-Baptiste Queru <jbq@google.com> merge from open-source master
e2557513420f6be2d70c19a4d826731174c828d1 28-Jul-2009 Bill Buzbee <buzbee@google.com> Fix for 3326: Incorrect return value from native library in dalvik
Really a workaround for a gcc bug in 4.3. Don't trust the C compiler
to properly clear high bits from < 32-bit JNI return values.
lass.c
7605a84a9a0a1764c1fb290d9c93e8114eaf620a 27-Jul-2009 Andy McFadden <fadden@android.com> Added dvmLinearAllocContains().
lass.c
6a95adec3a5fa107f2bec11d77a66408f239c5ac 26-Jul-2009 Jean-Baptiste Queru <jbq@google.com> Merge korg/donut into korg/master

Conflicts:

libcore/luni/src/main/java/org/apache/harmony/luni/platform/PlatformAddressFactory.java
vm/oo/Class.c
1d9206d47ee3f7ae1f75de3d1cb02a8e9a72a0bb 15-Jul-2009 Andy McFadden <fadden@android.com> Make verifier field/method resolution conformant.

The VM spec spells out a particular way to look for fields. It assumes
that static and virtual fields are piled together into a single pool,
so it makes sense to scan through both kinds when resolving. In Dalvik,
field definitions are separated by scope, so we can save a little time
by only searching through the appropriate list.

It turns out that you can create a situation where a field with the same
name is available in both static and virtual forms in the same class.
javac won't let you do this in a single class, but with separate
compilation and inheritance you can pull it off. In these situations,
Dalvik can do the wrong thing. For example, if you ask for a static
field, Dalvik will happily use the static field from a superclass without
realizing that there's an instance field with the same name in the current
class. It's supposed to find the instance field, realize that it's not
static, and throw an exception.

This change updates the verifier to do an "untyped" scan like the VM
spec wants. Problematic situations are identifed and result in an
"incompatible class change" exception.

This does not alter "direct" method lookups (constructors, private
methods).

I also altered the annotation "ambiguous" method lookup to use the new
function, since that's probably the desired behavior there as well.
bject.c
bject.h
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.
lass.c
511d0505abb8fe7d2af8cd8532de773ce30d7615 08-Jul-2009 Mike Lockwood <lockwood@android.com> Fix typo introduced in previous change.

Signed-off-by: Mike Lockwood <lockwood@android.com>
lass.c
eac47eddd953ca572f1c92a326b55b735b46377d 22-Jun-2009 Barry Hayes <bhayes@google.com> Add a bit-map encoding of Object-reference field offsets to ClassObject.

Class.c populates a new field with a bit for each of the first 32 instance
fields, to show if it is a reference or not, and an escape value if there is a
reference field beyond 32.

The GC uses the encoded bitmap -- if available -- to extract Object refererences
from DataObjects.
lass.c
bject.h
e7b30940e1459c50b003edb3909eeeb919cab3d5 27-May-2009 Andy McFadden <fadden@android.com> Another fix for external bug 2711 (over-eager conflicting class rejection).

The validateSuperDescriptors() test also checks for conflicts with
interface classes, and wasn't doing that quite right. We need to compare
every method declared by an interface against the class' implementation
of it. Methods implemented by superclasses are now tested in the context
of the superclass, not the current class.

This is a one-word fix + comments and new/updated tests.
lass.c
686e1e23324f1c1f358f29f13f23e57b41c00eaa 27-May-2009 Andy McFadden <fadden@android.com> Correct handling of certain incompatible class changes.

Tests 065 and 066 depened on the old behavior of the verifier. Updating
them to the new behavior wasn't enough, though, because they weren't
reporting the right error. The verifier's resolution code now examines
the exception to see if the load failure was caused by an incompatible
class change error.

I also updated the description of test 071 to note that it will fail on
the device if you don't have an sdcard.

Added a method to get the exception "cause" field. It handles the
"uninitialized" state, which I keep forgetting about.

Spruced up dvmDumpObject, which hadn't been used in a while. Fixed a
warning in Profile.c.

For internal bug 1866729.
bject.c
cab8be0c6e1e9a683402d5a71b037723a6b15bb2 26-May-2009 Andy McFadden <fadden@android.com> Fix for external bug 2711, over-eager conflicting class rejection.

The validateSuperDescriptors() test added in Cupcake (or thereabouts) was
checking things that didn't need to be checked, and rejecting classes that
didn't need to be rejected.

Expanded test 068 to include a doubled-but-okay test.

Updates FancyLoader to use a single copy of the DexFile.
lass.c
1b5895818bfe6c703b8803dd3f954709bf725983 22-May-2009 Andy McFadden <fadden@android.com> Ignore missing bootstrap class path jars after printing a warning.

Previous behavior was to print an error and halt. The warning will appear
in the log whenever the VM is started, which means you'll see it on every
"dexopt" invocation but otherwise only once during zygote init.

For internal bug 1812586.
lass.c
b51ea11c70602918c42764bfafe92a997d3b1803 09-May-2009 Andy McFadden <fadden@android.com> Defer reporting of certain verifier failures.

The verifier currently reports all failures immediately. Certain failures,
such as the failure to resolve a method, or the determination that access
to a field is not allowed, are supposed to deferred until the first time
that executing code does something that could cause the resolution.

With this change, several kinds of verification failures are deferred.
This is done by making a writable copy of the bytecode and replacing the
failing instruction with an "always throw" opcode.

Gory details:
- Added throw-verification-error instruction. Implemented in "portable"
and ARM interpreters. x86 uses portable form through stub.
- Added a function that creates a copy of a DexCode area and makes the
bytecodes writable.
- Added code that replaces a single instruction with an "always throw".
- Replaced runtime check for abstract/interface in new-instance with a
check at verification time.
- Added a test to exercise the deferred error mechanism.
- Minor cleanups (replaced tab, bad valgrind command, ...).
lass.c
lass.h
bject.h
d575a886761b5ddc56819cc29d3778fc5116ea88 16-May-2009 Andy McFadden <fadden@android.com> am 7ccb7a6a: Increase the number of entries set aside for zygote initiating loader lists.

Merge commit '7ccb7a6a563396e4b64069dd4e57977d1b5b6180'

* commit '7ccb7a6a563396e4b64069dd4e57977d1b5b6180':
Increase the number of entries set aside for zygote initiating loader lists.
Fix handling of "--dev" argument in dalvik tests.
7ccb7a6a563396e4b64069dd4e57977d1b5b6180 15-May-2009 Andy McFadden <fadden@android.com> Increase the number of entries set aside for zygote initiating loader lists.

The number of classes that are present when the zygote finishes
initializing increased in donut/master, above the 2000 we currently
plan for. Exceeding the limit reduces zygote sharing efficiency, so
this change raises the limit.
lass.c
68825974c18f3b03330c6f4b3a0bf9eb6504d20f 08-May-2009 Andy McFadden <fadden@android.com> Increase size of LinearAlloc region, and warn about massive Mirandizing.
lass.c
029c82d9f5bb66bf47e74ab8eaad24e569f81d72 29-Apr-2009 Barry Hayes <bhayes@google.com> am 2c98747: Improve zygote heap sharing.

Merge commit '2c98747b403970ef4b3352e271633f93935b9825'

* commit '2c98747b403970ef4b3352e271633f93935b9825':
Improve zygote heap sharing.
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
lass.c
bject.h
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
lass.c
bject.h
631444c8e555aa26d47ff38bf4df2e309a7ce819 16-Apr-2009 Andy McFadden <fadden@android.com> Corrected static field resolution.

It's legal (at the bytecode level) to have two fields with the same name
but different types.

Fixes http://b/issue?id=1788918 / http://b.android.com/2422
bject.c
9faa9e6a7df9a5b9ef7c8e9d5c07d2a050c319d3 08-Apr-2009 Andy McFadden <> AI 144931: Added a (hidden) way to "pre-cache" register maps.
The 50 methods that appeared on the GC stacks of the most applications
require 13KB of native heap for their uncompressed register maps, and
the full set took 5ms to uncompress. Pre-computation doesn't represent
a significant improvement in space or time, at the cost of a big pile
of strings in ZygoteInit.
I'm leaving the method in ZygoteInit, but it's not called, and the
static final String[] of method descriptors is empty. We may want to
revisit this later.
BUG=1729570

Automated import of CL 144931
lass.c
ab0f0a0581860a575cb869f6d3cdbba88fed9d04 27-Mar-2009 Andy McFadden <> AI 143123: Three minor changes.
1. detab "dx" script
2. log an error when annotation value parsing fails
3. slightly improve a resolver failure message

Automated import of CL 143123
esolve.c
d45a88794c6470d96e2139cbe803002d9d5d3a6c 25-Mar-2009 Andy McFadden <> Automated import from //branches/master/...@141645,141645
lass.c
99409883d9c4c0ffb49b070ce307bb33a9dfe9f1 19-Mar-2009 The Android Open Source Project <initial-contribution@android.com> auto import //branches/master/...@140412
lass.c
f6c387128427e121477c1b32ad35cdcaa5101ba3 04-Mar-2009 The Android Open Source Project <initial-contribution@android.com> auto import from //depot/cupcake/@135843
ccessCheck.c
ccessCheck.h
rray.c
rray.h
lass.c
lass.h
bject.c
bject.h
esolve.c
esolve.h
ypeCheck.c
ypeCheck.h
f72d5de56a522ac3be03873bdde26f23a5eeeb3c 04-Mar-2009 The Android Open Source Project <initial-contribution@android.com> auto import from //depot/cupcake/@135843
ccessCheck.c
ccessCheck.h
rray.c
rray.h
lass.c
lass.h
bject.c
bject.h
esolve.c
esolve.h
ypeCheck.c
ypeCheck.h
31e30105703263782efd450d356cd67ea01af3b7 03-Mar-2009 The Android Open Source Project <initial-contribution@android.com> auto import from //depot/cupcake/@132589
lass.c
6dcac3deb3c19dc634470eb30b2daedf2b201bd4 03-Mar-2009 The Android Open Source Project <initial-contribution@android.com> auto import from //depot/cupcake/@137055
lass.c
5d709784bbf5001012d7f25172927d46f6c1abe1 11-Feb-2009 The Android Open Source Project <initial-contribution@android.com> auto import from //branches/cupcake/...@130745
lass.c
lass.h
bject.h
esolve.c
bcd637a94f10b49d18b87a74a015f9d3453ed77a 22-Jan-2009 The Android Open Source Project <initial-contribution@android.com> auto import from //branches/cupcake/...@127436
rray.c
lass.c
lass.h
bject.h
4c1a2915e40eceeb68dbc323d28b8bf8763af83b 20-Jan-2009 The Android Open Source Project <initial-contribution@android.com> auto import from //branches/cupcake/...@127101
rray.c
lass.c
cc05ad238516f1303687aba4a978e24e57c0c07a 10-Jan-2009 The Android Open Source Project <initial-contribution@android.com> auto import from //branches/cupcake/...@125939
lass.c
89c1feb0a69a7707b271086e749975b3f7acacf7 18-Dec-2008 The Android Open Source Project <initial-contribution@android.com> Code drop from //branches/cupcake/...@124589
lass.c
lass.h
bject.h
ypeCheck.c
ypeCheck.h
2ad60cfc28e14ee8f0bb038720836a4696c478ad 21-Oct-2008 The Android Open Source Project <initial-contribution@android.com> Initial Contribution
ccessCheck.c
ccessCheck.h
rray.c
rray.h
lass.c
lass.h
bject.c
bject.h
esolve.c
esolve.h
ypeCheck.c
ypeCheck.h