History log of /art/runtime/check_jni.cc
Revision Date Author Comments
69944c96d75225c7d7e400296816ad228aacb158 17-Apr-2018 Andreas Gampe <agampe@google.com> ART: Properly check for attached thread in CheckJNI

The previous implementation checked too late, as the required
ScopedObjectAccess would have already aborted. Instead, preface
all necessary functions with an explicit check.

Performance should be almost neutral, as the test is only moved
earlier, but not duplicated.

(cherry picked from commit fb8f75c160f5f38efcb85988c98033650d5649bc)

Bug: 78135453
Test: m test-art-host-gtest-jni_internal_test
Merged-In: I7b98744e9a3895e84ba9e2661975ce29722076c3
Change-Id: I7b98744e9a3895e84ba9e2661975ce29722076c3
b2ec9f5c128673c43f776cbe12c8eeb0a6884ebb 21-Feb-2018 David Sehr <sehr@google.com> Remove duplication, split tests

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

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

Change-Id: Ie734672c4bca2c647d8016291f910b5608674545
9e937be874b4f76c50a05ec8f9d8e68ef2f9ae37 16-Feb-2018 Ian Rogers <irogers@google.com> Add check JNI tests for byte and 16-bit primitives.

Make boolean checking check 32-bit values in case of truncation.
Add unit test for out-of-bound primitive call values.
Make reflection's ArgArray anonymous as per more recent cppstyle and
address other minor style issues.
Test: mma -j32 test-art-host; boot (eng) emulator and check logcat is clean

Bug: 73656264
Change-Id: If7947e24ec3fe3303c1d3d0545605e82f651de25
ac4d45ae2999c0dbecbc31da3edbbc61d6ac6d61 15-Feb-2018 Ian Rogers <irogers@google.com> Reduce the scope of CheckJNI.

CheckJNI wasn't anonymous so that it could friend JniEnvExt. Add
accessors for the CheckJNI parts of JniEnvExt and make CheckJNI and
related classes anonymous. This is equivalent to making functions
within the scope of a file static and preferred now by cppstyle.
Make the force_copy_ field that could be const, const.
Test: m -j32; booted emulator.

Change-Id: I7e740d3b9bf4a3fedd30c4f44a852af67898d2f0
9e734c7ab4599d7747a05db0dc73c7b668cb6683 05-Jan-2018 David Sehr <sehr@google.com> Create dex subdirectory

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

Bug: 71361973
Test: make -j 50 test-art-host
Change-Id: I59e984ed660b93e0776556308be3d653722f5223
55256cb60e11d4fac71affb4b9760a2931a3598d 22-Dec-2017 Ian Rogers <irogers@google.com> Extensions to check JNI.

Ensure critical lock isn't held when returning from a down-call.
Log a warning if the critical lock is held for a significant period of
time.
Refactor JNIEnvExt to be a class rather than a struct.

Test: mma test-art-host

Change-Id: I4d149cb04d3a7308a22b92b196e51e2f1ae17ede
e4033fa9647774382d303f3b20e7139998565035 13-Dec-2017 Alex Light <allight@google.com> Loosen check:jni around GetStatic[...]Field

-Xcheck:jni was requiring that the jclass being passed to
GetStatic[...]Field was the exact same class as the jfieldID's
declaring class. This was stricter than is really needed and causes
some issues when dealing with fields where the declaring class cannot
be easily determined.

Bug: 70532839
Test: ./test.py --host -j50
Change-Id: I0987de09af956ed9a8dde37c50606604fdd94b87
57943810cfc789da890d73621741729da5feaaf8 07-Dec-2017 Andreas Gampe <agampe@google.com> ART: Replace base/logging with android-base/logging

Replace wherever possible. ART's base/logging is now mainly VLOG
and initialization code that is unnecessary to pull in and makes
changes to verbose logging more painful than they have to be.

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

Let clang-format reorder the header includes.

Derived with:

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

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

Test: mmma art
Change-Id: Ia963a8ce3ce5f96b5e78acd587e26908c7a70d02
46ee31b67d7ee1bd085fbc240502053caa3cf8fa 14-Dec-2016 Andreas Gampe <agampe@google.com> ART: Move to libbase StringPrintf

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

Test: m test-art-host
Change-Id: I564038d5868595ac3bb88d641af1000cea940e5a
08883debd927d18c9ecf66683a2a11aa98165656 08-Nov-2016 Andreas Gampe <agampe@google.com> ART: Refactor jfieldID handling

