History log of /dalvik/vm/analysis/
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
6ad3f100edffe51b2d4592dce893e1e2bb566161 14-Apr-2012 jeffhao <jeffhao@google.com> Output number of bytes used by LinearAlloc during dexopt.

Maps is exceeding the LinearAlloc limit set in Gingerbread (5MB). They
wanted a way to know how close they were from going over, so this added
output can tell them how much room is left.

Change-Id: I0b78ce24accc05746bc396398086ce695bd7ba57
exPrepare.cpp
9a05976eec8b0644e7cd9f4d4e4ecd0e73e19dd8 13-Feb-2012 jeffhao <jeffhao@google.com> Fix verifier typing for null float arrays.

Since the array is null, the verifier would get confused about its type.
Now it's treated as zero to allow it to be merged later without conflict.

Bug: http://code.google.com/p/android/issues/detail?id=24814

Change-Id: Id7e96f5d2fd4879c9eaa8535c2b9ae95b0b78cff
odeVerify.cpp
2a249c50903d669d2a9296f0fe407b67646626c8 18-Jan-2012 jeffhao <jeffhao@google.com> Fix to dex verifier to handle float types that look like Boolean.

Addresses http://code.google.com/p/android/issues/detail?id=23465, where
a Float value is potentially 0x0 or Float.MIN_VALUE (0x1), which combines
into a Boolean type, which should be allowed to be promoted to Float.

Change-Id: I1718820dc05719772aa939f3f7830bb86a161d56
odeVerify.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
odeVerify.cpp
exPrepare.cpp
exVerify.cpp
ptimize.cpp
egisterMap.cpp
erifySubs.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
exPrepare.cpp
ptimize.cpp
egisterMap.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
odeVerify.cpp
exPrepare.cpp
iveness.cpp
ptimize.cpp
egisterMap.cpp
fyBasicBlock.cpp
ab35b50311951feea3782151dd5422ee944685c2 05-Jan-2012 Elliott Hughes <enh@google.com> Remove unsupported experimental opcodes.

External developers were starting to try to get themselves into trouble with
this stuff...

Change-Id: I2b03bfeaa8c98b6a994bc7924fc8dcf4e4d4f6cb
odeVerify.cpp
exVerify.cpp
iveness.cpp
ptimize.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
odeVerify.cpp
exPrepare.cpp
exVerify.cpp
ptimize.cpp
egisterMap.cpp
fyBasicBlock.cpp
a488045bc62f616ba5f579594da828854b64cbd2 03-Nov-2011 Andy McFadden <fadden@android.com> am 63cd4b08: Don\'t malloc between fork and exec

* commit '63cd4b08e623242066c63563bad3a9f414a2bd2d':
Don't malloc between fork and exec
63cd4b08e623242066c63563bad3a9f414a2bd2d 02-Nov-2011 Andy McFadden <fadden@android.com> Don't malloc between fork and exec

This was causing hangs in DEX file loading.

Bug 5329833

Change-Id: I19e9e0624f3823cc771c71a4b4ac177d57343c58
exPrepare.cpp
566a832224f09bfc683a987f4fa6d90bd5010efe 02-Nov-2011 Andy McFadden <fadden@android.com> am a78b1255: Fix cleanup

* commit 'a78b1255ad1ce8dcacad21338d4f88db4231c4cd':
Fix cleanup
a78b1255ad1ce8dcacad21338d4f88db4231c4cd 01-Nov-2011 Andy McFadden <fadden@android.com> Fix cleanup

The code was attempting to null out a struct member after freeing
the struct.

Also, changed the order of directory permission tests so that
writable comes first. Somehow "dalvik-cache directory not
writable" seems more direct than "not readable", since the code
isn't generally interested in reading the directory.

Bug 5549907

Change-Id: Ie412ff6c0870357b92e53606f70cb9407e04e7cf
exPrepare.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
odeVerify.cpp
exPrepare.cpp
ptimize.cpp
egisterMap.cpp
fyBasicBlock.cpp
32c482c90d0ddfaefff623702eb862a77bffa9b2 06-Oct-2011 jeffhao <jeffhao@google.com> Reordered some checks and added more to the verifier.

The verifier checks for 2 errors in put instructions. First, if the
field can't be resolved, the instruction is overwritten to throw a
verifier error. Second, if the data types of the field and instruction
mismatch, the verifier rejects the whole class. This change swaps the
order of the checks, so that if both errors occur, the class is
rejected.

Also, checks were added to prevent float values from being used as array
indexes or arguments to if statements.

Change-Id: I7b122f4ebc4043266be4466e10679c6319a788ef
odeVerify.cpp
5a459d4a923cd2160026cc58e4d3da0858028320 04-Oct-2011 jeffhao <jeffhao@google.com> Fixed dx verifier issue when an error is detected.

The code needed to break out properly when an error was detected to
prevent it from causing even more problems.

Change-Id: If497655a406689aeb1b4aa6523421cc22f2b7593
odeVerify.cpp
43b06bc2d11c5fcd69c3554c0e525abad8480fab 10-Aug-2011 jeffhao <jeffhao@google.com> Dexopt verifier checks that int/float and double/long uses do not mix.

Added new types to dexopt indicating a type is derived from a constant,
which may or may not be floating point. After such a value is used, its
type can be determined, and the verifier enforces that it is always used
that way afterwards.

Change-Id: I150deaa162aec17bcc9c3e3200bc0350ae5b3f24
odeVerify.cpp
odeVerify.h
8bc8bf71a52e17d483021b4c9dc8e735d9bce3ed 20-Jul-2011 Elliott Hughes <enh@google.com> Don't use dvmIsValidObject outside the GC.

Use dvmIsHeapPointer outside the GC. (This still isn't safe because there's
no synchronization when dealing with the HeapSource.)

Bug: 5049447
Change-Id: Ie0b325ef0a92687ea1eaf1491a4bb832298893c5
odeVerify.cpp
7aa9563279627b2ff5413bc895381fc170df9f12 07-Jul-2011 Doug Kwan <dougkwan@google.com> Remove dead code/unused variables to avoid gcc-4.6 warnings.

Change-Id: I291fd42e91085c51772f560d424334874bef8add
odeVerify.cpp
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
odeVerify.h
exPrepare.h
exVerify.h
iveness.h
ptimize.h
egisterMap.h
erifySubs.h
fyBasicBlock.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
odeVerify.cpp
erifySubs.cpp
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
exPrepare.cpp
0bb39c2258a1e45bb1142ec89b8ca5d2eaaa6f02 06-Jun-2011 Dan Bornstein <danfuzz@android.com> Note a possible improvement.

This section of code was left commented out because of a bug in
dx. Since the dex format version has since changed, we can now
use detection of the format version to enable the code. This
patch just notes that fact for the record.

Change-Id: I9129bc4420c17fb8c703b424a0bac9437f796210
odeVerify.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
exPrepare.cpp
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
odeVerify.cpp
exVerify.cpp
iveness.cpp
ptimize.cpp
fyBasicBlock.cpp
291c84f60853d30e1c0d79dd08c5e5164f588e26 26-May-2011 Dan Bornstein <danfuzz@android.com> Prefer printf format "%#x" over "0x%x".

