History log of /art/runtime/gc/space/image_space.cc
Revision Date Author Comments
25adcfb7dc81131add3a0a681ae18bced6f7a0e0 22-Sep-2016 Mathieu Chartier <mathieuc@google.com> Make image test multi image

Required for testing multi image layout in future CLs.

Bug: 28640955

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

Change-Id: I14809f56e711b4a87e01056c327eddbbd087f4ee
f242f66cf7137ef681e44a494758976e11579260 10-Aug-2016 Andreas Gampe <agampe@google.com> ART: Check for more low-space situations in zygote

Even if a boot image exists and can be loaded, the rest of the
platform may not be able to boot. We previously only checked
after full image generation and missed this case.

Also prune the cache if there wasn't even space to put the boot
marker.

Bug: 30765660
Change-Id: Icd43746e681c62ce2e4e8745fb17bda65ca60372
ff2a8ef2ed6b3f21da26f85197170d7d2a9f5134 09-Jul-2016 Andreas Gampe <agampe@google.com> ART: Remove zygote OTA code

The renaming and relabeling of the A/B artifacts is now done in
a special-purpose script started by init, so as to not complicate
the logic here (e.g., name of the current slot).

Partially reverts commit 754479f7aa056602de8282f4f03718b42c20b89b.

Bug: 25612095
Bug: 28069686
Change-Id: I4d965361000fd448e199c9af059b6d18bfe928bb
df2d4f22d5e89692c90b443da82fe2930518418b 30-Jun-2016 Artem Udovichenko <artem.u@samsung.com> Revert "Revert "Optimize IMT""

This reverts commit 88f288e3564d79d87c0cd8bb831ec5a791ba4861.

Test: Includes smali tests to exercise cts failures that led to revert.
These tests check that objects that don't implement any interfaces are
handled properly when interface methods are invoked on them.

Bug: 29188168 (for initial CL)
Bug: 29778499 (reason for revert)

Change-Id: I49605d53692cbec1e2622e23ff2893fc51ed4115
fd43db68d204caaa0e411ca79a37af15d1c001af 29-Jun-2016 Jeff Hao <jeffhao@google.com> Revert "Optimize IMT"

This reverts commit 0790af1391b316c5c12b4e135be357008c060696.

Bug: 29188168 (for initial CL)
Bug: 29778499 (reason for revert)

Change-Id: I2c3e4ec2cebdd40faec67ddb721b7acdc8e90061
0790af1391b316c5c12b4e135be357008c060696 13-May-2016 Nelli Kim <nelli.kim@samsung.com> Optimize IMT

* Remove IMT for classes which do not implement interfaces
* Remove IMT for array classes
* Share same IMT

Saved memory (measured on hammerhead):
boot.art:
Total number of classes: 3854
Number of affected classes: 1637
Saved memory: 409kB

Chrome (excluding classes in boot.art):
Total number of classes: 2409
Number of affected classes: 1259
Saved memory: 314kB

Google Maps (excluding classes in boot.art):
Total number of classes: 6988
Number of affected classes: 2574
Saved memory: 643kB

Performance regression on benchmarks/InvokeInterface.java benchmark
(measured timeCall10Interface)
1st launch: 9.6%
2nd launch: 6.8%

Bug: 29188168

(cherry picked from commit badee9820fcf5dca5f8c46c3215ae1779ee7736e)

Change-Id: If8db765e3333cb78eb9ef0d66c2fc78a5f17f497
cdca476bf3394ce9d97a369e84e701b427009318 28-Apr-2016 Mathieu Chartier <mathieuc@google.com> Revert "Revert "Write conflict tables in image""

Added test.

Bug: 27906566

This reverts commit 8e2478d23e89a7022c93ddc608dcbba7b29b91e6.

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

Some strange issues on angler.

This reverts commit cda9386add68d94697449c6cb08b356747e55c21.

Change-Id: Iba3a8bac6ce40ee16d83163823356951fecb6787
cda9386add68d94697449c6cb08b356747e55c21 14-Apr-2016 Mathieu Chartier <mathieuc@google.com> Write conflict tables in image

Add image sections for runtime methods and conflict tables. This
makes it that we do not need to fake up a length prefixed array
for runtime methods.

Reduces .art private dirty and PSS.

System wide .art PSS goes from 32.5MB to 30.5MB after system boot.

Business card .art private dirty goes from 588K to 504K.

Increases image size by ~100K.

Bug: 27906566

Change-Id: I38cbe3150c3eeb385b8cad7cf93614e3980f4162
0dfb30d11d4e3ecd727542d712e8d6a110b1bb67 12-Apr-2016 Goran Jakovljevic <Goran.Jakovljevic@imgtec.com> Remove recursive ALWAYS_INLINE

GCC (mips32 Buildbot) is complaining about recursive inlining.

Clean up after
https://android-review.googlesource.com/#/c/214918/.

Change-Id: I221c53c32403e5e433e30cfee7b2ae36680f39e6
92ec594fba4645e12b67f7067f68786bb9519600 11-Apr-2016 Mathieu Chartier <mathieuc@google.com> Fix relocate in place to handle arbitrary app image layout

Previously the relocation had bugs where it would not work correctly
if the iftable was after the class since the object arrays would not
yet be updated to be the relocated address when we went through them
to fixup the ArtMethod pointers.

Also fixes a bug where the superclass of a class could not be
updated when we walk through it for visiting instance fields of
large objects.

Changed RelocateInPlace to use a simplier single pass approach.

Bug: 27906566
Bug: 22858531

(cherry picked from commit 564289c753cbe3521f9523b350bd713c1fe2fbd4)

Change-Id: I97affab6ff353dfdc4d1bf31df69ceb96a0c7a1a
19578c9ae94725aaa82ef32fbfb2f9fd09321844 11-Apr-2016 Mathieu Chartier <mathieuc@google.com> Don't abort during app image loading with no boot image

Fail gracefully instead. Fixes test 119.

Bug: 22858531

(cherry picked from commit e719926c78d6b717ecc0d3d1620a757ae3019d20)

Change-Id: If39e0cf146a3bd03bf23646077e9547dd56ec81c
564289c753cbe3521f9523b350bd713c1fe2fbd4 11-Apr-2016 Mathieu Chartier <mathieuc@google.com> Fix relocate in place to handle arbitrary app image layout

Previously the relocation had bugs where it would not work correctly
if the iftable was after the class since the object arrays would not
yet be updated to be the relocated address when we went through them
to fixup the ArtMethod pointers.

Also fixes a bug where the superclass of a class could not be
updated when we walk through it for visiting instance fields of
large objects.

Changed RelocateInPlace to use a simplier single pass approach.

Bug: 27906566
Bug: 22858531

Change-Id: I97affab6ff353dfdc4d1bf31df69ceb96a0c7a1a
e719926c78d6b717ecc0d3d1620a757ae3019d20 11-Apr-2016 Mathieu Chartier <mathieuc@google.com> Don't abort during app image loading with no boot image

Fail gracefully instead. Fixes test 119.

Bug: 22858531
Change-Id: If17acf5365f8a8fc0a2f6445c558960c62c8f948
acc1be3c215c1913eec783334f6a5e9af9286766 05-Apr-2016 Andreas Gampe <agampe@google.com> ART: Don't attempt write flock if not zygote

When loading an image, don't attempt a RDWR flock if the process
is not the zygote. The lock will be rejected as the process does
not have permission to write the file.

Bug: 28011897

(cherry picked from commit fff377b13469b8c84ce55ee20b10ca80a5a0813d)

Change-Id: I567934c4e9a9a13e9131711240e9ecfdd58b69f7
fff377b13469b8c84ce55ee20b10ca80a5a0813d 05-Apr-2016 Andreas Gampe <agampe@google.com> ART: Don't attempt write flock if not zygote

When loading an image, don't attempt a RDWR flock if the process
is not the zygote. The lock will be rejected as the process does
not have permission to write the file.

Bug: 28011897
Change-Id: I567934c4e9a9a13e9131711240e9ecfdd58b69f7
d5f3f32bc0ca729cf4bbf7975525dc921ce94678 21-Mar-2016 Mathieu Chartier <mathieuc@google.com> Add sanity checking to declaring class visiting

When we have an unmarked declaring class in the image, it will
SIGSEGV due to the bitmap being read-only. Print some useful
info to try and debug this.

This probably hurts performance a bit, TODO disable when the bug is
fixed.

Bug: 27493510

(cherry picked from commit b33b1dc78d178060ff0f4327d448fd3a89df51de)

Change-Id: I0c25afd5a6101a71fa1494e12dc019ba64bf43be
b33b1dc78d178060ff0f4327d448fd3a89df51de 21-Mar-2016 Mathieu Chartier <mathieuc@google.com> Add sanity checking to declaring class visiting

When we have an unmarked declaring class in the image, it will
SIGSEGV due to the bitmap being read-only. Print some useful
info to try and debug this.

This probably hurts performance a bit, TODO disable when the bug is
fixed.

Bug: 27493510

Change-Id: Ida0c09cb8e41c1c2ff5cd9d07cbf0d34d6802511
02d97c3727a4c7fb611b73fac1a0ff19568de2c9 15-Mar-2016 Jeff Hao <jeffhao@google.com> Fix zygote handling of when secondary image is out of date.

Simple fix for case when primary image is current, but a secondary image
is out of date. Will want to do a cleaner fix in the future.

Bug: 27340451

(cherry-picked from commit b8510d2311964489342d8875ef7f5b681ba874b4)

Change-Id: I034f001834d84b2a4aa367da722543091a2a7b3a
ab4a4d2b12d517af74b75ed22bebf7dec2bdf130 15-Mar-2016 Jeff Hao <jeffhao@google.com> Fix zygote handling of when secondary image is out of date.

Simple fix for case when primary image is current, but a secondary image
is out of date. Will want to do a cleaner fix in the future.

Bug: 27340451

(cherry-pick of commit b8510d2311964489342d8875ef7f5b681ba874b4)

