History log of /art/runtime/interpreter/interpreter_common.cc
Revision Date Author Comments
76e6adb99db915381da89615f303b3b190c547b1 23-Feb-2018 Orion Hodson <oth@google.com> Use ASM for invoke-custom tests

Removes the dependency of binary blobs generated by the jack compiler.

Fixes the exception chain raised when a bootstrap method returns null.

Bug: 73807070
Test: art/test/run-test --host 952-invoke-custom
Change-Id: Iac615cdeec342b1b67f50bb1258768e199adff10
e416979a83aa5d83461a3d116889928fff88ec7c 09-Feb-2018 Orion Hodson <oth@google.com> ART: Fix lookup class used by invoke-custom

Test: art/test/testrunner/testrunner.py --host -b -j32 -t 952-invoke-custom-lookup
Bug: b/73056094
Change-Id: Ie83a35fe8c28527a58ed2a4bd66bd53c1c1a9d78
928033d81f63912f669acd27a72897694eb31db6 07-Feb-2018 Orion Hodson <oth@google.com> Revert^2 "ART: Interpreter support for VarHandle accessors"

This reverts commit c4d3bf4eaff9720ed0bb7775db6fc24a1bd755dd.

Bug: 65872996
Test: art/test/testrunner.py -b --host
Change-Id: I2d1017c45cee5b2fd2dd05e5eeff0a72146663b1
c4d3bf4eaff9720ed0bb7775db6fc24a1bd755dd 06-Feb-2018 Orion Hodson <oth@google.com> Revert "ART: Interpreter support for VarHandle accessors"

This reverts commit becc83b59ff703c02198f832dbc3216a0ab8a022.

Reason for revert: breaks on the ART buildbots due to localized toolchain differences.

Change-Id: Ieb1d93b0fc7116ddc542d8bbfee1975bcb30a8f7
becc83b59ff703c02198f832dbc3216a0ab8a022 08-Dec-2017 Orion Hodson <oth@google.com> ART: Interpreter support for VarHandle accessors

Add support for invoking VarHandle accessors in the interpreter and
forces code with VarHandles accessor invocations to use the interpreter.

Bug: 65872996
Test: art/test/run-test --host 712
Change-Id: I9ee3ad6aef6a3bc73d90cec0a8e023e5db42b7a2
da1cdd0b1f89ef76def1c5fa8d2bea83c1a6cf48 31-Jan-2018 Orion Hodson <oth@google.com> ART: Fix call site resolution

Parameter type resolution should use the target method's DEX file.

Bug: 70166093
Test: art/test/run-test --host 714
Change-Id: Ic4961a905144ee85b36d02476506c4078c6cdf7a
0225f8e2939a9340cb7dcebfcfe7996a2bd9bce9 31-Jan-2018 David Sehr <sehr@google.com> Revert "Revert "Make libdexfile build independent of runtime dir""

This reverts commit 787784f9effb126b5d0d3dc97d544c4a477b5daf.

Reason for revert: Bot configuration issue.

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

This reverts commit b40b7e73469339a6b667b4a2e2b8690112a74dc9.

Reason for revert: on device libdexfile.so missing

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

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

Bug: 22322814
Test: make -j 50 test-art-host
Change-Id: Ifaf695216e4a0e43d3aa377984d933f7a2a243c2
9e734c7ab4599d7747a05db0dc73c7b668cb6683 05-Jan-2018 David Sehr <sehr@google.com> Create dex subdirectory

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

Bug: 71361973
Test: make -j 50 test-art-host
Change-Id: I59e984ed660b93e0776556308be3d653722f5223
808c7a57bb913b13c22884f57cdacd59bf1fdb3f 15-Dec-2017 Mathieu Chartier <mathieuc@google.com> Make CodeItem fields private

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

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

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

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

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

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

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

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

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

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

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

Test: m test-art-host-gtest
Test: testrunner.py --host --optimizing
Change-Id: I00634b89013b7348460aa73561fa14be7c8cdb7e
960d4f7c5f6a464aa00b8f393cc88996c55464f3 10-Nov-2017 Orion Hodson <oth@google.com> ART: Simplify MethodHandle invocations

Use an operand iterator rather than passing arguments for both
range and varargs operands.

Test: art/test.py --host -j32
Change-Id: Ia42398773bd3732d917e19c25aa431b1e1369320
43f0cdbe3281cd5c9a33d5472b1538e5617f6691 10-Oct-2017 Orion Hodson <oth@google.com> ART: Intrinsify polymorphic signature methods

Adds VarHandle accessor method to list of intrinsics.

Adds code to interpreter to ensure intrinsics with polymorphic
signatures are initialized.

Rename most uses of InvokePolymorphic to InvokeMethodHandle (and
similar changes) to be clear that the particular code path applies to
MethodHandle instances rather than VarHandle.

Change-Id: Ib74865124a1e986badc0a7c4bb3d782af07225d4
Bug: 65872996
Test: art/test.py --host
e7732be2390f00b1f98b8c0066a37892ee1126f6 11-Oct-2017 Orion Hodson <oth@google.com> ART: Implement missing mterp handlers

Adds mterp handlers for const-method-{handle,type}, invoke-custom, and
invoke-polymorphic.

Minor refactoring starting from interpreter_common.{h,cc} for consistency.

Test: m test-art-host
Bug: 65872996
Change-Id: I95cda758d1ce2fb52e3b1c6211e5d1763cee7bd6
848574ca50bb7e2d109608359d1086b3ca6bb4b3 26-Sep-2017 Alex Light <allight@google.com> Implement asynchronous exception support

This CL implements async exception support in the switch interpreter.
It also adds support for the MTerp to detect and switch back to the
switch interpreter in cases where an async exception is detected.

Tests follow in next CL.

Test: ./test.py --host -j50

Bug: 62821960
Bug: 34415266

Change-Id: Idb53711a40c20f962de8aa6b74662676b8bd25c6
e2abbc604ce003c776c00ecf1293796bb4c4ac5a 15-Sep-2017 Andreas Gampe <agampe@google.com> ART: Move kDexNoIndex to dex_file_types.h

Define the constant with the types to allow lowering the dependency
on DexFile.

Test: m
Change-Id: I3c61421db45be96d2057e01b1a7825883d8bd178
9fb1ab1f6bb58bdaccef78bc81b3202d0121e2ed 05-Sep-2017 Alex Light <allight@google.com> Revert "Revert "JVMTI Exception and ExceptionCatch events""

Fixed error where we were incorrectly not updating a ShadowFrame
dex_pc causing deoptimization errors.

Bug: 62821960
Bug: 65049545

Test: ./test.py --host -j50
Test: ./art/tools/run-libcore-tests.sh \
--mode=host --variant-X32 --debug

This reverts commit 959742483885779f106e000df6dd422fc8657931.

Change-Id: I91ab2bc3e645ddf0359c189b19a59a3ecf0d8921
959742483885779f106e000df6dd422fc8657931 04-Sep-2017 Nicolas Geoffray <ngeoffray@google.com> Revert "JVMTI Exception and ExceptionCatch events"

Breaks tests.

Bug: 62821960
Bug: 65049545

This reverts commit 798eab03120f6189e8f6aa804d67af1b1d9f00b0.

Change-Id: Ie96903df06bbbe41f288f5b75a5114b142998fac
798eab03120f6189e8f6aa804d67af1b1d9f00b0 23-Aug-2017 Alex Light <allight@google.com> JVMTI Exception and ExceptionCatch events

Add support for the JVMTI can_generate_exception_events capability.
This includes the Exception and ExceptionCatch events and all their
associated behaviors.

Test: ./test.py --host -j50
Bug: 62821960
Bug: 65049545

Change-Id: I21cc8522c01033cdeb47bf34fa433bf04bf7ca5c
e814f9d09c0fb1b678e610780d11ce3577db3599 01-Aug-2017 Alex Light <allight@google.com> JVMTI NotifyFramePop support

Adds support for the JVMTI can_generate_frame_pop_events capability.
This includes the NotifyFramePop function and the FramePop event.

We mark the interpreter shadowframes directly to get the events. This
relies on the fact that we never replace extant shadow-frames on the
interpreter stack to ensure that we can distinguish which jvmti-envs
requested the frame pops.

Test: ./test.py --host -j50
Bug: 34414072
Bug: 62821960
Bug: 65129403

Change-Id: I6e79e39f62fdf79268540c5c1be6311df704cff7
6e1607e247d979a1671a1fd5a98de3f1031fe719 23-Aug-2017 Alex Light <allight@google.com> Rename instrumentation ExceptionCaught to ExceptionThrown

The instrumentation ExceptionCaught event was badly named since it is
actually sent at the time the exception is thrown and is sent even if
the exception is never actually caught. Rename it and associated
methods/fields to ExceptionThrown to more accurately reflect the
event's semantics.

Test: ./test.py --host -j50
Change-Id: I1e9c401ab619259b25928dbf19f62d3fa9573d47
e5071cc58a3cdea4a88257be3c8fd4d012a64c74 12-Jun-2017 Vladimir Marko <vmarko@google.com> ART: Change method lookup to be more consistent to JLS and the RI.

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

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

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

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

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

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

(cherry picked from commit ba118827465d12177f3996e50133960087b1c916)

Change-Id: Ic73e4adf02b5cd66b5a22a3b619dc781357db14c
bd208d8e73084b691d9cfbe870120fe53863ce07 12-Jul-2017 Chang Xing <chxing@google.com> Read and write constraints for clinit

For clinits executed during pre-compile within a transaction, they are
constrained to only be able to access their own static fields because
the results of iniitialization relying on static fields, either read or
write, of other classes are runtiime determined.

Further discussion can be found at b/62887449.

When SGET and SPUT series instructions are executed, interpreter will
check whether fields are static and does the target match with the
transaction owner, if not, abort transaction and throw an exception.

Test: make test-art-host -j64
Bug: 62887449
Change-Id: I3e655269c8af5f0b3f2c1841fdd2602c827c2757
b45528c1f1b83ca8c970f439b54fbfcfda6908ea 27-Jul-2017 Vladimir Marko <vmarko@google.com> ART: Refactor retrieval of types through ArtMethod.

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

Test: m test-art-host-gtest
Test: testrunner.py --host
Change-Id: I0b7eaa1fadc2ffa8c0168203790467f91a126963
8cf9cb386cd9286d67e879f1ee501ec00d72a4e1 19-Jul-2017 Andreas Gampe <agampe@google.com> ART: Include cleanup

Let clang-format reorder the header includes.

Derived with:

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

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

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

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

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

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

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

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

