History log of /art/runtime/thread-inl.h
Revision Date Author Comments
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
39b378ca3b4b6dc6da1651b84ee4289cd9bff0f8 08-Dec-2017 Andreas Gampe <agampe@google.com> ART: Factor out gAborting

Cut dependencies on base/logging.h by moving gAborting to its
own header. Leave the static storage in logging.cc.

Test: m
Change-Id: Ib2ca880e15f9cb50cb9aab803784826bb46efb5e
dcc528d2c7d5ac2cc075d4c965fdf702421d0f43 07-Dec-2017 Andreas Gampe <agampe@google.com> ART: Move runtime-debug flags to own files

To reduce the need for base/logging.h and separate out concerns.

Test: m
Change-Id: Ib373357325c6e622f608ada341594c3bea2fce2e
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
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
b486a98aadc95d80548953410cf23edba62259fa 01-Jun-2017 Andreas Gampe <agampe@google.com> ART: Introduce thread-current-inl.h

Factor out Thread::Current() code into its own -inl file to remove
transitive includes.

This requires at the same time correcting mutex.h, i.e., moving
some functions into mutex-inl.h.

Test: m test-art-host
Change-Id: I88f888b604e0897368d9b483edce6ce4332dd9c9
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
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
8a433246d0f26f1f8519925ee6fc5cee8fbd0788 07-Mar-2017 Hiroshi Yamauchi <yamauchi@google.com> Add two locks to expected_mutexes_on_weak_ref_access_.

The ObjectRegistry lock and the jdwp event list lock to avoid DCHECK
failures.

Some cleanup.

Bug: 35360959
Bug: 35745310
Test: test-art-host
Test: jdwp test.
Test: angler boot.
Change-Id: I16000c0c7624b1271d40c4c1a01a4e249271b67e
c73cb64585f301c8bb3b03a0684f6baead99b7ac 22-Feb-2017 Andreas Gampe <agampe@google.com> ART: Remove ObjPtr kPoison template parameter

Move to a global constexpr, so that object pointer poisoning can
be explicitly turned off for lower debug build overhead.

Bug: 35644797
Test: m
Test: m test-art-host
Change-Id: I2412b67cbec144f2aee206fb48591abe581fd00a
a222404a5832ab16786931576d52825d08eed3ca 09-Feb-2017 Hiroshi Yamauchi <yamauchi@google.com> Fix the empty checkpoint timeout.

The problem happens when a thread is indirectly blocked on a mutex
that another thread holds and is blocked on a weak ref access.

Add a way to do a dummy wakeup on a thread that's blocked on a mutex
so that the thread will respond to the empty checkpoint request. Do
this for the mutexes that are expected to be held when a weak ref is
accessed. Add a check that detects an unexpected case.

Bug: 33006388
Bug: 12687968
Test: test-art-host.
Change-Id: Iefec69b9a21aa25a928cb31fcf4fb872f867a8c2
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
f42eb2c7801dbb45a6ba20a372d5ba4712ebefba 19-Oct-2016 David Sehr <sehr@google.com> Remove mutex dependency on art::Runtime

Breaks the cyclic dependency between mutex and the runtime. This allows
the use of mutexes without instantiating a runtime.

Bug: 22322814
Test: test-art
Change-Id: Ia642e515937068d385e5bb1e10bbd3e50a6e36d2
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
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
a59d9b228b1eda3bf71a81b6201ec64e26086c23 27-Sep-2016 Mathieu Chartier <mathieuc@google.com> Use ObjPtr for reflection.cc/h/inl

Changed Pretty helpers to use this to reduce usage of Decode. The
eventual goal is not have almost any calls to ObjPtr::Decode.

Moved ObjPtr out of mirror namespace for convenience. Added more
PoisonObjectPointers calls in class linker, thread suspension.

Bug: 31113334

Test: test-art-host

Change-Id: I44d08db5143d95ed1b65e2f00f9749ef5cf379f7
3f7f03ce9a102a23961753753b5aa500226b0581 26-Sep-2016 Mathieu Chartier <mathieuc@google.com> Add basic support for object pointer poisoning

ObjPtr is a pointer that checks for heap corruption and is meant
to replace mirror::Object* in places where a mirror::Object* is a
local variable. Whenever there is a possible suspend point, the
current thread's object pointers are all invalidated. This is done
by storing a cookie in the object pointer associated with what thread
created it.

Added test case in object_test.

Example failure:
object_test F 25379 25379 object_pointer.h:70] Check failed:
IsValid() Invalid cookie, expected 0 but got 2

Bug: 31113334

Test: test-art-host-gtest-object_test

Change-Id: I9fa80ccaf2f0448621942935af702a243a3e1ee6
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
10b218d32c0006aab747a53a9867d982cde9c938 26-Jul-2016 Mathieu Chartier <mathieuc@google.com> Add missing filter cards to zygote mod union table

Without filtering the cards, every object in the zygote is grayed
during the GC. This was deleted in a PS of previous CL.

GrayAllDirtyImmuneObjects goes from 1.974ms to 376.464us for CC on
N9 maps. This happens during the pause. This CL also fixes regression
in zygote PSS.

Bug: 29516968
Bug: 12687968

Change-Id: I42014e78b1de3ce9b2eefa3bd32f0d24e2ff71c6
9f5f8ac136d88de546f70f0ac2438610150ff401 29-Jun-2016 Nicolas Geoffray <ngeoffray@google.com> Special case the suspend to runnable transition when locking.

The runtime may be shutting down in parallel, and for daemons that
could lead to failed locking assertions.