ArtField objects have been native since Marshmallow.
Remove the dependency on being runnable. Refactor the
code into the jni_internal header.

Test: m test-art-host
Change-Id: I46708c70f9b4b566d7e26e4c5ffc3f0cbadc43fa
13b27842e88ccf1a42807c92daeb108e867dc4cd 08-Nov-2016 Andreas Gampe <agampe@google.com> ART: Refactor jmethodID handling

ArtMethod objects have been native since Marshmallow.
Remove the dependency on being runnable. Refactor the
code into the jni_internal header.

Test: m test-art-host
Change-Id: I1385fcd4c08981491701da55a87036b447aa2fc2
dc061d038e4e48fe2a967fd4a9c200d112df5698 24-Oct-2016 Andreas Gampe <agampe@google.com> ART: Clean up IndirectReferenceTable

Introduce constants and move some functions into the
IndirectReferenceTable class.

Slightly change IndirectRef encoding to be more obvious (and slighly
more optimized when decoding).

Bug: 32125344
Test: m test-art-host
Change-Id: I05819eccb733b611de582fb8d7151f1a110c305a
709b070044354d9f47641f273edacaeeb0240ab7 13-Oct-2016 David Sehr <sehr@google.com> Remove mirror:: and ArtMethod deps in utils.{h,cc}

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

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

Bug: 22322814
Test: test-art-host
Change-Id: I21adee3614aa697aa580cd1b86b72d9206e1cb24
9d156d500801accee919b6d51e22d6ddcdcd4a05 07-Oct-2016 Mathieu Chartier <mathieuc@google.com> Move Heap parameters to ObjPtr

Deleted some unused object dumping code.

Test: test-art-host

Bug: 31113334

Change-Id: I747220caafe6679591fd4b361d7f50383a046164
c4f3925490a73da8dc74884a1deb965d4ecaf14e 06-Oct-2016 Mathieu Chartier <mathieuc@google.com> Move remaining jobject related functions to use ObjPtr

Also added ObjPtr::DownCast.

Bug: 31113334

Test: test-art-host

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

Done to prevent ambiguity with ScopedObjectAccess::Decode.

Bug: 31113334

Test: test-art-host
Change-Id: I07a2497cc9cf66386311798933547471987fc316
3398c7874e002beaa6c2b2fadf183e7d1ddad23a 30-Sep-2016 Mathieu Chartier <mathieuc@google.com> Move ArtField to ObjPtr

Added EXPECT_OBJ_PTR_EQ and variants to gtests.

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

ObjPtr Decode call sites: 186 -> 181.

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

Bug: 31113334

Test: test-art-host CC baker

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

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

Changed AddLocalReference / Decode to use ObjPtr.

Changed libartbenchmark to be debug to avoid linkage errors.

Bug: 31113334

Test: test-art-host

Change-Id: I4d2e160483a29d21e1e0e440585ed328b9811483
3fec9ac0d5af1358d216eb2fdc2000ec0205f3f0 13-Sep-2016 Andreas Gampe <agampe@google.com> ART: Use libbase logging

Move most of our logging infrastructure over to system/core/base.
Retain VLOG.

Using unified Android infrastructure has two main advantages. First,
it reduces the complexity/maintenance burden in ART. Second, it
allows to detach logging for the cases where we do not want or need
a runtime, e.g., dexdump, the disassembler, etc. As a part of the
latter, libbase is also supported for all hosts (including Windows).

From a developer viewpoint, there are minor behavior changes for the
LOG statements (see above), but otherwise usage is the same. Explicit
severity enum items are in the android::base namespace now.

Bug: 31338270
Test: m test-art-host
Change-Id: I5abcb2f45f5b03d49951874c48544f72a283a91b
bdf7f1c3ab65ccb70f62db5ab31dba060632d458 31-Aug-2016 Andreas Gampe <agampe@google.com> ART: SHARED_REQUIRES to REQUIRES_SHARED

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

Test: m
Test: m test-art-host
Change-Id: Ia8986b5dfd926ba772bf00b0a35eaf83596d8518
35e827ade289f4c2985eb419b43a0d1776469738 11-May-2016 Daniel Erat <derat@google.com> Fix JNIEnv-on-wrong-thread abort message.

Update an incorrect abort message that claimed that thread A
was using the JNIEnv from thread A (when the JNIEnv was in
fact from another thread). Now, the message is e.g.

