History log of /art/runtime/thread.cc
Revision Date Author Comments
7dd211919cb6f2b283dbcefd16f137e83b692e03 29-Mar-2018 Vladimir Marko <vmarko@google.com> Fix failure to initialize AnnotatedStackTraceElement.

Test: 171-init-aste
Test: testrunner.py --host --interpreter
Bug: 76208924

(cherry picked from commit c4b1c0c42a707675755a468ba36026d7166a3cc0)

Change-Id: Id1992b04669fe2cd906dc62e70f2a47ca2ca3bb9
ac5fea049d898713bb5802141af2ee3d59ee592d 23-Mar-2018 Alex Light <allight@google.com> Remove unneeded ScopedGCCriticalSections from openjdkjvmti.

We used ScopedGCCriticalSections in many parts of the openjdkjvmti
often unnecessarily.

We removed a totally unneeded GCCriticalSection that was acquired when
modifying the instrumentation listeners.

We also removed RequestGCSafeSynchronousCheckpoint and the change to
use GcRoots instead. We added RequestGCSafeSynchronousCheckpoint as a
way to prevent the GC from running when we are doing some JVMTI
operations on other threads. This could interact with running GCs in
non-trivial ways, potentially causing deadlocks in some situations.
This changes the code to instead use read-barriers and GcRoots to
ensure that we do not read data from the wrong gc space.

In order for this to work correctly we need to make sure that we are
only ever reading the GcRoots from the thread that eventually needs
the reference. This required some re-writing of the checkpoint
closures since they would often just call AddLocalReference on
non-local Thread objects.

Changes to Thread::RequestSynchronousCheckpoint and art::Barrier were
needed in order to allow this all to work since we needed to ensure
that the requesting thread did not suspend as the checkpoint was being
run.

This is a partial revert of commit 7585b91bfc77b8.

Bug: 67838964
Bug: 76003243

Test: use gapid
Test: ./test.py --host -j50
Test: ./art/tools/run-libjdwp-tests.sh --mode=host

Merged-In: I26d871089829639eccb973cecc315194f7bcf681
Change-Id: I26d871089829639eccb973cecc315194f7bcf681
(cherry picked from commit 318afe6c3ac1e734adbd769bbf22b8c7e373e80b)
8f4b056427a9d2321e3aa4f21ca8ffb18b3e5ae6 02-Mar-2018 David Sehr <sehr@google.com> Move most of runtime/base to libartbase/base

Enforce the layering that code in runtime/base should not depend on
runtime by separating it into libartbase. Some of the code in
runtime/base depends on the Runtime class, so it cannot be moved yet.
Also, some of the tests depend on CommonRuntimeTest, which itself needs
to be factored (in a subsequent CL).

Bug: 22322814
Test: make -j 50 checkbuild
make -j 50 test-art-host

Change-Id: I8b096c1e2542f829eb456b4b057c71421b77d7e2
Merged-In: c431b9dc4b23cc950eb313695258df5d89f53b22

(cherry picked from commit c431b9dc4b23cc950eb313695258df5d89f53b22)
b2ec9f5c128673c43f776cbe12c8eeb0a6884ebb 21-Feb-2018 David Sehr <sehr@google.com> Remove duplication, split tests

The code move to libdexfile/dex/descriptors_names.cc apparently did not
remove the original code from runtime/utils.cc. Fix that duplication
and all the header mentions needed. Also, split the test files to go
along with the new locations for the code to be tested.

Bug: 22322814
Test: make -j 50 checkbuild
make -j 50 test-art-host-gtest
flash & boot marlin

Change-Id: Ie734672c4bca2c647d8016291f910b5608674545
ad0777d89df7eb21d7d2001f9743882d10de3f5c 12-Feb-2018 Roland Levillain <rpl@google.com> Visit proxy methods reference arguments when visiting Quick frames roots.

The arguments of a proxy method, stored in the proxy method's stack
frame, need to be visited as GC roots. This is especially important
in the case of a moving GC, where these reference arguments may be
moved like any object. Previously, we would only visit the target
(`this` argument) of proxy methods when visiting Quick frames roots.

Test: art/test/testrunner/testrunner.py --gcstress -t 999-proxy-method-arguments
Test: m test-art-host
Test: m test-art-target
Bug: 73149739
Bug: 70216372
Bug: 67679263
Change-Id: Ieacc966ab1038935600f2193c14e6ca01e88602e
2ae376f5af8953d3524cd8ed915ebdacf505625c 30-Jan-2018 Roland Levillain <rpl@google.com> Stylistic and aesthetic changes.

Test: art/test.py
Change-Id: Ic41aa80430d16af748994c80f049c5b479fd9980
fa854e4834c383daafd240902ecb291ecfdad7b6 07-Feb-2018 Roland Levillain <rpl@google.com> Visit targets of proxy methods when visiting thread roots.

The target of a non-static proxy method (`this` object), stored in the
proxy method's stack frame, needs to be visited as GC root. This is
especially important in the case of a moving GC, where the proxy
instance may be moved like any object.

Fix initially provided by Robert Vollmer.

Test: m test-art-host
Test: art/test/testrunner/testrunner.py --gcstress -t 1939-proxy-frames
Test: art/test/testrunner/testrunner.py --gcstress -t 1914-get-local-instance
Bug: 70216372
Bug: 67679263
Change-Id: Iea27a8eba51ccd9c9055efaf6b263892830170b5
0225f8e2939a9340cb7dcebfcfe7996a2bd9bce9 31-Jan-2018 David Sehr <sehr@google.com> Revert "Revert "Make libdexfile build independent of runtime dir""

This reverts commit 787784f9effb126b5d0d3dc97d544c4a477b5daf.

Reason for revert: Bot configuration issue.

Change-Id: I6a10bb4a9571f89c7e4dd095f9157e830a44e2de
Bug: 22322814
Test: make -j 50 checkbuild
787784f9effb126b5d0d3dc97d544c4a477b5daf 30-Jan-2018 David Sehr <sehr@google.com> Revert "Make libdexfile build independent of runtime dir"

This reverts commit b40b7e73469339a6b667b4a2e2b8690112a74dc9.

Reason for revert: on device libdexfile.so missing

Change-Id: I9bd61a98bef870400580e8c991cb061d3f57fa72
56776014d181b7ee386a2ba5d85cf66d8bb4dd22 27-Jan-2018 Andreas Gampe <agampe@google.com> ART: Call ThreadGroup.add for attached threads

When attaching threads to the runtime, call ThreadGroup.add to
let the thread's group know that the thread is now started. This
fixes incorrect internal accounting.

Test: art/test/testrunner/testrunner.py -b --host -t 169
Test: m test-art-host
Change-Id: I60362b6b53acf06b97779ea9b3b0bc6264f1dc2d
b40b7e73469339a6b667b4a2e2b8690112a74dc9 26-Jan-2018 David Sehr <sehr@google.com> Make libdexfile build independent of runtime dir

Remove libdexfile's dependency on utils.cc and move utf.cc into
/dex. Remove libdexfile's constituent sources from libart and
use libdexfile wherever libart is. Also remove some ART-specific
interfaces. Libdexfile's tests remain to be converted, plus
moving the files to a new directory peer to runtime/.

Bug: 22322814
Test: make -j 50 test-art-host
Change-Id: Ifaf695216e4a0e43d3aa377984d933f7a2a243c2
fb6b0b1b04081f9ef7a240f702d8ce4e61a02e9f 12-Dec-2017 Andreas Gampe <agampe@google.com> ART: Add support for VMStack.getAnnotatedStackTrace

Add Thread.CreateAnnotatedStackTrace to return an array that
contains an AnnotatedStackTraceElement for each stack frame,
with the StackTraceElement describing the frame, an array
containing all objects that are locked at the described location,
and optionally for the top frame an object the thread is blocked
on, waiting for or sleeping on.

Add a test.

Bug: 70538431
Test: m test-art-host
Test: art/test/testrunner/testrunner.py -b --host -t 168
Change-Id: I0d92e3d8182c4a592549a6445854816f71afd29e
9e734c7ab4599d7747a05db0dc73c7b668cb6683 05-Jan-2018 David Sehr <sehr@google.com> Create dex subdirectory

Move all the DexFile related source to a common subdirectory dex/ of
runtime.

Bug: 71361973
Test: make -j 50 test-art-host
Change-Id: I59e984ed660b93e0776556308be3d653722f5223
4131d1096ac57a29ba1939c1cf2cb74144c16c92 03-Jan-2018 Orion Hodson <oth@google.com> ART: Additional Atomic methods

A few additional methods on the Atomic class to support the
interpreter VarHandles implementation.

Minor renaming of Atomic::FetchAnd{Or,And}.* to
Atomic::FetchAndBitwise{Or,And}.*.

Minor updates for consistency in the choice of argument names and doc
comments.

Bug: 65872996
Test: art/test.py --host -j32
Change-Id: Iae35286935fbb270478082fed2fe74abb7b68c57
4557b3858a66aa20e42bce937e1f0620aad880a2 03-Jan-2018 Orion Hodson <oth@google.com> ART: Rename Atomic::CompareExchange methods

Renames Atomic::CompareExchange methods to Atomic::CompareAndSet
equivalents. These methods return a boolean and do not get the witness
value. This makes space for Atomic::CompareAndExchange methods in a
later commit that will return a boolean and get the witness value.

This is pre-work for VarHandle accessors which require both forms.

Bug: 65872996
Test: art/test.py --host -j32
Change-Id: I9c691250e5556cbfde7811381b06d2920247f1a1
55256cb60e11d4fac71affb4b9760a2931a3598d 22-Dec-2017 Ian Rogers <irogers@google.com> Extensions to check JNI.

Ensure critical lock isn't held when returning from a down-call.
Log a warning if the critical lock is held for a significant period of
time.
Refactor JNIEnvExt to be a class rather than a struct.

Test: mma test-art-host

Change-Id: I4d149cb04d3a7308a22b92b196e51e2f1ae17ede
808c7a57bb913b13c22884f57cdacd59bf1fdb3f 15-Dec-2017 Mathieu Chartier <mathieuc@google.com> Make CodeItem fields private

Make code item fields private and use accessors. Added a hand full of
friend classes to reduce the size of the change.

Changed default to be nullable and removed CreateNullable.
CreateNullable was a bad API since it defaulted to the unsafe, may
add a CreateNonNullable if it's important for performance.

Motivation:
Have a different layout for code items in cdex.

Bug: 63756964
Test: test-art-host-gtest
Test: test/testrunner/testrunner.py --host
Test: art/tools/run-jdwp-tests.sh '--mode=host' '--variant=X32' --debug

Change-Id: I42bc7435e20358682075cb6de52713b595f95bf9
9ff1251fed35356bf74dc875ae9b0cea9e50a3b0 04-Dec-2017 Kazuhiro Inaba <kinaba@google.com> ART: Null thread_name check for loggings in rare occasions.

Passing null char* to ostream::operator<< is undefined and can cause
a crash (for instance when libc++ is used) instead of printing the log.

Bug: None (crbug.com/531282)
Test: None

Change-Id: Ieb1f0fc50723b06e72b66b1da7b6abe58d5b9a02
9310495f3bb601058a3b6dedc298ad9f5275510e 14-Dec-2017 Andreas Gampe <agampe@google.com> ART: Factor out stack dumping with monitor objects

Factor out generic stack walking with monitor object visitation into
MonitorObjectsStackVisitor. Rewrite StackDumpVisitor in terms of this,
removing Monitor::DescribeWait on the way.

Bug: 70538431
Test: m test-art-host
Test: manual (SIGQUIT dumping)
Change-Id: I6f359f9a5f665f308328ad466bc7a437f52aea24
b6f309e4e9b7c0531f8d09998b48d82b45714173 12-Dec-2017 Andreas Gampe <agampe@google.com> ART: Factor out StackTraceElement creation

Move to a helper function to aid future reuse.

Bug: 70538431
Test: m test-art-host
Change-Id: Ia7c26d707abbae3a9d5cc5db99007e34a8ab6b62
7919db947bc41f6f5d194c50b88d0cba47319a1c 29-Nov-2017 Alex Light <allight@google.com> Speed up MterpShouldSwitchInterpreters check

