History log of /art/compiler/optimizing/optimizing_compiler.cc
Revision Date Author Comments
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)
032cacdbf32c50d3c43590600ed1e171a35fa93c 06-Apr-2017 Igor Murashkin <iam@google.com> optimizing: do not illegally remove constructor barriers after inlining

Remove the illegal optimization that destroyed constructor barriers
after inlining invoke-super constructor calls.

---

According to JLS 7.5.1,

"Note that if one constructor invokes another constructor, and the
invoked constructor sets a final field, the freeze for the final field
takes place at the end of the invoked constructor."

This means if an object is published (stored to a location potentially
visible to another thread) inside of an outer constructor, all final
field stores from any inner constructors must be visible to other
threads.

Test: art/test.py
Bug: 37001605
Change-Id: I3b55f6c628ff1773dab88022a6475d50a1a6f906
9c4f0d8ffd8fb1ce31b3f8de5ca8da497e0bee9a 05-Apr-2017 Goran Jakovljevic <Goran.Jakovljevic@imgtec.com> Clean up after MIPS got read barriers support

This enables checker tests, as well as compiler_driver_test and
reflection_test for MIPS32 and MIPS64.

Test: mma test-art-host-gtest
Test: mma test-art-target-gtest in QEMU (MIPS64)
Test: ./testrunner.py --optimizing --target in QEMU (MIPS64)

Change-Id: Ic6fe5b17f7f2cd7e38e12fef25afccf9358b80e0
1595815c2a914a78df7dfb6f0082f47d4e82bb36 10-Feb-2017 Alexey Frunze <Alexey.Frunze@imgtec.com> MIPS: Implement read barriers.

This is the core functionality. Further improvements
will be done separately.

This also adds/moves memory barriers where they belong and
removes the UnsafeGetLongVolatile and UnsafePutLongVolatile
MIPS32 intrinsics as they need to load/store a pair of
registers atomically, which is not supported directly by
the CPU.

Test: booted MIPS32R2 in QEMU
Test: test-art-target-run-test
Test: booted MIPS64 (with 2nd arch MIPS32R6) in QEMU
Test: "testrunner.py --target --optimizing -j1"
Test: same MIPS64 boot/test with ART_READ_BARRIER_TYPE=TABLELOOKUP
Test: "testrunner.py --target --optimizing --32 -j2" on CI20
Test: same CI20 test with ART_READ_BARRIER_TYPE=TABLELOOKUP

Change-Id: I0ff91525fefba3ec1cc019f50316478a888acced
f6d4668c42933e2f85ddbc94e276c49db4e2b1dd 28-Feb-2017 Nicolas Geoffray <ngeoffray@google.com> Improvements in the Inliner.

- Change from a depth limit to a total number of HInstructions
inlined limit. Remove the dex2oat depth limit argument.
- Add more stats to diagnose reasons for not inlining.
- Clean up logging to easily parse output.

Individual Ritz benchmarks improve from 3 to 10%.

No change in other heuristics. There was already an instruction budget.
Note that the instruction budget is rarely hit in the "apps" I've tried
with.

Compile-times improve from 5 to 15%.
Code size go from 4% increase (Gms) to 1% decrease (Docs).

bug:35724239
test: test-art-host test-art-target

Change-Id: I5a35c4bd826cf21fead77859709553c5b57608d6
051071718085ce807a2e7c55278a8d723e238e86 16-Mar-2017 Mathieu Chartier <mathieuc@google.com> Delete SrcMap

No longer used. SrcMapElem is still used by elf_debug_line_writer.h.

Address previous comments from aog/351387.

Test: make

Change-Id: Ib1525168b14889abbdc78ba20c64f3223b140a51
cbcedbf9382bc773713cd3552ed96f417bf1daeb 13-Mar-2017 Mathieu Chartier <mathieuc@google.com> Add method info to oat files

The method info data is stored separately from the code info to
reduce oat size by improving deduplication of stack maps.

To reduce code size, this moves the invoke info and inline info
method indices to this table.

Oat size for a large app (arm64): 77746816 -> 74023552 (-4.8%)
Average oat size reduction for golem (arm64): 2%

Repurposed unused SrcMapElem deduping to be for MethodInfo.
TODO: Delete SrcMapElem in a follow up CL.

Bug: 36124906

Test: clean-oat-host && test-art-host-run-test

Change-Id: I2241362e728389030b959f42161ce817cf6e2009
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
bcd9b99d9613400e6de8f082778a64c1018511d9 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
(cherry picked from commit 0b66d6174bf1f6023f9d36dda8538490b79c2e9f)
2f555967e54549d26ee74bd0303f8be5155f2e08 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
(cherry picked from commit 0b66d6174bf1f6023f9d36dda8538490b79c2e9f)
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
c4aa82c5b0aa921c51eaf6f6bbaff36501ea2cee 06-Mar-2017 Nicolas Geoffray <ngeoffray@google.com> Invoke typed arraycopy for primitive arrays.

Apps will always call the Object version of arraycopy. When
we can infer the types of the passed arrays, replace the method
being called to be the typed System.arraycopy one.

10% improvement on ExoPlayerBench.

Test: 641-checker-arraycopy
bug: 7103825
Change-Id: I872d7a6e163a4614510ef04ae582eb90ec48b5fa
92685a8a56fba7191612cf210f9c667b5ceda2af 06-Mar-2017 Aart Bik <ajcbik@google.com> Pass driver to loop opt. Add new side_effects phase.

Rationale:
Break-out CL of ART Vectorizer: number 3.
The purpose is making the original CL smaller
and easier to review.

Bug: 34083438
Test: test-art-host
Change-Id: I7cece807ee4f5fcaeae41f1deed33ac263447b77
b813ca14be33f7db8b7049c3b08a1eb776f25d1b 16-Feb-2017 Nicolas Geoffray <ngeoffray@google.com> Implement code sinking.

Small example of what the optimization does:

Object o = new Object();
if (test) {
throw new Error(o.toString());
}

will be turned into (note that the first user of 'o'
is the 'new Error' allocation which has 'o' in its
environment):
if (test) {
Object o = new Obect();
throw new Error(o.toString());
}

There are other examples in 639-checker-code-sinking.

Ritz individual benchmarks improve on art-jit-cc from
5% (EvaluateComplexFormulas) to 23% (MoveFunctionColumn)
on all platforms.

Test: 639-checker-code-sinking
Test: test-art-host
Test: borg job run
Test: libcore + jdwp

bug:35634932
bug:30933338

Change-Id: Ib99c00c93fe76ffffb17afffb5a0e30a14310652
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
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
fbdfa6d7485534eedbd3fb32cf572529ebddb63c 03-Feb-2017 Nicolas Geoffray <ngeoffray@google.com> Revert "Revert "Inline across dex files for JIT.""

bug:30933338

This reverts commit d16da8bd8106452eea82408748dc6b3fd64bcb80.

Change-Id: I6a30354d6d00442cb1a542af063c7769865e369d
83c8e27a292e6e002fb3b3def75cf6d8653378e8 31-Jan-2017 Nicolas Geoffray <ngeoffray@google.com> Code refactoring around sharpening HLoadClass.

Even if the class is not accessible through the dex cache, we
can access it by other means (eg boot class, jit table). So rewrite
static field access instruction builder to not bail out if a class
cannot be accessed through the dex cache.

bug:34966607

test: test-art-host test-art-target
Change-Id: I88e4e09951a002b480eb8f271726b56f981291bd
d16da8bd8106452eea82408748dc6b3fd64bcb80 03-Feb-2017 Nicolas Geoffray <ngeoffray@google.com> Revert "Inline across dex files for JIT."

Broke hikey build.

bug:30933338

This reverts commit f290c01c61f8a2979efa74ffcd2f54c5e426a3d0.

Change-Id: I3363d703c54d0f9b69197a29395cc08f60c8b2ac
f290c01c61f8a2979efa74ffcd2f54c5e426a3d0 28-Jan-2017 Nicolas Geoffray <ngeoffray@google.com> Inline across dex files for JIT.

bug:30933338
test: ART_TEST_JIT=true test-art-host test-art-target

Change-Id: I4ac708d70d90c2db4139d99a75bf4665a810c206
e0a1c5e871d7b68bd7c0e9c4496b620577a97cf9 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
(cherry picked from commit d16363a93053de0f32252c7897d839a46aff14ae)
80cd4004620fd1a672c2a550e9d71270feeabde9 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
(cherry picked from commit d16363a93053de0f32252c7897d839a46aff14ae)
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
22aa54bf8469689c7c6c33f15ff4df2ffba8fa15 18-Oct-2016 Alexandre Rames <alexandre.rames@linaro.org> AArch64: Add HInstruction scheduling support.

This commit adds a new `HInstructionScheduling` pass that performs
basic scheduling on the `HGraph`.

Currently, scheduling is performed at the block level, so no
`HInstruction` ever leaves its block in this pass.

The scheduling process iterates through blocks in the graph. For
blocks that we can and want to schedule:
1) Build a dependency graph for instructions. It includes data
dependencies (inputs/uses), but also environment dependencies and
side-effect dependencies.
2) Schedule the dependency graph. This is a topological sort of the
dependency graph, using heuristics to decide what node to schedule
first when there are multiple candidates. Currently the heuristics
only consider instruction latencies and schedule first the
instructions that are on the critical path.

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

Change-Id: Iec103177d4f059666d7c9626e5770531fbc5ccdc
f0acfe7a812a332122011832074142718c278dae 09-Jan-2017 Nicolas Geoffray <ngeoffray@google.com> Keep resolved String in HLoadString.

For the following reasons:
- Avoids needing to do a lookup again in CodeGenerator::EmitJitRoots.
- Fixes races where we the string was GC'ed before CodeGenerator::EmitJitRoots.
- Makes it possible to do GVN on the same string but defined in different
dex files.

Test: test-art-host, test-art-target
Change-Id: If2b5d3079f7555427b1b96ab04546b3373fcf921
b0b051ad6c9fab511346882650d5d689f805a980 17-Nov-2016 Mingyao Yang <mingyao@google.com> CHA guard optimization (elimination/hoisting).

Test: manual by checking the dump-cfg output.

Change-Id: I254e168b9a85d2d3d23e02eea7e129c1bc9ab920
ed015acdd0fbb1b837b3f74e8c5f624956189691 15-Dec-2016 Nicolas Geoffray <ngeoffray@google.com> Flush JIT data cache when committing code.

Otherwise, executing compiled code may see old data from
the data cache.

Test: ART_TEST_JIT=true test-art-target on arm/arm64
Test: run-libcore-tests.sh (especially jsr166) on arm/arm64
Change-Id: Id037c68897aa0e9ccacd4c5121f3743fb722c6f3
9186ced255f2e7402646b5b286deebb540640734 12-Dec-2016 Andreas Gampe <agampe@google.com> ART: Clean up utils.h

Remove functionality provided by libbase. Move some single-use
functions to their respective users.

Test: m test-art-host
Change-Id: I75594035fa975200d638cc29bb9f31bc6e6cb29f
22384aeab988df7fa5ccdc48a668589c5f602c39 12-Dec-2016 Nicolas Geoffray <ngeoffray@google.com> Revert "Revert "Add kJitTableAddress for HLoadClass.""

This reverts commit d2d5262c8370309e1f2a009f00aafc24f1cf00a0.

Change-Id: I6149d5c7d5df0b0fc5cb646a802a2eea8d01ac08
d2d5262c8370309e1f2a009f00aafc24f1cf00a0 12-Dec-2016 Nicolas Geoffray <ngeoffray@google.com> Revert "Add kJitTableAddress for HLoadClass."

One test failure after merge.

This reverts commit 5b12f7973636bfea29da3956a9baa7a6bbe2b666.

Change-Id: I120c49e53274471fc1c82a10d52e99c83f5f85cc
5b12f7973636bfea29da3956a9baa7a6bbe2b666 09-Dec-2016 Nicolas Geoffray <ngeoffray@google.com> Add kJitTableAddress for HLoadClass.

This new kind loads classes from the root table associated with
JIT compiled code.

Also remove kDexCacheAddress, which is replaced by kJitTableAddress.

test: ART_TEST_JIT=true test-art-host-jit test-art-target-jit
Change-Id: Ia23029688d1a60c178bf2ffa7463927c5d5de4d0
d4cc5b2127894475160b5d2bba9791dd21af5953 04-Nov-2016 Artem Serov <artem.serov@linaro.org> ARM: VIXL32: Implement Invoke, LoadClass, LoadString dispatch.

Implemented dispatch optimizations for InvokeStaticOrDirect,
LoadClass, LoadString (excluding cases that use Literals).
Performed a cleanup of VIXL backend.

Test: export ART_USE_VIXL_ARM_BACKEND=true && \
mma test-art-host dist && mma test-art-target dist

Change-Id: Ib37a6b7e7657196b13caec999d190be747857c1d
063fc772b5b8aed7d769cd7cccb6ddc7619326ee 02-Aug-2016 Mingyao Yang <mingyao@google.com> Class Hierarchy Analysis (CHA)

The class linker now tracks whether a method has a single implementation
and if so, the JIT compiler will try to devirtualize a virtual call for
the method into a direct call. If the single-implementation assumption
is violated due to additional class linking, compiled code that makes the
assumption is invalidated. Deoptimization is triggered for compiled code
live on stack. Instead of patching return pc's on stack, a CHA guard is
added which checks a hidden should_deoptimize flag for deoptimization.
This approach limits the number of deoptimization points.

This CL does not devirtualize abstract/interface method invocation.

Slides on CHA:
https://docs.google.com/a/google.com/presentation/d/1Ax6cabP1vM44aLOaJU3B26n5fTE9w5YU-1CRevIDsBc/edit?usp=sharing

Change-Id: I18bf716a601b6413b46312e925a6ad9e4008efa4
Test: ART_TEST_JIT=true m test-art-host/target-run-test test-art-host-gtest
f46501c6ad11025843682267c10f221323a206b1 22-Nov-2016 Nicolas Geoffray <ngeoffray@google.com> Clear the right data pointer.

Internally, stack_map_data is an offset of the roots_data allocation.
Pass both to the ClearData method, which will use the right pointer
to deallocate.

Test: test-art-host in debug mode
Change-Id: Ibfe38e7f1853870076048427f2efe7121c11c136
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
132d8363bf8cb043d910836672192ec8c36649b6 16-Nov-2016 Nicolas Geoffray <ngeoffray@google.com> Revert "Revert "Revert "Revert "JIT root tables.""""

Test: 626-set-resolved-string, test-art-host, test-art-target
Test: run-libcore-tests.sh
Test: phone boots and runs

This reverts commit 3395fbc20bcd20948bec8958db91b304c17cacd8.

Change-Id: I104b73d093e3eb6a271d564cfdb9ab09c1c8cf24
2bbc953357ac5f62cc4ab2eb055e4392e47d0c3d 21-Oct-2016 Artem Serov <artem.serov@linaro.org> ARM: VIXL32: Arch specific operations.

Tests which now start to pass:
550-checker-multiply-accumulate
564-checker-negbitwise

Test: export ART_USE_VIXL_ARM_BACKEND=true && \
mma test-art-host dist && mma test-art-target dist

Change-Id: I0b057486a8e0e48afbc52dd18b61ea16c671bec2
3395fbc20bcd20948bec8958db91b304c17cacd8 14-Nov-2016 Nicolas Geoffray <ngeoffray@google.com> Revert "Revert "Revert "JIT root tables."""

libcore failures:
dalvikvm32 F 11-14 03:04:06 14870 14870 jit_code_cache.cc:310] Check failed: new_string != nullptr

This reverts commit 75afcdd3503a8a8518e5b23d21b6e73306ce39ce.

Change-Id: I5a6b6b48aa79a763d1ff1ba4d85d63811254787d
75afcdd3503a8a8518e5b23d21b6e73306ce39ce 10-Nov-2016 Nicolas Geoffray <ngeoffray@google.com> Revert "Revert "JIT root tables.""

Also contains Revert "Support kJitTableAddress in x86/arm/arm64."

This reverts commit 4acd03638fcdb4e5d1666f8eec7eb3bf6d6be035.
This reverts commit 997d1217830c0a18b70faeabd53c04700a87d7d9.

Test: ART_USE_READ_BARRIER=true/false test-art-host test-art-target

Change-Id: I77cb1e9bf8f1b4c58b72d3cf5ca31ced2aaa1ea3
00c141aaa07b95a8c2c492b617871abd3cf7162a 10-Nov-2016 Nicolas Geoffray <ngeoffray@google.com> Dump c1visualizer output before and after each pass.

In order to get the last state of a graph before a crash.

Test: dex2oat --dump-cfg
Change-Id: I461a26a47a170b95fadb9da21a443af26fe52181
4acd03638fcdb4e5d1666f8eec7eb3bf6d6be035 09-Nov-2016 Nicolas Geoffray <ngeoffray@google.com> Revert "JIT root tables."

May be the offender for jit-gcstress failure of 902.

This reverts commit ac3ebc3150760425ed00abd56da48f9a6e0666bc.

