A char array copy optimization.
- 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
Change-Id: Ie88890eb65f011ca052b1f253f1b0e078ec24b6b
diff --git a/runtime/interpreter/interpreter.cc b/runtime/interpreter/interpreter.cc
index 59f0ac2..1677e80 100644
--- a/runtime/interpreter/interpreter.cc
+++ b/runtime/interpreter/interpreter.cc
@@ -127,7 +127,8 @@
args[0] = reinterpret_cast<uint32_t>(found);
EnterInterpreterFromInvoke(self, c, field.get(), args, NULL);
result->SetL(field.get());
- } else if (name == "void java.lang.System.arraycopy(java.lang.Object, int, java.lang.Object, int, int)") {
+ } else if (name == "void java.lang.System.arraycopy(java.lang.Object, int, java.lang.Object, int, int)" ||
+ name == "void java.lang.System.arraycopy(char[], int, char[], int, int)") {
// Special case array copying without initializing System.
Class* ctype = shadow_frame->GetVRegReference(arg_offset)->GetClass()->GetComponentType();
jint srcPos = shadow_frame->GetVReg(arg_offset + 1);