Commit Graph

146 Commits

Author SHA1 Message Date
Stephen Adams 8d68480746 [dart2js] Fix global type analysis
https://github.com/dart-lang/sdk/issues/43366

Fixed: 43366
Change-Id: Iac8247c31fa268186c8f2e3f52e0be1cac062598
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/162247
Commit-Queue: Stephen Adams <sra@google.com>
Reviewed-by: Mayank Patke <fishythefish@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2020-09-11 04:07:41 +00:00
Christian Altamirano c026589e69 [dart2js] Added interceptor bits to powerset domain
Change-Id: Ia949732ffd431461eb8dc9f14bf398bc85b71dff
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/160800
Commit-Queue: Christian Altamirano <coam@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
2020-08-29 02:14:13 +00:00
Joshua Litt c086f08285 [dart2js] Add regression test for #35311.
Change-Id: Ia3069fc10800debefa74d53bd987a06ada04df50
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/160702
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Joshua Litt <joshualitt@google.com>
2020-08-27 23:26:47 +00:00
Joshua Litt 29c0795f48 [dart2js] Flip new deferred split flag.
Change-Id: Ifa795b96f2d2fa685072f314508b761b77a39bf2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/160161
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Joshua Litt <joshualitt@google.com>
2020-08-26 23:17:05 +00:00
Christian Altamirano d52fd7d0d6 [dart2js] Implemented map that stores powerset bits for classes
Added a ClassInfo struct that stores bits for class, strict subclasses and strict subtypes.
This map is initialized empty and lazily computes the bits using the method computeClassInfo.
This function recursively traverses the class hierarchy only when needed, computes the bits on the fly and stores it.
Since the class hierarchy is a DAG, this recursive method terminates.
This map will also be used for some queries, which are now exercised in the new test

Change-Id: I0b8b0b34b5c7d5cc3c1608266c9795033351e650
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/160040
Reviewed-by: Stephen Adams <sra@google.com>
Commit-Queue: Christian Altamirano <coam@google.com>
2020-08-26 20:44:05 +00:00
Christian Altamirano 51cd4cb3d6 [dart2js] Implemented constant value query for powerset domain
This fixes the issue with the compiler when the powerset flag is on.
Now the powersetBits test works

Change-Id: I8e63b986a7dafb8937b93303cebe304f79bddabf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/159800
Commit-Queue: Christian Altamirano <coam@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
2020-08-23 23:21:55 +00:00
Christian Altamirano 42dec58c01 [dart2js] Added powerset bits API and implemented most powerset queries
Change-Id: I3d0940df76e66049f3bd545b1a53dbe6036b4df2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/158580
Commit-Queue: Christian Altamirano <coam@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
2020-08-21 18:10:00 +00:00
Stephen Adams ae462475f9 [dart2js] Try to preserve precision of bools in inferrer.
Use abstract type of constant for BoolConstantTypeInformation
as the AbstractValueDomain may have something more precise than 'bool'
for a true/false constant.

Evaluate short-circuit `&&` and `||` for constant inputs.
This can occur with named and -Dxxx= defined constants.

TODO: we should consider adding a node like a guarded-phi to
select an input, with possible boolean conversions on inputs.



Change-Id: I7f54503db87f6a6d2034ca59c16b4f1ff69ebbb6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/159323
Reviewed-by: Christian Altamirano <coam@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2020-08-20 18:26:59 +00:00
Mayank Patke bd672a90af [dart2js] Improve simplification of type tests.
Change-Id: I29fd8e32145df61816bf98dd9fdc2dac33cafc75
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/157662
Commit-Queue: Mayank Patke <fishythefish@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
2020-08-18 09:14:10 +00:00
Joshua Litt eab26cd2bd [dart2js] Flip flag to defer class types.
Change-Id: Ia1f913a01f2be006158967b145db3ee34b297cfe
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/155660
Commit-Queue: Joshua Litt <joshualitt@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2020-08-17 20:25:09 +00:00
Joshua Litt c060abfa45 [dart2js] Add regression test for 43055.
Change-Id: Ia83ada924f63ae7d8dfbe034415e5fd8f241cd2e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/158680
Commit-Queue: Joshua Litt <joshualitt@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2020-08-15 00:01:00 +00:00
Srujan Gaddam 57a522eaaf [dart2js] Allow multiple errors in native_test
native_test is set up so that it validates only one error per static
error. This CL allows multiple errors to be reported and validates
that all are reported.

Change-Id: I97e9abbfbd8273c0c436e44d08f5768eea3f7785
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/157663
Reviewed-by: Stephen Adams <sra@google.com>
2020-08-07 17:09:23 +00:00
Joshua Litt d384b7a0a6 [dart2js] Gather only required classes in deferred_load.
Currently we are gathering classes for all supertypes, but we only need
to gather classes for applied mixins and super classes.

