History log of /art/runtime/instrumentation.h
Revision Date Author Comments
4ba674b914f24f2baf42769401cff43f8261abd6 10-May-2016 Mingyao Yang <mingyao@google.com> Fix an assert during jdwp debugging.

When debugger attaches, we patch entry points of methods in framework code.
During that process, it's possible that some method's declaring class isn't
resolved yet. We need to relax one assert for that case.

Bug: 28630805

(cherry picked from commit 3fd448a8b7903b00fceaed5853306e2d7eb31c72)

Change-Id: I59fd488ad75417a64b52321677ffcac6ccdc5ce1
1d011d9306fd4ff57d72411775d415a86f5ed398 04-Apr-2016 Bill Buzbee <buzbee@google.com> Revert "Revert "Revert "Revert "ART: Improve JitProfile perf in arm/arm64 mterp""""

Bug: 28081559

This reverts commit 961ea9fe42edcc2c57469bf451d1ca421da5cd59.

Change-Id: I98a5bb8112646706ae7bd73bf6393cb956466be3
961ea9fe42edcc2c57469bf451d1ca421da5cd59 01-Apr-2016 Hiroshi Yamauchi <yamauchi@google.com> Revert "Revert "Revert "ART: Improve JitProfile perf in arm/arm64 mterp"""

This reverts commit 4a8ac9cee4312ac910fabf31c64d28d4c8362836.

570-checker-osr intermittently failing.

Bug: 27939339
d6190dcdfb1f247ff0bf8268dacf413c93b58cf5 31-Mar-2016 Calin Juravle <calin@google.com> Revert "Revert "Revert "ART: Improve JitProfile perf in arm/arm64 mterp"""

This reverts commit 4a8ac9cee4312ac910fabf31c64d28d4c8362836.

Bug: 27939339
4a8ac9cee4312ac910fabf31c64d28d4c8362836 25-Mar-2016 Bill Buzbee <buzbee@google.com> Revert "Revert "ART: Improve JitProfile perf in arm/arm64 mterp""

Ready for review.

This reverts commit 6aef867f4d1a98a12bcdd65e9bf2ff894f0f2d7e.

Change-Id: I5d53ed2bedc7e429ce7d3cdf80b6696a9628740e
6aef867f4d1a98a12bcdd65e9bf2ff894f0f2d7e 25-Mar-2016 Calin Juravle <calin@google.com> Revert "ART: Improve JitProfile perf in arm/arm64 mterp"

This reverts commit c1d6b341eed646e5adafc6c4fd4e3748f0292368.
c1d6b341eed646e5adafc6c4fd4e3748f0292368 02-Mar-2016 buzbee <buzbee@google.com> ART: Improve JitProfile perf in arm/arm64 mterp

ART currently requires two profiling-related things from the
interpreters: hotness updates and OSR switch checks. The hotness
updates previously used the existing instrumentation framework - which
is flexible, but quite heavyweight. For most things, the
instrumentation framework overhead is acceptable, but because we do a
hotness update on every backwards branch the overhead is unacceptable.
Prior to this CL, branch profiling dominates interpreter cost.

Here, we bypass the instrumentation framework for hotness updates
and deliver a significant performance improvement. Running
interpreter-only (dalvikvm -Xint) on a Nexus 6, we see the logic
subtest of Caffeinemark improving from 2600 to 9200, and the
overall score going from 1979 to over 3000. Compared to the
C++ switch interpreter, we see a 6x improvement on the branchy logic
subtest and a 2.6x improvement overall.

Compared with the previous mterp which did not have support for
jit profiling, we see a few (1% to 5%) performance loss on the
standard command-line benchmarks. I consider this acceptable
(we could create an alternate non-profiling mterp which would
have no penalty, but I don't consider this overhead big enough to
justify that).

Change-Id: I50b5b8c5ed8ebda3c8b4e65d27ba7393c3feae04
50e933188d993c6eb67560db1fcad67ba1d182e1 16-Mar-2016 Mathieu Chartier <mathieuc@google.com> Fix race in AllocEntrypointsInstrumented

We were using the quick_alloc_entry_points_instrumentation_counter_,
this counter is updated before the threads are suspended. The
allocator could come out of a suspend point, see that threads are
supposedly still no instrumented, continue the allocation, then
suddenly quick_alloc_entry_points_instrumentation_counter_ becomes
1 and alloc_tracking_enabled_ becomes true resulting in a failing
DCHECK.

The fix is to add a boolean that is updated only when the threads
are suspended.

Bug: 27506909

(cherry picked from commit 77d993107773b7b9bd7f07ce08d0aaac1631bf84)

Change-Id: Id12983ef77c4fddb0394e4439ce0829777f1a70b
77d993107773b7b9bd7f07ce08d0aaac1631bf84 16-Mar-2016 Mathieu Chartier <mathieuc@google.com> Fix race in AllocEntrypointsInstrumented

We were using the quick_alloc_entry_points_instrumentation_counter_,
this counter is updated before the threads are suspended. The
allocator could come out of a suspend point, see that threads are
supposedly still no instrumented, continue the allocation, then
suddenly quick_alloc_entry_points_instrumentation_counter_ becomes
1 and alloc_tracking_enabled_ becomes true resulting in a failing
DCHECK.

The fix is to add a boolean that is updated only when the threads
are suspended.

Bug: 27506909
Change-Id: Ic3c6716d2af9c00189ce9271f7a2825b03cdd8a0
ab4058c14ad800d20138a6c41b999029d342de2c 01-Mar-2016 Mathieu Chartier <mathieuc@google.com> Fix allocation tracking race

Check if changed from uninstrumented to instrumented during GC for
alloc. If we changed, retry the allocation with kInstrumented = true.

Added stress test.

Bug: 27337759

(cherry picked from commit eebc3af4453f5c1fb5fd80c710cfd49566080d28)

Change-Id: I8fa50975b558199fcf142c8555476053001ace50
eebc3af4453f5c1fb5fd80c710cfd49566080d28 01-Mar-2016 Mathieu Chartier <mathieuc@google.com> Fix allocation tracking race

Check if changed from uninstrumented to instrumented during GC for
alloc. If we changed, retry the allocation with kInstrumented = true.

Added stress test.

Bug: 27337759

Change-Id: Iaad7977693c9ed927f779a66b29cd58341a837da
6ea1a0e2168c8d9b6d97c075c73a72d84080f45b 29-Jan-2016 Mingyao Yang <mingyao@google.com> AOT compile framework code as non-debuggable

When a debugger attaches, we patch method entry points in framework
code to interpreter bridge. The code will later be jitted as debuggable.

Change-Id: Id148069ccad95e2339ba214742ae3ef4f084f495
fd522f9039befff986701ff05054ffdd1be1dd33 11-Feb-2016 Bill Buzbee <buzbee@google.com> Revert "Revert "Revert "Revert "ART: Enable Jit Profiling in Mterp for arm/arm64""""

This reverts commit 5d03317a834efdf3b5240c401f1bc2ceac7a2f25.

We need to catch all possible cases in which new instrumentation appears
or the debugger is attached, and then switch to the reference interpreter
if necessary. We may, in a future CL, use the alt-mterp mechanism to accompish
this (as did Dalvik).

Only enables Arm64 for now. Once it survives extended testing, will enable
arm and update x86.

Updated OSR handling to match other interpreters.

Change-Id: I076f1d752d6f59899876bab26b18e2221cd92f69
5d03317a834efdf3b5240c401f1bc2ceac7a2f25 11-Feb-2016 Nicolas Geoffray <ngeoffray@google.com> Revert "Revert "Revert "ART: Enable Jit Profiling in Mterp for arm/arm64"""

