Commit graph

2249 commits

Author SHA1 Message Date
Ömer Sinan Ağacan a1a942f960 [kernel] Remove references to DispatchCategory
DispatchCategory was removed in 74cf86cb.

Change-Id: Id5fa7710d7cd68d6004360bee90ac342c5f90583
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/273400
Commit-Queue: Ömer Ağacan <omersa@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2022-12-02 18:19:36 +00:00
Johnni Winther 999c9b5e19 [cfe] Add (rudimentary) subtype implementation for ViewType
Change-Id: I7b102de842a828bb2c49b347d045d5919a4a5ae5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/273241
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2022-12-02 11:17:34 +00:00
Daco Harkes 55b4542dab [pkg/vm] Native assets validator and synthesizer
Validates a yaml format encoding a native asset mapping, and
synthesizes a component containing a pragma with this information.

Yaml example:

```
format-version: [1,0,0]
native-assets:
  linux_x64:
    'package:foo/foo.dart': ['absolute', '/path/to/libfoo.so']
```

Generated format example:

```
@pragma('vm:ffi:native-assets': {
  'linux_x64' : {
     'package:foo/foo.dart': ['absolute', '/path/to/libfoo.so']
  }
})
library;
```

TEST=pkg/vm/test/native_assets/synthesizer_test.dart
TEST=pkg/vm/test/native_assets/validator_test.dart

In a follow-up CL, we will consume the yaml from `gen_kernel`
and consume the pragma in the VM for `@FfiNative`s.

Bug: https://github.com/dart-lang/sdk/issues/49803
Change-Id: Ie8d93b38ff4406ef7485e5513807e89b2772164b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/272660
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2022-12-01 11:33:27 +00:00
Johnni Winther 5994c04ef4 [cfe] Initial support for view methods
TEST=pkg/front_end/testcases/views/procedures.dart

Change-Id: I62c26183d8160a3841b74381a256d0a4b5bb9365
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/272624
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2022-12-01 09:54:40 +00:00
Chloe Stefantsova 1a8b1370a0 [cfe] Don't emit throw of AbstractClassInstantiationError
Change-Id: I4e464bdf1decf8484cd042e973e916b5aa3b8d1c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/271960
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2022-11-24 16:35:51 +00:00
Johnni Winther 6f54f6236e [cfe] Add AwaitExpression.runtimeTypeCheck
Add AwaitExpression.runtimeTypeCheck to support easy backend
implementation of runtime type check.

In response to https://github.com/dart-lang/sdk/issues/49396

TEST=pkg/front_end/testcases/general/issue49396.dart