Change-Id: I9ea6c9236fd1729fed7d1868dd8a111172932308
ca620d7bc03b23a0bcf0ef58df58603ee000dca0 08-Nov-2016 Andreas Gampe <agampe@google.com> ART: Fix tidy warnings

Switch to char versions of find variants.

Add "explicit" constructor variants or refactor and
remove defaults.

Use const references.

Bug: 32619234
Test: m test-art-host
Change-Id: I970cc2f47d6cf8f0c74104b994b075b2fafb3d45
ac3ebc3150760425ed00abd56da48f9a6e0666bc 05-Oct-2016 Nicolas Geoffray <ngeoffray@google.com> JIT root tables.

Implement root tables for the JIT. Each JIT compiled method
gets a table allocated before the stack maps.

The table gets visited through Runtime::SweepSystemWeaks.

Implement String roots for x86_64 as an example.

Test: test-art-host test-art-target

Change-Id: Id3d5bc67479e08b52dd4b253e970201203a0f0d2
2767f4ba2df934fea4c50a016e2955c2cf3f6b19 29-Oct-2016 Aart Bik <ajcbik@google.com> New instruction simplifications. Extra dce pass. Allow more per block repeats.

Rationale:
We were missing some obvious simplifications, which left performance
at the table for e.g. CaffeineLogic compiled with dx (4200us->2700us).
The constant for allowing a repeat on a BB seemed very low, at the
very least it should depend on the BB size.

Test: test-art-host

Change-Id: Ic234566e117593e12c936d556222e4cd4f928105
b0103ca545c285f07e30ba5fd1cc007332fef66b 01-Nov-2016 Roland Levillain <rpl@google.com> Flush the CFG visualizer output after writing to it.