Change-Id: Ia6db863e3d3c72120630bcbae8d399a78dda2710
b8510d2311964489342d8875ef7f5b681ba874b4 15-Mar-2016 Jeff Hao <jeffhao@google.com> Fix zygote handling of when secondary image is out of date.

Simple fix for case when primary image is current, but a secondary image
is out of date. Will want to do a cleaner fix in the future.

Bug: 27340451
Change-Id: I0e8ead1d0637346259cf9a54ee0f18c0ee57f910
0b4cbd0c2a75b47ae09d21e5d73d2b1709cb5b9e 09-Mar-2016 Mathieu Chartier <mathieuc@google.com> Add oatdump support for app images

Example usage on host:
oatdumpd --app-oat=art/plus32.odex --app-image=art/plus32.art
--image=art/oats/system@framework@boot.art --instruction-set=arm

TODO: Add to oatdump test.

Bug: 27408512
Bug: 22858531

(cherry picked from commit bcb6a72569a1401b36a3ad3b6aa4d13e29966cf0)

Change-Id: I9d1aa7eaa16795e5fbabc6974d245849e16b1d03
bec635813789a7365900d3db01c16e12a20c2815 21-Nov-2015 Andreas Gampe <agampe@google.com> ART: Update dalvik-cache for zygote after OTA

Detect OTA artifacts and move them over to the regular dalvik-cache
on boot.

Bug: 25612095

(cherry picked from commit 754479f7aa056602de8282f4f03718b42c20b89b)

Change-Id: I9a1a22641cc7833435098627a5cc6d954521c4ea
bcb6a72569a1401b36a3ad3b6aa4d13e29966cf0 09-Mar-2016 Mathieu Chartier <mathieuc@google.com> Add oatdump support for app images

Example usage on host:
oatdumpd --app-oat=art/plus32.odex --app-image=art/plus32.art
--image=art/oats/system@framework@boot.art --instruction-set=arm

TODO: Add to oatdump test.

Bug: 27408512
Bug: 22858531

Change-Id: I320db8b76c780c6eadabcb45ce88f45950741484
8e864bff9eadc749981db3c832d65c7ce909b5d3 14-Mar-2016 Mathieu Chartier <mathieuc@google.com> Do not include image header in decompressed size

Could cause a buffer overflow since we told LZ4 to decompress more
bytes than necessary.

Bug: 27561308

(cherry picked from commit 324eb2c6b049f1677133f0b708730e904c5e73ab)

Change-Id: I524c03b8f0e8a84814dbd8678285184e9d4da9f1
324eb2c6b049f1677133f0b708730e904c5e73ab 14-Mar-2016 Mathieu Chartier <mathieuc@google.com> Do not include image header in decompressed size

Could cause a buffer overflow since we told LZ4 to decompress more
bytes than necessary.

Bug: 27561308
Change-Id: Ic938f3e67f8c0627f203ad7261d4342ce43157cd
8b8f6d6e85f46718b6865c962614d3d34fd33db0 09-Mar-2016 Mathieu Chartier <mathieuc@google.com> Use per character suffix for multi image

E.g. if you pull the oat files from the device, you get oat files
with the following names:
system@framework@boot.art

But the name stored in the image header is:
boot.art

So we need to append system@framework@ as a file name prefix to each
image file to get the actual one.

Required for adding oatdump support for app images.

Bug: 22858531
Bug: 27408512

(cherry picked from commit 05752398db7f25d7892b62cb39615eee468f1db8)

Change-Id: Ia6fb34b137c5e285818d39c3b9794cd4ce6c3219
05752398db7f25d7892b62cb39615eee468f1db8 09-Mar-2016 Mathieu Chartier <mathieuc@google.com> Use per character suffix for multi image

E.g. if you pull the oat files from the device, you get oat files
with the following names:
system@framework@boot.art

But the name stored in the image header is:
boot.art

So we need to append system@framework@ as a file name prefix to each
image file to get the actual one.

Required for adding oatdump support for app images.

Bug: 22858531
Bug: 27408512

Change-Id: I93dd3f16652400f232e6175670fcd572395879e0
32ce2adefb8a3d0eda59a29f5e87c1eb43eef796 04-Mar-2016 Mathieu Chartier <mathieuc@google.com> Add more systracing everywhere

Added to:
JIT
DexFile functions
Oat file manager

Added helper ScopedTrace to prevent errors and reduce excess code.

Bug: 27502458

(cherry picked from commit dabdc0fe183d4684f3cf4d70cb09d318cff81b42)

Change-Id: Ifaeff8913d79eefc797380987d13cc00456266f8
dabdc0fe183d4684f3cf4d70cb09d318cff81b42 04-Mar-2016 Mathieu Chartier <mathieuc@google.com> Add more systracing everywhere

Added to:
JIT
DexFile functions
Oat file manager

Added helper ScopedTrace to prevent errors and reduce excess code.

Bug: 27502458

Change-Id: Ifaeff8913d79eefc797380987d13cc00456266f8
c5dd319c574f67d11a71f1b60ac6c34bfe93b750 10-Dec-2015 Mathieu Chartier <mathieuc@google.com> Add and use loaded class profiling

Class profiling is a way to keep track of which classes are resolved.
From here the compiler can use this information to generate a smaller
app image.

TODO: Add tests for profile stuff.

Bug: 22858531

(cherry picked from commit 8913fc1a27df8cf3b37fd99e94d87f290591328e)

Change-Id: Ifcd09230cbdc266305bc1247e0d31e7920eb353e
8913fc1a27df8cf3b37fd99e94d87f290591328e 10-Dec-2015 Mathieu Chartier <mathieuc@google.com> Add and use loaded class profiling

Class profiling is a way to keep track of which classes are resolved.
From here the compiler can use this information to generate a smaller
app image.

TODO: Add tests for profile stuff.

Bug: 22858531

Change-Id: I91ccd686394cc2517512f66abb0e277f3d26d4da
167e638ffd46186ef4fa26d1c0b6c7e00ed51ccb 25-Feb-2016 Mathieu Chartier <mathieuc@google.com> Add lz4hc image compression format

Smaller than lz4 and decompresses at the same speed. Compression is
a bit slower.

Example saves on old FB APK:
Uncompressed: 44748800 bytes
LZ4: 12443648 bytes
LZ4HC: 11055104 bytes

Generating the image slows down by ~1s per 20MB of image due to
slower compression. Decompression is about the same speed but there
should be a slight speedup since less data needs to be read from
flash.

Added test.

Bug: 22858531

(cherry picked from commit a6e81ed4c185b7362cd5199ebe5507d00883a9b0)

Change-Id: Idd0bbe1ea45fc6ab75a42bfeb0ef250e8b3e2f1b
1c3fa8891a95003f305a77d45838cb7c5040290f 25-Feb-2016 Mathieu Chartier <mathieuc@google.com> Add a decompression scoped timing for image loading

Shows up in systrace.

Bug: 22858531

(cherry picked from commit 31317c319667cf1d7d0f61229ccb5e76f22606cf)

Change-Id: Id4997fb9abc28fa8c1dd1e78ff01234637b229d3
a6e81ed4c185b7362cd5199ebe5507d00883a9b0 25-Feb-2016 Mathieu Chartier <mathieuc@google.com> Add lz4hc image compression format

Smaller than lz4 and decompresses at the same speed. Compression is
a bit slower.

Example saves on old FB APK:
Uncompressed: 44748800 bytes
LZ4: 12443648 bytes
LZ4HC: 11055104 bytes

Generating the image slows down by ~1s per 20MB of image due to
slower compression. Decompression is about the same speed but there
should be a slight speedup since less data needs to be read from
flash.

Added test.

Bug: 22858531

Change-Id: Ib2704305b9bec5b0ba3b1e871f59f4eedff330b7
31317c319667cf1d7d0f61229ccb5e76f22606cf 25-Feb-2016 Mathieu Chartier <mathieuc@google.com> Add a decompression scoped timing for image loading

Shows up in systrace.

Bug: 22858531
Change-Id: Ic165cd0106dd019c002b600d37560b71b4e351d1
d12513f7e57fec32729f1922f9c84f812ad0d0e7 17-Feb-2016 Mathieu Chartier <mathieuc@google.com> Only visit pointer arrays once during image relocation

Previously they could get visited twice, this caused corruption of
the app image if a pointer was updated twice.

Bug: 22858531

(cherry picked from commit 91edc62a9d8d4d8153b6b04140b50a3724cd3597)

Change-Id: I27aea3322ce925909e7ace59d91fc9299f2549ba
91edc62a9d8d4d8153b6b04140b50a3724cd3597 17-Feb-2016 Mathieu Chartier <mathieuc@google.com> Only visit pointer arrays once during image relocation

Previously they could get visited twice, this caused corruption of
the app image if a pointer was updated twice.

Bug: 22858531
Change-Id: I1f1ba1ba5dc205be07dba51bc6ce7a825c82b33a
6eb6a39bdcf669655190d40d20f8d2e663b262f4 11-Feb-2016 Andreas Gampe <agampe@google.com> ART: Simplify patchoat

Removed unused configurations. Cut out cruft that isn't used anymore
since multi-image. Make it smaller to not require new selinux
permissions for OTAs.

Split up the main function, to make the flow clearer for image vs
app/oat.

Bug: 25612095
Bug: 26317072

(cherry picked from commit 02bc0b70beedfe258c2147c2b4a205fbf3d6eebc)

Change-Id: Ieb55bd1a13cbb44fd0e2979a8a61a509df9c1e7e
02bc0b70beedfe258c2147c2b4a205fbf3d6eebc 11-Feb-2016 Andreas Gampe <agampe@google.com> ART: Simplify patchoat

Removed unused configurations. Cut out cruft that isn't used anymore
since multi-image. Make it smaller to not require new selinux
permissions for OTAs.

Split up the main function, to make the flow clearer for image vs
app/oat.

Bug: 25612095
Bug: 26317072
Change-Id: Ieb55bd1a13cbb44fd0e2979a8a61a509df9c1e7e
754479f7aa056602de8282f4f03718b42c20b89b 21-Nov-2015 Andreas Gampe <agampe@google.com> ART: Update dalvik-cache for zygote after OTA

