History log of /art/compiler/driver/compiler_driver.cc
Revision Date Author Comments
743aac3fbad3bbafeb5ad98e157726f740feb725 23-Mar-2018 Mathieu Chartier <mathieuc@google.com> Disable encoded static initialization

Encoded static initialization currently requires fixing up intered
strings. This fix up process causes app startup to be ~10ms longer.
Disable the initialization and fixup process until there is a faster
way to fix up the interned strings.

Bug: 70734839
Test: test-art-host

(cherry picked from commit 0933cc54c52054ab384d9a426448cd2004aa8968)

Merged-In: I847d0bd9a362243241c93b115081a67faab7bfc1
Change-Id: I11ffbba8538656b84fd5df5ab970633d90d86530
56c9b7c8b1c2b3aa848229e207caa8c6613692c0 28-Feb-2018 Andreas Gampe <agampe@google.com> ART: Change abort() to _exit()

Change kill behavior to _exit. Even a single stack trace is too much
for some folks.

Bug: 73749543
Test: mmma art
Change-Id: I4aef95a56056df45fb66d1e04e66fb465eb1700e
af290318c31180148bab64038d66a6059a1a89d5 27-Feb-2018 Roland Levillain <rpl@google.com> Small documentation and stylistic changes.

Test: art/test.py
Change-Id: Ibc74ee4783314266bf1d027811715058626c57c8
b2ec9f5c128673c43f776cbe12c8eeb0a6884ebb 21-Feb-2018 David Sehr <sehr@google.com> Remove duplication, split tests

The code move to libdexfile/dex/descriptors_names.cc apparently did not
remove the original code from runtime/utils.cc. Fix that duplication
and all the header mentions needed. Also, split the test files to go
along with the new locations for the code to be tested.

Bug: 22322814
Test: make -j 50 checkbuild
make -j 50 test-art-host-gtest
flash & boot marlin

Change-Id: Ie734672c4bca2c647d8016291f910b5608674545
279e3a3499d208daf467a1690b111dfb06f3e96e 25-Jan-2018 Mathieu Chartier <mathieuc@google.com> Enable code item deduping

Dedupe code items if they have the same contents, this is safe
because of the fixed quickening logic.

Removed duplicate code items in ManyMethods that caused the startup
methods section to be empty in dex2oat_test.

To avoid errors related to quickening and compilation of shared code
items, quickening is currently disabled for shared code items.

Bug: 63756964
Test: test-art-host

Change-Id: I7c62eb746785d787c5269effd396f7be4859d3a6
0225f8e2939a9340cb7dcebfcfe7996a2bd9bce9 31-Jan-2018 David Sehr <sehr@google.com> Revert "Revert "Make libdexfile build independent of runtime dir""

This reverts commit 787784f9effb126b5d0d3dc97d544c4a477b5daf.

Reason for revert: Bot configuration issue.

Change-Id: I6a10bb4a9571f89c7e4dd095f9157e830a44e2de
Bug: 22322814
Test: make -j 50 checkbuild
787784f9effb126b5d0d3dc97d544c4a477b5daf 30-Jan-2018 David Sehr <sehr@google.com> Revert "Make libdexfile build independent of runtime dir"

This reverts commit b40b7e73469339a6b667b4a2e2b8690112a74dc9.

Reason for revert: on device libdexfile.so missing

Change-Id: I9bd61a98bef870400580e8c991cb061d3f57fa72
b40b7e73469339a6b667b4a2e2b8690112a74dc9 26-Jan-2018 David Sehr <sehr@google.com> Make libdexfile build independent of runtime dir

Remove libdexfile's dependency on utils.cc and move utf.cc into
/dex. Remove libdexfile's constituent sources from libart and
use libdexfile wherever libart is. Also remove some ART-specific
interfaces. Libdexfile's tests remain to be converted, plus
moving the files to a new directory peer to runtime/.

Bug: 22322814
Test: make -j 50 test-art-host
Change-Id: Ifaf695216e4a0e43d3aa377984d933f7a2a243c2
bff7a52e2c6c9e988c3ed1f12a2da0fa5fd37cfb 25-Jan-2018 Nicolas Geoffray <ngeoffray@google.com> Revert "Compiler changes for bitstring based type checks."

Bug: 64692057
Bug: 71853552
Bug: 26687569

This reverts commit eb0ebed72432b3c6b8c7b38f8937d7ba736f4567.

Change-Id: I7daeaa077960ba41b2ed42bc47f17501621be4be
0be8cabf16ee5fa5186bc90471911336f6c01f19 25-Jan-2018 Nicolas Geoffray <ngeoffray@google.com> Revert "ART: Use the bitstring type check for AOT app compilation."

Test failures:
http://build.chromium.org/p/client.art/builders/fugu-debug/builds/4875

01-25 02:05:28.357 23732 23732 F /data/local/tmp/system/bin/../bin/dalvikvm: quick_throw_entrypoints.cc:132] Check failed: !dest_type->IsAssignableFrom(src_type)


This reverts commit 718e8319c728e9ee2ec15b1d56ca96baa4393028.

Change-Id: I022f88cd81ae99143e5670ae29eae326ecc83cc2
718e8319c728e9ee2ec15b1d56ca96baa4393028 22-Jan-2018 Vladimir Marko <vmarko@google.com> ART: Use the bitstring type check for AOT app compilation.

For boot image target classes that have their bitstring
already assigned in the boot image.

The size of the services.odex for aosp_taimen-userdebug:
- before:
- arm64: 20988640
- after:
- arm64: 20968016 (-20KiB, -0.1%)
(There is no arm version, only arm64.)

Test: New test case in 552-checker-sharpening.
Test: m test-art-host-gtest
Test: testrunner.py --host --optimizing
Test: Pixel 2 XL boots.
Test: testrunner.py --target --optimizing
Bug: 64692057
Change-Id: I9585efca8ba0df15400e7536e5e2cc76aca13e8d
f30752709e1131ae1a4c16f22cc7a0960c198e77 08-Jan-2018 Nicolas Geoffray <ngeoffray@google.com> Revert "Revert "Don't embed the dex code in the oat file if dex is uncompressed.""

Bug: 63920015
Bug: 70854754

Test: oat_writer_test.cc, test.py

Revert was due to userdebug/user differences, which is fixed with:
https://googleplex-android-review.googlesource.com/#/c/platform/build/+/3434091/

This CL also fixes oatdump when the dex code is not in the .vdex file.

This reverts commit e166e67666bf4b23e4ed0a98f5e2bb3cae9cee7d.

Change-Id: Iec924be2ff8f03cf2ebe306e7a0018241f33beb0
eb0ebed72432b3c6b8c7b38f8937d7ba736f4567 10-Jan-2018 Vladimir Marko <vmarko@google.com> Compiler changes for bitstring based type checks.

We guard the use of this feature with a compile-time flag,
set to true in this CL.

Boot image size for aosp_taimen-userdebug in AOSP master:
- before:
arm boot*.oat: 63604740
arm64 boot*.oat: 74237864
- after:
arm boot*.oat: 63531172 (-72KiB, -0.1%)
arm64 boot*.oat: 74135008 (-100KiB, -0.1%)

The new TypeCheckBenchmark yields the following changes
using the little cores of taimen fixed at 1.4016GHz:
32-bit 64-bit
timeCheckCastLevel1ToLevel1 11.48->15.80 11.47->15.78
timeCheckCastLevel2ToLevel1 15.08->15.79 15.08->15.79
timeCheckCastLevel3ToLevel1 19.01->15.82 17.94->15.81
timeCheckCastLevel9ToLevel1 42.55->15.79 42.63->15.81
timeCheckCastLevel9ToLevel2 39.70->14.36 39.70->14.35
timeInstanceOfLevel1ToLevel1 13.74->17.93 13.76->17.95
timeInstanceOfLevel2ToLevel1 17.02->17.95 16.99->17.93
timeInstanceOfLevel3ToLevel1 24.03->17.95 24.45->17.95
timeInstanceOfLevel9ToLevel1 47.13->17.95 47.14->18.00
timeInstanceOfLevel9ToLevel2 44.19->16.52 44.27->16.51
This suggests that the bitstring typecheck should not be
used for exact type checks which would be equivalent to the
"Level1ToLevel1" benchmark. Whether the implementation is
a beneficial replacement for the kClassHierarchyCheck and
kAbstractClassCheck on average depends on how many levels
from the target class (or Object for a negative result) is
a typical object's class.

Test: m test-art-host-gtest
Test: testrunner.py --host --optimizing --jit
Test: testrunner.py --host -t 670-bitstring-type-check
Test: Pixel 2 XL boots.
Test: testrunner.py --target --optimizing --jit
Test: testrunner.py --target -t 670-bitstring-type-check
Bug: 64692057
Bug: 71853552
Bug: 26687569
Change-Id: I538d7e036b5a8ae2cc3fe77662a5903d74854562
3913e488afb884ccee76d620d4357b6308e55010 23-Jan-2018 Andreas Gampe <agampe@google.com> ART: Refactor profile_compilation_info.h includes

Use forward declarations.

Test: m
Change-Id: Ife25be9e2eb5ba9224f082aaa935f821a3597963
3c060ad0ff25d8231d5a93ac17ec0f30150034dd 22-Jan-2018 Andreas Gampe <agampe@google.com> ART: Refactor dex2dex compilation

Refactor the code to tease out the dex2dex compilation flow. Use
templatized functions for common code.

Bug: 29089975
Test: m test-art-host
Change-Id: Ib31d491ed4676ae4cee9132ceb613a372fb06479
a79efdb69350fa66e1beabed4499ef4d0e809785 19-Jan-2018 Mathieu Chartier <mathieuc@google.com> Fix quickening logic

Fix varius bugs in the quickening logic where related to shared code
items for different methods.

Fixed the case where two methods quicken differently on the same code
item by checking that the quicken info is the same for all methods
that quicken the same code item. This is accomplished by requickening
and reverifying the contents of the quicken info.

Fixed the case where the dex to dex compiler would abort from a
DCHECK that there was no already quickened instructions.

Feature is tested by enabling deduping (aog/594315).

Test: test-art-host
Bug: 63756964

Change-Id: I52c2b89518f4e808594b450a5fcc373ab5a5863b
210531f8775c89feb90d430cd5b6026b4cf8ef89 12-Jan-2018 Mathieu Chartier <mathieuc@google.com> Revert "Revert "Move quickening info logic to its own table""

Bug: 71605148
Bug: 63756964

Test: test-art-target on angler

This reverts commit 6716941120ae9f47ba1b8ef8e79820c4b5640350.

Change-Id: Ic01ea4e8bb2c1de761fab354c5bbe27290538631
6716941120ae9f47ba1b8ef8e79820c4b5640350 12-Jan-2018 Nicolas Geoffray <ngeoffray@google.com> Revert "Move quickening info logic to its own table"

Bug: 71605148
Bug: 63756964

Seems to fail on armv7.

This reverts commit f5245188d9c61f6b90eb30cca0875fbdcc493b15.

Change-Id: I37786c04a8260ae3ec4a2cd73710126783c3ae7e
7a26f948204377130be7b738d70d7365c86a804b 05-Jan-2018 Mathieu Chartier <mathieuc@google.com> Move quickening info logic to its own table

Added a table that is indexed by dex method index. To prevent size
overhead, there is only one slot for each 16 method indices. This
means there is up to 15 loop iterations to get the quickening info
for a method. The quickening infos are now prefixed by a leb
encoded length. This allows methods that aren't quickened to only
have 1.25 bytes of space overhead.

The value was picked arbitrarily, there is little advantage to
increasing the value since the table only takes 1 byte per 4 method
indices currently. JIT benchmarks do not regress with the change.

There is a net space saving from removing 8 bytes from each
quickening info since most scenarios have more quickened methods than
compiled methods.

For getting quick access to the table, a 4 byte preheader was added
to each dex in the vdex file

Removed logic that stored the quickening info in the CodeItem
debug_info_offset field.

The change adds a small quicken table for each method index, this
means that filters that don't quicken will have a slight increase in
size. The worst case scenario is compiling all the methods, this
results in 0.3% larger vdex for this case. The change also disables
deduping since the quicken infos need to be in dex method index
order.

For filters that don't compile most methods like quicken and
speed-profile, there is space savings. For quicken, the vdex is 2%
smaller.

Bug: 71605148
Bug: 63756964
Test: test-art-host

Change-Id: I89cb679538811369c36b6ac8c40ea93135f813cd
698ebbca3c54d17c696e87b9e5838df6a5ac9b08 05-Jan-2018 Mathieu Chartier <mathieuc@google.com> Clean up CodeItemAccessors and Compact/StandardDexFile

Change constructor to use a reference to a dex file.

Remove duplicated logic for GetCodeItemSize.

Bug: 63756964
Test: test-art-host
Change-Id: I69af8b93abdf6bdfa4454e16db8f4e75883bca46
9e734c7ab4599d7747a05db0dc73c7b668cb6683 05-Jan-2018 David Sehr <sehr@google.com> Create dex subdirectory

Move all the DexFile related source to a common subdirectory dex/ of
runtime.

Bug: 71361973
Test: make -j 50 test-art-host
Change-Id: I59e984ed660b93e0776556308be3d653722f5223
2c64a837e62c2839521c89060b5bb0dcb237ddda 04-Jan-2018 Vladimir Marko <vmarko@google.com> Change ClassStatus to fit into 4 bits.

In preparation for extending the type check bit string from
24 to 28 bits, rewrite ClassStatus to fit into 4 bits. Also
perform a proper cleanup of the ClassStatus, i.e. change it
to an enum class, remove the "Status" word from enumerator
names, replace "Max" with "Last" in line with other
enumerations and remove aliases from mirror::Class.

Test: m test-art-host-gtest
Test: testrunner.py --host --optimizing
Test: Pixel 2 XL boots.
Test: testrunner.py --target --optimizing
Bug: 64692057
Bug: 65318848
Change-Id: Iec1610ba5dac2c527b36c12819f132e1a77f2d45
6238c8331bf89ce35a377c6475034243a0791f28 04-Jan-2018 Mathieu Chartier <mathieuc@google.com> Remove DexFile direct accesses to CodeItem

Motivation: StandardDexFile and CompactDexFile should be able to a
have different layout for code items.

Also addressed comments from a previous CL.

Bug: 63756964
Test: test-art-host

Change-Id: I5ea7a853b8095f68b4443ded0f599f2ac5efbd3a
73f21d45a41aaad1a02eecdf3bbdbf78ef599d5e 02-Jan-2018 Mathieu Chartier <mathieuc@google.com> Remove CodeItem accessor functions

These are replaced by the accessor helpers.

Bug: 63756964
Test: test-art-host
Test: test/testrunner/testrunner.py --host -j30

Change-Id: Ic93d60b68b684eeb5f69be286b4e15b8f8f97542
808c7a57bb913b13c22884f57cdacd59bf1fdb3f 15-Dec-2017 Mathieu Chartier <mathieuc@google.com> Make CodeItem fields private

Make code item fields private and use accessors. Added a hand full of
friend classes to reduce the size of the change.

Changed default to be nullable and removed CreateNullable.
CreateNullable was a bad API since it defaulted to the unsafe, may
add a CreateNonNullable if it's important for performance.

Motivation:
Have a different layout for code items in cdex.

Bug: 63756964
Test: test-art-host-gtest
Test: test/testrunner/testrunner.py --host
Test: art/tools/run-jdwp-tests.sh '--mode=host' '--variant=X32' --debug

Change-Id: I42bc7435e20358682075cb6de52713b595f95bf9
7314ad133572b52335d7232361e86bd6b8cc5f50 19-Dec-2017 Andreas Gampe <agampe@google.com> Revert "Don't embed the dex code in the oat file if dex is uncompressed."

This reverts commit ae7e83817e546848ef6b2949dd9065b153e14316.

Reason for revert: Broken wrt/ preopted apps and stripping

Bug: 63920015
Bug: 70777774
Change-Id: I39580684d46fa57bd780d2d8bedd65a47d58cf5e
Test: m
(cherry picked from commit e166e67666bf4b23e4ed0a98f5e2bb3cae9cee7d)
e166e67666bf4b23e4ed0a98f5e2bb3cae9cee7d 19-Dec-2017 Andreas Gampe <agampe@google.com> Revert "Don't embed the dex code in the oat file if dex is uncompressed."

This reverts commit ae7e83817e546848ef6b2949dd9065b153e14316.

Reason for revert: Broken wrt/ preopted apps and stripping

Bug: 63920015
Bug: 70777774
Change-Id: I39580684d46fa57bd780d2d8bedd65a47d58cf5e
Test: m
ae7e83817e546848ef6b2949dd9065b153e14316 20-Nov-2017 Nicolas Geoffray <ngeoffray@google.com> Don't embed the dex code in the oat file if dex is uncompressed.

Take uncompressed dex code as a signal that the app wants to
opt into b/63920015.

bug: 63920015
Test: dex2oat_test, 071-dexfile-clean-map

Change-Id: I878e7bb80fc895a2d9aafe81aa7666b86af1f808
666ee3d7c6039c80e75287e311895bd6a9b01e9f 11-Dec-2017 Vladimir Marko <vmarko@google.com> Do not pass DexFile to ClassLinker::Lookup/ResolveType().

The DexFile can be easily retrieved from the DexCache,
so reduce the number of arguments that need to be passed.

Also refactor the code to avoid doing the DexCache lookup
twice and avoid unnecessary read barriers in the initial
DexCache lookup (also for Lookup/ResolveField()).

Test: m test-art-host-gtest
Test: testrunner.py --host --optimizing
Change-Id: Idea9aa42b6a5bade947e93e330b1abdb9d11b2da
890111968fbd3f5ae528d97e42984c12a3dd27bd 11-Dec-2017 Vladimir Marko <vmarko@google.com> Do not pass DexFile to ClassLinker::Lookup/ResolveMethod().

The DexFile can be easily retrieved from the DexCache,
so reduce the number of arguments that need to be passed.

Test: m test-art-host-gtest
Test: testrunner.py --host --optimizing
Change-Id: I2e47280e7cb8b84595130c4abfb5ece18d7f5c75
a64b52deb0c792b8a0d47546edb8a2f8a7816c33 08-Dec-2017 Vladimir Marko <vmarko@google.com> Do not pass DexFile to ClassLinker::Lookup/ResolveString().

The DexFile can be easily retrieved from the DexCache,
so reduce the number of arguments that need to be passed.

Test: m test-art-host-gtest
Test: testrunner.py --host --optimizing
Change-Id: I8c4cec43b31b27de7e4e94374fdd69c6d6ca6c13
9b827ab7e63cf8b24987e75186434348d0dbf4e8 08-Dec-2017 Andreas Gampe <agampe@google.com> ART: Clean up ATRACE use

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

Remove utils/Trace.h include.

Test: m
Change-Id: I3a5123202f4e373074bfe0f7359ee6c60a70352a
e11dd50ac2b5ccbf3b02213b7361f55b1f1a90da 08-Dec-2017 Vladimir Marko <vmarko@google.com> Do not pass DexFile to ClassLinker::ResolveField*().

The DexFile can be easily retrieved from the DexCache,
so reduce the number of arguments that need to be passed.

Test: m test-art-host-gtest
Test: testrunner.py --host --optimizing
Change-Id: I0579db64c63afea789c7c9ad8db81e37c9248e97
28e012a4af2d710e5e5f824709ffd6432e4f549f 07-Dec-2017 Vladimir Marko <vmarko@google.com> Determine HLoadClass/String load kind early.

This helps save memory by avoiding the allocation of
HEnvironment and related objects for AOT references to
boot image strings and classes (kBootImage* load kinds)
and also for JIT references (kJitTableAddress).

Compiling aosp_taimen-userdebug boot image, the most memory
hungry method BatteryStats.dumpLocked() needs
- before:
Used 55105384 bytes of arena memory...
...
UseListNode 10009704
Environment 423248
EnvVRegs 20676560
...
- after:
Used 50559176 bytes of arena memory...
...
UseListNode 8568936
Environment 365680
EnvVRegs 17628704
...

Test: m test-art-host-gtest
Test: testrunner.py --host --optimizing --jit
Bug: 34053922
Change-Id: I68e73a438e6ac8e8908e6fccf53bbeea8a64a077
170331f0e44a0e07fcfe0b5932517e0500f5cd1f 08-Dec-2017 Andreas Gampe <agampe@google.com> ART: Remove base/logging from heap-inl.h

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

Test: m
Change-Id: I917df597cb62c57040c1fb0e0079df4d95e5a658
2d8801f7b932496d5c2606294ff8fdea60e05b30 28-Nov-2017 Nicolas Geoffray <ngeoffray@google.com> Clean some dex2oat options.

Remove dump-passes inherited from Quick days,
and move dump-timings and dump-stats to CompilerStats.

Test: test.py
Change-Id: Ie79be858a141e59dc0b2a87d8cb5a5248a5bc7af
b4c6acbf281c1cf960444e35bcac254a1f77c3ed 10-Nov-2017 Nicolas Geoffray <ngeoffray@google.com> Optimize lookup of quickening data.

Use the debug_info_off_ of CodeItem to store the quickening
offset in the vdex.

Impact:
- Code size almost unchanged (1 word saved per dex file in a vdex)
- GetQuickenedInfoOf doesn't show up in simpleperf during app startup

Test: test.py, run-libcore-tests, run-jdwp-tests
Test: 628-vdex
Change-Id: I15c3151feb58980a4c4d7469ca02728e94d36c07
d278cb48e91bf06f325663a14f026608cc904355 22-Nov-2017 Andreas Gampe <agampe@google.com> ART: Remove implicit boot image error aborts

There are now explicit arguments that induce the same invariants.
Move the configuration to the build system.

This allows certain configurations to disable these checks.

WARNING: Disabling the checks is highly discouraged.

Bug: 69106371
Test: m
Change-Id: I63e915005fcda588b223ec60ef8c9db28d42e577
92f7f3ce3b01f7c7df1c15b81c900e087248093f 31-Oct-2017 Vladimir Marko <vmarko@google.com> Use intrinsic codegen for compiling intrinsic methods.

When compiling an intrinsic method, generate a graph that
invokes the same method and try to compile it. If the call
is actually intrinsified (or simplified to other HIR) and
yields a leaf method, use the result of this compilation
attempt, otherwise compile the actual code or JNI stub.

Note that CodeGenerator::CreateThrowingSlowPathLocations()
actually marks the locations as kNoCall if the throw is not
in a catch block, thus considering some throwing methods
(for example, String.charAt()) as leaf methods.

We would ideally want to use the intrinsic codegen for all
intrinsics that do not generate a slow-path call to the
default implementation. Relying on the leaf method is
suboptimal as we're missing out on methods that do other
types of calls, for example runtime calls. This shall be
fixed in a subsequent CL.

Test: m test-art-host-gtest
Test: testrunner.py --host --optimizing
Bug: 67717501
Change-Id: I640fda7c22d4ff494b5ff77ebec3b7f5f75af652
b7c273cb44fcbdab3c17ec69124fe4bbea2696b1 11-Nov-2017 Mathieu Chartier <mathieuc@google.com> Add ClassDataItemIterator::HasNextMethod

Returns true if there are either static of virtual methods remaining,
changed most places to use this where possible.

Slight behavioral change for duplicate method checking, we not
persist the method index across the static method / virtual method
boundary.

Motivation: Generic cleanup to remove copy paste.

Test: test-art-host
Change-Id: I7a1b507e681b2c40452f8a9913b53a96b181e171
b0a6aeee250945b1d156ebab94053380f2e5a3c5 27-Oct-2017 Vladimir Marko <vmarko@google.com> Record @{Fast,Critical}Native in method's access flags.

Repurpose the old kAccFastNative flag (which wasn't actually
used for some time) and define a new kAccCriticalNative flag
to record the native method's annotation-based kind. This
avoids repeated determination of the kind from GenericJNI.
And making two transitions to runnable and back (using the
ScopedObjectAccess) from GenericJniMethodEnd() for normal
native methods just to determine that we need to transition
to runnable was really weird.

Since the IsFastNative() function now records the presence
of the @FastNative annotation, synchronized @FastNative
method calls now avoid thread state transitions.

When initializing the Runtime without a boot image, the
WellKnowClasses may not yet be initialized, so relax the
DCheckNativeAnnotation() to take that into account.

Also revert
https://android-review.googlesource.com/509715
as the annotation checks are now much faster.

Bug: 65574695
Bug: 35644369
Test: m test-art-host-gtest
Test: testrunner.py --host
Change-Id: I2fc5ba192b9ce710a0e9202977b4f9543e387efe
cac31ad4c43a24a959a4d3652b8b46538bdc8c53 07-Nov-2017 Andreas Gampe <agampe@google.com> ART: Add compiler option for code deduplication

Add --deduplicate-code and --no-deduplicate-code to ease in
experiments with deduplication, e.g., profiling.

Add dex2oat test.

Test: m test-art-host
Change-Id: Ib6c7fe082f43c5f76c8463cc563e2503c9a50480
33bff25bcd7a02d35c54f63740eadb1a4833fc92 01-Nov-2017 Vladimir Marko <vmarko@google.com> ART: Make InstructionSet an enum class and add kLast.

Adding InstructionSet::kLast shall make it easier to encode
the InstructionSet in fewer bits using BitField<>. However,
introducing `kLast` into the `art` namespace is not a good
idea, so we change the InstructionSet to an enum class.
This also uncovered a case of InstructionSet::kNone being
erroneously used instead of vixl32::Condition::None(), so
it's good to remove `kNone` from the `art` namespace.

Test: m test-art-host-gtest
Test: testrunner.py --host --optimizing
Change-Id: I6fa6168dfba4ed6da86d021a69c80224f09997a6
2b2bef245d5b2c6faa2d6f36da14866b2d8f5e4f 27-Oct-2017 Mathieu Chartier <mathieuc@google.com> Refactor DexInstructionIterator

Add a way to get the dex PC for the "for each" use case.

Bug: 67104794
Test: test-art-host
Change-Id: I144c459c9a2a03ec8d56842280338d1f7ce1caf0
26ef34c01ae5db2d3c964844b3717b8974a612c9 01-Nov-2017 Orion Hodson <oth@google.com> ART: Move intrinsics definitions to runtime

Bug: 37538194
Test: art/test.py --host
Change-Id: Ic7adf5f8b14be0e1880ae898a4e199b4416a4d24
f39208f6787928151153795a3cdae28cba964df6 20-Oct-2017 Andreas Gampe <agampe@google.com> ART: Add abort-on-soft-verifier-error

Add an option to abort compilation if any class fails compile-time
verification.

Bug: 65318848
Bug: 67358823
Test: m test-art-host-gtest-dex2oat_test
Change-Id: I5d2a7cd1d2ed048ab39d6f787ecc9eb2f41d3d77
1d2d4ff8570bb88d9d2d4633706fd7f6fb18d75e 24-Sep-2017 Mathieu Chartier <mathieuc@google.com> Add DexInstructionIterator and use it a few places

Motivation:
Want to start abstracting away dex specific functionality to enable
CompactDex. Adding an iterator will enable CompactDex iteration to
work differently than normal dex iteration.

Will eventually replace CodeItemIterator.

Bug: 63756964
Test: test-art-host

Change-Id: I90e67c1a994b7698aaac0523a82816b0a003fbdc
d8dbc8da0e5cc6b5c2176ce2d3877e6194d72c0c 20-Sep-2017 Vladimir Marko <vmarko@google.com> Refactor compiled_method.h .

Move LinkerPatch to compiler/linker/linker_patch.h .
Move SrcMapElem to compiler/debug/src_map_elem.h .
Introduce compiled_method-inl.h to reduce the number
of `#include`s in compiled_method.h .

Test: m test-art-host-gtest
Test: testrunner.py --host
Change-Id: Id211cdf94a63ad265bf4709f1a5e06dffbe30f64
fc8b422c286501346b5b797420fb616aaa5e952a 17-Sep-2017 Mathieu Chartier <mathieuc@google.com> Clean up AtomicDexRefMap

