Commit graph

93046 commits

Author SHA1 Message Date
Johnni Winther
29ff51a008 [cfe] Add ExtensionTypeHierarchyNode(Builder)
This adds checks for conflicting supertypes and prepares for computation
of extension type members.

Change-Id: If997fe84bac929274a6014b315ecea4f3856eedd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/315441
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2023-07-25 09:15:47 +00:00
Nicholas Shahan
f4e949609c [ddc] Add new build targets for DDC assets
- Introduces a new output subdirectory `gen/utils/ddc` where the
  new build targets output files. This is intended to make the
  migration to the new assets easier since landing this change
  shouldn't immediately break any dependencies.
- Enables building the canary and stable assets at the same time.
- Changes more names in our workflow from "dartdevc" to "ddc".
- Updates the ddc-canary-linux-chrome and
  ddc-canary-linux-chrome-unsound configurations to use the
  new assets.

The new outputs appear in directories that are more consistently
named, (no more sound vs kernel confusion). They are named in
preparation for the eventual deletion of the unsound targets
without any lingering cruft to be cleaned up in the sound
directories.

The new structure is:

```
gen/utils/ddc/
           |- canary
           |  |- pkg
           |  |- sdk
           |- canary_unsound
           |  |- pkg
           |  |- sdk
           |- stable
           |  |- pkg
           |  |- sdk
           |- stable-unsound
              |- pkg
              |- sdk
```

The 'pkg' and 'sdk' directories all contain outputs with the same
files names, each compiled in the respective build modes
(sound/unsound and stable/canary).

Change-Id: I66822ebf03bba487b6d359a8e0aa818b9e7b6bef
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/313081
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
2023-07-25 00:19:52 +00:00
Sam Rawlins
8e66248765 Refactor doc comment-parsing tests
I suspect we ought to just remove many/all of the remaining simpler parser tests. I glanced at a few, and they do not seem specific to analyzer, so their covered features should be covered by parser tests in _fe_analyzer_shared.

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

Change-Id: I0e524562f6584145db5e80a154e72ea66090d924
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/316042
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2023-07-25 00:15:41 +00:00
MarkZ
afefee3018 [ddc] Trust nullability of parameters in dart:_rti.
Improves performance of legacy mode apps in the new type system.

Change-Id: Ia884ea244741df5385271f43baa4125678b995ec
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/315983
Commit-Queue: Mark Zhou <markzipan@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
2023-07-25 00:00:48 +00:00
asiva
08b76a50fc [VM/Runtime] - Turn on reachabilityBarrier in product mode.
Fixes https://github.com/dart-lang/leak_tracker/issues/25

TEST=ci (existing test has been turned on for product mode)

Change-Id: I8ead4924846947016998c9c8870b5a0c851f0185
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/315981
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
2023-07-24 22:44:39 +00:00
Jake Macdonald
e12698594c Move more macro apis to has* instead of is* nomenclature.
These are intended to be syntactic and not semantic in meaning, so I think has* is a better name.

Change-Id: Ia2a8a276c1057bde913eb755cc1a7a559d953774
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/315960
Commit-Queue: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Bob Nystrom <rnystrom@google.com>
Auto-Submit: Jake Macdonald <jakemac@google.com>
2023-07-24 20:51:38 +00:00
MarkZ
5831ed204f [ddc] Avoiding emitting legacy or mixed mode null checks for dart:_runtime and dart:_rti operations.
A side effect of DDC's new shared runtime ('dart:_rti') is that previously @notNull-annotated code paths were being extraneously null-checked. This is partly responsible for the slowdowns in some internal mixed-mode apps found in testing.

Change-Id: I3f619cfd23688f3eb4ada0079ad1664d39a7e010
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/315640
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Mark Zhou <markzipan@google.com>
2023-07-24 20:06:43 +00:00
Kallen Tu
1740829f34 [analyzer] Remove unused methods in the constant evaluator.
Found some methods that weren't being referenced anywhere, or they
weren't cleaned up. Removing because it's just dead code.

