History log of /art/runtime/gc/heap.cc
Revision Date Author Comments
558511a782baf60547ce9a93377ef0eae89e01ad 02-Mar-2018 Mathieu Chartier <mathieuc@google.com> Remove mandatory address for non moving space / zygote

This used to not be safe when the immune region didn't correctly
handle gaps between the regions.

The immune spaces handles this correctly but may cause the GC to be
slightly slower when it occurs.

Test: test-art-host
Bug: 74062530

(cherry picked from commit fa4ea8243f1ed949bb76cf088a4b34275c622696)

Merged-In: Ia24db1c0a8c7b3667f3f893d0d9e9ead33d6a248
Change-Id: Ie6191f76dd082a6a22496e2855ba623ce594f68e
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)
af290318c31180148bab64038d66a6059a1a89d5 27-Feb-2018 Roland Levillain <rpl@google.com> Small documentation and stylistic changes.

Test: art/test.py
Change-Id: Ibc74ee4783314266bf1d027811715058626c57c8
99bd16bfd0cebb338dd33473cdf71176d560d6a3 21-Feb-2018 Roland Levillain <rpl@google.com> Extend error reporting in art::gc::Heap::GrowForUtilization.

Test: art/test.py
Bug: 73712520
Change-Id: I425368fd0bb69241e986b38c40a541e8f5c05c59
8f7ea9ab1703ef52c0c5ca3490e2913ac67f2a16 26-Jan-2018 Roland Levillain <rpl@google.com> Various ART GC documentation updates.

Also some cosmetic and stylistic changes.

Test: mmma art
Change-Id: I411cc45c6b5cb2a4b0652eeb9c4a6f4a3a274bd6
2ae376f5af8953d3524cd8ed915ebdacf505625c 30-Jan-2018 Roland Levillain <rpl@google.com> Stylistic and aesthetic changes.

Test: art/test.py
Change-Id: Ic41aa80430d16af748994c80f049c5b479fd9980
ef012225dcec8f736fc8fd848f5d8ee01c3c280f 21-Jun-2017 Roland Levillain <rpl@google.com> Fix typos.

Test: art/test/testrunner/testrunner.py
Change-Id: I5f5e052c940650a3adb3a8717b84260e6b306500
5f0b71ab2f60f76b5f73402bd1fdd25bbc179b6c 07-Feb-2018 Lokesh Gidra <lokeshgidra@google.com> Implement ClampGrowthLimit feature for region space

Concurrent copying GC, which uses region space, needs
virtual heap to be twice of capacity. Hence, it
becomes an issue with 32-bit apps which need large native heap.

Bug: 72383501
Bug: 72297706
Test: test-art-target
Change-Id: I7a8f272e82b3eb15a5dc57cfbfd51b7d62aa141f
1144b63a11525d5a7a273d7a957343ad68d162c6 18-Jan-2018 Lokesh Gidra <lokeshgidra@google.com> Fix calculation of concurrent_start_bytes in GrowForUtilization()

Concurrent_start_bytes currently is assigned product of bytes
allocated bytes during last GC and time spent (in seconds) in it.
Instead it should be just bytes allocated.

Bug: 71902460
Test: test-art-host
Change-Id: I6b8322756eb6464b4581311ea7e7c90ecb2cb5ae
f4eedfe973638ab22116acf6b85a1cf8a439db97 29-Dec-2017 Richard Uhler <ruhler@google.com> Remove blocking case from RegisterNativeAllocation.

To avoid causing jank for dubious reasons.

Test: art/test/testrunner/testrunner.py -b -t 004-NativeAllocations --host
Test: vogar --mode host libcore/luni/src/test/java/libcore/libcore/util/NativeAllocationRegistryTest.java

Bug: 70831911

Change-Id: I310e3daf5bd3b65097b6011d6a96fb42ac50132b
e11d50f23dc1256ad933d209f2db8f58138f02c0 10-Jan-2018 Yi Kong <yikong@google.com> Workaround bogus Thread Safety Analysis warning

Building art/runtime/gc/heap.cc with thread safety analysis produces
warnings that mutator_lock_->AssertNotHeld() conflicts with
ScopedObjectAccess for holding shared and exclusive lock within the same
scope. AssertNotHeld() is a capability assertion and does not actually
hold the lock.

Thread safety analysis was broken thus the warning not appearing before
Clang r316199 update. Temporarily workaround the issue while we fix the
bug in upstream.

Bug: 71769596
Test: m checkbuild
Change-Id: I48234db966332cf24e40774cd62589359aab6d05
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
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
94c589db78da2b66bc681c6480819ca4bd4d3326 27-Dec-2017 Andreas Gampe <agampe@google.com> ART: Mark Dbg GCs as debugger

Change Heap::CollectGarbage to accept explicit GcCause, but implicitly
default to kGcCauseExplicit.

Change Dbg functions that run an explicit GC to set the cause to
kGcCauseDebugger.

Test: m test-art-host
Change-Id: I53d4073fca01c1de78d14a58dff33004c7971981
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
9b827ab7e63cf8b24987e75186434348d0dbf4e8 08-Dec-2017 Andreas Gampe <agampe@google.com> ART: Clean up ATRACE use

Remove old ATRACE_BEGIN & _END pairs, where possible. Remove
ATRACE_CALL and replace it with ScopedTrace.

Remove utils/Trace.h include.

Test: m
Change-Id: I3a5123202f4e373074bfe0f7359ee6c60a70352a
170331f0e44a0e07fcfe0b5932517e0500f5cd1f 08-Dec-2017 Andreas Gampe <agampe@google.com> ART: Remove base/logging from heap-inl.h

Hide the single uncommon VLOG and remove the include. Fix up
transitive includes.

Test: m
Change-Id: I917df597cb62c57040c1fb0e0079df4d95e5a658
660be6ff67870d2512230b13effefdbc5abe43e4 22-Nov-2017 Richard Uhler <ruhler@google.com> Add VMDebug.getInstancesOfClasses API.

The API can be used to iterate over instances of a given type on the
heap.

The GetInstancesOfClassesBenchmark run on bullhead shows the run time
of the API grows linearly in the number of classes, C, to get instances
of and the number of total instances, N, allocated on the heap.

C N=~2^18 N=~2^19
1 13ms 21ms
2 26ms 43ms
4 53ms 87ms

Bug: 69729799
Test: ./test/testrunner/testrunner.py -t 099-vmdebug -b --host

Change-Id: Ied053d19760e656012e2577776f75a1cc0a14ac3
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
ed56b5e1b92ab11a2a1414807d1a8a1c9123f455 19-Oct-2017 Andreas Gampe <agampe@google.com> ART: Only stress background transition in slow-debug

To lighten the load when starting new processes, by default keep
the wait time until running background compaction.

Bug: 35644369
Test: m test-art-host
Change-Id: I932684b02f3095bc011e5e8346eea103e458bfc5
11c273ddfda3e30d14af32e385570955b61bc39b 16-Oct-2017 Mathieu Chartier <mathieuc@google.com> Remove low RAM special casing for heap growth multiplier

Moved to change the default value in runtime.cc. This enables
changing the value by passing in a
-XX:ForegroundHeapGrowthMultiplier value.

This enables devices to set the foreground heap growth multiplier
to non 1.0 values even when low_memory_mode is true. Doing this
reduces GC frequency and can help device performance.

Increased the limit to 5.0 since the old limit of 1.0 was bogus.

Bug: 67416130
Test: test-art-host
Test: make and flash

(cherry picked from commit 2f33ad21a5c3688c33c1f36665216d76bac47f2c)

Merged-In: I86166830261c034255c23611cb8f4ebcf8c43b09
Change-Id: I6fdf82e69ebe350476fb4fe3da9d22bf671b9eac
2f33ad21a5c3688c33c1f36665216d76bac47f2c 16-Oct-2017 Mathieu Chartier <mathieuc@google.com> Remove low RAM special casing for heap growth multiplier

Moved to change the default value in runtime.cc. This enables
changing the value by passing in a
-XX:ForegroundHeapGrowthMultiplier value.

This enables devices to set the foreground heap growth multiplier
to non 1.0 values even when low_memory_mode is true. Doing this
reduces GC frequency and can help device performance.

Increased the limit to 5.0 since the old limit of 1.0 was bogus.

Bug: 67416130
Test: test-art-host
Test: make and flash

Change-Id: I86166830261c034255c23611cb8f4ebcf8c43b09
df7f7f02b26f8a8b47345e713ce097ec0e956a11 05-Oct-2017 Mathieu Chartier <mathieuc@google.com> Address comment for aog/502433

Added a comment describing the fix.

Bug: 37885600
Test: test-art-host

Change-Id: Ia21ce29a6bee1b8f6992a2c051b32b5ab4356191
aac901234850494523b8907d51cc4b3e714efda7 04-Oct-2017 Mathieu Chartier <mathieuc@google.com> Compare rounded sizes in CheckPreconditionsForAllocObject

Fixes a bug where the retrying the allocation for switching from
non instrumented -> instrumented would cause DCHECK failure because
it was comparing a rounded size to an unrounded size.

Bug: 37885600
Test: test-art-host
Change-Id: I2bffff6ae4e3c20b2e830a407a0688ba4cad51a1
d972b427d49d75ba62bd80495ef706771504ac71 11-Sep-2017 Hans Boehm <hboehm@google.com> Random comment typo fixes

Discovered while trying to understand this code ...

Test: Build platform.

Change-Id: I606bf8b07375513699e12f31f771c2a7677b6766
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
0c18338ebae6b3597c882887f8354b64abb5e90f 14-Jul-2017 Andreas Gampe <agampe@google.com> ART: Replace or remove some ObjectCallback Walk functions

Replace with visitor functions in RegionSpace and SpaceBitmap. Remove
old ObjectCallback version in HeapBitmap. Fix up users. Move some
thread-safety annotations.

Move ObjectCallback definition to the only remaining user (ModUnionTable).

Test: m
Change-Id: I10307aeacad0c60d21fbade2081ec040d6a6ac4c
10d39085d5e064ae0afdc898eb32741a660c4b9d 14-Jul-2017 Andreas Gampe <agampe@google.com> ART: Remove old visit functions

Remove now-unused ObjectCallback-based VisitObjects functions.

Test: m
Change-Id: Iefccd6ff28654d86f5254a411e7c30263a85b9aa
1c158a07ac7bac301af9d2921207d66730d1ac0a 14-Jul-2017 Andreas Gampe <agampe@google.com> ART: Use VisitObjects visitor functions

Move users to VisitObjects with templated visitors. Clean
up the code a bit.

Test: m
Change-Id: Ibbda8e9aa17e895cee559080c1e4158744cbbbf6
351c44765279142d15333e2ae02b8a423d195b1b 13-Jul-2017 Andreas Gampe <agampe@google.com> ART: Add templated VisitObjects

Add templated versions of VisitObjects that accept visitors. This
allows to use more modern lambdas.

Test: m
Change-Id: I71a7f59bcae02090b9493bf8b477bb8b6ba649de
34afcde6e57f6d8a6077c0f23c1481c1122d3be9 01-Jul-2017 Mathieu Chartier <mathieuc@google.com> Trace heap size for allocations

Trace the heap size when we get bulk allocated bytes. This doesn't
happen often for RosAlloc/TLAB and should not hurt
performance.

The motivation is to enable systrace to see allocation behavior of
apps.

Test: test-art-host

Change-Id: I1e373b29507cc64bd5b6ecc9b4e9278399adf4b1
40112dd31260c624337f353ec00c444df64458d4 27-Jun-2017 Mathieu Chartier <mathieuc@google.com> Make waiting for blocking GC more intuitive

Now tells what GC cause blocked on what other GC cause.

Example output:
WaitForGcToComplete blocked HeapTrim on ProfileSaver for 396.361ms

Bug: 62941975
Test: test-art-host

(cherry picked from commit 87a619f43d4cb79b8723b42dc53cb10f7577f1de)

Change-Id: I1e3a35244db16974487dd8b82baae81669ae9aee
87a619f43d4cb79b8723b42dc53cb10f7577f1de 27-Jun-2017 Mathieu Chartier <mathieuc@google.com> Make waiting for blocking GC more intuitive

Now tells what GC cause blocked on what other GC cause.

Example output:
WaitForGcToComplete blocked HeapTrim on ProfileSaver for 396.361ms

Bug: 62941975
Test: test-art-host
Change-Id: I66832d7f1daf565129c27ad23fc25852d7782733
f45d61c0866461c9476f17644b27dc0664d507c5 07-Jun-2017 Andreas Gampe <agampe@google.com> ART: Fix or disable some tidy warnings.

Add a strlcpy shim for the host, so we can use strlcpy instead of
strcpy everywhere.

Fixed warnings include unused-decls, (some) unreachable code, use
after std::move, string char append, leaks, (some) excessive padding.

Disable some warnings we cannot or do not want to avoid.

Bug: 32619234
Test: m
Test: m test-art-host
Change-Id: Ie191985eebb160d94b988b41735d4f0a1fa1b54e
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
75e4b2af38b2909feaa58f682e9af53e2a50acbd 24-May-2017 Mathieu Chartier <mathieuc@google.com> Use HeapGrowthMultiplier for native allocaitons

Reduces the amount of native allocation GCs for foreground apps.
For camera: The number of native allocations GCs goes from 4 to 2,
improving launch time by 25ms (average of 25 runs on pixel).

The multiplier is 1 for low ram devices, so this should not increase
RAM on devices where it matters.

Test: test-art-host

(cherry picked from commit 30baf4a6d7c568e423c9d3e3fa7a7a25ab730b62)

Change-Id: Ifba47cfebab58d9a60a49446929c3475cef9ff14
30baf4a6d7c568e423c9d3e3fa7a7a25ab730b62 24-May-2017 Mathieu Chartier <mathieuc@google.com> Use HeapGrowthMultiplier for native allocaitons

Reduces the amount of native allocation GCs for foreground apps.
For camera: The number of native allocations GCs goes from 4 to 2,
improving launch time by 25ms (average of 25 runs on pixel).

The multiplier is 1 for low ram devices, so this should not increase
RAM on devices where it matters.

Bug: 36727951
Test: test-art-host

Change-Id: I0b9e090d9d85bcb2fcd24f221988e99b91ec5977
5dc8a08723afa5373abf6ccfc7c0fd57eb7a2936 19-May-2017 Mathieu Chartier <mathieuc@google.com> Go to suspended before waiting for GC to complete.

We are not allowed to wait on the GC complete lock while holding the
mutator lock.

Bug: 38449715
Bug: 38350590

Test: test-art-host

(cherry picked from commit b93d5b1f39fb0651dfe2f165ad1431c962f5a78e)

Change-Id: Ib5b6d99b82f0c4a999bfcbbb1f5271da41a51040
96f4c3cd9cb0f46ad41c3ffb45998c8e69e3ada8 19-May-2017 Mathieu Chartier <mathieuc@google.com> Use DumpObjectInfo in CheckPreconditionsForAllocObject

Try to get some insight in the corrupted class that shows up in test
145.

Bug: 37885600
Test: m
Change-Id: I94c5c158247da5d6e6217aaa78f3d5c2619650d3
b93d5b1f39fb0651dfe2f165ad1431c962f5a78e 19-May-2017 Mathieu Chartier <mathieuc@google.com> Go to suspended before waiting for GC to complete.

We are not allowed to wait on the GC complete lock while holding the
mutator lock.

Bug: 38449715
Bug: 38350590

Test: test-art-host

Change-Id: I4e2dfe9496a56cd7fbe8de76a1bc8951e929ddb1
76c7665802411e597a228439f354acf1dc53e3d2 19-May-2017 Igor Murashkin <iam@google.com> heap: Tolerate rosalloc allocation races in the heap visitor

When a new object is allocated by rosalloc, the fast path no longer
needs a memory barrier prior to being pushed to the object stack.

The heap visitor will check if the object's class is actually valid
(i.e. it's class's class is the ClassClass) and skip it otherwise.

This enables us to remove the DMB from the art_quick_alloc*initialized
entrypoints a follow-up CL for a speed-up.

Bug: 36656456
Bug: 36447861
Bug: 28790624
Change-Id: I28c75ce6828eba45529a6a12973181c9d616eb9f
da1da8a78c9df45890f48b4f0197ed18fa1de3c5 16-May-2017 Richard Uhler <ruhler@google.com> Revert "Revert "RegisterNativeAllocation: Avoid case of double blocking gc.""

This reverts commit 602b1c1421028310fdb1662fcec0aa8ac5e77604.

Change-Id: I02b698074845977cc799a0d0234627f7c8ef4eeb
Test: ART_DEFAULT_GC_TYPE=GSS ART_USE_READ_BARRIER=false ./test/testrunner/testrunner.py -b -j32 --target -t 004-NativeAllocations
Bug: 36851903
602b1c1421028310fdb1662fcec0aa8ac5e77604 16-May-2017 Richard Uhler <ruhler@google.com> Revert "RegisterNativeAllocation: Avoid case of double blocking gc."

This reverts commit 8df0f36b4fd5db6da67066da62eccc1e0b81e028.

004-NativeAllocations test fails on art-gss-gc-tlab configuration.

Change-Id: I0fb0969c8e4af0bcd5f8481ce828ac4cf258c089
Bug: 36851903
8df0f36b4fd5db6da67066da62eccc1e0b81e028 12-May-2017 Richard Uhler <ruhler@google.com> RegisterNativeAllocation: Avoid case of double blocking gc.

If multiple threads call RegisterNativeAllocation causing the blocking
watermark to be exceeded while a background GC is in progress, then
two back-to-back blocking GCs would be performed when a single
blocking GC is sufficient. For example:

1. Thread A RegisterNativeAllocation triggers background GC1
2. Thread A RegisterNativeAllocation triggers blocking GC2
3. Thread A's GC2 waits for GC1 to complete.
4. Thread B RegisterNativeAllocation sees GC2 in progress and waits for
it to complete before triggering a second blocking GC3.
5. GC1 completes.

Because thread B's RegisterNativeAllocation was called before GC1
completed and GC2 had not begun for real, thread B can simply wait for
GC2 to start and finish before returning, rather than waiting for GC2 to
start and finish and then doing a second blocking GC.

This change fixes the behavior so that only a single blocking GC is
performed in this case.

Bug: 36851903
Test: 004-NativeAllocations run test.
Change-Id: I1e178b9ee7bb68703bdc9a09b1041a982de8b2ce
e8857fe3349af3900ef5b6ba65627c82cb13a2c2 03-May-2017 Andreas Gampe <agampe@google.com> ART: Change alloc-space begin for x86 ASAN

Move the preferred AllocSpace begin to 0x40000000, as lower memory
is mostly reserved by ASAN. This does not seem to apply to arm32.

Bug: 31098551
Bug: 37728308
Test: m SANITIZE_HOST=address test-art-host-gtest32
Test: lunch aosp_bullhead && m && m SANITIZE_TARGET=address # device boots
Change-Id: I2c6508305e62040b0679dfe483c76fd283dba9de
b166f413411b380d32c75cb842fc2ab8be96a963 26-Apr-2017 Mathieu Chartier <mathieuc@google.com> Only log a few types of GC causes for the blocking cases

There are various types like debugger and GetObjectsAllocated that
can cause spam if we log all the blocking calls. In practice, these
are only used from tools and should not cause jank.

Bug: 37275712
Test: test-art-host

(cherry picked from commit 3b91fccc0a83c6c9ce7fef484495f863d739baff)

Change-Id: I457fa94985fda88b1cf208c935e1369493e036cb
3b91fccc0a83c6c9ce7fef484495f863d739baff 26-Apr-2017 Mathieu Chartier <mathieuc@google.com> Only log a few types of GC causes for the blocking cases

There are various types like debugger and GetObjectsAllocated that
can cause spam if we log all the blocking calls. In practice, these
are only used from tools and should not cause jank.

Bug: 37275712
Test: test-art-host
Change-Id: I3a6854d37a6e83c91e9cc8bcb76103e2498bc3b6
f9d0b5543cba4114712a6c1f876a9f59f04d4de0 20-Apr-2017 Roland Levillain <rpl@google.com> Improve deterministic boot image compilation with CC collector.

Allow deterministic compilation with the read barrier configuration.

(cherry picked from commit b81e9e90ee60e602286899fc3fa0048c2fcb1c30)

Test: Compare boot.art produced by different builds of the same tree.
Bug: 37442966
Change-Id: I6cc0d0d7fdfe4f954765764d9f7f3778b7307028
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
1ca689096b532e007dc9f8ba16db4731e6afd719 18-Apr-2017 Mathieu Chartier <mathieuc@google.com> More robust GC verification and corruption dumping

Added a test for GC heap corruption dumping, added more info to the
dump like adjacent bytes and card table.

Added heap corruption detection in
ConcurrentCopying::MarkNonMoving().

Bug: 37187694
Bug: 12687968

Test: mm test-art-host-gtest-verification_test -j20

Change-Id: I8c90e45796d0784265aa091b2f8082f0cfb62719
b81e9e90ee60e602286899fc3fa0048c2fcb1c30 20-Apr-2017 Roland Levillain <rpl@google.com> Improve deterministic boot image compilation with CC collector.

Allow deterministic compilation with the read barrier configuration.

Test: Compare boot.art produced by different builds of the same tree.
Bug: 37442966
Change-Id: I6cc0d0d7fdfe4f954765764d9f7f3778b7307028
c6ea7d00ad069a2736f603daa3d8eaa9a1f8ea11 02-Feb-2017 Andreas Gampe <agampe@google.com> ART: Clean up art_method.h

Clean up the header. Fix up other headers including the -inl file,
in an effort to prune the include graph. Fix broken transitive
includes by making includes explicit. Introduce new -inl files
for method handles and reference visiting.

Test: source build/envsetup.sh && lunch aosp_angler-userdebug && mmma art
Test: source build/envsetup.sh && lunch aosp_mips64-userdebug && mmma art
Change-Id: I8f60f1160c2a702fdf3598149dae38f6fa6bc851
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
35b59a262f660adaf30db11bc0c3d14bb56ebf79 18-Apr-2017 Mathieu Chartier <mathieuc@google.com> Differentiate between native alloc and normal background GC

Added a new GC cause kGcCauseForNativeAllocBackground.

Bug: 35872915

Test: test-art-host

Change-Id: I94e17f8bd53af29f2862b9910bd8abd2df97e229
d08f66f519f6cf75c2eb05a489b6e87f739badff 13-Apr-2017 Mathieu Chartier <mathieuc@google.com> Various debug ART GC performance improvements

Removed unnecessary read barriers in SizeOf and a few other places.
Disabled disallow read barrier check.

Before:
GC time: 15.817s
Real 0m26.113s
user 1m16.780s
sys 0m3.152s

After:
GC time: 9.212s
real 0m19.875s
user 1m9.916s
sys 0m1.916s

Bug: 35644369
Test: test-art-host

Change-Id: I79a65259deff2a478a96e02ae69b14730b6dcbe6
80d4f53fe8196e45ec79d3dc8266abafdf919e48 11-Apr-2017 Mathieu Chartier <mathieuc@google.com> Clear zygote space cards for CC

There may be dirty cards from reference processing or from zygote
compaction. Having these dirty cards in the zygote space is
unnecessary and causes PSS increase from GrayAllDirtyImmuneObjects
in future GCs. Clearing the zygote space cards when the zygote
space is created fixes this issue and reduces PSS.

System wide PSS for zygote space, before:
7,899K: .Zygote
7,896K: .Zygote
8,067K: .Zygote
8,547K: .Zygote

After:
4,881K: .Zygote
5,003K: .Zygote
5,582K: .Zygote
5,259K: .Zygote
5,176K: .Zygote

Bug: 12687968
Bug: 37219911

Test: Device boots
Test: test-art-host

(cherry picked from commit d5a67447de577546b76c0565aed5af56176bbeb4)

Change-Id: I3f61b0f26674a8434ee37925fefd3480b106857d
55c05f5b4e2c0cc084ee332bf7ae54ea44cde8ad 11-Apr-2017 Mathieu Chartier <mathieuc@google.com> Clear zygote space cards for CC

There may be dirty cards from reference processing or from zygote
compaction. Having these dirty cards in the zygote space is
unnecessary and causes PSS increase from GrayAllDirtyImmuneObjects
in future GCs. Clearing the zygote space cards when the zygote
space is created fixes this issue and reduces PSS.

System wide PSS for zygote space, before:
7,899K: .Zygote
7,896K: .Zygote
8,067K: .Zygote
8,547K: .Zygote

After:
4,881K: .Zygote
5,003K: .Zygote
5,582K: .Zygote
5,259K: .Zygote
5,176K: .Zygote

Bug: 12687968
Bug: 37219911

Test: Device boots
Test: test-art-host

(cherry picked from commit d5a67447de577546b76c0565aed5af56176bbeb4)

Change-Id: I4746c4829056f558b454c78c5991426feb460904
d5a67447de577546b76c0565aed5af56176bbeb4 11-Apr-2017 Mathieu Chartier <mathieuc@google.com> Clear zygote space cards for CC

There may be dirty cards from reference processing or from zygote
compaction. Having these dirty cards in the zygote space is
unnecessary and causes PSS increase from GrayAllDirtyImmuneObjects
in future GCs. Clearing the zygote space cards when the zygote
space is created fixes this issue and reduces PSS.

System wide PSS for zygote space, before:
7,899K: .Zygote
7,896K: .Zygote
8,067K: .Zygote
8,547K: .Zygote

After:
4,881K: .Zygote
5,003K: .Zygote
5,582K: .Zygote
5,259K: .Zygote
5,176K: .Zygote

Bug: 12687968
Bug: 37219911

Test: Device boots
Test: test-art-host

Change-Id: I92daacef51c13ba7536fa18e94af67674d13089f
3458359832973c8eddfdd50f06f8ea050b89dadf 24-Mar-2017 Mathieu Chartier <mathieuc@google.com> Move backtrace logic to backtrace_helper.h

Refactor this out so we can use it other places.

Test: test/run-test --host --gcstress --dev --64 048

Change-Id: I1c357714badd417a67a34cd5d371ddbf1282a179
e8649c7f1f1c21fdee1a40068c03d1e294e397ca 04-Mar-2017 Mathieu Chartier <mathieuc@google.com> Add GC critical section to GetObjectsAllocated

Prevent GC running during GetObjectsAllocated since we may get a
checkpoint request that tells us to suspend while we are doing
SuspendAll. This can cause a deadlock.

Bug: 35232978

Test: test-art-host

Change-Id: I9c02415df0a0b9fa787d7ce449ec06a40dfaf624
6711cd8bc9f9053d653a52676177f8a29c1c36eb 24-Feb-2017 Hiroshi Yamauchi <yamauchi@google.com> Change the region space region size to 256k.

Also add RegionSpace::non_free_region_index_limit_ to avoid the need
to scan the free end of the region table in SetFromSpace(), which
compensates (and more) the pause time increase due to the increasing
number of regions.

Ritz EAAC avg pause time (angler little core / -Xmx512m):
Before 186us
After 436us (without non_free_region_index_limit_)
After 103us

Partially revert aog/327342 and remove the temporary adjustment of
max/min-free. Changing the region size to 256k was enough to avoid the
GCE boot issue (b/34576638), but 154-gc-loop barely fails. Make
154-gc-loop failures less strict.

Allocation performance (angler little core / -Xmx512m)
Ritz EAAC
Before 939.6
After 937.8

BinaryTree
Before 603350
After 620200 (-3%)

Bug: 12687968
Test: test-art-host
Test: GCE boot
Change-Id: I1495ab4ced806e1c4d779d49b56cea618817a0d6
8876fb740431ef862339c5741c581a01f6289216 24-Feb-2017 Mathieu Chartier <mathieuc@google.com> Add more DCHECK logging to Heap::CheckPreconditionsForAllocObject

Print out relevant info about why the DCHECK failed.

Bug: 35746587

Test: test-art-host
Change-Id: If09ad7d050126647abc16a02c5e9a596634e285c
3c3c4a1da1e8c03e78813d175a9974fb9f1097ea 22-Feb-2017 Hiroshi Yamauchi <yamauchi@google.com> Improve the region space memory mapping.

Add a region space mmap fallback when the initial address isn't
available.

Clean up around the asan-specific base address.

Add MemMap::AlignBy to align the region space base address by the
region size, which is currently required by ReadBarrierTable.

Disable some read barriers in ZygoteCompactingCollector to avoid a
DCHECK failure in LockWord::SetMarkBitState when classes are in the
forward state due to unnecessary read barriers on
SizeOf/VisitReference.

Bug: 12687968
Test: test-art-host with CC and CMS.
Test: marlin-userdebug_asan_coverage boot.
Test: angler boots with CC and CMS.

Change-Id: I70f99779df6acc1b64cab6402f3ef7c73ce5b39b
057d977aed600843dd4a617dca7098555d79110b 18-Feb-2017 Hiroshi Yamauchi <yamauchi@google.com> Always mark reference referents in transaction mode.

Fix a to-space invariant check failure in EnqueueFinalizerReferences.

Reference processing can be a problem and useless during transaction
because it's not easy to roll back what reference processing does and
there's no daemon threads running (in the unstarted runtime). To avoid
issues, always mark reference referents.

Add a do_atomic_update parameter to MarkHeapReference.

Bug: 35417063
Test: test-art-host with CC/CMS/SS.
Change-Id: If32eba8fca19ef86e5d13f7925d179c8aecb9e27
d6b17d4eacd8a1a46a0d4837285735a071c0beb7 17-Feb-2017 Mathieu Chartier <mathieuc@google.com> Move thread_running_gc_ logic to VisitObjectsInternalRegionSpace

Cleaner to have the logic in the caller.

Test: test-art-host CC
Change-Id: I93a16f8baf327b6692cce5c6141d1c361ce53f16
183009a616b9d0d77591651f8e97f48ed4d924db 17-Feb-2017 Mathieu Chartier <mathieuc@google.com> Change IsMovingGCDisabled to take into account GC critical sections

Fixes CC test 130.

Test: test-art-host

Change-Id: I39a0d6b88a7e651a5fb2320fd34c5a8bdc615345
55113edeec3a6dee22ac2198b56258247440ee80 11-Feb-2017 Hiroshi Yamauchi <yamauchi@google.com> Use the alternate 32-bit base address for asan build only.

Following up
https://android-review.googlesource.com/#/c/331545/.

Bug: 34606909
Test: marlin-userdebug asan coverage build boots
Test: test-art-host

