changeset 11547:cefd4cb3cb2d

Merge.
author Christian Humer <christian.humer@gmail.com>
date Fri, 06 Sep 2013 16:17:16 +0200
parents f1c3f50ac36e (current diff) edf875b3c091 (diff)
children 6014bd8d52ce
files graal/com.oracle.graal.graph/src/com/oracle/graal/graph/NodeUsagesList.java
diffstat 46 files changed, 1484 insertions(+), 879 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.api.meta.test/src/com/oracle/graal/api/meta/test/TestResolvedJavaType.java	Fri Sep 06 16:17:01 2013 +0200
+++ b/graal/com.oracle.graal.api.meta.test/src/com/oracle/graal/api/meta/test/TestResolvedJavaType.java	Fri Sep 06 16:17:16 2013 +0200
@@ -594,6 +594,7 @@
         "getDeclaredMethods",
         "getDeclaredConstructors",
         "isInitialized",
+        "isLinked",
         "getEncoding",
         "hasFinalizableSubclass",
         "hasFinalizer",
--- a/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/ResolvedJavaMethod.java	Fri Sep 06 16:17:01 2013 +0200
+++ b/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/ResolvedJavaMethod.java	Fri Sep 06 16:17:16 2013 +0200
@@ -34,9 +34,14 @@
 
     /**
      * Returns the bytecode of this method, if the method has code. The returned byte array does not
-     * contain breakpoints or non-Java bytecodes.
+     * contain breakpoints or non-Java bytecodes. This may return null if the
+     * {@link #getDeclaringClass() holder} is not {@link ResolvedJavaType#isLinked() linked}.
      * 
-     * @return the bytecode of the method, or {@code null} if {@code getCodeSize() == 0}
+     * The contained constant pool indices may not be the ones found in the original class file but
+     * they can be used with the Graal API (e.g. methods in {@link ConstantPool}).
+     * 
+     * @return the bytecode of the method, or {@code null} if {@code getCodeSize() == 0} or if the
+     *         code is not ready.
      */
     byte[] getCode();
 
--- a/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/ResolvedJavaType.java	Fri Sep 06 16:17:01 2013 +0200
+++ b/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/ResolvedJavaType.java	Fri Sep 06 16:17:16 2013 +0200
@@ -112,7 +112,8 @@
     int getModifiers();
 
     /**
-     * Checks whether this type is initialized.
+     * Checks whether this type is initialized. If a type is initialized it implies that is was
+     * {@link #isLinked() linked} and that the static initializer has run.
      * 
      * @return {@code true} if this type is initialized
      */
@@ -124,6 +125,14 @@
     void initialize();
 
     /**
+     * Checks whether this type is linked and verified. When a type is linked the static initializer
+     * has not necessarily run. An {@link #isInitialized() initialized} type is always linked.
+     * 
+     * @return {@code true} if this type is linked
+     */
+    boolean isLinked();
+
+    /**
      * Determines if this type is either the same as, or is a superclass or superinterface of, the
      * type represented by the specified parameter. This method is identical to
      * {@link Class#isAssignableFrom(Class)} in terms of the value return for this type.
--- a/graal/com.oracle.graal.asm.ptx/src/com/oracle/graal/asm/ptx/PTXAssembler.java	Fri Sep 06 16:17:01 2013 +0200
+++ b/graal/com.oracle.graal.asm.ptx/src/com/oracle/graal/asm/ptx/PTXAssembler.java	Fri Sep 06 16:17:16 2013 +0200
@@ -272,69 +272,69 @@
     }
 
     public final void ld_global_b8(Register d, Register a, long immOff) {
-        emitString("ld.global.b8" + " " + "%r" + d.encoding() + ", [" + a.toString() + " + " + immOff + "]" + ";" + "");
+        emitString("ld.global.b8" + " " + "%r" + d.encoding() + ", [" + a + " + " + immOff + "]" + ";" + "");
     }
 
     public final void ld_global_b16(Register d, Register a, long immOff) {
-        emitString("ld.global.b16" + " " + "%r" + d.encoding() + ", [" + a.toString() + " + " + immOff + "]" + ";" + "");
+        emitString("ld.global.b16" + " " + "%r" + d.encoding() + ", [" + a + " + " + immOff + "]" + ";" + "");
     }
 
     public final void ld_global_b32(Register d, Register a, long immOff) {
-        emitString("ld.global.b32" + " " + "%r" + d.encoding() + ", [" + a.toString() + " + " + immOff + "]" + ";" + "");
+        emitString("ld.global.b32" + " " + "%r" + d.encoding() + ", [" + a + " + " + immOff + "]" + ";" + "");
     }
 
     public final void ld_global_b64(Register d, Register a, long immOff) {
-        emitString("ld.global.b64" + " " + "%r" + d.encoding() + ", [" + a.toString() + " + " + immOff + "]" + ";" + "");
+        emitString("ld.global.b64" + " " + "%r" + d.encoding() + ", [" + a + " + " + immOff + "]" + ";" + "");
     }
 
     public final void ld_global_u8(Register d, Register a, long immOff) {
-        emitString("ld.global.u8" + " " + "%r" + d.encoding() + ", [" + a.toString() + " + " + immOff + "]" + ";" + "");
+        emitString("ld.global.u8" + " " + "%r" + d.encoding() + ", [" + a + " + " + immOff + "]" + ";" + "");
     }
 
     public final void ld_global_u16(Register d, Register a, long immOff) {
-        emitString("ld.global.u16" + " " + "%r" + d.encoding() + ", [" + a.toString() + " + " + immOff + "]" + ";" + "");
+        emitString("ld.global.u16" + " " + "%r" + d.encoding() + ", [" + a + " + " + immOff + "]" + ";" + "");
     }
 
     public final void ld_global_u32(Register d, Register a, long immOff) {
-        emitString("ld.global.u32" + " " + "%r" + d.encoding() + ", [" + a.toString() + " + " + immOff + "]" + ";" + "");
+        emitString("ld.global.u32" + " " + "%r" + d.encoding() + ", [" + a + " + " + immOff + "]" + ";" + "");
     }
 
     public final void ld_global_u64(Register d, Register a, long immOff) {
-        emitString("ld.global.u64" + " " + "%r" + d.encoding() + ", [" + a.toString() + " + " + immOff + "]" + ";" + "");
+        emitString("ld.global.u64" + " " + "%r" + d.encoding() + ", [" + a + " + " + immOff + "]" + ";" + "");
     }
 
     public final void ld_global_s8(Register d, Register a, long immOff) {
-        emitString("ld.global.s8" + " " + "%r" + d.encoding() + ", [" + a.toString() + " + " + immOff + "]" + ";" + "");
+        emitString("ld.global.s8" + " " + "%r" + d.encoding() + ", [" + a + " + " + immOff + "]" + ";" + "");
     }
 
     public final void ld_global_s16(Register d, Register a, long immOff) {
-        emitString("ld.global.s16" + " " + "%r" + d.encoding() + ", [" + a.toString() + " + " + immOff + "]" + ";" + "");
+        emitString("ld.global.s16" + " " + "%r" + d.encoding() + ", [" + a + " + " + immOff + "]" + ";" + "");
     }
 
     public final void ld_global_s32(Register d, Register a, long immOff) {
-        emitString("ld.global.s32" + " " + "%r" + d.encoding() + ", [" + a.toString() + " + " + immOff + "]" + ";" + "");
+        emitString("ld.global.s32" + " " + "%r" + d.encoding() + ", [" + a + " + " + immOff + "]" + ";" + "");
     }
 
     public final void ld_global_s64(Register d, Register a, long immOff) {
-        emitString("ld.global.s64" + " " + "%r" + d.encoding() + ", [" + a.toString() + " + " + immOff + "]" + ";" + "");
+        emitString("ld.global.s64" + " " + "%r" + d.encoding() + ", [" + a + " + " + immOff + "]" + ";" + "");
     }
 
     public final void ld_global_f32(Register d, Register a, long immOff) {
-        emitString("ld.global.f32" + " " + "%r" + d.encoding() + ", [" + a.toString() + " + " + immOff + "]" + ";" + "");
+        emitString("ld.global.f32" + " " + "%r" + d.encoding() + ", [" + a + " + " + immOff + "]" + ";" + "");
     }
 
     public final void ld_global_f64(Register d, Register a, long immOff) {
-        emitString("ld.global.f64" + " " + "%r" + d.encoding() + ", [" + a.toString() + " + " + immOff + "]" + ";" + "");
+        emitString("ld.global.f64" + " " + "%r" + d.encoding() + ", [" + a + " + " + immOff + "]" + ";" + "");
     }
 
     // Load from state space to destination register
     public final void ld_from_state_space(String s, Register d, Register a, long immOff) {
-        emitString("ld" + s + " " + "%r" + d.encoding() + ", [" + a.toString() + " + " + immOff + "]" + ";" + "");
+        emitString("ld" + s + " " + "%r" + d.encoding() + ", [" + a + " + " + immOff + "]" + ";" + "");
     }
 
     // Load return address from return parameter which is in .param state space
     public final void ld_return_address(String s, Register d, Register a, long immOff) {
-        emitString("ld.param." + s + " " + "%r" + d.encoding() + ", [" + a.toString() + " + " + immOff + "]" + ";" + "");
+        emitString("ld.param." + s + " " + "%r" + d.encoding() + ", [" + a + " + " + immOff + "]" + ";" + "");
     }
 
     public final void mov_b16(Register d, Register a) {
@@ -429,68 +429,68 @@
         emitString("mov.f64" + " " + "%r" + d.encoding() + ", " + f64 + ";" + "");
     }
 
-    public final void mul_f32(Register d, Register a, Register b) {
-        emitString("mul.f32" + " " + "%r" + d.encoding() + ", %r" + a.encoding() + ", %r" + b.encoding() + ";" + "");
+    public final void mul_lo_f32(Register d, Register a, Register b) {
+        emitString("mul.lo.f32" + " " + "%r" + d.encoding() + ", %r" + a.encoding() + ", %r" + b.encoding() + ";" + "");
     }
 
-    public final void mul_f64(Register d, Register a, Register b) {
-        emitString("smul.f64" + " " + "%r" + d.encoding() + ", %r" + a.encoding() + ", %r" + b.encoding() + ";" + "");
+    public final void mul_lo_f64(Register d, Register a, Register b) {
+        emitString("mul.lo.f64" + " " + "%r" + d.encoding() + ", %r" + a.encoding() + ", %r" + b.encoding() + ";" + "");
     }
 
-    public final void mul_s16(Register d, Register a, Register b) {
-        emitString("mul.s16" + " " + "%r" + d.encoding() + ", %r" + a.encoding() + ", %r" + b.encoding() + ";" + "");
+    public final void mul_lo_s16(Register d, Register a, Register b) {
+        emitString("mul.lo.s16" + " " + "%r" + d.encoding() + ", %r" + a.encoding() + ", %r" + b.encoding() + ";" + "");
     }
 
-    public final void mul_s32(Register d, Register a, Register b) {
-        emitString("mul.s32" + " " + "%r" + d.encoding() + ", %r" + a.encoding() + ", %r" + b.encoding() + ";" + "");
+    public final void mul_lo_s32(Register d, Register a, Register b) {
+        emitString("mul.lo.s32" + " " + "%r" + d.encoding() + ", %r" + a.encoding() + ", %r" + b.encoding() + ";" + "");
     }
 
-    public final void mul_s64(Register d, Register a, Register b) {
-        emitString("mul.s64" + " " + "%r" + d.encoding() + ", %r" + a.encoding() + ", %r" + b.encoding() + ";" + "");
+    public final void mul_lo_s64(Register d, Register a, Register b) {
+        emitString("mul.lo.s64" + " " + "%r" + d.encoding() + ", %r" + a.encoding() + ", %r" + b.encoding() + ";" + "");
     }
 
-    public final void mul_s16(Register d, Register a, short s16) {
-        emitString("mul.s16" + " " + "%r" + d.encoding() + ", %r" + a.encoding() + ", " + s16 + ";" + "");
+    public final void mul_lo_s16(Register d, Register a, short s16) {
+        emitString("mul.lo.s16" + " " + "%r" + d.encoding() + ", %r" + a.encoding() + ", " + s16 + ";" + "");
     }
 
-    public final void mul_s32(Register d, Register a, int s32) {
-        emitString("mul.s32" + " " + "%r" + d.encoding() + ", %r" + a.encoding() + ", " + s32 + ";" + "");
+    public final void mul_lo_s32(Register d, Register a, int s32) {
+        emitString("mul.lo.s32" + " " + "%r" + d.encoding() + ", %r" + a.encoding() + ", " + s32 + ";" + "");
     }
 
-    public final void mul_s64(Register d, Register a, long s64) {
-        emitString("mul.s64" + " " + "%r" + d.encoding() + ", %r" + a.encoding() + ", " + s64 + ";" + "");
+    public final void mul_lo_s64(Register d, Register a, long s64) {
+        emitString("mul.lo.s64" + " " + "%r" + d.encoding() + ", %r" + a.encoding() + ", " + s64 + ";" + "");
     }
 
-    public final void mul_f32(Register d, Register a, float f32) {
-        emitString("mul.f32" + " " + "%r" + d.encoding() + ", %r" + a.encoding() + ", " + f32 + ";" + "");
+    public final void mul_lo_f32(Register d, Register a, float f32) {
+        emitString("mul.lo.f32" + " " + "%r" + d.encoding() + ", %r" + a.encoding() + ", " + f32 + ";" + "");
     }
 
-    public final void mul_f64(Register d, Register a, double f64) {
-        emitString("mul.f64" + " " + "%r" + d.encoding() + ", %r" + a.encoding() + ", " + f64 + ";" + "");
+    public final void mul_lo_f64(Register d, Register a, double f64) {
+        emitString("mul.lo.f64" + " " + "%r" + d.encoding() + ", %r" + a.encoding() + ", " + f64 + ";" + "");
     }
 
-    public final void mul_u16(Register d, Register a, Register b) {
-        emitString("mul.u16" + " " + "%r" + d.encoding() + ", %r" + a.encoding() + ", %r" + b.encoding() + ";" + "");
+    public final void mul_lo_u16(Register d, Register a, Register b) {
+        emitString("mul.lo.u16" + " " + "%r" + d.encoding() + ", %r" + a.encoding() + ", %r" + b.encoding() + ";" + "");
     }
 
-    public final void mul_u32(Register d, Register a, Register b) {
-        emitString("mul.u32" + " " + "%r" + d.encoding() + ", %r" + a.encoding() + ", %r" + b.encoding() + ";" + "");
+    public final void mul_lo_u32(Register d, Register a, Register b) {
+        emitString("mul.lo.u32" + " " + "%r" + d.encoding() + ", %r" + a.encoding() + ", %r" + b.encoding() + ";" + "");
     }
 
-    public final void mul_u64(Register d, Register a, Register b) {
-        emitString("mul.u64" + " " + "%r" + d.encoding() + ", %r" + a.encoding() + ", %r" + b.encoding() + ";" + "");
+    public final void mul_lo_u64(Register d, Register a, Register b) {
+        emitString("mul.lo.u64" + " " + "%r" + d.encoding() + ", %r" + a.encoding() + ", %r" + b.encoding() + ";" + "");
     }
 
-    public final void mul_u16(Register d, Register a, short u16) {
-        emitString("mul.u16" + " " + "%r" + d.encoding() + ", %r" + a.encoding() + ", " + u16 + ";" + "");
+    public final void mul_lo_u16(Register d, Register a, short u16) {
+        emitString("mul.lo.u16" + " " + "%r" + d.encoding() + ", %r" + a.encoding() + ", " + u16 + ";" + "");
     }
 
-    public final void mul_u32(Register d, Register a, int u32) {
-        emitString("mul.u32" + " " + "%r" + d.encoding() + ", %r" + a.encoding() + ", " + u32 + ";" + "");
+    public final void mul_lo_u32(Register d, Register a, int u32) {
+        emitString("mul.lo.u32" + " " + "%r" + d.encoding() + ", %r" + a.encoding() + ", " + u32 + ";" + "");
     }
 
-    public final void mul_u64(Register d, Register a, long u64) {
-        emitString("mul.u64" + " " + "%r" + d.encoding() + ", %r" + a.encoding() + ", " + u64 + ";" + "");
+    public final void mul_lo_u64(Register d, Register a, long u64) {
+        emitString("mul.lo.u64" + " " + "%r" + d.encoding() + ", %r" + a.encoding() + ", " + u64 + ";" + "");
     }
 
     public final void neg_f32(Register d, Register a) {
@@ -550,15 +550,15 @@
     }
 
     public final void param_8_decl(Register d, boolean lastParam) {
-        emitString(".param" + " " + ".s8" + " " + d.toString() + (lastParam ? "" : ","));
+        emitString(".param" + " " + ".s8" + " " + d + (lastParam ? "" : ","));
     }
 
     public final void param_32_decl(Register d, boolean lastParam) {
-        emitString(".param" + " " + ".s32" + " " + d.toString() + (lastParam ? "" : ","));
+        emitString(".param" + " " + ".s32" + " " + d + (lastParam ? "" : ","));
     }
 
     public final void param_64_decl(Register d, boolean lastParam) {
-        emitString(".param" + " " + ".s64" + " " + d.toString() + (lastParam ? "" : ","));
+        emitString(".param" + " " + ".s64" + " " + d + (lastParam ? "" : ","));
     }
 
     public final void popc_b32(Register d, Register a) {
@@ -849,54 +849,32 @@
         emitString("setp.ge.u32" + " " + "%p" + ", " + u32 + ", %r" + b.encoding() + ";" + "");
     }
 
-    public final void shl_s16(Register d, Register a, Register b) {
-        emitString("shl.s16" + " " + "%r" + d.encoding() + ", %r" + a.encoding() + ", %r" + b.encoding() + ";" + "");
-    }
-
-    public final void shl_s32(Register d, Register a, Register b) {
-        emitString("shl.s32" + " " + "%r" + d.encoding() + ", %r" + a.encoding() + ", %r" + b.encoding() + ";" + "");
+    // Shift left - only types supported are .b16, .b32 and .b64
+    public final void shl_b16(Register d, Register a, Register b) {
+        emitString("shl.b16" + " " + "%r" + d.encoding() + ", %r" + a.encoding() + ", %r" + b.encoding() + ";" + "");
     }
 
-    public final void shl_s64(Register d, Register a, Register b) {
-        emitString("shl.s64" + " " + "%r" + d.encoding() + ", %r" + a.encoding() + ", %r" + b.encoding() + ";" + "");
+    public final void shl_b32(Register d, Register a, Register b) {
+        emitString("shl.b32" + " " + "%r" + d.encoding() + ", %r" + a.encoding() + ", %r" + b.encoding() + ";" + "");
     }
 
-    public final void shl_s16(Register d, Register a, int u32) {
-        emitString("shl.s16" + " " + "%r" + d.encoding() + ", %r" + a.encoding() + ", " + u32 + ";" + "");
-    }
-
-    public final void shl_s32(Register d, Register a, int u32) {
-        emitString("shl.s32" + " " + "%r" + d.encoding() + ", %r" + a.encoding() + ", " + u32 + ";" + "");
-    }
-
-    public final void shl_s64(Register d, Register a, int u32) {
-        emitString("shl.s64" + " " + "%r" + d.encoding() + ", %r" + a.encoding() + ", " + u32 + ";" + "");
+    public final void shl_b64(Register d, Register a, Register b) {
+        emitString("shl.b64" + " " + "%r" + d.encoding() + ", %r" + a.encoding() + ", %r" + b.encoding() + ";" + "");
     }
 
-    public final void shl_u16(Register d, Register a, Register b) {
-        emitString("shl.u16" + " " + "%r" + d.encoding() + ", %r" + a.encoding() + ", %r" + b.encoding() + ";" + "");
-    }
-
-    public final void shl_u32(Register d, Register a, Register b) {
-        emitString("shl.u32" + " " + "%r" + d.encoding() + ", %r" + a.encoding() + ", %r" + b.encoding() + ";" + "");
-    }
-
-    public final void shl_u64(Register d, Register a, Register b) {
-        emitString("shl.u64" + " " + "%r" + d.encoding() + ", %r" + a.encoding() + ", %r" + b.encoding() + ";" + "");
+    public final void shl_b16_const(Register d, Register a, int b) {
+        emitString("shl.b16" + " " + "%r" + d.encoding() + ", %r" + a.encoding() + ", " + b + ";" + "");
     }
 
-    public final void shl_u16(Register d, Register a, int u32) {
-        emitString("shl.u16" + " " + "%r" + d.encoding() + ", %r" + a.encoding() + ", " + u32 + ";" + "");
+    public final void shl_b32_const(Register d, Register a, int b) {
+        emitString("shl.b32" + " " + "%r" + d.encoding() + ", %r" + a.encoding() + ", " + b + ";" + "");
     }
 
-    public final void shl_u32(Register d, Register a, int u32) {
-        emitString("shl.u32" + " " + "%r" + d.encoding() + ", %r" + a.encoding() + ", " + u32 + ";" + "");
+    public final void shl_b64_const(Register d, Register a, int b) {
+        emitString("shl.b64" + " " + "%r" + d.encoding() + ", %r" + a.encoding() + ", " + b + ";" + "");
     }
 
-    public final void shl_u64(Register d, Register a, int u32) {
-        emitString("shl.u64" + " " + "%r" + d.encoding() + ", %r" + a.encoding() + ", " + u32 + ";" + "");
-    }
-
+    // Shift Right instruction
     public final void shr_s16(Register d, Register a, Register b) {
         emitString("shr.s16" + " " + "%r" + d.encoding() + ", %r" + a.encoding() + ", %r" + b.encoding() + ";" + "");
     }
--- a/graal/com.oracle.graal.compiler.ptx.test/src/com/oracle/graal/compiler/ptx/test/IntegerPTXTest.java	Fri Sep 06 16:17:01 2013 +0200
+++ b/graal/com.oracle.graal.compiler.ptx.test/src/com/oracle/graal/compiler/ptx/test/IntegerPTXTest.java	Fri Sep 06 16:17:16 2013 +0200
@@ -22,7 +22,7 @@
  */
 package com.oracle.graal.compiler.ptx.test;
 
-import org.junit.Test;
+import org.junit.*;
 
 import java.lang.reflect.Method;
 
