History log of /art/runtime/gc/heap.h
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)
67bf42e89592c3a1c648f927f2ce3ccb189a1161 27-Feb-2018 David Sehr <sehr@google.com> Header library to remove dependence on runtime/

Add a new header library to remove libdexfile and others' dependence on
runtime (typically runtime/base) includes in libdexfile. Also a small step
to tease dexlayout and profman away from relying on these as well.

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

Change-Id: I38e2fe399a75f4bc6318c77a71954c00ea73ec2b
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
ef012225dcec8f736fc8fd848f5d8ee01c3c280f 21-Jun-2017 Roland Levillain <rpl@google.com> Fix typos.

Test: art/test/testrunner/testrunner.py
Change-Id: I5f5e052c940650a3adb3a8717b84260e6b306500
c06d6c60fcd8e0a66d9e8dc51a8f35e8f87454c8 24-Jan-2018 Roland Levillain <rpl@google.com> Remove art::gc::Heap::allocation_rate_.

This member is no longer used anywhere.

Test: mmma art
Change-Id: Ieb11ea74b27c3df9d818c420c50cc04d0f4cfb26
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
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
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
dcc528d2c7d5ac2cc075d4c965fdf702421d0f43 07-Dec-2017 Andreas Gampe <agampe@google.com> ART: Move runtime-debug flags to own files

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

Test: m
Change-Id: Ib373357325c6e622f608ada341594c3bea2fce2e
57943810cfc789da890d73621741729da5feaaf8 07-Dec-2017 Andreas Gampe <agampe@google.com> ART: Replace base/logging with android-base/logging

Replace wherever possible. ART's base/logging is now mainly VLOG
and initialization code that is unnecessary to pull in and makes
changes to verbose logging more painful than they have to be.

Test: m test-art-host
Change-Id: I3e3a4672ba5b621e57590a526c7d1c8b749e4f6e
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
2ffb703bf431d74326c88266b4ddaf225eb3c6ad 08-Nov-2017 Igor Murashkin <iam@google.com> cpplint: Cleanup errors

Cleanup errors from upstream cpplint in preparation
for moving art's cpplint fork to upstream tip-of-tree cpplint.

Test: cd art && mm
Bug: 68951293
Change-Id: I15faed4594cbcb8399850f8bdee39d42c0c5b956
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
217488a9ddf351033c1688198c492b9c40c36d8a 18-Sep-2017 Andreas Gampe <agampe@google.com> ART: Move read barrier config out of globals

Reduce the global dependencies by refactoring where the read
barrier constants are defined.

Rename read_barier_c.h to read_barier_config.h and ifdef the
C++ parts to have a common header for both C/asm and C++.

Put heap poisoning configuration into its own minimal header.

Fix up transitive includes.

Test: m
Change-Id: I159669ec61e3d1c4c7ddcd79e63b023a0519717a
8cf9cb386cd9286d67e879f1ee501ec00d72a4e1 19-Jul-2017 Andreas Gampe <agampe@google.com> ART: Include cleanup

Let clang-format reorder the header includes.

Derived with:

* .clang-format:
BasedOnStyle: Google
IncludeIsMainRegex: '(_test|-inl)?$'

* Steps:
find . -name '*.cc' -o -name '*.h' | xargs sed -i.bak -e 's/^#include/ #include/' ; git commit -a -m 'ART: Include cleanup'
git-clang-format -style=file HEAD^
manual inspection
git commit -a --amend

Test: mmma art
Change-Id: Ia963a8ce3ce5f96b5e78acd587e26908c7a70d02
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
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
5d08fcc21a14190c4dba3028a3e35d281afdd016 06-Jun-2017 Andreas Gampe <agampe@google.com> ART: More header cleanups

Pull out more dependencies through forward declarations.

Test: m test-art-host
Change-Id: I7d86726928937f788b956ec9eac91532d66d57ae
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
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
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
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
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
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
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
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
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
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
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
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
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
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
a058fdf0cf7435a13a6e8cae5e3a9bfa1513828d 07-Oct-2016 Mathieu Chartier <mathieuc@google.com> Move mirror::Object setters to ObjPtr

Bug: 31113334

Test: test-art-host

Change-Id: I2c4c84645e194c3c435a4a6fd670176b0e98671f
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
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
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
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
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
9e03b2fbc9843b834bb9d18bc8c3d2ef44a838d8 27-May-2016 Mathieu Chartier <mathieuc@google.com> Reduce TLAB size