Change-Id: Id344d2d7cedd87468255a33fea75bfda97d10cac
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/316000
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
2023-07-24 19:44:19 +00:00
Nicholas Shahan
9c7a5b8ed0 [ddc] Create new configs for DDC unit test results
- Run the tests on the existing DDC bots.
- In the future we would like to move these to their own bots so
  they can be triggered individually.

Change-Id: I2ab022f19323cdfd20f42ef5c41777547ec428f4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/313882
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Anna Gringauze <annagrin@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
2023-07-24 17:44:19 +00:00
Ömer Sinan Ağacan
7fec037b6b [dart2wasm] Split more patch files into patch + implementation files
Following the refactoring we started in previous CLs, this splits string
and int patch files into (1) patch files that only patch and don't add
implementation classes (2) files for implementation classes (3) helpers.

Changes:

- `string_patch` is split into `string.dart` and `string_patch.dart`.

- VM's `integers_patch.dart` copied as `int_patch.dart` and updated.
  This was needed as `integers_patch` requires VM's library paths in
  imports.

  We needed to copy this file to be able to optimize based on
  dart2wasm's implementation classes. However in this CL we copy the
  file as-is and update import paths.

- VM's `string_buffer_patch.dart` copied to be able to use the string
  implementation classes from the new library.
  `string_buffer_create.dart` is merged ino `string_buffer_patch.dart`.

- `getHash` and `setHash` to set object identity moved to
  `object_helper.dart`, to be able to use in string implementations.

- Redundant `new` keywords in copied files removed.

One TODO added in `string_buffer_patch.dart` when allocating a new
string to the buffer:

    // _parts = _GrowableList.withCapacity(10)..add(str);
    // TODO(omersa): Uncomment the line above after moving list
    // implementations to a library.
    _parts = [str];

We can enable the old code again after moving list implementations to a
library.

Change-Id: Ice5dba40b3ba894797028987d4b42cb0c0f0c230
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/315821
Commit-Queue: Ömer Ağacan <omersa@google.com>
Reviewed-by: Joshua Litt <joshualitt@google.com>
2023-07-24 16:58:52 +00:00
Ryan Macnak
8462db66b0 [vm, gc] Add tests for weakness across generations.
TEST=ci
Change-Id: I4bbe7ef47b8d8042eccc8f3d18521053cdc45d23
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/315000
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2023-07-24 16:55:47 +00:00
Ryan Macnak
41548aa698 [test] May rarely reach OOM without an aborted scavenge.
Whether the reordered objects fail to fit depends non-deterministically on the parallel worker speeds and the exact contents of new-space that vary with each VM or core library change.

Bug: https://github.com/dart-lang/sdk/issues/52936
Change-Id: I6e287d42b5ca77d2ffafd9a5a053118617d6fe51
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/313940
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2023-07-24 16:50:48 +00:00
Samuel Rawlins
008cb0bbc1 Revert "Separate out UNUSED_ELEMENT_PARAMETER from UNUSED_ELEMENT"
This reverts commit a458bab09a.

Reason for revert: broke flutter snippet tests, and maybe customer tests

Work towards https://github.com/flutter/flutter/issues/131096

Original change's description:
> Separate out UNUSED_ELEMENT_PARAMETER from UNUSED_ELEMENT
>
> Fixes https://github.com/dart-lang/sdk/issues/49025
>
> Change-Id: I401093e5b76bcf707060ce022c346e26c6807aa0
> Tested: try-bots
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/303261
> Commit-Queue: Samuel Rawlins <srawlins@google.com>
> Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
> Reviewed-by: Ben Konyi <bkonyi@google.com>
> Reviewed-by: Konstantin Shcheglov <scheglov@google.com>