JNI DETECTED ERROR IN APPLICATION: thread
Thread[1,tid=628,Native,Thread*=0xb038b400,peer=0x75efc1f0,"main"]
using JNIEnv* from thread
Thread[6,tid=640,Runnable,Thread*=0xaa890800,peer=0x12c00ca0,"Binder:628_1"]

Change-Id: I877a78c47e88d1e8a28bade8ea40be6bed58439f
fba39972d99701c80bf3beb7451aca508d67593c 11-May-2016 Chih-Hung Hsieh <chh@google.com> Fix misc-macro-parentheses warnings.

* Add parentheses to fix warnings.
* Use NOLINT to suppress wrong clang-tidy warnings.

Bug: 28705665
Change-Id: Icc8bc9b59583dee0ea17ab83e0ff0383b8599c3e
5f4a09a54eed55de89e194780214a2acfd2cb431 28-Sep-2015 Andreas Gampe <agampe@google.com> ART: Add CheckJNI lock checking

JNI MonitorEnter and MonitorExit have similar rules to structured
locking. Count locks in CheckJNI mode.

Bug: 23502994
Change-Id: Ie3f53d3aa669a6bd0c7153c50c168116b43764d9
48ffe0653c51c0785c8bd260fef486922ba00e4e 20-Aug-2015 Alex Light <allight@google.com> Made CheckJNI check varargs when possible

Several JNI functions such as NewObject and Call*Method take a variable
number of arguments. This patch will make CheckJNI do (limited) dynamic
validation of these arguments. Currently it is limited to checking that
objects are valid and that no value types have illegal values.

Bug: 20344596
Change-Id: I1f81d2bdd80215e0007fc636bac27d5bcc2dba96
3887c468d731420e929e6ad3acf190d5431e94fc 12-Aug-2015 Roland Levillain <rpl@google.com> Remove unnecessary `explicit` qualifiers on constructors.

Change-Id: Id12e392ad50f66a6e2251a68662b7959315dc567
ef4afe9dc2e13500c3057aaf7f697e654b0b2782 28-Jul-2015 Andreas Gampe <agampe@google.com> ART: Print out hex for NewStringUTF failure

Print out the input data as a hex stream in case of a NewStringUTF
input format failure.

Bug: 22773761
Change-Id: I99a275bebb89564b2d71f297c7f5b9543cf4312d
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
068361a555f7d8cfd5602abb1faf087aa88bfa49 14-Jul-2015 tony.ys_liu <tony.ys_liu@htc.com> Refine the canary pattern in RedZone

Change-Id: I5b63c8be6488c0ac29e1722c532cdbaab1d65086
71e46c1a2e1a8c2ef87b6137e8503dd12e18bb8d 25-Jun-2015 Mathieu Chartier <mathieuc@google.com> Fix force copy

We now correctly pass the returned pointer back onto the release functions.

Bug: 22056708
Change-Id: I1a7300d3a4522a3c81b432ec742ae1c0bd00b51e

(cherry picked from commit b735bd9c04aa291d0a1bdc2c0a094a1a75ad0596)
b735bd9c04aa291d0a1bdc2c0a094a1a75ad0596 25-Jun-2015 Mathieu Chartier <mathieuc@google.com> Fix force copy

We now correctly pass the returned pointer back onto the release functions.

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

Optimizing + quick tests are passing, devices boot.

TODO: Test and fix bugs in mips64.

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

Bug: 19264997

(cherry picked from commit e401d146407d61eeb99f8d6176b2ac13c4df1e33)

Change-Id: I622469a0cfa0e7082a2119f3d6a9491eb61e3f3d

Fix some ArtMethod related bugs

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

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

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

TODO: Fix JDWP tests.

Bug: 19264997

Change-Id: I7c55f69c61d1b45351fd0dc7185ffe5efad82bd3

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

Bug: 19264997
Change-Id: Ief45cdd4bae5a43fc8bfdfa7cf744e2c57529457

Fix JDWP tests after ArtMethod change

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

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

Bug: 19264997
Change-Id: I363e293796848c3ec491c963813f62d868da44d2

Fix accidental IMT and root marking regression

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

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

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

Bug: 19264997
Change-Id: I4333e80a8268c2ed1284f87f25b9f113d4f2c7e0

Fix bogus image test assert

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

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

