History log of /art/runtime/utils.cc
Revision Date Author Comments
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)
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
c15e566b36170237f01ccefc12129c1578a02140 17-Mar-2016 Calin Juravle <calin@google.com> Improve resolved classes saving strategy

If we already have a non empty profile file it means that we already
saved once the resolved classes. So there's no need to hurry up and
start the profile saver eagerly after 2s.

Bug: 27600652
Change-Id: I92ac5869bf68c8d6cbac8fc1503fe3c4930241b4
fa16a6d0039801293f7f4c035b4876d72f880adf 10-Mar-2016 Christopher Ferris <cferris@google.com> Log when why an Unwind failed.

Bug: 27449879

(cherry picked from commit f193878a242f5b86db62986a9b2cba5d99505c17)

Change-Id: Ieb4f258feaaef70a4982495e4f63ed778280b8da
f193878a242f5b86db62986a9b2cba5d99505c17 10-Mar-2016 Christopher Ferris <cferris@google.com> Log when why an Unwind failed.

Bug: 27449879
Change-Id: If7ae5f0991da6fd64dd45e22d69eecef1388a28e
024160850fbbf28368eae951beb4c72e2ce8fce6 23-Feb-2016 Calin Juravle <calin@google.com> Revert "Revert "Add profman tool: responsible to process profiles""

This reverts commit 3da74687e42de7d33a8e75df9bd64374e650f75e.

(cherry picked from commit 2e2db786b8fbaa4dceb37603a4296b0b2aea4e9e)

Change-Id: I38086cc9de939bad33bcd13b1677e1626af61c29
2e2db786b8fbaa4dceb37603a4296b0b2aea4e9e 23-Feb-2016 Calin Juravle <calin@google.com> Revert "Revert "Add profman tool: responsible to process profiles""

This reverts commit 3da74687e42de7d33a8e75df9bd64374e650f75e.

Change-Id: Id005096bd8063c6c602744d4476d5eb7e0d34e90
3da74687e42de7d33a8e75df9bd64374e650f75e 22-Feb-2016 Nicolas Geoffray <ngeoffray@google.com> Revert "Add profman tool: responsible to process profiles"

Needs a profile_assistant_test fix.

Bug: 26719109
Bug: 26563023

This reverts commit 6caefd983a800a063b219f1d3ed71b1416cecd70.

Change-Id: Ibdeb7385737dd7846ed861e0a95f083abb9aa974
6caefd983a800a063b219f1d3ed71b1416cecd70 01-Feb-2016 Calin Juravle <calin@google.com> Add profman tool: responsible to process profiles

This pulls out profile parsing from dex2oat into a separate tool.
Some additional refactoring:
- better return codes
- dex2oat now accepts only one profile file

This is the first step towards support secondary dex files and
extracting profiles out of the code_cache directory.

Bug: 26719109
Bug: 26563023

(cherry picked from commit d81c289e58f4ced8ec7674fd377c356669f97227)

Change-Id: I34d408faa318e866e1a23d4d04c369131ee5012b
d81c289e58f4ced8ec7674fd377c356669f97227 01-Feb-2016 Calin Juravle <calin@google.com> Add profman tool: responsible to process profiles

This pulls out profile parsing from dex2oat into a separate tool.
Some additional refactoring:
- better return codes
- dex2oat now accepts only one profile file

This is the first step towards support secondary dex files and
extracting profiles out of the code_cache directory.

Bug: 26719109
Bug: 26563023
Change-Id: I364dad7e3beb22ef71c372739d5bcc490ae23270
59a8c0bb74c353f879760bd6522b49cf7298666e 20-Jan-2016 tony.ys_liu <tony.ys_liu@htc.com> Use current pid not tid to create a backtrace map.

The BacktraceMap::Create() function assumes that the passed in
parameter is the current pid not tid. If a tid is passed in, then
the logic that creates the local map in libunwind is not used
and can bypass all of the special handling of local maps. The result
can be crashes if this map data gets out of sync with the real maps
found in the process.

Bug: 26676205
Bug: https://code.google.com/p/android/issues/detail?id=199219
Change-Id: Ibab9f7a7b99648a2cdaa185958bf6ffc368079ce
4d87df607a0b86cdf4b2c04f61d72a60d8975ce0 08-Jan-2016 Mathieu Chartier <mathieuc@google.com> Improve handling of daemon threads after runtime shutdown

The main issue comes from the fact that user daemon threads are
allowed to continue running after the runtime has shutdown. They may
still have a JNI env pointer. To prevent crashing if they call into
the env, we replace the function pointers with functions that sleep
forever.

The other issue is that user daemon threads that are blocked in an
ART condition variable may get woken up by another user daemon inside
of Monitor::Notify or by a spurious wakeup (i.e. SIGQUIT). To deal
with this issue, we check the JNI env for shutdown runtime when we
are woken up from a condition variable wait. This check fixes test
132 with --host --gdb --interpreter. Previously this test crashed
since dlclose was somehow causing a spurious futex wakeup.

TODO: Investigate adding a unit test.

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

bug: 26080105
Change-Id: I9969a4abd8533614922076551fcbae2cdf695525
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
5096e66d07db8041589518f8c5b0281d859d0817 08-Dec-2015 Vladimir Marko <vmarko@google.com> ART: Add FdFile::Copy() to copy data from another file.

Also move utilities for inspecting file magic numbers to
base/file_magic.{h,cc} and drop the unused IsOatMagic().

Change-Id: I2cc4dd18a5e8b9738fb386c8057faad3722bdd68
732f016139acac7bd7ec0d0c1d5e964eb8a28b2e 20-Nov-2015 Alex Light <allight@google.com> Revert "Use arc4random when available to select delta for image relocation."

This reverts commit 7ecbd49c6c78e6c633883aa6766675df8abaa7dd.

Change-Id: Ifb37e23584722b31cb2369bcc9b91da6146d2cf6
7ecbd49c6c78e6c633883aa6766675df8abaa7dd 19-Nov-2015 Alex Light <allight@google.com> Use arc4random when available to select delta for image relocation.

Bug: 25776162

Change-Id: I1c4cc992977b5d6fe782ff819903a802a40391ee
ae35c3716dd4d974f6e6c3900577d9d98f99132f 04-Nov-2015 Tobias Lindskog <tobias.lindskog@sonymobile.com> Use _exit instead of exit after exec fails