Make ClassReference, TypeReference, and MethodReference extend
DexFileReference. This enables using all of these types as the key
for AtomicDexRefMap.

Test: test-art-host
Bug: 63851220
Bug: 63756964

Change-Id: Ida3c94cadb53272cb5057e5cebc5971c1ab4d366
486dda03900a215650f71a9068759978aa77c699 11-Sep-2017 Nicolas Geoffray <ngeoffray@google.com> Add support for registering classpath classes status.

By doing class unloading after each dex file compilation, we are loosing
away verification done on classpath classes.

This change introduces a new table for keeping around class status of
classpath classes.

Multidex quickening compilation improved by ~5% by not re-verifying classpath
classes.

Bug: 63467744

test: test.py
test: golem successfully compiles FB
Change-Id: I629c0a7d86519bbc516f5e59f7cd92ca6ca842eb
5d3b002b9a244b5dc25fe97fedcb92851d9073f7 31-Aug-2017 Andreas Gampe <agampe@google.com> ART: Change CanAssumeVerified to GetPreviousClassState

Return any stored class state instead of a bool to allow more
recognized states in the future.

Bug: 63467744
Bug: 65318848
Test: m test-art-host
Change-Id: Id097273a41e09ee77c8d53377ad9beb09104a944
c5e0d3fb4bce1490dcdb65b1d858b1c955bf71c5 22-Aug-2017 Orion Hodson <oth@google.com> compiler_driver: treat java/lang/invoke as others

Reverts commit e3eae5e41502c85ba0b4ef88340c10bb53795a47.

