Fix crash when debugging exception

Fixes a crash when detaching the debugger during an exception event. The cause
is a concurrent modification of Instrumentation::exception_caught_listeners_
list (consequence of debugger being detached) while we loop over its elements.

Workaround the issue by making a copy of the listeners list.

Bug: 13738672
Change-Id: I56b84c5c8f31d6fbda1ba7cb35caeefc5e7ca60f
Speed up single-stepping

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

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

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

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

Bug: 13577964
Change-Id: If6fa198a676b515cd474b8c4d7bf7ef3626f2dc7
Avoid allocating OatFile::OatClass on the heap.

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

Change-Id: Ic7098109028a5b49e39ef626f877de86e732ed18
Fix thread join hangs

Current implementation notifies only one of joining threads on thread exit.
This causes the other joining threads to hang.

This patch notifies all joining threads: just call NotifyAll() instead of Notify().

Change-Id: If75f101d3d3d876f1aa7dcf537e56a37cc347803
Signed-off-by: Yevgeny Rouban <yevgeny.y.rouban@intel.com>
Fix typo in ISA centralization

X86 needs sign-extension.

Change-Id: I1253fbc9aa0e732e37b976a0723ec89155e7e2e7
Merge "Fix typo in ISA centralization"
Merge "Fix thread join hangs"
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
Use LIRSlowPath for throwing NPE.

Get rid of launchpads for throwing NPE and use LIRSlowPath instead.
Also clean up some code of using LIRSlowPath for checking div
by zero.

Bug: 13170824

Change-Id: I0c20a49c39feff3eb1f147755e557d9bc0ff15bb
Merge "Decrease target utilization for foreground apps."
Build dex2oat as 64b for the target when using zygote64

In single-zygote 64b builds we should build dex2oat as 64b to
avoid installd issues

Change-Id: I5f281d90fbd44abbca4182e39162b184be9f1b35
Fix volatile wide put/get to be atomic on x86 arch

Current implementation puts memory barriers for volatile fields.
Volatile semantics needs atomicity, which are not guaranteed by memory barriers.

The patch forces all wide volatile fields to be loaded/stored using
xmm registers.

Change-Id: Ie78e186d13ffa237e6e93747b71d26651fa02866
Signed-off-by: Yevgeny Rouban <yevgeny.y.rouban@intel.com>
Merge "Fix volatile wide put/get to be atomic on x86 arch"
Disable another timing sensitive test on dist builds

Change-Id: I1c0dc16ff22b23dbd238cbeba3f4c078c3ffeaed
Merge "Build dex2oat as 64b for the target when using zygote64"
Merge "Disable another timing sensitive test on dist builds"
Preparation for transition to libc++.

Move the dependency on libc++ to its own makefile so that we can switch in a
single place between libc++ and stlport.

Change-Id: Ie61e7d054dcd049e36d5e7298c27d8a4abe6edf7
Merge "Preparation for transition to libc++."
ART: Fixes an issue with REX prefix for instructions with no ModRM byte

There are instructions (such as push, pop, mov) in the x86 ISA
that encode first operands in their opcodes (opcode + reg).
In order to enable an extended 64bit registers (R9-R15) a special
prefix REX.B should be emitted before such instructions.

This patch fixes the issue when REX.R prefix was emitted before
instructions with no MorRM byte. So, the REX-prefix was simply
ignored by CPU for those instructions whose operands are encoded
in their opcodes.

This patch makes the jni_compiler_test passed with JNI compiler
enabled for x86_64 target.

Change-Id: Ib84da1cf9f8ff96bd7afd4e0fc53078f3231f8ec
Signed-off-by: Vladimir Kostyukov <vladimir.kostyukov@intel.com>
String.IndexOf method handles negative start index value in incorrect way

The standard implementation of String.IndexOf converts the negative value of
the start index to 0 and searching will start from the beginning of the string.
But current implementation may start searching from the incorrect memory
offset, that can lead to sigsegv or return incorrect result.
This patch adds the handler for cases when fromIndex is negative.

Change-Id: I3ac86290712789559eaf5e46bef0006872395bfa
Signed-off-by: Alexei Zavjalov <alexei.zavjalov@intel.com>