History log of /art/runtime/verifier/method_verifier.cc
Revision Date Author Comments
82cc2ed2553a274742606be23b86b9ef276c1edb 23-May-2016 Aart Bik <ajcbik@google.com> Fix bug in verifier: soft fail was hiding hard fail.

Rationale:
Dexfuzzing found a situation where a soft fail (modifying
a final field) was hiding a hard fail (type error on that
field), which caused a crash in the compiler later on.
Also added a crash-before/pass-after regression test,
so we don't add the return by accident later.

BUG=28908555

(cherry picked from commit c2bc26513ea7c5e2dd9f3b102fb23fd207e4ce63)

Change-Id: Ie79c4afa28cddbca4dfb78e5c75da6644612c15c
ffaa91d39baf82006afe74ad6e59cfd498334017 05-Apr-2016 Aart Bik <ajcbik@google.com> Workaround invokesuper underspecified behavior.

The verifier allows invokesuper on a class unrelated
to the referring class. However, the runtime uses the vtable of
the super class of the referring class to lookup the ArtMethod.
Since the receiver has no relation to the referring class, this lead
to either jumping to a wrong method, or "luckily" throw a
NoSuchMethodError if the vtable index is out of bounds of the super
class of the referring class.

This changes the runtime behavior to always throw NoSuchMethodError
when hitting such invokesuper.

Also, we make the verifier consistent with the runtime by treating
such calls unresolved.

bug=27627004

(cherry picked from commit f663e341c550d1aa6f8f587d0ae0dbf7d254ff55)

Change-Id: Ibec5a1e3a3320c474e1e0e5634a9ef62ea734cdf
f517e283d477dd2ae229ee3f054120c6953895db 28-Apr-2016 Andreas Gampe <agampe@google.com> ART: Disambiguate access-checks mode from lock-counting

Lock-counting (when structural locking verification failed) is a
special sub-mode of access-checks and must be disambiguated, because
we currently use access-checks mode class-wide when at least one
method soft-fails, but do not stop the compiler/JIT to compile
the "working" methods. So we may end up in the access-checks
interpreter for a working method through deopt without knowing
which locks are already held.

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

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

bug:28293819
bug:28313047

(cherry picked from commit 250a378d5a2152662e0fa820f2b38f794ddd3596)

Change-Id: Ic6d019bc2dd24e35e1377a6c3f8530348c1049df
dc4b6dd86ffe80e67c01df501ed2468bef252808 15-Apr-2016 Andreas Gampe <agampe@google.com> ART: Fix nits for verifier change

Follow-up to 6659624baadf2285ac5880fd28ffa31767dcae0b.

Bug: 28187158
Change-Id: Ie81aff1cae1ff275faaaf4b858608e74b86d8622
(cherry picked from commit 8f4ade0f05c0203b33e5f421d1e3794ab6075a82)
c69c0acadd5b83b467de24d1b5872daf0ac9cf8a 14-Apr-2016 Andreas Gampe <agampe@google.com> ART: Make iget receiver mismatch hard verifier error

If the classes are resolved, and still not match, this should be
a verify error.

Bug: 28187158
Change-Id: I89c996ae15865674f21cf32ec378d37bac34861b
(cherry picked from commit 6659624baadf2285ac5880fd28ffa31767dcae0b)
f0fe04cbaf189702e9dad7252ed834cb4735c877 13-Apr-2016 Alex Light <allight@google.com> Allow private methods in interfaces.

Private methods may be generated in interfaces during compilation of
some default methods. Change the verifier to allow these methods.

Bug: 27999840

(cherry picked from commit b55f1ac873f9541f391625c13fe9129fbd38e74c)

Change-Id: Ib8120a8f6cb036021334d9af0ed78ae372974ecb
76ed99d5ec208d5adcd63b41c2c290194ee0ecf7 29-Mar-2016 Andreas Gampe <agampe@google.com> ART: Postpone interface-related dex failure to version 37

For app compat, at least for now make the check for public-final-static
of interface members not fail on dex file versions less than 37. This
may be changed in future releases.

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

To help for build failures.

Change-Id: I6c94dfb50177daa7d89902d78715ccec31bf0e45
bf9611f821697b14bf9e170f503c3f47613b046b 26-Mar-2016 Andreas Gampe <agampe@google.com> ART: Clean up verifier

Clean up verifier post-Quick.

Change-Id: I0b05e10dd06edd228fe2068c8afffc4b7d7fdffa
8d8fc48664205e433cfa5540753b38043d918873 26-Mar-2016 Andreas Gampe <agampe@google.com> ART: Relax verifier checks

Only bail for unresolved merge types in a couple of cases. Follow-up
to bb18a03c44d99b3cae232d445d56e80d8388cca9.

Bug: 27799205
Change-Id: If448e14036bc5e245677e0cd8cdddee02b320525
bb18a03c44d99b3cae232d445d56e80d8388cca9 23-Mar-2016 Andreas Gampe <agampe@google.com> ART: Allow array-ness for unresolved merge types

In case component types aren't resolvable, array types won't be
either. They then may be merged. The merge is still potentially
an array type.

Ensure that merging an unresolved array type with a primitive
array type or a non-array type will be resolved to java.lang.Object.

Added tests.

Bug: 27799205
Change-Id: I9beff75318814dddd842abd64ef9a5d2644d801e
55ea94dc8a7417fa33db010826c1f37734f7d7f2 15-Mar-2016 Alex Light <allight@google.com> Fix bug where verification could crash on unresolved types.

Bug: 27626708

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

Added to:
JIT
DexFile functions
Oat file manager

Added helper ScopedTrace to prevent errors and reduce excess code.

Bug: 27502458

(cherry picked from commit dabdc0fe183d4684f3cf4d70cb09d318cff81b42)

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

Added to:
JIT
DexFile functions
Oat file manager

Added helper ScopedTrace to prevent errors and reduce excess code.

Bug: 27502458

Change-Id: Ifaeff8913d79eefc797380987d13cc00456266f8
7211aa62b2d000ad0e1e1a49bc30b962c2c069cd 03-Mar-2016 Mathieu Chartier <mathieuc@google.com> Add systrace to VerifyClass

Useful to see if verifier is preempting anything.

(cherry picked from commit 7f459f5859e5f01c92c3711e7d63c062f510b416)

Change-Id: I594cbdc5c2f8934fc6c4fc7ee47fc4ccfc3c627d
7f459f5859e5f01c92c3711e7d63c062f510b416 03-Mar-2016 Mathieu Chartier <mathieuc@google.com> Add systrace to VerifyClass

Useful to see if verifier is preempting anything.

Bug: 27398183
Change-Id: I3e318d2c9c5cbc4254b3ffe8e6e8c7b98a0f2ef7
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
361e04aaa5d3eca9f978a802ee44b1213f31da58 16-Feb-2016 Mathieu Chartier <mathieuc@google.com> Add custom arena deleter for RegisterLine

Previously it protected by using sizeof(RegisterLine) but this was
not accurate due to register lines being variable sized.

Bug: 27156726
Change-Id: Ia4b134b85a2e61993d17bd4f0eff60c89c164dc3
4a2c8fc0fc47631550bc5ff8edd8221a3aea1b23 12-Feb-2016 Alex Light <allight@google.com> Fix bug with verification of constructors

We would incorrectly allow the storing of values into superclass
fields before the superclass constructor was called.

Bug: 26965384

Change-Id: I45b824fbdbfc133663ed6d3306853595b5dc9262
980027c7f22f332ad224f662add0df197e71f137 11-Feb-2016 Pavel Vyssotski <pavel.n.vyssotski@intel.com> ART: Treat throw with non-reference type as hard failure in verifier.

The code
const v0, 0xbad
throw v0
crashes dex2oatd/Quick by DCHECK in art::Mir2Lir::LoadValueDirect.
dex2oat works fine producing VerifyError later in runtime.
Optimizing also pass as it rejects methods with soft failures.

Fix this by rejecting such methods in Verifier.

Bug: 27148248
Change-Id: Ib783f60a210362654d40e84172e7bd579913a4d4
Signed-off-by: Pavel Vyssotski <pavel.n.vyssotski@intel.com>
9fcfb8add23042713165f761b4f098e14b9a823b 05-Feb-2016 Andreas Gampe <agampe@google.com> ART: Curb lock-verification-failure spam

Just print one message per class. Also print a helpful message once.

Bug: 26951356
Change-Id: I83702b67dc535d86e03835df7a72afda081c83be
68b5c0b677bae53b3bae5d1890e21fae527f3df3 19-Jan-2016 David Brazdil <dbrazdil@google.com> ART: Disallow uses of uninitialized references

The following instructions accepted uninitialized reference types
as their arguments:
- instance-of
- check-cast
- throw
- iput-object (stored value argument)
- sput-object
- invoke-* (non-this arguments)

Monitor-enter and monitor-exit are allowed.

Bug: 26594149

Change-Id: I2a4decb1fba274b8969b17bc237ac0fd19b93c80
fedd91d50930e160c021d65b3740264f6ffec260 07-Jan-2016 Alex Light <allight@google.com> Optimizing compiler support for directly calling interface methods

This teaches the optimizing compiler how to perform invoke-super on
interfaces. This should make the invokes generally faster.

Bug: 24618811

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

This also enables interface static methods.

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

Bug: 24618811

Change-Id: Icd91e377bd6e1a45a1645f810d15de1b0312e31d
7268d47a6d2d44dcd844fcfff4699ad7689308d6 21-Jan-2016 Alex Light <allight@google.com> Add a METHOD_SUPER to the MethodType enum.

This makes some of the code simpler by disambiguating between regular
invoke-virtual and invoke-super, which have slightly different
requirements.

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

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

We add 3 tests for this behavior.

Currently only supports slow-path interpreter.

Invoke-super is currently extremely slow.

Bug: 24618811

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

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

Clean up the test a bit.

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

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

This reverts commit dae24142127c64551142a50423085aabdb0a6060.

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

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

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

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

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

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

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

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

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

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

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

Bug: 25432718
Change-Id: Ib8e6dd1ce8121045c0d38f54969100094c3dde6e
a4c98f292f6471f88816ce74046ecc85bc57e6b3 07-Nov-2015 Andreas Gampe <agampe@google.com> ART: Fix return-object verification

If the declared return type was unresolvable, we always threw a
soft failure, only. However, if the register type is not a reference,
this should always be a hard failure.

Add a test case.

Bug: 25494456
Change-Id: I6482a45ec36b58895816647da0ff3a731b31319f
0db36b3ec3feb34adabf5d211612226a66d8b063 27-Oct-2015 Alex Light <allight@google.com> Fix minor problems with interface verification and default methods.

Previously we would fail verification on some <clinit> methods when
default methods are enabled and they are not marked as public.

Previously we would also give verifier soft failures when using
interface statics.

Bug: 24618811

Change-Id: I735740b4058bfd71e67bc3fb99e6a8c0c4696b01
de40d478930d0889a2aea5cbf58aa63da24e5dfa 16-Oct-2015 Mathieu Chartier <mathieuc@google.com> Use arenas for the verifier

Improvements are from using arenas for verifier. The things that
were moved into arenas are register lines, reg types, and reg type
descriptors.

Also some minor cleanup. Fixed double space formatting error in
string piece.

========================================
Before:
=======================================
compile GmsCore 50x on host -j1:
real 3m5.510s
user 2m48.139s
sys 0m11.753s

50 random APKs:
real 1m18.157s
user 1m8.167s
sys 0m8.071s

RAM (GmsCore):
(threads: 1) arena alloc=0B java alloc=27MB native alloc=64MB free=792KB
(threads: 4) arena alloc=0B java alloc=27MB native alloc=64MB free=397KB
Perf:

=============================
After:
=============================
compile GmsCore 50x on host -j1:
real 2m31.455s
user 2m14.784s
sys 0m10.888s

50 random APKs:
Speed up from arena allocating:
real 1m12.094s
user 1m2.325s
sys 0m7.872s

Speed up from areans + CreateFindClassDefIndex + unordered_map for DexFileVerifier.
real 1m8.654s
user 0m58.955s
sys 0m7.777s

RAM (GmsCore):
(threads: 1) arena alloc=1049KB java alloc=27MB native alloc=65MB free=538KB
(threads: 4) arena alloc=4MB java alloc=27MB native alloc=69MB free=650KB

Perf on host key results:
_int_malloc: 3.60% -> 1.39%
malloc: 1.48% -> 0.65%
_int_free: 1.59% -> 0.61%
RegTypeCache::FromClass: 1.47% -> 0.86%
malloc_consolidate: 0.89% -> 0.63%

Real speed up is ~22% on GmsCore, ~14% on the set of 60 APKs.

Bug: 10921004

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

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

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

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

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

This adds 5 new run-tests for this functionality.

Bug: 24618811

Change-Id: I35ca800d99d3329348b277789b70ceeeba6e7f03
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
5469d3444614be1d29302aef75210119df453721 25-Sep-2015 David Brazdil <dbrazdil@google.com> ART: Reject PackedSwitch with overflowing keys

As stated in "Dalvik bytecode" sections on switch payload format,
switch case keys must be stored in ascending order. Verifier enforced
this for sparse-switch but not for packed-switch.

Bug: 24399945
Change-Id: I0802d38e2bfae93c0dffe8ebfce2e9693a63ec02
071cd9d654c3e578c400be1414c3b0ea58508c72 25-Sep-2015 Vladimir Marko <vmarko@google.com> ART: Fix misleading error message in method verifier.

Change-Id: I4805de0060b74168fa36e077a6a7ea59e9d72d46
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
e6215c0ec4b1bb71b722fdbf7e62eaf3be8a91d5 01-Sep-2015 Andreas Gampe <agampe@google.com> ART: Move access flags checking to dex file verifier

Actually implement all the access flags checking in the dex file
verifier. Add tests.