Removes exemption for java/lang/invoke/* from verification
DCHECK. No longer required with invoke-polymorphic support.

Bug: 32496585
Test: art/test.py --host -j32
Change-Id: Ie73274b723febfcffb687e879a80ffdb680f9491
12fadcd25e30c832b055d0ce37ad11e85a1829c2 03-Aug-2017 Andreas Gampe <agampe@google.com> ART: Rerun verifier in verbose mode on boot cp failure

When we fail to verify a boot classpath class during boot image
compilation, re-run the verifier in verbose mode to print soft failures
before aborting.

Bug: 64290614
Test: m test-art-host
Test: manual
Change-Id: I1c875ee4a5a73f80b7f8b75be35ed885bc0bf427
adc74df1e2bccda3a45e3bf1cce720fb36a53f87 09-Aug-2017 Mathieu Chartier <mathieuc@google.com> Support class unloading in dex2oat for quicken multidex

Support class unloading for the quicken compilation filter. This will
be enabled in a follow up CL.

Added a test that compares with and without unloading. The way that
it tests this is by adding an output app image. Having an app image
disables the unloading. This test also covers that app images don't
change the odex (currently).

Added a test for the assumed verified logic.

Cherry pick includes the test fix.

Bug: 63467744
Test: test-art-host
Test: test/testrunner/testrunner.py --interpreter --host -j40

(cherry-picked from commit 0b1c341d2d89a483142cd14bdeb4650ab00184f1)

Change-Id: If70e31d3a15579dc75fd40bfef186e0124568c87
9e050df94df5c6736e1e24705194f62fbc119114 09-Aug-2017 Mathieu Chartier <mathieuc@google.com> Revert "Revert "Support class unloading in dex2oat for quicken multidex""

Bug: 63467744
Test: test-art-host

This reverts commit 6921d90a241f0307ac25120f8f976744d4a57706.

Change-Id: If70e31d3a15579dc75fd40bfef186e0124568c87
6921d90a241f0307ac25120f8f976744d4a57706 09-Aug-2017 Richard Uhler <ruhler@google.com> Revert "Support class unloading in dex2oat for quicken multidex"

This reverts commit 0b1c341d2d89a483142cd14bdeb4650ab00184f1.

New test Dex2oatDeterminism.UnloadCompile fails on bots gtest-debug-gc and friends.

Change-Id: Ib101fc4390d90f88fe017d8482775d5e975f2ccb
0b1c341d2d89a483142cd14bdeb4650ab00184f1 15-Jul-2017 Mathieu Chartier <mathieuc@google.com> Support class unloading in dex2oat for quicken multidex

Support class unloading for the quicken compilation filter. This will
be enabled in a follow up CL.

Added a test that compares with and without unloading. The way that
it tests this is by adding an output app image. Having an app image
disables the unloading. This test also covers that app images don't
change the odex (currently).

Added a test for the assumed verified logic.

Bug: 63467744
Test: test-art-host
Test: test/testrunner/testrunner.py --interpreter --host -j40
Change-Id: I1e8a862c6f089c06c58aa0c846797e4c24bd072c
921cb1d8677f4e9e20b978d42f50d4b49bd229d5 15-Jul-2017 Mathieu Chartier <mathieuc@google.com> Use class unloading in dex2oat for verify and extract

Unload the main classloader in between each dex file compilation to
reduce RAM. This frees the whole java heap and associated linear
allocs. This is only used for quickening since filters that do
compilation may require loaded classes in the compiler and oat
writer.

This reduces dex2oat peak PSS for compiling a large app from 196MB
to 135MB.

Only works for verify and extract since the current approach is
incompatible with oat writer patching. b/63911263

Added a verification override that reads the compiled class status
to avoid ever verifying classes that were quickened (since this
is not supported and causes failures).

There is still some duplicated verification for some class with
superclasses in other dex files.

Support for quicken will be added in a follow up CL.

(cherry-picked from commit 72041a0dcb5b7c133b79a1d6783a23039f2136bd)
Merged-In: Id0e4f84eb5db91d6143f752b498f4832a5b25b6e

Bug: 63467744
Bug: 64473133
Test: test-art-host
Test: test/testrunner/testrunner.py --interpreter --host -j40
Change-Id: Id0e4f84eb5db91d6143f752b498f4832a5b25b6e
6a2ed4fb6e9a25f66d14c2075e9743b8d1198620 04-Aug-2017 Jeff Hao <jeffhao@google.com> Fix issue where classes that fail verification have kStatusNotReady.

Classes that failed verification at compile time were not getting the
status kStatusRetryVerificationAtRuntime. This is because
GetCompiledClass would return false for anything that wasn't verified,
making it look like the compiler had not touched the class at all, when
it should have failed verification.

Test: mm test-art-host
Bug: 64392002

(cherry picked from commit f1aa26599d866abe3c31ac959b042fc32d7fb581)

Change-Id: I41dbde3c0d0cbf2ff463a364c405ef7284e6aed9
f1aa26599d866abe3c31ac959b042fc32d7fb581 04-Aug-2017 Jeff Hao <jeffhao@google.com> Fix issue where classes that fail verification have kStatusNotReady.

Classes that failed verification at compile time were not getting the
status kStatusRetryVerificationAtRuntime. This is because
GetCompiledClass would return false for anything that wasn't verified,
making it look like the compiler had not touched the class at all, when
it should have failed verification.

Test: mm test-art-host
Bug: 64392002

Change-Id: I9687bcb53c60c1fb0a2df2f642ce9102cb488822
abadf024efdc632f663d7fb503cd277b3f65fca2 03-Aug-2017 Nicolas Geoffray <ngeoffray@google.com> Revert "Support clinit for app image during compilation"

Breaks on bots.

This reverts commit 50ce4414a6154ee2d9eeaa27237d80b685e5acf1.

Change-Id: I39d856dc76b55788b6775ff2269eb8570742c6ff
50ce4414a6154ee2d9eeaa27237d80b685e5acf1 21-Jul-2017 Chang Xing <chxing@google.com> Support clinit for app image during compilation

Enabled compiler driver to start initialization process for classes with
static class initializers if debuggable flag is not setted because this
might change the behaviour of interpreter (although invisible to user),
e.g. the memory heap at startup will contains initialization results.

Updated two testcases to reflect the change of heap memory before
classes are initialized.

Enabled testcase 660-clinit to test whether class initializers are
executed.

This CL have to be submitted after /c/432328, /c/432154, /c/433242 and
/c/433342 because without that four this will break the build. Besides,
the other four CL will be tested in this CL.

Test: make test-art-host -j64
Change-Id: Ia25b9e18bdcd0fa3619be0058d459651f3b9a492
63a2a09406cf5675fa275b3e5502719aac9a1abc 01-Aug-2017 Mathieu Chartier <mathieuc@google.com> Fix verifier deps determinism

Previously, the unverified_classes were not deterministic since
they were represented as a vector. This CL moves it to a set and adds
a regression test.

Bug: 63467744
Test: test-art-host

(cherry picked from commit bf755fefbfcfbb2677a519c12efe7890f3879854)

Change-Id: I4dce9f95fc1e56e383e8c617e1703ce360c67d5b
bf755fefbfcfbb2677a519c12efe7890f3879854 01-Aug-2017 Mathieu Chartier <mathieuc@google.com> Fix verifier deps determinism

Previously, the unverified_classes were not deterministic since
they were represented as a vector. This CL moves it to a set and adds
a regression test.

Bug: 63467744
Test: test-art-host

Change-Id: I891254a927228b1dc4d8e1c65d5e99ae58b854ea
e5071cc58a3cdea4a88257be3c8fd4d012a64c74 12-Jun-2017 Vladimir Marko <vmarko@google.com> ART: Change method lookup to be more consistent to JLS and the RI.

The method lookup for different invoke types was previously
widely different and didn't work well with the dex cache
method array where we have only a single slot for each
MethodId. The new behavior is to perform the same lookup for
all cases, distinguishing only between interface and
non-interface referencing class, and to further align the
behavior with the JLS and the RI. Where the JLS conflicts
with the RI, we follow the JLS semantics.

The new lookup for class methods first searches the methods
declared in the superclass chain (ignoring "copied" methods)
and only then looks in the "copied" methods. If the search
in the superclass chain finds a method that has not been
inherited (i.e. either a private method or a package-access
method where one of the classes in the chain does not belong
to the same package, see JLS 8.4.8), we still search the
"copied" methods as there may actually be a method inherited
from an interface. This follows the JLS semantics where
inherited methods are included in the search (JLS 15.12.2.1)
but conflicts with the RI where the private or
package-access method takes precedence over methods
inherited from interfaces.

Note that this search can find an accessible method that is
not inherited by the qualifying type, either for a package
access method when the referrer is in the same package but
the qualifying type is in another package, or for a private
method where the referrer is in the same class but the
qualifying type is actually a subclass. For the moment we
allow such calls and we shall consider whether to throw
an IncompatibleClassChangeError in this situation in future
to comply with JLS 15.12.4.3.

The new lookup for interface methods searches the interface
class, then all the superinterfaces and then the
java.lang.Object class, see implicitly declared methods in
interfaces, JLS 9.2. The search for the maximally-specific
non-abstract superinterface method is not yet implemented,
but the difference should be difficult to observe as the
usual subsequent call to FindVirtualMethodForInterface()
should yield the same result for any matching method.

The new test 162-method-idx-clash exposes several cases
where we previously completely messed up due to the effects
of the DexCache, or where we were out of line with the RI.
It also tests a case where the JLS and the RI disagree and
we follow the JLS.

Test: art/test/run-test --host --jvm 162-method-resolution
Test: m test-art-host-gtest
Test: testrunner.py --host
Test: testrunner.py --host --interp-ac
Test: Nexus 6P boots.
Test: testrunner.py --target
Bug: 62855082
Bug: 30627598

(cherry picked from commit ba118827465d12177f3996e50133960087b1c916)

Change-Id: Ic73e4adf02b5cd66b5a22a3b619dc781357db14c
72041a0dcb5b7c133b79a1d6783a23039f2136bd 15-Jul-2017 Mathieu Chartier <mathieuc@google.com> Use class unloading in dex2oat for verify and extract

Unload the main classloader in between each dex file compilation to
reduce RAM. This frees the whole java heap and associated linear
allocs. This is only used for quickening since filters that do
compilation may require loaded classes in the compiler and oat
writer.

This reduces dex2oat peak PSS for compiling a large app from 196MB
to 135MB.

Only works for verify and extract since the current approach is
incompatible with oat writer patching. b/63911263

Added a verification override that reads the compiled class status
to avoid ever verifying classes that were quickened (since this
is not supported and causes failures).

There is still some duplicated verification for some class with
superclasses in other dex files.

Support for quicken will be added in a follow up CL.

Bug: 63467744
Test: test-art-host
Test: test/testrunner/testrunner.py --interpreter --host -j40
Change-Id: Id0e4f84eb5db91d6143f752b498f4832a5b25b6e
fdfb4d4c20620d8ef725bcba5c8bdaba9849b6f7 27-Jul-2017 Andreas Gampe <agampe@google.com> ART: Modify --abort-on-hard-verifier-error

Add --no-abort-on-hard-verifier-error to turn off the behavior.

Use FATAL_WITHOUT_ABORT and abort() instead of LOG(FATAL) to avoid
multiple printouts of stacks. Just shutting down thread pools still
leads to three redundant stack dumps.

Bug: 36902714
Test: m
Change-Id: I35fef23fb36567b0d1deb7f16c2a2b43c3af47e8
b45528c1f1b83ca8c970f439b54fbfcfda6908ea 27-Jul-2017 Vladimir Marko <vmarko@google.com> ART: Refactor retrieval of types through ArtMethod.

Split Get*() functions that take a "bool resolve"
argument into Lookup*() and Resolve*() functions.

Test: m test-art-host-gtest
Test: testrunner.py --host
Change-Id: I0b7eaa1fadc2ffa8c0168203790467f91a126963
605fe24d07062a038c8332a4d98f47052e9cee6a 21-Jul-2017 Chang Xing <chxing@google.com> Implemented Nested Transaction

Transaction can be created recursively and every transaction knows which
class it is created for.

The goal of implementing nested transaction is to let every class
initialization (especially execution of class initializer) associates
with one transaction which provides the ability to track whether field
accesses are valid. To achieve this goal, we implemented a subclass for
ClassLinker called AotClassLinker, which will be instantiated instead of
ClassLinker under AOT compiler.

All invocations of InitializeClass happens at AOT compiler will be
wrapped with creating and destorying transactions.

Transactions will be paused when rollbacking, otherwise the memory will
not be rollbacked properly.

The use the transaction is changed and all usage are updated,
corresponding with native tests mentioning transaction, including
transaction_test and unstarted_runtime_test.

The validation rules will be implemented and explained in another CL.

Test: make test-art-host -j64

Change-Id: If53d3ee3231c337a9ea917f5b885c173917765de
5a906fcc111ffc07d9fd1e7265e8b4a89609f00e 27-Jul-2017 Chang Xing <chxing@google.com> Add strict flag in transaction

Add a flag named strict_ indicating whether we are compiling app images,
which need more strict constraints to control <clinit>s' behavours.

When the transaction is marked as strict mode, behaviour changes
including nested transactions, field access validation, memory
consumption limit and time out for <clinit> at compile time.

Test: make test-art-host -j64

Change-Id: I7cc0eea161803ad0d7763725d4deaeee21858054
726736e913785f87a211fa5862057b421c56da85 25-Jul-2017 Mathieu Chartier <mathieuc@google.com> Allow failure in RecordClassStatus for uses-library classes

The problem was that recursive initialization attempts to initialize
classes in used libraries for the app image case. This meant we
attempted to add an oat class status for the uses-library classes.

Adding a regression test is infeasible since run-test doesn't support
uses-library.

Test: test-art-host
Bug: 63994775

(cherry picked from commit 010f5ccfb666994c8c65d5b4f8a15208da3aee39)

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

Let clang-format reorder the header includes.

Derived with:

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

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

Test: mmma art
Change-Id: Ia963a8ce3ce5f96b5e78acd587e26908c7a70d02
010f5ccfb666994c8c65d5b4f8a15208da3aee39 25-Jul-2017 Mathieu Chartier <mathieuc@google.com> Allow failure in RecordClassStatus for uses-library classes

The problem was that recursive initialization attempts to initialize
classes in used libraries for the app image case. This meant we
attempted to add an oat class status for the uses-library classes.

Adding a regression test is infeasible since run-test doesn't support
uses-library.

Test: test-art-host
Bug: 63994775
Change-Id: If229d5deb3a0e5662839b0120c4c6d52bdcdcc57
cade5c3c75588da6d873df727acdaf3378a66efa 21-Jul-2017 Chang Xing <chxing@google.com> Track class initializing in transaction

Add a field and a corresponding constructor to transaction which keeps
track of the class that the transaction is initializing.

To implement constraints for <clinit> behaviors, the transaction needs
to know which class it is initializing.

Test: make test-art-host -j64
Change-Id: I87b3fcb3ef15914c79c6687ec8a87058265eaead
16d1dd86dca33520b44d9802695e19d3b658af3e 21-Jul-2017 Chang Xing <chxing@google.com> Move transaction creation to runtime

Move the transaction creation to runtime instead of passing a pointer to
runtime when EnterTransactionMode. Because later there will be more
places to create transaction so this makes the code cleaner and more
compact.

Test: make test-art-host -j64
Change-Id: I971edf3110eb6634b6e0f7f56256be04517a5281
ba118827465d12177f3996e50133960087b1c916 12-Jun-2017 Vladimir Marko <vmarko@google.com> ART: Change method lookup to be more consistent to JLS and the RI.

The method lookup for different invoke types was previously
widely different and didn't work well with the dex cache
method array where we have only a single slot for each
MethodId. The new behavior is to perform the same lookup for
all cases, distinguishing only between interface and
non-interface referencing class, and to further align the
behavior with the JLS and the RI. Where the JLS conflicts
with the RI, we follow the JLS semantics.

The new lookup for class methods first searches the methods
declared in the superclass chain (ignoring "copied" methods)
and only then looks in the "copied" methods. If the search
in the superclass chain finds a method that has not been
inherited (i.e. either a private method or a package-access
method where one of the classes in the chain does not belong
to the same package, see JLS 8.4.8), we still search the
"copied" methods as there may actually be a method inherited
from an interface. This follows the JLS semantics where
inherited methods are included in the search (JLS 15.12.2.1)
but conflicts with the RI where the private or
package-access method takes precedence over methods
inherited from interfaces.

Note that this search can find an accessible method that is
not inherited by the qualifying type, either for a package
access method when the referrer is in the same package but
the qualifying type is in another package, or for a private
method where the referrer is in the same class but the
qualifying type is actually a subclass. For the moment we
allow such calls and we shall consider whether to throw
an IncompatibleClassChangeError in this situation in future
to comply with JLS 15.12.4.3.

The new lookup for interface methods searches the interface
class, then all the superinterfaces and then the
java.lang.Object class, see implicitly declared methods in
interfaces, JLS 9.2. The search for the maximally-specific
non-abstract superinterface method is not yet implemented,
but the difference should be difficult to observe as the
usual subsequent call to FindVirtualMethodForInterface()
should yield the same result for any matching method.

The new test 162-method-idx-clash exposes several cases
where we previously completely messed up due to the effects
of the DexCache, or where we were out of line with the RI.
It also tests a case where the JLS and the RI disagree and
we follow the JLS.

Test: art/test/run-test --host --jvm 162-method-resolution
Test: m test-art-host-gtest
Test: testrunner.py --host
Test: testrunner.py --host --interp-ac
Test: Nexus 6P boots.
Test: testrunner.py --target
Bug: 62855082
Bug: 30627598
Change-Id: If450c8cff2751369011d649c25d28a482a2c61a3
1a088d440a3fac4e477a11af68adae9dcd3afd00 18-Jul-2017 Mathieu Chartier <mathieuc@google.com> Use AtomicDexRefMap for compiled classes

Changed compiled_classes_ to use an AtomicDexRefMap and deleted
the lock since it was no longer necessary.

This map is more compact than a SafeMap. RAM numbers for verify
filter on a large app (host arm compile):

Maximum resident set size (kbytes): 250012->243472
native alloc: 19284128B->13951600B

Bug: 6346774
Test: test-art-host
Change-Id: Iace66945b49433f353603a713593c53be6893cc5
e431e2758d62cf56f7f347f5a8c9d79e41b6dcd7 19-Jul-2017 Steven Moreland <smoreland@google.com> art: use proper nativehelper headers

libnativeheader exports headers under nativeheader. These were
available before incorrectly as global headers in order to give
access to jni.h.

Test: modules using art find headers
Bug: 63762847
Change-Id: I5c820d677e94e07b2859e78610bc997fe51b41dc
93764b8ee58d54118904b8f4473628451e568893 17-Jul-2017 Mathieu Chartier <mathieuc@google.com> Generalize atomic_method_ref_map to support dex references

Generalize atomic method ref map to support dex references instead
of only method references.

The goal is to use this in a future CL to replace compiled_classes_.

Test: test-art-host

Change-Id: Ic6d1e619584f790eea68f5160fa0fcd664524cd7
0733dc87518d2c8fc1ba2196c9f5cc9729de7c20 17-Jul-2017 Mathieu Chartier <mathieuc@google.com> Avoid creating verification_results_ unnecessarily

For compiler filters that don't quicken or compile, avoid creating
the verification results. This avoids creating some arrays that
were using a few MB of RAM in some cases.

For a large app verify compile:
Maximum resident set size (kbytes): 258948 -> 254300

Bug: 63467744
Test: test-art-host

Change-Id: I1d0536b2a6a5c301396641371915394cf4c0e5f3
0cb172874481f736c6b7c491dd621166cc25561b 12-Jul-2017 Jeff Hao <jeffhao@google.com> Do superclass validation at compile time and log with new class status.

Tries to perform superclass validation for classes that are resolved,
but not initialized at runtime. If successful, saves the result in the
oat file with a new class status. At runtime, the superclass validation
can be skipped during class initialization, saving some time and
reducing string accesses.

Results show savings of 50kB PSS in maps on startup, with slight
decrease in startup time.

Maps (average of 100 runs)
Before: dex 9941.3 odex 15159.8 total 25101.1 launch 908
After: dex 9897.4 odex 15155.7 total 25053.1 launch 906.6

Bug: 63456114
Test: mm test-art-host
Change-Id: If67a4a49d61781b6d561c26118d7e0c6b9cc0d6f
88b74b6a4dbbe0b5b75ef1738833e5b064e85d4c 17-Jul-2017 Mathieu Chartier <mathieuc@google.com> Avoid creating compiled_methods_ array unnecessarily

For compiler filters that don't quicken or compile, avoid creating
the compiled method arrays to save RAM.

For a dex2oat of a large app with verify filter -j4 on the host:
Reduce native alloc from 39MB to 35MB
Maximum resident set size (kbytes): 287592k -> 282696k

Bug: 63467744
Test: test-art-host
Change-Id: Ib84fd9337dc7f5f1e32017bf2c392d1d3328fba8
70f689dce49f2d1466dc98df9aee5a880956b45c 09-Jun-2017 Chang Xing <chxing@google.com> Add an init encoded fields threshold to compiler

Add a check for the number of encoded fields when initializing app
images and fail the initialization if too much encoded fields are
presented. This helps against the adversary applications and reduce
compiling time on test case 056.

Bug: 62337922
Test: art-host-test -j64
Change-Id: I9f24fbe5ada473ec415459a36b0c22d2f504af62
e602b1cde4e422b9ff508b8b3dbfb31cadd826b7 30-Jun-2017 Chang Xing <chxing@google.com> Fix boot classes init when compiling app image

Classes resident in boot library should not be initialized and stored in
app image anyway while compiling app image.

Fixed by checking the location of classes in compiler driver when
initializing classes and is compiling app image.

The InitializeDependencies is advanced which makes TryInitialize become
the only entrypoint for app image, and since boot image doesn't need
this function, the behavior for compiling boot image should stay the
same.

Bug: 62715577
Test: not covered now, will be fixed and test by another CL.
Change-Id: I8e683e6b14f1402dba8ef5c4b0f5fa936a343d8c
ba17dbd5f23d6f6acf3fb60b6dd65dc34bd833de 28-Jun-2017 Chang Xing <chxing@google.com> Revert "Revert "Fixed Literal String intern mismatch.""

This reverts commit f7ab8348b88b7ce63c5fa112f5a71756da541763.

Test: make test-ar-host -j64

Change-Id: I688b7c7905c8be575959fa78ad594ac1c782af9a
e17cf243978ca7f5356e746ee460f0fcf04e04a6 19-Jun-2017 Mathieu Chartier <mathieuc@google.com> Add field/method skipping helper functions to DexFile

Specifically added SkipStaticFields, SkipInstanceFields,
SkipAllFields, SkipStaticMethods, and SkipVirtualMethods.

Also applied the helpers to the code base.

Test: test-art-host
Change-Id: Idda77f9a6e2564c2e588d2bbe11cc320063fdb32
bbe3a5efcdfb2fb15a4e5f724cc323ae0ada5111 14-Jun-2017 Mathieu Chartier <mathieuc@google.com> Refactor some profiling info functions

Deleted profile_compilation_info-inl.h

Added a new helper class MethodHotness to reduce the number of
required getters for reading method hotness, startup, and post
startup booleans.

Test: test-art-host
Bug: 62040831

Change-Id: I799a38e2bea6177ba5816c54524f4ccacedba772
1cfea7af6f38cd06393fed3e466701869ce8b2c3 24-May-2017 Nicolas Geoffray <ngeoffray@google.com> Code cleanup around vdex.

1) Handle the vdex in dex2oat instead of compiler_driver
2) CHECK instead of DCHECK that we don't dexlayout with vdex.

Test: test.py
Change-Id: Idf7be59bb25708181e391d17128480659ac697e5
7a8bcfd197ccd755761df0d46f83491fadd3eb43 13-Jun-2017 Mathieu Chartier <mathieuc@google.com> Fix some indentation errors in compiler driver

Test: m
Change-Id: I8d64f6c7bdb5ccd82d916831cd0e3c3273097197
17498e59a35b3802f77a6a3338468e6d18c5046b 13-Jun-2017 Mathieu Chartier <mathieuc@google.com> Avoid calling InitializeDependencies for non image case

The previous CL was incorrect since IsImageClass returns true for
the no image case.

Test: test-art-host
Bug: 62402160
Change-Id: Id75170eeaae5dfa675c113aa04b1a10b1276fab1
dabeb3adf974d32ff1553af356d20e0a4abfd1f1 13-Jun-2017 Mathieu Chartier <mathieuc@google.com> Correctly set oat class status after initializing

The previous CL had a bug where it would not set the oat class status
for initialized classes that had run the class initializer for the
boot image case.

Aims to fix random dex2oat crashes during boot image creation.

Bug: 62402160
Test: test-art-host

Change-Id: Ia1814fc91ec71c9556eb37699a63be3b09ff6188
fd37f1dafbc1c9763b8ea30855120d2c22062732 13-Jun-2017 Mathieu Chartier <mathieuc@google.com> Revert "Revert "Fixed installation time regression when compile.""

Bug: 62337922

This reverts commit 54c32b1f3362129d79e512581d4932aec92425eb.

Change-Id: Ica942c9e70b63e2c4893f87c15757a519a0c4d73
f1dd69a8fd6bc330e5ff6e89eaaf3affbc7c6f31 09-Jun-2017 Mathieu Chartier <mathieuc@google.com> Revert "Revert "Fully support static encoded fields.""

Bug: 62337922

This reverts commit 84c8432726299e8884215874d83958f55d5b2cd7.

Test: format issue only

Change-Id: Idf6f39a50b6c3baa3cc0a2147724a5815dd6d9b4
84c8432726299e8884215874d83958f55d5b2cd7 07-Jun-2017 Nicolas Geoffray <ngeoffray@google.com> Revert "Fully support static encoded fields."

bug: 62337922

This reverts commit e71d6878449907b07add9f7a634a0e836911b0d1.

Change-Id: If1916cbbab4da69d69990f8cae3889a8d182b331
f7ab8348b88b7ce63c5fa112f5a71756da541763 07-Jun-2017 Nicolas Geoffray <ngeoffray@google.com> Revert "Fixed Literal String intern mismatch."

bug: 62337922

This reverts commit 762ef842d78b6f8a76f2b119504f075728540077.

Change-Id: Idfa3a9271e3dfb92dc849f68b97c8eeeb2732abc
54c32b1f3362129d79e512581d4932aec92425eb 07-Jun-2017 Nicolas Geoffray <ngeoffray@google.com> Revert "Fixed installation time regression when compile."

bug: 62337922

This reverts commit 8f987427cedef5d07783254ac16632ce02fd8f75.

Change-Id: Ieea7921dfd7f589054e3b1f1d50078ede09bee4b
7b135c80fedea16844892527555b144c64651a65 05-Jun-2017 Mathieu Chartier <mathieuc@google.com> Only compile hot methods

Instead of compiling all startup + hot methods, we now only compile
hot methods. However, the current logic still marks all startup
methods that have a counter greater than hot_method_sample_threshold_
as hot methods. Since hot-startup-method-samples is currently 1,
there is no current behavioral change.

The goal is to increase hot_method_sample_threshold_ in a follow up
CL.

Renamed startup-method-samples to hot-startup-method-samples to
better reflect the new behavior of the option.

Test: test-art-host
Bug: 36457259

Change-Id: I820bdcd4426769d76131b08a8b41f3b7eebfbc23
8f987427cedef5d07783254ac16632ce02fd8f75 05-Jun-2017 Chang Xing <chxing@google.com> Fixed installation time regression when compile.

Fixed the installation time regression problems happens at compilation
time caused by the recursive initialization which blocked the fast-fail
test for classes that can't be initialized during installation.

Solved by ruling out this situation. Check for app image before
resolving the dependencies, fall back to ordinary initialize process
if profile does not exist.

Bug: 62296843
Test: test-art-host -j64
Change-Id: I773406f11fd5dced8da5f0fe228b45d95eca936b
ea650f3bc4f54eb2c647cf0f7134398ef5038792 24-May-2017 Mathieu Chartier <mathieuc@google.com> Move profiles to use bitmaps for startup methods

This CL enables changes like compiling only hot methods while still
doing layout for hot and startup methods. The bitmaps are also a
bit smaller for post-launch use cases.

No change in compilation strategy yet.

Fixed some bugs in dexlayout test like using a profile with the wrong
dex location. This meant the second invocation of dexlayout didn't
have any profile data.

Added profman support for dump-classes-and-methods,
create-profile-from, and related test.

Profile sizes (bytes) post launch:
Gmail: 7290 -> 6136
Maps: 22896 -> 18984
Music: 8582 -> 7050
YouTube: 16733 -> 14592

Test: test-art-host

Bug: 62040831

Change-Id: I9915b81a2ff2c47464acbbdeb55ce30a33d5483f
762ef842d78b6f8a76f2b119504f075728540077 26-May-2017 Chang Xing <chxing@google.com> Fixed Literal String intern mismatch.

Literal Strings in app images are interned into local intern tables
which causes mismatch with the runtime intern table, especially when
a string is loaded from app images twice. Now when .art is loaded, a
visitor go through all classes and their fields to intern every string
literal found again.

Test case 596 is updated to test the string intern functioanlity.

Test on devices Nexus 5X, fixing strings takes 5.4 ms on GoogleMap
during startup.

Bug: 62224799

Test: test-art-host -j64

Change-Id: I2e1d44a79db1ae5f9aec80f228128201d1d838d8
f0446e9c785027b89a63f625b38f07c919bc6748 16-May-2017 Andreas Gampe <agampe@google.com> ART: Misc header cleanups

Move/remove arena allocator includes.

Test: mma art
Change-Id: If998569d96c791fc3d4aa93ca95672a4d4b5782c
e71d6878449907b07add9f7a634a0e836911b0d1 06-May-2017 Chang Xing <chxing@google.com> Fully support static encoded fields.

Intialization runs under one single thread. Class Status stored at Oat
Classes are set to uninitialized (maybe verified) when that class contains
static encoded fields.

Resolve all types mentioned in classes before initializing under
transaction mode, since ResolveType doesn't support transaction.

Test: make test-art-host
Change-Id: I6c9df8a2cdd43043837eb3b438ed7a89ecdaf64d
bb84610d2de3c12b0e0cdc724df29479b9501461 12-May-2017 Andreas Gampe <agampe@google.com> ART: Remove CompiledClass

Replace by direct storage of the class status, and modify accessor
to return boolean value of whether the item exits. Reduces RAM
requirements and allocations for dex2oat.

Test: m test-art-host
Change-Id: I6a80ac3d644c7fd0da167996ab991b6d2796a458
bbf04c6bf5e184ade52880b07faba1335f13a983 28-Apr-2017 Nicolas Geoffray <ngeoffray@google.com> Honor --force-determinism for vdex.

b/37442966
Test: build

(cherry picked from commit 46847395470e414cd2aa1c6ea13e9a3d08e2b46b)

Change-Id: I6b72b9d0d69f42a4f1ca46403647a172bb2c6e84
cab655799dc0c04d42b00642a813438efe46acf5 21-Apr-2017 Nicolas Geoffray <ngeoffray@google.com> Make vdex and dexlayout compatible.

Unquicken the vdex before dexlayout, to keep the dex integrity.

bug: 37558732
Test: run-test with speed-profile

(cherry picked from commit 4e868fa7b8c47600695ff92deeb373674956a67d)

Change-Id: I57ddabb79ff49d01df80bed4e3e53ba8fdb5346e
a10ac2ac733a9dc07962cfea2502605141e61953 21-Apr-2017 Nicolas Geoffray <ngeoffray@google.com> Rename and obsolete compiler filter names.

ART side of the change.

bug:34715556
Test: test-art-host, jdwp, libcore

(cherry picked from commit 49cda06d5bf003f588ba7839bbf89d606237dfa7)

Change-Id: I85126e5035f0f6fc15aa84d41af5f1d6e25a5f55
46847395470e414cd2aa1c6ea13e9a3d08e2b46b 28-Apr-2017 Nicolas Geoffray <ngeoffray@google.com> Honor --force-determinism for vdex.

b/37442966
Test: build

Change-Id: I220450ad204cf41ed24c2c98cdfc35aa9041a35e
4e868fa7b8c47600695ff92deeb373674956a67d 21-Apr-2017 Nicolas Geoffray <ngeoffray@google.com> Make vdex and dexlayout compatible.

Unquicken the vdex before dexlayout, to keep the dex integrity.

bug: 37558732
Test: run-test with speed-profile

Change-Id: Ifcd5c2e4378ccb0df0a66d07f68df31d94b83220
76c1965179bdf34ed9d0dded046c7ad6f277de3f 24-Apr-2017 Andreas Gampe <agampe@google.com> ART: More header cleanup - method_verifier.h

Move enumerations to own header. Move the compiler interface (of what
the compiler can tolerate) into its own header. Replace or remove
method_verifier.h where possible.

Test: mmma art
Change-Id: I075fcb10b02b6c1c760daad31cb18eaa42067b6d
(cherry picked from commit 6d7abbd2324f544c6b6da42bb6b9b531df0ce3cd)
6d7abbd2324f544c6b6da42bb6b9b531df0ce3cd 24-Apr-2017 Andreas Gampe <agampe@google.com> ART: More header cleanup - method_verifier.h

Move enumerations to own header. Move the compiler interface (of what
the compiler can tolerate) into its own header. Replace or remove
method_verifier.h where possible.

Test: mmma art
Change-Id: I075fcb10b02b6c1c760daad31cb18eaa42067b6d
c6ea7d00ad069a2736f603daa3d8eaa9a1f8ea11 02-Feb-2017 Andreas Gampe <agampe@google.com> ART: Clean up art_method.h

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

Test: source build/envsetup.sh && lunch aosp_angler-userdebug && mmma art
Test: source build/envsetup.sh && lunch aosp_mips64-userdebug && mmma art
Change-Id: I8f60f1160c2a702fdf3598149dae38f6fa6bc851
49cda06d5bf003f588ba7839bbf89d606237dfa7 21-Apr-2017 Nicolas Geoffray <ngeoffray@google.com> Rename and obsolete compiler filter names.

ART side of the change.

bug:34715556
test: test-art-host, jdwp, libcore
Change-Id: I3a73ae4af2d602431150c8ecfceaddb9ba519cee
fbc9041636dcb1b8567317daee4cc687205683b8 19-Apr-2017 Nicolas Geoffray <ngeoffray@google.com> Record class status after verification.

The class status was recorded when doing vdex verification, or
any compilation (quickening or optimizing), but not when only doing
verification.

bug:37446669
Test:compiler_driver_test

(cherry picked from commit c7da1d61ba0fc38950f303813d4ba8c2d6d05c7f)

Change-Id: I8f111273bab1fa5a6211f7d0ed07b520479b67a3
c7da1d61ba0fc38950f303813d4ba8c2d6d05c7f 19-Apr-2017 Nicolas Geoffray <ngeoffray@google.com> Record class status after verification.

The class status was recorded when doing vdex verification, or
any compilation (quickening or optimizing), but not when only doing
verification.

bug:37446669
Test:compiler_driver_test
Change-Id: Id027c7a9776ed651de570a0f3417c969c8cff9cd
1a4bc7f084fae3ebcf4eac5addce14a06cd1c668 27-Mar-2017 Andreas Gampe <agampe@google.com> ART: Remove unused DexToDex level.

There is only "skip" and "optimize." We no longer have a required
tier, as constructor fencing is now elision-based.

Bug: 36653594
Test: m test-art-host
Change-Id: Ide874a581fc5f887d020b3d32507e3973e7fd9a4
8d6768d47b66a688d35399d524ad5a5450e9d9d4 14-Mar-2017 Vladimir Marko <vmarko@google.com> Revert^6 "Hash-based dex cache type array."

Fixed ImageWriter to write class table also if it contains
only boot class loader classes. Added a regression test and
added extra checks for debug-build to verify that dex cache
types from app image are also in the class table. Removed
some unnecessary debug output.

Test: 158-app-image-class-table
Bug: 34839984
Bug: 30627598
Bug: 34659969

This reverts commit 0b66d6174bf1f6023f9d36dda8538490b79c2e9f.

Change-Id: I6a747904940c6ebc297f4946feef99dc0adf930c
0b66d6174bf1f6023f9d36dda8538490b79c2e9f 13-Mar-2017 Vladimir Marko <vmarko@google.com> Revert^5 "Hash-based dex cache type array."

For app images, ImageWriter does not add boot image
classes to the app image class table even though it
keeps them in the dex caches. The reason for that is
unknown, the code looks OK.

Bug: 34839984
Bug: 30627598
Bug: 34659969

Also reverts "Improve debugging output for a crash."

This reverts commits
bfb80d25eaeb7a604d5dd25a370e3869e96a33ab,
8dd56fcb3196f466ecaffd445397cb11ef85f89f.

Test: testrunner.py --host
Change-Id: Ic8db128207c07588c7f11563208ae1e85c8b0e84
97fa9928c07d3e0ee631235e9619fb0f8949ed7a 09-Mar-2017 Nicolas Geoffray <ngeoffray@google.com> Do not allow input-vdex with dexlayout.

input-vdex and dexlayout are incompatible with each other.

bug: 36084905
bug: 36076104
bug: 36059948
bug: 35872504

Test: device boots, vdex works on OTA, input-vdex is not passed
for speed-profile.

Change-Id: I630c90acf0a8f49f50b7909e2dec995dd4a4d13f
7cc3ae5705416bd8fc4b7096904e2871aa761e73 07-Mar-2017 Nicolas Geoffray <ngeoffray@google.com> Return the right value in VerifyClass.

We used to return kNoFailure when a class was already processed.
But it could have had soft failures.

Also remove IsCompileTimeVerified to avoid future confusions and
introduce ShouldVerifyAtRuntime.

Add some more checks to make sure we record the right things in
the vdex file.

bug: 33845394
test: verifier_deps_test test-art-host
Change-Id: Iff11a96e825c85db416083413761981515f405b7
7bf90484a6f3774875291e506136345f0b488976 03-Mar-2017 Andreas Gampe <agampe@google.com> ART: Resolve <clinit> strings in compiler driver

Resolve strings for <clinit> in classes that fail initialization.
This will move the data from the zygote heap into the image heap,
creating clean memory.

Increases the image size by XXX. However, at the same time decreases
the zygote heap by the same amount.

Bug: 34956610
Test: m
Test: m test-art-host
Test: Device boots
Change-Id: I5be41da8424d5de65c02a2aed1ac4d6113741876
9e7078b3e5794f1b65f7e75ad110551906bf5f0d 02-Mar-2017 Andreas Gampe <agampe@google.com> ART: Resolve static field strings in compiler driver

Resolved strings for static final fields in classes that fail
initialization. This will move the data from the zygote heap into
the image heap, creating clean memory.

Increases the image size by ~100K. However, at the same time decreases
the zygote heap by the same amount.

Bug: 34956610
Test: m
Test: m test-art-host
Test: Device boots
Change-Id: Ifa4aac0209f2364488b164b04daa9539821bc12b
97ab5e3b79d1cf6034d3a2a1c6e6b2176d4e2af5 22-Feb-2017 Mathieu Chartier <mathieuc@google.com> Check for null profile in ShouldCompileBasedOnProfile

It may be null if speed-profile is passed to dex2oat without a
profile. In this case, compile nothing.

Test: mm test-art-host-gtest-dex2oat_test -j32

Bug: 35665292
Bug: 35420088

Change-Id: I2da3258492d1f6b86bba6b4bb5a86d378f0a9227
bfb80d25eaeb7a604d5dd25a370e3869e96a33ab 14-Feb-2017 Vladimir Marko <vmarko@google.com> Revert^4 "Hash-based dex cache type array."

Added extra output to the abort message to collect more data
when we hit the crash. Added extra check when loading an app
image to verify that the class table isn't already broken.

Test: testrunner.py --host
Bug: 34839984
Bug: 30627598
Bug: 34659969

This reverts commit 5812e20ff7cbc8efa0b8d7486ada2f58840a6ad5.

Change-Id: I9bb442a184c236dcb75b3e42a095f39cd6bee59d
d0af56cdb1eaebea403e382257bdc14d7b7fdaa4 17-Feb-2017 Mathieu Chartier <mathieuc@google.com> Make dex2oat support profiles passed to non profile filters

Using a non profile filter with an input profile should compile
everything but generate an app image and optimize layout based on
the profile.

Change UseProfileGuidedCompilation to use the profile arguments.
Using profile arguments instead of being based on the compiler
filter lets us do full speed compile and layout based on profile.

Fix ShouldCompileBasedOnProfile to use the compiler filter instead
of the existence of a profile.

Fixed gtests.

Test: test-art-host

Bug: 34927277

Change-Id: I325a10d2072ed427bb32f96e4efa54cf81e94ad3
23a625c4c0ca13154f27bcf00928b0631e2a1f58 06-Feb-2017 Nicolas Geoffray <ngeoffray@google.com> Update verify-profile logic.

To start measuring OTA time improvements correctly, return
verify-profile as non-profile filter of verify-profile.

bug:34715556
Test: device boots, interpret-only is not used
Change-Id: I098a23d6dc958530df4eb94209d07d735576e0eb
fa4333dcb481e564f54726b4e6f8153612df835e 14-Feb-2017 Andreas Gampe <agampe@google.com> ART: Add operator == and != with nullptr to Handle

Get it in line with ObjPtr and prettify our code.

Test: m
Change-Id: I1322e2a9bc7a85d7f2441034a19bf4d807b81a0e
5812e20ff7cbc8efa0b8d7486ada2f58840a6ad5 14-Feb-2017 Mathieu Chartier <mathieuc@google.com> Revert^3 "Hash-based dex cache type array."

Assert failing for "earchbox:search":
F zygote64: class_linker.cc:4612] Check failed: handle_scope_iface.Get() != nullptr

Test: m test-art-host
Bug: 34839984
Bug: 30627598
Bug: 34659969

This reverts commit 85c0f2ac03417f5125bc2ff1dab8109859c67d5c.

Change-Id: I39846c20295af5875b0f945be7035c73ded23135
85c0f2ac03417f5125bc2ff1dab8109859c67d5c 02-Feb-2017 Vladimir Marko <vmarko@google.com> Revert^2 "Hash-based dex cache type array."

The reason for the revert was fixed by
https://android-review.googlesource.com/332666 .
We now enable clearing dex cache types in test 155 from that
CL. Also avoid an unnecessary store in LookupResolvedTypes()
and prevent verifier from messing up the dex cache types.

Test: m test-art-host
Bug: 34839984
Bug: 30627598
Bug: 34659969

This reverts commit d16363a93053de0f32252c7897d839a46aff14ae.

Change-Id: Ie8603cfa772e78e648d005b0b6eae59062ae729d
cd556b003adbb53739d4b3f43135e6a0ae69509a 03-Feb-2017 Vladimir Marko <vmarko@google.com> Fix dex cache resolved types and class table mismatch.

Record class table in ClassLinker::DexCacheData and use
it in DexCache.setResolvedType() to store the type also
in the initiating loader's class table if the dex file
has been registered.

Also throw InternalError when trying to register the
same DexFile with multiple class loaders. (Different
DexFile instances referencing the same file are OK.)

Test: 155-java-set-resolved-type
Test: m test-art-host
Bug: 30627598
Bug: 34193123
Bug: 34839984
Change-Id: Ia48acb300337c45880ea1459d2d32789546d67f4
d16363a93053de0f32252c7897d839a46aff14ae 01-Feb-2017 Vladimir Marko <vmarko@google.com> Revert "Hash-based dex cache type array."

Reverting to work around some programs crashing with
Check failed: handle_scope_iface.Get() != nullptr.
though the reason for the failure not yet understood.

Test: m test-art-host
Bug: 34839984
Bug: 30627598
Bug: 34659969
Bug: 30419309

This reverts commit ec7862283dd49f5a58d0ac45960ce27c2f7671b8.

Change-Id: Ifded663633082f1e59e5b6ff2e026dc559bd6b82
ec7862283dd49f5a58d0ac45960ce27c2f7671b8 20-Dec-2016 Vladimir Marko <vmarko@google.com> Hash-based dex cache type array.

Test: m test-art-host (Interpreter, Optimizing, JIT)
Test: m test-art-target on Nexus 6P (Interpreter, Optimizing, JIT)
Test: Nexus 6P boots
Test: m valgrind-test-art-host
Bug: 30627598
Bug: 34659969
Bug: 30419309
Change-Id: Ic00eda89e58088a3573fc9ec0ad04c0e69e161d1
e40dd38c6ccd3c55138ed6ef216dec261150fd5e 26-Jan-2017 Alex Light <allight@google.com> Re-enable tests 934 & 935

There were two issues causing problems with these tests.

1) The loading of classes could occur prior to the transformer being
enabled. This was fixed by putting the classes under test into a
different ClassLoader and disabling app-images.

2) DexToDex compilation was devirtualizing some calls meaning that
reordering the methods was causing incorrect dispatch.

This reverts commit 50cc0cceb5ca0abd4fff2cb3467ea74e7590cb10.
This reverts commit e9f36b7cb42348ef5c4eb3c88bd3cfdd56390a3e.
This reverts commit 1e7e96e4a66f668255a1683b837863228489faf9.

Test: ART_TEST_INTERPRETER=true \
ART_TEST_JIT=true \
mma -j40 test-art-host

Test: ART_TEST_INTERPRETER_ACCESS_CHECKS=true \
ART_TEST_RUN_TEST_NO_DEX2OAT=true \
ART_TEST_RUN_TEST_RELOCATE_NO_PATCHOAT=true \
ART_TEST_RUN_TEST_NO_RELOCATE=true \
mma -j40 test-art-host-run-test-934-load-transform \
test-art-host-run-test-935-non-retransformable

Change-Id: Ia600ba37d45a5f9489b03c7f4d143849c887b8a7
3eba863e41d531340392d9ec64e17963ac898d81 25-Jan-2017 Nicolas Geoffray <ngeoffray@google.com> Make verify-profile not look at the profile.

It doesn't work well with vdex. In follow-up CLs,
I'll just remove/rename the filter.

For the record, compiling sheets on an angler:
verify-profile: dex2oat took 5.383s (6.672s cpu)
vdex: dex2oat took 1.686s (1.562s cpu)

bug: 34715556
bug: 34691602
bug: 34691854

Test: test-art-host
Change-Id: I286637a3d7ebe1b18985e96845b0b8c4f67a1a39
0a27fd0e1177c58a344e7321fcae716c94c127eb 25-Jan-2017 Nicolas Geoffray <ngeoffray@google.com> Preserve verification invariant after compile-time verification.

After the verification step of the compiler, all classes in the
dex file that are being compiled should be either erroneous,
verified, or verify at runtime.

vdex used to break that invariant by only setting the status of
verified classes.

bug: 34691602
bug: 34691854

test: 634-vdex-duplicate, which breaks for the newly added
EnsureVerifiedOrVerifyAtRuntime check.

Change-Id: I67bd57880ed3238525f36fde484e36ca535ae5d5
72ab684871f870aead76b23cb67deb046107b380 20-Jan-2017 Vladimir Marko <vmarko@google.com> Add class status for resolved erroneous classes.

Split the old ambiguous status mirror::Class::kStatusError
into kStatusErrorUnresolved and kStatusErrorResolved. Once
a class has been resolved, IsResolved() shall return true
even if the class later becomes erroneous. Allow returning
erroneous class from ClassLinker::EnsureResolved() if it has
been previously resolved. This allows consistent behavior
for retrieving classes, immune to multi-threaded races and
multi-dex weirdness. It also allows JVMTI to properly report
"prepared" (i.e. resolved) classes that are also erroneous.

The new behavior is consistent with the RI.

Add regression tests to 008-exceptions for inconsistent
behavior for multi-dex retrieval of erroneous resolved class
(wrapping or not wrapping the old exception based on which
dex file is used for lookup) and for a CHECK(IsResolved())
crash in ClassLinker::LoadSuperAndInterfaces() (without any
tests for similar checks that could have previously failed
only due to extremely unlikely race conditions; these should
now also be fixed).

Inconsistency still remains for class verification as shown
by the new exceptionsForSuperClassInitFailure() test in
008-exceptions, where interpreter and Optimizing still
cause different exceptions to be thrown.

Note: This is partially changing behavior implemented for
bug 28787733. Since we allow the class loader to retrieve an
erroneous resolved class, the ExceptionInInitializerError is
not thrown at all from VMClassLoader_findLoadedClass(), so
there is nothing to wrap in ClassNotFoundException.

Test: m test-art-host
Bug: 30627598
Bug: 28787733
Change-Id: I86cdca00f35a0d6221d2559e3026ac0428a3613c
5e8d5f01b0fe87a6c649bd3a9f1534228b93423d 18-Oct-2016 Roland Levillain <rpl@google.com> Fix some typos in ART.

Test: m build-art-host
Test: m cpplint-art
Change-Id: Ifc6ce3d0d645c4a8dca72dd483fc03fc05077130
942fd3130254d8276cbfe8e6201825e9c49e9b2c 16-Jan-2017 Vladimir Marko <vmarko@google.com> Reduce using ArtMethod's dex_cache_resolved_types_.

Avoid using the ArtMethod's dex cache type array shortcut
in runtime, preparing for its removal. We do not completely
remove the shortcut yet because it is still used by array
allocation entrypoints.

Fix ArgArray::BuildArgArrayFromObjectArray in reflection.cc
to not ask for the parameter type to be resolved. It should
have been previously resolved when retrieving the Method.

Also partially revert
https://android-review.googlesource.com/310717
because it relied on the removed AIOOBE check in the removed
ArtMethod::GetDexCacheResolvedType(). The removed check was
simply defensive but it could not be triggered without some
memory corruption.

Test: m test-art-host
Bug: 30627598
Change-Id: Ic45a5ff8c66b79429e440cbc08d67bf22a083682
7498105ec7497bae2ba9f1a697da9efa0c979654 16-Jan-2017 Nicolas Geoffray <ngeoffray@google.com> Handle verify-profile and bootclasspath classes in vdex.

Two problems:
1) An apk might define a class twice, or define a class that
is already in the bootclasspath, or define a class that
in the future happens to be in the bootclasspath.
2) verify-profile does not make classes that were not verified
as verify-at-runtime for vdex.

Fixes:
1) Check that the resolved class is part of the dex file that
we are currently looking into. If not, don't update its
verification status.
2) Make unverified classes as such when they are not in the profile.

bug:34108532
Test: 634-vdex-duplicate
Change-Id: I77c5e417c16c91af257b88b6456d07c0e4c2ca93
60ca949cc39936b1f18853922d0dcafdda3b9322 20-Dec-2016 Nicolas Geoffray <ngeoffray@google.com> Optimize OatWriter when we don't compile any method.

- Don't write any quickening info.
- Don't visit methods.

Saves ~20% of compilation times.

Test: test-art-host

Change-Id: Ib18fd06c0ca42308e1d81401de0ee3e6297de0ce
c1a42cf3873be202c8c0ca3c4e67500b470ab075 18-Dec-2016 Nicolas Geoffray <ngeoffray@google.com> Remove soon to be obsolete call kinds for direct calls.

And remove CompilerDriver::GetCodeAndMethodForDirectCall in
preparation of removing non-PIC prebuild and non-PIC on-device
boot image compilation.

Test: test-art-host test-art-target
bug:33192586
Change-Id: Ic48e3e8b9d7605dd0e66f31d458a182198ba9578
b1677e2ff07d7cea3cf7ee91d7df202975c11836 16-Dec-2016 Nicolas Geoffray <ngeoffray@google.com> Don't unquicken RETURN_VOID_NO_BARRIER with vdex.

The quickening of the RETURN_VOID instruction is based on
local information (no final fields) that doesn't get affected
by a boot image update.

Test: test-art-host, verifier_deps_test
bug:30937355

Change-Id: I12b22d7fcda6dc681a32ff752c3871f6e84f19a1
d27097a6c9459d38e7c9f92a1fcfa77352a9e07d 16-Dec-2016 Nicolas Geoffray <ngeoffray@google.com> Clear exception if FindClass fails.

Test: verifier_deps_test.
bug: 30937355
Change-Id: I9916ec00010de012939462d4f30147e8b64fe279
ade72d6e03e2ca49a8d2691f35fe6e37d88a196d 15-Dec-2016 Nicolas Geoffray <ngeoffray@google.com> Do not resolve types with vdex.

We don't need to, and it's time expensive.

test: test-art-host, 2x faster vdex compilation time.
bug: 30937355

Change-Id: Ic04ebfee9172ed676fbb38e6901615ed3473352a
19f6c696bbb7a17d8ac521b316c40f9cbef32151 01-Dec-2016 Alexey Frunze <Alexey.Frunze@imgtec.com> MIPS64: Improve method invocation.

Improvements include:
- support for all kinds of method loads and static/direct calls
- 32-bit and 64-bit literals for the above and future work
- shorter instruction sequences for recursive static/direct calls
Also:
- include the MIPS64 dinsu instruction (missed earlier) and minor
clean-up in the disassembler
- properly prefix constant names with 'k' in relative patcher tests

Test: test-art-host-gtest
Test: booted MIPS64 (with 2nd arch MIPS32R6) in QEMU
Test: "make -j1 ART_TEST_DEFAULT_COMPILER=false ART_TEST_OPTIMIZING=true
ART_TEST_INTERPRETER=false ART_TEST_JIT=false
ART_TEST_PIC_TEST=true test-art-target-run-test64"

Change-Id: I19876fa5316b68531af7dfddfce90d2068433116
19a4d374738da4dc668a078f92dbe887ff9f00d9 08-Dec-2016 Vladimir Marko <vmarko@google.com> Clean up Class::GetDirectInterface().

Once the `klass` has been resolved, this function should not
need to resolve interface types anymore. Drop the type
resolution from this function and pass the Class as ObjPtr<>
instead of Handle<>. Make callers that expect non-null
result DCHECK() that assumption. For the callers that may
actually need to resolve these interface classes, introduce
a new function ResolveDirectInterface().

Also improve ObjPtr<> constructors and assignment operator
to improve overload resolution. For example, if we have
foo(ObjPtr<T1>) and foo(ObjPtr<T2>), calling foo(.) with
a T1* would have previously been ambiguous even if T1 is
not a base of T2.

Test: m test-art-host
Change-Id: Iff44a7285f68f0af4507fc9ba37343865422fe84
51c17faee9ff0b93914ae2d308cfa24f0bc71d0a 25-Nov-2016 Nicolas Geoffray <ngeoffray@google.com> Create empty VerifiedMethod after vdex verification.

The compiler and quicken require the existence of a
VerifiedMethod for compiling a method.

This fixes the regression of not doing any compilation when
passed --input-vdex.

Test: 629-vdex-speed

Change-Id: Ie65578eadd09099df1c1a403d96c15e5da78a901
acab8d485bd9c007b991f482ed01264d527b63d6 23-Nov-2016 Mathieu Chartier <mathieuc@google.com> Move compiled methods to use AtomicMethodRefMap

Use AtomicMethodRefMap to avoid locking and map costs.

Native RAM usage for interpret-only compile FB:
71270192B -> 64117168B

Perf:
CompilerDriver::GetCompiledMethod: 0.88% -> 0.04%
Mutex::ExclusiveLock: 1.55% -> 1.05%

Bug: 32641252

Test: test-art-host-run-test

Change-Id: I146e7bf2f3328b4fa84f2cc19d591f4da82dccfc
8a0128a5ca0784f6d2b4ca27907e8967a74bc4c5 28-Nov-2016 Andreas Gampe <agampe@google.com> ART: Add dex::StringIndex

Add abstraction for uint32_t string index.

Test: m test-art-host
Change-Id: I917c2881702fe3df112c713f06980f2278ced7ed
b0bbe8e5c28c061bf4ef4086d3bbb2c5c5266979 19-Nov-2016 Nicolas Geoffray <ngeoffray@google.com> Use input-vdex-fd, or input-vdex in dex2oat.

input-vdex-fd is used by installd
input-vdex is used by run-tests, and (will be used by) go/lem

This change copies the contents of the passed vdex to the new one,
unquicken the new vdex, and run the fast verification on the new
vdex.

bug:30937355
Test: device boots, apps get updated faster with vdex
Test: set TEST_VDEX to true in run-test-jar, run all tests
Test: 628-vdex

Change-Id: Idfbac4de411cebcf8ea7a6af7a417d7c7908dd72
340dafabc8e88378e395cda9027cf17726910e91 18-Nov-2016 Nicolas Geoffray <ngeoffray@google.com> Use a per-thread VerifierDeps.

Avoid lock contention on a singleton VerifierDeps by allocating
temporary per-thread VerifierDeps that get merged after verification.

This saves around ~35% compile-times on interpret-only.

Only the creation of extra strings is guarded by a lock, for simplicity.

Test: test-art-host, test-art-target
bug: 32641252
bug: 30937355

Change-Id: I11a2367da882b58e39afa7b42cba2e74a209b75d
a5b09a67034e57a6e10231dd4bd92f4cb50b824c 18-Nov-2016 Andreas Gampe <agampe@google.com> ART: Add dex::TypeIndex

Add abstraction for uint16_t type index.

Test: m test-art-host
Change-Id: I47708741c7c579cbbe59ab723c1e31c5fe71f83a
54b5855192abee8cb612fce3c34b7562ddf42522 17-Nov-2016 Jeff Hao <jeffhao@google.com> Change offline profile to store type_idx of classes.

Changed from storing class_def_idx to type_idx. Allows dexlayout to move
class defs without affecting the profile.

Test: mm test-art-host

Change-Id: I8a040adf0f5f47a1592e18aeb55edde01cb3e1ed
4c481a4245aebe6821914237249f11d03e687bf9 03-Nov-2016 Andreas Gampe <agampe@google.com> ART: Make some variables references

Avoid copying values.

Bug: 32619234
Test: m
Change-Id: I86bc206d6f6fccdf730c62c60317a7a4ae26c11b
6bb7f1b60f4b6b2214457d19d66d2b7b50685feb 03-Nov-2016 Nicolas Geoffray <ngeoffray@google.com> Integrate VerifierDeps in compiler driver.

If a VerifierDeps is given, try fast verify. Otherwise create
a new VerifierDeps and do the full verification.

test: test-art-host, verifier_deps_test
bug: 30937355
Change-Id: Ifb030d7b5232c95872164f601057a56ab96038e1
e3eae5e41502c85ba0b4ef88340c10bb53795a47 27-Oct-2016 Narayan Kamath <narayan@google.com> compiler_driver: loosen DCHECK for java/lang/invoke classes.

Verifier support for invoke-polymorphic hasn't been implemented
yet, so boot classpath classes that use it will not be verified
at compile time. This change will be reverted once verifier support
is implemented.

This change is a hack.

Test: make test-art-host
Bug: 32496585
Bug: 30550796

Change-Id: Id8fcb3fd0d5ddd09f1c80f751a5f96364b137855
0802518a6a5af8182131eb3fe66bf58dd77f9fe2 25-Oct-2016 Nicolas Geoffray <ngeoffray@google.com> Save the non-verified classes in the VerifierDeps.

We will need that information when taking an OTA to make sure
the same set of classes needs to be verified at runtime.

Currently, the vdex file will contain a list of unverified
classes. We could alternatively encode a bit vector of the size
of the type_id array, but the few experiments I did show that
the bit vector is actually larger. We can refine this later.

bug: 30937355
test: m test-art-host
test: verifier_deps_test.cc

Change-Id: I2670e4fd2e54ee7a148246baa705fda3a56617ff
28357fab628bd9b91749988b554977398caf9963 19-Oct-2016 Mathieu Chartier <mathieuc@google.com> Move most of class linker to ObjPtr

Return values are still mirror pointer. Fix some failing asserts in
compiler driver and tests.

Bug: 31113334

Test: test-art-host

Change-Id: I4450bf9dfb2541749496b8388616e8aae8488919
709b070044354d9f47641f273edacaeeb0240ab7 13-Oct-2016 David Sehr <sehr@google.com> Remove mirror:: and ArtMethod deps in utils.{h,cc}

The latest chapter in the ongoing saga of attempting to dump a DEX
file without having to start a whole runtime instance. This episode
finds us removing references to ArtMethod/ArtField/mirror.

One aspect of this change that I would like to call out specfically
is that the utils versions of the "Pretty*" functions all were written
to accept nullptr as an argument. I have split these functions up as
follows:
1) an instance method, such as PrettyClass that obviously requires
this != nullptr.
2) a static method, that behaves the same way as the util method, but
calls the instance method if p != nullptr.
This requires using a full class qualifier for the static methods,
which isn't exactly beautiful. I have tried to remove as many cases
as possible where it was clear p != nullptr.

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

Fixed possible moving GC bugs in ClinitImageUpdate class.

Bug: 31113334

Test: test-art-host
Change-Id: I0bf6578553d58b944aaa17665f1350bdf5ed15ec
571d2340d889dee2a7a809c3c56293fe06d2b52d 12-Oct-2016 Nicolas Geoffray <ngeoffray@google.com> Revert "Revert "Remove dead code from compiler driver.""

This reverts commit 38f250fd3cb36fac27bad7cac8eefacdf8a6e41e.

Change-Id: I491891c9108a0646145553241aa04a9cbba7d29b
5d9c6d6f654a3803269cee0c637c3385704bff93 04-Oct-2016 Nicolas Geoffray <ngeoffray@google.com> Fix build breakage.

Revert did not apply cleanly.

test: make test-art-host
Change-Id: Id94d377d19dc80237951ad40fd5e01f8fec67a47
38f250fd3cb36fac27bad7cac8eefacdf8a6e41e 04-Oct-2016 Nicolas Geoffray <ngeoffray@google.com> Revert "Remove dead code from compiler driver."

This reverts commit 44b3da25191052acc18528d8ade9cf3038505180.

Change-Id: I0cf049ed967bcaf8dfd89fc88288d992c63a4939
aad75c6d5bfab2dc8e30fc99fafe8cd2dc8b74d8 03-Oct-2016 Vladimir Marko <vmarko@google.com> Revert "Revert "Store resolved Strings for AOT code in .bss.""

Fixed oat_test to keep dex files alive. Fixed mips build.
Rewritten the .bss GC root visiting and added write barrier
to the artResolveStringFromCode().

Test: build aosp_mips-eng
Test: m ART_DEFAULT_GC_TYPE=SS test-art-target-host-gtest-oat_test
Test: Run ART test suite on host and Nexus 9.
Bug: 20323084
Bug: 30627598

This reverts commit 5f926055cb88089d8ca27243f35a9dfd89d981f0.

Change-Id: I07fa2278d82b8eb64964c9a4b66cb93726ccda6b
44b3da25191052acc18528d8ade9cf3038505180 03-Oct-2016 Nicolas Geoffray <ngeoffray@google.com> Remove dead code from compiler driver.

test: m test-art-host
Change-Id: Ie4b6a4c371fff6c9c213d8d6604eb09a5e71d595
b20f1feff8b1125ecf1f7d4537ed4d6eb002973f 03-Oct-2016 Nicolas Geoffray <ngeoffray@google.com> Address revew comments for change Ia653d2c72df13889dc85dd8c84997582c034ea4b.

test: test-art-host

Change-Id: I6ff79ce29efa5ede41c24d5fcca8c6b17cdd6cb0
5f926055cb88089d8ca27243f35a9dfd89d981f0 30-Sep-2016 Vladimir Marko <vmarko@google.com> Revert "Store resolved Strings for AOT code in .bss."

There are some issues with oat_test64 on host and aosp_mips-eng.

Also reverts "compiler_driver: Fix build."

Bug: 20323084
Bug: 30627598

This reverts commit 63dccbbefef3014c99c22748d18befcc7bcb3b41.
This reverts commit 04a44135ace10123f059373691594ae0f270a8a4.

Change-Id: I568ba3e58cf103987fdd63c8a21521010a9f27c4
04a44135ace10123f059373691594ae0f270a8a4 30-Sep-2016 Narayan Kamath <narayan@google.com> compiler_driver: Fix build.

Test: make-art-host
Change-Id: I94e164ed245caea60fe26872a943ea5e14aa8860
762869dee6e0eadab5be1c606792d6693bbabf4e 15-Jul-2016 Nicolas Geoffray <ngeoffray@google.com> Simplify our intrinsic recognizer.

- Use the modifiers for storing the intrinsic kind.
- Delete dex_file_method_inliner and its associated map.

This work was also motivated by the fact that the inline
method analyzer leaks intrinsic tables, and even worse, might re-use
a table from one dex file to another unrelated dex file in the presence
of class unloading and the unlikely event of the dex files getting
the same address.

test: m test-art-host m test-art-target

Change-Id: Ia653d2c72df13889dc85dd8c84997582c034ea4b
0795f23920ee9aabf28e45c63cd592dcccf00216 28-Sep-2016 Mathieu Chartier <mathieuc@google.com> Clean up ScopedThreadStateChange to use ObjPtr

Also fixed inclusion of -inl.h files in .h files by adding
scoped_object_access-inl.h and scoped_fast_natvie_object_access-inl.h

Changed AddLocalReference / Decode to use ObjPtr.

Changed libartbenchmark to be debug to avoid linkage errors.

Bug: 31113334

Test: test-art-host

Change-Id: I4d2e160483a29d21e1e0e440585ed328b9811483
63dccbbefef3014c99c22748d18befcc7bcb3b41 21-Sep-2016 Vladimir Marko <vmarko@google.com> Store resolved Strings for AOT code in .bss.

And do some related refactorings.

Bug: 20323084
Bug: 30627598
Test: Run ART test suite including gcstress on host and Nexus 9.
Test: Run ART test suite including gcstress with baker CC on host and Nexus 9.
Test: Build aosp_mips64-eng.
Change-Id: I1b12c1570fee8e5da490b47f231050142afcbd1e
8d41c086c41b2169ea9e21c6bfeee19984c79c6a 28-Sep-2016 Goran Jakovljevic <Goran.Jakovljevic@imgtec.com> Revert "jni: Punt to generic JNI for mips"

This reverts commit 9aa9fa243198fc1f48eb7ae5e3f363b71915c36f.

Change-Id: Iae5c19581eb2d925baae7175ca0d4c0d832c9450
da079bba8403733cac9bb7415b038ffd77e62403 26-Sep-2016 Nicolas Geoffray <ngeoffray@google.com> Cleanup String.<init> handling.

Move everything to one place (currently well_known_classes.cc, but
no strong preference) and define a macro to easily handle the list
of affected methods.

test: m test-art-host
test: m test-art-target
Change-Id: Ib8372d130d5458516a1f1ae31014afc76037fc34
9aa9fa243198fc1f48eb7ae5e3f363b71915c36f 26-Sep-2016 Igor Murashkin <iam@google.com> jni: Punt to generic JNI for mips

Preopting dex the bootclasspath causes dex2oat to crash for MIPS builds.
Disable JNI compiler for MIPS until it supports @CriticalNative.

Test: lunch aosp_mips-eng && make && make test-art-host
Bug: 31743474
Change-Id: I802f1e61863c4bb54a1bd884a4c9ce9a75bab62b
5e4e11e171f90d9a3ea178fc8e72aac909de55d5 22-Sep-2016 Nicolas Geoffray <ngeoffray@google.com> Clean-up sharpening and compiler driver.

Remove dependency on compiler driver for sharpening
and dex2dex (the methods called on the compiler driver were
doing unnecessary work), and remove the now unused methods
in compiler driver.

Also remove test that is now invalid, as sharpening always
succeeds.

test: m test-art-host m test-art-target
Change-Id: I54e91c6839bd5b0b86182f2f43ba5d2c112ef908
d9c90373d640a5e08072cf469c372e24a8c0fc35 14-Sep-2016 David Brazdil <dbrazdil@google.com> Move ArrayRef to runtime/base

Will be used in upcoming CLs regarding VDEX and VerifierDeps.

Test: m test-art-host
Change-Id: I68e611a4a52246c2bdf45eab7c61f3212908afd4
268764da8022cafa5661c5b514eaa343c5257e57 13-Sep-2016 Mathieu Chartier <mathieuc@google.com> Make ScopedAssertNoThreadSuspension no overhead for non-debug

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

Also cleaned up callers.

Bug: 31458474
Change-Id: I5a1621a5435476504d22266cc01a9bf26aab7568
5fd66d0546805f0d86ec3365762c00b8dd3415f5 13-Sep-2016 Andreas Gampe <agampe@google.com> ART: Remove LogSeverity NONE

Remove non-standard severity, and instead use a new enum to
configure verifier logging.

Partially reverts commit 7fe30233d32a872f5349e921dba65bd767ad994b.

Bug: 31338270
Test: m test-art-host
Change-Id: If52ee23c4902fbf2dabe7b232f6742448764ff8c
367f3dd32454858b8b25d87feb8f6599d3b4c9dd 02-Sep-2016 Igor Murashkin <iam@google.com> jni: Add @CriticalNative optimization to speed up JNI transitions

Change-Id: I963059ac3a72dd8e6a867596c356d7062deb6da7
15fc729ca5cd268a69bc1aa93f7d31c883dc310f 02-Sep-2016 David Brazdil <dbrazdil@google.com> verifier: Pass ClassDef as a reference

Tiny refactor. ClassDef should never be null, yet we pass it as
a pointer, check it is not null and dereference everywhere.

Change-Id: Id89a1f599f1289d3cc00846306a890e06e438f88
bdf7f1c3ab65ccb70f62db5ab31dba060632d458 31-Aug-2016 Andreas Gampe <agampe@google.com> ART: SHARED_REQUIRES to REQUIRES_SHARED

This coincides with the actual attribute name and upstream usage.
Preparation for deferring to libbase.

Test: m
Test: m test-art-host
Change-Id: Ia8986b5dfd926ba772bf00b0a35eaf83596d8518
ba6b679bd34449ec56508966706ca1b8d5e7cb17 15-Aug-2016 Artem Serov <artem.serov@linaro.org> ARM: Purge Arm32Assembler.

Use Thumb2Assembler always. This originated from finding out that
the JNI tests are run using the Arm32Assembler however in real
world Thumb2Assembler is used for JNI. Therefore Arm32Assembler
code is dead except its own tests and the illegitimate use in
JNI tests.

Change-Id: I9ca6b83582bf97149a46690518ccb9312b1a3b68
9d4b6da934934c322536ee3309b63ce402740f49 29-Jul-2016 Igor Murashkin <iam@google.com> jni: Fast path for @FastNative annotated java methods

Adds a faster path for java methods annotated with
dalvik.annotation.optimization.FastNative .

Intended to replace usage of fast JNI (registering with "!(FOO)BAR" descriptors).

Performance Microbenchmark Results (Angler):
* Regular JNI cost in nanoseconds: 115
* Fast JNI cost in nanoseconds: 60
* @FastNative cost in nanoseconds: 36

Summary: Up to 67% faster (vs fast jni) JNI transition cost

Change-Id: Ic23823ae0f232270c068ec999fd89aa993894b0e
d190d1ff1933cdb6b07c48179f4933ae720b9bc2 05-Aug-2016 Wojciech Staszkiewicz <staszkiewicz@google.com> Remove kRestrictCompilationFiltersToImage

Removed compiler driver kRestrictCompilationFiltersToImage flag,
impact is in the noise.

Change-Id: I50be7a201f677fa0cb6db38d9b5f039754e1f98c
542451cc546779f5c67840e105c51205a1b0a8fd 26-Jul-2016 Andreas Gampe <agampe@google.com> ART: Convert pointer size to enum

Move away from size_t to dedicated enum (class).

Bug: 30373134
Bug: 30419309
Test: m test-art-host
Change-Id: Id453c330f1065012e7d4f9fc24ac477cc9bb9269
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
a62cb9bb6cb2278cb41ab0664191623e178c6a4f 30-Jun-2016 Artem Udovichenko <artem.u@samsung.com> Revert "Revert "Optimize IMT""

This reverts commit 88f288e3564d79d87c0cd8bb831ec5a791ba4861.

Change-Id: I49605d53692cbec1e2622e23ff2893fc51ed4115
e3fb245fbdb5e91cf8a9750504df40bd629e0080 11-May-2016 Alexey Frunze <Alexey.Frunze@imgtec.com> MIPS32: Improve method invocation

Improvements include:
- CodeGeneratorMIPS::GenerateStaticOrDirectCall() supports:
- MethodLoadKind::kDirectAddressWithFixup (via literals)
- CodePtrLocation::kCallDirectWithFixup (via literals)
- MethodLoadKind::kDexCachePcRelative
- 32-bit literals to support the above (not ready for general-
purpose applications yet because RA is not saved in leaf
methods, but is clobbered on MIPS32R2 when simulating
PC-relative addressing (MIPS32R6 is OK because it has
PC-relative addressing with the lwpc instruction))
- shorter instruction sequences for recursive static/direct
calls

Tested:
- test-art-host-gtest
- test-art-target-gtest and test-art-target-run-test-optimizing on:
- MIPS32R2 QEMU
- CI20 board
- MIPS32R6 (2nd arch) QEMU

Change-Id: Id5b137ad32d5590487fd154c9a01d3b3e7e044ff
88f288e3564d79d87c0cd8bb831ec5a791ba4861 29-Jun-2016 Nicolas Geoffray <ngeoffray@google.com> Revert "Optimize IMT"

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

This reverts commit badee9820fcf5dca5f8c46c3215ae1779ee7736e.

Change-Id: I32b8463122c3521e233c34ca95c96a5078e88848
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
be84b59e802d9176a9b60b040e0be6bda54e958a 23-Jun-2016 Calin Juravle <calin@google.com> Remove the old obsolete profiler

Bug: 24698874
Test: all the existing run-tests pass.
Change-Id: I56d25c75541275512a64ae5708569461b875df9c
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
badee9820fcf5dca5f8c46c3215ae1779ee7736e 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%

Change-Id: If07e45390014a6ee8f3c1c4ca095b43046f0871f
696632e6113a379f24dc6fe4c38e4dee57a249f8 04-Jun-2016 Mathieu Chartier <mathieuc@google.com> Revert "Revert "Hold dex caches live in class table""

Bug: 29083330

This reverts commit f102faf1bcbdb2149e3e7bf27b1819f621b7894b.

(cherry picked from commit c9dbb1df3b5c06ba122cacaf35b17cb53c6be3c6)

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

This reverts commit d6d49e56c2b7b11f474acb80cb02bb1fe9b7861e.

Bug: 29083330

(cherry picked from commit f102faf1bcbdb2149e3e7bf27b1819f621b7894b)

Change-Id: Id0c921bd6fe422159f8daa598dc8e7c9ed6eca47
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
b089eccf503646e6ed2d5bb20d973d9131166655 01-Jun-2016 Vladimir Marko <vmarko@google.com> Delay dex-to-dex compilation until Optimizing is done.

This fixes a race between inlining in the Optimizing
backend and dex-to-dex quickening where the Optimizing can
read the non-quickened opcode and then the quickened field
index or vtable index and look up the wrong field or method.
Even if we such tearing of the dex instruction does not
happen, the possible reordering of dex-to-dex and Optimizing
compilation makes the final oat file non-deterministic.

Also, remove VerificationResults::RemoveVerifiedMethod() as
we have only the Optimizing backend now and as such it was
dead code and would have interfered with this change.

Bug: 29043547
Bug: 29089975

(cherry picked from commit 492a7fa6df3b197a24099a50f5abf624164f3842)

Change-Id: I1337b772dc69318393845a790e5f6d38aa3de60f
492a7fa6df3b197a24099a50f5abf624164f3842 01-Jun-2016 Vladimir Marko <vmarko@google.com> Delay dex-to-dex compilation until Optimizing is done.

This fixes a race between inlining in the Optimizing
backend and dex-to-dex quickening where the Optimizing can
read the non-quickened opcode and then the quickened field
index or vtable index and look up the wrong field or method.
Even if we such tearing of the dex instruction does not
happen, the possible reordering of dex-to-dex and Optimizing
compilation makes the final oat file non-deterministic.

Also, remove VerificationResults::RemoveVerifiedMethod() as
we have only the Optimizing backend now and as such it was
dead code and would have interfered with this change.

Bug: 29043547
Bug: 29089975
Change-Id: I8389927d35dcacaf2f99c2153f055857036c8129
f284d448e3edd428b6ade473d0993028638b2064 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
Change-Id: Ia44668f013ceef1f5eb80f653a48d0f8004548c9
f6d1e0f6196cb3669dfb4eed8ceef679b0588c0f 23-May-2016 Vladimir Marko <vmarko@google.com> Compile JNI stubs for verify-profile and interpret-only.

This is the intended behavior to have a good JNI transition
performance.

Bug: 28902384

(cherry picked from commit 8c185bf0c6f18a5349bc87a7e3751ba06d90f461)

Change-Id: I52767909b916ada3c619206c8838b85bff5ac316
8c185bf0c6f18a5349bc87a7e3751ba06d90f461 23-May-2016 Vladimir Marko <vmarko@google.com> Compile JNI stubs for verify-profile and interpret-only.

This is the intended behavior to have a good JNI transition
performance.

Bug: 28902384
Change-Id: Iedb2ca343d66cf422ef2dc0527639e81d6ba8960
d361afbf6677b5af99fe2a44e92ef9d6e3ad7c17 28-Apr-2016 Mathieu Chartier <mathieuc@google.com> Revert "Revert "Write conflict tables in image""

Added test.

Bug: 27906566

This reverts commit 8e2478d23e89a7022c93ddc608dcbba7b29b91e6.

(cherry picked from commit cdca476bf3394ce9d97a369e84e701b427009318)

Change-Id: Iedb4ca9a28ae178fa7c2d486803fa27b402a85ed
946593d7c593c912684022a808fd156e17852248 27-Apr-2016 Mathieu Chartier <mathieuc@google.com> Revert "Write conflict tables in image"

Some strange issues on angler.

This reverts commit cda9386add68d94697449c6cb08b356747e55c21.

(cherry picked from commit 8e2478d23e89a7022c93ddc608dcbba7b29b91e6)

Change-Id: I475ca30e60691cd00b818aabbeb88e6ce3a2ae17
5c4b2ec16bcd779731bed1d2a0bd902dba3d5f92 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

(cherry picked from commit cda9386add68d94697449c6cb08b356747e55c21)

Change-Id: I3ce151651bf95047b0f692c185016f693ac4f820
471118ef120cb075ccba9e307e2c1b9b5a584840 29-Apr-2016 Chih-Hung Hsieh <chh@google.com> Fix google-explicit-constructor warnings.

Bug: 28341362
Change-Id: Ic7e236a7f58c4021a3f8fb4536a6457d262fe62e
91288d8f03b9aab28b61a4a76e552ad7e0c15c8b 28-Apr-2016 Mathieu Chartier <mathieuc@google.com> Revert "Revert "Write conflict tables in image""

Added test.

Bug: 27906566

This reverts commit 8e2478d23e89a7022c93ddc608dcbba7b29b91e6.

(cherry picked from commit cdca476bf3394ce9d97a369e84e701b427009318)

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

Some strange issues on angler.

This reverts commit cda9386add68d94697449c6cb08b356747e55c21.

(cherry picked from commit 8e2478d23e89a7022c93ddc608dcbba7b29b91e6)

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

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

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

Bug: 27916886

(cherry picked from commit e5de54cfab5f14ba0b8ff25d8d60901c7021943f)

Change-Id: I68afc181d71447895fb12346c1806e99bcab1de2
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
e42888f9df4163303244070c65d5229d3e201742 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

(cherry picked from commit cda9386add68d94697449c6cb08b356747e55c21)

Change-Id: I38cbe3150c3eeb385b8cad7cf93614e3980f4162
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
116e6e2f36e82156d54f2505909be0a6b2b7247d 13-Apr-2016 Vladimir Marko <vmarko@google.com> Use dex cache from compilation unit in HInstructionBuilder.

Avoid calling costly ClassLinker::FindDexCache() from
HInstructionBuilder, the dex cache is already available in
the compilation unit. Compiling Nexus 5 boot image on host
under perf(1) shows that the time spent in FindDexCache()
is reduced from about 2% to well under 0.2%, 90% of the
remaining hits coming from ReferenceTypePropagation which
doesn't have access to the compilation unit.

Bug: 28173563

(cherry picked from commit 3cd50df11b3076b801954018236c366fd9b97948)

Change-Id: Ife0dba2dd8f49bd52f86ddadf06ee787bad03d66
d1ee80948144526b985afb44a0574248cf7da58a 13-Apr-2016 Vladimir Marko <vmarko@google.com> Move Assemblers to the Arena.

And clean up some APIs to return std::unique_ptr<> instead
of raw pointers that don't communicate ownership.

(cherry picked from commit 93205e395f777c1dd81d3f164cf9a4aec4bde45f)

Bug: 27505766
Change-Id: I3017302307a0253d661240750298802fb0d9585e
3cd50df11b3076b801954018236c366fd9b97948 13-Apr-2016 Vladimir Marko <vmarko@google.com> Use dex cache from compilation unit in HInstructionBuilder.

Avoid calling costly ClassLinker::FindDexCache() from
HInstructionBuilder, the dex cache is already available in
the compilation unit. Compiling Nexus 5 boot image on host
under perf(1) shows that the time spent in FindDexCache()
is reduced from about 2% to well under 0.2%, 90% of the
remaining hits coming from ReferenceTypePropagation which
doesn't have access to the compilation unit.

Change-Id: Id9df61c79db9a67e3f12c857f32a4ca80e5420c3
93205e395f777c1dd81d3f164cf9a4aec4bde45f 13-Apr-2016 Vladimir Marko <vmarko@google.com> Move Assemblers to the Arena.

And clean up some APIs to return std::unique_ptr<> instead
of raw pointers that don't communicate ownership.

Change-Id: I3017302307a0253d661240750298802fb0d9585e
b7248b9f1a6d62a30f0cefc12de63c216b5d46e2 07-Apr-2016 Mathieu Chartier <mathieuc@google.com> Store precice set of which constructors require barriers

Fixes bugs where things in the boot image might not have been
calculated even though resolved_clases was true. This only occured
for app and test compiles though.

Fixes test 476-checker-ctor-memory-barrier which was failing due to
inlining something in the boot class path and getting a unexpected
barrier since the barrier defaults to enabled.

No measurable increase in RAM usage.

(cherry picked from commit c4ae916def97b9e1ef6df35c8fabb3921a0e380c)

Bug: 28005874

Change-Id: I4a417819aa129c95f4a83c38df1a66eb77824ea9
c4ae916def97b9e1ef6df35c8fabb3921a0e380c 07-Apr-2016 Mathieu Chartier <mathieuc@google.com> Store precice set of which constructors require barriers

Fixes bugs where things in the boot image might not have been
calculated even though resolved_clases was true. This only occured
for app and test compiles though.

Fixes test 476-checker-ctor-memory-barrier which was failing due to
inlining something in the boot class path and getting a unexpected
barrier since the barrier defaults to enabled.

No measurable increase in RAM usage.

Bug: 28005874

Change-Id: I4a417819aa129c95f4a83c38df1a66eb77824ea9
b5d386118334fa5181c31b83b3fee6332537f4b7 07-Apr-2016 Mathieu Chartier <mathieuc@google.com> Revert "Revert "Check if we require barrier if we did not resolve classes""

This reverts commit a7ab4997f7263439561093ffbc7dea29181a47c5.
371bd83f21f8db3b8e4cc8a660ead6a0650e92f6 07-Apr-2016 Mathieu Chartier <mathieuc@google.com> Revert "Revert "Change RequiresConstructorBarrier default to yes""

This reverts commit 0436ee6bd33a0b905cd2a7e333f7935da1bd5d86.
0436ee6bd33a0b905cd2a7e333f7935da1bd5d86 07-Apr-2016 Roland Levillain <rpl@google.com> Revert "Change RequiresConstructorBarrier default to yes"

CL https://android-review.googlesource.com/#/c/213119/ is
breaking run-test 476-checker-ctor-memory-barrier on ARM
and ARM64.

Bug: 28005874

This reverts commit f2f0f4b0b9185fe0b6d1fb22744a871c96296db2.

Change-Id: Ic6e97ab07358406c07c654ac9de700f0186f15f8
a7ab4997f7263439561093ffbc7dea29181a47c5 07-Apr-2016 Roland Levillain <rpl@google.com> Revert "Check if we require barrier if we did not resolve classes"

CL https://android-review.googlesource.com/#/c/213119/ is
breaking run-test 476-checker-ctor-memory-barrier on ARM
and ARM64, and reverting it requires reverting this CL
(https://android-review.googlesource.com/#/c/213109/)
first.

Bug: 28005874

This reverts commit 20fd7cdd25364b16d878df037c6ae0fbd5f2a9ac.

Change-Id: Iaf174b2df3dd4dd469c79ca3f2c68ef87748d124
20fd7cdd25364b16d878df037c6ae0fbd5f2a9ac 06-Apr-2016 Mathieu Chartier <mathieuc@google.com> Check if we require barrier if we did not resolve classes

Check fields instead of just always inserting the return void
barrier.

Bug: 28005874

(cherry picked from commit 03c7df9648028228d75dddfc25cbc81ab8096167)

Change-Id: I1207fecc9a4425d024a7e5e1a850c9e2a6e17c31
03c7df9648028228d75dddfc25cbc81ab8096167 06-Apr-2016 Mathieu Chartier <mathieuc@google.com> Check if we require barrier if we did not resolve classes

Check fields instead of just always inserting the return void
barrier.

Bug: 28005874
Change-Id: I62cc1c3979304642109961fcf2607a7df065a162
f2f0f4b0b9185fe0b6d1fb22744a871c96296db2 06-Apr-2016 Mathieu Chartier <mathieuc@google.com> Change RequiresConstructorBarrier default to yes

Previously it defaulted to false, this caused incorrect dex2dex if
the resolution pass was not run.

TODO: Re-enable the no barrier for no resolution case to improve
interpreter performance slightly.

Bug: 28005874

(cherry picked from commit e5d8020b03956db6d533852b3ae940e0eb0fafc4)

Change-Id: Ibde6e18b8543f7bc9e17db6941a710756cd8b617
e5d8020b03956db6d533852b3ae940e0eb0fafc4 06-Apr-2016 Mathieu Chartier <mathieuc@google.com> Change RequiresConstructorBarrier default to yes

Previously it defaulted to false, this caused incorrect dex2dex if
the resolution pass was not run.

TODO: Re-enable the no barrier for no resolution case to improve
interpreter performance slightly.

Bug: 28005874
Change-Id: I6b2e5078e5a0d76317e5486cd5e4f04d995e7b56
085a072b209ac24ab4cb6b565a1570b485ec2fa3 02-Apr-2016 Mathieu Chartier <mathieuc@google.com> Mark array classes as verification attempted

We now initialize all array classes in the compiler driver. This in
turn will ensure they are marked verified in the image. This
prevents dirty pages in the image since we would otherwise set the
flags in the zygote.

On BusinessCard:
Reduces shared dirty from 636k -> 432k for boot.art, and dirty pages
from 183 to 132.

(cherry picked from commit 3b674098bef6eaf7d3fb731878293ef715fe1080)

Change-Id: If3093e4e3242e4ee3ea120abe5be7db028290260
3b674098bef6eaf7d3fb731878293ef715fe1080 02-Apr-2016 Mathieu Chartier <mathieuc@google.com> Mark array classes as verification attempted

We now initialize all array classes in the compiler driver. This in
turn will ensure they are marked verified in the image. This
prevents dirty pages in the image since we would otherwise set the
flags in the zygote.

On BusinessCard:
Reduces shared dirty from 636k -> 432k for boot.art, and dirty pages
from 183 to 132.

Bug: 27906566

Change-Id: I99fcaffe2cb7f0235a1a0845bebc44e2dc94cbf0
5a851261fd3c083e647e4b10c4ee0c5c31c4be5a 01-Apr-2016 Andreas Gampe <agampe@google.com> Revert "ART: Resolve all classes even when verify-profile"

This reverts commit 82e8c1ff6d58e98a52725eeefc6c2407470239d2.

The deadlock is fixed by 884f3b83ed6b2a378535ac6b2be57d6b2e22de09.

Bug: 27924355
82e8c1ff6d58e98a52725eeefc6c2407470239d2 30-Mar-2016 Andreas Gampe <agampe@google.com> ART: Resolve all classes even when verify-profile

Avoid deadlocks.

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

To help for build failures.

Change-Id: I6c94dfb50177daa7d89902d78715ccec31bf0e45
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
6915898b28cea6c9836ca1be6814d87e89cc6d76 16-Mar-2016 Calin Juravle <calin@google.com> Improve compiler stats

- report the max size of arena alloc
- report how many virtual or interface invokes were inlined

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

Added to:
JIT
DexFile functions
Oat file manager

Added helper ScopedTrace to prevent errors and reduce excess code.

Bug: 27502458

(cherry picked from commit dabdc0fe183d4684f3cf4d70cb09d318cff81b42)

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

Added to:
JIT
DexFile functions
Oat file manager

Added helper ScopedTrace to prevent errors and reduce excess code.

Bug: 27502458

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

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

TODO: Add tests for profile stuff.

Bug: 22858531

(cherry picked from commit 8913fc1a27df8cf3b37fd99e94d87f290591328e)

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

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

TODO: Add tests for profile stuff.

Bug: 22858531

Change-Id: I91ccd686394cc2517512f66abb0e277f3d26d4da
944da603cde59a4277f3bbc31d860a90842a1a2a 19-Feb-2016 Vladimir Marko <vmarko@google.com> ART: Allow method references across oat files for multi-image, 2nd attempt.

These were disabled because we didn't have sufficient
information about the multi-image layout when processing
link-time patches in OatWriter. This CL refactors the
ELF file creation so that the information is available.

Also clean up ImageWriter to use oat file indexes instead
of filenames and avoid reopening the oat file to retrieve
the checksum.

Change-Id: Icc7b528deca29da1e473c8f079521a36d6c4892f
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
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
ca76a1a0c1737b3e04961ba382c113102fdc00bf 02-Feb-2016 Jean-Philippe Halimi <jean-philippe.halimi@intel.com> Dex-wide ArenaPool scoping for AOT compilation

The Arena Pool is a structure that holds memory allocated by the Arena
Allocator, preventing system allocations and deallocations to occur too often
during AOT compilation. Currently, the Arena Pool holds memory it allocates
during the whole AOT compilation process. Unfortunately, such a behavior
generates memory usage overhead, which is exacerbated by bigger applications
such as Facebook.

In this particular app, method size imbalance provokes unnecessary memory
pressure, as one method might require a lot of arena allocations that won't be
used in the remaining compilation. Because the compiler memory footprint keeps
increasing during AOT compilation, the memory pressure becomes very high.

The proposed patch is an attempt to find a tradeoff between allocations /
deallocations time overhead, and the aforementioned memory pressure overhead
resulting of the allocations being held by the Arena Pool. The patch adds a
feature freeing up all memory allocated in the Arena Pool after each dex file
is done compiling.

We have measured no significant AOT compile-time overhead with the patch
(<0.3%), because the selected dex-file granularity is coarse enough. In the
meantime, it provides significant memory footprint improvements. The impact is
especially big with Facebook, because this app has a few methods generating
huge memory footprint peaks (peak native heap footprint goes down 34%).

Change-Id: I27e867e6a20b8a6c28a82cb83140941a8c2b5847
Signed-off-by: Jean-Philippe Halimi <jean-philippe.halimi@intel.com>
5b82d339955d1a0dc23eeb8d2d5659459ff987ba 18-Feb-2016 Nicolas Geoffray <ngeoffray@google.com> The JIT does not need VerifedMethod nor CompilerCallbacks.

bug:27173201

Change-Id: I971659f9ff6a8b780c94a7bed84de90fa9fc3456
45724f9a0cc38dbb3071beb3eeab96499868b49c 17-Feb-2016 Vladimir Marko <vmarko@google.com> Revert "Allow method references across oat files for multi-image."

Breaks Quick tests.

This reverts commit 6065402316da2b51eed5fc34cffbd991766bd408.

Change-Id: I8a5469ba7cea5f46b85cb489b3e0ef06ed548f03
6065402316da2b51eed5fc34cffbd991766bd408 16-Feb-2016 Vladimir Marko <vmarko@google.com> Allow method references across oat files for multi-image.

These were disabled because we didn't have sufficient
information about the multi-image layout when processing
link-time patches in OatWriter. This CL refactors the
ELF file creation so that the information is available.

Change-Id: I6f2e8dc8572d143c72cc2693bb0ba4fd76f889ab
dd9473b94c15c8cbdfcce702fdc7a50acdfbfd8b 28-Jan-2016 Anton Kirilov <anton.kirilov@linaro.org> dex2oat: Show memory usage values in bytes

Memory usage values are rounded down to an integer and shown in the
unit that would be most appropriate (refer to art::PrettySize());
e.g. if the value is at least 1 MB, but less than 1 GB, then it will
be shown in MB. However, that can introduce a very large error; for
example, a value that is close to, but less than 2 MB, will be
displayed as 1 MB.

This change forces dex2oat to print the raw value in bytes as well,
which may make memory usage analysis more accurate.

Change-Id: Id86a9fe21e8af0f02e77fac21cad51d35d941294
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
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
ace0dc1dd5480ad458e622085e51583653853fb9 20-Jan-2016 Andreas Gampe <agampe@google.com> ART: Add option to ensure deterministic compilation

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

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

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

The identity hashcode seed needs to be pinned.

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

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

Fix oatdump alignment padding accounting.

Bug: 26687569
Change-Id: Ia82120e8f715bb3691d861817b12778ac677355a
47496c293b2b79c9747eeebafe444715202e7fc6 27-Jan-2016 Vladimir Marko <vmarko@google.com> ART: Allow --no-inline-from to specify multiple dex files.

This will allow tests to specify arbitrary dex files from
which we should not inline, in addition to core-oj, so that
we can test the related functionality. Additionally, should
the core-oj.jar core grow beyond a single classes.dex and
require a multi-dex .jar, this change makes sure that we
prevent inlining also from the extra classes<N>.dex files.

Change-Id: I74da4839bf9bb405dd62ad80563bf646a7a65dd9
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
38f64d325867d3e7197da6e07b1d4d9ba8497427 18-Jan-2016 David Brazdil <dbrazdil@google.com> ART: Public classes never require access checks

CompilerDriver's CanAccess(Instantiable)TypeWithoutChecks will always
return false if the referrer class is unresolved. This is too
conservative when the target class is resolved and known public.

Change-Id: Ibf95f43f13a7295e85671e3b71e28b5d88b4ca3b
c903b6af634927479915eaa9516d493eea23f911 18-Jan-2016 Nicolas Geoffray <ngeoffray@google.com> Move --dump-cfg and dump-cfg-append to CompilerOptions.

It simplifies passing the option to the JIT.

Change-Id: Iee1b722362899e5809ef97be90961e3dda1e16cc
998c21661b5074c293cae818d0ab7c44dcda3a66 21-Dec-2015 Calin Juravle <calin@google.com> Perform profile file analysis in dex2oat

Dex2oat can accept now multiple profile files to drive a profile based
compilation. --profile-file and --reference-profile-file speficy a pair
of profile files which will be evaluated for significant differences
before starting the compilation. If the difference is insignificant
(according to some internal metric) the compilation is skipped and a
message is logged.

Multiple pairs of --profile-file and --reference-profile-file can be
specified. This effectively enables multi user support since profiles
for different users will be kept separately.

--reference-profile-file can be left out, case in which the decision is
solely based on --profile-file. If both flags are present, then their
repetition should form unique pairs.

If the compilation is performed and --reference-profile-file is given
then its data is merged with the data from the corresponding --profile-
file and saved back to the file.

If no profile flags are given, dex2oat proceeds as before and compiles
the dex files unconditionally.

As part of this change
- merge ProfileCompilationInfo and OfflineProfilingInfo under the same
object. There was no use to keep them separate anymore.
- SaveProfilingInfo now merges the data with what was in
the file before instead of overwriting it.

Bug: 26080105

Change-Id: Ia8c8b55587d468bca5179f78941854285426234d
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
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
226501b317e148aa8a8983355e85acb59c1eee83 11-Dec-2015 Calin Juravle <calin@google.com> Revert "Revert "Enable profiled guided compilation in dex2oat""

This reverts commit 2306ae0d412cc53cbf64877e4a8c37292dd907d8.

Change-Id: I50640009c2fac88ea703812b76549a0e8a6d7584
2306ae0d412cc53cbf64877e4a8c37292dd907d8 11-Dec-2015 Calin Juravle <calin@google.com> Revert "Enable profiled guided compilation in dex2oat"

The test still have some flakiness in it which didn't reproduce locally.

This reverts commit 500c9be1f261a8a95ae7a25f4f8084f43207f313.

Change-Id: I132aff62bf03c2f926aafde6869707573bae9b36
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
500c9be1f261a8a95ae7a25f4f8084f43207f313 25-Nov-2015 Calin Juravle <calin@google.com> Enable profiled guided compilation in dex2oat

- add parsing of the profile info saved during JIT.
- don't compile methods which are not part of the profile info.
- delete old profile hooks.
- add test for reading/writing profile. The test is disable in:
* interpreter modes: the test needs JIT.
* no-dex2oat/no-prebuild: we only save profiling info for the primary
oat file. In these modes we don't create oat files and thus nothing
is saved.

Bug:26080105

Change-Id: Ifdc63dc9d4b537fc79e54c3edc3ae3a462bc30fb
917d01680714b2295f109f8fea0aa06764a30b70 24-Nov-2015 Nicolas Geoffray <ngeoffray@google.com> Don't generate a slow path for strings in the dex cache.

Change-Id: I1d258f1a89bf0ec7c7ddd134be9215d480f0b09a
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
9fdb129b90c9a985f606f9d95627b4852171dc11 02-Dec-2015 Nicolas Geoffray <ngeoffray@google.com> Revert "Enable profiled guided compilation in dex2oat"

Test has flakes:

+art F 30865 30865 art/runtime/java_vm_ext.cc:466] JNI DETECTED ERROR IN APPLICATION: input is not valid Modified UTF-8: illegal start byte 0x80
+art F 30865 30865 art/runtime/java_vm_ext.cc:466] string: '��gy�'
+art F 30865 30865 art/runtime/java_vm_ext.cc:466] input: '<0x80> 0xd8 0x67 0x79 0x8e 0x7f'
+art F 30865 30865 art/runtime/java_vm_ext.cc:466] in call to NewStringUTF
+art F 30865 30865 art/runtime/java_vm_ext.cc:466] from java.lang.String Main.getProfileInfoDump(java.lang.String, java.lang.Class, java.lang.Class)

This reverts commit 27e17fd81cc30e16e86c9c15498cae7f920c9dfe.

Change-Id: Id224b5970c3620c4c71fc0d39ed4a2e4755e5f29
27e17fd81cc30e16e86c9c15498cae7f920c9dfe 25-Nov-2015 Calin Juravle <calin@google.com> Enable profiled guided compilation in dex2oat

- add parsing of the profile info saved during JIT
- don't compile methods which are not part of the profile info.
- delete old profile hooks

Change-Id: I45a13c3aeb36265d335e57cd160b9ea0fab3cbb5
10c13565474de2786aad7c2e79757ea250747a15 25-Nov-2015 Vladimir Marko <vmarko@google.com> Refactor oat file writing to give Dex2Oat more control.

This is the first step towards writing dex files to oat file
and mapping them from there for the actual AOT compilation.

Change-Id: Icb0d27487eaf6ba3a66c157e695f9bdc5bb9cf9a
42e372e5a34d0fef88007bc5f40dd0fc7c03b58b 24-Nov-2015 Nicolas Geoffray <ngeoffray@google.com> Optimize HLoadClass when we know the class is in the cache.

Change-Id: Iaa74591eed0f2eabc9ba9f9988681d9582faa320
fb8464ae5f5194dc16278e528cfcbff71498c767 02-Nov-2015 Mingyao Yang <mingyao@google.com> Revert "Revert "Enable store elimination for singleton objects.""

This reverts commit 55d02cf056f993aeafebd54e7b7c68c7a48507c9, and
makes the following change:
Currently we leverage loop side effects to decide whether heap values are
killed by the loop. Stores need to be kept if heap values may be killed
by loops and the corresponding loads cannot be eliminated. Similar thing
need to be done for each predecessor when we merge predecessor heap values.
To do that, the HInstanceFieldSet instruction itself is put in the heap
value array instead of the value of the store instruction. The store
instruction may be added to possibly_removed_stores_ first, but can later
be removed from possibly_removed_stores_ when it's found out that the store
needs to be kept due to merging/loop side effects.

Change-Id: I4f7bb1960f7b47240873e00ff1adac46fc102a02
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
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
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
d28b969c273ab777ca9b147b87fcef671b4f695f 04-Nov-2015 Nicolas Geoffray <ngeoffray@google.com> Code cleanup to avoid CompilerDriver abstractions in JIT.

Avoids allocating a CompiledMethod.

Change-Id: I35b4aa0d7c74daba68e827a01e71c300fce3b3bf
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
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
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
d1eaf0dc9abc42dbcbbd9c4b98bf930ae5f394f3 29-Oct-2015 Vladimir Marko <vmarko@google.com> Keep list of dex files for oat file in CompilerDriver.

Use this list to improve invoke-static/-direct dispatch for
intra-oat calls.

Also fix a latent ArmBaseRelativePatcher::ReserveSpaceEnd()
bug exposed by a buggy early version of this CL: when we
have unresolved patches at the end of all code, we need to
emit a final thunk. Though the OatWriter will try to patch
the unresolved call to a trampoline at the beginning of the
oat file, that trampoline may be too far and the relative
patcher doesn't know about it anyway, so it needs to assume
that a thunk is needed.

This reduces the overall size of oat files present in dalvik
cache on Nexus 9 after first boot by over 1MiB, AOSP ToT,
aosp_flounder-userdebug build.

Change-Id: I98604b70cb17377eed057c1c23971865cf344e43
55d02cf056f993aeafebd54e7b7c68c7a48507c9 29-Oct-2015 Andreas Gampe <agampe@google.com> Revert "Enable store elimination for singleton objects."

This reverts commit 7f43a3d48fc29045875d50e10bbc5d6ffc25d61e.

Fails booting.

Bug: 25357772
Change-Id: Ied19536f3ce8d81e76885cb6baed4853e2ed6714
7f43a3d48fc29045875d50e10bbc5d6ffc25d61e 28-Oct-2015 Mingyao Yang <mingyao@google.com> Enable store elimination for singleton objects.

Enable store elimination for singleton objects. However for finalizable object,
don't eliminate stores. Also added a testcase.

Change-Id: Icf991e7ded5b490f55f580ef928ece5c45e89902
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
0c3c2668ef44fdbd18d97f9134a85d1a7d561aa4 15-Oct-2015 Nicolas Geoffray <ngeoffray@google.com> Use DlMallocSpace for the JIT code cache.

- Also tidy up some code in the JIT compiler.
- And mprotect code space to be writable only when allocating.

Change-Id: I46ea5c029aec489f2af63452de31db3736aebc20
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
3cfa4d05afa76e19ca99ec964b535a15c73683f0 07-Oct-2015 Andreas Gampe <agampe@google.com> ART: Remove interpreter entrypoints

These are no longer used as entrypoints. Make them proper runtime
functions local to the interpreter.

Bump oat version.

Change-Id: Icdd92e20eafc5668b68eeebf55cf624560f462b3
740667a1c5fa0188bb676c569064deb2c47c0825 16-Sep-2015 Andreas Gampe <agampe@google.com> ART: Skip compiler-driver compile loop for VerifyAtRuntime

We don't compile (not even dex-to-dex) anyways, so skip iterating
over all methods. Shows a ~10% improvement of boot image compile
time on Nexus 9. Shows a ~40% improvement for a common large app
on the same device. Most of the remaining time is unzipping dex
files.

Bug: 24103765
Change-Id: I00931fd062a0a2297d1c7b90794302cb664571cc
87000a948524cba7538ccc5438f6a9ecbd4e347e 24-Aug-2015 Calin Juravle <calin@google.com> Add option to append to the cfg dump.

This makes life easier when verifying tests with unresolved classes
(which call dex2oat at rutime).

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

Usage replaces most SuspendAll and ResumeAll calls.

Change-Id: I355683a5365876242cea85a656dcb58455f7a294
f1d666e1b48f8070ef1177fce156c08827f08eb8 04-Sep-2015 Mathieu Chartier <mathieuc@google.com> Add ScopedThreadSuspension

Fixes the TransitionFromRunnableToSuspended and
TransitionFromSuspendedToRunnable pattern that was prone to errors.

Change-Id: Ie6ae9c0357c83b4fc4899d05dfa0975553170267
736b560f2d2c89b63dc895888c671b5519afa4c8 02-Sep-2015 Mathieu Chartier <mathieuc@google.com> Reduce how often we call FindDexCache

Before host boot.oat -j4 optimizing compile:
real 1m17.792s
user 3m26.140s
sys 0m8.340s

After:
real 1m12.324s
user 3m22.718s
sys 0m8.320s

Change-Id: If18e9e79e06cdf1676692e5efacb682bf93889c3
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
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.
a727e372d8f6929cd30b983f6969c7a50fc83bb6 25-Aug-2015 Andreas Gampe <agampe@google.com> ART: Balanced locking

Change the verifier to check for balanced locking. When balanced
locking can't be guaranteed, use a new failure kind to punt to
the interpreter.

Add smali tests, with JNI code to check the balanced-locking result.

Bug: 23502994
Change-Id: Icd7db0be20ef2f69f0ac784de43dcba990035cd8
0760a81257fa427646c309500d603194009265ef 27-Aug-2015 Andreas Gampe <agampe@google.com> ART: Propagate verifier failure types to the compilers

Add a bit-set encoding of seen failure types to the verifier and
make it available. Store this in VerifiedMethod, so that compilers
can inspect it and make choices based on failures. Rewrite the
current punting of runtime-throw errors to be at the compiler-driver
level.

Bug: 23502994
Change-Id: I1cfc7cbdf2aec1f14ba18f0169e432ba4ae16883
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
059ef3ddb2088f926ac452889e0953fdcd646a5e 18-Aug-2015 Mathieu Chartier <mathieuc@google.com> Always visit object class from VisitReferences

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

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

Bug: 22720414
Change-Id: I467ff9c9d55163d2a90b999aef3bdd7b3f648bac
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
5eb0d38dabda4d17a315c557f07f457308d28fa7 23-Jul-2015 Andreas Gampe <agampe@google.com> ART: Wire up DexToDexCompiler without extern

The extern declaration actually had the wrong signature, a parameter
was missing, and we never noticed.

Remove the function field and extern. Add a header for the compiler.
Use the header file.

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

Move from function pointers to virtual function visitors.

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

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

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

Also enable -Wthread-safety-negative.

Changes:
Switch to capabilities and negative capabilities.

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

Bug: 20072211

Change-Id: I42fcbe0300d98a831c89d1eff3ecd5a7e99ebf33
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
ed6195a514e3253576af27ea9ba13038509d29ac 13-Jul-2015 Nicolas Geoffray <ngeoffray@google.com> Revert "Revert "Revert "Make dex2dex return a CompiledMethod after quickening."""

Breaks again in some configurations I don't fully understand yet.

This reverts commit f075879649686e59b7a9065c5a061dbfdcdfbecc.

Change-Id: I0ac5533825e40b06462ee69b2740e4a96fb5c582
f075879649686e59b7a9065c5a061dbfdcdfbecc 13-Jul-2015 Nicolas Geoffray <ngeoffray@google.com> Revert "Revert "Make dex2dex return a CompiledMethod after quickening.""

This reverts commit 327c5ed30a1f016ef3e1bb26ea7b4abd34eb63b9.

Change-Id: I0dc5d92e5d1ef98830fbd3c40ec59a93f9e0422d
327c5ed30a1f016ef3e1bb26ea7b4abd34eb63b9 13-Jul-2015 Nicolas Geoffray <ngeoffray@google.com> Revert "Make dex2dex return a CompiledMethod after quickening."

Build failures on arm/arm64.

This reverts commit 6920703c8eae0d90528ea09945e742582b6f8198.

Change-Id: I0dd5426610150937dac6e4d9dd9aa759bdf7fca4
6920703c8eae0d90528ea09945e742582b6f8198 09-Jul-2015 Nicolas Geoffray <ngeoffray@google.com> Make dex2dex return a CompiledMethod after quickening.

This is the starting piece of pushing more verification and
dex2dex data into an .oat file, to lower the dependency on verification
results at runtime.

Change-Id: I8e1b49a0207714bc5b84d1f606806718c5c7fb69
005deb0a1683f9ee03a2cf2785dc6a7d7a8f16be 25-Jun-2015 Andreas Gampe <agampe@google.com> ART: Set methods to preverified in verify-none

Actually mark all methods to be verified, so that the interpreter
doesn't do access checks. Speedup is about 2x on a Nexus 6 when booting
in verify-none mode.

Bug: 22040916

(cherry picked from commit 1c284f2abdfe1b0ed87d5216021e69146f10b116)

Change-Id: I2d6c8df2a68eae6e358da2639d980cb8bfcc1560
1c284f2abdfe1b0ed87d5216021e69146f10b116 25-Jun-2015 Andreas Gampe <agampe@google.com> ART: Set methods to preverified in verify-none

Actually mark all methods to be verified, so that the interpreter
doesn't do access checks. Speedup is about 2x on a Nexus 6 when booting
in verify-none mode.

Bug: 22040916
Change-Id: I2d6c8df2a68eae6e358da2639d980cb8bfcc1560
421e495c9bc53649605639dd738b8da8669147f1 22-Jun-2015 Vladimir Marko <vmarko@google.com> ART: Don't do pre-linked calls to the interpreter bridge.

Bug: 21897404

(cherry picked from commit c08ab29796eeaa3b5863fbd987cd96fe7538d40c)

Change-Id: I66531379fb4468a8ddee063e664bf6593abbe7d5
c08ab29796eeaa3b5863fbd987cd96fe7538d40c 22-Jun-2015 Vladimir Marko <vmarko@google.com> ART: Don't do pre-linked calls to the interpreter bridge.

Bug: 21897404
Change-Id: I6cca9d3b436df2eed2b0192607de0faf5cc2ecf7
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
a8b41003a717ecf399b890c18e9b0df49f55472f 15-Jun-2015 Vladimir Marko <vmarko@google.com> ART: Fix reporting initialized classes by CompilerDriver.

Fix a bug where the CompilerDriver was erroneously reporting
classes as initialized during AOT compilation when they were
not guaranteed to be initialized at runtime.

This fix prevents the Quick compiler from inlining calls to
static methods in classes that are not guaranteed to be
initialized, so that the runtime performs the initialization
required for correctness.

Bug: 21847756

(cherry picked from commit 07785bb98dc8bbe192970e0f4c2cafd338a8dc68)

Change-Id: I60c7361cb6e8f51be20a3cbfcae19f3240bdfbed
07785bb98dc8bbe192970e0f4c2cafd338a8dc68 15-Jun-2015 Vladimir Marko <vmarko@google.com> ART: Fix reporting initialized classes by CompilerDriver.

Fix a bug where the CompilerDriver was erroneously reporting
classes as initialized during AOT compilation when they were
not guaranteed to be initialized at runtime.

This fix prevents the Quick compiler from inlining calls to
static methods in classes that are not guaranteed to be
initialized, so that the runtime performs the initialization
required for correctness.

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

Optimizing + quick tests are passing, devices boot.

TODO: Test and fix bugs in mips64.

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

Bug: 19264997

(cherry picked from commit e401d146407d61eeb99f8d6176b2ac13c4df1e33)

Change-Id: I622469a0cfa0e7082a2119f3d6a9491eb61e3f3d

Fix some ArtMethod related bugs

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

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

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

TODO: Fix JDWP tests.

Bug: 19264997

Change-Id: I7c55f69c61d1b45351fd0dc7185ffe5efad82bd3

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

Bug: 19264997
Change-Id: Ief45cdd4bae5a43fc8bfdfa7cf744e2c57529457

Fix JDWP tests after ArtMethod change

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

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

Bug: 19264997
Change-Id: I363e293796848c3ec491c963813f62d868da44d2

Fix accidental IMT and root marking regression

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

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

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

Bug: 19264997
Change-Id: I4333e80a8268c2ed1284f87f25b9f113d4f2c7e0

Fix bogus image test assert

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

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

Bug: 19264997
Change-Id: I7359f1f73ae3df60c5147245935a24431c04808a

[MIPS64] Fix art_quick_invoke_stub argument offsets.

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

This fixes mips64 boot.

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

Optimizing + quick tests are passing, devices boot.

TODO: Test and fix bugs in mips64.

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

Bug: 19264997
Change-Id: I622469a0cfa0e7082a2119f3d6a9491eb61e3f3d
ce0db62f8150afd3cf9f615490ebde762b3afa6d 27-May-2015 David Srbecky <dsrbecky@google.com> Revert "Revert "Switch to using ELF-64 for 64-bit architectures.""

This reverts commit 650f0c49ac4aff3c9f871cd041042ae28b7e1e0a.

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

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

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

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

Bug: 13925192

(cherry picked from commit 80afd02024d20e60b197d3adfbb43cc303cf29e0)

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

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

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

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

Bug: 13925192
Change-Id: I704884dab15b41ecf7a1c47d397ab1c3fc7ee0f7
650f0c49ac4aff3c9f871cd041042ae28b7e1e0a 23-May-2015 Hiroshi Yamauchi <yamauchi@google.com> Revert "Switch to using ELF-64 for 64-bit architectures."

This reverts commit a3a49fe863e0bcf423ed0b4082136d1439fb2e79.

Change-Id: I0afabec15f5d9110de0d4105cbab7d040f2b86e2
a3a49fe863e0bcf423ed0b4082136d1439fb2e79 19-May-2015 David Srbecky <dsrbecky@google.com> Switch to using ELF-64 for 64-bit architectures.

Bug: 21297086
Change-Id: I4914e097ceffa58ddbe567d23ab563b0d9db1f66
2b846ed46983f2b694f5a0f02806ba1449800d01 19-May-2015 Roland Levillain <rpl@google.com> Fix the size of a StackHandleScope in art::CompilerDriver.

Change-Id: Id6fbbbbfc5dcf9920e630699d4c1afc1b86f858f
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
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
70bef0d8f6aa30b0da5c6ca56e1bc5729f74654b 15-Apr-2015 Andreas Gampe <agampe@google.com> ART: Add compiled-methods

Add a dex2oat option for compiled-methods, a more granular filter
than compiled-classes. Add compiler-driver support for it.

Refactor dex2oat to reuse file reading.

Add a test to oat_test.

Change-Id: I78d0d040bce7738b4bb7aabe7768b5788d2587ac
b1fceadbd42b3047a9c06a8af6239c737d67344e 21-Apr-2015 Andreas Gampe <agampe@google.com> ART: Change image_classes and compiled_classes to unordered set

These lists can be large, and the soon-to-follow compiled_methods
will be potentially even larger. Use a hash set instead of a tree
set.

Change-Id: I7d25c075540f47771354c6f49928b4fd0c76eb2e
27df758e2e7baebb6e3f393f9732fd0d064420c8 17-Apr-2015 Calin Juravle <calin@google.com> [optimizing] Add memory barriers in constructors when needed

If a class has final fields we must add a memory barrier before
returning from constructor. This makes sure the fields are visible to
other threads.

Bug: 19851497
Change-Id: If8c485092fc512efb9636cd568cb0543fb27688e
f1c6d9e87cbfd27702103ccc7c7f08ce784dc872 13-Apr-2015 Calin Juravle <calin@google.com> Fallback to quick in case of soft verification errors

Add a regression test: using uninitialized values triggers a soft
verification error and optimizing should not crash.

Thanks to Stephen Kyle (stephenckyle@googlemail.com) for the bug report.

Bug: 19988704
Change-Id: I67174538eed853baff735694b3ae8eb34afe2a39
3481ba2c4e4f3aa80d8c6d50a9f85dacb56b508b 13-Apr-2015 Vladimir Marko <vmarko@google.com> ART: Clean up includes.

Reduce dependencies to improve incremental build times.
Break up circular dependency involving class_linker-inl.h.

Change-Id: I4be742c5c2b5cd9855beea86630fd68aab76b0db
031af41d1debbdbd8964d7c504a789068dfe6029 13-Apr-2015 Calin Juravle <calin@google.com> Revert "Fallback to quick in case of soft verification errors"

This reverts commit c751d37e692d89b360f3c09421401f581b5c6d06.

Change-Id: I2183df8e856410989bc019f6a1f58af37d5d7eab
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
c751d37e692d89b360f3c09421401f581b5c6d06 01-Apr-2015 Calin Juravle <calin@google.com> Fallback to quick in case of soft verification errors

Add a regression test: using uninitialized values triggers a soft
verification error and optimizing should not crash.

Thanks to Stephen Kyle (stephenckyle@googlemail.com) for the bug report.

Bug: 19988704

Change-Id: I2493f737efd3fad72f6b41fb60eff1d3731613fb
3773cd046b1c34569f4711666788bf8a389c7857 10-Apr-2015 Andreas Gampe <agampe@google.com> ART: Remove WriteElf from Compiler

As Portable is gone, we only have one elf_writer left. It also
allows to put the decision for 32b vs 64b ELF into a central
point.

Change-Id: Iae67d06df85268b3f0ee5725abc65edd23eb2499
c7399c82c27f85a2df2653e1eb8c0b60f2cfd934 08-Apr-2015 Andreas Gampe <agampe@google.com> ART: Remove LLVM cruft

Change-Id: I133ebed6101bf12a0642ed71e13f332c0c4f14e7
48699fb0b0662d9a4fa593d0bd2a7d5ace83e34e 06-Apr-2015 Jeff Hao <jeffhao@google.com> Prevent verified method from being deleted by compiler driver.

The results of it will be needed by future optimizing compiler changes.

Change-Id: Ifbdf47e7564906b74193f80a4ba0459eed87c0f7
75c40d419b621342ac834e5b61abcdcd84537063 03-Apr-2015 Goran Jakovljevic <Goran.Jakovljevic@imgtec.com> Fix JNI compiler for mips64

Fix assembly instructions in JNI stub to store the right size. Fix
callee-saves in JNI calling convention to reflect return registers.
Fix pointer size in mips64 assembler.

Change-Id: I4eccd1f56f62fa9119918192ec424e9073398bc7
7bf5a266719af47439c36128bf20fa14fe1e45e8 03-Apr-2015 Elliott Hughes <enh@google.com> Explicitly specify the C libraries that have mallinfo(3).

Change-Id: Ib6d22134cb246e30452a7ed9acabbde42b3ef091
20f85597828194c12be10d3a927999def066555e 19-Mar-2015 Vladimir Marko <vmarko@google.com> Fixed layout for dex caches in boot image.

Define a fixed layout for dex cache arrays (type, method,
string and field arrays) for dex caches in the boot image.
This gives those arrays fixed offsets from the boot image
code and allows PC-relative addressing of their elements.

Use the PC-relative load on arm64 for relevant instructions,
i.e. invoke-static, invoke-direct, const-string,
const-class, check-cast and instance-of. This reduces the
arm64 boot.oat on Nexus 9 by 1.1MiB.

This CL provides the infrastructure and shows on the arm64
the gains that we can achieve by having fixed dex cache
arrays' layout. To fully use this for the boot images, we
need to implement the PC-relative addressing for other
architectures. To achieve similar gains for apps, we need
to move the dex cache arrays to a .bss section of the oat
file. These changes will be implemented in subsequent CLs.

(Also remove some compiler_driver.h dependencies to reduce
incremental build times.)

Change-Id: Ib1859fa4452d01d983fd92ae22b611f45a85d69b
6ced4092bc425c6aa402d47be5e6c9e6ad2291ec 28-Feb-2015 Mathieu Chartier <mathieuc@google.com> Enable more direct code for JIT

Hard to measure the performance impact, but it should be faster.

Bug: 17950037

Change-Id: Ib8d216bb3b305dc390b5df7ee92427fd6bd8aab3
e86deeffad79c00ed2ebede04f4adc348bda790c 19-Mar-2015 Mathieu Chartier <mathieuc@google.com> Add verify-at-runtime compiler filter

Verifies at runtime only, instead of at compilation time.
AOSP HH boot time after clean-oat: ~30s instead of ~35s if enabled.
Also helps install time if enabled there.

TODO: See if there is any possible deadlocks that can result from
this.

Bug: 19762303

Change-Id: Ibfba77148da9039e8d7d7497c05486bc044eefe7
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
bf9fc581e8870faddbd320a935f9a627da724c48 14-Mar-2015 Mathieu Chartier <mathieuc@google.com> Add more info to who called SuspendAll

Helps diagnose related jank.

Change-Id: I38191cdda723c6f0355d0197c494a3dff2b6653c
9b34b244ecddd8a35c922ed87bc3df0ca4db0282 09-Mar-2015 Mathieu Chartier <mathieuc@google.com> Trim arenas for JIT

Moved arena pool into the runtime. Added arena trimming to arena
pool. When called, this madvises the used memory.

Changed the JIT compiler to trim arenas after compilation. Changed
the arena mmap name to dalvik-LinearAlloc.

Native PSS before:
80353 kB: Native
80775 kB: Native
78116 kB: Native
After:
73357 kB: Native
70181 kB: Native
70306 kB: Native

Bug: 17950037
Bug: 17643507
Bug: 19264997

Change-Id: I63e7a898fd6e909c2c677fa57b5917a7b1398930
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
6ea651f0f4c7de4580beb2e887d86802c1ae0738 24-Feb-2015 Maja Gagic <maja.gagic@imgtec.com> Initial support for quick compiler on MIPS64r6.

Change-Id: I6f43027b84e4a98ea320cddb972d9cf39bf7c4f8
6cf49e57ad7a61e1fffd5b1dfae9179c3ca5703d 05-Mar-2015 Andreas Gampe <agampe@google.com> ART: Add option to abort dex2oat on hard failure

Add an option that aborts dex2oat when a hard verifier failure occurs.

Bug: 19606409
Change-Id: I53195284e22fe6207274101e85745af763c06271
4d4eff794fb8f911d149536f144e589279a51781 05-Mar-2015 Andreas Gampe <agampe@google.com> ART: Fix compile-time-init fail

It is possible that a class that isn't itself marked as an image
class and would be skipped for compile-time-initialization by the
compiler driver is initialized when initializing a second class
that is an image class.

If the second class only depended on the first class during
initialization, e.g., to read field values, the compiler driver
may discard the class object (not reachable from image classes),
but record the oat class status as initialized (as it has been).

In that case we miss the initialization when we load the class at
runtime.

Ensure that all initialized classes with a class initializer are
considered image classes and retained.

Bug: 19323020
Change-Id: I4e537f328d9a4ea23ed5ff7166d532b8855f7acd
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
28a35887033652f3c1344bc3f46f5a1368023996 27-Feb-2015 Mathieu Chartier <mathieuc@google.com> Fix JIT direct call to interpreter bridge

FormulaEvaluationActions.EvaluateAndApplyChanges on hammerhead eng:
Before: 3550ms
After: 2540

Bug: 17950037
Change-Id: If7acaea20d4adb5418d00ef13192e2d4c29032af
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
a0acc2d5dbf8764b346da3d9e6ce1a91427fc4b5 27-Jan-2015 Jeff Hao <jeffhao@google.com> Revert "Revert "Allow preopted apps to have sharpened calls for non-x86 architectures.""

Should really say it allows pre-linked calls instead of sharpened calls.

Bug: 19100762
Change-Id: Ia2045a9eda92255e87a7f6187de18d6370b8f060
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
14247b687562003721c18aecf3f7aecf2e53d6ce 01-Feb-2015 Brian Carlstrom <bdc@google.com> Revert "Allow preopted apps to have sharpened calls for non-x86 architectures."

This reverts commit 1e3dfff2b73e142c568625a0310c1764658218c4.
1e3dfff2b73e142c568625a0310c1764658218c4 27-Jan-2015 Jeff Hao <jeffhao@google.com> Allow preopted apps to have sharpened calls for non-x86 architectures.

Bug: 19100762
Change-Id: Idce391a06a85b881ce138756155b36e3ed7319c1
2397ad72daff0e15a64281bf4b0dd8065551d22f 23-Jan-2015 Jeff Hao <jeffhao@google.com> Allow preopted apps to have sharpened calls for non-x86 architectures.

Bug: 19100762

Change-Id: Iefd4265cb7864cdaa12c1f9e44bfaa5aa4fb93ec
aa3eff991fc34d6434465bf6bf49ef2e2fb286b7 20-Jan-2015 Andreas Gampe <agampe@google.com> ART: Curb dex2oat verbosity

Only print dedupe collisions in a debug build or on verbose logging.

Bug: 19082662

(cherry picked from commit 8d295f8f0e88fa5c6373962d545020a06033b3fc)

Change-Id: I08bd04a453d95b6dba6cf6955b5741cd97daf480
8d295f8f0e88fa5c6373962d545020a06033b3fc 20-Jan-2015 Andreas Gampe <agampe@google.com> ART: Curb dex2oat verbosity

Only print dedupe collisions in a debug build or on verbose logging.

Change-Id: I08bd04a453d95b6dba6cf6955b5741cd97daf480
57b34294758e9c00993913ebe43c7ee4698a5cc6 15-Jan-2015 Andreas Gampe <agampe@google.com> ART: Allow to compile interpret-only mips64 files

Include enough infrastructure to allow cross-compiling for mips64,
interpret-only. This includes the instruction-set-features, frame
size info and utils assembler.

Also add a disassembler for oatdump, and support in patchoat.

Note: the runtime cannot run mips64, yet.

Change-Id: Id106581fa76b478984741c62a8a03be0f370d992
866c03125a3fcd74c9fff04da87865f5eb1767d9 13-Jan-2015 David Brazdil <dbrazdil@google.com> ART: dex2oat flag for HGraphVisualizer dump file

This patch adds a new '--dump-cfg=<file>' flag to dex2oat which
specifies the file that HGraphVisualizer will store its output into.
Until now the graph was dumped to 'art.cfg' in the current working
directory. To make Checker work with run-test, the output directory
needs to be customizable.

Change-Id: I4a940f7708b88deea5a0e51d13aed13e52199349
6e73272f093e9dc045c08baae57eebb5dcd6e044 13-Jan-2015 Andreas Gampe <agampe@google.com> Revert "ART: dex2oat flag for HGraphVisualizer dump file"

Breaks compilation of tests.

This reverts commit 54953dfdcb3bb8896d8af2d20adef84fb740ce77.

Change-Id: I868b876c3130be61f1169c5fccdffc0368bee11e
54953dfdcb3bb8896d8af2d20adef84fb740ce77 13-Jan-2015 David Brazdil <dbrazdil@google.com> ART: dex2oat flag for HGraphVisualizer dump file

This patch adds a new flag to dex2oat which allows to specify the
name of the file that HGraphVisualizer will store its output into.
Until now the graph was dumped to "art.cfg" in the current working
directory. To make Checker work with run-test, the output directory
needs to be customizable.

Change-Id: I395c518b987e594e89e5e80f202a96befa41ac20
e21dc3db191df04c100620965bee4617b3b24397 09-Dec-2014 Andreas Gampe <agampe@google.com> ART: Swap-space in the compiler

Introduce a swap-space and corresponding allocator to transparently
switch native allocations to memory backed by a file.

Bug: 18596910

(cherry picked from commit 62746d8d9c4400e4764f162b22bfb1a32be287a9)

Change-Id: I131448f3907115054a592af73db86d2b9257ea33
62746d8d9c4400e4764f162b22bfb1a32be287a9 09-Dec-2014 Andreas Gampe <agampe@google.com> ART: Swap-space in the compiler

Introduce a swap-space and corresponding allocator to transparently
switch native allocations to memory backed by a file.

Bug: 18596910
Change-Id: I131448f3907115054a592af73db86d2b9257ea33
6c170c9e884e9dddf61d963d403042ee2a399e7d 17-Dec-2014 Andreas Gampe <agampe@google.com> ART: Punt to the interpreter for VerifiedMethod errors

In case that the GC map can't be created (because of size restrictions),
do not fail the class. Instead punt to the interpreter.

Bug: 17791183

(cherry picked from commit f535c69f115c61ffadca1bd2706244d0aa30f9aa)

Change-Id: I348bb306dbfc85c235fa93c0c527fba6627551fe
f535c69f115c61ffadca1bd2706244d0aa30f9aa 17-Dec-2014 Andreas Gampe <agampe@google.com> ART: Punt to the interpreter for VerifiedMethod errors

In case that the GC map can't be created (because of size restrictions),
do not fail the class. Instead punt to the interpreter.

Bug: 17791183
Change-Id: I348bb306dbfc85c235fa93c0c527fba6627551fe
e53798a7e3267305f696bf658e418c92e63e0834 01-Dec-2014 Nicolas Geoffray <ngeoffray@google.com> Inlining support in optimizing.

Currently only inlines simple things that don't require an
environment, such as:
- Returning a constant.
- Returning a parameter.
- Returning an arithmetic operation.

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

Change-Id: I3bf3250fa866fd2265f1b115d52fa5dedc48a7fc
ab972ef472001fa113d54486d7592979e33480b3 04-Dec-2014 Mathieu Chartier <mathieuc@google.com> Remove method verification results right after compiling a method

This saves memory since it allows the code arrays from methods
compiled in future methods to use the ram we just freed from the
verification results.

GmsCore.apk:
Before: dex2oat took 77.383s (threads: 2) arena alloc=6MB java alloc=30MB native alloc=77MB free=13KB
After: dex2oat took 72.180s (threads: 2) arena alloc=6MB java alloc=30MB native alloc=60MB free=13KB

Bug: 18596910
Change-Id: I5d6df380e4fe58751a2b304202083f4d30b33b7c
(cherry picked from commit 25fda92083d5b93b38cc1f6b12ac6a44d992d6a4)
25fda92083d5b93b38cc1f6b12ac6a44d992d6a4 04-Dec-2014 Mathieu Chartier <mathieuc@google.com> Remove method verification results right after compiling a method

This saves memory since it allows the code arrays from methods
compiled in future methods to use the ram we just freed from the
verification results.

GmsCore.apk:
Before: dex2oat took 77.383s (threads: 2) arena alloc=6MB java alloc=30MB native alloc=77MB free=13KB
After: dex2oat took 72.180s (threads: 2) arena alloc=6MB java alloc=30MB native alloc=60MB free=13KB

Bug: 18596910
Change-Id: I5d6df380e4fe58751a2b304202083f4d30b33b7c
dc8b63c21f1e84b1bc0ec11400b60669bbdd62df 02-Dec-2014 Andreas Gampe <agampe@google.com> ART: Build fix.

Fix closure.

Change-Id: I6ab68f2e3fb210c3b644affe3410c67a28df3d8e
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
e94652f1e321b2c8b71acbe5b07d2ebf69fbdb99 02-Dec-2014 Ian Rogers <irogers@google.com> Remove MethodHelper from the interpreter.

Use ShadowFrame to get the executing method to avoid a handle for the current
method.
Various associated bits of header file clean-up and removal of an unnecessary
use of MethodHelper in CompilerDriver.

Change-Id: I3b6f4413701e8fc6b0c58b0041a0dd15472bedaa
dbfe254f5ca96f6c5b2284478597d6140c01a394 26-Nov-2014 Andreas Gampe <agampe@google.com> ART: Print initialization failures to file

Add the ability to print boot image initialization failures to a
file.

Add a tool to convert said file into a Graphviz file.

Change-Id: Iedcc337bdf05654c154aa553236f20bdd15572ee
7ae063bf396534bc3022cbc3a681c5302e864db8 25-Nov-2014 Andreas Gampe <agampe@google.com> ART: Check that boot image classes are verified

In a debug build, check that all classes in the boot image are
at least fully verified. This is to avoid issues when we need to
bring up a runtime quickly and without verification, e.g., the
decryption screen.

Change-Id: I819683d8d35b6ffb50c6387a0f8091b9f130980d
807140048f82a2b87ee5bcf337f23b6a3d1d5269 21-Nov-2014 Mathieu Chartier <mathieuc@google.com> Add fast string sharpening

String sharpening changes const strings to PC relative loads instead
of always going through the dex cache. This saves code size and
probably improves performance slightly.

Before: 49602992 system@framework@boot.oat
After: 49385904 system@framework@boot.oat

Pre-cursor to removing dex_cache_strings_ field from ArtMethod.

Bug: 17643507

Change-Id: I1787f48774631eee0accafeea257aa8d0e91e8d6
85448d4b9c0720049a7ee4afa331870e87d83995 11-Nov-2014 Andreas Gampe <agampe@google.com> ART: Compiled-classes list for compiler-driver

Similar to the image-classes list, introduce a list of class names
that are to be compiled when creating a boot image. This defaults
to all classes.

Bug: 18336591

(cherry picked from commit 26318f722958ac1cba6a812026a1377f37c54941)

Change-Id: I95f69afdb500a9defb6795803d4040bbe67c5a01
4bf3ae9930a155f238dfd471413c866912b2579e 11-Nov-2014 Andreas Gampe <agampe@google.com> ART: Compiled-classes list for compiler-driver

Similar to the image-classes list, introduce a list of class names
that are to be compiled when creating a boot image. This defaults
to all classes.

Bug: 18336591

(cherry picked from commit 26318f722958ac1cba6a812026a1377f37c54941)

Change-Id: I95f69afdb500a9defb6795803d4040bbe67c5a01
26318f722958ac1cba6a812026a1377f37c54941 11-Nov-2014 Andreas Gampe <agampe@google.com> ART: Compiled-classes list for compiler-driver

Similar to the image-classes list, introduce a list of class names
that are to be compiled when creating a boot image. This defaults
to all classes.

Bug: 18336591
Change-Id: I95f69afdb500a9defb6795803d4040bbe67c5a01
300590bd7291251d9ac9aa762785a517d7f9f919 17-Oct-2014 Igor Murashkin <iam@google.com> dex2oat: Add a --compile-pic option

(cherry-picked from AOSP master
83c5612e69fa05610baf4f4d237fe0995a79cde5)

Bug: 18035729

(cherry picked from commit 643b5df2b065ccf5bb19a183573da691e9d0311f)

Change-Id: I14edee7c7cb996bc388d89b4c5274db2caf91004
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
735b8559d6dd26c610d4b97d72f25a092d9c8947 31-Oct-2014 Douglas Leung <douglas.leung@imgtec.com> Add JNI trampoline for mips32.

This patch allows the browser to come up.

Change-Id: Icad9da868be76d6a08e615807fad8678ac0a110f
643b5df2b065ccf5bb19a183573da691e9d0311f 17-Oct-2014 Igor Murashkin <iam@google.com> dex2oat: Add a --compile-pic option

(cherry-picked from AOSP master
83c5612e69fa05610baf4f4d237fe0995a79cde5)

Bug: 18035729
Change-Id: I80e03613e3b6ac079bcbc7e068bbaae760c364c9
19a19cffd197a28ae4c9c3e59eff6352fd392241 22-Oct-2014 Nicolas Geoffray <ngeoffray@google.com> Add support for static fields in optimizing compiler.

Change-Id: Id2f010589e2bd6faf42c05bb33abf6816ebe9fa9
b0f370e24436022abc2cf361766bf5a9fd78e966 26-Sep-2014 Andreas Gampe <agampe@google.com> ART: Change boot image class update

Compute the transitive closure by a search from the already known
image classes.

Bug: 17632031
Change-Id: I66a2793517fc1380f20e12d624a76eed6975832c
66c6d7bdfdd535e6ecf4461bba3804f1a7794fcd 16-Oct-2014 Vladimir Marko <vmarko@google.com> Rewrite class initialization check elimination.

Split the notion of type being in dex cache away from the
class being initialized. Include static invokes in the class
initialization elimination pass.

Change-Id: Ie3760d8fd55b987f9507f32ef51456a57d79e3fb
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
a4a3f407edb824d09588f4dbb5111f3a74c160a9 21-Oct-2014 Ian Rogers <irogers@google.com> Enable generic JNI for x86 and ARM when interpret-only.

Change-Id: I006ce1ce74acd0f0d53d380e28e409d24d772ea3
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
d4c4d953035d4418126d36517e402f411d6a87f3 17-Oct-2014 Ian Rogers <irogers@google.com> Some code clean-up.

Change-Id: I4b745fd5298cd61c793e3b57514b48347bd66c0e
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
d6dee676acdd1ab0aa4e5ba6834ee7c40a6dd8ab 17-Oct-2014 Igor Murashkin <iam@google.com> dex2oat: Add a --compile-pic option

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

Change-Id: I4e4ef3a2002fc59ebd9097087f150eaf3f2a7e08
f4da675bbc4615c5f854c81964cac9dd1153baea 01-Aug-2014 Vladimir Marko <vmarko@google.com> Implement method calls using relative BL on ARM.

Store the linker patches with each CompiledMethod instead of
keeping them in CompilerDriver. Reorganize oat file creation
to apply the patches as we're writing the method code. Add
framework for platform-specific relative call patches in the
OatWriter. Implement relative call patches for ARM.

Change-Id: Ie2effb3d92b61ac8f356140eba09dc37d62290f8
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
61ff009e37fa73ddfa7676bd9832cf3ee9702f97 16-Sep-2014 Andreas Gampe <agampe@google.com> ART: Check for exceptions from unresolved classes

In no-verify mode, classes may be unresolved because of missing
dependencies. Ignore and clear the exception.

Bug: 17506140
Change-Id: I70602b089e6631b1e177dbe8316c5fefdaf777a0
(cherry picked from commit ba354a97a9742774f57bad7f96ccae2dbbd59f75)
ba354a97a9742774f57bad7f96ccae2dbbd59f75 16-Sep-2014 Andreas Gampe <agampe@google.com> ART: Check for exceptions from unresolved classes

In no-verify mode, classes may be unresolved because of missing
dependencies. Ignore and clear the exception.

Bug: 17506140
Change-Id: I70602b089e6631b1e177dbe8316c5fefdaf777a0
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
928f72bd75c385ba2708c58521171a77264d4486 10-Sep-2014 Andreas Gampe <agampe@google.com> ART: Fix things for valgrind

Wire up valgrind gtests. Add valgrind-test-art-host, currently
only depending on valgrind-test-art-host-gtest32.

Fix an Alloc setting to allow running valgrind.

Refactor the fault handler to manage (and correctly release) the
handlers.

Fix minor failure-case leaks exposed by tests.

Failing tests:

The optimizing compiler is leaking non-arena-ed structures
(e.g., assembler buffers), as code generators are not destroyed.
The solution has been moved to a follow-up CL.

Note: All 64b tests are failing as we cannot allocate a heap.

Change-Id: I7f854cfd098d9f68107ce492363e7dba9a82b9fa
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)
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
6dd35ccbfbb29201c84a54261d75977c598ef2e6 27-Aug-2014 Ian Rogers <irogers@google.com> Revert "Avoid using NanoTime for compiler and verifier"

This reverts commit c89e6edbdce97c7d199b54bf63aed7ea01ebf1ff.

Change-Id: Id3b89121a19e64bf3c457c39b375f3d3c0fcc579
c89e6edbdce97c7d199b54bf63aed7ea01ebf1ff 27-Aug-2014 Mathieu Chartier <mathieuc@google.com> Avoid using NanoTime for compiler and verifier

Target timings before with -j2 --compiler-filter=interpret-only:
Approximate speedup 3%.

Before:
real 0m36.852s
real 0m36.050s
real 0m36.246s

After:
real 0m35.667s
real 0m35.779s
real 0m35.458s

Bug: 16853450

Change-Id: Id996172d8283639fe293ddfc26d01fc1a0beed0b
b68c6e578a28a9717d78dfd522d9d9b8befaedf2 19-Aug-2014 Mathieu Chartier <mathieuc@google.com> Reduce interpret-only compile time.

Before:
39.04user 5.18system 0:29.24elapsed 151%CPU (0avgtext+0avgdata 164176maxresident)k
38.87user 5.16system 0:29.14elapsed 151%CPU (0avgtext+0avgdata 164144maxresident)k

After:
36.26user 3.25system 0:27.00elapsed 146%CPU (0avgtext+0avgdata 162592maxresident)k
36.25user 3.28system 0:26.28elapsed 150%CPU (0avgtext+0avgdata 162688maxresident)k

Disabled implicit stack protection for the compiler, this reduces page faults.

Added support for not timing every method compilation and verification. NanoTime is
slow and adds ~2 seconds of real time. This is currently enabled since people want
to know which methods are slow to compile.

Bug: 16853450

(cherry picked from commit 8e219ae27624116b6d23e858fb21e93342f81d66)

Change-Id: I349ffb3f36db8c437137387aa6914dc17d743f09
8e219ae27624116b6d23e858fb21e93342f81d66 19-Aug-2014 Mathieu Chartier <mathieuc@google.com> Reduce interpret-only compile time.

Before:
39.04user 5.18system 0:29.24elapsed 151%CPU (0avgtext+0avgdata 164176maxresident)k
38.87user 5.16system 0:29.14elapsed 151%CPU (0avgtext+0avgdata 164144maxresident)k

After:
36.26user 3.25system 0:27.00elapsed 146%CPU (0avgtext+0avgdata 162592maxresident)k
36.25user 3.28system 0:26.28elapsed 150%CPU (0avgtext+0avgdata 162688maxresident)k

Disabled implicit stack protection for the compiler, this reduces page faults.

Added support for not timing every method compilation and verification. NanoTime is
slow and adds ~2 seconds of real time. This is currently enabled since people want
to know which methods are slow to compile.

Bug: 16853450

Change-Id: I349ffb3f36db8c437137387aa6914dc17d743f09
898fcb573c2e49c9c2aa59f3743e8f357b3fbc5b 26-Aug-2014 Brian Carlstrom <bdc@google.com> CheckAndClearResolveException should allow LinkageError

Bug: 16565964

(cherry picked from commit 118785c6f82ac1ec7074b5efe367b3dafd904940)

Change-Id: I7bc170e7a9ee9bd19defdd20187ee36a2381bf5d
118785c6f82ac1ec7074b5efe367b3dafd904940 26-Aug-2014 Brian Carlstrom <bdc@google.com> CheckAndClearResolveException should allow LinkageError

Bug: 16565964
Change-Id: Ibf236c627519a5cdef9479b7bc21e931d5474abf
53c913bb71b218714823c8c87a1f92830c336f61 13-Aug-2014 Andreas Gampe <agampe@google.com> ART: Clean up compiler

Clean up the compiler: less extern functions, dis-entangle
compilers, hide some compiler specifics, lower global includes.

Change-Id: Ibaf88d02505d86994d7845cf0075be5041cc8438
d84f916d35bb0dc74d7daa075b883e5ee1ce1109 16-Aug-2014 Andreas Gampe <agampe@google.com> ART: Avoid expensive class lookup in compiler driver

When we are not compiling multidex, avoid an expensive by-descriptor
lookup for classes when deciding whether to skip compilation.

Bug: 17072698
Change-Id: I19bcb2a2928207fcae0badd466cdc52945bd37c4
e98c8899ba2ae36d52aa7152a29469c314fdc20d 16-Aug-2014 Andreas Gampe <agampe@google.com> ART: Avoid expensive class lookup in compiler driver

When we are not compiling multidex, avoid an expensive by-descriptor
lookup for classes when deciding whether to skip compilation.

Bug: 17072698

(cherry picked from commit d84f916d35bb0dc74d7daa075b883e5ee1ce1109)

Change-Id: I19bcb2a2928207fcae0badd466cdc52945bd37c4
e3ea83811d47152c00abea24a9b420651a33b496 08-Aug-2014 Yevgeny Rouban <yevgeny.y.rouban@intel.com> ART source line debug info in OAT files

OAT files have source line information enough for ART runtime needs like
jump to/from interpreter and thread suspension. But this information
is not enough for finer grained source level debugging and low-level
profiling (VTune or perf).

This patch adds to OAT files two additional sections:
.debug_line - DWARF formatted Elf32 section with detailed source line
information (mapping from native PC to Java source lines).

In addition to the debugging symbols added using the dex2oat option
--include-debug-symbols, the source line information is added to
the section .debug_line.

The source line info can be read by many Elf reading tools like objdump,
readelf, dwarfdump, gdb, perf, VTune, ...

gdb can use this debug line information in x86. In 64-bit mode
the information can be used if the oat file is mapped in the lower
address space (address has higher 32 bits zeroed). Relocation works.

Testing:
1. art/test/run-test --host --gdb [--64] 001-HelloWorld
2. in gdb: break Main.java:19
3. in gdb: break Runtime.java:111
4. in gdb: run - stops at void java.lang.Runtime.<init>()
5. in gdb: backtrace - shows call stack down to main()
6. in gdb: continue - stops at void Main.main() (only in 32-bit mode)
7. in gdb: backtrace - shows call stack down to main()
8. objdump -W <oat-file> - addresses are from VMA range of .text
section reported by objdump -h <file>
9. dwarfdump -ka <oat-file> - no errors expected

Size of aosp-x86-eng boot.oat increased by 11% from 80.5Mb to 89.2Mb
with two sections added .debug_line (7.2Mb) and .rel.debug (1.5Mb).

Change-Id: Ib8828832686e49782a63d5529008ff4814ed9cda
Signed-off-by: Yevgeny Rouban <yevgeny.y.rouban@intel.com>
a73a8b55415b544355438522524a640378698d85 11-Aug-2014 Mathieu Chartier <mathieuc@google.com> Move explicit GC after we are done initalizing all classes.

Previously we had the GC happen for each dex file, this added a
few seconds of time on boot.oat creation.

Bug: 16853450

(cherry picked from commit 093ef212b7db4c17ed62df5cac0c1ac3a24e691d)

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

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

Don't generate GC maps when compilation is disabled.

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

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

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

Bug: 16853450
Change-Id: Ic705ea24784bee24ab80084d06174cbf87d557ad

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

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

Don't generate GC maps when compilation is disabled.

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

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

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

Bug: 16853450
Change-Id: Ic705ea24784bee24ab80084d06174cbf87d557ad
093ef212b7db4c17ed62df5cac0c1ac3a24e691d 11-Aug-2014 Mathieu Chartier <mathieuc@google.com> Move explicit GC after we are done initalizing all classes.

Previously we had the GC happen for each dex file, this added a
few seconds of time on boot.oat creation.

Bug: 16853450

Change-Id: I6b78c8c6f6c3bc20c164d951f2af8efbff0b8600
0171987facdea1f4e22d0b5880dcde38a816adb1 29-Jul-2014 Andreas Gampe <agampe@google.com> ART: Skip compiling redefined classes in apps

If for an app a class is defined in more than one dex file, skip
all classes after the first.

Bug: 16057120

(cherry picked from commit de7b43626c49567cefb258669aac70a289b74b85)

Change-Id: I461942f762354b696c305dcae3a0d1c7de40f9df
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
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
79273802f2b788bcd3eb76edf4df1bcaa57f886f 06-Aug-2014 Andreas Gampe <agampe@google.com> ART: Rework CFA frame initialization and writing code

Move eh_frame initialization code and CFI writing code to
elf_writer_quick to remove hard-wired dependencies on specific
Quick-compiler backends.

Change-Id: I27ee8ce7245da33a20c90e0086b8d4fd0a2baf4d
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
e7f82e2515f47f3c3292281312d7031a34a58ffc 06-Aug-2014 Fred Shih <ffred@google.com> Added support for patching classes from different dex files.

Added support for class patching from different dex files and moved
ScopedObjectAccess from the quick compiler to driver. Slight refactoring
for clarity.

Bug: 16656190
Change-Id: I107fcbce75db42ca61321ea1c5d5f236680a1b3d
de7b43626c49567cefb258669aac70a289b74b85 29-Jul-2014 Andreas Gampe <agampe@google.com> ART: Skip compiling redefined classes in apps

If for an app a class is defined in more than one dex file, skip
all classes after the first.

Bug: 16057120
Change-Id: Ifd71e6f462fd691ee23724a001190e9175988069
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
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
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
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
e50383288a75244255d3ecedcc79ffe9caf774cb 04-Jul-2014 Nicolas Geoffray <ngeoffray@google.com> Support fields in optimizing compiler.

- Required support for temporaries, to be only used by baseline compiler.
- Also fixed a few invalid assumptions around locations and instructions
that don't need materialization. These instructions should not have an Out.

Change-Id: Idc4a30dd95dd18015137300d36bec55fc024cf62
6b0599fc9356deaefe3c49fb883ca5b62a9f0b12 09-Jul-2014 Brian Carlstrom <bdc@google.com> Whitelist another exception during dex2oat resolving.

Bug: 15936401
Bug: 16162780
Change-Id: I7389edc8cdacd5e3c2cc7d86bbd56e8c503c34b0
70b634882b523ec9795475dccc347b423cefaef6 28-Jun-2014 Mathieu Chartier <mathieuc@google.com> Only allow whitelisted exceptions during dex2oat resolving.

Previously we would clear any exceptions even though we only want
to clear NoClassDefFound and IncompatibleClassChangeError exceptions.
This meant that out of memory exceptions would incorrectly get
cleared resulting in excessively long dex2oat times when you ran out
of memory.

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

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

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

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

Change-Id: Ia55b65609468f212b3cd65cda66b843da42be645
50e7d733f387cca7a3105431ed53539e3a57aa2c 24-Jun-2014 Brian Carlstrom <bdc@google.com> Update black list for klp-modular-dev

Change-Id: Ia6b85b249fe80578e49eacec5edd6315f8e7698c
08f7a2d06b915a5e21ded648d9feee519afd2f76 23-Jun-2014 Calin Juravle <calin@google.com> Log profile info only on debug builds.

Change-Id: I80cce951bf4cce988c9ab8373be3e335860eadf3
073ed9ba97df41862403f64d7a2e824d09ab50ed 14-Jun-2014 Andreas Gampe <agampe@google.com> ART: Ignore timing issues in debug builds

When in debug builds, do not warn about slow verification and
compilation.

Change-Id: Ib982e1c7cf40cf624688bbf6c41f0a7cc53bbc67
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
c1b643cc6ac45dbd0eabdcd7425c7e86006c27d6 31-May-2014 Calin Juravle <calin@google.com> Fixed and refactored profiler options handling

- extracted profiler options in a separate class
- switched from system property reading to command line arguments
- added profile based compilation options to CompilerOptions
- removed no longer used kProfile compilation filter
- optimize dex files only if the profiler is enabled
- clean up unused arguments

Bug: 12877748
Bug: 15275634
Change-Id: I37ff68e7694370950ce8db2360562e9058ecebb7
bb0b53f58f11c628f077603b56077dfed1a18f11 23-May-2014 Calin Juravle <calin@google.com> Clean up the sampling profiler

- rename variables/fields names to match the code style (use
_underscore_names_)
- extract common property parsing in utils.cc
- fail to load profile file if any line is malformed
- added ProfileFile to manage the profile data generate in the previous
runs (replaces ProfileHelper and nests ProfileData)

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

Merge ART from AOSP to lmp-preview-dev.

Change-Id: I0f578733a4b8756fd780d4a052ad69b746f687a9
1589d9375f4a92f36a7aee0e7a0c984ce6271fd4 27-May-2014 Andreas Gampe <agampe@google.com> ART: Fix sharpening across dex files

Bug: 15196336

(cherry picked from commit e0099d4d4839cabfb26270a746580e9d4ec3a6c6)

Change-Id: Ieae2e5c9ba4d5a76120236fd1bd7bd1daacc4a59
e0099d4d4839cabfb26270a746580e9d4ec3a6c6 27-May-2014 Andreas Gampe <agampe@google.com> ART: Fix sharpening across dex files

Bug: 15196336
Change-Id: If4301bcddce0ddbc60bb33403e4a76eed35bcb2f
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
a51a0b0300268b605e3ad71b0e87ff394032c5e7 21-May-2014 Vladimir Marko <vmarko@google.com> Method inlining across dex files in boot image.

Fix LoadCodeAddress() and LoadMethodAddress() to use the dex
file in addition to the method index to uniquely identify
the literal. With that fix in place, when we have both the
direct code and the direct method, we can safely pass the
actual target method id instead of the method id from the
same dex file in the method lowering info. This was already
done for calls from apps into boot image (and thus there was
a bug with a tiny risk of the wrong literal being used) and
now we also do that for calls within the boot image. The
latter allows the inlining pass to inline many more methods
than before in the boot image.

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

Change-Id: I4858d9cbed95e5ca560956b9dabd976cebe68333
700a402244a1a423da4f3ba8032459f4b65fa18f 20-May-2014 Ian Rogers <irogers@google.com> Now we have a proper C++ library, use std::unique_ptr.

Also remove the Android.libcxx.mk and other bits of stlport compatibility
mechanics.

Change-Id: Icdf7188ba3c79cdf5617672c1cfd0a68ae596a61
f832284dd847ff077577bb5712225430bbbb3b67 16-May-2014 Mathieu Chartier <mathieuc@google.com> Delete ClassHelper and fix compaction bug in GetDirectInterface

Cleanup helps to prevent compaction bugs. Fixed a fairly serious
compaction error caused by calling ClassHelper::GetDirectInterface
without handling the case where it causes thread suspension due to
ResolveType.

Bug: 8981901

Change-Id: I82b3bb6dd48d21eb6ece7aae0733c4a23c2bc408
db2633ce0358c704f97130a94b582602cb01d14a 16-May-2014 Mathieu Chartier <mathieuc@google.com> Change ObjectLock to take Handle instead of Handle pointer.

Change-Id: I9abdcdc5c9c9174634336b9250ab24c6aee434ec
d5185344e19d9feb7ac268369e0af6a467d1cb48 13-May-2014 Kenny Root <kroot@google.com> Changes for vogar compatibility

Make sure dex2oat can make an image with an empty list of image_classes.
Add in some checks to make sure that no bad arguments sneak into
CompilerDriver.

If we're not on the ART_TARGET, we should check for the "hostdex"
versions of the libraries to substitute in our libart version.

Change-Id: I5e8485c6089d25664492f0217b43ef64ca84c061
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
72d32629303f8f39362a4099481f48646aed042f 07-May-2014 Ian Rogers <irogers@google.com> Give Compiler a back reference to the driver.

The compiler driver is a single object delegating work to the compiler, rather
than passing it through to every Compiler call make it a member of Compiler so
that it maybe queried. This simplifies the Compiler API and makes the
relationship to CompilerDriver more explicit.
Remove reference arguments that contravene code style.

Change-Id: Iba47f2e3cbda679a7ec7588f26188d77643aa2c6
c45b8b582be5c98941ca3869fcdc9a08d520da41 03-May-2014 Ian Rogers <irogers@google.com> Create stack traces in unstarted runtimes.

Use to diagnose failed initialization in dex2oat of boot (-verbose:compiler).
Fix identity hashCode, ArtMethod.getMethodName, IntegralToString.convertInt and
use of Void when called from a unstarted runtime.

Change-Id: I2d536174b59e2e5f19519f93fc6b5916652fb6cd
8668c3cbdcf9471bd97e0da68a240051f2973074 25-Apr-2014 Mathieu Chartier <mathieuc@google.com> Add finalizer references from the entrypoints.

We now have an invariant where we never allocate finalizable
objects with the Initialized or Resolved entrypoints. This speeds up
allocation by only doing the check in the slow path.

Before:
MemAllocTest: 3625, 3707, 3641
EvaluateAndApplyChanges: 3448, 3421, 3413

After:
MemAllocTest: 3164, 3109, 3135
EvaluateAndApplyChanges: 3272, 3299, 3353

Bug: 14078487

Change-Id: I2b0534af3e7c75ea5e5257cf3647744f7abfb74e
af13ad9fd18b6f75fe82e7995224c55654594f93 11-Apr-2014 Andreas Gampe <agampe@google.com> Centralize instruction-set pointer-size, alignment, 64b-width code
in instruction_set.h/cc

This allows to clean up some places that currently make explicit
comparisons.

Change-Id: I0dcc924c52fa53306f706aceea93a2d4a655c5df
b8153878da8b48a3da01553746859bc6adce12c5 10-Apr-2014 Dave Allison <dallison@google.com> Fix problem with empty profiles.

This fixes an issue where a profile file was created by the installer
but never written by the runtime. This happens when profiles are off.
This caused the compiler to think that there are no methods worthy
of compilation and skipped everything.

Bug: 13960166
Change-Id: I4c4598d4746218e21ca949112071dc1424d7d1f9
644789fa0e807a9aa6d6e32d36ce039ec7318a7f 10-Apr-2014 Dave Allison <dallison@google.com> Fix problem with empty profiles.

This fixes an issue where a profile file was created by the installer
but never written by the runtime. This happens when profiles are off.
This caused the compiler to think that there are no methods worthy
of compilation and skipped everything.

Bug: 13960166
Change-Id: I4c4598d4746218e21ca949112071dc1424d7d1f9
d6ed642458c8820e1beca72f3d7b5f0be4a4b64b 10-Apr-2014 Dave Allison <dallison@google.com> Revert "Revert "Revert "Use trampolines for calls to helpers"""

This reverts commit f9487c039efb4112616d438593a2ab02792e0304.

Change-Id: Id48a4aae4ecce73db468587967968a3f7618b700
f9487c039efb4112616d438593a2ab02792e0304 09-Apr-2014 Dave Allison <dallison@google.com> Revert "Revert "Use trampolines for calls to helpers""

This reverts commit 081f73e888b3c246cf7635db37b7f1105cf1a2ff.

Change-Id: Ibd777f8ce73cf8ed6c4cb81d50bf6437ac28cb61

Conflicts:
compiler/dex/quick/mir_to_lir.h
081f73e888b3c246cf7635db37b7f1105cf1a2ff 07-Apr-2014 Dave Allison <dallison@google.com> Revert "Use trampolines for calls to helpers"

This reverts commit 754ddad084ccb610d0cf486f6131bdc69bae5bc6.

Change-Id: Icd979adee1d8d781b40a5e75daf3719444cb72e8
9dae5b4b952824da45e9fd9c12cfcde9858f0974 07-Apr-2014 Calin Juravle <calin@google.com> Tweaked profile significant_difference.

- renamed to 'change_thr'
- now it represents how much the top K leading samples need to change
(in percents) in order to trigger compilation.
- extracted ProfileData & file parsing in profiler.h

Bug: 12877748
Change-Id: I10f66120dd5e68b8a690bfa0e9914c07f63c50d5
754ddad084ccb610d0cf486f6131bdc69bae5bc6 19-Feb-2014 Dave Allison <dallison@google.com> Use trampolines for calls to helpers

This is an ARM specific optimization to the compiler
that uses trampoline islands to make calls to runtime
helper functions. The intention is to reduce the size
of the generated code (by 2 bytes per call) without
affecting performance.

By default this is on when generating an OAT file. It is
off when compiling to memory.

To switch this off in dex2oat, use the command line option:
--no-helper-trampolines

Enhances disassembler to print the trampoline entry on the
BL instruction like this:

0xb6a850c0: f7ffff9e bl -196 (0xb6a85000) ; pTestSuspend

Bug: 12607709
Change-Id: I9202bdb7cf21252ad807bd48701f1f6ce8e3d0fe
17965ed6ec29407599a0bcd4ea92532424294fed 04-Apr-2014 Sebastien Hertz <shertz@google.com> Re-enable DEX-to-DEX compilation path

Bug: 13807032
Change-Id: I6de7adb81a0f955a93257b83db9ad689ebcd90ad
6a58cb16d803c9a7b3a75ccac8be19dd9d4e520d 02-Apr-2014 Dmitry Petrochenko <dmitry.petrochenko@intel.com> art: Handle x86_64 architecture equal to x86

This patch forces FE/ME to treat x86_64 as x86 exactly.
The x86_64 logic will be revised later when assembly will be ready.

Change-Id: I4a92477a6eeaa9a11fd710d35c602d8d6f88cbb6
Signed-off-by: Dmitry Petrochenko <dmitry.petrochenko@intel.com>
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
04ff226764b125c79a0bf41e571c8311bac8a868 02-Apr-2014 Calin Juravle <calin@google.com> Profile: renamed kThresholdPercent and make it configurable

Bug: 12877748
Change-Id: If266f20f77faad4a726ef8df451a0c42f541392f
f6a4cee66a173ee7ef48af5503d9899aa93b3aeb 02-Apr-2014 Calin Juravle <calin@google.com> Profile: repurposed kTresholdPercent

Previously kTresholdPercent was the percentage of samples of the total
that a method must comprise before compiling.

I changed it to mean the threshold for a running total...i.e. compile
all the methods that comprise K% of the samples cumulatively.

(in the process fixed ProfileData#percent doc and changed its name)

Bug: 12877748
Change-Id: Ib0e18e525a16c11b189afc3d840c09183ac629de
ea1e520e5a4b52b668ea2f9d3abdd9ae3a192186 02-Apr-2014 Calin Juravle <calin@google.com> Fixed total method count in profile file parsing.

Change-Id: Iae38b3ca296378d17f054ac330301035ec684084
dd7624d2b9e599d57762d12031b10b89defc9807 15-Mar-2014 Ian Rogers <irogers@google.com> Allow mixing of thread offsets between 32 and 64bit architectures.

Begin a more full implementation x86-64 REX prefixes.
Doesn't implement 64bit thread offset support for the JNI compiler.

Change-Id: If9af2f08a1833c21ddb4b4077f9b03add1a05147
b95a5345ae4217b70ca36f0cced92f68dda7caf5 12-Mar-2014 Stuart Monteith <stuart.monteith@arm.com> AArch64: Add arm64 runtime support.

Adds support for arm64 to ART. Assembler stubs are sufficient for
down calls into interpreter. JNI compiler and generics are not finished.

Basic Generic JNI functionality.

Change-Id: I4a07c79d1e037b9f5746673480e32cf456867b82
0188ab739c3ef8bcd521d88f84894db8c0f012c5 18-Mar-2014 Ian Rogers <irogers@google.com> Fix comment typo.

Change-Id: Ib03f4e5dbdf380f9c94f7a18c1ea755b03c1fe3e
5b27149ce3cbf39f99c9d9c8ba5ebf1657c297e1 14-Mar-2014 Ian Rogers <irogers@google.com> Use quick generic JNI calls based on compiler driver options.

Change-Id: Ic70f4b9b5759eb11b35677c0039fb00eb1c4c506
b34f69ab43aaf7a6e6045c95f398baf566ef5023 07-Mar-2014 Nicolas Geoffray <ngeoffray@google.com> Add command line support for enabling the optimizing compiler.

Also run tests with the optimizing compiler enabled when
the file art/USE_OPTIMIZING_COMPILER is present.

Change-Id: Ibc33eed62a43547bc3b9fe786d014c0d81b5add8
49161cef10a308aedada18e9aa742498d6e6c8c7 12-Mar-2014 Jeff Hao <jeffhao@google.com> Allow patching between dex files in the boot classpath.

Change-Id: I53f219a5382d0fcd580e96e50025fdad4fc399df
e3e0260c23d8999b9433715ac7ee5296ee2fd633 12-Mar-2014 Vladimir Marko <vmarko@google.com> Move inline method detection to runtime.

The debugger needs this for selective deoptimization.

Change-Id: I8100000449b56e619288fb05d41ea6f02b53b334
f096aad9203d7c50b2f9cbe1c1215a50c265a059 23-Jan-2014 Vladimir Marko <vmarko@google.com> Cache method lowering info in mir graph.

This should enable easy inlining checks. It should also
improve compilation time of methods that call the same
methods over and over - it is exactly such methods that
tend to exceed our 100ms time limit.

Change-Id: If01cd18e039071a74a1444570283c153429c9cd4
39c3bfbd03d85c63cfbe69f17ce5800ccc7d6c13 29-Jan-2014 Dave Allison <dallison@google.com> Make use of profiling information for dex2oat

If the profile file exists, the compiler driver will read it
and store the data in an internal map. Then, when we want to work
out whether to compile a method or not, the map is consulted and if
the method shows up with a high enough percentage of use we compile it.

The profile file itself is created by installd and is writeable by the
app. The file is in /data/dalvik-cache/profiles and is named by
the package name.

This also modifies the profiler itself to:

1. Only count runnable threads (not suspended threads) in the profile
2. Use system properties to allow tuning of the profile parameters
3. Merge profiles from multiple processes using file locking.

Bug: 12877748
Change-Id: Iab2f3a327a2860db2a80d5724277d6c626227f2b

Conflicts:
compiler/dex/frontend.cc
compiler/dex/mir_analysis.cc
compiler/dex/verification_results.cc
compiler/driver/compiler_driver.cc
dex2oat/dex2oat.cc
runtime/class_linker.cc
runtime/runtime.cc
runtime/runtime.h
c645f1ddb7c40bea6a38eda4b3f83f6b6dec405b 07-Mar-2014 Mathieu Chartier <mathieuc@google.com> Add more VerifyObject calls.

Added verify object calls to SirtRef, IndirectReferenceTable,
ReferenceTable.

Removed un-needed verify object in ScopedObjectAccess / DecodeJObject
since object sources are handled.

Bug: 12934910
Change-Id: I55a46a8ea61fed2a77526eda27fd2cce97a9b125
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
be0e546730e532ef0987cd4bde2c6f5a1b14dd2a 26-Feb-2014 Vladimir Marko <vmarko@google.com> Cache field lowering info in mir_graph.

Change-Id: I9f9d76e3ae6c31e88bdf3f59820d31a625da020f
ae9fd93c39a341e2dffe15c61cc7d9e841fa92c4 11-Feb-2014 Mark Mendell <mark.p.mendell@intel.com> Tell GDB about Quick ART generated code

This is actually a lot of work. To do this, we need:
.debug_info
.debug_abbrev
.debug_frame
.debug_str

These are generated into the OAT file by OatWriter and ElfWriterQuick.

Since the Quick ART runtime doesn't use dlopen to load the OAT files,
GDB can't find this information. Use the alternate GDB JIT interface,
which can be invoked at runtime. To use this interface, an ELF image
needs to be built in memory. Read the information from the OAT file,
fixup the addresses to point to the real locations, add a symbol table
to hold the .text symbol, and then let GDB know about the information,
which will be read from the runtime address space.

This is quite primitive now, and could be cleaned up considerably. It
probably needs symbol table entries for the methods, and descriptions of
parameters and return types.

Currently only supported for X86.

This defaults to enabled for debug builds. Added dexoat --gen-gdb-info
and --no-gen-gdb-info flags to override.

Change-Id: I4d18b2370f6dfaa00c8cc1925f10717be3bd1a62
Signed-off-by: Mark Mendell <mark.p.mendell@intel.com>
3d504075f7c1204d581923460754bf6d3714b13f 01-Mar-2014 Ian Rogers <irogers@google.com> Make out arguments non-reference types.

Also, tidy some portable related code.

Change-Id: I67c8aa52eef8b556ca117ecda1b1e75465ba06a5
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
9c86a0279aaf953377aa9e2277592e68bf814989 21-Feb-2014 Ian Rogers <irogers@google.com> Revert "Annotate used fields."

This reverts commit 7f6cf56942c8469958b273ea968db253051c5b05.

Change-Id: Ic389a194c3404ecb5bb563a405bf4a0d6336ea0d
7f6cf56942c8469958b273ea968db253051c5b05 29-Jan-2014 Vladimir Marko <vmarko@google.com> Annotate used fields.

Annotate all fields used by a method early during the
compilation, check acces rights and record field offset,
volatility, etc. Use these annotations when generating code
for IGET/IPUT/SGET/SPUT instructions.

Change-Id: I4bbf5cca4fecf53c9bf9c93ac1793e2f40c16b5f
f3e2cc4a38389aa75eb8ee3973a535254bf1c8d2 18-Feb-2014 Nicolas Geoffray <ngeoffray@google.com> Code cleanup to avoid LLVM dependency when building with quick only.

Change-Id: I0985c227d775c72fd23975d4c9bf673ba32615c2
84c072c348006d87a370ad6e746e2d976cbe62f2 17-Feb-2014 Vladimir Marko <vmarko@google.com> Expose inline method identification for debugger.

Also, record only those getter/setter functions which
we really intend to inline in the short term (and which
actually have a special implementation emitted).

Change-Id: Icb8d71707a65cb6fabae5bc9118e5f3eaf7b63dd
f5df8974173124faddb8e2b6a331959afdb94fdf 14-Feb-2014 Nicolas Geoffray <ngeoffray@google.com> Rewrite the compiler interface for CompilerDriver.

Change-Id: I15fa9afe7ffb7283ebda8d788a1e02793e3f75a6
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
707c96a9d3b23182d1515a7e683c0885eee08a06 12-Feb-2014 Brian Carlstrom <bdc@google.com> Add StandardSocketOptions to the black list.

Change-Id: I8bc80275412b730df0e955b809a889b4b2635db5
e549da59446a9fb986fbf02fe4cd2e3d610bd051 12-Feb-2014 Vladimir Marko <vmarko@google.com> Pass correct is_static to ResolveField.

Change-Id: I35ca25cd1b80b09c4e1e34d30c835d7dbd249b9e
c7ac649e6ddcf322de48abcddfde63b3e0832aea 12-Feb-2014 Vladimir Marko <vmarko@google.com> Check IsStatic() on special accessor fields.

Change-Id: I48aebff3c3200540195eea863a52790ed4b5819e
bbcc0c0a17262f3d2a70fc0a82e1783862f708cc 03-Feb-2014 Vladimir Marko <vmarko@google.com> Speed up method lookup in a different dex file.

Use already known name and proto.

Change-Id: I4505b81724bd6a0f3cf21ee6fed44774d38c4e15
ea3fa0b4ba13d7bd7f7c1cd85202ccbe141a35ae 10-Feb-2014 Nicolas Geoffray <ngeoffray@google.com> Re-apply: Implement cumulative timings for CompilerDriver.

The bug was due to how the test infrastructure works:
a compiler driver surives the stack where it is allocated.

Change-Id: I345fe0e4afb2bd15937233db8afb350f09429558
55d0eac918321e0525f6e6491f36a80977e0d416 06-Feb-2014 Mark Mendell <mark.p.mendell@intel.com> Support Direct Method/Type access for X86

Thumb generates code to optimize calls to methods within core.oat.
Implement this for X86 as well, but take advantage of mov with 32 bit
immediate and call relative with 32 bit immediate.

Fix some incorrect return locations for long inlines.

Change-Id: I1907bdfc7574f3d0aa76c7fad13dc537acdf1ed3
Signed-off-by: Mark Mendell <mark.p.mendell@intel.com>
2bc47809febcf36369dd40877b8226318642b428 10-Feb-2014 Vladimir Marko <vmarko@google.com> Revert "Revert "Check FastInstance() early for special getters and setters.""

This reverts commit 632e458dc267fadfb8120be3ab02701e09e64875.

Change-Id: I5098c41ee84fbbb39397133a7ecfd367fecebe42
632e458dc267fadfb8120be3ab02701e09e64875 08-Feb-2014 Ian Rogers <irogers@google.com> Revert "Check FastInstance() early for special getters and setters."

This reverts commit 5dc5727261e87ba8a418e2d0e970c75f67e4ab79.

Change-Id: I3299c8ca5c3ce3f2de994bab61ea16a734f1de33
5dc5727261e87ba8a418e2d0e970c75f67e4ab79 05-Feb-2014 Vladimir Marko <vmarko@google.com> Check FastInstance() early for special getters and setters.

Perform the FastInstance() check for getters and setters
when they are detected by the inliner. This will help avoid
the FastInstance() check for inlining.

We also record the field offset and whether the field is
volatile and whether the method is static for use when
inlining or generating the special accessors.

Change-Id: I3f832fc9ae263883b8a984be89a3b7793398b55a
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
89786437f4c0176b35ca0376153dd18ab7df4924 31-Jan-2014 Vladimir Marko <vmarko@google.com> Don't assume resolved type has the same dex cache.

When we resolve a type with a certain DexCache that type's
GetDexCache() doesn't necessarily return the same DexCache.
This could have led to the wrong DexFile being used in
access checks by the CompilerDriver.

Change-Id: I2c836477f69f142bcbff902207dc0ad83854a398
2730db03beee4d6687ddfb5000c33c0370fbc6eb 27-Jan-2014 Vladimir Marko <vmarko@google.com> Add VerfiedMethod to DexCompilationUnit.

Avoid some mutex locking and map lookups.

Change-Id: I8e0486af77e38dcd065569572a6b985eb57f4f63
c7f832061fea59fd6abd125f26c8ca1faec695a5 24-Jan-2014 Vladimir Marko <vmarko@google.com> Refactor verification results.

Rename VerificationMethodsData to VerificationResults.
Create new class VerifiedMethod to hold all the data for
a given method.

Change-Id: Ife1ac67cede20f3a2f9c7f5345f08a851cf1ed20
be1ca55db3362f5b100c4c65da5342fd299520bb 15-Jan-2014 Hiroshi Yamauchi <yamauchi@google.com> Use direct class pointers at allocation sites in the compiled code.

- Rather than looking up a class from its type ID (and checking if
it's resolved/initialized, resolving/initializing if not), use
direct class pointers, if possible (boot-code-to-boot-class pointers
and app-code-to-boot-class pointers.)
- This results in a 1-2% speedup in Ritz MemAllocTest on Nexus 4.
- Embedding the object size (along with class pointers) caused a 1-2%
slowdown in MemAllocTest and isn't implemented in this change.
- TODO: do the same for array allocations.
- TODO: when/if an application gets its own image, implement
app-code-to-app-class pointers.
- Fix a -XX:gc bug.
cf. https://android-review.googlesource.com/79460/
- Add /tmp/android-data/dalvik-cache to the list of locations to
remove oat files in clean-oat-host.
cf. https://android-review.googlesource.com/79550
- Add back a dropped UNLIKELY in FindMethodFromCode().
cf. https://android-review.googlesource.com/74205

Bug: 9986565
Change-Id: I590b96bd21f7a7472f88e36752e675547559a5b1
23a282146042a0d171aec2a415176f5d0621a90c 09-Jan-2014 Vladimir Marko <vmarko@google.com> Clean up access checks.

Change-Id: Ia62ba6c8f1d0a9bfbbfde2d7be4c52c0f982b9d2
650be76eb3c38ff905ec1d9675d73e5cb9a82dac 20-Jan-2014 Brian Carlstrom <bdc@google.com> Revert "Implement cumulative timings for CompilerDriver."

This reverts commit df013175d1aa04641e5c6175f8c786e547d31654.
df013175d1aa04641e5c6175f8c786e547d31654 13-Jan-2014 Nicolas Geoffray <ngeoffray@google.com> Implement cumulative timings for CompilerDriver.

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

Change-Id: I937ea93e6df1835ecfe2d4bb7d84c24fe7fc097b
5816ed48bc339c983b40dc493e96b97821ce7966 27-Nov-2013 Vladimir Marko <vmarko@google.com> Detect special methods at the end of verification.

This moves special method handling to method inliner
and prepares for eventual inlining of these methods.

Change-Id: I51c51b940fb7bc714e33135cd61be69467861352
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
e13717e796d338b08ea66f6a7e3470ca44de707f 20-Nov-2013 Vladimir Marko <vmarko@google.com> Per-DexFile locking for inliner initialization.

And clean up lock and compiler driver naming.

Change-Id: I1562c7f55c4b0174a36007ba6199360da06169ff
501baec5f2de2156bb5ed7f66d23f1b1ad026267 13-Dec-2013 Sebastien Hertz <shertz@google.com> Cleanup thread pool tasks creation.

Removes unused vector when adding new ForAllClosure tasks to the thread pool.

Change-Id: Ie0c8067bc5cbfac45db04a6242bc98f89c3efc8d
460536209b741bc469f1b0857775449abb2102fb 12-Dec-2013 Bernhard Rosenkränzer <Bernhard.Rosenkranzer@linaro.org> Don't rely on gcc extensions

Make the code more compatible with different compilers.
clang doesn't allow extra static qualifiers on template
specializations, const qualifiers on function types,
or inline attributes on lambda functions, and is more
picky about casting away constness with reinterpret_cast.

These modifications are compatible with both gcc and
clang.

Change-Id: I739b10df2780bec537827a13679fd2bcc2cc7188
Signed-off-by: Bernhard Rosenkränzer <Bernhard.Rosenkranzer@linaro.org>
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
93220fc756f11e817078cd9fbf5363691b3f87df 30-Oct-2013 Jeff Hao <jeffhao@google.com> Update compiler blacklist to include java.net.NetworkInterface.

(cherry picked from commit a52454455048d04d12e4da637a103412a55e579b)

Change-Id: I3ee632e13ebf13ae08273f284966254b2c5e4d79
e9c36b34efb7460f59c6766e526c9b0de8da70b3 21-Nov-2013 Vladimir Marko <vmarko@google.com> Avoid some string allocations.

Also avoid building a string one character at a time.

Change-Id: I3db26226c620a730b95637d5bfc23e2d4715cfb9
5fe9af720048673e62ee29597a30bb9e54c903c5 14-Nov-2013 Ian Rogers <irogers@google.com> Fix memory leaks relating to timing logger.

Bug: 11670287.
We use pointers to uninitialized values for control-flow in the timing logger
code, add TODO comments to clean this up later.
Remove base namespace and other bits of tidying.

Change-Id: I1e6600a1e92f974c8f58f3a405a4e4abb4d9f80f
bcd5e9daecad39f0dab3246808b4835caec29ea6 13-Nov-2013 Mathieu Chartier <mathieuc@google.com> Manually manage thread pool stacks.

We now allocate the thread pool worker stack using a MemMap. This
enables us to name the maps so that we get more descriptive output
for debugging leaks.

Appears to fix the mips build 5/5 successful clean-oat and builds.
This is probably since glibc caches up to 40 MB of thread stacks
before releasing them.

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

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

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

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

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

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

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

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

Bug: 8981901

Change-Id: I3c886fd322a6eef2b99388d19a765042ec26ab99
0e49b42e03af56521d8ce2c9c84ac5b79e6241c9 08-Nov-2013 Jeff Hao <jeffhao@google.com> Fix handling of duplicate class definitions in boot classpath.

The compiler driver would get the wrong class references if a class
is defined multiple times in the boot classpath. It will now skip the
extra definitions.

Bug: 11598481
Samsung bug: 11539656
Change-Id: I4d9ae2b6d11190e6e6b89261d5f87c802def8810
d3c20c1a46863841c866b64a4c21e8bf9396b54c 30-Oct-2013 Jeff Hao <jeffhao@google.com> Update compiler blacklist to include java.net.NetworkInterface.

Bug: 11411129
Change-Id: Ib93d2f75024b3def54eadc11547990150deccf4d
(cherry picked from commit a52454455048d04d12e4da637a103412a55e579b)
7020278bce98a0735dc6abcbd33bdf1ed2634f1d 23-Oct-2013 Dave Allison <dallison@google.com> Support hardware divide instruction

Bug: 11299025

Uses sdiv for division and a combo of sdiv, mul and sub for modulus.
Only does this on processors that are capable of the sdiv instruction, as determined
by the build system.

Also provides a command line arg --instruction-set-features= to allow cross compilation.
Makefile adds the --instruction-set-features= arg to build-time dex2oat runs and defaults
it to something obtained from the target architecture.

Provides a GetInstructionSetFeatures() function on CompilerDriver that can be
queried for various features. The only feature supported right now is hasDivideInstruction().

Also adds a few more instructions to the ARM disassembler

b/11535253 is an addition to this CL to be done later.

Change-Id: Ia8aaf801fd94bc71e476902749cf20f74eba9f68
4cad324424124998aee164b7bd7e6965c39a5c00 30-Oct-2013 Jeff Hao <jeffhao@google.com> Update compiler blacklist to include java.net.NetworkInterface.

(cherry picked from commit a52454455048d04d12e4da637a103412a55e579b)

Change-Id: I65771b8379bccee93d689f6e1d94509e15ec13cb
a52454455048d04d12e4da637a103412a55e579b 30-Oct-2013 Jeff Hao <jeffhao@google.com> Update compiler blacklist to include java.net.NetworkInterface.

Change-Id: Ib93d2f75024b3def54eadc11547990150deccf4d
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
39d0c0d02dc11d10974d368ffd18068ad7d2029a 28-Oct-2013 Brian Carlstrom <bdc@google.com> Update black list with android.os.Bundle

Bug: 11415283
Change-Id: I5a8c580f0e1d029c995faac3ec332083de7b8646
83883d7fddf30fdb8b6903560fa1337ab991e74c 22-Oct-2013 Ian Rogers <irogers@google.com> Populate dex cache for sharpened calls.

We ensured the resolved method was in the dex cache, but for a sharpened call
this is abstract. Ensure that the concrete method is also resolved.
Limit the use of direct dex cache based dispatch to cases where we know how to
patch the dex cache.

Bug 11389002

Change-Id: I08252686a53b5948650632837c74bcd5cbf8a862
e732ef1c0192acd71925bd0ff1ab09640d45531d 10-Oct-2013 Ian Rogers <irogers@google.com> Make compiler stat dumping easier to use.

Previous needed -verbose:compiler + a debug build. Now specify --dump-stats to
dex2oat.

Change-Id: Ifde379e7cd06bbb0fe20149ce89c3b3789221eac
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
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
9b297bfc588c7d38efd12a6f38cd2710fc513ee3 06-Sep-2013 Ian Rogers <irogers@google.com> Refactor CompilerDriver::Compute..FieldInfo

Don't use non-const reference arguments.
Move ins before outs.

Change-Id: I7b251156388d8f07513b3da62ebfd29e5fd9ff76
65ec92cf13c9d11c83711443a02e4249163d47f1 06-Sep-2013 Ian Rogers <irogers@google.com> Refactor CompilerDriver::ComputeInvokeInfo

Don't use non-const reference arguments.
Move ins before outs.

Change-Id: I4a7b8099abe91ea60f93a56077f4989303fa4876
1e54d68ce8e77dfe63340275d11a072c5184c89a 06-Sep-2013 Sebastien Hertz <shertz@google.com> Disable devirtualization detection in DEX-to-DEX compiler.

This CL allows the DEX-to-DEX compiler to disable devirtualization detection.
This allows to quicken invoke-virtual/range instructions that used to be
eligible for devirtualization.

Bug: 10632943
Change-Id: I6c9f4d3249cf42b47f004be5825b3186fa83501e
d133b97b1ccae88f6ee7040e288fd7a239ee4492 05-Sep-2013 Ian Rogers <irogers@google.com> Shard dedupe set locks.

We're seeing contention during compilation on the dedupe locks, sharding 4 ways
on an occam brings down contention by > 5x.
Improve dedupe hash function to have a FNV hash function at its heart.
Improve naming of dedupe locks.
Tidy portable JNI compiler paramters to be pointers, given that's their primary
use.

Change-Id: I95d905f2ca5fee4e83a0034926a5f6501b4aeb79
df6931437880e1f7da9f777f5e54474d7ed7a630 04-Sep-2013 Anwar Ghuloum <anwarg@google.com> Remove memory leaks

Change-Id: I13a74791b1d39edfbba7c7884057fa163c343a9a
193bad9b9cfd10642043fa2ebbfc68bd5f9ede4b 30-Aug-2013 Mathieu Chartier <mathieuc@google.com> Multi threaded hashed deduplication during compilation.

Moved deduplication to be in the compiler driver instead of oat
writer. This enables deduplication to be performed on multiple
threads. Also added a hash function to avoid excessive comparison
of byte arrays.

Improvements:
Before (alloats host):
real 1m6.967s
user 4m22.940s
sys 1m22.610s

Thinkfree.apk (target mako):
0m23.74s real 0m50.95s user 0m9.50s system
0m24.62s real 0m50.61s user 0m10.07s system
0m24.22s real 0m51.44s user 0m10.09s system
0m23.70s real 0m51.05s user 0m9.97s system
0m23.50s real 0m50.74s user 0m10.63s system

After (alloats host):
real 1m5.705s
user 4m44.030s
sys 1m29.990s

Thinkfree.apk (target mako):
0m23.32s real 0m51.38s user 0m10.00s system
0m23.49s real 0m51.20s user 0m9.80s system
0m23.18s real 0m50.80s user 0m9.77s system
0m23.52s real 0m51.22s user 0m10.02s system
0m23.50s real 0m51.55s user 0m9.46s system

Bug: 10552630

Change-Id: Ia6d06a747b86b0bfc4473b3cd68f8ce1a1c7eb22
4bf1c8d4f2127caf769573d7c762a5d460a2781f 29-Aug-2013 Brian Carlstrom <bdc@google.com> Update blacklist for klp-dev

Change-Id: I5308f71b4c2ccdd7f6ac422ccb2a2d78141d1ce3
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
0b3eb39f8bc92f955f875ef50929c439aafe35fb 23-Aug-2013 Mathieu Chartier <mathieuc@google.com> Use atomic integer for compiler driver work balancing.

Before, we divided the work by dividing the total work by the number
of threads. This did not balance work well since some threads could
finish much earlier than others. The new method uses a shared atomic
integer to balance work. This makes it that a thread can process at
most one item after the other worker threads are finished.

Changed the number of threads to take into account the main thread
also doing work. This means that we subtract one from the number of
threads when we make the thread pool.

Change-Id: I0147b0403c6214800ed6bfcdac4f1e5486330996
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
42b32404abdd9f66b4b168ad8b17bccebfeb99f3 22-Aug-2013 Brian Carlstrom <bdc@google.com> Update black list with Landroid/webkit/WebViewFactory;

Change-Id: I6689d116930e862826527adad9a4000ebe9a5d28
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
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
f96b21728e8b10e2060ad2d0de46fcacf5974260 20-Aug-2013 Brian Carlstrom <bdc@google.com> Tolerate both old and new java.util.concurrent.ConcurrentHashMap

Change-Id: I87397bbb662d7dd8cb0683fc08bd35b401034357
958aba1421f2234aeafb22219d45a561e109a445 19-Aug-2013 Ian Rogers <irogers@google.com> Build fix.

A static field was moved from an inner to an outer class in ConcurrentHashMap
leading to a disallowed call.
Also, tidy comments on other java.util.concurrent black listed classes.

(cherry picked from commit 65530499a0169b3b0b153008e2d187c9f4939541)

Change-Id: I918f567c5b84d9f16f91772bee89cda29f058750
65530499a0169b3b0b153008e2d187c9f4939541 19-Aug-2013 Ian Rogers <irogers@google.com> Build fix.

A static field was moved from an inner to an outer class in ConcurrentHashMap
leading to a disallowed call.
Also, tidy comments on other java.util.concurrent black listed classes.

Change-Id: Iccd808766dcd5406a5bb49a4b98f570606730250
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
bd136a29f08486525d6abc7d0a0006ce5b4011c1 14-Aug-2013 Dragos Sbirlea <dragoss@google.com> Get PORTABLE + SMALL on x86.

Implemented the portable resolution trampoline and
the portable to interpreter bridge.
Also work on integrating SEA_IR in the PORTABLE+SMALL framework.
Refactor some naming and correct indenting.

Change-Id: Ibd97da5e5b6f5148274c9bff368e3654b661ef51
75a43f10f55e2aa550de51e969cc1e60d583b632 14-Aug-2013 Anwar Ghuloum <anwarg@google.com> Clean up logcat spam from compiler and verifier

Moved to VLOG(...), adding verifer tag for VLOG.

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

Cherry-picked from commit ed41d5c44299ec5d44b8514f6e17f802f48094d1.

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

Bug: 10014286.

Change-Id: Iafc1d8c5b62562c9af8fb9fd8c5e1d61270536e7
67f99418f648c3a95256ed3dcd8e8b64eef0b372 12-Aug-2013 Anwar Ghuloum <anwarg@google.com> Yet more timing logger cleanup

Some cleanup of timing logger placement, additional systrace placement for
threaded compilation work, tweaking/hiding of some type names per previous
review comments.

Change-Id: Ic7db2e02747282ac7f474b9a060df9803bfdfa5e
155ecba1c9b56ce1b468135e6a591a3fe9258c52 13-Aug-2013 buzbee <buzbee@google.com> Fix SMALL_ART

On all art builds, the images classes must be compiled. When doing
a small art build, it is necessary to override the default compiler
filter to force compilation. A merge mistake broke this logic
for dalvik-dev.

Change-Id: I88186bd89d0ccb4316ee0910e9324ddc3e6a1f75
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
75021222d9c03a80fa5c136db0d5fb8d82d04031 16-Jul-2013 Sebastien Hertz <shertz@google.com> Adds a DEX-to-DEX compilation level.

This CL adds a DEX-to-DEX compilation level which allows the DEX-to-DEX
compiler to ensure correctness on classes with soft-failed verification.

Bug: 9307738
Change-Id: If051336bf81370bca55872c8c75ccd573d8ca391
7934ac288acfb2552bb0b06ec1f61e5820d924a4 26-Jul-2013 Brian Carlstrom <bdc@google.com> Fix cpplint whitespace/comments issues

Change-Id: Iae286862c85fb8fd8901eae1204cd6d271d69496
4d4adb1dae07bb7421e863732ab789413a3b43f0 24-Jul-2013 Sebastien Hertz <shertz@google.com> Prevent verifier from creating unused compilation data.

The verifier used to create data which may be unused like GC map. This is the
case for non-compiled method (which are interpreted). This CL aims to optimize
this.

Here are the changes:
- Move compilation selection to MethodVerifier::IsCandidateForCompilation.
- Compiler and verifier use this method to know if a method must be compiled.
- Only create compilation data while compiling using Runtime::IsCompiler.
- Do not create internal structures concerning GC map, ... in Runtime::Init and
Runtime::Shutdown when we are not compiling.
- Checks we are compiling when accessing these structures.
- Add missing destruction of MethodVerifier::safecast_map_lock_ and
MethodVerifier::safecast_map_ in Runtime::Shutdown.
- Call Runtime::Shutdown just before Runtime instance is destroyed to avoid a
crash.
- Add missing "GUARDED_BY" macro for MethodVerifier::rejected_classes_ field.
- Add "has_check_casts" to avoid the safecast pass if there is no check-cast
instruction.
- Add "has_virtual_or_interface_invokes" to avoid the devirtualization pass if
there is no invoke-virtual/range nor invoke-interface/range instructions.

Bug: 9987437
Change-Id: I418ee99f63e4203409cf5b7d2c2295b22fcf24c1
6f28d91aab952e3244fbb4e707fa38f85538f374 25-Jul-2013 Anwar Ghuloum <anwarg@google.com> Add systrace support to NewTimingLogger, migrate compiler timing logging to NewTimingLogger

Rpleaced old TimingLogger by NewTimingLogger, renamed NewTimingLogger to TimingLogger, added systrace support to TimingLogger.
Tests passing, phone booting, systrace working.

Change-Id: I2aeffb8bcb7f0fd979d8a2a3a8bcfbaa02413679
d792cc1569c3505d68352c11a72447419ee6eaaf 25-Jul-2013 Brian Carlstrom <bdc@google.com> Add art support for Zygote NoPreloadHolder which black lists early initialization.

Change-Id: I9c68f6d7a1f230aba6382b1331d413d4cb92be12
21a5f6959d1429100e1c16ddabe10cde2bfeb121 24-Jul-2013 Brian Carlstrom <bdc@google.com> Update blacklist with HttpsURLConnection$DefaultHolder

(cherry picked from commit 8f20ff4354fd3fdd7604a299b7bf4446e5f4584c)

Change-Id: I8fbdd87977d8d320178854b956845ed8dc6d14d0
8f20ff4354fd3fdd7604a299b7bf4446e5f4584c 24-Jul-2013 Brian Carlstrom <bdc@google.com> Update blacklist with HttpsURLConnection$DefaultHolder

Change-Id: Ib0a8b9511dc8e63d14f11ba48b80dfb78e32d25e
c50d8e11a098cc5c6239aa86b47d4fcf8cbb4899 24-Jul-2013 Brian Carlstrom <bdc@google.com> Remove OatWriter buffering to memory for ElfWriterQuick

This allows the oat contents to be directly written to the file.

Change-Id: Ibc7ddf57477b152f07784b52f7334be73fd22833
4560248d4c85cade7f4fc7b30c3fb41b95a04a7f 22-Jul-2013 Brian Carlstrom <bdc@google.com> Move TimingLogger creation to dex2oat

Change-Id: I4fdb6afd4ce2ac0d91c6c968893606d593b6ea18
0177fe200efc1bf4d433955ee7920c683fdf5901 21-Jul-2013 Brian Carlstrom <bdc@google.com> Remove CompilerDriver::IsDebuggingSupported

Change-Id: Ib67e3ef67462fe5dae81148f7fe8cc76b3887f11
0cd7ec2dcd8d7ba30bf3ca420b40dac52849876c 18-Jul-2013 Brian Carlstrom <bdc@google.com> Fix cpplint whitespace/blank_line issues

Change-Id: Ice937e95e23dd622c17054551d4ae4cebd0ef8a2
2ce745c06271d5223d57dbf08117b20d5b60694a 18-Jul-2013 Brian Carlstrom <bdc@google.com> Fix cpplint whitespace/braces issues

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

Change-Id: I069586205a9a92fc7375ccf5cdde136bbbcfc800
7940e44f4517de5e2634a7e07d58d0fb26160513 12-Jul-2013 Brian Carlstrom <bdc@google.com> Create separate Android.mk for main build targets

The runtime, compiler, dex2oat, and oatdump now are in seperate trees
to prevent dependency creep. They can now be individually built
without rebuilding the rest of the art projects. dalvikvm and jdwpspy
were already this way. Builds in the art directory should behave as
before, building everything including tests.

Change-Id: Ic6b1151e5ed0f823c3dd301afd2b13eb2d8feb81