Commit Graph

2729 Commits

Author SHA1 Message Date
Stephen Adams 35c7ebba1f [js_runtime] Specialize JSArray.addAll for JSArray input
Change-Id: I80b648a1a7c1cafb871618ccf57901047a374c19
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/175344
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2020-12-09 05:23:08 +00:00
Nicholas Shahan 4c2edfd5b9 [html] Make cancel() always return synchronously
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>
2020-12-09 01:44:38 +00:00
Lasse Reichstein Holst Nielsen f0ed48196e Undo conversion from List() to [] and List(n) to List.filled(n, null) in comments.
Change-Id: I80b5e335f63e14a80db697e2ac3cbcf4c8d51d6b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/175253
Commit-Queue: Lasse R.H. Nielsen <lrn@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
2020-12-07 22:10:18 +00:00
Lasse R.H. Nielsen 6e29700e16 Update List constructor documentation, deprecate constructor.
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>
2020-12-07 16:20:28 +00:00
Mark Zhou 37d8c78237 [dartdevc] Containerizing top-level variables to improve stepping times.
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>
2020-12-05 02:21:43 +00:00
Devon Carew 8cba879f46 Add additional validations to the pkg/ package pubspecs.
TEST=these are additional validations that we run on the bots

Redux of https://dart-review.googlesource.com/c/sdk/+/161040

Change-Id: Ia32ced5d48fbfeafacfa9e51dc4774d2e9425091
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/174601
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Devon Carew <devoncarew@google.com>
2020-12-02 17:27:18 +00:00
Nicholas Shahan a9f3c66bd8 Revert "[ddc] Verify null safety modes of modules agree"
This reverts commit fda897a423.

Reason for revert: Breaks all the flutter web tests here:
https://ci.chromium.org/ui/p/dart/builders/ci.sandbox/flutter-engine-linux-web_tests/1089/overview

This indicates we still have a misconfiguration in flutter web dev 
builds where artifacts with different null safety modes are being 
mixed.

Original change's description:
> [ddc] Verify null safety modes of modules agree
>
> Checks that the null safety mode of every module loaded matches the mode
> of the SDK.
>
> Change-Id: I50543d10fbea22a61bd7f12d51d6e9c8f8286890
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/173120
> Commit-Queue: Nicholas Shahan <nshahan@google.com>
> Reviewed-by: Mark Zhou <markzipan@google.com>

TBR=sigmund@google.com,nshahan@google.com,markzipan@google.com

Change-Id: I0d09efde53f268b353cb842286b11bb3f375e754
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/173440
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
2020-11-21 17:42:25 +00:00
Nicholas Shahan fda897a423 [ddc] Verify null safety modes of modules agree
Checks that the null safety mode of every module loaded matches the mode
of the SDK.

Change-Id: I50543d10fbea22a61bd7f12d51d6e9c8f8286890
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/173120
Commit-Queue: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Mark Zhou <markzipan@google.com>
2020-11-21 00:51:14 +00:00
Anna Gringauze c6c4661567 Enable fixed expression compilation tests, add more loop tests.
Tests are no longer failing since
https://github.com/dart-lang/sdk/issues/44235 is now fixed.

Change-Id: I2654233e4c62426e363eab518fdb5b041bc22724
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/173160
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Anna Gringauze <annagrin@google.com>
2020-11-20 21:47:23 +00:00
Anna Gringauze 57cbfa73ed Add tests for expression compilation with sound null safety
Change-Id: I895b769ce203c2aed0cfcce9f1fca70f42dbb97c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/172689
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Anna Gringauze <annagrin@google.com>
2020-11-19 01:24:41 +00:00
Sam Rawlins e228483736 dev_compiler: remove unused imports with shared prefixes
Bug: https://github.com/dart-lang/sdk/issues/38784
Change-Id: Ia29967ae40332db2e09d45b620acc7cbda4bbb7c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/172741
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2020-11-18 17:31:10 +00:00
Johnni Winther 887ab360e5 Revert "[kernel] Ensure that visitors don't implicitly returns null"
This reverts commit 4a3f121341.

The changes broke flutter/engine

TEST=It's a revert!