Change-Id: I13b9b14566ebc34cdb0811c16a262421417b68e7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/270723
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2022-11-22 10:42:22 +00:00
Paul Berry 22c46e573a Field type promotion: fix CFE handling of abstract fields.
Bug: https://github.com/dart-lang/language/issues/2020
Change-Id: Ie35f7ff2d3de33c5f94bb7b703c13c9764a85c70
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/269981
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2022-11-21 15:25:03 +00:00
Johnni Winther 91509ba7c5 [cfe] Derive view representation type from field
Change-Id: I83c0f45fa57e71c8a902f872547f26fbfdc9785a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/269760
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2022-11-18 10:30:26 +00:00
Johnni Winther 9061f57ec7 [kernel] Add assert and comment to RecordConstant
Change-Id: If6a3eb00e393bbe200b02b4a49e6d79999ed0b06
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/270183
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2022-11-18 09:07:37 +00:00
Kallen Tu 9e922093da [cfe] Add sealed classes to AST, builders and dill files.
TEST=pkg/front_end/testcases/sealed_class/*

Change-Id: Iea7db59d2bba92e5f3594f6e89949e6ff3c85a80
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/269801
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
2022-11-16 23:57:29 +00:00
Johnni Winther 39c68314f2 [cfe] Remove use of the AST-based class hierarchy from the inferrer
Change-Id: I636dd75b443a23dc531fbeddfbbf3cb76358e5f0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/269780
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2022-11-15 10:44:10 +00:00
Jens Johansen 9e53a1679c [CFE] Fix weekly bot 117 (incl references for views when recompiling)
Change-Id: I25316eaf5108012ed7b7d81dda93b88e758af24a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/269684
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2022-11-15 07:08:30 +00:00
Johnni Winther 4306e07775 [cfe] Add (Source)ViewBuilder
Includes refactoring to share code with (Source)ExtensionBuilder.

Change-Id: If3cc66fa9f868d23ef756f80bc2f447cb534c5d1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/268763
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2022-11-10 21:32:37 +00:00
Johnni Winther 3247ba2ac2 [cfe] Add extension type variable checks
Change-Id: I0c3c1ef5039213d800f68346c91db05e23b7b0b0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/268341
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2022-11-09 13:29:47 +00:00
Jens Johansen 00caf79873 [kernel] Order switch cases when reading dill according to (sampled) usage
I've sampled (eagerly) reading the VM platform, a compilation of
dart2js, a compilation of "flutter gallery" and a compilation of a big
internal app, and reordered switch cases accordingly.

I can't measure any difference in runtime, but have a hard time
thinking it's not better.

I've included the tool that does the sampling.

Change-Id: If61c5a95265229c238020264010553f281fec49c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/267362
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2022-11-07 09:20:59 +00:00
Johnni Winther 05ff50e6ca [kernel] Add View and ViewType
These are needed for the 'views' feature. No nodes are created yet.

TEST=existing

Change-Id: I0c7a34e460a4d17bd39ee23e7aa6bd8851f4275e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/266620
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2022-11-03 08:42:06 +00:00
Jens Johansen 1d7014c17b [kernel] Deduplicate FunctionType(void Function()) when loading dill
On a big internal app this saves 6.5 MB of FunctionTypes.

Change-Id: I5064f92996f615ff586a2776de6775aabc2865bd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/266941
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2022-11-02 09:39:58 +00:00
Jens Johansen e3d4fbec80 [kernel] Deduplicate Names when loading dill
When loading the sdk, a compilation of dart2js and a big internal app
without lazy loading (but with useGrowableLists: false though that
part shouldn't matter) I see these changes:

Loading the sdk: Saving ~1.17 MB Public and ~0.33 MB Private.
                 A total of ~1.5 MB.
Loading a compile of dart2js: Saving: ~7.0 MB Public and ~1.1 Private.
                              A total of ~8.1 MB.
Loading a compile of a big internal app: Saving ~74.7 MB Public and
                                                ~25.4 MB Private.
                                         A total of ~100 MB.

Specifically, when loading a big internal app I see these changes:

Change, without lazy loading (and useGrowableLists: false):
Current memory: -122.88 MB
Peak memory: -92.16 MB
Heap: -102.4 MB / -92.16 MB
_PublicNames: -74.75 MB (2 mio+ fewer)
_PrivateNames: -25.4 MB (800,000+ fewer)

Change, with lazy loading (and useGrowableLists: false):
Current memory: +10.24 MB (yes, more).
Peak memory: +10.24 MB (yes, more).
Heap: +2.2 MB / +2.5 MB (yes, more)
_PublicNames: -0.76 MB (20,000+ fewer)
_PrivateNames: -11.3 KB (some hundred fewer)

Change-Id: I710d966aacf2ab184139a1fb7e65e12551e830ab
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/266386
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2022-11-01 12:02:09 +00:00
Martin Kustermann 251303f28f [vm] Remove support for old native "<name>" syntax in VM
The old `native "<name>"` syntax was lowered to `@ExternalName()`
annotations. Those have been deprecated in favor of
`@pragma('vm:external-name')`. Users have now been migrated and we can
therefore remove the VM support for `@ExternalName`.

Issue https://github.com/dart-lang/sdk/issues/28791

TEST=ci

Change-Id: I69febe49f59627659c540dd50ad0fbf704b6c3a7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/266387
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2022-11-01 09:35:02 +00:00
Jens Johansen 49e0a9b19e [kernel] Deduplicate simple interface types when loading dill
Looking at only the amount of data used by interface types after
loading a dill completely (lazy loading disabled or everything read):

Loading the sdk: Saving ~3.3 MB.
Loading a compile of a simple flutter app: Saving: ~11.6 MB.
Loading a compile of dart2js: Saving: ~18.2 MB.

Testing on a big internal app I see savings of 200+MB.

In my tests it reduces the amount of interface types by a factor of between 7 and 12.

Looking at the VMs reported memory, peak memory and heap usage, without
lazy loading for the big internal app we're talking ~200 MB savings,
with lazy loading (without loading anything) we're generally
talking a ~10MB saving (process current an peak memory,
but where the heaps total capacity was ~4 MB bigger).

https://github.com/dart-lang/sdk/issues/50161

Change-Id: Ic6601e907fb3127694f54e0865fe7c5a7057d9f5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/266383
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2022-10-31 14:33:08 +00:00
Johnni Winther 41e04fc452 [cfe] Handle non-const records in const constructors
The initializer was built in an 'inferred' rather than a 'required'
constant context, meaning that it would be encoded as a declaratively
constant literal instead of a structurally constant literal.

Closes #50132

Change-Id: I58b995d879efd2ec374b711718b63ac8f122bcfc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/262349
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2022-10-28 09:55:22 +00:00
Srujan Gaddam d67104c37c [pkg:js] Refactor mock creation to export creation
Instead of relying on descriptors, we now just take in an export
map that was already precomputed for a given class. This map is
then used to create an object literal that maps property names to
their Dart targets.

Change-Id: I431cbfb3978eb41543bb46859612e13da7637e79
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/261764
Reviewed-by: Riley Porter <rileyporter@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2022-10-24 17:37:09 +00:00
Stephen Adams b03b9c3712 Redo "[kernel] Create Source.sourceCode as view of the binary bytes"
Retrying now that https://github.com/dart-lang/sdk/issues/50206 is fixed.

Change-Id: I2612e53c845b2e906ab51bfe39db2fe775e10bca
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/264602
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2022-10-21 01:11:47 +00:00
Alexander Markov 671717b578 [vm/aot] Support dynamic record field access in TFA
TEST=language/records/simple/dynamic_field_access_test

Issue: https://github.com/dart-lang/sdk/issues/49719
Change-Id: I811db5c649988cbadf7ab29e5c4c70366f55e86b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/262845
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2022-10-19 17:49:47 +00:00
Ahmed Ashour 10e7e478a2 Fix typos
Fixes #50184

Change-Id: If17f838d932171e30ef92d1bda8d4918e7e08a8f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/263622
Reviewed-by: Lasse Nielsen <lrn@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2022-10-12 14:12:42 +00:00
Ilya Yanok 174f3d3be2 Revert "[kernel] Create Source.sourceCode as view of the binary bytes"
This reverts commit a07a0333c3.

Reason for revert: Seems to increase AOT build times significantly (see b/251787563).

Original change's description:
> [kernel] Create Source.sourceCode as view of the binary bytes
>
> This saves about 400MB heap when loading a 900MB .dill file.
>
> Change-Id: I5a09b06764cb493aab8dade2afb4665e12688133
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/255802
> Reviewed-by: Jens Johansen <jensj@google.com>
> Commit-Queue: Stephen Adams <sra@google.com>

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

Change-Id: Ia7edd7d5e711a33bd037f6edbe52ba2fb561709c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/263101
Reviewed-by: Ivan Inozemtsev <iinozemtsev@google.com>
Reviewed-by: Morgan :) <davidmorgan@google.com>
Commit-Queue: Ilya Yanok <yanok@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
Reviewed-by: Alexander Thomas <athom@google.com>
Reviewed-by: Ilya Yanok <yanok@google.com>
2022-10-10 11:20:19 +00:00
Johnni Winther c3de385658 [cfe] Unify handling of 'resolveTypeParameterType'.
We had multiple implementations of this logic and with the introduction
of IntersectionType some where not updated. Instead, this is now added
as a property of `DartType`.

Closes #50112

Change-Id: I2d7a3943b0577d905a1861aa35b0552578766993
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/262960
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2022-10-06 10:38:39 +00:00
Jens Johansen 4d9bbde5ce [kernel] AST-to-Text for records works as expected
For whatever reason https://dart-review.googlesource.com/c/sdk/+/257203
didn't follow normal textual output and would for instance output

constants  {
  #C1 = 1
  #C2 = 2
const (#C1, #C2)
const ({a:#C1, b:#C2})
const ({a:#C3, b:#C4})
const (#C5, #C3)
}

instead of something like

constants  {
  #C1 = 1
  #C2 = 2
  #C3 = (#C1, #C2)
  #C4 = ({a:#C1, b:#C2})
  #C5 = ({a:#C3, b:#C4})
  #C6 = (#C5, #C3)
}

Change-Id: I9a8d515694d3486ffbb38fdc0d1986d41d053103
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/262800
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2022-10-06 06:32:31 +00:00
Stephen Adams a07a0333c3 [kernel] Create Source.sourceCode as view of the binary bytes
This saves about 400MB heap when loading a 900MB .dill file.

Change-Id: I5a09b06764cb493aab8dade2afb4665e12688133
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/255802
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2022-10-05 20:27:59 +00:00
Johnni Winther e2bf48243f [cfe] Handle record access through type variables
... and promotions.

Closes #50124

Change-Id: Ie04db8c13f81e6d81ad12bf2677e924492ac5fc3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/262602
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2022-10-05 09:25:21 +00:00
Chloe Stefantsova 1d768f3c75 Reland "Reland "[cfe,corelib] Add class 'Record' to the core library""
This is a reland of commit 4b6a8f35b9

Original change's description:
> Reland "[cfe,corelib] Add class 'Record' to the core library"
>
> Part of https://github.com/dart-lang/sdk/issues/49713
>
> Change-Id: I56bfca49492d14bb561b32993fd9adfe775b7400
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/259583
> Reviewed-by: Johnni Winther <johnniwinther@google.com>
> Reviewed-by: Slava Egorov <vegorov@google.com>
> Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>

Change-Id: Idaab98c028312ca36bd07f569374ca8b76151a02
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/260101
Reviewed-by: Slava Egorov <vegorov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2022-10-04 12:29:47 +00:00
Ömer Sinan Ağacan c427299b1c [kernel] Add an example and a note in kernel BreakStatement docs
Change-Id: Ic0153a084950d2eea53e9fd8a0ee0332de5e2ae3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/261841
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Ömer Ağacan <omersa@google.com>
2022-09-29 12:29:47 +00:00
Paul Berry 54906759b9 Don't delegate foreign private names to noSuchMethod.
If a concrete class implements an interface containing a name that's
private to a different library, any attempt to invoke that name will
result in an exception getting thrown.  Previously, such attempts
would result in the call being diverted to noSuchMethod.

This change closes a loophole in Dart's privacy system, and paves the way for
a future implementation of promotion for private final fields (see
https://github.com/dart-lang/language/issues/2020).

Bug: https://github.com/dart-lang/sdk/issues/49687
Change-Id: Ie55805e0fc77dc39713761a80a42c28bd0504722
Tested: language tests
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/255640
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
2022-09-27 21:20:35 +00:00
Chloe Stefantsova 354f144c08 [cfe] Add initial implementation of type inference for records
Part of https://github.com/dart-lang/sdk/issues/49713

Change-Id: I9208bbfa410fbf6d200e4715ea6171ed58b3510d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/260882
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2022-09-26 15:25:27 +00:00
Johnni Winther 008190bf11 [cfe] Ensure constructor type in type alias invocation
Closes #49985

Change-Id: I0fdf1a1cc984a5ab9e10f9df794864bbeaf44579
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/260705
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2022-09-26 10:52:47 +00:00
Johnni Winther d43aa20afa [cfe] Support current uri for crashes during top level inference
+ avoid printing the stack trace twice on crash

Change-Id: Iac220117b77c30bc03212b2727efe88036819357
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/260700
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2022-09-23 08:32:49 +00:00
Chloe Stefantsova 78dd98a8f4 [cfe] Add tests for NORM on records
Part of https://github.com/dart-lang/sdk/issues/49749

Change-Id: I7a72eeb14000823067736c8c010a83481677d9b2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/260521
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2022-09-22 10:11:38 +00:00
Johnni Winther 281a8a5d2b [cfe] Implement RecordLiteral.transformOrRemoveChildren
Closes #50004

Change-Id: Iaea68b563bd59bb3280bd6ffb86f18d50f3d2a4b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/260105
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2022-09-21 08:49:16 +00:00
Chloe Stefantsova f8ef60a868 Revert "Reland "[cfe,corelib] Add class 'Record' to the core library""
This reverts commit 4b6a8f35b9.

Reason for revert: Breakages in google3.

Original change's description:
> Reland "[cfe,corelib] Add class 'Record' to the core library"
>
> Part of https://github.com/dart-lang/sdk/issues/49713
>
> Change-Id: I56bfca49492d14bb561b32993fd9adfe775b7400
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/259583
> Reviewed-by: Johnni Winther <johnniwinther@google.com>
> Reviewed-by: Slava Egorov <vegorov@google.com>
> Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>

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

Change-Id: I61c4db244329615d7d218484cd86601b1c737ba6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/259800
Reviewed-by: Slava Egorov <vegorov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
Auto-Submit: Chloe Stefantsova <cstefantsova@google.com>
2022-09-19 13:52:01 +00:00
Alexander Markov e5f3b0dc0e [vm/aot] Initial support for records in TFA
This change adds minimal support for RecordType, RecordLiteral,
RecordIndexGet, RecordNameGet and RecordConstant kernel nodes to TFA.
TFA is *not* yet extended with the ability to infer record types.

TEST=language/records/simple

Issue: https://github.com/dart-lang/sdk/issues/49719
Change-Id: I7c5eb860c6a5cb263e4d1bb55ad230e5c51f47c2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/259520
Reviewed-by: Slava Egorov <vegorov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2022-09-16 18:43:50 +00:00
Chloe Stefantsova 4b6a8f35b9 Reland "[cfe,corelib] Add class 'Record' to the core library"
Part of https://github.com/dart-lang/sdk/issues/49713

Change-Id: I56bfca49492d14bb561b32993fd9adfe775b7400
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/259583
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2022-09-16 11:46:40 +00:00
Alexander Aprelev d31c741fbb Revert "[cfe,corelib] Add class 'Record' to the core library"
This reverts commit f553f0aad9

Reason for revert: breaks g3 bot

Original change's description:
> [cfe,corelib] Add class 'Record' to the core library
>
> Part of https://github.com/dart-lang/sdk/issues/49713
>
> Change-Id: Ibb0309f97565c0a623f60e588eefcad6759d5ace
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/257066
> Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
> Reviewed-by: Johnni Winther <johnniwinther@google.com>
> Reviewed-by: Konstantin Shcheglov <scheglov@google.com>

TBR=lrn@google.com,scheglov@google.com,cstefantsova@google.com,johnniwinther@google.com

Change-Id: If386819fc7419a660c692e4187ead4ebf142c68c
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/259462
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2022-09-15 17:45:50 +00:00
Chloe Stefantsova dc4c7a1a8d [cfe] Extend UP and DOWN onto record types
Closes https://github.com/dart-lang/sdk/issues/49914

Part of https://github.com/dart-lang/sdk/issues/49713

Change-Id: I49b1ca4ca9b68c8a8dfcdd9d0fc855f173088efe
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/258005
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2022-09-15 14:09:53 +00:00
Chloe Stefantsova f553f0aad9 [cfe,corelib] Add class 'Record' to the core library
Part of https://github.com/dart-lang/sdk/issues/49713

Change-Id: Ibb0309f97565c0a623f60e588eefcad6759d5ace
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/257066
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2022-09-15 11:50:33 +00:00
Chloe Stefantsova 14c30c3f10 [cfe] Interpret undetermined nullability as nullable in UP
Closes https://github.com/dart-lang/sdk/issues/49908
Closes https://github.com/dart-lang/sdk/issues/49909

Change-Id: I55007394454f2acab0e69a948df84007fedfc3c9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/259182
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2022-09-15 07:52:33 +00:00
Johnni Winther 6795c753fd [cfe] Handle unnamed extensions in parts
This introduces a MemberName abstraction that supports the late
computation of member names, taking privacy and synthesized names
of unnamed extensions into account. With this feature, the unnamed
extension are now more directly handled as having no (known) name
which avoids the clash between the eagerly synthesized named of
unnamed extensions in different parts.

Closes #48765

TEST=existing

Change-Id: I62c00ace017141ecbc61eeecb275d0211f341c82
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/258800
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
2022-09-14 14:44:12 +00:00
Johnni Winther 4ef2914caa [kernel] Update VariableDeclaration.name comment
Change-Id: I40336a0ea93b5384bd73e7c8810cdac8d029a014
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/258925
Commit-Queue: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Auto-Submit: Johnni Winther <johnniwinther@google.com>
2022-09-13 16:17:07 +00:00
Chloe Stefantsova 05ddb78364 [cfe] Make DartTypeEquivalence symmetrical for functions and records
Change-Id: I9963ae7401d1e31e07edf90146f411b6586dbc16
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/256664
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2022-09-07 09:11:11 +00:00
Johnni Winther 7f4c3787c3 [cfe] Handle RecordConstant in ast_to_text
Change-Id: Ie967e18e35da41eb1c563cd95aa21f08a401dc5a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/257203
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2022-09-02 09:40:53 +00:00
Johnni Winther 02c47b6de0 [cfe] Support const records
Change-Id: I3c0724e18a405ec0fe2d3a60e2722d78f9e3bed6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/256666
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2022-08-31 21:47:01 +00:00
Chloe Stefantsova d4a8100908 [cfe] Implement subtype relationship for record types
Part of https://github.com/dart-lang/sdk/issues/49713

Change-Id: I736a4e4f4ba09a80dda1409a1c6640a64ab560f4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/256480
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2022-08-29 10:05:35 +00:00
Johnni Winther 2da3806823 [cfe] Handle Record(Index/Name)Get
Change-Id: I9550d1e73b7caf1924596b3208a16f51a8cfcf41
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/256362
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2022-08-26 17:10:41 +00:00
Johnni Winther f8b6897a44 [cfe] Create RecordType and RecordLiteral
Change-Id: Idd59d5c26b1d695386a14544c1013aea3329b222
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/256361
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2022-08-26 15:59:22 +00:00
Chloe Stefantsova ddff459c7f [cfe] Add RecordType, RecordLiteral, and associated nodes
TEST=Covered by upcoming language and co19 tests.

Change-Id: Ibe8ecfb7f854adce5646125f6909066e27424665
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/256066
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2022-08-25 10:33:35 +00:00
Lasse R.H. Nielsen 8a883fa54d Change : to = for default values in pkg.
Leaves some in parser test:
 pkg/front_end/parser_testcases/error_recovery/keyword_named_formal_parameter_prime.dart

TEST=Refactoring, covered by existing tests.

Change-Id: I7a83ef95df3cbd283878b3685b5c747bd89a1b16
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/256125
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
2022-08-24 15:57:16 +00:00
Jens Johansen 104b0deb5c [kernel] Fix verifier having exponential behavior
Before this CL the verifiers `visitInterfaceType` would start by calling
`node.visitChildren(this);` and finish by calling
`defaultDartType(node);` which calls `defaultNode(node)` which calls
`node.visitChildren(this);`. This means that we call `visitChildren`
twice which means exponential --- e.g. the added test with nested Lists
(List mentioned 40 times) the innermost type would have been visited
549,755,813,888 times (that's 500+ billion times) (for a total of
1 trillion+ visits to types for that alone).

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

PS: We don't want to run the formatter on that either. It doesn't
exhibit bad speed-wise behavior but the output isn't exactly pretty.

Change-Id: Ibb2f0d2669511934badb562cb96ee439bd44bebd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/256121
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
2022-08-24 06:06:12 +00:00
Johnni Winther dcaebaa793 [cfe] Add Field.isEnumElement
This adds the flag `isEnumElement` to the `Field` node and uses it
to recognize enum elements for the exhaustiveness computation on
switch statements.

Closes #49697

TEST=pkg/front_end/testcases/general/issue49697/main.dart

Change-Id: I21852f3b063329e043639c825054f538c8ed6536
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/255808
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2022-08-22 05:44:57 +00:00
Chloe Stefantsova 1611fe6f45 [cfe] Separate out IntersectionType from TypeParameterType
TEST=Covered by existing tests

Change-Id: Ie7b99b1c109edff5198cfbf5d22e1cfb1dc130d2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/253665
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Mayank Patke <fishythefish@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2022-08-18 08:47:29 +00:00
Srujan Gaddam 61abaeda3f [CFE/web] Move static interop erasure and remove outline stubber
Deletes the outline stubber as it's not necessary on any backend.
DDC should compile the entire sources and outline dill in one step.
dart2wasm operates similarly, and so only needs the modular transformer.
dart2js moves the erasure to a global transform.

Also, this CL reverts now unnecessary plumbing that was needed for the
outline stubber.

Change-Id: Ic085c4fad5a6bdfc7d6916f7fa575c6ef9b20110
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/253000
Reviewed-by: Joshua Litt <joshualitt@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
2022-08-01 18:17:44 +00:00
Anis Alibegić 40e18905f2 Fixed various typos in a lot of files
Closes https://github.com/dart-lang/sdk/pull/49478

TEST=Manual

GitOrigin-RevId: f4c9c6869dfe73639295e86574a021523b3d374d
Change-Id: I134a97caed4eec59d70e9cbca16b7e9a472cf2c1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/251902
Reviewed-by: Michael Thomsen <mit@google.com>
Commit-Queue: Alexander Thomas <athom@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Reviewed-by: Kevin Chisholm <kevinjchisholm@google.com>
Reviewed-by: Alexander Thomas <athom@google.com>
2022-07-25 12:21:59 +00:00
Srujan Gaddam f6a3d2d5c2 [pkg:js] Transform constants and supertypes in eraser
Types in constants and supertypes need to be visited in case
they include @staticInterop types.

Fixes a bug in caching in the constant replacer.

Change-Id: Icde8b7170a8806d6a1995cad57a9788893b7772f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/249441
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Riley Porter <rileyporter@google.com>
2022-07-18 18:24:53 +00:00
Alexander Thomas 5249cd9294 [release] Bump version to 2.19
Tested: Standard CQ
Change-Id: Ic52d4d38a5b117dfcdc778dedfac08315ca30a54
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/251541
Commit-Queue: Alexander Thomas <athom@google.com>
Reviewed-by: William Hesse <whesse@google.com>
2022-07-14 14:14:55 +00:00
Jens Johansen 9f8f6df70f [CFE] Cache unevaluated constant results in equivalence testing
For now it's only done for unevaluated constants as that's where an
issue has been observed.
This CL further more limits the default nesting depth for both
expressions and statements (e.g. when .toString() printing an ast node)
to 50. Again this has been shown in one case to be a good place to
stop an (exponential time) issue from happening.

Change-Id: I6affb2846a6587542ffce3f8d6914a4209b08322
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/251103
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2022-07-12 10:14:45 +00:00
Alexander Markov 3a1229e56c [kernel] Remove obsolete AsyncMarker.SyncYielding and YieldStatement.isNative
AsyncMarker.SyncYielding and YieldStatement.isNative became
obsolete after async/async*/sync* kernel transformation was removed in
https://dart-review.googlesource.com/c/sdk/+/249944.

TEST=ci

Issue: https://github.com/dart-lang/sdk/issues/48378
Change-Id: I69ac994af77f7e403686750bf8df437868bf33fa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/249947
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2022-07-11 18:20:45 +00:00
Alexander Markov 94c120a6ea [vm] Cleanup old async/async*/sync* implementation from kernel
This change removes kernel transformation which was used to
desugar async/async*/sync* functions in the old implementation of
async/async*/sync*.

The useful part of the transformation is retained in
pkg/vm/lib/transformations/for_in_lowering.dart.

TEST=ci

Issue: https://github.com/dart-lang/sdk/issues/48378
Change-Id: Ic70c1fb35162a31bcc22eac3a8f6488b61e945b4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/249944
Reviewed-by: Slava Egorov <vegorov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2022-07-11 18:12:41 +00:00
Johnni Winther f6846849b9 [cfe] Handle augment super expressions
This adds the generation of access to augmented procedures.

TEST=existing

Change-Id: I5efa9cc541b86c18735bb1f4c51c73976ffa42ca
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/250164
Reviewed-by: Tess Strickland <sstrickl@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2022-07-04 12:37:50 +00:00
Srujan Gaddam 0036dc7c57 [CFE] Add constant replacer
Adds a replacement visitor for Constant types using null as a
sentinel value for whether a subnode has changed or not (except
in the case of TreeNodes in order to match existing Visitor
semantics).

Change-Id: Iaaab1b1c608af07f36ece08071b3d703884cd91b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/248944
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
2022-06-30 18:13:46 +00:00
Johnni Winther 414d5d3836 [cfe] Include concrete augmented procedures in the AST
This is in preparation for supporting `augment super` access of
augmented members.

Change-Id: Ib306ef59faa7c9ad735304545aa414f6b21e2596
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/249862
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2022-06-29 12:27:05 +00:00
Srujan Gaddam b372fd4c52 [CFE/pkg:js] Find reference of stub if it already exists
Fixes #49301

From https://github.com/dart-lang/sdk/issues/49301#issuecomment-1165536192

Adds referenceFromIndex to outline transformations so that the eraser
can use it to find the reference for the stub if it was already created.
This is needed when the module where the stub exists is invalidated.
Since references in other modules should still be valid, we should
attempt to get that reference.

