History log of /art/runtime/class_linker.cc
Revision Date Author Comments
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
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
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
38078c6449ea5c53ce390343eb57327552a7eaff 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
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
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
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
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
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
a8d6729501595d82004ec0d0e334d1ff33159d63 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
ca45725c80d2836f3f7441b27ff6e7c2f6421fc7 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
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
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
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
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
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
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
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
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
7989d22642415e1e4d608e210284834951bd0a39 28-Oct-2014 Mathieu Chartier <mathieuc@google.com> Fix 64 bit build

Buggy compiler.

Change-Id: Id16c83fc7963ca89fd7fae32dd15ae342cc7f064
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
95a935415d44903b28326424beb4db5c013ef089 29-Sep-2014 Brian Carlstrom <bdc@google.com> Add VMRuntime.isBootClassPathOnDisk

Bug: 17679443
Change-Id: I127ffdac3bfe731e9535dfe6a242eb950363d715
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
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
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
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
0624965c286ecd0971e44c060059251e75ba4b84 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
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
df1532b9ba0cda2d00b78fbdef461f8a6cf8a737 11-Sep-2014 Andreas Gampe <agampe@google.com> ART: Correctly make methods preverified

Bug: 16828525
Change-Id: I66756348b2aa50e41dacca59769b6810a91c73b0
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
8165fda0a8e0a54b4b622835f4962e2dd31b89f2 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
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
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
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)
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
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)
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
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
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
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
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
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
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
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
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
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
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
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
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
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
95e15588732684223ed7291e33af2e03e8e8ebfb 23-Jul-2014 Mingyao Yang <mingyao@google.com> Fix build, missing spaces around =/<.

(cherry picked from commit 1a12858eb15a14788478c4aca82c052bc84fcafa)

Change-Id: Id2d276cd1fb8bb95c46ff5ceacc7cfe1f5acf192
0e7f37de5bcebb413712eddd1831f30bd0818664 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
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