A call to exit() will run the atexit handlers before exiting, which is
usually not desirable in a forked-off child process.

Calling _exit() instead will not run the atexit handlers.

Change-Id: Ide9a69c0468faafeaf32b0babd9fcf2b4f06f546
abbb0f76b07417f13f712f54d5afddb72e3b9931 29-Oct-2015 Nicolas Geoffray <ngeoffray@google.com> Refactor code so that JIT can parse compiler options.

Currently only the CompilerOptions class. We should also
do it for the CompilerDriver options.

This will fix the flakiness seen on jdwp testing, as the
debuggable flag was not passed to the compiler.

Change-Id: I4218dd5928c9f4fe2d6191ab11e5598e7cf84bcf
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
ab60b68183cc8052b113c566f4851263444eb29c 20-Oct-2015 Nicolas Geoffray <ngeoffray@google.com> New attempt at fixing mac build.

Change-Id: I00e3df55e65eb5edb4e8dd244bb7f8918dd942d4
b937a443752d4185a18cafb88e686bec1dd53d15 20-Oct-2015 Nicolas Geoffray <ngeoffray@google.com> Fix mac build.

Change-Id: I7229a628a619164eea22735bcaed507428ab054a
524e7ea8cd17bad17bd9f3e0ccbb19ad0d4d9c02 16-Oct-2015 Nicolas Geoffray <ngeoffray@google.com> Remove ArtCode.

- Instead use OatQuickMethodHeader.
- Various cleanups now that we don't have all those
ArtMethod -> ArtCode -> OatQuickMethodHeader indirections.

As a consequence of this cleanup, exception handling got a bit
faster.

ParserCombinators benchmark (exception intensive) on x64: (lower is better)
Before:
ParserCombinators(RunTime): 1062500.0 us.
After:
ParserCombinators(RunTime): 833000.0 us.

Change-Id: Idac917b6f1b0dc254ad68fb3781cd61bccadb0f3
6bc4374e3fa00e3ee5e832e1761c43e0b8a71558 12-Oct-2015 Nicolas Geoffray <ngeoffray@google.com> Add an abstraction over a compiled code.

That's just step 1, moving code-related functions of ArtMethod to
another class. That class is only a wrapper on an ArtMethod, but will
be changed to be a wrapper around compiled code.

Change-Id: I6f35fc06d37220558dff61691e51ae20066b0dd6
f9f6441c665b5ff9004d3ed55014f46d416fb1bb 02-Sep-2015 Vladimir Marko <vmarko@google.com> Optimizing: Tag Arena allocations with their source.

This adds the ability to track where we allocate memory
when the kArenaAllocatorCountAllocations flag is turned on.

Also move some allocations from native heap to the Arena
and remove some unnecessary utilities.

Bug: 23736311
Change-Id: I1aaef3fd405d1de444fe9e618b1ce7ecef07ade3
53de99cd7e863e95179823504335f1f67e03c791 17-Aug-2015 Andreas Gampe <agampe@google.com> ART: Follow-up fixes

Addressing comments for CL 166499, commit
5073fedd553afeb6ccdb49c1a1ab2cc2947c0870.

Change-Id: I359e5a4c026d58d75cb62b90c495796855302b94
5073fedd553afeb6ccdb49c1a1ab2cc2947c0870 10-Aug-2015 Andreas Gampe <agampe@google.com> ART: Add utility function to dump dex CFG

Add a utility function in utils.h to dump the dex CFG of
a method.

Add an option ("-g") to dump CFGs of a dex file in dexdump2.

Change-Id: I380082f0abe8ed7eeb6a9186364a99425f69f55c
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
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
3d21bdf8894e780d349c481e5c9e29fe1556051c 22-Apr-2015 Mathieu Chartier <mathieuc@google.com> Move mirror::ArtMethod to native

Optimizing + quick tests are passing, devices boot.

TODO: Test and fix bugs in mips64.

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

Bug: 19264997

(cherry picked from commit e401d146407d61eeb99f8d6176b2ac13c4df1e33)

Change-Id: I622469a0cfa0e7082a2119f3d6a9491eb61e3f3d

Fix some ArtMethod related bugs

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

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

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

TODO: Fix JDWP tests.

Bug: 19264997

Change-Id: I7c55f69c61d1b45351fd0dc7185ffe5efad82bd3

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

Bug: 19264997
Change-Id: Ief45cdd4bae5a43fc8bfdfa7cf744e2c57529457

Fix JDWP tests after ArtMethod change

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

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

Bug: 19264997
Change-Id: I363e293796848c3ec491c963813f62d868da44d2

Fix accidental IMT and root marking regression

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

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

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

Bug: 19264997
Change-Id: I4333e80a8268c2ed1284f87f25b9f113d4f2c7e0

Fix bogus image test assert

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

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

Bug: 19264997
Change-Id: I7359f1f73ae3df60c5147245935a24431c04808a

[MIPS64] Fix art_quick_invoke_stub argument offsets.

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

This fixes mips64 boot.

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

Optimizing + quick tests are passing, devices boot.

TODO: Test and fix bugs in mips64.

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

Bug: 19264997
Change-Id: I622469a0cfa0e7082a2119f3d6a9491eb61e3f3d
f2383d6b754a8fa23617149a008aa2ab9fcf0adf 26-May-2015 Vladimir Marko <vmarko@google.com> Fix mac build: include <sys/time.h> in time_utils.cc .

Required for gettimeofday(). Not needed in utils.cc .

Bug: 13925192

(cherry picked from commit ce39200492e2715a94d96fbd39fa42b46115c255)

Change-Id: If40694965b84605819cac11a7937821aa74db82b
ce39200492e2715a94d96fbd39fa42b46115c255 26-May-2015 Vladimir Marko <vmarko@google.com> Fix mac build: include <sys/time.h> in time_utils.cc .

Required for gettimeofday(). Not needed in utils.cc .

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

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

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

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

Bug: 13925192

(cherry picked from commit 80afd02024d20e60b197d3adfbb43cc303cf29e0)

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

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

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

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

Bug: 13925192
Change-Id: I704884dab15b41ecf7a1c47d397ab1c3fc7ee0f7
8508e37deeb291f92d28a9bff2df77cabdc29ddf 06-May-2015 Narayan Kamath <narayan@google.com> Fix broken checks in IsValidPartOfMemberNameUtf8Slow.

