* 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
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()) {
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) {
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) {
// 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!");
}
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);
/* 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
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 */
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
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) {
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) {
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
// 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;
#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()