I exist to serve.

Change-Id: I8e2880b20eefd466da8515d5b6b0c5cb75d56169
odeVerify.cpp
exVerify.cpp
egisterMap.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
odeVerify.cpp
exPrepare.cpp
exVerify.cpp
iveness.cpp
ptimize.cpp
egisterMap.cpp
erifySubs.cpp
fyBasicBlock.cpp
a7323974309c3b81cfe342db635d0bf30f36ff62 07-May-2011 Carl Shapiro <cshapiro@google.com> Establish a subclass relationships among the field types.

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

Change-Id: I236c5a1553a51f82c9bc3eaaab042046c854d3b4
odeVerify.cpp
odeVerify.h
exPrepare.h
exVerify.h
iveness.h
ptimize.h
egisterMap.cpp
egisterMap.h
erifySubs.h
fyBasicBlock.h
1e1433e78f560a01744e870c19c162ab88df9dc1 21-Apr-2011 Carl Shapiro <cshapiro@google.com> Remove unneeded void argument list declarations.

Change-Id: Ica749f6defa890363ec531b29e25bc415dc2cbb9
odeVerify.cpp
ptimize.cpp
egisterMap.cpp
1813ab265f691e93401c7307c0b34247842ab35e 16-Apr-2011 Carl Shapiro <cshapiro@google.com> Move the verifier and parts of the interpreter into C++.

Change-Id: I8ce5fb558871d9709b251512dd01206be5ca8497
odeVerify.c
odeVerify.cpp
exPrepare.c
exPrepare.cpp
exVerify.c
exVerify.cpp
iveness.c
iveness.cpp
ptimize.c
ptimize.cpp
egisterMap.c
egisterMap.cpp
erifySubs.c
erifySubs.cpp
fyBasicBlock.c
fyBasicBlock.cpp
2d63bc57d5fcbcd54f0bd3e9491e1704b98ec0bf 14-Apr-2011 Carl Shapiro <cshapiro@google.com> Move JDWP into C++ and add extern "C" to remaining non-compiler includes.

Change-Id: I19cba56e8f75b76f902c87ff5c5b3e2c17cb5c00
exPrepare.h
iveness.h
erifySubs.h
fyBasicBlock.h
43eb72388a2e7465d256c7a2d50020d2c516b585 14-Apr-2011 Nick Kralevich <nnk@google.com> am 780d3e25: make dvmOpenCachedDexFile resistant to umask changes.

* commit '780d3e25adde11603bb6bab1b42a1e8e985aec15':
make dvmOpenCachedDexFile resistant to umask changes.
780d3e25adde11603bb6bab1b42a1e8e985aec15 14-Apr-2011 Nick Kralevich <nnk@google.com> make dvmOpenCachedDexFile resistant to umask changes.

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

Change-Id: Ibc3766edfbf7fdbde2d762d6e88a0bb02df2be31
exVerify.h
ptimize.h
5ede407bff0b4327c0f878024ca5701279c57093 11-Apr-2011 buzbee <buzbee@google.com> am 0161e158: Merge "Add missing JUMBO opcodes to volatile rewriting"

* commit '0161e1582b13173cc5a125cf504fd7714c9c82b2':
Add missing JUMBO opcodes to volatile rewriting
62fe4c1e9fc28254d357e9755cf4bd2138753c17 11-Apr-2011 buzbee <buzbee@google.com> Add missing JUMBO opcodes to volatile rewriting

The boolean/byte/char/short variants of iget/iput/sget/sput were not
being correctly converted to _VOLATILE opcodes for SMP builds.

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

Change-Id: I25d8fa821987a3dd6d7109d07fd42dbf2fe0e589
odeVerify.h
egisterMap.h
c4a8cafcd62484c1006c5dc9978731a5b7ce403d 24-Mar-2011 buzbee <buzbee@google.com> Interpreter fix - limit suspend checks

Register maps are generated only for a subset of instructions (to
limit memory consumption). The previous interpreter restructuring
was doing suspend checks at locations that had no register maps.
This CL limits suspend checks to instructions that have register
maps, and also expands that set to include foward as well as
backwards branches.

Change-Id: Ia2b2e1096efe524fdb2a5fd4be171a4216b6a3b4
exVerify.c
exVerify.h
71c1771a0ca30b09653de88f6a9c714dec7a61b7 12-Mar-2011 Andy McFadden <fadden@android.com> Replace jumbo opcodes in certain circumstances

With this change we will start using some dexopt-generated "jumbo"
opcodes for volatile field accesses and calls to Object.<init>. These
are necessary for correctness.

Fixed a bug that could prevent volatile fields in huge objects from
being handled correctly.

Also, return "void" from some functions whose return value is never
examined.

Change-Id: I2a7fc66b59953ed3a6f4ac507873101de5d101d5
ptimize.c
a5e5f6eb3ecb7950812a4718b8e795299ce79783 12-Mar-2011 Dan Bornstein <danfuzz@android.com> Merge "Clean up how primitive types are handled." into dalvik-dev
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
odeVerify.c
f4ef26d994b4e735d88b97d0f3f37046ba0f6793 11-Mar-2011 Andy McFadden <fadden@android.com> Clean up stale cases

Substitution of "volatile" ops was once done by the verifier, which
meant the verifier could see them. This is no longer the case, so we
don't need to be handling them.

Change-Id: I6e4cd24dd65a1c28d4e5ee781be6e3499562a05b
odeVerify.c
exVerify.c
iveness.c
24bd4c50bb3ea13be4f049710967961f0546fb2c 10-Mar-2011 Andy McFadden <fadden@android.com> Add volatile/jumbo opcodes

This adds 12 dexopt-generated "volatile/jumbo" instructions, to
be used for replacing appropriate get/put ops, plus a jumbo
replacement for invoke-object-init/range.

The new instructions are defined but not yet used. For x86 and
x86-atom, C stubs are selected.

Also, guarded macro args used in arithmetic expressions in header.S.

Bug 3403118

Change-Id: I283cea053d1cee1d70c3715df3e71177e8b8d3b2
odeVerify.c
exVerify.c
iveness.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
exPrepare.c
57fd399d1265ec627d28a15b3d4b98e5f239ac88 04-Mar-2011 Andy McFadden <fadden@android.com> Low-level support for in-memory DEX

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

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

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

Bug 1338213

Change-Id: If7128bf246992156662e089a2a87cebf475a6f2a
odeVerify.c
exPrepare.c
exPrepare.h
ptimize.c
ptimize.h
c06815473d1b62798a8c0f9edaf5f50a21984bf3 03-Mar-2011 Dan Bornstein <danfuzz@android.com> Merge "Clarify the ordering requirement." into dalvik-dev
4b5fa2e50860015beebcc5fc3a33265b266d6d34 03-Mar-2011 Dan Bornstein <danfuzz@android.com> Clarify the ordering requirement.

