History log of /dalvik/vm/Thread.h
Revision Date Author Comments
0c2dc522d0e120f346cf0a40c8cf0c93346131c2 03-Jul-2012 Dong-Yuan Chen <dong-yuan.chen@intel.com> [X86] X86 trace JIT compiler support

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

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

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

Change-Id: I241113681963a16c13a3562390813cbaaa6eedf0
Signed-off-by: Dong-Yuan Chen <dong-yuan.chen@intel.com>
Signed-off-by: Yixin Shou <yixin.shou@intel.com>
Signed-off-by: Johnnie Birch <johnnie.l.birch.jr@intel.com>
Signed-off-by: Udayan <udayan.banerji@intel.com>
Signed-off-by: Sushma Kyasaralli Thimmappa <sushma.kyasaralli.thimmappa@intel.com>
Signed-off-by: Bijoy Jose <bijoy.a.jose@intel.com>
Signed-off-by: Razvan A Lupusoru <razvan.a.lupusoru@intel.com>
Signed-off-by: Tim Hartley <timothy.d.hartley@intel.com>
75425b731c514bf90c985275d80aa7886727d83f 01-Feb-2012 Chris Dearman <chris@mips.com> Fix the portable interpreter build

Change-Id: Ibf08d50c7a01a4c30559dd2ee9511c28fb1365a5
Signed-off-by: Chris Dearman <chris@mips.com>
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
708f143f318bb2167c810f9506102f4ad656545c 08-Jun-2011 Elliott Hughes <enh@google.com> Improve "waiting on"/"waiting to lock" SIGQUIT dump info.

In particular, when we're waiting on a Class, say which class:

I(16573) - waiting on <0xf5ed54f8> (java.lang.Class<java.lang.ref.ReferenceQueue>)

versus:

I(16573) - waiting on <0xf5feda38> (a java.util.LinkedList)

Bug: http://code.google.com/p/android/issues/detail?id=17349
Change-Id: I844d02c008b1499adb02995ff3da25ba8cad0e0a
cf4a20cf0cbc53f03a5b16c7152bbb29907f7108 25-May-2011 buzbee <buzbee@google.com> Interpreter/Debugger fix #4479968

This one was tricky to track down. The underlying problem arose
with the consolidation of InterpState with Thread. Rather than
having a state structure for each instance of the interpreter, we
moved to a model that had a single thread-local struct shared by all
interpreter instances running on that thread. A portion of interpreter
state can't be shared - and thus was saved and restored on nested
invocations of the interpreter.

The bug here was that the storage for method return values was not
included in the state that needed save/retore. In normal operation,
it doesn't need to be saved - that storage isn't live across an
invoke that could trigger a nested interpreter activation. However,
when debugging, the debugger itself may hijack threads and create
new interpreter instances for its own purposed - and there is a small
window in which live retval can be trashed.

The fix is simply to move retval into the InterpSave struct.

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

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

Change-Id: I236c5a1553a51f82c9bc3eaaab042046c854d3b4
cf2aac7e6a29e7e1e5f622fd6123e0d1a9a75bda 25-Apr-2011 buzbee <buzbee@google.com> Refine & simplify the interBreak mechanism

Replace dvmUpdateInterpBreak() and friends with more direct
enable/disable subMode calls. Hide breakFlags manipulation from
higher-level callers and infer what is needed from the active
subMode.

Add documentation to the interpreter control section of
mterp/README.txt

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

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

Change-Id: I4a6070b1ba4fb08a0f6e0aba6f150b30f9159eed
30bc0d46ae730d78c42c39cfa56a59ba3025380b 22-Apr-2011 buzbee <buzbee@google.com> Consolidate curFrame fields in thread storage

We ended up with two locations in the Thread structure for saved
Dalvik frame pointer. This change consolidates them.

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

Change-Id: I25d8fa821987a3dd6d7109d07fd42dbf2fe0e589
77ebd063cf383b370dd7f3871baf625da0df312f 04-Apr-2011 Carl Shapiro <cshapiro@google.com> Size the jni local references table to avoid resizing at startup.

Change-Id: Ief382b9acb0fa6ce1e0371ecbb7d86f7059102d8
94d65255849ce9f195c971f726e8b09449ba4d14 25-Mar-2011 buzbee <buzbee@google.com> Add safepoint callback for gc

