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

Issue 10735051: Fix usage of UNKNOWN/CONFLICTING types for union. (Closed)

Created:
8 years, 5 months ago by floitsch
Modified:
8 years, 5 months ago
CC:
reviews_dartlang.org
Visibility:
Public.

Description

Fix usage of UNKNOWN/CONFLICTING types for union. Fixes issue 4033. Committed: https://code.google.com/p/dart/source/detail?r=9547

Patch Set 1 #

Patch Set 2 : Add another test. #

Total comments: 1

Patch Set 3 : Cosmetic change in comment. #

Total comments: 4
Unified diffs Side-by-side diffs Delta from patch set Stats (+488 lines, -442 lines) Patch
M lib/compiler/implementation/compiler.dart View 4 chunks +11 lines, -9 lines 0 comments Download
M lib/compiler/implementation/ssa/nodes.dart View 4 chunks +14 lines, -17 lines 0 comments Download
M lib/compiler/implementation/ssa/optimize.dart View 5 chunks +11 lines, -15 lines 1 comment Download
M lib/compiler/implementation/ssa/types.dart View 21 chunks +69 lines, -53 lines 3 comments Download
M lib/compiler/implementation/ssa/types_propagation.dart View 1 2 1 chunk +1 line, -1 line 0 comments Download
M tests/compiler/dart2js/type_combination_test.dart View 2 chunks +336 lines, -336 lines 0 comments Download
A + tests/language/field_optimization2_test.dart View 1 1 chunk +13 lines, -11 lines 0 comments Download
A tests/language/field_optimization_test.dart View 1 chunk +33 lines, -0 lines 0 comments Download

Messages

Total messages: 3 (0 generated)
floitsch
known to tank performance. https://chromiumcodereview.appspot.com/10735051/diff/2001/lib/compiler/implementation/compiler.dart File lib/compiler/implementation/compiler.dart (right): https://chromiumcodereview.appspot.com/10735051/diff/2001/lib/compiler/implementation/compiler.dart#newcode172 lib/compiler/implementation/compiler.dart:172: return HType.UNKNOWN; I didn't change ...
8 years, 5 months ago (2012-07-11 10:12:46 UTC) #1
Mads Ager (google)
LGTM! Good to have this fixed so we can actually get *correct* information from using ...
8 years, 5 months ago (2012-07-11 10:24:34 UTC) #2
sra1
8 years, 5 months ago (2012-07-11 20:04:33 UTC) #3
I think representing various points in the type lattice by a rich hierarchy of
classes is the wrong way to go.
Operations will be less error-prone if the type space is constructed as a union
of disjoint types, e.g. as a bit mask.  The operations can then be coded once
rather than having niggling bugs and asymmetry in the operations.

https://chromiumcodereview.appspot.com/10735051/diff/5001/lib/compiler/implem...
File lib/compiler/implementation/ssa/types.dart (right):

https://chromiumcodereview.appspot.com/10735051/diff/5001/lib/compiler/implem...
lib/compiler/implementation/ssa/types.dart:117: * A union of [CONFLICTING] with
any other types returns the other type.
I find CONFLICTING to be a confusing name.
The element is really the bottom element of a bounded lattice, which represents
the empty set of values.  For there to be a 'conflict' two things have to be in
opposition.  In a 0-1-many analysis, two is 'many', making it feel like
CONFLICTING is the top element, i.e. the same as UNKNOWN.
I suspect the bugs fixed in this change are due to that confusion.

I suggest renaming CONFLICTING to NOTHING, EMPTY, BOTTOM, NO_VALUES or something
similar.

If you choose BOTTOM, for consistency also change UNKNOWN to TOP.

https://chromiumcodereview.appspot.com/10735051/diff/5001/lib/compiler/implem...
lib/compiler/implementation/ssa/types.dart:165: if (other.isUnknown()) return
HType.UNKNOWN;
Every union method needs to accomplish the bounded lattice axioms

   this union CONFLICTING => this
   this union this => this
   this union UNKNOWN => UNKNOWN

Would it make sense for the base class to have a union method that does these
tests and calls _union only when the types don't match the axioms?

https://chromiumcodereview.appspot.com/10735051/diff/5001/lib/compiler/implem...
lib/compiler/implementation/ssa/types.dart:171: if (!other.canBeNull()) return
HType.UNKNOWN;
This is too pessimistic.  HBoundedType should become nullable.

Powered by Google App Engine
This is Rietveld 408576698