History log of /art/runtime/thread.cc
Revision Date Author Comments
f5f462b8e448c13d30094d0d259d8b06bc525376 15-Dec-2016 Calin Juravle <calin@google.com> Add Thread entry to signal if the thread can call into java

Compiler threads (AOT or JIT) should not call into Java as they have no
peers (which may lead to crashes, e.g. b/33067273)

(cherry picked from commit ccd56958eb46fbb00c1eb45c7a7b23d5bbfd7698)

Bug: 32602185
Bug: 33067273

Test: m test-art-host-run-test; m test-art-host-gtest
Change-Id: I97dda7a5444643db3c5d5318339a65a602f709e8
12c08f03f65acc1c308491fc7ab6c57f682e2f24 13-May-2016 Jeff Hao <jeffhao@google.com> Make quick frames of proxy methods visited if they're constructors.

Also adds a test case for getting annotations during moving GC.

Bug: 28510922
Change-Id: Ic9b849cd16321da3a3a609182dcdea08782496f9
e55fda1373abad5ace4409453c51aeb0daaf99ef 28-Apr-2016 Calin Juravle <calin@google.com> Fix how the ProfileSaver thread attaches to the runtime.

If the runtime is shutting down we can't attach new threads. In this
case it is expected that Runtime::Attach returns nullptr.

Also, lower the serverity of the log to warning so that it does not
show up in the run-tests.

Bug: 28435649
Change-Id: I208bcd6f0f7e35ae6471e263dee00d3ab68b3b8f
cdca476bf3394ce9d97a369e84e701b427009318 28-Apr-2016 Mathieu Chartier <mathieuc@google.com> Revert "Revert "Write conflict tables in image""

Added test.

Bug: 27906566

This reverts commit 8e2478d23e89a7022c93ddc608dcbba7b29b91e6.

Change-Id: I0894f5f7cd11af29ed9d0345b51f527fc8a41d19
8e2478d23e89a7022c93ddc608dcbba7b29b91e6 27-Apr-2016 Mathieu Chartier <mathieuc@google.com> Revert "Write conflict tables in image"

Some strange issues on angler.

This reverts commit cda9386add68d94697449c6cb08b356747e55c21.

Change-Id: Iba3a8bac6ce40ee16d83163823356951fecb6787
cda9386add68d94697449c6cb08b356747e55c21 14-Apr-2016 Mathieu Chartier <mathieuc@google.com> Write conflict tables in image

Add image sections for runtime methods and conflict tables. This
makes it that we do not need to fake up a length prefixed array
for runtime methods.

Reduces .art private dirty and PSS.

System wide .art PSS goes from 32.5MB to 30.5MB after system boot.

Business card .art private dirty goes from 588K to 504K.

Increases image size by ~100K.

Bug: 27906566

Change-Id: I38cbe3150c3eeb385b8cad7cf93614e3980f4162
8fff24953c78bd58f3a42ac83b340b90e7e7228a 15-Apr-2016 Calin Juravle <calin@google.com> Allow the framework to register sensistive threads to the runtime

Bug: 27865109
Bug: 28065407
Change-Id: Ieac3215879c40b16eb21b47a457fd0345d45177a
b2771b41a956b50266d4d83fbb067f99faf7b7dc 07-Apr-2016 Calin Juravle <calin@google.com> Add option to tune sample collection based on thread sensitivity

Bug: 28065407
Bug: 27865109

Change-Id: Icdb89f8f8874a41c07e73185523d18e8956620d3
9d07e3d128ccfa0ef7670feadd424a825e447d1d 31-Mar-2016 Vladimir Marko <vmarko@google.com> Clean up OatQuickMethodHeader after Quick removal.

This reduces the size of the pre-header by 8 bytes, reducing
oat file size and mmapped .text section size. The memory
needed to store a CompiledMethod by dex2oat is also reduced,
for 32-bit dex2oat by 8B and for 64-bit dex2oat by 16B. The
aosp_flounder-userdebug 32-bit and 64-bit boot.oat are each
about 1.1MiB smaller.

Disable the broken StubTest.IMT, b/27991555 .

Change-Id: I05fe45c28c8ffb7a0fa8b1117b969786748b1039
b0026b41f3d05eae3360c171d3e5baffc19a1bf6 01-Apr-2016 Mathieu Chartier <mathieuc@google.com> Disable checks for b/27493510

Disabled for performance now that the bug is fixed. Still enabled
for debug builds.

Bug: 27493510

(cherry picked from commit 8790c7f9f7d684bff40d5731b2d8e3462ef8ed90)

Change-Id: I049d4319bca1114bd11a35bb13fc9d80c993260c
8790c7f9f7d684bff40d5731b2d8e3462ef8ed90 01-Apr-2016 Mathieu Chartier <mathieuc@google.com> Disable checks for b/27493510

Disabled for performance now that the bug is fixed. Still enabled
for debug builds.

Bug: 27493510
Change-Id: I4838b63d79163b97b47e13b201349a72c352ff38
09ed09866da6d8c7448ef297c148bfa577a247c2 12-Feb-2016 David Srbecky <dsrbecky@google.com> Pack stack map entries on bit level to save space.

Use only the minimum number of bits required to store stack map data.
For example, if native_pc needs 5 bits and dex_pc needs 3 bits, they
will share the first byte of the stack map entry.

The header is changed to store bit offsets of the fields rather than
byte sizes. Offsets also make it easier to access later fields without
calculating sum of all previous sizes.

All of the header fields are byte sized or encoded as ULEB128 instead
of the previous fixed size encoding. This shrinks it by about half.

It saves 3.6 MB from non-debuggable boot.oat (AOSP).
It saves 3.1 MB from debuggable boot.oat (AOSP).

It saves 2.8 MB (of 99.4 MB) from /system/framework/arm/ (GOOG).
It saves 1.0 MB (of 27.8 MB) from /system/framework/oat/arm/ (GOOG).

Field loads from stackmaps seem to get around 10% faster.
(based on the time it takes to load all stackmap entries from boot.oat)

Bug: 27640410
Change-Id: I8bf0996b4eb24300c1b0dfc6e9d99fe85d04a1b7
bf9611f821697b14bf9e170f503c3f47613b046b 26-Mar-2016 Andreas Gampe <agampe@google.com> ART: Clean up verifier

Clean up verifier post-Quick.

Change-Id: I0b05e10dd06edd228fe2068c8afffc4b7d7fdffa
1fbd4520f9067439f09b98753b0c7c221930aa76 22-Mar-2016 Roland Levillain <rpl@google.com> Fix missing header inclusion in art/runtime/thread.cc.

The file art/runtime/thread.cc was missing an #include of
art/runtime/gc/accounting/heap_bitmap-inl.h, which is
required by art::ReferenceMapVisitor::VisitDeclaringClass to
find the (inlined) implementation of
art::gc::accounting::HeapBitmap::Test.

This fixes the MIPS32 build.

Change-Id: I00a8bc85d8b32cfed02309e13e437f0cfd0d493e
d5f3f32bc0ca729cf4bbf7975525dc921ce94678 21-Mar-2016 Mathieu Chartier <mathieuc@google.com> Add sanity checking to declaring class visiting

When we have an unmarked declaring class in the image, it will
SIGSEGV due to the bitmap being read-only. Print some useful
info to try and debug this.

This probably hurts performance a bit, TODO disable when the bug is
fixed.

Bug: 27493510

(cherry picked from commit b33b1dc78d178060ff0f4327d448fd3a89df51de)

Change-Id: I0c25afd5a6101a71fa1494e12dc019ba64bf43be
b33b1dc78d178060ff0f4327d448fd3a89df51de 21-Mar-2016 Mathieu Chartier <mathieuc@google.com> Add sanity checking to declaring class visiting

When we have an unmarked declaring class in the image, it will
SIGSEGV due to the bitmap being read-only. Print some useful
info to try and debug this.

This probably hurts performance a bit, TODO disable when the bug is
fixed.

Bug: 27493510

Change-Id: Ida0c09cb8e41c1c2ff5cd9d07cbf0d34d6802511
48a7bae220c823f03f53a58043845c2e58860b22 21-Mar-2016 Roland Levillain <rpl@google.com> Pacify g++ about a set-but-unused variable.

This fixes the MIPS32 build.

Change-Id: Ic1e6d4627d69a3701c2f3e8fdd784d97a4e41ba5
8245eb4ddd340769192febf597e80de96603d79d 18-Mar-2016 Andreas Gampe <agampe@google.com> ART: Speed up stack guard page install

Only the main thread doesn't have its stack mapped in under normal
conditions. Reading each page is a lot of overhead and we should
try to avoid it.

Rewrite to first try a (non-fatal) protect. If the outcome is a
success, finish. Otherwise do the stack mapping, and try again.

Bug: 27718174

(cherry picked from commit 2c2d2a05eaf81d07df27418f8dfd68de6fa28ac1)

Change-Id: I16b214567585ed2f09970f618ccdec7eed219fd3
2c2d2a05eaf81d07df27418f8dfd68de6fa28ac1 18-Mar-2016 Andreas Gampe <agampe@google.com> ART: Speed up stack guard page install

Only the main thread doesn't have its stack mapped in under normal
conditions. Reading each page is a lot of overhead and we should
try to avoid it.

Rewrite to first try a (non-fatal) protect. If the outcome is a
success, finish. Otherwise do the stack mapping, and try again.

Bug: 27718174
Change-Id: I16b214567585ed2f09970f618ccdec7eed219fd3
32ce2adefb8a3d0eda59a29f5e87c1eb43eef796 04-Mar-2016 Mathieu Chartier <mathieuc@google.com> Add more systracing everywhere

Added to:
JIT
DexFile functions
Oat file manager

Added helper ScopedTrace to prevent errors and reduce excess code.

Bug: 27502458

(cherry picked from commit dabdc0fe183d4684f3cf4d70cb09d318cff81b42)

Change-Id: Ifaeff8913d79eefc797380987d13cc00456266f8
dabdc0fe183d4684f3cf4d70cb09d318cff81b42 04-Mar-2016 Mathieu Chartier <mathieuc@google.com> Add more systracing everywhere

Added to:
JIT
DexFile functions
Oat file manager

Added helper ScopedTrace to prevent errors and reduce excess code.

Bug: 27502458

Change-Id: Ifaeff8913d79eefc797380987d13cc00456266f8
a73280df8cac1279b6dea0424722f42ef0048613 15-Feb-2016 Nicolas Geoffray <ngeoffray@google.com> Add an option to disable native stack dumping on SIGQUIT.

Some of our (stress) run-tests do ANR dumping, which end up
stressing libunwind, that has known problems. To avoid getting
flakes due to libunwind, disable native stack dumping on SIGQUIT
for our run-tests.

bug:27185632
bug:24664297
Change-Id: I69085e48db903d6240448d71666ae2dcd091922e
7ed9c561048d79083b6d0576c71a986a3123bca6 03-Feb-2016 Hiroshi Yamauchi <yamauchi@google.com> Use 8-byte increment bracket sizes for rosalloc thread local runs.

Very small space savings (< 1%) after device boot and up to 10%
allocation speedup.

Some minor cleanup.

Bug: 9986565

Change-Id: I51d791c4674d6944fe9a7ee78537ac3490c1a02c
b331febbab8e916680faba722cc84b66b84218a3 05-Feb-2016 Nicolas Geoffray <ngeoffray@google.com> Revert "Revert "Implement on-stack replacement for arm/arm64/x86/x86_64.""

This reverts commit bd89a5c556324062b7d841843b039392e84cfaf4.

Change-Id: I08d190431520baa7fcec8fbdb444519f25ac8d44
bd89a5c556324062b7d841843b039392e84cfaf4 05-Feb-2016 David Brazdil <dbrazdil@google.com> Revert "Implement on-stack replacement for arm/arm64/x86/x86_64."

DCHECK whether loop headers are covered fails.

This reverts commit 891bc286963892ed96134ca1adb7822737af9710.

Change-Id: I0f9a90630b014b16d20ba1dfba31ce63e6648021
891bc286963892ed96134ca1adb7822737af9710 29-Jan-2016 Nicolas Geoffray <ngeoffray@google.com> Implement on-stack replacement for arm/arm64/x86/x86_64.

High-level overview:
- osr_method_threshold is used to know when to compile a method
in osr mode (-> treat all loops as irreducible).
- branch instructions in the compiler query whether they can
jump to an osr method.
- An osr entry point is found through the stack maps: if a stack
map is duplicated in the CodeInfo, it is an osr entry point.

Change-Id: Ifb39338cd281e2c7eccce67f4e18d46428be71e4
e7f75f35371cf32954d94f9bb10fc96924f7edb4 02-Feb-2016 Mathieu Chartier <mathieuc@google.com> Add read barrier option to UpdateEntrypoints

Also call this without read barrier for image relocation.

Bug: 26786304
Change-Id: Ia718c1491b54cadb7283c62afc1eb9031a15b4ef
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
7c1559a06041c9c299d5ab514d54b2102f204a84 15-Dec-2015 Roland Levillain <rpl@google.com> x86 Baker's read barrier fast path implementation.

Introduce an x86 fast path implementation in Optimizing for
Baker's read barriers (for both heap reference loads and GC
root loads). The marking phase of the read barrier is
performed by a slow path, invoking a new runtime entry point
(artReadBarrierMark).

Other read barrier algorithms continue to use the original
slow path based implementation, which has been renamed as
GenerateReadBarrierSlow/GenerateReadBarrierForRootSlow.

Bug: 12687968
Change-Id: Ie610c4befc19ff22378a8cba38b422dcacb54320
a4f1220c1518074db18ca1044e9201492975750b 06-Aug-2015 Mark Mendell <mark.p.mendell@intel.com> Optimizing: Add direct calls to math intrinsics

Support the double forms of:
cos, sin, acos, asin, atan, atan2, cbrt, cosh, exp, expm1,
hypot, log, log10, nextAfter, sinh, tan, tanh

Add these entries to the vector addressed off the thread pointer. Call
the libc routines directly, which means that we have to implement the
native ABI, not the ART one. For x86_64, that includes saving XMM12-15
as the native ABI considers them caller-save, while the ART ABI
considers them callee-save. We save them by marking them as used by the
call to the math function. For x86, this is not an issue, as all the XMM
registers are caller-save.

Other architectures will call Java as before until they are ready to
implement the new intrinsics.

Bump the OAT version since we are incompatible with old boot.oat files.

Change-Id: Ic6332c3555c09393a17d1ad4daf62932488722fb
Signed-off-by: Mark Mendell <mark.p.mendell@intel.com>
73be1e8f8609708f6624bb297c9628de44fd8b6f 17-Sep-2015 Nicolas Geoffray <ngeoffray@google.com> Inline monomorphic calls.

Change-Id: If38171c2dc7d4a4378df5d050afc4fff4499c98f
0d5a281c671444bfa75d63caf1427a8c0e6e1177 13-Nov-2015 Roland Levillain <rpl@google.com> x86/x86-64 read barrier support for concurrent GC in Optimizing.

This first implementation uses slow paths to instrument heap
reference loads and GC root loads for the concurrent copying
collector, respectively calling the artReadBarrierSlow and
artReadBarrierForRootSlow (new) runtime entry points.

Notes:
- This implementation does not instrument HInvokeVirtual
nor HInvokeInterface instructions (for class reference
loads), as the corresponding read barriers are not stricly
required with the current concurrent copying collector.
- Intrinsics which may eventually call (on slow path) are
disabled when read barriers are enabled, as the current
slow path infrastructure does not support this case.
- When read barriers are enabled, the code generated for a
HArraySet instruction always go into the array set slow
path for object arrays (delegating the operation to the
runtime), as we are lacking a mechanism to keep a
temporary register live accross a runtime call (needed for
the instrumentation of type checking code, which requires
two successive read barriers).

Bug: 12687968
Change-Id: I14cd6107233c326389120336f93955b28ffbb329
04302dbb106d590ff72c0dfecda23d85b6565059 12-Nov-2015 Hiroshi Yamauchi <yamauchi@google.com> Fix class unloading with the CC collector.

Avoid unnecessarily decoding dex cache and class loader weak roots,
which would trigger read barriers.

Re-enable 141-class-unload with the CC collector.

Bug: 12687968
Bug: 24468364
Change-Id: Ib4c19f25000873cab0e06047040442d135285745
6cff48f05894a60aa4742472983a75504536ca15 27-Jan-2014 Christopher Ferris <cferris@google.com> ART: Speed up thread stack tracing for ANRs

Share a BacktraceMap for all threads being dumped, which speeds up
ANR dumping. Results from Nexus 9 (average of five):

Before: 0.587s
After: 0.206s

Change-Id: Ia70e0dbd39049318c02de561e7b95258d4849467
524e7ea8cd17bad17bd9f3e0ccbb19ad0d4d9c02 16-Oct-2015 Nicolas Geoffray <ngeoffray@google.com> Remove ArtCode.

- Instead use OatQuickMethodHeader.
- Various cleanups now that we don't have all those
ArtMethod -> ArtCode -> OatQuickMethodHeader indirections.

As a consequence of this cleanup, exception handling got a bit
faster.

ParserCombinators benchmark (exception intensive) on x64: (lower is better)
Before:
ParserCombinators(RunTime): 1062500.0 us.
After:
ParserCombinators(RunTime): 833000.0 us.

Change-Id: Idac917b6f1b0dc254ad68fb3781cd61bccadb0f3
6bc4374e3fa00e3ee5e832e1761c43e0b8a71558 12-Oct-2015 Nicolas Geoffray <ngeoffray@google.com> Add an abstraction over a compiled code.

That's just step 1, moving code-related functions of ArtMethod to
another class. That class is only a wrapper on an ArtMethod, but will
be changed to be a wrapper around compiled code.

Change-Id: I6f35fc06d37220558dff61691e51ae20066b0dd6
03ec930faded5bbfa096533ce60b6893847922db 28-Aug-2015 Andreas Gampe <agampe@google.com> ART: Lock counting in the interpreter

To support structured locking when balanced-locking verification
failed, count lock and unlock operations in the verifier.

Bug: 23502994
Change-Id: I2bb915da6e3d43c49723a943b42d4d5a7c939aa1
4b1d4ec525448302556e4c2b601b4dbb8e5e294e 02-Oct-2015 Andreas Gampe <agampe@google.com> ART: Do not abort on exception in CreatePeer

Different parts of CreatePeer may throw an exception, especially
the Thread constructor. Do not abort in such a case, but return
and report a failure to attach/create a thread.

Bug: 24200698

(cherry picked from commit 2a196784553f4fd0c0f7d4b8aac87281db3a4748)

Change-Id: I06f2c997f0451c71f791d1f12bea6f8ee65e8ab2
3cfa4d05afa76e19ca99ec964b535a15c73683f0 07-Oct-2015 Andreas Gampe <agampe@google.com> ART: Remove interpreter entrypoints

These are no longer used as entrypoints. Make them proper runtime
functions local to the interpreter.

Bump oat version.

Change-Id: Icdd92e20eafc5668b68eeebf55cf624560f462b3
2a196784553f4fd0c0f7d4b8aac87281db3a4748 02-Oct-2015 Andreas Gampe <agampe@google.com> ART: Do not abort on exception in CreatePeer

Different parts of CreatePeer may throw an exception, especially
the Thread constructor. Do not abort in such a case, but return
and report a failure to attach/create a thread.

Bug: 24200698
Change-Id: I06f2c997f0451c71f791d1f12bea6f8ee65e8ab2
910e8275440dd3b70f2e8f6c473ba1707c00261d 30-Sep-2015 Mathieu Chartier <mathieuc@google.com> Revert "Revert "Keep internal stack trace methods declaring classes live""

Fixed some code which used old stack trace representation in throwable.cc.

Bug: 22720414

This reverts commit 45a8522898702f6a725ae19d97bceedc8fc609a6.

Change-Id: I7385075caf649ce76da5d8866fd0031b9e8e5ef4
45a8522898702f6a725ae19d97bceedc8fc609a6 30-Sep-2015 Nicolas Geoffray <ngeoffray@google.com> Revert "Keep internal stack trace methods declaring classes live"

Breaks jdwp tests.

Bug: 22720414

This reverts commit 566fc926942ed57925627d1bd43e099938084f1e.

Change-Id: Ic3544e86af35bf748f9d47e0a4077dcdc206a821
566fc926942ed57925627d1bd43e099938084f1e 29-Sep-2015 Mathieu Chartier <mathieuc@google.com> Keep internal stack trace methods declaring classes live

We now store the declaring classes in the internal stack trace to
make sure class unloading doesn't unload any classes owning methods
in the stack trace.

This fixes DexClassLoaderTest in libcore. Added regression test.

Bug: 22720414

Change-Id: I185f87c8ec0807e83f4661bd5bb5652dba6fc281
639bdd13993644a267f177f8f5936496bda65e2b 03-Jun-2015 Andreas Gampe <agampe@google.com> ART: Single-frame deopt

Add deoptimization of a single frame. Works by removing the managed
code frame and jumping into the quick-to-interpreter bridge, and
the bridge understanding a stored ShadowFrame.