This change adds a safepoint callback registration mechanism.
On a per-thread (or all-thread) basis, you pass in a function to be
called at the next safe point by the target thread. That if that
function returns 0, it will be automatically disarmed. If not,
the callback will stay in effect and the function will be called
on all subsequent safe points.

GC is the expected customer of this feature.

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

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

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

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

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

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

This change removes support for direct references.

Change-Id: I2af043ecfc5811c16a7d02a5bbb6c071ec6f0a82
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
a7d59bbafea5430fe81fc21ba94ddf6f6a63b0b3 24-Feb-2011 buzbee <buzbee@google.com> New interpreter breakout mechanism

Introduce parallel handler entry points for mterp interpreters as a step
towards fully supporting debug, profile and JIT within mterp (instead of
bailing out to the portable debug interpreter).

This CL contains most of the structural changes that need to happen,
but does not yet enable the new switch mode. In short, within the
mterp assembly interpreter register rIBASE points to an array of handlers
for Dalvik opcodes. Instead of periodically checking for suspend,
debug, profiling and JIT trace selection breakouts, rIBASE may simply
be altered to point to the parallel breakout handlers when control needs
to be rerouted. This will enable us to eliminate the separate portable
debug interpreter and the entire mechanism of switching between the fast
and portable interpreters.

The x86 implementation required a large number of changes because of the
need to dedicate a register to holding the table base. It will now use %edx
(which was previously scratch).

Changes include:

o Support for two styles of mterp assembly code generation: computed goto
and jump table (ARM uses computed goto, x86 uses jump table)
o New mterp config operators to trigger generation of alternate entry points.
o Alternate entries route execution through new dvmCheckInst(). That's
where the checking code will go.
o For x86, reserved register edx as dedicated rIBASE.
o For jump-table mterps, ignore "%break" operator and allow variable-sized
handlers with no "sister" region.

Note that the x86-atom implementation will need substantial changes
to function in this new model.

Change-Id: I3a22048adb7dcfdeba4f94fbb977b26c3ab2fcb3
9f601a917c8878204482c37aec7005054b6776fa 12-Feb-2011 buzbee <buzbee@google.com> Interpreter restructuring: eliminate InterpState

The key datastructure for the interpreter is InterpState.
This change eliminates it, merging its data with the Thread structure.

Here's why:

In principio creavit Fadden Thread et InterpState. And it was good.

Thread holds thread-private state, while InterpState captures data
associated with a Dalvik interpreter activation. Because JNI calls
can result in nested interpreter invocations, we can have more than one
InterpState for each actual thread. InterpState was relatively small,
and it all worked well. It was used enough that in the Arm version
a register (rGLUE) was dedicated to it.

Then, along came the JIT guys, who saw InterpState as a convenient place
to dump all sorts of useful data that they wanted quick access to through
that dedicated register. InterpState grew and grew. In terms of
space, this wasn't a big problem - but it did mean that the initialization
cost of each interpreter activation grew as well. For applications
that do a lot of callbacks from native code into Dalvik, this is
measurable. It's also mostly useless cost because much of the JIT-related
InterpState initialization was setting up useful constants - things that
don't need to be saved and restored all the time.

The biggest problem, though, deals with thread control. When something
interesting is happening that needs all threads to be stopped (such as
GC and debugger attach), we have access to all of the Thread structures,
but we don't have access to all of the InterpState structures (which
may be buried/nested on the native stack). As a result, polling for
thread suspension is done via a one-indirection pointer chase. InterpState
itself can't hold the stop bits because we can't always find it, so
instead it holds a pointer to the global or thread-specific stop control.

Yuck.

With this change, we eliminate InterpState and merge all needed data
into Thread. Further, we replace the decidated rGLUE register with a
pointer to the Thread structure (rSELF). The small subset of state
data that needs to be saved and restored across nested interpreter
activations is collected into a record that is saved to the interpreter
frame, and restored on exit. Further, these small records are linked
together to allow tracebacks to show nested activations. Old InterpState
variables that simply contain useful constants are initialized once at
thread creation time.

