This reduces e main module size by ~ 0.5-1%
When compiling with deferred loading, we optimize each module
individually with open world assumptions.
Currently we run only one -Os pass which leaves code behind that can be
optimized by another -Os. See e.g. discussion at [0].
The additional -Os pass is much faster than the first, so it doesn't add
meaningful compile-time.
[0] https://github.com/WebAssembly/binaryen/issues/8077
Change-Id: Id8c5e49d97439e28b2f7d9c5a0c206eec0893cad
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/490101
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
This adds an expectation test for having the same deferred prefix in two sibling parts. This verifies that the AST encoding correctly disambiguates the prefixes.
Part of #56193
Change-Id: I5b5039989851738acf72343f3cf4742a521dfb93
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/490080
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Prior to this change, the VM service isolate was configured to execute
`main` directly. This resulted in unexpected behavior around exceptions
thrown after the first asynchronous gap, which were unhandled but caused
the service isolate to exit silently with no error.
This change updates how the service isolate starts execution by
invoking `main` via `dart:isolate`'s `_runMainIsolate` method, similar
to how user isolates and the DartDev isolate start execution. This
results in the message handler being triggered, meaning the microtask
queue will be processed correctly and unhandled exceptions in
asynchronous contexts being reported.
TEST=Local testing with exceptions explicitly thrown from within the VM
service
Change-Id: I69475a86d923489fa216bc8e939a2726cf3ff2e8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/490220
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
The `getOptions` and `getOptionsFile` were unused except in the tests
which tested them. These are removed.
`merge` is unused outside the library except for its test, so it is
made `@visibleForTesting`.
Change-Id: Id2e45dca7aa4f744fc84627d8e2a097d3ef98b10
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/490040
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
This CL changes the analyzer such that it forces formal parameters
to have the same properties during NNBD_TOP_MERGE (`topMerge`).
The implementation prior to this CL considered two optional positional
parameters to yield a required positional parameter in the merged
result, and it allowed merging a required named parameter and a
non-required named parameter. This implies that certain mergings
that used to succeed will now fail, but this is not a breaking change
in practice because the common front end already uses the more strict
checks that this CL introduces in the analyzer.
Change-Id: I9121db3754e422f5fab143f9990e58e210ed951e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/490120
Commit-Queue: Erik Ernst <eernst@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Initializers are created for outlines for const constructors and for constructors with super initializing formals. This led the addSuperParameterDefaultValueCloners method to process the initializers even when the constructor has no super initializing formals; crashing in the case of const redirecting generative constructors. The addSuperParameterDefaultValueCloners method now stops early if the constructor has no super initializing formals.
Change-Id: I2d640b20ac3fb281705b61362157e1fd09eed3f8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/490081
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Target process and the recorder might be running in different working
directories so request to start recording should always use absolute
path.
This also cleans up how file recorders are created: it does not make
sense to create the recorder and the check if we can open the file
(in fact: creating recorder and failing to open file will cause
deadlocks). Thus this CL changes the code to first open the file
and only if we succeeded creates the recorder.
Fixes https://github.com/dart-lang/sdk/issues/62959
TEST=extended existing tests to cover this
Change-Id: Ib9d88ce23d93bcc5d6335ba1daebad2e6a6a6964
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/490160
Commit-Queue: Slava Egorov <vegorov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
When analyzing the CFE with StableAnalysis in AOT with GC disabled:
* This CL reduces the combined cost of `popTypedList2` from ~501 million
instructions to ~150 million instructions according to
`valgrind --tool=callgrind`.
* Total savings, via `valgrind --tool=callgrind`, is reported as
~359 million instructions.
* Total savings, via `perf stat`, is reported as
~367 million instructions (see also below).
A benchmark run with 5 runs each gives this (but note that the normal gc
runs should mostly be ignored):
With normal GC:
```
page-faults:u: 2.5544% +/- 0.0884% (4895.60 +/- 169.43) (191651.60 -> 196547.20)
instructions:u: -1.7106% +/- 0.0039% (-990609348.00 +/- 2286578.79) (57909229892.40 -> 56918620544.40)
branch-misses:u: -4.0211% +/- 2.2322% (-7537436.00 +/- 4184151.25) (187447442.80 -> 179910006.80)
maxRssKbytes: -1.1530% +/- 0.0148% (-7169.60 +/- 91.81) (621801.60 -> 614632.00)
maxRssBytes: -1.1530% +/- 0.0148% (-7341670.40 +/- 94008.95) (636724838.40 -> 629383168.00)
Comparing GC data:
Scavenge( new space) goes from 171 to 169
MarkSweep( promotion) goes from 17 to 16
MarkSweep( old space) goes from 0 to 1
Notice combined GC time goes from 3636 ms to 3507 ms (notice only 1 run each).
```
```
With GC disabled:
page-faults:u: -1.7322% +/- 0.0001% (-21490.20 +/- 1.49) (1240629.60 -> 1219139.40)
instructions:u: -0.9185% +/- 0.0021% (-367119249.20 +/- 829664.80) (39970048410.80 -> 39602929161.60)
maxRssKbytes: -1.7226% +/- 0.0012% (-85733.60 +/- 60.60) (4977076.00 -> 4891342.40)
maxRssBytes: -1.7226% +/- 0.0012% (-87791206.40 +/- 62052.71) (5096525824.00 -> 5008734617.60)
```
Change-Id: I85eae091cc45d5fb2820fbd263d022619c9875f6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/490122
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
Guard the regex call by the comment containing `@`.
This makes `LanguageVersionOverrideVerifier.verify` goes from costing
~122 million instructions to costing ~81 million instructions saving
~41 million instructions.
Change-Id: Ib7068624bf7570873180fc1be33db0a3e53a0fca
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/489962
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
The function mostly returned null/nonsense if given a null argument,
and the few call sites with nullable arguments (in tests and tools)
are easily tweaked.
Change-Id: I7f9993696c4bd822b648a5a89114e6af25eac552
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/490020
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Tests for the spec change in https://github.com/dart-lang/language/pull/4655.
- An identifier expression denoting a parameter of a constant primary
constructor that occurs in the initializer list of the body part of the
primary constructor, or in an initializing expression of a non-late
instance variable declaration, is potentially constant.
- A compile-time error occurs if a class, mixin class, enum, or
extension type declaration has a constant generative constructor, and a
non-late instance variable declaration in the body of the declaration
has an initializing expression which is not potentially constant.
- A compile-time error also occurs if the body of a declaration contains
a body part for the primary constructor, and it has an initializer list,
and the initializer list contains an expression which is not potentially
constant.
- A compile-time error occurs if the result of substituting actual
arguments of the constructor invocation into one of the above mentioned
initializing expressions or initializer list elements yields an
expression which is not constant.
Bug: https://github.com/dart-lang/sdk/issues/61687
Change-Id: I8f9d5d49ab48f6cd07ad005b9483e21ef190f324
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/489543
Commit-Queue: Kallen Tu <kallentu@google.com>
Reviewed-by: Erik Ernst <eernst@google.com>
Otherwise folks on ~latest bits from Flutter can't run pub!
Resolving dependencies in `/Users/kevmoo/github/dart/sdk`...
The current Dart SDK version is 3.12.0-261.0.dev.
Because dart_runtime_service_vm requires SDK version ^3.12.0-edge, version solving failed.
Change-Id: I76af81c9f6d9360a347300a1b8bac479ee45c631
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/489640
Auto-Submit: Kevin Moore <kevmoo@google.com>
Commit-Queue: Kevin Moore <kevmoo@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
Moves the bulk of the business logic for type analyzing await
expressions from the analyzer and front_end codebases into the shared
`TypeAnalyzer` class. There is no functional change.
This paves the way for fixing
https://github.com/dart-lang/sdk/issues/62889 (Unsound type promotion
in inner async/generator functions), which will require the type
analysis of await expressions to be integrated more closely with flow
analysis. Sharing the type analysis logic will avoid the need to do
that integration twice.
Change-Id: I9f8770ce8127a960b746a89ee3e370ed6a6a6964
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/489480
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
In the front end, the logic for determining when to report a
`voidExpression` error is integrated into the resolution pass. The
method `InferenceVisitorImpl.inferExpression` accepts a named
parameter `isVoidAllowed`; if the value is `false`, and the
expression's static type is `void`, an error will be reported. The
parameter is optional with a default value of `false`; this means that
the parameter only needs to be specified in the situations where
`void` is allowed; this aligns well with the language spec, which
lists the situations in which an expression may have type `void`, and
declares that in all other situations it is an error.
This change integrates the front end's `isVoidAllowed` boolean with
the shared type analysis logic in `package:_fe_analyzer_shared`, so
that the shared logic can specify when a subexpression should not be
void. This will pave the way for fixing
https://github.com/dart-lang/sdk/issues/62939 (Switch scrutinees of
type void are erroneously accepted by the front end). It also will
pave the way for sharing the logic for analyzing await expressions,
which will make it easier to fix
https://github.com/dart-lang/sdk/issues/62889 (Unsound type promotion
in inner async/generator functions).
Note that the analyzer doesn't use the `isVoidAllowed` parameter; it
has its own mechanism for detecting invalid uses of void (which is
more ad hoc). In the long run I would like to make the analyzer's
mechanism more like the front end's, for easier code sharing; see
https://github.com/dart-lang/sdk/issues/62942.
Change-Id: Ibb8dd072d6aff980d7df0b2e94f434ee6a6a6964
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/489501
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Adds the unit test method
`ProtoExpression.checkExpressionTypeAnalysisResult`, which allows unit
tests of the shared analysis logic to access the object returned by
`TypeAnalyzer.dispatchExpression`.
This replaces ad-hoc logic that was used to test
`IntTypeAnalysisResult.convertedToDouble`, and allows testing of
`PatternAssignmentAnalysisResult.patternSchema` (which was previously
not covered by unit tests).
It also paves the way for shared analysis code I intend to introduce
for await expressions, as part of fixing
https://github.com/dart-lang/sdk/issues/62889.
(In principle, this mechanism could also be used to test the fields in
`SwitchExpressionResult`, but I believe I can refactor the code in
such a way that that class is no longer necessary, so I will try doing
that in a follow-up CL. If that doesn't work out, I'll add tests of
`SwitchExpressionResult` in a follow-up CL.)
Change-Id: I571c55f708b03e67ab491994675e53e16a6a6964
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/489460
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
This CL adjusts the predicate `_isFormalParameter` in the constant
evaluator, so that it includes variables from the new
model. Additionally, `IntenralPositionalParameters` and
`InternalNamedParameters` that were emitted as parts of function
declarations are replaced with their corresponding `astVariable`s in
the output.
The CL allows to unskip the last test in the bytecode generator when
the new variable model is enabled.
Part of https://github.com/dart-lang/sdk/issues/61572
Change-Id: Ibb8df47bf53f7f31aab58f8d5d104192edc83718
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/489380
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
The Flutter Widget Preview feature is currently implemented within
Flutter Tools, which is responsible for detecting widget preview
annotations in the user's project. When previews are detected, the
Flutter Tool injects code generated based on the detected previews into an artificial widget_preview_scaffold project and performs a hot reload to render updates to the preview set in the scaffold application.
`package:analyzer` is currently being used to detect previews, but this comes with a significant amount of memory overhead. Since widget
previews are mostly being used from within IDEs which already have an
active analysis server, moving widget preview detection into the DAS
will remove the need for creating an additional analysis context in the Flutter Tool itself.
This change includes the initial work to move widget preview detection
into the DAS. It utilizes a pull-based mechanism, where the Flutter Tool listens for file system events and then queries the DAS using the `dart/textDocument/getFlutterWidgetPreviews` and `dart/workspace/getFlutterWidgetPreviews` LSP methods.
Each reported preview contains some generated code based on the annotation used to define the preview. This code has all constants from the original annotation evaluated to either primitive values or constant expressions with namespaces applied to each symbol, allowing for the Flutter Tool to inject this code directly when updating the generated code in the scaffold project.
Towards https://github.com/flutter/flutter/issues/179584
Change-Id: I043cb3235a66b25dda3f852ca7f147bff0e1e537
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/478100
Auto-Submit: Ben Konyi <bkonyi@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
This change adds support for invoking RPCs via HTTP requests, allowing
for interacting with the service without needing to establish a web
socket connection.
This change also adds support for the development file system, otherwise
known as DevFS. DevFS is a (currently) undocumented feature provided by
the VM service that gives clients limited file system access within a
directory contained in the system's temp directory. This is currently
used by Flutter to push kernel files to the device when performing a hot
reload.
The DevFS implementation for package:dart_runtime_service_vm removes
the long deprecated support for `path` parameters, leaving `uri`s as
the only supported format for specifying file system types. Existing
DevFS tests have been updated to replace `path` with `uri` in
preparation for dart_runtime_service_vm becoming the new default VM
service.
This change brings the package:vm_service test suite pass rate to ~95%.
Change-Id: Ib7d95db5788c37408d3dec79926ca7206660a43f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/488280
Reviewed-by: Jessy Yameogo <yjessy@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
The `Match.operator[]` does the same thing and is
generally recommended (and shorter).
(I want to deprecate `group` and `groups`)
Tested: Refactoring.
CoreLibraryReviewExempt: Calling equivalent function.
Change-Id: I4c758968ae622fe16b7322be1b29b05b91e7fcd9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/489021
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>