From db09adc0d43258e3699172c021849e791fe75c0a Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Thu, 4 Jun 2009 17:19:48 -0600 Subject: [PATCH] allow copies between object arrays of different types in System.arraycopy --- src/builtin.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/builtin.cpp b/src/builtin.cpp index a1280163d4..fe1cf34c6f 100644 --- a/src/builtin.cpp +++ b/src/builtin.cpp @@ -61,6 +61,16 @@ enumerateThreads(Thread* t, Thread* x, object array, unsigned* index, } } +bool +compatibleArrayTypes(Thread* t, object a, object b) +{ + return classArrayElementSize(t, a) + and classArrayElementSize(t, b) + and (a == b + or (not ((classVmFlags(t, a) & PrimitiveFlag) + or (classVmFlags(t, b) & PrimitiveFlag)))); +} + } // namespace extern "C" JNIEXPORT int64_t JNICALL @@ -528,7 +538,9 @@ Avian_java_lang_System_arraycopy int32_t length = arguments[4]; if (LIKELY(src and dst)) { - if (LIKELY(objectClass(t, src) == objectClass(t, dst))) { + if (LIKELY(compatibleArrayTypes + (t, objectClass(t, src), objectClass(t, dst)))) + { unsigned elementSize = classArrayElementSize(t, objectClass(t, src)); if (LIKELY(elementSize)) {