Change-Id: I8b797357831b588589d56d6e2e22f7b410f33008
637ee0b9c10ab7732a7ee7b8335f3fff4ac1549c 04-Sep-2015 Vladimir Marko <vmarko@google.com> ART: Add some utilities for working with containers.

Add utility functions for searching, removing and replacing
existing values in a container, to be used with std::vector
(including the ArenaVector alias) and other containers.

Also move UniqueCPtr<> and MakeUnique() to base/stl_utils.h
and clean up related includes.

Change-Id: I1e61762df91c046866591bda167d42bf8b67a692
de286fdcb4d203438b4b49c22c8a4a24d08ad14d 04-Sep-2015 Mathieu Chartier <mathieuc@google.com> Address some leftover comments

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

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

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

This reverts commit 81a9087f0df0518c39405b7d18ba5858a6d8b77b.

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

Bug: 23602225
Bug: 22720414

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

This reverts commit 3ae6b1d42523bb2a0ddb5edff1aaf05b592f28f4.
a727e372d8f6929cd30b983f6969c7a50fc83bb6 25-Aug-2015 Andreas Gampe <agampe@google.com> ART: Balanced locking

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

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

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

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

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

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

Also deleted some unused functionality in image writer.

Bug: 22720414
Change-Id: If22cb3cad7e3baabc8158a77d7f20799faf4c341
ad238ce884468234509a9367c0ce1055bd1394bf 25-Aug-2015 Andreas Gampe <agampe@google.com> ART: Add option to retain lock levels in verifier

Templatize SetRegisterType to be able to retain lock levels. When
sharpening a type, e.g., in a branch after an instanceof, the
verifier should remember if the register had been locked before
and not implicitly erase that information.

Bug: 23502994
Change-Id: Iba62688a536792da0920598fecdbf24a4993ec04
c147410b4459aeda08fc0cd8b6df089d75f4e573 18-Aug-2015 Andreas Gampe <agampe@google.com> ART: Special form of lock aliasing

Check whether the instruction immediately before a monitor-enter
is a move-object, establishing previously untracked lock aliasing
in a low-overhead manner.

Bug: 20102779
Bug: 21169615
Bug: 21988678
Bug: 23300986
Change-Id: Ia10d6219357e7bce29f58134637b07d3f4857b2f
53de99cd7e863e95179823504335f1f67e03c791 17-Aug-2015 Andreas Gampe <agampe@google.com> ART: Follow-up fixes

Addressing comments for CL 166499, commit
5073fedd553afeb6ccdb49c1a1ab2cc2947c0870.

Change-Id: I359e5a4c026d58d75cb62b90c495796855302b94
ebf850c9ec47e199cfb3712b7832eb2f32e2ee02 15-Aug-2015 Andreas Gampe <agampe@google.com> ART: Fix verifier dumping, add hard-fail dumping

Fix the dumping code in the verifier.

Add an option to dump the verifier state on hard failure when
verbose:verifier.

Change-Id: Iccea92fcbcb2301356d86004ea0f5f3e5da84f3c
eb9d1f79a79e3235f25889a25cdba465a7a0f7bf 14-Aug-2015 Andreas Gampe <agampe@google.com> ART: Relax verifier aput checking

When checking on a null array, the cases of aput and aput-wide are
shared between integral and floating point types. Be careful to not
reject a valid program.

Bug: 21867457
Bug: 23201502

(cherry picked from commit 4bf4c78a6e8b7da7cf306e1dd17ff5a55d0c6c98)

Change-Id: I6c54a389c06e40a2dae00995aa16ff08a089e512
4bf4c78a6e8b7da7cf306e1dd17ff5a55d0c6c98 14-Aug-2015 Andreas Gampe <agampe@google.com> ART: Relax verifier aput checking

When checking on a null array, the cases of aput and aput-wide are
shared between integral and floating point types. Be careful to not
reject a valid program.

Bug: 21867457
Bug: 23201502
Change-Id: I6c54a389c06e40a2dae00995aa16ff08a089e512
e682a0250702c65a668e39eefdd1c49cfea5f388 12-Aug-2015 Andreas Gampe <agampe@google.com> ART: Change UninitializedThis tracking in the verifier

Only relying on register types is error-prone. For example, we may
inadvertently reject correct code when the constructor terminates
abnormally.

Bug: 20843113

(cherry picked from commit f10b6e109bfb595b6752d1b59db680694ac1684d)
(cherry picked from commit af31802e5b74f5b9b8d3aadbaaf48cfde14ff7d1)

Change-Id: I8826cd167780df25a6166740f183d216483fa550
f10b6e109bfb595b6752d1b59db680694ac1684d 12-Aug-2015 Andreas Gampe <agampe@google.com> ART: Change UninitializedThis tracking in the verifier

Only relying on register types is error-prone. For example, we may
inadvertently reject correct code when the constructor terminates
abnormally.

Bug: 20843113
Change-Id: I8826cd167780df25a6166740f183d216483fa550
b29179611a5d24ada72d8a7914bc8c1259e6d5b6 31-Jul-2015 Andreas Gampe <agampe@google.com> ART: Check a RETURN_VOID_NO_BARRIER like a RETURN_VOID

RETURN_VOID_NO_BARRIER is used in all methods with return-void,
as long as they're not a constructor and have been quickened. As
such, do the regular checking of the return type.

Bug: https://code.google.com/p/android/issues/detail?id=181700
Bug: 22871329
Change-Id: I11bcf7bffd91fc01995b703a99e603ddb370016e
07e0e6b076b2b8d0a03f3caf94ff8c71fa807d29 31-Jul-2015 Andreas Gampe <agampe@google.com> Revert "ART: Do not allow RETURN_VOID_NO_BARRIER outside constructors"

This reverts commit e93505f599682a2e95c4dac1c8633dec79c602bc.

This isn't the right thing to do, actually.

Bug: 22871329
Change-Id: I0a0a5a86c7c8d8afdf417444ca7d73e56e040515
e93505f599682a2e95c4dac1c8633dec79c602bc 31-Jul-2015 Andreas Gampe <agampe@google.com> ART: Do not allow RETURN_VOID_NO_BARRIER outside constructors

Let the verifier fail non-constructor methods using the no-barrier
variant of return. This is a quickened return purely to avoid the
constructor barrier for final fields, and cannot be used as a stand-in
for a regular return.

Bug: https://code.google.com/p/android/issues/detail?id=181700
Bug: 22871329
Change-Id: I9559c6a1599c20ce526582527ebed73b25242767
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
4d7b75f9cbcf99134c0a1c69b267b6bc8d94134e 22-Jul-2015 Igor Murashkin <iam@google.com> verifier: Skip verification of methods when seeing experimental opcodes

Bug: 22638098
Change-Id: I9f172f3e0e7ad2aa8873e4036415702fee6bf2eb
e2facc5b18cd756a8b5500fb3d90da69c9ee0fb7 10-Jul-2015 Igor Murashkin <iam@google.com> runtime: Add lambda box/unbox object equality

A lambda that is boxed with box-lambda is now stored as a weak reference
in a global runtime table (lambda::BoxTable). Repeatedly boxing the same
lambda closure value will always return the same java.lang.Object back.

Since there is no way to observe the address of an object, a GC can
happen and clean up the table of any dead boxed lambdas, which can also
shrink the table to prevent the memory use from growing too much.

(Note that a lambda closure is immutable, so hashing over it is
guaranteed safe.)

Change-Id: I786c1323ff14eed937936b303d511875f9642524
8f1e08af6172781f91a17fce0a5a4183a9f70aa9 26-Jun-2015 Vladimir Marko <vmarko@google.com> ART: Don't nest indenters in oatdump.

Reduces the time taken by the oatdump_test by ~12s (15%)
on host and ~55s (9%) on N5.

Change-Id: I99bb16ff5f3640389815f1fe54379ca64eac071b
a3cd834a9e63c4c2259f0ef87d79ddf2c4dd3afb 07-Jul-2015 Andreas Gampe <agampe@google.com> ART: Avoid soft- after hard-fail in verifier

Follow-up to 414000ec4d728b5c85f8c6dee4f867fecde59b01.

Bug: 21886894
Bug: 22245124

(cherry picked from commit 890da29d279c44923f9271450b8a4423b1267655)

Change-Id: I3728187bd8526cdf84f95b123e6fad5d6c5a8b3c
890da29d279c44923f9271450b8a4423b1267655 07-Jul-2015 Andreas Gampe <agampe@google.com> ART: Avoid soft- after hard-fail in verifier

Follow-up to 414000ec4d728b5c85f8c6dee4f867fecde59b01.

Bug: 21886894
Bug: 22245124
Change-Id: I3728187bd8526cdf84f95b123e6fad5d6c5a8b3c
57c47588434b98a3904950c3b1d820257984878a 02-Jul-2015 Andreas Gampe <agampe@google.com> ART: Check switch and array data better in the verifier

Incorrect padding (or just malformed code) can lead to pseudo
instructions for data payload not being correctly discoverable in
a linear scan. This is problematic for the optimizing compiler,
which uses such a scan to build its graph.

Use the opcode flag in the insn_flags_ to ensure that a pseudo
instruction referenced from a base instruction was actually
correctly discovered. This does not ensure the letter of the dex
specification for now, which calls for nops for padding. However,
it is unclear what the difference between unreachable code and
padding is.

Bug: 22237618
Bug: https://code.google.com/p/android/issues/detail?id=178522
Change-Id: I823b3f541f326e6e77b15f3e13a7608a39d4b1fb
d5ad72fb8ca28ee4fa4109fa7154e08d0c4ac4d3 27-Jun-2015 Andreas Gampe <agampe@google.com> ART: Fix invalid access and DCHECK in verifier

If we get a throwing failure when setting types from the signature,
the work instruction index is still invalid. Do not try to copy the
line then.

As a throwing failure might happen in the above instance, but the
flow analysis expects to have a cleared failure flag before processing
each instruction, clear the flag.

Bug: 21645819
Bug: 22080519

(cherry picked from commit 3ae8da0a803370be9dd410226438f636af553e22)

Change-Id: I224c4dad98fa5bb50e62210f0ee30c0dd020e3a6
3ae8da0a803370be9dd410226438f636af553e22 27-Jun-2015 Andreas Gampe <agampe@google.com> ART: Fix invalid access and DCHECK in verifier

If we get a throwing failure when setting types from the signature,
the work instruction index is still invalid. Do not try to copy the
line then.

As a throwing failure might happen in the above instance, but the
flow analysis expects to have a cleared failure flag before processing
each instruction, clear the flag.

Bug: 21645819
Bug: 22080519
Change-Id: I224c4dad98fa5bb50e62210f0ee30c0dd020e3a6
6415013f0b9509fed8367871daaf66c6841223f1 25-Jun-2015 Andreas Gampe <agampe@google.com> ART: Reset runtime_throw_failure flag

The flag is instruction-specific. It transports the info from Fail
to the main loop. It must be cleared after each iteration.

Introduce a second flag to store whether we saw such a failure at
all.

Update test expectations.

Bug: 22080519

(cherry picked from commit d12e782bcee03ecb6dec41aa9673ef53b638dcea)

Change-Id: I32be914819946233babaa4cb7343844d97b61ba5
d12e782bcee03ecb6dec41aa9673ef53b638dcea 25-Jun-2015 Andreas Gampe <agampe@google.com> ART: Reset runtime_throw_failure flag

The flag is instruction-specific. It transports the info from Fail
to the main loop. It must be cleared after each iteration.

Introduce a second flag to store whether we saw such a failure at
all.

Update test expectations.

Bug: 22080519
Change-Id: I32be914819946233babaa4cb7343844d97b61ba5
92067896c6583d59171dbee9c720a316d63be177 23-Jun-2015 Vladimir Marko <vmarko@google.com> Hard-fail get-/put-object to a non-reference field.

Bug: 21886894

(cherry picked from commit 414000ec4d728b5c85f8c6dee4f867fecde59b01)

Change-Id: Iafc32f0e45d26f3aaa2d521b98353e7cede16c6f
414000ec4d728b5c85f8c6dee4f867fecde59b01 23-Jun-2015 Vladimir Marko <vmarko@google.com> Hard-fail get-/put-object to a non-reference field.

Bug: 21886894
Change-Id: Iec870c223ce97fd90dcce05ae80c002e2b24cb5d
a32210c53d23b73ba769053b8c1b214a7468fe6e 24-Jun-2015 Andreas Gampe <agampe@google.com> ART: Correctly hard-fail method with undefined register

In case a return-object gets an undefined return value register
and an unresolved return type, the "undefined" must take precedence
and lead to a hard fail of the method.

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

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

bug:21865466

(cherry picked from commit 4824c27988c8eeb302791624bb3ce1d557b0db6c)

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

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

bug:21865466

Change-Id: I64c2c84dfa1c0d259631e65e5f44b94e4139e6a7
a497d1cf500f3b06fb401c33e21d38f1bd0026ad 23-Jun-2015 Andreas Gampe <agampe@google.com> ART: Follow-up to 507cc6f83bf6379728f2dd20391f2ed5fbfe6371

Do not trigger DCHECK aborts for final and abstract classes when
they are used from other classes. Instead issue a soft error that
leads to a runtime failure.

Bug: 21873151

(cherry picked from commit f23f33de8b3e9abd16720e0f48d43d63d41dee16)

Change-Id: Ie5251a176722811b3c74585222874313a53f7e02
f23f33de8b3e9abd16720e0f48d43d63d41dee16 23-Jun-2015 Andreas Gampe <agampe@google.com> ART: Follow-up to 507cc6f83bf6379728f2dd20391f2ed5fbfe6371

Do not trigger DCHECK aborts for final and abstract classes when
they are used from other classes. Instead issue a soft error that
leads to a runtime failure.

Bug: 21873151
Change-Id: Ie5251a176722811b3c74585222874313a53f7e02
4c67a6aae0eba853e84090dfb06daefe43d3dc95 22-Jun-2015 Andreas Gampe <agampe@google.com> ART: Allow checking RETURN_VOID_NO_BARRIER on unresolved classes