Change-Id: I5905a002480444aecd57de650cd439bdc34d4eba
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/249729
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Joshua Litt <joshualitt@google.com>
2022-06-28 18:36:02 +00:00
Alexander Markov 77ea9820aa [vm] New implementation of sync* based on suspend/resume stubs
Issue: https://github.com/dart-lang/sdk/issues/48378
Change-Id: I7f4b6b56d914a617dfd7ac724cd4414532073b4c
TEST=ci
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/249141
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2022-06-27 18:19:12 +00:00
Johnni Winther e18977ed9c [cfe] Report error for missing concrete super target
In response to https://github.com/dart-lang/sdk/issues/47406

The error is currently not reported if the mixin declaration is from
an outline dill.

Change-Id: I94a61d6409d0c238614d9f377b5f324153360bc6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/249184
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2022-06-24 14:04:49 +00:00
Johnni Winther 391540c889 [cfe] Make (Abstract)Super*.interfaceTarget non-nullable
This is a step towards improving the semantics of these nodes.

TEST=existing

Change-Id: I95bdb86790414b38af73e9e932cc228b3c0f1f6e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/249040
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
Reviewed-by: Joshua Litt <joshualitt@google.com>
2022-06-23 09:16:55 +00:00
Jens Johansen 3c8a679b46 [CFE] Handle unevaluated constants differently in constant evaluator
This for instance avoids an exponential blowup that would previously
have occurred in certain cases.

Change-Id: I258d8153e75f7059bca346826b5dec62cc1bac84
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/249000
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Joshua Litt <joshualitt@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2022-06-22 08:51:04 +00:00
Chloe Stefantsova 95d8a5d41a [cfe] Remove Kernel round-trip text serialization
Change-Id: Ifdf0df0b93773f95eb1646a313c15e0a578b5a8d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/249181
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2022-06-21 10:28:24 +00:00
Srujan Gaddam 459d57c8b8 [package:js] Add static interop stub for outlines
Fixes b/235393918

@staticInterop replaces factories with a new named node, a static
method. In order to persist this transformation in modular
compilation, this needs to be done to outlines that can then be
consumed by the source library. In order to allow erasure at the
time of 'performOutlineTransformations', coreTypes is added to that
API.

Change-Id: I90d17fff8bbe143982fcd12cfb06dc3e8d58781a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/247928
Commit-Queue: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Joshua Litt <joshualitt@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2022-06-17 19:58:49 +00:00
Johnni Winther 05bbe907d7 [cfe] Support extraneous references in serialization
This enables the serialization to handle references to libraries that
are not part of the serialized libraries. This is a step towards
removing the need to call computeCanonicalNames from outside the
serialization and to always use library filters for serialization
of a subset of the libraries in a component.

In response to b/235393918

TEST=existing

Change-Id: I48cd8b027795850ac2411a80e4b55efd517bb2cc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/248588
Reviewed-by: Jens Johansen <jensj@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2022-06-17 11:52:39 +00:00
Johnni Winther 661d9762af [cfe] Use InvalidExpression for targetless super access
This changes the encoding of super access without a target to use
InvalidExpression, similar to static access without a target, instead
of a SuperMethodInvocation/SuperPropertyGet/SuperPropertySet node with
a `null` interface target.

This is in preparation for using (Abstract)Super* nodes with the same
precision as Static*/Instance* nodes.

Change-Id: Ie0320c72241162a4c32a904a6608c9d29c2df401
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/248780
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2022-06-17 08:30:38 +00:00
Jens Johansen de23c67fb0 [kernel] Fix loading when overriding field with Procedure
Fixes https://github.com/dart-lang/sdk/issues/49261

Change-Id: Ia784afe0550865e5c9c37cd270525b7737c8b7f2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/248560
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2022-06-15 08:55:08 +00:00
Konstantin Shcheglov ba4b3d20d2 Import dart:typed_data instead of deprecated re-export from dart:io
Bug: https://github.com/dart-lang/sdk/issues/23067
Change-Id: I6bfe7afabe344bb0de690f762b5f80604809021e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/248344
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Bob Nystrom <rnystrom@google.com>
2022-06-14 06:29:37 +00:00
Johnni Winther bcf350e2ea [cfe] Support triggering inference through TypeBuilder.build
This adds the capability to trigger inference through
TypeBuilder.build when it is passed a ClassHierarchyBase object.

TypeBuilder.isExplicit is added to signal when a type can be built
without the need for inference. NamedTypedBuilder and
FunctionTypeBuilder are split into _Explicit* and _Inferred* subtype
the latter of which support late building of the type.

The new _Inferred* builders are not used yet.

Change-Id: I66fd669ae47e6eb3079461af31477215c262dcbb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/247220
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2022-06-09 16:32:15 +00:00
Alexander Markov 3e0abdbb98 Reland "[vm] Enable new implementation of async/async* in JIT mode"
TEST=ci

Issue: https://github.com/dart-lang/sdk/issues/48378
Change-Id: I5b8720b8ef5b8d28773d26c7e94c2e78d876c9d2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/247603
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2022-06-09 15:24:13 +00:00
Alexander Markov 3e10d8c833 Revert "[vm] Enable new implementation of async/async* in JIT mode"
This reverts commit b3544c44dc.

Reason for revert: avoid incompatibility between Dart->kernel compiler
and Dart VM during Dart and Flutter rolls (b/234850964).

TEST=ci

Original change's description:
> [vm] Enable new implementation of async/async* in JIT mode
>
> TEST=ci
>
> Issue: https://github.com/dart-lang/sdk/issues/48378
> Change-Id: I0fc069508cb1ce5648deb6604171dfdcd5bcb5c8
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/246082
> Reviewed-by: Johnni Winther <johnniwinther@google.com>
> Reviewed-by: Martin Kustermann <kustermann@google.com>
> Reviewed-by: Slava Egorov <vegorov@google.com>
> Commit-Queue: Alexander Markov <alexmarkov@google.com>

TBR=vegorov@google.com,kustermann@google.com,rmacnak@google.com,alexmarkov@google.com,johnniwinther@google.com

Change-Id: I6157623857dbfa9bb07eb1f620d100f5b24314d9
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Issue: https://github.com/dart-lang/sdk/issues/48378
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/247243
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2022-06-07 17:57:30 +00:00
Aske Simon Christensen 608b95c9b4 [kernel] Add exhaustiveness information to switch statements
Tested: Added flag to text output and updated expectation files
Change-Id: I44bb82242ad608b19894e22c41d8404c5003c2d1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/245982
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2022-06-07 10:45:39 +00:00
Alexander Markov 3d1c991fcf [cfe] Update test expectations after new async/async* implementation in the VM
The new implementation of async/async* doesn't use async kernel
transformation.

TEST=ci

Issue: https://github.com/dart-lang/sdk/issues/48378
Change-Id: I86594d8c0df382512e64e59847c178569f7fc38e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/246083
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2022-06-02 23:47:49 +00:00
Alexander Markov b3544c44dc [vm] Enable new implementation of async/async* in JIT mode
TEST=ci

Issue: https://github.com/dart-lang/sdk/issues/48378
Change-Id: I0fc069508cb1ce5648deb6604171dfdcd5bcb5c8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/246082
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2022-06-02 23:40:15 +00:00
Devon Carew f7c46f145c [pkg] prefer 'any' deps for package dev dependencies
Tested: CI validation
Change-Id: If65cc156130a65ffe00c6f1660ac320e2921afae
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/246053
Commit-Queue: Devon Carew <devoncarew@google.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
2022-05-27 01:34:59 +00:00
Ahmed Ashour a6fcb56901 Fix typos
Fixes #49094

TEST=ci

Change-Id: I23cdcb5ad2fc83e5e91d80e34b66af186c0cb923
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/245820
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2022-05-24 09:10:51 +00:00
Chloe Stefantsova 254b7882a1 [cfe] Adjust the number of optional positional parameters in DOWN
This CL brings the CFE into agreement with the spec and the Analyzer
for function types with optional positional parameters by adjusting
the number of such parameters.

Close https://github.com/dart-lang/sdk/issues/49044

Change-Id: I0d15bb5b4b10c5ca18b78c985e3424899155a3c6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/245367
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2022-05-20 11:41:42 +00:00
Johnni Winther cb3cac408d [kernel] Add AbstractSuper* nodes
This adds AbstractSuperMethodInvocation, AbstractSuperPropertyGet,
AbstractSuperPropertySet nodes which are to be used for super access
in mixin declaration.

These super accesses do not resolve to their statically bound target
but instead the interface target on the types in the 'on' clauses, and
need to be updated to the statically bound target upon mixin application.
This has lead backends to disregard the interface target provided by
the CFE and instead always compute targets for super accesses.

This change is a step towards creating a clear separation between the
two use cases, enabling a more precise handling of super accesses.

The new nodes are not created yet with this CL.

TEST=existing

Change-Id: I70ea9baf5b4b970b10cc72b7409633d270d57755
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/245168
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2022-05-20 09:50:01 +00:00
Liam Appelbe 521ad77689 [cfe] Mark enhanced enum toString method as synthetic
This fixes a bug where this method is showing up in coverage reports.

Also needed some plumbing in the VM for this flag, because we were
ignoring it before.

Change-Id: I9200a16dab488f5f880b9797243bd2f39de993b3
Fixes: https://github.com/dart-lang/coverage/issues/386
TEST=Added a source_report_test
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/245041
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Liam Appelbe <liama@google.com>
2022-05-17 22:11:36 +00:00
Johnni Winther 5222bfd90c [cfe] Refactor bounds checking
This CL moves the bounds checking into the TypeBuilder instead of
performing it from the outside on the computed DartType node.
This solves several problems:

  1) Errors are now reported on the type in the code instead of the
     declaration which holds the type.
  2) Checking of type aliases (both function and nonfunction type
     aliases) is now handled correctly in all cases. This achieved by
     computed the aliased type (containing TypedefType nodes)
     internally and performing the checking on this type, and only
     convert the type into the unaliased version (without TypedefType
     nodes) after checks have been performed. Previously this handled
     through the FunctionType.typedefType property for function type
     aliases and through and incomplete work-around for nonfunction
     type aliases.
  3) With 2) FunctionType.typedefType is no longer needed and is
     removed.

TEST=general/bounds_*

Change-Id: I7653bca5ccb0ebf4b3553828a298d1ad918ef235
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/243722
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2022-05-17 14:36:19 +00:00
Nate Bosch 6ebd2633cd Use any deps for all unpublished packages
It should not be necessary to ever run `pub get` for a package which is
not published. All packages used in the SDK are controlled by a single
package config, so it's not necessary to declare versions or paths for
any packages.

Remove all dependency overrides.

R=devoncarew@google.com

Change-Id: Icb328813b471f35ee4c99995f4e90aac4d8ed438
Tested: Covered by existing static analysis.
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/244767
Commit-Queue: Nate Bosch <nbosch@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
Reviewed-by: Devon Carew <devoncarew@google.com>
2022-05-17 01:22:25 +00:00
Nate Biggs c6173d3686 [dart2js] Correctness updates for async lowering.
- Wrap returns in Future.value to ensure the returned Future has the async function's return type.
- Skip any function that has try/catch/finally as these introduce more complex control flow. (Might be able to convert these using an onError callback in the future).
- Don't assume futureValueType since CFE might not populate it in Kernel when syntax is incorrect.

Change-Id: Ice3954da52a10a74f93b0adc6409a2d98e13cb3b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/241260
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
2022-05-05 21:25:45 +00:00
Paul Berry ce591d17c3 Resolve deferred function literals in stages.
This change allows function literals in invocations to be inferred in
dependency order.  For example, given the following code:

    U f<T, U>(T Function() g, U Function(T) h) => h(g());
    test() {
      var x = f(() => 0, (y) => [y]);
    }

The function literal `() => 0` is inferred first, causing the type
parameter `T` to be assigned the type `int`.  Then, `(y) => [x]` is
inferred with the benefit of this type assignment, so `y` gets the
type `int`, and consequently, `U` gets assigned the type `List<int>`.

This completes the support for
https://github.com/dart-lang/language/issues/731 (improved inference
for fold etc.)

Change-Id: I48c22693720a1cc8bbf435643e863834e07f02b1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/243002
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2022-05-03 22:04:39 +00:00
Alexander Markov 4075e8b3f9 [vm] New async*/yield/yield* implementation based on suspend/resume stubs
TEST=ci
Issue: https://github.com/dart-lang/sdk/issues/48378
Change-Id: I0c2ca9269b2c8f008a79c139a0ce10231996732d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/242923
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2022-05-02 20:53:01 +00:00
Aske Simon Christensen 28dec99cf5 [kernel] Allow bare return in sync* and async* functions in verifier
Such return statements are allowed in Dart, and they can be present in
kernel that has not been processed by the async transformation.

Change-Id: I8592cce58cb8fca2d78cdb0d5e5532715553c1ac
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/242544
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2022-04-29 15:02:51 +00:00
Jens Johansen 430abc54e8 [CFE] Add toText to Reference and CanonicalName
Add `toText` to both Reference and CanonicalName.
Change how CanonicalNames are printed through `text_util.dart` to be
more aligned with how the corresponding node would be printed had
it existed (and the CanonicalName thus normally not been used for
printing).
Add a test for (some definition of) common cases where printing should
be the same wherther done though the node, the reference or the
canonical name.
Fix usage of toStringInternal in the constant evaluator (though only
in use through an experiment) and add a test that showed that the
previous output was bad and the new isn't (at least in this case).

Change-Id: I10cbc1a542c7d8b079e0510bbd5eb5173b2e7563
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/242102
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2022-04-25 11:13:44 +00:00
Alexander Markov 2afc34112c [vm,kernel] New async/await implementation in the VM, part 1 - kernel
This change includes kernel-related changes:

* --compact-async option is added to kernel compilers (front-end
  server and gen_kernel). This option disables desugaring of async
  and await on kernel AST. Note that 'await for' is still desugared.

* File offset of the 'await' is now written for AwaitExpression nodes
  in the kernel binaries (will be used for async stack traces).

* Async/async*/sync* functions and AwaitExpression nodes are supported
  in TFA.

Design doc: go/compact-async-await.

TEST=ci

Issue: https://github.com/dart-lang/sdk/issues/48378
Change-Id: I4233086b7434bc48347f4220645b0be5f9133456
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/241842
Reviewed-by: Slava Egorov <vegorov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2022-04-21 15:11:08 +00:00
Chloe Stefantsova 59e6a37962 [cfe] Use NNBD-updated least closure in constraint gathering
Closes https://github.com/dart-lang/sdk/issues/47797

