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>
fields.
This brings it more in line with the lib_2 version.
Change-Id: I99e4f6a467fa5b58d6e7c5206e1f6d9956fc60bc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/158961
Auto-Submit: Mayank Patke <fishythefish@google.com>
Commit-Queue: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Sigmund Cherem <sigmund@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>
When `--null-assertions` is enabled, values returned from @Native
methods and getters with non-nullable return types are checked.
Change-Id: I4b38e651a9a6b370ebed5420a3cfac0a53cfeb60
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/158527
Commit-Queue: Stephen Adams <sra@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Srujan Gaddam <srujzs@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>
Adds errors for class members that have a @JS annotation but the
enclosing class does not.
Change-Id: Id693af71678510047a723863846d89aa29cebe26
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/157004
Reviewed-by: Nate Bosch <nbosch@google.com>
Reviewed-by: Sigmund Cherem <sigmund@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>
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>
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>
This cl implements deferred loading of class types. The bulk of the
logic is hidden behind a flag.
Change-Id: I7d5139eff72c7d29226a7e46c427c82fc5bda728
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/154580
Commit-Queue: Joshua Litt <joshualitt@google.com>
Reviewed-by: Sigmund Cherem <sigmund@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>
If an initializer throws, the variable should be treated as
uninitialized so that the next access reevaluates the initializer.
Change-Id: I8428383a7f99527a915962f7be348f4f33b83163
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/157040
Reviewed-by: Mark Zhou <markzipan@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>
This function only uses the CommonMasks and not the JClosedWorld.
Change-Id: I315da588612499324894dbecba7a7983de009ffb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/156802
Reviewed-by: Stephen Adams <sra@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
Inside masks.dart using '_closedWorld.abstractValueDomain' is the same as using 'this'
Change-Id: I30384f6f542283bc770bbf2b0bebdbb12c3c0306
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/156800
Commit-Queue: Christian Altamirano <coam@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
When a captured local type variable was used in more than one context
with different nullabilities, we would construct a separate field for
each one. Because the localToFieldMap is keyed by the local, each field
would clobber the previous one when it was written to the map.
This is a side effect of the CFE storing nullability on each type rather
than as a wrapper. Consider the following function:
void Function<S1 extends T, S2 extends T?>() f<T>() =>
<S1 extends T, S2 extends T?>() {};
Although the closure that f returns has a single free variable (T), we
end up with two distinct TypeVariableTypeWithContexts - one for T% and
one for T? - even though they're both keyed by the same local - T.
Change-Id: I7ea3ca7132ad51201beeb3c2a52311a97ce45875
Bug: #42847
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/156445
Commit-Queue: Mayank Patke <fishythefish@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
The stored AbstractValue is unused and removing it makes it possible
for the dummy to be independent of the AbtractValueDomain.
The actual receiver type is stored independently on the HInvokeDynamic
node, and would also be available via the 'interceptor' input, since
the dummy is used only on 'self-intercepted' call sites.
Change-Id: I04ff0a50f3afd399a6994ebe7f006687d57c84f6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/156585
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
These two functions (includeClosureCallInDomain and locateMembersInDomain) are similar to existing ones but take an AbstractValueDomain as a parameter. This is done so that the abstract value parameter belongs to the abstract value domain passed, for the wrapped version this did not happen.
Change-Id: Id085c1d589beccbf95fd2a0251b3b884f1dc2d30
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/156220
Commit-Queue: Christian Altamirano <coam@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
All of the backends (dart2js, DDC, VM) were checking if the invocation
name was tagged with "set:" and appending "=" to the name if so.
Instead, we can simply have the CFE perform this logic at the callsite.
Note that the name of the setter itself is still unchanged. Backends may
still need to generate the correct name themselves when handling NSMs
via code paths other than instantiateInvocation.
Change-Id: Iae42c849d3557be3e3b77c3af6f3993347ba0b6c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/156142
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Mayank Patke <fishythefish@google.com>
* Adds a bool `isNonNullableByDefault` field to Library entities.
* Adds a bool `usesNonNullableInitialization` to the JS emitter's StaticField.
* Emits two lazy-variable initialization functions: one for
pre-null-safety and one for post
New issues:
* Always emits both lazy init functions - even when only one is ever used.
Fixes#42419
Change-Id: I6a76798946b13842fbb2ad566d4505bbcd9ca0d1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/156063
Reviewed-by: Stephen Adams <sra@google.com>
Commit-Queue: Mark Zhou <markzipan@google.com>
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>
This reduces the number of _CompactLinkedHashSet objects by ~15% and
the number of _GrowableList objects by ~10% in Phase1.
Change-Id: I88ebe1b1c842977214985e23a1f3672ad43bdfdc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/155826
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
On a very big partition this reduces the memory footprint of the
ImportSets by 70% and is slightly faster.
This is because most ImportSet._transition maps have one entry.
Change-Id: I318a5675d8c3cf135c4937b2b0f63409e5c2d754
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/155725
Commit-Queue: Stephen Adams <sra@google.com>
Reviewed-by: Joshua Litt <joshualitt@google.com>
This is the same approach DDC and the VM take. Longer term, it may make
sense to move this logic into the CFE.
Change-Id: I9118747f187ca7bfa7eabe74d45e69a8c4cf240c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/155823
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Mayank Patke <fishythefish@google.com>
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>
--omit-implicit-checks.
When the default check policy is "trusted" instead of "emitted", we skip
checking every function during the RTI need computation. This works
because if the type arguments are needed for some other reason, like the
literal being used in the body, we see the type use and go back and
update the RTI need of the function. We can't do this for callable
properties because we don't know which function will be assigned at
runtime, so we need to conservatively provide type arguments no matter
what.
We could optimize this slightly by only providing type arguments if we
know a type use occurs in a function which is assignable to the type of
the property, but I expect this to save little for the amount of
overhead during compilation.
We also update the dependency computation to ensure that if a callable
property needs type arguments, then they're available for the enclosing
context to pass along.
Bug: https://github.com/dart-lang/sdk/issues/41449
Fixes: https://github.com/dart-lang/sdk/issues/41449
Change-Id: I98d9024dfa64cbfe33bd43172ffa905a8537649e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/154284
Reviewed-by: Stephen Adams <sra@google.com>
Commit-Queue: Mayank Patke <fishythefish@google.com>
This is only material for custom elements since no other intercepted
classes have actual fields.
Change-Id: Iae9a9af7dc0289c3fd28c38c517a642f8b16fa3e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/154860
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
ConstantValueTypeMasks will now contain a CommonMasks domain as a field which will be used in its visitor methods
Change-Id: I2913148794cce868f48ba4bf6fc5015cbb8f186b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/154600
Commit-Queue: Christian Altamirano <coam@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
The emitter creates classes in bulk, and then later connects them together
except for adding stubs for JS-interop is checks. We assumed the class for
JavaScriptObject was previously created and stored stubs eagerly while creating
classes.
We believe this caused a crash with flutter because the class was not yet
defined in that case.
One theory why this wasn't hit as much externally is that we sort classes by
location and process dart:* classes first. Flutter is the first use case where
JS-interop classes can be defined within SDK libraries.
Fixes#42612Fixes#25517
Change-Id: Icad0a9a16ec0d05481ed60f581a23c9eeb1ed5d3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/153943
Commit-Queue: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
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>
This experiment will use a powerset abstract value domain in the inferrer
Change-Id: I216ff9c24d1e7292688426ae7bcb52b15aa2714e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/153720
Reviewed-by: Stephen Adams <sra@google.com>
Commit-Queue: Christian Altamirano <coam@google.com>
Bad identifier for async closure generator body names in extension methods.
Fixed: 42531
Change-Id: Ice29bb5ac03c67b1024c0fd53ffdb9b9b1d2131f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/153484
Commit-Queue: Stephen Adams <sra@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>