OSDN Git Service

android-x86/dalvik.git
13 years agoAdd a link to the dex-format doc.
Dan Bornstein [Wed, 1 Dec 2010 06:14:50 +0000 (22:14 -0800)]
Add a link to the dex-format doc.

For ease of clicking around when browsing and easier discoverability
in general.

Change-Id: Ia50507df454dd65526e99ef14194c310bb11edb1

13 years agoMerge "Remove excess generality from the bitmap sweep walking routine." into dalvik-dev
Carl Shapiro [Wed, 1 Dec 2010 05:19:01 +0000 (21:19 -0800)]
Merge "Remove excess generality from the bitmap sweep walking routine." into dalvik-dev

13 years agoRemove excess generality from the bitmap sweep walking routine.
Carl Shapiro [Wed, 1 Dec 2010 04:55:32 +0000 (20:55 -0800)]
Remove excess generality from the bitmap sweep walking routine.

The bitmaps that are passed to the sweep walking routine always have
the same base, bitsLen, and max values.  As such, there is no need to
account for situations where these values may be different.  This is
guarnateed because bitmaps being swept are actually private copies of
the global bitmaps which are initialized with common parameters.

Furthermore, the sweep callback does not change the max values, so we
do not need a clean-up loop to accomodate changes to max.  The sweep
routine operates on garbage objects and therefore has no need to set
bits in a bitmap and, by extension, update the max value.

Also eliminated was an obsolete TODO regarding the unrolling of a
loop.  We will leave that class of optimization to the compiler.

Change-Id: Iff6ede3d0ac68f88d381a06911fb6bd9cada926d

13 years agoBring 00x and 20bc into the fold.
Dan Bornstein [Wed, 1 Dec 2010 00:46:20 +0000 (16:46 -0800)]
Bring 00x and 20bc into the fold.

Change-Id: I12fde7eb665c9f3b75684018457f9464b0990156

13 years agoExplain a bit.
Dan Bornstein [Wed, 1 Dec 2010 00:29:42 +0000 (16:29 -0800)]
Explain a bit.

Change-Id: I845f34924249b6c5f34ad9ef7b9ebd3bc44f1aac

13 years agoinvoke-direct-empty doesn't actually invoke anything.
Dan Bornstein [Tue, 30 Nov 2010 22:58:53 +0000 (14:58 -0800)]
invoke-direct-empty doesn't actually invoke anything.

Update bytecode.txt as well as a couple bits in the JIT in recognition
of this fact.

Change-Id: I989556d39b40a879021eaf841404e015076073be

13 years agoMerge "Punch opcode info access from libcore to the vm." into dalvik-dev
Dan Bornstein [Tue, 30 Nov 2010 22:31:07 +0000 (14:31 -0800)]
Merge "Punch opcode info access from libcore to the vm." into dalvik-dev

13 years agoMerge "Fix DexFile cookie check." into dalvik-dev
Andy McFadden [Tue, 30 Nov 2010 21:55:44 +0000 (13:55 -0800)]
Merge "Fix DexFile cookie check." into dalvik-dev

13 years agoPunch opcode info access from libcore to the vm.
Dan Bornstein [Tue, 30 Nov 2010 20:21:28 +0000 (12:21 -0800)]
Punch opcode info access from libcore to the vm.

I looked at doing this as a native file in libcore, but that seemed to
pull in too many dependencies.

Change-Id: I1753b9b78bc593b9467a877a5fea0ba5d5161cfe

13 years agoFix DexFile cookie check.
Andy McFadden [Tue, 30 Nov 2010 19:29:51 +0000 (11:29 -0800)]
Fix DexFile cookie check.

