Bug fix, the compressed version of input files can work now
authorjzhou <jzhou>
Sat, 19 May 2012 04:17:29 +0000 (04:17 +0000)
committerjzhou <jzhou>
Sat, 19 May 2012 04:17:29 +0000 (04:17 +0000)
Robust/src/Util/InputFileTranslator.java
Robust/src/buildscript

index c4a7d19..19b2196 100644 (file)
@@ -19,11 +19,17 @@ public class InputFileTranslator{
                System.out.println("Please enter the valid file name");\r
            }else{\r
                int offset = 0;\r
+               boolean isCompressed = false;\r
+               \r
                if (args[offset].equals("-dir")) {\r
                    PREFIX=args[++offset]+"/";\r
                    offset++;\r
+               } \r
+               if(args[offset].equals("-compress")) {\r
+                   isCompressed = true;\r
+                   offset++;\r
                }\r
-               boolean isCompressed = true;\r
+               \r
 \r
                System.out.println("Opening the output file............. : opened");\r
                \r
@@ -62,7 +68,7 @@ public class InputFileTranslator{
                    if(isCompressed) {\r
                        encodemapping.clear();\r
                        encodeVec.clear();\r
-                       encodenum = 0;\r
+                       encodenum = 1;\r
                        encodemapping.put((byte)0, 0);\r
                        encodeVec.add((byte)0);\r
                    }\r
@@ -128,7 +134,7 @@ public class InputFileTranslator{
                                out.println();\r
                                printReturn = false;\r
                            }\r
-                           if(!isCompressed && ('\n' == buf[j])) {\r
+                           if(!isCompressed && ('\n' == writevalue)) {\r
                                out.print("\'\\n\'");\r
                                printReturn = true;\r
                            } else {\r
@@ -241,7 +247,7 @@ public class InputFileTranslator{
                out.println("}");\r
                out.println();\r
 \r
-               out.println("unsigned char peek(unsigned char * filearray, int * pos, int * isHighbits, bool isCompressed) {");\r
+               out.println("unsigned char peek(unsigned char * filearray, unsigned char * decodearray, int * pos, int * isHighbits, bool isCompressed) {");\r
                out.println("  if(!isCompressed) {");\r
                out.println("    return filearray[*pos];");\r
                out.println("  } else {");\r
@@ -252,38 +258,45 @@ public class InputFileTranslator{
                out.println("    if(1==*isHighbits) {");\r
                out.println("      value=((nextValue&0x00F0)>>4)&0x000F;");\r
                out.println("      holdVal=true;");\r
-               out.println("      *isHighbits=0;");\r
                out.println("    } else {");\r
                out.println("      value=nextValue&0x000F;");\r
                out.println("      holdVal=false;");\r
-               out.println("      *isHighbits=1;");\r
                out.println("    }");\r
+               out.println("    value=decodearray[value];");\r
                out.println("    return value;");\r
                out.println("  }");\r
                out.println("}");\r
                out.println();\r
 \r
-               out.println("void next(int * pos, bool isCompressed) {");\r
+               out.println("void next(int * pos, int * isHighbits, bool isCompressed) {");\r
                out.println("  if(!isCompressed||!holdVal) {");\r
                out.println("    *pos = *pos+1;");\r
-               out.println(" }");\r
+               out.println("  }");\r
+               out.println("  if(isCompressed) {");\r
+               out.println("    if(*isHighbits) {");\r
+               out.println("      *isHighbits=0;");\r
+               out.println("    } else {");\r
+               out.println("      *isHighbits=1;");\r
+               out.println("    }");\r
+               out.println("  }");\r
                out.println("}");\r
                out.println();\r
                \r
                out.println("int nextInt(int fd, int * pos, int * isHighbits) {");\r
                out.println("  int i = 0;");\r
                out.println("  unsigned char * filearray = inputFileArrays[fd];");\r
+               out.println("  unsigned char * decodearray = inputFileArrays_decodeTbl[fd];");\r
                out.println("  bool isCompressed = false;");\r
-               out.println("  if(inputFileArrays_decodeTbl[fd]!=0) {");\r
+               out.println("  if(decodearray!=0) {");\r
                out.println("   isCompressed = true;");\r
                out.println("  }");\r
                out.println("  initVal();");\r
                out.println();\r
                out.println("  unsigned char b='\\0';");\r
                out.println("  while(true) {");\r
-               out.println("    b=peek(filearray, pos, isHighbits, isCompressed); ");\r
+               out.println("    b=peek(filearray, decodearray, pos, isHighbits, isCompressed); ");\r
                out.println("    if((b==' ')||(b=='\\n')){");\r
-               out.println("      next(pos, isCompressed);");\r
+               out.println("      next(pos, isHighbits, isCompressed);");\r
                out.println("    } else {");\r
                out.println("      break;");\r
                out.println("    }");\r
@@ -295,12 +308,12 @@ public class InputFileTranslator{
                out.println();\r
                out.println("  if (b=='-') {");\r
                out.println("    isNeg=true;");\r
-               out.println("    next(pos, isCompressed);");\r
-               out.println("    b=peek(filearray, pos, isHighbits, isCompressed);");\r
+               out.println("    next(pos, isHighbits, isCompressed);");\r
                out.println("  }");\r
                out.println("  bool cont=true;");\r
                out.println("  do {");\r
-               out.println("    unsigned int val;");\r
+               out.println("    b=peek(filearray, decodearray, pos, isHighbits, isCompressed); ");\r
+               out.println("    unsigned int val=0;");\r
                out.println("    if (b>='0'&&b<='9')");\r
                out.println("      val=b-'0';");\r
                out.println("    else if (b>='a'&&b<='z')");\r
@@ -314,8 +327,7 @@ public class InputFileTranslator{
                out.println("      if (val>=radix)");\r
                out.println("        printf(\"Error in nextInt(): val >= radix\");");\r
                out.println("      value=value*radix+val;");\r
-               out.println("      next(pos, isCompressed);");\r
-               out.println("      b=peek(filearray, pos, isHighbits, isCompressed);");\r
+               out.println("      next(pos, isHighbits, isCompressed);");\r
                out.println("    }");\r
                out.println("  }while(cont);");\r
                out.println("  if (isNeg)");\r
@@ -328,17 +340,18 @@ public class InputFileTranslator{
                out.println("double nextDouble(int fd, int * pos, int * isHighbits) {");\r
                out.println("  int i = 0;");\r
                out.println("  unsigned char * filearray = inputFileArrays[fd];");\r
+               out.println("  unsigned char * decodearray = inputFileArrays_decodeTbl[fd];");\r
                out.println("  bool isCompressed = false;");\r
-               out.println("  if(inputFileArrays_decodeTbl[fd]!=0) {");\r
+               out.println("  if(decodearray!=0) {");\r
                out.println("   isCompressed = true;");\r
                out.println("  }");\r
                out.println("  initVal();");\r
                out.println();\r
                out.println("  unsigned char b='\\0';");\r
                out.println("  while(true) {");\r
-               out.println("    b=peek(filearray, pos, isHighbits, isCompressed); ");\r
+               out.println("    b=peek(filearray, decodearray, pos, isHighbits, isCompressed); ");\r
                out.println("    if((b==' ')||(b=='\\n')){");\r
-               out.println("      next(pos, isCompressed);");\r
+               out.println("      next(pos, isHighbits, isCompressed);");\r
                out.println("    } else {");\r
                out.println("      break;");\r
                out.println("    }");\r
@@ -353,8 +366,7 @@ public class InputFileTranslator{
                out.println();\r
                out.println("  if (b=='-') {");\r
                out.println("    isNeg=true;");\r
-               out.println("    next(pos, isCompressed);");\r
-               out.println("    b=peek(filearray, pos, isHighbits, isCompressed); ");\r
+               out.println("    next(pos, isHighbits, isCompressed);");\r
                out.println("  }");\r
                out.println("  bool cont=true;");\r
                out.println("  bool exp=false;");\r
@@ -364,7 +376,8 @@ public class InputFileTranslator{
                out.println("  unsigned int dcount=0;");\r
                out.println("  // compute the base");\r
                out.println("  do {");\r
-               out.println("    unsigned int val;");\r
+               out.println("    b=peek(filearray, decodearray, pos, isHighbits, isCompressed); ");\r
+               out.println("    unsigned int val=0;");\r
                out.println("    if (b>='0'&&b<='9') {");\r
                out.println("      if (!omit) {");\r
                out.println("        val=b-'0';");\r
@@ -378,7 +391,7 @@ public class InputFileTranslator{
                out.println("    } else if (b=='E'||b=='e') {");\r
                out.println("      exp=true;");\r
                out.println("      cont=false;");\r
-               out.println("      next(pos, isCompressed);");\r
+               out.println("      next(pos, isHighbits, isCompressed);");\r
                out.println("    } else {");\r
                out.println("      cont=false;");\r
                out.println("    }");\r
@@ -396,23 +409,22 @@ public class InputFileTranslator{
                out.println("      } else if(!omit) {");\r
                out.println("        compute=true;");\r
                out.println("      }");\r
-               out.println("      next(pos, isCompressed);");\r
-               out.println("      b=peek(filearray, pos, isHighbits, isCompressed); ");\r
+               out.println("      next(pos, isHighbits, isCompressed);");\r
                out.println("    }");\r
                out.println("  }while(cont);");\r
                out.println("  if(exp) {");\r
                out.println("    // compute the power index");\r
                out.println("    cont=true;");\r
                out.println("    unsigned int n=0;");\r
-               out.println("    b=peek(filearray, pos, isHighbits, isCompressed); ");\r
+               out.println("    b=peek(filearray, decodearray, pos, isHighbits, isCompressed); ");\r
                out.println("    if (b=='-') {");\r
                out.println("      isDiv=true;");\r
-               out.println("      next(pos, isCompressed);");\r
+               out.println("      next(pos, isHighbits, isCompressed);");\r
                out.println("    } else if (b=='+') {");\r
-               out.println("      next(pos, isCompressed);");\r
-               out.println("      b=peek(filearray, pos, isHighbits, isCompressed); ");\r
+               out.println("      next(pos, isHighbits, isCompressed);");\r
                out.println("    }");\r
                out.println("    do {");\r
+               out.println("      b=peek(filearray, decodearray, pos, isHighbits, isCompressed); ");\r
                out.println("      unsigned int val;");\r
                out.println("      if (b>='0'&&b<='9') {");\r
                out.println("        val=b-'0';");\r
@@ -423,8 +435,7 @@ public class InputFileTranslator{
                out.println("        if (val>=radix)");\r
                out.println("          printf(\"Error in nextDouble(): val >= radix\");");\r
                out.println("        n=n*10+val;");\r
-               out.println("        next(pos, isCompressed);");\r
-               out.println("        b=peek(filearray, pos, isHighbits, isCompressed); ");\r
+               out.println("        next(pos, isHighbits, isCompressed);");\r
                out.println("      }");\r
                out.println("    }while(cont);");\r
                out.println("    if(isDiv) {");\r
index 7c54d9c..109eece 100755 (executable)
@@ -95,6 +95,7 @@ echo -profile_interrupt build with profile information of interrupts
 echo "-useio use standard io to output profiling data (should be used together with -raw and -profile), it only works with single core version"
 echo -gccachecoherent turns on the cache coherence during gc
 echo -inputfile enables reading input files in Tilera
+echo -inputfilecompress enables the compressed version of input files
 echo
 echo Multicore GC options
 echo -perfcount performance counters
@@ -278,6 +279,7 @@ TILERA_NUM_BLOCKS="20"
 TILERA_NUM_PAGES_PER_BLOCK="16"
 INPUTFILEFLAG=false
 INPUTFILES=''
+INPUTFILEOPTS=''
 GCCACHECOHERENTFLAG=false
 COMPILER_HEAP_SIZE="1500"
 
@@ -620,6 +622,9 @@ then
 INPUTFILEFLAG=true
 INPUTFILES="$INPUTFILES $2"
 shift
+elif [[ $1 = '-inputfilecompress' ]]
+then
+INPUTFILEOPTS="$INPUTFILEOPTS -compress"
 elif [[ $1 = '-mgcintel' ]]
 then
 MGCINTELFLAG=true
@@ -985,7 +990,7 @@ if $INPUTFILEFLAG
 then
 ./ourjavac -cp ../cup:.:$(CLASSPATH) Util/InputFileTranslator.java
 if ! ${ROBUSTROOT}/ourjava -Xms50m -Xmx${COMPILER_HEAP_SIZE}m -classpath $ROBUSTROOT Util.InputFileTranslator \
-       -dir $BUILDDIR $INPUTFILES
+       -dir $BUILDDIR $INPUTFILEOPTS $INPUTFILES
     then exit $?
 fi
 fi