GetUtf16FromUtf8 returns a surrogate pair only if it encounters
a 4-byte UTF sequence. Three byte UTF sequences will only return the
first or second half of a pair so we need to check for that
explicitly.

bug: 20844537

(cherry picked from commit 3ba8671d60061359fd833f60f7a9dca14878cc0b)

Change-Id: I2e2a4f9f736cd11050a2b634b3bb27b75a0ee0ba
3ba8671d60061359fd833f60f7a9dca14878cc0b 06-May-2015 Narayan Kamath <narayan@google.com> Fix broken checks in IsValidPartOfMemberNameUtf8Slow.

GetUtf16FromUtf8 returns a surrogate pair only if it encounters
a 4-byte UTF sequence. Three byte UTF sequences will only return the
first or second half of a pair so we need to check for that
explicitly.

bug: 20844537

Change-Id: Icb660fae77ac8a852fc768e6c1cd5766117e68e4
46578a4a3bf235fde35ed80c6e6cbe8fb5f06b48 04-May-2015 Mathieu Chartier <mathieuc@google.com> Fix NanoSleep and add test

Fixed a bug where tv_nsec was't between 0 and 999,999,999.

(cherry picked from commit 0b063d9ba7a11779667c0888e9f3495de0118b74)

Bug: 14450052
Change-Id: I30b29a716bfa63c6b57d589dd1102d2ca934c061
0b063d9ba7a11779667c0888e9f3495de0118b74 04-May-2015 Mathieu Chartier <mathieuc@google.com> Fix NanoSleep and add test

Fixed a bug where tv_nsec was't between 0 and 999,999,999.

Bug: 14450052
Change-Id: I30b29a716bfa63c6b57d589dd1102d2ca934c061
5a1b2bff14465113280265fc856e1cae116faa25 02-May-2015 Christopher Ferris <cferris@google.com> Let the map function compute the relative pc.

The new packed relocations linker option creates an elf with a non-zero
load base. It's no longer an easy task to compute the relative pc yourself
so call the helper function to do it for us.

Bug: 20687795

(cherry picked from commit 332ef327c2b1a5e1774ba0d1da23e07303002af9)

Change-Id: I3d61c767f21a3f240a14f9e8bc6bee53b6cdb60d
332ef327c2b1a5e1774ba0d1da23e07303002af9 02-May-2015 Christopher Ferris <cferris@google.com> Let the map function compute the relative pc.

The new packed relocations linker option creates an elf with a non-zero
load base. It's no longer an easy task to compute the relative pc yourself
so call the helper function to do it for us.

Bug: 20687795
Change-Id: If11c1a596bc79382d44e35a86d5035ab29d29864
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
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
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
66d874d96d5699bb090c59f47a5a528956ca053e 15-Jan-2015 Richard Uhler <ruhler@google.com> Create OatFileAssistant class for assisting with oat files.

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

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

Bug: 11301553
Change-Id: I0c16027b9bae4570c2c50faa9c14f581c0cbafb8
00a1f5bfa57bb4007a08435ba83b029dcebde5c0 27-Feb-2015 Andreas Gampe <agampe@google.com> Revert "Revert "Re-enable one thread dumping the native stack of another.""

This reverts commit edfdaf37d5520a3c3a858b6b3fba4f759c60dadc.

Tests seem to succeed. Might be helpful to understand some deadlock/timeout
situations.

Bug: 15446488
Bug: 18713034
Change-Id: I5be225363f698556221576b5827d9501e26799f3
965fd02721746d4164bc40719cd53eefab37cfb3 26-Feb-2015 Richard Uhler <ruhler@google.com> Don't require three-character extensions for dex locations.

Bug: 19437875
Change-Id: Ib62b4c691b04f27c5d499affd5a7fd4d9f0c64f9
a6dfdae1cffc78f9791348b2e1dc8f4c6c3f7128 25-Feb-2015 Andreas Gampe <agampe@google.com> ART: Print maps directly to log

Do not read proc maps into a string before printing them later back
to the log. In low-memory situations this can cause a bad_alloc.

External bug: http://b.android.com/153990
Bug: 19494774

Change-Id: Ie63d8788afe8c9da65b30b2f89c50d3dbb820755
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
80b96d1a76790527f72a660ac03d9c215eed17ce 19-Feb-2015 Vladimir Marko <vmarko@google.com> Replace a few std::vector with ArenaVector in Mir2Lir.

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

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

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

bug: 18848397
bug: https://code.google.com/p/android/issues/detail?id=81341
Change-Id: Ibc98d29e59d98803e640f2489ea4c56912a59b29
a1c9665c4659f4a8a3469bdb667a63a438725a17 06-Feb-2015 Christopher Ferris <cferris@google.com> Support map data in the backtrace data structure.

The backtrace data structure used to keep a pointer to the map data. Now
the code has the map data embedded in the structure and no pointers.

Bug: 19028453
Change-Id: If7088a73f3c6bf1f3bc8cdd2bb4b62e7cab831c0
3ef69b4692978daa620f2db2b1b057ef38c8a2f5 26-Jan-2015 Andreas Gampe <agampe@google.com> ART: Take apart stream output

To investigate bug.

Bug: 19028453
Change-Id: Ib109caf2747f9adeef15dfc0f4708498e395dacf
941c551acbc1fac40db89a723edc6b04d506d55c 15-Jan-2015 Andreas Gampe <agampe@google.com> ART: Only run addr2line in abort thread dumps

Avoid addr2line overhead for SIGQUIT and other thread dumps.

Bug: 18933933
Change-Id: I81bb291ede870d1d14b30bb0afdc47830ed14e8b
0a18df82f4dea95b7398f8c934341fccbf04eeee 10-Jan-2015 Elliott Hughes <enh@google.com> Clean up some #ifdefs.

Only the Mac doesn't have POSIX clocks. (And it still doesn't, a decade
later.)

glibc gained pthread_setname_np in 2.12.

Only the Mac doesn't have prctl.

Change-Id: I218e409f7e133736e15fb68e8a254cdc5799d667
00bd2da6ea009dedafc677229b485923f49ad61b 10-Jan-2015 Andreas Gampe <agampe@google.com> ART: Fix prefix issues in Addr2line dump