Prevent pathological cases like threads fighting for TLABs and doing
back to back GC for alloc each allocation.

No performance change on angler, before:
EEAC: 1161, 1171, 1211
MemAllocTest: 1005, 971, 1148

After:
EEAC: 1173, 1175, 1163
MemAllocTest: 1003, 908, 803

There is also a mysterious speed up on volantis:
EEAC: 1563, 1553, 1543
MemAllocTest: 1474, 1486, 1485

After:
EEAC: 709, 714, 709
MemAllocTest: 664, 684, 655

Bug: 28976163

Change-Id: I564908badf395b6f948aa2dafcb66fe353fc1eba
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
458b105a9cbab6156d72acf3b9372291dba9097a 29-Mar-2016 Mathieu Chartier <mathieuc@google.com> Obtain stack trace outside of critical section

Fixes deadlock if the stack walk does allocations, changed stack
trace format to prevent slowdown.

Added missing GetInterfaceMethodIfProxy to fix a crash in maps.

Bug: 27857910

(cherry picked from commit 23428587d32361736d4c5e0ba7270c7602695a43)

Change-Id: I64373bcd87a68fdd1b58fb855db2b16c9f6ed36b
23428587d32361736d4c5e0ba7270c7602695a43 29-Mar-2016 Mathieu Chartier <mathieuc@google.com> Obtain stack trace outside of critical section

Fixes deadlock if the stack walk does allocations, changed stack
trace format to prevent slowdown.

Added missing GetInterfaceMethodIfProxy to fix a crash in maps.

Bug: 27857910

Change-Id: Iba86b7390a87349c38785297ac76751417b0fc87
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
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
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
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
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
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
28b1cf779b8c438b01b28a4adfeb22a4a8ebdb12 16-Jan-2016 Mathieu Chartier <mathieuc@google.com> Change space base test to use parameters

Still need to convert remaining space tests to use gtest value
parameters.

Bug: 10245322
Change-Id: Iad3183d46f2fff1ec2aee6923c989433885adf81
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
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
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
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
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
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
4e2cb098017bf073335ebb02b1bc0a36828cd720 23-Jul-2015 Mathieu Chartier <mathieuc@google.com> Add uninterruptible role

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

TODO: Add annotation to more locations.

Bug: 20072211

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

Also enable -Wthread-safety-negative.

Changes:
Switch to capabilities and negative capabilities.

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

Bug: 20072211

Change-Id: I42fcbe0300d98a831c89d1eff3ecd5a7e99ebf33
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
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
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
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
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
414369a2e3f23e1408fc1cbf4f623014bd95cb8f 04-May-2015 Mathieu Chartier <mathieuc@google.com> Add some more DISALLOW_COPY_AND_ASSIGN

May help prevent bugs maybe.

(cherry picked from commit 3130cdf29eb203be0c38d1107a65d920ec39c106)

Change-Id: Ie73d469dfcd078492ecb3aa28682b42707221202
3130cdf29eb203be0c38d1107a65d920ec39c106 04-May-2015 Mathieu Chartier <mathieuc@google.com> Add some more DISALLOW_COPY_AND_ASSIGN

May help prevent bugs maybe.

Change-Id: Ie73d469dfcd078492ecb3aa28682b42707221202
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
10d6886c9ce3ed87431cf10d376a69c23950fa61 15-Apr-2015 Mathieu Chartier <mathieuc@google.com> Disable parallel GC by default

Not using parallel GC seems to reduce avg pauses by ~0.1s on
EvaluateAndApplyChanges. Avoiding creating the thread pool should
help app launch slightly and reduce memory ussage.

Change-Id: Iebec2a17701c76e4145b41d7c0b4f6dd17806efa
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
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
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
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
446ba4baa35f9eed9ee598438f25fdf02e4a582c 05-Feb-2015 Igor Murashkin <iam@google.com> Fix broken volantis build

Change-Id: Iedc1a94fd1ec4224b605b984c11cfcc8c1c510e3
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
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
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
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
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
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
446f9ee5031cf89b8964e29eba2c9f10a4d4aaf1 02-Dec-2014 Mathieu Chartier <mathieuc@google.com> Try normal allocation if large object allocation fails

If a large object allocation fails, we now try the normal allocators.

Bug: 18124612

(cherry picked from commit f1c4d0e3a27e9b39916750147ecdea1418fcc231)