Bug: 19264997
Change-Id: I7359f1f73ae3df60c5147245935a24431c04808a

[MIPS64] Fix art_quick_invoke_stub argument offsets.

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

This fixes mips64 boot.

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

Optimizing + quick tests are passing, devices boot.

TODO: Test and fix bugs in mips64.

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

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

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

Change-Id: I6efba5fb6e03eb5d0a300fddb2a75bf8e2f175cb
c50358b8947ae4367132dae5987d2e9738e90464 17-Apr-2015 Christopher Ferris <cferris@google.com> Fix access past end of args array.

Bug: 20340831
Change-Id: Ibc0995e28e74c65d81f001e5b4d1e4780ff19686
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
14691c5e786e8c2c5734f687e4c96217340771be 05-Mar-2015 Nicolas Geoffray <ngeoffray@google.com> Compute the right catch location for the debugger.

Also remove tls ThrowLocation, it is not needed anymore.

Change-Id: I78fddf09ce968ca475e39c17fa76d699c589c8d9
def194e182ce703077e20bb59025998039fadb75 20-Feb-2015 Andreas Gampe <agampe@google.com> ART: Do not read from JavaVMExt* after DestroyJavaVM

DestroyJavaVM deletes the structure.

Change-Id: Ida5fb98a47b1ebf0df7d54506e2fec8958fc105b
a5afcfc73141e5e378d79a326d02c5c2039fb025 29-Jan-2015 Narayan Kamath <narayan@google.com> Be more lenient with 4 byte UTF-8 sequences.

Accept 4 byte sequences and convert them into surrogate
pairs instead of expecting 2 separate 3 byte sequences
each encoding one half of a surrogate pair.

Note that in addition to supporting 4 byte sequences in
strings from JNI, we also tolerate them in dex files. This
is mainly for consistency, and there's no need to claim any
sort of official support.

bug: 18848397
bug: https://code.google.com/p/android/issues/detail?id=81341
Change-Id: Ibc98d29e59d98803e640f2489ea4c56912a59b29
08f1f50d6c2e8f247b8f5f19711d75a792851c7a 03-Dec-2014 Ian Rogers <irogers@google.com> Remove FieldHelper.

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

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

Change-Id: I5b433e722d2f75baacfacae4d32aef4a828bfe1b
c7dd295a4e0cc1d15c0c96088e55a85389bade74 22-Oct-2014 Ian Rogers <irogers@google.com> Tidy up logging.

Move gVerboseMethods to CompilerOptions. Now "--verbose-methods=" option to
dex2oat rather than runtime argument "-verbose-methods:".
Move ToStr and Dumpable out of logging.h, move LogMessageData into logging.cc
except for a forward declaration.
Remove ConstDumpable as Dump methods are all const (and make this so if not
currently true).
Make LogSeverity an enum and improve compile time assertions and type checking.
Remove log_severity.h that's only used in logging.h.
With system headers gone from logging.h, go add to .cc files missing system
header includes.
Also, make operator new in ValueObject private for compile time instantiation
checking.

Change-Id: I3228f614500ccc9b14b49c72b9821c8b0db3d641
fc787ecd91127b2c8458afd94e5148e2ae51a1f5 10-Oct-2014 Ian Rogers <irogers@google.com> Enable -Wimplicit-fallthrough.

Falling through switch cases on a clang build must now annotate the fallthrough
with the FALLTHROUGH_INTENDED macro.
Bug: 17731372

Change-Id: I836451cd5f96b01d1ababdbf9eef677fe8fa8324
51be0a7158b62d6da6a3ccb6fce9f7f677ec3ce3 24-Sep-2014 Marcus Oakland <marcus.oakland@arm.com> Fix CallStaticVoidMethodA for testEverything

The android.jni.cts.JniCTest#testEverything and
android.jni.cts.JniCppTest#testEverything CTS test were failing
because of a SIGABRT caused by a call to ScopedCheck::AbortF
from ScopedCheck::CheckInstance when CheckJNI::CallStaticVoidMethodA
was invoked. This was due to the CheckJNI::CallMethodA method being
called with the jobject obj parameter being passed jclass c, and the
jclass c parameter being passed nullptr. This problem was rectified
by swapping these two parameters, and the CTS tests then passed.

Change-Id: I025cfd85ab55eb3eadb287b56846d9d42f5b7e5e
Signed-off-by: Marcus Oakland <marcus.oakland@arm.com>
c0542af3e2170143ba40d89136e284997e16bf64 04-Sep-2014 Ian Rogers <irogers@google.com> Remove abuse of mirror::Object* to reference special values.

