Commit Graph

6190 Commits

Author SHA1 Message Date
Robert Nystrom 732b07a42b Roll dart_style into the SDK.
I'm still chasing down a couple of google3 failures, but this is ready for review so that I can get it approved and land it once the last couple of failures are fixed. Here is who I think should review what:

athom@ for:

- DEPS

johnniwinther@ for:

- pkg/_fe_analyzer_shared
- pkg/front_end
- pkg/kernel

brianwilkerson@ for:

- pkg/analysis_server
- pkg/analyzer_plugin
- pkg/analyzer_utilities

kenzieschmoll@ for:

- pkg/dartdev

pquitslund@ for:

- pkg/linter/lib/src/lint_codes.g.dart

If you're not the right person, feel free to summon someone else.

Most of the changes here are re-running code generators that auto-format the code they generate. The changes are:

Roll in the latest dart_style commit:

- DEPS

Manually updated these test expectations to expect the new style:

- pkg/analysis_server/test/lsp/format_test.dart
- pkg/analysis_server/test/services/refactoring/agnostic/change_method_signature_test.dart
- pkg/analysis_server/test/src/domains/flutter/set_property_value_test.dart
- pkg/analysis_server/test/src/services/flutter/container_properties_test.dart
- pkg/analysis_server/test/src/services/flutter/widget_descriptions_test.dart
- pkg/analysis_server/test/src/services/refactoring/convert_selected_formal_parameters_to_named_test.dart
- pkg/analysis_server/test/src/services/refactoring/move_selected_formal_parameters_left_test.dart

This was auto-generated by something, but I'm not sure why it thinks there is a diff:

- pkg/analyzer_plugin/doc/api.html

Updated to require a version of dart_style that accepts a language version in DartFormatter():

- pkg/analyzer_plugin/pubspec.yaml

Updated to always use the latest language version (and thus new style) when invoking the formatter:

- pkg/analyzer_utilities/lib/tools.dart

Manually updated the formatting in the code templates so that they matched the formatting expected by the tests, which implicitly format using the latest language version:

- pkg/dartdev/lib/src/templates/...

The rest are all generated files that are formatted so re-generated using the new style:

- pkg/_fe_analyzer_shared/lib/src/experiments/flags.dart
- pkg/_fe_analyzer_shared/lib/src/messages/codes_generated.dart
- pkg/analysis_server_client/lib/handler/notification_handler.dart
- pkg/analysis_server_client/lib/src/protocol/...
- pkg/analysis_server/lib/protocol/protocol_generated.dart
- pkg/analysis_server/test/integration/support/integration_test_methods.dart
- pkg/analysis_server/test/integration/support/protocol_matchers.dart
- pkg/analyzer_plugin/lib/protocol/...
- pkg/analyzer_plugin/test/integration/support/integration_test_methods.dart
- pkg/analyzer_plugin/test/integration/support/protocol_matchers.dart
- pkg/analyzer/lib/src/analysis_options/error/option_codes.g.dart
- pkg/analyzer/lib/src/dart/error/...
- pkg/analyzer/lib/src/error/codes.g.dart
- pkg/analyzer/lib/src/manifest/manifest_warning_code.g.dart
- pkg/analyzer/lib/src/pubspec/pubspec_warning_code.g.dart
- pkg/analyzer/lib/src/summary/format.dart
- pkg/analyzer/lib/src/wolf/ir/ir.g.dart
- pkg/compiler/test/tool/graph_isomorphizer/golden/less_simple/lib_000_1.dart
- pkg/compiler/test/tool/graph_isomorphizer/golden/less_simple/lib_001_0.dart
- pkg/compiler/test/tool/graph_isomorphizer/golden/less_simple/lib_010_0.dart
- pkg/compiler/test/tool/graph_isomorphizer/golden/less_simple/lib_100_0.dart
- pkg/compiler/test/tool/graph_isomorphizer/golden/simple/...
- pkg/front_end/lib/src/api_prototype/experimental_flags_generated.dart
- pkg/front_end/lib/src/codes/cfe_codes_generated.dart
- pkg/front_end/lib/src/util/parser_ast_helper.dart
- pkg/front_end/test/parser_test_listener.dart
- pkg/front_end/test/parser_test_parser.dart
- pkg/front_end/testcases/...
- pkg/kernel/lib/src/coverage.dart generated
- pkg/kernel/lib/src/equivalence.dart generated
- pkg/linter/lib/src/lint_codes.g.dart

