From 6fe295717a19d554c4334738b098039b5f951710 Mon Sep 17 00:00:00 2001 From: jzhou Date: Thu, 17 Mar 2011 00:49:19 +0000 Subject: [PATCH] Fix compilation problems for multicore code --- Robust/src/IR/Flat/BuildCode.java | 58 ++++++++++++-------- Robust/src/IR/Flat/BuildCodeMultiCore.java | 28 ++++++++++ Robust/src/IR/State.java | 2 +- Robust/src/IR/Virtual.java | 32 +++++++---- Robust/src/Runtime/bamboo/multicoreruntime.h | 14 +++-- Robust/src/Runtime/runtime.h | 12 ++++ 6 files changed, 105 insertions(+), 41 deletions(-) diff --git a/Robust/src/IR/Flat/BuildCode.java b/Robust/src/IR/Flat/BuildCode.java index beb4593a..dfeef8d1 100644 --- a/Robust/src/IR/Flat/BuildCode.java +++ b/Robust/src/IR/Flat/BuildCode.java @@ -254,7 +254,7 @@ public class BuildCode { * invoked and should be generated */ protected void checkMethods2Gen() { - MethodDescriptor md=typeutil.getMain(); + MethodDescriptor md=(state.main==null)?null:typeutil.getMain(); if(md != null) { // check the methods to be generated @@ -530,17 +530,19 @@ public class BuildCode { while(methodit.hasNext()) { /* Classify parameters */ MethodDescriptor md=(MethodDescriptor)methodit.next(); - Set vec_md = this.state.getMethod2gen().getSet(md.getSymbol()); - boolean foundmatch = false; - for(Iterator matchit=vec_md.iterator(); matchit.hasNext();) { - MethodDescriptor matchmd=(MethodDescriptor)matchit.next(); - if (md.matches(matchmd)) { - foundmatch=true; - break; + if(!this.state.genAllMethods) { + boolean foundmatch = false; + Set vec_md = this.state.getMethod2gen().getSet(md.getSymbol()); + for(Iterator matchit=vec_md.iterator(); matchit.hasNext();) { + MethodDescriptor matchmd=(MethodDescriptor)matchit.next(); + if (md.matches(matchmd)) { + foundmatch=true; + break; + } + } + if(!foundmatch) { + continue; } - } - if(!foundmatch) { - continue; } FlatMethod fm=state.getMethodFlat(md); if (!md.getModifiers().isNative()) { @@ -968,13 +970,17 @@ public class BuildCode { MethodDescriptor md=(MethodDescriptor)it.next(); if (md.isStatic()||md.getReturnType()==null) continue; - Set vec_md = this.state.getMethod2gen().getSet(md.getSymbol()); boolean foundmatch = false; - for(Iterator matchit=vec_md.iterator(); matchit.hasNext();) { - MethodDescriptor matchmd=(MethodDescriptor)matchit.next(); - if (md.matches(matchmd)) { - foundmatch=true; - break; + if(this.state.genAllMethods) { + foundmatch = true; + } else { + Set vec_md = this.state.getMethod2gen().getSet(md.getSymbol()); + for(Iterator matchit=vec_md.iterator(); matchit.hasNext();) { + MethodDescriptor matchmd=(MethodDescriptor)matchit.next(); + if (md.matches(matchmd)) { + foundmatch=true; + break; + } } } if(!foundmatch) { @@ -1674,13 +1680,17 @@ public class BuildCode { protected void generateCallStructsMethods(ClassDescriptor cn, PrintWriter output, PrintWriter headersout) { for(Iterator methodit=cn.getMethods(); methodit.hasNext(); ) { MethodDescriptor md=(MethodDescriptor)methodit.next(); - Set vec_md = this.state.getMethod2gen().getSet(md.getSymbol()); boolean foundmatch = false; - for(Iterator matchit=vec_md.iterator(); matchit.hasNext();) { - MethodDescriptor matchmd=(MethodDescriptor)matchit.next(); - if (md.matches(matchmd)) { - foundmatch=true; - break; + if(this.state.genAllMethods) { + foundmatch = true; + } else { + Set vec_md = this.state.getMethod2gen().getSet(md.getSymbol()); + for(Iterator matchit=vec_md.iterator(); matchit.hasNext();) { + MethodDescriptor matchmd=(MethodDescriptor)matchit.next(); + if (md.matches(matchmd)) { + foundmatch=true; + break; + } } } if(foundmatch) { @@ -2423,7 +2433,7 @@ public class BuildCode { // if the called method is a static block or a static method or a constructor // need to check if it can be invoked inside some static block if((md.isStatic() || md.isStaticBlock() || md.isConstructor()) && - ((fm.getMethod().isStaticBlock()) || (fm.getMethod().isInvokedByStatic()))) { + ((fm.getMethod() != null) && ((fm.getMethod().isStaticBlock()) || (fm.getMethod().isInvokedByStatic())))) { if(!md.isInvokedByStatic()) { System.err.println("Error: a method that is invoked inside a static block is not tagged!"); } diff --git a/Robust/src/IR/Flat/BuildCodeMultiCore.java b/Robust/src/IR/Flat/BuildCodeMultiCore.java index 7ce0e07d..05010567 100644 --- a/Robust/src/IR/Flat/BuildCodeMultiCore.java +++ b/Robust/src/IR/Flat/BuildCodeMultiCore.java @@ -110,6 +110,7 @@ public class BuildCodeMultiCore extends BuildCode { outstructs=new PrintWriter(new FileOutputStream(PREFIX+"structdefs.h"), true); outmethodheader=new PrintWriter(new FileOutputStream(PREFIX+"methodheaders.h"), true); outclassdefs=new PrintWriter(new FileOutputStream(PREFIX+"classdefs.h"), true); + outglobaldefs=new PrintWriter(new FileOutputStream(PREFIX+"globaldefs.h"), true); outglobaldefsprim=new PrintWriter(new FileOutputStream(PREFIX+"globaldefsprim.h"), true); outvirtual=new PrintWriter(new FileOutputStream(PREFIX+"virtualtable.h"), true); outmethod=new PrintWriter(new FileOutputStream(PREFIX+"methods.c"), true); @@ -149,6 +150,18 @@ public class BuildCodeMultiCore extends BuildCode { /* Output Structures */ outputStructs(outstructs); + + outglobaldefs.println("#ifndef __GLOBALDEF_H_"); + outglobaldefs.println("#define __GLOBALDEF_H_"); + outglobaldefs.println(""); + outglobaldefs.println("struct global_defs_t {"); + outglobaldefs.println(" int size;"); + outglobaldefs.println(" void * next;"); + + outglobaldefsprim.println("#ifndef __GLOBALDEFPRIM_H_"); + outglobaldefsprim.println("#define __GLOBALDEFPRIM_H_"); + outglobaldefsprim.println(""); + outglobaldefsprim.println("struct global_defsprim_t {"); // Output the C class declarations // These could mutually reference each other @@ -163,8 +176,23 @@ public class BuildCodeMultiCore extends BuildCode { ClassDescriptor cn=(ClassDescriptor)it.next(); generateCallStructs(cn, outclassdefs, outstructs, outmethodheader, outglobaldefs, outglobaldefsprim); } + outclassdefs.println("#include \"globaldefs.h\""); + outclassdefs.println("#include \"globaldefsprim.h\""); outclassdefs.println("#endif"); outclassdefs.close(); + outglobaldefs.println("};"); + outglobaldefs.println(""); + outglobaldefs.println("extern struct global_defs_t * global_defs_p;"); + outglobaldefs.println("#endif"); + outglobaldefs.flush(); + outglobaldefs.close(); + + outglobaldefsprim.println("};"); + outglobaldefsprim.println(""); + outglobaldefsprim.println("extern struct global_defsprim_t * global_defsprim_p;"); + outglobaldefsprim.println("#endif"); + outglobaldefsprim.flush(); + outglobaldefsprim.close(); if (state.TASK) { /* Map flags to integers */ diff --git a/Robust/src/IR/State.java b/Robust/src/IR/State.java index 54df5b66..eb614440 100644 --- a/Robust/src/IR/State.java +++ b/Robust/src/IR/State.java @@ -183,7 +183,7 @@ public class State { public Hashtable treemethodmap; public Hashtable flatmethodmap; SymbolTable methods2gen; - boolean genAllMethods; + public boolean genAllMethods; private HashSet arraytypes; public Hashtable arraytonumber; private int numclasses=1; // start from 1 instead of 0 for multicore gc diff --git a/Robust/src/IR/Virtual.java b/Robust/src/IR/Virtual.java index 52c73104..456fb45e 100644 --- a/Robust/src/IR/Virtual.java +++ b/Robust/src/IR/Virtual.java @@ -127,13 +127,17 @@ public class Virtual { MethodDescriptor md=(MethodDescriptor)it.next(); if (md.isStatic()||md.getReturnType()==null) continue; - Set vec_md = this.state.getMethod2gen().getSet(md.getSymbol()); boolean foundmatch = false; - for(Iterator matchit=vec_md.iterator(); matchit.hasNext();) { - MethodDescriptor matchmd=(MethodDescriptor)matchit.next(); - if (md.matches(matchmd)) { - foundmatch=true; - break; + if(this.state.genAllMethods) { + foundmatch = true; + } else { + Set vec_md = this.state.getMethod2gen().getSet(md.getSymbol()); + for(Iterator matchit=vec_md.iterator(); matchit.hasNext();) { + MethodDescriptor matchmd=(MethodDescriptor)matchit.next(); + if (md.matches(matchmd)) { + foundmatch=true; + break; + } } } if(!foundmatch) { @@ -175,13 +179,17 @@ public class Virtual { MethodDescriptor md=(MethodDescriptor)it.next(); if (md.isStatic()||md.getReturnType()==null) continue; - Set vec_md = this.state.getMethod2gen().getSet(md.getSymbol()); boolean foundmatch = false; - for(Iterator matchit=vec_md.iterator(); matchit.hasNext();) { - MethodDescriptor matchmd=(MethodDescriptor)matchit.next(); - if (md.matches(matchmd)) { - foundmatch=true; - break; + if(this.state.genAllMethods) { + foundmatch = true; + } else { + Set vec_md = this.state.getMethod2gen().getSet(md.getSymbol()); + for(Iterator matchit=vec_md.iterator(); matchit.hasNext();) { + MethodDescriptor matchmd=(MethodDescriptor)matchit.next(); + if (md.matches(matchmd)) { + foundmatch=true; + break; + } } } if(!foundmatch) { diff --git a/Robust/src/Runtime/bamboo/multicoreruntime.h b/Robust/src/Runtime/bamboo/multicoreruntime.h index 4ca9ec56..9be910f7 100644 --- a/Robust/src/Runtime/bamboo/multicoreruntime.h +++ b/Robust/src/Runtime/bamboo/multicoreruntime.h @@ -24,6 +24,16 @@ int totalexetime; bool reside; #endif +#ifdef MULTICORE +#ifdef GC_SMALLPAGESIZE +#define BAMBOO_GLOBAL_DEFS_SIZE (1024 * 1024) +#define BAMBOO_GLOBAL_DEFS_PRIM_SIZE (1024 * 512) +#else +#define BAMBOO_GLOBAL_DEFS_SIZE (BAMBOO_SMEM_SIZE) +#define BAMBOO_GLOBAL_DEFS_PRIM_SIZE (BAMBOO_SMEM_SIZE/2) +#endif // GC_SMALLPAGESIZE +#endif // MULTICORE + #ifdef MGC // shared memory pointer for global thread queue // In MGC version, this block of memory is located at the very bottom of the @@ -38,12 +48,8 @@ bool reside; // mutex + thread counter + start pointer + end pointer #ifdef GC_SMALLPAGESIZE #define BAMBOO_THREAD_QUEUE_SIZE (1024 * 1024) -#define BAMBOO_GLOBAL_DEFS_SIZE (1024 * 1024) -#define BAMBOO_GLOBAL_DEFS_PRIM_SIZE (1024 * 512) #else #define BAMBOO_THREAD_QUEUE_SIZE (BAMBOO_SMEM_SIZE) // (45 * 16 * 1024) -#define BAMBOO_GLOBAL_DEFS_SIZE (BAMBOO_SMEM_SIZE) -#define BAMBOO_GLOBAL_DEFS_PRIM_SIZE (BAMBOO_SMEM_SIZE/2) #endif // data structures for threads INTPTR * bamboo_thread_queue; diff --git a/Robust/src/Runtime/runtime.h b/Robust/src/Runtime/runtime.h index b02fc179..8f9e5f4b 100644 --- a/Robust/src/Runtime/runtime.h +++ b/Robust/src/Runtime/runtime.h @@ -114,6 +114,18 @@ void createstartupobject(); #define CALL24(name, rest, rest2, alt1, alt2, alt3, alt4) name(struct name ## _params * ___params___, rest, rest2) #define CALL34(name, rest, rest2, rest3, alt1, alt2, alt3, alt4) name(struct name ## _params * ___params___, rest, rest2, rest3) #define CALL35(name, rest, rest2, rest3, alt1, alt2, alt3, alt4, alt5) name(struct name ## _params * ___params___, rest, rest2, rest3) +#elif defined MULTICORE_GC +#define VAR(name) ___params___->name +#define CALL00(name) name(struct name ## _params * ___params___) +#define CALL01(name, alt) name(struct name ## _params * ___params___) +#define CALL02(name, alt1, alt2) name(struct name ## _params * ___params___) +#define CALL11(name,rest, alt) name(struct name ## _params * ___params___, rest) +#define CALL12(name,rest, alt1, alt2) name(struct name ## _params * ___params___, rest) +#define CALL22(name, rest, rest2, alt1, alt2) name(struct name ## _params * ___params___, rest, rest2) +#define CALL23(name, rest, rest2, alt1, alt2, alt3) name(struct name ## _params * ___params___, rest, rest2) +#define CALL24(name, rest, rest2, alt1, alt2, alt3, alt4) name(struct name ## _params * ___params___, rest, rest2) +#define CALL34(name, rest, rest2, rest3, alt1, alt2, alt3, alt4) name(struct name ## _params * ___params___, rest, rest2, rest3) +#define CALL35(name, rest, rest2, rest3, alt1, alt2, alt3, alt4, alt5) name(struct name ## _params * ___params___, rest, rest2, rest3) #else #define VAR(name) name #define CALL00(name) name() -- 2.34.1