Change-Id: I3fbf64a822520992670e91cc857f7279bd288546
ecc8230c708a1cc36c580951fa5759b0770f723b 16-Feb-2017 Mathieu Chartier <mathieuc@google.com> Revert "Revert "Avoid adding region space bitmap to heap bitmap""

The issue was that hprof dumping could run in the middle of non CC
GC. This meant the allocation stack and live bitmap could both visit
the same object. The solution is to use a GC critical section.

Bug: 34967844

Test: test-art-host

This reverts commit 215835daf496f44b94b37eb89dd659f84e3ae44d.

Change-Id: I99e65ff31ece74aa94fc55cc7480e27c1e39661b
215835daf496f44b94b37eb89dd659f84e3ae44d 16-Feb-2017 Richard Uhler <ruhler@google.com> Revert "Avoid adding region space bitmap to heap bitmap"

This reverts commit fdb7d5d882a5f18326746cd92e83473be48231eb.

Test failures due to failing the added DCHECK.

Bug: 34967844
Change-Id: If4a6ec70330c7f773b550481c3dd2e7a2e5d4f9a
fdb7d5d882a5f18326746cd92e83473be48231eb 16-Feb-2017 Mathieu Chartier <mathieuc@google.com> Avoid adding region space bitmap to heap bitmap

Adding the bitmap here really served no purpose and caused
VisitObjects to visit region space bitmap objects twice. This had
unwanted results like adding objects to hprof dumps twice.

Regression test is covered by DCHECK in hprof and test 130.

Test: N6P boot and test-art-host

Bug: 34967844
Change-Id: I53a6075d577430089bb42f84a3c80c1cc5302206
4f4a28dc26c1e6ef73df5b2da1fe9803dbc334b5 09-Feb-2017 Richard Uhler <ruhler@google.com> RegisterNativeAllocation: avoid an extraneous blocking gc.

If another thread already ran a blocking gc since
RegisterNativeAllocation was entered, there's no need to run another
blocking gc before exiting RegisterNativeAllocation.

Bug: 29156652
Bug: 32576211
Test: 004-NativeAllocations run test.
Change-Id: Ie89652760deaa24b70adb07227a9918059da46c7
caaa2b05cf581d5c5fc4253723ddd3299b3c3e25 01-Feb-2017 Richard Uhler <ruhler@google.com> Revert "Revert "Redesign implementation of RegisterNativeAllocation.""

This reverts commit 36bdbd2bf2ee36662f700b63474b546a7abecfa3.

Bug: 29156652
Bug: 32576211
Test: 004-NativeAllocations in a loop with high machine load.
Change-Id: I4470222c66aef4e0daa7612c84177b6c35bd28a9
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
4d444c87dc3d74f0f7136c6ac8a23929e0aac7a6 01-Feb-2017 Hiroshi Yamauchi <yamauchi@google.com> Fix address space conflict with asan in 32-bit.

Asan reserves 0x04000000 - 0x20000000 in 32-bit.

Bug: 34606909
Test: marlin-userdebug asan coverage build boots.
Test: test-art-host
Change-Id: I3ee9cd290cd02de02e7d6c79b854479a985549c3
4934eb1845a2b2535ebe086e906b45535a695a13 30-Jan-2017 Andreas Gampe <agampe@google.com> ART: Fix GC pause reporting

CC doesn't use ScopedPause normally, but that was hidden by it using
it for a debug check. Add a parameter for reporting.

Add explicit marking of the pause in CC. Currently this will conservatively
approximate pause times, as the actual pause is hidden inside ThreadList.

Clean up run-test 908.

Bug: 31684633
Test: m ART_TEST_RUN_TEST_NDEBUG=true test-art-host-run-test-908-gc-start-finish
Change-Id: Ie48af52e1225783b06e2e088c5adf3ef42fb5f64
72a328949cb6a882762ef140ae306f1fafd24c7e 24-Jan-2017 Mathieu Chartier <mathieuc@google.com> Temporarily increase heap min and max free

Make sure that GC doesn't run too often for TLAB ergonomics. Added a
regression test.

Bug: 34576638

Test: test-art-host

Change-Id: Ie07c7c470aaca044fea20b21cbe6bfe8667d082f
36bdbd2bf2ee36662f700b63474b546a7abecfa3 24-Jan-2017 Richard Uhler <ruhler@google.com> Revert "Redesign implementation of RegisterNativeAllocation."

This reverts commit 6bfc37d875b2556b3f1d95b00a785a09dc94ccb0.

Test failures in 004-NativeAllocations.

Bug: 29156652
Bug: 32576211

Change-Id: Ic54c67caf913024485a5c0621857d68a6fb710fa
5e8d5f01b0fe87a6c649bd3a9f1534228b93423d 18-Oct-2016 Roland Levillain <rpl@google.com> Fix some typos in ART.

Test: m build-art-host
Test: m cpplint-art
Change-Id: Ifc6ce3d0d645c4a8dca72dd483fc03fc05077130
6bfc37d875b2556b3f1d95b00a785a09dc94ccb0 24-Nov-2016 Richard Uhler <ruhler@google.com> Redesign implementation of RegisterNativeAllocation.

Improve the performance and remove the issue with GCing apps to death when
they reach the growth_limit_.

This implements the REDESIGN approach described in detail in the
document at go/understanding-register-native-allocation.

Bug: 29156652
Bug: 32576211
Test: m test-art-host
Test: vogar libcore/luni/src/test/java/libcore/util/NativeAllocationRegistryTest.java
Test: Device boots.
Test: adb bugreport and look for "Registered native bytes allocated"

Change-Id: I09176b2b0e4f0c401fe1947830fa5271060f4e61
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
2bd842872a0231b691cdff2833014413845937e7 05-Dec-2016 Andreas Gampe <agampe@google.com> ART: Move boot-image loading to ImageSpace

Move the complete loading sequence for multi-image into ImageSpace.
This simplifies Heap initialization.

Test: m test-art-host
Change-Id: I5a9ee818ce26f205c641e96288f5b4c42257e202
a9033d73a118536ece62c7f90d7f56064b4298ab 02-Dec-2016 Mathieu Chartier <mathieuc@google.com> Add more detail to rosalloc fragmentation OOME

Also include total number of free page bytes, space footprint, and
space max capacity.

Sample output:
Throwing OutOfMemoryError "Failed to allocate a 7012 byte allocation
with 103464 free bytes and 101KB until OOM; failed due to
fragmentation (required continguous free 8192 bytes, largest
contiguous free 4096 bytes, total free pages 4096 bytes, space
footprint 268435456 bytes, space max capacity 268435456 bytes)

Added a basic test to ensure the allocator coalesces properly.

Bug: 32997082

Test: test-art-host

Change-Id: I642b6ad34b98f6d98c10f242a6f6e926e0b42acc
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
e51ca8bfa8a193b64901ad214842f213adca92eb 22-Nov-2016 Nicolas Geoffray <ngeoffray@google.com> Move inline caches GC handling in JitCodeCache.

Make the classes they hold weak references and visit
them during SweepJitRoots.

This fixes the newly introduced deadlock:

Thread1:
1) Lock JitCodeCache lock to create Profiling info for
ArtMethod m.
2) m is a copied method, we need to track the actual holder,
needing to decode a weak reference.
3) Weak references are not accessible due to GC.

GC Thread:
- Disallow weak reference access.
- Wait for checkpoint.

Thread2:
- Try to lock JitCodeCache lock
- Deadlock, as Thread1 owns the JitCodeCache lock.

Test: test-art-host
bug: 31289185
bug: 33198826

Change-Id: I7ee17631015450ace8d2a0264415a81c5a902bb8
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
1b0adbf7b14973c3f110976de046d75a7d4ed934 15-Nov-2016 Hiroshi Yamauchi <yamauchi@google.com> Ensure CC GC is used for the read barrier config.

To prevent the -Xgc option from causing unsupported GC types to run.

Bug: 12687968
Test: test-art-host with CC.
Change-Id: I10b42190c0888342e9127c52e863ddae82e4d7a1
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
12b58b23de974232e991c650405f929f8b0dcc9f 01-Nov-2016 Hiroshi Yamauchi <yamauchi@google.com> Clean up the runtime read barrier and fix fake address dependency.

- Rename GetReadBarrierPointer to GetReadBarrierState.
- Change its return type to uint32_t.
- Fix the runtime fake address dependency for arm/arm64 using inline
asm.
- Drop ReadBarrier::black_ptr_ and some brooks code.

Bug: 12687968
Test: test-art with CC, Ritz EAAC, libartd boot on N9.
Change-Id: I595970db825db5be2e98ee1fcbd7696d5501af55
4af14174ee8cc2c443c92e263bba59cfe8e41a85 25-Oct-2016 Hiroshi Yamauchi <yamauchi@google.com> Avoid unnecessarily clearing/resetting region_space_ for each GC.

Bug: 12687968
Test: test-art-host with CC.
Change-Id: Idf8e6753ba9de23866e15634a093b47ae6a5c239
6e6078ab06e16bb4032b363316360f3b76685e30 25-Oct-2016 Mathieu Chartier <mathieuc@google.com> Clear (madvise) card table for CC

Since the cards are not really used, we can madvise them to reduce
RAM. Image and zygote cards are cleared in pause to prevent races
between with mutators.

Pause time goes up by only 1.5us on N6P maps:
(Paused)ClearCards: Sum: 755us 99% C.I. 0.250us-28us Avg: 1.540us Max: 28us

AOSP N6P before (60s after boot system wide CC):
4,194K: .GC
4,172K: .GC
4,110K: .GC

After:
3,253K: .GC
3,205K: .GC
3,245K: .GC

Bug: 12687968

Test: test-art-host

Change-Id: I3194b5b8044c2dca427302c32d9974920fecb289
9b8c5880de9b0f7dd8b1b863520714a9700a8dc2 22-Oct-2016 Andreas Gampe <agampe@google.com> ART: Add GC callbacks

Add start and end of pause callbacks.

Fix setup and missing functions in test 907.

Bug: 31684633
Test: m test-art-host
Test: m test-art-host-run-test-908-gc-start-finish
Change-Id: I1d8872ef9cd6914de7fb033cd873f8d5cb48ea17
7ec38dcb84d61f6172bbb5a303bd5ab7139f7409 08-Oct-2016 Mathieu Chartier <mathieuc@google.com> Persistent bitmap for region space

Fix bug where region space was not safely walkable due to holes
in the unevac regions possibly having dangling class pointers.

No preformance change, RAM overhead 1.1-1.2% .Heap (non LOS).

Test: test-art-host
Test: https://android-review.googlesource.com/#/c/288907/

Bug: 31522820

Change-Id: Ic4f8b7175e117689cb1ce3e28b082cf63f1f7b5a
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
11a66e40891234c4e54fb4c4e37f45f1651af770 18-Oct-2016 Andreas Gampe <agampe@google.com> ART: Do not free allocation listener in heap destructor

Do not deallocate on exit. Libraries are freed only after the heap
has already been destroyed.

Bug: 31684277
Bug: 31684920
Test: m test-art-host
Change-Id: I7061c4500a9ad314e2c00d7d722bb3372dff4810
31e88225b2ef68e7f32f11186acf922c74ddabab 15-Oct-2016 Mathieu Chartier <mathieuc@google.com> Move most mirror:: args to ObjPtr

Fixed possible moving GC bugs in ClinitImageUpdate class.

Bug: 31113334

Test: test-art-host
Change-Id: I0bf6578553d58b944aaa17665f1350bdf5ed15ec
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
2d8559517759dcfac749a28d6713d36809ec556f 13-Oct-2016 Mathieu Chartier <mathieuc@google.com> Move Heap::GetInstances to use Handles

Prevent moving GC bugs from VisitObjects. Fix JDWP tests.

Test: art/tools/run-jdwp-tests.sh '--mode=host' '--variant=X32' --debug

Bug: 31113334
Change-Id: Ie7f51f1980ec0c1eddc3b59c3e49564eacb3be85
aea9bfb051bb197fdfb63d56ff0f3d63b36eb499 13-Oct-2016 Mathieu Chartier <mathieuc@google.com> Use handles for GetReferringObjects

Required since VisitObjects may cause thread suspension. Fixes
failing jdwp tests.

Test: test-art-host
Test: art/tools/run-jdwp-tests.sh '--mode=host' '--variant=X32' --debug

Bug: 31113334
Change-Id: Ic11780b3778c83e7812bc90c0723a293537f376c
172ec8e37505727a1c514f5f5981bd1b3dbe44f3 12-Oct-2016 Andreas Gampe <agampe@google.com> ART: Fix typo

Follow-up to commit 27fa96c285c4aa2f64e9bb63a3f38ffdc98c282a.

Bug: 31684277
Test: m test-art-host
Change-Id: I165b350f6c1a216ed6a7ca648abd6004c662c1cb
3b1d1b7727ed9166c4ee7d0f66dec56d511bac83 12-Oct-2016 Hiroshi Yamauchi <yamauchi@google.com> Fix the CC monkey crashes.

Add ScopedGCCriticalSection around the monitor deflation to avoid race
conditions on the lock word.

Bug: 31773180
Bug: 31712602
Bug: 31712174
Bug: 31712601
Bug: 31712256
Bug: 31710993
Bug: 12687968
Test: test-art host/N9, N9 libartd boot, Ritz EAAC.
Change-Id: Id05c6502fb08ca2e0770af4940b737038c3412d6
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
27fa96c285c4aa2f64e9bb63a3f38ffdc98c282a 08-Oct-2016 Andreas Gampe <agampe@google.com> ART: Add allocation callback

Bug: 31684277
Test: m test-art-host
Change-Id: I959f44e23ca5fe55ed678315708895faf0aadb04
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
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
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
866d874c4fca90385251a1df28eed0eb6e1b88e2 22-Sep-2016 Mathieu Chartier <mathieuc@google.com> Make image test multi image

Required for testing multi image layout in future CLs.

Bug: 28640955

Test: clean-oat-host, test-art-host, device booting

(cherry picked from commit 25adcfb7dc81131add3a0a681ae18bced6f7a0e0)

Change-Id: I14809f56e711b4a87e01056c327eddbbd087f4ee
25adcfb7dc81131add3a0a681ae18bced6f7a0e0 22-Sep-2016 Mathieu Chartier <mathieuc@google.com> Make image test multi image

Required for testing multi image layout in future CLs.

Bug: 28640955

Test: clean-oat-hos, test-art-host, device booting

Change-Id: I14809f56e711b4a87e01056c327eddbbd087f4ee
268764da8022cafa5661c5b514eaa343c5257e57 13-Sep-2016 Mathieu Chartier <mathieuc@google.com> Make ScopedAssertNoThreadSuspension no overhead for non-debug

Previously it required Thread::Current() which may not be free.
The plan is to add a lot more ScopedAssertNoThreadSuspension in
the codebase.

Also cleaned up callers.

Bug: 31458474
Change-Id: I5a1621a5435476504d22266cc01a9bf26aab7568
a01d06618b08688472d2609220c3ba9c9d6de6f4 31-Aug-2016 Hiroshi Yamauchi <yamauchi@google.com> Fix a check failure in the CC background transition.

If there's a process state update from jank perceptible to jank
in-perceptible and a reverse update right after it, there's a chance
that the heap task daemon sees desired_collector_type ==
kCollectorTypeCC rather than kCollectorTypeCCBackground in
DoPendingCollectorTransition() which leads to a !kUseReadBarrier check
failure in TransitionCollector(). The fix is to move this check after
the early return case where collector_type == collector_type_ in
TransitionCollector() like the CMS/Hspace case.

Bug: 31039431
Bug: 12687968
Test: test-art-host, aosp boot with CC, master boot with CC.

Change-Id: I5fe34cb41eaa01c6d8bf80a185253fde6778e852
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
6fb276b5e6ac92a25edde51a6f5f4c70eb3e2cf8 26-Aug-2016 Hiroshi Yamauchi <yamauchi@google.com> Fix a race condition on GC timing logger data.

The GC timing logger data is thread local to the GC thread and
shouldn't be used by a mutator. The original intention was to have a
systrace scope.

This should fix the 004-JniTest failures.

Bug: 30980189
Bug: 29517059
Bug: 12687968
Test: test-art-host
Change-Id: Ibc8cfbfdd64d85ff65bf220d3022fc8fdf1064f2
60985b7a56d4fa7170721808734093a3affc41c6 24-Aug-2016 Hiroshi Yamauchi <yamauchi@google.com> Background full compaction for CC.

Invoke a full compaction with the CC collector when an app goes to the
background like the HSpace compaction for the CMS collector.

Bug: 31039431
Bug: 12687968
Test: test-art, Ritz EAAC, N9 libartd.so device boot with CC
Change-Id: I119aa26c1d3c167b12983fffcb16164929bf8f68
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
962cd7adf3d9d2a1dedf0318056a29e9390f1c38 16-Aug-2016 Mathieu Chartier <mathieuc@google.com> Always mark zygote large objects for CC

Prevent needing to gray holders of zygote large objects.
System wide zygote space PSS after boot:
12644 kB -> 5571 kB for CC.

Also PSS reduction in zygote large objects themselves since their
gray bit would have been set each GC.
Overall LOS savings hard to measure, could be up to 316 * 4KB per
app since there are 316 zygote large objects.

Also clear mod-union tables for image spaces to prevent dirty
image pages if any of the image spaces point to zygote large objects.
System wide .art mmap: 37432 kB -> 34372 kB

System server before (N6P):
LOS shared dirty: 12888 kB
Zygote space shared dirty: 700 kB
Zygote space private dirty: 868 kB
.art private dirty: 1696 kB

After:
LOS shared dirty 13672 kB
Zygote space shared dirty: 1072 kB
Zygote space private dirty: 496 kB
.art private dirty: 1432 kB

Bug: 29516968

Test: test-art-host with baker CC, debug N6P phone booting

Change-Id: Ia37ce2c11217cf56885bd1d1dc084332fcbb7843
a463b6a920a2a0bf14f9cca20a561b412b9349d1 13-Aug-2016 Andreas Gampe <agampe@google.com> ART: Refactor ImageSpace loading

Make the code more straightforward so it is easier to reason
about and extend.

Also change return types to unique pointers so it's clear that
it is the caller's responsibility to free those when necessary.

Bug: 30832951
Test: m test-art-host
Test: device booting
Change-Id: I3216eb702e45357a48af5158dacbe40e79bd1ae9
8da690f6ec82621a484c58be7dc57325582193b4 11-Aug-2016 Vladimir Marko <vmarko@google.com> Initialize Heap's collector pointers to null.

Test: Run ART test suite on host.
Bug: 30807718
Change-Id: I9b83b44df250b00af48dc1aa653d78aea84d0874
99c959f3868512bb95432cf02a1f0ad3971698bf 30-Jul-2016 Nicolas Geoffray <ngeoffray@google.com> Put the deletion of profiling info under a GC critical section.

Otherwise the GC could see dangling pointers.

bug:30033802

(cherry picked from commit cf48fa030780c3185f225d558b704c396f7713cc)

Change-Id: I2c43e973878f50dc147aa0af81551ecc942a790d
8261d02f9523b95013108f271b82bb157ef6f71d 08-Aug-2016 Mathieu Chartier <mathieuc@google.com> Revert "Revert "ARM64 asm for region space array allocation""

Also added missing large object check. No regression from the check
N6P CC EAAC time at 1313 for 10 samples vs 1314 before reverts.

Bug: 30162165
Bug: 12687968

Test: test-art-target with CC + heap poisoning

This reverts commit 6ae7f3a4541e70f04243a6fe469aa3bd51e16d79.

Change-Id: Ie28f652f619898d7d37eeebf3f31a88af8fac949
36a270ae4f288e49493432b7128f899ad579849e 29-Jul-2016 Mathieu Chartier <mathieuc@google.com> Change one read barrier bit to mark bit

Optimization to help slow path performance. When the GC marks an
object through the read barrier slow path. The GC sets the mark bit
in the lock word of that reference. This bit is checked from the
assembly entrypoint the common case is that it is set. If the bit is
set, the read barrier knows the object is already marked and there is
no work to do.

To prevent dirty pages in zygote and image, the bit is set by the
image writer and zygote space creation.

EAAC score (lower is better):
N9: 777 -> 700 (average 31 of runs)
N6P (960000 mhz): 1737.48 -> 1442.31 (average of 25 runs)

Bug: 30162165
Bug: 12687968

Test: N9, N6P booting, test-art-host, test-art-target all with CC

Change-Id: Iae0cacfae221e33151d3c0ab65338d1c822ab63d
cf48fa030780c3185f225d558b704c396f7713cc 30-Jul-2016 Nicolas Geoffray <ngeoffray@google.com> Put the deletion of profiling info under a GC critical section.

Otherwise the GC could see dangling pointers.

bug:30033802
Change-Id: I839c4f6e537aba98769e99e4d75ff869c9ff13eb
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
56fe25895e91d34a0a017429468829a20bdd5ae4 14-Jul-2016 Mathieu Chartier <mathieuc@google.com> Add a way to measure read barrier slow paths

If enabled, this option counts number of slow paths, measures the
total slow path time per GC and records the info into a histogram.
Also added support for systrace to see which threads are performing
slow paths.

Added runtime option -Xgc:measure to enable. The info is dumped
for SIGQUIT.

Test: Volantis boot with CC, test-art-host with CC, run EEAC with CC
and -Xgc:measure

Bug: 30162165

Change-Id: I3c2bdb4156065249c45695f13c77c0579bc8e57a
b6bab0f96f7426ca12ba377ec74ff1b62918cd27 19-Jul-2016 Hiroshi Yamauchi <yamauchi@google.com> Tune the GC ergnomics for the read barrier config.

Add 1.0 to the heap growth multiplier for the read barrier config, which
reduces the GC frequency down to roughly the same as CMS in one of the
jank tests.

Bug: 29517059
Bug: 12687968
Test: ART run-tests.
Change-Id: I1302a2f17e862f152d2f92bc06a65c9e6defcba0
4799530dfe335c081e5102539f88963bd8f6c8df 10-Jun-2016 Hiroshi Yamauchi <yamauchi@google.com> Fix the region space name for dumpsys meminfo.

Bug: 12687968
Change-Id: I42e3d4cd9afb9892eb1d173b18f8b3e9491429dd
f0192c86a58b2f43378c9a2113007538dd38ddbf 29-Mar-2016 Jeff Hao <jeffhao@google.com> Support to pass <uses-library> option through to dex2oat.

This change takes an app's shared libraries specified by <uses-library>
and passes it through to dex2oat to be used during compilation.

Part of a multi-project change.

Bug: 26880306

(cherry-picked from commit 26e8a2f150cd7f7195a10650ab8a5b6fa5014bc8)

Change-Id: I72a352abdfc37eacd8bedfa6c218e3809ca8e39c
5d2a3f7bdd23003af78e3f09e96b9f77ff33c4b6 11-May-2016 Mathieu Chartier <mathieuc@google.com> Add histogram for native allocations

Shows up in traces.txt, sample output:
Histogram of native allocation 0:4315,131072:33,1179648:3 bucket size 131072
Histogram of native free 0:995,131072:19,1179648:2 bucket size 131072

Bug: 28680116

(cherry picked from commit 0dce75dc6945c221a054eb9c479fb60efd193719)

Change-Id: Iaa07c6b8da0d6bab64a8fd4af8a02fc0b8c70e9e
0dce75dc6945c221a054eb9c479fb60efd193719 11-May-2016 Mathieu Chartier <mathieuc@google.com> Add histogram for native allocations

Shows up in traces.txt, sample output:
Histogram of native allocation 0:4315,131072:33,1179648:3 bucket size 131072
Histogram of native free 0:995,131072:19,1179648:2 bucket size 131072

Bug: 28680116

Change-Id: I584eb85709d3ae28f5142a01af11075a2a6436d7
ffc87076dda9878cb2cc098149bae441d38b9268 20-Apr-2016 Calin Juravle <calin@google.com> Split profile recording from jit compilation

We still use ProfileInfo objects to record profile information. That
gives us the flexibility to add the inline caches in the future and the
convenience of the already implemented GC.

If UseJIT is false and SaveProfilingInfo true, we will only record the
ProfileInfo and never launch compilation tasks.

Bug: 27916886

(cherry picked from commit e5de54cfab5f14ba0b8ff25d8d60901c7021943f)

Change-Id: I68afc181d71447895fb12346c1806e99bcab1de2
5872d7cd6ceffe67550d0b021191ec66f1a34c5d 27-Apr-2016 Jeff Hao <jeffhao@google.com> Support to pass <uses-library> option through to dex2oat.

This change takes an app's shared libraries specified by <uses-library>
and passes it through to dex2oat to be used during compilation.

Part of a multi-project change.

Includes fix from a6d46161aea07ebd1cbd6ab78b2b323f940e9c1e

Bug: 26880306

(cherry-picked from commit 26e8a2f150cd7f7195a10650ab8a5b6fa5014bc8)

Change-Id: I6bfc13693dbb835ca52fed2d03ec5346d43ec5d9
e5de54cfab5f14ba0b8ff25d8d60901c7021943f 20-Apr-2016 Calin Juravle <calin@google.com> Split profile recording from jit compilation

We still use ProfileInfo objects to record profile information. That
gives us the flexibility to add the inline caches in the future and the
convenience of the already implemented GC.

If UseJIT is false and SaveProfilingInfo true, we will only record the
ProfileInfo and never launch compilation tasks.

Bug: 27916886
Change-Id: I6e4768dc5d58f2f85f947b276b4244aa11ce3fca
26e8a2f150cd7f7195a10650ab8a5b6fa5014bc8 29-Mar-2016 Jeff Hao <jeffhao@google.com> Support to pass <uses-library> option through to dex2oat.

This change takes an app's shared libraries specified by <uses-library>
and passes it through to dex2oat to be used during compilation.

Part of a multi-project change.

Bug: 26880306

Change-Id: Ib70a48ff700a5db9a5b4aaf731552556878ad8f7
cee1321190401800504e42a9ccfe5e681d6be119 05-Apr-2016 Mathieu Chartier <mathieuc@google.com> ART: Handle OOM in stack overflow

When creating a stack overflow error, we must not allocate a
new out-of-memory error. Running its constructor will lead to
a nested exception.

Bug: 27663199

(cherry picked from commit e8f3f03ce142d9cdb10a1bb6bbbb428d0e8b672f)

Change-Id: I96b9682c3eb6ad71140a062cb357d4334c7fdaa5
e8f3f03ce142d9cdb10a1bb6bbbb428d0e8b672f 05-Apr-2016 Mathieu Chartier <mathieuc@google.com> ART: Handle OOM in stack overflow

When creating a stack overflow error, we must not allocate a
new out-of-memory error. Running its constructor will lead to
a nested exception.

Bug: 27663199

Change-Id: I2a7b5b937730eeade22dce654cfc4ad903c5f040
b62f2e6f3f8d66b3231ecec14ea9365733371b39 23-Mar-2016 Hiroshi Yamauchi <yamauchi@google.com> Add RosAlloc stats dump.

For better understanding of the RosAlloc space.

(cherrypick commit 565c2d9bce43c430d4267c82f5702160d971e712)

Bug: 27744947
Bug: 9986565

Change-Id: I8309761a68fbc143bbcd8458a9194085aace7c3e
565c2d9bce43c430d4267c82f5702160d971e712 23-Mar-2016 Hiroshi Yamauchi <yamauchi@google.com> Add RosAlloc stats dump.

For better understanding of the RosAlloc space.

Bug: 27744947
Bug: 9986565
Change-Id: I02a8028b9728f6862e5e78588a368b8029bb5c1a
f8cb1781a4e4be5df1f845206f7b37ed89092b64 19-Mar-2016 Mathieu Chartier <mathieuc@google.com> Move process state into runtime

Clean up.

Bug: 27420435

(cherry picked from commit f8484c8b55f4b423048f94dfabbe44110a039a9b)

Change-Id: Ia20781ee36e6a31c88ca41d3866b26813cff434d
f8484c8b55f4b423048f94dfabbe44110a039a9b 19-Mar-2016 Mathieu Chartier <mathieuc@google.com> Move process state into runtime

Clean up.

Bug: 27420435

Change-Id: I8fff84ed1b29a12310094b10fb6382268e69d54b
6f0c6cdae6962532c4699df9dd5af6289b86d1c6 19-Mar-2016 Hiroshi Yamauchi <yamauchi@google.com> Fix a CC 145-alloc-tracking-stress deadlock.

When the allocation tracking gets disabled, there may be threads
blocking on the system weak access for recording allocations, but when
GC reenables the system weak access, it fails to wake up those blocked
threads (which causes a deadlock) because the broadcast call is guarded
by Heap::IsAllocTrackingEnabled(), which is false at this point.

Broadcast in Heap::BroadcastForNewAllocationRecords() regardless of
Heap::IsAllocTrackingEnabled(), which is safe.

Also apply a similar fix for the non-CC case.

Bug: 27467554
Change-Id: I74cf88bceb306589ce11a19a688be223e099e88a
14b0a5ddc0ae305e3ac152c34e4d6fdd0abb854c 12-Mar-2016 Mathieu Chartier <mathieuc@google.com> Fix cases where we miss instrumentation changes

Moved allocation stack push to after we record the allocation since
it can cause thread suspension.

Added handling in entrypoint utils for thread suspension cases.

Keep the AllocRecordObjectMap around since we do not want to delete
it if there are any threads waiting on new_record_condition_. The
condition guards adding stack traces while the GC is running. If we
delete the map and there are still waiters that did not resume, it
caused a CHECK failure. This could happen in cases where one thread
disables allocation tracking while other threads are about to
resume from the condition.

Bug: 27506909

(cherry picked from commit 0f394021d6abfdf9ebea6c7f405ec936a812ea62)

Change-Id: I1dc51e9f000684b4032b57beab59d317ece26f06
0f394021d6abfdf9ebea6c7f405ec936a812ea62 12-Mar-2016 Mathieu Chartier <mathieuc@google.com> Fix cases where we miss instrumentation changes

Moved allocation stack push to after we record the allocation since
it can cause thread suspension.

Added handling in entrypoint utils for thread suspension cases.

Keep the AllocRecordObjectMap around since we do not want to delete
it if there are any threads waiting on new_record_condition_. The
condition guards adding stack traces while the GC is running. If we
delete the map and there are still waiters that did not resume, it
caused a CHECK failure. This could happen in cases where one thread
disables allocation tracking while other threads are about to
resume from the condition.

