Migrate Buffer peek*array methods to art.

This is the first half of part 2 from
https://b.corp.google.com/issues/176942060#comment4.
We will later use art internals to improve performance.

Test: m
Test: old (https://paste.googleplex.com/5268030335483904) vs new (https://paste.googleplex.com/6393930242326528) benchmark results
Bug: 176942060

Change-Id: I257ad28a5ef2c0f222ce65a30c8cf72e360d5e22
diff --git a/luni/src/main/native/libcore_io_Memory.cpp b/luni/src/main/native/libcore_io_Memory.cpp
index b015988..851cb9f 100644
--- a/luni/src/main/native/libcore_io_Memory.cpp
+++ b/luni/src/main/native/libcore_io_Memory.cpp
@@ -109,55 +109,6 @@
     return *cast<const jbyte*>(srcAddress);
 }
 
-static void Memory_peekByteArray(JNIEnv* env, jclass, jlong srcAddress, jbyteArray dst, jint dstOffset, jint byteCount) {
-    env->SetByteArrayRegion(dst, dstOffset, byteCount, cast<const jbyte*>(srcAddress));
-}
-
-// Implements the peekXArray methods:
-// - For unswapped access, we just use the JNI SetXArrayRegion functions.
-// - For swapped access, we use GetXArrayElements and our own copy-and-swap routines.
-//   GetXArrayElements is disproportionately cheap on Dalvik because it doesn't copy (as opposed
-//   to Hotspot, which always copies). The SWAP_FN copies and swaps in one pass, which is cheaper
-//   than copying and then swapping in a second pass. Depending on future VM/GC changes, the
-//   swapped case might need to be revisited.
-#define PEEKER(SCALAR_TYPE, JNI_NAME, SWAP_TYPE, SWAP_FN) { \
-    if (swap) { \
-        Scoped ## JNI_NAME ## ArrayRW elements(env, dst); \
-        if (elements.get() == NULL) { \
-            return; \
-        } \
-        const SWAP_TYPE* src = cast<const SWAP_TYPE*>(srcAddress); \
-        SWAP_FN(reinterpret_cast<SWAP_TYPE*>(elements.get()) + dstOffset, src, count); /*NOLINT*/ \
-    } else { \
-        const SCALAR_TYPE* src = cast<const SCALAR_TYPE*>(srcAddress); \
-        env->Set ## JNI_NAME ## ArrayRegion(dst, dstOffset, count, src); \
-    } \
-}
-
-static void Memory_peekCharArray(JNIEnv* env, jclass, jlong srcAddress, jcharArray dst, jint dstOffset, jint count, jboolean swap) {
-    PEEKER(jchar, Char, jshort, swapShorts);
-}
-
-static void Memory_peekDoubleArray(JNIEnv* env, jclass, jlong srcAddress, jdoubleArray dst, jint dstOffset, jint count, jboolean swap) {
-    PEEKER(jdouble, Double, jlong, swapLongs);
-}
-
-static void Memory_peekFloatArray(JNIEnv* env, jclass, jlong srcAddress, jfloatArray dst, jint dstOffset, jint count, jboolean swap) {
-    PEEKER(jfloat, Float, jint, swapInts);
-}
-
-static void Memory_peekIntArray(JNIEnv* env, jclass, jlong srcAddress, jintArray dst, jint dstOffset, jint count, jboolean swap) {
-    PEEKER(jint, Int, jint, swapInts);
-}
-
-static void Memory_peekLongArray(JNIEnv* env, jclass, jlong srcAddress, jlongArray dst, jint dstOffset, jint count, jboolean swap) {
-    PEEKER(jlong, Long, jlong, swapLongs);
-}
-
-static void Memory_peekShortArray(JNIEnv* env, jclass, jlong srcAddress, jshortArray dst, jint dstOffset, jint count, jboolean swap) {
-    PEEKER(jshort, Short, jshort, swapShorts);
-}
-
 static void Memory_pokeByte(JNIEnv*, jclass, jlong dstAddress, jbyte value) {
     *cast<jbyte*>(dstAddress) = value;
 }
@@ -290,19 +241,13 @@
     env->ReleasePrimitiveArrayCritical(srcArray, srcBytes, 0);
 }
 
+// The remaining Memory methods are contained in art/runtime/native/libcore_io_Memory.cc
 static JNINativeMethod gMethods[] = {
     NATIVE_METHOD(Memory, memmove, "(Ljava/lang/Object;ILjava/lang/Object;IJ)V"),
     FAST_NATIVE_METHOD(Memory, peekByte, "(J)B"),
-    FAST_NATIVE_METHOD(Memory, peekByteArray, "(J[BII)V"),
-    FAST_NATIVE_METHOD(Memory, peekCharArray, "(J[CIIZ)V"),
-    FAST_NATIVE_METHOD(Memory, peekDoubleArray, "(J[DIIZ)V"),
-    FAST_NATIVE_METHOD(Memory, peekFloatArray, "(J[FIIZ)V"),
     FAST_NATIVE_METHOD(Memory, peekIntNative, "(J)I"),
-    FAST_NATIVE_METHOD(Memory, peekIntArray, "(J[IIIZ)V"),
     FAST_NATIVE_METHOD(Memory, peekLongNative, "(J)J"),
-    FAST_NATIVE_METHOD(Memory, peekLongArray, "(J[JIIZ)V"),
     FAST_NATIVE_METHOD(Memory, peekShortNative, "(J)S"),
-    FAST_NATIVE_METHOD(Memory, peekShortArray, "(J[SIIZ)V"),
     FAST_NATIVE_METHOD(Memory, pokeByte, "(JB)V"),
     NATIVE_METHOD(Memory, pokeByteArray, "(J[BII)V"),
     NATIVE_METHOD(Memory, pokeCharArray, "(J[CIIZ)V"),