We need a separate fixup pass. For x86, we leave the return address
on the stack so we don't need to push it there.

Bug: 21611912
Change-Id: I06625685ced8b054244f8685ab50b238a705b9d2
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
26f728661a08062a373a3203b72dc2555c2aed2d 15-Sep-2015 Sebastien Hertz <shertz@google.com> Cleanup thread access in StackVisitor

Adds method StackVisitor::GetThread to give access to the visited
Thread* so we no longer need to copy that pointer in subclasses.

Also adds a few missing const and DISALLOW_COPY_AND_ASSIGN.

Change-Id: I57649ee7742ef4ef1e01447ac2fbb66f977b22eb
520633bebd2bf4d70884d30f179dbde9f275aac6 08-Sep-2015 Sebastien Hertz <shertz@google.com> Support deoptimization on exception

Allows to deoptimize when an exception is being thrown. We only
deoptimize if an executable frame (starting from the catch handler)
needs to be executed with the interpreter.

Before executing deoptimized frames, the exception is restored. The
interpreter starts by handling this exception at the point of the
throwing instruction.

Bug: 23714835
Change-Id: I0c5f7d4b257644acf12210aae8e5b6bb0f4af1f7
f1d666e1b48f8070ef1177fce156c08827f08eb8 04-Sep-2015 Mathieu Chartier <mathieuc@google.com> Add ScopedThreadSuspension

Fixes the TransitionFromRunnableToSuspended and
TransitionFromSuspendedToRunnable pattern that was prone to errors.

Change-Id: Ie6ae9c0357c83b4fc4899d05dfa0975553170267
30b5e27083913bb711fca0ca89a941797fcf3d5d 01-Sep-2015 Mathieu Chartier <mathieuc@google.com> Enable lockless decoding of weak globals

Will help speed up decoding weak DexCache roots.

Change-Id: I9a68beb4106cbd383111a30e249c9b0149064e78
0747466fca310eedea5fc49e37d54f240a0b3c0f 25-Aug-2015 Sebastien Hertz <shertz@google.com> Revert "Revert "Fix deoptimization with pending exception""

This reverts commit 6e2d5747d00697a25251d25dd33b953e54709507.

Fixes the deoptimization path from compiled code (generated by the
Optimizing compiler) by adding wrapper artDeoptimizeFromCompiledCode.
This wrapper, called through the matching assembler stub
art_quick_deoptimize_from_compiled_code, pushes the deoptimization
context just before deoptimizing the stack.

Bug: 23371176
Bug: 19944235
Change-Id: Ia7082656998aebdd0157438f7e6504c120e10d3e
6e2d5747d00697a25251d25dd33b953e54709507 25-Aug-2015 Sebastien Hertz <shertz@google.com> Revert "Fix deoptimization with pending exception"

This reverts commit 54b62480636ae846d705fc180c7bd6cd08ec1e42.

This is causing test failures with Optimizing compiler.

Bug: 23371176
Bug: 19944235
Change-Id: Ie3ffbcf2b6d2ca8bc93cb008a4e29a7567d04a7c
54b62480636ae846d705fc180c7bd6cd08ec1e42 20-Aug-2015 Sebastien Hertz <shertz@google.com> Fix deoptimization with pending exception

When deoptimizing the stack, we set a fake exception in the current
Thread* (see method Thread::GetDeoptimizationException). On the next
exception check, the QuickExceptionHandler will deoptimize the stack.

The issue is when we deoptimize while an exception is already pending
in the current Thread*: setting the fake exception will clobber the
pending exception which is not correct. This happens in the
artQuickToInterpreterBridge when returning from the interpreter and
we want to deoptimize the stack for debugging (like single-stepping).

This CL saves the pending exception before asking for deoptimization.
Then the exception is restored just before executing the deoptimized
frames with the interpreter.

Also cleans up the way we save deoptimization context (return value
and pending exception).

Bug: 23371176
Bug: 19944235
Change-Id: I7f4c8347b328817c452beda3399e210eba3a88a4
10e5ea90e20375e5ad2ff26cb760c0e7c586cc16 13-Aug-2015 Mathieu Chartier <mathieuc@google.com> Visit declaring class of methods on call stack

Bug: 22720414
Change-Id: Iab9727dde243d76fd9dfdb1db73899fedd1ab6ea
3887c468d731420e929e6ad3acf190d5431e94fc 12-Aug-2015 Roland Levillain <rpl@google.com> Remove unnecessary `explicit` qualifiers on constructors.

Change-Id: Id12e392ad50f66a6e2251a68662b7959315dc567
4382f1ef6ab2d6992d330cc8b43057d9139a1243 05-Aug-2015 Andreas Gampe <agampe@google.com> Revert "Revert "ART: Use bionic TLS slot for thread-self""

This reverts commit 50832b6804d15ea5ddfe99a2753a09111b5bfe37.

Fix clearing the TLS on detach.

Change-Id: I75ed5ccccb4f31800e5f893055e96067a9695258
90ef3db4bd1d4865f5f9cb95c8e7d9afb46994f9 05-Aug-2015 Mathieu Chartier <mathieuc@google.com> Address some comments and clean up

Change-Id: I538cf204f1c89d5fc81f8fc5e5800fcf1cf87359
50832b6804d15ea5ddfe99a2753a09111b5bfe37 05-Aug-2015 Andreas Gampe <agampe@google.com> Revert "ART: Use bionic TLS slot for thread-self"

This reverts commit b81535875ff46d1630c76091fe969a9eb7fc4d16.

Breaking tests, need to investigate.

Change-Id: Iab8c4f6136e6cb9bd6cf3c3495aa33962ef890ee
c60e1b755c5632dfeb04c333489ede52ee5c945f 30-Jul-2015 Andreas Gampe <agampe@google.com> ART: Use __ANDROID__ instead of HAVE_ANDROID_OS

Use the proper define.

Change-Id: I71e291ac25f5d5f0187ac9b6ef2d6872f19e6085
b81535875ff46d1630c76091fe969a9eb7fc4d16 29-Jul-2015 Andreas Gampe <agampe@google.com> ART: Use bionic TLS slot for thread-self

Use a private bionic TLS slot to store self instead of using
pthreads.

Change-Id: Icc86a2b7590734637366f9d5e41a5c6d18cc5772
1aee900d5a0b3a8d78725a7551356bda0d8554e1 15-Jul-2015 Man Cao <manc@google.com> Add read barrier support to the entrypoints.

Also remove "THIS_LOAD_REQUIRES_READ_BARRIER" since reading
an ArtMethod* no longer needs read barrier.

stub_test should also work with read barriers now.

Change-Id: I3fba18042de2f867a18dbdc38519986212bd9769
4e2cb098017bf073335ebb02b1bc0a36828cd720 23-Jul-2015 Mathieu Chartier <mathieuc@google.com> Add uninterruptible role

Example error:
cannot call function 'CopyOf' while mutex 'uninterruptible_' is held

TODO: Add annotation to more locations.

Bug: 20072211

Change-Id: I1bbf5a77e3deeafa5898df529cb7cb53a6d010d2
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
3387f39750942b0442eec351757c7d1f9b1405ca 18-Jul-2015 Mathieu Chartier <mathieuc@google.com> Get non proxy method for StackDumpVisitor

Fixes failing DCHECK.

(cherry picked from commit ef76c3fa57ddf3f7ca32e118f599da8cb4eb1560)

Bug: 22553459
Change-Id: I6fe1012f9a5f8d29cb98bf25e3a279da51c5e1c0
ef76c3fa57ddf3f7ca32e118f599da8cb4eb1560 18-Jul-2015 Mathieu Chartier <mathieuc@google.com> Get non proxy method for StackDumpVisitor

Fixes failing DCHECK.

Bug: 22553459
Change-Id: I6fe1012f9a5f8d29cb98bf25e3a279da51c5e1c0
14c3bf91b2ec434295ec84d6446f495fb7de6d5c 13-Jul-2015 Mathieu Chartier <mathieuc@google.com> Change intern table to not use WaitHoldingLocks

Bug: 22423014
Change-Id: I9e16b8cb4def72fff73f1783a182877105feb7aa
4abf45148c643f2f2ac0e177bd3d394abd9d1945 13-Jul-2015 Evgenii Stepanov <eugenis@google.com> Disable ASan on Thread::InstallImplicitProtection.

This function reads random stack locations and confuses ASan.

Bug: 21785137
Change-Id: Iaaee6032a651618e5275ab46e6e8f886df60a5d0
1e13374baf7dfaf442ffbf9809c37c131d681eaf 20-May-2015 Evgenii Stepanov <eugenis@google.com> Generalize Valgrind annotations in ART to support ASan.

Also add redzones around non-fixed mem_map(s).
Also extend -Wframe-larger-than limit to enable arm64 ASan build.

Change-Id: Ie572481a25fead59fc8978d2c317a33ac418516c
eac4424b3420c280f97ff2f815b5dedd8dac9801 29-Jun-2015 Yu Li <yu.l.li@intel.com> ART: JNI thread state transition optimization

This patch improves the JNI performance by removing the explicit acquiring and
releasing the mutator lock when a thread state transits between suspended and
runnable states.

The functions responsible for changing the state were found to be the costliest
part of the JNI. Originally, a thread needs to acquire a shared mutator lock by
a CAS instruction when entering the runnable state and also needs to release
the lock by a CAS when entering the native state from runnable. This patch
removes these CAS operations when a thread state transits between suspended and
runnable. A thread in the runnable state is considered to have shared ownership
of the mutator lock and therefore transitions in and out of the runnable state
have associated implication on the mutator lock ownership. Meanwhile, a barrier
is added to control suspending all threads from running.

JNI transition overhead was reduced by 25% on IA platform and by 17% on ARM
platform by this patch, while it has little impact on GC pause time (measured
with "suspend all histogram").

Change-Id: Icee95d8ffff1bbfc95309a41cc48836536fec689
Signed-off-by: Yu, Li <yu.l.li@intel.com>
Signed-off-by: Haitao, Feng <haitao.feng@intel.com>
Signed-off-by: Lei, Li <lei.l.li@intel.com>
0b71357fb52be9bb06d35396a3042b4381b01041 17-Jun-2015 Hiroshi Yamauchi <yamauchi@google.com> Thread-local mark stacks for the CC collector.

Thread-local mark stacks are assigned to mutators where they push
references in read barriers to reduce the (CAS) synchronization cost
in a global mark stack/queue.

We step through three mark stack modes (thread-local, shared,
GC-exclusive) and use per-thread flags to disable/enable system weak
accesses (only for the CC collector) instead of the existing global
one to safely perform the marking phase. The reasons are 1)
thread-local mark stacks for mutators need to be revoked using a
checkpoint to avoid races (incorrectly leaving a reference on mark
stacks) when terminating marking, and 2) we can’t use a checkpoint
while system weak accesses are disabled (or a deadlock would
happen). More details are described in the code comments.

Performance improvements in Ritzperf EAAC: a ~2.8% improvement
(13290->12918) in run time and a ~23% improvement (51.6s->39.8s) in
the total GC time on N5.

Bug: 12687968
Change-Id: I5d234d7e48bf115cd773d38bdb62ad24ce9116c7
5662383511a550e428bcdee0cc1be28e464ceed4 10-Jul-2015 Andreas Gampe <agampe@google.com> ART: Add Thread start VLOG

Add a stack trace at the time of thread creation or attaching to
the verbose:threads logging.

Change-Id: I5e07c81ce24f145c37ab172eda7bb4c54dad4445
bf1fa2ccb5e7409910b99dc46b616e44c66ade68 09-Jun-2015 Sebastien Hertz <shertz@google.com> Follow up on CL 151605

- Fixes return type of StackedShadowFrameRecord::GetType
- Makes StackedShadowFrameType an enum class (scoped enum)
- Moves DeoptimizationReturnValueRecord and StackedShadowFrameRecord
to thread.cc file and use forward declaration in thread.h header
- Fixes tools/generate-operator-out.py for scoped enum classes.

Bug: 20845490

(cherry picked from commit f795869da0a1fa006fdcdacd8afb6149a63fc1a7)

Change-Id: I6b67e288b1db563699161e58ec2e2330d42dd8f5
ef484d442a3dcae2cd1842c5be0623f5cf71e4ab 18-May-2015 Mingyao Yang <mingyao@google.com> Fix nested deoptimization.

Handle nested deoptimization cases. Create a stacked shadow frame
records to keep track of deoptimization shadow frames. Shadow frames
under construction can be tracked in the same stack.

Bug: 20845490

(cherry picked from commit 1f2d3ba6af52cf6f566deb38b7e07735c9a08fb6)

Change-Id: I768285792c29e7c3cfcd21e7a2600802506024d8
33d6903e570daf8f3cf7c1f6ebd9a6dd22c7c23c 18-Jun-2015 Roland Levillain <rpl@google.com> Replace some run-time assertions with compile-time ones in ART.

Change-Id: I16c3fad45c4b98b94b7c83d071374096e81d407a
41f9cc28f2c9edd3903ba6ca1c75b022445552ad 16-Jun-2015 Pavel Vyssotski <pavel.n.vyssotski@intel.com> ART: Compiler generated GC map should take care of temp registers.

If the compiler use a temp register as a reference it should be
added to generated GC map along with other SSA regs.

Change-Id: I3c79896dcd72228c9cf2bbbe737642d9ffb7684d
Signed-off-by: Pavel Vyssotski <pavel.n.vyssotski@intel.com>
6ba35b50347aa7418c66c7b046cd164987e95df3 01-Jun-2015 Sebastien Hertz <shertz@google.com> JDWP: asynchronous invoke command handling

