Commit Graph

244 Commits

Author SHA1 Message Date
Johnni Winther c987c9e5a7 Propagate cached static types to inference and ssa
+ use it to skip unnecessary casts.

Change-Id: Ib503a6fb74907f7e6367c8ee44548268e03045cf
Reviewed-on: https://dart-review.googlesource.com/c/86560
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2018-12-07 19:57:05 +00:00
Sigmund Cherem 2a39f63c2a Record deferred accesses in kernel world impacts and use it for splitting only
under a flag.

This reapplies commit 70e1517d98, but adds a flag
to gradually migrate users before enabling it by default.

Patchset 1 matches the old CL

Change-Id: Iaf7ee3dec8d4aa658f0b4334549b507e5a610a68
Reviewed-on: https://dart-review.googlesource.com/c/86444
Reviewed-by: Stephen Adams <sra@google.com>
Commit-Queue: Sigmund Cherem <sigmund@google.com>
2018-12-06 23:20:38 +00:00
Sigmund Cherem adf595dc62 Revert "Record deferred accesses in kernel world impacts and use it for splitting."
This reverts commit 70e1517d98.

Reason for revert: saw unexpected regression on acx-gallery as well. I'd like to look in more detail and reland if it is justified.

Original change's description:
> Record deferred accesses in kernel world impacts and use it for splitting.
> 
> On large apps this cuts down the time spent in the deferred loading algorithm by
> two thirds. To address issue #35311, this CL keeps things sound and may load in
> the main unit more code.
> 
> On some large apps, it appears the effect of this change is not that measurable,
> and we even see an improvement. I'm still validating the data, but I believe
> this is in part because there was a different bug
> in the previous algorithm: constructors were never deferred
> because we were looking for the constructor-name, usually '', instead of the
> enclosing class name.
> 
> My current data is that, the main unit of some large app shows:
>   old algorithm:        13,213,191
>   sound algorithm:      13,150,145
>   unsound algorithm*:   13,147,282
>   fixed old algorithm:  13,146,509
> 
> * ignoring return type of closures
> 
> 
> Change-Id: I7d3e525393ef38979b26051b4d354fc1001560af
> Reviewed-on: https://dart-review.googlesource.com/c/85725
> Commit-Queue: Sigmund Cherem <sigmund@google.com>
> Reviewed-by: Johnni Winther <johnniwinther@google.com>

TBR=johnniwinther@google.com,sigmund@google.com

Change-Id: I6992279bebcc99578f94087a17d6c327b32a0876
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/86246
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Sigmund Cherem <sigmund@google.com>
2018-12-05 19:16:32 +00:00
Sigmund Cherem 70e1517d98 Record deferred accesses in kernel world impacts and use it for splitting.
On large apps this cuts down the time spent in the deferred loading algorithm by
two thirds. To address issue #35311, this CL keeps things sound and may load in
the main unit more code.

On some large apps, it appears the effect of this change is not that measurable,
and we even see an improvement. I'm still validating the data, but I believe
this is in part because there was a different bug
in the previous algorithm: constructors were never deferred
because we were looking for the constructor-name, usually '', instead of the
enclosing class name.

My current data is that, the main unit of some large app shows:
  old algorithm:        13,213,191
  sound algorithm:      13,150,145
  unsound algorithm*:   13,147,282
  fixed old algorithm:  13,146,509

* ignoring return type of closures