We were often performing a pair of TLS reads in order to determine in
the current thread has any pending asynchronous exceptions (exceptions
thrown by the JVMTI StopThread function). This is quite slow and was
impacting some benchmarks. Since it is expected that asynchronous
exceptions are extremely rare we will first check to see if any
asynchronous exceptions have been sent on the current process. Only if
at least one asynchronous exception has been thrown will we do the
expensive TLS lookups to determine if one has been thrown on the
current thread.

Using a global instance value without synchronization or atomics is ok
here since the checkpoint that actually sets the async_exception_thrown
flag provides synchronization by either occurring on the target thread
or passing the checkpoint.

According to go/lem this gives us a 7% increase on the caffeine
string benchmark.

Test: go/lem runs
Test: ./test.py --host -j50
Bug: 68010816
Change-Id: I62684a5b3a7fc7cc600f5efd2a2393d9c4025917
2196c651ecc77e49992c6c329dfce45f78ff46cb 30-Nov-2017 Vladimir Marko <vmarko@google.com> Revert^4 "JIT JNI stubs."

The original CL,
https://android-review.googlesource.com/513417 ,
has a bug fixed in the Revert^2,
https://android-review.googlesource.com/550579 ,
and this Revert^4 adds two more fixes:
- fix obsolete native method getting interpreter
entrypoint in 980-redefine-object,
- fix random JIT GC flakiness in 667-jit-jni-stub.

Test: testrunner.py --host --prebuild --no-relocate \
--no-image --jit -t 980-redefine-object
Bug: 65574695
Bug: 69843562

This reverts commit 056d7756152bb3ced81dd57781be5028428ce2bd.

Change-Id: Ic778686168b90e29816fd526e23141dcbe5ea880
056d7756152bb3ced81dd57781be5028428ce2bd 30-Nov-2017 Nicolas Geoffray <ngeoffray@google.com> Revert "Revert "Revert "JIT JNI stubs."""

Still seeing occasional failures on 667-jit-jni-stub

Bug: 65574695
Bug: 69843562

This reverts commit e7441631a11e2e07ce863255a59ee4de29c6a56f.

Change-Id: I3db751679ef7bdf31c933208aaffe4fac749a14b
e7441631a11e2e07ce863255a59ee4de29c6a56f 29-Nov-2017 Vladimir Marko <vmarko@google.com> Revert "Revert "JIT JNI stubs.""

The original CL,
https://android-review.googlesource.com/513417 ,
had a bug for class unloading where a read barrier was
executed at the wrong time from
ConcurrentCopying::MarkingPhase() ->
ClassLinker::CleanupClassLoaders() ->
ClassLinker::DeleteClassLoader() ->
JitCodeCache::RemoveMethodsIn() ->
JitCodeCache::JniStubKey::UpdateShorty() ->
ArtMethod::GetShorty().
This has been fixed by removing sources of the read barrier
from ArtMethod::GetShorty().

Test: testrunner.py --host --prebuild --jit --no-relocate \
--no-image -t 998-redefine-use-after-free
Bug: 65574695
Bug: 69843562

This reverts commit 47d31853e16a95393d760e6be2ffeeb0193f94a1.

Change-Id: I06e7a15b09d9ff11cde15a7d1529644bfeca15e0
47d31853e16a95393d760e6be2ffeeb0193f94a1 28-Nov-2017 Vladimir Marko <vmarko@google.com> Revert "JIT JNI stubs."

Seems to break 998-redefine-use-after-free in
some --no-image configuration.

Bug: 65574695
Bug: 69843562

This reverts commit 3417eaefe4e714c489a6fb0cb89b4810d81bdf4d.

Change-Id: I2dd157b931c17c791522ea2544c1982ed3519b86
3417eaefe4e714c489a6fb0cb89b4810d81bdf4d 21-Sep-2017 Vladimir Marko <vmarko@google.com> JIT JNI stubs.

Allow the JIT compiler to compile JNI stubs and make sure
they can be collected once they are not in use anymore.

Test: 667-jit-jni-stub
Test: Pixel 2 XL boots.
Test: m test-art-host-gtest
Test: testrunner.py --host --jit
Test: testrunner.py --target --jit
Bug: 65574695
Change-Id: Idf81f50bcfa68c0c403ad2b49058be62b21b7b1f
33bff25bcd7a02d35c54f63740eadb1a4833fc92 01-Nov-2017 Vladimir Marko <vmarko@google.com> ART: Make InstructionSet an enum class and add kLast.

Adding InstructionSet::kLast shall make it easier to encode
the InstructionSet in fewer bits using BitField<>. However,
introducing `kLast` into the `art` namespace is not a good
idea, so we change the InstructionSet to an enum class.
This also uncovered a case of InstructionSet::kNone being
erroneously used instead of vixl32::Condition::None(), so
it's good to remove `kNone` from the `art` namespace.

Test: m test-art-host-gtest
Test: testrunner.py --host --optimizing
Change-Id: I6fa6168dfba4ed6da86d021a69c80224f09997a6
df00a1ed1a0b633a1e66f1f650f53c22ea260e5b 01-Nov-2017 Alex Light <allight@google.com> Prevent abort in situations with recursive checkpoints

In situations where there were multiple checkpoints queued and the
first one causes the thread to suspend itself again then the
RunCheckpointFunction function will hit a LOG(FATAL) and abort. This
is because the recursive checkpoint will clear out the checkpoint
backlog and the first RunCheckpointFunction invocation will
unexpectedly find itself without any more checkpoints to run and
abort.

To fix this, and simplify the code at the same time, we have changed
the RunCheckpointFunction method to (as its name suggests) only run a
single checkpoint function. It will pop this function off the stack of
pending checkpoints and run it relying on the caller to ensure that
all pending checkpoints are handled. This is fine since, due to the
multithreaded nature of checkpoints, the caller must call
RunCheckpointFunction in a loop anyway to ensure it does not advance
until all checkpoints have been handled.

We add test 203-multi-checkpoints that tests that the checkpoint
system does not fall over if there are multiple checkpoints some of
which can suspend.

Bug: 67838964
Test: ./test.py --host -j50
Change-Id: Ib6a3e083e6069d4839647d194bee6849d973633e
891a50e9dc0f02ee34bd7348f80b621249153af5 28-Oct-2017 David Sehr <sehr@google.com> Separate file utilities from utils.cc

Reduce the dependencies from utils.cc to arch/ subdirectories, etc.

Bug: 22322814
Test: make test-art-host
Change-Id: I4decd15ff4ec460735bfb58cebb1c6a1bf32b68f
373a9b5c718a45ac484afcf4fe6ce84f4bb562b3 18-Oct-2017 Andreas Gampe <agampe@google.com> ART: Depend on libnativehelper headers only

Depend on header-only versions where possible. Move projects
excluding libart to libnativehelper_header_only.

Bug: 65522645
Test: mmma art
Change-Id: I53dd3b2a97e94ee685f72de007ed3858f7f5c6b6
b1e31a8337b9cce2f3160a972123886b355dce27 05-Oct-2017 Alex Light <allight@google.com> Change RequestSynchronousCheckpoint to release thread_list_lock_

The RequestSynchronousCheckpoint function in some cases needs to
release the thread_list_lock_ as it waits for a checkpoint to be
executed. This means that the thread being checkpointed might be
deleted. Previously it was not obvious this was the case since the
thread_list_lock_ seemed to be held throughout the execution of the
method.

In order to prevent bugs we make RequestSynchronousCheckpoint
explicitly release the thread_list_lock_ when executed, meaning code
will be aware that threads might die during its execution.

Bug: 67362832
Test: ./test.py --host -j50
Change-Id: I1cbdf7660096dc1908b0eeabc1062447307bc888
df13240f4b9325b34d09e20cdac4e9a0b12ead61 29-Sep-2017 Alex Light <allight@google.com> Send ThreadEnd after clearing ThreadGroup.

The removal of a thread from it's thread group does cause managed code
to execute so it could cause additional events to trigger in agents,
potentially causing deadlocks. This changes where the event is
triggered to put it after the thread has been removed from its group.

Test: ./test.py --host -j50
Bug: 67104807

Change-Id: I53f53b2823835a9629842fb5c22079b3e42042d5
a78f5b6da738d38b0833b223b42d4486273f05bd 29-Sep-2017 Roland Levillain <rpl@google.com> Refactor conditional uses of ReadBarrier::AssertToSpaceInvariant.

Test: m test-art-host
Bug: 12687968
Change-Id: Idf7de149bc0d0dcfc9efe01918aa026754f9070d
848574ca50bb7e2d109608359d1086b3ca6bb4b3 26-Sep-2017 Alex Light <allight@google.com> Implement asynchronous exception support

This CL implements async exception support in the switch interpreter.
It also adds support for the MTerp to detect and switch back to the
switch interpreter in cases where an async exception is detected.

Tests follow in next CL.

Test: ./test.py --host -j50

Bug: 62821960
Bug: 34415266

Change-Id: Idb53711a40c20f962de8aa6b74662676b8bd25c6
b77b698f4550458725b72d3a451adca765f369cc 08-Jun-2017 Roland Levillain <rpl@google.com> Check the to-space invariant on a delivered exception.

Test: art/test/testrunner/testrunner.py
Bug: 62339341
Bug: 12687968
Change-Id: Ida5e91031cd94429a72fcc9d4d1333d21dd07421
e2abbc604ce003c776c00ecf1293796bb4c4ac5a 15-Sep-2017 Andreas Gampe <agampe@google.com> ART: Move kDexNoIndex to dex_file_types.h

Define the constant with the types to allow lowering the dependency
on DexFile.

Test: m
Change-Id: I3c61421db45be96d2057e01b1a7825883d8bd178
0882af2e3ca253184b6ab56a8966a2f37407144e 01-Sep-2017 Hans Boehm <hboehm@google.com> Shrink ART Mutex exclusive_owner_ field to Atomic<pid_t>

The old volatile uint64_t version had a data race, and was thus
technically incorrect. Since it's unclear whether volatile uint64_t
updates are actually atomic on 32-bit platforms, even the informal
correctness argument here already effectively assumed that the upper
32 bits were zero. Don't store them. Explicitly complain if a pid_t
might be too big to support lock-free atomic operations.

Remove many explicit references to exclusive_owner to avoid
littering the code with LoadRelaxed calls.

The return convention for GetExclusiveOwnerTid() was unclear
for the shared ownership case. It was previously treated
inconsistently as 0 (pthread locks), (uint64_t)(-1U) and
(uint64_t)(-1). Make it as consistent as easily possible, and
document remaining weirdness.

Bug: 65171052

Test: AOSP builds. Host tests pass.

Change-Id: Ia99aca268952597a90b3c798b714cddbdc2c365e
2ee17909eadd7155f4a7751c38398b36fc267f04 30-Aug-2017 Mingyao Yang <mingyao@google.com> Revert^4 "Allow deoptimization when returning from a runtime method."

This reverts commit 07c7028e518b98d3267a77dfe0d149db1adbe858.

Need some special treatment of string init's shorty.

Test: run-test/gtest on both host and target
Test: 597-deopt-busy-loop, 597-deopt-invoke-stub
Bug: 33616143
Change-Id: Id4c64910acfdd088835b6db6fc503e6ade0218e7
07c7028e518b98d3267a77dfe0d149db1adbe858 30-Aug-2017 Nicolas Geoffray <ngeoffray@google.com> Revert "Revert "Revert "Allow deoptimization when returning from a runtime method."""

Bug: 33616143

deopt string test still failing on occasion.

This reverts commit 047abb20d02546d3dd6e8630befc31e5568fa90e.

Change-Id: I89fc28696290da52317d0e3dd07ecf0d1bdac823
047abb20d02546d3dd6e8630befc31e5568fa90e 24-Aug-2017 Mingyao Yang <mingyao@google.com> Revert "Revert "Allow deoptimization when returning from a runtime method.""