The code incorrectly wrote the prefix twice for overly long lines.

Bug: 18933933
Change-Id: I4bc7c2cde435bd966276ca2dae6a5d060aa2d0f3
8e1cb91d2de6cacf388ca8550325fd8c21b1e58c 09-Jan-2015 Andreas Gampe <agampe@google.com> ART: Use addr2line on the host for DumpNativeStack

Use addr2line to attempt some better debug output for unexpected
signals in tests. This prints the demangled function name, source
file and line number (including inlined frames) when possible.

Bug: 18933933
Change-Id: I4b98d0cc7bef5cdc63c7ee0882629b363778afe2
9387c72720767b65b2ef27d6e922373d9ddc8d6c 08-Jan-2015 Andreas Gampe <agampe@google.com> ART: Fix Mac build

Fix Mac build after change-id Id2710d2fd44b7c3b3335973a9288979a5793638b.

Bug: 18933933
Change-Id: Ib0bb5082908d5dff33ef8f8a69d82c07406c176d
628a61ac52a8a314e74ab445397add60b4e72a5b 08-Jan-2015 Andreas Gampe <agampe@google.com> ART: Pass ucontext to Backtrace in Stack Dump

In case of an unexpected signal on the host we dump the thread stack
ourselves. We have to pass the context given to the signal handler,
as the signal handler is run on an alternate stack. Otherwise
libbacktrace can't dump the actual faulty part.

Bug: 18933933
Change-Id: Id2710d2fd44b7c3b3335973a9288979a5793638b
edfdaf37d5520a3c3a858b6b3fba4f759c60dadc 05-Dec-2014 Ian Rogers <irogers@google.com> Revert "Re-enable one thread dumping the native stack of another."

This reverts commit e652b62c581a3d68b1fc82e0b04e3a59dd633e52.

Change-Id: Ida56d2c23849c1ede82a22100df402877256e270
e652b62c581a3d68b1fc82e0b04e3a59dd633e52 05-Dec-2014 Ian Rogers <irogers@google.com> Re-enable one thread dumping the native stack of another.

Bug: 15446488
Change-Id: I49d4d283f7b7d04b9d8c940313d6c5107ba9f99d
08f1f50d6c2e8f247b8f5f19711d75a792851c7a 03-Dec-2014 Ian Rogers <irogers@google.com> Remove FieldHelper.

Change-Id: I2d74e2d5b3c35a691c95339de0db9361847fca11
83597d06cd4707b19c1985353418bd99f3aca6c7 20-Nov-2014 Ian Rogers <irogers@google.com> Re-enable DumpNativeStack.

Bug: 15446488
Change-Id: Icdd0b90c8abe2a361a488fc1742c6896605ddc41
4545d773856203eab6b026f66a005ee75b33e1c8 13-Nov-2014 Ian Rogers <irogers@google.com> Disable DumpNativeStack.

Causes crashes on 004-ThreadStress, already was a no-op on the target.
Bug: 15446488

Change-Id: I9a1541b894087337dafa3fdde00d845f3542b141
d7576328811e5103e99d31f834a857522cc1463f 25-Oct-2014 Andreas Gampe <agampe@google.com> ART: Fix valgrind

Allow ValgrindMallocSpace wrapper for RosAlloc.Requires refactoring,
as ValgrindMallocSpace was bound to the signature of DlMallocSpace.

Also turn of native stack dumping when running under Valgrind to
work around b/18119146.

Ritzperf before and after
Mean 3190.725 3082.475
Standard Error 11.68407 10.37911
Mode 3069 2980
Median 3182.5 3051.5
Variance 16382.117 12927.125
Standard Deviation 127.99264 113.69751
Kurtosis 1.1065632 0.3657799
Skewness 0.9013805 0.9117792
Range 644 528
Minimum 2991 2928
Maximum 3635 3456
Count 120 120

Bug: 18119146
Change-Id: I25558ea7cb578406011dede9d3d0bdbfee4ff4d5
9ee0f776095c0a93f388a29f2c37689892baa2df 26-Sep-2014 Mathieu Chartier <mathieuc@google.com> Optimize get/set reflection performance

Speedups mostly from reducing how often access checks are needed,
and adding more inlining, and adding templates.

Field_getInt from ~850ns -> 350ns.
Field_setInt from ~900ns -> 370ns.

Bug: 14063288
Change-Id: I2441581ff3478c6ae43b6aa49939ff3f07555ec8
(cherry picked from commit ffc788cb7b5b9f53734d7bb8af2d5e45d885546b)
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
e6ac4fd428a4897951aeb4cb3b45f1665276c511 04-Nov-2014 Nicolas Geoffray <ngeoffray@google.com> Try to fix mac build.

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

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

(cherry picked from commit 6f3dbbadf4ce66982eb3d400e0a74cb73eb034f3)

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

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

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

Change-Id: I4e4ef3a2002fc59ebd9097087f150eaf3f2a7e08
c0d8229898c44c0f604f08a5df1de83ff56c18fd 23-Sep-2014 Andreas Gampe <agampe@google.com> ART: Better IllegalAccessException message

Bug: 17618578
Bug: 17614623
Change-Id: I0e3f15e676acd6ed5844fc86e136f75cc335372d
76433275dbe39e5ced1c223b006d1b900b1937f6 26-Sep-2014 Mathieu Chartier <mathieuc@google.com> Optimize get/set reflection performance

Speedups mostly from reducing how often access checks are needed,
and adding more inlining, and adding templates.

Field_getInt from ~850ns -> 350ns.
Field_setInt from ~900ns -> 370ns.

Bug: 14063288

(cherry picked from commit ffc788cb7b5b9f53734d7bb8af2d5e45d885546b)

Change-Id: I2441581ff3478c6ae43b6aa49939ff3f07555ec8
ffc788cb7b5b9f53734d7bb8af2d5e45d885546b 26-Sep-2014 Mathieu Chartier <mathieuc@google.com> Optimize get/set reflection performance

Speedups mostly from reducing how often access checks are needed,
and adding more inlining, and adding templates.

Field_getInt from ~850ns -> 350ns.
Field_setInt from ~900ns -> 370ns.

