History log of /art/runtime/runtime.cc
Revision Date Author Comments
b73114e9ecd7a65df4abf648184dab8608f38e1d 14-May-2018 David Brazdil <dbrazdil@google.com> Set default hidden API policy to dark+black

When invoking dex2oat, only a boolean flag is used to enabled/disable
hidden API checks, instead of a 2-bit value passed down to zygote.
When the flag is true, use dark+black lists as the enforcement policy.
This is conservative, as compiling with both lists enforced may lead
to more classes being re-verified at runtime, but correctness is
preserved.

Bug: 64382372
Bug: 79738462
Test: N/A
Merged-In: If15723ad40b99c5475f10561b5b3a669a8fb01c7
Change-Id: If15723ad40b99c5475f10561b5b3a669a8fb01c7
(cherry picked from commit 46226f02fdfe50e1d49ffd77d3e99598ff79d9b9)
fb74d8bc938b1095b8e1e51083070feeb65cbd0f 04-May-2018 Calin Juravle <calin@google.com> Support system server ART-profiling

We don't have to map the code cache as executable if we only want to save
profiles. This enables system server profiling without disabling SElinux
to bypass the jit code cache exec-mapping.

Test: m test-art-host
boot a device with system server profiling enabled.
Bug: 73313191

(cherry picked from commit e6fcde455478f767f080f380f5958c6e0177e667)

Merged-In: I7f25a905e0b23456183e39e58ad8f4b829ddf0c5
Change-Id: I7f25a905e0b23456183e39e58ad8f4b829ddf0c5
96dca1c979325cdd8d543982ced4ad4fd01994d7 19-Apr-2018 Nicolas Geoffray <ngeoffray@google.com> Pass the fd to OatFile::Setup to avoid selinux errors.

bug: 77853712
Test: test.py

(cherry picked from commit 30025095524e471ec347633e39f26ed0606bea65)

Change-Id: I2af5c784f2ca12cd5b0859d93500c16be6a03428
90f8addf6c68a9be6d813e5da7f6bea370a048f9 24-Feb-2018 Alex Light <allight@google.com> Always allow agent attach on userdebug builds with kArtTiVersion

We added support for the jvmti-alike ArtTi for use by debuggers on
userdebug/eng builds of android. Extend this support to allow any
agent to be loaded on any process of a userdebug device. These agents
will need to make use of kArtTiVersion (0x70010200) envs.

Test: build
Test: ./test.py --host -j50
Test: ensure AS profiler continues to work with userdebug devices
Bug: 78195998
Merged-In: I984d1ea937eb49afb376a48bea3d67085192020e
Change-Id: I984d1ea937eb49afb376a48bea3d67085192020e
(cherry picked from commit f889c70e79643373320f5742cc719d6c467531b9)
73ddda4403c8088a730b8d456de46bb8e0307ed8 03-Apr-2018 Mathew Inwood <mathewi@google.com> Log an event on hidden API accesses.

The new event consists of:
- The type of access (reflection, JNI, etc.)
- The action taken (warn or deny)
- The type of member accessed (field or method)
- Name of the class which defined the member accessed
- The name of the member
- The type signature of the member (type of field, or method signature)

The fully qualified member name is also not included to avoid the overhead
of building the string. It can be build from the information included.

Similarly, the package name, version, etc. are not included as they can
be inferred from the context when analyzing the event log.

The event is sampled, according to a sampling rate that can be set by a
configuration option, to reduce log spam.

Test: $ m
Test: $ adb shell settings put global hidden_api_access_log_sampling_rate 65536
Test: $ adb lolcat -b events | grep art_hidden_api_access

Sample output:
16796 16796 I art_hidden_api_access: [1,0,Ldalvik/system/VMRuntime;,getRuntime,()Ldalvik/system/VMRuntime;]
16796 16796 I art_hidden_api_access: [1,2,Ldalvik/system/VMRuntime;,setHiddenApiExemptions,([Ljava/lang/String;)V]
16796 16796 I art_hidden_api_access: [1,3,Landroid/app/Activity;,mDoReportFullyDrawn,Z]
(Timestamps have been elided)

Bug: 64382372
Bug: 77517571
Change-Id: I012b2c9fbffbd00ed3219918e7a736a4f7435ec8
80f5fe5fa4fd4044c409b39db0f6b1b77542ce6e 29-Mar-2018 Andreas Gampe <agampe@google.com> ART: Refactor hidden_api

Add hidden_api.cc, move handling of hidden fields there. Also
remove an unnecessary include that meant hidden_api was imported
into too many compilation units, and fix transitive includes.

Bug: 73896556
Test: mmma art
Test: m test-art-host
Change-Id: Ie47e11abcea68e326c410bab215ebbfbf049051b
(cherry picked from commit aa12001baf69c124ab3901c13385aaa43fc76987)
a5dc52c023be28850e4d7422655d96771cb472f5 19-Feb-2018 Mathew Inwood <mathewi@google.com> More flexible API enforcement policy support.

This CL adds the ability to configure which banned API lists to enforce,
defined by new enum hiddenapi::ApiEnforcementPolicy. Currently, the policy
can be set at zygote fork time, but not at dex optimization time where
blacklist enforcement is still assumed. As such, making the policy more
strict will not work as expected yet. This will be improved in a follow up
CL.

(cherry-picked from commit 159f596eec01adbb5a1c9654402c137cdb943131)

Test: art tests pass
Test: Device boots

BUG: 73337509
Change-Id: I0f2eab0895acabfaca39c82bdb98316976c73bea
Merged-In: I33f9afce628a86727e400052f4d5979d3536da8c
c9806b1bdee97689af908f4b6f2e0dce5a1a4441 08-Mar-2018 Alex Light <allight@google.com> Make LOG(INFO) a VLOG(jdwp)

This log is often printed during cts tests where it is not useful.

Test: build
Bug: 62821960
Change-Id: I16c349152215fd41266725870e6ff39819fb03d4
(cherry picked from commit 230fa94bb87e6414376aa828bd47068c684ed57f)
8f4b056427a9d2321e3aa4f21ca8ffb18b3e5ae6 02-Mar-2018 David Sehr <sehr@google.com> Move most of runtime/base to libartbase/base

Enforce the layering that code in runtime/base should not depend on
runtime by separating it into libartbase. Some of the code in
runtime/base depends on the Runtime class, so it cannot be moved yet.
Also, some of the tests depend on CommonRuntimeTest, which itself needs
to be factored (in a subsequent CL).

Bug: 22322814
Test: make -j 50 checkbuild
make -j 50 test-art-host

Change-Id: I8b096c1e2542f829eb456b4b057c71421b77d7e2
Merged-In: c431b9dc4b23cc950eb313695258df5d89f53b22

(cherry picked from commit c431b9dc4b23cc950eb313695258df5d89f53b22)
66ff8a8b82ff103d48d40e8dad01342c2d6f6d0d 28-Feb-2018 Nicolas Geoffray <ngeoffray@google.com> Revert "Revert "Full-stack integrity: check vdex contents.""

bug: 30972906

Initial revert due to 'check' file of the test needing updating for target tests.

This reverts commit a19b7649faf8780737be7ce3ec48a12d81c6d69f.

Change-Id: I455780bd88cd89ff80c9084d399e2beeb819b95f
a19b7649faf8780737be7ce3ec48a12d81c6d69f 27-Feb-2018 Nicolas Geoffray <ngeoffray@google.com> Revert "Full-stack integrity: check vdex contents."

bug: 30972906

Test fails on device.

This reverts commit d6f914ea4bd09f2d60db2783f7a3fd93d3ec0afb.

Change-Id: I53902b0d6d4dbe8237f61bf01542acf538229c71
d6f914ea4bd09f2d60db2783f7a3fd93d3ec0afb 15-Feb-2018 Nicolas Geoffray <ngeoffray@google.com> Full-stack integrity: check vdex contents.

For priv-apps, if a vdex on /data has dex code, it must
be because the APK has compressed dex code.

Fall back to APK if not.

For test convenience, update --copy-dex-files to also
take a "always" variant.

bug: 30972906
Test: 677-fsi

Change-Id: I49f0eab46650145316a86de2971a3b9c140bcff7
2bce0763cbbd8cf35ab4e14a1920afce735e9b89 21-Feb-2018 Calin Juravle <calin@google.com> Register tests for profiling after the runtime has started

Ensure that the profile saver thread starts after the runtime finishes
starting. In test mode (when -Xps-profile-path is passed) we were
registering the app info to early.

Test: run-test 927-timers
Change-Id: Iede588524dda3ff60aa3e2c61ed1d906f63a6c70
7287c4d75e38e7a01c7ea3fdebb47d9cfe128a56 15-Feb-2018 Vladimir Marko <vmarko@google.com> Add Class.getPrimitiveClass().

Implement the native part in ART and remove the native parts
of the previously needed workaround for java.lang.Void.TYPE.

Companion libcore/ change:
https://android-review.googlesource.com/619326

Test: m test-art-host-gtest
Test: testrunner.py --host --optimizing
Test: Pixel 2 XL boots.
Bug: 73346078
Change-Id: Icfb201a1f08d8ff2a65c58f7c0ec25aa2296db29
d7fbc0eb824e495b940dd739404d945a35f01fd3 13-Feb-2018 David Brazdil <dbrazdil@google.com> Refactor hidden API runtime flag from negative to positive

There are only two situations in which we want to enable hidden API
access checks: (a) when forking a non-platform app from zygote, and
(b) when compiling such app with dex2oat. It is easier to cover these
two situations than all the other situations when we want to disable
the checks. Make the flag in Runtime class false by default and only
enable if checks are explicitly requested by the runtime.

Bug: 64382372
Test: boot device, install and run apps, check log messages

(cherry picked from commit 9cf8b671a24f55c7e1a1df561d6cce85b45cebd8)

Change-Id: Ib5ccb20596c708cedf9b2c05af228463bec2adb1
9cf8b671a24f55c7e1a1df561d6cce85b45cebd8 13-Feb-2018 David Brazdil <dbrazdil@google.com> Refactor hidden API runtime flag from negative to positive

There are only two situations in which we want to enable hidden API
access checks: (a) when forking a non-platform app from zygote, and
(b) when compiling such app with dex2oat. It is easier to cover these
two situations than all the other situations when we want to disable
the checks. Make the flag in Runtime class false by default and only
enable if checks are explicitly requested by the runtime.

Bug: 64382372
Test: boot device, install and run apps, check log messages
Change-Id: I7faf440ed714a5ddd08f6172d370202f0131db50
928033d81f63912f669acd27a72897694eb31db6 07-Feb-2018 Orion Hodson <oth@google.com> Revert^2 "ART: Interpreter support for VarHandle accessors"

This reverts commit c4d3bf4eaff9720ed0bb7775db6fc24a1bd755dd.

Bug: 65872996
Test: art/test/testrunner.py -b --host
Change-Id: I2d1017c45cee5b2fd2dd05e5eeff0a72146663b1
25419b59f6fce8da492c9d742d4a157c6c645558 09-Feb-2018 Andreas Gampe <agampe@google.com> ART: Add option to use stderr logger

Add a runtime option that sets the android-base logger to StderrLogger,
forcing all further logging to go to stderr. This can be used for
better interaction with dalvikvm or dex2oat on-device.

Bug: 72998814
Test: m test-art-target-gtest-dex2oat_test
Change-Id: I18794bbed0885810f8f0480816b1c780753a9702
a6899033c5799f882f19f5e4ff7844d21058143f 07-Feb-2018 David Brazdil <dbrazdil@google.com> Do not enforce hidden API for boot image and preopt compilation

When compiling on host that hidden API checks should not be enforced.
This is a proxy until the compiler flags are cleaned up.

Bug: 64382372
Test: make with blacklist enabled
Change-Id: I03777526d68db22ca3589e223af9466a1c9786d8
f3d6cddd1d3a8c12abe1027b11d71a7d87005f3f 07-Feb-2018 David Brazdil <dbrazdil@google.com> Revert "Do not show UI hidden API warning for exempt apps but print into log"

This reverts commit e5bc69765d685bcbd3d98a3b792f6d90e4e3dabc.

Reason for revert: This is no longer required

Change-Id: I80d4a866916a77032e205257d6f920b928fb876f
ad666279a4af62e122f52cc7872efb812d82887f 06-Feb-2018 David Brazdil <dbrazdil@google.com> Disable hidden API checks for Am

Am starts its own runtime and its Java code should be exempt from
hidden API checks. Change the logic in runtime.cc to disable hidden
API checks by default and only enable them if:
(a) dex2oat runs without -Xno-hidden-api-checks
(b) zygote forks a new process without DISABLE_HIDDEN_API_CHECKS flag

This logic can be simplified by changing the flag from negative to
positive. Since the cleanup requires touching multiple projects, it
will be done in a future CL.

Bug: 73001007
Bug: 64382372
Test: manual
Change-Id: I8a222f7a16bf88ffe4541558f3ba789f38d7322e
2b23147405b2f53d38b7b990c40baf698ed5739c 05-Feb-2018 David Brazdil <dbrazdil@google.com> Do not show UI hidden API warning for exempt apps but print into log

This is a configuration for dogfood builds in which we want to print
warnings into the log for all apps but not show UI toast for system
apps so as to not spam dogfooders unnecessarily.

Bug: 64382372
Test: make
Change-Id: I5b0d5757610dadd1593a5e388e5345c060cf39cf
(cherry picked from commit e5bc69765d685bcbd3d98a3b792f6d90e4e3dabc)
e5bc69765d685bcbd3d98a3b792f6d90e4e3dabc 05-Feb-2018 David Brazdil <dbrazdil@google.com> Do not show UI hidden API warning for exempt apps but print into log

This is a configuration for dogfood builds in which we want to print
warnings into the log for all apps but not show UI toast for system
apps so as to not spam dogfooders unnecessarily.

Bug: 64382372
Test: make
Change-Id: I5b0d5757610dadd1593a5e388e5345c060cf39cf
92265222f1e1df56ee6d106493b1bd2be65d5ce9 02-Feb-2018 David Brazdil <dbrazdil@google.com> Only set UI warning on hidden API dark greylist

The framework might show a toast notification on access to greylisted
hidden APIs. Only show this warning on dark greylist so as to not spam
early testers.

Bug: 64382372
Test: make
Change-Id: I8b5f7b4938e0f238c513e37d7db06856b966802f
2e349167ebdaf10dee9d68f06bbe620ed9aa841b 24-Jan-2018 David Brazdil <dbrazdil@google.com> Enable hidden API enforcement

Test: manual
Bug: 64382372
Change-Id: I4cbbfb83a2fb697e78a22858cfdd6a6779e6762d
264a486a05e832889b17dd2bbad2d9c6588c3603 31-Jan-2018 Alex Light <allight@google.com> Revert "Revert "Make the runtime default to not allowing JDWP again.""

This reverts commit f05c32008de16f669ea8323c4e17beef1df92d20.

We need to change the arguments passed from run-jdwp-tests.sh in some
situations.

Reason for revert: Fixed issue causing go/art-build to fail.

Test: ./art/tools/run-jdwp-tests.sh --mode=host
Bug: 72400560

Change-Id: I2be260479816e3a48df5cb65bba25858750df4db
f05c32008de16f669ea8323c4e17beef1df92d20 31-Jan-2018 David Brazdil <dbrazdil@google.com> Revert "Make the runtime default to not allowing JDWP again."

This reverts commit b06bd683aab50a80ef98f0ffbec9880dad068d15.

Reason for revert: Broke go/art-build. Reverting as ART Sheriff.

Change-Id: I1ab4f5eb22b51b3b348f592c22db340b88af4f7f
56776014d181b7ee386a2ba5d85cf66d8bb4dd22 27-Jan-2018 Andreas Gampe <agampe@google.com> ART: Call ThreadGroup.add for attached threads

When attaching threads to the runtime, call ThreadGroup.add to
let the thread's group know that the thread is now started. This
fixes incorrect internal accounting.

Test: art/test/testrunner/testrunner.py -b --host -t 169
Test: m test-art-host
Change-Id: I60362b6b53acf06b97779ea9b3b0bc6264f1dc2d
b06bd683aab50a80ef98f0ffbec9880dad068d15 29-Jan-2018 Alex Light <allight@google.com> Make the runtime default to not allowing JDWP again.

This was unintentionally changed a while ago and is causing a CTS test
to fail. Changed to make the runtime default to disabling jdwp if a
provider isn't given. Note this does not stop one from starting a
debugger with -agentpath. If jdwp options are given with jdwp disabled
the runtime will print a warning.

Test: atest CtsJdwpSecurityHostTestCases
Test: ./test/run-test --host --debug 001-HelloWorld
Bug: 72400560

Change-Id: I6561f269d9279eba0c1ac0b0f593ece867dab49e
ee7d2fd16d47b54d7fb5b9d5ec772fbc315faf4b 20-Jan-2018 David Brazdil <dbrazdil@google.com> Start warning on hidden API greylist

Insert checks into reflection, JNI and the verifier to print
a warning when greylisted methods are invoked and fields accessed.
We do this on actual access, because reflection allows to list
all methods/fields and simply listing a greylisted member would
print too many false positives.

Issuing a warning also sets a boolean flag in Runtime. This will
be made accessible through VMRuntime to the framework which will
issue a Toast on Activity start.

The change was tested with internal microbenchmarks of reflection
and those flagged one issue. Microbenchmark invoking a field getter
has regressed by 35%. We will profile this benchmark in detail and
consider options for improvement. Bug b/72482474 was created to track
progress.

Test: art/test.py -b -r -t 674-hiddenapi
Bug: 64382372
Bug: 72482474
Change-Id: I323244935e9091a2f8d012385cefaac6b1fe3777
3e0fa0aa5d929737f1d1c4bac07e2695ac438324 15-Jan-2018 David Brazdil <dbrazdil@google.com> Add runtime option for no hidden API access checks

Add a new Runtime option -Xno-hidden-api-checks to disable
enforcing hidden API access restrictions.

Test: m test-art-host
Bug: 64382372
Change-Id: I8bd5b7ef307f21ba71d05a066a9d5dd2d7614543
a7db026ff647eefb589043dbb55bbf28637755e8 16-Jan-2018 David Brazdil <dbrazdil@google.com> Add a new runtime option for target SDK version

SDK version can be set through VMRuntime, but we also need a way
of setting it in dex2oat.

Bug: 64382372
Test: make test-art-host
Change-Id: I82b9360be59a8bc1984006379d8011d50a0199c3
013fd8073f3ece22b0bba1853d3f3430c8a9e4bd 12-Jan-2018 David Sehr <sehr@google.com> Create an ART-independent DexFileLoader

Opening DEX files should not rely on instantiating a runtime or having a
large number of dependencies on runtime components. This CL makes
DexFileLoader a stub class that is independent of ART, and introduces a
subclass ArtDexFileLoader that contains the current implementations.

Bug: 22322814
Test: make -j 50 test-art-host
Change-Id: Ia6e92ae93c347057ea0c10455525239cbbe42c03
2ce6fc80711af9afa3ecda8fdff6f4ed80aa3022 19-Dec-2017 Alex Light <allight@google.com> Support using adbconnection and openjdkjvmti without JAVA_DEBUGGABLE

We need to support using a best-effort JDWP when we have the
ENABLE_JDWP attribute without the JAVA_DEBUGGABLE attribute. This is
used on eng and userdebug builds. We do this by making the plugin try
to change the runtime to debuggable if possible and to allow getting
an ArtTiEnv which is a best-effort version of JVMTI by calling GetEnv
with (JVMTI_VERSION_1_2 | 0x4000000). This is needed since if the
runtime isn't debuggable we cannot guarantee compatibility with the
JVMTI specification in all cases due to compiler optimizations such as
inlining. By creating this special version agents are able to
positively signal that they are able to deal with this uncertainty.

We also support using openjdkjvmti without being JAVA_DEBUGGABLE. This
is done by either only allowing the best effort ArtTiEnvs or by
changing the environment to be debuggable if we are loaded early
enough.

Moving the runtime to debuggable state involves deoptimizing the boot
image and throwing out any image files associated with non-debuggable
oat-files.

Bug: 62821960
Test: ./test.py --host -j50
Test: Manual
Test: Build, Test debugging system_server and other processes.
Change-Id: I2233299fceb83c76785e5de09e51eaf18b7922e8
e44ee0c3d073e00e88f3a29f2a42129c3eba84e7 08-Jan-2018 Alex Light <allight@google.com> Do not abort if we fail to allocate a thread-peer on shutdown

We were aborting if we failed to allocate the "Shutdown thread" a
java-peer. This can sometimes happen if there is very constrained
memory during shutdown for some reason. Since the thread-peer is only
observable in very rare situations (and the runtime is shutting down
anyway) we will instead simply continue without it.

We also change a test that was hitting this situation to handle not
having a thread peer.

Bug: 71623806

Test: while ./test/run-test --host \
--prebuild \
--compact-dex-level none \
--optimizing \
--no-relocate \
--runtime-option -Xcheck:jni \
--pic-test \
--64 \
--build-with-javac-dx \
004-ThreadStress;
do; done
Test: ./test.py --host -j50
Change-Id: Ib159d03e9f4b0e4d5b1b071d4b85e94620679bb0
9e734c7ab4599d7747a05db0dc73c7b668cb6683 05-Jan-2018 David Sehr <sehr@google.com> Create dex subdirectory

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

Bug: 71361973
Test: make -j 50 test-art-host
Change-Id: I59e984ed660b93e0776556308be3d653722f5223
7b38e692caa474bf0470349d016ef8f4502d50b9 29-Dec-2017 Andreas Gampe <agampe@google.com> ART: Take classloader into account for AttachAgent

Take a classloader into account for attaching an agent, if given.
This will use the library path from the classloader to find the
agent library.

Switch to libnativeloader to do the actual loading.

Bug: 70901841
Test: m test-art-host
Change-Id: I59ec55178792bc738fb06e0299522e207dd4a784
b6f3464a934910e84e9a76e9f453bec71bffed5c 04-Jan-2018 Alex Light <allight@google.com> Ensure shutdown thread has a java peer.

Using JVMTI it is possible to be running user-supplied code both on
the shutdown thread and on other threads while the shutdown thread is
running. Specifically some real-world JVMTI agents rely on being able
to suspend the shutdown thread while they do cleanup work. In order to
support this we will make sure that the shutdown thread is given its
own java peer so it can be suspended by other threads.

Bug: 66904725
Bug: 62821960

Test: ./test.py --host -j50

Change-Id: I1c89537c47fd3dd41aa4c0e7f7a6940d1c5ba913
473191c4093aac1ec50bc275c588287fa37a981e 29-Dec-2017 Andreas Gampe <agampe@google.com> ART: Clean up library loading

Retrieve the library path from the classloader before attempting to
load, instead of getting it passed down. This allows unifying said
loading behavior for follow-up changes.

Fix up test code to support the new required data in classloader
objects.

Bug: 70901841
Test: m test-art-host
Test: device boots
Change-Id: Iaccaeb56422877abac9f7fe6f5a17364c8adf4ca
aadcbc64c674995ccdaf686789c8d39ada9913ad 28-Dec-2017 Andreas Gampe <agampe@google.com> ART: Refactor Agent into Agent and AgentSpec

Separate configuration/loading and runtime state.

Test: m test-art-host
Change-Id: I69bb91e13ef10b9e1ce313f45b0b809b913d8e10
55256cb60e11d4fac71affb4b9760a2931a3598d 22-Dec-2017 Ian Rogers <irogers@google.com> Extensions to check JNI.

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

Test: mma test-art-host

Change-Id: I4d149cb04d3a7308a22b92b196e51e2f1ae17ede
fbf9670f31d09c47078d43fd85ee2bda23273d26 14-Dec-2017 Alex Light <allight@google.com> Add adbconnection plugin

This plugin will take care of creating and managing a debugger connection
through the adb daemon. This involves sending DDMS messages from the
runtime, loading the JDWP agent when required, and setting up the
connection. We need this since DDMS packets can be sent even if there has
not been a full handshake done with the JDWP agent.

Add an 'adbconnection' value to '-XjdwpProvider:...' to allow one to
request that the adbconnection plugin be used to provide JDWP
functionality.

Bug: 62821960
Test: Manual, Flash walleye, debug apps

Change-Id: Id9bed589b7c5e3830e6cdfbfee460b091459a27b
403207107da7f11525c4d305184c56b35ec1c17a 14-Dec-2017 Alex Light <allight@google.com> Add support for selecting alternate JDWP implementations

Change JDWP options parsing to take place later and add a
-XjdwpProvider:_ option that can be used by the runtime to select an
appropriate JDWP provider. The argument is a string.

If 'none' is given JDWP will be totally disabled.

If 'internal' is given the current internal JDWP implementation is
used.

If 'default' is given the 'internal' JDWP implementation will
currently be used.

Other values will be added in the future.

Also adds a runtime callback that will be invoked when the runtime
wants to start or stop the debugger (namely at the post-zygote fork
and just before exit) and check if a debugger is availible.

Also add '-XjdwpOptions:_' in preparation for the eventual removal of
the existing -Xrunjdwp=_ and -Xagentlib:jdwp=_ as top-level options.
All of these options now store their arguments as a std::string to be
interpreted by the JDWP implementation as it sees fit. Also change the
jdwpOptions to default to transport=dt_android_adb if there is not one
specified and it is available. This will make changing the default
transport based on the JDWP provider easier.

These new options are needed to allow us to support both the old,
internal, JDWP implementation as its replacement is tested and
verified. This lets us switch between them with little difficulty.

We will probably remove one or both of these options once we have
confidence that the new jdwp implementation has stuck.

Test: ./test.py --host -j50
Test: ./test/run-test --host --debug 001-HelloWorld
Test: Manual, flash walleye, debug app

Bug: 62821960

Change-Id: Ie31db6b6f7d76a03d4ab8e178fcf298ed0eec203
b0042b83f9695bb7e2f07c451166a97a6c14383f 13-Dec-2017 Mathieu Chartier <mathieuc@google.com> Specify INFO log severity for -XX:DumpGCPerformanceOnShutdown

The art script only has severity set to warning, this was causing
the GC timings to not get output.

Bug: 70630582
Test: art -Xmx512m -XX:DumpGCPerformanceOnShutdown .. some benchmark

Change-Id: I03e4e09836f0bd73fbbff3640b4db8617cc63c95
39b378ca3b4b6dc6da1651b84ee4289cd9bff0f8 08-Dec-2017 Andreas Gampe <agampe@google.com> ART: Factor out gAborting

Cut dependencies on base/logging.h by moving gAborting to its
own header. Leave the static storage in logging.cc.

Test: m
Change-Id: Ib2ca880e15f9cb50cb9aab803784826bb46efb5e
7919db947bc41f6f5d194c50b88d0cba47319a1c 29-Nov-2017 Alex Light <allight@google.com> Speed up MterpShouldSwitchInterpreters check

We were often performing a pair of TLS reads in order to determine in
the current thread has any pending asynchronous exceptions (exceptions
thrown by the JVMTI StopThread function). This is quite slow and was
impacting some benchmarks. Since it is expected that asynchronous
exceptions are extremely rare we will first check to see if any
asynchronous exceptions have been sent on the current process. Only if
at least one asynchronous exception has been thrown will we do the
expensive TLS lookups to determine if one has been thrown on the
current thread.

Using a global instance value without synchronization or atomics is ok
here since the checkpoint that actually sets the async_exception_thrown
flag provides synchronization by either occurring on the target thread
or passing the checkpoint.

According to go/lem this gives us a 7% increase on the caffeine
string benchmark.

Test: go/lem runs
Test: ./test.py --host -j50
Bug: 68010816
Change-Id: I62684a5b3a7fc7cc600f5efd2a2393d9c4025917
33bff25bcd7a02d35c54f63740eadb1a4833fc92 01-Nov-2017 Vladimir Marko <vmarko@google.com> ART: Make InstructionSet an enum class and add kLast.

Adding InstructionSet::kLast shall make it easier to encode
the InstructionSet in fewer bits using BitField<>. However,
introducing `kLast` into the `art` namespace is not a good
idea, so we change the InstructionSet to an enum class.
This also uncovered a case of InstructionSet::kNone being
erroneously used instead of vixl32::Condition::None(), so
it's good to remove `kNone` from the `art` namespace.

Test: m test-art-host-gtest
Test: testrunner.py --host --optimizing
Change-Id: I6fa6168dfba4ed6da86d021a69c80224f09997a6
891a50e9dc0f02ee34bd7348f80b621249153af5 28-Oct-2017 David Sehr <sehr@google.com> Separate file utilities from utils.cc

Reduce the dependencies from utils.cc to arch/ subdirectories, etc.

Bug: 22322814
Test: make test-art-host
Change-Id: I4decd15ff4ec460735bfb58cebb1c6a1bf32b68f
26ef34c01ae5db2d3c964844b3717b8974a612c9 01-Nov-2017 Orion Hodson <oth@google.com> ART: Move intrinsics definitions to runtime

Bug: 37538194
Test: art/test.py --host
Change-Id: Ic7adf5f8b14be0e1880ae898a4e199b4416a4d24
e875f4c210ce0598e47b6d66ec12cd7c60208844 26-Oct-2017 Nicolas Geoffray <ngeoffray@google.com> Don't verify dex file when the runtime is in NoVerify mode.

bug: 30972906
bug: 63920015

Test: systrace of priv-app with OOB, no verification at startup
Change-Id: I479a7ddcfa495228a379744b23c26fa8c91c3dde
d863be7a36bf2017958051fe1191ed47192085e8 12-Sep-2017 Andreas Gampe <agampe@google.com> ART: Move JniConstants::init from ART to libcore

This should live with libcore. There's no deep magic in the runtime
startup.

Also remove dependency on libnativehelper shared library.

Bug: 65522645
Test: m
Test: m test-art-host
Test: Device boots (bullhead)
Change-Id: I6d03144fa02461d31e9e26c27cdb3a9a9510122d
373a9b5c718a45ac484afcf4fe6ce84f4bb562b3 18-Oct-2017 Andreas Gampe <agampe@google.com> ART: Depend on libnativehelper headers only

Depend on header-only versions where possible. Move projects
excluding libart to libnativehelper_header_only.

Bug: 65522645
Test: mmma art
Change-Id: I53dd3b2a97e94ee685f72de007ed3858f7f5c6b6
095c6c96236476b605b3ac672f6d2b8c151e9479 19-Oct-2017 Nicolas Geoffray <ngeoffray@google.com> Pass the verify flag to DexFileLoader utilities.

Refactoring-only change.

Also remove unused DexFilerLoader::OpenMemory.

bug: 30972906
bug: 63920015

Test: build.

Change-Id: I7cd4b5787565ab1a3457ce2be6bb14657229c550
11c273ddfda3e30d14af32e385570955b61bc39b 16-Oct-2017 Mathieu Chartier <mathieuc@google.com> Remove low RAM special casing for heap growth multiplier

Moved to change the default value in runtime.cc. This enables
changing the value by passing in a
-XX:ForegroundHeapGrowthMultiplier value.

This enables devices to set the foreground heap growth multiplier
to non 1.0 values even when low_memory_mode is true. Doing this
reduces GC frequency and can help device performance.

Increased the limit to 5.0 since the old limit of 1.0 was bogus.

Bug: 67416130
Test: test-art-host
Test: make and flash

(cherry picked from commit 2f33ad21a5c3688c33c1f36665216d76bac47f2c)

Merged-In: I86166830261c034255c23611cb8f4ebcf8c43b09
Change-Id: I6fdf82e69ebe350476fb4fe3da9d22bf671b9eac
2f33ad21a5c3688c33c1f36665216d76bac47f2c 16-Oct-2017 Mathieu Chartier <mathieuc@google.com> Remove low RAM special casing for heap growth multiplier

Moved to change the default value in runtime.cc. This enables
changing the value by passing in a
-XX:ForegroundHeapGrowthMultiplier value.

This enables devices to set the foreground heap growth multiplier
to non 1.0 values even when low_memory_mode is true. Doing this
reduces GC frequency and can help device performance.

Increased the limit to 5.0 since the old limit of 1.0 was bogus.

Bug: 67416130
Test: test-art-host
Test: make and flash

Change-Id: I86166830261c034255c23611cb8f4ebcf8c43b09
c42cb0e08a7c8f7085115e57b0ea92da9eee1575 13-Oct-2017 Mathieu Chartier <mathieuc@google.com> Add -XX:MadviseRandomAccess option

If enabled, ART will advise random access to the kernel for files
that are thought to have such access patterns.

Bug: 67772594
Test: verify that -XX:MadviseRandomAccess:true is passed to runtime init

(cherry picked from commit 087f2046dfdf41646c740a05004b4d40cbd99b11)

Change-Id: I76a5f62846d563a4f2cf25e47dbd320464aee8c1
087f2046dfdf41646c740a05004b4d40cbd99b11 13-Oct-2017 Mathieu Chartier <mathieuc@google.com> Add -XX:MadviseRandomAccess option

If enabled, ART will advise random access to the kernel for files
that are thought to have such access patterns.

Bug: 67772594
Test: verify that -XX:MadviseRandomAccess:true is passed to runtime init
Change-Id: Iaaf8159d2ed69ed4968870a6104e3d1a8454b711
79c87da9d4698ec58ece65af0065eebd55a1cfe0 10-Oct-2017 Mathieu Chartier <mathieuc@google.com> Add DexFileLoader class

Added DexFileLoader class, moved functionality from DexFile there:
- Multidex loading logic
- DexFile opening logic for Zip and etc
- Some other helpers

Bug: 63756964
Test: test-art-host

Change-Id: Ic3dfa458947d4b69912dea5cdd836e7e8f55061c
e2abbc604ce003c776c00ecf1293796bb4c4ac5a 15-Sep-2017 Andreas Gampe <agampe@google.com> ART: Move kDexNoIndex to dex_file_types.h

Define the constant with the types to allow lowering the dependency
on DexFile.

Test: m
Change-Id: I3c61421db45be96d2057e01b1a7825883d8bd178
68bf3903250ff0bea11c4705ba331818c5bf5792 07-Sep-2017 Nicolas Geoffray <ngeoffray@google.com> Handle new zygote flags in ART

Add support for DISABLE_VERIFIER and ONLY_USE_SYSTEM_OAT_FILES.

bug: 30972906
bug: 63920015

Test: device boots
Change-Id: I7c4eddc070908aed980d54d374c0b261d1f32d57
c4cb7c143d8acdbacf5276991df6f0aa83ab1f35 12-Sep-2017 Andreas Gampe <agampe@google.com> ART: Clear JniConstants on shutdown

To permit a new runtime to repopulate the JniConstants cache,
call ClearJniConstantsCache() on shutdown.

Bug: 65522645
Test: m
Test: m test-art-host
Change-Id: I340cc2ced6b2e5bcd541f1d7b9741574e37c27eb
db48a79e49a900e255c1a472d6436a655016125f 09-Sep-2017 Andreas Gampe <agampe@google.com> ART: Clear WellKnownClasses on shutdown

The members go stale on shutdown, so delete them. This also works
around a startup bug that is relying on null members.

Bug: 65500943
Test: m test-art-host
Change-Id: Ib8c0a28c4b6509a0614a12e123b73e7c117db319
0b7f137f5f76afbe853483e08f1ac15e539b5d90 05-Sep-2017 Andreas Gampe <agampe@google.com> ART: Change thread dump order on abort

Dump the aborting thread last, in an effort to have it appear in
the logcat.

(cherry picked from commit a3f78fedfb9f791f849d0daa8b10a43232f09752)

Bug: 64689630
Test: m test-art-host
Merged-In: Ib9148b542a950545a5873e7ca71d3d3b2cefbd1f
Change-Id: Ib9148b542a950545a5873e7ca71d3d3b2cefbd1f
a3f78fedfb9f791f849d0daa8b10a43232f09752 05-Sep-2017 Andreas Gampe <agampe@google.com> ART: Change thread dump order on abort

Dump the aborting thread last, in an effort to have it appear in
the logcat.

Bug: 64689630
Test: m test-art-host
Change-Id: Ib9148b542a950545a5873e7ca71d3d3b2cefbd1f
e5071cc58a3cdea4a88257be3c8fd4d012a64c74 12-Jun-2017 Vladimir Marko <vmarko@google.com> ART: Change method lookup to be more consistent to JLS and the RI.

The method lookup for different invoke types was previously
widely different and didn't work well with the dex cache
method array where we have only a single slot for each
MethodId. The new behavior is to perform the same lookup for
all cases, distinguishing only between interface and
non-interface referencing class, and to further align the
behavior with the JLS and the RI. Where the JLS conflicts
with the RI, we follow the JLS semantics.

The new lookup for class methods first searches the methods
declared in the superclass chain (ignoring "copied" methods)
and only then looks in the "copied" methods. If the search
in the superclass chain finds a method that has not been
inherited (i.e. either a private method or a package-access
method where one of the classes in the chain does not belong
to the same package, see JLS 8.4.8), we still search the
"copied" methods as there may actually be a method inherited
from an interface. This follows the JLS semantics where
inherited methods are included in the search (JLS 15.12.2.1)
but conflicts with the RI where the private or
package-access method takes precedence over methods
inherited from interfaces.

Note that this search can find an accessible method that is
not inherited by the qualifying type, either for a package
access method when the referrer is in the same package but
the qualifying type is in another package, or for a private
method where the referrer is in the same class but the
qualifying type is actually a subclass. For the moment we
allow such calls and we shall consider whether to throw
an IncompatibleClassChangeError in this situation in future
to comply with JLS 15.12.4.3.

The new lookup for interface methods searches the interface
class, then all the superinterfaces and then the
java.lang.Object class, see implicitly declared methods in
interfaces, JLS 9.2. The search for the maximally-specific
non-abstract superinterface method is not yet implemented,
but the difference should be difficult to observe as the
usual subsequent call to FindVirtualMethodForInterface()
should yield the same result for any matching method.

The new test 162-method-idx-clash exposes several cases
where we previously completely messed up due to the effects
of the DexCache, or where we were out of line with the RI.
It also tests a case where the JLS and the RI disagree and
we follow the JLS.

Test: art/test/run-test --host --jvm 162-method-resolution
Test: m test-art-host-gtest
Test: testrunner.py --host
Test: testrunner.py --host --interp-ac
Test: Nexus 6P boots.
Test: testrunner.py --target
Bug: 62855082
Bug: 30627598

(cherry picked from commit ba118827465d12177f3996e50133960087b1c916)

Change-Id: Ic73e4adf02b5cd66b5a22a3b619dc781357db14c
55e6b552af6aa34439cb0699db5ddf08c437719b 25-Jul-2017 Andreas Gampe <agampe@google.com> ART: Move CHA to ClassLinker

Move the ClassHierarchyAnalysis singleton to ClassLinker. Hierarchy
analysis is a link-time effort and belongs to class-loading instead
of the global Runtime object.

Also clean up to use a unique_ptr, and add null checks to allow
bypassing the analysis.

(cherry-picked from commit c1ac9ee48ddf483ec770b424d63de4982262ea33)

Bug: 34193647
Bug: 63467744
Test: m test-art-host
Change-Id: I14ef536e37eb19c0dede372ffd68a826c482cf71
c88e2ae198ad52d91109d04a18dbffd3b46c051a 21-Jul-2017 Chang Xing <chxing@google.com> Add AotClassLinker

Add AotClassLinker, this will enable the compiler driver to intercept
class verification to avoid reverifying classes for ag/2614411. This
is required since we can't reverify classes that have quickened
bytecodes.

Test: make test-art-host -j64

Bug: 63467744

Merged-In: If53d3ee3231c337a9ea917f5b885c173917765de

Change-Id: I3fb0264e99c7b327e2eb1bfbd714d2c1bacc1299
605fe24d07062a038c8332a4d98f47052e9cee6a 21-Jul-2017 Chang Xing <chxing@google.com> Implemented Nested Transaction

Transaction can be created recursively and every transaction knows which
class it is created for.

The goal of implementing nested transaction is to let every class
initialization (especially execution of class initializer) associates
with one transaction which provides the ability to track whether field
accesses are valid. To achieve this goal, we implemented a subclass for
ClassLinker called AotClassLinker, which will be instantiated instead of
ClassLinker under AOT compiler.

All invocations of InitializeClass happens at AOT compiler will be
wrapped with creating and destorying transactions.

Transactions will be paused when rollbacking, otherwise the memory will
not be rollbacked properly.

The use the transaction is changed and all usage are updated,
corresponding with native tests mentioning transaction, including
transaction_test and unstarted_runtime_test.

The validation rules will be implemented and explained in another CL.

Test: make test-art-host -j64

Change-Id: If53d3ee3231c337a9ea917f5b885c173917765de
5a906fcc111ffc07d9fd1e7265e8b4a89609f00e 27-Jul-2017 Chang Xing <chxing@google.com> Add strict flag in transaction

Add a flag named strict_ indicating whether we are compiling app images,
which need more strict constraints to control <clinit>s' behavours.

When the transaction is marked as strict mode, behaviour changes
including nested transactions, field access validation, memory
consumption limit and time out for <clinit> at compile time.

Test: make test-art-host -j64

Change-Id: I7cc0eea161803ad0d7763725d4deaeee21858054
c1ac9ee48ddf483ec770b424d63de4982262ea33 25-Jul-2017 Andreas Gampe <agampe@google.com> ART: Move CHA to ClassLinker

Move the ClassHierarchyAnalysis singleton to ClassLinker. Hierarchy
analysis is a link-time effort and belongs to class-loading instead
of the global Runtime object.

Also clean up to use a unique_ptr, and add null checks to allow
bypassing the analysis.

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

Let clang-format reorder the header includes.

Derived with:

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

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

Test: mmma art
Change-Id: Ia963a8ce3ce5f96b5e78acd587e26908c7a70d02
cade5c3c75588da6d873df727acdaf3378a66efa 21-Jul-2017 Chang Xing <chxing@google.com> Track class initializing in transaction

Add a field and a corresponding constructor to transaction which keeps
track of the class that the transaction is initializing.

To implement constraints for <clinit> behaviors, the transaction needs
to know which class it is initializing.

Test: make test-art-host -j64
Change-Id: I87b3fcb3ef15914c79c6687ec8a87058265eaead
16d1dd86dca33520b44d9802695e19d3b658af3e 21-Jul-2017 Chang Xing <chxing@google.com> Move transaction creation to runtime

Move the transaction creation to runtime instead of passing a pointer to
runtime when EnterTransactionMode. Because later there will be more
places to create transaction so this makes the code cleaner and more
compact.

Test: make test-art-host -j64
Change-Id: I971edf3110eb6634b6e0f7f56256be04517a5281
ba118827465d12177f3996e50133960087b1c916 12-Jun-2017 Vladimir Marko <vmarko@google.com> ART: Change method lookup to be more consistent to JLS and the RI.

The method lookup for different invoke types was previously
widely different and didn't work well with the dex cache
method array where we have only a single slot for each
MethodId. The new behavior is to perform the same lookup for
all cases, distinguishing only between interface and
non-interface referencing class, and to further align the
behavior with the JLS and the RI. Where the JLS conflicts
with the RI, we follow the JLS semantics.

The new lookup for class methods first searches the methods
declared in the superclass chain (ignoring "copied" methods)
and only then looks in the "copied" methods. If the search
in the superclass chain finds a method that has not been
inherited (i.e. either a private method or a package-access
method where one of the classes in the chain does not belong
to the same package, see JLS 8.4.8), we still search the
"copied" methods as there may actually be a method inherited
from an interface. This follows the JLS semantics where
inherited methods are included in the search (JLS 15.12.2.1)
but conflicts with the RI where the private or
package-access method takes precedence over methods
inherited from interfaces.

Note that this search can find an accessible method that is
not inherited by the qualifying type, either for a package
access method when the referrer is in the same package but
the qualifying type is in another package, or for a private
method where the referrer is in the same class but the
qualifying type is actually a subclass. For the moment we
allow such calls and we shall consider whether to throw
an IncompatibleClassChangeError in this situation in future
to comply with JLS 15.12.4.3.

The new lookup for interface methods searches the interface
class, then all the superinterfaces and then the
java.lang.Object class, see implicitly declared methods in
interfaces, JLS 9.2. The search for the maximally-specific
non-abstract superinterface method is not yet implemented,
but the difference should be difficult to observe as the
usual subsequent call to FindVirtualMethodForInterface()
should yield the same result for any matching method.

The new test 162-method-idx-clash exposes several cases
where we previously completely messed up due to the effects
of the DexCache, or where we were out of line with the RI.
It also tests a case where the JLS and the RI disagree and
we follow the JLS.

Test: art/test/run-test --host --jvm 162-method-resolution
Test: m test-art-host-gtest
Test: testrunner.py --host
Test: testrunner.py --host --interp-ac
Test: Nexus 6P boots.
Test: testrunner.py --target
Bug: 62855082
Bug: 30627598
Change-Id: If450c8cff2751369011d649c25d28a482a2c61a3
e431e2758d62cf56f7f347f5a8c9d79e41b6dcd7 19-Jul-2017 Steven Moreland <smoreland@google.com> art: use proper nativehelper headers

libnativeheader exports headers under nativeheader. These were
available before incorrectly as global headers in order to give
access to jni.h.

Test: modules using art find headers
Bug: 63762847
Change-Id: I5c820d677e94e07b2859e78610bc997fe51b41dc
d0210e58100e029e865e783beb7906090781f602 23-Jun-2017 Andreas Gampe <agampe@google.com> ART: Add stack-dump mode for contention logging

Add a second threshold to contention logging. If this threshold
is reached, log the owner and the contender thread to the logcat.

Requires a bit of refactor in the contention logging code to hold
the locks correctly (different requirements for owner and contender).
Add -Xstackdumplockprofthreshold:ms to control the threshold value.
As with general contention logging, default to 0 = off. Use ThreadStress
with --locks-only to get test coverage.

Bug: 62353392
Test: m test-art-host
Change-Id: I1b5a5130c4f908497ac06464130844f5ca42a5fb
0ffbe5f14b14e84585a75ababd4864c187afae04 22-Jun-2017 Andreas Gampe <agampe@google.com> ART: Refactor abort code

Remove Runtime::Aborter and let Runtime::Abort set the abort message
on target.

This works around a missing tail-call optimization that leads to a
superfluous frame on the call-stack when aborting.

Partially reverts commit 3fec9ac0d5af1358d216eb2fdc2000ec0205f3f0.

(cherry picked from commit 51d80ccca5eb2ea0eef0de836dcc03e0545f63db)

Bug: 62810360
Test: m test-art-host
Test: Manual inspection of abort dump
Change-Id: Ie4efc8bbdc8b665b23081b37a11921fe26b182b4
247fc334ca91c22b19ac57b9c8bbbd15a1735aa1 23-Jun-2017 Andreas Gampe <agampe@google.com> ART: Make gAborting an atomic

It's probably overkill for the abort path, but make it safe,
nonetheless.

Test: m test-art-host
Change-Id: I8d333ea5f01ad43bb98e71cd2c89902ced1bd68d
51d80ccca5eb2ea0eef0de836dcc03e0545f63db 22-Jun-2017 Andreas Gampe <agampe@google.com> ART: Refactor abort code

Remove Runtime::Aborter and let Runtime::Abort set the abort message
on target.

This works around a missing tail-call optimization that leads to a
superfluous frame on the call-stack when aborting.

Partially reverts commit 3fec9ac0d5af1358d216eb2fdc2000ec0205f3f0.

Bug: 62810360
Test: m test-art-host
Test: Manual inspection of abort dump
Change-Id: Ie4efc8bbdc8b665b23081b37a11921fe26b182b4
b2d18fa4e33ca119654ced872c70fe198b0b2db5 07-Jun-2017 Andreas Gampe <agampe@google.com> ART: Clean up asm_support.h

The includes are only ever really needed for tests. Factor out
generation of the test function into asm_support_check.h

Fix up missing includes, mainly intern_table.h.

Test: m
Test: m test-art-host
Change-Id: I435199e6211e368be0a06c80d8fa95b9593aca31
8228cdf4ad6322ec8133564aaa51f966d36c0f17 31-May-2017 Andreas Gampe <agampe@google.com> ART: Move CalleeSaveType to callee_save_type.h

Move the type out of runtime to decrease dependencies. Make it
a proper enum class. Fix up usage.

Test: m test-art-host
Change-Id: Id84c44bf3c59f37c8a43548e720c5fb65707b198
d482e73fe26cb9161511a80e3db39e08b9808ab6 25-Apr-2017 Andreas Gampe <agampe@google.com> ART: More header cleanup - runtime.h

Remove unnecessary runtime.h includes. Refactor other headers
(move to forward declarations) to make this possible.

Test: mmma art
Change-Id: I297f0ad444ba92169edd16d8c7cbe95bb6dbb800
eb71033745325ffd5682fe7a6a48900e74657b02 10-May-2017 Narayan Kamath <narayan@google.com> ART: Use file descriptors handed out by tombstoned for traces.

There no longer needs to be any logic in ART to generate file
names and create files. The test of file creation logic has
therefore been deleted.

Test: manual, tests in other components.
Bug: 32064548

Change-Id: I9bce6ddf3270839c40060d1287e79f9bd57d75aa
5f2a2fcdba7c3ee502f1fa5df1ba69be6c83da33 19-May-2017 Andreas Gampe <agampe@google.com> ART: Reserve sentinel early

Reserve the sentinel early. Its address is out of the way of the
image.

Test: m test-art-host
Change-Id: Id04a76baaab60db86e863746d5ad6966c60cd334
dafb6c2f9e8b9173ada6b8311bd88a0ed24c5bd5 27-Apr-2017 Josh Gao <jmgao@google.com> sigchain: always call InitializeSignalChain on startup.

Processes that link against libsigchain because they might want to
dynamically load libart.so (e.g. surfaceflinger) might never explicitly
call InitializeSignalChain. In this scenario, the lazy initialization
that occurs when sigprocmask is called can happen at unexpected times,
such as from pthread_exit, leading to deadlocks or crashes.

Add __attribute__((constructor)) to InitializeSignalChain to have it be
automatically called upon process start. Keep the existing calls to it
in the wrapper functions in order to sidestep problems around static
initialization order.

Bug: https://issuetracker.google.com/37119593
Test: run-test 004-SignalTest
Test: m test-art-host
Test: m test-art-target
Change-Id: I7906c1f625ccca0350ea9310140a3f43a657be4c
(cherry picked from commit fd4d0d3eb9b5c7fe2fa1df97d9c0763900b2be52)
2ac67d526eb348019433138b04eb1473d45cb0f4 12-May-2017 Andreas Gampe <agampe@google.com> ART: Reserve sentinel fault page

Attempt to reserve a single page on startup that contains addresses we
use for clobbering.

Test: m test-art-host
Change-Id: Ibc0a29c99ff3ff42290877faaadcb914234024e4
fd4d0d3eb9b5c7fe2fa1df97d9c0763900b2be52 27-Apr-2017 Josh Gao <jmgao@google.com> sigchain: always call InitializeSignalChain on startup.

Processes that link against libsigchain because they might want to
dynamically load libart.so (e.g. surfaceflinger) might never explicitly
call InitializeSignalChain. In this scenario, the lazy initialization
that occurs when sigprocmask is called can happen at unexpected times,
such as from pthread_exit, leading to deadlocks or crashes.

Add __attribute__((constructor)) to InitializeSignalChain to have it be
automatically called upon process start. Keep the existing calls to it
in the wrapper functions in order to sidestep problems around static
initialization order.

Bug: https://issuetracker.google.com/37119593
Test: run-test 004-SignalTest
Test: m test-art-host
Test: m test-art-target
Change-Id: I7906c1f625ccca0350ea9310140a3f43a657be4c
6e6444508de1afaeaf612970fad608b58b89b009 10-May-2017 Andreas Gampe <agampe@google.com> ART: Make GC Pause Listener more precise

Refactor code to call the listener in FlipThreadRoots, after all
threads have been suspended.

Bug: 37283268
Test: m test-art-host
Change-Id: I313db07e014e65a997d0b58c8a70e4505425def0
79efadfdd861584f1c47654ade975eae6c43c360 08-May-2017 Nicolas Geoffray <ngeoffray@google.com> Add runtime reasons for deopt.

Currently to help investigate. Also:
1) Log when deoptimization happens (which method and what reason)
2) Trace when deoptimization happens (to make it visible in systrace)