Change-Id: Ie55a6587b0bc9cacf5061a52d2d9a9ec5fdbf2eb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/156761
Commit-Queue: Joshua Litt <joshualitt@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2020-08-07 16:26:15 +00:00
Mayank Patke 2f1711c798 [dart2js] Reuse SSA optimization for is-tests to optimize as-checks.
Change-Id: Ic33dec84e531f45522069032994d41862d923300
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/156620
Reviewed-by: Stephen Adams <sra@google.com>
Commit-Queue: Mayank Patke <fishythefish@google.com>
2020-08-05 23:13:35 +00:00
Srujan Gaddam 7bb0d1f39a [package:js] Add error for params in factories of anon classes
Adds a static error to check that factory constructors in anonymous
classes contain no positional parameters.

Change-Id: Iae7c5c1d9e2dc91390c85c58eb5e96718e808f9a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/156145
Reviewed-by: Nate Bosch <nbosch@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
2020-08-03 23:20:42 +00:00
Joshua Litt 7e39d33f05 [dart2js] Add type use for using a class only for its constructor.
Change-Id: I8a7e031045811962998229d25463c74b88ca311e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/156140
Commit-Queue: Joshua Litt <joshualitt@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
2020-07-30 22:30:14 +00:00
Christian Altamirano d983751b77 [dart2js] Refactor a few methods for type masks
Pass the CommonMasks abstract value domain instead of the JClosedWorld to TypeMask methods that need access to *their* abstract value domain. It is wrong to get the abstract value domain from the JClosedWorld because when we try to wrap abstract values, the abstract value domain in the JClosedWorld is the wrapper domain, not the domain being wrapped.

Change-Id: I5bbd0f4c56abe45714dd0a2657f73ef240efae0e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/155640
Commit-Queue: Christian Altamirano <coam@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
2020-07-28 17:25:40 +00:00
Mayank Patke 7e8348f4ce [dart2js] Assume isPotentialSubtype is always true.
The current implementation of this check is incorrect and produces false
negatives. Conservatively assuming that one type is always a potential
subtype of another is a simple fix to get this working.

The main downsides are that we may emit signatures and provide type
arguments to functions even when they're not needed because we no longer
statically deduce that a type check must fail. This may cause size
regressions.

I've added a TODO to add proper constraint solving per the local type
inference spec, but this is not currently a priority since no regression
is observed on large Google apps.

Change-Id: Ie5065596331c33a030e06e66481f258ef937e659
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/155544
Reviewed-by: Stephen Adams <sra@google.com>
Commit-Queue: Mayank Patke <fishythefish@google.com>
2020-07-24 11:13:05 +00:00
Srujan Gaddam 7c40665f91 [package:js] Add static errors for named parameters and tests
Adds error for named params in JS interop functions, static error
tests, and removes redundant code from dart2js.

Change-Id: Ie16ebdd7a816983c1250579ea346e31e77227112
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/154752
Commit-Queue: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2020-07-20 20:27:07 +00:00
Stephen Adams 3c0422d02c [dart2js] Constant-fold some cases of x.toInt()
Change-Id: Ibb574ab971ccee3be22fc8e2b33394f50e96122c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/154127
Commit-Queue: Stephen Adams <sra@google.com>
Reviewed-by: Mayank Patke <fishythefish@google.com>
2020-07-14 19:11:20 +00:00
Stephen Adams cf7a63afe6 [dart2js] inlining heuristics for generative constructor factory
Account for the size of the a generative constructor factory.

The factory evaluates all the initializers up the inheritance/mixin chain,
allocates the object, and then calls all the constructors down the
inheritance chain. All this is missed by the old code looking at the
immediate constructor body, sometimes causing extremely large
constructors to be inlined.

Change-Id: I8803b0f4b4155dec0f7878fd5527c1dd507b9c80
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/153560
Commit-Queue: Stephen Adams <sra@google.com>
Reviewed-by: Mayank Patke <fishythefish@google.com>
2020-07-10 01:40:08 +00:00
Sigmund Cherem b83d06e4f8 Fix order of async callback arguments
This was noticed when running the benchmarks/Calls/dart/Calls.dart with
sound-null-safety.

The only fix that was needed is to swap the argument order, but I also changed
to add the type promotion to make these errors stand out statically.

