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

Issue 10968060: Add a value range analysis phase to remove bounds checks. (Closed)

Created:
8 years, 2 months ago by ngeoffray
Modified:
8 years, 2 months ago
Reviewers:
Søren Gjesse, kasperl
CC:
reviews_dartlang.org
Visibility:
Public.

Description

Add a value range analysis phase to remove bounds checks. Committed: https://code.google.com/p/dart/source/detail?r=12957

Patch Set 1 : #

Total comments: 26

Patch Set 2 : #

Total comments: 12

Patch Set 3 : #

Patch Set 4 : #

Patch Set 5 : #

Unified diffs Side-by-side diffs Delta from patch set Stats (+879 lines, -54 lines) Patch
M lib/compiler/implementation/constant_system.dart View 1 2 1 chunk +2 lines, -0 lines 0 comments Download
M lib/compiler/implementation/constant_system_dart.dart View 1 2 15 chunks +22 lines, -0 lines 0 comments Download
M lib/compiler/implementation/js_backend/constant_system_javascript.dart View 1 2 3 chunks +5 lines, -0 lines 0 comments Download
M lib/compiler/implementation/ssa/bailout.dart View 1 2 2 chunks +2 lines, -2 lines 0 comments Download
M lib/compiler/implementation/ssa/codegen.dart View 1 2 2 chunks +21 lines, -8 lines 0 comments Download
M lib/compiler/implementation/ssa/nodes.dart View 1 2 5 chunks +18 lines, -3 lines 0 comments Download
M lib/compiler/implementation/ssa/optimize.dart View 1 2 5 chunks +15 lines, -38 lines 0 comments Download
M lib/compiler/implementation/ssa/ssa.dart View 1 2 1 chunk +1 line, -0 lines 0 comments Download
M lib/compiler/implementation/ssa/types.dart View 1 2 1 chunk +2 lines, -2 lines 0 comments Download
A lib/compiler/implementation/ssa/value_range_analyzer.dart View 1 2 3 4 1 chunk +655 lines, -0 lines 0 comments Download
M tests/compiler/dart2js/mock_compiler.dart View 1 2 1 chunk +2 lines, -1 line 0 comments Download
A tests/compiler/dart2js/value_range_test.dart View 1 chunk +134 lines, -0 lines 0 comments Download

Messages

Total messages: 7 (0 generated)
ngeoffray
8 years, 2 months ago (2012-09-24 15:42:27 UTC) #1
Søren Gjesse
https://codereview.chromium.org/10968060/diff/14/lib/compiler/implementation/js_backend/constant_system_javascript.dart File lib/compiler/implementation/js_backend/constant_system_javascript.dart (right): https://codereview.chromium.org/10968060/diff/14/lib/compiler/implementation/js_backend/constant_system_javascript.dart#newcode46 lib/compiler/implementation/js_backend/constant_system_javascript.dart:46: apply(left, right) => dartBitOperation.apply(left, right); Why do you not ...
8 years, 2 months ago (2012-09-26 09:08:24 UTC) #2
ngeoffray
New patchset upladed. https://codereview.chromium.org/10968060/diff/14/lib/compiler/implementation/js_backend/constant_system_javascript.dart File lib/compiler/implementation/js_backend/constant_system_javascript.dart (right): https://codereview.chromium.org/10968060/diff/14/lib/compiler/implementation/js_backend/constant_system_javascript.dart#newcode46 lib/compiler/implementation/js_backend/constant_system_javascript.dart:46: apply(left, right) => dartBitOperation.apply(left, right); On ...
8 years, 2 months ago (2012-09-26 09:33:26 UTC) #3
Søren Gjesse
lgtm https://codereview.chromium.org/10968060/diff/14/lib/compiler/implementation/ssa/value_range_analyzer.dart File lib/compiler/implementation/ssa/value_range_analyzer.dart (right): https://codereview.chromium.org/10968060/diff/14/lib/compiler/implementation/ssa/value_range_analyzer.dart#newcode89 lib/compiler/implementation/ssa/value_range_analyzer.dart:89: class MaxValue extends Value { On 2012/09/26 09:33:26, ...
8 years, 2 months ago (2012-09-26 14:00:15 UTC) #4
Søren Gjesse
One additional comment: How about adding printout of ranges to the tracer?
8 years, 2 months ago (2012-09-26 14:12:24 UTC) #5
ngeoffray
On 2012/09/26 14:12:24, Søren Gjesse wrote: > One additional comment: How about adding printout of ...
8 years, 2 months ago (2012-09-27 09:06:08 UTC) #6
ngeoffray
8 years, 2 months ago (2012-09-27 13:22:02 UTC) #7
Thanks Soren