bug:37655083
Test: test-art-host test-art-target

(cherry picked from commit 4e92c3ce7ef354620a785553bbada554fca83a67)

Change-Id: I992398a1038ab61ea0e5106af6b6ad0a3305312e
4e92c3ce7ef354620a785553bbada554fca83a67 08-May-2017 Nicolas Geoffray <ngeoffray@google.com> Add runtime reasons for deopt.

Currently to help investigate. Also:
1) Log when deoptimization happens (which method and what reason)
2) Trace when deoptimization happens (to make it visible in systrace)

bug:37655083
Test: test-art-host test-art-target
Change-Id: I0c2d87b40db09e8e475cf97a7c784a034c585e97
bcea58374cbd1447c2c7f2ffdc08e10e8accb721 03-May-2017 Igor Murashkin <iam@google.com> runtime: Properly unload partially loaded image spaces

When one of the (non-app) image space successfully loads,
it sets up runtime callee-save methods.

If it is later unloaded, callee-save methods are now pointing to memory
that is no longer valid (viewed as all 0s in the debugger).

Runtime::Init skips creating its own runtime methods if it already sees
that the runtime methods were set to non-null, thus dangling runtime
methods.

This crash would nominally manifest itself in unwinding the first time, or as a DCHECK
failure in the interpreter bridge invocation during aborting if debugging was enabled.

To get into this state:
* Fill up the /data partition (but perhaps leave a little bit of room
for one image, but not all images)
* Reboot the device or run zygote manually.

(cherry picked from commit 8275fbaccc012072948a16f537844a552db9be84)

Test: adb shell dd if=/dev/zero of=/data/local/tmp/tempFiller.deleteMe bs=1024 count=50g ; adb reboot
Bug: 36033084
Change-Id: I728c1058b003fcf5e98dc2746d53e44b688c4605
cab655799dc0c04d42b00642a813438efe46acf5 21-Apr-2017 Nicolas Geoffray <ngeoffray@google.com> Make vdex and dexlayout compatible.

Unquicken the vdex before dexlayout, to keep the dex integrity.

bug: 37558732
Test: run-test with speed-profile

(cherry picked from commit 4e868fa7b8c47600695ff92deeb373674956a67d)

Change-Id: I57ddabb79ff49d01df80bed4e3e53ba8fdb5346e
8275fbaccc012072948a16f537844a552db9be84 03-May-2017 Igor Murashkin <iam@google.com> runtime: Properly unload partially loaded image spaces

When one of the (non-app) image space successfully loads,
it sets up runtime callee-save methods.

If it is later unloaded, callee-save methods are now pointing to memory
that is no longer valid (viewed as all 0s in the debugger).

Runtime::Init skips creating its own runtime methods if it already sees
that the runtime methods were set to non-null, thus dangling runtime
methods.

This crash would nominally manifest itself in unwinding the first time, or as a DCHECK
failure in the interpreter bridge invocation during aborting if debugging was enabled.

To get into this state:
* Fill up the /data partition (but perhaps leave a little bit of room
for one image, but not all images)
* Reboot the device or run zygote manually.

Test: adb shell dd if=/dev/zero of=/data/local/tmp/tempFiller.deleteMe bs=1024 count=50g ; adb reboot
Bug: 36033084
Change-Id: I728c1058b003fcf5e98dc2746d53e44b688c4605
c4bed16daa6689eaa2148261b19662291417ced6 01-May-2017 Andreas Gampe <agampe@google.com> ART: Change shutdown order

Add explicit Shutdown method to ThreadList, doing the work that
was previously in the destructor. Call sid method before unloading
plugins and stopping the debugger.

Modulo daemon threads, this ensures that thread events will have
quiesced when plugins stop.

Bug: 37763974
Test: m test-art-host
Change-Id: I11d22f2c89a68e9f6720d61967b8e5aea41188dc
a10ac2ac733a9dc07962cfea2502605141e61953 21-Apr-2017 Nicolas Geoffray <ngeoffray@google.com> Rename and obsolete compiler filter names.

ART side of the change.

bug:34715556
Test: test-art-host, jdwp, libcore

(cherry picked from commit 49cda06d5bf003f588ba7839bbf89d606237dfa7)

Change-Id: I85126e5035f0f6fc15aa84d41af5f1d6e25a5f55
4e868fa7b8c47600695ff92deeb373674956a67d 21-Apr-2017 Nicolas Geoffray <ngeoffray@google.com> Make vdex and dexlayout compatible.

Unquicken the vdex before dexlayout, to keep the dex integrity.

bug: 37558732
Test: run-test with speed-profile

Change-Id: Ifcd5c2e4378ccb0df0a66d07f68df31d94b83220
84695aef89a3c42ea81c23f0590ae2ceca09ce6f 07-Apr-2017 Narayan Kamath <narayan@google.com> ART: Support per PID stack trace files.

Introduce an -Xstacktracedir argument that supplies a directory
under which stack traces are written, with a unique file created
per trace. The location of the actual directory in a production
system is still not decided, and follow up changes might be
introduced to supply a per process override.

Bug: 32064548
Test: test-art-host, test-art-target

Change-Id: If377ce6a2abe8b325f6441d8de222b1ea3f40ec9
c15a2f4f45661a7f5f542e406282c146ea1a968d 21-Apr-2017 Andreas Gampe <agampe@google.com> ART: Add object-readbarrier-inl.h

Move some read-barrier code into a new header. This prunes the
include tree for the concurrent-copying collector. Clean up other
related includes.

Test: mmma art
Change-Id: I40ce4e74f2e5d4c692529ffb4df933230b6fd73e
49cda06d5bf003f588ba7839bbf89d606237dfa7 21-Apr-2017 Nicolas Geoffray <ngeoffray@google.com> Rename and obsolete compiler filter names.

ART side of the change.

bug:34715556
test: test-art-host, jdwp, libcore
Change-Id: I3a73ae4af2d602431150c8ecfceaddb9ba519cee
a25504e7026109227691ca944f9359ca23d733ab 19-Apr-2017 Mathieu Chartier <mathieuc@google.com> Call mirror::CallSite::VisitRoots

Needed to visit CallSite static class root.

Test: test/run-test --no-patchoat --relocate --host --64 --interpreter --gdb 952

Bug: 33191717

Change-Id: I1fad3df8ad810c5c7905afadfa25cdc0901ef035
1d4950167b45369299fe30d7381516c3b5380a01 12-Apr-2017 Mathieu Chartier <mathieuc@google.com> Fix -XX:DumpGCPerformanceOnShutdown for debug builds

There was a failing DCHECK from CheckUnattachedThread. The fix is
to dump after attaching the shutdown thread.

Bug: 35644369
Test: test-art-host

Change-Id: I3d927e380888418167c101b2f09d1e547fe728cf
f9c917f8c149afc07e51604ea48508fbabcb4a3f 31-Mar-2017 Mathieu Chartier <mathieuc@google.com> Allow -Xjitsaveprofilinginfo for system server

setenforce 0 is still required to prevent selinux violations.

Test: adb shell setprop dalvik.vm.extra-opts "'-Xusejit:false -Xint -Xjitsaveprofilinginfo'" && adb shell start

Bug: 34927277
Bug: 36457259

(cherry picked from commit 449f0589c8c8572e32c57befee089123e9eea1ba)

Change-Id: I644cefe8aebf9ff47dc736eda8143d2f6258c324
449f0589c8c8572e32c57befee089123e9eea1ba 31-Mar-2017 Mathieu Chartier <mathieuc@google.com> Allow -Xjitsaveprofilinginfo for system server

setenforce 0 is still required to prevent selinux violations.

Test: adb shell setprop dalvik.vm.extra-opts "'-Xusejit:false -Xint -Xjitsaveprofilinginfo'" && adb shell start

Bug: 34927277
Bug: 36457259
Change-Id: I4d34b8662f596cb6d7a1ad0a2182ac88eb9bec41
9545f6db8b2487ecb940f91c29ce814ec6b1ea25 17-Mar-2017 Calin Juravle <calin@google.com> Accept output profile path from dalvikvm command

Test: run dalvikvm with -Xps-profile-path
Bug: 36032648

Change-Id: I34640afe1cf0e7b192ad082ccde2784faab1ba4c
6b2dc3156a2140a5bfd9cbbf5d7dad332ab5f5bd 14-Mar-2017 Narayan Kamath <narayan@google.com> ART: Get rid of most of java.lang.DexCache.

All remaining functionality is moved over to native. The DexCache
object itself is allocated in the Java heap, even though there's no
longer much of a reason to do so. It can be changed in a future change
if needed.

This also renames mirror::Class:GetInterfaces to GetProxyInterfaces
since it's supposed to be called only for proxies.

Test: test-art-host, cts -m CtsLibcoreTestCases

Change-Id: Ie261f22a9f80c929f01d2b456f170c7a464ba21c
a345d3144c56e510866848fd677b05adc7780189 15-Mar-2017 Calin Juravle <calin@google.com> Ensure the profile is written to disk at shutdown

Force profile saving during shutdown. It will make benchmark automation
much easier.

Test: test-art-host
Bug: 26719109
Change-Id: I529aa1a7b1192c53960fdb4ddc13b10b99e846cc
77651c4bbd56d502bcf05347e641061bbebca099 04-Mar-2017 Calin Juravle <calin@google.com> ART: Clean up code related to foreign dex use

We simplified the way we track whether or not a dex file is used by
other apps. DexManager in the framework keeps track of the data and we
no longer need file markers on disk.

Test: device boots, foreign dex markers are not created anymore

Bug: 32871170

(cherry picked from commit 868515e2606820ea96f8b9022b442f5bcc770867)

Change-Id: If51b3301c845a8c3bbaf87d0e35a12c700e1d0aa
Merged-In: I5a04d3bba29581dedf05e21b8b20d79afa9b405a
868515e2606820ea96f8b9022b442f5bcc770867 04-Mar-2017 Calin Juravle <calin@google.com> ART: Clean up code related to foreign dex use

We simplified the way we track whether or not a dex file is used by
other apps. DexManager in the framework keeps track of the data and we
no longer need file markers on disk.

Test: device boots, foreign dex markers are not created anymore

Bug: 32871170
Change-Id: I5a04d3bba29581dedf05e21b8b20d79afa9b405a
e00e5590a9cfb72c89294dd7a5480e5fa69a90b9 24-Feb-2017 Vladimir Marko <vmarko@google.com> Fix java.lang.Void.TYPE (void.class) initialization.

Do not rely on the DexCache resolved types now that entries
can be evicted.

Test: 157-void-class
Test: testrunner.py --host
Bug: 35652776
Bug: 30627598
Change-Id: Ic384174ae1849072568dd6d2ff9cc60d7f7f1880
ea9465eaaa55646b0de242d2a21f9c1f0f0aa01f 17-Feb-2017 Alex Light <allight@google.com> Move InMemoryDexClassLoader to be a subtype of BaseDexClassLoader

Also write a test that class transformation works with this type of
class loader.

Test: mma -j40 test-art-host

Change-Id: Ibc2214191e04876ff7bbea010be6ec03b6f41904
c069a30d42aefd902c20e8bc09dfad1683f07ded 18-Jan-2017 Orion Hodson <oth@google.com> ART: invoke-custom support

Adds invoke-custom instruction to the interpreter.

Bug: 33191717,30550796
Test: art/test/run-test --host 952
Change-Id: I3b754128649a8b3a00ade79ba2518d0e377f3a1e
f9e3754e8a2f6244e037362c03db32d4244ecb2d 30-Jan-2017 Andreas Gampe <agampe@google.com> Revert "Revert "ART: Give JIT thread pool workers a peer""

This reverts commit 9dfb707ba2f8c2ff67d42c26e3214f5d7142b6d3.

Accept a live Java thread for the JIT, and adjust the tests
accordingly.

(cherry picked from commit 4471e4f7c5874bdaf93762b6047d4a4bebc465df)

Bug: 31684920
Test: m ART_TEST_JIT=true ART_TEST_INTERPRETER=true test-art-host
Change-Id: I92cbae1eaae05711b9069335cf1a5f7eb58b9fd8
f5f462b8e448c13d30094d0d259d8b06bc525376 15-Dec-2016 Calin Juravle <calin@google.com> Add Thread entry to signal if the thread can call into java

Compiler threads (AOT or JIT) should not call into Java as they have no
peers (which may lead to crashes, e.g. b/33067273)

(cherry picked from commit ccd56958eb46fbb00c1eb45c7a7b23d5bbfd7698)

Bug: 32602185
Bug: 33067273

Test: m test-art-host-run-test; m test-art-host-gtest
Change-Id: I97dda7a5444643db3c5d5318339a65a602f709e8
4471e4f7c5874bdaf93762b6047d4a4bebc465df 30-Jan-2017 Andreas Gampe <agampe@google.com> Revert "Revert "ART: Give JIT thread pool workers a peer""

This reverts commit 9dfb707ba2f8c2ff67d42c26e3214f5d7142b6d3.

Accept a live Java thread for the JIT, and adjust the tests
accordingly.

Bug: 31684920
Test: m ART_TEST_JIT=true ART_TEST_INTERPRETER=true test-art-host
Change-Id: I92cbae1eaae05711b9069335cf1a5f7eb58b9fd8
433b79a9130df5f2375b9d3d7518c1f3fb84a467 30-Jan-2017 Nicolas Geoffray <ngeoffray@google.com> Revert "Revert "Make --debuggable rely on JIT code.""

Fixed by https://android-review.googlesource.com/#/c/330165/

This reverts commit 81356645157af44152c7b7db383596b5cf3479b5.

Change-Id: Ifb74e1cc90ab6dea621f7f54a00b540d6ccd0cf6
81356645157af44152c7b7db383596b5cf3479b5 30-Jan-2017 Vladimir Marko <vmarko@google.com> Revert "Make --debuggable rely on JIT code."

Breaks 137-cfi with ART_TEST_RUN_TEST_DEBUGGABLE=true

This reverts commit a0619e25aacf8b8074132f4951f75fdbcfd42925.

bug: 28769520
Change-Id: Ifd7b8fc7c9b72c0a523fd57c4b1b80edd3547caa
a0619e25aacf8b8074132f4951f75fdbcfd42925 20-Dec-2016 Nicolas Geoffray <ngeoffray@google.com> Make --debuggable rely on JIT code.

Removes -Xfully-deoptable in the process, which was added as a
temporary workaround until this CL.
Partial revert of https://android-review.googlesource.com/#/c/302232/

Makes things consistent with existing infrastructure:

- Parse the --debuggable from the compiler options, just like
--compiler-filter.

- Add DEBUG_JAVA_DEBUGGABLE, passed by the zygote, for debuggable apps.

- Java debuggable now solely relies on JIT for simplicity.

- Debugging under userdebug for non-java-debuggable apps is still
best effort.

Test: test-art-host, jdwp

bug: 28769520
Change-Id: Id0593aacd85b9780da97f20914a50943957c858f
9dfb707ba2f8c2ff67d42c26e3214f5d7142b6d3 28-Jan-2017 Andreas Gampe <agampe@google.com> Revert "ART: Give JIT thread pool workers a peer"

This reverts commit 1ee6dd71e1b9e51e15aae4d3bc95d799f11dbd04.

Has unintended consequences that need to be discussed.

Bug: 31684920
Change-Id: If0ff1b5d7473f98cb3a0efc3b4bb2c0f96ad684d
1ee6dd71e1b9e51e15aae4d3bc95d799f11dbd04 24-Jan-2017 Andreas Gampe <agampe@google.com> ART: Give JIT thread pool workers a peer

To allow reporting those threads, give JIT pool threads a peer.
This is necessary as the compiler may load classes.

Bug: Bug: 29547798
Bug: 31684920
Test: m ART_TEST_JIT=true test-art-host
Change-Id: I7c8e44132475f38995542da76285ca3dd63c559a
bd2fed5a813b68fa42fe941b07325ba4ff3190b0 25-Jan-2017 Narayan Kamath <narayan@google.com> MethodHandles: Support and tests for revealDirect / reflectAs.

We need runtime support to materialize a Constructor, Field or
Method object from a MethodHandle and its associated ArtField
or ArtMethod pointer.

An alternate approach might be to have all handles hold a reference
to their associated Field or Method object (in addition to the
raw ArtField or ArtMethod) but that seems unnecessary given that
these APIs are not expected to be called often.

Test: test-art-host

Change-Id: I9450706b9c30359edebf2e8a7afbc8d89bd68b26
01fd70b531a8bd8ebb2238f20c3e651f6b065285 25-Jan-2017 Andreas Gampe <agampe@google.com> ART: Remove experimental flags for plugins and agents

Remove experimental flags guarding plugins and agents.

Partial revert of commit 7233c7e752c0d26387d143ee74420e9cd1f09390.
Partial revert of commit 185d134a3b43ab7529053e965917e0fa74bceba4.

Bug: 31455788
Test: m test-art-host
Change-Id: I11a19f24b88ced8da7a28e2cb7a2f602aab884a8
3fceaf500d570722122f2d092f302d27769e3a51 22-Jan-2017 Mathieu Chartier <mathieuc@google.com> Use higher default thread suspend timeout for run tests

Increase the default for tests from 10s-50s to 500s. This is done
by adding a run-test option "--suspend-timeout" that defaults to
500000.

Example when passing a low value of 100:
test/run-test --host --suspend-timeout 100 --dev 004-ThreadStress

Results in:
dalvikvm32 F 01-22 13:33:31 12067 12118 thread_list.cc:669] Timed
out waiting for threads to suspend, waited for 100.114ms

This should fix some of the recent test flakiness.

Test: test-art-host

Change-Id: I303c4f198e560e9f38ec375e9d7a80a5e61f776e
eafaf57557939bcabeb7a7388fb4951e74661a53 20-Jan-2017 Andreas Gampe <agampe@google.com> ART: Add ThreadStart & ThreadEnd

Add support for ThreadStart and ThreadEnd events. Add tests.

Bug: 31684920
Test: m test-art-host-run-test-924-threads
Change-Id: I516993402747ffdc9a7d66985b21b95c059be107
96eca7895813ec70bbbbdb2aff7a3a03dcd3b21e 20-Jan-2017 Andreas Gampe <agampe@google.com> ART: Add GetPhase

Extend RuntimePhaseCallback. Add support for GetPhase.
Add tests.

Bug: 31455788
Test: m test-art-host-run-test-901-hello-ti-agent
Change-Id: I33b1934a0789bc713675f21c2c9f676c9d3a1ed1
4886411a81077e893a6e38c56938a252888ddd0e 20-Jan-2017 Andreas Gampe <agampe@google.com> ART: Add runtime phase callback

Add callback that describes the current runtime phase, one of
starting, initialized and death. Add test.

Bug: 31684920
Test: m test-art-host-gtest-runtime_callbacks_test
Change-Id: I08ae7c45851572f8b3e446c07f0498f66bb032d3
a5814f9de6009cc1763523109f50aae6bd1ff99e 19-Jan-2017 Andreas Gampe <agampe@google.com> ART: Add SigQuit Callback

Add callback being triggered when the runtime handles SigQuit.

Bug: 31684920
Test: m test-art-host-gtest-runtime_callbacks_test
Change-Id: I23e3b256c654b6078c79b3897439d893ea79d96e
ac30fa2151095d2b5fe42f169a02ed09fea312b4 19-Jan-2017 Andreas Gampe <agampe@google.com> ART: Make RuntimeCallbacks unique_ptr

Reduce the transitive closure of headers on runtime.h

Test: m
Change-Id: Ib5a3632c28b08bf07773f217a7ad711c1f12af6b
0f01b583c3952d0219696480654a0db8fac4b661 19-Jan-2017 Andreas Gampe <agampe@google.com> ART: Add ClassLoadCallback

Add callback for class-load and class-prepare events. Move Dbg
over. Add tests.

Bug: 31684920
Test: m test-art-host-gtest-runtime_callbacks_test
Test: art/tools/run-jdwp-tests.sh --mode=host
Change-Id: I871f6b3c54448fd6ece8d9a7571b2042be50d525
04bbb5be5b9c0f0b3a72116353d23ea63c8bc5e9 19-Jan-2017 Andreas Gampe <agampe@google.com> Revert "Revert "ART: Start RuntimeCallbacks""

This reverts commit bf6331a45f730e1f1044af2ce43bceda660ae6fc.

Switch to using the mutator lock.

Bug: 31684920
Test: m test-art-host-gtest-runtime_callbacks_test
Test: art/tools/run-jdwp-tests.sh --mode=host --debug
Change-Id: I6ce0f71de2aa9f90cd23cfca7723a793b560b16b
bf6331a45f730e1f1044af2ce43bceda660ae6fc 19-Jan-2017 Nicolas Geoffray <ngeoffray@google.com> Revert "ART: Start RuntimeCallbacks"

jdwp tests failing with:
STDERR> dalvikvm32 E 01-18 23:14:50 12180 12198 thread-inl.h:137] holding "runtime callbacks lock" at point where thread suspension is expected

Bug: 31684920

This reverts commit 13093d455b8266338fd713b04261c58e9dc2b164.

Change-Id: I94e4154e273d006eecdd485607dcfd96392d6a00
13093d455b8266338fd713b04261c58e9dc2b164 18-Jan-2017 Andreas Gampe <agampe@google.com> ART: Start RuntimeCallbacks

Add a central RuntimeCallbacks structure to handle certain interesting
runtime events.

In a first iteration, add ThreadLifecycleCallback with ThreadStart and
ThreadStop. Move Dbg over to ThreadLifecycleCallback.

Add a test.

Bug: 31684920
Test: m test-art-host-gtest-runtime_callbacks_test
Test: art/tools/run-jdwp-tests.sh --mode=host
Change-Id: Ie0f77739a563207bfb4f04374e72dc6935c40b4f
1f64859d59dc5da93913a1230cbb4e66d6e524c0 13-Jan-2017 Andreas Gampe <agampe@google.com> ART: Remove suspension from AttachAgent

It conflicts with calls later. Every plugin needs to do local
protections for itself.

Follow-up to commit ad2dc875ce29c3fafc1129a2a25184df28b66a10.

Bug: 31682382
Bug: 34275017
Test: m test-art-host-run-test-909-attach-agent
Change-Id: Ib698d880feb774a00c819ef14c27a48501ca1f13
c4baad2aa4857e0f64c37abc5185964b47aed8e1 12-Jan-2017 Andreas Gampe <agampe@google.com> Revert "Revert "ART: Ensure plugin is loaded on AttachAgent""