We must check that all fields are non-final, even for unresolved
classes. Fall back to the dex file for this information.

Bug: 22005084
Bug: https://code.google.com/p/android/issues/detail?id=177694

(cherry picked from commit 68df32091cc79468c81956633e279523b48ea8bf)

Change-Id: If2126d1be5dccadbbedcdccabde7398688d6e5ca
2ee54e249ad21c74f29a161e248bebe7d22fddf1 18-Jun-2015 Igor Murashkin <iam@google.com> runtime: Partially implement box-lambda and unbox-lambda experimental opcodes

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 box/unbox-lambda.
* box-lambda will take a closure and convert it into an Object
* unbox-lambda will take an Object and convert it to a closure

(Currently does not implement object identity or variable capture).

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

Change-Id: I3c15ccf8a26ccecd1d35808a8c1b4149220f6019
68df32091cc79468c81956633e279523b48ea8bf 22-Jun-2015 Andreas Gampe <agampe@google.com> ART: Allow checking RETURN_VOID_NO_BARRIER on unresolved classes

We must check that all fields are non-final, even for unresolved
classes. Fall back to the dex file for this information.

Bug: 22005084
Bug: https://code.google.com/p/android/issues/detail?id=177694
Change-Id: If2126d1be5dccadbbedcdccabde7398688d6e5ca
a6efe5e813457a1c7946a1e6c62646b7bd1150df 20-Jun-2015 Andreas Gampe <agampe@google.com> ART: Disallow classes that are abstract and final

Make the verifier fail such classes.

Bug: 21873151

(cherry picked from commit 507cc6f83bf6379728f2dd20391f2ed5fbfe6371)

Change-Id: I217f3d71f44bccdcee7ca830e092c807928bed39
39d40afb789c9ae80b1105168241dcdc92491b5d 19-Jun-2015 Nicolas Geoffray <ngeoffray@google.com> Verifier: check an aput, even if we know it will fail.

bug:21867457

(cherry picked from commit 66389fbeb41c981648bb2e1e7e2f43089f095591)

Change-Id: Id01edeb871f6bc59518eb341e5b76f021cfdfe06
507cc6f83bf6379728f2dd20391f2ed5fbfe6371 20-Jun-2015 Andreas Gampe <agampe@google.com> ART: Disallow classes that are abstract and final

Make the verifier fail such classes.

Bug: 21873151
Change-Id: I217f3d71f44bccdcee7ca830e092c807928bed39
673b4302edf6d1604e69a1427eea5324016bbab2 20-Jun-2015 Andreas Gampe <agampe@google.com> ART: Check for expected args for instance methods

Don't assume that the receiver is expected. This was writing out
of bounds (or triggering a DCHECK).

Bug: 21817284
Bug: 21872240
Bug: https://code.google.com/p/android/issues/detail?id=176571
Bug: https://code.google.com/p/android/issues/detail?id=176572

(cherry picked from commit ef0b1a1dbc99fe7c92f9598cbfc164763c1b66d7)

Change-Id: I7cad2c1dfc39feb0b1b4660deeb43afdcb844ba3
ef0b1a1dbc99fe7c92f9598cbfc164763c1b66d7 20-Jun-2015 Andreas Gampe <agampe@google.com> ART: Check for expected args for instance methods

Don't assume that the receiver is expected. This was writing out
of bounds (or triggering a DCHECK).

Bug: 21817284
Bug: 21872240
Bug: https://code.google.com/p/android/issues/detail?id=176571
Bug: https://code.google.com/p/android/issues/detail?id=176572
Change-Id: I7cad2c1dfc39feb0b1b4660deeb43afdcb844ba3
cbf5d89665cfb48778b2946794fbea43067ff04a 13-Apr-2015 Taiju Tsuiki <tzik@google.com> ART: Check var-arg count earlier in method verifier

Check the count in vararg instructions before filling the temp
array. Avoids a DCHECK.

Bug: 21869663
Bug: 20170976

(cherry picked from commit 29498a23bcfe47a7134552aacad5524ecb484a49)

Change-Id: I1ff93502ab84c5967ad54d1b50dba517da791637
29498a23bcfe47a7134552aacad5524ecb484a49 13-Apr-2015 Taiju Tsuiki <tzik@google.com> ART: Check var-arg count earlier in method verifier

Check the count in vararg instructions before filling the temp
array. Avoids a DCHECK.

Bug: 21869663
Bug: 20170976

Change-Id: I1ff93502ab84c5967ad54d1b50dba517da791637
66389fbeb41c981648bb2e1e7e2f43089f095591 19-Jun-2015 Nicolas Geoffray <ngeoffray@google.com> Verifier: check an aput, even if we know it will fail.

bug:21867457
Change-Id: I01e333d858995d0e1e083a50cf8d460a86381f2c
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
da9badb9edea5e0d18cd9f97eff0d0937ad48310 06-Jun-2015 Andreas Gampe <agampe@google.com> ART: Check long and double register pairs in invokes

For invokes, ensure that long and double parameters are actually
in registers pairs. We were testing the pair, but skipping the
actual high parameter register.

Bug: 17410612
Change-Id: I8f4c3335ea8b7dc3cf252bee52a5a706ae8905f8
d9e230185873d9d998d77d17107029e0603e82d6 05-Jun-2015 Andreas Gampe <agampe@google.com> ART: Reload class on miranda method in verifier

When checking the receiver of a call and we have a miranda method,
reload the class from the method index instead of using the declared
class - which is the interface class, not the abstract class.

Bug: 21646347
Change-Id: I5bceab75c3b76233cb42ea5cf0214d32c8149994
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
b588f4c037d27dedeef358b478c281ebb3fbb900 26-May-2015 Andreas Gampe <agampe@google.com> ART: Fix wrong hard-failure handling in verifier

Correctly return null for the method when a hard failure is
encountered. Also improve logging for order failures. Add a
regression test.

Bug: 20224106

(cherry picked from commit 3b74e275838729c5023cd80116f1b3b81306ee19)

Change-Id: I6e08202617147378b204af169308b67fc69f92c6
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
3b74e275838729c5023cd80116f1b3b81306ee19 26-May-2015 Andreas Gampe <agampe@google.com> ART: Fix wrong hard-failure handling in verifier

Correctly return null for the method when a hard failure is
encountered. Also improve logging for order failures. Add a
regression test.

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

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

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

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

Bug: 13925192

(cherry picked from commit 80afd02024d20e60b197d3adfbb43cc303cf29e0)

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

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

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

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

Bug: 13925192
Change-Id: I704884dab15b41ecf7a1c47d397ab1c3fc7ee0f7
3c651fc07bde1bfc375d2675c01ce9ccefdf2085 21-May-2015 Andreas Gampe <agampe@google.com> ART: Sometimes even empty methods take forever to verify

In cases of very high load and/or bad scheduling, the verifier may
take longer than the threshold duration to verify an empty method.
The LargeMethod detection needs to accept that the code_item may
be null.

Bug: 21364300

(cherry picked from commit 8110447356f559688d6290563e912af7f8d4709b)

Change-Id: Iceff3e4688cc1a5fe7a836f7a9bf6c49a392b618
8110447356f559688d6290563e912af7f8d4709b 21-May-2015 Andreas Gampe <agampe@google.com> ART: Sometimes even empty methods take forever to verify

In cases of very high load and/or bad scheduling, the verifier may
take longer than the threshold duration to verify an empty method.
The LargeMethod detection needs to accept that the code_item may
be null.

Bug: 21364300
Change-Id: Iceff3e4688cc1a5fe7a836f7a9bf6c49a392b618
f177dd6b9943e5b111b1e06d22a16cd2d01c89c5 19-May-2015 Andreas Gampe <agampe@google.com> ART: Change huge-method warning in verifier

Change the logging to be included in the took-a-long-time warning,
instead of being a non-descriptive standalone. This should reduce
the noise.

Bug: 21149450

(cherry picked from commit a4f5bf6ea99d6b3095a4ca261352729633bc44c5)

Change-Id: Ia4493dd12f54a8452a46541f6da86530584016ea
a4f5bf6ea99d6b3095a4ca261352729633bc44c5 19-May-2015 Andreas Gampe <agampe@google.com> ART: Change huge-method warning in verifier

Change the logging to be included in the took-a-long-time warning,
instead of being a non-descriptive standalone. This should reduce
the noise.

Bug: 21149450
Change-Id: Ia4493dd12f54a8452a46541f6da86530584016ea
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
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
d0ad2eea51850ed5972c23d03380b2305cdf7cb7 31-Mar-2015 Mathieu Chartier <mathieuc@google.com> Add support for nested method verifiers

Can occur in the following scenario:
MethodVerifier::Verify -> MethodVerifier::GetStaticField ->
ResolveFieldJLS -> ThrowNoSuchFieldError -> EnsureInitialized ->
VerifyClass

Also fixed another case where we can be requested to dump for ANR
while we are suspended in one of the AllowSuspension points.

Bug: 20140397

Change-Id: Ib17f6b98954caa5d1ea1c1dcde66091cc6d11c25
65b798ea10dd716c1bb3dda029f9bf255435af72 06-Apr-2015 Andreas Gampe <agampe@google.com> ART: Enable more Clang warnings

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

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

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

Mips64 is untested but might work, maybe.

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

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

Bug: 19264997

Change-Id: I0a71ebb5928f205b9b3f7945b25db6489d5657ca
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
16f149c2cb43a14d8f33d7d0fa36cd784e900f07 23-Mar-2015 Andreas Gampe <agampe@google.com> ART: Change RETURN_OBJECT verification for arrays

Arrays appear to be valid (as according to spec), even if their
components are erroneous. If a component is erroneous, it may not
have loaded superclass or interface information, and so fail a
direct check for assignability.

Add a cutout that checks whether the declared return-type or the
actual return-type are arrays with erroneous components (and if so,
have the same 'depth'). In that case, generate a soft instead of a
hard error.

Also includes a fix to DumpClass.

Bug: 19683465
Change-Id: Ie73de03adeb0af7e939370d7363684fe125d7994
9ccd151d0d27a729f88af9d00285afe4d147981a 21-Mar-2015 Jeff Hao <jeffhao@google.com> Fix verifier handling of empty switch as last instruction.

Also fixes optimizing compiler's assumption that switch is non-empty and
adds test case.

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

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

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

Bug: 19762303

Change-Id: Ibfba77148da9039e8d7d7497c05486bc044eefe7
d7cbf8a6629942e7bd315ffae7e1c77b082f3e11 19-Mar-2015 Mathieu Chartier <mathieuc@google.com> Change RETURN_VOID_BARRIER to RETURN_VOID_NO_BARRIER

We want to default to having a barrier for the case where we don't
dex to dex.

Bug: 19762303
Change-Id: I60348d89eaf0b9e1e480298afcecbb5f52e8661b
12d625f87bcd6c4059a205bb39007a255f57f382 13-Mar-2015 Mathieu Chartier <mathieuc@google.com> Change method verifiers to be thread local roots

Bug: 10921004

Change-Id: I3a1425d76cd380587ba67ef6d5ec1227564e55bf
66cdcbeeedc6e51b4c56da6969ce193b8c520bbc 06-Mar-2015 Mathieu Chartier <mathieuc@google.com> Fix incompatible class change error for JIT stress mode

There was a problem with miranda methods, when we would dequicken to
one of these, it wouldn't resolve as virtual during the method
lowering resolve. The solution is to try resolving as interface if we
fail to resolve as virtual.

Fixed a bug in dequickening where unreachable register lines with
quick invokes would cause CHECK failuers. In this case we punt to the
interpreter (test 435-try-*).

Added test regression test. Example failure:
java.lang.IncompatibleClassChangeError: The method
'void Main$TheInterface.m()' was expected to be of type virtual but
instead was found to be of type interface (declaration of
'java.lang.reflect.ArtMethod' appears in
out/host/linux-x86/framework/core-libart-hostdex.jar)
at Main.DoStuff(Main.java:37)
at Main.main(Main.java:44)

Bug: 17950037

(cherry picked from commit 091d238936809f6668ca6b7606c62bc224add430)

Change-Id: I90d2bea1cec81a3acac1da875320e1f90510edf4
d7f8d05987e08723de008ba6dbbf66acb7db0f24 12-Mar-2015 Andreas Gampe <agampe@google.com> ART: Save work-line for pending runtime failure

When we detect a pending runtime failure, we'll handle it as a
generic throw, no matter the instruction type. But we won't have
saved the work-line, which means we'll try to merge garbage into
the handler's line.

Copy the work-line when we set the failure.

Bug: 19634276
Change-Id: I54df9e9492cd48802f93e2f1938adaadc55c9bd5
091d238936809f6668ca6b7606c62bc224add430 06-Mar-2015 Mathieu Chartier <mathieuc@google.com> Fix incompatible class change error for JIT stress mode

There was a problem with miranda methods, when we would dequicken to
one of these, it wouldn't resolve as virtual during the method
lowering resolve. The solution is to try resolving as interface if we
fail to resolve as virtual.

Fixed a bug in dequickening where unreachable register lines with
quick invokes would cause CHECK failuers. In this case we punt to the
interpreter (test 435-try-*).

Added test regression test. Example failure:
java.lang.IncompatibleClassChangeError: The method
'void Main$TheInterface.m()' was expected to be of type virtual but
instead was found to be of type interface (declaration of
'java.lang.reflect.ArtMethod' appears in
out/host/linux-x86/framework/core-libart-hostdex.jar)
at Main.DoStuff(Main.java:37)
at Main.main(Main.java:44)

Bug: 17950037

Change-Id: I39c32cc8849bf02032a4f61a7ce57462b7fcac75
783f9f3f5251cd7c38e27f0f7113c60d0f38b633 18-Sep-2014 Andreas Gampe <agampe@google.com> ART: Do a pre-pass for monitor_enter dex pc search

In case the method does not have any monitor_enter instructions,
it is unnecessary to run the full verifier. Speeds up stack dumps
and works around b/17514582.