Change-Id: I58544e185fc691630d56960d54f0711f4a91b60a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/241746
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2022-04-21 09:28:28 +00:00
Srujan Gaddam a5cd295831 [CFE] Add 'futureValueType' to visitors/transformers
Closes https://github.com/dart-lang/sdk/issues/48835

This fixes an issue in which erasure is incomplete for
static interop types.

Change-Id: Ia2aef8c009d83df30bbb63b9c4dbb5b96e9f8e34
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/241820
Commit-Queue: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2022-04-20 21:59:10 +00:00
Johnni Winther f26c0e2056 [cfe] Add explicit type argument to .map(...).toList()
Expressions like

  List<VariableDeclaration> variables = ...
  List<Expression> reads = variables.map((v) => VariableGet(v)).toList()

don't get the intended type argument `<Expression>` through inference,
but instead the type inferred from the return type of the closure, in
this case `<VariableGet>`.

This causes problems when used with the AST which assumes that
expressions are interchangeable wherever they are used, and is likely
the cause of https://github.com/flutter/flutter/issues/102077 .

This CL adds an explicit type argument in these cases.

TEST=general/infer_map

Change-Id: I0bcae21f06c54f290dc20686b0d84c065d8ea04c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/241605
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2022-04-20 06:56:58 +00:00
Chloe Stefantsova 3d27f5cb79 [cfe] Adjust nullability of FutureOr in ReplacementVisitor
This fix is analogous to that made in _TypeSubstitutor in
https://dart-review.googlesource.com/c/sdk/+/240049, but made for
ReplacementVisitor.

Closes https://github.com/dart-lang/sdk/issues/48768

Change-Id: Ie3ac8fe834210d1249cbd5bd3d68b416f9efc034
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/240722
Auto-Submit: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2022-04-11 06:39:50 +00:00
Alexander Thomas 8033f609ff [release] Bump version to 2.18
Tested: Default CQ run; Dart VM changes were generated.
Change-Id: If0ea7b9fd2bb0de8459c9d4b39b9cc91cec73e23
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/240542
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Alexander Thomas <athom@google.com>
2022-04-08 08:25:33 +00:00
Johnni Winther 6980a1b4c3 [kernel] Add VariableDeclaration.hasDeclaredInitializer
The computation of default values on super parameters requires the
notion of a declared initializer. By adding this as a flag to
VariableDeclarations the implementation can now be normalized across
parameter from source and dill.

TEST=existing

Change-Id: Ic980e68b569e3bdab38d2c7c7e4374e0c931a87b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/240403
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2022-04-07 14:54:08 +00:00
Chloe Stefantsova 7d8d3bb807 [cfe] Adjust nullability of FutureOrType after substitution
Bug: https://github.com/dart-lang/sdk/issues/48631
Change-Id: I329a70386d59425cf3f157dc4b6316649f8aa389
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/240049
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2022-04-05 13:52:04 +00:00
Chloe Stefantsova abdd5765ee [cfe] Re-own TODOs assigned to 'dmitryas'
TEST=Only the comments were changed.

Change-Id: I8d4778746759466ea4c64f0eabe498da353fdd22
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/240041
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2022-04-05 09:04:53 +00:00
Nate Biggs 8fdd773096 [dart2js] Add async lowering transformation to kernel lowering transformer.
The JS expansion of an async/await function is a complex state machine.
In many cases 'async' functions either do not use 'await' or have very
simple 'await' logic which is easily captured by [Future]. By making this
transformation we avoid substantial over head from the state machine.

This implements the simplest case of a function with no awaits which translates to a Future.value() call.

Tested on cm_shell with the following results:
Before: Compiled 243,799,156 characters Dart to 155,116,598 characters
After: Compiled 243,799,156 characters Dart to 154,781,536 characters

Reduced output size by ~0.2%.

Later iterations of this will reduce JS size by ~0.7%.

Change-Id: I918f820ed2a8b27081dad0de9f922b595113d21f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/238461
Reviewed-by: Joshua Litt <joshualitt@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
2022-04-04 23:58:02 +00:00
Johnni Winther 88846ca4b4 [kernel] Remove unused Typedef fields
The fields typeParametersOfFunctionType, positionalParameters,
and namedParameters were never used.

TEST=existing

Change-Id: I0ca1c546fdf94df9c3248164a56ed88cd2468b18
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/239310
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2022-03-30 13:01:40 +00:00
Nate Biggs 0993ee0811 [CFE] Fix clone not copying futureValueType onto cloned FunctionNodes.
Happened upon this and noticed it was missing. Might not cause correctness bugs but my exclude the cloned function from some optimizations.

Change-Id: I2481c66a5f277556ac652954f03f09983d68480a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/239320
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
2022-03-29 21:24:59 +00:00
Johnni Winther 2b79d2b747 [cfe] Refactor TypeBuilders
Various cleanups to the TypeBuilder classes:

TypeBuilder:
* Remove `origin` parameter from TypeBuilder.build and instead make
  FunctionType.typedefType mutable and set if after creation.
* Remove `charOffset` and `fileUri` parameters from
  TypeBuilder.buildSupertype/buildMixedInType
* Remove `bind`, `resolveIn`, and `check` from TypeBuilder so that
  these are only present on NamedTypeBuilder
* Remove TypeBuilder.buildTypeLiteralType and instead pass an
  argument to NamedTypeBuilder that determines what type to create
  on `build`.

NamedTypeBuilder:
* Make NamedTypeBuilder.instanceTypeVariableAccess private
* Add NamedTypeBuilder.forDartType for prebuilt types
* Add NamedTypeBuilder.forInvalidType for types created for errors
* Make NamedTypeBuilder.declaration private and corresponding getter
* Check most type use errors on NamedTypeBuilder.bind
* Make NamedTypeBuilder helper methods private
* Add `TypeVariableBuilder.isClassParameter` to support checking for
  valid type variable use through the `NamedTypeBuilder.bind` method.
* Remove checking of type variable in static context from BodyBuilder
  since it is now checking on `NamedTypeBuilder.bind`.

FunctionTypeBuilder:
* Cache result of FunctionTypeBuilder.build

TypeBuilderComputer:
* Cache "constant" type declarations in TypeBuilderComputer
Change-Id: Ibaedcb255487eecc5efe70b84e5cbd5a118c1e0b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/239023
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2022-03-28 18:22:50 +00:00
Johnni Winther e16a4e76e6 [cfe] Use flatten(T) as future value type for pre-nnbd async functions
Change-Id: I38d537112e66c08bb06bc2493b3126b5f8f797b7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/239022
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2022-03-28 10:42:22 +00:00
Johnni Winther a6acb1a5f0 [cfe] Include the future value type in ast-to-text
This is in preparation for including a "futureValueType" for
non-nnbd async functions.

TEST=existing

Change-Id: I15cf5e58623df07fe3c670aa866b7b04805c0f3d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/238703
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2022-03-28 10:37:25 +00:00
Chloe Stefantsova ab62c34398 [cfe] Account for overall nullability of FutureOrType in UP
Closes https://github.com/dart-lang/sdk/issues/48631

Change-Id: I944da3a7f086a3d080de4f51bd99aa002f88cae6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/239024
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2022-03-28 07:43:48 +00:00
Johnni Winther c4eb880cac [cfe] Rename LibraryBuilder getters to [libraryBuilder]
Change-Id: I13ebe337ee3c032b02c6a4e437762ccc2ddfedde
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/237692
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2022-03-21 08:41:37 +00:00
Johnni Winther acc535dfab [cfe] Show annotations on library dependencies
This updates ast-to-text to show the annotations on import/exports. A
test is added that uses augmentation libraries to show that the
annotations are not currently ascribed to the correct library dependency.

Change-Id: I340c1ab920b16ff08dd9ac36ee9be4d2d651b4a5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/237301
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2022-03-17 09:38:25 +00:00
Chloe Stefantsova ad3d2eb5c4 [cfe] Adjust nullability of UP when r.h.s. is an intersection
Closes https://github.com/dart-lang/sdk/issues/48373

Change-Id: I9ec2211c6deccbc7c26e831863f9a9b05833380f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/236601
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2022-03-14 15:44:38 +00:00
Johnni Winther d380ae8d48 [cfe] Run commands of tool/fasta.dart in the same VM
This changes tool/fasta.dart to run the subcommand in the same VM when
no VM arguments are specified. This speeds up the tool and as a
consequence speeds up the tool/update_all.dart and
tool/update_expectation.dart tools.

Change-Id: I80b61a692a3ac2e15a7d1d097e65e1efbf9e4aee
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/236560
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2022-03-10 15:23:15 +00:00
Alexander Markov d0e8ef9816 [vm,kernel] Move transformations maintained by the VM team from pkg/kernel to pkg/vm
These transformations are maintained by the VM team and keeping them
in pkg/kernel would put a burden on the CFE team after code reviews
are tightened to require OWNERS approval.

TEST=ci

Change-Id: I931033ba987d17a2c9c6d80a16dad09bfbaa0572
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/234905
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2022-03-03 15:04:10 +00:00
Johnni Winther be7ff1daf6 [cfe] Add MacroSerializer
This adds a [MacroSerializer] interface to abstract how URIs are
created for precompiled macro components.

Two strategies are added. The existing solution using a temporary
directory in TempDirMacroSerializer and a new solution using the
recently added (experimental) Isolate.createUriForKernelBlob feature
in IsolateSerializer.

Change-Id: Id7117cc518f09e9b3762d6ca924c788c81fd9ac0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/234282
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2022-02-25 10:40:04 +00:00
Martin Kustermann f50b3a52e4 [vm] Make async lowering no longer use optional parameters
This CL

  * Makes :async_op only have two parameters: We take advantage
    of the fact that errors not only have exception != null but
    also stacktrace != null.
  * Makes :async_op have no optional parameters. This reduces
    code size significantly.
  * Removes unused parameter in _awaitHelper calls
  * Wrap the then callback instead of the error callback. (needed
    to make optional parameters required)

This results in 2% code savings on a big g3 app.
The size of :async_op shrinks on average by 11%

TEST=ci

Change-Id: I38d5fba4ebebc780b48dac5aa6a250d2c7952bfd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/233362
Reviewed-by: Slava Egorov <vegorov@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2022-02-18 12:09:42 +00:00
Alexander Thomas 30beab0f43 [infra] Add OWNERS to the Dart SDK
* Add team "groups" in tools/OWNERS_<group name>.
* Add top-level OWNERS as a fallback.
* Add OWNERS for all top-level directories.
* Add OWNERS to all packages.

For additional background information see go/dart-sdk-owners.

TEST=No op until code-owners is enabled.
Bug: b/200915407
Change-Id: I7fe6116cc599c749cd50ca16151d6d6a801d99d7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/229147
Reviewed-by: Jonas Termansen <sortie@google.com>
2022-02-14 14:06:34 +00:00
Nate Bosch 33e174084a Replace Uri.scheme == with Uri.isScheme
Use `hasScheme` in place of comparing against the empty string, and
`isScheme` to compare against all other schemes.

TEST=No behavior changes.

Change-Id: Ifc9fd13c6cf37933ebd4a754c4b500dedbcb291b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/231185
Reviewed-by: Kevin Moore <kevmoo@google.com>
Commit-Queue: Nate Bosch <nbosch@google.com>
2022-02-08 21:38:57 +00:00
Martin Kustermann 4eaacc3df9 [vm] Improve async performance by taking advantage of static types of returned values
In general any async function can return X or Future<X>. Though the
future implementation has to do different things depending on which case
we're in. It does so by using a `<obj> is Future<T>` test. This test is very
expensive if many different classes flow into `<obj>`.

Though most functions do not return `Future` objects from async
functions. We can determine that statically by looking if any returned
expression could be a future. If not, we can bypass the `is Future<T>`
test entirely.

Issue https://github.com/dart-lang/sdk/issues/48226
Issue https://github.com/dart-lang/sdk/issues/48235

TEST=pkg/front_end/testcases/general/async_function_returns_future_or.dart

Change-Id: If655bdbdddc214dd7b12be9905b3c788252547d0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/230662
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2022-02-04 22:06:59 +00:00
Jens Johansen 1044d83ab7 [kernel] Spell check kernel/bin
Change-Id: I1433d7940f9a20b70793c8e0ea801d16aa3f9eb4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/231201
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2022-02-02 12:20:46 +00:00
Jens Johansen 0794821969 [kernel] Add tool for comparing class hierarchies of two dills
This CL adds a tool that can compare the class hierarchies of two dill files.
Currently it only checks for public classes and their public supertypes.
We could extend the tool later if needed.

Currently it gives this for flutter:

```
$ out/ReleaseX64/dart pkg/kernel/bin/compare_hierarchies.dart /path/to/flutter/bin/cache/flutter_web_sdk/kernel/flutter_ddc_sdk_sound.dill /path/to/flutter/bin/cache/artifacts/engine/common/flutter_patched_sdk/platform_strong.dill "dart:nativewrappers#NativeFieldWrapperClass1"
(1): /path/to/flutter/bin/cache/flutter_web_sdk/kernel/flutter_ddc_sdk_sound.dill
(2): /path/to/flutter/bin/cache/artifacts/engine/common/flutter_patched_sdk/platform_strong.dill

Missing classes in lib dart:_internal
In (2) but not in (1): [VMLibraryHooks, Lists, VMInternalsForTesting, ClassID]

Missing classes in lib dart:ui
In (1) but not in (2): [PlatformViewRegistry]

Class(ColorFilter) in dart.ui from (2) has these extra supertypes: [ImageFilter (dart:ui)]
```

where the last line is https://github.com/dart-lang/sdk/issues/48245

It gives this for the dart sdk:
```
$ out/ReleaseX64/dart pkg/kernel/bin/compare_hierarchies.dart out/ReleaseX64/vm_platform_strong.dill out/ReleaseX64/ddc_platform_sound.dill "dart:nativewrappers#NativeFieldWrapperClass1"
(1): out/ReleaseX64/vm_platform_strong.dill
(2): out/ReleaseX64/ddc_platform_sound.dill

Missing classes in lib dart:_internal
In (1) but not in (2): [VMLibraryHooks, Lists, VMInternalsForTesting, ClassID]
```

which seems fine (dart:_internal after all)

Change-Id: I03c0dbcc3e5058a0c7d6a996b511cf6d449dd4f3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/231100
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2022-02-02 10:47:25 +00:00
Aske Simon Christensen 8df763f266 Prepare for sharing TFA and patch files between the VM and dart2wasm.
The VM patch files contain many annotations that guide the TFA and the
VM compilation pipeline. Most of these are not relevant to dart2wasm,
and having the TFA look at these when running inside dart2wasm leads to
sub-optimal, and sometimes even unsound, results.

In order to enable sharing of patch files between the VM and dart2wasm,
the annotation parser is given a target flag to control which
annotations it should recognize and how to parse them. The annotation
parser thus becomes an abstraction layer between the concrete
annotations in the patch files and the parsed annotations that the TFA
sees.