Agents require the JVMTI plugin. Ensure that it is loaded when
trying to satisfy an AttachAgent request. Amend test 909.

This reverts commit 98cf7cf8766770dba2718a6131345cc7f57c5bc7.
Blacklist debuggable test configurations for negative test.

Bug: 31682382
Test: m test-art-host-run-test-909-attach-agent
Change-Id: I7720a18689bd6ddee38292dd42faf190fc06d14d
98cf7cf8766770dba2718a6131345cc7f57c5bc7 12-Jan-2017 Nicolas Geoffray <ngeoffray@google.com> Revert "ART: Ensure plugin is loaded on AttachAgent"

Test fails.
Bug: 31682382

This reverts commit ad2dc875ce29c3fafc1129a2a25184df28b66a10.

Change-Id: Id15d9d5478d2f72a4dc59f119944a311be7bc989
ad2dc875ce29c3fafc1129a2a25184df28b66a10 11-Jan-2017 Andreas Gampe <agampe@google.com> ART: Ensure plugin is loaded on AttachAgent

Agents require the JVMTI plugin. Ensure that it is loaded when
trying to satisfy an AttachAgent request. Amend test 909.

Bug: 31682382
Test: m test-art-host-run-test-909-attach-agent
Change-Id: Id99d0315b5b2577167dd8f8448a052e04f3ed2e5
ccd56958eb46fbb00c1eb45c7a7b23d5bbfd7698 15-Dec-2016 Calin Juravle <calin@google.com> Add Thread entry to signal if the thread can call into java

Compiler threads (AOT or JIT) should not call into Java as they have no
peers (which may lead to crashes, e.g. b/33067273)

Bug: 32602185
Bug: 33067273

Test: m test-art-host-run-test; m test-art-host-gtest
Change-Id: I97dda7a5444643db3c5d5318339a65a602f709e8
eca3eda2ccc121b13ce0e6d8c8c6c4040f7147b6 09-Nov-2016 Vladimir Marko <vmarko@google.com> Add ClassLoader to app-image roots.

Previously we were looking for class loaders by going
through the dex cache type array. When we change the array
to be hash-based, we may not actually find the class loader
that way.

Bug: 30627598
Test: m test-art-host
Change-Id: Ic91a81853fec9946e26bb8272d2a9120393a43bf
9186ced255f2e7402646b5b286deebb540640734 12-Dec-2016 Andreas Gampe <agampe@google.com> ART: Clean up utils.h

Remove functionality provided by libbase. Move some single-use
functions to their respective users.

Test: m test-art-host
Change-Id: I75594035fa975200d638cc29bb9f31bc6e6cb29f
585da955bc8e5040705dcfd941b2131025ebcef8 02-Dec-2016 Andreas Gampe <agampe@google.com> ART: Add precise root visiting

Add VisitRootFlags::kVisitRootFlagPrecise to signal a
request for precise RootInfo objects.

Move VisitRootFlags to gc_root.h. Refactor VisitRoot
functions to pass flags. Add code in Thread visiting
to decode vregs in compiled code.

Bug: 31385354
Test: m test-art-host
Change-Id: I8e7280f0ab682871f729f2a1c6b18670cf2dbf82
cc1b5357f83f0b787d51fbfde3fe870c8a2fa050 02-Dec-2016 Andreas Gampe <agampe@google.com> ART: Clean up ClassLinker

Try to clean up and simplify ClassLinker.

Move dex_lock to Locks. Remove dead code. Move single-use
code to user. Hide implementation details from header.

Test: m test-art-host
Change-Id: I58150fa9c2a9524f8304370270c2197d655cb3a8
063fc772b5b8aed7d769cd7cccb6ddc7619326ee 02-Aug-2016 Mingyao Yang <mingyao@google.com> Class Hierarchy Analysis (CHA)

The class linker now tracks whether a method has a single implementation
and if so, the JIT compiler will try to devirtualize a virtual call for
the method into a direct call. If the single-implementation assumption
is violated due to additional class linking, compiled code that makes the
assumption is invalidated. Deoptimization is triggered for compiled code
live on stack. Instead of patching return pc's on stack, a CHA guard is
added which checks a hidden should_deoptimize flag for deoptimization.
This approach limits the number of deoptimization points.

This CL does not devirtualize abstract/interface method invocation.

Slides on CHA:
https://docs.google.com/a/google.com/presentation/d/1Ax6cabP1vM44aLOaJU3B26n5fTE9w5YU-1CRevIDsBc/edit?usp=sharing

Change-Id: I18bf716a601b6413b46312e925a6ad9e4008efa4
Test: ART_TEST_JIT=true m test-art-host/target-run-test test-art-host-gtest
e51ca8bfa8a193b64901ad214842f213adca92eb 22-Nov-2016 Nicolas Geoffray <ngeoffray@google.com> Move inline caches GC handling in JitCodeCache.

Make the classes they hold weak references and visit
them during SweepJitRoots.

This fixes the newly introduced deadlock:

Thread1:
1) Lock JitCodeCache lock to create Profiling info for
ArtMethod m.
2) m is a copied method, we need to track the actual holder,
needing to decode a weak reference.
3) Weak references are not accessible due to GC.

GC Thread:
- Disallow weak reference access.
- Wait for checkpoint.

Thread2:
- Try to lock JitCodeCache lock
- Deadlock, as Thread1 owns the JitCodeCache lock.

Test: test-art-host
bug: 31289185
bug: 33198826

Change-Id: I7ee17631015450ace8d2a0264415a81c5a902bb8
8a0128a5ca0784f6d2b4ca27907e8967a74bc4c5 28-Nov-2016 Andreas Gampe <agampe@google.com> ART: Add dex::StringIndex

Add abstraction for uint32_t string index.

Test: m test-art-host
Change-Id: I917c2881702fe3df112c713f06980f2278ced7ed
1af0c4ff8b79ad44a4e12d7271a66d4e775ba224 16-Nov-2016 Julien Duraj <julien.duraj@linaro.org> Fix the target Linux builds of ART

When ART_TARGET_LINUX was set it would hit some pieces of dead code that
were using old defines i.e. `__ANDROID__`

Test: export ART_TARGET_LINUX=true
Test: source build/envsetup.sh
Test: lunch
Test: cd art && mma

Change-Id: I80102750192928606e0884d2b723a87ccb7d7e19
9fd470f87342dfe974c8ec8c74239a547e768650 19-Nov-2016 Andreas Gampe <agampe@google.com> ART: Extend DumpRecursiveAbort

Accept recursive dump request for deeper recursions. Otherwise,
two or more threads aborting concurrently would ensure that there
are no dumps.

Test: m test-art-host
Change-Id: Ib82d64cceba0de89e352d9b15bcd5708db82498c
7afa45427cc2cef534a3fb68a295fa5a4f305062 18-Nov-2016 Andreas Gampe <agampe@google.com> ART: Dump native stack on recursive abort

Dump the native stack of the current thread on recursive abort.
That is safe to do, as it requires no runtime interaction.

Test: m test-art-host
Change-Id: I4e052916f1036c74dc9fa82b049b4574626a70bb
b67906bb98409911b4ffe7da7fcd5b049ee089fb 18-Nov-2016 Andreas Gampe <agampe@google.com> ART: Use cerr in Runtime::Abort on the host

Use cerr to immediately write out abort info on the host, in an
effort to make recursive aborts diagnosable. This is similar
(but slightly inferior) to the previous INTERNAL_FATAL fastpathing.

Test: m test-art-host
Change-Id: I7c49874951acd47e58faceeb84a9ba93159ca3b0
132d8363bf8cb043d910836672192ec8c36649b6 16-Nov-2016 Nicolas Geoffray <ngeoffray@google.com> Revert "Revert "Revert "Revert "JIT root tables.""""

Test: 626-set-resolved-string, test-art-host, test-art-target
Test: run-libcore-tests.sh
Test: phone boots and runs

This reverts commit 3395fbc20bcd20948bec8958db91b304c17cacd8.

Change-Id: I104b73d093e3eb6a271d564cfdb9ab09c1c8cf24
1b0adbf7b14973c3f110976de046d75a7d4ed934 15-Nov-2016 Hiroshi Yamauchi <yamauchi@google.com> Ensure CC GC is used for the read barrier config.

To prevent the -Xgc option from causing unsupported GC types to run.

Bug: 12687968
Test: test-art-host with CC.
Change-Id: I10b42190c0888342e9127c52e863ddae82e4d7a1
6b16d891bdf18cabed861cd67407eef9be639efd 11-Nov-2016 Alex Light <allight@google.com> Add option to force all code to be deoptimizable

Currently this can only be passed during runtime startup. We will add
support for doing it from the zygote in the future.

Bug: 28769520
Bug: 32369913

Test: m test-art-host

Change-Id: I5eb16887ea14b140217c123b3effd47c5c8b2768
3395fbc20bcd20948bec8958db91b304c17cacd8 14-Nov-2016 Nicolas Geoffray <ngeoffray@google.com> Revert "Revert "Revert "JIT root tables."""

libcore failures:
dalvikvm32 F 11-14 03:04:06 14870 14870 jit_code_cache.cc:310] Check failed: new_string != nullptr

This reverts commit 75afcdd3503a8a8518e5b23d21b6e73306ce39ce.

Change-Id: I5a6b6b48aa79a763d1ff1ba4d85d63811254787d
75afcdd3503a8a8518e5b23d21b6e73306ce39ce 10-Nov-2016 Nicolas Geoffray <ngeoffray@google.com> Revert "Revert "JIT root tables.""

Also contains Revert "Support kJitTableAddress in x86/arm/arm64."

This reverts commit 4acd03638fcdb4e5d1666f8eec7eb3bf6d6be035.
This reverts commit 997d1217830c0a18b70faeabd53c04700a87d7d9.

Test: ART_USE_READ_BARRIER=true/false test-art-host test-art-target

Change-Id: I77cb1e9bf8f1b4c58b72d3cf5ca31ced2aaa1ea3
3049324f4ef71b5d7a3de49bd77c75f07dbf8f3a 03-Nov-2016 Hiroshi Yamauchi <yamauchi@google.com> Make empty checkpoint work while weak ref access is disabled.

Fix a potential race on PushOntoMarkStack for CC by running an empty
checkpoint (while weak ref access is disabled).

Bug: 32508093
Bug: 12687968
Test: test-art-host with CC/CMS, libartd boot with N9, Ritz EAAC.
Change-Id: I3749bb525e7734804307ee16262355f3fc730312
4acd03638fcdb4e5d1666f8eec7eb3bf6d6be035 09-Nov-2016 Nicolas Geoffray <ngeoffray@google.com> Revert "JIT root tables."

May be the offender for jit-gcstress failure of 902.

This reverts commit ac3ebc3150760425ed00abd56da48f9a6e0666bc.

Change-Id: I9ea6c9236fd1729fed7d1868dd8a111172932308
ac3ebc3150760425ed00abd56da48f9a6e0666bc 05-Oct-2016 Nicolas Geoffray <ngeoffray@google.com> JIT root tables.

Implement root tables for the JIT. Each JIT compiled method
gets a table allocated before the stack maps.

The table gets visited through Runtime::SweepSystemWeaks.

Implement String roots for x86_64 as an example.

Test: test-art-host test-art-target

Change-Id: Id3d5bc67479e08b52dd4b253e970201203a0f0d2
13b27842e88ccf1a42807c92daeb108e867dc4cd 08-Nov-2016 Andreas Gampe <agampe@google.com> ART: Refactor jmethodID handling

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

Test: m test-art-host
Change-Id: I1385fcd4c08981491701da55a87036b447aa2fc2
cec2fd462aaa53918ba28a6a8149b812716ff957 03-Nov-2016 Alex Light <allight@google.com> Call ClassExt::VisitRoots

We were missing this call.

Test: ART_DEFAULT_GC_TYPE=GSS mma test-art-host
Change-Id: I559a64b04dde514888e37a86fafc260e55196f95
9e868098b4a5d666570e3924518978d7abd3542e 31-Oct-2016 Mathieu Chartier <mathieuc@google.com> Move intern table to ObjPtr

Also moved StringLog to use a GcRoot.

Also removed read barriers from lookup to prevent making weak strings
strongly live more often than necessary.

Bug: 31113334

Test: clean-oat-host && test-art-host CC baker

Change-Id: I05586e125d5dfed8d184890468fd398c79f32619
000e1885701c8fdad07a784e3771881fa9be1d8a 24-Oct-2016 Narayan Kamath <narayan@google.com> method_handles: Complete support for emulated stack frames.

Most of this change is a refactor that templatizes the code
that performs argument conversions. This allows us to copy arguments
between two shadow frames, or an emulated stack frame and a shadow
frame.

Test: make test-art-host
Bug: 30550796

Change-Id: I23e65735a2dbd28f3c7b7d1ccf9762e77e0cf1f1
eb84221ffc00357be6d69e2e461c7a45ee96334a 07-Oct-2016 Leonard Mosescu <mosescu@google.com> Enable agent attaching during live phase

This is the ART part, the plumbing from VMDebug_attachAgent() to
actually loading the agent into the runtime.

Test: m test-art-host

Bug: 31682382

Change-Id: I3ccc67aa050c1f78278882128983686ed44ddec2
f42eb2c7801dbb45a6ba20a372d5ba4712ebefba 19-Oct-2016 David Sehr <sehr@google.com> Remove mutex dependency on art::Runtime

Breaks the cyclic dependency between mutex and the runtime. This allows
the use of mutexes without instantiating a runtime.

Bug: 22322814
Test: test-art
Change-Id: Ia642e515937068d385e5bb1e10bbd3e50a6e36d2
da0a69edb24122d3d35ce1483c5ab94de919d714 11-Oct-2016 Richard Uhler <ruhler@google.com> Return error message if IndirectReferenceTable construction fails.

Previously if there was an error when constructing the
IndirectReferenceTable, the error message was lost. Now expose and
include the error message when throwing an exception related to
failures to construct the IndirectReferenceTable.

The error message is propagated through JVMEnvExt, JavaVMExt, and
Runtime::Init as well.

Bug: 32013594
Test: Added new 151-OpenFileLimit runtest.
Test: m test-art-host, m test-art-target

Change-Id: I3692f6928c9570358571bce634569d6f14cdeb05
f57589fd40e5b69dad5aff060ccef756507f381a 17-Oct-2016 David Sehr <sehr@google.com> Remove logging dependency on runtime

Moved the abort backtracing function to runtime, forcing callers to
supply the aborter at InitLogging. This makes runtime properly layer
on top of logging by removing the cyclic dependency.

Bug: 22322814
Test: test-art-host
Change-Id: I8b2e72174e937bb88fe1bddd6d04b564cfb011a9
f5b0f2cef8554efaa90adc6a1ae04c2b533970ed 14-Oct-2016 Brian Carlstrom <bdc@google.com> Ensure OpenDexFilesFromImage closes file to prevent file descriptor leak

(cherry picked from commit 645e477c2ce7a59ac98bc86463826cf082a13ad8)

Test: m -j32 test-art-host
Bug: 32095919
Change-Id: I44541edeb403a508e1b9794ee09fb1f55e3f42bf
645e477c2ce7a59ac98bc86463826cf082a13ad8 14-Oct-2016 Brian Carlstrom <bdc@google.com> Ensure OpenDexFilesFromImage closes file to prevent file descriptor leak

Test: m -j32 test-art-host
Bug: 32095919
Change-Id: I44541edeb403a508e1b9794ee09fb1f55e3f42bf
1a1de67c4923436eb7de7da334c6d77703375dbd 13-Oct-2016 Vladimir Marko <vmarko@google.com> Do not write empty class table and intern table to image.

And remove dead ClassLinker and InternTable code that would
be erroneously triggered by not writing the tables.

Test: m test-art-host
Change-Id: I2520daa8d1231e16112d44e364a72d782fa32527
a058fdf0cf7435a13a6e8cae5e3a9bfa1513828d 07-Oct-2016 Mathieu Chartier <mathieuc@google.com> Move mirror::Object setters to ObjPtr

Bug: 31113334

Test: test-art-host

Change-Id: I2c4c84645e194c3c435a4a6fd670176b0e98671f
97d7e1cd7f733cb33a0e238bec6d7ed525638cd1 04-Oct-2016 Vladimir Marko <vmarko@google.com> Remove #include "oat_file.h" from class_linker.h .

Refactor the OatClass and OatMethod related functions from
ClassLinker to OatFile and ArtMethod, respectively. Refactor
the remaining ClassLinker dependencies on OatFile to break
the #include dependency and reduce incremental build times.

Test: m test-art-host
Change-Id: Iebc5b9f81b48fbcf79821cc827a5d7c4a0261bf6
47d522b27febaeb4168b9069550218b3f55e1905 04-Oct-2016 Andreas Gampe <agampe@google.com> ART: Reprint long messages on abort

Add an abort message parameter to Runtime::Abort. In case the message
is multiline (and will thus not be completely preserved in the
Android abort reason), reprint the message after all threads have
been dumped.

Bug: 31893081
Test: m test-art-host
Change-Id: I65bc77691fec79f7c868a90d6132805fcc91e473
(cherry picked from commit 90a32b16feb58d4edf932fdcb6a070be3418e365)
1cc62e4ea24828fdb3f3da0b8603f0b107d09a04 04-Oct-2016 Mathieu Chartier <mathieuc@google.com> Rename ObjPtr::Decode to ObjPtr::Ptr

Done to prevent ambiguity with ScopedObjectAccess::Decode.

Bug: 31113334

Test: test-art-host
Change-Id: I07a2497cc9cf66386311798933547471987fc316
90a32b16feb58d4edf932fdcb6a070be3418e365 04-Oct-2016 Andreas Gampe <agampe@google.com> ART: Reprint long messages on abort

Add an abort message parameter to Runtime::Abort. In case the message
is multiline (and will thus not be completely preserved in the
Android abort reason), reprint the message after all threads have
been dumped.

Bug: 31893081
Test: m test-art-host
Change-Id: I65bc77691fec79f7c868a90d6132805fcc91e473
0795f23920ee9aabf28e45c63cd592dcccf00216 28-Sep-2016 Mathieu Chartier <mathieuc@google.com> Clean up ScopedThreadStateChange to use ObjPtr

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

Changed AddLocalReference / Decode to use ObjPtr.

Changed libartbenchmark to be debug to avoid linkage errors.

Bug: 31113334

Test: test-art-host

Change-Id: I4d2e160483a29d21e1e0e440585ed328b9811483
afa48270228832ecd7df4506915354d1a41f374a 03-Aug-2016 Narayan Kamath <narayan@google.com> java.lang.invoke: Add mirror types for MethodHandle / MethodType.

Bug: 30550796
Test: make test-art-host
Change-Id: I096160464bc6e84f7e5ad021306a7e462cf3b0c5
3fec9ac0d5af1358d216eb2fdc2000ec0205f3f0 13-Sep-2016 Andreas Gampe <agampe@google.com> ART: Use libbase logging

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

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

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

Bug: 31338270
Test: m test-art-host
Change-Id: I5abcb2f45f5b03d49951874c48544f72a283a91b
866d874c4fca90385251a1df28eed0eb6e1b88e2 22-Sep-2016 Mathieu Chartier <mathieuc@google.com> Make image test multi image

Required for testing multi image layout in future CLs.

Bug: 28640955

Test: clean-oat-host, test-art-host, device booting

(cherry picked from commit 25adcfb7dc81131add3a0a681ae18bced6f7a0e0)

Change-Id: I14809f56e711b4a87e01056c327eddbbd087f4ee
25adcfb7dc81131add3a0a681ae18bced6f7a0e0 22-Sep-2016 Mathieu Chartier <mathieuc@google.com> Make image test multi image

Required for testing multi image layout in future CLs.

Bug: 28640955

Test: clean-oat-hos, test-art-host, device booting

Change-Id: I14809f56e711b4a87e01056c327eddbbd087f4ee
0e8443995af602bcc2e70dcef1d20ee48acec934 08-Sep-2016 Neil Fuller <nfuller@google.com> Collapse ART's AbstractMethod class into Executable

After the OpenJDK 8 pull there is now a common base class
for Method and Constructor that can be used instead.

Methods that are abstract on Executable but on Android
were implemented in AbstractMethod are now consistently
renamed to "{method}Internal", declared final and
given package-protected access.

For consistency with all other private, natively
implemented methods, the method getDeclaredAnnotations()
has been renamed getDeclaredAnnotationsNative().

Bug: 28666126
Bug: 31052885
Test: make test-art-host and cts run of CtsLibcoreTestCases
Change-Id: Ibfe6af6a47fe0cfffd0859ffbe58980aeb84e053
b2267032bd852c5566462057135967b24fdfe076 14-Sep-2016 Robert Sesek <rsesek@google.com> Move art::Runtime::InitZygote logic from art into frameworks/base.

Test: m test-art
Test: m
Test: aosp_angler-eng boots
Change-Id: I119cdd74e5909137365ce723fca1a003ef3c5f95
fda5714edb368270b7ef639054f4cba1d5f4874c 09-Sep-2016 Andreas Gampe <agampe@google.com> ART: Add generic system-weak holder infrastructure

Add an "interface" for a generic system-weak holder that is
integrated with the well-known instances in Runtime. Add a
simple implementation handling synchronization.

Add a test.

Bug: 31385027
Test: m test-art-host-gtest-system_weak_test
Test: m ART_USE_READ_BARRIER=true test-art-host-gtest-system_weak_test
Test: m ART_DEFAULT_GC_TYPE=SS test-art-host-gtest-system_weak_test
Test: m ART_DEFAULT_GC_TYPE=GSS test-art-host-gtest-system_weak_test
Change-Id: I1100e2cbd9ee57860993d0039de73d197681c542
c93b3be140f6a57a572f2a4cdaf46aba87235a02 12-Sep-2016 David Brazdil <dbrazdil@google.com> Fix run-test after introduction of VDEX

Run-test 119-noimage-patchoat used to fail due to a codepath in
OatFile which allows to create an instance of the class from an
existing ElfFile instance. This patch updates the codepath to require
an existing VdexFile as well.

Test: art/test/run-test 119
Bug: 30937355
Change-Id: I8fd0e47f07921aaee999f73711766ada9c35d214
bb816d66aabb9c2a2e095517d2013041116332db 07-Sep-2016 Mathieu Chartier <mathieuc@google.com> Add transactions for string resolve

Fixes a bug where resolved strings can be left in the dex cache after
a transaction is rolled back even though the interned string was
removed.

Added test in transaction_test.

Bug: 31239436

Test: test-art-host

Change-Id: I42c67bcefeae8db134cde34c480261f52db4102e
60458a072c4f0b24038420b0f1bed0fe94c72965 01-Sep-2016 Neil Fuller <nfuller@google.com> Track libcore Executable.getParameter() changes

Executable.getParameter() has been added which added
two new fields to java.lang.reflect.Executable,
impacting class arrangements and padding.

The java.lang.reflect.Parameter class has been added
which has some associated native code and support
methods in DexFile.

Test: make test-art-host
Bug: 28666126
Change-Id: I4ff6469388879651a6c9e568eca0b1cd716f0c0d
a4c2a054ca946eb14496fe8e9fd6057a59ccf692 17-Aug-2016 Orion Hodson <oth@google.com> Support for loading classes from DEX files stored in a ByteBuffer.

Bug: http://b/26878838
Test: test-art-target-gtest-dex_file_test

Change-Id: I68845c35784386bde6270102f0079d4f07bc4d03
0e4a2f0d6b526d398b71a54395c3071a8e78e503 17-Aug-2016 David Sehr <sehr@google.com> Save environment snapshot and use at fork/exec

Some applications may inadvertently or maliciously set of environment
variables such as LD_LIBRARY_PATH before spawning subprocesses.
To make this more difficult, save the environment at the time the
runtime starts and use the saved copy anytime Exec is called.

BUG: 30160149
TEST: make test-art-{host,target}

Change-Id: I887b78bdb21ab20855636a96da14a74c767bbfef
(cherry picked from commit d106d9f871c957286ccdeb79c1c2a5ed41f859a6)
bdf7f1c3ab65ccb70f62db5ab31dba060632d458 31-Aug-2016 Andreas Gampe <agampe@google.com> ART: SHARED_REQUIRES to REQUIRES_SHARED

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

Test: m
Test: m test-art-host
Change-Id: Ia8986b5dfd926ba772bf00b0a35eaf83596d8518
d106d9f871c957286ccdeb79c1c2a5ed41f859a6 17-Aug-2016 David Sehr <sehr@google.com> Save environment snapshot and use at fork/exec

Some applications may inadvertently or maliciously set of environment
variables such as LD_LIBRARY_PATH before spawning subprocesses.
To make this more difficult, save the environment at the time the
runtime starts and use the saved copy anytime Exec is called.

BUG: 30160149
TEST: make test-art-{host,target}

Change-Id: I887b78bdb21ab20855636a96da14a74c767bbfef
47393386aa1f44c61a10045c7dbb5d559c9f7cab 23-Aug-2016 David Sehr <sehr@google.com> Revert "Save environment snapshot and use at fork/exec"

This reverts commit 1488ff8aa3b041734ef0fbd113df512a2376e44e.

Change-Id: I3c237c94ffa865378f8efd9aa2b0fb2ad33867c2
1488ff8aa3b041734ef0fbd113df512a2376e44e 17-Aug-2016 David Sehr <sehr@google.com> Save environment snapshot and use at fork/exec

Some applications may inadvertently or maliciously set of environment
variables such as LD_LIBRARY_PATH before spawning subprocesses.
To make this more difficult, save the environment at the time the
runtime starts and use the saved copy anytime Exec is called.

BUG=b/30160149
TEST=make test-art-{host,target}-gtest-utils_test

Change-Id: Ice0097bf0de30db3d4ead124caf93316f39e3df3
185d134a3b43ab7529053e965917e0fa74bceba4 11-Aug-2016 Alex Light <allight@google.com> Add basic runtime-plugins support.

This allows one to pass shared-libraries on the command line that the
runtime will load as plugins. They have access to runtime code and can
install hooks to add functionality. Currently the only hook they can
touch is JavaVMExt::AddEnvironmentHook to register a callback for
GetEnv(). More hooks might be added in the future.

Test: ./test/run-test 900
Change-Id: I852b4daf5a3fa71e9888722bc07794632c0e5010
7233c7e752c0d26387d143ee74420e9cd1f09390 28-Jul-2016 Alex Light <allight@google.com> Create a basic agent loading framework.

Currently we only allow agents to be loaded at runtime startup, though
this is expected to change soon.

Test: ./test/run-test --host 900
Change-Id: Id648eaed4bbbe6fdef41d64922d023a4db0bfa54
14832efeb92334c562ebedef34e920d30e3cee69 05-Aug-2016 Narayan Kamath <narayan@google.com> Revert experimental lambda feature.

This is a revert of the following changes :

30c475a2046951a81769c2db0b2dad66cd71e189.
lambda: Minor capture-variable/liberate-variable clean-up after post-merge reviews.

6918bf13eb855b3aa8ccdddda2d27ae8c60cec56.
lambda: Experimental support for capture-variable and liberate-variable

fc1ccd740b7c8e96dfac675cfc580122cd1b40a6.
lambda: Infrastructure to support capture/liberate-variable dex opcodes

e2facc5b18cd756a8b5500fb3d90da69c9ee0fb7.
runtime: Add lambda box/unbox object equality

2ee54e249ad21c74f29a161e248bebe7d22fddf1.
runtime: Partially implement box-lambda and unbox-lambda experimental opcodes

158f35c98e2ec0d40d2c032b8cdce5fb60944a7f.
interpreter: Add experimental lambda opcodes for invoke/create-lambda

a3bb72036f5454e410467f7151dc89f725ae1151.
Added format 25x to dexdump(2).

Plus surrounding cleanups.

Test: make test-art
Change-Id: Ic6f999ad17385ef933f763641049cf721510b202
5dd44d0da7999ab62f09a1bf03345280811736d4 03-Aug-2016 Andreas Gampe <agampe@google.com> ART: Factor out native stack dumping

Move DumpNativeStack and DumpKernelStack into a new file to keep
concerns separated. Clean up the file.

In preparation for modifications to how we use addr2line.

Bug: 30351473
Test: m test-art-host
Test: manual host testing with a test that times out
Change-Id: I02d5645952fe94fd8e73bcf0522721547f6cef66
542451cc546779f5c67840e105c51205a1b0a8fd 26-Jul-2016 Andreas Gampe <agampe@google.com> ART: Convert pointer size to enum

Move away from size_t to dedicated enum (class).

Bug: 30373134
Bug: 30419309
Test: m test-art-host
Change-Id: Id453c330f1065012e7d4f9fc24ac477cc9bb9269
56fe25895e91d34a0a017429468829a20bdd5ae4 14-Jul-2016 Mathieu Chartier <mathieuc@google.com> Add a way to measure read barrier slow paths

If enabled, this option counts number of slow paths, measures the
total slow path time per GC and records the info into a histogram.
Also added support for systrace to see which threads are performing
slow paths.

Added runtime option -Xgc:measure to enable. The info is dumped
for SIGQUIT.

Test: Volantis boot with CC, test-art-host with CC, run EEAC with CC
and -Xgc:measure

Bug: 30162165

Change-Id: I3c2bdb4156065249c45695f13c77c0579bc8e57a
138dbff9246c89ac9fbe0b086b54fdab3f4451fb 28-Jun-2016 Calin Juravle <calin@google.com> Clean up profiler options

- remove obsolete options
- using ProfileSaverOptions instead of hard-coded values in the profile
saver

Bug: 24698874
Change-Id: I4ff535d29a644d1bd5509844f89615b70a723749
Test: cmdline_parser_test, gtest and run-tests pass.
be84b59e802d9176a9b60b040e0be6bda54e958a 23-Jun-2016 Calin Juravle <calin@google.com> Remove the old obsolete profiler

Bug: 24698874
Test: all the existing run-tests pass.
Change-Id: I56d25c75541275512a64ae5708569461b875df9c
37d6a3bbf5826abb73f872ed0bc4c6ae9553e274 22-Jun-2016 Aart Bik <ajcbik@google.com> Support the -i flag in the new dexdump.

Rationale:
The old dexdump supported the -i feature (ignore checksum failures).
This CL adds the same functionality to the new dexdump. Note that
this feature is, for example, useful to inspect DEX files that are
extracted from images (with quickened instructions), since the
checksum is not always valid in those cases.

BUG=29548017

Change-Id: I6017b2f3d789f450560b568297f43c62bf9453b1
b369cad4225b08ba9f30c7499200956580d97f4a 17-Jun-2016 Mathieu Chartier <mathieuc@google.com> Revert "Revert "Skip DumpForSigQuit if debugger is active""

Bug: 26118154

This reverts commit 539f7fb0964a184b24bf40c729577be76dd7749a.
592a758c9a710985a3a9a3217002c1e275858bbd 17-Jun-2016 Mathieu Chartier <mathieuc@google.com> Revert "Skip DumpForSigQuit if debugger is active"

Bug: 26118154

This reverts commit 0b8f1bfdfc721a41d98d13e12c4c67f62f698dfc.

(cherry picked from commit 6017782485d30c4e440e53107dde03dc20d56a9a)

Change-Id: I783dac75b97a424c2d770e0d69e6f346c915a754
6017782485d30c4e440e53107dde03dc20d56a9a 17-Jun-2016 Mathieu Chartier <mathieuc@google.com> Revert "Skip DumpForSigQuit if debugger is active"

Bug: 26118154

This reverts commit 0b8f1bfdfc721a41d98d13e12c4c67f62f698dfc.

Change-Id: I03c743c1385e2488be1e21ee2ce34a74e6f22546
f711f2cf3c28dfe865e36f17419a16f06a0ebb5a 23-May-2016 Mingyao Yang <mingyao@google.com> Partial fragment deoptimization

We used to do either single frame deoptimization, or full fragment
deoptimization which deoptimizes all the frames in a fragment.
This change allows some methods to be not deoptimizeable, likely due
to some kind of optimization. So we need another deoptimization mode
that unwinds partial fragment. Deoptimizations are now generalized into
either full or partial fragment. A full fragment deoptimization will
deopt all frames in the fragment, and then returns from the invoke stub
to enter interpreter. A partial fragment deoptimization will deopt a
single frame, or all frames up to the method that's not deoptimizeable,
and then jumps to the interpreter bridge.

Currently code not deoptimizeable is the code in boot image since the
code may not be compiled with debuggable flag.

Bug: 28769520
Change-Id: I875c694791cc8ebd5121abcd92ce7b0db95aca38
f0192c86a58b2f43378c9a2113007538dd38ddbf 29-Mar-2016 Jeff Hao <jeffhao@google.com> Support to pass <uses-library> option through to dex2oat.

This change takes an app's shared libraries specified by <uses-library>
and passes it through to dex2oat to be used during compilation.

Part of a multi-project change.

Bug: 26880306

(cherry-picked from commit 26e8a2f150cd7f7195a10650ab8a5b6fa5014bc8)

Change-Id: I72a352abdfc37eacd8bedfa6c218e3809ca8e39c
d361afbf6677b5af99fe2a44e92ef9d6e3ad7c17 28-Apr-2016 Mathieu Chartier <mathieuc@google.com> Revert "Revert "Write conflict tables in image""

Added test.

Bug: 27906566

This reverts commit 8e2478d23e89a7022c93ddc608dcbba7b29b91e6.

(cherry picked from commit cdca476bf3394ce9d97a369e84e701b427009318)

Change-Id: Iedb4ca9a28ae178fa7c2d486803fa27b402a85ed
946593d7c593c912684022a808fd156e17852248 27-Apr-2016 Mathieu Chartier <mathieuc@google.com> Revert "Write conflict tables in image"

Some strange issues on angler.

This reverts commit cda9386add68d94697449c6cb08b356747e55c21.

(cherry picked from commit 8e2478d23e89a7022c93ddc608dcbba7b29b91e6)

Change-Id: I475ca30e60691cd00b818aabbeb88e6ce3a2ae17
5c4b2ec16bcd779731bed1d2a0bd902dba3d5f92 14-Apr-2016 Mathieu Chartier <mathieuc@google.com> Write conflict tables in image

Add image sections for runtime methods and conflict tables. This
makes it that we do not need to fake up a length prefixed array
for runtime methods.

Reduces .art private dirty and PSS.

System wide .art PSS goes from 32.5MB to 30.5MB after system boot.

Business card .art private dirty goes from 588K to 504K.

Increases image size by ~100K.

Bug: 27906566

(cherry picked from commit cda9386add68d94697449c6cb08b356747e55c21)

Change-Id: I3ce151651bf95047b0f692c185016f693ac4f820
6cb4ccbd0dfabb9261aca911749be0603adecfe5 12-May-2016 Przemyslaw Szczepaniak <pszczepaniak@google.com> Ensure that java.lang.reflect.Field is initialized

Recent change in libcore (a move of clinit code
to register function for java.net.InetAddress
class) was triggering a failure in 119-noimage-patchoat
test. Failure was occurring when the test was running
without the image. This was caused by the
java.lang.reflect.Field not being initialized when
running InetAddress.<clinit>, which is a side effect
of calling JNIEnv->GetMethodId inside the libcore JNI_OnLoad.

This changes makes sure that this class is initialized
when we're running without image.

Bug: 28153851
Bug: 27265238
Change-Id: I8aeb5eb312a163c452c40b851112544a8340e488
(cherry picked from commit a2b147eaf72c5af23302a382620360b4cac28934)
a2b147eaf72c5af23302a382620360b4cac28934 12-May-2016 Przemyslaw Szczepaniak <pszczepaniak@google.com> Ensure that java.lang.reflect.Field is initialized

Recent change in libcore (a move of clinit code
to register function for java.net.InetAddress
class) was triggering a failure in 119-noimage-patchoat
test. Failure was occurring when the test was running
without the image. This was caused by the
java.lang.reflect.Field not being initialized when
running InetAddress.<clinit>, which is a side effect
of calling JNIEnv->GetMethodId inside the libcore JNI_OnLoad.

This changes makes sure that this class is initialized
when we're running without image.

Bug: 28153851
Change-Id: I8aeb5eb312a163c452c40b851112544a8340e488
f4b3487ee77e3c2e3d5372ae9e857cd3429bb808 13-Apr-2016 Richard Uhler <ruhler@google.com> Remove -XOatFileManagerCompilerFilter argument.

Instead use the value of '-Xcompiler-option --compiler-filter=XXX' for
the target compiler filter to use to determine if the runtime should
try to invoke dex2oat when oat files are loaded.

Bug: 27641809
Change-Id: I1856e0e37df91835b81105567c70d8a285a88f62
91288d8f03b9aab28b61a4a76e552ad7e0c15c8b 28-Apr-2016 Mathieu Chartier <mathieuc@google.com> Revert "Revert "Write conflict tables in image""

Added test.

Bug: 27906566

This reverts commit 8e2478d23e89a7022c93ddc608dcbba7b29b91e6.

(cherry picked from commit cdca476bf3394ce9d97a369e84e701b427009318)

Change-Id: Ia94fc7acc7ae3879921c4e8d0a02b156037ac286
d23d7d145c86975acbcc75505b8a323337066ac0 27-Apr-2016 Mathieu Chartier <mathieuc@google.com> Revert "Write conflict tables in image"