@@ -32,10 +32,19 @@
     @Test
     public void testAdd() {
 
+        Integer r4 = (Integer) invoke(compile("testAdd2I"), 18, 24);
+        if (r4 == null) {
+            printReport("testAdd2I FAILED");
+        } else if (r4.intValue() == testAdd2I(18, 24)) {
+            printReport("testAdd2I PASSED");
+        } else {
+            printReport("testAdd2I FAILED");
+        }
+
         Long r2 = (Long) invoke(compile("testAdd2L"), (long) 12, (long) 6);
         if (r2 == null) {
             printReport("testAdd2L FAILED");
-        } else if (r2.longValue() == 18) {
+        } else if (r2.longValue() == testAdd2L(12, 6)) {
             printReport("testAdd2L PASSED");
         } else {
             printReport("testAdd2L FAILED");
@@ -43,10 +52,10 @@
 
         //invoke(compile("testAdd2B"), (byte) 6, (byte) 4);
 
-        Integer r4 = (Integer) invoke(compile("testAddIConst"), 5);
+        r4 = (Integer) invoke(compile("testAddIConst"), 5);
         if (r4 == null) {
             printReport("testAddIConst FAILED");
-        } else if (r4.intValue() == 37) {
+        } else if (r4.intValue() == testAddIConst(5)) {
             printReport("testAddIConst PASSED");
         } else {
             printReport("testAddIConst FAILED");
@@ -55,20 +64,12 @@
         r4 = (Integer) invoke(compile("testAddConstI"), 7);
         if (r4 == null) {
             printReport("testAddConstI FAILED");
-        } else if (r4.intValue() == 39) {
+        } else if (r4.intValue() == testAddConstI(7)) {
             printReport("testAddConstI PASSED");
         } else {
             printReport("testAddConstI FAILED");
         }
 
-        r4 = (Integer) invoke(compile("testAdd2I"), 18, 24);
-        if (r4 == null) {
-            printReport("testAdd2I FAILED");
-        } else if (r4.intValue() == 42) {
-            printReport("testAdd2I PASSED");
-        } else {
-            printReport("testAdd2I FAILED");
-        }
     }
 
     public static int testAdd2I(int a, int b) {
@@ -93,20 +94,21 @@
 
     @Test
     public void testSub() {
-        Long r2 = (Long) invoke(compile("testSub2L"), (long) 12, (long) 6);
-        if (r2 == null) {
-            printReport("testSub2I FAILED (null return value)");
-        } else if (r2.longValue() == 6) {
+
+        Integer r1 = (Integer) invoke(compile("testSub2I"), 18, 4);
+
+        if (r1 == null) {
+            printReport("testSub2I FAILED");
+        } else if (r1.intValue() == testSub2I(18, 4)) {
             printReport("testSub2I PASSED");
         } else {
             printReport("testSub2I FAILED");
         }
 
-        Integer r1 = (Integer) invoke(compile("testSub2I"), 18, 4);
-
-        if (r1 == null) {
-            printReport("testSub2I FAILED");
-        } else if (r1.intValue() == 14) {
+        Long r2 = (Long) invoke(compile("testSub2L"), (long) 12, (long) 6);
+        if (r2 == null) {
+            printReport("testSub2I FAILED (null return value)");
+        } else if (r2.longValue() == testSub2L(12, 6)) {
             printReport("testSub2I PASSED");
         } else {
             printReport("testSub2I FAILED");
@@ -115,7 +117,7 @@
         r1 = (Integer) invoke(compile("testSubIConst"), 35);
         if (r1 == null) {
             printReport("testSubIConst FAILED");
-        } else if (r1.intValue() == 3) {
+        } else if (r1.intValue() == testSubIConst(35)) {
             printReport("testSubIConst PASSED");
         } else {
             printReport("testSubIConst FAILED");
@@ -124,7 +126,7 @@
         r1 = (Integer) invoke(compile("testSubConstI"), 12);
         if (r1 == null) {
             printReport("testSubConstI FAILED");
-        } else if (r1.intValue() == 20) {
+        } else if (r1.intValue() == testSubConstI(12)) {
             printReport("testSubConstI PASSED");
         } else {
             printReport("testSubConstI FAILED");
@@ -149,10 +151,42 @@
 
     @Test
     public void testMul() {
-        invoke(compile("testMul2I"), 8, 4);
-        invoke(compile("testMul2L"), (long) 12, (long) 6);
-        invoke(compile("testMulIConst"), 4);
-        invoke(compile("testMulConstI"), 5);
+
+        Integer r1 = (Integer) invoke(compile("testMul2I"), 8, 4);
+        if (r1 == null) {
+            printReport("testMul2I FAILED");
+        } else if (r1.intValue() == testMul2I(8, 4)) {
+            printReport("testMul2I PASSED");
+        } else {
+            printReport("testMul2I FAILED");
+        }
+
+        Long r2 = (Long) invoke(compile("testMul2L"), (long) 12, (long) 6);
+        if (r2 == null) {
+            printReport("testMul2L FAILED");
+        } else if (r2.longValue() == testMul2L(12, 6)) {
+            printReport("testMul2L PASSED");
+        } else {
+            printReport("testMul2L FAILED");
+        }
+
+        r1 = (Integer) invoke(compile("testMulIConst"), 4);
+        if (r1 == null) {
+            printReport("testMulIConst FAILED");
+        } else if (r1.intValue() == testMulIConst(4)) {
+            printReport("testMulIConst PASSED");
+        } else {
+            printReport("testMulIConst FAILED");
+        }
+
+        r1 = (Integer) invoke(compile("testMulConstI"), 5);
+        if (r1 == null) {
+            printReport("testMulConstI FAILED");
+        } else if (r1.intValue() == testMulConstI(5)) {
+            printReport("testMulConstI PASSED");
+        } else {
+            printReport("testMulConstI FAILED");
+        }
     }
 
     public static int testMul2I(int a, int b) {
@@ -170,12 +204,44 @@
     public static int testMulConstI(int a) {
         return 32 * a;
     }
+
     @Test
     public void testDiv() {
-        invoke(compile("testDiv2I"), 8, 4);
-        invoke(compile("testDiv2L"), (long) 12, (long) 6);
-        invoke(compile("testDivIConst"), 64);
-        invoke(compile("testDivConstI"), 8);
+        Integer r1 = (Integer) invoke(compile("testDiv2I"), 8, 4);
+        if (r1 == null) {
+            printReport("testDiv2I FAILED (null value returned)");
+        } else if (r1.intValue() == testDiv2I(8, 4)) {
+            printReport("testDiv2I PASSED");
+        } else {
+            printReport("testDiv2I FAILED");
+        }
+
+        Long r2 = (Long) invoke(compile("testDiv2L"), (long) 12, (long) 6);
+        if (r2 == null) {
+            printReport("testDiv2L FAILED (null value returned)");
+        } else if (r2.longValue() == testDiv2L(12, 6)) {
+            printReport("testDiv2L PASSED");
+        } else {
+            printReport("testDiv2L FAILED");
+        }
+
+        r1 = (Integer) invoke(compile("testDivIConst"), 64);
+        if (r1 == null) {
+            printReport("testDivIConst FAILED (null value returned)");
+        } else if (r1.intValue() == testDivIConst(64)) {
+            printReport("testDivIConst PASSED");
+        } else {
+            printReport("testDivIConst FAILED");
+        }
+
+        r1 = (Integer) invoke(compile("testDivConstI"), 8);
+        if (r1 == null) {
+            printReport("testDivConstI FAILED (null value returned)");
+        } else if (r1.intValue() == testDivConstI(8)) {
+            printReport("testDivConstI PASSED");
+        } else {
+            printReport("testDivConstI FAILED");
+        }
     }
 
     public static int testDiv2I(int a, int b) {
@@ -196,8 +262,23 @@
 
     @Test
     public void testRem() {
-        invoke(compile("testRem2I"), 8, 4);
-        invoke(compile("testRem2L"), (long) 12, (long) 6);
+        Integer r1 = (Integer) invoke(compile("testRem2I"), 8, 4);
+        if (r1 == null) {
+            printReport("testRem2I FAILED (null value returned)");
+        } else if (r1.intValue() == testRem2I(8, 4)) {
+            printReport("testRem2I PASSED");
+        } else {
+            printReport("testRem2I FAILED");
+        }
+
+        Long r2 = (Long) invoke(compile("testRem2L"), (long) 12, (long) 6);
+        if (r2 == null) {
+            printReport("testRem2L FAILED (null value returned)");
+        } else if (r1.longValue() == testRem2L(12, 6)) {
+            printReport("testRem2L PASSED");
+        } else {
+            printReport("testRem2L FAILED");
+        }
     }
 
     public static int testRem2I(int a, int b) {
@@ -207,11 +288,27 @@
     public static long testRem2L(long a, long b) {
         return a % b;
     }
-
+    @Ignore
     @Test
     public void testIntConversion() {
-        invoke(compile("testI2L"), 8);
-        invoke(compile("testL2I"), (long) 12);
+        Long r1 = (Long) invoke(compile("testI2L"), 8);
+        if (r1 == null) {
+            printReport("testI2L FAILED (null value returned)");
+        } else if (r1.longValue() == testI2L(8)) {
+            printReport("testI2L PASSED");
+        } else {
+            printReport("testI2L FAILED");
+        }
+
+        Integer r2 = (Integer) invoke(compile("testL2I"), (long) 12);
+        if (r2 == null) {
+            printReport("testL2I FAILED (null value returned)");
+        } else if (r1.longValue() == testL2I(12)) {
+            printReport("testL2I PASSED");
+        } else {
+            printReport("testL2I FAILED");
+        }
+
         // invoke(compile("testI2C"), 65);
         // invoke(compile("testI2B"), 9);
         // invoke(compile("testI2F"), 17);
--- a/graal/com.oracle.graal.compiler.ptx/src/com/oracle/graal/compiler/ptx/PTXBackend.java	Fri Sep 06 16:17:01 2013 +0200
+++ b/graal/com.oracle.graal.compiler.ptx/src/com/oracle/graal/compiler/ptx/PTXBackend.java	Fri Sep 06 16:17:16 2013 +0200
@@ -174,7 +174,7 @@
         }
 
         for (Integer i : signed32) {
-            codeBuffer.emitString("  .reg .s32 %r" + i.intValue() + ";");
+            codeBuffer.emitString(".reg .s32 %r" + i.intValue() + ";");
         }
         for (Integer i : signed64) {
             codeBuffer.emitString(".reg .s64 %r" + i.intValue() + ";");
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/alloc/LinearScan.java	Fri Sep 06 16:17:01 2013 +0200
+++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/alloc/LinearScan.java	Fri Sep 06 16:17:16 2013 +0200
@@ -686,9 +686,8 @@
             List<LIRInstruction> instructions = ir.lir(block);
             int numInst = instructions.size();
 
-            // iterate all instructions of the block. skip the first because it is always a label
-            assert !instructions.get(0).hasOperands() : "first operation must always be a label";
-            for (int j = 1; j < numInst; j++) {
+            // iterate all instructions of the block
+            for (int j = 0; j < numInst; j++) {
                 final LIRInstruction op = instructions.get(j);
 
                 ValueProcedure useProc = new ValueProcedure() {
@@ -1174,10 +1173,8 @@
             }
 
             // iterate all instructions of the block in reverse order.
-            // skip the first instruction because it is always a label
             // definitions of intervals are processed before uses
-            assert !instructions.get(0).hasOperands() : "first operation must always be a label";
-            for (int j = instructions.size() - 1; j >= 1; j--) {
+            for (int j = instructions.size() - 1; j >= 0; j--) {
                 final LIRInstruction op = instructions.get(j);
                 final int opId = op.id();
 
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/LIRGenerator.java	Fri Sep 06 16:17:01 2013 +0200
+++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/LIRGenerator.java	Fri Sep 06 16:17:16 2013 +0200
@@ -40,7 +40,6 @@
 import com.oracle.graal.lir.*;
 import com.oracle.graal.lir.StandardOp.JumpOp;
 import com.oracle.graal.lir.StandardOp.LabelOp;
-import com.oracle.graal.lir.StandardOp.ParametersOp;
 import com.oracle.graal.nodes.*;
 import com.oracle.graal.nodes.PhiNode.PhiType;
 import com.oracle.graal.nodes.calc.*;
@@ -405,7 +404,7 @@
     }
 
     public void emitIncomingValues(Value[] params) {
-        append(new ParametersOp(params));
+        ((LabelOp) lir.lir(currentBlock).get(0)).setIncomingValues(params);
     }
 
     @Override
--- a/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/Graph.java	Fri Sep 06 16:17:01 2013 +0200
+++ b/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/Graph.java	Fri Sep 06 16:17:16 2013 +0200
@@ -40,6 +40,16 @@
 
     private final ArrayList<Node> nodes;
 
+    /**
+     * Records the modification count for nodes. This is only used in assertions.
+     */
+    private int[] nodeModCounts;
+
+    /**
+     * Records the modification count for nodes' usage lists. This is only used in assertions.
+     */
+    private int[] nodeUsageModCounts;
+
     // these two arrays contain one entry for each NodeClass, indexed by NodeClass.iterableId.
     // they contain the first and last pointer to a linked list of all nodes with this type.
     private final ArrayList<Node> nodeCacheFirst;
@@ -87,6 +97,18 @@
         this(null);
     }
 
+    static final boolean MODIFICATION_COUNTS_ENABLED = assertionsEnabled();
+
+    /**
+     * Determines if assertions are enabled for the {@link Graph} class.
+     */
+    @SuppressWarnings("all")
+    private static boolean assertionsEnabled() {
+        boolean enabled = false;
+        assert enabled = true;
+        return enabled;
+    }
+
     /**
      * Creates an empty Graph with a given name.
      * 
@@ -97,6 +119,46 @@
         nodeCacheFirst = new ArrayList<>(NodeClass.cacheSize());
         nodeCacheLast = new ArrayList<>(NodeClass.cacheSize());
         this.name = name;
+        if (MODIFICATION_COUNTS_ENABLED) {
+            nodeModCounts = new int[nodes.size()];
+            nodeUsageModCounts = new int[nodes.size()];
+        }
+    }
+
+    int modCount(Node node) {
+        if (node.id >= 0 && node.id < nodeModCounts.length) {
+            return nodeModCounts[node.id];
+        }
+        return 0;
+    }
+
+    void incModCount(Node node) {
+        if (node.id >= 0) {
+            if (node.id >= nodeModCounts.length) {
+                nodeModCounts = Arrays.copyOf(nodeModCounts, node.id + 30);
+            }
+            nodeModCounts[node.id]++;
+        } else {
+            assert false;
+        }
+    }
+
+    int usageModCount(Node node) {
+        if (node.id >= 0 && node.id < nodeUsageModCounts.length) {
+            return nodeUsageModCounts[node.id];
+        }
+        return 0;
+    }
+
+    void incUsageModCount(Node node) {
+        if (node.id >= 0) {
+            if (node.id >= nodeUsageModCounts.length) {
+                nodeUsageModCounts = Arrays.copyOf(nodeUsageModCounts, node.id + 30);
+            }
+            nodeUsageModCounts[node.id]++;
+        } else {
+            assert false;
+        }
     }
 
     /**
--- a/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/Node.java	Fri Sep 06 16:17:01 2013 +0200
+++ b/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/Node.java	Fri Sep 06 16:17:16 2013 +0200
@@ -22,6 +22,8 @@
  */
 package com.oracle.graal.graph;
 
+import static com.oracle.graal.graph.Graph.*;
+
 import java.lang.annotation.*;
 import java.util.*;
 
@@ -119,9 +121,18 @@
     // therefore points to the next Node of the same type.
     Node typeCacheNext;
 
-    private NodeUsagesList usages;
+    private static final int INLINE_USAGE_COUNT = 2;
+    private static final Node[] NO_NODES = {};
+
+    /**
+     * Head of usage list. The elements of the usage list in order are {@link #usage0},
+     * {@link #usage1} and {@link #extraUsages}. The first null entry terminates the list.
+     */
+    private Node usage0;
+    private Node usage1;
+    private Node[] extraUsages = NO_NODES;
+
     private Node predecessor;
-    private int modCount;
 
     public Node() {
         this.graph = null;
@@ -156,8 +167,211 @@
         return getNodeClass().getSuccessorIterable(this);
     }
 
+    class NodeUsageIterator implements Iterator<Node> {
+
+        private final int expectedModCount = usageModCount();
+        int index = -1;
+        Node current;
+
+        private void advance() {
+            assert index == -1 || current != null;
+            current = null;
+            index++;
+            if (index == 0) {
+                current = usage0;
+            } else if (index == 1) {
+                current = usage1;
+            } else {
+                if (index - INLINE_USAGE_COUNT < extraUsages.length) {
+                    current = extraUsages[index - INLINE_USAGE_COUNT];
+                }
+            }
+        }
+
+        public NodeUsageIterator() {
+            advance();
+        }
+
+        public boolean hasNext() {
+            assert expectedModCount == usageModCount();
+            return current != null;
+        }
+
+        public Node next() {
+            assert expectedModCount == usageModCount();
+            Node result = current;
+            if (result == null) {
+                throw new NoSuchElementException();
+            }
+            advance();
+            return result;
+        }
+
+        public void remove() {
+            throw new UnsupportedOperationException();
+        }
+    }
+
+    class NodeUsageIterable extends AbstractNodeIterable<Node> {
+
+        public NodeUsageIterator iterator() {
+            return new NodeUsageIterator();
+        }
+
+        @Override
+        public boolean isEmpty() {
+            return usage0 == null;
+        }
+
+        @Override
+        public boolean isNotEmpty() {
+            return usage0 != null;
+        }
+
+        @Override
+        public int count() {
+            if (usage0 == null) {
+                return 0;
+            }
+            if (usage1 == null) {
+                return 1;
+            }
+            return 2 + indexOfLastNonNull(extraUsages) + 1;
+        }
+    }
+
+    /**
+     * Gets the list of nodes that use this node (e.g., as an input).
+     */
     public final NodeIterable<Node> usages() {
-        return usages;
+        return new NodeUsageIterable();
+    }
+
+    /**
+     * Finds the index of the last non-null entry in a node array. The search assumes that all
+     * non-null entries precede the first null entry in the array.
+     * 
+     * @param nodes the array to search
+     * @return the index of the last non-null entry in {@code nodes} if it exists, else -1
+     */
+    private static int indexOfLastNonNull(Node[] nodes) {
+        if (nodes.length == 0 || nodes[0] == null) {
+            return -1;
+        }
+        if (nodes[nodes.length - 1] != null) {
+            return nodes.length - 1;
+        }
+
+        // binary search
+        int low = 0;
+        int high = nodes.length - 1;
+        while (true) {
+            int mid = (low + high) >>> 1;
+            if (nodes[mid] == null) {
+                if (nodes[mid - 1] != null) {
+                    return mid - 1;
+                }
+                high = mid - 1;
+            } else {
+                if (mid == nodes.length - 1 || nodes[mid + 1] == null) {
+                    return mid;
+                }
+                low = mid + 1;
+            }
+        }
+    }
+
+    /**
+     * Adds a given node to this node's {@linkplain #usages() usages}.
+     * 
+     * @param node the node to add
+     */
+    private void addUsage(Node node) {
+        incUsageModCount();
+        if (usage0 == null) {
+            usage0 = node;
+        } else if (usage1 == null) {
+            usage1 = node;
+        } else {
+            int length = extraUsages.length;
+            if (length == 0) {
+                extraUsages = new Node[4];
+                extraUsages[0] = node;
+            } else {
+                int lastNonNull = indexOfLastNonNull(extraUsages);
+                if (lastNonNull == length - 1) {
+                    extraUsages = Arrays.copyOf(extraUsages, length * 2 + 1);
+                    extraUsages[length] = node;
+                } else if (lastNonNull == -1) {
+                    extraUsages[0] = node;
+                } else {
+                    extraUsages[lastNonNull + 1] = node;
+                }
+            }
+        }
+    }
+
+    /**
+     * Removes a given node from this node's {@linkplain #usages() usages}.
+     * 
+     * @param node the node to remove
+     * @return whether or not {@code usage} was in the usage list
+     */
+    private boolean removeUsage(Node node) {
+        // It is critical that this method maintains the invariant that
+        // the usage list has no null element preceding a non-null element
+        incUsageModCount();
+        if (usage0 == node) {
+            if (usage1 != null) {
+                int lastNonNull = indexOfLastNonNull(extraUsages);
+                if (lastNonNull >= 0) {
+                    usage0 = extraUsages[lastNonNull];
+                    extraUsages[lastNonNull] = null;
+                } else {
+                    // usage1 is the last element
+                    usage0 = usage1;
+                    usage1 = null;
+                }
+            } else {
+                // usage0 is the last element
+                usage0 = null;
+            }
+            return true;
+        }
+        if (usage1 == node) {
+            int lastNonNull = indexOfLastNonNull(extraUsages);
+            if (lastNonNull >= 0) {
+                usage1 = extraUsages[lastNonNull];
+                extraUsages[lastNonNull] = null;
+            } else {
+                // usage1 is the last element
+                usage1 = null;
+            }
+            return true;
+        }
+        int lastNonNull = indexOfLastNonNull(extraUsages);
+        if (lastNonNull >= 0) {
+            for (int i = 0; i <= lastNonNull; ++i) {
+                Node n = extraUsages[i];
+                if (n == node) {
+                    if (i < lastNonNull) {
+                        extraUsages[i] = extraUsages[lastNonNull];
+                        extraUsages[lastNonNull] = null;
+                    } else {
+                        extraUsages[i] = null;
+                    }
+                    return true;
+                }
+            }
+        }
+        return false;
+    }
+
+    private void clearUsages() {
+        incUsageModCount();
+        usage0 = null;
+        usage1 = null;
+        extraUsages = NO_NODES;
     }
 
     public final Node predecessor() {
@@ -165,11 +379,29 @@
     }
 
     final int modCount() {
-        return modCount;
+        if (MODIFICATION_COUNTS_ENABLED && graph != null) {
+            return graph.modCount(this);
+        }
+        return 0;
     }
 
     final void incModCount() {
-        modCount++;
+        if (MODIFICATION_COUNTS_ENABLED && graph != null) {
+            graph.incModCount(this);
+        }
+    }
+
+    final int usageModCount() {
+        if (MODIFICATION_COUNTS_ENABLED && graph != null) {
+            return graph.usageModCount(this);
+        }
+        return 0;
+    }
+
+    final void incUsageModCount() {
+        if (MODIFICATION_COUNTS_ENABLED && graph != null) {
+            graph.incUsageModCount(this);
+        }
     }
 
     public boolean isDeleted() {
@@ -185,7 +417,6 @@
      * newInput: removes this node from oldInput's usages and adds this node to newInput's usages.
      */
     protected void updateUsages(Node oldInput, Node newInput) {
-        assert assertTrue(usages != null, "usages == null while adding %s to %s", newInput, this);
         if (oldInput != newInput) {
             if (oldInput != null) {
                 boolean result = removeThisFromUsages(oldInput);
@@ -196,8 +427,7 @@
                 if (inputChanged != null) {
                     inputChanged.nodeChanged(this);
                 }
-                assert newInput.usages != null : "not yet added? " + newInput;
-                newInput.usages.add(this);
+                newInput.addUsage(this);
             } else if (oldInput != null && oldInput.usages().isEmpty()) {
                 NodeChangedListener nodeChangedListener = graph.usagesDroppedZero;
                 if (nodeChangedListener != null) {
@@ -213,7 +443,6 @@
      * this node to newSuccessor's predecessors.
      */
     protected void updatePredecessor(Node oldSuccessor, Node newSuccessor) {
-        assert assertTrue(usages != null, "usages == null while adding %s to %s", newSuccessor, this);
         if (oldSuccessor != newSuccessor) {
             if (oldSuccessor != null) {
                 assert assertTrue(oldSuccessor.predecessor == this, "wrong predecessor in old successor (%s): %s", oldSuccessor, oldSuccessor.predecessor);
@@ -230,7 +459,6 @@
         assert assertTrue(id == INITIAL_ID, "unexpected id: %d", id);
         this.graph = newGraph;
         newGraph.register(this);
-        usages = new NodeUsagesList();
         for (Node input : inputs()) {
             updateUsages(null, input);
         }
@@ -253,7 +481,7 @@
 
     public void replaceAtUsages(Node other) {
         assert checkReplaceWith(other);
-        for (Node usage : usages) {
+        for (Node usage : usages()) {
             boolean result = usage.getNodeClass().replaceFirstInput(usage, this, other);
             assert assertTrue(result, "not found in inputs, usage: %s", usage);
             if (other != null) {
@@ -261,10 +489,10 @@
                 if (inputChanged != null) {
                     inputChanged.nodeChanged(usage);
                 }
-                other.usages.add(usage);
+                other.addUsage(usage);
             }
         }
-        usages.clear();
+        clearUsages();
     }
 
     public void replaceAtPredecessor(Node other) {
@@ -314,11 +542,7 @@
     }
 
     private boolean removeThisFromUsages(Node n) {
-        if (n.usages.remove(this)) {
-            return true;
-        } else {
-            return false;
-        }
+        return n.removeUsage(this);
     }
 
     public void clearSuccessors() {
@@ -332,7 +556,7 @@
     }
 
     private boolean checkDeletion() {
-        assertTrue(usages.isEmpty(), "cannot delete node %s because of usages: %s", this, usages);
+        assertTrue(usages().isEmpty(), "cannot delete node %s because of usages: %s", this, usages());
         assertTrue(predecessor == null, "cannot delete node %s because of predecessor: %s", this, predecessor);
         return true;
     }
@@ -355,7 +579,7 @@
         NodeClass clazz = getNodeClass();
         clazz.copyInputs(this, newNode);
         for (Node input : inputs()) {
-            input.usages.add(newNode);
+            input.addUsage(newNode);
         }
         return newNode;
     }
@@ -373,9 +597,10 @@
         newNode.typeCacheNext = null;
         newNode.id = INITIAL_ID;
         into.register(newNode);
-        newNode.usages = new NodeUsagesList();
+        newNode.usage0 = null;
+        newNode.usage1 = null;
+        newNode.extraUsages = NO_NODES;
         newNode.predecessor = null;
-        newNode.modCount = 0;
         return newNode;
     }
 
@@ -576,10 +801,10 @@
         }
 
         if (precision > 0) {
-            if (this.usages.count() > 0) {
+            if (!usages().isEmpty()) {
                 formatter.format(" usages={");
                 int z = 0;
-                for (Node usage : this.usages) {
+                for (Node usage : usages()) {
                     if (z != 0) {
                         formatter.format(", ");
                     }
--- a/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/NodeClass.java	Fri Sep 06 16:17:01 2013 +0200
+++ b/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/NodeClass.java	Fri Sep 06 16:17:16 2013 +0200
@@ -22,6 +22,8 @@
  */
 package com.oracle.graal.graph;
 
+import static com.oracle.graal.graph.Graph.*;
+
 import java.lang.reflect.*;
 import java.util.*;
 import java.util.Map.Entry;
@@ -432,7 +434,7 @@
          */
         private NodeClassIterator(Node node, long[] offsets, int directCount) {
             this.node = node;
-            this.modCount = node.modCount();
+            this.modCount = MODIFICATION_COUNTS_ENABLED ? node.modCount() : 0;
             this.offsets = offsets;
             this.directCount = directCount;
             index = NOT_ITERABLE;
--- a/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/NodeInputList.java	Fri Sep 06 16:17:01 2013 +0200
+++ b/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/NodeInputList.java	Fri Sep 06 16:17:16 2013 +0200
@@ -39,13 +39,13 @@
 
     public NodeInputList(Node self, T[] elements) {
         super(elements);
-        assert self.usages() == null;
+        assert self.usages().isEmpty();
         this.self = self;
     }
 
     public NodeInputList(Node self, List<? extends T> elements) {
         super(elements);
-        assert self.usages() == null;
+        assert self.usages().isEmpty();
         this.self = self;
     }
 
--- a/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/NodeSuccessorList.java	Fri Sep 06 16:17:01 2013 +0200
+++ b/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/NodeSuccessorList.java	Fri Sep 06 16:17:16 2013 +0200
@@ -37,7 +37,7 @@
 
     public NodeSuccessorList(Node self, T[] elements) {
         super(elements);
-        assert self.usages() == null;
+        assert self.usages().isEmpty();
         this.self = self;
     }
 
--- a/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/NodeUsagesList.java	Fri Sep 06 16:17:01 2013 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,163 +0,0 @@
-/*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.graal.graph;
-
-import java.util.*;
-
-import com.oracle.graal.graph.iterators.*;
-
-public final class NodeUsagesList extends AbstractNodeIterable<Node> {
-
-    protected static final Node[] EMPTY_NODE_ARRAY = new Node[0];
-
-    protected Node[] nodes = EMPTY_NODE_ARRAY;
-    private int size;
-    private int modCount;
-
-    NodeUsagesList() {
-        this.size = 0;
-        this.nodes = EMPTY_NODE_ARRAY;
-    }
-
-    NodeUsagesList(Node[] nodes) {
-        this.size = nodes.length;
-        this.nodes = nodes;
-    }
-
-    @Override
-    public boolean isEmpty() {
-        return size == 0;
-    }
-
-    @Override
-    public boolean isNotEmpty() {
-        return size > 0;
-    }
-
-    @Override
-    public int count() {
-        return size;
-    }
-
-    @Override
-    public Iterator<Node> iterator() {
-        return new Iterator<Node>() {
-
-            private final int expectedModCount = NodeUsagesList.this.modCount;
-            private int index = 0;
-
-            @Override
-            public boolean hasNext() {
-                assert expectedModCount == NodeUsagesList.this.modCount;
-                return index < NodeUsagesList.this.size;
-            }
-
-            @Override
-            public Node next() {
-                assert expectedModCount == NodeUsagesList.this.modCount;
-                return NodeUsagesList.this.nodes[index++];
-            }
-
-            @Override
-            public void remove() {
-                throw new UnsupportedOperationException();
-            }
-        };
-    }
-
-    @Override
-    public boolean contains(Node other) {
-        for (int i = 0; i < size; i++) {
-            if (nodes[i] == other) {
-                return true;
-            }
-        }
-        return false;
-    }
-
-    @Override
-    public List<Node> snapshot() {
-        return Arrays.asList(Arrays.copyOf(NodeUsagesList.this.nodes, NodeUsagesList.this.size));
-    }
-
-    private void incModCount() {
-        modCount++;
-    }
-
-    boolean add(Node node) {
-        incModCount();
-        if (size == nodes.length) {
-            nodes = Arrays.copyOf(nodes, nodes.length * 2 + 1);
-        }
-        nodes[size++] = node;
-        return true;
-    }
-
-    void copyAndClear(NodeUsagesList other) {
-        incModCount();
-        other.incModCount();
-        nodes = other.nodes;
-        size = other.size;
-        nodes = EMPTY_NODE_ARRAY;
-        size = 0;
-    }
-
-    void clear() {
-        incModCount();
-        nodes = EMPTY_NODE_ARRAY;
-        size = 0;
-    }
-
-    boolean remove(Node node) {
-        int i = 0;
-        incModCount();
-        while (i < size && nodes[i] != node) {
-            i++;
-        }
-        if (i < size) {
-            i++;
-            while (i < size) {
-                nodes[i - 1] = nodes[i];
-                i++;
-            }
-            nodes[--size] = null;
-            return true;
-        } else {
-            return false;
-        }
-    }
-
-    @Override
-    public String toString() {
-        StringBuilder str = new StringBuilder();
-        str.append('[');
-        for (int i = 0; i < size; i++) {
-            if (i > 0) {
-                str.append(", ");
-            }
-            str.append(nodes[i]);
-        }
-        str.append(']');
-        return str.toString();
-    }
-}
--- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotBackend.java	Fri Sep 06 16:17:01 2013 +0200
+++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotBackend.java	Fri Sep 06 16:17:16 2013 +0200
@@ -45,7 +45,7 @@
 import com.oracle.graal.hotspot.stubs.*;
 import com.oracle.graal.lir.*;
 import com.oracle.graal.lir.LIRInstruction.ValueProcedure;
-import com.oracle.graal.lir.StandardOp.ParametersOp;
+import com.oracle.graal.lir.StandardOp.LabelOp;
 import com.oracle.graal.lir.amd64.*;
 import com.oracle.graal.lir.asm.*;
 import com.oracle.graal.nodes.*;
@@ -214,7 +214,7 @@
         };
         for (Block block : lir.codeEmittingOrder()) {
             for (LIRInstruction op : lir.lir(block)) {
-                if (op instanceof ParametersOp) {
+                if (op instanceof LabelOp) {
                     // Don't consider this as a definition
                 } else {
                     op.forEachTemp(defProc);
--- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotLIRGenerator.java	Fri Sep 06 16:17:01 2013 +0200
+++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotLIRGenerator.java	Fri Sep 06 16:17:16 2013 +0200
@@ -46,7 +46,6 @@
 import com.oracle.graal.hotspot.nodes.*;
 import com.oracle.graal.hotspot.stubs.*;
 import com.oracle.graal.lir.*;
-import com.oracle.graal.lir.StandardOp.ParametersOp;
 import com.oracle.graal.lir.StandardOp.PlaceholderOp;
 import com.oracle.graal.lir.amd64.*;
 import com.oracle.graal.lir.amd64.AMD64ControlFlow.CondMoveOp;
@@ -162,9 +161,8 @@
             }
         }
         params[params.length - 1] = rbpParam;
-        ParametersOp paramsOp = new ParametersOp(params);
 
-        append(paramsOp);
+        emitIncomingValues(params);
 
         saveRbp = new SaveRbp(new PlaceholderOp(currentBlock, lir.lir(currentBlock).size()));
         append(saveRbp.placeholder);
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/CompilerToVM.java	Fri Sep 06 16:17:01 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/CompilerToVM.java	Fri Sep 06 16:17:16 2013 +0200
@@ -226,4 +226,6 @@
     void reprofile(long metaspaceMethod);
 
     void invalidateInstalledCode(HotSpotInstalledCode hotspotInstalledCode);
+
+    boolean isTypeLinked(HotSpotResolvedObjectType hotSpotResolvedObjectType);
 }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/CompilerToVMImpl.java	Fri Sep 06 16:17:01 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/CompilerToVMImpl.java	Fri Sep 06 16:17:16 2013 +0200
@@ -102,6 +102,8 @@
     @Override
     public native boolean isTypeInitialized(HotSpotResolvedObjectType klass);
 
+    public native boolean isTypeLinked(HotSpotResolvedObjectType hotSpotResolvedObjectType);
+
     @Override
     public native boolean hasFinalizableSubclass(HotSpotResolvedObjectType klass);
 
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedJavaMethod.java	Fri Sep 06 16:17:01 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedJavaMethod.java	Fri Sep 06 16:17:16 2013 +0200
@@ -138,7 +138,7 @@
         if (codeSize == 0) {
             return null;
         }
-        if (code == null) {
+        if (code == null && graalRuntime().getCompilerToVM().isTypeLinked(holder)) {
             code = graalRuntime().getCompilerToVM().initializeBytecode(metaspaceMethod, new byte[codeSize]);
             assert code.length == codeSize : "expected: " + codeSize + ", actual: " + code.length;
         }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedObjectType.java	Fri Sep 06 16:17:01 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedObjectType.java	Fri Sep 06 16:17:16 2013 +0200
@@ -83,6 +83,7 @@
     private ResolvedJavaType[] interfaces;
     private ConstantPool constantPool;
     private boolean isInitialized;
+    private boolean isLinked;
     private ResolvedJavaType arrayOfType;
 
     /**
@@ -292,9 +293,18 @@
     }
 
     @Override
+    public boolean isLinked() {
+        if (!isLinked) {
+            isLinked = graalRuntime().getCompilerToVM().isTypeLinked(this);
+        }
+        return isLinked;
+    }
+
+    @Override
     public void initialize() {
         if (!isInitialized) {
             graalRuntime().getCompilerToVM().initializeType(this);
+            assert graalRuntime().getCompilerToVM().isTypeInitialized(this);
         }
         isInitialized = true;
     }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedPrimitiveType.java	Fri Sep 06 16:17:01 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedPrimitiveType.java	Fri Sep 06 16:17:16 2013 +0200
@@ -112,6 +112,10 @@
         return true;
     }
 
+    public boolean isLinked() {
+        return true;
+    }
+
     @Override
     public boolean isInstance(Constant obj) {
         return false;
--- a/graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPhase.java	Fri Sep 06 16:17:01 2013 +0200
+++ b/graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPhase.java	Fri Sep 06 16:17:16 2013 +0200
@@ -242,7 +242,7 @@
 
         // remove dead FrameStates
         for (Node n : currentGraph.getNodes(FrameState.class)) {
-            if (n.usages().count() == 0 && n.predecessor() == null) {
+            if (n.usages().isEmpty() && n.predecessor() == null) {
                 n.safeDelete();
             }
         }
--- a/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXArithmetic.java	Fri Sep 06 16:17:01 2013 +0200
+++ b/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXArithmetic.java	Fri Sep 06 16:17:16 2013 +0200
@@ -316,7 +316,7 @@
                     masm.cvt_f32_f64(asFloatReg(dst), asDoubleReg(src));
                     break;
                 case LSHL:
-                    masm.shl_s64(asLongReg(dst), asLongReg(dst), asIntReg(src));
+                    masm.shl_b64(asLongReg(dst), asLongReg(dst), asIntReg(src));
                     break;
                 case LSHR:
                     masm.shr_s64(asLongReg(dst), asLongReg(dst), asIntReg(src));
@@ -360,19 +360,19 @@
             switch (opcode) {
             case IADD:  masm.add_s32(asIntReg(dst),    asIntReg(src1),    tasm.asIntConst(src2));    break;
             case ISUB:  masm.sub_s32(asIntReg(dst),    asIntReg(src1),    tasm.asIntConst(src2));    break;
-            case IMUL:  masm.mul_s32(asIntReg(dst),    asIntReg(src1),    tasm.asIntConst(src2));    break;
+            case IMUL:  masm.mul_lo_s32(asIntReg(dst), asIntReg(src1),    tasm.asIntConst(src2));    break;
             case IAND:  masm.and_b32(asIntReg(dst),    asIntReg(src1),    tasm.asIntConst(src2));    break;
-            case ISHL:  masm.shl_s32(asIntReg(dst),    asIntReg(src1),    tasm.asIntConst(src2));    break;
+            case ISHL:  masm.shl_b32_const(asIntReg(dst), asIntReg(src1), tasm.asIntConst(src2));    break;
             case ISHR:  masm.shr_s32(asIntReg(dst),    asIntReg(src1),    tasm.asIntConst(src2));    break;
             case IUSHR: masm.shr_u32(asIntReg(dst),    asIntReg(src1),    tasm.asIntConst(src2));    break;
             case IXOR:  masm.xor_b32(asIntReg(dst),    asIntReg(src1),    tasm.asIntConst(src2));    break;
             case LXOR:  masm.xor_b64(asLongReg(dst),   asLongReg(src1),   tasm.asLongConst(src2));   break;
             case LUSHR: masm.shr_u64(asLongReg(dst),   asLongReg(src1),   tasm.asLongConst(src2));   break;
             case FADD:  masm.add_f32(asFloatReg(dst),  asFloatReg(src1),  tasm.asFloatConst(src2));  break;
-            case FMUL:  masm.mul_f32(asFloatReg(dst),  asFloatReg(src1),  tasm.asFloatConst(src2));  break;
+            case FMUL:  masm.mul_lo_f32(asFloatReg(dst), asFloatReg(src1), tasm.asFloatConst(src2)); break;
             case FDIV:  masm.div_f32(asFloatReg(dst),  asFloatReg(src1),  tasm.asFloatConst(src2));  break;
             case DADD:  masm.add_f64(asDoubleReg(dst), asDoubleReg(src1), tasm.asDoubleConst(src2)); break;
-            case DMUL:  masm.mul_f64(asDoubleReg(dst), asDoubleReg(src1), tasm.asDoubleConst(src2)); break;
+            case DMUL:  masm.mul_lo_f64(asDoubleReg(dst), asDoubleReg(src1), tasm.asDoubleConst(src2)); break;
             case DDIV:  masm.div_f64(asDoubleReg(dst), asDoubleReg(src1), tasm.asDoubleConst(src2)); break;
             default:
                 throw GraalInternalError.shouldNotReachHere();
@@ -387,34 +387,34 @@
             // case D:  new Mul(Double, dst, src1, src2);
             case IADD:  masm.add_s32(asIntReg(dst),    asIntReg(src1),    asIntReg(src2));    break;
             case ISUB:  masm.sub_s32(asIntReg(dst),    asIntReg(src1),    asIntReg(src2));    break;
-            case IMUL:  masm.mul_s32(asIntReg(dst),    asIntReg(src1),    asIntReg(src2));    break;
+            case IMUL:  masm.mul_lo_s32(asIntReg(dst), asIntReg(src1),    asIntReg(src2));    break;
             case IDIV:  masm.div_s32(asIntReg(dst),    asIntReg(src1),    asIntReg(src2));    break;
             case IAND:  masm.and_b32(asIntReg(dst),    asIntReg(src1),    asIntReg(src2));    break;
             case IOR:    masm.or_b32(asIntReg(dst),    asIntReg(src1),    asIntReg(src2));    break;
             case IXOR:  masm.xor_b32(asIntReg(dst),    asIntReg(src1),    asIntReg(src2));    break;
-            case ISHL:  masm.shl_s32(asIntReg(dst),    asIntReg(src1),    asIntReg(src2));    break;
+            case ISHL:  masm.shl_b32(asIntReg(dst),    asIntReg(src1),    asIntReg(src2));    break;
             case ISHR:  masm.shr_s32(asIntReg(dst),    asIntReg(src1),    asIntReg(src2));    break;
             case IUSHR: masm.shr_u32(asIntReg(dst),    asIntReg(src1),    asIntReg(src2));    break;
             case IREM:  masm.rem_s32(asIntReg(dst),    asIntReg(src1),    asIntReg(src2));    break;
             case LADD:  masm.add_s64(asLongReg(dst),   asLongReg(src1),   asLongReg(src2));   break;
             case LSUB:  masm.sub_s64(asLongReg(dst),   asLongReg(src1),   asLongReg(src2));   break;
-            case LMUL:  masm.mul_s64(asLongReg(dst),   asLongReg(src1),   asLongReg(src2));   break;
+            case LMUL:  masm.mul_lo_s64(asLongReg(dst), asLongReg(src1),  asLongReg(src2));   break;
             case LDIV:  masm.div_s64(asLongReg(dst),   asLongReg(src1),   asLongReg(src2));   break;
             case LAND:  masm.and_b64(asLongReg(dst),   asLongReg(src1),   asLongReg(src2));   break;
-            case LOR:    masm.or_b64(asLongReg(dst),   asLongReg(src1),   asLongReg(src2));   break;
+            case LOR:   masm.or_b64(asLongReg(dst),    asLongReg(src1),   asLongReg(src2));   break;
             case LXOR:  masm.xor_b64(asLongReg(dst),   asLongReg(src1),   asLongReg(src2));   break;
-            case LSHL:  masm.shl_s64(asLongReg(dst),   asLongReg(src1),   asLongReg(src2));   break;
+            case LSHL:  masm.shl_b64(asLongReg(dst),   asLongReg(src1),   asLongReg(src2));   break;
             case LSHR:  masm.shr_s64(asLongReg(dst),   asLongReg(src1),   asLongReg(src2));   break;
             case LUSHR: masm.shr_u64(asLongReg(dst),   asLongReg(src1),   asIntReg(src2));    break;
             case LREM:  masm.rem_s64(asLongReg(dst),   asLongReg(src1),   asLongReg(src2));   break;
             case FADD:  masm.add_f32(asFloatReg(dst),  asFloatReg(src1),  asFloatReg(src2));  break;
             case FSUB:  masm.sub_f32(asFloatReg(dst),  asFloatReg(src1),  asFloatReg(src2));  break;
-            case FMUL:  masm.mul_f32(asFloatReg(dst),  asFloatReg(src1),  asFloatReg(src2));  break;
+            case FMUL:  masm.mul_lo_f32(asFloatReg(dst), asFloatReg(src1), asFloatReg(src2)); break;
             case FDIV:  masm.div_f32(asFloatReg(dst),  asFloatReg(src1),  asFloatReg(src2));  break;
             case FREM:  masm.div_f32(asFloatReg(dst),  asFloatReg(src1),  asFloatReg(src2));  break;
             case DADD:  masm.add_f64(asDoubleReg(dst), asDoubleReg(src1), asDoubleReg(src2)); break;
             case DSUB:  masm.sub_f64(asDoubleReg(dst), asDoubleReg(src1), asDoubleReg(src2)); break;
-            case DMUL:  masm.mul_f64(asDoubleReg(dst), asDoubleReg(src1), asDoubleReg(src2)); break;
+            case DMUL:  masm.mul_lo_f64(asDoubleReg(dst), asDoubleReg(src1), asDoubleReg(src2)); break;
             case DDIV:  masm.div_f64(asDoubleReg(dst), asDoubleReg(src1), asDoubleReg(src2)); break;
             case DREM:  masm.div_f64(asDoubleReg(dst), asDoubleReg(src1), asDoubleReg(src2)); break;
             default:
--- a/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXMemOp.java	Fri Sep 06 16:17:01 2013 +0200
+++ b/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXMemOp.java	Fri Sep 06 16:17:16 2013 +0200
@@ -158,7 +158,7 @@
                     masm.ld_from_state_space(".param.s16", asRegister(result), addr.getBase(), addr.getDisplacement());
                     break;
                 case Char:
-                    masm.ld_from_state_space(".param.s16", asRegister(result), addr.getBase(), addr.getDisplacement());
+                    masm.ld_from_state_space(".param.u16", asRegister(result), addr.getBase(), addr.getDisplacement());
                     break;
                 case Int:
                     masm.ld_from_state_space(".param.s32", asRegister(result), addr.getBase(), addr.getDisplacement());
--- a/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXParameterOp.java	Fri Sep 06 16:17:01 2013 +0200
+++ b/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXParameterOp.java	Fri Sep 06 16:17:16 2013 +0200
@@ -42,23 +42,23 @@
 
     @Override
     public void emitCode(TargetMethodAssembler tasm) {
-        PTXAssembler ptxasm = (PTXAssembler) tasm.asm;
+        PTXAssembler masm = (PTXAssembler) tasm.asm;
         // Emit parameter directives for arguments
         int argCount = params.length;
         for (int i = 0; i < argCount; i++) {
             Kind paramKind = params[i].getKind();
             switch (paramKind) {
             case Int :
-                ptxasm.param_32_decl(asIntReg(params[i]), (i == (argCount - 1)));
+                masm.param_32_decl(asIntReg(params[i]), (i == (argCount - 1)));
                 break;
             case Long :
-                ptxasm.param_64_decl(asLongReg(params[i]), (i == (argCount - 1)));
+                masm.param_64_decl(asLongReg(params[i]), (i == (argCount - 1)));
                 break;
             case Float :
-                ptxasm.param_32_decl(asFloatReg(params[i]), (i == (argCount - 1)));
+                masm.param_32_decl(asFloatReg(params[i]), (i == (argCount - 1)));
                 break;
             case Double :
-                ptxasm.param_64_decl(asDoubleReg(params[i]), (i == (argCount - 1)));
+                masm.param_64_decl(asDoubleReg(params[i]), (i == (argCount - 1)));
                 break;
             default :
                 throw GraalInternalError.shouldNotReachHere("unhandled parameter type "  + paramKind.toString());
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/StandardOp.java	Fri Sep 06 16:17:01 2013 +0200
+++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/StandardOp.java	Fri Sep 06 16:17:16 2013 +0200
@@ -54,12 +54,30 @@
      */
     public static class LabelOp extends LIRInstruction {
 
+        private static final Value[] NO_VALUES = new Value[0];
+
+        /**
+         * In the LIR, every register and variable must be defined before it is used. For method
+         * parameters that are passed in fixed registers, exception objects passed to the exception
+         * handler in a fixed register, or any other use of a fixed register not defined in this
+         * method, an artificial definition is necessary. To avoid spill moves to be inserted
+         * between the label at the beginning of a block an an actual definition in the second
+         * instruction of a block, the registers are defined here in the label.
+         */
+        @Def({REG, STACK}) private Value[] incomingValues;
+
         private final Label label;
         private final boolean align;
 
         public LabelOp(Label label, boolean align) {
             this.label = label;
             this.align = align;
+            this.incomingValues = NO_VALUES;
+        }
+
+        public void setIncomingValues(Value[] values) {
+            assert incomingValues.length == 0;
+            incomingValues = values;
         }
 
         @Override
@@ -121,25 +139,6 @@
     }
 
     /**
-     * Meta-operation that defines the incoming method parameters. In the LIR, every register and
-     * variable must be defined before it is used. This operation is the definition point of method
-     * parameters, but is otherwise a no-op. In particular, it is not the actual method prologue.
-     */
-    public static final class ParametersOp extends LIRInstruction {
-
-        @Def({REG, STACK}) protected Value[] params;
-
-        public ParametersOp(Value[] params) {
-            this.params = params;
-        }
-
-        @Override
-        public void emitCode(TargetMethodAssembler tasm) {
-            // No code to emit.
-        }
-    }
-
-    /**
      * Placeholder for a LIR instruction that will be subsequently replaced.
      */
     public static class PlaceholderOp extends LIRInstruction {
--- a/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/LoopFragment.java	Fri Sep 06 16:17:01 2013 +0200
+++ b/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/LoopFragment.java	Fri Sep 06 16:17:16 2013 +0200
@@ -145,11 +145,11 @@
         }
     }
 
-    protected static NodeBitMap computeNodes(Graph graph, Collection<AbstractBeginNode> blocks) {
+    protected static NodeBitMap computeNodes(Graph graph, Iterable<AbstractBeginNode> blocks) {
         return computeNodes(graph, blocks, Collections.<AbstractBeginNode> emptyList());
     }
 
-    protected static NodeBitMap computeNodes(Graph graph, Collection<AbstractBeginNode> blocks, Collection<AbstractBeginNode> earlyExits) {
+    protected static NodeBitMap computeNodes(Graph graph, Iterable<AbstractBeginNode> blocks, Iterable<AbstractBeginNode> earlyExits) {
         final NodeBitMap nodes = graph.createNodeBitMap(true);
         for (AbstractBeginNode b : blocks) {
             for (Node n : b.getBlockNodes()) {
@@ -229,12 +229,28 @@
         return false;
     }
 
-    public static Collection<AbstractBeginNode> toHirBlocks(Collection<Block> blocks) {
-        List<AbstractBeginNode> hir = new ArrayList<>(blocks.size());
-        for (Block b : blocks) {
-            hir.add(b.getBeginNode());
-        }
-        return hir;
+    public static NodeIterable<AbstractBeginNode> toHirBlocks(final Iterable<Block> blocks) {
+        return new AbstractNodeIterable<AbstractBeginNode>() {
+
+            public Iterator<AbstractBeginNode> iterator() {
+                final Iterator<Block> it = blocks.iterator();
+                return new Iterator<AbstractBeginNode>() {
+
+                    public void remove() {
+                        throw new UnsupportedOperationException();
+                    }
+
+                    public AbstractBeginNode next() {
+                        return it.next().getBeginNode();
+                    }
+
+                    public boolean hasNext() {
+                        return it.hasNext();
+                    }
+                };
+            }
+
+        };
     }
 
     /**
--- a/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/LoopFragmentInside.java	Fri Sep 06 16:17:01 2013 +0200
+++ b/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/LoopFragmentInside.java	Fri Sep 06 16:17:16 2013 +0200
@@ -231,7 +231,7 @@
         StructuredGraph graph = graph();
         if (endsToMerge.size() == 1) {
             AbstractEndNode end = endsToMerge.get(0);
-            assert end.usages().count() == 0;
+            assert end.usages().isEmpty();
             newExit = graph.add(new BeginNode());
             end.replaceAtPredecessor(newExit);
             end.safeDelete();
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/LoopEndNode.java	Fri Sep 06 16:17:01 2013 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/LoopEndNode.java	Fri Sep 06 16:17:16 2013 +0200
@@ -72,7 +72,7 @@
     @Override
     public boolean verify() {
         assertTrue(loopBegin != null, "must have a loop begin");
-        assertTrue(usages().count() == 0, "LoopEnds can not be used");
+        assertTrue(usages().isEmpty(), "LoopEnds can not be used");
         return super.verify();
     }
 
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/StructuredGraph.java	Fri Sep 06 16:17:01 2013 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/StructuredGraph.java	Fri Sep 06 16:17:16 2013 +0200
@@ -144,15 +144,19 @@
         return copy(name);
     }
 
-    @Override
-    public StructuredGraph copy(String newName) {
-        StructuredGraph copy = new StructuredGraph(newName, method, graphId, entryBCI);
+    public StructuredGraph copy(String newName, ResolvedJavaMethod newMethod) {
+        StructuredGraph copy = new StructuredGraph(newName, newMethod, graphId, entryBCI);
         HashMap<Node, Node> replacements = new HashMap<>();
         replacements.put(start, copy.start);
         copy.addDuplicates(getNodes(), replacements);
         return copy;
     }
 
+    @Override
+    public StructuredGraph copy(String newName) {
+        return copy(newName, method);
+    }
+
     public LocalNode getLocal(int index) {
         for (LocalNode local : getNodes(LocalNode.class)) {
             if (local.index() == index) {
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/ReadNode.java	Fri Sep 06 16:17:01 2013 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/ReadNode.java	Fri Sep 06 16:17:16 2013 +0200
@@ -72,7 +72,7 @@
 
     public static ValueNode canonicalizeRead(ValueNode read, LocationNode location, ValueNode object, CanonicalizerTool tool, boolean compressible) {
         MetaAccessProvider runtime = tool.runtime();
-        if (read.usages().count() == 0) {
+        if (read.usages().isEmpty()) {
             // Read without usages can be savely removed.
             return null;
         }
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/InstanceOfDynamicNode.java	Fri Sep 06 16:17:01 2013 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/InstanceOfDynamicNode.java	Fri Sep 06 16:17:16 2013 +0200
@@ -23,9 +23,7 @@
 package com.oracle.graal.nodes.java;
 
 import com.oracle.graal.api.meta.*;
-import com.oracle.graal.graph.*;
 import com.oracle.graal.nodes.*;
-import com.oracle.graal.nodes.calc.*;
 import com.oracle.graal.nodes.spi.*;
 import com.oracle.graal.nodes.type.*;
 
@@ -74,12 +72,4 @@
     public ValueNode mirror() {
         return mirror;
     }
-
-    @Override
-    public boolean verify() {
-        for (Node usage : usages()) {
-            assertTrue(usage instanceof IfNode || usage instanceof FixedGuardNode || usage instanceof ConditionalNode, "unsupported usage: %s", usage);
-        }
-        return super.verify();
-    }
 }
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/InliningPhase.java	Fri Sep 06 16:17:01 2013 +0200
+++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/InliningPhase.java	Fri Sep 06 16:17:16 2013 +0200
@@ -512,7 +512,7 @@
             while ((current = nextQueuedNode()) != null) {
                 assert current.isAlive();
 
-                if (current instanceof Invoke) {
+                if (current instanceof Invoke && ((Invoke) current).callTarget() instanceof MethodCallTargetNode) {
                     if (current != start) {
                         invokes.addLast((Invoke) current);
                     }
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/RemoveValueProxyPhase.java	Fri Sep 06 16:17:01 2013 +0200
+++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/RemoveValueProxyPhase.java	Fri Sep 06 16:17:16 2013 +0200
@@ -39,7 +39,7 @@
             FrameState stateAfter = exit.stateAfter();
             if (stateAfter != null) {
                 exit.setStateAfter(null);
-                if (stateAfter.usages().count() == 0) {
+                if (stateAfter.usages().isEmpty()) {
                     stateAfter.safeDelete();
                 }
             }
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCompilerImpl.java	Fri Sep 06 16:17:01 2013 +0200
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCompilerImpl.java	Fri Sep 06 16:17:16 2013 +0200
@@ -36,6 +36,7 @@
 import com.oracle.graal.compiler.*;
 import com.oracle.graal.compiler.target.*;
 import com.oracle.graal.debug.*;
+import com.oracle.graal.debug.internal.*;
 import com.oracle.graal.hotspot.*;
 import com.oracle.graal.java.*;
 import com.oracle.graal.nodes.*;
@@ -107,6 +108,10 @@
         });
     }
 
+    public static final DebugTimer PartialEvaluationTime = Debug.timer("PartialEvaluationTime");
+    public static final DebugTimer CompilationTime = Debug.timer("CompilationTime");
+    public static final DebugTimer CodeInstallationTime = Debug.timer("CodeInstallation");
+
     private InstalledCode compileMethodImpl(final OptimizedCallTarget compilable) {
         final StructuredGraph graph;
         final GraphBuilderConfiguration config = GraphBuilderConfiguration.getDefault();
@@ -115,7 +120,9 @@
 
         compilable.timeCompilationStarted = System.nanoTime();
         Assumptions assumptions = new Assumptions(true);
-        graph = partialEvaluator.createGraph(compilable, assumptions);
+        try (TimerCloseable a = PartialEvaluationTime.start()) {
+            graph = partialEvaluator.createGraph(compilable, assumptions);
+        }
         compilable.timePartialEvaluationFinished = System.nanoTime();
         compilable.nodeCountPartialEval = graph.getNodeCount();
         InstalledCode compiledMethod = compileMethodHelper(graph, config, compilable, assumptions);
@@ -143,9 +150,11 @@
 
             @Override
             public CompilationResult call() {
-                CallingConvention cc = getCallingConvention(runtime, Type.JavaCallee, graph.method(), false);
-                return GraalCompiler.compileGraph(graph, cc, graph.method(), runtime, replacements, backend, runtime.getTarget(), null, plan, OptimisticOptimizations.ALL, new SpeculationLog(),
-                                suites, new CompilationResult());
+                try (TimerCloseable a = CompilationTime.start()) {
+                    CallingConvention cc = getCallingConvention(runtime, Type.JavaCallee, graph.method(), false);
+                    return GraalCompiler.compileGraph(graph, cc, graph.method(), runtime, replacements, backend, runtime.getTarget(), null, plan, OptimisticOptimizations.ALL, new SpeculationLog(),
+                                    suites, new CompilationResult());
+                }
             }
         });
 
@@ -169,11 +178,13 @@
 
             @Override
             public InstalledCode call() throws Exception {
-                InstalledCode installedCode = runtime.addMethod(graph.method(), result);
-                if (installedCode != null) {
-                    Debug.dump(new Object[]{result, installedCode}, "After code installation");
+                try (TimerCloseable a = CodeInstallationTime.start()) {
+                    InstalledCode installedCode = runtime.addMethod(graph.method(), result);
+                    if (installedCode != null) {
+                        Debug.dump(new Object[]{result, installedCode}, "After code installation");
+                    }
+                    return installedCode;
                 }
-                return installedCode;
             }
         });
 
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/Node.java	Fri Sep 06 16:17:01 2013 +0200
+++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/Node.java	Fri Sep 06 16:17:16 2013 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -59,6 +59,11 @@
         CompilerAsserts.neverPartOfCompilation();
     }
 
+    protected Node(SourceSection sourceSection) {
+        CompilerAsserts.neverPartOfCompilation();
+        this.sourceSection = sourceSection;
+    }
+
     /**
      * Assigns a link to a guest language source section to this node.
      * 
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/RootNode.java	Fri Sep 06 16:17:01 2013 +0200
+++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/RootNode.java	Fri Sep 06 16:17:16 2013 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -34,6 +34,13 @@
  */
 public abstract class RootNode extends Node {
 
+    protected RootNode() {
+    }
+
+    protected RootNode(SourceSection sourceSection) {
+        super(sourceSection);
+    }
+
     /**
      * Executes this function using the specified frame and returns the result value.
      * 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mx/.pylintrc	Fri Sep 06 16:17:16 2013 +0200
@@ -0,0 +1,278 @@
+[MASTER]
+
+# Specify a configuration file.
+#rcfile=
+
+# Python code to execute, usually for sys.path manipulation such as
+# pygtk.require().
+#init-hook=
+
+# Profiled execution.
+profile=no
+
+# Add files or directories to the blacklist. They should be base names, not
+# paths.
+ignore=CVS
+
+# Pickle collected data for later comparisons.
+persistent=no
+
+# List of plugins (as comma separated values of python modules names) to load,
+# usually to register additional checkers.
+load-plugins=
+
+
+[MESSAGES CONTROL]
+
+# Enable the message, report, category or checker with the given id(s). You can
+# either give multiple identifier separated by comma (,) or put this option
+# multiple time. See also the "--disable" option for examples.
+#enable=
+
+# Disable the message, report, category or checker with the given id(s). You
+# can either give multiple identifiers separated by comma (,) or put this
+# option multiple times (only on the command line, not in the configuration
+# file where it should appear only once).You can also use "--disable=all" to
+# disable everything first and then reenable specific checks. For example, if
+# you want to run only the similarities checker, you can use "--disable=all
+# --enable=similarities". If you want to run only the classes checker, but have
+# no Warning level messages displayed, use"--disable=all --enable=classes
+# --disable=W"
+disable=attribute-defined-outside-init,arguments-differ,
+        bare-except,global-statement,protected-access,redefined-outer-name,
+        unused-argument,star-args,pointless-string-statement,old-style-class,
+        too-many-lines,missing-docstring,no-init,no-self-use,too-many-statements,
+        too-many-locals,too-few-public-methods,too-many-instance-attributes,
+        too-many-arguments,too-many-branches,too-many-public-methods,
+        abstract-method
+
+[REPORTS]
+
+# Set the output format. Available formats are text, parseable, colorized, msvs
+# (visual studio) and html. You can also give a reporter class, eg
+# mypackage.mymodule.MyReporterClass.
+output-format=text
+
+# Put messages in a separate file for each module / package specified on the
+# command line instead of printing them on stdout. Reports (if any) will be
+# written in a file name "pylint_global.[txt|html]".
+files-output=no
+
+# Tells whether to display a full report or only the messages
+reports=no
+
+# Python expression which should return a note less than 10 (10 is the highest
+# note). You have access to the variables errors warning, statement which
+# respectively contain the number of errors / warnings messages and the total
+# number of statements analyzed. This is used by the global evaluation report
+# (RP0004).
+evaluation=10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10)
+
+# Add a comment according to your evaluation note. This is used by the global
+# evaluation report (RP0004).
+comment=no
+
+# Template used to display messages. This is a python new-style format string
+# used to format the massage information. See doc for all details
+#msg-template=
+
+
+[BASIC]
+
+# Required attributes for module, separated by a comma
+required-attributes=
+
+# List of builtins function names that should not be used, separated by a comma
+bad-functions=filter,apply,input
+
+# Regular expression which should only match correct module names
+module-rgx=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$
+
+# Regular expression which should only match correct module level names
+const-rgx=[a-zA-Z0-9_]{2,30}$
+
+# Regular expression which should only match correct class names
+class-rgx=[A-Z_][a-zA-Z0-9]+$
+
+# Regular expression which should only match correct function names
+function-rgx=[a-z_][a-zA-Z0-9_]{1,40}$
+
+# Regular expression which should only match correct method names
+method-rgx=[a-z_][a-zA-Z0-9_]{2,40}$
+
+# Regular expression which should only match correct instance attribute names
+attr-rgx=[a-z_][a-zA-Z0-9_]{1,30}$
+
+# Regular expression which should only match correct argument names
+argument-rgx=[a-z_][a-zA-Z0-9_]{0,30}$
+
+# Regular expression which should only match correct variable names
+variable-rgx=[a-z_][a-zA-Z0-9_]{0,30}$
+
+# Regular expression which should only match correct attribute names in class
+# bodies
+class-attribute-rgx=([A-Za-z_][A-Za-z0-9_]{2,30}|(__.*__))$
+
+# Regular expression which should only match correct list comprehension /
+# generator expression variable names
+inlinevar-rgx=[A-Za-z_][A-Za-z0-9_]*$
+
+# Good variable names which should always be accepted, separated by a comma
+good-names=i,j,k,ex,Run,_
+
+# Bad variable names which should always be refused, separated by a comma
+bad-names=foo,bar,baz,toto,tutu,tata
+
+# Regular expression which should only match function or class names that do
+# not require a docstring.
+no-docstring-rgx=.*
+
+# Minimum line length for functions/classes that require docstrings, shorter
+# ones are exempt.
+docstring-min-length=-1
+
+
+[FORMAT]
+
+# Maximum number of characters on a single line.
+max-line-length=300
+
+# Regexp for a line that is allowed to be longer than the limit.
+ignore-long-lines=^\s*(# )?<?https?://\S+>?$
+
+# Maximum number of lines in a module
+max-module-lines=1000
+
+# String used as indentation unit. This is usually " " (4 spaces) or "\t" (1
+# tab).
+indent-string='    '
+
+
+[MISCELLANEOUS]
+
+# List of note tags to take in consideration, separated by a comma.
+notes=FIXME
+
+
+[SIMILARITIES]
+
+# Minimum lines number of a similarity.
+min-similarity-lines=4
+
+# Ignore comments when computing similarities.
+ignore-comments=yes
+
+# Ignore docstrings when computing similarities.
+ignore-docstrings=yes
+
+# Ignore imports when computing similarities.
+ignore-imports=no
+
+
+[TYPECHECK]
+
+# Tells whether missing members accessed in mixin class should be ignored. A
+# mixin class is detected if its name ends with "mixin" (case insensitive).
+ignore-mixin-members=yes
+
+# List of classes names for which member attributes should not be checked
+# (useful for classes with attributes dynamically set).
+ignored-classes=SQLObject
+
+# When zope mode is activated, add a predefined set of Zope acquired attributes
+# to generated-members.
+zope=no
+
+# List of members which are set dynamically and missed by pylint inference
+# system, and so shouldn't trigger E0201 when accessed. Python regular
+# expressions are accepted.
+generated-members=REQUEST,acl_users,aq_parent
+
+
+[VARIABLES]
+
+# Tells whether we should check for unused import in __init__ files.
+init-import=no
+
+# A regular expression matching the beginning of the name of dummy variables
+# (i.e. not used).
+dummy-variables-rgx=_$|dummy
+
+# List of additional names supposed to be defined in builtins. Remember that
+# you should avoid to define new builtins when possible.
+additional-builtins=
+
+
+[CLASSES]
+
+# List of interface methods to ignore, separated by a comma. This is used for
+# instance to not check methods defines in Zope's Interface base class.
+ignore-iface-methods=isImplementedBy,deferred,extends,names,namesAndDescriptions,queryDescriptionFor,getBases,getDescriptionFor,getDoc,getName,getTaggedValue,getTaggedValueTags,isEqualOrExtendedBy,setTaggedValue,isImplementedByInstancesOf,adaptWith,is_implemented_by
+
+# List of method names used to declare (i.e. assign) instance attributes.
+defining-attr-methods=__init__,__new__,setUp
+
+# List of valid names for the first argument in a class method.
+valid-classmethod-first-arg=cls
+
+# List of valid names for the first argument in a metaclass class method.
+valid-metaclass-classmethod-first-arg=mcs
+
+
+[DESIGN]
+
+# Maximum number of arguments for function / method
+max-args=5
+
+# Argument names that match this expression will be ignored. Default to name
+# with leading underscore
+ignored-argument-names=_.*
+
+# Maximum number of locals for function / method body
+max-locals=15
+
+# Maximum number of return / yield for function / method body
+max-returns=6
+
+# Maximum number of branch for function / method body
+max-branches=12
+
+# Maximum number of statements in function / method body
+max-statements=50
+
+# Maximum number of parents for a class (see R0901).
+max-parents=7
+
+# Maximum number of attributes for a class (see R0902).
+max-attributes=7
+
+# Minimum number of public methods for a class (see R0903).
+min-public-methods=2
+
+# Maximum number of public methods for a class (see R0904).
+max-public-methods=20
+
+
+[IMPORTS]
+
+# Deprecated modules which should not be used, separated by a comma
+deprecated-modules=regsub,TERMIOS,Bastion,rexec
+
+# Create a graph of every (i.e. internal and external) dependencies in the
+# given file (report RP0402 must not be disabled)
+import-graph=
+
+# Create a graph of external dependencies in the given file (report RP0402 must
+# not be disabled)
+ext-import-graph=
+
+# Create a graph of internal dependencies in the given file (report RP0402 must
+# not be disabled)
+int-import-graph=
+
+
+[EXCEPTIONS]
+
+# Exceptions that will emit a warning when being caught. Defaults to
+# "Exception"
+overgeneral-exceptions=Exception
--- a/mx/commands.py	Fri Sep 06 16:17:01 2013 +0200
+++ b/mx/commands.py	Fri Sep 06 16:17:16 2013 +0200
@@ -45,10 +45,10 @@
 _vmChoices = {
     'graal' : 'All compilation is performed with Graal. This includes bootstrapping Graal itself unless -XX:-BootstrapGraal is used.',
     'server' : 'Normal compilation is performed with the tiered system (i.e., client + server), Truffle compilation is performed with Graal. Use this for optimal Truffle performance.',
-    'client' : None, # normal compilation with client compiler, explicit compilation (e.g., by Truffle) with Graal
-    'server-nograal' : None, # all compilation with tiered system (i.e., client + server), Graal omitted
-    'client-nograal' : None, # all compilation with client compiler, Graal omitted
-    'original' : None, # default VM copied from bootstrap JDK
+    'client' : None,  # normal compilation with client compiler, explicit compilation (e.g., by Truffle) with Graal
+    'server-nograal' : None,  # all compilation with tiered system (i.e., client + server), Graal omitted
+    'client-nograal' : None,  # all compilation with client compiler, Graal omitted
+    'original' : None,  # default VM copied from bootstrap JDK
 }
 
 """ The VM that will be run by the 'vm' command and built by default by the 'build' command.
@@ -95,14 +95,13 @@
         items = [k for k in _vmChoices.keys() if _vmChoices[k] is not None]
         descriptions = [_vmChoices[k] for k in _vmChoices.keys() if _vmChoices[k] is not None]
         vm = mx.select_items(items, descriptions, allowMultiple=False)
-        answer = raw_input('Persist this choice by adding "DEFAULT_VM=' + vm + '" to ' + envPath + '? [Yn]: ')
-        if not answer.lower().startswith('n'):
+        if mx.ask_yes_no('Persist this choice by adding "DEFAULT_VM=' + vm + '" to ' + envPath, 'y'):
             with open(envPath, 'a') as fp:
                 print >> fp, 'DEFAULT_VM=' + vm
     _vm = vm
     return vm
 
-""" 
+"""
 A context manager that can be used with the 'with' statement to set the VM
 used by all VM executions within the scope of the 'with' statement. For example:
 
@@ -117,17 +116,17 @@
         self.build = build if build else _vmbuild
         self.previousVm = _vm
         self.previousBuild = _vmbuild
-        
+
     def __enter__(self):
         global _vm, _vmbuild
         _vm = self.vm
         _vmbuild = self.build
-        
+
     def __exit__(self, exc_type, exc_value, traceback):
         global _vm, _vmbuild
         _vm = self.previousVm
         _vmbuild = self.previousBuild
-    
+
 def _chmodDir(chmodFlags, dirname, fnames):
     os.chmod(dirname, chmodFlags)
     for name in fnames:
@@ -145,7 +144,7 @@
                 shutil.rmtree(name)
             elif os.path.isfile(name):
                 os.unlink(name)
-                
+
         rmIfExists(join(_graal_home, 'build'))
         rmIfExists(join(_graal_home, 'build-nograal'))
         rmIfExists(_jdksDir())
@@ -154,7 +153,7 @@
 def export(args):
     """create a GraalVM zip file for distribution"""
 
-    parser = ArgumentParser(prog='mx export');
+    parser = ArgumentParser(prog='mx export')
     parser.add_argument('--omit-vm-build', action='store_false', dest='vmbuild', help='omit VM build step')
     parser.add_argument('--omit-dist-init', action='store_false', dest='distInit', help='omit class files and IDE configurations from distribution')
     parser.add_argument('zipfile', nargs=REMAINDER, metavar='zipfile')
@@ -201,13 +200,13 @@
     vmOpts, benchmarksAndOptions = _extract_VM_args(args, useDoubleDash=availableBenchmarks is None)
 
     if availableBenchmarks is None:
-        harnessArgs = benchmarksAndOptions 
+        harnessArgs = benchmarksAndOptions
         return runBenchmark(None, harnessArgs, vmOpts)
 
     if len(benchmarksAndOptions) == 0:
         mx.abort('at least one benchmark name or "all" must be specified')
     benchmarks = list(itertools.takewhile(lambda x: not x.startswith('-'), benchmarksAndOptions))
-    harnessArgs = benchmarksAndOptions[len(benchmarks):] 
+    harnessArgs = benchmarksAndOptions[len(benchmarks):]
 
     if 'all' in benchmarks:
         benchmarks = availableBenchmarks
@@ -229,7 +228,7 @@
 
     def launcher(bm, harnessArgs, extraVmOpts):
         return sanitycheck.getDacapo(bm, harnessArgs).test(_get_vm(), extraVmOpts=extraVmOpts)
-        
+
     _run_benchmark(args, sanitycheck.dacapoSanityWarmup.keys(), launcher)
 
 def scaladacapo(args):
@@ -281,8 +280,7 @@
 def _handle_missing_VM(bld, vm):
     mx.log('The ' + bld + ' ' + vm + ' VM has not been created')
     if sys.stdout.isatty():
-        answer = raw_input('Build it now? [Yn]: ')
-        if not answer.lower().startswith('n'):
+        if mx.ask_yes_no('Build it now', 'y'):
             with VM(vm, bld):
                 build([])
             return
@@ -334,7 +332,7 @@
             if mx.get_os() != 'windows':
                 chmodRecursive(jdk, 0755)
             shutil.move(join(_vmLibDirInJdk(jdk), defaultVM), join(_vmLibDirInJdk(jdk), 'original'))
-            
+
 
             with open(jvmCfg, 'w') as fp:
                 for line in jvmCfgLines:
@@ -350,10 +348,10 @@
             if _installed_jdks and mx._opts.verbose:
                 mx.log("Could not find JDK directory at " + jdk)
             _handle_missing_VM(build, vmToCheck if vmToCheck else 'graal')
-            
+
     if installGraalJar:
         _installGraalJarInJdks(mx.distribution('GRAAL'))
-    
+
     if vmToCheck is not None:
         jvmCfg = _vmCfgInJdk(jdk)
         found = False
@@ -364,7 +362,7 @@
                     break
         if not found:
             _handle_missing_VM(build, vmToCheck)
-        
+
     return jdk
 
 def _installGraalJarInJdks(graalDist):
@@ -380,25 +378,27 @@
                 shutil.copyfile(graalJar, tmp)
                 os.close(fd)
                 shutil.move(tmp, join(jreLibDir, 'graal.jar'))
-                
+
                 if exists(graalOptions):
                     shutil.copy(graalOptions, join(jreLibDir, 'graal.options'))
 
 # run a command in the windows SDK Debug Shell
-def _runInDebugShell(cmd, workingDir, logFile=None, findInOutput=None, respondTo={}):
+def _runInDebugShell(cmd, workingDir, logFile=None, findInOutput=None, respondTo=None):
+    if respondTo is None:
+        respondTo = {}
     newLine = os.linesep
-    STARTTOKEN = 'RUNINDEBUGSHELL_STARTSEQUENCE'
-    ENDTOKEN = 'RUNINDEBUGSHELL_ENDSEQUENCE'
+    startToken = 'RUNINDEBUGSHELL_STARTSEQUENCE'
+    endToken = 'RUNINDEBUGSHELL_ENDSEQUENCE'
 
     winSDK = mx.get_env('WIN_SDK', 'C:\\Program Files\\Microsoft SDKs\\Windows\\v7.1\\')
-    
+
     if not exists(winSDK):
         mx.abort("Could not find Windows SDK : '" + winSDK + "' does not exist")
-        
+
     if not exists(join(winSDK, 'Bin', 'SetEnv.cmd')):
         mx.abort("Invalid Windows SDK path (" + winSDK + ") : could not find Bin/SetEnv.cmd (you can use the WIN_SDK environment variable to specify an other path)")
 
-    p = subprocess.Popen('cmd.exe /E:ON /V:ON /K ""' + winSDK + '/Bin/SetEnv.cmd" & echo ' + STARTTOKEN + '"', \
+    p = subprocess.Popen('cmd.exe /E:ON /V:ON /K ""' + winSDK + '/Bin/SetEnv.cmd" & echo ' + startToken + '"', \
             shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, creationflags=subprocess.CREATE_NEW_PROCESS_GROUP)
     stdout = p.stdout
     stdin = p.stdin
@@ -406,20 +406,20 @@
         log = open(logFile, 'w')
     ret = False
     while True:
-        
+
         # encoding may be None on windows plattforms
         if sys.stdout.encoding is None:
             encoding = 'utf-8'
         else:
             encoding = sys.stdout.encoding
-        
+
         line = stdout.readline().decode(encoding)
         if logFile:
             log.write(line.encode('utf-8'))
         line = line.strip()
         mx.log(line)
-        if line == STARTTOKEN:
-            stdin.write('cd /D ' + workingDir + ' & ' + cmd + ' & echo ' + ENDTOKEN + newLine)
+        if line == startToken:
+            stdin.write('cd /D ' + workingDir + ' & ' + cmd + ' & echo ' + endToken + newLine)
         for regex in respondTo.keys():
             match = regex.search(line)
             if match:
@@ -428,7 +428,7 @@
             match = findInOutput.search(line)
             if match:
                 ret = True
-        if line == ENDTOKEN:
+        if line == endToken:
             if not findInOutput:
                 stdin.write('echo ERRXXX%errorlevel%' + newLine)
             else:
@@ -436,12 +436,44 @@
         if line.startswith('ERRXXX'):
             if line == 'ERRXXX0':
                 ret = True
-            break;
+            break
     stdin.write('exit' + newLine)
     if logFile:
         log.close()
     return ret
 
+def pylint(args):
+    """run pylint (if available) over Python source files"""
+    rcfile = join(_graal_home, 'mx', '.pylintrc')
+    if not exists(rcfile):
+        mx.log('pylint configuration file does not exist: ' + rcfile)
+        return
+
+    try:
+        output = subprocess.check_output(['pylint', '--version'], stderr=subprocess.STDOUT)
+        m = re.match(r'.*pylint (\d+)\.(\d+)\.(\d+).*', output, re.DOTALL)
+        if not m:
+            mx.log('could not determine pylint version from ' + output)
+            return
+        major, minor, micro = (int(m.group(1)), int(m.group(2)), int(m.group(3)))
+        if major < 1:
+            mx.log('require pylint version >= 1 (got {0}.{1}.{2})'.format(major, minor, micro))
+            return
+    except BaseException:
+        mx.log('pylint is not available')
+        return
+
+
+    env = os.environ.copy()
+    env['PYTHONPATH'] = dirname(mx.__file__)
+
+    versioned = subprocess.check_output(['hg', 'locate', '-f'], stderr=subprocess.STDOUT).split(os.linesep)
+    for f in versioned:
+        if f.endswith('.py'):
+            pyfile = f
+            mx.log('Running pylint on ' + pyfile + '...')
+            mx.run(['pylint', '--reports=n', '--rcfile=' + rcfile, pyfile], env=env)
+
 def jdkhome(args, vm=None):
     """print the JDK directory selected for the 'vm' command"""
 
@@ -458,16 +490,16 @@
         'INSTALL' : 'Install the built VM into the JDK? (default: y)',
         'ZIP_DEBUGINFO_FILES' : 'Install zipped debug symbols file? (default: 0)',
     }
-    
+
     mx.log('HotSpot build variables that can be set by the -D option to "mx build":')
     mx.log('')
     for n in sorted(buildVars.iterkeys()):
         mx.log(n)
         mx.log(textwrap.fill(buildVars[n], initial_indent='    ', subsequent_indent='    ', width=200))
-        
+
     mx.log('')
     mx.log('Note that these variables can be given persistent values in the file ' + join(_graal_home, 'mx', 'env') + ' (see \'mx about\').')
-    
+
 def build(args, vm=None):
     """build the VM binary
 
@@ -488,7 +520,7 @@
             return result
 
     # Call mx.build to compile the Java sources
-    parser=AP()
+    parser = AP()
     parser.add_argument('--export-dir', help='directory to which graal.jar and graal.options will be copied', metavar='<path>')
     parser.add_argument('-D', action='append', help='set a HotSpot build variable (run \'mx buildvars\' to list variables)', metavar='name=value')
     opts2 = mx.build(['--source', '1.7'] + args, parser=parser)
@@ -522,7 +554,11 @@
     else:
         assert vm == 'graal', vm
         buildSuffix = 'graal'
-        
+
+    if _installed_jdks and _installed_jdks != _graal_home:
+        if not mx.ask_yes_no("Warning: building while --installed-jdks is set (" + _installed_jdks + ") is not recommanded - are you sure you want to continue", 'n'):
+            mx.abort(1)
+
     for build in builds:
         if build == 'ide-build-target':
             build = os.environ.get('IDE_BUILD_TARGET', None)
@@ -577,7 +613,7 @@
             variant = {'client': 'compiler1', 'server': 'compiler2'}.get(vm, vm)
             project_config = variant + '_' + build
             _runInDebugShell('msbuild ' + _graal_home + r'\build\vs-amd64\jvm.vcproj /p:Configuration=' + project_config + ' /target:clean', _graal_home)
-            winCompileCmd = r'set HotSpotMksHome=' + mksHome + r'& set OUT_DIR=' + jdk + r'& set JAVA_HOME=' + jdk + r'& set path=%JAVA_HOME%\bin;%path%;%HotSpotMksHome%& cd /D "' +_graal_home + r'\make\windows"& call create.bat ' + _graal_home
+            winCompileCmd = r'set HotSpotMksHome=' + mksHome + r'& set OUT_DIR=' + jdk + r'& set JAVA_HOME=' + jdk + r'& set path=%JAVA_HOME%\bin;%path%;%HotSpotMksHome%& cd /D "' + _graal_home + r'\make\windows"& call create.bat ' + _graal_home
             print(winCompileCmd)
             winCompileSuccess = re.compile(r"^Writing \.vcxproj file:")
             if not _runInDebugShell(winCompileCmd, _graal_home, compilelogfile, winCompileSuccess):
@@ -590,14 +626,14 @@
         else:
             cpus = multiprocessing.cpu_count()
             runCmd = [mx.gmake_cmd()]
-            runCmd.append(build + buildSuffix) 
+            runCmd.append(build + buildSuffix)
             env = os.environ.copy()
-            
+
             if opts2.D:
                 for nv in opts2.D:
                     name, value = nv.split('=', 1)
                     env[name.strip()] = value
-            
+
             env.setdefault('ARCH_DATA_MODEL', '64')
             env.setdefault('LANG', 'C')
             env.setdefault('HOTSPOT_BUILD_JOBS', str(cpus))
@@ -645,7 +681,7 @@
                 if line.strip() == vmKnown.strip():
                     found = True
                 lines.append(line)
-                
+
         if not found:
             mx.log('Appending "' + prefix + 'KNOWN" to ' + jvmCfg)
             if mx.get_os() != 'windows':
@@ -699,7 +735,7 @@
         for p in mx.projects():
             excludes += _find_classes_with_annotations(p, None, ['@Snippet', '@ClassSubstitution', '@Test'], includeInnerClasses=True).keys()
             excludes += p.find_classes_with_matching_source_line(None, lambda line: 'JaCoCo Exclude' in line, includeInnerClasses=True).keys()
-            
+
         includes = ['com.oracle.graal.*']
         agentOptions = {
                         'append' : 'true' if _jacoco == 'append' else 'false',
@@ -714,12 +750,12 @@
 
     exe = join(jdk, 'bin', mx.exe_suffix('java'))
     pfx = _vm_prefix.split() if _vm_prefix is not None else []
-    
+
     if '-version' in args:
-        ignoredArgs = args[args.index('-version')+1:]
+        ignoredArgs = args[args.index('-version') + 1:]
         if  len(ignoredArgs) > 0:
             mx.log("Warning: The following options will be ignored by the vm because they come after the '-version' argument: " + ' '.join(ignoredArgs))
-    
+
     return mx.run(pfx + [exe, '-' + vm] + args, nonZeroIsFatal=nonZeroIsFatal, out=out, err=err, cwd=cwd, timeout=timeout)
 
 def _find_classes_with_annotations(p, pkgRoot, annotations, includeInnerClasses=False):
@@ -728,7 +764,7 @@
     (ignoring preceding whitespace) and return the fully qualified class name for each Java
     source file matched in a list.
     """
-    
+
     matches = lambda line : len([a for a in annotations if line == a or line.startswith(a + '(')]) != 0
     return p.find_classes_with_matching_source_line(pkgRoot, matches, includeInnerClasses)
 
@@ -740,7 +776,7 @@
         if useDoubleDash:
             if args[i] == '--':
                 vmArgs = args[:i]
-                remainder = args[i + 1:] 
+                remainder = args[i + 1:]
                 return vmArgs, remainder
         else:
             if not args[i].startswith('-'):
@@ -750,25 +786,19 @@
                     else:
                         continue
                 vmArgs = args[:i]
-                remainder = args[i:] 
+                remainder = args[i:]
                 return vmArgs, remainder
-            
+
     return args, []
-    
+
 def _run_tests(args, harness, annotations, testfile):
-    
-    
+
+
     vmArgs, tests = _extract_VM_args(args)
     for t in tests:
         if t.startswith('-'):
             mx.abort('VM option ' + t + ' must precede ' + tests[0])
 
-    def containsAny(c, substrings):
-        for s in substrings:
-            if s in c:
-                return True
-        return False
-    
     candidates = []
     for p in mx.projects():
         if mx.java().javaCompliance < p.javaCompliance:
@@ -833,14 +863,14 @@
 
     If filters are supplied, only tests whose fully qualified name
     includes a filter as a substring are run.
-    
+
     For example, this command line:
-    
+
        mx unittest -G:Dump= -G:MethodFilter=BC_aload.* -G:+PrintCFG BC_aload
-    
+
     will run all JUnit test classes that contain 'BC_aload' in their
-    fully qualified name and will pass these options to the VM: 
-    
+    fully qualified name and will pass these options to the VM:
+
         -G:Dump= -G:MethodFilter=BC_aload.* -G:+PrintCFG
 
     To get around command line length limitations on some OSes, the
@@ -853,7 +883,7 @@
     As with all other commands, using the global '-v' before 'unittest'
     command will cause mx to show the complete command line
     it uses to run the VM.
-""" 
+"""
 
 def unittest(args):
     """run the JUnit tests (all testcases){0}"""
@@ -875,8 +905,8 @@
 
     vmsDefault = ','.join(_vmChoices.keys())
     vmbuildsDefault = ','.join(_vmbuildChoices)
-    
-    parser = ArgumentParser(prog='mx buildvms');
+
+    parser = ArgumentParser(prog='mx buildvms')
     parser.add_argument('--vms', help='a comma separated list of VMs to build (default: ' + vmsDefault + ')', metavar='<args>', default=vmsDefault)
     parser.add_argument('--builds', help='a comma separated list of build types (default: ' + vmbuildsDefault + ')', metavar='<args>', default=vmbuildsDefault)
     parser.add_argument('-n', '--no-check', action='store_true', help='omit running "java -version" after each build')
@@ -897,7 +927,8 @@
                 start = time.time()
                 mx.log('BEGIN: ' + v + '-' + vmbuild + '\t(see: ' + logFile + ')')
                 # Run as subprocess so that output can be directed to a file
-                subprocess.check_call([sys.executable, '-u', join('mxtool', 'mx.py'), '--vm', v, '--vmbuild', vmbuild, 'build'], cwd=_graal_home, stdout=log, stderr=subprocess.STDOUT)
+                subprocess.check_call([sys.executable, '-u', join('mxtool', 'mx.py'), '--vm', v, '--vmbuild',
+                                       vmbuild, 'build'], cwd=_graal_home, stdout=log, stderr=subprocess.STDOUT)
                 duration = datetime.timedelta(seconds=time.time() - start)
                 mx.log('END:   ' + v + '-' + vmbuild + '\t[' + str(duration) + ']')
             else:
@@ -936,7 +967,7 @@
             mx.abort(codeOrMessage)
             return self
 
-    parser = ArgumentParser(prog='mx gate');
+    parser = ArgumentParser(prog='mx gate')
     parser.add_argument('-j', '--omit-java-clean', action='store_false', dest='cleanJava', help='omit cleaning Java native code')
     parser.add_argument('-n', '--omit-native-clean', action='store_false', dest='cleanNative', help='omit cleaning and building native code')
     parser.add_argument('-g', '--only-build-graalvm', action='store_false', dest='buildNonGraal', help='only build the Graal VM')
@@ -945,11 +976,15 @@
     args = parser.parse_args(args)
 
     global _jacoco
-    
+
     tasks = []
     total = Task('Gate')
     try:
 
+        t = Task('Pylint')
+        pylint([])
+        tasks.append(t.stop())
+
         t = Task('Clean')
         cleanArgs = []
         if not args.cleanNative:
@@ -976,7 +1011,7 @@
         if mx.canonicalizeprojects([]) != 0:
             t.abort('Rerun "mx canonicalizeprojects" and check-in the modified mx/projects files.')
         tasks.append(t.stop())
-        
+
         t = Task('BuildJava')
         build(['--no-native', '--jdt-warning-as-error'])
         tasks.append(t.stop())
@@ -985,10 +1020,10 @@
         if mx.checkstyle([]) != 0:
             t.abort('Checkstyle warnings were found')
         tasks.append(t.stop())
-        
+
         if exists('jacoco.exec'):
             os.unlink('jacoco.exec')
-        
+
         if args.jacocout is not None:
             _jacoco = 'append'
         else:
@@ -1007,10 +1042,10 @@
             t = Task('BootstrapWithGCVerification:product')
             vm(['-XX:+UnlockDiagnosticVMOptions', '-XX:+VerifyBeforeGC', '-XX:+VerifyAfterGC', '-version'])
             tasks.append(t.stop())
-    
+
         with VM('graal', 'product'):
             t = Task('BootstrapWithG1GCVerification:product')
-            vm(['-XX:+UnlockDiagnosticVMOptions', '-XX:-UseSerialGC','-XX:+UseG1GC','-XX:+UseNewCode','-XX:+VerifyBeforeGC', '-XX:+VerifyAfterGC', '-version'])
+            vm(['-XX:+UnlockDiagnosticVMOptions', '-XX:-UseSerialGC', '-XX:+UseG1GC', '-XX:+UseNewCode', '-XX:+VerifyBeforeGC', '-XX:+VerifyAfterGC', '-version'])
             tasks.append(t.stop())
 
         with VM('graal', 'product'):
@@ -1023,7 +1058,7 @@
             vm(['-G:+AOTCompilation', '-G:+VerifyPhases', '-esa', '-version'])
             tasks.append(t.stop())
 
-        with VM('server', 'product'): # hosted mode
+        with VM('server', 'product'):  # hosted mode
             t = Task('UnitTests:hosted-product')
             unittest([])
             tasks.append(t.stop())
@@ -1037,7 +1072,7 @@
 
         if args.jacocout is not None:
             jacocoreport([args.jacocout])
-            
+
         _jacoco = 'off'
 
         t = Task('CleanAndBuildGraalVisualizer')
@@ -1058,7 +1093,7 @@
                         t = Task('DaCapo_pmd:' + theVm + ':' + vmbuild)
                         dacapo(['pmd'])
                         tasks.append(t.stop())
-    
+
                         t = Task('UnitTests:' + theVm + ':' + vmbuild)
                         unittest(['-XX:CompileCommand=exclude,*::run*', 'graal.api'])
                         tasks.append(t.stop())
@@ -1078,7 +1113,7 @@
         mx.log('  ' + str(t.duration) + '\t' + t.title)
     mx.log('  =======')
     mx.log('  ' + str(total.duration))
-    
+
 def deoptalot(args):
     """bootstrap a fastdebug Graal VM with DeoptimizeALot and VerifyOops on
 
@@ -1088,15 +1123,15 @@
     if len(args) > 0 and args[0].isdigit():
         count = int(args[0])
         del args[0]
-    
+
     for _ in range(count):
         if not vm(['-XX:+DeoptimizeALot', '-XX:+VerifyOops'] + args + ['-version'], vmbuild='fastdebug') == 0:
             mx.abort("Failed")
-            
+
 def longtests(args):
-    
+
     deoptalot(['15', '-Xmx48m'])
-    
+
     dacapo(['100', 'eclipse', '-esa'])
 
 def gv(args):
@@ -1131,7 +1166,7 @@
     vm = _get_vm()
     if len(args) is 0:
         args = ['all']
-    
+
     vmArgs = [arg for arg in args if arg.startswith('-')]
 
     def benchmarks_in_group(group):
@@ -1140,7 +1175,7 @@
 
     results = {}
     benchmarks = []
-    #DaCapo
+    # DaCapo
     if ('dacapo' in args or 'all' in args):
         benchmarks += sanitycheck.getDacapos(level=sanitycheck.SanityCheckLevel.Benchmark)
     else:
@@ -1163,23 +1198,23 @@
             if (iterations > 0):
                 benchmarks += [sanitycheck.getScalaDacapo(scaladacapo, ['-n', str(iterations)])]
 
-    #Bootstrap
+    # Bootstrap
     if ('bootstrap' in args or 'all' in args):
         benchmarks += sanitycheck.getBootstraps()
-    #SPECjvm2008
+    # SPECjvm2008
     if ('specjvm2008' in args or 'all' in args):
         benchmarks += [sanitycheck.getSPECjvm2008(['-ikv', '-wt', '120', '-it', '120'])]
     else:
         specjvms = benchmarks_in_group('specjvm2008')
         for specjvm in specjvms:
             benchmarks += [sanitycheck.getSPECjvm2008(['-ikv', '-wt', '120', '-it', '120', specjvm])]
-            
+
     if ('specjbb2005' in args or 'all' in args):
         benchmarks += [sanitycheck.getSPECjbb2005()]
-        
-    if ('specjbb2013' in args): # or 'all' in args //currently not in default set
+
+    if ('specjbb2013' in args):  # or 'all' in args //currently not in default set
         benchmarks += [sanitycheck.getSPECjbb2013()]
-        
+
     if ('ctw-full' in args):
         benchmarks.append(sanitycheck.getCTW(vm, sanitycheck.CTWMode.Full))
     if ('ctw-noinline' in args):
@@ -1198,37 +1233,36 @@
 
 def specjvm2008(args):
     """run one or more SPECjvm2008 benchmarks"""
-    
+
     def launcher(bm, harnessArgs, extraVmOpts):
         return sanitycheck.getSPECjvm2008(harnessArgs + [bm]).bench(_get_vm(), extraVmOpts=extraVmOpts)
-    
+
     availableBenchmarks = set(sanitycheck.specjvm2008Names)
     for name in sanitycheck.specjvm2008Names:
         parts = name.rsplit('.', 1)
         if len(parts) > 1:
             assert len(parts) == 2
             group = parts[0]
-            print group
             availableBenchmarks.add(group)
 
     _run_benchmark(args, sorted(availableBenchmarks), launcher)
-    
+
 def specjbb2013(args):
     """runs the composite SPECjbb2013 benchmark"""
-    
+
     def launcher(bm, harnessArgs, extraVmOpts):
         assert bm is None
         return sanitycheck.getSPECjbb2013(harnessArgs).bench(_get_vm(), extraVmOpts=extraVmOpts)
-    
+
     _run_benchmark(args, None, launcher)
 
 def specjbb2005(args):
     """runs the composite SPECjbb2005 benchmark"""
-    
+
     def launcher(bm, harnessArgs, extraVmOpts):
         assert bm is None
         return sanitycheck.getSPECjbb2005(harnessArgs).bench(_get_vm(), extraVmOpts=extraVmOpts)
-    
+
     _run_benchmark(args, None, launcher)
 
 def hsdis(args, copyToDir=None):
@@ -1252,17 +1286,17 @@
     Run a tool over the input files to convert all embedded HexCodeFiles
     to a disassembled format."""
 
-    parser = ArgumentParser(prog='mx hcfdis');
+    parser = ArgumentParser(prog='mx hcfdis')
     parser.add_argument('-m', '--map', help='address to symbol map applied to disassembler output')
     parser.add_argument('files', nargs=REMAINDER, metavar='files...')
 
     args = parser.parse_args(args)
-    
+
     path = join(_graal_home, 'lib', 'hcfdis-1.jar')
     if not exists(path):
         mx.download(path, ['http://lafo.ssw.uni-linz.ac.at/hcfdis-1.jar'])
     mx.run_java(['-jar', path] + args.files)
-    
+
     if args.map is not None:
         addressRE = re.compile(r'0[xX]([A-Fa-f0-9]+)')
         with open(args.map) as fp:
@@ -1271,8 +1305,8 @@
         for l in lines:
             addressAndSymbol = l.split(' ', 1)
             if len(addressAndSymbol) == 2:
-                address, symbol = addressAndSymbol;
-                if address.startswith('0x'): 
+                address, symbol = addressAndSymbol
+                if address.startswith('0x'):
                     address = long(address, 16)
                     symbols[address] = symbol
         for f in args.files:
@@ -1334,6 +1368,7 @@
         'hcfdis': [hcfdis, ''],
         'igv' : [igv, ''],
         'jdkhome': [jdkhome, ''],
+        'pylint': [pylint, ''],
         'dacapo': [dacapo, '[VM options] benchmarks...|"all" [DaCapo options]'],
         'scaladacapo': [scaladacapo, '[VM options] benchmarks...|"all" [Scala DaCapo options]'],
         'specjvm2008': [specjvm2008, '[VM options] benchmarks...|"all" [SPECjvm2008 options]'],
@@ -1362,7 +1397,7 @@
 
     if (_vmSourcesAvailable):
         mx.add_argument('--vm', action='store', dest='vm', choices=_vmChoices.keys(), help='the VM type to build/run')
-        mx.add_argument('--vmbuild', action='store', dest='vmbuild', choices=_vmbuildChoices, help='the VM build to build/run (default: ' + _vmbuildChoices[0] +')')
+        mx.add_argument('--vmbuild', action='store', dest='vmbuild', choices=_vmbuildChoices, help='the VM build to build/run (default: ' + _vmbuildChoices[0] + ')')
         mx.add_argument('--ecl', action='store_true', dest='make_eclipse_launch', help='create launch configuration for running VM execution(s) in Eclipse')
         mx.add_argument('--vmprefix', action='store', dest='vm_prefix', help='prefix for running the VM (e.g. "/usr/bin/gdb --args")', metavar='<prefix>')
         mx.add_argument('--gdb', action='store_const', const='/usr/bin/gdb --args', dest='vm_prefix', help='alias for --vmprefix "/usr/bin/gdb --args"')
@@ -1371,9 +1406,9 @@
             'export': [export, '[-options] [zipfile]'],
         })
 
-    mx.commands.update(commands)
+    mx._commands.update(commands)
 
-def mx_post_parse_cmd_line(opts):#
+def mx_post_parse_cmd_line(opts):  #
     # TODO _minVersion check could probably be part of a Suite in mx?
     if (mx.java().version < _minVersion) :
         mx.abort('Requires Java version ' + str(_minVersion) + ' or greater, got version ' + str(mx.java().version))
--- a/mx/outputparser.py	Fri Sep 06 16:17:01 2013 +0200
+++ b/mx/outputparser.py	Fri Sep 06 16:17:16 2013 +0200
@@ -26,13 +26,13 @@
 import re
 
 class OutputParser:
-    
+
     def __init__(self):
         self.matchers = []
-        
+
     def addMatcher(self, matcher):
         self.matchers.append(matcher)
-    
+
     def parse(self, output):
         valueMaps = []
         for matcher in self.matchers:
@@ -47,12 +47,12 @@
 given as the group name enclosed in '<' and '>'.
 """
 class ValuesMatcher:
-    
+
     def __init__(self, regex, valuesTemplate):
         assert isinstance(valuesTemplate, dict)
         self.regex = regex
         self.valuesTemplate = valuesTemplate
-        
+
     def parse(self, text, valueMaps):
         for match in self.regex.finditer(text):
             valueMap = {}
@@ -62,10 +62,10 @@
                 assert not valueMap.has_key(key), key
                 valueMap[key] = value
             valueMaps.append(valueMap)
-        
+
     def get_template_value(self, match, template):
         def replace_var(m):
             groupName = m.group(1)
             return match.group(groupName)
-        
+
         return re.sub(r'<([\w]+)>', replace_var, template)
--- a/mx/sanitycheck.py	Fri Sep 06 16:17:01 2013 +0200
+++ b/mx/sanitycheck.py	Fri Sep 06 16:17:16 2013 +0200
@@ -27,31 +27,31 @@
 import re, mx, commands, os, sys, StringIO, subprocess
 from os.path import isfile, join, exists
 
-gc='UseSerialGC'
+gc = 'UseSerialGC'
 
 dacapoSanityWarmup = {
-    'avrora':     [0, 0,  3,  6, 13],
-    'batik':      [0, 0,  5,  5, 20],
-    'eclipse':    [2, 4,  5, 10, 16],
+    'avrora':     [0, 0, 3, 6, 13],
+    'batik':      [0, 0, 5, 5, 20],
+    'eclipse':    [2, 4, 5, 10, 16],
     'fop':        [4, 8, 10, 20, 30],
-    'h2':         [0, 0,  5,  5,  8],
-    'jython':     [0, 0,  5, 10, 13],
-    'luindex':    [0, 0,  5, 10, 10],
-    'lusearch':   [0, 4,  5,  5,  8],
-    'pmd':        [0, 0,  5, 10, 13],
-    'sunflow':    [0, 2,  5, 10, 15],
-    'tomcat':     [0, 0,  5, 10, 15],
-    'tradebeans': [0, 0,  5, 10, 13],
-    'tradesoap':  [2, 4,  5, 10, 15],
-    'xalan':      [0, 0,  5, 10, 18],
+    'h2':         [0, 0, 5, 5, 8],
+    'jython':     [0, 0, 5, 10, 13],
+    'luindex':    [0, 0, 5, 10, 10],
+    'lusearch':   [0, 4, 5, 5, 8],
+    'pmd':        [0, 0, 5, 10, 13],
+    'sunflow':    [0, 2, 5, 10, 15],
+    'tomcat':     [0, 0, 5, 10, 15],
+    'tradebeans': [0, 0, 5, 10, 13],
+    'tradesoap':  [2, 4, 5, 10, 15],
+    'xalan':      [0, 0, 5, 10, 18],
 }
 
 dacapoScalaSanityWarmup = {
 # (tw) actors sometimes fails verification; hardly reproducible
-    'actors':     [0, 0, 0,  0,  0],
+    'actors':     [0, 0, 0, 0, 0],
 # (lstadler) apparat was disabled due to a deadlock which I think is the benchmarks fault.
-    'apparat':    [0, 0, 0,  0,  0],
-    'factorie':   [0, 0, 2,  5,  5],
+    'apparat':    [0, 0, 0, 0, 0],
+    'factorie':   [0, 0, 2, 5, 5],
     'kiama':      [0, 0, 3, 13, 15],
     'scalac':     [0, 0, 5, 15, 20],
     'scaladoc':   [0, 0, 5, 15, 15],
@@ -59,8 +59,8 @@
     'scalariform':[0, 0, 6, 15, 20],
     'scalatest':  [0, 0, 2, 10, 12],
     'scalaxb':    [0, 0, 5, 15, 25],
-#(gdub) specs sometimes returns a non-zero value event though there is no apparent failure
-    'specs':      [0, 0, 0,  0,  0],
+# (gdub) specs sometimes returns a non-zero value event though there is no apparent failure
+    'specs':      [0, 0, 0, 0, 0],
     'tmt':        [0, 0, 3, 10, 12]
 }
 
@@ -77,7 +77,8 @@
     'sunflow':    [           'fastdebug', 'debug'],
     'tomcat':     ['product', 'fastdebug', 'debug'],
     'tradebeans': ['product', 'fastdebug', 'debug'],
-    'tradesoap':  ['product'],
+    # tradesoap is too unreliable for the gate, often crashing with "java.net.BindException: Address already in use"
+    'tradesoap':  [                               ],
     'xalan':      ['product', 'fastdebug', 'debug'],
 }
 
@@ -137,60 +138,68 @@
     'xml.validation'
 ]
 
+def _noneAsEmptyList(a):
+    if a is None:
+        return []
+    return a
+
 class SanityCheckLevel:
     Fast, Gate, Normal, Extensive, Benchmark = range(5)
-    
-def getSPECjbb2005(benchArgs = []):
-    
+
+def getSPECjbb2005(benchArgs=None):
+    benchArgs = [] if benchArgs is None else benchArgs
+
     specjbb2005 = mx.get_env('SPECJBB2005')
     if specjbb2005 is None or not exists(join(specjbb2005, 'jbb.jar')):
         mx.abort('Please set the SPECJBB2005 environment variable to a SPECjbb2005 directory')
-    
+
     score = re.compile(r"^Valid run, Score is  (?P<score>[0-9]+)$", re.MULTILINE)
     error = re.compile(r"VALIDATION ERROR")
     success = re.compile(r"^Valid run, Score is  [0-9]+$", re.MULTILINE)
     matcher = ValuesMatcher(score, {'group' : 'SPECjbb2005', 'name' : 'score', 'score' : '<score>'})
     classpath = ['jbb.jar', 'check.jar']
-    return Test("SPECjbb2005", ['spec.jbb.JBBmain', '-propfile', 'SPECjbb.props'] + benchArgs, [success], [error], [matcher], vmOpts=['-Xms3g', '-XX:+'+gc, '-XX:-UseCompressedOops', '-cp', os.pathsep.join(classpath)], defaultCwd=specjbb2005)
+    return Test("SPECjbb2005", ['spec.jbb.JBBmain', '-propfile', 'SPECjbb.props'] + benchArgs, [success], [error], [matcher], vmOpts=['-Xms3g', '-XX:+' + gc, '-XX:-UseCompressedOops', '-cp', os.pathsep.join(classpath)], defaultCwd=specjbb2005)
 
-def getSPECjbb2013(benchArgs = []):
-    
+def getSPECjbb2013(benchArgs=None):
+
     specjbb2013 = mx.get_env('SPECJBB2013')
     if specjbb2013 is None or not exists(join(specjbb2013, 'specjbb2013.jar')):
         mx.abort('Please set the SPECJBB2013 environment variable to a SPECjbb2013 directory')
-    
+
     jops = re.compile(r"^RUN RESULT: hbIR \(max attempted\) = [0-9]+, hbIR \(settled\) = [0-9]+, max-jOPS = (?P<max>[0-9]+), critical-jOPS = (?P<critical>[0-9]+)$", re.MULTILINE)
-    #error?
+    # error?
     success = re.compile(r"org.spec.jbb.controller: Run finished", re.MULTILINE)
     matcherMax = ValuesMatcher(jops, {'group' : 'SPECjbb2013', 'name' : 'max', 'score' : '<max>'})
     matcherCritical = ValuesMatcher(jops, {'group' : 'SPECjbb2013', 'name' : 'critical', 'score' : '<critical>'})
-    return Test("SPECjbb2013", ['-jar', 'specjbb2013.jar', '-m', 'composite'] + benchArgs, [success], [], [matcherCritical, matcherMax], vmOpts=['-Xmx6g', '-Xms6g', '-Xmn3g', '-XX:+UseParallelOldGC', '-XX:-UseAdaptiveSizePolicy', '-XX:-UseBiasedLocking', '-XX:-UseCompressedOops'], defaultCwd=specjbb2013)
-    
-def getSPECjvm2008(benchArgs=[]):
-    
+    return Test("SPECjbb2013", ['-jar', 'specjbb2013.jar', '-m', 'composite'] +
+                _noneAsEmptyList(benchArgs), [success], [], [matcherCritical, matcherMax],
+                vmOpts=['-Xmx6g', '-Xms6g', '-Xmn3g', '-XX:+UseParallelOldGC', '-XX:-UseAdaptiveSizePolicy', '-XX:-UseBiasedLocking', '-XX:-UseCompressedOops'], defaultCwd=specjbb2013)
+
+def getSPECjvm2008(benchArgs=None):
+
     specjvm2008 = mx.get_env('SPECJVM2008')
     if specjvm2008 is None or not exists(join(specjvm2008, 'SPECjvm2008.jar')):
         mx.abort('Please set the SPECJVM2008 environment variable to a SPECjvm2008 directory')
-    
+
     score = re.compile(r"^(Score on|Noncompliant) (?P<benchmark>[a-zA-Z0-9\._]+)( result)?: (?P<score>[0-9]+((,|\.)[0-9]+)?)( SPECjvm2008 Base)? ops/m$", re.MULTILINE)
     error = re.compile(r"^Errors in benchmark: ", re.MULTILINE)
     # The ' ops/m' at the end of the success string is important : it's how you can tell valid and invalid runs apart
     success = re.compile(r"^(Noncompliant c|C)omposite result: [0-9]+((,|\.)[0-9]+)?( SPECjvm2008 (Base|Peak))? ops/m$", re.MULTILINE)
     matcher = ValuesMatcher(score, {'group' : 'SPECjvm2008', 'name' : '<benchmark>', 'score' : '<score>'})
-    
-    return Test("SPECjvm2008", ['-jar', 'SPECjvm2008.jar'] + benchArgs, [success], [error], [matcher], vmOpts=['-Xms3g', '-XX:+'+gc, '-XX:-UseCompressedOops'], defaultCwd=specjvm2008)
+
+    return Test("SPECjvm2008", ['-jar', 'SPECjvm2008.jar'] + _noneAsEmptyList(benchArgs), [success], [error], [matcher], vmOpts=['-Xms3g', '-XX:+' + gc, '-XX:-UseCompressedOops'], defaultCwd=specjvm2008)
 
-def getDacapos(level=SanityCheckLevel.Normal, gateBuildLevel=None, dacapoArgs=[]):
+def getDacapos(level=SanityCheckLevel.Normal, gateBuildLevel=None, dacapoArgs=None):
     checks = []
-    
+
     for (bench, ns) in dacapoSanityWarmup.items():
         if ns[level] > 0:
             if gateBuildLevel is None or gateBuildLevel in dacapoGateBuildLevels[bench]:
-                checks.append(getDacapo(bench, ['-n', str(ns[level])] + dacapoArgs))
-    
+                checks.append(getDacapo(bench, ['-n', str(ns[level])] + _noneAsEmptyList(dacapoArgs)))
+
     return checks
 
-def getDacapo(name, dacapoArgs=[]):
+def getDacapo(name, dacapoArgs=None):
     dacapo = mx.get_env('DACAPO_CP')
     if dacapo is None:
         l = mx.library('DACAPO', False)
@@ -198,31 +207,31 @@
             dacapo = l.get_path(True)
         else:
             mx.abort('DaCapo 9.12 jar file must be specified with DACAPO_CP environment variable or as DACAPO library')
-    
+
     if not isfile(dacapo) or not dacapo.endswith('.jar'):
         mx.abort('Specified DaCapo jar file does not exist or is not a jar file: ' + dacapo)
-    
+
     dacapoSuccess = re.compile(r"^===== DaCapo 9\.12 ([a-zA-Z0-9_]+) PASSED in ([0-9]+) msec =====$", re.MULTILINE)
     dacapoFail = re.compile(r"^===== DaCapo 9\.12 ([a-zA-Z0-9_]+) FAILED (warmup|) =====$", re.MULTILINE)
     dacapoTime = re.compile(r"===== DaCapo 9\.12 (?P<benchmark>[a-zA-Z0-9_]+) PASSED in (?P<time>[0-9]+) msec =====")
     dacapoTime1 = re.compile(r"===== DaCapo 9\.12 (?P<benchmark>[a-zA-Z0-9_]+) completed warmup 1 in (?P<time>[0-9]+) msec =====")
-    
+
     dacapoMatcher = ValuesMatcher(dacapoTime, {'group' : 'DaCapo', 'name' : '<benchmark>', 'score' : '<time>'})
     dacapoMatcher1 = ValuesMatcher(dacapoTime1, {'group' : 'DaCapo-1stRun', 'name' : '<benchmark>', 'score' : '<time>'})
-    
-    return Test("DaCapo-" + name, ['-jar', dacapo, name] + dacapoArgs, [dacapoSuccess], [dacapoFail], [dacapoMatcher, dacapoMatcher1], ['-Xms2g', '-XX:+'+gc, '-XX:-UseCompressedOops'])
+
+    return Test("DaCapo-" + name, ['-jar', dacapo, name] + _noneAsEmptyList(dacapoArgs), [dacapoSuccess], [dacapoFail], [dacapoMatcher, dacapoMatcher1], ['-Xms2g', '-XX:+' + gc, '-XX:-UseCompressedOops'])
 
-def getScalaDacapos(level=SanityCheckLevel.Normal, gateBuildLevel=None, dacapoArgs=[]):
+def getScalaDacapos(level=SanityCheckLevel.Normal, gateBuildLevel=None, dacapoArgs=None):
     checks = []
-    
+
     for (bench, ns) in dacapoScalaSanityWarmup.items():
         if ns[level] > 0:
             if gateBuildLevel is None or gateBuildLevel in dacapoScalaGateBuildLevels[bench]:
-                checks.append(getScalaDacapo(bench, ['-n', str(ns[level])] + dacapoArgs))
-    
+                checks.append(getScalaDacapo(bench, ['-n', str(ns[level])] + _noneAsEmptyList(dacapoArgs)))
+
     return checks
 
-def getScalaDacapo(name, dacapoArgs=[]):
+def getScalaDacapo(name, dacapoArgs=None):
     dacapo = mx.get_env('DACAPO_SCALA_CP')
     if dacapo is None:
         l = mx.library('DACAPO_SCALA', False)
@@ -230,23 +239,23 @@
             dacapo = l.get_path(True)
         else:
             mx.abort('Scala DaCapo 0.1.0 jar file must be specified with DACAPO_SCALA_CP environment variable or as DACAPO_SCALA library')
-    
+
     if not isfile(dacapo) or not dacapo.endswith('.jar'):
         mx.abort('Specified Scala DaCapo jar file does not exist or is not a jar file: ' + dacapo)
-    
+
     dacapoSuccess = re.compile(r"^===== DaCapo 0\.1\.0(-SNAPSHOT)? ([a-zA-Z0-9_]+) PASSED in ([0-9]+) msec =====$", re.MULTILINE)
     dacapoFail = re.compile(r"^===== DaCapo 0\.1\.0(-SNAPSHOT)? ([a-zA-Z0-9_]+) FAILED (warmup|) =====$", re.MULTILINE)
     dacapoTime = re.compile(r"===== DaCapo 0\.1\.0(-SNAPSHOT)? (?P<benchmark>[a-zA-Z0-9_]+) PASSED in (?P<time>[0-9]+) msec =====")
-    
+
     dacapoMatcher = ValuesMatcher(dacapoTime, {'group' : "Scala-DaCapo", 'name' : '<benchmark>', 'score' : '<time>'})
-    
-    return Test("Scala-DaCapo-" + name, ['-jar', dacapo, name] + dacapoArgs, [dacapoSuccess], [dacapoFail], [dacapoMatcher], ['-Xms2g', '-XX:+'+gc, '-XX:-UseCompressedOops'])
+
+    return Test("Scala-DaCapo-" + name, ['-jar', dacapo, name] + _noneAsEmptyList(dacapoArgs), [dacapoSuccess], [dacapoFail], [dacapoMatcher], ['-Xms2g', '-XX:+' + gc, '-XX:-UseCompressedOops'])
 
 def getBootstraps():
     time = re.compile(r"Bootstrapping Graal\.+ in (?P<time>[0-9]+) ms")
     scoreMatcher = ValuesMatcher(time, {'group' : 'Bootstrap', 'name' : 'BootstrapTime', 'score' : '<time>'})
     scoreMatcherBig = ValuesMatcher(time, {'group' : 'Bootstrap-bigHeap', 'name' : 'BootstrapTime', 'score' : '<time>'})
-    
+
     tests = []
     tests.append(Test("Bootstrap", ['-version'], successREs=[time], scoreMatchers=[scoreMatcher], ignoredVMs=['client', 'server'], benchmarkCompilationRate=False))
     tests.append(Test("Bootstrap-bigHeap", ['-version'], successREs=[time], scoreMatchers=[scoreMatcherBig], vmOpts=['-Xms2g'], ignoredVMs=['client', 'server'], benchmarkCompilationRate=False))
@@ -255,16 +264,16 @@
 class CTWMode:
     Full, NoInline, NoComplex = range(3)
 
-def getCTW(vm,mode):
+def getCTW(vm, mode):
     time = re.compile(r"CompileTheWorld : Done \([0-9]+ classes, [0-9]+ methods, (?P<time>[0-9]+) ms\)")
     scoreMatcher = ValuesMatcher(time, {'group' : 'CompileTheWorld', 'name' : 'CompileTime', 'score' : '<time>'})
-    
+
     jre = os.environ.get('JAVA_HOME')
     if exists(join(jre, 'jre')):
         jre = join(jre, 'jre')
     rtjar = join(jre, 'lib', 'rt.jar')
 
-    
+
     args = ['-XX:+CompileTheWorld', '-Xbootclasspath/p:' + rtjar]
     if commands.isGraalEnabled(vm):
         args += ['-XX:+BootstrapGraal', '-G:-Debug']
@@ -276,9 +285,9 @@
     if mode >= CTWMode.NoComplex:
         if commands.isGraalEnabled(vm):
             args += ['-G:-OptLoopTransform', '-G:-OptTailDuplication', '-G:-FullUnroll', '-G:-MemoryAwareScheduling', '-G:-NewMemoryAwareScheduling', '-G:-PartialEscapeAnalysis']
-        
+
     return Test("CompileTheWorld", args, successREs=[time], scoreMatchers=[scoreMatcher], benchmarkCompilationRate=False)
-    
+
 
 class Tee:
     def __init__(self):
@@ -291,24 +300,24 @@
 Encapsulates a single program that is a sanity test and/or a benchmark.
 """
 class Test:
-    def __init__(self, name, cmd, successREs=[], failureREs=[], scoreMatchers=[], vmOpts=[], defaultCwd=None, ignoredVMs=[], benchmarkCompilationRate=False):
+    def __init__(self, name, cmd, successREs=None, failureREs=None, scoreMatchers=None, vmOpts=None, defaultCwd=None, ignoredVMs=None, benchmarkCompilationRate=False):
 
         self.name = name
-        self.successREs = successREs
-        self.failureREs = failureREs + [re.compile(r"Exception occurred in scope: ")]
-        self.scoreMatchers = scoreMatchers
-        self.vmOpts = vmOpts
+        self.successREs = _noneAsEmptyList(successREs)
+        self.failureREs = _noneAsEmptyList(failureREs) + [re.compile(r"Exception occurred in scope: ")]
+        self.scoreMatchers = _noneAsEmptyList(scoreMatchers)
+        self.vmOpts = _noneAsEmptyList(vmOpts)
         self.cmd = cmd
         self.defaultCwd = defaultCwd
-        self.ignoredVMs = ignoredVMs
+        self.ignoredVMs = _noneAsEmptyList(ignoredVMs)
         self.benchmarkCompilationRate = benchmarkCompilationRate
         if benchmarkCompilationRate:
             self.vmOpts = self.vmOpts + ['-XX:+CITime']
-        
+
     def __str__(self):
         return self.name
-    
-    def test(self, vm, cwd=None, extraVmOpts=[], vmbuild=None):
+
+    def test(self, vm, cwd=None, extraVmOpts=None, vmbuild=None):
         """
         Run this program as a sanity test.
         """
@@ -319,27 +328,27 @@
         parser = OutputParser()
         jvmError = re.compile(r"(?P<jvmerror>([A-Z]:|/).*[/\\]hs_err_pid[0-9]+\.log)")
         parser.addMatcher(ValuesMatcher(jvmError, {'jvmError' : '<jvmerror>'}))
-        
+
         for successRE in self.successREs:
             parser.addMatcher(ValuesMatcher(successRE, {'passed' : '1'}))
         for failureRE in self.failureREs:
             parser.addMatcher(ValuesMatcher(failureRE, {'failed' : '1'}))
 
         tee = Tee()
-        retcode = commands.vm(self.vmOpts + extraVmOpts + self.cmd, vm, nonZeroIsFatal=False, out=tee.eat, err=subprocess.STDOUT, cwd=cwd, vmbuild=vmbuild)
+        retcode = commands.vm(self.vmOpts + _noneAsEmptyList(extraVmOpts) + self.cmd, vm, nonZeroIsFatal=False, out=tee.eat, err=subprocess.STDOUT, cwd=cwd, vmbuild=vmbuild)
         output = tee.output.getvalue()
         valueMaps = parser.parse(output)
 
         if len(valueMaps) == 0:
             return False
-        
+
         record = {}
         for valueMap in valueMaps:
             for key, value in valueMap.items():
                 if record.has_key(key) and record[key] != value:
                     mx.abort('Inconsistant values returned by test machers : ' + str(valueMaps))
                 record[key] = value
-        
+
         jvmErrorFile = record.get('jvmError')
         if jvmErrorFile:
             mx.log('/!\\JVM Error : dumping error log...')
@@ -347,13 +356,13 @@
                 mx.log(fp.read())
             os.unlink(jvmErrorFile)
             return False
-        
+
         if record.get('failed') == '1':
             return False
-        
+
         return retcode == 0 and record.get('passed') == '1'
-    
-    def bench(self, vm, cwd=None, extraVmOpts=[], vmbuild=None):
+
+    def bench(self, vm, cwd=None, extraVmOpts=None, vmbuild=None):
         """
         Run this program as a benchmark.
         """
@@ -362,7 +371,7 @@
         if cwd is None:
             cwd = self.defaultCwd
         parser = OutputParser()
-        
+
         for successRE in self.successREs:
             parser.addMatcher(ValuesMatcher(successRE, {'passed' : '1'}))
         for failureRE in self.failureREs:
@@ -379,10 +388,10 @@
             else:
                 ibps = re.compile(r"(?P<compiler>[\w]+) compilation speed: +(?P<rate>[0-9]+) bytes/s {standard")
                 parser.addMatcher(ValuesMatcher(ibps, {'group' : 'InlinedBytecodesPerSecond', 'name' : '<compiler>:' + self.name, 'score' : '<rate>'}))
-            
+
         startDelim = 'START: ' + self.name
         endDelim = 'END: ' + self.name
-        
+
         outputfile = os.environ.get('BENCH_OUTPUT', None)
         if outputfile:
             # Used only to debug output parsing
@@ -399,7 +408,7 @@
         else:
             tee = Tee()
             mx.log(startDelim)
-            if commands.vm(self.vmOpts + extraVmOpts + self.cmd, vm, nonZeroIsFatal=False, out=tee.eat, err=subprocess.STDOUT, cwd=cwd, vmbuild=vmbuild) != 0:
+            if commands.vm(self.vmOpts + _noneAsEmptyList(extraVmOpts) + self.cmd, vm, nonZeroIsFatal=False, out=tee.eat, err=subprocess.STDOUT, cwd=cwd, vmbuild=vmbuild) != 0:
                 mx.abort("Benchmark failed (non-zero retcode)")
             mx.log(endDelim)
             output = tee.output.getvalue()
@@ -419,8 +428,8 @@
                 score = valueMap.get('score')
                 if name and score:
                     group[name] = score
-        
+
         if not passed:
             mx.abort("Benchmark failed (not passed)")
-        
+
         return groups
--- a/mxtool/mx.py	Fri Sep 06 16:17:01 2013 +0200
+++ b/mxtool/mx.py	Fri Sep 06 16:17:16 2013 +0200
@@ -125,7 +125,7 @@
     javaCompliance
         The minimum JDK version (format: x.y) to which the project's
         sources comply (required for non-native projects).
-    
+
     workingSets
         A comma separated list of working set names. The project belongs
         to the given working sets, for which the eclipseinit command
@@ -146,8 +146,6 @@
 from argparse import ArgumentParser, REMAINDER
 from os.path import join, basename, dirname, exists, getmtime, isabs, expandvars, isdir, isfile
 
-DEFAULT_JAVA_ARGS = '-ea -Xss2m -Xmx1g'
-
 _projects = dict()
 _libs = dict()
 _dists = dict()
@@ -169,17 +167,17 @@
             self.path = join(suite.dir, self.path)
         self.deps = deps
         self.update_listeners = set()
-        
+
     def __str__(self):
         return self.name
-    
+
     def add_update_listener(self, listener):
         self.update_listeners.add(listener)
-        
+
     def notify_updated(self):
         for l in self.update_listeners:
             l(self)
-    
+
 """
 A dependency is a library or project specified in a suite.
 """
@@ -202,7 +200,7 @@
 
     def isLibrary(self):
         return isinstance(self, Library)
-    
+
     def isProject(self):
         return isinstance(self, Project)
 
@@ -216,7 +214,7 @@
         self.native = False
         self.workingSets = workingSets
         self.dir = d
-        
+
         # Create directories for projects that don't yet exist
         if not exists(d):
             os.mkdir(d)
@@ -244,7 +242,7 @@
         return deps
 
     def _compute_max_dep_distances(self, name, distances, dist):
-        currentDist = distances.get(name);
+        currentDist = distances.get(name)
         if currentDist is None or currentDist < dist:
             distances[name] = dist
             p = project(name, False)
@@ -260,14 +258,14 @@
         distances = dict()
         result = set()
         self._compute_max_dep_distances(self.name, distances, 0)
-        for n,d in distances.iteritems():
+        for n, d in distances.iteritems():
             assert d > 0 or n == self.name
             if d == 1:
                 result.add(n)
 
         if len(result) == len(self.deps) and frozenset(self.deps) == result:
             return self.deps
-        return result;
+        return result
 
     def max_depth(self):
         """
@@ -275,7 +273,7 @@
         """
         distances = dict()
         self._compute_max_dep_distances(self.name, distances, 0)
-        return max(distances.values())        
+        return max(distances.values())
 
     def source_dirs(self):
         """
@@ -337,23 +335,23 @@
                                     matchFound = True
                                 if pkg and matchFound:
                                     break
-                                        
+
                         if matchFound:
-                            basename = name[:-len('.java')]
+                            simpleClassName = name[:-len('.java')]
                             assert pkg is not None
                             if pkgRoot is None or pkg.startswith(pkgRoot):
                                 pkgOutputDir = join(outputDir, pkg.replace('.', os.path.sep))
                                 if exists(pkgOutputDir):
                                     for e in os.listdir(pkgOutputDir):
                                         if includeInnerClasses:
-                                            if e.endswith('.class') and (e.startswith(basename) or e.startswith(basename + '$')):
+                                            if e.endswith('.class') and (e.startswith(simpleClassName) or e.startswith(simpleClassName + '$')):
                                                 className = pkg + '.' + e[:-len('.class')]
                                                 result[className] = source
-                                        elif e == basename + '.class':
-                                            className = pkg + '.' + basename
+                                        elif e == simpleClassName + '.class':
+                                            className = pkg + '.' + simpleClassName
                                             result[className] = source
         return result
-    
+
     def _init_packages_and_imports(self):
         if not hasattr(self, '_defined_java_packages'):
             packages = set()
@@ -367,21 +365,21 @@
                 for root, _, files in os.walk(sourceDir):
                     javaSources = [name for name in files if name.endswith('.java')]
                     if len(javaSources) != 0:
-                        pkg = root[len(sourceDir) + 1:].replace(os.sep,'.')
+                        pkg = root[len(sourceDir) + 1:].replace(os.sep, '.')
                         if not pkg in depPackages:
                             packages.add(pkg)
                         else:
                             # A project extends a package already defined by one of it dependencies
                             extendedPackages.add(pkg)
                             imports.add(pkg)
-                        
+
                         for n in javaSources:
                             with open(join(root, n)) as fp:
                                 content = fp.read()
                                 imports.update(importRe.findall(content))
             self._defined_java_packages = frozenset(packages)
             self._extended_java_packages = frozenset(extendedPackages)
-            
+
             importedPackages = set()
             for imp in imports:
                 name = imp
@@ -394,12 +392,12 @@
                 if name is not None:
                     importedPackages.add(name)
             self._imported_java_packages = frozenset(importedPackages)
-    
+
     def defined_java_packages(self):
         """Get the immutable set of Java packages defined by the Java sources of this project"""
         self._init_packages_and_imports()
         return self._defined_java_packages
-    
+
     def extended_java_packages(self):
         """Get the immutable set of Java packages extended by the Java sources of this project"""
         self._init_packages_and_imports()
@@ -417,7 +415,7 @@
             if hasattr(self, '_declaredAnnotationProcessors'):
                 ap = set(self._declaredAnnotationProcessors)
 
-            # find dependencies that auto-inject themselves as annotation processors to all dependents                
+            # find dependencies that auto-inject themselves as annotation processors to all dependents
             allDeps = self.all_deps([], includeLibs=False, includeSelf=False, includeAnnotationProcessors=False)
             for p in allDeps:
                 if hasattr(p, 'annotationProcessorForDependents') and p.annotationProcessorForDependents.lower() == 'true':
@@ -442,7 +440,7 @@
         if not isabs(path):
             path = join(self.suite.dir, path)
         if resolve and self.mustExist and not exists(path):
-            assert not len(self.urls) == 0, 'cannot find required library ' + self.name + ' ' + path;
+            assert not len(self.urls) == 0, 'cannot find required library ' + self.name + ' ' + path
             print('Downloading ' + self.name + ' from ' + str(self.urls))
             download(path, self.urls)
         return path
@@ -462,7 +460,7 @@
         path = self.get_path(resolve)
         if exists(path) or not resolve:
             cp.append(path)
-            
+
     def all_deps(self, deps, includeLibs, includeSelf=True, includeAnnotationProcessors=False):
         if not includeLibs or not includeSelf:
             return deps
@@ -482,11 +480,11 @@
         self._load_env(mxDir)
         self._load_commands(mxDir)
         self._load_includes(mxDir)
-        self.name = d # re-initialized in _load_projects
+        self.name = d  # re-initialized in _load_projects
 
     def __str__(self):
         return self.name
-    
+
     def _load_projects(self, mxDir):
         libsMap = dict()
         projsMap = dict()
@@ -536,7 +534,7 @@
             srcDirs = pop_list(attrs, 'sourceDirs')
             deps = pop_list(attrs, 'dependencies')
             ap = pop_list(attrs, 'annotationProcessors')
-            #deps += ap
+            # deps += ap
             javaCompliance = attrs.pop('javaCompliance', None)
             subDir = attrs.pop('subDir', None)
             if subDir is None:
@@ -570,17 +568,17 @@
             d = Distribution(self, name, path, deps)
             d.__dict__.update(attrs)
             self.dists.append(d)
-            
+
         if self.name is None:
             abort('Missing "suite=<name>" in ' + projectsFile)
 
     def _load_commands(self, mxDir):
-        commands = join(mxDir, 'commands.py')
-        if exists(commands):
+        commandsPath = join(mxDir, 'commands.py')
+        if exists(commandsPath):
             # temporarily extend the Python path
             sys.path.insert(0, mxDir)
             mod = __import__('commands')
-            
+
             self.commands = sys.modules.pop('commands')
             sys.modules[join(mxDir, 'commands')] = self.commands
 
@@ -588,7 +586,7 @@
             del sys.path[0]
 
             if not hasattr(mod, 'mx_init'):
-                abort(commands + ' must define an mx_init(env) function')
+                abort(commandsPath + ' must define an mx_init(env) function')
             if hasattr(mod, 'mx_post_parse_cmd_line'):
                 self.mx_post_parse_cmd_line = mod.mx_post_parse_cmd_line
 
@@ -632,7 +630,7 @@
                 abort('cannot redefine library  ' + l.name)
             _libs[l.name] = l
         for d in self.dists:
-            existing = _dists.get(l.name)
+            existing = _dists.get(d.name)
             if existing is not None:
                 abort('cannot redefine distribution  ' + d.name)
             _dists[d.name] = d
@@ -641,7 +639,7 @@
 
 class XMLElement(xml.dom.minidom.Element):
     def writexml(self, writer, indent="", addindent="", newl=""):
-        writer.write(indent+"<" + self.tagName)
+        writer.write(indent + "<" + self.tagName)
 
         attrs = self._get_attributes()
         a_names = attrs.keys()
@@ -657,14 +655,14 @@
                 # text is printed without any indentation or new line padding
                 writer.write(">")
                 self.childNodes[0].writexml(writer)
-                writer.write("</%s>%s" % (self.tagName,newl))
+                writer.write("</%s>%s" % (self.tagName, newl))
             else:
-                writer.write(">%s"%(newl))
+                writer.write(">%s" % (newl))
                 for node in self.childNodes:
-                    node.writexml(writer,indent+addindent,addindent,newl)
-                writer.write("%s</%s>%s" % (indent,self.tagName,newl))
+                    node.writexml(writer, indent + addindent, addindent, newl)
+                writer.write("%s</%s>%s" % (indent, self.tagName, newl))
         else:
-            writer.write("/>%s"%(newl))
+            writer.write("/>%s" % (newl))
 
 class XMLDoc(xml.dom.minidom.Document):
 
@@ -682,7 +680,9 @@
     def comment(self, txt):
         self.current.appendChild(self.createComment(txt))
 
-    def open(self, tag, attributes={}, data=None):
+    def open(self, tag, attributes=None, data=None):
+        if attributes is None:
+            attributes = {}
         element = self.createElement(tag)
         for key, value in attributes.items():
             element.setAttribute(key, value)
@@ -698,7 +698,9 @@
         self.current = self.current.parentNode
         return self
 
-    def element(self, tag, attributes={}, data=None):
+    def element(self, tag, attributes=None, data=None):
+        if attributes is None:
+            attributes = {}
         return self.open(tag, attributes, data).close(tag)
 
     def xml(self, indent='', newl='', escape=False, standalone=None):
@@ -888,7 +890,7 @@
 def _handle_missing_java_home():
     if not sys.stdout.isatty():
         abort('Could not find bootstrap JDK. Use --java-home option or ensure JAVA_HOME environment variable is set.')
- 
+
     candidateJdks = []
     if get_os() == 'darwin':
         base = '/Library/Java/JavaVirtualMachines'
@@ -908,7 +910,7 @@
         javaHome = select_items(candidateJdks + ['<other>'], allowMultiple=False)
         if javaHome == '<other>':
             javaHome = None
-            
+
     while javaHome is None:
         javaHome = raw_input('Enter path of bootstrap JDK: ')
         rtJarPath = join(javaHome, 'jre', 'lib', 'rt.jar')
@@ -917,13 +919,12 @@
             javaHome = None
         else:
             break
-    
+
     envPath = join(_mainSuite.dir, 'mx', 'env')
-    answer = raw_input('Persist this setting by adding "JAVA_HOME=' + javaHome + '" to ' + envPath + '? [Yn]: ')
-    if not answer.lower().startswith('n'):
+    if ask_yes_no('Persist this setting by adding "JAVA_HOME=' + javaHome + '" to ' + envPath, 'y'):
         with open(envPath, 'a') as fp:
             print >> fp, 'JAVA_HOME=' + javaHome
-            
+
     return javaHome
 
 class ArgParser(ArgumentParser):
@@ -943,7 +944,7 @@
         self.add_argument('-d', action='store_const', const=8000, dest='java_dbg_port', help='alias for "-dbg 8000"')
         self.add_argument('--cp-pfx', dest='cp_prefix', help='class path prefix', metavar='<arg>')
         self.add_argument('--cp-sfx', dest='cp_suffix', help='class path suffix', metavar='<arg>')
-        self.add_argument('--J', dest='java_args', help='Java VM arguments (e.g. --J @-dsa)', metavar='@<args>', default=DEFAULT_JAVA_ARGS)
+        self.add_argument('--J', dest='java_args', help='Java VM arguments (e.g. --J @-dsa)', metavar='@<args>', default='-ea -Xss2m -Xmx1g')
         self.add_argument('--Jp', action='append', dest='java_args_pfx', help='prefix Java VM arguments (e.g. --Jp @-dsa)', metavar='@<args>', default=[])
         self.add_argument('--Ja', action='append', dest='java_args_sfx', help='suffix Java VM arguments (e.g. --Ja @-dsa)', metavar='@<args>', default=[])
         self.add_argument('--user-home', help='users home directory', metavar='<path>', default=os.path.expanduser('~'))
@@ -988,8 +989,8 @@
 
 def _format_commands():
     msg = '\navailable commands:\n\n'
-    for cmd in sorted(commands.iterkeys()):
-        c, _ = commands[cmd][:2]
+    for cmd in sorted(_commands.iterkeys()):
+        c, _ = _commands[cmd][:2]
         doc = c.__doc__
         if doc is None:
             doc = ''
@@ -1076,7 +1077,7 @@
 
     if env is None:
         env = os.environ
-        
+
     if _opts.verbose:
         if _opts.very_verbose:
             log('Environment variables:')
@@ -1109,17 +1110,17 @@
                 for line in iter(stream.readline, ''):
                     f(line)
                 stream.close()
-            stdout=out if not callable(out) else subprocess.PIPE
-            stderr=err if not callable(err) else subprocess.PIPE
+            stdout = out if not callable(out) else subprocess.PIPE
+            stderr = err if not callable(err) else subprocess.PIPE
             p = subprocess.Popen(args, cwd=cwd, stdout=stdout, stderr=stderr, preexec_fn=preexec_fn, creationflags=creationflags, env=env)
             _currentSubprocess = (p, args)
             if callable(out):
                 t = Thread(target=redirect, args=(p.stdout, out))
-                t.daemon = True # thread dies with the program
+                t.daemon = True  # thread dies with the program
                 t.start()
             if callable(err):
                 t = Thread(target=redirect, args=(p.stderr, err))
-                t.daemon = True # thread dies with the program
+                t.daemon = True  # thread dies with the program
                 t.start()
             if timeout is None or timeout == 0:
                 retcode = waitOn(p)
@@ -1142,7 +1143,7 @@
             if _opts.very_verbose:
                 raise subprocess.CalledProcessError(retcode, ' '.join(args))
             else:
-                log('[exit code: ' + str(retcode)+ ']')
+                log('[exit code: ' + str(retcode) + ']')
         abort(retcode)
 
     return retcode
@@ -1159,7 +1160,7 @@
     """
     Adds the platform specific library prefix to a name
     """
-    os = get_os();
+    os = get_os()
     if os == 'linux' or os == 'solaris' or os == 'darwin':
         return 'lib' + name
     return name
@@ -1168,7 +1169,7 @@
     """
     Adds the platform specific library suffix to a name
     """
-    os = get_os();
+    os = get_os()
     if os == 'windows':
         return name + '.dll'
     if os == 'linux' or os == 'solaris':
@@ -1182,7 +1183,7 @@
 """
 class JavaCompliance:
     def __init__(self, ver):
-        m = re.match('1\.(\d+).*', ver)
+        m = re.match(r'1\.(\d+).*', ver)
         assert m is not None, 'not a recognized version string: ' + ver
         self.value = int(m.group(1))
 
@@ -1194,22 +1195,22 @@
             other = JavaCompliance(other)
 
         return cmp(self.value, other.value)
-    
+
 """
 A Java version as defined in JSR-56
 """
 class JavaVersion:
     def __init__(self, versionString):
-        validChar = '[\x21-\x25\x27-\x29\x2c\x2f-\x5e\x60-\x7f]'
-        separator = '[.\-_]'
+        validChar = r'[\x21-\x25\x27-\x29\x2c\x2f-\x5e\x60-\x7f]'
+        separator = r'[.\-_]'
         m = re.match(validChar + '+(' + separator + validChar + '+)*', versionString)
         assert m is not None, 'not a recognized version string: ' + versionString
-        self.versionString = versionString;
+        self.versionString = versionString
         self.parts = [int(f) if f.isdigit() else f for f in re.split(separator, versionString)]
-        
+
     def __str__(self):
         return self.versionString
-    
+
     def __cmp__(self, other):
         return cmp(self.parts, other.parts)
 
@@ -1220,8 +1221,8 @@
     def __init__(self, opts):
         self.jdk = opts.java_home
         self.debug_port = opts.java_dbg_port
-        self.jar   = exe_suffix(join(self.jdk, 'bin', 'jar'))
-        self.java  = exe_suffix(join(self.jdk, 'bin', 'java'))
+        self.jar = exe_suffix(join(self.jdk, 'bin', 'jar'))
+        self.java = exe_suffix(join(self.jdk, 'bin', 'java'))
         self.javac = exe_suffix(join(self.jdk, 'bin', 'javac'))
         self.javap = exe_suffix(join(self.jdk, 'bin', 'javap'))
         self.javadoc = exe_suffix(join(self.jdk, 'bin', 'javadoc'))
@@ -1299,7 +1300,7 @@
 def logv(msg=None):
     if _opts.verbose:
         log(msg)
-    
+
 def log(msg=None):
     """
     Write a message to the console.
@@ -1333,16 +1334,16 @@
         try:
             output = subprocess.check_output([a, '--version'])
             if 'GNU' in output:
-                return a;
+                return a
         except:
             pass
     abort('Could not find a GNU make executable on the current path.')
 
 def expandvars_in_property(value):
-        result = expandvars(value)
-        if '$' in result or '%' in result:
-            abort('Property contains an undefined environment variable: ' + value)
-        return result
+    result = expandvars(value)
+    if '$' in result or '%' in result:
+        abort('Property contains an undefined environment variable: ' + value)
+    return result
 
 
 def abort(codeOrMessage):
@@ -1353,8 +1354,8 @@
     the object's value is printed and the exit status is one.
     """
 
-    #import traceback
-    #traceback.print_stack()
+    # import traceback
+    # traceback.print_stack()
     currentSubprocess = _currentSubprocess
     if currentSubprocess is not None:
         p, _ = currentSubprocess
@@ -1362,7 +1363,7 @@
             p.kill()
         else:
             _kill_process_group(p.pid)
-    
+
     raise SystemExit(codeOrMessage)
 
 def download(path, urls, verbose=False):
@@ -1452,9 +1453,9 @@
             f.write(content)
 
         log(('modified ' if existed else 'created ') + path)
-        return True;
+        return True
     except IOError as e:
-        abort('Error while writing to ' + path + ': ' + str(e));
+        abort('Error while writing to ' + path + ': ' + str(e))
 
 # Builtin commands
 
@@ -1488,11 +1489,11 @@
         parser.add_argument('remainder', nargs=REMAINDER, metavar='...')
 
     args = parser.parse_args(args)
-    
+
     jdtJar = None
     if args.jdt is not None:
         if args.jdt.endswith('.jar'):
-            jdtJar=args.jdt
+            jdtJar = args.jdt
             if not exists(jdtJar) and os.path.abspath(jdtJar) == os.path.abspath(defaultEcjPath):
                 # Silently ignore JDT if default location is used but not ecj.jar exists there
                 jdtJar = None
@@ -1507,7 +1508,7 @@
         sortedProjects = [project(name) for name in args.only.split(',')]
     else:
         sortedProjects = sorted_deps(projects, includeAnnotationProcessors=True)
-    
+
     for p in sortedProjects:
         if p.native:
             if args.native:
@@ -1522,7 +1523,7 @@
         else:
             if not args.java:
                 continue
-            if exists(join(p.dir, 'plugin.xml')): # eclipse plugin project
+            if exists(join(p.dir, 'plugin.xml')):  # eclipse plugin project
                 continue
 
         # skip building this Java project if its Java compliance level is "higher" than the configured JDK
@@ -1621,11 +1622,11 @@
         ap = p.annotation_processors()
         if len(ap) > 0:
             processorPath = classpath(ap, resolve=True)
-            genDir = p.source_gen_dir();
+            genDir = p.source_gen_dir()
             if exists(genDir):
                 shutil.rmtree(genDir)
             os.mkdir(genDir)
-            processorArgs += ['-processorpath', join(processorPath), '-s', genDir] 
+            processorArgs += ['-processorpath', join(processorPath), '-s', genDir]
         else:
             processorArgs += ['-proc:none']
 
@@ -1634,20 +1635,20 @@
             compliance = str(p.javaCompliance) if p.javaCompliance is not None else args.compliance
             if jdtJar is None:
                 log('Compiling Java sources for {0} with javac...'.format(p.name))
-                
-                
+
+
                 javacCmd = [java().javac, '-g', '-J-Xmx1g', '-source', compliance, '-classpath', cp, '-d', outputDir]
                 if java().debug_port is not None:
                     javacCmd += ['-J-Xdebug', '-J-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=' + str(java().debug_port)]
                 javacCmd += processorArgs
                 javacCmd += ['@' + argfile.name]
-                
+
                 if not args.warnAPI:
                     javacCmd.append('-XDignore.symbol.file')
                 run(javacCmd)
             else:
                 log('Compiling Java sources for {0} with JDT...'.format(p.name))
-                                
+
                 jdtArgs = [java().java, '-Xmx1g']
                 if java().debug_port is not None:
                     jdtArgs += ['-Xdebug', '-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=' + str(java().debug_port)]
@@ -1657,8 +1658,8 @@
                          '-cp', cp, '-g', '-enableJavadoc',
                          '-d', outputDir]
                 jdtArgs += processorArgs
-                         
-                         
+
+
                 jdtProperties = join(p.dir, '.settings', 'org.eclipse.jdt.core.prefs')
                 rootJdtProperties = join(p.suite.dir, 'mx', 'eclipse-settings', 'org.eclipse.jdt.core.prefs')
                 if not exists(jdtProperties) or os.path.getmtime(jdtProperties) < os.path.getmtime(rootJdtProperties):
@@ -1679,12 +1680,12 @@
                     else:
                         jdtArgs += ['-properties', jdtProperties]
                 jdtArgs.append('@' + argfile.name)
-                
+
                 run(jdtArgs)
         finally:
             for n in toBeDeleted:
                 os.remove(n)
-                
+
     for dist in _dists.values():
         archive(['@' + dist.name])
 
@@ -1701,17 +1702,17 @@
     parser.add_argument('-e', '--eclipse-exe', help='location of the Eclipse executable')
     parser.add_argument('-C', '--no-backup', action='store_false', dest='backup', help='do not save backup of modified files')
     parser.add_argument('--projects', action='store', help='comma separated projects to process (omit to process all projects)')
-    
+
     args = parser.parse_args(args)
     if args.eclipse_exe is None:
         args.eclipse_exe = os.environ.get('ECLIPSE_EXE')
     if args.eclipse_exe is None:
         abort('Could not find Eclipse executable. Use -e option or ensure ECLIPSE_EXE environment variable is set.')
-        
+
     # Maybe an Eclipse installation dir was specified - look for the executable in it
     if join(args.eclipse_exe, exe_suffix('eclipse')):
         args.eclipse_exe = join(args.eclipse_exe, exe_suffix('eclipse'))
-        
+
     if not os.path.isfile(args.eclipse_exe) or not os.access(args.eclipse_exe, os.X_OK):
         abort('Not an executable file: ' + args.eclipse_exe)
 
@@ -1726,7 +1727,7 @@
         def __init__(self, settingsFile):
             self.path = settingsFile
             self.javafiles = list()
-            
+
         def settings(self):
             with open(self.path) as fp:
                 return fp.read()
@@ -1745,14 +1746,14 @@
                     self.content = content
                     return True
             os.utime(self.path, self.times)
-            
+
     modified = list()
-    batches = dict() # all sources with the same formatting settings are formatted together
+    batches = dict()  # all sources with the same formatting settings are formatted together
     for p in projects:
         if p.native:
             continue
         sourceDirs = p.source_dirs()
-        
+
         batch = Batch(join(p.dir, '.settings', 'org.eclipse.jdt.core.prefs'))
 
         if not exists(batch.path):
@@ -1777,7 +1778,7 @@
         for fi in batch.javafiles:
             if fi.update():
                 modified.append(fi)
-                
+
     log('{0} files were modified'.format(len(modified)))
     if len(modified) != 0:
         if args.backup:
@@ -1793,25 +1794,25 @@
     return 0
 
 def processorjars():
-    
+
     projs = set()
     for p in sorted_deps():
         if _isAnnotationProcessorDependency(p):
             projs.add(p)
-            
+
     if len(projs) < 0:
         return
-    
+
     pnames = [p.name for p in projs]
     build(['--projects', ",".join(pnames)])
     archive(pnames)
 
 def archive(args):
     """create jar files for projects and distributions"""
-    parser = ArgumentParser(prog='mx archive');
+    parser = ArgumentParser(prog='mx archive')
     parser.add_argument('names', nargs=REMAINDER, metavar='[<project>|@<distribution>]...')
     args = parser.parse_args(args)
-    
+
     for name in args.names:
         if name.startswith('@'):
             dname = name[1:]
@@ -1822,7 +1823,7 @@
             def overwriteCheck(zf, arcname, source):
                 if arcname in zf.namelist():
                     log('warning: ' + d.path + ': overwriting ' + arcname + ' [source: ' + source + ']')
-                
+
             try:
                 zf = zipfile.ZipFile(tmp, 'w')
                 for dep in sorted_deps(d.deps, includeLibs=True):
@@ -1847,7 +1848,7 @@
                         if java().javaCompliance < p.javaCompliance:
                             log('Excluding {0} from {2} (Java compliance level {1} required)'.format(p.name, p.javaCompliance, d.path))
                             continue
-    
+
                         logv('[' + d.path + ': adding project ' + p.name + ']')
                         outputDir = p.output_dir()
                         for root, _, files in os.walk(outputDir):
@@ -1877,7 +1878,7 @@
                 shutil.rmtree(services)
                 # Atomic on Unix
                 shutil.move(tmp, d.path)
-                #print time.time(), 'move:', tmp, '->', d.path
+                # print time.time(), 'move:', tmp, '->', d.path
                 d.notify_updated()
             finally:
                 if exists(tmp):
@@ -1925,11 +1926,11 @@
                     out.write(line + '\n')
                 else:
                     p = project(m.group(1))
-                    
+
                     for pkg in p.defined_java_packages():
                         if not pkg.startswith(p.name):
                             abort('package in {0} does not have prefix matching project name: {1}'.format(p, pkg))
-                    
+
                     ignoredDeps = set([name for name in p.deps if project(name, False) is not None])
                     for pkg in p.imported_java_packages():
                         for name in p.deps:
@@ -1942,7 +1943,7 @@
                                 if pkg in dep.extended_java_packages():
                                     ignoredDeps.discard(name)
                     if len(ignoredDeps) != 0:
-                        candidates = set();
+                        candidates = set()
                         # Compute dependencies based on projects required by p
                         for d in sorted_deps():
                             if not d.defined_java_packages().isdisjoint(p.imported_java_packages()):
@@ -1951,16 +1952,16 @@
                         for c in list(candidates):
                             candidates.difference_update(c.all_deps([], False, False))
                         candidates = [d.name for d in candidates]
-                        
+
                         abort('{0}:{1}: {2} does not use any packages defined in these projects: {3}\nComputed project dependencies: {4}'.format(
                             projectsFile, lineNo, p, ', '.join(ignoredDeps), ','.join(candidates)))
-                    
+
                     out.write('project@' + m.group(1) + '@dependencies=' + ','.join(p.canonical_deps()) + '\n')
                 lineNo = lineNo + 1
             content = out.getvalue()
         if update_file(projectsFile, content):
             changedFiles += 1
-    return changedFiles;
+    return changedFiles
 
 def checkstyle(args):
     """run Checkstyle on the Java sources
@@ -1972,7 +1973,7 @@
 
     parser.add_argument('-f', action='store_true', dest='force', help='force checking (disables timestamp checking)')
     args = parser.parse_args(args)
-    
+
     totalErrors = 0
     for p in sorted_deps():
         if p.native:
@@ -1982,7 +1983,7 @@
 
         if not exists(dotCheckstyle):
             continue
-        
+
         # skip checking this Java project if its Java compliance level is "higher" than the configured JDK
         if java().javaCompliance < p.javaCompliance:
             log('Excluding {0} from checking (Java compliance level {1} required)'.format(p.name, p.javaCompliance))
@@ -2075,13 +2076,12 @@
                     finally:
                         if exists(auditfileName):
                             errors = []
-                            source = None
+                            source = [None]
                             def start_element(name, attrs):
                                 if name == 'file':
-                                    global source
-                                    source = attrs['name']
+                                    source[0] = attrs['name']
                                 elif name == 'error':
-                                    errors.append('{}:{}: {}'.format(source, attrs['line'], attrs['message']))
+                                    errors.append('{}:{}: {}'.format(source[0], attrs['line'], attrs['message']))
 
                             p = xml.parsers.expat.ParserCreate()
                             p.StartElementHandler = start_element
@@ -2109,7 +2109,7 @@
 
     suppliedParser = parser is not None
 
-    parser = parser if suppliedParser else ArgumentParser(prog='mx build');
+    parser = parser if suppliedParser else ArgumentParser(prog='mx build')
     parser.add_argument('--no-native', action='store_false', dest='native', help='do not clean native projects')
     parser.add_argument('--no-java', action='store_false', dest='java', help='do not clean Java projects')
 
@@ -2121,13 +2121,13 @@
                 run([gmake_cmd(), '-C', p.dir, 'clean'])
         else:
             if args.java:
-                genDir = p.source_gen_dir();
+                genDir = p.source_gen_dir()
                 if genDir != '' and exists(genDir):
                     log('Clearing {0}...'.format(genDir))
                     for f in os.listdir(genDir):
                         shutil.rmtree(join(genDir, f))
-                    
-                    
+
+
                 outputDir = p.output_dir()
                 if outputDir != '' and exists(outputDir):
                     log('Removing {0}...'.format(outputDir))
@@ -2151,8 +2151,8 @@
         return
 
     name = args[0]
-    if not commands.has_key(name):
-        hits = [c for c in commands.iterkeys() if c.startswith(name)]
+    if not _commands.has_key(name):
+        hits = [c for c in _commands.iterkeys() if c.startswith(name)]
         if len(hits) == 1:
             name = hits[0]
         elif len(hits) == 0:
@@ -2160,7 +2160,7 @@
         else:
             abort('mx: command \'{0}\' is ambiguous\n    {1}'.format(name, ' '.join(hits)))
 
-    value = commands[name]
+    value = _commands[name]
     (func, usage) = value[:2]
     doc = func.__doc__
     if len(value) > 2:
@@ -2207,10 +2207,12 @@
     slm.close('sourceLookupDirector')
     return slm
 
-def make_eclipse_attach(hostname, port, name=None, deps=[]):
+def make_eclipse_attach(hostname, port, name=None, deps=None):
     """
     Creates an Eclipse launch configuration file for attaching to a Java process.
     """
+    if deps is None:
+        deps = []
     slm = _source_locator_memento(deps)
     launch = XMLDoc()
     launch.open('launchConfiguration', {'type' : 'org.eclipse.jdt.launching.remoteJavaApplication'})
@@ -2233,10 +2235,12 @@
         os.makedirs(eclipseLaunches)
     return update_file(join(eclipseLaunches, name + '.launch'), launch)
 
-def make_eclipse_launch(javaArgs, jre, name=None, deps=[]):
+def make_eclipse_launch(javaArgs, jre, name=None, deps=None):
     """
     Creates an Eclipse launch configuration file for running/debugging a Java command.
     """
+    if deps is None:
+        deps = []
     mainClass = None
     vmArgs = []
     appArgs = []
@@ -2303,7 +2307,7 @@
 
     if suite is None:
         suite = _mainSuite
-        
+
     if buildProcessorJars:
         processorjars()
 
@@ -2330,7 +2334,7 @@
             out.element('classpathentry', {'kind' : 'src', 'path' : src})
 
         if len(p.annotation_processors()) > 0:
-            genDir = p.source_gen_dir();
+            genDir = p.source_gen_dir()
             if not exists(genDir):
                 os.mkdir(genDir)
             out.element('classpathentry', {'kind' : 'src', 'path' : 'src_gen'})
@@ -2338,12 +2342,12 @@
         # Every Java program depends on the JRE
         out.element('classpathentry', {'kind' : 'con', 'path' : 'org.eclipse.jdt.launching.JRE_CONTAINER'})
 
-        if exists(join(p.dir, 'plugin.xml')): # eclipse plugin project
+        if exists(join(p.dir, 'plugin.xml')):  # eclipse plugin project
             out.element('classpathentry', {'kind' : 'con', 'path' : 'org.eclipse.pde.core.requiredPlugins'})
 
         for dep in p.all_deps([], True):
             if dep == p:
-                continue;
+                continue
 
             if dep.isLibrary():
                 if hasattr(dep, 'eclipse.container'):
@@ -2420,7 +2424,7 @@
             out.element('name', data='net.sf.eclipsecs.core.CheckstyleBuilder')
             out.element('arguments', data='')
             out.close('buildCommand')
-        if exists(join(p.dir, 'plugin.xml')): # eclipse plugin project
+        if exists(join(p.dir, 'plugin.xml')):  # eclipse plugin project
             for buildCommand in ['org.eclipse.pde.ManifestBuilder', 'org.eclipse.pde.SchemaBuilder']:
                 out.open('buildCommand')
                 out.element('name', data=buildCommand)
@@ -2428,19 +2432,19 @@
                 out.close('buildCommand')
 
         if _isAnnotationProcessorDependency(p):
-            _genEclipseBuilder(out, p, 'Jar.launch', 'archive ' + p.name, refresh = False, async = False, xmlIndent='', xmlStandalone='no')
-            _genEclipseBuilder(out, p, 'Refresh.launch', '', refresh = True, async = True)
-                       
+            _genEclipseBuilder(out, p, 'Jar.launch', 'archive ' + p.name, refresh=False, async=False, xmlIndent='', xmlStandalone='no')
+            _genEclipseBuilder(out, p, 'Refresh.launch', '', refresh=True, async=True)
+
         if projToDist.has_key(p.name):
             dist, distDeps = projToDist[p.name]
             _genEclipseBuilder(out, p, 'Create' + dist.name + 'Dist.launch', 'archive @' + dist.name, refresh=False, async=True)
-        
+
         out.close('buildSpec')
         out.open('natures')
         out.element('nature', data='org.eclipse.jdt.core.javanature')
         if exists(csConfig):
             out.element('nature', data='net.sf.eclipsecs.core.CheckstyleNature')
-        if exists(join(p.dir, 'plugin.xml')): # eclipse plugin project
+        if exists(join(p.dir, 'plugin.xml')):  # eclipse plugin project
             out.element('nature', data='org.eclipse.pde.PluginNature')
         out.close('natures')
         out.close('projectDescription')
@@ -2463,7 +2467,7 @@
                     if len(p.annotation_processors()) > 0:
                         content = content.replace('org.eclipse.jdt.core.compiler.processAnnotations=disabled', 'org.eclipse.jdt.core.compiler.processAnnotations=enabled')
                     update_file(join(settingsDir, name), content)
-        
+
         if len(p.annotation_processors()) > 0:
             out = XMLDoc()
             out.open('factorypath')
@@ -2496,50 +2500,50 @@
     return p in sorted_deps(annotation_processors())
 
 def _genEclipseBuilder(dotProjectDoc, p, name, mxCommand, refresh=True, async=False, logToConsole=False, xmlIndent='\t', xmlStandalone=None):
-    launchOut = XMLDoc();
+    launchOut = XMLDoc()
     consoleOn = 'true' if logToConsole else 'false'
     launchOut.open('launchConfiguration', {'type' : 'org.eclipse.ui.externaltools.ProgramBuilderLaunchConfigurationType'})
-    launchOut.element('booleanAttribute', {'key' : 'org.eclipse.debug.core.capture_output',                'value': consoleOn})
+    launchOut.element('booleanAttribute', {'key' : 'org.eclipse.debug.core.capture_output', 'value': consoleOn})
     launchOut.open('mapAttribute', {'key' : 'org.eclipse.debug.core.environmentVariables'})
-    launchOut.element('mapEntry', {'key' : 'JAVA_HOME',	'value' : java().jdk})
+    launchOut.element('mapEntry', {'key' : 'JAVA_HOME', 	'value' : java().jdk})
     launchOut.close('mapAttribute')
-    
+
     if refresh:
-        launchOut.element('stringAttribute',  {'key' : 'org.eclipse.debug.core.ATTR_REFRESH_SCOPE',            'value': '${project}'})
-    launchOut.element('booleanAttribute', {'key' : 'org.eclipse.debug.ui.ATTR_CONSOLE_OUTPUT_ON',          'value': consoleOn})
-    launchOut.element('booleanAttribute', {'key' : 'org.eclipse.debug.ui.ATTR_LAUNCH_IN_BACKGROUND',       'value': 'true' if async else 'false'})
-    
+        launchOut.element('stringAttribute', {'key' : 'org.eclipse.debug.core.ATTR_REFRESH_SCOPE', 'value': '${project}'})
+    launchOut.element('booleanAttribute', {'key' : 'org.eclipse.debug.ui.ATTR_CONSOLE_OUTPUT_ON', 'value': consoleOn})
+    launchOut.element('booleanAttribute', {'key' : 'org.eclipse.debug.ui.ATTR_LAUNCH_IN_BACKGROUND', 'value': 'true' if async else 'false'})
+
     baseDir = dirname(dirname(os.path.abspath(__file__)))
-    
+
     cmd = 'mx.sh'
     if get_os() == 'windows':
         cmd = 'mx.cmd'
-    launchOut.element('stringAttribute',  {'key' : 'org.eclipse.ui.externaltools.ATTR_LOCATION',           'value': join(baseDir, cmd) })
-    launchOut.element('stringAttribute',  {'key' : 'org.eclipse.ui.externaltools.ATTR_RUN_BUILD_KINDS',    'value': 'auto,full,incremental'})
-    launchOut.element('stringAttribute',  {'key' : 'org.eclipse.ui.externaltools.ATTR_TOOL_ARGUMENTS',     'value': mxCommand})
-    launchOut.element('booleanAttribute', {'key' : 'org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED','value': 'true'})
-    launchOut.element('stringAttribute',  {'key' : 'org.eclipse.ui.externaltools.ATTR_WORKING_DIRECTORY',  'value': p.suite.dir})
-    
-    
+    launchOut.element('stringAttribute', {'key' : 'org.eclipse.ui.externaltools.ATTR_LOCATION', 'value': join(baseDir, cmd) })
+    launchOut.element('stringAttribute', {'key' : 'org.eclipse.ui.externaltools.ATTR_RUN_BUILD_KINDS', 'value': 'auto,full,incremental'})
+    launchOut.element('stringAttribute', {'key' : 'org.eclipse.ui.externaltools.ATTR_TOOL_ARGUMENTS', 'value': mxCommand})
+    launchOut.element('booleanAttribute', {'key' : 'org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED', 'value': 'true'})
+    launchOut.element('stringAttribute', {'key' : 'org.eclipse.ui.externaltools.ATTR_WORKING_DIRECTORY', 'value': p.suite.dir})
+
+
     launchOut.close('launchConfiguration')
-    
+
     externalToolDir = join(p.dir, '.externalToolBuilders')
-    
+
     if not exists(externalToolDir):
         os.makedirs(externalToolDir)
     update_file(join(externalToolDir, name), launchOut.xml(indent=xmlIndent, standalone=xmlStandalone, newl='\n'))
-    
+
     dotProjectDoc.open('buildCommand')
     dotProjectDoc.element('name', data='org.eclipse.ui.externaltools.ExternalToolBuilder')
     dotProjectDoc.element('triggers', data='auto,full,incremental,')
     dotProjectDoc.open('arguments')
     dotProjectDoc.open('dictionary')
-    dotProjectDoc.element('key', data = 'LaunchConfigHandle')
-    dotProjectDoc.element('value', data = '<project>/.externalToolBuilders/' + name)
+    dotProjectDoc.element('key', data='LaunchConfigHandle')
+    dotProjectDoc.element('value', data='<project>/.externalToolBuilders/' + name)
     dotProjectDoc.close('dictionary')
     dotProjectDoc.open('dictionary')
-    dotProjectDoc.element('key', data = 'incclean')
-    dotProjectDoc.element('value', data = 'true')
+    dotProjectDoc.element('key', data='incclean')
+    dotProjectDoc.element('value', data='true')
     dotProjectDoc.close('dictionary')
     dotProjectDoc.close('arguments')
     dotProjectDoc.close('buildCommand')
@@ -2549,9 +2553,9 @@
     Populate the workspace's working set configuration with working sets generated from project data.
     If the workspace already contains working set definitions, the existing ones will be retained and extended.
     In case mx/env does not contain a WORKSPACE definition pointing to the workspace root directory, the Graal project root directory will be assumed.
-    If no workspace root directory can be identified, the Graal project root directory is used and the user has to place the workingsets.xml file by hand. 
+    If no workspace root directory can be identified, the Graal project root directory is used and the user has to place the workingsets.xml file by hand.
     """
-    
+
     # identify the location where to look for workingsets.xml
     wsfilename = 'workingsets.xml'
     wsroot = suite.dir
@@ -2561,7 +2565,7 @@
     if not exists(wsdir):
         wsdir = wsroot
     wspath = join(wsdir, wsfilename)
-    
+
     # gather working set info from project data
     workingSets = dict()
     for p in projects():
@@ -2572,24 +2576,24 @@
                 workingSets[w] = [p.name]
             else:
                 workingSets[w].append(p.name)
-    
+
     if exists(wspath):
         wsdoc = _copy_workingset_xml(wspath, workingSets)
     else:
         wsdoc = _make_workingset_xml(workingSets)
-    
+
     update_file(wspath, wsdoc.xml(newl='\n'))
 
 def _make_workingset_xml(workingSets):
     wsdoc = XMLDoc()
     wsdoc.open('workingSetManager')
-    
+
     for w in sorted(workingSets.keys()):
         _workingset_open(wsdoc, w)
         for p in workingSets[w]:
             _workingset_element(wsdoc, p)
         wsdoc.close('workingSet')
-    
+
     wsdoc.close('workingSetManager')
     return wsdoc
 
@@ -2598,16 +2602,16 @@
     target.open('workingSetManager')
 
     parser = xml.parsers.expat.ParserCreate()
-    
+
     class ParserState(object):
         def __init__(self):
             self.current_ws_name = 'none yet'
             self.current_ws = None
             self.seen_ws = list()
             self.seen_projects = list()
-    
+
     ps = ParserState()
-    
+
     # parsing logic
     def _ws_start(name, attributes):
         if name == 'workingSet':
@@ -2620,7 +2624,7 @@
                 ps.current_ws = None
             target.open(name, attributes)
             parser.StartElementHandler = _ws_item
-    
+
     def _ws_end(name):
         if name == 'workingSet':
             if not ps.current_ws is None:
@@ -2637,22 +2641,22 @@
                     for p in workingSets[w]:
                         _workingset_element(target, p)
                     target.close('workingSet')
-    
+
     def _ws_item(name, attributes):
         if name == 'item':
             if ps.current_ws is None:
                 target.element(name, attributes)
             else:
-                p_name = attributes['elementID'][1:] # strip off the leading '='
+                p_name = attributes['elementID'][1:]  # strip off the leading '='
                 _workingset_element(target, p_name)
                 ps.seen_projects.append(p_name)
-    
+
     # process document
     parser.StartElementHandler = _ws_start
     parser.EndElementHandler = _ws_end
     with open(wspath, 'r') as wsfile:
         parser.ParseFile(wsfile)
-    
+
     target.close('workingSetManager')
     return target
 
@@ -2661,22 +2665,19 @@
 
 def _workingset_element(wsdoc, p):
     wsdoc.element('item', {'elementID': '=' + p, 'factoryID': 'org.eclipse.jdt.ui.PersistableJavaElementFactory'})
-    
+
 def netbeansinit(args, suite=None):
     """(re)generate NetBeans project configurations"""
 
     if suite is None:
         suite = _mainSuite
 
-    def println(out, obj):
-        out.write(str(obj) + '\n')
-
     updated = False
     for p in projects():
         if p.native:
             continue
 
-        if exists(join(p.dir, 'plugin.xml')): # eclipse plugin project
+        if exists(join(p.dir, 'plugin.xml')):  # eclipse plugin project
             continue
 
         if not exists(join(p.dir, 'nbproject')):
@@ -2716,7 +2717,7 @@
         firstDep = True
         for dep in p.all_deps([], True):
             if dep == p:
-                continue;
+                continue
 
             if not dep.isLibrary():
                 n = dep.name.replace('.', '_')
@@ -2835,7 +2836,7 @@
                 print >> out, 'src.' + src + '.dir=${' + ref + '}'
 
         javacClasspath = []
-        
+
         deps = p.all_deps([], True)
         annotationProcessorOnlyDeps = []
         if len(p.annotation_processors()) > 0:
@@ -2844,12 +2845,12 @@
                 if not apDep in deps:
                     deps.append(apDep)
                     annotationProcessorOnlyDeps.append(apDep)
-        
-        annotationProcessorReferences = [];
-        
+
+        annotationProcessorReferences = []
+
         for dep in deps:
             if dep == p:
-                continue;
+                continue
 
             if dep.isLibrary():
                 if not dep.mustExist:
@@ -2871,12 +2872,12 @@
                 javacClasspath.append('${' + ref + '}')
             else:
                 annotationProcessorReferences.append('${' + ref + '}')
-                annotationProcessorReferences +=  ":\\\n    ${" + ref + "}"
+                annotationProcessorReferences += ":\\\n    ${" + ref + "}"
 
         print >> out, 'javac.classpath=\\\n    ' + (os.pathsep + '\\\n    ').join(javacClasspath)
         print >> out, 'javac.test.processorpath=${javac.test.classpath}\\\n    ' + (os.pathsep + '\\\n    ').join(annotationProcessorReferences)
         print >> out, 'javac.processorpath=${javac.classpath}\\\n    ' + (os.pathsep + '\\\n    ').join(annotationProcessorReferences)
-    
+
         updated = update_file(join(p.dir, 'nbproject', 'project.properties'), out.getvalue()) or updated
         out.close()
 
@@ -2907,7 +2908,7 @@
             rm(join(p.dir, p.name + '.jar'))
         except:
             log("Error removing {0}".format(p.name + '.jar'))
-            
+
 
 def ideinit(args, suite=None):
     """(re)generate Eclipse and NetBeans project configurations"""
@@ -2928,7 +2929,7 @@
                 projectConfigFiles = frozenset(['.classpath', 'nbproject'])
                 indicators = projectConfigFiles.intersection(files)
                 if len(indicators) != 0:
-                    if not sys.stdout.isatty() or raw_input(currentDir + ' looks like a removed project -- delete it? [yn]: ') == 'y':
+                    if not sys.stdout.isatty() or ask_yes_no(currentDir + ' looks like a removed project -- delete it', 'n'):
                         shutil.rmtree(currentDir)
                         log('Deleted ' + currentDir)
 
@@ -2990,11 +2991,13 @@
                 logv('[package-list file exists - skipping {0}]'.format(p.name))
 
 
-    def find_packages(sourceDirs, pkgs=set()):
+    def find_packages(sourceDirs, pkgs=None):
+        if pkgs is None:
+            pkgs = set()
         for sourceDir in sourceDirs:
             for root, _, files in os.walk(sourceDir):
                 if len([name for name in files if name.endswith('.java')]) != 0:
-                    pkg = root[len(sourceDir) + 1:].replace(os.sep,'.')
+                    pkg = root[len(sourceDir) + 1:].replace(os.sep, '.')
                     if len(packages) == 0 or pkg in packages:
                         if len(exclude_packages) == 0 or not pkg in exclude_packages:
                             pkgs.add(pkg)
@@ -3012,7 +3015,7 @@
         for p in projects:
             # The project must be built to ensure javadoc can find class files for all referenced classes
             build(['--no-native', '--projects', p.name])
-            
+
             pkgs = find_packages(p.source_dirs(), set())
             deps = p.all_deps([], includeLibs=False, includeSelf=False)
             links = ['-link', 'http://docs.oracle.com/javase/' + str(p.javaCompliance.value) + '/docs/api/']
@@ -3050,11 +3053,11 @@
             finally:
                 if delOverviewFile:
                     os.remove(overviewFile)
-                
+
     else:
         # The projects must be built to ensure javadoc can find class files for all referenced classes
         build(['--no-native'])
-        
+
         pkgs = set()
         sp = []
         names = []
@@ -3108,7 +3111,7 @@
             rdelimLen = 0
         old = content[lindex:rindex + rdelimLen]
         return content.replace(old, repl)
-        
+
 # Post-process an overview-summary.html file to move the
 # complete overview to the top of the page
 def _fix_overview_summary(path, topLink):
@@ -3140,7 +3143,7 @@
     assert chunk1.text, 'Could not find header section in ' + path
     assert chunk2.text, 'Could not find footer section in ' + path
 
-    content = chunk1.replace(content, '<div class="header"><div class="subTitle"><div class="block">' + topLink + chunk2.text +'</div></div></div>')
+    content = chunk1.replace(content, '<div class="header"><div class="subTitle"><div class="block">' + topLink + chunk2.text + '</div></div></div>')
     content = chunk2.replace(content, '')
 
     with open(path, 'w') as fp:
@@ -3172,9 +3175,9 @@
     if chunk1.text:
         if chunk2.text:
             repl = re.sub(r'<h2 title=(.*) Description</h2>', r'<h1 title=\1</h1>', chunk2.text, 1)
-            content = chunk1.replace(content, '<div class="header">' + repl +'</div></div>')
+            content = chunk1.replace(content, '<div class="header">' + repl + '</div></div>')
             content = chunk2.replace(content, '')
-        
+
             with open(path, 'w') as fp:
                 fp.write(content)
         else:
@@ -3236,12 +3239,12 @@
 <tbody>"""
                     color = 'row'
                     for p in projects:
-                        print >> fp2, '<tr class="{1}Color"><td class="colFirst"><a href="../{0}/javadoc/index.html", target = "_top">{0}</a></td><td class="colLast">&nbsp;</td></tr>'.format(p.name, color)
+                        print >> fp2, '<tr class="{1}Color"><td class="colFirst"><a href="../{0}/javadoc/index.html",target = "_top">{0}</a></td><td class="colLast">&nbsp;</td></tr>'.format(p.name, color)
                         color = 'row' if color == 'alt' else 'alt'
-                        
+
                     print >> fp2, '</tbody></table></div>'
                     print >> fp2, content[idx:]
-        
+
         title = args.title if args.title is not None else args.name
         javadoc(['--base', tmpbase,
                  '--unified',
@@ -3257,10 +3260,10 @@
                 if not 'version' in subprocess.check_output(['dot', '-V'], stderr=subprocess.STDOUT):
                     dotErr = 'dot -V does not print a string containing "version"'
             except subprocess.CalledProcessError as e:
-                dotErr = 'error calling "dot -V": {}'.format(e) 
+                dotErr = 'error calling "dot -V": {}'.format(e)
             except OSError as e:
                 dotErr = 'error calling "dot -V": {}'.format(e)
-                 
+
             if dotErr != None:
                 abort('cannot generate dependency graph: ' + dotErr)
 
@@ -3274,7 +3277,7 @@
                 print >> fp, 'rankdir=BT;'
                 print >> fp, 'size = "' + str(dim) + ',' + str(dim) + '";'
                 print >> fp, 'node [shape=rect, fontcolor="blue"];'
-                #print >> fp, 'edge [color="green"];'
+                # print >> fp, 'edge [color="green"];'
                 for p in projects:
                     print >> fp, '"' + p.name + '" [URL = "../' + p.name + '/javadoc/index.html", target = "_top"]'
                     for dep in p.canonical_deps():
@@ -3285,7 +3288,7 @@
                     d = p.max_depth()
                     depths.setdefault(d, list()).append(p.name)
                 print >> fp, '}'
-    
+
             run(['dot', '-Tsvg', '-o' + svg, '-Tjpg', '-o' + jpg, dot])
 
             # Post-process generated SVG to remove title elements which most browsers
@@ -3296,7 +3299,7 @@
             content = re.sub('xlink:title="[^"]*"', '', content)
             with open(svg, 'w') as fp:
                 fp.write(content)
-        
+
             # Create HTML that embeds the svg file in an <object> frame
             with open(html, 'w') as fp:
                 print >> fp, '<html><body><object data="{}.svg" type="image/svg+xml"></object></body></html>'.format(args.dot_output_base)
@@ -3347,7 +3350,7 @@
 def select_items(items, descriptions=None, allowMultiple=True):
     """
     Presents a command line interface for selecting one or more (if allowMultiple is true) items.
-    
+
     """
     if len(items) <= 1:
         return items
@@ -3371,10 +3374,10 @@
             except:
                 log('Selection contains non-numeric characters: "' + ' '.join(s) + '"')
                 continue
-            
+
             if allowMultiple and 0 in s:
                 return items
-            
+
             indexes = []
             for n in s:
                 if n not in range(1, len(items) + 1):
@@ -3391,15 +3394,15 @@
 def javap(args):
     """disassemble classes matching given pattern with javap"""
 
-    javap = java().javap
-    if not exists(javap):
-        abort('The javap executable does not exists: ' + javap)
+    javapExe = java().javap
+    if not exists(javapExe):
+        abort('The javap executable does not exists: ' + javapExe)
     else:
         candidates = findclass(args, logToConsole=False)
         if len(candidates) == 0:
             log('no matches')
         selection = select_items(candidates)
-        run([javap, '-private', '-verbose', '-classpath', classpath()] + selection)
+        run([javapExe, '-private', '-verbose', '-classpath', classpath()] + selection)
 
 def show_projects(args):
     """show all loaded projects"""
@@ -3410,6 +3413,22 @@
             for p in s.projects:
                 log('\t' + p.name)
 
+def ask_yes_no(question, default=None):
+    """"""
+    assert not default or default == 'y' or default == 'n'
+    if not sys.stdout.isatty():
+        if default:
+            return default
+        else:
+            abort("Can not answer '" + question + "?' if stdout is not a tty")
+    questionMark = '? [yn]: '
+    if default:
+        questionMark = questionMark.replace(default, default.upper())
+    answer = raw_input(question + questionMark) or default
+    while not answer:
+        answer = raw_input(question + questionMark)
+    return answer.lower().startswith('y')
+
 def add_argument(*args, **kwargs):
     """
     Define how a single command-line argument.
@@ -3422,7 +3441,7 @@
 # If any of the format args are instances of Callable, then they are called with an 'env' are before being
 # used in the call to str.format().
 # Extensions should update this table directly
-commands = {
+_commands = {
     'about': [about, ''],
     'build': [build, '[options]'],
     'checkstyle': [checkstyle, ''],
@@ -3487,8 +3506,8 @@
     command = commandAndArgs[0]
     command_args = commandAndArgs[1:]
 
-    if not commands.has_key(command):
-        hits = [c for c in commands.iterkeys() if c.startswith(command)]
+    if not _commands.has_key(command):
+        hits = [c for c in _commands.iterkeys() if c.startswith(command)]
         if len(hits) == 1:
             command = hits[0]
         elif len(hits) == 0:
@@ -3496,7 +3515,7 @@
         else:
             abort('mx: command \'{0}\' is ambiguous\n    {1}'.format(command, ' '.join(hits)))
 
-    c, _ = commands[command][:2]
+    c, _ = _commands[command][:2]
     def term_handler(signum, frame):
         abort(1)
     signal.signal(signal.SIGTERM, term_handler)
--- a/src/gpu/ptx/vm/gpu_ptx.cpp	Fri Sep 06 16:17:01 2013 +0200
+++ b/src/gpu/ptx/vm/gpu_ptx.cpp	Fri Sep 06 16:17:16 2013 +0200
@@ -38,6 +38,7 @@
 gpu::Ptx::cuda_cu_ctx_create_func_t gpu::Ptx::_cuda_cu_ctx_create;
 gpu::Ptx::cuda_cu_ctx_destroy_func_t gpu::Ptx::_cuda_cu_ctx_destroy;
 gpu::Ptx::cuda_cu_ctx_synchronize_func_t gpu::Ptx::_cuda_cu_ctx_synchronize;
+gpu::Ptx::cuda_cu_ctx_set_current_func_t gpu::Ptx::_cuda_cu_ctx_set_current;
 gpu::Ptx::cuda_cu_device_get_count_func_t gpu::Ptx::_cuda_cu_device_get_count;
 gpu::Ptx::cuda_cu_device_get_name_func_t gpu::Ptx::_cuda_cu_device_get_name;
 gpu::Ptx::cuda_cu_device_get_func_t gpu::Ptx::_cuda_cu_device_get;
@@ -87,7 +88,7 @@
     tty->print_cr("Failed to initialize CUDA device");
     return false;
   }
- 
+
   if (TraceGPUInteraction) {
     tty->print_cr("CUDA driver initialization: Success");
   }
@@ -108,7 +109,7 @@
   if (TraceGPUInteraction) {
     tty->print_cr("[CUDA] Number of compute-capable devices found: %d", device_count);
   }
-  
+
   /* Get the handle to the first compute device */
   int device_id = 0;
   /* Compute-capable device handle */
@@ -195,12 +196,6 @@
   jit_options[2] = GRAAL_CU_JIT_MAX_REGISTERS;
   jit_option_values[2] = (void *)(size_t)jit_register_count;
 
-  if (TraceGPUInteraction) {
-    tty->print_cr("[CUDA] PTX Kernel\n%s", code);
-    tty->print_cr("[CUDA] Function name : %s", name);
-
-  }
-
   /* Create CUDA context to compile and execute the kernel */
   int status = _cuda_cu_ctx_create(&_device_context, 0, _cu_device);
 
@@ -213,6 +208,23 @@
     tty->print_cr("[CUDA] Success: Created context for device: %d", _cu_device);
   }
 
+  status = _cuda_cu_ctx_set_current(_device_context);
+
+  if (status != GRAAL_CUDA_SUCCESS) {
+    tty->print_cr("[CUDA] Failed to set current context for device: %d", _cu_device);
+    return NULL;
+  }
+
+  if (TraceGPUInteraction) {
+    tty->print_cr("[CUDA] Success: Set current context for device: %d", _cu_device);
+  }
+
+  if (TraceGPUInteraction) {
+    tty->print_cr("[CUDA] PTX Kernel\n%s", code);
+    tty->print_cr("[CUDA] Function name : %s", name);
+
+  }
+
   /* Load module's data with compiler options */
   status = _cuda_cu_module_load_data_ex(&cu_module, (void*) code, jit_num_options,
                                             jit_options, (void **)jit_option_values);
@@ -220,7 +232,7 @@
     if (status == GRAAL_CUDA_ERROR_NO_BINARY_FOR_GPU) {
       tty->print_cr("[CUDA] Check for malformed PTX kernel or incorrect PTX compilation options");
     }
-    tty->print_cr("[CUDA] *** Error (%d) Failed to load module data with online compiler options for method %s", 
+    tty->print_cr("[CUDA] *** Error (%d) Failed to load module data with online compiler options for method %s",
                   status, name);
     return NULL;
   }
@@ -255,7 +267,7 @@
   unsigned int blockX = 1;
   unsigned int blockY = 1;
   unsigned int blockZ = 1;
-  
+
   struct CUfunc_st* cu_function = (struct CUfunc_st*) kernel;
 
   void * config[5] = {
@@ -366,7 +378,7 @@
   if (cuda_library_name != NULL) {
     char *buffer = (char*)malloc(STD_BUFFER_SIZE);
     void *handle = os::dll_load(cuda_library_name, buffer, STD_BUFFER_SIZE);
-	free(buffer);
+        free(buffer);
     if (handle != NULL) {
       _cuda_cu_init =
         CAST_TO_FN_PTR(cuda_cu_init_func_t, os::dll_lookup(handle, "cuInit"));
@@ -376,6 +388,8 @@
         CAST_TO_FN_PTR(cuda_cu_ctx_destroy_func_t, os::dll_lookup(handle, "cuCtxDestroy"));
       _cuda_cu_ctx_synchronize =
         CAST_TO_FN_PTR(cuda_cu_ctx_synchronize_func_t, os::dll_lookup(handle, "cuCtxSynchronize"));
+      _cuda_cu_ctx_set_current =
+        CAST_TO_FN_PTR(cuda_cu_ctx_set_current_func_t, os::dll_lookup(handle, "cuCtxSetCurrent"));
       _cuda_cu_device_get_count =
         CAST_TO_FN_PTR(cuda_cu_device_get_count_func_t, os::dll_lookup(handle, "cuDeviceGetCount"));
       _cuda_cu_device_get_name =
@@ -416,4 +430,3 @@
   tty->print_cr("Failed to find CUDA linkage");
   return false;
 }
-
--- a/src/gpu/ptx/vm/gpu_ptx.hpp	Fri Sep 06 16:17:01 2013 +0200
+++ b/src/gpu/ptx/vm/gpu_ptx.hpp	Fri Sep 06 16:17:16 2013 +0200
@@ -87,6 +87,7 @@
   typedef int (*cuda_cu_ctx_create_func_t)(void*, int, int);
   typedef int (*cuda_cu_ctx_destroy_func_t)(void*);
   typedef int (*cuda_cu_ctx_synchronize_func_t)(void);
+  typedef int (*cuda_cu_ctx_set_current_func_t)(void*);
   typedef int (*cuda_cu_device_get_count_func_t)(int*);
   typedef int (*cuda_cu_device_get_name_func_t)(char*, int, int);
   typedef int (*cuda_cu_device_get_func_t)(int*, int);
@@ -98,7 +99,7 @@
                                               unsigned int, void*, void**, void**);
   typedef int (*cuda_cu_module_get_function_func_t)(void*, void*, const char*);
   typedef int (*cuda_cu_module_load_data_ex_func_t)(void*, void*, unsigned int, void*, void**);
-  typedef int (*cuda_cu_memalloc_func_t)(void*, unsigned int);
+  typedef int (*cuda_cu_memalloc_func_t)(void*, size_t);
   typedef int (*cuda_cu_memfree_func_t)(gpu::Ptx::CUdeviceptr);
   typedef int (*cuda_cu_memcpy_htod_func_t)(gpu::Ptx::CUdeviceptr, const void*, unsigned int);
   typedef int (*cuda_cu_memcpy_dtoh_func_t)(const void*, gpu::Ptx::CUdeviceptr,  unsigned int);
@@ -120,6 +121,7 @@
   static cuda_cu_memfree_func_t                   _cuda_cu_memfree;
   static cuda_cu_memcpy_htod_func_t               _cuda_cu_memcpy_htod;
   static cuda_cu_memcpy_dtoh_func_t               _cuda_cu_memcpy_dtoh;
+  static cuda_cu_ctx_set_current_func_t           _cuda_cu_ctx_set_current;
 
 protected:
   static void* _device_context;
--- a/src/gpu/ptx/vm/kernelArguments.hpp	Fri Sep 06 16:17:01 2013 +0200
+++ b/src/gpu/ptx/vm/kernelArguments.hpp	Fri Sep 06 16:17:16 2013 +0200
@@ -56,6 +56,7 @@
     _args = args;
     _success = true;
     _bufferOffset = 0;
+    _return_value_ptr = 0;
     if (!is_static) {
       // TODO : Create a device argument for receiver object and add it to _kernelBuffer
       tty->print_cr("{CUDA] ****** TODO: Support for execution of non-static java methods not implemented yet.");
--- a/src/share/vm/graal/graalCompilerToVM.cpp	Fri Sep 06 16:17:01 2013 +0200
+++ b/src/share/vm/graal/graalCompilerToVM.cpp	Fri Sep 06 16:17:16 2013 +0200
@@ -64,39 +64,24 @@
   ResourceMark rm;
 
   int code_size = method->code_size();
-  jbyte* reconstituted_code = NULL;
+  jbyte* reconstituted_code = NEW_RESOURCE_ARRAY(jbyte, code_size);
+
+  guarantee(method->method_holder()->is_rewritten(), "Method's holder should be rewritten");
+  // iterate over all bytecodes and replace non-Java bytecodes
 
-  // replace all breakpoints - must be done before undoing any rewriting
-  if (method->number_of_breakpoints() > 0) {
-    reconstituted_code = NEW_RESOURCE_ARRAY(jbyte, code_size);
-    memcpy(reconstituted_code, (jbyte *) method->code_base(), code_size);
-    BreakpointInfo* bp = InstanceKlass::cast(method->method_holder())->breakpoints();
-    for (; bp != NULL; bp = bp->next()) {
-      if (bp->match(method())) {
-        jbyte code = bp->orig_bytecode();
-        reconstituted_code[bp->bci()] = code;
-      }
-    }
-  }
+  for (BytecodeStream s(method); s.next() != Bytecodes::_illegal; ) {
+    Bytecodes::Code code = s.code();
+    Bytecodes::Code raw_code = s.raw_code();
+    int bci = s.bci();
+    int len = s.instruction_size();
 
-  // iterate over all bytecodes and replace non-Java bytecodes
-  if (RewriteBytecodes || RewriteFrequentPairs || InstanceKlass::cast(method->method_holder())->is_rewritten()) {
-    if (reconstituted_code == NULL) {
-      reconstituted_code = NEW_RESOURCE_ARRAY(jbyte, code_size);
-      memcpy(reconstituted_code, (jbyte *) method->code_base(), code_size);
+    // Restore original byte code.
+    reconstituted_code[bci] = (jbyte) (s.is_wide()? Bytecodes::_wide : code);
+    if (len > 1) {
+      memcpy(&reconstituted_code[bci+1], s.bcp()+1, len-1);
     }
 
-    for (BytecodeStream s(method); s.next() != Bytecodes::_illegal; ) {
-      Bytecodes::Code code = s.code();
-      Bytecodes::Code raw_code = s.raw_code();
-      int bci = s.bci();
-
-      // Restore original byte code.  The Bytecodes::is_java_code check
-      // also avoids overwriting wide bytecodes.
-      if (!Bytecodes::is_java_code(raw_code)) {
-        reconstituted_code[bci] = (jbyte) code;
-      }
-
+    if (len > 1) {
       // Restore the big-endian constant pool indexes.
       // Cf. Rewriter::scan_method
       switch (code) {
@@ -141,11 +126,7 @@
     }
   }
 
-  if (reconstituted_code == NULL) {
-    env->SetByteArrayRegion(result, 0, code_size, (jbyte *) method->code_base());
-  } else {
-    env->SetByteArrayRegion(result, 0, code_size, reconstituted_code);
-  }
+  env->SetByteArrayRegion(result, 0, code_size, reconstituted_code);
 
   return result;
 C2V_END
@@ -573,6 +554,12 @@
   return InstanceKlass::cast(klass)->is_initialized();
 C2V_END
 
+C2V_VMENTRY(jboolean, isTypeLinked,(JNIEnv *, jobject, jobject hotspot_klass))
+  Klass* klass = java_lang_Class::as_Klass(HotSpotResolvedObjectType::javaMirror(hotspot_klass));
+  assert(klass != NULL, "method must not be called for primitive types");
+  return InstanceKlass::cast(klass)->is_linked();
+C2V_END
+
 C2V_VMENTRY(jboolean, hasFinalizableSubclass,(JNIEnv *, jobject, jobject hotspot_klass))
   Klass* klass = java_lang_Class::as_Klass(HotSpotResolvedObjectType::javaMirror(hotspot_klass));
   assert(klass != NULL, "method must not be called for primitive types");
@@ -1217,6 +1204,7 @@
   {CC"getInstanceFields",             CC"("HS_RESOLVED_TYPE")["HS_RESOLVED_FIELD,                       FN_PTR(getInstanceFields)},
   {CC"getMethods",                    CC"("HS_RESOLVED_TYPE")["HS_RESOLVED_METHOD,                      FN_PTR(getMethods)},
   {CC"isTypeInitialized",             CC"("HS_RESOLVED_TYPE")Z",                                        FN_PTR(isTypeInitialized)},
+  {CC"isTypeLinked",                  CC"("HS_RESOLVED_TYPE")Z",                                        FN_PTR(isTypeLinked)},
   {CC"hasFinalizableSubclass",        CC"("HS_RESOLVED_TYPE")Z",                                        FN_PTR(hasFinalizableSubclass)},
   {CC"initializeType",                CC"("HS_RESOLVED_TYPE")V",                                        FN_PTR(initializeType)},
   {CC"getMaxCallTargetOffset",        CC"(J)J",                                                         FN_PTR(getMaxCallTargetOffset)},