Commit graph

92484 commits

Author SHA1 Message Date
Vyacheslav Egorov a52f2b9617 [vm] Rework awaiter stack unwinding.
The main contribution of this CL is unification of disparate
handling of various functions like `Future.timeout`,
`Future.wait`, `_SuspendState.createAsyncCallbacks` and
`_SuspendState._createAsyncStarCallback` into a single
`@pragma('vm:awaiter-link')` which allows Dart developers
to specify where awaiter unwinder should look for the next
awaiter.

For example this allows unwinding to succeed for the code like this:

    Future<int> outer(Future<int> inner) {
      @pragma('vm:awaiter-link')
      final completer = Completer<int>();

      inner.then((v) => completer.complete(v));

      return completer.future;
   }

This refactoring also ensures that we preserve information
(including Function & Code objects) required for awaiter
unwinding across all modes (JIT, AOT and AOT with DWARF stack
traces). This guarantees users will get the same information
no matter which mode they are running in. Previously
we have been disabling awaiter_stacks tests in some AOT
modes - which led to regressions in the quality of produced
stacks.

This CL also cleans up relationship between debugger and awaiter
stack returned by StackTrace.current - which makes stack trace
displayed by debugger (used for stepping out and determinining
whether exception is caught or not) and `StackTrace.current`
consistent.

Finally we make one user visible change to the stack trace:
awaiter stack will no always include intermediate listeners
created through `Future.then`. Previously we would sometimes
include these listeners at the tail of the stack trace,
which was inconsistent.

Ultimately this means that code like this:

    Future<int> inner() async {
      await null;  // asynchronous gap
      print(StackTrace.current); // (*)
      return 0;
    }

    Future<int> outer() async {
      int process(int v) {
        return v + 1;
      }

      return await inner().then(process);
    }

    void main() async {
      await outer();
    }

Produces stack trace like this:

    inner
    <asynchronous suspension>
    outer.process
    <asynchronous suspension>
    outer
    <asynchronous suspension>
    main
    <asynchronous suspension>

And when stepping out of `inner` execution will stop at `outer.process`
first and the next step out will bring execution to `outer` next.

Fixes https://github.com/dart-lang/sdk/issues/52797
Fixes https://github.com/dart-lang/sdk/issues/52203
Issue https://github.com/dart-lang/sdk/issues/47985

TEST=ci

Bug: b/279929839
CoreLibraryReviewExempt: CL just adds @pragma to facilitate unwinding
Cq-Include-Trybots: luci.dart.try:vm-aot-linux-product-x64-try,vm-aot-linux-debug-x64-try,vm-aot-linux-release-x64-try,vm-aot-obfuscate-linux-release-x64-try,vm-aot-dwarf-linux-product-x64-try
Change-Id: If377d5329d6a11c86effb9369dc603a7ae616fe7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311680
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2023-06-30 14:03:03 +00:00
Konstantin Shcheglov 8828fee865 Deprecate ExecutableElement.returnType, use returnType2 instead.
Change-Id: Ibd29c3fbec0439236c2cf45c57f820c45427df9f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311932
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-06-29 23:16:59 +00:00
Jake Macdonald 34f25c4a28 Add library introspection apis for macros.
Allows you to ask for the types in a library in the declarations phase, and all
the top level declarations in the definitions phase.

Bug: https://github.com/dart-lang/language/issues/2839
Change-Id: If0f8fb777fd8a006d686d457cf5d5ca11fcca9ee
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311900
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Jake Macdonald <jakemac@google.com>
Reviewed-by: Bob Nystrom <rnystrom@google.com>
2023-06-29 22:05:58 +00:00
Kallen Tu 74adf1626e [analyzer] Refactor visitNamedType and other visitors in const evaluator.
Change-Id: Ia3c22fc87c96d719cfa3617c72f5586badfec183
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/310972
Commit-Queue: Kallen Tu <kallentu@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2023-06-29 21:26:14 +00:00
Konstantin Shcheglov fae9e418ea Deprecate Element.enclosingElement, use enclosingElement2 instead.
Change-Id: I78edb6d433949eb8bd86f397fb873a078edf9fc4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311827
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-06-29 19:45:19 +00:00
Ryan Macnak 8f21c8ed2a [gardening] Don't attempt to measure RSS under sanitizers or with reload.
Bug: https://github.com/dart-lang/sdk/issues/52816
Change-Id: I4e50180a9285727cc2e275dd17dd6855f21a0b6e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311926
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2023-06-29 19:39:05 +00:00
Danny Tuppeny fc1188d55c [analysis_server] Refactor/rename server to simplify sharing handlers between LSP+Legacy protocols
In order to share LSP handlers between protocols, we need to be able to use a LegacyAnalysisServer in place of an LspAnalysisServer which means having a common interface (which they have via AnalysisServer) and to make the mapping of LSP method names to handlers reusable.

