added gnuplots
authoradam <adam@megacz.com>
Tue, 11 May 2004 09:01:15 +0000 (02:01 -0700)
committeradam <adam@megacz.com>
Tue, 11 May 2004 09:01:15 +0000 (02:01 -0700)
darcs-hash:20040511090115-5007d-c749ab64c542dd42bcafeb486efc795d6f68b9ab.gz

Makefile
doc/charts/boxfill.pl [new file with mode: 0755]
doc/charts/chart1.dat [new file with mode: 0644]
doc/charts/chart1.gnuplot [new file with mode: 0644]
doc/ivme04.tex [moved from doc/nestedvm.ivme04.tex with 96% similarity]

index 6d7a771..4d5c279 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -178,7 +178,7 @@ runtime.jar: $(runtime_classes:%=build/org/ibex/nestedvm/%.class)
                $(runtime_classes:%=org/ibex/nestedvm/%.class) \
                org/ibex/nestedvm/Runtime\$$*.class \
                org/ibex/nestedvm/util/Seekable\$$*.class
-               
+
 .manifest:
        echo -ne "Manifest-Version: 1.0\nMain-Class: org.ibex.nestedvm.RuntimeCompiler\n" > $@
 
@@ -214,7 +214,7 @@ rebuild-constants: $(tasks)/build_newlib
                        s/ *# *define \([A-Z_][A-Za-z0-9_]*\) \([0-9][0-9x]*\)/    public static final int \1 = \2;/p'; \
                echo "}"; \
        ) > src/org/ibex/nestedvm/UsermodeConstants.java
-       
+
 #
 # Tests
 # These are simply here for convenience. They aren't required 
@@ -252,7 +252,7 @@ Paranoia_CFLAGS = "-Wno-error"
 Paranoia_LDFLAGS = -lm
 paranoiatest: build/tests/Paranoia.class
        $(JAVA) -cp build tests.Paranoia
-       
+
 #
 # Freetype Stuff
 #
@@ -301,7 +301,7 @@ BusyBox_COMPILERFLAGS = -o unixruntime
 build/tests/BusyBox.mips: $(mips_objects) $(tasks)/build_busybox
        @mkdir -p `dirname $@`
        cp upstream/build/busybox/busybox $@
-       
+
 busyboxtest: build/tests/BusyBox.class
        $(JAVA) -cp $(classpath) tests.BusyBox ash
 