This reverts commit 2b87ae0073256e909e15f464300912552e58ee48.

For an invocation runtime method such as quick-to-interpreter bridge,
add a special stack walk to get the shorty for the invoked method.

Test: run-test/gtest on both host and target, and 597-deopt-runtime-method.
Bug: 33616143

Change-Id: I53ae93880f62c95dcf48005239b925d7f7b11eb6
6e1607e247d979a1671a1fd5a98de3f1031fe719 23-Aug-2017 Alex Light <allight@google.com> Rename instrumentation ExceptionCaught to ExceptionThrown

The instrumentation ExceptionCaught event was badly named since it is
actually sent at the time the exception is thrown and is sent even if
the exception is never actually caught. Rename it and associated
methods/fields to ExceptionThrown to more accurately reflect the
event's semantics.

Test: ./test.py --host -j50
Change-Id: I1e9c401ab619259b25928dbf19f62d3fa9573d47
2b87ae0073256e909e15f464300912552e58ee48 23-Aug-2017 Vladimir Marko <vmarko@google.com> Revert "Allow deoptimization when returning from a runtime method."

Reason for revert:
Some tests failing even after a minor fix.

This reverts commit edeba10d523c3e283ab939a16c7203af32c7707e.

Change-Id: I6407c9b489c016d19a12c28d1da0efa55ad554a7
edeba10d523c3e283ab939a16c7203af32c7707e 12-Apr-2017 Mingyao Yang <mingyao@google.com> Allow deoptimization when returning from a runtime method.

This CL patches the return pc of a runtime method to allow the top
Java frame to be deoptimized. This should fix the issue that debugger
cannot break in a busy loop. It also means we can now do full async
deoptimization, if we want to enable it by letting environment keep
registers live.

art_quick_instrumentation_exit and art_quick_deoptimize now need to save
all registers since some compiler slow paths assume runtime methods save
everything.

Some special handling needs to be done to decide whether dex_pc should
be advanced when deoptimized back to interpreter.

Test: run-test/gtest on both host and target, and 597-deopt-runtime-method.
Bug: 33616143
Change-Id: I2e2c199998825afd5057f7deadfc8fa203ce1936
e5071cc58a3cdea4a88257be3c8fd4d012a64c74 12-Jun-2017 Vladimir Marko <vmarko@google.com> ART: Change method lookup to be more consistent to JLS and the RI.

The method lookup for different invoke types was previously
widely different and didn't work well with the dex cache
method array where we have only a single slot for each
MethodId. The new behavior is to perform the same lookup for
all cases, distinguishing only between interface and
non-interface referencing class, and to further align the
behavior with the JLS and the RI. Where the JLS conflicts
with the RI, we follow the JLS semantics.

The new lookup for class methods first searches the methods
declared in the superclass chain (ignoring "copied" methods)
and only then looks in the "copied" methods. If the search
in the superclass chain finds a method that has not been
inherited (i.e. either a private method or a package-access
method where one of the classes in the chain does not belong
to the same package, see JLS 8.4.8), we still search the
"copied" methods as there may actually be a method inherited
from an interface. This follows the JLS semantics where
inherited methods are included in the search (JLS 15.12.2.1)
but conflicts with the RI where the private or
package-access method takes precedence over methods
inherited from interfaces.

Note that this search can find an accessible method that is
not inherited by the qualifying type, either for a package
access method when the referrer is in the same package but
the qualifying type is in another package, or for a private
method where the referrer is in the same class but the
qualifying type is actually a subclass. For the moment we
allow such calls and we shall consider whether to throw
an IncompatibleClassChangeError in this situation in future
to comply with JLS 15.12.4.3.

The new lookup for interface methods searches the interface
class, then all the superinterfaces and then the
java.lang.Object class, see implicitly declared methods in
interfaces, JLS 9.2. The search for the maximally-specific
non-abstract superinterface method is not yet implemented,
but the difference should be difficult to observe as the
usual subsequent call to FindVirtualMethodForInterface()
should yield the same result for any matching method.

The new test 162-method-idx-clash exposes several cases
where we previously completely messed up due to the effects
of the DexCache, or where we were out of line with the RI.
It also tests a case where the JLS and the RI disagree and
we follow the JLS.

Test: art/test/run-test --host --jvm 162-method-resolution
Test: m test-art-host-gtest
Test: testrunner.py --host
Test: testrunner.py --host --interp-ac
Test: Nexus 6P boots.
Test: testrunner.py --target
Bug: 62855082
Bug: 30627598

(cherry picked from commit ba118827465d12177f3996e50133960087b1c916)

Change-Id: Ic73e4adf02b5cd66b5a22a3b619dc781357db14c
165ba42d5df5f1f21346e117ff905fcd2f80540d 06-Jul-2017 Andreas Gampe <agampe@google.com> ART: Make Touch's stack array smaller under ASAN

Under ASAN, especially on x86, there's a lot of overhead. To keep
below a single page, add a multiplier to the deduction.

(cherry picked from commit 4ca02b5b0409fa08b6eed77610f6a783319361fc)

Bug: 31098551
Bug: 62952017
Test: m
Test: SANITIZE_HOST=address SANITIZE_TARGET=address m ; manual assembly inspection
Merged-In: I8c80181e0fc5c6f4a1d3c6544f1a0e1089bb0631
Change-Id: I8c80181e0fc5c6f4a1d3c6544f1a0e1089bb0631
2dc01ce7f2f1e186c44346fdbb0b486397de6a34 29-Jun-2017 Andreas Gampe <agampe@google.com> ART: Change main-thread thread paging scheme

Modify the code that ensures we can install a stack guard page into
the main thread.

A recent kernel change means that our previous approach of using a
free pointer does not work. It is important to actually extend the
stack properly. For portability, use a function with a large stack
frame (suggested by and adapted from hboehm).

(cherry picked from commit a79db76cedaf6e4cd3e8a30cde0051632a21233d)

Bug: 62952017
Test: m
Test: m test-art-host
Test: Device boots (x86_64 emulator)
Test: Device boots (bullhead)
Merged-In: Ic2a0c3d6d05a1ea9f655329d147b46949e1b9db3
Change-Id: Ic2a0c3d6d05a1ea9f655329d147b46949e1b9db3
4ca02b5b0409fa08b6eed77610f6a783319361fc 06-Jul-2017 Andreas Gampe <agampe@google.com> ART: Make Touch's stack array smaller under ASAN

Under ASAN, especially on x86, there's a lot of overhead. To keep
below a single page, add a multiplier to the deduction.

(cherry picked from commit 6f1c7517a9e411e4000aa7b13743ed49e0c38bc0)

Bug: 31098551
Bug: 62952017
Test: m
Test: SANITIZE_HOST=address SANITIZE_TARGET=address m ; manual assembly inspection
Merged-In: I8c80181e0fc5c6f4a1d3c6544f1a0e1089bb0631
Change-Id: I8c80181e0fc5c6f4a1d3c6544f1a0e1089bb0631
a79db76cedaf6e4cd3e8a30cde0051632a21233d 29-Jun-2017 Andreas Gampe <agampe@google.com> ART: Change main-thread thread paging scheme

Modify the code that ensures we can install a stack guard page into
the main thread.

A recent kernel change means that our previous approach of using a
free pointer does not work. It is important to actually extend the
stack properly. For portability, use a function with a large stack
frame (suggested by and adapted from hboehm).

(cherry picked from commit e43dfd6498545ab54121bf330941aef82d9bf339)

Bug: 62952017
Test: m
Test: m test-art-host
Test: Device boots (x86_64 emulator)
Test: Device boots (bullhead)
Merged-In: Ic2a0c3d6d05a1ea9f655329d147b46949e1b9db3
Change-Id: Ic2a0c3d6d05a1ea9f655329d147b46949e1b9db3
854b3503ab4d6f41079e0541c8dc382427f7eb2f 06-Jul-2017 Andreas Gampe <agampe@google.com> ART: Make Touch's stack array smaller under ASAN

Under ASAN, especially on x86, there's a lot of overhead. To keep
below a single page, add a multiplier to the deduction.

(cherry picked from commit 6f1c7517a9e411e4000aa7b13743ed49e0c38bc0)

Bug: 31098551
Bug: 62952017
Test: m
Test: SANITIZE_HOST=address SANITIZE_TARGET=address m ; manual assembly inspection
Merged-In: I8c80181e0fc5c6f4a1d3c6544f1a0e1089bb0631
Change-Id: I8c80181e0fc5c6f4a1d3c6544f1a0e1089bb0631
afb2b33f871021d0d82318f36404cf1294383269 29-Jun-2017 Andreas Gampe <agampe@google.com> ART: Change main-thread thread paging scheme

Modify the code that ensures we can install a stack guard page into
the main thread.

A recent kernel change means that our previous approach of using a
free pointer does not work. It is important to actually extend the
stack properly. For portability, use a function with a large stack
frame (suggested by and adapted from hboehm).

(cherry picked from commit 6c63f863f9dbf734732ff837c1e772b3482e59ff)

Bug: 62952017
Test: m
Test: m test-art-host
Test: Device boots (x86_64 emulator)
Test: Device boots (bullhead)
Merged-In: Ic2a0c3d6d05a1ea9f655329d147b46949e1b9db3
Change-Id: Ic2a0c3d6d05a1ea9f655329d147b46949e1b9db3
ba118827465d12177f3996e50133960087b1c916 12-Jun-2017 Vladimir Marko <vmarko@google.com> ART: Change method lookup to be more consistent to JLS and the RI.

The method lookup for different invoke types was previously
widely different and didn't work well with the dex cache
method array where we have only a single slot for each
MethodId. The new behavior is to perform the same lookup for
all cases, distinguishing only between interface and
non-interface referencing class, and to further align the
behavior with the JLS and the RI. Where the JLS conflicts
with the RI, we follow the JLS semantics.

The new lookup for class methods first searches the methods
declared in the superclass chain (ignoring "copied" methods)
and only then looks in the "copied" methods. If the search
in the superclass chain finds a method that has not been
inherited (i.e. either a private method or a package-access
method where one of the classes in the chain does not belong
to the same package, see JLS 8.4.8), we still search the
"copied" methods as there may actually be a method inherited
from an interface. This follows the JLS semantics where
inherited methods are included in the search (JLS 15.12.2.1)
but conflicts with the RI where the private or
package-access method takes precedence over methods
inherited from interfaces.

Note that this search can find an accessible method that is
not inherited by the qualifying type, either for a package
access method when the referrer is in the same package but
the qualifying type is in another package, or for a private
method where the referrer is in the same class but the
qualifying type is actually a subclass. For the moment we
allow such calls and we shall consider whether to throw
an IncompatibleClassChangeError in this situation in future
to comply with JLS 15.12.4.3.

The new lookup for interface methods searches the interface
class, then all the superinterfaces and then the
java.lang.Object class, see implicitly declared methods in
interfaces, JLS 9.2. The search for the maximally-specific
non-abstract superinterface method is not yet implemented,
but the difference should be difficult to observe as the
usual subsequent call to FindVirtualMethodForInterface()
should yield the same result for any matching method.

The new test 162-method-idx-clash exposes several cases
where we previously completely messed up due to the effects
of the DexCache, or where we were out of line with the RI.
It also tests a case where the JLS and the RI disagree and
we follow the JLS.

Test: art/test/run-test --host --jvm 162-method-resolution
Test: m test-art-host-gtest
Test: testrunner.py --host
Test: testrunner.py --host --interp-ac
Test: Nexus 6P boots.
Test: testrunner.py --target
Bug: 62855082
Bug: 30627598
Change-Id: If450c8cff2751369011d649c25d28a482a2c61a3
e431e2758d62cf56f7f347f5a8c9d79e41b6dcd7 19-Jul-2017 Steven Moreland <smoreland@google.com> art: use proper nativehelper headers

libnativeheader exports headers under nativeheader. These were
available before incorrectly as global headers in order to give
access to jni.h.

