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

Issue 1024843002: Change ListIterator to only check for concurrent modification at each iteration (Closed)

Created:
5 years, 9 months ago by Lasse Reichstein Nielsen
Modified:
5 years, 8 months ago
CC:
reviews_dartlang.org, Vyacheslav Egorov (Google), srdjan
Target Ref:
refs/remotes/git-svn
Visibility:
Public.

Description

Change ListIterator to only check for concurrent modification at each iteration in checked mode. It also checks at the end in all cases. Iteration only goes from 0 to the original length of the list. This ensures that iterating a list while adding to it (like by x.addAll(x)) is caught instead of growing until out-of-memory. For well-behaved programs this makes no difference since length and original length stay the same. Also, it means that calling moveNext again later, after increasing the length, will not make iteration continue. After returning false, iteration is always done. However, it means that reducing the length causes an out-of-range read before reaching the end, and before a concurrent modification error can happen. R=sra@google.com Committed: https://code.google.com/p/dart/source/detail?r=45198

Patch Set 1 #

Patch Set 2 : Check iterable.length on each iteration. #

Patch Set 3 : Changelog. #

Unified diffs Side-by-side diffs Delta from patch set Stats (+55 lines, -37 lines) Patch
M CHANGELOG.md View 1 2 1 chunk +4 lines, -0 lines 0 comments Download
M sdk/lib/_internal/compiler/js_lib/js_array.dart View 1 2 1 chunk +14 lines, -17 lines 0 comments Download
M sdk/lib/internal/iterable.dart View 1 2 1 chunk +14 lines, -11 lines 0 comments Download
M tests/corelib/iterable_fold_test.dart View 1 2 2 chunks +3 lines, -2 lines 0 comments Download
M tests/corelib/iterable_reduce_test.dart View 1 2 2 chunks +4 lines, -2 lines 0 comments Download
M tests/corelib/json_map_test.dart View 1 2 1 chunk +1 line, -1 line 0 comments Download
M tests/corelib/list_test.dart View 1 2 1 chunk +15 lines, -4 lines 0 comments Download

Messages

Total messages: 11 (2 generated)
Lasse Reichstein Nielsen
5 years, 9 months ago (2015-03-20 10:39:59 UTC) #2
sra1
For dart2js we want compile for (var e in a){...} to something that (1) is ...
5 years, 9 months ago (2015-03-20 12:36:59 UTC) #3
Lasse Reichstein Nielsen
Is this closer to what you need?
5 years, 8 months ago (2015-04-15 13:24:55 UTC) #4
floitsch
I would be ok with this. It makes the code faster and in checked mode ...
5 years, 8 months ago (2015-04-15 13:26:14 UTC) #5
sra1
I would like to move forward with the assert-only check. Please also update the iterator ...
5 years, 8 months ago (2015-04-15 19:17:26 UTC) #6
sra1
lgtm
5 years, 8 months ago (2015-04-15 19:19:27 UTC) #7
Lasse Reichstein Nielsen
Committed patchset #3 (id:40001) manually as 45198 (presubmit successful).
5 years, 8 months ago (2015-04-16 09:08:11 UTC) #8
floitsch
CCing a few VM devs, since they might want to look at their strategies of ...
5 years, 8 months ago (2015-04-16 11:20:57 UTC) #9
sra1
5 years, 8 months ago (2015-04-16 17:56:21 UTC) #11
Message was sent while issue was closed.
I apologize that I misread the CL.

I had misread it as no checks at all in production mode.
This is what we need to generate idiomatic JS - no checks.

We can't generate the check after the loop since there must be no checks on exit
via break statements.
Generating the check as part of the loop condition is as bad (or worse) for V8
than in the update since it puts unknown code between i < a.length and a[i].

The only way to get from 26us to 14us on jsshell is to have no check at all.  I
guess I was reading what I wanted to read.

I apologize for saying lgtm, we should revert until we get this sorted out.

Powered by Google App Engine
This is Rietveld 408576698