Change-Id: I7d3e525393ef38979b26051b4d354fc1001560af
Reviewed-on: https://dart-review.googlesource.com/c/85725
Commit-Queue: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2018-12-05 17:40:27 +00:00
Johnni Winther c18225d98c Implement guarded type promotion in dart2js
Change-Id: Ic284990c73ff5cb4b201ed4bbcc57ec0d7b0b66f
Reviewed-on: https://dart-review.googlesource.com/c/85923
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2018-12-05 11:52:26 +00:00
Johnni Winther 9cfab12d36 Reorganize imports to decouple dart2js_target.dart from dart2js
Change-Id: Ie958dbbf75f5cac20074b2a64a4eefb9de636116
Reviewed-on: https://dart-review.googlesource.com/c/85290
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2018-11-27 09:15:34 +00:00
Johnni Winther e62951fd3d Use assigned variables data to infer static types for effectively final locals.
Change-Id: I3687d28628b0476c6a848f135bbda97e594449c2
Reviewed-on: https://dart-review.googlesource.com/c/84629
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2018-11-21 09:16:21 +00:00
Johnni Winther 3bf6a550ea Add static type tests
Change-Id: I4282a1261ad4f4f4641750bd5ca492e5a943b6f0
Reviewed-on: https://dart-review.googlesource.com/c/84628
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2018-11-20 14:02:39 +00:00
Johnni Winther d544a5d3b6 Compute variable allocation data during closure scope visitor.
Change-Id: I71814a30ac469cbcfea5bf6804f6762c2e039c64
Reviewed-on: https://dart-review.googlesource.com/c/84625
Reviewed-by: Stephen Adams <sra@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2018-11-20 14:02:39 +00:00
Johnni Winther b943fa897c Move closure scope classes to ir/
Change-Id: Ib14696e9ab8572e30343e0880c1d028cfc26b377
Reviewed-on: https://dart-review.googlesource.com/c/84621
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2018-11-20 14:02:39 +00:00
Johnni Winther 5cb37ff5b8 Collapse KernelToElementMapImpl hierarchy
Change-Id: Ia6e14e0890709448443c97561c8641d0379a3536
Reviewed-on: https://dart-review.googlesource.com/c/84001
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2018-11-09 20:20:41 +00:00
Johnni Winther a9e2af657f Refactor static type computation
This decouples the computation of static types from the kernel impact
visitor and prepares for flow sensitive static types (i.e. guarded type
promotion).

Change-Id: Ic8b6283bd64d535ff49b1d6fee2e5ae38d48a2d9
Reviewed-on: https://dart-review.googlesource.com/c/83381
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2018-11-08 13:16:42 +00:00
Johnni Winther 9a1a7763f1 Skip checking of casts in metadata
This avoids assertion failure on js-interop class computation.

Change-Id: I040c6d63dbc427d239eb97c22dc8c3c67a6fb9fd
Reviewed-on: https://dart-review.googlesource.com/c/82722
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2018-11-05 10:40:58 +00:00
Johnni Winther 672a049303 Move KClosedWorldImpl to its own library
+ and merge it with its mixin

Change-Id: Ib0eea07cee0bed602be90cf4a324bd423cba0a86
Reviewed-on: https://dart-review.googlesource.com/c/82720
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2018-11-02 21:11:31 +00:00
Peter von der Ahé 248954117a Consolidate dart2js front-end dependencies
Also, convert dart2js to use onDiagnostic.

Change-Id: Ifdf89349eaf2ebe8cfcd1994712b3d1be2dd4197
Reviewed-on: https://dart-review.googlesource.com/77400
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2018-10-02 12:34:28 +00:00
Johnni Winther 41a875f420 Fix (super)mixins issues
Change-Id: I5892f2fec7fc7b7449fb600c74e4d105dc0f4bbe
Reviewed-on: https://dart-review.googlesource.com/77180
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Auto-Submit: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2018-09-28 23:03:24 +00:00
Johnni Winther 82b3501c3c Fix supermixin handling in dart2js
Change-Id: I77251a1b90f62e1c103f018bdd15a7ae385008ee
Reviewed-on: https://dart-review.googlesource.com/76941
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Auto-Submit: Johnni Winther <johnniwinther@google.com>
2018-09-27 11:44:53 +00:00
Kevin Millikin c9b05d3f1f Allow super calls in mixin declarations
Allow super calls to occur in mixin declarations if they target a
method from any of the superclass constraint interfaces.

Instead of compiling the Dart mixin declaration
    mixin M on S0, S1 {...}
to Kernel:
    abstract class _M&S0&S1 = S0 with S1;
    abstract class M extends _M&S0&S1 { ... }
we compile it to Kernel:
    abstract class _M&S0&S1 implements S0, S1 {}
    abstract class M extends _M&S0&S1 { ... }
