changeset 13886:812f3155efba

merge
author Christian Wimmer <christian.wimmer@oracle.com>
date Wed, 05 Feb 2014 23:38:59 -0800
parents eceacf66c44a (current diff) afd6fa5e8229 (diff)
children f3e4f746e9c6
files GRAAL_AUTHORS README README_GRAAL.txt
diffstat 36 files changed, 313 insertions(+), 150 deletions(-) [+]
line wrap: on
line diff
--- a/.hgtags	Wed Feb 05 04:54:01 2014 -0800
+++ b/.hgtags	Wed Feb 05 23:38:59 2014 -0800
@@ -403,3 +403,4 @@
 05fedd51e40da22c9460bf17c7185889e435db3d hs25-b62
 fca262db9c4309f99d2f5542ab0780e45c2f1578 jdk8-b120
 41f4cad94c581034d4c427d2aaabcc20f26342d0 hs25-b63
+b124e22eb772806c13d942cc110de38da0108147 graal-0.1
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/AUTHORS.html	Wed Feb 05 23:38:59 2014 -0800
@@ -0,0 +1,27 @@
+<h2>Graal Authors</h2>
+
+The GraalVM is based on the source code of HotSpot. The following authors have contributed to the Graal-specific part of the source base:
+
+<ul>
+<li>Tom Deneau (tdeneau)</li>
+<li>Gilles Duboscq (gdub)</li>
+<li>Matthias Grimmer (mgrimmer)</li>
+<li>Peter Hofer</li>
+<li>Christian Haeubl (chaeubl)</li>
+<li>Michael Haupt (mhaupt)</li>
+<li>Christian Humer (chumer)</li>
+<li>Morris Meyer (morris)</li>
+<li>Roland Schatz</li>
+<li>Doug Simon (dnsimon)</li>
+<li>Lukas Stadler (lstadler)</li>
+<li>Roland Schatz (rschatz)</li>
+<li>Alexander Stipsits</li>
+<li>Katrin Strassl</li>
+<li>Christian Thalinger (twisti)</li>
+<li>Vasanth Venkatachalam (vvenkat)</li>
+<li>Christian Wimmer (cwimmer)</li>
+<li>Christian Wirth (cwirth)</li>
+<li>Andreas Woess (aw)</li>
+<li>Thomas Wuerthinger (thomaswue)</li>
+<li>Bharadwaj Yadavalli (bharadwaj)</li>	
+</ul>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/CHANGELOG.html	Wed Feb 05 23:38:59 2014 -0800
@@ -0,0 +1,34 @@
+<h1>GraalVM Changelog</h1>
+
+<h2>Tip</h2>
+<ul>
+<li>
+<b>Graal</b>
+<ul>
+<li>...</li>
+</ul>
+</li>
+<li>
+<b>Truffle</b>
+<ul>
+<li>...</li>
+</ul>
+</li></ul>
+<h2>Version 0.1</h2>
+<ul>
+<li>
+<b>Graal</b>
+<ul>
+<li>Initial version of a dynamic Java compiler written in Java.</li>
+<li>Support for multiple co-existing GPU backends (<a href="https://bugs.openjdk.java.net/browse/GRAAL-1">GRAAL-1</a>).</li>
+<li>Fixed a compiler bug when running RuneScape (<a href="https://bugs.openjdk.java.net/browse/GRAAL-7">GRAAL-7</a>).</li>
+<li>Bug fixes (<a href="https://bugs.openjdk.java.net/browse/GRAAL-4">GRAAL-4</a>, <a href="https://bugs.openjdk.java.net/browse/GRAAL-5">GRAAL-5</a>).</li>
+</ul>
+</li>
+<li>
+<b>Truffle</b>
+<ul>
+<li>Initial version of a multi-language framework on top of Graal. </li>
+<li>Update of the <a href="http://mail.openjdk.java.net/pipermail/graal-dev/2014-January/001516.html">Truffle inlining API</a>.</li>
+</ul>
+</li></ul>
--- a/GRAAL_AUTHORS	Wed Feb 05 04:54:01 2014 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,12 +0,0 @@
-Gilles Duboscq (gdub)
-Peter Hofer
-Christian Haeubl (chaeubl)
-Christian Humer (chumer)
-Roland Schatz
-Doug Simon (dnsimon)
-Lukas Stadler (lstadler)
-Alexander Stipsits
-Katrin Strassl
-Christian Wimmer (cwimmer)
-Andreas Woess (aw)
-Thomas Wuerthinger (thomaswue)
--- a/README	Wed Feb 05 04:54:01 2014 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,14 +0,0 @@
-README:
-  This file should be located at the top of the hotspot Mercurial repository.
-
-  See http://openjdk.java.net/ for more information about the OpenJDK.
-
-  See ../README-builds.html for complete details on build machine requirements.
-
-Simple Build Instructions:
-
-    cd make && gnumake
-     
-  The files that will be imported into the jdk build will be in the "build"
-  directory.
-
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/README.html	Wed Feb 05 23:38:59 2014 -0800
@@ -0,0 +1,81 @@
+<h2>Building Graal</h2>
+<p>There is a Python script in mxtool/mx.py that simplifies working with the code
+base. It requires Python 2.7. While you can run this script by using an absolute path,
+it's more convenient to add graal/mxtool to your PATH environment variable so that the
+'mx' helper script can be used. The following instructions in this file assume this
+setup.</p>
+
+<p>Building both the Java and C++ source code comprising the Graal VM
+can be done with the following simple command.</p>
+
+<pre>
+% mx build
+</pre>
+
+<p>There are a number of VM configurations supported by mx which can
+be explicitly specified using the --vm option. However, you'll typically
+want one of these VM configurations:</p>
+
+<ol>
+<li> The 'server' configuration is a standard HotSpot VM that includes the
+   runtime support for Graal but uses the existing compilers for normal
+   compilation (e.g., when the interpreter threshold is hit for a method).
+   Compilation with Graal is only done by explicit requests to the
+   Graal API. This is how Truffle uses Graal.</li>
+   
+<li> The 'graal' configuration is a VM where all compilation is performed
+   by Graal and no other compilers are built into the VM binary. This
+   VM will bootstrap Graal itself at startup unless the -XX:-BootstrapGraal
+   VM option is given.   </li>
+</ol>
+
+<p>Unless you use the --vm option with the build command, you will be presented
+with a dialogue to choose one of the above VM configurations for the build
+as well as have the option to make it your default for subsequent commands
+that need a VM specified.</p>
+
+<p>To build the debug or fastdebug builds:</p>
+
+<pre>
+% mx --vmbuild debug build
+% mx --vmbuild fastdebug build
+</pre>
+
+<h2>Running Graal</h2>
+
+<p>To run the VM, use 'mx vm' in place of the standard 'java' command:</p>
+
+<pre>
+% mx vm ...
+</pre>
+
+<p>To select the fastdebug or debug builds of the VM:</p>
+
+<pre>
+% mx --vmbuild fastdebug vm ...
+% mx --vmbuild debug vm ...
+</pre>
+
+<h2>Other VM Configurations</h2>
+
+<p>In addition to the VM configurations described above, there are
+VM configurations that omit all VM support for Graal:</p>
+
+<pre>
+% mx --vm server-nograal build
+% mx --vm server-nograal vm -version
+java version "1.7.0_25"
+Java(TM) SE Runtime Environment (build 1.7.0_25-b15)
+OpenJDK 64-Bit Server VM (build 25.0-b43-internal, mixed mode)
+</pre>
+
+<pre>
+% mx --vm client-nograal build
+% mx --vm client-nograal vm -version
+java version "1.7.0_25"
+Java(TM) SE Runtime Environment (build 1.7.0_25-b15)
+OpenJDK 64-Bit Cleint VM (build 25.0-b43-internal, mixed mode)
+</pre>
+
+<p>These configurations aim to match as closely as possible the
+VM(s) included in the OpenJDK binaries one can download.</p>
--- a/README_GRAAL.txt	Wed Feb 05 04:54:01 2014 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,70 +0,0 @@
-Building Graal
---------------
-There is a Python script in mxtool/mx.py that simplifies working with the code
-base. It requires Python 2.7. While you can run this script by using an absolute path,
-it's more convenient to add graal/mxtool to your PATH environment variable so that the
-'mx' helper script can be used. The following instructions in this file assume this
-setup.
-
-Building both the Java and C++ source code comprising the Graal VM
-can be done with the following simple command.
-
-% mx build
-
-There are a number of VM configurations supported by mx which can
-be explicitly specified using the --vm option. However, you'll typically
-want one of these VM configurations:
-
-1. The 'server' configuration is a standard HotSpot VM that includes the
-   runtime support for Graal but uses the existing compilers for normal
-   compilation (e.g., when the interpreter threshold is hit for a method).
-   Compilation with Graal is only done by explicit requests to the
-   Graal API. This is how Truffle uses Graal.
-   
-2. The 'graal' configuration is a VM where all compilation is performed
-   by Graal and no other compilers are built into the VM binary. This
-   VM will bootstrap Graal itself at startup unless the -XX:-BootstrapGraal
-   VM option is given.   
-
-Unless you use the --vm option with the build command, you will be presented
-with a dialogue to choose one of the above VM configurations for the build
-as well as have the option to make it your default for subsequent commands
-that need a VM specified.
-
-To build the debug or fastdebug builds:
-
-% mx --vmbuild debug build
-% mx --vmbuild fastdebug build
-
-Running Graal
--------------
-
-To run the VM, use 'mx vm' in place of the standard 'java' command:
-
-% mx vm ...
-
-To select the fastdebug or debug builds of the VM:
-
-% mx --vmbuild fastdebug vm ...
-% mx --vmbuild debug vm ...
-
-Other VM Configurations
------------------------
-
-In addition to the VM configurations described above, there are
-VM configurations that omit all VM support for Graal:
-
-% mx --vm server-nograal build
-% mx --vm server-nograal vm -version
-java version "1.7.0_25"
-Java(TM) SE Runtime Environment (build 1.7.0_25-b15)
-OpenJDK 64-Bit Server VM (build 25.0-b43-internal, mixed mode)
-
-% mx --vm client-nograal build
-% mx --vm client-nograal vm -version
-java version "1.7.0_25"
-Java(TM) SE Runtime Environment (build 1.7.0_25-b15)
-OpenJDK 64-Bit Cleint VM (build 25.0-b43-internal, mixed mode)
-
-These configurations aim to match as closely as possible the
-VM(s) included in the OpenJDK binaries one can download.
\ No newline at end of file
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/ConstantNode.java	Wed Feb 05 04:54:01 2014 -0800
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/ConstantNode.java	Wed Feb 05 23:38:59 2014 -0800
@@ -70,7 +70,7 @@
      * Used to measure the impact of ConstantNodes not recording their usages. This and all code
      * predicated on this value being true will be removed at some point.
      */