Change-Id: Ib0c9afc4911efd620013896fb895ab7825c50aa4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/315940
Commit-Queue: Siva Annamalai <asiva@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2023-07-24 16:25:07 +00:00
Jake Macdonald
5220b9e5f7 Add Extension declaration introspection and extension macros
Bug: https://github.com/dart-lang/language/issues/3223
Change-Id: I43e0ea17ea1bf8dbb41ad899675ac25d26ca568f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/315300
Commit-Queue: Jake Macdonald <jakemac@google.com>
Reviewed-by: Bob Nystrom <rnystrom@google.com>
Auto-Submit: Jake Macdonald <jakemac@google.com>
2023-07-24 15:24:10 +00:00
Paul Berry
03a91b5d2a Simplify handling of variable expressions in shared analysis tests.
When using the "mini-ast" pseudo-language to write unit tests for the
flow analysis and type analysis logic in the `_fe_analyzer_shared`
package, it is no longer necessary to use `.expr` to turn a `Var` into
an `Expression`; this now happens automatically. The way this works
under the hood is that the `Var` and `Expression` classes implement
the `ProtoExpression` interface; constructs that expect expressions
are declared with input parameters of type `ProtoExpression`, and they
automatically convert to `Expression`s when necessary.

Change-Id: I85c493145c3fc41a5296c1807cd63fe1401672db
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/315247
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2023-07-24 15:03:19 +00:00
Konstantin Shcheglov
2d5dd229fe Add ExtensionTypeDeclaration, parse into it.
Change-Id: I5f7e8b074a137f6be86965509a47ce10c11e05e9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/315620
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2023-07-24 15:02:38 +00:00
Johnni Winther
d9a1bd7762 [cfe] Refactor HierarchyBuilder
This removes the substitutions from ClassHierarchyBuilder and moves
the checking of inheritance conflict to the ClassHierarchyNodeBuilder.

Change-Id: I87a943102ab644c3b50acb07defb156e686225d1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/315102
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2023-07-24 14:55:14 +00:00
Chloe Stefantsova
cc5ba81491 [cfe] Use term equality in place of identity in UP and DOWN
Closes https://github.com/dart-lang/sdk/issues/52997

Change-Id: I8b15ca1c4d2e3efbc8d7cdebeed1b16fe92d542b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/315443
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2023-07-24 14:54:34 +00:00
Danny Tuppeny
f191f235df [dds/dap] Fix some races in termination of test runs in DAP tests
It's not guaranteed that a "terminate" request will get a response so this changes the helper to accept a "terminated" event as acknowledgement of termination too.

It also fixes some issues running individual tests that didn't set a CWD (by setting a default for tests, since we can't "dart run test:test" without a cwd), and also updates a breakpoint test to not send breakpoints on invalid lines (something that had been fixed in the CLI test, but not the Test test).

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

Change-Id: I19dd60eb2b6d56035bb4d5b02d8e90713a8ce42d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/315823
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2023-07-24 14:41:40 +00:00
Martin Kustermann
8c60c4e70f [vm] Rewrite tools/offset_extractors.sh in Dart
Also

* Make C++ offset_extractor binaries emit entire if/def condition
  (including product vs non-product)
  => This makes it much nicer to look up offsets, as the preceding
     #if condition will be the whole condition.

* Run the builds & offset extractions in parallel

This will make it easier to extend the cross product of our
configurations that require different offsets (e.g. sanitizers)

TEST=Manually run.

Change-Id: I458deb7a1c9403ab3624dd6b6ca51df72d6a6b28
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/312442
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Tess Strickland <sstrickl@google.com>
2023-07-24 12:47:52 +00:00
Ilya Yanok
3911ef982d Try to fix _SubstitutedTypeParameters
It really looks like `_SubstitutedTypeParameters` factory
constructor assumes its `substitution` argument doesn't
include any of `elements` neither as a key, nor anywhere
it the result types. Since if it does contains a key from
`elements` that part of `substitution` will be lost, overriden by
`...substitution2.map` part of `Substitution.fromMap` call.
And if it has `elements` mentioned anywhere in values of the
`substitution` map, those won't be renamed.

But sometimes `_SubstitutedTypeParameters._SubstitutedTypeParameters`
is called with a `subtitution` that includes some of `elements`.
For example, that's what happens in both added tests.

