summaryrefslogtreecommitdiff
path: root/src/java_lang_System.cc
diff options
context:
space:
mode:
author Ian Rogers <irogers@google.com> 2012-02-28 13:51:55 -0800
committer Ian Rogers <irogers@google.com> 2012-02-28 15:21:27 -0800
commita15e67d5ee5aa9615596cee2be42c2b2caf128c6 (patch)
treecd126ce1e809688011385d521abf19c9c302d1b1 /src/java_lang_System.cc
parent9b5ee8837b4864b6ac114e9fead17bdeb04c6d55 (diff)
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
Diffstat (limited to 'src/java_lang_System.cc')
-rw-r--r--src/java_lang_System.cc11
1 files changed, 7 insertions, 4 deletions
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<uint8_t*>(dstArray->GetRawData());
- const uint8_t* srcBytes = reinterpret_cast<const uint8_t*>(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<uint8_t*>(dstArray->GetRawData(width));
+ const uint8_t* srcBytes = reinterpret_cast<const uint8_t*>(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<uint8_t*>(dstArray->GetRawData(width));
+ const uint8_t* srcBytes = reinterpret_cast<const uint8_t*>(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);