because the former is not symmetrical with respect to S0 and S1.  It
will prefer a method from the 'mixin' S1 over one from S0 which can
give a compile-time error if the method from S0 is more general.

Modify mixin inference to support the new compilation of mixin
declarations.  It still has to support old-style VM super mixins until
support for those is removed from the VM.

Change-Id: Ib945aa11cc19c457b07bc802beae10d1663ff6b7
Reviewed-on: https://dart-review.googlesource.com/76141
Reviewed-by: Jenny Messerly <jmesserly@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Commit-Queue: Kevin Millikin <kmillikin@google.com>
2018-09-27 10:19:30 +00:00
Johnni Winther 4a58112a7c Move kernel_impact.dart from ssa/ to kernel/
Change-Id: I284aaea0f2743017ec2d0042de7453f479586f03
Reviewed-on: https://dart-review.googlesource.com/76666
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2018-09-27 09:00:56 +00:00
Johnni Winther e9c949372e Remove unused parts of J/K*Env classes
Change-Id: I5aa5f5cb5504f5479ab9b18960246fb68b56d02c
Reviewed-on: https://dart-review.googlesource.com/76665
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2018-09-27 08:17:56 +00:00
Johnni Winther 4659cb9480 Fully split JsToElementMap and KernelToElementMap
- including the first benefit: Removing Class/Member definitions from the K-world.

Change-Id: I440dce2e37758dd276a417851f67a1403f6535a0
Reviewed-on: https://dart-review.googlesource.com/76641
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2018-09-27 08:17:56 +00:00
Johnni Winther 1652850381 Compute static types during impact computation
This speeds up the computation of static type by avoiding repeated
visits of subtrees. The change also paves the way for improving
static type computation beyond what is specified. For instance by
handling negative type promotions.

Change-Id: Ifa3ea0f9760251f43cbbcc97b684004741a97b11
Reviewed-on: https://dart-review.googlesource.com/76020
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
2018-09-25 09:58:19 +00:00
Johnni Winther 4b312b2b8c Support multiple superclasses in the mixin on clause.
Change-Id: I23c613170be8fdf3c4a7ace560d71161b3e7320f
Reviewed-on: https://dart-review.googlesource.com/75881
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
2018-09-25 08:26:38 +00:00
Johnni Winther cf5cdea808 Add J/K versions CommonElements and ElementEnvironment
This is a step towards separating the element map implementations.

Change-Id: Iaf8cee48bd0c127a981b1661773d9036b419fecf
Reviewed-on: https://dart-review.googlesource.com/75300
Reviewed-by: Stephen Adams <sra@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2018-09-20 07:37:32 +00:00
Johnni Winther 5dff98f960 Use inferred map type arguments in element map fields
+ split method creation from lookup in kernel element map.

Change-Id: If375d8ffdb12cde9180476828a9324e372d5738f
Reviewed-on: https://dart-review.googlesource.com/74721
Reviewed-by: Stephen Adams <sra@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2018-09-18 06:51:15 +00:00
Johnni Winther 2da165a62d Stop compilation early on CFE compile-time errors
Change-Id: Ie93af5880bbd0b9f0c72aa6c1832550bf9025595
Reviewed-on: https://dart-review.googlesource.com/75160
Reviewed-by: Stephen Adams <sra@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2018-09-18 06:50:55 +00:00
Johnni Winther 625d679c8b Remove ElementCreatorMixin from JsKernelToElementMap
Change-Id: I2ff9014305177a1f0060626062fadf8276b74979
Reviewed-on: https://dart-review.googlesource.com/74400
Reviewed-by: Stephen Adams <sra@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2018-09-13 07:32:15 +00:00
Johnni Winther 5ab5c00ea4 Compute annotations in the K-World
This ensures that entities only used in metadata is part of the K-world
and doesn't have to be created late in (only) the J-world.

Change-Id: If9a264c51fba99093a196538fb655b1d5fafd47a
Reviewed-on: https://dart-review.googlesource.com/73880
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
2018-09-11 11:10:37 +00:00
Johnni Winther db1570bdcd Split element maps for J/K further
* The J model is in the /js_model/ folder and KernelToElementMapForBuilding is renamed
  to JsToElementMap.
