Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1055)

Unified Diff: sdk/lib/_internal/compiler/js_lib/js_helper.dart

Issue 1087973002: Rewrite for-in loop as indexing loop for JavaScript indexable arrays (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: sdk/lib/_internal/compiler/js_lib/js_helper.dart
diff --git a/sdk/lib/_internal/compiler/js_lib/js_helper.dart b/sdk/lib/_internal/compiler/js_lib/js_helper.dart
index bb22a2fdce13d5954ddecb7bc395941c2aa2fca4..ff66109f202fa0f2fdfe147cb91e696b3300ef46 100644
--- a/sdk/lib/_internal/compiler/js_lib/js_helper.dart
+++ b/sdk/lib/_internal/compiler/js_lib/js_helper.dart
@@ -1435,6 +1435,30 @@ throwAbstractClassInstantiationError(className) {
throw new AbstractClassInstantiationError(className);
}
+// This is used in open coded for-in loops on arrays.
+//
+// checkConcurrentModificationError(a.length == startLength, a)
+//
+// is replaced in codegen by:
+//
+// a.length == startLength || throwConcurrentModificationError(a)
+//
+// TODO(sra): We would like to annotate this as @NoSideEffects() so that loops
+// with no other effects can recognize that the array length does not
+// change. However, in the usual case where the loop does have other effects,
+// that causes the length in the loop condition to be phi(startLength,a.length),
+// which causes confusion in range analysis and the insertion of a bounds check.
+@NoInline()
+checkConcurrentModificationError(sameLength, collection) {
+ if (true != sameLength) {
+ throwConcurrentModificationError(collection);
+ }
+}
+
+@NoInline()
+throwConcurrentModificationError(collection) {
+ throw new ConcurrentModificationError(collection);
+}
/**
* Helper class for building patterns recognizing native type errors.

Powered by Google App Engine
This is Rietveld 408576698