History log of /art/runtime/class_linker.cc
Revision Date Author Comments
f5f462b8e448c13d30094d0d259d8b06bc525376 15-Dec-2016 Calin Juravle <calin@google.com> Add Thread entry to signal if the thread can call into java

Compiler threads (AOT or JIT) should not call into Java as they have no
peers (which may lead to crashes, e.g. b/33067273)

(cherry picked from commit ccd56958eb46fbb00c1eb45c7a7b23d5bbfd7698)

Bug: 32602185
Bug: 33067273

Test: m test-art-host-run-test; m test-art-host-gtest
Change-Id: I97dda7a5444643db3c5d5318339a65a602f709e8
40d4c7636e51f910b2c9ef226b7183e6ccc9ab4b 08-Nov-2016 neo.chae <neo.chae@lge.com> Add visiting for class loaders in StickyMarkSweep

StickyMarkSweep clear the mark stack,
Because all reachable objects must be referenced by a root or a dirty card.
But, there are some marking hole for class object.

If some object is marked and the object and it's class object is not dirty,
Then class object cannot be marking by card table.

In previous OS including mashmellow,
Class table was maintaned by class linker
and all class object was marked with kVisitRootFlagAllRoots flag.

In N OS,
Class object is not marked with kVisitRootFlagAllRoots.
So, I added new flag to mark class object and using it StickyMarkSweep.

Added regression test in 141-class-unload.

Test: test-art-host
Merged-In: I57599e6db53b260f4c5ef466b63962141b8da5c3

(cherry picked from commit a2d1b28599e38ee0180f0f7130a879eac5be9dec)

Bug: 33924225

Change-Id: I57599e6db53b260f4c5ef466b63962141b8da5c3
Signed-off-by: Hyangseok Chae <neo.chae@lge.com>
b47a1cc17f53951b900e56bb68c58c972517cb07 07-Sep-2016 Alex Light <allight@google.com> Fix vtable corruption issue

We were adding duplicate methods to the vtable in some cases where
default methods (and conflict methods) were used. This caused issues
where they were not correctly overridden in subclasses that implement
these methods directly. When overridden only one of the vtable entries
was updated meaning it was still possible to reach the overridden code
using a virtual call.

This change prevents the duplicate methods from being added to the
vtable in this circumstance. It also adds a debug check that ensures
that the vtable has no duplicates to prevent regressions.

Bug: 31280371

Test: mma test-art-host
Test: mma test-art-host-run-test-960-default-smali

Change-Id: I17d88fb8949c8d5d75b4de3c734fd98660b81e61
(cherry picked from commit 1f3925d4f067438d3689ef2736fd2af063c98668)
db16f2a0a71503fe046e41fb8d249a1a25e0658e 05-Aug-2016 Mathieu Chartier <mathieuc@google.com> Card mark holding class instead of declaring class

For profiling info, we need to mark the card of the holding class
instead of declaring class. This is required for GC correctness since
the GC relies on the card table to track cross space references.

Test: test-art-host ART_TEST_JIT=true

Bug: 30655270

(cherry picked from commit 65975776f807d55c83af6cca1e447f8daa794413)

Change-Id: I3de518693d3cac1ad9770eae671db740ebdf1d8d
23da026ec7a7fae22833ed2f61a80d9f9bf7e732 30-Jul-2016 Mathieu Chartier <mathieuc@google.com> Revert "Revert "Use try lock to fix class resolution race""

Fix possible deadlock in EnsureResolved caused by interaction with
GC. Since we were sleeping while holding the mutator lock, it could
block thread suspension. This would deadlock if the thread that
had locked h_class is already suspended since we would spin forever
and not make progress.

Bug: 27417671
Bug: 30500547

Test: test-art-host ART_TEST_GC_STRESS=true

This reverts commit 69bf969c055c31a75d17ea92aeee756042678114.

(cherry picked from commit 4b0ef1c980a1f3b0201d77e33bdb2f7df12c9114)

Change-Id: If5766c2c3c8a130cbb83735cdb9970038570dafd
adc538a57ad1f771051cd52afc216c3e5f0270cd 29-Jul-2016 Mathieu Chartier <mathieuc@google.com> Revert "Use try lock to fix class resolution race"

This reverts commit a704eda0078989a73cac111ed309aca50d2e289b.

Bug: 27417671
Bug: 30500547

(cherry picked from commit 69bf969c055c31a75d17ea92aeee756042678114)

Change-Id: I4354d1c9f1c554f054e99efd7aa52d8a2c5d402c
1386f8619bb9cd338e51a9b6b5121bc8443bda76 13-Jul-2016 Mathieu Chartier <mathieuc@google.com> Use try lock to fix class resolution race

There was some possible deadlocks related to EnsureResolved caused by
acquiring an object lock.

Scenario:
Thread 1 acquires lock on obj1
Thread 1 begins to resolve / initialize class1
Thread 1 blocks since it sees that class1 is already being resolved and
gets preempted before it can acquire the object lock on class1
Thread 2 finishes resolving and initializing class1 and locks class1
Thread 2 blocks attempting to lock obj1
Thread 1 blocks attempting to lock class1
Deadlock

Fixed the deadlock by changing EnsureResolved to use a try lock for the
unresolved case.

Added a test.

Test: Device boot, test-art-host, monitor_test

Bug: 27417671

(cherry picked from commit a704eda0078989a73cac111ed309aca50d2e289b)

Change-Id: I1150b19bdc1a5cc87ae95eda4f2b6b4bca215a60
5464c73567ccccd0cda6449d2a2775814d5fe88d 10-Aug-2016 Mathieu Chartier <mathieuc@google.com> Fix pending exception failure for encoded statics

ReadValueToField may allocate a string and cause OOME, we were
not checking this each loop iteration. Throwing an exception
with a pending exception causes an abort.

Bug: 30690988

Test: test-art-host

(cherry picked from commit da595bec0f9af0b087822e4febc282fe8ec28192)

Change-Id: I4701a4dcc63553aeb5c7970f99fd7f136443b266
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
c9dbb1df3b5c06ba122cacaf35b17cb53c6be3c6 04-Jun-2016 Mathieu Chartier <mathieuc@google.com> Revert "Revert "Hold dex caches live in class table""

Bug: 29083330

This reverts commit f102faf1bcbdb2149e3e7bf27b1819f621b7894b.

Change-Id: Ibc6d260247b3113beec7d33552061512a36c9ce8
f102faf1bcbdb2149e3e7bf27b1819f621b7894b 04-Jun-2016 Brian Carlstrom <bdc@google.com> Revert "Hold dex caches live in class table"

This reverts commit d6d49e56c2b7b11f474acb80cb02bb1fe9b7861e.

Bug: 29083330
Change-Id: Ie209b27897b8079f2d13fd0837fe5f83a7e61afc
d6d49e56c2b7b11f474acb80cb02bb1fe9b7861e 02-Jun-2016 Mathieu Chartier <mathieuc@google.com> Hold dex caches live in class table

Prevents temporary dex caches being unloaded for the same dex file.
Usually this is OK, but if someone resolved a string in that dex
cache, it could leave stale pointers in BSS. Also it can use extra
memory in linear alloc if we allocate dex cache arrays multiple
times.

Bug: 29083330

(cherry picked from commit f284d448e3edd428b6ade473d0993028638b2064)

Change-Id: Ie1b0b0cf835a998e19227cbb90014011a6cd40c4
fe179c2b28b3d9edbaa6549cb829ebd3ddce8c4f 01-Jun-2016 Mathieu Chartier <mathieuc@google.com> Fix race with host_dlopen_handles_

Thread 1 opens an already opened oat file.
Thread 2 dlcloses the oat file and removes it from
host_dlopen_handles_.
Thread 1 checks that it is not already in host_dlopen_handles_ and
proceeds to return the oat file. The problem now is that the BSS is
not cleared since it is the same oat file that was opened earlier.

The fix is to just hold the lock for dlopen / dlclose. This only
affects contention on host.

Bug: 28992179
Bug: 28990799
Bug: 28826195

(cherry picked from commit c7d3f4b8c294f36209ea2c129f9714a36ae1ec6b)

Change-Id: Ib462720fab26427d8ca0c6323080604878edb8b5
55accd5725442026c8c32dc773b1cd12a65f90f6 25-May-2016 Mathieu Chartier <mathieuc@google.com> Fix broken DCHECK

Dex cache may now contain references into boot image. Only check
classes that are actually in the application image.

Bug: 28295348

Change-Id: I9d92137c99a53924b13182ded6afabdeb441437d
1df3b55abea375671b79e3f4e6851be757a2d8a7 26-Apr-2016 Nicolas Geoffray <ngeoffray@google.com> Put boot class loader classes and strings in dex cache of app images.

The reason for b/28295348 was that an ArtMethod of the boot image was
in the app image dex cache, but the declaring class of that
boot image method was not.

Since objects of boot images don't need fixups, the comparisons for
FixupStrings and FixupResolvedTypes was always false for them.

bug:28295348

Change-Id: Ida6d42c902692914c302b7fe3d003f73710de6e1
22bd2a1b5ec2a5038cc3ae1964781f30aef0315f 19-May-2016 Mathieu Chartier <mathieuc@google.com> Only fill methods with 0xFE on debug builds

The GC scans classes without holding any locks, we can not fill
the methods if it is running. Added a GC critical section to address
this. Fixes random crash when scanning classes' methods.

Only for debug builds to not hurt performance.

Bug: 28699001
Change-Id: If96155eaf3fc0e6df31f57dcf32fbd4063b09345
90328ac545f65759a8e4fb217a75332906795518 18-May-2016 Roland Levillain <rpl@google.com> Catch classes inheriting from themselves in the class linker.

Bug: 28685551
Bug: 27682580
Bug: 28830038

Change-Id: If568013bf3c82c1df9b282522712d9af5ca5945d
92091bde26fb9fc54b7e5f459b696d4b88ea30de 11-May-2016 Mathieu Chartier <mathieuc@google.com> Prevent ArtMethod clearing race

There was race condition where the GC would be visiting the methods
of a class while the class linker overwrote the contents with 0xFE
when copying to a new array.

Since the GC is holding the class table lock at this time, we can
use this lock in the class linker to prevent the race.

Bug: 28699001

(cherry picked from commit 10c5f56423feaf3eadb3d4c09c61d2b998404162)

Change-Id: I5ddca93106cb8e48962cf44e5ce434c45e05cd0c
b554343e1d72104f0b26e749c1877d0566667a85 03-May-2016 Alex Light <allight@google.com> Fix vtable corruption.

Due to failing to keep track of superclass implementations of
interface methods we could end up in situations where methods were
placed onto a class's vtable multiple times. This could cause virtual
and interface dispatches on subclasses to fail by causing corruption
of the subclass's vtable and iftable.

Bug: 28333278

(cherry picked from commit d6c2bfaff8850a9a02ee9b75cf8c96eadd8d5c69)

Change-Id: I37d9740ca912daf37cdf9ff82697bbc5db46177a
9275af6ec0d71d1a13a97a1d292806b73f755717 29-Apr-2016 Mathieu Chartier <mathieuc@google.com> Fix profile saver to use base dex location

Previously we were using the dex location. This only matches the
base location for the main dex file, and resulted in only the
main dex file to have classes recorded.

Bug: 28463739

Change-Id: I0117352150c7244dd048338dbb677abdd4554eb0
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
5872d7cd6ceffe67550d0b021191ec66f1a34c5d 27-Apr-2016 Jeff Hao <jeffhao@google.com> Support to pass <uses-library> option through to dex2oat.

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

Part of a multi-project change.

Includes fix from a6d46161aea07ebd1cbd6ab78b2b323f940e9c1e

Bug: 26880306

(cherry-picked from commit 26e8a2f150cd7f7195a10650ab8a5b6fa5014bc8)

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

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

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

Bug: 27916886
Change-Id: I6e4768dc5d58f2f85f947b276b4244aa11ce3fca
49b5cede15d69930a8c156a3aea240164ca7af80 14-Apr-2016 Mathieu Chartier <mathieuc@google.com> Add support for eagerly calculating conflict tables

Will be used to put them in the image by having the compiler eagerly
calculate them.

Enabled for debug builds (non compiler). Support for having conflict
tables written in the image will come in the next CL.

Bug: 27906566

Change-Id: I03d1671a4b49317aaab5a741bbeaed7957cd6229
fc49fa05c51a26ba1b185401cdba95cea1b67b39 21-Apr-2016 Andreas Gampe <agampe@google.com> ART: Slightly change InitializeClass flow

Since 884f3b83ed6b2a378535ac6b2be57d6b2e22de09, verification isn't
run completely under a class' lock. This means it is possible to
race from unverified to initialized in InitializeClass. So check
the class state after VerifyClass, and handle new success and
failure cases.

Bug: 28254258
Change-Id: I22a6121477e409987281bc81c28b6c942f1bd319
9510ccd93bb752c1baf9eb12d15c08d43c0720a3 20-Apr-2016 Andreas Gampe <agampe@google.com> ART: Add logging for CHECK failure

Add more logging around which thread raced this one.

Bug: 28254258
Change-Id: I136a8074295527a4908825f424fc7fe4b13fbae4
6d25cf6cbda1b95fb014a3fd22c01a6bdf47725e 13-Apr-2016 Mathieu Chartier <mathieuc@google.com> Fix InsertDexFileInToClassLoader to handle null class loaders

Maybe used by legacy apps. This functionality is planned for
deprecation.

Bug: 27954959

(cherry picked from commit f2bf9d640e37b72be8b4f6016d4aa95a0e27b7b4)

Change-Id: I1ae2cf1e33f2f1b237a41c8cc50d2a814a52a95a
f2bf9d640e37b72be8b4f6016d4aa95a0e27b7b4 13-Apr-2016 Mathieu Chartier <mathieuc@google.com> Fix InsertDexFileInToClassLoader to handle null class loaders

Maybe used by legacy apps. This functionality is planned for
deprecation.

Bug: 27954959

Change-Id: I20a3f9de2ca743b2ba2a26d591c09624ead4127e
565bc96291623bf617aef40739247b224188fd16 31-Mar-2016 Alex Light <allight@google.com> Fix issued with non-public interface methods.

Some APK's ship with dex files containing non-public interface
methods. These would cause crashes on newer versions of ART due to
stricter verification of dex files. Make ART emit a warning but allow
this behavior.

Bug: 27928832

(cherry picked from commit d7c10c237bf2631630fac7982c3f374b1a27ed01)

Change-Id: Ia3689ee091aa154fb5954b1f6dd50c489128acce
d7c10c237bf2631630fac7982c3f374b1a27ed01 31-Mar-2016 Alex Light <allight@google.com> Fix issued with non-public interface methods.

Some APK's ship with dex files containing non-public interface
methods. These would cause crashes on newer versions of ART due to
stricter verification of dex files. Make ART emit a warning but allow
this behavior.

Bug: 27928832

Change-Id: Ia3689ee091aa154fb5954b1f6dd50c489128acce
06039ba7c5d1251be7bc041cf64069827364d4ce 04-Apr-2016 Alex Light <allight@google.com> Fix issue with verification check failure on erroneous classes.

Bug: 27924355

Change-Id: I7d680e7196aeb9e2e6ef54139634564e058174d7
f934bf700701b064c3d32924bdda5967b15df7d1 31-Mar-2016 Andreas Gampe <agampe@google.com> ART: Do not run verification under lock

Do not hold the object lock for the duration of the verification.
Instead, use the kStatusVerifying indicator to wait, similar to
resolution.

Bug: 27924355

(cherry picked from commit 884f3b83ed6b2a378535ac6b2be57d6b2e22de09)

Change-Id: Ie831f47dd830756a1b7002ca9c792f8ff67570dc
b0026b41f3d05eae3360c171d3e5baffc19a1bf6 01-Apr-2016 Mathieu Chartier <mathieuc@google.com> Disable checks for b/27493510

Disabled for performance now that the bug is fixed. Still enabled
for debug builds.

Bug: 27493510

(cherry picked from commit 8790c7f9f7d684bff40d5731b2d8e3462ef8ed90)

Change-Id: I049d4319bca1114bd11a35bb13fc9d80c993260c
884f3b83ed6b2a378535ac6b2be57d6b2e22de09 31-Mar-2016 Andreas Gampe <agampe@google.com> ART: Do not run verification under lock

Do not hold the object lock for the duration of the verification.
Instead, use the kStatusVerifying indicator to wait, similar to
resolution.

Bug: 27924355
Change-Id: Ie831f47dd830756a1b7002ca9c792f8ff67570dc
a0b9521b44594d7e546d12785284e7a4bb28c12c 08-Mar-2016 Mathieu Chartier <mathieuc@google.com> Add verification for image ArtMethod declaring classes

Try and see if any ArtMethods in the image have declaring classes
that are not marked in the heap live bitmap. Trying to mark these
would cause a SIGSEGV since the bitmap is read only.

TODO: Disable for performance.

(cherry-picked from commit 03c1dd9858962071bf3f0c988abc39e0e6ed7a1e)

Bug: 27493510
Change-Id: I231b07b84d98dcd7ee1557c18956c86264058ee1
8790c7f9f7d684bff40d5731b2d8e3462ef8ed90 01-Apr-2016 Mathieu Chartier <mathieuc@google.com> Disable checks for b/27493510

Disabled for performance now that the bug is fixed. Still enabled
for debug builds.

Bug: 27493510
Change-Id: I4838b63d79163b97b47e13b201349a72c352ff38
cac5a7e871f1f346b317894359ad06fa7bd67fba 22-Feb-2016 Vladimir Marko <vmarko@google.com> Optimizing: Improve const-string code generation.

For strings in the boot image, use either direct pointers
or pc-relative addresses. For other strings, use PC-relative
access to the dex cache arrays for AOT and direct address of
the string's dex cache slot for JIT.

For aosp_flounder-userdebug:
- 32-bit boot.oat: -692KiB (-0.9%)
- 64-bit boot.oat: -948KiB (-1.1%)
- 32-bit dalvik cache total: -900KiB (-0.9%)
- 64-bit dalvik cache total: -3672KiB (-1.5%)
(contains more files than the 32-bit dalvik cache)
For aosp_flounder-userdebug forced to compile PIC:
- 32-bit boot.oat: -380KiB (-0.5%)
- 64-bit boot.oat: -928KiB (-1.0%)
- 32-bit dalvik cache total: -468KiB (-0.4%)
- 64-bit dalvik cache total: -1928KiB (-0.8%)
(contains more files than the 32-bit dalvik cache)

Bug: 26884697
Change-Id: Iec7266ce67e6fedc107be78fab2e742a8dab2696
7fe30233d32a872f5349e921dba65bd767ad994b 26-Mar-2016 Andreas Gampe <agampe@google.com> ART: Make verifier fail log level adjustable

To help for build failures.

Change-Id: I6c94dfb50177daa7d89902d78715ccec31bf0e45
796d63050a18f263b93ea34951a61deaecab3422 13-Mar-2016 Nicolas Geoffray <ngeoffray@google.com> Add an ImtConflictTable to better resolve IMT conflicts.

- Attach a ImtConflictTable to conflict runtime ArtMethod.
- Initially 0, a new one will be created at the first hit of
the conflict method.
- If the assembly code does not find a target method in the table,
we will create a new one again, copying the data from the previous
table and adding the new mapping.

Implemented for arm/arm64/x86/x64.

bug:27556801
bug:24769046

Change-Id: Ie74d1c77cf73d451a1142bdc5e3683f9f84bb4e7
086e279ff9c739da617c9fb50fababf74ed52890 18-Mar-2016 Mathieu Chartier <mathieuc@google.com> Disable LZ4HC compressed images

Seem to get randomly compressed incorrectly on volantis. Added
verifiation in the image writer.

Using LZ4HC now silently uses LZ4. This is still safe since both use
the same decompression code.

Bug: 27560444

(cherry picked from commit 9894fc8079a5c6eb72e04099bdbd3239b75cf491)

Change-Id: Ic0d78f419884d7ef2e29948835c942fbb68e66da
9894fc8079a5c6eb72e04099bdbd3239b75cf491 18-Mar-2016 Mathieu Chartier <mathieuc@google.com> Disable LZ4HC compressed images

Seem to get randomly compressed incorrectly on volantis. Added
verifiation in the image writer.

Using LZ4HC now silently uses LZ4. This is still safe since both use
the same decompression code.

Bug: 27560444

Change-Id: I652eee7498dc84994993be3a5b0447ec5b246304
6300fd77033817664aee3056c4ff5fab85698d2b 18-Mar-2016 Nicolas Geoffray <ngeoffray@google.com> Code cleanup between debugger and jit.

This is to allow secondary dex files to be fully compiled.

- No need to do full deopt anymore for breakpoints: code in boot.oat
is deoptimized as soon as the debugger attaches (and we decided that
existing frames could not be debugged), and application being
debugged is compiled debuggable.

- jit should only call UpdateMethodsCode if exit stubs are not
installed due to lock violation otherwise (the lock level of the
jit code cache is lower than the deoptimization lock).
This part needs an overall cleanup beyond the scope of this change.

Change-Id: I38d85dcb270db746c1d6b0ceb7893a1aad8c9655
a807780b1d8ee01dfb03923c673621b4c81ac858 17-Mar-2016 Mathieu Chartier <mathieuc@google.com> Add verify-profile compiler filter

Only verifies and dex2dex compiles classes in the profile. Goal
is to reduce application launch time.

~2x faster than interpret-only for Facebook.

Bug: 27688727

(cherry picked from commit a079e3aa62cceb76c1c1811e6e09bcaf75e20289)

Change-Id: Iad5aa1adee3aa6c2408820e8cbbab2d4412021b8
a079e3aa62cceb76c1c1811e6e09bcaf75e20289 17-Mar-2016 Mathieu Chartier <mathieuc@google.com> Add verify-profile compiler filter

Only verifies and dex2dex compiles classes in the profile. Goal
is to reduce application launch time.

~2x faster than interpret-only for Facebook.

Bug: 27688727
Change-Id: Ic9979c4f7ba4930298d0983c4e3c70c63500213f
5457b86f9dc02045436cc53327c4b6383805cb6a 17-Mar-2016 Alex Light <allight@google.com> Revert "Revert "Fix issue with proxy invocation on default methods""

This reverts commit daf58c80d42f024aae0cb94ebd2c0bd61ebbf240.

Bug: 27621360

(cherry picked from commit e9dd04f633fcffc485f8d74861f39f66fc8bc522)

Change-Id: I56fccf19ae80451be4c316ba14911c667cbe9e47
e9dd04f633fcffc485f8d74861f39f66fc8bc522 17-Mar-2016 Alex Light <allight@google.com> Revert "Revert "Fix issue with proxy invocation on default methods""

This reverts commit daf58c80d42f024aae0cb94ebd2c0bd61ebbf240.

Bug: 27621360
Change-Id: I56fccf19ae80451be4c316ba14911c667cbe9e47
f448016e70fa91269d3750384aab1ac98d7896fd 16-Mar-2016 David Srbecky <dsrbecky@google.com> Do not JIT boot image during native-debugging (keep AOT code instead).

The performance impact is currently significant and being able
to debug framework is not our primary goal for native debugging.

Change-Id: I3366c2a6317004f9dd16700b271a6c9b974f1c6e
daf58c80d42f024aae0cb94ebd2c0bd61ebbf240 17-Mar-2016 Alex Light <allight@google.com> Revert "Fix issue with proxy invocation on default methods"

This reverts commit ec3b7ab8f008f36f1072d4ba03da204229b95976.

Change-Id: Idfb2c63c246cc5dae7670503e70ad3f62bb1e1eb
7670908bb4a19649e0d60296d5adb3f05e9fea86 16-Mar-2016 Alex Light <allight@google.com> Revert "Fix issue with proxy invocation on default methods"

This reverts commit 4b34bf5b242dce5ee20db08b7781bbbaf0d25969.

Change-Id: If072fdbaafd0ee1877e8281a83ba4a598adb3355
4b34bf5b242dce5ee20db08b7781bbbaf0d25969 15-Mar-2016 Alex Light <allight@google.com> Fix issue with proxy invocation on default methods

Bug: 27621360

(cherry picked from commit ec3b7ab8f008f36f1072d4ba03da204229b95976)

Change-Id: I617eee243f475872235fd75b6a401e056111ea23
879d27b0a8138188abb13ff995160154cae0d772 15-Mar-2016 Vladimir Marko <vmarko@google.com> ART: Fix ignoring duplicate fields.

Ignore duplicate fields when calculating class size without
embedded tables. We already ignored them when loading class
members. This fixes a check failure in debug build that the
final class is no smaller than the temporary class.

Bug: 21868015
Bug: 27626707
Change-Id: Id72121724abc093d536c2329c61a24854a20122c
ec3b7ab8f008f36f1072d4ba03da204229b95976 15-Mar-2016 Alex Light <allight@google.com> Fix issue with proxy invocation on default methods

Bug: 27621360

Change-Id: I617eee243f475872235fd75b6a401e056111ea23
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
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
1a7beaea6f5f12e8248544a6dbe74b90c3b723b5 10-Mar-2016 Andreas Gampe <agampe@google.com> ART: Fix assumption in class profile collection

The dex cache may contain erroneous classes. Filter, instead of
DCHECK.

Bug: 27500691

(cherry picked from commit 4309f6129795ade42591b872e44a33cec95f4e79)

Change-Id: Ic99bca3a7e54a5e7893c801ec5ac92cbf690cd67
4309f6129795ade42591b872e44a33cec95f4e79 10-Mar-2016 Andreas Gampe <agampe@google.com> ART: Fix assumption in class profile collection

The dex cache may contain erroneous classes. Filter, instead of
DCHECK.

Bug: 27500691
Change-Id: Ic99bca3a7e54a5e7893c801ec5ac92cbf690cd67
0c344f2c889520de9b2547df3818676540787a93 08-Mar-2016 Mathieu Chartier <mathieuc@google.com> Fix lock order violation

Release class linker lock before acquiring heap bitmap lock.

Bug: 27493510

(cherry picked from commit 064e9d401c49d3789b5deeeb6b423a4f551e4206)

Change-Id: I7809e0f591513b85d295d43e639152ce92984f9c
064e9d401c49d3789b5deeeb6b423a4f551e4206 08-Mar-2016 Mathieu Chartier <mathieuc@google.com> Fix lock order violation

Release class linker lock before acquiring heap bitmap lock.

Bug: 27493510
Change-Id: I7809e0f591513b85d295d43e639152ce92984f9c
03c1dd9858962071bf3f0c988abc39e0e6ed7a1e 08-Mar-2016 Mathieu Chartier <mathieuc@google.com> Add verification for image ArtMethod declaring classes

Try and see if any ArtMethods in the image have declaring classes
that are not marked in the heap live bitmap. Trying to mark these
would cause a SIGSEGV since the bitmap is read only.

TODO: Disable for performance.

Bug: 27493510
Change-Id: I231b07b84d98dcd7ee1557c18956c86264058ee1
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
095a0b234a47261402bf81681eacb6092517766e 05-Mar-2016 Mathieu Chartier <mathieuc@google.com> Remove no thread suspension assert in AddImageSpace

Heap::VisitObjects may cause thread suspension for the CC case.

Change-Id: Ibd495690b87dc8731919e1b1164be834c9da02b2
f28a99a90b68e45f39191258832e7a526c4742ba 02-Mar-2016 Mathieu Chartier <mathieuc@google.com> Fix potential linear alloc memory leak

Previously, if we created a linear alloc for a class loader but
never created the class table, the linear alloc would never get
freed since it would have no corresponding ClassLoaderData.

Fixes valgrind-test-art-host-gtest-oat_test

Bug: 27384882
Bug: 22858531

(cherry picked from commit 5b83050affa6a3b1d3863c0b903f9d48fe4aefb2)

Change-Id: I71b650eac4e33212a7f03c43141db99e635a19ad
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
88027bd6810b9a5b785dba5396eec5301e4540b2 03-Mar-2016 Mathieu Chartier <mathieuc@google.com> Only visit app image classes in class loader

Only update dex cache arrays of added classes since the declaring
class is in image DCHECK fails for other classes in the class loader.

Also some cleanup to prevent app images leaving invalid state if
they get rejected.

Bug: 22858531
Bug: 27431418

(cherry picked from commit 6973100705716bffce3768a8a0908d7ca1d02ec1)

Change-Id: Ib05364c44f2b943e3341ef2b1dd43337833de143
6973100705716bffce3768a8a0908d7ca1d02ec1 03-Mar-2016 Mathieu Chartier <mathieuc@google.com> Only visit app image classes in class loader

Only update dex cache arrays of added classes since the declaring
class is in image DCHECK fails for other classes in the class loader.

Also some cleanup to prevent app images leaving invalid state if
they get rejected.

Bug: 22858531
Bug: 27431418
Change-Id: Ib2a5692a1ad78b014a1bfc6b27fb1c12bc8565e6
5b83050affa6a3b1d3863c0b903f9d48fe4aefb2 02-Mar-2016 Mathieu Chartier <mathieuc@google.com> Fix potential linear alloc memory leak

Previously, if we created a linear alloc for a class loader but
never created the class table, the linear alloc would never get
freed since it would have no corresponding ClassLoaderData.