This fixes test failures exposed by the ART Buildbot in
608-checker-unresolved-lse (AOT) on the hammerhead-ndebug
configuration. The test used to fail because the CFG file
dumped by second invocation of dex2oat on device would be
truncated (at the beginning of the disassembly section
of the second compiled Dex file's contents) because of
dex2oat's fast exit.

Interestingly enough, this is the only case where this
failure has been observed, which seems to be due to a
combination of:
- targeting (32-bit) ARM;
- using a secondary Dex file (used to create an unresolved
access for that test);
- compiling that secondary Dex file with dex2oat (ndebug
mode) instead of dex2oatd;
- supporting multithread CFG graph dumping (by having the
write-to-file operation in a critical section) since
https://android-review.googlesource.com/#/c/296224/.

Test: art/test/run-test -O --debuggable 608-checker-unresolved-lse
Change-Id: Ifc1a23a3708b8645fd36c148312074bb9fe00cfc
a0d81af89349dada4586a2770597e27e5c9f0f90 27-Oct-2016 Andreas Gampe <agampe@google.com> ART: Make graph visualizer thread-safe

Store visualizer to a temporary string stream during compilation.
Print to the final output on destruction, and do so under a lock.

Note: the order of methods in the output is only guaranteed to be
deterministic with single-threaded compilation (-j1).

Test: m
Test: Compile multithread
Test: Check output file that begin_compilation and end_compilation
are interleaved
Test: Check that names of compiled methods match

Change-Id: I7eb3be2f88333cf1f116fe71b77cffa1ac702208
639cc8c7bbb7d8c341173bcf24604ccb4328acb8 18-Oct-2016 Aart Bik <ajcbik@google.com> Improve recognition of select-based period induction.

Rationale:
Similar to the previous CL, this helps to eliminate more dead induction.
Now, CaffeineLogic, when compiled with dx (rather than jack) improves
by a 1.5 speedup (9000us -> 6000us).

Note:
We need to run the simplifier before induction analysis to trigger
the select simplification first. Although a bit of a compile-time hit,
it seems a good idea to run a simplifier here again anyway.

Test: test-art-host
Change-Id: I93b91ca40a4d64385c64393028e8d213f0c904a8
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
a7812ae7939b199392f874b24a52454bbd0c13f2 17-Oct-2016 Scott Wakeling <scott.wakeling@linaro.org> ARM: VIXL32: Pass initial ART tests with new code generator.

- Implement enough codegen to pass ~70 art/tests.

- When ART_USE_VIXL_ARM_BACKEND is defined:
- Blacklist known-to-fail target tests
- interpret-only everything except the tests themselves
- Set a flag to use the VIXL based ARM backend

Test: export ART_USE_VIXL_ARM_BACKEND=true && mma test-art-target && mma test-art-host

Change-Id: Ic8bc095e8449f10f97fa0511284790f36c20e276
e8a3c576301fd531d5f73a65fc8b84a63619d580 12-Oct-2016 Mathieu Chartier <mathieuc@google.com> Replace StackHandleScopeCollection with VariableSizedHandleScope

VariableSizedHandleScope's internal handle scopes are not pushed
directly on the thread. This means that it is safe to intermix with
other types of handle scopes.

Added test.

Test: clean-oat-host && test-art-host

Change-Id: Id2fd1155788428f394d49615d337d9134824c8f0
97d7e1cd7f733cb33a0e238bec6d7ed525638cd1 04-Oct-2016 Vladimir Marko <vmarko@google.com> Remove #include "oat_file.h" from class_linker.h .

Refactor the OatClass and OatMethod related functions from
ClassLinker to OatFile and ArtMethod, respectively. Refactor
the remaining ClassLinker dependencies on OatFile to break
the #include dependency and reduce incremental build times.

Test: m test-art-host
Change-Id: Iebc5b9f81b48fbcf79821cc827a5d7c4a0261bf6
ebe167422f6197b9df0698bbeb944a0e4eea5f2d 05-Oct-2016 Nicolas Geoffray <ngeoffray@google.com> Properly scope HLoopOptimization's allocator.

HOptimization classes do not get their destructor called,
as they are arena objects. So the scope for the optimization
allocator needs to be the Run method.

Also anticipate bisection search breakage by adding
HLoopOptimization to the list of recognized optimizations.

Change-Id: I7770989c39d5700a3b6b0a20af5d4b874dfde111
281c681a0852c10f5ca99b351650b244e878aea3 26-Aug-2016 Aart Bik <ajcbik@google.com> A first implementation of a loop optimization framework.

Rationale:
We are planning to add more and more loop related optimizations
and this framework provides the basis to do so. For starters,
the framework optimizes dead induction, induction that can be
replaced with a simpler closed-form, and eliminates dead loops
completely (either pre-existing or as a result of induction
removal).

Speedup on e.g. Benchpress Loop is 73x (17.5us. -> 0.24us.)
[with the potential for more exploiting outer loop too]

Test: 618-checker-induction et al.

Change-Id: If80a809acf943539bf6726b0030dcabd50c9babc
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
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
68c981fad87720fae9c799b240141ce3c12cd5bf 26-Aug-2016 Vladimir Marko <vmarko@google.com> ARM/MIPS: Avoid dead dex cache arrays base for intrinsics.

Test: Run ART test suite on host and Nexus 6.
Change-Id: Ie2ad70f1e3f125eae5dad53a6384d405e0311505
b6a12832943fcf838d89134158208c8a2e47f49f 17-Aug-2016 Wojciech Staszkiewicz <staszkiewicz@google.com> Use full pass name when building optimizations

If possible, use full pass name provided in --run-passes rather
than its base version.

Test: m test-art-host -j32

1. Prepare a run-passes file with content:
dead_code_elimination$initial
instruction_simplifier
x86_memory_operand_generation
2. Run art for a dex file like:
art -Xcompiler-option --run-passes=run-passes -Xcompiler-option
--dump-passes -classpath classes.dex Test
3. Verify that dead_code_elimination$initial string is present in
dump-passes output.

Change-Id: I92d9ed0c8b919ea03f625f549123f546dffe546b
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
e28c7d022b73cff58d0a9bcbaa5cfdc0950fe003 18-Aug-2016 Wojciech Staszkiewicz <staszkiewicz@google.com> Fix optimizing compiler not building for svelte

Fixes compiler not building when some of the codegen paths
are disabled.

Test: mmma -j art ART_TARGET_CODEGEN_ARCHS=svelte
m -j32 test-art-host

BUG=30928847

Change-Id: I52c78e8a4e507f74b1f2a39352970079721b737e
e706070b271945d60229736a15bb712f3061fd15 17-Aug-2016 Wojciech Staszkiewicz <staszkiewicz@google.com> Log optimization passes in verbose mode

Introduce verbose logging of optimization passes run during
compilation.

Test: m test-art-host -j32
art -Xcompiler-option --runtime-arg -Xcompiler-option -verbose:compiler
-classpath classes.dex Test
Change-Id: Iae98ce9dcafc252f2d0eec138aa05b34e424bd2a
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
5319d3cca5a9b8e9e3f59421818272b966575172 02-Aug-2016 Wojciech Staszkiewicz <staszkiewicz@google.com> Implement running user defined list of passes

This change introduces new dex2oat switch --run-passes=. This switch
accepts path to a text file with names of passes to run.
Compiler will run optimization passes specified in the file rather
then the default ones.

There is no verification implemented on the compiler side. It is user's
responsibility to provide a list of passes that leads to successful
generation of correct code. Care should be taken to prepare a list
that satisfies all dependencies between optimizations.

We only take control of the optional optimizations. Codegen (builder),
and all passes required for register allocation will run unaffected
by this mechanism.

Change-Id: Ic3694e53515fefcc5ce6f28d9371776b5afcbb4f
2cd05b7d9976c0c7fa74d58cb1608c809e5c37d3 04-Aug-2016 Matthew Gharrity <gharrma@google.com> Add a register allocation strategy compiler option

Test: manually, on device.

Change-Id: If007a1657dd5769ddef03691e0a19dbbe6ba1a29
06a46c44bf1a5cba6c78c3faffc4e7ec1442b210 20-Jul-2016 Alexey Frunze <Alexey.Frunze@imgtec.com> MIPS32: Improve string and class loads

Tested:
- MIPS32 Android boots in QEMU
- test-art-host-gtest
- test-art-target-run-test-optimizing in QEMU, on CI20
- test-art-target-gtest on CI20

Change-Id: I70fd5d5267f8594c3b29d5a4ccf66b8ca8b09df3
f5fb09035da52a07e9df81cdcb4b025edb0db113 22-Jul-2016 Wojciech Staszkiewicz <staszkiewicz@google.com> Make static helper methods member functions of OptimizingCompiler class

Make RunOptimizations, MaybeRunInliner and RunArchOptimizations member
functions of OptimizingCompiler class.

Both versions of RunOptimizations are protected in preparation for
bisection bug search CL.

Change-Id: I596efa9ed3fccd1ed3798c6427cc166e2a5d28bd
328429ff48d06e2cad4ebdd3568ab06de916a10a 06-Jul-2016 Artem Serov <artem.serov@linaro.org> ARM: Port instr simplification of array accesses.

After changing the addressing mode for array accesses (in
https://android-review.googlesource.com/248406) the 'add'
instruction that calculates the base address for the array can be
shared across accesses to the same array.

Before https://android-review.googlesource.com/248406:
add IP, r[Array], r[Index0], LSL #2
ldr r0, [IP, #12]
add IP, r[Array], r[Index1], LSL #2
ldr r0, [IP, #12]

Before this CL:
add IP. r[Array], #12
ldr r0, [IP, r[Index0], LSL #2]
add IP. r[Array], #12
ldr r0, [IP, r[Index1], LSL #2]

After this CL:
add IP. r[Array], #12
ldr r0, [IP, r[Index0], LSL #2]
ldr r0, [IP, r[Index1], LSL #2]

Link to the original optimization:
https://android-review.googlesource.com/#/c/127310/

Test: Run ART test suite on Nexus 6.
Change-Id: Iee26f9a0a7ca46abb90e3f60d19d22dc8dee4d8f
8f49d4b04bab40bfd32ed7c8dfe501dea172bd79 14-Jul-2016 Matthew Gharrity <gharrma@google.com> Refactor register allocation to be pluggable

Allow alternate register allocation strategies to be implemented
in subclasses of a common register allocation base class.

Test: m test-art-host

Change-Id: I7c5866aa9ddff8f53fcaf721bad47654ab221b4f
e9288851eb6b62ece28f510d978d3793723b9a51 14-Jul-2016 Matthew Gharrity <gharrma@google.com> Rename current register allocator implementation

This will allow a cleaner commit in an upcoming
refactoring of register allocation.

Test: m test-art-host

Change-Id: If420c97b088b3c934411ff83373e024003120746
ee8d971b14edfc1e0af9436fd223277df966e4c2 12-Jul-2016 Mark Mendell <mark.p.mendell@intel.com> X86: Use memory to do array range checks

Currently, an HBoundsCheck is fed by an HArrayLength, causing a load of
the array length, followed by a register compare.

Avoid the load when we can by comparing directly with the array length
in memory. Implement this by marking the HArrayLength as 'emitted at
use site', and then generating the code in the HBoundsCheck.

Only do this replacement when we are the only user of the ArrayLength
and it isn't visible to the environment.

Handle the special case where the array is 'null' and where an implicit
null check can't be eliminated.

This code moves the load of the length to the slow code for the failed
check, which is what we want.

Test: 609-checker-x86-bounds-check

Change-Id: I9cdb183301e048234bb0ffeda940eedcf4a655bd
Signed-off-by: Mark Mendell <mark.p.mendell@intel.com>
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
2f116815ae4344c30a9eab1984563b3d969bd769 07-Jun-2016 Nicolas Geoffray <ngeoffray@google.com> Revert "Revert "Fix ArtMethod::GetInvokeType for static methods on interfaces.""

bug:29089267
bug:27521545

We were hitting a compiler DCHECK that a class would never require to
do access checks on itself. The reason was that the compiler driver
was not trying to resolve a type, but instead relied on the verifier
for pre-populating the dex cache. However, the verifier doesn't
necessarily run in JIT mode.

This reverts commit 12abcbd950bd0ff4528e2e0d27ca5e881c7b0467.

(cherry picked from commit 3aaf9645639ff56fbfe49a981242cbda01d6796e)

Change-Id: I2f0de6e4f00f336dc61b2378054fb6d27a7298d0
3aaf9645639ff56fbfe49a981242cbda01d6796e 07-Jun-2016 Nicolas Geoffray <ngeoffray@google.com> Revert "Revert "Fix ArtMethod::GetInvokeType for static methods on interfaces.""

bug:29089267
bug:27521545

We were hitting a compiler DCHECK that a class would never require to
do access checks on itself. The reason was that the compiler driver
was not trying to resolve a type, but instead relied on the verifier
for pre-populating the dex cache. However, the verifier doesn't
necessarily run in JIT mode.

This reverts commit 12abcbd950bd0ff4528e2e0d27ca5e881c7b0467.

Change-Id: I59204c16927084f6605a2a3f999ca529f949e1ad
12abcbd950bd0ff4528e2e0d27ca5e881c7b0467 06-Jun-2016 Nicolas Geoffray <ngeoffray@google.com> Revert "Fix ArtMethod::GetInvokeType for static methods on interfaces."

bug:29089267
bug:27521545

Fails some DHECKs.

This reverts commit 808067335b228d7b50ad84123d3c8ecb7aeeb200.

Change-Id: I0e768ce85be593e3f50fd02abc29aa34f2be3562
808067335b228d7b50ad84123d3c8ecb7aeeb200 02-Jun-2016 Nicolas Geoffray <ngeoffray@google.com> Fix ArtMethod::GetInvokeType for static methods on interfaces.

And avoid calling ResolveMethod in the JIT, since it already
knows that method.

bug:29089267
bug:27521545

(cherry picked from commit 2dc77ecf375882f51ff7c09712c05b80e58abb6b)

Change-Id: I36084b1f207317452c42fdfc8ffa4d8c721d2f76
2dc77ecf375882f51ff7c09712c05b80e58abb6b 02-Jun-2016 Nicolas Geoffray <ngeoffray@google.com> Fix ArtMethod::GetInvokeType for static methods on interfaces.

And avoid calling ResolveMethod in the JIT, since it already
knows that method.

bug:29089267
bug:27521545

Change-Id: I5c5dae385804f1d2062defca459f69c26cdb4fef
62e631a678ef18c80f37862a2dc74004954a8502 20-Apr-2016 Nicolas Geoffray <ngeoffray@google.com> Add flag to ArtMethod to skip compilation.

To ensure even the JIT will not try to compile methods with
soft failures a runtime_throw.

bug:28293819
bug:28313047

(cherry picked from commit 250a378d5a2152662e0fa820f2b38f794ddd3596)

Change-Id: Ic6d019bc2dd24e35e1377a6c3f8530348c1049df
250a378d5a2152662e0fa820f2b38f794ddd3596 20-Apr-2016 Nicolas Geoffray <ngeoffray@google.com> Add flag to ArtMethod to skip compilation.

To ensure even the JIT will not try to compile methods with
soft failures a runtime_throw.

bug:28293819
bug:28313047

Change-Id: Ie3fd71ded0b77de8dab1c3c825b867cb321b8873
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
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
dee58d6bb6d567fcd0c4f39d8d690c3acaf0e432 07-Apr-2016 David Brazdil <dbrazdil@google.com> Revert "Revert "Refactor HGraphBuilder and SsaBuilder to remove HLocals""

This patch merges the instruction-building phases from HGraphBuilder
and SsaBuilder into a single HInstructionBuilder class. As a result,
it is not necessary to generate HLocal, HLoadLocal and HStoreLocal
instructions any more, as the builder produces SSA form directly.

Saves 5-15% of arena-allocated memory (see bug for more data):
GMS 20.46MB => 19.26MB (-5.86%)
Maps 24.12MB => 21.47MB (-10.98%)
YouTube 28.60MB => 26.01MB (-9.05%)

This CL fixed an issue with parsing quickened instructions.

Bug: 27894376
Bug: 27998571
Bug: 27995065

Change-Id: I20dbe1bf2d0fe296377478db98cb86cba695e694
60328910cad396589474f8513391ba733d19390b 04-Apr-2016 David Brazdil <dbrazdil@google.com> Revert "Refactor HGraphBuilder and SsaBuilder to remove HLocals"

Bug: 27995065
This reverts commit e3ff7b293be2a6791fe9d135d660c0cffe4bd73f.

Change-Id: I5363c7ce18f47fd422c15eed5423a345a57249d8
9d07e3d128ccfa0ef7670feadd424a825e447d1d 31-Mar-2016 Vladimir Marko <vmarko@google.com> Clean up OatQuickMethodHeader after Quick removal.

This reduces the size of the pre-header by 8 bytes, reducing
oat file size and mmapped .text section size. The memory
needed to store a CompiledMethod by dex2oat is also reduced,
for 32-bit dex2oat by 8B and for 64-bit dex2oat by 16B. The
aosp_flounder-userdebug 32-bit and 64-bit boot.oat are each
about 1.1MiB smaller.

Disable the broken StubTest.IMT, b/27991555 .

Change-Id: I05fe45c28c8ffb7a0fa8b1117b969786748b1039
e3ff7b293be2a6791fe9d135d660c0cffe4bd73f 02-Mar-2016 David Brazdil <dbrazdil@google.com> Refactor HGraphBuilder and SsaBuilder to remove HLocals

This patch merges the instruction-building phases from HGraphBuilder
and SsaBuilder into a single HInstructionBuilder class. As a result,
it is not necessary to generate HLocal, HLoadLocal and HStoreLocal
instructions any more, as the builder produces SSA form directly.

Saves 5-15% of arena-allocated memory (see bug for more data):
GMS 20.46MB => 19.26MB (-5.86%)
Maps 24.12MB => 21.47MB (-10.98%)
YouTube 28.60MB => 26.01MB (-9.05%)

Bug: 27894376
Change-Id: Iefe28d40600c169c5d306fd2c77034ae19476d90
86ea7eeabe30c98bbe1651a51d03cb89776724e7 16-Feb-2016 David Brazdil <dbrazdil@google.com> Build dominator tree before generating HInstructions

Second CL in the series of merging HGraphBuilder and SsaBuilder. This
patch refactors the builders so that dominator tree can be built
before any HInstructions are generated. This puts the SsaBuilder
removal of HLoadLocals/HStoreLocals straight after HGraphBuilder's
HInstruction generation phase. Next CL will therefore be able to
merge them.

This patch also adds util classes for iterating bytecode and switch
tables which allowed to simplify the code.

Bug: 27894376
Change-Id: Ic425d298b2e6e7980481ed697230b1a0b7904526
df739841b781dbd49c247e3795696389c4799020 23-Mar-2016 Vladimir Marko <vmarko@google.com> Post-Quick cleanup: Remove CompilationUnit.

Change-Id: I309411b0fffaaed1e218e2c34394bdf6e2f75b48
7bcfcb80a31f57a84d754e00bca8698829365208 23-Mar-2016 Andreas Gampe <agampe@google.com> Revert "Revert "Use compiler filter to determine oat file status.""

This reverts commit 845e5064580bd37ad5014f7aa0d078be7265464d.

Add an option to change what OatFileManager considers up-to-date.
In our tests we're allowed to write to the dalvik-cache, so it
cannot be kSpeed.

(cherry picked from commit 29d38e77c553c6cf71fc4dafe2d22b4e3f814872)

Bug: 27689078
Change-Id: I6274188610f31dcd9d086fc080b2be93afae5a6b
29d38e77c553c6cf71fc4dafe2d22b4e3f814872 23-Mar-2016 Andreas Gampe <agampe@google.com> Revert "Revert "Use compiler filter to determine oat file status.""

This reverts commit 845e5064580bd37ad5014f7aa0d078be7265464d.

Add an option to change what OatFileManager considers up-to-date.
In our tests we're allowed to write to the dalvik-cache, so it
cannot be kSpeed.

Bug: 27689078
Change-Id: I0c578705a9921114ed1fb00d360cc7448addc93a
845e5064580bd37ad5014f7aa0d078be7265464d 23-Mar-2016 Nicolas Geoffray <ngeoffray@google.com> Revert "Use compiler filter to determine oat file status."

Bots are red. Tentative reverting as this is likely the offender.

Bug: 27689078

This reverts commit a62d2f04a6ecf804f8a78e722a6ca8ccb2dfa931.

Change-Id: I3ec6947a5a4be878ff81f26f17dc36a209734e2a
a62d2f04a6ecf804f8a78e722a6ca8ccb2dfa931 18-Mar-2016 Richard Uhler <ruhler@google.com> Use compiler filter to determine oat file status.

Record the compiler filter in the oat header. Use that to determine
when the oat file is up-to-date with respect to a target compiler
filter level.

New xxx-profile filter levels are added to specify if a profile should
be used instead of testing for the presence of a profile file.

This change should allow for different compiler-filters to be set for
different package manager use cases.

Bug: 27689078
Change-Id: Id6706d0ed91b45f307142692ea4316aa9713b023
3a40bf2fc1b9823e3bc8fcf96d5242668b5c088b 22-Mar-2016 Vladimir Marko <vmarko@google.com> ART: Clean up arena allocation memory tracking.

Remove unused allocation types, mostly from removed Quick.
Move logging one level up to capture memory used by stack
maps during AOT compilation. Raise the reporting threshold
to 8MiB to limit the output to the worst offenders.

Change-Id: I8c7a01bfa90bc8ec5eab66187eb6850a022f3543
933330a192d43d7c7304120999907857a89c2f96 16-Mar-2016 Nicolas Geoffray <ngeoffray@google.com> Add more statistics for memory use of the JIT.

Collect data for stack maps, profiling info, and compiled code.

bug:27520994

Change-Id: Ic87361230c96ce0090027a37d750e948d806c597
2ae48182573da7087bffc2873730bc758ec29696 16-Mar-2016 Calin Juravle <calin@google.com> Clean up NullCheck generation and record stats about it.

This removes redundant code from the generators and allows for easier
stat recording.

Change-Id: Iccd4368f9e9d87a6fecb863dee4e2145c97851c4
a4f81546373f4cb5fa6dfc135307ee0a1d930872 08-Mar-2016 Nicolas Geoffray <ngeoffray@google.com> Collect memory use for the JIT.

bug:27520994

Change-Id: I67b0c5b822001bfde8738a988c1ade69f1a26e3f
09c2a6be63337ee060e2d54bd01cf18be7301d29 11-Mar-2016 David Srbecky <dsrbecky@google.com> Add trampoline symbols to native debug info.

The debugger needs them to unwind through the trampolines and to
understand what is happening in the call stack.

Change-Id: Ia554058c3796788adcd7336d620a7734eb366905
d1c4045fb4d4703642f3f79985727b9a12cf5c49 03-Mar-2016 Aart Bik <ajcbik@google.com> Avoid generating dead code on frame enter/exit.
This includes stack operations and, on x86, call/pop to read PC.

bug=26997690

Rationale:
(1) If method is fully intrinsified, and makes no calls in slow
path or uses special input, no need to require current method.
(2) Invoke instructions with HasPcRelativeDexCache() generate code
that reads the PC (call/pop) on x86. However, if the invoke is
an intrinsic that is later replaced with actual code, this PC
reading code may be dead.

Example X86 (before/after):

0x0000108c: 83EC0C sub esp, 12
0x0000108f: 890424 mov [esp], eax <-- not needed
0x00001092: E800000000 call +0 (0x00001097)
0x00001097: 58 pop eax <-- dead code to read PC
0x00001098: F30FB8C1 popcnt eax, ecx
0x0000109c: F30FB8DA popcnt ebx, edx
0x000010a0: 03D8 add ebx, eax
0x000010a2: 89D8 mov eax, ebx
0x000010a4: 83C40C add esp, 12 <-- not needed
0x000010a7: C3 ret

0x0000103c: F30FB8C1 popcnt eax, ecx
0x00001040: F30FB8DA popcnt ebx, edx
0x00001044: 03D8 add ebx, eax
0x00001046: 89D8 mov eax, ebx
0x00001048: C3 ret

Example ARM64 (before/after):

0x0000103c: f81e0fe0 str x0, [sp, #-32]!
0x00001040: f9000ffe str lr, [sp, #24]
0x00001044: dac01020 clz x0, x1
0x00001048: f9400ffe ldr lr, [sp, #24]
0x0000104c: 910083ff add sp, sp, #0x20 (32)
0x00001050: d65f03c0 ret

0x0000103c: dac01020 clz x0, x1
0x00001040: d65f03c0 ret

Change-Id: I8377db80c9a901a08fff4624927cf4a6e585da0c
fe736b775c7774bb2f7072e022099ca47dd21a3c 09-Mar-2016 David Srbecky <dsrbecky@google.com> Allow generation of native debug info for multiple methods.

Slight tweak in the API which I will need in the near future.

Change-Id: I45954ae16710bc941a9a06a3a17c70798315ca53
197160d47f34238cb5e7444fa4c2de300db8e2c6 07-Mar-2016 David Srbecky <dsrbecky@google.com> Refactor MethodDebugInfo (input of DWARF writer).

Do not pass CompiledMethod pointer through since it is only available
during AOT compile but not during JIT compile or at runtime. Creating
mock CompiledMethod just pass data is proving increasingly tricky, so
copy the fields that we need to MethodDebugInfo instead.

Change-Id: I820297b41e769fcac488c0ff2d2ea0492bb13ed8
91cc06c1814bd1d0fd6635bc3d7632a2bb7b0e7c 07-Mar-2016 David Srbecky <dsrbecky@google.com> Mark DWARF lines in non-debuggable methods as "not a statement".

This is a hint to the debugger that breakpoints and stepping
might not function as intended (since we have limited information).

Change-Id: I23c4a816182cc7548fcd69fbd00112225e7b1710
5d8112029d0e085c5a0099257daa4c7e29c12310 08-Mar-2016 David Srbecky <dsrbecky@google.com> Propagate InstructionSetFeatures to ElfBuilder.

This is subset of CL171665 and it separates it into two.
It will be needed to generate .MIPS.abiflags ELF section.

Change-Id: I5557e7cb98d0fa1dc57c85cf6161e119c6d50a1a
700347e9bc6c2ed29046e0c13122a5ad57d2fc51 02-Mar-2016 Mingyao Yang <mingyao@google.com> Add a PassScope for PrepareForRegisterAllocation

This pass does transform the graph so make it part of cfg-dumping.

Change-Id: I42e361382c85c97b974faad8bb0fcf2cb0750355
25e0456b6ea13eba290b63ea88b6b7120ed89413 01-Mar-2016 Nicolas Geoffray <ngeoffray@google.com> Give the JIT its own arena pool to avoid lock contentions.

Sharing it with the verifier and the class loader is not ideal,
especially at startup time.

bug:27398183
bug:23128949
Change-Id: I1b91663a13f6c5b33ad3b4be780d93eb7fe445b4
4a0dad67867f389e01a5a6c0fe381d210f687c0d 25-Jan-2016 Artem Udovichenko <artem.u@samsung.com> Revert "Revert "ARM/ARM64: Extend support of instruction combining.""

This reverts commit 6b5afdd144d2bb3bf994240797834b5666b2cf98.

Change-Id: Ic27a10f02e21109503edd64e6d73d1bb0c6a8ac6
38e9e8046ea2196284bdb4638771c31108a30a4a 18-Feb-2016 Jean-Philippe Halimi <jean-philippe.halimi@intel.com> Add statistics support for some optimizations

This patch adds support for the --dump-stats facility with some
optimizations
and fixes all build issues introduced by the patch:
I68751b119a030952a11057cb651a3c63e87e73ea (which got reverted)

Change-Id: I5af1f2a8cced0a1a55c2bb4d8c88e6f0a24ec879
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
badd826664896d4a9628a5a89b78016894aa414b 02-Feb-2016 David Brazdil <dbrazdil@google.com> ART: Run SsaBuilder from HGraphBuilder

First step towards merging the two passes, which will later result in
HGraphBuilder directly producing SSA form. This CL mostly just updates
tests broken by not being able to inspect the pre-SSA form.

Using HLocals outside the HGraphBuilder is now deprecated.

Bug: 27150508
Change-Id: I00fb6050580f409dcc5aa5b5aa3a536d6e8d759e
c5bfa97c47d656b76f297af8abcd5f7502987399 05-Feb-2016 David Srbecky <dsrbecky@google.com> Split elf_writer_debug.cc to several files.

Refactoring only. The file has grown significantly over time,
and it is time to split it so it can be better managed.

Change-Id: Idce0231718add722292f4701df353d5baf31de5f
4fda4eb799c95be266f52aaf3461a440ea86b841 05-Feb-2016 David Srbecky <dsrbecky@google.com> Move code related to debug info generation to its own directory.

debug/dwarf/ contains helper classes which hide the details
of the DWARF file format. It acts as independent DWARF library.

debug/ contains ART-specific code which generates ELF debug
sections (which includes non-DWARF sections like .symtab).

Change-Id: Id351f604e4e64be2ca395a78324ea02e30481497
b331febbab8e916680faba722cc84b66b84218a3 05-Feb-2016 Nicolas Geoffray <ngeoffray@google.com> Revert "Revert "Implement on-stack replacement for arm/arm64/x86/x86_64.""

This reverts commit bd89a5c556324062b7d841843b039392e84cfaf4.

Change-Id: I08d190431520baa7fcec8fbdb444519f25ac8d44
bd89a5c556324062b7d841843b039392e84cfaf4 05-Feb-2016 David Brazdil <dbrazdil@google.com> Revert "Implement on-stack replacement for arm/arm64/x86/x86_64."

DCHECK whether loop headers are covered fails.

This reverts commit 891bc286963892ed96134ca1adb7822737af9710.

Change-Id: I0f9a90630b014b16d20ba1dfba31ce63e6648021
891bc286963892ed96134ca1adb7822737af9710 29-Jan-2016 Nicolas Geoffray <ngeoffray@google.com> Implement on-stack replacement for arm/arm64/x86/x86_64.

High-level overview:
- osr_method_threshold is used to know when to compile a method
in osr mode (-> treat all loops as irreducible).
- branch instructions in the compiler query whether they can
jump to an osr method.
- An osr entry point is found through the stack maps: if a stack
map is duplicated in the CodeInfo, it is an osr entry point.

Change-Id: Ifb39338cd281e2c7eccce67f4e18d46428be71e4
74eb1b264691c4eb399d0858015a7fc13c476ac6 14-Dec-2015 David Brazdil <dbrazdil@google.com> ART: Implement HSelect

This patch adds a new HIR instruction to Optimizing. HSelect returns
one of two inputs based on the outcome of a condition.

This is only initial implementation which:
- defines the new instruction,
- repurposes BooleanSimplifier to emit it,
- extends InstructionSimplifier to statically resolve it,
- updates existing code and tests accordingly.

Code generators currently emit fallback if/then/else code and will be
updated in follow-up CLs to use platform-specific conditional moves
when possible.

Change-Id: Ib61b17146487ebe6b55350c2b589f0b971dcaaee
5b1c2ca30dad519be285f0a1e839c23cc4e3a51d 25-Jan-2016 David Srbecky <dsrbecky@google.com> Revert "Revert "Add option to generate compressed backtrace info.""

This reverts commit 8546cc9aeb05e866e1fb6a9e4130d53ea330baa8.

Change-Id: I676fdf9af27fa3b16fa8921778ff8832ab8c437d
8546cc9aeb05e866e1fb6a9e4130d53ea330baa8 25-Jan-2016 David Srbecky <dsrbecky@google.com> Revert "Add option to generate compressed backtrace info."

This reverts commit 5fdcc3c931b70204fd8c491afa66f57f8428490f.

Change-Id: I9c1f5aad6933a46af6717e3a90a51f76111f9c8a
5fdcc3c931b70204fd8c491afa66f57f8428490f 19-Jan-2016 David Srbecky <dsrbecky@google.com> Add option to generate compressed backtrace info.

Add flag --generate-mini-debug-info which generates
LZMA compressed .symtab and .debug_frame, which are
sufficient to print java backtraces in libunwind.

If enabled, it increases the size of boot.oat by about 3.5%.

Change-Id: Ic3c2ef7704c05fa328720c6781ca2a9b8e3935a3
6b5afdd144d2bb3bf994240797834b5666b2cf98 22-Jan-2016 Nicolas Geoffray <ngeoffray@google.com> Revert "ARM/ARM64: Extend support of instruction combining."

The test fails its checker parts.

This reverts commit debeb98aaa8950caf1a19df490f2ac9bf563075b.

Change-Id: I49929e15950c7814da6c411ecd2b640d12de80df
debeb98aaa8950caf1a19df490f2ac9bf563075b 11-Dec-2015 Ilmir Usmanov <i.usmanov@samsung.com> ARM/ARM64: Extend support of instruction combining.

Combine multiply instructions in the following way:
ARM64:
MUL/NEG -> MNEG
ARM32 (32-bit integers only):
MUL/ADD -> MLA
MUL/SUB -> MLS

Change-Id: If20f2d8fb060145ab6fbceeb5a8f1a3d02e0ecdb
58282f4510961317b8d5a364a6f740a78926716f 14-Jan-2016 David Brazdil <dbrazdil@google.com> ART: Remove Baseline compiler

We don't need Baseline any more and it hasn't been maintained for
a while anyway. Let's remove it.

Change-Id: I442ed26855527be2df3c79935403a25b1ee55df6
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
15bd22849ee6a1ffb3fb3630f686c2870bdf1bbc 05-Jan-2016 Nicolas Geoffray <ngeoffray@google.com> Implement irreducible loop support in optimizing.

So we don't fallback to the interpreter in the presence of
irreducible loops.

Implications:
- A loop pre-header does not necessarily dominate a loop header.
- Non-constant redundant phis will be kept in loop headers, to
satisfy our linear scan register allocation algorithm.
- while-graph optimizations, such as gvn, licm, lse, and dce
need to know when they are dealing with irreducible loops.

Change-Id: I2cea8934ce0b40162d215353497c7f77d6c9137e
86e4278d5edc3685465b8846dcb17efa83c86d75 05-Jan-2016 Tamas Berghammer <tberghammer@google.com> Add DWARF type information generation.

Emit native debugging information for types which are used during
compilation.

Change-Id: If28d19f60294494b7c6db8400d179494bebe9e61
5cc349f3dd578e974f78314c50b6a0267c23e591 18-Dec-2015 David Srbecky <dsrbecky@google.com> Report DWARF debug information for JITed code.

Change-Id: Ia5b2133c54386932c76c22774cf3d2ae61e0925f
15693bfdf9fa3ec79327a77b7e10315614d716cc 16-Dec-2015 David Brazdil <dbrazdil@google.com> ART: Resolve ambiguous ArraySets

Just like aget(-wide), the value operand of aput(-wide) bytecode
instructions can be both int/long and float/double. This patch builds
on the previous mechanism for resolving type of ArrayGets to type the
values of ArraySets based on the reference type of the array.

Bug: 22538329

Change-Id: Ic86abbb58de146692de04476b555010b6fcdd8b6
5949fa0cb9a8d26ac20b9b02065a63b4b20443be 18-Dec-2015 Nicolas Geoffray <ngeoffray@google.com> Revert "Revert "Tweak inlining heuristics.""

This reverts commit b17d1ccff0ac26fc22df671907ba2b4f4c656ce4.

Change-Id: I26f6f8702a448c3da12662cbc6bc0f6e562bc40b
4833f5a1990c76bc2be89504225fb13cca22bedf 16-Dec-2015 David Brazdil <dbrazdil@google.com> ART: Refactor SsaBuilder for more precise typing info

This reverts commit 68289a531484d26214e09f1eadd9833531a3bc3c.

Now uses Primitive::Is64BitType instead of Primitive::ComponentSize
because it was incorrectly optimized by GCC.

Bug: 26208284
Bug: 24252151
Bug: 24252100
Bug: 22538329
Bug: 25786318

Change-Id: Ib39f3da2b92bc5be5d76f4240a77567d82c6bebe
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
b17d1ccff0ac26fc22df671907ba2b4f4c656ce4 17-Dec-2015 Nicolas Geoffray <ngeoffray@google.com> Revert "Tweak inlining heuristics."

This reverts commit fcb7613d3aaa9a6802800b6e957aaad51cedf6dc.

Change-Id: Idc0df6a2f68e8b5aa740bb1259f19c2953811510
fcb7613d3aaa9a6802800b6e957aaad51cedf6dc 17-Dec-2015 Nicolas Geoffray <ngeoffray@google.com> Tweak inlining heuristics.

go/lem driven:

Performance:
Richards +41%
CaffeineMethod +43%
ReversiBench: +52%
Towers: +73%
Tak: +85%

Memory use: 7% less memory
CompileTime: 14% increase
CodeSize: 8% increase

Last three measures are now more acceptable given we JIT.

Change-Id: Ic4aa6535d2b76cf3545ef00e9b2ae32330f10745
68289a531484d26214e09f1eadd9833531a3bc3c 16-Dec-2015 Alex Light <allight@google.com> Revert "ART: Refactor SsaBuilder for more precise typing info"

This reverts commit d9510dfc32349eeb4f2145c801f7ba1d5bccfb12.

Bug: 26208284

Bug: 24252151
Bug: 24252100
Bug: 22538329
Bug: 25786318

Change-Id: I5f491becdf076ff51d437d490405ec4e1586c010
d9510dfc32349eeb4f2145c801f7ba1d5bccfb12 05-Nov-2015 David Brazdil <dbrazdil@google.com> ART: Refactor SsaBuilder for more precise typing info

This patch refactors the SsaBuilder to do the following:

1) All phis are constructed live and marked dead if not used or proved
to be conflicting.

2) Primitive type propagation, now not a separate pass, identifies
conflicting types and marks corresponding phis dead.

3) When compiling --debuggable, DeadPhiHandling used to revive phis
which had only environmental uses but did not attempt to resolve
conflicts. This pass was removed as obsolete and is now superseded
by primitive type propagation (identifying conflicting phis) and
SsaDeadPhiEliminiation (keeping phis live if debuggable + env use).

4) Resolving conflicts requires correct primitive type information
on all instructions. This was not the case for ArrayGet instructions
which can have ambiguous types in the bytecode. To this end,
SsaBuilder now runs reference type propagation and types ArrayGets
from the type of the input array.

5) With RTP being run inside the SsaBuilder, it is not necessary to
run it as a separate optimization pass. Optimizations can now assume
that all instructions of type kPrimNot have reference type info after
SsaBuilder (with the exception of NullConstant).

6) Graph now contains a reference type to be assigned to NullConstant.
All reference type instructions therefore have RTI, as now enforced
by the SsaChecker.

Bug: 24252151
Bug: 24252100
Bug: 22538329
Bug: 25786318

Change-Id: I7a3aee1ff66c82d64b4846611c547af17e91d260
f71b3ade9c99ce2fec2f5049ce9c5968721e1b81 08-Dec-2015 David Srbecky <dsrbecky@google.com> Get source mapping table from stack maps.

Stack maps contain pc to dex mapping.
Reuse them instead of maintaining separate map.

Change-Id: Iaaec9a6bd2603eace1dfc8f4344087883d88cce3
8993caf6571863c8e5eec0b2ce4d72f6f1793f31 07-Dec-2015 David Brazdil <dbrazdil@google.com> ART: Enable all optimizations except LSE under try/catch

Dynamic BCE now updates try/catch information during basic block
manipulation and can be enabled. The last missing optimization is LSE.
This patch removes all special-casing from optimizing_compiler.cc and
bails inside LSE instead.

Change-Id: Ie0c6fde7295880ea55d35571455a617fce2b7580
73be1e8f8609708f6624bb297c9628de44fd8b6f 17-Sep-2015 Nicolas Geoffray <ngeoffray@google.com> Inline monomorphic calls.

Change-Id: If38171c2dc7d4a4378df5d050afc4fff4499c98f
4a34277c55279ba57ab361f7580db846a201d9b1 30-Nov-2015 Aart Bik <ajcbik@google.com> Dynamic BCE (based on induction range analysis)

Rationale:
A rewritten dynamic BCE that uses induction variable analysis
to generate the run-time tests before a loop in order to
eliminate bounds-checks from its body. This CL removes now
obsoleted induction related code inside the BCE module.
Also, the dynamic test generation is placed more strategically,
since we missed a few cases where static analysis does better.

Most significant performance improvements (filtering noise) is about:

Linpack +20%
LU > +10%

Change-Id: I03d7631857154b6a131b132f26a2dc568af1b3a1
ad543383b5883d6e32993efaefc704eff3225ffe 19-Nov-2015 Calin Juravle <calin@google.com> Clean up optimizing compiler stats

- removed unused stats.
- add 'OptStat' prefix to the names of the printed
stats to make them `grep` friendly.

Change-Id: I189e98b5226465c88c4a00247cd0b9b2ddb6d66e
b4536b7de576b20c74c612406c5d3132998075ef 24-Nov-2015 Vladimir Marko <vmarko@google.com> Optimizing/ARM: Implement kDexCachePcRelative dispatch.

Change-Id: I0fe2da50a30a3f62bec8ea01688dd1fec84b1831
22ccc3a93d32fa6991535eaebb17daf5abaf4ebf 24-Nov-2015 Roland Levillain <rpl@google.com> ARM64 read barrier support for concurrent GC in Optimizing.

This first implementation uses slow paths to instrument heap
reference loads and GC root loads for the concurrent copying
collector, respectively calling the artReadBarrierSlow and
artReadBarrierForRootSlow runtime entry points.

Notes:
- This implementation does not instrument HInvokeVirtual
nor HInvokeInterface instructions (for class reference
loads), as the corresponding read barriers are not stricly
required with the current concurrent copying collector.
- Intrinsics which may eventually call (on slow path) are
disabled when read barriers are enabled, as the current
slow path infrastructure does not support this case.
- When read barriers are enabled, the code generated for a
HArraySet instruction always go into the array set slow
path for object arrays (delegating the operation to the
runtime), as we are lacking a mechanism to keep a
temporary register live accross a runtime call (needed for
the instrumentation of type checking code, which requires
two successive read barriers).

Bug: 12687968
Change-Id: Icfb74f67bf23ae80e7723ee6a0c9ff34ba325d48
0d1caa5df8d99320036888600190337bbe540731 20-Nov-2015 Vladimir Marko <vmarko@google.com> Optimizing: Avoid a PrettyMethod() call per compiled method.

PrettyMethod() is expensive so avoid it unless it's actually
needed.

Change-Id: I06ab29cc18e426b7dfb8c53b163757c88b53c27f
e34648dec914453f7e8b6c517dd272823319cd6d 23-Nov-2015 Nicolas Geoffray <ngeoffray@google.com> Revert "Add stats support for existing optimizations"

Breaks the build. Please ensure your changes build.

This reverts commit 06241b1b07fb031b7d2cf55f4b78d3444d07cc2d.

Change-Id: I68b18f99a9882719bf6654d3313531a7965b8483
06241b1b07fb031b7d2cf55f4b78d3444d07cc2d 03-Sep-2015 Jean-Philippe Halimi <jean-philippe.halimi@intel.com> Add stats support for existing optimizations

This patch adds support for the --dump-stats facility with existing
optimizations.

Change-Id: I68751b119a030952a11057cb651a3c63e87e73ea
Signed-off-by: Jean-Philippe Halimi <jean-philippe.halimi@intel.com>
d59c70627cc42878cc30b46bd29ff497b4483b22 21-Nov-2015 Aart Bik <ajcbik@google.com> Revert "Dynamic BCE (based on induction range analysis)"

This reverts commit 0b5849be045c5683d4a6b6b6c306abadba5f0fcc.


Change-Id: Id33f5da42bbdfb1aff7e2281417c8a7aa492df05
Rationale: so close :-( but bullhead-userdebug (linux) build in git_mnc-dr-dev-plus-aosp reported a breakage with a type inconsistency (long vs int in probably the codegen of dynamic bce); no time to investigate and fix this fully before my trip, so rolling back for now
0b5849be045c5683d4a6b6b6c306abadba5f0fcc 19-Oct-2015 Aart Bik <ajcbik@google.com> Dynamic BCE (based on induction range analysis)

Rationale: A rewritten dynamic BCE that uses induction variable analysis
to generate the run-time tests before a loop in order to
eliminate bounds-checks from its body. This CL removes now
obsoleted induction related code inside the BCE module.
Also, the dynamic test generation is placed more strategically,
since we missed a few cases where static analysis does better.

Most significant performance improvements (after filtering noise) is about:
Linpack +20%
LU > +10%

Change-Id: I4e7b8bab0288beff6f98a14856e3536103d32742
3b359c71f2fb784589be113206932e76807787bb 17-Nov-2015 Roland Levillain <rpl@google.com> ARM read barrier support for concurrent GC in Optimizing.

This first implementation uses slow paths to instrument heap
reference loads and GC root loads for the concurrent copying
collector, respectively calling the artReadBarrierSlow and
artReadBarrierForRootSlow runtime entry points.

Notes:
- This implementation does not instrument HInvokeVirtual
nor HInvokeInterface instructions (for class reference
loads), as the corresponding read barriers are not stricly
required with the current concurrent copying collector.
- Intrinsics which may eventually call (on slow path) are
disabled when read barriers are enabled, as the current
slow path infrastructure does not support this case.
- When read barriers are enabled, the code generated for a
HArraySet instruction always go into the array set slow
path for object arrays (delegating the operation to the
runtime), as we are lacking a mechanism to keep a
temporary register live accross a runtime call (needed for
the instrumentation of type checking code, which requires
two successive read barriers).

Bug: 12687968
Change-Id: I92e8db414d029f952c07f3d3a98069e46dfdbc2a
0d5a281c671444bfa75d63caf1427a8c0e6e1177 13-Nov-2015 Roland Levillain <rpl@google.com> x86/x86-64 read barrier support for concurrent GC in Optimizing.

This first implementation uses slow paths to instrument heap
reference loads and GC root loads for the concurrent copying
collector, respectively calling the artReadBarrierSlow and
artReadBarrierForRootSlow (new) runtime entry points.

Notes:
- This implementation does not instrument HInvokeVirtual
nor HInvokeInterface instructions (for class reference
loads), as the corresponding read barriers are not stricly
required with the current concurrent copying collector.
- Intrinsics which may eventually call (on slow path) are
disabled when read barriers are enabled, as the current
slow path infrastructure does not support this case.
- When read barriers are enabled, the code generated for a
HArraySet instruction always go into the array set slow
path for object arrays (delegating the operation to the
runtime), as we are lacking a mechanism to keep a
temporary register live accross a runtime call (needed for
the instrumentation of type checking code, which requires
two successive read barriers).

Bug: 12687968
Change-Id: I14cd6107233c326389120336f93955b28ffbb329
0f7dca4ca0be8d2f8776794d35edf8b51b5bc997 02-Nov-2015 Vladimir Marko <vmarko@google.com> Optimizing/X86: PC-relative dex cache array addressing.

Add PC-relative dex cache array addressing for X86 and use
it for better invoke-static/-direct dispatch. Also delay
the initialization to the PC-relative base until needed.

Change-Id: Ib8634d5edce4920cd70172fd13211809cf6948d1
cdfed3dc422d0e1a9a0a948863308e58c39d01ba 26-Oct-2015 Calin Juravle <calin@google.com> Revert "Revert "Run type propagation after inliner only when needed.""

This reverts commit 271743601650308c7ac5c7a3ec35025d8130a298.

Change-Id: I173e27a0a4d7d54f90ca459eb48d280d1d40ab70
8a7c0fe837bb00b02dfcfc678910d81d07fb2136 02-Nov-2015 David Brazdil <dbrazdil@google.com> Revert "Revert "ART: Update DCE to work with try/catch""

The previous CL failed because it did not update inputs of catch phis.
Since phi input indices cannot be easily mapped back to throwing
instructions, this new implementation at least removes catch phi uses
of values defined in the removed blocks to preserve graph consistency.

This reverts commit fb552d7061746f7a90fdd5002696e255e2e15c35.

Change-Id: I63d95915d1ef50e71d3bcf0cd10aaded554035b4
d28b969c273ab777ca9b147b87fcef671b4f695f 04-Nov-2015 Nicolas Geoffray <ngeoffray@google.com> Code cleanup to avoid CompilerDriver abstractions in JIT.

Avoids allocating a CompiledMethod.

Change-Id: I35b4aa0d7c74daba68e827a01e71c300fce3b3bf
951779839f0d35ed5336f399c8f521fd9a6b7c27 30-Oct-2015 David Brazdil <dbrazdil@google.com> ART: Enable inlining under try/catch

This patch updates the inliner to set try/catch information
when inlining into a method with try/catch. It does not yet
allow inlining of methods with try/catch because that will
require generating catch stack maps with inline info.

Change-Id: I7d57e1454e7da537d75c5c7eda60b22f3a30fa60
771e5cc519665ce0cc76985bb4803f0dd50c3b40 29-Oct-2015 David Brazdil <dbrazdil@google.com> Revert "ART: Enable more passes under try/catch"

BCE does not set TryCatchInformation when creating new blocks.
Will be fixed with DynamicBCE CL.

This reverts commit 39fabd6bb6fcf7a712b370d3b6fd0ada83e2e5d8.

Change-Id: I76ae707ac132bb1a4a9f64f4916ffcd786ef730c
39fabd6bb6fcf7a712b370d3b6fd0ada83e2e5d8 26-Oct-2015 David Brazdil <dbrazdil@google.com> ART: Enable more passes under try/catch

LICM, BCE, LSE are all safe under try/catch. Inliner and DCE
need updating and will be enabled in follow-up CLs.

Change-Id: I86db5f811257d5e765fea91666a2a2af0fb24ec3
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
271743601650308c7ac5c7a3ec35025d8130a298 26-Oct-2015 Calin Juravle <calin@google.com> Revert "Run type propagation after inliner only when needed."

This reverts commit 4e5dd521063beae1706410419f19c7e224db50fe.

Change-Id: I0de261d14dd3f71abe05f9bc71744820cf23b937
4e5dd521063beae1706410419f19c7e224db50fe 19-Oct-2015 Calin Juravle <calin@google.com> Run type propagation after inliner only when needed.

Currently we run a type propagation pass unconditionally after the
inliner. This change looks at the returned value (if any) and runs a
minimal type propagation only if its type has changed.

Change-Id: I0dd72bd481219081e8a978d2632426afc980d73a
dc151b2346bb8a4fdeed0c06e54c2fca21d59b5d 15-Oct-2015 Vladimir Marko <vmarko@google.com> Optimizing: Determine invoke-static/-direct dispatch early.

Determine the dispatch type of invoke-static/-direct in a
special pass right after the type inference. This allows the
inliner to pass the "needs dex cache" check and inline more.
It also allows the code generator to avoid requesting a
register location for the ArtMethod* for kDexCachePcRelative
and direct methods.

The supported dispatch check handles also situations that
the CompilerDriver currently doesn't allow. The cleanup of
the CompilerDriver and required changes to Quick will come
in a separate change.

Change-Id: I3f8e903a119949e95871d8ab0a995f4731a13a07
8df69d42a9e3ccd9456ff72fac8dbd1999f98755 23-Oct-2015 Mingyao Yang <mingyao@google.com> Revert "Revert "load store elimination.""

This reverts commit 8030c4100d2586fac39ed4007c61ee91d4ea4f25.

Change-Id: I79558d85484be5f5d04e4a44bea7201fece440f0
f652cecb984c104d44a0223c3c98400ef8ed8ce2 25-Aug-2015 Goran Jakovljevic <Goran.Jakovljevic@imgtec.com> MIPS: Initial version of optimizing compiler for MIPS32

Change-Id: I370388e8d5de52c7001552b513877ef5833aa621
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
4b8f1ecd3aa5a29ec1463ff88fee9db365f257dc 26-Aug-2015 Roland Levillain <rpl@google.com> Use ATTRIBUTE_UNUSED more.

Use it in lieu of UNUSED(), which had some incorrect uses.

Change-Id: If247dce58b72056f6eea84968e7196f0b5bef4da
8030c4100d2586fac39ed4007c61ee91d4ea4f25 15-Oct-2015 Nicolas Geoffray <ngeoffray@google.com> Revert "load store elimination."

Breaks libcore tests:

libcore.java.lang.ref.FinalizeTest#testWatchdogDoesNotFailForObjectsThatAreNearTheDeadline
libcore.java.util.ResourceLeakageDetectorTest#testDetectsUnclosedCloseGuard
org.apache.harmony.tests.java.lang.ref.ReferenceTest#test_finalizeReferenceInteraction

This reverts commit 589dac7f0ce078d19aad7e35bb0195c47ddf01d2.

Change-Id: I55115765c10762d5bc152d3425e4622560d8b9f4
589dac7f0ce078d19aad7e35bb0195c47ddf01d2 24-Aug-2015 Mingyao Yang <mingyao@google.com> load store elimination.

This adds a pass to eliminate some unnecessary heap loads/stores. It
first collects heap locations and then tracks values stored to those heap
locations. Alias analysis is done based on offset, type, singleton,
pre-existence, etc.

Change-Id: I11a9d8ef20d1b2f245607eb25118e9aff9be472a
655e585073ac271cc9afa7c9d6ff5ab4dbe4b72e 12-Oct-2015 Vladimir Marko <vmarko@google.com> Optimizing: Move GraphChecker memory allocations to arena.

Bug: 18120045
Change-Id: I3934158e6ea4868d9baa1dfcc53b603ca6c521e2
cff8cc7818dd901d3667025ad0ff654100bbb629 09-Oct-2015 Calin Juravle <calin@google.com> Don't check for optimizing test marker on unsupported ISAs.

Change-Id: I39b31e770f4a9f1f5806cc4b28009e2f1908ad43
09b1d6f749437bdd47f61e7c4f924f6d16b59536 07-Oct-2015 Calin Juravle <calin@google.com> Enforce optimizing test marker for verification errors.

Change-Id: Ie7babf162729fa02d285572ee043fa9e588d73cc
c90d7c7cd3103a7b7ce62b40873d2dfcf306ca74 06-Oct-2015 Vladimir Marko <vmarko@google.com> Revert "Optimizing: Disable -Wframe-larger-than= for CompileOptimized()."

Instead, prevent inlining of AllocateRegisters() that uses
huge stack-allocated objects.

Bug: 24698147

This reverts commit 67f784e63343db5ecd6e584343484684ea60d1f8.

Change-Id: I94c408f7acf6e43897a248d9ea0761b979ed00c8
67f784e63343db5ecd6e584343484684ea60d1f8 06-Oct-2015 Vladimir Marko <vmarko@google.com> Optimizing: Disable -Wframe-larger-than= for CompileOptimized().

Bug: 24698147
Change-Id: I360e9412d85afa83ef2152e4c16bcd3139b34f75
da3a55bd07e1907d4286dd1b6de77ff42d861e16 02-Oct-2015 Nicolas Geoffray <ngeoffray@google.com> Don't delegate to Quick anymore.

Change-Id: I81ffd83daec7be03a796903f40b8bbdcd63c34c7
07380a2d6cb9feee02facc81f699eed5cb670cd5 17-Sep-2015 Calin Juravle <calin@google.com> Enable compilation of members with access check failures.

Change-Id: I0de73099b53612072c3e6f1235c22f96339fe440
1920c1036ebe6dcdc93959714c9fdcedc199baf0 29-Sep-2015 Nicolas Geoffray <ngeoffray@google.com> Revert "Revert "Enable optimizations with --debuggable.""

This reverts commit b7d27a53cb280a943c0a63a9e0806cf8e3ae4cde.

Change-Id: I398c23863e4fd86a3112076417378d22efd08306
b7d27a53cb280a943c0a63a9e0806cf8e3ae4cde 29-Sep-2015 Nicolas Geoffray <ngeoffray@google.com> Revert "Enable optimizations with --debuggable."

Build error with gcc.

This reverts commit 43855ccb01703b188777fe59e1110e6a23803171.

Change-Id: I45abc7ee0943b2ad7bd644c88858891fc7a38ead
43855ccb01703b188777fe59e1110e6a23803171 29-Sep-2015 Nicolas Geoffray <ngeoffray@google.com> Enable optimizations with --debuggable.

Change-Id: I8979e59ee081222687fda1c93ac0bf3acbbad936
175dc732c80e6f2afd83209348124df349290ba8 25-Aug-2015 Calin Juravle <calin@google.com> Support unresolved methods in Optimizing

Change-Id: If2da02b50d2fa668cd58f134a005f1752e7746b1
22af3bee34d0ab1a4bd186c71ccab00366882259 10-Sep-2015 Aart Bik <ajcbik@google.com> Use induction variable range analysis in BCE (statically).

Rationale: Finally! After lots of very large CLs, now a small CL
that uses the new induction variable analysis in BCE
(statically, using this dynamically with de-opt is TBD).
Despite its relative small size, be aware though,
since the CL introduces a new phase to the compiler.

Change-Id: If5555a173fd5d55d147c63138ef51fc296fa1414
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
77a48ae01bbc5b05ca009cf09e2fcb53e4c8ff23 15-Sep-2015 David Brazdil <dbrazdil@google.com> Revert "Revert "ART: Register allocation and runtime support for try/catch""

The original CL triggered b/24084144 which has been fixed
by Ib72e12a018437c404e82f7ad414554c66a4c6f8c.

This reverts commit 659562aaf133c41b8d90ec9216c07646f0f14362.

Change-Id: Id8980436172457d0fcb276349c4405f7c4110a55
94ca9afd15e5b151860f6ce305ad4d8662fa95b7 15-Sep-2015 Nicolas Geoffray <ngeoffray@google.com> Temporarly disable SSA creation in try/catch/debuggable.

This is to enable optimizations when the debuggable flag is set.

bug:24054676

Change-Id: I34eef2481ae44ad3550e04ec6f796d421d03adc0
659562aaf133c41b8d90ec9216c07646f0f14362 14-Sep-2015 David Brazdil <dbrazdil@google.com> Revert "ART: Register allocation and runtime support for try/catch"

Breaks libcore test org.apache.harmony.security.tests.java.security.KeyStorePrivateKeyEntryTest#testGetCertificateChain. Need to investigate.

This reverts commit b022fa1300e6d78639b3b910af0cf85c43df44bb.

Change-Id: Ib24d3a80064d963d273e557a93469c95f37b1f6f
b022fa1300e6d78639b3b910af0cf85c43df44bb 20-Aug-2015 David Brazdil <dbrazdil@google.com> ART: Register allocation and runtime support for try/catch

This patch completes a series of CLs that add support for try/catch
in the Optimizing compiler. With it, Optimizing can compile all
methods containing try/catch, provided they don't contain catch loops.
Future work will focus on improving performance of the generated code.

SsaLivenessAnalysis was updated to propagate liveness information of
instructions live at catch blocks, and to keep location information on
instructions which may be caught by catch phis.

RegisterAllocator was extended to spill values used after catch, and
to allocate spill slots for catch phis. Catch phis generated for the
same vreg share a spill slot as the raw value must be the same.

Location builders and slow paths were updated to reflect the fact that
throwing an exception may not lead to escaping the method.

Instruction code generators are forbidden from using of implicit null
checks in try blocks as live registers need to be saved before handing
over to the runtime.

CodeGenerator emits a stack map for each catch block, storing locations
of catch phis. CodeInfo and StackMapStream recognize this new type of
stack map and store them separate from other stack maps to avoid dex_pc
conflicts.

After having found the target catch block to deliver an exception to,
QuickExceptionHandler looks up the dex register maps at the throwing
instruction and the catch block and copies the values over to their
respective locations.

The runtime-support approach was selected because it allows for the
best performance in the normal control-flow path, since no propagation
of catch phi values is necessary until the exception is thrown. In
addition, it also greatly simplifies the register allocation phase.

ConstantHoisting was removed from LICMTest because it instantiated
(now abstract) HConstant and was bogus anyway (constants are always in
the entry block).

Change-Id: Ie31038ad8e3ee0c13a5bbbbaf5f0b3e532310e4e
0616ae081e648f4b9b64b33e2624a943c5fce977 17-Apr-2015 Mark Mendell <mark.p.mendell@intel.com> [optimizing] Add support for x86 constant area

Use the Quick trick of finding the address of the method by calling the
next instruction and popping the return address into a register. This
trick is used because of the lack of PC-relative addressing in 32 bit
mode on the X86.

Add a HX86ComputeBaseMethodAddress instruction to trigger generation
of the method address, which is referenced by instructions needing
access to the constant area.

Add a HX86LoadFromConstantTable instruction that takes a
HX86ComputeBaseMethodAddress and a HConstant that will be used to load
the value when needed.

Change Add/Sub/Mul/Div to detect a HX86LoadFromConstantTable right hand
side, and generate code that directly references the constant area.
Other uses will be added later.

Change the inputs to HReturn and HInvoke(s), replacing the FP constants
with HX86LoadFromConstantTable instead. This allows values to be
loaded from the constant area into the right location.

Port the X86_64 assembler constant area handling to the X86.

Use the new per-backend optimization framework to do this conversion.

Change-Id: I6d235a72238262e4f9ec0f3c88319a187f865932
Signed-off-by: Mark Mendell <mark.p.mendell@intel.com>
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
2a7c1ef95c850abae915b3a59fbafa87e6833967 22-Jul-2015 Yevgeny Rouban <yevgeny.y.rouban@intel.com> Add more dwarf debug line info for Optimized methods.

Optimizing compiler generates minimum debug line info that
is built using the dex_pc information about suspend points.
This is not enough for performance and debugging needs.

This CL generates additional debug line information for
instructions which have known dex_pc and it ensures that
whole call sites are mapped (as opposed to suspend points
which map only one instruction past the function call).

Bug: 23157336
Change-Id: I9f2b1c2038e3560847c175b8121cf9496b8b58fa
Signed-off-by: Yevgeny Rouban <yevgeny.y.rouban@intel.com>
f9f6441c665b5ff9004d3ed55014f46d416fb1bb 02-Sep-2015 Vladimir Marko <vmarko@google.com> Optimizing: Tag Arena allocations with their source.

This adds the ability to track where we allocate memory
when the kArenaAllocatorCountAllocations flag is turned on.

Also move some allocations from native heap to the Arena
and remove some unnecessary utilities.

Bug: 23736311
Change-Id: I1aaef3fd405d1de444fe9e618b1ce7ecef07ade3
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
ed15000a5099f5e230c8ded5ac75692bae272650 28-Aug-2015 Mathieu Chartier <mathieuc@google.com> Fix some HandleScope bugs and add corresponding checks

Some places were creating or destroying handle scopes without holding
the mutator lock. This can cause GC crashes if thread roots are being
marked or hprof dumps to also fail.

Also added checks to catch some of these errors.

Bug: 23468617
Change-Id: I1a2d615923484cfc25014967656775c445aa3f1f
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
bbd733e4ef277eff19bf9a6601032da081e9b68f 18-Aug-2015 David Brazdil <dbrazdil@google.com> ART: Enable basic optimizations for try/catch

Generating code for try/catch methods requires having run at least the
instruction simplifier to remove redundant suspend checks. This patch
enables the first group of optimizations when try/catch is present.

Enabled optimizations:
1) IntrinsicsRecognizer
Does not modify the graph, only sets HInvoke::intrinsic_.

2) ConstantFolding
Does not deal with throwing instructions.

3) InstructionSimplifier
May remove a throwing instruction (e.g. LoadClass in VisitCheckCast),
or may turn a throwing instruction into a non-throwing one (ArraySet).
Their corresponding catch phi inputs are not removed but correctness
is preserved.

4) ReferenceTypePropagation
Does not modify the graph, only sets type properties. Typing of
LoadException from catch handler information was added.

5) DeadCodeElimination
Removing individual instructions is fine (same as 3). Removal of dead
blocks was disabled for try/catch.

Change-Id: I2722c3229eb8aaf326391e07f522dbf5186774b8
581550137ee3a068a14224870e71aeee924a0646 19-Aug-2015 Vladimir Marko <vmarko@google.com> Revert "Revert "Optimizing: Better invoke-static/-direct dispatch.""

Fixed kCallArtMethod to use correct callee location for
kRecursive. This combination is used when compiling with
debuggable flag set.

This reverts commit b2c431e80e92eb6437788cc544cee6c88c3156df.

Change-Id: Idee0f2a794199ebdf24892c60f8a5dcf057db01c
44b9cf937836bb33139123e15ca8b586b5853268 19-Aug-2015 Alexandre Rames <alexandre.rames@linaro.org> Put in place the ARM64 instruction simplification framework.

This commit introduces and runs the empty InstructionSimplifierArm64
pass. Further commits will introduce arm64-specific transformations in
that pass.

Change-Id: I458f8a2b15470297b87fc1f7ff85bd52155d93ef
b2c431e80e92eb6437788cc544cee6c88c3156df 19-Aug-2015 Vladimir Marko <vmarko@google.com> Revert "Optimizing: Better invoke-static/-direct dispatch."

Reverting due to failing ndebug tests.

This reverts commit 9b688a095afbae21112df5d495487ac5231b12d0.

Change-Id: Ie4f69da6609df3b7c8443412b6cf7f5c43c2c5d9
9b688a095afbae21112df5d495487ac5231b12d0 06-May-2015 Vladimir Marko <vmarko@google.com> Optimizing: Better invoke-static/-direct dispatch.

Add framework for different types of loading ArtMethod*
and code pointer retrieval. Implement invoke-static and
invoke-direct calls the same way as Quick. Document the
dispatch kinds in HInvokeStaticOrDirect's new enumerations
MethodLoadKind and CodePtrLocation.

PC-relative loads from dex cache arrays are used only for
x86-64 and arm64. The implementation for other architectures
will be done in separate CLs.

Change-Id: I468ca4d422dbd14748e1ba6b45289f0d31734d94
ec74835a7e4f2660250a2f3f9508cbbe5269e49a 29-Jul-2015 Calin Juravle <calin@google.com> Allow for fine tuning the inliner.

Bug: 21868508

Change-Id: Ice7f1604ed65e3d4ed2a010ee431272b7d000cdb
a5ae3c3f468ffe3a317b498d7fde1f8e9325346a 28-Jul-2015 Calin Juravle <calin@google.com> Revert "Revert "Revert "Revert "Fixes and improvements in ReferenceTypePropagation""""

This reverts commit e344a8070d4549d513413c06767abf8a2c5e9709.

Change-Id: I400fab0e02ce3c11376cc1f3ae9c7cf2c82ffcc1
e344a8070d4549d513413c06767abf8a2c5e9709 28-Jul-2015 Calin Juravle <calin@google.com> Revert "Revert "Revert "Fixes and improvements in ReferenceTypePropagation"""

This reverts commit 00e3b38be4b280d6d7a7e843cd336ffbd2ba4365.

Change-Id: I4dbadb2d7312a410f1c56283f063dd82156cf702
00e3b38be4b280d6d7a7e843cd336ffbd2ba4365 15-Jul-2015 Calin Juravle <calin@google.com> Revert "Revert "Fixes and improvements in ReferenceTypePropagation""

This reverts commit 9b0096ba77e7e61bc2dcbbf954831dcae54a6c27.

Change-Id: I824f16e800ca32e646577d5e1e0d593887ccead1
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
53fcd0f2637207ecad2fd57a6a0f1cf8392fcc40 22-Jul-2015 Andreas Gampe <agampe@google.com> ART: Add VerboseMethods to optimizing compiler

Bring the optimizing compiler up to Quick levels for debuggability.

Change-Id: Ib2adce7a31cc6a60c37c63d0df5cb6a35a85e790
9b0096ba77e7e61bc2dcbbf954831dcae54a6c27 22-Jul-2015 Calin Juravle <calin@google.com> Revert "Fixes and improvements in ReferenceTypePropagation"

This reverts commit b0d5fc0ac139da4aaa1440263416b9bde05630b0.

Change-Id: Iea8adfc0bd4cb7ee2b292278b8bac80a259acbd1
b0d5fc0ac139da4aaa1440263416b9bde05630b0 15-Jul-2015 Calin Juravle <calin@google.com> Fixes and improvements in ReferenceTypePropagation

- Bound object types after a CheckCast. This increases the precision of
(inlining) generic operations.
- Make sure that the BoundType is exact when the class is final.
- Make sure that we don't duplicate BoundTypes when we run the analysis
more than once.

Change-Id: Ic22b610766fae101f942c0d753ddcac32ac1844a
9523a3ed0ae6fa31cd978a3999fd88233218f98b 17-Jul-2015 Nicolas Geoffray <ngeoffray@google.com> Revert "Revert "Use the quickened metadata to compile -QUICK opcodes.""

This reverts commit 8ab9a9010f3929acbb6c671008b8885b762b01e1.

Change-Id: I1e654d5010ea2112982c3055fcb8c8f9c10e9ac8
030f2af20dcae2c44bcf1b7b265cf3db4e3c23f8 17-Jul-2015 Nicolas Geoffray <ngeoffray@google.com> Reduce space filter threshold to 128.

In order to get closer to our code increase limit.

Bug:21868508

(cherry picked from commit 432bf3d525dd0736c91238d69e29b4db6a2f7b80)

Change-Id: Iab19fe99a8a869b0fb841bac317016e4a3dc00e2
432bf3d525dd0736c91238d69e29b4db6a2f7b80 17-Jul-2015 Nicolas Geoffray <ngeoffray@google.com> Reduce space filter threshold to 128.

In order to get closer to our code increase limit.

Bug:21868508

Change-Id: I05f76bfd97f03bda3741eca4e6a678c536ad0702
8ab9a9010f3929acbb6c671008b8885b762b01e1 17-Jul-2015 Nicolas Geoffray <ngeoffray@google.com> Revert "Use the quickened metadata to compile -QUICK opcodes."

Broke sdk build. Investigating.

This reverts commit 4515a67434c9e3e1627586629a1f2aba1a99aa6a.

Change-Id: I6c1107ab626758570a59dc6bf3e4228c70a57196
4515a67434c9e3e1627586629a1f2aba1a99aa6a 16-Jul-2015 Nicolas Geoffray <ngeoffray@google.com> Use the quickened metadata to compile -QUICK opcodes.

Change-Id: I28a8d68921698bea81f54c95cc6e4c6d2c03f2b4
ffee3d33f3ea39aa6031c3d2ff29c4806c8dcc51 06-Jul-2015 David Brazdil <dbrazdil@google.com> ART: Build SSA form when try/catch is present

This patch implements support for try/catch in the SsaBuilder.
Values of locals are propagated from throwing sites inside try
blocks to their respective catch blocks and phis ("catch phis")
are created when necessary.

Change-Id: I0736565c2c4ff3f9f0924b6e3a785a50023f875a
2e7cd752452d02499a2f5fbd604c5427aa372f00 10-Jul-2015 Nicolas Geoffray <ngeoffray@google.com> [optimizing] Don't rely on the verifier for String.<init>.

Continue work on cutting the dependency on the verifier.

Change-Id: I0f95b1eb2e10fd8f6bf54817f1202bdf6dfdb0fe
ae0c62fda785e70a795ae7d50191df1f50fbbeaf 26-Jun-2015 David Brazdil <dbrazdil@google.com> Revert "ART: Bail out immediately on try/catch"

This is an MNC-only CL and should not be merged downstream.

This reverts commit 1ff04abecc7318826248c24850c1116df5b68b33.
1ff04abecc7318826248c24850c1116df5b68b33 26-Jun-2015 David Brazdil <dbrazdil@google.com> ART: Bail out immediately on try/catch

Optimizing builds the graph even if it knows it will delegate to
Quick. This patch moves the decision at the beginning of the
TryCompile function to save a little bit of compile time.

Bug: 22115561
Change-Id: I18b5a686e10592080ea3c49d53a0dd81aa3b3010
a1935c4fa255b5c20f5e9b2abce6be2d0f7cb0a8 26-Jun-2015 Roland Levillain <rpl@google.com> MIPS: Initial version of optimizing compiler for MIPS64R6.

(cherry picked from commit 4dda3376b71209fae07f5c3c8ac3eb4b54207aa8)
(amended for mnc-dev)

Bug: 21555893
Change-Id: I874dc356eee6ab061a32f8f3df5f8ac3a4ab7dcf
Signed-off-by: Alexey Frunze <Alexey.Frunze@imgtec.com>
Signed-off-by: Douglas Leung <douglas.leung@imgtec.com>
20d60dd249e07a17351427770f0e0f6c68945b7a 25-Jun-2015 Nicolas Geoffray <ngeoffray@google.com> Only do some checks when compiling against the core image.

This will avoid false negatives when running dex2oatd on apks.

bug:21865473

(cherry picked from commit 335005e2b3a179f26b7a8ae64ca60a1406b669bd)

Change-Id: Iac6dbe30c9d576077a0384b88696f79937d89471
335005e2b3a179f26b7a8ae64ca60a1406b669bd 25-Jun-2015 Nicolas Geoffray <ngeoffray@google.com> Only do some checks when compiling against the core image.

This will avoid false negatives when running dex2oatd on apks.

bug:21865473

Change-Id: Id8eacaefae0bcf07a2ada8aedd7951854cdb5c4f
286763464072ffb599846f76720c7ec54392ae6e 24-Jun-2015 Nicolas Geoffray <ngeoffray@google.com> Use a flag from the verifier to know if we should compile.

Only used for the lack of bottom type in the aget-object case
for now. Could be used for more.

bug:21865466

(cherry picked from commit 4824c27988c8eeb302791624bb3ce1d557b0db6c)

Change-Id: I2bb7fe1d4737bd92c1076b5193607d74d8761ee7
4824c27988c8eeb302791624bb3ce1d557b0db6c 24-Jun-2015 Nicolas Geoffray <ngeoffray@google.com> Use a flag from the verifier to know if we should compile.

Only used for the lack of bottom type in the aget-object case
for now. Could be used for more.

bug:21865466

Change-Id: I64c2c84dfa1c0d259631e65e5f44b94e4139e6a7
69ba7b7112c2277ac225615b37e6df74c055740d 23-Jun-2015 David Brazdil <dbrazdil@google.com> ART: Run GraphChecker after Builder and SsaBuilder

This patch refactors the way GraphChecker is invoked, utilizing the
same scoping mechanism as pass timing and graph visualizer. Therefore,
GraphChecker will now run not just after instances of HOptimization
but after the builders and reg alloc, too.

Change-Id: I8173b98b79afa95e1fcbf3ac9630a873d7f6c1d4
eb7b7399dbdb5e471b8ae00a567bf4f19edd3907 19-Jun-2015 Alexandre Rames <alexandre.rames@linaro.org> Opt compiler: Add disassembly to the '.cfg' output.

This is automatically added to the '.cfg' output when using the usual
`--dump-cfg` option.

Change-Id: I864bfc3a8299c042e72e451cc7730ad8271e4deb
a04e7b7ceae01a7ceda41419e4c639a43e18361e 18-Jun-2015 Nicolas Geoffray <ngeoffray@google.com> Run a simplification pass before code generation.

The code generators assume things that only the instruction
simplier ensures. So it has to be run last in case previous
optimiziations broke those assumptions.

bug:21865464

(cherry picked from commit b2bdfce7f805b00668a2521b1c939a0aafb2be49)

Change-Id: Ibf4384a911e400eb7586bbf6b4edd6351034cbd8
25fde612b0df01a086cd4c801b7bd3a10e93a0e9 18-Jun-2015 Nicolas Geoffray <ngeoffray@google.com> Fix a bug in optimizing when the null constant has been DCE.

If it has been DCE, we should create a new one, instead of
using the old one.

Also move the first DCE to a place where it could actually
be useful.

bug:21870788

(cherry picked from commit 18e6873c469b48aaed22148451523479eece98e3)

Change-Id: I3b3ab2dafe8ce5fb60868fd1a6ef0eeefe666e0c
4dda3376b71209fae07f5c3c8ac3eb4b54207aa8 02-Jun-2015 Alexey Frunze <Alexey.Frunze@imgtec.com> MIPS: Initial version of optimizing compiler for MIPS64R6.

Bug: 21555893
Change-Id: I874dc356eee6ab061a32f8f3df5f8ac3a4ab7dcf
Signed-off-by: Alexey Frunze <Alexey.Frunze@imgtec.com>
Signed-off-by: Douglas Leung <douglas.leung@imgtec.com>
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
b2bdfce7f805b00668a2521b1c939a0aafb2be49 18-Jun-2015 Nicolas Geoffray <ngeoffray@google.com> Run a simplification pass before code generation.

The code generators assume things that only the instruction
simplier ensures. So it has to be run last in case previous
optimiziations broke those assumptions.

bug:21865464

Change-Id: I1f84016017bf691c2a34982e202a505b269f609a
18e6873c469b48aaed22148451523479eece98e3 18-Jun-2015 Nicolas Geoffray <ngeoffray@google.com> Fix a bug in optimizing when the null constant has been DCE.

If it has been DCE, we should create a new one, instead of
using the old one.

Also move the first DCE to a place where it could actually
be useful.

bug:21870788

Change-Id: I28fc52ae481ef92cba45fc1b5abcf07c995f524c
a3a3c5943522e7325d60cfcbdd17aff1e138f53d 12-Jun-2015 Vladimir Marko <vmarko@google.com> Optimizing: Move optimization objects to Arena.

This should reduce the stack size needed by the
OptimizingCompiler::CompileOptimized() which was very
close to our limits for clang builds, causing repeated
build breakages on otherwise healthy changes:
art/compiler/optimizing/optimizing_compiler.cc:395:37:
error: stack frame size of 1760 bytes in function
'art::OptimizingCompiler::CompileOptimized'
[-Werror,-Wframe-larger-than=]

Change-Id: I2f4ab0235f4eac61823a4a320bb4fe78942a23c2
454a481d116ec4e6dc36fab23a073017b1436d7f 09-Jun-2015 Nicolas Geoffray <ngeoffray@google.com> Revert "Revert "Support for inlining virtual and interface calls.""

It now works thanks to:
- https://android-review.googlesource.com/#/c/154016/ where
the invoke type is changed.
- The new FindMethodIndexIn method in this change, that
locates the right method index relative to the caller's
dex file.

This reverts commit 6e4758615308bb525b6350c30468e33a2e1f2274.

Change-Id: Iddba11664a9241e210fec211cd2aed9f4b90d118
6e4758615308bb525b6350c30468e33a2e1f2274 08-Jun-2015 Nicolas Geoffray <ngeoffray@google.com> Revert "Support for inlining virtual and interface calls."

Fails for some apps.

bug: 21674542

This reverts commit 1d5006c34d75758752bf3499892e3d5beb11d5dc.

Change-Id: Ia74b5e54d59f8ffe9992591324a12f71efb67af4
1d5006c34d75758752bf3499892e3d5beb11d5dc 03-Jun-2015 Nicolas Geoffray <ngeoffray@google.com> Support for inlining virtual and interface calls.

Also had to change the pass order to get reference type propagation
before the inliner.

Change-Id: I4bf3bbb2d17c7d9cab632cfdd96adad8368bdfea
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
8363c772581bf00ebcdc2e38391b4bfae51beb75 28-May-2015 David Srbecky <dsrbecky@google.com> Add --generate-debug-info flag and remove the other two flags.

Replace the flags --include-debug-symbols and --include-cfi
with single flag called --generate-debug-info (with alias -g).

The name "symbol" was not ideal, since depending on context it
may be interpreted as "ELF symbols", or "debugging information".

This CL also means that we have only the options to include
either all debugging information or none. This should be fine,
since we can use standard tools to strip anything we do not want.

Change-Id: I721fded56d755d7eed0ef36aa84e841a1f5747f8
d5111bf05fc0a9974280a80eeb43db6d5227a81e 22-May-2015 Nicolas Geoffray <ngeoffray@google.com> Do not use dex_compilation_unit after inlining.

It's incompatible with inlining, as inlined invokes/load class/new
can be from another dex file.

Change-Id: I8897b6a012942bc8e136f2bea70252d3fb3a7fa5
b176d7c6c8c01a50317f837a78de5da57ee84fb2 20-May-2015 Nicolas Geoffray <ngeoffray@google.com> Also encode the InvokeType in an InlineInfo.

This will be needed to recover the call stack.

Change-Id: I2fe10785eb1167939c8cce1862b2d7f4066e16ec
3cd4fc8bbb40a57d2ffde85f543c124f53237c1d 14-May-2015 Calin Juravle <calin@google.com> Eliminate redundant constructor barriers when inlining.

Bug: 20410297
Change-Id: I2097743d00eb795d050d390b1918e38c7f41d506
e8ff50df01c89e1b5264a5a900cfebdde87a9b44 07-May-2015 David Brazdil <dbrazdil@google.com> ART: Rediscover loops after deleting blocks in DCE

The way DCE currently updates loop information does not cover all
cases. This patch removes the logic, resets loop information of live
blocks to pre-SSA state and reanalyzes the affected loops.

Change-Id: I0b996a70235b95a8db0de9a23a03f71db57a21b8
(cherry picked from commit a4b8c21dae70ae34aee13628632c39a675c06022)
a4b8c21dae70ae34aee13628632c39a675c06022 07-May-2015 David Brazdil <dbrazdil@google.com> ART: Rediscover loops after deleting blocks in DCE

The way DCE currently updates loop information does not cover all
cases. This patch removes the logic, resets loop information of live
blocks to pre-SSA state and reanalyzes the affected loops.

Change-Id: I0b996a70235b95a8db0de9a23a03f71db57a21b8
0a23d74dc2751440822960eab218be4cb8843647 07-May-2015 Nicolas Geoffray <ngeoffray@google.com> Add a parent environment to HEnvironment.

This code has no functionality change. It adds a placeholder
for chaining inlined frames.

Change-Id: I5ec57335af76ee406052345b947aad98a6a4423a
917f9ab1eaaafdab25b4fd24ca1f49a76182a794 21-Apr-2015 David Brazdil <dbrazdil@google.com> ART: Run BooleanSimplifier after inlining

Inlined methods are currently not simplified.

Change-Id: I075130c9df55e2f55032a2c81b08d42cb2cc01f6
862aaefdd63d8058b54a7d956a0229eec9dcbde6 22-Apr-2015 Calin Juravle <calin@google.com> [optimizing] Name the last DCE pass.

This will allow Checker to differentiate between them.

Change-Id: I972d452a64f1c19d370567b9ef3d620f9b835a9a
8f20bdb9d3b7516e75a7845e610105d87ce25ae6 21-Apr-2015 Calin Juravle <calin@google.com> Run DCE again after all the other optimizations have run.

On docs this doubles the amount of instructions removed.
0cdf6d31b6e8b39b56deba92336383f43fba9c0f 21-Apr-2015 Nicolas Geoffray <ngeoffray@google.com> Revert "Run DCE again after all the other optimizations have run."

Reverting because of libcore failures.

This reverts commit 7a9c885684c965fe84f91d8ad74f54f869e2a448.

Change-Id: Iafe59b02fe7617243d81533d66e609a3528e7a58
7a9c885684c965fe84f91d8ad74f54f869e2a448 21-Apr-2015 Calin Juravle <calin@google.com> Run DCE again after all the other optimizations have run.

On docs this doubles the amount of instructions removed.

Change-Id: I1712a92c0c0b3b32b111d194b64d8ea81d652822
2be39e05ea8c4475278fe6a6573c3c8f04e075d4 21-Apr-2015 Calin Juravle <calin@google.com> Use --dump-stats to dump optimizing compiler stats.

VLOG(compiler) produces too much output and it takes a long time if you
only need to see how an analysis performs.

Change-Id: Ic17c2b2b5fec431d356cecd37289fb96985d4d7f
b2a58477e14e1b15cb9848d16015a49a854ee32c 17-Apr-2015 Alexandre Rames <alexandre.rames@arm.com> Minor improvements to 458-checker-instruction-simplification.

This follows earlier comments from Roland:
https://android-review.googlesource.com/#/c/140446
/2/test/458-checker-instruction-simplification/src/Main.java@337
/2/test/458-checker-instruction-simplification/src/Main.java@465

Change-Id: I255ab74b8885dd8e86bb2c11bba4075fa0eaa183
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
0d9f17de8f21a10702de1510b73e89d07b3b9bbf 15-Apr-2015 Nicolas Geoffray <ngeoffray@google.com> Move the linear order to the HGraph.

Bug found by Zheng Xu: SsaLivenessAnalysis being a stack allocated
object, we should not refer to it in later phases of the compiler.
Specifically, the code generator was using the linear order, which
was stored in the liveness analysis object.

Change-Id: I574641f522b7b86fc43f3914166108efc72edb3b
8dc7324da5bd0f2afd2ab558ab04882329a61fe8 12-Apr-2015 David Srbecky <dsrbecky@google.com> Add --include-cfi compiler option.

Decouple generation of CFI from the rest of debug symbols.
This makes it possible to generate oat with CFI but without
the rest of debug symbols.

This is in line with intention of the .eh_frame section.
The section does not have the .debug_ prefix because it
is considered somewhat different to the rest of debug symbols.

Change-Id: I32816ecd4f30ac4e0dc69d69a4993e349c737f96
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
c2bcafe225d672611284ef247b777b9b19817c7d 10-Apr-2015 Andreas Gampe <agampe@google.com> ART: Refactor CompileOptimized

Factor out register allocation. Both Clang and GCC inline the
function, but it changes how Clang stack-allocates enough so
that the resulting frame size is below our limit.

Bug: 20139216
Change-Id: I2cf393aed70f2ce0556252b61ae639aacab6f3a7
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
691184dd9667b2dbb49b36b6d71053161983ecd0 09-Apr-2015 David Srbecky <dsrbecky@google.com> Fix build - the stack frame is too large.

Change-Id: Icabad2e3ccbaa4783df6c18c60a206357398edc5
c6b4dd8980350aaf250f0185f73e9c42ec17cd57 07-Apr-2015 David Srbecky <dsrbecky@google.com> Implement CFI for Optimizing.

CFI is necessary for stack unwinding in gdb, lldb, and libunwind.

Change-Id: I1a3480e3a4a99f48bf7e6e63c4e83a80cfee40a2
3c54b0023fca579aae006dfa607fb14de5846c42 08-Apr-2015 Andreas Gampe <agampe@google.com> ART: Fix 64-bit ELF file support

The API wasn't cross-compile-safe, 32-bit patchoat would fail for
negative delta applied to a 64-bit ELF file.

Add 64-bit ELF file output to the compilers, behind a flag, currently
off by default (preserving current behavior).

Bug: 20095017
Change-Id: I2cde7b4c7cc83413c76692d7b745868d644a604c
62e074f0d1a18f0f5aa6716f000825704f55e81b 07-Apr-2015 David Brazdil <dbrazdil@google.com> ART: Print C1vis header only if visualizer enabled

Setting kStringFilter currently suppresses graph dumps of non-matching
methods but their headers are still printed. This fixes the issue.

Change-Id: Ib33fb20fcca2bf409534a824e7f76f1feb85724d
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
12be74e37b587ef2dea838d480018f4658b95ad7 30-Mar-2015 Nicolas Geoffray <ngeoffray@google.com> [optimizing] Only print full stats in VLOG(compiler)

Also add a kCompiledQuick stat.

bug:19956318

Change-Id: I0c6c0ac256362824eb9f1418216ab7e2c289a17b
9437b78780f9e6ffa5797ebe82de8e8d7f3a5ed6 25-Mar-2015 Nicolas Geoffray <ngeoffray@google.com> Revert "Revert "Inline across dex files.""

This reverts commit 6a816cf624ba56bf2872916d7b65b18fd9a411ef.

Change-Id: I36cb524108786dd7996f2aea0443675be1f1b859
579ea7d0d89a1d7f02c35ef1beb6328a37259735 24-Mar-2015 Nicolas Geoffray <ngeoffray@google.com> Share the runtime arena for faster compile times.

Using a shared arena has the downside of getting more contentions
when requesting memory, but saves on compilation times because
we don't free the memory it allocated util the end of dex2oat.

Change-Id: I353ced1db34539850ec639b6b228451b455a48ec
46e2a3915aa68c77426b71e95b9f3658250646b7 16-Mar-2015 David Brazdil <dbrazdil@google.com> ART: Boolean simplifier

The optimization recognizes the negation pattern generated by 'javac'
and replaces it with a single condition. To this end, boolean values
are now consistently assumed to be represented by an integer.

This is a first optimization which deletes blocks from the HGraph and
does so by replacing the corresponding entries with null. Hence,
existing code can continue indexing the list of blocks with the block
ID, but must check for null when iterating over the list.

Change-Id: I7779da69cfa925c6521938ad0bcc11bc52335583
36540cb4d549c706cc7cd23086684f1548a91042 23-Mar-2015 Nicolas Geoffray <ngeoffray@google.com> Implement a space filter for optimizing.

Heuristic-based. Currently only for enabling fugu user build.

Change-Id: I76e652bd3f00ed84a2a8ad69c7c2c0e24d74cd68
216eaa2927f424821a03d7c4c6bf701fdb48e865 17-Mar-2015 Nicolas Geoffray <ngeoffray@google.com> Fall back to Quick when Optimizing cannot compile.

Currently applies when seeing unresolved types/methods/fields,
and methods with try/catch.

Change-Id: I93b12d440b39f0b9faf98f08f2bfddedfeff7182
a3d90fb449e2fba87211a7de323faff63cba41fc 16-Mar-2015 Nicolas Geoffray <ngeoffray@google.com> [optimizing] Use baseline when debuggable is set.

SSA form conflicts with JDWP's SetValue functionality. Because
we do not deopt all the call stack, we may call SetValue on a
compiled frame, which doesn't work with optimizing. Simplest
solution for now is to just use baseline.

Change-Id: I91738b363eec8fef145486bd96681aea73a1baa8
234d69d075d1608f80adb647f7935077b62b6376 09-Mar-2015 Nicolas Geoffray <ngeoffray@google.com> Revert "Revert "[optimizing] Enable x86 long support.""

This reverts commit 154552e666347d41d95d7619c6ee56249ff4feca.

Change-Id: Idc726551c249a888b7ff5fde8508ae50e81b2e13
e0fe7ae36180863e45cbb9d1e6e9c30b1b1a949c 09-Mar-2015 Nicolas Geoffray <ngeoffray@google.com> Make the SSA builder honor the debuggable flag.

This requires to properly type phis that are only
used by environments, and discard phis with incomptable types.
The code generators do not handle these conflicting types. In
the process, ensure a phi has a type that does not depend
on the order of the inputs (for example (char, short) -> short),
and set int for int-like types. We can refine this later.

Change-Id: I60ab601d6d00b1cbf18623ee4ff1795aa28f84a1
154552e666347d41d95d7619c6ee56249ff4feca 06-Mar-2015 Nicolas Geoffray <ngeoffray@google.com> Revert "[optimizing] Enable x86 long support."

Few libcore failures.

This reverts commit b4ba354cf8d22b261205494875cc014f18587b50.

Change-Id: I4a28d853e730dff9b69aec9555505803cf2fcd63
b4ba354cf8d22b261205494875cc014f18587b50 05-Mar-2015 Nicolas Geoffray <ngeoffray@google.com> [optimizing] Enable x86 long support.

Change-Id: I9006972a65a1f191c45691104a960366747f9d16
7c3952f423b8213083d60596a5f0bf4237ca3f7b 20-Feb-2015 Andreas Gampe <agampe@google.com> ART: Add -Wunused

Until the global CFLAGS are fixed, add Wunused. Fix declarations
in the optimizing compiler.

Change-Id: Ic4553f08e809dc54f3d82af57ac592622c98e000
b666f4805c8ae707ea6fd7f6c7f375e0b000dba8 18-Feb-2015 Mathieu Chartier <mathieuc@google.com> Move arenas into runtime

Moved arena pool into the runtime.

Motivation:
Allow GC to use arena allocators, recycle arena pool for linear alloc.

Bug: 19264997
Change-Id: I8ddbb6d55ee923a980b28fb656c758c5d7697c2f
acf735c13998ad2a175f5a17e7bfce220073279d 12-Feb-2015 Calin Juravle <calin@google.com> Reference type propagation

- propagate reference types between instructions
- remove checked casts when possible
- add StackHandleScopeCollection to manage an arbitrary number of stack
handles (see comments)

Change-Id: I31200067c5e7375a5ea8e2f873c4374ebdb5ee60
aa9b7c48069699e2aabedc6c0f62cb131fee0c73 17-Feb-2015 Roland Levillain <rpl@google.com> Have the opt. compiler set the size of "empty" frames to zero.

This is to mimic Quick's behavior and honor stack frame
alignment constraints after changes introduced by Change-Id
I0fdb31e8c631e99091b818874a558c9aa04b1628.

This issue use to make oatdump crash on oat files produced by
the optimized compiler (e.g.
out/host/linux-x86/framework/x86_64/core-optimizing.oat).

Change-Id: I8ba52601edb0a0993eaf8923eba55aafdce5043e
809658ec5c5515ae9eb87d32012ec5e088612949 05-Feb-2015 David Brazdil <dbrazdil@google.com> ART: Fix crash when timing method failing to build

PassInfoPrinter previously required that AfterPass is always called
before the timing results are printed, which was not the case when
a method compilation failed either in Builder or SsaBuilder.

Change-Id: I3686bba6869402a62eec884f59fd872d5674e5a5
5e8b137d28c840b128e2488f954cccee3e86db14 23-Jan-2015 David Brazdil <dbrazdil@google.com> Create HGraph outside Builder, print timings

This patch refactors the way HGraph objects are created, moving the
instantiation out of the Builder class and creating the CodeGenerator
earlier. The patch uses this to build a single interface for printing
timings info and dumping the CFG.

Change-Id: I2eb63eabf28e2d0f5cdc7affaa690c3a4b1bdd21
82091dad38f3e5bfaf3b6984c9ab73069fb68310 26-Jan-2015 Nicolas Geoffray <ngeoffray@google.com> Implement LICM in optimizing compiler.

Change-Id: I9c8afb0a58ef45e568576015473cbfd5f011c242
10e244f9e7f6d96a95c910a2bedef5bd3810c637 26-Jan-2015 Calin Juravle <calin@google.com> optimizing: NullCheck elimination

How it works:
- run a type analysis to propagate null information on instructions
- during the last instruction simplifier remove null checks for which
the input is known to be not null

The current type analysis is actually a nullability analysis but it will
be reused in follow up CLs to propagate type information: so it keeps
the more convenient name.

Change-Id: I54bb1d32ab24604b4d677d1ecdaf8d60a5ff5ce9
9c462086269324350516b3394d478f1d71a4b5d1 27-Jan-2015 Andreas Gampe <agampe@google.com> ART: Even more Quick cleanup

Remove Backend.

Change-Id: I247cc65ccda6a362ba1a8f5e73e7f12ecd980a87
827eedbfa882496407375f22b08243a38a5bd53b 26-Jan-2015 Nicolas Geoffray <ngeoffray@google.com> Move code around and address growable_array comment.

- Move SideEffectsAnalysis to its own file.
- Move most of gvn.h to gvn.cc.
- Don't call Resize in GrowableArray constructor, but just set num_used
directly.

Change-Id: I1f1291207945d678d3c99cc0ec1ec155bcae82f6
86dde1658a1951c251dd5c6ff21ecc5c281879a6 26-Jan-2015 Nicolas Geoffray <ngeoffray@google.com> Introduce a SideEffectsAnalysis class.

LICM also needs the side effects information of loops, so move
the GVN::ComputeSideEffects method into its own analysis class.

Change-Id: I810c8230a0eb6b9b536e8f808e17a3a4ad72f7db
d97dc40d186aec46bfd318b6a2026a98241d7e9c 22-Jan-2015 Nicolas Geoffray <ngeoffray@google.com> Support callee save floating point registers on x64.

- Share the computation of core_spill_mask and fpu_spill_mask
between backends.
- Remove explicit stack overflow check support: we need to adjust
them and since they are not tested, they will easily bitrot.

Change-Id: I0b619b8de4e1bdb169ea1ae7c6ede8df0d65837a
9ee66183d8e046ea661f642ba884626f16b46e06 16-Jan-2015 Nicolas Geoffray <ngeoffray@google.com> Constant fold after inlining.

- Inlining opens up new opportunities for constant folding.
- Fix a bug in constant folder where the result type was not
correctly set for the folding of a HCompare.
- Improve graph checker's coverage.

Change-Id: I0943bf8ff65505c4addc4a555a526b55e00b5268
cd6dffedf1bd8e6dfb3fb0c933551f9a90f7de3f 08-Jan-2015 Calin Juravle <calin@google.com> Add implicit null checks for the optimizing compiler

- for backends: arm, arm64, x86, x86_64
- fixed parameter passing for CodeGenerator
- 003-omnibus-opcodes test verifies that NullPointerExceptions work as
expected

Change-Id: I1b302acd353342504716c9169a80706cf3aba2c8
71fb52fee246b7d511f520febbd73dc7a9bbca79 30-Dec-2014 Andreas Gampe <agampe@google.com> ART: Optimizing compiler intrinsics

Add intrinsics infrastructure to the optimizing compiler.

Add almost all intrinsics supported by Quick to the x86-64 backend.
Further intrinsics require more assembler support.

Change-Id: I48de9b44c82886bb298d16e74e12a9506b8e8807
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
12df9ebf72255544b0147c81b1dca6644a29764e 09-Jan-2015 Nicolas Geoffray <ngeoffray@google.com> Move code around in OptimizingCompiler::Compile to reduce stack space.

Also fix an (intentional) memory leak, by allocating the CodeGenerator
on the heap instead of the arena: they construct an Assembler object
that requires destruction.

BUG:18787334

Change-Id: I8cf0667cb70ce5b14d4ac334bd4487a562635f1b
3416601a9e9be81bb7494864287fd3602d18ef13 19-Dec-2014 Calin Juravle <calin@google.com> Look at instruction set features when generating volatiles code

Change-Id: Ia882405719fdd60b63e4102af7e085f7cbe0bb2a
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
ee690a3dd364c025ebc1767d9f84097bb7473eec 01-Dec-2014 David Brazdil <dbrazdil@google.com> ART: Added Checker, a pattern matching test engine

This patch adds a Python script which implements a domain-specific
mini-language similar to that of LLVM's FileCheck. It is primarily
intended for writing tests for the optimizing compiler but could be
configured for other use cases too. It is implemented from scratch in
order to avoid dependency on LLVM.

Checker tests are written in Java and dex2oat is invoked with a flag
which dumps the CFG before and after each pass of the optimizing
compiler. The output is then compared against assertions in the
test's comments parsed by Checker. See comments in tools/checker.py
for more details about the currently supported language features.

This initial CL implements only one type of assertion - whether the
output contains lines matching a desired pattern in the given order -
but supports both plain text and regex matching and allows for
equivalency testing by matching for the outcome of a previous match.
See the tests in compiler/optimizing/test/ConstantFolding.java for
examples.

Change-Id: I1ad7431b399c38dc0391ccee74d2c643ba0b0675
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
48c2b03965830c73cdddeae8aea8030f08430137 09-Dec-2014 Calin Juravle <calin@google.com> Add more compilation stats to optimizing

Optimizing is getting closer to have full coverage and this provides a
nice overview on why certain methods are not compiled/optimized.

Also, clean up some of the builder methods.

Change-Id: Id2f31441a788b797b0efea7ec78bee27bb654186
376b2bbf7c39108223a7a01568a7b4b04d84eeac 09-Dec-2014 Nicolas Geoffray <ngeoffray@google.com> Ensure stack maps are 4 byte aligned.

With the recent move to gcc 4.9, we are hitting alignment
SIGBUS on ARM. The reason is that gcc will optimize two consecutive
32bits loads into one 64bits load, and the instruction (ldrd)
will fail if the data is not aligned.

Also removed the emission of mapping table when a method is optimized.
The information can be found in the StackMap itself.

Change-Id: Icf79406c18a3f4db3c05d52fc2c0dd2e35bf0f8f
f384f88d4d1e89df82f47fbc7245a8acc9c2d49c 23-Oct-2014 Mingyao Yang <mingyao@google.com> Bounds check elimination.

Change-Id: Ia0d6a4226c1f9f1ff1dd35347a38db1dc4265319
f537012ceb6cba8a78b36a5065beb9588451a250 02-Dec-2014 Nicolas Geoffray <ngeoffray@google.com> Treat SSA transformation special, as we may have to bailout.

We forgot to bailout when we found a non-natural loop (on which
our optimizations don't work).

Change-Id: I11976b5af4c98f4f29267a74c74d34b5ad81e20c
43a539f780af20a1854bca81c3d4835a585f0620 02-Dec-2014 Nicolas Geoffray <ngeoffray@google.com> Add some heursitics for compiling, close to Quick's.

Quick has more machinery to give up/not give up, but we can
backport them later.

Change-Id: I5eb62c664246f4ce46f0400cf24ec34a72afb51e
37b55ebd45a2f4514bee3e111bd49c06751da49d 01-Dec-2014 Nicolas Geoffray <ngeoffray@google.com> Don't run optimizations after baseline.

We have enough coverage now. This was also motivated
by having to call RunOptimizations instead, which does invoke
InstructionSimplifier, required by the code generators (for, e.g.
removing useless HTypeConversion nodes).

Change-Id: I4e616dae771b8ced60e1f418e3da834f44edb717
3159674c0863f53cfbc1913d493550221ac47f02 24-Nov-2014 Nicolas Geoffray <ngeoffray@google.com> Fix a bug in the type analysis phase of optimizing.

Dex code can lead to the creation of a phi with one
float input and one integer input. Since the SSA builder trusts
the verifier, it assumes that the integer input must be converted
to float. However, when the register is not used afterwards, the
verifier hasn't ensured that. Therefore, the compiler must remove
the phi prior to doing type propagation.

Change-Id: Idcd51c4dccce827c59d1f2b253bc1c919bc07df5
5e6916cea259897baaca019c5c7a5d05746306ed 18-Nov-2014 Nicolas Geoffray <ngeoffray@google.com> Use HOptimization abstraction for running optimizations.

Move existing optimizations to it.

Change-Id: I3b43f9997faf4ed8875162e3a3abdf99375478dd
4179cc148734fbda4677846369ae4a4db68677bf 19-Nov-2014 Nicolas Geoffray <ngeoffray@google.com> Use cross-compilation helper.

The default method uses the current pointer size. We should
use the pointer size given to the compiler.

Change-Id: I4d6bacad6c17ac715455cabfc89cc651368d07a5
e2dc6fa7aa319ee892d6ed407c986c5a3ec3dcd7 17-Nov-2014 Nicolas Geoffray <ngeoffray@google.com> Don't fall back to Quick in optimizing.

The compiler can now have a life of its own.

Change-Id: I804638c574d1a37299fa8427a3fd10d627d2844e
af07bc121121d7bd7e8329c55dfe24782207b561 12-Nov-2014 Nicolas Geoffray <ngeoffray@google.com> Minor object store optimizations.

- Avoid emitting write barrier when the value is null.
- Do not do a typecheck on an arraystore when storing something that
was loaded from the same array.

Change-Id: I902492928692e4553b5af0fc99cce3c2186c442a
de58ab2c03ff8112b07ab827c8fa38f670dfc656 05-Nov-2014 Nicolas Geoffray <ngeoffray@google.com> Implement try/catch/throw in optimizing.

- We currently don't run optimizations in the presence of a try/catch.
- We therefore implement Quick's mapping table.
- Also fix a missing null check on array-length.

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

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

Change-Id: I5b433e722d2f75baacfacae4d32aef4a828bfe1b
b5f62b3dc5ac2731ba8ad53cdf3d9bdb14fbf86b 30-Oct-2014 Nicolas Geoffray <ngeoffray@google.com> Support for CONST_STRING in optimizing compiler.

Change-Id: Iab8517bdadd1d15ffbe570010f093660be7c51aa
1ba0f596e9e4ddd778ab431237d11baa85594eba 27-Oct-2014 Nicolas Geoffray <ngeoffray@google.com> Support hard float on arm in optimizing compiler.

Also bump oat version, needed after latest hard float switch.

Change-Id: Idf5acfb36c07e74acff00edab998419a3c6b2965
5667fdbb6e441dee7534ade18b628ed396daf593 23-Oct-2014 Zheng Xu <zheng.xu@arm.com> ARM: Use hardfp calling convention between java to java call.

This patch default to use hardfp calling convention. Softfp can be enabled
by setting kArm32QuickCodeUseSoftFloat to true.

We get about -1 ~ +5% performance improvement with different benchmark
tests. Hopefully, we should be able to get more performance by address the left
TODOs, as some part of the code takes the original assumption which is not
optimal.

DONE:
1. Interpreter to quick code
2. Quick code to interpreter
3. Transition assembly and callee-saves
4. Trampoline(generic jni, resolution, invoke with access check and etc.)
5. Pass fp arg reg following aapcs(gpr and stack do not follow aapcs)
6. Quick helper assembly routines to handle ABI differences
7. Quick code method entry
8. Quick code method invocation
9. JNI compiler

TODO:
10. Rework ArgMap, FlushIn, GenDalvikArgs and affected common code.
11. Rework CallRuntimeHelperXXX().

Change-Id: I9965d8a007f4829f2560b63bcbbde271bdcf6ec2
5319defdf502fc4569316473846b83180ec08035 23-Oct-2014 Alexandre Rames <alexandre.rames@arm.com> ART: optimizing compiler: initial support for ARM64.

The ARM64 port uses VIXL for code generation, to which it defers work
like label binding and branch resolving, register type coherency
checking, and immediate values handling.

Change-Id: I0a44508c0c991f472a63e67b3469cdd878fe1a68
Signed-off-by: Serban Constantinescu <serban.constantinescu@arm.com>
Signed-off-by: Alexandre Rames <alexandre.rames@arm.com>
75be28332b278cff9039b54bfb228ac72f539ccc 17-Oct-2014 Roland Levillain <rpl@google.com> Revert "Revert "Introduce a class to implement optimization passes.""

This reverts commit 1ddbf6d4b37979a9f11a203c12befd5ae8b65df4.

Change-Id: I110a14668d1564ee0604dc958b91394b40da89fc
26a25ef62a13f409f941aa39825a51b4d6f0f047 30-Sep-2014 Nicolas Geoffray <ngeoffray@google.com> Add a prepare for register allocation pass.

- Currently the pass just changes the uses of checks to the
actual values.
- Also optimize array access, now that inputs can be constants.
- And fix another bug in the register allocator reveiled by
this change.

Change-Id: I43be0dbde9330ee5c8f9d678de11361292d8bd98
1ddbf6d4b37979a9f11a203c12befd5ae8b65df4 01-Oct-2014 Nicolas Geoffray <ngeoffray@google.com> Revert "Introduce a class to implement optimization passes."

This reverts commit bf9cd7ba2118a75f5aa9b56241c4d5fa00dedeb8.

Change-Id: I0a483446666c9c24c45925a5fc199debdefd8b3e
bf9cd7ba2118a75f5aa9b56241c4d5fa00dedeb8 30-Sep-2014 Roland Levillain <rpl@google.com> Introduce a class to implement optimization passes.

- Add art::HOptimization.
- Rename art::ConstantPropagation to art::HConstantFolding in
compiler/optimizing/constant_folding.h to avoid name
clashes with a class of the same name in
compiler/dex/post_opt_passes.h.
- Rename art::DeadCodeElimination to
art::HDeadCodeElimination for consistency reasons.
- Have art::HDeadCodeElimination and art::HConstantFolding
derive from art::HOptimization.
- Start to use these optimizations in
art:OptimizingCompiler::TryCompile.

Change-Id: Iaab350c122d87b2333b3760312b15c0592d7e010
3c04974a90b0e03f4b509010bff49f0b2a3da57f 24-Sep-2014 Nicolas Geoffray <ngeoffray@google.com> Optimize suspend checks in optimizing compiler.

- Remove the ones added during graph build (they were added
for the baseline code generator).
- Emit them at loop back edges after phi moves, so that the test
can directly jump to the loop header.
- Fix x86 and x86_64 suspend check by using cmpw instead of cmpl.

Change-Id: I6fad5795a55705d86c9e1cb85bf5d63dadfafa2a
d31cf3d55a0847c018c4eaa2b349b8eea509de64 08-Sep-2014 Nicolas Geoffray <ngeoffray@google.com> First optimization in new compiler: simple GVN.

Change-Id: Ibe0efa4e84fd020a53ded310a92e0b4363f91b12
ce71ae7daca2e9ae4eec42d7445013c37d96e385 18-Sep-2014 Nicolas Geoffray <ngeoffray@google.com> It can be that no method has been compiled.

Therefore do not divide by 0, but log it.

Change-Id: Iee7760ab7f31c73e90d62387e5fb6fb7aa2c56e2
88157efc1e16707d4ae10775d4acb15121c50fe7 12-Sep-2014 Nicolas Geoffray <ngeoffray@google.com> Add the "time" compilation filter and output compilation stats.

A "time" compiler filter means the compiler optimizes for
compile time.

Change-Id: Id1a207ceb2d95f3548aae5e45d51b80695da2029
3946844c34ad965515f677084b07d663d70ad1b8 02-Sep-2014 Nicolas Geoffray <ngeoffray@google.com> Runtime support for the new stack maps for the opt compiler.

Now most of the methods supported by the compiler can be optimized,
instead of using the baseline.

Change-Id: I80ab36a34913fa4e7dd576c7bf55af63594dc1fa
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
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>
8d486731559ba0c5e12c27b4a507181333702b7e 16-Jul-2014 Nicolas Geoffray <ngeoffray@google.com> Use the thumb2 assembler for the optimizing compiler.

Change-Id: I2b058f4433504dc3299c06f5cb0b5ab12f34aa82
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
7dc206a53a42a658f52d5cb0b7e79b47da370c9b 11-Jul-2014 Nicolas Geoffray <ngeoffray@google.com> Add two phi pruning phases.

Change-Id: Ic4f05e3df96970d78a6938b27cdf9b58ef3849b9
8fb5ce3a7e1dec587642f900be86729c10224174 04-Jul-2014 Nicolas Geoffray <ngeoffray@google.com> Do not attempt to compile on architectures we do not support.

Change-Id: I431edff0a753a7fa37c79bdf7ab918d6747667a4
20550910e608ed7d86db97927d2ce9d2191061a4 25-Jun-2014 Nicolas Geoffray <ngeoffray@google.com> Re-enable tests with the optimizing compiler.

Tests run ok on my host/target. I reverted the move to
using thumb2, because tests were crashing. But I could not
reproduce file limits issues.

Change-Id: I26bc4ec1eb6c227750d11210e012d9d3b1d824af
f61b5377068f22c0be7b2f6e62961e620408beb2 25-Jun-2014 Nicolas Geoffray <ngeoffray@google.com> Re-enable tests with the optimizing compiler.

Tests run ok on my host/target. I reverted the move to
using thumb2, because tests were crashing. But I could not
reproduce file limits issues.

Make SignalTest as crashing for optimizing. We need to implement
stack overflow checks.

Change-Id: Ieda575501eaf30af7aaa2c44e71544c9c467c24f
e61fd353c06f51f1b8ca5af69997d0185b7659b2 25-Jun-2014 Nicolas Geoffray <ngeoffray@google.com> Revert "Re-enable tests with the optimizing compiler."

This reverts commit 20550910e608ed7d86db97927d2ce9d2191061a4.

Change-Id: Ic28b719946c795378838a18162a2a2b2cf41a0e8
20dfc797dc631bf8d655dcf123f46f13332d3074 17-Jun-2014 Dave Allison <dallison@google.com> Add some more instruction support to optimizing compiler.

This adds a few more DEX instructions to the optimizing compiler's
builder (constants, moves, if_xx, etc).

Also:
* Changes the codegen for IF_XX instructions to use a condition
rather than comparing a value against 0.
* Fixes some instructions in the ARM disassembler.
* Fixes PushList and PopList in the thumb2 assembler.
* Switches the assembler for the optimizing compiler to thumb2
rather than ARM.

Change-Id: Iaafcd02243ccc5b03a054ef7a15285b84c06740f
86dbb9a12119273039ce272b41c809fa548b37b6 04-Jun-2014 Nicolas Geoffray <ngeoffray@google.com> Final CL to enable register allocation on x86.

This CL implements:
1) Resolution after allocation: connecting the locations
allocated to an interval within a block and between blocks.
2) Handling of fixed registers: some instructions require
inputs/output to be at a specific location, and the allocator
needs to deal with them in a special way.
3) ParallelMoveResolver::EmitNativeCode for x86.

