History log of /art/runtime/interpreter/interpreter_common.cc
Revision Date Author Comments
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
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
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
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
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