Bug: 17514582
Change-Id: I5201bfbb9fb6cad49596b4c72e71983b58d9f20c
(cherry picked from AOSP commit cb3c08fe9c733e477776dcc0d0fa5a3cf0053aa7)
e5f13e57ff8fa36342beb33830b3ec5942a61cca 24-Feb-2015 Mathieu Chartier <mathieuc@google.com> Revert "Revert "Add JIT""

Added missing EntryPointToCodePointer.

This reverts commit a5ca888d715cd0c6c421313211caa1928be3e399.

Change-Id: Ia74df0ef3a7babbdcb0466fd24da28e304e3f5af
a5ca888d715cd0c6c421313211caa1928be3e399 24-Feb-2015 Nicolas Geoffray <ngeoffray@google.com> Revert "Add JIT"

Sorry, run-test crashes on target:
0-05 12:15:51.633 I/DEBUG (27995): Abort message: 'art/runtime/mirror/art_method.cc:349] Check failed: PcIsWithinQuickCode(reinterpret_cast<uintptr_t>(code), pc) java.lang.Throwable java.lang.Throwable.fillInStackTrace() pc=71e3366b code=0x71e3362d size=ad000000'
10-05 12:15:51.633 I/DEBUG (27995): r0 00000000 r1 0000542b r2 00000006 r3 00000000
10-05 12:15:51.633 I/DEBUG (27995): r4 00000006 r5 b6f9addc r6 00000002 r7 0000010c
10-05 12:15:51.633 I/DEBUG (27995): r8 b63fe1e8 r9 be8e1418 sl b6427400 fp b63fcce0
10-05 12:15:51.633 I/DEBUG (27995): ip 0000542b sp be8e1358 lr b6e9a27b pc b6e9c280 cpsr 40070010
10-05 12:15:51.633 I/DEBUG (27995):

Bug: 17950037
This reverts commit 2535abe7d1fcdd0e6aca782b1f1932a703ed50a4.

Change-Id: I6f88849bc6f2befed0c0aaa0b7b2a08c967a83c3
2535abe7d1fcdd0e6aca782b1f1932a703ed50a4 17-Feb-2015 Mathieu Chartier <mathieuc@google.com> Add JIT

Currently disabled by default unless -Xjit is passed in.

The proposed JIT is a method JIT which works by utilizing interpreter
instrumentation to request compilation of hot methods async during
runtime.

JIT options:
-Xjit / -Xnojit
-Xjitcodecachesize:N
-Xjitthreshold:integervalue

The JIT has a shared copy of a compiler driver which is accessed
by worker threads to compile individual methods.

Added JIT code cache and data cache, currently sized at 2 MB
capacity by default. Most apps will only fill a small fraction of
this cache however.

Added support to the compiler for compiling interpreter quickened
byte codes.

Added test target ART_TEST_JIT=TRUE and --jit for run-test.

TODO:
Clean up code cache.
Delete compiled methods after they are added to code cache.
Add more optimizations related to runtime checks e.g. direct pointers
for invokes.
Add method recompilation.
Move instrumentation to DexFile to improve performance and reduce
memory usage.

Bug: 17950037

Change-Id: Ifa5b2684a2d5059ec5a5210733900aafa3c51bca
90a33595bc637f5768a7726a186bdfe25efcd0d6 16-Jan-2015 Sebastien Hertz <shertz@google.com> Fix exception handling during deoptimization

When interpreting a deoptimized shadow frame, we may start with a
pending exception thrown by a previous deoptimized shadow frame (from
a previous invoke). Therefore, we need to handle it before executing
any instruction, otherwise we execute incorrect code.

Because we need the DEX pc of the throwing instruction to find a
matching catch handler, we initialize deoptimized shadow frames with
the current DEX pc at the time the stack is deoptimized.
When we are about to interpret a deoptimized shadow frame, we need to
update the shadow frame with the DEX pc of the next instruction to
interpret. There are three cases:
- if there is no pending exception, this is the instruction following
the current one.
- if there is a pending exception and we found a matching catch
handler, this is the first instruction of this handler.
- if there is a pending exception but there is no matching catch
handler, we do not execute the deoptimized shadow frame and continue
to its caller.

The verifier now fails when a method starts with a move-exception
instruction. Indeed we cannot start executing a method with a pending
exception.

Bug: 19057915
Bug: 19041195
Bug: 18607595

(cherry picked from commit 270a0e16c3b8e5b95cbfdbd8996ac137c7c6322b)

Change-Id: Ib4fdd0ad704b4f2369d229737c9cc77f559cea55
270a0e16c3b8e5b95cbfdbd8996ac137c7c6322b 16-Jan-2015 Sebastien Hertz <shertz@google.com> Fix exception handling during deoptimization

When interpreting a deoptimized shadow frame, we may start with a
pending exception thrown by a previous deoptimized shadow frame (from
a previous invoke). Therefore, we need to handle it before executing
any instruction, otherwise we execute incorrect code.

Because we need the DEX pc of the throwing instruction to find a
matching catch handler, we initialize deoptimized shadow frames with
the current DEX pc at the time the stack is deoptimized.
When we are about to interpret a deoptimized shadow frame, we need to
update the shadow frame with the DEX pc of the next instruction to
interpret. There are three cases:
- if there is no pending exception, this is the instruction following
the current one.
- if there is a pending exception and we found a matching catch
handler, this is the first instruction of this handler.
- if there is a pending exception but there is no matching catch
handler, we do not execute the deoptimized shadow frame and continue
to its caller.

The verifier now fails when a method starts with a move-exception
instruction. Indeed we cannot start executing a method with a pending
exception.

Bug: 19057915
Bug: 19041195
Bug: 18607595
Change-Id: I355ac81e6ac098edc7e3cc8c13dbfa24a2969ab2
4306ef8a7ec8e3887e51f64e80d940d974cc3ac3 20-Dec-2014 Mathieu Chartier <mathieuc@google.com> Don't allow suspension from FindLocksAtDexPc

Transitioning to suspended from runnable sometimes runs dump
checkpoints in ThreadStress which can cause deadlocks. This happens
since FindLocksAtDexPC runs the verifier which calls
AllowThreadSuspension. This results in a blocked thread which holds
the monitor lock, and if another thread tries to do a monitor enter,
it deadlocks while holding the mutator lock (assuming the GC is
suspending all).

The fix for avoiding this deadlock is not calling
AllowThreadSuspension from FindLocksAtDexPc.

Bug: 18576985
Change-Id: I7e5faaf3bbbd5b5f680de95d53c33b5106705b0c
7e541c91997b7747fa79014a8ea540395e54efc8 17-Dec-2014 Stephen Kyle <stephen.kyle@arm.com> ART: Fix verification of constructors.

Summary:

A constructor must call its superclass constructor. However, if one
replaces the invoke-direct superclass.<init>() instruction with a
variety of instructions, the verifier would NOT complain that the
superclass constructor hadn't been called.

Detailed explanation:

This was because if we are verifying the return-void insn of a
constructor, then we check that the register line doesn't contain a
register with an UninitializedThis type. With a method like follows:

Class.<init>()V:
return-void

Then we hit the return-void, see the UninitializedThis, and fail the
method. However, with a method like follows:

Class.<init>()V:
nop
return-void

Any insn that continues or branches onto a return-void instruction will
mark all of the registers as Conflict. This meant that the check in
return-void for an UninitializedThis residing the register line would
_always_ pass if there were any insns before it - the entire line had
been set to Conflict.

The fix is to bring the check for an UninitializedThis forward to the
point just before we set all registers to Conflict, if we're about to
hit a return-void insn in a constructor. It still needs to be done
again in the verification of return-void itself, to avoid the solo
return-void case.

This patch also deals with the case where the only remaining
UninitializedThis reference is overwritten, to avoid a method like the
following from getting through verification:

Class.<init>()V:
const/4 v0, 0
return-void

Bug: 18800943

Change-Id: I2e317261844d3b6c78e35228669f3da173316570
Fuzzed-With: https://android-review.googlesource.com/#/c/119463/
36b58f5ebb85d58f8b5966b8577a6dfe720d1e16 10-Dec-2014 Mathieu Chartier <mathieuc@google.com> Add verifier support for dequickening

Also some cleanup.

Bug: 17950037

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

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

This reverts commit fe382b5296ef132316d8883a0bdf8cb00d40d16b.

Bug: 18338511
Bug: 18705942
Change-Id: I3516acaaa65f05395c14da0701d1049ba80acb12
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
f9943f251a57644b28800212e21f6a252683adba 10-Dec-2014 Brian Carlstrom <bdc@google.com> Fix verifier bug caused by confusing ArtMethod::IsDirect vs ArtMethod::IsStatic semantics.

Bug: 18485243

(cherry picked from commit be6fa5eb4a571e14481cf43f4cb264629c069153)

Change-Id: I6e4d8e7587f7e03288ce039471154c1e6ebc7d8a
be6fa5eb4a571e14481cf43f4cb264629c069153 10-Dec-2014 Brian Carlstrom <bdc@google.com> Fix verifier bug caused by confusing ArtMethod::IsDirect vs ArtMethod::IsStatic semantics.

Bug: 18485243
Change-Id: I011872446490628b51fb38a353abd1d499cc1290
8b858e16563ebf8e522df026a6ab409f1bd9b3de 27-Nov-2014 Vladimir Marko <vmarko@google.com> Quick: Redefine the notion of back-egdes.

Redefine a back-edge to really mean an edge to a loop head
instead of comparing instruction offsets. Generate suspend
checks also on fall-through to a loop head; insert an extra
GOTO for these edges.

Add suspend checks to fused cmp instructions.

Rewrite suspend check elimination to track whether there is
an invoke on each path from the loop head to a given back
edge, instead of using domination info to look for a basic
block with invoke that must be on each path. Ignore invokes
to intrinsics and move the optimization to a its own pass.

The new loops in 109-suspend-check should prevent intrinsics
and fused cmp-related regressions.

Bug: 18522004
Change-Id: I96ac818f76ccf9419a6e70e9ec00555f9d487a9e
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
896df40bbb20f4a1c468e87313b510c082016dd3 21-Oct-2014 Andreas Gampe <agampe@google.com> ART: Fix possible soft+hard failure in verifier

It was possible to generate a hard failure and a subsequent soft
failure, which violates a CHECKed invariant.

Refactor code slightly to share common code.

Bug: 17625962

(cherry picked from commit f08663b47ccd3aa083972d62937a328ad80d080e)

Change-Id: Iccd9e30f1087363b19b2faedc10243a2290202c0
f08663b47ccd3aa083972d62937a328ad80d080e 21-Oct-2014 Andreas Gampe <agampe@google.com> ART: Fix possible soft+hard failure in verifier

It was possible to generate a hard failure and a subsequent soft
failure, which violates a CHECKed invariant.

Refactor code slightly to share common code.

Bug: 17625962
Change-Id: Iccd9e30f1087363b19b2faedc10243a2290202c0
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
f72a11dd4b0dd86bc4b1baa37bfa47fc8d5572b5 30-Oct-2014 Ian Rogers <irogers@google.com> Add math routines with defined wrapping behavior for the interpreter.

Add a RSUB_INT_LIT16 instruction alias to make instruction opcode switch
statements easier to read.

Change-Id: I3bac07c9518665abf0b05b5c3105a90be22f780a
7c0381049ea33e64514984432312290842946bc1 28-Oct-2014 Andreas Gampe <agampe@google.com> ART: Do not abort on most verifier failures

Changes hard aborts to hard verifier failures, which rejects a
class instead of killing the process.

Bug: 17625962

(cherry picked from commit 8fa841aa1c02ff8e3e7caaa73ed5fe25f027d5d3)

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

Also, fix missing handle in HasSameSignatureWithDifferentClassLoaders.

Change-Id: I9e1ffd09be950ecc8346fc3c485760d82d9ecab3
8fa841aa1c02ff8e3e7caaa73ed5fe25f027d5d3 28-Oct-2014 Andreas Gampe <agampe@google.com> ART: Do not abort on most verifier failures

Changes hard aborts to hard verifier failures, which rejects a
class instead of killing the process.

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

Change-Id: I4e4ef3a2002fc59ebd9097087f150eaf3f2a7e08
b5abda622135d913e224faa8f9b863e1adf876e0 15-Aug-2014 Elena Sayapina <elena.v.sayapina@intel.com> ART: Fix verifier fail message.

Verifier failure message is corrupted.
The verification failure reason overlaps verification failure location.
MethodVerifier::Fail() method creates failure message stream by
std::ostringstream(failure location) constructor which by default
sets the stream's position indicator to the begging of that stream.
Inserting failure reason to the stream by "<<" then overrides the failure location.
Using std::ostringstream(failure location, std::ostringstream::ate) fixes the issue
by setting the stream's position indicator to the end of the stream on opening.

Signed-off-by: Elena Sayapina <elena.v.sayapina@intel.com>

(cherry picked from commit 78480ecb348beee3f27731e12ec06ade032521d6)

bug: 17790245

Change-Id: I31955e859a4eb01d05318395901e8cd229a6c33c
5ca20548f6298b16ebf9793d0135c1478dd65946 16-Sep-2014 Andreas Gampe <agampe@google.com> ART: More verifier error output

Add some debug output on verifier abort.

Change-Id: I4a84ff1d8e1bad689addca287a989639e7111b97
cb3c08fe9c733e477776dcc0d0fa5a3cf0053aa7 18-Sep-2014 Andreas Gampe <agampe@google.com> ART: Do a pre-pass for monitor_enter dex pc search

In case the method does not have any monitor_enter instructions,
it is unnecessary to run the full verifier. Speeds up stack dumps
and works around b/17514582.

Bug: 17514582
Change-Id: I5201bfbb9fb6cad49596b4c72e71983b58d9f20c
5f09be9e4fbd3002712e820245562b1a57e55c3f 26-Sep-2014 Hiroshi Yamauchi <yamauchi@google.com> Fix verifier crash in GetQuickFieldAccess().