Additionally, external members used by dart2wasm don't always have
external names. To support this, the signature shaker must skip all
external members, not just the ones with an external name. This makes no
difference for the VM, since all of its external members either have an
external name or are implemented in a patch file, making them no longer
external.

TEST=ci + upcoming dart2wasm CL
Change-Id: Id425dd1ccc5560721034ae83c8cdc1593801a4e5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/231102
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Aske Simon Christensen <askesc@google.com>
2022-02-01 21:08:46 +00:00
Jens Johansen adb1dc9380 [VM] [CFE]: Make VM send over type information for expression compilation
Missing:
* Function types.
* Type variables in bounds, like "method<T, S extends T>() {}" and
  "method<T extends Foo<T>>() {}"

This is in many ways a follow-up to
https://dart-review.googlesource.com/c/sdk/+/212286

TEST=service and (cfe) expression suite tests added.

Change-Id: I20472b59ed73e9845f073e176d73b2c213f9407a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/215760
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2022-01-28 07:49:21 +00:00
Jens Johansen 441dca77fd [CFE][kernel] Use .of instead of .from
This CL replaces most usages of `.from` (e.g.
`List<String>.from(variable)`) to use `.of` instead.

This is done because code like
`List<String> foo = new List<String>.from([null])`
is valid and gives no warnings or errors.

Using `.of` instead will give an error.
Also `.of` appears to be slightly faster.

Change-Id: I1b4327be228b77e6a3e9faa283f8ce64f0565608
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/228642
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2022-01-24 14:38:36 +00:00
Jens Johansen ae593598f8 [dart:ffi] Only operate on transitive dependencies of dart:ffi
This CL does two things:
* "Reenable" the skipping of the dart:ffi transformation entirely when
  the application does not use dart:ffi. This was originally added in
  ad596359a6 but was logically disabled in 4558112105 when dart:core
  started depending on it. Here we now ignore (real) dart:* libraries
  when looking for dependencies of dart:ffi.
* Find the subset of the just compiled libraries that transitively
  depend on dart:ffi and just run the dart:ffi transformation on those
  libraries.


For dart2js that doesn't use dart:ffi at all we go from:

```
$ out/ReleaseX64/dart pkg/front_end/tool/_fasta/compile.dart -v pkg/compiler/bin/dart2js.dart | grep -i "ffi"
0:00:09.003428: Transformed ffi natives in 51ms.
0:00:09.203442: Transformed ffi annotations in 199ms.
$ out/ReleaseX64/dart pkg/front_end/tool/_fasta/compile.dart -v pkg/compiler/bin/dart2js.dart | grep -i "ffi"
0:00:09.098175: Transformed ffi natives in 52ms.
0:00:09.296847: Transformed ffi annotations in 198ms.
$ out/ReleaseX64/dart pkg/front_end/tool/_fasta/compile.dart -v pkg/compiler/bin/dart2js.dart | grep -i "ffi"
0:00:08.854341: Transformed ffi natives in 57ms.
0:00:09.061804: Transformed ffi annotations in 207ms.
```

to

```
$ out/ReleaseX64/dart pkg/front_end/tool/_fasta/compile.dart -v pkg/compiler/bin/dart2js.dart | grep -i "ffi"
0:00:09.138651: Skipped ffi transformation in 1ms.
$ out/ReleaseX64/dart pkg/front_end/tool/_fasta/compile.dart -v pkg/compiler/bin/dart2js.dart | grep -i "ffi"
0:00:09.242590: Skipped ffi transformation in 1ms.
$ out/ReleaseX64/dart pkg/front_end/tool/_fasta/compile.dart -v pkg/compiler/bin/dart2js.dart | grep -i "ffi"
0:00:09.163885: Skipped ffi transformation in 1ms.
```

When compiling the flutter gallery app that does depend on dart:ffi we go from:

```
$ out/ReleaseX64/dart pkg/front_end/tool/_fasta/compile.dart -v --target=flutter --platform=/tmp/tmp.6KV5psVGIG/flutter_patched_sdk/platform_strong.dill /tmp/tmp.6KV5psVGIG/gallery/lib/main.dart | grep -i "ffi"
0:00:16.344955: Transformed ffi natives in 78ms.
0:00:16.777218: Transformed ffi annotations in 432ms.
$ out/ReleaseX64/dart pkg/front_end/tool/_fasta/compile.dart -v --target=flutter --platform=/tmp/tmp.6KV5psVGIG/flutter_patched_sdk/platform_strong.dill /tmp/tmp.6KV5psVGIG/gallery/lib/main.dart | grep -i "ffi"
0:00:15.994674: Transformed ffi natives in 80ms.
0:00:16.472779: Transformed ffi annotations in 478ms.
$ out/ReleaseX64/dart pkg/front_end/tool/_fasta/compile.dart -v --target=flutter --platform=/tmp/tmp.6KV5psVGIG/flutter_patched_sdk/platform_strong.dill /tmp/tmp.6KV5psVGIG/gallery/lib/main.dart | grep -i "ffi"
0:00:16.027488: Transformed ffi natives in 81ms.
0:00:16.491362: Transformed ffi annotations in 463ms.
```

to

```
$ out/ReleaseX64/dart pkg/front_end/tool/_fasta/compile.dart -v --target=flutter --platform=/tmp/tmp.6KV5psVGIG/flutter_patched_sdk/platform_strong.dill /tmp/tmp.6KV5psVGIG/gallery/lib/main.dart | grep -i "ffi"
0:00:15.991628: Transformed ffi natives in 30ms.
0:00:16.226564: Transformed ffi annotations in 234ms.
$ out/ReleaseX64/dart pkg/front_end/tool/_fasta/compile.dart -v --target=flutter --platform=/tmp/tmp.6KV5psVGIG/flutter_patched_sdk/platform_strong.dill /tmp/tmp.6KV5psVGIG/gallery/lib/main.dart | grep -i "ffi"
0:00:16.184984: Transformed ffi natives in 29ms.
0:00:16.404439: Transformed ffi annotations in 219ms.
$ out/ReleaseX64/dart pkg/front_end/tool/_fasta/compile.dart -v --target=flutter --platform=/tmp/tmp.6KV5psVGIG/flutter_patched_sdk/platform_strong.dill /tmp/tmp.6KV5psVGIG/gallery/lib/main.dart | grep -i "ffi"
0:00:15.933513: Transformed ffi natives in 27ms.
0:00:16.145640: Transformed ffi annotations in 212ms.
```

TEST=Assuming tests already exists.

Change-Id: Ie13be1924d3439cb710c782af81e1e42cda2a838
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/228001
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2022-01-17 09:43:14 +00:00
Chloe Stefantsova 442836bce4 [cfe] Fail early on some subtype checks instead of crashing
Some subtype tests are crashing due to infinite recursion. It is a
known issue. An example of such test is FutureOr<T> against
FutureOr<S> where T and S are type variables declared as T extends
FutureOr<T> and S extends FutureOr<S>.

In some cases it's possible to fail early instead of crashing, for
exmaple, by checking Future-branch of the left-hand side first before
checking the type argumennt of FutureOr which would lead to the
infinite recursion. This CL does that, allowing some more type checks
to pass instead of crashing.

Change-Id: I075aa65522510db1a97ac2a8de7278a3ce3f400c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/227820
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2022-01-13 11:22:16 +00:00
Liam Appelbe 9d79a890f3 [vm] Adding branch coverage RPC to source report
TEST=Unit tests and an integration test
Bug: https://github.com/dart-lang/coverage/issues/141
Change-Id: I84958091dc6f9753f5e9446bb3517a8099019981
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/222541
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Liam Appelbe <liama@google.com>
2022-01-12 19:12:04 +00:00
Johnni Winther 8510f27d37 [cfe] Change encoding of supported dart: libraries
This CL changes the way dart: libraries are considered supported when
used in conditional imports or bool.fromEnvironment constant using
the "dart.library.*" values.

Library nodes now has an isUnsupported flag which is set according to
the "supported" property in the libraries specification. Furthermore
the Target now supplies a DartLibrarySupport interface that allows
targets to override whether dart: libraries are unsupported.

This allows the JIT/AOT to use the same platform file but still
consider dart:mirrors unsupported in AOT mode, and dart2js to consider
the internal library `dart:_dart2js_runtime_metrics` supported.

Furthermore, the internal handling is changed so that condition imports
and bool.fromEnvironments constants are computed through the same logic
for "dart.library.*" values, avoiding the need for passing these values
through the environment.

TEST=pkg/front_end/testcases/general/supported_libraries/main

Closes https://github.com/dart-lang/sdk/issues/48057
Closes https://github.com/dart-lang/sdk/issues/47814
Closes https://github.com/dart-lang/sdk/issues/47243
Closes https://github.com/dart-lang/sdk/issues/32657
Closes https://github.com/dart-lang/sdk/issues/36460

Change-Id: Ie8f8dff99167de64ced51b71d89918bf0f3bbd13
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/227020
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2022-01-11 14:52:38 +00:00
William Hesse 05b19a2218 Bump SDK version to 2.17
TEST=Standard CQ

Change-Id: I0eba9fa6eaa73bf9da8abdd93645a8e6eb8e601b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/226691
Reviewed-by: Alexander Thomas <athom@google.com>
Commit-Queue: William Hesse <whesse@google.com>
2022-01-10 11:05:10 +00:00
Johnni Winther 7695118aa2 [cfe] Add Class.isMacro
This adds support for detecting macro classes from .dill

TEST=pkg/front_end/testcases/macros/macro_class.dart

Change-Id: I8d45cafff1b4edaff7e090384be1a1cf9c8087ae
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/224948
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2021-12-22 11:49:01 +00:00
Johnni Winther 81ee883c98 [cfe] Separate entry-point read from imports/exports/parts
This separates the reading of entry-points, which do not have an
accessor library, from reading of imports, exports and parts, which must
have an access library.

This change also disallows access to platform private libraries, like
dart:_internal, as entry-points.

Change-Id: I017ca30231eb99dc8463266dca0973a02f6f0e30
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/223423
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2021-12-15 11:42:42 +00:00
Alexander Markov 1777f769ab [vm/aot] Visit TypeParameterType.promotedBound in tree shaker
If tree shaker doesn't visit TypeParameterType.promotedBound which
contains the only reference to a particular class it may remove that
class, leaving a dangling reference from promotedBound. After that
kernel AST serialization would crash with "Missing canonical name for
Reference" error.

This change also fixes TypeParameterType.visitChildren.

TEST=pkg/vm/testcases/transformations/type_flow/transformer/regress_47878.dart
Fixes https://github.com/dart-lang/sdk/issues/47878

Change-Id: I555261713240bf0be412db27efb68f32cfd8008b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/222781
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2021-12-09 20:58:20 +00:00
Johnni Winther 0e4e2be639 [cfe] Split computation of hierarchy and members
This CL splits the ClassHierarchyBuilder implementation into two parts:
1) ClassHierarchyBuilder (using ClassHierarchyNode and
   ClassHierarchyNodeBuilder) which computes the superclass/
   superinterface relations.
2) ClassMembersBuilder (using ClassMembersNode and
   ClassMembersNodeBuilder) which computes the class members.

The CL prepares for supporting subtype queries from the macro generation
at point in time where members can still be added to the classes.

Change-Id: Ic28fc6eddd1b651916de46583aeed791ce81e844
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/222461
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2021-12-09 17:31:27 +00:00
Johnni Winther 2b4934a54d [cfe,dart2js] Reuse field reference for static late lowering
In response to https://github.com/flutter/flutter/issues/89740 and
https://github.com/flutter/flutter/issues/94561

Change-Id: I22c100a575b91e70a2c5835b8db6dd450f319ce7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/221947
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2021-12-07 21:12:17 +00:00
Johnni Winther 6b4b1a0fef [cfe] Reimplement topological sort
This replaces the previous implementation (and the topological sort of
classes, on which it was based) which was O(|vertices|*|edges|). The new
implementation is O(|vertices|+|edges|).

Change-Id: I4f5f1e63b4c7dd67d6f17c087724c20d4d33bf83
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/221820
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2021-12-02 15:31:37 +00:00
Johnni Winther aa5c2b3da6 [cfe] Handle field/getter/setter in ReferenceName equality
ReferenceName is used in equivalence testing to match reference
reguardless of whether the reference have associated nodes or
canonical names. The implementation didn't previously account for
fields, getters and setters with the same simple name, and would
wrongfully equate them.

Change-Id: Iacc8e0eb2c5c04a3cf11c3b5104a8f0441cf3ab6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/221621
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2021-11-30 12:37:55 +00:00
Johnni Winther eda10ffe4b [cfe] Add test for compilation sequence to macro test
This CL adds a test for the minimal sequence of compilation steps
that need to be performed to compile the test while ensuring that
macro declarations are compiled before any application.

Change-Id: Icd6b9140e60d35d2b2b034c16e0807262f971418
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/220768
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2021-11-23 09:40:21 +00:00
Clement Skau edc0675e6e [vm] Adds offsets to sync gen.
Sync generators contain two implicit wrappers (:sync_op_gen
and :sync_op), which do not directly correspond to any user
code - and therefore do not have fileOffsets.

Some tools however rely on fileOffsets to e.g. compute code
coverage, so this change adds fileOffset inherited from the
non-synthetic code to :sync_op_gen and :sync_op.

Bug: https://github.com/dart-lang/sdk/issues/47681
Change-Id: I0c54bc3eaf5892e591fead845b5d31d2dfc9481f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/220543
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Clement Skau <cskau@google.com>
2021-11-18 12:31:16 +00:00
Johnni Winther cb1f1b8102 [cfe] Migrate text serialization suite
Change-Id: Ib44e1c69f5e9aa0e17794b647c50b28fe4cf3d62
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/220741
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2021-11-18 12:07:26 +00:00
Joshua Litt 3d1f6a48b7 [dart2js] Add dart2js target to build summaries.
Change-Id: I1ef0b3f87124333e44cb15001c556b1767ddf28f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/219841
Commit-Queue: Joshua Litt <joshualitt@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2021-11-18 00:58:40 +00:00
Alexander Thomas 55134ad5c8 Bump SDK version to 2.16
TEST=Standard CQ
Change-Id: I8598e2102df2990396afa3e56ad4a41120c5dee0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/219787
Auto-Submit: Alexander Thomas <athom@google.com>
Commit-Queue: Alexander Thomas <athom@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2021-11-10 12:51:46 +00:00
Kevin Moore 632f3428f3 Update dependencies in unpublished packages
TEST=No SDK affect. Just helping our outdated package tracking