Hopefully, future maintainers won't also have to spend a day or so
sorting out what's going on.

Bug: 3500987
Change-Id: I0a1041df9ed4992563bc9d882fa134e82829cf18
exPrepare.c
0fbb64af826ac722a33f6545186873daa460f67d 02-Mar-2011 Dan Bornstein <danfuzz@android.com> Merge "Yak-shaving in support of the exception cleanup." into dalvik-dev
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
odeVerify.c
exPrepare.c
0346e9dcddccd449c731e42ef83708ff6d8f0976 02-Mar-2011 Andy McFadden <fadden@android.com> Change invoke-object-init to /range form

The invoke-object-init instruction pretends to be a regular invoke
that only knows how to call Object.<init>. As such it always takes
one argument, and if we use the /range version we can specify the
"this" register with 16 bits instead of only 4.

Bug 3486699

Change-Id: I9ee4700c6935beee1dcbaa583b57befd33641414
odeVerify.c
exVerify.c
iveness.c
ptimize.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
exPrepare.c
exPrepare.h
ptimize.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
odeVerify.c
6af2ddd107842c3737c04c37343cac9be17f4209 17-Feb-2011 Andy McFadden <fadden@android.com> Defer marking of objects as finalizable

This shifts responsibility for marking an object as "finalizable" from
object creation to object initialization. We want to make the object
finalizable when Object.<init> completes. For performance reasons we
skip the call to the Object constructor (which doesn't do anything)
and just take the opportunity to check the class flag.

Handling of clone()d object isn't quite right yet.

Also, fixed a minor glitch in stubdefs.

Bug 3342343

Change-Id: I5b7b819079e5862dc9cbd1830bb445a852dc63bf
ptimize.c
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
ptimize.c
750d110b62cef538e193b6f91f5239b0c4b63ef1 12-Feb-2011 Andy McFadden <fadden@android.com> Rename invoke-direct-empty to invoke-object-init

The invoke-direct-empty instruction was introduced to remove the
overhead of calling the empty Object constructor. We now need it
to do some extra work on behalf of object construction, so it's
appropriate to change the instruction name to match the role it
fills rather than the more general role it was hoped to fill.

No functional changes.

Bug 3342343

Change-Id: I65dd6a2c00c99581c9a19b16fe193b70642c8fbb
odeVerify.c
exVerify.c
iveness.c
ptimize.c
df39bb7e9a56686c68cd8929c0ad464348e61832 09-Feb-2011 Carl Shapiro <cshapiro@google.com> Replace dvmValidateObject with ordinary null pointer checks.

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

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

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

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

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

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

Change-Id: I4244e011839f77311fea0570195b3b0df4d84dcf
exPrepare.c
exPrepare.h
ptimize.c
ptimize.h
dff310d9837da4e694342af1d23773093d373a51 14-Jan-2011 Andy McFadden <fadden@android.com> am db3c9225: am d5dae2a4: Merge "Fix invoke-interface verification failures" into honeycomb

* commit 'db3c9225ce1cb2af645958a517233787899c2cfe':
Fix invoke-interface verification failures
c957f639ae11f4b8bf5e2dc5d01b3ef63afbcfc8 14-Jan-2011 Andy McFadden <fadden@android.com> Fix invoke-interface verification failures

A regression introduced in bug 3329492 was causing exceptions to be
thrown immediately (during class initialization) rather than when the
problem was actually hit.

Bug 3345814.

Change-Id: I0a6b36a226b70f7a7da4384fe46095b45f004300
ptimize.c
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
ptimize.c
e203aed65a74d7521ff93a033d58d24124ae643a 07-Jan-2011 Andy McFadden <fadden@android.com> Merge "Fix JNI GetMethodID on interfaces" into dalvik-dev
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
ptimize.c
71eee1f0c2eb514585fdbee16730c9c2209e8f68 04-Jan-2011 jeffhao <jeffhao@google.com> Added vm support for new jumbo opcodes.

This enables jumbo opcodes by default, and they will get used by the
current build without modification. Support has been added for arm, x86,
and the portable interpreter. x86-atom support is on the TODO list. This
commit also includes a test for the new jumbo opcodes.

Change-Id: Ic3f1b41b51645861c5196f76aaf0e96e727ea537
odeVerify.c
exVerify.c
iveness.c
dce27e5a9bed6db6a032343fcfb36ef9ccb3e34e 18-Dec-2010 Andy McFadden <fadden@android.com> Factor debug locals into liveness.

If the debugger asks for a reference held in a local variable, we know
that the reference is valid because the stack is part of the root set.
With liveness analysis, it's possible for a local to be considered dead
and get GCed. Since we don't currently have a way to deal with that
in the debugging code, we just mark debugger-visible locals as live.

Bug 2534655

Change-Id: I5b217f20a76364f1f6a89499058de6ec4eb07b7d
iveness.c
iveness.h
e9224fbea5e7aaa120847aac9d1fe9f38cad9222 18-Dec-2010 Andy McFadden <fadden@android.com> Rename BackwardFlow --> Liveness

Changed my mind.

Change-Id: I16cdba8ba20a4dc60db5fbd70e591fb375c48008
ackwardFlow.c
ackwardFlow.h
odeVerify.c
iveness.c
iveness.h
9fd527f3258381b33365cb18fd37c7864e2bbb40 11-Dec-2010 Andy McFadden <fadden@android.com> Progress on live-precise GC.

This implements computation of register liveness. This is still a work
in progress. The computation is disabled by default, and when enabled
it's not yet used during the generation of register maps. The code
has not been thoughly tested.

While working on this I fiddled around with the verifier's verbose
debugging stuff a bit.

This also changes some stuff in BitVector. Unsigned ints are now
prevalent, and functions like dvmSetBit abort rather than returning a
boolean value when an illegal operation is attempted. (Some parallel
functions in the compiler were also updated.)

Bug 2534655

Change-Id: Iea161c6d63a310e1dbdac2aeeb7b7aeadda8807c
ackwardFlow.c
ackwardFlow.h
odeVerify.c
odeVerify.h
erifySubs.c
erifySubs.h
fyBasicBlock.c
fyBasicBlock.h
e91b6e1f666cf2d032971b190205d6574e631be9 11-Dec-2010 Andy McFadden <fadden@android.com> Minor tweaks.

Clean up replaceFailingInstruction() a little. In particular, use
the appropriate method for extracting the opcode, and assert that
the instruction we're replacing was marked "can throw" (if it wasn't,
the list of predecessors in the catch handler will be wrong). Also
remove a declaration that became redundant when we started replacing
instructions in place (as opposed to making a copy of the method body).

Strip out a bit of stale #if 0 code.

Change-Id: Iccf80647237672e2da4b1b46ca9627ae3344704d
odeVerify.c
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
odeVerify.c
odeVerify.h
exVerify.c
erifySubs.c
erifySubs.h
fyBasicBlock.c
fyBasicBlock.h
fc75f3ed87b55d625b6054e18645da5cbdba31c6 07-Dec-2010 Carl Shapiro <cshapiro@google.com> Fix implicit conversions, rename reserved works, enable -Wc++-compat.