Unfortunately, run-test interpreter on arm32 are still timing out, and the following jdwp tests on armv8 are failing:

org.apache.harmony.jpda.tests.jdwp.Events.EventWithExceptionTest#testBreakpoint_BeforeException (no test history available)
org.apache.harmony.jpda.tests.jdwp.Events.EventWithExceptionTest#testFieldAccess (no test history available)
org.apache.harmony.jpda.tests.jdwp.Events.EventWithExceptionTest#testFieldModification (no test history available)
org.apache.harmony.jpda.tests.jdwp.Events.EventWithExceptionTest#testMethodExit (no test history available)
org.apache.harmony.jpda.tests.jdwp.Events.EventWithExceptionTest#testMethodExitWithReturnValue (no test history available)
org.apache.harmony.jpda.tests.jdwp.Events.FieldAccessTest#testFieldAccessEvent (no test history available)
org.apache.harmony.jpda.tests.jdwp.Events.FieldModification002Test#testFieldModifyEvent (no test history available)
org.apache.harmony.jpda.tests.jdwp.Events.FieldModificationTest#testFieldModifyEvent (no test history available)
org.apache.harmony.jpda.tests.jdwp.Events.MethodExitWithReturnValueTest#testMethodExitWithReturnValueException (no test history available)

This reverts commit 9687f244bdb5dd0b4d9dd804a7c8c7b4a911d364.

Change-Id: Iadac4902ab8d7eb574cc4abeba5f93388d59dcb4
9687f244bdb5dd0b4d9dd804a7c8c7b4a911d364 05-Feb-2016 Bill Buzbee <buzbee@google.com> Revert "Revert "ART: Enable Jit Profiling in Mterp for arm/arm64""

Fixes: missing sign extension in iget template
Call to wrong branch profiling helper in arm/goto_16 and arm/goto_32
Missing export PCs
Reworks: Branch handlers to reduce cost of branch profiling.

Re-enables Jit profiling for both Arm and Arm64.

Performance note:
Branch profiling is relatively expensive, though the real
cost will depend on branch frequency. Taking a very
branch intensive benchmark, CaffeineMark's logic test, we
see the following scores (higher is better):

Mterp (profiling off) 6187
Mterp (profiling on) 4305

Switch (profiling off) 3931
Switch (profiling on) 2032

This reverts commit 95717f0010e7a9445450f4d39babfaf3a83e29b5.

Change-Id: Ia2ef8b54ce95bfa86178b89c43f8a703316b2944
95717f0010e7a9445450f4d39babfaf3a83e29b5 05-Feb-2016 Nicolas Geoffray <ngeoffray@google.com> Revert "ART: Enable Jit Profiling in Mterp for arm/arm64"

Not super happy to revert this, but unfortunately, too many problems when testing:

arm: tests timeout when running run-tests with the interpreter.

arm64 failures:
test-art-target-run-test-ndebug-prebuild-jit-relocate-ntrace-cms-checkjni-image-npictest-ndebuggable-003-omnibus-opcodes64
test-art-target-run-test-ndebug-prebuild-jit-relocate-ntrace-cms-checkjni-image-npictest-ndebuggable-005-annotations64
test-art-target-run-test-ndebug-prebuild-jit-relocate-ntrace-cms-checkjni-image-npictest-ndebuggable-064-field-access64
test-art-target-run-test-ndebug-prebuild-jit-relocate-ntrace-cms-checkjni-image-npictest-ndebuggable-406-fields64

org.apache.harmony.jpda.tests.jdwp.Events.EventWithExceptionTest#testBreakpoint_BeforeException
org.apache.harmony.jpda.tests.jdwp.Events.EventWithExceptionTest#testFieldAccess
org.apache.harmony.jpda.tests.jdwp.Events.EventWithExceptionTest#testFieldModification
org.apache.harmony.jpda.tests.jdwp.Events.EventWithExceptionTest#testMethodExit
org.apache.harmony.jpda.tests.jdwp.Events.EventWithExceptionTest#testMethodExitWithReturnValue
org.apache.harmony.jpda.tests.jdwp.Events.FieldAccessTest#testFieldAccessEvent
org.apache.harmony.jpda.tests.jdwp.Events.FieldModification002Test#testFieldModifyEvent
org.apache.harmony.jpda.tests.jdwp.Events.FieldModificationTest#testFieldModifyEvent
org.apache.harmony.jpda.tests.jdwp.Events.MethodExitWithReturnValueTest#testMethodExitWithReturnValueException

This reverts commit a0a16105423459287497a98129dcba2828ccd7f0.

Change-Id: I8ff0512265ed0a422be67e7410998ad02639509c
a0a16105423459287497a98129dcba2828ccd7f0 04-Feb-2016 buzbee <buzbee@google.com> ART: Enable Jit Profiling in Mterp for arm/arm64

Adds the hooks for branch profiling to arm and arm64. The
other Jit profiling modes are handled in common code.

Stubbed out support for on-stack replacement.

Change-Id: Ic298a81139108c3d7f1325b59d97e14a9de08de6
81f0f953c4bb159997046c962d44cb1898b1778d 20-Jan-2016 Nicolas Geoffray <ngeoffray@google.com> Move backward branch instrumentation to all branch.

This is in preparation for osr, and later dead branch profiling.

Change-Id: I4597c0784c894c310f295dd534967d67dcefa419
3fdb3fec5c36127d8568b2f89698906ba4b68576 14-Jan-2016 Mathieu Chartier <mathieuc@google.com> Don't allow thread suspension in ProfilingInfo::Create

AddSamples calls ProfilingInfo::Create which would occasionally
transition to suspended and wait for code cache GC to complete.
This CL removes the thread state change and
WaitForPotentialCollectionToComplete which caused thread suspension.

The thread suspension caused occasional stale object references in
InvokeVirtualOrInterface since moving GC could occur.
If this_object became stale, we would put it's stale class into the
profile info, resulting in a GC crash.

Bug: 26086970
Change-Id: I5a86561098d72b7be80e8a3bcf3d8401403a0b00
1452bee8f06b9f76a333ddf4760e4beaa82f8099 06-Mar-2015 buzbee <buzbee@google.com> Fast Art interpreter

Add a Dalvik-style fast interpreter to Art.
Three primary deficiencies in the existing Art interpreter
will be addressed:

1. Structural inefficiencies (primarily the bloated
fetch/decode/execute overhead of the C++ interpreter
implementation).
2. Stack memory wastage. Each managed-language invoke
adds a full copy of the interpreter's compiler-generated
locals on the shared stack. We're at the mercy of
the compiler now in how much memory is wasted here. An
assembly based interpreter can manage memory usage more
effectively.
3. Shadow frame model, which not only spends twice the memory
to store the Dalvik virtual registers, but causes vreg stores
to happen twice.

