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

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: retry 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
« no previous file with comments | « pkg/compiler/lib/src/ssa/optimize.dart ('k') | tests/compiler/dart2js/mock_libraries.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 702d4bea833ca333545ab3a15243d26d83342c0d..578ec5c01c26acec3c00c4968dabaca984be6d19 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.
« no previous file with comments | « pkg/compiler/lib/src/ssa/optimize.dart ('k') | tests/compiler/dart2js/mock_libraries.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698