Change-Id: Ib83ebe53fbdd83aa2d23fd10a8bb10e149f8918f
f1c4d0e3a27e9b39916750147ecdea1418fcc231 02-Dec-2014 Mathieu Chartier <mathieuc@google.com> Try normal allocation if large object allocation fails

If a large object allocation fails, we now try the normal allocators.

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

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

Bug: 18056890

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

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

Change-Id: I5b433e722d2f75baacfacae4d32aef4a828bfe1b
2d2621a1463d2f3f03fa73503fa42e43657cdcfc 24-Oct-2014 Mathieu Chartier <mathieuc@google.com> Optimize method linking

Added more inlining, removed imt array allocation and replaced it
with a handle scope. Removed some un-necessary handle scopes.

Added logic to base interface method tables from the superclass so
that we dont need to reconstruct for every interface (large win).

Facebook launch Dalvik KK MR2:
TotalTime: 3165
TotalTime: 3652
TotalTime: 3143
TotalTime: 3298
TotalTime: 3212
TotalTime: 3211

Facebook launch TOT before:
WaitTime: 3702
WaitTime: 3616
WaitTime: 3616
WaitTime: 3687
WaitTime: 3742
WaitTime: 3767

After optimizations:
WaitTime: 2903
WaitTime: 2953
WaitTime: 2918
WaitTime: 2940
WaitTime: 2879
WaitTime: 2792

LinkInterfaceMethods no longer one of the hottest methods, new list:
4.73% art::ClassLinker::LinkVirtualMethods(art::Thread*, art::Handle<art::mirror::Class>)
3.07% art::DexFile::FindClassDef(char const*) const
2.94% art::mirror::Class::FindDeclaredStaticField(art::mirror::DexCache const*, unsigned int)
2.90% art::DexFile::FindStringId(char const*) const

Bug: 18054905
Bug: 16828525

(cherry picked from commit 1fb463e42cf1d67595cff66d19c0f99e3046f4c4)

Change-Id: I27cc70178fd3655fbe5a3178887fcba189d21321
1fb463e42cf1d67595cff66d19c0f99e3046f4c4 24-Oct-2014 Mathieu Chartier <mathieuc@google.com> Optimize method linking

Added more inlining, removed imt array allocation and replaced it
with a handle scope. Removed some un-necessary handle scopes.

Added logic to base interface method tables from the superclass so
that we dont need to reconstruct for every interface (large win).

Facebook launch Dalvik KK MR2:
TotalTime: 3165
TotalTime: 3652
TotalTime: 3143
TotalTime: 3298
TotalTime: 3212
TotalTime: 3211

Facebook launch TOT before:
WaitTime: 3702
WaitTime: 3616
WaitTime: 3616
WaitTime: 3687
WaitTime: 3742
WaitTime: 3767

After optimizations:
WaitTime: 2903
WaitTime: 2953
WaitTime: 2918
WaitTime: 2940
WaitTime: 2879
WaitTime: 2792

LinkInterfaceMethods no longer one of the hottest methods, new list:
4.73% art::ClassLinker::LinkVirtualMethods(art::Thread*, art::Handle<art::mirror::Class>)
3.07% art::DexFile::FindClassDef(char const*) const
2.94% art::mirror::Class::FindDeclaredStaticField(art::mirror::DexCache const*, unsigned int)
2.90% art::DexFile::FindStringId(char const*) const

Bug: 18054905
Bug: 16828525

Change-Id: I27cc70178fd3655fbe5a3178887fcba189d21321
cf7f19135f0e273f7b0136315633c2abfc715343 23-Oct-2014 Ian Rogers <irogers@google.com> C++11 related clean-up of DISALLOW_..

Move DISALLOW_COPY_AND_ASSIGN to delete functions. By no having declarations
with no definitions this prompts better warning messages so deal with these
by correcting the code.
Add a DISALLOW_ALLOCATION and use for ValueObject and mirror::Object.
Make X86 assembly operand types ValueObjects to fix compilation errors.
Tidy the use of iostream and ostream.
Avoid making cutils a dependency via mutex-inl.h for tests that link against
libart. Push tracing dependencies into appropriate files and mutex.cc.
x86 32-bit host symbols size is increased for libarttest, avoid copying this
in run-test 115 by using symlinks and remove this test's higher than normal
ulimit.
Fix the RunningOnValgrind test in RosAllocSpace to not use GetHeap as it
returns NULL when the heap is under construction by Runtime.