Change-Id: I1e65e6cfab03795a21a64a96fe3ed72e6ba8ecd9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/172760
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2020-11-18 14:51:30 +00:00
Johnni Winther 4a3f121341 [kernel] Ensure that visitors don't implicitly returns null
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>
2020-11-18 11:54:30 +00:00
Nicholas Shahan bfe8aa8d5b [ddc] Add option to throw null safety violations
Allows sound-like null safety when running mixed applications in weak
mode.

This is not a specified option and is only intended to assist large
scale migration efforts.

Change-Id: Icd0abb0e876d16e719a01e8381eef55a2b511051
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/171821
Commit-Queue: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Mark Zhou <markzipan@google.com>
2020-11-16 22:58:50 +00:00
Nicholas Shahan 7878baf1eb [dart:html] Remove casts in cancel() method
Casts in _EventStreamSubscription.cancel() are causing unwanted failures
in ddc when we turn weak null safety warnings into errors via a flag. By
removing the casts more apps can run when the weak mode errors are
enabled. The null value is used inside the SDK to signal synchronous
behavior.

This is a temporary fix until we can resolve the larger issue with the
API in dart:html. See https://github.com/dart-lang/sdk/issues/44157.


Change-Id: Ic9651779a394a03f092a5b4b7944c1306afcb826
Issue: https://github.com/dart-lang/sdk/issues/41653
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/171660
Reviewed-by: Mark Zhou <markzipan@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
2020-11-16 22:52:10 +00:00
Nicholas Shahan a6b76a610a [ddc] Optimize list control flow operations
Allows spread, collection for and collection if in list literals to
avoid unnecessary checks that the list is growable/modifiable and type
checks when adding the elements to the list.

Use a `push()` on the underlying JavaScript Array rather than calling
the exposed `add()` method.

The related ListCopy benchmarks show a performance increases between
10-40%.
https://golem.corp.goog/Comparison?repository=dart&team=dartdevc#targetA%3Ddartdevc%3BmachineTypeA%3Dlinux-x64%3BrevisionA%3D89256%3BpatchA%3Dnshahan-optimize-list-add%3BtargetB%3Ddartdevc%3BmachineTypeB%3Dlinux-x64%3BrevisionB%3D89253%3BpatchB%3DNone


Change-Id: I7e3ac3044d2af319a7ea40bbceef1d65ecec8261
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/172082
Reviewed-by: Mark Zhou <markzipan@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
2020-11-16 20:31:46 +00:00
Aske Simon Christensen 1ab705f60c [vm] Require all recognized methods to be marked with pragma.
Adds a @pragma("vm:recognized", <kind>) to all recognized methods, where
<kind> is one of "intrinsic", "graph" or "other", corresponding to the
kind of recognized method.

When running in debug mode, it is checked that all recognized methods
are marked with the correct kind of pragma, and that all methods marked
with the pragma are in fact recognized.

This enables kernel-level analyses and optimizations to query whether
a method is recognized by the VM.

TEST=Asserts that check the correspondence both ways, covered by test
suite, in particular the various CompileAll tests that compile all code.
Change-Id: I12f3305c72a93ecb1aefae2d66e3d9a7dae23b44
Cq-Do-Not-Cancel-Tryjobs: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/168951
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2020-11-16 13:49:50 +00:00
Anna Gringauze 9c54996510 Fix issues in expression evaluation in google3
- 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>
2020-11-14 01:34:16 +00:00
Johnni Winther 7b89827956 [cfe] Support bit mask for enabling specific late lowerings
TEST=pkg/front_end/testcases/late_lowering/late_lowering_bitmasks.dart

Closes #43993

Change-Id: I47d238dd7cf0ea22983a38bed86e415330070596
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/171580
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
2020-11-11 14:06:30 +00:00
Stephen Adams 8c13fa841e [dart2js] Kernel transformer expansion for List.generate
Simple calls to `List.generate` are expanded into a list allocation
and a loop. This generates better code for several reasons:

 - There is no overhead for the function argument (closure allocation,
   closure type, closure class)

 - Global type inference is more precise since each List.generate list
   is tracked separately, and the assignments in the loop give better
   inference to the collection's element type.

To get precise element type inference, there are two new JSArray
constructors. Global type inference starts with the element type being
bottom for these elements, avoiding spurious nulls in the inferred
type.