Test: art/test/run-test --host --jvm 162-method-resolution
Test: m test-art-host-gtest
Test: testrunner.py --host
Test: testrunner.py --host --interp-ac
Test: Nexus 6P boots.
Test: testrunner.py --target
Bug: 62855082
Bug: 30627598
Change-Id: If450c8cff2751369011d649c25d28a482a2c61a3
448bbcfc76426d6dfc336954df51bdad47f34ef7 06-Jul-2017 Mathieu Chartier <mathieuc@google.com> Avoid cross compilation error in DoCallCommon

Avoid calling ShouldUseInterpreterEntrypoint in DoCallCommon for
unstarted runtimes. This fixes a cross compilation error caused by
reading past the end of a 32 bit ArtMethod with a 64 bit dex2oat.

Test: test-art-host ART_TEST_INTERPRETER=true
Bug: 62402160
Change-Id: I792d4e1663dd13ac3836b7ce439e8286cb0a1bc3
631827d9b200c93f24816c6869d72426f9fed8e3 10-Apr-2017 Orion Hodson <oth@google.com> Fixes for constant method handles

Add support for constant direct and interface method handles in the
DEX file.

Add error handling for field and method resolution failures in
ClassLinker::ResolveMethodHandle().

Bug: 36957105
Test: art/test/run-test --host 952-invoke-custom-kinds
Change-Id: I91a2a23ba3365310eccb8cadd193b62f57e5811c
084fa370a14edc43dcf8ff4e454e04c863e1a130 16-Jun-2017 Alex Light <allight@google.com> Add field access & modify JVMTI callbacks

This adds support for the FieldAccess and FieldModification callbacks
in JVMTI and all other functions and behaviors associated with the
can_generate_field_modification_events and
can_generate_field_access_events capabilities.

Tests follow in the next CL.

Bug: 34409228
Test: ./test.py --host -j40

Change-Id: Id18fc53677cc1f96e1460c498ade7607219d5a79
513061a792b22c417c938d31c19581390709561c 01-Jun-2017 Andreas Gampe <agampe@google.com> ART: Clean up thread.h and thread_list.h

Remove dependency on stack.h and gc_root.h. Remove unused object
callbacks include. Factor out ManagedStack into its own set of files.
Fix up users of transitive includes.

Test: m test-art-host
Change-Id: I01286c43d8c7710948c161b1348faabb05922e59
5ea8413714ceec50a758df6614dc4a3ec6179112 06-May-2017 Jeff Hao <jeffhao@google.com> Stop interpreter from accessing code items of compiled code.

The ArtInterpreterToCompiledCodeBridge accesses the code item in a
number of places to handle argument marshalling. However, the code item
of a compiled method should have no need to be accessed by the runtime
at all, since the code has been compiled. By removing these accesses,
there is a drop in the memory footprint of the dex file, since these
code items remain untouched by the runtime.

Includes fixes for JIT and deopt.

For Maps:
Systrace vdex memory usage: 19.4/33.4MB -> 18.8/33.4MB
Dumpsys meminfo vdex PSS: 9371kB -> 9275kB

Bug: 35800981
Test: mm test-art-host
Change-Id: I3bf17f8866287d9a8f127c16da23bebb801456dc
ef65271c52cff9b39aeb5f326a605e4753214ab2 18-May-2017 Nicolas Geoffray <ngeoffray@google.com> Revert "Stop interpreter from accessing code items of compiled code."

The entrypoint of a method can change concurrently.

Bug: 35800981

This reverts commit 178dce79220c16e6f0061bcd12e9e9683ec045ee.

Change-Id: I25ae8d0d2830eb8412c52f61736bac7b16281c11
178dce79220c16e6f0061bcd12e9e9683ec045ee 06-May-2017 Jeff Hao <jeffhao@google.com> Stop interpreter from accessing code items of compiled code.

The ArtInterpreterToCompiledCodeBridge accesses the code item in a
number of places to handle argument marshalling. However, the code item
of a compiled method should have no need to be accessed by the runtime
at all, since the code has been compiled. By removing these accesses,
there is a drop in the memory footprint of the dex file, since these
code items remain untouched by the runtime.

Maps Vdex Memory Usage: 19.4/33.4MB -> 18.8/33.4MB

Bug: 35800981
Test: mm test-art-host
Change-Id: I147a9267ec022547b384374e1449d20bcab1ead2
76c1965179bdf34ed9d0dded046c7ad6f277de3f 24-Apr-2017 Andreas Gampe <agampe@google.com> ART: More header cleanup - method_verifier.h

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

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

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

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

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

Test: source build/envsetup.sh && lunch aosp_angler-userdebug && mmma art
Test: source build/envsetup.sh && lunch aosp_mips64-userdebug && mmma art
Change-Id: I8f60f1160c2a702fdf3598149dae38f6fa6bc851
01822299e8c3a7827d6613cd08fca6aa52c4ae42 09-Mar-2017 Nicolas Geoffray <ngeoffray@google.com> Revert "Stop interpreter from accessing code items of compiled code."

Bug: 35800981

This reverts commit df79ddb545f0d6e71d6eebb9cb94aa6916351ee9.

Change-Id: I04b1cb8d002ca330c0aa6e68b431c7f80c2779d6
df79ddb545f0d6e71d6eebb9cb94aa6916351ee9 27-Feb-2017 Jeff Hao <jeffhao@google.com> Stop interpreter from accessing code items of compiled code.

The ArtInterpreterToCompiledCodeBridge accesses the code item in a
number of places to handle argument marshalling. However, the code item
of a compiled method should have no need to be accessed by the runtime
at all, since the code has been compiled. By removing these accesses,
there is a drop in the memory footprint of the dex file, since these
code items remain untouched by the runtime.

Bug: 35800981
Test: mm test-art-host
Change-Id: Ib7d29c17e80b1690aa819d083f5b12739492ebd6
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
c069a30d42aefd902c20e8bc09dfad1683f07ded 18-Jan-2017 Orion Hodson <oth@google.com> ART: invoke-custom support

Adds invoke-custom instruction to the interpreter.

Bug: 33191717,30550796
Test: art/test/run-test --host 952
Change-Id: I3b754128649a8b3a00ade79ba2518d0e377f3a1e
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
8631a46d6d93d739428873b9b4053d228b9b5cfa 20-Jan-2017 Alexey Frunze <Alexey.Frunze@imgtec.com> Fix polymorphic invokes (one more round).

memcpy() exhibits undefined behavior when the source and the
destination overlap. Use memmove() instead.

This fixes test failures when running the below tests on MIPS.

Test: booted MIPS32R2 in QEMU
Test: ./run-test --interpreter 953-invoke-polymorphic-compiler
Test: ./run-test --interpreter 955-methodhandles-smali
Test: ./run-test --interpreter 956-methodhandles
Test: ./run-test --interpreter 957-methodhandle-transforms
Test: ./run-test --interpreter 958-methodhandle-emulated-stackframe
Test: ./run-test --interpreter 959-invoke-polymorphic-accessors

Change-Id: Ia17ff25001faa7d91ce1178ab35313c36e75aa07
942fd3130254d8276cbfe8e6201825e9c49e9b2c 16-Jan-2017 Vladimir Marko <vmarko@google.com> Reduce using ArtMethod's dex_cache_resolved_types_.

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

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

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

Test: m test-art-host
Bug: 30627598
Change-Id: Ic45a5ff8c66b79429e440cbc08d67bf22a083682
811bd5ff0189122d34e8a1b8ccda889bbba4c0d1 07-Dec-2016 Orion Hodson <oth@google.com> ART: Make method handle runtime code callable from compiler.

Most of this change is moving the existing method handles code, but it
also introduces a new header file, common_dex_operations.h, that has
some operations taken from interpreter_common.{h,cc} that are also used
by method handles (perform call, set field, get field).

Bug: 30550796
Test: m test-art-host
Change-Id: I2235e13770a5562950f2767f65a25ca273479150
46ee31b67d7ee1bd085fbc240502053caa3cf8fa 14-Dec-2016 Andreas Gampe <agampe@google.com> ART: Move to libbase StringPrintf

Remove ART's StringPrintf implementation. Fix up clients. Add
missing includes where necessary.

Test: m test-art-host
Change-Id: I564038d5868595ac3bb88d641af1000cea940e5a
cfa325e4ca65603fdb03a836a6cb394d23ed511f 13-Oct-2016 Orion Hodson <oth@google.com> ART: Add verifier support for invoke-polymorphic.

Change-Id: I1e1860cad80db46320c3ef5a9eaceb7529ea68d7
Bug: 30550796,33099829,33191712
Test: make test-art-host
1c87878ca87b0c5dde08416ef75615632eace7ac 25-Nov-2016 Orion Hodson <oth@google.com> Revert "Revert "Method Handles: Add VarargsCollector.""

This reverts commit 12af7a41c224923fb55699305008214636a1a3da.

Test: m test-art-host-run-test-956-methodhandles
Bug: 30550796
Change-Id: Ia820093bab919667729daba5b14330de51a63f79
fef0664fa7b480032f17c60f767bcca43a659d8a 25-Nov-2016 Orion Hodson <oth@google.com> ART: Throw InternalError rather than VirtualMachineError

Instantiate InternalError instead of VirtualMachineError as the latter
is abstract and not instantiable.

Change-Id: I3e90b28a34bef02dd1c200c02cb832aa8dce10b3
12af7a41c224923fb55699305008214636a1a3da 25-Nov-2016 Orion Hodson <oth@google.com> Revert "Method Handles: Add VarargsCollector."

This reverts commit ab52ce1480d9c4701bfe3ff3530596ec0c5760ee.

Change-Id: Idc6dd28b58a61cbd2c9ee72e8a0eeb07b2ca0edf
ab52ce1480d9c4701bfe3ff3530596ec0c5760ee 11-Nov-2016 Orion Hodson <oth@google.com> Method Handles: Add VarargsCollector.

Enable support for methods with variable arity arguments.

Test: m test-art-host-run-test-956-methodhandles
Bug: 30550796

Change-Id: I205724ddacc6c9840e18093a3984c1ad6e54394a
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
6beced4c017826f7c449f12fac7fa42403657f2b 16-Nov-2016 Mathieu Chartier <mathieuc@google.com> Change iftable to never be null

Simplifies code generation by removing a null check. The null case
is rare.

Ritzperf code size: 13107624 -> 13095336

Also addressed comments from previous CL.

Bug: 32577579

Test: test-art-host, run ritzperf both with CC

Change-Id: I2b31e800867112869d7f0643e16c08826296979e
1a06f9f67a4e91610d2a050093b36de264904916 09-Nov-2016 Orion Hodson <oth@google.com> MethodHandles: Enable return value conversions.

Enables return values conversions and simplify the type conversion
logic. Ensures check for WrongMethodTypeExceptions before invoking a
method handle.

Test: m test-art-host-run-test-956-methodhandles
Bug: 30550796

Change-Id: I8add3ad0a19b43010946b4fb9f1c0f0949287860
751e2886f00eba428f5f9ef478befe712bb4ef4b 09-Nov-2016 Narayan Kamath <narayan@google.com> MethodHandles: Remove obsolete TODO.