This CL is large enough by itself that the new ability to streamline
suspend checks is not done here - that will happen in a future CL. Here
we just focus on consolidation.

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

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

Change-Id: Ia770b03ebc90a3dc7851c0cd8ef301f9762f50db
dcb65c6975125328c9bf46799f36c59d8fb203e6 25-Jan-2011 Andy McFadden <fadden@android.com> Increase default stack size

This increases the default stack size from 12KB to 16KB.

Bug 3388513

Change-Id: I7f7c3f75b749ca2145a96434e89e6500f79973e4
80e8d7f9ca9b49437bec6224162d7bb7f42392da 25-Jan-2011 Andy McFadden <fadden@android.com> Increase default stack size

This increases the default stack size from 12KB to 16KB.

Bug 3388513

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

Change-Id: Ie9a23da2baf201c50cad5ba0d0992cec9bcace54
07018e2d14b012ae433a0d82025a885ed8debc3b 27-Oct-2010 Carl Shapiro <cshapiro@google.com> Separate HPROF from the GC.

In the beginning, the only way to traverse the roots and heap was to
piggyback off the garbage collector. As such, HPROF was implemented
by instrumenting the root- and object traversal routines to check a
mode flag and call into HPROF during a GC when the flag was set.

This change moves the HPROF calls out of the GC and into callbacks
invoked through the visitor. Notably, it allows HPROF dumps to be
computed at any point in time without invoking a GC and potentially
destroying evidence relating to the cause of an OOM.

Change-Id: I2b74c4f10f35af3ca33b7c0bbfe470a8b586ff66
d19988d14f24086ea1bb37cf662c8729ff78e113 22-Oct-2010 Andy McFadden <fadden@android.com> Lock thread list, show join target

There were some paths to "thread list lock must be held" functions that
weren't locking the thread list. We now do trylock/unlock in dumpFrames
to ensure that doesn't happen.

Also, append "tid=N" to the "waiting on" line in stack trace output
when we're waiting on a VMThread object (i.e. we're in Thread.join()).

Bug 2827015 (for the thread list lock).

Change-Id: I05aa27dd440c671b22ef7cfe47e31dfe54b0ed2d
c415aaf5d72862084cf58ccf53b6d0e8370109de 01-Sep-2010 Brian Carlstrom <bdc@google.com> Removal of more sampling profiler bits

dalvik/vm/native/SystemThread.[ch] was added for the old sampling
profiler, and can be removed as it's not needed for the new one.

Bug: 2967741
Change-Id: Ibd306b4ba579f9796facbf7a69719b3cb6640762
b5f3c0b8222efea953adb94b97a2c70ba58e26e3 24-Aug-2010 Andy McFadden <fadden@android.com> Change the way thread suspension works.

There are at least three ways to handle detection of thread suspension
correctly: (1) hold a mutex, (2) pile all state into a single 32-bit
location and use atomic ops, and (3) order the operations carefully.
Of these, #3 has the least overhead on uniprocessors, so we're going
with that.

It does introduce one quirk, because we're now changing to "running"
mode before checking to see if we're allowed to run. This creates
a tiny window of opportunity for assertions and thread dumps to see
what appears to be a thread that's running when it shouldn't be.
This is correctable with additional work (e.g. transitioning through
a pre-running state) but probably not worth worrying about.

This eliminates the separate self->isSuspended flag in favor of the
new THREAD_SUSPENDED thread state.

Bug 2667016.

(cherry-pick from dalvik-dev)

Change-Id: Ibc77ebbb03a7993bc4057c1c375498172ca8ff1c
6dce996e16e8a7f8d538910221aa29df43eed9ed 24-Aug-2010 Andy McFadden <fadden@android.com> Change the way thread suspension works.

There are at least three ways to handle detection of thread suspension
correctly: (1) hold a mutex, (2) pile all state into a single 32-bit
location and use atomic ops, and (3) order the operations carefully.
Of these, #3 has the least overhead on uniprocessors, so we're going
with that.

It does introduce one quirk, because we're now changing to "running"
mode before checking to see if we're allowed to run. This creates
a tiny window of opportunity for assertions and thread dumps to see
what appears to be a thread that's running when it shouldn't be.
This is correctable with additional work (e.g. transitioning through
a pre-running state) but probably not worth worrying about.