Some strange issues on angler.

This reverts commit cda9386add68d94697449c6cb08b356747e55c21.

(cherry picked from commit 8e2478d23e89a7022c93ddc608dcbba7b29b91e6)

Change-Id: Iffd25c5fb732ff72b58c787c107dc33c56f8c8d4
cdca476bf3394ce9d97a369e84e701b427009318 28-Apr-2016 Mathieu Chartier <mathieuc@google.com> Revert "Revert "Write conflict tables in image""

Added test.

Bug: 27906566

This reverts commit 8e2478d23e89a7022c93ddc608dcbba7b29b91e6.

Change-Id: I0894f5f7cd11af29ed9d0345b51f527fc8a41d19
af36e4996abd11e91faf0bb8bcd45696321b2c5d 27-Apr-2016 Calin Juravle <calin@google.com> Fix -Xint and -Xusejit interaction

- don't allow interpret and jit compilation at the same time
- make sure we -Xsaveprofileinfo works with -Xint.

Bug: 27916886

(cherry picked from commit 6caaa84947d5d207cde511978db327d95226e3ce)

Change-Id: Id5e7731653b322c25329b031561cfe150eb66522
ffc87076dda9878cb2cc098149bae441d38b9268 20-Apr-2016 Calin Juravle <calin@google.com> Split profile recording from jit compilation

We still use ProfileInfo objects to record profile information. That
gives us the flexibility to add the inline caches in the future and the
convenience of the already implemented GC.

If UseJIT is false and SaveProfilingInfo true, we will only record the
ProfileInfo and never launch compilation tasks.

Bug: 27916886

(cherry picked from commit e5de54cfab5f14ba0b8ff25d8d60901c7021943f)

Change-Id: I68afc181d71447895fb12346c1806e99bcab1de2
97cbc9206e9adc473a90650ebdb5d620f517ff04 15-Apr-2016 Calin Juravle <calin@google.com> Allow the framework to register sensistive threads to the runtime

Bug: 27865109
Bug: 28065407

(cherry picked from commit 8fff24953c78bd58f3a42ac83b340b90e7e7228a)

Change-Id: I82094e46a2fd12617e091d98831193f9ff56d26b
6caaa84947d5d207cde511978db327d95226e3ce 27-Apr-2016 Calin Juravle <calin@google.com> Fix -Xint and -Xusejit interaction

- don't allow interpret and jit compilation at the same time
- make sure we -Xsaveprofileinfo works with -Xint.

Bug: 27916886
Change-Id: Icab85e5b6f576f82374d5f88145cc81595afce37
8e2478d23e89a7022c93ddc608dcbba7b29b91e6 27-Apr-2016 Mathieu Chartier <mathieuc@google.com> Revert "Write conflict tables in image"

Some strange issues on angler.

This reverts commit cda9386add68d94697449c6cb08b356747e55c21.

Change-Id: Iba3a8bac6ce40ee16d83163823356951fecb6787
e42888f9df4163303244070c65d5229d3e201742 14-Apr-2016 Mathieu Chartier <mathieuc@google.com> Write conflict tables in image

Add image sections for runtime methods and conflict tables. This
makes it that we do not need to fake up a length prefixed array
for runtime methods.

Reduces .art private dirty and PSS.

System wide .art PSS goes from 32.5MB to 30.5MB after system boot.

Business card .art private dirty goes from 588K to 504K.

Increases image size by ~100K.

Bug: 27906566

(cherry picked from commit cda9386add68d94697449c6cb08b356747e55c21)

Change-Id: I38cbe3150c3eeb385b8cad7cf93614e3980f4162
5872d7cd6ceffe67550d0b021191ec66f1a34c5d 27-Apr-2016 Jeff Hao <jeffhao@google.com> Support to pass <uses-library> option through to dex2oat.

This change takes an app's shared libraries specified by <uses-library>
and passes it through to dex2oat to be used during compilation.

Part of a multi-project change.

Includes fix from a6d46161aea07ebd1cbd6ab78b2b323f940e9c1e

Bug: 26880306

(cherry-picked from commit 26e8a2f150cd7f7195a10650ab8a5b6fa5014bc8)

Change-Id: I6bfc13693dbb835ca52fed2d03ec5346d43ec5d9
cda9386add68d94697449c6cb08b356747e55c21 14-Apr-2016 Mathieu Chartier <mathieuc@google.com> Write conflict tables in image

Add image sections for runtime methods and conflict tables. This
makes it that we do not need to fake up a length prefixed array
for runtime methods.

Reduces .art private dirty and PSS.

System wide .art PSS goes from 32.5MB to 30.5MB after system boot.

Business card .art private dirty goes from 588K to 504K.

Increases image size by ~100K.

Bug: 27906566

Change-Id: I38cbe3150c3eeb385b8cad7cf93614e3980f4162
e5de54cfab5f14ba0b8ff25d8d60901c7021943f 20-Apr-2016 Calin Juravle <calin@google.com> Split profile recording from jit compilation

We still use ProfileInfo objects to record profile information. That
gives us the flexibility to add the inline caches in the future and the
convenience of the already implemented GC.

If UseJIT is false and SaveProfilingInfo true, we will only record the
ProfileInfo and never launch compilation tasks.

Bug: 27916886
Change-Id: I6e4768dc5d58f2f85f947b276b4244aa11ce3fca
bb661c0f0cb72d4bbfc2e251f6ded6949a713292 04-Apr-2016 Bilyan Borisov <bilyan.borisov@linaro.org> Refactor use of __ANDROID__ macro

We use the __ANDROID__ macro, which is provided by the toolchain, in
numerous places. This patch refactors the usage of this by defining a
new macro, ART_TARGET_ANDROID, that is being passed during build to
ART_TARGET_CFLAGS in Android.common_build.mk on the same line as
ART_TARGET. The codebase currently assumes that the existence of the
__ANDROID__ macro implies that we are compiling art for an android
target device. This is because, currently, target builds are compiled
with target toolchains that provide the macro, while host toolchains
do not. With this change this assumption is still preserved. However,
in a future patch we will add the ability to compile art for a linux
target, and in that case the ART_TARGET_ANDROID macro won't be passed
anymore.

Change-Id: I1f3a811aa735c87087d812da27fc6b08f01bad51
26e8a2f150cd7f7195a10650ab8a5b6fa5014bc8 29-Mar-2016 Jeff Hao <jeffhao@google.com> Support to pass <uses-library> option through to dex2oat.

This change takes an app's shared libraries specified by <uses-library>
and passes it through to dex2oat to be used during compilation.

Part of a multi-project change.

Bug: 26880306

Change-Id: Ib70a48ff700a5db9a5b4aaf731552556878ad8f7
8fff24953c78bd58f3a42ac83b340b90e7e7228a 15-Apr-2016 Calin Juravle <calin@google.com> Allow the framework to register sensistive threads to the runtime

Bug: 27865109
Bug: 28065407
Change-Id: Ieac3215879c40b16eb21b47a457fd0345d45177a
bb11c8b1219f5b4b3154c2c83fca19ec8add6646 12-Apr-2016 Nicolas Geoffray <ngeoffray@google.com> Remove the JIT from the instrumentation framework.

This was slowing down the interpreter for no reason.
Also, call AddSamples for invoke-static and invoke-direct.

bug:27865109

(cherry picked from commit 274fe4adcb0610a9920be7814d9beb9cac6417ce)

Change-Id: I3519456ac8e0c7211cbe3f12e88d134beee87479
274fe4adcb0610a9920be7814d9beb9cac6417ce 12-Apr-2016 Nicolas Geoffray <ngeoffray@google.com> Remove the JIT from the instrumentation framework.

This was slowing down the interpreter for no reason.
Also, call AddSamples for invoke-static and invoke-direct.

Change-Id: I7b5641097f7741dd32feb1ce6af739fd27fb37c2
b2771b41a956b50266d4d83fbb067f99faf7b7dc 07-Apr-2016 Calin Juravle <calin@google.com> Add option to tune sample collection based on thread sensitivity

Bug: 28065407
Bug: 27865109

Change-Id: Icdb89f8f8874a41c07e73185523d18e8956620d3
f38a6618b453b76a3370bbf6b351971687099388 11-Apr-2016 Andreas Gampe <agampe@google.com> ART: Flag to fail thread creation

Add a flag to mark when the zygote is not allowed to create threads.

Bug: 27248115
Bug: 28149511

(cherry picked from commit 415d8070e37c20dfb7e6dc37e74fdb5fffc2022e)

Change-Id: I1dc3620d9e7d0054c672b993d89459fc4b353dfc
415d8070e37c20dfb7e6dc37e74fdb5fffc2022e 11-Apr-2016 Andreas Gampe <agampe@google.com> ART: Flag to fail thread creation

Add a flag to mark when the zygote is not allowed to create threads.

Bug: 27248115
Bug: 28149511
Change-Id: I1dc3620d9e7d0054c672b993d89459fc4b353dfc
08305325d3468d5ef413eb0b36b1ea1b3746a6c4 05-Apr-2016 Jeff Hao <jeffhao@google.com> Remove AnnotationAccess and its remaining uses.

Art side of this change. Adds a test to ensure annotations not marked
for runtime retention can't be seen at runtime.

Bug: 27912552

(cherry picked from commit 1133db79350060158f99210c56f111c6dad43563)

Change-Id: I090a90bc82fc9b5e51aba02dcb3d8cccb6fb0f90
1133db79350060158f99210c56f111c6dad43563 05-Apr-2016 Jeff Hao <jeffhao@google.com> Remove AnnotationAccess and its remaining uses.

Art side of this change. Adds a test to ensure annotations not marked
for runtime retention can't be seen at runtime.

Bug: 27912552
Change-Id: I078069b7b3cb72bfe7d0b9ea61e527fee04d56a3
cac5a7e871f1f346b317894359ad06fa7bd67fba 22-Feb-2016 Vladimir Marko <vmarko@google.com> Optimizing: Improve const-string code generation.

For strings in the boot image, use either direct pointers
or pc-relative addresses. For other strings, use PC-relative
access to the dex cache arrays for AOT and direct address of
the string's dex cache slot for JIT.

For aosp_flounder-userdebug:
- 32-bit boot.oat: -692KiB (-0.9%)
- 64-bit boot.oat: -948KiB (-1.1%)
- 32-bit dalvik cache total: -900KiB (-0.9%)
- 64-bit dalvik cache total: -3672KiB (-1.5%)
(contains more files than the 32-bit dalvik cache)
For aosp_flounder-userdebug forced to compile PIC:
- 32-bit boot.oat: -380KiB (-0.5%)
- 64-bit boot.oat: -928KiB (-1.0%)
- 32-bit dalvik cache total: -468KiB (-0.4%)
- 64-bit dalvik cache total: -1928KiB (-0.8%)
(contains more files than the 32-bit dalvik cache)

Bug: 26884697
Change-Id: Iec7266ce67e6fedc107be78fab2e742a8dab2696
e9300271556e47639cade1ec5fdf8f66b3724d03 23-Mar-2016 Nicolas Geoffray <ngeoffray@google.com> Fix dex2oat/oatdump cross-compilation.

Only set the ImtConflictTable when not in AOT, to not mess up
with the image.

(cherry picked from commit 40c68c690546e8c15dcb2de6137e72c74f573a75)

Change-Id: I7bff3a18cc06184ed9d7d63ab433f286884f19e7
c1bc4150415686e6240343c7345c49d80e351df3 25-Mar-2016 Mathieu Chartier <mathieuc@google.com> Only call jit_load after the zygote fork

Otherwise we always get that enable_debug_features is false since
that flag passed as a compiler option post zygote fork.

No significant change to libart-compiler PSS on calculator.

Bug: 27810774

(cherry picked from commit b10cef442594dd0d6c5f1a5784643931a25cc431)

Change-Id: Ie50668ba05ad07a5cf046497959f6d27e09f8fe2
b10cef442594dd0d6c5f1a5784643931a25cc431 25-Mar-2016 Mathieu Chartier <mathieuc@google.com> Only call jit_load after the zygote fork

Otherwise we always get that enable_debug_features is false since
that flag passed as a compiler option post zygote fork.

No significant change to libart-compiler PSS on calculator.

Bug: 27810774
Change-Id: I9854716902c79e16bdfd64754cc1ed05e852a5de
72918ea854d182ef25b2352bfe1c46c1e916a141 24-Mar-2016 Mathieu Chartier <mathieuc@google.com> Load jit compiler pre zygote fork

Reduces PSS for libart-compiler.so from 115KB to 2KB per app.

Also some clean-up.

Bug: 27810774

(cherry picked from commit ff2376770c1c6d301778c41e5c27c808a38e6968)

Change-Id: Ic0077a07c21ed9f1952a6c29863a5c0e5bacc01a
ff2376770c1c6d301778c41e5c27c808a38e6968 24-Mar-2016 Mathieu Chartier <mathieuc@google.com> Load jit compiler pre zygote fork

Reduces PSS for libart-compiler.so from 115KB to 2KB per app.

Also some clean-up.

Bug: 27810774

Change-Id: I9938b022e90c58e7978c5038338d0bcbe2a1dc2b
7bcfcb80a31f57a84d754e00bca8698829365208 23-Mar-2016 Andreas Gampe <agampe@google.com> Revert "Revert "Use compiler filter to determine oat file status.""

This reverts commit 845e5064580bd37ad5014f7aa0d078be7265464d.

Add an option to change what OatFileManager considers up-to-date.
In our tests we're allowed to write to the dalvik-cache, so it
cannot be kSpeed.

(cherry picked from commit 29d38e77c553c6cf71fc4dafe2d22b4e3f814872)

Bug: 27689078
Change-Id: I6274188610f31dcd9d086fc080b2be93afae5a6b
29d38e77c553c6cf71fc4dafe2d22b4e3f814872 23-Mar-2016 Andreas Gampe <agampe@google.com> Revert "Revert "Use compiler filter to determine oat file status.""

This reverts commit 845e5064580bd37ad5014f7aa0d078be7265464d.

Add an option to change what OatFileManager considers up-to-date.
In our tests we're allowed to write to the dalvik-cache, so it
cannot be kSpeed.

Bug: 27689078
Change-Id: I0c578705a9921114ed1fb00d360cc7448addc93a
40c68c690546e8c15dcb2de6137e72c74f573a75 23-Mar-2016 Nicolas Geoffray <ngeoffray@google.com> Fix dex2oat/oatdump cross-compilation.

Only set the ImtConflictTable when not in AOT, to not mess up
with the image.

Change-Id: I8f2926ad30dc913d61b0c8957affc25fc8056ada
796d63050a18f263b93ea34951a61deaecab3422 13-Mar-2016 Nicolas Geoffray <ngeoffray@google.com> Add an ImtConflictTable to better resolve IMT conflicts.

- Attach a ImtConflictTable to conflict runtime ArtMethod.
- Initially 0, a new one will be created at the first hit of
the conflict method.
- If the assembly code does not find a target method in the table,
we will create a new one again, copying the data from the previous
table and adding the new mapping.

Implemented for arm/arm64/x86/x64.

bug:27556801
bug:24769046

Change-Id: Ie74d1c77cf73d451a1142bdc5e3683f9f84bb4e7
c6b1b93f47f5694025b35e8417112b303091dc7c 22-Mar-2016 Nicolas Geoffray <ngeoffray@google.com> Revert "Revert "Enable compilation of secondary dex files""

Bug: 26719109

This reverts commit d98a52f0bc6c58e8e538de8335ab9bcb6ae73aa7.

Change-Id: I523675eb6d647fe773dd57b6e1cc398927bb066e
f8cb1781a4e4be5df1f845206f7b37ed89092b64 19-Mar-2016 Mathieu Chartier <mathieuc@google.com> Move process state into runtime

Clean up.

Bug: 27420435

(cherry picked from commit f8484c8b55f4b423048f94dfabbe44110a039a9b)

Change-Id: Ia20781ee36e6a31c88ca41d3866b26813cff434d
f8484c8b55f4b423048f94dfabbe44110a039a9b 19-Mar-2016 Mathieu Chartier <mathieuc@google.com> Move process state into runtime

Clean up.

Bug: 27420435

Change-Id: I8fff84ed1b29a12310094b10fb6382268e69d54b
04680f3d7b021a0afb460266d442f564186a3b6f 17-Mar-2016 Nicolas Geoffray <ngeoffray@google.com> Dump oat file information as part of DumpForSigQuit.

Change-Id: Ie8d256d8fa16565105cfe5c39cc96826983469da
f448016e70fa91269d3750384aab1ac98d7896fd 16-Mar-2016 David Srbecky <dsrbecky@google.com> Do not JIT boot image during native-debugging (keep AOT code instead).

The performance impact is currently significant and being able
to debug framework is not our primary goal for native debugging.

Change-Id: I3366c2a6317004f9dd16700b271a6c9b974f1c6e
0cb11c3dc6c3e7c3521b49ab0be9138c60037eba 16-Mar-2016 Narayan Kamath <narayan@google.com> runtime: delete native/java_lang_Runtime.h.

Now unused, except for an unnecessary include.

bug: 27387202
Change-Id: Ie77dc0da156a64e8ea03af1878b44d20c16c5ae5
f525272b1edec721058e7d888545dd5d97b5045d 15-Mar-2016 Narayan Kamath <narayan@google.com> runtime: delete native/java_lang_Runtime.cc

We're now using Runtime.c from ojluni, which does the same set
of things via the JVM interface. This removes unnecessary duplication
of code between Runtime.cc and OpenJdkJvm.cc.

Also includes a few changes to JVM_NativeLoad to bring it in sync
with the version in Runtime.cc.

bug: 27387202

(cherry picked from commit 5f97157263d1b52bf4aea523b28294b21d694da1)

Change-Id: Ic2848755505a0cb25da8237150b07dadf0a42929
5f97157263d1b52bf4aea523b28294b21d694da1 15-Mar-2016 Narayan Kamath <narayan@google.com> runtime: delete native/java_lang_Runtime.cc

We're now using Runtime.c from ojluni, which does the same set
of things via the JVM interface. This removes unnecessary duplication
of code between Runtime.cc and OpenJdkJvm.cc.

Also includes a few changes to JVM_NativeLoad to bring it in sync
with the version in Runtime.cc.

bug: 27387202
Change-Id: I92aac81d131661aca588e352aee7a167593e17d4
a1425a1c9c98ae3fc772834933a5d55566fb5699 12-Mar-2016 Andreas Gampe <agampe@google.com> ART: Remember whether the cache was pruned

Remember (and expose) whether the cache was pruned when initializing
the runtime.

Bug: 27618311

(cherry picked from commit 7ef1b4b20bd7cf485f5e443927c1e6fa797a0439)

Change-Id: I178d18d731a9dce5cb11ed0874c9c9c9d36d7d8e
0b4cbd0c2a75b47ae09d21e5d73d2b1709cb5b9e 09-Mar-2016 Mathieu Chartier <mathieuc@google.com> Add oatdump support for app images

Example usage on host:
oatdumpd --app-oat=art/plus32.odex --app-image=art/plus32.art
--image=art/oats/system@framework@boot.art --instruction-set=arm

TODO: Add to oatdump test.

Bug: 27408512
Bug: 22858531

(cherry picked from commit bcb6a72569a1401b36a3ad3b6aa4d13e29966cf0)

Change-Id: I9d1aa7eaa16795e5fbabc6974d245849e16b1d03
bcb6a72569a1401b36a3ad3b6aa4d13e29966cf0 09-Mar-2016 Mathieu Chartier <mathieuc@google.com> Add oatdump support for app images

Example usage on host:
oatdumpd --app-oat=art/plus32.odex --app-image=art/plus32.art
--image=art/oats/system@framework@boot.art --instruction-set=arm

TODO: Add to oatdump test.

Bug: 27408512
Bug: 22858531

Change-Id: I320db8b76c780c6eadabcb45ce88f45950741484
7ef1b4b20bd7cf485f5e443927c1e6fa797a0439 12-Mar-2016 Andreas Gampe <agampe@google.com> ART: Remember whether the cache was pruned

Remember (and expose) whether the cache was pruned when initializing
the runtime.

Bug: 27618311
Change-Id: I178d18d731a9dce5cb11ed0874c9c9c9d36d7d8e
d98a52f0bc6c58e8e538de8335ab9bcb6ae73aa7 14-Mar-2016 Nicolas Geoffray <ngeoffray@google.com> Revert "Enable compilation of secondary dex files"

Reverting until we fix the buildbot failures on jdwp and libcore.

Bug: 26719109

This reverts commit 770b39eb564ec16c672ace83515535b055edb2b1.

Change-Id: Ifba366d2ddc9311737b6ea29c007475a40cc803f
770b39eb564ec16c672ace83515535b055edb2b1 09-Mar-2016 Calin Juravle <calin@google.com> Enable compilation of secondary dex files

DexClassLoader should be allowed to compile the secondary dex files if
needed. Adding interpret-only flag when using JIT prevented that.

Note that primary apks are loaded with a PathClassLoader and which
should not attempt to compile the dex files.

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

Added to:
JIT
DexFile functions
Oat file manager

Added helper ScopedTrace to prevent errors and reduce excess code.

Bug: 27502458

(cherry picked from commit dabdc0fe183d4684f3cf4d70cb09d318cff81b42)

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

Added to:
JIT
DexFile functions
Oat file manager

Added helper ScopedTrace to prevent errors and reduce excess code.

Bug: 27502458

Change-Id: Ifaeff8913d79eefc797380987d13cc00456266f8
c90bc92bc577020ff4d3caced4cee1cdf41fa5de 24-Feb-2016 Calin Juravle <calin@google.com> Record foreign dex files loaded by the app in the profile

A foreign dex file is a file which is not owned by the app
(it's not part of its code paths or its private data directory).

When such a dex file is loaded by the app, the runtime will record
a marker in a dedicated profile folder (foreing_dex_profile_path).
The marker is just a file named after the canonical location of the
dex file where '/' is replaced by '@'.

The markers will be used by the system server system server to
decide if the apk should be fully or profile guide compiled.

Bug: 27334750
Bug: 26080105

(cherry picked from commit 86a9ebe4197e963249ffbbaa1830da97ed642fa5)

Change-Id: I8be1fd4d854fa1e23c3c1054c9c083ad7b27317b
86a9ebe4197e963249ffbbaa1830da97ed642fa5 24-Feb-2016 Calin Juravle <calin@google.com> Record foreign dex files loaded by the app in the profile

A foreign dex file is a file which is not owned by the app
(it's not part of its code paths or its private data directory).

When such a dex file is loaded by the app, the runtime will record
a marker in a dedicated profile folder (foreing_dex_profile_path).
The marker is just a file named after the canonical location of the
dex file where '/' is replaced by '@'.

The markers will be used by the system server system server to
decide if the apk should be fully or profile guide compiled.

Bug: 27334750
Bug: 26080105
Change-Id: If4fa8208be4e2f6f0b748b8a5417c4ae9c2d5df6
25e0456b6ea13eba290b63ea88b6b7120ed89413 01-Mar-2016 Nicolas Geoffray <ngeoffray@google.com> Give the JIT its own arena pool to avoid lock contentions.

Sharing it with the verifier and the class loader is not ideal,
especially at startup time.

bug:27398183
bug:23128949
Change-Id: I1b91663a13f6c5b33ad3b4be780d93eb7fe445b4
942dc298d7af3e60fe40c69b4b416ef144e5c723 24-Feb-2016 Dimitry Ivanov <dimitry@google.com> Simplify LoadNativeLibrary()

With ApplicationLoaders.getClassLoader() ensuring
linker-namespace initialization there is no longer
need for LoadNativeLibrary() and callers to pass
along namespace-specific information to art.

This change removes unnecessary parameters of such
calls.

Bug: http://b/27189432
Bug: http://b/22548808
Change-Id: I341d35a2d5195e634678b352f4361f8712984b69
(cherry picked from commit c286a7fcd8a446c086127bf03fd07f904e017336)
e8725e4ab2134f9fd80290cb039a6827a14c381d 26-Feb-2016 Nicolas Geoffray <ngeoffray@google.com> Revert "Preload public libraries on Runtime::Start()"

Loading is done in app_process.

Bug: http://b/27245894

This reverts commit 7bca74e53d3665bcd243d4e0277f6561c0c80271.

Change-Id: Ie2edbe88dea867fcd5cca109d279f1c19e4df6bb
c66577ece35b73250f2078d8d59ac661a95a63d0 25-Feb-2016 Nicolas Geoffray <ngeoffray@google.com> Revert "Preload public libraries on Runtime::Start()"

Breaks anyone not working on up-to-date devices/trees. I'll work on a revert of the revert.

Bug: http://b/27245894

This reverts commit ea9fc5bd31781fb380ace74ccddf2137c7dcc5d9.

Change-Id: Ie8fc286a64de4db2c905502a528005022803ed94
ea9fc5bd31781fb380ace74ccddf2137c7dcc5d9 22-Feb-2016 Dimitry Ivanov <dimitry@google.com> Preload public libraries on Runtime::Start()

Preloading public libraries on Runtime::Start()
instead of doing it in native_loader c-tor
ensures that the libraries are loaded only for
binaries that are using Android Runtime, and not
just linking against libandroid_runtime or libart.

Loading public libraries on Runtime::Start()
also helps some apps to save startup time and space
by ensuring that all NDK libraries are loaded
and ready to use.

Bug: http://b/27245894
Change-Id: I15679a72450f3d18a7dd503d0ae977cebcfd7f52
(cherry picked from commit 7bca74e53d3665bcd243d4e0277f6561c0c80271)
7bca74e53d3665bcd243d4e0277f6561c0c80271 22-Feb-2016 Dimitry Ivanov <dimitry@google.com> Preload public libraries on Runtime::Start()

Preloading public libraries on Runtime::Start()
instead of doing it in native_loader c-tor
ensures that the libraries are loaded only for
binaries that are using Android Runtime, and not
just linking against libandroid_runtime or libart.

Loading public libraries on Runtime::Start()
also helps some apps to save startup time and space
by ensuring that all NDK libraries are loaded
and ready to use.

Bug: http://b/27245894
Change-Id: I15679a72450f3d18a7dd503d0ae977cebcfd7f52
c286a7fcd8a446c086127bf03fd07f904e017336 24-Feb-2016 Dimitry Ivanov <dimitry@google.com> Simplify LoadNativeLibrary()

With ApplicationLoaders.getClassLoader() ensuring
linker-namespace initialization there is no longer
need for LoadNativeLibrary() and callers to pass
along namespace-specific information to art.

This change removes unnecessary parameters of such
calls.

Bug: http://b/27189432
Bug: http://b/22548808
Change-Id: I341d35a2d5195e634678b352f4361f8712984b69
ca76a1a0c1737b3e04961ba382c113102fdc00bf 02-Feb-2016 Jean-Philippe Halimi <jean-philippe.halimi@intel.com> Dex-wide ArenaPool scoping for AOT compilation

The Arena Pool is a structure that holds memory allocated by the Arena
Allocator, preventing system allocations and deallocations to occur too often
during AOT compilation. Currently, the Arena Pool holds memory it allocates
during the whole AOT compilation process. Unfortunately, such a behavior
generates memory usage overhead, which is exacerbated by bigger applications
such as Facebook.

In this particular app, method size imbalance provokes unnecessary memory
pressure, as one method might require a lot of arena allocations that won't be
used in the remaining compilation. Because the compiler memory footprint keeps
increasing during AOT compilation, the memory pressure becomes very high.

The proposed patch is an attempt to find a tradeoff between allocations /
deallocations time overhead, and the aforementioned memory pressure overhead
resulting of the allocations being held by the Arena Pool. The patch adds a
feature freeing up all memory allocated in the Arena Pool after each dex file
is done compiling.

We have measured no significant AOT compile-time overhead with the patch
(<0.3%), because the selected dex-file granularity is coarse enough. In the
meantime, it provides significant memory footprint improvements. The impact is
especially big with Facebook, because this app has a few methods generating
huge memory footprint peaks (peak native heap footprint goes down 34%).

Change-Id: I27e867e6a20b8a6c28a82cb83140941a8c2b5847
Signed-off-by: Jean-Philippe Halimi <jean-philippe.halimi@intel.com>
5b82d339955d1a0dc23eeb8d2d5659459ff987ba 18-Feb-2016 Nicolas Geoffray <ngeoffray@google.com> The JIT does not need VerifedMethod nor CompilerCallbacks.

bug:27173201

Change-Id: I971659f9ff6a8b780c94a7bed84de90fa9fc3456
a73280df8cac1279b6dea0424722f42ef0048613 15-Feb-2016 Nicolas Geoffray <ngeoffray@google.com> Add an option to disable native stack dumping on SIGQUIT.

Some of our (stress) run-tests do ANR dumping, which end up
stressing libunwind, that has known problems. To avoid getting
flakes due to libunwind, disable native stack dumping on SIGQUIT
for our run-tests.

bug:27185632
bug:24664297
Change-Id: I69085e48db903d6240448d71666ae2dcd091922e
6eb6a39bdcf669655190d40d20f8d2e663b262f4 11-Feb-2016 Andreas Gampe <agampe@google.com> ART: Simplify patchoat

Removed unused configurations. Cut out cruft that isn't used anymore
since multi-image. Make it smaller to not require new selinux
permissions for OTAs.

Split up the main function, to make the flow clearer for image vs
app/oat.

Bug: 25612095
Bug: 26317072

(cherry picked from commit 02bc0b70beedfe258c2147c2b4a205fbf3d6eebc)

Change-Id: Ieb55bd1a13cbb44fd0e2979a8a61a509df9c1e7e
02bc0b70beedfe258c2147c2b4a205fbf3d6eebc 11-Feb-2016 Andreas Gampe <agampe@google.com> ART: Simplify patchoat

Removed unused configurations. Cut out cruft that isn't used anymore
since multi-image. Make it smaller to not require new selinux
permissions for OTAs.

Split up the main function, to make the flow clearer for image vs
app/oat.

Bug: 25612095
Bug: 26317072
Change-Id: Ieb55bd1a13cbb44fd0e2979a8a61a509df9c1e7e
b331febbab8e916680faba722cc84b66b84218a3 05-Feb-2016 Nicolas Geoffray <ngeoffray@google.com> Revert "Revert "Implement on-stack replacement for arm/arm64/x86/x86_64.""

This reverts commit bd89a5c556324062b7d841843b039392e84cfaf4.

Change-Id: I08d190431520baa7fcec8fbdb444519f25ac8d44
bd89a5c556324062b7d841843b039392e84cfaf4 05-Feb-2016 David Brazdil <dbrazdil@google.com> Revert "Implement on-stack replacement for arm/arm64/x86/x86_64."

DCHECK whether loop headers are covered fails.

This reverts commit 891bc286963892ed96134ca1adb7822737af9710.

Change-Id: I0f9a90630b014b16d20ba1dfba31ce63e6648021
891bc286963892ed96134ca1adb7822737af9710 29-Jan-2016 Nicolas Geoffray <ngeoffray@google.com> Implement on-stack replacement for arm/arm64/x86/x86_64.

High-level overview:
- osr_method_threshold is used to know when to compile a method
in osr mode (-> treat all loops as irreducible).
- branch instructions in the compiler query whether they can
jump to an osr method.
- An osr entry point is found through the stack maps: if a stack
map is duplicated in the CodeInfo, it is an osr entry point.

Change-Id: Ifb39338cd281e2c7eccce67f4e18d46428be71e4
d3e7c6c76f564b58e66010c30b62bb56ef046f2c 04-Feb-2016 Calin Juravle <calin@google.com> Don't use native bridge for non zygote-spawn processes

... unless we force it for testing purposes.

Bug: 26954924
Change-Id: Ib4660a35175abb479d0399e18b6194eb04dbc248
df707e406877e9c0426dd051c00933ebb331673e 03-Feb-2016 Igor Murashkin <iam@google.com> runtime: Don't skip verification for -Xverify:soft-fail

When forcing the interpreter into access checks mode,
make sure that the regular verification is still run,
giving the verifier an opportunity to throw a VerifyError.

If verification would've succeeded (without -Xverify:soft-fail flag),
override this and soft-fail, to force the interpreter-with-access-checks to be run
instead of the normal faster interpreter.

This fixes the following run-tests under the interpeter-access-checks:
* 135
* 412
* 471
* 506
* 800

Bug: 22414682
Change-Id: I5cb86a8bba71c7af9361a63c0802786c852b857b
4a26f17b055cadc949c3e9fdfa637fe5656339d9 26-Jan-2016 Mathieu Chartier <mathieuc@google.com> Remove GetImageRoots read barrier for image relocation

Fixes CC assertion that failed if an app image was loaded when the GC
was running.

Bug: 26786304
Change-Id: I47bea7b4b947332b57be2e2db604c2c25d92b7e2
fbc31087932a65e036a153afab3049dc5298656a 24-Jan-2016 Mathieu Chartier <mathieuc@google.com> Revert "Revert "Load app images""

This reverts commit 1bc977cf2f8199311a97f2ba9431a184540e3e9c.

Bug: 22858531

Change-Id: Ide00bf3a73a02cba3bb364177204ad1b13f70295
1bc977cf2f8199311a97f2ba9431a184540e3e9c 23-Jan-2016 Nicolas Geoffray <ngeoffray@google.com> Revert "Load app images"

Fails when a method is duplicated (see test 097-duplicate-method)

Bug: 22858531

This reverts commit f7fd970244f143b1abb956e29794c446e4d57f46.

Change-Id: Ib30ae5be00cc568e799290be6b3c8f29cbbe4c20
f7fd970244f143b1abb956e29794c446e4d57f46 09-Nov-2015 Mathieu Chartier <mathieuc@google.com> Load app images

Support in-place patching of the app image based on boot image
location and app oat location. Only loads for art run test so far
since we do not automatically generate app images for app installs.

N5 maps launch time (~200 runs):
Before: 930ms
After: 878.18ms
After + image class table: 864.57ms

TODO:
Oatdump support.
Store class loaders as class roots in image.

Bug: 22858531

Change-Id: I9cbc645645e62ea2ed1ad8e139e91af7d88514c1
9bdf108885a27ba05fae8501725649574d7c491b 21-Jan-2016 Vladimir Marko <vmarko@google.com> Revert "Revert "Write dex files to oat file early.""

This reverts commit 919f5536182890d2e03f59b961acf8f7c836ff61.

Fix linker error (Mac build):
Replace inline definition of art::ZipArchive::~ZipArchive()
with an out-of-line definition in zip_archive.cc to avoid
direct reference to CloseArchive() from libart-compiler due
to inlining. Note that libart is linked against -lziparchive
but libart-compiler is not.

Change-Id: I92620ea0200282ca7ba9b7f61a592cb6468d90d8
919f5536182890d2e03f59b961acf8f7c836ff61 20-Jan-2016 Vladimir Marko <vmarko@google.com> Revert "Write dex files to oat file early."

This reverts commit 625a64aad13905d8a2454bf3cc0e874487b110d5.

Breaks the Mac build:

Undefined symbols for architecture i386:
"_CloseArchive", referenced from:
... in oat_writer.o
ld: symbol(s) not found for architecture i386

Change-Id: I21608bc51437834e1e6abde9bcbe5e7d9998197e
fffbee4d158259633ec7b7f712eaf75be86bd4e5 15-Jan-2016 Tamas Berghammer <tberghammer@google.com> Report types loaded during init to the native debugger

The runtime loads a lot of type before it creates the jit from the
boot image and from hard coded source code (e.g. primitive arrays).
This change emits type information for these types after the jit has
been created. At the same time we remove the type info generation
that happens during AOT compilation because that type information can
be modified by a class loader at runtime.

Change-Id: Ie5b3b3df9d01c7200a1f670a98d9cbee796234e9
625a64aad13905d8a2454bf3cc0e874487b110d5 26-Nov-2015 Vladimir Marko <vmarko@google.com> Write dex files to oat file early.

Write dex files to oat file before we actually open and
verify them. Instead, open and verify the copies from the
oat file and use these. This way, in the most common case
of zipped dex files, we have mmapped dex files instead of
inflated dex files. That reduces the number of dirty pages
used by dex2oat.

Reading /proc/self/statm after we write the oat file for
a compilation of a certain large app on Nexus 5 AOSP build
with -j1, three attempts before and after this CL gave
before: 346061 189462 6269 26 0 140723 0
346189 189450 6269 26 0 140851 0
346061 189463 6269 26 0 140723 0
after: 346186 185808 23040 27 0 140468 0
346186 185819 23040 27 0 140468 0
346186 185822 23040 27 0 140468 0
These values are in pages (4KiB), so while the "size"
(=VmSize) is essentially unchanged, the "resident" (=VmRSS)
is over 14MiB less and the "shared" (i.e. backed by a file)
is 65.5MiB more. That is, the amount of dirty non-pageable
memory used is reduced by about 80MiB.

The oat file format has changed slightly, the class offset
table has been moved from the OatDexFile to its own section.
This actually fixes the alignment of these offsets as they
could have been unaligned previously, yet accessed as normal
with significant performance impact if the kernel has to
emulate the unaligned access (say, mips).

Change-Id: I0f4799bb1f1ca28e3533156a3494f55345c3e10a
1452bee8f06b9f76a333ddf4760e4beaa82f8099 06-Mar-2015 buzbee <buzbee@google.com> Fast Art interpreter

Add a Dalvik-style fast interpreter to Art.
Three primary deficiencies in the existing Art interpreter
will be addressed:

1. Structural inefficiencies (primarily the bloated
fetch/decode/execute overhead of the C++ interpreter
implementation).
2. Stack memory wastage. Each managed-language invoke
adds a full copy of the interpreter's compiler-generated
locals on the shared stack. We're at the mercy of
the compiler now in how much memory is wasted here. An
assembly based interpreter can manage memory usage more
effectively.
3. Shadow frame model, which not only spends twice the memory
to store the Dalvik virtual registers, but causes vreg stores
to happen twice.

This CL mostly deals with #1 (but does provide some stack memory
savings). Subsequent CLs will address the other issues.

Current status:
Passes all run-tests.
Phone boots interpret-only.
2.5x faster than Clang-compiled Art goto interpreter on fetch/decode/execute
microbenchmark, 5x faster than gcc-compiled goto interpreter.
1.6x faster than Clang goto on Caffeinemark overall
2.0x faster than Clang switch on Caffeinemark overall
68% of Dalvik interpreter performance on Caffeinemark (still much slower,
primarily because of poor invoke performance and lack of execute-inline)
Still nearly an order of magnitude slower than Dalvik on invokes
(but slightly better than Art Clang goto interpreter.
Importantly, saves ~200 bytes of stack memory per invoke (but still
wastes ~400 relative to Dalvik).

What's needed:
Remove the (large quantity of) bring-up hackery in place.
Integrate into the build mechanism. I'm still using the old Dalvik manual
build step to generate assembly code from the stub files.
Remove the suspend check hack. For bring-up purposes, I'm using an explicit
suspend check (like the other Art interpreters). However, we should be
doing a Dalvik style suspend check via the table base switch mechanism.
This should be done during the alternative interpreter activation.
General cleanup.
Add CFI info.
Update the new target bring-up README documentation.
Add other targets.

In later CLs:
Consolidate mterp handlers for expensive operations (such as new-instance) with
the code used by the switch interpreter. No need to duplicate the code for
heavyweight operations (but will need some refactoring to align).
Tuning - some fast paths needs to be moved down to the assembly handlers,
rather than being dealt with in the out-of-line code.
JIT profiling. Currently, the fast interpreter is used only in the fast
case - no instrumentation, no transactions and no access checks. We
will want to implement fast + JIT-profiling as the alternate fast
interpreter. All other cases can still fall back to the reference
interpreter.
Improve invoke performance. We're nearly an order of magnitude slower than
Dalvik here. Some of that is unavoidable, but I suspect we can do
better.
Add support for our other targets.

Change-Id: I43e25dc3d786fb87245705ac74a87274ad34fedc
10edbb159afae232817c86fc06a6801349f05bae 07-Jan-2016 Andreas Gampe <agampe@google.com> ART: Use libopenjdkd

Load libopenjdkd in debug mode. Add dependencies for libopenjdkd
in the Makefiles.

Bug: 26421792
Change-Id: Ie64cd56f73901b9c7645e46384d753752bbd5351
fb6db4c841e928feb35a985923fe2d41848f8f31 07-Jan-2016 Mathieu Chartier <mathieuc@google.com> Add systrace output to runtime shutdown

Help debug why am command shutdown is slow.

Findings:
~200ms spent in deleting thread list on N5.

Bug: 26351700
Change-Id: Icb59390a5267ae8bade4ced12252743c48206bb1
205b7624e434050125ada92a318cdc2655ac7b4a 07-Jan-2016 Mathieu Chartier <mathieuc@google.com> Address some intern table comments

Change-Id: I7ffaa463272015c2924ba03e006041daee498ad4
ea0831f60d26e3297e6463634a9fbb6384f00661 29-Dec-2015 Mathieu Chartier <mathieuc@google.com> Re-enable adding intern table to image

Changed intern table to have a stack of tables similarily to
ClassTable. Adding an image intern table adds to the front of the
intern table stack. Also some cleanup.

Bug: 26317072

Change-Id: I7bbf9485b5dbbbf3707fed21e29de3beccfb8705
1c1a342ba4e029ea1868a41ed0310756b7d78f45 05-Jan-2016 Jeff Hao <jeffhao@google.com> Fix multi-image TODOs in class linker, runtime, and oat file.

- Modified SanityCheckArtMethodPointerArray in class linker
- Put back warnings in OatFile::GetOatDexFile
- Reinstated ImageSpace VerifyImageAllocations in Runtime::Init

Bug: 26317072

(cherry-picked from commit 0dfef949bb824accde27f8cfe1b233ec9e087355)

Change-Id: I3bdb8f87d885213795c82c41e5095fec6daf00c4
0dfef949bb824accde27f8cfe1b233ec9e087355 05-Jan-2016 Jeff Hao <jeffhao@google.com> Fix multi-image TODOs in class linker, runtime, and oat file.

- Modified SanityCheckArtMethodPointerArray in class linker
- Put back warnings in OatFile::GetOatDexFile
- Reinstated ImageSpace VerifyImageAllocations in Runtime::Init

Change-Id: I3bdb8f87d885213795c82c41e5095fec6daf00c4
5e2b971e468ca73a8e10a120730b3b6f17fad408 18-Dec-2015 Calin Juravle <calin@google.com> Assume the profile file was created before saving.

bug: 26080105
Change-Id: I9969a4abd8533614922076551fcbae2cdf695525
8994a04162a92759f8ec531d18ee8901145dfda0 30-Dec-2015 Andreas Gampe <agampe@google.com> Revert "Revert "ART: Fix up some multi-image cases""

This reverts commit de38b797c3e5ba3ee44c480db7093386975c51eb.

Fix up imgdiag for std::string and multi-image.

Bug: 26317072
Bug: 26320300

Change-Id: I94ce9528e9fea6fb3231a70c32db02d567143db9
de38b797c3e5ba3ee44c480db7093386975c51eb 30-Dec-2015 Nicolas Geoffray <ngeoffray@google.com> Revert "ART: Fix up some multi-image cases"

Fails imgdiag_test on device.

Bug: 26317072
Bug: 26320300

This reverts commit 288b1e9a0dddfb91e85067fe81de55174f313c7c.

Change-Id: Iccd05827b0630281b6f959331eaa4202526df78e
288b1e9a0dddfb91e85067fe81de55174f313c7c 28-Dec-2015 Andreas Gampe <agampe@google.com> ART: Fix up some multi-image cases

Change the auto-generated multi-image names to include the path
components from the first image, as well as prefix them with the
first image's name to disambiguate. This fixes vogar-style usage.

Fix an out-of-bounds issue in dex2oat when dex files are missing.

Forbid generating or patching multi-image parts when loading images.
Instead just fail loading them.

Remember ImageSpace instances that have been added while trying to
load a multi-image set. Remove all loaded instances when the overall
loading process fails.

Refactor the dex location adaptation into ImageSpace. Reuse the code
in the Runtime path for fallback, so that all dex files can be found
correctly.

Fix an out-of-bounds access in OatFileAssistant in fallback mode.

Partially reverts d895961d07a1d320b29f2045a48bc5a1944a4d3c. Push an
actual image name, that is, something with an art extension, to
the vogar scripts.

Partially reverts c525604b313bb77a2077e1fec43dfab76cb1b9b1. Test
119-noimage-patchoat works again.

Bug: 26317072
Bug: 26320300
Change-Id: I3f05fa77f22a2b9ca54c3105ffc53646c1928604
4d77b6a511659f26fdc711e23825ffa6e7feed7a 01-Dec-2015 Calin Juravle <calin@google.com> Save profile information in a separate thread.

Previously we would save the profiling information only when the app
was sent to background. This missed on an important number of updates
on the jit code cache and it didn't work for background processes.

Bug: 26080105

Change-Id: I84075629870e69b3ed372f00f4806af1e9391e0f
dcdc85bbd569f0ee66c331b4219c19304a616214 04-Dec-2015 Jeff Hao <jeffhao@google.com> Dex2oat support for multiple oat file and image file outputs.

Multiple changes to dex2oat and the runtime to support a --multi-image
option. This generates a separate oat file and image file output for
each dex file input.

Change-Id: Ie1d6f0b8afa8aed5790065b8c2eb177990c60129
d5bbadf44032510b1ce12d9e5f2adad9234cf6b9 15-Dec-2015 Dimitry Ivanov <dimitry@google.com> Use shared namespaces for bundled apps

Shared namespaces clone the list of loaded native
libraries from the caller namespace. This allows
classloaders for bundled apps to share already loaded
libraries with default namespace.

Bug: http://b/26165097
Bug: http://b/22548808
Change-Id: Ia90b603a0ca97194618b82fb191d6790a4b1f281
(cherry picked from commit 986f650d8b552e8b7dbebef1f50f015e7850edfc)
986f650d8b552e8b7dbebef1f50f015e7850edfc 15-Dec-2015 Dimitry Ivanov <dimitry@google.com> Use shared namespaces for bundled apps

Shared namespaces clone the list of loaded native
libraries from the caller namespace. This allows
classloaders for bundled apps to share already loaded
libraries with default namespace.

Bug: http://b/26165097
Bug: http://b/22548808
Change-Id: Ia90b603a0ca97194618b82fb191d6790a4b1f281
66f55237679db90cb0a0a265043a787932b466f8 08-Dec-2015 Calin Juravle <calin@google.com> Pass down to the runtime the application code paths.

When registering the app with the runtime the framework needs to pass
down the list of application code paths. This will be used by JIT to
know what profile info to persist.

This fixes the reliance on OatFileManager::GetPrimaryOatFile which may
produce inconsistent results based on external factors (i.e. class path
order or failing to compile the first dex file from the class path)

Bug: 26080105
Change-Id: Iadcebd2684fcd48569e8f76ef21bd4d117fedc05
aee2156e308f3f346ac4df76ba1d33ee9b11be84 15-Dec-2015 Nicolas Geoffray <ngeoffray@google.com> Add some dumping when SIGQUIT for the JIT.

Change-Id: Iad68bdc8a4ab53e810feb3bc8507b7f42e79b1f7
3e381723658e8a0bce24071b53f57bf22af76a1e 24-Nov-2015 Dmitriy Ivanov <dimitry@google.com> Port isolated namespace changes over to OpenJdkJvm.cc

Bug: http://b/22548808
Change-Id: I6f11102e828ee5ef4b5107590c598fd0db787fe1
44409d33e05cd2f73d69e0a98daa5c9e2fe38089 11-Nov-2015 Dmitriy Ivanov <dimitry@google.com> Use isolated namespaces for app native libs

Linker namespaces provide necessary level
of isolation for application native libraries.

The native libraries will no longer be able to
mistakenly depend on platform private libraries
like /system/lib/libssl.so

This change creates one namespace for each instance
of class-loader and uses it when loading native libraries.

For backwards compatibility with older apps we keep
using default namespace and LD_LIBRARY_PATH if target
sdk version is <= 23. (currently set to 0 for testing)

Bug: http://b/22548808
Change-Id: I64e97af7450fbf7e3740ccddda96bb2f7c52e03b
(cherry picked from commit f5a3099c509cf9b8a4ce9c3073a4db47e14a23bc)
226501b317e148aa8a8983355e85acb59c1eee83 11-Dec-2015 Calin Juravle <calin@google.com> Revert "Revert "Enable profiled guided compilation in dex2oat""

This reverts commit 2306ae0d412cc53cbf64877e4a8c37292dd907d8.

Change-Id: I50640009c2fac88ea703812b76549a0e8a6d7584
d66c8621610dc18d324132c8e5b081520f719777 11-Dec-2015 Nicolas Geoffray <ngeoffray@google.com> Special case system_server to not create the JIT code cache.

Change-Id: I34485c709b0c70b8d9c34bebcf399781aebaf11b
2306ae0d412cc53cbf64877e4a8c37292dd907d8 11-Dec-2015 Calin Juravle <calin@google.com> Revert "Enable profiled guided compilation in dex2oat"

The test still have some flakiness in it which didn't reproduce locally.

This reverts commit 500c9be1f261a8a95ae7a25f4f8084f43207f313.

Change-Id: I132aff62bf03c2f926aafde6869707573bae9b36
7d2b04c227b73257d7c282ca9f7147418091e9f6 11-Dec-2015 Mathieu Chartier <mathieuc@google.com> Skip DumpForSigQuit if debugger is active

Otherwise, the SIGQUIT dumping may get blocked on the mutator lock
and freeze the debugger.

Future work: Ideally we want to dump what we can instead of nothing.

Bug: 26118154

(cherry picked from commit 0b8f1bfdfc721a41d98d13e12c4c67f62f698dfc)

Change-Id: I28e5352dab3b8abce0b39850e3e58282ae454b51
f5a3099c509cf9b8a4ce9c3073a4db47e14a23bc 11-Nov-2015 Dmitriy Ivanov <dimitry@google.com> Use isolated namespaces for app native libs

Linker namespaces provide necessary level
of isolation for application native libraries.

The native libraries will no longer be able to
mistakenly depend on platform private libraries
like /system/lib/libssl.so

This change creates one namespace for each instance
of class-loader and uses it when loading native libraries.

For backwards compatibility with older apps we keep
using default namespace and LD_LIBRARY_PATH if target
sdk version is <= 23. (currently set to 0 for testing)

Bug: http://b/22548808
Change-Id: I64e97af7450fbf7e3740ccddda96bb2f7c52e03b
0b8f1bfdfc721a41d98d13e12c4c67f62f698dfc 11-Dec-2015 Mathieu Chartier <mathieuc@google.com> Skip DumpForSigQuit if debugger is active

Otherwise, the SIGQUIT dumping may get blocked on the mutator lock
and freeze the debugger.

Future work: Ideally we want to dump what we can instead of nothing.

Bug: 26118154
Change-Id: I365612a3a34ca6d3215892e6c54b649b93365c80
500c9be1f261a8a95ae7a25f4f8084f43207f313 25-Nov-2015 Calin Juravle <calin@google.com> Enable profiled guided compilation in dex2oat

- add parsing of the profile info saved during JIT.
- don't compile methods which are not part of the profile info.
- delete old profile hooks.
- add test for reading/writing profile. The test is disable in:
* interpreter modes: the test needs JIT.
* no-dex2oat/no-prebuild: we only save profiling info for the primary
oat file. In these modes we don't create oat files and thus nothing
is saved.

Bug:26080105

Change-Id: Ifdc63dc9d4b537fc79e54c3edc3ae3a462bc30fb
88b2b80aed15bb1f931cddd40e44ca525ef10018 04-Dec-2015 Vladimir Marko <vmarko@google.com> Allow initializing runtime with parsed options.

Needed by upcoming refactoring of dex2oat to allow
early writing of dex files to the oat file.

Change-Id: Ia13c26132846801522f181f51f64035d625e8416
9fdb129b90c9a985f606f9d95627b4852171dc11 02-Dec-2015 Nicolas Geoffray <ngeoffray@google.com> Revert "Enable profiled guided compilation in dex2oat"

Test has flakes:

+art F 30865 30865 art/runtime/java_vm_ext.cc:466] JNI DETECTED ERROR IN APPLICATION: input is not valid Modified UTF-8: illegal start byte 0x80
+art F 30865 30865 art/runtime/java_vm_ext.cc:466] string: '��gy�'
+art F 30865 30865 art/runtime/java_vm_ext.cc:466] input: '<0x80> 0xd8 0x67 0x79 0x8e 0x7f'
+art F 30865 30865 art/runtime/java_vm_ext.cc:466] in call to NewStringUTF
+art F 30865 30865 art/runtime/java_vm_ext.cc:466] from java.lang.String Main.getProfileInfoDump(java.lang.String, java.lang.Class, java.lang.Class)

