This adds support lowering the encoding of top-level/static fields
with initializers as if they were marked as late fields. This ensures
that LateInitialization is thrown if final fields are written to during
initialization.
Closes#42956
Change-Id: I488fdddd87ebd935a0cdaf82a724e9b87d5f91ba
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/160724
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
In spec-mode, conditions are forced to be true/false if necessary by a
HBoolConversion check. The refined output of HBoolConversion can be a
constant, allowing a branch of an if-then-else to be deleted.
If production-mode (-O3), this check is omitted, making it possible
for `null` and other values to flow to the condition. Without the
refinement of the HBoolConversion, the abstract value might not even
be a constant. To enable a branch of the if-then-else to be deleted as
an optimization (i.e. without changing the behaviour), we need to be
able to predict the JavaScript interpretation of the condition.
Change-Id: I44200adb7270a3feb26ce110ad4930cfa127f8c3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/160402
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
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>
The queries of the form is<Something>OrNull actually require the value to be <Something> allowing also null.
Change-Id: I869d4364b56ec56ef09dc962abda0530546a9678
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/159980
Reviewed-by: Stephen Adams <sra@google.com>
Commit-Queue: Christian Altamirano <coam@google.com>
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>
This code was inadvertently falling through to the `throw` if `VoidType`
was encountered (although this case currently never happens). In
addition, we were missing cases for some of the newer `DartType`s.
This CL fixes those cases and removes Object from the classes implied by
`DynamicType`.
Change-Id: Ibfecd92c0113d11eb8870d511d60cbc34ac1bfa0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/159020
Commit-Queue: Mayank Patke <fishythefish@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
This code worked around bugs in how TypeMasks were generated 4+ years
ago. Now subtype cones are generated from the least upper bound of
instantiated subtypes, resulting in TypeMasks that are no longer
disjoint for 'double' and 'int'.
Change-Id: I7189c4447f2c41db7abb7a0ea1240eca6e28aa7f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/159000
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
Previously, we were creating nullable typemasks and then stripping off
the nullability if non-nullability was specified. We should be assuming
non-nullability as the default and adding nullability in if required.
The former approach has the issue that typemasks for `Null` keep getting
converted to empty typemasks when we try and remove the nullability.
Change-Id: I58907c1c45c756f023d67043ce88eb82c4b1589c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/158371
Reviewed-by: Stephen Adams <sra@google.com>
Specifically this allows passing the result of `someUri.toFilePath()` on windows as a multi-root.
These paths have drive letters which are not understood by `Uri.base.resolve`.
Change-Id: I66d452be1e1c6923e61c1843bdfbce83a7c12f94
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/158900
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Sigmund Cherem <sigmund@google.com>
Auto-Submit: Jake Macdonald <jakemac@google.com>
Adds `--report-metrics` and `--report-all-metrics`.
These options print all the Metrics objects exposed by CompilerTask.
This CL has counts and durations and adds metrics to two tasks to
demonstrate the 'framework'. More task metrics will be implemented
as needed. As we do so, we will experiment to see if it is possible
to make it easier and more efficient collect metrics.
```
$ dart2js ... --report-metrics
Info: Metrics:
type_inference.time: 1.429s
deferred_load.time: 0.424s
...
$ dart2js ... --report-all-metrics
Info: Metrics:
type_inference.time: 1.300s
type_inference.time.analyze: 0.695s
type_inference.time.refine1: 0.361s
type_inference.time.refine2: 0.175s
type_inference.count.exceededMaxChange: 5
type_inference.count.overallRefines: 90827
deferred_load.time: 0.270s
deferred_load.hunkListElements: 1
```
Change-Id: I2ba66f65af604758b0cbd71a688133cb562e32ed
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/156842
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
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>
This is based on the wrapped version that also includes a bit integer.
Right now the methods use the old abstract value domain but will use the integer bits in later CLs.
Also added and updated a flag so that now there is one for a wrapped domain and another for a powerset domain..
Change-Id: Iab6b93584a9a644dfef92f689c4be8c42ce8076a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/157620
Commit-Queue: Christian Altamirano <coam@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
lib/html/js_typed_interop_type_test.
Also update the error produced when an interop type contains a
non-external member in case users run into it via a late field.
Change-Id: I5968f4c8b3a71a3d467412c4499524ec4cc9d838
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/157161
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Mayank Patke <fishythefish@google.com>
It will be used as a base for the upcoming powerset abstract value domain
Tests that do not depend on the detailes of the TypeMask abstract value will be fixed in a follow-up CL
Change-Id: I42398504d7c09a0b7c3b3d6b0682e1e813ea4d1d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/154520
Commit-Queue: Christian Altamirano <coam@google.com>
Reviewed-by: Stephen Adams <sra@google.com>