The JDWP thread used to wait for the result of a method invocation
running in an event thread. But doing that prevents the JDWP thread
from processing incoming commands from the debugger if the event
thread gets suspended by a debug event occurring in another thread.
In Android Studio (or another IDE), this leads to the debugger being
blocked (with the famous message "Waiting until last debugger command
completes" of Android Studio / IntelliJ) because it is actually
waiting for the reply of its latest command while the JDWP thread
cannot process it.

This CL changes the way invoke commands (ClassType.InvokeCommand,
ClassType.NewInstance and ObjectReference.InvokeCommand) are handled
in the ART runtime.
The JDWP thread no longer waits for the event thread to complete the
method invocation. It now simply waits for the next JDWP command to
process. This means it does not send any reply for invoke commands,
except if the information given by the debugger is wrong. In this
case, it still sends a reply with the appropriate error code.
The event thread is now responsible for sending the reply (containing
the result and the exception object of the invoked method) before
going back to the suspended state.

In other words, we add special handling for invoke commands so they
are handled asynchronously while other commands remained handled
synchronously. In the future, we may want to handle all commands
asynchronously (using a queue of reply/event for instance) to remove
the special handling code this CL is adding.

Now the JDWP thread can process commands while a thread is invoking
a method, it is possible for the debugger to detach (by sending a
VirtualMachine.Dispose command) before the invocation completes. In
that situation, we must not suspend threads again (including the
event thread that executed the method) because they would all remain
suspended forever.

Also minor cleanup of the use of JDWP constants and update comments.

Bug: 21515842
Bug: 18899981

(cherry picked from commit cbc5064ff05179b97b416f00ca579c55e38cd7d9)

Change-Id: I8d31006043468913ee8453212e6d16e11fcfe4ea
cbc5064ff05179b97b416f00ca579c55e38cd7d9 01-Jun-2015 Sebastien Hertz <shertz@google.com> JDWP: asynchronous invoke command handling

The JDWP thread used to wait for the result of a method invocation
running in an event thread. But doing that prevents the JDWP thread
from processing incoming commands from the debugger if the event
thread gets suspended by a debug event occurring in another thread.
In Android Studio (or another IDE), this leads to the debugger being
blocked (with the famous message "Waiting until last debugger command
completes" of Android Studio / IntelliJ) because it is actually
waiting for the reply of its latest command while the JDWP thread
cannot process it.

This CL changes the way invoke commands (ClassType.InvokeCommand,
ClassType.NewInstance and ObjectReference.InvokeCommand) are handled
in the ART runtime.
The JDWP thread no longer waits for the event thread to complete the
method invocation. It now simply waits for the next JDWP command to
process. This means it does not send any reply for invoke commands,
except if the information given by the debugger is wrong. In this
case, it still sends a reply with the appropriate error code.
The event thread is now responsible for sending the reply (containing
the result and the exception object of the invoked method) before
going back to the suspended state.

In other words, we add special handling for invoke commands so they
are handled asynchronously while other commands remained handled
synchronously. In the future, we may want to handle all commands
asynchronously (using a queue of reply/event for instance) to remove
the special handling code this CL is adding.

Now the JDWP thread can process commands while a thread is invoking
a method, it is possible for the debugger to detach (by sending a
VirtualMachine.Dispose command) before the invocation completes. In
that situation, we must not suspend threads again (including the
event thread that executed the method) because they would all remain
suspended forever.

Also minor cleanup of the use of JDWP constants and update comments.

Bug: 21515842
Bug: 18899981
Change-Id: I15e00fb068340f3d69dc9225d8d2065246e68c58
f795869da0a1fa006fdcdacd8afb6149a63fc1a7 09-Jun-2015 Sebastien Hertz <shertz@google.com> Follow up on CL 151605

- Fixes return type of StackedShadowFrameRecord::GetType
- Makes StackedShadowFrameType an enum class (scoped enum)
- Moves DeoptimizationReturnValueRecord and StackedShadowFrameRecord
to thread.cc file and use forward declaration in thread.h header
- Fixes tools/generate-operator-out.py for scoped enum classes.

Bug: 20845490
Change-Id: I6b67e288b1db563699161e58ec2e2330d42dd8f5
1f2d3ba6af52cf6f566deb38b7e07735c9a08fb6 18-May-2015 Mingyao Yang <mingyao@google.com> Fix nested deoptimization.

Handle nested deoptimization cases. Create a stacked shadow frame
records to keep track of deoptimization shadow frames. Shadow frames
under construction can be tracked in the same stack.

Bug: 20845490
Change-Id: I768285792c29e7c3cfcd21e7a2600802506024d8
f677ebfd832c9c614fea5e6735725fec2f7a3f2a 29-May-2015 David Brazdil <dbrazdil@google.com> Cache stack map encoding

Operations on CodeInfo and StackMap objects repeatedly read encoding
information from the MemoryRegion. Since these are 3-bit-loads of
values that never change, caching them can measurably reduce compile
times.

According to benchmarks, this patch saves 1-3% on armv7, 2-4% on x86,
and 0-1% on x64.

Change-Id: I46b197513601325d8bab562cc80100c00ec28a3b
449357d3f61bdd134967ecdacc3516e1707cf882 02-Jun-2015 Andreas Gampe <agampe@google.com> ART: Refactor Thread::Init

This refactor allows the parent thread to allocate the JNIEnvExt
for the child (with a fallback in place in Init). This allows to
throw an OOME in CreateNativeThread instead of aborting in the
child.

Bug: 21291279

(cherry picked from commit 520abbd0edcf333f07164539620ce65258c72383)

Change-Id: Iccc1a5c202999f5bfacec706d9833e53135ba2fa
520abbd0edcf333f07164539620ce65258c72383 02-Jun-2015 Andreas Gampe <agampe@google.com> ART: Refactor Thread::Init

This refactor allows the parent thread to allocate the JNIEnvExt
for the child (with a fallback in place in Init). This allows to
throw an OOME in CreateNativeThread instead of aborting in the
child.

Bug: 21291279
Change-Id: Iccc1a5c202999f5bfacec706d9833e53135ba2fa
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
415fd0833fe44b99ed57353f4bd7572681506daa 01-Jun-2015 Sebastien Hertz <shertz@google.com> 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
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
41b175aba41c9365a1c53b8a1afbd17129c87c14 19-May-2015 Vladimir Marko <vmarko@google.com> ART: Clean up arm64 kNumberOfXRegisters usage.

Avoid undefined behavior for arm64 stemming from 1u << 32 in
loops with upper bound kNumberOfXRegisters.

Create iterators for enumerating bits in an integer either
from high to low or from low to high and use them for
<arch>Context::FillCalleeSaves() on all architectures.

Refactor runtime/utils.{h,cc} by moving all bit-fiddling
functions to runtime/base/bit_utils.{h,cc} (together with
the new bit iterators) and all time-related functions to
runtime/base/time_utils.{h,cc}. Improve test coverage and
fix some corner cases for the bit-fiddling functions.

Bug: 13925192

(cherry picked from commit 80afd02024d20e60b197d3adfbb43cc303cf29e0)

Change-Id: I905257a21de90b5860ebe1e39563758f721eab82
80afd02024d20e60b197d3adfbb43cc303cf29e0 19-May-2015 Vladimir Marko <vmarko@google.com> ART: Clean up arm64 kNumberOfXRegisters usage.

Avoid undefined behavior for arm64 stemming from 1u << 32 in
loops with upper bound kNumberOfXRegisters.

Create iterators for enumerating bits in an integer either
from high to low or from low to high and use them for
<arch>Context::FillCalleeSaves() on all architectures.

Refactor runtime/utils.{h,cc} by moving all bit-fiddling
functions to runtime/base/bit_utils.{h,cc} (together with
the new bit iterators) and all time-related functions to
runtime/base/time_utils.{h,cc}. Improve test coverage and
fix some corner cases for the bit-fiddling functions.

Bug: 13925192
Change-Id: I704884dab15b41ecf7a1c47d397ab1c3fc7ee0f7
e12997fbce8e22431be58cac9db2535f7b4a7ac3 22-May-2015 Nicolas Geoffray <ngeoffray@google.com> Return an invalid StackMap when one cannot be found.

This avoids aborting when handling a crash.

Change-Id: Ie5b5d48061fa9258b349b0284f7b00c5855d9fbd
39b6c24ce68cf05db0f82f454b4401cfb03d675f 20-May-2015 Jeff Hao <jeffhao@google.com> Intercept JNI invocation of String.<init> methods.

libmono uses JNI AllocObject and CallNonvirtualVoidMethod to create and
initialize a string instead of using the recommended NewObject. This
change adds an intercept to change the String.<init> call to a
StringFactory call instead. Then, it uses the object id of the original
string object referrer and maps it to the result of the StringFactory.

Bug: 21288130

(cherry picked from commit 15e9ad1d028d7f12cb598b075453173532a00d91)

Change-Id: I3421c43722c07397da4a398c2ca9110e1d40bcfa
15e9ad1d028d7f12cb598b075453173532a00d91 20-May-2015 Jeff Hao <jeffhao@google.com> Intercept JNI invocation of String.<init> methods.

libmono uses JNI AllocObject and CallNonvirtualVoidMethod to create and
initialize a string instead of using the recommended NewObject. This
change adds an intercept to change the String.<init> call to a
StringFactory call instead. Then, it uses the object id of the original
string object referrer and maps it to the result of the StringFactory.

Bug: 21288130
Change-Id: Ib4db402c178bc37188d5c5faf30b6e4fdc747b17
8e5bd18fc665d7ec5461ea068e98740a65da754c 06-May-2015 Nicolas Geoffray <ngeoffray@google.com> Add a flag to StackVisitor for inlining.

The flag tells whether the stack walk needs to include inlined
Java frames.

This does not do anything just yet, as we're not inlining anyways.

Change-Id: I716e25094fe56fa335ca1f9a398c1bcdba478e73
50030ef998be09789da4a9a56738362852068f12 08-May-2015 Mathieu Chartier <mathieuc@google.com> Check IsReferenceVReg during deopt

Required since the quick GC maps may not agree with the verifier
ones. Without this check we may copy stale object references into
the shadow frame.

(cherry picked from commit f00baf56ef647684888a407dbb6adadd704a2039)

Bug: 20736048
Change-Id: I7783c8a8ee45cf601b08b4c38f1dec7f7d11380c
f00baf56ef647684888a407dbb6adadd704a2039 08-May-2015 Mathieu Chartier <mathieuc@google.com> Check IsReferenceVReg during deopt

Required since the quick GC maps may not agree with the verifier
ones. Without this check we may copy stale object references into
the shadow frame.

Bug: 20736048
Change-Id: I7783c8a8ee45cf601b08b4c38f1dec7f7d11380c
1cc71ebf333ca323ae0e130fefbce4593e385c10 07-May-2015 Hiroshi Yamauchi <yamauchi@google.com> Insert a read barrier in the JNI bridge.

Bug: 20720510
Bug: 12687968
Change-Id: Ia9edb614853bad45ec25d6e2142361a8bda1eccf
3c683c5d107cb43e8027d740ed579ef92a88af2e 04-May-2015 Mathieu Chartier <mathieuc@google.com> Revert "HACK: Disable native stack trace dumping for tetra. DO NOT MERGE"

This reverts commit 471b7cb6c1b8128bb343b49198f2654f9f5b8f86.

Change-Id: Ia22615b401fd28ea94e6269f9eac5653e103a6fd
471b7cb6c1b8128bb343b49198f2654f9f5b8f86 29-Apr-2015 Mathieu Chartier <mathieuc@google.com> HACK: Disable native stack trace dumping for tetra. DO NOT MERGE

Hopefully stops deadlocks.

Bug: 20640601
Change-Id: I3e19217b6da002d328ffa7d941e14bfe734442c3
848f70a3d73833fc1bf3032a9ff6812e429661d9 15-Jan-2014 Jeff Hao <jeffhao@google.com> Replace String CharArray with internal uint16_t array.

Summary of high level changes:
- Adds compiler inliner support to identify string init methods
- Adds compiler support (quick & optimizing) with new invoke code path
that calls method off the thread pointer
- Adds thread entrypoints for all string init methods
- Adds map to verifier to log when receiver of string init has been
copied to other registers. used by compiler and interpreter

Change-Id: I797b992a8feb566f9ad73060011ab6f51eb7ce01
b28412e3fcc97fbcd0a11d25703a4ad64c3d9552 25-Apr-2015 Mathieu Chartier <mathieuc@google.com> Guard against name == null in ShortDump

Bug: 20561804
Change-Id: If1e4adb74d5b936cf171f2402bf4525bf8c2d209
a61894d88fabe45677f491c9f6bde30059a49026 24-Apr-2015 Mathieu Chartier <mathieuc@google.com> Fix reflection handling and test flakiness

Fixed reflection invoke to handle exceptions which occur from
FindClass or NewObject by throwing these instead of
the expected InvocationTargetException.

Added test case to 080 for this reflection invoke.

Fixed println throwing OOM in 104-growth-limit.

Change-Id: I65766e7c3478e299da06fdc3a521fe3f3e8fdba9
2cebb24bfc3247d3e9be138a3350106737455918 22-Apr-2015 Mathieu Chartier <mathieuc@google.com> Replace NULL with nullptr

Also fixed some lines that were too long, and a few other minor
details.

Change-Id: I6efba5fb6e03eb5d0a300fddb2a75bf8e2f175cb
9086b65b2ad35dd39a8afc62d535be8217208d08 14-Apr-2015 Mathieu Chartier <mathieuc@google.com> Fix valgrind tests

Delete large objects in space destructor. Also some cleanup.

Change-Id: I4c4e90149841a156b7a3236201b37683e14890fb
1561e1b4029cc25a653e17b36663ae047345fad0 14-Apr-2015 Christopher Ferris <cferris@google.com> Revert "ART: Turn of native stack dump on x86 on-device"

This reverts commit 2f0751ea75e5f093d9ce7b8587e65a2ca3de0855.

Bug: 20040863

Change-Id: Ibd40916c0f84512b0ba13af09d4fd345be39e227
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
d0ad2eea51850ed5972c23d03380b2305cdf7cb7 31-Mar-2015 Mathieu Chartier <mathieuc@google.com> Add support for nested method verifiers

Can occur in the following scenario:
MethodVerifier::Verify -> MethodVerifier::GetStaticField ->
ResolveFieldJLS -> ThrowNoSuchFieldError -> EnsureInitialized ->
VerifyClass

Also fixed another case where we can be requested to dump for ANR
while we are suspended in one of the AllowSuspension points.

Bug: 20140397

Change-Id: Ib17f6b98954caa5d1ea1c1dcde66091cc6d11c25
3f5881fda3606b27e30bf903052c73b03910f90b 08-Apr-2015 Andreas Gampe <agampe@google.com> ART: IRT refactor

IRT creation might fail. Add a path that allows to bypass the aborts
and instead signal validity. Hide this path with a private constructor,
rewrite users to use a static Create method.

Bug: 20110201

Change-Id: I440499c3372cd7557eb970b70ce2c4543da520e4
4809d0a8a5fca85a67dd0588ead5dfbd0f1acf96 07-Apr-2015 Mathieu Chartier <mathieuc@google.com> Fix CC root visiting bug

Also some cleanup.

Change-Id: Ia3de8f2d409770be3619ec116e8b06ecd82338fe
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
2f0751ea75e5f093d9ce7b8587e65a2ca3de0855 03-Apr-2015 Andreas Gampe <agampe@google.com> ART: Turn of native stack dump on x86 on-device

Temporary workaround for bug.

Bug: 20040863
Change-Id: Ifdde68c66b94ebc2f13c7983f38700c8bcf41559
d43b3ac88cd46b8815890188c9c2b9a3f1564648 01-Apr-2015 Mingyao Yang <mingyao@google.com> Revert "Revert "Deoptimization-based bce.""

This reverts commit 0ba627337274ccfb8c9cb9bf23fffb1e1b9d1430.

Change-Id: I1ca10d15bbb49897a0cf541ab160431ec180a006
0ba627337274ccfb8c9cb9bf23fffb1e1b9d1430 24-Mar-2015 Andreas Gampe <agampe@google.com> Revert "Deoptimization-based bce."

This breaks compiling the core image:

Error after BCE: art::SSAChecker: Instruction 219 in block 1 does not dominate use 221 in block 1.

This reverts commit e295e6ec5beaea31be5d7d3c996cd8cfa2053129.

Change-Id: Ieeb48797d451836ed506ccb940872f1443942e4e
e295e6ec5beaea31be5d7d3c996cd8cfa2053129 07-Mar-2015 Mingyao Yang <mingyao@google.com> Deoptimization-based bce.

A mechanism is introduced that a runtime method can be called
from code compiled with optimizing compiler to deoptimize into
interpreter. This can be used to establish invariants in the managed code
If the invariant does not hold at runtime, we will deoptimize and continue
execution in the interpreter. This allows to optimize the managed code as
if the invariant was proven during compile time. However, the exception
will be thrown according to the semantics demanded by the spec.

The invariant and optimization included in this patch are based on the
length of an array. Given a set of array accesses with constant indices
{c1, ..., cn}, we can optimize away all bounds checks iff all 0 <= min(ci) and
max(ci) < array-length. The first can be proven statically. The second can be
established with a deoptimization-based invariant. This replaces n bounds
checks with one invariant check (plus slow-path code).

Change-Id: I8c6e34b56c85d25b91074832d13dba1db0a81569
004c230b4cfc856690c61faabc41864061813c88 20-Mar-2015 Nicolas Geoffray <ngeoffray@google.com> Compress the StackMaps.

First step towards the compression of the StackMap (not
the DexRegisterMap). Next step will be to just use what is
needed (instead of byte -> word).

Change-Id: I4f81b2d05bf5cc508585e16fbbed1bafbc850e2e
12d625f87bcd6c4059a205bb39007a255f57f382 13-Mar-2015 Mathieu Chartier <mathieuc@google.com> Change method verifiers to be thread local roots

Bug: 10921004

Change-Id: I3a1425d76cd380587ba67ef6d5ec1227564e55bf
15b9d5274399736ac09705f0507df24fac4f00c1 12-Mar-2015 Nicolas Geoffray <ngeoffray@google.com> API change in StackVisitor::GetVReg*.

- Remove GetVReg() and SetVReg() that were expecting to always succeed.
- Change Quick-only methods to take a FromQuickCode suffix.
- Change deopt to use dead values when GetVReg does not succeed:
the optimizing compiler will not have a location for uninitialized
Dex registers and potentially dead registers.

Change-Id: Ida05773a97aff8aa69e0caf42ea961f80f854b77
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
ee0770379ab3e328fdd5a733e62f05b9f5216e38 09-Mar-2015 Nicolas Geoffray <ngeoffray@google.com> Use the current Java stack instead of the ThrowLocation.

The ThrowLocation contains information we can actually retrieve
from the current stack.

Change-Id: I7e5b2f519f95830c457cb31ea10a581aa9c973ee
1558b577907b613864e98f05862543557263e864 25-Feb-2015 Sebastien Hertz <shertz@google.com> JDWP: allocate DebugInvokeReq only when requested

Only allocates thread-local DebugInvokeReq when the debugger requests
a thread to invoke a method. The JDWP thread allocates that structure
then attaches it to the target thread. When the thread is resumed, it
executes the method. Once the invocation completes, the thread
detaches the DebugInvokeReq, signals the JDWP thread then suspends.
Finally, the JDWP thread wakes up, prepares the reply with the invoke
result (or exception) and deallocates the DebugInvokeReq.

Also ensures GC safety for object returned by the invoke. We add the
object to the JDWP object registry right after the invoke. We now
reference that object with a JDWP ObjectID instead of an Object* in
the DebugInvokeReq struct. This prevent from accessing a stale
reference if the GC runs and moves the Object*.

This CL includes the following changes:
- Move former DebugInvokeReq::ready flag to
Thread::tls_32bit_sized_values::ready_for_debug_invoke. It's needed
to know whether a thread has been suspended by an event, thus ready
to invoke a method from the debugger.
- Remove DebugInvokeReq::invoke_needed: we now test if we attached a
DebugInvokeReq* to the thread.
- Rename misleading FinishMethod function to RequestMethod.

Bug: 19142632
Bug: 18166750
Change-Id: I351fb4eb94bfe69fcafb544d21d55ff35a033000
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
7642cfc90fc9c3ebfd8e3b5041915705c93b5cf0 26-Feb-2015 Nicolas Geoffray <ngeoffray@google.com> Change how we report exceptions to the debugger.

This is only a refactoring/cleanup. Bug fixes with respect
to catch location, and more cleanups will follow.

Change-Id: I30d3c6260b0c8f8115a811621397225b88f2063a
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
794ad76e8d5b5b9132819d5b08a0570e27615644 23-Feb-2015 Andreas Gampe <agampe@google.com> ART: Introduce NO_RETURN, Mark DoLongJump noreturn

Add NO_RETURN macro that adds C++11 noreturn attribute. Mark
DoLongJump methods as noreturn.

Change-Id: Ifde4318e370493237050d4c1349285a0382df23f
e4301ffb56f9be6f6c2640bfb1870b74f4a37ad2 18-Feb-2015 Andreas Gampe <agampe@google.com> ART: Make run-tests more verbose

Make run-tests log ERROR level on host. Adjust some internal LOG(ERROR)
to LOG(WARNING). Add check scripts to adjust for other LOG(ERROR)
messages.

Bug: 18713034
Change-Id: I2a3e055baa6a0e31f106364c300c20963a59ed94
597c4f0aeafed2b6fa69e53ece4be4f53115d707 26-Jan-2015 Sebastien Hertz <shertz@google.com> JDWP: allocate single step control only when active

Only allocates SingleStepControl when a single step is requested in
a thread.

Bug: 19142632
Change-Id: I830b7eaea86b516d3fac80ce14d41c66b4bd5415
2cd334ae2d4287216523882f0d298cf3901b7ab1 09-Jan-2015 Hiroshi Yamauchi <yamauchi@google.com> More of the concurrent copying collector.

Bug: 12687968
Change-Id: I62f70274d47df6d6cab714df95c518b750ce3105
988939683c26c0b1c8808fc206add6337319509a 21-Jan-2015 Nicolas Geoffray <ngeoffray@google.com> Enable core callee-save on x64.

Will work on other architectures and FP support in other CLs.

Change-Id: I8cef0343eedc7202d206f5217fdf0349035f0e4d
e34fa1df67fbe0173b4ea9abddcc3ae3d0537037 14-Jan-2015 Mathieu Chartier <mathieuc@google.com> Print more info in MarkSweep::VerifyRoot

Refactored old root callback to use a new class called RootInfo.
RootInfo contains all the relevant info related to the root
associated with the callback. The MarkSweep::VerifyRoot function
now uses this info to print the StackVisitor's described location
if the GC root is of the type kRootJavaFrame.

Some other cleanup.

Example output:
E/art (12167): Tried to mark 0x123 not contained by any spaces
E/art (12167): Attempting see if it's a bad root
E/art (12167): Found invalid root: 0x123 with type RootJavaFrame
E/art (12167): Location=Visiting method
'void java.lang.Runtime.gc()' at dex PC 0xffffffff (native PC 0x0)
vreg=0

(cherry picked from commit 12f7423a2bb4bfab76700d84eb6d4338d211983a)

Bug: 18588862
Change-Id: Ic5a2781f704e931265ffb3621c2eab4b2e25f60f
12f7423a2bb4bfab76700d84eb6d4338d211983a 14-Jan-2015 Mathieu Chartier <mathieuc@google.com> Print more info in MarkSweep::VerifyRoot

Refactored old root callback to use a new class called RootInfo.
RootInfo contains all the relevant info related to the root
associated with the callback. The MarkSweep::VerifyRoot function
now uses this info to print the StackVisitor's described location
if the GC root is of the type kRootJavaFrame.

Some other cleanup.

Example output:
E/art (12167): Tried to mark 0x123 not contained by any spaces
E/art (12167): Attempting see if it's a bad root
E/art (12167): Found invalid root: 0x123 with type RootJavaFrame
E/art (12167): Location=Visiting method
'void java.lang.Runtime.gc()' at dex PC 0xffffffff (native PC 0x0)
vreg=0

Bug: 18588862
Change-Id: Ic5a2781f704e931265ffb3621c2eab4b2e25f60f
0a18df82f4dea95b7398f8c934341fccbf04eeee 10-Jan-2015 Elliott Hughes <enh@google.com> Clean up some #ifdefs.

Only the Mac doesn't have POSIX clocks. (And it still doesn't, a decade
later.)

glibc gained pthread_setname_np in 2.12.

Only the Mac doesn't have prctl.

Change-Id: I218e409f7e133736e15fb68e8a254cdc5799d667
bef89c910dc40f7e82ee56c3c8e8fdaa0cd5562b 09-Jan-2015 Mathieu Chartier <mathieuc@google.com> Fix HandleScope with wrong thread error

Possibly fixes
+art F 5127 6995 art/runtime/handle_scope-inl.h:43]
Check failed: top_handle_scope == this
(top_handle_scope=0x2b449293c770, this=0x2b4492d6a0a8)
Seen in tests. A possible cause was that the thread dumping stacks
was running checkpoints on a suspended thread but putting a
HandleScope on that thread instead of itself. This isn't safe if the
suspended thread is doing HandleScope stuff in a non runnable state.

Change-Id: Icdaadabca5aff8d380d5cc9570b9e899fe790a62
e6a8eec3a5db28de7d5db6d78e38033b80740e49 06-Jan-2015 Mathieu Chartier <mathieuc@google.com> Fix frequent gcstress ThreadStress crash

Calling IdentityHashCode before PrettyTypeOf was causing occasional
stale root errors since IdentityHashCode can cause thread suspension.

Cleaned up VisitLocks.

Bug: 18766916
Change-Id: I7679539877e48a8c9aadb8a34718404ebce98d25
4306ef8a7ec8e3887e51f64e80d940d974cc3ac3 20-Dec-2014 Mathieu Chartier <mathieuc@google.com> Don't allow suspension from FindLocksAtDexPc

Transitioning to suspended from runnable sometimes runs dump
checkpoints in ThreadStress which can cause deadlocks. This happens
since FindLocksAtDexPC runs the verifier which calls
AllowThreadSuspension. This results in a blocked thread which holds
the monitor lock, and if another thread tries to do a monitor enter,
it deadlocks while holding the mutator lock (assuming the GC is
suspending all).

The fix for avoiding this deadlock is not calling
AllowThreadSuspension from FindLocksAtDexPc.

Bug: 18576985
Change-Id: I7e5faaf3bbbd5b5f680de95d53c33b5106705b0c
b8f2f63c3d5f0d6fb2a165b3fb8379608076ddae 02-Jan-2015 Vladimir Marko <vmarko@google.com> Implement LogLineLowStack() properly.

Avoid stack-based buffers used by the log formatting in
__android_log_print().

Move the VLOG(threads) in Thread::InitStackHwm() after the
low stack check as it's not safe to actually log before
that; even the StringPrintf() is using a stack-based buffer.

Bug: 18830897
Change-Id: I13b2166438e871c52ab91dabfe98f2200fd7c1cf
a1b94c6d06e3cf2aa4f3aa42a1133995a4d8a1fb 18-Dec-2014 Hiroshi Yamauchi <yamauchi@google.com> Fix a race condition during the rosalloc verification.

Since an exiting thread could revoke its thread-local runs without
holding the mutator lock, when rosalloc verification is running at a
pause, the thread could concurrently modify runs and cause a race
condition/verification check failure.

Now an exiting thread acquires the mutator lock when it revokes its
thread-local runs, which should avoid the race condition.

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

Change-Id: I3bf3250fa866fd2265f1b115d52fa5dedc48a7fc
db978719dbcb73fc6acfd193561445c4462786b8 09-Dec-2014 Nicolas Geoffray <ngeoffray@google.com> Revert "Tidy gAborting."

Creates infinite loop: b/18674776.

This reverts commit 015b137efb434528173779bc3ec8d72494456254.

Change-Id: I67fe310d2e95ee2ec37bec842be06fb1123b6f4e
015b137efb434528173779bc3ec8d72494456254 05-Dec-2014 Ian Rogers <irogers@google.com> Tidy gAborting.

Reduce scope to Runtime::Abort and short-cut recursive case earlier. gAborting
remains global to avoid two fatal errors in thread and the verifier.

Change-Id: Ibc893f891ffee9a763c65cde9507d99083d47b3f
957ca1cd025104fccb0b08928f955f9bdb4ab91c 22-Nov-2014 Mathieu Chartier <mathieuc@google.com> Delete ArtMethod gc_map_ field