Change-Id: Ice0141b763e63b84f54692cd19a442a0719673c6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/391263
Commit-Queue: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Alexander Thomas <athom@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
2024-11-06 18:42:25 +00:00
Srujan Gaddam 2973f37c9a [dart2js] Skip interop extension type object literal constructors during serialization
Fixes https://github.com/dart-lang/sdk/issues/57008

dart2js was mistakenly assuming the generated procedures for these
constructors are top-level external interop members and accidentally
generating invalid code. We should skip serializing these procedures.
This should be safe since any invocation of these procedures are
transformed in visitStaticInvocation.

Change-Id: If11c718bea8447b60de00b73f328a3cdd5544bda
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/393001
Auto-Submit: Srujan Gaddam <srujzs@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Nate Biggs <natebiggs@google.com>
2024-11-01 16:11:30 +00:00
Stephen Adams 9062cf4d75 [dart2js] Improve DominatedUses.replaceWith
When the instruction being replaced has many uses, it is beneficial to update them together, rather than one at a time.

Also:

- Make value_range_analyer output intermediate state for `--dump-ssa`.
- Remove bounds checks all together at end of range analysis.
- Don't add RangeConversion for the length when the length is a constant.

Compiling a method with 5000 assignments of the form `a[N] = N;` is reduced 20x, from 123 seconds to 6 seconds.

Bug: #56919
Change-Id: I9ca7b41ca156ee40b96cfed9e18369662053b3b7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/390824
Reviewed-by: Nate Biggs <natebiggs@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2024-10-23 00:35:20 +00:00
asiva da14b16ef3 [Web/DDC] - Convert the kernel_worker and dartdevc snapshots to an AOT snapshot
Converts kernel_worker.dart.snapshot and dartdevc.dart.snapshot to
 AOT snapshots. Fixes tests and paths in the code accordingly.

TESTS=ci

Change-Id: Ib99b2a3343e23252c3a6b5295b0d20f0f486aede
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/381388
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
2024-10-22 17:39:27 +00:00
Kallen Tu 1bf5482e1e Enable 'wildcard-variables' feature flag.
This CL enables the wildcard variables feature by default in Dart 3.7.

Local variables and parameters named `_` are now non-binding and they can be declared multiple times without collisions. All wildcard variable declaration types that have this behavior are described in the
wildcard variables specification: https://github.com/dart-lang/language/blob/main/accepted/future-releases/wildcard-variables/feature-specification.md.

Top-level variables, top-level function names, type names, member names, etc.
are unchanged. They can be named `_` and used as they are today.

These are a few examples of where wildcard variables can be used:
```dart
Foo(_, this._, super._, void _()) {}

typedef T = void Function(String _, String _);

main() {
  var _ = 1;
  int _ = 2;

  list.where((_) => true);
}
```

Bug: https://github.com/dart-lang/sdk/issues/55673
Fixes: https://github.com/dart-lang/sdk/issues/55654
Change-Id: I80e904d39b364f5e54b8406b4db02ec40ecc9db0
TEST=Existing tests, language tests for wildcards.
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/381311
Reviewed-by: Mark Zhou <markzipan@google.com>
Reviewed-by: Mayank Patke <fishythefish@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Bob Nystrom <rnystrom@google.com>
2024-10-15 19:12:31 +00:00
Lasse R.H. Nielsen f8086c81ae Collect all test-related files in package:expect.
Collects files from `package:async_helper` and `tests/language`
that are generally useful, so that all test-related helpers are
in `package:expect`.

Moves the two libraries from `package:async_helper` into `package:expect`,
and the `tests/language/static_type_helper.dart` file too.

Deprecates `async_minitest.dart`, to follow `minitest.dart`,
expecting the Flutter use of it to have been fixed to not break
on deprecation (I believe Flutter no longer breaks builds on deprecations at all).

Patch 1 is the actual change.
Patch 2+4+8 is changing all existing references to the files.
Patch 6 ignores deprecation in files still using `async_minitest.dart`.

3+5+7+9 are updating this text to make the numbers match.
Then it's just test-expectations and small tweaks from there.

