}
private void generateFlatNew(FlatMethod fm, LocalityBinding lb, FlatNew fn, PrintWriter output) {
- String isglobal="";
- if (fn.isGlobal())
- isglobal="global";
if (fn.getType().isArray()) {
int arrayid=state.getArrayNumber(fn.getType())+state.numClasses();
- if (GENERATEPRECISEGC) {
- output.println(generateTemp(fm,fn.getDst(),lb)+"=allocate_newarray"+isglobal+"(&"+localsprefix+", "+arrayid+", "+generateTemp(fm, fn.getSize(),lb)+");");
+ if (fn.isGlobal()) {
+ output.println(generateTemp(fm,fn.getDst(),lb)+"=allocate_newarrayglobal(trans, "+arrayid+", "+generateTemp(fm, fn.getSize(),lb)+");");
+ } else if (GENERATEPRECISEGC) {
+ output.println(generateTemp(fm,fn.getDst(),lb)+"=allocate_newarray(&"+localsprefix+", "+arrayid+", "+generateTemp(fm, fn.getSize(),lb)+");");
} else {
- output.println(generateTemp(fm,fn.getDst(),lb)+"=allocate_newarray"+isglobal+"("+arrayid+", "+generateTemp(fm, fn.getSize(),lb)+");");
+ output.println(generateTemp(fm,fn.getDst(),lb)+"=allocate_newarray("+arrayid+", "+generateTemp(fm, fn.getSize(),lb)+");");
}
} else {
- if (GENERATEPRECISEGC) {
- output.println(generateTemp(fm,fn.getDst(),lb)+"=allocate_new"+isglobal+"(&"+localsprefix+", "+fn.getType().getClassDesc().getId()+");");
+ if (fn.isGlobal()) {
+ output.println(generateTemp(fm,fn.getDst(),lb)+"=allocate_newglobal(trans, "+fn.getType().getClassDesc().getId()+");");
+ } else if (GENERATEPRECISEGC) {
+ output.println(generateTemp(fm,fn.getDst(),lb)+"=allocate_new(&"+localsprefix+", "+fn.getType().getClassDesc().getId()+");");
} else {
- output.println(generateTemp(fm,fn.getDst(),lb)+"=allocate_new"+isglobal+"("+fn.getType().getClassDesc().getId()+");");
+ output.println(generateTemp(fm,fn.getDst(),lb)+"=allocate_new("+fn.getType().getClassDesc().getId()+");");
}
}
}
int dstmStartup(const char *);
void transInit();
-void * dstmalloc(int size);
+void * dstmalloc(transrecord_t *trans, int size);
void randomdelay(void);
transrecord_t *transStart();
pthread_mutex_unlock(&pqueue.qlock);
}
-static int objid=1;
-/* This function allocates an object */
-void * dstmalloc(int size) {
- objheader_t * newobj=(objheader_t *)objstrAlloc(mainobjstore, size+sizeof(objheader_t));
- OID(newobj)=objid;
- newobj->version=1;
- newobj->rcount=0;
- STATUS(newobj)=NEW;
- objid+=2;
+/* This function allocates an object on the local machine */
+//FIXME
+
+void * dstmalloc(transrecord_t *trans, int size) {
+ objheader_t * newobj=(objheader_t *)objstrAlloc(trans->cache, size+sizeof(objheader_t));
+ //Need to assign OID
+
return newobj;
}
/* Object allocation function */
#ifdef DSTM
-void * allocate_newglobal(void * ptr, int type) {
- struct ___Object___ * v=(struct ___Object___ *) dstmalloc(classsize[type]);
+void * allocate_newglobal(transrecord_t *trans, int type) {
+ struct ___Object___ * v=(struct ___Object___ *) dstmalloc(trans, classsize[type]);
v->type=type;
#ifdef THREADS
v->tid=0;
/* Array allocation function */
-struct ArrayObject * allocate_newarrayglobal(void * ptr, int type, int length) {
- struct ArrayObject * v=(struct ArrayObject *)dstmalloc(classsize[type]);
+struct ArrayObject * allocate_newarrayglobal(transrecord_t *trans, int type, int length) {
+ struct ArrayObject * v=(struct ArrayObject *)dstmalloc(trans, classsize[type]);
v->type=type;
if (length<0) {
printf("ERROR: negative array\n");
extern jmp_buf error_handler;
extern int instructioncount;
extern int failurecount;
+#ifdef DSTM
+#include "dstm.h"
+#endif
#define TAGARRAYINTERVAL 10
#define OBJECTARRAYINTERVAL 10
#define ARRAYGET(array, type, index) \
((type *)(&(& array->___length___)[1]))[index]
-#ifdef PRECISE_GC
-#include "garbage.h"
#ifdef DSTM
-void * allocate_newglobal(void *, int type);
-struct ArrayObject * allocate_newarrayglobal(void *, int type, int length);
+void * allocate_newglobal(transrecord_t *, int type);
+struct ArrayObject * allocate_newarrayglobal(transrecord_t *, int type, int length);
#endif
+
+#ifdef PRECISE_GC
+#include "garbage.h"
void * allocate_new(void *, int type);
struct ArrayObject * allocate_newarray(void *, int type, int length);
struct ___String___ * NewString(void *, const char *str,int length);
struct ___TagDescriptor___ * allocate_tag(void *ptr, int index);
#else
-#ifdef DSTM
-void * allocate_newglobal(int type);
-struct ArrayObject * allocate_newarrayglobal(int type, int length);
-#endif
void * allocate_new(int type);
struct ArrayObject * allocate_newarray(int type, int length);
struct ___String___ * NewString(const char *str,int length);