Bug: 17671806
Change-Id: Ifb603f6f55a94826d656a4c73a7e328d74f6dac9
9bc6199a9a6e140102951f6f38845b43b561af83 22-Sep-2014 Stephen Kyle <stephen.kyle@arm.com> ART: Reject branch/switch/throw to move-result.

move-result* instructions must occur after invoke instructions,
however it was still possible to branch or switch to a move-result*
instruction with creative DEX manipulation. The verifier now rejects
this situation, as well as having a move-result* instruction as the
first instruction in a try block's handler. This now ensures that
move-result* must happen dynamically after an invoke, not just
statically.

Change-Id: Ida97852f4051310fdaf38bed1d6e1c5a541c85c5
Signed-off-by: Stephen Kyle <stephen.kyle@arm.com>
0036cd492ab19668c4efe0975654b7d11d1d8998 18-Sep-2014 Brian Carlstrom <bdc@google.com> Remove MethodVerifier whitespace diff from aosp/master

(cherry picked from commit 6e5251e154cf7e1ce0965f62146467c91a69f811)

Change-Id: I821eee8cfacfbb9b7cc8fa972faa58e9ad47f58e
6e5251e154cf7e1ce0965f62146467c91a69f811 18-Sep-2014 Brian Carlstrom <bdc@google.com> Remove MethodVerifier whitespace diff from aosp/master

Change-Id: Iaec0afe71ed05e44850ed22d4849b464e423c218
5cbcde2983d7cb95deb38d39784f03a7192b0061 16-Sep-2014 Andreas Gampe <agampe@google.com> ART: Fix method verifier dumping

Do not try to dump on hard failure.

Bug: 15567083
Change-Id: I6278f551f8a9dc7411087e214023dd4d142d1d26
2cbaccb67e22c0b313a9785bfc65bcb4b25d0676 15-Sep-2014 Brian Carlstrom <bdc@google.com> Avoid printing absolute addresses in oatdump

- Added printing of OatClass offsets.
- Added printing of OatMethod offsets.
- Added bounds checks for code size size, code size, mapping table, gc map, vmap table.
- Added sanity check of 100k for code size.
- Added partial disassembly of questionable code.
- Added --no-disassemble to disable disassembly.
- Added --no-dump:vmap to disable vmap dumping.
- Reordered OatMethod info to be in file order.

Bug: 15567083

(cherry picked from commit 34fa79ece5b3a1940d412cd94dbdcc4225aae72f)

Change-Id: I2c368f3b81af53b735149a866f3e491c9ac33fb8
34fa79ece5b3a1940d412cd94dbdcc4225aae72f 15-Sep-2014 Brian Carlstrom <bdc@google.com> Avoid printing absolute addresses in oatdump

- Added printing of OatClass offsets.
- Added printing of OatMethod offsets.
- Added bounds checks for code size size, code size, mapping table, gc map, vmap table.
- Added sanity check of 100k for code size.
- Added partial disassembly of questionable code.
- Added --no-disassemble to disable disassembly.
- Added --no-dump:vmap to disable vmap dumping.
- Reordered OatMethod info to be in file order.

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

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

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

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

Bug: 17316928

(cherry picked from commit 35439baf287b291b67ee406308e17fc6194facbf)

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

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

Bug: 16161620

(cherry picked from commit 7fc8f90b7160e879143be5cfd6ea3df866398884)

Change-Id: I2f591d53b7d1559171e70aaaf22225d94b4882f5
7c438b19b71932ac8a44eff44f20744a01559c8d 13-Sep-2014 Mathieu Chartier <mathieuc@google.com> Fix stale root error in verifier

There was a stale root error caused by the static roots from
the reg types. These were visitied if there was an active verifier
in the method_verifiers_ but this is not always the case when a GC
is run. The fix is to always visit the static method verifier roots.

This only showed up as a bug without an image since these roots
were primitive classes and always in the image, and therefore
didn't ever need to be updated due to moving GC.

(cherry picked from commit 6167864e28e4e12658ebdbaf1d5239acdaf4aaa4)

Change-Id: I592f2770570de97b431671cfbd409f63697892f1
6167864e28e4e12658ebdbaf1d5239acdaf4aaa4 13-Sep-2014 Mathieu Chartier <mathieuc@google.com> Fix stale root error in verifier

There was a stale root error caused by the static roots from
the reg types. These were visitied if there was an active verifier
in the method_verifiers_ but this is not always the case when a GC
is run. The fix is to always visit the static method verifier roots.

This only showed up as a bug without an image since these roots
were primitive classes and always in the image, and therefore
didn't ever need to be updated due to moving GC.

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

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

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

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

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

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

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

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

Bug: 16161620
Change-Id: I2f591d53b7d1559171e70aaaf22225d94b4882f5
d8f69b086baf6717ce949d1c4de90d73b91083b0 10-Sep-2014 Ian Rogers <irogers@google.com> Revert "Add read barriers for the roots in the verifier."

This reverts commit 7da9586b559290e1c16207c6513ffe485de61655.

Bug: 17398101

Change-Id: I1d6110fdf0d3a3c9241c8e7e7f4b85a298f9dd8e
376fa68f02d1cd56e506533a3ad16de4de88271d 07-Sep-2014 Andreas Gampe <agampe@google.com> ART: Fix unchecked register index validity

The static check of index validity is against the type given by
the instruction, e.g., boolean for SPUT_BOOLEAN, but the target_type
is the resolved field type and can differ. An additional check is
necessary to avoid a read out of bounds.

Bug: 17411109

(cherry picked from commit 74ae47a0590feceea31a2388f98c83e3ec0df0ec)

Change-Id: Ie4ed8bbda79f3f6403a24e727450a943447aa71d
74ae47a0590feceea31a2388f98c83e3ec0df0ec 07-Sep-2014 Andreas Gampe <agampe@google.com> ART: Fix unchecked register index validity

The static check of index validity is against the type given by
the instruction, e.g., boolean for SPUT_BOOLEAN, but the target_type
is the resolved field type and can differ. An additional check is
necessary to avoid a read out of bounds.

Bug: 17411109
Change-Id: Ie4ed8bbda79f3f6403a24e727450a943447aa71d
6dd35ccbfbb29201c84a54261d75977c598ef2e6 27-Aug-2014 Ian Rogers <irogers@google.com> Revert "Avoid using NanoTime for compiler and verifier"

This reverts commit c89e6edbdce97c7d199b54bf63aed7ea01ebf1ff.

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

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

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

After:
real 0m35.667s
real 0m35.779s
real 0m35.458s

Bug: 16853450

Change-Id: Id996172d8283639fe293ddfc26d01fc1a0beed0b
b68c6e578a28a9717d78dfd522d9d9b8befaedf2 19-Aug-2014 Mathieu Chartier <mathieuc@google.com> Reduce interpret-only compile time.

Before:
39.04user 5.18system 0:29.24elapsed 151%CPU (0avgtext+0avgdata 164176maxresident)k
38.87user 5.16system 0:29.14elapsed 151%CPU (0avgtext+0avgdata 164144maxresident)k

After:
36.26user 3.25system 0:27.00elapsed 146%CPU (0avgtext+0avgdata 162592maxresident)k
36.25user 3.28system 0:26.28elapsed 150%CPU (0avgtext+0avgdata 162688maxresident)k

Disabled implicit stack protection for the compiler, this reduces page faults.

Added support for not timing every method compilation and verification. NanoTime is
slow and adds ~2 seconds of real time. This is currently enabled since people want
to know which methods are slow to compile.

Bug: 16853450

(cherry picked from commit 8e219ae27624116b6d23e858fb21e93342f81d66)

Change-Id: I349ffb3f36db8c437137387aa6914dc17d743f09
8e219ae27624116b6d23e858fb21e93342f81d66 19-Aug-2014 Mathieu Chartier <mathieuc@google.com> Reduce interpret-only compile time.

Before:
39.04user 5.18system 0:29.24elapsed 151%CPU (0avgtext+0avgdata 164176maxresident)k
38.87user 5.16system 0:29.14elapsed 151%CPU (0avgtext+0avgdata 164144maxresident)k

After:
36.26user 3.25system 0:27.00elapsed 146%CPU (0avgtext+0avgdata 162592maxresident)k
36.25user 3.28system 0:26.28elapsed 150%CPU (0avgtext+0avgdata 162688maxresident)k

Disabled implicit stack protection for the compiler, this reduces page faults.

Added support for not timing every method compilation and verification. NanoTime is
slow and adds ~2 seconds of real time. This is currently enabled since people want
to know which methods are slow to compile.

Bug: 16853450

Change-Id: I349ffb3f36db8c437137387aa6914dc17d743f09
ccb1a5d46bc1b4ee888e74775f5c1291d600ff54 22-Aug-2014 Stephen Kyle <stephen.kyle@arm.com> ART: Reject field accesses to non-reference vregs.

The verifier will now reject any iget/iput insts
that do not have a reference object in vB.

Bug: 17207857
Signed-off-by: Stuart Monteith <stuart.monteith@arm.com>

(cherry picked from commit 695c5982eeddee18c643cc2f94c9d78fa75599ab)

Change-Id: I3790b8687673643bb142549d74f36a3e2978bf13
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
695c5982eeddee18c643cc2f94c9d78fa75599ab 22-Aug-2014 Stephen Kyle <stephen.kyle@arm.com> ART: Reject field accesses to non-reference vregs.

The verifier will now reject any iget/iput insts
that do not have a reference object in vB.

Bug: 17207857
Change-Id: I2826f0f7abfc88561f4da9486588592f4b296d14
Signed-off-by: Stuart Monteith <stuart.monteith@arm.com>
dc3761719fb5e2d1ced5708e3c73b965f9ef0c73 22-Aug-2014 Hiroshi Yamauchi <yamauchi@google.com> Handlerize MethodVerifier::mirror_method_.

The method (mirror_method_) wasn't handlerized across some
allocation/GC points such as the ResolveType() call in
ScanTryCatchBlocks() and the GetReturnType() calls in
CodeFlowVerifyInstruction().

Bug: 12687968
Change-Id: I95323de14459eb5a7c4abfcf44f882f86d59be64
78480ecb348beee3f27731e12ec06ade032521d6 15-Aug-2014 Elena Sayapina <elena.v.sayapina@intel.com> ART: Fix verifier fail message.

Verifier failure message is corrupted.
The verification failure reason overlaps verification failure location.
MethodVerifier::Fail() method creates failure message stream by
std::ostringstream(failure location) constructor which by default
sets the stream's position indicator to the begging of that stream.
Inserting failure reason to the stream by "<<" then overrides the failure location.
Using std::ostringstream(failure location, std::ostringstream::ate) fixes the issue
by setting the stream's position indicator to the end of the stream on opening.

Change-Id: I8cc1cffc95bc5c56aadbb9ab8c0cdc8bc680d6f4
Signed-off-by: Elena Sayapina <elena.v.sayapina@intel.com>
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
04ce113458b6b01f96d58dbb4c41682ee22d8b5d 04-Aug-2014 Jeff Hao <jeffhao@google.com> Make verifier identify unresolved methods as constructors by <init>.

Check was previously missing brackets in the method name.

Bug: 16560516
Change-Id: I6b28f8413f3d4c14269a6de38731213d7c964af6
0d08727e19b46770f0f27633d08caf13d9bb3e98 04-Aug-2014 Jeff Hao <jeffhao@google.com> Make verifier identify unresolved methods as constructors by <init>.

Check was previously missing brackets in the method name.

Bug: 16560516

(cherry picked from commit 04ce113458b6b01f96d58dbb4c41682ee22d8b5d)

Change-Id: Ie98c5b84e73ffc43ea08e1b08ae9c6e41bcd5891
e19f2b00eebd61e73761ab531866654f08968711 16-Jul-2014 Mingyao Yang <mingyao@google.com> Set vtable in class object to null after linking.

This is follow-up work of embedding imt and vtable for
faster interface/virtual call dispatching.
Once vtable becomes embedded, the original vtable is nulled.

(cherry picked from commit 2cdbad7c62f126581ec5177104de961c4d71adaa)

Change-Id: I6acdcd1ee560d387fb77c55c58bbe3598c197ba1
7da9586b559290e1c16207c6513ffe485de61655 30-Jul-2014 Hiroshi Yamauchi <yamauchi@google.com> Add read barriers for the roots in the verifier.

Note: Because the roots (the class references in RegType objects) can
be updated by the read barriers, a lot of uses of type "const RegType"
were replaced with "RegType".

Bug: 12687968
Change-Id: I6cf37a87f352938d43fb51560a8d927ada104f50
4c6427a757cae2b1c79aafca71be780e54620e68 28-Jul-2014 Andreas Gampe <agampe@google.com> ART: Reject array-length on non-reference register

It should be a hard verifier failure if we detect an array-length
instruction over a non-reference-type register.

Bug: 16595896

(cherry picked from commit 65c9db8dfbeea3f708f95f058f4fed7c2af71052)

Change-Id: I56babcbe95d50fd66a132cf4434cf5fa780beb4e
65c9db8dfbeea3f708f95f058f4fed7c2af71052 28-Jul-2014 Andreas Gampe <agampe@google.com> ART: Reject array-length on non-reference register

It should be a hard verifier failure if we detect an array-length
instruction over a non-reference-type register.

Bug: 16595896
Change-Id: I059510b15c846551b2f8ded86cfd8127543324f4
328fbbf9b2de27f02dbbee4e91bb5e612ef43203 22-Jul-2014 Andreas Gampe <agampe@google.com> ART: Check high part of dalvik register pairs on put-wide

When verifying a put-wide, it is necessary to check the lo and the hi
register for the right type.

Bug: 16018242

(cherry picked from commit 2a593a14e8e0df01a50139e0d48c7be46fb057ef)

