I doubt that this will have any significant performance impact, but it
seems wasteful to invoke all of the 'generalized' visit methods when
the only important one is `visitNode`.
Change-Id: Ie574d1456a4cccb26090c36f7f6340445bba4006
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/287160
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
This allows us to better track all kinds of accesses to record
implementation classes in dart2wasm, which generates separate
record implementation class per record shape.
This change also allows us to remove mutable dispatch targets
which were used to implement dynamic accesses to record fields,
and make tracking of record field types more accurate
(record fields are now versioned per shape).
This is also a step towards inferring actual record types.
TEST=pkg/vm/testcases/transformations/type_flow/transformer/records.dart
TEST=pkg/vm/testcases/transformations/type_flow/transformer/records_dart2wasm.dart
TEST=language/records/simple/dynamic_field_access_test
Issue https://github.com/dart-lang/sdk/issues/49719
Fixes https://github.com/dart-lang/sdk/issues/51363
Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-nnbd-linux-release-x64-try
Change-Id: Icba62a7ca8cfd8ddbc7f2b7c38aeabbef5caec4b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/286950
Reviewed-by: Slava Egorov <vegorov@google.com>
Reviewed-by: Ömer Ağacan <omersa@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
I would prefer to have the code uncommented because it will help prevent
it from becoming stale.
Change-Id: I86dc0c715433cbeab33b3739f826475fcc583bc6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/287161
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Judging by several test cases that have shown up in co19 tests and
informal discussions, it appears to be a common expectation that a
pattern like `int? x?` or `int? x!` should promote `x` to
non-nullable. Previous to this change, this didn't work in general.
Consider:
Object? o = ...;
switch (o) {
case int? x?:
print(x.isEven); // (1)
}
At (1), the null-check happens *before* the required type check of the
variable pattern; therefore it promotes the matched value type to
`Object`. This is not a subtype of the required type of the variable
pattern (which is `int?`), therefore, previous to this change, `x` was
not promoted.
With this change, since the matched value type of `Object` is
non-nullable, the required type of the variable pattern is
re-interpreted as its non-nullable counterpart, `int`.
In a fully null-safe program, this is sound, because if the matched
value type is non-nullable, that guarantees that the matched value is
not `null`, and therefore it is equivalent to type check against the
non-nullable counterpart of the required type.
In a program that is not fully null-safe, the matched value might have
originated in a non-null-safe library (and thus might be `null` in
violation of its static type). So, strictly speaking, it is not sound
to re-interpret the required type of the pattern as its non-nullable
counterpart. However, the only way this unsoundness can manifest is
for the matched value to be promoted to non-nullable when it is in
fact `null`, and that is precisely the sort of unsoundness thta we
permit in mixed-mode programs. So this change won't result in
unsoundness escalation.
Bug: https://github.com/dart-lang/sdk/issues/51644
Change-Id: I9479e3c29e12f2a62a9e165b32c3480d7e299c29
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/287040
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Includes just one more commit - "Enable support for inline class syntax"
Change-Id: Ie230fc72b7170d3610bdd7ed7ab8c193338f8a93
Bug: b/271244238
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/287020
Commit-Queue: Oleh Prypin <oprypin@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Auto-Submit: Oleh Prypin <oprypin@google.com>
Reviewed-by: Bob Nystrom <rnystrom@google.com>
This CL replaces `late Finalizable` variables with the original and
a nullable non-late variable. Every assignment is done first to the
late variable, and the immediately to the nullable non-late shadow
variable. The reachability fences are then inserted only for the
nullable non-late shadow variable.
The advantage of this is that the semantics are fully valid and none
of the further compiler pipeline has to know about late Finalizables.
(1) We remove the special casing in the VM.
(2) The TFA logic with finalizables is no longer blocked.
The downside of this approach is that we use more memory, we need
two fields at runtime, one storing a null and the other storing a
sentinel on initiazation. Moreover, we get some extra store
instructions.
TEST=pkg/vm/testcases/transformations/ffi/finalizable_late.dart
TEST=pkg/vm/testcases/transformations/ffi/finalizable_late_2.dart
TEST=tests/language/vm/regress_49005_test.dart
Closes: https://github.com/dart-lang/sdk/issues/51511
Change-Id: Ifedd3387a368233a2d01e1bcaa9f5e3eceb76856
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/286782
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
This improves the support for logical and pattern by making an
approximation of the intersection of spaces. When creating an
intersection between two [SingleSpace]s, if one of the static
types is a subtype of the other, this used for the create
intersection. Otherwise the intersection is modelled by including
an "unknown space" in the result.
Change-Id: Ia9d7324fa13f4b9850aece126de3aab3a1e63d3e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/286962
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
This adds a [SpaceCreator] mixin used to share the code that creates
the [Space] for each pattern. This is mixed into the [PatternConverter]
in the analyzer and a similar [PatternConverter] is added to the CFE.
Change-Id: I0b284b1473b464167aa84f1948264efc4120001d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/286960
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
"dartdevc" and "dartdevk" have been replaced with "ddc".
Change-Id: I823bc029a0bbe1295fd731efcc32961e61c6c175
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/282485
Commit-Queue: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Alexander Thomas <athom@google.com>
Would otherwise emit `CantUseClassAsMixin` and then if the supertype is final or interface, would emit `FinalMixinMixedInOutsideOfLibrary` and `InterfaceMixinMixedInOutsideOfLibrary`respectively. These errors together don't make sense so this CL fixes it.
Change-Id: I5fdf4e260b709e08af53cbda0414cff2ef93d3b5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/286951
Commit-Queue: Kallen Tu <kallentu@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
This propagates information about reported error to the caller of
a shared type analysis. This is used to properly turn errors into
invalid expressions/patterns, as is normally done in the CFE in
face of errors.
Change-Id: Ibb8adedccb8314fabfe18ecaa3559e32ad7267ca
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/286145
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
With pattern assignment, the error messages are now different in 2.19
libraries since a parenthesized expression looks like you might be
trying to do a pattern assignment.
Change-Id: I00105ea4cb5dbe8c8b328fb2e665200f3dc33722
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/286870
Auto-Submit: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Jake Macdonald <jakemac@google.com>
Commit-Queue: Jake Macdonald <jakemac@google.com>
This changes the Space computation for CastPattern to just the
Space for the subpattern. For a non-throwing cast, this is exactly
what the pattern will match.
There is still potential for handling the types rejected by the cast.
For instance recognizing that the (yet) unhandled subtypes of a
sealed type are exhausted by the throw.
Change-Id: Ia846895449f37a970f87a7f6c54a0ff8285df6b0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/286825
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
This adds a [Witness] class as the result of an exhaustiveness test.
This allows for testing exhaustiveness without having to compute the
textual representation of the witness.
Change-Id: I6225b6d35a23792ecc15ae769e4b70cab93e2229
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/286824
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
See: https://github.com/dart-lang/sdk/issues/50417
Initial work to support return conversions. Arguments and assignments to come and will likely lead to some refactoring but there's enough here to benefit from some early feedback.
Thanks in advance! :D
Change-Id: Ic3d0349aa12d8c951e3afe0da3e00e2777480e38
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/286861
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
This remove the [Space] class from the old algorithm and instead
encodes the patterns into the new model. The [Pattern] and
[Patterns] classes of the new model have been renamed to
[SingleSpace] and [Space], respectively, and a [Path] class is
added to track the path property used in the model of the new
algorithm.
Change-Id: I0c86c738807030be2f9b59f3aefb5bfcf5bbaeee
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/286501
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Fix test_runner's handling of tests passed as
relative native file paths to the test runner command.
Fix failing use of a special executable to test a crashing process.
Change-Id: I0837a0c2c4461883a604aa85083c3098dfbaae2e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/286821
Reviewed-by: Devon Carew <devoncarew@google.com>
Reviewed-by: Bob Nystrom <rnystrom@google.com>
Commit-Queue: William Hesse <whesse@google.com>
Reviewed-by: Alexander Thomas <athom@google.com>
Change from `List<_StringBase>` to `List<String>`, as that's what
`_getTypeNames` returns.
Change-Id: Ib216796eb0a105e81e45d6217c2a6ddb015129c1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/286923
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Commit-Queue: Ömer Ağacan <omersa@google.com>
This reverts commit c67fac9cb4.
Reason for revert: Regresses `dart:io` performance and causes
failures.
https://github.com/dart-lang/sdk/issues/51639
Original change's description:
> [vm] Remove tcmalloc and malloc profiler.
>
> The standalone VM originally began statically linking tcmalloc to work around bugs in the system malloc for Fiber. Later it used tcmalloc's hooks to implement a profiler, but this is rarely used since it is only available in debug mode, misses early allocations, and often misses late allocations from an exhausted sample buffer. Removing it altogether avoids build complexity around which combinations of compiler/architecture/sysroot support tcmalloc, and reduces binary size.
>
> TEST=ci
> Change-Id: I4b259e18b82b2d12a2a60962aabf83bd8d997d19
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/286120
> Reviewed-by: Ben Konyi <bkonyi@google.com>
> Commit-Queue: Ryan Macnak <rmacnak@google.com>
Change-Id: I4395edd6f5bd7e26b4e38f4d931ad2ea67afba18
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/286925
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
This proved to be quite a bit more time consuming than I'd realized,
and it was a lot harder to verify the results than I would have
guessed.
But I think it made it easier to see holes in our location coverage
to have the tests split up this way. I decided not to fill those
holes in this CL in the hope that it's easier to see the
correspondence between the old tests and the new tests.
Change-Id: Ia73ce4367fc11ae78310f7ae182bf16591246597
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/286871
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Changes:
- Instantiation context structs now have a common supertype:
`#InstantiationClosureContextBase`. This supertype is used to check if
a closure is an instantiation.
- Generic closure vtables now have one more entry for comparing types in
instantiation contexts.
- All instantiations with same number of types use the same context
struct type and the vtable entry for comparing types in contexts.
- `_Closure._equals` checks if closures are instantiations (with a type
test against `#InstantiationClosureContextBase`), and if they are,
gets the contexts and calls the function in the vtable for comparing
the types in the contexts.
Fixes#51030
Change-Id: I680041480963381337dcfa1fbf6c3a77ca564205
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/285902
Commit-Queue: Ömer Ağacan <omersa@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
We've changed const `==` to be based on primitive equality. It used to
just be an allowed list of concrete types, but now `==` is a valid
constant expression on any type that has primitive equality.
This change isn't directly part of patterns, but is enabled under the
same flag.
Update this test to the new semantics.
Change-Id: I484bd09f5775319dc49038d70a244c3c1564fe93
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/286865
Commit-Queue: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Jake Macdonald <jakemac@google.com>
Auto-Submit: Bob Nystrom <rnystrom@google.com>
The standalone VM originally began statically linking tcmalloc to work around bugs in the system malloc for Fiber. Later it used tcmalloc's hooks to implement a profiler, but this is rarely used since it is only available in debug mode, misses early allocations, and often misses late allocations from an exhausted sample buffer. Removing it altogether avoids build complexity around which combinations of compiler/architecture/sysroot support tcmalloc, and reduces binary size.
TEST=ci
Change-Id: I4b259e18b82b2d12a2a60962aabf83bd8d997d19
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/286120
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Querying the thread clock takes the overwhelming majority of time when using the VM-internal recorders (ring, startup, endless, file). Including the thread clocks in the timeline allowed visualizing roughly how much an event got scheduled out, but not when. This is a high price to pay for such fuzzy information. Precise scheduling information is available from Fuchsia tracing, systrace or Signposts.
```
import "dart:developer";
main() {
var n = 1000000;
var watch = new Stopwatch()..start();
for (var i = 0; i < n; i++) {
Timeline.timeSync("EventName", () {});
}
print("${watch.elapsedMicroseconds.toDouble() / n} us/event");
}
```
--timeline_recorder=ring 2.751822 -> 0.487936 us/event (5.64x)
--timeline_recorder=systrace 0.440439 -> 0.435997 us/event
TEST=ci
Bug: https://github.com/flutter/flutter/issues/121372
Change-Id: Ib6d625f28384a4e87df2a3305483f0f6facd08ff
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/286661
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
This contains support for all of the 3.0 language features. It also
contains a couple of very minor style changes. Unlike the previous
reverted roll (https://dart-review.googlesource.com/c/sdk/+/285460),
this does *not* contain the style change to support compact switch
statements. This should eliminate most of the style churn.
Change-Id: I95dd73a3a921b4a0cd278a7abb86daf8eea21397
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/286701
Reviewed-by: Alexander Thomas <athom@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Bob Nystrom <rnystrom@google.com>