changes
authorbdemsky <bdemsky>
Mon, 28 Feb 2011 05:15:56 +0000 (05:15 +0000)
committerbdemsky <bdemsky>
Mon, 28 Feb 2011 05:15:56 +0000 (05:15 +0000)
Robust/src/IR/Flat/BuildCode.java
Robust/src/IR/Flat/BuildCodeMGC.java
Robust/src/IR/Flat/BuildCodeTran.java

index 2d539354f3c4af638c32d9937cf15a817a7e9f13..6b64d4e62e4aa8d4ce5b7673f1380a46ad9836b9 100644 (file)
@@ -145,6 +145,7 @@ public class BuildCode {
     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("");
@@ -304,11 +305,12 @@ public class BuildCode {
   protected void outputMainMethod(PrintWriter outmethod) {
     outmethod.println("int main(int argc, const char *argv[]) {");
     outmethod.println("  int i;");
+    outmethod.println("  global_defs_p=calloc(1, sizeof(struct global_defs_t));");
+    outmethod.println("  global_defsprim_p=calloc(1, sizeof(struct global_defsprim_t));");
     if (GENERATEPRECISEGC) {
       outmethod.println("  global_defs_p->size="+globaldefscount+";");
       outmethod.println("  for(i=0;i<"+globaldefscount+";i++) {");
-      outmethod.println("    ((struct garbagelist *)global_defs_p)->array[i]=NUL
-L;");
+      outmethod.println("    ((struct garbagelist *)global_defs_p)->array[i]=NULL;");
       outmethod.println("  }");
     }
     outputStaticBlocks(outmethod);
index 3384a86a8b1da0b38fbff6d3f6acf157a3eaf6af..6931f85f88e1bcc423034f5d962925e070d756c2 100644 (file)
@@ -77,6 +77,8 @@ public class BuildCodeMGC extends BuildCode {
     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_");
index f7c2b087168ad9836daf3ef61d62d3da46afad14..7966193f2e24c5d3a235ea54329b4b02bbb6ef18 100644 (file)
@@ -117,6 +117,15 @@ public class BuildCodeTran extends BuildCode {
   protected void outputMainMethod(PrintWriter outmethod) {
     outmethod.println("int main(int argc, const char *argv[]) {");
     outmethod.println("  int i;");
+    outmethod.println("  global_defs_p=calloc(1, sizeof(struct global_defs_t));");
+    outmethod.println("  global_defsprim_p=calloc(1, sizeof(struct global_defsprim_t));");
+    if (GENERATEPRECISEGC) {
+      outmethod.println("  global_defs_p->size="+globaldefscount+";");
+      outmethod.println("  for(i=0;i<"+globaldefscount+";i++) {");
+      outmethod.println("    ((struct garbagelist *)global_defs_p)->array[i]=NULL;");
+      outmethod.println("  }");
+    }
+
     outputStaticBlocks(outmethod);
     outputClassObjects(outmethod);
     additionalCodeAtTopOfMain(outmethod);
@@ -928,7 +937,7 @@ public class BuildCodeTran extends BuildCode {
            // TODO add version for normal Java later
            if((fm.getMethod() != null) && (fm.getMethod().isStaticBlock())) {
              // a static block, check if it has been executed
-             output.println("  global_defs_p->" + fm.getMethod().getClassDesc().getSafeSymbol()+"static_block_exe_flag = 1;");
+             output.println("  global_defsprim_p->" + fm.getMethod().getClassDesc().getSafeSymbol()+"static_block_exe_flag = 1;");
              output.println("");
            }
          }
@@ -1562,12 +1571,12 @@ public class BuildCodeTran extends BuildCode {
            // need to check if the class' static fields have been initialized and/or
            // its static blocks have been executed
            output.println("#ifdef MGC_STATIC_INIT_CHECK");
-           output.println("if(global_defs_p->" + cn.getSafeSymbol()+"static_block_exe_flag == 0) {");
+           output.println("if(global_defsprim_p->" + cn.getSafeSymbol()+"static_block_exe_flag == 0) {");
            if(cn.getNumStaticBlocks() != 0) {
              MethodDescriptor t_md = (MethodDescriptor)cn.getMethodTable().get("staticblocks");
              output.println("  "+cn.getSafeSymbol()+t_md.getSafeSymbol()+"_"+t_md.getSafeMethodDescriptor()+"();");
            } else {
-             output.println("  global_defs_p->" + cn.getSafeSymbol()+"static_block_exe_flag = 1;");
+             output.println("  global_defsprim_p->" + cn.getSafeSymbol()+"static_block_exe_flag = 1;");
            }
            output.println("}");
            output.println("#endif // MGC_STATIC_INIT_CHECK");