Bug: 27506909
Change-Id: I097689ca35ad408121c6b8dabd28e75cce1a43a0
b6e20ae17d0881a66c22532e4152ce6779454a92 07-Mar-2016 Nicolas Geoffray <ngeoffray@google.com> Clear inline caches at each full GC.

This fixes occasional failures of 141-class-unload.

Also fix a bug where clearing inline caches also cleared the dex
pc associated with it.

bug:26846185
bug:23128949
Change-Id: I77bf1dee229d7764c3cc21440829c7fba7b37001
35fd969d663f8f89ecdbdb14e52e4f03e37d3f86 02-Mar-2016 Mathieu Chartier <mathieuc@google.com> Delete alloc tracking map outside of critical section

There can be lock order violations otherwise due to runtime shutdown
lock that may get acquired in the condition variable destructor.

Bug: 27506909

(cherry picked from commit 0b8b4a609120b90081d898dbf3c26f68fe80de96)

Change-Id: I6972c450db8856e30c13e27aea94b01943618f64
bcd9dd7d1223eaa60f188d1a109d26e5e0143e10 07-Mar-2016 Mathieu Chartier <mathieuc@google.com> Don't use ScopedObjectAccess in Heap::DumpSpaces

ScopedObjectAccess does not work well if the mutator lock is
excusively held while in a suspend thread state. This caused
deadlocks and DCHECK failures.

Bug: 27493316

(cherry picked from commit 03d21bc5bed887243ff6ce3531179185ffd3532c)

Change-Id: I5d67f74fc7082761e45dc1d7778b0ea7fceaaf8f
03d21bc5bed887243ff6ce3531179185ffd3532c 07-Mar-2016 Mathieu Chartier <mathieuc@google.com> Don't use ScopedObjectAccess in Heap::DumpSpaces

ScopedObjectAccess does not work well if the mutator lock is
excusively held while in a suspend thread state. This caused
deadlocks and DCHECK failures.

Bug: 27493316
Change-Id: I75ab223b2d15ab4e53753f1046c580228fc1866e
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
0b8b4a609120b90081d898dbf3c26f68fe80de96 02-Mar-2016 Mathieu Chartier <mathieuc@google.com> Delete alloc tracking map outside of critical section

There can be lock order violations otherwise due to runtime shutdown
lock that may get acquired in the condition variable destructor.

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

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

Added stress test.

Bug: 27337759

(cherry picked from commit eebc3af4453f5c1fb5fd80c710cfd49566080d28)

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

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

Added stress test.

Bug: 27337759

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

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

Change-Id: Id148069ccad95e2339ba214742ae3ef4f084f495
20a0be0299183b54be9643820294e011d3358823 20-Feb-2016 Hiroshi Yamauchi <yamauchi@google.com> Fix CC collector thread flip and JNI critical section deadlocks.

There's a bug in the synchronization between the CC collector's thread
flip and JNI critical sections where it incorrectly attempts to make
the synchronization scheme to be writer (GC) preference to avoid
starvation of GC in the presence of frequent JNI critical section
enter/exit. This could cause a deadlock between them if a thread
enters a nested JNI critical section after a thread flip occurs. This
is reproduced in the added test.

The fix is to use a thread local disable counter in addition to the
global counter to detect a nested enter by the same thread and avoid
waiting if nested.

Bug: 19235243
Bug: 12687968
Change-Id: Idf7720a6906c9ea508219935af3727f76680d2d8
6edb9aecdbe8b31f7ae1d35f21d013631337a424 08-Feb-2016 Hiroshi Yamauchi <yamauchi@google.com> Check pages are readable after mprotect for SEGV_ACCERR diagnosis

We have a suspected mprotect issue where we see seg faults after pages
are mprotected with PROT_READ|PROT_WRITE with the SS collector on
host. This change attempts to see if earlier reads would cause faults
similarly.

Bug: 19894268

Change-Id: I041a663c6b55b747120915f73a0db5f566744ed8
582b68f654de87fb04b453f243733ffe119d1481 04-Feb-2016 Mathieu Chartier <mathieuc@google.com> Use correct requested alloc space begin for CC

Now we restore the original value instead of setting to null.

Bug: 26970047
Change-Id: I94d546c3a69ddf11805990a1003707bf55013328
b08f305b2514f26bfeb54072191f5336e1f37a1e 03-Feb-2016 Mathieu Chartier <mathieuc@google.com> Prevent crashes if boot images fail to load

We now reset the requested_alloc_space_begin so that there are no gaps
between any boot images and the non moving space.

Also clear boot_image_spaces so that ClassLinker::InitFromBootImage is
not called.

Finally, delete image spaces so that the maps and oat files are
unmapped.

Bug: 26913820

(cherry picked from commit 1e5ff87e774fdbd46efb1d2f61b1b2ab80145a19)

Change-Id: Ia31937f29ef217eac083165dfff37cd068fbd32b
1e5ff87e774fdbd46efb1d2f61b1b2ab80145a19 03-Feb-2016 Mathieu Chartier <mathieuc@google.com> Prevent crashes if boot images fail to load

We now reset the requested_alloc_space_begin so that there are no gaps
between any boot images and the non moving space.

Also clear boot_image_spaces so that ClassLinker::InitFromBootImage is
not called.

Finally, delete image spaces so that the maps and oat files are
unmapped.

Bug: 26913820

Change-Id: If5058a214456bd123163ae064a0c66d6a77d6309
c68e77b3e446e248ed025bfc756a0e83718918ad 28-Jan-2016 Mathieu Chartier <mathieuc@google.com> Fix image test with GSS

There was a gap between image space and non moving space for some
reason. No time for a better fix.

Bug: 26849108

Change-Id: If7fe9db060b7accbffd1b4636ce4e0d82a02ed7b
ace0dc1dd5480ad458e622085e51583653853fb9 20-Jan-2016 Andreas Gampe <agampe@google.com> ART: Add option to ensure deterministic compilation

To ensure reliable stable generation of a boot image, add a flag
for forced determinism, trading compile time for a deterministic
output.

We have to run certain passes in the compiler-driver single-threaded.
It is also necessary to try to make the heap layout deterministic.
Switch to nonconcurrent GC, use the free-list implementation for LOS,
and try to allocate the main space at a known location. This is best
effort at the moment.

To allow the compiler phase to be parallelized, const-strings need
to be created beforehand.

The identity hashcode seed needs to be pinned.

Besides the Dex object we also need to null the DexFile pointer in
dex caches.

For classes, we need to remove the clinit thread ID.

Fix oatdump alignment padding accounting.

Bug: 26687569
Change-Id: Ia82120e8f715bb3691d861817b12778ac677355a
76ce917c546d4793316cd8356a12c2791406ae39 27-Jan-2016 Mathieu Chartier <mathieuc@google.com> Move heap trim outside of zygote creation lock region

Fixes lock order violation due if non moving space is a RosAllocSpace
since the trim requires acquiring the mutator lock.

Change-Id: Iff0b8c943e261702eda65b3c255fda24a6fe14c2
a9d82fe8bc6960b565245b920e99107a824ca515 26-Jan-2016 Mathieu Chartier <mathieuc@google.com> Use mutator lock to guard adding and removing heap spaces

Too hard to add a new lock since dlmalloc ArtMoreCore requires
looping through the spaces while holding the allocator lock.

Bug: 22858531
Change-Id: Ieac2136da02c766b6795cd604a58798bee37ef2a
fbc31087932a65e036a153afab3049dc5298656a 24-Jan-2016 Mathieu Chartier <mathieuc@google.com> Revert "Revert "Load app images""

This reverts commit 1bc977cf2f8199311a97f2ba9431a184540e3e9c.

Bug: 22858531

Change-Id: Ide00bf3a73a02cba3bb364177204ad1b13f70295
966f533da85f5bf0b17c9de70598707cdc2655a7 25-Jan-2016 Mathieu Chartier <mathieuc@google.com> Only create non-moving space at fixed address if zygote

Pulled from app image CL, hopefully fixes dex2oat asan failure.

Change-Id: I022f7509b534679e5a4ef99ec7a0c622472cf740
1bc977cf2f8199311a97f2ba9431a184540e3e9c 23-Jan-2016 Nicolas Geoffray <ngeoffray@google.com> Revert "Load app images"

Fails when a method is duplicated (see test 097-duplicate-method)

Bug: 22858531

This reverts commit f7fd970244f143b1abb956e29794c446e4d57f46.

Change-Id: Ib30ae5be00cc568e799290be6b3c8f29cbbe4c20
f7fd970244f143b1abb956e29794c446e4d57f46 09-Nov-2015 Mathieu Chartier <mathieuc@google.com> Load app images

Support in-place patching of the app image based on boot image
location and app oat location. Only loads for art run test so far
since we do not automatically generate app images for app installs.

N5 maps launch time (~200 runs):
Before: 930ms
After: 878.18ms
After + image class table: 864.57ms

TODO:
Oatdump support.
Store class loaders as class roots in image.

Bug: 22858531

Change-Id: I9cbc645645e62ea2ed1ad8e139e91af7d88514c1
a06ba0589b2e29ee620432db053186056e074552 06-Jan-2016 Mathieu Chartier <mathieuc@google.com> Remove gaps between images

We now use the same logic to calculate the size as we use to create
the image header. This should mean that it always lines up correctly.
Previously the alignment rounding could have caused page off by one
errors in some cases.

Re-enable no gap check in heap.cc.

Bug: 26317072
Change-Id: I558a4e60197ca4613fc4ec4c3a618c64a83d006a
ea0831f60d26e3297e6463634a9fbb6384f00661 29-Dec-2015 Mathieu Chartier <mathieuc@google.com> Re-enable adding intern table to image

Changed intern table to have a stack of tables similarily to
ClassTable. Adding an image intern table adds to the front of the
intern table stack. Also some cleanup.

Bug: 26317072

Change-Id: I7bbf9485b5dbbbf3707fed21e29de3beccfb8705
8994a04162a92759f8ec531d18ee8901145dfda0 30-Dec-2015 Andreas Gampe <agampe@google.com> Revert "Revert "ART: Fix up some multi-image cases""

This reverts commit de38b797c3e5ba3ee44c480db7093386975c51eb.

Fix up imgdiag for std::string and multi-image.

Bug: 26317072
Bug: 26320300

Change-Id: I94ce9528e9fea6fb3231a70c32db02d567143db9
de38b797c3e5ba3ee44c480db7093386975c51eb 30-Dec-2015 Nicolas Geoffray <ngeoffray@google.com> Revert "ART: Fix up some multi-image cases"

Fails imgdiag_test on device.

Bug: 26317072
Bug: 26320300

This reverts commit 288b1e9a0dddfb91e85067fe81de55174f313c7c.

Change-Id: Iccd05827b0630281b6f959331eaa4202526df78e
288b1e9a0dddfb91e85067fe81de55174f313c7c 28-Dec-2015 Andreas Gampe <agampe@google.com> ART: Fix up some multi-image cases

Change the auto-generated multi-image names to include the path
components from the first image, as well as prefix them with the
first image's name to disambiguate. This fixes vogar-style usage.

Fix an out-of-bounds issue in dex2oat when dex files are missing.

Forbid generating or patching multi-image parts when loading images.
Instead just fail loading them.

Remember ImageSpace instances that have been added while trying to
load a multi-image set. Remove all loaded instances when the overall
loading process fails.

Refactor the dex location adaptation into ImageSpace. Reuse the code
in the Runtime path for fallback, so that all dex files can be found
correctly.

Fix an out-of-bounds access in OatFileAssistant in fallback mode.

Partially reverts d895961d07a1d320b29f2045a48bc5a1944a4d3c. Push an
actual image name, that is, something with an art extension, to
the vogar scripts.

Partially reverts c525604b313bb77a2077e1fec43dfab76cb1b9b1. Test
119-noimage-patchoat works again.

Bug: 26317072
Bug: 26320300
Change-Id: I3f05fa77f22a2b9ca54c3105ffc53646c1928604
dcdc85bbd569f0ee66c331b4219c19304a616214 04-Dec-2015 Jeff Hao <jeffhao@google.com> Dex2oat support for multiple oat file and image file outputs.

Multiple changes to dex2oat and the runtime to support a --multi-image
option. This generates a separate oat file and image file output for
each dex file input.

Change-Id: Ie1d6f0b8afa8aed5790065b8c2eb177990c60129
e6465bc8a52cfa3995b4072810cdb7ab397a7793 15-Dec-2015 Dimitry Ivanov <dimitry@google.com> Remove references to dlmalloc specific functions

Remove references to internal libc dlmalloc_* functions
so that we can hide them for lp64

Change-Id: I13977bea63d900e1819052140e3bd6bc1f2fc759
a7a4759946d9f11c88dc108b2b6a9518ce9c1e18 24-Nov-2015 Nicolas Geoffray <ngeoffray@google.com> Revert "lambda: Add support for invoke-interface for boxed innate lambdas"

955-lambda is flaky

Bug: 24618608
Bug: 25107649

This reverts commit 457e874459ae638145cab6d572e34d48480e39d2.

(cherry picked from commit 3a0909248e04b22c3981cbf617bc2502ed5b6380)

Change-Id: I24884344d21d7a4262e53e3f5dba57032687ddb7
3a0909248e04b22c3981cbf617bc2502ed5b6380 24-Nov-2015 Nicolas Geoffray <ngeoffray@google.com> Revert "lambda: Add support for invoke-interface for boxed innate lambdas"

955-lambda is flaky

Bug: 24618608
Bug: 25107649

This reverts commit 457e874459ae638145cab6d572e34d48480e39d2.

Change-Id: I24884344d21d7a4262e53e3f5dba57032687ddb7
457e874459ae638145cab6d572e34d48480e39d2 23-Oct-2015 Igor Murashkin <iam@google.com> lambda: Add support for invoke-interface for boxed innate lambdas

Lambda closures created with the 'create-lambda' instruction
(termed "innate lambdas") can be turned into an object with 'box-lambda'.

This CL enables support for those kinds of lambdas to work with
'invoke-interface' by generating a proxy class for the lambda.

Note: MIPS32/64 support not included.

Bug: 24618608
Bug: 25107649
Change-Id: Ic8f1bb66ebeaed4097e758a50becf1cff6ccaefb
073b16c8429d302d5413e8ffc488b03b8f770780 10-Nov-2015 Mathieu Chartier <mathieuc@google.com> Image space cleanup for app images

Removed Heap::GetImageSpace, added Heap::GetBootImageSpace.

Generalized some logic in the class linker for image spaces.

Bug: 22858531

Change-Id: Ib3e12bb061a247e232d3dc93b0d6b35eb3a34d25
6be4f2ae282077e2b6ecb4244c79f1b20e19b99e 10-Nov-2015 Andreas Gampe <agampe@google.com> ART: Fix leak in Heap

Delete a mutex in the destructor.

Change-Id: I7fb8f3f9e7a30baf352f384f38520eb0dd4906eb
10d2508b105427ef1bcaf0c222873bae7acc66d3 29-Oct-2015 Mathieu Chartier <mathieuc@google.com> Change Checkpoint API to return total number of checkpoints

Fixes a race condition with SetStateUnsafe that caused some
warnings in the Barrier::~Barrier.

The race was:
RunCheckpoint sees suspended thread, runs the checkpoint. Inside the
checkpoint, the thread state had changed to runnable by
SetStateUnsafe. This occasionally caused more Barrier::Pass than
expected.

The fix is to return the total number of checkpoints instead of just
the runnable ones.

Bug: 24191051
Change-Id: If15a933ed4c8efa66a5f27cd5feaa2e5957ae804
8d447252fdd2c5f4d77cef8dc19499b4a116d876 26-Oct-2015 Mathieu Chartier <mathieuc@google.com> Trim arena maps during heap trim

Reduces RAM with verify-at-runtime.

Before:
9985 kB: .LinearAlloc

After:
6594 kB: .LinearAlloc

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

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

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

Change-Id: I580152118e068a70f309dcc19df4144afec835dd
598302ac91fd3e990f50e1aa530c3ad61d6d946e 23-Sep-2015 Mathieu Chartier <mathieuc@google.com> Call JNI_OnUnload when class loaders get collected

Added test case to 141-class-unload.

Bug: 22720414
Change-Id: I0575fae72521520a17587e8b0088bf8112705ad8
4f55e22630d99ca0edd9e951e5ee96b57bb9b980 04-Sep-2015 Mathieu Chartier <mathieuc@google.com> Add and use ScopedSuspendAll

Usage replaces most SuspendAll and ResumeAll calls.

Change-Id: I355683a5365876242cea85a656dcb58455f7a294
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
fdbd13c7af91a042eda753e436eeebf0e1937250 03-Sep-2015 Hiroshi Yamauchi <yamauchi@google.com> Some fixes for the CC collector.

- Remove a DCHECK in DisableMarkingCheckpoint, which caused
occasional (false) failures.
- Check the thread-local GetWeakRefAccessEnabled in boxed lambdas weak
access.
- Add missing BroadcastForNewAllocationRecords and
BroadcastForNewWeakBoxedLambdas. The lack of the former caused
occasional deadlocks in the ddmc test.
- Remove the 'ensure system weaks disallowed' calls, which weren't
useful and dead.

Bug: 12687968
Change-Id: I33850c8d12e6e1a3aed1c2bb18eba263cbab76e8
db00eaf64e94ab1b4289952699c3b81f73ca406a 01-Sep-2015 Mathieu Chartier <mathieuc@google.com> Add GC coverage test for moving GC

Adds testing coverage for collector transitions and homogeneous space
compaction.

Bug: 10808403

Change-Id: Ia79fecb47c33fc95d940243d6cb1068e9ee9dc9a
76f55b030d2517d434f227bee2363c3fb760e5c6 22-Aug-2015 Hiroshi Yamauchi <yamauchi@google.com> Synchronize JNI critical calls with the CC collector thread flip.

JNI critical calls (like GetArrayElementsCritical) would need to block
for the whole GC run to finish if the CC collector GC is ongoing. This
CL changes it so that they don't need to block for the GC run, but
only for the duration of the thread flip operation, which is much
shorter. This is valid due to the to-space invariant.

Bug: 12687968
Bug: 19235243

Change-Id: I1b6b4ae4fa539ddc0ec50b10ae8c8709f2a12fe8
52a7f5caebdf359ab877f1928aad59f1e9ad29fa 19-Aug-2015 Mathieu Chartier <mathieuc@google.com> Add class flags to class to help GC scanning

Reduces GC time and pauses by reducing the number of loads required
to scan an object.

Average total GC time before on EvaluateAndApplyChanges (EAAC): 7.452s
After: 7.144s

Average GC pause times before on EAAC: 860.67us
After: 722.75us

Adding the class flags field cause a memory increase of ~24k system
wide on low memory devices.

Change-Id: I3f04212d5787bfbf5e55026584d149f55476105e
059ef3ddb2088f926ac452889e0953fdcd646a5e 18-Aug-2015 Mathieu Chartier <mathieuc@google.com> Always visit object class from VisitReferences

We don't want to unload classes which have instances.

Slight increase in CMS GC time from ~6.5s to ~7.3s on
EvaluateAndApplyChanges.

Bug: 22720414
Change-Id: I467ff9c9d55163d2a90b999aef3bdd7b3f648bac
511683764f2580d877725e20514ca4976c91bbfb 13-Aug-2015 Mathieu Chartier <mathieuc@google.com> Wait for GC to finish in ThreadList::~ThreadList

Added a DisableGC to the heap instead of using the runtime shutdown
boolean. The runtime shutting down boolean is set to true before the
non daemon threads have exited. These threads may still be doing
allocations and we don't want to throw OOME if unnecessary.

Bug: 18577101
Change-Id: Iceb7048e6bd799aa2716099459c54f8dc0fb8feb
e2a0a20659e43d5873f187b8d9646c9b606c1b16 12-Aug-2015 Mathieu Chartier <mathieuc@google.com> Don't allow GC to start if the runtime is shutting down

Daemon threads may be trying to do allocations as the runtime is
shutting down, don't allow GC to start since it touches the heap
and may cause crashes if it is running while we delete the heap
or thread list.

Bug: 18577101
Change-Id: I1404b41f2aee13d3c26acffdf588c985628beefc
e8a69447d845cc5c0b5ccfa9c4d4b1b588271f52 12-Aug-2015 Mathieu Chartier <mathieuc@google.com> Delete AllocationTimer

Not very useful, running benchmarks is better.

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

Change-Id: Id12e392ad50f66a6e2251a68662b7959315dc567
a4f6af9b1e6380b31674d7ac645b1732c846ac06 12-Aug-2015 Mathieu Chartier <mathieuc@google.com> Some heap cleanup

Bug: 19534862
Change-Id: Ia63f489d26ec8813a263ce877bdbbc8c4e8fe5f4
c0fe56a4ee672bb346b124438941e753887e7416 11-Aug-2015 Mathieu Chartier <mathieuc@google.com> Address some comments

Change-Id: I0262304cc720a0e93015955d0a7fb05dfebe213e
54d220eb9cc51215d75b9e0fe921b94bebbb3fd6 31-Jul-2015 Mathieu Chartier <mathieuc@google.com> Move ArtFields and ArtMethods to be a length prefixed array

Fixes race conditions between changing method and fields arrays
being seen in the wrong order by the GC.

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

Use the proper define.

Change-Id: I71e291ac25f5d5f0187ac9b6ef2d6872f19e6085
da7c650022a974be10e2f00fa07d5109e3d8826f 24-Jul-2015 Mathieu Chartier <mathieuc@google.com> Visit class native roots from VisitReferences

Visit class roots when we call Class::VisitReferences instead of in
the class linker. This makes it easier to implement class unloading
since unmarked classes won't have their roots visited by the class
linker.

Bug: 22181835
Change-Id: I63f31e5ebef7b2a0b764b3ba3cb038b3f561b379
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
14d90579f013b374638b599361970557ed4b3f09 16-Jul-2015 Roland Levillain <rpl@google.com> Use (D)CHECK_ALIGNED more.

Change-Id: I9d740f6a88d01e028d4ddc3e4e62b0a73ea050af
97509954404d031594b2ecbda607314d169d512e 13-Jul-2015 Mathieu Chartier <mathieuc@google.com> Clean up GC callbacks to be virtual methods

Change-Id: Ia08034a4e5931c4fcb329c3bd3c4b1f301135735
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
f1820850307f7c2940c758f1232e1c40888a111a 10-Jul-2015 Mathieu Chartier <mathieuc@google.com> Add VMDebug.countInstancesOfClasses

countInstancesOfClasses allows passing multiple classes unlike
countInstanceOfClass instead of needing to do one at a time.

This is going to be used to speed up string mode checking.

Also changed the logic to not do a GC, this was the old Dalvik
behavior. It is the job of the caller to do this.

Added test.

https://code.google.com/p/android/issues/detail?id=177552

Change-Id: Ia85684f40cf59a52aa71a8479c711a994651209b
3cf225386e8129dcbe32b289279ecb87ec255318 10-Jul-2015 Mathieu Chartier <mathieuc@google.com> Clean up some includes

Change-Id: Ia03a3b54b235df38d5cfe096fef1aebe2b80eb29
41656de4b6440bcd1bea5fb785f0710153b2bc68 07-Jul-2015 Man Cao <manc@google.com> Fix potential bugs in allocation tracker

Add a missing visit allocation records call in concurrent copying collecter.
Handle null class objects if we support class unloading, and issues
with disallow and allow new allocation records.

Bug: 20037135
Change-Id: I59b7321c281e0d79a620501b2f43e36d2a576203
42c3c33df8b6eefc4ba532f1981282510f109928 24-Jun-2015 Man Cao <manc@google.com> Make allocation tracker use less memory

The allocation tracker no longer keeps recently allocated objects live.
Instead it just keeps their class objects live as strong roots. This fixed
the gc-stress test failure for 098-ddmc.

Also fixed the issue in DisableNewSystemWeak() for allocation tracker,
by making new allocation to wait until GC's sweeping to complete. I didn't
feel any significant slowdown with this wait.

Bug: 20037135
Change-Id: I6a98188832cf7ee478007e3788e742dc6e18f7b8
71e46c1a2e1a8c2ef87b6137e8503dd12e18bb8d 25-Jun-2015 Mathieu Chartier <mathieuc@google.com> Fix force copy

We now correctly pass the returned pointer back onto the release functions.

Bug: 22056708
Change-Id: I1a7300d3a4522a3c81b432ec742ae1c0bd00b51e

(cherry picked from commit b735bd9c04aa291d0a1bdc2c0a094a1a75ad0596)
b735bd9c04aa291d0a1bdc2c0a094a1a75ad0596 25-Jun-2015 Mathieu Chartier <mathieuc@google.com> Fix force copy

We now correctly pass the returned pointer back onto the release functions.

Bug: 22056708
Change-Id: I1a7300d3a4522a3c81b432ec742ae1c0bd00b51e
1ed11b9ad5512cf464cb1686640df53201fa5297 12-Jun-2015 Man Cao <manc@google.com> Restore DDMS recent allocation tracking's behavior

Make the allocation tracker mark recently allocated objects as roots,
so the allocation records are not swept. Because DDMS needs recent
allocation tracking records even for dead objects. This should fix
the flaky failures for 098-ddmc test, but it cannot pass GC stress
test (OOM). Re-enabled 098-ddmc for other tests.

There should be an option to not mark them as roots, when user only
needs HPROF dump with traces but not DDMS's recent allocation tracking.
Probably need to add a new JNI API function for this option.

There could be another way to keep a second list of recent allocation
records and maintain a type cache for them, so not to make the objects
roots. But it's more complex, and not sure which is better.

Also reduce memory usage for AllocRecordStackTrace objects, and change
default stack depth to 16. Rename the property that controls the stack
depth to "debug.allocTracker.maxStackDepth" so developer can change it.

Bug:20037135
Change-Id: Ic6b9ae87bdcda558be6f14ded8057e763439881c
bad9c7b7f88689133cae59d9ccae231822a2020c 14-Jun-2015 Mathieu Chartier <mathieuc@google.com> New experimental GC stress mode

Tries to do a GC for every unique call stack (up to 16 frames).
The goal is to catch moving GC bugs and lock violations without being
rediculously slow. Some tests fail on 64 bits, 32 bit host doesn't
work. N5 is booting.

Added runtime -Xgc options: gcstress and nogcstress.

Bug: 21664466

(cherry picked from commit 310008008c90fea246efd00cb99ee7ded97c5209)

Change-Id: Icb8e420f2048e8ee83bcca7937563166a2638f5c
310008008c90fea246efd00cb99ee7ded97c5209 14-Jun-2015 Mathieu Chartier <mathieuc@google.com> New experimental GC stress mode

Tries to do a GC for every unique call stack (up to 16 frames).
The goal is to catch moving GC bugs and lock violations without being
rediculously slow. Some tests fail on 64 bits, 32 bit host doesn't
work. N5 is booting.

Added runtime -Xgc options: gcstress and nogcstress.

Bug: 21664466

Change-Id: Icb8e420f2048e8ee83bcca7937563166a2638f5c
a26cb57f46fd3f27a930d9d688fe8670c1f24754 23-Apr-2015 David Srbecky <dsrbecky@google.com> ART stack unwinding fixes for libunwind/gdb/lldb.

dex2oat can already generate unwinding and symbol information which
allows tools to create backtrace of mixed native and Java code.

This is a cherry pick from aosp/master which fixes several issues.
Most notably:
* It enables generation of ELF-64 on 64-bit systems (in dex2oat, C
compilers already produce ELF-64). Libunwind requires ELF-64 on
64-bit systems for backtraces to work.
* It enables loading of ELF files with dlopen. This is required for
libunwind to be able to generate backtrace of current process (i.e.
the process requesting backtrace of itself).
* It adds unit test to test the above (32 vs 64 bit, in-proces vs
out-of-process, application code vs framework code).
* Some other fixes or clean-ups which should not be of much
significance but which are easier to include to make the
important CLs cherry-pick cleanly.

This is squash of the following commits from aosp/master:
7381010 ART: CFI Test
e1bbed2 ART: Blacklist CFI test for non-compiled run-tests
aab9f73 ART: Blacklist CFI test for JIT
4437219 ART: Blacklist CFI test for Heap Poisoning
a3a49fe Switch to using ELF-64 for 64-bit architectures.
297ed22 Write 64-bit address in DWARF if we are on 64-bit architecture.
24981a1 Set correct size of PT_PHDR ELF segment.
1a146bf Link .dynamic to .dynstr
67a0653 Make some parts of ELF more (pointer) aligned.
f50fa82 Enable 64-bit CFI tests.
49e1fab Use dlopen to load oat files.
5dedb80 Add more logging output for dlopen.
aa03870 Find the dlopened file using address rather than file path.
82e73dc Release dummy MemMaps corresponding to dlopen.
5c40961 Test that we can unwind framework code.
020c543 Add more log output to the CFI test.
88da3b0 ART: Fix CFI test wrt/ PIC
a70e5b9 CFI test: kill the other process in native code.
ad5fa8c Support generation of CFI in .debug_frame format.
90688ae Fix build - large frame size of ElfWriterQuick<ElfTypes>::Write.
97dabb7 Fix build breakage in dwarf_test.
388d286 Generate just single ARM mapping symbol.
f898087 Split .oat_patches to multiple sections.
491a7fe Fix build - large frame size of ElfWriterQuick<ElfTypes>::Write (again).
8363c77 Add --generate-debug-info flag and remove the other two flags.
461d72a Generate debug info for core.oat files.

Bug: 21924613
Change-Id: I3f944a08dd2ed1df4d8a807da4fee423fdd35eb7
5dedb808acf84712daf7dee3cf8137d4e34b4b78 17-Jun-2015 David Srbecky <dsrbecky@google.com> Add more logging output for dlopen.

Investigation of build bot failure which I can not reproduce locally.

Bug: 21854739
Change-Id: I4584bb10ad44e4bcf8232c060e40b36ff924ffa2
37670178497df18ae6b2a97a2ea9bf365621f16e 11-Jun-2015 Hiroshi Yamauchi <yamauchi@google.com> Reset GC performance stats at zygote fork.

So GCs before a zygote fork won't be attributed to an app.

(cherry pick commit Ib37bc587e0f039ef8faeabe63dec19de49501863)

Bug: 21491908
Change-Id: Ib37bc587e0f039ef8faeabe63dec19de49501863
9a7fffb36bad0bf3e7bac21dd223d975bc9dde55 11-Jun-2015 Hiroshi Yamauchi <yamauchi@google.com> Reset GC performance stats at zygote fork.

So GCs before a zygote fork won't be attributed to an app.