Remove kInvalidIndirectRefObject, kClearedJniWeakGlobal and
ObjectRegistry::kInvalidObject. Handle error conditions by passing in or
returning an error value.
GetObjectRefType is simplified to be faster and not return invalid references
that are not expected according to the spec. Adjust check JNI and
jni_internal_test appropriately.
Fix cases in the debugger/JDWP of out arguments being passed by reference.
Bug: 17376993

Change-Id: I3ce8a28c01827e163f4dc288449959464da788b1
167350d9c781c5e3893714bb26ab5cb1c4abf6b4 20-Aug-2014 Mathieu Chartier <mathieuc@google.com> Add null check to CheckVirtualMethod

There was a runtime SIGSEGV that should have been a check jni
failure.

Also added regression test.

Bug: 16320699
Change-Id: If6c8e73959cefb24e4703f1562cdddb343d86630
a1e78fa763c9883af1c01a6c10fac5f5aa2f9659 20-Aug-2014 Mathieu Chartier <mathieuc@google.com> Add null check to CheckVirtualMethod

There was a runtime SIGSEGV that should have been a check jni
failure.

Also added regression test.

Bug: 16320699

(cherry picked from commit 167350d9c781c5e3893714bb26ab5cb1c4abf6b4)

Change-Id: I7edea6af6517f1e5628678e824b8307daf491418
68d8b42ddec39ec0174162d90d4abaa004d1983e 17-Jul-2014 Ian Rogers <irogers@google.com> Wire up check JNI force copy mode.

Increase check JNI checks.
Break apart jni_internal.h in to jni_env_ext.h and java_vm_ext.h.
Fix the abuse of ScopedObjectAccess/annotalysis by ScopedCheck in the case
of VM routines.
Make class loader override and shared library class loader JNI global
references rather than mirror pointers.
Clean-ups to native bridge.

Change-Id: If7c6110b5aade7a402bfb67534af86a7b2cdeb55
b76cac637691c29daa9c44e493b5bc26346ed116 23-Jul-2014 Mathieu Chartier <mathieuc@google.com> Revert "Revert "Disable adding main and non moving spaces to immune region in GSS""

This reverts commit f85c2fb317399ab540854cd7551ac47690366543.
f85c2fb317399ab540854cd7551ac47690366543 22-Jul-2014 Mathieu Chartier <mathieuc@google.com> Revert "Disable adding main and non moving spaces to immune region in GSS"

Bug: 16399257

This reverts commit be0562fb14e6754ee932b8d9c97e2a6df3a91119.

Change-Id: I29e07a8fa1e972990e5bf1ddf8c9a3538ea5f9cf
be0562fb14e6754ee932b8d9c97e2a6df3a91119 14-Jul-2014 Mathieu Chartier <mathieuc@google.com> Disable adding main and non moving spaces to immune region in GSS

Disabled adding the main and non moving space to the immune region.
This will enable us to recycle bump pointer spaces for malloc space
-> malloc space compaction as well as collector transitions.

Also added logic for falling back to the non moving space, we may
copy objects there.

Refactored mod union table logic into MarkReachableObjects.

No measurable performance benefit or regression.

Bug: 14059466
Bug: 16291259

(cherry picked from commit 4c13a3ff475f206c4d0a86ee2595c45392fd942f)

Change-Id: I858b4fbddca888e164052ad247565a0bdbea68b5
4c13a3ff475f206c4d0a86ee2595c45392fd942f 14-Jul-2014 Mathieu Chartier <mathieuc@google.com> Disable adding main and non moving spaces to immune region in GSS

Disabled adding the main and non moving space to the immune region.
This will enable us to recycle bump pointer spaces for malloc space
-> malloc space compaction as well as collector transitions.

Also added logic for falling back to the non moving space, we may
copy objects there.

Refactored mod union table logic into MarkReachableObjects.

No measurable performance benefit or regression.

Bug: 14059466
Bug: 16291259

Change-Id: If663d9fdbde943b988173b7f6ac844e5f78a0327
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
45d26c86b00580593067ca42091ad66cf7dc4f7c 25-Jun-2014 Brian Carlstrom <bdc@google.com> Treat larger than jint capacity in NewDirectByteBuffer as an error

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

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

Bug: 13077697

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

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