This CL mostly deals with #1 (but does provide some stack memory
savings). Subsequent CLs will address the other issues.

Current status:
Passes all run-tests.
Phone boots interpret-only.
2.5x faster than Clang-compiled Art goto interpreter on fetch/decode/execute
microbenchmark, 5x faster than gcc-compiled goto interpreter.
1.6x faster than Clang goto on Caffeinemark overall
2.0x faster than Clang switch on Caffeinemark overall
68% of Dalvik interpreter performance on Caffeinemark (still much slower,
primarily because of poor invoke performance and lack of execute-inline)
Still nearly an order of magnitude slower than Dalvik on invokes
(but slightly better than Art Clang goto interpreter.
Importantly, saves ~200 bytes of stack memory per invoke (but still
wastes ~400 relative to Dalvik).

What's needed:
Remove the (large quantity of) bring-up hackery in place.
Integrate into the build mechanism. I'm still using the old Dalvik manual
build step to generate assembly code from the stub files.
Remove the suspend check hack. For bring-up purposes, I'm using an explicit
suspend check (like the other Art interpreters). However, we should be
doing a Dalvik style suspend check via the table base switch mechanism.
This should be done during the alternative interpreter activation.
General cleanup.
Add CFI info.
Update the new target bring-up README documentation.
Add other targets.

In later CLs:
Consolidate mterp handlers for expensive operations (such as new-instance) with
the code used by the switch interpreter. No need to duplicate the code for
heavyweight operations (but will need some refactoring to align).
Tuning - some fast paths needs to be moved down to the assembly handlers,
rather than being dealt with in the out-of-line code.
JIT profiling. Currently, the fast interpreter is used only in the fast
case - no instrumentation, no transactions and no access checks. We
will want to implement fast + JIT-profiling as the alternate fast
interpreter. All other cases can still fall back to the reference
interpreter.
Improve invoke performance. We're nearly an order of magnitude slower than
Dalvik here. Some of that is unavoidable, but I suspect we can do
better.
Add support for our other targets.

Change-Id: I43e25dc3d786fb87245705ac74a87274ad34fedc
514a616fd434212815bdd49cc1e2786817395969 03-Nov-2015 Nicolas Geoffray <ngeoffray@google.com> Fix broken handling of instrumentation lists.

- We cannot copy before iterating, as entries might be deleted.
- We cannot remove entries in the list, as mutators could be
currently iterating over it.

Solution in this change is to never remove list entries, but
put null when a listener is removed. When adding a listener, we
will either put it where there is a null slot, or at the end
of the list if there is no null slot.

Change-Id: Id94582fd971cd56bcb445caff64270d21987f700
b2feaafd89813af69c65da95e0b51b1a4cecaf0b 12-Oct-2015 Sebastien Hertz <shertz@google.com> Revert "Revert "Fix instrumentation frame check with inlining""

This reverts commit e3e2fe5ecc16184ba91018adb3bfbec1c5880c29.

Fixes an incorrect CHECK_GT into CHECK_GE in method
Instrumentation::ComputeFrameId.

Bug: 22519499
Change-Id: I0a11d378f3baa728b9176ff086fe4b835b30bb46
e3e2fe5ecc16184ba91018adb3bfbec1c5880c29 12-Oct-2015 Nicolas Geoffray <ngeoffray@google.com> Revert "Fix instrumentation frame check with inlining"

Times out on some run-tests.

Bug: 22519499

This reverts commit 3079e28b00accd19aa1153929fb00497d00956d9.

Change-Id: I4c612a5af20e4481eb9865f90abd429f4a40ce57
3079e28b00accd19aa1153929fb00497d00956d9 06-Oct-2015 Sebastien Hertz <shertz@google.com> Fix instrumentation frame check with inlining

When instrumenting code compiled with inlining, we must compute
frame IDs like instrumentation did for pushing instrumentation
stack frames.

Bug: 22519499
Change-Id: I4a72dbe9e4d2fd4985e49f8261b54c96df7c4a81
aa5168291c46f9b418d989bccf2d8e09338a83e6 03-Oct-2015 Mathieu Chartier <mathieuc@google.com> Add exclusion between instrumentation and GC

Instrumentation calls VisitClasses while exclusive holding the
mutator lock. This can cause deadlocks since VisitClasses needs to
decode JNI weak globals. If the system weak slow path flag is set,
then we wait holding locks while exclusive holding the mutator lock.
This causes a deadlock since the GC cannot acquire the mutator lock
to sweep system weaks.

This fixes a deadlock seen in one of the tracing tests.

Change-Id: I580152118e068a70f309dcc19df4144afec835dd
99170c636dfae4908b102347cfe9f92bad1881cc 06-Jul-2015 Mingyao Yang <mingyao@google.com> Deoptimization support in optimizing compiler for setting local values

Due to compiler optimizations, we may not always be able to update
the value of a local variable in a compiled frame (like a variable
seen as constant by the compiler). To avoid that situation, we simply
deoptimize compiled frames updated by the debugger so they are
executed by the interpreter with the updated value.

When the debugger attempts to set a local variable (actually a DEX
register or a pair of registers) in a compiled frame, we allocate a
ShadowFrame associated to that frame (using its frame id) and set the
new value in that ShadowFrame. When we know we are about to continue
the execution of the compiled frame, we deoptimize the stack using
the preallocated ShadowFrame (instead of creating a new one). We
initialize it with the current value of all DEX registers except
the ones that have been set by the debugger. Therefore, the
ShadowFrame represent the runtime context modified by the debugger.

Bumps oat version to force recompilation.

Bug: 19944235
Change-Id: I0ebe6241264f7a3be0f14ee4516c1f7436e04da6
5550ca8bcc742b109d77e62f3a0877c667d894d3 21-Aug-2015 Nicolas Geoffray <ngeoffray@google.com> Record profiling information before Jitting.

- Add a new instrumentation kind to record dynamic invokes.
- Use the JNI entry point field to store the profiling data.
- Record seen receivers for every dynamic invoke.

Change-Id: I2c1738ab2a72052d45964d055dc16b44b906e54c
90443477f9a0061581c420775ce3b7eeae7468bc 17-Jul-2015 Mathieu Chartier <mathieuc@google.com> Move to newer clang annotations

Also enable -Wthread-safety-negative.

Changes:
Switch to capabilities and negative capabilities.

Future work:
Use capabilities to implement uninterruptible annotations to work
with AssertNoThreadSuspension.

Bug: 20072211

Change-Id: I42fcbe0300d98a831c89d1eff3ecd5a7e99ebf33
3d21bdf8894e780d349c481e5c9e29fe1556051c 22-Apr-2015 Mathieu Chartier <mathieuc@google.com> Move mirror::ArtMethod to native

Optimizing + quick tests are passing, devices boot.

TODO: Test and fix bugs in mips64.

Saves 16 bytes per most ArtMethod, 7.5MB reduction in system PSS.
Some of the savings are from removal of virtual methods and direct
methods object arrays.

Bug: 19264997

(cherry picked from commit e401d146407d61eeb99f8d6176b2ac13c4df1e33)

Change-Id: I622469a0cfa0e7082a2119f3d6a9491eb61e3f3d

Fix some ArtMethod related bugs

Added root visiting for runtime methods, not currently required
since the GcRoots in these methods are null.

Added missing GetInterfaceMethodIfProxy in GetMethodLine, fixes
--trace run-tests 005, 044.

Fixed optimizing compiler bug where we used a normal stack location
instead of double on ARM64, this fixes the debuggable tests.

TODO: Fix JDWP tests.

Bug: 19264997

Change-Id: I7c55f69c61d1b45351fd0dc7185ffe5efad82bd3

ART: Fix casts for 64-bit pointers on 32-bit compiler.

Bug: 19264997
Change-Id: Ief45cdd4bae5a43fc8bfdfa7cf744e2c57529457

Fix JDWP tests after ArtMethod change

Fixes Throwable::GetStackDepth for exception event detection after
internal stack trace representation change.

Adds missing ArtMethod::GetInterfaceMethodIfProxy call in case of
proxy method.

Bug: 19264997
Change-Id: I363e293796848c3ec491c963813f62d868da44d2

Fix accidental IMT and root marking regression

Was always using the conflict trampoline. Also included fix for
regression in GC time caused by extra roots. Most of the regression
was IMT.

Fixed bug in DumpGcPerformanceInfo where we would get SIGABRT due to
detached thread.

EvaluateAndApplyChanges:
From ~2500 -> ~1980
GC time: 8.2s -> 7.2s due to 1s less of MarkConcurrentRoots

Bug: 19264997
Change-Id: I4333e80a8268c2ed1284f87f25b9f113d4f2c7e0

Fix bogus image test assert

Previously we were comparing the size of the non moving space to
size of the image file.

Now we properly compare the size of the image space against the size
of the image file.

Bug: 19264997
Change-Id: I7359f1f73ae3df60c5147245935a24431c04808a

[MIPS64] Fix art_quick_invoke_stub argument offsets.

ArtMethod reference's size got bigger, so we need to move other args
and leave enough space for ArtMethod* and 'this' pointer.

This fixes mips64 boot.

Bug: 19264997
Change-Id: I47198d5f39a4caab30b3b77479d5eedaad5006ab
e401d146407d61eeb99f8d6176b2ac13c4df1e33 22-Apr-2015 Mathieu Chartier <mathieuc@google.com> Move mirror::ArtMethod to native

Optimizing + quick tests are passing, devices boot.

TODO: Test and fix bugs in mips64.

Saves 16 bytes per most ArtMethod, 7.5MB reduction in system PSS.
Some of the savings are from removal of virtual methods and direct
methods object arrays.

Bug: 19264997
Change-Id: I622469a0cfa0e7082a2119f3d6a9491eb61e3f3d
5eae455507399286c845ba54796c47087a72b3e2 01-Apr-2015 Sebastien Hertz <shertz@google.com> Support multiple instrumentation clients

Changes Instrumentation::ConfigureStubs to support multiple clients
that need different levels of instrumenation. A client is identified
by a string key used to save the desired instrumentation level.

Also adds regression gtest instrumentation_test and some cleanup.

Bug: 19829329

(cherry picked from commit 0462c4c87c39db6cfcd338f323844738109ac3c9)

Change-Id: I1fc24a86fcb7cb46d4be806895376c25cc0a0b3c
0462c4c87c39db6cfcd338f323844738109ac3c9 01-Apr-2015 Sebastien Hertz <shertz@google.com> Support multiple instrumentation clients

Changes Instrumentation::ConfigureStubs to support multiple clients
that need different levels of instrumenation. A client is identified
by a string key used to save the desired instrumentation level.

Also adds regression gtest instrumentation_test and some cleanup.

Bug: 19829329
Change-Id: I1fc24a86fcb7cb46d4be806895376c25cc0a0b3c
40da286d3207d88ed8ff3f5caac4873874603428 27-Feb-2015 Andreas Gampe <agampe@google.com> ART: Streaming trace mode

Add a streaming mode for tracing. Streaming uses a buffer of 16KB
and writes to the output when that buffer gets full. Streaming mode
can be enabled with -Xmethod-trace-stream and is currently not
exposed otherwise.

Add a python script that can parse the streaming format, which
simply contains strings for newly encountered threads and methods
inline, and create output that can be used with traceview.

Add Trace::Pause and Trace::Abort, which can pause and abort tracing.
Abort is different from Stop in that it does not write the data.

Add code to the zygote hooks JNI implementation that pauses tracing
before the fork, making sure that a child cannot clobber the parent's
data.

Add code to the zygote hooks JNI implementation that aborts old
tracing and starts new tracing in the child after the fork. Currently
base the output on the pid. This will not work on an unmodified
device, as the profiles directory is not generally writable, but
we do not have enough information at that point. Consider a scheme
that restarts tracing later.

Change-Id: I93c7bf87e35af582bdfdd3ecc7c52454514220dd
c785344b87221f5e4e6473e5b762e4e61fe65dcf 27-Mar-2015 Mathieu Chartier <mathieuc@google.com> Move ArtField to native

Add linear alloc. Moved ArtField to be native object. Changed image
writer to put ArtFields after the mirror section.

Savings:
2MB on low ram devices
4MB on normal devices

Total PSS measurements before (normal N5, 95s after shell start):
Image size: 7729152 bytes
23112 kB: .NonMoving
23212 kB: .NonMoving
22868 kB: .NonMoving
23072 kB: .NonMoving
22836 kB: .NonMoving
19618 kB: .Zygote
19850 kB: .Zygote
19623 kB: .Zygote
19924 kB: .Zygote
19612 kB: .Zygote
Avg: 42745.4 kB

After:
Image size: 7462912 bytes
17440 kB: .NonMoving
16776 kB: .NonMoving
16804 kB: .NonMoving
17812 kB: .NonMoving
16820 kB: .NonMoving
18788 kB: .Zygote
18856 kB: .Zygote
19064 kB: .Zygote
18841 kB: .Zygote
18629 kB: .Zygote
3499 kB: .LinearAlloc
3408 kB: .LinearAlloc
3424 kB: .LinearAlloc
3600 kB: .LinearAlloc
3436 kB: .LinearAlloc
Avg: 39439.4 kB

No reflection performance changes.

Bug: 19264997
Bug: 17643507

Change-Id: I10c73a37913332080aeb978c7c94713bdfe4fe1c
bb87e0f1a52de656bc77cb01cb887e51a0e5198b 03-Apr-2015 Mathieu Chartier <mathieuc@google.com> Refactor and improve GC root handling

Changed GcRoot to use compressed references. Changed root visiting to
use virtual functions instead of function pointers. Changed root visting
interface to be an array of roots instead of a single root at a time.
Added buffered root marking helper to avoid dispatch overhead.

Root marking seems a bit faster on EvaluateAndApplyChanges due to batch
marking. Pause times unaffected.

Mips64 is untested but might work, maybe.

Before:
MarkConcurrentRoots: Sum: 67.678ms 99% C.I. 2us-664.999us Avg: 161.138us Max: 671us

After:
MarkConcurrentRoots: Sum: 54.806ms 99% C.I. 2us-499.986us Avg: 136.333us Max: 602us

Bug: 19264997

Change-Id: I0a71ebb5928f205b9b3f7945b25db6489d5657ca
0aa50ce2fb75bfc2e815a0c33adf9b049561923b 10-Mar-2015 Nicolas Geoffray <ngeoffray@google.com> Remove ThrowLocation.

Note that this is a cleanup change, and has no functionality change.
The ThrowLocation had no use anymore.

Change-Id: I3d2126af1dc673cec3a0453ff3d56a172663a5f6
14691c5e786e8c2c5734f687e4c96217340771be 05-Mar-2015 Nicolas Geoffray <ngeoffray@google.com> Compute the right catch location for the debugger.

Also remove tls ThrowLocation, it is not needed anymore.

Change-Id: I78fddf09ce968ca475e39c17fa76d699c589c8d9
e5f13e57ff8fa36342beb33830b3ec5942a61cca 24-Feb-2015 Mathieu Chartier <mathieuc@google.com> Revert "Revert "Add JIT""

Added missing EntryPointToCodePointer.

This reverts commit a5ca888d715cd0c6c421313211caa1928be3e399.

Change-Id: Ia74df0ef3a7babbdcb0466fd24da28e304e3f5af
a5ca888d715cd0c6c421313211caa1928be3e399 24-Feb-2015 Nicolas Geoffray <ngeoffray@google.com> Revert "Add JIT"

Sorry, run-test crashes on target:
0-05 12:15:51.633 I/DEBUG (27995): Abort message: 'art/runtime/mirror/art_method.cc:349] Check failed: PcIsWithinQuickCode(reinterpret_cast<uintptr_t>(code), pc) java.lang.Throwable java.lang.Throwable.fillInStackTrace() pc=71e3366b code=0x71e3362d size=ad000000'
10-05 12:15:51.633 I/DEBUG (27995): r0 00000000 r1 0000542b r2 00000006 r3 00000000
10-05 12:15:51.633 I/DEBUG (27995): r4 00000006 r5 b6f9addc r6 00000002 r7 0000010c
10-05 12:15:51.633 I/DEBUG (27995): r8 b63fe1e8 r9 be8e1418 sl b6427400 fp b63fcce0
10-05 12:15:51.633 I/DEBUG (27995): ip 0000542b sp be8e1358 lr b6e9a27b pc b6e9c280 cpsr 40070010
10-05 12:15:51.633 I/DEBUG (27995):

Bug: 17950037
This reverts commit 2535abe7d1fcdd0e6aca782b1f1932a703ed50a4.

Change-Id: I6f88849bc6f2befed0c0aaa0b7b2a08c967a83c3
2535abe7d1fcdd0e6aca782b1f1932a703ed50a4 17-Feb-2015 Mathieu Chartier <mathieuc@google.com> Add JIT

Currently disabled by default unless -Xjit is passed in.

The proposed JIT is a method JIT which works by utilizing interpreter
instrumentation to request compilation of hot methods async during
runtime.

JIT options:
-Xjit / -Xnojit
-Xjitcodecachesize:N
-Xjitthreshold:integervalue

The JIT has a shared copy of a compiler driver which is accessed
by worker threads to compile individual methods.

Added JIT code cache and data cache, currently sized at 2 MB
capacity by default. Most apps will only fill a small fraction of
this cache however.

Added support to the compiler for compiling interpreter quickened
byte codes.

Added test target ART_TEST_JIT=TRUE and --jit for run-test.

TODO:
Clean up code cache.
Delete compiled methods after they are added to code cache.
Add more optimizations related to runtime checks e.g. direct pointers
for invokes.
Add method recompilation.
Move instrumentation to DexFile to improve performance and reduce
memory usage.

Bug: 17950037

Change-Id: Ifa5b2684a2d5059ec5a5210733900aafa3c51bca
a10aa3789544cf62a2d362c032ea8d9532b47b39 21-Jan-2015 Sebastien Hertz <shertz@google.com> Follow up on CL 123650

Change-Id: If575fdb9cc73e312e222e6853890e8dacd83b284
956af0f0cb05422e38c1d22cbef309d16b8a1a12 11-Dec-2014 Elliott Hughes <enh@google.com> Remove portable.

Change-Id: I3bf3250fa866fd2265f1b115d52fa5dedc48a7fc
a7dd0386f35c0ba4aef3f5b16bc84c6f4e2fc702 21-Nov-2014 Mathieu Chartier <mathieuc@google.com> Fix oatdump to use OatHeader pointer size

Bug: 18473190
Change-Id: If505b4f62105899f4f1257d3bccda3e6eb0dcd7c

(cherry picked from commit c934e483ceabbd589422beea1fa35f5182ecfa99)
c934e483ceabbd589422beea1fa35f5182ecfa99 21-Nov-2014 Mathieu Chartier <mathieuc@google.com> Fix oatdump to use OatHeader pointer size

Bug: 18473190
Change-Id: If505b4f62105899f4f1257d3bccda3e6eb0dcd7c
d582fa4ea62083a7598dded5b82dc2198b3daac7 06-Nov-2014 Ian Rogers <irogers@google.com> Instruction set features for ARM64, MIPS and X86.

Also, refactor how feature strings are handled so they are additive or
subtractive.
Make MIPS have features for FPU 32-bit and MIPS v2. Use in the quick compiler
rather than #ifdefs that wouldn't have worked in cross-compilation.
Add SIMD features for x86/x86-64 proposed in:
https://android-review.googlesource.com/#/c/112370/

Bug: 18056890

Change-Id: Ic88ff84a714926bd277beb74a430c5c7d5ed7666
6a3c1fcb4ba42ad4d5d142c17a3712a6ddd3866f 31-Oct-2014 Ian Rogers <irogers@google.com> Remove -Wno-unused-parameter and -Wno-sign-promo from base cflags.

Fix associated errors about unused paramenters and implict sign conversions.
For sign conversion this was largely in the area of enums, so add ostream
operators for the effected enums and fix tools/generate-operator-out.py.
Tidy arena allocation code and arena allocated data types, rather than fixing
new and delete operators.
Remove dead code.

Change-Id: I5b433e722d2f75baacfacae4d32aef4a828bfe1b
9ef78b59da51080882e47505896b420977fd79ae 26-Sep-2014 Mathieu Chartier <mathieuc@google.com> Fix broken runtime SetStatsEnabled logic

Previously, Runtime::SetStatsEnabled wouldn't take stats_enabled_
into account when deciding whether or not to increment / decrement
teh stats enabled counter. This resulted in counter underflows and
other errors which caused some CTS tests to fail.

Also added some locking to prevent race conditions.

Bug: 17360878

(cherry picked from commit a98ffd745bbecb2e84a492194950c0b94966546b)

Change-Id: I21d241a58d35bd6a607aa2305c6da81720bd0886
a98ffd745bbecb2e84a492194950c0b94966546b 26-Sep-2014 Mathieu Chartier <mathieuc@google.com> Fix broken runtime SetStatsEnabled logic

Previously, Runtime::SetStatsEnabled wouldn't take stats_enabled_
into account when deciding whether or not to increment / decrement
teh stats enabled counter. This resulted in counter underflows and
other errors which caused some CTS tests to fail.

Also added some locking to prevent race conditions.

Bug: 17360878

Change-Id: I779237d55dda4f35054a4d27fb2c660a38750fc0
69dbec6d9d55eeb2867949c2791d01dc9aa916c8 16-Sep-2014 Jeff Hao <jeffhao@google.com> Avoid suspending for alloc trace enabling when already suspended.

Bug: 17499772

(cherry picked from commit 1d6ee090fddd4bfd35c304d6ceb929d5c529dfcc)

Change-Id: Id09809c476c685f0a197ee75bb08638931364efd
1d6ee090fddd4bfd35c304d6ceb929d5c529dfcc 16-Sep-2014 Jeff Hao <jeffhao@google.com> Avoid suspending for alloc trace enabling when already suspended.

Bug: 17499772
Change-Id: Id98c10967b28e8859e5ac46f5878c304fb85c498
ed2be1725fb79075892b1a9103487c9d9a95b350 19-Aug-2014 Sebastien Hertz <shertz@google.com> Reduce lock contention when debugging

Uses a ReaderWriterMutex for the breakpoint lock to reduce contention during
debugging session.

Also adds missing thread safety annotations on fields and methods related to
instrumentation and debugging.

Bug: 16814665
Bug: 11667502

(cherry picked from commit 59d9d668d4f4286813afe2b4e7c6db839222ce96)

Change-Id: I5f1156da8c6cc8316d6db16e6cfb2470fe289ad3
59d9d668d4f4286813afe2b4e7c6db839222ce96 19-Aug-2014 Sebastien Hertz <shertz@google.com> Reduce lock contention when debugging

Uses a ReaderWriterMutex for the breakpoint lock to reduce contention during
debugging session.

Also adds missing thread safety annotations on fields and methods related to
instrumentation and debugging.

Bug: 16814665
Bug: 11667502
Change-Id: I056cdafa91109e0c83806c8d8df75c37ade0a354
96add97815ba8418fb4e8c0fc08dbf9c7198f244 18-Aug-2014 Daniel Mihalyi <daniel.mihalyi@mattakis.com> Optimized instrumentation listener handling

Some instrumentation listener lists may be modified while iterating
over the list to deliver an instrumentation event. Therefore the
previous implementation copied the list of listeners before starting
the iteration.

This new implementation only copies the list of instrumentation
listeners when the list is changed. Instances of the list are
reference counted using std::shared_ptr<>.

Bug: 16814665

(cherry picked from commit ca1d06cfa2f2b8d2be4390644e126cb68cdbb5ba)

Change-Id: Ib2e6b980de85b75f1c8f4a8825bdc7767154663a
ca1d06cfa2f2b8d2be4390644e126cb68cdbb5ba 18-Aug-2014 Daniel Mihalyi <daniel.mihalyi@mattakis.com> Optimized instrumentation listener handling

Some instrumentation listener lists may be modified while iterating
over the list to deliver an instrumentation event. Therefore the
previous implementation copied the list of listeners before starting
the iteration.

This new implementation only copies the list of instrumentation
listeners when the list is changed. Instances of the list are
reference counted using std::shared_ptr<>.

Change-Id: I1b84db1f2042836dc1110925243f49e5790156d6
94f7b49578b6aaa80de8ffed230648d601393905 23-Jul-2014 Hiroshi Yamauchi <yamauchi@google.com> Add GcRoot to clean up and enforce read barriers.

Introduce a value-type wrapper around Object* for GC roots so that 1)
we won't have to directly add the read barrier code in many places and
2) we can avoid accidentally bypassing/missing read barriers on GC
roots (the GcRoot interface ensures that the read barrier is executed
on a read).

