Commit Graph

8 Commits

Author SHA1 Message Date
Jens Johansen bce3dd4fe7 [CFE/shared] Make formatting more consistent by specifying DartFormatter.latestShortStyleLanguageVersion
Autogenerated files was formatted with the new style, so if one for
instance formatted the file via the IDE or by saying
`out/ReleaseX64/dart-sdk/bin/dart format pkg/front_end/lib/` we'd get
*a lot* of changes which isn't great.
This CL sets the formatter version for the auto-generated files,
hopefully avoiding such things.

Change-Id: I4f92aafde7c77e7c78179f78bf821979a25ec12c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/398884
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2024-12-05 08:50:30 +00:00
Robert Nystrom 8a9fb7ca07 Pass in a language version when calling the formatter.
There is an upcoming version of dart_style that makes this argument
required, so every DartFormatter() constructor callsite needs to pass
it in. These are the last two I could find in the Dart SDK.

I'm not familiar with the surrounding code, but I believe passing in
DartFormatter.latestLanguage version will do the right thing:

* For the benchmark script, that's generated code that we will always
  want to be valid on the latest version of Dart.

* For the text_outline_suite, my understanding is that CFE tests that
  require older language versions always use the "// @dart=x.y" comment
  to opt in to that version. Those comments are also respected by the
  formatter and override the languageVersion argument passed to the
  constructor. So I think passing in latestSupportedVersion will do the
  right thing.

Bug: https://github.com/dart-lang/sdk/issues/56687

Change-Id: If29188df479c7b41beb68ac889d56be13a395a16
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/389622
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Auto-Submit: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2024-10-11 07:43:30 +00:00
Robert Nystrom 13323eeac6 Migrate internal CFE tools to the new DartFormatter API.
As far as I can tell, these scripts are all only used internally for
formatting generated code, so it should be safe to just parse the code
at the latest language version.

I didn't migrate:

  pkg/front_end/test/fasta/textual_outline_suite.dart

I believe that one may need to pass in a specific language version if it
needs to support formatting code from before Dart 3.0. (In particular
if it needs to handle code using old switch constant expressions that
are not supported in Dart 3.0 and later like `case 1 + 2:`.)

Bug: https://github.com/dart-lang/sdk/issues/56687
Change-Id: Ib5cef82c22fc749223095215d3b692e6c27decc7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/385341
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Bob Nystrom <rnystrom@google.com>
Auto-Submit: Bob Nystrom <rnystrom@google.com>
2024-09-17 10:59:41 +00:00
Johnni Winther 058e810da1 [cfe] Update datatypes benchmark with patterns strategy
This updates the datatypes benchmark to include a strategy that
uses pattern matching. This show that pattern matching is
comparable to if-then-else and should be used.

Change-Id: Icaf7644e5817767959c639ce655be7d4012ea5d2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/377980
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2024-07-31 07:38:32 +00:00
Johnni Winther b48d4f224f [cfe] Cleanup imports
Change-Id: I60891b46119d6451810adf2846a05a66050bacd0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/373246
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2024-06-27 08:54:39 +00:00
Jens Johansen 16289b490d [CFE] Benchmarks for list copy, mapping etc.
On my computer:

1) If creating a Set from a list mapping simply adding
   each entry to the set seems faster.
2) When mapping a list to a new list using `List.generate`
  seems to be the fastest. Prefer `growable: false` if not
  needing it to be growable.
3) When creating a new list `.of` seems faster than `.from`.

Change-Id: I7f3d66100246e170cf09431dddf64b3ec39579f5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/228643
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2022-01-24 14:40:26 +00:00
Jens Johansen 497eda096a [CFE] Add benchmark for list generation via alternative methods
Change-Id: I6f2f9a02252a27e4c87b41d95ed292ccc9ec0779
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/228203
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2022-01-17 09:14:24 +00:00
Johnni Winther ba98ca1be1 [cfe] Add measurement for patterns
This CL adds an initial framework for testing performance of programming
patterns. Included is a test of the pattern used to choose
implementation based on a runtime type, using either an if-then-else
sequence, dynamic dispatch on the runtime object, or visitor pattern.

The test framework runs the patterns on a range of inputs using a
predefined set of scenarios and outputs a table of the measurements which
can be copied into Google Sheets to visualize the results.

Further work is to use statistics to quantify the results, and expand
the framework to be used to detect asymptotic performance of algorithms
used in the compiler itself.

Change-Id: Ic99588d13adead309715957e1bc0aa6def46c9dc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/226104
Reviewed-by: Jens Johansen <jensj@google.com>
2022-01-06 15:15:58 +00:00