Commit graph

98317 commits

Author SHA1 Message Date
Dan Chevalier
cf0d8e9556 Fix streamNotify so that it works with binary data
Change-Id: I173ebf46b4ec2bcb138e26456ec40f1fc8faaa19
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/337900
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Dan Chevalier <danchevalier@google.com>
2023-11-22 21:06:50 +00:00
Jake Macdonald
613fa1f5aa fix executor_test.dart for hasAbstract changes
Bug: https://github.com/dart-lang/sdk/issues/54130
Change-Id: If3554796de99ed0e8b8ea37ae159e89bcc5cbcf6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/337860
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Auto-Submit: Jake Macdonald <jakemac@google.com>
2023-11-22 18:52:20 +00:00
Danny Tuppeny
15ac79c93d [analysis_server] Fix a test that's failing on Windows
This code uses `Element.documentationComment` in the generated code and assumes it has the correct line endings. However, `documentationComment` is always normalized to `\n` so that's what we need to replace when building the new code.

Change-Id: I83c73bfeccbce7ec8621da2759f042f736fbe4d6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/337724
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-11-22 18:18:11 +00:00
Alexander Aprelev
72be727857 [gardening] Remove tests from stress_test_list that fail on the bot.
Change-Id: I2f17952836770dfe2b118bffc38b56b760eed29a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/337616
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2023-11-22 17:44:57 +00:00
Jake Macdonald
e6ebb9340f remove unmeaningful constructor parameters from ConstructorDeclarationImpl
Change-Id: I1bb5712349198d3a1658c405a164aa38d447c752
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/337660
Commit-Queue: Jake Macdonald <jakemac@google.com>
Auto-Submit: Jake Macdonald <jakemac@google.com>
Reviewed-by: Morgan :) <davidmorgan@google.com>
2023-11-22 17:37:22 +00:00
Paul Berry
430df693b9 Fix NodeTextExpectationsCollector.updatingIsEnabled and add presubmit check.
It looks like a recent commit accidentally left `updatingIsEnabled`
set to `true`. This should never be done, because it makes all tests
that use `NodeTextExpectationsCollector` silently pass on trybots. To
help prevent this happening by mistake again in the future, I've added
a presubmit check that will prevent a CL from being uploaded that
changes the `updatingIsEnabled` to `true`.

Change-Id: I8380e0ac1f425c64e62483f64916de6a804052e7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/337840
Auto-Submit: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-11-22 16:55:30 +00:00
Daco Harkes
47357d8535 Reland "[vm/ffi] Optimize @Native calls"
Original change in patchset 1.

The reland contains a fix for handles. The objects passed in handles
must live on the stack (or in the heap) so that that memory location
can be used as a handle.

This CL introduces a new allocation policy `RequiresRegister` which
forces constants to be spilled to the stack during register
allocation.
Note: Parameters to FfiCall instructions are currently not used in a
way that can make the parameters assigned to registers. So only
constants are treated currently. If we have a way to reproduce params
being assigned to registers, then we can force spilling for
non-consts as well in the register allocator.