Bug: 21491908
Change-Id: Ib37bc587e0f039ef8faeabe63dec19de49501863
8c2ff641294715864013737fdec57cdfd410270c 28-May-2015 Man Cao <manc@google.com> Add allocation stack traces for HPROF dump.

This feature is currently only enabled when DDMS's allocation tracking
is enabled. In the future there should be a way to enable this feature
before an application starts.

Also updates DDMS's recent allocation tracking to use a new backend
data structure that is shared with this feature.

The following system properties controls customizable parameters:
dalvik.vm.allocTrackerMax: max number of objects that have allocation
records, default 512K;

dalvik.vm.recentAllocMax: max number of records that are sent to DDMS
when clicking "Get allocation" button,
default 64K-1 (limit of the protocol);

dalvik.vm.allocStackDepth: max number of stack frames in an allocation
record, default 4.

Bug: 20037135
Change-Id: I26ed378a5613678bd3c43e846025f90470a8e059
b5de3bb65556950d5cce1dea3ea6d80adcc5051d 05-Jun-2015 Mathieu Chartier <mathieuc@google.com> Use runFinalizationWithTimeout for native allocations

Prevents deadlocks by not waiting longer than 250ms for finalizers
to complete.

(cherry picked from commit 3b532d744034b43ed329a3198f15846d80fec3f0)

Bug: 21544853
Change-Id: I57b2f7ae8b74185922eb3c15ba0ab71a4d2348aa
3b532d744034b43ed329a3198f15846d80fec3f0 05-Jun-2015 Mathieu Chartier <mathieuc@google.com> Use runFinalizationWithTimeout for native allocations

Prevents deadlocks by not waiting longer than 250ms for finalizers
to complete.

Bug: 21544853
Change-Id: I57b2f7ae8b74185922eb3c15ba0ab71a4d2348aa
054a078ecebfb84b5003f2d0239c472de53267e2 07-Apr-2015 Richard Uhler <ruhler@google.com> Add atrace calls to runtime start and heap create

(cherry picked from commit 7fabaa6ba1927d21a317c03499b705cbde4f6a47)

Bug: 20727525

Change-Id: I91a74b793fb9eda8ed580244a6a5fd313ef2eb27
7fabaa6ba1927d21a317c03499b705cbde4f6a47 07-Apr-2015 Richard Uhler <ruhler@google.com> Add atrace calls to runtime start and heap create

Bug: 20727525

Change-Id: I91a74b793fb9eda8ed580244a6a5fd313ef2eb27
f6c2a2743d70966cf9ff02294276549ce4dc8683 04-Jun-2015 Mathieu Chartier <mathieuc@google.com> Fix valgrind large_object_space_test

Also some cleanup.

(cherry picked from commit c991403cd8b869e4a38c11c6a58223b82b89a1b2)

Change-Id: I9c1a8093e6356f1b52e332009429b77fa5c1d448
c991403cd8b869e4a38c11c6a58223b82b89a1b2 04-Jun-2015 Mathieu Chartier <mathieuc@google.com> Fix valgrind large_object_space_test

Also some cleanup.

Change-Id: I9c1a8093e6356f1b52e332009429b77fa5c1d448
e7158116f345df6df73f0df7ebdc2be8e0e4f3e8 03-Jun-2015 Mathieu Chartier <mathieuc@google.com> Add a way to determine if a large object is a zygote object

Also fix a slight memory leak in LargeObjectMapSpace.

Bug: 20674158

(cherry picked from commit 8f23620d45399286564986d2541cda761b3fe0ac)

Change-Id: I2416df484e5b84a8c5cc0b5664c8cb102dc235f6
8f23620d45399286564986d2541cda761b3fe0ac 03-Jun-2015 Mathieu Chartier <mathieuc@google.com> Add a way to determine if a large object is a zygote object

Also fix a slight memory leak in LargeObjectMapSpace.

Bug: 20674158
Change-Id: I2416df484e5b84a8c5cc0b5664c8cb102dc235f6
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
4edd8476339fd93ba8ff384ad107f1fc662e64a3 01-Jun-2015 Mathieu Chartier <mathieuc@google.com> 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
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
b43390cb87eace4a017f672d66cfb20fb9e76aa1 12-May-2015 Mathieu Chartier <mathieuc@google.com> Hold heap bitmap lock in Heap::GetObjectsAllocated

Fixes a race condition where add and remove space could cause a crash
when we iterated over the spaces.

TODO: Add a spaces lock or something to guard against this.

(cherry picked from commit a395c0a492079d86b312c9edc796d63001576954)

Bug: 21031927

Change-Id: I7f0d558316f8e9d9f22ffd182e8666355bf50d47
a395c0a492079d86b312c9edc796d63001576954 12-May-2015 Mathieu Chartier <mathieuc@google.com> Hold heap bitmap lock in Heap::GetObjectsAllocated

Fixes a race condition where add and remove space could cause a crash
when we iterated over the spaces.

TODO: Add a spaces lock or something to guard against this.

Bug: 21031927

Change-Id: I7f0d558316f8e9d9f22ffd182e8666355bf50d47
dd5a4d0a9cdf75e8fffc3cc3a08c808bbd997b22 08-May-2015 Vladimir Marko <vmarko@google.com> ART: Merge entries with same name and protect in MemMap dump.

This should make the MemMap dump less chatty and allow the
logger to keep more relevant output.

Bug: 20873174

(cherry picked from commit 17a924abde2b0f1f37f6008b451a0a75190c71ff)

Change-Id: I1748f57a1f149a5498b42ee246f13d2bf1e8c2f7
17a924abde2b0f1f37f6008b451a0a75190c71ff 08-May-2015 Vladimir Marko <vmarko@google.com> ART: Merge entries with same name and protect in MemMap dump.

This should make the MemMap dump less chatty and allow the
logger to keep more relevant output.

Bug: 20873174
Change-Id: I09058798faa8f79d154cee5008017b03700df8db
d45c84364db585f2e45a6264ae3116d004858677 02-May-2015 Hiroshi Yamauchi <yamauchi@google.com> Request full/partial GC type from VMRuntime.requestConcurrentGC().

(cherry pick commit 0ae98992d348b5bf3fc85a52d81b0e5f221f20d6)

Bug: 20554807
Change-Id: I572e846e9d0347b8b2692442e55f56c08b07d395
0ae98992d348b5bf3fc85a52d81b0e5f221f20d6 01-May-2015 Hiroshi Yamauchi <yamauchi@google.com> Request full/partial GC type from VMRuntime.requestConcurrentGC().

Bug: 20554807
Change-Id: I1cd855507c3f4e191035dbc2c429e1b8b344d81b
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
a1c9f013c034fbddb9337cc5c7ecf0e5a8b77547 02-Apr-2015 Hiroshi Yamauchi <yamauchi@google.com> getRuntimeStat() support (ART).

Export some runtime stats (currently GC stats) via
VMDebug.getRuntimeStat().

Added several new GC stats such as blocking GC counts and GC count
histograms.

Bug: 19825248
Change-Id: I8ece9ed241dc3982dfd983d7159090ba82940dce
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
65b798ea10dd716c1bb3dda029f9bf255435af72 06-Apr-2015 Andreas Gampe <agampe@google.com> ART: Enable more Clang warnings

Change-Id: Ie6aba02f4223b1de02530e1515c63505f37e184c
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
ddac42329314587f6f188bacf101b3cb15175b3c 02-Apr-2015 Mathieu Chartier <mathieuc@google.com> Fix race with Heap::ClampGrowthLimit and GC

Aded logic for handling the temp bitmap if the GC is running and
the live bitmap is clamped to the mark bitmap. This fixes the SIGABRT
from ClampGrowthLimit if the GC clamped the bitmaps at this point.

Also added locking of the heap_bitmap_lock_ so that added a lock so
that the temp bitmap doesn't change from underneath us.

Bug: 20043461

Change-Id: Ib427e40bcdf149de0408b4b53e6524f51463f0af
faed9950572632ffaac69e70c0b1ab90496c98f3 01-Apr-2015 Mathieu Chartier <mathieuc@google.com> Only GC the first time we call PreZygoteFork

PreZygoteFork is called for every app launch, it is overkill to GC
each time since it takes 20-30ms and blocks app launch for that long.

Change-Id: I647c8ccca767ceca67a006c1d80a739c7860f0d0
cd8f6377821370cb471fb21ae095dfaa204e4410 21-Mar-2015 Mathieu Chartier <mathieuc@google.com> Remove some spammy logging

Did not provide useful info and or was redundant.

Change-Id: I42da705debc43460cdd3fdf16e9e9ceb2c137001
3dbf23412481c4da51f0ebe32bec5d300c36834b 18-Mar-2015 Hiroshi Yamauchi <yamauchi@google.com> Fix oat_file_assistant_test32 flaky failures with GSS collector.

Bug: 19800031
Change-Id: I5146fa4e6a79bad94762102a50956c31251dcd2a
bf9fc581e8870faddbd320a935f9a627da724c48 14-Mar-2015 Mathieu Chartier <mathieuc@google.com> Add more info to who called SuspendAll

Helps diagnose related jank.

Change-Id: I38191cdda723c6f0355d0197c494a3dff2b6653c
8711d1fadb62481cdcb10c829a54b36f6aa16f6f 14-Mar-2015 Hiroshi Yamauchi <yamauchi@google.com> Fix valgrind heap_test.

Copy the exact object size rather than the aligned size to avoid
valgrind errors in the zygote compact collector.

Change-Id: I260b8901f96fb4c0937a1a5237120b56f6858b7a
60e27165e13a8401ded88c492ab804419537b2c7 10-Mar-2015 Lin Zang <lin.zang@intel.com> ART: correct native bytes allocated in RegisterNativeAllocation

Fix the issue that in RegisterNativeAllocation the new_native_bytes_allocated
was not updated after Runfinalization, which may cause unnecessary GC.

Change-Id: Icbbc0d1cbcd7b1b8e42576104de69c8ff3afa745
Signed-off-by: Lin Zang <lin.zang@intel.com>
d04495edc261bf7fbdb7c6a1c31c6dda08e990ed 12-Mar-2015 Hiroshi Yamauchi <yamauchi@google.com> Fix CC collector boot.

Avoid a DCHECK failure that the semi space collector isn't initialized
at the pre-zygote fork time when the CC collector is used.

Change-Id: If35707b241be05a341abb11ba51fbd0bc222d219
4460a84be92b5a94ecfb5c650aef4945ab849c93 09-Mar-2015 Hiroshi Yamauchi <yamauchi@google.com> Rosalloc thread local allocation path without a cas.

Speedup on N4:
MemAllocTest 3044 -> 2396 (~21% reduction)
BinaryTrees 4101 -> 2929 (~26% reduction)

Bug: 9986565
Change-Id: Ia1d1a37b9e001f903c3c056e8ec68fc8c623a78b
dfe3083054aa7be60adc24e3e58e0ae4773c41ff 07-Mar-2015 Mathieu Chartier <mathieuc@google.com> Only allocate collectors if we may use them

I believe most of the savings come from not allocating the concurrent
copying 8MB MarkQueue.

Before AOSP hh native PSS:
72653 kB: Native
72998 kB: Native
72882 kB: Native

After AOSP hh native PSS:
64823 kB: Native
65986 kB: Native
64219 kB: Native

Bug: 17643507
Change-Id: Ic5a8e753beca36142c1bf36be6311051f7c78e47
5c42c29b89286e5efa4a4613132b09051ce5945b 25-Feb-2015 Vladimir Marko <vmarko@google.com> Add support for .bss section in oat files.

Change-Id: I779b80b8139d9afdc28373f8c68edff5df7726ce
4858a935868162266ead90ef2f7802108711371d 23-Jan-2015 Mathieu Chartier <mathieuc@google.com> Change card cache mod-union table to use bitmaps

Previously used card sets, using bitmaps saves memory and slightly
increases performance.

Added mod union table test.

Performance EvaluateAndApplyChanges (minimal changes):

Before (card cache image mu table):
UpdateAndMarkImageModUnionTable: Avg: 524.320us
ImageModUnionClearCards: Avg: 54.580us
Native PSS: ~67500kB

After (card cache image mu table):
UpdateAndMarkImageModUnionTable: Avg: 515.600us
ImageModUnionClearCards: Avg: 53.780us
Native PSS: ~66014kB

Native PSS was higher before since the mod_union_table->SetCards()
which happens pre zygote fork was allocating a large amount of
std::nodes.

Bug: 11859910

Change-Id: I956b7e51d5572feec1393ffa618b7b7d8c147b28
e4d99873eb1dbee956d76c1edef489103898b33f 26-Feb-2015 Hiroshi Yamauchi <yamauchi@google.com> Add standard gc log for transition collections.

Factor out the gc log logic into a function.

Note we still don't log in background as before but do for things like
OOME compactions in foreground.

Change-Id: Ifd35a796cf26aba2fba83bf07e72902357d91f8b
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
ac195160c299f1c7a87144da7dccb9411df3c1fd 20-Feb-2015 Mathieu Chartier <mathieuc@google.com> Revert "Do GC for alloc for unstarted runtimes"

Bug: 19451379

This reverts commit c0a7e2bb1609da40ec67cb7e00c918637c610897.

Change-Id: Ib079e5ce1647fd44239f7f2f658b2c50d619fece
c0a7e2bb1609da40ec67cb7e00c918637c610897 16-Dec-2014 Mathieu Chartier <mathieuc@google.com> Do GC for alloc for unstarted runtimes

Currently, concurrent GC requests are ignored for unstarted runtimes.
The new logic is to do a GC for alloc in RequestConcurrentGC if the
runtime is not started. This reduces the java heap size in dex2oat.

Change-Id: I8d4364a4e3537013b27390bb22a6f64aab58c924
aaebaa0121be3b9d9f13630585304482cbcaeb4b 26-Jan-2015 Igor Murashkin <iam@google.com> art: Refactor RuntimeOptions/ParsedOptions

Refactor the RuntimeOptions to be a
type-safe map (VariantMap, see runtime_options.h) and the ParsedOptions
to delegate the parsing to CmdlineParser (see cmdline/cmdline_parser.h).

This is the start of a command line parsing refactor, and may include
more in the future (dex2oat, patchoat, etc).

For more details of the command line parsing generator usage see cmdline/README.md

Change-Id: Ic67c6bca5e1f33bf2ec60e2e3ff8c366bab91563
dd9943d4466b052ef6c5ee5b32187adb48cbce74 02-Feb-2015 Lei Li <lei.l.li@intel.com> ART: checkpoint mechanism optimization

GC thread and trim thread are both using checkpoint mechanism. GC thread
will request java threads to mark their thread roots by themselves. Trim
thread will request java threads to trim their jni local reference
tables by themselves.

The checkpint mechanism semantics is that the runnable java threads will
run checkpoint function itself at safepoint, and finally the java
threads and gc thread or trim thread is synchronized via barrier. If the
java threads are not runnable, gc thread or trim thread will suspend
them and then run their checkpoint functions one by one on behalf of
them. If all the java threads are not runnable, then gc thread or trim
thread will do all the work itself. In this case, there is no need
synchronization. This will save unnecessary synchronization and thread
state transitions.

Change-Id: If55940946cb3f8b1af42c7237c334f09c8ec7a9f
4add3b4fa38ec42bb3c71d01cf70bce8e9a9fb4e 15-Jan-2015 Lei Li <lei.l.li@intel.com> ART: clear dirty cards of alloc space for MS/CMS partial and full GCs

For MS/CMS partial and full GCs, we could clear the dirty cards of alloc
space when we process cards as we care about the dirty cards after GC
starts.

Change-Id: I1f9b32b20d75979387bc5d26b0cf9a256dcf20b6
Signed-off-by: Lei Li <lei.l.li@intel.com>
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
727b294b4091cf3cc2f8137cd654552f477fe46a 15-Jan-2015 Lei Li <lei.l.li@intel.com> ART: clear dirty cards of alloc space in pause phase

Clear the dirty cards of alloc spaces when scanning them in pause phase,
the dirty cards of image or zygote space will not be cleared in order to
track the references to the other spaces.

Change-Id: I519f071d954a589aa33dbce0cdba405f2d2cef71
Signed-off-by: Lei Li <lei.l.li@intel.com>
0c8c303c20cdaaf54d26e45cc17dc5afb820d8ef 17-Jan-2015 Hiroshi Yamauchi <yamauchi@google.com> Clean up the locks around Heap::VisitObjects().

This is so that we could support suspending all threads when visiting
objects in the presence of a concurrent, moving collector.

Bug: 12687968
Change-Id: Icc8e60630465afde948ebc6ea91d4ebaff5d7837
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
a233e03473cd9f0a582447f71946122140a2472c 10-Jan-2015 Hiroshi Yamauchi <yamauchi@google.com> [WIP] Fix a rosalloc verification crash.

Bug: 18960494
Change-Id: Ia7a11f06b3fc8207f6304ae881539251d6b1de24
68d1bfc0bb5a7be79354f6551dae6cd600c20e76 08-Jan-2015 Mathieu Chartier <mathieuc@google.com> Add clamp growth limit

Clamp growth limit shrinks the space memmaps to the current growth
limit. This reduces virtual memory usage for apps with small heaps.

Bug: 18387825
Bug: 17131630

(cherry picked from commit 379d09fe3c3feb7c2a2fb5a3623689b5ace7e79b)

Change-Id: I4f8e507fde1c8e10373615254aa0f1bf1b48a7ea
379d09fe3c3feb7c2a2fb5a3623689b5ace7e79b 08-Jan-2015 Mathieu Chartier <mathieuc@google.com> Add clamp growth limit

Clamp growth limit shrinks the space memmaps to the current growth
limit. This reduces virtual memory usage for apps with small heaps.

Bug: 18387825
Bug: 17131630

Change-Id: I4a8fdc335d2c40492e991708adabcc46299efb7d
50c138f7f89ed03d49aa4bdde7351c26b3403e90 08-Jan-2015 Mathieu Chartier <mathieuc@google.com> Fix signal test to work with gcstress

We now avoid running GC if we are handling a stack overflow, this
helps prevent running past the end of the stack overflow reserved
bytes.

Added logic in ThrowStackOverflowError to use a stack overflow
exception without a stack trace if we fail to allocate the stack
trace.

Bug: 16406852
Change-Id: Ib34e235cd0af6d7c4c93c9705fa822f2b9b23b38
a5eae69589ff562ad66c57665882cd16f237321c 18-Dec-2014 Mathieu Chartier <mathieuc@google.com> Add heap task processor

The heap task processor processes async tasks which may be delayed.
The motivation for this change is preventing deadlocks which
can occur when the daemon threads get suspended by GetThreadStack.

Other improvements, reduces daemon thread count by one.
Cleaner pending transition VS heap trimming logic.

Bug: 18739541

Change-Id: Idab52b2d9661a6385cada74b93ff297ddc55fc78
e2c2f6e61df0bfa1516bfc8943e78ea610d4d878 17-Dec-2014 Mathieu Chartier <mathieuc@google.com> Fix concurrent GC ergonomics

Fixed a race with the gc_request_pending_ boolean which would cause
two concurrent GCs to start in a row in most cases. This broke sticky
CMS ergonomics since the second GC was a sticky CMS which started way
too early resulting in low throughput. Since the throughput was low,
it switch to partial / full for the next iteration.

The race happened as follows, allocating thread would request
concurrent GC which woke up the daemon thread. The daemon thread
cleared the gc_request_pending_ boolean, but before we set the
concurrent_start_bytes_ to max in to prevent more request, the
allocating thread would call RequestConcurrentGC again. This caused
the next WaitForConcurrentGCRequest to return right away and a
concurrent GC to occur earlier than necessary.

Changed the allocation rate ergonomics to use allocation rate
during the GC instead of allocation rate inbetween GCs, this is
better since the allocation rate may become slower if the GC steals
mutator time, resulting in concurrent GCs starting a bit earlier
than they need to.

Fixed a bug in GrowForUtilization where we didn't use the adjusted
max_free when we shrank down the heap, this caused the sticky CMS to
occasionally shrink the heap more than necessary.

EvaluateAndApplyChanges:
Before: ~12.6s GC time
After: ~7.75s GC time

Change-Id: I354bc825b3c44ccfbfe867af0d437b17fe1fe022
70a596d61f8cf5b6447326c46c3386e0fbd5bfb5 17-Dec-2014 Mathieu Chartier <mathieuc@google.com> Add thread suspend histogram

Helps measure time to suspend.
Example output (maps after a few seconds):
suspend all histogram: Sum: 2.806ms 99% C.I. 2us-1090.560us Avg: 43.843us Max: 1126us

Change-Id: I7bd9dd3b401fb3e3059e8718556d60910e541611
c85cdeb22b6d38b90904241c284f389043822073 17-Dec-2014 Mathieu Chartier <mathieuc@google.com> Delete gc request lock

Fixes valgrind tests.

Change-Id: I763e5709fffb002b14615ed5d08236970643e520
079101a17575114622f6e1d5be5c9ba643630e9a 15-Dec-2014 Mathieu Chartier <mathieuc@google.com> Move GC daemon locking logic into heap

Fixes deadlock caused by acquirng the mutator lock while
synchronizing on the daemon thread.

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

Change-Id: I3bf3250fa866fd2265f1b115d52fa5dedc48a7fc
95a505c787fe4673c091e5cd4bd2905d9f17ae36 11-Dec-2014 Mathieu Chartier <mathieuc@google.com> Increase default allocation stack size

Prevents some GC for alloc which can occur if the allocation stack
overflows.

Bug: 18707404

(cherry picked from commit 4911153db37264de407b2a08c2e4c9bb6aef3545)

Change-Id: I4748485dd495526ab1a313f366d93dbb3ee8112b
4911153db37264de407b2a08c2e4c9bb6aef3545 11-Dec-2014 Mathieu Chartier <mathieuc@google.com> Increase default allocation stack size

Prevents some GC for alloc which can occur if the allocation stack
overflows.

Bug: 18707404
Change-Id: I00e8e518aa5105b69c70603a8395c81617b87d14
0310da5361f41bc7f58eb102a5b232faa394183a 01-Dec-2014 Mathieu Chartier <mathieuc@google.com> Fix growth limit / footprint limit problems

We now properly clear the growth limit of all the spaces when
ClearGrowthLimit is called. Previously we didn't clear the growth
limit of the background space.

This wasn't caught by heap test since it only manifested itself
when we had a zygote space.

Bug: 18504942

(cherry picked from commit d59c170057dcc213a858652abc71eec710898a41)

Change-Id: I6e4394b9c9f7f22aabc5f5955adb8dd4511c2617
d59c170057dcc213a858652abc71eec710898a41 01-Dec-2014 Mathieu Chartier <mathieuc@google.com> Fix growth limit / footprint limit problems

We now properly clear the growth limit of all the spaces when
ClearGrowthLimit is called. Previously we didn't clear the growth
limit of the background space.

This wasn't caught by heap test since it only manifested itself
when we had a zygote space.

Bug: 18504942
Change-Id: Ibb3d76cba54a45ef755d7e2ced8c2e16cd2996b0
3abf4d694acde8f7f3efaa11dcd8ea74c7281c66 27-Nov-2014 Mathieu Chartier <mathieuc@google.com> Revert "Trim reference tables when we trim the heap"

This reverts commit 84dc99d2fa67e5dff018685661cb2bff62132989.

Change-Id: I48c2563c9b4579d6f4dadac6b8dcae8428993fab
abf9edc6915ae92e94ecb422a12190fa8e22afc4 27-Nov-2014 Mathieu Chartier <mathieuc@google.com> Revert "Add missing thread state change to kWaitingForCheckPointsToRun"

This reverts commit 20e11a7956eaebf97d7ed44bbca1c42948b3a580.

Change-Id: Ifde51cba3f02c64f2dac5bd95ddaf474f15e4f86
6785702b58ac97c07550a67734b9ef88e94d7d99 27-Nov-2014 Mathieu Chartier <mathieuc@google.com> Revert "Revert "Add missing thread state change to kWaitingForCheckPointsToRun""

This reverts commit 12e29285346a68e46444a5a7b87608475c1147ac.

Change-Id: I24e42309f19f781f3159cb715e8a64d6aea4b464
12e29285346a68e46444a5a7b87608475c1147ac 27-Nov-2014 Mathieu Chartier <mathieuc@google.com> Revert "Add missing thread state change to kWaitingForCheckPointsToRun"

This reverts commit 20e11a7956eaebf97d7ed44bbca1c42948b3a580.

Change-Id: Ifde51cba3f02c64f2dac5bd95ddaf474f15e4f86
91c2f0cde2a009bd52aa1c3d1dee705cc02c932f 26-Nov-2014 Mathieu Chartier <mathieuc@google.com> Trim reference tables when we trim the heap

Before:
System server:
virtual shared shared private private
size RSS PSS clean dirty clean dirty # object
2200 300 229 0 80 0 220 77 /dev/ashmem/dalvik-indirect ref table (deleted)
Location:
1896 128 102 0 28 0 100 39 /dev/ashmem/dalvik-indirect ref table (deleted)

After:
virtual shared shared private private
size RSS PSS clean dirty clean dirty # object
System server:
2216 64 64 0 0 0 64 79 /dev/ashmem/dalvik-indirect ref table (deleted)
Location:
2120 48 48 0 0 0 48 67 /dev/ashmem/dalvik-indirect ref table (deleted)

No pause time regression measured in memalloc test.

(cherry picked from commit 84dc99d2fa67e5dff018685661cb2bff62132989)

Change-Id: I80d9bd3b98e888fa8f77d03df69f8479ed209986
20e11a7956eaebf97d7ed44bbca1c42948b3a580 27-Nov-2014 Mathieu Chartier <mathieuc@google.com> Add missing thread state change to kWaitingForCheckPointsToRun

Fixes tests

Change-Id: I4907d83ee1e9bcd2f6a823e402950d8051d4556a
84dc99d2fa67e5dff018685661cb2bff62132989 26-Nov-2014 Mathieu Chartier <mathieuc@google.com> Trim reference tables when we trim the heap

Before:
System server:
virtual shared shared private private
size RSS PSS clean dirty clean dirty # object
2200 300 229 0 80 0 220 77 /dev/ashmem/dalvik-indirect ref table (deleted)
Location:
1896 128 102 0 28 0 100 39 /dev/ashmem/dalvik-indirect ref table (deleted)

After:
virtual shared shared private private
size RSS PSS clean dirty clean dirty # object
System server:
2216 64 64 0 0 0 64 79 /dev/ashmem/dalvik-indirect ref table (deleted)
Location:
2120 48 48 0 0 0 48 67 /dev/ashmem/dalvik-indirect ref table (deleted)

No pause time regression measured in memalloc test.

Bug: 17643507

Change-Id: I32d3e64cdcf8dd2f7aea509c81631597bbb9b392
7247af507f8e2218e73379ded5b2c4bbdd2a56c7 19-Nov-2014 Mathieu Chartier <mathieuc@google.com> Fix zygote space and non moving space map names

Space names:
"non moving space" -> "zygote space"
"alloc space" -> "non moving space"

Bug: 18447855
Change-Id: Ia937b6d046ccf7f66bf1f6bbb9f17a5e0d00c016
(cherry picked from commit c5d085c955244be1743c33227384e5b62076b8bd)
c5d085c955244be1743c33227384e5b62076b8bd 19-Nov-2014 Mathieu Chartier <mathieuc@google.com> Fix zygote space and non moving space map names

Space names:
"non moving space" -> "zygote space"
"alloc space" -> "non moving space"

Bug: 18447855
Change-Id: Ia937b6d046ccf7f66bf1f6bbb9f17a5e0d00c016
20ed5af7a623a2d095082f8d6f53151c46fb8842 18-Nov-2014 Hiroshi Yamauchi <yamauchi@google.com> Enable the hspace compaction on OOM by default.

(cherrypick commit d3f228062a1d71ce6ace2f31ecf369ae247633c2)

Bug: 18377775
Change-Id: I4a0998c7f35b6418004e92bc07926abc9b74962a
d3f228062a1d71ce6ace2f31ecf369ae247633c2 15-Nov-2014 Hiroshi Yamauchi <yamauchi@google.com> Enable the hspace compaction on OOM by default.

Bug: 18377775
Change-Id: I714367813e0f6d7cb854ace7f40dad0715f99e00
c2e20629c7dfdb0f679fa30c14b41fe68588697f 03-Nov-2014 Mathieu Chartier <mathieuc@google.com> Add hash set

More memory efficient than libcxx since we do not box the values.

Change intern table to use new hash set. Clean up intern table by
removing const casts and deleting unnecessary code.

Changed the class linker to use a hash set, also added a pre-zygote
class table.

5 samples of:
adb shell stop && adb shell start && sleep 60 && adb shell dumpsys meminfo
Before:
165929 kB: Native
175859 kB: Native
168434 kB: Native
166559 kB: Native
169958 kB: Native

After:
160972 kB: Native
159439 kB: Native
157204 kB: Native
165093 kB: Native
163039 kB: Native

TODO: Add HashTable which is implemented by using a HashSet.
TODO: Use for DexFile::find_class_def_misses_.
TODO: Investigate using mem maps instead of native heap.

Bug: 17808975

Change-Id: I93e376cf6eb9628cf52f4aefdadb6157acfb799a

(cherry picked from commit e05d1d5fd86867afc7513b1c546375dba11eee50)
e05d1d5fd86867afc7513b1c546375dba11eee50 03-Nov-2014 Mathieu Chartier <mathieuc@google.com> Add hash set

More memory efficient than libcxx since we do not box the values.

Change intern table to use new hash set. Clean up intern table by
removing const casts and deleting unnecessary code.

Changed the class linker to use a hash set, also added a pre-zygote
class table.

5 samples of:
adb shell stop && adb shell start && sleep 60 && adb shell dumpsys meminfo
Before:
165929 kB: Native
175859 kB: Native
168434 kB: Native
166559 kB: Native
169958 kB: Native

After:
160972 kB: Native
159439 kB: Native
157204 kB: Native
165093 kB: Native
163039 kB: Native

TODO: Add HashTable which is implemented by using a HashSet.
TODO: Use for DexFile::find_class_def_misses_.
TODO: Investigate using mem maps instead of native heap.

Bug: 17808975

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

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

Change-Id: I5b433e722d2f75baacfacae4d32aef4a828bfe1b
eb175f70ef352ce0b9bcafdf06c5ac22b0ff626a 31-Oct-2014 Mathieu Chartier <mathieuc@google.com> Add image strings to intern table