Moved the gc_map field from OatMethod to OatQuickMethodHeader.
Deleted the ArtMethod gc_map_ field.

Bug: 17643507

Change-Id: Ifa0470c3e4c2f8a319744464d94c6838b76b3d48

(cherry picked from commit 807140048f82a2b87ee5bcf337f23b6a3d1d5269)
c6fc909c6b42b4c365b1e7f86639ee4b360249fa 22-Nov-2014 Mathieu Chartier <mathieuc@google.com> Delete ArtMethod gc_map_ field

Moved the gc_map field from OatMethod to OatQuickMethodHeader.
Deleted the ArtMethod gc_map_ field.

Bug: 17643507

Change-Id: Ifa0470c3e4c2f8a319744464d94c6838b76b3d48
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
445120568460cae68d37a27ac39477fbf20952fc 12-Nov-2014 Vladimir Marko <vmarko@google.com> Fix bad OOM check in Thread::CreatePeer().

Bug: 18342629

(cherry picked from commit 7bcea103af7cd130254835a30b45d5277a478074)

Change-Id: I5d5c7511bbc705d040095f4934d98d326d54d39e
7bcea103af7cd130254835a30b45d5277a478074 12-Nov-2014 Vladimir Marko <vmarko@google.com> Fix bad OOM check in Thread::CreatePeer().

Bug: 18342629
Change-Id: Ic070ed6b72d11b2e1e2a89904bd9659b2146f863
f4d4da18aa1914d10264082bd0433f59bff45453 12-Nov-2014 Ian Rogers <irogers@google.com> Allow JNI AttachCurrentThread to fail if not enough stack.

Add unit tests and move JavaVM JNI tests into there own set of gtests.
Bug: 18330119

Change-Id: I0e93dff783b1f5d787b3084d24122883e14951a1
e07fd17f3c45034470eb6f5a265152a39854995c 11-Nov-2014 Mathieu Chartier <mathieuc@google.com> Add null check for thread name creation

Previously we didn't check for null which could result in check jni
failures if we tried to throw another OOM in the next allocation.

Bug: 18297817

(cherry picked from commit a7ade888ab99b1453571d14c41d4a0322c400fcd)

Change-Id: Ideef46f4900e546e81fbd9a5225c06698f36e9ac
a7ade888ab99b1453571d14c41d4a0322c400fcd 11-Nov-2014 Mathieu Chartier <mathieuc@google.com> Add null check for thread name creation

Previously we didn't check for null which could result in check jni
failures if we tried to throw another OOM in the next allocation.

Bug: 18297817
Change-Id: I459b1de7760a4009e410fdbdcacdb748d13fbc1d
a0b34518cf3f3801407624d95846f8ff90c05d25 07-Oct-2014 Narayan Kamath <narayan@google.com> Fix thread priorities for unstarted threads.

Calls to Thread.setPriority for unstarted threads now behave
similar to dalvik. Note that there's still some inconsistent
behaviour carried over from dalvik.

- high priority threads from bg_non_interactive processes are
not always moved to the SP_FOREGROUND cgroup.
- we do not attempt to adjust the cgroup of a native thread
that's attaching.

Note that on android, the system_server will change the
cgroups for all running threads in a process when it moves
into the foreground and background. It's by design that
threads in a background process can request to be moved
to the foreground by setting a higher priority.

bug: 17893086

(cherry picked from commit 1bd326a5e2aaff06a5bcae9cb2c42a4e8de31401)

Change-Id: Iad362f7c5c8697c349f2b6d7fcba69a4e141883e
1bd326a5e2aaff06a5bcae9cb2c42a4e8de31401 07-Oct-2014 Narayan Kamath <narayan@google.com> Fix thread priorities for unstarted threads.

Calls to Thread.setPriority for unstarted threads now behave
similar to dalvik. Note that there's still some inconsistent
behaviour carried over from dalvik.

- high priority threads from bg_non_interactive processes are
not always moved to the SP_FOREGROUND cgroup.
- we do not attempt to adjust the cgroup of a native thread
that's attaching.

Note that on android, the system_server will change the
cgroups for all running threads in a process when it moves
into the foreground and background. It's by design that
threads in a background process can request to be moved
to the foreground by setting a higher priority.

bug: 17893086

Change-Id: I1662982b1c7b3ac509698e2e12c9768d082c8053
277ccbd200ea43590dfc06a93ae184a765327ad0 04-Nov-2014 Andreas Gampe <agampe@google.com> ART: More warnings

Enable -Wno-conversion-null, -Wredundant-decls and -Wshadow in general,
and -Wunused-but-set-parameter for GCC builds.

Change-Id: I81bbdd762213444673c65d85edae594a523836e5
2c4257be8191c5eefde744e8965fcefc80a0a97d 24-Oct-2014 Ian Rogers <irogers@google.com> Tidy logging code not using UNIMPLEMENTED.

Change-Id: I7a79c1671a6ff8b2040887133b3e0925ef9a3cfe
c7dd295a4e0cc1d15c0c96088e55a85389bade74 22-Oct-2014 Ian Rogers <irogers@google.com> Tidy up logging.

Move gVerboseMethods to CompilerOptions. Now "--verbose-methods=" option to
dex2oat rather than runtime argument "-verbose-methods:".
Move ToStr and Dumpable out of logging.h, move LogMessageData into logging.cc
except for a forward declaration.
Remove ConstDumpable as Dump methods are all const (and make this so if not
currently true).
Make LogSeverity an enum and improve compile time assertions and type checking.
Remove log_severity.h that's only used in logging.h.
With system headers gone from logging.h, go add to .cc files missing system
header includes.
Also, make operator new in ValueObject private for compile time instantiation
checking.

Change-Id: I3228f614500ccc9b14b49c72b9821c8b0db3d641
250e372f889049f55b54bb4149c2deb041fc38c1 20-Oct-2014 Daniel Mihalyi <daniel.mihalyi@mattakis.com> Fixed debugger for threads attached from JNI

Dbg::PostThreadStart was not invoked in Thread::Attach,
thus when attaching existing native thread to JNI, JDWP
events from that thread are not handled correctly by the
debugger, because the thread keeps being unannounced.

The issue was reproduced on Eclipse 4.3 and 4.4.

Bug: 18030371
(cherry picked from commit dfafeef139dbc77e86fdb465d960b4a17a7ac4a0)

Change-Id: Ia91dcf1aa98913aea2742c90b3e21b10d2cb36d4
Signed-off-by: Daniel Mihalyi <daniel.mihalyi@mattakis.com>
1d8cdbc5202378a5f1a4b3a1fba610675ed4dcd5 23-Sep-2014 Ian Rogers <irogers@google.com> Refactor quick entrypoints

Remove FinishCalleeSaveFrameSetup.
Assembly routines write down anchor into TLS as well as placing runtime
method in callee save frame.
Simplify artSet64InstanceFromCode by not computing the referrer from the
stack in the C++ code.
Move assembly offset tests next to constant declaration and tidy arch_test.

Change-Id: Iededeebc05e54a1e2bb7bb3572b8ba012cffa1c8
dfafeef139dbc77e86fdb465d960b4a17a7ac4a0 20-Oct-2014 Daniel Mihalyi <daniel.mihalyi@mattakis.com> Fixed debugger for threads attached from JNI

Dbg::PostThreadStart was not invoked in Thread::Attach,
thus when attaching existing native thread to JNI, JDWP
events from that thread are not handled correctly by the
debugger, because the thread keeps being unannounced.

The issue was reproduced on Eclipse 4.3 and 4.4.

Change-Id: I9a330f5cb96857862b18f37047ef87646a1f2aa2
Signed-off-by: Daniel Mihalyi <daniel.mihalyi@mattakis.com>
677cd61ad05d993c4d3b22656675874f06d6aabc 15-Oct-2014 Ian Rogers <irogers@google.com> Make ART compile with GCC -O0 again.

Tidy up InstructionSetFeatures so that it has a type hierarchy dependent on
architecture.
Add to instruction_set_test to warn when InstructionSetFeatures don't agree
with ones from system properties, AT_HWCAP and /proc/cpuinfo.
Clean-up class linker entry point logic to not return entry points but to
test whether the passed code is the particular entrypoint. This works around
image trampolines that replicate entrypoints.
Bug: 17993736

(cherry picked from commit 6f3dbbadf4ce66982eb3d400e0a74cb73eb034f3)

Change-Id: I3e7595f437db4828072589d475a5453b7f31003e
6f3dbbadf4ce66982eb3d400e0a74cb73eb034f3 15-Oct-2014 Ian Rogers <irogers@google.com> Make ART compile with GCC -O0 again.

Tidy up InstructionSetFeatures so that it has a type hierarchy dependent on
architecture.
Add to instruction_set_test to warn when InstructionSetFeatures don't agree
with ones from system properties, AT_HWCAP and /proc/cpuinfo.
Clean-up class linker entry point logic to not return entry points but to
test whether the passed code is the particular entrypoint. This works around
image trampolines that replicate entrypoints.
Bug: 17993736

Change-Id: I5f4b49e88c3b02a79f9bee04f83395146ed7be23
acbb30867482986e02a7cc53c099b8d56d32acee 16-Oct-2014 Xingxing Pan <xxingpan@gmail.com> Fix UnimplementedEntryPoint initialziation.

Change-Id: I16c4a8869a210008eede244fc3e5388d882ccaf5
Signed-off-by: Xingxing Pan <xxingpan@gmail.com>
5eaff90846d34434c1a67f61ccd09a3d52e4246b 11-Oct-2014 Ian Rogers <irogers@google.com> Handlerize throw location in DumpJavaStack

Handlerize this object and method during DumpJavaStack.
Bug: 17669899

(cherry picked from commit 79ffe35fa0784f26c2d25242ea1b3ce300a009cb)

Change-Id: Id090daaa2eef8cd445e52cbbe71b2e2ed7fef2fe
986c6fbb5f65006165f8b7fed1fd105fb3a83bd9 03-Oct-2014 Andreas Gampe <agampe@google.com> ART: Stash any exception before dumping a stack

Dumping a managed stack entails dumping held locks, in the process
of which the verifier will be run. The verifier works under the
assumption that there were no exceptions when started. This
assumption is violated for example on certain JNI aborts.

The solution is to stash any pending exception before dumping the
stack, and re-installing it afterwards.

Bug: 17669899

(cherry picked from commit d87bc135dba41f0f21cf0018a3b2cb46809890d7)

Change-Id: Ic44780bad90a8e1ba80858c807e2bef3bf6651c6
79ffe35fa0784f26c2d25242ea1b3ce300a009cb 11-Oct-2014 Ian Rogers <irogers@google.com> Handlerize throw location in DumpJavaStack

Handlerize this object and method during DumpJavaStack.
Bug: 17669899

Change-Id: I2e082137fe7f4c82257fc3b2fb36485a6981f369
13735955f39b3b304c37d2b2840663c131262c18 08-Oct-2014 Ian Rogers <irogers@google.com> stdint types all the way!

Change-Id: I4e4ef3a2002fc59ebd9097087f150eaf3f2a7e08
d87bc135dba41f0f21cf0018a3b2cb46809890d7 03-Oct-2014 Andreas Gampe <agampe@google.com> ART: Stash any exception before dumping a stack

Dumping a managed stack entails dumping held locks, in the process
of which the verifier will be run. The verifier works under the
assumption that there were no exceptions when started. This
assumption is violated for example on certain JNI aborts.

The solution is to stash any pending exception before dumping the
stack, and re-installing it afterwards.

Bug: 17669899
Change-Id: I3cd0526b52fce1acaa35fe0e419176478c82be22
c8ccf68b805c92674545f63e0341ba47e8d9701c 30-Sep-2014 Andreas Gampe <agampe@google.com> ART: Fix some -Wpedantic errors

Remove extra semicolons.

Dollar signs in C++ identifiers are an extension.

Named variadic macros are an extension.

Binary literals are a C++14 feature.

Enum re-declarations are not allowed.

Overflow.

Change-Id: I7d16b2217b2ef2959ca69de84eaecc754517714a
2366f4e4432d8644404de8c9f9d6a8f2f0b329ff 20-Sep-2014 Christopher Ferris <cferris@google.com> Dump kernel/native stacks of pure native threads.

Bug: 16463406

(cherry picked from commit 7da37cca5a5f71a0cd2442b2a119f76fa62e84b5)

Change-Id: I22a26d4ec4e3048ddcfd668eee4fccd8b2b3b727
7da37cca5a5f71a0cd2442b2a119f76fa62e84b5 20-Sep-2014 Christopher Ferris <cferris@google.com> Dump kernel/native stacks of pure native threads.

Bug: 16463406
Change-Id: Ifa18d7ec6c60721ce4d3e73944851d1f07372043
b2f5dbb85bef25eb911dbea119ed8d6450fd6f8c 17-Sep-2014 Andreas Gampe <agampe@google.com> ART: Avoid recursive abort on thread dump

Also clean up unused variable.

Bug: 15567083
Change-Id: Id83a3784bbe88520a4ffe654b2553d36a7b8e5bc
(cherry picked from commit 2f9e21503c2b6958213f9a2610023c7ab8a01707)
2f9e21503c2b6958213f9a2610023c7ab8a01707 17-Sep-2014 Andreas Gampe <agampe@google.com> ART: Avoid recursive abort on thread dump

Also clean up unused variable.

Bug: 15567083
Change-Id: Id83a3784bbe88520a4ffe654b2553d36a7b8e5bc
5a4b8a236030460651a3136397d23ca6744e7eb7 11-Sep-2014 Andreas Gampe <agampe@google.com> ART: Rename Handle hierarchy

Bring the names in line with normal OO principles: ConstHandle
becomes Handle, and Handle becomes MutableHandle.

Change-Id: I0f018eb7ba28bc422e3a23dd73a6cbe6fc2d2044
7b078e8c04f3e1451dbdd18543c8b9692b5b067e 10-Sep-2014 Ian Rogers <irogers@google.com> Compile time performance improvements focusing on interpret-only.

Reduce virtual method dispatch in the method verifier and make more code
inline-able.
Add a StringPiece with const char* equality operator to avoid redundant
StringPieces and strlens.
Remove back link from register line to verifier and pass as argument to reduce
size of RegisterLine.
Remove instruction length from instruction flags and compute from the
instruction, again to reduce size.
Add suspend checks to resolve and verify to allow for more easy monitor
inflation and reduce contention on Locks::thread_list_suspend_thread_lock_.
Change ThrowEarlierClassFailure to throw pre-allocated exception.
Avoid calls to Thread::Current() by passing self.
Template specialize IsValidClassName.
Make ANR reporting with SIGQUIT run using checkpoints rather than suspending
all threads. This makes the stack/lock analysis less lock error prone.
Extra Barrier assertions and condition variable time out is now returned as a
boolean both from Barrier and ConditionVariable::Wait.

2 threaded host x86-64 interpret-only numbers from 341 samples:
Before change: Avg 176.137ms 99% CI 3.468ms to 1060.770ms
After change: Avg 139.163% 99% CI 3.027ms to 838.257ms
Reduction in average compile time after change is 20.9%.
Slow-down without change is 26.5%.

Bug: 17471626 - Fix bug where RegTypeCache::JavaLangObject/String/Class/Throwable
could return unresolved type when class loading is disabled.
Bug: 17398101

Change-Id: Id59ce3cc520701c6ecf612f7152498107bc40684
3946844c34ad965515f677084b07d663d70ad1b8 02-Sep-2014 Nicolas Geoffray <ngeoffray@google.com> Runtime support for the new stack maps for the opt compiler.

Now most of the methods supported by the compiler can be optimized,
instead of using the baseline.

Change-Id: I80ab36a34913fa4e7dd576c7bf55af63594dc1fa
c0542af3e2170143ba40d89136e284997e16bf64 04-Sep-2014 Ian Rogers <irogers@google.com> Remove abuse of mirror::Object* to reference special values.

Remove kInvalidIndirectRefObject, kClearedJniWeakGlobal and
ObjectRegistry::kInvalidObject. Handle error conditions by passing in or
returning an error value.
GetObjectRefType is simplified to be faster and not return invalid references
that are not expected according to the spec. Adjust check JNI and
jni_internal_test appropriately.
Fix cases in the debugger/JDWP of out arguments being passed by reference.
Bug: 17376993

Change-Id: I3ce8a28c01827e163f4dc288449959464da788b1
839cc30467d51414e8185eee6101e19f5ab20871 28-Aug-2014 Elliott Hughes <enh@google.com> Move the glibc unlimited stack hack into GetThreadStack.

Optional cleanup that was previously a TODO.

Bug: 17111575
Change-Id: I7c20dbf1fdbcaf4604d7b55552930c10e166539d
6d3fc5615612e500a00aba0a0d331436fae8d996 27-Aug-2014 Elliott Hughes <enh@google.com> Actually ask the pthread implementation for the stack guard size.

(cherry-pick 307091dc306c34ce9e4ee6cc3b467807b3a3bd12.)

Bug: 17111575
Change-Id: I23919b1e8aeff627a65daf57f1109bec60b196cc
307091dc306c34ce9e4ee6cc3b467807b3a3bd12 27-Aug-2014 Elliott Hughes <enh@google.com> Actually ask the pthread implementation for the stack guard size.

Bug: 17111575
Change-Id: I23919b1e8aeff627a65daf57f1109bec60b196cc
8ce6b9040747054b444a7fa706503cd257801936 26-Aug-2014 Dave Allison <dallison@google.com> Handle nested signals

This allows for signals to be raised inside the ART signal handler.
This can occur when the JavaStackTraceHandler attempts to generate
a stack trace and something goes wrong.

It also fixes an issue where the fault manager was not being
correctly shut down inside the signal chaining code. In this
case the signal handler was not restored to the original.

Bug: 17006816
Bug: 17133266

(cherry picked from commit fabe91e0d558936ac26b98d2b4ee1af08f58831d)

Change-Id: I10730ef52d5d8d34610a5293253b3be6caf4829e
b68c6e578a28a9717d78dfd522d9d9b8befaedf2 19-Aug-2014 Mathieu Chartier <mathieuc@google.com> Reduce interpret-only compile time.

Before:
39.04user 5.18system 0:29.24elapsed 151%CPU (0avgtext+0avgdata 164176maxresident)k
38.87user 5.16system 0:29.14elapsed 151%CPU (0avgtext+0avgdata 164144maxresident)k

After:
36.26user 3.25system 0:27.00elapsed 146%CPU (0avgtext+0avgdata 162592maxresident)k
36.25user 3.28system 0:26.28elapsed 150%CPU (0avgtext+0avgdata 162688maxresident)k

Disabled implicit stack protection for the compiler, this reduces page faults.

Added support for not timing every method compilation and verification. NanoTime is
slow and adds ~2 seconds of real time. This is currently enabled since people want
to know which methods are slow to compile.

Bug: 16853450

(cherry picked from commit 8e219ae27624116b6d23e858fb21e93342f81d66)

Change-Id: I349ffb3f36db8c437137387aa6914dc17d743f09
fabe91e0d558936ac26b98d2b4ee1af08f58831d 26-Aug-2014 Dave Allison <dallison@google.com> Handle nested signals

This allows for signals to be raised inside the ART signal handler.
This can occur when the JavaStackTraceHandler attempts to generate
a stack trace and something goes wrong.

It also fixes an issue where the fault manager was not being
correctly shut down inside the signal chaining code. In this
case the signal handler was not restored to the original.

Bug: 17006816
Bug: 17133266
Change-Id: I9c25bf4f6921e6a107aefbdf47d2c0db9f41508f
8e219ae27624116b6d23e858fb21e93342f81d66 19-Aug-2014 Mathieu Chartier <mathieuc@google.com> Reduce interpret-only compile time.

Before:
39.04user 5.18system 0:29.24elapsed 151%CPU (0avgtext+0avgdata 164176maxresident)k
38.87user 5.16system 0:29.14elapsed 151%CPU (0avgtext+0avgdata 164144maxresident)k

After:
36.26user 3.25system 0:27.00elapsed 146%CPU (0avgtext+0avgdata 162592maxresident)k
36.25user 3.28system 0:26.28elapsed 150%CPU (0avgtext+0avgdata 162688maxresident)k

Disabled implicit stack protection for the compiler, this reduces page faults.

Added support for not timing every method compilation and verification. NanoTime is
slow and adds ~2 seconds of real time. This is currently enabled since people want
to know which methods are slow to compile.

Bug: 16853450

Change-Id: I349ffb3f36db8c437137387aa6914dc17d743f09
d9efea646485fe996c967f4680a3fc4cdc40b251 22-Jul-2014 Andreas Gampe <agampe@google.com> ART: Improve error message on oat writer failure

Try to log the pending exception to help resolve issues.

Bug: 16406811
Change-Id: I035ae9e59a5ee02b9e90c35c0644ec088d3c7d12
37f05ef45e0393de812d51261dc293240c17294d 17-Jul-2014 Fred Shih <ffred@google.com> Reduced memory usage of primitive fields smaller than 4-bytes

