Commit Graph

11 Commits

Author SHA1 Message Date
Johnni Winther 01dddf659e [_fe_analyzer_shared] Shared literal parsing
This adds shared helpers for parsing bool, int, and double literals to
their corresponding values.

The macro metadata literals are updated support digit separators and
to hold the literal value.

Change-Id: I709018b6c3a3b8ab09188d36c28f3c09636e0ea0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/391964
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2024-10-28 09:03:45 +00:00
Jens Johansen 8c5dce6994 [parser] Replace optional/optional2/isOneOf/isOneOfOrEof with extension method calls
The entire scanner/parser now no longer uses `optional` or `optional2`,
the latter being completely removed.

Furthermore, when compiling a fixed version of the CFE with the CFE
this CL reduces the instructions used by ~13.6 mio.

```
page-faults:u: -0.3695% +/- 0.0676% (-384.20 +/- 70.23)
instructions:u: -0.0645% +/- 0.0007% (-13671097.80 +/- 153289.78)
```

Change-Id: Ib93dd2983aa1b4df0610d099010ac10f55f357f8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/388323
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2024-10-09 12:11:50 +00:00
Jens Johansen dfb414a0ec [parser] Replace optional for some calls
This CL replaces the `optional` call in some places (more will likely
follow in follow-up-CLs) with the (badly named) `optional2` which is
both better typed (doesn't use strings) and is faster.

In this CL I've replaced the most used calls (when using the CFE to
compile itself), saving ~100 mio instructions.

Sometimes statistics just says the ~100 mio instructions saved, other
times I get statistics like this:

```
msec task-clock:u: -0.6861% +/- 0.2300% (-28.64 +/- 9.60)
page-faults:u: 0.1113% +/- 0.0114% (116.33 +/- 11.97)
cycles:u: -0.7966% +/- 0.2280% (-137543215.11 +/- 39365289.96)
instructions:u: -0.4655% +/- 0.0003% (-100120984.16 +/- 56848.83)
branch-misses:u: -3.5671% +/- 0.8585% (-2249707.82 +/- 541442.75)
seconds time elapsed: -0.6788% +/- 0.2307% (-0.03 +/- 0.01)
seconds user: -0.8448% +/- 0.2950% (-0.03 +/- 0.01)
```

```
msec task-clock:u: -0.4102% +/- 0.2224% (-17.29 +/- 9.37)
page-faults:u: 0.1194% +/- 0.0130% (124.99 +/- 13.61)
cycles:u: -0.4368% +/- 0.2296% (-75891577.97 +/- 39893793.33)
instructions:u: -0.4658% +/- 0.0003% (-100182606.12 +/- 62071.96)
branch-misses:u: -1.5890% +/- 0.9771% (-1012729.95 +/- 622739.88)
seconds time elapsed: -0.4072% +/- 0.2224% (-0.02 +/- 0.01)
seconds user: -0.4771% +/- 0.3049% (-0.02 +/- 0.01)
```

```
msec task-clock:u: -0.4542% +/- 0.2160% (-19.18 +/- 9.12)
page-faults:u: 0.1219% +/- 0.0115% (127.61 +/- 12.03)
cycles:u: -0.4774% +/- 0.2225% (-83126015.12 +/- 38752062.54)
instructions:u: -0.4658% +/- 0.0003% (-100174778.84 +/- 61310.55)
branch-misses:u: -1.9576% +/- 0.9711% (-1253736.65 +/- 621904.22)
seconds time elapsed: -0.4471% +/- 0.2160% (-0.02 +/- 0.01)
seconds user: -0.4976% +/- 0.2645% (-0.02 +/- 0.01)
```

These are statistics on 100 runs (each) of the CFE compiling itself when
run as an AOT compile with `--deterministic`. It seems likely that it
saves something like 0.4% in both instructions, cycles and actual
runtime.

Change-Id: I12763c23b1ec33357a31aaf47ed93ca16264c0f7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/385160
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2024-09-17 07:00:41 +00:00
Alexander Thomas 9394b30b77 Fix incorrect file reference in license headers
Bug: b/286184681
Change-Id: I903528c4adfbc576644aec7541903df6b9633e26
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/325523
Reviewed-by: Jonas Termansen <sortie@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Alexander Thomas <athom@google.com>
2023-09-18 06:44:08 +00:00
Johnni Winther b1594fa130 [parser] Handle invalid extension type header in error recovery
This expands the existing recovery for class headers to handle
invalid, out-of-order, and duplicate clauses in extension type
declaration headers.

Change-Id: I7b33b91cc718e4c0673137121b8d083fa0ef1562
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/321900
Reviewed-by: Jens Johansen <jensj@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2023-08-24 11:20:18 +00:00
Johnni Winther d89ae3c2c6 [parser] Report error on invalid const patterns
This handles the restriction imposed on the expression occurring
within a constant pattern.

Change-Id: I946d85f908609340a61e060c6bdbee143666fd91
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/280460
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2023-02-09 12:43:31 +00:00
Konstantin Shcheglov d4c443cfb7 Enable annotate_overrides lint in _fe_analyzer_shared/
Change-Id: Ic8e34af296368e8159fa75887ed54cbb4b550648
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/270226
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2022-11-17 15:13:39 +00:00
Lasse R.H. Nielsen 8a883fa54d Change : to = for default values in pkg.
Leaves some in parser test:
 pkg/front_end/parser_testcases/error_recovery/keyword_named_formal_parameter_prime.dart

TEST=Refactoring, covered by existing tests.

Change-Id: I7a83ef95df3cbd283878b3685b5c747bd89a1b16
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/256125
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
2022-08-24 15:57:16 +00:00
Johnni Winther ce4e7705f2 [cfe] Handle explicit instantiation in implicit creation syntax
Closes #46719
Closes #46887

Change-Id: I4ad0f1bb4ab847a44f749113c6446f62a474143c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/211260
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2021-08-26 11:59:48 +00:00
Johnni Winther 2a5c85e7cf [parser] Add useImplicitCreationExpression
This flag prepares for the removal of the special case of implicit
creation syntax, `foo<bar>.baz()`, which with constructor-tearoffs
doesn't have to be a creation expression. Since both the analyzer
and the CFE needs to support parsering without special casing
before it can be removed, the flag is added to ensure both
implementations will agree on what the future parser behavior will be.

The CL hard-wires the CFE use of the parser to a single constant value.

Change-Id: I04724f039d2e698f3cf67e8b0b56dfa7e96ed3b4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/211000
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2021-08-25 11:44:53 +00:00
Johnni Winther 00c2962db8 [cfe+analyzer] Move messages, scanner and parser to package:_fe_analyzer_shared
Change-Id: I4fa87aee65f30a9868a6cf8f0342591869ece7ea
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/123663
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2019-11-01 09:37:57 +00:00