Change-Id: I9e661951d592e155e0f281ea959e778d8f4a67ab
2cdbad7c62f126581ec5177104de961c4d71adaa 16-Jul-2014 Mingyao Yang <mingyao@google.com> Set vtable in class object to null after linking.

This is follow-up work of embedding imt and vtable for
faster interface/virtual call dispatching.
Once vtable becomes embedded, the original vtable is nulled.

Change-Id: I307696657d1e283654169dbecb8f7815c42bbabc
2a593a14e8e0df01a50139e0d48c7be46fb057ef 22-Jul-2014 Andreas Gampe <agampe@google.com> ART: Check high part of dalvik register pairs on put-wide

When verifying a put-wide, it is necessary to check the lo and the hi
register for the right type.

Bug: 16018242
Change-Id: I9e661951d592e155e0f281ea959e778d8f4a67ab
f021cc085ac00ee2b6eaac6ffdf8f01596289dc7 19-Jul-2014 Andreas Gampe <agampe@google.com> ART: Also accept java.lang.Throwable as a catch-all handler.

Accept catch handlers with catch type of java.lang.Throwable as
catch-all handlers.

(cherry picked from commit f91baf17ad11a86c84c9fc34ff70feee65a43233)

Bug: 16308310
Change-Id: Ie9b9582ee71c94c82b7695dc6f9c2c6df3d869d8
493c9beb3635d091c159043337836d6fa5d10107 18-Jul-2014 Andreas Gampe <agampe@google.com> ART: Make a soft failure in method verifier hard, add check

Make the soft error of using a primitive type in an instanceof a
hard verifier error.

Add a check when doing check_cast peep-hole optimization to check
whether the cast type is valid.

(cherry picked from commit 00633eb490ad21f711dcfccfb3a70992b2f8a72a)

Bug: 16020300
Change-Id: Icaea560d17804f24a13dc09c115e9ec7039cb472
f91baf17ad11a86c84c9fc34ff70feee65a43233 19-Jul-2014 Andreas Gampe <agampe@google.com> ART: Also accept java.lang.Throwable as a catch-all handler.

Accept catch handlers with catch type of java.lang.Throwable as
catch-all handlers.

Bug: 16308310
Change-Id: Ie9b9582ee71c94c82b7695dc6f9c2c6df3d869d8
00633eb490ad21f711dcfccfb3a70992b2f8a72a 18-Jul-2014 Andreas Gampe <agampe@google.com> ART: Make a soft failure in method verifier hard, add check

Make the soft error of using a primitive type in an instanceof a
hard verifier error.

Add a check when doing check_cast peep-hole optimization to check
whether the cast type is valid.

Bug: 16020300
Change-Id: Icaea560d17804f24a13dc09c115e9ec7039cb472
e5877a12c30afe10a5c6a1afaff7a47ef44a2a5f 16-Jul-2014 Ian Rogers <irogers@google.com> Fix x86 build.

Also fix attributes/annotalysis on entrypoint_utils functions now we have
clang that is smarter wrt warnings than GCC.

Change-Id: I69257b4ad9a27d07acbc973d21a1cfa4260a8ed6
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
ebbdd87cbb57e45da341fbf7325406e982810c10 08-Jul-2014 Ian Rogers <irogers@google.com> Only allow instance-of to improve knowledge of a type for downcasts.

Previous "not upcast" test could improve a type to an impossible type that
following a merge back with the original register would lead to conflict
(and subsequent verifier errors).
Modify UpdateRegisters so that the work line will be updated if merging
causes changes in the fall-through case.

Bug: 15808277
Issue: https://code.google.com/p/android/issues/detail?id=72093
Change-Id: Ib16cae8506246177e902825af036d5a397ad0dac
c3314311df5ae50ea9151ac4933d3eccbdefb41a 20-Jun-2014 Andreas Gampe <agampe@google.com> ART: Method verifier must check invoke-virtuals for non-zero args

Compiler checks rely on all instructions, not just reachable ones,
so add two new verifier flags.

Bug: 15755602
Change-Id: Ia9c2146cf82d94ce4d69fb6f7be6450137bb84bd
77cd4d677c682c194b8325b209cb76720be4046a 20-Jun-2014 Andreas Gampe <agampe@google.com> ART: Method verifier needs to check 2-reg values

The method verifier did not check against the second register
for a J or D parameter from a method signature.

The register line had a wrong DCHECK that did not catch this even
in debug mode.

Bug: 15751498
Change-Id: Ic6af08bf4704b3ab0f308dd9f0da28691a4cb024
95c0bf8fb5847cff263639f889d04c7c3c26eedd 16-Jun-2014 Andreas Gampe <agampe@google.com> ART: Make verifier check invocation args of unresolved methods

In the case of unresolvable methods it is not enough to bail out
with a soft verifier failure, as the compiler relies on the
invocation being well-formed. Check all arguments against the
proto id in such a case.

Also make sure to complete parsing arguments in the case the
method was resolved.

Refactored code to unite these two cases.

Bug: 15616104
Change-Id: I5ec58cbfbf6b09eaaf07ddf15edae7c6a8b62b17
073ed9ba97df41862403f64d7a2e824d09ab50ed 14-Jun-2014 Andreas Gampe <agampe@google.com> ART: Ignore timing issues in debug builds

When in debug builds, do not warn about slow verification and
compilation.

Change-Id: Ib982e1c7cf40cf624688bbf6c41f0a7cc53bbc67
acc4d2f72a2cadce2964dd2cc9eb20f73fc552ff 13-Jun-2014 Andreas Gampe <agampe@google.com> ART: Check the number of invocation args in verifier

Check the number of invocation arguments against the method's
prototype signature. It could happen that the method wasn't
available, yet, in which case we would let a clearly wrong
instruction through.

This generalizes https://android-review.googlesource.com/#/c/97779/

Bug: 15570483
Change-Id: Ie81aff3c1166a2b2bf1385414dff2e22fbb40ef2
e2256621883f321513a6397ca82a271c64d7c393 12-Jun-2014 Andreas Gampe <agampe@google.com> ART: Do not allow quickened dex codes in compiler mode.

The method verifier will reject quickened dex opcodes when the
runtime is in compiler mode, as we do not expect them here.

Bug: 15570344
Change-Id: I072567835139860213f9882cac995370b4548a79
5fb22a916dcb652fd2c2a2421de621f458177dcd 13-Jun-2014 Ian Rogers <irogers@google.com> Don't verify runtime only opcodes in the data-flow phase of verification.

Bug: 15570344
Change-Id: I0304e8742a1d0318783ba72862e684ab91f63d0e
9f2b6433c17ec8ea30015fd1b20e7a0ad3d4159e 13-Jun-2014 Andreas Gampe <agampe@google.com> ART: Invoke_virtual needs at least receiver parameter

Makes the method verifier reject invoke_virtual instructions that
claim they do not need any parameters.

Bug: 15570946
Change-Id: Ia76fddb7a08551d6c08654950e7085f09eacf430
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
576ca0cd692c0b6ae70e776de91015b8ff000a08 07-Jun-2014 Ian Rogers <irogers@google.com> Reduce header files including header files.

Main focus is getting heap.h out of runtime.h.

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

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

Bug: 13077697

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

Merge ART from AOSP to lmp-preview-dev.

Change-Id: I0f578733a4b8756fd780d4a052ad69b746f687a9
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
46960fe5dcc1be07b39a55114338423a73554449 23-May-2014 Ian Rogers <irogers@google.com> Make the specification of when we need precise constants more precise.

Means that oatdump output showing values for deoptimization actually reflects
what we see at runtime.
Also, doesn't do precise in the case of determining methods and fields for the
quickened case, which may be an occasional performance win.

Change-Id: I62c7fb244f7996ba9d52e7a7ce75c046b663fa17
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
700a402244a1a423da4f3ba8032459f4b65fa18f 20-May-2014 Ian Rogers <irogers@google.com> Now we have a proper C++ library, use std::unique_ptr.

Also remove the Android.libcxx.mk and other bits of stlport compatibility
mechanics.

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

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

Bug: 8981901

Change-Id: I82b3bb6dd48d21eb6ece7aae0733c4a23c2bc408
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
6c9678f64d022a76aa43c4eba5e30d9759e2a77e 08-May-2014 Ian Rogers <irogers@google.com> Allow invoke-virtual-quick on interface types.

Fix a broken assumption that receivers for invoke-virtual are non-interface
types.

Bug: 14469172
Change-Id: I0d6e19141d4f52a4bd27bf1cb5f8d0e85fc9cf49
a4cf1df04b3de24e69c044e0aae4c2573d6c37d1 08-May-2014 Ian Rogers <irogers@google.com> Allow invoke-virtual-quick on interface types.

Fix a broken assumption that receivers for invoke-virtual are non-interface
types.

Bug: 14469172
Change-Id: I0d6e19141d4f52a4bd27bf1cb5f8d0e85fc9cf49
deca99bf42d0f5300b1dacc1df383b5950209645 06-May-2014 Brian Carlstrom <bdc@google.com> Add more context for CHECKs

Bug: 14469172
Change-Id: I7b75c63c857d0fd7e3b08990f21a73d2dfe430b1
33f2e594cc37570de9fc806e1cf66767205f20a2 06-May-2014 Brian Carlstrom <bdc@google.com> Add more context for CHECKs

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

Change-Id: I188dc7fef4f4033361c78daf2015b869242191c6
2ed76f95dd5a7edada82407a1853be803c9853a9 22-Apr-2014 Sebastien Hertz <shertz@google.com> Resolve method's argument reference types

Using ResolveClassAndCheckAccess allows to resolve reference types and check
we have access to these types too. This also prevents from getting unresolved
reference types, which has been observed during deoptimization.

Bug: 13464407
Change-Id: I4c02fdff191c195f34502a4d4a20357419982eb1
479fc1ecc12fa6560ca90d841c4d5174fb346618 04-Apr-2014 Sebastien Hertz <shertz@google.com> Support field watchpoint in interpreter

We report field read/write events to instrumentation from the interpreter. This
allows it to send JDWP field access and field modification events to debugger.
This completes CL https://android-review.googlesource.com/90390.

We also fix the JDWP FieldOnly modifier by introducing ModBasket.fieldTypeID.
We incorrectly used ModBasket.classId which is actually dedicated to ClassOnly
modifier based on thread's location's class id.

Finally, we now enable canWatchFieldModification and canWatchFieldAccess JDWP
capabilities so a debugger can request these events to be reported.

Bug: 8267708
Change-Id: I987852ad47abb27b2f7e78544a8189c7a4e2f462
b878f2133a04593643228eb1d47993092528b963 25-Apr-2014 Jeff Hao <jeffhao@google.com> Make unresolved exception types cause soft verification errors.

Before, the verifier would allow the first exception it finds
for a catch block to be unresolved, but this causes problems if
it merges other exceptions later. The verifier should soft fail
for any unresolved exception type it finds.

Bug: 14256107
Change-Id: I22563ebfe8c9680cc676b73516d5b48bc9c4ecf3
9bc54406ba3377980cfce44901dc2be246178ba9 18-Apr-2014 Ian Rogers <irogers@google.com> Interpreter-only mode should cause dex-to-dex compilation.

Also, fix quick iget/iput that had similar issues to:
https://android-review.googlesource.com/91423
Also, remove fall-back resolution code from quick invokes/igets/iputs as we
allow class loading for the exception throw and regular verification already
allows class loading.
Bug: 14133618

Change-Id: I51199e6e2392da0354f64b157e79af494c183778
639815628cf52a4a944a4322cb09da37cded2de9 17-Apr-2014 Andreas Gampe <agampe@google.com> Fix a class-loading bug in the verifier when throwing NPE

When throwing an NPE for invocation, we try to resolve the class of
the method being called. When in the interpreter and having quickened
code, that failed.

Bug: 14133618
Change-Id: I4964b908bb26a82a12263fb86f5dc39c9042479b
d1c88b5030f6f7d1f5aea2e6b69a9c0b41515c67 10-Apr-2014 Mathieu Chartier <mathieuc@google.com> Change FindClass in GetQuickInvokedMethod to use reg_types_.

FindClass can do ScopedThreadStateChange which causes check failures
during SIGQUIT.

Bug: 13929160
Change-Id: I00be4972423c04254a922de3aa731e8edb38ca02
4b06a725fe722063cb595d42ed4ed8b4fd05db9c 10-Apr-2014 Mathieu Chartier <mathieuc@google.com> Change FindClass in GetQuickInvokedMethod to use reg_types_.

FindClass can do ScopedThreadStateChange which causes check failures
during SIGQUIT.

Bug: 13929160
Change-Id: I00be4972423c04254a922de3aa731e8edb38ca02
757b304a2dfaeaee01071c9e2ee5e5a18ea18545 28-Mar-2014 Sebastien Hertz <shertz@google.com> Properly dump register type in verifier failure messages

Fixes failure messages where we miss to dereference pointer to RegType. This
caused to dump the address of the reg type instead of the reg type itself.

Also moves merging tests of primitive types from RegTypeReferenceTest to
RegTypeTest class.

Change-Id: I71cea419fdaa9ac46d7c011eb23e8746a14fb378
aa0c00c97bc1fe5c8def7c6cdebfd119e86d07e5 14-Mar-2014 Sebastien Hertz <shertz@google.com> Fix reg type merging in the verifier

Fixes bad merging of float, long and double reg types with constant types. Adds
merging tests in reg_type_test.

Bug: https://code.google.com/p/android/issues/detail?id=66434
Bug: 13464407
Change-Id: I56761f5f5562b742d0ef9cc66b58d55f7b668949
c645f1ddb7c40bea6a38eda4b3f83f6b6dec405b 07-Mar-2014 Mathieu Chartier <mathieuc@google.com> Add more VerifyObject calls.

Added verify object calls to SirtRef, IndirectReferenceTable,
ReferenceTable.

Removed un-needed verify object in ScopedObjectAccess / DecodeJObject
since object sources are handled.