This reverts commit 27e17fd81cc30e16e86c9c15498cae7f920c9dfe.

Change-Id: Id224b5970c3620c4c71fc0d39ed4a2e4755e5f29
049cff0ed5e28aa17a17e456efe3121b6d58910f 02-Dec-2015 Andreas Gampe <agampe@google.com> ART: Refactor oat_file.h/cc for better maintainability

Refactor the code so that generic oat file initialization (checking
ART symbols etc) is common between dlopen and ART's ElfFile
implementation. Reduce methods and fields exposed in the oat_file
header.

Change-Id: I5bf65dd8b7047a007c6bf435b55bdde306595e8d
27e17fd81cc30e16e86c9c15498cae7f920c9dfe 25-Nov-2015 Calin Juravle <calin@google.com> Enable profiled guided compilation in dex2oat

- add parsing of the profile info saved during JIT
- don't compile methods which are not part of the profile info.
- delete old profile hooks

Change-Id: I45a13c3aeb36265d335e57cd160b9ea0fab3cbb5
31f2c155975c5794d481df03eb0947cb48d2c6b5 23-Oct-2015 Calin Juravle <calin@google.com> Save jit profiling info to file.

Currently saves only the hot method references and omits the inline
cache.

Change-Id: I79e91f855f6b52dc19a9a86662604f2eee16613c
0871cd77724873c9a8c58f04168e360afd787ab0 20-Nov-2015 Yi Kong <yikong@google.com> Switch init order of WellKnownClasses and NativeMethods

Native methods need to be loaded before initializing java.lang.Thread
class, make sure we do that first.

Bug: 25760806

(cherry picked from commit 321f0cdf07e09335cad13a96de35c28795880535)

Change-Id: I5f3f7819f660f9ce472a96a13201ab09950e92e3
3db9c5da2925ca5ca82cc37b60a8e9fc39e88d1d 17-Nov-2015 Andreas Gampe <agampe@google.com> ART: Change Init{From,Without}Image to return bool

Rewrite some CHECKs to return false. For a common failure (missing)
image, this improves the abort (as it's not a runtime abort with
lots of stack traces anymore).

Change-Id: I717b1db74950267ced0ad3bafa1aed1693680062
d7b3c7f0044bc5d120cd6d516866ab399489b4e7 18-Nov-2015 Narayan Kamath <narayan@google.com> Rename native library.

Change-Id: I3b89059a91ebb70ee5007a03d5dd237f6bff1251
ba69a51724d33444064443e456ce78b71db2fd16 17-Nov-2015 Nicolas Geoffray <ngeoffray@google.com> Fix bogus DCHECK and rename DidForkFromZygote.

The method can also be called for non-zygote forked processes.

(cherry picked from commit 9d157e48e0abc48f08fd98e4c5e918d029c1b84c)

Change-Id: Id4f57b77c1a7f802f80e066afcf30afecc198bfc
787ae8eb018d46b4b464e3a7c8de37d9262deb61 05-Nov-2015 Nicolas Geoffray <ngeoffray@google.com> Remove DEBUG_JIT from Zygote flags.

The flag is being obsolete by the move to JIT.

(cherry picked from commit 0f042e04efba887557e40f981bd9c41b121c4652)

Change-Id: I32c3183e791690964c00fab02a6ee7bbacf6b665
9d157e48e0abc48f08fd98e4c5e918d029c1b84c 17-Nov-2015 Nicolas Geoffray <ngeoffray@google.com> Fix bogus DCHECK and rename DidForkFromZygote.

The method can also be called for non-zygote forked processes.

Change-Id: Ie93f92bdca9fb8d5bccec0e770e71a38aff2aaef
04302dbb106d590ff72c0dfecda23d85b6565059 12-Nov-2015 Hiroshi Yamauchi <yamauchi@google.com> Fix class unloading with the CC collector.

Avoid unnecessarily decoding dex cache and class loader weak roots,
which would trigger read barriers.

Re-enable 141-class-unload with the CC collector.

Bug: 12687968
Bug: 24468364
Change-Id: Ib4c19f25000873cab0e06047040442d135285745
bc36a0f4d8194f9e3e79dde3b7d01098894535ee 11-Nov-2015 Yi Kong <yikong@google.com> Build libxxavacore library for gtests

It is a dependency for exception_test, jni_compiler_test,
reflection_test and stub_test.

Change-Id: I0a4ed85762091617842901f9bd590d24fe39ec7b
0f042e04efba887557e40f981bd9c41b121c4652 05-Nov-2015 Nicolas Geoffray <ngeoffray@google.com> Remove DEBUG_JIT from Zygote flags.

The flag is being obsolete by the move to JIT.

Change-Id: Iefb12690523e45300557701a9b9c0b9f04feff50
f32e8327da5dd33abe18662fbca5e584cd047816 07-Oct-2015 Przemyslaw Szczepaniak <pszczepaniak@google.com> Add Android System#arraycopy fast specializations.

Re-added System#arraycopy specializations that are
really fast for small arrays. They were introduced
originally in b/7103825.

Change-Id: Ie8c995852810ad555fe73743d4d40ec45d8d6bbe
0787f9d489da6496213c8d60d1dec113a0653f0f 09-Sep-2015 Narayan Kamath <narayan@google.com> Rename native library.

Change-Id: Ie9da5051fc71c512cc8205ae6baf3da040b34ecb
073b16c8429d302d5413e8ffc488b03b8f770780 10-Nov-2015 Mathieu Chartier <mathieuc@google.com> Image space cleanup for app images

Removed Heap::GetImageSpace, added Heap::GetBootImageSpace.

Generalized some logic in the class linker for image spaces.

Bug: 22858531

Change-Id: Ib3e12bb061a247e232d3dc93b0d6b35eb3a34d25
88f423f8ce96d521e8f54f84611520b67d320fdc 07-May-2015 Piotr Jastrzebski <haaawk@google.com> Remove native registration of a new classes.

Change-Id: Iea060b2fb2133f2c7c84b7fde887e591507c02fc
8ca90774165b22fdbc87c89c8b55192e43fb2e43 24-Apr-2015 Piotr Jastrzebski <haaawk@google.com> Load libopenjdkjavacore in addition to libjavacore.

Change-Id: I205f055838adefc7350ae65401310f7d2192f562
6cff48f05894a60aa4742472983a75504536ca15 27-Jan-2014 Christopher Ferris <cferris@google.com> ART: Speed up thread stack tracing for ANRs

Share a BacktraceMap for all threads being dumped, which speeds up
ANR dumping. Results from Nexus 9 (average of five):

Before: 0.587s
After: 0.206s

Change-Id: Ia70e0dbd39049318c02de561e7b95258d4849467
32cc9ee0cdffecb0ec8d80a7fd55d7dccae3a7ee 15-Oct-2015 Mathieu Chartier <mathieuc@google.com> Change hash table load factors

Changed class table and intern table load factors to query the
runtime. The runtime returns load factors based on whether or not we
are a low ram device.

DescriptorEquals time for class linking goes from 10% -> 1.2% for
compiling GmsCore with interpret only.

Added test.

Bug: 24917584

Change-Id: Iaaf5d2eab1b0c2d188d299e4bc1852cdb3801173
e58991b3b2282b5761f1a6023a16c803e1c4eb45 13-Oct-2015 Mathieu Chartier <mathieuc@google.com> Revert "Revert "Unload oat files""

Fixed a race where two threads calling OatFile::Open could both use
dlopen on the host.

Bug: 22720414

This reverts commit 72da5e7461fec3b1e116050f2e6f233efb9c54f3.

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

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

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

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

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

This adds 5 new run-tests for this functionality.

Bug: 24618811

Change-Id: I35ca800d99d3329348b277789b70ceeeba6e7f03
f9c6fc610b27887f832e453a0da1789187293408 07-Oct-2015 Mathieu Chartier <mathieuc@google.com> Add OatFileManager

Takes over a large amount of functionality from the class linker.

Changed OatFile to loading the same OatFile multiple times. This is
required for unloading OatFiles and moving dex caches to BSS since
these require a different OatFile for each dex cache and class
loader.

Bug: 22720414

Change-Id: I0321096723a294dc72949f21e66da82727b512fc
a6b1ead81603513fd40b77fd72f06d8cb1f35276 06-Oct-2015 Mathieu Chartier <mathieuc@google.com> Mark breakpoint roots

Used to prevent class unloading on methods that have breakpoints.

Bug: 22720414
Change-Id: I9aee8bcbfdf253607e89dfc55a50ba3f11d99206
c3fcd41f15dffbb5f28c9900f421471a3d2dd420 26-Sep-2015 Mathieu Chartier <mathieuc@google.com> Address some code comments

Change-Id: I0a38a387c4328d45bbc04d095bf3388c27495c12
017ed0b936539dba1bb6f1d9b2bd81798b471966 22-Sep-2015 Mathieu Chartier <mathieuc@google.com> Fix CreateLinearAlloc bug

Should have been using IsAotCompiler since the JIT has IsCompiler
as true but no low 4 GB arena pool.

Fixes 64 bit JIT tests.

Change-Id: Idc4d3e66c573eacd31ae85c66f8493b418d221d7
951ec2c93c79c5539cbcc669566f0808d4460338 22-Sep-2015 Mathieu Chartier <mathieuc@google.com> Revert "Revert "Add one LinearAlloc per ClassLoader""

Issue was fixed by:
https://android-review.googlesource.com/#/c/171945/

Bug: 22720414

This reverts commit 7de5dfe37f3cf24e1166412b589f6f67dcd1f1c0.
37cf51fb00bbe4bb82e713228b460cafbbf79b43 22-Sep-2015 Vladimir Marko <vmarko@google.com> ART: Fix destruction order in Runtime.

Destroy arena allocators as late as possible.

With https://android-review.googlesource.com/172057 , the
ArenaPool was indirectly used by ClassLinker's destructor
(via ~LinearAlloc) after it has already been destroyed.
These allocators were being destroyed way too early anyway,
they should be orderly destroyed when the unique_ptr<>
members of Runtime have their destructors executed. However,
due to the potential dependence on MemMap, we destroy them
just before the MemMap::ShutDown().

Change-Id: Ifc3e5a24a29536d5767c82353901e2d22b13d643
7de5dfe37f3cf24e1166412b589f6f67dcd1f1c0 22-Sep-2015 Nicolas Geoffray <ngeoffray@google.com> Revert "Add one LinearAlloc per ClassLoader"

Times out on 32bit target/host for 132-daemon-locks-shutdown test.

Bug: 22720414

This reverts commit 356412e2b7ba3fde164bc08a44fee0ddc19c54e1.

Change-Id: I5ab3a09e88a5ad8c306a27d2606ecbecc80b9326
356412e2b7ba3fde164bc08a44fee0ddc19c54e1 21-Sep-2015 Mathieu Chartier <mathieuc@google.com> Add one LinearAlloc per ClassLoader

Also added freeing linear alloc and class table when the
corresponding class loader is no longer reachable.

Bug: 22720414

Change-Id: Icb32c3a4c865f240e147bc87ed080a6b1d8a5795
1147b9bd68323c753ed1a0b6106b205fd640c820 15-Sep-2015 Mathieu Chartier <mathieuc@google.com> Use image pointer size for profile info

May fix some random crashes in dex2oat due to cross compilation.

Change-Id: I633652500e8c7dfec38044dffd07eb467973d82a
5550ca8bcc742b109d77e62f3a0877c667d894d3 21-Aug-2015 Nicolas Geoffray <ngeoffray@google.com> Record profiling information before Jitting.

- Add a new instrumentation kind to record dynamic invokes.
- Use the JNI entry point field to store the profiling data.
- Record seen receivers for every dynamic invoke.

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

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

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

Change-Id: I1e61762df91c046866591bda167d42bf8b67a692
fdbd13c7af91a042eda753e436eeebf0e1937250 03-Sep-2015 Hiroshi Yamauchi <yamauchi@google.com> Some fixes for the CC collector.

- Remove a DCHECK in DisableMarkingCheckpoint, which caused
occasional (false) failures.
- Check the thread-local GetWeakRefAccessEnabled in boxed lambdas weak
access.
- Add missing BroadcastForNewAllocationRecords and
BroadcastForNewWeakBoxedLambdas. The lack of the former caused
occasional deadlocks in the ddmc test.
- Remove the 'ensure system weaks disallowed' calls, which weren't
useful and dead.

Bug: 12687968
Change-Id: I33850c8d12e6e1a3aed1c2bb18eba263cbab76e8
c823effac6455affd40bedbc9f620f9275919e73 02-Sep-2015 Hiroshi Yamauchi <yamauchi@google.com> Disable the GDB-based test timeout dump in 32 bit.

Bug: 23485091
Change-Id: I46b8ae8d0a37439ca6f2d1030dec8e513b82745f
6ffb9ccfec7ec2149c4a3d403ca81c48585857e0 01-Sep-2015 Hiroshi Yamauchi <yamauchi@google.com> Use GDB to dump threads in test timeouts, if available.

GDB is able to dump threads which may not be responding to the SIGQUIT
thread dump.

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

This reverts commit 81a9087f0df0518c39405b7d18ba5858a6d8b77b.

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

Bug: 23602225
Bug: 22720414

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

This reverts commit 3ae6b1d42523bb2a0ddb5edff1aaf05b592f28f4.
3ae6b1d42523bb2a0ddb5edff1aaf05b592f28f4 14-Aug-2015 Mathieu Chartier <mathieuc@google.com> Change dex caches to be weak roots

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

Also deleted some unused functionality in image writer.

Bug: 22720414
Change-Id: If22cb3cad7e3baabc8158a77d7f20799faf4c341
90ef3db4bd1d4865f5f9cb95c8e7d9afb46994f9 05-Aug-2015 Mathieu Chartier <mathieuc@google.com> Address some comments and clean up

Change-Id: I538cf204f1c89d5fc81f8fc5e5800fcf1cf87359
b1d8c314b55bb2df2b2bb72a3daaf5db65b7ebc7 04-Aug-2015 Igor Murashkin <iam@google.com> Revert "cleanup: Replace pointers with out-parameters and fix-up formatting"

This reverts commit a315f5c546b796f55f4872bb6efc15eb858d9639.

--

Revert "runtime: cleanup class_linker out-parameters and formatting"

This reverts commit bc1d78daa463572c5a770cdca858a3b51d8e1b7b.

--

Revert "base: replace raw pointers for out-parameters with safer out<T>"

This reverts commit fb326cffc679cab8eb873b9e44795706f023cb3c.
a315f5c546b796f55f4872bb6efc15eb858d9639 01-Aug-2015 Igor Murashkin <iam@google.com> cleanup: Replace pointers with out-parameters and fix-up formatting

Cleans all of oat_file.h/.cc, parsed_options.h./cc, runtime.h/.cc

Other files are touched only incidentally to use outof(x) instead of &x.

Change-Id: I0bb15111149d53bb21aac2199ef33bd35333b0ca
695a2732ae19649b3331673747177fcc57afb012 25-Jul-2015 Andreas Gampe <agampe@google.com> ART: Make warnings into errors in InitZygote

These warnings are actual errors and lead to failure to start the
runtime. Print them accordingly.

Change-Id: I907e32a3c5da5364ecc9678bb9a11604234d669c
dd6712578b6aa8a292bc6249295b6d2a7b182717 23-Jul-2015 Andreas Gampe <agampe@google.com> ART: Change the stack dump format to be in line with debuggerd

Make offsets 16 digits on 64-bit platforms.

Add the ability to provide the build fingerprint, and print it in
the traces output.

Bug: 22693991

(cherry picked from commit 242ae94dc39be53e519a6163ea1db494ceb75954)

Change-Id: Ibd3d3b3bd65dce84acfb97a487807d6f280a9508
242ae94dc39be53e519a6163ea1db494ceb75954 23-Jul-2015 Andreas Gampe <agampe@google.com> ART: Change the stack dump format to be in line with debuggerd

Make offsets 16 digits on 64-bit platforms.

Add the ability to provide the build fingerprint, and print it in
the traces output.

Bug: 22693991
Change-Id: Ibd3d3b3bd65dce84acfb97a487807d6f280a9508
90443477f9a0061581c420775ce3b7eeae7468bc 17-Jul-2015 Mathieu Chartier <mathieuc@google.com> Move to newer clang annotations

Also enable -Wthread-safety-negative.

Changes:
Switch to capabilities and negative capabilities.

Future work:
Use capabilities to implement uninterruptible annotations to work
with AssertNoThreadSuspension.

Bug: 20072211

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

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

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

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

Change-Id: I786c1323ff14eed937936b303d511875f9642524
7617abdb402fd0419daa3eefb2ad059ccbb8b6db 11-Jul-2015 Igor Murashkin <iam@google.com> runtime: Add -Xverify:softfail and ART_TEST_INTERPRETER_ACCESS_CHECKS

Use ART_TEST_INTERPRETER_ACCESS_CHECKS=true to run all the tests through
the interpreter with access checks enabled. The normal interpreter tests
do not currently enable access checks, which means that a large part of
the interpreter codebase is untested.

The verifier will force every class into a soft fail mode if
-Xverify:softfail is used, thereby ensuring that if used along with the
interpreter (-Xint) that the interpret is always in access checks mode.

This is used alongside with --compile-filter=verify-at-runtime to
prevent the AOT compiler from putting down any code.

Change-Id: I35a10ed8c43d76fa96133cf01fdad497da387200
14c3bf91b2ec434295ec84d6446f495fb7de6d5c 13-Jul-2015 Mathieu Chartier <mathieuc@google.com> Change intern table to not use WaitHoldingLocks

Bug: 22423014
Change-Id: I9e16b8cb4def72fff73f1783a182877105feb7aa
97509954404d031594b2ecbda607314d169d512e 13-Jul-2015 Mathieu Chartier <mathieuc@google.com> Clean up GC callbacks to be virtual methods

Change-Id: Ia08034a4e5931c4fcb329c3bd3c4b1f301135735
1e13374baf7dfaf442ffbf9809c37c131d681eaf 20-May-2015 Evgenii Stepanov <eugenis@google.com> Generalize Valgrind annotations in ART to support ASan.

Also add redzones around non-fixed mem_map(s).
Also extend -Wframe-larger-than limit to enable arm64 ASan build.

Change-Id: Ie572481a25fead59fc8978d2c317a33ac418516c
0b71357fb52be9bb06d35396a3042b4381b01041 17-Jun-2015 Hiroshi Yamauchi <yamauchi@google.com> Thread-local mark stacks for the CC collector.

Thread-local mark stacks are assigned to mutators where they push
references in read barriers to reduce the (CAS) synchronization cost
in a global mark stack/queue.

We step through three mark stack modes (thread-local, shared,
GC-exclusive) and use per-thread flags to disable/enable system weak
accesses (only for the CC collector) instead of the existing global
one to safely perform the marking phase. The reasons are 1)
thread-local mark stacks for mutators need to be revoked using a
checkpoint to avoid races (incorrectly leaving a reference on mark
stacks) when terminating marking, and 2) we can’t use a checkpoint
while system weak accesses are disabled (or a deadlock would
happen). More details are described in the code comments.

Performance improvements in Ritzperf EAAC: a ~2.8% improvement
(13290->12918) in run time and a ~23% improvement (51.6s->39.8s) in
the total GC time on N5.

Bug: 12687968
Change-Id: I5d234d7e48bf115cd773d38bdb62ad24ce9116c7
7a4d0157eb690266928902a67922f346e290f4c6 10-Jul-2015 Nicolas Geoffray <ngeoffray@google.com> Change JIT code to use optimizing.

Obviously, will fall back to quick for most methods currently,
due to lack of -QUICK opcodes support.

Change-Id: I28882fbe805cd907275b6047437d9639a475964a
41656de4b6440bcd1bea5fb785f0710153b2bc68 07-Jul-2015 Man Cao <manc@google.com> Fix potential bugs in allocation tracker

Add a missing visit allocation records call in concurrent copying collecter.
Handle null class objects if we support class unloading, and issues
with disallow and allow new allocation records.

Bug: 20037135
Change-Id: I59b7321c281e0d79a620501b2f43e36d2a576203
ccbbda2b716bcc0dd9ad7b6c7bf9079efa3fca23 03-Jul-2015 Douglas Leung <douglas.leung@imgtec.com> Add implicit null pointer and stack overflow checks for Mips.

(cherry picked from commit 22bb5a2ebc1e2724179faf4660b2735dcb185f21)

Bug: 21555893
Change-Id: I2a995be128a5603d08753c14956dd8c8240ac63c
22bb5a2ebc1e2724179faf4660b2735dcb185f21 03-Jul-2015 Douglas Leung <douglas.leung@imgtec.com> Add implicit null pointer and stack overflow checks for Mips.

Bug: 21555893
Change-Id: I2a995be128a5603d08753c14956dd8c8240ac63c
01aaf6ef3e3e35cc8e41cf3fe899a7bf337042f4 19-Jun-2015 Calin Juravle <calin@google.com> Allow for sig chain to be disabled.

Tools like dex2oat or patchoat don't need the sig chain or the fault
manager. This also enables building a statically link version of
dex2oat.

Change-Id: I9897728cac48acade854bb027bfde860628ebf84
42c3c33df8b6eefc4ba532f1981282510f109928 24-Jun-2015 Man Cao <manc@google.com> Make allocation tracker use less memory

The allocation tracker no longer keeps recently allocated objects live.
Instead it just keeps their class objects live as strong roots. This fixed
the gc-stress test failure for 098-ddmc.

Also fixed the issue in DisableNewSystemWeak() for allocation tracker,
by making new allocation to wait until GC's sweeping to complete. I didn't
feel any significant slowdown with this wait.

Bug: 20037135
Change-Id: I6a98188832cf7ee478007e3788e742dc6e18f7b8
1ed11b9ad5512cf464cb1686640df53201fa5297 12-Jun-2015 Man Cao <manc@google.com> Restore DDMS recent allocation tracking's behavior