Change-Id: I0d392694e9eb926f60667508b55094ffa208db18
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/218381
Auto-Submit: Kevin Moore <kevmoo@google.com>
Commit-Queue: Devon Carew <devoncarew@google.com>
Reviewed-by: Devon Carew <devoncarew@google.com>
2021-10-28 15:46:08 +00:00
Johnni Winther 114ad79698 [cfe] Ensure separation between StaticGet/StaticTearOff/ConstructorTearOff
Change-Id: I5b8d1103c10fecaf8fdaa69ee62215deb7eebc38
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/217641
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2021-10-26 04:53:00 +00:00
Johnni Winther c206ec38ce [cfe] Pass ReferenceFromIndex to value class transformation
This fixes fuzz testing for value_class/empty,
value_class/explicit_mixin, and value_class/value_mixin_error

Change-Id: Ia098b3ed5b8a028f1a28c5579fe5df11e5a92ff0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/217185
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2021-10-19 10:02:38 +00:00
Johnni Winther 565d0977d1 [cfe] Handle Procedure.signatureType in transformers
Change-Id: I2e32883c2e2cebaa48335d1aa3a1d1834d3a8106
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/217182
Reviewed-by: Chloe Stefantsova <dmitryas@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2021-10-19 09:24:07 +00:00
Alexander Thomas 52294b4056 [testing] Remove self-check runtime
This config hasn't been running at least since Dart 2.0. This basically
reverts https://codereview.chromium.org/2549793002.

test.py no longer supports these options:
* --skip-compilation (skipped compilation commands)
* --runtime=self-check (ran the self-check tests)

Change-Id: I135c8d488a9319ee3482131cd22eb7cd3dfa3f25
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/217003
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Alexander Thomas <athom@google.com>
2021-10-15 09:43:22 +00:00
Johnni Winther 56490f9776 [cfe] Add Procedure.signatureType
The added field holds the interface signature type for a Procedure when
this is different from the class signature type (implied by the function
parameters and return type). This is needed for forwarding semi stubs
when its declared type is different from the called super member.

Closes https://github.com/dart-lang/sdk/issues/47072

TEST=pkg/front_end/testcases/general/implement_semi_stub.dart and more

Change-Id: I4a7cdc9d564fb0a59e7b06e83646b5410d8d82f5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/216420
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Chloe Stefantsova <dmitryas@google.com>
2021-10-13 11:31:16 +00:00
Chloe Stefantsova d83e78c7a3 [cfe] Account for bounds changes in override substitution
Closes https://github.com/dart-lang/sdk/issues/47311.

Bug: https://github.com/dart-lang/sdk/issues/47311
Change-Id: I0ef3245f5a69951c323dc4a592e2c8ce194f59f3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/215763
Commit-Queue: Chloe Stefantsova <dmitryas@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2021-10-12 09:46:25 +00:00
Johnni Winther 3aaea30f10 [cfe] Pass references to lowered tear-offs
TEST=existing

Change-Id: I7e2625f87b357ceec45ec2664f7444af38ec0cf1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/215402
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2021-10-05 09:20:41 +00:00
Johnni Winther 5b7968346d [kernel] Add Field.fieldReference
This adds a third reference to Field declaration, so that we know have
three references, one for each use case:

1) fieldReference used for initialization; in FieldInitializer and as
   the key in the InstanceConstant.fieldValues map.
2) getterReference used for reading; in InstanceGet, StaticGet and
   SuperPropertyGet
3) setterReference used for writing; in InstanceSet, StaticSet and
   SuperPropertySet

TEST=existing

Change-Id: I223f130e808e7f19a831c1fe5e3a4725d1bcdc3b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/203770
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2021-09-24 12:01:08 +00:00
Chloe Stefantsova 65184a9ff4 [cfe] Don't serialize an empty show/hide clause
TEST=existing

Change-Id: Ie63444c4dbeaa45b38fd195e554780f14fed878e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/213767
Commit-Queue: Chloe Stefantsova <dmitryas@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2021-09-23 14:01:54 +00:00
Johnni Winther 6c4b75237a [kernel] Rename isFieldFormal to isInitializingFormal
+ update ast-to-text, including previous renames of covariant

TEST=existing

Change-Id: Ia29847cba791096ccd9c6c383a1b633a6150cd94
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/214042
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Chloe Stefantsova <dmitryas@google.com>
2021-09-22 15:56:07 +00:00
Lasse R.H. Nielsen 18f37dd8f3 Add extension name getter on Enum.
We use an extension getter instead of an instance getter because
it doesn't conflict with any potential existing or future enums
which want an element named `name`.
Keeping the namespace for enum elements open is a priority.
We currently only reserve `index` and `values`.

BUG: https://github.com/dart-lang/language/issues/1511

Fixes language issue #1511, which is a long-standing request,
and should replace a number of alternative implementations
which are based on parsing the `toString()`.


This version has two fields on the shared superclass, the index
and private name, and has a separate `toString` for each `enum` class
which hard-codes that enum's class name.

An earlier version had both `"name"` and `"ClassName.name"` as fields
to be able to reuse the same `toString` method on all enum classes,
but that cost too much for JS compiled code.
Even having just `ClassName.` as a field and then combining inside
`toString` requires more code to create the enum instances.
Instead this version hardcodes the `ClassName.` string once
in the `toString` method, which means each enum class has its own
toString (which can *potentially* be tree-shaken then.)

This still tree-shakes slightly worse than the previous implementation
where every enum class had its own `index` and `_name` fields
independent of each other, which could then be tree-shaken independently.
However, the `index` was already made an interface member with the
addition of the `Enum` interface, so code which accesses `.index`
on something of the `Enum` supertype could prevent tree-shaking of
all enum classes' `index` fields.
Likewise any general access to the "name" of an enum would necessarily
do the same for the name.
This CL makes up for some of that by sharing more implementation
between enum classes.

DartVM AOT CodeSize impact: ~0.15% regression on gallery (little less on big g3 app)

TEST= New tests added to enum_test.dart

Change-Id: Id25334e6c987f470f558de3c141d0e3ff542b020
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/210480
Commit-Queue: Lasse R.H. Nielsen <lrn@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2021-09-22 14:20:16 +00:00
Chloe Stefantsova 684e8cf9f7 [cfe] Distinguish between call-site access kind in shown members
Change-Id: Ie893e1b9ef46ccfb3a86393cec4342845af49f2a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/213765
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <dmitryas@google.com>
2021-09-22 10:13:37 +00:00
Sam Rawlins 8d04e49078 Remove redundant imports
Each of these imports removed is redundant with
'package:kernel/ast.dart'.

Bug: https://github.com/dart-lang/sdk/issues/44569
Change-Id: Ia9bc08b4ffd863572c84fe8a4fa465d2e8e04f7c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/213845
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2021-09-20 15:25:01 +00:00
Ben Konyi c51f885613 [ Debugger ] Allow for setting breakpoints on conditional statements
with simple boolean conditions

Fixes https://github.com/flutter/devtools/issues/3289

TEST=runtime/observatory/tests/service/breakpoint_on_simple_conditions_test.dart

Change-Id: I5ed0b78b4e462615d0d0c7dff1581b38dcf00aee
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/213421
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2021-09-16 16:12:17 +00:00
Jens Johansen 17503caa05 [CFE] Fix dangling reference to part imported as library
Before this CL:
If a library (say lib.dart) imports a file (say part.dart) that's
actually a part (of some other library (say main.dart)) an error is
given, but the "fake library" shortly representing the part is still
"linked" into the libraries dependency list.
This means that the component returned from a compilation is different
from the combination of libraries one can get to if walking all
LibraryDependency's. This also means that if we serialize the component
we can't load it back in (https://github.com/dart-lang/sdk/issues/46706).
It furthermore means that we have two different entities with the same
fileUri and importUri.

This CL rewrites a such import of a part to instead be an import of the
"parent", i.e. if a library lib.dart imports part.dart that's a part of
main.dart an error is issued, and the import is rewritten to be an import
of main.dart instead. The same thing happens to exports.