Fixes valgrind-test-art-host-gtest-oat_test

Bug: 27384882
Change-Id: Ic8f35b58c3117127a39521b6b9d25ef12c72040c
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
7ead0c009c64f1e10aa39e44ea10383dd859d332 22-Feb-2016 Alex Light <allight@google.com> Make JNI work correctly with default methods.

Also adds some tests for JNI and DefaultMethods.

Bug: 27259142
Bug: 24618811

(cherry picked from commit 3612149aee482ab7a17da68b0ef5fef3879729a2)

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

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

Change-Id: Id148069ccad95e2339ba214742ae3ef4f084f495
3612149aee482ab7a17da68b0ef5fef3879729a2 22-Feb-2016 Alex Light <allight@google.com> Make JNI work correctly with default methods.

Also adds some tests for JNI and DefaultMethods.

Bug: 27259142
Bug: 24618811

Change-Id: I31222e3e41059d803be1dbb0f40e1144ac4bf457
d07e1b338ddedd03728136f136a2c4cb6df50dc4 17-Feb-2016 Alex Light <allight@google.com> Fix issue with copied methods not being checked.

In several places we were using IsMiranda to check if a method is
copied. This misses cases involving default methods.

(cherrypicked commit fcea56f9cc51957161fe7a6e35e895fd8c4c4a7f)

Bug: 27216437

Change-Id: I8c800e3e622a9c0ca0f8752c3d5202f433af9a1c
fcea56f9cc51957161fe7a6e35e895fd8c4c4a7f 17-Feb-2016 Alex Light <allight@google.com> Fix issue with copied methods not being checked.

In several places we were using IsMiranda to check if a method is
copied. This misses cases involving default methods.

Bug: 27216437
Change-Id: I8c800e3e622a9c0ca0f8752c3d5202f433af9a1c
dd5e5e975e1965c3e4568143e8e1c7b65b319f58 12-Feb-2016 Tamas Berghammer <tberghammer@google.com> Revert "Revert "Make it possible to enable native debugging through debug flags""

This reverts commit 3a98aae1b9b20bc78dc5e05d2e60cb1d0072db02.

* Add support for a new debug flag disabling the optimizations in
the compiler and enable the generation of some additional debug
info (--native-debuggable).
* Ignore the content of the oat files if force JIT is enabled so
the runtime ignores the AOT-ed code what doesn't contain any
debug info.

Time measurements on a Nexus 5 with running:
am start -n com.facebook.katana/com.facebook.katana.LoginActivity -W

Before change: | AVG | DEV
--------------------------------------
ThisTime: 549 492 512 511 | 516 | 24
TotalTime: 549 492 512 511 | 516 | 24
WaitTime: 662 511 528 526 | 557 | 71

After change: | AVG | DEV
--------------------------------------
ThisTime: 530 467 503 544 | 511 | 34
TotalTime: 530 467 503 544 | 511 | 34
WaitTime: 551 497 536 583 | 541 | 36

Based on the numbers the speed impact of the change is less then the
accuracy of the measurement and it is also negligible.

The minor speed improvement displayed in the measurements are just
the cause of the variance of the measurement and not caused by this
change.

Change-Id: Ibf7294bfd14f8632a0fdeb27a5b90bfe5037d085
3a98aae1b9b20bc78dc5e05d2e60cb1d0072db02 08-Feb-2016 Tamas Berghammer <tberghammer@google.com> Revert "Make it possible to enable native debugging through debug flags"

The change causes issues in test-art-target-gtest-jni_internal_test32

This reverts commit c94a61f06ffc13288c67891048128c987b29bf33.

Change-Id: Iecfe3c6874d7b0dd59f10156fe2eb743ab7221dc
c94a61f06ffc13288c67891048128c987b29bf33 05-Feb-2016 Tamas Berghammer <tberghammer@google.com> Make it possible to enable native debugging through debug flags

* Add support for a new debug flag disabling the optimizations in
the compiler and enable the generation of some additional debug
info (--native-debuggable).
* Ignore the content of the oat files if force JIT is enabled so
the runtime ignores the AOT-ed code what doesn't contain any
debug info.

Time measurements on a Nexus 5 with running:
am start -n com.facebook.katana/com.facebook.katana.LoginActivity -W

Before change: | AVG | DEV
--------------------------------------
ThisTime: 549 492 512 511 | 516 | 24
TotalTime: 549 492 512 511 | 516 | 24
WaitTime: 662 511 528 526 | 557 | 71

After change: | AVG | DEV
--------------------------------------
ThisTime: 530 467 503 544 | 511 | 34
TotalTime: 530 467 503 544 | 511 | 34
WaitTime: 551 497 536 583 | 541 | 36

Based on the numbers the speed impact of the change is less then the
accuracy of the measurement and it is also negligible.

The minor speed improvement displayed in the measurements are just
the cause of the variance of the measurement and not caused by this
change.

Change-Id: Ia9022cbc1bbfcc072314b6c95f63a4bf8060c36c
7ba5a67686a5c6fc5735a4a9457958c79e6ca818 05-Feb-2016 Andreas Gampe <agampe@google.com> ART: Better InitWithoutImage error messages

InitWithoutImage can easily fail when assumptions of the runtime
with respect to core classes are wrong. Give some more general
helpful messages.

Change-Id: Icedac9a0d6ad84b2d1dde9e30bf4fab2f48a3efd
8c4f041368f26cec076d003cbabbc0eb827c9875 04-Feb-2016 Mathieu Chartier <mathieuc@google.com> madvise away app image dex cache arrays

This saves ram and PSS by reducing the number of mapped pages. Also
PROT_NONE the dex cache arrays section to make accesses fault.

virtual shared shared private private
size RSS PSS clean dirty clean dirty swap
-------- -------- -------- -------- -------- -------- -------- --------
Before:
/data/app/com.facebook.katana-2/oat/arm/base.art
52484 52144 43522 17244 0 0 34900 0
/data/app/com.google.android.apps.maps-2/oat/arm/base.art
6876 6816 6816 0 0 2008 4808 0

After:
/data/app/com.facebook.katana-2/oat/arm/base.art
52484 49204 42032 14344 0 0 34860 0
/data/app/com.google.android.apps.maps-2/oat/arm/base.art
6876 6388 6388 0 0 1584 4804 0

Bug: 22858531

Change-Id: I87888a7c1518a92736dbd29eed338e7472ae3587
df707e406877e9c0426dd051c00933ebb331673e 03-Feb-2016 Igor Murashkin <iam@google.com> runtime: Don't skip verification for -Xverify:soft-fail

When forcing the interpreter into access checks mode,
make sure that the regular verification is still run,
giving the verifier an opportunity to throw a VerifyError.

If verification would've succeeded (without -Xverify:soft-fail flag),
override this and soft-fail, to force the interpreter-with-access-checks to be run
instead of the normal faster interpreter.

This fixes the following run-tests under the interpeter-access-checks:
* 135
* 412
* 471
* 506
* 800

Bug: 22414682
Change-Id: I5cb86a8bba71c7af9361a63c0802786c852b857b
9b1c9b761dea9bc48a2994e3d4de46fc10343a25 02-Feb-2016 Mathieu Chartier <mathieuc@google.com> Fix updating string dex cache array for no class table case

The issue was that array classes do not have a dex cache. Also removed
some unnecessary mutables.

Bug: 22858531
Change-Id: I2bc45f019e064b6e562c8f158cc2ac8c0e513afd
e3d4ff566f9545114bf9ed72421e49eaf9d37953 02-Feb-2016 Igor Murashkin <iam@google.com> runtime: Update Proxy to assume 1 less direct method

Part of a libcore-side cleanup to remove dead code.

Requires a corresponding libcore change to run.

Bug: 26846861
Change-Id: I44ee74d8a4cbd7889d655c15c76dad8121c3297e
69a0405e79fc9b61e90d6cf0364f85f10fa29a36 02-Feb-2016 Vladimir Marko <vmarko@google.com> ART: Clean up strings fixup for app images.

This is a follow-up to
https://android-review.googlesource.com/199854 .

Bug: 26846419
Bug: 22858531
Change-Id: Ib2b2c299c51686afb7f297697125296705ed77b8
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
5a5598609f4f65f446e46327e7b6789c41c92bde 29-Jan-2016 Alex Light <allight@google.com> Fix issue with exception type resolution during linking.

When using default methods that cross dex-files we would sometimes
attempt to lookup method information using the wrong dex file. This
fixes this issue.

Bug: 26872564

Change-Id: I3c4b64ef970017356962060f3bd3781b4629a3c8
369c8513cb23dbd18267da5479947ccf59997a57 29-Jan-2016 Andreas Gampe <agampe@google.com> ART: Dump full exception on re-init failure message

It is a recurring issue to investigate the underlying issue. Just
dumping the top-level failure type is not very helpful. Take the
logcat hit and dump the full exception (including causes).

Change-Id: If071df9667473410222438e1c5f956c9b56b4d77
7f3e0db231787e65fb99aeab83ac43d78a13b824 28-Jan-2016 Nicolas Geoffray <ngeoffray@google.com> Change log to avoid polluting logcat.

Change-Id: I804afe9e3a78876f4fc2d74ae084419530435840
d329a3b6a77148839171132eb779577fe4b16cdd 28-Jan-2016 Mathieu Chartier <mathieuc@google.com> Fix pointer conversion error in SetElementPtrSize

SetElementPtrSize used to cast from pointer to uint64_t which
could sign extend with 32 bit dex2oat for 64 bit app image.
Also removed C style casts and added more logging.

Bug: 22858531

(cherry picked from commit d22886357d4c53f74ca298faa7ad2555794e17e0)

Change-Id: I479124328fbc497cfcae20c43b4b55827e446527
d22886357d4c53f74ca298faa7ad2555794e17e0 28-Jan-2016 Mathieu Chartier <mathieuc@google.com> Fix pointer conversion error in SetElementPtrSize

SetElementPtrSize used to cast from pointer to uint64_t which
could sign extend with 32 bit dex2oat for 64 bit app image.
Also removed C style casts and added more logging.

Bug: 22858531

Change-Id: I9a5efc4d22c069f4016263ee7a84932a4e7306a6
12771081679e43a6c34cd35c80ff9663bbdd15e9 27-Jan-2016 Alex Light <allight@google.com> Fix issue with IMT dispatch.

If a default and an abstract method map to the same IMT slot one could
end up invoking the default method when one invokes the abstract
method.

Bug: 24618811
Bug: 26827549

Change-Id: I2ccb8e8b5362eb4961531b63e7b946ad8ef936a6
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
76172164667d565c1d3316935a24b0d9712bb2f6 26-Jan-2016 Mathieu Chartier <mathieuc@google.com> Convert to UTF8 before doing dex file location comparison

Need to have strings in the same format or else the lengths
might not match due to UTF8 conversion.

Added regression test.

Bug: 26799552

(cherry picked from commit 3776db4e51ab61a6e535772417c2adf95920b569)

Change-Id: Ifbc8c38418c9da307a0ff4446d18cea4fb5e71bc
3776db4e51ab61a6e535772417c2adf95920b569 26-Jan-2016 Mathieu Chartier <mathieuc@google.com> Convert to UTF8 before doing dex file location comparison

Need to have strings in the same format or else the lengths
might not match due to UTF8 conversion.

Added regression test.

Bug: 26799552
Change-Id: If2c9e029e4096eeff6eabbbaec35663f6d2bcdb4
9724c636467d56632a45fdf6353e3d57d1925501 07-Jan-2016 Neil Fuller <nfuller@google.com> Enable interface default methods by default.

This also enables interface static methods.

This removes the -Xexperimental:default-methods flag and all places
where we explicitly check for its presence.

Bug: 24618811

Change-Id: Icd91e377bd6e1a45a1645f810d15de1b0312e31d
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
160e6df5debaf77223eebddb8a4e3f7c5e729ad0 05-Jan-2016 Tamas Berghammer <tberghammer@google.com> Report loaded classes to native debugger.

Change-Id: Iee902a9ed8fa7545ba3e6afc32f285aa350a5383
966878d987cec1940fdfa8633fc79f8112320821 14-Jan-2016 Mathieu Chartier <mathieuc@google.com> Revert "Create parent class loader for dex2oat"

Bug: 22858531

This reverts commit d37d364c27e74a7b49970a8c970482e273aa7b1a.

Change-Id: Id71a6f3bb9a29c04a5c13210633674e05d798114
705ad49f353d3f90d8b63625aca2c2035bacdbef 21-Sep-2015 Alex Light <allight@google.com> Support directly invoking interface default methods

With the Java 8 Language one is allowed to directly call default
interface methods of interfaces one (directly) implements through the
use of the super keyword. We support this behavior through the
invoke-super opcode with the target being an interface.

We add 3 tests for this behavior.

Currently only supports slow-path interpreter.

Invoke-super is currently extremely slow.

Bug: 24618811

Change-Id: I7e06e17326f7dbae0116bd7dfefca151f0092bd2
acd7a6ac4bb5b43b07362f5c83ab0259514370d6 08-Jan-2016 Jeff Hao <jeffhao@google.com> Fix general multi-image TODOs.

- Removed some unnecessary comments.

Bug: 26317072

(cherry-picked from commit 509f2ab308032534f14d8f4f374f60da8a615fa2)

Change-Id: Id542262ca1182fb77f029f2136266e470bde9473
509f2ab308032534f14d8f4f374f60da8a615fa2 08-Jan-2016 Jeff Hao <jeffhao@google.com> Fix general multi-image TODOs.

- Removed some unnecessary comments.
- Reenabled tests that are working again.

Change-Id: Id542262ca1182fb77f029f2136266e470bde9473
1f47b678db70d57aa5194266651a8f4336fc851e 08-Jan-2016 Mathieu Chartier <mathieuc@google.com> Re-enable class table for image writer

Changes, create one temporary class table per ImageInfo. Don't keep
track of class loaders.

Bug: 26317072

Change-Id: I4f9121194f39031fb8629d60b6feeb2747a77870
1c1a342ba4e029ea1868a41ed0310756b7d78f45 05-Jan-2016 Jeff Hao <jeffhao@google.com> Fix multi-image TODOs in class linker, runtime, and oat file.

- Modified SanityCheckArtMethodPointerArray in class linker
- Put back warnings in OatFile::GetOatDexFile
- Reinstated ImageSpace VerifyImageAllocations in Runtime::Init

Bug: 26317072

(cherry-picked from commit 0dfef949bb824accde27f8cfe1b233ec9e087355)

Change-Id: I3bdb8f87d885213795c82c41e5095fec6daf00c4
0dfef949bb824accde27f8cfe1b233ec9e087355 05-Jan-2016 Jeff Hao <jeffhao@google.com> Fix multi-image TODOs in class linker, runtime, and oat file.

- Modified SanityCheckArtMethodPointerArray in class linker
- Put back warnings in OatFile::GetOatDexFile
- Reinstated ImageSpace VerifyImageAllocations in Runtime::Init

Change-Id: I3bdb8f87d885213795c82c41e5095fec6daf00c4
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
9865bde5d822f56c4732214c2005dfcaa41f94cf 21-Dec-2015 Mathieu Chartier <mathieuc@google.com> Rename NullHandle to ScopedNullHandle

This makes it clearer that is invalid to do things like:
Handle<T> h = ScopedNullHandle<T>();

Bug: 26233305
Change-Id: I6d8f54eae01ec2e901cb7043afa853ea77db79fe
51a64d5d4fe91842cc2a5f2a412441147c145683 17-Dec-2015 Alex Light <allight@google.com> Make use of new method iterators.

Change-Id: I1f82f17951339b2054a1dac87bde79f9e803fc4a
e64300b8488716056775ecbfa2915dd1b4ce7e08 16-Dec-2015 Alex Light <allight@google.com> Revert "Revert "Combine direct_methods_ and virtual_methods_ fields of mirror::Class""

This reverts commit ae358c1d5cef227b44d6f4971b79e1ab91aa26eb.

Bug: 24618811

Change-Id: I8becf9bae3258450b90cfef5e79589db7c535a4d
2efb0aa57da168944f99a2d13aed2a426cfa76e7 15-Dec-2015 Alex Light <allight@google.com> Revert "Combine direct_methods_ and virtual_methods_ fields of mirror::Class"

This reverts commit 9539150b85142c18e9e8c2264b5b6100942667c3.

Change-Id: I596876cd643ec0ad524a56621efb6b89e8886230
ae358c1d5cef227b44d6f4971b79e1ab91aa26eb 15-Dec-2015 Alex Light <allight@google.com> Revert "Combine direct_methods_ and virtual_methods_ fields of mirror::Class"

This reverts commit 6286a97bea0f584342803a215550038852b24776.

Change-Id: I5b00f6d1350e9c587acd4b185367dc815ea707de
9539150b85142c18e9e8c2264b5b6100942667c3 04-Dec-2015 Alex Light <allight@google.com> Combine direct_methods_ and virtual_methods_ fields of mirror::Class

Manual cherry-pick of 6286a97 to master

This makes several parts of the overall runtime simpler and reduces
the size of a class object by 32-bits.

Bug: 24618811

Change-Id: I36129b52189e26898ea56fa2b7b45652e06af236
6286a97bea0f584342803a215550038852b24776 04-Dec-2015 Alex Light <allight@google.com> Combine direct_methods_ and virtual_methods_ fields of mirror::Class

This makes several parts of the overall runtime simpler and reduces
the size of a class object by 32-bits.

Bug: 24618811

Change-Id: I36129b52189e26898ea56fa2b7b45652e06af236
42ef8ab151a3d0cbb42cb43f6841c3708d65fca3 04-Dec-2015 Andreas Gampe <agampe@google.com> ART: Stash a resolved method late in the verifier

Invoke-interface should only be called on an interface method.
We cannot move the check earlier, as there are other checks
that must be done that can fail a class hard. So postpone
a push to the dex cache.

Clean up the test a bit.

Also templatize ResolveMethod with a version always checking
the invoke type, and on a cache miss check whether type target
type is an interface when an interface invoke type was given.

Bug: 21869691
Change-Id: I94cbb23339cbbb3cb6be9995775e4dcefacce7fd
c96205e03bd4f991ad1540df38f9f692ef211b22 10-Dec-2015 Andreas Gampe <agampe@google.com> Revert "ART: Check invoke-interface earlier in verifier"

This reverts commit dae24142127c64551142a50423085aabdb0a6060.

It is important to check the name of the method being called.

Bug: 21869691
53e32d14d7a51198c6ef09120c15bafdd1d055c2 10-Dec-2015 Andreas Gampe <agampe@google.com> ART: Refactor verifier callbacks

Change the return type of MethodVerified to void. It was never
used anyways.

Remove the callbacks calls from the core of the verifier (Verify()).
Instead, make the convenience functions do the work, and add a
parameter to supply the callback so that the verifier becomes
independent of the Runtime-stored one.

Fix up calls that now need to provide a callback, but leave places
that only run the verifier to get metadata (e.g., register type data,
lock state) without callback. This avoids callback calls when in JIT
mode.

Bug: 26075442
Change-Id: I2c270f01e4de088771d4d4b19dae4f07d77640f0
dae24142127c64551142a50423085aabdb0a6060 04-Dec-2015 Andreas Gampe <agampe@google.com> ART: Check invoke-interface earlier in verifier

Invoke-interface should only be called on an interface method.
Move the check earlier, as otherwise we'll try to resolve and
potentially inject a method into the dex cache.

Also templatize ResolveMethod with a version always checking
the invoke type, and on a cache miss check whether type target
type is an interface when an interface invoke type was given.

Bug: 21869691
Change-Id: Ica27158f675b5aa223d9229248189612f4706832
208a5cb383dd9dcd3461f89b74af5df67dc8d794 03-Dec-2015 Mathieu Chartier <mathieuc@google.com> Store class tables in the image

Reduces how long it takes to load an application image.

N5 boot.art size
Before: 8007680
After: 8122368

Also reduces boot time by how long AddImageClassesToClassTable
used to take (~20ms).

Changed class hashes to be uint32_t to fix cross compilation. We need
serialized hash tables to be valid with different pointer sizes.

Bug: 22858531

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

955-lambda is flaky

Bug: 24618608
Bug: 25107649

This reverts commit 457e874459ae638145cab6d572e34d48480e39d2.

(cherry picked from commit 3a0909248e04b22c3981cbf617bc2502ed5b6380)

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

955-lambda is flaky

Bug: 24618608
Bug: 25107649

This reverts commit 457e874459ae638145cab6d572e34d48480e39d2.

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

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

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

Note: MIPS32/64 support not included.

Bug: 24618608
Bug: 25107649
Change-Id: Ic8f1bb66ebeaed4097e758a50becf1cff6ccaefb
d37d364c27e74a7b49970a8c970482e273aa7b1a 20-Nov-2015 Mathieu Chartier <mathieuc@google.com> Create parent class loader for dex2oat

This means we also put the class loader in the app image so that it
can be used for verifying the dex file order.

Bug: 22858531
Change-Id: I30761b59421c8a24cffd62b469134b25d2929e2e
3db9c5da2925ca5ca82cc37b60a8e9fc39e88d1d 17-Nov-2015 Andreas Gampe <agampe@google.com> ART: Change Init{From,Without}Image to return bool

Rewrite some CHECKs to return false. For a common failure (missing)
image, this improves the abort (as it's not a runtime abort with
lots of stack traces anymore).

Change-Id: I717b1db74950267ced0ad3bafa1aed1693680062
04302dbb106d590ff72c0dfecda23d85b6565059 12-Nov-2015 Hiroshi Yamauchi <yamauchi@google.com> Fix class unloading with the CC collector.

Avoid unnecessarily decoding dex cache and class loader weak roots,
which would trigger read barriers.

Re-enable 141-class-unload with the CC collector.

Bug: 12687968
Bug: 24468364
Change-Id: Ib4c19f25000873cab0e06047040442d135285745
dcf1b59d6f834cce110028e20a00187091c0138a 12-Oct-2015 Przemyslaw Szczepaniak <pszczepaniak@google.com> Fix Constructor#serializationCopy

Added new Constructor#newInstanceFromSerialization
method that's used to implement #newInstance on
Constructor instances created by the #serializationCopy.

+ Restored ArtField::GetOffset missing DCHECK and
fixed debug build use of GetOffset to GetOffsetDuringLinking
in the class_linker.cc.

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

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

Generalized some logic in the class linker for image spaces.

Bug: 22858531

Change-Id: Ib3e12bb061a247e232d3dc93b0d6b35eb3a34d25
9139e008abe30b7beaf4afd6533228a1dd9b202c 10-Oct-2015 Alex Light <allight@google.com> Correct exception behavior for default methods

Default methods are defined to throw an IncompatibleClassChangeError
(ICCE) when they are called and there is no "best" implementation.
Previously we would simply throw an ICCE during class loading as soon
as we noticed that this would happen if called. This makes us wait
until we actually attempt to execute the method. Furthermore, this
allows us to use other, non-conflicting, methods on the object as
normal.

Furthermore, this makes us correctly throw AbstractMethodErrors in
cases where all default implementations of a method are overridden by
abstract declarations.

Adds 3 tests for this new behavior.

Bug: 24618811

Change-Id: Id891958a81f9b3862b2ce5919636aabef7d3422e
f1f104935bc9a200f6e79c52c56c5d7cf0f43bb2 08-Oct-2015 Alex Light <allight@google.com> Class Linker: Implement default interface verification ordering.

We ensure that default interface verification failure is propagated to
the implementing class so that the compiler is able to properly handle
verification failures. Furthermore we ensure that default interfaces
are verified at the same time their implementing classes are.

This does not add additional support for default methods to the verifier.

This adds a basic test of this functionality.

Previously assumptions made about the order of verification in our
code could cause a check failure during compilation. Our old code
assumed that all code that would be run during a classes
initialization had been verified before any of it was run. The default
interfaces broke this assumption. Now we will simply verify default
interfaces with any classes that implement them.

Bug: 24618811

Change-Id: Ia11a50a28889dbd7ca22ffa730ef443e39f3cb5b
ec6e6c19662260c059b273dfc9c502900756487d 06-Nov-2015 Andreas Gampe <agampe@google.com> ART: Rerun the verifier for compile-time failures

To aid app failure diagnosis, by default re-run the verifier at
runtime to compute a better VerifyError message.

Rewrite the verifier driver code to pass the last actual low-level
verifier message.

Bug: 25432718
Change-Id: Ib8e6dd1ce8121045c0d38f54969100094c3dde6e
3b021bf1b7f6487c640ef5b92dbcc3e1852f23ff 05-May-2015 Piotr Jastrzebski <haaawk@google.com> Update the number of direct methods in j.l.reflect.Proxy.

Change-Id: I868ac35f2587cc164872c1e0f6c67fc0d44a576c
da5b28adf5ba013f0784578a8b97577782e23d95 05-Nov-2015 Mathieu Chartier <mathieuc@google.com> Revert "Revert "Add basic image writer support for app images""

No changes, bug fixed in:
https://android-review.googlesource.com/#/c/180886/

Bug: 22858531

This reverts commit 4b018565e57c3349a3c1b5ec8ac9dae261c5e00b.

Change-Id: I86d9c2b55d535d803c6e1b3b8b4836bf6ff077e5
81819db4248da38068c029add11a9d36215a01b1 05-Nov-2015 Vladimir Marko <vmarko@google.com> ART: Fix ignoring duplicate fields when loading class.

Bug: 25493974
Change-Id: I59e7ee6ee5b991b327553d022d7d212db415c9c3
4b018565e57c3349a3c1b5ec8ac9dae261c5e00b 05-Nov-2015 Nicolas Geoffray <ngeoffray@google.com> Revert "Add basic image writer support for app images"

interpreter and jit tests fail.

Bug: 22858531

This reverts commit c033474cfbfe1e963c07fa5c38aed02e35ed6f91.

Change-Id: Ic12a3e2a1908ac0db52d21a0b44b2508c88b2585
cb086955c2a21270cd2f53a8bce71e577d776506 03-Nov-2015 Andreas Gampe <agampe@google.com> ART: Change behavior for rethrowing init failures (2)

Always store the pending exception when making a class erroneous.
Instead of filtering by ExceptionInInitializerError, add an option
to the rethrow that enforces a NoClassDefFoundError, which is required
by the specification.

Use the libcore companion change to add the stored error (if any) as
a cause to the NoClassDefFoundError, which should significantly help
tracking down issues.

Fix run-test 008 to expect spec-compliant behavior. Test that a cause
has been set.

Bug: 25445103
Change-Id: I6a0dc54e78312283faf23415887eff387531407f
c033474cfbfe1e963c07fa5c38aed02e35ed6f91 02-Nov-2015 Mathieu Chartier <mathieuc@google.com> Add basic image writer support for app images

Needed to handle references from app image -> boot image.

Generate app images for tests to enable some testing.

Bug: 22858531

Change-Id: I1af98b6c4dfcb3a147fb5b0dea64aa4946c7ce57
99babb6add7db19ce7605f6d5e4aee79d52e386f 03-Nov-2015 Andreas Gampe <agampe@google.com> ART: Change behavior for rethrowing init failures

Allow to store a Throwable instance or a throwable class. Handle
rethrow accordingly.

Bug: 25444180
Change-Id: I703c2c6eaf34ad0e3bc0f5a104d65f2ff1b212ca
22cf3d361695ff1d585a8a412ebeade69749811f 02-Nov-2015 Nicolas Geoffray <ngeoffray@google.com> Fix tests flakiness with jit when using Proxy classes.

We cannot copy the entry point between ArtMethod when
the entry point has been JITted. We put the interpreter
bridge instead.

bug:25334878

Change-Id: I65a50cc1f10a5a152733807f8c85fb3ed81c5829
9507fa2c9545156747a5eb248bc1af3159bfd8c8 29-Oct-2015 Mathieu Chartier <mathieuc@google.com> Change a few places to use string version of GetTypeId

GetTypeId is about 20% faster than GetStringId + integer GetTypeID
since it does less binary searches.

Change-Id: I876c4ac89ab206acca217b2287b0197ef2e408c2
35831e8bfa1c0944d4c978d99c4c5b9577945170 11-Sep-2015 Vladimir Marko <vmarko@google.com> Reduce memory used by CompiledMethods.

Use LengthPrefixedArray<>s instead of SwapVector<>s to store
CompiledMethod data and get rid of the unnecessary members
of CompiledMethod to reduce dex2oat memory usage. Refactor
the deduplication from CompilerDriver to a new class.

Use HashSet<> instead of std::set<> for the DedupeSet<> to
further decrease the memory usage and improve performance.

This reduces the dex2oat memory usage when compiling boot
image on Nexus 5 (with Optimizing, -j1) by ~6.75MiB (5%).
This also reduces the compile time by ~2.2% (~1.6% dex2oat
time; with Optimizing, without -j).

Change-Id: I974f1f5e58350de2bf487a2bca3907fa05fb80ea
1dad3f68b7f5a4a4cb2b281413357adc2309a8fd 23-Oct-2015 Nicolas Geoffray <ngeoffray@google.com> Support garbage collection of JITted code.