It was addressed by change 0d781e6e17a3f6285736c590001b59d50879f13b.

Test: make build-art-host
Change-Id: Ifb3f7fa2ffc245e88c77ca41268c376be1611308
0d781e6e17a3f6285736c590001b59d50879f13b 04-Nov-2016 Orion Hodson <oth@google.com> MethodHandles: Constructor support

Test: m test-art-host-run-test-956-methodhandles
Bug: 30550796

Change-Id: Ied466d7e0f0f0b472e3a28909ca712dfdb99e422
ba28f9f62f9908e04be3097f900db4701dd3d392 26-Oct-2016 Orion Hodson <oth@google.com> Argument conversions for setter/getter MethodHandles.

Test: m test-art-host-run-test-959-invoke-polymorphic-accessors
Bug: 30550796

Change-Id: I9898605fc9f9f8a80f47f9559f3ccb99b02b07c8
0c14d8b10e8528f8143d9ed7f45da812fcd86885 03-Nov-2016 Orion Hodson <oth@google.com> ART: Additional initialization for MethodHandle accessors.

Ensure classes are initialized before static fields are touched by
MethodHandle setters and getters.

Bug: 30550796
Test: m test-art-host-run-test-979-invoke-polymorphic-accessors
Change-Id: Ibac4372607ecbb4e6f7347b89cef6d280632c835
0a8485ef5cb81746625fe57acf8adfd8b2bb28c0 02-Nov-2016 Narayan Kamath <narayan@google.com> MethodHandles: Implement MethodHandle.asType.

Tracks libcore change 16fa583fb5ee489.

Test: make test-art-host
Bug: 30550796

Change-Id: I2457b563f67a183c4eebf94ddbe74cc55f772ee0
2cb856c47b884a08485e2f08e6a3ef6a5bbf773a 02-Nov-2016 Narayan Kamath <narayan@google.com> Address review comments from change 000e1885701c8f.

Style fixes, and better OOM handling.

bug: 30550796
Test: make test-art-host
Change-Id: I2ab58e25bd08daace6609ba45d860994a354280f
3e0dce0ff7e28f756ec4b8a08259517e5fb3776d 31-Oct-2016 Narayan Kamath <narayan@google.com> MethodHandles: Better detail message for WrongMethodTypeExceptions

We now include the type of the callee and the callsite.

This change also fixes a call to ThrowWrongMethodTypeException that
passed arguments in the wrong order.

Test: make test-art-host

Change-Id: I3ced2e331cb49b616a8374f5a604dafa37330059
6fcc5e8e0fb4298c83286ae5a5bcd0d06180f356 31-Oct-2016 Narayan Kamath <narayan@google.com> Interpreter: fix build.

Due to unfortunate commit timing.

Test: make build-art-host
Change-Id: Ie523399309b20836ab9f7a8a8224c5cb41bc79fc
3d617ac3d87f7fa98793406818e54b057bd701a1 19-Oct-2016 Orion Hodson <oth@google.com> Getter/Setter support for invoke-polymorphic of invokeExact().

Test: make test-art-host
Bug: 30550796

Change-Id: I427a6e0afba88b223655ad1ba30843aaf255182b
000e1885701c8fdad07a784e3771881fa9be1d8a 24-Oct-2016 Narayan Kamath <narayan@google.com> method_handles: Complete support for emulated stack frames.

Most of this change is a refactor that templatizes the code
that performs argument conversions. This allows us to copy arguments
between two shadow frames, or an emulated stack frame and a shadow
frame.

Test: make test-art-host
Bug: 30550796

Change-Id: I23e65735a2dbd28f3c7b7d1ccf9762e77e0cf1f1
a314773a624f9f51391be91bda3472bbdbe0050e 27-Oct-2016 Mathieu Chartier <mathieuc@google.com> Add handle wrapper for interpreter iget/iput quick

JDWP has thread suspension in instrumentation listeners. The fix is
to use handle wrappers here. This change fixes JDWP tests.

Bug: 31113334

Test: art/tools/run-jdwp-tests.sh '--mode=host' '--variant=X64' --debug

Change-Id: Ic7dcb1201ec44946e8002547b2f7f5645b4dea48
e22305b8a093a892a10029e905064776fd2082c5 27-Oct-2016 Mathieu Chartier <mathieuc@google.com> Add handle wrapper for DoCallCommon

Prevents potential moving GC bugs from thread suspension caused
by GetTypeItem. Fixes build-art.

Bug: 31113334

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

Change-Id: I9ef18b1d1dab61cc86a7468d535972eba51763f5
ef41db7a3f322a1feb305fdb457410c4cea94d00 26-Oct-2016 Mathieu Chartier <mathieuc@google.com> Move interpreter to ObjPtr

Moved most of interpreter, interpreter_common,
interpreter_switch_impl, and some of mterp to ObjPtr.

Bug: 31113334

Test: test-art-host ART_TEST_INTERPRETER=true
Test: art/tools/run-libcore-tests.sh '--mode=host' '--variant=X32' --debug

Change-Id: I0935d18287e1332205c17c5a018aa167788ab897
c3b7f1a34667386a2e55f59db795082a9e2408fd 19-Oct-2016 Narayan Kamath <narayan@google.com> Interpreter: Add support for method handle transforms [Part 1].

Method handle transformations are implemented in Java by
subclasses of java.lang.invoke.Transformers.Transformer. Transformer
extends MethodHandle and provides a transformer method defined like so:

public static class TransformerImpl extends Transformer {
@Override
public void transform(EmulatedStackFrame emulatedStackFrame) throws Throwable {
}
}

An EmulatedStackFrame is synthesized by the runtime based on the
caller stack frame and arguments specified by the instruction. It will
contain all input arguments to the method their associated types. It
will also exactly match the method type specified by the target handle
(i.e, argument coversions are performed by the runtime).

The transformer method operates on supplied EmulatedStackFrame
and other instance state to synthesize the transformation. In some
cases, these transformations will end up calling other signature
polymorphic methods. In those cases, the transformer can construct
an EmulatedStackFrame and issue the invoke passing that through as
the single input argument. For e.g,

EmulatedStackFrame sf = EmulatedStackFrame.newInstance();
sf.pushArgument("foo", String.class);
sf.pushIntArgument(42);

// The callsite type for this polymorphic invoke is
// (Ldalvik/system/EmulatedStackFrame)V;
delegate.invoke(sf);

The runtime will treat such polymorphic invokes specially and unmarshal
this EmulatedStackFrame on to the callee stack frame based on the type
and number of arguments contained in the EmulatedStackFrame and the
declared type of the target method handle.

In this change :

Adds the basic plumbing for transformer invokes. In particular, the code
for marshaling and unmarshaling emulated stack frames isn't implemented
and will be added in a follow up method. This plumbing is sufficient to
implement a test case of a method handle transform that doesn't need any
input arguments, so is trivially implementable without proper
EmulatedStackFrame support.

bug: 30550796
Test: make test-art-host
Change-Id: Iafa29accaef26d0a33f8b83713bed5d929df547e
da24650d142883ea9962eaedd479547bfe44bbf4 20-Oct-2016 Narayan Kamath <narayan@google.com> method_handles: Minor refactor of PerformArgumentConversions.

Separate out a method that can perform a single argument conversion.
Useful for Field setters and also for future use in transforming handles
where the input source will not be a stack frame.

Also remove unnecessary JValue* argument.

bug: 30550796
Test: make test-art-host
Change-Id: I75a63800839dbf1016a2c362169e138c83f34e4c
9bdaeebe6aca491b11a44999f571f0122ad87499 20-Oct-2016 Narayan Kamath <narayan@google.com> Revert "Revert "Interpreter: Add support for direct handle invokes on methods.""

This reverts commit cfa61ad52077df66a448b84c360b12bc6f0e3f51.

Test flakiness in 956-methodhandles is fixed by
d08e39b6f02368aaa668b5aae6b6077b3eb44d9c.

Test: make test-art-host

Change-Id: I56e02e9a5bbc2b992cf746a92fd95ea77d32456c
cfa61ad52077df66a448b84c360b12bc6f0e3f51 19-Oct-2016 Narayan Kamath <narayan@google.com> Revert "Interpreter: Add support for direct handle invokes on methods."

This reverts commit e5cd2cd7d0f8e1332f25edfd2798d84fec871f10.

Reverting due to flakiness in 956-methodhandles. Flakiness will be
fixed by 67f0929710a4489e3603383e57c9d236920654aa but might take time
to submit.

Change-Id: Ifdda5d3caca62d16d21cefaab7742fb2e8ca6969
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
e5cd2cd7d0f8e1332f25edfd2798d84fec871f10 14-Oct-2016 Narayan Kamath <narayan@google.com> Interpreter: Add support for direct handle invokes on methods.

Constructors are still not supported and will be implemented in a
follow up change.

Also adds a new run-test that compiles from source using an alpha
version of Jack.

Test: make test-art-host
bug: 30550796
Change-Id: I3212c032a5885854f691156c29f12613e5194667
208f857edf8361ddc4e85d82699935998e7179ac 03-Aug-2016 Narayan Kamath <narayan@google.com> interpreter: support for non-exact invokes.

Performs primitive argument conversions as well as boxing and unboxing
operations. Support for return value conversions will be added in a
follow up change.

Test: make test-art-host

Change-Id: I2e3348ff64a5826e477f87c12a7d5c390eb3a653
9823e788ed3368ecf826c44bfa16ccabfcbe32f8 03-Aug-2016 Narayan Kamath <narayan@google.com> Basic implementation of invoke / invoke-polymorphic.

Basic switch interpreter support for invoke-polymorphic. This change
allows for virtual/interface and static invokes on method handles.

Support for direct invokes (including constructors) and field
getters and setters will be added in follow up changes.

Bug: 30550796
Test: make test-art-host

Change-Id: Ieb3a991d974060d930d56467908d5c7c11d0e38e
1cc62e4ea24828fdb3f3da0b8603f0b107d09a04 04-Oct-2016 Mathieu Chartier <mathieuc@google.com> Rename ObjPtr::Decode to ObjPtr::Ptr

Done to prevent ambiguity with ScopedObjectAccess::Decode.

Bug: 31113334

Test: test-art-host
Change-Id: I07a2497cc9cf66386311798933547471987fc316
370423d7b2ed357f79b704ff369008cef3ac4772 03-Oct-2016 Narayan Kamath <narayan@google.com> interpreter: Remove unnecessary template arg from DoCallCommon.

The function was always called with a fixed size array so there's
no real advantage in templatizing it this way.

Test: make build-art-host

Change-Id: I782e113225f1c97877f2bcb5afe8df9ae8efd26e
0715c0b7c047053c54212ae247868675710fb29c 04-Oct-2016 Mathieu Chartier <mathieuc@google.com> Add handle wrapper for interpreter field get/set

