History log of /art/runtime/class_linker.cc
Revision Date Author Comments
22e0ce3a73760757e509032a324bbbb9a1a93f5e 09-Oct-2015 Mathieu Chartier <mathieuc@google.com> DO NOT MERGE Add locking to prevent races between setting class methods and marking

There was a race condition between VisitNativeRoots and threads which were
updating the lengths and pointers of the direct or virtual methods of classes.

For example:
The thread doing VisitNativeRoots could see a null pointer with a non 0 length if
another thread had changed the length but not the pointer.

The fix is already in master, do not merge.

Bug: 24270063
Change-Id: Id7280b9507b95703820aedb6c5fee49966dabe27
cb44b11a926696e34b3dc44288e762b4303cc128 24-Jun-2015 Richard Uhler <ruhler@google.com> Do not try to compile resource-only dex files.

This changes behavior in the case where we are asked to load a dex
file that does not exist or has no classes.dex entry.

Previously we would run dex2oat, which would log an error message and
fail. Now we skip running dex2oat, we report the DexOptStatus as
kNoDexOptNeeded, and we do not try to fall back to the missing
original dex files.

Bug: 21722039
Change-Id: I90b1f4165138daac57bb9d7a354319005652c593
bad9c7b7f88689133cae59d9ccae231822a2020c 14-Jun-2015 Mathieu Chartier <mathieuc@google.com> New experimental GC stress mode

Tries to do a GC for every unique call stack (up to 16 frames).
The goal is to catch moving GC bugs and lock violations without being
rediculously slow. Some tests fail on 64 bits, 32 bit host doesn't
work. N5 is booting.

Added runtime -Xgc options: gcstress and nogcstress.

Bug: 21664466

(cherry picked from commit 310008008c90fea246efd00cb99ee7ded97c5209)

Change-Id: Icb8e420f2048e8ee83bcca7937563166a2638f5c
6e80460bdf0aa9bd273d4a4d665d679c651b5f4f 20-Jun-2015 Mathieu Chartier <mathieuc@google.com> Fix another miranda method moving GC bug

Need to copy miranda methods over before we allocate the new vtable
or else we may have stale miranda gc roots.

Bug: 21664466
Change-Id: Ib3e415bb9e7df7abfa18c98fe01f790fa39622dc
a26cb57f46fd3f27a930d9d688fe8670c1f24754 23-Apr-2015 David Srbecky <dsrbecky@google.com> ART stack unwinding fixes for libunwind/gdb/lldb.

dex2oat can already generate unwinding and symbol information which
allows tools to create backtrace of mixed native and Java code.

This is a cherry pick from aosp/master which fixes several issues.
Most notably:
* It enables generation of ELF-64 on 64-bit systems (in dex2oat, C
compilers already produce ELF-64). Libunwind requires ELF-64 on
64-bit systems for backtraces to work.
* It enables loading of ELF files with dlopen. This is required for
libunwind to be able to generate backtrace of current process (i.e.
the process requesting backtrace of itself).
* It adds unit test to test the above (32 vs 64 bit, in-proces vs
out-of-process, application code vs framework code).
* Some other fixes or clean-ups which should not be of much
significance but which are easier to include to make the
important CLs cherry-pick cleanly.

This is squash of the following commits from aosp/master:
7381010 ART: CFI Test
e1bbed2 ART: Blacklist CFI test for non-compiled run-tests
aab9f73 ART: Blacklist CFI test for JIT
4437219 ART: Blacklist CFI test for Heap Poisoning
a3a49fe Switch to using ELF-64 for 64-bit architectures.
297ed22 Write 64-bit address in DWARF if we are on 64-bit architecture.
24981a1 Set correct size of PT_PHDR ELF segment.
1a146bf Link .dynamic to .dynstr
67a0653 Make some parts of ELF more (pointer) aligned.
f50fa82 Enable 64-bit CFI tests.
49e1fab Use dlopen to load oat files.
5dedb80 Add more logging output for dlopen.
aa03870 Find the dlopened file using address rather than file path.
82e73dc Release dummy MemMaps corresponding to dlopen.
5c40961 Test that we can unwind framework code.
020c543 Add more log output to the CFI test.
88da3b0 ART: Fix CFI test wrt/ PIC
a70e5b9 CFI test: kill the other process in native code.
ad5fa8c Support generation of CFI in .debug_frame format.
90688ae Fix build - large frame size of ElfWriterQuick<ElfTypes>::Write.
97dabb7 Fix build breakage in dwarf_test.
388d286 Generate just single ARM mapping symbol.
f898087 Split .oat_patches to multiple sections.
491a7fe Fix build - large frame size of ElfWriterQuick<ElfTypes>::Write (again).
8363c77 Add --generate-debug-info flag and remove the other two flags.
461d72a Generate debug info for core.oat files.

Bug: 21924613
Change-Id: I3f944a08dd2ed1df4d8a807da4fee423fdd35eb7
a3b9d4eda1ef0845f307891f349eaf752750ac16 17-Jun-2015 Mathieu Chartier <mathieuc@google.com> Add missing EndAssertNoThreadSuspension

Bug: 21872507
Change-Id: I20f9920e4a12511ce498c252bca955d82a4f4102
fac3a390a247fe33d4873773d742aad4cc100118 10-Jun-2015 Mathieu Chartier <mathieuc@google.com> Move image intern table into image

Previously we recreated this intern table during runtime startup.
This added 50-100ms of boot time.

Fixed bug where we didn't copy over hashcodes into the image.

Deleted some stale code.

Bug: 20727525
Bug: 19569780
Change-Id: I08959e9aa2a73cedb52f393033e2ffea3a26e76b
0fc16a09b4d2323f9c2b6aabc81ce120b278329b 04-Jun-2015 Andreas Gampe <agampe@google.com> Revert "Revert "Turn off duplicate-classes checking""

This reverts commit 18a1827a159f1b235f3fcc934f428059185f550e.

Bug: 21333911
Change-Id: I8cb96efbf7151b238f3ee137a938b20ddfaf0ebc
44905ce1c97613a5cb44046049843fe1029a64cf 03-Jun-2015 Andreas Gampe <agampe@google.com> ART: Prune FindArrayClass cache in image writer

The ClassLinker cache speeds up FindArrayClass requests, but all
entries are roots. It is possible that an entry is a non-image
class when creating the boot image, artificially keeping the
class around.

Bug: 21596650
Change-Id: Ief9b439945d0e293a3cb5dcddfeb189b5e174f06
519fd543625da68ef93f0cd5539c949e5e74e04e 02-Jun-2015 Mathieu Chartier <mathieuc@google.com> Update IMT for stale miranda methods

Fixes occasional crash in dex2oat.

Bug: 19264997
Change-Id: Icb1a323d8c44fa40309486e17aec56d2c2588e67
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
a2ea7405471f6fd7fd5b0d52abb9ad8497c2d144 08-May-2015 Vladimir Marko <vmarko@google.com> Fix double-exception in super-class method validation.

Bug: 19333589

(cherry picked from commit d5e5a0e61b5b1fe0aaa7edc25a08adebd5a92353)

Change-Id: If394a678ef6271c1119dac3f959773f23e789c56
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
08d1b5f2296c0f51507b8b443f4e39dfc161572c 21-May-2015 Hiroshi Yamauchi <yamauchi@google.com> Fix for potential moving GC bugs around proxy class.

- Handlerize proxy_class which is live across multiple allocation
points in ClassLinker::CreateProxyClass().

- In ClassLinker::CreateProxyClass(), insert a proxy class into the
class table before creating ArtFields for it (and update it later in
LinkClass()) because the field roots (ArtField::declaring_class_)
won't be updated by GC unless the class is in the class table. If GC
happens before they are updated by FixupTemporaryDeclaringClass()
from LinkClass(), FixupTemporaryDeclaringClass() may not update the
field roots correctly because the old class may already be moved but
the fields roots may not. Reduce a window of time where the fields
roots could be stale.

- In ClassLinker::LinkClass(), directly wrap a new class in a handle
to avoid a window of time where new_class may be potentially stale.

- Print more diagnostic info about the holder of the field upon a mark
sweep invalid ref crash.

- Add an additional sanity check in Field::GetArtField().

Bug: 20557050

Change-Id: I9ad32d304922da96b7e1fad262d97de21cbac776
18a1827a159f1b235f3fcc934f428059185f550e 21-May-2015 Andreas Gampe <agampe@google.com> Revert "DO NOT MERGE ART: Turn off duplicate-classes checking"

This reverts commit aafcfca5fe545365ef377fff2897b8a908f03e71.

Bug: 21333911
Change-Id: Ibbc6b1be8bebc1d0ab9c5955b34eb89f40577baa
aafcfca5fe545365ef377fff2897b8a908f03e71 20-May-2015 Andreas Gampe <agampe@google.com> DO NOT MERGE ART: Turn off duplicate-classes checking

Bug: 21333911
Change-Id: I9832526a6d2996aadb459e3ec0930cbaf151478a
094ff2c0c1f736521c634d5f606e274cb6c55345 13-May-2015 Sebastien Hertz <shertz@google.com> Fix debuggable compiler flag detection for secondary dex files

Compiles secondary dex files like the primary dex file: if it has
been compiled with the --debuggable flag, compile secondary dex files
with the --debuggable flag too.

Therefore, dex files loaded at runtime are compiled the same way as
dex files compiled at install time on the classpath (excluding the
boot image that is not compiled debuggable).

Also adds debuggable key in the oat header and bump the oat version.

Bug: 20944228

(cherry picked from commit 0de1133ba600f299b3d67938f650720d9f859eb2)

Change-Id: If6b2236e7fe547cc421f57b573043748018d3ae0
8b83b55de8abbc195c038789f1034107f4974597 30-Apr-2015 Andreas Gampe <agampe@google.com> ART: Allow oat files with duplicates classes in corner case

When the oat file is actually an odex file, that is, a preopted
/system app, then it is impossible to fall back to the original
APK, as that has been stripped.

When it looks like it will be impossible to successfully open the
original dex location, grudgingly allow to open the found oat file,
even if it has duplicate classes, but warn accordingly.

Bug: 20697582

(cherry picked from commit 0cba004b97245300d7f39318d5921ee8edbef1ac)

Change-Id: I1dd459563d977a2e77806eacd03e49334d5b1f14
0cba004b97245300d7f39318d5921ee8edbef1ac 30-Apr-2015 Andreas Gampe <agampe@google.com> ART: Allow oat files with duplicates classes in corner case

When the oat file is actually an odex file, that is, a preopted
/system app, then it is impossible to fall back to the original
APK, as that has been stripped.

When it looks like it will be impossible to successfully open the
original dex location, grudgingly allow to open the found oat file,
even if it has duplicate classes, but warn accordingly.

Bug: 20697582
Change-Id: I1dd459563d977a2e77806eacd03e49334d5b1f14
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
94329d31d2a99c9aff889b88ba4b675135409b82 25-Apr-2015 Andreas Gampe <agampe@google.com> ART: Duplicate-classes cleanup

Disable old test. Improve collision warning message. Add a comment
about the algorithm.

Change-Id: Ibd29d79565732162150aebd7fe08d0895ccf3d79
b9aec2ccd8b9f39a4ddadde5ca8304cea6b1b188 24-Apr-2015 Andreas Gampe <agampe@google.com> ART: Check for duplicate classes when loading oat files

Oat files are usually produced standalone, and the compilers take
advantage of any information they get. It is thus possible that
when compile-time and runtime class-path are not the same, classes
are resolved differently and optimized code is incorrect.

This is a very conservative check, scanning the complete class tables
of dex files. In case any duplicate class is found, the new oat file
will be rejected and the original dex files will be used in interpreted
mode.

A possible refinement to this is actual tracking of the compile-time
class-path instead. That is however significantly complicated by the
DexFile API and the non-standard uses it allows.

An alternative for both optimized code and correct resolution is
native multidex. Apps should switch to multidex and benefit from
the optimization as well as the shift of all compile time to install
time. Split APKs are currently compiled separately, but it is a goal
to change that install flow to simulated multidex.

Change-Id: Ib9e0db5091e060e3bb2c0e5e6c007430becbfc21
bfdcdc1e2c0af34aeaf7b5b4d499975e0c3157be 23-Apr-2015 Andreas Gampe <agampe@google.com> ART: Fix re-throwing failures of non-convention errors

While it is convention that Throwable subclasses should have a
constructor with a String argument, that is not rigorously enforced.
So if a static initializer throws an error that omits that
constructor, we must not provide a message when trying to throw
again.

Bug: 20495321
Bug: 20497840
Change-Id: Ia4334fa24223750f90a8f2732f1eb1e738575e8d
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
fc58af45e342ba9e18bbdf597f205a58ec731658 17-Apr-2015 Mathieu Chartier <mathieuc@google.com> Add AbstractMethod, Constructor, Method

Moves functionality to ART from libcore. Precursor to moving
ArtMethods to native. Mostly performance improvements.

N5 perf before (irrelevant results removed):
Class_getConstructor 962.87 ===========
Class_getDeclaredMethod 2394.37 ============================
Class_getMethod 2509.20 ==============================
Class_newInstance 1999.81 =======================
Method_invokeI 1439.02 =================
Method_invokePreBoxedI 1415.82 ================
Method_invokeStaticI 1456.24 =================
Method_invokeStaticPreBoxedI 1427.32 =================
Method_invokeStaticV 814.47 =========
Method_invokeV 816.56 =========
After:
benchmark ns linear runtime
Class_getConstructor 1302.04 ================
Class_getDeclaredMethod 1459.01 ==================
Class_getMethod 1560.40 ===================
Class_newInstance 2029.94 =========================
Method_invokeI 1312.89 ================
Method_invokePreBoxedI 1255.01 ===============
Method_invokeStaticI 1289.13 ===============
Method_invokeStaticPreBoxedI 1196.52 ==============
Method_invokeStaticV 790.82 =========
Method_invokeV 791.73 =========

Performance improvements are more than just fixing regressions introduced
in: http://android-review.googlesource.com/#/c/146069/

Bug: 19264997

Change-Id: Ife79c469fdb09f30e3aefcfc3e0ce5ed32303fce
f3f2a7a0dac552593825807605c98f3910f3e557 15-Apr-2015 Mathieu Chartier <mathieuc@google.com> Remove suspend point from field loading

The error was that we had a partially constructed field array when we
got suspended by moving GC. This caused the already allocated fields
to not get updated, and be stale roots the next GC. Fixes test 125
with GSS collector.

Change-Id: I7278def915f540b6a9d12677a6ba61637f5949a2
f865ea9557e6fe017caf99832dc3adf9fadbf86f 14-Apr-2015 Andreas Gampe <agampe@google.com> ART: Make the PathClassLoader fast-path recursive

Allow an arbitrary nesting of path class-loaders. This will also
handle the fake java.lang.BootClassLoader as a class-loader object
correctly (which is of some importance to compile-time initialization).

Bug: 19781184
Bug: 19542228
Change-Id: I61f0249cf4ec8df08a83ccbd29bcf067619c28c0
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
4809d0a8a5fca85a67dd0588ead5dfbd0f1acf96 07-Apr-2015 Mathieu Chartier <mathieuc@google.com> Fix CC root visiting bug

Also some cleanup.

Change-Id: Ia3de8f2d409770be3619ec116e8b06ecd82338fe
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
2fd7e69505195cda4caaa3161aaf37315552a698 02-Apr-2015 Sebastien Hertz <shertz@google.com> Use specific exception class to abort transaction

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

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

Bug: 20019689
Change-Id: I019a72a1c754d8bba6a7ad6bb0f02e4fd6668622
07b3c2351bb527ea91c084dc19434600af9ae66b 01-Apr-2015 Richard Uhler <ruhler@google.com> Store OatDexFile instead of OatFile in DexFile.

This requires moving OatDexFile out of the OatFile class so that
a forward class declaration can be used for OatDexFile.

Bug: 19071355
Change-Id: Ibda85b78d0577e9e81073090616fc0f2fa526be3
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
e48856666e2e959687660f3b708e0c6da210ecb2 28-Mar-2015 Andreas Gampe <agampe@google.com> ART: Use instrumented Alloc in Class-Linker

To support Valgrind over dex2oat and gtests, CreatePathClassLoader
must use instrumented allocation.

Change-Id: I9dc2d009d37bec598c5de67688ebf9810da6e899
81c6f8db12b203878a7d72444ead2bc7cf5c47ad 26-Mar-2015 Andreas Gampe <agampe@google.com> ART: PathClassLoader for compiler

Use an actual PathClassLoader when compiling apps, instead of a
side structure and cutout.

This CL sets up a minimal object 'cluster' that recreates the Java
side of a regular ClassLoader such that the Class-Linker will
recognize it and use the internal native fast-path.

This CL removes the now unnecessary compile-time-classpath and
replaces it with a single 'compiling-the-boot-image' flag in the
compiler callbacks.

Note: This functionality is *only* intended for the compiler, as
the objects have not been completely initialized.

Bug: 19781184

Change-Id: I7f36af12dd7852d21281110a25c119e8c0669c1d
d8565456d29f4ad05f11cf84d2d2dac488508e06 26-Mar-2015 Mathieu Chartier <mathieuc@google.com> Fix ClassLinker::MayBeCalledWithDirectCodePointer for JIT

Currently, we don't know if another method has a direct code
pointer or not. This should fix the case where breakpoints
occasionally don't work with JIT.

The JIT now also checks that a method doesn't have any breakpoints
before starting to compile it.

Bug: 17950037

Change-Id: I17cfe874fe4825beba23903a5053d5cb27e106cb
5b783e66b26b7b6ee13d344f4b77f6b7c47c4723 19-Mar-2015 Hiroshi Yamauchi <yamauchi@google.com> Fix 003-omnibus-opcodes flaky failures with GSS GC.

Fix a moving GC bug in Class::SetStatus().

Bug: 19828874

Change-Id: I6bef49a7ce964e8a7e316f282aaf1b8544efe76d
47f867a0ae34d743f6159c2261e5b11e39693e15 18-Mar-2015 Mathieu Chartier <mathieuc@google.com> Clean up hash set

Added vertical whitespace, const iterators, made some functions
const.

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

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

Change-Id: I3d2126af1dc673cec3a0453ff3d56a172663a5f6
66d874d96d5699bb090c59f47a5a528956ca053e 15-Jan-2015 Richard Uhler <ruhler@google.com> Create OatFileAssistant class for assisting with oat files.

The oat file assistant is used for determining whether dex2oat or
patchoat is needed, for running dex2oat or patchoat as needed to make
an oat file up to date, and to load dex files associated with a given
dex location.

The introduction of the OatFileAssistant class is meant to clean up and
consolidate code related to the management of oat files that was
duplicated and spread across dalvik_system_DexFile.cc and
class_linker.cc.

Bug: 11301553
Change-Id: I0c16027b9bae4570c2c50faa9c14f581c0cbafb8
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
bd9cf9f6bbf285ec7a5b74ce655a9e68e0f6e434 03-Mar-2015 Sebastien Hertz <shertz@google.com> Follow-up 128393