Change-Id: I1b665135b5fef9b9a0c3b340ffe9daf874d0174c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/373120
Reviewed-by: Nate Bosch <nbosch@google.com>
Reviewed-by: Devon Carew <devoncarew@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
2024-10-11 16:53:52 +00:00
Stephen Adams b8a3da5c3e [dart2js] Fix constant hashing finalizer
Other instances of this algorithm use '^'.
Using '&' causes a few more hash collisions.

Change-Id: I933565fa2008f2c96337d26e95c82e5db8f615f7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/388425
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2024-10-08 18:39:22 +00:00
Kevin Moore 07fd58715c pkg-compiler: drop Pair class, use Record
Change-Id: I19b05ffc6bd8e87e58990a62a21b8a2986fe9f54
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/382760
Commit-Queue: Nate Biggs <natebiggs@google.com>
Auto-Submit: Kevin Moore <kevmoo@google.com>
Reviewed-by: Nate Biggs <natebiggs@google.com>
2024-10-07 17:55:44 +00:00
Mayank Patke e1ea58781e [dart2js] Convert side effects flags to enumsets.
Change-Id: I10c5ebe70d3f096a2c2e0cb5af7d69e6e13b9681
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/387880
Commit-Queue: Mayank Patke <fishythefish@google.com>
Reviewed-by: Nate Biggs <natebiggs@google.com>
2024-10-04 18:33:09 +00:00
Mayank Patke 03c01908f2 [dart2js] Convert compact flags to enumsets.
Change-Id: I79aba08aafa41fdde57ab0268376bf4f158179df
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/386827
Reviewed-by: Nate Biggs <natebiggs@google.com>
2024-10-04 18:33:09 +00:00
Jens Johansen 3dce89fbe0 [scanner] Don't give the Utf8 scanner a 0-terminated byte sequence
Not having to do the read-allocate-copy dance for files to add a 0-byte
at the end results in these changes when using the CFE to compile
(a fixed version of) the CFE:

```
msec task-clock:u: -1.7356% +/- 0.2164% (-73.16 +/- 9.12)
page-faults:u: -2.6957% +/- 0.0111% (-2914.83 +/- 12.00)
cycles:u: -1.7128% +/- 0.2223% (-297927979.70 +/- 38660477.01)
instructions:u: -1.6814% +/- 0.0002% (-361315766.86 +/- 36853.71)
branch-misses:u: -3.3289% +/- 0.9669% (-2153126.00 +/- 625370.97)
seconds time elapsed: -1.7372% +/- 0.2154% (-0.07 +/- 0.01)
seconds user: -1.5998% +/- 0.2740% (-0.06 +/- 0.01)
seconds sys: -4.1451% +/- 2.9801% (-0.01 +/- 0.01)
Scavenge(   new space) goes from 62 to 61
```

TEST=Existing test coverage.

Change-Id: I8e182bcee39839f6ed1e658c30c85c40ecf0b259
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/385722
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Morgan :) <davidmorgan@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Mayank Patke <fishythefish@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2024-09-25 08:33:48 +00:00
Mayank Patke 8fda05e2fd [dart2js] Remove redundant clone method from EnumSet.
Change-Id: I5ee35d9d66072a3838113e5686b40b5f7bc1dd02
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/386605
Reviewed-by: Nate Biggs <natebiggs@google.com>
Commit-Queue: Mayank Patke <fishythefish@google.com>
2024-09-24 22:21:38 +00:00
Nate Biggs 755db057ff [dart2js] Fix record FieldGet receiver type update.
We should be updating the receiver record's type regardless of whether or not we have a specific record type.

Bug: https://github.com/dart-lang/sdk/issues/56741
Change-Id: I16ce9f1db96c295566be802211c7280917416924
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/386262
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
2024-09-23 19:48:07 +00:00
Nate Biggs 1d392255ef [dart2wasm] Add wasm module test mode.
Adds a mode that puts every library (outside of the SDK) into its own wasm module. Each module is then loaded before the program executes.

This allows us to get better coverage on multi-module logic.

I chose to augment the SDK `_invokeMain` entry point because it allows us to push the user-defined main into a second module ensuring we always have at least 2 modules. The SDK alone is then the main module and all user-code is in deferred modules.

The next step is to make a test configuration for this and decide what frequency to execute it with.