The listeners have thread suspension for jdwp tests.

Bug: 31113334

Test: tools/run-jdwp-tests.sh '--mode=host' '--variant=X32' --no-jit --debug

Change-Id: I08f17432cc0c79ee9a0163eb88d4d6355f6851ca
3398c7874e002beaa6c2b2fadf183e7d1ddad23a 30-Sep-2016 Mathieu Chartier <mathieuc@google.com> Move ArtField to ObjPtr

Added EXPECT_OBJ_PTR_EQ and variants to gtests.

Fixed moving GC bugs in:
ClassLinker::CreatePathClassLoader
ClassLinkerTest: StaticFields

ObjPtr Decode call sites: 186 -> 181.

Some tests fail due to ResolvedFieldAccessTest, will fix in follow
up CL.

Bug: 31113334

Test: test-art-host CC baker

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

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

test: m test-art-host
test: m test-art-target
Change-Id: Ib8372d130d5458516a1f1ae31014afc76037fc34
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
14832efeb92334c562ebedef34e920d30e3cee69 05-Aug-2016 Narayan Kamath <narayan@google.com> Revert experimental lambda feature.

This is a revert of the following changes :

30c475a2046951a81769c2db0b2dad66cd71e189.
lambda: Minor capture-variable/liberate-variable clean-up after post-merge reviews.

6918bf13eb855b3aa8ccdddda2d27ae8c60cec56.
lambda: Experimental support for capture-variable and liberate-variable

fc1ccd740b7c8e96dfac675cfc580122cd1b40a6.
lambda: Infrastructure to support capture/liberate-variable dex opcodes

e2facc5b18cd756a8b5500fb3d90da69c9ee0fb7.
runtime: Add lambda box/unbox object equality

2ee54e249ad21c74f29a161e248bebe7d22fddf1.
runtime: Partially implement box-lambda and unbox-lambda experimental opcodes

158f35c98e2ec0d40d2c032b8cdce5fb60944a7f.
interpreter: Add experimental lambda opcodes for invoke/create-lambda

a3bb72036f5454e410467f7151dc89f725ae1151.
Added format 25x to dexdump(2).

Plus surrounding cleanups.

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

Move away from size_t to dedicated enum (class).

Bug: 30373134
Bug: 30419309
Test: m test-art-host
Change-Id: Id453c330f1065012e7d4f9fc24ac477cc9bb9269
6b2ddc8d347840b230b5984ce0f22b765e6cdf6c 19-May-2016 Mingyao Yang <mingyao@google.com> Revert "Revert "Move rewritten StringFactory call results into dex registers for deopt""

Potential gc points can make the result value stale. We now set the result value
to null proactively once it's moved to shadow frame registers. IsStringInit()
is written in a way that does string comparison instead of requiring method
resolution so that it doesn't have a gc point. Also we don't cache the callee
method during frame unwinding since the method may be rewritten already.

(cherry picked from commit ffedec510c07cf0f77d0cce51940838f2e630514)

Bug: 28555675

Change-Id: Ic51511a4a0fc84a852d8d907f91e7835f49ac478
ffedec510c07cf0f77d0cce51940838f2e630514 19-May-2016 Mingyao Yang <mingyao@google.com> Revert "Revert "Move rewritten StringFactory call results into dex registers for deopt""

Potential gc points can make the result value stale. We now set the result value
to null proactively once it's moved to shadow frame registers. IsStringInit()
is written in a way that does string comparison instead of requiring method
resolution so that it doesn't have a gc point. Also we don't cache the callee
method during frame unwinding since the method may be rewritten already.

Bug: 28555675

Change-Id: Ic51511a4a0fc84a852d8d907f91e7835f49ac478
5a6171d7909666cb58383e2b2a0c2f51ace3f5ef 19-May-2016 Roland Levillain <rpl@google.com> Revert "Move rewritten StringFactory call results into dex registers for deopt"

This reverts commit 0ea451b4d74e8ddc28ea5ce87ef6d21113a3cdd5.

597-deopt-new-string is failing.

Bug: 28846692
Bug: 28555675
Change-Id: I8274e5ae1d065dedc562132882b39e7f3fe5baf4
695e2c4aa1e61aa006412c83f15c4a659111a08a 19-May-2016 Hiroshi Yamauchi <yamauchi@google.com> Revert "Move rewritten StringFactory call results into dex registers for deopt"

This reverts commit 8ca33bf04060fadd5b35fa93fa56547c62fe52e7.

597-deopt-new-string is failing.

Bug: 28846692
Bug: 28555675
Change-Id: Ibfb59ec36e089c987ea64e4af4ca3709e536412a
0ea451b4d74e8ddc28ea5ce87ef6d21113a3cdd5 16-May-2016 Mingyao Yang <mingyao@google.com> Move rewritten StringFactory call results into dex registers for deopt

Bug: 28555675

(cherry picked from commit 8ca33bf04060fadd5b35fa93fa56547c62fe52e7)

Change-Id: I9236df283f2e83ca5dcde01f73dc0522d745cd59
8ca33bf04060fadd5b35fa93fa56547c62fe52e7 16-May-2016 Mingyao Yang <mingyao@google.com> Move rewritten StringFactory call results into dex registers for deopt

Bug: 28555675
Change-Id: I9236df283f2e83ca5dcde01f73dc0522d745cd59
f3f9cf6b65c4bcf9ea44253188d8d910b7cf7e64 14-Apr-2016 Nicolas Geoffray <ngeoffray@google.com> Add weight to compiled/interpreter transitions.

Also:
- Cleanup logging.
- Check ArtMethod status before adding compilation requests.
- Don't request osr compilation if we know AddSamples does not come
from a back edge.

Bug: 27865109

(cherry picked from commit 71cd50fb67fa48667b0ab59aa436a582c04ba43d)

Change-Id: Icbe89fe6cc495b113616391a8f257758d34b4b60
71cd50fb67fa48667b0ab59aa436a582c04ba43d 14-Apr-2016 Nicolas Geoffray <ngeoffray@google.com> Add weight to compiled/interpreter transitions.

Also:
- Cleanup logging.
- Check ArtMethod status before adding compilation requests.
- Don't request osr compilation if we know AddSamples does not come
from a back edge.

Bug: 27865109

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

This reverts commit ec3b7ab8f008f36f1072d4ba03da204229b95976.

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

This reverts commit 4b34bf5b242dce5ee20db08b7781bbbaf0d25969.

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

Bug: 27621360

(cherry picked from commit ec3b7ab8f008f36f1072d4ba03da204229b95976)

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

Bug: 27621360

Change-Id: I617eee243f475872235fd75b6a401e056111ea23
98e6ce44c700abd9375fe17f0aa31fea1e1e938b 16-Feb-2016 Nicolas Geoffray <ngeoffray@google.com> Remove string init map.

Partial revert of the String init change.

- Make Quick bailout in the presence of String allocation.
- Rely on the compiler for knowing when dex registers alias.

bug:27173201

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

This reverts commit 3a98aae1b9b20bc78dc5e05d2e60cb1d0072db02.

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

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

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

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

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

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

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

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

This reverts commit c94a61f06ffc13288c67891048128c987b29bf33.

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

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

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

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

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

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

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

Change-Id: Ia9022cbc1bbfcc072314b6c95f63a4bf8060c36c
9f95ba750583735cff1f2921b8014099dd801734 01-Feb-2016 Igor Murashkin <iam@google.com> interpreter: Fix proxy method invocation with access checks enabled.

Interpret with access checks uses type information stored by a dex file,
so we need to get the original interface method (which is guaranteed
to be dex file backed) in that case.

Does not change method invoke target, just the method used for checks.

The existing 044-proxy test already covers this, so no regression test
necessary. Remove fixed tests from the blacklist.

Bug: 26846861
Bug: 22414682
Change-Id: I28c3707e38c1f69ea9d3660f68136f688122ac4e
05d241565f36df825cf56a4f1b61bfb7e4dcb056 06-Jan-2016 Siva Chandra <sivachandra@google.com> Add option to never interpret.

Change-Id: Ib6d6170fa60c77c2e6a8844964f14fa0de4c9e7b
65902e86b91f984061657bd8cacf239edb53c39d 15-Jan-2016 David Brazdil <dbrazdil@google.com> ART: Optimize out redundant NewInstances of String

NewInstance of String creates an empty String object before it is
replaced by the result of a StringFactory call (String.<init>). If
the empty object is never used prior to the call, it can be safely
removed (replaced with null in this case).

We do not remove the instruction if:
- it has a real use (comparison, instanceof, check-cast), or
- we are compiling with --debuggable and there is an environment use.

If removed and execution deoptimizes before the StringFactory call,
the interpreter will see String.<init> being called on a null object.
Since the verifier guarantees that the call was made on new-instance
in the input bytecode (b/26579108), the interpreter can safely assume
that it was optimized out rather than throw NullPointerException.

Results (all without --debuggable):
- boot.oat: 563/563 removed
- Google Maps: 480/480 removed
- Google Docs: 819/819 removed

Change-Id: I9fdfc50e9dea6299a7327f94327cdfd2b2538079
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
03ec930faded5bbfa096533ce60b6893847922db 28-Aug-2015 Andreas Gampe <agampe@google.com> ART: Lock counting in the interpreter

To support structured locking when balanced-locking verification
failed, count lock and unlock operations in the verifier.

Bug: 23502994
Change-Id: I2bb915da6e3d43c49723a943b42d4d5a7c939aa1
3cfa4d05afa76e19ca99ec964b535a15c73683f0 07-Oct-2015 Andreas Gampe <agampe@google.com> ART: Remove interpreter entrypoints

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

Bump oat version.

Change-Id: Icdd92e20eafc5668b68eeebf55cf624560f462b3
6918bf13eb855b3aa8ccdddda2d27ae8c60cec56 28-Sep-2015 Igor Murashkin <iam@google.com> Revert "Revert "lambda: Experimental support for capture-variable and liberate-variable""

This reverts commit 7bbb80ab52c203e44d2ded2c947b3b03b4b31ec4.

Change-Id: If806ce5c6c5e96fdb2c3761dee096f74e7e5b001
7bbb80ab52c203e44d2ded2c947b3b03b4b31ec4 27-Sep-2015 Nicolas Geoffray <ngeoffray@google.com> Revert "lambda: Experimental support for capture-variable and liberate-variable"

Test fails.

This reverts commit b72123440d8541362ebdb131436f9dbdda5fd329.

Change-Id: Ic9ed92f8c826d8465eb36b746dc44af05caf041c
b72123440d8541362ebdb131436f9dbdda5fd329 25-Sep-2015 Igor Murashkin <iam@google.com> lambda: Experimental support for capture-variable and liberate-variable

