Fixes https://github.com/dart-lang/sdk/issues/42375
EdgeBuilder wishes to do its own GLB type-joining, as does FlowAnalysis.
When FlowAnalysis pushes a promotion in ifNullExpression_rightBegin,
and then in write, and then pops those two promotions to join them in
ifNullExpression_end, EdgeBuilder is not given a chance to make its
own GLB node. Instead promotion never happens: the DecoratedType which
is the variable's type is promoted to non-nullable, for the left side.
The DecoratedType for the right side expression is not considered
non-nullable, so the FlowAnalysis.join will always fail to promote.
TypeOperations.adjustPromotedTypes solves this. It is a no-op in all
implementations except in EdgeBuilder.
Additionally FlowAnalysis.write's promotion fails for the same reason:
the only type of interest is the declared type made non-nullable, and
no matter what, the writtenType is not a subtype of this.
TypeOperations.forcePromotion solves this. It is a no-op in all
implementations except EdgeBuilder.
Change-Id: Iba6b9a69583af8fe1aa23124c7d66047acfff495
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/152104
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
This also includes few other changes:
- Add ability to collapse leaf nodes in a treemap created from V8 snapshot
profile. This behavior is programmatically controlled by `TreemapFormat format`
parameter and from CLI via `--format` flag. The following options are available
- `collapsed` essentially renders `ProgramInfo` as a treemap, individual
snapshot nodes are ignored.
- `data-and-code` collapses snapshot nodes based on whether they represent
data or executable code.
- `object-type` collapses snapshot nodes based on their type only.
- When computing `ProgramInfo` from a V8 snapshot profile no longer create
`ProgramInfoNode` for `Code` nodes which are owned by a function - instead
directly attribute the `Code` node itself and all retained nodes into
`ProgramInfoNode` for the function itself. For stubs (including allocation
stubs) create an artificial `functionNode` instead of using `NodeType.other`.
The only remaining use of `NodeType.other` is for fields.
Cq-Include-Trybots: luci.dart.try:pkg-linux-debug-try,pkg-linux-release-try,pkg-win-release-try,pkg-mac-release-try
Change-Id: I18e5437a10dd9141adaed5dfd6f0a3545740e2a2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/152320
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Kenzie Schmoll <kenzieschmoll@google.com>
Reviewed-by: Tess Strickland <sstrickl@google.com>
There was a crash internally, caused by the fact that when we have
duplicate name for class and enum, during linking we put them into
different Reference bucket - @class and @enum, and also inside
the class, the reference to its name is the class.
But when we resolve, we check equality of elements using not
references, but locations. So, we need to make sure that their
kinds are also different, so go into different bucket, and so
not equal.
When they are InterfaceType and equal, we would try to match
type arguments against the wrong number of type parameters and crash.
Change-Id: Iee3f8691adac65d4b0395ceec7fc7250f96afa88
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/152404
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
When getting a value from a field of covariant type we can apply
field guard summary which would narrow field type using the actual
type arguments of the receiver.
This results in more accurate types returned from widely used
iterators and for-in loops.
Doesn't affect Flutter gallery size in release mode.
Fixes https://github.com/dart-lang/sdk/issues/42413
Change-Id: I835756fb18a1fcbf055a43e4ece8b7539f1ba938
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151889
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
This CL adds a package uri to SourceLibraryBuilder based on the
package information computated by package:package_config. This uri is
used to determine whether experimental flags are enabled and thus using
allowed_experiments.json in bin/test folders as well as the lib folder.
Change-Id: I60e6e97139a4a24b8d4d27d314cfc0f7d7bfc816
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/152151
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Rationale: internally we patch a number of diagnostic messages to add context to messages (and corrections). Introducing maps that allow for customization makes the internal patching process far easier and less prone to error.
Change-Id: I2d1e7488b451654dd24b8ae95647619c65d3974b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151664
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: David Morgan <davidmorgan@google.com>
Previously we given the info node and its corresponding snapshot node we
would attribute the size of snapshot node to the parent of the info node,
which is incorrect.
This CL also includes few other minor changes (all described in
CHANGELOG.md):
- `--help` output of the command,
the method for detecting executable name was not working correctly
under `pub global activate`: it printed snapshot name, instead of
`snapshot_analysis`;
- rename `README.dart` to `README.md` because `.dart` extension
confuses `pub` analysis.
- add documentation to `ProgramInfoNode.size`.
- add documentation on passing flags to AOT compiler
Cq-Include-Trybots: luci.dart.try:pkg-linux-release-try,pkg-win-release-try,pkg-mac-release-try
Change-Id: I8e8f2e9b7b9bfb3fe688caa16c0490eb8ec60e7c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/152148
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Tess Strickland <sstrickl@google.com>
This change introduces handling of protobufs while doing type flow
analysis. Metadata in protobuf message classes is updated dynamically
according to the set of called accessors, invalidating and rebuilding
TFA summaries as needed.
Previously, protobuf-aware tree shaker required the 2nd run of TFA
in order to do the actual tree-shaking after protobuf messages are
pruned. This significantly increases compilation time.
AOT compilation time of a large app (--from-dill): 274s -> 152s
New tree shaker is available in kernel compilers under the flag
--protobuf-tree-shaker-v2.
Issue https://github.com/dart-lang/sdk/issues/42442
Fixes https://github.com/dart-lang/sdk/issues/40785
Change-Id: I4347896737b9b0f7407b845e614dda9ba7621921
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/152100
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Clement Skau <cskau@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
These cases are collected sorted and printed back out to help us improve the context type algorithm, that is we may choose to in completion locations 'var i = ^', to assume that the user will be entering an int type.
Change-Id: Ia3e4663b2cf1614935ff49a4ab10299db0dc909d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151783
Commit-Queue: Jaime Wren <jwren@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
This CL adds some infrastructure that makes it possible to defer the
inference of type arguments for a type alias which is used to specify
an instance creation:
class B<X, Y> {}
class C<X> implements B<String, X> {}
typedef T<X> = C<List<X>>;
void main() {
B<Object, Iterable<num>> c = T(); // Infer `T<num>()`.
}
The CL contains an implementation for type inference in the case
where the target is a non-redirecting constructor.
There is not yet an implementation of type inference for the case
where the type alias ultimately resolves to a redirecting factory
constructor, and the shadow nodes are eliminated as null.
Change-Id: I9721b293dce37313e046a8339359e51c2d54b4c3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/150301
Commit-Queue: Erik Ernst <eernst@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
This code will be published on Pub so that Dev Tools can consume it.
Cq-Include-Trybots: luci.dart.try:pkg-linux-debug-try,pkg-linux-release-try,pkg-win-release-try,pkg-mac-release-try
Change-Id: Iddfbd3f0976af218d29ac20b452fbb139983a484
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/152008
Reviewed-by: Tess Strickland <sstrickl@google.com>
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
Supports compiling to snapshots, JS, native executables, and kernel:
$ dart help compile
Compile Dart to various formats
Usage: dart compile <subcommand> [arguments]
-h, --help Print this usage information.
Available subcommands:
aot Compile Dart to an AOT snapshot
exe Compile Dart to a self-contained executable
jit Compile Dart to a JIT snapshot
js Compile Dart to JavaScript
kernel Compile Dart to Kernel intermediate format
Change-Id: I1143f8dd0eec6f87a8271144f92dedc1fcf82923
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/146806
Commit-Queue: Michael Thomsen <mit@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Jaime Wren <jwren@google.com>