Detect OTA artifacts and move them over to the regular dalvik-cache
on boot.

Bug: 25612095
Change-Id: I9a1a22641cc7833435098627a5cc6d954521c4ea
a57ee9dac63148848a5e11461bafcfd33689ea10 03-Feb-2016 Mathieu Chartier <mathieuc@google.com> Avoid read barrier for UpdateEntrypoints

Somehow not caught by local testing.

Bug: 26786304
Change-Id: Ib9b53c0252bc053013fddd63c8146f4057a38453
dfe02f6aafee264478d510b9742ee266ea52e8a8 02-Feb-2016 Mathieu Chartier <mathieuc@google.com> Fix remaining read barrier issues in image relocation

Added a way to disallow read barriers, this makes it easy to find
the issues.

Bug: 26786304
Change-Id: I7ebb50832686d03e096a979aae9741239371683f
1aa8ec2ccdd7bedb6d30d91c89f1e94ab23c4439 01-Feb-2016 Mathieu Chartier <mathieuc@google.com> Fix up dex cache strings stored in classes

Previously we left the image pointer instead of fixing up the pointer
to the one in the BSS. This only showed up because JIT does the same
as boot image, bypassing null check.

Fixed a bug where oat files without embedded dex cache arrays would
get their dex cache arrays corrupted.

Added a non virtual class visitor for performance.

Bug: 26846419
Bug: 22858531

Change-Id: I8cd0d61e440f753b4628ddb8c932eb23a0a81027
9ff846053a33db95fcf739831baf55eb7e1ce243 29-Jan-2016 Mathieu Chartier <mathieuc@google.com> Add oat checksum check for app image loading

Bug: 26846419
Bug: 22858531

Change-Id: If30028b7d6b5749f5bdbed0c219d014a3b50a11b
60bc39c8eb0e5d7328bf59a96e9eedfc6f0a4aeb 28-Jan-2016 Mathieu Chartier <mathieuc@google.com> Remove some more read barriers in image relocation

Bug: 26786304
Bug: 22858531
Change-Id: I70dacae7657ebf6dac2b3dad7726eebe5a2b2649
4a26f17b055cadc949c3e9fdfa637fe5656339d9 26-Jan-2016 Mathieu Chartier <mathieuc@google.com> Remove GetImageRoots read barrier for image relocation

Fixes CC assertion that failed if an app image was loaded when the GC
was running.

Bug: 26786304
Change-Id: I47bea7b4b947332b57be2e2db604c2c25d92b7e2
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
2d124ec869430789b51dc624db8ac655971c3a97 06-Jan-2016 Mathieu Chartier <mathieuc@google.com> Get rid of shadow maps for images

Fixed the image bitmap creation to use the End of the object section
instead of using the map size. This means that the bitmap covers at
most one word of bits past the end of the object section.

Reverts shadow map logic introduced by multi image CL:
(commit dcdc85bbd569f0ee66c331b4219c19304a616214)

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

This reverts commit de38b797c3e5ba3ee44c480db7093386975c51eb.

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

Bug: 26317072
Bug: 26320300

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

Fails imgdiag_test on device.

Bug: 26317072
Bug: 26320300

This reverts commit 288b1e9a0dddfb91e85067fe81de55174f313c7c.

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

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

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

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

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

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

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

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

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

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

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

Change-Id: Ie1d6f0b8afa8aed5790065b8c2eb177990c60129
ceb07b3285eaab350a8cd12f7d74be3e40a255dd 10-Dec-2015 Mathieu Chartier <mathieuc@google.com> Revert "Revert "Add support for LZ4 compressed image files""

Needed to call compiler_driver_->SetSupportBootImageFixup(false).

Bug: 22858531

This reverts commit 83d4d72aa0e4170209ab50c67ba22e46b71352c1.

Change-Id: Iaed6a810a0c088f1f2c57cf2f12087f3978a3de1
83d4d72aa0e4170209ab50c67ba22e46b71352c1 10-Dec-2015 Nicolas Geoffray <ngeoffray@google.com> Revert "Add support for LZ4 compressed image files"

Tentative. Looks like it breaks image_test for hammerhead:
art/compiler/linker/arm/relative_patcher_thumb2.cc:36] Check failed: target_offset & 1u == 1u (target_offset & 1u=0, 1u=1)

Bug: 22858531

This reverts commit c6f41b5b3ca3d7ac3c12ad3995ffef4e831973a0.

Change-Id: I9bc5738a8b5c8f8bc8b73309f9420fd691bc79a9
c6f41b5b3ca3d7ac3c12ad3995ffef4e831973a0 05-Dec-2015 Mathieu Chartier <mathieuc@google.com> Add support for LZ4 compressed image files

Added dex2oat option --image-format=(store|lz4). Using lz4 means
that the main image section (all data other than header and bitmap)
are stored in a compressed state.

N5 results:
Boot image size: 8067128 -> 2827605
Decompression time 18.93ms
Decompression rate: 426MB/s

Patchoat is not currently supported since it maps the source image
directly. In order to support compressed images we would need to
recompress the output image and then write it back out to a file.
Also there are not many cases where we would want to patch a
compressed image since they are going to be dirty memory when
uncompressed anyways. Might as well just patch as we are loading.

Bug: 22858531

Change-Id: I8c54ccf73408273011161a61bb891736735074d9
1532476b2245e509f6fa2d91526a775468de5cfc 19-Nov-2015 Alex Light <allight@google.com> Use arc4random when available to select delta for image relocation.

Bug: 25776162

Change-Id: I5a5ca5d55c231508b61d4960049ab42e19c017e2
732f016139acac7bd7ec0d0c1d5e964eb8a28b2e 20-Nov-2015 Alex Light <allight@google.com> Revert "Use arc4random when available to select delta for image relocation."

This reverts commit 7ecbd49c6c78e6c633883aa6766675df8abaa7dd.

Change-Id: Ifb37e23584722b31cb2369bcc9b91da6146d2cf6
7ecbd49c6c78e6c633883aa6766675df8abaa7dd 19-Nov-2015 Alex Light <allight@google.com> Use arc4random when available to select delta for image relocation.

Bug: 25776162

Change-Id: I1c4cc992977b5d6fe782ff819903a802a40391ee
42bddcec51e71d206f6d3b30a881ee6c1d50a63c 10-Nov-2015 Mathieu Chartier <mathieuc@google.com> Add low_4gb support to MapFile and MapFileAtAddress

Motivation is to use this for loading app images in low 4GB at a
non fixed address.

Added test.

Bug: 22858531
Change-Id: I0f79a4a7bfbfbdfc112e41b25c8682b1fb932ab7
f9c6fc610b27887f832e453a0da1789187293408 07-Oct-2015 Mathieu Chartier <mathieuc@google.com> Add OatFileManager

Takes over a large amount of functionality from the class linker.

Changed OatFile to loading the same OatFile multiple times. This is
required for unloading OatFiles and moving dex caches to BSS since
these require a different OatFile for each dex cache and class
loader.

Bug: 22720414

Change-Id: I0321096723a294dc72949f21e66da82727b512fc
b1d8c314b55bb2df2b2bb72a3daaf5db65b7ebc7 04-Aug-2015 Igor Murashkin <iam@google.com> Revert "cleanup: Replace pointers with out-parameters and fix-up formatting"

This reverts commit a315f5c546b796f55f4872bb6efc15eb858d9639.

--

Revert "runtime: cleanup class_linker out-parameters and formatting"

This reverts commit bc1d78daa463572c5a770cdca858a3b51d8e1b7b.

--

Revert "base: replace raw pointers for out-parameters with safer out<T>"

This reverts commit fb326cffc679cab8eb873b9e44795706f023cb3c.
a315f5c546b796f55f4872bb6efc15eb858d9639 01-Aug-2015 Igor Murashkin <iam@google.com> cleanup: Replace pointers with out-parameters and fix-up formatting

Cleans all of oat_file.h/.cc, parsed_options.h./cc, runtime.h/.cc

Other files are touched only incidentally to use outof(x) instead of &x.

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

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

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

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

Bug: 21924613
Change-Id: I3f944a08dd2ed1df4d8a807da4fee423fdd35eb7
88da3b0d2f76b1d6b9749315ac0c5b0367e92262 13-Jun-2015 Andreas Gampe <agampe@google.com> ART: Fix CFI test wrt/ PIC

PIC boot images can't be loaded with dlopen, as their base is zero,
but we have an expectant address. Turn off in-process unwinding
in 137-cfi by checking the boot image oat file type.

Keep a non-owned referenced to the oat file in image space to simplify
access.

Change-Id: Ia2b525f9b2ecbc80b433f09e04ebece4cb6f2d2b
d39645e22b8db1767cf64dc1200a9e4b2f939ed2 10-Jun-2015 Mathieu Chartier <mathieuc@google.com> Move image intern table into image

Previously we recreated this intern table during runtime startup.
This added 50-100ms of boot time.

Fixed bug where we didn't copy over hashcodes into the image.

Deleted some stale code.

(cherry picked from commit fac3a390a247fe33d4873773d742aad4cc100118)

Bug: 20727525
Bug: 19569780
Change-Id: I08959e9aa2a73cedb52f393033e2ffea3a26e76b
fac3a390a247fe33d4873773d742aad4cc100118 10-Jun-2015 Mathieu Chartier <mathieuc@google.com> Move image intern table into image

Previously we recreated this intern table during runtime startup.
This added 50-100ms of boot time.

Fixed bug where we didn't copy over hashcodes into the image.

Deleted some stale code.

Bug: 20727525
Bug: 19569780
Change-Id: I08959e9aa2a73cedb52f393033e2ffea3a26e76b
3d21bdf8894e780d349c481e5c9e29fe1556051c 22-Apr-2015 Mathieu Chartier <mathieuc@google.com> Move mirror::ArtMethod to native

Optimizing + quick tests are passing, devices boot.

TODO: Test and fix bugs in mips64.