Supports capturing/liberating any primitive variables.
No support for capturing objects/lambdas yet since they would both
need GC changes to track roots through closures.

Change-Id: Ibfb68bfe4c579dbf93823aac4c0e6ac8f6360c5d
b30259251b22430fad12f1adeab671e4bf8f88f5 01-Sep-2015 Andreas Gampe <agampe@google.com> ART: Use unique_ptr for alloca-ed ShadowFrames

To enable automated calls of the destructor (for extensions of
ShadowFrame), return a unique_ptr with a custom deleter. Use a
macro so that the alloca happens in the caller.

Change-Id: Id28a6ea131f108e4a94ff1699fc22e7b44aec018
78568351b22554c3a885216cd5be480dab88a951 21-Sep-2015 Vladimir Marko <vmarko@google.com> Fix locking on string init map (again).

Follow-up to
https://android-review.googlesource.com/172036 ,
https://android-review.googlesource.com/171621 .

Don't overwrite existing values, only insert new ones.
(Also improve performance by using move semantics.)

This prevents the following race: Thread 1 looks for string
init map for a method but doesn't find it, so it starts to
construct a new map. Thread 2 is doing the same but it's
faster and actually inserts the new map and keeps a pointer
to it. After Thread 2 releases the lock, Thread 1 acquires
it and starts to Overwrite() the element that the Thread 2
is currently using, so Thread 2 ends up looking at a map
that's being actively modified.

Change-Id: I135571af644363ea7bb282969a1bc7287b34f9b2
4686c52394c0221ee3236753ad6be48f18b79365 18-Sep-2015 Jeff Hao <jeffhao@google.com> Fix locking on string init map.

Related to: https://android-review.googlesource.com/#/c/171621

Change-Id: Ib6dcf9914f490f1d744c0abe1f520e5b307c7acd
a2c38644d96cbad4106c0165811d0f670d6cec8f 18-Sep-2015 Jeff Hao <jeffhao@google.com> Add lock around interpreter string init reg map.

Fixes intermittent test failures. Note that locks can't be held
while the verifier is generating the map.

Change-Id: Ie38d6bf0d9c5e81d66b8c167fde0e75a0565cea5
520633bebd2bf4d70884d30f179dbde9f275aac6 08-Sep-2015 Sebastien Hertz <shertz@google.com> Support deoptimization on exception

Allows to deoptimize when an exception is being thrown. We only
deoptimize if an executable frame (starting from the catch handler)
needs to be executed with the interpreter.

Before executing deoptimized frames, the exception is restored. The
interpreter starts by handling this exception at the point of the
throwing instruction.

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

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

Change-Id: Icbc9e20ad1b565e603195b12714762bb446515fa
90ef3db4bd1d4865f5f9cb95c8e7d9afb46994f9 05-Aug-2015 Mathieu Chartier <mathieuc@google.com> Address some comments and clean up

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

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

This reverts commit 7070ccd8b6439477eafeea7ed3736645d78e003f.

bug:22242193

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

Build failures on bots. Investigating.

This reverts commit fa2c054b28d4b540c1b3651401a7a091282a015f.

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

Saves 4/8 bytes for each ArtMethod.

Change-Id: I110ecdddf8516b0759a31fa157609643e6d60b15
a06b49b6eb3980b4f0e6f5b1222ef2aebe5029f0 26-Jun-2015 Igor Murashkin <iam@google.com> interpreter: Fix string init for soft-failed invokes

Bug: 22040916
Change-Id: Id5b6f0f29e763c31bab4d85877cd8aaf02334e48
6e82168bcb339b162f8fac1034a1153eec421eae 19-Jun-2015 Mathieu Chartier <mathieuc@google.com> Fix moving GC bug in DoFilledNewArray

Previously we read from componentClass after allocating the array.

Bug: 21783443

(cherry picked from commit 52ea33b10370d60d4ce877aec529626537b7813b)

Change-Id: I5283982edab479434e27416509e1436b4176fe01
52ea33b10370d60d4ce877aec529626537b7813b 19-Jun-2015 Mathieu Chartier <mathieuc@google.com> Fix moving GC bug in DoFilledNewArray

Previously we read from componentClass after allocating the array.

Bug: 21783443

Change-Id: I5283982edab479434e27416509e1436b4176fe01
bf1fa2ccb5e7409910b99dc46b616e44c66ade68 09-Jun-2015 Sebastien Hertz <shertz@google.com> Follow up on CL 151605

- Fixes return type of StackedShadowFrameRecord::GetType
- Makes StackedShadowFrameType an enum class (scoped enum)
- Moves DeoptimizationReturnValueRecord and StackedShadowFrameRecord
to thread.cc file and use forward declaration in thread.h header
- Fixes tools/generate-operator-out.py for scoped enum classes.

Bug: 20845490

(cherry picked from commit f795869da0a1fa006fdcdacd8afb6149a63fc1a7)

Change-Id: I6b67e288b1db563699161e58ec2e2330d42dd8f5
ef484d442a3dcae2cd1842c5be0623f5cf71e4ab 18-May-2015 Mingyao Yang <mingyao@google.com> Fix nested deoptimization.

Handle nested deoptimization cases. Create a stacked shadow frame
records to keep track of deoptimization shadow frames. Shadow frames
under construction can be tracked in the same stack.

Bug: 20845490

(cherry picked from commit 1f2d3ba6af52cf6f566deb38b7e07735c9a08fb6)

Change-Id: I768285792c29e7c3cfcd21e7a2600802506024d8
158f35c98e2ec0d40d2c032b8cdce5fb60944a7f 11-Jun-2015 Igor Murashkin <iam@google.com> interpreter: Add experimental lambda opcodes for invoke/create-lambda

These opcodes are not yet fully specified, and *will* change before they become shippable.
Do not write production code against experimental opcodes.

--

Implement partial interpreter support for new dex instructions invoke/create-lambda, and a
new opcode format 25x.

* Does not verify, in fact verification will soft fail when we see those opcodes.
* Compilers will punt to interpreter since they don't support new opcodes.
* As there is no way to capture/liberate variables yet, the "closure" is just
an ArtMethod for the time being.

All new opcodes are disabled by default, use runtime option -Xexperimental-lambdas to enable them.

For example:
dalvikvm ... -Xexperimental-lambdas ...
dex2oat --runtime-arg -Xexperimental-lambdas ...

Change-Id: I6c996ca32a9b54ec45ec21d7a959b84dfb8a24eb
c449e8b79aaaf156ce055524c41474cc1200ed5a 11-Jun-2015 Igor Murashkin <iam@google.com> runtime: Minor cleanup and extra comments around interpreter

Change-Id: I24c0b261de8cf737babd9d01bf679482d48c8bc9
f795869da0a1fa006fdcdacd8afb6149a63fc1a7 09-Jun-2015 Sebastien Hertz <shertz@google.com> Follow up on CL 151605

- Fixes return type of StackedShadowFrameRecord::GetType
- Makes StackedShadowFrameType an enum class (scoped enum)
- Moves DeoptimizationReturnValueRecord and StackedShadowFrameRecord
to thread.cc file and use forward declaration in thread.h header
- Fixes tools/generate-operator-out.py for scoped enum classes.

Bug: 20845490
Change-Id: I6b67e288b1db563699161e58ec2e2330d42dd8f5
1f2d3ba6af52cf6f566deb38b7e07735c9a08fb6 18-May-2015 Mingyao Yang <mingyao@google.com> Fix nested deoptimization.

Handle nested deoptimization cases. Create a stacked shadow frame
records to keep track of deoptimization shadow frames. Shadow frames
under construction can be tracked in the same stack.

Bug: 20845490
Change-Id: I768285792c29e7c3cfcd21e7a2600802506024d8
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
99ca40cf9d390479a7243b8b3321cad7d9faa2a4 16-May-2015 Andreas Gampe <agampe@google.com> ART: Refactor UnstartedRuntime for testing

Expose the UnstartedRuntime implementation functions as private static
methods of a class. Add a gtest that can invoke these functions. Add
sample tests for String and Memory.

Bug: 21173514

(cherry picked from commit 799681b176ad25437ce2849639f54f610dcbf684)

Change-Id: Ib5bde6347fafaf7607c642542ea7d5938ff4b1df
799681b176ad25437ce2849639f54f610dcbf684 16-May-2015 Andreas Gampe <agampe@google.com> ART: Refactor UnstartedRuntime for testing

Expose the UnstartedRuntime implementation functions as private static
methods of a class. Add a gtest that can invoke these functions. Add
sample tests for String and Memory.

Bug: 21173514
Change-Id: Ib5bde6347fafaf7607c642542ea7d5938ff4b1df
8c638bc1f6c186ff3a5706031cb4cf41493c1e7a 15-May-2015 Kenny Root <kroot@google.com> Fix non-range String init calls

When the String constructor was called via invoke-direct, it is changed
to the new StringFactory which is static. That means that the args need
to be shifted by one to deal with the change from non-static to static.
However, the non-range version of the invoke-direct was not shifted
correctly causing unstarted runtime initialization to get the wrong
first_dest_reg argument.

(cherry picked from commit 788a0a157cb138c33882511ff09afacde99443b7)

Bug: 21036900
Change-Id: Ibd7a643d877514ea396d7e4ab0dea327207cb78f
788a0a157cb138c33882511ff09afacde99443b7 15-May-2015 Kenny Root <kroot@google.com> Fix non-range String init calls

When the String constructor was called via invoke-direct, it is changed
to the new StringFactory which is static. That means that the args need
to be shifted by one to deal with the change from non-static to static.
However, the non-range version of the invoke-direct was not shifted
correctly causing unstarted runtime initialization to get the wrong
first_dest_reg argument.

Bug: 21036900
Change-Id: Ibd7a643d877514ea396d7e4ab0dea327207cb78f
9651d9b4ce938e49788e83d38d410eccee54ac90 30-Apr-2015 Jeff Hao <jeffhao@google.com> Restore interpreter check during DoCall removed by string init.

Also reorder test in verifier to check for string_init first.

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

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

Change-Id: I797b992a8feb566f9ad73060011ab6f51eb7ce01
2cebb24bfc3247d3e9be138a3350106737455918 22-Apr-2015 Mathieu Chartier <mathieuc@google.com> Replace NULL with nullptr

Also fixed some lines that were too long, and a few other minor
details.

Change-Id: I6efba5fb6e03eb5d0a300fddb2a75bf8e2f175cb
c785344b87221f5e4e6473e5b762e4e61fe65dcf 27-Mar-2015 Mathieu Chartier <mathieuc@google.com> Move ArtField to native

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

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

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

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

No reflection performance changes.

Bug: 19264997
Bug: 17643507

Change-Id: I10c73a37913332080aeb978c7c94713bdfe4fe1c
45b1597c152af90f6d5792d02b64fd4e7c81ac9d 03-Apr-2015 Sebastien Hertz <shertz@google.com> Use va_list argument to abort transaction