When we create the runtime, we now add the image strings to the
intern table if we are the zygote. This caused some memory bloat,
so I added an extra unordered set to the intern table.

There is now two unordered sets (hash talbe). One for pre-zygote
interns and one for post-zygote interns. This helps since the
pre-zygote hash table doesn't get dirtied. Even with adding
the image strings, we get total memory savings of around 5-7 MB
native PSS after device boot.

FB launch Before:
2.20% art::DexFile::FindStringId(char const*) const
TotalTime: 2069
TotalTime: 1985
TotalTime: 2088
TotalTime: 2003
TotalTime: 2034
TotalTime: 2049
After boot native PSS: 175585 kB: Native

After:
0.27% art::DexFile::FindStringId(char const*) const
TotalTime: 1682
TotalTime: 1756
TotalTime: 1825
TotalTime: 1751
TotalTime: 1666
TotalTime: 1813
After boot native PSS: 167089 kB: Native

Bug: 18054905
Bug: 16828525
Bug: 17808975

(cherry picked from commit b6e292bf7eac9d73c6b79b1e9b7b87beb02436c9)

Change-Id: Ie367f3222f8c4db409ec49c3845276908b51e9c9
b6e292bf7eac9d73c6b79b1e9b7b87beb02436c9 31-Oct-2014 Mathieu Chartier <mathieuc@google.com> Add image strings to intern table

When we create the runtime, we now add the image strings to the
intern table if we are the zygote. This caused some memory bloat,
so I added an extra unordered set to the intern table.

There is now two unordered sets (hash talbe). One for pre-zygote
interns and one for post-zygote interns. This helps since the
pre-zygote hash table doesn't get dirtied. Even with adding
the image strings, we get total memory savings of around 5-7 MB
native PSS after device boot.

FB launch Before:
2.20% art::DexFile::FindStringId(char const*) const
TotalTime: 2069
TotalTime: 1985
TotalTime: 2088
TotalTime: 2003
TotalTime: 2034
TotalTime: 2049
After boot native PSS: 175585 kB: Native

After:
0.27% art::DexFile::FindStringId(char const*) const
TotalTime: 1682
TotalTime: 1756
TotalTime: 1825
TotalTime: 1751
TotalTime: 1666
TotalTime: 1813
After boot native PSS: 167089 kB: Native

Bug: 18054905
Bug: 16828525
Bug: 17808975

Change-Id: Ie367f3222f8c4db409ec49c3845276908b51e9c9
872dd8208f00c667af8d9e0fd07fdd0ada56d437 30-Oct-2014 Ian Rogers <irogers@google.com> Tidy and reduce ART library dependencies on the host.

Move to shared rather than static libraries. Avoids capture of all static
libraries library dependencies.

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

Change-Id: I7a79c1671a6ff8b2040887133b3e0925ef9a3cfe
c63a505ae9992cc6ad154179734f078594c72d01 23-Oct-2014 Mathieu Chartier <mathieuc@google.com> Fix concurrent start bytes race

Previously, we set concurrent start bytes to max int when we
requested a concurrent GC, but there was a race if another thread
was doing another GC and had already completed GrowForUtilization
but had not yet finished the GC. This meant that the thread doing
the GC would update the concurrent start bytes properly, but the
allocating thread would re-update it to max int. Then when the
concurrent GC thread woke up, it would call WaitForGcToComplete
and see that there was a collector running and avoid doing the
concurrent GC, leaving the concurrent start bytes set to max int.

This meant that there would be no more concurrent GC until either
the next explicit GC or the next GC for alloc.

The fix is to only set concurrent start bytes to max int inside of
the CollectGarbageInternal code such that there isn't any way for
two threads to race.

Bug: 17942071
Change-Id: I2a4b067d99ae0aeebcc32fa4970024dcdff2ddc3
(cherry picked from commit 0133ec454d8dd3fa5ffe35649b5704aa18f15a49)
08cef22f4675862fd4bcf486a3f58d70d4ba5234 23-Oct-2014 Mathieu Chartier <mathieuc@google.com> Fix concurrent start bytes race

Previously, we set concurrent start bytes to max int when we
requested a concurrent GC, but there was a race if another thread
was doing another GC and had already completed GrowForUtilization
but had not yet finished the GC. This meant that the thread doing
the GC would update the concurrent start bytes properly, but the
allocating thread would re-update it to max int. Then when the
concurrent GC thread woke up, it would call WaitForGcToComplete
and see that there was a collector running and avoid doing the
concurrent GC, leaving the concurrent start bytes set to max int.

This meant that there would be no more concurrent GC until either
the next explicit GC or the next GC for alloc.

The fix is to only set concurrent start bytes to max int inside of
the CollectGarbageInternal code such that there isn't any way for
two threads to race.

Bug: 17942071

(cherry picked from commit 0133ec454d8dd3fa5ffe35649b5704aa18f15a49)

Change-Id: Ibc23dd2f937a2b5fda51ed064634c034dbb6e668
ef32b8f169d7440d24ca4f99adb87e64d424e287 23-Oct-2014 Kyungmin Lee <snailee@gmail.com> Use the passed-in 'name' param to create a MemMap.

Change-Id: I15c33b23751f4c32cb40c9514b602845feb47f9f
Signed-off-by: Kyungmin Lee <snailee@gmail.com>
0133ec454d8dd3fa5ffe35649b5704aa18f15a49 23-Oct-2014 Mathieu Chartier <mathieuc@google.com> Fix concurrent start bytes race

Previously, we set concurrent start bytes to max int when we
requested a concurrent GC, but there was a race if another thread
was doing another GC and had already completed GrowForUtilization
but had not yet finished the GC. This meant that the thread doing
the GC would update the concurrent start bytes properly, but the
allocating thread would re-update it to max int. Then when the
concurrent GC thread woke up, it would call WaitForGcToComplete
and see that there was a collector running and avoid doing the
concurrent GC, leaving the concurrent start bytes set to max int.

This meant that there would be no more concurrent GC until either
the next explicit GC or the next GC for alloc.

The fix is to only set concurrent start bytes to max int inside of
the CollectGarbageInternal code such that there isn't any way for
two threads to race.

Bug: 17942071
Change-Id: I2a4b067d99ae0aeebcc32fa4970024dcdff2ddc3
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
13735955f39b3b304c37d2b2840663c131262c18 08-Oct-2014 Ian Rogers <irogers@google.com> stdint types all the way!

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

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

Also added some locking to prevent race conditions.

Bug: 17360878

(cherry picked from commit a98ffd745bbecb2e84a492194950c0b94966546b)

Change-Id: I21d241a58d35bd6a607aa2305c6da81720bd0886
268ea6c707ea5db008ff7b5e5a49e8aa952b5127 26-Sep-2014 Mathieu Chartier <mathieuc@google.com> Change heap base address

Moved to 300 MB to allow room for other people who wish to use the
low 1 GB.

Bug: 17671634

(cherry picked from commit 23fb122b57c52ab1db98708a4e15765b46b26405)

Change-Id: Icb2784fc92cb5c46edb6e3a9de2d8383e012a07c
23fb122b57c52ab1db98708a4e15765b46b26405 26-Sep-2014 Mathieu Chartier <mathieuc@google.com> Change heap base address

Moved to 300 MB to allow room for other people who wish to use the
low 1 GB.

Bug: 17671634

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

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

Also added some locking to prevent race conditions.

Bug: 17360878

Change-Id: I779237d55dda4f35054a4d27fb2c660a38750fc0
2d5f39ed5aeaeb7ca22b07b4c6e8c56348ef8893 20-Sep-2014 Mathieu Chartier <mathieuc@google.com> Add ScopedAssertNoThreadSuspension

Added a new class, ScopedAssertNoThreadSuspension.
Deleted some unnecessary ScopedAssertNoThreadSuspension since
VisitObjects already has a ScopedAssertNoThreadSuspension.

Change-Id: I29ec0006120c39a27184d30e2d1d0c179e203776
1b636c661c3d21461fd072e542a9152212398f77 13-Aug-2014 Mathieu Chartier <mathieuc@google.com> Add allocation rate tracking to systrace.

Bug: 16956980

(cherry picked from commit 837150818af0eee993f7d93c5a50c3c7b46f1dab)

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

Bug: 17499772

(cherry picked from commit 1d6ee090fddd4bfd35c304d6ceb929d5c529dfcc)

Change-Id: Id09809c476c685f0a197ee75bb08638931364efd
2dbe627954fd78a3659ab3cd42d2ead5b4529441 16-Sep-2014 Mathieu Chartier <mathieuc@google.com> Add runtime options for large object space

Adds the two following options:
Option -XX:LargeObjectSpace={freelist, map, disabled}
Option -XX:LargeObjectThreshold=size specifies the size for which
primitive arrays are allocated in the large object space.

Added handling for large object space == null in collectors.

Fixed an error in the mem map space where we didn't use the page
aligned size LOS for bytes allocated, this resutled in heaps appearing
a bit smaller than they should be.

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

Bug: 17499772
Change-Id: Id98c10967b28e8859e5ac46f5878c304fb85c498
af4edbd2b77fef0eee3827eb30cc1a0e8e6efeb1 09-Sep-2014 Mathieu Chartier <mathieuc@google.com> Fix and re-enable FreeList large object space for 64 bit

Not enabled on 32 bit due to virtual memory fragmentation concerns.
The new free list large object space ensures that allocations are
page aligned by using a side table for accounting data.

(cherry picked from commit 66e222aa48e6d2fe4c78a1df938364b82bc83e72)

Change-Id: Idbcbe75cb86b6d9b3d8b20f3048631a48c511458
66e222aa48e6d2fe4c78a1df938364b82bc83e72 09-Sep-2014 Mathieu Chartier <mathieuc@google.com> Fix and re-enable FreeList large object space for 64 bit

Not enabled on 32 bit due to virtual memory fragmentation concerns.
The new free list large object space ensures that allocations are
page aligned by using a side table for accounting data.

Bug: 17414549

Change-Id: Idbcbe75cb86b6d9b3d8b20f3048631a48c511458
30cbbee37d9fcca1a39b3681434180102ee5251a 08-Sep-2014 Mathieu Chartier <mathieuc@google.com> Ignore heap trim requests if we are the zygote

Done to prevent app launching lag due to sleep in heap trimmer
daemon.

Bug: 17310019

(cherry picked from commit f81bfa3e21c8a4e031505470ea954c93949cb30b)

Change-Id: I3942d465781218aa04f7edc899ea87aa091f3cf7
b27285583ca40253b76010948420a91b45f79257 08-Sep-2014 Mathieu Chartier <mathieuc@google.com> Revert "Fix heap trimmer daemon sleeping."

This reverts commit 698b44634396e8111e96e1116586fde89a838347.

(cherry picked from commit 4d3981c72a546b87c8f5d391ff8b5135b8ca99a7)

Change-Id: I7245bc08ebb95c12e7cc71b97edf9ca11ffbdf61
f81bfa3e21c8a4e031505470ea954c93949cb30b 08-Sep-2014 Mathieu Chartier <mathieuc@google.com> Ignore heap trim requests if we are the zygote

Done to prevent app launching lag due to sleep in heap trimmer
daemon.

Bug: 17310019

Change-Id: Ia593e7eced1c1583771985ec9e7b60ee0c0e7912
4d3981c72a546b87c8f5d391ff8b5135b8ca99a7 08-Sep-2014 Mathieu Chartier <mathieuc@google.com> Revert "Fix heap trimmer daemon sleeping."

This reverts commit 698b44634396e8111e96e1116586fde89a838347.

Change-Id: Ifa8c2d554b82289cc31803ad6027735d2c3c9be8
1f0437ecd88bef4a40e587283b02785839bac4b8 05-Sep-2014 Mathieu Chartier <mathieuc@google.com> Delete double finalization hack.

No longer necessary.

Change-Id: Ie5eb9e9ce4b8473d3b3e65bd108f93223b9a80dd
23d683ff957ed9967a045ad3da61f4a4e3c99f2a 04-Sep-2014 Mathieu Chartier <mathieuc@google.com> Fix heap trimmer daemon sleeping.

Problem:
Heap trimmer daemon sleeping caused app launch occasionally to take a
while due stopping the heap trimming thread taking a long time.

The heap trimmer thread now never sleeps, we prevent issues caused
by frequent back and forth process state changes by only
transitioning to background if it has been kCollectorTransitionWait
time since the last transition to background. Similar logic for heap
trimming.

(cherry picked from commit 698b44634396e8111e96e1116586fde89a838347)

Change-Id: I5b2894e92eb79351eec35078d49c8457d2fd67a8
698b44634396e8111e96e1116586fde89a838347 04-Sep-2014 Mathieu Chartier <mathieuc@google.com> Fix heap trimmer daemon sleeping.

Problem:
Heap trimmer daemon sleeping caused app launch occasionally to take a
while due stopping the heap trimming thread taking a long time.

The heap trimmer thread now never sleeps, we prevent issues caused
by frequent back and forth process state changes by only
transitioning to background if it has been kCollectorTransitionWait
time since the last transition to background. Similar logic for heap
trimming.

Bug: 17310019

Change-Id: I23980421cc388f36b66a4c03ed15dd11d43f59b5
8ec31f9835a8d1513be9be7f9fa236fe4715750d 03-Sep-2014 Mathieu Chartier <mathieuc@google.com> Fix native allocation watermark clamping.

The main issue causing the test to fail is that
native_footprint_gc_watermark_ becoming > growth_limit_ due to no
clamping.

Temporary runFinalization fix is calling runFinalization 2x.

Bug: 17371542

(cherry picked from commit 4c7fc5950853b0c368e2148db77ced7c4d3c303c)

Change-Id: I05b85e95560c32c33d53bc96abf87d5262007395
4c7fc5950853b0c368e2148db77ced7c4d3c303c 03-Sep-2014 Mathieu Chartier <mathieuc@google.com> Fix native allocation watermark clamping.

The main issue causing the test to fail is that
native_footprint_gc_watermark_ becoming > growth_limit_ due to no
clamping.

Temporary runFinalization fix is calling runFinalization 2x.

Bug: 17371542
Change-Id: I188cb530a44dd109e066a22091f12f8d2d4350c3
f4f3843150bb2152bcc583c1896f45a313d5f6a4 03-Sep-2014 Mathieu Chartier <mathieuc@google.com> Add exception check to AllocateInternalWithGc

Trying to figure out if the pending exception comes before or during
AllocateInternalWithGc.

Bug: 17164348

(cherry picked from commit 98d43cb0da3c34d1888d1e31d953c2940fd0f897)

Change-Id: I2aac4b67f0c3f1c0fe3c9dc321316f76494c4074
98d43cb0da3c34d1888d1e31d953c2940fd0f897 03-Sep-2014 Mathieu Chartier <mathieuc@google.com> Add exception check to AllocateInternalWithGc

Trying to figure out if the pending exception comes before or during
AllocateInternalWithGc.

Bug: 17164348

Change-Id: Id46d82bfc0f84d16e5ffdafe41658aee4cc2c702
08487454218c2bfee6a9d669622c9ed935408783 03-Sep-2014 Mathieu Chartier <mathieuc@google.com> Change native allocations to use growth limit.

Previously native allocation tracking used a GC footprint limit
which would cause GC in the allocating thread. This prevented
excessive growth of the heap but could cause jank due to GC in
the allocating thread. The new behavior is using the growth_limit
instead of the native footprint limit.

(cherry picked from commit d9819ecc0bc21a2bb356a4de9b013e36fe618627)

Change-Id: Ia40ed830e8c674cc49d4c0a6fd773d6cb8ff97fa
d9819ecc0bc21a2bb356a4de9b013e36fe618627 03-Sep-2014 Mathieu Chartier <mathieuc@google.com> Change native allocations to use growth limit.

Previously native allocation tracking used a GC footprint limit
which would cause GC in the allocating thread. This prevented
excessive growth of the heap but could cause jank due to GC in
the allocating thread. The new behavior is using the growth_limit
instead of the native footprint limit.

Bug: 17006948

Change-Id: I40f30af09bb25596a9f57fa50e2a155fb947b5fe
98172a66f14fd8c6ebce4240a3bb2eaa69eb16bc 02-Sep-2014 Mathieu Chartier <mathieuc@google.com> Change heap transitions + hspace compation to use VLOG(heap)

VLOG(gc) is spammy since it is enabled.

(cherry picked from commit 8bd2961b385c870953e650c253a04ee24b76809b)

Change-Id: Id75256cdc6a9802818bb56f77533cca88ace42a6
8bd2961b385c870953e650c253a04ee24b76809b 02-Sep-2014 Mathieu Chartier <mathieuc@google.com> Change heap transitions + hspace compation to use VLOG(heap)

VLOG(gc) is spammy since it is enabled.

Change-Id: I07d1d40e2f19134f885d6777b60533a9010ae164
bad0267eaab9d6a522d05469ff90501deefdb88b 25-Aug-2014 Mathieu Chartier <mathieuc@google.com> Add native memory accounting through custom allocator.

Added a custom allocator that lets you pass in a special tag which
specifices where the allocation came from. This is used when
dumping. The performance overhead is low since each allocation only
does a atomic add/sub for each allocation/free.

The measurements are dumped to traces.txt during SIGQUIT.

Example output:
I/art (27274): AllocatorTagHeap active=120 max=120 total=168
I/art (27274): AllocatorTagMonitorList active=1572 max=6240 total=11724
I/art (27274): AllocatorTagClassTable active=185208 max=185208 total=268608
I/art (27274): AllocatorTagInternTable active=430368 max=430368 total=436080
I/art (27274): AllocatorTagMaps active=5616 max=6168 total=34392
I/art (27274): AllocatorTagLOS active=1024 max=1536 total=2044
I/art (27274): AllocatorTagSafeMap active=0 max=51936 total=533688
I/art (27274): AllocatorTagLOSMaps active=144 max=1248 total=5760
I/art (27274): AllocatorTagReferenceTable active=10944 max=11840 total=19136
I/art (27274): AllocatorTagHeapBitmap active=32 max=40 total=56
I/art (27274): AllocatorTagHeapBitmapLOS active=8 max=8 total=8
I/art (27274): AllocatorTagVerifier active=0 max=18844 total=1073156
I/art (27274): AllocatorTagModUnionCardSet active=5300 max=5920 total=56020
I/art (27274): AllocatorTagModUnionReferenceArray active=24864 max=24864 total=24864
I/art (27274): AllocatorTagJNILibrarires active=320 max=320 total=320
I/art (27274): AllocatorTagOatFile active=1400 max=1400 total=5852

Change-Id: Ibb470ef2e9c9a24563bb46422d46a55799704d82

(cherry picked from commit 5369c40f75fdcb1be7a7c06db212ce965c83a164)
5369c40f75fdcb1be7a7c06db212ce965c83a164 25-Aug-2014 Mathieu Chartier <mathieuc@google.com> Add native memory accounting through custom allocator.

Added a custom allocator that lets you pass in a special tag which
specifices where the allocation came from. This is used when
dumping. The performance overhead is low since each allocation only
does a atomic add/sub for each allocation/free.

The measurements are dumped to traces.txt during SIGQUIT.

Example output:
I/art (27274): AllocatorTagHeap active=120 max=120 total=168
I/art (27274): AllocatorTagMonitorList active=1572 max=6240 total=11724
I/art (27274): AllocatorTagClassTable active=185208 max=185208 total=268608
I/art (27274): AllocatorTagInternTable active=430368 max=430368 total=436080
I/art (27274): AllocatorTagMaps active=5616 max=6168 total=34392
I/art (27274): AllocatorTagLOS active=1024 max=1536 total=2044
I/art (27274): AllocatorTagSafeMap active=0 max=51936 total=533688
I/art (27274): AllocatorTagLOSMaps active=144 max=1248 total=5760
I/art (27274): AllocatorTagReferenceTable active=10944 max=11840 total=19136
I/art (27274): AllocatorTagHeapBitmap active=32 max=40 total=56
I/art (27274): AllocatorTagHeapBitmapLOS active=8 max=8 total=8
I/art (27274): AllocatorTagVerifier active=0 max=18844 total=1073156
I/art (27274): AllocatorTagModUnionCardSet active=5300 max=5920 total=56020
I/art (27274): AllocatorTagModUnionReferenceArray active=24864 max=24864 total=24864
I/art (27274): AllocatorTagJNILibrarires active=320 max=320 total=320
I/art (27274): AllocatorTagOatFile active=1400 max=1400 total=5852

Bug: 16238192

Change-Id: Ibb470ef2e9c9a24563bb46422d46a55799704d82
e1cb298bbd15141a55b5a760448a2402681fd1fc 27-Aug-2014 Andreas Gampe <agampe@google.com> ART: Check for no gaps only when we will have an immune region

In dex2oat, for example, this is not necessary. This CL enables running
dex2oat under valgrind.

Change-Id: Ia25c7bfb4903a613c80f4685030970b2a48e24f9
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
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
e4927f6654b7eda672312898e1fd3fecccacd6aa 23-Aug-2014 Mathieu Chartier <mathieuc@google.com> Fix race condition in TransitionCollector.

There was a minor race condition that could happen if multiple
threads called TransitionCollector at the same time. Starting out
in CMS:

Thread 1: TransitionCollector(SS).
Thread 2: TransitionCollector(CMS) sees that it is already CMS so
has copying_transition == false. But then thread 2 changes to SS.
Thread 1 resumes but incorrectly doesn't check the
disable_moving_gc_count_ possibly resulting in errors if
disable_moving_gc_count_ != 0 due to JNI since we are going from
SS -> CMS and are goign to move objects.

(cherry picked from commit de2233bbf64c7dde96513a729f6a97aebc2f0424)

Change-Id: I2fdda85f7cb7cbb0df3d1466a3c74853c5304c1b
de2233bbf64c7dde96513a729f6a97aebc2f0424 23-Aug-2014 Mathieu Chartier <mathieuc@google.com> Fix race condition in TransitionCollector.

There was a minor race condition that could happen if multiple
threads called TransitionCollector at the same time. Starting out
in CMS:

Thread 1: TransitionCollector(SS).
Thread 2: TransitionCollector(CMS) sees that it is already CMS so
has copying_transition == false. But then thread 2 changes to SS.
Thread 1 resumes but incorrectly doesn't check the
disable_moving_gc_count_ possibly resulting in errors if
disable_moving_gc_count_ != 0 due to JNI since we are going from
SS -> CMS and are goign to move objects.

Bug: 17189964

Change-Id: I4f0d002717516b81355d66f26e0e8ebe3958348d
c44ce2e9e88443d931443aa7ee738e4c43e1a12d 26-Aug-2014 Mathieu Chartier <mathieuc@google.com> Map heap maps at a lower address.

We now map the heap mmaps at a lower address in case the app needs
larger continuous address space.

Bug: 16502380

(cherry picked from commit 18bacb60e09fa8aa20ae0a1d7a4a8968d4913fb0)

Change-Id: I66447f853e439448c72923e2d1c657c94c5f1543
91c2f71bb518f5dcb9e01b4dbb136c5bec9e3a65 26-Aug-2014 Mathieu Chartier <mathieuc@google.com> Reduce GC log spam.

Homogeneous compaction and collector transitions now print to
VLOG(gc) instead of LOG(INFO).

Bug: 17166556

(cherry picked from commit 0ab56e95e203806dae347056d3331a3e6037457d)

Change-Id: I33157ca27da86cbb741759bb0bda6d38d1f5bfcd
0ab56e95e203806dae347056d3331a3e6037457d 26-Aug-2014 Mathieu Chartier <mathieuc@google.com> Reduce GC log spam.

Homogeneous compaction and collector transitions now print to
VLOG(gc) instead of LOG(INFO).

Bug: 17166556
Change-Id: I5d54acf36a9b2763922e6329596a2f191d45535c
18bacb60e09fa8aa20ae0a1d7a4a8968d4913fb0 26-Aug-2014 Mathieu Chartier <mathieuc@google.com> Map heap maps at a lower address.

We now map the heap mmaps at a lower address in case the app needs
larger continuous address space.

Bug: 16502380

Change-Id: I2cc11d0c207c0eae8db0c5025a48b11119c5a802
507e6180ad271eb719c67ce7394852c731d975a5 19-Aug-2014 Alex Light <allight@google.com> Support running without a boot image.

Bug: 17000769

(cherry picked from commit 64ad14dbe2225441fb7734bf6d89358d96692eea)

Change-Id: I6404d5050c8a2f4ee6e70d58532eb25ee9de248e
64ad14dbe2225441fb7734bf6d89358d96692eea 19-Aug-2014 Alex Light <allight@google.com> Support running without a boot image.

Bug: 17000769

Change-Id: I6404d5050c8a2f4ee6e70d58532eb25ee9de248e
6a7824dc81aaab3cb09ced16affca72d1b1da649 22-Aug-2014 Mathieu Chartier <mathieuc@google.com> Add fallback for non moving space being full.

When the non moving space becomes full, we disable moving GC and
make the main space the new non moving space.

Also added a runtime option for changing the non moving space size:
-XX:NonMovingSpaceCapacity.

Bug: 17189964

(cherry picked from commit 4c5a469683e433f126c9863cd393747d2e7c4a29)

Change-Id: If82e3c6f8a0f389e37e14a0b1e6d5126d571fd7a
4c5a469683e433f126c9863cd393747d2e7c4a29 22-Aug-2014 Mathieu Chartier <mathieuc@google.com> Add fallback for non moving space being full.

When the non moving space becomes full, we disable moving GC and
make the main space the new non moving space.

Also added a runtime option for changing the non moving space size:
-XX:NonMovingSpaceCapacity.

Bug: 17189964
Change-Id: I04d00d0f457f6c1f5724bf32932b6b6ce4d341b1
0deeb815d32be7c98d8b1567db3e8f8d190b6d3b 22-Aug-2014 Mathieu Chartier <mathieuc@google.com> Fix testing wrong variable for non zygote.

For non zygote we want to only have a single non moving space to
let dex2oat use RosAlloc for all allocations.

Fixed stale low memory logic in parsed options.

Bug: 17189964

(cherry picked from commit a12c2a945fe3f10d3ed31aa5db3e422cc1ad7f98)

Change-Id: I4fc00b277db6780ed410eab4cd969e8f004d5348
a12c2a945fe3f10d3ed31aa5db3e422cc1ad7f98 22-Aug-2014 Mathieu Chartier <mathieuc@google.com> Fix testing wrong variable for non zygote.

For non zygote we want to only have a single non moving space to
let dex2oat use RosAlloc for all allocations.

Fixed stale low memory logic in parsed options.

Bug: 17189964
Change-Id: I85a565002fd18ae30105df084796521abd60ea12
e4cab17634dc6d5809b40f2ed80d6459734ae2fe 20-Aug-2014 Mathieu Chartier <mathieuc@google.com> Enable large object space for zygote.

We now enable the large object space before the zygote fork.
This reduces the size of the zygote and removes the need for
excessive explicit GCs during phone booting.

Changed the card set mod union table to support forgetting cards.
If a card has no non null references which are in another space
then it is removed from the set.

Added logging of the zygote size when you do a SIGQUIT.

Dalvik PSS is the same or slightly lower (1-3%).

Zygote space size:
Before: 15MB
After: 8MB (+ some large objects).

TODO: Combine remembered sets and mod union tables into a single
interface.

Bug: 16398684
Change-Id: Ie48cdf35004a0a37eedb1ccc1bf214b1fa9e0cca
6724d8649ab73e4fb86c8014bda51b13bddf2f3f 19-Aug-2014 Mathieu Chartier <mathieuc@google.com> Fix heap corruption and verification.

There was a faulty assumption that space End() was always aligned to
card boundaries. This was true for all spaces other than the image
and resulted in heap corruption when the last object of the image
space contained a reference to an object in another space.

Also fixed an error where we called the pre GC verification post GC.

Bug: 17080623

Change-Id: I041ee564518f53b79c6e8dc2ad782a3152577a4e
d35326fc45ef71d88b82fd5fe6875ae07f3646cb 19-Aug-2014 Mathieu Chartier <mathieuc@google.com> Fix heap corruption and verification.

There was a faulty assumption that space End() was always aligned to
card boundaries. This was true for all spaces other than the image
and resulted in heap corruption when the last object of the image
space contained a reference to an object in another space.

Also fixed an error where we called the pre GC verification post GC.

Bug: 17080623

(cherry picked from commit 6724d8649ab73e4fb86c8014bda51b13bddf2f3f)

Change-Id: I931149421c738653863eb6105dfdf7ecd750601a
837150818af0eee993f7d93c5a50c3c7b46f1dab 13-Aug-2014 Mathieu Chartier <mathieuc@google.com> Add allocation rate tracking to systrace.

Bug: 16956980

Change-Id: I7074f4ae0f75d1bb58e9860ded4e17ce6978d74e
cb6b0f31ede2275e79e6199ec391147585a37a2a 12-Aug-2014 Ian Rogers <irogers@google.com> Avoid use of std::string where we have const char*.

Removing the ClassHelper caused std::string creation for all calls to
Class::GetDescriptor and a significant performance regression. Make the
std::string an out argument so the caller can maintain it and its life time
while allowing GetDescriptor to return the common const char* case.

Don't generate GC maps when compilation is disabled.

Remove other uses of std::string that are occuring on critical paths.
Use the cheaper SkipClass in CompileMethod in CompilerDriver.
Specialize the utf8 as utf16 comparison code for the common shorter byte
encoding.
Force a bit of inlining, remove some UNLIKELYs (they are prone to pessimizing
code), add some LIKELYs.

x86-64 host 1-thread interpret-only of 57 apks:
Before: 29.539s
After: 23.467s

Regular compile:
Before: 1m35.347s
After: 1m20.056s

Bug: 16853450
Change-Id: Ic705ea24784bee24ab80084d06174cbf87d557ad

Conflicts:
runtime/utils.cc
1ff3c98775a4577cf053dba9a0c2d5c21c07b298 12-Aug-2014 Ian Rogers <irogers@google.com> Avoid use of std::string where we have const char*.

Removing the ClassHelper caused std::string creation for all calls to
Class::GetDescriptor and a significant performance regression. Make the
std::string an out argument so the caller can maintain it and its life time
while allowing GetDescriptor to return the common const char* case.

Don't generate GC maps when compilation is disabled.

Remove other uses of std::string that are occuring on critical paths.
Use the cheaper SkipClass in CompileMethod in CompilerDriver.
Specialize the utf8 as utf16 comparison code for the common shorter byte
encoding.
Force a bit of inlining, remove some UNLIKELYs (they are prone to pessimizing
code), add some LIKELYs.