The jdwp test passed.

Bug: 12687968
Change-Id: Ib167c7c325b3c7e3900133578815f04d219972a1
799eb3a5555254427db269921042419bc30d4d86 19-Jul-2014 Hiroshi Yamauchi <yamauchi@google.com> Add read barriers for the GC roots in Instrumentation.

Bug: 12687968
Change-Id: I324e2f950ce4500b0e00722044af3a9c82487b23
9f1020305292a21fd14a402b189c765a125226ab 23-May-2014 Sebastien Hertz <shertz@google.com> Fix exception reporting from interpreter

To comply with JDWP exception report rules, we must report an exception at the
location of the throw (or the first instruction encountered after a native
call). To do this, we use the CatchLocationFinder visitor to look for a catch
handler until we reach a native frame or the top frame.

Because interpreter handles pending exception on a method-by-method basis, we
need a flag to remember we already reported the exception and avoid reporting
it multiple times when unwinding methods. The drawback is we need to maintain
the state of this flag. We clear it when the exception is cleared. In the case
we temporarily clear the exception (when finding a catch handler for instance),
we restore the flag to its previous value at the same time we restore the
pending exception.

Bump oat version to force recompilation because we modify Thread offsets.

Bug: 14402770
Change-Id: Ic059c58f80b2023b118038301f8f0a24f1e18241
d58342caa97108ba413bad467c285c0377f138f5 05-Jun-2014 Andreas Gampe <agampe@google.com> ART: Add instrumentation stubs for ARM64 and X86-64