We use a "cookie" rather than just accepting a raw pointer so that the
VM doesn't crash if something weird gets passed in.  Unfortunately the
cookie verify function was dereferencing the cookie to compute a value
for the hash table lookup, defeating the purpose.  Since we don't deal
with opening the same DEX file in a constructive way, we can just take
the low part of the pointer itself and use that as the hash.  (Hashing
isn't really necessary given the number of DEX files we expect to have
open; mostly it's just a convenient synchronized data structure.)

Bug 3238298

Change-Id: I1a545d4154b58159acdc21809b55b098c1419644

13 years agoClean up the opcode maintenance instructions.
Dan Bornstein [Tue, 30 Nov 2010 18:45:02 +0000 (10:45 -0800)]
Clean up the opcode maintenance instructions.

Change-Id: Ic9d7fcfd234116099ef510e4339a9af0bc3fcb1d

13 years agoMerge "Make the scan and the visit routines look more alike." into dalvik-dev
Carl Shapiro [Tue, 30 Nov 2010 04:05:40 +0000 (20:05 -0800)]
Merge "Make the scan and the visit routines look more alike." into dalvik-dev

13 years agoMake the scan and the visit routines look more alike.
Carl Shapiro [Tue, 30 Nov 2010 01:24:50 +0000 (17:24 -0800)]
Make the scan and the visit routines look more alike.

This code shares a common origin but the implementations eventually
diverged.  Alas, a forthcoming change may cause the scan routines to
permanently diverge from the visitor.  Until that happens, we should
try to keep these routines as similar as possible.

Change-Id: Icf95b3bb4db704c8c7b4ab5aab84d9e091675bab

13 years agoMerge "Code to generate libcore's Dalvik opcode code." into dalvik-dev
Dan Bornstein [Tue, 30 Nov 2010 00:54:40 +0000 (16:54 -0800)]
Merge "Code to generate libcore's Dalvik opcode code." into dalvik-dev

13 years agoCode to generate libcore's Dalvik opcode code.
Dan Bornstein [Tue, 30 Nov 2010 00:47:09 +0000 (16:47 -0800)]
Code to generate libcore's Dalvik opcode code.

That was a mouthful.

Change-Id: I49152fdacbfa9593e7a95f5c120fea023b06d03b

13 years agoMerge "Verifier doc addendum." into dalvik-dev
Andy McFadden [Mon, 29 Nov 2010 22:35:48 +0000 (14:35 -0800)]
Merge "Verifier doc addendum." into dalvik-dev

13 years agoVerifier doc addendum.
Andy McFadden [Mon, 29 Nov 2010 22:23:46 +0000 (14:23 -0800)]
Verifier doc addendum.

Added note about hand-over-hand locking.

Change-Id: I9912e87f2585c3d225b93e037c04f9bf7e2cff14

13 years agoMerge "Fixed identification of objects in the Constant Collector." into dalvik-dev
jeffhao [Mon, 29 Nov 2010 18:47:28 +0000 (10:47 -0800)]
Merge "Fixed identification of objects in the Constant Collector." into dalvik-dev

13 years agoFixed identification of objects in the Constant Collector.
jeffhao [Mon, 22 Nov 2010 19:53:41 +0000 (11:53 -0800)]
Fixed identification of objects in the Constant Collector.

The constant collector was improperly identifying constant objects,
keying off the move-result-pseudo instruction that gets the result
instead of the const-string/class instruction that generates the
result. The new code fixes this, so that the following block of code
detects that the const-string/class instruction can throw and will
properly ignore objects. Before, since move-result-pseudo can't throw,
it would skip past that block and try to collect the object anyway.

Change-Id: Ia0a8b07cbe5ece8f586581b86e8507d29a2b9e02

13 years agoCPU errata workaround.
Andy McFadden [Wed, 24 Nov 2010 19:04:36 +0000 (11:04 -0800)]
CPU errata workaround.

Added #ifdefs to avoid the use of conditional loads on certain CPUs.

Bug 3216139

Change-Id: Ic014daf9de59a5697d68ac092724e17b2bcb0f42

13 years agoMerge "Check monitors during bytecode verification" into dalvik-dev
Andy McFadden [Tue, 23 Nov 2010 22:42:55 +0000 (14:42 -0800)]
Merge "Check monitors during bytecode verification" into dalvik-dev

13 years agoam abf3ef82: Fix off-by-1 bug in expandable bit vectors.
Ben Cheng [Tue, 23 Nov 2010 21:16:22 +0000 (13:16 -0800)]
am abf3ef82: Fix off-by-1 bug in expandable bit vectors.

* commit 'abf3ef8206de388c7fc5f529f3ee05419475b651':
  Fix off-by-1 bug in expandable bit vectors.

13 years agoCheck monitors during bytecode verification
Andy McFadden [Sat, 13 Nov 2010 00:55:21 +0000 (16:55 -0800)]
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

13 years agoFix off-by-1 bug in expandable bit vectors.
Ben Cheng [Tue, 23 Nov 2010 19:55:16 +0000 (11:55 -0800)]
Fix off-by-1 bug in expandable bit vectors.

Bug: 3224068
Change-Id: I6e5e956da380262e65cb1da9bcc51ba31f5b0d14

13 years agoAdd dvmHumanReadableDescriptor function, and use it.
Elliott Hughes [Mon, 22 Nov 2010 21:14:23 +0000 (13:14 -0800)]
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

13 years agoMerge "Protect against bogus arrays." into dalvik-dev
Dan Bornstein [Sat, 20 Nov 2010 01:27:18 +0000 (17:27 -0800)]
Merge "Protect against bogus arrays." into dalvik-dev

13 years agoMerge "Better ArrayStoreException detail messages." into dalvik-dev
Elliott Hughes [Sat, 20 Nov 2010 01:25:57 +0000 (17:25 -0800)]
Merge "Better ArrayStoreException detail messages." into dalvik-dev

13 years agoProtect against bogus arrays.
Dan Bornstein [Sat, 20 Nov 2010 01:13:13 +0000 (17:13 -0800)]
Protect against bogus arrays.

VMDebug.getInstructionCount() used to rely on the fact that its
argument would be passed in as non-null and be of an appropriate
length. Now, it's paranoid.

Change-Id: I8abb3d50227073cdd43007a7708987865651ec48

13 years agoBetter ArrayStoreException detail messages.
Elliott Hughes [Sat, 20 Nov 2010 00:35:05 +0000 (16:35 -0800)]
Better ArrayStoreException detail messages.

This fixes the portable interpreter, ARM, and x86. System.arraycopy was already
doing the right thing.

Bug: 3216051
Change-Id: I8a675eb62d6e7fd53a009f53ce8e34f93799b18c

13 years agoSay kNumDalvikInstructions when appropriate.
Dan Bornstein [Sat, 20 Nov 2010 00:01:25 +0000 (16:01 -0800)]
Say kNumDalvikInstructions when appropriate.

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

Change-Id: Icc77120c2673968dddd6b4003f717245d46e4159

13 years agoKill off InsnFormat.nextUp().
Dan Bornstein [Fri, 19 Nov 2010 22:15:17 +0000 (14:15 -0800)]
Kill off InsnFormat.nextUp().

This method used to be used during instruction selection, but hasn't
been used since the bytecode.txt file got updated to include format
chains.

Change-Id: Iee827c8b8008a88d56326aecf249299fe92101e1

13 years agoVerification no longer requires startup/shutdown.
Dan Bornstein [Fri, 19 Nov 2010 21:54:00 +0000 (13:54 -0800)]
Verification no longer requires startup/shutdown.

Change-Id: I634f8712295b8ed500092310a2f5bcdc9ff39112

13 years agoGet rid of the copies of the opcode table pointers.
Dan Bornstein [Fri, 19 Nov 2010 20:36:19 +0000 (12:36 -0800)]
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

13 years agoMerge "Use the generated opcode info tables." into dalvik-dev
Dan Bornstein [Fri, 19 Nov 2010 18:29:14 +0000 (10:29 -0800)]
Merge "Use the generated opcode info tables." into dalvik-dev

13 years agoBetter ClassCastException detail messages for x86.
Elliott Hughes [Thu, 18 Nov 2010 23:23:49 +0000 (15:23 -0800)]
Better ClassCastException detail messages for x86.

Bug: 3210374
Change-Id: I5b6ff68b611f56276ef6e519511ed4dee22b0136

13 years agoMerge "Include both types in ClassCastException detail messages." into dalvik-dev
Elliott Hughes [Thu, 18 Nov 2010 20:21:10 +0000 (12:21 -0800)]
Merge "Include both types in ClassCastException detail messages." into dalvik-dev

13 years agoInclude both types in ClassCastException detail messages.
Elliott Hughes [Thu, 18 Nov 2010 19:49:04 +0000 (11:49 -0800)]
Include both types in ClassCastException detail messages.

Along the lines of "java.lang.Exception cannot be cast to java.lang.String".

This is ARM and portable interpreter only. x86 will come later.

Bug: 3210374
Change-Id: I48719dbdb569bbc3be2a31d0e5507b8dc42101b3

13 years agoUse the generated opcode info tables.
Dan Bornstein [Wed, 17 Nov 2010 22:16:56 +0000 (14:16 -0800)]
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

13 years agoGenerate the tables in InstrUtils.c...almost.
Dan Bornstein [Wed, 17 Nov 2010 20:05:04 +0000 (12:05 -0800)]
Generate the tables in InstrUtils.c...almost.

This patch adds code to opcode-gen to generate the opcode info tables
currently built at vm start time, but they are left commented out for
now. I wanted to separate the work of getting these tables generated
from the work of getting those new tables hooked up, and this seemed
like a reasonable way to cut through the larger effort.

To be clear, I've already verified that the data in the new
pregenerated tables matches what's in the status quo.

Change-Id: Ie73dc6c6a5721e8f714f845c97b5338141995770

13 years agoGenerate the contents of OpCodeNames.c.
Dan Bornstein [Tue, 16 Nov 2010 23:54:10 +0000 (15:54 -0800)]
Generate the contents of OpCodeNames.c.

This was another one that was pretty easy to add to opcode-gen. I did
end up tweaking opcode-gen to make it obvious that the two forms of
name are different by more than just upper vs. lower case, especially
because I duplicated the original distinction of the optimized opcodes
having extra prefix characters in their human-oriented names but not
in the names when used as programming constants.

Change-Id: I5062442540d26318914964bd2722cc32380b19ca

13 years agoMerge "Generate most of OpCode.h using opcode-gen." into dalvik-dev
Dan Bornstein [Tue, 16 Nov 2010 23:07:38 +0000 (15:07 -0800)]
Merge "Generate most of OpCode.h using opcode-gen." into dalvik-dev

13 years agoMerge "Improve error messages for bad modified UTF-8 strings passed to JNI functions...
Elliott Hughes [Tue, 16 Nov 2010 22:01:41 +0000 (14:01 -0800)]
Merge "Improve error messages for bad modified UTF-8 strings passed to JNI functions." into dalvik-dev

13 years agoImprove error messages for bad modified UTF-8 strings passed to JNI functions.
Elliott Hughes [Tue, 16 Nov 2010 19:46:50 +0000 (11:46 -0800)]
Improve error messages for bad modified UTF-8 strings passed to JNI functions.

Bug: 2567771
Change-Id: I8b67d13aaf0127f7eafffd69beb6f3b63729182f

13 years agoGenerate most of OpCode.h using opcode-gen.
Dan Bornstein [Tue, 16 Nov 2010 21:09:45 +0000 (13:09 -0800)]
Generate most of OpCode.h using opcode-gen.

This was the easiest bit to tackle in libdex. More to come!

Change-Id: I3f79039ce98951d694d2c896ee1c7a60b417bc49

13 years agoPromote opcode-gen to the dalvik directory.
Dan Bornstein [Tue, 16 Nov 2010 20:21:50 +0000 (12:21 -0800)]
Promote opcode-gen to the dalvik directory.

This tool will soon be used to generate code in libdex, so it
doesn't make sense for it to live in the dx directory.

Change-Id: I63ff7ccceac08fbe314fb0782dc8f2b5d75d155a

13 years agoAdd all the optimized / runtime-only opcodes.
Dan Bornstein [Sat, 13 Nov 2010 01:47:43 +0000 (17:47 -0800)]
Add all the optimized / runtime-only opcodes.

With this patch, the opcodes all have lines in bytecode.txt, but
it's still the case that nothing is being done to use the info in the
vm.

Change-Id: Icf25e0b3b5328bc4c034602fb1ec21741f86c6d5

13 years agoGet rid of kInstrUnconditional.
Dan Bornstein [Sat, 13 Nov 2010 00:07:16 +0000 (16:07 -0800)]
Get rid of kInstrUnconditional.

Replace its use with an inline function dexIsGoto(flags), which uses
the existing flag bits kInstrCanBranch and kInstrCanContinue.

Change-Id: I84f533f619434ad0ad2831c147b50f6dc79b9928

13 years agoMerge "Be more prepared for InstrUtils code generation." into dalvik-dev
Dan Bornstein [Fri, 12 Nov 2010 23:24:57 +0000 (15:24 -0800)]
Merge "Be more prepared for InstrUtils code generation." into dalvik-dev

13 years agoBe more prepared for InstrUtils code generation.
Dan Bornstein [Fri, 12 Nov 2010 22:56:12 +0000 (14:56 -0800)]
Be more prepared for InstrUtils code generation.

This patch removes "unconditional" as a flag (related change coming soon
to the vm code), and it prevents the dx codegen paths from doing anything
with optimized opcodes.

Change-Id: I0391d69d7956a564f3019f54d69a5522b8984ca0

13 years agoMerge "Progress toward structured lock checks" into dalvik-dev
Andy McFadden [Fri, 12 Nov 2010 22:32:29 +0000 (14:32 -0800)]
Merge "Progress toward structured lock checks" into dalvik-dev

13 years agoProgress toward structured lock checks
Andy McFadden [Wed, 10 Nov 2010 15:55:14 +0000 (07:55 -0800)]
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

13 years agoTypeRef, not ClassRef.
Dan Bornstein [Fri, 12 Nov 2010 20:51:35 +0000 (12:51 -0800)]
TypeRef, not ClassRef.

Old habits die hard. The things in question have been called TypeRefs
for quite a while now.

Change-Id: I77b0066a67c63b8e801ec62eb613f18a4812585a

13 years agoMerge "Add info to the bytecode.txt file." into dalvik-dev
Dan Bornstein [Fri, 12 Nov 2010 20:46:16 +0000 (12:46 -0800)]
Merge "Add info to the bytecode.txt file." into dalvik-dev

13 years agoAdd info to the bytecode.txt file.
Dan Bornstein [Fri, 12 Nov 2010 20:15:46 +0000 (12:15 -0800)]
Add info to the bytecode.txt file.

This additional info should be enough to start generating the
tables used by InstrUtils, though this patch doesn't do anything
more than check the syntax of the new data.

Change-Id: Id823518d5a2edaea3397561a53070cc605ad4bf1

13 years agoStop reporting negative widths.
Andy McFadden [Fri, 12 Nov 2010 00:49:22 +0000 (16:49 -0800)]
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

13 years agoMerge "Remove unused logging macros." into dalvik-dev
Carl Shapiro [Fri, 12 Nov 2010 01:21:37 +0000 (17:21 -0800)]
Merge "Remove unused logging macros." into dalvik-dev

13 years agoam 72ef412b: Fix uninitialized variable warning(error).
Jing Yu [Fri, 12 Nov 2010 01:11:28 +0000 (17:11 -0800)]
am 72ef412b: Fix uninitialized variable warning(error).

* commit '72ef412b56becfbdd54f239ea672a48b163ff1d2':
  Fix uninitialized variable warning(error).

13 years agoRemove unused logging macros.
Carl Shapiro [Fri, 12 Nov 2010 01:09:12 +0000 (17:09 -0800)]
Remove unused logging macros.

Change-Id: Ie1a2bb96232677c02e08b6c8f75dc9cdf2c371d8

13 years agoReset the finger immediately after it becomes no longer useful.
Carl Shapiro [Fri, 12 Nov 2010 00:39:58 +0000 (16:39 -0800)]
Reset the finger immediately after it becomes no longer useful.

Change-Id: Icdef2bb73289d12e9973898732ef9a17b0123d34

13 years agoAdd the new instruction formats.
Dan Bornstein [Thu, 11 Nov 2010 20:26:58 +0000 (12:26 -0800)]
Add the new instruction formats.

This just adds new elements to the enum and adds code to InstrUtils
and dexdump which knows how to decode them.

In dexdump, I took advantage of the new index type table to simplify
how all the index-bearing instructions get dumped, to the point where
adding the new formats was really just a matter of picking the right
switch cases to add new labels to.

Change-Id: I9094b0d568e7c71ee237672bbea8c319274c6697

13 years agoFix uninitialized variable warning(error).
Jing Yu [Thu, 11 Nov 2010 19:48:23 +0000 (11:48 -0800)]
Fix uninitialized variable warning(error).

Change-Id: I10815b033199758976950b28af7cc412f093a7f5

13 years agoFix Thumb2 codegen.
Dan Bornstein [Thu, 11 Nov 2010 18:55:45 +0000 (10:55 -0800)]
Fix Thumb2 codegen.

My local build wasn't doing Thumb2. Unsurprising in retrospect.

Change-Id: I38ab4dc80e1115cf459f6d890c7d0eb2705fa7c9

13 years agoAdd a new index type table for instruction decoding.
Dan Bornstein [Thu, 11 Nov 2010 01:34:32 +0000 (17:34 -0800)]
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

13 years agoSimplify the instruction decoder.
Dan Bornstein [Wed, 10 Nov 2010 19:26:52 +0000 (11:26 -0800)]
Simplify the instruction decoder.

The decoder for format 35mi was *mostly* identical to the one for
35c/35ms. The one place where it differed was in the allowing (or not)
of a fifth argument. I combined the two blocks and just added an
additional format check in the five-argument case. I ended up
rewriting the stuff to pull arguments into the args array, because
while the original loop at the core of it was attractively simple, the
extra stuff around it just made the code obscure. With this change,
the code just does switch(count) and has a nice little cascade.

While I was in the territory, I did a couple other minor cleanups.

Change-Id: Ib75d47eae92a91571445751789d56feeb4e0ca81

13 years agoReharmonize the implementation with the spec.
Dan Bornstein [Wed, 10 Nov 2010 01:15:10 +0000 (17:15 -0800)]
Reharmonize the implementation with the spec.

In particular, I altered the naming of some instruction format fields
as well as the names of instruction formats themselves, all in an attempt
to make the implementation be a more straightforward match of the spec.

This patch mostly changes comments to reflect the new harmonized
reality. The only "code-like" change is the renaming of kFmt3inline
and kFmt3rinline to kFmt35mi and kFmt3rmi (respectively), which is
what they're called in the spec.

Bonus: Added the new extended opcode instruction formats to
InstrUtils.h, though I left them commented out for now.

Change-Id: I0109f361c1e9b6f0308c45e8cda5320e9ad3060c

13 years agoMerge "Pro-active pre-harmonization." into dalvik-dev
Dan Bornstein [Wed, 10 Nov 2010 01:14:36 +0000 (17:14 -0800)]
Merge "Pro-active pre-harmonization." into dalvik-dev

13 years agoPro-active pre-harmonization.
Dan Bornstein [Wed, 10 Nov 2010 01:04:53 +0000 (17:04 -0800)]
Pro-active pre-harmonization.

This is the same idea as my last change, except with the new
extended opcode formats. I also added a little more explanatory
text.

Change-Id: Iab9d1beb1ed445b94e72a438dfb83ea077c8c35b

13 years agoMerge "Spec/implementation harmony." into dalvik-dev
Dan Bornstein [Wed, 10 Nov 2010 00:10:10 +0000 (16:10 -0800)]
Merge "Spec/implementation harmony." into dalvik-dev

13 years agoSpec/implementation harmony.
Dan Bornstein [Tue, 9 Nov 2010 23:21:37 +0000 (15:21 -0800)]
Spec/implementation harmony.

I did two things here: (1) made the lettering for formats 35c and 35ms
match how things are actually implemented; and (2) formally defined
formats 35mi and 3rmi, to correspond to the inline linked formats
actually used in our current implementation.

In neither case does this change the meaning of the spec in any
substantive way. The first case is just about labels, and the second
case is just about (from the standpoint of the spec) a suggestion.

Change-Id: I6a6226a8cdd82ae4dcc43d342a9e9b98582cefd7

13 years agoMerge "Allocate the mark stack as part of heap allocation." into dalvik-dev
Carl Shapiro [Tue, 9 Nov 2010 23:39:07 +0000 (15:39 -0800)]
Merge "Allocate the mark stack as part of heap allocation." into dalvik-dev

13 years agoMerge "Added info for parallel dx switch "num-threads" to help message." into dalvik-dev
jeffhao [Tue, 9 Nov 2010 23:33:22 +0000 (15:33 -0800)]
Merge "Added info for parallel dx switch "num-threads" to help message." into dalvik-dev

13 years agoMerge "Expand away the QUIET_ZYGOTE_MONITOR macro." into dalvik-dev
Carl Shapiro [Tue, 9 Nov 2010 23:21:07 +0000 (15:21 -0800)]
Merge "Expand away the QUIET_ZYGOTE_MONITOR macro." into dalvik-dev

13 years agoExpand away the QUIET_ZYGOTE_MONITOR macro.
Carl Shapiro [Tue, 9 Nov 2010 22:30:11 +0000 (14:30 -0800)]
Expand away the QUIET_ZYGOTE_MONITOR macro.

Change-Id: I74eac297597e8e7c9a13d03335f91cf289e060df

13 years agoAllocate the mark stack as part of heap allocation.
Carl Shapiro [Tue, 9 Nov 2010 22:27:02 +0000 (14:27 -0800)]
Allocate the mark stack as part of heap allocation.

Previously, the mark stack would be allocated and freed as part of a
garbage collection.  This had two deficiencies.  First, allocating the
mark stack requires a file descriptor to open the ashmem device.  If
there are file descriptors free at the time of an garbage collection
the runtime is forced to abort.  Second, it turns out that ashmem is
slow.  I wrote a benchmark that evaluates the speed of various methods
for allocating memory 1e6 times in a tight loop.  The results are
summarized below

  madvise             2.279357911
  mprotect            3.451385496
  mmap MAP_ANONYMOUS  4.408111572
  mmap /dev/zero     14.232635436
  ashmem             35.414886504

The madvise algorithm preallocated some virtual memory, advise the
pages needed during a garbage collection, and advised the same pages
not need afterward.  It is not clear if this actually causes pages to
be made available to other processes or mappings in between garbage
collections.

The mprotect algorithm reserves some virtual memory and commit its
pages during a garbage collection and then uncommit its pages
afterward.  This releases pages and, like all slower methods, runs the
risk of being unable to allocate those pages afterward if physical
pages are unavailable.

The mmap MAP_ANONYMOUS algorithm allocates and frees virtual memory
each iteration.  This is surprisingly competitive with the methods
that preallocate memory and an order of magnitude faster than ashmem.

The mmap /dev/zero algorithm is similar to MAP_ANONYMOUS but allocates
anonymous memory through a file mapping.  It is substantially more
expensive than MAP_ANONYMOUS.

The ashmem algorithm is what is currently used.  It is also the
slowest method to allocate memory.

With this change, the madvise algorithm is used to allocate the mark
stack.  Virtual memory for the largest possible mark stack is reserved
at startup.  At the start of a garbage collection enough pages are
advised as needed for a mark stack given the current size of the heap.
At the end of a garbage collection, these pages are advised as no longer
needed.

As part of this change the mark stack has been changed to grow upward.
This makes the code simpler when the mark stack is incrementally
consumed.  Also, the pushing and popping routines have been separated
into distinct functions.

Change-Id: Ibe4cc025c95451c2e462fbf10885ca85eef2088a

13 years agoAdded info for parallel dx switch "num-threads" to help message.
jeffhao [Tue, 9 Nov 2010 22:24:28 +0000 (14:24 -0800)]
Added info for parallel dx switch "num-threads" to help message.

Change-Id: I7fa31ab7160956c135ab95f8411ad359f616403d

13 years agoMerge "Add const-class/jumbo." into dalvik-dev
Dan Bornstein [Tue, 9 Nov 2010 18:27:05 +0000 (10:27 -0800)]
Merge "Add const-class/jumbo." into dalvik-dev

13 years agoam 6505cfe3: am ef4b0613: am e9503ef8: am 886130bc: (-s ours) Two patches.
Andy McFadden [Tue, 9 Nov 2010 04:15:42 +0000 (20:15 -0800)]
am 6505cfe3: am ef4b0613: am e9503ef8: am 886130bc: (-s ours) Two patches.

* commit '6505cfe36b9815db674a0fedc9ab2147efcd5a03':
  Two patches.

13 years agoam ef4b0613: am e9503ef8: am 886130bc: (-s ours) Two patches.
Andy McFadden [Tue, 9 Nov 2010 04:00:39 +0000 (20:00 -0800)]
am ef4b0613: am e9503ef8: am 886130bc: (-s ours) Two patches.

* commit 'ef4b0613d6952770aefac07d503955eb7b962d2b':
  Two patches.

13 years agoam e9503ef8: am 886130bc: (-s ours) Two patches.
Andy McFadden [Tue, 9 Nov 2010 03:38:19 +0000 (19:38 -0800)]
am e9503ef8: am 886130bc: (-s ours) Two patches.

* commit 'e9503ef8c460f4818062ecc80a9e0b4f8c6745b8':
  Two patches.

13 years agoam 886130bc: (-s ours) Two patches.
Andy McFadden [Tue, 9 Nov 2010 02:13:32 +0000 (18:13 -0800)]
am 886130bc: (-s ours) Two patches.

* commit '886130bc7ff992940e152636f57072e58c91aa2e':
  Two patches.

13 years agoAdd const-class/jumbo.
Dan Bornstein [Tue, 9 Nov 2010 02:03:33 +0000 (18:03 -0800)]
Add const-class/jumbo.

I neglected to include this one in my original list of new opcodes.

Change-Id: Ia59b4b2f21516d851f0398361eb5db1cb413aaab

13 years agoMerge "Add the new jumbo opcodes to dx...almost." into dalvik-dev
Dan Bornstein [Tue, 9 Nov 2010 01:36:31 +0000 (17:36 -0800)]
Merge "Add the new jumbo opcodes to dx...almost." into dalvik-dev

13 years agoTwo patches.
Andy McFadden [Tue, 9 Nov 2010 01:05:39 +0000 (17:05 -0800)]
Two patches.

Patch 1a+1b: Set capabilities sooner.

(cherry-pick from gingerbread I22fde728bd5d65774f8fdf1fa45956fe18358c4c)
(hand-pick from gingerbread Ief58bdfff2cb82d7824ef796c2c1031f525f6ee9,
 plus minor tweak to avoid altering the API)

Patch 3: If there's an error dropping privileges, abort.

(cherry-pick from gingerbread I85ce12e93cb8c297add756dc3b872b8346eda00b)

Bug 3176774

Change-Id: If8285d7bfd5a466bd77c0f7ffadf1bf96d31db06

13 years agoMerge "Track change in libcore/NativeCode.mk." into dalvik-dev
Elliott Hughes [Tue, 9 Nov 2010 00:57:12 +0000 (16:57 -0800)]
Merge "Track change in libcore/NativeCode.mk." into dalvik-dev

13 years agoTrack change in libcore/NativeCode.mk.
Elliott Hughes [Tue, 9 Nov 2010 00:54:57 +0000 (16:54 -0800)]
Track change in libcore/NativeCode.mk.

Bug: 2281992
Change-Id: Ibfb877bc78396bc0e947ae2f8f86e484843f07de

13 years agoAdd the new jumbo opcodes to dx...almost.
Dan Bornstein [Tue, 9 Nov 2010 00:28:33 +0000 (16:28 -0800)]
Add the new jumbo opcodes to dx...almost.

This change adds the new opcodes while simultaneously preventing
them from actually being emitted, the prevention being controlled
by a new flag in InsnFormat.

Empirically speaking, we already have latent demand for the new
opcodes -- specifically because they allow for wider register
references than their wee companions -- and so we can't actually
enable their generation until the VM is prepared to execute them.

If you're wondering why dx without the new opcodes doesn't crap out on
the register references in question, it's because there's code in dx
which will expand an instruction that has non-fitting register
references into a sequence of two or more instructions, where it
shuffles values into and out of usable registers before and/or after
the instruction. When we turn on the jumbo opcodes, at least some
of these register shuffles will immediately get to go away.

Change-Id: I3f921ab07efa4944d7526fa48534d69f508ac249

13 years agoMinor tweaks and clarification.
Dan Bornstein [Mon, 8 Nov 2010 23:55:32 +0000 (15:55 -0800)]
Minor tweaks and clarification.

Change-Id: I861c2d65fea468fd1f085d845981b1cd9d98d3a8

13 years agoAnother bit of cleanup.
Dan Bornstein [Mon, 8 Nov 2010 21:13:54 +0000 (13:13 -0800)]
Another bit of cleanup.

Making it a little easier to have more than 256 opcodes.

Change-Id: I050050f2b6078407dde4d4f214dec2c1a331000c

13 years agoMove some verifier stuff around.
Andy McFadden [Thu, 4 Nov 2010 23:31:37 +0000 (16:31 -0700)]
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

13 years agoMerge "Use the static opcode chains in dx." into dalvik-dev
Dan Bornstein [Thu, 4 Nov 2010 23:42:11 +0000 (16:42 -0700)]
Merge "Use the static opcode chains in dx." into dalvik-dev

13 years agoMerge "Parameterize instance counting to include subclasses." into dalvik-dev
Carl Shapiro [Thu, 4 Nov 2010 23:34:33 +0000 (16:34 -0700)]
Merge "Parameterize instance counting to include subclasses." into dalvik-dev

13 years agoUse the static opcode chains in dx.
Dan Bornstein [Thu, 4 Nov 2010 22:33:35 +0000 (15:33 -0700)]
Use the static opcode chains in dx.

This removes the need to iterate over all possible opcodes looking for
family/format matches whenever the need arises to rewrite an
instruction with a new opcode. This should speed dx up at least a
little, though I don't know if it will be measurable. It's certainly
cleaner and a bit simpler, though.

Change-Id: I779f19cb1249d30f6886faf76670ae37d5dfc402

13 years agoParameterize instance counting to include subclasses.
Carl Shapiro [Thu, 4 Nov 2010 22:12:09 +0000 (15:12 -0700)]
Parameterize instance counting to include subclasses.

Change-Id: Idf54343a6a587e512833bbacbd0f7290adf8517e

13 years agoMerge "Start including the "next opcode" in Dop instances." into dalvik-dev
Dan Bornstein [Thu, 4 Nov 2010 21:06:28 +0000 (14:06 -0700)]
Merge "Start including the "next opcode" in Dop instances." into dalvik-dev

13 years agoMerge "Fix CloseGuard issue in test 087." into dalvik-dev
Andy McFadden [Thu, 4 Nov 2010 20:29:25 +0000 (13:29 -0700)]
Merge "Fix CloseGuard issue in test 087." into dalvik-dev

13 years agoFix CloseGuard issue in test 087.
Andy McFadden [Thu, 4 Nov 2010 20:09:39 +0000 (13:09 -0700)]
Fix CloseGuard issue in test 087.

Need to explicitly close the DexFile.

Change-Id: I15ec8550d3991cf492fbd20c87cb9408d205dd7f

13 years agoMerge "Rename wrap/unwrap --> box/unbox" into dalvik-dev
Andy McFadden [Thu, 4 Nov 2010 20:03:57 +0000 (13:03 -0700)]
Merge "Rename wrap/unwrap --> box/unbox" into dalvik-dev

13 years agoRename wrap/unwrap --> box/unbox
Andy McFadden [Thu, 4 Nov 2010 19:37:51 +0000 (12:37 -0700)]
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

13 years agoStart including the "next opcode" in Dop instances.
Dan Bornstein [Thu, 4 Nov 2010 18:22:35 +0000 (11:22 -0700)]
Start including the "next opcode" in Dop instances.

Nothing's using it yet, though. Coming soon!

Change-Id: Ide34647fce6ad55fe52c8f6012145b724c134799

13 years agoMerge remote branch 'goog/dalvik-dev' into dalvik-dev-to-master
Elliott Hughes [Thu, 4 Nov 2010 18:03:57 +0000 (11:03 -0700)]
Merge remote branch 'goog/dalvik-dev' into dalvik-dev-to-master