}
private void computeCallsFlags(FlatMethod fm, Hashtable parammap, Set tagbindings, Set newflags) {
- System.out.println(" "+fm.getMethod());
Set nodeset=fm.getNodeSet();
for(Iterator nodeit=nodeset.iterator();nodeit.hasNext();) {
FlatNode fn=(FlatNode)nodeit.next();
nativeWrite(b, offset, len);
}
+ private native void nativeBindFD(int fd);
private native int nativeRead(byte[] b);
private native void nativeWrite(byte[] b, int offset, int len);
private native void nativeClose();
inline int Objnext(struct ObjectIterator *thisvar) {
int curr=thisvar->cur->data;
- thisvar->cur=thisvar->cur->next;
+ thisvar->cur=thisvar->cur->lnext;
return curr;
}
return ptr->key;
}
+int RuntimeHashremovekey(struct RuntimeHash *thisvar, int key) {
+ unsigned int hashkey = (unsigned int)key % thisvar->size;
+
+ struct RuntimeNode **ptr = &thisvar->bucket[hashkey];
+ int i;
+
+ while (*ptr) {
+ if ((*ptr)->key == key) {
+ struct RuntimeNode *toremove=*ptr;
+ *ptr=(*ptr)->next;
+
+ if (toremove->lprev!=NULL)
+ toremove->lprev->lnext=toremove->lnext;
+ else
+ thisvar->listhead=toremove->lnext;
+ if (toremove->lnext!=NULL)
+ toremove->lnext->lprev=toremove->lprev;
+ else
+ thisvar->listtail=toremove->lprev;
+ RUNFREE(toremove);
+
+ thisvar->numelements--;
+ return 1;
+ }
+ ptr = &((*ptr)->next);
+ }
+
+ return 0;
+}
+
int RuntimeHashremove(struct RuntimeHash *thisvar, int key, int data) {
unsigned int hashkey = (unsigned int)key % thisvar->size;
inline int Runnext(struct RuntimeIterator *thisvar) {
int curr=thisvar->cur->data;
- thisvar->cur=thisvar->cur->next;
+ thisvar->cur=thisvar->cur->lnext;
+ return curr;
}
inline int Runkey(struct RuntimeIterator *thisvar) {
void RuntimeHashrehash(struct RuntimeHash * thisvar);
int RuntimeHashadd(struct RuntimeHash *, int key, int data);
+int RuntimeHashremovekey(struct RuntimeHash *,int key);
int RuntimeHashremove(struct RuntimeHash *,int key, int data);
bool RuntimeHashcontainskey(struct RuntimeHash *,int key);
bool RuntimeHashcontainskeydata(struct RuntimeHash *,int key, int data);
}
}
+void checkvalid(void * ptr) {
+ if (ptr>=curr_heapbase&&ptr<=curr_heaptop) {
+ printf("Valid\n");
+ }
+}
+
+void validitycheck(struct RuntimeHash *forward, struct RuntimeHash *reverse) {
+ struct RuntimeIterator rit;
+ RuntimeHashiterator(forward, &rit);
+ while(RunhasNext(&rit)) {
+ struct ___Object___ * data=(struct ___Object___*) Runnext(&rit);
+ int type=data->type;
+ unsigned int * pointer=pointerarray[type];
+ int size;
+ int i;
+ if (pointer!=0&&((int)pointer)!=1) {
+ size=pointer[0];
+ for(i=1;i<=size;i++) {
+ int offset=pointer[i];
+ void * ptr=*(void **) (((int) data) + offset);
+ if (ptr!=NULL&&!RuntimeHashcontainskey(reverse, (int) ptr)) {
+ printf("Bad\n");
+ }
+ checkvalid(ptr);
+ }
+ }
+ }
+
+ RuntimeHashiterator(reverse, &rit);
+ while(RunhasNext(&rit)) {
+ struct ___Object___ * data=(struct ___Object___*) Runkey(&rit);
+ Runnext(&rit);
+ int type=data->type;
+ unsigned int * pointer=pointerarray[type];
+ int size;
+ int i;
+ if (pointer!=0&&((int)pointer)!=1) {
+ size=pointer[0];
+ for(i=1;i<=size;i++) {
+ int offset=pointer[i];
+ void * ptr=*(void **) (((int) data) + offset);
+ if (ptr!=NULL&&!RuntimeHashcontainskey(reverse, (int) ptr)) {
+ printf("Bad2\n");
+ }
+ checkvalid(ptr);
+ }
+ }
+ }
+ }
+
+
+
void ** makecheckpoint(int numparams, void ** srcpointer, struct RuntimeHash * forward, struct RuntimeHash * reverse) {
#ifdef PRECISE_GC
void **newarray=cpmalloc(sizeof(void *)*numparams);
{
void *cpy;
RuntimeHashget(forward, (int) ptr, (int *) &cpy);
+
unsigned int * pointer=pointerarray[type];
#ifdef TASK
if (type==TAGTYPE) {
void *objptr=((struct ___TagDescriptor___*)ptr)->flagptr;
if (objptr!=NULL) {
- void * copy=createcopy(objptr);
- RuntimeHashadd(forward, (int) objptr, (int) copy);
- RuntimeHashadd(reverse, (int) copy, (int) objptr);
- RuntimeHashadd(todo, (int) objptr, (int) objptr);
- ((struct ___TagDescriptor___*)cpy)->flagptr=copy;
+ if (!RuntimeHashcontainskey(forward, (int) objptr)) {
+ void *copy=createcopy(objptr);
+ RuntimeHashadd(forward, (int) objptr, (int) copy);
+ RuntimeHashadd(reverse, (int) copy, (int) objptr);
+ RuntimeHashadd(todo, (int) objptr, (int) objptr);
+ ((struct ___TagDescriptor___*)cpy)->flagptr=copy;
+ } else {
+ RuntimeHashget(forward, (int) objptr, (int *) &(((struct ___TagDescriptor___*) cpy)->flagptr));
+ }
}
} else
#endif
return -1;
}
+#ifdef TASK
+int CALL12(___Socket______nativeBindFD____I, int ___fd___, struct ___Socket___ * ___this___, int ___fd___) {
+ if (RuntimeHashcontainskey(fdtoobject, ___fd___))
+ RuntimeHashremovekey(fdtoobject, ___fd___);
+ RuntimeHashadd(fdtoobject, ___fd___, (int) VAR(___this___));
+ addreadfd(___fd___);
+}
+#endif
+
int CALL12(___Socket______nativeBind_____AR_B_I, int ___port___, struct ArrayObject * ___address___, int ___port___) {
int fd;