Before Null Safety, `_EventStreamSubscription.cancel()` used a trick
to run with synchronous timing even though it was typed to return a
`Future`. During the migration of the SDK to support Null Safety it
kept the synchronous timing in weak mode, but was changed to
asynchronous in sound mode so that the behavior matched the method
signature. In hindsight, changing the timing when opting into Null
Safety is problematic:
* A shared package has no control over what mode it runs in. Libraries
may be opted in and run their tests with sound null safety but the
apps they are used in could still be running in weak mode. This
results in library unit tests that behave differently than the
production app that deploys the code.
* This codepath can be triggered by EventTarget.dispatchEvent() from
dart:html which should have synchronous timings for the event
listeners before returning to the calling code. The asynchronous
timing when running with sound null safety is inconsistent with the
browser API.
This change reverses that migration decision and keeps the synchronous
timing in both modes. To support this in sound mode it returns a
special future value that is internal to the SDK and known to be used
for synchronous timing.
This change also removes the workaround introduced in DDC to avoid
warning/failing when `_EventStreamSubscription.cancel()` returned
null and the extra warnings/errors features were enabled in weak
null safety mode.
Change-Id: I6b08a2ada5b10120bea787ad59d1d58e6e181de5
Fixes: https://github.com/dart-lang/sdk/issues/44157
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/175323
Commit-Queue: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Emphasize that the operation is going away,
and mark constructor as deprecated.
TEST= Refactoring+deprecation only, covered by existing tests.
Change-Id: I82aa044cd2cf7bf347b624371399f44bda8f4a07
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/173261
Commit-Queue: Lasse R.H. Nielsen <lrn@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
This change selectively containerizes many top-level JS constructs. Containers maintain a max size of 500 elements for JS optimization purposes. Containers with unspecified key names are emitted as JS arrays. Containerization occurs for symbols when the number of top level symbols exceeds 600 but is automatic for other constructs. However, containerization in the Dart SDK only happens for web libraries for runtime optimization purposes.
Two types of common DDC constructs result in their capture by all subsequent closures:
* Self-referential variables:
var selfLambda = () => selfLambda = "foo";
* Variables referenced in sister functions:
var unused = "foo";
function unusedF() => console.log(unused);
The following are now accessed through an additional level of indirection:
* Type generators (frequently follow the self-referential variable pattern)
* Constant cache variables
* Dart private names (used for virtual method dispatch)
* Top-level string constants (such as URI strings)
Additional changes:
* The ModuleItemContainer handles automatic renaming of arbitrary top-level JS expressions. This is a multimap that maps keys of an arbitrary type to JS key-value pairs.
* The CacheTable and TypeTable have been unified. The old cache table seemed to have been created with a similar use case as the ModuleItemContainer but had become too specialized.
* The new TypeTable unifies much of the logic for emitting types, including explicitly separating the discharge of types dependent on free variables (such as generic types, generic functions, and their bounds) from types that are fully bound.
Reduces top-level captured variables in the SDK by ~5711 per recursive callback.
Change-Id: Id44efef8e93d1a83fdac808814d9ace99c4d27bd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/173800
Commit-Queue: Mark Zhou <markzipan@google.com>
Reviewed-by: Anna Gringauze <annagrin@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
This is in preparation to migrate package:kernel to null safety.
For the visitor interfaces to support non-nullable return types, the
implementations must avoid using `null` as return value in its base case.
TEST=Refactoring
Change-Id: I9f9b318982148d844be9826a5f8c88374a9fc402
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/172180
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
- Define private symbols load without reloading the module
and knowing module format
- Remove libraryName->moduleName map from ExpressionCompiler's
compileExpressionToJs API as a result of above
- Make ddc tolerate null locations on kernel loaded from dill
during assert insertions for nullability
- Disable asserts in expression compilation worker
due to ddc reading source for assert statement compilation
- Remove unused test configuration for expression compiler worker
- Add and update expression compiler tests
Part of: https://github.com/dart-lang/webdev/issues/1174
Change-Id: Idf8f508308915a5487fa0e9810b5674140393fed
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/170028
Commit-Queue: Anna Gringauze <annagrin@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
This CL:
- Fixes https://github.com/dart-lang/sdk/issues/43987 (an exception in custom formatting code)
- Restores (most of) debugger_test.dart to passing (which tests above)
- Fixes a type caching error also exposed by the above test
Note, this skips the golden file comparison. That appears to be very broken
(see comment).
Change-Id: I283b66a710f17765faed47aa099b0b8570e6cac1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/170022
Reviewed-by: Gary Roumanis <grouma@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Vijay Menon <vsm@google.com>
This reverts commit 9dade7fd21.
With changes further in the relation chain, specifically around
making native null assertions tied to sound null-safety only,
the failure which caused the original revert should no longer occur.
Change-Id: I5a6074304d08e6e8f168bea678439b1ab3e90d0e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/168998
Reviewed-by: Nicholas Shahan <nshahan@google.com>
The covariance optimization assumed that private members only occur
in the library in which they are private. This is not the case. The
CFE injects member signatures, forwarding stubs and noSuchMethod
forwarders for private members into other libraries.
This change takes that into account by only removing covariant bits
on members private to the enclosing library.
This hopefully a fix for https://github.com/flutter/flutter/issues/66122
Change-Id: I5070cee9eea8e785622cef33fdc7138a0a90f53a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/168950
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
- Fixes broken benchmarks in ddc because the benchmarks run in
d8 with the ddc module system can handle conflicting library
names more gracefully than es6.
- In the future we need to update the source of truth for
dart_library.js so we can keep the file in sync.
- Removes the ability for ddb to run with any precompiled sdk.js
from a dart installation. Now you must run a build first and
the sdk.js files from that build will be used. This means the
`--debug` flag no longer changes which sdk.js files are used.
Change-Id: Icaf78956f93ff643d23e68001354ec08c9c28b12
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/166926
Reviewed-by: Mark Zhou <markzipan@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
Modifies ddc and dart2js logic to only include null-checks on native
members inside the web libraries. Modifies tests to account for this
change.
Change-Id: If9c164fb90b761d3c4611d87ffeb02c2fa884457
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/168585
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Even when non-nullable is enabled by default, enabling the experiment
explicitly should result in the experiment release version (and not
the experiment enabled version) to be used for opting in.
For this change, the semantics of parseExperimentalFlags was change
to _not_ normalize the flags to a full mapping including default values.
For this reason all uses of such maps are renamed to
'explicitExperimentalFlags'.
Closes#43879
Change-Id: I0d0262e68ec1403549abcfd305ae3a4404fe93e3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/168654
Reviewed-by: Jake Macdonald <jakemac@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
- make sure nested blocks scopes are visited
- make sure variable definitions do not leak beyond block scopes
- properly collect scopes for loops, if statements, constructors
- add calculation of fileEndOffsets for blocks
- save block file offsets to dill
- update binary format version
- change kernel readers and writers to read and write block offsets
- change vm readers to read and block offsets for new version
- add missing fileOffsets and fileEndOffsets on functions for
late fields
- add missing fileOffsets and fileEndOffsets on functions for
extensions
- add errors on failures to find scope
- find libraries for private fields correctly
- add more expression compilation tests
- add test to verify fileOffsets and fileEndOffsets are set for
SDK summary (will add full dill tests later)
Closes: https://github.com/dart-lang/sdk/issues/40278
Related: https://github.com/dart-lang/sdk/issues/34942
Change-Id: I5bc1bb645543045b689d8d61069ee77dc4ee9025
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/167541
Commit-Queue: Anna Gringauze <annagrin@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Use the non-nullablity of local variables and method arguments
to help guide the nullable inference when running with sound
null safety.
Change-Id: I00484dc908502b600de058103381af6588c4a958
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/155301
Reviewed-by: Mark Zhou <markzipan@google.com>
JS templates should always use their own source information. DDC
was incorrectly caching and reusing templates with the same source
information in various parts of the program. This lead to incorrect
source maps and in some cases compiler crashes when the source map
in a user application pointed to source location in the SDK.
Change-Id: I11607e6f02b894ead1d350e9b3071173ba36a048
Fixes: https://github.com/dart-lang/sdk/issues/43589
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/166122
Reviewed-by: Mark Zhou <markzipan@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>