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

Issue 1627333002: Optimize subclass/subtype queries (Closed)

Created:
4 years, 11 months ago by Johnni Winther
Modified:
4 years, 10 months ago
CC:
reviews_dartlang.org
Base URL:
https://github.com/dart-lang/sdk.git@master
Target Ref:
refs/heads/master
Visibility:
Public.

Description

Patch Set 1 #

Patch Set 2 : Cleanup #

Total comments: 4

Patch Set 3 : Updated cf. comments #

Patch Set 4 : Rebased #

Patch Set 5 : Fix forEachSubtype on interfaces. #

Patch Set 6 : Use strictSubtypeCount #

Total comments: 6
Unified diffs Side-by-side diffs Delta from patch set Stats (+1162 lines, -491 lines) Patch
M pkg/compiler/lib/src/elements/elements.dart View 2 chunks +3 lines, -1 line 0 comments Download
M pkg/compiler/lib/src/elements/modelx.dart View 2 chunks +4 lines, -2 lines 0 comments Download
M pkg/compiler/lib/src/js_backend/backend.dart View 1 2 3 chunks +4 lines, -5 lines 0 comments Download
M pkg/compiler/lib/src/js_backend/codegen/glue.dart View 1 chunk +1 line, -2 lines 0 comments Download
M pkg/compiler/lib/src/js_backend/runtime_types.dart View 1 chunk +1 line, -2 lines 0 comments Download
M pkg/compiler/lib/src/js_emitter/js_emitter.dart View 1 2 1 chunk +2 lines, -0 lines 0 comments Download
M pkg/compiler/lib/src/js_emitter/runtime_type_generator.dart View 4 chunks +5 lines, -4 lines 0 comments Download
M pkg/compiler/lib/src/ssa/builder.dart View 1 2 1 chunk +1 line, -2 lines 0 comments Download
M pkg/compiler/lib/src/types/union_type_mask.dart View 1 2 3 4 5 1 chunk +3 lines, -3 lines 0 comments Download
M pkg/compiler/lib/src/universe/class_set.dart View 1 2 3 4 12 chunks +217 lines, -43 lines 6 comments Download
M pkg/compiler/lib/src/world.dart View 1 8 chunks +110 lines, -27 lines 0 comments Download
M tests/compiler/dart2js/class_set_test.dart View 1 2 3 4 2 chunks +528 lines, -290 lines 0 comments Download
M tests/compiler/dart2js/world_test.dart View 1 2 3 4 3 chunks +283 lines, -110 lines 0 comments Download

Messages

Total messages: 16 (5 generated)
Johnni Winther
Main changes in universe/class_set.dart
4 years, 11 months ago (2016-01-26 09:35:41 UTC) #2
karlklose
LGTM. https://codereview.chromium.org/1627333002/diff/20001/pkg/compiler/lib/src/universe/class_set.dart File pkg/compiler/lib/src/universe/class_set.dart (right): https://codereview.chromium.org/1627333002/diff/20001/pkg/compiler/lib/src/universe/class_set.dart#newcode216 pkg/compiler/lib/src/universe/class_set.dart:216: /// [predicate] is a applied to subclasses if ...
4 years, 11 months ago (2016-01-26 12:13:32 UTC) #3
Johnni Winther
Committed patchset #3 (id:40001) manually as 285400c7a73f98da3e3076038d91ddf3ecbbba9e (presubmit successful).
4 years, 11 months ago (2016-01-26 13:44:36 UTC) #5
asgerf
It seems the test co19/LibTest/collection/DoubleLinkedQueue/iterator_A01_t01 broke after this landed.
4 years, 11 months ago (2016-01-26 14:20:44 UTC) #6
Johnni Winther
https://codereview.chromium.org/1627333002/diff/20001/pkg/compiler/lib/src/universe/class_set.dart File pkg/compiler/lib/src/universe/class_set.dart (right): https://codereview.chromium.org/1627333002/diff/20001/pkg/compiler/lib/src/universe/class_set.dart#newcode216 pkg/compiler/lib/src/universe/class_set.dart:216: /// [predicate] is a applied to subclasses if their ...
4 years, 11 months ago (2016-01-27 09:20:05 UTC) #8
Johnni Winther
PTAL at patches after rebase
4 years, 11 months ago (2016-01-27 12:26:26 UTC) #9
karlklose
LGTM.
4 years, 11 months ago (2016-01-27 12:29:56 UTC) #10
Johnni Winther
Committed patchset #6 (id:100001) manually as 8ab89a265301b787de7093737ee3c94232338c2a (presubmit successful).
4 years, 11 months ago (2016-01-27 13:34:09 UTC) #12
Siggi Cherem (dart-lang)
dbc https://codereview.chromium.org/1627333002/diff/100001/pkg/compiler/lib/src/universe/class_set.dart File pkg/compiler/lib/src/universe/class_set.dart (right): https://codereview.chromium.org/1627333002/diff/100001/pkg/compiler/lib/src/universe/class_set.dart#newcode581 pkg/compiler/lib/src/universe/class_set.dart:581: forEach ??= ForEach.CONTINUE; nit: here and elsewhere, I ...
4 years, 10 months ago (2016-02-06 00:17:27 UTC) #14
Siggi Cherem (dart-lang)
https://codereview.chromium.org/1627333002/diff/100001/pkg/compiler/lib/src/universe/class_set.dart File pkg/compiler/lib/src/universe/class_set.dart (right): https://codereview.chromium.org/1627333002/diff/100001/pkg/compiler/lib/src/universe/class_set.dart#newcode450 pkg/compiler/lib/src/universe/class_set.dart:450: bool get hasOnlyInstantiatedSubclasses { I was looking into something ...
4 years, 10 months ago (2016-02-09 23:40:12 UTC) #15
Johnni Winther
4 years, 10 months ago (2016-02-10 09:32:08 UTC) #16
Message was sent while issue was closed.
Comments addressed in https://codereview.chromium.org/1683063002