Reduced memory used by byte and boolean fields from 4 bytes down to a
single byte and shorts and chars down to two bytes. Fields are now
arranged as Reference followed by decreasing component sizes, with
fields shuffled forward as needed.

Bug: 8135266
Change-Id: I65eaf31ed27e5bd5ba0c7d4606454b720b074752
216cf23663789b06508f65f6dc0a72f181c9c03a 19-Aug-2014 Dave Allison <dallison@google.com> Workaround problem reading main stack on intel devices.

This works around a problem where ART can't read the lowest page
of the main stack. The workaround is to add 4K to the stack
start address on the main stack on Intel.

Please see https://b2.corp.google.com/issues/17111575 for
underlying cause.

Cherry picked from d970bac690baa6f735b0cd187440546869088a0f

Bug: 17031544
Change-Id: Ifc3216e10160bb1eec9d989fd57b10345bc89537
d970bac690baa6f735b0cd187440546869088a0f 19-Aug-2014 Dave Allison <dallison@google.com> Workaround problem reading main stack on intel devices.

This works around a problem where ART can't read the lowest page
of the main stack. The workaround is to add 4K to the stack
start address on the main stack on Intel.

Please see https://b2.corp.google.com/issues/17111575 for
underlying cause.

Bug: 17031544
Change-Id: Ifc3216e10160bb1eec9d989fd57b10345bc89537
b090a18e4292dc339a3b2668bf6dc855928dee3a 14-Aug-2014 Dave Allison <dallison@google.com> Merge stack usage reduction for overflow checks

Cherry pick from: b038ba66a166fb264ca121632f447712e0973b5b

Change-Id: I19999e72ff731d4fc73d91b9ff767de5858c15ee
3ea69c0abce1b81b3c45033867d49b00e6d6b709 19-Aug-2014 Brian Carlstrom <bdc@google.com> AttachCurrentThread should only warn on missing thread name if CheckJNI is enabled.

Bug: 17108693
Change-Id: I346cc090e091605c552e5954d7ea1ca4874cea5f
21ecab6effd08ed781d55fbb53b0e71c526c25fa 19-Aug-2014 Brian Carlstrom <bdc@google.com> AttachCurrentThread should only warn on missing thread name if CheckJNI is enabled.

Bug: 17108693

(cherry picked from commit 3ea69c0abce1b81b3c45033867d49b00e6d6b709)

Change-Id: Ide8158cc3e12e604f4fa344cd881fe6f68476ab7
956a5228276693a7317ae6b41bfe7a7f0f3cbe6b 16-Aug-2014 Andreas Gampe <agampe@google.com> ART: Do not recursively abort when visiting locks in a bad state

This avoids a nested abort in VisitLocks.

Bug: 17080621, 16382675

(cherry picked from commit 760172c3ccd6e75f6f1a89d8006934e8ffb1303e)

Change-Id: Id604976ac9dcac0e319fb25cab4d2cbc98d7ee24
760172c3ccd6e75f6f1a89d8006934e8ffb1303e 16-Aug-2014 Andreas Gampe <agampe@google.com> ART: Do not recursively abort when visiting locks in a bad state

This avoids a nested abort in VisitLocks.

Bug: 17080621, 16382675
Change-Id: Id604976ac9dcac0e319fb25cab4d2cbc98d7ee24
b038ba66a166fb264ca121632f447712e0973b5b 14-Aug-2014 Dave Allison <dallison@google.com> Revert "Revert "Reduce stack usage for overflow checks""

Fixes stack protection issue.
Fixes mac build issue.

This reverts commit 83b1940e6482b9d8feba5c492507735686650ea5.

Change-Id: I7ba17252882b23a740bcda2ea94aacf398255406
2d0b18f74149302cc4c39a91c26ac218fff33a8b 14-Aug-2014 Andreas Gampe <agampe@google.com> Revert "ART: Fix mac build"

The underlying CL was reverted.

This reverts commit 564f58305961986591ccb2fff04b9ccdd430a6db.

Change-Id: Ic9fe93a95c4357d0045a430713be7da517f626b5
4cf00ba324f5f6884059796a6ba41937f32e1844 14-Aug-2014 Dave Allison <dallison@google.com> Revert "Reduce stack usage for overflow checks"

This reverts commit 63c051a540e6dfc806f656b88ac3a63e99395429.

Change-Id: I282a048994fcd130fe73842b16c21680053c592f
b84d7a226399dcc60bc0a421715ffc90ce9213f7 15-Aug-2014 Andreas Gampe <agampe@google.com> Revert "Revert "ART: Fix mac build""

This reverts commit 350b03bca65f87895275d1ed4bb895d5afeeeff1.

Also fixes a fault_handler symbol.

Change-Id: I1315527400bffc8ded9f2a7e7fdb1c8a6c104b96
03c9785a8a6d712775cf406c4371d0227c44148f 14-Aug-2014 Dave Allison <dallison@google.com> Revert "Revert "Reduce stack usage for overflow checks""

Fixes stack protection issue.
Fixes mac build issue.

This reverts commit 83b1940e6482b9d8feba5c492507735686650ea5.

Change-Id: I7ba17252882b23a740bcda2ea94aacf398255406
83b1940e6482b9d8feba5c492507735686650ea5 14-Aug-2014 Dave Allison <dallison@google.com> Revert "Reduce stack usage for overflow checks"

This reverts commit 63c051a540e6dfc806f656b88ac3a63e99395429.

Change-Id: I282a048994fcd130fe73842b16c21680053c592f
564f58305961986591ccb2fff04b9ccdd430a6db 14-Aug-2014 Andreas Gampe <agampe@google.com> ART: Fix mac build

is_main_thread is unused in the case of a mac.

Bug: 15435566

(cherry picked from commit 7b1bf42dbc765524d54d45a70cb7eb1cccf0c617)

Change-Id: I9848d0156a4903ce73d20b5ce282b61ceb3039ff
7b1bf42dbc765524d54d45a70cb7eb1cccf0c617 14-Aug-2014 Andreas Gampe <agampe@google.com> ART: Fix mac build

is_main_thread is unused in the case of a mac.

Change-Id: Ib0658b622f261e09dbe1c7592fa802a484ba7f94
63c051a540e6dfc806f656b88ac3a63e99395429 26-Jul-2014 Dave Allison <dallison@google.com> Reduce stack usage for overflow checks

This reduces the stack space reserved for overflow checks to 12K, split
into an 8K gap and a 4K protected region. GC needs over 8K when running
in a stack overflow situation.

Also prevents signal runaway by detecting a signal inside code that
resulted from a signal handler invokation. And adds a max signal count to
the SignalTest to prevent it running forever.

Also reduces the number of iterations for the InterfaceTest as this was
taking (almost) forever with the --trace option on run-test.

Bug: 15435566

Change-Id: Id4fd46f22d52d42a9eb431ca07948673e8fda694

Conflicts:
compiler/optimizing/code_generator_x86_64.cc
runtime/arch/x86/fault_handler_x86.cc
runtime/arch/x86_64/quick_entrypoints_x86_64.S
350b03bca65f87895275d1ed4bb895d5afeeeff1 14-Aug-2014 Andreas Gampe <agampe@google.com> Revert "ART: Fix mac build"

The underlying CL was reverted.

This reverts commit 564f58305961986591ccb2fff04b9ccdd430a6db.

Change-Id: Ic9fe93a95c4357d0045a430713be7da517f626b5
648d7112609dd19c38131b3e71c37bcbbd19d11e 26-Jul-2014 Dave Allison <dallison@google.com> Reduce stack usage for overflow checks

This reduces the stack space reserved for overflow checks to 12K, split
into an 8K gap and a 4K protected region. GC needs over 8K when running
in a stack overflow situation.

Also prevents signal runaway by detecting a signal inside code that
resulted from a signal handler invokation. And adds a max signal count to
the SignalTest to prevent it running forever.

Also reduces the number of iterations for the InterfaceTest as this was
taking (almost) forever with the --trace option on run-test.

Bug: 15435566

Change-Id: Id4fd46f22d52d42a9eb431ca07948673e8fda694
68d8b42ddec39ec0174162d90d4abaa004d1983e 17-Jul-2014 Ian Rogers <irogers@google.com> Wire up check JNI force copy mode.

Increase check JNI checks.
Break apart jni_internal.h in to jni_env_ext.h and java_vm_ext.h.
Fix the abuse of ScopedObjectAccess/annotalysis by ScopedCheck in the case
of VM routines.
Make class loader override and shared library class loader JNI global
references rather than mirror pointers.
Clean-ups to native bridge.

Change-Id: If7c6110b5aade7a402bfb67534af86a7b2cdeb55
698d79d1e3f348102deaa03b5e0fc23641107239 25-Jul-2014 Andreas Gampe <agampe@google.com> ART: Clean up API after change 102631

This adds an abort_on_error parameter to GetCurrentMethod, which is
by default true. This restores all previous behavior, except for
monitor installation, where it follows 101639.

Bug: 16556938

(cherry picked from commit 6ec8ebd178ed39aa09e4c7fad194900114c4121a)

Change-Id: I2dee19d30674f2ffda33b3dc963e12470f39edb9
6d5e82f78d7b121a33f935521e0a7f5335cab213 25-Jul-2014 Andreas Gampe <agampe@google.com> ART: Fix wrong CHECK in GetCurrentLocationForThrow

Under certain circumstances kDexNoIndex is actually an encoded
dex pc. Change the setup of CurrentMethodVisitor to account for that.

Bug: 16556938

(cherry picked from commit f9df5c1639a9418fcdf70476556a4c30b210701e)

Change-Id: Icb1d42ccd22296e2e0c629ebbd7e4d8c7d87f07a
b3ec51e63c5041f77389ee001b47a8897b2a7acc 17-Jul-2014 Andreas Gampe <agampe@google.com> ART: Relax CurrentMethodVisitor requirements on GetDexPC

In case we want to dump a Java stack after an unhandled fault, in
case we hold a thinlocked monitor, that monitor might get inflated.
That can cause an abort as we may not have enough/correct information
for the state at the bottom-most call.

Relax GetDexPc in the CurrentMethodVisitor to not abort when it cannot
find a dex pc. Instead, let the caller handle such a case. This CL
allows the locking_dex_pc_ in Monitor to be DexFile::kDexNoIndex,
which avoids the above abort.

Bug: 16352802, 16556938

(cherry picked from commit 4a8c3fa4bd8d95fac5671ab778dd00b6dc3ec0e4)

Change-Id: I60d3d89603de65752d9230ceac6abb0242388c18
6ec8ebd178ed39aa09e4c7fad194900114c4121a 25-Jul-2014 Andreas Gampe <agampe@google.com> ART: Clean up API after change 102631

This adds an abort_on_error parameter to GetCurrentMethod, which is
by default true. This restores all previous behavior, except for
monitor installation, where it follows 101639.

Bug: 16556938
Change-Id: I9a12b9a21ccb9f558c86236bb58d15ff2fafaec0
0f45f22eb3c52f0ece4c56989180e79c6680d825 15-Jul-2014 Andreas Gampe <agampe@google.com> ART: Throw StackOverflowError in native code

Initialize stack-overflow errors in native code to be able to reduce
the preserved area size of the stack.

Includes a refactoring away from constexpr in instruction_set.h to allow
for easy changing of the values.

Bug: 16256184

(cherry picked from commit 7ea6f79bbddd69d5db86a8656a31aaaf64ae2582)

Change-Id: I117cc8485f43da5f0a470f0f5e5b3dc3b5a06246
f9df5c1639a9418fcdf70476556a4c30b210701e 25-Jul-2014 Andreas Gampe <agampe@google.com> ART: Fix wrong CHECK in GetCurrentLocationForThrow

Under certain circumstances kDexNoIndex is actually an encoded
dex pc. Change the setup of CurrentMethodVisitor to account for that.

Bug: 16556938
Change-Id: I4671f8c71c76f3e17e02db10f6da8ecc8331c87d
4a8c3fa4bd8d95fac5671ab778dd00b6dc3ec0e4 17-Jul-2014 Andreas Gampe <agampe@google.com> ART: Relax CurrentMethodVisitor requirements on GetDexPC

In case we want to dump a Java stack after an unhandled fault, in
case we hold a thinlocked monitor, that monitor might get inflated.
That can cause an abort as we may not have enough/correct information
for the state at the bottom-most call.

Relax GetDexPc in the CurrentMethodVisitor to not abort when it cannot
find a dex pc. Instead, let the caller handle such a case. This CL
allows the locking_dex_pc_ in Monitor to be DexFile::kDexNoIndex,
which avoids the above abort.

Bug: 16352802, 16556938
Change-Id: I3adf89b2d8f018a0c3e3abdd26e542f46ee59eef
7ea6f79bbddd69d5db86a8656a31aaaf64ae2582 15-Jul-2014 Andreas Gampe <agampe@google.com> ART: Throw StackOverflowError in native code

Initialize stack-overflow errors in native code to be able to reduce
the preserved area size of the stack.

Includes a refactoring away from constexpr in instruction_set.h to allow
for easy changing of the values.

Change-Id: I117cc8485f43da5f0a470f0f5e5b3dc3b5a06246
c114b5fbc91e6d19ef430d9bc3468386ca61b324 21-Jul-2014 Ian Rogers <irogers@google.com> Fix erroneous behaviors with OOME present.

Bug: 16454510
Change-Id: I757088a7b82ff73f58aba8d357080028b56442e6
147eb41b53729ec8d5c188d1cac90964a51afb8a 11-Jul-2014 Dave Allison <dallison@google.com> Revert "Revert "Revert "Revert "Add implicit null and stack checks for x86""""

This reverts commit 0025a86411145eb7cd4971f9234fc21c7b4aced1.

Bug: 16256184
Change-Id: Ie0760a0c293aa3b62e2885398a8c512b7a946a73

Conflicts:
compiler/dex/quick/arm64/target_arm64.cc
compiler/image_test.cc
runtime/fault_handler.cc
69dfe51b684dd9d510dbcb63295fe180f998efde 11-Jul-2014 Dave Allison <dallison@google.com> Revert "Revert "Revert "Revert "Add implicit null and stack checks for x86""""

This reverts commit 0025a86411145eb7cd4971f9234fc21c7b4aced1.

Bug: 16256184
Change-Id: Ie0760a0c293aa3b62e2885398a8c512b7a946a73
d9cb8ae2ed78f957a773af61759432d7a7bf78af 09-Jul-2014 Douglas Leung <douglas@mips.com> Fix art test failures for Mips.

This patch fixes the following art test failures for Mips:
003-omnibus-opcodes
030-bad-finalizer
041-narrowing
059-finalizer-throw

Change-Id: I4e0e9ff75f949c92059dd6b8d579450dc15f4467
Signed-off-by: Douglas Leung <douglas@mips.com>
22d5e735f403c57525fe868304c7123f0ce66399 16-Jul-2014 Ian Rogers <irogers@google.com> Remove object_utils.h.

Break into object_lock, field_helper and method_helper.
Clean up header files following this.
Also tidy some of the Handle code in response to compiler errors when resolving
the changes in this CL.

Change-Id: I73e63015a0f02a754d0866bfaf58208aebcaa295
e63db27db913f1a88e2095a1ee8239b2bb9124e8 16-Jul-2014 Ian Rogers <irogers@google.com> Break apart header files.

Create libart-gtest for common runtime and compiler gtest routines.
Rename CompilerCallbacksImpl that is quick compiler specific.
Rename trace clock source constants to not use the overloaded profiler term.

Change-Id: I4aac4bdc7e7850c68335f81e59a390133b54e933
7fb36ded9cd5b1d254b63b3091f35c1e6471b90e 10-Jul-2014 Dave Allison <dallison@google.com> Revert "Revert "Add implicit null and stack checks for x86""

Fixes x86_64 cross compile issue. Removes command line options
and property to set implicit checks - this is hard coded now.

This reverts commit 3d14eb620716e92c21c4d2c2d11a95be53319791.

Change-Id: I5404473b5aaf1a9c68b7181f5952cb174d93a90d
0025a86411145eb7cd4971f9234fc21c7b4aced1 11-Jul-2014 Nicolas Geoffray <ngeoffray@google.com> Revert "Revert "Revert "Add implicit null and stack checks for x86"""

Broke the build.

This reverts commit 7fb36ded9cd5b1d254b63b3091f35c1e6471b90e.

Change-Id: I9df0e7446ff0913a0e1276a558b2ccf6c8f4c949
8c1b5f71a8005743756206120624121d7678381f 10-Jul-2014 Ian Rogers <irogers@google.com> Missed use of android_atomic and thread state_.

Move to using art::Atomic, add necessary FetchAnd... operations to art::Atomic.

Change-Id: I32f1cdc4e0a2037b73f459bf4bb4d544f357f41b
34e826ccc80dc1cf7c4c045de6b7f8360d504ccf 29-May-2014 Dave Allison <dallison@google.com> Add implicit null and stack checks for x86

This adds compiler and runtime changes for x86
implicit checks. 32 bit only.

Both host and target are supported.
By default, on the host, the implicit checks are null pointer and
stack overflow. Suspend is implemented but not switched on.

Change-Id: I88a609e98d6bf32f283eaa4e6ec8bbf8dc1df78a
b8e087e0dfd619df90cbb56534478a60bc859ebf 10-Jul-2014 Ian Rogers <irogers@google.com> Move thread state to art::Atomic.

Leaves the CAS operations as relaxed although art::Atomic treats relaxed CAS
as a strong CAS when not compiling with clang.

Change-Id: I6d37c22173540d166b624385e52e4ad05e592adc
3d14eb620716e92c21c4d2c2d11a95be53319791 10-Jul-2014 Dave Allison <dallison@google.com> Revert "Add implicit null and stack checks for x86"

It breaks cross compilation with x86_64.

This reverts commit 34e826ccc80dc1cf7c4c045de6b7f8360d504ccf.

Change-Id: I34ba07821fc0a022fda33a7ae21850957bbec5e7
a9d8c4ce62fff49580fa70d3fcb3aee45344d8ca 08-Jul-2014 Ian Rogers <irogers@google.com> BaseMutex::IsExclusiveHeld should only be called on self.

Fix issue in Thread::DumpState of lock dumping calling IsExclusiveHeld on a
thread that isn't self causing intermittent crashes of ThreadStress oat test.

Bug: 15446488
Change-Id: I86924397a4e21ce10a95ea2a737d7bfbcb8ffe28
86797a791d692f81def5c1b5f0918992c49ed122 19-Jun-2014 Serban Constantinescu <serban.constantinescu@arm.com> AArch64: Add memcmp16() for Arm64; ensure xSELF not clobbered

This patch modifies memcmp() to memcmp16(). Please note that this
implementation of memcmp16() is based on the bionic's memcmp().

However, to reflect a recent specification change, the file has been
modified to respect the new String.compareTo() behavior.

A test for memcmp16() has been added. The string_compareto test in
stub_test has been changed to invoke __memcmp16 in assembly stubs.

Add artIsAssignableFromCode to the list of native downcalls to
store and reload x18. Remove CheckSuspendFromCode, as it is unused.

Signed-off-by: Serban Constantinescu <serban.constantinescu@arm.com>
Change-Id: Ie0b5425ecfb62906d29a5d02e84c7e07ffb34a11
eef2e54113ba10cd76ddc368b928a2864401700e 25-Jun-2014 Ian Rogers <irogers@google.com> Weaken condition to dump a thread's stack in a debug build.

If the current thread isn't suspended its also ok to dump the stack.
Bug: 14229281

Change-Id: I2810ea79bc4330bb6e9616436d74076b5997c20b
ea2e1bd713ca8295ba4fcd01e77a3ce532ea61e4 18-Jun-2014 Hiroshi Yamauchi <yamauchi@google.com> Add more read barriers for JNI roots.

To make it possible to concurrently scan the JNI global roots (that
is, the roots visited by JavaVMExt::VisitRoots()), add read barriers
to the indirect reference table and the reference table.

Also, add read barriers to the jmethodID/jfieldID decode routines
(ScopedObjectAccessAlreadyRunnable::DecodeField/DecodeMethod) so that
we can concurrently handle (encoded) fields and methods.

Bug: 12687968
Change-Id: I3df4e4e622a572ff0ea8d44b2dc70a4d6b3ba058
7cd26f355ba83be75b72ed628ed5ee84a3245c4f 19-Jun-2014 Andreas Gampe <agampe@google.com> ART: Target-dependent stack overflow, less check elision

Refactor the separate stack overflow reserved sizes from thread.h
into instruction_set.h and make sure they're used in the compiler.

Refactor the decision on when to elide stack overflow checks:
especially with large interpreter stack frames, it is not a good
idea to elide checks when the frame size is even close to the
reserved size. Currently enforce checks when the frame size is
>= 2KB, but make sure that frame sizes 1KB and below will elide
the checks (number from experience).

Bug: 15728765
Change-Id: I016bfd3d8218170cbccbd123ed5e2203db167c06
4d0589c90971e19c25894414ae7da579269e1fe2 11-Jun-2014 Andreas Gampe <agampe@google.com> ART: Move __memcmp16 from Bionic to ART

