From a15e67d5ee5aa9615596cee2be42c2b2caf128c6 Mon Sep 17 00:00:00 2001 From: Ian Rogers Date: Tue, 28 Feb 2012 13:51:55 -0800 Subject: Remove pad word from arrays This change removes the 4 byte pad from all arrays except longs and doubles. It saves 76kb from the boot image, and will also reduce the size of arrays in the heap (and thereby reduce garbage collection). Change-Id: I3ff277d5bf14c57c0f7552215818e588ec6cc275 --- src/java_lang_System.cc | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src/java_lang_System.cc') diff --git a/src/java_lang_System.cc b/src/java_lang_System.cc index 78100cf688..b48cee9941 100644 --- a/src/java_lang_System.cc +++ b/src/java_lang_System.cc @@ -148,9 +148,6 @@ void System_arraycopy(JNIEnv* env, jclass, jobject javaSrc, jint srcPos, jobject return; } - uint8_t* dstBytes = reinterpret_cast(dstArray->GetRawData()); - const uint8_t* srcBytes = reinterpret_cast(srcArray->GetRawData()); - // Handle primitive arrays. if (srcComponentType->IsPrimitive() || dstComponentType->IsPrimitive()) { // If one of the arrays holds a primitive type the other array must hold the exact same type. @@ -162,7 +159,11 @@ void System_arraycopy(JNIEnv* env, jclass, jobject javaSrc, jint srcPos, jobject return; } - switch (srcArray->GetClass()->GetComponentSize()) { + size_t width = srcArray->GetClass()->GetComponentSize(); + uint8_t* dstBytes = reinterpret_cast(dstArray->GetRawData(width)); + const uint8_t* srcBytes = reinterpret_cast(srcArray->GetRawData(width)); + + switch (width) { case 1: memmove(dstBytes + dstPos, srcBytes + srcPos, length); break; @@ -185,6 +186,8 @@ void System_arraycopy(JNIEnv* env, jclass, jobject javaSrc, jint srcPos, jobject // Neither class is primitive. Are the types trivially compatible? const size_t width = sizeof(Object*); + uint8_t* dstBytes = reinterpret_cast(dstArray->GetRawData(width)); + const uint8_t* srcBytes = reinterpret_cast(srcArray->GetRawData(width)); if (dstArray == srcArray || dstComponentType->IsAssignableFrom(srcComponentType)) { // Yes. Bulk copy. COMPILE_ASSERT(sizeof(width) == sizeof(uint32_t), move32_assumes_Object_references_are_32_bit); -- cgit v1.2.3-59-g8ed1b