Avoids false warning when initializing the exception's class by
marking the transaction aborted after throwing the InternalError
exception.

Also uses VLOG(compiler) to print the warning since it's only useful
when investigating ahead-of-time class initialization.

Bug: 19202032
Change-Id: I3c53639cbb888086ad345d668d1e5b73c5aaf861
c0d5f89d99c55ab63d6757fbd71dbfe95d347c1f 25-Feb-2015 Mathieu Chartier <mathieuc@google.com> Fix JIT for vmdebug test 99

Test was flaky due to JIT re-compiliation after deoptimization
resulting in some invalid PC offsets.

Bug: 17950037
Change-Id: I276c84c918579259ce47ef873892c3c5dcf0c977
324b9bb2f48be39e20077c1d7da45cf3dc47fe06 24-Feb-2015 Andreas Gampe <agampe@google.com> ART: Move DexFile vector to Java array

To avoid having native vectors only referenced by Java objects,
which look like leaks to Valgrind, use a Java array to store
references to native DexFile objects.

Change-Id: If3c2b31b9d0914ed1965cfd5e3fdb94ea41b1477
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
24e04aa68c575d349eac0d9d09aab9bd3106ef94 12-Sep-2014 Jean Christophe Beyler <jean.christophe.beyler@intel.com> ART: Allow the execution to stop if the compilation fails via an option

The current implementation continues the execution of the application if
dex2oat fails by relying on the interpreter.

This patch adds a -Xno-dex-file-fallback option to stop the default behavior.
This can be used two-fold.

First, one can enforce that a runtime only starts with a boot image. A
follow-up patch will ensure that dex2oat (for apps) and patchoat in general
request that mode and close gracefully otherwise.

Second, this can be used for testing and debugging purposes, as it ensures
that compiler failures & aborts are not silently ignored.

Add testing.

Bug: 19100590
Change-Id: Iaf07b5ccf00942ca8a8ec8687599320a3ddbc089
Signed-off-by: Jean Christophe Beyler <jean.christophe.beyler@intel.com>
f52857f4735a49a2a15305b3d1edf808a126b164 19-Feb-2015 Andreas Gampe <agampe@google.com> ART: Ensure order of field gaps

Disambiguate field gaps of same size by starting offset. That will
make the priority queue stable.

Bug: 19413180
Change-Id: I6302a8bbdc590af7e9ec4f332c386c375fa8d8cd
ab1eb0d1d047e3478ebb891e5259d2f1d1dd78bd 14-Feb-2015 Andreas Gampe <agampe@google.com> ART: Templatize IsInt & IsUint

Ensure that things are used correctly.

Change-Id: I76f082b32dcee28bbfb4c519daa401ac595873b3
e4301ffb56f9be6f6c2640bfb1870b74f4a37ad2 18-Feb-2015 Andreas Gampe <agampe@google.com> ART: Make run-tests more verbose

Make run-tests log ERROR level on host. Adjust some internal LOG(ERROR)
to LOG(WARNING). Add check scripts to adjust for other LOG(ERROR)
messages.

Bug: 18713034
Change-Id: I2a3e055baa6a0e31f106364c300c20963a59ed94
d8ca52e28ea00d1f23866a421791935e13b42bce 14-Feb-2015 Andreas Gampe <agampe@google.com> ART: Add more details to LinkageError

Add the classes or method details that fail during linking to enable
better diagnosis of problems.

Bug: 19294695
Change-Id: Ifab48bc182cd801d44d3aead2168028f27043be0
862f43c65652d132e73eff89667a11c9757e817d 10-Feb-2015 Vladimir Marko <vmarko@google.com> Fix HasSameSignatureWithDifferentClassLoaders().

Add a missing handle and make sure that the handle's
Get() is sequenced after the call that can cause GC.

Change-Id: I3c0479650c40ceb803bfbf658238aeea8e4b0a1a
c7d11887725e28db2796c848f4485e59d5eb690c 04-Feb-2015 Jeff Hao <jeffhao@google.com> Handle variable size of methods properly between 32 and 64 bit.

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

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

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

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

Bug: 19202032
Change-Id: Iedc6969528a68bbdf3123146e990df4dbc57834b
2cd334ae2d4287216523882f0d298cf3901b7ab1 09-Jan-2015 Hiroshi Yamauchi <yamauchi@google.com> More of the concurrent copying collector.

Bug: 12687968
Change-Id: I62f70274d47df6d6cab714df95c518b750ce3105
0c8c303c20cdaaf54d26e45cc17dc5afb820d8ef 17-Jan-2015 Hiroshi Yamauchi <yamauchi@google.com> Clean up the locks around Heap::VisitObjects().

This is so that we could support suspending all threads when visiting
objects in the presence of a concurrent, moving collector.

Bug: 12687968
Change-Id: Icc8e60630465afde948ebc6ea91d4ebaff5d7837
a8a697f48e92c85136fc7bec661623c434f67ede 15-Jan-2015 Sebastien Hertz <shertz@google.com> Update instrumentation stubs on resolved classes

We cannot update methods of a class in the process of being loaded.
We need it to be fully resolved (kStatusResolved) so we can access
its complete structure (including method index) and the compiled
code from the oat file.

We ensure that by skipping classes that are not resolved yet when we
update instrumentation (with all threads suspended). The entrypoints
will be updated when the class gets resolved by the ClassLinker. We
also do not update method entrypoints of erroneous classes
(kStatusError) because we cannot execute code for these methods.

This situation can happen when the debugger requests an event that
will cause a full deoptimization (like a METHOD_ENTRY event) while we
are loading a new class. Because we suspend all threads to update
instrumentation, we may visit a class that is being loaded but not
yet resolved.

Bug: 19012386
Bug: 18766029
Change-Id: I5a645dfaf5c25dcf4282c1aaeb24f1b6333baa37
7f418db815f0eaef5b2f43e1f06fb8773a415494 26-Nov-2014 Sebastien Hertz <shertz@google.com> JDWP: fix breakpoint for method in the image

When we set a breakpoint in a compiled method, we deoptimize it by
changing its entrypoint so it is executed with the interpreter.
However, methods in the image can be called with their direct code
pointer, ignoring the updated entrypoint. In that case, the method
is not executed with the interpreter and we miss the breakpoint.

This CL avoids that situation by forcing a full deoptimization so
everything runs with the interpreter. However, if the image has been
compiled in PIC mode, we keep using selective deoptimization because
direct code pointer is not used in this mode.

Bug: 17965285

(cherry picked from commit 6963e44331258b131bcc0599b868ba15902d6d22)

Change-Id: I9bf738f89b9eb6d18733503216b376b8a1d181f5
e34fa1df67fbe0173b4ea9abddcc3ae3d0537037 14-Jan-2015 Mathieu Chartier <mathieuc@google.com> Print more info in MarkSweep::VerifyRoot

Refactored old root callback to use a new class called RootInfo.
RootInfo contains all the relevant info related to the root
associated with the callback. The MarkSweep::VerifyRoot function
now uses this info to print the StackVisitor's described location
if the GC root is of the type kRootJavaFrame.

Some other cleanup.

Example output:
E/art (12167): Tried to mark 0x123 not contained by any spaces
E/art (12167): Attempting see if it's a bad root
E/art (12167): Found invalid root: 0x123 with type RootJavaFrame
E/art (12167): Location=Visiting method
'void java.lang.Runtime.gc()' at dex PC 0xffffffff (native PC 0x0)
vreg=0

(cherry picked from commit 12f7423a2bb4bfab76700d84eb6d4338d211983a)

Bug: 18588862
Change-Id: Ic5a2781f704e931265ffb3621c2eab4b2e25f60f
12f7423a2bb4bfab76700d84eb6d4338d211983a 14-Jan-2015 Mathieu Chartier <mathieuc@google.com> Print more info in MarkSweep::VerifyRoot

Refactored old root callback to use a new class called RootInfo.
RootInfo contains all the relevant info related to the root
associated with the callback. The MarkSweep::VerifyRoot function
now uses this info to print the StackVisitor's described location
if the GC root is of the type kRootJavaFrame.

Some other cleanup.

Example output:
E/art (12167): Tried to mark 0x123 not contained by any spaces
E/art (12167): Attempting see if it's a bad root
E/art (12167): Found invalid root: 0x123 with type RootJavaFrame
E/art (12167): Location=Visiting method
'void java.lang.Runtime.gc()' at dex PC 0xffffffff (native PC 0x0)
vreg=0

Bug: 18588862
Change-Id: Ic5a2781f704e931265ffb3621c2eab4b2e25f60f
fd9eb3923dcf417afcf5ed4ebb13867fd10f2de3 07-Nov-2014 Andreas Gampe <agampe@google.com> ART: Simple structural class check

Adds a simple check to class-loading when the embedded dex file in
an oat file and the dex file on the class path where we found the
class do not match.

We require that the number of methods and fields do not change, as
that will almost certainly mean that quickened and other compiled
offsets are wrong now. This is a reasonably lightweight change, but
we should investigate a full comparison including name and type of
members.

Bug: 17937814
Bug: 18708951

(cherry picked from commit 15a33b3f88546bce85dcb9d28caf200da51154d7)

Change-Id: Icb9638bebd369ab23822817f4a97c8dd8625fea5
15a33b3f88546bce85dcb9d28caf200da51154d7 07-Nov-2014 Andreas Gampe <agampe@google.com> ART: Simple structural class check

Adds a simple check to class-loading when the embedded dex file in
an oat file and the dex file on the class path where we found the
class do not match.

We require that the number of methods and fields do not change, as
that will almost certainly mean that quickened and other compiled
offsets are wrong now. This is a reasonably lightweight change, but
we should investigate a full comparison including name and type of
members.

Bug: 17937814
Bug: 18708951
Change-Id: Icb9638bebd369ab23822817f4a97c8dd8625fea5
fbef44de596d298dc6430f482dffc933a046dd28 23-Dec-2014 Richard Uhler <ruhler@google.com> Use unique_ptr to track ownership of dex files.

Bug: 18809837
Change-Id: Ie571eae8fc19ee9207390cff5c7e2a38071b126a
956af0f0cb05422e38c1d22cbef309d16b8a1a12 11-Dec-2014 Elliott Hughes <enh@google.com> Remove portable.

Change-Id: I3bf3250fa866fd2265f1b115d52fa5dedc48a7fc
a696c0a27f9b9cdf68ac17bdb4e29ac1f798ac32 11-Dec-2014 Andreas Gampe <agampe@google.com> ART: More ELF and oat file safety measures

In an ELF file, look for a shstrtab section when loading in
program-header-only mode. If the section is outside the file size,
it strongly indicates a broken compile.

When compiling oat files in the class linker, explicitly unlink
on failure. This should catch cases when dex2oat is killed or
crashes and doesn't have a chance to delete its (partial) output.

Bug: 15567083

(cherry picked from commit ad00fed942a9a04cf3f46784bbd04a5f00dd4ab8)

Change-Id: Ia0c75f151d91c6f26a71696967255d6d409ca882
ad00fed942a9a04cf3f46784bbd04a5f00dd4ab8 11-Dec-2014 Andreas Gampe <agampe@google.com> ART: More ELF and oat file safety measures

In an ELF file, look for a shstrtab section when loading in
program-header-only mode. If the section is outside the file size,
it strongly indicates a broken compile.

When compiling oat files in the class linker, explicitly unlink
on failure. This should catch cases when dex2oat is killed or
crashes and doesn't have a chance to delete its (partial) output.

Bug: 15567083
Change-Id: Ia0c75f151d91c6f26a71696967255d6d409ca882
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
fe382b5296ef132316d8883a0bdf8cb00d40d16b 10-Dec-2014 Nicolas Geoffray <ngeoffray@google.com> Revert "Ensure void type is resolved when running without image"

Reverting to stop tests breakage.

This reverts commit 3138584a720b86f2f542160425d3a922920760c0.

Change-Id: Idd30d458cef67839416ffeae4d558da2affd29d0
3138584a720b86f2f542160425d3a922920760c0 09-Dec-2014 Sebastien Hertz <shertz@google.com> Ensure void type is resolved when running without image

To initialize java.lang.Void correctly, we need to ensure the 'void'
class is initialized in the dex cache of core-libart (because Java
code relies on it). However, if we run without image, the dex cache
may not contain the void class before we initialize java.lang.Void
class.

This CL fixes this by forcing the resolution of 'void' class when
initializing the runtime without image.

We also generalize that to other types by not skipping verification
when running with preopted oat files without image. By verifying
all classes, we ensure all resolved types are in the dex caches.

Bug: 18338511
(cherry picked from commit cad417c72cc879ae8b6a8b2fff26f05a770f2051)

Change-Id: I65e345da47be6eda1ee55897c01a9a4cc1444915
cad417c72cc879ae8b6a8b2fff26f05a770f2051 09-Dec-2014 Sebastien Hertz <shertz@google.com> Ensure void type is resolved when running without image

To initialize java.lang.Void correctly, we need to ensure the 'void'
class is initialized in the dex cache of core-libart (because Java
code relies on it). However, if we run without image, the dex cache
may not contain the void class before we initialize java.lang.Void
class.

This CL fixes this by forcing the resolution of 'void' class when
initializing the runtime without image.

We also generalize that to other types by not skipping verification
when running with preopted oat files without image. By verifying
all classes, we ensure all resolved types are in the dex caches.

Bug: 18338511
Change-Id: I65e345da47be6eda1ee55897c01a9a4cc1444915
a89d7ed6f091ac495cd43560ece6988776d14d61 05-Dec-2014 Mathieu Chartier <mathieuc@google.com> Add pointer size logic to InitFromImageInterpretOnly

Previously we didn't have this logic which broke dex2oat if passed
--runtime-option -Xint flag.

Also we now no longer call InitFromImageInterpretOnlyCallback if
we are the compiler.

Bug: 18631640
Change-Id: Ie84fceeb85cabeeec7a5fedefd73dd919cca8e5e
6963e44331258b131bcc0599b868ba15902d6d22 26-Nov-2014 Sebastien Hertz <shertz@google.com> JDWP: fix breakpoint for method in the image

When we set a breakpoint in a compiled method, we deoptimize it by
changing its entrypoint so it is executed with the interpreter.
However, methods in the image can be called with their direct code
pointer, ignoring the updated entrypoint. In that case, the method
is not executed with the interpreter and we miss the breakpoint.

This CL avoids that situation by forcing a full deoptimization so
everything runs with the interpreter. However, if the image has been
compiled in PIC mode, we keep using selective deoptimization because
direct code pointer is not used in this mode.

Bug: 17965285
Change-Id: Icaf8cbb7fe9ad01d36f7378c59d50d9ce42ae57f
b5fb207ed5e3570ec14e18811b3fa066168fe493 03-Dec-2014 Ian Rogers <irogers@google.com> Remove MethodHelper::HasSameSignatureWithDifferentClassLoaders.

Move sole use to a static function within class_linker.cc.
Remove unused MutableMethodHelper and empty method_helper.cc.

Change-Id: Ia26bc76674ed2ee7c9c546de820cc181005fed77
f2247513a54300cfa6a2f23fdbbafead115c99b2 03-Dec-2014 Ian Rogers <irogers@google.com> Remove MethodHelper::HasSameNameAndSignature.

Move sole use to a static method with art_method.cc.

Change-Id: I2e7994cc1c31b5ca74df5d7be5538003d4ed0150
e0a02dabedd7db2c511a513fb48d7e39ed3dd9c0 02-Dec-2014 Ian Rogers <irogers@google.com> Move FindDexMethodIndexInOtherDexFile into ArtMethod.

Move FindDexMethodIndexInOtherDexFile out of MethodHelper into ArtMethod in
preparation for the removal of MethodHelper.
Tidy ClassLinker::ResolveMethod so that all exception paths flow through the
exception pending assertion.
Tidy artQuickResolutionTrampoline to be more explicit about variable names and
only update the dex cache if necessary.

Change-Id: I3e48eb4f6c1291533067c1b53efe90c53bfcaea8
72267f9b0cf19afae278d8a2f272f3038b999c33 02-Dec-2014 Sebastien Hertz <shertz@google.com> Fix build

Fixes bad merge with duplicated method.

Change-Id: I3059f4d5c0efcca67c4bbf166e4f5a19f8b0c9c1
91a6dc41003cdd22073e72fd5425df8e95b1c172 01-Dec-2014 Mathieu Chartier <mathieuc@google.com> Set dex_cache_strings_ when we call Class::SetDexCache

Ensures that these two variables never get out of sync. The error
was presumably related to not doing this for proxy classes. This
caused java code which was looking at the dex_cache_strings_ field
to incorrectly access a null array.

Bug: 18548887

(cherry picked from commit ea1c3d77b92b30ec527f2ca5bfe316a882b698e0)

Change-Id: I022d9311b38b61e160ed70e3c5d9639797adb29c
ea1c3d77b92b30ec527f2ca5bfe316a882b698e0 01-Dec-2014 Mathieu Chartier <mathieuc@google.com> Set dex_cache_strings_ when we call Class::SetDexCache

Ensures that these two variables never get out of sync. The error
was presumably related to not doing this for proxy classes. This
caused java code which was looking at the dex_cache_strings_ field
to incorrectly access a null array.

Bug: 18548887
Change-Id: If53c6ade3588b82a480d6674dfbd5caa2e5069fd
eace45873190a27302b3644c32ec82854b59d299 25-Nov-2014 Mathieu Chartier <mathieuc@google.com> Move dexCacheStrings from ArtMethod to Class

Adds one load for const strings which are not direct.

Saves >= 60KB of memory avg per app.
Image size: -350KB.

Bug: 17643507
Change-Id: I2d1a3253d9de09682be9bc6b420a29513d592cc8

(cherry picked from commit f521f423b66e952f746885dd9f6cf8ef2788955d)
f521f423b66e952f746885dd9f6cf8ef2788955d 25-Nov-2014 Mathieu Chartier <mathieuc@google.com> Move dex cache strings from ArtMethod -> Class

Adds one load for const strings which are not direct.

Saves >= 60KB of memory avg per app.
Image size: -350KB.

Bug: 17643507
Change-Id: I2d1a3253d9de09682be9bc6b420a29513d592cc8
f2134f684923454e00c8ca7675b431a8538131bc 17-Nov-2014 Sebastien Hertz <shertz@google.com> JDWP: only deoptimize when it is required

We don't need to deoptimize anything when we forced the use of the
interpreter (-Xint). In this case, no compiled code is executed
(except native methods which are not concerned by deoptimization).
Therefore we even don't need to enable/disable deoptimization support
in instrumentation.

We also don't need to deoptimize a method that hasn't been compiled.
Since it will run with interpreter, there is no point deoptimizing
it. However this method may be inlined in a compiled caller method
so we still need to deoptimize everything in this case.

This CL updates breakpoint support by storing the required kind of
deoptimization for a particular method. There are 3 cases:
- kNothing: the method does not require deoptimization.
- kSelectiveDeoptimization: the method needs to be deoptimized.
- kFullDeoptimization: we must deoptimize everythinig.
When uninstalling a breakpoint, we need to do the reverse operation.

