Commit Graph

7128 Commits

Author SHA1 Message Date
pq fba5cbc425 Analyzer 0.27.4-alpha.9 (API fixes) (#26562).
Restores `EmbedderUriResolver` API.

Addresses breakages in `dartdoc` and any other downstream dependencies.

See: https://github.com/dart-lang/sdk/issues/26562.

BUG=
R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org/2021453003 .
2016-05-29 06:57:42 -07:00
pq c77781d27e Precompute IgnoreInfo in Scanner.
The existing support for `ignore` filtering requires the error generator task to depend on parsed sources as input.  As it happens, these parse results get flushed between the parse task and error generation, meaning that they need to be recomputed for EVERY source.  This change moves ignore detection into the scanner which now produces a new result (akin to LineInfo) that can be used at error generation time (and will not be flushed).

Local profiling shows this change making a roughly 10% improvement to overall analysis time for `flutter analyze`.  Server-based analysis should enjoy a similar benefit.

A few thoughts for further refinement:

* can we NOT produce ignore results for sources whose errors we will not generate?
* can we (and should we) improve the regexp-based approach?

BUG=
R=brianwilkerson@google.com, scheglov@google.com

Review URL: https://codereview.chromium.org/2011183004 .
2016-05-27 14:52:20 -07:00
Konstantin Shcheglov 3b27a0368d Rewrite checker_test using reflective tests.
It is just a mechanical transformation.
The only kind of changes to the test case code is intentation.

R=brianwilkerson@google.com
BUG=

Review URL: https://codereview.chromium.org/2024433002 .
2016-05-27 14:49:14 -07:00
Konstantin Shcheglov 7ce8e2744f Resynthesize local variables lazily.
R=brianwilkerson@google.com, paulberry@google.com
BUG=

Review URL: https://codereview.chromium.org/2017173002 .
2016-05-27 14:05:58 -07:00
Sam Rawlins c2794f634a Add YieldStatement support to ExitDetector
BUG=https://github.com/dart-lang/sdk/issues/26553
R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org/2010283002 .
2016-05-27 11:44:00 -07:00
Paul Berry 4b2742448d Remove skipBrokenAstInference flag (it is no longer needed).
R=scheglov@google.com

Review URL: https://codereview.chromium.org/2013193003 .
2016-05-27 09:04:12 -07:00
Paul Berry 84c5cd016e Fix handling of identifier sequences starting with a function parameter.
R=scheglov@google.com

Review URL: https://codereview.chromium.org/2011323002 .
2016-05-27 08:45:51 -07:00
John Messerly 5fcf79c618 Improve Future<T>.then<R> inference
This is not a general fix, but it's a simplest fix I could come up with.

It fixes the common problem of downwards and upwards inference conflicting. On the way down, we use the return context, but on the way back up, we ignore it for `Future.then`. This allows inference to conclude an instantiation like:

    f.then/*<Future<int>>*/(...)

Then, thanks to Future flattening, we get the right return type as well (return type is Future<R>, which strong mode interprets as Future< flatten(R) >, so it works out).

Many of the other example cases are not fixed, though. Downwards inference will only push down `R` not `Future<R> | R`, so if the Future<R> branch was needed, for example: Future<Lint<int>> g = f.then(() => new Future.value([])) will not infer the `<int>[]` allocation nor the `Future<List<int>>` type. I have a work-in-progress that fixes those but introduces a special union type notion for `Future<R> | R`, and I'm not sure we're ready for that.

R=leafp@google.com

Review URL: https://codereview.chromium.org/2016793002 .
2016-05-26 17:02:49 -07:00
Paul Berry f251da2dc9 Make AST-based type inference handle <bottom> consistently.
The non-AST-based type inference engine has the following quirk.  With
the source code:

var x = null;

The type of `x` is inferred as `dynamic`, whereas the type of the
synthetic initializer function associated with `x` is inferred as `()
-> <bottom>`.

This CL makes the AST-based type inference engine act in the same way
for consistency.

In the future we may want to change both engines to consistently infer
`dynamic`.

R=scheglov@google.com

Review URL: https://codereview.chromium.org/2014383003 .
2016-05-26 15:21:31 -07:00
Paul Berry be7db60753 Implement AST-based type inference involving expression-type closures.
R=scheglov@google.com

Review URL: https://codereview.chromium.org/2016873002 .
2016-05-26 14:31:24 -07:00
Paul Berry 20056c3f45 In AST-based type inference, use function elements rather than variable elements.
This paves the way for including closures in type inference, since
closures are function elements that don't have an associated variable.

R=scheglov@google.com

Review URL: https://codereview.chromium.org/2014893004 .
2016-05-26 12:46:30 -07:00
Paul Berry 0548ae7f3f Fix circularity detection for AST-based type inference in the presence of closures.
R=scheglov@google.com

Review URL: https://codereview.chromium.org/2015833004 .
2016-05-26 12:00:58 -07:00
Konstantin Shcheglov 039f2a05c4 Resynthesize some more types lazily.
R=paulberry@google.com
BUG=

Review URL: https://codereview.chromium.org/2010143002 .
2016-05-26 11:45:23 -07:00
Konstantin Shcheglov cdc0b17246 Resynthesize ParameterElementImpl.parameterKind lazily.
R=brianwilkerson@google.com
BUG=

Review URL: https://codereview.chromium.org/2015963002 .
2016-05-26 10:08:48 -07:00
Paul Berry e71e111b24 Summarize references to closure parameters properly.
R=scheglov@google.com

Review URL: https://codereview.chromium.org/2013093002 .
2016-05-26 10:04:27 -07:00
Paul Berry dcadf0b35c Store expression function closures summaries when needed for type inference.
R=scheglov@google.com

Review URL: https://codereview.chromium.org/2012263002 .
2016-05-26 09:26:40 -07:00
Konstantin Shcheglov ac7f892cc4 Resynthesize FieldFormalParameterElementImpl(s) lazily.
And also resynthesize parameter types lazily.

R=brianwilkerson@google.com, paulberry@google.com
BUG=

Review URL: https://codereview.chromium.org/2016543002 .
2016-05-26 08:36:41 -07:00
Paul Berry 8d43e02174 Migrate UnlinkedParam.defaultValue to UnlinkedExecutable.bodyExpr.
To do AST-based type inference involving function closures, we have
added a `bodyExpr` field to UnlinkedExecutable.  Since every
UnlinkedParam with a default value has a corresponding
UnlinkedExecutable representing its initializer, it makes sense to
store the constant expression there for uniformity.

R=scheglov@google.com

Review URL: https://codereview.chromium.org/2010993002 .
2016-05-26 08:12:39 -07:00
Paul Berry f1bd126241 Migrate UnlinkedVariable.constExpr to UnlinkedExecutable.bodyExpr.
To do AST-based type inference involving function closures, we will
need to be able to store closure body expressions in unlinked
summaries--this requires adding a `bodyExpr` field to
UnlinkedExecutable.  Since every UnlinkedVariable with a body
expression has a corresponding UnlinkedExecutable representing its
initializer, it makes sense to store the constant expression there for
uniformity.

R=scheglov@google.com

Review URL: https://codereview.chromium.org/2013883003 .
2016-05-25 15:22:49 -07:00
Paul Berry b1afdec64c Fix type errors introduced by 8fdeb785fd
TBR=srawlins@google.com

Review URL: https://codereview.chromium.org/2016533002 .
2016-05-25 15:20:42 -07:00
Sam Rawlins 8fdeb785fd Add label support to ExitDetector
BUG=https://github.com/dart-lang/sdk/issues/26534
R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org/2008363002 .
2016-05-25 14:04:22 -07:00
Paul Berry 3d00d5d7d1 Fix AST-based type inference via interfaces.
R=scheglov@google.com

Review URL: https://codereview.chromium.org/2012023002 .
2016-05-25 13:27:41 -07:00
pq 53fe39137f Embedder support refactoring (phase 1).
A bunch of changes to pave the way for emebdder SDK summary creation.

* Moves _embedder.yaml processing into the embedder SDK (out of the resolver).
* Changes EmbedderUriResolver to compose rather than extend a DartUriResolver.
* Fixes the wierd handling (dropping to add back) of `dart:` URIs.
* Fixes the incorrect overriding docs for `SDKLibraryImpl.shortName`.
* Updates embedder test to include a definition of `dart:core` in anticipation of adding some embedder SDK tests.

Some API work TODO in a follow-up CL (notably the way we check for the presence of embedders by querying the resolver is odd).

BUG=
R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org/2009303002 .
2016-05-25 10:52:53 -07:00
Brian Wilkerson a3ed9fe569 Optimize more megamorphic dispatch sites
R=scheglov@google.com

Review URL: https://codereview.chromium.org/2015513003 .
2016-05-25 10:49:11 -07:00
Brian Wilkerson 7eddfb7394 Fix cross-partition dependency handling (issue 26466)
R=scheglov@google.com

Review URL: https://codereview.chromium.org/2008133002 .
2016-05-25 07:43:01 -07:00
Paul Berry b3d6bf252c Fix some corner cases of inferring type parameters from bounds.
R=scheglov@google.com

Review URL: https://codereview.chromium.org/2002353006 .
2016-05-24 15:17:00 -07:00
Sam Rawlins d948ea2c17 Don't short circuit visiting else
BUG=https://github.com/dart-lang/sdk/issues/26517
R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org/2002353003 .
2016-05-24 06:53:56 -07:00
Sam Rawlins c0b0c7be81 Revert "If an if or do statement always exits, following statements are dead."
This reverts commit d7833e1c1f.

BUG=

Review URL: https://codereview.chromium.org/2004223002 .
2016-05-23 15:15:05 -07:00
Sam Rawlins d7833e1c1f If an if or do statement always exits, following statements are dead.
BUG=https://github.com/dart-lang/sdk/issues/16420
R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org/1943443002 .
2016-05-23 13:20:48 -07:00
Konstantin Shcheglov 635dc5fabf Resynthesize exports lazily.
This and the previous import changes made DDC about 18% faster, down
from 1100 ms to 900 ms.

R=paulberry@google.com
BUG=

Review URL: https://codereview.chromium.org/2002163002 .
2016-05-23 11:05:29 -07:00
Konstantin Shcheglov caac40c875 Make imports resynthesizing completely lazy.
R=paulberry@google.com
BUG=

Review URL: https://codereview.chromium.org/2001903002 .
2016-05-23 08:56:46 -07:00
Konstantin Shcheglov 5f7f716b93 Fix for FastUri.hashCode and hasAuthorizy (to fix ==).
R=brianwilkerson@google.com, paulberry@google.com
BUG=

Review URL: https://codereview.chromium.org/2004793002 .
2016-05-23 08:44:10 -07:00
Konstantin Shcheglov 6db29e9468 Resynthesize most of the ImportElementImpl lazily.
R=paulberry@google.com
BUG=

Review URL: https://codereview.chromium.org/2003733003 .
2016-05-20 17:16:40 -07:00
Konstantin Shcheglov d78cf637b1 Use FastUri instead of Uri in analyzer.
This makes DDC compilation about 25% faster - from 1550 to 1200 ms.

R=brianwilkerson@google.com, paulberry@google.com
BUG=

Review URL: https://codereview.chromium.org/2003633002 .
2016-05-20 10:33:20 -07:00
Konstantin Shcheglov cb4bb69ec3 Make ExecutableElementImpl implement TypeParameterizedElementMixin.
R=paulberry@google.com
BUG=

Review URL: https://codereview.chromium.org/2002483002 .
2016-05-20 06:59:42 -07:00
Konstantin Shcheglov 0f441fa3ea Use BufferContext + offset instead of BufferPointer.
This lets us avoid creating tens of millions of BufferPointer instances
and makes DDC compilation about 6% faster.

R=paulberry@google.com
BUG=

Review URL: https://codereview.chromium.org/1998833002 .
2016-05-19 20:08:26 -07:00
Konstantin Shcheglov aa4c42c7f7 Fix for resynthesizing default values referencing type parameters.
R=paulberry@google.com
BUG=

Review URL: https://codereview.chromium.org/1993333003 .
2016-05-19 14:58:46 -07:00
Konstantin Shcheglov 458f82c207 Use String.fromCharCodes() instead of UTF8.decode() for Latin strings.
This makes DDC compilation another 5% faster.

R=paulberry@google.com
BUG=

Review URL: https://codereview.chromium.org/1999433002 .
2016-05-19 13:21:34 -07:00
Konstantin Shcheglov 54e58c7a44 Build top-level variables and property accessors lazily.
This makes DDC compilation of the latest big test codebase about 25%
faster - from 2900 ms to 2196 ms.

We also have to compute lazily public and export namespaces.

R=paulberry@google.com, brianwilkerson@google.com
BUG=

Review URL: https://codereview.chromium.org/1995763003 .
2016-05-19 10:12:36 -07:00
Paul Berry 54350526b9 Fix generation of variable initializer synthetic functions in summary AST linker.
R=scheglov@google.com

Review URL: https://codereview.chromium.org/1994673003 .
2016-05-18 10:22:43 -07:00
Paul Berry 7ed17435bd Fix linker's handling of malformed function references.
R=scheglov@google.com

Review URL: https://codereview.chromium.org/1989943002 .
2016-05-18 10:02:29 -07:00
Sam Rawlins cd34de9e0e Adjust do visit in ExitDetector
BUG=https://github.com/dart-lang/sdk/issues/26473
R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org/1985173003 .
2016-05-17 17:11:53 -07:00
Konstantin Shcheglov b0f2d80d5a Delay resynthesizing metadata to Impl classes.
Now we can restore the disabled metadata validation.

R=paulberry@google.com, brianwilkerson@google.com
BUG=

Review URL: https://codereview.chromium.org/1983293002 .
2016-05-17 14:18:16 -07:00
Konstantin Shcheglov e2ed7243e2 Move TypeParameterizedElementForLink and TypeParameterElementForLink to impl.
There is much more to do - do the same not just for classes, but also
for typedefs and executables; this is just minimally valuable (maybe)
change.

R=brianwilkerson@google.com, paulberry@google.com
BUG=

Review URL: https://codereview.chromium.org/1986853003 .
2016-05-17 12:51:31 -07:00
Paul Berry 39d184f2f3 Change ClassElementForLink.getContainedName() to include non-static members.
This is necessary because ClassElementForLink.getContainedName() is used
to access non-static members when resynthesizing references from a
summary.

R=scheglov@google.com

Review URL: https://codereview.chromium.org/1983153002 .
2016-05-17 11:34:09 -07:00
John Messerly 67cb710631 use GLB function in strong mode inference
R=leafp@google.com

Review URL: https://codereview.chromium.org/1975753004 .
2016-05-17 11:04:40 -07:00
Paul Berry c26995c6b9 Add preliminary local function reference support to the AST summary linker.
R=scheglov@google.com

Review URL: https://codereview.chromium.org/1985063003 .
2016-05-17 10:20:25 -07:00
Paul Berry f5ffdf1604 In summary AST linker, fix top level isStatic getters.
R=scheglov@google.com

Review URL: https://codereview.chromium.org/1981363002 .
2016-05-17 10:19:05 -07:00
Konstantin Shcheglov 6ef389ab94 Test resynthesized modifiers using accessors.
It is still pain, but when I try to migrate some implementation
classes to using serialized information it would be nice not to
implement also hasModifier() for every hasX getter.

R=paulberry@google.com
BUG=

Review URL: https://codereview.chromium.org/1979343002 .
2016-05-16 11:46:51 -07:00
Brian Wilkerson 3024554b3c Improve type information and minor clean up
R=scheglov@google.com

Review URL: https://codereview.chromium.org/1977413002 .
2016-05-16 08:43:58 -07:00