Bug: 13077697

Change-Id: I7de9ded2893b5568d43e4daa86fd135bf5508b72
2d10b206f9d0b97396b7dadb9a6415cd39efd341 13-May-2014 Ian Rogers <irogers@google.com> Ensure JNI primitive array type is appropriate.

Check the primitive array type for GetPrimitiveArray, ReleasePrimitiveArray,
GetPrimitiveArrayRegion and SetPrimitiveArrayRegion matches the given array
type. Check the GetPrimitiveArrayCritical and ReleasePrimitiveArrayCritical are
given a primitive array.
Add unit tests that null parameters lead to fatal errors, not crashes. Fix
issues where CheckJNI assumed non-null arguments.
Tidy testing code via the use of nullptr. Add a few extra checks.
Ensure arrays of void are not able to be created, use RI compatible
NoClassDefError.

Bug: 14817823

Change-Id: I9903bcd800d0da1988ced07f61fb97b783c5deab
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
b0fa5dc7769c1e054032f39de0a3f6d6dd06f8cf 29-Apr-2014 Ian Rogers <irogers@google.com> Force inlining on trivial accessors.

Make volatility for GetFieldObject a template parameter.
Move some trivial mirror::String routines to a -inl.h.

Bug: 14285442

Change-Id: Ie23b11d4f18cb15a62c3bbb42837a8aaf6b68f92
987560fee798e48fb725c44b796d8ca7a5872ad6 22-Apr-2014 Ian Rogers <irogers@google.com> Remove support for app JNI workarounds.

Change-Id: I4396df7e93fcace4b5b19c2c387e5c30089182a6
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
b73f31fd83151bfe9f73166343fd698fffa4e03b 31-Dec-2013 Narayan Kamath <narayan@google.com> Fix a typo in a comment.

Change-Id: I2579261f9ea2f8f9c64975fe6cb18c3c6102da39
ef809d09cf0d28d999ac69969e4506d8afa4624d 19-Dec-2013 Narayan Kamath <narayan@google.com> JNI: NewDirectByteBuffer should allow 0 length buffers.

This makes the implementation symmetric with direct
buffers allocated from java.

- GetDirectBufferAddress returns the address of the buffer
passed in to NewDirectByteBuffer (and not NULL).
- GetDirectBufferCapaticy returns 0.

bug: https://code.google.com/p/android/issues/detail?id=63055
Change-Id: I55b24623ec4f7670972fed898ea097934c6c0b5f
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
77129ff50fc0234b62684e556d2c0bcb86123e80 18-Oct-2013 Mathieu Chartier <mathieuc@google.com> Remove kNoCopyMagic.

Was needed by jniGetNonMovableArrayElements which is now removed.

Change-Id: Ie71eda5c5c3643c12db07d249597dbb2df41e88e
67fe2b41a6afccf6ab1a58879eae3e0e8f3d6c7a 16-Oct-2013 Brian Carlstrom <bdc@google.com> Fix backwards check in CheckStaticMethod

Bug: 11243757
Change-Id: I559d1163ce72ab7831bd328c621519acb72975e0
bb1c6242c63a7ea31f2980f42c3e3e95c164a790 16-Oct-2013 Brian Carlstrom <bdc@google.com> Fix backwards check in CheckStaticMethod

Bug: 11243757
Change-Id: I559d1163ce72ab7831bd328c621519acb72975e0
a4684052dbe58d36e32d1035c10bae2e2d52a8dd 04-Sep-2013 Elliott Hughes <enh@google.com> [build fix] Remove redundant complexity from JNI aborts.

(cherry picked from commit 8e4d3ed463df1a9f5fdc1e927a6afe6d208558e1)

Change-Id: I375f27efbec35a7d21070b3a5699ab798143a6a2
8e4d3ed463df1a9f5fdc1e927a6afe6d208558e1 04-Sep-2013 Elliott Hughes <enh@google.com> Remove redundant complexity from JNI aborts.

Change-Id: I7aca6c661f0dc868e33fd354d0ed27bf17361b28
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
9b3c3cdb62f7142384e6bf2c0cb6e3a76b16f0e3 13-Aug-2013 Mathieu Chartier <mathieuc@google.com> C++11 support for ART.

We can now use auto, ranged based loops, etc..
This compiles, the phone boots, and the tests pass.

Depends on:
https://googleplex-android-review.googlesource.com/#/c/342487/

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

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

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