Bug: 14063288
Change-Id: I2441581ff3478c6ae43b6aa49939ff3f07555ec8
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
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
cc2f2393e69a9b1425bad1a89f41aaaf8c38f9e2 30-Aug-2014 Ian Rogers <irogers@google.com> Reduce and speed-up class def searches.

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

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

Bug: 16853450

Change-Id: Icf72df76b0a4328f2a24075e81f4ff267b9401f4
(cherry picked from commit 68b56858367e29461ae290fd797443a1ef6d8005)
68b56858367e29461ae290fd797443a1ef6d8005 30-Aug-2014 Ian Rogers <irogers@google.com> Reduce and speed-up class def searches.

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

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

Bug: 16853450

Change-Id: Icf72df76b0a4328f2a24075e81f4ff267b9401f4
7895d554d17309db67737b6750c59d8cece213e3 28-Aug-2014 Hiroshi Yamauchi <yamauchi@google.com> Fix an assert failure in art::DumpNativeStack().

When ThreadList::SuspendAll() times out (and aborts),
UnsafeLogFatalForThreadSuspendAllTimeout() will call
art::DumpNativeStack() but it does not have the mutator lock
shared-locked (as it failed while trying to exclusive-lock the mutator
lock) and the AssertSharedHeld() on the mutator lock fails. It's an
assert failure nested in an time-out abort.

This change avoids it by letting it print the native method frame info
only if the thread has a shared lock on the mutator lock, as opposed
to asserting that it has a shared lock.

Change-Id: I17851ebcaa37f4f67086c15243a2cffea3997a02
839cc30467d51414e8185eee6101e19f5ab20871 28-Aug-2014 Elliott Hughes <enh@google.com> Move the glibc unlimited stack hack into GetThreadStack.

Optional cleanup that was previously a TODO.

Bug: 17111575
Change-Id: I7c20dbf1fdbcaf4604d7b55552930c10e166539d
6d3fc5615612e500a00aba0a0d331436fae8d996 27-Aug-2014 Elliott Hughes <enh@google.com> Actually ask the pthread implementation for the stack guard size.

(cherry-pick 307091dc306c34ce9e4ee6cc3b467807b3a3bd12.)

Bug: 17111575
Change-Id: I23919b1e8aeff627a65daf57f1109bec60b196cc
307091dc306c34ce9e4ee6cc3b467807b3a3bd12 27-Aug-2014 Elliott Hughes <enh@google.com> Actually ask the pthread implementation for the stack guard size.

Bug: 17111575
Change-Id: I23919b1e8aeff627a65daf57f1109bec60b196cc
49e36ec1b3457f529d9404a33ff9c92921e3dde9 21-Aug-2014 Elliott Hughes <enh@google.com> Kill HAVE_ANDROID_PTHREAD_SETNAME_NP.

All it means is __BIONIC__ anyway.

Change-Id: I3ef4ef1a14d0a77c75539f2ab533ee2f3964e1a5
323aa865a8238d6e2174533464a252cb1606afda 21-Aug-2014 Elliott Hughes <enh@google.com> bionic has always had gettid.

dex2oat calls GetTid for every line it outputs via Message, which is why
this showed up so much in strace.

Bug: 17049821
Change-Id: Ib51c7f88410b291692874023902cf43f4b9a9d1c
e3ea83811d47152c00abea24a9b420651a33b496 08-Aug-2014 Yevgeny Rouban <yevgeny.y.rouban@intel.com> ART source line debug info in OAT files

OAT files have source line information enough for ART runtime needs like
jump to/from interpreter and thread suspension. But this information
is not enough for finer grained source level debugging and low-level
profiling (VTune or perf).

This patch adds to OAT files two additional sections:
.debug_line - DWARF formatted Elf32 section with detailed source line
information (mapping from native PC to Java source lines).

In addition to the debugging symbols added using the dex2oat option
--include-debug-symbols, the source line information is added to
the section .debug_line.

The source line info can be read by many Elf reading tools like objdump,
readelf, dwarfdump, gdb, perf, VTune, ...

gdb can use this debug line information in x86. In 64-bit mode
the information can be used if the oat file is mapped in the lower
address space (address has higher 32 bits zeroed). Relocation works.

Testing:
1. art/test/run-test --host --gdb [--64] 001-HelloWorld
2. in gdb: break Main.java:19
3. in gdb: break Runtime.java:111
4. in gdb: run - stops at void java.lang.Runtime.<init>()
5. in gdb: backtrace - shows call stack down to main()
6. in gdb: continue - stops at void Main.main() (only in 32-bit mode)
7. in gdb: backtrace - shows call stack down to main()
8. objdump -W <oat-file> - addresses are from VMA range of .text
section reported by objdump -h <file>
9. dwarfdump -ka <oat-file> - no errors expected

Size of aosp-x86-eng boot.oat increased by 11% from 80.5Mb to 89.2Mb
with two sections added .debug_line (7.2Mb) and .rel.debug (1.5Mb).

Change-Id: Ib8828832686e49782a63d5529008ff4814ed9cda
Signed-off-by: Yevgeny Rouban <yevgeny.y.rouban@intel.com>
cb6b0f31ede2275e79e6199ec391147585a37a2a 12-Aug-2014 Ian Rogers <irogers@google.com> Avoid use of std::string where we have const char*.

Removing the ClassHelper caused std::string creation for all calls to
Class::GetDescriptor and a significant performance regression. Make the
std::string an out argument so the caller can maintain it and its life time
while allowing GetDescriptor to return the common const char* case.

Don't generate GC maps when compilation is disabled.

Remove other uses of std::string that are occuring on critical paths.
Use the cheaper SkipClass in CompileMethod in CompilerDriver.
Specialize the utf8 as utf16 comparison code for the common shorter byte
encoding.
Force a bit of inlining, remove some UNLIKELYs (they are prone to pessimizing
code), add some LIKELYs.

x86-64 host 1-thread interpret-only of 57 apks:
Before: 29.539s
After: 23.467s

Regular compile:
Before: 1m35.347s
After: 1m20.056s

Bug: 16853450
Change-Id: Ic705ea24784bee24ab80084d06174cbf87d557ad

Conflicts:
runtime/utils.cc
1ff3c98775a4577cf053dba9a0c2d5c21c07b298 12-Aug-2014 Ian Rogers <irogers@google.com> Avoid use of std::string where we have const char*.

