Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Conversation

@dnfield
Copy link
Contributor

@dnfield dnfield commented Mar 2, 2020

@dnfield dnfield requested review from alexmarkov and zanderso March 2, 2020 22:31
@auto-assign auto-assign bot requested a review from gw280 March 2, 2020 22:31

bool _matches(Class node) {
return node.enclosingLibrary.canonicalName.name == classLibraryUri &&
return node.enclosingLibrary.importUri.toString() == classLibraryUri &&
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is more correct than using canonicalName, per @alexmarkov offline discussion.

Comment on lines +45 to +47
if (_cache.add(node)) {
super.defaultConstant(node);
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoids combinatorial explosion when viewing deeply nested constants.


@override
void defaultConstantReference(Constant node) {
defaultConstant(node);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the actual critical change for this fix.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Putting some comments here as it looks like github doesn't allow me to attach them to the corresponding lines.

  1. We should probably also visit all children recursively in visitInstanceConstantReference, e.g. consider replacing L71 with
  super.visitInstanceConstantReference(node);

and removing L73. This will cover cases like an InstanceConstant which has ListConstant in its field which has InstanceConstant in its element.

  1. Nit: typo in _visitedInstnaces

  2. Consider replacing kvp.key.canonicalName.name at L82 with kvp.key.asField.name.name.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done x3

}

class StaticConstInitializer {
static const List<Target> targets = <Target>[
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding a test with deeper nesting to test the caching optimization.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alexmarkov - can you help suggest a test for this, or point me to one in the Kernel compiler?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not entirely sure what we'd test here either - we don't have benchmarks for this and I'm not sure we want to set them up, and otherwise I guess we could expose number of visits done, but that puts us at the mercy up upstream changes in the kernel pretty tightly...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect, thanks - I took one of those and basically copied it into here with slight modifications for Flutter style.

Copy link
Contributor

@alexmarkov alexmarkov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM w/nits.


@override
void defaultConstantReference(Constant node) {
defaultConstant(node);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Putting some comments here as it looks like github doesn't allow me to attach them to the corresponding lines.

  1. We should probably also visit all children recursively in visitInstanceConstantReference, e.g. consider replacing L71 with
  super.visitInstanceConstantReference(node);

and removing L73. This will cover cases like an InstanceConstant which has ListConstant in its field which has InstanceConstant in its element.

  1. Nit: typo in _visitedInstnaces

  2. Consider replacing kvp.key.canonicalName.name at L82 with kvp.key.asField.name.name.

@dnfield
Copy link
Contributor Author

dnfield commented Mar 3, 2020

Going to land this on red to kick infra that flaked on a gsutil upload

Also, the web failure has nothing to do with this change - /cc @yjbanov FYI, felt tests failed on this change.

@dnfield
Copy link
Contributor Author

dnfield commented Mar 3, 2020

(I will wait for the build_and_test_linux_unopt_debug to pass, that one is relevant to this change)

@dnfield dnfield merged commit e54f2c8 into flutter:master Mar 3, 2020
@dnfield dnfield deleted the const_finder_fixes branch March 3, 2020 00:56
@yjbanov
Copy link
Contributor

yjbanov commented Mar 3, 2020

Thanks for the heads-up. build_and_test_linux_unopt_debug runs all of the same tests as the failing Linux Web Engine does. The problem must be with LUCI infra. The 10-second timeout is probably too tight for screenshot tests given that we have to clone the goldens repo. We'll bump that up to a couple of minutes (I'll file an issue). The golden comparison failure looks more concerning. We'll have to look into it too, if it happens again without the timeout.

engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Mar 3, 2020
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Mar 3, 2020
cbracken pushed a commit to flutter/flutter that referenced this pull request Mar 3, 2020
* 38f497c Roll src/third_party/skia 9dd0bd78b2d7..470f0637aeea (11 commits) (flutter/engine#16887)

* 5073cc7 Roll src/third_party/dart fbe9f6115d2f..0b819161d778 (3 commits) (flutter/engine#16888)

* df94213 Revert "Try rasterizing images and layers only once , even when their rasterization fails. Further enforce the same access threshold on layers as on Pictures. Previously layers would always be cached. The latter is a semantic change. (#16545)" (flutter/engine#16889)

* b230adb Roll src/third_party/skia 470f0637aeea..ded437003d0e (6 commits) (flutter/engine#16891)

* 63bdf3e Roll fuchsia/sdk/core/mac-amd64 from q2DAy... to WmA2M... (flutter/engine#16892)

* e54f2c8 Const finder missing `static const` list/map/set fields. (flutter/engine#16896)

* 10275fe Roll fuchsia/sdk/core/linux-amd64 from 9NHsJ... to uiAI5... (flutter/engine#16893)

* 8d046fa Roll src/third_party/skia ded437003d0e..b43cfa4d3f96 (7 commits) (flutter/engine#16894)

* 9c53993 Roll src/third_party/dart 0b819161d778..ca3ad264a649 (18 commits) (flutter/engine#16898)

* 6991dd9 Roll src/third_party/skia b43cfa4d3f96..8121d27b297c (10 commits) (flutter/engine#16899)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

const_finder is not finding all const instances

5 participants