History log of /dalvik/vm/oo/Class.c
Revision Date Author Comments
818164b87a9c08a938c371d8b47987a3af06d6f6 07-May-2010 Dan Egnor <egnor@google.com> Revert "Plug leak in class initialization."

This reverts commit d07cf9d69dddeebb91386a88f7b6d2323cf125a9.
Bug: 2664424

Change-Id: I1a36469757f2f20fb29b3bcf04e2a23aa7b72dca
d07cf9d69dddeebb91386a88f7b6d2323cf125a9 06-May-2010 Andy McFadden <fadden@android.com> Plug leak in class initialization.

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

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

Bug 2655384.

Change-Id: Ib0c285ef23d58ae709be65f09efb68e73f982084
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
e15a8eb2653da80c1c3816ddce8186746b57b4a3 23-Feb-2010 Andy McFadden <fadden@android.com> Add class init stats to alloc counters (API change).

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

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

For bug 2461549.
7c70b3f1c2e92364ea44ece3843a64fe69274427 12-Jan-2010 Carl Shapiro <cshapiro@google.com> Delete remaining FANCY_REFERENCE_SUBCLASS code. According to find and
grep, this is the last use of that macro in Dalvik.
96516932f1557d8f48a8b2dbbb885af01a11ef6e 29-Oct-2009 Andy McFadden <fadden@android.com> Change the way breakpoints work.

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

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

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

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

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

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

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

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

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

The bottom line is that code should run noticeably faster while a
debugger is attached.
72e93344b4d1ffc71e9c832ec23de0657e5b04a5 13-Nov-2009 Jean-Baptiste Queru <jbq@google.com> eclair snapshot
504e9f4441c3a013047931d24a978523a26fde2d 16-Sep-2009 Andy McFadden <fadden@android.com> Speling.
2fbe6d15ed8d266ed55fb76e97f866dbd07d5fa6 05-Sep-2009 Andy McFadden <fadden@android.com> Reduce a log message, stifle a gcc warning.
6daaac12e5de630749f94ff5f15e902e7b18d8e7 08-Jul-2009 Barry Hayes <bhayes@google.com> Add a bit-map encoding of Object-reference field offsets to ClassObject.

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

The GC uses the encoded bitmap -- if available -- to extract Object refererences
from DataObjects.
e2729683dc78022e033c7bac36e061baff7cd3c5 21-Aug-2009 Andy McFadden <fadden@android.com> Fix a couple of compiler warnings.
e2557513420f6be2d70c19a4d826731174c828d1 28-Jul-2009 Bill Buzbee <buzbee@google.com> Fix for 3326: Incorrect return value from native library in dalvik
Really a workaround for a gcc bug in 4.3. Don't trust the C compiler
to properly clear high bits from < 32-bit JNI return values.
7605a84a9a0a1764c1fb290d9c93e8114eaf620a 27-Jul-2009 Andy McFadden <fadden@android.com> Added dvmLinearAllocContains().
85745e148153894aac52ad3d7f6a36a7767b45a0 08-Jul-2009 Mike Lockwood <lockwood@android.com> Fix variable names related to bytecode tracing.

Signed-off-by: Tony Yokoyama <chuuoudai@gmail.com>

The compile errors, encountered in the case that macro LOG_INSTR is
turned on, are fixed.

On branch log_instr
Changes to be committed:

modified: vm/mterp/armv5te/debug.c
modified: vm/mterp/c/gotoTargets.c
modified: vm/mterp/out/InterpC-allstubs.c
modified: vm/mterp/out/InterpC-armv4.c
modified: vm/mterp/out/InterpC-armv5te.c
modified: vm/mterp/out/InterpC-portdbg.c
modified: vm/mterp/out/InterpC-portstd.c
modified: vm/mterp/out/InterpC-x86.c
modified: vm/mterp/portable/debug.c
modified: vm/oo/Class.c
7fc3ce8f0223a90006ad2c431a43b0bc841ee3c2 15-Jul-2009 Andy McFadden <fadden@android.com> Throw a pre-fabricated NoClassDefFoundError.

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

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

I think the only way that anyone will see this is if they try to
load a class directly from the bootstrap loader, in which case the
ClassNotFoundException will show the canned NCDFE as the cause. I
don't think any useful diagnostic information is being lost.
511d0505abb8fe7d2af8cd8532de773ce30d7615 08-Jul-2009 Mike Lockwood <lockwood@android.com> Fix typo introduced in previous change.

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

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

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

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

This is a one-word fix + comments and new/updated tests.
cab8be0c6e1e9a683402d5a71b037723a6b15bb2 26-May-2009 Andy McFadden <fadden@android.com> Fix for external bug 2711, over-eager conflicting class rejection.

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

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

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

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

For internal bug 1812586.
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, ...).
7ccb7a6a563396e4b64069dd4e57977d1b5b6180 15-May-2009 Andy McFadden <fadden@android.com> Increase the number of entries set aside for zygote initiating loader lists.

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

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

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

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

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

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

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

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

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

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

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

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