Change-Id: I01bf3a5fee4604a890ef376ebd35113281a36a5c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/384404
Commit-Queue: Nate Biggs <natebiggs@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2024-09-23 18:56:24 +00:00
Nate Biggs e06d0f3c40 [dart2js] Update DartFormatter invocations to pass language version.
Bug: https://github.com/dart-lang/sdk/issues/56686
Change-Id: I3f578d29e125426c02eac564ca6baff9fb7d8919
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/384402
Reviewed-by: Bob Nystrom <rnystrom@google.com>
Auto-Submit: Nate Biggs <natebiggs@google.com>
Commit-Queue: Bob Nystrom <rnystrom@google.com>
2024-09-10 18:38:28 +00:00
Nate Biggs b28913c7e1 [dart2js] Make 'load-priority' pragma pass an arbitrary option string.
Change-Id: I4d9fb69dfb4ec040b0e63893e4ace33c6a5dd454
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/384360
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
2024-09-09 19:47:48 +00:00
Mayank Patke 0aee974736 [dart2js] Document/assert that enumset indices must be less than 64
Change-Id: I8b4b1c296fe11044e69221c020a7b1b3abbd9275
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/384042
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Auto-Submit: Mayank Patke <fishythefish@google.com>
Commit-Queue: Sigmund Cherem <sigmund@google.com>
2024-09-06 20:14:59 +00:00
Mayank Patke 7c03127388 [dart2js] Add package:meta to dependencies
Change-Id: Ib976d76c43c0bf2742929e3e432ab7995b5774c7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/383924
Commit-Queue: Mayank Patke <fishythefish@google.com>
Reviewed-by: Mark Zhou <markzipan@google.com>
2024-09-06 17:25:51 +00:00
Mayank Patke 1031795c61 [dart2js] Convert static use flags to enum.
Change-Id: I137c9cbd865fb9944d4d326f5d73f9f09a6e2505
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/383900
Reviewed-by: Nate Biggs <natebiggs@google.com>
Commit-Queue: Mayank Patke <fishythefish@google.com>
2024-09-06 16:20:37 +00:00
Mayank Patke 15366a10b7 [dart2js] Convert EnumSet to an extension type.
Because the old EnumSet was a wrapper object, some APIs performed
stateful updates. This CL also ensures that callers are now performing
their own state updates, just as if we were manipulating ints directly.

Change-Id: I305cd42b5e0c9395d1d1dac724a108bf083ab0d4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/379510
Reviewed-by: Nate Biggs <natebiggs@google.com>
2024-09-06 16:20:37 +00:00
Stephen Adams 2afecb210b [dart2js] Register legacy classes if instantiated in JS()
This change makes sure that

    JS('JavaScriptFunction', '...', ...)

actually registers `JavaScriptFunction` and its superclass `LegacyJavaScriptObject` as instantiated.