Also fixes the SanityCheckExistingBreakpoints function to control
breakpoints related to the given method only and adds extra verbose
ilogs when choosing the appropriate deoptimization kind.

Includes a partial cherry-pick of commit
87553c9fa1298ffb40127b2bb6413859fd3f79df to use method
ClassLinker::GetOatMethodQuickCodeFor.

Bug: 18407046

(cherry picked from commit f3928794a10516e2ac0ffe2686a10891788d4b9c)

Change-Id: I50853cc5fc5c52650485785a1198d35ea0f7fb8e
957ca1cd025104fccb0b08928f955f9bdb4ab91c 22-Nov-2014 Mathieu Chartier <mathieuc@google.com> Delete ArtMethod gc_map_ field

Moved the gc_map field from OatMethod to OatQuickMethodHeader.
Deleted the ArtMethod gc_map_ field.

Bug: 17643507

Change-Id: Ifa0470c3e4c2f8a319744464d94c6838b76b3d48

(cherry picked from commit 807140048f82a2b87ee5bcf337f23b6a3d1d5269)
3242729362b74d22f11d8bc7b4800ba0a8695df6 19-Nov-2014 Ian Rogers <irogers@google.com> Avoid JNI call with pending OOME.

If EnsureResolved fails with an exception then FindClassInPathClassLoader may
fall-through to a call to NewStringUTF with a pending exception.
Bug: 15446488

Change-Id: I007f7bee7c50aa588d0b1c776da67a38314dc897
2d7210188805292e463be4bcf7a133b654d7e0ea 10-Nov-2014 Mathieu Chartier <mathieuc@google.com> Change 64 bit ArtMethod fields to be pointer sized

Changed the 64 bit entrypoint and gc map fields in ArtMethod to be
pointer sized. This saves a large amount of memory on 32 bit systems.
Reduces ArtMethod size by 16 bytes on 32 bit.

Total number of ArtMethod on low memory mako: 169957
Image size: 49203 methods -> 787248 image size reduction.
Zygote space size: 1070 methods -> 17120 size reduction.
App methods: ~120k -> 2 MB savings.

Savings per app on low memory mako: 125K+ per app
(less active apps -> more image methods per app).

Savings depend on how often the shared methods are on dirty pages vs
shared.

TODO in another CL, delete gc map field from ArtMethod since we
should be able to get it from the Oat method header.

Bug: 17643507

Change-Id: Ie9508f05907a9f693882d4d32a564460bf273ee8

(cherry picked from commit e832e64a7e82d7f72aedbd7d798fb929d458ee8f)
e832e64a7e82d7f72aedbd7d798fb929d458ee8f 10-Nov-2014 Mathieu Chartier <mathieuc@google.com> Change 64 bit ArtMethod fields to be pointer sized

Changed the 64 bit entrypoint and gc map fields in ArtMethod to be
pointer sized. This saves a large amount of memory on 32 bit systems.
Reduces ArtMethod size by 16 bytes on 32 bit.

Total number of ArtMethod on low memory mako: 169957
Image size: 49203 methods -> 787248 image size reduction.
Zygote space size: 1070 methods -> 17120 size reduction.
App methods: ~120k -> 2 MB savings.

Savings per app on low memory mako: 125K+ per app
(less active apps -> more image methods per app).

Savings depend on how often the shared methods are on dirty pages vs
shared.

TODO in another CL, delete gc map field from ArtMethod since we
should be able to get it from the Oat method header.

Bug: 17643507

Change-Id: Ie9508f05907a9f693882d4d32a564460bf273ee8
b34674d246c7d678e5796d561af00d51ad43996c 17-Nov-2014 Vladimir Marko <vmarko@google.com> Fix ordering of fields with the same name.

While the Java language doesn't allow multiple fields with
the same name in a single class (excluding fields from super
classes), the bytecode specification permits it and tools
such as proguard actually generate them. Define the order of
these fields by their dex file index and relax the check of
field ordering to permit identical names.

Bug: 18211592

(cherry picked from commit 7a7c1db21782fb922d3ffc5c576117812624ea58)

Change-Id: I8547eeac890b7483c8925367a85382197be9ea7a
938f966d399821d29075198cac4331d9a0c92bea 12-Nov-2014 Vladimir Marko <vmarko@google.com> Fix LinkFieldsComparator.

