Variable patterns behave so differently inside a patternAssignment
that we may want to represent them using different AST nodes inside
the analyzer/CFE. This change adds a boolean flag allowing the
implementation to know what kind of variable pattern it's looking at
when parsing occurs.
Bug: https://github.com/dart-lang/sdk/issues/50035
Change-Id: I60adf2865bbe24f85b72a79b1360833bf823bd67
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/273829
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
```
import 'dart:typed_data';
@pragma("vm:never-inline")
fetch(l, i) => l[i];
main() {
const n = 16*1024*1024;
final l = ByteData(16 * n).buffer.asFloat64x2List();
for (int i = 0; i < n; i++) {
fetch(l, i);
}
final sw = Stopwatch()..start();
for (int i = 0; i < n; i++) {
fetch(l, i);
}
print(sw.elapsedMilliseconds);
}
```
on x64
before 1137ms
after 101ms
BUG=https://github.com/dart-lang/sdk/issues/50636
TEST=ci
Change-Id: I90ef8ccfa1161d4d8bb076a3c1a0e3c7d6521289
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/274263
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
The field `Var.errorId` was being used for two purposes:
- For checking error messages.
- To distinguish different variables with the same name when merging
variables in `||` and cases.
As a result, a lot of variables to be tagged with error IDs even in
tests that weren't generating any errors, which was confusing.
This change creates a new `Var.identity` field which is used for
merging variables in `||` and cases; it defaults to the variable name
but may be overridden in tests where distinguishing variables of the
same name is important.
Change-Id: Ieb587f434520dc484180aaa72658c899a2eb06d0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/273824
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
This change makes the API for the `ifCaseElement` method similar to
that of `ifCase`, which should make it easier to write flow analysis
unit tests for if-case elements.
Bug: https://github.com/dart-lang/sdk/issues/50419
Change-Id: I64c160f3b6df38b0d337f9b8f9c6c9189e9a13ed
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/274161
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
This change makes the API for the `ifCase` method the same as that of
`if_`, which should make it easier to write flow analysis unit tests
for if-case statements.
Bug: https://github.com/dart-lang/sdk/issues/50419
Change-Id: Iea7e0fabba9966eae52c0d28b52d2f8fcea25e46
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/273820
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
These checks are cosmetic right now in DDC, but the load check was happening synchronously rather than after the future returned by loadLibrary completed.
Change-Id: I867779605ddfe4f63b83b47418994e0c5e68572a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/274087
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Mark Zhou <markzipan@google.com>
Reviewed-by: Anna Gringauze <annagrin@google.com>
Right each `Pointer.fromFunction()` invocation will lead to creation of
a new ffi trampoline function & it's following JITed code. In AOT we
have exactly one ffi trampoline per target/native-signature/exceptional-return
combination.
=> This CL ensures we have only one such function.
Furthermore each `Pointer.fromFunction()` will currently perform 2
runtime calls in JIT: One to create a `Function` object, the other to
JIT that function & register callback metadata.
=> This CL ensures we won't do a runtime call to get a function, instead
do it at compile-time (as in AOT)
Furthermore we eagerly assign a callback-id to the unique/deduped ffi
trampoline callbacks. Only when the application requests a pointer, do
we populate metadata on the `Thread` object.
This CL doesn't (yet) change the fact that in JIT mode we have
isolate-specific jit trampolines (that will call now shared ffi trampoline
functions).
We also avoid baking in C++ runtime function pointers in generated
code. As a result we can now preserve ffi trampolines across AppJIT
serialization.
As a nice side-effect, we remove 100 lines of code.
TEST=ffi{,_2}/ffi_callback_unique_test
Issue https://github.com/dart-lang/sdk/issues/50611
Change-Id: I458831a47b041a088086f28f825de2a3849f6adc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/273420
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
The comment mentions that this was a planned refactoring after
--sync-async became the default. Avoid eagerly reading
`StackTrace.current` and switch to an `async` method.
Change-Id: I6a8e9399fa4c282ddbd42eb93f6e19669e75ebc9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/274260
Commit-Queue: Lasse Nielsen <lrn@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Nate Bosch <nbosch@google.com>
Auto-Submit: Nate Bosch <nbosch@google.com>
Some other whitespace tweaks
Dropped a bunch of gratuitous `[]` bits next to links
Change-Id: I32b46138d3ff7df68b8a4dab80b346de20fee73f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/274088
Auto-Submit: Kevin Moore <kevmoo@google.com>
Commit-Queue: Kevin Moore <kevmoo@google.com>
Reviewed-by: Michael Thomsen <mit@google.com>
This shares a cache for mapping Elements to their public LibraryElements across each snippet producer, and also skips snippet producers that produce snippets that won't match any typed prefix.
Change-Id: I6b64b3c55f1030a5eaa7ca1afdcd6c416e4baa08
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/273962
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
This prepares dart2js to default to sound null safety in Dart 3.0.
The compiler no longer infers the default mode based on the input
program, instead uses sound null safety unless
'--no-sound-null-safety' is specified.
On a separate change, we expect to remove the option of disabling
null safety.
Note: this change should also be reflected in the CHANGELOG, but
we've currently not included it to redeuce merge conflicts, as we plan
to land multiple 3.0-alpha changes in a short window of time
Change-Id: Id87498cc5976548ec89d1f36c60674b72406950a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/270860
Reviewed-by: Nate Biggs <natebiggs@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
Reviewed-by: Mayank Patke <fishythefish@google.com>
The JIT support for dynamically unboxing has been removed in [0]. As
such all double/float32x4/float64x2/int32x4 objects are immutable and
can therefore be shared across isolates.
[0] https://dart-review.googlesource.com/c/sdk/+/256211
TEST=ci
Change-Id: Ifd4e7c2444415b2e3b5269d9fbeb6570cc5d6768
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/273680
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
- Flip flag to make strong null safety the default
- Remove code that auto detects null safety mode from source files,
it is necessary to specify --no-strong-null-safety to opt out.
- Retains sniffing of AOT/JIT snapshots and kernel files to determine
null safety mode, the opt out has to be done when generating these
file.
TEST=ci
Change-Id: If2c9608eedb7c46d9c3cd85e261ee9640e0d28eb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/261140
Reviewed-by: Alexander Thomas <athom@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
- Fix ddc null dereference while generating symbols with mixins
- Fix incremental compiler failure on non-SCC components
- Reworked expression compiler worker tests for effiiciency
- Create module configuration in tests only once
- Add test case of compiling expression in an non-SCC module
- Add test case of compiling expression in an SCC module
This is a reland of commit e6f779bcdd
Original change's description:
> Cache expression compilers in incremental DDC mode
>
> - cache expression compilers in expression compiler worker
> to improve performance of exression compilation.
> - pass module format in expression compiler worker
> (the ddc format tests were not running!)
> - fix an issue where the same library was imported twice
> in module_builder.dart
> - add verbose mode timeline logging to ProgramCompiler.
> - update tests.
>
> Closes: https://github.com/dart-lang/sdk/issues/49944
> Change-Id: Ie7408dcd42e757b1eb5e7f5ccbc1b078b6417011
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/268361
> Reviewed-by: Johnni Winther <johnniwinther@google.com>
> Reviewed-by: Mark Zhou <markzipan@google.com>
> Commit-Queue: Anna Gringauze <annagrin@google.com>
> Reviewed-by: Nicholas Shahan <nshahan@google.com>
Change-Id: I80546773d957f37ec5b2353ea060b50f3fba0aa7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/271801
Reviewed-by: Jens Johansen <jensj@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Mark Zhou <markzipan@google.com>
Commit-Queue: Anna Gringauze <annagrin@google.com>
At the end of a scavenge, ObjectPtr::IsRawNull was used on what is either a pointer into old-space or a pointer into from-space. If a pointer into from-space, the header may be a forwarding pointer. When IsRawNull interprets this is an object header, the bits in the ClassIdTag position will sometimes happen to equal kNullCid, causing the pointer to be incorrectly interpreted as null instead of a forwarding pointer and thus leaving behind a dangling pointer into from-space.
This separate null check can simply be removed because null is always an old-space object.
TEST=splay_{weak/c_finalizer/dart_finalizer}_test
Bug: https://github.com/dart-lang/sdk/issues/50578
Bug: https://github.com/dart-lang/sdk/issues/50612
Change-Id: Ifc7dc19c36703222a9302a8dbb68982fdbbc91fb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/273560
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
This can be used by the front end to detect when to add synthetic
break statements to switches involving patterns.
Bug: https://github.com/dart-lang/sdk/issues/50624
Change-Id: I783b0920b8dc6ccbc7af8062fba7bfdeaa9dd9cc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/273800
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
In
b2889872c3,
the switch expression syntax was changed so that it no longer uses the
`case` keyword.
Change-Id: I97c10b3462b5849e1baf386df81a656d5ac25c09
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/273623
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Change-Id: I1ebb2ea12f4d01c4077fca6fc380353f821bc68a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/267422
Commit-Queue: Erik Ernst <eernst@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
When asking for all references of a member it starts by finding all
supertypes for the class, then for each supertype (including itself)
(that has a member with the same name as the one we're querying for)
it searches for all subtypes.
We recall that when getting all subtypes, it really gets all direct
subtypes, then for each of those, their direct subtypes etc.
Naturally, then, with getting all subtypes for all supertypes we
will often ask for all direct subtypes of the same class several times.
In fact, it's O(n^2):
As an example, if asking for references to `foo` on this
(in a file in analyzer, with 8 workspaces):
```
class X0 { void foo() { print('hello'); } }
class X1 extends X0 { void foo() { print('hello'); } }
class X2 extends X1 { void foo() { print('hello'); } }
[...]
class X149 extends X148 { void foo() { print('hello'); } }
```
we ask for subtypes 90600 (150 classes * 151 / 2 * 8 workspaces) times.
This CL stops that from happening and in the example from above we
"only" asks for subtypes 1200 (150 classes * 8 workspaces) times.
For the `newFile` from `AbstractSingleUnitTest` example, for instance,
we go from 28,264 asks to 17,432 asks (a ~38% reduction).
Non-first runtimes when asking for references:
Before:
0:00:03.074853
0:00:03.021881
0:00:03.034707
0:00:03.115596
0:00:03.032574
After:
0:00:02.223978
0:00:02.149937
0:00:02.150236
0:00:02.104704
0:00:02.175859
Difference at 95.0% confidence
-0.894979 +/- 0.060283
-29.2867% +/- 1.97266%
(Student's t, pooled s = 0.0413338)
Change-Id: Id792a595e74de01c7186ab1263c38728f051f603
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/272623
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>