Change-Id: I9afc544460ae4fb31149644b6196ac7f5182c784
00310e0bb4ee541b99f0b687dbf5f706db2aabca 17-Oct-2015 Mathieu Chartier <mathieuc@google.com> Keep dex files live in class table

The DexFile.loadClass API allows callers to load classes using a
dex file without having that dex file owned by the specified class
loader. We now add the dex file to the class table to make sure it
stays live until the class loader is unreachable.

Fixes interpreter gcstress test 087 with 64 bit.

Bug: 22720414
Change-Id: Ia4341149f45b6293312f8b275c7a68cea179f718
06d7aaa75f3d6d21fe904d54208b28e486673d97 16-Oct-2015 Vladimir Marko <vmarko@google.com> Clean up OatFile.

In Setup(), avoid reading beyond the end and use the %zu
format specifier instead of %zd for size_t output.

Make the .bss section pointers non-const.

Change-Id: Ic8f066effe8037b552d8e911c6a5d17370d79ff4
32cc9ee0cdffecb0ec8d80a7fd55d7dccae3a7ee 15-Oct-2015 Mathieu Chartier <mathieuc@google.com> Change hash table load factors

Changed class table and intern table load factors to query the
runtime. The runtime returns load factors based on whether or not we
are a low ram device.

DescriptorEquals time for class linking goes from 10% -> 1.2% for
compiling GmsCore with interpret only.

Added test.

Bug: 24917584

Change-Id: Iaaf5d2eab1b0c2d188d299e4bc1852cdb3801173
09d0943f5efe92c1f3a6b9dbdf255adb0f960a22 08-Sep-2015 Vladimir Marko <vmarko@google.com> ART: Use .bss section for dex cache arrays.

Change-Id: I5fd507973b56f6a662a02a8c1dd9ac4493fb7b36
d57d454a11ac6f49eaa397ec14d6231e3a2727b7 14-Oct-2015 Mathieu Chartier <mathieuc@google.com> Allocate dex cache arrays in their class loader's linear alloc

Fixes memory leak for class unloading where the dex cache arrays
used to be in the runtime linear alloc which never got freed.

TODO: Some of the callers like the compiler just use the runtime
linear alloc. We could clean this up if we want to have class
unloading during compilation for some reason.

Added regression test.

Bug: 22720414

Change-Id: Ia50333a06a339efbdaedb5ad94b7a1ae841124ec
56a40f5530bae9bfb738479d28b799d3ea577a68 14-Oct-2015 Alex Light <allight@google.com> Cleanup interface initialization code to create fewer scopes

Make us not create scopes and handles in loops and instead just mutate
a single one.

Bug: 24618811

Change-Id: Ia16ed24c9914efa5a3358df24f0b2d05e2613910
e58991b3b2282b5761f1a6023a16c803e1c4eb45 13-Oct-2015 Mathieu Chartier <mathieuc@google.com> Revert "Revert "Unload oat files""

Fixed a race where two threads calling OatFile::Open could both use
dlopen on the host.

Bug: 22720414

This reverts commit 72da5e7461fec3b1e116050f2e6f233efb9c54f3.

Change-Id: I1636045b724944d2a09417527280784967957095
eb7c144a6aff7da673ba53d501c46f00311d4d7f 31-Aug-2015 Alex Light <allight@google.com> Add initial default method support to Art

This commit starts the process of adding default methods and their
associated pieces to ART.

This adds full support for calling default methods using
invoke-interface and invoke-virtual on objects implementing the
interfaces. Verifier is changed to allow this when the runtime is
started with -Xexperimental:default-methods.

This also adds support for defining and calling static methods on
interface classes with invoke-static.

Directly calling overridden default methods using invoke-super is not
yet supported.

This adds 5 new run-tests for this functionality.

Bug: 24618811

Change-Id: I35ca800d99d3329348b277789b70ceeeba6e7f03
72da5e7461fec3b1e116050f2e6f233efb9c54f3 13-Oct-2015 Nicolas Geoffray <ngeoffray@google.com> Revert "Unload oat files"

Tentative, will monitor bots if flakiness is fixed.

Bug: 22720414

This reverts commit 18656fefc7e68e2549a8fa93455074d359d1efa8.

Change-Id: I53b645b73207ccd21cad6ddac1de483bcc158794
6cfc2c086c47342fd8f5cb09f565979333066473 13-Oct-2015 Mathieu Chartier <mathieuc@google.com> Avoid visiting find array class cache as roots

If we visit the find array class cache as roots it will prevent
unloading for any array classes in the cache. This is not ideal
since it may take a long time for the entries to get replaced.

Also added a missed exception check in getDeclaredClasses.

Bug: 22720414

Change-Id: Id34557fd034b3e3967ef629301ee251931937849
18656fefc7e68e2549a8fa93455074d359d1efa8 10-Oct-2015 Mathieu Chartier <mathieuc@google.com> Unload oat files

Unregister and delete oat file when we call DexFile.closeDexFile if
all of the dex files are no longer in use. We store the oat file as
the first element of the dex files array (cookie).

Added a test that reads the proc maps to ensure there are no
unload-ex maps. Also some clean up.

Bug: 22720414

Change-Id: I52ab84562d1045e94b9a37aafe57609a14f188f7
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
22e0ce3a73760757e509032a324bbbb9a1a93f5e 09-Oct-2015 Mathieu Chartier <mathieuc@google.com> DO NOT MERGE Add locking to prevent races between setting class methods and marking

There was a race condition between VisitNativeRoots and threads which were
updating the lengths and pointers of the direct or virtual methods of classes.

For example:
The thread doing VisitNativeRoots could see a null pointer with a non 0 length if
another thread had changed the length but not the pointer.

The fix is already in master, do not merge.

Bug: 24270063
Change-Id: Id7280b9507b95703820aedb6c5fee49966dabe27
7778b880b9cf46fe7a303b11477bd92b5cf65316 06-Oct-2015 Mathieu Chartier <mathieuc@google.com> Disable class unloading when tracing is active

Tracing keeps a lot of pointers to ArtMethods that could belong to
classes that we are going to unload. A quick fix for this is to
disable class unloading when tracing is active.

Bug: 24414774
Bug: 22720414
Change-Id: Ia5619cbd7c9fd558eaa2a5000871d287213c4a76
4843bd5a0ba1d85e73f6e0ed7a24fa4a344cccb0 02-Oct-2015 Mathieu Chartier <mathieuc@google.com> Change DecodeWeakGlobal to DecodeJObject for class unloading

DecodeWeakGlobal returns the sentinel object for cleared JNI weak
globals. This was causing a memory leak since it wouldn't delete
class tables and linear allocs due to never returning null. The bug
was found by yamauchi.

Bug: 22720414

Change-Id: Iff4681495232b9a9756dbdb51d10ea72691a85dd
c3fcd41f15dffbb5f28c9900f421471a3d2dd420 26-Sep-2015 Mathieu Chartier <mathieuc@google.com> Address some code comments

Change-Id: I0a38a387c4328d45bbc04d095bf3388c27495c12
05aa4d3eb18bdcf2dab0addbc656f5ba28242043 19-Sep-2015 Mathieu Chartier <mathieuc@google.com> Enable class unloading

Also added class unloading test. Added a missing write barrier in
the class linker to fix a heap corruption error.

Bug: 22720414
Change-Id: Iff615d69b574a4438e91d4c844279d202f4f2736
951ec2c93c79c5539cbcc669566f0808d4460338 22-Sep-2015 Mathieu Chartier <mathieuc@google.com> Revert "Revert "Add one LinearAlloc per ClassLoader""

Issue was fixed by:
https://android-review.googlesource.com/#/c/171945/

Bug: 22720414

This reverts commit 7de5dfe37f3cf24e1166412b589f6f67dcd1f1c0.
7de5dfe37f3cf24e1166412b589f6f67dcd1f1c0 22-Sep-2015 Nicolas Geoffray <ngeoffray@google.com> Revert "Add one LinearAlloc per ClassLoader"

Times out on 32bit target/host for 132-daemon-locks-shutdown test.

Bug: 22720414

This reverts commit 356412e2b7ba3fde164bc08a44fee0ddc19c54e1.

Change-Id: I5ab3a09e88a5ad8c306a27d2606ecbecc80b9326
356412e2b7ba3fde164bc08a44fee0ddc19c54e1 21-Sep-2015 Mathieu Chartier <mathieuc@google.com> Add one LinearAlloc per ClassLoader

Also added freeing linear alloc and class table when the
corresponding class loader is no longer reachable.

Bug: 22720414

Change-Id: Icb32c3a4c865f240e147bc87ed080a6b1d8a5795
3d6b47018ecc8f469919d383b7d80568d94690cc 21-Sep-2015 Andreas Gampe <agampe@google.com> ART: Show the previous failure type in init rejection

Print the descriptor of the failure type when we reject re-init
on a previously failed class.

Bug: 24213543
Change-Id: Ied0f101b81e386951313edd09865a8b0142b9d16
498b160f0cb61ea4756d8ce859ae73c522366458 17-Sep-2015 Hiroshi Yamauchi <yamauchi@google.com> Allow null self only in DecodeWeakGlobalDuringShutdown().

To follow up CL 169855, allow a null current thread only in
DecodeWeakGlobalDuringShutdown() as a special case rather than
DecodeWeakGlobal(). This is to prevent a bug where null is accidentally
passed to DecodeWeakGlobal().

Bug: 23897251

Change-Id: I5e7bb78ec739b8bfcf77284ed321d507737ee33e
9b1c71ec77d92d63f1c2183b0cd3588727b2c265 03-Sep-2015 Mathieu Chartier <mathieuc@google.com> Make class loaders weak roots

Making the class loaders weak roots in the class linker prevents them
from keeping the classes as live. However we currently do mark them
as strong roots to make sure no accidental class unloading occurs
until the logic to free from linear alloc is complete.

Bug: 22720414

Change-Id: I57466236d9ce6fd064dda9a30ce8ab68094fb8b0
c77f3ab25939727346b0b6ec2f9421e218ac836a 04-Sep-2015 Mathieu Chartier <mathieuc@google.com> Clean up formatting in class linker

Change-Id: Ifc27dbe0b5fcabec439602e02f4128c063e1b120
05792b98980741111b4d0a24d68cff2a8e070a3a 03-Aug-2015 Vladimir Marko <vmarko@google.com> ART: Move DexCache arrays to native.

This CL has a companion CL in libcore/
https://android-review.googlesource.com/162985

Change-Id: Icbc9e20ad1b565e603195b12714762bb446515fa
ca33089f22aaebfb74229235b14adc24d3a91a4d 02-Sep-2015 Mathieu Chartier <mathieuc@google.com> No longer lock WeakGlobalsLock in FindDexCache

Since DecodeWeakGlobal is now usually lock free, it is faster to use
that instead of the locked version.

10x boot.oat compile on host -j4:
Before:
real 1m24.674s
user 3m40.446s
sys 0m15.749s

After:
real 1m14.529s
user 3m26.734s
sys 0m8.469s

Change-Id: I15bb10ad3a9bb2e6f8edb5dc0668267be821d603
673ed3d8aedc5462a47ded827c99f35d46525457 28-Aug-2015 Mathieu Chartier <mathieuc@google.com> Revert "Revert "Change dex caches to be weak roots""

This reverts commit 81a9087f0df0518c39405b7d18ba5858a6d8b77b.

Boot.oat creation time goes from 4.7s to 4.9s on host due to extra
locking. Will try to improve this in another CL.

Bug: 23602225
Bug: 22720414

Change-Id: I7e25b75cfb63faa196c7b0f60e46cce50bf12021
81a9087f0df0518c39405b7d18ba5858a6d8b77b 28-Aug-2015 Brian Carlstrom <bdc@google.com> Revert "Change dex caches to be weak roots"

This reverts commit 3ae6b1d42523bb2a0ddb5edff1aaf05b592f28f4.
ac8f4397f6978484fad6769526e9e3b3f7e7bd19 27-Aug-2015 Mathieu Chartier <mathieuc@google.com> Keep dex files live for duration of oatdump

Not keeping the dex file live caused a dex cache with a pointer to a
stale dex file resulting in oatdump failing. This is required to
remove the dex file location test that causes the class loader 068
test to fail.

Change-Id: I5d532862ab998482c0d16d7a63c6bdc3752f031a
5af910615a4b99eb7f493465bf3d42558c596237 27-Aug-2015 Mathieu Chartier <mathieuc@google.com> Re-add location check for FindDexCache

Fixes oatdump test.

Bug: 22720414

Change-Id: I4a7622ab9e47893deaea2c100fabfa1f3386a4bc
3ae6b1d42523bb2a0ddb5edff1aaf05b592f28f4 14-Aug-2015 Mathieu Chartier <mathieuc@google.com> Change dex caches to be weak roots

Changed dex caches to be weak roots. This is necessary for class
unloading since the resolved types arrays would keep classes live
when they should be unloaded. Currently the dex caches still don't
get freed due to the class loader roots.

Also deleted some unused functionality in image writer.

Bug: 22720414
Change-Id: If22cb3cad7e3baabc8158a77d7f20799faf4c341
66c2d2d64d7ea75602eb63de7ae9bd2eaeb0a3c2 25-Aug-2015 Mathieu Chartier <mathieuc@google.com> Address some comments for class flags

Change-Id: I354f48aefc37ce92c4d02cfce1723db0e28907bf
13e748b28c5f2bd1e83674d2ca899ff61ae5c0a1 25-Aug-2015 Jeff Hao <jeffhao@google.com> Revert "Revert "Move annotations to native.""

This reverts commit 7db6dd79a24570448ae737ee1946b00396696cac.

Adds check if field's declaring class is proxy.
Bug: 23508574

Change-Id: Ie829f1526e74427711e818b56d1588d92946cbf6
7db6dd79a24570448ae737ee1946b00396696cac 25-Aug-2015 Roland Levillain <rpl@google.com> Revert "Move annotations to native."

This reverts commit 0042c6d49b8488c78f0b937063e316e8d6244439.

Reverting this change (as well as the companion CL
https://android-review.googlesource.com/#/c/167510/ in
platform/libcore) as they make libcore test
libcore.java.lang.reflect.ProxyTest#test24846 fail.

Change-Id: Ie0676cabb128277c7df5dab7bde17aefd3b2c09c
0042c6d49b8488c78f0b937063e316e8d6244439 30-Jul-2015 Jeff Hao <jeffhao@google.com> Move annotations to native.

Art side of this change. There is also a corresponding Libcore change.

Seeing ~2-3x speedup over dalvik KK MR1 in AnnotatedElementBenchmark.
Benchmark Speedup of Art AOSP to Dalvik KK MR1
GetAllReturnsLargeAnnotation 2.99
GetAllReturnsMarkerAnnotation 2.20
GetAllReturnsNoAnnotation 2.43
GetAllReturnsSmallAnnotation 2.52
GetAllReturnsThreeAnnotations 2.87
GetAnnotationsOnSubclass 2.42
GetDeclaredAnnotationsOnSubclass 2.49
GetFieldAnnotation 2.68
GetFieldAnnotations 2.60
GetMethodAnnotation 2.66
GetMethodAnnotations 2.61
GetParameterAnnotations 2.52
GetTypeAnnotation 2.56
GetTypeAnnotations 2.17
IsFieldAnnotationPresent 3.26
IsMethodAnnotationPresent 4.99
IsTypeAnnotationPresent 1.34

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

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

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

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

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

Change-Id: I3f04212d5787bfbf5e55026584d149f55476105e
14632857428b7e37761e6e811c19021715a400f8 17-Aug-2015 Vladimir Marko <vmarko@google.com> ART: Rename ArtMethod's size and alignment methods.

Remove the historical prefix "Object" to avoid confusion
with Java objects.

Change-Id: Ib36422c9a24878d8d4bd757977d99cbf66b3d567
cf36d493124d8048efa0bd6f67d817ce3cd6b725 12-Aug-2015 Vladimir Marko <vmarko@google.com> ART: Compress LengthPrefixedArray on 32-bit targets.

Previously, the LengthPrefixedArray<ArtMethod> on 32-bit
targets contained a 64-bit length field followed by the
ArtMethod elements with size only a multiple of 4, not 8.
Consequently, an odd-length array broke the alignment for
the following array which would have the 64-bit length
placed at an unaligned address.

To fix that, we make the length field 32-bit and explicitly
pass the alignment information to the LengthPrefixedArray.
This also makes the 32-bit boot image a bit smaller.
On Nexus 5, AOSP, ToT, the field section is 11528B smaller
and the method section is 21036B smaller. 64-bit targets
should see the same savings for the field section but no
difference for the methods section.

Change-Id: I3e03e7b94129025c8a1c117c27645a34dec516d2
e4275c07e9852a6944f47efa9d0591fceb8e8e36 07-Aug-2015 Mathieu Chartier <mathieuc@google.com> Visit class roots from ClassLoader::VisitReferences

This causes the classes of a class loader to get marked when that
class loader gets marked instead of during class root visiting.

Bug: 22720414

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

Change-Id: I0262304cc720a0e93015955d0a7fb05dfebe213e
3ee25bb1df3df4f57c6a4c7d3957dd7303aa00d7 10-Aug-2015 Mathieu Chartier <mathieuc@google.com> Do read barriers on native roots in CopyClassVisitor

Fixes a race condition caused by making a copy of a class then
clearing the native root arrays of the original class. If the
original class was gray and the new class was black then the GC
would miss the native roots.

Bug: 22957957

Change-Id: I706110018220af12a2ad0d72eb803f1cfe3580b9
6b06953817bdf613b52389c457e2f4ed6cf46f5c 06-Aug-2015 Mathieu Chartier <mathieuc@google.com> Add class table field to class loader

Fixes bug with the class table where the comparator would cause read
barriers and break the map strict ordering properties.

Bug: 22957957

Change-Id: I8dbc042db6e22e2172ab4ec58ddf1db0345dcaaa
46e857a8b905a59254ca749f664d1e808918f558 06-Aug-2015 Sebastien Hertz <shertz@google.com> Fix image loading in interpeter-only mode

Follow-up https://android-review.googlesource.com/162935. We now need
an ArtMethodVisitor to update entrypoints of methods in the image.

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

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

Bug: 22832610
Change-Id: Ia21d6698f73ba207a6392c3d6b9be2658933073f
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
bc1d78daa463572c5a770cdca858a3b51d8e1b7b 31-Jul-2015 Igor Murashkin <iam@google.com> runtime: cleanup class_linker out-parameters and formatting

* Use out<T> instead of parameters
* Fixes up some other signatures to be more correct
* Reformat parameters to be one per line if they can't fit on one line
* Reformat locks to be one per line if they can't fit on the decl line

Change-Id: Ib71b08707d3ed0bb85299406c0b23a1de4e92a1c
40c8141b48275afd1680b99878782848ab3a6761 01-Aug-2015 Igor Murashkin <iam@google.com> Revert "runtime: cleanup class_linker out-parameters and formatting"

This reverts commit 0de694ed3efe8412b83622a24074831edcc7e384.

Change-Id: I4b185584d6e47918179b16d76709cc3366872f3c
0de694ed3efe8412b83622a24074831edcc7e384 31-Jul-2015 Igor Murashkin <iam@google.com> runtime: cleanup class_linker out-parameters and formatting

* Use out<T> instead of parameters
* Fixes up some other signatures to be more correct
* Reformat parameters to be one per line if they can't fit on one line
* Reformat locks to be one per line if they can't fit on the decl line

Change-Id: I1031cf4edc41f95b89edb343d43ef93e15384206
eb837eb7c27e789bc7b05f474be9aa119f2fd99f 30-Jul-2015 Mathieu Chartier <mathieuc@google.com> Clear temporary class arrays before linking the new class

Fixes DCHECK failure from remembered sets where two classes had the
same field array which caused the remembered set to incorrectly
remove a card with a reference to the target space.

Change-Id: If43875616fb750e20667212381bc7e359c4214a5
e0671ce5a6cb34e44e3afefa8e29c0c3e30d2855 29-Jul-2015 Mathieu Chartier <mathieuc@google.com> Clean up class visitors

Move from function pointers to virtual function visitors.

Change-Id: I68cb83c1d2ed9b5a89f8e534fe7ca4bbc1c91f45
cc5ebdf29ea47e24e79279169e0192dfc08b38c8 27-Jul-2015 Mathieu Chartier <mathieuc@google.com> Split the class table for each class loader

Each class loader now has its own class table. This makes it easier
to mark classes when a classloader is marked.

Fixed a bug in LookupClass where we used to look ignore the return
value of InsertClass.

Bug: 22720414

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

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

Bug: 22181835
Change-Id: I63f31e5ebef7b2a0b764b3ba3cb038b3f561b379
4e2cb098017bf073335ebb02b1bc0a36828cd720 23-Jul-2015 Mathieu Chartier <mathieuc@google.com> Add uninterruptible role

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

TODO: Add annotation to more locations.

Bug: 20072211

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

Also enable -Wthread-safety-negative.

Changes:
Switch to capabilities and negative capabilities.

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

Bug: 20072211

Change-Id: I42fcbe0300d98a831c89d1eff3ecd5a7e99ebf33
7617abdb402fd0419daa3eefb2ad059ccbb8b6db 11-Jul-2015 Igor Murashkin <iam@google.com> runtime: Add -Xverify:softfail and ART_TEST_INTERPRETER_ACCESS_CHECKS

Use ART_TEST_INTERPRETER_ACCESS_CHECKS=true to run all the tests through
the interpreter with access checks enabled. The normal interpreter tests
do not currently enable access checks, which means that a large part of
the interpreter codebase is untested.

The verifier will force every class into a soft fail mode if
-Xverify:softfail is used, thereby ensuring that if used along with the
interpreter (-Xint) that the interpret is always in access checks mode.

This is used alongside with --compile-filter=verify-at-runtime to
prevent the AOT compiler from putting down any code.

Change-Id: I35a10ed8c43d76fa96133cf01fdad497da387200
14d90579f013b374638b599361970557ed4b3f09 16-Jul-2015 Roland Levillain <rpl@google.com> Use (D)CHECK_ALIGNED more.

Change-Id: I9d740f6a88d01e028d4ddc3e4e62b0a73ea050af
fab6788358dfb64e5c370611ddbbbffab0ed0553 14-Jul-2015 Richard Uhler <ruhler@google.com> Fix FieldGap priority queue ordering bug.

The priority queue for keeping track of gaps when packing fields in a
class object had the order reversed, giving priority to smaller gaps
instead of priority to larger gaps. This led to cases where fields
were not placed in gaps when they could be.