* The K model is in the /kernel/ folder and KernelToElementMapForImpact is renamed
  to KernelToElementMap.
* Code shared between JsToElementMap and KernelToElementMap is in the /ir/ folder using
  the interface IrToElementMap internally.
* KernelToElementMap and JsToElementMap do _not_ implement IrToElementMap so all code
  that is not part of the implementation must explicitly use one or the other.
* Both KernelToElementMap and JsToElementMap extend KernelToElementMapBase
  but this will be changed in a follow-up.

Change-Id: Id6b762984d25354477cb099dc2f8301b83a7ba07
Reviewed-on: https://dart-review.googlesource.com/73382
Reviewed-by: Stephen Adams <sra@google.com>
2018-09-11 11:10:37 +00:00
Johnni Winther f8633aeae7 Move KernelToElementMapForBuilding and friends to js_model/element_map*
- this is part of splitting element map classes between K/J worlds

Change-Id: I82e4373f0849b12cb0d1586b77bfa411f55d26a7
Reviewed-on: https://dart-review.googlesource.com/72822
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
2018-09-10 14:44:02 +00:00
Johnni Winther 88bff737f9 Inline element map mixins that are only applied once
Change-Id: Ibfadf6ee6aaf5ec184b4b7b71cb8767cd968a237
Reviewed-on: https://dart-review.googlesource.com/72820
Reviewed-by: Stephen Adams <sra@google.com>
2018-09-10 14:44:02 +00:00
Johnni Winther 8c03bff4bb Step towards splitting element maps in K/J versions
* Refactor ClassData, remove ensureCallType
* Make kernel/types.dart its own library

Change-Id: I280f7de0b78f9a14551f0ae0548452693a6d0d05
Reviewed-on: https://dart-review.googlesource.com/72761
Reviewed-by: Stephen Adams <sra@google.com>
2018-09-10 14:44:02 +00:00
Johnni Winther e311e12bc4 Move all data for collection for testing behind one flag
- to ensure that we don't retain unneeded data in production

Change-Id: I2f702e040ed99cb8540a5b60efcf88a2c6b33af0
Reviewed-on: https://dart-review.googlesource.com/72720
Reviewed-by: Stephen Adams <sra@google.com>
2018-09-10 14:44:02 +00:00
Johnni Winther f3036f4e17 Support supermixins in dart2js
The tests use the old syntax which CFE currently (wrongfully) allows for dart2js.

Change-Id: Ia4dde9e6e1444d8ec22905c36209049bd4161faa
Reviewed-on: https://dart-review.googlesource.com/72443
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
2018-09-10 08:16:57 +00:00
Johnni Winther 5e263044e8 Enable StrongModeWorldStrategy
This makes closed world computation take the static type of the receiver
into account and removes non-live members from the J-world.

Change-Id: I5547aaae4685c6417a94916df0bc4e621296ce8d
Reviewed-on: https://dart-review.googlesource.com/72643
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
2018-09-10 07:09:07 +00:00
Johnni Winther 814738b273 Remove CompilerOptions.strongMode/enableTypeAssertions/trustTypeAnnotations
Change-Id: I4a51b081f42d76f12c70c140286c28375fcbd5ce
Reviewed-on: https://dart-review.googlesource.com/70515
Reviewed-by: Stephen Adams <sra@google.com>
2018-08-21 08:21:02 +00:00
Sigmund Cherem 11f3c57e9c Fix deferred type literals and typedefs
Closes https://github.com/dart-lang/sdk/issues/33890

