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

Side by Side Diff: sdk/lib/_internal/compiler/js_lib/js_array.dart

Issue 1064053007: Revert "Change ListIterator to only check for concurrent modification at each iteration" (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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/vm/method_recognizer.h ('k') | sdk/lib/internal/iterable.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 part of _interceptors; 5 part of _interceptors;
6 6
7 /** 7 /**
8 * The interceptor class for [List]. The compiler recognizes this 8 * The interceptor class for [List]. The compiler recognizes this
9 * class as an interceptor, and changes references to [:this:] to 9 * class as an interceptor, and changes references to [:this:] to
10 * actually use the receiver of the method, which is generated as an extra 10 * actually use the receiver of the method, which is generated as an extra
(...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after
598 * 'isGrowable' and 'isMutable' checks into the getInterceptor implementation so 598 * 'isGrowable' and 'isMutable' checks into the getInterceptor implementation so
599 * these classes can have specialized implementations. Doing so will challenge 599 * these classes can have specialized implementations. Doing so will challenge
600 * many assuptions in the JS backend. 600 * many assuptions in the JS backend.
601 */ 601 */
602 class JSMutableArray<E> extends JSArray<E> implements JSMutableIndexable {} 602 class JSMutableArray<E> extends JSArray<E> implements JSMutableIndexable {}
603 class JSFixedArray<E> extends JSMutableArray<E> {} 603 class JSFixedArray<E> extends JSMutableArray<E> {}
604 class JSExtendableArray<E> extends JSMutableArray<E> {} 604 class JSExtendableArray<E> extends JSMutableArray<E> {}
605 605
606 606
607 /// An [Iterator] that iterates a JSArray. 607 /// An [Iterator] that iterates a JSArray.
608 ///
608 class ArrayIterator<E> implements Iterator<E> { 609 class ArrayIterator<E> implements Iterator<E> {
609 final JSArray<E> _iterable; 610 final JSArray<E> _iterable;
610 final int _originalLength; 611 final int _length;
611 int _index; 612 int _index;
612 E _current; 613 E _current;
613 614
614 ArrayIterator(JSArray<E> iterable) 615 ArrayIterator(JSArray<E> iterable)
615 : _iterable = iterable, _originalLength = iterable.length, _index = 0; 616 : _iterable = iterable, _length = iterable.length, _index = 0;
616 617
617 E get current => _current; 618 E get current => _current;
618 619
619 bool moveNext() { 620 bool moveNext() {
620 // Check for concurrent modifiction at each step in checked mode. 621 int length = _iterable.length;
621 assert((_originalLength == _iterable.length) || 622
622 (throw new ConcurrentModificationError(_iterable))); 623 // We have to do the length check even on fixed length Arrays. If we can
623 if (_index < _iterable.length) { 624 // inline moveNext() we might be able to GVN the length and eliminate this
624 _current = _iterable.elementAt(_index); 625 // check on known fixed length JSArray.
625 _index++; 626 if (_length != length) {
626 return true;
627 }
628 // Check for concurrent modification only at the end in production mode.
629 if (_originalLength != _iterable.length) {
630 throw new ConcurrentModificationError(_iterable); 627 throw new ConcurrentModificationError(_iterable);
631 } 628 }
632 _current = null; 629
633 return false; 630 if (_index >= length) {
631 _current = null;
632 return false;
633 }
634 _current = _iterable[_index];
635 _index++;
636 return true;
634 } 637 }
635 } 638 }
OLDNEW
« no previous file with comments | « runtime/vm/method_recognizer.h ('k') | sdk/lib/internal/iterable.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698