More boundary checks
diff --git a/lib/runtime/dart/_interceptors.js b/lib/runtime/dart/_interceptors.js
index 5ae0f7d..c5b25fc 100644
--- a/lib/runtime/dart/_interceptors.js
+++ b/lib/runtime/dart/_interceptors.js
@@ -130,7 +130,8 @@
       }
       [dartx.remove](element) {
         this[dartx.checkGrowable]('remove');
-        for (let i = 0; i < dart.notNull(this[dartx.length]); i++) {
+        let length = dart.notNull(this[dartx.length]);
+        for (let i = 0; i < length; i++) {
           if (dart.equals(this[dartx.get](i), element)) {
             this.splice(i, 1);
             return true;
@@ -180,8 +181,9 @@
       [dartx.join](separator) {
         if (separator === void 0)
           separator = "";
-        let list = core.List.new(this[dartx.length]);
-        for (let i = 0; i < dart.notNull(this[dartx.length]); i++) {
+        let length = dart.notNull(this[dartx.length]);
+        let list = core.List.new(length);
+        for (let i = 0; i < length; i++) {
           list[dartx.set](i, `${this[dartx.get](i)}`);
         }
         return list.join(separator);
@@ -980,7 +982,8 @@
       }
       if (dart.notNull(start) + dart.notNull(this[dartx.length]) > dart.notNull(string[dartx.length]))
         return null;
-      for (let i = 0; i < dart.notNull(this[dartx.length]); i++) {
+      let length = dart.notNull(this[dartx.length]);
+      for (let i = 0; i < length; i++) {
         if (string[dartx.codeUnitAt](dart.notNull(start) + i) != this[dartx.codeUnitAt](i)) {
           return null;
         }
diff --git a/lib/runtime/dart/collection.js b/lib/runtime/dart/collection.js
index 306c2e6..72a4303 100644
--- a/lib/runtime/dart/collection.js
+++ b/lib/runtime/dart/collection.js
@@ -1661,7 +1661,7 @@
       }
       contains(element) {
         let length = dart.notNull(this.length);
-        for (let i = 0; i < dart.notNull(this.length); i++) {
+        for (let i = 0; i < length; i++) {
           if (dart.equals(this.get(i), element))
             return true;
           if (length != this.length) {
@@ -1853,10 +1853,11 @@
         }
       }
       remove(element) {
-        for (let i = 0; i < dart.notNull(this.length); i++) {
+        let length = dart.notNull(this.length);
+        for (let i = 0; i < length; i++) {
           if (dart.equals(this.get(i), element)) {
-            this.setRange(i, dart.notNull(this.length) - 1, this, i + 1);
-            this.length = dart.notNull(this.length) - 1;
+            this.setRange(i, length - 1, this, i + 1);
+            this.length = length = length - 1;
             return true;
           }
         }
diff --git a/tool/input_sdk/lib/collection/list.dart b/tool/input_sdk/lib/collection/list.dart
index faaab3b..bf3a080 100644
--- a/tool/input_sdk/lib/collection/list.dart
+++ b/tool/input_sdk/lib/collection/list.dart
@@ -89,7 +89,7 @@
 
   bool contains(Object element) {
     int length = this.length + 0;
-    for (int i = 0; i < this.length; i++) {
+    for (int i = 0; i < length; i++) {
       if (this[i] == element) return true;
       if (length != this.length) {
         throw new ConcurrentModificationError(this);
@@ -252,10 +252,11 @@
   }
 
   bool remove(Object element) {
-    for (int i = 0; i < this.length; i++) {
+    int length = this.length + 0;
+    for (int i = 0; i < length; i++) {
       if (this[i] == element) {
-        this.setRange(i, this.length - 1, this, i + 1);
-        this.length -= 1;
+        this.setRange(i, length - 1, this, i + 1);
+        this.length = length = length - 1;
         return true;
       }
     }
diff --git a/tool/input_sdk/private/js_array.dart b/tool/input_sdk/private/js_array.dart
index 9cc9967..d06a467 100644
--- a/tool/input_sdk/private/js_array.dart
+++ b/tool/input_sdk/private/js_array.dart
@@ -82,7 +82,8 @@
 
   bool remove(Object element) {
     checkGrowable('remove');
-    for (int i = 0; i < this.length; i++) {
+    int length = this.length + 0;
+    for (int i = 0; i < length; i++) {
       if (this[i] == element) {
         JS('var', r'#.splice(#, 1)', this, i);
         return true;
@@ -134,8 +135,9 @@
   }
 
   String join([String separator = ""]) {
-    var list = new List(this.length);
-    for (int i = 0; i < this.length; i++) {
+    int length = this.length + 0;
+    var list = new List(length);
+    for (int i = 0; i < length; i++) {
       list[i] = "${this[i]}";
     }
     return JS('String', "#.join(#)", list, separator);
diff --git a/tool/input_sdk/private/js_string.dart b/tool/input_sdk/private/js_string.dart
index 4007b2f..9492761 100644
--- a/tool/input_sdk/private/js_string.dart
+++ b/tool/input_sdk/private/js_string.dart
@@ -36,7 +36,8 @@
     }
     if (start + this.length > string.length) return null;
     // TODO(lrn): See if this can be optimized.
-    for (int i = 0; i < this.length; i++) {
+    int length = this.length + 0;
+    for (int i = 0; i < length; i++) {
       if (string.codeUnitAt(start + i) != this.codeUnitAt(i)) {
         return null;
       }
diff --git a/tool/sdk_expected_errors.txt b/tool/sdk_expected_errors.txt
index 2fe8258..9493cfa 100644
--- a/tool/sdk_expected_errors.txt
+++ b/tool/sdk_expected_errors.txt
@@ -9,16 +9,16 @@
 warning: [DownCastComposite] args (dynamic) will need runtime check to cast to type List<String> (dart:_isolate_helper, line 839, col 37)
 warning: [DownCastComposite] msg['args'] (dynamic) will need runtime check to cast to type List<String> (dart:_isolate_helper, line 886, col 11)
 warning: [DownCastComposite] JS('var', r'#.pop()', this) (dynamic) will need runtime check to cast to type E (dart:_interceptors/js_array.dart, line 80, col 12)
-warning: [DownCastComposite] JS('', '#[#]', this, i) (dynamic) will need runtime check to cast to type E (dart:_interceptors/js_array.dart, line 125, col 9)
-warning: [DownCastComposite] IterableMixinWorkaround.reduce(this, combine) (dynamic) will need runtime check to cast to type E (dart:_interceptors/js_array.dart, line 161, col 12)
-warning: [DownCastComposite] IterableMixinWorkaround.firstWhere(this, test, orElse) (dynamic) will need runtime check to cast to type E (dart:_interceptors/js_array.dart, line 169, col 12)
-warning: [DownCastComposite] IterableMixinWorkaround.lastWhereList(this, test, orElse) (dynamic) will need runtime check to cast to type E (dart:_interceptors/js_array.dart, line 173, col 12)
-warning: [DownCastComposite] IterableMixinWorkaround.singleWhere(this, test) (dynamic) will need runtime check to cast to type E (dart:_interceptors/js_array.dart, line 177, col 12)
-warning: [DownCastComposite] JS('var', '#[#]', this, index) (dynamic) will need runtime check to cast to type E (dart:_interceptors/js_array.dart, line 314, col 12)
+warning: [DownCastComposite] JS('', '#[#]', this, i) (dynamic) will need runtime check to cast to type E (dart:_interceptors/js_array.dart, line 126, col 9)
+warning: [DownCastComposite] IterableMixinWorkaround.reduce(this, combine) (dynamic) will need runtime check to cast to type E (dart:_interceptors/js_array.dart, line 163, col 12)
+warning: [DownCastComposite] IterableMixinWorkaround.firstWhere(this, test, orElse) (dynamic) will need runtime check to cast to type E (dart:_interceptors/js_array.dart, line 171, col 12)
+warning: [DownCastComposite] IterableMixinWorkaround.lastWhereList(this, test, orElse) (dynamic) will need runtime check to cast to type E (dart:_interceptors/js_array.dart, line 175, col 12)
+warning: [DownCastComposite] IterableMixinWorkaround.singleWhere(this, test) (dynamic) will need runtime check to cast to type E (dart:_interceptors/js_array.dart, line 179, col 12)
+warning: [DownCastComposite] JS('var', '#[#]', this, index) (dynamic) will need runtime check to cast to type E (dart:_interceptors/js_array.dart, line 316, col 12)
 warning: [DownCastComposite] charCodes (dynamic) will need runtime check to cast to type List<int> (dart:_js_helper, line 264, col 31)
 warning: [DownCastComposite] JS('', '#.value', ret) (dynamic) will need runtime check to cast to type E (dart:_js_helper, line 779, col 16)
-warning: [DownCastComposite] JS('JSExtendableArray', r'#.split(#)', this, pattern) (dynamic) will need runtime check to cast to type List<String> (dart:_interceptors/js_string.dart, line 86, col 14)
-warning: [DownCastComposite] JS('JSExtendableArray', r'#.split(#)', this, re) (dynamic) will need runtime check to cast to type List<String> (dart:_interceptors/js_string.dart, line 89, col 14)
+warning: [DownCastComposite] JS('JSExtendableArray', r'#.split(#)', this, pattern) (dynamic) will need runtime check to cast to type List<String> (dart:_interceptors/js_string.dart, line 87, col 14)
+warning: [DownCastComposite] JS('JSExtendableArray', r'#.split(#)', this, re) (dynamic) will need runtime check to cast to type List<String> (dart:_interceptors/js_string.dart, line 90, col 14)
 warning: [DownCastComposite] JS('JSExtendableArray|Null', r'#.exec(#)', _nativeRegExp, checkString(string)) (dynamic) will need runtime check to cast to type List<String> (dart:_js_helper/regexp_helper.dart, line 108, col 22)
 warning: [DownCastComposite] match (List<dynamic>) will need runtime check to cast to type List<String> (dart:_js_helper/regexp_helper.dart, line 140, col 43)
 warning: [DownCastComposite] match (List<dynamic>) will need runtime check to cast to type List<String> (dart:_js_helper/regexp_helper.dart, line 152, col 43)
@@ -138,9 +138,9 @@
 warning: [DownCastComposite] current (_LinkedListLink) will need runtime check to cast to type E (dart:collection/linked_list.dart, line 134, col 14)
 warning: [DownCastComposite] _next (_LinkedListLink) will need runtime check to cast to type E (dart:collection/linked_list.dart, line 192, col 16)
 warning: [DownCastComposite] _next (_LinkedListLink) will need runtime check to cast to type E (dart:collection/linked_list.dart, line 249, col 16)
-warning: [DownCastComposite] iterable (Iterable<E>) will need runtime check to cast to type List<dynamic> (dart:collection/list.dart, line 367, col 19)
-warning: [DownCastComposite] otherList[otherStart + i] (dynamic) will need runtime check to cast to type E (dart:collection/list.dart, line 379, col 27)
-warning: [DownCastComposite] otherList[otherStart + i] (dynamic) will need runtime check to cast to type E (dart:collection/list.dart, line 383, col 27)
+warning: [DownCastComposite] iterable (Iterable<E>) will need runtime check to cast to type List<dynamic> (dart:collection/list.dart, line 368, col 19)
+warning: [DownCastComposite] otherList[otherStart + i] (dynamic) will need runtime check to cast to type E (dart:collection/list.dart, line 380, col 27)
+warning: [DownCastComposite] otherList[otherStart + i] (dynamic) will need runtime check to cast to type E (dart:collection/list.dart, line 384, col 27)
 warning: [DownCastComposite] _map[_map.keys.first] (dynamic) will need runtime check to cast to type V (dart:collection/maps.dart, line 122, col 18)
 warning: [DownCastComposite] _map[_map.keys.single] (dynamic) will need runtime check to cast to type V (dart:collection/maps.dart, line 123, col 19)
 warning: [DownCastComposite] _map[_map.keys.last] (dynamic) will need runtime check to cast to type V (dart:collection/maps.dart, line 124, col 17)