Merge r13661-13672 into trunk.

git-svn-id: http://dart.googlecode.com/svn/trunk@13673 260f80e4-7a28-3924-810f-c04153c831b5
diff --git a/lib/compiler/implementation/js/printer.dart b/lib/compiler/implementation/js/printer.dart
index 769d339..e29ef8d 100644
--- a/lib/compiler/implementation/js/printer.dart
+++ b/lib/compiler/implementation/js/printer.dart
@@ -351,7 +351,7 @@
     blockBody(node.body, needsSeparation: false, needsNewline: true);
   }
 
-  void functionOut(Fun fun, Node name, VarCollector vars) {
+  void functionOut(Fun fun, Node name) {
     out("function");
     if (name != null) {
       out(" ");
@@ -359,7 +359,7 @@
       visitNestedExpression(name, PRIMARY,
                             newInForInit: false, newAtStatementBegin: false);
     }
-    namer.enterScope(vars);
+    namer.enterScope();
     out("(");
     if (fun.params != null) {
       visitCommaSeparated(fun.params, PRIMARY,
@@ -371,10 +371,8 @@
   }
 
   visitFunctionDeclaration(FunctionDeclaration declaration) {
-    VarCollector vars = new VarCollector();
-    vars.visitFunctionDeclaration(declaration);
     indent();
-    functionOut(declaration.function, declaration.name, vars);
+    functionOut(declaration.function, declaration.name);
     lineOut();
   }
 
@@ -615,11 +613,11 @@
   }
 
   visitVariableDeclaration(VariableDeclaration decl) {
-    out(namer.getName(decl.name));
+    out(namer.declareName(decl.name));
   }
 
   visitParameter(Parameter param) {
-    out(namer.getName(param.name));
+    out(namer.declareName(param.name));
   }
 
   bool isDigit(int charCode) {
@@ -667,15 +665,11 @@
   }
 
   visitNamedFunction(NamedFunction namedFunction) {
-    VarCollector vars = new VarCollector();
-    vars.visitNamedFunction(namedFunction);
-    functionOut(namedFunction.function, namedFunction.name, vars);
+    functionOut(namedFunction.function, namedFunction.name);
   }
 
   visitFun(Fun fun) {
-    VarCollector vars = new VarCollector();
-    vars.visitFun(fun);
-    functionOut(fun, null, vars);
+    functionOut(fun, null);
   }
 
   visitLiteralBool(LiteralBool node) {
@@ -784,58 +778,6 @@
   }
 }
 
-
-// Collects all the var declarations in the function.  We need to do this in a
-// separate pass because JS vars are lifted to the top of the function.
-class VarCollector extends BaseVisitor {
-  bool nested;
-  final Set<String> vars;
-  final List<String> ordered_vars;
-
-  VarCollector() : nested = false, vars = new Set<String>(), ordered_vars = [];
-
-  void forEach(void fn(String)) => ordered_vars.forEach(fn);
-
-  void collectVarsInFunction(Fun fun) {
-    if (!nested) {
-      nested = true;
-      if (fun.params != null) {
-        for (int i = 0; i < fun.params.length; i++) {
-          add(fun.params[i].name);
-        }
-      }
-      visitBlock(fun.body);
-      nested = false;
-    }
-  }
-
-  void add(String name) {
-    if (!vars.contains(name)) {
-      vars.add(name);
-      ordered_vars.add(name);
-    }
-  }
-
-  void visitFunctionDeclaration(FunctionDeclaration declaration) {
-    // Note that we don't bother collecting the name of the function.
-    collectVarsInFunction(declaration.function);
-  }
-
-  void visitNamedFunction(NamedFunction namedFunction) {
-    // Note that we don't bother collecting the name of the function.
-    collectVarsInFunction(namedFunction.function);
-  }
-
-  void visitFun(Fun fun) {
-    collectVarsInFunction(fun);
-  }
-
-  void visitVariableDeclaration(VariableDeclaration decl) {
-    add(decl.name);
-  }
-}
-
-
 /**
  * Returns true, if the given node must be wrapped into braces when used
  * as then-statement in an [If] that has an else branch.
@@ -897,7 +839,7 @@
 abstract class Namer {
   String getName(String oldName);
   String declareName(String oldName);
-  void enterScope(VarCollector vars);
+  void enterScope();
   void leaveScope();
 }
 
@@ -905,7 +847,7 @@
 class IdentityNamer implements Namer {
   String getName(String oldName) => oldName;
   String declareName(String oldName) => oldName;
-  void enterScope(VarCollector vars) {}
+  void enterScope() {}
   void leaveScope() {}
 }
 
@@ -917,10 +859,9 @@
 
   MinifyRenamer();
 
-  void enterScope(VarCollector vars) {
+  void enterScope() {
     maps.add(new Map<String, String>());
     nameNumberStack.add(nameNumber);
-    vars.forEach(declareName);
   }
 
   void leaveScope() {
@@ -945,7 +886,6 @@
     const LETTERS = 52;
     const DIGITS = 10;
     if (maps.isEmpty()) return oldName;
-
     String newName;
     int n = nameNumber;
     if (n < LETTERS) {
diff --git a/lib/compiler/implementation/lib/web.dart b/lib/compiler/implementation/lib/web.dart
new file mode 100644
index 0000000..a75db7b
--- /dev/null
+++ b/lib/compiler/implementation/lib/web.dart
@@ -0,0 +1,9 @@
+// Copyright (c) 2012, the Dart project authors.  Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+#library("web");
+
+String htmlEscape(String text) {
+  throw "Unimplemented: web::htmlEscape(String).";
+}
diff --git a/lib/compiler/implementation/lib/web.dartp b/lib/compiler/implementation/lib/web.dartp
new file mode 100644
index 0000000..c3ba2ad
--- /dev/null
+++ b/lib/compiler/implementation/lib/web.dartp
@@ -0,0 +1,13 @@
+// Copyright (c) 2012, the Dart project authors.  Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+// Patch file for dart:web
+
+/*patch*/ String htmlEscape(String text) {
+  return text.replaceAll("&", "&amp;")
+             .replaceAll("<", "&lt;")
+             .replaceAll(">", "&gt;")
+             .replaceAll('"', "&quot;")
+             .replaceAll("'", "&apos;");  // Different from original.
+}
diff --git a/lib/dom/templates/html/dartium/factoryprovider__Elements.darttemplate b/lib/dom/templates/html/dartium/factoryprovider__Elements.darttemplate
new file mode 100644
index 0000000..8fe27e5
--- /dev/null
+++ b/lib/dom/templates/html/dartium/factoryprovider__Elements.darttemplate
@@ -0,0 +1,7 @@
+// Copyright (c) 2012, the Dart project authors.  Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+class _Elements {
+
+$!FACTORY_METHODS}
diff --git a/lib/dom/templates/html/dartium/impl_EventTarget.darttemplate b/lib/dom/templates/html/dartium/impl_EventTarget.darttemplate
new file mode 100644
index 0000000..1b4a00d
--- /dev/null
+++ b/lib/dom/templates/html/dartium/impl_EventTarget.darttemplate
@@ -0,0 +1,106 @@
+// Copyright (c) 2012, the Dart project authors.  Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+class _EventsImpl implements Events {
+  // TODO(podivilov): add type.
+  final _ptr;
+
+  final Map<String, EventListenerList> _listenerMap;
+
+  _EventsImpl(this._ptr) : _listenerMap = <EventListenerList>{};
+
+  EventListenerList operator [](String type) {
+    return _listenerMap.putIfAbsent(type,
+      () => new _EventListenerListImpl(_ptr, type));
+  }
+}
+
+class _EventListenerWrapper {
+  final EventListener raw;
+  final Function wrapped;
+  final bool useCapture;
+  _EventListenerWrapper(this.raw, this.wrapped, this.useCapture);
+}
+
+class _EventListenerListImpl implements EventListenerList {
+  // TODO(podivilov): add type.
+  final _ptr;
+  final String _type;
+  List<_EventListenerWrapper> _wrappers;
+
+  _EventListenerListImpl(this._ptr, this._type) :
+    // TODO(jacobr): switch to <_EventListenerWrapper>[] when the VM allow it.
+    _wrappers = new List<_EventListenerWrapper>();
+
+  EventListenerList add(EventListener listener, [bool useCapture = false]) {
+    _add(listener, useCapture);
+    return this;
+  }
+
+  EventListenerList remove(EventListener listener, [bool useCapture = false]) {
+    _remove(listener, useCapture);
+    return this;
+  }
+
+  bool dispatch(Event evt) {
+    // TODO(jacobr): what is the correct behavior here. We could alternately
+    // force the event to have the expected type.
+    assert(evt.type == _type);
+    return _ptr.$dom_dispatchEvent(evt);
+  }
+
+  void _add(EventListener listener, bool useCapture) {
+    _ptr.$dom_addEventListener(_type,
+                          _findOrAddWrapper(listener, useCapture),
+                          useCapture);
+  }
+
+  void _remove(EventListener listener, bool useCapture) {
+    Function wrapper = _removeWrapper(listener, useCapture);
+    if (wrapper !== null) {
+      _ptr.$dom_removeEventListener(_type, wrapper, useCapture);
+    }
+  }
+
+  Function _removeWrapper(EventListener listener, bool useCapture) {
+    if (_wrappers === null) {
+      return null;
+    }
+    for (int i = 0; i < _wrappers.length; i++) {
+      _EventListenerWrapper wrapper = _wrappers[i];
+      if (wrapper.raw === listener && wrapper.useCapture == useCapture) {
+        // Order doesn't matter so we swap with the last element instead of
+        // performing a more expensive remove from the middle of the list.
+        if (i + 1 != _wrappers.length) {
+          _wrappers[i] = _wrappers.removeLast();
+        } else {
+          _wrappers.removeLast();
+        }
+        return wrapper.wrapped;
+      }
+    }
+    return null;
+  }
+
+  Function _findOrAddWrapper(EventListener listener, bool useCapture) {
+    if (_wrappers === null) {
+      _wrappers = <_EventListenerWrapper>[];
+    } else {
+      for (_EventListenerWrapper wrapper in _wrappers) {
+        if (wrapper.raw === listener && wrapper.useCapture == useCapture) {
+          return wrapper.wrapped;
+        }
+      }
+    }
+    final wrapped = (e) { listener(e); };
+    _wrappers.add(new _EventListenerWrapper(listener, wrapped, useCapture));
+    return wrapped;
+  }
+}
+
+class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC {
+/*
+$!MEMBERS
+*/
+}
diff --git a/lib/dom/templates/html/frog/factoryprovider__Elements.darttemplate b/lib/dom/templates/html/frog/factoryprovider__Elements.darttemplate
new file mode 100644
index 0000000..8fe27e5
--- /dev/null
+++ b/lib/dom/templates/html/frog/factoryprovider__Elements.darttemplate
@@ -0,0 +1,7 @@
+// Copyright (c) 2012, the Dart project authors.  Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+class _Elements {
+
+$!FACTORY_METHODS}
diff --git a/lib/dom/templates/html/frog/impl_EventTarget.darttemplate b/lib/dom/templates/html/frog/impl_EventTarget.darttemplate
new file mode 100644
index 0000000..893f3d2
--- /dev/null
+++ b/lib/dom/templates/html/frog/impl_EventTarget.darttemplate
@@ -0,0 +1,61 @@
+// Copyright (c) 2012, the Dart project authors.  Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+class _EventsImpl implements Events {
+  /* Raw event target. */
+  // TODO(jacobr): it would be nice if we could specify this as
+  // _EventTargetImpl or EventTarget
+  final Dynamic _ptr;
+
+  _EventsImpl(this._ptr);
+
+  _EventListenerListImpl operator [](String type) {
+    return new _EventListenerListImpl(_ptr, type);
+  }
+}
+
+class _EventListenerListImpl implements EventListenerList {
+  
+  // TODO(jacobr): make this _EventTargetImpl
+  final Dynamic _ptr;
+  final String _type;
+
+  _EventListenerListImpl(this._ptr, this._type);
+
+  // TODO(jacobr): implement equals.
+
+  _EventListenerListImpl add(EventListener listener,
+      [bool useCapture = false]) {
+    _add(listener, useCapture);
+    return this;
+  }
+
+  _EventListenerListImpl remove(EventListener listener,
+      [bool useCapture = false]) {
+    _remove(listener, useCapture);
+    return this;
+  }
+
+  bool dispatch(Event evt) {
+    // TODO(jacobr): what is the correct behavior here. We could alternately
+    // force the event to have the expected type.
+    assert(evt.type == _type);
+    return _ptr.$dom_dispatchEvent(evt);
+  }
+
+  void _add(EventListener listener, bool useCapture) {
+    _ptr.$dom_addEventListener(_type, listener, useCapture);
+  }
+
+  void _remove(EventListener listener, bool useCapture) {
+    _ptr.$dom_removeEventListener(_type, listener, useCapture);
+  }
+}
+
+
+class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC {
+
+  Events get on() => new _EventsImpl(this);
+$!MEMBERS
+}
diff --git a/tests/compiler/dart2js/class_codegen_test.dart b/tests/compiler/dart2js/class_codegen_test.dart
index dae160e..09c45eb 100644
--- a/tests/compiler/dart2js/class_codegen_test.dart
+++ b/tests/compiler/dart2js/class_codegen_test.dart
@@ -53,8 +53,8 @@
 
 const String TEST_FIVE = r"""
 class A {
-  var a;
-  A(a) : this.a = a {}
+  var x;
+  A(x) : this.x = x {}
 }
 
 main() {
@@ -90,7 +90,7 @@
 
 constructor1() {
   String generated = compileAll(TEST_FIVE);
-  Expect.isTrue(generated.contains(r"new $.A(a);"));
+  Expect.isTrue(generated.contains(r"new $.A(x);"));
 }
 
 main() {
diff --git a/tests/compiler/dart2js/code_motion_test.dart b/tests/compiler/dart2js/code_motion_test.dart
index f093b7a..0c71c99 100644
--- a/tests/compiler/dart2js/code_motion_test.dart
+++ b/tests/compiler/dart2js/code_motion_test.dart
@@ -5,13 +5,13 @@
 #import("compiler_helper.dart");
 
 const String TEST_ONE = r"""