Change-Id: I5efb90651ae3f9eb2e81af556704960cdf0b75c5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/168770
Commit-Queue: Stephen Adams <sra@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2020-11-11 04:27:22 +00:00
Nicholas Shahan 03bf11e1d9 [ddc] Add nullability to JS interop types
This should get the current behavior closer to dart2js and more of the
tests passing found in
https://dart-review.googlesource.com/c/sdk/+/170660

Change-Id: I67bd647d12ff9db7ec9b884680c2b42e260b732e
Fixes: https://github.com/dart-lang/sdk/issues/44084
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/170746
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
2020-11-10 18:03:54 +00:00
Dmitry Stefantsov d54e2bb568 [cfe,ddc,dart2js,vm] Add NullType
This CL is the sum of the following 5 CLs:
* https://dart-review.googlesource.com/c/sdk/+/170342/
* https://dart-review.googlesource.com/c/sdk/+/170344/
* https://dart-review.googlesource.com/c/sdk/+/170345/
* https://dart-review.googlesource.com/c/sdk/+/170346/
* https://dart-review.googlesource.com/c/sdk/+/170347/

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 #40122.

TEST=Verified by changes in .expect files in pkg/vm/.
Bug: https://github.com/dart-lang/sdk/issues/40122
Change-Id: Ib8197802fdc69694387ae47ac990c58b3aaab7a5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/170689
Commit-Queue: Dmitry Stefantsov <dmitryas@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2020-11-06 12:43:52 +00:00
Vijay Menon f346cb7f77 Fix ddc debugger_test
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>
2020-11-02 23:31:30 +00:00
Nicholas Shahan ab7dc265d7 [ddc] Avoid weak mode warning in FutureOr casts
This is not intended to change the result of the cast in any mode.

An optimization for casting null in weak mode accidentally added
warnings when casting to a FutureOr (non-nullable) of a legacy
type.

Also moves the `is` and `as` methods for FutureOr types from being
hard-coded in the compiler to the runtime method that builds the
type.

Tested on golem and found no attributable performance regressions:
https://golem.corp.goog/Comparison?team=dartdevc#targetA%3Ddartdevc-null%3BmachineTypeA%3Dlinux-x64%3BrevisionA%3D88970%3BpatchA%3Dnshahan-FutureOr-Fix%3BtargetB%3Ddartdevc-null%3BmachineTypeB%3Dlinux-x64%3BrevisionB%3D88964%3BpatchB%3DNone

Change-Id: I44a23c7e2e1d15bc6c383fc95b19f99b584a3f7a
Fixes: https://github.com/dart-lang/sdk/issues/43990
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/170001
Reviewed-by: Mark Zhou <markzipan@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
2020-11-02 21:45:09 +00:00
Anna Gringauze 42dc617ee8 Emit constants during expression compilation to js
Closes: https://github.com/dart-lang/sdk/issues/43963
Change-Id: Ic8af046b2cf1506984b84ea66b2676b3cc0f1771
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/169580
Commit-Queue: Anna Gringauze <annagrin@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
2020-11-02 20:03:14 +00:00
Srujan Gaddam 2fd4b4f562 [dart2js, ddc] Emit native null checks in sound mode only
Bug: https://github.com/dart-lang/sdk/issues/42536
Bug: https://github.com/dart-lang/sdk/issues/42535

Since ddc would require a potentially breaking change to emit these
checks in unsound mode without opt-in and it's currently not possible
to emit these checks only in opt-in with dart2js, both are changed
to only emit checks in sound mode. In ddc, calling convention is
changed conditionally on sound mode as well to avoid emitting
unnecessary code in unsound mode.

Change-Id: I42f7bb5a53550f4ee5412fbbbfb6ca533c393e96
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/169247
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
2020-10-28 21:35:45 +00:00
Srujan Gaddam 8b68bb4191 Revert "Revert "[ddc] Move native null-checks to definitions""
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>
2020-10-28 21:35:45 +00:00
Srujan Gaddam ed009afc4c [package:js] Add static errors for invalid extends
Bug: https://github.com/dart-lang/sdk/issues/37896

