From: jzhou Date: Sat, 19 Feb 2011 00:55:50 +0000 (+0000) Subject: Add some runtime support for MGC X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=c2946b5ce88dc24554c081a79f194d3f0fc929f7;p=IRC.git Add some runtime support for MGC --- diff --git a/Robust/src/ClassLibrary/gnu/Double.java b/Robust/src/ClassLibrary/gnu/Double.java index 93ab44ca..ea5c9334 100644 --- a/Robust/src/ClassLibrary/gnu/Double.java +++ b/Robust/src/ClassLibrary/gnu/Double.java @@ -287,7 +287,7 @@ public final class Double extends Number //implements Comparable } public static native double nativeparsedouble(String str); - public static native double nativeparsedouble(byte[] str, int start, int length); + public static native double nativeparsedouble(int start, int length, byte[] str); /** * Return true if the double has the same diff --git a/Robust/src/Runtime/bamboo/multicoreruntime.c b/Robust/src/Runtime/bamboo/multicoreruntime.c index ad956737..f08c9447 100644 --- a/Robust/src/Runtime/bamboo/multicoreruntime.c +++ b/Robust/src/Runtime/bamboo/multicoreruntime.c @@ -5,6 +5,7 @@ #include "runtime_arch.h" #include "GenericHashtable.h" #include "structdefs.h" +#include "methodheaders.h" #include "mem.h" #ifndef RAW #include @@ -63,7 +64,7 @@ void injectinstructionfailure() { #ifdef D___Double______nativeparsedouble____L___String___ double CALL01(___Double______nativeparsedouble____L___String___,struct ___String___ * ___str___) { - int length=VAR(___str___)->___count___; + /*int length=VAR(___str___)->___count___; int maxlength=(length>60) ? 60 : length; char str[maxlength+1]; struct ArrayObject * chararray=VAR(___str___)->___value___; @@ -73,13 +74,32 @@ double CALL01(___Double______nativeparsedouble____L___String___,struct ___String str[i]=((short *)(((char *)&chararray->___length___)+sizeof(int)))[i+offset]; } str[i]=0; - double d=atof(str); + double d=atof(str);*/ + printf("Unimplemented Double.nativeparsedouble(S) \n"); + double d = 0.0; + return d; +} +#endif + +#ifdef D___Double______nativeparsedouble_____AR_B_I_I +double CALL23(___Double______nativeparsedouble_____AR_B_I_I, int start, int length,int start,int length,struct ArrayObject * ___str___) { + /*int maxlength=(length>60)?60:length; + char str[maxlength+1]; + struct ArrayObject * bytearray=VAR(___str___); + int i; + for(i=0; i___length___)+sizeof(int))[i+start]; + } + str[i]=0; + double d=atof(str);*/ + printf("Unimplemented Double.nativeparsedouble() \n"); + double d = 0.0; return d; } #endif #ifdef D___String______convertdoubletochar____D__AR_C -int CALL12(___String______convertdoubletochar____D__AR_C, double ___val___, double ___val___, struct ArrayObject ___chararray___) { +int CALL12(___String______convertdoubletochar____D__AR_C, double ___val___, double ___val___, struct ArrayObject * ___chararray___) { int length=VAR(___chararray___)->___length___; char str[length]; int i; @@ -97,21 +117,107 @@ int CALL12(___String______convertdoubletochar____D__AR_C, double ___val___, doub } #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 + +#ifdef D___System______arraycopy____L___Object____I_L___Object____I_I +void arraycopy(struct ___Object___ *src, int srcPos, struct ___Object___ *dst, int destPos, int length) { + int dsttype=((int *)dst)[0]; + int srctype=((int *)src)[0]; + + //not an array or type mismatch + if (dsttype___length___; + int srclength=aosrc->___length___; + + if (length<=0) + return; + if (srcPos+length>srclength) + return; + if (destPos+length>dstlength) + return; + + unsigned INTPTR *pointer=pointerarray[srctype]; + if (pointer==0) { + int elementsize=classsize[srctype]; + int size=length*elementsize; + //primitives + memcpy(((char *)&aodst->___length___)+sizeof(int)+destPos*elementsize, ((char *)&aosrc->___length___)+sizeof(int)+srcPos*elementsize, size); + } else { + //objects + int i; + for(i=0;i___length___)+sizeof(int)))[i+srcPos]; + int ptrtype=((int *)ptr)[0]; + //hit an object + ((struct ___Object___ **)(((char*) &aodst->___length___)+sizeof(int)))[i+destPos]=ptr; + } + } +} + +void CALL35(___System______arraycopy____L___Object____I_L___Object____I_I, int ___srcPos___, int ___destPos___, int ___length___, struct ___Object___ * ___src___, int ___srcPos___, struct ___Object___ * ___dst___, int ___destPos___, int ___length___) { + arraycopy(VAR(___src___), ___srcPos___, VAR(___dst___), ___destPos___, ___length___); +} +#endif + void CALL11(___System______exit____I,int ___status___, int ___status___) { BAMBOO_EXIT(___status___); } +#ifdef D___Vector______removeElement_____AR_L___Object____I_I void CALL23(___Vector______removeElement_____AR_L___Object____I_I, int ___index___, int ___size___, struct ArrayObject * ___array___, int ___index___, int ___size___) { char* offset=((char *)(&VAR(___array___)->___length___))+sizeof(unsigned int)+sizeof(void *)*___index___; memmove(offset, offset+sizeof(void *),(___size___-___index___-1)*sizeof(void *)); } +#endif void CALL11(___System______printI____I,int ___status___, int ___status___) { BAMBOO_DEBUGPRINT(0x1111); BAMBOO_DEBUGPRINT_REG(___status___); } -long CALL00(___System______currentTimeMillis____) { +long long CALL00(___System______currentTimeMillis____) { // not supported in MULTICORE version return -1; } diff --git a/Robust/src/Runtime/math.c b/Robust/src/Runtime/math.c index 0bd678e8..683c033c 100644 --- a/Robust/src/Runtime/math.c +++ b/Robust/src/Runtime/math.c @@ -81,3 +81,10 @@ float CALL22(___Math______powf____F_F, float ___a___, float ___b___, float ___a_ float CALL11(___Math______ceilf____F, float ___a___, float ___a___) { return ceilf(___a___); } + +#ifdef MGC +float CALL22(___Math______IEEEremainder____F_F, float ___a___, float ___b___, float ___a___, float ___b___) { + return fmod(___a___, ___b___); +} + +#endif