Handle __memcmp16 / MemCmp16 in ART. Import assembly implementations
for arm and mips from Bionic. Use a generic C version for all other
platforms.

Removes the memcmp16 quick entrypoint, as it is never used. Bump
the oat version and update thread.cc and checks to reflect the
structural change.

Change-Id: I54a5a1da2a0a43ef271c8aeda0bf2276b8b11ac6
c5f17732d8144491c642776b6b48c85dfadf4b52 06-Jun-2014 Ian Rogers <irogers@google.com> Remove deprecated WITH_HOST_DALVIK.

Bug: 13751317
Fix the Mac build:
- disable x86 selector removal that causes OS/X 10.9 kernel panics,
- madvise don't need does zero memory on the Mac, factor into MemMap
routine,
- switch to the elf.h in elfutils to avoid Linux kernel dependencies,
- we can't rely on exclusive_owner_ being available from other pthread
libraries so maintain our own when futexes aren't available (we
can't rely on the OS/X 10.8 hack any more),
- fix symbol naming in assembly code,
- work around C library differences,
- disable backtrace in DumpNativeStack to avoid a broken libbacktrace
dependency,
- disable main thread signal handling logic,
- align the stack in stub_test,
- use $(HOST_SHLIB_SUFFIX) rather than .so in host make file variables.

Not all host tests are passing on the Mac with this change. dex2oat
works as does running HelloWorld.
Change-Id: I5a232aedfb2028524d49daa6397a8e60f3ee40d3
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
bfd9a4378eacaf2dc2bbe05ad48c5164fc93c9fe 22-May-2014 Mathieu Chartier <mathieuc@google.com> Change MethodHelper to use a Handle.

Added ConstHandle to help prevent errors where you modify the value
stored in the handle of the caller. Also fixed compaction bugs
related to not knowing MethodHelper::GetReturnType can resolve types.
This bug was present in interpreter RETURN_OBJECT.

Bug: 13077697

Change-Id: I71f964d4d810ab4debda1a09bc968af8f3c874a3
9db911eb76976fc1c73c8e563beb3620f1cadf99 04-Jun-2014 Mathieu Chartier <mathieuc@google.com> Print mutexes held in Thread::Dump.

Should help finding and fixing thread suspend timeout issues.

Bug: 15328839
Change-Id: I30a10529cec0716c7571a0318e9f66be54734fd8
2a0d4ec9532a89abe722e5babdfbb846ffaad721 03-Jun-2014 Andreas Gampe <agampe@google.com> ART: Fix forbidden thread state change in interpreter

While loading a type for assignability, it might happen that it's
not available yet locally and must be resolved. Formerly, we
disallowed a state change to ensure no GC taking place while a new
shadow frame has not been pushed on the stack yet.

As a fix, allow a "shadow frame under construction" in the thread,
which is visited during GC.

Change-Id: I973487a46b0e9e21fd6d49099d713b58f06d3b45
ffddfdf6fec0b9d98a692e27242eecb15af5ead2 03-Jun-2014 Tim Murray <timmurray@google.com> DO NOT MERGE

Merge ART from AOSP to lmp-preview-dev.

Change-Id: I0f578733a4b8756fd780d4a052ad69b746f687a9
5cf98196d488437acd1e989c08a554ef697fded1 30-May-2014 Ian Rogers <irogers@google.com> Don't report down-calls as unhandled exceptions.

Bug: 15310540
Also, narrow scope of catch/deoptimize stack visitors that are specific to
quick exception delivery.

Change-Id: Ib13a006ce1347acb93a36b0186550d4c3ec2034b
cf4035a4c41ccfcc3e89a0cee25f5218a11b0705 29-May-2014 Andreas Gampe <agampe@google.com> ART: Use StackReference in Quick Stack Frame

The method reference at the bottom of a quick frame is a stack
reference and not a native pointer. This is important for 64b
architectures, where the notions do not coincide.

Change key methods to have StackReference<mirror::ArtMethod>*
parameter instead of mirror::ArtMethod**. Make changes to
invoke stubs for 64b archs, change the frame setup for JNI code
(both generic JNI and compilers), tie up loose ends.

Tested on x86 and x86-64 with host tests. On x86-64, tests succeed
with jni compiler activated. x86-64 QCG was not tested.

Tested on ARM32 with device tests.

Fix ARM64 not saving x19 (used for wSUSPEND) on upcalls.

Tested on ARM64 in interpreter-only + generic-jni mode.

Fix ARM64 JNI Compiler to work with the CL.

Tested on ARM64 in interpreter-only + jni compiler.

Change-Id: I77931a0cbadd04d163b3eb8d6f6a6f8740578f13
196851b634a5bfdd8ab3fb59a320e550b21b0f4d 29-May-2014 Hiroshi Yamauchi <yamauchi@google.com> Add read barriers for the weak roots in the JNI weak globals.

Bug: 12687968
Change-Id: Ic265a0e162e8cc9edc4ab7fa34f8afd5ce968d08
055c29fd0f752328981f1b7ccadb1862eecedd40 27-May-2014 buzbee <buzbee@google.com> Art compiler: remove unnecessary sqrt call

For reasons lost in the mists of time, the Dalvik JIT tested
the results of an inlined sqrt for NaN on Arm targets, and then
called an out-of-line routine to recompute if true. The Quick
compiler inherited this behavior. It is not necessary, and the CL
purges it (along with the out-of-line sqrt entrypoint).

Change-Id: I8c8fa6feacf9b7c3b9e190dfc6f728932fd948c6
4c1c510bea6f20f4d8b09e15547cd2967ad51c88 14-May-2014 Vladimir Marko <vmarko@google.com> Improve stack walk performance.

Move a few functions from art_method.cc to art_method-inl.h
and introduce new overloads that take already known partial
results; do not rely on the compiler to magically merge the
identical but non-trivial paths. The partial results are
DCHECKed to be correct.

Change-Id: I342c3001bbff08a2bbbb9a7b62ae67188ad8cffc
700a402244a1a423da4f3ba8032459f4b65fa18f 20-May-2014 Ian Rogers <irogers@google.com> Now we have a proper C++ library, use std::unique_ptr.

Also remove the Android.libcxx.mk and other bits of stlport compatibility
mechanics.

Change-Id: Icdf7188ba3c79cdf5617672c1cfd0a68ae596a61
2b7c4d196c8abe32f4ca633534917da9de53c359 19-May-2014 Mathieu Chartier <mathieuc@google.com> Don't get and restore thread state for ScopedFastNativeObjectAccess.

Before we would ensure that we were runnable for fast native object
access. However, these are done when you are already runnable.

Change-Id: Ia4c6e4c83d146fe2a988b37b3133ca46b0f0fa42
92d1a666534aa98b173bb33dc5dba86b2d48aedb 16-May-2014 Hiroshi Yamauchi <yamauchi@google.com> Visit methods in stack frames during root visits.

This is necessary for a Baker-style read barrier to-space invariant to
hold. That is, an object either needs to be marked/forwarded as root
or it must be accessed only through a read barrier by mutators. Since
stack frames have direct pointers to methods that a mutator can access
without a read barrier, stack frame methods have to be visited as
root, which makes sense as stack frames are thread roots. This is the
case even if methods do not move as they have to be marked 'gray' for
the objects pointed to by them, which can move, to be recursively
marked/forwarded.

This also puts us in the right direction toward moving methods (and
fields) in the future.

Bug: 12687968
Change-Id: Id32b913c021a140073deea9149a8782e8f308303
db2633ce0358c704f97130a94b582602cb01d14a 16-May-2014 Mathieu Chartier <mathieuc@google.com> Change ObjectLock to take Handle instead of Handle pointer.

Change-Id: I9abdcdc5c9c9174634336b9250ab24c6aee434ec
eb8167a4f4d27fce0530f6724ab8032610cd146b 08-May-2014 Mathieu Chartier <mathieuc@google.com> Add Handle/HandleScope and delete SirtRef.

Delete SirtRef and replaced it with Handle. Handles are value types
which wrap around StackReference*.

Renamed StackIndirectReferenceTable to HandleScope.

Added a scoped handle wrapper which wraps around an Object** and
restores it in its destructor.

Renamed Handle::get -> Get.

Bug: 8473721

Change-Id: Idbfebd4f35af629f0f43931b7c5184b334822c7a
7624d25dad2d1ba25969ae704fccf68649103ae5 02-May-2014 Vladimir Marko <vmarko@google.com> Move quick frame info to OatQuickMethodHeader.

Rename OatMethodHeader to OatQuickMethodHeader, move frame
info from OatMethodOffsets to OatQuickMethodHeader. Retrieve
the info from other places for non-quick methods (portable
compiled bytecode or jni stub, generic jni, runtime,
abstract and proxy).

This change has a libcore/ companion CL
"Remove ArtMethod's quick fields for frame size and spills."
https://android-review.googlesource.com/94164

Bug: 11767815
Change-Id: I0e31a7875d76732e1ec479c86b9b5ca01203507f
c56057e40938c587a74984651a510e320a8cb4fd 04-May-2014 Mathieu Chartier <mathieuc@google.com> Add lockless SynchronizedGet for indirect reference table.

Used for decoding global references without holding locks.

Results on JniCallback:
Before: 615ms (3 samples).
After: 585ms (3 samples).

Change-Id: Ifcac8d0359cf658d87f695c6eb869d148af002e5
5cd33753b96d92c03e3cb10cb802e68fb6ef2f21 16-Apr-2014 Dave Allison <dallison@google.com> Handle implicit stack overflow without affecting stack walks

This changes the way in which implicit stack overflows are handled
to satisfy concerns about changes to the stack walk code.

Instead of creating a gap in the stack and checking for it in
the stack walker, use the ManagedStack infrastructure to concoct
an invisible gap that will never be seen by a stack walk.

Also, this uses madvise to tell the kernel that the main stack's
protected region will probably never be accessed, and instead
of using memset to map the pages in, use memcpy to read from
them. This will save 32K on the main stack.

Also adds a 'signals' verbosity level as per a review request.

Bug: 14066862
Change-Id: I5257305feeaea241d11e6aa6f021d2a81da20b81
c45b8b582be5c98941ca3869fcdc9a08d520da41 03-May-2014 Ian Rogers <irogers@google.com> Create stack traces in unstarted runtimes.

Use to diagnose failed initialization in dex2oat of boot (-verbose:compiler).
Fix identity hashCode, ArtMethod.getMethodName, IntegralToString.convertInt and
use of Void when called from a unstarted runtime.

Change-Id: I2d536174b59e2e5f19519f93fc6b5916652fb6cd
0651d41e41341fb2e9ef3ee41dc1f1bfc832dbbb 29-Apr-2014 Mathieu Chartier <mathieuc@google.com> Add thread unsafe allocation methods to spaces.

Used by SS/GSS collectors since these run with mutators suspended and
only allocate from a single thread. Added AllocThreadUnsafe to
BumpPointerSpace and RosAllocSpace. Added AllocThreadUnsafe which uses
current runs as thread local runs for a thread unsafe allocation.
Added code to revoke current runs which are the same idx as thread
local runs.

Changed:
The number of thread local runs in each thread is now the the number
of thread local runs in RosAlloc instead of the number of size
brackets.

Total GC time / time on EvaluateAndApplyChanges.
TLAB SS:
Before: 36.7s / 7254
After: 16.1s / 4837

TLAB GSS:
Before: 6.9s / 3973
After: 5.7s / 3778

Bug: 8981901

Change-Id: Id1d264ade3799f431bf7ebbdcca6146aefbeb632
b0fa5dc7769c1e054032f39de0a3f6d6dd06f8cf 29-Apr-2014 Ian Rogers <irogers@google.com> Force inlining on trivial accessors.

Make volatility for GetFieldObject a template parameter.
Move some trivial mirror::String routines to a -inl.h.

Bug: 14285442

Change-Id: Ie23b11d4f18cb15a62c3bbb42837a8aaf6b68f92
714f175bd66d03225927a84f3d5dbc923c5a3e7e 28-Apr-2014 Sebastien Hertz <shertz@google.com> Visit deoptimized shadow frames as roots

During deoptimization, we create shadow frames but do not attach them to the
stack until we transition to interpreter mode. If a GC happens before that,
these shadow frames are not visited by GC so they may contain stale references.

This CL addresses this issue by visiting the shadow frames "under contruction"
in Thread::VisitRoots so we correctly update all references they hold.

To make them visible, we now save the top shadow frame (the first one created)
in the field Thread::tls_ptr_sized_values::deoptimization_shadow_frame. This
field will then be cleared when transitioning to interpreter mode.

Bug: 14324885
Change-Id: Ib213ddc80f19cfcdfcec6f20acaa7f1a0e9ce2c1
73d1e17b3afc7d5e56184f90bf819dc64956448a 12-Apr-2014 Mathieu Chartier <mathieuc@google.com> Enable reading page map without lock in RosAlloc::BulkFree

Enabling this flag greatly reduces how much time was spent in the GC.
It was not done previously since it was regressing MemAllocTest. With
these RosAlloc changes, the benchmark score no longer regresses after
we enable the flag.

Changed Run::AllocSlot to only have one mode of allocation. The new
mode is finding the first free bit in the bitmap. This was
previously the slow path but is now the fast path. Some optimizations
which enabled this include always having the alloc bitmap bits which
correspond to invalid slots be set to 1. This prevents us from needing
a bound check since we will never end up allocating there.

Changed revoking thread local buffer to point to an invalid run. The
invalid run is just a run which always has all the allocation bits set
to 1. When a thread attempts to do a thread local allocation from here
it will always fail and go slow path. This eliminates the need for a
null check for revoked runs.

Changed zeroing of memory to happen during free, AllocPages should
always return zeroed memory. Added prefetching which happens when we
allocate a run.

Some refactoring to reduce duplicated code.

Ergonomics changes: Changed kStickyGcThroughputAdjustment to 1.0,
this helps reduce GC time.

Measurements (3 samples per benchmark):
Before: MemAllocTest scores: 3463, 3445, 3431
EvaluateAndApplyChanges score | total GC time
Iter 1: 3485, 23.602436s
Iter 2: 3434, 22.499882s
Iter 3: 3483, 23.253274s

After: MemAllocTest scores: 3495, 3417, 3409
EvaluateAndApplyChanges score | total GC time:
Iter 1: 3375, 17.463462s
Iter 2: 3358, 16.185188s
Iter 3: 3367, 15.822312s

Bug: 8788501
Bug: 11790317
Bug: 9986565
Change-Id: Ifd273a054824028dabed27c07c081dde1816f93c
fd3077e4b9ebadd281777310d26e64443858f653 23-Apr-2014 Sebastien Hertz <shertz@google.com> Refactor exception handling for deoptimization

This CL refactors the exception handling (on the quick side) by isolating the
search of catch handler and the preparation of deoptimization.

We rename the CatchFinder class to QuickExceptionHandler so it's less specific
to catch handler search.

Finding catch handler happens in QuickExceptionHandler::FindCatch. Since the
CatchBlockStackVisitor resolves exception types, it may cause thread suspension
and breaks the assertion current thread can't be suspended. Therefore, we place
the exception in a SirtRef (while it is detached from the current thread) and
remove the thread suspension assertion.

Deoptimization now happens in QuickExceptionHandler::DeoptimizeStack. It uses
the new DeoptimizeStackVisitor class to create shadow frames.

We also add the Thread::GetDeoptimizationException method to get the definition
of the fake exception in only one place.

Change-Id: I01b19fa72af64329b5c3b6c7f0c3339d2d724978
987560fee798e48fb725c44b796d8ca7a5872ad6 22-Apr-2014 Ian Rogers <irogers@google.com> Remove support for app JNI workarounds.

Change-Id: I4396df7e93fcace4b5b19c2c387e5c30089182a6
a2cee18799d7e61adb037a4219adb23fef7d022b 17-Apr-2014 Christopher Ferris <cferris@google.com> Modify unwind to comply with stack parser tools.

Bug: 14081592

Change-Id: I6906b2575c74d64f1c3ba7602779b3a789de1c69
4d7f61d44a732cfbc8573e5d93364983fd746888 17-Apr-2014 Mathieu Chartier <mathieuc@google.com> Use non volatile lock words in semispace collector.

GSS FormulaEvaluationActions.EvaluateAndApplyChanges:
Before GC time: 9.1s
After GC time: 7.98s

Fixed timing logger errors.

Change-Id: I4193c6ccbbbe7a7220dfaabbf3472a5dcebae616
63e8a68c9a2cdbbe9bfd8d200610119dd359ee59 16-Apr-2014 Yevgeny Rouban <yevgeny.y.rouban@intel.com> Fix thread join hangs

Current implementation notifies only one of joining threads on thread exit.
This causes the other joining threads to hang.

This patch notifies all joining threads: just call NotifyAll() instead of Notify().

Change-Id: If75f101d3d3d876f1aa7dcf537e56a37cc347803
Signed-off-by: Yevgeny Rouban <yevgeny.y.rouban@intel.com>
c7a966dbba6902618ff0959d604c05d7570df8c8 11-Apr-2014 Mathieu Chartier <mathieuc@google.com> Prevent deadlocks in Runtime::Abort.

If we have the threads suspended, attempting to use a
ScopedObjectAccess causes a deadlock. We now specifically avoid this
to prevent deadlocks.

Bug: 13747880
Change-Id: I45fd3fff917da98b22970e5351a9e25b143a4eed
43d8bb870fadd4775a8513a1df955cdf66ad4b92 03-Apr-2014 Mathieu Chartier <mathieuc@google.com> Add monitor_enter_object as root.

The monitor enter object was not a root, this caused issues with
compactions since the object could move and then verify object would
fail.

Bug: 13769139
Change-Id: Ia732376fb9d1de8bf137ef9894cb2bb3241d8bb2
2966e13d504a72d55c62bf864e183ec80703c699 02-Apr-2014 Ian Rogers <irogers@google.com> Avoid debug check violation in thread registration.

Bug: 13757855
Change-Id: Ied83a7fc43e2b9a89a8b99aa4f74069ef8a369b1
ee1d79a603c77c0667b27c075a983579d5c51f7e 21-Feb-2014 Sebastien Hertz <shertz@google.com> Cleanup transaction support

Updates Thread::CreateInternalStackTrace to support both transactional and
non-transactional modes using template.

Generalizes non-transactional mode for invariant fields (which are set only
once).

Removes ArrayLog::VisitRoots as we never create Array logs of ObjectArray. As
ObjectArray elements are set using Object::SetFieldObject, they are already
recorded in the object logs: the object is the array itself and the offset
corresponds to the element index in this array. And also checks we never log
ObjectArray in array logs.

Fixes location of thrown exception when calling native method during class
initialization.

Change-Id: Idbc368d3b8292b85ff40bc8a7c559e085477bf89
d803bc7ce255be6c16eaf6a8a58a742515e9da9f 02-Apr-2014 Ian Rogers <irogers@google.com> Fix ThreadStress, unify ANR lock descriptions.

Bug: 13323656
Change-Id: I902825a847af9aa570ed79701409298e3532bebf
c751fdcc9491c1b60c3db517fbc41bb98e92441f 31-Mar-2014 Mathieu Chartier <mathieuc@google.com> Add handler for printing java stack traces for compiled code SIGSEGV.

Added a new FaultHandler which attempts to print a java stack trace
when a SIGSEGV occurse in generated code. This should help debugging
compiler and GC related heap corruption.

Bug: 13725693
Bug: 12934910

Change-Id: Id54d83ea180c222eb86d449c61926e83f0b026ad
dd7624d2b9e599d57762d12031b10b89defc9807 15-Mar-2014 Ian Rogers <irogers@google.com> Allow mixing of thread offsets between 32 and 64bit architectures.

Begin a more full implementation x86-64 REX prefixes.
Doesn't implement 64bit thread offset support for the JNI compiler.

Change-Id: If9af2f08a1833c21ddb4b4077f9b03add1a05147
f943914730db8ad2ff03d49a2cacd31885d08fd7 27-Mar-2014 Dave Allison <dallison@google.com> Implement implicit stack overflow checks

This also fixes some failing run tests due to missing
null pointer markers.

The implementation of the implicit stack overflow checks introduces
the ability to have a gap in the stack that is skipped during
stack walk backs. This gap is protected against read/write and
is used to trigger a SIGSEGV at function entry if the stack
will overflow.

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

Bug: 13634574
Change-Id: I2a76f6c43f1d0ad1922f06deb40a71ff651129fd
d5e4ac0abdeeb4dc13bd05a40bf496299a787536 01-Feb-2014 Brian Carlstrom <bdc@google.com> Properly tolerate missing declaring source files

Broken in 228d6b8a4f0a21c1e9b2372c3104ce4ee19f65b4

(cherry picked from commit 7c6aca27dd2df58ac3d83a93ec5848e2b7d3159a)

Bug: 13575571
Bug: 12802375
Change-Id: Ia8a3196b15f8ed29810d0b6f09f81c7ae4e7480e
c93c530efc175954160c3834c93961a1a946a35a 21-Mar-2014 Hiroshi Yamauchi <yamauchi@google.com> Revoke rosalloc thread-local buffers at the checkpoint.