https://codereview.chromium.org/10968060/diff/14/lib/compiler/implementation/...
File lib/compiler/implementation/ssa/value_range_analyzer.dart (right):

https://codereview.chromium.org/10968060/diff/14/lib/compiler/implementation/...
lib/compiler/implementation/ssa/value_range_analyzer.dart:89: class MaxValue
extends Value {
On 2012/09/26 14:00:15, Søren Gjesse wrote:
> On 2012/09/26 09:33:26, ngeoffray wrote:
> > On 2012/09/26 09:08:24, Søren Gjesse wrote:
> > > Should this maybe be called MaxIntValue and extend IntValue instead (then
it
> > > should implement isZero)?
> > 
> > Renaming is fine, but if it extends IntValue what value would you put in the
> > [value] field? Also, all values here a re "int" values, so would you prefer
if
> > IntValue was renamed to ConcreteIntValue?
> 
> Another alternative is to have AbstractIntValue with subclasses IntValue,
> MaxIntValue and MinIntValue. But then AbstractIntValue does not add much.
> 
> Thinking about it maybe the comments for MaxValue and MinValue should just be
> changed to not mention integer. As far as I can see they could be used with
> doubles as well if we where to start tracking double value ranges.
> 
> Then IntValue should be abstract then without the value field with 

Let's rename MaxValue and MinValue to MaxIntValue and MinIntValue for now. I'd
prefer not to take decisions on what things we might implement in the future.

https://codereview.chromium.org/10968060/diff/12001/lib/compiler/implementati...
File lib/compiler/implementation/ssa/codegen.dart (right):

https://codereview.chromium.org/10968060/diff/12001/lib/compiler/implementati...
lib/compiler/implementation/ssa/codegen.dart:1944: }
On 2012/09/26 14:00:15, Søren Gjesse wrote:
> Maybe assert that not both under and over are null.

Done.

https://codereview.chromium.org/10968060/diff/12001/lib/compiler/implementati...
File lib/compiler/implementation/ssa/nodes.dart (right):

https://codereview.chromium.org/10968060/diff/12001/lib/compiler/implementati...
lib/compiler/implementation/ssa/nodes.dart:2578: accept(HVisitor visitor) =>
visitor.visitRangeConversion(this);
On 2012/09/26 14:00:15, Søren Gjesse wrote:
> Maybe add a comment that we only do range analysis for integers.

Done.

https://codereview.chromium.org/10968060/diff/12001/lib/compiler/implementati...
File lib/compiler/implementation/ssa/optimize.dart (right):

https://codereview.chromium.org/10968060/diff/12001/lib/compiler/implementati...
lib/compiler/implementation/ssa/optimize.dart:202: // Try to recognize [:new
List(int):].
On 2012/09/26 14:00:15, Søren Gjesse wrote:
> Isn't it "Try to recognize length interceptor with input [:new List(int):]"?

Yes, done.

https://codereview.chromium.org/10968060/diff/12001/lib/compiler/implementati...
File lib/compiler/implementation/ssa/value_range_analyzer.dart (right):

https://codereview.chromium.org/10968060/diff/12001/lib/compiler/implementati...
lib/compiler/implementation/ssa/value_range_analyzer.dart:115: if
(other.isNegative()) return other;
On 2012/09/26 14:00:15, Søren Gjesse wrote:
> Shouldn't this be MinValue instead of other? They only have the MSB at an
> infinite position in common.

Good point. Done.

https://codereview.chromium.org/10968060/diff/12001/lib/compiler/implementati...
lib/compiler/implementation/ssa/value_range_analyzer.dart:216: // Will return
IntValue(-42)
On 2012/09/26 14:00:15, Søren Gjesse wrote:
> So using the fact that (a - b) - c == a - (b - c) == (a - c) - b.

Added as a comment.

https://codereview.chromium.org/10968060/diff/12001/lib/compiler/implementati...
lib/compiler/implementation/ssa/value_range_analyzer.dart:390: bool
handleBoundsCheck(HBoundsCheck check) {
On 2012/09/26 14:00:15, Søren Gjesse wrote:
> Maybe comment that this returns true is the bounds check was eliminated.

Done.

Powered by Google App Engine
This is Rietveld 408576698