Change-Id: If47b04596d2da9d30961705fd858f2f2ba2b12c9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/153062
Reviewed-by: Stephen Adams <sra@google.com>
Commit-Queue: Sigmund Cherem <sigmund@google.com>
2020-07-01 23:06:24 +00:00
Mayank Patke e8daaefabf [dart2js] Ensure generic local functions are marked as potentially
needing type arguments.

Change-Id: I50831df2530395b9ec3562be171422b0b6455335
Bug: https://github.com/dart-lang/sdk/issues/42501
Fixes: https://github.com/dart-lang/sdk/issues/42501
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/152606
Commit-Queue: Mayank Patke <fishythefish@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
2020-06-26 21:27:38 +00:00
Mayank Patke 3b67681bcc [dart2js] Clean up (pre-)NNBD unit test configurations.
Change-Id: Ife85aafa90b1b0347fabb6e95f3d6c00c5307cd2
Bug: https://github.com/dart-lang/sdk/issues/42063
Fixes: https://github.com/dart-lang/sdk/issues/42063
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/152440
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Mayank Patke <fishythefish@google.com>
2020-06-25 18:44:32 +00:00
Stephen Adams 7425b3de51 [dart2js] Remove more dead code.
Change-Id: Iff5b3921f40981c8122d7720ce80a5f01731aa47
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151883
Commit-Queue: Stephen Adams <sra@google.com>
Reviewed-by: Mayank Patke <fishythefish@google.com>
2020-06-19 21:20:07 +00:00
Stephen Adams acf41746f5 [dart2js] More old-rti cleanup
Change-Id: Ia1bb661a255a9e3ea48b79ff33532d0d66e8e80e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151803
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2020-06-19 17:49:33 +00:00
Stephen Adams d8b7ec5163 [dart2js] Share large strings
On a per output-unit basis, repeated large strings are shared via a
`string$` pool.

TODOs:

- don't do it with strings passed to JS() code (they might need
  to be property accesses).

- tweak thresholds, using different thresholds for slow/run-once code.

Change-Id: Ib14245d9d428e52fb2ca23f34fa533de97fa2208
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/136304
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2020-06-19 16:34:13 +00:00
Stephen Adams a26ad7fb7c Remove more old-rti code
Change-Id: I9c9cf3d1a408138790176525cff4e8991cd1ba32
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151632
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2020-06-18 16:24:10 +00:00
Stephen Adams 0ccc96f470 [dart2js] remove more old-rti code
Change-Id: I462dd6aec1bf39c16e340699b2803254fd4fc941
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151345
Commit-Queue: Stephen Adams <sra@google.com>
Reviewed-by: Joshua Litt <joshualitt@google.com>
2020-06-17 20:31:01 +00:00
Leaf Petersen d44457f79d [Core Libraries] Eliminate the fork in the core libraries.
Move the nnbd core libraries from sdk_nnbd to sdk, and updates
references in build files and elsewhere accordingly.

Change-Id: I09760fe1e006657aacdfe80f3b22fdf6f7e30a9f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151121
Commit-Queue: Leaf Petersen <leafp@google.com>
Reviewed-by: Bob Nystrom <rnystrom@google.com>
2020-06-16 23:37:36 +00:00
Stephen Adams cf1681e11e [dart2js] Remove more unused old rti helpers
Change-Id: Icbc50554f2b3ae2cb74b32c9876c7c0cdf15c75b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/150640
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2020-06-15 18:23:17 +00:00
Stephen Adams 60ec2b31e6 [dart2js] More sharding of rti_need and rti_emission tests
Both are now sharded 4-ways, which should reduce the individual shards
to about 2 minutes.

Change-Id: I5e8a718a0b5c58b0850015bee76f10df26aee84d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151141
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Alexander Thomas <athom@google.com>
2020-06-15 16:32:25 +00:00
Dmitry Stefantsov 929d5e4a98 [cfe,ddc,dart2js,vm] Add FutureOrType
This CL is the sum of the following 5 CLs:
* https://dart-review.googlesource.com/c/sdk/+/149297/
* https://dart-review.googlesource.com/c/sdk/+/149299/
* https://dart-review.googlesource.com/c/sdk/+/149320/
* https://dart-review.googlesource.com/c/sdk/+/149321/
* https://dart-review.googlesource.com/c/sdk/+/149323/

The reason for landing the 5 CLs as one CL is to prevent potential
troubles with bisecting over the branch because the change is fully
functional only with all 5 CLs.

Closes #40123.