Saves 16 bytes per most ArtMethod, 7.5MB reduction in system PSS.
Some of the savings are from removal of virtual methods and direct
methods object arrays.

Bug: 19264997

(cherry picked from commit e401d146407d61eeb99f8d6176b2ac13c4df1e33)

Change-Id: I622469a0cfa0e7082a2119f3d6a9491eb61e3f3d

Fix some ArtMethod related bugs

Added root visiting for runtime methods, not currently required
since the GcRoots in these methods are null.

Added missing GetInterfaceMethodIfProxy in GetMethodLine, fixes
--trace run-tests 005, 044.

Fixed optimizing compiler bug where we used a normal stack location
instead of double on ARM64, this fixes the debuggable tests.

TODO: Fix JDWP tests.

Bug: 19264997

Change-Id: I7c55f69c61d1b45351fd0dc7185ffe5efad82bd3

ART: Fix casts for 64-bit pointers on 32-bit compiler.

Bug: 19264997
Change-Id: Ief45cdd4bae5a43fc8bfdfa7cf744e2c57529457

Fix JDWP tests after ArtMethod change

Fixes Throwable::GetStackDepth for exception event detection after
internal stack trace representation change.

Adds missing ArtMethod::GetInterfaceMethodIfProxy call in case of
proxy method.

Bug: 19264997
Change-Id: I363e293796848c3ec491c963813f62d868da44d2

Fix accidental IMT and root marking regression

Was always using the conflict trampoline. Also included fix for
regression in GC time caused by extra roots. Most of the regression
was IMT.

Fixed bug in DumpGcPerformanceInfo where we would get SIGABRT due to
detached thread.

EvaluateAndApplyChanges:
From ~2500 -> ~1980
GC time: 8.2s -> 7.2s due to 1s less of MarkConcurrentRoots

Bug: 19264997
Change-Id: I4333e80a8268c2ed1284f87f25b9f113d4f2c7e0

Fix bogus image test assert

Previously we were comparing the size of the non moving space to
size of the image file.

Now we properly compare the size of the image space against the size
of the image file.

Bug: 19264997
Change-Id: I7359f1f73ae3df60c5147245935a24431c04808a

[MIPS64] Fix art_quick_invoke_stub argument offsets.

ArtMethod reference's size got bigger, so we need to move other args
and leave enough space for ArtMethod* and 'this' pointer.

This fixes mips64 boot.

Bug: 19264997
Change-Id: I47198d5f39a4caab30b3b77479d5eedaad5006ab
e401d146407d61eeb99f8d6176b2ac13c4df1e33 22-Apr-2015 Mathieu Chartier <mathieuc@google.com> Move mirror::ArtMethod to native

Optimizing + quick tests are passing, devices boot.

TODO: Test and fix bugs in mips64.

Saves 16 bytes per most ArtMethod, 7.5MB reduction in system PSS.
Some of the savings are from removal of virtual methods and direct
methods object arrays.

Bug: 19264997
Change-Id: I622469a0cfa0e7082a2119f3d6a9491eb61e3f3d
41b175aba41c9365a1c53b8a1afbd17129c87c14 19-May-2015 Vladimir Marko <vmarko@google.com> ART: Clean up arm64 kNumberOfXRegisters usage.

Avoid undefined behavior for arm64 stemming from 1u << 32 in
loops with upper bound kNumberOfXRegisters.

Create iterators for enumerating bits in an integer either
from high to low or from low to high and use them for
<arch>Context::FillCalleeSaves() on all architectures.

Refactor runtime/utils.{h,cc} by moving all bit-fiddling
functions to runtime/base/bit_utils.{h,cc} (together with
the new bit iterators) and all time-related functions to
runtime/base/time_utils.{h,cc}. Improve test coverage and
fix some corner cases for the bit-fiddling functions.

Bug: 13925192

(cherry picked from commit 80afd02024d20e60b197d3adfbb43cc303cf29e0)

Change-Id: I905257a21de90b5860ebe1e39563758f721eab82
80afd02024d20e60b197d3adfbb43cc303cf29e0 19-May-2015 Vladimir Marko <vmarko@google.com> ART: Clean up arm64 kNumberOfXRegisters usage.

Avoid undefined behavior for arm64 stemming from 1u << 32 in
loops with upper bound kNumberOfXRegisters.

Create iterators for enumerating bits in an integer either
from high to low or from low to high and use them for
<arch>Context::FillCalleeSaves() on all architectures.

Refactor runtime/utils.{h,cc} by moving all bit-fiddling
functions to runtime/base/bit_utils.{h,cc} (together with
the new bit iterators) and all time-related functions to
runtime/base/time_utils.{h,cc}. Improve test coverage and
fix some corner cases for the bit-fiddling functions.

Bug: 13925192
Change-Id: I704884dab15b41ecf7a1c47d397ab1c3fc7ee0f7
094ff2c0c1f736521c634d5f606e274cb6c55345 13-May-2015 Sebastien Hertz <shertz@google.com> Fix debuggable compiler flag detection for secondary dex files

Compiles secondary dex files like the primary dex file: if it has
been compiled with the --debuggable flag, compile secondary dex files
with the --debuggable flag too.

Therefore, dex files loaded at runtime are compiled the same way as
dex files compiled at install time on the classpath (excluding the
boot image that is not compiled debuggable).

Also adds debuggable key in the oat header and bump the oat version.

Bug: 20944228

(cherry picked from commit 0de1133ba600f299b3d67938f650720d9f859eb2)

Change-Id: If6b2236e7fe547cc421f57b573043748018d3ae0
0de1133ba600f299b3d67938f650720d9f859eb2 13-May-2015 Sebastien Hertz <shertz@google.com> Fix debuggable compiler flag detection for secondary dex files

Compiles secondary dex files like the primary dex file: if it has
been compiled with the --debuggable flag, compile secondary dex files
with the --debuggable flag too.

Therefore, dex files loaded at runtime are compiled the same way as
dex files compiled at install time on the classpath (excluding the
boot image that is not compiled debuggable).

Also adds debuggable key in the oat header and bump the oat version.

Bug: 20944228
Change-Id: I59119f3468adb27ab1d6026f2cefbebbd814224c
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
c785344b87221f5e4e6473e5b762e4e61fe65dcf 27-Mar-2015 Mathieu Chartier <mathieuc@google.com> Move ArtField to native

Add linear alloc. Moved ArtField to be native object. Changed image
writer to put ArtFields after the mirror section.

Savings:
2MB on low ram devices
4MB on normal devices

Total PSS measurements before (normal N5, 95s after shell start):
Image size: 7729152 bytes
23112 kB: .NonMoving
23212 kB: .NonMoving
22868 kB: .NonMoving
23072 kB: .NonMoving
22836 kB: .NonMoving
19618 kB: .Zygote
19850 kB: .Zygote
19623 kB: .Zygote
19924 kB: .Zygote
19612 kB: .Zygote
Avg: 42745.4 kB

After:
Image size: 7462912 bytes
17440 kB: .NonMoving
16776 kB: .NonMoving
16804 kB: .NonMoving
17812 kB: .NonMoving
16820 kB: .NonMoving
18788 kB: .Zygote
18856 kB: .Zygote
19064 kB: .Zygote
18841 kB: .Zygote
18629 kB: .Zygote
3499 kB: .LinearAlloc
3408 kB: .LinearAlloc
3424 kB: .LinearAlloc
3600 kB: .LinearAlloc
3436 kB: .LinearAlloc
Avg: 39439.4 kB

No reflection performance changes.

Bug: 19264997
Bug: 17643507

Change-Id: I10c73a37913332080aeb978c7c94713bdfe4fe1c
e5fed03772144595c0904faf3d6974cc55214c8c 18-Mar-2015 Richard Uhler <ruhler@google.com> Support relative encoded dex locations in oat files.

Now when opening an oat file, the caller can pass an absolute dex
location used to resolve the absolute path for any relative
encoded dex locations in the oat file.

Bug: 19550105
Change-Id: I6e9559afe4d86ac12cf0b90176b5ea696a83d0e7
73ffc3e5b59bbc2ff5439d705b0876531ecb645b 19-Feb-2015 Andreas Gampe <agampe@google.com> ART: Check image size when opening

The image file might have been truncated. In that case, reject
loading the image space.

Bug: 19398702

(cherrypicked from commit beacd381dbdcc9f7f02b5e207037afb993aabba4)

Change-Id: I8e46340fe1e05629704d6e3bae84caf8b0435125
e5f13e57ff8fa36342beb33830b3ec5942a61cca 24-Feb-2015 Mathieu Chartier <mathieuc@google.com> Revert "Revert "Add JIT""

Added missing EntryPointToCodePointer.

This reverts commit a5ca888d715cd0c6c421313211caa1928be3e399.

Change-Id: Ia74df0ef3a7babbdcb0466fd24da28e304e3f5af
a5ca888d715cd0c6c421313211caa1928be3e399 24-Feb-2015 Nicolas Geoffray <ngeoffray@google.com> Revert "Add JIT"

Sorry, run-test crashes on target:
0-05 12:15:51.633 I/DEBUG (27995): Abort message: 'art/runtime/mirror/art_method.cc:349] Check failed: PcIsWithinQuickCode(reinterpret_cast<uintptr_t>(code), pc) java.lang.Throwable java.lang.Throwable.fillInStackTrace() pc=71e3366b code=0x71e3362d size=ad000000'
10-05 12:15:51.633 I/DEBUG (27995): r0 00000000 r1 0000542b r2 00000006 r3 00000000
10-05 12:15:51.633 I/DEBUG (27995): r4 00000006 r5 b6f9addc r6 00000002 r7 0000010c
10-05 12:15:51.633 I/DEBUG (27995): r8 b63fe1e8 r9 be8e1418 sl b6427400 fp b63fcce0
10-05 12:15:51.633 I/DEBUG (27995): ip 0000542b sp be8e1358 lr b6e9a27b pc b6e9c280 cpsr 40070010
10-05 12:15:51.633 I/DEBUG (27995):

