Make ByteBuffer.allocateDirect be 8 byte aligned.

Bug: 16449607

Change-Id: I4a854d55f49fe709965c6b6a769fb58c356627dc
Fix PriorityQueue.removeAt(.), call siftUp(.) if needed.

Bug: 10424240

(cherry picked from commit cc9eae501ba0064681e44e175f2afdc6c190d9ca)

Change-Id: Id62d69926235912d047c71975bdb541f1cf67ad7
Fix BIO_OutputStream::write to return the correct length.

This was leaving bad OpenSSL error states lying around for later
innocent calls to trip over.

Also clean up some of the other error reporting/handling.

Bug: 9822466
Bug: 10344304

(cherry picked from commit 9fcf4ef542e3bc040bba8ed3b40874e2ba6f2d9a)

Change-Id: Ib446417dc8eaaad0f517340a8c9b012f25bb9b15
A char array copy optimization (libcore).

- Based on measurements, copy char by char for arrays of length <= 64.
- With this change, the Ritz MemAllocBench got ~25% faster on Nexus 4
  and ~20% faster on host.
- This change only handles arraycopy calls in the core libraries and
  char arrays with the rest future work.

Bug: 7103825

(cherry picked from commit a3eb10feba1c3479ad99ef5c5323d011a5365f4b)

Change-Id: Ic002ced3bc2f2a682cd4b8cec07ede990edd7463
Fix an array copy optimization bug.

When we copy within the same array, we need to take care of
overlapping range cases and copy backward in some cases. Verifed with
TestBigDecimal and CTS tests.api.java.math.BigDecimalTest.

Bug: 11233386
Bug: 9986565

(cherry picked from commit 7f2504897c33ab3c312028b4546818bc2d037bc7)

Change-Id: I5243c01222c58c137ad2595048372022c689576d
Avoid running Runtime.gc() until we need to run finalization.

This prevents excessive explicit GC which are called from apps to get
good GC behavior on Dalvik. Calling System.gc() does not help on ART
since GC for alloc is much rarer.

If running finalizers is requested following a System.gc we remember
that a GC was requested and perform it ahead of finalization.

Bug: 12004934

Change-Id: Id1343ce8b5378c5f53c1e5649c06ddd045f56a3b
Fix String.replace("", x) for strings with non-0 offsets.

Also fix the sizing of the StringBuilder.

Bug: https://code.google.com/p/android/issues/detail?id=55129
Change-Id: Ic56763ef90451a25a0adfbe649b0a766e9b930f9
Finish off AutoCloseable.

Bug: 3484927
Change-Id: Ia0f5ad3db9807459ce6cda05bc2f53564b63b375
Finish fixing Zygote descriptor leakage problem

In order to prevent Zygote descriptors from leaking into the child
environment, they should be closed by the forked-off child process
before the child switches to the application UID.  These changes close
the descriptors via dup2(), substituting a descriptor open to
/dev/null in their place; this allows the Zygote Java code to close
the FileDescriptor objects cleanly.

This is a multi-project change: dalvik, art, libcore, frameworks/base,
and external/sepolicy are affected.  The CLs need to be approved
together, lest the build break or the software fail to boot.

Bug: 12114500
Change-Id: I8ea69de7b1cfbd811977a5629eb0af665f6dd66a
Remove old fork-and-specialize API

As promised, this is the cleanup patch-set which removes the
old native "fork and specialize" API, which has been replaced
by a slightly-enhanced one which can close the Zygote socket
descriptors in the Zygote child.

Change-Id: Icaeab730bee8638354dc664524e4118cdd946d2f