Original change's description:
> [vm/ffi] Optimize `@Native` calls
>
> This CL removes static fields for storing the `@Native`'s function
> addresses. Instead, the function addresses are stored in the object
> pool for all archs except for ia32. ia32 has no AOT and no AppJit
> snapshots, so the addresses are directly embedded in the code.
>
> This CL removes the closure wrapping for `@Native`s. Instead of
> `pointer.asFunctionInternal()()` where `asFunction` returns a closure
> which contains the trampoline, the function is compiled to a body
> which contains the trampoline `Native()`. This is possible for
> `@Native`s because the dylib and symbol names are known statically.
>
> Doing the compilation in kernel_to_il instead of a CFE transform
> enables supporting static linking later. (The alternative would have
> been to transform in the cfe to a `@pragma('vm:cachable-idempotent')`
> instead of constructing the IL in kernel_to_il.
>
> To enable running resolution in ia32 in kernel_to_il.cc, the
> resolution function has been made available via
> `runtime/lib/ffi_dynamic_library.h`.
>
> Because the new calls are simply static calls, the TFA can figure
> out const arguments flowing to these calls. This leads to constant
> locations in the parameters to FfiCalls. So, this CL also introduces
> logic to move constants into `NativeLocation`s.

TEST=tests/ffi/vmspecific_ffi_native_handles_test.dart
TEST=tests/ffi/function_*_native_(leaf_)test.dart
TEST=pkg/vm/testcases/transformations/ffi/ffinative_compound_return.dart

Closes: https://github.com/dart-lang/sdk/issues/47625
CoreLibraryReviewExempt: Internal FFI implementation changes
Change-Id: Ia1401b335524dcbf50c663a8770d9a02802923df
Cq-Include-Trybots: luci.dart.try:vm-aot-android-release-arm64c-try,vm-aot-android-release-arm_x64-try,vm-aot-linux-debug-x64-try,vm-aot-linux-debug-x64c-try,vm-aot-mac-release-arm64-try,vm-aot-mac-release-x64-try,vm-aot-obfuscate-linux-release-x64-try,vm-aot-optimization-level-linux-release-x64-try,vm-aot-win-debug-arm64-try,vm-aot-win-debug-x64c-try,vm-aot-win-release-x64-try,vm-appjit-linux-debug-x64-try,vm-asan-linux-release-x64-try,vm-checked-mac-release-arm64-try,vm-eager-optimization-linux-release-ia32-try,vm-eager-optimization-linux-release-x64-try,vm-ffi-android-debug-arm-try,vm-ffi-android-debug-arm64c-try,vm-ffi-qemu-linux-release-arm-try,vm-ffi-qemu-linux-release-riscv64-try,vm-fuchsia-release-x64-try,vm-kernel-linux-debug-x64-try,vm-kernel-precomp-linux-release-x64-try,vm-linux-debug-ia32-try,vm-linux-debug-x64-try,vm-linux-debug-x64c-try,vm-mac-debug-arm64-try,vm-mac-debug-x64-try,vm-msan-linux-release-x64-try,vm-reload-linux-debug-x64-try,vm-reload-rollback-linux-debug-x64-try,vm-ubsan-linux-release-x64-try,vm-win-debug-arm64-try,vm-win-debug-x64-try,vm-win-debug-x64c-try,vm-win-release-ia32-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/333841
Reviewed-by: Slava Egorov <vegorov@google.com>
2023-11-22 16:13:42 +00:00
Jonas Termansen
53eabe4824 [infra] Enable RBE on Linux intel.
This change migrates the Dart linux builders from Goma to RBE via
reclient. Goma is being shut down by the end of the year and we must
migrate to the new replacement, which is much more powerful and can do
things we could never do with Goma. We should already see some mild
build time improvements from simply switching.

This change can be safely reverted if there are any problems:

- If you must revert this change, please reach out with what you
  observed, but please first read and try the below instructions.

- Cross-compilation with RBE is not implemented at this time and certain
  special builders running on Linux intel may not support RBE. The
  existing configuration support to disable Goma remains in place. The
  existence of configuration file makes the recipe switch all Linux x64
  bots use RBE rather than Goma. Try disabling Goma on any builders that
  are failing, whether using `--no-goma` in the test matrix or using
  `goma = False` on infra/config. Goma is going away soon and we will
  soon bring RBE up to feature parity and Goma isn't really working on
  the special cross builds anyway.

- Rare flakes in the remote builds have previously been observed, but I
  haven't seen them reappear yet after upgrading reclient. Look for
  build log messages mentioning the remote execution failed, or that an
  upload blob size digest mysteriously changed. Please alert me if you
  see this and I will talk to the Foundry team. If this happens, please
  try if you can fix this using `exec_strategy=remote_local_fallback` in
  the configuration file. Right now reclient only does remote executions
  to catch cases where RBE doesn't work, but if it fails, it can be
  configured to silently fall back on a slow local build.

- If RBE is used on a configuration that doesn't support RBE builds, the
  default -j 1000 may overload the bot if it falls back on a local
  build. If this happens, the bot may explode and fail with BOT_DIED. If
  this happens, disable Goma (RBE) on the builder as above and let me
  know about the problem.

- We haven't tried sending a full production load to the RBE pool yet.
  Flutter is already using the RBE pool partially. It's unclear what
  will happen once we turn this on for everyone. Keep an eye out for
  anything unusual and let me know.

- If it turns out RBE doesn't cache invalidate properly, it is possible
  outdated object files will be linked. If anything really weird
  happens, this may the case. As far as I tested, the caching is working
  correctly.

RBE is yet to be officially rolled out to our developers. Stay tuned.

Bug: b/296994239
Change-Id: I77e0025197ab98a672efbc0cb04c8ece528c3e29
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/335826
Reviewed-by: Alexander Thomas <athom@google.com>
Commit-Queue: Jonas Termansen <sortie@google.com>
2023-11-22 15:44:09 +00:00
Alexander Thomas
096bde2a4d [cleanup] Remove co19_2 and other references to _2 suites
Bug: b/310114753
Cq-Include-Trybots: luci.dart.try:dart2js-hostasserts-linux-unsound-try,ddc-linux-chrome-unsound-try,vm-kernel-linux-debug-x64-try,vm-kernel-linux-release-x64-try,vm-kernel-precomp-linux-release-x64-try,front-end-linux-release-x64-try
Change-Id: I45ebfda5d746f12ca0fa3c0003c299720f1c7179
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/337180
Commit-Queue: Alexander Thomas <athom@google.com>
Reviewed-by: Jonas Termansen <sortie@google.com>
2023-11-22 11:15:57 +00:00
Ryan Macnak
b9dc72f367 [infra] Give VM engineers OWNERS over double-conversion and binary_size.
Ownership used to be inherited from //runtime until 4d308f3911.

Change-Id: I252d7c3bfea20a5763ea432eedaf5a79d74c956b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/337604
Reviewed-by: Alexander Thomas <athom@google.com>
Commit-Queue: Alexander Thomas <athom@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2023-11-22 08:38:49 +00:00
Sam Rawlins
cf44f0c780 Analyzer: unregister test rules in tearDown
Change-Id: I8aae2ce4d75af0e47b900a149ff73dcb6064a26e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/337613
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2023-11-22 01:24:11 +00:00
Konstantin Shcheglov
800619634b Extension type. Issue 54081. Report ENUM_CONSTANT_INVOKES_FACTORY_CONSTRUCTOR.
Bug: https://github.com/dart-lang/sdk/issues/54081
Change-Id: Id539dd6693eaab0a86f51982e4497943e150d5b7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/337608
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-11-22 00:58:09 +00:00
Jake Macdonald
a1b8fa4613 move hasAbstract from FunctionDeclaration to FieldDeclaration
Bug: https://github.com/dart-lang/language/issues/3454
Change-Id: Ic157dcd1e2c82c8cc08cd225065fd2810a8b02f2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/335240
Reviewed-by: Morgan :) <davidmorgan@google.com>
Commit-Queue: Jake Macdonald <jakemac@google.com>
2023-11-21 23:18:10 +00:00
Konstantin Shcheglov
87fefe24e2 Macro. Add tests for function type formal parameters without name.
Change-Id: I9622efbd73f36eaf909b37bea27ff363fa111fb6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/337611
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
2023-11-21 22:42:14 +00:00
Stephen Adams
3f2432f36c [js_runtime] Utf8 - reuse buffer to avoid creating many small buffers
Allocating typed data on Chrome is surprisingly expensive
(e.g. https://bugs.chromium.org/p/v8/issues/detail?id=9199).  This
makes it worthwhile to keep a buffer around for reuse rather than
allocating a new one for each conversion that requires copying.

Change-Id: I8b2823f487cd8b869fc8b22f309490475c7c010d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/337462
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2023-11-21 22:40:10 +00:00
pq
69666dc283 thread analysis options into the error verifier and type resolver
Change-Id: I6f48f01040280b0c74dc4077b47e717912985b74
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/337640
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2023-11-21 20:49:39 +00:00
Ryan Macnak
fc85488000 [vm] Unwind records for Windows ARM64.
TEST=ffi_induce_a_crash_test
Bug: https://github.com/dart-lang/sdk/issues/51726
Change-Id: I7df3b56a150434d4c7b0cfbadda4fd9d57606eef
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/336203
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2023-11-21 20:39:29 +00:00
Sam Rawlins
faf503cbc4 Correct FunctionType docs
In particular, revert text about the parameters being sorted.

Also, put all text in present tense.

Also, follow some Effective Dart:

* https://dart.dev/effective-dart/documentation#do-start-doc-comments-with-a-single-sentence-summary
* https://dart.dev/effective-dart/documentation#do-separate-the-first-sentence-of-a-doc-comment-into-its-own-paragraph
* https://dart.dev/effective-dart/documentation#prefer-starting-function-or-method-comments-with-third-person-verbs
* https://dart.dev/effective-dart/documentation#prefer-starting-a-non-boolean-variable-or-property-comment-with-a-noun-phrase

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

Change-Id: Idbe1a1a80281071db5fe25c1faa8ccd5be1a5322
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/337606
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-11-21 20:24:12 +00:00
Danny Tuppeny
2aa6fa772b [analysis_server] Don't send redundant empty LSP diagnostics
We never need to send empty diagnostics to the client unless we have previously sent a non-empty set. These empty diagnostics account for a large amount of traffic during initial analysis and also could be quite large when modifying files with dependencies.

See https://github.com/dart-lang/sdk/issues/53501

Change-Id: I3d0e2ea2633469da905c8ca328dcc89e38a64edc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/337582
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2023-11-21 20:05:04 +00:00
Danny Tuppeny
4438cdc6b9 [analysis_server] Add a failing integration test for non-existent workspace roots
See https://github.com/dart-lang/sdk/issues/54116

Change-Id: Ic5d448f0b461fcc8d85384cf16ddd947da1ab02f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/337542
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2023-11-21 19:41:13 +00:00
Paul Berry
a19ae4ee68 Enable the extension types language feature.
This language feature allows the user to declare a static type using
`extension type` syntax, for example:

    extension type IdNumber(int i) {
      operator <(IdNumber other) => i < other.i;
      bool isValid(Some parameters) => ...;
    }

This behaves similarly to a "wrapper" class:

    class IdNumber {
      final int i;
      IdNumber(this.i);
      operator <(IdNumber other) => i < other.i;
      bool isValid(Some parameters) => ...;
    }

However, at runtime, no wrapper objects are created; instead, an
instance of the extension type is represented directly by its
"representation type" (`int` in the above example), and methods like
`isValid` are resolved statically. This gives developers an
abstraction mechanism with the advantage of zero runtime performance
cost, since no extra heap space is required, and no extra instructions
are needed to convert between an extension type and its underlying
representation.

The disadvantage of using extension types as an abstraction mechanism
is that since no wrapper objects are created at runtime, the
abstraction can be bypassed using `dynamic`, runtime casts, or by
"laundering" the object through contravariant generic methods like
`List.add` (which are runtime checked in Dart). For example:

    main() {
      var id = IdNumber(1);
      var list1 = <int>[];
      List<Object> list2 = list1;
      list2.add(id); // OK at compile time because `IdNumber` is a
                     // subtype of `Object`. OK at runtime because
		     // at runtime, `IdNumber` and `int` are
		     // indistinguishable.
      int i = list1[0];
      print(i);
    }

Extension types are expected to be particularly useful for
low-overhead decoding of external data formats (such as JSON), and for
inter-operation with other languages (such as Javascript).

For additional information see the feature specification:
https://github.com/dart-lang/language/blob/main/accepted/future-releases/extension-types/feature-specification.md

Change-Id: I900a3a25dcfc38bfa9c9f9b5b9fa20f362883653
Tested: Standard trybots
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/335062
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Leaf Petersen <leafp@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2023-11-21 19:14:49 +00:00
Paul Berry
66fd5972bd Fix analyzer warning in step_through_extension_type_method_call_test.dart
Once the flag for extension type support has been flipped on, the
analyzer will stop reporting `experiment_not_enabled` for this file,
and will instead be able to analyze it properly.

To avoid the `always_declare_return_types` warning when that happens,
the `<` operator needs a return type.

Change-Id: I76af290decf2ab480486c981ce1e1f17e44716c7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/337463
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2023-11-21 19:11:34 +00:00
Danny Tuppeny
cfcd74e72c [analysis_server] Remove some boilerplate from LSP tests
No functional changes, just some refactoring extracted from another change to simplify reviewing.

This just:

- adds an `initialAnalysis` getter for tests since it's very common to wait for
- adds a `diagnostics` map that tracks the current state of diagnostics in a test (to avoid tests setting up their own tracking)
- removes some duplicating code for sending diagnostics by having NotificationManager call LspAnalysisServer to send them
- removes unnecessary experiment flags from LSP tests

Change-Id: I1811f393a6d3446550f9007ede926f9ca4556563
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/337580
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2023-11-21 19:02:16 +00:00
Sam Rawlins
dd6c961bf0 Remove all pre-NNBD support in the linter code
In this CL we "remove" 3 linter rules, and any subsequently unused quick fixes:

* `always_require_non_null_named_parameters`
* `avoid_returning_null`
* `avoid_returning_null_for_future`

We also delete any code that branched on pre-NNBD libraries; these are
no longer supported.

Change-Id: I3bad7a44de3563e5737919c878170213ad506b82
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/336244
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2023-11-21 18:55:01 +00:00
Paul Berry
4016197b30 Add support for await, yield, and is checks to the wolf analysis prototype.
The AST-to-IR conversion stage now handles the AwaitExpression,
YieldStatement, and IsExpression AST nodes. This required adding the
`await_`, `yield_`, and `is_` instructions.

I believe this completes the proof-of-concept phase of AST-to-IR
conversion. I plan to move on now to implementing some lint rules
based on the IR representation.

Change-Id: I5f6e920dd04ca23d6b90d1522abf32955f757bc4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/337280
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2023-11-21 18:54:10 +00:00
Zach Anderson
8724025782 Adds a flag to run_binary_size_analysis.py to disable format checks
This change is needed for compatibility with the Flutter Engine's
use of a new Android NDK. The new Android NDK includes a new clang
toolchain which does a better job of classifying various
contributors to a binary's size, but which fails the compatibility
checks in the script. The intention of the compatibility checks is
to exclude versions of tooling that are too old not versions that
are too new. The compatibility check is also redundant with
failure modes later in the script. To avoid breaking any usage
of this script in the Dart tree, however, the check is retained
by this change, and instead a flag is added that skips it. This
is preferable to expanding on the questionable use of regular
expressions that implement the check to capture the strings
emitted by a continually updating toolchain.

Change-Id: If379e4aa86339a31eada0b6ce3fa90ddc9351804
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/337602
Commit-Queue: Zach Anderson <zra@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2023-11-21 18:46:57 +00:00
Parker Lougheed
2f30295254 [analyzer] Correct invalid_dependency diagnostic message
Fixes https://github.com/dart-lang/sdk/issues/53217

Bug: https://github.com/dart-lang/sdk/issues/53217
Change-Id: I2b802adda2ff6403d279dc2f6cffc36f6f8047d1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/337302
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Marya Belanger <mbelanger@google.com>
Auto-Submit: Parker Lougheed <parlough@gmail.com>
Reviewed-by: Marya Belanger <mbelanger@google.com>
2023-11-21 18:46:06 +00:00
Alexander Aprelev
2b596a77ae [gardening] Clean up isolate stress tests list.
This removes tests that don't work well in isolate stress testing environment.

Change-Id: Ifddb53dd17408848522649aa68123cb0b60d5c20
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/337600
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2023-11-21 18:22:53 +00:00
Paul Berry
88286dc100 Add support for simple loops to the wolf analysis prototype.
The AST-to-IR conversion stage now handles the DoStatement and
WhileStatement AST nodes, as well as simple ForStatement nodes (those
whose `forLoopParts` is `ForPartsWithDeclarations`). This required
adding the `loop` instruction. Unlabeled `break` and `continue`
statements are also supported.

Change-Id: Iaa46245755087e9f905988d65c4c2e0c33d283ab
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/337041
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2023-11-21 18:10:03 +00:00
Tess Strickland
4bedb142d3 Reland "[pkg/vm] Handle switch statements in unreachable code eliminator."
This is a reland of commit 262311772b

When running with sound null safety, reducing a logical expression to
the right hand side if the left hand side is constant and does not short
circuit is valid, as the right hand side is guaranteed not to evaluate
to null.

In other modes, however, the right hand side may evaluate to null.
Thus, in thos modes, we return the original node if the RHS is not a
constant boolean value, so that the operator can perform whatever null
checking is required.

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

Original change's description:
> Reland "[pkg/vm] Handle switch statements in unreachable code eliminator."
>
> This is a reland of commit 92bf76d9e8
>
> In the original CL, the changes to the UCE assumed all
> SwitchStatements were exhaustive. Now if a SwitchStatement isn't
> explicitly or implicitly (via a default case) exhaustive and no case
> matches the tested constant, the SwitchStatement is properly removed.
>
> In addition, if a guaranteed to match case is found, more than one
> cases remain (thus the SwitchStatement is not removed or replaced with
> the single case's body), and the default case is removed, then the
> resulting SwitchStatement is marked as explicitly exhaustive, as this
> serves as a signal to backends that they do not need to handle the
> possibility of no case matching in the absence of a default case.
>
> Original change's description:
> > [pkg/vm] Handle switch statements in unreachable code eliminator.
> >
> > Namely, if the tested expression for a switch statement is constant,
> > then we can remove any constant cases where the constants differ,
> > and if all but a single case is removed, we can replace the switch
> > with the case body.
> >
> > If constant functions are not enabled, then getters annotated with
> > @pragma("vm:platform-const") are still evaluated with the constant
> > function evaluation machinery, but only those and no others (including
> > any functions called within an annotated getter). This way, functions
> > can be annotated with @pragma("vm:platform-const") without having to
> > rewrite them to be a single returned expression.
> >
> > TEST=pkg/vm/test/transformations/unreachable_code_elimination
> >      pkg/vm/test/transformations/vm_constant_evaluator
> >
> > Issue: https://github.com/dart-lang/sdk/issues/50473
> > Issue: https://github.com/dart-lang/sdk/issues/31969
> > Change-Id: Ie290d2f1f469326238d66c3d9631f8e696685ff0
> > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/332760
> > Commit-Queue: Tess Strickland <sstrickl@google.com>
> > Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
> > Reviewed-by: Alexander Markov <alexmarkov@google.com>
>
> TEST=pkg/vm/test/transformations/unreachable_code_elimination
>      pkg/vm/test/transformations/vm_constant_evaluator
>
> Issue: https://github.com/dart-lang/sdk/issues/50473
> Issue: https://github.com/dart-lang/sdk/issues/31969
> Cq-Include-Trybots: luci.dart.try:vm-aot-linux-release-x64-try,vm-aot-mac-release-arm64-try
> Change-Id: I557ca933808012e670e306f2d880221a0d7dd670
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/334224
> Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
> Reviewed-by: Alexander Markov <alexmarkov@google.com>
> Commit-Queue: Tess Strickland <sstrickl@google.com>

TEST=pkg/vm/test/transformations/unreachable_code_elimination
     pkg/vm/test/transformations/vm_constant_evaluator

Change-Id: Ia51b7c5f3b51f57a6a306551fe74b47e0cba3c23
Cq-Include-Trybots: luci.dart.try:vm-aot-linux-release-x64-try,vm-aot-mac-release-arm64-try,vm-kernel-precomp-linux-release-x64-try,vm-kernel-linux-release-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/335828
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
2023-11-21 18:07:30 +00:00
Paul Berry
2c4a1354e1 Add support for ++ and -- to the wolf analysis prototype.
The AST-to-IR conversion stage now fully handles prefix and postfix
increment and decrement operations. These are implemented in terms of
more primitive IR operations, so no additional IR support is needed.

Change-Id: I0c1bdccdb73db8d15c0ad45d699e793406345583
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/336830
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2023-11-21 18:02:00 +00:00
Paul Berry
0adcceec9f Add support for BinaryExpression to the wolf analysis prototype.
The AST-to-IR conversion stage now fully handles the BinaryExpression
AST node. Most binary expressions are handled by invoking a
user-definable operator. `==` and `!=` (which were implemented in a
previous CL) are handled through the `eq` instruction. Shortcutting
operations `&&`, `||`, and `??` are handled with flow control.

Also added support for compound assignments (`op=`) and if-null
assignments (`??=`).

Change-Id: I90623c4175bf20c77016409da5e503ab74408f6c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/337080
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2023-11-21 17:59:27 +00:00
Jackson Gardner
7961fea00f Revert "Reland adding a pass to fix pubspec during dart fix runs"
This reverts commit 3c3dd78bc1.

Reason for revert: Causes a crash when analyzing flutter customer tests. See https://github.com/flutter/flutter/issues/138813

Original change's description:
> Reland adding a pass to fix pubspec during dart fix runs
>
> Change-Id: I48d2cd1e4023129e62ef371b452873a320ce0461
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/337160
> Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
> Auto-Submit: Keerti Parthasarathy <keertip@google.com>
> Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>

Change-Id: I4056ef6ab6772ec6ee8eada9657bb6eacc0a1274
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/337603
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
2023-11-21 17:45:29 +00:00
Nate Bosch
459f1adecc Bump collection to 2d57a82ad079fe2d127f5a9b188170de2f5cdedc
Changes:
```
> git log --format="%C(auto) %h %s" f309148..2d57a82
 https://dart.googlesource.com/collection.git/+/2d57a82 Avoid setRange with potentially incompatible types (320)

```

Diff: https://dart.googlesource.com/collection.git/+/f309148623c4755ce9d6c00850092458325058ca..2d57a82ad079fe2d127f5a9b188170de2f5cdedc/
Change-Id: I7d65dd8ebebee6505561ed59282af84a3c22119a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/337461
Reviewed-by: Sigurd Meldgaard <sigurdm@google.com>
Commit-Queue: Nate Bosch <nbosch@google.com>
2023-11-21 17:41:03 +00:00
pq
408cf78856 thread analysis options into AST resolvers
Follow-up from: https://dart-review.googlesource.com/c/sdk/+/336824

Change-Id: Ida8bbcf167dfb2cf0561ee2839b2b2b887892305
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/337402
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2023-11-21 17:30:29 +00:00
Alexander Thomas
0b831251c6 [infra] Upgrade d8 to 12.1.131
This version of the d8 package has been created with an updated script
that also publishes arm64 binaries.

See https://dart-review.googlesource.com/c/sdk/+/336200.

Bug: b/312410807
Cq-Include-Trybots: luci.dart.try:dart2js-hostasserts-linux-d8-try,dart2js-minified-linux-d8-try,dart2wasm-linux-d8-try
Change-Id: Iaff4d26c4c6f12feaea6f1cd08ce408925c2a3d3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/337483
Reviewed-by: Ömer Ağacan <omersa@google.com>
Commit-Queue: Alexander Thomas <athom@google.com>
2023-11-21 17:15:20 +00:00
Ryan Macnak
c1143082fe Include ARM64 when uploading d8.
Change-Id: I613ca948734a849c43f6f6d02cfd678d18fe7e03
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/336200
Reviewed-by: Alexander Thomas <athom@google.com>
2023-11-21 17:15:20 +00:00
David Morgan
8d62c1962c Add extension type macro and declaration interfaces and implementation.
Add test coverage: `SimpleMacro`, `executor_test`, `serialization_test`.

R=jakemac@google.com

Bug: https://github.com/dart-lang/language/issues/3224
Change-Id: I17a814b18231db60a33b41099c93c0978cebae1b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/337543
Reviewed-by: Jake Macdonald <jakemac@google.com>
Commit-Queue: Jake Macdonald <jakemac@google.com>
Auto-Submit: Morgan :) <davidmorgan@google.com>
2023-11-21 16:55:34 +00:00
Moritz
a3568286ff Adding the resource-identifier functionality from the compiler to the
vm.

This identifies all calls to static methods annotated with
`@ResourceIdentifier`, collects the constant arguments passed to the
method, and writes the results into a file.

The purpose of this feature is to be able to pass the recorded
information to packages in a post-compilation step, allowing them to
remove or modify assets based on the actual usage in the code prior to
bundling in the final application.

Tested: pkg/vm/test/transformations/resource_identifier_test.dart
Change-Id: I58cb313b66ee23c1d154dcc242547723a1ced359
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/329961
Commit-Queue: Moritz Sümmermann <mosum@google.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
2023-11-21 15:05:35 +00:00
Paul Berry
099721d8a2 Add support for MethodInvocation to the wolf analysis prototype.
The AST-to-IR conversion stage now handles the MethodInvocation AST
node (which is used for both method invocations and top level function
invocations).  This required adding the instruction `identical`, to
support invocations of the `identical()` function.

Change-Id: I7a4204f50c770874ff913e2cbeabb997958025c8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/336829
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2023-11-21 14:58:59 +00:00
Paul Berry
f03646e2fc Add more simple flow control support to the Wolf analysis prototype.
The AST-to-IR conversion stage now handles if statements, conditional
expressions, unary `!`, and binary `!=`. This required adding the
instruction `not`.

Change-Id: I2c87f95d8dfa1967ebe6c92c789c16254779c5bd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/336821
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2023-11-21 14:16:29 +00:00
Alexander Thomas
001e41eca6 [infra] Upgrade jsshell to 120.0
Bug: b/312410807
Change-Id: I7439d9aede2794d32f02d4dd068727de661d990b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/337484
Commit-Queue: Alexander Thomas <athom@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2023-11-21 13:52:28 +00:00
Alexander Thomas
b9f034ad5d [infra] Upgrade firefox to 120.0
Bug: b/312410807
Cq-Include-Trybots: luci.dart.try:dart2js-linux-firefox-try,ddc-linux-firefox-try
Change-Id: I365fd8e32a87b0d76b34bc77e06b3975b4d8c0af
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/337541
Reviewed-by: Martin Kustermann <kustermann@google.com>
2023-11-21 13:10:58 +00:00
Tess Strickland
fc613d85a7 [vm] Respect PC offset printing options for disassembled function info.
When disassembling functions, respect whether absolute addresses should
be used for PC offsets when printing stack map, PC descriptor and
exception handler information.

Also don't print out results for empty auxiliary information.

TEST=ci

Change-Id: Ieda990c1eabcce8be968981a81123a78746c6b6b
Cq-Include-Trybots: luci.dart.try:vm-aot-linux-release-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/336663
Commit-Queue: Tess Strickland <sstrickl@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
2023-11-21 12:23:52 +00:00
Martin Kustermann
742715e57a [gardening] Fix memory leak in vm/cc/SafepointRwLockExclusiveNestedWriter_Regress44000
The test was recently modified in [0] and introduced a memory leak which
this CL fixes.

TEST=Fixes vm/cc/SafepointRwLockExclusiveNestedWriter_Regress44000 in asan mode

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

Change-Id: I536b3c56cf448019294053e5ef7d347ccbe6d366
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/337482
Reviewed-by: Tess Strickland <sstrickl@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2023-11-21 11:46:24 +00:00
Tess Strickland
26911a6176 [vm/compiler] On 32-bit archs, no specific inline for index checks.
Replacing index checks with a single GenericCheckBound instruction
currently causes performance regressions on 32-bit ARM. Undo that
optimization there for now, instead inlining the original Dart code
into the indexing operations.

TEST=ci

Issue: https://github.com/flutter/flutter/issues/138689
Change-Id: I7e67966b576a9d1b5f510e17b44f853f23c98a91
Cq-Include-Trybots: luci.dart.try:vm-linux-release-simarm-try,vm-ffi-qemu-linux-release-arm-try,vm-aot-linux-release-simarm_x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/337480
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
2023-11-21 11:40:01 +00:00
Ömer Sinan Ağacan
7f5cba2e53 [dart2wasm] Stop using Utf8Decoder._convertIntercepted
Issue: #54018.

Change-Id: Ic8ee663f45acc3ae0300cdd3f1cbb9132110c6f3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/337481
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Commit-Queue: Ömer Ağacan <omersa@google.com>
2023-11-21 11:18:12 +00:00
Ömer Sinan Ağacan
dd8952f575 [dart2wasm] Avoid bounds check in some dart:convert functions
Also improves `codeUnitAt` bounds checks by using unsigned comparisons.

`package:characters` benchmarks before:

    Index Iteration: 23316 gc/ms
    String Iteration: 15329 cu/ms
    String Reversing: 6974.1 cu/ms
    String Replacing: 222.88 changes/ms

After:

    Index Iteration: 29729 gc/ms
    String Iteration: 17923 cu/ms
    String Reversing: 7270.9 cu/ms
    String Replacing: 236.28 changes/ms

Change-Id: I36832206b99ba9704e6e5863028d7eaa76412c3f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/337181
Commit-Queue: Ömer Ağacan <omersa@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
2023-11-21 10:51:50 +00:00
Parker Lougheed
bbdbd07287 Update README.dart-sdk for inclusion of AOT snapshots
Updates the `snapshots/` description now that some Dart tools are included as AOT snapshots. Also updates the `utils/` description to be more generic since wasm-opt is bundled as well.

TEST=ci

Change-Id: If2611e9ae139ede772061ee62644e91d9b051555
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/332180
Reviewed-by: Michael Thomsen <mit@google.com>
Auto-Submit: Parker Lougheed <parlough@gmail.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Michael Thomsen <mit@google.com>
2023-11-21 10:33:22 +00:00
Jens Johansen
40777c001a [CFE] Textual outline suite pretends the inline_class flag was flipped
Currently, if a not-enabled-by-default experimental flag is on we allow
formatting to fail.
This means that when the flag is flipped there's a risk of failures as
formatter crashes are now not allowed anymore.

The failures for flipping the extension types / inline-class feature
has caused crashes and was fixed before (twice!) in
https://dart-review.googlesource.com/c/sdk/+/336001
https://dart-review.googlesource.com/c/sdk/+/335448

But naturally a new test was added after
(https://dart-review.googlesource.com/c/sdk/+/336022) and we had a new
failure on the flag-flip CL.

This CL instead pretends like the inline-class flag is already flipped,
in that the formatter is not allowed to crash because of it.
That should make any new tests added before the flag is flipped that
would otherwise cause a failure upon flag flip, fail, forcing the
update of the status file.

The status file is furtermore updated.

Change-Id: Ifbc3d271a614e5dd747b35b252034087ad155a92
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/337321
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2023-11-21 10:23:48 +00:00