Commit graph

91431 commits

Author SHA1 Message Date
Johnni Winther fe01a2068d [cfe] Implement least upper bound for inline types
Closes #51556

Change-Id: I44f2ae947b5316d21d23b39b88f1515702525955
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/294983
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2023-04-24 09:14:07 +00:00
Sergey G. Grekhov 92239e6b27 [co19] Roll co19 to 4b8157719cdcb99ee7380c920551786b6383f961
2023-04-19 sgrekhov22@gmail.com dart-lang/co19#1959. Test valid combinations of modifiers. Part 1 (dart-lang/co19#2023)
2023-04-18 49699333+dependabot[bot]@users.noreply.github.com Bump actions/checkout from 3.5.0 to 3.5.2 (dart-lang/co19#2022)
2023-04-17 sgrekhov22@gmail.com dart-lang/co19#1959. More basic and mixin restrictions tests (dart-lang/co19#2021)
2023-04-17 sgrekhov22@gmail.com dart-lang/co19#1959. Tests for syntax and basic restrictions (dart-lang/co19#2017)

Change-Id: I0d27a6b3504eb13351e72d8dac6281ff0aa52fc7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/296802
Reviewed-by: Alexander Thomas <athom@google.com>
Commit-Queue: Alexander Thomas <athom@google.com>
2023-04-24 07:59:58 +00:00
Chloe Stefantsova 6b0acfecc1 [cfe] Put patterns in the scopes of their declared variables
Closes https://github.com/dart-lang/sdk/issues/51971

Change-Id: I8ba634e7303bafdb1895c50970fbc80321f4bf6a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/296581
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2023-04-24 07:30:00 +00:00
Zach Anderson e34daa818b Revert "[analysis_server] Analyze fix data in fix_data folder"
This reverts commit bbacf39e9c.

Reason for revert: Causing flutter/engine to fail to roll into flutter/flutter. See https://github.com/flutter/flutter/pull/125363.

Original change's description:
> [analysis_server] Analyze fix data in fix_data folder
>
> Fixes part of https://github.com/dart-lang/sdk/issues/52126.
>
> Change-Id: Ib4bd7830a2f644eacedccd375c7c8dc60f040d33
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/296801
> Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
> Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>

Change-Id: I109a4b2c596ad22d73eaf0ac3e25f53a35ba5e28
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/297320
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Zach Anderson <zra@google.com>
2023-04-22 22:10:12 +00:00
Zach Anderson 7575e2c5be Revert "[analysis_server] Use fixDataYamlFolder constant instead of string literals"
This reverts commit ccb02fa8fc.

Reason for revert: Blocking revert in https://dart-review.googlesource.com/c/sdk/+/297320

Original change's description:
> [analysis_server] Use fixDataYamlFolder constant instead of string literals
>
> Follow-up from https://dart-review.googlesource.com/c/sdk/+/296801.
>
> Change-Id: I72ea8a42ec64c4bd6c6cee021a1464167ec368e6
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/296862
> Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
> Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>

Change-Id: I8ed39fc343b9121c40de83038e97c43cac669ca1
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/297321
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Zach Anderson <zra@google.com>
2023-04-22 21:22:47 +00:00
Stephen Adams 45efccb5e0 Remove left-over patch declarations for List constructor.
This CL replaces https://dart-review.googlesource.com/c/sdk/+/296900

The `List` constructor is removed in Dart 3.0.
Some of the `@patch` implementations were not removed.

This is *high priority*. It seems the left-over `@patch factory List` constructor did not cause any errors, instead it *added* a constructor  to `List` that can be used in web compiled code. Even if `List` doesn't have such a constructor in the SDK code proper.
The VM and analyzer will say the invocation is an error, but dart2js happily compiles it and runs.

(It used to be that patches couldn't add public members, that security seems to have been removed.)

Also removes code which tries to detect "the unnamed List constructor",
which is no longer a thing, and a number of invocations of the constructor, where it's not clear that the test is aware that the constructor no longer exists, and is not marked as `@dart=2.x` with x < 12.

TEST=ci

Change-Id: I4ffaf3ae2c4e75ca06e7ba0bf19187b6376f3888
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/297100
Reviewed-by: Brian Quinlan <bquinlan@google.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2023-04-22 00:38:28 +00:00
Brian Quinlan 69f71e90ea Remove 'abstract' from 'class Platform'
Bug: https://github.com/dart-lang/sdk/issues/52138
Change-Id: Ibef54f5369d4b9374e9d58939ee26c853021bf74
CoreLibraryReviewExempt: Partial revert of 9c702bc72e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/297160
Commit-Queue: Brian Quinlan <bquinlan@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2023-04-21 23:44:29 +00:00
pq c1affe94e0 bump linter to grab pattern field false positive fixes
Change-Id: I80d0bcbeaf9b46488d53126deafc21215276036f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/297120
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
2023-04-21 23:09:45 +00:00
Nate Biggs 13849a9dd9 [dart2js] Add Dart input chars to compiler output when reading from dill.
What was being logged as "kernel bytes" or "Dart characters" included the size of the platform dill as well. Changed the text for that to the more general "input bytes". The new source bytes number is the number of bytes registered to Dart2JS by the CFE. This registration is done when the CFE is being run modularly or directly from sources.

When being run modularly the input to phase 0 (CFE-only) is slightly larger (includes extra files) but the input to phase 1 (closed world) ends up matching the non-modular value.

Example output:
Compiled 14,927,936 input bytes (8,010,096 characters source) to 11,647,944 kernel bytes in 0.48 seconds using 114.082 MB of memory

Change-Id: Idaaaf6f9c906659434a9af50882b7ed3343e601a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/297020
Commit-Queue: Nate Biggs <natebiggs@google.com>
Reviewed-by: Mayank Patke <fishythefish@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2023-04-21 22:49:11 +00:00
Ryan Macnak 78daab15b3 [vm] Remove FindObject.
Before the calling convention change during the introduction of AOT, this was used to get code metadata associated with a frame. Its remaining non-test use is forming service IDs for code object, which can  use the regular visitors.

TEST=ci
Change-Id: Ica8eafe988d19eba8d905d9dc5907afbfd559118
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/296705
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2023-04-21 22:41:28 +00:00
Konstantin Shcheglov b5d63cb67f Add quick assist to convert SwitchStatement (with patterns) into if-case chain.
Bug: https://github.com/dart-lang/sdk/issues/52068
Change-Id: Ia20b943dfc5212764f31cd94f4f8cce8755628bc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/297140
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
2023-04-21 22:07:02 +00:00
Konstantin Shcheglov 529adda42e Issue 52131. Find implicit constructor invocations from other constructors.
Bug: https://github.com/dart-lang/sdk/issues/52131
Change-Id: I7f28e4664f18196f978cb9dd38f878b1240d46a1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/297080
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-04-21 22:04:16 +00:00
Ryan Macnak 29472dbb73 [vm, gc] Avoid race between unregistering pages with LSAN and exit.
After the Page is unregistered, the only reference to its VirtualMemory is in memory not traced by LSAN. If exit happens here before the VirtualMemory is deleted or put into the global cache, it appears to be leaked.

TEST=lsan
Bug: https://github.com/dart-lang/sdk/issues/51560
Change-Id: I973e09bb19910d9cdcc3af6c8c9a188f095df36a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/297040
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2023-04-21 19:32:40 +00:00
Konstantin Shcheglov 81ab76124f Support for pattern variables in RemoveUnusedLocalVariable.
Change-Id: I67ed0892a96f911bfae7a4fda91e2e6e55927fc9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/296761
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-04-21 19:18:59 +00:00
Paul Berry 5d7dd58d41 Ignore TODO in pkg/analyzer and pkg/analysis_server.
The analyzer team has decided to adopt the convention of using `TODO`
comments to document long term issues that should persist in the
codebase, and `FIXME` comments to document short term issues that need
immediate attention.  They may even consider adding a presubmit hook
to ensure that `FIXME` comments are only used during local
development.

Accordingly, it makes sense to suppress `TODO` comments from being
surfaced to the IDE "problems" view (since there are hundreds of them,
and they're not immediately actionable).  This makes VSCode's
"problems" view much more usable in "tree" mode.

Change-Id: I11a0c59132fb98c1c86fb4adf22d1fdf3b547c80
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/295662
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2023-04-21 19:16:04 +00:00
Derek Xu e36a587298 [VM/Service] Prepare to publish package:vm_service 11.4.0
Change-Id: I5ffbe166a0c13135c3fe356f46f8d355240585cd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/297000
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Derek Xu <derekx@google.com>
2023-04-21 18:59:37 +00:00
Danny Tuppeny ccb02fa8fc [analysis_server] Use fixDataYamlFolder constant instead of string literals
Follow-up from https://dart-review.googlesource.com/c/sdk/+/296801.

Change-Id: I72ea8a42ec64c4bd6c6cee021a1464167ec368e6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/296862
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2023-04-21 18:50:50 +00:00
Paul Berry 3516c86ae5 Add dependency overrides for pkg/analysis_server
These dependency overrides prevent pub from getting confused about the
fact that our SDK development is in a mono-repo; that in turn will
allow unit tests to be run from inside vscode using the standard test
integration (see https://github.com/Dart-Code/Dart-Code/issues/4502).

Change-Id: I8ea709984b03927e67f119d147338203d7e80811
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/296980
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2023-04-21 18:43:33 +00:00
Martin Kustermann 79d133ab3a [vm] Fix product build by if/defing out reload tests
TEST=Fixes product build of run_vm_tests

Change-Id: I62fae4aba74cca6ebe1b3ce965fc015db3277e02
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/296803
Reviewed-by: Alexander Aprelev <aam@google.com>
2023-04-21 17:38:00 +00:00
Danny Tuppeny ee178b273b [analysis_server] Switch TypeMemberContributor to using InheritanceManager3
Fixes https://github.com/Dart-Code/Dart-Code/issues/4499.

Change-Id: I339f975894f6734c634df5dbc2df9695ecc999a1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/296580
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2023-04-21 17:31:12 +00:00
Danny Tuppeny bbacf39e9c [analysis_server] Analyze fix data in fix_data folder
Fixes part of https://github.com/dart-lang/sdk/issues/52126.

Change-Id: Ib4bd7830a2f644eacedccd375c7c8dc60f040d33
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/296801
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-04-21 15:18:56 +00:00
Alexander Markov d83caf1c0c [vm/compiler] Support obfuscation of record field names
TEST=language/records/simple/* on vm-aot-obfuscate-linux-release-x64

Fixes https://github.com/dart-lang/sdk/issues/52124
Fixes https://github.com/flutter/flutter/issues/125289

Cq-Include-Trybots: luci.dart.try:vm-aot-obfuscate-linux-release-x64-try
Change-Id: Ic53ae5282ba1d30b395fa706840393fd467abf2e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/296920
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2023-04-21 15:14:58 +00:00
Jonas Termansen df63c24638 Checked in SDKs are now automatically uploaded.
The official dart-sdk packages are now automatically built in the CI and
developers will no longer need to build them manually when rolling the
checked in SDK. The cipd instances are now tagged with the commit hash
instead of the version number, which allows us multiple attempts at
building a particular version (which different commits).

Bug: b/279024347
Change-Id: I4bfb4a5384bb8c671b576afdac0e5008ccfcc8a1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/296861
Reviewed-by: William Hesse <whesse@google.com>
Commit-Queue: Jonas Termansen <sortie@google.com>
2023-04-21 13:57:15 +00:00
Martin Kustermann 2ea92acba5 [vm] Make reloading of isolate groups use new safepoint-level mechanism
The current hot-reload implementation [0] will perform a reload by
first sending OOB messages to all isolates and waiting until those OOB
messages are being handled. The handler of the OOB message will block
the thread (and unschedule isolate) and notify the thread performing
reload it's ready.

This requires that all isolates within a group can actually run & block.
This is the case for the VM implementation of isolates (as they are
run an unlimited size thread pool).

Though flutter seems to multiplex several engine isolates on the same OS
thread. Reloading can then result in one engine isolate performing
reload waiting for another to act on the OOB message (which it will not
do as it's multiplexed on the same thread as the former).

Now that we have a more flexible safepointing mechanism (introduced in
[1]) we can utilize for hot reloading by introducing a new "reloading"
safepoint level.

Reload safepoints
-----------------------

We introduce a new safepoint level (SafepointLevel::kGCAndDeoptAndReload).

Being at a "reload safepoint" implies being at a "deopt safepoint"
which implies being at a "gc safepoint".

Code has to explicitly opt-into making safepoint checks participate /
check into "reload safepoints" using [ReloadParticipationScope]. We do
that at certain well-defined places where reload is possible (e.g. event
loop boundaries, descheduling of isolates, OOM message processing, ...).

While running under [NoReloadScope] we disable checking into "reload
safepoints".

Initiator of hot-reload
-----------------------

When a mutator initiates a reload operation (e.g. as part of a
`ReloadSources` `vm-service` API call) it will use a
[ReloadSafepointOperationScope] to get all other mutators to a
safepoint.

For mutators that aren't already at a "reload safepoint", we'll
notify them via an OOB message (instead of scheduling kVMInterrupt).

While waiting for all mutators to check into a "reload safepoint", the
thread is itself at a safepoint (as other mutators may perform lower
level safepoint operations - e.g. GC, Deopt, ...)

Once all mutators are at a "reload safepoint" the thread will take
ownership of all safepoint levels.

Other mutators
-----------------------

Mutators can be at a "reload safepoint" already (e.g. isolate is not
scheduled). If they try to exit safepoint they will block until the
reload operation is finished.

Mutators that are not at a "reload safepoint" (e.g. executing Dart or VM
code) will be sent an OOB message indicating it should check into a
"reload safepoint". We assume mutators make progress until they can
process OOB message.

Mutators may run under a [NoReloadScope] when handling the OOM message.
In that case they will not check into the "reload safepoint" and simply
ignore the message. To ensure the thread will eventually check-in,
we'll make the destructor of [~NoReloadScope] check & send itself a new OOB
message indicating reload should happen. Eventually getting the mutator
to process the OOM message (which is a well-defined place where we can
check into the reload safepoint).

Non-isolate mutators such as the background compiler do not react to OOB
messages. This means that either those mutators have to be stopped (e.g.
bg compiler) before initiating a reload safepoint operation, the
threads have to explicitly opt-into participating in reload safepoints
or the threads have to deschedule themselves eventually.

Misc
----

Owning a reload safepoint operation implies also owning the deopt &
gc safepoint operation. Yet some code would like to ensure it actually
runs under a [DeoptSafepointOperatoinScope]/[GCSafepointOperationScope].
=> The `Thread::OwnsGCSafepoint()` handles that.

While performing hot-reload we may exercise common code (e.g. kernel
loader, ...) that acquires safepoint locks. Normally it's disallows to
acquire safepoint locks while holding a safepoint operation (since
mutators may be stopped at places where they hold locks, creating
deadlock scenarios).
=> We explicitly opt code into participating in reload safepointing
requests. Those well-defined places aren't holding safepoint locks.
=> The `Thread::CanAcquireSafepointLocks()` will return `true` despite
owning a reload operation. (But if one also holds deopt/gc safepoint
operation it will return false)

Example where this matters: As part of hot-reload, we load kernel which
may create new symbols. The symbol creation code may acquire the symbol
lock and `InsertNewOrGet()` a symbol. This is safe as other mutators
don't hold the symbol lock at reload safepoints. The same cannot be said
for Deopt/GC safepoint operations - as they can interrupt code at many
more places where there's no guarantee that no locks are held.

[0] https://dart-review.googlesource.com/c/sdk/+/187461
[1] https://dart-review.googlesource.com/c/sdk/+/196927

Issue https://github.com/flutter/flutter/issues/124546

TEST=Newly added Reload_* tests.

Change-Id: I6842d7d2b284d043cc047fd702b7c5c7dd1fa3c5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/296183
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2023-04-21 13:56:49 +00:00
Martin Kustermann 742612ddac [vm] Add Isolate::{Enter,Exit}AsNonMutator() APIs, use in sweeper
The sweeper threads are bypassing safepoints and have no need for normal
mutator state (e.g. storebuffer, marking stacks, .,..) on the [Thread]
object.

This fixes a TSAN report where sweeper would clear reusable handles
(which it didn't actually modify) and scavenger is reading those
handles (which arguably it doesn't have to either).

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

TEST=ci

Change-Id: I03a36e8518b6c00eb7f3b57f65fd469dddba23e0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/296860
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2023-04-21 11:23:47 +00:00
Martin Kustermann 586d359813 [gardening] Update status files after starting to run tests in obfucated/dwarf nnbd mode
After [0] landed we started running tests in strong mode (instead of
skipping them). This is the corresponding status file update.

[0] https://dart-review.googlesource.com/c/sdk/+/296583

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

TEST=ci

Change-Id: I52e5e9477c47c42a583fb76a8b4205c0ac16bbf3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/296820
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
2023-04-21 10:13:57 +00:00
Sigurd Meldgaard e0177fe017 Bump pub to 21eb39e148c720ab8577bbf3bf089556a113eb10
Changes:
```
> git log --format="%C(auto) %h %s" 3e2c92a..21eb39e
 https://dart.googlesource.com/pub.git/+/21eb39e1 Don't pass --fatal-infos to `dart analyze` in validation (3877)
 https://dart.googlesource.com/pub.git/+/95044c22 Improve message when sdk constraint is not null-safety enabled (3875)
 https://dart.googlesource.com/pub.git/+/b666c920 Fix tests to work in context of 3.1 (3876)
 https://dart.googlesource.com/pub.git/+/c890afa1 Refactor `cache add` check for existing package. (3872)
 https://dart.googlesource.com/pub.git/+/460283b7 Bump actions/checkout from 3.3.0 to 3.5.0 (3858)
 https://dart.googlesource.com/pub.git/+/b5df2113 Bump dart-lang/setup-dart from 1.4.0 to 1.5.0 (3857)

```

Diff: https://dart.googlesource.com/pub.git/+/3e2c92a8bb74935302de52b80b870bf66963756d..21eb39e148c720ab8577bbf3bf089556a113eb10/
Change-Id: If3f6244e79f7b284876795887066412b351a441b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/295820
Reviewed-by: Jonas Jensen <jonasfj@google.com>
Commit-Queue: Sigurd Meldgaard <sigurdm@google.com>
2023-04-21 09:58:38 +00:00
Daco Harkes a045aea9bc [test/ffi] Format record types
Now that https://github.com/dart-lang/dart_style/issues/1128 has been
addressed, format the files testing varargs.

And skips `printf` executable lookup on Android.

Closes: https://github.com/dart-lang/sdk/issues/52112
Change-Id: I31158ad7a5ddd8520bbee5d67e427ee4c1f3da9e
Cq-Include-Trybots: luci.dart.try:vm-ffi-android-debug-arm-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/296800
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2023-04-21 08:23:57 +00:00
Martin Kustermann 2e466f66db [vm] Refactor thread scheduling code to better handle exits with active stack
An embedder (or the VM) can exit an isolate via `Thread::ExitIsolate()`
at a point where there's still active state (e.g. dart frames).

Because of this the VM has so far conservatively retained the [Thread]
object of dart mutators throughout the isolate's lifetime. After which
is was manually `delete`ed. We'd never re-use those [Thread] objects (we
do re-use [Thread] objects of non-dart-mutator threads).

When exiting via `Thread::ExitIsolate()` with active state, the mutator
was assumed to be at-safepoint at all levels. It was removed from the
thread registry's active threads. This also means that when e.g. GC runs
it can't use the thread registry to find all active threads it may
need to scan, instead it uses [Isolate::mutator_thread_] of all isolates.

This causes a variety of subtle issues, but the main one that motivated
this change is the following:

If a thread obtains a safepoint operation it means all other mutators
are parked. The thread owning the safepoint can do whatever it likes.
When introducing reload operation safepoints, a thread may want to

    ReloadSafepointOperation reload(thread);
    ...

    // Compile sources.
    {
      TransitionVMToNative transition(thread);

      // Will temporarily exit & re-enter current isolate.
      response_port = Dart_NewNativePort();

      Dart_PostCObject(kernel_isolate_port, ...);

      // Wait on [response_port] for response.
    }

This will cause the reloading thread to own the reload safepoint
operation but still transition states and even exit/re-enter the
isolate. Though this is currently not possible in the way enter/exit is
implemented.

So we'll refactor this fragile code in the following way:

* Move thread enter/exit logic entirely to the [Thread] object.

* Keep used threads in the thread registry's active list.

  => This allows us to keep various state on the [Thread] and thereby
  avoids clearing it when suspending & re-initialing it when resuming

  => It makes nested `Thread::ExitIsolate()` faster as we mainly have
  to enter safepoint (avoid acquiring threads lock, avoid releasing
  storebuffers, ...)

  => It makes nested `Thread::EnterIsolate()` faster as we mainly have
  to leave the safepoint (avoid acquiring threads lock, avoid acquiring
  storebuffers, ...).

  => A mutator can now own a safepoint operation (e.g. reload safepoint
  operation) and still `ExitSafepoint()` / `EnterSafepoint()` safely -
  as those are based on the normal `EnterSafepoint()` and
  `LeaveSafepoint()` APIs.

* We separate

   - Suspend & Resume of a dart mutator (possibly with active stack)
   - Setup & Reset of state only relevant for dart mutators
   - Setup & Reset of state relevant for any mutator

* We unify how the [Thread] objects are freed between dart mutator and
  non-dart mutators: [Thread] objects without state can be given back to
  the [ThreadRegistry] and re-used (instead of being deleted in
  `Isolate::~Isolate`)

* We have capability to free [Thread] objects if a dart mutator has an
  empty stack & re-use for another isolate of the same group.
  (In future we may have N Thread objects for N cores and the threads
   would even maintain their TLABs when switching between isolates)

* Since we allow reusing of [Thread] objects also for dart mutators now,
  we have extensive asserts to ensure they are "clean" when they get
  into the free list and come out "clean" again.

TEST=ci

Change-Id: Id85e8e484efd98d28e323b33795716420e619986
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/296585
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2023-04-21 08:06:49 +00:00
Robert Nystrom b985fc961a Make the static error updater gracefully skip multitests.
Multitests aren't valid Dart files that can be processed by a Dart
implementation so the updater generally does a poor job if it tries to
update one.

It's probably not worth supporting because, in practice, a test should
either be a multitest or a static error test, but not both.

Change the tool to skip over any multitests it encounters. If this
results in it doing nothing at all, it reports that as an error.
Otherwise, it just lists the multitests it didn't process.

Close #37721.

Change-Id: Icfb1ff9fe63f2c249b3ccfba65166b97654a9918
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/296760
Commit-Queue: Leaf Petersen <leafp@google.com>
Reviewed-by: Leaf Petersen <leafp@google.com>
Auto-Submit: Bob Nystrom <rnystrom@google.com>
2023-04-21 04:17:27 +00:00
Stephen Adams 2a66f966f3 [dart2js] Rename dart:_async_await_error_codes -> dart:_async_status_codes
Change-Id: I6b47f08791544eabc09bb05a81bbd0154bc39cb2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/296704
Commit-Queue: Stephen Adams <sra@google.com>
Reviewed-by: Mayank Patke <fishythefish@google.com>
2023-04-21 00:01:51 +00:00
Jake Macdonald 922f611d7f Use a BytesBuilder to group length and message, enable tcpNoDelay.
This makes the socket benchmark (and real world code also), about 100x faster.

Change-Id: Iaa130b7bf69e4c89d3c3a221680e5b62ffe10583
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/296641
Auto-Submit: Jake Macdonald <jakemac@google.com>
Commit-Queue: Jake Macdonald <jakemac@google.com>
Reviewed-by: Bob Nystrom <rnystrom@google.com>
2023-04-20 23:35:51 +00:00
Paul Berry 600fccb9bb Rework exhaustiveness witness generation to allow analyzer to capture import info.
In order for an analyzer quick fix to aid the user in correcting
exhaustiveness errors, it needs to know not just the text of the
witness pattern that needs to be inserted, but also which elements are
referenced by the identifiers in that pattern.  This will allow it to
add in imports if the user's code doesn't yet import the necessary
library, or insert import prefixes in the case where the user is
already importing the necessary library in a prefixed fashion.

To reduce the effect on the exhaustiveness logic (which was designed
with the intention of building up the witness pattern into a
StringBuffer), we introduce a new type, `DartTemplateBuffer`, which
behaves similarly to StringBuffer but also captures the necessary
semantic information so that the analyzer will be able to fix up
imports in an appropriate way.

This change is mostly isolated to the _fe_analyzer_shared package; it
doesn't add the necessary logic to the analyzer to capture the
elements; it simply plumbs them up to the API boundary between the
packages.  Future CLs will add the necessary analyzer logic to make
use of the information.

Change-Id: I7c030fc49a2510acbefd6aeb567e0e7b7102855a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/296385
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
2023-04-20 23:30:21 +00:00
Ryan Macnak df9c6eb48f [vm] Cleanup some duplication during Dart entry.
TEST=ci
Change-Id: I10640eba020ddfb942b4c76be950fa84f4f2170f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/296386
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2023-04-20 23:09:47 +00:00
Ryan Macnak 0b70e1c7e2 [vm] Fix gcc build.
TEST=ci
Change-Id: Iad1b682d4eed8aacad4079ab1ce12fb8553baf3f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/296721
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2023-04-20 22:41:50 +00:00
Robert Nystrom 3bc7d9562f Migrate "u" and "v" directory language tests off @compile-error.
The "@compile-error" comment is an old not-great way of defining static
error tests.

See: https://github.com/dart-lang/sdk/issues/45634
Change-Id: I3a41bb83767052abda1fdfc77e21bd1a83188482
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/296441
Auto-Submit: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Jake Macdonald <jakemac@google.com>
Commit-Queue: Bob Nystrom <rnystrom@google.com>
2023-04-20 22:33:22 +00:00
pq ef372f2621 bump linter for prefer_final_locals fix
Includes fix for https://github.com/dart-lang/linter/issues/4286

Change-Id: I2124d26cbd3a4105073559d75830b5718684be59
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/296702
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
2023-04-20 21:58:57 +00:00
Robert Nystrom 9bb4402abd Migrate "a" directory language tests off @compile-error.
The "@compile-error" comment is an old not-great way of defining static
error tests.

See: https://github.com/dart-lang/sdk/issues/45634
Change-Id: I35d4a7c7ad09cb77ff379af036180794d8b6afbf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/296403
Auto-Submit: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Jake Macdonald <jakemac@google.com>
Commit-Queue: Bob Nystrom <rnystrom@google.com>
2023-04-20 20:50:39 +00:00
Robert Nystrom 9789e9d7a0 Migrate "e" and "f" directory language tests off @compile-error.
The "@compile-error" comment is an old not-great way of defining static
error tests.

See: https://github.com/dart-lang/sdk/issues/45634
Change-Id: Idf9012cb8c213b523d1c8bb827e530e0d2cf6609
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/296407
Auto-Submit: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Jake Macdonald <jakemac@google.com>
Commit-Queue: Bob Nystrom <rnystrom@google.com>
2023-04-20 20:49:17 +00:00
Ryan Macnak 829958d387 [vm, gc] Track largeness and VM isolate membership in page headers.
The latter will factor into a page's alignment offset.

TEST=ci
Change-Id: Iee5117efb3278399e0fd09b21ea92eadc8237296
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/263680
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2023-04-20 20:27:10 +00:00
Sigmund Cherem eda54b0e93 [dart2js] update documentation on source-map extensions to mention VLQ encoding.
Change-Id: Ic564a992310591ee25a9aba1e1dc391160c47df2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/296680
Reviewed-by: Stephen Adams <sra@google.com>
Commit-Queue: Sigmund Cherem <sigmund@google.com>
2023-04-20 20:02:33 +00:00
Robert Nystrom 51fe275a62 Migrate "t" directory language tests off @compile-error.
The "@compile-error" comment is an old not-great way of defining static
error tests.

See: https://github.com/dart-lang/sdk/issues/45634
Change-Id: I4c2840deffe5d790a22facebbcc8a02c1cb98020
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/296425
Auto-Submit: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
Commit-Queue: Bob Nystrom <rnystrom@google.com>
2023-04-20 19:55:31 +00:00
Kallen Tu 199feac353 [analyzer/cfe] Update abstract sealed error message.
State more explicitly that sealed classes are abstract and lead the
user to a better fix with the error message.

Bug: https://github.com/dart-lang/sdk/issues/52073
Change-Id: Id24c6cb187ee5497ca2819f930c48ff5aa8d07fc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/296025
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
2023-04-20 19:54:30 +00:00
Konstantin Shcheglov 9070c7baf1 Don't suggest UseCurlyBraces for else-if
Change-Id: I2e29565fe67fbe8e412306ef0b8fd3c3188a970b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/296661
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-04-20 19:37:37 +00:00
Robert Nystrom 0eb13c95ac Migrate corelib and lib tests off @compile-error.
The "@compile-error" comment is an old not-great way of defining static
error tests.

See: https://github.com/dart-lang/sdk/issues/45634
Change-Id: I42d3712f2f75f66e7ecae19f740de16f6025b41d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/296120
Commit-Queue: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Leaf Petersen <leafp@google.com>
2023-04-20 19:19:01 +00:00
Ryan Macnak 4d8fa9729e [infra] Remove configurations for legacy obfuscate and stripped modes.
Change-Id: I7192ba0fe31f2059c722559c4acaec4bdf0b01f3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/296022
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Thomas <athom@google.com>
2023-04-20 19:11:06 +00:00
Robert Nystrom d244eeb84c Migrate "c" directory language tests off @compile-error.
The "@compile-error" comment is an old not-great way of defining static
error tests.

See: https://github.com/dart-lang/sdk/issues/45634
Change-Id: I3e10209e78e48893d2f2df7f8af7963d319efd9f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/296405
Reviewed-by: Jake Macdonald <jakemac@google.com>
Commit-Queue: Bob Nystrom <rnystrom@google.com>
Auto-Submit: Bob Nystrom <rnystrom@google.com>
2023-04-20 19:10:58 +00:00
Ben Konyi aef551ac35 Reland "[ Observatory ] Disable serving Observatory by default"
This reverts commit fa0c81efe1.

Requires https://github.com/flutter/flutter/pull/123556/ to have landed.

TEST=Existing tests

Change-Id: I40b9e11a89fd66ec511d31a385192e577899fca3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/296640
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2023-04-20 18:16:09 +00:00
asiva ac92f41e7a [VM/Timeline] Fix comment.
TEST=Only comment changed.

Change-Id: Ic4316f7f53120b5d56c20965c690fd97df2f7ba8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/296660
Commit-Queue: Siva Annamalai <asiva@google.com>
Reviewed-by: Derek Xu <derekx@google.com>
2023-04-20 18:14:22 +00:00
Robert Nystrom 1b422af61f Migrate "s" directory language tests off @compile-error.
The "@compile-error" comment is an old not-great way of defining static
error tests.

See: https://github.com/dart-lang/sdk/issues/45634
Change-Id: I6218c6ea339b6c19c1495b1db9b2da3fe1654718
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/296440
Commit-Queue: Jake Macdonald <jakemac@google.com>
Auto-Submit: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Jake Macdonald <jakemac@google.com>
2023-04-20 17:59:44 +00:00