-    public static final boolean ConstantNodeRecordsUsages = Boolean.getBoolean("graal.constantNodeRecordsUsages");
+    public static final boolean ConstantNodeRecordsUsages = Boolean.parseBoolean(System.getProperty("graal.constantNodeRecordsUsages", "true"));
 
     @Override
     public boolean recordsUsages() {
--- a/graal/com.oracle.truffle.sl.test/tests/LoopCall.sl	Wed Feb 05 04:54:01 2014 -0800
+++ b/graal/com.oracle.truffle.sl.test/tests/LoopCall.sl	Wed Feb 05 23:38:59 2014 -0800
@@ -3,13 +3,18 @@
 }
 
 function loop(n) {
-  i = 0;  
+  i = 0;
   while (i < n) {  
     i = add(i, 1);  
-  }  
+  }
   return i;
-}  
+}
 
 function main() {
+  i = 0;
+  while (i < 20) {
+    loop(1000);
+    i = i + 1;
+  }
   println(loop(1000));  
-}  
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.truffle.sl.test/tests/LoopInvalidate.output	Wed Feb 05 23:38:59 2014 -0800
@@ -0,0 +1,1 @@
+1000
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.truffle.sl.test/tests/LoopInvalidate.sl	Wed Feb 05 23:38:59 2014 -0800
@@ -0,0 +1,21 @@
+function add(a, b) {
+  return a + b;
+}
+
+function loop(n) {
+  i = 0;  
+  while (i < n) {  
+    i = add(i, 1);  
+  }  
+  return i;
+}  
+
+function main() {
+  i = 0;
+  while (i < 20) {
+    loop(1000);
+    i = i + 1;
+  }
+  add("a", "b");
+  println(loop(1000));  
+}  
--- a/graal/com.oracle.truffle.sl.test/tests/LoopPolymorphic.sl	Wed Feb 05 04:54:01 2014 -0800
+++ b/graal/com.oracle.truffle.sl.test/tests/LoopPolymorphic.sl	Wed Feb 05 23:38:59 2014 -0800
@@ -3,14 +3,20 @@
 }
 
 function loop(n) {
-  i = 0;  
-  while (i < n) {  
-    i = add(i, 1);  
-  }  
+  i = 0;
+  while (i < n) {
+    i = add(i, 1); 
+  }
   return i;
-}  
+}
 
 function main() {
   add("a", "b");
+
+  i = 0;
+  while (i < 20) {
+    loop(1000);
+    i = i + 1;
+  }
   println(loop(1000));  
-}  
+}
--- a/graal/com.oracle.truffle.sl.test/tests/LoopPrint.sl	Wed Feb 05 04:54:01 2014 -0800
+++ b/graal/com.oracle.truffle.sl.test/tests/LoopPrint.sl	Wed Feb 05 23:38:59 2014 -0800
@@ -7,5 +7,10 @@
 }  
 
 function main() {
+  i = 0;
+  while (i < 20) {
+    loop(1000);
+    i = i + 1;
+  }
   println(loop(1000));  
 }  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.truffle.sl.test/tests/error/TypeError03.output	Wed Feb 05 23:38:59 2014 -0800
