This change addresses a technical debt issue in dart2js, where
errors sometimes get reported as a binary offset location, instead
of a line/column position with contextual data from the source file.
The reason for this behavior is that dartj2s reports binary offsets
when it can't recover line/column data and show the contents of the
file. This typically happens if the file cannot be read directly
from disk.
The fix consits of adding an API to record the contents of files
that are not read directly by the compiler. We then use this API to
provide all sources collected by the CFE when parsing components
from .dill files.
Note: this CL also deletes the `autoread` feature in
source-file-provider. That feature was added for the same purpose.
The way it worked was that instead of registering source content, it
tried to read the sources from disk on-demand as errors got
reported. This doesn't always work for three reasons:
* First, we often use custom schemes (like the multi-root scheme) in
dill files to make the .dill deterministic in distributed build
systems, the autoload feature had no understanding of how to
translate those custom URIs to file URIs (that translation is only
define at the time the .dill is being built).
* Second, sometimes the files are simply not available, for example,
in hermetic build systems like bazel we have no access to those
files.
* Third, when files were found, there was no guarantee that the
contents were consistent. That is, the current version of the file
on disk could have been modified and have different contents than
those used when the .dill file was built.
I tested this manually by adding a crash in SSA and observing the
location in multiple scenarios, including running from source,
running from a .dill with file URIs, running from a .dill with
multi-root URIs, crashing in SDK locations in regular files and
patch files.
Change-Id: Ief09be577f4c9c4b345b4e2641918cafbe93c3fc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/251700
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Sigmund Cherem <sigmund@google.com>
Note: this info is not added to the proto format
Change-Id: Ic7407405dea7bcd7b9d3328cfe0850609dc007a9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/250785
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Mark Zhou <markzipan@google.com>
The annotation data is queried on demand rather than being precomputed.
Methods that don't throw are computed after computing side-effects.
Change-Id: I4e31f0b7df668d41a15dcafee0c84fc7249e0699
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/251340
Commit-Queue: Stephen Adams <sra@google.com>
Reviewed-by: Nate Biggs <natebiggs@google.com>
Not storing a collection of methods is a step towards processing
annotations more 'online'.
Change-Id: I378ec4db9526004a1f1dc56886bbc91a7acde7f0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/251322
Commit-Queue: Stephen Adams <sra@google.com>
Reviewed-by: Nate Biggs <natebiggs@google.com>
This is required for apps that use split-phase compilation
Change-Id: I8ea20dd610781064af95d2ac3c7c612db3dd7e5a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/250948
Commit-Queue: Mark Zhou <markzipan@google.com>
Reviewed-by: Joshua Litt <joshualitt@google.com>
Calculates and prints the number of files blocked by each unmigrated file. Adds he option for a flag to sort by number of blocking files.
Change-Id: I565f565d2d68e6d630bb2c9bb6d7fc46b016e365
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/251180
Commit-Queue: Nate Biggs <natebiggs@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
See: #49160
This doesn't offer a phase-specific view of the ram usage nor aggregate ram usage across split phase compilation.
Change-Id: Ia1f781f9bd35b40048ac23fe103b8fee3b4da584
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/250947
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Mark Zhou <markzipan@google.com>
This is very similar as the change Ivan sent in
https://dart-review.googlesource.com/c/sdk/+/250081, except that we additionally
skip updating the cache unnecessarily.
This should allow relanding the change that migrates this library.
Change-Id: I37684e66abe43446f4a5e8b3ed41d6573d93a3ca
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/250440
Reviewed-by: Nate Biggs <natebiggs@google.com>
Commit-Queue: Sigmund Cherem <sigmund@google.com>
Resolves issue where some programs could not be compiled with dart2js and --enabled-asserts flag. The following assert was failing:
https://github.com/dart-lang/sdk/blob/main/pkg/compiler/lib/src/ir/static_type.dart#L987
This assert checks that the promoted static type that Dart2JS calculates for variables is a subtype of the promoted type calculated by the CFE. This was not true in some cases.
The cause of this discrepancy was that `as` expressions were not properly promoting casted variables. For example:
int func() {
dynamic x = 3.0;
x as double;
return x.asInt();
}
The cast on the second line of the function should promote the type of `x` through the rest of the function and `asInt()` should not be a dynamic invocation.
Change-Id: Iea2508627fb6b3f0cdde785624a00aa2d22d75de
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/250860
Reviewed-by: Joshua Litt <joshualitt@google.com>
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
The type bounds in each case statement can diverge when a break is hit in a conditional control flow block. Previously the switch statement was just merging the end state after visiting each case block. Instead we need to merge all possible termination states for each case.
This is trivial when the switch only contains breaks. The termination states are just those when we reach each break (or the end of the switch if there's a default).
When there are switch-continue statements we must reconcile the states that flow into each targeted switch before reconciling the types of those targeted switches themselves. We achieve that by making two passes over the cases, the first to gather the continue states and the second to update the switches affected by those states. Similar to before this is done repeatedly until a fixed point is reached.
Fixed: 46770
Change-Id: I5795748a4591e6a1dc283f2a54129e09a20d13d8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/250200
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
Index cache maps should be copied instead of used directly. And the set of indices (DataSourceIndices.caches) needs to be copied as well since we alter it when reading each shard.
Change-Id: If7a640ead07a54e3cb6003eee89c44db8f449812
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/250202
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
Includes skipping duplicated installation code.
For more info, see #49348
Change-Id: I34833df32156d9fe090b579b665dd9cb93860f8b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/250020
Commit-Queue: Mark Zhou <markzipan@google.com>
Reviewed-by: Joshua Litt <joshualitt@google.com>
Fixes#49301
From https://github.com/dart-lang/sdk/issues/49301#issuecomment-1165536192
Adds referenceFromIndex to outline transformations so that the eraser
can use it to find the reference for the stub if it was already created.
This is needed when the module where the stub exists is invalidated.
Since references in other modules should still be valid, we should
attempt to get that reference.
Change-Id: I5905a002480444aecd57de650cd439bdc34d4eba
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/249729
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Joshua Litt <joshualitt@google.com>
`element_map_interfaces.dart` contains temporary interfaces that exist for the duration of the nnbd migration.
`element_map_migrated.dart` contains 'real' code from `element_map.dart` that has been migrated. This will get re-combined with the `element_map.dart` once it is all migrated.
Change-Id: I55cc414de471adbe2d63c0e226558d5b4773d409
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/249744
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
At this point the only imports of the pre-nnbd DataSourceReader and DataSinkWriter are files that need to instantiate the class. Other references have been migrated.
Change-Id: I79672fc5f8c681d05a183990e184535f1becc0e9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/249742
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
This allows `e!` to be replaced by `e ?? failedAt(...)` where a more descriptive internal error is desired.
`failedAt` used to return `bool` so that you could write
assert(condition || failedAt(...));
We have had assertions with messages for a long time, so that was changed to
assert(condition, failedAt(...));
This still works with the type `Never`.
Change-Id: I132665d898a6aefe1fcf73235e88c156bab1e21e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/249730
Reviewed-by: Joshua Litt <joshualitt@google.com>
Reviewed-by: Nate Biggs <natebiggs@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
In response to https://github.com/dart-lang/sdk/issues/47406
The error is currently not reported if the mixin declaration is from
an outline dill.
Change-Id: I94a61d6409d0c238614d9f377b5f324153360bc6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/249184
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
This CL:
* Removed the redirect from .packages to .dart_tool/package_config.json
(whenever such a file existed).
* Removes support for the old format entirely.
* Updates all tests etc that were found.
Fixes https://github.com/dart-lang/sdk/issues/48939
TEST=Existing tests updated.
Change-Id: Iccf711c455ac1885189aa773ca74dd8f55012964
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/248603
Reviewed-by: Michael Thomsen <mit@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
Codegen deserialization was inadvertantly loading the nodes for many ClosureMemberDefinitions, specifically ones for generators. The node doesn't actually end up being used after this point though so the Deferrable is unnecessarily triggered.
To get around this we have the SpecialMemberDefinition constructor copy the Deferrable out of the ClosureMemberDefinition.
To avoid exposing the deferrable I've moved the ClosureMemberDefinition into the same library as SpecialMemberDefinition.
This brings the number of Kernel AST function bodies being deserialized down to 2 in cm_shell (down from many thousand).
Change-Id: I0781ab490dc1972118cf2ac2359f467916031633
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/247283
Reviewed-by: Stephen Adams <sra@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
Reviewed-by: Joshua Litt <joshualitt@google.com>
Also:
- KFieldAnalysis takes an elementMap instead of the whole strategy.
- Fix a missing `?` from a previous migration
Change-Id: I7f8fab61c644d14d1f037603a8539a2db5090d8b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/249547
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
This is a step towards improving the semantics of these nodes.
TEST=existing
Change-Id: I95bdb86790414b38af73e9e932cc228b3c0f1f6e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/249040
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
Reviewed-by: Joshua Litt <joshualitt@google.com>