Removing the ClassHelper caused std::string creation for all calls to
Class::GetDescriptor and a significant performance regression. Make the
std::string an out argument so the caller can maintain it and its life time
while allowing GetDescriptor to return the common const char* case.

Don't generate GC maps when compilation is disabled.

Remove other uses of std::string that are occuring on critical paths.
Use the cheaper SkipClass in CompileMethod in CompilerDriver.
Specialize the utf8 as utf16 comparison code for the common shorter byte
encoding.
Force a bit of inlining, remove some UNLIKELYs (they are prone to pessimizing
code), add some LIKELYs.

x86-64 host 1-thread interpret-only of 57 apks:
Before: 29.539s
After: 23.467s

Regular compile:
Before: 1m35.347s
After: 1m20.056s

Bug: 16853450
Change-Id: Ic705ea24784bee24ab80084d06174cbf87d557ad
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
345c4b19758703793ed31024cfb79940e2c63b75 18-Jul-2014 Alex Light <allight@google.com> Make system use patchoat to relocate during runtime.

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

Bug: 15358152

(cherry picked from commit 6e183f2e973a20f2eaca135c240908e1bf98c5d0)

Change-Id: Ib21f4f41b6cbf18094e3ca1a30d65a3b197b71b0
547cdfd21ee21e4ab9ca8692d6ef47c62ee7ea52 05-Aug-2014 Tong Shen <endlessroad@google.com> Emit CFI for x86 & x86_64 JNI compiler.

Now for host-side x86 & x86_64 ART, we are able to get complete stacktrace with even mixed C/C++ & Java stack frames.

Testing:
1. art/test/run-test --host --gdb [--64] --no-relocate 005
2. In gdb, run 'b art::Class_classForName' which is implementation of a Java native method, then 'r'
3. In gdb, run 'bt'. You should see stack frames down to main()

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

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

Bug: 15358152

Change-Id: Ibe92d8b55a24bbf718b0416a21b76e5df7a2de26
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
22d5e735f403c57525fe868304c7123f0ce66399 16-Jul-2014 Ian Rogers <irogers@google.com> Remove object_utils.h.

Break into object_lock, field_helper and method_helper.
Clean up header files following this.
Also tidy some of the Handle code in response to compiler errors when resolving
the changes in this CL.

Change-Id: I73e63015a0f02a754d0866bfaf58208aebcaa295
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
829b4bad12a34c90734e73d4460d571db812372c 26-Jun-2014 Andreas Gampe <agampe@google.com> ART: Change sprintf to snprintf

Use of sprintf is discouraged. Change to snprintf in utils.cc. Avoids
a warning with GCC 4.9.

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

Native support for zip files with multiple classesX.dex.

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

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

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

Change-Id: I0de107e1369cbc94416c544aca3b17525c9eac8b
f5997b4d3f889569d5a2b724d83d764bfbb8d106 20-Jun-2014 Mathieu Chartier <mathieuc@google.com> More advanced timing loggers.

The new timing loggers have lower overhead since they only push into
a vector. The new format has two types, a start timing and a stop
timing. You can thing of these as brackets associated with a
timestamp. It uses these to construct various statistics when needed,
such as: Total time, exclusive time, and nesting depth.

Changed PrettyDuration to have a default of 3 digits after the decimal
point.

Exaple of a GC dump with exclusive / total times and indenting:
I/art (23546): GC iteration timing logger [Exclusive time] [Total time]
I/art (23546): 0ms InitializePhase
I/art (23546): 0.305ms/167.746ms MarkingPhase
I/art (23546): 0ms BindBitmaps
I/art (23546): 0ms FindDefaultSpaceBitmap
I/art (23546): 0ms/1.709ms ProcessCards
I/art (23546): 0.183ms ImageModUnionClearCards
I/art (23546): 0.916ms ZygoteModUnionClearCards
I/art (23546): 0.610ms AllocSpaceClearCards
I/art (23546): 1.373ms AllocSpaceClearCards
I/art (23546): 0.305ms/6.318ms MarkRoots
I/art (23546): 2.106ms MarkRootsCheckpoint
I/art (23546): 0.153ms MarkNonThreadRoots
I/art (23546): 4.287ms MarkConcurrentRoots
I/art (23546): 43.461ms UpdateAndMarkImageModUnionTable
I/art (23546): 0ms/112.712ms RecursiveMark
I/art (23546): 112.712ms ProcessMarkStack
I/art (23546): 0.610ms/2.777ms PreCleanCards
I/art (23546): 0.305ms/0.855ms ProcessCards
I/art (23546): 0.153ms ImageModUnionClearCards
I/art (23546): 0.610ms ZygoteModUnionClearCards
I/art (23546): 0.610ms AllocSpaceClearCards
I/art (23546): 0.549ms AllocSpaceClearCards
I/art (23546): 0.549ms MarkRootsCheckpoint
I/art (23546): 0.610ms MarkNonThreadRoots
I/art (23546): 0ms MarkConcurrentRoots
I/art (23546): 0.610ms ScanGrayImageSpaceObjects
I/art (23546): 0.305ms ScanGrayZygoteSpaceObjects
I/art (23546): 0.305ms ScanGrayAllocSpaceObjects
I/art (23546): 1.129ms ScanGrayAllocSpaceObjects
I/art (23546): 0ms ProcessMarkStack
I/art (23546): 0ms/0.977ms (Paused)PausePhase
I/art (23546): 0.244ms ReMarkRoots
I/art (23546): 0.672ms (Paused)ScanGrayObjects
I/art (23546): 0ms (Paused)ProcessMarkStack
I/art (23546): 0ms/0.610ms SwapStacks
I/art (23546): 0.610ms RevokeAllThreadLocalAllocationStacks
I/art (23546): 0ms PreSweepingGcVerification
I/art (23546): 0ms/10.621ms ReclaimPhase
I/art (23546): 0.610ms/0.702ms ProcessReferences
I/art (23546): 0.214ms/0.641ms EnqueueFinalizerReferences
I/art (23546): 0.427ms ProcessMarkStack
I/art (23546): 0.488ms SweepSystemWeaks
I/art (23546): 0.824ms/9.400ms Sweep
I/art (23546): 0ms SweepMallocSpace
I/art (23546): 0.214ms SweepZygoteSpace
I/art (23546): 0.122ms SweepMallocSpace
I/art (23546): 6.226ms SweepMallocSpace
I/art (23546): 0ms SweepMallocSpace
I/art (23546): 2.144ms SweepLargeObjects
I/art (23546): 0.305ms SwapBitmaps
I/art (23546): 0ms UnBindBitmaps
I/art (23546): 0.275ms FinishPhase
I/art (23546): GC iteration timing logger: end, 178.971ms