Test: modules using art find headers
Bug: 63762847
Change-Id: I5c820d677e94e07b2859e78610bc997fe51b41dc
88fd720b6799184c8ad61e766a6d37af33ed30ef 30-Jun-2017 Alex Light <allight@google.com> Add Jvmti Suspend/ResumeThread functions

Enable the can_suspend jvmti capability and implement all required
functionality associated with it.

Test: ./test.py --host -j40
Bug: 34415266
Bug: 62821960
Bug: 63579748

Change-Id: I83b92de7f81622e1658114b034918e8295805b6e
8c5e2dad9f585562f6a5b3ed2242a5d4a11fce3c 11-Jul-2017 Alex Light <allight@google.com> Move ThreadDeath event before clearing Thread.nativePeer

We were clearing the Thread.nativePeer field prior to calling
ThreadDeath event. Since this event can call into user-supplied code
we want to call it before we do any real cleanup.

Test: ./test.py --host -j40
Bug: 62117833

Change-Id: I6b93d82d23946c07dfbeb837d841339108e4b084
97c46466aea25ab63a99b3d1afc558f0d9f55abb 11-May-2017 Roland Levillain <rpl@google.com> Introduce a Marking Register in ARM64 code generation.

When generating code for ARM64, maintain the status of
Thread::Current()->GetIsGcMarking() in register X20,
dubbed MR (Marking Register), and check the value of that
register (instead of loading and checking a read barrier
marking entrypoint) in read barriers.

Test: m test-art-target
Test: m test-art-target with tree built with ART_USE_READ_BARRIER=false
Test: ARM64 device boot test
Bug: 37707231
Change-Id: Ibe9bc5c99a2176b0a0476e9e9ad7fcc9f745017b
6f1c7517a9e411e4000aa7b13743ed49e0c38bc0 06-Jul-2017 Andreas Gampe <agampe@google.com> ART: Make Touch's stack array smaller under ASAN

Under ASAN, especially on x86, there's a lot of overhead. To keep
below a single page, add a multiplier to the deduction.

Bug: 31098551
Bug: 62952017
Test: m
Test: SANITIZE_HOST=address SANITIZE_TARGET=address m ; manual assembly inspection
Change-Id: I8c80181e0fc5c6f4a1d3c6544f1a0e1089bb0631
46f9340f2a055a8fdfebbfbb739c697c20d83e7c 29-Jun-2017 Alex Light <allight@google.com> Add SuspendReason enum and change Suspension functions.

More self-documenting and more type safe.

Bug: 62821960
Test: ./test.py
Change-Id: Ic7a1ae6a25e687d65f5aa10c1aad54a7b80dd086
6c63f863f9dbf734732ff837c1e772b3482e59ff 29-Jun-2017 Andreas Gampe <agampe@google.com> ART: Change main-thread thread paging scheme

Modify the code that ensures we can install a stack guard page into
the main thread.

A recent kernel change means that our previous approach of using a
free pointer does not work. It is important to actually extend the
stack properly. For portability, use a function with a large stack
frame (suggested by and adapted from hboehm).

Bug: 62952017
Test: m
Test: m test-art-host
Test: Device boots (x86_64 emulator)
Test: Device boots (bullhead)
Change-Id: Ic2a0c3d6d05a1ea9f655329d147b46949e1b9db3
117f9b3a821e5a81673a9859488a5c05cdf901ac 23-Jun-2017 Andreas Gampe <agampe@google.com> ART: Fix issues in RequestSynchronousCheckpoint

Do not run the checkpoint for another thread while being suspended.
Only suspend while waiting for that thread to become suspended.

After decreasing the suspend count, broadcast on the resume condition,
to tell the thread that it may progress.

Bug: 62353392
Test: m test-art-host
Change-Id: I63082b1fac5ec1db6ac31199548b9ae3cb30ea47
28c4a233681040de4b2785ab5beef0a6d150e46a 22-Jun-2017 Andreas Gampe <agampe@google.com> ART: Fix RequestSynchronousCheckpoint

Fix the known races in the code by requiring more locks on entry.
This helps ensure there is no time in the caller where the thread
can die while requesting the checkpoint.

Fix up GetStackTrace, GetFrameCount and GetFrameLocation.

Bug: 62353392
Test: m test-art-host
Test: art/test/testrunner/testrunner.py -b --host -t 911
Change-Id: Ia0c5e920599b58098dc4b3a3d09c5284045f2947
36a296ff674e0aea16b29db965f84f81866b1375 13-Jun-2017 Andreas Gampe <agampe@google.com> ART: Refactor stack.h

Factor out LockCountData, ShadowFrame and JavaFrameRootInfo and leave
stack.h for the StackVisitor. Move single-use function to user to remove
DexFile dependency.

Test: m test-art-host
Change-Id: I53d2880917bdf6782856fd2b16f38a0293f3aefc
513061a792b22c417c938d31c19581390709561c 01-Jun-2017 Andreas Gampe <agampe@google.com> ART: Clean up thread.h and thread_list.h

Remove dependency on stack.h and gc_root.h. Remove unused object
callbacks include. Factor out ManagedStack into its own set of files.
Fix up users of transitive includes.

Test: m test-art-host
Change-Id: I01286c43d8c7710948c161b1348faabb05922e59
d49012909625c3bf87bf51138fe79315ce1b1bdc 31-May-2017 Andreas Gampe <agampe@google.com> ART: Clean up heap headers

Use more forward declarations for accounting structures and spaces.
Factor out structs to reduce header surface. Remove heap include where
unnecessary. Fix up transitive users. Move some debug-only code out
of line.

Test: m test-art-host
Change-Id: I16db4aaa803f39e155ce6e1b0778b7e393dcbb17
365719c23d809e595cf320bfba40e76bb4e87940 08-Mar-2017 Nicolas Geoffray <ngeoffray@google.com> No need to lock when calling Thread.interrupted.

Also intrinsify the Thread.interrupted call.

The rationale behind this optimization is that the flag can only
have two values, and only self can set it to false.

Test: libcore, jdwp, run-tests, 050-sync-test
Change-Id: I5c2b43bf872ba0bfafcb54b2cfcd19181864bc4c
3768adec2f819cb506577618fdde158ba659ddd4 02-May-2017 Mathieu Chartier <mathieuc@google.com> Revert "Revert "Add concurrent card graying for immune spaces""

Added an additional checkpoint before the concurrent graying to set
the mark entrypoints to non-null.

Bug: 37876887

Test: test-art-host

This reverts commit c83dd7bfde2171c879efb92a31a363505385ffb9.

Change-Id: I961c4631c9595c52cd7765f61b22b8291fef2088
c83dd7bfde2171c879efb92a31a363505385ffb9 02-May-2017 Mathieu Chartier <mathieuc@google.com> Revert "Add concurrent card graying for immune spaces"

Bug: 37876887

This reverts commit 88d329a698ba186aeb1f1ef8794355512ada84a9.

Test: mm

Change-Id: I93880fb7cd8c4c27c65777079d48947075f8cb64
88d329a698ba186aeb1f1ef8794355512ada84a9 27-Apr-2017 Mathieu Chartier <mathieuc@google.com> Add concurrent card graying for immune spaces

We now age the cards and gray the objects before the GC pause. This
is done to reduce how much work is required during the pause and
allows increasing the card size without regressing the GC pause
time.

We rescan the cards in the pause and only process the cards that were
dirtied since the concurrent graying.

Pause time spent graying objects on maps (Pixel). The average is the
per GC metric.

Disabled entrypoint switching for x86 and x86_64. This is to fix a
case where the gray bit is set but the entrypoint is null, resulting
in crashes.

Also reverted to checking "is gc marking" for x86 and x86_64 codegen
to prevent performance regressions.

128 byte cards without the change:
Sum: 1.912ms 99% C.I. 125us-244us Avg: 159.333us Max: 244us

512 byte cards without the change:
Sum: 12.027ms 99% C.I. 0.940ms-1.495ms Avg: 1.202ms Max: 1.495ms

512 byte cards with concurrent graying:
Sum: 1.385ms 99% C.I. 51us-239us Avg: 86.562us Max: 239us

Bug: 36457259
Bug: 12687968
Bug: 31022084

Test: test-art-host

(cherry picked from commit a3856d0d801f066b9b09649b3a17bdbb747f012d)

Change-Id: I7e8f8a5716f96dde827377234f854482452bc9cd
a3856d0d801f066b9b09649b3a17bdbb747f012d 27-Apr-2017 Mathieu Chartier <mathieuc@google.com> Add concurrent card graying for immune spaces

We now age the cards and gray the objects before the GC pause. This
is done to reduce how much work is required during the pause and
allows increasing the card size without regressing the GC pause
time.

We rescan the cards in the pause and only process the cards that were
dirtied since the concurrent graying.

Pause time spent graying objects on maps (Pixel). The average is the
per GC metric.

Disabled entrypoint switching for x86 and x86_64. This is to fix a
case where the gray bit is set but the entrypoint is null, resulting
in crashes.

Also reverted to checking "is gc marking" for x86 and x86_64 codegen
to prevent performance regressions.

128 byte cards without the change:
Sum: 1.912ms 99% C.I. 125us-244us Avg: 159.333us Max: 244us

512 byte cards without the change:
Sum: 12.027ms 99% C.I. 0.940ms-1.495ms Avg: 1.202ms Max: 1.495ms

512 byte cards with concurrent graying:
Sum: 1.385ms 99% C.I. 51us-239us Avg: 86.562us Max: 239us

Bug: 36457259
Bug: 12687968
Bug: 31022084

Test: test-art-host

Change-Id: Ib8d41bf14fd396956718b55c896f1eb4adf94215
a62b453e6fe8a606ae9239051802e6a8190d5970 26-Apr-2017 Mathieu Chartier <mathieuc@google.com> Use stack allocated context for VisitRoots

Prevents allocation of contexts for threads that do not throw
exceptions.

Saves up to 544 per thread on arm64.

Bug: 36457259

Test: mm test-art-host on with N6P target (build covers arm32, arm64)
Change-Id: I782a1115d624edcc1279fa2317d026408dfa8a10
c15a2f4f45661a7f5f542e406282c146ea1a968d 21-Apr-2017 Andreas Gampe <agampe@google.com> ART: Add object-readbarrier-inl.h

Move some read-barrier code into a new header. This prunes the
include tree for the concurrent-copying collector. Clean up other
related includes.

Test: mmma art
Change-Id: I40ce4e74f2e5d4c692529ffb4df933230b6fd73e
6bc7774426cc0b6bbab5566fa62b3c509455e583 19-Apr-2017 Mathieu Chartier <mathieuc@google.com> Use partial TLAB regions

Instead of having 256K TLAB regions, have 256K TLABs split into
16K regions. This fixes pathological cases with multithreaded
allocation that caused many GCs since each thread reserving
256K would often bump the counter past the GC start threshold. Now
threads only bump the counter every 16K.

System wide results (average of 5 samples on N6P):
Total GC time 60s after starting shell: 45s -> 24s
Average .Heap PSS 60s after starting shell: 57900k -> 58682k

BinaryTrees gets around 5% slower, numbers are noisy.

Boot time: 13.302 -> 12.899 (average of 100 runs)

Bug: 35872915
Bug: 36216292

Test: test-art-host

(cherry picked from commit bf48003fa32d2845f2213c0ba31af6677715662d)

Change-Id: I5ab22420124eeadc0a53519c70112274101dfb39
bf48003fa32d2845f2213c0ba31af6677715662d 19-Apr-2017 Mathieu Chartier <mathieuc@google.com> Use partial TLAB regions

Instead of having 256K TLAB regions, have 256K TLABs split into
16K regions. This fixes pathological cases with multithreaded
allocation that caused many GCs since each thread reserving
256K would often bump the counter past the GC start threshold. Now
threads only bump the counter every 16K.

System wide results (average of 5 samples on N6P):
Total GC time 60s after starting shell: 45s -> 24s
Average .Heap PSS 60s after starting shell: 57900k -> 58682k

BinaryTrees gets around 5% slower, numbers are noisy.

Boot time: 13.302 -> 12.899 (average of 100 runs)

Bug: 35872915
Bug: 36216292