Change-Id: I0da6bd7eb66877987148b87c3be6a983b4e3f858
31d76b42ef5165351499da3f8ee0ac147428c5ed 09-Jun-2014 Nicolas Geoffray <ngeoffray@google.com> Plug code generator into liveness analysis.

Also implement spill slot support.

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

Merge ART from AOSP to lmp-preview-dev.

Change-Id: I0f578733a4b8756fd780d4a052ad69b746f687a9
a7062e05e6048c7f817d784a5b94e3122e25b1ec 22-May-2014 Nicolas Geoffray <ngeoffray@google.com> Add a linear scan register allocator to the optimizing compiler.

This is a "by-the-book" implementation. It currently only deals
with allocating registers, with no hint optimizations.

The changes remaining to make it functional are:
- Allocate spill slots.
- Resolution and placements of Move instructions.
- Connect it to the code generator.

Change-Id: Ie0b2f6ba1b98da85425be721ce4afecd6b4012a4
ddb311fdeca82ca628fed694c4702f463b5c4927 16-May-2014 Nicolas Geoffray <ngeoffray@google.com> Build live ranges in preparation for register allocation.

Change-Id: I7ae24afaa4e49276136bf34f4ba7d62db7f28c01
f635e63318447ca04731b265a86a573c9ed1737c 14-May-2014 Nicolas Geoffray <ngeoffray@google.com> Add a compilation tracing mechanism to the new compiler.