I assume it never breaks, because the part of `substitution`
that acts on `elements` is trivial: just renaming a type
variable to a fresh name. And since `_SubstitutedTypeParameters`
just gets yet another fresh name for it, that works.

One small problem arises though if a type variable renamed by
`substitution` has a bound that references the type variable itself
(like `T extends Foo<T>`). In that case bound gets substituted with the
`substitution` first, so `substitution2` doesn't work on it anymore.
So we end up with an element `T0 extends Foo<T1>`, where `T0` and
`T1` and two different fresh names for `T`.

This commit changes the order of substitutions when handling bounds,
such that the part of `substitution` that substitutes `elements` is
effectively ignored. That agrees with the existing behavior of
rewriting this part of `substitution` in the result, so it shouldn't
make things worse.

Change-Id: I8f68c4342aad0c8f59f7c01a6cfac074946529ef
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/312401
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Ilya Yanok <yanok@google.com>
2023-07-24 12:23:27 +00:00
Daco Harkes
72dd200f8a [pkg][dartdev] Error on native assets but not enabled
And only print logs if `-v` is passed.

TEST=pkg/dartdev/test/native_assets/

Bug: https://github.com/dart-lang/sdk/issues/50565
Change-Id: Iccf879c80ea01cb39f9dd0d13c2f515a885d11d2
Cq-Include-Trybots: luci.dart.try:pkg-linux-debug-try,pkg-linux-release-try,pkg-mac-release-arm64-try,pkg-mac-release-try,pkg-win-release-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/314721
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Hossein Yousefi <yousefi@google.com>
2023-07-24 11:25:06 +00:00
Martin Kustermann
11d820890e Use utf8.encode() instead of longer const Utf8Encoder.convert()
The change in [0] has propagated now everywhere, so we can use
`utf8.encode()` instead of the longer `const Utf8Encoder.convert()`.

As the checked-in SDK has been rolled to include [0] we can now rely on
the better return type.

[0] https://github.com/dart-lang/sdk/issues/52801

TEST=ci

CoreLibraryReviewExempt: Minor cleanup.
Change-Id: I2c0144023e03b2c265582d83a7fb9469b02f1570
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/313563
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2023-07-24 09:28:38 +00:00
Daco Harkes
87aba00a12 [tool] find_builders.dart
A script to find all try jobs for a set of tests.

Usage:

```
$ tools/find_builders.dart ffi/regress_51504_test ffi/regress_51913_test
Cq-Include-Trybots: luci.dart.try:vm-kernel-linux-debug-x64,...
```

Change-Id: I85abd3ca2b2adf4e184a38f5ef821d40fbd97bf2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/314800
Auto-Submit: Daco Harkes <dacoharkes@google.com>
Reviewed-by: William Hesse <whesse@google.com>
Commit-Queue: William Hesse <whesse@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2023-07-24 09:07:04 +00:00
Konstantin Shcheglov
4bb8312b4a Revert "Move API declarations of elements into src/, re-export."
This reverts commit 43db92d9ed.


Revert "Tweaks for comments of classes around augmentations."

This reverts commit 6d0fb5094f.

Change-Id: I9508169158d536302579346defebf696edfe4bec
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/315660
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2023-07-23 16:43:30 +00:00
Jia Hao Goh
11d0f060ef [dart2wasm] Fix location RangeError when using part
Here's a minimal repro that this CL fixes:

`ui.dart`

```dart
library dart.ui;

import 'dart:ffi';

part 'foo.dart';
```

`foo.dart`

```dart
part of dart.ui;

@Native<Void Function()>(symbol: 'foo_func', isLeaf: true)
external void foo_func();
```

When compiling with `compile_platform.dart` with `--target=dart2wasm`, the following error appears:


