History log of /art/runtime/gc/heap.h
Revision Date Author Comments
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
df96098c5d079e20c92a8de06dcbe5dacc6b1ab7 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
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
4d3981c72a546b87c8f5d391ff8b5135b8ca99a7 08-Sep-2014 Mathieu Chartier <mathieuc@google.com> Revert "Fix heap trimmer daemon sleeping."

This reverts commit 698b44634396e8111e96e1116586fde89a838347.

Change-Id: Ifa8c2d554b82289cc31803ad6027735d2c3c9be8
d81877cad7a6e9b97dfdc4c63984f218b7e31df5 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
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
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
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
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
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
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
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