Adds instrumentation stubs necessary for debugger support.

Refactors MethodAndCode to a top-level TwoWordReturn. A function
having a return type of TwoWordReturn will return its two-word
content, either 2x32b or 2x64b, in two registers according to
the architecture's ABI.

Bug: 15443938
Change-Id: Id7e1fbd4ad8eb6f29e23d48903c76f77b28d981a
576ca0cd692c0b6ae70e776de91015b8ff000a08 07-Jun-2014 Ian Rogers <irogers@google.com> Reduce header files including header files.

Main focus is getting heap.h out of runtime.h.

Change-Id: I8d13dce8512816db2820a27b24f5866cc871a04b
42cd43fa593e8f0427eb0ec158bef08814a6180b 13-May-2014 Sebastien Hertz <shertz@google.com> Register debugger for interesting instrumentation events only

This avoids the overhead of notifying events (like method entry/exit, field
read/write, ...) from the interpreter when they are not requested on the JDWP
side. It also avoids burning JDWP ids for objects and classes before we find
out we do not need to report the event.

When we register a JDWP event (like a breakpoint), we add the debugger as
a listener for the corresponding instrumentation event (like kDexPcChanged).
On the other hand, when a JDWP event is cleared, we remove the debugger as a
listener for the corresponding instrumentation event. To control we add/remove
the debugger as listener only once per instrumentation event, we use reference
counting.