Bug: https://github.com/dart-lang/sdk/issues/40123
Change-Id: Ice52250a98acfe455b1d7fa5bb0624c115ca5dac
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/150934
Commit-Queue: Dmitry Stefantsov <dmitryas@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2020-06-15 12:18:46 +00:00
Stephen Adams a13a2d7c84 Redo "[dart2js] Delete unused old-rti helpers"
Change-Id: I756a1adde6bbecdb5f28eb93f93041463435476d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151041
Reviewed-by: Stephen Adams <sra@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2020-06-12 01:29:39 +00:00
Johnni Winther ab034e69b4 [dart2js] Fix reduction to declared type in type promotion computation
When reducing the type promotion in case of assignment, the target
info wasn't correctly handling the reduction to the trivial state.
This caused an error in a following join computation.


Closes #42281

Change-Id: I2144f5401e9736308dc37147f7a5cb9ab1be8583
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/150935
Commit-Queue: Stephen Adams <sra@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
2020-06-11 18:52:38 +00:00
Mayank Patke 9f6510b31b [dart2js] Replace accesses to options.nullSafetyMode with
`options.useLegacySubtyping` where possible.

Change-Id: I462044e536f061cc0c67b044b986494801f58e1b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/150765
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Mayank Patke <fishythefish@google.com>
2020-06-11 17:35:41 +00:00
Stephen Adams 96fc158e4e Revert "[dart2js] Delete unused old-rti helpers"
This reverts commit e75b824aed.

Reason for revert: Break in google3 

Original change's description:
> [dart2js] Delete unused old-rti helpers
> 
> Change-Id: I0f97dddbfcbe5f51dff1d7d68f880e85d62768a4
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/150504
> Commit-Queue: Stephen Adams <sra@google.com>
> Reviewed-by: Sigmund Cherem <sigmund@google.com>

TBR=sra@google.com,sigmund@google.com,joshualitt@google.com

Change-Id: If71d84fda4ce596bb762d32454a4c635185f189f
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/150780
Reviewed-by: Stephen Adams <sra@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2020-06-10 17:46:40 +00:00
Stephen Adams e75b824aed [dart2js] Delete unused old-rti helpers
Change-Id: I0f97dddbfcbe5f51dff1d7d68f880e85d62768a4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/150504
Commit-Queue: Stephen Adams <sra@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2020-06-09 18:24:53 +00:00
Harry Terkelsen 54fe29e965 support @JS annotation from SDK
Attempt at fixing https://github.com/dart-lang/sdk/issues/39740 to allow the flutter web engine to use @JS
interop to avoid the overhead of the SDK available js interop.

Bug: 39740
Change-Id: I7ba9c8981e639cd267bee3086ba900b89bfc0d6f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/150501
Reviewed-by: Stephen Adams <sra@google.com>
Commit-Queue: Harry Terkelsen <het@google.com>
2020-06-09 17:10:15 +00:00
Stephen Adams e3fac1dde2 [dart2js] Remove Options.useNewRti
Change-Id: Ib959cddf7929e2e5d6f3e514e718976fd0135b7e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/150473
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2020-06-09 17:01:55 +00:00
Stephen Adams 7eee7b6957 [dart2js] Remove old rti in ssa/
Remove HInstructions related to old rti.

Some methods are still called 'fooNewRti'. These will be renamed 'foo'
at the very end of removing old rti.

Change-Id: I36fcc9d2d5bc19988e26fa5014c895f54b88900c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/150276
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2020-06-09 00:43:05 +00:00
Joshua Litt 451694e855 [dart2js] Move dart2js_native to dart2js/native.
Change-Id: I2f879fe18376b8c1b82fc201d488425dc154d2b7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/149341
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Joshua Litt <joshualitt@google.com>
2020-06-04 18:11:49 +00:00
Joshua Litt 05ca544f15 [dart2js] Move tests/compiler/dart2js_extra to tests/dart2js_2.
Change-Id: Iaa0ca2b4f2d1b15f79ddca37834d3ed2497bc068
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/149242
Commit-Queue: Joshua Litt <joshualitt@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2020-06-03 15:15:30 +00:00
Johnni Winther 3a021a6545 [cfe] Remove EvaluationMode.legacy
This is no longer valid. Since the SDK is agnostic we should default to weak mode.

Change-Id: Ia9fbf911e7ebb595c93a71afe3bb8de7495cebba
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/149065
Reviewed-by: Jens Johansen <jensj@google.com>
2020-05-30 09:47:02 +00:00
Joshua Litt 107862e2bf [dart2js] Fix bug in modular_test_suite.
Change-Id: I37954e14e8b53e70e0cfc4c3bcfb216e9f4d482f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/148000
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2020-05-28 21:30:36 +00:00
Joshua Litt 20faaa5d94 [dart2js] Move dart2js unit tests to pkg/compiler/test.
Change-Id: Ib18f554c1076f27a3f7c0df5a36410da41a1f467
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/148784
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2020-05-28 18:51:11 +00:00