This changes makes the following non-functional changes (to reduce the size of a future change that will begin sharing handlers):

- Rename "clientCapabilities" to "lspClientCapabilities" to avoid conflicts with legacy servers clientCapabilities field when we add this to the base AnalysisServer interface
- Rename "clientConfiguration" to "lspClientConfiguration" for consistency
- Add an "LspMessageHandler" typedef over "MessageHandler" which now has a server type arg so that it can be used with either LspAnalysisServer (by handlers that really need LSP) and AnalysisServer (for handlers that can work in either server)
- Extract handler generators in `InitializedStateMessageHandler` to a static map and make constructors consistent taking only a server (in a future CL the legacy server will want access to some this mapping)

Change-Id: I23554a7ca318fbcd1113dcebff5601186b223618
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311982
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-06-29 19:20:20 +00:00
Ryan Macnak a4f59b8c20 [gardening] Update PatchClass::patched_class_ to wrapped_class_ in pkg/vm_snapshot_analsysis.
Cf. 99db606bab

Change-Id: I653ab3d8d4bb0ccee0bfeed7e8ab5d2c219b6924
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311928
Reviewed-by: Alexander Aprelev <aam@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2023-06-29 18:34:37 +00:00
Devon Carew e6b7459abc [deps] rev dartdoc, ecosystem, http, lints, markdown, mockito, protobuf, test
Revisions updated by `dart tools/rev_sdk_deps.dart`.