Bug: 12934910
Change-Id: I55a46a8ea61fed2a77526eda27fd2cce97a9b125
b04388f6f05be900386da1ca66615d9542c35475 05-Mar-2014 Brian Carlstrom <bdc@google.com> Fix oatdump for interpret-only boot classpath

Change-Id: I12cf5046b01dfba110bf0604fe01a8abf8b352dc
a2806550cefb7c70781d8ee6279e6ad5769804cb 27-Feb-2014 Brian Carlstrom <bdc@google.com> Remove some stray stringpiece.h includes

Bug: 13186058
Change-Id: I2cb313425864a5d4e988fcf71a99c60ad63c63fb
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
83c8ee000d525017ead8753fce6bc1020249b96a 28-Jan-2014 Mathieu Chartier <mathieuc@google.com> Add root types and thread id to root visiting.

Enables us to pass the root type and thread id to hprof.

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

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

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

Change-Id: I1a5694c251a42c9eff71084dfdd4b51fff716822
eae2fb27c91aa7972dffcb32d5e405567badd6aa 14-Jan-2014 Mathieu Chartier <mathieuc@google.com> Don't resolve types in verifier when we can't load classes.

Added a boolean parameter to GetReturnType which tells us whether or
not we can resolve types. We pass in can_load_classes_.

Bug: 11689500
Change-Id: Ib3d35f441e08c2409ce14ac269854012dc978ddd
849600bb5cfc02bf5ab4aa9a810667ebd3b53328 20-Dec-2013 Sebastien Hertz <shertz@google.com> Use imprecise constants at compilation time.

During veriifcation, we create constant types for the following instructions:
const/4, const/16, const and const/high16. We used to create "precise" constant
types for each constant we process in the method being verified. Though precise
constants are only useful for deoptimization which happens at runtime.

This CL now creates "imprecise" constant types at compilation time. Since it
reduces the number of constant types we create during verification, it should
also reduce the amount of time spent in verification at compilation time.

Bug: 12167380
Bug: 12126841
Change-Id: I70522c4133a74a533fc2d2cb8d4f49888e590828
2b5eaa2b49f7489bafdadc4b4463ae27e4261817 13-Dec-2013 Vladimir Marko <vmarko@google.com> Move compiler code out of method verifier.

We want to detect small methods for inlining at the end of
the method verification. Instead of adding more compiler
code to the runtime, we create a callback from the runtime
into the compiler, so that we can keep the code there.
Additionally, we move the compiler-related code that was
already in the method verifier to the compiler since it
doesn't really belong to the runtime in the first place.

Change-Id: I708ca13227c809e07917ff3879a89722017e83a9
2d7e5aa6c707537f1906ed77b0ff29ec3dd261f7 14-Dec-2013 Jeff Hao <jeffhao@google.com> Add classes that fail verification early to rejected class list.

Change-Id: I5e06ec2dc3dfd061fcd6c099e10991482a1aaf65
c528dba35b5faece51ca658fc008b688f8b690ad 26-Nov-2013 Mathieu Chartier <mathieuc@google.com> Enable moving classes.

Slight reduction in Zygote size, memory savings are in the noise.
Before: Zygote size: 8739224
After: Zygote size: 8733568

Fixed a bug where we didn't set the concurrent start bytes after
switching the allocator from bump pointer to ROSAlloc in the
zygote. This caused excessive memory usage.

Added the method verifiers as roots to fix an issue caused by
RegTypes holding a Class*.

Added logic to clear card table in the SemiSpace collector, this
reduces DalvikOther from ~2400k -> ~1760k when using the SemiSpace
collector.

Added a missing lock to the timing loggers which caused a rare
one time crash in std::set.

Bug: 11771255
Bug: 8499494
Bug: 10802951

Change-Id: I99d2b528cd51c1c5ed7012e3220b3aefded680ae
8171fc34bf74ed0df02385787d916bc13eb7f160 26-Nov-2013 Vladimir Marko <vmarko@google.com> Don't prefix GC map by length.

Bug: 11767815
Change-Id: I063917aefdf7674ee1a77736db059c9ee95ea075
4137f4828a6a7c48aa1b161cecb82e1e0880aa16 22-Nov-2013 Jeff Hao <jeffhao@google.com> Make verifier log hard failures by default.

Previously required verbose verifier logging to see reasons for hard failures.

Change-Id: I2d05dfec95aeb48e8e1d9d3e4386916ab90071a4
c255e9723c4ac6eff7778ade21296bb5f11ea7bf 19-Nov-2013 Vladimir Marko <vmarko@google.com> Avoid unnecessary copy of dex_gc_map.

Change-Id: I8a7209d92aeee853f6a4e9e9bb0e094c5acd5e05
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
d60f3eee1866d950c0f0bfa6466955538ae81feb 04-Nov-2013 Jeff Hao <jeffhao@google.com> Verifier uses exception type instead of conflict if unresolved.

Fixes OneMedical app installation issues.

Bug: 11335470
Change-Id: I10ef8c84ef5bf5587283413b8cea89202407fe2b
(cherry picked from commit c26a56cb596c3c8efd519c4014fc2ebb3e48b221)
c26a56cb596c3c8efd519c4014fc2ebb3e48b221 04-Nov-2013 Jeff Hao <jeffhao@google.com> Verifier uses exception type instead of conflict if unresolved.

Fixes OneMedical app installation issues.

Bug: 11335470
Change-Id: I10ef8c84ef5bf5587283413b8cea89202407fe2b
dfb325e0ddd746cd8f7c2e3723b3a573eb7cc111 30-Oct-2013 Ian Rogers <irogers@google.com> Don't use UTF16 length as length for MUTF8.

Bug 11367555.

Change-Id: Ia0b07072a1a49d435c3b71ed9a668b316b7ff5d8
8249b425ba81d804c222c746e31bfcac9516e759 29-Oct-2013 Sebastien Hertz <shertz@google.com> Avoid verifier crash for quickened invoke on null.

When verifying an invoke-virtual-quick on a "null" instance, we can't infer the
class of the method being invoked. This CL handles this case and avoid a crash
due to a failed check in RegType::GetClass.

Also revert changes made to test 082-inline-execute since it succeeds with this
CL now.

Bug: 11427954
Change-Id: I4b2c1deaa43b144684539acea471543716f36fb3
a9a8254c920ce8e22210abfc16c9842ce0aea28f 04-Oct-2013 Ian Rogers <irogers@google.com> Improve quick codegen for aput-object.

1) don't type check known null.
2) if we know types in verify don't check at runtime.
3) if we're runtime checking then move all the code out-of-line.

Also, don't set up a callee-save frame for check-cast, do an instance-of test
then throw an exception if that fails.
Tidy quick entry point of Ldivmod to Lmod which it is on x86 and mips.
Fix monitor-enter/exit NPE for MIPS.
Fix benign bug in mirror::Class::CannotBeAssignedFromOtherTypes, a byte[]
cannot be assigned to from other types.

Change-Id: I9cb3859ec70cca71ed79331ec8df5bec969d6745
a6b22c5be364a4ea926bfd2d0ea6169b22bdd10b 04-Oct-2013 Jeff Hao <jeffhao@google.com> Verifier allows arguments of integral types to be interchangeable.

This fixes a bug where code was passing an int into a method with a
byte argument. The RI allows this, but the verifier was rejecting it.

Bug: 11033423
Change-Id: I2a6af3bbbc6e9288fc000f711ae1337ab5786d1a
d91d6d6a80748f277fd938a412211e5af28913b1 26-Sep-2013 Ian Rogers <irogers@google.com> Introduce Signature type to avoid string comparisons.

Method resolution currently creates strings to then compare with strings formed
from methods in other dex files. The temporary strings are purely created for
the sake of comparisons. This change creates a new Signature type that
represents a method signature but not as a string. This type supports
comparisons and so can be used when searching for methods in resolution.

With this change malloc is no longer the hottest method during dex2oat (now its
memset) and allocations during verification have been reduced. The verifier is
commonly what is populating the dex cache for methods and fields not declared
in the dex file itself.

Change-Id: I5ef0542823fbcae868aaa4a2457e8da7df0e9dae
d0fbd85a82a266c21d6b72c61d6dc098ec362de7 25-Sep-2013 Ian Rogers <irogers@google.com> Reduce memory allocation in verifier.

Remove the use of a map PcToRegisterLineTable for efficiency (matches Dalvik).
Place the register line register values inside the RegisterLine, saves a
secondary allocation and indirection.
Avoid the use of a deque in RegisterLine to avoid an allocation.
Simplify the SirtRef destructor in non-debug builds.
Saves >100ms from the two threaded compile time of ThinkFree on host.

Change-Id: I2dacba61dbaf284ca02d4c194413e1da221dcb76
fc0e94bed3f88ed7e50854fd8dfaf5dcb345250f 24-Sep-2013 Ian Rogers <irogers@google.com> StringPiece clean up.

Profile guided clean up.
Try to avoid creating StringPieces with the contents of a dex file where
the length is known.
Try to avoid RegTypeCache::FromDescriptor when there's a class available.
Make ConstantType::ConstantValue inlinable.
Saving of about 50ms from a 2 threaded ThinkFree compile on host.

Change-Id: I47a12c3c76f46e2c9805be1c3a3e3870fe1f5d85
deb43702e611d6c75b459ea352a00f5d98fc0aa9 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

(cherry picked from commit a3faaf4bece7f42529c013fe87bd41de59798656)

Change-Id: I161bfdbfa116890ffa9e7a593c756229bd939eb4
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
ee39a10e45a6a0880e8b829525c40d6055818560 19-Sep-2013 Ian Rogers <irogers@google.com> Use class def index from java.lang.Class.

Bug: 10244719
This removes the computation of the dex file index, when necessary this is
computed by searching the dex file. Its only necessary in
dalvik.system.DexFile.defineClassNative and DexFile::FindInClassPath, the
latter not showing up significantly in profiling with this change.

(cherry-picked from 8b2c0b9abc3f520495f4387ea040132ba85cae69)
Change-Id: I20c73a3b17d86286428ab0fd21bc13f51f36c85c
8b2c0b9abc3f520495f4387ea040132ba85cae69 19-Sep-2013 Ian Rogers <irogers@google.com> Use class def index from java.lang.Class.

Bug: 10244719
Depends on:
https://googleplex-android-review.git.corp.google.com/362363
This removes the computation of the dex file index, when necessary this is
computed by searching the dex file. Its only necessary in
dalvik.system.DexFile.defineClassNative and DexFile::FindInClassPath, the
latter not showing up significantly in profiling with this change.

Change-Id: I20c73a3b17d86286428ab0fd21bc13f51f36c85c
dd3c27eeb8286ab53d8a2f1aec76a7a919ba353a 05-Sep-2013 Jeff Hao <jeffhao@google.com> Fix verifier upcasting type after instance_of.

The verifier automatically changed the type of a register to be
the checked type in an instance_of instruction, even if the
checked type was the register type's superclass. This would loosen
the type information of the register and cause problems later.

Bug: 10614872

(cherry picked from commit c642ec8987746a2a44b990bd5354306242d709da)

Change-Id: Ib447557d3582dad6ac01f0e3b4ee497a27a45172
c642ec8987746a2a44b990bd5354306242d709da 05-Sep-2013 Jeff Hao <jeffhao@google.com> Fix verifier upcasting type after instance_of.

The verifier automatically changed the type of a register to be
the checked type in an instance_of instruction, even if the
checked type was the register type's superclass. This would loosen
the type information of the register and cause problems later.

Bug: 10614872

Change-Id: I67aa2c66be754d946e928b8a64431f193539b842
b8a0b94735f188bc739e4c55479c37699006b881 21-Aug-2013 Ian Rogers <irogers@google.com> Switch JNI globals lock to reader-writer.

Also, verifier rejected classes lock. These locks show as contended during
dex2oat, however, they're commonly only read access is required.

Change-Id: If8bb834cc69cd8c26494c87fb7f7b20d4e41cdfd
90af14d2743614e3e1453984b14258a6f145501d 16-Aug-2013 Dragos Sbirlea <dragoss@google.com> Get SEA fibonacci running in interpreter mode.

Android.mk: Added new file to build.
compile_driver.cc: Moved SE_IR usage test in the block
protected by bool compile, which is enabled by
adding a sepatate test in IsCnadidateForCompilation.
class_linker.cc: Added check in NeedsInterpreter to enable SEA_IR.
art_method-inl.h: DIsabled check in SEA_IR mode.
method_verifier.cc: Added check for SEA_IR mode.
method_verifier.h: Chenged IsCandidateForCompilation signature to
allow testing the function name (for SEA_IR selective
compilation).
dot_gen.h: Updated ART file API usage to altest version.
sea_ir/frontend.cc: Passing function symbol name to CompileMethod.
instruction_Nodes.h: Added accessor for method index for
InvokeStatic IR node.
sea.cc: Added additional IR SignatureNode for function calls (extra
Method parameter). Fixed UnnamedConstant constant value.
sea.h: Passing function_name to GenerateLLVM.
type_inference_visitor.cc: Aded type for first (placeholder) method
parameter.

Change-Id: I295858ea0761a3dffb36f35748d8b93d4919d6a9
0f40ac31134d9ae0f059d4c448165599dc8459c1 14-Aug-2013 Ian Rogers <irogers@google.com> Fix races in small mode compiler filters setup

Fixes host tests in small art mode.

Change-Id: I2579f872583f425607f91c1e58df68b05b5098bb
97a03e3cc86002b10889562a6b5b164cd2b99e7e 14-Aug-2013 Ian Rogers <irogers@google.com> Fix small art build.

Change-Id: Idaade55babbab192c87b32c077d2ec01ac9ef0e2
75a43f10f55e2aa550de51e969cc1e60d583b632 14-Aug-2013 Anwar Ghuloum <anwarg@google.com> Clean up logcat spam from compiler and verifier

Moved to VLOG(...), adding verifer tag for VLOG.