```
Unhandled exception:
Verification error: Target=wasm, VerificationStage.afterModularTransformations: Invalid location with target 'wasm' on FunctionNode() (FunctionNode): RangeError (offset): Invalid value: Not in inclusive range 0..56: 91
Context: 'foo_func_$import'.
Node: 'FunctionNode()'.
#0      VerificationErrorListener.reportError (package:kernel/verifier.dart:81:5)
#1      VerifyingVisitor.problem (package:kernel/verifier.dart:222:14)
#2      VerifyingVisitor._getLocation (package:kernel/verifier.dart:1361:7)
#3      VerifyingVisitor._hasLocation (package:kernel/verifier.dart:1370:26)
#4      VerifyingVisitor.getSameLibraryLastSeenTreeNode (package:kernel/verifier.dart:1342:28)
#5      VerifyingVisitor.localContext (package:kernel/verifier.dart:1382:24)
#6      VerifyingVisitor.defaultDartType (package:kernel/verifier.dart:1491:41)
#7      Visitor.visitVoidType (package:kernel/visitor.dart:1309:37)
#8      VoidType.accept (package:kernel/ast.dart:11190:42)
#9      FunctionNode.visitChildren (package:kernel/ast.dart:3919:16)
#10     VerifyingVisitor.visitChildren (package:kernel/verifier.dart:259:10)
#11     VerifyingVisitor.visitWithLocalScope (package:kernel/verifier.dart:266:5)
#12     VerifyingVisitor.visitFunctionNode (package:kernel/verifier.dart:721:5)
#13     FunctionNode.accept (package:kernel/ast.dart:3908:38)
#14     VerifyingVisitor.visitProcedure (package:kernel/verifier.dart:620:19)
#15     Procedure.accept (package:kernel/ast.dart:3311:40)
#16     visitList (package:kernel/ast.dart:14488:14)
#17     Library.visitChildren (package:kernel/ast.dart:591:5)
#18     VerifyingVisitor.visitChildren (package:kernel/verifier.dart:259:10)
#19     VerifyingVisitor.defaultTreeNode (package:kernel/verifier.dart:196:5)
#20     TreeVisitor.visitLibrary (package:kernel/visitor.dart:503:35)
#21     VerifyingVisitor.visitLibrary (package:kernel/verifier.dart:367:11)
#22     Library.accept (package:kernel/ast.dart:577:38)
#23     visitList (package:kernel/ast.dart:14488:14)
#24     Component.visitChildren (package:kernel/ast.dart:14320:5)
#25     VerifyingVisitor.visitChildren (package:kernel/verifier.dart:259:10)
#26     VerifyingVisitor.visitComponent (package:kernel/verifier.dart:342:7)
#27     Component.accept (package:kernel/ast.dart:14313:38)
#28     VerifyingVisitor.check (package:kernel/verifier.dart:171:15)
#29     verifyComponent (package:kernel/verifier.dart:69:20)
...
```

The issue seems to be that after doing this native transformation, the node's `fileUri` references the enclosing library (`ui.dart` above), but the `node.location` references the actual source file (`foo.dart` above) indirectly through `node.fileOffset`.

This ends up being an issue when compiling the platform dill in Google3,   but I didn't look into why `flutter build web --wasm` isn't broken.

Internal bug: b/292172146

Change-Id: I2b8d7d215b2c36354860257ce651d50168e9523d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/315360
Reviewed-by: Ömer Ağacan <omersa@google.com>
Commit-Queue: Jia Hao Goh <jiahaog@google.com>
2023-07-21 23:08:28 +00:00
Anna Gringauze
a322a97fac [ddc] Add debugger runtime API
Define debugger runtime API so the debugger can display objects without knowing DDC implementation details.

- Add new DDC debugger runtime API in `debugger.dart`
- Add helpers for getting some type information in new and old type systems
- Add tests


Closes: https://github.com/dart-lang/sdk/issues/52773
Change-Id: I8efa4cacebb0d73ef58b5360979089cba2039379
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311154
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Mark Zhou <markzipan@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
Commit-Queue: Anna Gringauze <annagrin@google.com>
2023-07-21 20:10:15 +00:00
Konstantin Shcheglov
4854aabac9 Stop expecting 'inlineKeyword' during class parsing.
Inline classes will be replaced with extension types.