Change-Id: I3a154d4de46747f3ad905de889f14188fdfff50a
Reviewed-on: https://dart-review.googlesource.com/65442
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Sigmund Cherem <sigmund@google.com>
2018-07-18 18:28:21 +00:00
Johnni Winther 1c673b1046 Include bounds in type literals
Change-Id: Ieb3e5b09e88c98f8943a6e7ca9031c8a6ab776e1
Reviewed-on: https://dart-review.googlesource.com/63820
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2018-07-09 12:24:04 +00:00
Johnni Winther 04168fa922 Move more methods to ClassHierarchy.
Change-Id: I6f7f0266a77db1e64a40307a4878bfd9b1ca5f07
Reviewed-on: https://dart-review.googlesource.com/61932
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2018-07-06 22:02:57 +00:00
Johnni Winther bb69cc15cb Add ClassHierarchy to share code between J/KClosedWorld (second attempt)
+ improve the commonSubclasses implementation to support the
implementation of FlatTypeMask.intersection and RuntimeEquals.equals
computation. FlatTypeMask.intersection is now ~20% faster.

Change-Id: I0b452afd260ab3b0598ed4d67f07a55ea96d2756
Reviewed-on: https://dart-review.googlesource.com/63560
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2018-07-04 09:00:28 +00:00
Stephen Adams 50fe42a886 Reduce use of putIfAbsent
Change-Id: I2088d80126bd5af09c0091c768c381b13733aa1e
Reviewed-on: https://dart-review.googlesource.com/62021
Commit-Queue: Stephen Adams <sra@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2018-06-27 02:58:38 +00:00
Stephen Adams e0905b979a Revert "Add ClassHierarchy to share code between J/KClosedWorld"
This reverts commit a8e930caf3.

Compile time regression on some large apps.

TBR=johnniwinther@google.com

Change-Id: Ic1b736a5d50814ed8b8d24a9dc4a2d910e5f70df
Reviewed-on: https://dart-review.googlesource.com/62446
Reviewed-by: Stephen Adams <sra@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2018-06-26 23:40:48 +00:00
Johnni Winther a8e930caf3 Add ClassHierarchy to share code between J/KClosedWorld
+ improve the commonSubclasses implementation to support the
implementation of FlatTypeMask.intersection and RuntimeEquals.equals
computation.

Change-Id: I51c4d229e9dc6d5de101aff33e56bb44bf93bc0d
Reviewed-on: https://dart-review.googlesource.com/61927
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2018-06-26 07:46:24 +00:00
Johnni Winther a8d805055a Handle covariant parameters in function types
Closes #33575

Change-Id: I743a951f5864ca538b588441ecba2680eba2081f
Reviewed-on: https://dart-review.googlesource.com/61924
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2018-06-22 20:24:55 +00:00
Johnni Winther 532b9aaa93 Flatten *WorldBuilder hierarchies.
Change-Id: I59bfa08f151f2e238816a4da6163a39e6df2dc9c
Reviewed-on: https://dart-review.googlesource.com/60544
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2018-06-19 08:16:03 +00:00
Johnni Winther f59389b688 Optimize .runtimeType impact based on usage
Change-Id: If6c24d4115241dcb8ac2ed82eee58c4025e3d8e2
Reviewed-on: https://dart-review.googlesource.com/59090
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2018-06-15 19:51:14 +00:00
Johnni Winther 37425618d5 Narrow to static types in invoke/get in inference
Change-Id: Ifb085cf881c21a6161a22cb1f2b6058a9947f321
Reviewed-on: https://dart-review.googlesource.com/55920
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2018-06-13 13:11:10 +00:00
Johnni Winther 7321f938d5 Use default type for type variable bounds.
Change-Id: I5d21a16a76eb6cd898e8e11104d0be0f7e669426
Reviewed-on: https://dart-review.googlesource.com/59420
Reviewed-by: Stephen Adams <sra@google.com>
2018-06-12 09:05:09 +00:00
Stephen Adams 38467cca03 Track always-initialized-to-null fields
Change-Id: Idb4d3a0395ce73eaaa4fc15a8df3bceaa4821b4f
Reviewed-on: https://dart-review.googlesource.com/57525
Commit-Queue: Stephen Adams <sra@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2018-06-04 21:05:01 +00:00
Johnni Winther 82755aa303 Rename ClosedWorld to JClosedWorld and merge it with ClosedWorldRefiner
Change-Id: I858695194fe4b0dffb7c85a93e2d6bcc04dd6229
Reviewed-on: https://dart-review.googlesource.com/58022
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2018-06-04 09:22:41 +00:00