Make the allocation tracker mark recently allocated objects as roots,
so the allocation records are not swept. Because DDMS needs recent
allocation tracking records even for dead objects. This should fix
the flaky failures for 098-ddmc test, but it cannot pass GC stress
test (OOM). Re-enabled 098-ddmc for other tests.

There should be an option to not mark them as roots, when user only
needs HPROF dump with traces but not DDMS's recent allocation tracking.
Probably need to add a new JNI API function for this option.

There could be another way to keep a second list of recent allocation
records and maintain a type cache for them, so not to make the objects
roots. But it's more complex, and not sure which is better.

Also reduce memory usage for AllocRecordStackTrace objects, and change
default stack depth to 16. Rename the property that controls the stack
depth to "debug.allocTracker.maxStackDepth" so developer can change it.

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

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

Added runtime -Xgc options: gcstress and nogcstress.

Bug: 21664466

(cherry picked from commit 310008008c90fea246efd00cb99ee7ded97c5209)

Change-Id: Icb8e420f2048e8ee83bcca7937563166a2638f5c
310008008c90fea246efd00cb99ee7ded97c5209 14-Jun-2015 Mathieu Chartier <mathieuc@google.com> New experimental GC stress mode

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

Added runtime -Xgc options: gcstress and nogcstress.

Bug: 21664466

Change-Id: Icb8e420f2048e8ee83bcca7937563166a2638f5c
158f35c98e2ec0d40d2c032b8cdce5fb60944a7f 11-Jun-2015 Igor Murashkin <iam@google.com> interpreter: Add experimental lambda opcodes for invoke/create-lambda

These opcodes are not yet fully specified, and *will* change before they become shippable.
Do not write production code against experimental opcodes.

--

Implement partial interpreter support for new dex instructions invoke/create-lambda, and a
new opcode format 25x.

* Does not verify, in fact verification will soft fail when we see those opcodes.
* Compilers will punt to interpreter since they don't support new opcodes.
* As there is no way to capture/liberate variables yet, the "closure" is just
an ArtMethod for the time being.

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

For example:
dalvikvm ... -Xexperimental-lambdas ...
dex2oat --runtime-arg -Xexperimental-lambdas ...

Change-Id: I6c996ca32a9b54ec45ec21d7a959b84dfb8a24eb
37670178497df18ae6b2a97a2ea9bf365621f16e 11-Jun-2015 Hiroshi Yamauchi <yamauchi@google.com> Reset GC performance stats at zygote fork.

So GCs before a zygote fork won't be attributed to an app.

(cherry pick commit Ib37bc587e0f039ef8faeabe63dec19de49501863)

Bug: 21491908
Change-Id: Ib37bc587e0f039ef8faeabe63dec19de49501863
9a7fffb36bad0bf3e7bac21dd223d975bc9dde55 11-Jun-2015 Hiroshi Yamauchi <yamauchi@google.com> Reset GC performance stats at zygote fork.

So GCs before a zygote fork won't be attributed to an app.

Bug: 21491908
Change-Id: Ib37bc587e0f039ef8faeabe63dec19de49501863
8c2ff641294715864013737fdec57cdfd410270c 28-May-2015 Man Cao <manc@google.com> Add allocation stack traces for HPROF dump.

This feature is currently only enabled when DDMS's allocation tracking
is enabled. In the future there should be a way to enable this feature
before an application starts.

Also updates DDMS's recent allocation tracking to use a new backend
data structure that is shared with this feature.

The following system properties controls customizable parameters:
dalvik.vm.allocTrackerMax: max number of objects that have allocation
records, default 512K;

dalvik.vm.recentAllocMax: max number of records that are sent to DDMS
when clicking "Get allocation" button,
default 64K-1 (limit of the protocol);

dalvik.vm.allocStackDepth: max number of stack frames in an allocation
record, default 4.

Bug: 20037135
Change-Id: I26ed378a5613678bd3c43e846025f90470a8e059
054a078ecebfb84b5003f2d0239c472de53267e2 07-Apr-2015 Richard Uhler <ruhler@google.com> Add atrace calls to runtime start and heap create

(cherry picked from commit 7fabaa6ba1927d21a317c03499b705cbde4f6a47)

Bug: 20727525

Change-Id: I91a74b793fb9eda8ed580244a6a5fd313ef2eb27
7fabaa6ba1927d21a317c03499b705cbde4f6a47 07-Apr-2015 Richard Uhler <ruhler@google.com> Add atrace calls to runtime start and heap create

Bug: 20727525

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

Optimizing + quick tests are passing, devices boot.

TODO: Test and fix bugs in mips64.

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

Bug: 19264997

(cherry picked from commit e401d146407d61eeb99f8d6176b2ac13c4df1e33)

Change-Id: I622469a0cfa0e7082a2119f3d6a9491eb61e3f3d

Fix some ArtMethod related bugs

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

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

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

TODO: Fix JDWP tests.

Bug: 19264997

Change-Id: I7c55f69c61d1b45351fd0dc7185ffe5efad82bd3

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

Bug: 19264997
Change-Id: Ief45cdd4bae5a43fc8bfdfa7cf744e2c57529457

Fix JDWP tests after ArtMethod change

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

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

Bug: 19264997
Change-Id: I363e293796848c3ec491c963813f62d868da44d2

Fix accidental IMT and root marking regression

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

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

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

Bug: 19264997
Change-Id: I4333e80a8268c2ed1284f87f25b9f113d4f2c7e0

Fix bogus image test assert

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

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

Bug: 19264997
Change-Id: I7359f1f73ae3df60c5147245935a24431c04808a

[MIPS64] Fix art_quick_invoke_stub argument offsets.

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

This fixes mips64 boot.

Bug: 19264997
Change-Id: I47198d5f39a4caab30b3b77479d5eedaad5006ab
e3b034a6f6f0d80d519ab08bdd18be4de2a4a2db 31-May-2015 Mathieu Chartier <mathieuc@google.com> Fix some ArtMethod related bugs

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

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

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

TODO: Fix JDWP tests.

Bug: 19264997

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

Optimizing + quick tests are passing, devices boot.

TODO: Test and fix bugs in mips64.

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

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

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

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

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

Bug: 20944228

(cherry picked from commit 0de1133ba600f299b3d67938f650720d9f859eb2)

Change-Id: If6b2236e7fe547cc421f57b573043748018d3ae0
0de1133ba600f299b3d67938f650720d9f859eb2 13-May-2015 Sebastien Hertz <shertz@google.com> Fix debuggable compiler flag detection for secondary dex files

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

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

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

Bug: 20944228
Change-Id: I59119f3468adb27ab1d6026f2cefbebbd814224c
b81e1cddd6a8ccccb9fe86e3bfae12b2657b8085 28-Apr-2015 Sebastien Hertz <shertz@google.com> Fix missing transaction abort error message

Change-Id: I5157def06d385c082f9fdd4714e20bead9e707e8
848f70a3d73833fc1bf3032a9ff6812e429661d9 15-Jan-2014 Jeff Hao <jeffhao@google.com> Replace String CharArray with internal uint16_t array.

Summary of high level changes:
- Adds compiler inliner support to identify string init methods
- Adds compiler support (quick & optimizing) with new invoke code path
that calls method off the thread pointer
- Adds thread entrypoints for all string init methods
- Adds map to verifier to log when receiver of string init has been
copied to other registers. used by compiler and interpreter

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

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

Change-Id: I6efba5fb6e03eb5d0a300fddb2a75bf8e2f175cb
fc58af45e342ba9e18bbdf597f205a58ec731658 17-Apr-2015 Mathieu Chartier <mathieuc@google.com> Add AbstractMethod, Constructor, Method

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

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

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

Bug: 19264997

Change-Id: Ife79c469fdb09f30e3aefcfc3e0ce5ed32303fce
40da286d3207d88ed8ff3f5caac4873874603428 27-Feb-2015 Andreas Gampe <agampe@google.com> ART: Streaming trace mode

Add a streaming mode for tracing. Streaming uses a buffer of 16KB
and writes to the output when that buffer gets full. Streaming mode
can be enabled with -Xmethod-trace-stream and is currently not
exposed otherwise.

Add a python script that can parse the streaming format, which
simply contains strings for newly encountered threads and methods
inline, and create output that can be used with traceview.

Add Trace::Pause and Trace::Abort, which can pause and abort tracing.
Abort is different from Stop in that it does not write the data.

Add code to the zygote hooks JNI implementation that pauses tracing
before the fork, making sure that a child cannot clobber the parent's
data.

Add code to the zygote hooks JNI implementation that aborts old
tracing and starts new tracing in the child after the fork. Currently
base the output on the pid. This will not work on an unmodified
device, as the profiles directory is not generally writable, but
we do not have enough information at that point. Consider a scheme
that restarts tracing later.

Change-Id: I93c7bf87e35af582bdfdd3ecc7c52454514220dd
3481ba2c4e4f3aa80d8c6d50a9f85dacb56b508b 13-Apr-2015 Vladimir Marko <vmarko@google.com> ART: Clean up includes.

Reduce dependencies to improve incremental build times.
Break up circular dependency involving class_linker-inl.h.

Change-Id: I4be742c5c2b5cd9855beea86630fd68aab76b0db
c785344b87221f5e4e6473e5b762e4e61fe65dcf 27-Mar-2015 Mathieu Chartier <mathieuc@google.com> Move ArtField to native

Add linear alloc. Moved ArtField to be native object. Changed image
writer to put ArtFields after the mirror section.

Savings:
2MB on low ram devices
4MB on normal devices

Total PSS measurements before (normal N5, 95s after shell start):
Image size: 7729152 bytes
23112 kB: .NonMoving
23212 kB: .NonMoving
22868 kB: .NonMoving
23072 kB: .NonMoving
22836 kB: .NonMoving
19618 kB: .Zygote
19850 kB: .Zygote
19623 kB: .Zygote
19924 kB: .Zygote
19612 kB: .Zygote
Avg: 42745.4 kB

After:
Image size: 7462912 bytes
17440 kB: .NonMoving
16776 kB: .NonMoving
16804 kB: .NonMoving
17812 kB: .NonMoving
16820 kB: .NonMoving
18788 kB: .Zygote
18856 kB: .Zygote
19064 kB: .Zygote
18841 kB: .Zygote
18629 kB: .Zygote
3499 kB: .LinearAlloc
3408 kB: .LinearAlloc
3424 kB: .LinearAlloc
3600 kB: .LinearAlloc
3436 kB: .LinearAlloc
Avg: 39439.4 kB

No reflection performance changes.

Bug: 19264997
Bug: 17643507

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

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

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

Mips64 is untested but might work, maybe.

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

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

Bug: 19264997

Change-Id: I0a71ebb5928f205b9b3f7945b25db6489d5657ca
02d2f290380c6aeff5f5a089ee38fa5d55e46130 03-Apr-2015 Hiroshi Yamauchi <yamauchi@google.com> Fix the read barrier builds.

A check failure (!UseJit() in ArtMethod::Invoke()) in forced interpret
only mode in the eng build with JIT enabled by default on target.

A build failure (inl header file issues) in the USE_BAKER_READ_BARRIER
build.

Change-Id: Ib13632b10864ad8b4691b66971c0ab5d2ae1e675
2fd7e69505195cda4caaa3161aaf37315552a698 02-Apr-2015 Sebastien Hertz <shertz@google.com> Use specific exception class to abort transaction

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

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

Bug: 20019689
Change-Id: I019a72a1c754d8bba6a7ad6bb0f02e4fd6668622
f6a780abeaed4bf745720e8f836a3064d3ffbec4 03-Apr-2015 Andreas Gampe <agampe@google.com> ART: Move trace options to a struct

Bundles the different options and moves them to a struct in the
implementation file. Will allow for easier change for streaming.

Change-Id: I486e0942614e714964eb233e2d6b4e3e12aa704f
461687d898dfd91253f242072849a9fe43e5f523 31-Mar-2015 Mathieu Chartier <mathieuc@google.com> Visit image roots for hprof

Bug: 19995360

(cherry picked from commit 0cab5e68f14ee403380664146db6dc7ddfc32064)

Change-Id: I17868bff2a701dc25291d41b9732c6b86f92be08
0cab5e68f14ee403380664146db6dc7ddfc32064 31-Mar-2015 Mathieu Chartier <mathieuc@google.com> Visit image roots for hprof

Bug: 19995360
Change-Id: I1f2989c8bccf508b1d47dfd0d7aee4c7bb275b56
7e7e0f47628fb358da70c5e2766545c4f0596235 30-Mar-2015 Andreas Gampe <agampe@google.com> ART: Use enums in Trace

Move away from booleans. Will make introduction of streaming mode
a bit easier / obvious.

Change-Id: Id7ae92f6b97f627e848510d473931537d7db0db8
daaf3265806eb2eadb2e03302bd68022fab5ca28 24-Mar-2015 Mathieu Chartier <mathieuc@google.com> Add AccessibleObject and Field to mirror

Main motivation is to remove all the functionality / field access on
java side to ArtField. Also comes with some reflection speedups /
slowdowns.

Summary results:
getDeclaredField/getField are slower mostly due to JNI overhead.
However, there is a large speedup in getInt, setInt,
GetInstanceField, and GetStaticField.

Before timings (N5 --compiler-filter=everything):

benchmark ns linear runtime
Class_getDeclaredField 782.86 ===
Class_getField 832.77 ===
Field_getInt 160.17 =
Field_setInt 195.88 =
GetInstanceField 3214.38 ==============
GetStaticField 6809.49 ==============================

After:
Class_getDeclaredField 1068.15 ============
Class_getField 1180.00 ==============
Field_getInt 121.85 =
Field_setInt 139.98 =
GetInstanceField 1986.15 =======================
GetStaticField 2523.63 ==============================

Bug: 19264997

Change-Id: Ic0d0fc1b56b95cd6d60f8e76f19caeaa23045c77
4585f876eb5dfb936bd0d6cb6acd78a1f2182ba6 28-Mar-2015 Andreas Gampe <agampe@google.com> ART: Some runtime cleanup

Use an enum for the compiler-callback mode.

Refactor and remove some unnecessary includes in runtime.h.

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

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

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

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

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

Bug: 19781184

Change-Id: I7f36af12dd7852d21281110a25c119e8c0669c1d
e5fed03772144595c0904faf3d6974cc55214c8c 18-Mar-2015 Richard Uhler <ruhler@google.com> Support relative encoded dex locations in oat files.

Now when opening an oat file, the caller can pass an absolute dex
location used to resolve the absolute path for any relative
encoded dex locations in the oat file.

Bug: 19550105
Change-Id: I6e9559afe4d86ac12cf0b90176b5ea696a83d0e7
785049f8083e56e88dfeab5ff74fb3817f9854e3 18-Jul-2014 Dmitriy Ivanov <dimitry@google.com> Add paths to apk!lib/<abi> to LD_LIBRARY_PATH

Add paths to .apk to LD_LIBRARY_PATH to enable
bionic linker's "open from zip-file" feature.

Bug: 8076853
Change-Id: I1aa2c039bb2a590ae72f256acc9ba5401c2c59b1
455f67c4cf0b4f04e117db3024fd189fa1c7dab9 17-Mar-2015 Mathieu Chartier <mathieuc@google.com> Fix JIT options with late init

Previously we couldn't create the JIT since we didn't have any
JITOptions.

Bug: 19735273

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

Bug: 10921004

Change-Id: I3a1425d76cd380587ba67ef6d5ec1227564e55bf
2435a43f6c851c23922d8508fb17c6079248201c 13-Mar-2015 bowen_lai <bowen_lai@htc.com> ART: Add entries_ lock for race condition

GCDaemon thread would visit incorrect RegType content when there is
another thread initializing classes.
Add a lock to protect entries_.

https://code.google.com/p/android/issues/detail?id=159849

Change-Id: Iabaa1c7f5cc5106b60a6e3856152e0797e8a5d6d
c6201fa2ec66a218c4d0320fbcddd2fbb65cfa4a 12-Mar-2015 Mathieu Chartier <mathieuc@google.com> Add way to select arena type at runtime

We now use MemMap for JIT, and malloc for everything else. This
should help fix the allegedly regressed compile times.

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

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

Change-Id: I3d2126af1dc673cec3a0453ff3d56a172663a5f6
9b34b244ecddd8a35c922ed87bc3df0ca4db0282 09-Mar-2015 Mathieu Chartier <mathieuc@google.com> Trim arenas for JIT

Moved arena pool into the runtime. Added arena trimming to arena
pool. When called, this madvises the used memory.

Changed the JIT compiler to trim arenas after compilation. Changed
the arena mmap name to dalvik-LinearAlloc.

Native PSS before:
80353 kB: Native
80775 kB: Native
78116 kB: Native
After:
73357 kB: Native
70181 kB: Native
70306 kB: Native

Bug: 17950037
Bug: 17643507
Bug: 19264997

Change-Id: I63e7a898fd6e909c2c677fa57b5917a7b1398930
14691c5e786e8c2c5734f687e4c96217340771be 05-Mar-2015 Nicolas Geoffray <ngeoffray@google.com> Compute the right catch location for the debugger.

Also remove tls ThrowLocation, it is not needed anymore.

Change-Id: I78fddf09ce968ca475e39c17fa76d699c589c8d9
184c9dc3bfc500134fdb2fbea0a7fab290c0abb0 05-Mar-2015 Mathieu Chartier <mathieuc@google.com> Fix some incorrect IsCompiler instead of IsAotCompiler

Fixes jdwp related issues (DDMS) when JIT is enabled.

Bug: 19623297
Change-Id: I36139c70a97b529135febcf01b227e7ab9affacc
7b2f09eb6b5c74ffc38bd70f0aa74b8f8112e394 02-Mar-2015 Andreas Gampe <agampe@google.com> ART: Add debuggable compiler flag

Add a flag to compiler options that shows debuggability.

Change-Id: Id17ec72babe2ee88713a0d274eff86508de30666
bd9cf9f6bbf285ec7a5b74ce655a9e68e0f6e434 03-Mar-2015 Sebastien Hertz <shertz@google.com> Follow-up 128393

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

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

Bug: 19202032
Change-Id: I3c53639cbb888086ad345d668d1e5b73c5aaf861
deebb99a53b0af3ccfde9daaef8cae8fad9e44d2 02-Mar-2015 Mathieu Chartier <mathieuc@google.com> Fix AddCurrentRuntimeFeaturesAsDex2OatArguments jit handling

Now jit passes interpret filter to dex2oat.

Bug: 19550422
Change-Id: I932c7d1084acbb9d356ad0f5534a270e2ca2d6ec
e5f13e57ff8fa36342beb33830b3ec5942a61cca 24-Feb-2015 Mathieu Chartier <mathieuc@google.com> Revert "Revert "Add JIT""

Added missing EntryPointToCodePointer.

This reverts commit a5ca888d715cd0c6c421313211caa1928be3e399.

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

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

Bug: 17950037
This reverts commit 2535abe7d1fcdd0e6aca782b1f1932a703ed50a4.

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

Currently disabled by default unless -Xjit is passed in.

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

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

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

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

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

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

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

Bug: 17950037

Change-Id: Ifa5b2684a2d5059ec5a5210733900aafa3c51bca
05d1461f40a065acb66e6d5248609cf33c5b900a 24-Feb-2015 Mathieu Chartier <mathieuc@google.com> Only detach shutdown thread if we attached it

Speculative fix to:
"Request to unregister unattached thread" bug.

Bug: 18713034
Change-Id: I6e69088dd66970c704010397a11e3758cf107ff9
24e04aa68c575d349eac0d9d09aab9bd3106ef94 12-Sep-2014 Jean Christophe Beyler <jean.christophe.beyler@intel.com> ART: Allow the execution to stop if the compilation fails via an option

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

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

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

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

Add testing.

Bug: 19100590
Change-Id: Iaf07b5ccf00942ca8a8ec8687599320a3ddbc089
Signed-off-by: Jean Christophe Beyler <jean.christophe.beyler@intel.com>
5a2be3f40125af8b25fbbd9d55dc968168c76ed7 16-Feb-2015 Narayan Kamath <narayan@google.com> Implement a simple count based boot marker.

We write the number of failed boots to the marker and only
prune the dalvik cache if the number of consecutive failed
boots is higher than a predefined threshold.

Note that the code is forgiving of errors related to boot
markers; we continue the boot process even if we're unable
to create / write or flush the boot marker.

bug: 19360096
Change-Id: Ia17c3b783318ddf43c9199d0f7f09c54a4176667
f360ad091bdc1484db2e4e0f0492f620402dbf58 20-Feb-2015 Hiroshi Yamauchi <yamauchi@google.com> Make UseTLAB a bool flag.

This would make it easier to override its default value at build time.

Change-Id: I643fe1afaf492f0443dc01df0c9a62bb3fa025d9
b3b173bbbd1d1cbad555de13c3fa6765f5078bce 06-Feb-2015 Sebastien Hertz <shertz@google.com> Follow up 129144

Passes JDWP options to debugger on runtime init so we no longer need
to keep them on the heap.

Updates ParseJdwpOption to return Result for consistency.

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

Bug: 19100762
Change-Id: I62358905fa882284d0201ed3c1e97e1286ccec5f
3be6e9d904baa13d7cf51dfc6742dea12e766b2e 05-Feb-2015 Sebastien Hertz <shertz@google.com> Read JDWP options from runtime

Allocates JDWP::JdwpOptions on the heap and copies parsed options to
avoid the need to include jdwp/jdwp.h into runtime.h file.

Also does some minor cleanup and removes the old JDWP options parsing
code that became dead code after we move it to the new command-line
parser.

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

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

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

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

Bug: 19202032
Change-Id: Iedc6969528a68bbdf3123146e990df4dbc57834b
eb6c7c23a8065af665e71f3408980bacd8ecc529 05-Feb-2015 Igor Murashkin <iam@google.com> art: Try to fix parsed_options_test on the build server

(It works fine locally because environment variables are defined
differently)

Also some minor cleanup elsewhere pointed out in the previous code
review.

Change-Id: I80650d2be6ce467b838db85eb130a0020d7c1480
aaebaa0121be3b9d9f13630585304482cbcaeb4b 26-Jan-2015 Igor Murashkin <iam@google.com> art: Refactor RuntimeOptions/ParsedOptions

Refactor the RuntimeOptions to be a
type-safe map (VariantMap, see runtime_options.h) and the ParsedOptions
to delegate the parsing to CmdlineParser (see cmdline/cmdline_parser.h).

This is the start of a command line parsing refactor, and may include
more in the future (dex2oat, patchoat, etc).

For more details of the command line parsing generator usage see cmdline/README.md

Change-Id: Ic67c6bca5e1f33bf2ec60e2e3ff8c366bab91563
02c5f4dbc26d3a055953a5ac4578817bc0375b41 30-Jan-2015 Brian Carlstrom <bdc@google.com> Remove some unused cutils/properties.h references

Also remove an obsolete include workaround

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

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

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

Some other cleanup.

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

(cherry picked from commit 12f7423a2bb4bfab76700d84eb6d4338d211983a)

Bug: 18588862
Change-Id: Ic5a2781f704e931265ffb3621c2eab4b2e25f60f
57b34294758e9c00993913ebe43c7ee4698a5cc6 15-Jan-2015 Andreas Gampe <agampe@google.com> ART: Allow to compile interpret-only mips64 files

Include enough infrastructure to allow cross-compiling for mips64,
interpret-only. This includes the instruction-set-features, frame
size info and utils assembler.

Also add a disassembler for oatdump, and support in patchoat.

Note: the runtime cannot run mips64, yet.

Change-Id: Id106581fa76b478984741c62a8a03be0f370d992
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
fbef44de596d298dc6430f482dffc933a046dd28 23-Dec-2014 Richard Uhler <ruhler@google.com> Use unique_ptr to track ownership of dex files.

Bug: 18809837
Change-Id: Ie571eae8fc19ee9207390cff5c7e2a38071b126a
e6c143fae8ec487704b3d0d28914cda3d6d19e88 13-Jan-2015 Sebastien Hertz <shertz@google.com> Fix bootclasspath string initialization

When running the runtime with an image without explicitly specifying
the bootclasspath (with the -Xbootclasspath option), we construct it
from the location of DEX files loaded from the image.

This allows to fix the JDWP test ClassPathsTest#testClassPaths001 on
the host where the bootclasspath is not explicitly specified on the
command line.

Bug: 18812378
Change-Id: I726eafd8b9e59dc9513beeb7082cf086fe89c4b1
c275259449ec57987e52d3ab1eda3272b994488f 02-Jan-2015 Richard Uhler <ruhler@google.com> Remove back-door bootclasspath option from Runtime

The 'bootclasspath' option allowed users of the Runtime to load their
own boot class path DexFiles and pass them directly to the Runtime as
an option. This obscures the fact that the Runtime must take ownership
of the boot class path DexFiles.

This change removes the use of the bootclasspath option by dex2oat and
the common runtime tests. For dex2oat, we use the existing
-Xbootclasspath option instead, and introduce a new
-Xbootclasspath-locations option to override the dex locations for the
loaded boot class path dex files. For the common runtime tests, we
simply use -Xbootclasspath.

Bug: 18809837
Change-Id: Idfcd4885390bf0f3dc350993756dd337220def73
a2cfee3854193d541530f511ea328b0c1a3136c6 08-Jan-2015 Igor Murashkin <iam@google.com> Fix valgrind imgdiag test failure / memory leak in runtime

Bug: 18907700
Change-Id: I399a6a64a743d3fac86b8bb5bf0eef1f23b95dc4
487c1c9a0ae4022ef01c95bd92a6ea9cb14dc59c 16-Dec-2014 Mathieu Chartier <mathieuc@google.com> Don't add or remove verifiers if aborting

Prevents deadlock if marking verifier roots fails when we attempt to
dump the stack traces. The deadlock occurs from FindLocksAtDexPC
since this allocates a new verifier then adds / removes it from the
method_verifiers_ array.

Bug: 18651054
Change-Id: Ia9b9470ce5e4ac20bfbb39bef0283974cf487765
d289348804738ad26f1c787b265d9d8156170ae1 13-Dec-2014 Elliott Hughes <enh@google.com> Remove a dependency on AndroidConfig.h.

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

Change-Id: I3bf3250fa866fd2265f1b115d52fa5dedc48a7fc
cef50f0487929f72183623bc2a5819cf3a63bff6 10-Dec-2014 Mathieu Chartier <mathieuc@google.com> Stop daemon threads in runtime shutdown

Ensure that daemons are stopped and joins before bringing down the
runtime. This fixes bugs related to native code still running when
we shutdown the runtime.

Also changed the mutex destructor to allow contenders if we are
deleting a monitor lock level mutex.

Bug: 18577101
Change-Id: I6457b35fd69c6997b9003b5f15f39861749843a9
db978719dbcb73fc6acfd193561445c4462786b8 09-Dec-2014 Nicolas Geoffray <ngeoffray@google.com> Revert "Tidy gAborting."

Creates infinite loop: b/18674776.

This reverts commit 015b137efb434528173779bc3ec8d72494456254.

Change-Id: I67fe310d2e95ee2ec37bec842be06fb1123b6f4e
015b137efb434528173779bc3ec8d72494456254 05-Dec-2014 Ian Rogers <irogers@google.com> Tidy gAborting.

Reduce scope to Runtime::Abort and short-cut recursive case earlier. gAborting
remains global to avoid two fatal errors in thread and the verifier.

Change-Id: Ibc893f891ffee9a763c65cde9507d99083d47b3f
56bf0c793d461cc2f9c37ab8fce79a268fd700e0 26-Nov-2014 Dmitriy Ivanov <dimitry@google.com> Disable stack mprotects when running on valgrind

Bug: 18155388
Change-Id: I17d7e3c707e83b864b0394ebbfb2438021faf76f
9c7d8bcc60d3c80df074ebac6ec62cf60a852bfa 17-Nov-2014 Mathieu Chartier <mathieuc@google.com> Change IsZygote test to !IsCompiler

Enables test coverage through run test 118.

Change-Id: I21ce32e83629eb507b8440cebdd721d29171a984
bc58ede2eebe20d592959b88c36fb74d4d832441 17-Nov-2014 Mathieu Chartier <mathieuc@google.com> Don't call AddImageStringsToTable or MoveImageClassesToClassTable if running imageless

If we fail to create the image we use imageless running, this was
breaking AddImageStringsToTable since we didn't check for this
case. Added a check which avoids calling AddImageStringsToTable and
MoveImageClassesToClassTable if we don't have an image.

Bug: 18412472

(cherry picked from commit ab1953f35880f94752e1fcde3f6b3f0d3532125b)

Change-Id: Ida18e1fcd04d752d55923e65c3122c0ac0bde728
ab1953f35880f94752e1fcde3f6b3f0d3532125b 17-Nov-2014 Mathieu Chartier <mathieuc@google.com> Don't call AddImageStringsToTable or MoveImageClassesToClassTable if running imageless

If we fail to create the image we use imageless running, this was
breaking AddImageStringsToTable since we didn't check for this
case. Added a check which avoids calling AddImageStringsToTable and
MoveImageClassesToClassTable if we don't have an image.

Bug: 18412472
Change-Id: I1dd8f306d5e41356a6b62fbd95315f564ee0d36e
d582fa4ea62083a7598dded5b82dc2198b3daac7 06-Nov-2014 Ian Rogers <irogers@google.com> Instruction set features for ARM64, MIPS and X86.

Also, refactor how feature strings are handled so they are additive or
subtractive.
Make MIPS have features for FPU 32-bit and MIPS v2. Use in the quick compiler
rather than #ifdefs that wouldn't have worked in cross-compilation.
Add SIMD features for x86/x86-64 proposed in:
https://android-review.googlesource.com/#/c/112370/

Bug: 18056890

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

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

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

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

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

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

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

Bug: 17808975

Change-Id: I93e376cf6eb9628cf52f4aefdadb6157acfb799a

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

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

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

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

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

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

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

Bug: 17808975

Change-Id: I93e376cf6eb9628cf52f4aefdadb6157acfb799a
277ccbd200ea43590dfc06a93ae184a765327ad0 04-Nov-2014 Andreas Gampe <agampe@google.com> ART: More warnings

Enable -Wno-conversion-null, -Wredundant-decls and -Wshadow in general,
and -Wunused-but-set-parameter for GCC builds.

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

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

Change-Id: I5b433e722d2f75baacfacae4d32aef4a828bfe1b
eb175f70ef352ce0b9bcafdf06c5ac22b0ff626a 31-Oct-2014 Mathieu Chartier <mathieuc@google.com> Add image strings to intern table

When we create the runtime, we now add the image strings to the
intern table if we are the zygote. This caused some memory bloat,
so I added an extra unordered set to the intern table.

There is now two unordered sets (hash talbe). One for pre-zygote
interns and one for post-zygote interns. This helps since the
pre-zygote hash table doesn't get dirtied. Even with adding
the image strings, we get total memory savings of around 5-7 MB
native PSS after device boot.

FB launch Before:
2.20% art::DexFile::FindStringId(char const*) const
TotalTime: 2069
TotalTime: 1985
TotalTime: 2088
TotalTime: 2003
TotalTime: 2034
TotalTime: 2049
After boot native PSS: 175585 kB: Native

After:
0.27% art::DexFile::FindStringId(char const*) const
TotalTime: 1682
TotalTime: 1756
TotalTime: 1825
TotalTime: 1751
TotalTime: 1666
TotalTime: 1813
After boot native PSS: 167089 kB: Native

Bug: 18054905
Bug: 16828525
Bug: 17808975

(cherry picked from commit b6e292bf7eac9d73c6b79b1e9b7b87beb02436c9)

Change-Id: Ie367f3222f8c4db409ec49c3845276908b51e9c9
b6e292bf7eac9d73c6b79b1e9b7b87beb02436c9 31-Oct-2014 Mathieu Chartier <mathieuc@google.com> Add image strings to intern table

When we create the runtime, we now add the image strings to the
intern table if we are the zygote. This caused some memory bloat,
so I added an extra unordered set to the intern table.

There is now two unordered sets (hash talbe). One for pre-zygote
interns and one for post-zygote interns. This helps since the
pre-zygote hash table doesn't get dirtied. Even with adding
the image strings, we get total memory savings of around 5-7 MB
native PSS after device boot.

FB launch Before:
2.20% art::DexFile::FindStringId(char const*) const
TotalTime: 2069
TotalTime: 1985
TotalTime: 2088
TotalTime: 2003
TotalTime: 2034
TotalTime: 2049
After boot native PSS: 175585 kB: Native

After:
0.27% art::DexFile::FindStringId(char const*) const
TotalTime: 1682
TotalTime: 1756
TotalTime: 1825
TotalTime: 1751
TotalTime: 1666
TotalTime: 1813
After boot native PSS: 167089 kB: Native

Bug: 18054905
Bug: 16828525
Bug: 17808975

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

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

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

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

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

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

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

Bug: 18054905
Bug: 16828525

(cherry picked from commit 1fb463e42cf1d67595cff66d19c0f99e3046f4c4)

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

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

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

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

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

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

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

Bug: 18054905
Bug: 16828525

Change-Id: I27cc70178fd3655fbe5a3178887fcba189d21321
2ff973cc395007ddbcf6b498c8de8880d77dd787 22-Oct-2014 Calin Juravle <calin@google.com> [native bridge] Make sure we always unload the native bridge

libnativebridge may allocate some resources during loading and
intialization and de-allocate them when unloading. This makes sure that
we don't leak anything.

Bug: 18097480

(cherry picked from commit 07d83c7a25022064ac0a8dac4fe2a7a38681fa4b)

Change-Id: I3a5155a6760399ccfaf9130c72679615a3d4f2e7
07d83c7a25022064ac0a8dac4fe2a7a38681fa4b 22-Oct-2014 Calin Juravle <calin@google.com> [native bridge] Make sure we always unload the native bridge

libnativebridge may allocate some resources during loading and
intialization and de-allocate them when unloading. This makes sure that
we don't leak anything.

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

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

Change-Id: I3228f614500ccc9b14b49c72b9821c8b0db3d641
3bd08d5de1120b6488c4cdcf8fa17855cf383a1c 20-Oct-2014 Vladimir Marko <vmarko@google.com> Shut down FaultManager after shutting down threads.

Bug: 17703163

(cherry picked from commit 2beeb82523bd3b8015851b69ccd088553ec0c226)

Change-Id: Ic4beae99734ec15b8ead362fbf76a69eceae5980
4f55ff6887559f91f8fb1cbfab0d5b0f3b2cafbe 21-Oct-2014 Elliott Hughes <enh@google.com> Clarify a confusing error message.

We didn't run out of stack; we ran out of heap so there's no stack
trace in the pre-allocated exception we're throwing.

Bug: 17975886
Change-Id: I406f84d7580a28451b232eba323f9c9978e678e6
1d8cdbc5202378a5f1a4b3a1fba610675ed4dcd5 23-Sep-2014 Ian Rogers <irogers@google.com> Refactor quick entrypoints

Remove FinishCalleeSaveFrameSetup.
Assembly routines write down anchor into TLS as well as placing runtime
method in callee save frame.
Simplify artSet64InstanceFromCode by not computing the referrer from the
stack in the C++ code.
Move assembly offset tests next to constant declaration and tidy arch_test.

Change-Id: Iededeebc05e54a1e2bb7bb3572b8ba012cffa1c8
2beeb82523bd3b8015851b69ccd088553ec0c226 20-Oct-2014 Vladimir Marko <vmarko@google.com> Shut down FaultManager after shutting down threads.

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

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

(cherry picked from commit 6f3dbbadf4ce66982eb3d400e0a74cb73eb034f3)

Change-Id: I3e7595f437db4828072589d475a5453b7f31003e
d4c4d953035d4418126d36517e402f411d6a87f3 17-Oct-2014 Ian Rogers <irogers@google.com> Some code clean-up.

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

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

Change-Id: I5f4b49e88c3b02a79f9bee04f83395146ed7be23
c5ef693b3fec328c6f4a566d572c36f6587a6ab1 16-Oct-2014 Piotr Jastrzebski <haaawk@google.com> Stop using |instance_| in Runtime::InitNativeMethods.

Runtime::InitNativeMethods is a member function so we
don't need to use |instance_| to call Runtime methods there.

I believe that this call uses |instance_| instead of |this|
because it was originally in a static Runtime::Create method.
It was originally called 'instance_->InitLibraries();' and was
moved to Runtime::Start which is a member function here:
http://ag/#/c/133053/6/src/runtime.cc
and since then it was further moved and renamed but it kept using |instance_|
even though use of |this| seems more appropriate.

Change-Id: I79b9d23873272ba2f124e285602f1b2683c2f27f
c54e12a413e16f90526318f1f466a900a717fbb0 15-Oct-2014 Mathieu Chartier <mathieuc@google.com> Change MemMap::maps_ to not be global variable

Runtime.exit() was causing globals to get destructed at the same time
that another thread was using it for allocating a new mem map.

(cherry picked from commit 6e88ef6b604a7a945a466784580c42e6554c1289)

Bug: 17962201
Change-Id: I400cb7b8141d858f3c08a6fe59a02838c04c6962
6e88ef6b604a7a945a466784580c42e6554c1289 15-Oct-2014 Mathieu Chartier <mathieuc@google.com> Change MemMap::maps_ to not be global variable

Runtime.exit() was causing globals to get destructed at the same time
that another thread was using it for allocating a new mem map.