This eliminates the separate self->isSuspended flag in favor of the
new THREAD_SUSPENDED thread state.

Bug 2667016.

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

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

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

Bug 2923442.

Change-Id: I335ebd5193bc86f7641513b1b41c0378839be1fe
3469a7e404591fe158a60b4d05b0f2c768bcfce2 05-Aug-2010 Andy McFadden <fadden@android.com> Fix some potential SMP issues.

Wandered through Thread.c looking for SMP trouble spots. Changed a
couple of stores to android_atomic_release_store, and added some
comments.

Also, wrapped the self-suspend stuff that's in the thread status change
code so it only happens if we're actually going to suspend the thread.

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

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

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

Change-Id: I0c0edb3ebf0d5e040d6bbbf60269fab0deb70ef9
b31b30131bbf58280a515c40027aa958b81b5cd6 26-May-2010 Carl Shapiro <cshapiro@google.com> Eliminate more unused variables and compiler warnings.

This change also introduces wrappers for condition variable operations
similar to what we have already for mutex operations.

Almost all the remaining warnings are now in the compiler or non-debug
uses of the CHECK_JIT macro.

Change-Id: I9f492f1582a06065e3a52287c7834adddfbefff9
ab227f7a9a9d4c7837ee7a5cc9f07b665d516bac 06-Apr-2010 Andy McFadden <fadden@android.com> Correct long-standing thread status change bug.

If the stars aligned correctly (or you were running valgrind), it was
possible for a thread to change its status to RUNNING immediately after
having its suspend count incremented. The problem is that the thread
initiating the suspension regards the target thread as being in (say)
VMWAIT with sCount=1, which means its safe to kick off a GC. The target
thread thinks it's happily in RUNNING and can go do whatever it wants.

The fix is to move the status change so that it's guarded by the
suspension count mutex.

This shouldn't affect performance. The number of instructions executed
is about the same.

Also, the "self can be NULL" feature of dvmCheckSuspendPending had very
few customers, so we now skip that check and just require it to be set.

For bug 2309331.

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

Change-Id: Idd921bcc0e084c18bff1e209a8591ef55f57843a
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
384ef6b4770ad6ae3c4c940bd6c5a6e768d1e45f 16-Mar-2010 Andy McFadden <fadden@android.com> Point debuggerd at the interesting thread.

There are a couple of situations (spin-on-suspend, HeapWorker wedged)
where the current thread's native stack is much less interesting than one
of the others. This change will cause a couple of signals to be thrown
at the "interesting" thread in an attempt to get more useful information
out of debuggerd in these cases.

For bug 2517042.

Change-Id: Ib8c0e0ef93f07b7114e5f4638a907a0f7802bdc0
0a24ef9d1a88984dae3f7a9bf431c82626eadb2e 12-Mar-2010 Andy McFadden <fadden@android.com> Try to show lock owner in MONITOR thread dump.

A thread in the MONITOR state is blocked waiting on a monitor. This
raises two interesting questions: (1) what lock is it waiting on, and
(2) who holds that lock? The answer to (1) can be determined easily by
looking at the source code, but (2) is a bit harder.

This change extracts the target object from the instruction stream and
prints some information about it, e.g.:

- waiting to lock <0x40028c68> (a java.lang.Object) held by threadid=1 (main)

Also: fiddled with "must [not] be locked" on a recently-added function.

(cherry-picked from dalvik-dev)

Change-Id: Ic16695741760d50be70e70fb7470972cef28bb09
fd54266907c3046339b48748f63afa32ee3ab4e1 12-Mar-2010 Andy McFadden <fadden@android.com> Try to show lock owner in MONITOR thread dump.

A thread in the MONITOR state is blocked waiting on a monitor. This
raises two interesting questions: (1) what lock is it waiting on, and
(2) who holds that lock? The answer to (1) can be determined easily by
looking at the source code, but (2) is a bit harder.

This change extracts the target object from the instruction stream and
prints some information about it, e.g.:

- waiting to lock <0x40028c68> (a java.lang.Object) held by threadid=1 (main)