Creates AbortTransactionV taking a va_list argument and renames
AbortTransaction to AbortTransactionF which calls AbortTransactionV.

This fixes the compiler_driver_test under valgrind.

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

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

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

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

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

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

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

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

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

Bug: 19264997

Change-Id: Ic0d0fc1b56b95cd6d60f8e76f19caeaa23045c77
eb07669e9784ccb41d75df180727e57fc4520e28 22-Aug-2014 Daniel Mihalyi <daniel.mihalyi@mattakis.com> JDWP: Optimized single step during debugging

For single stepping full deoptimization and undeoptimizations were
performed with significant overhead, because every code will be
executed in interpreted mode during a single step, even if it is not
strictly required.

For example, if we have a computation heavy method call and we would
like to step over it, that method (and all the methods called from it)
will run in interpreter mode. This can take so long in some cases
(e.g. multiple minutes) that it makes debugging process unusable.

The solution for this limitation is not using full deoptimizations for
single steps and force interpreter only for those methods that we are
about to step into, and require stack deoptimization before step outs.

Bug: 17750566
Bug: 18094282
Bug: https://code.google.com/p/android/issues/detail?id=77984

Change-Id: I683c52465883146c4c84ec47bf96f8efd920527f
Signed-off-by: Daniel Mihalyi <daniel.mihalyi@mattakis.com>
2969bcdcd80624e4a4fef696b54c2c76b44b6853 09-Mar-2015 Andreas Gampe <agampe@google.com> ART: Refactor unstarted runtime

Refactor and clean up unstarted runtime.

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

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

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

Also remove tls ThrowLocation, it is not needed anymore.

Change-Id: I78fddf09ce968ca475e39c17fa76d699c589c8d9
e2be653f220106961ecb119063ef8b839ad1ad34 07-Mar-2015 Andreas Gampe <agampe@google.com> ART: Allow arraycopy with int[] in unstarted runtime

Overlooked in the condition, the actual code was already there.

Bug: 19542228
Change-Id: I30caf77b345cb9bdb1f54c28bf4d42852c9a3298
729699d4a71c0e2452dc0745600d659d2cc7cb82 04-Mar-2015 Andreas Gampe <agampe@google.com> ART: Fix missing handles

Follow-up to https://android-review.googlesource.com/137010.

Change-Id: Ie97bd01f3cd6eeef9ae38fd189b933b905832d52
7642cfc90fc9c3ebfd8e3b5041915705c93b5cf0 26-Feb-2015 Nicolas Geoffray <ngeoffray@google.com> Change how we report exceptions to the debugger.

This is only a refactoring/cleanup. Bug fixes with respect
to catch location, and more cleanups will follow.

Change-Id: I30d3c6260b0c8f8115a811621397225b88f2063a
f0e128a41154642f470eae0c7c57476efb527cd1 28-Feb-2015 Andreas Gampe <agampe@google.com> ART: Allow more operations in unstarted Runtime

To compile-time initialize more classes, have more dedicated code
for special methods.

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

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

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

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

Bug: 19202032
Change-Id: Iedc6969528a68bbdf3123146e990df4dbc57834b
ffc605cd817e79d6c7602a87543bb31f24d3a99f 10-Dec-2014 Mathieu Chartier <mathieuc@google.com> Add missing iget quick for bool, byte, char, short

Bug: 17791557
Bug: 17671806
Change-Id: Ifac4fbfba6c3a3f97131e85914b24756fb7f9722
a0485607a4a4d8c683a9849f6f20902c4e1da7a4 03-Dec-2014 Ian Rogers <irogers@google.com> Move GetClassFromTypeIdx to ArtMethod.

Move GetClassFromTypeIdx out of MethodHelper into ArtMethod in
preparation for the removal of MethodHelper.

Change-Id: I9c03dd8c821944c606ea08cdf92afc80c4275247
08f1f50d6c2e8f247b8f5f19711d75a792851c7a 03-Dec-2014 Ian Rogers <irogers@google.com> Remove FieldHelper.

Change-Id: I2d74e2d5b3c35a691c95339de0db9361847fca11
e94652f1e321b2c8b71acbe5b07d2ebf69fbdb99 02-Dec-2014 Ian Rogers <irogers@google.com> Remove MethodHelper from the interpreter.

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

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

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

Change-Id: I81bbdd762213444673c65d85edae594a523836e5
6b14d55c812ee3438e87db249d5a144e0397fb3b 29-Oct-2014 Ian Rogers <irogers@google.com> Move GetNameAsString out of MethodHelper into ArtMethod.

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

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

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

(cherry picked from commit 6f3dbbadf4ce66982eb3d400e0a74cb73eb034f3)

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

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

Change-Id: I5f4b49e88c3b02a79f9bee04f83395146ed7be23
5ad97daa3112ca626e3fbf2bf08971977344c3c3 06-Oct-2014 Hiroshi Yamauchi <yamauchi@google.com> Handlerize methods across some GC points.

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

Remove extra semicolons.

Dollar signs in C++ identifiers are an extension.

Named variadic macros are an extension.

Binary literals are a C++14 feature.

Enum re-declarations are not allowed.

Overflow.

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

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

Bug: 9986565

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

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

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

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

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

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

Change-Id: Id59ce3cc520701c6ecf612f7152498107bc40684
37f05ef45e0393de812d51261dc293240c17294d 17-Jul-2014 Fred Shih <ffred@google.com> Reduced memory usage of primitive fields smaller than 4-bytes

Reduced memory used by byte and boolean fields from 4 bytes down to a
single byte and shorts and chars down to two bytes. Fields are now
arranged as Reference followed by decreasing component sizes, with
fields shuffled forward as needed.

Bug: 8135266
Change-Id: I65eaf31ed27e5bd5ba0c7d4606454b720b074752
bf99f77dda749e2b653e8c45259b1fb56e7bb012 24-Aug-2014 Mathieu Chartier <mathieuc@google.com> Clean up Handle usage.

Prefer using ConstHandle instead of Handle as function arguments
since you can't assign new references to ConstHandle which helps
prevent bugs.

Changed NullHandle to be a ConstHandle so that you can never modify
it to be a non null reference.

Change-Id: I81cb979f6f8d5b49e5614966a2caf28c3701dd4f
cb6b0f31ede2275e79e6199ec391147585a37a2a 12-Aug-2014 Ian Rogers <irogers@google.com> Avoid use of std::string where we have const char*.

Removing the ClassHelper caused std::string creation for all calls to
Class::GetDescriptor and a significant performance regression. Make the
std::string an out argument so the caller can maintain it and its life time
while allowing GetDescriptor to return the common const char* case.

Don't generate GC maps when compilation is disabled.

Remove other uses of std::string that are occuring on critical paths.
Use the cheaper SkipClass in CompileMethod in CompilerDriver.
Specialize the utf8 as utf16 comparison code for the common shorter byte
encoding.
Force a bit of inlining, remove some UNLIKELYs (they are prone to pessimizing
code), add some LIKELYs.

x86-64 host 1-thread interpret-only of 57 apks:
Before: 29.539s
After: 23.467s

Regular compile:
Before: 1m35.347s
After: 1m20.056s

Bug: 16853450
Change-Id: Ic705ea24784bee24ab80084d06174cbf87d557ad

Conflicts:
runtime/utils.cc
1ff3c98775a4577cf053dba9a0c2d5c21c07b298 12-Aug-2014 Ian Rogers <irogers@google.com> Avoid use of std::string where we have const char*.

Removing the ClassHelper caused std::string creation for all calls to
Class::GetDescriptor and a significant performance regression. Make the
std::string an out argument so the caller can maintain it and its life time
while allowing GetDescriptor to return the common const char* case.

Don't generate GC maps when compilation is disabled.

Remove other uses of std::string that are occuring on critical paths.
Use the cheaper SkipClass in CompileMethod in CompilerDriver.
Specialize the utf8 as utf16 comparison code for the common shorter byte
encoding.
Force a bit of inlining, remove some UNLIKELYs (they are prone to pessimizing
code), add some LIKELYs.

x86-64 host 1-thread interpret-only of 57 apks:
Before: 29.539s
After: 23.467s

Regular compile:
Before: 1m35.347s
After: 1m20.056s

Bug: 16853450
Change-Id: Ic705ea24784bee24ab80084d06174cbf87d557ad
62327cda9a75e9d15daab0749b37257a146631f4 16-Jul-2014 Sebastien Hertz <shertz@google.com> Fix class initialization checks in interpreter

Check field's class initialization after handling null pointer exception.

Bug: 16324235

(cherry picked from commit 1edbd8e5405486a96d69481f5f30a8ca16d510b5)

Change-Id: I31ef07a08ff70c5695dda1079afea5b2579bb8e3
1edbd8e5405486a96d69481f5f30a8ca16d510b5 16-Jul-2014 Sebastien Hertz <shertz@google.com> Fix class initialization checks in interpreter

Check field's class initialization after handling null pointer exception.

Bug: 16324235
Change-Id: I33d537168e068b7fb51ddf97bc5aadee9dd65f67
22d5e735f403c57525fe868304c7123f0ce66399 16-Jul-2014 Ian Rogers <irogers@google.com> Remove object_utils.h.

Break into object_lock, field_helper and method_helper.
Clean up header files following this.
Also tidy some of the Handle code in response to compiler errors when resolving
the changes in this CL.

Change-Id: I73e63015a0f02a754d0866bfaf58208aebcaa295
4e99b3d8955131f3fc71aa113f0fa71f0092cb6f 24-Jun-2014 Sebastien Hertz <shertz@google.com> Add missing class initialization during compilation and tests

Adds missing class initialization during compilation and tests, especially
java.lang.Class. Otherwise, we'd be able to execute code while the referring
class is not initialized or initializing.

Also adds mirror::Class::AssertInitializedOrInitializingInThread method to
check class initialization when entering the interpreter: the called method's
declaring class must either be initialized or be initializing by the current
thread (other threads must be waiting for the class initialization to complete
holding its lock). Note we only do this check in debug build.

Bump oat version to force compilation.

Bug: 15899971
Change-Id: I9a4edd3739a3ca4cf1c4929dcbb44cdf7a1ca1fe
7b1cabf3d910f199d77e47f458680f700a31f7e8 09-Jul-2014 Sean Wan <swan@google.com> CW on Master: Propagate or throw exception when no class found happens in interpreter.

The old behavior is a check fail which causes zygote process crash.

This is particular a problem for CW in which webview is not used, and
this stops CW system start.

(cherry picked from commit 41a71f3db62e5bccb162a2b18ed3801e00ff6f87)

Change-Id: Iabe091ebe4bbdd86d931ac6c06abd089f1338d59
41a71f3db62e5bccb162a2b18ed3801e00ff6f87 09-Jul-2014 Sean Wan <swan@google.com> CW on Master: Propagate or throw exception when no class found happens in interpreter.