Bug: 22460222
Change-Id: I062e772e030c034adc227d75deed31c3322e203e
c04c800e7bda94abfadc8c2d30f58c50b261b612 14-Jul-2015 Nicolas Geoffray <ngeoffray@google.com> Revert "Revert "Revert "Revert "Make dex2dex return a CompiledMethod after quickening.""""

This reverts commit ed6195a514e3253576af27ea9ba13038509d29ac.

Change-Id: Icb58854301e8982147cdebe3edf2e0d9e0a63a56
7bf2b4f1d08050f80782217febac55c8cfc5e4ef 08-Jul-2015 Nicolas Geoffray <ngeoffray@google.com> Revert "Revert "Remove interpreter entrypoint in ArtMethod.""

The start of the interned strings in the image was not aligned
properly, now that ArtMethods just need to be word aligned.

This reverts commit 7070ccd8b6439477eafeea7ed3736645d78e003f.

bug:22242193

Change-Id: I580c23310c33c239fe0e5d15c72f23a936f58ed1
7070ccd8b6439477eafeea7ed3736645d78e003f 08-Jul-2015 Nicolas Geoffray <ngeoffray@google.com> Revert "Remove interpreter entrypoint in ArtMethod."

Build failures on bots. Investigating.

This reverts commit fa2c054b28d4b540c1b3651401a7a091282a015f.

Change-Id: Id65b2009aa66cb291fb8c39758a58e0b0d22616c
fa2c054b28d4b540c1b3651401a7a091282a015f 01-Jul-2015 Nicolas Geoffray <ngeoffray@google.com> Remove interpreter entrypoint in ArtMethod.

Saves 4/8 bytes for each ArtMethod.

Change-Id: I110ecdddf8516b0759a31fa157609643e6d60b15
23682bf61e91a4c34373d55b085ab7cbade3ed1b 24-Jun-2015 Vladimir Marko <vmarko@google.com> ART: Ignore repeated field indexes when loading a class.

This provides a deterministic behavior for classes with
duplicate field indexes in class_data_item and avoids
failures when verifying the field ordering in debug build.

Regression test not feasible without hand-edited dex file.
(Smali deduplicates field definitions.)

Bug: 21868015
Change-Id: I4f97ba005e063686f8f44248ed7f1286d987888a
9b994ea841eaaefbdda652251894a74db9cefcc8 24-Jun-2015 Richard Uhler <ruhler@google.com> Do not try to compile resource-only dex files.

This changes behavior in the case where we are asked to load a dex
file that does not exist or has no classes.dex entry.

Previously we would run dex2oat, which would log an error message and
fail. Now we skip running dex2oat, we report the DexOptStatus as
kNoDexOptNeeded, and we do not try to fall back to the missing
original dex files.

Bug: 21722039
(cherry picked from commit cb44b11a926696e34b3dc44288e762b4303cc128)

Change-Id: I84a85dc9ece54bcc0a5283f871e09bf68471c6e7
cb44b11a926696e34b3dc44288e762b4303cc128 24-Jun-2015 Richard Uhler <ruhler@google.com> Do not try to compile resource-only dex files.

This changes behavior in the case where we are asked to load a dex
file that does not exist or has no classes.dex entry.

Previously we would run dex2oat, which would log an error message and
fail. Now we skip running dex2oat, we report the DexOptStatus as
kNoDexOptNeeded, and we do not try to fall back to the missing
original dex files.

Bug: 21722039
Change-Id: I90b1f4165138daac57bb9d7a354319005652c593
555b3d0fc62ecccb590dc8a07736ca4eda8722e7 23-Jun-2015 Nicolas Geoffray <ngeoffray@google.com> Use GetOffsetDuringLinking instead of GetOffset.

GetOffset assumes the class has been resolved, but LinkFields
is called before the class is marked as such.

Change-Id: I6f9fc21cd220881806f00461a82a14e459e26a8b
d4d83b84e14fdb3cba808fc5f94390c72b3d286a 20-Jun-2015 Mathieu Chartier <mathieuc@google.com> Fix another miranda method moving GC bug

Need to copy miranda methods over before we allocate the new vtable
or else we may have stale miranda gc roots.

(cherry picked from commit 6e80460bdf0aa9bd273d4a4d665d679c651b5f4f)

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

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

Added runtime -Xgc options: gcstress and nogcstress.

Bug: 21664466

(cherry picked from commit 310008008c90fea246efd00cb99ee7ded97c5209)

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

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

Added runtime -Xgc options: gcstress and nogcstress.

Bug: 21664466

Change-Id: Icb8e420f2048e8ee83bcca7937563166a2638f5c
6e80460bdf0aa9bd273d4a4d665d679c651b5f4f 20-Jun-2015 Mathieu Chartier <mathieuc@google.com> Fix another miranda method moving GC bug

Need to copy miranda methods over before we allocate the new vtable
or else we may have stale miranda gc roots.

Bug: 21664466
Change-Id: Ib3e415bb9e7df7abfa18c98fe01f790fa39622dc
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
4d122c180c3ff8c677cbaae83e856acf0d856498 17-Jun-2015 Mathieu Chartier <mathieuc@google.com> Add missing EndAssertNoThreadSuspension

(cherry picked from commit a3b9d4eda1ef0845f307891f349eaf752750ac16)

Bug: 21872507
Change-Id: I20f9920e4a12511ce498c252bca955d82a4f4102
a3b9d4eda1ef0845f307891f349eaf752750ac16 17-Jun-2015 Mathieu Chartier <mathieuc@google.com> Add missing EndAssertNoThreadSuspension

Bug: 21872507
Change-Id: I20f9920e4a12511ce498c252bca955d82a4f4102
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
69b5d8febe6dd552d427c106f3e3f8cf715206b0 04-Jun-2015 Andreas Gampe <agampe@google.com> Revert "Revert "Turn off duplicate-classes checking""

This reverts commit 18a1827a159f1b235f3fcc934f428059185f550e.

Bug: 21333911

(cherry picked from commit 0fc16a09b4d2323f9c2b6aabc81ce120b278329b)

Change-Id: I8cb96efbf7151b238f3ee137a938b20ddfaf0ebc
12768a0b8cd6d1fd4953e24cd84edfbc3d8a9d79 21-May-2015 Andreas Gampe <agampe@google.com> Revert "DO NOT MERGE ART: Turn off duplicate-classes checking"

This reverts commit aafcfca5fe545365ef377fff2897b8a908f03e71.

Bug: 21333911

(cherry picked from commit 18a1827a159f1b235f3fcc934f428059185f550e)

Change-Id: Ibbc6b1be8bebc1d0ab9c5955b34eb89f40577baa
fc3f39eafd4c27f5f616f309c9cbff80d88a48ed 20-May-2015 Andreas Gampe <agampe@google.com> DO NOT MERGE ART: Turn off duplicate-classes checking

Bug: 21333911

(cherry picked from commit aafcfca5fe545365ef377fff2897b8a908f03e71)

Change-Id: I9832526a6d2996aadb459e3ec0930cbaf151478a
0fc16a09b4d2323f9c2b6aabc81ce120b278329b 04-Jun-2015 Andreas Gampe <agampe@google.com> Revert "Revert "Turn off duplicate-classes checking""

This reverts commit 18a1827a159f1b235f3fcc934f428059185f550e.

Bug: 21333911
Change-Id: I8cb96efbf7151b238f3ee137a938b20ddfaf0ebc
8ac75952f13f0a80803628f0c2aa06120ad42126 03-Jun-2015 Andreas Gampe <agampe@google.com> ART: Prune FindArrayClass cache in image writer

The ClassLinker cache speeds up FindArrayClass requests, but all
entries are roots. It is possible that an entry is a non-image
class when creating the boot image, artificially keeping the
class around.

Bug: 21596650

(cherry picked from commit 44905ce1c97613a5cb44046049843fe1029a64cf)

Change-Id: Ief9b439945d0e293a3cb5dcddfeb189b5e174f06
44905ce1c97613a5cb44046049843fe1029a64cf 03-Jun-2015 Andreas Gampe <agampe@google.com> ART: Prune FindArrayClass cache in image writer

The ClassLinker cache speeds up FindArrayClass requests, but all
entries are roots. It is possible that an entry is a non-image
class when creating the boot image, artificially keeping the
class around.

Bug: 21596650
Change-Id: Ief9b439945d0e293a3cb5dcddfeb189b5e174f06
a40c74a7a4341257cf14822d54ca233617216129 02-Jun-2015 Mathieu Chartier <mathieuc@google.com> Update IMT for stale miranda methods

Fixes occasional crash in dex2oat.

(cherry picked from commit 519fd543625da68ef93f0cd5539c949e5e74e04e)

Bug: 19264997
Change-Id: Icb1a323d8c44fa40309486e17aec56d2c2588e67
519fd543625da68ef93f0cd5539c949e5e74e04e 02-Jun-2015 Mathieu Chartier <mathieuc@google.com> Update IMT for stale miranda methods

Fixes occasional crash in dex2oat.

Bug: 19264997
Change-Id: Icb1a323d8c44fa40309486e17aec56d2c2588e67
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
cf3b1a3fb0c37ffa596dfae62f86b46a4d521c41 01-Jun-2015 Mathieu Chartier <mathieuc@google.com> Copy miranda methods before suspend point

This fixes a bug where moving GC could happen at vtable CopyOf and
result miranda methods having stale pointers since they are not part
of the class roots at this point.

Also some minor cleanup.

Bug: 21564728
Change-Id: Ife520db6973782e40edcb2074c17274b799af738
4edd8476339fd93ba8ff384ad107f1fc662e64a3 01-Jun-2015 Mathieu Chartier <mathieuc@google.com> Fix accidental IMT and root marking regression

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

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

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

Bug: 19264997
Change-Id: I4333e80a8268c2ed1284f87f25b9f113d4f2c7e0
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
a2ea7405471f6fd7fd5b0d52abb9ad8497c2d144 08-May-2015 Vladimir Marko <vmarko@google.com> Fix double-exception in super-class method validation.

Bug: 19333589

(cherry picked from commit d5e5a0e61b5b1fe0aaa7edc25a08adebd5a92353)

Change-Id: If394a678ef6271c1119dac3f959773f23e789c56
d5e5a0e61b5b1fe0aaa7edc25a08adebd5a92353 08-May-2015 Vladimir Marko <vmarko@google.com> Fix double-exception in super-class method validation.

Bug: 19333589
Change-Id: I2399c4058d488bbdbf6709c63e367f1b7c251b1d
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
679b1cf291f364dcc3a142f53a07b0ad15c01e9a 21-May-2015 Hiroshi Yamauchi <yamauchi@google.com> Fix for potential moving GC bugs around proxy class.

- Handlerize proxy_class which is live across multiple allocation
points in ClassLinker::CreateProxyClass().

- In ClassLinker::CreateProxyClass(), insert a proxy class into the
class table before creating ArtFields for it (and update it later in
LinkClass()) because the field roots (ArtField::declaring_class_)
won't be updated by GC unless the class is in the class table. If GC
happens before they are updated by FixupTemporaryDeclaringClass()
from LinkClass(), FixupTemporaryDeclaringClass() may not update the
field roots correctly because the old class may already be moved but
the fields roots may not. Reduce a window of time where the fields
roots could be stale.

- In ClassLinker::LinkClass(), directly wrap a new class in a handle
to avoid a window of time where new_class may be potentially stale.

- Print more diagnostic info about the holder of the field upon a mark
sweep invalid ref crash.

- Add an additional sanity check in Field::GetArtField().

(cherry pick commit 08d1b5f2296c0f51507b8b443f4e39dfc161572c)

Bug: 20557050

Change-Id: I9ad32d304922da96b7e1fad262d97de21cbac776
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
f39c9eb7f85de1c4ddd50ab9ca0e095e62ce2518 26-May-2015 Roland Levillain <rpl@google.com> Fix a few literals and assertions.

Change-Id: I0a1e9db607ec7325e17568b034ba90e68d2298f9
08d1b5f2296c0f51507b8b443f4e39dfc161572c 21-May-2015 Hiroshi Yamauchi <yamauchi@google.com> Fix for potential moving GC bugs around proxy class.

- Handlerize proxy_class which is live across multiple allocation
points in ClassLinker::CreateProxyClass().

- In ClassLinker::CreateProxyClass(), insert a proxy class into the
class table before creating ArtFields for it (and update it later in
LinkClass()) because the field roots (ArtField::declaring_class_)
won't be updated by GC unless the class is in the class table. If GC
happens before they are updated by FixupTemporaryDeclaringClass()
from LinkClass(), FixupTemporaryDeclaringClass() may not update the
field roots correctly because the old class may already be moved but
the fields roots may not. Reduce a window of time where the fields
roots could be stale.

- In ClassLinker::LinkClass(), directly wrap a new class in a handle
to avoid a window of time where new_class may be potentially stale.

- Print more diagnostic info about the holder of the field upon a mark
sweep invalid ref crash.

- Add an additional sanity check in Field::GetArtField().

Bug: 20557050

Change-Id: I9ad32d304922da96b7e1fad262d97de21cbac776
18a1827a159f1b235f3fcc934f428059185f550e 21-May-2015 Andreas Gampe <agampe@google.com> Revert "DO NOT MERGE ART: Turn off duplicate-classes checking"

This reverts commit aafcfca5fe545365ef377fff2897b8a908f03e71.

Bug: 21333911
Change-Id: Ibbc6b1be8bebc1d0ab9c5955b34eb89f40577baa
aafcfca5fe545365ef377fff2897b8a908f03e71 20-May-2015 Andreas Gampe <agampe@google.com> DO NOT MERGE ART: Turn off duplicate-classes checking

Bug: 21333911
Change-Id: I9832526a6d2996aadb459e3ec0930cbaf151478a
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
8b83b55de8abbc195c038789f1034107f4974597 30-Apr-2015 Andreas Gampe <agampe@google.com> ART: Allow oat files with duplicates classes in corner case

When the oat file is actually an odex file, that is, a preopted
/system app, then it is impossible to fall back to the original
APK, as that has been stripped.

When it looks like it will be impossible to successfully open the
original dex location, grudgingly allow to open the found oat file,
even if it has duplicate classes, but warn accordingly.

Bug: 20697582

(cherry picked from commit 0cba004b97245300d7f39318d5921ee8edbef1ac)

Change-Id: I1dd459563d977a2e77806eacd03e49334d5b1f14
0cba004b97245300d7f39318d5921ee8edbef1ac 30-Apr-2015 Andreas Gampe <agampe@google.com> ART: Allow oat files with duplicates classes in corner case

When the oat file is actually an odex file, that is, a preopted
/system app, then it is impossible to fall back to the original
APK, as that has been stripped.

When it looks like it will be impossible to successfully open the
original dex location, grudgingly allow to open the found oat file,
even if it has duplicate classes, but warn accordingly.

Bug: 20697582
Change-Id: I1dd459563d977a2e77806eacd03e49334d5b1f14
848f70a3d73833fc1bf3032a9ff6812e429661d9 15-Jan-2014 Jeff Hao <jeffhao@google.com> Replace String CharArray with internal uint16_t array.

Summary of high level changes:
- Adds compiler inliner support to identify string init methods
- Adds compiler support (quick & optimizing) with new invoke code path
that calls method off the thread pointer
- Adds thread entrypoints for all string init methods
- Adds map to verifier to log when receiver of string init has been
copied to other registers. used by compiler and interpreter

Change-Id: I797b992a8feb566f9ad73060011ab6f51eb7ce01
94329d31d2a99c9aff889b88ba4b675135409b82 25-Apr-2015 Andreas Gampe <agampe@google.com> ART: Duplicate-classes cleanup

Disable old test. Improve collision warning message. Add a comment
about the algorithm.

Change-Id: Ibd29d79565732162150aebd7fe08d0895ccf3d79
b9aec2ccd8b9f39a4ddadde5ca8304cea6b1b188 24-Apr-2015 Andreas Gampe <agampe@google.com> ART: Check for duplicate classes when loading oat files

Oat files are usually produced standalone, and the compilers take
advantage of any information they get. It is thus possible that
when compile-time and runtime class-path are not the same, classes
are resolved differently and optimized code is incorrect.

This is a very conservative check, scanning the complete class tables
of dex files. In case any duplicate class is found, the new oat file
will be rejected and the original dex files will be used in interpreted
mode.

A possible refinement to this is actual tracking of the compile-time
class-path instead. That is however significantly complicated by the
DexFile API and the non-standard uses it allows.

An alternative for both optimized code and correct resolution is
native multidex. Apps should switch to multidex and benefit from
the optimization as well as the shift of all compile time to install
time. Split APKs are currently compiled separately, but it is a goal
to change that install flow to simulated multidex.

Change-Id: Ib9e0db5091e060e3bb2c0e5e6c007430becbfc21
bfdcdc1e2c0af34aeaf7b5b4d499975e0c3157be 23-Apr-2015 Andreas Gampe <agampe@google.com> ART: Fix re-throwing failures of non-convention errors

While it is convention that Throwable subclasses should have a
constructor with a String argument, that is not rigorously enforced.
So if a static initializer throws an error that omits that
constructor, we must not provide a message when trying to throw
again.

Bug: 20495321
Bug: 20497840
Change-Id: Ia4334fa24223750f90a8f2732f1eb1e738575e8d
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
fc58af45e342ba9e18bbdf597f205a58ec731658 17-Apr-2015 Mathieu Chartier <mathieuc@google.com> Add AbstractMethod, Constructor, Method

Moves functionality to ART from libcore. Precursor to moving
ArtMethods to native. Mostly performance improvements.

N5 perf before (irrelevant results removed):
Class_getConstructor 962.87 ===========
Class_getDeclaredMethod 2394.37 ============================
Class_getMethod 2509.20 ==============================
Class_newInstance 1999.81 =======================
Method_invokeI 1439.02 =================
Method_invokePreBoxedI 1415.82 ================
Method_invokeStaticI 1456.24 =================
Method_invokeStaticPreBoxedI 1427.32 =================
Method_invokeStaticV 814.47 =========
Method_invokeV 816.56 =========
After:
benchmark ns linear runtime
Class_getConstructor 1302.04 ================
Class_getDeclaredMethod 1459.01 ==================
Class_getMethod 1560.40 ===================
Class_newInstance 2029.94 =========================
Method_invokeI 1312.89 ================
Method_invokePreBoxedI 1255.01 ===============
Method_invokeStaticI 1289.13 ===============
Method_invokeStaticPreBoxedI 1196.52 ==============
Method_invokeStaticV 790.82 =========
Method_invokeV 791.73 =========

Performance improvements are more than just fixing regressions introduced
in: http://android-review.googlesource.com/#/c/146069/

Bug: 19264997

Change-Id: Ife79c469fdb09f30e3aefcfc3e0ce5ed32303fce
f3f2a7a0dac552593825807605c98f3910f3e557 15-Apr-2015 Mathieu Chartier <mathieuc@google.com> Remove suspend point from field loading

The error was that we had a partially constructed field array when we
got suspended by moving GC. This caused the already allocated fields
to not get updated, and be stale roots the next GC. Fixes test 125
with GSS collector.

Change-Id: I7278def915f540b6a9d12677a6ba61637f5949a2
f865ea9557e6fe017caf99832dc3adf9fadbf86f 14-Apr-2015 Andreas Gampe <agampe@google.com> ART: Make the PathClassLoader fast-path recursive

Allow an arbitrary nesting of path class-loaders. This will also
handle the fake java.lang.BootClassLoader as a class-loader object
correctly (which is of some importance to compile-time initialization).

Bug: 19781184
Bug: 19542228
Change-Id: I61f0249cf4ec8df08a83ccbd29bcf067619c28c0
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
4809d0a8a5fca85a67dd0588ead5dfbd0f1acf96 07-Apr-2015 Mathieu Chartier <mathieuc@google.com> Fix CC root visiting bug

Also some cleanup.

Change-Id: Ia3de8f2d409770be3619ec116e8b06ecd82338fe
bb87e0f1a52de656bc77cb01cb887e51a0e5198b 03-Apr-2015 Mathieu Chartier <mathieuc@google.com> Refactor and improve GC root handling

Changed GcRoot to use compressed references. Changed root visiting to
use virtual functions instead of function pointers. Changed root visting
interface to be an array of roots instead of a single root at a time.
Added buffered root marking helper to avoid dispatch overhead.

Root marking seems a bit faster on EvaluateAndApplyChanges due to batch
marking. Pause times unaffected.

Mips64 is untested but might work, maybe.

Before:
MarkConcurrentRoots: Sum: 67.678ms 99% C.I. 2us-664.999us Avg: 161.138us Max: 671us

After:
MarkConcurrentRoots: Sum: 54.806ms 99% C.I. 2us-499.986us Avg: 136.333us Max: 602us

Bug: 19264997

Change-Id: I0a71ebb5928f205b9b3f7945b25db6489d5657ca
2fd7e69505195cda4caaa3161aaf37315552a698 02-Apr-2015 Sebastien Hertz <shertz@google.com> Use specific exception class to abort transaction

We used to throw a java.lang.InternalError when aborting a
transaction (when preinitializing image classes at compilation time).

We now use dedicated class dalvik.system.TransactionAbortError that
is only thrown by the compiler to abort a transaction. This class has
constructors taking a java.lang.Throwable "cause" so we can wrap
exceptions causing the transaction to abort (for instance class
java.lang.ClassNotFoundException) and give more information about the
cause of the transaction abort.

Bug: 20019689
Change-Id: I019a72a1c754d8bba6a7ad6bb0f02e4fd6668622
07b3c2351bb527ea91c084dc19434600af9ae66b 01-Apr-2015 Richard Uhler <ruhler@google.com> Store OatDexFile instead of OatFile in DexFile.

This requires moving OatDexFile out of the OatFile class so that
a forward class declaration can be used for OatDexFile.

Bug: 19071355
Change-Id: Ibda85b78d0577e9e81073090616fc0f2fa526be3
daaf3265806eb2eadb2e03302bd68022fab5ca28 24-Mar-2015 Mathieu Chartier <mathieuc@google.com> Add AccessibleObject and Field to mirror

Main motivation is to remove all the functionality / field access on
java side to ArtField. Also comes with some reflection speedups /
slowdowns.

Summary results:
getDeclaredField/getField are slower mostly due to JNI overhead.
However, there is a large speedup in getInt, setInt,
GetInstanceField, and GetStaticField.

Before timings (N5 --compiler-filter=everything):

benchmark ns linear runtime
Class_getDeclaredField 782.86 ===
Class_getField 832.77 ===
Field_getInt 160.17 =
Field_setInt 195.88 =
GetInstanceField 3214.38 ==============
GetStaticField 6809.49 ==============================

After:
Class_getDeclaredField 1068.15 ============
Class_getField 1180.00 ==============
Field_getInt 121.85 =
Field_setInt 139.98 =
GetInstanceField 1986.15 =======================
GetStaticField 2523.63 ==============================

Bug: 19264997

Change-Id: Ic0d0fc1b56b95cd6d60f8e76f19caeaa23045c77
e48856666e2e959687660f3b708e0c6da210ecb2 28-Mar-2015 Andreas Gampe <agampe@google.com> ART: Use instrumented Alloc in Class-Linker

To support Valgrind over dex2oat and gtests, CreatePathClassLoader
must use instrumented allocation.

Change-Id: I9dc2d009d37bec598c5de67688ebf9810da6e899
81c6f8db12b203878a7d72444ead2bc7cf5c47ad 26-Mar-2015 Andreas Gampe <agampe@google.com> ART: PathClassLoader for compiler

Use an actual PathClassLoader when compiling apps, instead of a
side structure and cutout.

This CL sets up a minimal object 'cluster' that recreates the Java
side of a regular ClassLoader such that the Class-Linker will
recognize it and use the internal native fast-path.

This CL removes the now unnecessary compile-time-classpath and
replaces it with a single 'compiling-the-boot-image' flag in the
compiler callbacks.

Note: This functionality is *only* intended for the compiler, as
the objects have not been completely initialized.

Bug: 19781184

Change-Id: I7f36af12dd7852d21281110a25c119e8c0669c1d
d8565456d29f4ad05f11cf84d2d2dac488508e06 26-Mar-2015 Mathieu Chartier <mathieuc@google.com> Fix ClassLinker::MayBeCalledWithDirectCodePointer for JIT

Currently, we don't know if another method has a direct code
pointer or not. This should fix the case where breakpoints
occasionally don't work with JIT.

The JIT now also checks that a method doesn't have any breakpoints
before starting to compile it.

Bug: 17950037

Change-Id: I17cfe874fe4825beba23903a5053d5cb27e106cb
5b783e66b26b7b6ee13d344f4b77f6b7c47c4723 19-Mar-2015 Hiroshi Yamauchi <yamauchi@google.com> Fix 003-omnibus-opcodes flaky failures with GSS GC.

Fix a moving GC bug in Class::SetStatus().

Bug: 19828874

Change-Id: I6bef49a7ce964e8a7e316f282aaf1b8544efe76d
47f867a0ae34d743f6159c2261e5b11e39693e15 18-Mar-2015 Mathieu Chartier <mathieuc@google.com> Clean up hash set

Added vertical whitespace, const iterators, made some functions
const.

Change-Id: I188dc0384a98d6dae2822f0ac38b740f2356c23d
0aa50ce2fb75bfc2e815a0c33adf9b049561923b 10-Mar-2015 Nicolas Geoffray <ngeoffray@google.com> Remove ThrowLocation.

Note that this is a cleanup change, and has no functionality change.
The ThrowLocation had no use anymore.

Change-Id: I3d2126af1dc673cec3a0453ff3d56a172663a5f6
66d874d96d5699bb090c59f47a5a528956ca053e 15-Jan-2015 Richard Uhler <ruhler@google.com> Create OatFileAssistant class for assisting with oat files.

The oat file assistant is used for determining whether dex2oat or
patchoat is needed, for running dex2oat or patchoat as needed to make
an oat file up to date, and to load dex files associated with a given
dex location.

The introduction of the OatFileAssistant class is meant to clean up and
consolidate code related to the management of oat files that was
duplicated and spread across dalvik_system_DexFile.cc and
class_linker.cc.

Bug: 11301553
Change-Id: I0c16027b9bae4570c2c50faa9c14f581c0cbafb8
14691c5e786e8c2c5734f687e4c96217340771be 05-Mar-2015 Nicolas Geoffray <ngeoffray@google.com> Compute the right catch location for the debugger.

Also remove tls ThrowLocation, it is not needed anymore.

Change-Id: I78fddf09ce968ca475e39c17fa76d699c589c8d9
bd9cf9f6bbf285ec7a5b74ce655a9e68e0f6e434 03-Mar-2015 Sebastien Hertz <shertz@google.com> Follow-up 128393

Avoids false warning when initializing the exception's class by
marking the transaction aborted after throwing the InternalError
exception.

Also uses VLOG(compiler) to print the warning since it's only useful
when investigating ahead-of-time class initialization.

Bug: 19202032
Change-Id: I3c53639cbb888086ad345d668d1e5b73c5aaf861
c0d5f89d99c55ab63d6757fbd71dbfe95d347c1f 25-Feb-2015 Mathieu Chartier <mathieuc@google.com> Fix JIT for vmdebug test 99

Test was flaky due to JIT re-compiliation after deoptimization
resulting in some invalid PC offsets.

Bug: 17950037
Change-Id: I276c84c918579259ce47ef873892c3c5dcf0c977
324b9bb2f48be39e20077c1d7da45cf3dc47fe06 24-Feb-2015 Andreas Gampe <agampe@google.com> ART: Move DexFile vector to Java array

To avoid having native vectors only referenced by Java objects,
which look like leaks to Valgrind, use a Java array to store
references to native DexFile objects.

Change-Id: If3c2b31b9d0914ed1965cfd5e3fdb94ea41b1477
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
24e04aa68c575d349eac0d9d09aab9bd3106ef94 12-Sep-2014 Jean Christophe Beyler <jean.christophe.beyler@intel.com> ART: Allow the execution to stop if the compilation fails via an option

The current implementation continues the execution of the application if
dex2oat fails by relying on the interpreter.

This patch adds a -Xno-dex-file-fallback option to stop the default behavior.
This can be used two-fold.

First, one can enforce that a runtime only starts with a boot image. A
follow-up patch will ensure that dex2oat (for apps) and patchoat in general
request that mode and close gracefully otherwise.

Second, this can be used for testing and debugging purposes, as it ensures
that compiler failures & aborts are not silently ignored.

Add testing.

Bug: 19100590
Change-Id: Iaf07b5ccf00942ca8a8ec8687599320a3ddbc089
Signed-off-by: Jean Christophe Beyler <jean.christophe.beyler@intel.com>
f52857f4735a49a2a15305b3d1edf808a126b164 19-Feb-2015 Andreas Gampe <agampe@google.com> ART: Ensure order of field gaps

Disambiguate field gaps of same size by starting offset. That will
make the priority queue stable.

Bug: 19413180
Change-Id: I6302a8bbdc590af7e9ec4f332c386c375fa8d8cd
ab1eb0d1d047e3478ebb891e5259d2f1d1dd78bd 14-Feb-2015 Andreas Gampe <agampe@google.com> ART: Templatize IsInt & IsUint

Ensure that things are used correctly.

Change-Id: I76f082b32dcee28bbfb4c519daa401ac595873b3
e4301ffb56f9be6f6c2640bfb1870b74f4a37ad2 18-Feb-2015 Andreas Gampe <agampe@google.com> ART: Make run-tests more verbose

Make run-tests log ERROR level on host. Adjust some internal LOG(ERROR)
to LOG(WARNING). Add check scripts to adjust for other LOG(ERROR)
messages.

Bug: 18713034
Change-Id: I2a3e055baa6a0e31f106364c300c20963a59ed94
d8ca52e28ea00d1f23866a421791935e13b42bce 14-Feb-2015 Andreas Gampe <agampe@google.com> ART: Add more details to LinkageError

Add the classes or method details that fail during linking to enable
better diagnosis of problems.

Bug: 19294695
Change-Id: Ifab48bc182cd801d44d3aead2168028f27043be0
862f43c65652d132e73eff89667a11c9757e817d 10-Feb-2015 Vladimir Marko <vmarko@google.com> Fix HasSameSignatureWithDifferentClassLoaders().

Add a missing handle and make sure that the handle's
Get() is sequenced after the call that can cause GC.

Change-Id: I3c0479650c40ceb803bfbf658238aeea8e4b0a1a
c7d11887725e28db2796c848f4485e59d5eb690c 04-Feb-2015 Jeff Hao <jeffhao@google.com> Handle variable size of methods properly between 32 and 64 bit.

Bug: 19100762
Change-Id: I62358905fa882284d0201ed3c1e97e1286ccec5f
1c80becf5406cd6d95dc24bf47a0c5a3809ea281 03-Feb-2015 Sebastien Hertz <shertz@google.com> Fix transaction aborting

During compilation, a java.lang.InternalError is used to indicate
that class initialization failed and the enclosing transaction
should be aborted and the changes rolled back. However there is
nothing preventing the code executed from a class initializer from
catching that exception (like catching Throwable and ignore it).
Therefore we may return from the class initializer with no pending
exception, even if the transaction was aborted, and not rollback
the changes properly.

To fix this, we now rely on the new Transaction::aborted_ field to
know whether a transaction aborted. When returning from the class
initializer without pending exception, we now check wether we aborted
the enclosing transaction. If that's the case, we set the status of
the class to kStatusError and throw a new java.lang.InternalError
with the original abort message.

This CL also contains some cleanup:
- Renames Transaction::Abort to Transaction::Rollback which is less
ambiguous and more reflect what is done.
- Moves the code throwing the java.lang.InternalError exception into
the Transaction::ThrowInternalError method so we do not duplicate
code. Now we may abort transaction more than once (because we may
have caught the java.lang.InternalError then execute code causing
new transaction abort), we only keep the first abort message to
throw the exception.
- Updates transaction_test with more cases and more checks.
- Bumps oat version to force recompilation with this fix.

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

Bug: 12687968
Change-Id: I62f70274d47df6d6cab714df95c518b750ce3105
0c8c303c20cdaaf54d26e45cc17dc5afb820d8ef 17-Jan-2015 Hiroshi Yamauchi <yamauchi@google.com> Clean up the locks around Heap::VisitObjects().

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

Bug: 12687968
Change-Id: Icc8e60630465afde948ebc6ea91d4ebaff5d7837
a8a697f48e92c85136fc7bec661623c434f67ede 15-Jan-2015 Sebastien Hertz <shertz@google.com> Update instrumentation stubs on resolved classes

We cannot update methods of a class in the process of being loaded.
We need it to be fully resolved (kStatusResolved) so we can access
its complete structure (including method index) and the compiled
code from the oat file.

We ensure that by skipping classes that are not resolved yet when we
update instrumentation (with all threads suspended). The entrypoints
will be updated when the class gets resolved by the ClassLinker. We
also do not update method entrypoints of erroneous classes
(kStatusError) because we cannot execute code for these methods.

This situation can happen when the debugger requests an event that
will cause a full deoptimization (like a METHOD_ENTRY event) while we
are loading a new class. Because we suspend all threads to update
instrumentation, we may visit a class that is being loaded but not
yet resolved.

Bug: 19012386
Bug: 18766029
Change-Id: I5a645dfaf5c25dcf4282c1aaeb24f1b6333baa37
7f418db815f0eaef5b2f43e1f06fb8773a415494 26-Nov-2014 Sebastien Hertz <shertz@google.com> JDWP: fix breakpoint for method in the image

When we set a breakpoint in a compiled method, we deoptimize it by
changing its entrypoint so it is executed with the interpreter.
However, methods in the image can be called with their direct code
pointer, ignoring the updated entrypoint. In that case, the method
is not executed with the interpreter and we miss the breakpoint.

This CL avoids that situation by forcing a full deoptimization so
everything runs with the interpreter. However, if the image has been
compiled in PIC mode, we keep using selective deoptimization because
direct code pointer is not used in this mode.

Bug: 17965285

(cherry picked from commit 6963e44331258b131bcc0599b868ba15902d6d22)

Change-Id: I9bf738f89b9eb6d18733503216b376b8a1d181f5
e34fa1df67fbe0173b4ea9abddcc3ae3d0537037 14-Jan-2015 Mathieu Chartier <mathieuc@google.com> Print more info in MarkSweep::VerifyRoot

Refactored old root callback to use a new class called RootInfo.
RootInfo contains all the relevant info related to the root
associated with the callback. The MarkSweep::VerifyRoot function
now uses this info to print the StackVisitor's described location
if the GC root is of the type kRootJavaFrame.

Some other cleanup.

Example output:
E/art (12167): Tried to mark 0x123 not contained by any spaces
E/art (12167): Attempting see if it's a bad root
E/art (12167): Found invalid root: 0x123 with type RootJavaFrame
E/art (12167): Location=Visiting method
'void java.lang.Runtime.gc()' at dex PC 0xffffffff (native PC 0x0)
vreg=0

(cherry picked from commit 12f7423a2bb4bfab76700d84eb6d4338d211983a)

Bug: 18588862
Change-Id: Ic5a2781f704e931265ffb3621c2eab4b2e25f60f
12f7423a2bb4bfab76700d84eb6d4338d211983a 14-Jan-2015 Mathieu Chartier <mathieuc@google.com> Print more info in MarkSweep::VerifyRoot

Refactored old root callback to use a new class called RootInfo.
RootInfo contains all the relevant info related to the root
associated with the callback. The MarkSweep::VerifyRoot function
now uses this info to print the StackVisitor's described location
if the GC root is of the type kRootJavaFrame.

Some other cleanup.

Example output:
E/art (12167): Tried to mark 0x123 not contained by any spaces
E/art (12167): Attempting see if it's a bad root
E/art (12167): Found invalid root: 0x123 with type RootJavaFrame
E/art (12167): Location=Visiting method
'void java.lang.Runtime.gc()' at dex PC 0xffffffff (native PC 0x0)
vreg=0

Bug: 18588862
Change-Id: Ic5a2781f704e931265ffb3621c2eab4b2e25f60f
fd9eb3923dcf417afcf5ed4ebb13867fd10f2de3 07-Nov-2014 Andreas Gampe <agampe@google.com> ART: Simple structural class check

Adds a simple check to class-loading when the embedded dex file in
an oat file and the dex file on the class path where we found the
class do not match.

We require that the number of methods and fields do not change, as
that will almost certainly mean that quickened and other compiled
offsets are wrong now. This is a reasonably lightweight change, but
we should investigate a full comparison including name and type of
members.

Bug: 17937814
Bug: 18708951

(cherry picked from commit 15a33b3f88546bce85dcb9d28caf200da51154d7)

Change-Id: Icb9638bebd369ab23822817f4a97c8dd8625fea5
15a33b3f88546bce85dcb9d28caf200da51154d7 07-Nov-2014 Andreas Gampe <agampe@google.com> ART: Simple structural class check

Adds a simple check to class-loading when the embedded dex file in
an oat file and the dex file on the class path where we found the
class do not match.

We require that the number of methods and fields do not change, as
that will almost certainly mean that quickened and other compiled
offsets are wrong now. This is a reasonably lightweight change, but
we should investigate a full comparison including name and type of
members.

Bug: 17937814
Bug: 18708951
Change-Id: Icb9638bebd369ab23822817f4a97c8dd8625fea5
fbef44de596d298dc6430f482dffc933a046dd28 23-Dec-2014 Richard Uhler <ruhler@google.com> Use unique_ptr to track ownership of dex files.

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

Change-Id: I3bf3250fa866fd2265f1b115d52fa5dedc48a7fc
a696c0a27f9b9cdf68ac17bdb4e29ac1f798ac32 11-Dec-2014 Andreas Gampe <agampe@google.com> ART: More ELF and oat file safety measures

In an ELF file, look for a shstrtab section when loading in
program-header-only mode. If the section is outside the file size,
it strongly indicates a broken compile.

When compiling oat files in the class linker, explicitly unlink
on failure. This should catch cases when dex2oat is killed or
crashes and doesn't have a chance to delete its (partial) output.

Bug: 15567083

(cherry picked from commit ad00fed942a9a04cf3f46784bbd04a5f00dd4ab8)

Change-Id: Ia0c75f151d91c6f26a71696967255d6d409ca882
ad00fed942a9a04cf3f46784bbd04a5f00dd4ab8 11-Dec-2014 Andreas Gampe <agampe@google.com> ART: More ELF and oat file safety measures

In an ELF file, look for a shstrtab section when loading in
program-header-only mode. If the section is outside the file size,
it strongly indicates a broken compile.

When compiling oat files in the class linker, explicitly unlink
on failure. This should catch cases when dex2oat is killed or
crashes and doesn't have a chance to delete its (partial) output.

Bug: 15567083
Change-Id: Ia0c75f151d91c6f26a71696967255d6d409ca882
76bd88005bba706f98c4b3eb23a226d184d85152 11-Dec-2014 Andreas Gampe <agampe@google.com> Revert "Revert "Ensure void type is resolved when running without image""

Accept the verification status of image classes out of oat files even
when the image could not be loaded. This is necessary as the dex files
might be quickened and the verifier can't work on them when the runtime
is not started.

This reverts commit fe382b5296ef132316d8883a0bdf8cb00d40d16b.

Bug: 18338511
Bug: 18705942
Change-Id: I3516acaaa65f05395c14da0701d1049ba80acb12
fe382b5296ef132316d8883a0bdf8cb00d40d16b 10-Dec-2014 Nicolas Geoffray <ngeoffray@google.com> Revert "Ensure void type is resolved when running without image"

Reverting to stop tests breakage.

This reverts commit 3138584a720b86f2f542160425d3a922920760c0.

Change-Id: Idd30d458cef67839416ffeae4d558da2affd29d0
3138584a720b86f2f542160425d3a922920760c0 09-Dec-2014 Sebastien Hertz <shertz@google.com> Ensure void type is resolved when running without image

To initialize java.lang.Void correctly, we need to ensure the 'void'
class is initialized in the dex cache of core-libart (because Java
code relies on it). However, if we run without image, the dex cache
may not contain the void class before we initialize java.lang.Void
class.

This CL fixes this by forcing the resolution of 'void' class when
initializing the runtime without image.

We also generalize that to other types by not skipping verification
when running with preopted oat files without image. By verifying
all classes, we ensure all resolved types are in the dex caches.

Bug: 18338511
(cherry picked from commit cad417c72cc879ae8b6a8b2fff26f05a770f2051)

Change-Id: I65e345da47be6eda1ee55897c01a9a4cc1444915
cad417c72cc879ae8b6a8b2fff26f05a770f2051 09-Dec-2014 Sebastien Hertz <shertz@google.com> Ensure void type is resolved when running without image

To initialize java.lang.Void correctly, we need to ensure the 'void'
class is initialized in the dex cache of core-libart (because Java
code relies on it). However, if we run without image, the dex cache
may not contain the void class before we initialize java.lang.Void
class.

This CL fixes this by forcing the resolution of 'void' class when
initializing the runtime without image.

We also generalize that to other types by not skipping verification
when running with preopted oat files without image. By verifying
all classes, we ensure all resolved types are in the dex caches.

Bug: 18338511
Change-Id: I65e345da47be6eda1ee55897c01a9a4cc1444915
a89d7ed6f091ac495cd43560ece6988776d14d61 05-Dec-2014 Mathieu Chartier <mathieuc@google.com> Add pointer size logic to InitFromImageInterpretOnly

Previously we didn't have this logic which broke dex2oat if passed
--runtime-option -Xint flag.

Also we now no longer call InitFromImageInterpretOnlyCallback if
we are the compiler.

Bug: 18631640
Change-Id: Ie84fceeb85cabeeec7a5fedefd73dd919cca8e5e
6963e44331258b131bcc0599b868ba15902d6d22 26-Nov-2014 Sebastien Hertz <shertz@google.com> JDWP: fix breakpoint for method in the image

When we set a breakpoint in a compiled method, we deoptimize it by
changing its entrypoint so it is executed with the interpreter.
However, methods in the image can be called with their direct code
pointer, ignoring the updated entrypoint. In that case, the method
is not executed with the interpreter and we miss the breakpoint.

This CL avoids that situation by forcing a full deoptimization so
everything runs with the interpreter. However, if the image has been
compiled in PIC mode, we keep using selective deoptimization because
direct code pointer is not used in this mode.

Bug: 17965285
Change-Id: Icaf8cbb7fe9ad01d36f7378c59d50d9ce42ae57f
b5fb207ed5e3570ec14e18811b3fa066168fe493 03-Dec-2014 Ian Rogers <irogers@google.com> Remove MethodHelper::HasSameSignatureWithDifferentClassLoaders.

Move sole use to a static function within class_linker.cc.
Remove unused MutableMethodHelper and empty method_helper.cc.

Change-Id: Ia26bc76674ed2ee7c9c546de820cc181005fed77
f2247513a54300cfa6a2f23fdbbafead115c99b2 03-Dec-2014 Ian Rogers <irogers@google.com> Remove MethodHelper::HasSameNameAndSignature.

Move sole use to a static method with art_method.cc.

Change-Id: I2e7994cc1c31b5ca74df5d7be5538003d4ed0150
e0a02dabedd7db2c511a513fb48d7e39ed3dd9c0 02-Dec-2014 Ian Rogers <irogers@google.com> Move FindDexMethodIndexInOtherDexFile into ArtMethod.

Move FindDexMethodIndexInOtherDexFile out of MethodHelper into ArtMethod in
preparation for the removal of MethodHelper.
Tidy ClassLinker::ResolveMethod so that all exception paths flow through the
exception pending assertion.
Tidy artQuickResolutionTrampoline to be more explicit about variable names and
only update the dex cache if necessary.

Change-Id: I3e48eb4f6c1291533067c1b53efe90c53bfcaea8
72267f9b0cf19afae278d8a2f272f3038b999c33 02-Dec-2014 Sebastien Hertz <shertz@google.com> Fix build

Fixes bad merge with duplicated method.

Change-Id: I3059f4d5c0efcca67c4bbf166e4f5a19f8b0c9c1
91a6dc41003cdd22073e72fd5425df8e95b1c172 01-Dec-2014 Mathieu Chartier <mathieuc@google.com> Set dex_cache_strings_ when we call Class::SetDexCache

Ensures that these two variables never get out of sync. The error
was presumably related to not doing this for proxy classes. This
caused java code which was looking at the dex_cache_strings_ field
to incorrectly access a null array.

Bug: 18548887

(cherry picked from commit ea1c3d77b92b30ec527f2ca5bfe316a882b698e0)

Change-Id: I022d9311b38b61e160ed70e3c5d9639797adb29c
ea1c3d77b92b30ec527f2ca5bfe316a882b698e0 01-Dec-2014 Mathieu Chartier <mathieuc@google.com> Set dex_cache_strings_ when we call Class::SetDexCache

Ensures that these two variables never get out of sync. The error
was presumably related to not doing this for proxy classes. This
caused java code which was looking at the dex_cache_strings_ field
to incorrectly access a null array.

Bug: 18548887
Change-Id: If53c6ade3588b82a480d6674dfbd5caa2e5069fd
eace45873190a27302b3644c32ec82854b59d299 25-Nov-2014 Mathieu Chartier <mathieuc@google.com> Move dexCacheStrings from ArtMethod to Class

Adds one load for const strings which are not direct.

Saves >= 60KB of memory avg per app.
Image size: -350KB.

Bug: 17643507
Change-Id: I2d1a3253d9de09682be9bc6b420a29513d592cc8

(cherry picked from commit f521f423b66e952f746885dd9f6cf8ef2788955d)
f521f423b66e952f746885dd9f6cf8ef2788955d 25-Nov-2014 Mathieu Chartier <mathieuc@google.com> Move dex cache strings from ArtMethod -> Class

Adds one load for const strings which are not direct.

Saves >= 60KB of memory avg per app.
Image size: -350KB.

Bug: 17643507
Change-Id: I2d1a3253d9de09682be9bc6b420a29513d592cc8
f2134f684923454e00c8ca7675b431a8538131bc 17-Nov-2014 Sebastien Hertz <shertz@google.com> JDWP: only deoptimize when it is required

We don't need to deoptimize anything when we forced the use of the
interpreter (-Xint). In this case, no compiled code is executed
(except native methods which are not concerned by deoptimization).
Therefore we even don't need to enable/disable deoptimization support
in instrumentation.

We also don't need to deoptimize a method that hasn't been compiled.
Since it will run with interpreter, there is no point deoptimizing
it. However this method may be inlined in a compiled caller method
so we still need to deoptimize everything in this case.

This CL updates breakpoint support by storing the required kind of
deoptimization for a particular method. There are 3 cases:
- kNothing: the method does not require deoptimization.
- kSelectiveDeoptimization: the method needs to be deoptimized.
- kFullDeoptimization: we must deoptimize everythinig.
When uninstalling a breakpoint, we need to do the reverse operation.

Also fixes the SanityCheckExistingBreakpoints function to control
breakpoints related to the given method only and adds extra verbose
ilogs when choosing the appropriate deoptimization kind.

Includes a partial cherry-pick of commit
87553c9fa1298ffb40127b2bb6413859fd3f79df to use method
ClassLinker::GetOatMethodQuickCodeFor.

Bug: 18407046

(cherry picked from commit f3928794a10516e2ac0ffe2686a10891788d4b9c)

Change-Id: I50853cc5fc5c52650485785a1198d35ea0f7fb8e
957ca1cd025104fccb0b08928f955f9bdb4ab91c 22-Nov-2014 Mathieu Chartier <mathieuc@google.com> Delete ArtMethod gc_map_ field

Moved the gc_map field from OatMethod to OatQuickMethodHeader.
Deleted the ArtMethod gc_map_ field.

Bug: 17643507

Change-Id: Ifa0470c3e4c2f8a319744464d94c6838b76b3d48

(cherry picked from commit 807140048f82a2b87ee5bcf337f23b6a3d1d5269)
3242729362b74d22f11d8bc7b4800ba0a8695df6 19-Nov-2014 Ian Rogers <irogers@google.com> Avoid JNI call with pending OOME.

If EnsureResolved fails with an exception then FindClassInPathClassLoader may
fall-through to a call to NewStringUTF with a pending exception.
Bug: 15446488

Change-Id: I007f7bee7c50aa588d0b1c776da67a38314dc897
2d7210188805292e463be4bcf7a133b654d7e0ea 10-Nov-2014 Mathieu Chartier <mathieuc@google.com> Change 64 bit ArtMethod fields to be pointer sized

Changed the 64 bit entrypoint and gc map fields in ArtMethod to be
pointer sized. This saves a large amount of memory on 32 bit systems.
Reduces ArtMethod size by 16 bytes on 32 bit.

Total number of ArtMethod on low memory mako: 169957
Image size: 49203 methods -> 787248 image size reduction.
Zygote space size: 1070 methods -> 17120 size reduction.
App methods: ~120k -> 2 MB savings.

Savings per app on low memory mako: 125K+ per app
(less active apps -> more image methods per app).

Savings depend on how often the shared methods are on dirty pages vs
shared.

TODO in another CL, delete gc map field from ArtMethod since we
should be able to get it from the Oat method header.

Bug: 17643507

Change-Id: Ie9508f05907a9f693882d4d32a564460bf273ee8

(cherry picked from commit e832e64a7e82d7f72aedbd7d798fb929d458ee8f)
e832e64a7e82d7f72aedbd7d798fb929d458ee8f 10-Nov-2014 Mathieu Chartier <mathieuc@google.com> Change 64 bit ArtMethod fields to be pointer sized

Changed the 64 bit entrypoint and gc map fields in ArtMethod to be
pointer sized. This saves a large amount of memory on 32 bit systems.
Reduces ArtMethod size by 16 bytes on 32 bit.

Total number of ArtMethod on low memory mako: 169957
Image size: 49203 methods -> 787248 image size reduction.
Zygote space size: 1070 methods -> 17120 size reduction.
App methods: ~120k -> 2 MB savings.

Savings per app on low memory mako: 125K+ per app
(less active apps -> more image methods per app).

Savings depend on how often the shared methods are on dirty pages vs
shared.

TODO in another CL, delete gc map field from ArtMethod since we
should be able to get it from the Oat method header.

Bug: 17643507

Change-Id: Ie9508f05907a9f693882d4d32a564460bf273ee8
b34674d246c7d678e5796d561af00d51ad43996c 17-Nov-2014 Vladimir Marko <vmarko@google.com> Fix ordering of fields with the same name.

While the Java language doesn't allow multiple fields with
the same name in a single class (excluding fields from super
classes), the bytecode specification permits it and tools
such as proguard actually generate them. Define the order of
these fields by their dex file index and relax the check of
field ordering to permit identical names.

Bug: 18211592

(cherry picked from commit 7a7c1db21782fb922d3ffc5c576117812624ea58)

Change-Id: I8547eeac890b7483c8925367a85382197be9ea7a
938f966d399821d29075198cac4331d9a0c92bea 12-Nov-2014 Vladimir Marko <vmarko@google.com> Fix LinkFieldsComparator.

Define order for primitive types with the same sizes.
Previously, the comparator would consider the fields equal
so the order would depend on std::sort() implementation.
Changing the STL implementation could silently change the
field offsets. (And, unlike std::stable_sort(), the
std::sort() doesn't even need to be deterministic.)

(cherry picked from commit d577748c041aa6df599218f3cb31697ecf032730)

Change-Id: I9b769d023864aa36c52918c7c3dd11c0f6b8f40e
7a7c1db21782fb922d3ffc5c576117812624ea58 17-Nov-2014 Vladimir Marko <vmarko@google.com> Fix ordering of fields with the same name.

While the Java language doesn't allow multiple fields with
the same name in a single class (excluding fields from super
classes), the bytecode specification permits it and tools
such as proguard actually generate them. Define the order of
these fields by their dex file index and relax the check of
field ordering to permit identical names.

Bug: 18211592
Change-Id: I1dee9b2b669a6ea180a2d3a41030efb2aed53950
d577748c041aa6df599218f3cb31697ecf032730 12-Nov-2014 Vladimir Marko <vmarko@google.com> Fix LinkFieldsComparator.

Define order for primitive types with the same sizes.
Previously, the comparator would consider the fields equal
so the order would depend on std::sort() implementation.
Changing the STL implementation could silently change the
field offsets. (And, unlike std::stable_sort(), the
std::sort() doesn't even need to be deterministic.)

Change-Id: I91fa562f82447606aced64643bea8c70784766b5
76649e8d775519fe19f2b14d18ac488c13296054 10-Nov-2014 Vladimir Marko <vmarko@google.com> Keep original order of fields in Class.

The fields of a class are ordered alphabetically in the dex
file. Keep the same order in the field arrays so that we can
do binary search lookups by name. Those lookups will be
implemented in a subsequent change in libcore/.

Bug: 18211592

(cherry picked from commit bfa3ed0ad988e1da13626ddbaf6dcae0c58ea79e)

Change-Id: I8f979de62ffe37d1c7d5c721717d2f3501e7c9e6
bfa3ed0ad988e1da13626ddbaf6dcae0c58ea79e 10-Nov-2014 Vladimir Marko <vmarko@google.com> Keep original order of fields in Class.

The fields of a class are ordered alphabetically in the dex
file. Keep the same order in the field arrays so that we can
do binary search lookups by name. Those lookups will be
implemented in a subsequent change in libcore/.

Bug: 18211592
Change-Id: I8f979de62ffe37d1c7d5c721717d2f3501e7c9e6
e225eab4a17dd8db7f9d8412e4edc04e330462bc 30-Oct-2014 Igor Murashkin <iam@google.com> art: Fix classlinker and nopatchoat test for PIC case

ClassLinker should not be checking oat data begin and the patch delta
as part of the checksum verification (when PIC is enabled).

Also update nopatchoat test since it needs to be parametric on whether
PIC is used.

(cherry-picked from AOSP master
230faa7c44ec1986d5fa93d205eb23cb8024e333)

Bug: 18035729

(cherry picked from commit 5ef2990c2933152021633e6697d5325103649499)

Change-Id: Ia0a601c657b813767114095c3b7577421e03bde4
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
998ee7d0f62a1ee7efaaad49e728d19c38b4c9c3 23-Oct-2014 Andreas Gampe <agampe@google.com> ART: Add pic flag to oat header store

Add the compile-time PIC flag to the oat-header key-value store.
Ignore image offset and patch delta when loading PIC oat files.

(cherry-picked from AOSP master
7ba649636c4475c3992fa15a57acd2546d69ff38)

Bug: 18035729
Signed-off-by: Igor Murashkin <iam@google.com>

(cherry picked from commit d7392faea80acb5d73a027bb384e3222bc2c2e43)

Change-Id: If5f6cf13f4c7ecb6038415e68fbb0ae9cee5ec60
e7c9a8c2b8481aafbc6af4ce6229bd361ba24742 07-Nov-2014 Mathieu Chartier <mathieuc@google.com> Add hash map, reduce excessive hashing

Changed the class def index to use a HashMap instead of unordered_map
so that we can use FindWithHash to reduce how often we need to compute
hashes.

Fixed a bug in ClassLinker::UpdateClass where we didn't properly
handle classes with the same descriptor but different class loaders.
Introduced by previous CL.

Before (fb launch):
1.74% art::ComputeModifiedUtf8Hash(char const*)

After:
0.95% art::ComputeModifiedUtf8Hash(char const*)

Bug: 18054905
Bug: 16828525

Change-Id: Iba2ee37c9837289e0ea187800ba4af322225a994

(cherry picked from commit 564ff985184737977aa26c485d0c1a413e530705)
564ff985184737977aa26c485d0c1a413e530705 07-Nov-2014 Mathieu Chartier <mathieuc@google.com> Add hash map, reduce excessive hashing

Changed the class def index to use a HashMap instead of unordered_map
so that we can use FindWithHash to reduce how often we need to compute
hashes.

Fixed a bug in ClassLinker::UpdateClass where we didn't properly
handle classes with the same descriptor but different class loaders.
Introduced by previous CL.

Before (fb launch):
1.74% art::ComputeModifiedUtf8Hash(char const*)

After:
0.95% art::ComputeModifiedUtf8Hash(char const*)

Bug: 18054905
Bug: 16828525

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

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

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

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

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

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

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

Bug: 17808975

Change-Id: I93e376cf6eb9628cf52f4aefdadb6157acfb799a

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

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

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

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

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

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

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

Bug: 17808975

Change-Id: I93e376cf6eb9628cf52f4aefdadb6157acfb799a
277ccbd200ea43590dfc06a93ae184a765327ad0 04-Nov-2014 Andreas Gampe <agampe@google.com> ART: More warnings

Enable -Wno-conversion-null, -Wredundant-decls and -Wshadow in general,
and -Wunused-but-set-parameter for GCC builds.

Change-Id: I81bbdd762213444673c65d85edae594a523836e5
575e78c41ece0dec969d31f46be563d4eb7ae43b 04-Nov-2014 Andreas Gampe <agampe@google.com> ART: Replace COMPILE_ASSERT with static_assert (runtime)

Replace all occurrences of COMPILE_ASSERT in the runtime tree.

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

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

Change-Id: I5b433e722d2f75baacfacae4d32aef4a828bfe1b
5ef2990c2933152021633e6697d5325103649499 30-Oct-2014 Igor Murashkin <iam@google.com> art: Fix classlinker and nopatchoat test for PIC case

ClassLinker should not be checking oat data begin and the patch delta
as part of the checksum verification (when PIC is enabled).

Also update nopatchoat test since it needs to be parametric on whether
PIC is used.

(cherry-picked from AOSP master
230faa7c44ec1986d5fa93d205eb23cb8024e333)

Bug: 18035729
Change-Id: I4eb184d22616230a7b8f0dd514d3416d0976b07e
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
d7392faea80acb5d73a027bb384e3222bc2c2e43 23-Oct-2014 Andreas Gampe <agampe@google.com> ART: Add pic flag to oat header store

Add the compile-time PIC flag to the oat-header key-value store.
Ignore image offset and patch delta when loading PIC oat files.

(cherry-picked from AOSP master
7ba649636c4475c3992fa15a57acd2546d69ff38)

Bug: 18035729
Signed-off-by: Igor Murashkin <iam@google.com>
Change-Id: Ie1f1ef37125386a968228033d1e2bec565315510
9f3629df89b7f2b4f7a599bdc5f7eeb748330582 29-Oct-2014 Mathieu Chartier <mathieuc@google.com> Add hash table to link virtual methods

Added a hash table for turning the O(m*n) lookup average case to
O(m+n) average case. There is probably still some room for improvement.

Before:
WaitTime: 2121
WaitTime: 2051
WaitTime: 2134
WaitTime: 2104
WaitTime: 2237
WaitTime: 2391
4.99% art::MethodNameAndSignatureComparator::HasSameNameAndSignature(art::mirror::ArtMethod)
1.65% art::ClassLinker::LinkVirtualMethods(art::Thread*, art::Handle<art::mirror::Class>)

After:
WaitTime: 2038
WaitTime: 1965
WaitTime: 1979
WaitTime: 1976
WaitTime: 1957
WaitTime: 2004
0.46% art::MethodNameAndSignatureComparator::HasSameNameAndSignature(art::mirror::ArtMethod*)
1.39% art::ClassLinker::LinkVirtualMethods(art::Thread*, art::Handle<art::mirror::Class>)

Bug: 18054905
Bug: 16828525

(cherry picked from commit a9ca9ac444ceb2cf5e8bd5c98c1ed47f2a9a94dd)

Change-Id: If847afb7194daa05ace38d15862e4b871dfffae1
a9ca9ac444ceb2cf5e8bd5c98c1ed47f2a9a94dd 29-Oct-2014 Mathieu Chartier <mathieuc@google.com> Add hash table to link virtual methods

Added a hash table for turning the O(m*n) lookup average case to
O(m+n) average case. There is probably still some room for improvement.

Before:
WaitTime: 2121
WaitTime: 2051
WaitTime: 2134
WaitTime: 2104
WaitTime: 2237
WaitTime: 2391
4.99% art::MethodNameAndSignatureComparator::HasSameNameAndSignature(art::mirror::ArtMethod)
1.65% art::ClassLinker::LinkVirtualMethods(art::Thread*, art::Handle<art::mirror::Class>)

After:
WaitTime: 2038
WaitTime: 1965
WaitTime: 1979
WaitTime: 1976
WaitTime: 1957
WaitTime: 2004
0.46% art::MethodNameAndSignatureComparator::HasSameNameAndSignature(art::mirror::ArtMethod*)
1.39% art::ClassLinker::LinkVirtualMethods(art::Thread*, art::Handle<art::mirror::Class>)

Bug: 18054905
Bug: 16828525

Change-Id: If847afb7194daa05ace38d15862e4b871dfffae1
96e83930f35544872228be209d3704f60c2c485c 30-Oct-2014 Igor Murashkin <iam@google.com> art: Fix classlinker and nopatchoat test for PIC case

ClassLinker should not be checking oat data begin and the patch delta
as part of the checksum verification (when PIC is enabled).

Also update nopatchoat test since it needs to be parametric on whether
PIC is used.

Bug: 18035729
Change-Id: I4eb184d22616230a7b8f0dd514d3416d0976b07e
ded66a01f81812e0129d17c3d08d5eda18433062 29-Oct-2014 Ian Rogers <irogers@google.com> Move MethodHelper::GetReturnType to mirror::ArtMethod.

Also, fix missing handle in HasSameSignatureWithDifferentClassLoaders.

Change-Id: I9e1ffd09be950ecc8346fc3c485760d82d9ecab3
473484fac7bd53523f5503176ecc5955325a9731 28-Oct-2014 Ian Rogers <irogers@google.com> Tidy MethodProtoHelper.

Move to place of only use, class_linker.cc. Be lazy in computing the name.

Before:
WaitTime: 2699
WaitTime: 2791
WaitTime: 2653
WaitTime: 2929
WaitTime: 2651
WaitTime: 2971

After:
WaitTime: 2749
WaitTime: 2786
WaitTime: 2852
WaitTime: 2856
WaitTime: 2703
WaitTime: 2784

Bug: 18054905
Bug: 16828525

(cherry picked from commit 03b6eafba8ace9a9c4d5ee9c47723d1910ccd7a8)

Change-Id: I1438efbda58369ddd0ac36eda8a5a0a6c6fdff77
05d89ee90413c51573c8e708a193f4ff87d67d0a 28-Oct-2014 Mathieu Chartier <mathieuc@google.com> Fill resolved static fields during class initialization

Previously everytime we resolved static fields we linear searched
the class to find the field with the specified field id. Now we
eagerly set these fields in the dex cache when we initialize classes.

FB launch timings before:
WaitTime: 2903
WaitTime: 2953
WaitTime: 2918
WaitTime: 2940
WaitTime: 2879
WaitTime: 2792

Timings after:
WaitTime: 2699
WaitTime: 2791
WaitTime: 2653
WaitTime: 2929
WaitTime: 2651
WaitTime: 2971

Perf before:
2.94% art::mirror::Class::FindDeclaredStaticField(art::mirror::DexCache const*, unsigned int)
After:
0.00% art::mirror::Class::FindDeclaredStaticField(art::mirror::DexCache const*, unsigned int)

Bug: 18054905
Bug: 16828525

(cherry picked from commit bfb21589a6490769690b44aaf8e6a0021a1261b7)

Change-Id: I33255f85d10c29cae085584880196c45ac0ea230
bfb21589a6490769690b44aaf8e6a0021a1261b7 28-Oct-2014 Mathieu Chartier <mathieuc@google.com> Fill resolved static fields during class initialization

Previously everytime we resolved static fields we linear searched
the class to find the field with the specified field id. Now we
eagerly set these fields in the dex cache when we initialize classes.

FB launch timings before:
WaitTime: 2903
WaitTime: 2953
WaitTime: 2918
WaitTime: 2940
WaitTime: 2879
WaitTime: 2792

Timings after:
WaitTime: 2699
WaitTime: 2791
WaitTime: 2653
WaitTime: 2929
WaitTime: 2651
WaitTime: 2971

Perf before:
2.94% art::mirror::Class::FindDeclaredStaticField(art::mirror::DexCache const*, unsigned int)
After:
0.00% art::mirror::Class::FindDeclaredStaticField(art::mirror::DexCache const*, unsigned int)

Bug: 18054905
Bug: 16828525

Change-Id: I33255f85d10c29cae085584880196c45ac0ea230
03b6eafba8ace9a9c4d5ee9c47723d1910ccd7a8 28-Oct-2014 Ian Rogers <irogers@google.com> Tidy MethodProtoHelper.

Move to place of only use, class_linker.cc. Be lazy in computing the name.

Change-Id: I1438efbda58369ddd0ac36eda8a5a0a6c6fdff77
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
7ba649636c4475c3992fa15a57acd2546d69ff38 23-Oct-2014 Andreas Gampe <agampe@google.com> ART: Add pic flag to oat header store

Add the compile-time PIC flag to the oat-header key-value store.
Ignore image offset and patch delta when loading PIC oat files.

Change-Id: Ie1f1ef37125386a968228033d1e2bec565315510
d035c2d0523f29cb3c4fcc14a80d2a8ceadec3ba 28-Oct-2014 Mathieu Chartier <mathieuc@google.com> Fix 64 bit build

Buggy compiler.

(cherry picked from commit 7989d22642415e1e4d608e210284834951bd0a39)

Change-Id: Id16c83fc7963ca89fd7fae32dd15ae342cc7f064
7989d22642415e1e4d608e210284834951bd0a39 28-Oct-2014 Mathieu Chartier <mathieuc@google.com> Fix 64 bit build

Buggy compiler.

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

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

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

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

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

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

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

Bug: 18054905
Bug: 16828525

(cherry picked from commit 1fb463e42cf1d67595cff66d19c0f99e3046f4c4)

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

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

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

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

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

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

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

Bug: 18054905
Bug: 16828525

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

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

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

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

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

(cherry picked from commit 6f3dbbadf4ce66982eb3d400e0a74cb73eb034f3)

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

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

Change-Id: I5f4b49e88c3b02a79f9bee04f83395146ed7be23
b23eab1c507f5d133a2dbcdd00c45aa86d156eef 09-Oct-2014 Brian Carlstrom <bdc@google.com> Add VLOG(class_linker) for clinit errors

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

Change-Id: I4e4ef3a2002fc59ebd9097087f150eaf3f2a7e08
cdc1aaffabbdf417d29b203b2cd2763ed2d623f8 09-Oct-2014 Ian Rogers <irogers@google.com> Simplify instance reference offsets.

Don't encode Object's class. Use trailing rather than leading zeroes to give
offset position.

Change-Id: I1ae74e7a01f63696429644adf81cdf6ee58832fe
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
07140838a3ee44a6056cacdc78f2930e019107da 01-Oct-2014 Ian Rogers <irogers@google.com> Enable -Wunreachable-code

Caught bugs in DeoptimizeStackVisitor and assemble_x86 SIB encoding.
Add UNREACHABLE macro to document code expected to be unreachable.
Bug: 17731047

Change-Id: I2e363fe5b38a1246354d98be18c902a6031c0b9e
c8ccf68b805c92674545f63e0341ba47e8d9701c 30-Sep-2014 Andreas Gampe <agampe@google.com> ART: Fix some -Wpedantic errors

Remove extra semicolons.

Dollar signs in C++ identifiers are an extension.

Named variadic macros are an extension.

Binary literals are a C++14 feature.

Enum re-declarations are not allowed.

Overflow.

Change-Id: I7d16b2217b2ef2959ca69de84eaecc754517714a
f0edfc355893d53d1104b05501c99ad5ccf305c4 25-Sep-2014 Hiroshi Yamauchi <yamauchi@google.com> Some optimizations for the array alloc path.

- Force Array::Alloc() to be inlined.
- Simplify the array size overflow check.
- Turn fill_usable into a template parameter.
- Remove a branch in Array::DataOffset() and avoid
Primitive::ComponentSize(), which has a switch, in the array alloc
path.
- Strength reductions in the array size computation by using component
size shifts instead of component sizes. Store component size shift
in the upper 16 bits of primitive_type field.
- Speedup: ~4% (3435->3284) in MemAllocTest on N4.

Bug: 9986565

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

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

Change-Id: I29ec0006120c39a27184d30e2d1d0c179e203776
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
63bc11efaac0c041e849ab401f9fc368631a00f5 18-Sep-2014 Ian Rogers <irogers@google.com> DO NOT MERGE. Only have a portable entrypoint in portable builds.

Bug: 16214885

Change-Id: Iff7b7415efdbdabd7e6020e221a540f6a774c852
5a4b8a236030460651a3136397d23ca6744e7eb7 11-Sep-2014 Andreas Gampe <agampe@google.com> ART: Rename Handle hierarchy

Bring the names in line with normal OO principles: ConstHandle
becomes Handle, and Handle becomes MutableHandle.

Change-Id: I0f018eb7ba28bc422e3a23dd73a6cbe6fc2d2044
2ed8deff799448e094fa7a7cb9cf3b718820f4c6 28-Aug-2014 Andreas Gampe <agampe@google.com> ART: Allow quickening in the boot image

Update the class linker to accept class status from the boot image
in compiler mode. Update compiler driver to allow quickening for
boot image classes. Update method verifier to accept quickened
instructions in compiler mode when we just want to dump. Update
oatdump to the new verifier API.

Bug: 17316928

(cherry picked from commit 35439baf287b291b67ee406308e17fc6194facbf)

Change-Id: I9ef1bfd78b0d93625b89b3d662131d7d6e5f2903
5182932cf6704b53e957f7b4be021fe505a55e22 26-Aug-2014 Andreas Gampe <agampe@google.com> ART: Change access flag behavior in verifier

Note: this moves the miranda modifier to the upper 16 bit.

Bug: 16161620

(cherry picked from commit 7fc8f90b7160e879143be5cfd6ea3df866398884)

Change-Id: I2f591d53b7d1559171e70aaaf22225d94b4882f5
35439baf287b291b67ee406308e17fc6194facbf 28-Aug-2014 Andreas Gampe <agampe@google.com> ART: Allow quickening in the boot image

Update the class linker to accept class status from the boot image
in compiler mode. Update compiler driver to allow quickening for
boot image classes. Update method verifier to accept quickened
instructions in compiler mode when we just want to dump. Update
oatdump to the new verifier API.

Bug: 17316928
Change-Id: I9ef1bfd78b0d93625b89b3d662131d7d6e5f2903
7b078e8c04f3e1451dbdd18543c8b9692b5b067e 10-Sep-2014 Ian Rogers <irogers@google.com> Compile time performance improvements focusing on interpret-only.

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

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

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

Change-Id: Id59ce3cc520701c6ecf612f7152498107bc40684
7fc8f90b7160e879143be5cfd6ea3df866398884 26-Aug-2014 Andreas Gampe <agampe@google.com> ART: Change access flag behavior in verifier

Note: this moves the miranda modifier to the upper 16 bit.

Bug: 16161620
Change-Id: I2f591d53b7d1559171e70aaaf22225d94b4882f5
ab0ed82ff64ba5a751dcc0a38d0e0c41c53dc923 11-Sep-2014 Mathieu Chartier <mathieuc@google.com> Add fast path to VMClassLoader.findLoadedClass

VMClassLoader.findLoadedClass now calls FindClassInPathClassLoader
as a fast path. Exclusive time results (trace view maps launch):

Before:
nativeFillInStackTrace 1.4%
defineClassNative 1.2%
findLoadedClass 0.2%

After:
nativeFillInStackTrace 0.5%
defineClassNative 0.0%
findLoadedClass 0.9%

(cherry picked from commit 194116c836080de14245a3a7c4617d07b8abf8cf)

Change-Id: I63fd7b4bccb71789e92bd39d1d3f9d0de22535de
bb0c7f6a247521bc3e85f08f93603122bccb1a72 11-Sep-2014 Andreas Gampe <agampe@google.com> ART: Fix preverified setting in VerifyClass

Make sure soft-failed classes cannot set methods to pre-verified.

Bug: 16828525, 17465185

(cherry picked from commit 3892cf8da7d5e76c0dee585fc8f69df773680525)

Change-Id: I09c0a68ca722978459741311148eae7614f9ca49
194116c836080de14245a3a7c4617d07b8abf8cf 11-Sep-2014 Mathieu Chartier <mathieuc@google.com> Add fast path to VMClassLoader.findLoadedClass

VMClassLoader.findLoadedClass now calls FindClassInPathClassLoader
as a fast path. Exclusive time results (trace view maps launch):

Before:
nativeFillInStackTrace 1.4%
defineClassNative 1.2%
findLoadedClass 0.2%

After:
nativeFillInStackTrace 0.5%
defineClassNative 0.0%
findLoadedClass 0.9%

Bug: 16828525

Change-Id: I1bde48effcd28529778c00ec0fa0dda4e32026a3
3892cf8da7d5e76c0dee585fc8f69df773680525 11-Sep-2014 Andreas Gampe <agampe@google.com> ART: Fix preverified setting in VerifyClass

Make sure soft-failed classes cannot set methods to pre-verified.

Bug: 16828525, 17465185
Change-Id: I09c0a68ca722978459741311148eae7614f9ca49
48498591b90a8ff7b24b1ce05c220e3bc42013df 11-Sep-2014 Andreas Gampe <agampe@google.com> ART: Correctly make methods preverified

Bug: 16828525

(cherry picked from commit df1532b9ba0cda2d00b78fbdef461f8a6cf8a737)

Change-Id: I66756348b2aa50e41dacca59769b6810a91c73b0
52be37cb506d3313f3fc5b0afdc5d0322b1191e3 11-Sep-2014 Brian Carlstrom <bdc@google.com> Move EnsurePreverifiedMethods to take ConstHandle to reconcile with AOSP

Bug: 16828525
Change-Id: I7b6a3771ed78ef609d84ee539e9d9575deb2476a
df1532b9ba0cda2d00b78fbdef461f8a6cf8a737 11-Sep-2014 Andreas Gampe <agampe@google.com> ART: Correctly make methods preverified

Bug: 16828525
Change-Id: I66756348b2aa50e41dacca59769b6810a91c73b0
faff0f05fef90577c9744505555675185832aacd 10-Sep-2014 Mingyao Yang <mingyao@google.com> Remove reference_static_offsets used for iterating through class static fields.

Since static fields are contiguous in class object and there is no need to
traverse super classes, it's not meaningful to use reference_static_offsets.
Also especially with embedded vtable/imt, static field offset can't be encoded
with an unsigned integer anyway.

A corresponding change is made to Class.java to remove the member field.

Bug: 16236588
Change-Id: I1fde3cd9efce884945876f0658c63d992164fd94
be4e64303cc66bda0a12eaab835caa0bcfda3cd9 05-Sep-2014 Vladimir Marko <vmarko@google.com> Improve dex location canonicalization-related performance.

Eagerly add canonical dex file locations to the OatFile's
primary lookup map in Setup(). This moves the boot.oat work
from every app startup to the zygote initialization. Since
we always ended up initializing the canonical location map
anyway due to the way that we're loading dex files, the lazy
initialization didn't save anything.

Clean up dex file name canonicalization to make sure we
free() the memory returned by realpath() rather than using
std::unique_ptr<> with the default deleter.

Avoid some unnecessary duplicate OatDexFile lookups.

Bug: 16828525
Bug: 17346103

(cherry picked from commit aa4497db59f1eeec954f2ba5da6d458fcdf9b3a4)

Change-Id: Icc4b14ebe903282ca91ce24e33a6d7c75dff991c
1a465ca32178292888d3dc34b1cd784432a35848 10-Sep-2014 Sebastien Hertz <shertz@google.com> Ensure class is linked before resolution

Adds a missing call to ClassLinker::EnsureResolved to ensure we did link the
class and retired the temp class (placeholder) before doing the resolution.

Bug: 17435441

(cherry picked from commit 72da76359aa5599f78ddca79b294e9bf30e004ed)

Change-Id: I3b368567c7b24ec2ff7ee1dec7bcd3501a6061f8
72da76359aa5599f78ddca79b294e9bf30e004ed 10-Sep-2014 Sebastien Hertz <shertz@google.com> Ensure class is linked before resolution

Adds a missing call to ClassLinker::EnsureResolved to ensure we did link the
class and retired the temp class (placeholder) before doing the resolution.

Bug: 17435441

Change-Id: Ib1a7181d6e5e814ca9299d0504e739a2b69475ef
aa4497db59f1eeec954f2ba5da6d458fcdf9b3a4 05-Sep-2014 Vladimir Marko <vmarko@google.com> Improve dex location canonicalization-related performance.

Eagerly add canonical dex file locations to the OatFile's
primary lookup map in Setup(). This moves the boot.oat work
from every app startup to the zygote initialization. Since
we always ended up initializing the canonical location map
anyway due to the way that we're loading dex files, the lazy
initialization didn't save anything.

Clean up dex file name canonicalization to make sure we
free() the memory returned by realpath() rather than using
std::unique_ptr<> with the default deleter.

Avoid some unnecessary duplicate OatDexFile lookups.

Bug: 16828525
Bug: 17346103
Change-Id: Id8fbc8992f62996138eb2006a0046c6529747c09
6bcae8fa93684af581d16400f360541d39e5b5e6 05-Sep-2014 Mathieu Chartier <mathieuc@google.com> Add fast path for FindClass using the type dex file.

If we are using the PathClassLoader with a BootClassLoader
parent, we can handle the common case in the FindClass function
without needing to go back to java code.

Around 10% speedup measured of maps launch, could be noise due to
large variation of app launch times. Eliminates defineClassNative
from being anywhere near the top of sampling profiles.

Bug: 17397179
Bug: 16828525

(cherry picked from commit 8a39e7fe02e9a81853dc7a75cb50d9ece07a9b37)

Change-Id: I1f31de76c1b1a53e32173b1e61a59b0e2f267c98
8a39e7fe02e9a81853dc7a75cb50d9ece07a9b37 05-Sep-2014 Mathieu Chartier <mathieuc@google.com> Add fast path for FindClass using the type dex file.

If we are using the PathClassLoader with a BootClassLoader
parent, we can handle the common case in the FindClass function
without needing to go back to java code.

Around 10% speedup measured of maps launch, could be noise due to
large variation of app launch times. Eliminates defineClassNative
from being anywhere near the top of sampling profiles.

Bug: 17397179
Bug: 16828525
Change-Id: Ide0db2b5f6cf5b96fc46e89178e0799de667cb88
30c2e1b3970c8a720eac38dbaca1d849c619114e 08-Sep-2014 Vladimir Marko <vmarko@google.com> Small error reporting fix in class linker.

Change-Id: Ia9e94df48e9984c25ad8ab5c6ca41f9153984915
ca0c8d3f81cdee58bd9a70c0fd26f79917dff3b5 30-Aug-2014 Ian Rogers <irogers@google.com> VisitClassesWithoutClassesLock isn't safe if classes move.

Which they do, so avoid by doing an array allocation.
Also, tidy member variables to the end of ClassLinker.
Remove unnecessary mutable. Tidy and fix a locks required/excluded.

Change-Id: I2404a9e7a1ea997d68ab1206f97d2a20dffbda06
(cherry picked from commit dbf3be0f133c0bdf454f637fee2452dbb5f7c027)
621962a0872bf328dba7eda44061f0f505014cef 02-Sep-2014 Calin Juravle <calin@google.com> Avoid recomputing the dex checksum during class loading

Thread the already computed checksum to VerifyOatAndDexFileChecksums and
LoadMultiDexFilesFromOatFile to avoid recomputing it.

Bug:17346103

(cherry picked from commit ca3459398018360d9968a52eebf727df085caf83)

Change-Id: Ie244efaca55b9e7c814b35feec7fce11fab3856d
a8c55ae449ad423087f232b2fec1064062755970 05-Sep-2014 Calin Juravle <calin@google.com> Remove unreachable code from class_linker.cc

If the checksum doesn't match the oat_dex_file will be NULL, a case
which is handled in the first if.

Bug: 17402267

Change-Id: If8547ddc8fd7eff59a3b7dd36c07ac4ceb351361
ca3459398018360d9968a52eebf727df085caf83 02-Sep-2014 Calin Juravle <calin@google.com> Avoid recomputing the dex checksum during class loading

Thread the already computed checksum to VerifyOatAndDexFileChecksums and
LoadMultiDexFilesFromOatFile to avoid recomputing it.

Bug:17346103
Change-Id: Ifa0c1cad952853751e98cbb3c999631b9909a9f9
68caf9e7232109c698e7f91f64b348cf37b432dd 03-Sep-2014 Jeff Hao <jeffhao@google.com> Fix stack overflow and duplicate methods while tracing.

Bug: 16386215
Change-Id: I0d0ae0113a3a00013ce84a1f5a110e2c52f19b86
(cherry picked from commit 6b28a456b075fe53dfb7e924a44dbf35d0d41eb3)
dbf3be0f133c0bdf454f637fee2452dbb5f7c027 30-Aug-2014 Ian Rogers <irogers@google.com> VisitClassesWithoutClassesLock isn't safe if classes move.

Which they do, so avoid by doing an array allocation.
Also, tidy member variables to the end of ClassLinker.
Remove unnecessary mutable. Tidy and fix a locks required/excluded.

Change-Id: I2404a9e7a1ea997d68ab1206f97d2a20dffbda06
6b28a456b075fe53dfb7e924a44dbf35d0d41eb3 03-Sep-2014 Jeff Hao <jeffhao@google.com> Fix stack overflow and duplicate methods while tracing.

Bug: 16386215
Change-Id: I0d0ae0113a3a00013ce84a1f5a110e2c52f19b86
79cfc0e93e210e548b45459478a154168d2d8cc2 05-Jun-2014 Ian Rogers <irogers@google.com> Pre-allocate the NoClassDefFoundError to be thrown for boot classes.

Bring over a Dalvik "optimization".
Bug: 12804658
Bug: 16853450
Change-Id: I6419de7bd2ba18d91479cb52489104954f5c4524

(cherry picked from commit 63557459a4098294a9ff44d035241de2966047c0)
cc2f2393e69a9b1425bad1a89f41aaaf8c38f9e2 30-Aug-2014 Ian Rogers <irogers@google.com> Reduce and speed-up class def searches.

Use the class linker for descriptor lookups from the compile driver so that
dex caches are populated.
Reduce the scope of functions for scanning class paths to just the class
linker where they are performed.
If we see more than a threshold number of find class def misses on a dex file
lazily compute an index, so that future lookups are constant time (part of the
collection code is taken from
https://android-review.googlesource.com/#/c/103865/3). Note that we take a lazy
approach so that we don't serialize on loading dex files, this avoids the
reason the index was removed in 8b2c0b9abc3f520495f4387ea040132ba85cae69.
Remove an implicit and unnecessary std::string creation for PrintableString.

Single threaded interpret-only dex2oat performance is improved by roughly 10%.

Bug: 16853450

Change-Id: Icf72df76b0a4328f2a24075e81f4ff267b9401f4
(cherry picked from commit 68b56858367e29461ae290fd797443a1ef6d8005)
63557459a4098294a9ff44d035241de2966047c0 05-Jun-2014 Ian Rogers <irogers@google.com> Pre-allocate the NoClassDefFoundError to be thrown for boot classes.

Bring over a Dalvik "optimization".
Bug: 12804658
Bug: 16853450
Change-Id: I6419de7bd2ba18d91479cb52489104954f5c4524
68b56858367e29461ae290fd797443a1ef6d8005 30-Aug-2014 Ian Rogers <irogers@google.com> Reduce and speed-up class def searches.

Use the class linker for descriptor lookups from the compile driver so that
dex caches are populated.
Reduce the scope of functions for scanning class paths to just the class
linker where they are performed.
If we see more than a threshold number of find class def misses on a dex file
lazily compute an index, so that future lookups are constant time (part of the
collection code is taken from
https://android-review.googlesource.com/#/c/103865/3). Note that we take a lazy
approach so that we don't serialize on loading dex files, this avoids the
reason the index was removed in 8b2c0b9abc3f520495f4387ea040132ba85cae69.
Remove an implicit and unnecessary std::string creation for PrintableString.

Single threaded interpret-only dex2oat performance is improved by roughly 10%.

Bug: 16853450

Change-Id: Icf72df76b0a4328f2a24075e81f4ff267b9401f4
496cd337c19ca8386fec24633160f82c01993bbd 29-Aug-2014 Alex Light <allight@google.com> Fix segfault if running without image.

Bug: 17325091

(cherry picked from commit 7adb7ac3913364de8cc57b8934024dd12e1d3bea)

Change-Id: I343099543ce0abf02219da84d61d9ce2dfc47980
7adb7ac3913364de8cc57b8934024dd12e1d3bea 29-Aug-2014 Alex Light <allight@google.com> Fix segfault if running without image.

Bug: 17325091
Change-Id: I343099543ce0abf02219da84d61d9ce2dfc47980
381e4ca3cc9fc6405ff20e1de873a56d78d51923 26-Aug-2014 Fred Shih <ffred@google.com> Filling hole between subclass and superclass.

Subclasses no longer need to be 4-byte aligned at the end. Any gaps
between a superclass and its subclasses will be filled in by halfword
or byte fields if possible.

Refactored the alignment and shuffling methods to use a priority queue
in order to reduce the amount of logic when laying out objects.

Change-Id: Ifed71af534e0c5e77bb14555c44b973fe66df6da
524507a9265e8e5e2b040c113d903c815748245a 28-Aug-2014 Mathieu Chartier <mathieuc@google.com> Prevent exception bugs in class linker

There were some places that could throw exceptions but still succeed.
This caused the allocation entrypoints to occasionally allocate a
heap object with a pending exception.
Also added some additional AssertNoExceptionPending.

Bug: 17164348

(cherry picked from commit 58c016c3f85d6d5496cea25325778de3a8d9a3ac)

Change-Id: Id9918fa8f1a5d713b847cb95cdade925ff80a826
440d3da1284f7c7333b4fc5d09072664ae7a370a 27-Aug-2014 Sebastien Hertz <shertz@google.com> Ensure proxy constructor is in dex cache

Bug: 17262039

(cherry picked from commit ae94e350f100207359b8345d8d21e78e7cfb44c4)

Change-Id: I1cfc8dac1f63b9012fa098804135be8847b1daee
58c016c3f85d6d5496cea25325778de3a8d9a3ac 28-Aug-2014 Mathieu Chartier <mathieuc@google.com> Prevent exception bugs in class linker

There were some places that could throw exceptions but still succeed.
This caused the allocation entrypoints to occasionally allocate a
heap object with a pending exception.
Also added some additional AssertNoExceptionPending.

Bug: 17164348

Change-Id: Ic6dd3b0cce9955349176503dd7f6c3da7ab0a6f1
ae94e350f100207359b8345d8d21e78e7cfb44c4 27-Aug-2014 Sebastien Hertz <shertz@google.com> Ensure proxy constructor is in dex cache

Bug: 17262039

Change-Id: I879341fa9c66f18ec64d6d4bf6a222a452c27739
fb7775981c7e6ecca78dcce774e9cc4db63e6e99 23-Aug-2014 Alex Light <allight@google.com> Support booting without functioning boot.oat/art patchoat.

Bug: 17000769

(cherry picked from commit 84d7605f93f1e6e86a16e02017e305c90e93117a)

Change-Id: I89c26a905af12ea288742368c2c038afd57a879a
84d7605f93f1e6e86a16e02017e305c90e93117a 23-Aug-2014 Alex Light <allight@google.com> Support booting without functioning boot.oat/art patchoat.

Bug: 17000769

Change-Id: I89c26a905af12ea288742368c2c038afd57a879a
df7337508381dce5e653b2e7a2ee4ca93103d67c 26-Aug-2014 Andreas Gampe <agampe@google.com> ART: kSuper also has IncompatibleClassChangeError

When resolving methods, kSuper can also have
IncompatibleClassChangeError.

Bug: 17266767

(cherry picked from commit 9cb8d7a9a5013dd1e6734d9643573a4750d869e2)

Change-Id: I5fafe03ad578f605825a3d0c89f1254a4a385b76
9cb8d7a9a5013dd1e6734d9643573a4750d869e2 26-Aug-2014 Andreas Gampe <agampe@google.com> ART: kSuper also has IncompatibleClassChangeError

When resolving methods, kSuper can also have
IncompatibleClassChangeError.

Bug: 17266767
Change-Id: I5fafe03ad578f605825a3d0c89f1254a4a385b76
8850011ceffce5de38262169de74e4a41ced50eb 22-Aug-2014 Hiroshi Yamauchi <yamauchi@google.com> Remove an intermediate field array in ClassLinker::InitializeClass.

This improves on CL 105090 by removing the need for the intermediate
field array by iterating two iterators in parallel.

Bug: 12687968
Change-Id: I32d4570948a9d39ccb1c20a02e18b48f15ed0738
37f05ef45e0393de812d51261dc293240c17294d 17-Jul-2014 Fred Shih <ffred@google.com> Reduced memory usage of primitive fields smaller than 4-bytes

Reduced memory used by byte and boolean fields from 4 bytes down to a
single byte and shorts and chars down to two bytes. Fields are now
arranged as Reference followed by decreasing component sizes, with
fields shuffled forward as needed.

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

Bug: 17000769

(cherry picked from commit 64ad14dbe2225441fb7734bf6d89358d96692eea)

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

Bug: 17000769

Change-Id: I6404d5050c8a2f4ee6e70d58532eb25ee9de248e
bf99f77dda749e2b653e8c45259b1fb56e7bb012 24-Aug-2014 Mathieu Chartier <mathieuc@google.com> Clean up Handle usage.

Prefer using ConstHandle instead of Handle as function arguments
since you can't assign new references to ConstHandle which helps
prevent bugs.

Changed NullHandle to be a ConstHandle so that you can never modify
it to be a non null reference.

Change-Id: I81cb979f6f8d5b49e5614966a2caf28c3701dd4f
67ef46adfb2c4990832e23aebeb9c0582d8519c4 22-Aug-2014 Hiroshi Yamauchi <yamauchi@google.com> Avoid handle-less fields in ClassLinker::InitializeClass()

There were some handle-less fields in a SafeMap across GC points.

Bug: 12687968
Change-Id: Ib8c6527d4e23031f1d0074fa11d8f85499b68340
0a112bbbcd761c749c346bfec0ec39c1ef37a590 14-Aug-2014 Alex Light <allight@google.com> Make apps able to run with a failing patchoat

Bug: 17000769

(cherry picked from commit 9dcc4572949f6a8231a1b4ed859676ba6f411726)

Change-Id: I0a1a4dc7f5d4bb268530840302ecfb1555231e05
9dcc4572949f6a8231a1b4ed859676ba6f411726 14-Aug-2014 Alex Light <allight@google.com> Make apps able to run with a failing patchoat

Bug: 17000769

Change-Id: I0a1a4dc7f5d4bb268530840302ecfb1555231e05
9bdec8839c1a34d09ec3e8916a4bd3a022ac45b6 16-Aug-2014 Hiroshi Yamauchi <yamauchi@google.com> Check that we don't accidentally invoke compiled code when -Xint.

The heap poisoning breakge (b/17018234) would have been detected with
this check.

Bug: 17018234
Change-Id: If4827ea1b02396d41012f0955e55c887387a0565
41369d2f7042b728a78d5f1e8c49925463e50294 19-Aug-2014 Hiroshi Yamauchi <yamauchi@google.com> Avoid handle-less methods in ClassLinker::LinkInterfaceMethods().

There were some handle-less methods in local variables across
potential GC points.

Bug: 12687968

Change-Id: I786fbaadf7a52e98194080c67c90fc1c35060d59
ee5618be0076ac359ab59af1c2ba945d85b2986e 15-Aug-2014 Jeff Hao <jeffhao@google.com> resolved conflicts for merge of 549c9b17 to lmp-dev-plus-aosp

Change-Id: Icea7763c830aeefa02d6a86c960c4b41148d397b
9c290012b7f505ae1943ab87236f775b97a46e2d 22-Jul-2014 Nicolas Geoffray <ngeoffray@google.com> Execute an application even when dex2oat crashes.

Bug: 17000769

(cherry picked from commit 4fcdc94d22a4608e355aa8df36240181149d10e8)

Change-Id: Iccb1fec94fe64ce4c3097510952f275482b86aa9
95b4c65da93500cdbdcaa3e01010771ef3f466f1 15-Aug-2014 Jeff Hao <jeffhao@google.com> Prevent stubs from being installed in java.lang.reflect.Proxy.<init>.

This CL is a better fix for proxy tracing and undoes the changes in
https://android-review.googlesource.com/#/c/103025/

Bug: 16386215

(cherry picked from commit db8a664e0b68c7c4d36270cd21dce8de1912d7f9)

Change-Id: Ic9e0ea2af7cb2da5d90c56aa009de92dba14cc47
4bf8d11df5dccc1b276cd9c40a98e8a14d79a9c8 25-Jul-2014 Jeff Hao <jeffhao@google.com> Fix proxy tracing and enable tests that now work with tracing.

Also updates proxy_test to generate an image for GetQuickOatCodeFor.

Bug: 16386215

(cherry picked from commit f0a3f09c3d54646166a55c05a6b39c7dd504129c)

Change-Id: I138edbad9e1646db8590f2b1b73f2788d9710e68
db8a664e0b68c7c4d36270cd21dce8de1912d7f9 15-Aug-2014 Jeff Hao <jeffhao@google.com> Prevent stubs from being installed in java.lang.reflect.Proxy.<init>.

This CL is a better fix for proxy tracing and undoes the changes in
https://android-review.googlesource.com/#/c/103025/

Change-Id: Ie82bb49f07774bd08a6720ddbe5b1f8ee9363acf
82546347f86440b5e6317e304b04383f5d1ce326 13-Aug-2014 Mingyao Yang <mingyao@google.com> Use handle in one case that spans a gc-point.

Bug: 16689428

(cherry picked from commit 38eecb0f4288a374c9b0b4b4df8793eb5fc6697c)

Change-Id: Id4a1bde9012e4dd333493e46997c200537c9cf55
eff0f5d9d52805abf825601960cc0c42dc8d7b5a 14-Aug-2014 Andreas Gampe <agampe@google.com> ART: Fix class-linker handling

ResolveMethod did not account correctly for the mutual exclusivity
of direct and static methods. In such a case we threw a NoSuchMethodError,
while the correct behavior is to throw an IncompatibleClassChangeError.

Bug: 16956477

(cherry picked from commit b5d1efa0012d31f7c52c0a2e2b70c77c8708c885)

Change-Id: Id014affe0b8a43dbd75570b123b921d5853ab135
b5d1efa0012d31f7c52c0a2e2b70c77c8708c885 14-Aug-2014 Andreas Gampe <agampe@google.com> ART: Fix class-linker handling

ResolveMethod did not account correctly for the mutual exclusivity
of direct and static methods. In such a case we threw a NoSuchMethodError,
while the correct behavior is to throw an IncompatibleClassChangeError.

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

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

Don't generate GC maps when compilation is disabled.

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

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

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

Bug: 16853450
Change-Id: Ic705ea24784bee24ab80084d06174cbf87d557ad

Conflicts:
runtime/utils.cc
38eecb0f4288a374c9b0b4b4df8793eb5fc6697c 13-Aug-2014 Mingyao Yang <mingyao@google.com> Use handle in one case that spans a gc-point.

Bug: 16689428
Change-Id: Ib209d2ca1e7024bffb2bc17c5b5899e231c0e2ca
1ff3c98775a4577cf053dba9a0c2d5c21c07b298 12-Aug-2014 Ian Rogers <irogers@google.com> Avoid use of std::string where we have const char*.

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

Don't generate GC maps when compilation is disabled.

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

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

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

Bug: 16853450
Change-Id: Ic705ea24784bee24ab80084d06174cbf87d557ad
97b52f89e5e0b52a08d4b9a3953d0973a3cf5636 14-Aug-2014 Ian Rogers <irogers@google.com> Make OatClass and OatMethod immutable once more.

OatClass and OatMethod are representation of disk data and we don't want the
runtime to mutate this.

Change-Id: Id5b8658fd544f5d6e1b9120af134d3644ff1a52c
4fcdc94d22a4608e355aa8df36240181149d10e8 22-Jul-2014 Nicolas Geoffray <ngeoffray@google.com> Execute an application even when dex2oat crashes.

Bug: 17000769

Change-Id: Iffeb582862a5e794b6c7364c7ec2368cfd0f2214
4ef12f5b0e26c6016c87866f6a33da5ed8e98d74 01-Aug-2014 Andreas Gampe <agampe@google.com> ART: Add guards to the dex cache and its shortcuts

Do not return fields, methods or classes if the (declaring) class is
erroneous.

Bug: 16692788

(cherry picked from commit 58a5af8568d224ca7eccf2483396ff9862f8d1ee)

Change-Id: I7d3e4cb8113e2e764ed7433eed25e1031e6a0f14
68d8b42ddec39ec0174162d90d4abaa004d1983e 17-Jul-2014 Ian Rogers <irogers@google.com> Wire up check JNI force copy mode.

Increase check JNI checks.
Break apart jni_internal.h in to jni_env_ext.h and java_vm_ext.h.
Fix the abuse of ScopedObjectAccess/annotalysis by ScopedCheck in the case
of VM routines.
Make class loader override and shared library class loader JNI global
references rather than mirror pointers.
Clean-ups to native bridge.

Change-Id: If7c6110b5aade7a402bfb67534af86a7b2cdeb55
58a5af8568d224ca7eccf2483396ff9862f8d1ee 01-Aug-2014 Andreas Gampe <agampe@google.com> ART: Add guards to the dex cache and its shortcuts

Do not return fields, methods or classes if the (declaring) class is
erroneous.

Bug: 16692788
Change-Id: If43c2414ad0eb22db5eba7cf66396c7f16c26597
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
f0a3f09c3d54646166a55c05a6b39c7dd504129c 25-Jul-2014 Jeff Hao <jeffhao@google.com> Fix proxy tracing and enable tests that now work with tracing.

Also updates proxy_test to generate an image for GetQuickOatCodeFor.

Bug: 16386215
Change-Id: Ie7daad3d73ea7b60187bc1e7037ade0df8277107
66d1caf42c20efba8305efb3a819993126e8abbf 16-Jul-2014 Calin Juravle <calin@google.com> Use canonical paths when searching for dex files

Apps which use the DexPathClassLoader directly may
pass symlinks when trying to load dex files. This
will not work as we use string comparision to find
the dex in an oat file. The CL fixes this issue by
using using dex conical paths for comparisons.

Bug: 15313272

(cherry picked from commit 4e1d579d6401fef2dd57b16f8d406e33221a69d9)

Change-Id: I441f1ef18388c4a17c747a7e55b57f917724db85
4e1d579d6401fef2dd57b16f8d406e33221a69d9 16-Jul-2014 Calin Juravle <calin@google.com> Use canonical paths when searching for dex files

Apps which use the DexPathClassLoader directly may
pass symlinks when trying to load dex files. This
will not work as we use string comparision to find
the dex in an oat file. The CL fixes this issue by
using using dex conical paths for comparisons.

Bug: 15313272

Change-Id: Ic314374b17612c3afbcadec93a88b2515a0aca5e
9854fe24d3e22a2e232597b4334ac93205ff17ed 23-Jul-2014 Mingyao Yang <mingyao@google.com> Fix build, missing spaces around =/<.

(cherry picked from commit 1a12858eb15a14788478c4aca82c052bc84fcafa)

Change-Id: Id2d276cd1fb8bb95c46ff5ceacc7cfe1f5acf192
e19f2b00eebd61e73761ab531866654f08968711 16-Jul-2014 Mingyao Yang <mingyao@google.com> Set vtable in class object to null after linking.

This is follow-up work of embedding imt and vtable for
faster interface/virtual call dispatching.
Once vtable becomes embedded, the original vtable is nulled.

(cherry picked from commit 2cdbad7c62f126581ec5177104de961c4d71adaa)

Change-Id: I6acdcd1ee560d387fb77c55c58bbe3598c197ba1
94f7b49578b6aaa80de8ffed230648d601393905 23-Jul-2014 Hiroshi Yamauchi <yamauchi@google.com> Add GcRoot to clean up and enforce read barriers.

Introduce a value-type wrapper around Object* for GC roots so that 1)
we won't have to directly add the read barrier code in many places and
2) we can avoid accidentally bypassing/missing read barriers on GC
roots (the GcRoot interface ensures that the read barrier is executed
on a read).

The jdwp test passed.

Bug: 12687968
Change-Id: Ib167c7c325b3c7e3900133578815f04d219972a1
0398e171f206cd3b140a358ac31b0a3760380df1 25-Jul-2014 Jeff Hao <jeffhao@google.com> Fix proxy tracing and enable tests that now work with tracing.

Bug: 16386215
Change-Id: Iec2a372c921caceb050c6baf72d48b3d822899a4
22e59fd2861a4aab16adb2b80a1d5166382a6617 24-Jul-2014 Andreas Gampe <agampe@google.com> ART: Allow arrays with erroneous component type

Array classes must tolerate having component type classes that are
erroneous. Change CreateArrayClass to use LookupClass when FindClass
failed.

Bug: 16019155

(cherry picked from commit dc13d7df5da49e93963035633a82699c68fa0971)

Change-Id: I506250949a1802898433e9099dcb8ef31dd89659
dc13d7df5da49e93963035633a82699c68fa0971 24-Jul-2014 Andreas Gampe <agampe@google.com> ART: Allow arrays with erroneous component type

Array classes must tolerate having component type classes that are
erroneous. Change CreateArrayClass to use LookupClass when FindClass
failed.

Bug: 16019155
Change-Id: Id4868c5498431c85c199aa3cbecd23566dce3601
167cc7c33f7100e3f7acc1594c066daa0122e27a 29-Jul-2014 Nicolas Geoffray <ngeoffray@google.com> Revert "Fix proxy tracing and enable tests that now work with tracing."

This reverts commit 0398e171f206cd3b140a358ac31b0a3760380df1.

Change-Id: I1346ab01485cc7207be0ecb4d8788c500c0df903
1a12858eb15a14788478c4aca82c052bc84fcafa 23-Jul-2014 Mingyao Yang <mingyao@google.com> Fix build, missing spaces around =/<.

Change-Id: I2e7824075626a07eccb0a5eb77ef157214fe70fb
2cdbad7c62f126581ec5177104de961c4d71adaa 16-Jul-2014 Mingyao Yang <mingyao@google.com> Set vtable in class object to null after linking.

This is follow-up work of embedding imt and vtable for
faster interface/virtual call dispatching.
Once vtable becomes embedded, the original vtable is nulled.

Change-Id: I307696657d1e283654169dbecb8f7815c42bbabc
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
1e5bc0bc5257cb1fce5fe71a1b922527fe6b8fa4 17-Jul-2014 Calin Juravle <calin@google.com> Fix bad comment in class_linker

(cherry picked from commit ff5a372be9b5ecaa4c3a9887f064a8a98069d036)

Change-Id: I04b2156fbd85929b082097e6faab8097552744c3
c114b5fbc91e6d19ef430d9bc3468386ca61b324 21-Jul-2014 Ian Rogers <irogers@google.com> Fix erroneous behaviors with OOME present.

Bug: 16454510
Change-Id: I757088a7b82ff73f58aba8d357080028b56442e6
ecd4d9adc1e2b2ac1367de9a2dc1ca15ebf4310c 22-Jul-2014 Ian Rogers <irogers@google.com> Avoid marking erroneous classes as erroneous twice.

Change-Id: I1f340a6054cf36f6b4ba7d85cfd05b1c677dced7
0fbd6e6ec3241b7163b95f9f001bfe9b08f8b200 18-Jul-2014 Hiroshi Yamauchi <yamauchi@google.com> Fix two read barrier bugs introduced in CL 97882.

Bug: 12687968
Change-Id: Ib28da4c33977cc58b09913ef5b738dec75365714
ff5a372be9b5ecaa4c3a9887f064a8a98069d036 17-Jul-2014 Calin Juravle <calin@google.com> Fix bad comment in class_linker

Change-Id: Ic8c90e9d880c5aae7e7bdb6c2a0c854fdaa5c357
39c86bc9de106e3641ecab2374a24e41d0430694 16-Jul-2014 Calin Juravle <calin@google.com> Make ART fail gracefully when it can't update the desired code.

ART was exiting with a fatal error when it couldn't clean an obsolete
file. Relaxing this and failing gracefully preserves the behaviour that
Dalvik had.

Bug: 15313272

(cherry picked from commit c54aea7f4acd1a32bb298d43c20e3e0217638926)

Change-Id: I862a8925a0edd6370e94af8fa984a64099240029
d85614222fa062ec809af9d65f04ab6b7dc1c248 11-Jul-2014 Fred Shih <ffred@google.com> Revert "Revert "Revert "Revert "Add intrinsic for Reference.get()""""