Change-Id: I06292964a6882ea2d0c17c5c962db95e46b01543
odeVerify.c
exPrepare.c
ptimize.c
egisterMap.c
egisterMap.h
90f15431b24a4004fab2db70f273155fcd1c42a4 03-Dec-2010 Dan Bornstein <danfuzz@android.com> Make opcode 00ff be called "dispatch-ff".

With this change, it's still implemented as an unused opcode, but
it's now ready for its new life!

Change-Id: Ic70d311704925067e47d87b657d133a792144e65
odeVerify.c
exVerify.c
e485276c6ba778cafa373b3b5c867f84e91b0bfd 02-Dec-2010 Dan Bornstein <danfuzz@android.com> Rename some instruction/opcode types and utilities.

A lot of this is more about properties of opcodes as opposed to
inspecting instructions per se, and the new naming attempts to
make it clear what is being queried and what sort of data is being
returned.

Change-Id: Ice6f9f2ebf4f1cfa8c99597419aa13d1134a33b2
odeVerify.c
exVerify.c
ptimize.c
5638f4d459d0b3b84d4086ea7e20b8f26e7b44bd 02-Dec-2010 Andy McFadden <fadden@android.com> Fix monitor verification.

An earlier change inadvertently disabled the basic register type check
when the fancier checks were disabled. This restores the type check,
and replaces a "TODO: add an assert" with an actual assert.

Bug 3246598.

Change-Id: I842c392e1e3aa8525235d873726c840f39703ff3
odeVerify.c
9a1f81699cc05b58378ffb9aadb4e97677943791 02-Dec-2010 Dan Bornstein <danfuzz@android.com> It's "opcode" not "opCode".

Similarly "Opcode" not "OpCode".

This appears to be the general worldwide consensus on the matter. Other
residents of my office didn't seem to mind one way or the other how it's
spelled in our code, but for whatever reason, it really bugged me.

Change-Id: Ia0b73d19c54aefc0f543a9c9451dda22ee876a59
odeVerify.c
exVerify.c
ptimize.c
f7576b296b88cbe13b86464efbbebbca5cff22ba 29-Nov-2010 Andy McFadden <fadden@android.com> Minor tweaks.

Use dexOpCodeFromCodeUnit instead of (*insns & 0xff). (Not strictly
necessary in its current incarnation, but the code will soon be checking
opcode flags.)

Mark some local functions "static".

Make instruction widths >= 65536 a warning rather than an error. I
don't think you can get there with converted Java bytecode because of
the method size limit, but it's possible in directly-generated DEX.

Change-Id: Ic9714b855c606f8b5c618793b271436e1c2cdc44
odeVerify.c
odeVerify.h
exVerify.c
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
odeVerify.c
odeVerify.h
exPrepare.c
exVerify.c
exVerify.h
5016966b91f1bc36b2bd52ec13ecfd8de1c68209 22-Nov-2010 Elliott Hughes <enh@google.com> Add dvmHumanReadableDescriptor function, and use it.

We were abusing the fact that dvmDescriptorToDot, which is actually meant
for the class loading machinery, produces more readable output than a
regular descriptor. This patch adds a dvmHumanReadableDescriptor function,
switches all the relevant callers over to it, and and reuses the code that
was already in HprodClass.c.

This means we now say "java.lang.String[]" instead of "[Ljava.lang.String;".

Note that the old hprof code would have left "I" unchanged; I modified it
to translate "I" to "int" (et cetera). This was probably an oversight because
primitive scalars can't appear on the heap, so hprof had no need to format
those types (just arrays of primitives, which it got right).

Bug: 3216276
Change-Id: I63f32a2b020674dfa62ce198ff2699ec01857540
odeVerify.c
erifySubs.c
7c02a97a7ea688f77fa219bd122870dd30a6bbf0 19-Nov-2010 Dan Bornstein <danfuzz@android.com> Verification no longer requires startup/shutdown.

Change-Id: I634f8712295b8ed500092310a2f5bcdc9ff39112
exVerify.c
exVerify.h
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
odeVerify.c
exVerify.c
543223954993a19fa96670692bc7aa55d851966b 17-Nov-2010 Dan Bornstein <danfuzz@android.com> Use the generated opcode info tables.

This is, once again, an intermediate step. Soon, I'm going to try to
remove need to keep and pass copies of the opcode info pointers all
over the place.

Change-Id: Ic6af849310b22ca604a7f2d18c78ff8d112459b4
odeVerify.c
exVerify.c
ptimize.c
319a33bf2d40e11a0074952d537584a0332b8e45 10-Nov-2010 Andy McFadden <fadden@android.com> Progress toward structured lock checks

This change replaces the old array-of-arrays with an array of structs
that have a pointer to the register array. The struct will soon also
hold the additional data required to perform structured lock checks,
which confirm that every monitor-enter instruction is paired with
a monitor-exit. (Prototype fields have been added but are currently
unused.)

No change in behavior is expected, although verification of the
bootstrap classes does take about 5% longer now.

Bug 2534655

Change-Id: Idf25f9a72c5e6cdefe201eebe7c3f5a37064ffca
odeVerify.c
odeVerify.h
egisterMap.c
a0929372ae4996cde3aece52f98128a957166ffc 12-Nov-2010 Andy McFadden <fadden@android.com> Stop reporting negative widths.

At one point, returning a negative width for dexopt output was useful.
That stopped being the case a long time ago.

This also removes a bad assert that went into my previous checkin.

Change-Id: I18880c2316f5499a09dc479d271ca70b2a5be259
odeVerify.c
exVerify.c
ptimize.c
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
odeVerify.c
exVerify.c
ptimize.c
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
odeVerify.c
exPrepare.c
exVerify.c
exVerify.h
egisterMap.c
erifySubs.c
d325011fc98e0f1179d467bbc284cccea72f560b 03-Nov-2010 Andy McFadden <fadden@android.com> Shift register index tests to static pass.

This rather hefty change moves the range tests on register index values
from the code-flow pass to the earlier static analysis pass. The idea
is to test everything up front so that we don't have to do a bounds
check every time we get or set a register value during verification.

This allowed some simplification in the code-flow pass, since get/set
of a register no longer needs to have the method register count passed
in, and can no longer fail due to bad input.

As part of doing this, some of the static verification code was
cleaned up, e.g. the instruction decoding is now only done in one place.

This had no apparently effect on performance on nexus one -- verify+opt
of the bootstrap classes takes the same amount of time. However, it
does reduce the compiled size of the humongous instruction verification
method by about 10%.

Also, cleaned up some instruction format stuff (e.g. removed 3rfs).

Bug 2534655.

(cherry-pick from dalvik-dev)

Change-Id: I1b220f4e97b1214ed575470695c52e1bd64d5137
odeVerify.c
exVerify.c
erifySubs.c
erifySubs.h
c2d74ddc6fa38ea28b2984f32f41a92e18243009 26-Oct-2010 Andy McFadden <fadden@android.com> Correct verifier merging of primitive arrays