Bug: 17950037
This reverts commit 2535abe7d1fcdd0e6aca782b1f1932a703ed50a4.

Change-Id: I6f88849bc6f2befed0c0aaa0b7b2a08c967a83c3
2535abe7d1fcdd0e6aca782b1f1932a703ed50a4 17-Feb-2015 Mathieu Chartier <mathieuc@google.com> Add JIT

Currently disabled by default unless -Xjit is passed in.

The proposed JIT is a method JIT which works by utilizing interpreter
instrumentation to request compilation of hot methods async during
runtime.

JIT options:
-Xjit / -Xnojit
-Xjitcodecachesize:N
-Xjitthreshold:integervalue

The JIT has a shared copy of a compiler driver which is accessed
by worker threads to compile individual methods.

Added JIT code cache and data cache, currently sized at 2 MB
capacity by default. Most apps will only fill a small fraction of
this cache however.

Added support to the compiler for compiling interpreter quickened
byte codes.

Added test target ART_TEST_JIT=TRUE and --jit for run-test.

TODO:
Clean up code cache.
Delete compiled methods after they are added to code cache.
Add more optimizations related to runtime checks e.g. direct pointers
for invokes.
Add method recompilation.
Move instrumentation to DexFile to improve performance and reduce
memory usage.

Bug: 17950037

Change-Id: Ifa5b2684a2d5059ec5a5210733900aafa3c51bca
5a2be3f40125af8b25fbbd9d55dc968168c76ed7 16-Feb-2015 Narayan Kamath <narayan@google.com> Implement a simple count based boot marker.

We write the number of failed boots to the marker and only
prune the dalvik cache if the number of consecutive failed
boots is higher than a predefined threshold.

Note that the code is forgiving of errors related to boot
markers; we continue the boot process even if we're unable
to create / write or flush the boot marker.

bug: 19360096
Change-Id: Ia17c3b783318ddf43c9199d0f7f09c54a4176667
6c8b49f2bf9c88ef8c38081b1459c73334967eb0 19-Feb-2015 Andreas Gampe <agampe@google.com> ART: Check image size when opening

The image file might have been truncated. In that case, reject
loading the image space.

Bug: 19398702
Change-Id: I8e46340fe1e05629704d6e3bae84caf8b0435125
a44bd82fd03089faf2f57185c2b4c8fa48ba0ecb 19-Nov-2014 Andreas Gampe <agampe@google.com> ART: Flush and close boot marker

Temporary fix.

Change-Id: I0a54d1562eb2081362c49b7b56c1ad0584c24bf5
28bc98705912efc27099ffc3a5415f6f941d2ab8 07-Nov-2014 Narayan Kamath <narayan@google.com> Prune image cache if the boot marker is still in place.

We place a marker in each isa cache dir and have the framework
delete it for us.

This seems like a convenient place to do it given all the other
dalvik-cache related code that hooks in here, and also because
this is the first point where we try to access the cache.

TODO: Add a timeout to the (higher level) zygote code to correctly
kill the surviving zygote if one of them never comes up.

bug: 18280671

(cherry picked from commit c38276177aeeda4326a54f1121790c154df04300)
(partial cherry-pick of 9433ec60b325b708b9fa87e699ab4a6565741494)

Change-Id: I5dbea21b4bf9ca4106a13225946d3f35f8060a43
9433ec60b325b708b9fa87e699ab4a6565741494 06-Nov-2014 Andreas Gampe <agampe@google.com> ART: Track Flush & Close in FdFile

Implement a check that aborts when a file hasn't been explicitly
flushed and closed when it is destructed.

Add WARN_UNUSED to FdFile methods.

Update dex2oat, patchoat, scoped_flock and some gtests to pass with
this.

Change-Id: I9ab03b1653e69f44cc98946dc89d764c3e045dd4
c38276177aeeda4326a54f1121790c154df04300 07-Nov-2014 Narayan Kamath <narayan@google.com> Prune image cache if the boot marker is still in place.

We place a marker in each isa cache dir and have the framework
delete it for us.

This seems like a convenient place to do it given all the other
dalvik-cache related code that hooks in here, and also because
this is the first point where we try to access the cache.

TODO: Add a timeout to the (higher level) zygote code to correctly
kill the surviving zygote if one of them never comes up.

bug: 18280671

Change-Id: I4d964adc826e62c29ab73a098474a116f9818366
d00804c6b7ebde7ffdd06037e93291efe867744d 10-Nov-2014 Andreas Gampe <agampe@google.com> ART: Prune links in the dalvik cache

When pruning the isa-specific directory of the cache, also remove
symbolic links.

Bug: 18035729
Bug: 18153744

(cherry picked from commit de5ed50940452f06b00514af0667972542ee5d59)

Change-Id: I84dbf578577b080785bbb81b660e4148bb512410
48447025389cd67605041a28d4ded1528381bc4e 22-Oct-2014 Igor Murashkin <iam@google.com> ART: Add support for patching and loading OAT files compiled with PIC

* Images (.art) compiled with pic now have a new field added.
* isDexOptNeeded will now skip patch-ing for apps compiled PIC
* First-boot patching now only copies boot.art, boot.oat is linked

As a result, all system preopted dex files (with --compile-pic) no
longer take up any space in /data/dalvik-cache/<isa>.

(cherry-picked from AOSP master
46774767fcf7780d1455e755729198648d08742e)

Conflicts (from aosp master):
compiler/image_test.cc
compiler/image_writer.cc
compiler/image_writer.h
compiler/oat_test.cc
dex2oat/dex2oat.cc
oatdump/oatdump.cc
runtime/elf_file.cc
runtime/elf_file.h
runtime/elf_file_impl.h
runtime/oat_file.cc
runtime/oat_file.h

Bug: 18035729

(cherry picked from commit 90ca5c0301651101de0e363842e5d08ae65233f7)

Change-Id: I8d99f95cc3d1fa221fc530ebb1fcc4b3263c183d
8db9dcdabfb8eb6be1211da6667bee889277223d 10-Nov-2014 Andreas Gampe <agampe@google.com> ART: Prune links in the dalvik cache

When pruning the isa-specific directory of the cache, also remove
symbolic links.

Bug: 18035729
Bug: 18153744
Change-Id: I40347ee77e95ff9fc8e6107ba661338f5c7b1db9
(cherry picked from commit de5ed50940452f06b00514af0667972542ee5d59)
de5ed50940452f06b00514af0667972542ee5d59 10-Nov-2014 Andreas Gampe <agampe@google.com> ART: Prune links in the dalvik cache

When pruning the isa-specific directory of the cache, also remove
symbolic links.

Bug: 18035729
Bug: 18153744
Change-Id: I40347ee77e95ff9fc8e6107ba661338f5c7b1db9
70be1fb17e5777f3a05dc86cfa8ee12cddb42698 01-Nov-2014 Andreas Gampe <agampe@google.com> ART: Discard generated image in a low-memory environment

In case the available memory after image generation is low,
discard the image and continue in interpreted mode to mitigate
low-mem issues.

Bug: 17975190

(cherry picked from commit e059b778a6a471455659eb8c3616858eb189fda8)

Change-Id: I9bbb5e52ffbf3570f85510efb76bcd7654e6951c
e059b778a6a471455659eb8c3616858eb189fda8 01-Nov-2014 Andreas Gampe <agampe@google.com> ART: Discard generated image in a low-memory environment

In case the available memory after image generation is low,
discard the image and continue in interpreted mode to mitigate
low-mem issues.

Bug: 17975190
Change-Id: I67a0f9c32a6c1f1a7ec659e90b1fec834a92d323
90ca5c0301651101de0e363842e5d08ae65233f7 22-Oct-2014 Igor Murashkin <iam@google.com> ART: Add support for patching and loading OAT files compiled with PIC

* Images (.art) compiled with pic now have a new field added.
* isDexOptNeeded will now skip patch-ing for apps compiled PIC
* First-boot patching now only copies boot.art, boot.oat is linked

As a result, all system preopted dex files (with --compile-pic) no
longer take up any space in /data/dalvik-cache/<isa>.

(cherry-picked from AOSP master
46774767fcf7780d1455e755729198648d08742e)

Conflicts (from aosp master):
compiler/image_test.cc
compiler/image_writer.cc
compiler/image_writer.h
compiler/oat_test.cc
dex2oat/dex2oat.cc
oatdump/oatdump.cc
runtime/elf_file.cc
runtime/elf_file.h
runtime/elf_file_impl.h
runtime/oat_file.cc
runtime/oat_file.h

Bug: 18035729
Change-Id: Ie1acad81a0fd8b2f24e1f3f07a06e6fdb548be62
e9105f708bbc5dba6ede5faa50e2a8b9b1b52ea7 28-Oct-2014 Brian Carlstrom <bdc@google.com> Work around relocated boot.oat corruption

Bug: 18143314

(cherry picked from commit 7dd7261845258b7c29b588829c80164b878f4424)

Change-Id: I70e708940663bf53ebe5320f53fd2dcebb0c623f
7dd7261845258b7c29b588829c80164b878f4424 28-Oct-2014 Brian Carlstrom <bdc@google.com> Work around relocated boot.oat corruption

Bug: 18143314
Change-Id: Ibecade061d6c887bde2f8a085ed7dede3345125a
efb9f850292a2ea5aae4ab56556c9ab25b308a96 25-Oct-2014 Andreas Gampe <agampe@google.com> ART: Fix ImageSpace error message.

Use *error_msg instead of error_msg.

(cherry picked from commit 50f2e9a6b935ba1c456a687e5f0822d9356d71e5)

Bug: 18143314
Change-Id: I62f6aeda142235eb1a412a4c1ae1104b813e6967
46774767fcf7780d1455e755729198648d08742e 22-Oct-2014 Igor Murashkin <iam@google.com> ART: Add support for patching and loading OAT files compiled with PIC

* Images (.art) compiled with pic now have a new field added.
* isDexOptNeeded will now skip patch-ing for apps compiled PIC
* First-boot patching now only copies boot.art, boot.oat is linked