Define order for primitive types with the same sizes.
Previously, the comparator would consider the fields equal
so the order would depend on std::sort() implementation.
Changing the STL implementation could silently change the
field offsets. (And, unlike std::stable_sort(), the
std::sort() doesn't even need to be deterministic.)

(cherry picked from commit d577748c041aa6df599218f3cb31697ecf032730)

Change-Id: I9b769d023864aa36c52918c7c3dd11c0f6b8f40e
7a7c1db21782fb922d3ffc5c576117812624ea58 17-Nov-2014 Vladimir Marko <vmarko@google.com> Fix ordering of fields with the same name.

While the Java language doesn't allow multiple fields with
the same name in a single class (excluding fields from super
classes), the bytecode specification permits it and tools
such as proguard actually generate them. Define the order of
these fields by their dex file index and relax the check of
field ordering to permit identical names.

Bug: 18211592
Change-Id: I1dee9b2b669a6ea180a2d3a41030efb2aed53950
d577748c041aa6df599218f3cb31697ecf032730 12-Nov-2014 Vladimir Marko <vmarko@google.com> Fix LinkFieldsComparator.

Define order for primitive types with the same sizes.
Previously, the comparator would consider the fields equal
so the order would depend on std::sort() implementation.
Changing the STL implementation could silently change the
field offsets. (And, unlike std::stable_sort(), the
std::sort() doesn't even need to be deterministic.)

Change-Id: I91fa562f82447606aced64643bea8c70784766b5
76649e8d775519fe19f2b14d18ac488c13296054 10-Nov-2014 Vladimir Marko <vmarko@google.com> Keep original order of fields in Class.

The fields of a class are ordered alphabetically in the dex
file. Keep the same order in the field arrays so that we can
do binary search lookups by name. Those lookups will be
implemented in a subsequent change in libcore/.

Bug: 18211592

(cherry picked from commit bfa3ed0ad988e1da13626ddbaf6dcae0c58ea79e)

Change-Id: I8f979de62ffe37d1c7d5c721717d2f3501e7c9e6
bfa3ed0ad988e1da13626ddbaf6dcae0c58ea79e 10-Nov-2014 Vladimir Marko <vmarko@google.com> Keep original order of fields in Class.

The fields of a class are ordered alphabetically in the dex
file. Keep the same order in the field arrays so that we can
do binary search lookups by name. Those lookups will be
implemented in a subsequent change in libcore/.

Bug: 18211592
Change-Id: I8f979de62ffe37d1c7d5c721717d2f3501e7c9e6
e225eab4a17dd8db7f9d8412e4edc04e330462bc 30-Oct-2014 Igor Murashkin <iam@google.com> art: Fix classlinker and nopatchoat test for PIC case

ClassLinker should not be checking oat data begin and the patch delta
as part of the checksum verification (when PIC is enabled).

Also update nopatchoat test since it needs to be parametric on whether
PIC is used.

(cherry-picked from AOSP master
230faa7c44ec1986d5fa93d205eb23cb8024e333)

Bug: 18035729

(cherry picked from commit 5ef2990c2933152021633e6697d5325103649499)

Change-Id: Ia0a601c657b813767114095c3b7577421e03bde4
48447025389cd67605041a28d4ded1528381bc4e 22-Oct-2014 Igor Murashkin <iam@google.com> ART: Add support for patching and loading OAT files compiled with PIC

* Images (.art) compiled with pic now have a new field added.
* isDexOptNeeded will now skip patch-ing for apps compiled PIC
* First-boot patching now only copies boot.art, boot.oat is linked

As a result, all system preopted dex files (with --compile-pic) no
longer take up any space in /data/dalvik-cache/<isa>.

(cherry-picked from AOSP master
46774767fcf7780d1455e755729198648d08742e)

Conflicts (from aosp master):
compiler/image_test.cc
compiler/image_writer.cc
compiler/image_writer.h
compiler/oat_test.cc
dex2oat/dex2oat.cc
oatdump/oatdump.cc
runtime/elf_file.cc
runtime/elf_file.h
runtime/elf_file_impl.h
runtime/oat_file.cc
runtime/oat_file.h

Bug: 18035729

(cherry picked from commit 90ca5c0301651101de0e363842e5d08ae65233f7)

Change-Id: I8d99f95cc3d1fa221fc530ebb1fcc4b3263c183d
998ee7d0f62a1ee7efaaad49e728d19c38b4c9c3 23-Oct-2014 Andreas Gampe <agampe@google.com> ART: Add pic flag to oat header store

Add the compile-time PIC flag to the oat-header key-value store.
Ignore image offset and patch delta when loading PIC oat files.

(cherry-picked from AOSP master
7ba649636c4475c3992fa15a57acd2546d69ff38)

Bug: 18035729
Signed-off-by: Igor Murashkin <iam@google.com>

(cherry picked from commit d7392faea80acb5d73a027bb384e3222bc2c2e43)

Change-Id: If5f6cf13f4c7ecb6038415e68fbb0ae9cee5ec60
e7c9a8c2b8481aafbc6af4ce6229bd361ba24742 07-Nov-2014 Mathieu Chartier <mathieuc@google.com> Add hash map, reduce excessive hashing

Changed the class def index to use a HashMap instead of unordered_map
so that we can use FindWithHash to reduce how often we need to compute
hashes.

Fixed a bug in ClassLinker::UpdateClass where we didn't properly
handle classes with the same descriptor but different class loaders.
Introduced by previous CL.

Before (fb launch):
1.74% art::ComputeModifiedUtf8Hash(char const*)

After:
0.95% art::ComputeModifiedUtf8Hash(char const*)

Bug: 18054905
Bug: 16828525

Change-Id: Iba2ee37c9837289e0ea187800ba4af322225a994

(cherry picked from commit 564ff985184737977aa26c485d0c1a413e530705)
564ff985184737977aa26c485d0c1a413e530705 07-Nov-2014 Mathieu Chartier <mathieuc@google.com> Add hash map, reduce excessive hashing

Changed the class def index to use a HashMap instead of unordered_map
so that we can use FindWithHash to reduce how often we need to compute
hashes.

Fixed a bug in ClassLinker::UpdateClass where we didn't properly
handle classes with the same descriptor but different class loaders.
Introduced by previous CL.

Before (fb launch):
1.74% art::ComputeModifiedUtf8Hash(char const*)

After:
0.95% art::ComputeModifiedUtf8Hash(char const*)

Bug: 18054905
Bug: 16828525

Change-Id: Iba2ee37c9837289e0ea187800ba4af322225a994
c2e20629c7dfdb0f679fa30c14b41fe68588697f 03-Nov-2014 Mathieu Chartier <mathieuc@google.com> Add hash set

More memory efficient than libcxx since we do not box the values.

Change intern table to use new hash set. Clean up intern table by
removing const casts and deleting unnecessary code.

Changed the class linker to use a hash set, also added a pre-zygote
class table.

5 samples of:
adb shell stop && adb shell start && sleep 60 && adb shell dumpsys meminfo
Before:
165929 kB: Native
175859 kB: Native
168434 kB: Native
166559 kB: Native
169958 kB: Native

After:
160972 kB: Native
159439 kB: Native
157204 kB: Native
165093 kB: Native
163039 kB: Native

TODO: Add HashTable which is implemented by using a HashSet.
TODO: Use for DexFile::find_class_def_misses_.
TODO: Investigate using mem maps instead of native heap.

Bug: 17808975

Change-Id: I93e376cf6eb9628cf52f4aefdadb6157acfb799a

(cherry picked from commit e05d1d5fd86867afc7513b1c546375dba11eee50)
e05d1d5fd86867afc7513b1c546375dba11eee50 03-Nov-2014 Mathieu Chartier <mathieuc@google.com> Add hash set

More memory efficient than libcxx since we do not box the values.

Change intern table to use new hash set. Clean up intern table by
removing const casts and deleting unnecessary code.

Changed the class linker to use a hash set, also added a pre-zygote
class table.

5 samples of:
adb shell stop && adb shell start && sleep 60 && adb shell dumpsys meminfo
Before:
165929 kB: Native
175859 kB: Native
168434 kB: Native
166559 kB: Native
169958 kB: Native

After:
160972 kB: Native
159439 kB: Native
157204 kB: Native
165093 kB: Native
163039 kB: Native

TODO: Add HashTable which is implemented by using a HashSet.
TODO: Use for DexFile::find_class_def_misses_.
TODO: Investigate using mem maps instead of native heap.

Bug: 17808975

Change-Id: I93e376cf6eb9628cf52f4aefdadb6157acfb799a
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
575e78c41ece0dec969d31f46be563d4eb7ae43b 04-Nov-2014 Andreas Gampe <agampe@google.com> ART: Replace COMPILE_ASSERT with static_assert (runtime)

Replace all occurrences of COMPILE_ASSERT in the runtime tree.

Change-Id: I01e420899c760094fb342cc6cb9e692dd670a0b2
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
5ef2990c2933152021633e6697d5325103649499 30-Oct-2014 Igor Murashkin <iam@google.com> art: Fix classlinker and nopatchoat test for PIC case

ClassLinker should not be checking oat data begin and the patch delta
as part of the checksum verification (when PIC is enabled).

Also update nopatchoat test since it needs to be parametric on whether
PIC is used.

(cherry-picked from AOSP master
230faa7c44ec1986d5fa93d205eb23cb8024e333)

Bug: 18035729
Change-Id: I4eb184d22616230a7b8f0dd514d3416d0976b07e
90ca5c0301651101de0e363842e5d08ae65233f7 22-Oct-2014 Igor Murashkin <iam@google.com> ART: Add support for patching and loading OAT files compiled with PIC

* Images (.art) compiled with pic now have a new field added.
* isDexOptNeeded will now skip patch-ing for apps compiled PIC
* First-boot patching now only copies boot.art, boot.oat is linked

As a result, all system preopted dex files (with --compile-pic) no
longer take up any space in /data/dalvik-cache/<isa>.

(cherry-picked from AOSP master
46774767fcf7780d1455e755729198648d08742e)

Conflicts (from aosp master):
compiler/image_test.cc
compiler/image_writer.cc
compiler/image_writer.h
compiler/oat_test.cc
dex2oat/dex2oat.cc
oatdump/oatdump.cc
runtime/elf_file.cc
runtime/elf_file.h
runtime/elf_file_impl.h
runtime/oat_file.cc
runtime/oat_file.h

Bug: 18035729
Change-Id: Ie1acad81a0fd8b2f24e1f3f07a06e6fdb548be62
d7392faea80acb5d73a027bb384e3222bc2c2e43 23-Oct-2014 Andreas Gampe <agampe@google.com> ART: Add pic flag to oat header store

Add the compile-time PIC flag to the oat-header key-value store.
Ignore image offset and patch delta when loading PIC oat files.

(cherry-picked from AOSP master
7ba649636c4475c3992fa15a57acd2546d69ff38)

Bug: 18035729
Signed-off-by: Igor Murashkin <iam@google.com>
Change-Id: Ie1f1ef37125386a968228033d1e2bec565315510
9f3629df89b7f2b4f7a599bdc5f7eeb748330582 29-Oct-2014 Mathieu Chartier <mathieuc@google.com> Add hash table to link virtual methods

Added a hash table for turning the O(m*n) lookup average case to
O(m+n) average case. There is probably still some room for improvement.

Before:
WaitTime: 2121
WaitTime: 2051
WaitTime: 2134
WaitTime: 2104
WaitTime: 2237
WaitTime: 2391
4.99% art::MethodNameAndSignatureComparator::HasSameNameAndSignature(art::mirror::ArtMethod)
1.65% art::ClassLinker::LinkVirtualMethods(art::Thread*, art::Handle<art::mirror::Class>)

After:
WaitTime: 2038
WaitTime: 1965
WaitTime: 1979
WaitTime: 1976
WaitTime: 1957
WaitTime: 2004
0.46% art::MethodNameAndSignatureComparator::HasSameNameAndSignature(art::mirror::ArtMethod*)
1.39% art::ClassLinker::LinkVirtualMethods(art::Thread*, art::Handle<art::mirror::Class>)

Bug: 18054905
Bug: 16828525

(cherry picked from commit a9ca9ac444ceb2cf5e8bd5c98c1ed47f2a9a94dd)

Change-Id: If847afb7194daa05ace38d15862e4b871dfffae1
a9ca9ac444ceb2cf5e8bd5c98c1ed47f2a9a94dd 29-Oct-2014 Mathieu Chartier <mathieuc@google.com> Add hash table to link virtual methods

Added a hash table for turning the O(m*n) lookup average case to
O(m+n) average case. There is probably still some room for improvement.

Before:
WaitTime: 2121
WaitTime: 2051
WaitTime: 2134
WaitTime: 2104
WaitTime: 2237
WaitTime: 2391
4.99% art::MethodNameAndSignatureComparator::HasSameNameAndSignature(art::mirror::ArtMethod)
1.65% art::ClassLinker::LinkVirtualMethods(art::Thread*, art::Handle<art::mirror::Class>)

After:
WaitTime: 2038
WaitTime: 1965
WaitTime: 1979
WaitTime: 1976
WaitTime: 1957
WaitTime: 2004
0.46% art::MethodNameAndSignatureComparator::HasSameNameAndSignature(art::mirror::ArtMethod*)
1.39% art::ClassLinker::LinkVirtualMethods(art::Thread*, art::Handle<art::mirror::Class>)

Bug: 18054905
Bug: 16828525

Change-Id: If847afb7194daa05ace38d15862e4b871dfffae1
96e83930f35544872228be209d3704f60c2c485c 30-Oct-2014 Igor Murashkin <iam@google.com> art: Fix classlinker and nopatchoat test for PIC case

ClassLinker should not be checking oat data begin and the patch delta
as part of the checksum verification (when PIC is enabled).

Also update nopatchoat test since it needs to be parametric on whether
PIC is used.

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

Also, fix missing handle in HasSameSignatureWithDifferentClassLoaders.

Change-Id: I9e1ffd09be950ecc8346fc3c485760d82d9ecab3
473484fac7bd53523f5503176ecc5955325a9731 28-Oct-2014 Ian Rogers <irogers@google.com> Tidy MethodProtoHelper.

Move to place of only use, class_linker.cc. Be lazy in computing the name.

Before:
WaitTime: 2699
WaitTime: 2791
WaitTime: 2653
WaitTime: 2929
WaitTime: 2651
WaitTime: 2971

After:
WaitTime: 2749
WaitTime: 2786
WaitTime: 2852
WaitTime: 2856
WaitTime: 2703
WaitTime: 2784

Bug: 18054905
Bug: 16828525

(cherry picked from commit 03b6eafba8ace9a9c4d5ee9c47723d1910ccd7a8)

Change-Id: I1438efbda58369ddd0ac36eda8a5a0a6c6fdff77
05d89ee90413c51573c8e708a193f4ff87d67d0a 28-Oct-2014 Mathieu Chartier <mathieuc@google.com> Fill resolved static fields during class initialization

Previously everytime we resolved static fields we linear searched
the class to find the field with the specified field id. Now we
eagerly set these fields in the dex cache when we initialize classes.

FB launch timings before:
WaitTime: 2903
WaitTime: 2953
WaitTime: 2918
WaitTime: 2940
WaitTime: 2879
WaitTime: 2792

Timings after:
WaitTime: 2699
WaitTime: 2791
WaitTime: 2653
WaitTime: 2929
WaitTime: 2651
WaitTime: 2971

Perf before:
2.94% art::mirror::Class::FindDeclaredStaticField(art::mirror::DexCache const*, unsigned int)
After:
0.00% art::mirror::Class::FindDeclaredStaticField(art::mirror::DexCache const*, unsigned int)

Bug: 18054905
Bug: 16828525

(cherry picked from commit bfb21589a6490769690b44aaf8e6a0021a1261b7)

Change-Id: I33255f85d10c29cae085584880196c45ac0ea230
bfb21589a6490769690b44aaf8e6a0021a1261b7 28-Oct-2014 Mathieu Chartier <mathieuc@google.com> Fill resolved static fields during class initialization

Previously everytime we resolved static fields we linear searched
the class to find the field with the specified field id. Now we
eagerly set these fields in the dex cache when we initialize classes.

FB launch timings before:
WaitTime: 2903
WaitTime: 2953
WaitTime: 2918
WaitTime: 2940
WaitTime: 2879
WaitTime: 2792

Timings after:
WaitTime: 2699
WaitTime: 2791
WaitTime: 2653
WaitTime: 2929
WaitTime: 2651
WaitTime: 2971

Perf before:
2.94% art::mirror::Class::FindDeclaredStaticField(art::mirror::DexCache const*, unsigned int)
After:
0.00% art::mirror::Class::FindDeclaredStaticField(art::mirror::DexCache const*, unsigned int)

Bug: 18054905
Bug: 16828525

Change-Id: I33255f85d10c29cae085584880196c45ac0ea230
03b6eafba8ace9a9c4d5ee9c47723d1910ccd7a8 28-Oct-2014 Ian Rogers <irogers@google.com> Tidy MethodProtoHelper.

Move to place of only use, class_linker.cc. Be lazy in computing the name.

Change-Id: I1438efbda58369ddd0ac36eda8a5a0a6c6fdff77
46774767fcf7780d1455e755729198648d08742e 22-Oct-2014 Igor Murashkin <iam@google.com> ART: Add support for patching and loading OAT files compiled with PIC

* Images (.art) compiled with pic now have a new field added.
* isDexOptNeeded will now skip patch-ing for apps compiled PIC
* First-boot patching now only copies boot.art, boot.oat is linked

As a result, all system preopted dex files (with --compile-pic) no
longer take up any space in /data/dalvik-cache/<isa>.

Bug: 18035729
Change-Id: Ie1acad81a0fd8b2f24e1f3f07a06e6fdb548be62
7ba649636c4475c3992fa15a57acd2546d69ff38 23-Oct-2014 Andreas Gampe <agampe@google.com> ART: Add pic flag to oat header store

Add the compile-time PIC flag to the oat-header key-value store.
Ignore image offset and patch delta when loading PIC oat files.

Change-Id: Ie1f1ef37125386a968228033d1e2bec565315510
d035c2d0523f29cb3c4fcc14a80d2a8ceadec3ba 28-Oct-2014 Mathieu Chartier <mathieuc@google.com> Fix 64 bit build

Buggy compiler.

(cherry picked from commit 7989d22642415e1e4d608e210284834951bd0a39)

Change-Id: Id16c83fc7963ca89fd7fae32dd15ae342cc7f064
7989d22642415e1e4d608e210284834951bd0a39 28-Oct-2014 Mathieu Chartier <mathieuc@google.com> Fix 64 bit build

Buggy compiler.

Change-Id: Id16c83fc7963ca89fd7fae32dd15ae342cc7f064
2d2621a1463d2f3f03fa73503fa42e43657cdcfc 24-Oct-2014 Mathieu Chartier <mathieuc@google.com> Optimize method linking

Added more inlining, removed imt array allocation and replaced it
with a handle scope. Removed some un-necessary handle scopes.

Added logic to base interface method tables from the superclass so
that we dont need to reconstruct for every interface (large win).

Facebook launch Dalvik KK MR2:
TotalTime: 3165
TotalTime: 3652
TotalTime: 3143
TotalTime: 3298
TotalTime: 3212
TotalTime: 3211

Facebook launch TOT before:
WaitTime: 3702
WaitTime: 3616
WaitTime: 3616
WaitTime: 3687
WaitTime: 3742
WaitTime: 3767

After optimizations:
WaitTime: 2903
WaitTime: 2953
WaitTime: 2918
WaitTime: 2940
WaitTime: 2879
WaitTime: 2792

LinkInterfaceMethods no longer one of the hottest methods, new list:
4.73% art::ClassLinker::LinkVirtualMethods(art::Thread*, art::Handle<art::mirror::Class>)
3.07% art::DexFile::FindClassDef(char const*) const
2.94% art::mirror::Class::FindDeclaredStaticField(art::mirror::DexCache const*, unsigned int)
2.90% art::DexFile::FindStringId(char const*) const

Bug: 18054905
Bug: 16828525

(cherry picked from commit 1fb463e42cf1d67595cff66d19c0f99e3046f4c4)

Change-Id: I27cc70178fd3655fbe5a3178887fcba189d21321
1fb463e42cf1d67595cff66d19c0f99e3046f4c4 24-Oct-2014 Mathieu Chartier <mathieuc@google.com> Optimize method linking

Added more inlining, removed imt array allocation and replaced it
with a handle scope. Removed some un-necessary handle scopes.

Added logic to base interface method tables from the superclass so
that we dont need to reconstruct for every interface (large win).

Facebook launch Dalvik KK MR2:
TotalTime: 3165
TotalTime: 3652
TotalTime: 3143
TotalTime: 3298
TotalTime: 3212
TotalTime: 3211

Facebook launch TOT before:
WaitTime: 3702
WaitTime: 3616
WaitTime: 3616
WaitTime: 3687
WaitTime: 3742
WaitTime: 3767

After optimizations:
WaitTime: 2903
WaitTime: 2953
WaitTime: 2918
WaitTime: 2940
WaitTime: 2879
WaitTime: 2792

LinkInterfaceMethods no longer one of the hottest methods, new list:
4.73% art::ClassLinker::LinkVirtualMethods(art::Thread*, art::Handle<art::mirror::Class>)
3.07% art::DexFile::FindClassDef(char const*) const
2.94% art::mirror::Class::FindDeclaredStaticField(art::mirror::DexCache const*, unsigned int)
2.90% art::DexFile::FindStringId(char const*) const

Bug: 18054905
Bug: 16828525

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

Change-Id: I7a79c1671a6ff8b2040887133b3e0925ef9a3cfe
cf7f19135f0e273f7b0136315633c2abfc715343 23-Oct-2014 Ian Rogers <irogers@google.com> C++11 related clean-up of DISALLOW_..

Move DISALLOW_COPY_AND_ASSIGN to delete functions. By no having declarations
with no definitions this prompts better warning messages so deal with these
by correcting the code.
Add a DISALLOW_ALLOCATION and use for ValueObject and mirror::Object.
Make X86 assembly operand types ValueObjects to fix compilation errors.
Tidy the use of iostream and ostream.
Avoid making cutils a dependency via mutex-inl.h for tests that link against
libart. Push tracing dependencies into appropriate files and mutex.cc.
x86 32-bit host symbols size is increased for libarttest, avoid copying this
in run-test 115 by using symlinks and remove this test's higher than normal
ulimit.
Fix the RunningOnValgrind test in RosAllocSpace to not use GetHeap as it
returns NULL when the heap is under construction by Runtime.

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

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

(cherry picked from commit 6f3dbbadf4ce66982eb3d400e0a74cb73eb034f3)

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

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

Change-Id: I5f4b49e88c3b02a79f9bee04f83395146ed7be23
b23eab1c507f5d133a2dbcdd00c45aa86d156eef 09-Oct-2014 Brian Carlstrom <bdc@google.com> Add VLOG(class_linker) for clinit errors

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

Change-Id: I4e4ef3a2002fc59ebd9097087f150eaf3f2a7e08
cdc1aaffabbdf417d29b203b2cd2763ed2d623f8 09-Oct-2014 Ian Rogers <irogers@google.com> Simplify instance reference offsets.

Don't encode Object's class. Use trailing rather than leading zeroes to give
offset position.

Change-Id: I1ae74e7a01f63696429644adf81cdf6ee58832fe
31d8f5295c24730a57cb36cbc41197f0b7e8397c 29-Sep-2014 Brian Carlstrom <bdc@google.com> Add VMRuntime.isBootClassPathOnDisk

Bug: 17679443

(cherry picked from commit 95a935415d44903b28326424beb4db5c013ef089)

Change-Id: Iba40291dead3f0b6715903c986370fd0cf1e41e1
95a935415d44903b28326424beb4db5c013ef089 29-Sep-2014 Brian Carlstrom <bdc@google.com> Add VMRuntime.isBootClassPathOnDisk

Bug: 17679443
Change-Id: I127ffdac3bfe731e9535dfe6a242eb950363d715
07140838a3ee44a6056cacdc78f2930e019107da 01-Oct-2014 Ian Rogers <irogers@google.com> Enable -Wunreachable-code

Caught bugs in DeoptimizeStackVisitor and assemble_x86 SIB encoding.
Add UNREACHABLE macro to document code expected to be unreachable.
Bug: 17731047

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

Remove extra semicolons.

Dollar signs in C++ identifiers are an extension.

Named variadic macros are an extension.

Binary literals are a C++14 feature.

Enum re-declarations are not allowed.

Overflow.

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

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

Bug: 9986565

Change-Id: I4b142ffac4ab8b5b915836f1660a949d6442344c
2d5f39ed5aeaeb7ca22b07b4c6e8c56348ef8893 20-Sep-2014 Mathieu Chartier <mathieuc@google.com> Add ScopedAssertNoThreadSuspension

Added a new class, ScopedAssertNoThreadSuspension.
Deleted some unnecessary ScopedAssertNoThreadSuspension since
VisitObjects already has a ScopedAssertNoThreadSuspension.

Change-Id: I29ec0006120c39a27184d30e2d1d0c179e203776
3c13a794845e0cf7887e33b2ec20de7e6ba85f8f 19-Sep-2014 Andreas Gampe <agampe@google.com> ART: Only allow the zygote to create the global boot image

Do not allow arbitrary processes, even when root, to write the
boot image in /data/dalvik-cache.

Bug: 17478752, 17510489, 17439961
Change-Id: Iba2b74be6d0752f4221f4ff5ee295b45a34cb2e1
(cherry picked from commit 33c36d4f22ab6a5e61eb47b654deaf647c34e49c)
33c36d4f22ab6a5e61eb47b654deaf647c34e49c 19-Sep-2014 Andreas Gampe <agampe@google.com> ART: Only allow the zygote to create the global boot image

Do not allow arbitrary processes, even when root, to write the
boot image in /data/dalvik-cache.

Bug: 17478752, 17510489, 17439961
Change-Id: Iba2b74be6d0752f4221f4ff5ee295b45a34cb2e1
63bc11efaac0c041e849ab401f9fc368631a00f5 18-Sep-2014 Ian Rogers <irogers@google.com> DO NOT MERGE. Only have a portable entrypoint in portable builds.

Bug: 16214885

Change-Id: Iff7b7415efdbdabd7e6020e221a540f6a774c852
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
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
ab0ed82ff64ba5a751dcc0a38d0e0c41c53dc923 11-Sep-2014 Mathieu Chartier <mathieuc@google.com> Add fast path to VMClassLoader.findLoadedClass

VMClassLoader.findLoadedClass now calls FindClassInPathClassLoader
as a fast path. Exclusive time results (trace view maps launch):

Before:
nativeFillInStackTrace 1.4%
defineClassNative 1.2%
findLoadedClass 0.2%

After:
nativeFillInStackTrace 0.5%
defineClassNative 0.0%
findLoadedClass 0.9%

(cherry picked from commit 194116c836080de14245a3a7c4617d07b8abf8cf)

Change-Id: I63fd7b4bccb71789e92bd39d1d3f9d0de22535de
bb0c7f6a247521bc3e85f08f93603122bccb1a72 11-Sep-2014 Andreas Gampe <agampe@google.com> ART: Fix preverified setting in VerifyClass

Make sure soft-failed classes cannot set methods to pre-verified.

Bug: 16828525, 17465185

(cherry picked from commit 3892cf8da7d5e76c0dee585fc8f69df773680525)

Change-Id: I09c0a68ca722978459741311148eae7614f9ca49
194116c836080de14245a3a7c4617d07b8abf8cf 11-Sep-2014 Mathieu Chartier <mathieuc@google.com> Add fast path to VMClassLoader.findLoadedClass

VMClassLoader.findLoadedClass now calls FindClassInPathClassLoader
as a fast path. Exclusive time results (trace view maps launch):

Before:
nativeFillInStackTrace 1.4%
defineClassNative 1.2%
findLoadedClass 0.2%

After:
nativeFillInStackTrace 0.5%
defineClassNative 0.0%
findLoadedClass 0.9%

Bug: 16828525

Change-Id: I1bde48effcd28529778c00ec0fa0dda4e32026a3
3892cf8da7d5e76c0dee585fc8f69df773680525 11-Sep-2014 Andreas Gampe <agampe@google.com> ART: Fix preverified setting in VerifyClass

Make sure soft-failed classes cannot set methods to pre-verified.

Bug: 16828525, 17465185
Change-Id: I09c0a68ca722978459741311148eae7614f9ca49
48498591b90a8ff7b24b1ce05c220e3bc42013df 11-Sep-2014 Andreas Gampe <agampe@google.com> ART: Correctly make methods preverified

Bug: 16828525

(cherry picked from commit df1532b9ba0cda2d00b78fbdef461f8a6cf8a737)

Change-Id: I66756348b2aa50e41dacca59769b6810a91c73b0
52be37cb506d3313f3fc5b0afdc5d0322b1191e3 11-Sep-2014 Brian Carlstrom <bdc@google.com> Move EnsurePreverifiedMethods to take ConstHandle to reconcile with AOSP

Bug: 16828525
Change-Id: I7b6a3771ed78ef609d84ee539e9d9575deb2476a
df1532b9ba0cda2d00b78fbdef461f8a6cf8a737 11-Sep-2014 Andreas Gampe <agampe@google.com> ART: Correctly make methods preverified

Bug: 16828525
Change-Id: I66756348b2aa50e41dacca59769b6810a91c73b0
faff0f05fef90577c9744505555675185832aacd 10-Sep-2014 Mingyao Yang <mingyao@google.com> Remove reference_static_offsets used for iterating through class static fields.

Since static fields are contiguous in class object and there is no need to
traverse super classes, it's not meaningful to use reference_static_offsets.
Also especially with embedded vtable/imt, static field offset can't be encoded
with an unsigned integer anyway.

A corresponding change is made to Class.java to remove the member field.

Bug: 16236588
Change-Id: I1fde3cd9efce884945876f0658c63d992164fd94
be4e64303cc66bda0a12eaab835caa0bcfda3cd9 05-Sep-2014 Vladimir Marko <vmarko@google.com> Improve dex location canonicalization-related performance.

Eagerly add canonical dex file locations to the OatFile's
primary lookup map in Setup(). This moves the boot.oat work
from every app startup to the zygote initialization. Since
we always ended up initializing the canonical location map
anyway due to the way that we're loading dex files, the lazy
initialization didn't save anything.

Clean up dex file name canonicalization to make sure we
free() the memory returned by realpath() rather than using
std::unique_ptr<> with the default deleter.

Avoid some unnecessary duplicate OatDexFile lookups.

Bug: 16828525
Bug: 17346103

(cherry picked from commit aa4497db59f1eeec954f2ba5da6d458fcdf9b3a4)

Change-Id: Icc4b14ebe903282ca91ce24e33a6d7c75dff991c
1a465ca32178292888d3dc34b1cd784432a35848 10-Sep-2014 Sebastien Hertz <shertz@google.com> Ensure class is linked before resolution

Adds a missing call to ClassLinker::EnsureResolved to ensure we did link the
class and retired the temp class (placeholder) before doing the resolution.

Bug: 17435441

(cherry picked from commit 72da76359aa5599f78ddca79b294e9bf30e004ed)

Change-Id: I3b368567c7b24ec2ff7ee1dec7bcd3501a6061f8
72da76359aa5599f78ddca79b294e9bf30e004ed 10-Sep-2014 Sebastien Hertz <shertz@google.com> Ensure class is linked before resolution

Adds a missing call to ClassLinker::EnsureResolved to ensure we did link the
class and retired the temp class (placeholder) before doing the resolution.

Bug: 17435441

Change-Id: Ib1a7181d6e5e814ca9299d0504e739a2b69475ef
aa4497db59f1eeec954f2ba5da6d458fcdf9b3a4 05-Sep-2014 Vladimir Marko <vmarko@google.com> Improve dex location canonicalization-related performance.

Eagerly add canonical dex file locations to the OatFile's
primary lookup map in Setup(). This moves the boot.oat work
from every app startup to the zygote initialization. Since
we always ended up initializing the canonical location map
anyway due to the way that we're loading dex files, the lazy
initialization didn't save anything.

Clean up dex file name canonicalization to make sure we
free() the memory returned by realpath() rather than using
std::unique_ptr<> with the default deleter.

Avoid some unnecessary duplicate OatDexFile lookups.

Bug: 16828525
Bug: 17346103
Change-Id: Id8fbc8992f62996138eb2006a0046c6529747c09
6bcae8fa93684af581d16400f360541d39e5b5e6 05-Sep-2014 Mathieu Chartier <mathieuc@google.com> Add fast path for FindClass using the type dex file.

If we are using the PathClassLoader with a BootClassLoader
parent, we can handle the common case in the FindClass function
without needing to go back to java code.

Around 10% speedup measured of maps launch, could be noise due to
large variation of app launch times. Eliminates defineClassNative
from being anywhere near the top of sampling profiles.

Bug: 17397179
Bug: 16828525

(cherry picked from commit 8a39e7fe02e9a81853dc7a75cb50d9ece07a9b37)

Change-Id: I1f31de76c1b1a53e32173b1e61a59b0e2f267c98
8a39e7fe02e9a81853dc7a75cb50d9ece07a9b37 05-Sep-2014 Mathieu Chartier <mathieuc@google.com> Add fast path for FindClass using the type dex file.

If we are using the PathClassLoader with a BootClassLoader
parent, we can handle the common case in the FindClass function
without needing to go back to java code.

Around 10% speedup measured of maps launch, could be noise due to
large variation of app launch times. Eliminates defineClassNative
from being anywhere near the top of sampling profiles.

Bug: 17397179
Bug: 16828525
Change-Id: Ide0db2b5f6cf5b96fc46e89178e0799de667cb88
30c2e1b3970c8a720eac38dbaca1d849c619114e 08-Sep-2014 Vladimir Marko <vmarko@google.com> Small error reporting fix in class linker.

Change-Id: Ia9e94df48e9984c25ad8ab5c6ca41f9153984915
ca0c8d3f81cdee58bd9a70c0fd26f79917dff3b5 30-Aug-2014 Ian Rogers <irogers@google.com> VisitClassesWithoutClassesLock isn't safe if classes move.

Which they do, so avoid by doing an array allocation.
Also, tidy member variables to the end of ClassLinker.
Remove unnecessary mutable. Tidy and fix a locks required/excluded.

Change-Id: I2404a9e7a1ea997d68ab1206f97d2a20dffbda06
(cherry picked from commit dbf3be0f133c0bdf454f637fee2452dbb5f7c027)
621962a0872bf328dba7eda44061f0f505014cef 02-Sep-2014 Calin Juravle <calin@google.com> Avoid recomputing the dex checksum during class loading

Thread the already computed checksum to VerifyOatAndDexFileChecksums and
LoadMultiDexFilesFromOatFile to avoid recomputing it.

Bug:17346103

(cherry picked from commit ca3459398018360d9968a52eebf727df085caf83)

Change-Id: Ie244efaca55b9e7c814b35feec7fce11fab3856d
a8c55ae449ad423087f232b2fec1064062755970 05-Sep-2014 Calin Juravle <calin@google.com> Remove unreachable code from class_linker.cc

If the checksum doesn't match the oat_dex_file will be NULL, a case
which is handled in the first if.

Bug: 17402267

Change-Id: If8547ddc8fd7eff59a3b7dd36c07ac4ceb351361
ca3459398018360d9968a52eebf727df085caf83 02-Sep-2014 Calin Juravle <calin@google.com> Avoid recomputing the dex checksum during class loading

Thread the already computed checksum to VerifyOatAndDexFileChecksums and
LoadMultiDexFilesFromOatFile to avoid recomputing it.

Bug:17346103
Change-Id: Ifa0c1cad952853751e98cbb3c999631b9909a9f9
68caf9e7232109c698e7f91f64b348cf37b432dd 03-Sep-2014 Jeff Hao <jeffhao@google.com> Fix stack overflow and duplicate methods while tracing.

Bug: 16386215
Change-Id: I0d0ae0113a3a00013ce84a1f5a110e2c52f19b86
(cherry picked from commit 6b28a456b075fe53dfb7e924a44dbf35d0d41eb3)
dbf3be0f133c0bdf454f637fee2452dbb5f7c027 30-Aug-2014 Ian Rogers <irogers@google.com> VisitClassesWithoutClassesLock isn't safe if classes move.

Which they do, so avoid by doing an array allocation.
Also, tidy member variables to the end of ClassLinker.
Remove unnecessary mutable. Tidy and fix a locks required/excluded.

Change-Id: I2404a9e7a1ea997d68ab1206f97d2a20dffbda06
6b28a456b075fe53dfb7e924a44dbf35d0d41eb3 03-Sep-2014 Jeff Hao <jeffhao@google.com> Fix stack overflow and duplicate methods while tracing.

Bug: 16386215
Change-Id: I0d0ae0113a3a00013ce84a1f5a110e2c52f19b86
79cfc0e93e210e548b45459478a154168d2d8cc2 05-Jun-2014 Ian Rogers <irogers@google.com> Pre-allocate the NoClassDefFoundError to be thrown for boot classes.

Bring over a Dalvik "optimization".
Bug: 12804658
Bug: 16853450
Change-Id: I6419de7bd2ba18d91479cb52489104954f5c4524

(cherry picked from commit 63557459a4098294a9ff44d035241de2966047c0)
cc2f2393e69a9b1425bad1a89f41aaaf8c38f9e2 30-Aug-2014 Ian Rogers <irogers@google.com> Reduce and speed-up class def searches.

Use the class linker for descriptor lookups from the compile driver so that
dex caches are populated.
Reduce the scope of functions for scanning class paths to just the class
linker where they are performed.
If we see more than a threshold number of find class def misses on a dex file
lazily compute an index, so that future lookups are constant time (part of the
collection code is taken from
https://android-review.googlesource.com/#/c/103865/3). Note that we take a lazy
approach so that we don't serialize on loading dex files, this avoids the
reason the index was removed in 8b2c0b9abc3f520495f4387ea040132ba85cae69.
Remove an implicit and unnecessary std::string creation for PrintableString.

Single threaded interpret-only dex2oat performance is improved by roughly 10%.

Bug: 16853450

Change-Id: Icf72df76b0a4328f2a24075e81f4ff267b9401f4
(cherry picked from commit 68b56858367e29461ae290fd797443a1ef6d8005)
63557459a4098294a9ff44d035241de2966047c0 05-Jun-2014 Ian Rogers <irogers@google.com> Pre-allocate the NoClassDefFoundError to be thrown for boot classes.

Bring over a Dalvik "optimization".
Bug: 12804658
Bug: 16853450
Change-Id: I6419de7bd2ba18d91479cb52489104954f5c4524
68b56858367e29461ae290fd797443a1ef6d8005 30-Aug-2014 Ian Rogers <irogers@google.com> Reduce and speed-up class def searches.

Use the class linker for descriptor lookups from the compile driver so that
dex caches are populated.
Reduce the scope of functions for scanning class paths to just the class
linker where they are performed.
If we see more than a threshold number of find class def misses on a dex file
lazily compute an index, so that future lookups are constant time (part of the
collection code is taken from
https://android-review.googlesource.com/#/c/103865/3). Note that we take a lazy
approach so that we don't serialize on loading dex files, this avoids the
reason the index was removed in 8b2c0b9abc3f520495f4387ea040132ba85cae69.
Remove an implicit and unnecessary std::string creation for PrintableString.

Single threaded interpret-only dex2oat performance is improved by roughly 10%.

Bug: 16853450

Change-Id: Icf72df76b0a4328f2a24075e81f4ff267b9401f4
496cd337c19ca8386fec24633160f82c01993bbd 29-Aug-2014 Alex Light <allight@google.com> Fix segfault if running without image.

Bug: 17325091

(cherry picked from commit 7adb7ac3913364de8cc57b8934024dd12e1d3bea)

Change-Id: I343099543ce0abf02219da84d61d9ce2dfc47980
7adb7ac3913364de8cc57b8934024dd12e1d3bea 29-Aug-2014 Alex Light <allight@google.com> Fix segfault if running without image.

Bug: 17325091
Change-Id: I343099543ce0abf02219da84d61d9ce2dfc47980
381e4ca3cc9fc6405ff20e1de873a56d78d51923 26-Aug-2014 Fred Shih <ffred@google.com> Filling hole between subclass and superclass.

Subclasses no longer need to be 4-byte aligned at the end. Any gaps
between a superclass and its subclasses will be filled in by halfword
or byte fields if possible.

Refactored the alignment and shuffling methods to use a priority queue
in order to reduce the amount of logic when laying out objects.

Change-Id: Ifed71af534e0c5e77bb14555c44b973fe66df6da
524507a9265e8e5e2b040c113d903c815748245a 28-Aug-2014 Mathieu Chartier <mathieuc@google.com> Prevent exception bugs in class linker

There were some places that could throw exceptions but still succeed.
This caused the allocation entrypoints to occasionally allocate a
heap object with a pending exception.
Also added some additional AssertNoExceptionPending.

Bug: 17164348

(cherry picked from commit 58c016c3f85d6d5496cea25325778de3a8d9a3ac)

Change-Id: Id9918fa8f1a5d713b847cb95cdade925ff80a826
440d3da1284f7c7333b4fc5d09072664ae7a370a 27-Aug-2014 Sebastien Hertz <shertz@google.com> Ensure proxy constructor is in dex cache

Bug: 17262039

(cherry picked from commit ae94e350f100207359b8345d8d21e78e7cfb44c4)

Change-Id: I1cfc8dac1f63b9012fa098804135be8847b1daee
58c016c3f85d6d5496cea25325778de3a8d9a3ac 28-Aug-2014 Mathieu Chartier <mathieuc@google.com> Prevent exception bugs in class linker

There were some places that could throw exceptions but still succeed.
This caused the allocation entrypoints to occasionally allocate a
heap object with a pending exception.
Also added some additional AssertNoExceptionPending.

Bug: 17164348

Change-Id: Ic6dd3b0cce9955349176503dd7f6c3da7ab0a6f1
ae94e350f100207359b8345d8d21e78e7cfb44c4 27-Aug-2014 Sebastien Hertz <shertz@google.com> Ensure proxy constructor is in dex cache

Bug: 17262039

Change-Id: I879341fa9c66f18ec64d6d4bf6a222a452c27739
fb7775981c7e6ecca78dcce774e9cc4db63e6e99 23-Aug-2014 Alex Light <allight@google.com> Support booting without functioning boot.oat/art patchoat.

Bug: 17000769

(cherry picked from commit 84d7605f93f1e6e86a16e02017e305c90e93117a)

Change-Id: I89c26a905af12ea288742368c2c038afd57a879a
84d7605f93f1e6e86a16e02017e305c90e93117a 23-Aug-2014 Alex Light <allight@google.com> Support booting without functioning boot.oat/art patchoat.

Bug: 17000769

Change-Id: I89c26a905af12ea288742368c2c038afd57a879a
df7337508381dce5e653b2e7a2ee4ca93103d67c 26-Aug-2014 Andreas Gampe <agampe@google.com> ART: kSuper also has IncompatibleClassChangeError

When resolving methods, kSuper can also have
IncompatibleClassChangeError.

Bug: 17266767

(cherry picked from commit 9cb8d7a9a5013dd1e6734d9643573a4750d869e2)

Change-Id: I5fafe03ad578f605825a3d0c89f1254a4a385b76
9cb8d7a9a5013dd1e6734d9643573a4750d869e2 26-Aug-2014 Andreas Gampe <agampe@google.com> ART: kSuper also has IncompatibleClassChangeError

When resolving methods, kSuper can also have
IncompatibleClassChangeError.

Bug: 17266767
Change-Id: I5fafe03ad578f605825a3d0c89f1254a4a385b76
8850011ceffce5de38262169de74e4a41ced50eb 22-Aug-2014 Hiroshi Yamauchi <yamauchi@google.com> Remove an intermediate field array in ClassLinker::InitializeClass.

This improves on CL 105090 by removing the need for the intermediate
field array by iterating two iterators in parallel.

Bug: 12687968
Change-Id: I32d4570948a9d39ccb1c20a02e18b48f15ed0738
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
507e6180ad271eb719c67ce7394852c731d975a5 19-Aug-2014 Alex Light <allight@google.com> Support running without a boot image.

Bug: 17000769

(cherry picked from commit 64ad14dbe2225441fb7734bf6d89358d96692eea)

Change-Id: I6404d5050c8a2f4ee6e70d58532eb25ee9de248e
64ad14dbe2225441fb7734bf6d89358d96692eea 19-Aug-2014 Alex Light <allight@google.com> Support running without a boot image.

Bug: 17000769

Change-Id: I6404d5050c8a2f4ee6e70d58532eb25ee9de248e
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
67ef46adfb2c4990832e23aebeb9c0582d8519c4 22-Aug-2014 Hiroshi Yamauchi <yamauchi@google.com> Avoid handle-less fields in ClassLinker::InitializeClass()

There were some handle-less fields in a SafeMap across GC points.

Bug: 12687968
Change-Id: Ib8c6527d4e23031f1d0074fa11d8f85499b68340
0a112bbbcd761c749c346bfec0ec39c1ef37a590 14-Aug-2014 Alex Light <allight@google.com> Make apps able to run with a failing patchoat

Bug: 17000769

(cherry picked from commit 9dcc4572949f6a8231a1b4ed859676ba6f411726)

Change-Id: I0a1a4dc7f5d4bb268530840302ecfb1555231e05
9dcc4572949f6a8231a1b4ed859676ba6f411726 14-Aug-2014 Alex Light <allight@google.com> Make apps able to run with a failing patchoat

Bug: 17000769

Change-Id: I0a1a4dc7f5d4bb268530840302ecfb1555231e05
9bdec8839c1a34d09ec3e8916a4bd3a022ac45b6 16-Aug-2014 Hiroshi Yamauchi <yamauchi@google.com> Check that we don't accidentally invoke compiled code when -Xint.

The heap poisoning breakge (b/17018234) would have been detected with
this check.

Bug: 17018234
Change-Id: If4827ea1b02396d41012f0955e55c887387a0565
41369d2f7042b728a78d5f1e8c49925463e50294 19-Aug-2014 Hiroshi Yamauchi <yamauchi@google.com> Avoid handle-less methods in ClassLinker::LinkInterfaceMethods().

There were some handle-less methods in local variables across
potential GC points.

Bug: 12687968

Change-Id: I786fbaadf7a52e98194080c67c90fc1c35060d59
ee5618be0076ac359ab59af1c2ba945d85b2986e 15-Aug-2014 Jeff Hao <jeffhao@google.com> resolved conflicts for merge of 549c9b17 to lmp-dev-plus-aosp

Change-Id: Icea7763c830aeefa02d6a86c960c4b41148d397b
9c290012b7f505ae1943ab87236f775b97a46e2d 22-Jul-2014 Nicolas Geoffray <ngeoffray@google.com> Execute an application even when dex2oat crashes.

Bug: 17000769

(cherry picked from commit 4fcdc94d22a4608e355aa8df36240181149d10e8)

Change-Id: Iccb1fec94fe64ce4c3097510952f275482b86aa9
95b4c65da93500cdbdcaa3e01010771ef3f466f1 15-Aug-2014 Jeff Hao <jeffhao@google.com> Prevent stubs from being installed in java.lang.reflect.Proxy.<init>.

This CL is a better fix for proxy tracing and undoes the changes in
https://android-review.googlesource.com/#/c/103025/

Bug: 16386215

(cherry picked from commit db8a664e0b68c7c4d36270cd21dce8de1912d7f9)

Change-Id: Ic9e0ea2af7cb2da5d90c56aa009de92dba14cc47
4bf8d11df5dccc1b276cd9c40a98e8a14d79a9c8 25-Jul-2014 Jeff Hao <jeffhao@google.com> Fix proxy tracing and enable tests that now work with tracing.

Also updates proxy_test to generate an image for GetQuickOatCodeFor.

Bug: 16386215

(cherry picked from commit f0a3f09c3d54646166a55c05a6b39c7dd504129c)

Change-Id: I138edbad9e1646db8590f2b1b73f2788d9710e68
db8a664e0b68c7c4d36270cd21dce8de1912d7f9 15-Aug-2014 Jeff Hao <jeffhao@google.com> Prevent stubs from being installed in java.lang.reflect.Proxy.<init>.

This CL is a better fix for proxy tracing and undoes the changes in
https://android-review.googlesource.com/#/c/103025/

Change-Id: Ie82bb49f07774bd08a6720ddbe5b1f8ee9363acf
82546347f86440b5e6317e304b04383f5d1ce326 13-Aug-2014 Mingyao Yang <mingyao@google.com> Use handle in one case that spans a gc-point.

Bug: 16689428

(cherry picked from commit 38eecb0f4288a374c9b0b4b4df8793eb5fc6697c)

Change-Id: Id4a1bde9012e4dd333493e46997c200537c9cf55
eff0f5d9d52805abf825601960cc0c42dc8d7b5a 14-Aug-2014 Andreas Gampe <agampe@google.com> ART: Fix class-linker handling

ResolveMethod did not account correctly for the mutual exclusivity
of direct and static methods. In such a case we threw a NoSuchMethodError,
while the correct behavior is to throw an IncompatibleClassChangeError.

Bug: 16956477

(cherry picked from commit b5d1efa0012d31f7c52c0a2e2b70c77c8708c885)

Change-Id: Id014affe0b8a43dbd75570b123b921d5853ab135
b5d1efa0012d31f7c52c0a2e2b70c77c8708c885 14-Aug-2014 Andreas Gampe <agampe@google.com> ART: Fix class-linker handling

ResolveMethod did not account correctly for the mutual exclusivity
of direct and static methods. In such a case we threw a NoSuchMethodError,
while the correct behavior is to throw an IncompatibleClassChangeError.

Bug: 16956477
Change-Id: Id014affe0b8a43dbd75570b123b921d5853ab135
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
38eecb0f4288a374c9b0b4b4df8793eb5fc6697c 13-Aug-2014 Mingyao Yang <mingyao@google.com> Use handle in one case that spans a gc-point.

Bug: 16689428
Change-Id: Ib209d2ca1e7024bffb2bc17c5b5899e231c0e2ca
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
97b52f89e5e0b52a08d4b9a3953d0973a3cf5636 14-Aug-2014 Ian Rogers <irogers@google.com> Make OatClass and OatMethod immutable once more.

OatClass and OatMethod are representation of disk data and we don't want the
runtime to mutate this.

Change-Id: Id5b8658fd544f5d6e1b9120af134d3644ff1a52c
4fcdc94d22a4608e355aa8df36240181149d10e8 22-Jul-2014 Nicolas Geoffray <ngeoffray@google.com> Execute an application even when dex2oat crashes.

Bug: 17000769

Change-Id: Iffeb582862a5e794b6c7364c7ec2368cfd0f2214
4ef12f5b0e26c6016c87866f6a33da5ed8e98d74 01-Aug-2014 Andreas Gampe <agampe@google.com> ART: Add guards to the dex cache and its shortcuts

Do not return fields, methods or classes if the (declaring) class is
erroneous.

Bug: 16692788

(cherry picked from commit 58a5af8568d224ca7eccf2483396ff9862f8d1ee)

Change-Id: I7d3e4cb8113e2e764ed7433eed25e1031e6a0f14
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
58a5af8568d224ca7eccf2483396ff9862f8d1ee 01-Aug-2014 Andreas Gampe <agampe@google.com> ART: Add guards to the dex cache and its shortcuts

Do not return fields, methods or classes if the (declaring) class is
erroneous.

Bug: 16692788
Change-Id: If43c2414ad0eb22db5eba7cf66396c7f16c26597
345c4b19758703793ed31024cfb79940e2c63b75 18-Jul-2014 Alex Light <allight@google.com> Make system use patchoat to relocate during runtime.

Change dalvik_system_DexFile.cc so that isDexOptNeededInternal will be
able to indicate that a patchoat is required. Change default of relocate
option to be on.

Bug: 15358152

(cherry picked from commit 6e183f2e973a20f2eaca135c240908e1bf98c5d0)

Change-Id: Ib21f4f41b6cbf18094e3ca1a30d65a3b197b71b0
6e183f2e973a20f2eaca135c240908e1bf98c5d0 18-Jul-2014 Alex Light <allight@google.com> Make system use patchoat to relocate during runtime.

Change dalvik_system_DexFile.cc so that isDexOptNeededInternal will be
able to indicate that a patchoat is required. Change default of relocate
option to be on.

Bug: 15358152

Change-Id: Ibe92d8b55a24bbf718b0416a21b76e5df7a2de26
f0a3f09c3d54646166a55c05a6b39c7dd504129c 25-Jul-2014 Jeff Hao <jeffhao@google.com> Fix proxy tracing and enable tests that now work with tracing.

Also updates proxy_test to generate an image for GetQuickOatCodeFor.

Bug: 16386215
Change-Id: Ie7daad3d73ea7b60187bc1e7037ade0df8277107
66d1caf42c20efba8305efb3a819993126e8abbf 16-Jul-2014 Calin Juravle <calin@google.com> Use canonical paths when searching for dex files

Apps which use the DexPathClassLoader directly may
pass symlinks when trying to load dex files. This
will not work as we use string comparision to find
the dex in an oat file. The CL fixes this issue by
using using dex conical paths for comparisons.

Bug: 15313272

(cherry picked from commit 4e1d579d6401fef2dd57b16f8d406e33221a69d9)

Change-Id: I441f1ef18388c4a17c747a7e55b57f917724db85
4e1d579d6401fef2dd57b16f8d406e33221a69d9 16-Jul-2014 Calin Juravle <calin@google.com> Use canonical paths when searching for dex files

Apps which use the DexPathClassLoader directly may
pass symlinks when trying to load dex files. This
will not work as we use string comparision to find
the dex in an oat file. The CL fixes this issue by
using using dex conical paths for comparisons.

Bug: 15313272

Change-Id: Ic314374b17612c3afbcadec93a88b2515a0aca5e
9854fe24d3e22a2e232597b4334ac93205ff17ed 23-Jul-2014 Mingyao Yang <mingyao@google.com> Fix build, missing spaces around =/<.

(cherry picked from commit 1a12858eb15a14788478c4aca82c052bc84fcafa)

Change-Id: Id2d276cd1fb8bb95c46ff5ceacc7cfe1f5acf192
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
94f7b49578b6aaa80de8ffed230648d601393905 23-Jul-2014 Hiroshi Yamauchi <yamauchi@google.com> Add GcRoot to clean up and enforce read barriers.

Introduce a value-type wrapper around Object* for GC roots so that 1)
we won't have to directly add the read barrier code in many places and
2) we can avoid accidentally bypassing/missing read barriers on GC
roots (the GcRoot interface ensures that the read barrier is executed
on a read).

The jdwp test passed.

Bug: 12687968
Change-Id: Ib167c7c325b3c7e3900133578815f04d219972a1
0398e171f206cd3b140a358ac31b0a3760380df1 25-Jul-2014 Jeff Hao <jeffhao@google.com> Fix proxy tracing and enable tests that now work with tracing.

Bug: 16386215
Change-Id: Iec2a372c921caceb050c6baf72d48b3d822899a4
22e59fd2861a4aab16adb2b80a1d5166382a6617 24-Jul-2014 Andreas Gampe <agampe@google.com> ART: Allow arrays with erroneous component type

Array classes must tolerate having component type classes that are
erroneous. Change CreateArrayClass to use LookupClass when FindClass
failed.

Bug: 16019155

(cherry picked from commit dc13d7df5da49e93963035633a82699c68fa0971)

Change-Id: I506250949a1802898433e9099dcb8ef31dd89659
dc13d7df5da49e93963035633a82699c68fa0971 24-Jul-2014 Andreas Gampe <agampe@google.com> ART: Allow arrays with erroneous component type

Array classes must tolerate having component type classes that are
erroneous. Change CreateArrayClass to use LookupClass when FindClass
failed.

Bug: 16019155
Change-Id: Id4868c5498431c85c199aa3cbecd23566dce3601
167cc7c33f7100e3f7acc1594c066daa0122e27a 29-Jul-2014 Nicolas Geoffray <ngeoffray@google.com> Revert "Fix proxy tracing and enable tests that now work with tracing."

This reverts commit 0398e171f206cd3b140a358ac31b0a3760380df1.

Change-Id: I1346ab01485cc7207be0ecb4d8788c500c0df903
1a12858eb15a14788478c4aca82c052bc84fcafa 23-Jul-2014 Mingyao Yang <mingyao@google.com> Fix build, missing spaces around =/<.

Change-Id: I2e7824075626a07eccb0a5eb77ef157214fe70fb
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
a59dd80f9f48cb750d329d4d4af2d99d72b484d1 03-Jul-2014 Alex Light <allight@google.com> Runtime can now be set to require relocation

Add a pair of runtime flags -Xrelocate and -Xnorelocate that can force
the runtime to require that all files that are run are relocated, to
prevent attacks based on the known art base address.

Add support for running patchoat on oat files compiled without an image.

Change run-test to have new --prebuild and --relocate flags.

Bug: 15358152

Change-Id: I91166c62dd1ab80e5cbcb7883a2cd0d56afca32d
1e5bc0bc5257cb1fce5fe71a1b922527fe6b8fa4 17-Jul-2014 Calin Juravle <calin@google.com> Fix bad comment in class_linker

(cherry picked from commit ff5a372be9b5ecaa4c3a9887f064a8a98069d036)

Change-Id: I04b2156fbd85929b082097e6faab8097552744c3
c114b5fbc91e6d19ef430d9bc3468386ca61b324 21-Jul-2014 Ian Rogers <irogers@google.com> Fix erroneous behaviors with OOME present.

Bug: 16454510
Change-Id: I757088a7b82ff73f58aba8d357080028b56442e6
ecd4d9adc1e2b2ac1367de9a2dc1ca15ebf4310c 22-Jul-2014 Ian Rogers <irogers@google.com> Avoid marking erroneous classes as erroneous twice.

Change-Id: I1f340a6054cf36f6b4ba7d85cfd05b1c677dced7
0fbd6e6ec3241b7163b95f9f001bfe9b08f8b200 18-Jul-2014 Hiroshi Yamauchi <yamauchi@google.com> Fix two read barrier bugs introduced in CL 97882.

Bug: 12687968
Change-Id: Ib28da4c33977cc58b09913ef5b738dec75365714
ff5a372be9b5ecaa4c3a9887f064a8a98069d036 17-Jul-2014 Calin Juravle <calin@google.com> Fix bad comment in class_linker

Change-Id: Ic8c90e9d880c5aae7e7bdb6c2a0c854fdaa5c357
39c86bc9de106e3641ecab2374a24e41d0430694 16-Jul-2014 Calin Juravle <calin@google.com> Make ART fail gracefully when it can't update the desired code.

ART was exiting with a fatal error when it couldn't clean an obsolete
file. Relaxing this and failing gracefully preserves the behaviour that
Dalvik had.

Bug: 15313272

(cherry picked from commit c54aea7f4acd1a32bb298d43c20e3e0217638926)

Change-Id: I862a8925a0edd6370e94af8fa984a64099240029
d85614222fa062ec809af9d65f04ab6b7dc1c248 11-Jul-2014 Fred Shih <ffred@google.com> Revert "Revert "Revert "Revert "Add intrinsic for Reference.get()""""

Fixed TargetReg issue causing build failure for x86.
This reverts commit 9e82bd3f0ce9e5f5777bea2f752ff3e251d32f9f.

(cherry picked from commit 4ee7a665e7f9cd2c5ace2d6304e33f64067b209f)

Change-Id: I555f4e06955711262e6b37ffbeabee9698ec695c
c54aea7f4acd1a32bb298d43c20e3e0217638926 16-Jul-2014 Calin Juravle <calin@google.com> Make ART fail gracefully when it can't update the desired code.

ART was exiting with a fatal error when it couldn't clean an obsolete
file. Relaxing this and failing gracefully preserves the behaviour that
Dalvik had.

Bug: 15313272
Change-Id: I8d0d6d374c90d2a434909dd4ae56f0799f30134d
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
4ee7a665e7f9cd2c5ace2d6304e33f64067b209f 11-Jul-2014 Fred Shih <ffred@google.com> Revert "Revert "Revert "Revert "Add intrinsic for Reference.get()""""

Fixed TargetReg issue causing build failure for x86.
This reverts commit 9e82bd3f0ce9e5f5777bea2f752ff3e251d32f9f.

Change-Id: I7e6a526954467aaf68deeed999880dfe9aa5f06e
22f8e5c82d12951be38cd893426e13bee33fd69d 09-Jul-2014 Andreas Gampe <agampe@google.com> Revert "Revert "ART: Key-Value Store in Oat header""

This reverts commit 452bee5da9811f62123978e142bd67b385e9ff82.

Heap-allocate a couple of objects in dex2oat to avoid large frame
size.

Includes fixes originally in 100596 and 100605.

Change-Id: Id51a44198c973c91f0a3f87b9d992a5dc110c6f8
98d1cc8033251c93786e2fa8c59a2e555a9493be 16-May-2014 Mingyao Yang <mingyao@google.com> Improve performance of invokevirtual/invokeinterface with embedded imt/vtable

Add an embedded version of imt/vtable into class object. Both tables start at
fixed offset within class object so method/entry point can be loaded directly
from class object for invokeinterface/invokevirtual.

Bug: 8142917
Change-Id: I4240d58cfbe9250107c95c0708c036854c455968
a9b870b73a155ce70c867d5b3f9758fab0b45f07 11-Jul-2014 Christopher Ferris <cferris@google.com> Revert "Add intrinsic for Reference.get()"

This reverts commit 460503b13bc894828a2d2d47d09e5534b3e91aa1.

Change-Id: Ie63f43049307e02e3b90f4e034abc9ea54ca4e24
d4415e8bd04c4a9367744ff0149597b4f37a0e0a 11-Jul-2014 Christopher Ferris <cferris@google.com> Revert "Revert "Add intrinsic for Reference.get()""

This reverts commit a9b870b73a155ce70c867d5b3f9758fab0b45f07.

Change-Id: Ic2a9b47f2b911bef4b764d10bc33cf000e4b4211
9e82bd3f0ce9e5f5777bea2f752ff3e251d32f9f 11-Jul-2014 Sebastien Hertz <shertz@google.com> Revert "Revert "Revert "Add intrinsic for Reference.get()"""

This reverts commit d4415e8bd04c4a9367744ff0149597b4f37a0e0a.

Change-Id: I34553ccbdcfea35c7742d21be2a74dc7085ab2a0
460503b13bc894828a2d2d47d09e5534b3e91aa1 18-Jun-2014 Fred Shih <ffred@google.com> Add intrinsic for Reference.get()

Added an intrinsic function for Reference.get(). Return immediately
without going through JNI if the slow path is not currently in use.
Otherwise, branch off to the the existing JNI function.

Approximately 47x speedup for cases where slow path is not enabled.

Change-Id: I13ad65a356fe4e104d8d83980694dc2740d7d039
c87d27b25994da8670d82a8f7bad6327b693bfff 27-Jun-2014 Andreas Gampe <agampe@google.com> ART: Key-Value Store in Oat header

Allows the storage of string-string pairs in the oat header. The
first significant use of this is storing the implicit-check flags,
so that an oat file can be rejected if it doesn't agree with the
current runtime.

Bump the oat version as the header structure changes.

Change-Id: I15a1c16886e6b8fa7b881c918c19c1efa5c7c00f
670134e8555d40fc880271b1ab97483094b4b816 08-Jul-2014 Brian Carlstrom <bdc@google.com> Make dex2oat heap size product configurable [art]

Bug: 15919420
Change-Id: I1b4f3256f6352b2d3e268991406def9e8efab945
452bee5da9811f62123978e142bd67b385e9ff82 09-Jul-2014 Nicolas Geoffray <ngeoffray@google.com> Revert "ART: Key-Value Store in Oat header"

Broke arm64 build.

This reverts commit c87d27b25994da8670d82a8f7bad6327b693bfff.

Change-Id: I4c2ade295d2b5aa77fc3ad810e0e859629a5bf09
833a48501d560c9fa7fc78ef619888138c2d374f 22-May-2014 Andreas Gampe <agampe@google.com> ART: Native support for multidex

Native support for zip files with multiple classesX.dex.

Works by explicitly looking for those files in ascending order. As
these files have no file system representation for themselves,
introduce synthetic dex locations: the name of the originating file
plus a colon plus the name of the dex file, e.g., test.jar:classes2.dex.

Opening a zip dex file will return all dex files in this way. This
keeps the changes to dex2oat minimal.

To hide multidex/synthetic names from the Java layer, let the handle
of dalvik.system.DexFile refer to a vector of DexFile objects. When
opening a location, test possible synthetic names and add them to the
vector. Thus, the original multidex jar in the classpath will be
associated with all embedded dex files.

Change-Id: I0de107e1369cbc94416c544aca3b17525c9eac8b
e9e3e697f0c426132bee10aaa6aee9107d2d7dc6 24-Jun-2014 Hiroshi Yamauchi <yamauchi@google.com> Add more read barriers to the class linker.

This change makes it possible to concurrently scan the remaining roots
in the class linker (the non-class-table roots that are visited by
ClassLinker::VisitRoots()) by adding read barriers.

Bug: 12687968
Change-Id: I66fecf7a303eee7537429e018f38da8270b18c67
52e4b43d62896b56f8c2bd041e528472bb4a0d8d 10-Jun-2014 Mathieu Chartier <mathieuc@google.com> Add mark compact collector.

The mark compact collector is a 4 phase collection, doing a normal
full mark_sweep, calculating forwarding addresses of objects in the
from space, updating references of objects in the from space, and
moving the objects in the from space.

Support is diabled by default since it needs to have non movable
classes and field arrays. Performance numbers is around 50% as fast.

The main advantage that this has over semispace is that the worst
case memory usage is 50% since we only need one space isntead of two.

TODO: Make field arrays and classes movable. This causes complication
since Object::VisitReferences relies on these, so if we update the
fields of an object but another future object uses this object to
figure out what fields are reference fields it doesn't work.

Bug: 14059466

Change-Id: I661ed3b71ad4dde124ef80312c95696b4a5665a1
a91a4bc1f8960f64c5f7e4616d46e21b8e1bfba2 14-Jun-2014 Hiroshi Yamauchi <yamauchi@google.com> Add read barriers for the class and the intern tables.

Add read barriers for the strong roots in the intern table and the
(strong) roots in the class table to make possible concurrent scanning
of them.

Bug: 12687968
Change-Id: If6edc33a37e65a8494e66dc3b144138b1530367f
d1c606f280797be81e2592c483869a6ec836a9f3 09-Jun-2014 Narayan Kamath <narayan@google.com> Add locking around boot image generation.

If zygote aborts due to an error, it will restart and
spawn another dex2oat process while the old one is still
running. If this happens fast enough, the system will
eventually need a kernel reboot since neither the zygote
nor dex2oat are killable.

This brings boot image generation in line with dex2oat
generation, which uses a similar pattern of advisory
locking.

bug: 15415316

Change-Id: Iaccd274d3d96ab002b04e246ec4b3ef9a422ff7c
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
ffddfdf6fec0b9d98a692e27242eecb15af5ead2 03-Jun-2014 Tim Murray <timmurray@google.com> DO NOT MERGE

Merge ART from AOSP to lmp-preview-dev.

Change-Id: I0f578733a4b8756fd780d4a052ad69b746f687a9
12e6d7446384a7a5fbec25fe116bbb271c62842e 22-May-2014 Tsu Chiang Chuang <tsu@google.com> Add option to specify compiler executable.

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

Fixed the generic trampoline to not use ToJObject when unnecessary.

Bug: 15167269

This reverts commit 3bdb873122964da7937eb070cbcf2ef638a8e459.

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

This reverts commit e09ae0920be57760fb390b6944bce420fa0b5582.

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

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

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

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

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

Change-Id: I1b51723920a2e4f4f8b2907066f578a3e879fd5b
f3632835c8d643632e6d1af403b4a5c309133e08 21-May-2014 Brian Carlstrom <bdc@google.com> Add context to LinkFields asserts since the previous_size check failed

Change-Id: If7a6c4219f52fd772141e6f070bb7d9a1d9464c0
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
2b7c4d196c8abe32f4ca633534917da9de53c359 19-May-2014 Mathieu Chartier <mathieuc@google.com> Don't get and restore thread state for ScopedFastNativeObjectAccess.

Before we would ensure that we were runnable for fast native object
access. However, these are done when you are already runnable.

Change-Id: Ia4c6e4c83d146fe2a988b37b3133ca46b0f0fa42
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
f0972a410a0665dbe32bd96df09a572d69f9f3a3 16-May-2014 Dmitry Petrochenko <dmitry.petrochenko@intel.com> Fix generic jni issue in ArtMethod::GetQuickFrameInfo

The 64-bit host mode fails to start due to incorrect
detection of GetQuickGenericJniTrampoline.
The quick_code is 32-bit and taken from oat file, but
GetQuickGenericJniTrampoline returnf 0x7fffxx (64-bit)
address of trampoline and execution went to incorrect way.

Some clean-up.

Original Author: Dmitry Petrochenko <dmitry.petrochenko@intel.com>
Signed-off-by: Dmitry Petrochenko <dmitry.petrochenko@intel.com>
Signed-off-by: Serguei Katkov <serguei.i.katkov@intel.com>
Change-Id: I0952443b2a9f6833ad37ec373837ae208681fad7
0e12bdc49744eb6d5c29b9611a8dbe10bac4cd53 15-May-2014 Brian Carlstrom <bdc@google.com> Add ISA directory to image and odex pathnames.

Bug: 14882223
Bug: 14694978
Change-Id: Ic1b5ae836b8e91ea461dcd4f3da8e38dc3bec00f
db2633ce0358c704f97130a94b582602cb01d14a 16-May-2014 Mathieu Chartier <mathieuc@google.com> Change ObjectLock to take Handle instead of Handle pointer.

Change-Id: I9abdcdc5c9c9174634336b9250ab24c6aee434ec
507dfdd147c97bfbadebfd63584d094b6a4e7b47 16-May-2014 Ian Rogers <irogers@google.com> Compatibility layer to transition from UniquePtr to std::unique_ptr.

Use ART_WITH_STLPORT (enabled for the target) to cause the use of UniquePtr,
for the host switch to std::unique_ptr. For now the type remains called
UniquePtr.
Make dalvik compile with clang on the host, move its build to C++11.

Change-Id: I5ba8d2757904bc089ed62047ea03de3c0853fb12
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
7624d25dad2d1ba25969ae704fccf68649103ae5 02-May-2014 Vladimir Marko <vmarko@google.com> Move quick frame info to OatQuickMethodHeader.

Rename OatMethodHeader to OatQuickMethodHeader, move frame
info from OatMethodOffsets to OatQuickMethodHeader. Retrieve
the info from other places for non-quick methods (portable
compiled bytecode or jni stub, generic jni, runtime,
abstract and proxy).

This change has a libcore/ companion CL
"Remove ArtMethod's quick fields for frame size and spills."
https://android-review.googlesource.com/94164

Bug: 11767815
Change-Id: I0e31a7875d76732e1ec479c86b9b5ca01203507f
151f2214d95f6003fe067fa2ebcd8ddad11e735c 06-May-2014 Ian Rogers <irogers@google.com> Improve ValidateSuperClassDescriptors performance.

ValidateSuperClassDescriptors uses FindClass with the 2 class loaders that are
being used in validating method parameter types. The use of 2 class loaders
ensures at least one miss with LookupClass and thereby a call to
ClassLoader.loadClass which will then defer to the parent class loader eating
time. This change modifies the behavior to instead lookup types with a dex
cache, so that resolution and load class are only performed once per type.

Bug: 12804658
Change-Id: Ia7be1f7bab8175a6934fd59fc54e0829beed0198
5d27fafdf03f259e92eaee9f6319b9349cc8d62e 03-May-2014 Ian Rogers <irogers@google.com> Allow ArtMethod::Invoke in unstarted runtimes.

Change-Id: I0141f4daef4751589d03d27484eb65c811b14f27
52f84884433f3875f4b1bc5595b8d5a2d6fb3d99 02-May-2014 Narayan Kamath <narayan@google.com> Prevent spurious dexopts in 32-64 builds.

When we're checking if a file needs to be dexopted, we
need to compare oat file checksums with the image checksum
for the oat file's target instruction set and not the current
runtime's target instruction set.

bug:14475807

Change-Id: Ib44d8e3c6cdf3a37fce6332c694a6602c658e925
64e7ac0bcc2ea96c0e09fe3f4c86a5ad755a975c 01-May-2014 Vladimir Marko <vmarko@google.com> Don't leak oat file when we fail to open a dex file.

Change-Id: I929b34d240d2052d1eea8344b6fa79646920a4c1
11d9f06a96a6909905c248ed684366190140095c 23-Apr-2014 Narayan Kamath <narayan@google.com> Use instruction specific dalvik cache dirs.

- All oat & art files are now placed under /data/dalvik-cache/<isa>/.
- GetDalvikCacheOrDie now requires a mandatory subdirectory argument,
and is implicitly rooted under /data/.
- Added helper methods to convert InstructionSet enums into strings
and vice versa.

(cherry picked from commit 2974bc3d8a5d161d449dd66826d668d87bdc3cbe)

Change-Id: Ic7986938e6a7091a2af675ebafec768f7b5fb8cd
2974bc3d8a5d161d449dd66826d668d87bdc3cbe 23-Apr-2014 Narayan Kamath <narayan@google.com> Use instruction specific dalvik cache dirs.

- All oat & art files are now placed under /data/dalvik-cache/<isa>/.
- GetDalvikCacheOrDie now requires a mandatory subdirectory argument,
and is implicitly rooted under /data/.
- Added helper methods to convert InstructionSet enums into strings
and vice versa.

Change-Id: I9bff2e2ca534e0b93842a50d5b272ddf6d5745f3
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
8a630577ed2d9e9571c3434c505e5de223b23c07 09-Apr-2014 Vladimir Marko <vmarko@google.com> Move mapping table and vmap table offsets to OatMethodHeader.

This change has a libcore/ companion CL
"Remove ArtMethod's quick fields mapping table and vmap table."
https://android-review.googlesource.com/91254

Bug: 11767815
Change-Id: I46ce2067e1ecd915da3890606498e31ffc332813
d3c5bebcb52a67cb06e7ab303eaf45f230c08b60 11-Apr-2014 Vladimir Marko <vmarko@google.com> Avoid allocating OatFile::OatClass on the heap.

Avoid allocating a BitVector for OatFile::OatClass::bitmap_
with kOatClassSomeCompiled methods. That makes the OatClass
copy-constructible as it doesn't own any memory. We use that
in OatFile::OatDexFile::GetOatClass() to return the result
by value thus avoiding one or two heap allocations per call.

Change-Id: Ic7098109028a5b49e39ef626f877de86e732ed18
7ec2f1ca3cbd021848da75d5566f7239ce29676f 27-Mar-2014 Sebastien Hertz <shertz@google.com> Speed up single-stepping

During single-stepping sequence, we need to deoptimize everything when we
register a single-step event and undeoptimize everything when it is done. This
causes a slow pattern where we continuously deoptimize-undeoptimize everything
for each single-step.

This CL introduces a special handling of single-step undeoptimization. We now
delay the undeoptimization to the next resume (one thread or all threads) or
the end of the debugging session. Indeed, a single-step event registration is
always followed by a resume command.
At the "resume" point, we know if a single-step event is registered and if we
really need to undeoptimize. At the "registration" point, we know we did not
undeoptimized everything so we don't need to deoptimize everything again.
Therefore, in a sequence of single-steps, we only do a full deoptimization for
the first single-step and a full undeoptimization for the last single-step.

We update logs at deoptimization points so we can track more precisely. Note
they are verbose logs that still must be enabled with -verbose:jdwp option.

We also make some improvement inside instrumentation:
* updates Instrumentation::ShouldNotifyMethodEnterExitEvents to comply with its
name.
* compute frame id only once when looking for the corresponding instrumentation
frame.
* compute the OatMethod once in ClassLinker::GetPortableOatCodeFor to avoid
looking for it again.

Bug: 13577964
Change-Id: If6fa198a676b515cd474b8c4d7bf7ef3626f2dc7
329d18806792771dfee064203fe27875d79cd53a 08-Apr-2014 Andreas Gampe <agampe@google.com> Better error reporting when loading dex files

Collect all partial error messages and return them as cause
exceptions for the top-level exception returned.

Change-Id: I9661b8aed2a571dc88bf0f06d447108eeaed1409
4cd662e54440f76fc920cb2c67acab3bba8b33dd 04-Apr-2014 Hiroshi Yamauchi <yamauchi@google.com> Fix Object::Clone()'s pre-fence barrier.

Pass in a pre-fence barrier object that sets in the array length
instead of setting it after returning from AllocObject().

Fix another potential bug due to the wrong default pre-fence barrier
parameter value. Since this appears error-prone, removed the default
parameter value and make it an explicit parameter.

Fix another potential moving GC bug due to a lack of a SirtRef.

Bug: 13097759
Change-Id: I466aa0e50f9e1a5dbf20be5a195edee619c7514e
4a200f56b7075309316b04d550c9cc50f8314edd 01-Apr-2014 Jeff Hao <jeffhao@google.com> Add support for -Xverify:none mode.

This mode skips all verification and compilation.
Public bug: https://code.google.com/p/android/issues/detail?id=67664

Change-Id: Idd00ab8e9e46d129c02988b063c41a507e07bf5b
8afeb85d3def12b559b7565fb6d3956f81b55132 02-Apr-2014 Ian Rogers <irogers@google.com> Pass instruction-set from runtime through to spawned dex2oat.

Change-Id: I1727af7beb9f710c29124d4d6bc9175e4856f3cc
624468cd401cc1ac0dd70c746301e0788a597759 01-Apr-2014 Hiroshi Yamauchi <yamauchi@google.com> Make the support code for read barriers a bit more general.

Add an option for Baker in addition to Brooks.

Bug: 12687968
Change-Id: I8a31db817ff6686c72951b6534f588228e270b11
62f0512bf6d9bc6141358bf22e93afa70dc58b1a 21-Mar-2014 Ian Rogers <irogers@google.com> Improvements to Field.get/set.

Avoid unnecessary repeated computation in Field.get/set.
Refactor FromReflectedField and FromReflectedMethod into common helpers in
mirror::ArtField and mirror::ArtMethod, and make use of thereby avoiding
transitions through JNI.
Avoid JNI use from within FromReflectedField and FromReflectedMethod.
Tidy up Field.get/set wrt moving collector support.
Bug: 12189533

Change-Id: I643ab3474bade4abac3a3ae2b6e373b2bb0891c8
8fa2dad7fe7909c8335101d6c8904ae997cdf29f 13-Mar-2014 Mathieu Chartier <mathieuc@google.com> Refactor reference code into mirror namespace.

Added two new files: mirror/reference.h and mirror/reference-inl.h.

Change-Id: Ibe3ff6379aef7096ff130594535b7f7c0b7dabce
9a6a99aaac2e4c973e0bc71075f196b8b084100f 14-Mar-2014 Andreas Gampe <agampe@google.com> Remove small duplicate code in Generic JNI handling, add comments

Change-Id: Ib276fa63b6a00480eaaff6c352d37917c61e966c
90546836312adda54f28b700f25ff29ec8becdf8 13-Mar-2014 Andreas Gampe <agampe@google.com> Fixes for Generic JNI

This fixes some linking issues and native code retrieval errors.
All host tests are functional with this change.

Make ArtMethod::GetFrameSizeInBytes() templated to bypass the
embedded sanity check. Necessary for fix-up decision.

Add ArtMethod metadata fix-up code to ClassLinker::LinkCode.
Necessitates new parameters to access the shorty and compute
the frame size.

Fix handling the JNI dlsym lookup stub in the generic JNI code.

Change-Id: I4173b0fbb1ba5b1bcbee1bb340cfdd08a54767e5
b373e091eac39b1a79c11f2dcbd610af01e9e8a9 21-Feb-2014 Dave Allison <dallison@google.com> Implicit null/suspend checks (oat version bump)

This adds the ability to use SEGV signals
to throw NullPointerException exceptions from Java code rather
than having the compiler generate explicit comparisons and
branches. It does this by using sigaction to trap SIGSEGV and when triggered
makes sure it's in compiled code and if so, sets the return
address to the entry point to throw the exception.

It also uses this signal mechanism to determine whether to check
for thread suspension. Instead of the compiler generating calls
to a function to check for threads being suspended, the compiler
will now load indirect via an address in the TLS area. To trigger
a suspend, the contents of this address are changed from something
valid to 0. A SIGSEGV will occur and the handler will check
for a valid instruction pattern before invoking the thread
suspension check code.

If a user program taps SIGSEGV it will prevent our signal handler
working. This will cause a failure in the runtime.

There are two signal handlers at present. You can control them
individually using the flags -implicit-checks: on the runtime
command line. This takes a string parameter, a comma
separated set of strings. Each can be one of:

none switch off
null null pointer checks
suspend suspend checks
all all checks

So to switch only suspend checks on, pass:
-implicit-checks:suspend

There is also -explicit-checks to provide the reverse once
we change the default.

For dalvikvm, pass --runtime-arg -implicit-checks:foo,bar

The default is -implicit-checks:none

There is also a property 'dalvik.vm.implicit_checks' whose value is the same
string as the command option. The default is 'none'. For example to switch on
null checks using the option:

setprop dalvik.vm.implicit_checks null

It only works for ARM right now.

Bumps OAT version number due to change to Thread offsets.

Bug: 13121132
Change-Id: If743849138162f3c7c44a523247e413785677370
1a5706611bffa5d6ed6843ee5e320f504590e097 12-Mar-2014 Ian Rogers <irogers@google.com> A few 64bit fixes.

Change-Id: I1fe189d638b9cb5127b897da6cecdad6902db930
bf6b92a158053c98b15f4393abb3b86344ec9a20 06-Mar-2014 Andreas Gampe <agampe@google.com> Generic JNI implementation for x86_64

Starting implementation for generic JNI on x86_64. Frames are of
large static size (>4K) right now, should be compacted later. Passes
the whole of jni_compiler_test.

Change-Id: I88ac3e13a534afe7568d62a1ef97cb766e8260e4
2ec6520d57479d393bffa05defa1479b25ca8382 04-Mar-2014 Brian Carlstrom <bdc@google.com> Support compiler filters for boot classpath

image_writer.cc
Remove assumption that all methods in the boot classpath are compiled

oat_writer.cc
Don't skip writing ArtMethod::quick_code_offset_ for methods that need resolution, leave that to ImageWriter

dex2oat.cc
Allow dex2dex compilation of image dex files by making the in memory pages writable in all cases, not just app case.

oatdump.cc
dump new OatHeader fields
use ImageSpace.GetImageFilename, not command line image filename, since location may be in dalvik-cache
remove inaccurate check about non-null GC map

quick_trampoline_entrypoints.cc
add and improve some DCHECKS that were useful while debugging

class_linker.cc
image_space.cc
fix double facepalm

parsed_options.cc
fix zygote logging to not skip values to two part options like -classpath <foo>

runtime.cc
wireup parsed compiler options to runtime

Change-Id: Iad314df0b80623c0663d61713d5098297ab9ac87
893263b7d5bc2ca43a91ecb8071867f5134fc60a 04-Mar-2014 Mathieu Chartier <mathieuc@google.com> Avoid marking old class linker and intern table roots during pause.

The new root visiting logic has a concept of a root log which holds
new roots which were added since the start of the GC. This is an
optimization since it lets us only mark these newly added roots
during the pause (or pre-cleaning) since the other roots intern table
and class linker roots were marked concurrently at the start of the
GC.

Before (EvaluateAndApplyChanges):
MarkConcurrentRoots: Sum: 605.193ms
After:
MarkConcurrentRoots: Sum: 271.858ms

This should also reduce pathological GC pauses which used to be able
to happen when the intern table or class linker became "dirty"
during the concurrent GC.

Change-Id: I433fab021f2c339d50c35aaae7161a50a0901dec
9583fbcf597eff6d0b3c5359b8e8d5f70ed82c40 28-Feb-2014 Nicolas Geoffray <ngeoffray@google.com> Remove oat file location in the image.

The oat file is now always in the same directory, and has the
same name as the image file. Only difference is the extension.

This also removes the need for host-prefix.

Change-Id: I16d1f7aeb1d58372d41921694664e9c321afc1ad
2da882315a61072664f7ce3c212307342e907207 27-Feb-2014 Andreas Gampe <agampe@google.com> Initial changes towards Generic JNI option

Some initial changes that lead to an UNIMPLEMENTED. Works
by not compiling for JNI right now and tracking native methods
which have neither quick nor portable code. Uses new trampoline.

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

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

Change-Id: Id5760041a2d7f94dcaf17ec760f6095ec75dadaa
9d04a20bde1b1855cefc64aebc1a44e253b1a13b 31-Jan-2014 Hiroshi Yamauchi <yamauchi@google.com> (Experimental) Add Brooks pointers.

This feature is disabled by default.

Verified that the Brooks pointers are installed correctly by using the
CMS/SS collectors.

Change-Id: Ia9be9814ab6e29169ac85edc4792ce8c81d552a9
4cf5e57b5ec366b8730dacd45e8011e5f9b07b6d 25-Feb-2014 Brian Carlstrom <bdc@google.com> Move waitpid(2) includes to art::Exec implementation

(cherry picked from commit 446a13ff04dae7ef9c90584e7cf8e834ee841681)

Change-Id: Id5fe3dd8e6c4cef953c39b00f2a53b23da5a6247
35d8b8e0f6d174108b5e94ec2e49cf3c6a0c72c3 25-Feb-2014 Brian Carlstrom <bdc@google.com> Avoid going through char* for std::string API

Bug: 13186058

(cherry picked from commit 14ae4a873e91ae8cb1c00013579b5b058268879d)

Change-Id: Ib529cc10abc2d413e9da65c043dbc2638b734acd
97ae85853c8ac39cc71a67c820d76ebc2b2cab20 25-Feb-2014 Brian Carlstrom <bdc@google.com> Avoid going through char* for std::string API

Bug: 13186058
Change-Id: Idd58b15428e8849a93c1f57a9819fcb514f1545d
14ae4a873e91ae8cb1c00013579b5b058268879d 25-Feb-2014 Brian Carlstrom <bdc@google.com> Avoid going through char* for std::string API

Bug: 13186058
Change-Id: Idd58b15428e8849a93c1f57a9819fcb514f1545d
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
6449c62e40ef3a9bb75f664f922555affb532ee4 11-Feb-2014 Brian Carlstrom <bdc@google.com> Create CompilerOptions

Package up most compiler related options in CompilerOptions. Details include:
- Includes compiler filter, method thresholds, SEA IR mode.
- Excludes those needed during Runtime::Init such as CompilerCallbacks and VerificationResults.
- Pass CompilerOptions to CompilerDriver.
- Remove CompilerOptions from Runtime.
- Add ability to pass options for app and image dex2oat to runtime via
-Xcompiler-option and -Ximage-compiler-option respectively.

Other
- Replace 2x CompilerCallbacks implementations with one.
- Factor out execv code for use by both image and oat generation.
- More OatFile error_msg reporting.
- DCHECK for SuspendAll found trying to run valgrind.

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

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

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

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

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

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

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

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

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

Bug: 12934910
Bug: 12879358

Change-Id: Ic61033104dfc334543f89b0fc0ad8cd4f4015d69
073278cd7129ff07dbcd6ccfabd2c34f47ec92ad 20-Feb-2014 Brian Carlstrom <bdc@google.com> Do not FixupStaticTrampolines of uninitialized classes

Bug: 13027732
Change-Id: I5966d63afd8fbcd091801297290f117f3c9cb44c
815873ecc312b1d231acce71e1a16f42cdaf09f2 14-Feb-2014 Mathieu Chartier <mathieuc@google.com> Change root visitor to use Object**.

Simplifies code and improves the performance of root visiting since
we usually don't need to check to see if the object moved.

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

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

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

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

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

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

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

Bug: 9676614
Change-Id: I221910a9183a5ba6c2b99a277f5a5a68bc69b5f9
0177e53ea521ad58b70c305700dab32f1ac773b7 12-Feb-2014 Ian Rogers <irogers@google.com> Work in the direction of hard float quick ABIs.

Pass a shorty to ArtMethod::Invoke so that register setup can use it.
Document x86-64 ABI.
Add extra debug output for one JNI native method registration fails, namely a
dump of the Class and its dex file's location.
Add hack to get testing of OatMethod's without GC maps working in 64bit.

Change-Id: Ic06b68e18eac33637df2caf5e7e775ff95ae70f3
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
b60847e72d040bf5e08b787d4b63708f7a506a31 06-Feb-2014 Brian Carlstrom <bdc@google.com> Merge "Fix apps with more than one dex file with the same name"
0d6adac2550113da33d42e88f0d87a57b25c5a60 06-Feb-2014 Brian Carlstrom <bdc@google.com> Fix apps with more than one dex file with the same name

Reverts most of 60836d5a9bcf8b30984aae4279a4f6233b0bf622 which I
believe was an incorrect attempt to address issue introduced in
8d31bbd3d6536de12bc20e3d29cfe03fe848f9da, which is also reverted here.

Also adds some debugging aids include operator<< for DexFile and
MemMap and checksum information to OatFile logging.

Bug: 12802375
Change-Id: Idd6f7dd487f6e01e9479cd15cd4b61580160e8a3
c0a9ea40237de8fa3c623f68c904d416a3a79bf5 04-Feb-2014 Mathieu Chartier <mathieuc@google.com> Add missing SIRT to CreateArrayClass.

component_type was not guarded by a SIRT. This meant that it could
point to a stale object if AllocClass caused a GC.

Bug: 12875306
Change-Id: I387aa53cf461349b183360c37ff69bffbfe54041
1d27b34d3b18a5a0c832dae9768366dc08ef8d1c 28-Jan-2014 Mathieu Chartier <mathieuc@google.com> Change DisableGC to DisableMovingGC.

Also removed the WaitForConcurrentGC in IncrementDisableMovingGC
since we do not currently support any type of concurrent moving
collectors.

This fixes the performance regression introduced by waiting for the
concurrent GC which manifested itself in framework perf benchmarks
as a result of background compaction.

Change-Id: I524f9ab52e1992419626a27649f232ca6967b03d
23a282146042a0d171aec2a415176f5d0621a90c 09-Jan-2014 Vladimir Marko <vmarko@google.com> Clean up access checks.

Change-Id: Ia62ba6c8f1d0a9bfbbfde2d7be4c52c0f982b9d2
60836d5a9bcf8b30984aae4279a4f6233b0bf622 16-Jan-2014 Vladimir Marko <vmarko@google.com> Fix opening oat files that are out of date.

Make sure we're not using an old MAP_PRIVATE mapping of an
OatFile after a forked process modifies the underlying file.

Change-Id: I5c6caaf34272c805e40e95ee690dd948d7406751
5ddb4104ac605d66693b55b79f26f8b8a5505e63 07-Jan-2014 Ian Rogers <irogers@google.com> Remove intialized static storage from dex cache.

The initialized static storage array is used by compiled code to determine if
for a sget/sput class initialization is necessary. The compiled code typically
doesn't require this test as the class is pre-initialized or the class being
accessed is the same as the current method.

Change-Id: Icbc45e692b3d0ac61e559e69edb6c9b29439e571
801a811c2c59704d326dcde440e58d84ebb22b25 06-Jan-2014 Vladimir Marko <vmarko@google.com> Remove duplicate/unnecessary code from ClassLinker.

Change-Id: I986c3aa36cb63ae5ea099680e8e4c42bdf891ef1
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
22cb09b35e8eb30c016065f0eec4b3b96666de43 12-Dec-2013 Jeff Hao <jeffhao@google.com> Add class to verifier's rejected list if superclass is erroneous.

This will prevent the compiler from trying to compile one of these
classes, which will fail because it has no GC map.

Bug: 12104117
Change-Id: I77ec77d30ee5dc92d7f4c594f1e8f1ce9b67855d
08cbf66dc4632913f80f8ac18082c39b7d52c7dd 11-Dec-2013 Brian Carlstrom <bdc@google.com> Do not require classes.dex to support stripped zip files

Change-Id: Ief34c1b559dbebda85d181ae49da7d35446c9b37
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
cbb2d20bea2861f244da2e2318d8c088300a3710 15-Nov-2013 Mathieu Chartier <mathieuc@google.com> Refactor allocation entrypoints.

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

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

Rosalloc measurements:
4583
4453
4439
4434
4751

After change:
4184
4287
4131
4335
4097

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

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

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

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

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

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

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

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

Bug: 8981901

Change-Id: I3c886fd322a6eef2b99388d19a765042ec26ab99
610e49f5adc8b5e4a37696aa20fc029dab6b1e40 05-Nov-2013 Brian Carlstrom <bdc@google.com> Fix typo in duplicate condition

Bug: https://code.google.com/p/android/issues/detail?id=61768
Change-Id: I65b85de1d942c5bd0dfd6a8f7b67e157c066b9f6
dfb325e0ddd746cd8f7c2e3723b3a573eb7cc111 30-Oct-2013 Ian Rogers <irogers@google.com> Don't use UTF16 length as length for MUTF8.

Bug 11367555.

Change-Id: Ia0b07072a1a49d435c3b71ed9a668b316b7ff5d8
88474b416eb257078e590bf9bc7957cee604a186 24-Oct-2013 Jeff Hao <jeffhao@google.com> Implement Interface Method Tables (IMT).

Change-Id: Idf7fe85e1293453a8ad862ff2380dcd5db4e3a39
79b4f38dd35b83206e8166aaafb94bd75c3318b3 24-Oct-2013 Mathieu Chartier <mathieuc@google.com> Fix incorrect initial dex cache size.

We were previously setting it to be sizeof(DexCacheClass) instead
of sizeof(DexCache). This was causing some problems with
compaction when I relied on the object sizes being accurate to
visit objects in the bump pointer space.

Bug: 8981901
Change-Id: Iede04763aced041986b1b239368fc867143ad70d
8d31bbd3d6536de12bc20e3d29cfe03fe848f9da 13-Oct-2013 Ian Rogers <irogers@google.com> Throw IOException at source of failing to open a dex file.

Before is:
java.lang.ClassNotFoundException: Didn't find class "GCBench" on path: DexPathList[[zip file "/disk2/dalvik-dev/out/host/linux-x86/framework/GCBench.jar"],nativeLibraryDirectories=[/disk2/dalvik-dev/out/host/linux-x86/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
Suppressed: java.lang.ClassNotFoundException: GCBench
at java.lang.Class.classForName(Native Method)
at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
... 1 more
Caused by: java.lang.NoClassDefFoundError: Class "LGCBench;" not found
... 5 more
And after is:
java.lang.ClassNotFoundException: Didn't find class "GCBench" on path: DexPathList[[zip file "/disk2/dalvik-dev/out/host/linux-x86/framework/GCBench.jar"],nativeLibraryDirectories=[/disk2/dalvik-dev/out/host/linux-x86/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
Suppressed: java.io.IOException: Zip archive '/disk2/dalvik-dev/out/host/linux-x86/framework/GCBench.jar' doesn't contain classes.dex
at dalvik.system.DexFile.openDexFile(Native Method)
at dalvik.system.DexFile.<init>(DexFile.java:80)
at dalvik.system.DexFile.<init>(DexFile.java:59)
at dalvik.system.DexPathList.loadDexFile(DexPathList.java:268)
at dalvik.system.DexPathList.makeDexElements(DexPathList.java:235)
at dalvik.system.DexPathList.<init>(DexPathList.java:113)
at dalvik.system.BaseDexClassLoader.<init>(BaseDexClassLoader.java:48)
at dalvik.system.PathClassLoader.<init>(PathClassLoader.java:38)
at java.lang.ClassLoader.createSystemClassLoader(ClassLoader.java:128)
at java.lang.ClassLoader.access$000(ClassLoader.java:65)
at java.lang.ClassLoader$SystemClassLoader.<clinit>(ClassLoader.java:81)
at java.lang.ClassLoader.getSystemClassLoader(ClassLoader.java:137)
Suppressed: java.lang.ClassNotFoundException: GCBench
at java.lang.Class.classForName(Native Method)
at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
... 1 more
Caused by: java.lang.NoClassDefFoundError: Class "LGCBench;" not found
... 5 more

Also, move dex file verifier messages out of logs.
In the process the ClassLinker::dex_lock_ needed tidying to cover a smaller
scope. Bug 11301553.

Change-Id: I80058652e11e7ea63457cc01a0cb48afe1c15543
e810452722ac83b294d1f7aa80bdd88e547d5af0 16-Oct-2013 Brian Carlstrom <bdc@google.com> Preload DexCaches

Bug: 11045348
Change-Id: I6f9c0d11613b6b4933a04ae23dbf4bc7879cea65
31b9d6644cce958ddde939e8c26a08e3f704e3df 14-Oct-2013 Mathieu Chartier <mathieuc@google.com> Hold proxy classes live in class linker.

We currently assume that class loaders hold proxy classes live, but
this is not always the case (e.g. class loader gets freeed). This
was resulting in a bug where we were freeing a class when there
was still a live object referencing it.

Bug: 11141694
Change-Id: I318e9fee41c86b7790431d09ba5e83633fab547b
241b5de2d3cf06868ac31f1153aa0b32ddb07b20 10-Oct-2013 Ian Rogers <irogers@google.com> Clinits may not have the kAccConstructor flag.

Bug: 11157540
Set the clinit access flag when we load the method and warn about badly
formed access flags.

Change-Id: I515c692095051f84f98510722ab764591185918e
8e3fb14615f20677da8421ada131b5f2fcd8eb56 10-Oct-2013 Brian Carlstrom <bdc@google.com> Revert "Add Jack modifier."

This reverts commit 6ffd0967027c092a62d7100ca42ceded369c8ca1.

Change-Id: Ia69241a5100e8f740379e2ed944279de4daaf9ed
756ee4e090bc1e1812b41fb7b4661df601a32ef9 04-Oct-2013 Brian Carlstrom <bdc@google.com> Find OatDexFile by DexFile name and checksum, not just checksum

Bug: 10614658
Change-Id: Ie0b5a34fd396b6299000c37909108c5e7e6ab80f
7c3d13aebdd8611cae58a1048bffb13cbdc465cb 05-Sep-2013 Brian Carlstrom <bdc@google.com> Use file magic to determine file type, not file extension.

Bug: 10614658
Change-Id: I9156dfca78ac8cd1c62fb258825cc791629270a4
1c82982f4eab8f0e84829fec25e3f899da44e7ce 01-Oct-2013 Ian Rogers <irogers@google.com> Early exit for static fixup if no direct methods.

Change-Id: I401746e48259a98fb0c80144ff5310380889b154
b00309f1aece094de16e0e542cc30cb2e27f2326 30-Sep-2013 Brian Carlstrom <bdc@google.com> Fix OatFile leak causing dlopen to return stale OatFile contents

Bug: 10917637
Change-Id: If6b7bb8dd9c7aa3d870bd43964f31512385c5d39
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
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
abcf7ae8deba4ee81dec44f3d1a2f0ecaf032859 24-Sep-2013 Brian Carlstrom <bdc@google.com> Fix overly restrictive assert

Found by 084-class-init on a clean build.

Bug: 10750824
Change-Id: I7cf1ee190cbddbda98132511527eab36c36da523
cb5f5e53b580023fa2c1d8235c2e9aa1ff67d1dc 24-Sep-2013 Brian Carlstrom <bdc@google.com> Make sure CompilerDriver actually resolves types

Bug: 10750824
Change-Id: Ie61881f24196e851d87822798a7e9abdf9678aa3
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
c4621985bdfc2b27494087e5dee65a6d0cc5a632 17-Sep-2013 Mathieu Chartier <mathieuc@google.com> Fix race in root marking.

There was a race which caused the class linker / intern table to not
become dirty after adding a root. We now guard the is dirty flag by
the corresponding locks to prevent this from occuring. This was
causing roots to be occasionally missed.

Also fixes the bug where we occasionally scan more cards than
needed.

Bug: 10626133

Change-Id: I0f6e72d92035ff463954d66988ef610ea0df61be
423d2a3dcbb260b020efb5da59f784c9f02accbf 13-Sep-2013 Mathieu Chartier <mathieuc@google.com> Add support for changing roots through the root visitor callback.

Needed for copying collectors.

Change-Id: Icc4a342a57e0cfb79587edb02ef8c85e08808877
a436fde2762664a3ecdda5eefcadd20b2e104f59 28-Aug-2013 Ian Rogers <irogers@google.com> Handle OOMEs in class linker with grace.

Check for OOMEs and then fail due to them in class loading.
Make the compiler driver spot OOMEs during resolution and abort compilation to
avoid needless GC thrash then eventual death.
Allocate the pre-allocated OOME during Runtime::Init as Runtime::Start isn't
called in the context of the compiler/tools.

Change-Id: Id72199d0fe82001b5bf22758b3cdc9cc4b8efbb9
7dfb28c066159e6cde8181720f0c451a700ef966 22-Aug-2013 Ian Rogers <irogers@google.com> Don't scan image space when starting runtime.

Bug 10432288.
Find Classes and Strings from dex caches lazily rather than when the image is
loaded.
Make class status changes do notifies when there can be waiters.
For Class lookup there's a pathology if we always search dex caches and
so after 1000 failures move all classes into the class table.
Be consistent in using "const char*" for class linker descriptors as this
most easily agrees with the type in the dex file.
Improve the intern run-test so that it has a case of a literal contained in the
image.
Modify image_test to allow any valid lock word rather than expecting 0, ideally
we wouldn't see inflated monitors but we do due to NotifyAll (see bug 6961405).

Change-Id: Ia9bfa748eeccb9b4498784b97c6823141b1f6db8
6d3f72ce67d012318dee23c86a7464a9440fabff 22-Aug-2013 Brian Carlstrom <bdc@google.com> Use Class::IsVerified to confirm status, not MethodVerifier::FailureKind

Change-Id: Ideeb1ee38e9188ec7cbfd001e7422e847d52092c
8f3c9ae38df2460940a26dff889a84430b6c38d3 21-Aug-2013 Ian Rogers <irogers@google.com> Don't allow class status to go backward except for error.

Allow greater parallelism of initialization.
Bug 10393546.

Change-Id: Ic194ed490bb0a986250c09fcf335eb1be9714657
fe9ca4028f379688ecba6132ac3738171176b3e4 21-Aug-2013 buzbee <buzbee@google.com> Compiler filter update

Tweak of the compiler filter to give better results for applications
which are not dominated by tight arithmetic loops. Deleted
the "DeferCompilation" setting - it didn't differ enough from the
"Space" setting. Added "Everything" setting to support forced
compilation (for images and testing). Previously used "Speed"
for that purpose, but in the speed setting there are some things we
don't want to compile.

Change-Id: Ia53b14f2044fc9738c1a4c1318f8204f2c25abe3
be7149fc2e7cc607937209f2819e3c1d672e2668 20-Aug-2013 Ian Rogers <irogers@google.com> Avoid throwing NoClassDefFoundError at compile time.

Change-Id: I8ba56a8750e1718babcb1f94e0408d89f58ea9b5
e6bb3b2ce5a69c31c2adfc7eb2705633b7f966eb 20-Aug-2013 Ian Rogers <irogers@google.com> Reduce AOT initialization.

When compiling apps there is no need to resolve all types in the dex file, just
those declared in the dex file. There's also no need to initialize static
fields if we can only leave the class in a verified state.

Increase use of CompilerDriver::IsImage.
Move timing of dex2oat setup to before Runtime::Create.

On run-test 056 the performance improvement is an order of magnitude, for
ThinkFree dex2oat time is dominated by compilation and this change has no
effect.

Bug 10316099.

Change-Id: Ibdd7caa43284e7448e6a56d810967100ae4a7898
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
02e25119b15a6f619f17db99f5d05124a5807ff3 15-Aug-2013 Mathieu Chartier <mathieuc@google.com> Fix up TODO: c++0x, update cpplint.

Needed to update cpplint to handle const auto.

Fixed a few cpplint errors that were being missed before.

Replaced most of the TODO c++0x with ranged based loops. Loops which
do not have a descriptive container name have a concrete type instead
of auto.

Change-Id: Id7cc0f27030f56057c544e94277300b3f298c9c5
414af10d719603fb4d8d972f5a022c17957b44e1 13-Aug-2013 Brian Carlstrom <bdc@google.com> Add flock(2)ing on dex-cache files to prevent races

Bug: 9071417
Change-Id: I1ee9ff281867f90fba7a8ed8bbf06b33ac29d511
7571e8b761ebc2c923525e12ea9fcf07e62cb33e 13-Aug-2013 Brian Carlstrom <bdc@google.com> Add flock(2)ing on dex-cache files to prevent races

Bug: 9071417
Change-Id: I1ee9ff281867f90fba7a8ed8bbf06b33ac29d511
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
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
468532ea115657709bc32ee498e701a4c71762d4 05-Aug-2013 Ian Rogers <irogers@google.com> Entry point clean up.

Create set of entry points needed for image methods to avoid fix-up at load time:
- interpreter - bridge to interpreter, bridge to compiled code
- jni - dlsym lookup
- quick - resolution and bridge to interpreter
- portable - resolution and bridge to interpreter

Fix JNI work around to use JNI work around argument rewriting code that'd been
accidentally disabled.
Remove abstact method error stub, use interpreter bridge instead.
Consolidate trampoline (previously stub) generation in generic helper.
Simplify trampolines to jump directly into assembly code, keeps stack crawlable.
Dex: replace use of int with ThreadOffset for values that are thread offsets.
Tidy entry point routines between interpreter, jni, quick and portable.

Change-Id: I52a7c2bbb1b7e0ff8a3c3100b774212309d0828e
(cherry picked from commit 848871b4d8481229c32e0d048a9856e5a9a17ef9)
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
848871b4d8481229c32e0d048a9856e5a9a17ef9 05-Aug-2013 Ian Rogers <irogers@google.com> Entry point clean up.

Create set of entry points needed for image methods to avoid fix-up at load time:
- interpreter - bridge to interpreter, bridge to compiled code
- jni - dlsym lookup
- quick - resolution and bridge to interpreter
- portable - resolution and bridge to interpreter

Fix JNI work around to use JNI work around argument rewriting code that'd been
accidentally disabled.
Remove abstact method error stub, use interpreter bridge instead.
Consolidate trampoline (previously stub) generation in generic helper.
Simplify trampolines to jump directly into assembly code, keeps stack crawlable.
Dex: replace use of int with ThreadOffset for values that are thread offsets.
Tidy entry point routines between interpreter, jni, quick and portable.

Change-Id: I52a7c2bbb1b7e0ff8a3c3100b774212309d0828e
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
7655f29fabc0a12765de828914a18314382e5a35 29-Jul-2013 Ian Rogers <irogers@google.com> Portable refactorings.

Separate quick from portable entrypoints.
Move architectural dependencies into arch.

Change-Id: I9adbc0a9782e2959fdc3308215f01e3107632b7c
8df6cea295bb685e812e40496ed77351b9881ef6 29-Jul-2013 Jeff Hao <jeffhao@google.com> Put jni lookup stub in native code ptr and fix GetOatMethodFor for proxy.

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

Change-Id: Iae286862c85fb8fd8901eae1204cd6d271d69496
a6468f681b6e5feff940d0c32363847e795e97c6 19-Jul-2013 Brian Carlstrom <bdc@google.com> Fix dalvik-dev branch cpplint issues

Change-Id: Id5710dd26e8c433887543c867f037532e61731cc
ad256bb4ca1740eba533d6527bad34e9a046ec00 18-Jul-2013 Anwar Ghuloum <anwarg@google.com> Fixing gtest failure due to VerifyClassUsingOatFile change

Change-Id: I8d4ed31fada333013a56dcb7aebbd25f5323017c
044d2832edbdadbbdce78012a257428224f42a15 18-Jul-2013 Anwar Ghuloum <anwarg@google.com> Fix VerifyClassUsingOatFile to check preverified image classes

We now bail out in two cases: we're verifying an application class or we're
verifying a boot classpath class while compiling boot classpath classes.

Change-Id: I0b8c776c032612a24799d72468dcf26280a9ab8d
56d947fbc9bc2992e2f93112fafb73e50d2aaa7a 15-Jul-2013 Brian Carlstrom <bdc@google.com> Add verification of boot.oat generated on device

Change-Id: I069586205a9a92fc7375ccf5cdde136bbbcfc800
f1d3455064792ac1c486a4a9c24279a37b4af473 13-Jul-2013 Brian Carlstrom <bdc@google.com> Do not mark pages executable unnecessarily to play nice with selinux

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