Test: test-art-host

Change-Id: I5ab22420124eeadc0a53519c70112274101dfb39
1c8f4ff04062407db3d2dd834dd6bc24f6662c4d 14-Apr-2017 Sebastien Hertz <shertz@google.com> Always check result of Thread::ModifySuspendCount

Ensures that we never ignore the result of ModifySuspendCount so that
we can react if the suspend count is not updated as expected.

This CL does the following:
* Adds __attribute__((warn_unused_result)) on the method to raise an
error at compilation time if the result is ignored.
* Wraps calls with DCHECK where the result used to be ignored.

Bug: 27385848
Test: make -j test-art-host
Test: art/tools/run-jdwp-tests.sh --mode=host --variant=X64
Change-Id: I2d0e1ab7158c70ec8076c8bae6e4b814aee75af6
21cf95d8f34dc9cc20c75896a0cc4df9a8fd77e6 18-Apr-2017 Andreas Gampe <agampe@google.com> ART: Call ThreadGroup.add in Thread::FinishStartup

ART should add the main thread to the main ThreadGroup. Behavior
of the Thread constructor changed.

Bug: 37444210
Test: art/test/testrunner/testrunner.py -b --host -t 051
Test: m test-art-host
Test: m build-art-host && art/tools/run-libcore-tests.sh --mode=host
Change-Id: I92cf2f9a6c5c3fdf385eb7925addc38b64fa4d98
640a104d25db5a46a53c45e7132db577188729cc 20-Mar-2017 Brian Carlstrom <bdc@google.com> Avoid use of pthread_getschedparam (except on the Mac)

Squashed commit of two cherry-picks:

During Thread::DumpState the pthread may have exited.
We have the tid, use that instead.

Test: m -j50 test-art-host -k
Test: adb shell kill -3 `pid system_server`
Bug: 36445592

(cherry picked from commit 08e762782a1e352c329945e0df3f35da7e71ad8a)

Restore broken code for the Mac

Test: m -j48
Bug: 36445592

(cherry picked from commit 4b16f0b860f4d59601706305b2949b98db586a47)

Test: m -j48 && flashall && m -j8 test-art-host
Bug: 36445592
Change-Id: I96d51614f569338d85de0fd59188445df3289dfd
4b16f0b860f4d59601706305b2949b98db586a47 21-Mar-2017 Brian Carlstrom <bdc@google.com> Restore broken code for the Mac

Test: m -j48
Bug: 36445592
Change-Id: I50d1fbc62e057860f32838734333267419ea60ee
08e762782a1e352c329945e0df3f35da7e71ad8a 20-Mar-2017 Brian Carlstrom <bdc@google.com> Avoid use of pthread_getschedparam

During Thread::DumpState the pthread may have exited.
We have the tid, use that instead.

Test: m -j50 test-art-host -k
Test: adb shell kill -3 `pid system_server`
Bug: 36445592
Change-Id: Idb28fcb1f9232768d32966973fe9dbeb3fa74b56
efd20cb2f63cf647c7d947d00e8987affefeb177 01-Mar-2017 Josh Gao <jmgao@google.com> Catch signals that happen inside a fault handler.

Unblock some signals (SIGABRT, SIGBUS, SIGSEGV) that could happen
inside of the ART internal fault handlers, to report crashes inside of
the signal handler. Because we can't use sigaction to change the
handler when this happens, because it modifies global state, add a new
member variable in Thread to track whether a call to the fault handler
is reentrant or not.

Remove the old nested signal implementation that attempted to do this.

Bug: http://b/35853436
Test: changed the #if 0 to #if 1, ran a dummy process that
threw a NullPointerException, inspected logcat
Change-Id: I04bb4a09433c6817933d64ec681ec433b528f2a5
374cd2c4262a718f9e2e984b14553885f1e5e255 15-Feb-2017 Nicolas Geoffray <ngeoffray@google.com> Emit the dex_pc if the line number is absent.

bug:30183883
Test: test-art-host run-libcore-tests run-jdwp-tests
Test: art/test/638-no-line-number/

Change-Id: I5ab54620b2bfba1059543696ff7310b8496b1893
bad529da18122c7044fbfd7d56153535d34367b1 14-Feb-2017 Andreas Gampe <agampe@google.com> ART: Add currentThread cutout to Unstarted Runtime

Add currentThread() and getThreadState() cutouts to the unstarted
runtime to allow further compile-time initialization. The cutouts
are protected by call-stack checks.

Add tests.

Bug: 34956610
Test: m test-art-host-gtest-unstarted_runtime_test
Change-Id: I6335bccda8bedae90376fc7c47b303576f1ac78b
fa4333dcb481e564f54726b4e6f8153612df835e 14-Feb-2017 Andreas Gampe <agampe@google.com> ART: Add operator == and != with nullptr to Handle

Get it in line with ObjPtr and prettify our code.

Test: m
Change-Id: I1322e2a9bc7a85d7f2441034a19bf4d807b81a0e
ffc8cad04135192a8d10e7f38bd97c48101294a8 10-Feb-2017 Nicolas Geoffray <ngeoffray@google.com> Add a DCHECK in thread::GetPeer.

Motivated by https://android-review.googlesource.com/#/c/333205/.

Test: test-art-host run-jdwp-test.sh
Change-Id: I173c060324aa0dc39144db55e3a97e672c012ba8
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
02f365f0fb74acf09ffb8f04a80d32ca1152ed8b 04-Feb-2017 Hiroshi Yamauchi <yamauchi@google.com> Force stack dump to diagnose empty checkpoint timeout (2).

Bug: 33006388
Bug: 12687968
Test: test-art-host
Test: Thread dumping in a simulated empty checkpoint timeout.

Change-Id: I06641396b8f3d7a1a98366a01807aab2e6f31bd5
202f85a54bfd1844664a18c18a4c0494763c6b82 06-Feb-2017 Andreas Gampe <agampe@google.com> ART: Add marking to thread peer gathering in TI

When CC is marking, we may get stale references due to a missing
mark.

Bug: 34760612
Test: ART_TEST_JIT=true ART_TEST_GC_STRESS=true test-art-host-run-test-924-threads
Test: ART_TEST_JIT=true ART_TEST_GC_STRESS=true test-art-host-run-test-925-threadgroups
Change-Id: I1becfc188b59a3c99cc7eea07c63abaaf108fd15
90b936ddda63139ff46a6755c3b83ad6e4ab4ac5 31-Jan-2017 Andreas Gampe <agampe@google.com> ART: Refactor verify_object.h

Move the actual VerifyObject check into a new cc file, as we
commonly don't enable the check at all. This allows to cut the
-inl include from almost all current users.

This also exposes missing -inl includes. Also fix up some of our old
mess where .h defined functions require -inl.h defined functions.

Test: m

Change-Id: I3dd821bbe2015564a29bf1ed9be00f7a7276ad61
65b8bb2f5948d2a80a347472293f6ef3c7f7f766 01-Feb-2017 Mathieu Chartier <mathieuc@google.com> Faster stack trace creation

Cache stack frames from the counting visitor to avoid needing to
walk the stack twice in the common case.

Speeds up pmd benchark by 20%.

Test: test-art-host

Change-Id: I81e4e55280d9c1ccf1937a7ea12abff75e9abb94
1a20b6801f2432a42b906f0de01e7e9586526aec 31-Jan-2017 Mathieu Chartier <mathieuc@google.com> Deduplicate register masks

Data is commonly shared between different stack maps. The register
masks are stored after the stack masks.

Oat size for a large app:
96722288 -> 94485872 (-2.31%)

Average oat size reduction according to golem -3.193%.

Bug: 34621054

Test: test-art-host

Change-Id: I5eacf668992e866d11ddba0c01675038a16cdfb4
13c1635e07b8ee09120e267e2abe860aee05db7c 31-Jan-2017 Hiroshi Yamauchi <yamauchi@google.com> Force stack dump to diagnose empty checkpoint timeout.

Bug: 33006388
Bug: 12687968
Test: test-art-host
Change-Id: Ida149c98eeb05ca4ad8d0f7ef49228c9b45a6312
45aa598cd1773f5eb1705dec13bea059238e054d 18-Mar-2016 David Srbecky <dsrbecky@google.com> Deduplicate stack masks

The stack masks repeat often enough so that it is worth deduplicating
them.

Oat size for a large app:
98143600 -> 96722288 (-1.44%)

Bug: 34621054

Test: test-art-host
Change-Id: If73d51e46066357049d5be2e406ae9a32b7ff1f4
433b79a9130df5f2375b9d3d7518c1f3fb84a467 30-Jan-2017 Nicolas Geoffray <ngeoffray@google.com> Revert "Revert "Make --debuggable rely on JIT code.""

Fixed by https://android-review.googlesource.com/#/c/330165/

This reverts commit 81356645157af44152c7b7db383596b5cf3479b5.

Change-Id: Ifb74e1cc90ab6dea621f7f54a00b540d6ccd0cf6
81356645157af44152c7b7db383596b5cf3479b5 30-Jan-2017 Vladimir Marko <vmarko@google.com> Revert "Make --debuggable rely on JIT code."

Breaks 137-cfi with ART_TEST_RUN_TEST_DEBUGGABLE=true

This reverts commit a0619e25aacf8b8074132f4951f75fdbcfd42925.

bug: 28769520
Change-Id: Ifd7b8fc7c9b72c0a523fd57c4b1b80edd3547caa
a0619e25aacf8b8074132f4951f75fdbcfd42925 20-Dec-2016 Nicolas Geoffray <ngeoffray@google.com> Make --debuggable rely on JIT code.

Removes -Xfully-deoptable in the process, which was added as a
temporary workaround until this CL.
Partial revert of https://android-review.googlesource.com/#/c/302232/

Makes things consistent with existing infrastructure:

- Parse the --debuggable from the compiler options, just like
--compiler-filter.

- Add DEBUG_JAVA_DEBUGGABLE, passed by the zygote, for debuggable apps.

- Java debuggable now solely relies on JIT for simplicity.

- Debugging under userdebug for non-java-debuggable apps is still
best effort.

Test: test-art-host, jdwp

bug: 28769520
Change-Id: Id0593aacd85b9780da97f20914a50943957c858f
12f1b99775bbf7dd82d0a897587ab6ed0e75ee22 20-Jan-2017 Mathieu Chartier <mathieuc@google.com> Remove alignment bits in between stack maps

Saves 0.65% of boot.oat size, probably similar on apps. Added
BitMemoryRegion to avoid requiring adding state to StackMap. Added
test to memory_region_test.

Test: clean-oat-host && test-art-host

Bug: 34621054

Change-Id: I40279c59e262bd5e3c6a9135f83e22b5b6900d68
b048cb74b742b03eb6dd5f1d6dd49e559f730b36 23-Jan-2017 Nicolas Geoffray <ngeoffray@google.com> Add per array size allocation entrypoints.

- Update architectures that have fast paths for
array allocation to use it.
- Will add more fast paths in follow-up CLs.

Test: test-art-target test-art-host.
Change-Id: I138cccd16464a85de22a8ed31c915f876e78fb04
732b0aca4fb8e5ffbd518ca913cb82810b6b2061 19-Jan-2017 Andreas Gampe <agampe@google.com> ART: Add Agent Thread API

Add support for RunAgentThread. Add test.

Bug: 31684593
Test: m test-art-host-run-test-931-agent-thread
Change-Id: I5deb213fb06eedc5ee78a340458cf0dff615d0ac
ac30fa2151095d2b5fe42f169a02ed09fea312b4 19-Jan-2017 Andreas Gampe <agampe@google.com> ART: Make RuntimeCallbacks unique_ptr

Reduce the transitive closure of headers on runtime.h

Test: m
Change-Id: Ib5a3632c28b08bf07773f217a7ad711c1f12af6b
04bbb5be5b9c0f0b3a72116353d23ea63c8bc5e9 19-Jan-2017 Andreas Gampe <agampe@google.com> Revert "Revert "ART: Start RuntimeCallbacks""

This reverts commit bf6331a45f730e1f1044af2ce43bceda660ae6fc.

