From: bdemsky Date: Thu, 2 Jul 2009 04:07:34 +0000 (+0000) Subject: add native copy method X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=4daf2efc796f8736a48491b76e3d09b576e7a325;p=IRC.git add native copy method --- diff --git a/Robust/src/ClassLibrary/System.java b/Robust/src/ClassLibrary/System.java index ef6caa03..1aa3d089 100644 --- a/Robust/src/ClassLibrary/System.java +++ b/Robust/src/ClassLibrary/System.java @@ -52,4 +52,6 @@ public class System { public static native void rangePrefetch(Object o, short[] offsets); + public static native void deepArrayCopy(Object dst, Object src); + } diff --git a/Robust/src/Runtime/runtime.c b/Robust/src/Runtime/runtime.c index c175242f..e7de7f78 100644 --- a/Robust/src/Runtime/runtime.c +++ b/Robust/src/Runtime/runtime.c @@ -140,6 +140,45 @@ int CALL12(___String______convertdoubletochar____D__AR_C, double ___val___, doub return num; } #endif +#ifdef D___System______deepArrayCopy____L___Object____L___Object___ +void deepArrayCopy(struct ___Object___ * dst, struct ___Object___ * src) { + int dsttype=((int *)dst)[0]; + int srctype=((int *)src)[0]; + if (dsttype___length___; + int srclength=aosrc->___length___; + if (dstlength!=srclength) + return; + unsigned INTPTR *pointer=pointerarray[srctype]; + if (pointer==0) { + int elementsize=classsize[srctype]; + int size=srclength*elementsize; + //primitives + memcpy(((char *)&aodst->___length___)+sizeof(int) , ((char *)&aosrc->___length___)+sizeof(int), size); + } else { + //objects + int i; + for(i=0;i___length___)+sizeof(int)))[i]; + int ptrtype=((int *)ptr)[0]; + if (ptrtype>=NUMCLASSES) { + struct ___Object___ * dstptr=((struct ___Object___**)(((char*) &aodst->___length___)+sizeof(int)))[i]; + deepArrayCopy(dstptr,ptr); + } else { + //hit an object + ((struct ___Object___ **)(((char*) &aodst->___length___)+sizeof(int)))[i]=ptr; + } + } + } +} + +void CALL02(___System______deepArrayCopy____L___Object____L___Object___, struct ___Object___ * ___dst___, struct ___Object___ * ___src___) { + deepArrayCopy(VAR(___dst___), VAR(___src___)); +} +#endif void CALL11(___System______exit____I,int ___status___, int ___status___) { #ifdef TRANSSTATS