@@ -373,9 +373,16 @@ compiletests: $(patsubst %,build/tests/%.class,FTBench MSPackBench DJpeg Test Fr
        @true
 
 
+charts := $(shell find doc/charts -name \*.dat)
+
 # IVME Paper
-doc/nestedvm.ivme04.pdf: doc/nestedvm.ivme04.tex doc/acmconf.cls
-       cd doc; pdflatex nestedvm.ivme04.tex && ./pst2pdf && pdflatex nestedvm.ivme04.tex
+doc/charts/%.pdf: doc/charts/%.dat doc/charts/%.gnuplot
+       cd doc/charts; gnuplot $*.gnuplot
+       cd doc/charts; chmod +x boxfill.pl; ./boxfill.pl -g -o unfilled.eps $*.eps
+       cd doc/charts; ps2pdf $*.eps
+
+doc/ivme04.pdf: doc/ivme04.tex doc/acmconf.cls $(charts:%.dat=%.pdf)
+       cd doc; pdflatex ivme04.tex && ./pst2pdf && pdflatex ivme04.tex
 
-pdf: doc/nestedvm.ivme04.pdf
-       open doc/nestedvm.ivme04.pdf
+pdf: doc/ivme04.pdf
+       open doc/ivme04.pdf
diff --git a/doc/charts/boxfill.pl b/doc/charts/boxfill.pl
new file mode 100755 (executable)
index 0000000..91b8464
--- /dev/null
@@ -0,0 +1,259 @@
+#!/usr/bin/perl -w
+
+# Copyright 2001, Felix Ritter (Felix.Ritter@gmx.de)
+#
+# Original script (color mode) Copyright 2000,
+# Andreas Widmann (widmann@rz.uni-leipzig.de)
+#
+# This script is free software; permission to use, copy, modify, and
+# distribute this software and its documentation for any purpose without
+# fee is hereby granted, provided that both the above copyright notice
+# and this permission notice appear in all copies and in supporting
+# documentation.
+#
+# This software is provided "as is" without express or implied warranty
+# of any kind.
+
+#introstuff
+sub usage_info() {
+  print "gnuplot-boxfill.pl\n";
+  print "  fills (and outlines) boxes in gnuplot 3.7.1 postscript files\n";
+  print "usage:\n";
+  print "  gnuplot-boxfill.pl [-c | -g | -p] [-o] [-r] [-z] <ps_in> <ps_out>\n";
+  print "options:\n";
+  print "  -c         color fill (default)\n";
+  print "  -g         gray fill\n";
+  print "  -p         pattern fill\n";
+  print "  -o         draw outline\n";
+  print "  -r         remove \"currentpoint stroke M\" (experimental!)\n";
+  print "  -z         outline zero height boxes (experimental!)\n";
+  print "arguments:\n";
+  print "  <ps_in>    postscript input file\n";
+  print "  <ps_out>   postscript output file\n";
+}
+if ($#ARGV < 1) {
+  &usage_info();
+  exit(0);
+}
+
+$prolog = '/graymode true def
+
+/BfDict 400 dict def 
+
+/dpiranges   [  2540    2400    1693     1270    1200     635      600      0      ] def
+/PatFreq     [ 10.5833 10.0     9.4055  10.5833 10.0     10.5833  10.0    9.375   ] def
+
+/dpi 72 0 matrix defaultmatrix dtransform dup mul exch dup mul add sqrt def
+
+/screenIndex {
+       0 1 dpiranges length 1 sub { dup dpiranges exch get 1 sub dpi le {exit} {pop} ifelse } for
+} bind def
+
+/CurColors [ 0 0 0 1 0 0 0 1] def
+
+/RealSetgray /setgray load def
+/RealSetrgbcolor /setrgbcolor load def
+/RealSetcmykcolor {
+       4 1 roll
+       3 { 3 index add 0 max 1 min 1 exch sub 3 1 roll} repeat 
+       RealSetrgbcolor pop
+} bind def
+
+/tintCMYK {
+       1 tintGray sub CurColors 0 4 getinterval aload pop      
+       4 index mul 5 1 roll                                                                            
+       3 index mul 5 1 roll                                                                            
+       2 index mul 5 1 roll                                                                            
+       mul 4 1 roll                                                                                            
+}bind def
+/tintRGB {
+       1 tintGray sub CurColors 4 3 getinterval aload pop      
+       1 exch sub 3 index mul 1 exch sub 4 1 roll                                      
+       1 exch sub 2 index mul 1 exch sub 4 1 roll                                      
+       1 exch sub mul 1 exch sub 3 1 roll                                                      
+}bind def
+/combineColor {
+       /tintGray 1 1 CurGray sub CurColors 7 get mul sub def
+       graymode not {
+               [/Pattern [/DeviceCMYK]] setcolorspace
+               tintCMYK CurPat setcolor
+       } {
+               CurColors 3 get 1.0 ge {
+                       tintGray RealSetgray
+               } {
+                       graymode {
+                               tintCMYK
+                               RealSetcmykcolor
+                       } {
+                               tintRGB
+                               RealSetrgbcolor
+                       } ifelse
+               } ifelse
+       } ifelse
+} bind def
+
+/patProcDict 5 dict dup begin
+       <0f1e3c78f0e1c387> { 3 setlinewidth -1 -1 moveto 9 9 lineto stroke
+                               4 -4 moveto 12 4 lineto stroke
+                               -4 4 moveto 4 12 lineto stroke} bind def
+       <0f87c3e1f0783c1e> { 3 setlinewidth -1 9 moveto 9 -1 lineto stroke
+                               -4 4 moveto 4 -4 lineto stroke
+                               4 12 moveto 12 4 lineto stroke} bind def
+       <8142241818244281> { 1 setlinewidth -1 9 moveto 9 -1 lineto stroke
+                               -1 -1 moveto 9 9 lineto stroke } bind def
+       <03060c183060c081> { 1 setlinewidth -1 -1 moveto 9 9 lineto stroke
+                               4 -4 moveto 12 4 lineto stroke
+                               -4 4 moveto 4 12 lineto stroke} bind def
+       <8040201008040201> { 1 setlinewidth -1 9 moveto 9 -1 lineto stroke
+                               -4 4 moveto 4 -4 lineto stroke
+                               4 12 moveto 12 4 lineto stroke} bind def
+end def
+/patDict 15 dict dup begin
+       /PatternType 1 def              
+       /PaintType 2 def                
+       /TilingType 3 def               
+       /BBox [ 0 0 8 8 ] def   
+       /XStep 8 def                    
+       /YStep 8 def                    
+       /PaintProc {
+               begin
+               patProcDict bstring known {
+                       patProcDict bstring get exec
+               } {
+                       8 8 true [1 0 0 -1 0 8] bstring imagemask
+               } ifelse
+               end
+       } bind def
+end def
+
+/setPatternMode {
+       pop pop
+       dup patCache exch known {
+               patCache exch get
+       } { 
+               dup
+               patDict /bstring 3 -1 roll put
+               patDict 
+               65 PatFreq screenIndex get div dup matrix scale
+               makepattern
+               dup 
+               patCache 4 -1 roll 3 -1 roll put
+       } ifelse
+       /CurGray 0 def
+       /CurPat exch def
+       /graymode false def
+       combineColor
+} bind def
+/setGrayScaleMode {
+       graymode not {
+               /graymode true def
+       } if
+       /CurGray exch def
+       combineColor
+} bind def
+
+BfDict begin [
+       /fillvals
+] { 0 def } forall
+
+/SetPattern { 
+       fillvals exch get
+       dup type /stringtype eq
+       {8 1 setPatternMode} 
+       {setGrayScaleMode}
+       ifelse
+       } bind def
+
+/InitPattern {
+       BfDict begin dup
+       array /fillvals exch def
+       dict /patCache exch def
+       end
+       } def
+/DefPattern {
+       BfDict begin
+       fillvals 3 1 roll put
+       end
+       } def
+
+7 InitPattern
+0 <03060c183060c081> DefPattern
+1 <8040201008040201> DefPattern
+2 <0f1e3c78f0e1c387> DefPattern
+3 <0f87c3e1f0783c1e> DefPattern
+4 <8142241818244281> DefPattern
+5 <111111ff111111ff> DefPattern
+6 0 DefPattern';
+
+$outlinestyle = 'LTb';
+if(grep(/^-o$/, @ARGV) == 1) { $outline = "\ngsave\ncurrentpoint $outlinestyle M redo stroke\ngrestore" }
+else { $outline = '' }
+
+#read input file
+open(IN, $ARGV[$#ARGV - 1]) || die "Cannot open $ARGV[$#ARGV - 1]\n";
+$content = join('', <IN>);
+close(IN);
+
+#search patterns
+$key = '(-*\d+ -*\d+ M\n)(-*\d+)( -*\d+ V\n)(-*\d+ -*\d+ [RM]\n-*\d+ -*\d+ V\n-*\d+ -*\d+ V\n-*\d+ -*\d+ V\n-*\d+ -*\d+ V\n)';
+#$key = '(-*\d+ -*\d+ M\n)(-*\d+)( -*\d+ V\n)(-*\d+ -*\d+ [RM]\n-*\d+ -*\d+ V\n-*\d+ -*\d+ V\n)'; #experimental
+$box = '(?<!LTb)(\n-*\d+ -*\d+ [RM]\n)(-*\d+ -*\d+ V\n-*\d+ -*\d+ V\n-*\d+ -*\d+ V\n-*\d+ -*\d+ V)';
+#$box = '(?<!LTb)(\n-*\d+ -*\d+ [RM]\n)(-*\d+ -*\d+ V\n-*\d+ -*\d+ V\n-*\d+ -*\d+ [LV]\n-*\d+ -*\d+ V)'; #experimental
+$endComments = '(%%EndComments[ \t]*\n)';
+$sftextcmd = '(/[LRC]show *{)(.*\n.*)(}.*def)';
+$mftextcmd = '(/MFshow *{.*\n.*\n.*{)(show)(}.*\n.*} *bind *def)';
+$ltTable = '(/LT)([0-8])( { PL \[.*\] ).* DL( } def)';
+$bfDLPlace = '(/DL { Color)';
+
+#substitute comments
+$content =~ s/(%%Title: ).*$/$1$ARGV[$#ARGV]/m;
+$content =~ s/(%%Creator: ).*$/$1gnuplot-boxfill.pl/m;
+$content =~ s/(%%CreationDate: ).*$/$1.localtime()/em;
+
+#remove "currentpoint stroke M"
+if(grep(/^-r$/, @ARGV) == 1) { $content =~ s/\ncurrentpoint stroke M\n/\n/g }
+
+if(grep(/^-g$/, @ARGV) == 1) {
+  #modify colors
+  $content =~ s/$bfDLPlace/\/BfDL { Color {8 exch sub 4 div 1 sub 0.15 sub setgray Solid {pop []} if 0 setdash }\n {pop Solid {pop []} if 0 setdash} ifelse } def\n$1/;
+  $content =~ s/$ltTable/$1$2$3$2 BfDL$4/g;
+
+  #substitute boxplot commands
+  $content =~ s/$key/$1gsave\n\/redo \{0 vpt 1.25 div V $2 0 V 0 vpt 1.75 mul neg V $2 neg 0 V closepath\} bind def\ncurrentpoint M redo fill\ngrestore$outline\n$2 0 R\n$4/g;
+  $content =~ s/$box/$1gsave\n\/redo\{$2\} bind def\ncurrentpoint M redo fill\ngrestore$outline/g;
+
+  #modify text output commands
+  $content =~ s/$sftextcmd/$1gsave 0 setgray\n$2grestore\n$3/g;
+  $content =~ s/$mftextcmd/$1gsave 0 setgray $2 grestore$3/g;
+}
+elsif(grep(/^-p$/, @ARGV) == 1) {
+  #add postscript macros
+  $content =~ s/$endComments/$1$prolog\n/;
+
+  #modify colors
+  $content =~ s/$ltTable/$1$2$3$2 SetPattern$4/g;
+
+  #substitute boxplot commands
+  $content =~ s/$key/$1gsave\n\/redo \{0 vpt 1.25 div V $2 0 V 0 vpt 1.75 mul neg V $2 neg 0 V closepath\} bind def\ncurrentpoint currentpoint M redo gsave 1 setgray fill grestore M redo fill\ngrestore$outline\n$2 0 R\n$4/g;
+  $content =~ s/$box/$1gsave\n\/redo\{$2\} bind def\ncurrentpoint currentpoint M redo gsave 1 setgray fill grestore M redo fill\ngrestore$outline/g;
+
+  #modify text output commands
+  $content =~ s/$sftextcmd/$1gsave 0 setgray\n$2grestore\n$3/g;
+  $content =~ s/$mftextcmd/$1gsave 0 setgray $2 grestore$3/g;
+}
+else {
+  #substitute boxplot commands
+  $content =~ s/$key/$1gsave\n\/redo \{0 vpt 1.25 div V $2 0 V 0 vpt 1.75 mul neg V $2 neg 0 V closepath\} bind def\ncurrentpoint M redo fill\ngrestore$outline\n$2 0 R\n$4/g;
+  $content =~ s/$box/$1gsave\n\/redo\{$2\} bind def\ncurrentpoint M redo fill\ngrestore$outline/g;
+}
+
+#outline zero height boxes
+if(grep(/^-z$/, @ARGV) == 1) {
+  $boxshort = '(?<!LTb)(\n-*\d+ -*\d+ [RM]\n)(-*\d+ -*\d+ V\n-*\d+ -*\d+ V)(?!\n.*V\n)';
+  $content =~ s/$boxshort/$1gsave\n\/redo\{$2\} bind def\ncurrentpoint stroke M redo fill\ngrestore$outline/g;
+}
+
+#write to output file
+open(OUT, ">$ARGV[$#ARGV]") || die "Cannot open $ARGV[$#ARGV]\n";
+print OUT "$content";
+close(OUT);
diff --git a/doc/charts/chart1.dat b/doc/charts/chart1.dat
new file mode 100644 (file)
index 0000000..a3d6dcd
--- /dev/null
@@ -0,0 +1,3 @@
+3      59 97 159 256
+
+
diff --git a/doc/charts/chart1.gnuplot b/doc/charts/chart1.gnuplot
new file mode 100644 (file)
index 0000000..f4ba07f
--- /dev/null
@@ -0,0 +1,23 @@
+# don't touch this
+set terminal postscript landscape color "Helvetica" 19 
+set output 'unfilled.eps'
+
+set yrange [0:300]
+set xrange [1.8:4.5]
+set data style boxes
+set boxwidth 0.4
+set xtics (" " 3)
+set xlabel "X Axis Label"
+set ylabel "Y Axis Label"
+set grid
+set label "59"  at 2.15, 69 
+set label "97"  at 2.55, 107
+set label "159" at 2.95, 169
+set label "256" at 3.35, 266
+plot \
+  'chart1.dat' using ($1-0.8):($2) title "x86",      \
+  'chart1.dat' using ($1-0.4):($3) title "Sparc",    \
+  'chart1.dat' using     ($1):($4) title "HPL-PD",   \
+  'chart1.dat' using ($1+0.4):($5) title "Canonical"
+
+
similarity index 96%
rename from doc/nestedvm.ivme04.tex
rename to doc/ivme04.tex
index c6cccbb..b1bfa6d 100644 (file)
@@ -31,28 +31,36 @@ Complete Translation of Unsafe Native Code to Safe Bytecode
 
 \maketitle
 
+{\it This document was typeset using D. E. Knuth's original \TeX 89
+     Pascal source code, which was both compiled and executed entirely
+     within a Java Virtual Machine.  No native code was utilized.}
+
 \begin{abstract}
 
 Most existing techniques for using code written in an unsafe language
 within a safe virtual machine involve transformations from one source
-code language (such as C) to another (such as Java) and then to
-virtual machine bytecodes.  We present an alternative approach which
-uses a standard compiler to turn unsafe source code into unsafe MIPS
-binaries, which are then translated into safe virtual machine
-bytecodes.  This approach offers four key advantages over existing
-techniques:
+code language (such as C, Pascal, or Fortran) to another (such as
+Java) and then to virtual machine bytecodes.  We present an
+alternative approach which can translate MIPS binaries produced by any
+compiler into safe virtual machine bytecodes.  This approach offers
+four key advantages over existing techniques:
 
 \begin{itemize}
-\item Total coverage of all language features
+\item Language-agnostic
+\item Bug-for-bug compiler compatability
 \item No post-translation human intervention
 \item No build process modifications
-\item Bug-for-bug compiler compatability
 \end{itemize}
 
-We have implemented this technique in NestedVM, a binary-to-source and
-binary-to-binary translator targeting the Java Virtual Machine.
-NestedVM-translated versions of the {\tt libfreetype}, {\tt libjpeg},
-and {\tt libmspack} libraries are currently in production use.
+We also present NestedVM, a complete implementation of this technique,
+which we have used to translate a number of programs.  Six examples
+are discussed in this paper: LINPACK (Fortran source), which was used
+as one of our performance tests, \TeX (Pascal source), which was used
+to typeset this document, {\tt libjpeg}, {\tt libmspack}, and FreeType
+(all C source), which are currently in production use as part of the
+Ibex Project, and {\tt gcc}, which was used to compile all of the
+aforementioned.
+
 Performance measurements indicate a best case performance within 3x of
 native code and worst case typically within 10x, making it an
 attractive solution for code which is not performance-critical.
@@ -535,7 +543,7 @@ sequences, a straightforward mapping of the general purpose hardware
 registers to 32 {\tt int} fields turned out to be optimal.
 
 
-\epsfig{file=chart1,width=3in}
+\epsfig{file=charts/chart1,width=3in}
 
 Unfortunately, Java imposes a 64kb limit on the size of the bytecode
 for a single method.  This presents a problem for NestedVM, and