As a result, all system preopted dex files (with --compile-pic) no
longer take up any space in /data/dalvik-cache/<isa>.

Bug: 18035729
Change-Id: Ie1acad81a0fd8b2f24e1f3f07a06e6fdb548be62
2f1e15cc3e169ac61b910c41d695e55671c8d4ca 28-Oct-2014 Brian Carlstrom <bdc@google.com> Remove boot.art/boot.oat on failure to create

Bug: 18143314

(cherry picked from commit a6b2affaf99e03f938f6f26e42606488d43f2efe)

Change-Id: Iac6d03d81997911f6707340487a26ee26a3aee27
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
a6b2affaf99e03f938f6f26e42606488d43f2efe 28-Oct-2014 Brian Carlstrom <bdc@google.com> Remove boot.art/boot.oat on failure to create

Bug: 18143314
Change-Id: I5f4733ed7f359158a2bda58ff4f228ba60e2f493
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
50f2e9a6b935ba1c456a687e5f0822d9356d71e5 25-Oct-2014 Andreas Gampe <agampe@google.com> ART: Fix ImageSpace error message.

Use *error_msg instead of error_msg.

Change-Id: Idabee3e4a66effd9f6346a2640a3038c5448889e
c7dd295a4e0cc1d15c0c96088e55a85389bade74 22-Oct-2014 Ian Rogers <irogers@google.com> Tidy up logging.

Move gVerboseMethods to CompilerOptions. Now "--verbose-methods=" option to
dex2oat rather than runtime argument "-verbose-methods:".
Move ToStr and Dumpable out of logging.h, move LogMessageData into logging.cc
except for a forward declaration.
Remove ConstDumpable as Dump methods are all const (and make this so if not
currently true).
Make LogSeverity an enum and improve compile time assertions and type checking.
Remove log_severity.h that's only used in logging.h.
With system headers gone from logging.h, go add to .cc files missing system
header includes.
Also, make operator new in ValueObject private for compile time instantiation
checking.

Change-Id: I3228f614500ccc9b14b49c72b9821c8b0db3d641
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
31d8f5295c24730a57cb36cbc41197f0b7e8397c 29-Sep-2014 Brian Carlstrom <bdc@google.com> Add VMRuntime.isBootClassPathOnDisk

Bug: 17679443

(cherry picked from commit 95a935415d44903b28326424beb4db5c013ef089)

Change-Id: Iba40291dead3f0b6715903c986370fd0cf1e41e1
95a935415d44903b28326424beb4db5c013ef089 29-Sep-2014 Brian Carlstrom <bdc@google.com> Add VMRuntime.isBootClassPathOnDisk

Bug: 17679443
Change-Id: I127ffdac3bfe731e9535dfe6a242eb950363d715
3c13a794845e0cf7887e33b2ec20de7e6ba85f8f 19-Sep-2014 Andreas Gampe <agampe@google.com> ART: Only allow the zygote to create the global boot image

Do not allow arbitrary processes, even when root, to write the
boot image in /data/dalvik-cache.

Bug: 17478752, 17510489, 17439961
Change-Id: Iba2b74be6d0752f4221f4ff5ee295b45a34cb2e1
(cherry picked from commit 33c36d4f22ab6a5e61eb47b654deaf647c34e49c)
33c36d4f22ab6a5e61eb47b654deaf647c34e49c 19-Sep-2014 Andreas Gampe <agampe@google.com> ART: Only allow the zygote to create the global boot image

Do not allow arbitrary processes, even when root, to write the
boot image in /data/dalvik-cache.

Bug: 17478752, 17510489, 17439961
Change-Id: Iba2b74be6d0752f4221f4ff5ee295b45a34cb2e1
6a6a896572a76e3871f5f6b2901e3bb5dec1e2f3 29-Aug-2014 Brian Carlstrom <bdc@google.com> Fix Mac build

Bug: 17000769,16875245

(cherry picked from commit debdda0262bfbcb966a89e693d933cc74eb412ac)

Change-Id: I158f090c89587f176813a15e9edad917bd134cd0
debdda0262bfbcb966a89e693d933cc74eb412ac 29-Aug-2014 Brian Carlstrom <bdc@google.com> Fix Mac build

Bug: 17000769,16875245
Change-Id: Id5ff133e0c6c56db6972a187773c7e873b7062ee
6c050b5f782b61a16083ae35c98931a2d51d0a33 29-Aug-2014 Alex Light <allight@google.com> Fix incorect variable name.

Bug: 16875245
(cherry picked from commit 1291e9bc87edc8fde56434bc66bef0c62d44a8e6)
Change-Id: Idd0f7ac677568a53569308a67f1ad613584949a5
1f0198162044d015072cbb7824f4a6688d0300ee 28-Aug-2014 Alex Light <allight@google.com> Change /dalvik-cache to be owned by root.

Also prune the dalvik-cache during startup if we need to generate or
relocate an image.

Bug: 17000769,16875245

(cherry picked from commit 2539613be94f599c1713627f80c7398028d1a6aa)

Change-Id: I29a70215a2207bc4e0db02ab751d32a68edf4b66
1291e9bc87edc8fde56434bc66bef0c62d44a8e6 29-Aug-2014 Alex Light <allight@google.com> Fix incorect variable name.

Bug: 16875245
Change-Id: Idd0f7ac677568a53569308a67f1ad613584949a5
2539613be94f599c1713627f80c7398028d1a6aa 28-Aug-2014 Alex Light <allight@google.com> Change /dalvik-cache to be owned by root.

Also prune the dalvik-cache during startup if we need to generate or
relocate an image.

Bug: 17000769,16875245

Change-Id: I29a70215a2207bc4e0db02ab751d32a68edf4b66
0699fbf769befd3a850005790b26941c38fa2fb4 21-Aug-2014 Alex Light <allight@google.com> Reduce log spam by changing a LOG(INFO) to VLOG(startup)

Bug: 17166556

(cherry picked from commit b6cabc1345ec307559a6e85141fb69b7caa9413c)

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

Bug: 17000769

(cherry picked from commit 64ad14dbe2225441fb7734bf6d89358d96692eea)

Change-Id: I6404d5050c8a2f4ee6e70d58532eb25ee9de248e
b6cabc1345ec307559a6e85141fb69b7caa9413c 21-Aug-2014 Alex Light <allight@google.com> Reduce log spam by changing a LOG(INFO) to VLOG(startup)

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

Bug: 17000769

Change-Id: I6404d5050c8a2f4ee6e70d58532eb25ee9de248e
345c4b19758703793ed31024cfb79940e2c63b75 18-Jul-2014 Alex Light <allight@google.com> Make system use patchoat to relocate during runtime.

Change dalvik_system_DexFile.cc so that isDexOptNeededInternal will be
able to indicate that a patchoat is required. Change default of relocate
option to be on.

Bug: 15358152

(cherry picked from commit 6e183f2e973a20f2eaca135c240908e1bf98c5d0)

Change-Id: Ib21f4f41b6cbf18094e3ca1a30d65a3b197b71b0
6e183f2e973a20f2eaca135c240908e1bf98c5d0 18-Jul-2014 Alex Light <allight@google.com> Make system use patchoat to relocate during runtime.

Change dalvik_system_DexFile.cc so that isDexOptNeededInternal will be
able to indicate that a patchoat is required. Change default of relocate
option to be on.

Bug: 15358152

Change-Id: Ibe92d8b55a24bbf718b0416a21b76e5df7a2de26
57309dbec7a119670bfae722f7399dd308042bbc 31-Jul-2014 Brian Carlstrom <bdc@google.com> Move image classes options from art to AndroidRuntime [art]

Bug: 15165413
Change-Id: I3dfa702ac29279cf76d4cc451138c03a5158ac3a
b93637a01831e697725753541083f04b1e2df6fb 31-Jul-2014 Alex Light <allight@google.com> Make ImageSpace skip validation if we are using a relocated image

Change-Id: I0682d1870f5b3e27adb9c9de803fbb7d364ad00d
1a762136398ffa4ed2c366d344b45ca4244d6c6c 31-Jul-2014 Alex Light <allight@google.com> Fix image not regenerating on changes to bootclasspath

Bug: 16367410
Change-Id: I10e81d068ffc2ab712a287f88ef67f6a1be4df4c
cf4bf386ef3f527825c70e01130b9276da4f786a 24-Jul-2014 Alex Light <allight@google.com> Tweaks to patchoat and other related things.

Removed some flags from patchoat that were poorly specified and fixed
some other issues with the relocation system.

Bug: 15358152

Change-Id: Ia6d47b1a008f02373307d833ba45f00ea408d76f
45232a423e8ceb64abf51100c26b693781c0d897 22-Jul-2014 Andreas Gampe <agampe@google.com> ART: Fix checks for relocation delta

Change < to <= and > to >=.

Change-Id: I7579e3c13dc1b33801ace3a0f8d85cadaee41e6e
a59dd80f9f48cb750d329d4d4af2d99d72b484d1 03-Jul-2014 Alex Light <allight@google.com> Runtime can now be set to require relocation

Add a pair of runtime flags -Xrelocate and -Xnorelocate that can force
the runtime to require that all files that are run are relocated, to
prevent attacks based on the known art base address.

Add support for running patchoat on oat files compiled without an image.

Change run-test to have new --prebuild and --relocate flags.

Bug: 15358152

Change-Id: I91166c62dd1ab80e5cbcb7883a2cd0d56afca32d
22f8e5c82d12951be38cd893426e13bee33fd69d 09-Jul-2014 Andreas Gampe <agampe@google.com> Revert "Revert "ART: Key-Value Store in Oat header""

This reverts commit 452bee5da9811f62123978e142bd67b385e9ff82.

Heap-allocate a couple of objects in dex2oat to avoid large frame
size.

Includes fixes originally in 100596 and 100605.

Change-Id: Id51a44198c973c91f0a3f87b9d992a5dc110c6f8
c87d27b25994da8670d82a8f7bad6327b693bfff 27-Jun-2014 Andreas Gampe <agampe@google.com> ART: Key-Value Store in Oat header