Bug: 17962201
Change-Id: I400cb7b8141d858f3c08a6fe59a02838c04c6962
a4fee49a5023a3cf8431597950ee87c711d0b81c 16-Sep-2014 Dave Allison <dallison@google.com> Don't call dlsym from signal context in signal chain

It is dangerous to call dlsym from within a signal context
since it takes a lock and can lead to a mutex reentry attempt if
timing is bad.

This change adds an initialization function to the signal chain
that calls dlsym for sigaction and sigprocmask from outside the
signal context (from Runtime::Init()). The results are cached
in a static variable and used from within the signal context if
necessary.

However, tests don't necessarily call Runtime::Init() so we also
need to deal with the case where the signal chain is not initialized
and perform a lazy initialization from inside sigaction or sigprocmask.
This is always outside a signal context since we have not initialized
the runtime.

Bug: 17498571, 17896006

(cherry picked from commit cefcea838729287a04174664a76514dd793dd77d)

Change-Id: I9bf8540a1250eadf977ff9af249dbe1c73b5ac63
b57f1c70a58aabef3246d19174df0dcbdb25b779 08-Oct-2014 Brian Carlstrom <bdc@google.com> Disable kEnableJavaStackTraceHandler

Bug: 17890306

(cherry picked from commit b6404fe0bb782cbbccda88903901fe0096a741d5)

Change-Id: Ie13d6af1d384c6ebf87e8f055120609e2bff3338
b6404fe0bb782cbbccda88903901fe0096a741d5 08-Oct-2014 Brian Carlstrom <bdc@google.com> Disable kEnableJavaStackTraceHandler

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

Bug: 17679443

(cherry picked from commit 95a935415d44903b28326424beb4db5c013ef089)

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

Bug: 17679443
Change-Id: I127ffdac3bfe731e9535dfe6a242eb950363d715
6d031046eeb5e9f62b657df0695b752e1d0aa583 10-Sep-2014 jgu21 <jinghui.gu@intel.com> ART: Update for split native bridge initialization

(cherry picked from commit a6da74e941d7cee498ac3880018a1d8dc953c6eb)
(cherry picked from commit 7a536531791293441253cffb6e370ba1150eee96)

Bug: 17671501
Change-Id: Id948e3ab22ac988d96f5d370bba8c3f86d08abff
9ef78b59da51080882e47505896b420977fd79ae 26-Sep-2014 Mathieu Chartier <mathieuc@google.com> Fix broken runtime SetStatsEnabled logic

Previously, Runtime::SetStatsEnabled wouldn't take stats_enabled_
into account when deciding whether or not to increment / decrement
teh stats enabled counter. This resulted in counter underflows and
other errors which caused some CTS tests to fail.

Also added some locking to prevent race conditions.

Bug: 17360878

(cherry picked from commit a98ffd745bbecb2e84a492194950c0b94966546b)

Change-Id: I21d241a58d35bd6a607aa2305c6da81720bd0886
a98ffd745bbecb2e84a492194950c0b94966546b 26-Sep-2014 Mathieu Chartier <mathieuc@google.com> Fix broken runtime SetStatsEnabled logic

Previously, Runtime::SetStatsEnabled wouldn't take stats_enabled_
into account when deciding whether or not to increment / decrement
teh stats enabled counter. This resulted in counter underflows and
other errors which caused some CTS tests to fail.

Also added some locking to prevent race conditions.

Bug: 17360878

Change-Id: I779237d55dda4f35054a4d27fb2c660a38750fc0
a6da74e941d7cee498ac3880018a1d8dc953c6eb 10-Sep-2014 jgu21 <jinghui.gu@intel.com> ART: Update for split native bridge initialization

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

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

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

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

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

Bug: 16214885

Change-Id: Iff7b7415efdbdabd7e6020e221a540f6a774c852
69dbec6d9d55eeb2867949c2791d01dc9aa916c8 16-Sep-2014 Jeff Hao <jeffhao@google.com> Avoid suspending for alloc trace enabling when already suspended.

Bug: 17499772

(cherry picked from commit 1d6ee090fddd4bfd35c304d6ceb929d5c529dfcc)

Change-Id: Id09809c476c685f0a197ee75bb08638931364efd
2dbe627954fd78a3659ab3cd42d2ead5b4529441 16-Sep-2014 Mathieu Chartier <mathieuc@google.com> Add runtime options for large object space

Adds the two following options:
Option -XX:LargeObjectSpace={freelist, map, disabled}
Option -XX:LargeObjectThreshold=size specifies the size for which
primitive arrays are allocated in the large object space.

Added handling for large object space == null in collectors.

Fixed an error in the mem map space where we didn't use the page
aligned size LOS for bytes allocated, this resutled in heaps appearing
a bit smaller than they should be.

Change-Id: I6f17c3534b59e7dc68cd375153e7a846799b3da4
1d6ee090fddd4bfd35c304d6ceb929d5c529dfcc 16-Sep-2014 Jeff Hao <jeffhao@google.com> Avoid suspending for alloc trace enabling when already suspended.

Bug: 17499772
Change-Id: Id98c10967b28e8859e5ac46f5878c304fb85c498
cefcea838729287a04174664a76514dd793dd77d 16-Sep-2014 Dave Allison <dallison@google.com> Don't call dlsym from signal context in signal chain

It is dangerous to call dlsym from within a signal context
since it takes a lock and can lead to a mutex reentry attempt if
timing is bad.

This change adds an initialization function to the signal chain
that calls dlsym for sigaction and sigprocmask from outside the
signal context (from Runtime::Init()). The results are cached
in a static variable and used from within the signal context if
necessary.

However, tests don't necessarily call Runtime::Init() so we also
need to deal with the case where the signal chain is not initialized
and perform a lazy initialization from inside sigaction or sigprocmask.
This is always outside a signal context since we have not initialized
the runtime.

Bug: 17498571
Change-Id: I59eebfc67cc91c6f1d781a73e5d432ca5269ee48
a5a53efea976af505f4f849b5925d5e14c4f8e5c 12-Sep-2014 Mathieu Chartier <mathieuc@google.com> Add native support for FinalizerList.makeCircularListIfUnenqueued

Called from FinalizerReference.enqueueSentinelReference to prevent
a race where the GC updates pendingNext of the sentinel reference
before enqueueSentinelReference.

Bug: 17462553

(cherry picked from commit 3256166df40981f1f1997a5f00303712277c963f)

Change-Id: I7ad2fd250c2715d1aeb919bd548ef9aab24f30a2
3256166df40981f1f1997a5f00303712277c963f 12-Sep-2014 Mathieu Chartier <mathieuc@google.com> Add native support for FinalizerList.makeCircularListIfUnenqueued

Called from FinalizerReference.enqueueSentinelReference to prevent
a race where the GC updates pendingNext of the sentinel reference
before enqueueSentinelReference.

Bug: 17462553

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

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

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

(cherry picked from commit 6167864e28e4e12658ebdbaf1d5239acdaf4aaa4)

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

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

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

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

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

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

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

Change-Id: Id59ce3cc520701c6ecf612f7152498107bc40684
928f72bd75c385ba2708c58521171a77264d4486 10-Sep-2014 Andreas Gampe <agampe@google.com> ART: Fix things for valgrind

Wire up valgrind gtests. Add valgrind-test-art-host, currently
only depending on valgrind-test-art-host-gtest32.

Fix an Alloc setting to allow running valgrind.

Refactor the fault handler to manage (and correctly release) the
handlers.

Fix minor failure-case leaks exposed by tests.

Failing tests:

The optimizing compiler is leaking non-arena-ed structures
(e.g., assembler buffers), as code generators are not destroyed.
The solution has been moved to a follow-up CL.

Note: All 64b tests are failing as we cannot allocate a heap.

Change-Id: I7f854cfd098d9f68107ce492363e7dba9a82b9fa
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
aa4497db59f1eeec954f2ba5da6d458fcdf9b3a4 05-Sep-2014 Vladimir Marko <vmarko@google.com> Improve dex location canonicalization-related performance.

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

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

Avoid some unnecessary duplicate OatDexFile lookups.

Bug: 16828525
Bug: 17346103
Change-Id: Id8fbc8992f62996138eb2006a0046c6529747c09
8a74117cac720239a69e60e734c7044b433fad47 08-Sep-2014 Hiroshi Yamauchi <yamauchi@google.com> Address read barrier issue with cl/106467

And tidy/add a check.

Bug: 12687968
Change-Id: If63dc0d9d0a0ce5f2eeb81734ff8f4307865f67d
13e3c6dd64ef3ca350356128d3a3e2fdd57513ee 03-Sep-2014 Andreas Gampe <agampe@google.com> ART: Change ART for new native bridge sequence

Initialize or unload after a fork.

(cherry picked from commit 6be67eeedbe60afce42300ae3e7f0e7180a96efa)

Change-Id: I5a20de1cb68dd1802937b369b14c50c9c1031c67
6be67eeedbe60afce42300ae3e7f0e7180a96efa 03-Sep-2014 Andreas Gampe <agampe@google.com> ART: Change ART for new native bridge sequence

Initialize or unload after a fork.

Change-Id: I5a20de1cb68dd1802937b369b14c50c9c1031c67
c0542af3e2170143ba40d89136e284997e16bf64 04-Sep-2014 Ian Rogers <irogers@google.com> Remove abuse of mirror::Object* to reference special values.

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

Change-Id: I3ce8a28c01827e163f4dc288449959464da788b1
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)
63557459a4098294a9ff44d035241de2966047c0 05-Jun-2014 Ian Rogers <irogers@google.com> Pre-allocate the NoClassDefFoundError to be thrown for boot classes.

Bring over a Dalvik "optimization".
Bug: 12804658
Bug: 16853450
Change-Id: I6419de7bd2ba18d91479cb52489104954f5c4524
cdfd39f579574a75b98e7ad48c69826b00361b27 30-Aug-2014 Mathieu Chartier <mathieuc@google.com> Change intern table to unordered set.

Intern table active used bytes goes from 430k to 317k on system
server. Similar %wise savings on other apps.

Bug: 16238192

(cherry picked from commit d910fcef539e12ab181e56ec80684f39c4e95733)

Change-Id: Ic70395124435c6f420a77e6d8639404a160f395a
d910fcef539e12ab181e56ec80684f39c4e95733 30-Aug-2014 Mathieu Chartier <mathieuc@google.com> Change intern table to unordered set.

Intern table active used bytes goes from 430k to 317k on system
server. Similar %wise savings on other apps.

Bug: 16238192

Change-Id: I92de72de3eae0b76629e9da83db2c2d0fa613052
bad0267eaab9d6a522d05469ff90501deefdb88b 25-Aug-2014 Mathieu Chartier <mathieuc@google.com> Add native memory accounting through custom allocator.

Added a custom allocator that lets you pass in a special tag which
specifices where the allocation came from. This is used when
dumping. The performance overhead is low since each allocation only
does a atomic add/sub for each allocation/free.

The measurements are dumped to traces.txt during SIGQUIT.

Example output:
I/art (27274): AllocatorTagHeap active=120 max=120 total=168
I/art (27274): AllocatorTagMonitorList active=1572 max=6240 total=11724
I/art (27274): AllocatorTagClassTable active=185208 max=185208 total=268608
I/art (27274): AllocatorTagInternTable active=430368 max=430368 total=436080
I/art (27274): AllocatorTagMaps active=5616 max=6168 total=34392
I/art (27274): AllocatorTagLOS active=1024 max=1536 total=2044
I/art (27274): AllocatorTagSafeMap active=0 max=51936 total=533688
I/art (27274): AllocatorTagLOSMaps active=144 max=1248 total=5760
I/art (27274): AllocatorTagReferenceTable active=10944 max=11840 total=19136
I/art (27274): AllocatorTagHeapBitmap active=32 max=40 total=56
I/art (27274): AllocatorTagHeapBitmapLOS active=8 max=8 total=8
I/art (27274): AllocatorTagVerifier active=0 max=18844 total=1073156
I/art (27274): AllocatorTagModUnionCardSet active=5300 max=5920 total=56020
I/art (27274): AllocatorTagModUnionReferenceArray active=24864 max=24864 total=24864
I/art (27274): AllocatorTagJNILibrarires active=320 max=320 total=320
I/art (27274): AllocatorTagOatFile active=1400 max=1400 total=5852

Change-Id: Ibb470ef2e9c9a24563bb46422d46a55799704d82

(cherry picked from commit 5369c40f75fdcb1be7a7c06db212ce965c83a164)
5369c40f75fdcb1be7a7c06db212ce965c83a164 25-Aug-2014 Mathieu Chartier <mathieuc@google.com> Add native memory accounting through custom allocator.

Added a custom allocator that lets you pass in a special tag which
specifices where the allocation came from. This is used when
dumping. The performance overhead is low since each allocation only
does a atomic add/sub for each allocation/free.

The measurements are dumped to traces.txt during SIGQUIT.

Example output:
I/art (27274): AllocatorTagHeap active=120 max=120 total=168
I/art (27274): AllocatorTagMonitorList active=1572 max=6240 total=11724
I/art (27274): AllocatorTagClassTable active=185208 max=185208 total=268608
I/art (27274): AllocatorTagInternTable active=430368 max=430368 total=436080
I/art (27274): AllocatorTagMaps active=5616 max=6168 total=34392
I/art (27274): AllocatorTagLOS active=1024 max=1536 total=2044
I/art (27274): AllocatorTagSafeMap active=0 max=51936 total=533688
I/art (27274): AllocatorTagLOSMaps active=144 max=1248 total=5760
I/art (27274): AllocatorTagReferenceTable active=10944 max=11840 total=19136
I/art (27274): AllocatorTagHeapBitmap active=32 max=40 total=56
I/art (27274): AllocatorTagHeapBitmapLOS active=8 max=8 total=8
I/art (27274): AllocatorTagVerifier active=0 max=18844 total=1073156
I/art (27274): AllocatorTagModUnionCardSet active=5300 max=5920 total=56020
I/art (27274): AllocatorTagModUnionReferenceArray active=24864 max=24864 total=24864
I/art (27274): AllocatorTagJNILibrarires active=320 max=320 total=320
I/art (27274): AllocatorTagOatFile active=1400 max=1400 total=5852

Bug: 16238192

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

Bug: 17000769

(cherry picked from commit 84d7605f93f1e6e86a16e02017e305c90e93117a)

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

Bug: 17000769

Change-Id: I89c26a905af12ea288742368c2c038afd57a879a
37f05ef45e0393de812d51261dc293240c17294d 17-Jul-2014 Fred Shih <ffred@google.com> Reduced memory usage of primitive fields smaller than 4-bytes

Reduced memory used by byte and boolean fields from 4 bytes down to a
single byte and shorts and chars down to two bytes. Fields are now
arranged as Reference followed by decreasing component sizes, with
fields shuffled forward as needed.

Bug: 8135266
Change-Id: I65eaf31ed27e5bd5ba0c7d4606454b720b074752
507e6180ad271eb719c67ce7394852c731d975a5 19-Aug-2014 Alex Light <allight@google.com> Support running without a boot image.

Bug: 17000769

(cherry picked from commit 64ad14dbe2225441fb7734bf6d89358d96692eea)

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

Bug: 17000769

Change-Id: I6404d5050c8a2f4ee6e70d58532eb25ee9de248e
6a7824dc81aaab3cb09ced16affca72d1b1da649 22-Aug-2014 Mathieu Chartier <mathieuc@google.com> Add fallback for non moving space being full.

When the non moving space becomes full, we disable moving GC and
make the main space the new non moving space.

Also added a runtime option for changing the non moving space size:
-XX:NonMovingSpaceCapacity.

Bug: 17189964

(cherry picked from commit 4c5a469683e433f126c9863cd393747d2e7c4a29)

Change-Id: If82e3c6f8a0f389e37e14a0b1e6d5126d571fd7a
4c5a469683e433f126c9863cd393747d2e7c4a29 22-Aug-2014 Mathieu Chartier <mathieuc@google.com> Add fallback for non moving space being full.

When the non moving space becomes full, we disable moving GC and
make the main space the new non moving space.

Also added a runtime option for changing the non moving space size:
-XX:NonMovingSpaceCapacity.

Bug: 17189964
Change-Id: I04d00d0f457f6c1f5724bf32932b6b6ce4d341b1
a68629ed992e2eef7b139b09e46ebe8fd3fb5ef2 22-Aug-2014 Calin Juravle <calin@google.com> Always setup the native bridge library

... even if the string is empty. This will initialize the native bridge
library but mark it as unavailable.

- also, rename native_bridge_library_path to
native_bridge_library_filename to be closer to the actual meaning (it's
just the filename without any path).

Bug: 16404669

(cherry picked from commit I94628639691459d48d1fbf0841f36b68d51818e7)

Change-Id: I94628639691459d48d1fbf0841f36b68d51818e7
ccdd4a5be1db2588767ed230b7064e5fe802ce8d 22-Aug-2014 Calin Juravle <calin@google.com> Always setup the native bridge library

... even if the string is empty. This will initialize the native bridge
library but mark it as unavailable.

- also, rename native_bridge_library_path to
native_bridge_library_filename to be closer to the actual meaning (it's
just the filename without any path).

Bug: 16404669.
Change-Id: I94628639691459d48d1fbf0841f36b68d51818e7
1f8ef6fa2fb5d79799371f8bf745824b78bc48f2 21-Aug-2014 Dave Allison <dallison@google.com> Fix fault handler to unregister on shutdown

This fixes a problem with the fault handler where it wasn't
unregistering itself during shutdown of the runtime.

Bug: 17133266

(cherry picked from commit e8b9afcd0cd86b8808af29a97332038aab70c604)

Change-Id: I1a4ec4292ec049046dda30769265680201729efb
e8b9afcd0cd86b8808af29a97332038aab70c604 21-Aug-2014 Dave Allison <dallison@google.com> Fix fault handler to unregister on shutdown

This fixes a problem with the fault handler where it wasn't
unregistering itself during shutdown of the runtime.

Bug: 17133266
Change-Id: If4758b14ded0fba194897191b1a8d8d7b0b3e6e5
3ea69c0abce1b81b3c45033867d49b00e6d6b709 19-Aug-2014 Brian Carlstrom <bdc@google.com> AttachCurrentThread should only warn on missing thread name if CheckJNI is enabled.

Bug: 17108693
Change-Id: I346cc090e091605c552e5954d7ea1ca4874cea5f
21ecab6effd08ed781d55fbb53b0e71c526c25fa 19-Aug-2014 Brian Carlstrom <bdc@google.com> AttachCurrentThread should only warn on missing thread name if CheckJNI is enabled.

Bug: 17108693

(cherry picked from commit 3ea69c0abce1b81b3c45033867d49b00e6d6b709)

Change-Id: Ide8158cc3e12e604f4fa344cd881fe6f68476ab7
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
93de4273d72a2558a7b3423547b5074cd76c5796 12-Aug-2014 Calin Juravle <calin@google.com> [ART] Move to system/core native bridge library

Some cleanups on the way:
- move NativeBridgeRuntimeCallbacks from a global to a field
- rename native_bridge_library_string to the more suggestive
navtive_bridge_library_path
- clean up imports

Bug: 16884833

(cherry picked from commit I73aab8e212860ba5aee9444d801806d3da326a41)

Change-Id: I67f037ea81d2a4ede4294afd8b84b7640e534a13
c8423521c1d1136c70b153479b7df3bf4fd7fc2a 12-Aug-2014 Calin Juravle <calin@google.com> [ART] Move to system/core native bridge library

Some cleanups on the way:
- move NativeBridgeRuntimeCallbacks from a global to a field
- rename native_bridge_library_string to the more suggestive
navtive_bridge_library_path
- clean up imports

Bug: 16884833
Change-Id: I73aab8e212860ba5aee9444d801806d3da326a41
20ae1d77463d1c3f206eac8d541124b4555464de 17-Jul-2014 Ian Rogers <irogers@google.com> Clean up native bridge

(partially cherry picked from commit
68d8b42ddec39ec0174162d90d4abaa004d1983e)

Change-Id: I85813e97d73b1b331646dd0e880108dfbfe80f69
b0f05b9654eb005bc8c8e15f615a7f5a312f640c 17-Jul-2014 Dave Allison <dallison@google.com> Add implicit checks for x86_64 architecture.

This combines the x86 and x86_64 fault handlers into one. It also
merges in the change to the entrypoints for X86_64.

Replaces generic instruction length calculator with one that only
works with the specific instructions we use.

Bug: 16256184

Change-Id: I1e8ab5ad43f46060de9597615b423c89a836035c
Signed-off-by: Chao-ying Fu <chao-ying.fu@intel.com>
4fcdc94d22a4608e355aa8df36240181149d10e8 22-Jul-2014 Nicolas Geoffray <ngeoffray@google.com> Execute an application even when dex2oat crashes.

Bug: 17000769

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

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

Change-Id: If7c6110b5aade7a402bfb67534af86a7b2cdeb55
7204c04dd86ae8ce05690e38737b2abf017a0a69 11-Jun-2014 Stuart Monteith <stuart.monteith@arm.com> AArch64: Implicit StackOverflow/NPE/Suspend checks.

This implements implicit stack overflow checks and null pointer exceptions
for AArch64. Suspend checks are implemented but not switched on yet.

Bug: 16256184
Change-Id: I2eb076f2c0c9d94793d5a898fea49cf409b4eb66
Signed-off-by: Stuart Monteith <stuart.monteith@arm.com>
dfd3b47813c14c5f1607cbe7b10a28b1b2f29cbc 17-Jul-2014 Dave Allison <dallison@google.com> Add implicit checks for x86_64 architecture.

This combines the x86 and x86_64 fault handlers into one. It also
merges in the change to the entrypoints for X86_64.

Replaces generic instruction length calculator with one that only
works with the specific instructions we use.

Bug: 16256184

Change-Id: I1e8ab5ad43f46060de9597615b423c89a836035c
Signed-off-by: Chao-ying Fu <chao-ying.fu@intel.com>
d5c78f44dc53ef9fda47a95ad3e9799be850c2b2 11-Jun-2014 Stuart Monteith <stuart.monteith@arm.com> AArch64: Implicit StackOverflow/NPE/Suspend checks.

This implements implicit stack overflow checks and null pointer exceptions
for AArch64. Suspend checks are implemented but not switched on yet.

Change-Id: I2eb076f2c0c9d94793d5a898fea49cf409b4eb66
Signed-off-by: Stuart Monteith <stuart.monteith@arm.com>
c7c6d18a90079b67a7592d3f2cb3d4c6f0081512 29-Jul-2014 Jeff Hao <jeffhao@google.com> Stop thread from reattaching during runtime shutdown while tracing.

Bug: 16024763

(cherry picked from commit c5d824a20c225763761a6dff43294b229ff35469)

Change-Id: Ideab9adedabf3c58f5162e43e79c72af0642bdfa
82558acbca3eae5b7e47748bcfb8070855266676 30-Jul-2014 Jeff Hao <jeffhao@google.com> Submitted wrong changelist!

Revert "Stop thread from reattaching during runtime shutdown while tracing."

This reverts commit c96657c4243e04888d5948fa023d78cc9213800b.

Change-Id: I859347f93704a94d23f72ef7d483298b08bbed0d
c96657c4243e04888d5948fa023d78cc9213800b 29-Jul-2014 Jeff Hao <jeffhao@google.com> Stop thread from reattaching during runtime shutdown while tracing.

Bug: 16024763

(cherry picked from commit c5d824a20c225763761a6dff43294b229ff35469)

Change-Id: Id5dcd4c8a131b93de00023c3ae9f518ea182614a
c5d824a20c225763761a6dff43294b229ff35469 29-Jul-2014 Jeff Hao <jeffhao@google.com> Stop thread from reattaching during runtime shutdown while tracing.

Bug: 16024763
Change-Id: Iad5ba180241ff74b15baf5c3a15ed2d2ed60fcf0
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
855564b83db7b106d2995d0e784f1f4b62e52371 25-Jul-2014 Andreas Gampe <agampe@google.com> ART: Native bridge command-line parameter

Add a command-line parameter for the native bridge library, slight
refactor/cleanup.

Add run-test 115 to test the native bridge interface. Currently the
tests are black-listed for the target, as the setup for the test
is too complicated in the current infrastructure.

Change-Id: I6ccf19485e8c30b96e9f2fd5425278cb1ebd403f
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
147eb41b53729ec8d5c188d1cac90964a51afb8a 11-Jul-2014 Dave Allison <dallison@google.com> Revert "Revert "Revert "Revert "Add implicit null and stack checks for x86""""

This reverts commit 0025a86411145eb7cd4971f9234fc21c7b4aced1.

Bug: 16256184
Change-Id: Ie0760a0c293aa3b62e2885398a8c512b7a946a73

Conflicts:
compiler/dex/quick/arm64/target_arm64.cc
compiler/image_test.cc
runtime/fault_handler.cc
535a3fbc08e1577f43aec7402cab80c14ca64c41 22-Jul-2014 Nicolas Geoffray <ngeoffray@google.com> Interpreter can kick in even when implicit checks are enabled.

Add a GetStackEndForInterpreter for its stack overfow check.

Change-Id: I2d4fc229a8eb727fda509ff778e16d60d96ecc28
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
69dfe51b684dd9d510dbcb63295fe180f998efde 11-Jul-2014 Dave Allison <dallison@google.com> Revert "Revert "Revert "Revert "Add implicit null and stack checks for x86""""

This reverts commit 0025a86411145eb7cd4971f9234fc21c7b4aced1.

Bug: 16256184
Change-Id: Ie0760a0c293aa3b62e2885398a8c512b7a946a73
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
e63db27db913f1a88e2095a1ee8239b2bb9124e8 16-Jul-2014 Ian Rogers <irogers@google.com> Break apart header files.

Create libart-gtest for common runtime and compiler gtest routines.
Rename CompilerCallbacksImpl that is quick compiler specific.
Rename trace clock source constants to not use the overloaded profiler term.

Change-Id: I4aac4bdc7e7850c68335f81e59a390133b54e933
ab088118d33caafb00815ab72ac0fd7374169f64 14-Jul-2014 Hiroshi Yamauchi <yamauchi@google.com> Add read barriers for the roots in Runtime.

Bug: 12687968
Change-Id: If26518a8251702cfe4d5cd7d1f50e80e342704cf
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
f37a88b8e6db6c587fa449a12e40cb46be1689fc 10-Jul-2014 Zuo Wang <zuo.wang@intel.com> ART: Compacting ROS/DlMalloc spaces with semispace copy GC

Current semispace copy GC is mainly associated with bump pointer
spaces. Though it squeezes fragmentation most aggressively, an extra
copy is required to re-establish the data in the ROS/DlMalloc space to allow
CMS GCs to happen afterwards. As semispace copy GC is still stop-the-world,
this not only introduces unnecessary overheads but also longer response time.
Response time indicates the time duration between the start of transition
request and the start of transition animation, which may impact the user
experience.

Using semispace copy GC to compact the data in a ROS space to another ROS(or
DlMalloc space to another DlMalloc) space solves this problem. Although it
squeezes less fragmentation, CMS GCs can run immediately after the compaction.

We apply this algorithm in two cases:
1) Right before throwing an OOM if -XX:EnableHSpaceCompactForOOM is passed in
as true.
2) When app is switched to background if the -XX:BackgroundGC option has value
HSpaceCompact.

For case 1), OOMs are significantly delayed in the harmony GC stress test,
with compaction ratio up to 0.87. For case 2), compaction ratio around 0.5 is
observed in both built-in SMS and browser. Similar results have been obtained
on other apps as well.

Change-Id: Iad9eabc6d046659fda3535ae20f21bc31f89ded3
Signed-off-by: Wang, Zuo <zuo.wang@intel.com>
Signed-off-by: Chang, Yang <yang.chang@intel.com>
Signed-off-by: Lei Li <lei.l.li@intel.com>
Signed-off-by: Lin Zang <lin.zang@intel.com>
a9b870b73a155ce70c867d5b3f9758fab0b45f07 11-Jul-2014 Christopher Ferris <cferris@google.com> Revert "Add intrinsic for Reference.get()"

This reverts commit 460503b13bc894828a2d2d47d09e5534b3e91aa1.

Change-Id: Ie63f43049307e02e3b90f4e034abc9ea54ca4e24
7fb36ded9cd5b1d254b63b3091f35c1e6471b90e 10-Jul-2014 Dave Allison <dallison@google.com> Revert "Revert "Add implicit null and stack checks for x86""

Fixes x86_64 cross compile issue. Removes command line options
and property to set implicit checks - this is hard coded now.

This reverts commit 3d14eb620716e92c21c4d2c2d11a95be53319791.

Change-Id: I5404473b5aaf1a9c68b7181f5952cb174d93a90d
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
0025a86411145eb7cd4971f9234fc21c7b4aced1 11-Jul-2014 Nicolas Geoffray <ngeoffray@google.com> Revert "Revert "Revert "Add implicit null and stack checks for x86"""

Broke the build.

This reverts commit 7fb36ded9cd5b1d254b63b3091f35c1e6471b90e.

Change-Id: I9df0e7446ff0913a0e1276a558b2ccf6c8f4c949
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
34e826ccc80dc1cf7c4c045de6b7f8360d504ccf 29-May-2014 Dave Allison <dallison@google.com> Add implicit null and stack checks for x86

This adds compiler and runtime changes for x86
implicit checks. 32 bit only.

Both host and target are supported.
By default, on the host, the implicit checks are null pointer and
stack overflow. Suspend is implemented but not switched on.

Change-Id: I88a609e98d6bf32f283eaa4e6ec8bbf8dc1df78a
3d14eb620716e92c21c4d2c2d11a95be53319791 10-Jul-2014 Dave Allison <dallison@google.com> Revert "Add implicit null and stack checks for x86"

It breaks cross compilation with x86_64.

This reverts commit 34e826ccc80dc1cf7c4c045de6b7f8360d504ccf.

Change-Id: I34ba07821fc0a022fda33a7ae21850957bbec5e7
bae182cbc6adc8796154162a87fc54ae804e0469 17-Dec-2013 Sebastien Hertz <shertz@google.com> Fix method tracing from command-line

Transitions current thread to the new kWaitingForMethodTracingStart thread
state when starting method tracing.

Ensures there is a current thread when method tracing is stopped due to runtime
shutdown. If the current thread has been detached, we now re-attach it.
Note: we only do this if method tracing has been activated from command-line.

Fixes instrumentation when forcing interpreter mode (-Xint) with method tracing
enabled.

Removes unused parameter from UnsafeLogFatalForThreadSuspendAllTimeout.

Bug: https://code.google.com/p/android/issues/detail?id=72094
Bug: 11683397
Change-Id: I70f000fb46ddd95d6ad51ea0a8eee77697a045e9
0ec17d2ddb69d3f5c46ccad62e82c0ffd6219428 07-Jul-2014 Hiroshi Yamauchi <yamauchi@google.com> Remove Dbg::VisitRoots().

We replace the GC strong roots with JNI.

jdwp_test passes.

Bug: 12687968
Change-Id: I841f1aaa5dffa784ca25953a251600f70df273b2
4e14e721055eeeb42b06ad231bce930f3e1c1728 28-Jun-2014 Ian Rogers <irogers@google.com> Avoid segvs if LOG(FATAL) is called during runtime start-up.

Change-Id: I8b054d0ff2084411ab49ebba83799eb79da879f6
a93b0bb9abfbd19fc40ff8ced8818aec1a3464b9 10-Jun-2014 Wei Jin <wejin@google.com> Add an option to enable collecting dex pc in ART profiler

This CL allows the ART profiler to collect both method signature and
dex pc. The type of the profile data is controlled by the option
"-Xprofile-type:{method,dexpc}". To avoid conflicting with the
original profile data based on method signatures, the new profile
data are stored in files with extension ".pc".

Change-Id: I8afb2541d386bff77c5b07fc9367d817a79f58e1
4eb1331f912d6c3614bd65845fa046fc8d3300d8 13-Jun-2014 Dave Allison <dallison@google.com> Don't use signal handlers in interpreter only mode

Bug: 15543631

Change-Id: I8f251b5a66487dce3ac3127bdf3b5bc824d0e4bc
b5a9e3d1cc1fd66683e43e365afc8c900e2800c4 09-Jun-2014 Hiroshi Yamauchi <yamauchi@google.com> Remove Object* weak roots from the debugger.

The weak roots were converted to JNI weak refs.

Since the weak roots are now normal JNI weak refs, we eliminate the
need to insert read barriers for those weak roots in the debugger and
the need for the GC to have a separate step to update them as part of
the system weak sweeping.

Bug: 12687968
Change-Id: If16396d4713457b8af4f1ea6a0c6ec6799cb615e
c5f17732d8144491c642776b6b48c85dfadf4b52 06-Jun-2014 Ian Rogers <irogers@google.com> Remove deprecated WITH_HOST_DALVIK.

Bug: 13751317
Fix the Mac build:
- disable x86 selector removal that causes OS/X 10.9 kernel panics,
- madvise don't need does zero memory on the Mac, factor into MemMap
routine,
- switch to the elf.h in elfutils to avoid Linux kernel dependencies,
- we can't rely on exclusive_owner_ being available from other pthread
libraries so maintain our own when futexes aren't available (we
can't rely on the OS/X 10.8 hack any more),
- fix symbol naming in assembly code,
- work around C library differences,
- disable backtrace in DumpNativeStack to avoid a broken libbacktrace
dependency,
- disable main thread signal handling logic,
- align the stack in stub_test,
- use $(HOST_SHLIB_SUFFIX) rather than .so in host make file variables.

Not all host tests are passing on the Mac with this change. dex2oat
works as does running HelloWorld.
Change-Id: I5a232aedfb2028524d49daa6397a8e60f3ee40d3
576ca0cd692c0b6ae70e776de91015b8ff000a08 07-Jun-2014 Ian Rogers <irogers@google.com> Reduce header files including header files.

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

Change-Id: I8d13dce8512816db2820a27b24f5866cc871a04b
c1b643cc6ac45dbd0eabdcd7425c7e86006c27d6 31-May-2014 Calin Juravle <calin@google.com> Fixed and refactored profiler options handling

- extracted profiler options in a separate class
- switched from system property reading to command line arguments
- added profile based compilation options to CompilerOptions
- removed no longer used kProfile compilation filter
- optimize dex files only if the profiler is enabled
- clean up unused arguments

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

Merge ART from AOSP to lmp-preview-dev.

Change-Id: I0f578733a4b8756fd780d4a052ad69b746f687a9
f00571c4e1ae202b3b4acb6b47cbe23a65178f7f 30-May-2014 Jeff Hao <jeffhao@google.com> Added workaround passing empty arg array for proxy invocation.

This recreates old Dalvik behavior for older target sdk versions,
but will still pass null for newer ones.

Bug: 13247236

(cherry picked from commit 01d5a146e20660bd06f026c16f19ec080f8fdd7b)

Change-Id: I911889cf559ad8d9f37ea9be3929387c86446851
01d5a146e20660bd06f026c16f19ec080f8fdd7b 30-May-2014 Jeff Hao <jeffhao@google.com> Added workaround passing empty arg array for proxy invocation.

This recreates old Dalvik behavior for older target sdk versions,
but will still pass null for newer ones.

Bug: 13247236

Change-Id: I663c44f729dd173b47da692a753b986daa0463e9
f4b80bcc7190fe75023b983d56a795b440a0c515 15-May-2014 Dave Allison <dallison@google.com> Make use of sigchainlib for signal chaining for implicit checks

This adds a preload library that overrides sigaction and sigprocmask
to implement signal chaining. Signal chaining allows us to chain
any signal so that the ART runtime receives it before any signal
handler registered in native code by an application. If the
ART signal handler doesn't want it, it will pass it on to the
user's handler.

ART uses signals for null pointer checks, stack overflow checks and
suspend points.

Also adds an OAT test to test this in isolation.

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

Change-Id: I973da5e74be5a62461caacbc708288fb95e1b99b
6a58691356979164249c63cb3f98f5dbd75cc4bb 22-May-2014 Wei Jin <wejin@google.com> Fix the problem of not shutting down the profiler in ART properly

This CL fixes the problem of not saving the last batch of profile data to the
external file when the runtime exits before the end of the current iteration of
profile sampling. This problem was fixed by shutting down the ART profiler
when the runtime exits and allowing the profiler to write the last batch of
data even it was signaled to shut down. This CL increases the precision of
profile data and fixes the bug that no data is saved if the duration of profile
sampling specified by VM arguments (by default 20 seconds) is longer than the
length of a single execution because the profiler was never signaled when the
runtime exits.

Change-Id: I7cc4805b7e2a22a990d04a5b9724ad1d931d7152
Signed-off-by: Wei Jin <wejin@google.com>
bd0fb61e24270b1f382ecbef4c1260c703550e84 20-May-2014 Hiroshi Yamauchi <yamauchi@google.com> Simplify Class::IsArtFieldClass().

Fix the slight glitch that when ImageSpace::VerifyImageAllocations()
called in ImageSpace::Create(), the ArtField and ArtMethod class roots
weren't set, which were used by DCHECKs in Object::Size(), which
VerifyImageAllocations() calls, by delaying the point of the
VerifyImageAllocations() call to Runtime::Init() at which point the
class linker has set the class roots.

To completely disable read barriers from Object::SizeOf(), the
ReadBarrierOption template parameter should have been added to
Class::GetInstanceField(), which calls GetFieldObject(), when it's
called from Class::IsArtFieldClass(). This change fixes this by
removing the need for the call, instead of adding the
ReadBarrierOption parameter.