dartdoc (e04a6b3..c2ed703):
  c2ed703c  2023-06-26  dependabot[bot]  Bump ossf/scorecard-action from 2.1.3 to 2.2.0 (#3454)

ecosystem (b1056e6..19fa443):
  19fa443  2023-06-29  Lasse R.H. Nielsen  Clean-up and tweaks of the firehose project. (#117)
  9ef5948  2023-06-27  Moritz  Excise health from firehose (#118)
  36c662e  2023-06-27  Moritz  Introduce a health checking workflow (#115)

http (ff1fcfe..d68081f):
  d68081f  2023-06-26  Nate Bosch  Prepare to publish package:http (#973)
  067bff3  2023-06-26  Alex James  Create java http package (#971)

lints (79581ff..89f9519):
  89f9519  2023-06-28  Parker Lougheed  Fix typo in 3.0.0-wip changelog entry (#137)

markdown (bd6ae8d..4674d09):
  4674d09  2023-06-27  Zhiguang Chen  Fix HtmlBlockSyntax (#548)

mockito (1d6064a..974226e):
  974226e  2023-06-27  Googler  Internal change

protobuf (e76bd74..7bebbc6):
  7bebbc6  2023-06-29  Ömer Sinan Ağacan  Update protoc_plugin Makefile: (#858)
  acc0462  2023-06-29  Ömer Sinan Ağacan  Ignore non-items in message sets (#857)
  0eb3796  2023-06-29  Ömer Sinan Ağacan  Ignore unknown tags in message set items (#856)
  2996e1d  2023-06-27  Ömer Sinan Ağacan  Implement message set wire format (#836)

test (cdc8178..021667a):
  021667a4  2023-06-28  Jacob MacDonald  prep to release (#2048)
  3d44fcae  2023-06-28  Yaroslav Vorobev  feat(test): add MOZ_AUTOMATION=1 to ff test runner (#2049)
  6e675f80  2023-06-28  Parker Lougheed  Replace broken link to observatory with DevTools mention (#2047)
  2904779b  2023-06-28  Yaroslav Vorobev  feat(runner): add env overrides for safari and ff (#2042)
  54350282  2023-06-28  Parker Lougheed  Update link from old linter site to dart.dev (#2046)
  8c4b15d1  2023-06-28  Jacob MacDonald  allow the latest analyzer (6.x.x) (#2045)

Change-Id: I86901fb2211adf81288f0940a355d6c33ddd8a7d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311927
Auto-Submit: Devon Carew <devoncarew@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-06-29 18:20:19 +00:00
Nate Bosch a4331b433a Fix dependency on package:meta
A usage of `@mustBeOverridden` was added in
https://dart-review.googlesource.com/c/sdk/+/309460. The API was added
in version `1.9.0` of `package:meta`.

R=jakemac@google.com

Bug: https://github.com/dart-lang/sdk/issues/52815
Change-Id: I6069b20d2ea6cfae6af4cb0af033ad9a07f48d0b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311925
Reviewed-by: Jake Macdonald <jakemac@google.com>
Commit-Queue: Nate Bosch <nbosch@google.com>
2023-06-29 17:35:51 +00:00
Martin Kustermann 45038a2e71 [vm] Avoid repeatedly re-setting stack limits on each dart invocation
Currently every invocation of a dart function will set and later on
reset the stack limits. Doing so requires acquiring locks.

Similarly because we have async ffi callbacks (another way to invoke
dart code) the logic was duplicated there.

Though the stack limit never changes for a given [OSThread]. Isolates
can run on different [OSThread]s throughtout its lifetime. But an
isolate always has to be entered on a native thread before it can
execute dart code.

=> We initialize the stack limit when we scheduling an isolate on a
thread and re-set it when unscheduling it.

=> That centralizes the place to one where we have to deal with stack
limits and avoids repeated acquiring of locks on each embedder dart
function invocation.

TEST=ci

Change-Id: Ia59ba8f92b93c58a990010ec75dfcd879aea2c43
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311960
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2023-06-29 17:29:48 +00:00
Ryan Macnak ac77af1c07 Group the GC tests into a common directory.
The makes it possible to run just these tests with `test.py vm/gc/`.

Change-Id: Ied4aa0b2fb045c19b1aced68f58a1ef195a5df8a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311145
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2023-06-29 17:27:48 +00:00
Ryan Macnak 41bb44e93e [vm, gc] Update the write barrier stub to allow for both the generational and incremental barriers triggering.
Currently the generational and incremental barriers cannot both apply for the same store because the former only applies for old->new stores and the latter only applies for old->old stores. Marking through new-space will cause the incremental barrier to apply to all stores.

TEST=ci
Change-Id: I40d492cc8b5b2fff8d5d4bc8625d45f2e6a2d488
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/309830
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2023-06-29 16:26:48 +00:00
Danny Tuppeny 70be63ce49 Fix CreateConstructorForFinalFieldsRequiredNamedTest.test_enum on Windows
Checking the offset can be wrong on Windows due to line endings. Other tests in this file are checking the message, so I've done the same here.

I noticed this locally, but I see the Windows bot was also failing on this.

Change-Id: I36de86c3b3eac6f379da894ea9e6fcfcb1a0aa4a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311981
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2023-06-29 15:39:08 +00:00
Martin Kustermann 99db606bab [vm] Cleanup [PatchClass] in the VM
The [PatchClass] no longer needs to refer to a original [Class] and a
patched [Class] objects: Since the CFE does handling of patches the VM
only has a single [Class] object, so those two fields are always the
same.

=> Change `PatchClass::{origin_class,patched_class} -> `PatchClass::wrapped_class`

We also remove the `Field::Origin()` / `Function::origin()` methods
as they return the same as the `Owner()` would return.

TEST=ci

Change-Id: Iec0849f6ffc2026760dad89a9bcf07e9469bc8b6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311840
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2023-06-29 15:03:37 +00:00
Martin Kustermann 63b567add2 [vm] Split isolate initialization logic into two pieces
This splits `Dart::InitializeIsolate()` into

* `Dart::InitializeIsolateGroup()` that sets up an `IsolateGroup`
  => This is only done at isolate group creation time when the very
     first isolate is created.

* `Dart::InitializeIsolate()` that sets up an `Isolate`.
  => This is done for every isolate.

This is purely refactoring / code cleanup.

TEST=ci

Change-Id: Ica906444f79fe49849b9e11e96f7c89184cb9d09
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311603
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2023-06-29 08:04:20 +00:00
Srujan Gaddam bd3e6fa1a3 Revert "[dart:html] Throw exception if Window.open opens null window"
This reverts commit a356f71b71.

Reason for revert: This should be handled by throwing an exception when
the methods of the returned window are called, not when it is opened.
This would be a noisy breaking change that we don't want for 3.1. For
now, revert until the change that affects the individual methods is
landed.

Original change's description:
> [dart:html] Throw exception if Window.open opens null window
>
> Window.open silently allows a null window to be opened, and
> issues arise later when users try to use the non-null wrapper.
> This CL changes that to throw an exception if the window is null.
> This exception can be caught and recovered from. This avoids the
> larger breaking change of making this API nullable.
>
> CoreLibraryReviewExempt: Backend-specific library.
> Change-Id: I9a53a477cb370c3bc6bc26b2162ce66c5af166aa
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/306910
> Reviewed-by: Sigmund Cherem <sigmund@google.com>
> Commit-Queue: Srujan Gaddam <srujzs@google.com>

CoreLibraryReviewExempt: Revert in backend-specific library.
Change-Id: I5007b7d7aa608bfc8e5827b5f967af5573d0b758
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/309000
Commit-Queue: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2023-06-28 23:21:32 +00:00
Ivan Inozemtsev 2b250992f9 Revert "[dart:html] Move NullWindowException to implementation"
This reverts commit 14a3051552.

Reason for revert: b/289195983

Original change's description:
> [dart:html] Move NullWindowException to implementation
>
> Window.open may open a null window in more cases than expected.
> Users may not care that the window they get back is invalid if
> they never use it. Therefore, this CL moves the exception to
> the implementation of the returned window in order to reduce
> noise, but still give a way for users to recover if they wish
> to do so.
>
> CoreLibraryReviewExempt: Backend-specific library.
> Change-Id: I005cf80630cfb4db2f5ec2012cfcd0161ad10ff1
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311460
> Commit-Queue: Srujan Gaddam <srujzs@google.com>
> Reviewed-by: Sigmund Cherem <sigmund@google.com>

Change-Id: Id7c514a80fdcaa18a7eb0acdcb7f36477a04d966
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311843
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Auto-Submit: Ivan Inozemtsev <iinozemtsev@google.com>
2023-06-28 23:21:32 +00:00
Konstantin Shcheglov 8a037770f9 Tweaks for element model documentation comments.
As requested in https://dart-review.googlesource.com/c/sdk/+/311725

Change-Id: I76cd2322f9cca9845f3ec767adfd1e5dca9d7c47
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311826
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-06-28 20:28:30 +00:00
Konstantin Shcheglov 6f01da06a2 Put aside invalid mixin constructors, quick fix for MIXIN_DECLARES_CONSTRUCTOR.
Change-Id: If1b808bf7746b4f2c2c856d7fb7e72499023759f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311823
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-06-28 19:49:08 +00:00
Keerti Parthasarathy aec08eabd9 Convert some more assists/fixes to using ParsedCorrectionProducer
Change-Id: Ie715868183e1b06023b538ec1bc550171cfa2f5f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311825
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
2023-06-28 19:46:47 +00:00
Konstantin Shcheglov 1fd7e2b670 Update a few documentation comments to the style guide.
Change-Id: If019e456de041081ed688cfce4c7f5063055ba39
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311821
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-06-28 17:44:08 +00:00
Dan Chevalier 2423ba80e3 Bump DevTools DEP to 2.25.0
Change-Id: I92aedf55aba06536b0a3b70cfe1a4ceb344bbbc0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311860
Commit-Queue: Dan Chevalier <danchevalier@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2023-06-28 16:54:51 +00:00
Ryan Macnak 8853472dd6 [vm, gc] Pause concurrent marking during scavenge.
TEST=ci
Change-Id: I7c3deaf4383b993c4c0253a4f94a1d503b2d9a92
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/309802
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2023-06-28 16:49:07 +00:00
Konstantin Shcheglov 892a7fbe4e Put aside invalid nodes during parsing, fix for EXTENSION_DECLARES_CONSTRUCTOR.
Change-Id: Ic01f4c1116ecb29087c8d1bff679906522b7562e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311726
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2023-06-28 15:17:23 +00:00
Konstantin Shcheglov a49dbe539f Extract NamedInstanceElement from InstanceElement, use for ExtensionElement.
Change-Id: Iee49f110afacc3f5c54fb15e70b3f18ac18c67a3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311725
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-06-28 15:16:18 +00:00
Slava Egorov 8b6e39696f [vm/io] Avoid leaking Handle::data_ready_ on Windows.
Handle::data_ready_ contains bytes which are ready to be sent to Dart
side. Not all code paths fully drain this buffer and delete it
before destroying the handle, for example directory watch implementation
was prone to leaking data_ready_ when subscription was cancelled.

This CL switches the code to use unique_ptr to hold on to data_ready_
which makes sure that it is deleted when Handle is destroyed.

The code would benefit from holding all OverlappedBuffer instances
through unique_ptr but that is a much larger refactoring which
we leave for a later date.

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

TEST=standalone{,_2}/regress_52715_test

Bug: 52715
Cq-Include-Trybots: luci.dart.try:vm-win-release-x64-try,vm-win-debug-x64-try,vm-aot-win-release-x64-try,analyzer-win-release-try
Change-Id: Ie8d728b823de7e8f9de1489898e270580c2af269
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311841
Commit-Queue: Slava Egorov <vegorov@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Auto-Submit: Slava Egorov <vegorov@google.com>
2023-06-28 13:06:51 +00:00
Vyacheslav Egorov 86c311607a [vm] Fix HeapProfileSampler::SampleOldSpaceAllocation
When Isolate is just starting up and no TLABs are yet present
we were setting interval_to_next_sample_ to -1 which caused
every old space allocation to be sampled.

This CL properly initializes the interval to sampling_interval_
instead.

TEST=vm/cc/DartAPI_HeapSampling_CorrectSamplingIntervalForOldSpaceAllocations

Change-Id: Ieb29234379d3afa4716ebdf3591f9fc0cbcaef71
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311844
Commit-Queue: Slava Egorov <vegorov@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
Auto-Submit: Slava Egorov <vegorov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2023-06-28 12:58:32 +00:00
Martin Kustermann 8f7cf7724c [gardening] Ensure functions use stable hashes across reload
Root cause is that `Function::Hash()` depends on the owner class
id. This causes two issues

a) Issue with reload:

During reload the reloader code will change `Function::owner()`
from a `Class` to a `PatchClass`. This in return will cause a change in
the function's hash, which means we won't find the function in the
closure cache anymore.

b) Issue with app-jit:

As part of app-jit we re-number class ids. This re-numbering would also
render the closure cache as invalid - as the function hash code would
change. So instead the closure cache was cleared entirely. While this
works for AOT, in app-jit we may serialize closure functions and their
code. Though at app-jit runtime we then fail to find the functions in
the closure function cache (as it was cleared during snapshoting)

(This will surface by us triggering an optimizing compile of a function
in the background compiler which will try to make a new `Function`
object for a closure, even though the app-jit snapshot already has one)

To fix these issues we make the `Function::Hash()` stable across reload

  * we use `Function::Owner()` instead of `Function::owner()` (the
    former will always return the actual class, the ladder can return
    the `PatchClass`)

  * we avoid re-hashing the closure cache by making `Function::Hash()`
    use the name of the class instead of the class id

  * we clear out the closure cache array during AOT snapshoting, as this
    is not used in AOT runtime.

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

TEST=Fixes various issues on CI.

Change-Id: I352d0a768df0f29d504cdd80e3533cbedc437b9b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311744
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2023-06-28 11:48:26 +00:00
Liam Appelbe c3a532bc36 [vm] Deflake async callbacks test
Change-Id: Ia12ac5380f90760a23297b449d24e324f6156daa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311800
Auto-Submit: Liam Appelbe <liama@google.com>
Commit-Queue: Liam Appelbe <liama@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2023-06-28 10:26:21 +00:00
Chloe Stefantsova 53c9cf1c46 [cfe] Remove spurious assignment error on late final loop variables
Closes https://github.com/dart-lang/sdk/issues/52704

Change-Id: I2bf7363be6def613fdd9389d5e080514a3f2e455
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311120
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2023-06-28 10:13:28 +00:00
Martin Kustermann 29509e0124 [gardening] Fix riscv32/riscv64 build
The constants in [0] were not quite correct for riscv.

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

TEST=ci

Change-Id: I194cde2541293935ef89861f3d1607c1913068f9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311743
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Liam Appelbe <liama@google.com>
2023-06-28 09:21:11 +00:00
Daco Harkes bd1bad7afc [deps/ffi] Unbundle package:native_assets_builder
The Dart SDK CL for https://github.com/dart-lang/native/pull/69.

Bug: https://github.com/dart-lang/native/issues/67
Change-Id: I45d7ac691a6aaa41bce5be0e36403021a948bb4f
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/+/311740
Reviewed-by: William Hesse <whesse@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Devon Carew <devoncarew@google.com>
2023-06-28 09:09:09 +00:00
Johnni Winther 0c8ded72dc [cfe] Add FileUriConstantExpression
This adds FileUriConstantExpression, a subclass of ConstantExpression, to support correct file offset of annotations for augmentations and patches.
The FileUriExpression is used to carry the file uri of the expression
before constant evaluation.

TEST=general/patch_annotations

Change-Id: I0dc8a0cb97dd530fd1960785d38c2d5e4883c3dd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311660
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2023-06-28 07:52:09 +00:00
Johnni Winther cfd4200c85 [cfe] Handle late lowered fields in addUnpromotablePrivateFieldNames
Closes #52452

Change-Id: I39b3045b5e8b95493ea954ffa678b9caede901c8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311741
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2023-06-28 07:34:38 +00:00
Sam Rawlins bc14588ad1 Bump linter to 770c3c5858a112cdb9e8d65e11ba659322700c68
Change-Id: I4efce2fa815f6844f70aa49b491c2a2c97a26195
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311720
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2023-06-28 04:56:18 +00:00
Liam Appelbe 13ec07415b [vm] Async FFI callbacks
More details about the design:
https://docs.google.com/document/d/1QDjyY_6wOTOgURwpeYMKU9qEz0gKxx2MUrdruC6Kp6c/edit?usp=sharing

Change-Id: Ie3985d86dca7f5010044ca46c33ca177588c0f69
Bug: #37022
CoreLibraryReviewExempt: Reviewed by vm and api groups. web and wasm groups not affected because FFI isn't on those platforms.
TEST=async_void_function_callbacks_test.dart, ffi_callback_metadata_test.cc, other front end tests
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/305900
Commit-Queue: Liam Appelbe <liama@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2023-06-28 01:00:18 +00:00
Konstantin Shcheglov d264ceeb05 Add InstanceElement as a super-interface for InterfaceElement and InlineClassElement.
Change-Id: Ie92168509cccb5b145bc5c9adea2945813725038
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311721
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-06-28 00:56:05 +00:00
Alexander Markov 12c7455436 [vm] Reset closure functions cache when sorting class ids
Hashes of functions depend on the class ids, so cache of the closure
functions should be cleared when class ids are sorted.
This is safe to do because at that point all compiled code is cleared.

TEST=ci

Change-Id: Iaf3a66d1026611fc0a3df3903cb4e09e6d6c4c17
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311723
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Auto-Submit: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2023-06-27 23:08:26 +00:00
Ryan Macnak 274db26c57 [vm, gc] Refactor weak mourning.
TEST=ci
Change-Id: I0d60ed9284651eb49ea2b44edc877083c8c8390d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311152
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2023-06-27 22:23:17 +00:00
Anna Gringauze 789b1d1fcd [frontend_server] Add --canary flag
Closes: https://github.com/dart-lang/sdk/issues/52774
Change-Id: Ie42a803c5b63a41c37984a790ab0406c8939872d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311149
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Anna Gringauze <annagrin@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Mark Zhou <markzipan@google.com>
2023-06-27 22:21:04 +00:00
Ryan Macnak 4949f6185e [vm, gc] The GC cares about immediate-ness not Smi-ness.
TEST=ci
Change-Id: Ib7bae6df6becf0ed696a4c00257cedaf46f750aa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311148
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2023-06-27 19:47:04 +00:00
Alexander Markov dc30f815f1 [vm] Inline local functions declared in outer functions
Previously, inliner was able to inline closure calls only when closure
was allocated in the current function (or in a function which was
inlined so far). This is not true for local functions declared in outer
functions (they are allocated at declaration site).

Now, when calling local functions, target of closure call is always
known regardless of where the function is declared, so calls to local
functions can be inlined.

TEST=runtime/tests/vm/dart/inline_local_functions_il_test.dart
Fixes https://github.com/dart-lang/sdk/issues/52695
Fixes https://github.com/dart-lang/sdk/issues/15558

Change-Id: I0e51dbaf63a6d4427bff366b40414ca5fac3d418
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311465
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2023-06-27 19:42:15 +00:00
Nate Bosch 8debcecb85 Mention that IOSink truncates List<int> to bytes
Closes #31670

In `add` and `addStream` mention that int values which are too large are
truncated to bytes.

R=lrn@google.com

Change-Id: Idf276fc65592e21766659e9d89dd687c441b7357
CoreLibraryReviewExempt: Doc changes only.
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/310768
Auto-Submit: Nate Bosch <nbosch@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Nate Bosch <nbosch@google.com>
2023-06-27 19:39:01 +00:00
Nate Bosch db585cef2b Add a note about training run for JIT snapshot
Closes #50615

R=bkonyi@google.com

Change-Id: I488c9f232ab5b0138d25a66006b8f69a05ea9c05
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311144
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Nate Bosch <nbosch@google.com>
2023-06-27 19:26:38 +00:00
Nate Biggs 6378357ef4 [dart2js] Fix failing web/deferred_fail_and_retry_test on d8 platform.
'document.body' is not defined on the d8 platform but 'document' is so this was throwing.

Change-Id: I6e4049d86beedf4dbadee466fa581e4d3426df41
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311560
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
2023-06-27 18:25:30 +00:00
Nate Biggs d9b676b0be [dart2js] Add retry mechanism to deferred loading when file fails to register as loaded.
In order to have the browser send a new request for each retry (each new appended script tag), a query token must be appended to the URI. We don't include any extra tokens on the initial request.

Change-Id: I846660894c16345a441193cd9c7b4784364a3c54
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311200
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
2023-06-27 18:18:43 +00:00
Devon Carew 9216f830c6 [deps] rev package:lints to the latest; address lints
Change-Id: I64032a39c589c291297decade18f6a46c08f9c5e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/310966
Commit-Queue: Devon Carew <devoncarew@google.com>
Reviewed-by: Ömer Ağacan <omersa@google.com>
2023-06-27 17:03:37 +00:00
Tess Strickland 3a9c1e6d6d [vm] Remove extra DEBUG-only checking in SubtypeNTestCache.
These checks convert what would likely be a segfault into a breakpoint
instead, but they're heavyweight enough on certain tests to cause
timeouts. Remove them as issues here are easily debugged without them.

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

TEST=vm/dart/regress_48523 on debug reload bots

Change-Id: Icf9ea6191eb82c254d9a01fbc9f8ba6255602084
Cq-Include-Trybots: luci.dart.try:vm-reload-linux-debug-x64-try,vm-reload-rollback-linux-debug-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311621
Auto-Submit: Tess Strickland <sstrickl@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
2023-06-27 15:36:38 +00:00
Jens Johansen b2756f3aae [CFE] Tool for benchmarking adjacent revisions
E.g. if asking the tool to figure out any performance changes to
revision 5222bfd90c it will checkout 5222bfd90c and 2037563b94
(the previous commit), make aot-snapshots for both and run both on
the same (specified) target.

Change-Id: Ief56843326343ebaa681df596162d1d08457a8f7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311602
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2023-06-27 14:58:03 +00:00