Merging of primitive array types (e.g. float[][] + String[]) was being
handled by the general-purpose type merge, which was determining the
result to be an Object. It should have been an Object[].

This changes the verifier to treat arrays of primitive as arrays, but
with one fewer dimension.

Bug: 3130586
Change-Id: I35a6c27256f69f142fa2a8c22bc5f995096c9ae1
odeVerify.c
2446f44302dacac8b68fc443b6fb41833653ab34 21-Oct-2010 Patrick Scott <phanna@android.com> Fix debug statements.

Shows up without NDEBUG.

Change-Id: I1270266369beb783242283af60ee268118c8fb3d
exPrepare.c
7e08546def661fc0f629d8462aae2db88c1a9708 11-Oct-2010 Andy McFadden <fadden@android.com> am c7fb06ef: am 5276cccb: Verify method invocation type.

Merge commit 'c7fb06efb576b7ff0295dd70c8beaeea11918645'

* commit 'c7fb06efb576b7ff0295dd70c8beaeea11918645':
Verify method invocation type.
5276cccb15b6ce0133c8107ff9ff013b4a176ef7 10-Oct-2010 Andy McFadden <fadden@android.com> Verify method invocation type.

Dalvik provides five different ways to invoke a method (virtual, super,
direct, static, interface). Using a virtual invoke instruction to call
a direct method will not produce the desired results.

This adds a test to the verifier that ensures the method targeted by
an invocation instruction is of an appropriate kind.

Bug 3082885.

(cherry-pick from dalvik-dev)

Change-Id: I3237cbefc7314f0b9d7557fc0bfd2b548ea30938
odeVerify.c
2f92dcdc05f3c4c1bd7d67786f56393308813f1e 01-Oct-2010 Andy McFadden <fadden@android.com> am 33ff9f32: am d8b5f50d: Correct dexopt for uniprocessors.

Merge commit '33ff9f32d460a232729a123617ca81b3f67195c6'

* commit '33ff9f32d460a232729a123617ca81b3f67195c6':
Correct dexopt for uniprocessors.
d8b5f50d0c6c9a0ce157e89df4ee1e8eb8b334c3 30-Sep-2010 Andy McFadden <fadden@android.com> Correct dexopt for uniprocessors.

The SMP flag was defaulting to "true" for dexopt, even on uniprocessors.
With this change the VM now has three choices: dexopt for SMP, dexopt
for uniprocessor, or dexopt for current system. The last is used for
just-in-time dexopt (used by -eng and -userdebug builds on bootstrap DEX
files) and installd dexopt (used for apps on all builds).

The dexopt used by the build system during -user builds will either be
explicitly SMP or explicitly uniprocessor, since "current system" has
no meaning when you're cross-dexopting.

Also, unified the dexopt control flags into a single enum.

(cherry-pick from dalvik-dev)

Change-Id: Id1d9c548ca8567585a28ef9ee911cc2ac6b116dd
exPrepare.c
exPrepare.h
d53caae351e40f877a7bcf592a31594ac2be9691 29-Sep-2010 Dan Bornstein <danfuzz@android.com> am b3a94965: am 148283d7: Plumb SMP optimization control through to dexopt.

Merge commit 'b3a949656a773953a44b148a6cdcba19f1c48e87'

* commit 'b3a949656a773953a44b148a6cdcba19f1c48e87':
Plumb SMP optimization control through to dexopt.
481c25391ef818539b2fbbe682dc873965af5306 29-Sep-2010 Andy McFadden <fadden@android.com> am 63114829: am de9cdfa9: Fix verification of switch offsets in large methods.

Merge commit '63114829802ecdade4c95fe08a02acec67bd17bd'

* commit '63114829802ecdade4c95fe08a02acec67bd17bd':
Fix verification of switch offsets in large methods.
148283d71a7e35b9b506cbb49294b6822719c25e 29-Sep-2010 Dan Bornstein <danfuzz@android.com> Plumb SMP optimization control through to dexopt.

Change-Id: I3bfaf6723e7b14d001f9de60cc1c1fd4f8e1ed99
exPrepare.h
de9cdfa9d6d5fa5c46a0ec0f3f1e8de08a688841 28-Sep-2010 Andy McFadden <fadden@android.com> Fix verification of switch offsets in large methods.

The verifier was only using the low 16 bits when checking the offset
to a switch table. This was failing on really large methods.