Fixed TargetReg issue causing build failure for x86.
This reverts commit 9e82bd3f0ce9e5f5777bea2f752ff3e251d32f9f.

(cherry picked from commit 4ee7a665e7f9cd2c5ace2d6304e33f64067b209f)

Change-Id: I555f4e06955711262e6b37ffbeabee9698ec695c
c54aea7f4acd1a32bb298d43c20e3e0217638926 16-Jul-2014 Calin Juravle <calin@google.com> Make ART fail gracefully when it can't update the desired code.

ART was exiting with a fatal error when it couldn't clean an obsolete
file. Relaxing this and failing gracefully preserves the behaviour that
Dalvik had.

Bug: 15313272
Change-Id: I8d0d6d374c90d2a434909dd4ae56f0799f30134d
22d5e735f403c57525fe868304c7123f0ce66399 16-Jul-2014 Ian Rogers <irogers@google.com> Remove object_utils.h.

Break into object_lock, field_helper and method_helper.
Clean up header files following this.
Also tidy some of the Handle code in response to compiler errors when resolving
the changes in this CL.

Change-Id: I73e63015a0f02a754d0866bfaf58208aebcaa295
4ee7a665e7f9cd2c5ace2d6304e33f64067b209f 11-Jul-2014 Fred Shih <ffred@google.com> Revert "Revert "Revert "Revert "Add intrinsic for Reference.get()""""

Fixed TargetReg issue causing build failure for x86.
This reverts commit 9e82bd3f0ce9e5f5777bea2f752ff3e251d32f9f.

Change-Id: I7e6a526954467aaf68deeed999880dfe9aa5f06e
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
98d1cc8033251c93786e2fa8c59a2e555a9493be 16-May-2014 Mingyao Yang <mingyao@google.com> Improve performance of invokevirtual/invokeinterface with embedded imt/vtable

Add an embedded version of imt/vtable into class object. Both tables start at
fixed offset within class object so method/entry point can be loaded directly
from class object for invokeinterface/invokevirtual.

Bug: 8142917
Change-Id: I4240d58cfbe9250107c95c0708c036854c455968
a9b870b73a155ce70c867d5b3f9758fab0b45f07 11-Jul-2014 Christopher Ferris <cferris@google.com> Revert "Add intrinsic for Reference.get()"

This reverts commit 460503b13bc894828a2d2d47d09e5534b3e91aa1.

Change-Id: Ie63f43049307e02e3b90f4e034abc9ea54ca4e24
d4415e8bd04c4a9367744ff0149597b4f37a0e0a 11-Jul-2014 Christopher Ferris <cferris@google.com> Revert "Revert "Add intrinsic for Reference.get()""

This reverts commit a9b870b73a155ce70c867d5b3f9758fab0b45f07.

Change-Id: Ic2a9b47f2b911bef4b764d10bc33cf000e4b4211
9e82bd3f0ce9e5f5777bea2f752ff3e251d32f9f 11-Jul-2014 Sebastien Hertz <shertz@google.com> Revert "Revert "Revert "Add intrinsic for Reference.get()"""