@@ -0,0 +1,1 @@
+Type error at TypeError03.sl line 2 col 7: operation "&&" not defined for String "4", ANY
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.truffle.sl.test/tests/error/TypeError03.sl	Wed Feb 05 23:38:59 2014 -0800
@@ -0,0 +1,3 @@
+function main() {  
+  "4" && 4;  
+}  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.truffle.sl.test/tests/error/TypeError04.output	Wed Feb 05 23:38:59 2014 -0800
@@ -0,0 +1,1 @@
+Type error at TypeError04.sl line 2 col 11: operation "||" not defined for Boolean false, Number 4
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.truffle.sl.test/tests/error/TypeError04.sl	Wed Feb 05 23:38:59 2014 -0800
@@ -0,0 +1,3 @@
+function main() {  
+  (1 > 2) || 4;  
+}  
--- a/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/SLMain.java	Wed Feb 05 04:54:01 2014 -0800
+++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/SLMain.java	Wed Feb 05 23:38:59 2014 -0800
@@ -183,8 +183,10 @@
     }
 
     /**
-     * Dumps the AST of all functions to the IGV visualizer, via a socket connection. IGV can be
-     * started with the mx command "mx igv". Optionally, also prints the ASTs to the console.
+     * When dumpASTToIGV is true: dumps the AST of all functions to the IGV visualizer, via a socket
+     * connection. IGV can be started with the mx command "mx igv".
+     * <p>
+     * When printASTToLog is true: prints the ASTs to the console.
      */
     private static void printScript(String groupName, SLContext context, PrintStream logOutput, boolean printASTToLog, boolean dumpASTToIGV) {
         if (dumpASTToIGV) {
--- a/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/builtins/SLDefineFunctionBuiltin.java	Wed Feb 05 04:54:01 2014 -0800
+++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/builtins/SLDefineFunctionBuiltin.java	Wed Feb 05 23:38:59 2014 -0800
@@ -22,10 +22,12 @@
  */
 package com.oracle.truffle.sl.builtins;
 
+import com.oracle.truffle.api.CompilerDirectives.SlowPath;
 import com.oracle.truffle.api.*;
 import com.oracle.truffle.api.dsl.*;
 import com.oracle.truffle.api.nodes.*;
 import com.oracle.truffle.sl.parser.*;
+import com.oracle.truffle.sl.runtime.*;
 
 /**
  * Builtin function to define (or redefine) functions. The provided source code is parsed the same
@@ -36,9 +38,14 @@
 
     @Specialization
     public String defineFunction(String code) {
-        Source source = getContext().getSourceManager().get("[defineFunction]", code);
+        return doDefineFunction(getContext(), code);
+    }
+
+    @SlowPath
+    private static String doDefineFunction(SLContext context, String code) {
+        Source source = context.getSourceManager().get("[defineFunction]", code);
         /* The same parsing code as for parsing the initial source. */
-        Parser.parseSL(getContext(), source);
+        Parser.parseSL(context, source);
         return code;
     }
 }