This alleviates the problems (i.e. no crashing if trying to load the dill,
no referenec to a otherwise non-existing library etc), and has the added
benefit of probably being what the user wants: Anything defined in
part.dart (that isn't private) is still in scope from lib.dart.

Change-Id: I17aca9db4edbf25b23d3ef301cf65589eeeb1635
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/213344
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2021-09-15 06:20:03 +00:00
Chloe Stefantsova 2048ab37f1 [cfe] Add shown and hidden elements to Extension Kernel node
TEST=existing

Change-Id: I8271cb7f4731dea289c855b0c5384f8e181530c9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/212761
Commit-Queue: Chloe Stefantsova <dmitryas@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2021-09-13 13:18:19 +00:00
Johnni Winther a4a1f2c0d5 [cfe] Update precedence for instantiation and constant nodes in ast-to-text
TEST=existing

Change-Id: I6269aaef293765e68e5f119184f0d24f40da9aec
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/212821
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
2021-09-10 12:10:27 +00:00
Johnni Winther d80cff6b2b [cfe] Rename isCovariant and isGenericCovariantImpl
- to isCovariantByDeclaration and isCovariantByClass, respectively.

This is done to align the terminology with the spec.

TEST=existing

Change-Id: I96b2e5d6e05caca431aad2b54545e928aee034e5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/213041
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
2021-09-10 11:27:37 +00:00
Vyacheslav Egorov d8d7af15ce [vm] Migrate away from native 'name' syntax.
As part of deprecating support for native extensions we are also
migrating away from legacy VM-specific `native 'name'` syntax
towards metadata based encoding which does not require any special
syntax.

This CL is a step 1 in migration:

- introduces support for `@pragma('vm:external-name', 'name')`
which serves as a direct replacement for `native 'name'`;
- all core libraries and tests are migrated to use the annotation;

Once this CL lands and rolls we will edit internal and external embedders
to eliminate uses of the native keyword (step 2) and finally remove
support for native keyword across our parsers (step 3).

TEST=ci

Bug: https://github.com/dart-lang/sdk/issues/28791
Change-Id: Id6dea878db82dd4fd81149243c425b5c5dc6df86
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/212461
Commit-Queue: Slava Egorov <vegorov@google.com>
Reviewed-by: Lasse R.H. Nielsen <lrn@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2021-09-08 13:39:34 +00:00
Johnni Winther fbc70d8be6 [cfe] Don't replace concrete stubs with abstract methods in mixin transformation
Closes #46389
Closes #46390

Change-Id: If3446d08d0feaf8f778dc396bbed1ebb1c5c0bc7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/212745
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2021-09-08 12:43:35 +00:00
Johnni Winther 8c6ba91e98 [cfe] Add AsExpression to forwarding super stubs where needed
Change-Id: I87cda549802f4cde8ed9b5ee56b3dfbea69a0e0d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/212588
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2021-09-08 08:42:36 +00:00
Johnni Winther bc1c71fd9b [cfe] Handle un-inlined fields/locals in eager instantiation constantification
Closes #47108

TEST=existing

Change-Id: I590939161cde1316eede7d828dff5fe6ac2790fd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/212577
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
2021-09-07 15:14:36 +00:00
Dmitry Stefantsov 0a9d14a8e3 [cfe] Adjust computation of nullability in flatten
Closes #47057.

Bug: https://github.com/dart-lang/sdk/issues/47057
Change-Id: Iad719192d0ecbe97461bfed868899072a6dd52e2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/212467
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Dmitry Stefantsov <dmitryas@google.com>
2021-09-07 10:40:44 +00:00
Ahmed Ashour f1ded6af56 Remove import dart:core
Fixes #47092

TEST=existing

Change-Id: I3c5c0a1ec5e0426642a5dc70aa9a0391a143ed93
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/212298
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2021-09-06 11:57:40 +00:00
Daco Harkes 2b5adb7231 [vm] Implement constant Maps in the VM
This CL changes the frontend to emit map and set constants which are
then processed by the constant reader in the VM.

This CL also introduces support for sending the const maps and sets
in messages between isolates and saving it in snapshots.

TEST=tests/language/const/map_test.dart (et al, for lookups)
TEST=tests/lib/isolate/message3_test.dart (et al, for isolate messages)
TEST=tools/test.py -c dartkp (for consts from clustered snapshot)
TEST=tools/test.py -n app_jitk-linux-debug-x64 (for consts from app
     jit snapshots)
TEST=Building the SDK which uses const Maps in clustered snapshots.

Closes: https://github.com/dart-lang/sdk/issues/45908

Change-Id: I1f8150a8aba8298c4e64d2571dd147743526135a
Cq-Include-Trybots: luci.dart.try:analyzer-nnbd-linux-release-try,app-kernel-linux-debug-x64-try,dart-sdk-linux-try,front-end-nnbd-linux-release-x64-try,pkg-linux-debug-try,vm-canary-linux-debug-try,vm-kernel-asan-linux-release-x64-try,vm-kernel-checked-linux-release-x64-try,vm-kernel-linux-debug-x64c-try,vm-kernel-linux-debug-x64-try,vm-kernel-linux-debug-simarm64c-try,vm-kernel-nnbd-linux-release-simarm-try,vm-kernel-optcounter-threshold-linux-release-x64-try,vm-kernel-precomp-android-release-arm_x64-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-debug-x64c-try,vm-kernel-reload-linux-debug-x64-try,vm-kernel-reload-rollback-linux-debug-x64-try,vm-precomp-ffi-qemu-linux-release-arm-try,vm-kernel-precomp-linux-debug-simarm_x64-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-tsan-linux-release-x64-try,vm-kernel-tsan-linux-release-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/203765
Reviewed-by: Martin Kustermann <kustermann@google.com>
2021-09-06 06:28:59 +00:00
Dmitry Stefantsov 6050b7e06f [cfe] Remove kernel-semantics.tex
Closes #47066.

Bug: https://github.com/dart-lang/sdk/issues/47066
Change-Id: Ia8d3397f33f049776587a4a650f4d249c9eaecb5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/212285
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2021-09-02 13:54:15 +00:00
Johnni Winther 4ff04f641b [kernel] Add always_declare_return_types lint
Change-Id: Icdcc648f42393b28daf648f752e3b4d61f51aa10
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/212043
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2021-09-01 16:50:27 +00:00
Johnni Winther 93c531f1a0 [cfe] Move force* flags from TargetFlags to TestTargetFlags
TEST=existing

Change-Id: I3db6f5bdd72ca6303766b6524df19e66b1ba1cc7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/212001
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2021-09-01 13:29:26 +00:00
Johnni Winther 097a511d9f [kernel] Add annotate_overrides lint
Change-Id: I1fffd60eeb14ecd6d5ba30cd584a75ddd4a8acfc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/212005
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2021-09-01 11:45:17 +00:00
Johnni Winther 1556299acf [cfe] Handle redirecting factory invocation in metadata
Closes #47036

Change-Id: I2c482df3b2c5c9bdca672167d03c7d77563cb12f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/211822
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2021-08-30 17:20:37 +00:00
Johnni Winther ce4e7705f2 [cfe] Handle explicit instantiation in implicit creation syntax
Closes #46719
Closes #46887

Change-Id: I4ad0f1bb4ab847a44f749113c6446f62a474143c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/211260
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2021-08-26 11:59:48 +00:00
Jens Johansen c0a9d571ce [kernel] Add 'dill_forensic' tool
Tool will try to extract useful information from invalid (e.g. partial
or wrong version) dill.
This is a first stab and could possibly be extended and improved in the
future.

Change-Id: Ib381794a3fe80036bb845800488fa0e1a7f04f83
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/211241
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2021-08-25 11:37:42 +00:00
Johnni Winther ae4543fcb9 [cfe] Report all compile-time errors found during constant evaluation
Closes #46925

Change-Id: I81e97cae05c39c24b24dae82a222f857d4730ac7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/210465
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2021-08-24 11:42:53 +00:00
Johnni Winther b54269e255 [cfe] Updates cf. equivalence visitors comments
Change-Id: Ib5990cf1434ce07019e9602150df66b359476095
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/210863
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2021-08-24 10:37:49 +00:00
Johnni Winther 6ee9cd0df1 [cfe] Add preamble to visitor generators
Change-Id: I3d0e873f7e4b03e107cb713ec375e0078e2de1a3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/211002
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2021-08-24 10:36:58 +00:00
Johnni Winther 5e7b7dbcda [cfe] Add clone test for file offsets
Change-Id: Ic6049f8262119f8d77c926ce4606c50b8323a327
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/210380
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
2021-08-18 22:18:35 +00:00
Johnni Winther c13746df2b [cfe] Add NodeCreator and clone test
Change-Id: I3b0f9c716a25eed05e83dbd653f50a478242a7a5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/210240
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2021-08-18 15:21:03 +00:00
Alexander Thomas d2bd43f43e [python3] Migrate PRESUBMIT.py files
* Force depot_tools to use python3 results (USE_PYTHON3=True).
* Fixes the dart format presubmit check.
* Remove broken DOM tools presubmit check.

TEST=Manually provoked errors and ran git cl presubmit -v -f.

Cq-Include-Trybots: luci.dart.try.shared:presubmit-try
Change-Id: I8ba46e2ae1640f1b2f82e18bc8024e0aa4838b2b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/210123
Reviewed-by: Ben Konyi <bkonyi@google.com>
Reviewed-by: William Hesse <whesse@google.com>
2021-08-16 08:29:54 +00:00
Dmitry Stefantsov 6393841036 [cfe] Account for InvalidType at nestedness level in UP and DOWN
Closes #46863.

Bug: https://github.com/dart-lang/sdk/issues/46863
Change-Id: I0cc60251f80406baa955131978cd6cbd029b228e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/209700
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Dmitry Stefantsov <dmitryas@google.com>
2021-08-11 09:40:31 +00:00
Alexander Thomas c040c050d6 [release] Bump language version to 2.15
TEST=Standard CQ.
Change-Id: Ib50b4d23f25ea4bd074904a87068a4a8774932aa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/209561
Commit-Queue: Alexander Thomas <athom@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
Reviewed-by: Leaf Petersen <leafp@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2021-08-10 13:06:53 +00:00
Stephen Adams c9ebc7c13f [dart2js/kernel] Fix poor code with nested List.generate
Cloning of InstanceInvocation kernel ast nodes was dropping the
isInvariant and isBoundSafe flags, causing the nested List.generate
expansion to not be as well optimized. `-O3` and `-O4` were 'hiding'
the problem by removing the checks anyway.

Change-Id: Id20f2eb4ef5396691a2dd5cbdd847e2d361a21d0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/209442
Commit-Queue: Stephen Adams <sra@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2021-08-09 20:38:50 +00:00
Dmitry Stefantsov f77f8e5871 [cfe] Add type checks on tearing off instance members
Closes #46784.

Bug: https://github.com/dart-lang/sdk/issues/46784
Change-Id: I7637618be0686bbffe6eb18a19049ec5da6059aa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/208881
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Dmitry Stefantsov <dmitryas@google.com>
2021-08-06 15:19:35 +00:00
Alexander Markov 300a2ea952 [cfe] Create normal bodies for redirecting factories
Replace bogus body created for redirecting factories with a
normal body which calls target factory or constructor and
forwards all arguments. Such a body can be used by back-ends
if they choose to treat redirecting factories as ordinary
factories.

TEST=ci
Fixes https://github.com/dart-lang/sdk/issues/41915
Issue https://github.com/dart-lang/sdk/issues/46231

Change-Id: I62c83bcc9005995e85de049d3d929ca86a75297f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/208681
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2021-08-04 17:51:07 +00:00
Johnni Winther 5dc4d65114 [kernel] Add InvalidExpression.expression
... and use this to wrap expressions instead of Let

TEST=existing

Change-Id: I6d1f5cfa4693222840d6cb406790c39c6ae63e5d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/208580
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
2021-08-04 08:40:18 +00:00
Riley Porter cf3387efd3 Remove Link depenedency in Tagging debug class.
Change-Id: Iabd0edb24eee278c3f12a9f61fe535645e1f26d6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/208761
Commit-Queue: Riley Porter <rileyporter@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2021-08-03 00:32:22 +00:00
Johnni Winther 8038ecab65 [cfe] Generate equivalence visitor
+ use it to allow discrepancy in incremental_dart2js_load_from_dill_test

Change-Id: I0adad30af1e502d81e870b26eb63a03b70e42333
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/205796
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2021-08-02 19:50:20 +00:00
Riley Porter b36dcbf00b [ddc] Print AST of compiled libraries with summarize-text flag.
Moves dart2js DebugPrinter and Indentation to pkg/kernel/lib/text
and produces the AST of compiled libraries when ddc is run using
the --summarize-text flag.

Change-Id: I195ff99a0929ac12791b4f7b6c5e755b19065c23
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/208460
Commit-Queue: Riley Porter <rileyporter@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2021-08-02 17:36:10 +00:00
Johnni Winther cb3a9b0043 [cfe] Remove old method invocation encoding nodes
TEST=existing

Change-Id: I05ee649ecfa7945e2e0f5e5d09441d8916a9c46e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/208185
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
2021-07-28 15:44:04 +00:00
Johnni Winther 16ebd4fe57 [cfe] Add InternalMethodInvocation, InternalPropertyGet and InternalPropertySet
- to replace internal use of the old method invocation encoding.

Change-Id: I7ca876d28beec265f1a143ce5f29deb9e61616d7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/208184
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2021-07-28 10:13:34 +00:00
Johnni Winther 286702df6b [kernel] Migrate tests
Change-Id: If426fc15f7bce54b51eaac3354061684cd5b0e17
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/207129
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
2021-07-27 12:35:37 +00:00
Johnni Winther eb1a2166cd [cfe] Fix sound mode failures
Closes #46704

Change-Id: I39b05b8432a8c316c4bca8679531d663e46817a9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/208084
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2021-07-26 15:14:17 +00:00
Johnni Winther ca8ea1d936 [cfe] Reimplement typedef tearoff lowering
Using top level procedures generated for each constructor in the
targeted class.

Closes #46676

Change-Id: I42e98254e5cdb8922fafd29e0170dd70ef3e693e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/207961
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
2021-07-23 14:29:37 +00:00
Johnni Winther 66f6a490d7 [cfe] Handle TypedefTearOff(Constant) in constant evaluation
+ fix bug in TypedefTearOff.getStaticType and implement
TypedefTearConstant.hashCode to match operator==

Closes #46674

Change-Id: I95d9e058865b7290208429f671e8f276b1d7993c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/207660
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
2021-07-22 18:09:29 +00:00
Alexander Markov 3a96674d3d Migrate pkg/vm to null safety, part 2
TEST=ci
Issue: https://github.com/dart-lang/sdk/issues/46620

Change-Id: I18bab8755bfa937b6de07a738e3f22309240da22
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/207365
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2021-07-22 17:30:49 +00:00
Johnni Winther fac1174b28 [cfe] Support lowering for redirecting factory tear offs
- including refactoring to reuse functionality in
  constructor_tearoff_lowering.dart

Change-Id: I7d9cad93a2cf7b809eb7726fbef7bf5a57a2ae82
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/207303
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
2021-07-20 15:58:40 +00:00
Johnni Winther 761eb28fd8 [cfe] Support new nodes in text serialization
Change-Id: I351e97c6547ef6196b8e081271640ed4fa39f651
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/207301
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
2021-07-20 13:58:00 +00:00
Johnni Winther 8674c7da89 [cfe] Generate RedirectingFactoryTearOff(Constant)
Change-Id: I8bf989921916ced48d583b9278d0ab8b1da03dd5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/207300
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
2021-07-20 12:44:00 +00:00
Johnni Winther 970ea21f49 [cfe] Handle constructor tear off in constant evaluation
- including updates to ast-to-text

TEST=existing

Change-Id: I4c9ccca1da3956d10f4ebb6e27f894463dd303ca
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/207082
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
2021-07-20 09:15:20 +00:00
Johnni Winther 4ca415a9fa [kernel] Update FunctionNode.computeFunctionType for constructor tear offs
FunctionNode.computeFunctionType didn't handle constructors for generic
classes and would fail to substitute type parameters from the enclosing
class.

Change-Id: Ia16ea55ce774597590e6e7da7af066b5c66dfe67
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/207123
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
2021-07-20 07:08:00 +00:00
Alexander Markov 8e1fbc9ab3 Migrate pkg/vm to null safety, part 1
TEST=ci
Issue: https://github.com/dart-lang/sdk/issues/46620

Change-Id: I2ad3f3aac03c8c13d2562a385a5b6636675401f5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/207362
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2021-07-20 06:49:20 +00:00
Johnni Winther faed4bacb3 [cfe] Add RedirectingFactoryTearOff(Constant)
+ rename RedirectingFactoryConstructor to RedirectingFactory
+ change encoding of RedirectingFactory to use FunctionNode

TEST=existing

Change-Id: I80778acc215a36ab6b87518824389a293b96f0a7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/206780
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
2021-07-19 16:46:29 +00:00
Johnni Winther 8ea5fc2773 [cfe] Add flag for lowering redirecting factories
+ handle constructor tear offs in part files

Change-Id: Id3100ebbabb1c125b18c52cca7cb06871ed0f726
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/206621
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2021-07-19 14:25:39 +00:00
Dmitry Stefantsov ff2be51b1f [cfe] Generate TypedefTearOff nodes on the output
Change-Id: I4b4a25137bffb0fa284a94908b05fef9b9e5c5da
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/206370
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2021-07-13 09:13:15 +00:00
Clement Skau ffde1585da [VM] Removes types from reused temps in async.
When we detect that a temporary variable is being reused
with a different type, we change the type of the temp
to dynamic.
This allows us to retain types for any non-reused temps.

For any dynamic temps we still have type information available
for use sites, which we can pass on via unsafeCast.

One drawback of this approach is that we don't know ahead
of time which temps are reused, and get turned into dynamic,
so we have to unsafeCast all uses.


This change is similar to what was done in:
https://dart-review.googlesource.com/c/sdk/+/138500

TEST=Adds tests/language/vm/regress_flutter_85311_test.dart,
updates relevant expect files.

Bug: https://github.com/flutter/flutter/issues/85311
Change-Id: I821c5266327892d5c3fd5bae1bebba7f3fe3931b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/205647
Commit-Queue: Clement Skau <cskau@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2021-07-12 08:55:53 +00:00
Johnni Winther a0d57b0a4d [cfe] Initial implementation for constructor tear off lowering
TEST=pkg/front_end/testcases/constructor_tearoffs/lowering/*

Change-Id: Ie8a36df4068093dc4d239b48c31f47d03054ba2b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/206080
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
2021-07-08 11:05:04 +00:00
Johnni Winther 093bfcd883 [cfe] Migrate remaining front_end/lib/ libraries
Change-Id: Ia6efe9046b80709605aef1e7f38fce523baafa91
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/206081
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2021-07-07 19:11:04 +00:00
Johnni Winther 49e2148dea [cfe] Migrate wave 10 aka the big one
Change-Id: I77a1996fe3ebd3605efc5afc6ff3308f6ebc3cac
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/205580
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2021-07-07 15:18:02 +00:00
Dmitry Stefantsov 5a9ffe55a8 [cfe] Add generation of ConstructorTearOff nodes
Change-Id: Ice66a1cdde0e4858528ec0bbc0a85054b08228c5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/206040
Commit-Queue: Dmitry Stefantsov <dmitryas@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2021-07-06 11:31:50 +00:00
Johnni Winther c019575d48 [cfe] Implement TypedefTearOffConstant.== using assumptions
Change-Id: Id329259ce95ceaa8c4a7418de487c8595f5ea7e9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/205522
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2021-06-30 15:57:00 +00:00
Dmitry Stefantsov d3e1cdfb16 [cfe] Add more Kernel nodes to support constructor tear-off feature
TEST=Covered by existing tests.

Change-Id: Idb6451ec66bd89a5abc7c4f799a1e66fd26697cf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/204980
Commit-Queue: Dmitry Stefantsov <dmitryas@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2021-06-30 11:27:42 +00:00
Alexander Markov a9757d177a [vm, kernel] Cleanup support for old invocation nodes from the VM
This change concludes switching to the new invocation nodes in the VM.
Support for the old invocation nodes (MethodInvocation, PropertyGet
and PropertySet) is removed from the VM and VM-specific kernel
transformations.

TEST=ci

Closes https://github.com/dart-lang/sdk/issues/45340

Change-Id: I0717732feb1b9c6ebdf0f6079ed42a90d00970a5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/204741
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2021-06-24 16:17:50 +00:00
Johnni Winther 1adf5dc7c6 [cfe] Verify that only new method invocation nodes are generated when supported
Closes https://github.com/dart-lang/sdk/issues/46339

Change-Id: I404a8afd141f615cfcb6050f280a1410adaac0ab
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/204580
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2021-06-23 09:41:35 +00:00
Jens Johansen 5b5956bd4e [CFE] First pass at internal test utility
This is a first pass at running inlined tests
(seemingly called doctests in for instance python) on internal CFE code.

This is not useful for testing the entire compiler for instance, but
could be useful for utility methods that take simple inputs and provide
simple outputs.

I've added tests to a few tings to try it out.

The syntax for it here is probably overly verbose but we could iterate
on that if need be.

The way it's done is that the test-code is extracted from the comments
and (virtually) "injected" in a weirdly named top level method of the
same file, which is then called from a "fake" main; the whole thing is
compiled to dill and run in an isolate.
(This is an application where making advanced invalidation support
adding top level methods would be great).

Change-Id: I7927822bca0ba68780458c40fe585882330e3b60
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/203242
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2021-06-22 08:12:58 +00:00
Konstantin Shcheglov 29191139f2 Fix pre-existing HintCode.UNNECESSARY_TYPE_CHECK_TRUE in CFE.
Change-Id: Idb85e0eeec14e31d4d4d1516bafff99186494491
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/204084
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2021-06-18 16:00:02 +00:00
Dmitry Stefantsov 7985e8b038 [cfe] Add ConstructorTearOff Kernel AST node
TEST=Adding new node id. Conflicts should be detected by existing tests.

Change-Id: I49791188345b6b8cfc7cad2fef9983d499d326ef
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/202764
Commit-Queue: Dmitry Stefantsov <dmitryas@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2021-06-16 15:20:17 +00:00
Jens Johansen cb69b50912 [CFE] Use '_getInstancesAsArray' to find leaks
This CL changes the leak finding from using heap dumps to using the
undocumented (/ private?) method '_getInstancesAsArray' to get all
instances of specific clases (i.e. the one(s) we're finding leaks for).

This - I'm hoping - is more stable than the heap dump version (which,
though, seems to have become more stable over the last weeks).

It is also potentially faster: The speed depends on how many different
classes we want to look at to find leaks.

In the flutter compilation leak tests we only look for one and it
finishes in ~78% of the time it did before. That's (rounding at bit)
going from ~6 hours to ~4.5 hours.

In vm_service_for_leak_detection.dart - that looks at four different
classes - it's something like 26% slower though.

Change-Id: Ic8abb1b293137b166ab0935eae423b60e2d4562b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/202762
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2021-06-15 10:32:54 +00:00
Jens Johansen b21e12aebf [CFE/kernel] Dummy TreeNodes can leak - null parent pointer in test
As kernel `TreeNode`s have `parent`-pointers we can leak through our
dummy nodes. This CL makes a list of all TreeNode dummys so it's
possible to iterate over them and null out the parent pointer,
making it possible to plug the leak "on demand".
This doesn't feel like a real solution and for now is only used in a
test so those leaks doesn't obscure other leaks should any such surface.

Change-Id: I6c0c60ba58df8d9d5eb6cc1c3a144ea31aa3810c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/202682
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2021-06-15 10:25:09 +00:00
Alexander Markov dd1f384f23 [vm] Generate new invocation node in the VM-specific transformations
This change updates the remaining places in the VM-specific
transformations to generate new invocation nodes (InstanceInvocation,
EqualsNull, LocalFunctionInvocation) instead of old invocation
nodes such as MethodInvocation.
The old nodes will be deleted eventually.

TEST=existing tests

Issue: https://github.com/dart-lang/sdk/issues/45340
Change-Id: I00a845e8191f79584c250f57214dd5fb4d6241ed
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/203443
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2021-06-14 17:09:33 +00:00
Devon Carew 8871c3cea2 Add Widget names to the information collected by the widget transformer.
Change-Id: I3401f22e907cddb12f8a122b1c824bc06372c42a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/203291
Commit-Queue: Devon Carew <devoncarew@google.com>
Reviewed-by: Jacob Richman <jacobr@google.com>
2021-06-14 16:14:43 +00:00
Devon Carew 522629df12 Remove some older flutter_web support in the kernel transformer.
Change-Id: I7874617caadf91fdc8ae24ff50387c825385c81f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/203281
Reviewed-by: Jacob Richman <jacobr@google.com>
Commit-Queue: Devon Carew <devoncarew@google.com>
2021-06-10 20:05:23 +00:00
Alexander Markov 6e989dfe35 [vm/kernel] Generate new invocation nodes in async transformers
This change replaces generation of old invocation AST nodes
(such as PropertyGet, PropertySet and MethodInvocation) in async
transformers with new nodes (InstanceGet, InstanceSet,
InstanceInvocation, LocalFunctionInvocation).
The old nodes will be deleted eventually.

TEST=existing tests

Issue: https://github.com/dart-lang/sdk/issues/45340
Change-Id: I8c2ead9509cfd2def2f75f9d82dc13b2a9490fdf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/202801
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Clement Skau <cskau@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
2021-06-09 22:14:51 +00:00
Mayank Patke 93c96d5857 [dart2js] Implement basic lowering for late instance variables.
This feature is gated behind the --experiment-late-instance-variables
flag.

Change-Id: I1ecb2d4d960b58204207ea055361463efa3a0bcb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/200922
Commit-Queue: Mayank Patke <fishythefish@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
2021-06-02 23:21:24 +00:00
Dmitry Stefantsov 6a3fc5010e [cfe] Rewrite computeConstCanonicalType using ReplacementVisitor
Change-Id: I2154fe11fb23e4e184f59cffef89dbcf48528662
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/200869
Commit-Queue: Dmitry Stefantsov <dmitryas@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2021-05-21 14:26:12 +00:00
Johnni Winther d8bbd356a9 [cfe] Migrate constant evaluator
Change-Id: I6e8496886257bd1361a004c8672064542427928e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/200867
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2021-05-21 08:39:01 +00:00
Alexander Markov b07305d2c3 [kernel] Visit/transform Typedef fields
Previously, certain fields of Typedef kernel AST nodes
were omitted from visitChildren(), transformChildren() and
transformOrRemoveChildren() and were not properly visited.

Also, the following related problems are fixed in this CL:
* parents of VariableDeclaration nodes in Typedef were not properly set;
* verifier didn't account for VariableDeclaration nodes in Typedefs.

TEST=existing tests

Change-Id: I4f9cb694ad9cacc9c20fe66e8a49f73f547ca245
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/96964
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2021-05-19 17:47:02 +00:00
Alexander Markov f6f2f5044c [kernel] Visit functionType/resultType fields in new invocation nodes
New invocation nodes have explicit functionType/resultType fields
which should be also visited by various visitors and transformers.

Without visiting those fields not all types are processed by
certain transformation (e.g. tree shaker) which causes crashes
during AOT compilation if new invocation nodes are enabled.

TEST=runtime/tests/vm/dart/regress_45966_test.dart (with new
invocation nodes).

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

Change-Id: I61d79650984a353d842b58da082a021ab37ab777
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/199365
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2021-05-19 17:41:42 +00:00
Jeffrey Swan fed6cadf77 fix(docs): corrects common typos in project documentation
Scope of changes is restricted to markdown docs only. Changes made in agreement with Standard American English.

Closes https://github.com/dart-lang/sdk/pull/45818
https://github.com/dart-lang/sdk/pull/45818

TEST=Manual review of the changed markdown files.

GitOrigin-RevId: 6df9128b46e4e51e634baf534c0169f62bc6a67e
Change-Id: I7b67dcb5a6e0a03db2b6eea24ace8dee207c4a11
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/196742
Reviewed-by: Bob Nystrom <rnystrom@google.com>
2021-05-18 15:48:18 +00:00
Sam Rawlins 64c2dd6193 Remove "unnecessary" imports in pkg/kernel
In each library where an import is removed, the library uses some elements
provided by the import, BUT there is another import which provides all of the
same elements, and at least one more which the library uses.

In this change, we remove the imports which can be simply removed in favor of
the other already present imports.

See https://github.com/dart-lang/sdk/issues/44569 for more information.

Change-Id: Ifebf11894fd62280b20230aa6d66de41cf6baae8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/199462
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2021-05-14 20:18:18 +00:00
Mayank Patke 2d62f325a2 [dart2js] Add a flag to omit names for late cells.
Change-Id: I67125e35b5339697b97738dd0c5540fe7a773510
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/199300
Commit-Queue: Mayank Patke <fishythefish@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
2021-05-12 14:02:10 +00:00
Dmitry Stefantsov 9f750ca0d3 [cfe] Add flags field to Extension and use it for 'extension type'
TEST=Checked by existing tests.

Change-Id: I436c0322124165f52195ebef402d7ab9104bbb30
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/198763
Commit-Queue: Dmitry Stefantsov <dmitryas@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2021-05-11 10:15:43 +00:00
Alexander Markov df3bb63a13 [cfe] Use more precise types for FunctionInvocation and LocalFunctionInvocation in type checker
Issue: https://github.com/dart-lang/sdk/issues/45340
Change-Id: I963b3a3b1143a9fbd0eac700daa11488aa5b183a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/198182
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2021-05-05 23:31:56 +00:00
Alexander Markov b00233f128 [vm] Support new kernel AST invocation nodes in the VM
TEST=Manual testing with new invocation nodes enabled.

Issue: https://github.com/dart-lang/sdk/issues/45340
Change-Id: I7eb5f03b9d9ac16c911812a5dbcd92ad43220278
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/197585
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2021-05-05 20:39:12 +00:00
Lasse R.H. Nielsen 3e9cdc5644 Seal typed-data types.
Change-Id: Ic20b68fc258ddbf5c007f9d357366d8a41d1f1e2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/192186
Reviewed-by: Lasse R.H. Nielsen <lrn@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Lasse R.H. Nielsen <lrn@google.com>
2021-05-05 18:04:05 +00:00
Jens Johansen 08faf7bddb [kernel] Fix speed regression introduced in readAnnotationList recently
In 3c83032c60
(https://dart-review.googlesource.com/c/sdk/+/195517)
a change inadvertently made it in that changed readAnnotationList from
always returning a constant empty list when the size was 0, to only
returning an (almost) constant list if the size was 0 and a non-default
setting was enabled.
In practise that meant that for normal runs we went from returning
a constant list when the size was 0 to returning a new empty list,
and the benchmarking system said
AstFromBinaryLazy (Intel Xeon): +33.2%
AstFromBinaryLazyP90 (Intel Core i5): +87.2%
AstFromBinaryLazyP90 (Intel Xeon): +117%
(i.e. generally much slower).

This CL restore the status quo and my local benchmarks says:
AstFromBinaryLazy(RunTimeRaw): -22.98% +/- 3.91%
AstFromBinaryLazyP50(RunTimeRaw): -6.20% +/- 5.03%
AstFromBinaryLazyP90(RunTimeRaw): -54.25% +/- 3.78%

Change-Id: Ia198cbbb0b2739f49a085435d98efb04740fa593
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/198280
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2021-05-05 07:36:32 +00:00
Alexander Markov df80241899 [vm] Handle new AST invocation nodes in VM kernel transformations
This change extends VM-specific kernel transformations to handle
new AST invocation nodes. The transformations may still generate
old nodes, but they should accept and handle new nodes coming from
the front-end.

TEST=Manual testing with new invocation nodes enabled.

Issue: https://github.com/dart-lang/sdk/issues/45340
Change-Id: I2de9f0eb00fcf844ba62fdc93b15a907c2d6b69d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/197443
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2021-05-04 18:15:01 +00:00
Jens Johansen da4343348e [kernel] Change constant references; remove need for map
Previously constants were referenced via there relative binary offset,
i.e. a constant reference saying 42 meant at byte offset 42 relative to
the start of the constant table in the binary. This was done to be able
to (on the VM side) read the needed constants lazily. It meant, though,
that constants had to be stored in a map, mapping from the byte position
to the constant.

This change adds a level of indirection when needing the lazy reading,
but lets the constant references reference the constant number instead
so that a constant reference saying 42 means constant number 42,
i.e. constants can be stored in a list instead of in a map.
This is done on the dart side, but the VM still stores it in a map.

The level of indirection is a tabel next to the constant table where
each entry has constant size (4 bytes) from which one can read the
relative byte offset into the constant table from the constant number,
thus still being able to read needed constants lazily.

This CL also cleans up a leftover where for instance double constants
had their textual representation saved as a string in the string indexer
(and thus the output dill) even though they were never referenced.

File size changes:
* Platform: increses 7,816 bytes.
* Compile of dart2js (including platform): decreases 71,424 bytes.

Speed changes:
* Adding `UserTag`s to the code and looking at observatories cpu profile
  on a `pkg/kernel/test/binary_bench.dart --golem AstFromBinaryLazy`
  run of a compile of dart2js reading the constant table has gone
  from ~10% to ~5%.
* Doing statistics on
  `pkg/kernel/test/binary_bench.dart --raw AstFromBinaryLazy` run of a
  compile of dart2js says -6.28169% +/- 4.97269%.
* Golem runs has nothing above the noise level.
  It does say "AstFromBinaryLazy (Intel Xeon) -4.006% (0.4 noise)" and
  "AstFromBinaryEagerP50 (Intel Core i5) -8.929% (0.6 noise)" though.

TEST=All tests running the VM tests this.

Change-Id: I07ead457527a4477de803ee55ba742f5557413d3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/196925
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2021-05-04 11:08:31 +00:00
Johnni Winther b8bc0dd751 [kernel,vm] Migrate first part of vm transformations
Since the VM package isn't opted in, the individual libraries have
been annotated with `@dart=2.12` to opt in to null safety.

TEST=existing

Change-Id: I0bfbcf69cb80d32bb6b80a171f7bdb62fde7ca65
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195277
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
2021-05-03 12:13:28 +00:00
Johnni Winther efe0ddccab [kernel] Reland: Migrate remaining bin/lib libraries in package:kernel
Change-Id: I5eacb92ea6ce00d83b3440a473cca8dad0892a87
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/197165
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2021-04-28 14:36:53 +00:00
Johnni Winther 3c83032c60 [kernel] Avoid using List.length= to grow lists in ast_from_binary
+ some additional changes needed for sound null safety

Change-Id: Icab02486109b38b6dec269a65d705126efa88622
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195517
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2021-04-28 09:59:23 +00:00
Dmitry Stefantsov cc621431f9 [cfe] Implement subtype relation for ExtensionType
Change-Id: I725c6abd4ad2ec7fe217e271fbe60d57af443f7a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/196933
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Dmitry Stefantsov <dmitryas@google.com>
2021-04-27 13:03:38 +00:00
Johnni Winther 8f92864ca3 [kernel] Rename MapEntry to MapLiteralEntry
- to avoid collisions with MapEntry from dart:core

TEST=existing

Change-Id: I7b9592844345313e79ac18d18017c74de7c02106
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/196930
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
2021-04-27 10:36:38 +00:00
Dmitry Stefantsov 3eaeec5397 [cfe] Add Extensions to the parser in the CFE type tests
Change-Id: I796fcab752da42c77414170b661dfe5c42e30aec
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/196492
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Dmitry Stefantsov <dmitryas@google.com>
2021-04-23 09:14:01 +00:00
Johnni Winther 41183d1641 [kernel] Make Location.file non-nullable
+ remove support for serializing null uris

Change-Id: I527eb5206f4999c717cb06d88bdbe6e02b7c8218
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/196482
Reviewed-by: Jens Johansen <jensj@google.com>
2021-04-23 07:19:11 +00:00
Johnni Winther fdc765faad [cfe] Make TypeParameter.defaultType non-nullable
TEST=existing

Change-Id: I0a8fdf09f742b55357411f12dc6164d4050bb83c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/196283
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
2021-04-21 13:51:50 +00:00