This reverts commit d4415e8bd04c4a9367744ff0149597b4f37a0e0a.

Change-Id: I34553ccbdcfea35c7742d21be2a74dc7085ab2a0
460503b13bc894828a2d2d47d09e5534b3e91aa1 18-Jun-2014 Fred Shih <ffred@google.com> Add intrinsic for Reference.get()

Added an intrinsic function for Reference.get(). Return immediately
without going through JNI if the slow path is not currently in use.
Otherwise, branch off to the the existing JNI function.

Approximately 47x speedup for cases where slow path is not enabled.

Change-Id: I13ad65a356fe4e104d8d83980694dc2740d7d039
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
833a48501d560c9fa7fc78ef619888138c2d374f 22-May-2014 Andreas Gampe <agampe@google.com> ART: Native support for multidex

Native support for zip files with multiple classesX.dex.

Works by explicitly looking for those files in ascending order. As
these files have no file system representation for themselves,
introduce synthetic dex locations: the name of the originating file
plus a colon plus the name of the dex file, e.g., test.jar:classes2.dex.

Opening a zip dex file will return all dex files in this way. This
keeps the changes to dex2oat minimal.

To hide multidex/synthetic names from the Java layer, let the handle
of dalvik.system.DexFile refer to a vector of DexFile objects. When
opening a location, test possible synthetic names and add them to the
vector. Thus, the original multidex jar in the classpath will be
associated with all embedded dex files.