bug:27378067
Change-Id: I53785cad537a3d4846661a7b0780543226ea3928
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
8ac9c91cfa2408cf8d27bcf12785a60923aab775 02-Oct-2015 Mathieu Chartier <mathieuc@google.com> Make SetStateUnsafe run checkpoints before going to suspended

This prevents cases where we can get a checkpoint request in runnable
and then unsafe set to suspended. This was bad behavior since the
checkpoint may not be run in a timely manner.

Bug: 24191051
Change-Id: I73605c1a1154f67699f3902141f3232ab064793f
dabdccc816309ff29b39d13696c58c8543450739 01-Oct-2015 Mathieu Chartier <mathieuc@google.com> Add more error printing to TransitionFromSuspendedToRunnable

Bug: 24191051
Change-Id: I5c66ba5c76bf86e8d603110989b9da883ca4ca65
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
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
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
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>
3cf225386e8129dcbe32b289279ecb87ec255318 10-Jul-2015 Mathieu Chartier <mathieuc@google.com> Clean up some includes

Change-Id: Ia03a3b54b235df38d5cfe096fef1aebe2b80eb29
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
cb535da36915f9d10bec3880b46f1de1f7a69f22 23-Jan-2015 Mathieu Chartier <mathieuc@google.com> Change AtomicStack to use StackReference

Previously used Object*, using StackReference saves memory on 64 bit
devices.

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

Bug: 12687968
Change-Id: I62f70274d47df6d6cab714df95c518b750ce3105
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
ef048f6f968abd59fa7fa89413a6eb85c959beaf 26-Nov-2014 Andreas Gampe <agampe@google.com> ART: Add some thread abort logging

This hits intermittently on tests. Print out the thread name and
the state it wants to go to.

Change-Id: I86c8f0d61e23cbe4d46175a5eefaef03c23a2a81
4ad5cd3e7d519484559ef778d96fb3f0be8919fa 12-Nov-2014 Ian Rogers <irogers@google.com> Modify the behavior of thread suspend shootouts.

The thread doing the suspension doesn't attempt to suspend the other thread
unless it knows another thread isn't trying to suspend it. Use the suspend
count, and its lock, for this purpose.
Re-enable ThreadStress test.
Bug: 15446488

Change-Id: Idd34410c7b89d8abd6973e5699a15ca699472c78
8409ec440079020bbe4ad066cf18a5fadfba67d2 05-Nov-2014 Ian Rogers <irogers@google.com> Make thread dumping more tolerant of broken invariants during abort.

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

Change-Id: I4e4ef3a2002fc59ebd9097087f150eaf3f2a7e08
76433275dbe39e5ced1c223b006d1b900b1937f6 26-Sep-2014 Mathieu Chartier <mathieuc@google.com> Optimize get/set reflection performance

Speedups mostly from reducing how often access checks are needed,
and adding more inlining, and adding templates.

Field_getInt from ~850ns -> 350ns.
Field_setInt from ~900ns -> 370ns.

Bug: 14063288

(cherry picked from commit ffc788cb7b5b9f53734d7bb8af2d5e45d885546b)

Change-Id: I2441581ff3478c6ae43b6aa49939ff3f07555ec8
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
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
f3d874c60ee3ada19ce26a5c4e532312b6f3a9e9 18-Jul-2014 Ian Rogers <irogers@google.com> Avoid race in single thread suspension.

Don't allow more than one concurrent single thread suspension to avoid
potential cycles and deadlocks where threads try to suspend each other.
Bug: 16364458, 16354227

Change-Id: I907f1d5591a6aa5c241d37d6b4a34f968f98df77
6093a5c277e54bcd949dd6fac7b3856e5f371d06 18-Jul-2014 Ian Rogers <irogers@google.com> Avoid race in single thread suspension.

Don't allow more than one concurrent single thread suspension to avoid
potential cycles and deadlocks where threads try to suspend each other.
Bug: 16364458, 16354227

(cherry picked from commit f3d874c60ee3ada19ce26a5c4e532312b6f3a9e9)

Change-Id: I907f1d5591a6aa5c241d37d6b4a34f968f98df77
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
576ca0cd692c0b6ae70e776de91015b8ff000a08 07-Jun-2014 Ian Rogers <irogers@google.com> Reduce header files including header files.

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

Change-Id: I8d13dce8512816db2820a27b24f5866cc871a04b
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
719d1a33f6569864f529e5a3fff59e7bca97aad0 06-Mar-2014 Ian Rogers <irogers@google.com> Enable annotalysis on clang ART builds.

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

Change-Id: I72cea8da9a3757b1a0b3acb4081feccb7c6cef90
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
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
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
0f5f6bbc3a0bb125875f28ad61584001989a7f10 23-Nov-2013 Dave Allison <dallison@google.com> Fix thread checkpoint issue

This changes a do...while loop into a while(true) with
a break out. Fixes issue where checkpoint functions can
cause the thread state to become overwritten by a garbage
value.

Bug: 11809176
Change-Id: Ifbbc5e5cee85649d57f71267933539eefa7e25ea
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
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
1eb512d33f94d1dd7ea38263307ba0f7a0dfa653 19-Oct-2013 Ian Rogers <irogers@google.com> Fast JNI support.

Use a modifier to signal a native method is a fast JNI method. If the
modifier is set then don't perform runnable transitions.

Change-Id: I7835b4d837bfdd1cb8e2d54b919c0d5e6cf90499
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
02ed4c04468ca5f5540c5b704ac3e2f30eb9e8f4 06-Sep-2013 Ian Rogers <irogers@google.com> Move disassembler out of runtime.

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

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