The old behavior is a check fail which causes zygote process crash.

This is particular a problem for CW in which webview is not used, and
this stops CW system start.

Change-Id: I45f26d6e5d328de7f156793f9044f6bf3f878a1a
5487494e54e719d3bb4ead7a0b73e1d456fec8da 11-Jun-2014 Ian Rogers <irogers@google.com> Workaround frame size issues.

x86 and x86-64 are exceeding the frame size for the switch interpreter.
The SOMETIMES_INLINE hack doesn't work with GCC as inline and the noinline
attribute are mutually exclusive. As a temporary solution move the effected
code to the the interpreter_common.cc file.
Bug: 14882674

Change-Id: Id5383ef5436046b36565cd1d76de8e3d59f42cff
9f1020305292a21fd14a402b189c765a125226ab 23-May-2014 Sebastien Hertz <shertz@google.com> Fix exception reporting from interpreter

To comply with JDWP exception report rules, we must report an exception at the
location of the throw (or the first instruction encountered after a native
call). To do this, we use the CatchLocationFinder visitor to look for a catch
handler until we reach a native frame or the top frame.

Because interpreter handles pending exception on a method-by-method basis, we
need a flag to remember we already reported the exception and avoid reporting
it multiple times when unwinding methods. The drawback is we need to maintain
the state of this flag. We clear it when the exception is cleared. In the case
we temporarily clear the exception (when finding a catch handler for instance),
we restore the flag to its previous value at the same time we restore the
pending exception.

Bump oat version to force recompilation because we modify Thread offsets.

Bug: 14402770
Change-Id: Ic059c58f80b2023b118038301f8f0a24f1e18241
bfd9a4378eacaf2dc2bbe05ad48c5164fc93c9fe 22-May-2014 Mathieu Chartier <mathieuc@google.com> Change MethodHelper to use a Handle.

Added ConstHandle to help prevent errors where you modify the value
stored in the handle of the caller. Also fixed compaction bugs
related to not knowing MethodHelper::GetReturnType can resolve types.
This bug was present in interpreter RETURN_OBJECT.

Bug: 13077697

Change-Id: I71f964d4d810ab4debda1a09bc968af8f3c874a3
61c5ebc6aee2cac1c363de6fbdac25ada1697fdb 06-Jun-2014 Mathieu Chartier <mathieuc@google.com> Change FieldHelper to use a handle.

Fixed compaction bugs related to FieldHelper::GetType in:
artSet32InstanceFromCode
SetFieldValueImpl
CheckReceiver
Field_set
interpreter::DoFieldPut
MethodVerifier::VerifyISGet
MethodVerifier::VerifyISPut
MethodVerifier::VerifyIGetQuick

Bug: 13077697

Change-Id: I7de9ded2893b5568d43e4daa86fd135bf5508b72
2a0d4ec9532a89abe722e5babdfbb846ffaad721 03-Jun-2014 Andreas Gampe <agampe@google.com> ART: Fix forbidden thread state change in interpreter

While loading a type for assignability, it might happen that it's
not available yet locally and must be resolved. Formerly, we
disallowed a state change to ensure no GC taking place while a new
shadow frame has not been pushed on the stack yet.

As a fix, allow a "shadow frame under construction" in the thread,
which is visited during GC.

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

Merge ART from AOSP to lmp-preview-dev.

Change-Id: I0f578733a4b8756fd780d4a052ad69b746f687a9
0cd81352a7c06e381951cea1b104fd73516f4341 23-May-2014 Mathieu Chartier <mathieuc@google.com> Revert "Revert "Fix an outstanding compaction bug in interpreter.""

Fixed the generic trampoline to not use ToJObject when unnecessary.

Bug: 15167269

This reverts commit 3bdb873122964da7937eb070cbcf2ef638a8e459.

Change-Id: I0525d0e0f3afb753c770e1572070a0fa22b02271
3bdb873122964da7937eb070cbcf2ef638a8e459 23-May-2014 Mathieu Chartier <mathieuc@google.com> Revert "Fix an outstanding compaction bug in interpreter."

This reverts commit e09ae0920be57760fb390b6944bce420fa0b5582.

Change-Id: I48036306130d5ccfec683d0dc3e9a642a02ee9c1
e09ae0920be57760fb390b6944bce420fa0b5582 15-May-2014 Mathieu Chartier <mathieuc@google.com> Fix an outstanding compaction bug in interpreter.

Fixed a bug in DoFieldPut where the FieldHelper GetType could cause
thread suspension which would result in a stale obj.

Added more handles in the class linker to facilitate moving fiels
and methods in the future.

Removed un-necessarly passing handle references since these are value
types and don't need to be passed by reference.

Added a special NullHandle type which allows null handles without a
handle scope.

Change-Id: I1b51723920a2e4f4f8b2907066f578a3e879fd5b
f832284dd847ff077577bb5712225430bbbb3b67 16-May-2014 Mathieu Chartier <mathieuc@google.com> Delete ClassHelper and fix compaction bug in GetDirectInterface

Cleanup helps to prevent compaction bugs. Fixed a fairly serious
compaction error caused by calling ClassHelper::GetDirectInterface
without handling the case where it causes thread suspension due to
ResolveType.

Bug: 8981901

Change-Id: I82b3bb6dd48d21eb6ece7aae0733c4a23c2bc408
eb8167a4f4d27fce0530f6724ab8032610cd146b 08-May-2014 Mathieu Chartier <mathieuc@google.com> Add Handle/HandleScope and delete SirtRef.

Delete SirtRef and replaced it with Handle. Handles are value types
which wrap around StackReference*.

Renamed StackIndirectReferenceTable to HandleScope.

Added a scoped handle wrapper which wraps around an Object** and
restores it in its destructor.

Renamed Handle::get -> Get.

Bug: 8473721

Change-Id: Idbfebd4f35af629f0f43931b7c5184b334822c7a
c45b8b582be5c98941ca3869fcdc9a08d520da41 03-May-2014 Ian Rogers <irogers@google.com> Create stack traces in unstarted runtimes.

Use to diagnose failed initialization in dex2oat of boot (-verbose:compiler).
Fix identity hashCode, ArtMethod.getMethodName, IntegralToString.convertInt and
use of Void when called from a unstarted runtime.

Change-Id: I2d536174b59e2e5f19519f93fc6b5916652fb6cd
29a2648821ea4d0b5d3aecb9f835822fdfe6faa1 03-May-2014 Ian Rogers <irogers@google.com> Move DecodedInstruction into MIR.

Change-Id: I188dc7fef4f4033361c78daf2015b869242191c6
b2c7ead6bb5c98282cdfbc89db8984a004bea030 29-Apr-2014 Mathieu Chartier <mathieuc@google.com> Don't allow allocating finalizable objects during transactions.

It doesn't make sense to allocate finalizable objects during a
transcation since they will never get finalized without a started
runtime.

Before StatusInitialized in core.host.oatdump.txt: 3564
After StatusInitialized in core.host.oatdump.txt: 3564

Bug: 14078487

Change-Id: I7070536f7bb87bfc691d4268bd39a3eca492f48e
7104cbf9c594563c6daae592b8f38f49a423d12e 21-Mar-2014 Andreas Gampe <agampe@google.com> Fix sign problem, implement low-mem mmap wraparound

A signed value comparison meant that on 64b systems comparisons
were false when pointers > 2GB were in use (as happens in long-running
tests). Fix this to be uint.

Implement a simple wrap-around in the MAP_32BIT emulation code.

Change-Id: I09870b4755f2dca676e42e701fbb6f6eb4bb95d0
563b47cc142e477da244539b1d63070425e7fd78 01-Mar-2014 Hiroshi Yamauchi <yamauchi@google.com> Fix the bug that some compiled code was invoked with -Xint.

Some compiled code (probably static methods) is still being invoked
with -Xint. Added an assert to detect this case.

Bug: 13250375
Change-Id: Iecfe8ef40c6c326962593db78e6e1d9f1c93842e
6fac447555dc94a935b78198479cce645c837b89 26-Feb-2014 Ian Rogers <irogers@google.com> Make allocations report usable size.

Work-in-progress to allow arrays to fill usable size. Bug: 13028925.
Use C++11's override keyword on GCC >= 2.7 to ensure that we override GC and
allocator methods.
Move initial mirror::Class set up into a Functor so that all allocated objects
have non-zero sizes. Use this property to assert that all objects are never
larger than their usable size.
Other bits of GC related clean-up, missing initialization, missing use of
const, hot methods in .cc files, "unimplemented" functions that fail at
runtime in header files, reducing header file includes, move valgrind's space
into its own files, reduce number of array allocation routines.

Change-Id: Id5760041a2d7f94dcaf17ec760f6095ec75dadaa
9837939678bb5dcba178e5fb00ed59b5d14c8d9b 25-Feb-2014 Ian Rogers <irogers@google.com> Avoid std::string allocations for finding an array class.

Introduce ClassLinker::FindArrayClass which performs an array class lookup
given the element/component class. This has a 16 element cache of recently
looked up arrays.
Pass the current thread to ClassLinker Find .. Class routines to avoid calls
to Thread::Current().
Avoid some uses of FindClass in the debugger where WellKnownClasses is a
faster and more compacting GC friendly alternative.

Change-Id: I60e231820b349543a7edb3ceb9cf1ce92db3c843
4e30541a92381fb280cd0be9a1763b713ee4d64c 19-Feb-2014 Mathieu Chartier <mathieuc@google.com> Fix and optimize verify object.

VerifyObject no longer resides in heap. You can now enable
VerifyObject for non-debug builds. VerifyStack is still slow, so it
is now guarded by its own flag.

Fixed the image writer to not use verification at places where
verification fails due to invalid reads.

Fixed RosAlloc to use SizeOf which doesn't call verify object.

Added a flag paremeter to some of the mirror getters / setters to
be able to selectively disable VerifyObject on certain calls.

Optimized the GC to not verify each object multiple times during
object scanning if verify object is enabled.

Added 3 verification options: verify reads, verify this, and verify
writes so that you can select how much verification you want for
mirror getters and setters.

Removed some useless DCHECKs which would slow debug builds without
providing any benefits.

TODO: RosAlloc verification doesn't currently work with verify
objects.

Bug: 12934910
Bug: 12879358

Change-Id: Ic61033104dfc334543f89b0fc0ad8cd4f4015d69
d2fe10a3a34af171bf1631219cd2d6ff6b7778b5 15-Jan-2014 Sebastien Hertz <shertz@google.com> Remove blacklist

Removes the class initialization blacklist and use transaction to detect and
revert class initialization attempting to invoke native method. This only
concerns class initialization happening at compilation time when generating an
image (like boot.art for the system).