Change-Id: I0de107e1369cbc94416c544aca3b17525c9eac8b
e9e3e697f0c426132bee10aaa6aee9107d2d7dc6 24-Jun-2014 Hiroshi Yamauchi <yamauchi@google.com> Add more read barriers to the class linker.

This change makes it possible to concurrently scan the remaining roots
in the class linker (the non-class-table roots that are visited by
ClassLinker::VisitRoots()) by adding read barriers.

Bug: 12687968
Change-Id: I66fecf7a303eee7537429e018f38da8270b18c67
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
a91a4bc1f8960f64c5f7e4616d46e21b8e1bfba2 14-Jun-2014 Hiroshi Yamauchi <yamauchi@google.com> Add read barriers for the class and the intern tables.

Add read barriers for the strong roots in the intern table and the
(strong) roots in the class table to make possible concurrent scanning
of them.

Bug: 12687968
Change-Id: If6edc33a37e65a8494e66dc3b144138b1530367f
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
bfd9a4378eacaf2dc2bbe05ad48c5164fc93c9fe 22-May-2014 Mathieu Chartier <mathieuc@google.com> Change MethodHelper to use a Handle.

Added ConstHandle to help prevent errors where you modify the value
stored in the handle of the caller. Also fixed compaction bugs
related to not knowing MethodHelper::GetReturnType can resolve types.
This bug was present in interpreter RETURN_OBJECT.

Bug: 13077697

Change-Id: I71f964d4d810ab4debda1a09bc968af8f3c874a3
61c5ebc6aee2cac1c363de6fbdac25ada1697fdb 06-Jun-2014 Mathieu Chartier <mathieuc@google.com> Change FieldHelper to use a handle.

Fixed compaction bugs related to FieldHelper::GetType in:
artSet32InstanceFromCode
SetFieldValueImpl
CheckReceiver
Field_set
interpreter::DoFieldPut
MethodVerifier::VerifyISGet
MethodVerifier::VerifyISPut
MethodVerifier::VerifyIGetQuick

Bug: 13077697

Change-Id: I7de9ded2893b5568d43e4daa86fd135bf5508b72
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
0cd81352a7c06e381951cea1b104fd73516f4341 23-May-2014 Mathieu Chartier <mathieuc@google.com> Revert "Revert "Fix an outstanding compaction bug in interpreter.""

Fixed the generic trampoline to not use ToJObject when unnecessary.

Bug: 15167269

This reverts commit 3bdb873122964da7937eb070cbcf2ef638a8e459.

Change-Id: I0525d0e0f3afb753c770e1572070a0fa22b02271
3bdb873122964da7937eb070cbcf2ef638a8e459 23-May-2014 Mathieu Chartier <mathieuc@google.com> Revert "Fix an outstanding compaction bug in interpreter."

This reverts commit e09ae0920be57760fb390b6944bce420fa0b5582.

Change-Id: I48036306130d5ccfec683d0dc3e9a642a02ee9c1
e09ae0920be57760fb390b6944bce420fa0b5582 15-May-2014 Mathieu Chartier <mathieuc@google.com> Fix an outstanding compaction bug in interpreter.

Fixed a bug in DoFieldPut where the FieldHelper GetType could cause
thread suspension which would result in a stale obj.

Added more handles in the class linker to facilitate moving fiels
and methods in the future.

Removed un-necessarly passing handle references since these are value
types and don't need to be passed by reference.

Added a special NullHandle type which allows null handles without a
handle scope.

Change-Id: I1b51723920a2e4f4f8b2907066f578a3e879fd5b
f3632835c8d643632e6d1af403b4a5c309133e08 21-May-2014 Brian Carlstrom <bdc@google.com> Add context to LinkFields asserts since the previous_size check failed

Change-Id: If7a6c4219f52fd772141e6f070bb7d9a1d9464c0
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
2b7c4d196c8abe32f4ca633534917da9de53c359 19-May-2014 Mathieu Chartier <mathieuc@google.com> Don't get and restore thread state for ScopedFastNativeObjectAccess.

Before we would ensure that we were runnable for fast native object
access. However, these are done when you are already runnable.

Change-Id: Ia4c6e4c83d146fe2a988b37b3133ca46b0f0fa42
f832284dd847ff077577bb5712225430bbbb3b67 16-May-2014 Mathieu Chartier <mathieuc@google.com> Delete ClassHelper and fix compaction bug in GetDirectInterface

Cleanup helps to prevent compaction bugs. Fixed a fairly serious
compaction error caused by calling ClassHelper::GetDirectInterface
without handling the case where it causes thread suspension due to
ResolveType.

Bug: 8981901

Change-Id: I82b3bb6dd48d21eb6ece7aae0733c4a23c2bc408
f0972a410a0665dbe32bd96df09a572d69f9f3a3 16-May-2014 Dmitry Petrochenko <dmitry.petrochenko@intel.com> Fix generic jni issue in ArtMethod::GetQuickFrameInfo

The 64-bit host mode fails to start due to incorrect
detection of GetQuickGenericJniTrampoline.
The quick_code is 32-bit and taken from oat file, but
GetQuickGenericJniTrampoline returnf 0x7fffxx (64-bit)
address of trampoline and execution went to incorrect way.

Some clean-up.

Original Author: Dmitry Petrochenko <dmitry.petrochenko@intel.com>
Signed-off-by: Dmitry Petrochenko <dmitry.petrochenko@intel.com>
Signed-off-by: Serguei Katkov <serguei.i.katkov@intel.com>
Change-Id: I0952443b2a9f6833ad37ec373837ae208681fad7
0e12bdc49744eb6d5c29b9611a8dbe10bac4cd53 15-May-2014 Brian Carlstrom <bdc@google.com> Add ISA directory to image and odex pathnames.

Bug: 14882223
Bug: 14694978
Change-Id: Ic1b5ae836b8e91ea461dcd4f3da8e38dc3bec00f
db2633ce0358c704f97130a94b582602cb01d14a 16-May-2014 Mathieu Chartier <mathieuc@google.com> Change ObjectLock to take Handle instead of Handle pointer.

Change-Id: I9abdcdc5c9c9174634336b9250ab24c6aee434ec
507dfdd147c97bfbadebfd63584d094b6a4e7b47 16-May-2014 Ian Rogers <irogers@google.com> Compatibility layer to transition from UniquePtr to std::unique_ptr.

Use ART_WITH_STLPORT (enabled for the target) to cause the use of UniquePtr,
for the host switch to std::unique_ptr. For now the type remains called
UniquePtr.
Make dalvik compile with clang on the host, move its build to C++11.

Change-Id: I5ba8d2757904bc089ed62047ea03de3c0853fb12
2d10b206f9d0b97396b7dadb9a6415cd39efd341 13-May-2014 Ian Rogers <irogers@google.com> Ensure JNI primitive array type is appropriate.

Check the primitive array type for GetPrimitiveArray, ReleasePrimitiveArray,
GetPrimitiveArrayRegion and SetPrimitiveArrayRegion matches the given array
type. Check the GetPrimitiveArrayCritical and ReleasePrimitiveArrayCritical are
given a primitive array.
Add unit tests that null parameters lead to fatal errors, not crashes. Fix
issues where CheckJNI assumed non-null arguments.
Tidy testing code via the use of nullptr. Add a few extra checks.
Ensure arrays of void are not able to be created, use RI compatible
NoClassDefError.

Bug: 14817823

Change-Id: I9903bcd800d0da1988ced07f61fb97b783c5deab
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
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
151f2214d95f6003fe067fa2ebcd8ddad11e735c 06-May-2014 Ian Rogers <irogers@google.com> Improve ValidateSuperClassDescriptors performance.

ValidateSuperClassDescriptors uses FindClass with the 2 class loaders that are
being used in validating method parameter types. The use of 2 class loaders
ensures at least one miss with LookupClass and thereby a call to
ClassLoader.loadClass which will then defer to the parent class loader eating
time. This change modifies the behavior to instead lookup types with a dex
cache, so that resolution and load class are only performed once per type.

Bug: 12804658
Change-Id: Ia7be1f7bab8175a6934fd59fc54e0829beed0198
5d27fafdf03f259e92eaee9f6319b9349cc8d62e 03-May-2014 Ian Rogers <irogers@google.com> Allow ArtMethod::Invoke in unstarted runtimes.

Change-Id: I0141f4daef4751589d03d27484eb65c811b14f27
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
64e7ac0bcc2ea96c0e09fe3f4c86a5ad755a975c 01-May-2014 Vladimir Marko <vmarko@google.com> Don't leak oat file when we fail to open a dex file.

Change-Id: I929b34d240d2052d1eea8344b6fa79646920a4c1
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
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
8a630577ed2d9e9571c3434c505e5de223b23c07 09-Apr-2014 Vladimir Marko <vmarko@google.com> Move mapping table and vmap table offsets to OatMethodHeader.

This change has a libcore/ companion CL
"Remove ArtMethod's quick fields mapping table and vmap table."
https://android-review.googlesource.com/91254

Bug: 11767815
Change-Id: I46ce2067e1ecd915da3890606498e31ffc332813
d3c5bebcb52a67cb06e7ab303eaf45f230c08b60 11-Apr-2014 Vladimir Marko <vmarko@google.com> Avoid allocating OatFile::OatClass on the heap.

Avoid allocating a BitVector for OatFile::OatClass::bitmap_
with kOatClassSomeCompiled methods. That makes the OatClass
copy-constructible as it doesn't own any memory. We use that
in OatFile::OatDexFile::GetOatClass() to return the result
by value thus avoiding one or two heap allocations per call.

Change-Id: Ic7098109028a5b49e39ef626f877de86e732ed18
7ec2f1ca3cbd021848da75d5566f7239ce29676f 27-Mar-2014 Sebastien Hertz <shertz@google.com> Speed up single-stepping

During single-stepping sequence, we need to deoptimize everything when we
register a single-step event and undeoptimize everything when it is done. This
causes a slow pattern where we continuously deoptimize-undeoptimize everything
for each single-step.

This CL introduces a special handling of single-step undeoptimization. We now
delay the undeoptimization to the next resume (one thread or all threads) or
the end of the debugging session. Indeed, a single-step event registration is
always followed by a resume command.
At the "resume" point, we know if a single-step event is registered and if we
really need to undeoptimize. At the "registration" point, we know we did not
undeoptimized everything so we don't need to deoptimize everything again.
Therefore, in a sequence of single-steps, we only do a full deoptimization for
the first single-step and a full undeoptimization for the last single-step.

We update logs at deoptimization points so we can track more precisely. Note
they are verbose logs that still must be enabled with -verbose:jdwp option.

We also make some improvement inside instrumentation:
* updates Instrumentation::ShouldNotifyMethodEnterExitEvents to comply with its
name.
* compute frame id only once when looking for the corresponding instrumentation
frame.
* compute the OatMethod once in ClassLinker::GetPortableOatCodeFor to avoid
looking for it again.

Bug: 13577964
Change-Id: If6fa198a676b515cd474b8c4d7bf7ef3626f2dc7
329d18806792771dfee064203fe27875d79cd53a 08-Apr-2014 Andreas Gampe <agampe@google.com> Better error reporting when loading dex files

Collect all partial error messages and return them as cause
exceptions for the top-level exception returned.

Change-Id: I9661b8aed2a571dc88bf0f06d447108eeaed1409
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
4a200f56b7075309316b04d550c9cc50f8314edd 01-Apr-2014 Jeff Hao <jeffhao@google.com> Add support for -Xverify:none mode.

This mode skips all verification and compilation.
Public bug: https://code.google.com/p/android/issues/detail?id=67664

Change-Id: Idd00ab8e9e46d129c02988b063c41a507e07bf5b
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
62f0512bf6d9bc6141358bf22e93afa70dc58b1a 21-Mar-2014 Ian Rogers <irogers@google.com> Improvements to Field.get/set.

Avoid unnecessary repeated computation in Field.get/set.
Refactor FromReflectedField and FromReflectedMethod into common helpers in
mirror::ArtField and mirror::ArtMethod, and make use of thereby avoiding
transitions through JNI.
Avoid JNI use from within FromReflectedField and FromReflectedMethod.
Tidy up Field.get/set wrt moving collector support.
Bug: 12189533

Change-Id: I643ab3474bade4abac3a3ae2b6e373b2bb0891c8
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
9a6a99aaac2e4c973e0bc71075f196b8b084100f 14-Mar-2014 Andreas Gampe <agampe@google.com> Remove small duplicate code in Generic JNI handling, add comments

Change-Id: Ib276fa63b6a00480eaaff6c352d37917c61e966c
90546836312adda54f28b700f25ff29ec8becdf8 13-Mar-2014 Andreas Gampe <agampe@google.com> Fixes for Generic JNI

This fixes some linking issues and native code retrieval errors.
All host tests are functional with this change.

Make ArtMethod::GetFrameSizeInBytes() templated to bypass the
embedded sanity check. Necessary for fix-up decision.

Add ArtMethod metadata fix-up code to ClassLinker::LinkCode.
Necessitates new parameters to access the shorty and compute
the frame size.

Fix handling the JNI dlsym lookup stub in the generic JNI code.

Change-Id: I4173b0fbb1ba5b1bcbee1bb340cfdd08a54767e5
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
1a5706611bffa5d6ed6843ee5e320f504590e097 12-Mar-2014 Ian Rogers <irogers@google.com> A few 64bit fixes.

Change-Id: I1fe189d638b9cb5127b897da6cecdad6902db930
bf6b92a158053c98b15f4393abb3b86344ec9a20 06-Mar-2014 Andreas Gampe <agampe@google.com> Generic JNI implementation for x86_64