Change-Id: I9472dfbb92f7f50a4649e6f1953481a9ac237fe3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/313284
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Auto-Submit: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-07-21 19:12:48 +00:00
Ryan Macnak
d29235cdb5 [vm] Speed up the ARM simulators.
Cf. 01a7f207c3.

TEST=ci
Change-Id: I8b6f9b827c1725d85013de70a1346303bdd9129e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/283200
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2023-07-21 19:06:43 +00:00
Ömer Sinan Ağacan
37581cb79e [dart2wasm] Fix names of dynamic call entry functions
Currently all closure dynamic call entries have the same name. This
makes it difficult to find locations of crashes. Example:

    wasm-function[677]:0x1de1d: RuntimeError: illegal cast
    RuntimeError: illegal cast
        at dynamic call entry (wasm://wasm/000909b2:wasm-function[677]:0x1de1d)
        at method forwarder for 'call' (wasm://wasm/000909b2:wasm-function[583]:0x1b474)
        ...

With this we now add the function name before "dynamic call entry":

  wasm-function[677]:0x1de1d: RuntimeError: illegal cast
  RuntimeError: illegal cast
      at C.m1 tear-off dynamic call entry (wasm://wasm/000921c6:wasm-function[677]:0x1de1d)
      at method forwarder for 'call' (wasm://wasm/000921c6:wasm-function[583]:0x1b474)
      ...

Which makes it easy to find the function in .wat output as there is only
one function with the name "C.m1 tear-off dyamic call entry".

Change-Id: Iea726b695fc29b361a347b64194d5c09601a0999
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/315440
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Ömer Ağacan <omersa@google.com>
2023-07-21 17:48:38 +00:00
Konstantin Shcheglov
6d0fb5094f Tweaks for comments of classes around augmentations.
Change-Id: If380225009237ca260cfb11b0f1861b50d34cae4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/315223
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-07-21 17:42:32 +00:00
Ömer Sinan Ağacan
8b709ded96 [dart2wasm] Generate type names in names section
Change-Id: I35879dba0e5e4ecee279bdd8bf725798cd806595
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/315402
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Ömer Ağacan <omersa@google.com>
2023-07-21 17:36:47 +00:00
Johnni Winther
65ce98f6de [cfe] Report error on cyclic extension types
Change-Id: I556a7fb63818879ac4adf94e070f68bf3b732036
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/314440
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2023-07-21 17:34:28 +00:00
Ryan Macnak
cdddf869f2 [vm, compiler] Use acquire ordering to load the type arguments instantiation cache.
TEST=tsan
Change-Id: I6dea219ecb26949f01fc51b1c46fd53d3921aba8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/315246
Reviewed-by: Tess Strickland <sstrickl@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2023-07-21 17:13:31 +00:00
Alexander Thomas
1cfcb4feaa [presubmit] Remove check to keep _2 suites in sync
We have disabled most legacy testing and keeping the old suites in sync
is no longer worth the effort.

Change-Id: Id2f60ef558225bfc16836ad9c11e4c5819717b45
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/315401
Auto-Submit: Alexander Thomas <athom@google.com>
Reviewed-by: Bob Nystrom <rnystrom@google.com>
Commit-Queue: Bob Nystrom <rnystrom@google.com>
2023-07-21 16:08:49 +00:00
Konstantin Shcheglov
43db92d9ed Move API declarations of elements into src/, re-export.
In following CLs I plan to add `final` and `sealed` modifiers.

Change-Id: Ia6b9091034ed9f8f6f8576dbe6029d7e72a9d6b3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/315249
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2023-07-21 16:05:21 +00:00
Konstantin Shcheglov
deb5fc8fa7 Don't report DUPLICATE_DEFINITION for augmentations of class / mixin / method.
Change-Id: I7c8e14216df650fbd6876a8087005a3bd3e82595
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/315248
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-07-21 15:59:08 +00:00
Aske Simon Christensen
bac7e9b8c0 [dart2wasm] Emit encoding for final types.
This marks all types without subtypes as final and all types with
subtypes as non-final. This makes the emitted types maximally final
and is appropriate for a closed-world module.

V8 currently ignores the finality of types for the temporary WasmGC
encoding, which make our current encoding work even though it
implicitly marks some types as final that shouldn't be. For the final
WasmGC instruction encoding, V8 is likely to reject modules containing
final types with subtypes.

Change-Id: If3030c49e8fe60fec8099b731b6fcf618d6a7e64
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/310163
Reviewed-by: Ömer Ağacan <omersa@google.com>
Commit-Queue: Ömer Ağacan <omersa@google.com>
2023-07-21 15:52:38 +00:00
Sam Rawlins
892fdd9ab0 Move all comment-parsing code into pkg/analyzer
I did not change the content of the functions, except the following:

* modernized some variable declarations with `var`.
* added periods to the end of comments.
* privatized most methods.

Work towards https://github.com/dart-lang/sdk/issues/50702

Change-Id: I4d63d3ee847316b58fa76c12558767c0825027a9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/315243
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2023-07-21 15:19:38 +00:00
Jake Macdonald
9803ffef27 Add support for macros adding mixins and interfaces to existing types in
the types phase.

Also seales the Code types hierarchy to block users from attempting to
create their own subclasses.

Bug: https://github.com/dart-lang/language/issues/3211
Change-Id: I51ebdfdad6e1fba3c19ef91f25e238730e98e740
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/314821
Auto-Submit: Jake Macdonald <jakemac@google.com>
Reviewed-by: Bob Nystrom <rnystrom@google.com>
Commit-Queue: Jake Macdonald <jakemac@google.com>
2023-07-21 15:18:33 +00:00
Paul Berry
82a196387d Allow .pattern only on const expressions.
Previously, when using the "mini-ast" pseudo-language to write unit
tests for the flow analysis and type analysis logic in the
`_fe_analyzer_shared` package, it was possible to call `.pattern` on
any arbitrary expression, creating a constant pattern containing the
expression. This didn't make sense--only constant expressions can be
used as the basis for constant patterns.

With this change, `.pattern` is only available on the various forms of
constant expressions supported by the "mini-ast" pseudo-language
(currently: integer literals, the `null` literal, and placeholder
expressions created using the `expr` function).

Change-Id: I0d87c66bdb8e636615b20bbb6207c38d78d0d2dd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/315245
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2023-07-21 14:52:26 +00:00
Paul Berry
64ecabdf16 Add function second to flow analysis tests.
In several flow analysis tests we need to model an expression with two
subexpressions, where the type of the overall expression is the same
as the type of the second subexpression.

Previously we did this using `ProtoStatement.thenExpr`, which created
a magic compound expression consisting of an expression (or statement)
followed by a second expression. This was too general, since it
allowed modelling code that would not be possible in Dart.

This CL replaces uses of `ProtoStatement.thenExpr` with a function
`second`, which models a Dart function defined this way:

    T second(dynamic x, T y) => y;

This has two advantages:

- The tests are now modelling code that could actually exist in the
  real world, rather than modelling pseudo-expressions that are not
  actually possible to write in Dart.

- It prepares for a follow-up CL in which I'll be unifying the
  representation of patterns and expressions in the flow analysis
  tests; eliminating `ProtoStatement.thenExpr` will prevent a conflict
  between it and `PossiblyGuardedPattern.thenExpr`.

With this change, two tests had to be deleted, because the conditions
they were testing could no longer be expressed:

- `for_conditionBegin() handles not-yet-seen variables`

- `whileStatement_conditionBegin() handles not-yet-seen variables`

This is ok, because these tests were designed to verify correct
behavior in the circumstance where the client forgets to declare a
variable. This circumstance no longer arises, because the
`_FlowAnalysisImpl` constructor detects undeclared variables and
generates synthetic declarations for them.

Change-Id: I19275ba0b7fa143ce7051bf14d0d4c6f57a4ab8e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/315244
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2023-07-21 14:43:08 +00:00
Johnni Winther
9cbb27ae8a [cfe] Create builders for extension type declarations
Change-Id: I12251865e0657a6241e9e3ce905df83bda24e260
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/313566
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2023-07-21 14:39:41 +00:00
Paul Berry
bcaab7e985 Make more "mini-ast" constructs into expressions.
The following functions, which are used to create constructs in the
"mini-ast" pseudo-language to write unit tests for shared flow
analysis and type analysis logic, now have a return type of
`Expression` rather than `Statement`:

- checkAssigned
- checkUnassigned
- getSsaNodes
- implicitThis_whyNotPromoted an expression

This allows them to be used either where an expression is exprected or
where a statement is expected, which should give us the ability to
write some tests that are not possible (or very difficult) to write
today.

Change-Id: Ie50e82ad05dc88182b59c99c11ffaac41515ebb9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/315460
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2023-07-21 13:24:37 +00:00
Jonas Finnemann Jensen
c77b7a6eda Add diagnostics for platforms key in pubspec.yaml.
**Context:**
The `platforms` field is used to indicate what platforms are supported
by a given package. It's only relevant when publishing to pub.dev, or
similar package repository. If no `platforms` fields is supplied the
platforms will be detected based on `import` statements, also accounting
for conditional imports. See [pubspec reference][1] for details.

These diagnostics aim to help developers discover a misconfigured
`platforms` fields, which they would otherwise only discover when
publishing to [pub.dev][2].

[1]: https://dart.dev/tools/pub/pubspec#platforms
[2]: https://pub.dev

Change-Id: I7b9ea5e371bb1cce6410d32fe6f38c49bc2ff69e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/309661
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Marya Belanger <mbelanger@google.com>
Commit-Queue: Jonas Jensen <jonasfj@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
2023-07-21 12:04:19 +00:00
Johnni Winther
5fae2e484b [parser] Add parser support for extension type syntax
Change-Id: I6bf6c118b4daa2bed438f8f406b9aef6aacf439e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/313501
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2023-07-21 12:01:10 +00:00
Chloe Stefantsova
d3b2b764a1 [cfe] Remove 'value-class' experimental flag
Change-Id: I9bcb9e30732503c9da4e723ded863949f5f0f1b1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/315200
Reviewed-by: Michael Thomsen <mit@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2023-07-21 11:16:24 +00:00
Johnni Winther
46086e908c [cfe] Disallow script tag in part file
In response to https://github.com/dart-lang/sdk/issues/52575

Change-Id: I452575517c378dda3000b8fcbf4f66274b1583a6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/315420
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2023-07-21 11:08:48 +00:00
Ömer Sinan Ağacan
463e251334 [dart2wasm] Optimize some list operations
- Use `array.copy` and `array.fill` when possible.

- Use the Wasm array directly (instead of `[]` and `[]=`) when possible
  to avoid redundant bounds checks.

- `_GrowableList.insert` is rewritten to avoid a redundant write when
  the element is not added to the end.

- Remove redundant bounds checks when calling `Lists.copy`.

Change-Id: I08d96b56201cbb4ff24ca969b7fde8bcc1315e4b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/315120
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Ömer Ağacan <omersa@google.com>
2023-07-21 10:29:46 +00:00
Ömer Sinan Ağacan
b45d62959f [dart2wasm] Update Binaryen
New version supports final encodings used in [1], `array.fill` used in
[2], and updates some other encodings to match V8, as noted in [3].

[1]: https://dart-review.googlesource.com/c/sdk/+/310163
[2]: https://dart-review.googlesource.com/c/sdk/+/315120
[3]: https://dart-review.googlesource.com/c/sdk/+/310560

Change-Id: Ib5627f02327a1301909fd7708856a6f726234293
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/312800
Commit-Queue: Ömer Ağacan <omersa@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2023-07-21 08:42:49 +00:00