Test Plan:
Behavioral correctness should be ensured by existing tests. Tests in vm/dart/entrypoints
ensure that the unchecked entrypoint is used in cases where the optimization should trigger.
Bug: https://github.com/dart-lang/sdk/issues/31798
Change-Id: Id25ecba86e20c22f0678c12986ad620db312ddaa
Cq-Include-Trybots: luci.dart.try:vm-kernel-win-release-x64-try,vm-kernel-optcounter-threshold-linux-release-x64-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-release-simarm-try,vm-kernel-precomp-linux-release-simarm64-try,vm-kernel-precomp-linux-release-x64-try,vm-kernel-precomp-win-release-x64-try
Reviewed-on: https://dart-review.googlesource.com/69743
Commit-Queue: Samir Jindel <sjindel@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
This change improves type flow analysis to infer int types, in addition
to concrete classes (int type is abstract and has 2 concrete subclasses,
_Smi and _Mint).
Also, this CL enables devirtualization of dynamic calls (previously, only
calls with known interface target were devirtualized).
DartMicroBench.PrimeNumber:
x64: +221%
armv8: +461%
armv7h: +47.98%
No measurable impact on Flutter gallery build time in release mode.
Issue: https://github.com/flutter/flutter/issues/19677
Change-Id: I34db195f52f2a434218ee11eee7f308d4661738b
Reviewed-on: https://dart-review.googlesource.com/69520
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
The detailed description of the corner case can be found in comment in
_FieldValue.setValue() method (in analysis.dart).
Unfortunately, this bugfix increases analysis time of Flutter gallery
from 10383ms to 11624ms.
Change-Id: I6161fea0747a27d6461e7ff9a1fcedd6b2f91d1e
Reviewed-on: https://dart-review.googlesource.com/66103
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
GrowableArrayMarker was a class that implemented int and was used to
enable implementation of default List factory constructor in pure Dart:
factory List([int length = GROWABLE_ARRAY_MARKER]) {
return identical(length, GROWABLE_ARRAY_MARKER) ? new _GrowableList<E>(0)
: new _List<E>(length);
}
Its existence complicated all kinds of things in the VM and it is finally
time to remove it.
Instead we build List factory body directly in IL.
This CL also provides inlining rule for `new List(n)` case.
Change-Id: I870751658a4ac17fce649c9ac70395ff88a5436c
Reviewed-on: https://dart-review.googlesource.com/57262
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
The behavioral difference is that named and optional arguments are filled in
with their default values in the `Invocation` object passed to `noSuchMethod`.
On the implementation side we make NSM forwarders concrete and fill in their
bodies in the CFE. The custom (and somewhat hacky) VM support is no longer
needed, and Dart2JS can benefit from this implementation as well.
According to discussion on #33031 we will be able to re-land this soon without
breaking Mockito.
Prior failures on precompiler bots are fixed in Patchset 2.
Change-Id: If1b7fe4cf6da5ef38f330e1ad226121bcfc958a1
Reviewed-on: https://dart-review.googlesource.com/54401
Commit-Queue: Samir Jindel <sjindel@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
This reverts commit 7d5025e814.
Reason for revert: <INSERT REASONING HERE>
Original change's description:
> Fix incorrect handling of NSM forwarders and pull all logic into CFE.
>
> The original implementation was designed around a shared misunderstanding
> of optional parameter handling in the spec. (which was also ambiguous about type parameters).
>
> The correct behavior for optional/type parameters is to fill them in with their default values/bounds.
> This behavior can be implemented without any backend support, as is done in this CL.
>
> Change-Id: Ib81f17ead2d2920e755703e244db5afc328d0315
> Reviewed-on: https://dart-review.googlesource.com/52802
> Commit-Queue: Samir Jindel <sjindel@google.com>
> Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
TBR=dmitryas@google.com,sjindel@google.com
Change-Id: Ice6cd36cc62772e013bded83e0f589fe4b5e9d53
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/53400
Reviewed-by: Samir Jindel <sjindel@google.com>
Commit-Queue: Samir Jindel <sjindel@google.com>
The original implementation was designed around a shared misunderstanding
of optional parameter handling in the spec. (which was also ambiguous about type parameters).
The correct behavior for optional/type parameters is to fill them in with their default values/bounds.
This behavior can be implemented without any backend support, as is done in this CL.
Change-Id: Ib81f17ead2d2920e755703e244db5afc328d0315
Reviewed-on: https://dart-review.googlesource.com/52802
Commit-Queue: Samir Jindel <sjindel@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
This CL enables type inference for bool expressions used in 'if',
'while', 'for', 'assert', '?:', '&&', '||' and '!' in TFA in order to
eliminate more bool checks.
AOT snapshot size of flutter_gallery (in release mode):
Before:
Instructions(CodeSize): 7297024
Total(CodeSize): 11833828
After:
Instructions(CodeSize): 7159120
Total(CodeSize): 11648470
Issue: https://github.com/dart-lang/sdk/issues/32718
Change-Id: If4212ec493ff9f4443be6da02bdd75f74c8c8c42
Reviewed-on: https://dart-review.googlesource.com/49823
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Zach Anderson <zra@google.com>
This CL fixes TFA summary collector to use right-hand side value as the
result of SuperPropertySet expression instead of result of setter invocation.
Change-Id: Ie2388387645eeec95096ab797e2718b7e031131b
Reviewed-on: https://dart-review.googlesource.com/48300
Reviewed-by: Martin Kustermann <kustermann@google.com>
This CL adds tree shaking transformation into TFA transformer, replacing
simple DropMethodBodiesVisitor. In addition to removing bodies of
unreachable members, tree shaker is able to remove unused classes, typedefs
and member declarations, and replace unreachable calls with 'throw'.
Total(CodeSize) of flutter_gallery in --release mode
before: 11,671,369
after: 11,499,694
https://github.com/dart-lang/sdk/issues/30480
Change-Id: I966cf222eb9725b7a75dd193ac479436b9b9b4c3
Reviewed-on: https://dart-review.googlesource.com/46942
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
In Dart, if initializer throws an exception, a static non-const field
will have a null value, even if result of initializer is non-nullable.
This CL fixes TFA to make static non-const fields with initializer
nullable in order to correctly handle this case.
Change-Id: Ib451927b3da508c18ea43fcd0533066fb129a45e
Reviewed-on: https://dart-review.googlesource.com/46577
Reviewed-by: Zach Anderson <zra@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
This CL changes incoming argument types of raw (opaque, untracked) calls
in type flow analysis (TFA) from static parameter types to 'dynamic'.
Currently, raw calls are used to approximate calls from native code to
entry points and calls through tear-offs. Using static parameter types
is not correct for raw calls as incoming argument types should not include
the effect of strong mode argument type checks inside the body of a
method. This change has almost no impact on the results of analysis
because intersection with static parameter types is already performed when
applying a summary.
To fill out the remaining gap, static types of fields are now taken
into account in TFA: type of an incoming value is intersected with a static
field type in _FieldValue.setValue().
Also, this CL includes a fix for handling cyclic type parameters in TFA
(this problem appears on language_2/cyclic_type_variable_test test as
soon as TFA starts looking at static types of fields).
Issue: https://github.com/dart-lang/sdk/issues/30480
Change-Id: Ib79f1399e6c086445a61acc22a24a5e37bf481e6
Reviewed-on: https://dart-review.googlesource.com/42820
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
This CL adds special case for FutureOr<T> type (which is a union
of Future<T> and T) into type flow analysis.
As type flow analysis doesn't retain information about generic type
arguments yet, FutureOr<T> is treated as AnyType for now.
Issue: https://github.com/dart-lang/sdk/issues/30480
Change-Id: Ieb4d862b5a993fe46c9662d9bcb0e1f06058a166
Reviewed-on: https://dart-review.googlesource.com/40463
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
This CL fixes the case when an invocation is invalidated in the
middle of processing. In such case, its result should not be retained
and it should be re-processed again.
Also:
* _WorkList.pending Set is replaced with LinkedList (reduces analysis time).
* ClassHierarchy is configured to ignore ambiguous supertypes.
* _AssertionError._throwNew entry point is added (as it is implicitly
inserted by flow graph builder).
Change-Id: Ie2d5d29352a5463fbe602910f9ae7f6f77a917d7
Reviewed-on: https://dart-review.googlesource.com/37126
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
* Invocation handlers and InvocationAnalyzer are revised to reduce
complexity of the code, improve precision and efficiency of analysis.
* Invocation now has 2 subclasses: DirectInvocation and
DispatchableInvocation; processing of invocations is moved to these
subclasses and simplified.
DirectInvocation is responsible for processing particular
methods and fields, while DispatchableInvocation processes polymorphic
calls by collecting targets and accurate receiver types for each target,
and delegating to DirectInvocations for processing of each target.
* Dynamic tear-offs and dynamic calls via getter/field are
supported.
* Invalidation of field initializers is implemented.
* Implicit 'return null' at the end of a function is correctly
detected.
Issue: https://github.com/dart-lang/sdk/issues/30480
Change-Id: I3d2ea69fbc95e3eb9aee244ee909016dfcf79bee
Reviewed-on: https://dart-review.googlesource.com/34507
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>