Like deoptimization, we can update instrumentation listeners only when when all
mutator threads are suspended. To add or remove the debugger as listener, we
extend the support of deoptimization requests to a more general support dealing
with instrumentation requests.
We add kRegisterForEvent and kUnregisterForEvent request kinds, respectively to
add or remove the debugger as a listener for a given instrumentation event.
Note: we will rename the related classes, methods, ... to avoid pollution in
the code review.

This CL also fixes Instrumentation::IsActive to take field read/write events
into account.

Bug: 14401699
Bug: 14826953
Change-Id: Ic896469e82a8589de419ebea4b9dc3116925f3ab
3f52eafe5577b8489f90dc8ed5981b3455206147 04-Apr-2014 Sebastien Hertz <shertz@google.com> Prepare field watchpoint support

Adds field read/write events in the instrumentation. The debugger now registers
as a listener for these events so JDWP field access and field modification
events can be reported.

This CL will be followed by another one to report these events from the
interpreter. Therefore no JDWP field access and field modification events
can be sent for now.

Bug: 8267708
Change-Id: If2a93eb590805567d69015c83cce9cd2ab712cbd
a76a6d4cb3dedec909bd927f20bc0ab23198a337 20-Mar-2014 Sebastien Hertz <shertz@google.com> Support inlining with breakpoint