Change-Id: Ia246f7ac0c11f73072b30d70566a196e9b78472b
677cd61ad05d993c4d3b22656675874f06d6aabc 15-Oct-2014 Ian Rogers <irogers@google.com> Make ART compile with GCC -O0 again.

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

(cherry picked from commit 6f3dbbadf4ce66982eb3d400e0a74cb73eb034f3)

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

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

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

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

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

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

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

Change-Id: Id59ce3cc520701c6ecf612f7152498107bc40684
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
eb10cfe7849236ca9eb5a6d05ac0d06be05f19bf 09-Sep-2014 Mathieu Chartier <mathieuc@google.com> Temporarily disable LOS on 64 bit

Problem is that MAP_32BIT simulation can take seconds on large object
allocations in the worst case.

Bug: 17414549

Change-Id: I463bb0b728eed14847a32a27a93640ec6080f6b3
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
4d3981c72a546b87c8f5d391ff8b5135b8ca99a7 08-Sep-2014 Mathieu Chartier <mathieuc@google.com> Revert "Fix heap trimmer daemon sleeping."

This reverts commit 698b44634396e8111e96e1116586fde89a838347.

Change-Id: Ifa8c2d554b82289cc31803ad6027735d2c3c9be8
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
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
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
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
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
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
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
eb1e929c0d6e312beb313ec108e611f1e74ff45c 06-Aug-2014 Hiroshi Yamauchi <yamauchi@google.com> Implement TLAB fast paths in artAllocObjectFromCode.

GSS/TLAB GC speedup on N4 (ms):

MemAllocTest 2963 -> 2792
BinaryTrees 2205 -> 2113

Also, measured wth -XX:IgnoreMaxFootprint to invoke GC less often
(only when the bump pointer space is filled rather than based on the
target utilization):

MemAllocTest 2707 -> 2590
BinaryTrees 2023 -> 1906

TODO: implement fast paths for array allocations.

Bug: 9986565
Change-Id: I73ff6327b229704f8ae5924ae9b747443c229841
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
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
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
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>
2f4f0a3d049a39687418087fc0165f7a21654b45 11-Jul-2014 Mathieu Chartier <mathieuc@google.com> Change default heap maximum size to be 256m.

Useful for command line benchmarks.

Change-Id: Ie525863cd8eff93c64ce76639b1108fbdad91633
654dd48e2230e16bfaa225decce72b52642e2f78 09-Jul-2014 Hiroshi Yamauchi <yamauchi@google.com> Improve the OOME fragmentation message.

Change-Id: I390d3622f8d572ec7e34ea6dff9e1e0936e81ac1
7c88c6054dfc01f2ac36b19842d467626459fc45 09-Jul-2014 Mathieu Chartier <mathieuc@google.com> Add easy way to ensure the next allocation does GC.

Added a class called ScopedHeapFill which changes the bytes allocated
counter to be equal to the growth limit. This causes the next
allocation to do a GC and possibly generate an OOM error. This is
useful for tests which need GC to happen at specific point.

Change-Id: Ibd8f3d5928b58534c5165ba7c296980002aa2c28
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
146b1872a4b379e808e2738b4090d3293a34c2e8 27-Jun-2014 Mathieu Chartier <mathieuc@google.com> Don't allow negative GetFreeMemory.

The max allowed footprint is only updated after the GC. But we can
still allocate even if bytes_allocated > max_allowed_footprint_.
This means that we used to be able to get a negative value if
bytes_allocated > max_allowed_footprint_.

External bug:
https://code.google.com/p/android/issues/detail?id=72221

Change-Id: I4ef9a534e29211786e82cdcb2582c11ab37a348a
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
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
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
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
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
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
2afe49450f2e018f18b5de45428b9174bfd6f196 19-May-2014 Brian Carlstrom <bdc@google.com> Follow up to "Add ISA directory to image and odex pathnames."

Change-Id: I7f08cc3052fbed93a56ccf1ab7675ae8bc129da9
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
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
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
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
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
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
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
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
7bf9f190cd33a7e2f8584299eb889e9df66e0323 04-Apr-2014 Mathieu Chartier <mathieuc@google.com> Improve invalid root dumping.

The invalid root dumping now attempts to print the root type.

Change-Id: Ie821296d569f34909ba6e2705f5c347cd2143a3a
4cd662e54440f76fc920cb2c67acab3bba8b33dd 04-Apr-2014 Hiroshi Yamauchi <yamauchi@google.com> Fix Object::Clone()'s pre-fence barrier.