In the mark sweep collector, rosalloc thread-local buffers were
revoked during the pause. Now, they are revoked at the thread
checkpoint, as opposed to during the pause, which appears to help
reduce the pause time.

In Ritz MemAllocTest, the average sticky pause time went down ~20%
(925 us -> 724 us).

Bug: 13394464
Bug: 9986565
Change-Id: I104992a11b46d59264c0b9aa2db82b1ccf2826bc
88e46a35b4b898ec2032348a185d2b0b812b6ad9 14-Mar-2014 Ian Rogers <irogers@google.com> Remove unused variable and tidy test #includes.

Change-Id: I0eaeea0d50f66302d632aab400cfa48dc301ef69
53b8b09fc80329539585dcf43657bc5f4ecefdff 14-Mar-2014 Ian Rogers <irogers@google.com> Refactor reflective method invocation.

Move invocation code out of JNI internal into reflection, including ArgArray
code. Make reflective invocation use the ArgArray to build arguments rather
than allocating a jvalue[] and unboxing arguments into that.
Move reflection part of jni_internal_test into reflection_test.
Make greater use of fast JNI.

Change-Id: Ib381372df5f9a83679e30e7275de24fa0e6b1057
b373e091eac39b1a79c11f2dcbd610af01e9e8a9 21-Feb-2014 Dave Allison <dallison@google.com> Implicit null/suspend checks (oat version bump)

This adds the ability to use SEGV signals
to throw NullPointerException exceptions from Java code rather
than having the compiler generate explicit comparisons and
branches. It does this by using sigaction to trap SIGSEGV and when triggered
makes sure it's in compiled code and if so, sets the return
address to the entry point to throw the exception.

It also uses this signal mechanism to determine whether to check
for thread suspension. Instead of the compiler generating calls
to a function to check for threads being suspended, the compiler
will now load indirect via an address in the TLS area. To trigger
a suspend, the contents of this address are changed from something
valid to 0. A SIGSEGV will occur and the handler will check
for a valid instruction pattern before invoking the thread
suspension check code.

If a user program taps SIGSEGV it will prevent our signal handler
working. This will cause a failure in the runtime.

There are two signal handlers at present. You can control them
individually using the flags -implicit-checks: on the runtime
command line. This takes a string parameter, a comma
separated set of strings. Each can be one of:

none switch off
null null pointer checks
suspend suspend checks
all all checks

So to switch only suspend checks on, pass:
-implicit-checks:suspend

There is also -explicit-checks to provide the reverse once
we change the default.

For dalvikvm, pass --runtime-arg -implicit-checks:foo,bar

The default is -implicit-checks:none

There is also a property 'dalvik.vm.implicit_checks' whose value is the same
string as the command option. The default is 'none'. For example to switch on
null checks using the option:

setprop dalvik.vm.implicit_checks null

It only works for ARM right now.

Bumps OAT version number due to change to Thread offsets.

Bug: 13121132
Change-Id: If743849138162f3c7c44a523247e413785677370
0f6784737882199197796b67b99e5f1ded383bee 11-Mar-2014 Ian Rogers <irogers@google.com> Unify 64bit int constant definitions.

LL and ULL prefixes are word size dependent, use the INT64_C and UINT64_C
macros instead.

Change-Id: I5b70027651898814fc0b3e9e22a18a1047e76cb9
0c6afa40af7b9f097131126d084d5f19c2accaac 19-Dec-2013 Mathieu Chartier <mathieuc@google.com> Fix NewLocalRef, NewGlobalRef to handle cleared weak globals.

We were not checking for null after decoding the reference, this
meant that we incorrectly created null weak global references instead
of returning null.

Issue: 63929
Bug: 13400455

(cherry-picked from e8c48db6bb507d7fa20c78481c58c23be0045f67)

Change-Id: I9159682e6edad8f415ef8144fc13b9aedd2cceb4
e0dcd46314d07eeb332edea292f5110178e4e3d2 09-Mar-2014 Ian Rogers <irogers@google.com> JNI down call fixes.

Ensure SIRT isn't accessed via quick callee save frame.
Some tidying of code.

Change-Id: I8fec3e89aa6d2e86789c60a07550db2e92478ca7
c645f1ddb7c40bea6a38eda4b3f83f6b6dec405b 07-Mar-2014 Mathieu Chartier <mathieuc@google.com> Add more VerifyObject calls.

Added verify object calls to SirtRef, IndirectReferenceTable,
ReferenceTable.

Removed un-needed verify object in ScopedObjectAccess / DecodeJObject
since object sources are handled.

Bug: 12934910
Change-Id: I55a46a8ea61fed2a77526eda27fd2cce97a9b125
067d20fd2fddd947ce3a014d023e9de249082ebe 05-Mar-2014 Kenny Root <kroot@google.com> backtrace: use Java stack to help decode native

Before change:

native: usb_host_run+16 [0x400a43f9] (/libusbhost.so)
native: android::Vector<int>::do_move_forward(void*, void const*, unsigned int) const+54 [0x501b1c5b] (/libandroid_servers.so)
native: ??? [0x624de480] (/system@framework@boot.oat)
at com.android.server.usb.UsbHostManager.monitorUsbHostBus(Native method)
at com.android.server.usb.UsbHostManager.access$000(UsbHostManager.java:38)

After change:

native: usb_host_run+16 [0x400933f9] (libusbhost.so)
native: android::Vector<int>::do_move_forward(void*, void const*, unsigned int) const+54 [0x4e984c5b] (libandroid_servers.so)
native: Java_com_android_server_usb_UsbHostManager_monitorUsbHostBus__+92 [0x624de480] (system@framework@boot.oat)
at com.android.server.usb.UsbHostManager.monitorUsbHostBus(Native method)
at com.android.server.usb.UsbHostManager.access$000(UsbHostManager.java:38)

Change-Id: Iea550a251a12e9ba7df9582fd454093bfa4e90e0
6dda898d47b3e8931e4404330e81b7110108e34f 06-Mar-2014 Mathieu Chartier <mathieuc@google.com> Disable compaction for jni workarounds.

Compaction can't work when jni workarounds is enabled. Also some
other refactoring.

Change-Id: Ia7b0f2b39c79f5a0a5f50874d823b950ab02a0c3
6cbd271d061707dfe70e29c16bb97b6acbd3c533 05-Mar-2014 Ian Rogers <irogers@google.com> Oatdump fix.

Change-Id: Idd4fe294a628efb2a3bd39061a61bab3017784a2
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
2da882315a61072664f7ce3c212307342e907207 27-Feb-2014 Andreas Gampe <agampe@google.com> Initial changes towards Generic JNI option

Some initial changes that lead to an UNIMPLEMENTED. Works
by not compiling for JNI right now and tracking native methods
which have neither quick nor portable code. Uses new trampoline.

Change-Id: I5448654044eb2717752fd7359f4ef8bd5c17be6e
8d7672e476a526aa6205a008b5a06c8216342ac6 25-Feb-2014 Mathieu Chartier <mathieuc@google.com> Print message when throwing new exception with pending exception.

Useful to see what the new exception is.

Bug: 12957138
Change-Id: I751b3a9b0b5d57d72f15d3ed7fa746a1991b181c
9837939678bb5dcba178e5fb00ed59b5d14c8d9b 25-Feb-2014 Ian Rogers <irogers@google.com> Avoid std::string allocations for finding an array class.

Introduce ClassLinker::FindArrayClass which performs an array class lookup
given the element/component class. This has a 16 element cache of recently
looked up arrays.
Pass the current thread to ClassLinker Find .. Class routines to avoid calls
to Thread::Current().
Avoid some uses of FindClass in the debugger where WellKnownClasses is a
faster and more compacting GC friendly alternative.

Change-Id: I60e231820b349543a7edb3ceb9cf1ce92db3c843
3addc29228cb3a2d263e1d91a0b7d4e0fe26e246 04-Dec-2013 Jeff Hao <jeffhao@google.com> Fix stack trace for proxy methods and added test case.

Bug: 11861564

Change-Id: I9513359ff9e5d345ee71d84388afed02bd114ecf
(cherry picked from 228d6b8a4f0a21c1e9b2372c3104ce4ee19f65b4)
4e30541a92381fb280cd0be9a1763b713ee4d64c 19-Feb-2014 Mathieu Chartier <mathieuc@google.com> Fix and optimize verify object.

VerifyObject no longer resides in heap. You can now enable
VerifyObject for non-debug builds. VerifyStack is still slow, so it
is now guarded by its own flag.

Fixed the image writer to not use verification at places where
verification fails due to invalid reads.

Fixed RosAlloc to use SizeOf which doesn't call verify object.

Added a flag paremeter to some of the mirror getters / setters to
be able to selectively disable VerifyObject on certain calls.

Optimized the GC to not verify each object multiple times during
object scanning if verify object is enabled.

Added 3 verification options: verify reads, verify this, and verify
writes so that you can select how much verification you want for
mirror getters and setters.

Removed some useless DCHECKs which would slow debug builds without
providing any benefits.

TODO: RosAlloc verification doesn't currently work with verify
objects.

Bug: 12934910
Bug: 12879358

Change-Id: Ic61033104dfc334543f89b0fc0ad8cd4f4015d69
815873ecc312b1d231acce71e1a16f42cdaf09f2 14-Feb-2014 Mathieu Chartier <mathieuc@google.com> Change root visitor to use Object**.

Simplifies code and improves the performance of root visiting since
we usually don't need to check to see if the object moved.

Change-Id: Iba998f5a15ae1fa1b53ca5226dd2168a411196cf
d2fe10a3a34af171bf1631219cd2d6ff6b7778b5 15-Jan-2014 Sebastien Hertz <shertz@google.com> Remove blacklist

Removes the class initialization blacklist and use transaction to detect and
revert class initialization attempting to invoke native method. This only
concerns class initialization happening at compilation time when generating an
image (like boot.art for the system).

In transactional mode, we log every object's field assignment and array update.
Therefore we're able to abort a transaction to restore values of fields and
array as they were before the transaction starts. We also log changes to the
intern string table so we can restore its state prior to transaction start.

Since transactional mode only happens at compilation time, we don't need to log
all these changes at runtime. In order to reduce the overhead of testing if
transactional mode is on/off, we templatize interfaces of mirror::Object and
mirror::Array, respectively responsible for setting a field and setting an
array element.

For various reasons, we skip some specific fields from transaction:
- Object's class and array's length must remain unchanged so garbage collector
can compute object's size.
- Immutable fields only set during class loading: list of fields, method,
dex caches, vtables, ... as all classes have been loaded and verified before a
transaction occurs.
- Object's monitor for performance reason.

Before generating the image, we browse the heap to collect objects that need to
be written into it. Since the heap may still holds references to unreachable
objects due to aborted transactions, we trigger one collection at the end of
the class preinitialization phase.

Since the transaction is held by the runtime and all compilation threads share
the same runtime, we need to ensure only one compilation thread has exclusive
access to the runtime. To workaround this issue, we force class initialization
phase to run with only one thread. Note this is only done when generating image
so application compilation is not impacted. This issue will be addressed in a
separate CL.

Bug: 9676614
Change-Id: I221910a9183a5ba6c2b99a277f5a5a68bc69b5f9
f5b0e20b5b31f5f5465784adcf2a204dcd69c7fd 12-Feb-2014 Hiroshi Yamauchi <yamauchi@google.com> Thread-local allocation stack.

With this change, Ritz MemAllocTest gets ~14% faster on N4.

Bug: 9986565
Change-Id: I2fb7d6f7c5daa63dd4fc73ba739e6ae4ed820617
89bb1449bbef1863b12dfa3813ab7c78be94316f 12-Feb-2014 Mathieu Chartier <mathieuc@google.com> Fix wrong thread id being passed to SIRT roots.

Fixes jhat on hprof dumps.

Change-Id: I1a71eb3370606129fb5cf791ab582f34052a9f35
0177e53ea521ad58b70c305700dab32f1ac773b7 12-Feb-2014 Ian Rogers <irogers@google.com> Work in the direction of hard float quick ABIs.

Pass a shorty to ArtMethod::Invoke so that register setup can use it.
Document x86-64 ABI.
Add extra debug output for one JNI native method registration fails, namely a
dump of the Class and its dex file's location.
Add hack to get testing of OatMethod's without GC maps working in 64bit.

Change-Id: Ic06b68e18eac33637df2caf5e7e775ff95ae70f3
83c8ee000d525017ead8753fce6bc1020249b96a 28-Jan-2014 Mathieu Chartier <mathieuc@google.com> Add root types and thread id to root visiting.

Enables us to pass the root type and thread id to hprof.

Bug: 12680863
Change-Id: I6a0f1f9e3aa8f9b4033d695818ae7ca3460d67cb
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
1efa0a9d6cd5f5b40b8a21d39f1103a3610250ee 03-Feb-2014 Alexei Zavjalov <alexei.zavjalov@intel.com> ART can't create more than 8k threads during the worktime

ART uses LDT to point to the Java Thread structure. This structure
can holds up to 8k pointers, so we can have 8k threads simultaneously.
But the current implementation does not free slots for the finished threads.
This means there cannot be more than 8k threads created during the whole
life cycle.
This patch implements the LDT slots freeing mechanism.

Change-Id: Ifcf8fe1f4434a13f940146fff39b9c7bf91ee17b
Signed-off-by: Alexei Zavjalov <alexei.zavjalov@intel.com>
7c6aca27dd2df58ac3d83a93ec5848e2b7d3159a 01-Feb-2014 Brian Carlstrom <bdc@google.com> Properly tolerate missing declaring source files

Broken in 228d6b8a4f0a21c1e9b2372c3104ce4ee19f65b4

Bug: 12802375
Change-Id: I60eeefeb3aff3e0a9f143791cf772e531a68d16a
bb8f0ab736b61db8f543e433859272e83f96ee9b 28-Jan-2014 Hiroshi Yamauchi <yamauchi@google.com> Embed array class pointers at array allocation sites.

Following https://android-review.googlesource.com/#/c/79302, embed
array class pointers at array allocation sites in the compiled code.

Change-Id: I67a1292466dfbb7f48e746e5060e992dd93525c5
be1ca55db3362f5b100c4c65da5342fd299520bb 15-Jan-2014 Hiroshi Yamauchi <yamauchi@google.com> Use direct class pointers at allocation sites in the compiled code.

- Rather than looking up a class from its type ID (and checking if
it's resolved/initialized, resolving/initializing if not), use
direct class pointers, if possible (boot-code-to-boot-class pointers
and app-code-to-boot-class pointers.)
- This results in a 1-2% speedup in Ritz MemAllocTest on Nexus 4.
- Embedding the object size (along with class pointers) caused a 1-2%
slowdown in MemAllocTest and isn't implemented in this change.
- TODO: do the same for array allocations.
- TODO: when/if an application gets its own image, implement
app-code-to-app-class pointers.
- Fix a -XX:gc bug.
cf. https://android-review.googlesource.com/79460/
- Add /tmp/android-data/dalvik-cache to the list of locations to
remove oat files in clean-oat-host.
cf. https://android-review.googlesource.com/79550
- Add back a dropped UNLIKELY in FindMethodFromCode().
cf. https://android-review.googlesource.com/74205

Bug: 9986565
Change-Id: I590b96bd21f7a7472f88e36752e675547559a5b1
d45a1f5d1dd5bc9badfab3a8aee90c934d9f2227 09-Jan-2014 Sebastien Hertz <shertz@google.com> Avoid instrumentation stack corruption.

While debugging a throwing exception, we may end up updating instrumentation
stack frame after having already walked the native stack. This leads to not pop
instrumentation frames prior to catch handler (or upcall if exception is not
caught) and get it desynchronized with the native stack.

To solve this issue, we need to walk the stack again after having reporting the
exception to the instrumentation listener (for example: the debugger) which
may push new instrumentation stack frames. However we do it only when we know
instrumentation is enabled to not slow down exception delivery when executing
code without instrumentation.

Here are the main changes:
- Creates InstrumentationStackVisitor to compute the number of instrumentation
frames to pop (previously done in CatchBlockStackVisitor). We only count frames
prior to catch handler (or upcall). Popping instrumentation frames is done
after having reported the exception to the instrumentation listener.
- Updates the CatchBlockStackVisitor to remove instrumentation frame handling
and focus only on finding the catch handler and prepare deoptimization.
- Creates CatchFinder class to control both visitors and do the long jump.

Change-Id: I29b3871403f297bfb8c087e27f1330b002f5d56d
e6da9af8dfe0a3e3fbc2be700554f6478380e7b9 16-Dec-2013 Mathieu Chartier <mathieuc@google.com> Background compaction support.

When the process state changes to a state which does not perceives
jank, we copy from the main free-list backed allocation space to
the bump pointer space and enable the semispace allocator.

When we transition back to foreground, we copy back to a free-list
backed space.

Create a seperate non-moving space which only holds non-movable
objects. This enables us to quickly wipe the current alloc space
(DlMalloc / RosAlloc) when we transition to background.

Added multiple alloc space support to the sticky mark sweep GC.

Added a -XX:BackgroundGC option which lets you specify
which GC to use for background apps. Passing in
-XX:BackgroundGC=SS makes the heap compact the heap for apps which
do not perceive jank.

Results:
Simple background foreground test:
0. Reboot phone, unlock.
1. Open browser, click on home.
2. Open calculator, click on home.
3. Open calendar, click on home.
4. Open camera, click on home.
5. Open clock, click on home.
6. adb shell dumpsys meminfo

PSS Normal ART:
Sample 1:
88468 kB: Dalvik
3188 kB: Dalvik Other
Sample 2:
81125 kB: Dalvik
3080 kB: Dalvik Other

PSS Dalvik:
Total PSS by category:
Sample 1:
81033 kB: Dalvik
27787 kB: Dalvik Other
Sample 2:
81901 kB: Dalvik
28869 kB: Dalvik Other

PSS ART + Background Compaction:
Sample 1:
71014 kB: Dalvik
1412 kB: Dalvik Other
Sample 2:
73859 kB: Dalvik
1400 kB: Dalvik Other

Dalvik other reduction can be explained by less deep allocation
stacks / less live bitmaps / less dirty cards.

TODO improvements: Recycle mem-maps which are unused in the current
state. Not hardcode 64 MB capacity of non movable space (avoid
returning linear alloc nightmares). Figure out ways to deal with low
virtual address memory problems.

Bug: 8981901

Change-Id: Ib235d03f45548ffc08a06b8ae57bf5bada49d6f3
0aded089f565008ba5908e395e5914ca4f91f2de 07-Nov-2013 Dave Allison <dallison@google.com> Add sampling profiler

This adds a sampling profiler thread that runs every so often, gathering
profiling data and writing the results to a file in /data/data (specific to
app running). The intention is to use these files as input to the compiler
so that it can determine the best methods to compile.

Bug: 11539952
Change-Id: I0bfbb4146fb7966673c792f017ffac8107b6272d
e8c48db6bb507d7fa20c78481c58c23be0045f67 19-Dec-2013 Mathieu Chartier <mathieuc@google.com> Fix NewLocalRef, NewGlobalRef to handle cleared weak globals.

We were not checking for null after decoding the reference, this
meant that we incorrectly created null weak global references instead
of returning null.

Issue: 63929
Change-Id: I9159682e6edad8f415ef8144fc13b9aedd2cceb4
692fafd9778141fa6ef0048c9569abd7ee0253bf 30-Nov-2013 Mathieu Chartier <mathieuc@google.com> Thread local bump pointer allocator.

Added a thread local allocator to the heap, each thread has three
pointers which specify the thread local buffer: start, cur, and
end. When the remaining space in the thread local buffer isn't large
enough for the allocation, the allocator allocates a new thread
local buffer using the bump pointer allocator.

The bump pointer space had to be modified to accomodate thread
local buffers. These buffers are called "blocks", where a block
is a buffer which contains a set of adjacent objects. Blocks
aren't necessarily full and may have wasted memory towards the
end. Blocks have an 8 byte header which specifies their size and is
required for traversing bump pointer spaces.

Memory usage is in between full bump pointer and ROSAlloc since
madvised memory limits wasted ram to an average of 1/2 page per
block.

Added a runtime option -XX:UseTLAB which specifies whether or
not to use the thread local allocator. Its a NOP if the garbage
collector is not the semispace collector.

TODO: Smarter block accounting to prevent us reading objects until
we either hit the end of the block or GetClass() == null which
signifies that the block isn't 100% full. This would provide a
slight speedup to BumpPointerSpace::Walk.

Timings: -XX:HeapMinFree=4m -XX:HeapMaxFree=8m -Xmx48m
ritzperf memalloc:
Dalvik -Xgc:concurrent: 11678
Dalvik -Xgc:noconcurrent: 6697
-Xgc:MS: 5978
-Xgc:SS: 4271
-Xgc:CMS: 4150
-Xgc:SS -XX:UseTLAB: 3255

Bug: 9986565
Bug: 12042213

Change-Id: Ib7e1d4b199a8199f3b1de94b0a7b6e1730689cad
c528dba35b5faece51ca658fc008b688f8b690ad 26-Nov-2013 Mathieu Chartier <mathieuc@google.com> Enable moving classes.

Slight reduction in Zygote size, memory savings are in the noise.
Before: Zygote size: 8739224
After: Zygote size: 8733568

Fixed a bug where we didn't set the concurrent start bytes after
switching the allocator from bump pointer to ROSAlloc in the
zygote. This caused excessive memory usage.

Added the method verifiers as roots to fix an issue caused by
RegTypes holding a Class*.

Added logic to clear card table in the SemiSpace collector, this
reduces DalvikOther from ~2400k -> ~1760k when using the SemiSpace
collector.

Added a missing lock to the timing loggers which caused a rare
one time crash in std::set.

Bug: 11771255
Bug: 8499494
Bug: 10802951

Change-Id: I99d2b528cd51c1c5ed7012e3220b3aefded680ae
8171fc34bf74ed0df02385787d916bc13eb7f160 26-Nov-2013 Vladimir Marko <vmarko@google.com> Don't prefix GC map by length.

Bug: 11767815
Change-Id: I063917aefdf7674ee1a77736db059c9ee95ea075
59cde534aa295bad7de29472b3cce9576d7996a8 05-Dec-2013 Chris Dearman <chris.dearman@imgtec.com> Workaround for gcc volatile struct member bug

gcc does not handle struct with volatile member assignments correctly.
See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47409

Using structure assignments for the StateAndFlag union can cause gcc
to optimise the code incorrectly. Doing the assignment using the
as_int member forces the correct behaviour.

Change-Id: I6379d36add16c321b2e4d1dcd6fd8c959f3f92d6
5f51d4b80058236759fea1d932470a57f348c199 03-Dec-2013 Mathieu Chartier <mathieuc@google.com> Fix races in thread list Unregister.

First race:
We were releasing the thin_lock_id in Unregister before the thread
was not suspended. This could cause problems in
SuspendThreadByThreadId since there was a small window of time where
two threads could share the same thread id. This race caused an
occasional check failure in SuspendThreadByThreadId.

Second race:
We were setting the thin_lock_thread_id_ to 0 in Unregister before
waiting to not be suspended. This caused another race in
SuspendThreadByThreadId where we modified the thread suspend count,
busy waited, but didn't find the thread the next iteration. This
meant that we were returning null even though we had modified the
suspend count. This caused the suspend count to not get decremented
since the caller didn't know that the suspend count had been
increased. Removing the self->thin_lock_thread_id_ = 0 in
ThreadList::UnRegister fixes this race.

Added a bit of additional checks and logging to prevent these issues
from resurfacing, other misc cleanup.

Added thread names to threads in ThreadStress.

Bug: 11319866

Change-Id: I48e3a0700193b72079e450be1e924a2f88cf52e2
123756a041baf8421ed933312605daa5ef082f6f 27-Nov-2013 Sebastien Hertz <shertz@google.com> Fix JDWP class-only modifier.

Fix Dbg::MatchType which is used for class-only and exception-only modifiers.

Also fix crash happening when notifying an exception. A debugger may walk the
stack of the current thread so we need to keep the instrumentation stack frame
synced with the native stack.

Bug: 11856587
Change-Id: Ibf95f8a83ce9ee640abf945e498b42cc88ea92a0
228d6b8a4f0a21c1e9b2372c3104ce4ee19f65b4 04-Dec-2013 Jeff Hao <jeffhao@google.com> Fix stack trace for proxy methods and added test case.

Bug: 11861564

Change-Id: I9513359ff9e5d345ee71d84388afed02bd114ecf
61b7f1b05d1fe12d4009316263bf990903e4edff 15-Nov-2013 Sebastien Hertz <shertz@google.com> Move single-step control into thread.

This CL moves single-step control into the Thread structure. This is stored in
Thread::single_step_control_ member. This allows to support single-stepping of
multiple threads at the same time.

Since each thread holds its single-step information, we no longer need to use
the breakpoint lock to support single-stepping. It helps reduce lock contention
on this lock while debugging.

All JDWP tests passed on the host and on the target with this CL.

Bug: 11667502
Change-Id: I886d5c8c625ca5a072803e296c32eec5f7e9e82d
cf58d4adf461eb9b8e84baa8019054c88cd8acc6 26-Sep-2013 Hiroshi Yamauchi <yamauchi@google.com> A custom 'runs-of-slots' memory allocator.

Bug: 9986565
Change-Id: I0eb73b9458752113f519483616536d219d5f798b
590fee9e8972f872301c2d16a575d579ee564bee 13-Sep-2013 Mathieu Chartier <mathieuc@google.com> Compacting collector.

The compacting collector is currently similar to semispace. It works by
copying objects back and forth between two bump pointer spaces. There
are types of objects which are "non-movable" due to current runtime
limitations. These are Classes, Methods, and Fields.

Bump pointer spaces are a new type of continuous alloc space which have
no lock in the allocation code path. When you allocate from these it uses
atomic operations to increase an index. Traversing the objects in the bump
pointer space relies on Object::SizeOf matching the allocated size exactly.

Runtime changes:
JNI::GetArrayElements returns copies objects if you attempt to get the
backing data of a movable array. For GetArrayElementsCritical, we return
direct backing storage for any types of arrays, but temporarily disable
the GC until the critical region is completed.

Added a new runtime call called VisitObjects, this is used in place of
the old pattern which was flushing the allocation stack and walking
the bitmaps.

Changed image writer to be compaction safe and use object monitor word
for forwarding addresses.

Added a bunch of added SIRTs to ClassLinker, MethodLinker, etc..

TODO: Enable switching allocators, compacting on background, etc..

Bug: 8981901

Change-Id: I3c886fd322a6eef2b99388d19a765042ec26ab99
88474b416eb257078e590bf9bc7957cee604a186 24-Oct-2013 Jeff Hao <jeffhao@google.com> Implement Interface Method Tables (IMT).

Change-Id: Idf7fe85e1293453a8ad862ff2380dcd5db4e3a39
a9a8254c920ce8e22210abfc16c9842ce0aea28f 04-Oct-2013 Ian Rogers <irogers@google.com> Improve quick codegen for aput-object.

1) don't type check known null.
2) if we know types in verify don't check at runtime.
3) if we're runtime checking then move all the code out-of-line.