When installing/uninstalling a breakpoint in a method, we fully or selectively
deoptimize/undeoptimize depending on whether the method can be inlined. When
the method can be inlined, it requires full deoptimization. Otherwise, it only
requires selective deoptimization.

We add sanity check to control we are in a consistent state each time we add or
remove a breakpoint. We also add some comments to better describe the process
of deoptimization for breakpoint.

Bug: 12187616
Change-Id: Id15adc6e5e2fe783c83c925cbcd19ae02431b7e0
4d25df3f76f864b7629ac8c0046d46997f293d8d 21-Mar-2014 Sebastien Hertz <shertz@google.com> Refactor deoptimization support in debugger

This CL prepares breakpoint support for inlined methods where we'll have to
deoptimize everything.

We move deoptimization-related information to Dbg class only (deoptimization
request queue, full deoptimization event count and deoptimization lock). We
replace MethodInstrumentionRequest by DeoptimizationRequest. This is used to
know which kind of deoptimization is required for a particular event.

It also simplifies lock ordering a bit during event setup: we no longer need to
hold the deoptimization lock while holding the breakpoint lock. Moreover, the
deoptimization lock should be held only after the event list lock.

Bug: 12187616
Change-Id: Iff13f004adaeb25e5d609238bacce0b9720510e6
3b05e9ba874449dbff65b01b8781001f7d93eea6 25-Mar-2014 Mathieu Chartier <mathieuc@google.com> Add missing debugger root visiting.

Bug: 13634574
Change-Id: I2a76f6c43f1d0ad1922f06deb40a71ff651129fd
719d1a33f6569864f529e5a3fff59e7bca97aad0 06-Mar-2014 Ian Rogers <irogers@google.com> Enable annotalysis on clang ART builds.

Fix clang build errors aswell as restructure locking/mutex code for correct
thread safety analysis support.
Reorder make dependencies so that host builds build first as they should
provide better compilation errors than target.
Remove host's use of -fno-omit-frame-pointer as it has no value with correct
use of CFI, which we should have.

Change-Id: I72cea8da9a3757b1a0b3acb4081feccb7c6cef90
661974a5561e5ccdfbac8cb5d8df8b7e6f3483b8 09-Jan-2014 Mathieu Chartier <mathieuc@google.com> Fix valgrind gtests and memory leaks.

All tests pass other than image_test which passes if some bad reads
are disabled (buzbee working on this).

Change-Id: Ifd6b6e3aed0bc867703b6e818353a9f296609422
d889178ec78930538d9d6a66c3df9ee9afaffbb4 02-Mar-2014 Mathieu Chartier <mathieuc@google.com> Guard entrypoint changing by runtime shutdown lock.

There was a race when we changed the allocation entrypoints where a
new thread would be starting (Thread::Init) and initialize to the
wrong entrypoints. Guarding allocation entrypoint changing
with the runtime shutdown lock fixes this race condition since
Thread::Init is only called with the runtime shutdown lock held.

Bug: 13250963

Change-Id: I8eb209c124b6bf17020de874e1b0083f158b8200
563b47cc142e477da244539b1d63070425e7fd78 01-Mar-2014 Hiroshi Yamauchi <yamauchi@google.com> Fix the bug that some compiled code was invoked with -Xint.

Some compiled code (probably static methods) is still being invoked
with -Xint. Added an assert to detect this case.

Bug: 13250375
Change-Id: Iecfe8ef40c6c326962593db78e6e1d9f1c93842e
11d40c250ec86c784cf76b8c31e1cf9285d555dc 19-Feb-2014 Sebastien Hertz <shertz@google.com> Fix deoptimization deadlock

Fixes a deadlock occuring during undeoptimization on debugging session end.

Before disconnecting debugger, we must unregister all requested events. We take
the event list lock to browse all these events. Some of them (as METHOD_EXIT)
may have activated deoptimization so we need to undeoptimize. During this
process, we restore all original entrypoints of every method in the stack and
notify method exit events to the instrumentation listener (see method
InstrumentationLister::MethodExited). In our case, the instrumentation listener
is the debugger. It takes the event list lock (to browse the event list and see
if this event must be posted) but hangs waiting for it. Since it's already
holding the event list lock (which is not recursive), it ends up in a deadlock
situation.

This CL fixes the way we prevent from posting method enter/exit events during
the process of deoptimization/undeoptimization. We now explicitly set a flag
indicating if deoptimization is enabled (by the debugger).

Also removes unused field in InstallStackVisitor class and remove debugger as
listener before disabling deoptimization to ensure it does not receive any
event when disconnecting.

Change-Id: I49a2ae43e86cf29094f4b462bfa754d7740d3e97
ef7d42fca18c16fbaf103822ad16f23246e2905d 06-Jan-2014 Ian Rogers <irogers@google.com> Object model changes to support 64bit.

Modify mirror objects so that references between them use an ObjectReference
value type rather than an Object* so that functionality to compress larger
references can be captured in the ObjectRefererence implementation.
ObjectReferences are 32bit and all other aspects of object layout remain as
they are currently.

Expand fields in objects holding pointers so they can hold 64bit pointers. Its
expected the size of these will come down by improving where we hold compiler
meta-data.
Stub out x86_64 architecture specific runtime implementation.
Modify OutputStream so that reads and writes are of unsigned quantities.
Make the use of portable or quick code more explicit.
Templatize AtomicInteger to support more than just int32_t as a type.
Add missing, and fix issues relating to, missing annotalysis information on the
mutator lock.
Refactor and share implementations for array copy between System and uses
elsewhere in the runtime.
Fix numerous 64bit build issues.

Change-Id: I1a5694c251a42c9eff71084dfdd4b51fff716822
138dbfc3336e379d74d157086f69a0fbe830089b 04-Dec-2013 Sebastien Hertz <shertz@google.com> Selective deoptimization.

Update the instrumentation to allow selective deoptimization.

Separate instrumentation listener registration from stubs configuration. A
listener is now responsible for configuring the appropriate stubs.
- The method tracing listener installs instrumentation entry/exit stubs or
the interpreter depending on the accuracy of events we want (controlled by
kDeoptimizeForAccurateMethodEntryExitListeners).
- The debugger registers itself as an instrumentation listener but does not
modify methods entrypoints. It only does this on demand when deoptimizing one
method or all the methods.

The selective deoptimization is used for breakpoint only. When a breakpoint is
requested, the debugger deoptimizes this method by setting its entrypoint to
the interpreter stub. As several breakpoints can be set on the same method, we
deoptimize only once. When the last breakpoint on a method is removed, we
reoptimize it by restoring the original entrypoints.

The full deoptimization is used for method entry, method exit and single-step
events. When one of these events is requested, we force eveything to run with
the interpreter (except native and proxy methods). When the last of these
events is removed, we restore all methods entrypoints except those which are
currently deoptimized.