Pass in a pre-fence barrier object that sets in the array length
instead of setting it after returning from AllocObject().

Fix another potential bug due to the wrong default pre-fence barrier
parameter value. Since this appears error-prone, removed the default
parameter value and make it an explicit parameter.

Fix another potential moving GC bug due to a lack of a SirtRef.

Bug: 13097759
Change-Id: I466aa0e50f9e1a5dbf20be5a195edee619c7514e
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
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
36bf21665b43adc2485167cbb3a044dbdf4931ee 20-Mar-2014 Mathieu Chartier <mathieuc@google.com> Add Heap::RunningOnValgrind and call it from the spaces.

Makes it easier to disable valgrind support.

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

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

Change-Id: I72cea8da9a3757b1a0b3acb4081feccb7c6cef90
f517f1a994fab72ba484bbbac6911e315f59f6cd 07-Mar-2014 Mathieu Chartier <mathieuc@google.com> Restore obj after RequestConcurrentGC.

RequestConcurrentGC can cause thread suspension, this means that
another thread could transition the heap or cause moving GC.

Bug: 12934910

Change-Id: I5c07161e2e849d7acbdf939f1c24e1ba361a1d6a
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
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
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
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
90d706849a09590f150748ff97256ef718aca441 21-Feb-2014 Hiroshi Yamauchi <yamauchi@google.com> Fix oatdumpd.

Bug: 13063529
Change-Id: I777cd7621ed522b8ab84c5bb1a9d2e5583817a08
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
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
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
816021e1ef6a9b1751cb455b51f53f98bcac1756 06-Feb-2014 Mathieu Chartier <mathieuc@google.com> Remove unused code in heap.h

Change-Id: I77268e92deeade14315e704dcfe77618382c46b8
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
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
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
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
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
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
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
4b5553031edf6ca5212f4eb183073e43abac2b0d 21-Nov-2013 Mathieu Chartier <mathieuc@google.com> Fix memory leak caused by not adding lage objects to allocation stack.

Large objects weren't being added to allocation stack. This was
causing them to never be marked as live and therefore never freed.

Change-Id: Ie84e3cd7a417a89870752cb21bd7d562c3427284
1febddf359ae500ef1bb01ab4883b076fcb56440 20-Nov-2013 Mathieu Chartier <mathieuc@google.com> Set array length before fence in allocation code path.

Could not delete SetLength since it is required by
space_test.

Bug: 11747779

Change-Id: Icf1ead216b6ff1b519240ab0d0ca30d68429d5b6
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
d31fb9718a6180304cd951619dc36be8e090a641 19-Nov-2013 Hiroshi Yamauchi <yamauchi@google.com> Enable rosalloc by default.

Bug: 9986565
Change-Id: I485341d30a21704ddbc45d8f531ef5593a358bb5
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
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
0732d59d42523b8c2d807de3a380d2fbfa781364 06-Nov-2013 Mathieu Chartier <mathieuc@google.com> Improve object clone performance and make compaction proof.

Bug: 11551604
Bug: 8981901

Change-Id: I60646d838dbb51e125303d1a8fe869191aa63e78
ad2541a59c00c2c69e8973088891a2b5257c9780 25-Oct-2013 Mathieu Chartier <mathieuc@google.com> Fix object identity hash.

The object identity hash is now stored in the monitor word after
being computed. Hashes are computed by a pseudo random number
generator.

When we write the image, we eagerly compute object hashes to
prevent pages getting dirtied.

Bug: 8981901

Change-Id: Ic8edacbacb0afc7055fd740a52444929f88ed564
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
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
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
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
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
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)
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
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
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
58b42b986742565cccfde4366495ad23d0ba57d1 26-Jul-2013 Mathieu Chartier <mathieuc@google.com> Fix portable build.

Move dlmalloc include inside of cc file.

Change-Id: Ic36bdbf9fa964b93a23d1a45f603bab1bf9583d7
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
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
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
fc0e3219edc9a5bf81b166e82fd5db2796eb6a0d 17-Jul-2013 Brian Carlstrom <bdc@google.com> Fix multiple inclusion guards to match new pathnames

Change-Id: Id7735be1d75bc315733b1773fba45c1deb8ace43
56d947fbc9bc2992e2f93112fafb73e50d2aaa7a 15-Jul-2013 Brian Carlstrom <bdc@google.com> Add verification of boot.oat generated on device

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