Change-Id: Ia55b65609468f212b3cd65cda66b843da42be645
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
bfd9a4378eacaf2dc2bbe05ad48c5164fc93c9fe 22-May-2014 Mathieu Chartier <mathieuc@google.com> Change MethodHelper to use a Handle.

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

Bug: 13077697

Change-Id: I71f964d4d810ab4debda1a09bc968af8f3c874a3
576ca0cd692c0b6ae70e776de91015b8ff000a08 07-Jun-2014 Ian Rogers <irogers@google.com> Reduce header files including header files.

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

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

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

Bug: 13077697

Change-Id: I7de9ded2893b5568d43e4daa86fd135bf5508b72
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
bb0b53f58f11c628f077603b56077dfed1a18f11 23-May-2014 Calin Juravle <calin@google.com> Clean up the sampling profiler

- rename variables/fields names to match the code style (use
_underscore_names_)
- extract common property parsing in utils.cc
- fail to load profile file if any line is malformed
- added ProfileFile to manage the profile data generate in the previous
runs (replaces ProfileHelper and nests ProfileData)

Bug: 12877748
Change-Id: Ie7bda30bfdeb7e78534c986615b0649eac12a97b
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
2afe49450f2e018f18b5de45428b9174bfd6f196 19-May-2014 Brian Carlstrom <bdc@google.com> Follow up to "Add ISA directory to image and odex pathnames."

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

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

Bug: 8981901

Change-Id: I82b3bb6dd48d21eb6ece7aae0733c4a23c2bc408
0e12bdc49744eb6d5c29b9611a8dbe10bac4cd53 15-May-2014 Brian Carlstrom <bdc@google.com> Add ISA directory to image and odex pathnames.

Bug: 14882223
Bug: 14694978
Change-Id: Ic1b5ae836b8e91ea461dcd4f3da8e38dc3bec00f
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
41ccffd58512f1fa1aeb9ad288cbb667899ff1be 06-May-2014 Brian Carlstrom <bdc@google.com> Automatically create non-/data dalvik-cache directories

Bug: 14471634
Change-Id: Ie8ae4537102352dc1b270e9b65e681adf3631a80
7b20533d064dcc4670e581d8a843aa3d84d0ae02 06-May-2014 Colin Cross <ccross@google.com> Revert "art: fix creating dalvik-cache subdirectory"

This reverts commit 165e8bda46a81a39862b953e85408b0d7688446d.

Change-Id: Ib4d1bd5b9bd965cacb28e9ecc485fca9443aca8b
165e8bda46a81a39862b953e85408b0d7688446d 06-May-2014 Colin Cross <ccross@android.com> art: fix creating dalvik-cache subdirectory

The current code only ever calls mkdir if dalvik_cache_root starts
with /tmp, which is not true on the device. Split the logic for
creating dalvik-cache from the logic for creating dalvik-cache
subdirectories, as they have different conditions.

Fixes:
05-05 21:34:04.870 1295 1295 F art : art/runtime/utils.cc:1187] Failed to find dalvik-cache directory /data/dalvik-cache/arm64
when /data/dalvik-cache/arm64 doesn't exist.

Change-Id: Ifdf5fcc2d3a8d80f6182cf2e5b5d7b1fac3c3810
ef204fae79009caa1ec7df1f79462bf8b92b5e58 30-Apr-2014 Narayan Kamath <narayan@google.com> Fix errno checking for dalvik-cache creation.

On the host, it's possible for /tmp/foo/dalvik-cache/<isa> to
not exist, but for /tmp/foo/dalvik-cache to be already present.
In this scenario, the first mkdir() can fail with EEXIST.

(cherry picked from commit 6fa28aef44106eef4a7195adb5eb77f6e5531572)

Change-Id: I1da79ad23a4ff510a0f87eca4b52d9f52ab791ad
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
6fa28aef44106eef4a7195adb5eb77f6e5531572 30-Apr-2014 Narayan Kamath <narayan@google.com> Fix errno checking for dalvik-cache creation.

On the host, it's possible for /tmp/foo/dalvik-cache/<isa> to
not exist, but for /tmp/foo/dalvik-cache to be already present.
In this scenario, the first mkdir() can fail with EEXIST.

Change-Id: Ia99f35a28f5ce4e3ac6c47933b79369240683091
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
a2cee18799d7e61adb037a4219adb23fef7d022b 17-Apr-2014 Christopher Ferris <cferris@google.com> Modify unwind to comply with stack parser tools.

Bug: 14081592

Change-Id: I6906b2575c74d64f1c3ba7602779b3a789de1c69
0f6784737882199197796b67b99e5f1ded383bee 11-Mar-2014 Ian Rogers <irogers@google.com> Unify 64bit int constant definitions.

LL and ULL prefixes are word size dependent, use the INT64_C and UINT64_C
macros instead.

Change-Id: I5b70027651898814fc0b3e9e22a18a1047e76cb9
474cc79e445d4d4fedabfc5b7acf648cf338fc26 07-Mar-2014 Brian Carlstrom <bdc@google.com> Use GetEntryPointFromQuickCompiledCode instead of GetQuickOatCodeOffset

The latter is meant for compile time use only when an offset is stored, instead of a pointer to code

Change-Id: I2fa9b8b3aaab0e6cfa1fc31c4d44aab0d9c3d30f
067d20fd2fddd947ce3a014d023e9de249082ebe 05-Mar-2014 Kenny Root <kroot@google.com> backtrace: use Java stack to help decode native

Before change:

native: usb_host_run+16 [0x400a43f9] (/libusbhost.so)
native: android::Vector<int>::do_move_forward(void*, void const*, unsigned int) const+54 [0x501b1c5b] (/libandroid_servers.so)
native: ??? [0x624de480] (/system@framework@boot.oat)
at com.android.server.usb.UsbHostManager.monitorUsbHostBus(Native method)
at com.android.server.usb.UsbHostManager.access$000(UsbHostManager.java:38)