x86-64 host 1-thread interpret-only of 57 apks:
Before: 29.539s
After: 23.467s

Regular compile:
Before: 1m35.347s
After: 1m20.056s

Bug: 16853450
Change-Id: Ic705ea24784bee24ab80084d06174cbf87d557ad
b225890e02bc8d5864217743eaef306d5387e0e9 07-Aug-2014 Mathieu Chartier <mathieuc@google.com> Change FreeMemory and TotalMemory behavior.

TotalMemory is now equal to the footprint limit (around when the
next GC will occur).
FreeMemory is now equal to TotalMemory() - bytes_allocated_.
Also added more memory dumping info to DumpGcPerformanceInfo.

Bug: 16520008
Bug: 15819878

(cherry picked from commit dd162fb5990cedf80a5093ecc0e77df82af5f754)

Change-Id: I68239a5295cc1372b3995eb781d67b9e25d6eaed
c30a7257f1d0cc79931f38e8cbbb45aab8682acb 12-Aug-2014 Mathieu Chartier <mathieuc@google.com> Prevent merge conflicts.

Change-Id: I61af7f3c9be47d4776371dfe2b97850ea3f3101f
dd162fb5990cedf80a5093ecc0e77df82af5f754 07-Aug-2014 Mathieu Chartier <mathieuc@google.com> Change FreeMemory and TotalMemory behavior.

TotalMemory is now equal to the footprint limit (around when the
next GC will occur).
FreeMemory is now equal to TotalMemory() - bytes_allocated_.
Also added more memory dumping info to DumpGcPerformanceInfo.

Bug: 16520008
Bug: 15819878

Change-Id: Ifa59a2f2136dd0704097411ee183925e6c387fae
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
104fa0c0c7dad925d9f4d5c101a8064cd6830da7 07-Aug-2014 Mathieu Chartier <mathieuc@google.com> Guard pause histogram with lock.

There is a race condition since the GC was updating this without
holding any locks. But the signal catcher could be dumping the
timings with DumpGcPerformanceInfo at the same time. This could
potentially cause out of bound errors, etc..

Also did a bit of cleanup.

Bug: 15446488
Change-Id: Icaff19d872cc7f7d31c34e4ddaae97502454e09c
c1276c838d1d0896048b8c14458432b94274e869 07-Aug-2014 Hiroshi Yamauchi <yamauchi@google.com> Fix a SIGSEGV at background-to-foreground collector transition.

The mem map that's used to create the backup main rosalloc space is
set to PROT_NONE by the compaction and the rosalloc space creation
attempts to write the debug magic number in the first page.

This is a debug build only issue.

Bug: 16854263
Change-Id: I3cc6b7288ee53c006366bb428fb245a909bc3db5
e0d6421cdb42508f4d36f28cc9eddc31271bb37a 07-Aug-2014 Hiroshi Yamauchi <yamauchi@google.com> Fix a SIGSEGV at background-to-foreground collector transition.

The mem map that's used to create the backup main rosalloc space is
set to PROT_NONE by the compaction and the rosalloc space creation
attempts to write the debug magic number in the first page.

This is a debug build only issue.

Cherry pick commit c1276c838d1d0896048b8c14458432b94274e869.

Bug: 16854263
Change-Id: Ide2545d92bcafd3a095ac7f0c89c5b43d6dd78de
6bff7130878128c9836a21ae58d0cfdb0075b1b5 30-Jul-2014 Mathieu Chartier <mathieuc@google.com> Add support for bump pointer spaces to DdmSendHeapSegments.

Added support for bump pointer spaces as well as
differentiating between DlMallocSpaces and RosAllocSpaces.
Added logic to reset the start of next chunk to prevent
inbetween space regions counted as free.

Fixed a debug build bug where we were doing an mprotect after
creating a rosalloc space. In debug builds, this writes a magic
value in the page. This was faulting since it was set to PROT_NONE.
The fix moves the mprotect before the RosAlloc space creation.

Bug: 16408851

(cherry picked from commit 36dab3607e77505ce139eacef1c62a1c4bc4affd)

Change-Id: I5095feb01fa7e248178a2833da7f821f4fd52c89
36dab3607e77505ce139eacef1c62a1c4bc4affd 30-Jul-2014 Mathieu Chartier <mathieuc@google.com> Add support for bump pointer spaces to DdmSendHeapSegments.

Added support for bump pointer spaces as well as
differentiating between DlMallocSpaces and RosAllocSpaces.
Added logic to reset the start of next chunk to prevent
inbetween space regions counted as free.

Fixed a debug build bug where we were doing an mprotect after
creating a rosalloc space. In debug builds, this writes a magic
value in the page. This was faulting since it was set to PROT_NONE.
The fix moves the mprotect before the RosAlloc space creation.

Bug: 16408851
Change-Id: Ibe18198d05ff353fbb57d10b2f7719fdcbf1c5f0
b2ac1ab47f84bd989fb2c94a532f5dc7d177ebe4 25-Jul-2014 Mathieu Chartier <mathieuc@google.com> Fix main space memory leak and add checks.

The hypothesis is that we were leaking the main space and its
bitmaps, then eventually we would run out of virtual address space,
which would cause a null bitmap (DCHECK). Finally when we tried
adding the space with a null bitmap to the heap bitmap it segfaulted.

Changed some non performance critical DCHECK -> CHECK.

Bug: 16563323

(cherry picked from commit 2796a1669ae0f3b96db8432fbd8be1b93bf335c4)

Change-Id: Ifa9d866c6c89eff22a547af4db70bc79a77690ed
2796a1669ae0f3b96db8432fbd8be1b93bf335c4 25-Jul-2014 Mathieu Chartier <mathieuc@google.com> Fix main space memory leak and add checks.

The hypothesis is that we were leaking the main space and its
bitmaps, then eventually we would run out of virtual address space,
which would cause a null bitmap (DCHECK). Finally when we tried
adding the space with a null bitmap to the heap bitmap it segfaulted.

Changed some non performance critical DCHECK -> CHECK.

Bug: 16563323
Change-Id: I08a1f873752e28ebcf63ebbd90f92d994d7ca96b
00b5915828f89daaefd9e8fb215658360f76762c 25-Jul-2014 Mathieu Chartier <mathieuc@google.com> Fix dangling pointer bug when transitioning to background.

Dangling pointer left behind from the old rosalloc / dlmalloc
spaces. We now avoid using this pointer by using main_space_
and non_moving_space_ as well as clear the pointer when we remove
the space.

Bug: 16567203

Change-Id: Ida9ff30783e89cd4a4d86a4d0e912701692101f1
27c84b64bdd3302d8260c6f330513e484d97fc98 25-Jul-2014 Mathieu Chartier <mathieuc@google.com> Fix dangling pointer bug when transitioning to background.

Dangling pointer left behind from the old rosalloc / dlmalloc
spaces. We now avoid using this pointer by using main_space_
and non_moving_space_ as well as clear the pointer when we remove
the space.

Bug: 16567203

(cherry picked from commit 00b5915828f89daaefd9e8fb215658360f76762c)

Change-Id: I5962929e4a0bb4db6f531d25ee322da7ab3f5dd4
4df72b8a198e2d649c6be76628d80d984cc33395 16-Jul-2014 Stephen Hines <srhines@google.com> Remove errors/warnings from tautological comparisons.

Change-Id: I2728b08d55abccd14c111c6c9da93068d4e14275
79ce45ce0f57ed27f280507163b7ba954307e2ba 16-Jul-2014 Stephen Hines <srhines@google.com> Add back a deleted check related to verification.

Change-Id: Ib939d1a7395a4b6cc9a7256cfb0a3498ba296744
c0dcf29143051cf34d6c032a7b385ac4579bd4ec 24-Jul-2014 Mathieu Chartier <mathieuc@google.com> Fix stale remembered sets error.

We were forgetting to remove the remembered set in transition to
background. This resulted in remembered sets being added for
spaces which no longer existed. This finally caused an error when
a new space happened to have the same address as the old space,
resulting in a CHECK failure.

Also tuned the number of ParallelGC to prevent spurrious failures
and removed the ParallelGC from broken tests in the make file.

Bug: 16532086
Bug: 16406852

Change-Id: I00bbcbd7daa03c867732d165be62b72e6c43bce1

(cherry picked from c5a8347ac491a5f521945d3835a322123830456b)
38c488bcd41ba632a646d7a1d790ec71a2fcf6fa 16-Jul-2014 Mathieu Chartier <mathieuc@google.com> Recycle mem-maps for collector transitions.

We now create spaces when we need them for collector transitions or
homogeneous compaction by recycling mem maps. Change the bump
pointer space size to be as large as the heap capacity instead of
1/2 heap capacity like it used to be. For GSS, bump pointer spaces
are set to 32MB currently.

Changed GSS to have main space == non moving space since we don't
need to copy from the main space.

Fixes GC stress tests 074, 096.
Fixed test 080 oom throw with -Xmx2m for GC stress test, this was
broken since it was allocating a 4 MB array before starting the
OOM process.

Bug: 14059466
Bug: 16406852

(cherry picked from commit b363f666883860d40823d5528df3c98c897f74f4)

Change-Id: I62877cfa24ec944a6f34ffac30334f454a8002fd
b76cac637691c29daa9c44e493b5bc26346ed116 23-Jul-2014 Mathieu Chartier <mathieuc@google.com> Revert "Revert "Disable adding main and non moving spaces to immune region in GSS""

This reverts commit f85c2fb317399ab540854cd7551ac47690366543.
5189e24fb6d42c04c48169ab2f15de56ecf3c828 24-Jul-2014 Mathieu Chartier <mathieuc@google.com> Fix memory leak in RemoveRememberedSet.

RemoveRememberedSet now deletes the remembered set.

Bug: 16532086
Change-Id: I01092931cc20cd0688dd42eed3dde9ad140889b2
c5a8347ac491a5f521945d3835a322123830456b 24-Jul-2014 Mathieu Chartier <mathieuc@google.com> Fix stale remembered sets error.

We were forgetting to remove the remembered set in transition to
background. This resulted in remembered sets being added for
spaces which no longer existed. This finally caused an error when
a new space happened to have the same address as the old space,
resulting in a CHECK failure.

Also tuned the number of ParallelGC to prevent spurrious failures
and removed the ParallelGC from broken tests in the make file.

Bug: 16532086
Bug: 16406852

Change-Id: I00bbcbd7daa03c867732d165be62b72e6c43bce1
b363f666883860d40823d5528df3c98c897f74f4 16-Jul-2014 Mathieu Chartier <mathieuc@google.com> Recycle mem-maps for collector transitions.

We now create spaces when we need them for collector transitions or
homogeneous compaction by recycling mem maps. Change the bump
pointer space size to be as large as the heap capacity instead of
1/2 heap capacity like it used to be. For GSS, bump pointer spaces
are set to 32MB currently.

Changed GSS to have main space == non moving space since we don't
need to copy from the main space.

Fixes GC stress tests 074, 096.
Fixed test 080 oom throw with -Xmx2m for GC stress test, this was
broken since it was allocating a 4 MB array before starting the
OOM process.

Bug: 14059466
Bug: 16406852
Change-Id: I62877cfa24ec944a6f34ffac30334f454a8002fd
f85c2fb317399ab540854cd7551ac47690366543 22-Jul-2014 Mathieu Chartier <mathieuc@google.com> Revert "Disable adding main and non moving spaces to immune region in GSS"

Bug: 16399257

This reverts commit be0562fb14e6754ee932b8d9c97e2a6df3a91119.

Change-Id: I29e07a8fa1e972990e5bf1ddf8c9a3538ea5f9cf
be0562fb14e6754ee932b8d9c97e2a6df3a91119 14-Jul-2014 Mathieu Chartier <mathieuc@google.com> Disable adding main and non moving spaces to immune region in GSS

Disabled adding the main and non moving space to the immune region.
This will enable us to recycle bump pointer spaces for malloc space
-> malloc space compaction as well as collector transitions.

Also added logic for falling back to the non moving space, we may
copy objects there.

Refactored mod union table logic into MarkReachableObjects.

No measurable performance benefit or regression.

Bug: 14059466
Bug: 16291259

(cherry picked from commit 4c13a3ff475f206c4d0a86ee2595c45392fd942f)

Change-Id: I858b4fbddca888e164052ad247565a0bdbea68b5
22c6a817ed3019455d22df13bd91faf012177ef6 16-Jul-2014 Stephen Hines <srhines@google.com> Add back a deleted check related to verification.

Change-Id: Ib939d1a7395a4b6cc9a7256cfb0a3498ba296744
4c13a3ff475f206c4d0a86ee2595c45392fd942f 14-Jul-2014 Mathieu Chartier <mathieuc@google.com> Disable adding main and non moving spaces to immune region in GSS

Disabled adding the main and non moving space to the immune region.
This will enable us to recycle bump pointer spaces for malloc space
-> malloc space compaction as well as collector transitions.

Also added logic for falling back to the non moving space, we may
copy objects there.

Refactored mod union table logic into MarkReachableObjects.

No measurable performance benefit or regression.

Bug: 14059466
Bug: 16291259

Change-Id: If663d9fdbde943b988173b7f6ac844e5f78a0327
b5f5649ba4c8cb51ce143ddbedd5e1549f08f8b3 16-Jul-2014 Stephen Hines <srhines@google.com> Remove errors/warnings from tautological comparisons.

Change-Id: I2728b08d55abccd14c111c6c9da93068d4e14275
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
f37a88b8e6db6c587fa449a12e40cb46be1689fc 10-Jul-2014 Zuo Wang <zuo.wang@intel.com> ART: Compacting ROS/DlMalloc spaces with semispace copy GC

Current semispace copy GC is mainly associated with bump pointer
spaces. Though it squeezes fragmentation most aggressively, an extra
copy is required to re-establish the data in the ROS/DlMalloc space to allow
CMS GCs to happen afterwards. As semispace copy GC is still stop-the-world,
this not only introduces unnecessary overheads but also longer response time.
Response time indicates the time duration between the start of transition
request and the start of transition animation, which may impact the user
experience.

Using semispace copy GC to compact the data in a ROS space to another ROS(or
DlMalloc space to another DlMalloc) space solves this problem. Although it
squeezes less fragmentation, CMS GCs can run immediately after the compaction.

We apply this algorithm in two cases:
1) Right before throwing an OOM if -XX:EnableHSpaceCompactForOOM is passed in
as true.
2) When app is switched to background if the -XX:BackgroundGC option has value
HSpaceCompact.

For case 1), OOMs are significantly delayed in the harmony GC stress test,
with compaction ratio up to 0.87. For case 2), compaction ratio around 0.5 is
observed in both built-in SMS and browser. Similar results have been obtained
on other apps as well.

Change-Id: Iad9eabc6d046659fda3535ae20f21bc31f89ded3
Signed-off-by: Wang, Zuo <zuo.wang@intel.com>
Signed-off-by: Chang, Yang <yang.chang@intel.com>
Signed-off-by: Lei Li <lei.l.li@intel.com>
Signed-off-by: Lin Zang <lin.zang@intel.com>
654dd48e2230e16bfaa225decce72b52642e2f78 09-Jul-2014 Hiroshi Yamauchi <yamauchi@google.com> Improve the OOME fragmentation message.

Change-Id: I390d3622f8d572ec7e34ea6dff9e1e0936e81ac1
a5b5c55c8585b7ce915f0c7e1f66d121a7f7a078 24-Jun-2014 Mathieu Chartier <mathieuc@google.com> Add notion of released vs empty pages to ROSAlloc.

A notion of released vs empty pages helps get a more accurate view of
how much memory was released during heap trimming. Otherwise we get
that the same pages possibly get madvised multiple times without
getting dirtied.

Also enabled heap trimming of rosalloc spaces even when we care about
jank. This is safe to do since the trimming process only acquires
locks for short periods of time.

Dalvik PSS reduces from ~52M to ~50M after boot on N4.

Bug: 9969166

Change-Id: I4012e0a2554f413d18efe1a0371fe18d1edabaa9
f5997b4d3f889569d5a2b724d83d764bfbb8d106 20-Jun-2014 Mathieu Chartier <mathieuc@google.com> More advanced timing loggers.

The new timing loggers have lower overhead since they only push into
a vector. The new format has two types, a start timing and a stop
timing. You can thing of these as brackets associated with a
timestamp. It uses these to construct various statistics when needed,
such as: Total time, exclusive time, and nesting depth.

Changed PrettyDuration to have a default of 3 digits after the decimal
point.

Exaple of a GC dump with exclusive / total times and indenting:
I/art (23546): GC iteration timing logger [Exclusive time] [Total time]
I/art (23546): 0ms InitializePhase
I/art (23546): 0.305ms/167.746ms MarkingPhase
I/art (23546): 0ms BindBitmaps
I/art (23546): 0ms FindDefaultSpaceBitmap
I/art (23546): 0ms/1.709ms ProcessCards
I/art (23546): 0.183ms ImageModUnionClearCards
I/art (23546): 0.916ms ZygoteModUnionClearCards
I/art (23546): 0.610ms AllocSpaceClearCards
I/art (23546): 1.373ms AllocSpaceClearCards
I/art (23546): 0.305ms/6.318ms MarkRoots
I/art (23546): 2.106ms MarkRootsCheckpoint
I/art (23546): 0.153ms MarkNonThreadRoots
I/art (23546): 4.287ms MarkConcurrentRoots
I/art (23546): 43.461ms UpdateAndMarkImageModUnionTable
I/art (23546): 0ms/112.712ms RecursiveMark
I/art (23546): 112.712ms ProcessMarkStack
I/art (23546): 0.610ms/2.777ms PreCleanCards
I/art (23546): 0.305ms/0.855ms ProcessCards
I/art (23546): 0.153ms ImageModUnionClearCards
I/art (23546): 0.610ms ZygoteModUnionClearCards
I/art (23546): 0.610ms AllocSpaceClearCards
I/art (23546): 0.549ms AllocSpaceClearCards
I/art (23546): 0.549ms MarkRootsCheckpoint
I/art (23546): 0.610ms MarkNonThreadRoots
I/art (23546): 0ms MarkConcurrentRoots
I/art (23546): 0.610ms ScanGrayImageSpaceObjects
I/art (23546): 0.305ms ScanGrayZygoteSpaceObjects
I/art (23546): 0.305ms ScanGrayAllocSpaceObjects
I/art (23546): 1.129ms ScanGrayAllocSpaceObjects
I/art (23546): 0ms ProcessMarkStack
I/art (23546): 0ms/0.977ms (Paused)PausePhase
I/art (23546): 0.244ms ReMarkRoots
I/art (23546): 0.672ms (Paused)ScanGrayObjects
I/art (23546): 0ms (Paused)ProcessMarkStack
I/art (23546): 0ms/0.610ms SwapStacks
I/art (23546): 0.610ms RevokeAllThreadLocalAllocationStacks
I/art (23546): 0ms PreSweepingGcVerification
I/art (23546): 0ms/10.621ms ReclaimPhase
I/art (23546): 0.610ms/0.702ms ProcessReferences
I/art (23546): 0.214ms/0.641ms EnqueueFinalizerReferences
I/art (23546): 0.427ms ProcessMarkStack
I/art (23546): 0.488ms SweepSystemWeaks
I/art (23546): 0.824ms/9.400ms Sweep
I/art (23546): 0ms SweepMallocSpace
I/art (23546): 0.214ms SweepZygoteSpace
I/art (23546): 0.122ms SweepMallocSpace
I/art (23546): 6.226ms SweepMallocSpace
I/art (23546): 0ms SweepMallocSpace
I/art (23546): 2.144ms SweepLargeObjects
I/art (23546): 0.305ms SwapBitmaps
I/art (23546): 0ms UnBindBitmaps
I/art (23546): 0.275ms FinishPhase
I/art (23546): GC iteration timing logger: end, 178.971ms

Change-Id: Ia55b65609468f212b3cd65cda66b843da42be645
48ab687d1f864fec93c2682de6fdc44ab784e2f8 24-Jun-2014 Mathieu Chartier <mathieuc@google.com> Add logging to monitor deflation.

Change-Id: I0251ff19e0a3c3b9edc7c7e296f15eb3229f8f7c
10fb83ad7442c8cf3356a89ec918e0786f110981 16-Jun-2014 Mathieu Chartier <mathieuc@google.com> Shared single GC iteration accounting for all GCs.

Previously, each garbage collector had data that was only used
during collection. Since only one collector can be running at any
given time, we can make this data be shared between all collectors.
This reduces memory usage since we don't need to have redundant
information for each GC types. Also reduced how much code is required
to sweep spaces.

Bug: 9969166
Change-Id: I31caf0ee4d572f75e0c66863fe7db12c08ae08e7
19d46b44f2abe742be22e32908dbfd9e6dd9bfea 18-Jun-2014 Mathieu Chartier <mathieuc@google.com> Fix systrace logging, total paused time, and bytes saved message.

Moved the GC top level systrace logging to be inside of Collector::Run.
This prevents cases where we forgot to call it such as background
compaction. Fixed a unit error regarding total pause time. Fixed
negative bytes saved to use the word "expanded".

Bug: 15702709

Change-Id: Ic2991ecad2daa000d0aee9d559b8bc77d8c160aa
52e4b43d62896b56f8c2bd041e528472bb4a0d8d 10-Jun-2014 Mathieu Chartier <mathieuc@google.com> Add mark compact collector.

The mark compact collector is a 4 phase collection, doing a normal
full mark_sweep, calculating forwarding addresses of objects in the
from space, updating references of objects in the from space, and
moving the objects in the from space.

Support is diabled by default since it needs to have non movable
classes and field arrays. Performance numbers is around 50% as fast.

The main advantage that this has over semispace is that the worst
case memory usage is 50% since we only need one space isntead of two.

TODO: Make field arrays and classes movable. This causes complication
since Object::VisitReferences relies on these, so if we update the
fields of an object but another future object uses this object to
figure out what fields are reference fields it doesn't work.

Bug: 14059466

Change-Id: I661ed3b71ad4dde124ef80312c95696b4a5665a1
96bcd45e8bd9ab5a50e005fdaf4448e2c53283ec 17-Jun-2014 Mathieu Chartier <mathieuc@google.com> Fix error with remembered sets creation.

There was an error where we were not re-creating the remembered sets
in PreZygoteFork. This caused a rare check failure due to the
stale remembered set occasionally having the same space as the newly
created one.

Bug: 15680452
Change-Id: Ibfa569e67ad0ff032f3e9696a99b992a18583243
308351ada0008b0cbe1a5afc31c302c975554ee4 15-Jun-2014 Mathieu Chartier <mathieuc@google.com> Change reference processing to use heap references.

Removes several SetReferents for updating moved referents. Cleaned
up other aspects of the code.

Change-Id: Ibcb4d713fadea617efee7e936352ddf77ff4c370
d30e1d6b477650366c25822f956202fec041e1d5 09-Jun-2014 Mathieu Chartier <mathieuc@google.com> Fix GetFreeMemory to use fooprint limit instead of max memory.

Based on definitions in:
http://developer.android.com/reference/java/lang/Runtime.html

Bug: 15507122
Change-Id: I02f34682d7ac2d379a07631b5207b6cfb224da6b
aff59a8a4eb976fbac371cc416fc5ffb117cd6c7 07-Jun-2014 Mathieu Chartier <mathieuc@google.com> Add missing initializtaion of last_gc_time_ns_.

Fixes some valgrind warnings.

Bug: 15426766
Change-Id: Ibaa78465739bf6919509cf87c72b25c84ed1d12c
3eed93dd5be03e5539827bebf0f414251a12e15e 04-Jun-2014 Hiroshi Yamauchi <yamauchi@google.com> Verify there's no mem map gap for immune region not to break.

This adds code that verifies that there's no memory map gap between
the image space and the main space so that the immune region
functionality won't silently break. For example, if there's a gap and
a large object is allocated in that gap, the large object is
incorrectly part of the immune region and the marking breaks.

Bug: 14059466
Change-Id: Ie6ed82988d74b6d0562ebbbaac96ee43c15b14a6
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
ffddfdf6fec0b9d98a692e27242eecb15af5ead2 03-Jun-2014 Tim Murray <timmurray@google.com> DO NOT MERGE

Merge ART from AOSP to lmp-preview-dev.

Change-Id: I0f578733a4b8756fd780d4a052ad69b746f687a9
8e1ebf467a9c8fa504d7a90e03df6053ecdceeb3 30-May-2014 Mathieu Chartier <mathieuc@google.com> Change GetFreeMemory to use the growth limit.

This makes more sense since it is what the allocator uses. Also fixed
somewhere where we were not properly passing in whether or not it was
a large object allocation.

Bug: 15327879
Change-Id: Ieab7af5427f5cdc2760390186b67e2c96d4bafa7
4240c5112aedb174a3e1c1f071ea54e82168b130 27-May-2014 Mathieu Chartier <mathieuc@google.com> Don't create bump pointer spaces unless necessary.

We now only create these spaces if the foreground or background
collector is a moving collector.

Bug: 13564922
Bug: 14059466
Change-Id: I9f83c7881bc28423b78d5249c8e8854add91b60c
c179016fe188bef09487e777aa0fd861f5cdf067 23-May-2014 Mathieu Chartier <mathieuc@google.com> Add reserve area to allocation stacks.

This fixes an issue with heap verification which was caused when
the allocation stack overflowed. This resulted in heap verification
failures since we were storing the newly allocated object in a
handle scope without having it be live either in the live bitmap
or allocation stack. We now push the object in the reserve area
before we do a GC due to allocation stack overflow.

Change-Id: I83b42c4b3250d7eaab1b49e53066e21c8656a740
c4ddc042eaf5232a3f9b111f42af39eeab6e0294 13-May-2014 Christopher Ferris <cferris@google.com> Add support for jemalloc instead of dlmalloc.

Bug: 981363
Change-Id: I226ce3249c0d982eb1a9fdb9d04b25737f77345d
e9e55ac9f68b74a0fcd208685082fd6a1e89a51e 22-May-2014 Mathieu Chartier <mathieuc@google.com> Fix build.

Old Atomic things were rebased over.

Change-Id: I437041af3247c316f2a75f5ef4bd35286fc8e2b1
8e4a96d9a7ba7c555032ef583a089ebd2c53f5f7 21-May-2014 Mathieu Chartier <mathieuc@google.com> Change zygote_creation_lock_ to be member instead of static.

Static variables aren't thread safe and could cause the zygote to be
created twice.

Bug: 15133494
Change-Id: I65c8f089bed8de93f895b62b3dcff4c936931860
3e5cf305db800b2989ad57b7cde8fb3cc9fa1b9e 21-May-2014 Ian Rogers <irogers@google.com> Begin migration of art::Atomic to std::atomic.

Change-Id: I4858d9cbed95e5ca560956b9dabd976cebe68333
8ab7e78be6835d63a2cee9f234334ed8fb409781 20-May-2014 Mathieu Chartier <mathieuc@google.com> Improve heap verification for invalid roots.

The new root verification prints the root type and owner thread id as
well as the type of the object.

Also a bit of work for planned multi-threaded verification.

Bug: 14289301

Change-Id: Ia73c517dc11ec6dd82f3d945604ee3836b3db536
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
f832284dd847ff077577bb5712225430bbbb3b67 16-May-2014 Mathieu Chartier <mathieuc@google.com> Delete ClassHelper and fix compaction bug in GetDirectInterface

Cleanup helps to prevent compaction bugs. Fixed a fairly serious
compaction error caused by calling ClassHelper::GetDirectInterface
without handling the case where it causes thread suspension due to
ResolveType.

Bug: 8981901

Change-Id: I82b3bb6dd48d21eb6ece7aae0733c4a23c2bc408
507dfdd147c97bfbadebfd63584d094b6a4e7b47 16-May-2014 Ian Rogers <irogers@google.com> Compatibility layer to transition from UniquePtr to std::unique_ptr.

Use ART_WITH_STLPORT (enabled for the target) to cause the use of UniquePtr,
for the host switch to std::unique_ptr. For now the type remains called
UniquePtr.
Make dalvik compile with clang on the host, move its build to C++11.

Change-Id: I5ba8d2757904bc089ed62047ea03de3c0853fb12
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
a6a8d142e60076db1ed6035119856779533bd09e 13-May-2014 Hiroshi Yamauchi <yamauchi@google.com> Fix a lock level violation with background compaction enabled.

Bug: 14840305
Change-Id: I19f3d26af0c4f9c5a2843e0d95c8c10391cc38b1
78f7b4c04ab6e8b5581921bc95b67a9beee1c246 06-May-2014 Mathieu Chartier <mathieuc@google.com> Add concurrent reference processing.

Concurrent reference processing currently works by going into native
code from java.lang.ref.Reference.get(). From there, we have a fast
path if the references aren't being processed which returns the
referent without needing to access any locks. In the slow path we
block until reference processing is complete. It may be possible to
improve the slow path if the referent is blackened.

TODO: Investigate doing the fast path in java code by using racy reads
of a static volatile boolean. This will work as long as there are no
suspend points inbetween the boolean read and referent read.

Bug: 14381653

Change-Id: I1546b55be4691fe4ff4aa6d857b234cce7187d87
52ba1996f1d8089f0101d189a5cdd27356206b1c 07-May-2014 Mathieu Chartier <mathieuc@google.com> Fix spammy "Disabling background compaction for non zygote" message.

Change-Id: I4abd85f75341ffc3cc38200d8b43a77b9b87c744
41961e2ad0aa064db9fefdd2a52368047961115a 07-May-2014 Mathieu Chartier <mathieuc@google.com> Fix device booting with DlMalloc instead of RosAlloc.

Change-Id: I347ef931e5c738937bcc50d7e8f4d5b3729fd3e4
e76e70f424468f311c2061c291e8384263f3968c 03-May-2014 Mathieu Chartier <mathieuc@google.com> Add RecordFree to the GarbageCollector interface

RecordFree now calls the Heap::RecordFree as well as updates the
garbage collector's internal bytes freed accounting.

Change-Id: I8cb03748b0768e3c8c50ea709572960e6e4ad219
89a201e599da95d88590c7b4d069b76735e20fa8 02-May-2014 Mathieu Chartier <mathieuc@google.com> Add GC cause to WaitForGcToComplete message.

Change-Id: I8fe107d90a84de065c407b8d29fd106267ac440d
8668c3cbdcf9471bd97e0da68a240051f2973074 25-Apr-2014 Mathieu Chartier <mathieuc@google.com> Add finalizer references from the entrypoints.