Starting implementation for generic JNI on x86_64. Frames are of
large static size (>4K) right now, should be compacted later. Passes
the whole of jni_compiler_test.

Change-Id: I88ac3e13a534afe7568d62a1ef97cb766e8260e4
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
893263b7d5bc2ca43a91ecb8071867f5134fc60a 04-Mar-2014 Mathieu Chartier <mathieuc@google.com> Avoid marking old class linker and intern table roots during pause.

The new root visiting logic has a concept of a root log which holds
new roots which were added since the start of the GC. This is an
optimization since it lets us only mark these newly added roots
during the pause (or pre-cleaning) since the other roots intern table
and class linker roots were marked concurrently at the start of the
GC.

Before (EvaluateAndApplyChanges):
MarkConcurrentRoots: Sum: 605.193ms
After:
MarkConcurrentRoots: Sum: 271.858ms

This should also reduce pathological GC pauses which used to be able
to happen when the intern table or class linker became "dirty"
during the concurrent GC.

Change-Id: I433fab021f2c339d50c35aaae7161a50a0901dec
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
2da882315a61072664f7ce3c212307342e907207 27-Feb-2014 Andreas Gampe <agampe@google.com> Initial changes towards Generic JNI option

Some initial changes that lead to an UNIMPLEMENTED. Works
by not compiling for JNI right now and tracking native methods
which have neither quick nor portable code. Uses new trampoline.

Change-Id: I5448654044eb2717752fd7359f4ef8bd5c17be6e
6fac447555dc94a935b78198479cce645c837b89 26-Feb-2014 Ian Rogers <irogers@google.com> Make allocations report usable size.

Work-in-progress to allow arrays to fill usable size. Bug: 13028925.
Use C++11's override keyword on GCC >= 2.7 to ensure that we override GC and
allocator methods.
Move initial mirror::Class set up into a Functor so that all allocated objects
have non-zero sizes. Use this property to assert that all objects are never
larger than their usable size.
Other bits of GC related clean-up, missing initialization, missing use of
const, hot methods in .cc files, "unimplemented" functions that fail at
runtime in header files, reducing header file includes, move valgrind's space
into its own files, reduce number of array allocation routines.

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

This feature is disabled by default.

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

Change-Id: Ia9be9814ab6e29169ac85edc4792ce8c81d552a9
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
35d8b8e0f6d174108b5e94ec2e49cf3c6a0c72c3 25-Feb-2014 Brian Carlstrom <bdc@google.com> Avoid going through char* for std::string API

Bug: 13186058

(cherry picked from commit 14ae4a873e91ae8cb1c00013579b5b058268879d)

Change-Id: Ib529cc10abc2d413e9da65c043dbc2638b734acd
97ae85853c8ac39cc71a67c820d76ebc2b2cab20 25-Feb-2014 Brian Carlstrom <bdc@google.com> Avoid going through char* for std::string API

Bug: 13186058
Change-Id: Idd58b15428e8849a93c1f57a9819fcb514f1545d
14ae4a873e91ae8cb1c00013579b5b058268879d 25-Feb-2014 Brian Carlstrom <bdc@google.com> Avoid going through char* for std::string API

Bug: 13186058
Change-Id: Idd58b15428e8849a93c1f57a9819fcb514f1545d
9837939678bb5dcba178e5fb00ed59b5d14c8d9b 25-Feb-2014 Ian Rogers <irogers@google.com> Avoid std::string allocations for finding an array class.

Introduce ClassLinker::FindArrayClass which performs an array class lookup
given the element/component class. This has a 16 element cache of recently
looked up arrays.
Pass the current thread to ClassLinker Find .. Class routines to avoid calls
to Thread::Current().
Avoid some uses of FindClass in the debugger where WellKnownClasses is a
faster and more compacting GC friendly alternative.

Change-Id: I60e231820b349543a7edb3ceb9cf1ce92db3c843
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
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
073278cd7129ff07dbcd6ccfabd2c34f47ec92ad 20-Feb-2014 Brian Carlstrom <bdc@google.com> Do not FixupStaticTrampolines of uninitialized classes

Bug: 13027732
Change-Id: I5966d63afd8fbcd091801297290f117f3c9cb44c
815873ecc312b1d231acce71e1a16f42cdaf09f2 14-Feb-2014 Mathieu Chartier <mathieuc@google.com> Change root visitor to use Object**.

Simplifies code and improves the performance of root visiting since
we usually don't need to check to see if the object moved.

Change-Id: Iba998f5a15ae1fa1b53ca5226dd2168a411196cf
d2fe10a3a34af171bf1631219cd2d6ff6b7778b5 15-Jan-2014 Sebastien Hertz <shertz@google.com> Remove blacklist

Removes the class initialization blacklist and use transaction to detect and
revert class initialization attempting to invoke native method. This only
concerns class initialization happening at compilation time when generating an
image (like boot.art for the system).

In transactional mode, we log every object's field assignment and array update.
Therefore we're able to abort a transaction to restore values of fields and
array as they were before the transaction starts. We also log changes to the
intern string table so we can restore its state prior to transaction start.

Since transactional mode only happens at compilation time, we don't need to log
all these changes at runtime. In order to reduce the overhead of testing if
transactional mode is on/off, we templatize interfaces of mirror::Object and
mirror::Array, respectively responsible for setting a field and setting an
array element.

For various reasons, we skip some specific fields from transaction:
- Object's class and array's length must remain unchanged so garbage collector
can compute object's size.
- Immutable fields only set during class loading: list of fields, method,
dex caches, vtables, ... as all classes have been loaded and verified before a
transaction occurs.
- Object's monitor for performance reason.

Before generating the image, we browse the heap to collect objects that need to
be written into it. Since the heap may still holds references to unreachable
objects due to aborted transactions, we trigger one collection at the end of
the class preinitialization phase.

Since the transaction is held by the runtime and all compilation threads share
the same runtime, we need to ensure only one compilation thread has exclusive
access to the runtime. To workaround this issue, we force class initialization
phase to run with only one thread. Note this is only done when generating image
so application compilation is not impacted. This issue will be addressed in a
separate CL.

Bug: 9676614
Change-Id: I221910a9183a5ba6c2b99a277f5a5a68bc69b5f9
0177e53ea521ad58b70c305700dab32f1ac773b7 12-Feb-2014 Ian Rogers <irogers@google.com> Work in the direction of hard float quick ABIs.

Pass a shorty to ArtMethod::Invoke so that register setup can use it.
Document x86-64 ABI.
Add extra debug output for one JNI native method registration fails, namely a
dump of the Class and its dex file's location.
Add hack to get testing of OatMethod's without GC maps working in 64bit.

Change-Id: Ic06b68e18eac33637df2caf5e7e775ff95ae70f3
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
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
b60847e72d040bf5e08b787d4b63708f7a506a31 06-Feb-2014 Brian Carlstrom <bdc@google.com> Merge "Fix apps with more than one dex file with the same name"
0d6adac2550113da33d42e88f0d87a57b25c5a60 06-Feb-2014 Brian Carlstrom <bdc@google.com> Fix apps with more than one dex file with the same name

Reverts most of 60836d5a9bcf8b30984aae4279a4f6233b0bf622 which I
believe was an incorrect attempt to address issue introduced in
8d31bbd3d6536de12bc20e3d29cfe03fe848f9da, which is also reverted here.

Also adds some debugging aids include operator<< for DexFile and
MemMap and checksum information to OatFile logging.

Bug: 12802375
Change-Id: Idd6f7dd487f6e01e9479cd15cd4b61580160e8a3
c0a9ea40237de8fa3c623f68c904d416a3a79bf5 04-Feb-2014 Mathieu Chartier <mathieuc@google.com> Add missing SIRT to CreateArrayClass.

component_type was not guarded by a SIRT. This meant that it could
point to a stale object if AllocClass caused a GC.

Bug: 12875306
Change-Id: I387aa53cf461349b183360c37ff69bffbfe54041
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
23a282146042a0d171aec2a415176f5d0621a90c 09-Jan-2014 Vladimir Marko <vmarko@google.com> Clean up access checks.

Change-Id: Ia62ba6c8f1d0a9bfbbfde2d7be4c52c0f982b9d2
60836d5a9bcf8b30984aae4279a4f6233b0bf622 16-Jan-2014 Vladimir Marko <vmarko@google.com> Fix opening oat files that are out of date.

Make sure we're not using an old MAP_PRIVATE mapping of an
OatFile after a forked process modifies the underlying file.

Change-Id: I5c6caaf34272c805e40e95ee690dd948d7406751
5ddb4104ac605d66693b55b79f26f8b8a5505e63 07-Jan-2014 Ian Rogers <irogers@google.com> Remove intialized static storage from dex cache.

The initialized static storage array is used by compiled code to determine if
for a sget/sput class initialization is necessary. The compiled code typically
doesn't require this test as the class is pre-initialized or the class being
accessed is the same as the current method.

Change-Id: Icbc45e692b3d0ac61e559e69edb6c9b29439e571
801a811c2c59704d326dcde440e58d84ebb22b25 06-Jan-2014 Vladimir Marko <vmarko@google.com> Remove duplicate/unnecessary code from ClassLinker.

Change-Id: I986c3aa36cb63ae5ea099680e8e4c42bdf891ef1
2b5eaa2b49f7489bafdadc4b4463ae27e4261817 13-Dec-2013 Vladimir Marko <vmarko@google.com> Move compiler code out of method verifier.

We want to detect small methods for inlining at the end of
the method verification. Instead of adding more compiler
code to the runtime, we create a callback from the runtime
into the compiler, so that we can keep the code there.
Additionally, we move the compiler-related code that was
already in the method verifier to the compiler since it
doesn't really belong to the runtime in the first place.

Change-Id: I708ca13227c809e07917ff3879a89722017e83a9
22cb09b35e8eb30c016065f0eec4b3b96666de43 12-Dec-2013 Jeff Hao <jeffhao@google.com> Add class to verifier's rejected list if superclass is erroneous.

This will prevent the compiler from trying to compile one of these
classes, which will fail because it has no GC map.

Bug: 12104117
Change-Id: I77ec77d30ee5dc92d7f4c594f1e8f1ce9b67855d
08cbf66dc4632913f80f8ac18082c39b7d52c7dd 11-Dec-2013 Brian Carlstrom <bdc@google.com> Do not require classes.dex to support stripped zip files

Change-Id: Ief34c1b559dbebda85d181ae49da7d35446c9b37
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
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
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
610e49f5adc8b5e4a37696aa20fc029dab6b1e40 05-Nov-2013 Brian Carlstrom <bdc@google.com> Fix typo in duplicate condition

Bug: https://code.google.com/p/android/issues/detail?id=61768
Change-Id: I65b85de1d942c5bd0dfd6a8f7b67e157c066b9f6
dfb325e0ddd746cd8f7c2e3723b3a573eb7cc111 30-Oct-2013 Ian Rogers <irogers@google.com> Don't use UTF16 length as length for MUTF8.

Bug 11367555.

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

Change-Id: Idf7fe85e1293453a8ad862ff2380dcd5db4e3a39
79b4f38dd35b83206e8166aaafb94bd75c3318b3 24-Oct-2013 Mathieu Chartier <mathieuc@google.com> Fix incorrect initial dex cache size.

We were previously setting it to be sizeof(DexCacheClass) instead
of sizeof(DexCache). This was causing some problems with
compaction when I relied on the object sizes being accurate to
visit objects in the bump pointer space.

Bug: 8981901
Change-Id: Iede04763aced041986b1b239368fc867143ad70d
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
e810452722ac83b294d1f7aa80bdd88e547d5af0 16-Oct-2013 Brian Carlstrom <bdc@google.com> Preload DexCaches

Bug: 11045348
Change-Id: I6f9c0d11613b6b4933a04ae23dbf4bc7879cea65
31b9d6644cce958ddde939e8c26a08e3f704e3df 14-Oct-2013 Mathieu Chartier <mathieuc@google.com> Hold proxy classes live in class linker.

We currently assume that class loaders hold proxy classes live, but
this is not always the case (e.g. class loader gets freeed). This
was resulting in a bug where we were freeing a class when there
was still a live object referencing it.

Bug: 11141694
Change-Id: I318e9fee41c86b7790431d09ba5e83633fab547b
241b5de2d3cf06868ac31f1153aa0b32ddb07b20 10-Oct-2013 Ian Rogers <irogers@google.com> Clinits may not have the kAccConstructor flag.

Bug: 11157540
Set the clinit access flag when we load the method and warn about badly
formed access flags.

Change-Id: I515c692095051f84f98510722ab764591185918e
8e3fb14615f20677da8421ada131b5f2fcd8eb56 10-Oct-2013 Brian Carlstrom <bdc@google.com> Revert "Add Jack modifier."

This reverts commit 6ffd0967027c092a62d7100ca42ceded369c8ca1.

Change-Id: Ia69241a5100e8f740379e2ed944279de4daaf9ed
756ee4e090bc1e1812b41fb7b4661df601a32ef9 04-Oct-2013 Brian Carlstrom <bdc@google.com> Find OatDexFile by DexFile name and checksum, not just checksum

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

Bug: 10614658
Change-Id: I9156dfca78ac8cd1c62fb258825cc791629270a4
1c82982f4eab8f0e84829fec25e3f899da44e7ce 01-Oct-2013 Ian Rogers <irogers@google.com> Early exit for static fixup if no direct methods.

Change-Id: I401746e48259a98fb0c80144ff5310380889b154
b00309f1aece094de16e0e542cc30cb2e27f2326 30-Sep-2013 Brian Carlstrom <bdc@google.com> Fix OatFile leak causing dlopen to return stale OatFile contents

Bug: 10917637
Change-Id: If6b7bb8dd9c7aa3d870bd43964f31512385c5d39
d91d6d6a80748f277fd938a412211e5af28913b1 26-Sep-2013 Ian Rogers <irogers@google.com> Introduce Signature type to avoid string comparisons.

Method resolution currently creates strings to then compare with strings formed
from methods in other dex files. The temporary strings are purely created for
the sake of comparisons. This change creates a new Signature type that
represents a method signature but not as a string. This type supports
comparisons and so can be used when searching for methods in resolution.

With this change malloc is no longer the hottest method during dex2oat (now its
memset) and allocations during verification have been reduced. The verifier is
commonly what is populating the dex cache for methods and fields not declared
in the dex file itself.

Change-Id: I5ef0542823fbcae868aaa4a2457e8da7df0e9dae
fc0e94bed3f88ed7e50854fd8dfaf5dcb345250f 24-Sep-2013 Ian Rogers <irogers@google.com> StringPiece clean up.

Profile guided clean up.
Try to avoid creating StringPieces with the contents of a dex file where
the length is known.
Try to avoid RegTypeCache::FromDescriptor when there's a class available.
Make ConstantType::ConstantValue inlinable.
Saving of about 50ms from a 2 threaded ThinkFree compile on host.

Change-Id: I47a12c3c76f46e2c9805be1c3a3e3870fe1f5d85
abcf7ae8deba4ee81dec44f3d1a2f0ecaf032859 24-Sep-2013 Brian Carlstrom <bdc@google.com> Fix overly restrictive assert

Found by 084-class-init on a clean build.

Bug: 10750824
Change-Id: I7cf1ee190cbddbda98132511527eab36c36da523
cb5f5e53b580023fa2c1d8235c2e9aa1ff67d1dc 24-Sep-2013 Brian Carlstrom <bdc@google.com> Make sure CompilerDriver actually resolves types

Bug: 10750824
Change-Id: Ie61881f24196e851d87822798a7e9abdf9678aa3
ee39a10e45a6a0880e8b829525c40d6055818560 19-Sep-2013 Ian Rogers <irogers@google.com> Use class def index from java.lang.Class.

Bug: 10244719
This removes the computation of the dex file index, when necessary this is
computed by searching the dex file. Its only necessary in
dalvik.system.DexFile.defineClassNative and DexFile::FindInClassPath, the
latter not showing up significantly in profiling with this change.

(cherry-picked from 8b2c0b9abc3f520495f4387ea040132ba85cae69)
Change-Id: I20c73a3b17d86286428ab0fd21bc13f51f36c85c
8b2c0b9abc3f520495f4387ea040132ba85cae69 19-Sep-2013 Ian Rogers <irogers@google.com> Use class def index from java.lang.Class.

Bug: 10244719
Depends on:
https://googleplex-android-review.git.corp.google.com/362363
This removes the computation of the dex file index, when necessary this is
computed by searching the dex file. Its only necessary in
dalvik.system.DexFile.defineClassNative and DexFile::FindInClassPath, the
latter not showing up significantly in profiling with this change.

Change-Id: I20c73a3b17d86286428ab0fd21bc13f51f36c85c
c4621985bdfc2b27494087e5dee65a6d0cc5a632 17-Sep-2013 Mathieu Chartier <mathieuc@google.com> Fix race in root marking.

There was a race which caused the class linker / intern table to not
become dirty after adding a root. We now guard the is dirty flag by
the corresponding locks to prevent this from occuring. This was
causing roots to be occasionally missed.

Also fixes the bug where we occasionally scan more cards than
needed.

Bug: 10626133

Change-Id: I0f6e72d92035ff463954d66988ef610ea0df61be
423d2a3dcbb260b020efb5da59f784c9f02accbf 13-Sep-2013 Mathieu Chartier <mathieuc@google.com> Add support for changing roots through the root visitor callback.

Needed for copying collectors.

Change-Id: Icc4a342a57e0cfb79587edb02ef8c85e08808877
a436fde2762664a3ecdda5eefcadd20b2e104f59 28-Aug-2013 Ian Rogers <irogers@google.com> Handle OOMEs in class linker with grace.

Check for OOMEs and then fail due to them in class loading.
Make the compiler driver spot OOMEs during resolution and abort compilation to
avoid needless GC thrash then eventual death.
Allocate the pre-allocated OOME during Runtime::Init as Runtime::Start isn't
called in the context of the compiler/tools.

Change-Id: Id72199d0fe82001b5bf22758b3cdc9cc4b8efbb9
7dfb28c066159e6cde8181720f0c451a700ef966 22-Aug-2013 Ian Rogers <irogers@google.com> Don't scan image space when starting runtime.

Bug 10432288.
Find Classes and Strings from dex caches lazily rather than when the image is
loaded.
Make class status changes do notifies when there can be waiters.
For Class lookup there's a pathology if we always search dex caches and
so after 1000 failures move all classes into the class table.
Be consistent in using "const char*" for class linker descriptors as this
most easily agrees with the type in the dex file.
Improve the intern run-test so that it has a case of a literal contained in the
image.
Modify image_test to allow any valid lock word rather than expecting 0, ideally
we wouldn't see inflated monitors but we do due to NotifyAll (see bug 6961405).

Change-Id: Ia9bfa748eeccb9b4498784b97c6823141b1f6db8
6d3f72ce67d012318dee23c86a7464a9440fabff 22-Aug-2013 Brian Carlstrom <bdc@google.com> Use Class::IsVerified to confirm status, not MethodVerifier::FailureKind

Change-Id: Ideeb1ee38e9188ec7cbfd001e7422e847d52092c
8f3c9ae38df2460940a26dff889a84430b6c38d3 21-Aug-2013 Ian Rogers <irogers@google.com> Don't allow class status to go backward except for error.

Allow greater parallelism of initialization.
Bug 10393546.

Change-Id: Ic194ed490bb0a986250c09fcf335eb1be9714657
fe9ca4028f379688ecba6132ac3738171176b3e4 21-Aug-2013 buzbee <buzbee@google.com> Compiler filter update

Tweak of the compiler filter to give better results for applications
which are not dominated by tight arithmetic loops. Deleted
the "DeferCompilation" setting - it didn't differ enough from the
"Space" setting. Added "Everything" setting to support forced
compilation (for images and testing). Previously used "Speed"
for that purpose, but in the speed setting there are some things we
don't want to compile.

Change-Id: Ia53b14f2044fc9738c1a4c1318f8204f2c25abe3
be7149fc2e7cc607937209f2819e3c1d672e2668 20-Aug-2013 Ian Rogers <irogers@google.com> Avoid throwing NoClassDefFoundError at compile time.

Change-Id: I8ba56a8750e1718babcb1f94e0408d89f58ea9b5
e6bb3b2ce5a69c31c2adfc7eb2705633b7f966eb 20-Aug-2013 Ian Rogers <irogers@google.com> Reduce AOT initialization.

When compiling apps there is no need to resolve all types in the dex file, just
those declared in the dex file. There's also no need to initialize static
fields if we can only leave the class in a verified state.

Increase use of CompilerDriver::IsImage.
Move timing of dex2oat setup to before Runtime::Create.

On run-test 056 the performance improvement is an order of magnitude, for
ThinkFree dex2oat time is dominated by compilation and this change has no
effect.

Bug 10316099.

Change-Id: Ibdd7caa43284e7448e6a56d810967100ae4a7898
90af14d2743614e3e1453984b14258a6f145501d 16-Aug-2013 Dragos Sbirlea <dragoss@google.com> Get SEA fibonacci running in interpreter mode.

Android.mk: Added new file to build.
compile_driver.cc: Moved SE_IR usage test in the block
protected by bool compile, which is enabled by
adding a sepatate test in IsCnadidateForCompilation.
class_linker.cc: Added check in NeedsInterpreter to enable SEA_IR.
art_method-inl.h: DIsabled check in SEA_IR mode.
method_verifier.cc: Added check for SEA_IR mode.
method_verifier.h: Chenged IsCandidateForCompilation signature to
allow testing the function name (for SEA_IR selective
compilation).
dot_gen.h: Updated ART file API usage to altest version.
sea_ir/frontend.cc: Passing function symbol name to CompileMethod.
instruction_Nodes.h: Added accessor for method index for
InvokeStatic IR node.
sea.cc: Added additional IR SignatureNode for function calls (extra
Method parameter). Fixed UnnamedConstant constant value.
sea.h: Passing function_name to GenerateLLVM.
type_inference_visitor.cc: Aded type for first (placeholder) method
parameter.

Change-Id: I295858ea0761a3dffb36f35748d8b93d4919d6a9
02e25119b15a6f619f17db99f5d05124a5807ff3 15-Aug-2013 Mathieu Chartier <mathieuc@google.com> Fix up TODO: c++0x, update cpplint.

Needed to update cpplint to handle const auto.

Fixed a few cpplint errors that were being missed before.

Replaced most of the TODO c++0x with ranged based loops. Loops which
do not have a descriptive container name have a concrete type instead
of auto.

Change-Id: Id7cc0f27030f56057c544e94277300b3f298c9c5
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
0f40ac31134d9ae0f059d4c448165599dc8459c1 14-Aug-2013 Ian Rogers <irogers@google.com> Fix races in small mode compiler filters setup

Fixes host tests in small art mode.

Change-Id: I2579f872583f425607f91c1e58df68b05b5098bb
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
08bf1967611965b65ffd5de1aa603b60e7b2d6a8 12-Aug-2013 Dragos Sbirlea <dragoss@google.com> Work on SMALL_ART and PORTABLE working at the same time.

Change-Id: Iddedf63b6f9d908717a4d30f963e9b81a9604d49
468532ea115657709bc32ee498e701a4c71762d4 05-Aug-2013 Ian Rogers <irogers@google.com> Entry point clean up.

Create set of entry points needed for image methods to avoid fix-up at load time:
- interpreter - bridge to interpreter, bridge to compiled code
- jni - dlsym lookup
- quick - resolution and bridge to interpreter
- portable - resolution and bridge to interpreter

Fix JNI work around to use JNI work around argument rewriting code that'd been
accidentally disabled.
Remove abstact method error stub, use interpreter bridge instead.
Consolidate trampoline (previously stub) generation in generic helper.
Simplify trampolines to jump directly into assembly code, keeps stack crawlable.
Dex: replace use of int with ThreadOffset for values that are thread offsets.
Tidy entry point routines between interpreter, jni, quick and portable.

Change-Id: I52a7c2bbb1b7e0ff8a3c3100b774212309d0828e
(cherry picked from commit 848871b4d8481229c32e0d048a9856e5a9a17ef9)
ee17e0aa4d24deb11c1766bfcc6a864519df1c1e 31-Jul-2013 buzbee <buzbee@google.com> Compilation filter

This CL introduces a static compilation filter mechanism intended
to allow us to reduce compilation time and space requirements until
we have a profiling mechanism in place.

It supports 5 modes of filtering:

o interpret-only (compile nothing)
o deferred-compilation (compile only those methods believe to be
compute-intensive)
o space (optimized for space)
o balanced (best return on space investment)
o speed (compile everything)

A future CL will allow the default filtering mode to be set
via system property. For now, you can pass it in via command
line as follows:

dalvikvm -compiler-filter:[interpret-only|defer-compilation|
space|balanced|speed]

or dex2oat --runtime-arg -compiler-filter:[one of the above modes]

Creating a file named art/SMALL_ART will force the filter
default to interpret-only. Later on we'll move this capability
to a persistent system property.

or modify kDefaultCompilerFilter in runtime.h

It also changes the compiler driver to allow the compilers to
decline to compile a method by return NULL.

Change-Id: Ic73411818f8bb845a4a19a05b0395c50902c534f
(cherry picked from commit a024a0686c3b0fea13f362bff70d65981e5febc5)
a024a0686c3b0fea13f362bff70d65981e5febc5 31-Jul-2013 buzbee <buzbee@google.com> Compilation filter

This CL introduces a static compilation filter mechanism intended
to allow us to reduce compilation time and space requirements until
we have a profiling mechanism in place.

It supports 5 modes of filtering:

o interpret-only (compile nothing)
o deferred-compilation (compile only those methods believe to be
compute-intensive)
o space (optimized for space)
o balanced (best return on space investment)
o speed (compile everything)

A future CL will allow the default filtering mode to be set
via system property. For now, you can pass it in via command
line as follows:

dalvikvm -compiler-filter:[interpret-only|defer-compilation|
space|balanced|speed]

or dex2oat --runtime-arg -compiler-filter:[one of the above modes]

Creating a file named art/SMALL_ART will force the filter
default to interpret-only. Later on we'll move this capability
to a persistent system property.

or modify kDefaultCompilerFilter in runtime.h

It also changes the compiler driver to allow the compilers to
decline to compile a method by return NULL.

Change-Id: Ic73411818f8bb845a4a19a05b0395c50902c534f
848871b4d8481229c32e0d048a9856e5a9a17ef9 05-Aug-2013 Ian Rogers <irogers@google.com> Entry point clean up.

Create set of entry points needed for image methods to avoid fix-up at load time:
- interpreter - bridge to interpreter, bridge to compiled code
- jni - dlsym lookup
- quick - resolution and bridge to interpreter
- portable - resolution and bridge to interpreter

Fix JNI work around to use JNI work around argument rewriting code that'd been
accidentally disabled.
Remove abstact method error stub, use interpreter bridge instead.
Consolidate trampoline (previously stub) generation in generic helper.
Simplify trampolines to jump directly into assembly code, keeps stack crawlable.
Dex: replace use of int with ThreadOffset for values that are thread offsets.
Tidy entry point routines between interpreter, jni, quick and portable.

Change-Id: I52a7c2bbb1b7e0ff8a3c3100b774212309d0828e
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
7655f29fabc0a12765de828914a18314382e5a35 29-Jul-2013 Ian Rogers <irogers@google.com> Portable refactorings.

Separate quick from portable entrypoints.
Move architectural dependencies into arch.

Change-Id: I9adbc0a9782e2959fdc3308215f01e3107632b7c
8df6cea295bb685e812e40496ed77351b9881ef6 29-Jul-2013 Jeff Hao <jeffhao@google.com> Put jni lookup stub in native code ptr and fix GetOatMethodFor for proxy.

Change-Id: I197aeafd9828a6ac5546af86ca4e6141b2375896
7934ac288acfb2552bb0b06ec1f61e5820d924a4 26-Jul-2013 Brian Carlstrom <bdc@google.com> Fix cpplint whitespace/comments issues

Change-Id: Iae286862c85fb8fd8901eae1204cd6d271d69496
a6468f681b6e5feff940d0c32363847e795e97c6 19-Jul-2013 Brian Carlstrom <bdc@google.com> Fix dalvik-dev branch cpplint issues

Change-Id: Id5710dd26e8c433887543c867f037532e61731cc
ad256bb4ca1740eba533d6527bad34e9a046ec00 18-Jul-2013 Anwar Ghuloum <anwarg@google.com> Fixing gtest failure due to VerifyClassUsingOatFile change

Change-Id: I8d4ed31fada333013a56dcb7aebbd25f5323017c
044d2832edbdadbbdce78012a257428224f42a15 18-Jul-2013 Anwar Ghuloum <anwarg@google.com> Fix VerifyClassUsingOatFile to check preverified image classes

We now bail out in two cases: we're verifying an application class or we're
verifying a boot classpath class while compiling boot classpath classes.

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

Change-Id: I069586205a9a92fc7375ccf5cdde136bbbcfc800
f1d3455064792ac1c486a4a9c24279a37b4af473 13-Jul-2013 Brian Carlstrom <bdc@google.com> Do not mark pages executable unnecessarily to play nice with selinux

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