Change-Id: Ia9ac8aeaf5aa1f4881e384003e82a66e560c5692
ea46f950e7a51585db293cd7f047de190a482414 30-Jul-2013 Brian Carlstrom <bdc@google.com> Refactor java.lang.reflect implementation

Cherry-picked from commit ed41d5c44299ec5d44b8514f6e17f802f48094d1.

Move to ArtMethod/Field instead of AbstractMethod/Field and have
java.lang.reflect APIs delegate to ArtMethod/ArtField.

Bug: 10014286.

Change-Id: Iafc1d8c5b62562c9af8fb9fd8c5e1d61270536e7
08bf1967611965b65ffd5de1aa603b60e7b2d6a8 12-Aug-2013 Dragos Sbirlea <dragoss@google.com> Work on SMALL_ART and PORTABLE working at the same time.

Change-Id: Iddedf63b6f9d908717a4d30f963e9b81a9604d49
673b68360e9d030b250ed23bf33c33381640a220 31-Jul-2013 Jeff Hao <jeffhao@google.com> Make verifier allow integral types to be put in integral type arrays.

This fixes a problem where the verifier was rejecting when an integer
is put into a byte array. This also more closely matches the RI.

Also fixes various issues with debugging checks caught by cts.

Bug 10097083

Change-Id: Ie816fcdd85d6dc898feffa1e3fea8cfc2c6946ff

Conflicts:
runtime/verifier/method_verifier.cc

(cherry-picked from commit b24b4a7e0c4f9bbea49f9dd95b2600080c8293d9)
f9468a5ad69edbb92f7b0998960383787cf9cbb1 07-Aug-2013 Jeff Hao <jeffhao@google.com> Verifier checks that primitive put array/field type matches insn type.

Change-Id: Idd68a36d26451459e55fc586bbd1e71c51a81be9
(cherry picked from commit a464748006d101407108c3d9eefd865c44cce695)
7644966addc0d7760baffc8897799f019981d74f 01-Aug-2013 Jeff Hao <jeffhao@google.com> Move verification of primitive type puts into helper method.

Change-Id: Ia40d9f85303a52e20ca57acf13a0cfc8a9922024

Conflicts:
runtime/verifier/method_verifier.cc

(cherry-picked from commit fe1f7c84369abbf5a0121557aa0c6c58e9477710)
d678802609ad07ec2f307caecce5fe5a16fedd46 05-Aug-2013 Sebastien Hertz <shertz@google.com> Use reader writer mutex for safe checkcast map.

Use a ReaderWriterMutex to protect MethodVerifier::safecast_map_ like
what's done for MethodVerifier::dex_gc_maps_ and MethodVerifier::devirt_maps_.

Change-Id: Id2ac9c290cc524eb992ea7cabe63766e88753747
(cherry picked from commit b9c37fb5746cc240e86677e56cb0d74d829e3504)
a49bdffd3826ea45b5d8f435b2add160871351bb 31-Jul-2013 Ian Rogers <irogers@google.com> Don't add barriers to clinit methods.

Change-Id: I13e6c008feb8c19e452d6e2f88b2bbbcac997de5
(cherry picked from commit 9fc16eb43fe938f0cddb13638bd7cbc2ea9534a2)
ee17e0aa4d24deb11c1766bfcc6a864519df1c1e 31-Jul-2013 buzbee <buzbee@google.com> Compilation filter

This CL introduces a static compilation filter mechanism intended
to allow us to reduce compilation time and space requirements until
we have a profiling mechanism in place.

It supports 5 modes of filtering:

o interpret-only (compile nothing)
o deferred-compilation (compile only those methods believe to be
compute-intensive)
o space (optimized for space)
o balanced (best return on space investment)
o speed (compile everything)

A future CL will allow the default filtering mode to be set
via system property. For now, you can pass it in via command
line as follows:

dalvikvm -compiler-filter:[interpret-only|defer-compilation|
space|balanced|speed]

or dex2oat --runtime-arg -compiler-filter:[one of the above modes]

Creating a file named art/SMALL_ART will force the filter
default to interpret-only. Later on we'll move this capability
to a persistent system property.

or modify kDefaultCompilerFilter in runtime.h

It also changes the compiler driver to allow the compilers to
decline to compile a method by return NULL.

Change-Id: Ic73411818f8bb845a4a19a05b0395c50902c534f
(cherry picked from commit a024a0686c3b0fea13f362bff70d65981e5febc5)
a024a0686c3b0fea13f362bff70d65981e5febc5 31-Jul-2013 buzbee <buzbee@google.com> Compilation filter

This CL introduces a static compilation filter mechanism intended
to allow us to reduce compilation time and space requirements until
we have a profiling mechanism in place.

It supports 5 modes of filtering:

o interpret-only (compile nothing)
o deferred-compilation (compile only those methods believe to be
compute-intensive)
o space (optimized for space)
o balanced (best return on space investment)
o speed (compile everything)

A future CL will allow the default filtering mode to be set
via system property. For now, you can pass it in via command
line as follows:

dalvikvm -compiler-filter:[interpret-only|defer-compilation|
space|balanced|speed]

or dex2oat --runtime-arg -compiler-filter:[one of the above modes]

Creating a file named art/SMALL_ART will force the filter
default to interpret-only. Later on we'll move this capability
to a persistent system property.

or modify kDefaultCompilerFilter in runtime.h

It also changes the compiler driver to allow the compilers to
decline to compile a method by return NULL.

Change-Id: Ic73411818f8bb845a4a19a05b0395c50902c534f
a464748006d101407108c3d9eefd865c44cce695 07-Aug-2013 Jeff Hao <jeffhao@google.com> Verifier checks that primitive put array/field type matches insn type.

Change-Id: Idd68a36d26451459e55fc586bbd1e71c51a81be9
b9c37fb5746cc240e86677e56cb0d74d829e3504 05-Aug-2013 Sebastien Hertz <shertz@google.com> Use reader writer mutex for safe checkcast map.

Use a ReaderWriterMutex to protect MethodVerifier::safecast_map_ like
what's done for MethodVerifier::dex_gc_maps_ and MethodVerifier::devirt_maps_.

Change-Id: Id2ac9c290cc524eb992ea7cabe63766e88753747
fe1f7c84369abbf5a0121557aa0c6c58e9477710 01-Aug-2013 Jeff Hao <jeffhao@google.com> Move verification of primitive type puts into helper method.

Change-Id: Ia40d9f85303a52e20ca57acf13a0cfc8a9922024
b24b4a7e0c4f9bbea49f9dd95b2600080c8293d9 31-Jul-2013 Jeff Hao <jeffhao@google.com> Make verifier allow integral types to be put in integral type arrays.

This fixes a problem where the verifier was rejecting when an integer
is put into a byte array. This also more closely matches the RI.

Also fixes various issues with debugging checks caught by cts.

Bug 10097083

Change-Id: Ie816fcdd85d6dc898feffa1e3fea8cfc2c6946ff
834b394ee759ed31c5371d8093d7cd8cd90014a8 31-Jul-2013 Brian Carlstrom <bdc@google.com> Merge remote-tracking branch 'goog/dalvik-dev' into merge-art-to-dalvik-dev

Change-Id: I323e9e8c29c3e39d50d9aba93121b26266c52a46
9fc16eb43fe938f0cddb13638bd7cbc2ea9534a2 31-Jul-2013 Ian Rogers <irogers@google.com> Don't add barriers to clinit methods.

Change-Id: I13e6c008feb8c19e452d6e2f88b2bbbcac997de5
2724776ad521eebb1c7f0e4be56d6e6ab4764f86 28-Jul-2013 buzbee <buzbee@google.com> Support inline dex data, take 2

Allow switch and array data blocks to appear interspersed
with Dex code (rather than just at the end).

Bug 10040419

Change-Id: Ia2850070f0e702381eb402f604d675e5a0b101de
c449aa8151bf81d93d22ff24677ccf09a6da218e 29-Jul-2013 Ian Rogers <irogers@google.com> Clear exception if catch block doesn't have move-exception.

Bug: 10040419

Change-Id: Icc7a55cb3cdfbc3efd2b161bbe22b3e5007de35f
46a1270fad27d81904ed60d0df56761356af500d 27-Jul-2013 Brian Carlstrom <bdc@google.com> Revert "Support inline dex data"

This reverts commit 728328a441c6d3172283f3e44d120550997b5887.
728328a441c6d3172283f3e44d120550997b5887 27-Jul-2013 buzbee <buzbee@google.com> Support inline dex data

Dx always places switch table and array data following executable
code. However, embedding data inline appears to be legal - and
the Garmin Connect app does this. Unknown is what tool generated
the odd dex code. This CL reworks dex parsing to support inline data.

Further, a verification check to require a move-exception at
the beginning of catch regions is disabled. Dalvik's verifier appears
to only require that if a move-exception exists, it must be at
the beginning of the catch. If there is value to the check
requiring a move-exception, we'll need to enable it based on a
future dex version.

Change-Id: I80c78544993acb999f7c62d32479c3c8455b56cb
7934ac288acfb2552bb0b06ec1f61e5820d924a4 26-Jul-2013 Brian Carlstrom <bdc@google.com> Fix cpplint whitespace/comments issues

Change-Id: Iae286862c85fb8fd8901eae1204cd6d271d69496
93c3396f8b33539489763ebdfafcedb4127009d9 26-Jul-2013 Brian Carlstrom <bdc@google.com> Fix style issues in MethodVerifier

Change-Id: I3aa5929311863e40840acebc5efafecb949fdea5
4d4adb1dae07bb7421e863732ab789413a3b43f0 24-Jul-2013 Sebastien Hertz <shertz@google.com> Prevent verifier from creating unused compilation data.

The verifier used to create data which may be unused like GC map. This is the
case for non-compiled method (which are interpreted). This CL aims to optimize
this.

Here are the changes:
- Move compilation selection to MethodVerifier::IsCandidateForCompilation.
- Compiler and verifier use this method to know if a method must be compiled.
- Only create compilation data while compiling using Runtime::IsCompiler.
- Do not create internal structures concerning GC map, ... in Runtime::Init and
Runtime::Shutdown when we are not compiling.
- Checks we are compiling when accessing these structures.
- Add missing destruction of MethodVerifier::safecast_map_lock_ and
MethodVerifier::safecast_map_ in Runtime::Shutdown.
- Call Runtime::Shutdown just before Runtime instance is destroyed to avoid a
crash.
- Add missing "GUARDED_BY" macro for MethodVerifier::rejected_classes_ field.
- Add "has_check_casts" to avoid the safecast pass if there is no check-cast
instruction.
- Add "has_virtual_or_interface_invokes" to avoid the devirtualization pass if
there is no invoke-virtual/range nor invoke-interface/range instructions.

Bug: 9987437
Change-Id: I418ee99f63e4203409cf5b7d2c2295b22fcf24c1
b8c7859f21f5ae4c9b90f2ef2effc51967299737 26-Jul-2013 Ian Rogers <irogers@google.com> Revert "Revert "Remove non-live vregs from GC map on return.""

This reverts commit 73dda0bc2adcd6a3a7d75f663a3559f8b527d485.
It also fixes the problematic line in the ReferenceMap test.

Change-Id: Ic3b62db7c040853a5ddfed589f6e0acff25d82b7
73dda0bc2adcd6a3a7d75f663a3559f8b527d485 25-Jul-2013 Ian Rogers <irogers@google.com> Revert "Remove non-live vregs from GC map on return."

This change causes a test regression on the oat tests, back out until the change also updates the test for the new GC map values.

This reverts commit c0d120a0b1389f1f402d13e20b9e4abd9ab7cd95.

Change-Id: I48bc951b1dad9a9ae83cccf0b5b68ad60fac052c
c0d120a0b1389f1f402d13e20b9e4abd9ab7cd95 24-Jul-2013 Ian Rogers <irogers@google.com> Remove non-live vregs from GC map on return.

Mark registers going into a return as conflict/bottom so that they aren't
considered for GC maps and deoptimization.

Bug 4191345.

Change-Id: I8af6c21824b6459788852be5417849e8ef999bcb
6d376aec61fc57b4caa840c1ae309e4f4f589792 24-Jul-2013 Ian Rogers <irogers@google.com> Tidy ws and document verifier instruction flags.

Change-Id: I6c58a76f3373b17fc001480c4db069fc942fce3a
02c8cc6d1312a2b55533f02f6369dc7c94672f90 19-Jul-2013 Brian Carlstrom <bdc@google.com> Fixing cpplint whitespace/blank_line, whitespace/end_of_line, whitespace/labels, whitespace/semicolon issues

Change-Id: Ide4f8ea608338b3fed528de7582cfeb2011997b6
1895ea386ca78573302483f589ebabd8ce1480e7 18-Jul-2013 Brian Carlstrom <bdc@google.com> Fix cpplint readability/fn_size issues

Change-Id: I1efdb07a948a2af49db1a9d21ccab16dacc03a54
df62950e7a32031b82360c407d46a37b94188fbb 18-Jul-2013 Brian Carlstrom <bdc@google.com> Fix cpplint whitespace/parens issues

Change-Id: Ifc678d59a8bed24ffddde5a0e543620b17b0aba9
0cd7ec2dcd8d7ba30bf3ca420b40dac52849876c 18-Jul-2013 Brian Carlstrom <bdc@google.com> Fix cpplint whitespace/blank_line issues

Change-Id: Ice937e95e23dd622c17054551d4ae4cebd0ef8a2
7940e44f4517de5e2634a7e07d58d0fb26160513 12-Jul-2013 Brian Carlstrom <bdc@google.com> Create separate Android.mk for main build targets

The runtime, compiler, dex2oat, and oatdump now are in seperate trees
to prevent dependency creep. They can now be individually built
without rebuilding the rest of the art projects. dalvikvm and jdwpspy
were already this way. Builds in the art directory should behave as
before, building everything including tests.

Change-Id: Ic6b1151e5ed0f823c3dd301afd2b13eb2d8feb81