After change:

native: usb_host_run+16 [0x400933f9] (libusbhost.so)
native: android::Vector<int>::do_move_forward(void*, void const*, unsigned int) const+54 [0x4e984c5b] (libandroid_servers.so)
native: Java_com_android_server_usb_UsbHostManager_monitorUsbHostBus__+92 [0x624de480] (system@framework@boot.oat)
at com.android.server.usb.UsbHostManager.monitorUsbHostBus(Native method)
at com.android.server.usb.UsbHostManager.access$000(UsbHostManager.java:38)

Change-Id: Iea550a251a12e9ba7df9582fd454093bfa4e90e0
cc460f11b5422d8ad93c64b9c1d79b694386c272 05-Mar-2014 Kenny Root <kroot@google.com> backtrace: trim of unneeded slash from solib

Previously we would output solib with an unnecessary slash:

native: art::JDWP::JdwpState::Run()+6018 [0x416bf3e3] (/libart.so)

Trim it off so it omits the slash:

native: art::JDWP::JdwpState::Run()+6018 [0x41961f6b] (libart.so)

Change-Id: I82baf1e624227858f5750ef57058474d21777451
13db9aa2d23e705d49c777abb45ba47e3747d873 27-Feb-2014 Brian Carlstrom <bdc@google.com> Avoid tripping up debuggered with the fatal crash abort

Bug: 13226780
Change-Id: Ia876d1dc7774713ec49fb8e6b0625f118fffb198
a1ce1fef2d49d1d537776a5308ace7102a815fe5 25-Feb-2014 Brian Carlstrom <bdc@google.com> Split up CommonTest into CommonRuntimeTest and CommonCompilerTest

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

(cherry picked from commit 446a13ff04dae7ef9c90584e7cf8e834ee841681)

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

Bug: 13186058

(cherry picked from commit 14ae4a873e91ae8cb1c00013579b5b058268879d)

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

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

Bug: 13186058
Change-Id: Idd58b15428e8849a93c1f57a9819fcb514f1545d
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
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
943af7dab1454517c5bd11a31ab99f260afb22d1 16-Jan-2014 Christopher Ferris <cferris@google.com> Change to support new BacktraceMap.

Change-Id: I291313583dca2c8e1e946504c442f5810f0fb477
16ce0923698d9a2df8a93d3895d2e851d8ac6fbf 10-Jan-2014 Ian Rogers <irogers@google.com> Make fast JNI part of pretty method output.

Change-Id: Ic4951a22d12e93d7f1e1af7ffbb08b4bb9b8f587
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
6e9aeb6633e42bc7d2265f73de28e521e3fc9c21 06-Nov-2013 Christopher Ferris <cferris@google.com> Update Backtrace::Create to use new define.

Change-Id: Ib345ef796c99d12fb3a4118f28edec7cbffa76d2
7020278bce98a0735dc6abcbd33bdf1ed2634f1d 23-Oct-2013 Dave Allison <dallison@google.com> Support hardware divide instruction

Bug: 11299025

Uses sdiv for division and a combo of sdiv, mul and sub for modulus.
Only does this on processors that are capable of the sdiv instruction, as determined
by the build system.

Also provides a command line arg --instruction-set-features= to allow cross compilation.
Makefile adds the --instruction-set-features= arg to build-time dex2oat runs and defaults
it to something obtained from the target architecture.

Provides a GetInstructionSetFeatures() function on CompilerDriver that can be
queried for various features. The only feature supported right now is hasDivideInstruction().

Also adds a few more instructions to the ARM disassembler

b/11535253 is an addition to this CL to be done later.

Change-Id: Ia8aaf801fd94bc71e476902749cf20f74eba9f68
7b5f0cf08f74ff36760a813888779d28a175982d 01-Nov-2013 Christopher Ferris <cferris@google.com> Use libbacktrace instead of libcorkscrew.

Also, removed the ignore frames of 2, this was causing threads to chop
the lower two frames. The original code assumed that the calls to decode
the frame were in the unwind trace, but that's not the case.

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

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

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

Change-Id: I80058652e11e7ea63457cc01a0cb48afe1c15543
19a083603128c2cded84f0e5ad59db2044b1d6b6 16-Oct-2013 Brian Carlstrom <bdc@google.com> Fix dumpsys meminfo for art

Bug: 10112253

(cherry picked from commit fb2f70c7678d33c2027cdd0285d8b5421876e6aa)

Change-Id: I149c30242f3c9ef1f67b95e26731c2505e840171
fb2f70c7678d33c2027cdd0285d8b5421876e6aa 16-Oct-2013 Brian Carlstrom <bdc@google.com> Fix dumpsys meminfo for art

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

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

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

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

Change-Id: I5ef0542823fbcae868aaa4a2457e8da7df0e9dae
2921201dce37ba40c55b89c0deca3c34bf64168e 13-Sep-2013 Brian Carlstrom <bdc@google.com> Remove some non-const references in utils

Change-Id: Ib2d3c39fadb6a750c68c37b0aa53daab155a65a3
a67249065e4c9b3cf4a7c081d95a78df28291ee9 23-Sep-2013 Ian Rogers <irogers@google.com> Move hot utf routines into -inl.h.

Change-Id: I7050d8282a7e5870b2bf671d6867c57625e00ccc
caacdf326cfe09decfca0a15c62ebe10b774e05e 20-Sep-2013 Anwar Ghuloum <anwarg@google.com> Fix dumpsys meminfo for art

BUG:10112253
Change-Id: I2a34cc0841bdcf922c4ab4eadda360313858a0d6
57dac6ed61a0a25c14d4e2fabc84435578d42360 16-Aug-2013 Jeff Hao <jeffhao@google.com> Fix sampling profiler to use thread's cpu clock.

The sampling profiler was using the sampling thread's cpu clock to
measure cpu time, instead of the sampled thread's cpu clock.

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

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

Bug: 9071417
Change-Id: I1ee9ff281867f90fba7a8ed8bbf06b33ac29d511
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
7934ac288acfb2552bb0b06ec1f61e5820d924a4 26-Jul-2013 Brian Carlstrom <bdc@google.com> Fix cpplint whitespace/comments issues

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