Bug: 12687968
Change-Id: Ibbecc08f4e3b898851805d690dff8ccac55e94f2
35aef2ce9d9cbfb37e9b2f6776afce3caed37063 19-May-2014 Yevgeny Rouban <yevgeny.y.rouban@intel.com> Fix race condition between GCDaemon and DeleteLocalReference

There is a race condition between the GCDaemon visiting
thread local roots starting from the thread's indirect ref table (IRT)
and another thread calling JNI::DeleteLocalReference, which is clearing
one of the indirect references.

To cope with the race condition the DeleteLocalReference used to transit
from suspended to running state by creating a ScopedObjectReference(env).
But this transition was removed with the following patch:
https://android.googlesource.com/platform/art/+/ef28b14268ed0f9db0c7bbd571aa514354a360bd%5E!/#F0

If so the GCDaemon must be careful to work with IRT entries.

This new patch:
1. calls the visitor only if the reference is not null. This if-null
behavior of ART GC is consistent with what Dalvik GC does.
2. But this might be not enough for some future sophisticated GC algorithms.
For example, if GC moves an object, then the IRT entry must be changed
with CAS only if it has not been cleared. So, for the safety reasons
the patch put backs the ScopedObjectReference soa(env) to
DeleteLocalReference.

Only one of those two changes would be enough.

mathieuc note: I decided to delete the root null check but kept the
ScopedObjectAccess in DeleteLocalRef and added missing annotations as
well as more ScopedObjectAccess in jni internals.

Bug: 14626564

Change-Id: I90d4b8494f61404579ecdd2918d1482093d99387
Signed-off-by: Yevgeny Rouban <yevgeny.y.rouban@intel.com>
Signed-off-by: Yang Chang <yang.chang@intel.com>
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
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
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
b9beb2e2efb6a204a69ca660d478b45f851e8f09 10-May-2014 Ian Rogers <irogers@google.com> Place ISA into boot image name.

Depends upon:
https://android-review.googlesource.com/94078

Change-Id: I22c18b03b2c0db7a3f792920064e7710363b58b4
37eecbde9ab8432c2d047a1524d0ea14f88b94bb 11-May-2014 Ian Rogers <irogers@google.com> Dump the native stack of an unattached aborting thread.

Useful when diagnosing errors in threads that have yet to become attached.

Change-Id: Id50b96d12f8c2e8a29e0606d15009287a554aa64
ca1da7aac327bc336f66b05c183d32ff48b4508f 09-May-2014 Dave Allison <dallison@google.com> Revert "Switch on implicit null pointer and stack overflow checks."

This seems to break facebook

This reverts commit 052664322767de1799f060c306e729b0e73ce893.

Change-Id: I6c8dabdc2519c0925ffde41975878f821e3933de
ad9697a91d5acdc772ae6c0461540bfec358a070 09-May-2014 Dave Allison <dallison@google.com> Revert "Switch on implicit null pointer and stack overflow checks."

This seems to break facebook

This reverts commit 052664322767de1799f060c306e729b0e73ce893.

Change-Id: I6c8dabdc2519c0925ffde41975878f821e3933de
119c6bd97f7ac24b64eaf4e9333abb44acbf780f 09-May-2014 Mathieu Chartier <mathieuc@google.com> Fix stub_test to pass with SS collector.

Changed the test to access the allocation entrypoints from the thread.

Change the order roots are visited to prevent a rare error where the
java lang reflect art method would move before it was checked in
SanityCheckFrame.

Change-Id: Ifb96220f3fbb74ea5d720777f130450f04c0e044
4d466a8e4587422c989705dce3b2a19e7f0137f5 09-May-2014 Brian Carlstrom <bdc@google.com> Remove all LOG(DEBUG) which is not intended to be checked in

Bug: 14632493
Change-Id: Id9da8b87798af0a1b2bd2c178133e5f1ba47d43d
78f7b4c04ab6e8b5581921bc95b67a9beee1c246 06-May-2014 Mathieu Chartier <mathieuc@google.com> Add concurrent reference processing.

Concurrent reference processing currently works by going into native
code from java.lang.ref.Reference.get(). From there, we have a fast
path if the references aren't being processed which returns the
referent without needing to access any locks. In the slow path we
block until reference processing is complete. It may be possible to
improve the slow path if the referent is blackened.

TODO: Investigate doing the fast path in java code by using racy reads
of a static volatile boolean. This will work as long as there are no
suspend points inbetween the boolean read and referent read.

Bug: 14381653

Change-Id: I1546b55be4691fe4ff4aa6d857b234cce7187d87
052664322767de1799f060c306e729b0e73ce893 05-May-2014 Dave Allison <dallison@google.com> Switch on implicit null pointer and stack overflow checks.

This switches on the use of implicit checks for null pointers
and stack overflows. These use the SIGSEGV handler in the ART
runtime to detect these conditions and throw the appropriate
exceptions.

Change-Id: I4d27d4e976a58b18fb16a89572b1fb3798608449
89a201e599da95d88590c7b4d069b76735e20fa8 02-May-2014 Mathieu Chartier <mathieuc@google.com> Add GC cause to WaitForGcToComplete message.

Change-Id: I8fe107d90a84de065c407b8d29fd106267ac440d
8194963098247be6bca9cc4a54dbfa65c73e8ccc 02-May-2014 Vladimir Marko <vmarko@google.com> Replace CountOneBits and __builtin_popcount with POPCOUNT.

Clean up utils.h, make some functions constexpr.

Change-Id: I2399100280cbce81c3c4f5765f0680c1ddcb5883
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
6f365cc033654a5a3b45eaa1379d4b5f156b0cee 23-Apr-2014 Mathieu Chartier <mathieuc@google.com> Enable concurrent sweeping for non-concurrent GC.

Refactored the GarbageCollector to let all of the phases be run by
the collector's RunPhases virtual method. This lets the GC decide
which phases should be concurrent and reduces how much baked in GC
logic resides in GarbageCollector.

Enabled concurrent sweeping in the semi space and non concurrent
mark sweep GCs. Changed the semi-space collector to have a swap semi
spaces boolean which can be changed with a setter.

Fixed tests to pass with GSS collector, there was an error related to
the large object space limit.

Before (EvaluateAndApplyChanges):
GSS paused GC time 7.81s/7.81s, score: 3920

After (EvaluateAndApplyChanges):
GSS paused GC time 6.94s/7.71s, score: 3900

Benchmark score doesn't go up since the GC happens in the allocating
thread. There is a slight reduction in pause times experienced by
other threads (0.8s total).

Added options for pre sweeping GC heap verification and pre sweeping
rosalloc verification.

Bug: 14226004
Bug: 14250892
Bug: 14386356

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

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

Change-Id: I51199e6e2392da0354f64b157e79af494c183778
2f8da3e9ff60e5cb2a3fdf57dbcb67f513b9c2c2 16-Apr-2014 Mathieu Chartier <mathieuc@google.com> Decrease target utilization for foreground apps.

GC time in FormulaEvaluationActions.EvaluateAndApplyChanges goes from
26.1s to 23.2s. Benchmark score goes down ~50 in
FormulaEvaluationActions.EvaluateAndApplyChanges, and up ~50 in
GenericCalcActions.MemAllocTest.

Bug: 8788501
Change-Id: I412af1205f8b67e70a12237c990231ea62167bc0
c7a966dbba6902618ff0959d604c05d7570df8c8 11-Apr-2014 Mathieu Chartier <mathieuc@google.com> Prevent deadlocks in Runtime::Abort.

If we have the threads suspended, attempting to use a
ScopedObjectAccess causes a deadlock. We now specifically avoid this
to prevent deadlocks.

Bug: 13747880
Change-Id: I45fd3fff917da98b22970e5351a9e25b143a4eed
1659006728b929aa820d09bdaba58b462cc8e7cc 07-Apr-2014 Calin Juravle <calin@google.com> Profile: made startImmediately settable

By default the profiler starts immediately upon app startup. To delay the
startup by some random offset use -Xprofile-start_lazy.

Bug: 12877748
Change-Id: Ifc1bb7f79f9f9aa53204b2fb1fbae3cd5c780cac
242947dbcdc4038ddd8ac522bb480f82e7d92ffa 03-Apr-2014 Andreas Gampe <agampe@google.com> Make frame size dependent on arch-specific constants.

Necessary for proper cross-compiling.

Change-Id: I852901ee6ca5121e480b83a8e318bdc9c7d615e8
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
3de95a7b0a2d30cde6dc92b72c35df3a61002124 02-Apr-2014 Narayan Kamath <narayan@google.com> Runtime::PreZygoteFork returns void, not boolean.

This method aborts on failure (as it should) and unconditionally
returns true, so making it return void simplifies callers.

Change-Id: Iae39bd327f20311579ece47efa8afd1be7defce9
ee1d79a603c77c0667b27c075a983579d5c51f7e 21-Feb-2014 Sebastien Hertz <shertz@google.com> Cleanup transaction support

Updates Thread::CreateInternalStackTrace to support both transactional and
non-transactional modes using template.

Generalizes non-transactional mode for invariant fields (which are set only
once).

Removes ArrayLog::VisitRoots as we never create Array logs of ObjectArray. As
ObjectArray elements are set using Object::SetFieldObject, they are already
recorded in the object logs: the object is the array itself and the offset
corresponds to the element index in this array. And also checks we never log
ObjectArray in array logs.

Fixes location of thrown exception when calling native method during class
initialization.

Change-Id: Idbc368d3b8292b85ff40bc8a7c559e085477bf89
da44d773dedf8aae6153e3423012f236cba3bfcd 02-Apr-2014 Mathieu Chartier <mathieuc@google.com> Fix running with DlMalloc instead of RosAlloc.

Bug: 13748830
Bug: 13744490

Change-Id: Ieec97cf58ebf9864a40ee85aae582cdcf3f27c0c
c751fdcc9491c1b60c3db517fbc41bb98e92441f 31-Mar-2014 Mathieu Chartier <mathieuc@google.com> Add handler for printing java stack traces for compiled code SIGSEGV.

Added a new FaultHandler which attempts to print a java stack trace
when a SIGSEGV occurse in generated code. This should help debugging
compiler and GC related heap corruption.

Bug: 13725693
Bug: 12934910

Change-Id: Id54d83ea180c222eb86d449c61926e83f0b026ad
8b2c8b9642d5fe037f93ab0cb6a5065e2a192e40 31-Mar-2014 Narayan Kamath <narayan@google.com> Move most zygote related code to frameworks/base.

Avoids code duplication across art/dalvik. Also, most of
this code is not directly related to the runtime (mounting external
storage, multi user etc.) and therefore belongs in the frameworks.

Change-Id: Icf4723dd0ec4521ef6b1f785c99d50aebca7779a
dd7624d2b9e599d57762d12031b10b89defc9807 15-Mar-2014 Ian Rogers <irogers@google.com> Allow mixing of thread offsets between 32 and 64bit architectures.

Begin a more full implementation x86-64 REX prefixes.
Doesn't implement 64bit thread offset support for the JNI compiler.

Change-Id: If9af2f08a1833c21ddb4b4077f9b03add1a05147
3b05e9ba874449dbff65b01b8781001f7d93eea6 25-Mar-2014 Mathieu Chartier <mathieuc@google.com> Add missing debugger root visiting.

Bug: 13634574
Change-Id: I2a76f6c43f1d0ad1922f06deb40a71ff651129fd
6ed19fd1b08abbc438781ae3e6fea111c1f92315 20-Mar-2014 Ian Rogers <irogers@google.com> 64bit: make runtime offsets more deterministic.

STL implementations vary causing offsets not to be consistent. Place member
variables we care about the offsets of at the start of Runtime.

Change-Id: I3ad7fe606cb99bcdd884a8fdbdd06bd7e047cd84
b95a5345ae4217b70ca36f0cced92f68dda7caf5 12-Mar-2014 Stuart Monteith <stuart.monteith@arm.com> AArch64: Add arm64 runtime support.

Adds support for arm64 to ART. Assembler stubs are sufficient for
down calls into interpreter. JNI compiler and generics are not finished.

Basic Generic JNI functionality.

Change-Id: I4a07c79d1e037b9f5746673480e32cf456867b82
53b8b09fc80329539585dcf43657bc5f4ecefdff 14-Mar-2014 Ian Rogers <irogers@google.com> Refactor reflective method invocation.

Move invocation code out of JNI internal into reflection, including ArgArray
code. Make reflective invocation use the ArgArray to build arguments rather
than allocating a jvalue[] and unboxing arguments into that.
Move reflection part of jni_internal_test into reflection_test.
Make greater use of fast JNI.

Change-Id: Ib381372df5f9a83679e30e7275de24fa0e6b1057
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
39c3bfbd03d85c63cfbe69f17ce5800ccc7d6c13 29-Jan-2014 Dave Allison <dallison@google.com> Make use of profiling information for dex2oat

If the profile file exists, the compiler driver will read it
and store the data in an internal map. Then, when we want to work
out whether to compile a method or not, the map is consulted and if
the method shows up with a high enough percentage of use we compile it.

The profile file itself is created by installd and is writeable by the
app. The file is in /data/dalvik-cache/profiles and is named by
the package name.

This also modifies the profiler itself to:

1. Only count runnable threads (not suspended threads) in the profile
2. Use system properties to allow tuning of the profile parameters
3. Merge profiles from multiple processes using file locking.

Bug: 12877748
Change-Id: Iab2f3a327a2860db2a80d5724277d6c626227f2b

Conflicts:
compiler/dex/frontend.cc
compiler/dex/mir_analysis.cc
compiler/dex/verification_results.cc
compiler/driver/compiler_driver.cc
dex2oat/dex2oat.cc
runtime/class_linker.cc
runtime/runtime.cc
runtime/runtime.h
719d1a33f6569864f529e5a3fff59e7bca97aad0 06-Mar-2014 Ian Rogers <irogers@google.com> Enable annotalysis on clang ART builds.

Fix clang build errors aswell as restructure locking/mutex code for correct
thread safety analysis support.
Reorder make dependencies so that host builds build first as they should
provide better compilation errors than target.
Remove host's use of -fno-omit-frame-pointer as it has no value with correct
use of CFI, which we should have.

Change-Id: I72cea8da9a3757b1a0b3acb4081feccb7c6cef90
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
491ca9e75fad381468dd7f5fdbff56d1a9738dd7 03-Mar-2014 Brian Carlstrom <bdc@google.com> Add ART -help and -showversion

Bug: https://code.google.com/p/android/issues/detail?id=62149
Change-Id: I5c21c0433f5f341f94e7d977e8d2d69cc46d6fe3
15d3402bbf8265eb1165694da2e4117eb128f3bc 27-Feb-2014 Mathieu Chartier <mathieuc@google.com> Add custom SIGSEGV handler to help find heap corruption.

The new signal handler prints heap diagnostics when you get a SIGSEGV.
Added a fault message member in runtime which is modifiable by
Runtime::SetFaultMessage. When you get a SIGSEGV it will print out
whatever is stored in this string as well as the normal information.
This is useful for debugging heap corruption since it lets you see
which threads were in which methods when the last GC occured.

Added some smarter object dumping logic when the faulting address is
in the heap.

Bug: 12934910

Change-Id: Ia72be2c39f70ad711cbd746d66fad2b617d5d29f
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
936b37f3a7f224d990a36b2ec66782a4462180d6 14-Feb-2014 Ian Rogers <irogers@google.com> Upcall support for x86-64.

Sufficient to pass jni_internal_test.

Change-Id: Ia0d9b8241ab8450e04765b9c32eb6dc8fc1a8733
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
97f4489166ae31c12d35ad3f550a5fc8d143b4fa 15-Feb-2014 Ian Rogers <irogers@google.com> Revert "Revert "Revert "Add a script for running art standalone."""

This reverts commit 4b23250f4cbf3047924c646c1a0c078394f8362d.

Change-Id: Ib749a8267abf35e51552b741ba749d6ed6975f95
4b23250f4cbf3047924c646c1a0c078394f8362d 13-Feb-2014 Nicolas Geoffray <ngeoffray@google.com> Revert "Revert "Add a script for running art standalone.""

This reverts commit 41dcb9f856a2051527cd595f8fe7d200066acba4.

Change-Id: Ide6fa696c6fb43fe17e0993e8c9d1b588c99b1f3
41dcb9f856a2051527cd595f8fe7d200066acba4 12-Feb-2014 Brian Carlstrom <bdc@google.com> Revert "Add a script for running art standalone."

This reverts commit 1f5a90f28443886ebefcfbd531b8e41ece298cca.
1f5a90f28443886ebefcfbd531b8e41ece298cca 07-Feb-2014 Nicolas Geoffray <ngeoffray@google.com> Add a script for running art standalone.

Change-Id: I0c48856d811c40662a6e4a4782478a0bc8e0f697
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
412c7fced915fc8d4d5e4166e977d55c809168a6 07-Feb-2014 Mathieu Chartier <mathieuc@google.com> Make debugger / jdwp compaction safe.

Fixed GetInstances, GetReferringObjects, CountInstances to use
VisitObjects instead of the live bitmap.

We now treat the object registry as system weaks and update the
objects when/if they move. Also added the recent_allocation_records_
as roots.

Bug: 12936165

Change-Id: I615c289efbf2977ceab5c4ffa73d216d799e6e33
a4adbfd44032d70e166e6f18096bbbed05a990ba 05-Feb-2014 Hiroshi Yamauchi <yamauchi@google.com> RosAlloc verification.

If enabled, RosAlloc verification checks the allocator internal
metadata and invariants to detect bugs, heap corruptions, and race
conditions. Added runtime options for enabling and disabling
it. Enable it for the debug build.

Bug: 9986565
Bug: 12592026
Change-Id: I923742b87805ae839f1549d78d0d492733da6a58
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
055d46c479369ea825712834353660b45215c195 06-Feb-2014 Mathieu Chartier <mathieuc@google.com> Add missing SIRT to LoadNativeLibrary.

When we transition to kWaitingForJniOnLoad, we are suspended and
a GC can occur. This caused issues since classloaders are movable.

Change-Id: Iae59019c22ac64322a82300107d06a4323ee602b
6c2270be8d01a9cc3b691c49b43644545c2f4f33 29-Jan-2014 lzang1 <lin.zang@intel.com> Fix GC options to make the setting available

The concurrent gc thread number and parallel gc thread number is configurable by the options,
This patch fix the bug that making the options value valid.
This patch also fix that GC log threshold settings as MillionSecond.

Change-Id: I737838ef4af44396c23a538cd8a33581d9ae5e4d
Author: Lin Zang <lin.zang@intel.com>
Signed-off-by: Jack Ren <jack.ren@intel.com>
Signed-off-by: Bruce Beare <bruce.j.beare@intel.com>
be1ca55db3362f5b100c4c65da5342fd299520bb 15-Jan-2014 Hiroshi Yamauchi <yamauchi@google.com> Use direct class pointers at allocation sites in the compiled code.

- Rather than looking up a class from its type ID (and checking if
it's resolved/initialized, resolving/initializing if not), use
direct class pointers, if possible (boot-code-to-boot-class pointers
and app-code-to-boot-class pointers.)
- This results in a 1-2% speedup in Ritz MemAllocTest on Nexus 4.
- Embedding the object size (along with class pointers) caused a 1-2%
slowdown in MemAllocTest and isn't implemented in this change.
- TODO: do the same for array allocations.
- TODO: when/if an application gets its own image, implement
app-code-to-app-class pointers.
- Fix a -XX:gc bug.
cf. https://android-review.googlesource.com/79460/
- Add /tmp/android-data/dalvik-cache to the list of locations to
remove oat files in clean-oat-host.
cf. https://android-review.googlesource.com/79550
- Add back a dropped UNLIKELY in FindMethodFromCode().
cf. https://android-review.googlesource.com/74205

Bug: 9986565
Change-Id: I590b96bd21f7a7472f88e36752e675547559a5b1
938a03b3f196895e1fce2b862ae01039deca4c34 17-Jan-2014 Mathieu Chartier <mathieuc@google.com> Fix heap verification and add runtime options.

Post GC heap verification is now enabled by default for debug builds.
Added four Xgc runtime options: preverify, nopreverify, postverify,
nopostverify.

Fixed another bug where the non-moving space could theoretically end
up outside of the card table address range.

Bug: 10672951
Change-Id: I5ba3cd96dbfb900263dba795242df74c563deaa3
0f875ef27a4842d2e7c857b3c7eedbf8c8cf873f 15-Jan-2014 Mathieu Chartier <mathieuc@google.com> Revert accidental default collector type change.

Default collector type had been changed to generational semi-space
by default by accident.

Change-Id: I060b3f292261b8bb258ca2a350e26a328340c49c
6f4ffe41649f1e6381e8cda087ad3749206806e5 13-Jan-2014 Hiroshi Yamauchi <yamauchi@google.com> Improve the generational mode.

- Turn the compile-time flags for generational mode into a command
line flag.

- In the generational mode, always collect the whole heap, as opposed
to the bump pointer space only, if a collection is an explicit,
native allocation-triggered or last attempt one.

Change-Id: I7a14a707cc47e6e3aa4a3292db62533409f17563
e6da9af8dfe0a3e3fbc2be700554f6478380e7b9 16-Dec-2013 Mathieu Chartier <mathieuc@google.com> Background compaction support.

When the process state changes to a state which does not perceives
jank, we copy from the main free-list backed allocation space to
the bump pointer space and enable the semispace allocator.

When we transition back to foreground, we copy back to a free-list
backed space.

Create a seperate non-moving space which only holds non-movable
objects. This enables us to quickly wipe the current alloc space
(DlMalloc / RosAlloc) when we transition to background.

Added multiple alloc space support to the sticky mark sweep GC.

Added a -XX:BackgroundGC option which lets you specify
which GC to use for background apps. Passing in
-XX:BackgroundGC=SS makes the heap compact the heap for apps which
do not perceive jank.

Results:
Simple background foreground test:
0. Reboot phone, unlock.
1. Open browser, click on home.
2. Open calculator, click on home.
3. Open calendar, click on home.
4. Open camera, click on home.
5. Open clock, click on home.
6. adb shell dumpsys meminfo

PSS Normal ART:
Sample 1:
88468 kB: Dalvik
3188 kB: Dalvik Other
Sample 2:
81125 kB: Dalvik
3080 kB: Dalvik Other

PSS Dalvik:
Total PSS by category:
Sample 1:
81033 kB: Dalvik
27787 kB: Dalvik Other
Sample 2:
81901 kB: Dalvik
28869 kB: Dalvik Other

PSS ART + Background Compaction:
Sample 1:
71014 kB: Dalvik
1412 kB: Dalvik Other
Sample 2:
73859 kB: Dalvik
1400 kB: Dalvik Other

Dalvik other reduction can be explained by less deep allocation
stacks / less live bitmaps / less dirty cards.

TODO improvements: Recycle mem-maps which are unused in the current
state. Not hardcode 64 MB capacity of non movable space (avoid
returning linear alloc nightmares). Figure out ways to deal with low
virtual address memory problems.

Bug: 8981901

Change-Id: Ib235d03f45548ffc08a06b8ae57bf5bada49d6f3
0aded089f565008ba5908e395e5914ca4f91f2de 07-Nov-2013 Dave Allison <dallison@google.com> Add sampling profiler

This adds a sampling profiler thread that runs every so often, gathering
profiling data and writing the results to a file in /data/data (specific to
app running). The intention is to use these files as input to the compiler
so that it can determine the best methods to compile.

Bug: 11539952
Change-Id: I0bfbb4146fb7966673c792f017ffac8107b6272d
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
692fafd9778141fa6ef0048c9569abd7ee0253bf 30-Nov-2013 Mathieu Chartier <mathieuc@google.com> Thread local bump pointer allocator.

Added a thread local allocator to the heap, each thread has three
pointers which specify the thread local buffer: start, cur, and
end. When the remaining space in the thread local buffer isn't large
enough for the allocation, the allocator allocates a new thread
local buffer using the bump pointer allocator.

The bump pointer space had to be modified to accomodate thread
local buffers. These buffers are called "blocks", where a block
is a buffer which contains a set of adjacent objects. Blocks
aren't necessarily full and may have wasted memory towards the
end. Blocks have an 8 byte header which specifies their size and is
required for traversing bump pointer spaces.

Memory usage is in between full bump pointer and ROSAlloc since
madvised memory limits wasted ram to an average of 1/2 page per
block.

Added a runtime option -XX:UseTLAB which specifies whether or
not to use the thread local allocator. Its a NOP if the garbage
collector is not the semispace collector.

TODO: Smarter block accounting to prevent us reading objects until
we either hit the end of the block or GetClass() == null which
signifies that the block isn't 100% full. This would provide a
slight speedup to BumpPointerSpace::Walk.

Timings: -XX:HeapMinFree=4m -XX:HeapMaxFree=8m -Xmx48m
ritzperf memalloc:
Dalvik -Xgc:concurrent: 11678
Dalvik -Xgc:noconcurrent: 6697
-Xgc:MS: 5978
-Xgc:SS: 4271
-Xgc:CMS: 4150
-Xgc:SS -XX:UseTLAB: 3255

Bug: 9986565
Bug: 12042213

Change-Id: Ib7e1d4b199a8199f3b1de94b0a7b6e1730689cad
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
501668ae6b3c1546cd94cbce71bc2e9eb0d851b8 05-Dec-2013 Hiroshi Yamauchi <yamauchi@google.com> Fix a rosalloc check failure in a test.

Bug: 11884037
Change-Id: I44356bbb0b4406ac289d59f4fd29878452087c03
0de9f73afe3e835b63f2ee0c1416930656449f3f 23-Nov-2013 Mathieu Chartier <mathieuc@google.com> Add -xGc: MS, CMS, SS options to specify which GC to use.

Can be used for running tests or benchmarks with semispace,
marksweep or concurrent marksweep.

Change-Id: Ic9ab1220150f2c7c9c30df4ffee45b9d303094b3
2e899a92439dc6bdaaa67b8230933006284aa600 23-Nov-2013 Hiroshi Yamauchi <yamauchi@google.com> Fix a crash with -XX:DumpGCPerformanceOnShutdown.

DumpGcPerformanceInfo() could call RosAllocSpace::InspectAllRosAlloc()
which needs the thread list to be still alive. Fix by moving the
DumpGcPerformanceInfo() call from the Heap destructor up to the
beginning of the Runtime destructor so that the thread list is still
alive when it's called.

Bug: 11830901
Change-Id: Ib094d60916943c8cb1d4b769d805b4ca03269f90
ff3b24aa929a9db79daeef7c0b0522da099700a9 23-Nov-2013 Mathieu Chartier <mathieuc@google.com> Add developer option for dumping GC cumulative timings on shutdown.

The option is "-XX:DumpGCPerformanceOnShutdown".
Bug: 9986416

Change-Id: If6ebb26b3e611a9dead197740dbfc64e548dc388
cf58d4adf461eb9b8e84baa8019054c88cd8acc6 26-Sep-2013 Hiroshi Yamauchi <yamauchi@google.com> A custom 'runs-of-slots' memory allocator.

Bug: 9986565
Change-Id: I0eb73b9458752113f519483616536d219d5f798b
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
fa82427c68b09f4aedbee319dc71579afbfc66f5 06-Nov-2013 Ian Rogers <irogers@google.com> Fix oatdump and valgrind.

Bug: 11531382
Move allocation instrumentation out of runtime into instrumentation. Don't
attempt to suspend threads in unstarted runtimes.
Make indentation support sputc returning eof, on which it will sync and try
again. A further failure likely means the disk is full.
Move the dump-oat output directory to be art as now there's too much output to
fit all the dump-oat data in our standard /tmp.

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

Change-Id: Idf7fe85e1293453a8ad862ff2380dcd5db4e3a39
1eb512d33f94d1dd7ea38263307ba0f7a0dfa653 19-Oct-2013 Ian Rogers <irogers@google.com> Fast JNI support.

Use a modifier to signal a native method is a fast JNI method. If the
modifier is set then don't perform runnable transitions.

Change-Id: I7835b4d837bfdd1cb8e2d54b919c0d5e6cf90499
ce88853ab316c70ef7b598978a3609611db60552 10-Oct-2013 Brian Carlstrom <bdc@google.com> Have JNI FindClass fall back to system ClassLoader
Bug: 10994325

Change-Id: Id0a46e78eecfe8a9eb91008765c4fff48697cc58
253ea073ec03a0be1e22df98957257594e316a39 02-Oct-2013 Hiroshi Yamauchi <yamauchi@google.com> Fix an Art debug build boot failure.

(The original change is 3b4c18933c24b8a33f38573c2ebcdb9aa16efeb5.)

Bug: 11003273
Bug: 9986565
Change-Id: Iaaf6395f171eb6e6b8c99386c20c4970c53ee00d
d9c4fc94fa618617f94e1de9af5f034549100753 02-Oct-2013 Ian Rogers <irogers@google.com> Inflate contended lock word by suspending owner.

Bug 6961405.
Don't inflate monitors for Notify and NotifyAll.
Tidy lock word, handle recursive lock case alongside unlocked case and move
assembly out of line (except for ARM quick). Also handle null in out-of-line
assembly as the test is quick and the enter/exit code is already a safepoint.
To gain ownership of a monitor on behalf of another thread, monitor contenders
must not hold the monitor_lock_, so they wait on a condition variable.
Reduce size of per mutex contention log.
Be consistent in calling thin lock thread ids just thread ids.
Fix potential thread death races caused by the use of FindThreadByThreadId,
make it invariant that returned threads are either self or suspended now.

Code size reduction on ARM boot.oat 0.2%.
Old nexus 7 speedup 0.25%, new nexus 7 speedup 1.4%, nexus 10 speedup 2.24%,
nexus 4 speedup 2.09% on DeltaBlue.

Change-Id: Id52558b914f160d9c8578fdd7fc8199a9598576a
3b4c18933c24b8a33f38573c2ebcdb9aa16efeb5 13-Sep-2013 Hiroshi Yamauchi <yamauchi@google.com> Split the allocation path into 'instrumented' and 'uninstrumented'
ones.

The instrumented path is equivalent to the existing allocation path
that checks for three instrumentation mechanisms (the debugger
allocation tracking, the runtime allocation stats collection, and
valgrind) for every allocation. The uinstrumented path does not
perform these checks. We use the uninstrumented path by default and
enable the instrumented path only when any of the three mechanisms is
enabled. The uninstrumented version of Heap::AllocObject() is inlined.

This change improves the Ritz MemAllocTest by ~4% on Nexus 4 and ~3%
on Host/x86.

Bug: 9986565
Change-Id: I3e68dfff6789d77bbdcea98457b694e1b5fcef5f
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
c11d9b8870de5f860b13c84003ade7b3f3125a52 19-Sep-2013 Mathieu Chartier <mathieuc@google.com> Re-enable concurrent system weak sweeping.

Enabled by disallowing new system weaks during the pause and
re-allowing it after the system weaks have been swept. Reduces
GC pause by ~1ms.

Fixes pause regression caused by fix for
Bug: 10626133

Change-Id: If49d33e7ef19cb728ed3cef5187acfa53b9b05d8
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
52cd1e8f2f0622a174f883e24151ab873170787f 18-Sep-2013 Jeff Sharkey <jsharkey@android.com> Allow traversal into /storage paths.

Apps are no longer required to have sdcard_r or sdcard_rw to access
some parts of external storage. Relax the mount parameters to allow
everyone to traverse.

Bug: 10577808
Change-Id: Ife3c6fb18028f7093ff853459c1ca1e0ec7a6d01
6aa3df965395566ed6a4fec4af37c2b7577992e9 18-Sep-2013 Mathieu Chartier <mathieuc@google.com> Refactor system weak sweeping, add support for modification.

Required for moving collectors.

Change-Id: Ib97ba4a05af1139f8d388077a15e62bcb9534855
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
cf2fb8e6430059cc7fe0a6f931555bb717988393 23-Aug-2013 Jeff Hao <jeffhao@google.com> Add art support for sample profiling from traceview gui.

Change-Id: I6004bf143521b872084ca4aae873bea3524aa895
(cherry picked from commit 23009dca63c1699e28bfeaa8b45ca48fa0e86ace)
23009dca63c1699e28bfeaa8b45ca48fa0e86ace 23-Aug-2013 Jeff Hao <jeffhao@google.com> Add art support for sample profiling from traceview gui.

Change-Id: I6004bf143521b872084ca4aae873bea3524aa895
2775ee4f82dff260663ca16adddc0b15327aaa42 21-Aug-2013 Mathieu Chartier <mathieuc@google.com> Add more runtime options.

Changed HeapGCThreads to be split into two different options:
-XX:ParallelGCThreads: Which specifies how many threads the GC may
use when the mutators are suspended.

-XX:ConcGCThreads: Which specifies how many threads the GC may use
when the mutators are running.

Added runtime options to specify long pause / long GC thresholds:
-XX:LongPauseThreshold (default 5ms)
-XX:LongGCThreshold (default 100ms)
These thresholds were previously constants, but are now runtime
options. If we exceed either of the thresholds, we print the GC
message.

Added a new runtime option: -XX:IgnoreMaxFootprint which makes it
that the GC only does GC when the number of bytes allocated hits
the growth limit. This causes GC to occur much less frequently and
can be useful to measure how much of an impact GC has on performance.

Changed the GC behaviour to use only one thread when we do not care
about pauses to prevent jank that can be caused by 2 simultaneous GC
on different processes fighting for CPU time.

Added thread pool functionality for changing the maximum number of
active workers.

Fixed an accounting error where we didn't count large objects in the
total freed.

Bug: 9986416

Change-Id: I86afa358d93dcd3780e18ac5d85bdb1a130cb7e7
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
abd7be989a7509d6dd7325d505fa9926ed502355 15-Aug-2013 Ian Rogers <irogers@google.com> Prevent segvs in JNI.

A segv in JNI code (without CheckJNI) is hard to debug as we fail to see
stacks, pending exceptions.. Make JNI code robust to null arguments, but don't
go to the lengths that CheckJNI does in also sanity checking arguments, the
priority here is just to stop the VM from crashing.

Bug 10305723

Also, allow an unknown throw location not to crash exception dumping.

Found/useful for debugging bug 10331039.

(cherry picked from commit bc939663ccfbe0c648dd6a3670041510aca82420)

Change-Id: Id0203db7d9e320d45ae5ba25d2b63939c79e5c16
bc939663ccfbe0c648dd6a3670041510aca82420 15-Aug-2013 Ian Rogers <irogers@google.com> Prevent segvs in JNI.

A segv in JNI code (without CheckJNI) is hard to debug as we fail to see
stacks, pending exceptions.. Make JNI code robust to null arguments, but don't
go to the lengths that CheckJNI does in also sanity checking arguments, the
priority here is just to stop the VM from crashing.

Bug 10305723

Also, allow an unknown throw location not to crash exception dumping.

Found/useful for debugging bug 10331039.

Change-Id: Ib1e5540df87e2d9ce7570802d624baae7797611f
8718359763aa3dcd0033a2d2e67e0cb145fb9c53 14-Aug-2013 Anwar Ghuloum <anwarg@google.com> Add -XX:+DisableExplicitGC option for Art

Phone boots. Also removed elfwriter spam from logcat.

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

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

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

Cherry-picked from commit ed41d5c44299ec5d44b8514f6e17f802f48094d1.

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

Bug: 10014286.

Change-Id: Iafc1d8c5b62562c9af8fb9fd8c5e1d61270536e7
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
e0a53e99e2a01f8668d6616c3cec7e2f5a711286 05-Aug-2013 Mathieu Chartier <mathieuc@google.com> Add low memory mode option to ART.

Useful so that we match the option I added here:
https://googleplex-android-review.googlesource.com/#/c/328940/

In ART low memory mode reduces the maximum number of histogram
buckets. We also trim no matter the utilization.

Change-Id: I655ba63312c0a6574569cdd5171ca81ea338c2aa
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
166db04e259ca51838c311891598664deeed85ad 26-Jul-2013 Ian Rogers <irogers@google.com> Move assembler out of runtime into compiler/utils.

Other directory layout bits of clean up. There is still work to separate quick
and portable in some files (e.g. argument visitor, proxy..).

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

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

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

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

Bug: 9987437
Change-Id: I418ee99f63e4203409cf5b7d2c2295b22fcf24c1
63a54345598861030178e033ffbd72c0e231a4c9 23-Jul-2013 Mathieu Chartier <mathieuc@google.com> Add option for changing number of GC threads.

The number of threads was previously set to 1 by an accidential
checkin. This hurts on all devices which aren't dual core. We now
properly use sysconf to determine how many threads we should create.

Also added a -XX:HeapGCThreads heap option which lets us change
how many GC threads we create. The default value is equal to the
number of processors on the device minus one.

Change-Id: If65065ef09174a3813b8741efdd5ea7bbe82a4e2
b1eba213afaf7fa6445de863ddc9680ab99762ea 18-Jul-2013 Brian Carlstrom <bdc@google.com> Fix cpplint whitespace/comma issues

Change-Id: I456fc8d80371d6dfc07e6d109b7f478c25602b65
2ce745c06271d5223d57dbf08117b20d5b60694a 18-Jul-2013 Brian Carlstrom <bdc@google.com> Fix cpplint whitespace/braces issues

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