Switch to using the mutator lock.

Bug: 31684920
Test: m test-art-host-gtest-runtime_callbacks_test
Test: art/tools/run-jdwp-tests.sh --mode=host --debug
Change-Id: I6ce0f71de2aa9f90cd23cfca7723a793b560b16b
8d91ac31ccb92557e434d89ffade3372466e1af5 18-Jan-2017 Nicolas Geoffray <ngeoffray@google.com> Remove unused array entrypoints.

Test: test-art-host test-art-target
Change-Id: I910d1c912c7c9056ecea0e1e7da7afb2a7220dfa
bf6331a45f730e1f1044af2ce43bceda660ae6fc 19-Jan-2017 Nicolas Geoffray <ngeoffray@google.com> Revert "ART: Start RuntimeCallbacks"

jdwp tests failing with:
STDERR> dalvikvm32 E 01-18 23:14:50 12180 12198 thread-inl.h:137] holding "runtime callbacks lock" at point where thread suspension is expected

Bug: 31684920

This reverts commit 13093d455b8266338fd713b04261c58e9dc2b164.

Change-Id: I94e4154e273d006eecdd485607dcfd96392d6a00
13093d455b8266338fd713b04261c58e9dc2b164 18-Jan-2017 Andreas Gampe <agampe@google.com> ART: Start RuntimeCallbacks

Add a central RuntimeCallbacks structure to handle certain interesting
runtime events.

In a first iteration, add ThreadLifecycleCallback with ThreadStart and
ThreadStop. Move Dbg over to ThreadLifecycleCallback.

Add a test.

Bug: 31684920
Test: m test-art-host-gtest-runtime_callbacks_test
Test: art/tools/run-jdwp-tests.sh --mode=host
Change-Id: Ie0f77739a563207bfb4f04374e72dc6935c40b4f
39cee66a8ddf0254626c9591662cf87e4a1cedc4 13-Jan-2017 Nicolas Geoffray <ngeoffray@google.com> Entrypoints cleanup.

Remove unused ones to facilitate the transition to compressed
dex caches.

test: test-art-host, test-art-target
Change-Id: I1d1cb0daffa86dd9dda2eaa3c1ea3650a5c8d9d0
ac141397dc29189ad2b2df41f8d4312246beec60 13-Jan-2017 Orion Hodson <oth@google.com> Revert "Revert "ART: Compiler support for invoke-polymorphic.""

This reverts commit 0fb5af1c8287b1ec85c55c306a1c43820c38a337.

This takes us back to the original change and attempts to fix the
issues encountered:

- Adds transition record push/pop around artInvokePolymorphic.
- Changes X86/X64 relocations for MacSDK.
- Implements MIPS entrypoint for art_quick_invoke_polymorphic.
- Corrects size of returned reference in art_quick_invoke_polymorphic
on ARM.

Bug: 30550796,33191393
Test: art/test/run-test 953
Test: m test-art-run-test

Change-Id: Ib6b93e00b37b9d4ab743a3470ab3d77fe857cda8
0d3998b5ff619364acf47bec0b541e7a49bd6fe7 12-Jan-2017 Nicolas Geoffray <ngeoffray@google.com> Revert "Revert "Make object allocation entrypoints only take a class.""

This reverts commit f7aaacd97881c6924b8212c7f8fe4a4c8721ef53.

Change-Id: I6756cd1e6110bb45231f62f5e388f16c044cb145
f7aaacd97881c6924b8212c7f8fe4a4c8721ef53 12-Jan-2017 Hiroshi Yamauchi <yamauchi@google.com> Revert "Make object allocation entrypoints only take a class."

960-default-smali64 is failing.

This reverts commit 2b615ba29c4dfcf54aaf44955f2eac60f5080b2e.

Change-Id: Iebb8ee5a917fa84c5f01660ce432798524d078ef
0fb5af1c8287b1ec85c55c306a1c43820c38a337 11-Jan-2017 Orion Hodson <oth@google.com> Revert "ART: Compiler support for invoke-polymorphic."

This reverts commit 02e3092f8d98f339588e48691db77f227b48ac1e.

Reasons for revert:

- Breaks MIPS/MIPS64 build.
- Fails under GCStress test on x64.
- Different x64 build configuration doesn't like relocation.

Change-Id: I512555b38165d05f8a07e8aed528f00302061001
02e3092f8d98f339588e48691db77f227b48ac1e 01-Dec-2016 Orion Hodson <oth@google.com> ART: Compiler support for invoke-polymorphic.

Adds basic support to invoke method handles in compiled code.

Enables method verification for methods containing invoke-polymorphic.

Adds k45cc/k45rc output to Instruction::DumpString() which
was found to be missing when enabling verification.

Include stack traces in test 957-methodhandle-transforms for
failures so they can be easily identified.

Bug: 30550796,33191393
Test: art/test/run-test 953
Test: m test-art-run-test
Change-Id: Ic9a96ea24906087597d96ad8159a5bc349d06950
2b615ba29c4dfcf54aaf44955f2eac60f5080b2e 06-Jan-2017 Nicolas Geoffray <ngeoffray@google.com> Make object allocation entrypoints only take a class.

Change motivated by:
- Dex cache compression: having the allocation fast path do a
dex cache lookup will be too expensive. So instead, rely on the
compiler having direct access to the class (either through BSS for
AOT, or JIT tables for JIT).
- Inlining: the entrypoints relied on the caller of the allocation to
have the same dex cache as the outer method (stored at the bottom of
the stack). This meant we could not inline methods from a different
dex file that do allocations. By avoiding the dex cache lookup in
the entrypoint, we can now remove this restriction.

Code expansion on average for Docs/Gms/FB/Framework (go/lem numbers):
- Around 0.8% on arm64
- Around 1% for x64, arm
- Around 1.5% on x86

Test: test-art-host, test-art-target, ART_USE_READ_BARRIER=true/false
Test: test-art-host, test-art-target, ART_DEFAULT_GC_TYPE=SS ART_USE_TLAB=true

Change-Id: I41f3748bb4d251996aaf6a90fae4c50176f9295f
f5769e15aa9f058a5af987f0d1354f16f4464a7d 11-Jan-2017 Mathieu Chartier <mathieuc@google.com> Move most of art::Thread to ObjPtr

Bug: 31113334

Test: test-art-host

Change-Id: I73d0de3c875d3ec3d732034fdc961dae79ef4070
ccd56958eb46fbb00c1eb45c7a7b23d5bbfd7698 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)

Bug: 32602185
Bug: 33067273

Test: m test-art-host-run-test; m test-art-host-gtest
Change-Id: I97dda7a5444643db3c5d5318339a65a602f709e8
46ee31b67d7ee1bd085fbc240502053caa3cf8fa 14-Dec-2016 Andreas Gampe <agampe@google.com> ART: Move to libbase StringPrintf

Remove ART's StringPrintf implementation. Fix up clients. Add
missing includes where necessary.

Test: m test-art-host
Change-Id: I564038d5868595ac3bb88d641af1000cea940e5a
9186ced255f2e7402646b5b286deebb540640734 12-Dec-2016 Andreas Gampe <agampe@google.com> ART: Clean up utils.h

Remove functionality provided by libbase. Move some single-use
functions to their respective users.

Test: m test-art-host
Change-Id: I75594035fa975200d638cc29bb9f31bc6e6cb29f
585da955bc8e5040705dcfd941b2131025ebcef8 02-Dec-2016 Andreas Gampe <agampe@google.com> ART: Add precise root visiting

Add VisitRootFlags::kVisitRootFlagPrecise to signal a
request for precise RootInfo objects.

Move VisitRootFlags to gc_root.h. Refactor VisitRoot
functions to pass flags. Add code in Thread visiting
to decode vregs in compiled code.

Bug: 31385354
Test: m test-art-host
Change-Id: I8e7280f0ab682871f729f2a1c6b18670cf2dbf82
a82769c1168d38fb4d36eaecfc186aecb17d4b16 03-Dec-2016 Hiroshi Yamauchi <yamauchi@google.com> Dump more debug info for b/33006388.

Bug: 33006388
Bug: 12687968
Test: test-art-host with CC.
Change-Id: Id9d67bc603c6ff7bc8e346e181e3e09ffbda43b3
2c19f5b12cd4cd446fda6b4dd05397e9f8424dc3 28-Nov-2016 Andreas Gampe <agampe@google.com> ART: Clean up Thread

Move debug code to .cc, simplify includes.

Test: m test-art-host
Change-Id: I5e66a54223a8f965a46fb14021d0e29aa2496ed1
5ace201d84adb7753680bf4c7877b3b71558da82 30-Nov-2016 Mathieu Chartier <mathieuc@google.com> Revert "Revert CC related changes."

Disable entrypoint switching in ResetQuickAllocEntryPointsForThread
instead of callers. Fixes bug where instrumentation would switch
to non CC entrypoints for non X86_64 architectures causing aborts.

Bug: 31018974

Test: test-art-host
Test: test/run-test 099

This reverts commit 96172e0172c5fca6e9a5ad4b857a24d8c7b064e5.

Change-Id: If206694ae35ff4446c6a8a97bfbcbf2dac35e3f9
96172e0172c5fca6e9a5ad4b857a24d8c7b064e5 30-Nov-2016 Nicolas Geoffray <ngeoffray@google.com> Revert CC related changes.

Revert: "X86_64: Add allocation entrypoint switching for CC is_marking"
Revert: "Fix mips build in InitEntryPoints"
Revert: "Fix mac build in ResetQuickAllocEntryPoints"

Test: test-art-target-run-test
Change-Id: If38d44edf8c5def5c4d8c9419e4af0cd8d3be724
340dafabc8e88378e395cda9027cf17726910e91 18-Nov-2016 Nicolas Geoffray <ngeoffray@google.com> Use a per-thread VerifierDeps.

Avoid lock contention on a singleton VerifierDeps by allocating
temporary per-thread VerifierDeps that get merged after verification.

This saves around ~35% compile-times on interpret-only.

Only the creation of extra strings is guarded by a lock, for simplicity.

Test: test-art-host, test-art-target
bug: 32641252
bug: 30937355

Change-Id: I11a2367da882b58e39afa7b42cba2e74a209b75d
f5de23265360e15fcfceb7d07bdadca0e5bb5f0a 16-Nov-2016 Mathieu Chartier <mathieuc@google.com> X86_64: Add allocation entrypoint switching for CC is_marking

Only X86_64 done so far. Use normal TLAB allocators if GC is not
marking.

Allocation speed goes up by ~8% based on perf sampling.

Without change:
1.19%: art_quick_alloc_object_region_tlab

With change:
0.63%: art_quick_alloc_object_tlab
0.47%: art_quick_alloc_object_region_tlab

Bug: 31018974
Bug: 12687968

Test: test-art-host-run-test

Change-Id: I4c4d9eb229d4ad2f41b856ba5c2958a5eb3b7ffa
fe814e89965ddf9a8b603863bd28259f8dd7be35 09-Nov-2016 Mathieu Chartier <mathieuc@google.com> Use entrypoint switching to reduce code size of GcRoot read barrier

Set the read barrier mark register entrypoints to null when the GC
is not marking. The compiler uses this to avoid needing to load the
is_gc_marking boolean.

Code size results on ritzperf CC:
arm32: 13439400 -> 13242792 (-1.5%)
arm64: 16380544 -> 16208512 (-1.05%)

Implemented for arm32 and arm64. TODO: Consider implementing on x86.

Bug: 32638713
Bug: 29516974

Test: test-art-host + run ritzperf
Change-Id: I527ca5dc4cd43950ba43b872d0ac81e1eb5791eb
3049324f4ef71b5d7a3de49bd77c75f07dbf8f3a 03-Nov-2016 Hiroshi Yamauchi <yamauchi@google.com> Make empty checkpoint work while weak ref access is disabled.

Fix a potential race on PushOntoMarkStack for CC by running an empty
checkpoint (while weak ref access is disabled).