https://codereview.chromium.org/1627333002/diff/100001/pkg/compiler/lib/src/u...
File pkg/compiler/lib/src/universe/class_set.dart (right):

https://codereview.chromium.org/1627333002/diff/100001/pkg/compiler/lib/src/u...
pkg/compiler/lib/src/universe/class_set.dart:450: bool get
hasOnlyInstantiatedSubclasses {
On 2016/02/09 23:40:12, Siggi Cherem (dart-lang) wrote:
> I was looking into something else and run into this part of the change. I
think
> I understand how this works now, but I wanted to confirm/double check with
you.
> 
> In particular, I was thinking of this example:
> 
>   class B extends A {}
>   class C extends B {}
>   class D implements B {}
>   main() => print([new A(), new B(), new C(), new D()]);
> 
> I expect hasOnlyInstantiatedSubclasses for `A` to be false. I believe that's
the
> case here because the 'directSubtypes' includes subtypes of subclasses too, so
> in this case `D` is in the subtypes list of `A`'s class-set, and because of
that
> we'll say false here.
> 
> Is that right?

Yes. The cause is that implements is transitive. The
[hasOnlyInstantiatedSubclasses] is checked to know if `subtype of A` means
`extends A`, and because of `D` we say no. We should, though, rename
[directSubtypes] to something else.

https://codereview.chromium.org/1627333002/diff/100001/pkg/compiler/lib/src/u...
pkg/compiler/lib/src/universe/class_set.dart:581: forEach ??= ForEach.CONTINUE;
On 2016/02/06 00:17:26, Siggi Cherem (dart-lang) wrote:
> nit: here and elsewhere, I rather keep the variable with a single assignment
and
> use ?? instead, that makes it more obvious that it is a default value. In
other
> words:
> 
>   var x = something ?? defaultValue;
> 
> instead of 
> 
>   var x = something;
>   x ??= defaultValue;

Will do. Code motion caused this ;-)

https://codereview.chromium.org/1627333002/diff/100001/pkg/compiler/lib/src/u...
pkg/compiler/lib/src/universe/class_set.dart:859: enum ForEach {
On 2016/02/06 00:17:26, Siggi Cherem (dart-lang) wrote:
> naming nit: could we rename this to something that describes what this is,
> rather than where it is used?
> 
> Some ideas:
> - enum IterationControl { CONTINUE, STOP, SKIP_SUBCLASSES }
> - enum IterationStep    { NEXT_CLASS, STOP, NEXT_SUBCLASS }
> 
> I like the latter, since the corresponding local variable names in the code
> above become more readable. For example:
> 
> var nextStep =
>     node.forEachSubclass(f, mask, strict: strict) ?? IterationStep.NEXT_CLASS;
> 
> if (nextStep == ForEach.NEXT_CLASS && _directSubtypes != null) {
>   for (ClassHierarchyNode subclass in _directSubtypes) {
>     var subStep = subclass.forEachSubclass(f, mask);
>     if (subStep == IterationStep.STOP) return IterationStep.STOP;
>   }
> }
> 
> return nextStep;

If find the latter confusing but like enum class name.

Powered by Google App Engine
This is Rietveld 408576698