dart2js disallows JS interop classes from extending Dart classes,
and ddc does not work as expected. Dart classes that extends JS
interop classes can't be declared in ddc and throw an error on
usage in dart2js. This CL adds static errors for both cases.

Change-Id: I72001d2e8bec046c0e1ab4c06fed8fcf84ade259
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/164840
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
2020-10-28 16:04:15 +00:00
Johnni Winther c5f478dfa8 [ddc] Don't remove covariance bits on injected members
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>
2020-10-24 11:30:23 +00:00
Nicholas Shahan 1869a54132 [ddc] Update ddb to run with ddc/legacy modules in d8
- 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>
2020-10-24 00:14:42 +00:00
Nicholas Shahan 2615e865e2 [ddc] Opt code in expression compiler test
Avoids breaks that appear when enabling the `nnbd` experiment
by default as seen in:
https://dart-review.googlesource.com/c/sdk/+/166790

Change-Id: I052853c42b772af9180d109f231215c00a5a8202
Fixes: https://github.com/dart-lang/sdk/issues/43843
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/168742
Reviewed-by: Anna Gringauze <annagrin@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
2020-10-23 17:49:22 +00:00
Lasse Reichstein Holst Nielsen f264f6a451 Fix bad DartDoc in Set.toSet documentation.
Change-Id: I1801d4d8f3f25c76885f3482ae1553d32e6ee15b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/168828
Commit-Queue: Lasse R.H. Nielsen <lrn@google.com>
Reviewed-by: Erik Ernst <eernst@google.com>
2020-10-23 11:18:12 +00:00
Srujan Gaddam d201c33f69 [ddc, dartj2s] Exclude null checks on non-web native members
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>
2020-10-23 00:07:21 +00:00
Johnni Winther b42f954364 [cfe] Use experiment release version when non-nullable is enabled explicitly
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>
2020-10-22 06:17:39 +00:00
Jens Johansen 29fa4e8148 [CFE et al] Compile flutter platform as agnostic for test; set component mode more
Bug: dartbug.com/43844 dartbug.com/43807
Change-Id: Iba662f0955897244aaac86ceace73b213fa06319
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/168482
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2020-10-21 10:04:41 +00:00
Nicholas Shahan f990e70930 [ddc] Opt code in nullable inference test
Avoids breaks that appear when enabling the `nnbd` experiment
by default as seen in:
https://dart-review.googlesource.com/c/sdk/+/166790

Change-Id: Idaf69b40c27336c8601cb143741f79604d2647e7
Fixes: https://github.com/dart-lang/sdk/issues/43843
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/168583
Reviewed-by: Mark Zhou <markzipan@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
2020-10-20 21:38:51 +00:00
Lasse Reichstein Holst Nielsen 48c73d82bf Clean up annotations and update @override documentation.
Fixes #43622

Bug: http://dartbug.com/43622
Change-Id: I4adea2995146ecd317d5c90a514cb564afa4f846
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/165800
Commit-Queue: Lasse R.H. Nielsen <lrn@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2020-10-20 15:56:13 +00:00
Anna Gringauze f04bc85e4f Refined scope calculation in expression compiler
- 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>
2020-10-20 01:44:52 +00:00
Nicholas Shahan f3962367a5 [ddc] Add language version to test files
Avoids breaks that appear when enabling the `nnbd` experiment
by default as seen in:
https://dart-review.googlesource.com/c/sdk/+/166790

Some of these synthetic files are created as packages but the
expression compiler wasn't designed to handle that information.
In the future we should support language versioning better in the
expression compiler or setup similar tests for opted in code since
in reality the language versioning might be handled by the dev
build system.

Fixes: https://github.com/dart-lang/sdk/issues/43843

Change-Id: Icfac40d1c9b47e75fb92d7672700e066ac372267
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/168441
Reviewed-by: Anna Gringauze <annagrin@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
2020-10-20 00:48:08 +00:00
Michal Terepeta 9dade7fd21 Revert "[ddc] Move native null-checks to definitions"
This reverts commit e02085bec3.