-foo(int a, int b, bool param2) {
+foo(int param0, int param1, bool param2) {
   for (int i = 0; i < 1; i++) {
-    var x = a + 5;  // '+' is now GVNed.
+    var x = param0 + 5;  // '+' is now GVNed.
     if (param2) {
-      print(a + b);
+      print(param0 + param1);
     } else {
-      print(a + b);
+      print(param0 + param1);
     }
   }
 }
@@ -19,7 +19,7 @@
 
 main() {
   String generated = compile(TEST_ONE, 'foo');
-  RegExp regexp = const RegExp('a \\+ b');
+  RegExp regexp = const RegExp('param0 \\+ param1');
   Iterator matches = regexp.allMatches(generated).iterator();
   Expect.isTrue(matches.hasNext());
   matches.next();
diff --git a/tests/compiler/dart2js/compiler_helper.dart b/tests/compiler/dart2js/compiler_helper.dart
index 6606697..057a3aa 100644
--- a/tests/compiler/dart2js/compiler_helper.dart
+++ b/tests/compiler/dart2js/compiler_helper.dart
@@ -68,11 +68,11 @@
 String anyIdentifier = "[a-zA-Z][a-zA-Z0-9]*";
 
 String getIntTypeCheck(String variable) {
-  return "\\($variable ?!== ?\\($variable ?\\| ?0\\)\\)";
+  return "\\($variable !== \\($variable \\| 0\\)\\)";
 }
 
 String getNumberTypeCheck(String variable) {
-  return "\\(typeof $variable ?!== ?'number'\\)";
+  return "\\(typeof $variable !== 'number'\\)";
 }
 
 bool checkNumberOfMatches(Iterator it, int nb) {
@@ -96,28 +96,3 @@
 }
 
 int length(Link link) => link.isEmpty() ? 0 : length(link.tail) + 1;
-
-// Does a compile and then a match where every 'x' is replaced by something
-// that matches any variable, and every space is optional.
-void compileAndMatchFuzzy(String code, String entry, String regexp) {
-  compileAndMatchFuzzyHelper(code, entry, regexp, true);
-}
- 
-void compileAndDoNotMatchFuzzy(String code, String entry, String regexp) {
-  compileAndMatchFuzzyHelper(code, entry, regexp, false);
-}
-
-void compileAndMatchFuzzyHelper(
-    String code, String entry, String regexp, bool shouldMatch) {
-  String generated = compile(code, entry);
-  final xRe = new RegExp('\\bx\\b');
-  regexp = regexp.replaceAll(xRe, '(?:$anyIdentifier)');
-  final spaceRe = new RegExp('\\s+');
-  regexp = regexp.replaceAll(spaceRe, '(?:\\s*)');
-  if (shouldMatch) {
-    Expect.isTrue(new RegExp(regexp).hasMatch(generated));
-  } else {
-    Expect.isFalse(new RegExp(regexp).hasMatch(generated));
-  }
-}
-
diff --git a/tests/compiler/dart2js/gvn_test.dart b/tests/compiler/dart2js/gvn_test.dart
index 72716ca..c63b2c6 100644
--- a/tests/compiler/dart2js/gvn_test.dart
+++ b/tests/compiler/dart2js/gvn_test.dart
@@ -15,7 +15,7 @@
 
 main() {
   String generated = compile(TEST_ONE, 'foo');
-  RegExp regexp = const RegExp(r"1 \+ [a-z]+");
+  RegExp regexp = const RegExp(r"1 \+ bar");
   Iterator matches = regexp.allMatches(generated).iterator();
   Expect.isTrue(matches.hasNext());
   matches.next();
diff --git a/tests/compiler/dart2js/inverse_operator_test.dart b/tests/compiler/dart2js/inverse_operator_test.dart
index 2b48242..df3da80 100644
--- a/tests/compiler/dart2js/inverse_operator_test.dart
+++ b/tests/compiler/dart2js/inverse_operator_test.dart
@@ -16,5 +16,6 @@
 
 main() {
   // Make sure we don't introduce a new variable.
-  compileAndMatchFuzzy(MAIN, 'main', "1 >= x");
+  RegExp regexp = new RegExp("1 >= x");
+  compileAndMatch(MAIN, 'main', regexp);
 }
diff --git a/tests/compiler/dart2js/no_constructor_body_test.dart b/tests/compiler/dart2js/no_constructor_body_test.dart
index dc942af..52ce77c 100644
--- a/tests/compiler/dart2js/no_constructor_body_test.dart
+++ b/tests/compiler/dart2js/no_constructor_body_test.dart
@@ -18,5 +18,5 @@
 main() {
   String generated = compileAll(TEST);
   Expect.isTrue(
-      generated.contains('\$.A = {"":\n [],\n "super": "Object"\n}'));
+      generated.contains('\$.A = {"":\n [],\n "super": "Object"\n};'));
 }
diff --git a/tests/compiler/dart2js/ssa_phi_codegen_test.dart b/tests/compiler/dart2js/ssa_phi_codegen_test.dart
index 63c7280..3f66613 100644
--- a/tests/compiler/dart2js/ssa_phi_codegen_test.dart
+++ b/tests/compiler/dart2js/ssa_phi_codegen_test.dart
@@ -42,33 +42,49 @@
 
 const String TEST_FOUR = r"""
 foo() {
-  var a = true;
-  var b = false;
-  for (var i = 0; a; i = i + 1) {
-    if (i == 9) a = false;
-    for (var j = 0; b; j = j + 1) {
-      if (j == 9) b = false;
+  var cond1 = true;
+  var cond2 = false;
+  for (var i = 0; cond1; i = i + 1) {
+    if (i == 9) cond1 = false;
+    for (var j = 0; cond2; j = j + 1) {
+      if (j == 9) cond2 = false;
     }
   }
-  print(a);
-  print(b);
+  print(cond1);
+  print(cond2);
 }
 """;
 
 main() {
-  compileAndMatchFuzzy(TEST_ONE, 'foo', "var x = x === true \\? 2 : 3;");
-  compileAndMatchFuzzy(TEST_ONE, 'foo', "print\\(x\\);");
+  String generated = compile(TEST_ONE, 'foo');
+  Expect.isTrue(generated.contains('var a = bar === true ? 2 : 3;'));
+  Expect.isTrue(generated.contains('print(a);'));
 
-  compileAndMatchFuzzy(TEST_TWO, 'main', "x \\+= 10");
-  compileAndMatchFuzzy(TEST_TWO, 'main', "\\+\\+x");
+  generated = compile(TEST_TWO, 'main');
+  RegExp regexp = new RegExp("t \\+= 10");
+  Expect.isTrue(regexp.hasMatch(generated));
 
-  // Check that we don't have 'd = d' (using regexp back references).
-  compileAndDoNotMatchFuzzy(TEST_THREE, 'foo', '(x) = \1');
-  compileAndMatchFuzzy(TEST_THREE, 'foo', 'return x');
+  regexp = new RegExp("\\+\\+i");
+  Expect.isTrue(regexp.hasMatch(generated));
+
+  generated = compile(TEST_THREE, 'foo');
+
+  // Check that we don't have 'val = val'.
+  regexp = const RegExp("val = val;");
+  Expect.isTrue(!regexp.hasMatch(generated));
+
+  regexp = const RegExp("return val");
+  Expect.isTrue(regexp.hasMatch(generated));
   // Check that a store just after the declaration of the local
   // only generates one instruction.
-  compileAndMatchFuzzy(TEST_THREE, 'foo', 'x = 42');
+  regexp = const RegExp(r"val = 42");
+  Expect.isTrue(regexp.hasMatch(generated));
 
-  var generated = compile(TEST_FOUR, 'foo');
-  compileAndDoNotMatchFuzzy(TEST_FOUR, 'foo', '(x) = \1;');
+  generated = compile(TEST_FOUR, 'foo');
+
+  regexp = const RegExp("cond1 = cond1;");
+  Expect.isTrue(!regexp.hasMatch(generated));
+
+  regexp = const RegExp("cond2 = cond2;");
+  Expect.isTrue(!regexp.hasMatch(generated));
 }
diff --git a/tests/compiler/dart2js/type_guard_unuser_test.dart b/tests/compiler/dart2js/type_guard_unuser_test.dart
index e9cdced..367b62b 100644
--- a/tests/compiler/dart2js/type_guard_unuser_test.dart
+++ b/tests/compiler/dart2js/type_guard_unuser_test.dart
@@ -6,9 +6,9 @@
 
 const String TEST_ONE = r"""
 foo(a) {
-  int b = foo(true);
-  if (a) b = foo(2);
-  return b;
+  int c = foo(true);
+  if (a) c = foo(2);
+  return c;
 }
 """;
 
@@ -24,16 +24,16 @@
 """;
 
 const String TEST_THREE = r"""
-foo(int a, int b) {
-  return 0 + a + b;
+foo(int param1, int param2) {
+  return 0 + param1 + param2;
 }
 """;
 
 const String TEST_THREE_WITH_BAILOUT = r"""
-foo(int a, int b) {
+foo(int param1, int param2) {
   var t;
   for (int i = 0; i < 1; i++) {
-    t = 0 + a + b;
+    t = 0 + param1 + param2;
   }
   return t;
 }
@@ -44,7 +44,7 @@
   RegExp regexp = new RegExp(getIntTypeCheck(anyIdentifier));
   Iterator<Match> matches = regexp.allMatches(generated).iterator();
   checkNumberOfMatches(matches, 0);
-  Expect.isTrue(generated.contains(r'return a === true ? $.foo(2) : b;'));
+  Expect.isTrue(generated.contains(r'return a === true ? $.foo(2) : c;'));
 
   generated = compile(TEST_TWO, 'foo');
   regexp = const RegExp("foo\\(1\\)");
@@ -52,14 +52,14 @@
   checkNumberOfMatches(matches, 1);
 
   generated = compile(TEST_THREE, 'foo');
-  regexp = new RegExp(getNumberTypeCheck('a'));
+  regexp = new RegExp(getNumberTypeCheck('param1'));
   Expect.isTrue(regexp.hasMatch(generated));
-  regexp = new RegExp(getNumberTypeCheck('b'));
+  regexp = new RegExp(getNumberTypeCheck('param2'));
   Expect.isTrue(regexp.hasMatch(generated));
 
   generated = compile(TEST_THREE_WITH_BAILOUT, 'foo');
-  regexp = new RegExp(getNumberTypeCheck('a'));
+  regexp = new RegExp(getNumberTypeCheck('param1'));
   Expect.isTrue(regexp.hasMatch(generated));
-  regexp = new RegExp(getNumberTypeCheck('b'));
+  regexp = new RegExp(getNumberTypeCheck('param2'));
   Expect.isTrue(regexp.hasMatch(generated));
 }
diff --git a/tests/compiler/dart2js/type_inference2_test.dart b/tests/compiler/dart2js/type_inference2_test.dart
index 7d87645..594c321 100644
--- a/tests/compiler/dart2js/type_inference2_test.dart
+++ b/tests/compiler/dart2js/type_inference2_test.dart
@@ -13,5 +13,6 @@
 """;
 
 main() {
-  compileAndMatchFuzzy(TEST_ONE, 'sum', r"\+\+x");
+  String generated = compile(TEST_ONE, 'sum');
+  Expect.isTrue(generated.contains('++i'));
 }
diff --git a/tests/compiler/dart2js/type_inference3_test.dart b/tests/compiler/dart2js/type_inference3_test.dart
index 65e9147..70fabe8 100644
--- a/tests/compiler/dart2js/type_inference3_test.dart
+++ b/tests/compiler/dart2js/type_inference3_test.dart
@@ -14,8 +14,8 @@
 
 main() {
   String generated = compile(TEST_ONE, 'sum');
-  RegExp regexp = new RegExp(getNumberTypeCheck('(param0|a)'));
+  RegExp regexp = new RegExp(getNumberTypeCheck('param0'));
   Expect.isTrue(regexp.hasMatch(generated));
-  regexp = new RegExp(getNumberTypeCheck('(param1|b)'));
+  regexp = new RegExp(getNumberTypeCheck('param1'));
   Expect.isTrue(regexp.hasMatch(generated));
 }
diff --git a/tests/compiler/dart2js/type_inference4_test.dart b/tests/compiler/dart2js/type_inference4_test.dart
index 48d18d6..4690202 100644
--- a/tests/compiler/dart2js/type_inference4_test.dart
+++ b/tests/compiler/dart2js/type_inference4_test.dart
@@ -6,10 +6,10 @@
 
 const String TEST_ONE = r"""
 foo(j) {
-  var array = [1, 2, 3];
+  var a = [1, 2, 3];
   if (j < 0) j = 0;
   for (var i = j; i < 3; i++) {
-    array[i];
+    a[i];
   }
 }
 """;
@@ -22,6 +22,6 @@
   Expect.isFalse(generated.contains('iae'));
   // Also make sure that we are not just in bailout mode without speculative
   // types by grepping for the integer-bailout check on argument j.
-  RegExp regexp = new RegExp(getIntTypeCheck('[aj]'));
+  RegExp regexp = new RegExp(getIntTypeCheck('j'));
   Expect.isTrue(regexp.hasMatch(generated));
 }
diff --git a/tests/compiler/dart2js/type_inference5_test.dart b/tests/compiler/dart2js/type_inference5_test.dart
index 1385bd1..aa850bb 100644
--- a/tests/compiler/dart2js/type_inference5_test.dart
+++ b/tests/compiler/dart2js/type_inference5_test.dart
@@ -21,9 +21,6 @@
   Expect.isFalse(generated.contains('iae'));
   // Also make sure that we are not just in bailout mode without speculative
   // types by grepping for the integer-bailout check on argument j.
-  var argname =
-      const RegExp(r'function(?: [a-z]+)?\(([a-zA-Z0-9_]+)\)').firstMatch(generated)[1];
-  print(argname);
-  RegExp regexp = new RegExp(getIntTypeCheck(argname));
+  RegExp regexp = new RegExp(getIntTypeCheck('j'));
   Expect.isTrue(regexp.hasMatch(generated));
 }
diff --git a/tests/compiler/dart2js/type_inference_test.dart b/tests/compiler/dart2js/type_inference_test.dart
index 1009486..92a8a5a 100644
--- a/tests/compiler/dart2js/type_inference_test.dart
+++ b/tests/compiler/dart2js/type_inference_test.dart
@@ -5,38 +5,38 @@
 #import("compiler_helper.dart");
 
 const String TEST_ONE = r"""
-sum(a, b) {
-  var c = 0;
-  for (var d = a; d < b; d += 1) c = c + d;
-  return c;
+sum(param0, param1) {
+  var sum = 0;
+  for (var i = param0; i < param1; i += 1) sum = sum + i;
+  return sum;
 }
 """;
 
 const String TEST_TWO = r"""
-foo(int a) {
-  return -a;
+foo(int param0) {
+  return -param0;
 }
 """;
 
 const String TEST_TWO_WITH_BAILOUT = r"""
-foo(int a) {
-  for (int b = 0; b < 1; b++) {
-    a = -a;
+foo(int param0) {
+  for (int i = 0; i < 1; i++) {
+    param0 = -param0;
   }
-  return a;
+  return param0;
 }
 """;
 
 const String TEST_THREE = r"""
-foo(a) {
-  for (int b = 0; b < 10; b++) print(a[b]);
+foo(c) {
+  for (int i = 0; i < 10; i++) print(c[i]);
 }
 """;
 
 const String TEST_FOUR = r"""
-foo(String a) {
-  print(a[0]); // Force a type guard.
-  while (true) print(a.length);
+foo(String c) {
+  print(c[0]); // Force a type guard.
+  while (true) print(c.length);
 }
 """;
 
@@ -66,29 +66,30 @@
 """;
 
 main() {
-  compileAndMatchFuzzy(TEST_ONE, 'sum', "x \\+= x");
-  compileAndMatchFuzzy(TEST_ONE, 'sum', "typeof x !== 'number'");
+  String generated = compile(TEST_ONE, 'sum');
+  Expect.isTrue(generated.contains('sum += i'));
+  Expect.isTrue(generated.contains("typeof param1 !== 'number'"));
 
-  var generated = compile(TEST_TWO, 'foo');
-  RegExp regexp = new RegExp(getNumberTypeCheck('a'));
+  generated = compile(TEST_TWO, 'foo');
+  RegExp regexp = new RegExp(getNumberTypeCheck('param0'));
   Expect.isTrue(!regexp.hasMatch(generated));
 
-  regexp = const RegExp('-a');
+  regexp = const RegExp('-param0');
   Expect.isTrue(!regexp.hasMatch(generated));
 
   generated = compile(TEST_TWO_WITH_BAILOUT, 'foo');
-  regexp = new RegExp(getNumberTypeCheck('a'));
+  regexp = new RegExp(getNumberTypeCheck('param0'));
   Expect.isTrue(regexp.hasMatch(generated));
 
-  regexp = const RegExp('-a');
+  regexp = const RegExp('-param0');
   Expect.isTrue(regexp.hasMatch(generated));
 
   generated = compile(TEST_THREE, 'foo');
-  regexp = new RegExp("a[$anyIdentifier]");
+  regexp = new RegExp("c[$anyIdentifier]");
   Expect.isTrue(regexp.hasMatch(generated));
 
   generated = compile(TEST_FOUR, 'foo');
-  regexp = new RegExp("a.length");
+  regexp = new RegExp("c.length");
   Expect.isTrue(regexp.hasMatch(generated));
 
   generated = compile(TEST_FIVE, 'foo');
diff --git a/tools/VERSION b/tools/VERSION
index 453bc99..c3d743e 100644
--- a/tools/VERSION
+++ b/tools/VERSION
@@ -1,4 +1,4 @@
 MAJOR 0
 MINOR 1
-BUILD 2
-PATCH 0
+BUILD 6
+PATCH 3