Change-Id: Iad18fc6f2df4142368bdf1063b8cc71de2d66156
Also: fiddled with "must [not] be locked" on a recently-added function.
2b94b30abe21de859b00965d00cc7d42ee436943 10-Mar-2010 Andy McFadden <fadden@android.com> If a finalizer wedges, raise prio and retry.

The VM uses a watchdog mechanism to detect stuck finalizers. It appears
that, in some cases, the watchdog may be firing because the HeapWorker
thread in a background process doesn't get any CPU time after a
remotely-induced GC finishes. With this change, if the HeapWorker is
running at a reduced priority, we raise the priority and allow it to
try some more.

No attempt is made to put the thread priority back. (The HeapWorker
thread doesn't do anything in an idle process, and what it does do is
geared toward freeing one kind of resource or another.)

For bug 2492196.

Change-Id: Ic734c2e2819b9d60d20b2961f2a75085d5879495
98389d0893ad3d3e06cfb38296b01de39e52db31 15-Feb-2010 Carl Shapiro <cshapiro@google.com> Eliminate unused variable warnings in the alloc code. In the places
where unused attributes have been added, arguably, the return code
should be passed up to the caller or, if the return code indicates an
error, we should fast-fail.
964a7b06a9134947b5985c7f712d18d57ed665d2 28-Jan-2010 Bill Buzbee <buzbee@google.com> Jit: Rework delayed start plus misc. cleanup

Defer initialization of jit to support upcoming feature to wait until
first screen is painted to start in order to avoid wasting effort on
jit'ng initialization code. Timed delay in place for the moment.
To change the on/off state, call dvmSuspendAllThreads(), update the
value of gDvmJit.pJitTable and then dvmResumeAllThreads().
Each time a thread goes through the heavyweight check suspend path, returns
from a monitor lock/unlock or returns from a JNI call, it will refresh
its on/off state.

Also:
Recognize and handle failure to increase size of JitTable.
Avoid repeated lock/unlock of JitTable modification mutex during resize
Make all work order enqueue actions non-blocking, which includes adding
a non-blocking mutex lock: dvmTryLockMutex().
Fix bug Jeff noticed where we were using a half-word form of a Thumb2
instruction rather than the byte form.
Minor comment changes.
7a0bcd0de6c4da6499a088a18d1750e51204c2a6 23-Jan-2010 Ben Cheng <bccheng@android.com> Tighten the safe points for code cache resets to happen.

Add a new flag in the Thread struct to track the whereabout of the top frame
in each Java thread. It is not safe to blow away the code cache if any thread
is in the JIT'ed land.
60c24f436d603c564d5351a6f81821f12635733c 04-Jan-2010 Ben Cheng <bccheng@google.com> Tear down the code cache when it is full and restart from scratch.

Because the code cache may be wiped out after safe points now the patching of
inline cache for predicted chains is done through the compiler thread's work
queue.
b453919fee9bf10ccd576d389d8b3584061bba8b 05-Jan-2010 Carl Shapiro <cshapiro@google.com> Remove references to the old wait implementation in various comments.
Also, move the waitMutex above the values it guards to improve the
readability of the Thread structure.
77f52ebffa3793a7e824fab7da02eaee9afdae0e 25-Dec-2009 Carl Shapiro <cshapiro@google.com> New implementation of wait, notify, and notifyAll. Uses an explicit
queue to represent the wait set instead of the implicit queue within
the monitor condition variable.
909ce240fd544de9ba42daf590e1cf17e874ec3b 11-Dec-2009 Andy McFadden <fadden@android.com> Iterate in JNI thread exit check.

The Dalvik VM includes a helpful check that kicks and screams if a thread
exits without detaching from the VM first. It manages this with a pthread
TLS destructor. This is handy, but it will interfere with anyone who
wants to use a TLS destructor to initiate the thread detach.

With this change, we now iterate a couple of times to allow other
destructors a chance to detach the thread before we get snippy.

For 2319072.
72e93344b4d1ffc71e9c832ec23de0657e5b04a5 13-Nov-2009 Jean-Baptiste Queru <jbq@google.com> eclair snapshot
a8e64a7c83ac6fb487a140f77ab8803b46193f45 20-Oct-2009 Ben Cheng <bccheng@google.com> Fix an invoke-interface bug that manifests itself with thread state warnings.