Allows the storage of string-string pairs in the oat header. The
first significant use of this is storing the implicit-check flags,
so that an oat file can be rejected if it doesn't agree with the
current runtime.

Bump the oat version as the header structure changes.

Change-Id: I15a1c16886e6b8fa7b881c918c19c1efa5c7c00f
670134e8555d40fc880271b1ab97483094b4b816 08-Jul-2014 Brian Carlstrom <bdc@google.com> Make dex2oat heap size product configurable [art]

Bug: 15919420
Change-Id: I1b4f3256f6352b2d3e268991406def9e8efab945
452bee5da9811f62123978e142bd67b385e9ff82 09-Jul-2014 Nicolas Geoffray <ngeoffray@google.com> Revert "ART: Key-Value Store in Oat header"

Broke arm64 build.

This reverts commit c87d27b25994da8670d82a8f7bad6327b693bfff.

Change-Id: I4c2ade295d2b5aa77fc3ad810e0e859629a5bf09
d1c606f280797be81e2592c483869a6ec836a9f3 09-Jun-2014 Narayan Kamath <narayan@google.com> Add locking around boot image generation.

If zygote aborts due to an error, it will restart and
spawn another dex2oat process while the old one is still
running. If this happens fast enough, the system will
eventually need a kernel reboot since neither the zygote
nor dex2oat are killable.

This brings boot image generation in line with dex2oat
generation, which uses a similar pattern of advisory
locking.

bug: 15415316

Change-Id: Iaccd274d3d96ab002b04e246ec4b3ef9a422ff7c
ffddfdf6fec0b9d98a692e27242eecb15af5ead2 03-Jun-2014 Tim Murray <timmurray@google.com> DO NOT MERGE

Merge ART from AOSP to lmp-preview-dev.

Change-Id: I0f578733a4b8756fd780d4a052ad69b746f687a9
12e6d7446384a7a5fbec25fe116bbb271c62842e 22-May-2014 Tsu Chiang Chuang <tsu@google.com> Add option to specify compiler executable.

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

Change-Id: I4858d9cbed95e5ca560956b9dabd976cebe68333
bd0fb61e24270b1f382ecbef4c1260c703550e84 20-May-2014 Hiroshi Yamauchi <yamauchi@google.com> Simplify Class::IsArtFieldClass().

Fix the slight glitch that when ImageSpace::VerifyImageAllocations()
called in ImageSpace::Create(), the ArtField and ArtMethod class roots
weren't set, which were used by DCHECKs in Object::Size(), which
VerifyImageAllocations() calls, by delaying the point of the
VerifyImageAllocations() call to Runtime::Init() at which point the
class linker has set the class roots.

To completely disable read barriers from Object::SizeOf(), the
ReadBarrierOption template parameter should have been added to
Class::GetInstanceField(), which calls GetFieldObject(), when it's
called from Class::IsArtFieldClass(). This change fixes this by
removing the need for the call, instead of adding the
ReadBarrierOption parameter.

Bug: 12687968
Change-Id: Ibbecc08f4e3b898851805d690dff8ccac55e94f2
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
0e12bdc49744eb6d5c29b9611a8dbe10bac4cd53 15-May-2014 Brian Carlstrom <bdc@google.com> Add ISA directory to image and odex pathnames.

Bug: 14882223
Bug: 14694978
Change-Id: Ic1b5ae836b8e91ea461dcd4f3da8e38dc3bec00f
7624d25dad2d1ba25969ae704fccf68649103ae5 02-May-2014 Vladimir Marko <vmarko@google.com> Move quick frame info to OatQuickMethodHeader.

Rename OatMethodHeader to OatQuickMethodHeader, move frame
info from OatMethodOffsets to OatQuickMethodHeader. Retrieve
the info from other places for non-quick methods (portable
compiled bytecode or jni stub, generic jni, runtime,
abstract and proxy).

This change has a libcore/ companion CL
"Remove ArtMethod's quick fields for frame size and spills."
https://android-review.googlesource.com/94164

Bug: 11767815
Change-Id: I0e31a7875d76732e1ec479c86b9b5ca01203507f
b9beb2e2efb6a204a69ca660d478b45f851e8f09 10-May-2014 Ian Rogers <irogers@google.com> Place ISA into boot image name.

Depends upon:
https://android-review.googlesource.com/94078

Change-Id: I22c18b03b2c0db7a3f792920064e7710363b58b4
52f84884433f3875f4b1bc5595b8d5a2d6fb3d99 02-May-2014 Narayan Kamath <narayan@google.com> Prevent spurious dexopts in 32-64 builds.

When we're checking if a file needs to be dexopted, we
need to compare oat file checksums with the image checksum
for the oat file's target instruction set and not the current
runtime's target instruction set.

bug:14475807

Change-Id: Ib44d8e3c6cdf3a37fce6332c694a6602c658e925
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
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
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
8afeb85d3def12b559b7565fb6d3956f81b55132 02-Apr-2014 Ian Rogers <irogers@google.com> Pass instruction-set from runtime through to spawned dex2oat.

Change-Id: I1727af7beb9f710c29124d4d6bc9175e4856f3cc
624468cd401cc1ac0dd70c746301e0788a597759 01-Apr-2014 Hiroshi Yamauchi <yamauchi@google.com> Make the support code for read barriers a bit more general.

Add an option for Baker in addition to Brooks.

Bug: 12687968
Change-Id: I8a31db817ff6686c72951b6534f588228e270b11
4fb5df8453367aa3f160ac230c03a7a98a28e562 13-Mar-2014 Hiroshi Yamauchi <yamauchi@google.com> Make MemMap::MapAnonymous() fail if the requested address is not available.

Change MapAnonymous() so that a requested address vs. actual map
address mismatch will cause a failure. The existing MapAnonymous()
call sites do not check this. This should prevent potential rare case
bugs where mmap does not happen to map a region at an specified
address.

There's a potential bug that if MapAnonymous() does not guarantee the
requested address (and there's a gap between the image/oat files and
the zygote/malloc space), then GC could in theory allocate a large
object space in the gap. This would break the GC notion of the immune
space. This change will prevent this by causing all non-moving spaces
to be (really) adjacent, with no gaps in between, which CL 87711
missed.

Change-Id: Id4adb0e30adbad497334d7e00def4c0c66b15719
b373e091eac39b1a79c11f2dcbd610af01e9e8a9 21-Feb-2014 Dave Allison <dallison@google.com> Implicit null/suspend checks (oat version bump)

This adds the ability to use SEGV signals
to throw NullPointerException exceptions from Java code rather
than having the compiler generate explicit comparisons and
branches. It does this by using sigaction to trap SIGSEGV and when triggered
makes sure it's in compiled code and if so, sets the return
address to the entry point to throw the exception.

It also uses this signal mechanism to determine whether to check
for thread suspension. Instead of the compiler generating calls
to a function to check for threads being suspended, the compiler
will now load indirect via an address in the TLS area. To trigger
a suspend, the contents of this address are changed from something
valid to 0. A SIGSEGV will occur and the handler will check
for a valid instruction pattern before invoking the thread
suspension check code.

If a user program taps SIGSEGV it will prevent our signal handler
working. This will cause a failure in the runtime.

There are two signal handlers at present. You can control them
individually using the flags -implicit-checks: on the runtime
command line. This takes a string parameter, a comma
separated set of strings. Each can be one of:

none switch off
null null pointer checks
suspend suspend checks
all all checks

So to switch only suspend checks on, pass:
-implicit-checks:suspend

There is also -explicit-checks to provide the reverse once
we change the default.

For dalvikvm, pass --runtime-arg -implicit-checks:foo,bar

The default is -implicit-checks:none

There is also a property 'dalvik.vm.implicit_checks' whose value is the same
string as the command option. The default is 'none'. For example to switch on
null checks using the option:

setprop dalvik.vm.implicit_checks null

It only works for ARM right now.

Bumps OAT version number due to change to Thread offsets.

Bug: 13121132
Change-Id: If743849138162f3c7c44a523247e413785677370
c7cb1901b776129044a4ad3886fd6450e83df681 05-Mar-2014 Mathieu Chartier <mathieuc@google.com> Print error message if ImageSpace::Init fails.

Also changed some of the args in mem_map.cc to print as hex.

Bug: 13323732

Change-Id: I02cd81300793515d143e94473f48fc701e401b38
2ec6520d57479d393bffa05defa1479b25ca8382 04-Mar-2014 Brian Carlstrom <bdc@google.com> Support compiler filters for boot classpath

image_writer.cc
Remove assumption that all methods in the boot classpath are compiled

oat_writer.cc
Don't skip writing ArtMethod::quick_code_offset_ for methods that need resolution, leave that to ImageWriter

dex2oat.cc
Allow dex2dex compilation of image dex files by making the in memory pages writable in all cases, not just app case.

oatdump.cc
dump new OatHeader fields
use ImageSpace.GetImageFilename, not command line image filename, since location may be in dalvik-cache
remove inaccurate check about non-null GC map

quick_trampoline_entrypoints.cc
add and improve some DCHECKS that were useful while debugging

class_linker.cc
image_space.cc
fix double facepalm

parsed_options.cc
fix zygote logging to not skip values to two part options like -classpath <foo>

runtime.cc
wireup parsed compiler options to runtime

Change-Id: Iad314df0b80623c0663d61713d5098297ab9ac87
9583fbcf597eff6d0b3c5359b8e8d5f70ed82c40 28-Feb-2014 Nicolas Geoffray <ngeoffray@google.com> Remove oat file location in the image.

The oat file is now always in the same directory, and has the
same name as the image file. Only difference is the extension.

This also removes the need for host-prefix.

Change-Id: I16d1f7aeb1d58372d41921694664e9c321afc1ad
9d04a20bde1b1855cefc64aebc1a44e253b1a13b 31-Jan-2014 Hiroshi Yamauchi <yamauchi@google.com> (Experimental) Add Brooks pointers.

This feature is disabled by default.

Verified that the Brooks pointers are installed correctly by using the
CMS/SS collectors.