Bug: 32508093
Bug: 12687968
Test: test-art-host with CC/CMS, libartd boot with N9, Ritz EAAC.
Change-Id: I3749bb525e7734804307ee16262355f3fc730312
08883debd927d18c9ecf66683a2a11aa98165656 08-Nov-2016 Andreas Gampe <agampe@google.com> ART: Refactor jfieldID handling

ArtField objects have been native since Marshmallow.
Remove the dependency on being runnable. Refactor the
code into the jni_internal header.

Test: m test-art-host
Change-Id: I46708c70f9b4b566d7e26e4c5ffc3f0cbadc43fa
b99f4d6463e7cb5654af3893ed7b3113665df658 08-Nov-2016 Mathieu Chartier <mathieuc@google.com> Change check cast entrypoint to check instance of

Reduces code size since we do not need to reload class before
calling slow path.

TODO: Delete read barriers in the check cast code since the slow
path will retry with the proper read barriers if the check fails.

Bug: 12687968
Bug: 29516974

Test: test-art-host + test-art-target with CC

Change-Id: Ia4eb9bbe3fe2d2016e44523cf0451210828d7b88
13b27842e88ccf1a42807c92daeb108e867dc4cd 08-Nov-2016 Andreas Gampe <agampe@google.com> ART: Refactor jmethodID handling

ArtMethod objects have been native since Marshmallow.
Remove the dependency on being runnable. Refactor the
code into the jni_internal header.

Test: m test-art-host
Change-Id: I1385fcd4c08981491701da55a87036b447aa2fc2
e9f67125f9a9c54b226c7daa95ebd0c5b31e8510 28-Oct-2016 Andreas Gampe <agampe@google.com> ART: Add synchronous checkpoint

Add a thread function that will run the given checkpoint function
on the thread and wait for its completion.

Bug: 31684812
Test: m test-art-host
Change-Id: Icbb9f3a6b0bbf31e62be0508714ee172456bea29
0a85576a71adb9af631c9b9f5e48f21888313c14 26-Oct-2016 Andreas Gampe <agampe@google.com> ART: Clean up Thread

Make some functions private. Move some test-only functionality to
the test using it.

Test: m test-art-host
Change-Id: Ic84c8bcb150f991c6fc264c2d490363a3bd3e1f4
dc061d038e4e48fe2a967fd4a9c200d112df5698 24-Oct-2016 Andreas Gampe <agampe@google.com> ART: Clean up IndirectReferenceTable

Introduce constants and move some functions into the
IndirectReferenceTable class.

Slightly change IndirectRef encoding to be more obvious (and slighly
more optimized when decoding).

Bug: 32125344
Test: m test-art-host
Change-Id: I05819eccb733b611de582fb8d7151f1a110c305a
da0a69edb24122d3d35ce1483c5ab94de919d714 11-Oct-2016 Richard Uhler <ruhler@google.com> Return error message if IndirectReferenceTable construction fails.

Previously if there was an error when constructing the
IndirectReferenceTable, the error message was lost. Now expose and
include the error message when throwing an exception related to
failures to construct the IndirectReferenceTable.

The error message is propagated through JVMEnvExt, JavaVMExt, and
Runtime::Init as well.

Bug: 32013594
Test: Added new 151-OpenFileLimit runtest.
Test: m test-art-host, m test-art-target

Change-Id: I3692f6928c9570358571bce634569d6f14cdeb05
709b070044354d9f47641f273edacaeeb0240ab7 13-Oct-2016 David Sehr <sehr@google.com> Remove mirror:: and ArtMethod deps in utils.{h,cc}

The latest chapter in the ongoing saga of attempting to dump a DEX
file without having to start a whole runtime instance. This episode
finds us removing references to ArtMethod/ArtField/mirror.

One aspect of this change that I would like to call out specfically
is that the utils versions of the "Pretty*" functions all were written
to accept nullptr as an argument. I have split these functions up as
follows:
1) an instance method, such as PrettyClass that obviously requires
this != nullptr.
2) a static method, that behaves the same way as the util method, but
calls the instance method if p != nullptr.
This requires using a full class qualifier for the static methods,
which isn't exactly beautiful. I have tried to remove as many cases
as possible where it was clear p != nullptr.

Bug: 22322814
Test: test-art-host
Change-Id: I21adee3614aa697aa580cd1b86b72d9206e1cb24
28bd2e4f151267b34b8e1eb19c489d8d547bbf5c 04-Oct-2016 Mathieu Chartier <mathieuc@google.com> Move mirror::Class to use ObjPtr

Leave the return types as non ObjPtr for now. Fixed moving GC bugs
in tests.

Test: test-art-host

Bug: 31113334

Change-Id: I5da1b5ac55dfbc5cc97a64be2c870ba9f512d9b0
e8a3c576301fd531d5f73a65fc8b84a63619d580 12-Oct-2016 Mathieu Chartier <mathieuc@google.com> Replace StackHandleScopeCollection with VariableSizedHandleScope

VariableSizedHandleScope's internal handle scopes are not pushed
directly on the thread. This means that it is safe to intermix with
other types of handle scopes.

Added test.

Test: clean-oat-host && test-art-host

Change-Id: Id2fd1155788428f394d49615d337d9134824c8f0
9d156d500801accee919b6d51e22d6ddcdcd4a05 07-Oct-2016 Mathieu Chartier <mathieuc@google.com> Move Heap parameters to ObjPtr

Deleted some unused object dumping code.

Test: test-art-host

Bug: 31113334

Change-Id: I747220caafe6679591fd4b361d7f50383a046164
c4f3925490a73da8dc74884a1deb965d4ecaf14e 06-Oct-2016 Mathieu Chartier <mathieuc@google.com> Move remaining jobject related functions to use ObjPtr

Also added ObjPtr::DownCast.

Bug: 31113334

Test: test-art-host

Change-Id: I59c253211dc435579ffdfd49f856861ab13d262c
02e7f1a46d8dbb277d045182cd1fa4b058d55162 04-Oct-2016 Hiroshi Yamauchi <yamauchi@google.com> Fix a deadlock between thread flip and suspend request.

See 31683379#9 for the deadlock scenario.

Make ModifySuspendCount(+1) retry if the thread flip function is set.

Bug: 31683379
Bug: 12687968
Test: test-art, N9 libartd boot, Ritz EAAC with CC.
Test: 129-GetThreadId with gcstress and CC.
Change-Id: Id5cdfcd90a08a2ff497f9f0e2842fa4c613549bc
8778c521de4f686118549ef7b20ae497e53b9e93 05-Oct-2016 Mathieu Chartier <mathieuc@google.com> Change indirect reference table to use ObjPtr

Bug: 31113334

Test: test-art-host

Change-Id: I340fdf430897ebd790ea4e35f94bcee776e98445
1cc62e4ea24828fdb3f3da0b8603f0b107d09a04 04-Oct-2016 Mathieu Chartier <mathieuc@google.com> Rename ObjPtr::Decode to ObjPtr::Ptr

Done to prevent ambiguity with ScopedObjectAccess::Decode.

Bug: 31113334

Test: test-art-host
Change-Id: I07a2497cc9cf66386311798933547471987fc316
3398c7874e002beaa6c2b2fadf183e7d1ddad23a 30-Sep-2016 Mathieu Chartier <mathieuc@google.com> Move ArtField to ObjPtr

Added EXPECT_OBJ_PTR_EQ and variants to gtests.

Fixed moving GC bugs in:
ClassLinker::CreatePathClassLoader
ClassLinkerTest: StaticFields

ObjPtr Decode call sites: 186 -> 181.

Some tests fail due to ResolvedFieldAccessTest, will fix in follow
up CL.

Bug: 31113334

Test: test-art-host CC baker

Change-Id: I8b266ad00f3c20c8cbe7cfdf280d175083df0b88
0795f23920ee9aabf28e45c63cd592dcccf00216 28-Sep-2016 Mathieu Chartier <mathieuc@google.com> Clean up ScopedThreadStateChange to use ObjPtr

Also fixed inclusion of -inl.h files in .h files by adding
scoped_object_access-inl.h and scoped_fast_natvie_object_access-inl.h

Changed AddLocalReference / Decode to use ObjPtr.

Changed libartbenchmark to be debug to avoid linkage errors.

Bug: 31113334

Test: test-art-host

Change-Id: I4d2e160483a29d21e1e0e440585ed328b9811483
da079bba8403733cac9bb7415b038ffd77e62403 26-Sep-2016 Nicolas Geoffray <ngeoffray@google.com> Cleanup String.<init> handling.

Move everything to one place (currently well_known_classes.cc, but
no strong preference) and define a macro to easily handle the list
of affected methods.

test: m test-art-host
test: m test-art-target
Change-Id: Ib8372d130d5458516a1f1ae31014afc76037fc34
d6e54bbc09595465309aa7909b7a3965defe4419 26-Sep-2016 Andreas Gampe <agampe@google.com> ART: Fix nits

Follow-up to commit 3fec9ac0d5af1358d216eb2fdc2000ec0205f3f0.

Bug: 31338270
Test: m test-art-host
Change-Id: Ia50f450bef144167b946224c26242c529302996e
3fec9ac0d5af1358d216eb2fdc2000ec0205f3f0 13-Sep-2016 Andreas Gampe <agampe@google.com> ART: Use libbase logging

Move most of our logging infrastructure over to system/core/base.
Retain VLOG.

Using unified Android infrastructure has two main advantages. First,
it reduces the complexity/maintenance burden in ART. Second, it
allows to detach logging for the cases where we do not want or need
a runtime, e.g., dexdump, the disassembler, etc. As a part of the
latter, libbase is also supported for all hosts (including Windows).

From a developer viewpoint, there are minor behavior changes for the
LOG statements (see above), but otherwise usage is the same. Explicit
severity enum items are in the android::base namespace now.

Bug: 31338270
Test: m test-art-host
Change-Id: I5abcb2f45f5b03d49951874c48544f72a283a91b
9323e6e44060545d6c4f925139572868f65b7fe3 13-Sep-2016 David Sehr <sehr@google.com> Separate annotations from dexfile reading.

Bug: 22322814
Change-Id: I867d66da407dd80394a10d19903ebbc1ec3986ff
Test: test-art
05846475c8d48ce191dcd333c76d5ccc17aea9dd 14-Sep-2016 Vladimir Marko <vmarko@google.com> Remove ThrowNoSuchMethod entrypoint.

Run ART test suite on host and Nexus 6.
Bug: 31464666
Change-Id: I5aa737726031adae0b132f759cf802a93d581a7f
eb1680f0365a5b2dd10dd38982cf716ac6fd8c84 12-Sep-2016 Hiroshi Yamauchi <yamauchi@google.com> Add a debug check for unsaved callee-save register for diagnosis.

Bug: 29231980
Bug: 12687968
Test: test-art-host with CC.
Change-Id: I385ce7712e63072a0664d86414605d23ef44401b
bdf7f1c3ab65ccb70f62db5ab31dba060632d458 31-Aug-2016 Andreas Gampe <agampe@google.com> ART: SHARED_REQUIRES to REQUIRES_SHARED

This coincides with the actual attribute name and upstream usage.
Preparation for deferring to libbase.

Test: m
Test: m test-art-host
Change-Id: Ia8986b5dfd926ba772bf00b0a35eaf83596d8518
ee23582af60b36f982de2ad16f485a61f35ae817 20-Aug-2016 Hiroshi Yamauchi <yamauchi@google.com> Revert "Revert "Improve the thread flip.""

This reverts commit db3204f87c3f7c4de89762ce9e8502a9dc25c2d8.

Improve the thread flip.

- In addition to the threads that are suspended in FullSuspendCheck(),
prioritize the resume of threads that are blocking for the thread
flip at the JNI critical section entry and threads are about to
transition to runnable (eg. blocking at the SOA entry from JNI).
- Shorten the length of the thread flip critical
section (ThreadFlipBegin/End).
- Add some systrace scopes.
- Add a read barrier for the locked objects during the thread dump in
case the thread is in the middle of flipping.