Also, don't set up a callee-save frame for check-cast, do an instance-of test
then throw an exception if that fails.
Tidy quick entry point of Ldivmod to Lmod which it is on x86 and mips.
Fix monitor-enter/exit NPE for MIPS.
Fix benign bug in mirror::Class::CannotBeAssignedFromOtherTypes, a byte[]
cannot be assigned to from other types.

Change-Id: I9cb3859ec70cca71ed79331ec8df5bec969d6745
d9c4fc94fa618617f94e1de9af5f034549100753 02-Oct-2013 Ian Rogers <irogers@google.com> Inflate contended lock word by suspending owner.

Bug 6961405.
Don't inflate monitors for Notify and NotifyAll.
Tidy lock word, handle recursive lock case alongside unlocked case and move
assembly out of line (except for ARM quick). Also handle null in out-of-line
assembly as the test is quick and the enter/exit code is already a safepoint.
To gain ownership of a monitor on behalf of another thread, monitor contenders
must not hold the monitor_lock_, so they wait on a condition variable.
Reduce size of per mutex contention log.
Be consistent in calling thin lock thread ids just thread ids.
Fix potential thread death races caused by the use of FindThreadByThreadId,
make it invariant that returned threads are either self or suspended now.

Code size reduction on ARM boot.oat 0.2%.
Old nexus 7 speedup 0.25%, new nexus 7 speedup 1.4%, nexus 10 speedup 2.24%,
nexus 4 speedup 2.09% on DeltaBlue.

Change-Id: Id52558b914f160d9c8578fdd7fc8199a9598576a
3b4c18933c24b8a33f38573c2ebcdb9aa16efeb5 13-Sep-2013 Hiroshi Yamauchi <yamauchi@google.com> Split the allocation path into 'instrumented' and 'uninstrumented'
ones.

The instrumented path is equivalent to the existing allocation path
that checks for three instrumentation mechanisms (the debugger
allocation tracking, the runtime allocation stats collection, and
valgrind) for every allocation. The uinstrumented path does not
perform these checks. We use the uninstrumented path by default and
enable the instrumented path only when any of the three mechanisms is
enabled. The uninstrumented version of Heap::AllocObject() is inlined.

This change improves the Ritz MemAllocTest by ~4% on Nexus 4 and ~3%
on Host/x86.

Bug: 9986565
Change-Id: I3e68dfff6789d77bbdcea98457b694e1b5fcef5f
530825ba92e317822116efffd470577ddfd142d4 26-Sep-2013 Mathieu Chartier <mathieuc@google.com> Make InternalStackTraceToStackTraceElementArray compaction safe.

Added more SOA decodes.

Change-Id: Idbfd546467582a848be91c358c6926a6e472fbff
2921201dce37ba40c55b89c0deca3c34bf64168e 13-Sep-2013 Brian Carlstrom <bdc@google.com> Remove some non-const references in utils

Change-Id: Ib2d3c39fadb6a750c68c37b0aa53daab155a65a3
ee39a10e45a6a0880e8b829525c40d6055818560 19-Sep-2013 Ian Rogers <irogers@google.com> Use class def index from java.lang.Class.

Bug: 10244719
This removes the computation of the dex file index, when necessary this is
computed by searching the dex file. Its only necessary in
dalvik.system.DexFile.defineClassNative and DexFile::FindInClassPath, the
latter not showing up significantly in profiling with this change.

(cherry-picked from 8b2c0b9abc3f520495f4387ea040132ba85cae69)
Change-Id: I20c73a3b17d86286428ab0fd21bc13f51f36c85c
c11d9b8870de5f860b13c84003ade7b3f3125a52 19-Sep-2013 Mathieu Chartier <mathieuc@google.com> Re-enable concurrent system weak sweeping.

Enabled by disallowing new system weaks during the pause and
re-allowing it after the system weaks have been swept. Reduces
GC pause by ~1ms.

Fixes pause regression caused by fix for
Bug: 10626133

Change-Id: If49d33e7ef19cb728ed3cef5187acfa53b9b05d8
8b2c0b9abc3f520495f4387ea040132ba85cae69 19-Sep-2013 Ian Rogers <irogers@google.com> Use class def index from java.lang.Class.

Bug: 10244719
Depends on:
https://googleplex-android-review.git.corp.google.com/362363
This removes the computation of the dex file index, when necessary this is
computed by searching the dex file. Its only necessary in
dalvik.system.DexFile.defineClassNative and DexFile::FindInClassPath, the
latter not showing up significantly in profiling with this change.

Change-Id: I20c73a3b17d86286428ab0fd21bc13f51f36c85c
423d2a3dcbb260b020efb5da59f784c9f02accbf 13-Sep-2013 Mathieu Chartier <mathieuc@google.com> Add support for changing roots through the root visitor callback.

Needed for copying collectors.

Change-Id: Icc4a342a57e0cfb79587edb02ef8c85e08808877
2e450bf45e1bacc9c356f6ab239ccfb31bd8d7e4 07-Sep-2013 Brian Carlstrom <bdc@google.com> Revert "Remove bogus fastpath from String::Equals(const StringPiece&)"

This reverts commit 8438ed31e10f3881ed92f03877d5edaca7d5b48c.

Bug: 10614658
Change-Id: I335f10a7140e1644957bc1cee21a9b310a558499
8438ed31e10f3881ed92f03877d5edaca7d5b48c 05-Sep-2013 Brian Carlstrom <bdc@google.com> Remove bogus fastpath from String::Equals(const StringPiece&)

Bug: 10614658
Change-Id: I907ec77a65c1ae29e800356abdf755a457620081
ba311b4385fa3f382f01312a8cc97b52011232e3 27-Aug-2013 Mathieu Chartier <mathieuc@google.com> Fix mark stack expand race.

We now guard parallel mark stack pushing with a lock. This is
only used by checkpoint root marking. I did not observe a
significant slowdown by looking at ritzperf and maps, but it may
be worth reinvestigating in the future.

Also a bit of refactoring.

Bug: 10113123

Change-Id: Ifcb12d14df437e2aea9a1165a9568054f80d91b3
b8a0b94735f188bc739e4c55479c37699006b881 21-Aug-2013 Ian Rogers <irogers@google.com> Switch JNI globals lock to reader-writer.

Also, verifier rejected classes lock. These locks show as contended during
dex2oat, however, they're commonly only read access is required.

Change-Id: If8bb834cc69cd8c26494c87fb7f7b20d4e41cdfd
958aba1421f2234aeafb22219d45a561e109a445 19-Aug-2013 Ian Rogers <irogers@google.com> Build fix.

A static field was moved from an inner to an outer class in ConcurrentHashMap
leading to a disallowed call.
Also, tidy comments on other java.util.concurrent black listed classes.

(cherry picked from commit 65530499a0169b3b0b153008e2d187c9f4939541)

Change-Id: I918f567c5b84d9f16f91772bee89cda29f058750
65530499a0169b3b0b153008e2d187c9f4939541 19-Aug-2013 Ian Rogers <irogers@google.com> Build fix.

A static field was moved from an inner to an outer class in ConcurrentHashMap
leading to a disallowed call.
Also, tidy comments on other java.util.concurrent black listed classes.

Change-Id: Iccd808766dcd5406a5bb49a4b98f570606730250
5ce4b178d2483df679e7f718e379305e5d42a300 17-Aug-2013 Jeff Hao <jeffhao@google.com> Clean up sampling tracing.

- Moved maps to fields within thread.
- Created temp trace field to lessen amount of traces allocated and freed.

Change-Id: I23fe25a85ad2894cc6917f87d4046cdececf0739
57dac6ed61a0a25c14d4e2fabc84435578d42360 16-Aug-2013 Jeff Hao <jeffhao@google.com> Fix sampling profiler to use thread's cpu clock.

The sampling profiler was using the sampling thread's cpu clock to
measure cpu time, instead of the sampled thread's cpu clock.

Change-Id: Ief1f82e07e0353192c61521f67dec7a761905f64
414af10d719603fb4d8d972f5a022c17957b44e1 13-Aug-2013 Brian Carlstrom <bdc@google.com> Add flock(2)ing on dex-cache files to prevent races

Bug: 9071417
Change-Id: I1ee9ff281867f90fba7a8ed8bbf06b33ac29d511
7571e8b761ebc2c923525e12ea9fcf07e62cb33e 13-Aug-2013 Brian Carlstrom <bdc@google.com> Add flock(2)ing on dex-cache files to prevent races

Bug: 9071417
Change-Id: I1ee9ff281867f90fba7a8ed8bbf06b33ac29d511
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
96faf5b363d922ae91cf25404dee0e87c740c7c5 10-Aug-2013 Ian Rogers <irogers@google.com> Uleb128 compression of vmap and mapping table.

Bug 9437697.

Change-Id: I30bcb97d12cd8b46d3b2cdcbdd358f08fbb9947a
(cherry picked from commit 1809a72a66d245ae598582d658b93a24ac3bf01e)
468532ea115657709bc32ee498e701a4c71762d4 05-Aug-2013 Ian Rogers <irogers@google.com> Entry point clean up.

Create set of entry points needed for image methods to avoid fix-up at load time:
- interpreter - bridge to interpreter, bridge to compiled code
- jni - dlsym lookup
- quick - resolution and bridge to interpreter
- portable - resolution and bridge to interpreter

Fix JNI work around to use JNI work around argument rewriting code that'd been
accidentally disabled.
Remove abstact method error stub, use interpreter bridge instead.
Consolidate trampoline (previously stub) generation in generic helper.
Simplify trampolines to jump directly into assembly code, keeps stack crawlable.
Dex: replace use of int with ThreadOffset for values that are thread offsets.
Tidy entry point routines between interpreter, jni, quick and portable.

Change-Id: I52a7c2bbb1b7e0ff8a3c3100b774212309d0828e
(cherry picked from commit 848871b4d8481229c32e0d048a9856e5a9a17ef9)
1809a72a66d245ae598582d658b93a24ac3bf01e 10-Aug-2013 Ian Rogers <irogers@google.com> Uleb128 compression of vmap and mapping table.

Bug 9437697.

Change-Id: I30bcb97d12cd8b46d3b2cdcbdd358f08fbb9947a
848871b4d8481229c32e0d048a9856e5a9a17ef9 05-Aug-2013 Ian Rogers <irogers@google.com> Entry point clean up.

Create set of entry points needed for image methods to avoid fix-up at load time:
- interpreter - bridge to interpreter, bridge to compiled code
- jni - dlsym lookup
- quick - resolution and bridge to interpreter
- portable - resolution and bridge to interpreter

Fix JNI work around to use JNI work around argument rewriting code that'd been
accidentally disabled.
Remove abstact method error stub, use interpreter bridge instead.
Consolidate trampoline (previously stub) generation in generic helper.
Simplify trampolines to jump directly into assembly code, keeps stack crawlable.
Dex: replace use of int with ThreadOffset for values that are thread offsets.
Tidy entry point routines between interpreter, jni, quick and portable.

Change-Id: I52a7c2bbb1b7e0ff8a3c3100b774212309d0828e
834b394ee759ed31c5371d8093d7cd8cd90014a8 31-Jul-2013 Brian Carlstrom <bdc@google.com> Merge remote-tracking branch 'goog/dalvik-dev' into merge-art-to-dalvik-dev

Change-Id: I323e9e8c29c3e39d50d9aba93121b26266c52a46
7655f29fabc0a12765de828914a18314382e5a35 29-Jul-2013 Ian Rogers <irogers@google.com> Portable refactorings.

Separate quick from portable entrypoints.
Move architectural dependencies into arch.

Change-Id: I9adbc0a9782e2959fdc3308215f01e3107632b7c
c449aa8151bf81d93d22ff24677ccf09a6da218e 29-Jul-2013 Ian Rogers <irogers@google.com> Clear exception if catch block doesn't have move-exception.

Bug: 10040419

Change-Id: Icc7a55cb3cdfbc3efd2b161bbe22b3e5007de35f
166db04e259ca51838c311891598664deeed85ad 26-Jul-2013 Ian Rogers <irogers@google.com> Move assembler out of runtime into compiler/utils.

Other directory layout bits of clean up. There is still work to separate quick
and portable in some files (e.g. argument visitor, proxy..).

Change-Id: If8fecffda8ba5c4c47a035f0c622c538c6b58351
7934ac288acfb2552bb0b06ec1f61e5820d924a4 26-Jul-2013 Brian Carlstrom <bdc@google.com> Fix cpplint whitespace/comments issues

Change-Id: Iae286862c85fb8fd8901eae1204cd6d271d69496
fb2802da02337309ac64970e06c90bb3b1b1de3f 24-Jul-2013 Jeff Hao <jeffhao@google.com> Fixes to instrumentation and quick to interpreter entry.

- Interpreter entry was missing check that a static method is
initialized.
- Fixed instrumentation stack unwinding to not pop off the handler
frame only if it actually exists on the instrumentation stack.

Change-Id: I05a96ea7c0aea4dc6552da0edf485856cd004d85
df62950e7a32031b82360c407d46a37b94188fbb 18-Jul-2013 Brian Carlstrom <bdc@google.com> Fix cpplint whitespace/parens issues

Change-Id: Ifc678d59a8bed24ffddde5a0e543620b17b0aba9
0cd7ec2dcd8d7ba30bf3ca420b40dac52849876c 18-Jul-2013 Brian Carlstrom <bdc@google.com> Fix cpplint whitespace/blank_line issues

Change-Id: Ice937e95e23dd622c17054551d4ae4cebd0ef8a2
f69863b3039fc621ff4250e262d2a024d5e79ec8 18-Jul-2013 Brian Carlstrom <bdc@google.com> Fix cpplint whitespace/newline issues

Change-Id: Ie2049d9f667339e41f36c4f5d09f0d10d8d2c762
93ba893c20532990a430741e0a97212900094e8c 18-Jul-2013 Brian Carlstrom <bdc@google.com> Fix cpplint runtime/explicit issues

Change-Id: I352ba0b427f1ff9b22887693952b180eae0839ba
b1eba213afaf7fa6445de863ddc9680ab99762ea 18-Jul-2013 Brian Carlstrom <bdc@google.com> Fix cpplint whitespace/comma issues

Change-Id: I456fc8d80371d6dfc07e6d109b7f478c25602b65
6d69f592696f3bbd3bb0978ae3b25f2c359aac0d 17-Jul-2013 Brian Carlstrom <bdc@google.com> Fix thread initialization issue when runtime started twice (as seen in image_test)

Change-Id: Ic20758ee64c1b2c41cd2329cf6d66b15d0ac2473
d6a23bd327c38b08aaf6846d426fd6824fe9780b 16-Jul-2013 Elliott Hughes <enh@google.com> Don't manually mess with sigaltstack on Android any more.

Bionic now takes care of things.

Bug: 8557703
Change-Id: I0510a193f2433eaf54c9c6ac3415c85b50a7f1d2
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