We now have an invariant where we never allocate finalizable
objects with the Initialized or Resolved entrypoints. This speeds up
allocation by only doing the check in the slow path.

Before:
MemAllocTest: 3625, 3707, 3641
EvaluateAndApplyChanges: 3448, 3421, 3413

After:
MemAllocTest: 3164, 3109, 3135
EvaluateAndApplyChanges: 3272, 3299, 3353

Bug: 14078487

Change-Id: I2b0534af3e7c75ea5e5257cf3647744f7abfb74e
11d9f06a96a6909905c248ed684366190140095c 23-Apr-2014 Narayan Kamath <narayan@google.com> Use instruction specific dalvik cache dirs.

- All oat & art files are now placed under /data/dalvik-cache/<isa>/.
- GetDalvikCacheOrDie now requires a mandatory subdirectory argument,
and is implicitly rooted under /data/.
- Added helper methods to convert InstructionSet enums into strings
and vice versa.

(cherry picked from commit 2974bc3d8a5d161d449dd66826d668d87bdc3cbe)

Change-Id: Ic7986938e6a7091a2af675ebafec768f7b5fb8cd
1b54f9cb38605046d772ba0e125d5c009f1de7d2 01-May-2014 Mathieu Chartier <mathieuc@google.com> Clean up Add/Remove space.

Deleted the set_as_default parameter and added a new function
SetSpaceAsDefault instead.

Change-Id: Ic4c359854d08e64ac0d0df92f0105447adb9df36
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
2974bc3d8a5d161d449dd66826d668d87bdc3cbe 23-Apr-2014 Narayan Kamath <narayan@google.com> Use instruction specific dalvik cache dirs.

- All oat & art files are now placed under /data/dalvik-cache/<isa>/.
- GetDalvikCacheOrDie now requires a mandatory subdirectory argument,
and is implicitly rooted under /data/.
- Added helper methods to convert InstructionSet enums into strings
and vice versa.

Change-Id: I9bff2e2ca534e0b93842a50d5b272ddf6d5745f3
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
6f365cc033654a5a3b45eaa1379d4b5f156b0cee 23-Apr-2014 Mathieu Chartier <mathieuc@google.com> Enable concurrent sweeping for non-concurrent GC.

Refactored the GarbageCollector to let all of the phases be run by
the collector's RunPhases virtual method. This lets the GC decide
which phases should be concurrent and reduces how much baked in GC
logic resides in GarbageCollector.

Enabled concurrent sweeping in the semi space and non concurrent
mark sweep GCs. Changed the semi-space collector to have a swap semi
spaces boolean which can be changed with a setter.

Fixed tests to pass with GSS collector, there was an error related to
the large object space limit.

Before (EvaluateAndApplyChanges):
GSS paused GC time 7.81s/7.81s, score: 3920

After (EvaluateAndApplyChanges):
GSS paused GC time 6.94s/7.71s, score: 3900

Benchmark score doesn't go up since the GC happens in the allocating
thread. There is a slight reduction in pause times experienced by
other threads (0.8s total).

Added options for pre sweeping GC heap verification and pre sweeping
rosalloc verification.

Bug: 14226004
Bug: 14250892
Bug: 14386356

Change-Id: Ib557d0590c1ed82a639d0f0281ba67cf8cae938c
62ab87bb3ff4830def25a1716f6785256c7eebca 28-Apr-2014 Mathieu Chartier <mathieuc@google.com> Always log explicit GC.

People who use DDMS want to see that a GC actually occurs when they
press GC button.

Bug: 14325353
Change-Id: I44e0450c92abf7223d33552ed37f626fe63e1c28
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
3c4a43469046934e76082a4cf1aca14429cd9735 23-Apr-2014 Mathieu Chartier <mathieuc@google.com> Don't allow heap transitions if the runtime is shutting down.

Bug: 14254222
Change-Id: I97ac988a96b56a8dc1eec018bf3ef7a691f04745
bbd695c71e0bf518f582e84524e1cdeb3de3896c 16-Apr-2014 Mathieu Chartier <mathieuc@google.com> Replace ObjectSet with LargeObjectBitmap.

Speeds up large object marking since large objects no longer required
a lock. Changed the GCs to use the heap bitmap for marking objects
which aren't in the fast path. This eliminates the need for a
MarkLargeObject function.

Maps before (10 GC iterations):
Mean partial time: 180ms
Mean sticky time: 151ms

Maps after:
Mean partial time: 161ms
Mean sticky time: 101ms

Note: the GC durations are long due to recent ergonomic changes and
because the fast bulk free hasn't yet been enabled. Over 50% of the
GC time is spent in RosAllocSpace::FreeList.

Bug: 13571028

Change-Id: Id8f94718aeaa13052672ccbae1e8edf77d653f62
2f8da3e9ff60e5cb2a3fdf57dbcb67f513b9c2c2 16-Apr-2014 Mathieu Chartier <mathieuc@google.com> Decrease target utilization for foreground apps.

GC time in FormulaEvaluationActions.EvaluateAndApplyChanges goes from
26.1s to 23.2s. Benchmark score goes down ~50 in
FormulaEvaluationActions.EvaluateAndApplyChanges, and up ~50 in
GenericCalcActions.MemAllocTest.

Bug: 8788501
Change-Id: I412af1205f8b67e70a12237c990231ea62167bc0
dcee9eeaa1d6ad80301c2ca52145259ab83abb2a 15-Apr-2014 Mathieu Chartier <mathieuc@google.com> Less confusing heap transition message.

The heap transition message now just says how long the transition
took and up to how much memory was saved (it can still be negative).

Change-Id: If421dcc2aa9cc40740b858dcc2ff1b8e595f9a40
309e3bfc6a4c682ac09c95c596e11d8678603577 14-Apr-2014 Mathieu Chartier <mathieuc@google.com> Reduce bump pointer space capacity.

Bug: 14058912
Change-Id: I7ae53e667539530d56ca2f5d10214e69c9c994e2
a8e8f9c0a8e259a807d7b99a148d14104c24209d 09-Apr-2014 Mathieu Chartier <mathieuc@google.com> Refactor space bitmap to support different alignments.

Required for:
Using space bitmaps instead of std::set in mod union table +
remembered set.
Using a bitmap instead of set for large object marking.

Bug: 13571028

Change-Id: Id024e9563d4ca4278f79607cdb2f81895121b113
7840888bd9b6accdb32c38563e78a9dc201f1303 12-Apr-2014 Mathieu Chartier <mathieuc@google.com> Fix hammerhead phone boot on master.

Wasn't failing on AOSP.

Change-Id: I8e531bf7493d36dc2667afeaf3133ce8560a2ce1
b272cd3013e046b7b001a091b0925b99a844e382 12-Apr-2014 Mathieu Chartier <mathieuc@google.com> Fix heap verification with SS/GSS.

Since I had removed the SwapSemiSpaces it was trying to verify
references in the from space of the semispace collector, which isn't
necessarily valid.

Bug: 13989162

Change-Id: I8e0b7119a1a53d63f2c71ecdb276290eda5bae07
d20aba14a3cb522e933800a164f7dc10eba21da3 12-Apr-2014 Hiroshi Yamauchi <yamauchi@google.com> Fix an occasional ThreadStress crash.

Also, fix the NativeAllocations test for the case with the GSS
collector as the default GC. Since kGcCauseForAlloc (incorrect) was
being passed into the collector instead of kGcCauseForNativeAlloc
(correct) from Heap::RegisterNativeAllocation(), the GCC collector
never invoked a whole heap collection which was necessary to do
sufficent finalizations to pass the test.

Bug: 13988451
Bug: 11650816
Change-Id: Ib02f061751cd777e0d3bfa81b29e04a874dc58a0
31f441464c0c8f840aba37e236ad133f30308d70 08-Apr-2014 Mathieu Chartier <mathieuc@google.com> Clean-up heap spaces.

We now use the CMS collector instead of the semispace collector when
the phone is booting. We still perform compaction during the zygote
space creation. This reduces time spent in GC by ~2s during boot
and doesn't affect zygote space size.

Changed the space creation logic to create the temp space when a
background transition occurs.

Added a flag to each space which is true if you are allowed to
move objects that are within this space.

Removed SwapSemiSpaces call from the semi space collector, it is now
the job of the caller to do this with threads suspended. This
simplifies the logic in the zygote compaction / heap transition code
since these do not copy from one semispace to another.

Added Space::Clear to RosAllocSpace and DlMallocSpace. This greatly
simplifies the code used for collector transitions.

Time spent in GC creating zygote space:
Before: 3.4s, After: 1.28s
No change in zygote space size.

Bug: 13878055

Change-Id: I700348ab7d5bf3aa537c0cd70c0fed09aa4b0623
b38d483b742eafc7833fac1ebb4fa1481cbac179 10-Apr-2014 Mathieu Chartier <mathieuc@google.com> Fix race condition in TransitionCollector.

There was a race condition where if multiple threads were calling
TransitionCollector it could cause a crash due to an invalid
collector transition if another thread did the collector transition
before the SuspendAll.

Bug: 13929101
Change-Id: I8c162a83c1f53d0cbdefab62b0a5bcbb151d6c42
b6898f55d27d40b60e1a4b0036ae809cc9123cee 09-Apr-2014 Mathieu Chartier <mathieuc@google.com> Add mean GC duration to DumpGcPerformanceInfo.

Change-Id: Ibd68e9d8cae71d0ceb769fc975f1148287e9ca4a
df86d1f8147a95c1ec2f0c5d85e0439ef7d71730 08-Apr-2014 Mathieu Chartier <mathieuc@google.com> Adjust sticky GC ergonomics.

Added an adjustment factor that causes sticky GC to occur more often.
Currently, we adjust the throughput by 5 / 4 comapred to the non
sticky GC. This improves the MemAllocTest score by 50-100. I believe
this happens since the sticky GC uses less memory bandwidth than
partial/full GC. No benchmark score regression on
EvaluateAndApplyChanges though total GC time is increased by ~0.5s.

Bug: 13818507
Change-Id: Ic721a1bff069ddaf8acc55e776b8bc26e171d46e
df386c551405ce9668e827584f744c6f098761fa 09-Apr-2014 Hiroshi Yamauchi <yamauchi@google.com> GSS: Fix the bump pointer space only collection.

Fixes b/13912464 where the clear soft reference behavior accidentally
disabled the bump pointer space only collection.

Changed the collector name so that the GC logs would indicate the
generational mode and the collection mode.

Peformance enhancement: instead of triggering the whole heap
collection every 5 collections, count the bytes promoted since the
last whole heap collection and use it to decide when to trigger the
whole heap collection. This improves MemAllocTest by 5-10% (N4 and
host).

Bug: 13912464
Bug: 11650816
Bug: 9986565
Change-Id: I653a0dca62a8b54adf69abe2940a41eac70f809b
5a48719b516a52d1a6800d8ae6f7dcba3d883bdc 08-Apr-2014 Mathieu Chartier <mathieuc@google.com> Reset GC timings after SIGQUIT.

We now reset the GC timings when a SIGQUIT happens, this is useful
for excluding GCs which happen during the initialization of an app
when measuring GC performance.

Change-Id: I68c79bdb279290c12ae588bc7e95ac24908c157e
440e4ceb310349ee8eb569495bc04d3d7fbe71cb 01-Apr-2014 Mathieu Chartier <mathieuc@google.com> Add monitor deflation.

We now deflate the monitors when we perform a heap trim. This causes
a pause but it shouldn't matter since we should be in a state where
we don't care about pauses. Memory savings are hard to measure.

Fixed integer overflow bug in GetEstimatedLastIterationThroughput.

Bug: 13733906
Change-Id: I4e0e68add02e7f43370b3a5ea763d6fe8a5b212c
da44d773dedf8aae6153e3423012f236cba3bfcd 02-Apr-2014 Mathieu Chartier <mathieuc@google.com> Fix running with DlMalloc instead of RosAlloc.

Bug: 13748830
Bug: 13744490

Change-Id: Ieec97cf58ebf9864a40ee85aae582cdcf3f27c0c
624468cd401cc1ac0dd70c746301e0788a597759 01-Apr-2014 Hiroshi Yamauchi <yamauchi@google.com> Make the support code for read barriers a bit more general.

Add an option for Baker in addition to Brooks.

Bug: 12687968
Change-Id: I8a31db817ff6686c72951b6534f588228e270b11
5ae2c9335a0c4eeaf4c67a52d066f16aad1aa907 29-Mar-2014 Mathieu Chartier <mathieuc@google.com> Fix non concurrent mark sweep ergonomics.

Previously we would continue to do sticky GC until the sticky GC did
not free enough memory for the allocation, this was excessive since it
could do one sticky GC per allocation. The new logic uses the next GC
type before trying all the GCs in the plan.

Before memalloc benchmark (non concurrent mark sweep):
Total time spent in GC: 11.212701s
Score: 7790

After:
Total time spent in GC: 9.422676s
Score: 6870

Change-Id: Iba75b70ea825ef3fd4b3e064d4f12c2fe5a3b176
4aeec176eaf11fe03f342aadcbb79142230270ed 28-Mar-2014 Mathieu Chartier <mathieuc@google.com> Refactor some GC code.

Reduced amount of code in mark sweep / semi space by moving
common logic to garbage_collector.cc. Cleaned up mod union tables
and deleted an unused implementation.

Change-Id: I4bcc6ba41afd96d230cfbaf4d6636f37c52e37ea
d5307ec41c8344be0c32273ec4f574064036187d 28-Mar-2014 Hiroshi Yamauchi <yamauchi@google.com> An empty collector skeleton for a read barrier-based collector.

Bug: 12687968

Change-Id: Ic2a3a7b9943ca64e7f60f4d6ed552a316ea4a6f3
afe4998fc15b8de093d6b282c9782d7182829e36 27-Mar-2014 Mathieu Chartier <mathieuc@google.com> Change sticky GC ergonomics to use GC throughput.

The old sticky ergonomics used partial/full GC when the bytes until
the footprint limit was < min free. This was suboptimal. The new
sticky GC ergonomics do partial/full GC when the throughput
of the current sticky GC iteration is <= mean throughput of the
partial/full GC.

Total GC time on FormulaEvaluationActions.EvaluateAndApplyChanges.
Before: 26.4s
After: 24.8s
No benchmark score change measured.

Bug: 8788501

Change-Id: I90000305e93fd492a8ef5a06ec9620d830eaf90d
0767c9a85a97e0e16c39a63c31de6c543304b0a4 26-Mar-2014 Mathieu Chartier <mathieuc@google.com> Add valgrind support to large object map space.

Added valgrind support to large object map space.

Bug: 7392044
Change-Id: I1456f46414e1fa59ebcc2190ec00576dae26d623
91e3063d97b4dba239682d00ecfb3ea8c0a96539 25-Mar-2014 Mathieu Chartier <mathieuc@google.com> Add GC mode for stressing testing heap transitions.

The stress testing mode does repeated heap transitions when the heap
gets a process state update. In between each transition, the heap
waits for a specified number of time.

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

Bug: 13634574
Change-Id: I2a76f6c43f1d0ad1922f06deb40a71ff651129fd
407f702da4f867c074fc3c8c688b8f8c32279eff 18-Feb-2014 Mathieu Chartier <mathieuc@google.com> Refactor object reference visiting logic.

Refactored the reference visiting logic to be in mirror::Object
instead of MarkSweep.

Change-Id: I773249478dc463d83b465e85c2402320488577c0
0e54cd0d8fc635d3dc8bf88a465fdade151a098f 20-Mar-2014 Mathieu Chartier <mathieuc@google.com> Refactor and optimize GC code.

Fixed the reference cache mod union table, and re-enabled it by
default. Added a boolean flag to count how many null objects,
immune, fast path, slow path objects we marked.

Slight speedup in mark stack processing, large speedup in image mod
union table scanning.
EvaluateAndApplyChanges Before:
Process mark stack time for full GC only:
12.464089s, 12.357870s, 12.538028s
Time spent marking mod image union table ~240ms.
After:
Process mark stack time: 12.299375s, 12.217142s, 12.187076s
Time spent marking mod image union table ~40ms.

TODO: Refactor reference visiting logic into mirror::Object.

Change-Id: I91889ded9d3f2bf127bc0051c1b1ff77e792e94f
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
601276abdb746b03675ff945745aa936694d3439 20-Mar-2014 Mathieu Chartier <mathieuc@google.com> Fix RecordFree to take signed parameters.

RecordFree can get negative bytes allocated when background
compaction foreground transitions occur. This caused a DCHECK to
fail on debug builds. Also did some refactoring in
PreProcessReferences.

Bug: 13568814
Change-Id: I57543f1c78544a94f1d241459698b736dba8cfa8
3e41780cb3bcade3b724908e00443a9caf6977ef 20-Mar-2014 Hiroshi Yamauchi <yamauchi@google.com> Refactor the garbage collector driver (GarbageCollector::Run).

Bug: 12687968

Change-Id: Ifc9ee86249f7938f51495ea1498cf0f7853a27e8
1ad2784ad9f311ebf9fe0677d33818648f423f9c 20-Mar-2014 Mathieu Chartier <mathieuc@google.com> Add soft reference pre processing.

Soft reference pre-processing does soft reference preservation with
mutators running. After this is done, it does another pass with
mutators paused in the ProcessReference code. This helps lower pauses
since most preserved soft references have their referents recursive
marked outside the pause.

Changed ergonomics to have non sticky collectors always clear the
soft references.

Maps pauses ~10ms -> ~3ms on Nexus 4.

Bug: 13421927

Change-Id: I1370f7bb6934034869aa5afca0c377876267aa8e
38e68e9978236db87c9008bbe47db80525d2fa16 07-Mar-2014 Hiroshi Yamauchi <yamauchi@google.com> Use the card table to speed up the GSS collector.

Scan only dirty cards, as opposed to the whole space, to find
references from the non-moving spaces to the bump pointer spaces at
bump pointer space only collections.

With this change, the Ritz MemAllocTest speeds up by 8-10% on host and
2-3% on N4. The Ritz EvaluateFibonacci speeds up by 8% and its average
pause time is reduced by 43% on N4.

Bug: 11650816
Change-Id: I1eefe75776bc37e24673b301ffa65a25f9bd4cde
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
8fa2dad7fe7909c8335101d6c8904ae997cdf29f 13-Mar-2014 Mathieu Chartier <mathieuc@google.com> Refactor reference code into mirror namespace.

Added two new files: mirror/reference.h and mirror/reference-inl.h.

Change-Id: Ibe3ff6379aef7096ff130594535b7f7c0b7dabce
7bf52d28978a6a747795cc0c78b04a3e83f0cf16 13-Mar-2014 Mathieu Chartier <mathieuc@google.com> Fix heap trimming logic.

The new heap trimming logic introduced in the c/84301 was not very
good since the heap trim would get avoided since the daemon thread
was coming to the heap trimming code before the scheduled time.

The new logic is to do the heap trim if the last heap trim occurred
more than kHeapTrimWait ns ago.

Change-Id: I9d0e6766bf0c68e5f7fb15fb059140e1f1264216
5ccd498d4aa450b0381344724b072a932709a59a 11-Mar-2014 Hiroshi Yamauchi <yamauchi@google.com> Put the post zygote non-moving space next to the malloc space.

This change fixes the following problem with the GSS collector: if the
post zygote non-moving space happens to be located after the bump
pointer spaces, the bump pointer space is treated wrongfully as an
immune space. The reasons are 1) the immune space is represented by a
simple address range and 2) the GSS collector treats the post zygote
non-moving space as an immune space at a bump pointer space only
collection.

In addition, this change makes it a reality that all the non-moving
spaces are adjacent, which we tend to assume in the code (eg. the
notion of the immune space represented by a simple address range.)
This should help avoid potential confusions in the future.

Fix a DCHECK failure where usable_size isn't set properly when
-XX:UseTLAB is used.

Change-Id: I585920e433744a390f87e9a25bef6114b2a4623f
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
a5f9de040a7a740b7b4979bc8d47f95eb05718ae 01-Mar-2014 Mathieu Chartier <mathieuc@google.com> Defer heap transitions to heap trimming daemon.

This fixes the case where quick back and forth process state changes
would cause a lot of heap transitions.

Change-Id: Ia5be792edcf26079b2aa23b9c115f6b0a9a39a1c
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
661974a5561e5ccdfbac8cb5d8df8b7e6f3483b8 09-Jan-2014 Mathieu Chartier <mathieuc@google.com> Fix valgrind gtests and memory leaks.

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

Change-Id: Ifd6b6e3aed0bc867703b6e818353a9f296609422
893263b7d5bc2ca43a91ecb8071867f5134fc60a 04-Mar-2014 Mathieu Chartier <mathieuc@google.com> Avoid marking old class linker and intern table roots during pause.

The new root visiting logic has a concept of a root log which holds
new roots which were added since the start of the GC. This is an
optimization since it lets us only mark these newly added roots
during the pause (or pre-cleaning) since the other roots intern table
and class linker roots were marked concurrently at the start of the
GC.

Before (EvaluateAndApplyChanges):
MarkConcurrentRoots: Sum: 605.193ms
After:
MarkConcurrentRoots: Sum: 271.858ms

This should also reduce pathological GC pauses which used to be able
to happen when the intern table or class linker became "dirty"
during the concurrent GC.

Change-Id: I433fab021f2c339d50c35aaae7161a50a0901dec
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
c2f4d0240b3a9b905dff5b546924865f15241481 04-Mar-2014 Mathieu Chartier <mathieuc@google.com> Fix SafePrettyTypeOf to never call VerifyObject.

Calling VerifyObject from the segfault handler caused another
segfault.

Change-Id: I459646594d830cbb110a4ac2bac25a7b90794854
15d3402bbf8265eb1165694da2e4117eb128f3bc 27-Feb-2014 Mathieu Chartier <mathieuc@google.com> Add custom SIGSEGV handler to help find heap corruption.

The new signal handler prints heap diagnostics when you get a SIGSEGV.
Added a fault message member in runtime which is modifiable by
Runtime::SetFaultMessage. When you get a SIGSEGV it will print out
whatever is stored in this string as well as the normal information.
This is useful for debugging heap corruption since it lets you see
which threads were in which methods when the last GC occured.

Added some smarter object dumping logic when the faulting address is
in the heap.

Bug: 12934910

Change-Id: Ia72be2c39f70ad711cbd746d66fad2b617d5d29f
bd0a65339a08dc28c6b56d2673f1f13b6bddd7aa 27-Feb-2014 Mathieu Chartier <mathieuc@google.com> Enable large object space for command line runs.

Added a dynamic large_object_threshold_ variable which is max int
when the large object space is disabled.

No longer clear timing logger timings after zygote creation since
it is not required and removes the boot semispace timings.

Change-Id: I693865f4699cc32381199377239854c6ec42f37e
6fac447555dc94a935b78198479cce645c837b89 26-Feb-2014 Ian Rogers <irogers@google.com> Make allocations report usable size.

Work-in-progress to allow arrays to fill usable size. Bug: 13028925.
Use C++11's override keyword on GCC >= 2.7 to ensure that we override GC and
allocator methods.
Move initial mirror::Class set up into a Functor so that all allocated objects
have non-zero sizes. Use this property to assert that all objects are never
larger than their usable size.
Other bits of GC related clean-up, missing initialization, missing use of
const, hot methods in .cc files, "unimplemented" functions that fail at
runtime in header files, reducing header file includes, move valgrind's space
into its own files, reduce number of array allocation routines.

Change-Id: Id5760041a2d7f94dcaf17ec760f6095ec75dadaa
9d04a20bde1b1855cefc64aebc1a44e253b1a13b 31-Jan-2014 Hiroshi Yamauchi <yamauchi@google.com> (Experimental) Add Brooks pointers.

This feature is disabled by default.

Verified that the Brooks pointers are installed correctly by using the
CMS/SS collectors.

Change-Id: Ia9be9814ab6e29169ac85edc4792ce8c81d552a9
c22c59ef8513b4cbbfd25073d1afbf58196b522a 25-Feb-2014 Mathieu Chartier <mathieuc@google.com> Remove started runtime check in RevokeAllThreadLocalAllocationStacks

This check occasionally caused some thread local allocation stacks
to incorrectly not get revoked when multiple threads were allocating
without a started runtime. This showed up in image_test with
compaction enabled when we were initializing classes in the compiler
driver.

Change-Id: I7f28d072feea333c2503e35265ba25c51a6308fe
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
3bb57c7b41bf5419fe895e7aa664d8d430205ba8 18-Feb-2014 Mathieu Chartier <mathieuc@google.com> Change ProcessReferences to not use RecursiveMarkObject.

Calling ProcessMarkStack in RecursiveMarkObject caused a lot of
overhead due to timing logger splits. Changed the logic to be the
same as prior to the reference queue refactoring which involves
calling process mark stack after preserving soft references and
enqueueing finalizer references.

FinalizingGC longest pause is reduced by around 1/2 down to ~300ms.
Benchmark score ~400000 -> ~600000.

Also changed the timing logger splits in the GC to have (Paused) if
the split is a paused part of the GC.

Bug: 12129382

Change-Id: I7476d4f23670b19d70738e2fd48e37ec2f57e9f4
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
1ed9061e5912ebea7d4639ee2926d273300606a1 15-Feb-2014 Hiroshi Yamauchi <yamauchi@google.com> Fix preverify.

The thread-local allocation stack change:

https://android-review.googlesource.com/82056

broke preverify. This change fixes it.

Change-Id: I2625e47d48d0fd48dff6c9210be6ebffe7a5f233
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
be77b7a77e5a6391f9ad128ad302bae266c0730e 13-Feb-2014 Mathieu Chartier <mathieuc@google.com> Merge "Prevent object allocation related races in VisitObjects."
ebdf3f320d71563cf0236c31d35d633be9576d8c 13-Feb-2014 Mathieu Chartier <mathieuc@google.com> Prevent object allocation related races in VisitObjects.

Prevents the following race conditions:
Someone is in the process of pushing a reference in the allocation
stack but hasn't yet written the reference. This caused VisitObjects
to occasionally send null objects to the visitor.
Fixed another race where the object had just been allocated but the
class had not been written. We now skip objects in the allocation
stack which have a null class.

Bug: 13004631
Change-Id: Iad789c5e277a7717ce595c7124f0d65b44392fd8
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
d68ac700820f3e4253c8b4bcf718daf452f6da4c 11-Feb-2014 Mathieu Chartier <mathieuc@google.com> Add more checking to ReleasePrimitiveArray.

When we ReleasePrimitiveArray, we now check that the elements pointer
is not a heap address if it is not equal to the java array's data.

Bug: 12845603
Change-Id: I458862f4dc586ba1c414647c7eb81b978c4ccb7e
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
412c7fced915fc8d4d5e4166e977d55c809168a6 07-Feb-2014 Mathieu Chartier <mathieuc@google.com> Make debugger / jdwp compaction safe.

Fixed GetInstances, GetReferringObjects, CountInstances to use
VisitObjects instead of the live bitmap.

We now treat the object registry as system weaks and update the
objects when/if they move. Also added the recent_allocation_records_
as roots.

Bug: 12936165

Change-Id: I615c289efbf2977ceab5c4ffa73d216d799e6e33
a4adbfd44032d70e166e6f18096bbbed05a990ba 05-Feb-2014 Hiroshi Yamauchi <yamauchi@google.com> RosAlloc verification.

If enabled, RosAlloc verification checks the allocator internal
metadata and invariants to detect bugs, heap corruptions, and race
conditions. Added runtime options for enabling and disabling
it. Enable it for the debug build.

Bug: 9986565
Bug: 12592026
Change-Id: I923742b87805ae839f1549d78d0d492733da6a58
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
1f3b5358b28a83f0929bdd8ce738f06908677fb7 03-Feb-2014 Mathieu Chartier <mathieuc@google.com> Move SwapBitmaps to ContinuousMemMapAllocSpace.

Moved the SwapBitmaps function to ContinuousMemMapAllocSpace since
the zygote space uses this function during full GC.

Fixed a place where we were casting a ZygoteSpace to a MallocSpace,
somehow this didn't cause any issues in non-debug builds.

Moved the CollectGarbage in PreZygoteFork before the lock to prevent
an occasional lock level violation caused by attempting to enqueue
java lang references with the a lock.

Bug: 12876255

Change-Id: I77439e46d5b26b37724bdcee3a0948410f1b0eb4
caa82d61b73d2d426ac1666e9186d7825000a849 03-Feb-2014 Mathieu Chartier <mathieuc@google.com> Fix lock order checking violation.

Turns out you can't do thread state changes while holding locks.
This change fixes occasional lock violations in ThreadStress test.

Also moved the usleep in TransitionCollector outside of the place we
hold the gc_complete_lock_.

Change-Id: Ib3a85fffdbea80b64d72a2ad7e916251340c22e6
d5a89ee74c00bd24a34b6e795828a0b86842630f 31-Jan-2014 Mathieu Chartier <mathieuc@google.com> Fix race conditions caused by StartGC.

Race1: Heap trimming could happen when we were transitioning the heap.
This caused the space to get deleted in the middle of the trim.

Race2: IncrementDisableCompactingGC needed to WaitForConcurrentGC if
we were running a moving GC or about to starting a moving GC.

Race3: The logic for whether or not we had a compacting GC was
calculated before StartGC in CollectGarbageInternal. This could cause
us to get blocked waiting for the GC to complete and come out of the
wait with a new collector_type_ due to a heap transition.

Change-Id: I07c36ae5df1820e9cca70cf239e46175c1eb9575
a1602f28c0e3127ad511712d4b08db89737ae901 14-Jan-2014 Mathieu Chartier <mathieuc@google.com> Add zygote space as its own space type.

Helps prevent errors caused from doing invalid operations on the
old alloc space.

Removed some duplicated code in mark_sweep.cc and semi_space.cc.

Change-Id: I67a772cab30d698744c918aad581053f282a4a99
1d27b34d3b18a5a0c832dae9768366dc08ef8d1c 28-Jan-2014 Mathieu Chartier <mathieuc@google.com> Change DisableGC to DisableMovingGC.

Also removed the WaitForConcurrentGC in IncrementDisableMovingGC
since we do not currently support any type of concurrent moving
collectors.

This fixes the performance regression introduced by waiting for the
concurrent GC which manifested itself in framework perf benchmarks
as a result of background compaction.

Change-Id: I524f9ab52e1992419626a27649f232ca6967b03d
9be9a7a344096e040f2edfbdf8e479634058a2d7 24-Jan-2014 Mathieu Chartier <mathieuc@google.com> Improve IsMovableObject logic.