Code mostly imported from: https://android-review.googlesource.com/#/c/81653/.

Change-Id: I150fe942be0fb270e03fabb19032180f7a065d13
622d9c31febd950255b36a48b47e1f630197c5fe 12-May-2014 Nicolas Geoffray <ngeoffray@google.com> Add loop recognition and CFG simplifications in new compiler.

We do three simplifications:
- Split critical edges, for code generation from SSA (new).
- Ensure one back edge per loop, to simplify loop recognition (new).
- Ensure only one pre header for a loop, to simplify SSA creation (existing).

Change-Id: I9bfccd4b236a00486a261078627b091c8a68be33
804d09372cc3d80d537da1489da4a45e0e19aa5d 02-May-2014 Nicolas Geoffray <ngeoffray@google.com> Build live-in, live-out and kill sets for each block.

This information will be used when computing live ranges of
instructions.

Change-Id: I345ee833c1ccb4a8e725c7976453f6d58d350d74
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
c32e770f21540e4e9eda6dc7f770e745d33f1b9f 24-Apr-2014 Nicolas Geoffray <ngeoffray@google.com> Add a Transform to SSA phase to the optimizing compiler.

Change-Id: Ia9700756a0396d797a00b529896487d52c989329
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
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
8ccc3f5d06fd217cdaabd37e743adab2031d3720 19-Mar-2014 Nicolas Geoffray <ngeoffray@google.com> Add support for invoke-static in optimizing compiler.

Support is limited to calls without parameters and returning
void. For simplicity, we currently follow the Quick ABI.

Change-Id: I54805161141b7eac5959f1cae0dc138dd0b2e8a5
92cf83e001357329cbf41fa15a6e053fab6f4933 18-Mar-2014 Nicolas Geoffray <ngeoffray@google.com> Run Java tests with the optimizing compiler.

Also fix a vector.reserve -> vector.resize braino, and build
a GC map that dex2oat expects.

Change-Id: I6acf2f90a4c32f90b79bf7709bf2e43931b98757
787c3076635cf117eb646c5a89a9014b2072fb44 17-Mar-2014 Nicolas Geoffray <ngeoffray@google.com> Plug new optimizing compiler in compilation pipeline.

Also rename accessors to ART's conventions.

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