We also blew up the arbitrary size cap again, so I made it a warning
rather than a failure (it really wasn't doing anybody any good).

Changed to width-specific types for the various offsets and sizes.

Bug 3044850.

(cherry-pick+squash from dalvik-dev)

Change-Id: Ic7ebb86728cb39151f617a3e69e1c1994e61b5d9
odeVerify.c
erifySubs.c
fe700260881c8f59ee2f2dc2308aef3b0cc39734 15-Sep-2010 Elliott Hughes <enh@google.com> Check at startup that we can resolve all the inline natives.

Also fix a bug where we'd dereference NULL if an inline native's class failed
to resolve.

Also merge this method lookup with Optimize.c's (superior) near-duplicate.

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

Change-Id: I3c030a6b19416a2ac3ca709cdbcbc6b41e6379d3
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
exPrepare.c
3f4b63f47f50f200538e83fa3fac06947afa08b4 13-Sep-2010 Andy McFadden <fadden@android.com> Emit return-void-barrier when appropriate.

If SMP is enabled, and we're optimizing a constructor, and the
class in question has final fields, we replace all occurrences of
"return-void" with "return-void-barrier".

This is an "essential" optimization for SMP, meaning it will be done
regardless of the verification/optimization settings.

Also, split the updateCode() helper function into two versions (one
to update the whole 16-bit code unit, one to replace just the opcode).

Also, make the presence of a duplicate class in the bootstrap class
path a failure for optimization as well as verification. Otherwise,
if you have "-Xdexopt:all", you could end up trying to optimize a
class loaded from a bootstrap DEX file, which doesn't work well
since those classes are mapped read-only in dexopt.

Bug 2965743.

Change-Id: I29e67133731b59beb6af5003f3cd69302c5c20f5
exPrepare.c
ptimize.c
291758c5c4902900c6f86794ba8ab9cad9b26197 10-Sep-2010 Andy McFadden <fadden@android.com> Add return-void-barrier instruction.

This introduces the return-void-barrier instruction, which is identical
to return-void on UP systems, but provides an additional store/store
barrier on SMP. This is intended for use in constructors of objects
with final fields.

The assembler doesn't like "dmb st", and we don't have an
ANDROID_MEMBAR_STORE barrier defined, so this currently uses full
fences.

This just defines the new instruction. It's not actually used yet.

Also, removed some stale "unused" files from the x86 and x86-atom
directories.

Bug 2965743.

Change-Id: I072e372fd2d57f2617a8d4fff5fd4b38bdda75d1
odeVerify.c
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
ptimize.c
a3096e3ed510442a14e43a88c9355dc4adbcf427 10-Sep-2010 Dan Bornstein <danfuzz@android.com> am 611f0c0b: am 070fceca: am d394371b: Remove the functionality in ReduceConstants.[ch].

Merge commit '611f0c0b5075be16c517431354db4a3facd5a5ef' into dalvik-dev

* commit '611f0c0b5075be16c517431354db4a3facd5a5ef':
Remove the functionality in ReduceConstants.[ch].
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
ptimize.c
d394371bd84bacc51e96e2d2eacb8549d9110b1e 09-Sep-2010 Dan Bornstein <danfuzz@android.com> Remove the functionality in ReduceConstants.[ch].

It was a good experiment to try, but it was never made production-ready,
and it doesn't look like it would be a net win at this point. We
metaphorically pour out a beer in its honor.

Change-Id: I7f6ac95f5b7c963df0a3015ed33595fa1a928636
exPrepare.c
educeConstants.c
educeConstants.h
e377ef62a40267ab16c2dd20cc5f4c63af6397cc 01-Sep-2010 Dan Bornstein <danfuzz@android.com> Split out the optimized dex file handling into its own file.

Also, make the optimized dex data area be consistently referred to as
the "opt" section instead of sometimes the "aux" section.

Change-Id: Id5589c13ce4b53d713f8186314ea886cd884c865
exPrepare.c
e7ad112562af04d825fdd0d403deaf0ddd70a2ea 17-Aug-2010 Andy McFadden <fadden@android.com> Nudge a couple of log messages.

Also, don't show errno on a short read.

Related to bug 2916809.

Change-Id: I163906d47b698ac5e77202c323db5823196169bb
exPrepare.c
c650d2beb66896c0cf51f737d7a39476630dd142 17-Aug-2010 Andy McFadden <fadden@android.com> Added fsync call to dexopt.

If various system-level things go wrong you might end up with a
correctly-written .odex header but an incomplete file, which ideally
would never happen. This adds an fsync() call before we write the
header to make this less likely.

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

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

See also bug 2781881.

Change-Id: I58041572f6cf9308a8a125200dc419ce9d3d8d12
ptimize.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
odeVerify.c
exPrepare.c
ptimize.c
ptimize.h
8b31f73c2d72cfac18125f15bc69a74d3204389b 25-Jun-2010 Jesse Wilson <jessewilson@google.com> Extending the maximum length of a boot classpath.

Running dalvikvm on a simulator causes path lengths to grow longer
because '/system' is prefixed with the full path to the android build
tree.
exPrepare.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
odeVerify.c
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
odeVerify.c
odeVerify.h
exPrepare.c
exVerify.c
exVerify.h
ptimize.c
egisterMap.c
egisterMap.h
erifySubs.c
d50850632c85795f82db9ec10e76c0e3a18811d0 14-Jun-2010 Andy McFadden <fadden@android.com> am 48184679: am c12b0da0: am e0b23da8: Merge "Tweak sanity check." into gingerbread

Merge commit '48184679e8caa9d4c637187cd94f59d38929ac7a' into dalvik-dev

* commit '48184679e8caa9d4c637187cd94f59d38929ac7a':
Tweak sanity check.
48184679e8caa9d4c637187cd94f59d38929ac7a 14-Jun-2010 Andy McFadden <fadden@android.com> am c12b0da0: am e0b23da8: Merge "Tweak sanity check." into gingerbread

Merge commit 'c12b0da035901923893f50663c48cb4efd390712'

* commit 'c12b0da035901923893f50663c48cb4efd390712':
Tweak sanity check.
6be954f498fe5ef425b231f9afd50b94f1ecc73f 14-Jun-2010 Andy McFadden <fadden@android.com> Tweak sanity check.

Somebody managed to overrun this.

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

Change-Id: I1e3d103a7b932ef21acedb6438c0f26b315df28f
odeVerify.c
exPrepare.c
exVerify.c
ptimize.c
educeConstants.c
egisterMap.c
erifySubs.c
de75089fb7216d19e9c22cce4dc62a49513477d3 09-Jun-2010 Carl Shapiro <cshapiro@google.com> Remove trailing whitespace.

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

Change-Id: I0c0edb3ebf0d5e040d6bbbf60269fab0deb70ef9
odeVerify.c
exOptimize.c
exOptimize.h
exPrepare.c
exPrepare.h
exVerify.c
ptimize.c
ptimize.h
educeConstants.c
egisterMap.c
erifySubs.c
erifySubs.h
b89bd11119b9981f4e5e4db840e580bb228f290c 28-May-2010 Andy McFadden <fadden@android.com> Branch-to-self is a backward branch.

Teach the verifier to identify branch-to-self as a backward branch,
which makes the instruction a GC point and worthy of a register map.

For bug 2702514.

Change-Id: Id5b26220db8008adbb2b5b7f69894a7704a0b559
exVerify.c
4b0750e8df91220690bb417f45d7ae8b7851b220 27-May-2010 Dan Bornstein <danfuzz@android.com> Fix two dex file structural verification issues.

First, structural verification failed to check for inconsistencies with
the number of arguments to methods compared to the number of registers
declared by those methods.

Second, neither the dexdump nor dexlist tools would run structural
verification.

As an added bonus, I renamed the function that performs byte swapping
and structural verification to be more descriptive about what it
does.

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

Change-Id: Icbe24eaf1ad499f28b68b6a5f05368271a0a7e86
odeVerify.c
exPrepare.c
exVerify.c
ptimize.c
educeConstants.c
egisterMap.c
erifySubs.c
64896a2543ee54e47c586f4cf26f54e7fdb366bd 05-May-2010 Andy McFadden <fadden@android.com> Write until we fall over.

Implement enh's idea about repeating write() until it fails. Use it
in the zip expander and dexopt, which have an above-average chance of
failing due to lack of disk space.

Replace a stray DEFAULT_PAGE_SIZE with SYSTEM_PAGE_SIZE. Apparently I
missed that during the Great Page Size Unification.

Change-Id: Id173cb7669330deebe2f24ae23ece4009a90e3bd
exPrepare.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
exVerify.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
exVerify.c
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
exPrepare.c
exVerify.c
ptimize.c
ptimize.h
2e1ee50a08cc3dd07ce4e956b925c1f0f28cf329 24-Mar-2010 Andy McFadden <fadden@android.com> Rearrange some things.

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

Twiddled some comments.

No substantive code changes.

Change-Id: Ia51865b259fb32822132e2373997866e360ca86a
odeVerify.c
exOptimize.c
exOptimize.h
exPrepare.c
exPrepare.h
ptimize.c
ptimize.h
erifySubs.h
980ffb0243a1840ad0a93cfa06dfc02ca6f2d01c 14-Mar-2010 Carl Shapiro <cshapiro@google.com> Replace free calls to the pthread mutex lock, unlock, and trylock
functions with calls to the error checked wrapper functions. This
ensures that all mutex operations are checked in debug builds.

Change-Id: I4a5f181e025a2974f3325bcd9efa861eb6a92978
egisterMap.c
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.
odeVerify.c
exOptimize.c
5387824f19033ed51a945fbc8c2b574998404b3d 05-Mar-2010 Andy McFadden <fadden@android.com> Add instructions for volatile wide fields.

This adds four new instructions for accessing volatile wide fields (long
and double). The JLS requires that such accesses are atomic, but the
VM doesn't otherwise make guarantees about the atomicity of reads and
writes on 64-bit fields.

There are no behavioral changes. This just adds definitions for the new
instructions and a couple of tests. The current implementation is just
the non-volatile form of the instructions or a C stub, but since we're
not generating them it doesn't really matter yet.

Also:
- bumped Dalvik version to 1.3.0
- added a note to the x86-atom TODO list

For bug 1633591.
odeVerify.c
egisterMap.c
7d18e38e260d79df8144908b28033b800d5d7470 04-Dec-2009 Andy McFadden <fadden@android.com> Added additional DEX checksum.

We have a checksum on the base DEX data, but not on the stuff that
dexopt appends. If a flash block goes "funny" we might not be able to
detect the problem. This change adds a checksum field to the
"optimized" header.

The new checksum is verified under the same circumstances as the base
DEX checksum: when you use "dexdump", and when you enable additional
checking with -Xcheckdexsum (or the property dalvik.vm.check-dex-sum
is set to "true").

For bug 2255640.
exOptimize.c
869898f16f414a63187cd736e375fe32aae41f0f 24-Nov-2009 Andy McFadden <fadden@android.com> Fix an assertion.

The assertion probably dated from before the binary-search path existed.
egisterMap.c
b0a0541b59d1126ff77c88de742b4a74579fe296 19-Nov-2009 Andy McFadden <fadden@android.com> Add execute-inline/range instruction.

Like "execute-inline", this is an instruction generated by dexopt that
replaces a method invoke instruction. It's useful for small, frequently
called methods in the core libs.

As with execute-inline, we allow at most 4 arguments, but with /range
we're no longer limited to the low 16 registers.

Also: marked execute-inline as being able to throw an exception.

Needed: native x86 implementation; support in JIT.

For bug 2268232.
odeVerify.c
exOptimize.c
egisterMap.c
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.
odeVerify.c
exVerify.c
egisterMap.c
a915b67335c1ffd78927eecd7023fc3d08e3e93f 24-Sep-2009 Andy McFadden <fadden@android.com> Fix gcc complaint.
egisterMap.c
ec628b5b580f00339d971107b8370960e55ea94f 20-Sep-2009 David 'Digit' Turner <digit@google.com> Allow dalvik pre-optimization to run in ARMv7 emulator.

This sad hack is used to allow the Dex preopt pass to run properly
in ARMv7 emulation mode. Without it, the function dvmComputeWidths()
aborts the VM in ways that are hard to properly understand.

This issue has been discussed extensively with fadden, which provided
the patch. It seems that adding both log lines fixes it, but only using
one will not. I'm suspecting an emulation bug, or even worse, a C compiler
bug that would generate invalid machine code.

NOTE: The dex pre-optimization pass of user builds requires to run
the DexOpt in the emulator for all -user builds. While this patch
might not fix the underlying issue, it allows us to generate these
images correctly (along with a few other system hacks).
erifySubs.c
af0e838887d3a2fa76e0d2716e39adf2bb0c01a1 28-Aug-2009 Andy McFadden <fadden@android.com> Fix reporting of certain verify errors.

The code was assuming that the reference type could always be inferred
from the error code, but in two cases it couldn't. This resulted in a
weird string appearing where the class name should be in the exception.
The type is now explicitly stuffed into the replacement instruction.

I added one additional test to 075; with this, plus 003 and 077, I think
we have full coverage.

For bug 2084560.
odeVerify.c
exOptimize.h
a66a01ad2a9e5c6aefc93d12a5c18d6bba570a3e 19-Aug-2009 Andy McFadden <fadden@android.com> Turn down RegisterMap paranoia.

This disables verification of RegisterMap contents and compressed
output, as well as a GC-time check that double-checked the validity of a
register known to hold a reference.

For internal bug 1896437.
egisterMap.c
734155efc18543eab20b763f9a315ab1a44240ac 17-Jul-2009 Andy McFadden <fadden@android.com> Indirect reference table implementation.

This change introduces the "indirect" reference table, which will be
replacing ReferenceTable for local and global JNI references. The key
difference is that, instead of handing raw Object pointers to JNI, we
will be giving them a magic value that can be converted back to an
Object. The goal is to avoid having to pin every object that native
code is aware of.

The code is not actually used anywhere yet.

Also bundled up here:
- added detail to a log message
- fixed a string format issue in the internal assert() definition
- very minor optimization in "remove" function in ReferenceTable
- quiet a gcc complaint
- only include the hash table regression test in builds that invoke it
egisterMap.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.
exOptimize.c
23e84b1055fd9626153d28d7799b2d99cbc57967 18-Jun-2009 Andy McFadden <fadden@android.com> Bump the VM version.

This should have been incremented when OP_THROW_VERIFICATION_ERROR was
added, since older VMs won't be able to handle the odex we generate.

Dropped the log level on the warning.
exOptimize.c
80d25ea84b6fa9342f1432a07ba0d0612ff72e48 12-Jun-2009 Andy McFadden <fadden@android.com> Treat some right shifts as narrowing conversions.

Java bytecode optimizers like ProGuard will remove explicit integer
width conversions from certain sequences. For example, after
right-shifting an integer 24 times, an int-to-byte instruction is
redundant.

This change teaches the verifier that right shifts sometimes reduce
(or at least don't increase) the width of an integer. Previously, the
result of a right shift was always a full-sized int.
odeVerify.c
b5f64bc92510dbe3bd3bfc61314edf43674219f2 10-Jun-2009 Andy McFadden <fadden@android.com> Allow {iput,sput}-boolean on a byte value.

javac generates code that can only be understood as storing a byte value
into a boolean field. The verifier now allows this.
odeVerify.c
86c8643eca135fab0b8e21ba10244f3d6eb4bcf0 27-May-2009 Andy McFadden <fadden@android.com> Correct some things in test 068. Add detail to a verification error message.
odeVerify.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.
odeVerify.c
exOptimize.c
exVerify.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, ...).
odeVerify.c
odeVerify.h
exOptimize.c
exOptimize.h
d9062a6b02e81d9c2d5992788625da95ec2b8605 11-May-2009 Android (Google) Code Review <android-gerrit@google.com> am 96e0f60: Merge change 1369 into donut

Merge commit '96e0f600a6a52aa1424c1e8787fc40c1b3b3f79a'

* commit '96e0f600a6a52aa1424c1e8787fc40c1b3b3f79a':
Updated a comment.
06b7a2876a36a425d2f8caeb2e097fa238b0dcc8 11-May-2009 Andy McFadden <fadden@android.com> Updated a comment.
odeVerify.c
99647fbab2aee5730d277ddb2247709ccd4c95fa 09-May-2009 Andy McFadden <fadden@android.com> Pull the useful part of p9-132414 over to "donut".

This was inspired by some valgrind complaints marcone noticed. The change
is already part of "master".

(I just noticed that the comment isn't quite right, but hopefully if I leave
it alone it'll merge trivially and I can fix it up in a subsequent change.)
odeVerify.c
3a1aedbc9777eab6275a360b93b81b079464238e 07-May-2009 Andy McFadden <fadden@android.com> Added throw-verification-error instruction.

This is for the deferred verifier error reporting. It replaces OP_UNUSED_ED.
The instructions aren't actually used yet, which is good since the x86
version hasn't been written yet.

The mterp regen also pushed out some recent-ish changes that hadn't
propagated to the armv4t sources.
odeVerify.c
exOptimize.h
62a75162b995dc0f800ef0f8726f2855720f8aa8 18-Apr-2009 Andy McFadden <fadden@android.com> Changed the way errors are propagated through the verifier.

Changed the boolean "okay" to a "failure" enumeration. Most failures are
"generic", but some are called out specially. Added a more detailed
failure result from resolver functions.

In theory, no behavior has changed.
odeVerify.c
exOptimize.c
exOptimize.h
b488f71958487cdb06c3c1468b1c7f9e3a00669f 09-Apr-2009 Andy McFadden <> Merge branch 'readonly-p4-master'
f5f370ef5005db7f9af092d6d813c408090c15b4 09-Apr-2009 Andy McFadden <> AI 145331: Shush.

Automated import of CL 145331
egisterMap.c
ac2180528b20383201147e5a9b09af5ae2a67bb1 08-Apr-2009 Andy McFadden <> Merge branch 'readonly-p4-master'
074afd6143d7134bfe16aee3de2f29b739be648d 08-Apr-2009 Andy McFadden <> AI 145086: Use process groups to avoid a collision between dexopt and ProcessManager.
If the ProcessManager thread was waiting for a child process to finish,
it could inadvertently capture the exit status of dexopt. This
confused the VM somewhat. With this change the dexopt child runs in
its own process group, and the ProcessManager only waits for children
in the parent's process group.
I also now create a new process in the DexClassLoader test to check for
clashes. (It's a race, but it nearly always hits on the device, and
occasionally hits on desktop.)
BUG=1777736

Automated import of CL 145086
exOptimize.c
9303642643b5a90a0b47b1af311508a7b5f59722 08-Apr-2009 Andy McFadden <> Merge branch 'readonly-p4-master'
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
egisterMap.c
c4a5112197976eee186fd2e6a740c1dcc0860b4b 29-Mar-2009 The Android Open Source Project <initial-contribution@android.com> Merge branch 'open_source' into google_internal
1035127f783b84befca34f1afe2a5bff64546902 25-Mar-2009 Andy McFadden <> Automated import from //branches/master/...@142073,142073
egisterMap.c
1d47a87b38e41f9957849ba685af1f41e53f8a05 25-Mar-2009 Andy McFadden <> Automated import from //branches/master/...@141837,141837
egisterMap.c
egisterMap.h
d45a88794c6470d96e2139cbe803002d9d5d3a6c 25-Mar-2009 Andy McFadden <> Automated import from //branches/master/...@141645,141645
egisterMap.c
egisterMap.h
99409883d9c4c0ffb49b070ce307bb33a9dfe9f1 19-Mar-2009 The Android Open Source Project <initial-contribution@android.com> auto import //branches/master/...@140412
odeVerify.c
odeVerify.h
exOptimize.c
exOptimize.h
exVerify.c
egisterMap.c
egisterMap.h
erifySubs.h
6964d8bb917798d3296f0b42c15515de7bc81b1c 19-Mar-2009 Jean-Baptiste Queru <jbq@google.com> Merge commit 'remotes/korg/cupcake' into cupcake_to_master
af93f33a83ecbd44b8a946bbad5291a79aadc2e8 04-Mar-2009 Jean-Baptiste Queru <jbq@google.com> Use static const variable for speed. Clarify a comment.

Fixes http://code.google.com/p/android/issues/detail?id=2088
odeVerify.c
exVerify.c
f6c387128427e121477c1b32ad35cdcaa5101ba3 04-Mar-2009 The Android Open Source Project <initial-contribution@android.com> auto import from //depot/cupcake/@135843
odeVerify.c
odeVerify.h
exOptimize.c
exOptimize.h
exVerify.c
exVerify.h
educeConstants.c
educeConstants.h
egisterMap.c
egisterMap.h
erifySubs.c
erifySubs.h
f72d5de56a522ac3be03873bdde26f23a5eeeb3c 04-Mar-2009 The Android Open Source Project <initial-contribution@android.com> auto import from //depot/cupcake/@135843
odeVerify.c
odeVerify.h
exOptimize.c
exOptimize.h
exVerify.c
exVerify.h
educeConstants.c
educeConstants.h
egisterMap.c
egisterMap.h
erifySubs.c
erifySubs.h
077f9d75d9701778830742b9c2afad4742635b58 19-Feb-2009 The Android Open Source Project <initial-contribution@android.com> auto import from //branches/cupcake/...@132276
exOptimize.c
5d709784bbf5001012d7f25172927d46f6c1abe1 11-Feb-2009 The Android Open Source Project <initial-contribution@android.com> auto import from //branches/cupcake/...@130745
odeVerify.c
odeVerify.h
exOptimize.c
exOptimize.h
exVerify.c
exVerify.h
egisterMap.c
egisterMap.h
bcd637a94f10b49d18b87a74a015f9d3453ed77a 22-Jan-2009 The Android Open Source Project <initial-contribution@android.com> auto import from //branches/cupcake/...@127436
odeVerify.c
exOptimize.c
4c1a2915e40eceeb68dbc323d28b8bf8763af83b 20-Jan-2009 The Android Open Source Project <initial-contribution@android.com> auto import from //branches/cupcake/...@127101
odeVerify.c
exOptimize.c
exVerify.c
egisterMap.c
egisterMap.h
erifySubs.c
erifySubs.h
cc05ad238516f1303687aba4a978e24e57c0c07a 10-Jan-2009 The Android Open Source Project <initial-contribution@android.com> auto import from //branches/cupcake/...@125939
odeVerify.c
odeVerify.h
exVerify.c
exVerify.h
egisterMap.c
egisterMap.h
erifySubs.c
erifySubs.h
89c1feb0a69a7707b271086e749975b3f7acacf7 18-Dec-2008 The Android Open Source Project <initial-contribution@android.com> Code drop from //branches/cupcake/...@124589
odeVerify.c
exOptimize.c
exOptimize.h
exVerify.c
educeConstants.c
educeConstants.h
2ad60cfc28e14ee8f0bb038720836a4696c478ad 21-Oct-2008 The Android Open Source Project <initial-contribution@android.com> Initial Contribution
odeVerify.c
odeVerify.h
exOptimize.c
exOptimize.h
exVerify.c
exVerify.h