The new logic says the main space is non movable iff neither the
background collector or foreground collector are compacting.
Temporarily fixes performance regressions and stability issues
caused by buggy JNI code.

Also addressed a few review comments from previous CLs.

Change-Id: Id5f91765b5fbdae387b566c0bda3392557218ba1
7476280b20d0b5addf9e4a2ce84d1eee36c76c1e 24-Jan-2014 Mathieu Chartier <mathieuc@google.com> Change GC ergonomics to better handle heap verification.

Added a new constant kMaxConcurrentRemainingBytes which put a lower
bound on the background GC watermark. This fixes a performance issue
caused by heap verification being really slow and making it that we
were excessively scheduling back to back GCs.

Greatly increases system/test performance when heap verification is
enabled.

Change-Id: I68fa5a247c42f6c661e313c49dd3ca6be29951d4
938a03b3f196895e1fce2b862ae01039deca4c34 17-Jan-2014 Mathieu Chartier <mathieuc@google.com> Fix heap verification and add runtime options.

Post GC heap verification is now enabled by default for debug builds.
Added four Xgc runtime options: preverify, nopreverify, postverify,
nopostverify.

Fixed another bug where the non-moving space could theoretically end
up outside of the card table address range.

Bug: 10672951
Change-Id: I5ba3cd96dbfb900263dba795242df74c563deaa3
6f4ffe41649f1e6381e8cda087ad3749206806e5 13-Jan-2014 Hiroshi Yamauchi <yamauchi@google.com> Improve the generational mode.

- Turn the compile-time flags for generational mode into a command
line flag.

- In the generational mode, always collect the whole heap, as opposed
to the bump pointer space only, if a collection is an explicit,
native allocation-triggered or last attempt one.

Change-Id: I7a14a707cc47e6e3aa4a3292db62533409f17563
e01b5406a93293f5abf6a61d4fec34f2becd47ca 13-Jan-2014 Mathieu Chartier <mathieuc@google.com> Remove zygote space from alloc_spaces_ array.

Not removing this space was causing a crash in
Heap::GetObjectsAllocated since the new zygote bin packing places
objects where the normal DlMalloc/RosAlloc accounting would be.

Going to refactor zygote spaces to be a new space type in the near
future to avoid more of these types of issues.

Bug: 12490061

Change-Id: Id4f75d0315c63e0e8c19f6fba9ad9cb2ba9017e5
05e713a3a009a0825826ce6d494582fcd6dd6a8d 09-Jan-2014 Hiroshi Yamauchi <yamauchi@google.com> Bump pointer space only collection.

Add a mode of collection that collects only the bump pointer spaces,
as opposed to the whole heap. It's disabled behind a flag.

TODO: It still scans the entire non-moving space to look for
inter-space references. Use a card table like technique to limit the
scope of scanning and speed it up.

Bug: 11650816
Change-Id: I56cb11e78e47a578bff644e6e6c63d978cfedf39
db7f37d57b6ac83abe6815d0cd5c50701b6be821 10-Jan-2014 Mathieu Chartier <mathieuc@google.com> Refactor large object sweeping.

Moved basic sweeping logic into large_object_space.cc.
Renamed SpaceSetMap -> ObjectSet.

Change-Id: I938c1f29f69b0682350347da2bd5de021c0e0224
5dc08a680696554ffc76d58dd591b23e79f5b5a1 10-Jan-2014 Mathieu Chartier <mathieuc@google.com> Fix ART debug build boot.

Some of the checks were no longer valid after the zygote bin packing.

Bug: 12480317
Change-Id: Iaa169b0aafe9fec06e75e9b58a3de28aa70a9421
a4b95a2793c9840ae5e273e4499d8765438e4a2d 10-Jan-2014 Mathieu Chartier <mathieuc@google.com> Fix RemoveSpace memory leak.

RemoveSpace now deletes the input space. This fixes a memory leak
related to background compaction.

Change-Id: I7123297adb475b1045f7d1a42d595c53daad0faa
fc5b528fc46ccff655cfb3578847350f74064e8d 10-Jan-2014 Mathieu Chartier <mathieuc@google.com> Fix IsMovableObject to handle background compaction.

Before we assumed that only the bump pointer space contained
movable objects. This is incorrect since the background compaction
foreground -> background transition copies objects from the
RosAlloc / DlMalloc space (now called main space) to the bump pointer
space.

Bug: 8981901

Change-Id: Ie7bb9a5d82012988573e944ede2f6a8a77d8872f
85a43c055fcdc366293c61df6f65e586d6967841 08-Jan-2014 Mathieu Chartier <mathieuc@google.com> Bin packing the zygote (best fit).

We now use bin packing to fill holes in the non movable space with
objects from the bump pointer space when we create the zygote.

Zygote space PSS reduction on AOSP: ~300k.
Zygote size on AOSP: 2121040 bytes -> 1597944 bytes.

Deleted some unreachable code.

Bug: 11902311

Change-Id: Idc957d69e93b3a941e0c298d47a21b73526dd286
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
b122a4bbed34ab22b4c1541ee25e5cf22f12a926 20-Nov-2013 Ian Rogers <irogers@google.com> Tidy up memory barriers.

Change-Id: I937ea93e6df1835ecfe2d4bb7d84c24fe7fc097b
573f7d2d68e1838a0485e6b40d90c967526e00c2 17-Dec-2013 Hiroshi Yamauchi <yamauchi@google.com> Fix an array copy benchmark regression.

Add different page release modes to rosalloc.

Bug: 12064551
Change-Id: Ib837bbd1a2757741a4e2743e0a1272bf46a30252
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
7bf82af01ec250a4ed2cee03a0e51d179fa820f9 07-Dec-2013 Mathieu Chartier <mathieuc@google.com> Fix memory usage regression and clean up collector changing code.

Memory usage regressed since we didn't properly update
concurrent_start_bytes_ when changing collectors.

Bug: 12034247

Change-Id: I1c69e71cd2919e0d3bf75485a4ac0b0aeca59278
ca2a24da53869a04e1947aa46d06ccce5247d6f4 26-Nov-2013 Mathieu Chartier <mathieuc@google.com> Add interface for updating process state.

Called from activity manager to let the heap know when it should
perform compaction and trimming.
Bug: 8981901

Change-Id: Ib8ea48d2dc9d6901c3f2e0554391721d6691e726
7410f29b4dae223befac036ea567d7f33351dad1 24-Nov-2013 Mathieu Chartier <mathieuc@google.com> Fix dumpsys meminfo <pid>.

Added a case for BumpPointerSpaces. Confirmed working non-debug.
Should also work in debug builds.

Bug: 11830794
Change-Id: I12053ff16eec403dcd4a780e13095e3212a77132
0de9f73afe3e835b63f2ee0c1416930656449f3f 23-Nov-2013 Mathieu Chartier <mathieuc@google.com> Add -xGc: MS, CMS, SS options to specify which GC to use.

Can be used for running tests or benchmarks with semispace,
marksweep or concurrent marksweep.

Change-Id: Ic9ab1220150f2c7c9c30df4ffee45b9d303094b3
2e899a92439dc6bdaaa67b8230933006284aa600 23-Nov-2013 Hiroshi Yamauchi <yamauchi@google.com> Fix a crash with -XX:DumpGCPerformanceOnShutdown.

DumpGcPerformanceInfo() could call RosAllocSpace::InspectAllRosAlloc()
which needs the thread list to be still alive. Fix by moving the
DumpGcPerformanceInfo() call from the Heap destructor up to the
beginning of the Runtime destructor so that the thread list is still
alive when it's called.

Bug: 11830901
Change-Id: Ib094d60916943c8cb1d4b769d805b4ca03269f90
ff3b24aa929a9db79daeef7c0b0522da099700a9 23-Nov-2013 Mathieu Chartier <mathieuc@google.com> Add developer option for dumping GC cumulative timings on shutdown.

The option is "-XX:DumpGCPerformanceOnShutdown".
Bug: 9986416

Change-Id: If6ebb26b3e611a9dead197740dbfc64e548dc388
50482234bed852766498321f71d2ff5e46e4fec2 21-Nov-2013 Mathieu Chartier <mathieuc@google.com> Compact zygote.

We now start out using the bump pointer allocator and switch to
the free list collector (ROSAlloc) after the zygote forks.

Before compaction:
Zygote size: 9060352

After compaction
Zygote size: 8425864

The main reason the size doesn't reduce more is that most of the
zygote space is non-movable objects allocated by
VMRuntime.newNonMovableObject. The objects which are non-movable
but could be movable include around 10000 classes and some number
of fields and methods.

Bug: 8981901

Change-Id: Iea21b70fb7af27cb7e92d72070d278a5cd4026ac
f9ed0d38c596d22c57d57e6111819bbb09e7d0fb 22-Nov-2013 Mathieu Chartier <mathieuc@google.com> Fix concurrent GC to properly handle no zygote.

I had introduced a regression in
https://googleplex-android-review.googlesource.com/#/c/389851/
which caused concurrent GC to not get run if there was no zygote.
This caused a regression in ritzperf when run from the commmand
line. The fix properly handles the no zygote case by doing full
GC instead.

Bug: 11811477
Change-Id: Ib42b914509b951054895fea8741f6c68cdada52a
b2f9936cab87a187f078187c22d9b29d4a188a62 21-Nov-2013 Mathieu Chartier <mathieuc@google.com> Add histogram for GC pause times.

Printed when you dump the GC performance info.

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

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

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

Rosalloc measurements:
4583
4453
4439
4434
4751

After change:
4184
4287
4131
4335
4097

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

Bug: 9986565
Change-Id: I0eb73b9458752113f519483616536d219d5f798b
39e3261168e7761fea6d873494d7c5d191285791 13-Nov-2013 Mathieu Chartier <mathieuc@google.com> Refactor reference queues.

Refactored the reference queue processing to reside in the heap code.
This removes significant code duplication in the semispace and
marksweep garbage collectors.

Changed the soft reference behaviour to preserve all soft references
unless the GC requires them to be cleared to avoid an out of memory
error. It may be worth investigating a better heuristic in the
future to preserve soft references by LRU order.

Change-Id: I1f3ff5bd4b3c5149271f4bb4fc94ba199e2f9bc2
5fe9af720048673e62ee29597a30bb9e54c903c5 14-Nov-2013 Ian Rogers <irogers@google.com> Fix memory leaks relating to timing logger.

Bug: 11670287.
We use pointers to uninitialized values for control-flow in the timing logger
code, add TODO comments to clean this up later.
Remove base namespace and other bits of tidying.

Change-Id: I1e6600a1e92f974c8f58f3a405a4e4abb4d9f80f
bcd5e9daecad39f0dab3246808b4835caec29ea6 13-Nov-2013 Mathieu Chartier <mathieuc@google.com> Manually manage thread pool stacks.

We now allocate the thread pool worker stack using a MemMap. This
enables us to name the maps so that we get more descriptive output
for debugging leaks.

Appears to fix the mips build 5/5 successful clean-oat and builds.
This is probably since glibc caches up to 40 MB of thread stacks
before releasing them.

Change-Id: I1df2de50cb95838aa0d272a09807021404ba410c
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
fa82427c68b09f4aedbee319dc71579afbfc66f5 06-Nov-2013 Ian Rogers <irogers@google.com> Fix oatdump and valgrind.

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

Change-Id: I8ea848ace318552c180e2efa46570288ff1ca62c
8d31bbd3d6536de12bc20e3d29cfe03fe848f9da 13-Oct-2013 Ian Rogers <irogers@google.com> Throw IOException at source of failing to open a dex file.

Before is:
java.lang.ClassNotFoundException: Didn't find class "GCBench" on path: DexPathList[[zip file "/disk2/dalvik-dev/out/host/linux-x86/framework/GCBench.jar"],nativeLibraryDirectories=[/disk2/dalvik-dev/out/host/linux-x86/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
Suppressed: java.lang.ClassNotFoundException: GCBench
at java.lang.Class.classForName(Native Method)
at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
... 1 more
Caused by: java.lang.NoClassDefFoundError: Class "LGCBench;" not found
... 5 more
And after is:
java.lang.ClassNotFoundException: Didn't find class "GCBench" on path: DexPathList[[zip file "/disk2/dalvik-dev/out/host/linux-x86/framework/GCBench.jar"],nativeLibraryDirectories=[/disk2/dalvik-dev/out/host/linux-x86/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
Suppressed: java.io.IOException: Zip archive '/disk2/dalvik-dev/out/host/linux-x86/framework/GCBench.jar' doesn't contain classes.dex
at dalvik.system.DexFile.openDexFile(Native Method)
at dalvik.system.DexFile.<init>(DexFile.java:80)
at dalvik.system.DexFile.<init>(DexFile.java:59)
at dalvik.system.DexPathList.loadDexFile(DexPathList.java:268)
at dalvik.system.DexPathList.makeDexElements(DexPathList.java:235)
at dalvik.system.DexPathList.<init>(DexPathList.java:113)
at dalvik.system.BaseDexClassLoader.<init>(BaseDexClassLoader.java:48)
at dalvik.system.PathClassLoader.<init>(PathClassLoader.java:38)
at java.lang.ClassLoader.createSystemClassLoader(ClassLoader.java:128)
at java.lang.ClassLoader.access$000(ClassLoader.java:65)
at java.lang.ClassLoader$SystemClassLoader.<clinit>(ClassLoader.java:81)
at java.lang.ClassLoader.getSystemClassLoader(ClassLoader.java:137)
Suppressed: java.lang.ClassNotFoundException: GCBench
at java.lang.Class.classForName(Native Method)
at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
... 1 more
Caused by: java.lang.NoClassDefFoundError: Class "LGCBench;" not found
... 5 more

Also, move dex file verifier messages out of logs.
In the process the ClassLinker::dex_lock_ needed tidying to cover a smaller
scope. Bug 11301553.

Change-Id: I80058652e11e7ea63457cc01a0cb48afe1c15543
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
be031fff278799984166ec866c2dd202447e0f23 09-Oct-2013 Hiroshi Yamauchi <yamauchi@google.com> Remove four counter increments out of the allocation path.

- This change removes the four allocation counters (the number of
bytes allocated, the number of objects allocated, the number of bytes
allocated ever, the number of objects allocated ever) from the
dlmalloc space allocation path. Now those counter values are computed
on the fly based on a combination of the two new counters that are
incremented by the GC side (the number of bytes freed ever and the
number of objects freed ever) and mspace_inspect_all() calls.

- This results in a 1-2% speedup (though with some noise) in Ritz
MemAllocTest on Nexus 4.

Bug: 9986565
Change-Id: Id9a8e05a745ac1e5ea7a2b5fd9319814a9d4af13
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
11409ae81a3eaf84d7fd2b3c85b8b06d2bae27f0 23-Sep-2013 Mathieu Chartier <mathieuc@google.com> Refactor and improve mod-union tables.

Allow support for adding more mod union tables, reduces the amount
of baked in logic. Adds support for updating mod union table references
from compaction (not for ReferenceCache table yet).

Change-Id: I1beeda00839ed86ef0e853beff5ce10d0ab2b9d1
fc0e94bed3f88ed7e50854fd8dfaf5dcb345250f 24-Sep-2013 Ian Rogers <irogers@google.com> StringPiece clean up.

Profile guided clean up.
Try to avoid creating StringPieces with the contents of a dex file where
the length is known.
Try to avoid RegTypeCache::FromDescriptor when there's a class available.
Make ConstantType::ConstantValue inlinable.
Saving of about 50ms from a 2 threaded ThinkFree compile on host.

Change-Id: I47a12c3c76f46e2c9805be1c3a3e3870fe1f5d85
0f72e4136aecaf6976fdb55916bbd7b6d5c9c77b 07-Sep-2013 Mathieu Chartier <mathieuc@google.com> Improve heap verification.

Re-enabled checking the allocation stack for heap verification.

Added tracking of recent frees in DlMallocSpace if debug spaces is
enabled. This is useful when you have heap corruption caused by a
live object referencing a recently freed object.

Added various other sanity checks in the GC.

Bug: 10626133

Change-Id: I5ada11966336ae9a06615b16f4b933f05b5d0c32
b4ea4de2d6b63a3855968f2748878018a27af106 18-Sep-2013 Mathieu Chartier <mathieuc@google.com> Fix soft reference clearing issue.

There was a bug where we would check that the pending next field was
non null before enqueueing up cleared references. This was causing
references to not get queued up during ProcessReferences.

Bug: 10626133

Change-Id: Ic1e00e42045092280b4abb3d41f1c58f7adbc3de
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
31e8925781c2302f1d1a9b39e216ba415bfe0d7e 28-Aug-2013 Mathieu Chartier <mathieuc@google.com> Write out image bitmap inside of image file.

We now create the image bitmap when we generate the image. The image
bitmap is written after the image inside of the image file. This
speeds up dex2oat by making walking the image during heap creation
unnecessary. This should also help memory pressure by enabling the
image bitmap to be swappable.

Bug: 10432288

Change-Id: Idebf459ed15edbb41a7d9b9b353934155bce2f19
2775ee4f82dff260663ca16adddc0b15327aaa42 21-Aug-2013 Mathieu Chartier <mathieuc@google.com> Add more runtime options.

Changed HeapGCThreads to be split into two different options:
-XX:ParallelGCThreads: Which specifies how many threads the GC may
use when the mutators are suspended.

-XX:ConcGCThreads: Which specifies how many threads the GC may use
when the mutators are running.

Added runtime options to specify long pause / long GC thresholds:
-XX:LongPauseThreshold (default 5ms)
-XX:LongGCThreshold (default 100ms)
These thresholds were previously constants, but are now runtime
options. If we exceed either of the thresholds, we print the GC
message.

Added a new runtime option: -XX:IgnoreMaxFootprint which makes it
that the GC only does GC when the number of bytes allocated hits
the growth limit. This causes GC to occur much less frequently and
can be useful to measure how much of an impact GC has on performance.

Changed the GC behaviour to use only one thread when we do not care
about pauses to prevent jank that can be caused by 2 simultaneous GC
on different processes fighting for CPU time.

Added thread pool functionality for changing the maximum number of
active workers.

Fixed an accounting error where we didn't count large objects in the
total freed.

Bug: 9986416

Change-Id: I86afa358d93dcd3780e18ac5d85bdb1a130cb7e7
e53225c7b8c98f8fc3855fc70f718e7f8abab307 19-Aug-2013 Mathieu Chartier <mathieuc@google.com> Print information about large objects freed and AllocSpace objects.

When we print information about the GC, we now print how many
AllocSpace and LOS objects were freed along with their corresponding
total sizes.

Fixed a disabled timing longer which I had accidentally done in
another CL.

Change-Id: I6cf958ec553bdbb365f242b3844461acec801078
720ef7680573c1afd12f99f02eee3045daee5168 17-Aug-2013 Mathieu Chartier <mathieuc@google.com> Fix non concurrent GC ergonomics.

If we dont have concurrent GC enabled, we need to force GC for alloc
when we hit the maximum allowed footprint so that our heap doesn't
keep growing until it hits the growth limit.

Refactored a bit of stuff.

Change-Id: I8eceac4ef01e969fd286ebde3a735a09d0a6dfc1
94c32c5f01c7d44781317bf23933ed0a5bc4b796 09-Aug-2013 Mathieu Chartier <mathieuc@google.com> More parallel GC, rewritten parallel mark stack processing.

Card scanning may now be done in parallel. This speeds up sticky and
reduces pause times for all GC types.

Speedup on my mako (ritz perf):
Average pause time for sticky GC (~250 samples):
Without parallel cards scanning enabled: 2.524904215ms
Parallel card scanning (num_gc_threads_): 1.552123552ms
Throughput (~250 samples):
Sticky GC throughput with parallel card scanning: 69MB/s
Sticky GC throughput without parallel card scanning: 51MB/s

Rewrote the mark stack processing to be LIFO and use a prefetch queue
like the non parallel version.

Cleaned up some of the logcat printing for the activity manager
process state listening.

Added unlikely hints to object scanning since arrays and classes are
scanned much less often than normal objects.

Fixed a bug where the number of GC threads was clamped to 1 due to a
bool instead of a size_t.

Fixed a race condition when we added references to the reference
queues. Sharded the reference queue lock into one lock for each reference
type (weak, soft, phatom, finalizer).

Changed timing splits to be different for processing gray objects with
and without mutators paused since sticky GC does both.

Mask out the class bit when visiting fields as an optimization, this is
valid since classes are held live by the class linker.

Partially completed: Parallel recursive mark + finger.

Bug: 10245302
Bug: 9969166
Bug: 9986532
Bug: 9961698

Change-Id: I142d09718c4609b7c2387cb28f517a6983c73288
02e25119b15a6f619f17db99f5d05124a5807ff3 15-Aug-2013 Mathieu Chartier <mathieuc@google.com> Fix up TODO: c++0x, update cpplint.

Needed to update cpplint to handle const auto.

Fixed a few cpplint errors that were being missed before.

Replaced most of the TODO c++0x with ranged based loops. Loops which
do not have a descriptive container name have a concrete type instead
of auto.

Change-Id: Id7cc0f27030f56057c544e94277300b3f298c9c5
ba041a59071036d5c78b70a372739e90cf6fe6d4 16-Aug-2013 Anwar Ghuloum <anwarg@google.com> Log long GC pause only when the process cares about pause time

Change-Id: Iffdb83dff43020c3477b5391deb04102e00eb61e
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
67f99418f648c3a95256ed3dcd8e8b64eef0b372 12-Aug-2013 Anwar Ghuloum <anwarg@google.com> Yet more timing logger cleanup

Some cleanup of timing logger placement, additional systrace placement for
threaded compilation work, tweaking/hiding of some type names per previous
review comments.

Change-Id: Ic7db2e02747282ac7f474b9a060df9803bfdfa5e
f981da1d60864a730f744ef2cc3a19391c8303f2 08-Aug-2013 Mathieu Chartier <mathieuc@google.com> Use JNI to access activity manager process state.

After a GC occurs, we use JNI to access activity manager process
state to decide whether or not we will trim.

Change-Id: Iad981e3a7cdc694729d8792cc0f19e0262154388
(cherry picked from commit c39e342317d77e701b4cd01cd5b05902e6512f4b)
4446ab9e70dde779d97f451c4904f6b8770232bd 10-Aug-2013 Anwar Ghuloum <anwarg@google.com> Systrace fixups and refactoring for TimingLogger

Fixed systrace bounds for timing logger in GC. Refactored CumulativeLogger a bit to
allow for multiple identical entries. Added ScopedSplit, now composes with explicit
start/end/new splits. Adds some unit tests.
Bug: 10036801

Change-Id: If0afb88b48ec3a1e19462ed354babb274a9517a7
c39e342317d77e701b4cd01cd5b05902e6512f4b 08-Aug-2013 Mathieu Chartier <mathieuc@google.com> Use JNI to access activity manager process state.

After a GC occurs, we use JNI to access activity manager process
state to decide whether or not we will trim.

Change-Id: Iad981e3a7cdc694729d8792cc0f19e0262154388
eb5710eba75bf338da56386ca29039df9d5134cb 26-Jul-2013 Mathieu Chartier <mathieuc@google.com> New free list large object space.

More memory efficient, uses a std::set instead of multiset. Each
large object allocation has sizeof(size_t) * 2 bytes of overhead
without taking into account the std::set overhead. If debug is
enabled, then objects are mprotected as they are freed.

Added a large object test to space test.

Change-Id: I3e714e1afbed49208a4a7e60f9ef7d701a56801b
9642c96bd5a1ccc4e221de9c0af4a545af8182d2 06-Aug-2013 Mathieu Chartier <mathieuc@google.com> Move allocation stack unmarking outside of pause.

Reduces pause time by moving the allocation stack unmarking outside
of the pause. This is especially helpful for devices which have longer
GC times since these times result in having more things to be
unmarked in the allocation stack.

Bug: 9969166

Change-Id: I570f2213cbdda9d90545b64538e2cbeb0dc32d16
e0a53e99e2a01f8668d6616c3cec7e2f5a711286 05-Aug-2013 Mathieu Chartier <mathieuc@google.com> Add low memory mode option to ART.

Useful so that we match the option I added here:
https://googleplex-android-review.googlesource.com/#/c/328940/

In ART low memory mode reduces the maximum number of histogram
buckets. We also trim no matter the utilization.

Change-Id: I655ba63312c0a6574569cdd5171ca81ea338c2aa
50b2928501fe489c108472e7648ec98cdca62e10 30-Jul-2013 Hiroshi Yamauchi <yamauchi@google.com> Improve the allocation speed.

- Improves the Ritz MemAllocTest benchmark result by ~500 ms (or ~5%) on Nexus 4.
- Move the memset() call that zeroes the allocated memory out of the lock region.
- De-virtualize/Inline the allocation call chains into Heap::AllocObject().
- Turn Heap::measure_allocation_time_ into a static const variable.
- Surround the VerifyObject() call with kIsDebugBuild.

Bug: 9986565
Change-Id: Ib70b6d051a80ec329788b30256565561f031da2a
184e322fe8ddd75c844a1eb2eb1ca32bc02f2d45 03-Aug-2013 Mathieu Chartier <mathieuc@google.com> Disable and remove finger.

Finger is useless for multithreaded GC, removing it should provide a
slight speed up due to avoided comparison.

Change-Id: I7eb7abcbab8d3307807b1086c06d68b2d4bcd2e9
161a8e0fcbf26922c97654c00b68082be71eeb50 02-Aug-2013 Mathieu Chartier <mathieuc@google.com> Fix accidental performance regression.

Accidentally changed mod union table in another CL, slowed down
partial GC by a bit.

Change-Id: I8aba855a6b475da2969187ecd73f05c0667e470d
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
0418ae2bdd996b64f733b1290080e3f98a05609f 31-Jul-2013 Mathieu Chartier <mathieuc@google.com> GC a lot mode.

Enabling GC a lot mode bounds the size of the allocation stack to
a small value.

Bug: 8509379

Change-Id: Ia098af54b755e03eb78c5128654edfca3f90f391
f082d3ce16c520b2d039869e8eb3055eda04e591 30-Jul-2013 Mathieu Chartier <mathieuc@google.com> Remove sorted variable in allocation stacks.

Speeds up allocations, mark stack processing non parallel. This is
safe to do since the pre/post GC heap verification is the only
place where we sort the allocation and live stacks and this is
done with mutators suspended.

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

Change-Id: Iae286862c85fb8fd8901eae1204cd6d271d69496
6f28d91aab952e3244fbb4e707fa38f85538f374 25-Jul-2013 Anwar Ghuloum <anwarg@google.com> Add systrace support to NewTimingLogger, migrate compiler timing logging to NewTimingLogger

Rpleaced old TimingLogger by NewTimingLogger, renamed NewTimingLogger to TimingLogger, added systrace support to TimingLogger.
Tests passing, phone booting, systrace working.

Change-Id: I2aeffb8bcb7f0fd979d8a2a3a8bcfbaa02413679
0a9dc05e704bfd033bac2aa38a4fc6f6b8e6cf93 25-Jul-2013 Mathieu Chartier <mathieuc@google.com> GC data structures allocation tracking

Adds a new stl compatible allocator that is used in most GC data
structures. When the data structures allocate and free memory, it
lets the heap know of how much memory was allocated or freed. Using
this info, we dump the approximated stl data structures memory usage
when a sigquit occurs.

The allocation tracking can be disabled with a compile time boolean
flag to remove performance impact.

Change-Id: Idddb6713169e07be913bceeb50f305c8573e4392
333cf1b3b3f55c937d4f72559504297df18951ff 24-Jul-2013 Ian Rogers <irogers@google.com> Tidy OOME message.

1) Make fragmentation reporting not occur for LOS allocations.
2) Don't report bytes allocated in alloc and LOS as the free bytes are what
matter and are already reported. The alloc and LOS sizes should have had
units and describe bytes in the image and Zygote - but really, all you care
about are free bytes.

Change-Id: I53ad8744e07f2087a174ed650d10ee45f46a60b3
63a54345598861030178e033ffbd72c0e231a4c9 23-Jul-2013 Mathieu Chartier <mathieuc@google.com> Add option for changing number of GC threads.

The number of threads was previously set to 1 by an accidential
checkin. This hurts on all devices which aren't dual core. We now
properly use sysconf to determine how many threads we should create.

Also added a -XX:HeapGCThreads heap option which lets us change
how many GC threads we create. The default value is equal to the
number of processors on the device minus one.

Change-Id: If65065ef09174a3813b8741efdd5ea7bbe82a4e2
09b07a96094086e205948717666025909a75163b 15-Jul-2013 Hiroshi Yamauchi <yamauchi@google.com> Show size/alloc/free per Dalvik heap space in dumpsys

Add the heap size/alloc/free stats to the Dalvik heap space breakdown section in dumpsys meminfo.

Also, now the zygote heap has a distict ashmem region name.

Bug: 9532137
Bug: 8266259
Change-Id: Ieeb02f5f5ebf7ffe35d4b55ad81d46989af2827b
4274889d48ef82369bf2c1ca70d84689b4f9e93a 19-Jul-2013 Brian Carlstrom <bdc@google.com> Fixing cpplint readability/check issues

Change-Id: Ia81db7238b4a13ff2e585aaac9d5e3e91df1e3e0
2d88862f0752a7a0e65145b088f49dabd49d4284 19-Jul-2013 Brian Carlstrom <bdc@google.com> Fixing cpplint readability/casting issues

Change-Id: I6821da0e23737995a9b884a04e9b63fac640cd05
82353313bbe00d033b6733535d0dcd6f56c36d8d 18-Jul-2013 Mathieu Chartier <mathieuc@google.com> Add interface for updating the heap's process state

In the future, the heap's process state will be used
to determine GC behavior.

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

Change-Id: Ifc678d59a8bed24ffddde5a0e543620b17b0aba9
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
56d947fbc9bc2992e2f93112fafb73e50d2aaa7a 15-Jul-2013 Brian Carlstrom <bdc@google.com> Add verification of boot.oat generated on device

Change-Id: I069586205a9a92fc7375ccf5cdde136bbbcfc800
4b95e8fad803ad307fa09c11c08894544e07a731 16-Jul-2013 Mathieu Chartier <mathieuc@google.com> Refactor atomic integer.

Refactored atomic integer to be similar to c++11 std::atomic<int>.

Removed jdwp serial lock and reverted lock level name change from
https://googleplex-android-review.googlesource.com/#/c/327297/

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