--- a/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/builtins/SLPrintlnBuiltin.java	Wed Feb 05 04:54:01 2014 -0800
+++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/builtins/SLPrintlnBuiltin.java	Wed Feb 05 23:38:59 2014 -0800
@@ -22,6 +22,9 @@
  */
 package com.oracle.truffle.sl.builtins;
 
+import java.io.*;
+
+import com.oracle.truffle.api.CompilerDirectives.SlowPath;
 import com.oracle.truffle.api.dsl.*;
 import com.oracle.truffle.api.nodes.*;
 import com.oracle.truffle.sl.runtime.*;
@@ -30,31 +33,55 @@
  * Builtin function to write a value to the {@link SLContext#getOutput() standard output}. The
  * different specialization leverage the typed {@code println} methods available in Java, i.e.,
  * primitive values are printed without converting them to a {@link String} first.
+ * <p>
+ * Printing involves a lot of Java code, so we need to tell the optimizing system that it should not
+ * unconditionally inline everything reachable from the println() method. This is done via the
+ * {@link SlowPath} annotations.
  */
 @NodeInfo(shortName = "println")
 public abstract class SLPrintlnBuiltin extends SLBuiltinNode {
 
     @Specialization
     public long println(long value) {
-        getContext().getOutput().println(value);
+        doPrint(getContext().getOutput(), value);
         return value;
     }
 
+    @SlowPath
+    private static void doPrint(PrintStream out, long value) {
+        out.println(value);
+    }
+
     @Specialization
     public boolean println(boolean value) {
-        getContext().getOutput().println(value);
+        doPrint(getContext().getOutput(), value);
         return value;
     }
 
+    @SlowPath
+    private static void doPrint(PrintStream out, boolean value) {
+        out.println(value);
+    }
+
     @Specialization
     public String println(String value) {
-        getContext().getOutput().println(value);
+        doPrint(getContext().getOutput(), value);
         return value;
     }
 
+    @SlowPath
+    private static void doPrint(PrintStream out, String value) {
+        out.println(value);
+    }
+
     @Specialization
     public Object println(Object value) {
-        getContext().getOutput().println(value);
+        doPrint(getContext().getOutput(), value);
         return value;
     }
+
+    @SlowPath
+    private static void doPrint(PrintStream out, Object value) {
+        out.println(value);
+    }
 }
--- a/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/builtins/SLReadlnBuiltin.java	Wed Feb 05 04:54:01 2014 -0800
+++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/builtins/SLReadlnBuiltin.java	Wed Feb 05 23:38:59 2014 -0800
@@ -24,6 +24,7 @@
 
 import java.io.*;
 
+import com.oracle.truffle.api.CompilerDirectives.SlowPath;
 import com.oracle.truffle.api.dsl.*;
 import com.oracle.truffle.api.nodes.*;
 import com.oracle.truffle.sl.*;
@@ -37,17 +38,22 @@
 
     @Specialization
     public String readln() {
+        String result = doRead(getContext().getInput());
+        if (result == null) {
+            /*
+             * We do not have a sophisticated end of file handling, so returning an empty string is
+             * a reasonable alternative. Note that the Java null value should never be used, since
+             * it can interfere with the specialization logic in generated source code.
+             */
+            result = "";
+        }
+        return result;
+    }
+
+    @SlowPath
+    private static String doRead(BufferedReader in) {
         try {
-            String result = getContext().getInput().readLine();
-            if (result == null) {
-                /*
-                 * We do not have a sophisticated end of file handling, so returning an empty string
-                 * is a reasonable alternative. Note that the Java null value should never be used,
-                 * since it can interfere with the specialization logic in generated source code.
-                 */
-                result = "";
-            }
-            return result;
+            return in.readLine();
         } catch (IOException ex) {
             throw new SLException(ex.getMessage());
         }
--- a/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/SLBinaryNode.java	Wed Feb 05 04:54:01 2014 -0800
+++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/SLBinaryNode.java	Wed Feb 05 23:38:59 2014 -0800
@@ -26,8 +26,8 @@
 
 /**
  * Utility base class for operations that take two arguments (per convention called "left" and
- * "right). For concrete subclasses of this class, the Truffle DSL creates two child fields, and the
- * necessary constructors and logic to set them.
+ * "right"). For concrete subclasses of this class, the Truffle DSL creates two child fields, and
+ * the necessary constructors and logic to set them.
  */
 @NodeChildren({@NodeChild("leftNode"), @NodeChild("rightNode")})
 public abstract class SLBinaryNode extends SLExpressionNode {
--- a/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/SLTypes.java	Wed Feb 05 04:54:01 2014 -0800
+++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/SLTypes.java	Wed Feb 05 23:38:59 2014 -0800
@@ -29,10 +29,10 @@
 import com.oracle.truffle.sl.runtime.*;
 
 /**
- * The type system of SL, as explained in {@link SLMain}. Based on the annotation {@link TypeSystem}
- * , the Truffle DSL generates the subclass {@link SLTypesGen} with type test and type conversion
- * methods for all types. In this class, we only cover types where the automatically generated ones
- * would not be sufficient.
+ * The type system of SL, as explained in {@link SLMain}. Based on the {@link TypeSystem}
+ * annotation, the Truffle DSL generates the subclass {@link SLTypesGen} with type test and type
+ * conversion methods for all types. In this class, we only cover types where the automatically
+ * generated ones would not be sufficient.
  */
 @TypeSystem({long.class, BigInteger.class, boolean.class, String.class, SLFunction.class, SLNull.class})
 public abstract class SLTypes {
--- a/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/call/SLCallNode.java	Wed Feb 05 04:54:01 2014 -0800
+++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/call/SLCallNode.java	Wed Feb 05 23:38:59 2014 -0800
@@ -22,6 +22,7 @@
  */
 package com.oracle.truffle.sl.nodes.call;
 
+import com.oracle.truffle.api.*;
 import com.oracle.truffle.api.dsl.*;
 import com.oracle.truffle.api.frame.*;
 import com.oracle.truffle.api.nodes.*;
@@ -57,6 +58,14 @@
     public Object executeGeneric(VirtualFrame frame) {
         SLFunction function = evaluateFunction(frame);
 
+        /*
+         * The number of arguments is constant for one call node. During compilation, the loop is
+         * unrolled and the execute methods of all arguments are inlined. This is triggered by the
+         * ExplodeLoop annotation on the method. The compiler assertion below illustrates that the
+         * array length is really constant.
+         */
+        CompilerAsserts.compilationConstant(argumentNodes.length);
+
         Object[] argumentValues = new Object[argumentNodes.length];
         for (int i = 0; i < argumentNodes.length; i++) {
             argumentValues[i] = argumentNodes[i].executeGeneric(frame);
--- a/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/controlflow/SLBlockNode.java	Wed Feb 05 04:54:01 2014 -0800
+++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/controlflow/SLBlockNode.java	Wed Feb 05 23:38:59 2014 -0800
@@ -22,6 +22,7 @@
  */
 package com.oracle.truffle.sl.nodes.controlflow;
 
+import com.oracle.truffle.api.*;
 import com.oracle.truffle.api.frame.*;
 import com.oracle.truffle.api.nodes.*;
 import com.oracle.truffle.sl.nodes.*;
@@ -30,7 +31,7 @@
  * A statement node that just executes a list of other statements.
  */
 @NodeInfo(shortName = "block")
-public class SLBlockNode extends SLStatementNode {
+public final class SLBlockNode extends SLStatementNode {
 
     /**
      * The array of child nodes. The annotation {@link com.oracle.truffle.api.nodes.Node.Children
@@ -55,6 +56,12 @@
     @Override
     @ExplodeLoop
     public void executeVoid(VirtualFrame frame) {
+        /*
+         * This assertion illustrates that the arryay length is really a constant during
+         * compilation.
+         */
+        CompilerAsserts.compilationConstant(bodyNodes.length);
+
         for (SLStatementNode statement : bodyNodes) {
             statement.executeVoid(frame);
         }
--- a/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/controlflow/SLFunctionBodyNode.java	Wed Feb 05 04:54:01 2014 -0800
+++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/controlflow/SLFunctionBodyNode.java	Wed Feb 05 23:38:59 2014 -0800
@@ -36,7 +36,7 @@
  * {@link SLNull#SINGLETON default null value}.
  */
 @NodeInfo(shortName = "body")
-public class SLFunctionBodyNode extends SLExpressionNode {
+public final class SLFunctionBodyNode extends SLExpressionNode {
 
     /** The body of the function. */
     @Child private SLStatementNode bodyNode;
--- a/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/controlflow/SLIfNode.java	Wed Feb 05 04:54:01 2014 -0800
+++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/controlflow/SLIfNode.java	Wed Feb 05 23:38:59 2014 -0800
@@ -29,7 +29,7 @@
 import com.oracle.truffle.sl.nodes.*;
 
 @NodeInfo(shortName = "if")
-public class SLIfNode extends SLStatementNode {
+public final class SLIfNode extends SLStatementNode {
 
     /**
      * The condition of the {@code if}. This in a {@link SLExpressionNode} because we require a
--- a/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/controlflow/SLReturnNode.java	Wed Feb 05 04:54:01 2014 -0800
+++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/controlflow/SLReturnNode.java	Wed Feb 05 23:38:59 2014 -0800
@@ -35,7 +35,7 @@
  * the return value.
  */
 @NodeInfo(shortName = "return")
-public class SLReturnNode extends SLStatementNode {
+public final class SLReturnNode extends SLStatementNode {
 
     @Child private SLExpressionNode valueNode;
 
--- a/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/controlflow/SLWhileNode.java	Wed Feb 05 04:54:01 2014 -0800
+++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/controlflow/SLWhileNode.java	Wed Feb 05 23:38:59 2014 -0800
@@ -30,7 +30,7 @@
 import com.oracle.truffle.sl.nodes.*;
 
 @NodeInfo(shortName = "while")
-public class SLWhileNode extends SLStatementNode {
+public final class SLWhileNode extends SLStatementNode {
 
     /**
      * The condition of the loop. This in a {@link SLExpressionNode} because we require a result
--- a/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLDivNode.java	Wed Feb 05 04:54:01 2014 -0800
+++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLDivNode.java	Wed Feb 05 23:38:59 2014 -0800
@@ -29,13 +29,16 @@
 import com.oracle.truffle.sl.nodes.*;
 
 /**
- * This class is similar to the extensively documented {@link SLAddNode}.
+ * This class is similar to the extensively documented {@link SLAddNode}. Divisions by 0 throw the
+ * same {@link ArithmeticException exception} as in Java, SL has no special handling for it to keep
+ * the code simple.
  */
 @NodeInfo(shortName = "/")
 public abstract class SLDivNode extends SLBinaryNode {
 
-    @Specialization(rewriteOn = ArithmeticException.class)
+    @Specialization
     protected long div(long left, long right) {
+        /* No overflow is possible on a division. */
         return left / right;
     }
 
--- a/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLEqualNode.java	Wed Feb 05 04:54:01 2014 -0800
+++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLEqualNode.java	Wed Feb 05 23:38:59 2014 -0800
@@ -30,7 +30,7 @@
 import com.oracle.truffle.sl.runtime.*;
 
 /**
- * The {@code ==} operator of SL is defined on all types. Therefore, we need a (@link
+ * The {@code ==} operator of SL is defined on all types. Therefore, we need a
  * {@link #equal(Object, Object) generic implementation} that can handle all possible types. But
  * since {@code ==} can only return {@code true} when the type of the left and right operand are the
  * same, the specializations already cover all possible cases that can return {@code true} and the
@@ -78,7 +78,7 @@
     }
 
     /**
-     * The {@link Generic} annotation informs that Truffle DSL that this method should be executed
+     * The {@link Generic} annotation informs the Truffle DSL that this method should be executed
      * when no {@link Specialization specialized method} matches. The operand types must be
      * {@link Object}.
      */
--- a/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/local/SLReadArgumentNode.java	Wed Feb 05 04:54:01 2014 -0800
+++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/local/SLReadArgumentNode.java	Wed Feb 05 23:38:59 2014 -0800
@@ -32,10 +32,10 @@
 /**
  * Reads a function argument. Arguments are passed in as a {@link SLArguments} object, which
  * encapsulates an {@link SLArguments#getFromFrame Object[] array}. Language-defined subclasses of
- * {@link Arguments} are the standard Truffle way to pass values between function.
+ * {@link Arguments} are the standard Truffle way to pass values between functions.
  * <p>
  * Arguments are not type-specialized. To ensure that repeated accesses within a method are
- * specialized and can, e.g., accessed without unboxing, all arguments are loaded into local
+ * specialized and can, e.g., be accessed without unboxing, all arguments are loaded into local
  * variables {@link SLNodeFactory#addFormalParameter in the method prologue}.
  */
 public class SLReadArgumentNode extends SLExpressionNode {
--- a/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/local/SLReadLocalVariableNode.java	Wed Feb 05 04:54:01 2014 -0800
+++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/local/SLReadLocalVariableNode.java	Wed Feb 05 23:38:59 2014 -0800
@@ -33,7 +33,6 @@
  * variable changes its type, the frame access method throws an {@link FrameSlotTypeException},
  * which causes not rewriting. The rewriting code is generated by the Truffle DSL.
  */
-@PolymorphicLimit(1)
 @NodeField(name = "slot", type = FrameSlot.class)
 public abstract class SLReadLocalVariableNode extends SLExpressionNode {
 
@@ -53,13 +52,17 @@
         return frame.getBoolean(getSlot());
     }
 
-    @Specialization(rewriteOn = {FrameSlotTypeException.class})
+    @Specialization(order = 1, rewriteOn = {FrameSlotTypeException.class})
     protected Object readObject(VirtualFrame frame) throws FrameSlotTypeException {
         return frame.getObject(getSlot());
     }
 
-    @Generic
-    protected Object readGeneric(VirtualFrame frame) {
+    /**
+     * This is the generic case that always succeeds. Since we already have another specialization
+     * with the same signature above, we need to order them explicitly with the order attribute.
+     */
+    @Specialization(order = 2)
+    protected Object read(VirtualFrame frame) {
         return frame.getValue(getSlot());
     }
 }
--- a/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/local/SLWriteLocalVariableNode.java	Wed Feb 05 04:54:01 2014 -0800
+++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/local/SLWriteLocalVariableNode.java	Wed Feb 05 23:38:59 2014 -0800
@@ -42,7 +42,7 @@
     protected abstract FrameSlot getSlot();
 
     /**
-     * Specialized method to write a primitive {@code long} value}. This is only possible if the
+     * Specialized method to write a primitive {@code long} value. This is only possible if the
      * local variable also has currently the type {@code long}, therefore a Truffle DSL
      * {@link #isLongKind() custom guard} is specified.
      */
--- a/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SimpleLanguage.atg	Wed Feb 05 04:54:01 2014 -0800
+++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SimpleLanguage.atg	Wed Feb 05 23:38:59 2014 -0800
@@ -21,6 +21,12 @@
  * questions.
  */
 
+/*
+ * This is the grammar of SL that is used to automatically generate the Parser.java and Scanner.java
+ * files. You can download the parser generator Coco/R from http://ssw.jku.at/coco/. Then run
+ * "java -jar Coco.jar SimpleLanguage.atg"
+ */
+
 COMPILER SimpleLanguage
 
 CHARACTERS
--- a/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/runtime/SLContext.java	Wed Feb 05 04:54:01 2014 -0800
+++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/runtime/SLContext.java	Wed Feb 05 23:38:59 2014 -0800
@@ -39,9 +39,9 @@
  * context is used during {@link SLNodeFactory parsing} and by {@link SLBuiltinNode#getContext()
  * builtin functions}.
  * <p>
- * It would be an error to have two different context instances at the same. From a software
- * engineering point of view, it is better to pass around this encapsulated context object instead
- * of storing the data in static Java fields.
+ * It would be an error to have two different context instances during the execution of one script.
+ * However, if two separate scripts run in one Java VM at the same time, they have a different
+ * context. Therefore, the context is not a singleton.
  */
 public final class SLContext {
     private final SourceManager sourceManager;