Reason for revert: This seems to break an internal test
(http://b/171029249).

Original change's description:
> [ddc] Move native null-checks to definitions
>
> Bug: https://github.com/dart-lang/sdk/issues/42535
>
> Native null-checks are moved to member definitions, and native
> member accesses are changed to use this indirection in the case
> where the member type can be checked.
>
> Change-Id: I499bb3a4f6a66021dd0ab7930a55e7233c1ce020
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/166785
> Reviewed-by: Nicholas Shahan <nshahan@google.com>
> Reviewed-by: Sigmund Cherem <sigmund@google.com>
> Commit-Queue: Srujan Gaddam <srujzs@google.com>

TBR=sigmund@google.com,nshahan@google.com,srujzs@google.com

# Not skipping CQ checks because original CL landed > 1 day ago.

Bug: https://github.com/dart-lang/sdk/issues/42535
Change-Id: I145ff11a18374d0d63e2042956ad53ea0939baf7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/168345
Commit-Queue: Michal Terepeta <michalt@google.com>
Reviewed-by: David Morgan <davidmorgan@google.com>
Reviewed-by: Michal Terepeta <michalt@google.com>
2020-10-19 13:43:27 +00:00
Nicholas Shahan 6b84ac8d0f [ddc] Optimize creating native typed data lists
Connect the type hierarchy with the missing (compared to the
dart2js versions) of the JSMutableIndexable class.

Avoids an extra copying of all data to a temporary list during
the construction just to get access to the index operator.

Change-Id: I8a9f8ba4d956ac49d6fb635709d11a6e7c018270
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/166782
Reviewed-by: Mark Zhou <markzipan@google.com>
2020-10-16 21:21:42 +00:00
Nicholas Shahan 0376746d84 [ddc] Optimize list operations
Avoid redundant element casts and checks if the list is growable.

Change-Id: Ib915ccf2ec65fbe7d32ecaabe23899f2530617c5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/166781
Reviewed-by: Mark Zhou <markzipan@google.com>
2020-10-16 21:21:42 +00:00
Nicholas Shahan 885cc8ce18 [ddc] Optimize toString() calls
Change-Id: Ib2caa2d08076fac80917336f69c22ab771e95664
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/166301
Reviewed-by: Mark Zhou <markzipan@google.com>
2020-10-16 21:21:42 +00:00
Nicholas Shahan bef5ffde1e [ddc] Optimize calling values typed as a Function
Change-Id: Idb74eb268de780e935d72c91f0758cbb02552d2f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/166300
Reviewed-by: Mark Zhou <markzipan@google.com>
2020-10-16 21:21:42 +00:00
Nicholas Shahan 4cb164215f [ddc] Trust non-nullability of awaited expressions
Change-Id: I0691dd2b2b7fd9f3e563952d983514cd095bb6ef
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/166940
Reviewed-by: Mark Zhou <markzipan@google.com>
2020-10-16 21:21:42 +00:00
Nicholas Shahan ed8933db3f [ddc] Trust non-nullability of casts
Change-Id: I19f73e7a3e1f65e27a27eb00f6f6d41ffda598af
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/165141
Reviewed-by: Mark Zhou <markzipan@google.com>
2020-10-16 21:21:42 +00:00
Nicholas Shahan e2a4906c51 [ddc] Trust non-nullability of return types
Change-Id: I2587fc8f263762524dfac27c75bd975d7aa51299
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/165140
Reviewed-by: Mark Zhou <markzipan@google.com>
2020-10-16 21:21:42 +00:00
Nicholas Shahan e92b1b30b0 [ddc] Trust non-nullability of variables
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>
2020-10-16 21:21:42 +00:00
Srujan Gaddam e02085bec3 [ddc] Move native null-checks to definitions
Bug: https://github.com/dart-lang/sdk/issues/42535

Native null-checks are moved to member definitions, and native
member accesses are changed to use this indirection in the case
where the member type can be checked.

Change-Id: I499bb3a4f6a66021dd0ab7930a55e7233c1ce020
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/166785
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
2020-10-15 21:10:57 +00:00
Kevin Moore 98a21f44d5 dev_compiler: cleanup outdated URLs
dartlang.org -> dart.dev
Remove references to dev-compiler group that has been deleted

Change-Id: I8d994b5f2dba19aab3c3b0fc16c5c340fbce80fd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/167442
Auto-Submit: Kevin Moore <kevmoo@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
2020-10-13 20:06:28 +00:00