Bug: #56533
Change-Id: I977f149cff97b0a5f42d69f303664f5a70cb401c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/381820
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2024-08-22 19:44:08 +00:00
Paul Berry 24a4bf31f9 Remove unreachable default clauses from world_test.dart.
I'm currently working on a fix to the analyzer that will cause
unreachable default clauses to be properly flagged as a warning
(https://github.com/dart-lang/sdk/issues/54575). To avoid a bot
failure when the fix lands, these unreachable default clauses need to
be removed.

Bug: https://github.com/dart-lang/sdk/issues/54575
Change-Id: I35cc2be79d918a8f6ee7b388cf97044f0196b932
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/380961
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Nate Biggs <natebiggs@google.com>
Auto-Submit: Paul Berry <paulberry@google.com>
2024-08-16 16:45:59 +00:00
Stephen Adams 9162f0f9c9 Reapply "[dart2js] Make more use of kernel's static type"
This reverts commit f9aec1c997.

Change-Id: I731b29714797fbea38da09ed48a0dd4852af986b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/379669
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2024-08-15 18:58:55 +00:00
Stephen Adams f9aec1c997 Revert "[dart2js] Make more use of kernel's static type"
This reverts commit 1057e5575f.

Reason for revert: Breakage in product test

Original change's description:
> [dart2js] Make more use of kernel's static type
>
> This change helps with one hang-over from Dart 1.
>
> In code like `a[i] == 1`, the type of the indexed element was inferred
> as the element type of `a`. This was great if `a` was a traced List,
> but too general if the provenance of `a` is unknown, since the general
> element type over all lists is 'top'.
>
> Dart 3 gives much better guarantees than Dart 1. We can now rely on
> the front-end inferred type for `a[i]`. To do so, we track the
> abstract value contraint for the type through SSA so that SSA-level
> type propagation can re-apply the constraint.
>
> This removes about 100 interceptor calls from the main unit of some
> large ACX apps.
>
> Change-Id: I6839a6045d9341633c08678affb35fdb2998a96d
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/379145
> Reviewed-by: Mayank Patke <fishythefish@google.com>
> Commit-Queue: Stephen Adams <sra@google.com>

Change-Id: I5e2b9fde9ffd7d79332fd493649e8f342219c8ea
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/379667
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2024-08-08 22:14:38 +00:00
Stephen Adams 1057e5575f [dart2js] Make more use of kernel's static type
This change helps with one hang-over from Dart 1.

In code like `a[i] == 1`, the type of the indexed element was inferred
as the element type of `a`. This was great if `a` was a traced List,
but too general if the provenance of `a` is unknown, since the general
element type over all lists is 'top'.

Dart 3 gives much better guarantees than Dart 1. We can now rely on
the front-end inferred type for `a[i]`. To do so, we track the
abstract value contraint for the type through SSA so that SSA-level
type propagation can re-apply the constraint.

This removes about 100 interceptor calls from the main unit of some
large ACX apps.

Change-Id: I6839a6045d9341633c08678affb35fdb2998a96d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/379145
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2024-08-08 00:30:48 +00:00
Stephen Adams e28c480e12 [dart2js] Use addUnused method for unused fields in proto shaker
The call to the new method has fewer arguments, which helps code size.

Change-Id: I50668e54bfba07ac34e8db99a748f7d83c6e5be4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/378382
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2024-08-06 21:58:29 +00:00
Mayank Patke ab8e382d26 [dart2js] Add source information to interop null checks
Change-Id: Ib81199030680160e215321f9460d7bac24489763
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/378903
Commit-Queue: Mayank Patke <fishythefish@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2024-08-06 20:52:19 +00:00
Srujan Gaddam ae3dbcdfb1 [dart:js_interop] Add toJSCaptureThis
Closes https://github.com/dart-lang/sdk/issues/54381

- Adds an API to capture the this value so that users
can use it in the callback.
- Adds specialized stubs to dart2js similar to what was
done for toJS.
- Adds generic stub to DDC as these stubs don't get
tree-shaken away and toJSCaptureThis is less likely to be
used.
- Modifies dart2wasm lowerings to add this to the JS
function wrapper if calling toJSCaptureThis.

Change-Id: Ic0a7fd768de1dd6b491998e029ff5eb406ee7992
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/377160
Reviewed-by: Stephen Adams <sra@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Leaf Petersen <leafp@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2024-08-01 01:02:47 +00:00
Stephen Adams 175dc05db3 [dart2js, pkg/vm] Recognize more BuilderInfo methods.
An upcomming change to protobufs adds a few more BuilderInfo methods
that 'define' fields.

TEST=existing

Change-Id: I78be355ea1458a6a0f2619c63e3ff5838b527533
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/377742
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Nate Biggs <natebiggs@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2024-07-29 20:54:38 +00:00
Nate Biggs 629d170962 [dart2js] Fix inference tracing closures through non-method members named 'call'.
Change-Id: I8619343f9d5ff1e64ecc84c549eda400bbce31dc
Fixes: https://github.com/dart-lang/sdk/issues/56293
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/376880
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
2024-07-22 17:48:50 +00:00
Mayank Patke 37e351db10 [dart2js] Don't overwrite type in _invokeJsInteropFunction.
Discarding the nullability caused us to assume that interop checks were
always needed below.

Bug: b/353690007
Fixes: b/353690007
Change-Id: I085f98c06d2e91412c5c6e795359eb2df4d84d5b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/376124
Reviewed-by: Nate Biggs <natebiggs@google.com>
Commit-Queue: Mayank Patke <fishythefish@google.com>
2024-07-17 21:53:48 +00:00
Stephen Adams 15792df87e [dart2js] Use indexes for operation names and verbs
Change-Id: Ic954a7e20062aa8bf1c0f622ee9b0656bc563ba5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/375024
Commit-Queue: Stephen Adams <sra@google.com>
Reviewed-by: Mayank Patke <fishythefish@google.com>
2024-07-15 02:18:52 +00:00
Nate Biggs ae34c07b94 [ddc] Move async_status_codes to shared sdk library.
This will allow DDC and dart2js to share these values for their async systems.

Change-Id: If6eef5de535cdf55e10adca3b2de11c408df4070
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/374520
Reviewed-by: Mark Zhou <markzipan@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
2024-07-12 16:05:19 +00:00
Mayank Patke 62b17a59f4 [dart2js] interop null checks: ensure member return type is non-nullable
before adding check in caller

This wasn't needed when the required null checks were keyed on member
entities. Since we now use selectors as keys instead, it's possible for
a selector to be marked as requiring caller-side checks even though not
every associated member requires one.

Change-Id: Ibe4be750e4d3dd02f97e8d27efa29a1c7904e2bd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/375420
Reviewed-by: Nate Biggs <natebiggs@google.com>
Commit-Queue: Mayank Patke <fishythefish@google.com>
2024-07-11 20:38:24 +00:00
Stephen Adams e66a0cbde8 [dart2js] Unmodifiable Array and typed data using flags
- Add SSA HArrayFlags{Check,Get,Set} instructions to check for
  fixed-length and unmodifiable JSArray and JavaScript typed data
  instances.

- Add optimizations to remove redundant checks.

- Added HOutputConstrained interface for instructions that must have
  the input and output in the same JavaScript variable. This
  generalizes some code generation logic already applied to HCheck.

Bug: #53785
Change-Id: I61750dd03aa3a964eed3bc76e1656c5f60f77109
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/372002
Commit-Queue: Stephen Adams <sra@google.com>
Reviewed-by: Mayank Patke <fishythefish@google.com>
2024-07-10 01:39:58 +00:00
Stephen Adams bd290e8d87 [dart2js] Use representation type of record if available
Change-Id: I48f5d8d3f020e6f9d2b69eea1ad9f1e991a66f6d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/372861
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2024-07-09 23:30:49 +00:00
Sam Rawlins 5e8ee77772 Support digit separators
Work towards https://github.com/dart-lang/language/issues/2

The feature is well-specified at the issue, but I will also follow
up with a specification to check into the language repo.

This change implements the feature more-or-less from front to back
(because the back is very close to the front in this case :P; no
"backend" work in the VM, etc). Digit separators are made available
via a new experiment, `digit-separators`.

Care is taken to report a single error when an underscore appears in
an unexpected position (see new `separators_error_test.dart`).

Three test files are added:

* `separators_test.dart` is run with the experiment enabled, and has
  no compile-time errors.
* `separators_error_test.dart` is run with the experiment enabled, and
  has many compile-time errors.
* `separators_error_no_experiment_test.dart` is run with the
  experiment _disabled_.

Change-Id: I7f1b1305d28b708b5ddf83f26188cd6e9ce3dd58
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/365181
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
Reviewed-by: Kevin Moore <kevmoo@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2024-07-09 14:50:59 +00:00
Johnni Winther c17e9c116e [cfe] Clean up backend imports
This updates backend imports to use reexports from api_prototype
or api_unstable.

TEST=existing

Change-Id: I8d9d1c76ef72c709c578acac5497064710ee5579
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/373462
Reviewed-by: Jens Johansen <jensj@google.com>
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Ömer Ağacan <omersa@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2024-07-08 11:32:30 +00:00
Mayank Patke b64c64012f [dart2js] Remove asserts in ConstConditionalSimplifier
Fixes: b/349652368
Change-Id: I0d5cad6a55cba6b31d8a352d278daf844db95efb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/373328
Reviewed-by: Nate Biggs <natebiggs@google.com>
Commit-Queue: Mayank Patke <fishythefish@google.com>
2024-06-27 19:12:02 +00:00
Johnni Winther 543bc03de8 [cfe] Move /fasta/ content into /base/
These files should be further reorganized but that is for a
future CL.

Part of removing uses of 'fasta'.

Change-Id: I5010789b5901ba51c58d98fe26f13177b13c81b3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/373080
Reviewed-by: Jens Johansen <jensj@google.com>
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2024-06-27 07:54:23 +00:00
Johnni Winther 8df57398c9 [cfe] Move src/fasta/ subfolders to src/
Part of removing uses of 'fasta'.

TEST=existing

Change-Id: Ice027678e11b7da8c1a7e756a1e1c8c8284722bf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/372623
Reviewed-by: Jens Johansen <jensj@google.com>
Reviewed-by: Mayank Patke <fishythefish@google.com>
Reviewed-by: Ömer Ağacan <omersa@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2024-06-25 10:05:21 +00:00
Mayank Patke 56851e50e2 [dart2js] Restrict instanceof is-test specializations to non-generic
types when SNS checks are enabled.

Change-Id: I759a4ba77b74f6e0ec7c7ec65ad3ca37ed8410a9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/372201
Commit-Queue: Mayank Patke <fishythefish@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
2024-06-24 20:52:43 +00:00
Stephen Adams 0db3b1215c [dart2js] Use patterns for HIndex simplifications
Change-Id: I8a1e888da1d976ae80effc220a41243ff85ee4f6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/372001
Commit-Queue: Stephen Adams <sra@google.com>
Reviewed-by: Mayank Patke <fishythefish@google.com>
2024-06-18 23:19:28 +00:00
Mayank Patke d430e7ab55 [dart2js] Remove memberContext from getConstantValue.
Change-Id: I3ed4343c7cd2880414a8e99361d8017ca9f756a8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/372160
Commit-Queue: Mayank Patke <fishythefish@google.com>
Reviewed-by: Nate Biggs <natebiggs@google.com>
2024-06-18 18:31:58 +00:00
Stephen Adams 3a91bcb39e [dart2js] SSA - pre-assign variable to reduce phi assignments
Introducing a partial redundancy with a variable with a longer
live-range can reduce the size of the emitted code.

Flute.complex (-O4): -0.377%
cm_shell (-O4): -0.029%

Change-Id: I0d03119b17f4b58d61f277bf8bb0e57d8e7c47c5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/360360
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2024-06-17 22:47:57 +00:00
Stephen Adams 77496338dc [dart2js] Constant-fold const record accesses
I noticed that dart2js generated poor code for `(a, b) = (1, 2)`.
This is due to an oversight in not constant-folding record field loads.

Change-Id: Iac110d8c3373d7673c21494fc467f7fcb400de1d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/371505
Commit-Queue: Stephen Adams <sra@google.com>
Reviewed-by: Mayank Patke <fishythefish@google.com>
2024-06-17 19:47:34 +00:00
Nate Biggs b9b4d616a4 [dart2js] Fix record field get receiver type serialization.
Internal users reported a compiler crash when using sequential compilation. Their change involved adding a class hierarchy in which the constructor of a superclass included a RecordIndexGet. When analyzing the constructor of the subclass we also analyze the body of the super constructors.

In this rare case the member being analyzed does not match the member containing the receiver node. Usually calls act as a layer of indirection that we do not analyze across.

When we then save the type of the receiver, we do so in the context of the wrong member (the subclass constructor rather than the superclass constructor). We just have to be more careful to use the correct context member.

The added test fails prior to this change.

Change-Id: I8b9a3b8a7692b8604d5c37c59b94bb8d46afff75
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/371580
Commit-Queue: Nate Biggs <natebiggs@google.com>
Reviewed-by: Mayank Patke <fishythefish@google.com>
2024-06-14 19:17:14 +00:00
Mayank Patke bf83cc30ed [dart2js] Convert VariableUse to a sealed class hierarchy.
Change-Id: I28d71d81031e3e6eefc2b4f6decfe375099a1c32
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/371185
Reviewed-by: Stephen Adams <sra@google.com>
Commit-Queue: Mayank Patke <fishythefish@google.com>
2024-06-13 23:01:34 +00:00
Mayank Patke 0ddba91190 [dart2js] Convert SubclassResult to a sealed class hierarchy.
Change-Id: I151c2f6f72dcecaff6a6976f058940b9ddf97f47
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/371461
Reviewed-by: Nate Biggs <natebiggs@google.com>
Commit-Queue: Mayank Patke <fishythefish@google.com>
2024-06-13 19:25:28 +00:00
Mayank Patke ad3a1a72fd [dart2js] Convert IsTestSpecialization to sealed class hierarchy.
Change-Id: I08552d4dda928259be56e0b99f9f002baeb4d6b2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/371240
Commit-Queue: Mayank Patke <fishythefish@google.com>
Reviewed-by: Nate Biggs <natebiggs@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
2024-06-13 18:21:59 +00:00