Bug: 30980189
Bug: 29517059
Bug: 12687968
Test: test-art-host, Ritz EAAC, N9 libartd boot
Change-Id: I3a903c47c0fcc746664ec376cc31dee8af3c3ecb
db3204f87c3f7c4de89762ce9e8502a9dc25c2d8 19-Aug-2016 Hiroshi Yamauchi <yamauchi@google.com> Revert "Improve the thread flip."

This reverts commit e61e6fdd404b8f04bd33fc3ea49e38e92e31ad69.

ThreadStress failing.

Bug: 29517059
Bug: 12687968
Change-Id: I0ee8ef04f77c5f9378e4bd21c5dedb4e435a2dc6
e61e6fdd404b8f04bd33fc3ea49e38e92e31ad69 03-Aug-2016 Hiroshi Yamauchi <yamauchi@google.com> Improve the thread flip.

- In addition to the threads that are suspended in FullSuspendCheck(),
prioritize the resume of threads that are blocking for the thread
flip at the JNI critical section entry and threads are about to
transition to runnable (eg. blocking at the SOA entry from JNI).
- Shorten the length of the thread flip critical
section (ThreadFlipBegin/End).
- Add some systrace scopes.

Bug: 29517059
Bug: 12687968
Test: test-art-host, Ritz EAAC, N9 libartd boot.
Change-Id: Idecec9936ae432c23d5f83321ba13339852018df
9d4b6da934934c322536ee3309b63ce402740f49 29-Jul-2016 Igor Murashkin <iam@google.com> jni: Fast path for @FastNative annotated java methods

Adds a faster path for java methods annotated with
dalvik.annotation.optimization.FastNative .

Intended to replace usage of fast JNI (registering with "!(FOO)BAR" descriptors).

Performance Microbenchmark Results (Angler):
* Regular JNI cost in nanoseconds: 115
* Fast JNI cost in nanoseconds: 60
* @FastNative cost in nanoseconds: 36

Summary: Up to 67% faster (vs fast jni) JNI transition cost

Change-Id: Ic23823ae0f232270c068ec999fd89aa993894b0e
5dd44d0da7999ab62f09a1bf03345280811736d4 03-Aug-2016 Andreas Gampe <agampe@google.com> ART: Factor out native stack dumping

Move DumpNativeStack and DumpKernelStack into a new file to keep
concerns separated. Clean up the file.

In preparation for modifications to how we use addr2line.

Bug: 30351473
Test: m test-art-host
Test: manual host testing with a test that times out
Change-Id: I02d5645952fe94fd8e73bcf0522721547f6cef66
5cbe65d3c9b4e7d89c35ba47e2bff7d8aa0dc250 22-Jul-2016 Tobias Thierer <tobiast@google.com> Use Thread.dispatchUncaughtException() rather than duplicating logic.

Previously, the runtime duplicated the logic in Thread's methods
dispatchUncaughtException() and getUncaughtExceptionHandler().
Since we're modifying this logic to ensure that uncaught
exceptions are logged, this CL changes the runtime to call
dispatchUncaughtException instead. This also has the benefit
that we can remove Thread.UncaughtExceptionHandler from the
list of well known classes.

Test: art/tools/run-libcore-tests.sh --mode=host --variant=X32
Bug: 29624607
Change-Id: Id7161d841d64ff9d8f2a7ec1c8c0c5c911ff0b64
542451cc546779f5c67840e105c51205a1b0a8fd 26-Jul-2016 Andreas Gampe <agampe@google.com> ART: Convert pointer size to enum

Move away from size_t to dedicated enum (class).

Bug: 30373134
Bug: 30419309
Test: m test-art-host
Change-Id: Id453c330f1065012e7d4f9fc24ac477cc9bb9269
d549c28cfbddba945cb88857bcca3dce1414fb29 25-Jul-2016 Roland Levillain <rpl@google.com> Remove two ReadBarrierMarkRegX entrypoints.

As entry points ReadBarrierMarkReg30 and
ReadBarrierMarkReg31 are undefined on all architectures
supporting the read barrier configuration (ARM, ARM64, x86
and x86-64), remove them from the entry point list.

Test: ART host and target (ARM, ARM64) tests.
Bug: 29506760
Bug: 12687968
Change-Id: I500626e54f00aebfc095b4ef5f81b49fa43f7768
02b75806a80f8b75c3d6ba2ff97c995117630f36 13-Jul-2016 Roland Levillain <rpl@google.com> Introduce more compact ReadBarrierMark slow-paths.

Replace entry point ReadBarrierMark with 32
ReadBarrierMarkRegX entry points, using register
number X as input and output (instead of the standard
runtime calling convention) to save two moves in Baker's
read barrier mark slow-path code.

Test: ART host and target (ARM, ARM64) tests.
Bug: 29506760
Bug: 12687968
Change-Id: I73cfb82831cf040b8b018e984163c865cc44ed87
7df12cb7e0fb25faa149b1594c444cf780e8bc43 11-Jun-2016 Andreas Gampe <agampe@google.com> ART: Workaround for ARM valgrind stack issues

The reports from pthreads and the builtins don't match up (compiled
code and thus actual stack pointer values haven't been tested, yet).
As a temporary workaround, implicitly disable the checks by storing
0x0 as the stack base.

Bug: 19127663
Bug: 29282211
Change-Id: Ib4170e222ca7e2ef92bf125b0a7409770ded7822
952e1e3710158982941fc70326e9fddc3021235d 13-Jun-2016 Mathieu Chartier <mathieuc@google.com> Support unlimited pending checkpoints

Prevents the spinning that used to happen if RunCheckpoint was called
with 3 pending checkpoints. This spinning was done when holding
thread_list_lock_ and thread_suspend_count_lock_ and could deadlock
if any of the pending checkpoints required any of these locks.

The fix is to use an overflow list instead of having a fixed limit of
3.

Changed suspend stress test to have more threads and only compare last
line since there may be libbacktrace spam like:
"+E/libbacktrace(69891): void SignalHandler(int, siginfo_t *, void *):
Timed out waiting for unwind thread to indicate it completed."

Bug: 28988206

Change-Id: I2ae611506147d5199d59a08eee0395f7fa35d448
b87c03f530956a7b9c4ca2c8c1fb68285d8db12c 11-Jun-2016 Andreas Gampe <agampe@google.com> Revert "ART: Disable check under memory tools"

This reverts commit 820c13bea5795e04986bf617319517562de76514.

The check is valid, the whole stack setup is broken.
820c13bea5795e04986bf617319517562de76514 11-Jun-2016 Andreas Gampe <agampe@google.com> ART: Disable check under memory tools

Disable a stack check under memory tools. It assumes a single
common stack, which seems violated at least under valgrind on
ARM.

Change-Id: Ida05adb0728cc46f3bbda4d34be7a1623bb3bc82
f711f2cf3c28dfe865e36f17419a16f06a0ebb5a 23-May-2016 Mingyao Yang <mingyao@google.com> Partial fragment deoptimization

We used to do either single frame deoptimization, or full fragment
deoptimization which deoptimizes all the frames in a fragment.
This change allows some methods to be not deoptimizeable, likely due
to some kind of optimization. So we need another deoptimization mode
that unwinds partial fragment. Deoptimizations are now generalized into
either full or partial fragment. A full fragment deoptimization will
deopt all frames in the fragment, and then returns from the invoke stub
to enter interpreter. A partial fragment deoptimization will deopt a
single frame, or all frames up to the method that's not deoptimizeable,
and then jumps to the interpreter bridge.

Currently code not deoptimizeable is the code in boot image since the
code may not be compiled with debuggable flag.

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

Added test.

Bug: 27906566

This reverts commit 8e2478d23e89a7022c93ddc608dcbba7b29b91e6.

(cherry picked from commit cdca476bf3394ce9d97a369e84e701b427009318)

Change-Id: Iedb4ca9a28ae178fa7c2d486803fa27b402a85ed
946593d7c593c912684022a808fd156e17852248 27-Apr-2016 Mathieu Chartier <mathieuc@google.com> Revert "Write conflict tables in image"

Some strange issues on angler.

This reverts commit cda9386add68d94697449c6cb08b356747e55c21.

(cherry picked from commit 8e2478d23e89a7022c93ddc608dcbba7b29b91e6)

Change-Id: I475ca30e60691cd00b818aabbeb88e6ce3a2ae17
5c4b2ec16bcd779731bed1d2a0bd902dba3d5f92 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

(cherry picked from commit cda9386add68d94697449c6cb08b356747e55c21)

Change-Id: I3ce151651bf95047b0f692c185016f693ac4f820
84a4ab827685b10088eb01807b1e9296bec527b3 13-May-2016 Evgenii Stepanov <eugenis@google.com> SafeStack-friendly stack protection in ART.

This code takes an address of a stack variable to find the current
stack top. With SafeStack, such variables can be allocated on a
separate, "unsafe" stack, generating a completely bogus address.

Use __builtin_frame_address(0) instead.

Change-Id: I84fe3161bdd01cebbb4e9bebf2aca86783cc6f15
8494943e2e4ca98f2087dbacfae1dedefc853a4b 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

(cherry-picked from commit 12c08f03f65acc1c308491fc7ab6c57f682e2f24)

Change-Id: I0d5cc9d5bb8bbff6bd6b108f7486a63402a15993
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
fba39972d99701c80bf3beb7451aca508d67593c 11-May-2016 Chih-Hung Hsieh <chh@google.com> Fix misc-macro-parentheses warnings.

* Add parentheses to fix warnings.
* Use NOLINT to suppress wrong clang-tidy warnings.

Bug: 28705665
Change-Id: Icc8bc9b59583dee0ea17ab83e0ff0383b8599c3e
f39f0097c5cb6f9413f5df0558ffb24bc3221d41 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

(cherry picked from commit e55fda1373abad5ace4409453c51aeb0daaf99ef)

Change-Id: I96464d76a275d155a90a1bc3bb99fbb9d914cf20
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
91288d8f03b9aab28b61a4a76e552ad7e0c15c8b 28-Apr-2016 Mathieu Chartier <mathieuc@google.com> Revert "Revert "Write conflict tables in image""

Added test.

Bug: 27906566

This reverts commit 8e2478d23e89a7022c93ddc608dcbba7b29b91e6.

(cherry picked from commit cdca476bf3394ce9d97a369e84e701b427009318)

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

Some strange issues on angler.

This reverts commit cda9386add68d94697449c6cb08b356747e55c21.

(cherry picked from commit 8e2478d23e89a7022c93ddc608dcbba7b29b91e6)

Change-Id: Iffd25c5fb732ff72b58c787c107dc33c56f8c8d4
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
97cbc9206e9adc473a90650ebdb5d620f517ff04 15-Apr-2016 Calin Juravle <calin@google.com> Allow the framework to register sensistive threads to the runtime

Bug: 27865109
Bug: 28065407

(cherry picked from commit 8fff24953c78bd58f3a42ac83b340b90e7e7228a)

Change-Id: I82094e46a2fd12617e091d98831193f9ff56d26b
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
e42888f9df4163303244070c65d5229d3e201742 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

(cherry picked from commit cda9386add68d94697449c6cb08b356747e55c21)

Change-Id: I38cbe3150c3eeb385b8cad7cf93614e3980f4162
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
bb661c0f0cb72d4bbfc2e251f6ded6949a713292 04-Apr-2016 Bilyan Borisov <bilyan.borisov@linaro.org> Refactor use of __ANDROID__ macro

We use the __ANDROID__ macro, which is provided by the toolchain, in
numerous places. This patch refactors the usage of this by defining a
new macro, ART_TARGET_ANDROID, that is being passed during build to
ART_TARGET_CFLAGS in Android.common_build.mk on the same line as
ART_TARGET. The codebase currently assumes that the existence of the
__ANDROID__ macro implies that we are compiling art for an android
target device. This is because, currently, target builds are compiled
with target toolchains that provide the macro, while host toolchains
do not. With this change this assumption is still preserved. However,
in a future patch we will add the ability to compile art for a linux
target, and in that case the ART_TARGET_ANDROID macro won't be passed
anymore.

Change-Id: I1f3a811aa735c87087d812da27fc6b08f01bad51
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