r12 is a scratch register and apparently gcc 4.4 starts to actively use it in
dvmFindInterfaceMethodInCache, the very function that the original live value
is being protected around. This results in useless values setup in the chaining
cell and increases the chances to patch the cell (thus the suspend-all
requests).

Add verbose names for new JIT-related suspend reasons.

With all these changes, the thread state warning will still occur but much less
frequently.

bug 2194174.
5a2056ca8c7e7c0ed9f51d68cedbee59cc936685 12-Sep-2009 San Mehat <san@google.com> dalvik: Switch to common cutils sched_policy api

Signed-off-by: San Mehat <san@google.com>
2fe146a3650e9ccf5da2d24f60841513713f5029 10-Sep-2009 Bob Lee <crazybob@google.com> Addressed reviewer comments.
20677ed1a7114a2aa51086d5097f6328cd4fb94d 10-Sep-2009 San Mehat <san@google.com> dalvik: Use common SchedPolicy type and fix getpid() vs. gettid() bug

Signed-off-by: San Mehat <san@google.com>
894dd4668c4b5c5f4259fd2d84ed4deaa5611efd 09-Sep-2009 San Mehat <san@google.com> vm: Add support for using scheduler policies instead of cgroups

Signed-off-by: San Mehat <san@google.com>
9dc72a3c54af7201b6b85d96dba23a5f85309d9b 05-Sep-2009 Bob Lee <crazybob@crazybob.org> Modified Thread.c to allow sampling profiler thread in zygote. Added a function that
queries the native thread status. Modified the profiler to sample every thread at
a fixed interval instead of adjusting the delay based on the number of threads. This
will make it easier to compare results across apps. Added ability to shut down
the profiler thread. Added code to track whether the method was a leaf or a
caller.
d5ab726b65d7271be261864c7e224fb90bfe06e0 25-Aug-2009 Andy McFadden <fadden@android.com> Another round of scary indirect ref changes.

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

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

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

Some adjustments were made to the JNI code, e.g. dvmCallMethod now needs
to understand if it needs to convert reference arguments from
local/global refs to pointers (it's called from various places
throughout the VM).
0083d37b0e1c9e542f671cbca2e9db6819ecccba 21-Aug-2009 Andy McFadden <fadden@android.com> Use local references for native method args.

This changes the JNI method call mechanism to register all reference
arguments as local refs, as well as the "this" argument (for virtual
calls) and the class object (for static calls).

Before now we skipped this part, because we're handing raw object
pointers around, and we know that all of the arguments can be found by
the GC on the interpreted stack. In fact, there's no need to add the
arguments for GC-correctness; rather, we need to do this to rewrite the
pointers we hand to native code.

This change impacts JNI method call performance, especially for functions
with a large number of reference arguments. To improve things a little,
there are now four "call bridge" functions:

(1) general handler
(2) synchronized method handler (grabs lock, calls #1)
(3) virtual method, no reference args
(4) static method, no reference args

While booting the system, the virtual/static no-ref handlers are used
for about 70% of calls. Since these don't have to scan the method
signature to look for reference arguments, they're a bit faster.

At this point we're still passing raw pointers around, so nothing should
really change.
97319a8a234e9fe1cf90ca39aa6eca37d729afd5 13-Aug-2009 Jeff Hao <jeffhao@google.com> New changes to enable self verification mode.
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
2717622484eb0f7ad537275f7260b2f93324eda2 09-Jun-2009 Bill Buzbee <buzbee@google.com> Makes the primary Jit table growable. Also includes a change suggested earlier by Dan to use a pre-defined mask in the hash function. Reduce the default JitTable size from 2048 entries to 512 entries.
Update per Ben's comments.
39b99b0038fcca0dfe972e70b182b559404ffc78 11-May-2009 Andy McFadden <fadden@android.com> Increase default stack size from 8K to 12K.

For internal bug 1844105.
256fc159a267859c18e11e1d15fd7d97a59757c6 21-Apr-2009 San Mehat <san@google.com> vm: Add support for changing the scheduler group for a thread.
Also temporarily bumps the scheduler group for background threads while performing GC

Signed-off-by: San Mehat <san@google.com>
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
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