In transactional mode, we log every object's field assignment and array update.
Therefore we're able to abort a transaction to restore values of fields and
array as they were before the transaction starts. We also log changes to the
intern string table so we can restore its state prior to transaction start.

Since transactional mode only happens at compilation time, we don't need to log
all these changes at runtime. In order to reduce the overhead of testing if
transactional mode is on/off, we templatize interfaces of mirror::Object and
mirror::Array, respectively responsible for setting a field and setting an
array element.

For various reasons, we skip some specific fields from transaction:
- Object's class and array's length must remain unchanged so garbage collector
can compute object's size.
- Immutable fields only set during class loading: list of fields, method,
dex caches, vtables, ... as all classes have been loaded and verified before a
transaction occurs.
- Object's monitor for performance reason.

Before generating the image, we browse the heap to collect objects that need to
be written into it. Since the heap may still holds references to unreachable
objects due to aborted transactions, we trigger one collection at the end of
the class preinitialization phase.

Since the transaction is held by the runtime and all compilation threads share
the same runtime, we need to ensure only one compilation thread has exclusive
access to the runtime. To workaround this issue, we force class initialization
phase to run with only one thread. Note this is only done when generating image
so application compilation is not impacted. This issue will be addressed in a
separate CL.

Bug: 9676614
Change-Id: I221910a9183a5ba6c2b99a277f5a5a68bc69b5f9
ef7d42fca18c16fbaf103822ad16f23246e2905d 06-Jan-2014 Ian Rogers <irogers@google.com> Object model changes to support 64bit.

Modify mirror objects so that references between them use an ObjectReference
value type rather than an Object* so that functionality to compress larger
references can be captured in the ObjectRefererence implementation.
ObjectReferences are 32bit and all other aspects of object layout remain as
they are currently.

Expand fields in objects holding pointers so they can hold 64bit pointers. Its
expected the size of these will come down by improving where we hold compiler
meta-data.
Stub out x86_64 architecture specific runtime implementation.
Modify OutputStream so that reads and writes are of unsigned quantities.
Make the use of portable or quick code more explicit.
Templatize AtomicInteger to support more than just int32_t as a type.
Add missing, and fix issues relating to, missing annotalysis information on the
mutator lock.
Refactor and share implementations for array copy between System and uses
elsewhere in the runtime.
Fix numerous 64bit build issues.

Change-Id: I1a5694c251a42c9eff71084dfdd4b51fff716822
abff6439db28fbbed95490bfff7e24d1fdf5b771 27-Jan-2014 Sebastien Hertz <shertz@google.com> Refactor array access for the interpreter.

Adds GetWithoutChecks and SetWithoutChecks methods in PrimitiveArray and use
them in the interpreter. Updates Get and Set methods to rely on them and adds
some DCHECK to control exception flow.

Renames IsValidIndex into CheckIsValidIndex to reflect it can throw an
exception. It's also more consistent with ObjectArray::CheckIsAssignable.

Make ThrowArrayIndexOutOfBoundsException private in Array since it's only used
by Array::CheckIsValidIndex.

Updates DoFilledNewArray to use SetWithoutChecks rather than Set.

Change-Id: I2fd314d77a67cf969843d499b86d04ca7b7a43e6
1d99e4549309d05007d041d058b1878de88e9585 03-Jan-2014 Ian Rogers <irogers@google.com> Disallow JNI NewObjectArray of primitive types.

Also, make jni_internal_test execute via the interpreter rather than compile
methods. Add tests for passing negative array sizes to JNI routines new
functions. Re-enable the tests NewStringNullCharsNonzeroLength and
NewDirectBuffer_GetDirectBufferAddress_GetDirectBufferCapacity. Test and
explicitly fail if the initial value argument to NewObjectArray isn't
assignable to that type of array.
Use unchecked ObjectArray::Set with NewObjectArray with an initial value.

Change-Id: If3491cb5f974b42cf70c1b850819265f9963ee48
9119c5f9e4f447f4209d51cff66d1aace510ce5e 16-Dec-2013 Sebastien Hertz <shertz@google.com> Cleanup invoke's receiver handling in interpreter.

To comply with a moving collector, we used to load invoke's receiver (for non
static methods only) from the caller shadow frame after resolving the method
itself (in case the garbage collector is triggered inside) but before passing
invoke arguments, including loading receiver from the caller's shadow frame
into the callee's shadow frame. Therefore, we used to load the receiver 3 times
in the fast path but only twice in the slow path.

The slow path is rarely used (only in method requiring extra runtime checks) so
we now move this extra reload to the slow path. Therefore an invoke using the
fast path loads the receiver twice while the slow path loads it 3 times.

I don't expect much improvement here. The main reason is to keep extra code in
the slow path.

Change-Id: I10e96b10de4b8c2992e276bd564bc3e2f191779c
4fa0bcd2142793e1f105b24b658de3635652b957 10-Dec-2013 Brian Carlstrom <bdc@google.com> Remove unneeded quoting

Change-Id: I87f452e338bd4ff0587e3fc7b0bec3f08a1e7fe6
fa31b3c382f5202bc2b07c81108627e476cf753d 09-Dec-2013 Kenny Root <kroot@google.com> Add some functions to the unitialized VM handling

Only the Class#forName(String) call was handled during the compilation
stage, but VMClassLoader#loadClass and VMClassLoader#findLoadedClass
gets called through various other channels. Add these so we cover most
of the use cases without going too far up the call stack.

This was encountered during compilation of code that did:
MyClass.class.getClassLoader().loadClass(...)
during an attempt to avoid class initialization. Note that the existing
Class#forName handling doesn't appear to ensure the class is initialized
like would normally happen when Class#forName is called in the running
VM. This is a correctness issue, but is left for another change to
correct.

Change-Id: I14628a1d1d5a5dd1a885cbd24455a73bb0531489
cbb2d20bea2861f244da2e2318d8c088300a3710 15-Nov-2013 Mathieu Chartier <mathieuc@google.com> Refactor allocation entrypoints.

Adds support for switching entrypoints during runtime. Enables
addition of new allocators with out requiring significant copy
paste. Slight speedup on ritzperf probably due to more inlining.

TODO: Ensuring that the entire allocation path is inlined so
that the switch statement in the allocation code is optimized
out.

Rosalloc measurements:
4583
4453
4439
4434
4751

After change:
4184
4287
4131
4335
4097

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

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

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

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

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

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

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

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

Bug: 8981901

Change-Id: I3c886fd322a6eef2b99388d19a765042ec26ab99
e861ebd5d9490cc86200f3859f3d36fadad4588c 10-Oct-2013 Mathieu Chartier <mathieuc@google.com> Fix interpreter bugs.

These showed up in compaction work.

Change-Id: Iac8eb0a1395c25aabba9f2e0ff6b01fc6180bdca
c67148594b1580c278ae71e3ce5c6fd59bfa6bd3 30-Sep-2013 Sebastien Hertz <shertz@google.com> Enable thread analysis on template functions.

All template functions using thread analysis must be explicitly instantiated
with the thread analysis attributes to enable thread analysis. We use macros
to do this since there are many variants of a same function depending the
number of template arguments.

Also add documentation of these functions.

Change-Id: I3c79acc2f0a6a8dfb5c42924439145292dd68812
9ace87b47a756d519e8897d6c1f0f4664ed82f86 27-Sep-2013 Sebastien Hertz <shertz@google.com> Optimize shadow frame initialization during invoke.

This CL improves the initialization of the new shadow frame (callee) from the
current shadow frame (caller) following invoke format (non-range or range).

This also removes the use of Instruction::GetArgs for non-range invoke when we
can go the fast route (no use of shorty). This avoids decoding arguments into
the stack from the instruction and then read these arguments from the stack. We
now do both at once. Note the slow path (doing runtime checks) is not modified
since it should be rarely used.

Performance improved by 3% in average on our benchmarks. Good news it is more
important on benchmark doing lots of invokes:
- Dhrystone: +11%
- DeltaBlue: +7%
- CaffeineMark Method: +16%

Bug: 10668955
Change-Id: I5c230777b2388a78dca7b3a88189e007c1c2bb7a
c61124bdeaae94f977ffc36ac69535e792c226f2 10-Sep-2013 Sebastien Hertz <shertz@google.com> Cleanup invoke in interpreter.

Some cleanup in invocation stuff:
- Get the number of invoke arguments from instruction (vA) rather than get it
from its code item. This benefits to native invoke since we no longer need to
parse the method's shorty. Also pass the low 16 bits of instructions to avoid
fetching it twice when reading vA.
- Remove "is_static" tests by taking advantage of invoke type template argument
rather than testing method's access flags.
- Ensure Instruction::GetArgs is inlined.
- Check exception when initializing method's class when transitioning from
interpreter to compiled code (artInterpreterToCompiledCodeBridge).
- Move UnstartedRuntimeInvoke function to interpreter_common.cc and make it
static as it's only used by DoInvoke and DoInvokeVirtualQuick functions.
- Avoid duplicating code in ShadowFrame::Create.

Performance remains the same according to benchmarks. Hopefully, this should be
addressed in next CLs, especially by improving new shadow frame initialization.

Bug: 10668955
Change-Id: I514b8f098d0ef3e35921ceb770383aac1a9c7902
a3faaf4bece7f42529c013fe87bd41de59798656 04-Sep-2013 Jeff Hao <jeffhao@google.com> Fix handling of unresolved references in verifier.

The verifier should not treat use of unresolved references as a reason to reject
the entire class. Instead, the verifier treats the instruction as a throw. If
that class is run, the interpreter with extra checks will throw an exception.

Bug: 10457426

Change-Id: I3799da843a7ffb3519bbf6dc13a6276519d9cb95
8ece050d85fc244c72610244e440b0e00aa618fa 07-Aug-2013 Sebastien Hertz <shertz@google.com> Add an interpreter using computed goto table.

This CL adds a new implementation of the interpreter using computed goto table.
In order to keep the switch-based implementation, it reorders things as the
following:
- Keep interpreter entrypoints into interpreter.h/.cc files.
- Move common interpreter parts to interpreter_common.h/.cc files.
- Separate both implementations to their own modules.

The interpreter implementation can be selected by changing the value of the
kInterpreterImplKind global variable (see interpreter.cc file). The default one
remains the switch-based implementation.

Also updates the exception handling (FindNextInstructionFollowingException) and
SPARSE_SWITCH switch handling (DoSparseSwitch) routines to share code between both
implementations.

Finally, adds a PACKED_SWITCH handling routine (DoPackedSwitch) so we are
consistent with SPARSE_SWITCH handling.

The computed goto implementation use two handlers table: one for normal
instruction handling and one for instrumentation handling. The current handlers
table to be used is updated on backward branch depending on whether there is
listener to DEX pc change.

Bug: 10602809
Change-Id: Ibb53bcc68be75c473fe5440835e78fc9a74381b3