Change-Id: Ia9be9814ab6e29169ac85edc4792ce8c81d552a9
4cf5e57b5ec366b8730dacd45e8011e5f9b07b6d 25-Feb-2014 Brian Carlstrom <bdc@google.com> Move waitpid(2) includes to art::Exec implementation

(cherry picked from commit 446a13ff04dae7ef9c90584e7cf8e834ee841681)

Change-Id: Id5fe3dd8e6c4cef953c39b00f2a53b23da5a6247
6449c62e40ef3a9bb75f664f922555affb532ee4 11-Feb-2014 Brian Carlstrom <bdc@google.com> Create CompilerOptions

Package up most compiler related options in CompilerOptions. Details include:
- Includes compiler filter, method thresholds, SEA IR mode.
- Excludes those needed during Runtime::Init such as CompilerCallbacks and VerificationResults.
- Pass CompilerOptions to CompilerDriver.
- Remove CompilerOptions from Runtime.
- Add ability to pass options for app and image dex2oat to runtime via
-Xcompiler-option and -Ximage-compiler-option respectively.

Other
- Replace 2x CompilerCallbacks implementations with one.
- Factor out execv code for use by both image and oat generation.
- More OatFile error_msg reporting.
- DCHECK for SuspendAll found trying to run valgrind.

Change-Id: Iecb57da907be0c856d00c3cd634b5042a229e620
97f4489166ae31c12d35ad3f550a5fc8d143b4fa 15-Feb-2014 Ian Rogers <irogers@google.com> Revert "Revert "Revert "Add a script for running art standalone."""

This reverts commit 4b23250f4cbf3047924c646c1a0c078394f8362d.

Change-Id: Ib749a8267abf35e51552b741ba749d6ed6975f95
4b23250f4cbf3047924c646c1a0c078394f8362d 13-Feb-2014 Nicolas Geoffray <ngeoffray@google.com> Revert "Revert "Add a script for running art standalone.""

This reverts commit 41dcb9f856a2051527cd595f8fe7d200066acba4.

Change-Id: Ide6fa696c6fb43fe17e0993e8c9d1b588c99b1f3
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
b122a4bbed34ab22b4c1541ee25e5cf22f12a926 20-Nov-2013 Ian Rogers <irogers@google.com> Tidy up memory barriers.

Change-Id: I937ea93e6df1835ecfe2d4bb7d84c24fe7fc097b
590fee9e8972f872301c2d16a575d579ee564bee 13-Sep-2013 Mathieu Chartier <mathieuc@google.com> Compacting collector.

The compacting collector is currently similar to semispace. It works by
copying objects back and forth between two bump pointer spaces. There
are types of objects which are "non-movable" due to current runtime
limitations. These are Classes, Methods, and Fields.

Bump pointer spaces are a new type of continuous alloc space which have
no lock in the allocation code path. When you allocate from these it uses
atomic operations to increase an index. Traversing the objects in the bump
pointer space relies on Object::SizeOf matching the allocated size exactly.

Runtime changes:
JNI::GetArrayElements returns copies objects if you attempt to get the
backing data of a movable array. For GetArrayElementsCritical, we return
direct backing storage for any types of arrays, but temporarily disable
the GC until the critical region is completed.

Added a new runtime call called VisitObjects, this is used in place of
the old pattern which was flushing the allocation stack and walking
the bitmaps.

Changed image writer to be compaction safe and use object monitor word
for forwarding addresses.

Added a bunch of added SIRTs to ClassLinker, MethodLinker, etc..

TODO: Enable switching allocators, compacting on background, etc..

Bug: 8981901

Change-Id: I3c886fd322a6eef2b99388d19a765042ec26ab99
88474b416eb257078e590bf9bc7957cee604a186 24-Oct-2013 Jeff Hao <jeffhao@google.com> Implement Interface Method Tables (IMT).

Change-Id: Idf7fe85e1293453a8ad862ff2380dcd5db4e3a39
8d31bbd3d6536de12bc20e3d29cfe03fe848f9da 13-Oct-2013 Ian Rogers <irogers@google.com> Throw IOException at source of failing to open a dex file.

Before is:
java.lang.ClassNotFoundException: Didn't find class "GCBench" on path: DexPathList[[zip file "/disk2/dalvik-dev/out/host/linux-x86/framework/GCBench.jar"],nativeLibraryDirectories=[/disk2/dalvik-dev/out/host/linux-x86/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
Suppressed: java.lang.ClassNotFoundException: GCBench
at java.lang.Class.classForName(Native Method)
at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
... 1 more
Caused by: java.lang.NoClassDefFoundError: Class "LGCBench;" not found
... 5 more
And after is:
java.lang.ClassNotFoundException: Didn't find class "GCBench" on path: DexPathList[[zip file "/disk2/dalvik-dev/out/host/linux-x86/framework/GCBench.jar"],nativeLibraryDirectories=[/disk2/dalvik-dev/out/host/linux-x86/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
Suppressed: java.io.IOException: Zip archive '/disk2/dalvik-dev/out/host/linux-x86/framework/GCBench.jar' doesn't contain classes.dex
at dalvik.system.DexFile.openDexFile(Native Method)
at dalvik.system.DexFile.<init>(DexFile.java:80)
at dalvik.system.DexFile.<init>(DexFile.java:59)
at dalvik.system.DexPathList.loadDexFile(DexPathList.java:268)
at dalvik.system.DexPathList.makeDexElements(DexPathList.java:235)
at dalvik.system.DexPathList.<init>(DexPathList.java:113)
at dalvik.system.BaseDexClassLoader.<init>(BaseDexClassLoader.java:48)
at dalvik.system.PathClassLoader.<init>(PathClassLoader.java:38)
at java.lang.ClassLoader.createSystemClassLoader(ClassLoader.java:128)
at java.lang.ClassLoader.access$000(ClassLoader.java:65)
at java.lang.ClassLoader$SystemClassLoader.<clinit>(ClassLoader.java:81)
at java.lang.ClassLoader.getSystemClassLoader(ClassLoader.java:137)
Suppressed: java.lang.ClassNotFoundException: GCBench
at java.lang.Class.classForName(Native Method)
at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
... 1 more
Caused by: java.lang.NoClassDefFoundError: Class "LGCBench;" not found
... 5 more

Also, move dex file verifier messages out of logs.
In the process the ClassLinker::dex_lock_ needed tidying to cover a smaller
scope. Bug 11301553.

Change-Id: I80058652e11e7ea63457cc01a0cb48afe1c15543
7c3d13aebdd8611cae58a1048bffb13cbdc465cb 05-Sep-2013 Brian Carlstrom <bdc@google.com> Use file magic to determine file type, not file extension.

Bug: 10614658
Change-Id: I9156dfca78ac8cd1c62fb258825cc791629270a4
31e8925781c2302f1d1a9b39e216ba415bfe0d7e 28-Aug-2013 Mathieu Chartier <mathieuc@google.com> Write out image bitmap inside of image file.

We now create the image bitmap when we generate the image. The image
bitmap is written after the image inside of the image file. This
speeds up dex2oat by making walking the image during heap creation
unnecessary. This should also help memory pressure by enabling the
image bitmap to be swappable.

Bug: 10432288

Change-Id: Idebf459ed15edbb41a7d9b9b353934155bce2f19
414af10d719603fb4d8d972f5a022c17957b44e1 13-Aug-2013 Brian Carlstrom <bdc@google.com> Add flock(2)ing on dex-cache files to prevent races

Bug: 9071417
Change-Id: I1ee9ff281867f90fba7a8ed8bbf06b33ac29d511
7571e8b761ebc2c923525e12ea9fcf07e62cb33e 13-Aug-2013 Brian Carlstrom <bdc@google.com> Add flock(2)ing on dex-cache files to prevent races

Bug: 9071417
Change-Id: I1ee9ff281867f90fba7a8ed8bbf06b33ac29d511
ea46f950e7a51585db293cd7f047de190a482414 30-Jul-2013 Brian Carlstrom <bdc@google.com> Refactor java.lang.reflect implementation

Cherry-picked from commit ed41d5c44299ec5d44b8514f6e17f802f48094d1.

Move to ArtMethod/Field instead of AbstractMethod/Field and have
java.lang.reflect APIs delegate to ArtMethod/ArtField.

Bug: 10014286.

Change-Id: Iafc1d8c5b62562c9af8fb9fd8c5e1d61270536e7
e5426c9995d28bcb19391d8dbf0ad70606cf1770 01-Aug-2013 Mathieu Chartier <mathieuc@google.com> Fix histogram memory issues.

Before we had buckets of 5 micro second size. For a 100 MS GC
this used at least 16 * (100 / .005) bytes of storage inside of the
histogram data structure. If you consider the 3 different GC types,
and each timing logger having its own histogram its easy to see
how memory used was significant.

We now have an upper bound on the number of buckets (default 100).
When we hit the upper bound we simply combine adjacent buckets
together. This reduces the total number of buckets by a factor of
2, while increasing the bucket size by a factor of 2. This means
that we may lose a slight amount of precision, but the confidence
intervals remain nearly as useful.

Total unknown memory (occam-svelte):
Before: 45648 kB:
After: 33304 kB

There are probably still some additional optimizations which can be
done as disabling histograms altogether reduces the memory used by
another ~2mB.

A bit of other cleanup in image_space.cc and dlmalloc_space.cc.

Bug: 9967927

Change-Id: I87bb6fe4a3e0e790f104abf3cf07f67677cd7ab3
08d7d44bc33a7251ff34287422c7751c5a65683d 01-Aug-2013 Mathieu Chartier <mathieuc@google.com> Fix image generation.

Small error passing wrong program in, tests and clean-oat didn't
catch for some reason.

Change-Id: Id4eab9e700b50ed76f98b66d55cca9d8ab93c70e
8bbc8c0ac51dbb61535016872e8389620c49982a 01-Aug-2013 Mathieu Chartier <mathieuc@google.com> Fix mismatched malloc / delete.

Removed all the strdup, we now convert a string vector to a vector
of char* right before doing the fork.

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