diff options
author | Tom Tromey <tromey@cygnus.com> | 1999-11-25 00:36:51 +0000 |
---|---|---|
committer | Tom Tromey <tromey@gcc.gnu.org> | 1999-11-25 00:36:51 +0000 |
commit | 93d455621810ca1fcb759fcb6cc4c237ba02a584 (patch) | |
tree | 35bb29ca80faf5479ebdd7ea3a0fbd2086f9fc89 /libjava/java | |
parent | fc39d3710887c5a0d560d93e29e8c222d40bf072 (diff) | |
download | gcc-93d455621810ca1fcb759fcb6cc4c237ba02a584.zip gcc-93d455621810ca1fcb759fcb6cc4c237ba02a584.tar.gz gcc-93d455621810ca1fcb759fcb6cc4c237ba02a584.tar.bz2 |
prims.cc (_Jv_NewObjectArray): Use _Jv_GetArrayElementFromElementType.
* prims.cc (_Jv_NewObjectArray): Use
_Jv_GetArrayElementFromElementType.
(_Jv_NewPrimArray): Likewise.
* java/lang/natObject.cc (clone): Use
_Jv_GetArrayElementFromElementType instead of sizeof.
* java/lang/natSystem.cc (arraycopy): Use
_Jv_GetArrayElementFromElementType.
* include/jvm.h (_Jv_GetArrayElementFromElementType): New
function.
From-SVN: r30655
Diffstat (limited to 'libjava/java')
-rw-r--r-- | libjava/java/lang/natObject.cc | 5 | ||||
-rw-r--r-- | libjava/java/lang/natSystem.cc | 46 |
2 files changed, 6 insertions, 45 deletions
diff --git a/libjava/java/lang/natObject.cc b/libjava/java/lang/natObject.cc index 22632c5..0ca5a58 100644 --- a/libjava/java/lang/natObject.cc +++ b/libjava/java/lang/natObject.cc @@ -84,7 +84,10 @@ java::lang::Object::clone (void) r = _Jv_NewObjectArray (array->length, comp, NULL); eltsize = sizeof (jobject); } - size = sizeof (__JArray) + array->length * eltsize; + // We can't use sizeof on __JArray because we must account for + // alignment of the element type. + size = (_Jv_GetArrayElementFromElementType (array, comp) - (char *) array + + array->length * eltsize); } else { diff --git a/libjava/java/lang/natSystem.cc b/libjava/java/lang/natSystem.cc index 268c1cc..4e4316a 100644 --- a/libjava/java/lang/natSystem.cc +++ b/libjava/java/lang/natSystem.cc @@ -124,52 +124,10 @@ java::lang::System::arraycopy (jobject src, jint src_offset, const size_t size = (prim ? src_comp->size() : sizeof elements((jobjectArray)src)[0]); - // In an ideal world we would do this via a virtual function in - // __JArray. However, we can't have virtual functions in - // __JArray due to the need to copy an array's virtual table in - // _Jv_FindArrayClass. - // We can't just pick a single subtype of __JArray to use due to - // alignment concerns. - char *src_elts = NULL; - if (! prim) - src_elts = (char *) elements ((jobjectArray) src); - else if (src_comp == JvPrimClass (byte)) - src_elts = (char *) elements ((jbyteArray) src); - else if (src_comp == JvPrimClass (short)) - src_elts = (char *) elements ((jshortArray) src); - else if (src_comp == JvPrimClass (int)) - src_elts = (char *) elements ((jintArray) src); - else if (src_comp == JvPrimClass (long)) - src_elts = (char *) elements ((jlongArray) src); - else if (src_comp == JvPrimClass (boolean)) - src_elts = (char *) elements ((jbooleanArray) src); - else if (src_comp == JvPrimClass (char)) - src_elts = (char *) elements ((jcharArray) src); - else if (src_comp == JvPrimClass (float)) - src_elts = (char *) elements ((jfloatArray) src); - else if (src_comp == JvPrimClass (double)) - src_elts = (char *) elements ((jdoubleArray) src); + char *src_elts = _Jv_GetArrayElementFromElementType (src, src_comp); src_elts += size * src_offset; - char *dst_elts = NULL; - if (! prim) - dst_elts = (char *) elements ((jobjectArray) dst); - else if (dst_comp == JvPrimClass (byte)) - dst_elts = (char *) elements ((jbyteArray) dst); - else if (dst_comp == JvPrimClass (short)) - dst_elts = (char *) elements ((jshortArray) dst); - else if (dst_comp == JvPrimClass (int)) - dst_elts = (char *) elements ((jintArray) dst); - else if (dst_comp == JvPrimClass (long)) - dst_elts = (char *) elements ((jlongArray) dst); - else if (dst_comp == JvPrimClass (boolean)) - dst_elts = (char *) elements ((jbooleanArray) dst); - else if (dst_comp == JvPrimClass (char)) - dst_elts = (char *) elements ((jcharArray) dst); - else if (dst_comp == JvPrimClass (float)) - dst_elts = (char *) elements ((jfloatArray) dst); - else if (dst_comp == JvPrimClass (double)) - dst_elts = (char *) elements ((jdoubleArray) dst); + char *dst_elts = _Jv_GetArrayElementFromElementType (dst, dst_comp); dst_elts += size * dst_offset; #if HAVE_MEMMOVE |