Deoptimizing a method requires all mutator threads be suspended in order to
walk each thread's stack and ensure no code is actually executing while we
modify methods entrypoints. Suspending all the threads requires to not hold
any lock.
In the debugger, we deoptimize/undeoptimize when the JDWP event list changes
(add or remove a breakpoint for instance). During the update, we need to hold
the JDWP event list lock. This means we cannot suspend all the threads at this
time.
In order to deal with these constraints, we support a queue of deoptimization
requests. When an event needs selective/full deoptimization/undeoptimization,
we save its request in the queue. Once we release the JDWP event list lock, we
suspend all the threads, process this queue and finally resume all the threads.
This is done in Dbg::ManageDeoptimization. Note: threads already suspended
before doing this remain suspended so we don't "break" debugger suspensions.

When we deoptimize one method or every method, we need to browse each thread's
stack to install instrumentation exit PC as return PC and save information in
the instrumentation stack frame. Now we can deoptimize multiple times during
the execution of an application, we need to preserve exisiting instrumentation
frames (which is the result of a previous deoptimization). This require to push
new instrumentation frames before existing ones so we don't corrupt the
instrumentation stack frame while walking the stack.

Bug: 11538162
Change-Id: I477142df17edf2dab8ac5d879daacc5c08a67c39
cbb2d20bea2861f244da2e2318d8c088300a3710 15-Nov-2013 Mathieu Chartier <mathieuc@google.com> Refactor allocation entrypoints.

Adds support for switching entrypoints during runtime. Enables
addition of new allocators with out requiring significant copy
paste. Slight speedup on ritzperf probably due to more inlining.

TODO: Ensuring that the entire allocation path is inlined so
that the switch statement in the allocation code is optimized
out.

Rosalloc measurements:
4583
4453
4439
4434
4751

After change:
4184
4287
4131
4335
4097

Change-Id: I1352a3cbcdf6dae93921582726324d91312df5c9
51db44a194bafc3810a41164a8b39614f10e79df 19-Nov-2013 Sebastien Hertz <shertz@google.com> Propagate 'this_object' for method unwind event.

Propagates the 'this_object' to InstrumentationListener::MethodUnwind callback.

Change-Id: I12561f1a611b8399b94e669f9b8a6eaaf1a58631
5bfd5c9e75b31afab2cb3676b8dc71e58a7d90df 15-Nov-2013 Sebastien Hertz <shertz@google.com> Fix missing class initialization during instrumentation.

Static methods (except the <clinit>) all point to the resolution trampoline
to handle class initialization. When we enable instrumentation, we update the
entry point to the instrumentation stub. But doing so makes us miss the call
into the trampoline.

This CL fixes this issue by leaving the resolution trampoline. Once a method's
class is initialized, we update all its static methods' entry point. When
instrumentation is enabled, this entry point becomes the instrumentation entry
stub.

This also allows to post method enter events in the right order during static
invokes. First, we get into the trampoline which call the method's class
<clinit> method and post the corresponding "method enter" event. Then we get
into the instrumentation entry stub of the static method being called and post
the corresponding "method enter" event before getting into its code.

Bug: 11686442
Change-Id: I202db921225c8be0b2191074d09b0ba40f9248b2
fa82427c68b09f4aedbee319dc71579afbfc66f5 06-Nov-2013 Ian Rogers <irogers@google.com> Fix oatdump and valgrind.

Bug: 11531382
Move allocation instrumentation out of runtime into instrumentation. Don't
attempt to suspend threads in unstarted runtimes.
Make indentation support sputc returning eof, on which it will sync and try
again. A further failure likely means the disk is full.
Move the dump-oat output directory to be art as now there's too much output to
fit all the dump-oat data in our standard /tmp.

Change-Id: I8ea848ace318552c180e2efa46570288ff1ca62c
ee1997a3b83334985e757f369c09e111b121661b 19-Sep-2013 Sebastien Hertz <shertz@google.com> Improve interpreter handler table management.

We still have two handlers table:
- the "main" table which holds execution handlers of each instruction,
- the "alternative" table which holds handlers supporting instrumentation
before jumping to the corresponding instruction handler from the "main" table.

Instrumentation holds the index of the handler table the interpreter must use.
This index is represented by the InterpreterHandlerTable enum and is stored in
the Instrumentation::interpreter_handler_table_ field.

Interpreter's current handler table update happens:
- on backward branch
- after invoke
- when throwing exception.
In the case of the backward branch and exception, we only update the table if
any thread's flags is set. This allows to only do one test for handling thread
suspension and handler table update.

This CL also removes the local variable "instrumentation". Every handler which
needs it will get it from Runtime::Current()->GetInstrumentation().

Change-Id: Id886ea7ebf3dac1285f0ca701c098aee7ebaab8d
947ff080753c786a74f1cd7aeb09f717bb7074bd 17-Sep-2013 Sebastien Hertz <shertz@google.com> Load shadow frame's this object only upon instrumentation.

We used to load the shadow frame's this object when entering the interpreter
and push it into thread's SIRT to make it visible to garbage collector. But
it is only used by instrumentation listeners.

We now move this load at each place an instrumentation listener is called. This
avoids loading it when instrumentation is disabled. This also allows to remove
the SIRT reference and the push/pop management it implies when entering/exiting
the interpreter.

The performance improvement is 6% in average on our benchmarks suite.

This CL also makes method Instrumentation::ExceptionCaughtEvent const so we can
use a "const instrumentation::Instrumentation*" object in interpreter.

Change-Id: I2caccba9a906f244c8057b24031250f9824cc711
ea46f950e7a51585db293cd7f047de190a482414 30-Jul-2013 Brian Carlstrom <bdc@google.com> Refactor java.lang.reflect implementation

Cherry-picked from commit ed41d5c44299ec5d44b8514f6e17f802f48094d1.

Move to ArtMethod/Field instead of AbstractMethod/Field and have
java.lang.reflect APIs delegate to ArtMethod/ArtField.

Bug: 10014286.

Change-Id: Iafc1d8c5b62562c9af8fb9fd8c5e1d61270536e7
fc0e3219edc9a5bf81b166e82fd5db2796eb6a0d 17-Jul-2013 Brian Carlstrom <bdc@google.com> Fix multiple inclusion guards to match new pathnames

Change-Id: Id7735be1d75bc315733b1773fba45c1deb8ace43
65d15d985a27be01e1d64f473af0e9d8eb19051d 17-Jul-2013 Jeff Hao <jeffhao@google.com> Fixes to instrumentation for debug build and interpreter.

- Stub uninstall will put back the interpreter entry point if Xint
mode is specified.
- Copy method entry and exit listeners before iterating over them
to prevent problems that occur when they are modified during
iteration.
- Corrected checks from WalkStack and AssertPcIsWithinCode to
handle instrumented code since they are used to remove the stubs.

Change-Id: Ib0e2b421e6b56d520e4643699624dd80ee5148e3
7940e44f4517de5e2634a7e07d58d0fb26160513 12-Jul-2013 Brian Carlstrom <bdc@google.com> Create separate Android.mk for main build targets

The runtime, compiler, dex2oat, and oatdump now are in seperate trees
to prevent dependency creep. They can now be individually built
without rebuilding the rest of the art projects. dalvikvm and jdwpspy
were already this way. Builds in the art directory should behave as
before, building everything including tests.

Change-Id: Ic6b1151e5ed0f823c3dd301afd2b13eb2d8feb81