Commit graph

998 commits

Author SHA1 Message Date
Alexander Markov 83d962339e [vm/nnbd] Fix handling of catch-all try blocks with null safety
Before null safety

  try {
    ...
  } catch (e) {
    ...
  }

was translated to a try-catch block with 'dynamic' catch type.

VM has a special, more efficient handling of such catch-all try blocks.
Those try blocks were detected by comparing catch type with 'dynamic'.

With null safety front-end started to translate those try blocks
using non-nullable Object as a catch type. As a result, this disabled
all optimizations for catch-all try blocks in the VM.

This change extends detection of catch-all try blocks to handle both
dynamic and Object as catch types.

Improves ParserCombinators benchmark with null safety 12x in JIT mode,
15x in AOT mode. This benchmark is now on par with legacy (pre-NNBD)
version.

Change-Id: I128aa1599d8a6f979fc2e8535d0f5c934bf3a5ba
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/157565
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2020-08-06 23:46:09 +00:00
Liam Appelbe 79cec0e864 [vm] Delete ABI infrastructure
Change-Id: I26d455d96c87010293a6dcb9f6c0eecfcaf3c816
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/157102
Reviewed-by: Alexander Thomas <athom@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Liam Appelbe <liama@google.com>
2020-08-06 19:55:12 +00:00
Alexander Markov ce9c18fad1 [vm/aot/tfa] Fix return value of operator== in TFA summaries
Fixes https://github.com/dart-lang/sdk/issues/42937

Change-Id: I04d1d66453440c891694abfe1828d582925bb8f7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/157422
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2020-08-06 15:37:19 +00:00
Tess Strickland 702756ec5d [vm/bytecode] Fix handling of required named parameter flags.
In AOT mode, TFA turns optional arguments (named or positional) that are
always provided into required positional arguments and increases the
number of required arguments accordingly. Thus, from the standpoint of
the VM, whether it's reading in bytecode or kernel, these are just
regular fixed positional arguments. However, TFA originally left the
parameter flags alone for these parameters, so required named parameters
that were converted to positional arguments still had the required flag
set.

This CL does two things:

1. It fixes TFA to clear the required bit on a parameter if it is
converted from a named parameter to a required positional parameter.

2. It adds ASSERT()s and RELEASE_ASSERT()s on the VM side to ensure that
only named parameters have the required bit set.

Change-Id: I1c36d777a7e9e7d703bcc23ee1b798bffeffa29e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/157381
Commit-Queue: Tess Strickland <sstrickl@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2020-08-05 18:54:49 +00:00
Mayank Patke ca743398c2 Ensure CFE provides correct setter name to instantiateInvocation.
All of the backends (dart2js, DDC, VM) were checking if the invocation
name was tagged with "set:" and appending "=" to the name if so.
Instead, we can simply have the CFE perform this logic at the callsite.

Note that the name of the setter itself is still unchanged. Backends may
still need to generate the correct name themselves when handling NSMs
via code paths other than instantiateInvocation.

Change-Id: Iae42c849d3557be3e3b77c3af6f3993347ba0b6c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/156142
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Mayank Patke <fishythefish@google.com>
2020-07-30 06:21:20 +00:00
Nate Bosch 5e6d949757 Remove some misleading int returns from main
During normal execution the return value from `main` is _not_ used as an
exit code. Fix some cases that try to use it that way.

Change-Id: I292dc8ebf0acc8cb3d4d72f55107e438df9112de
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/156143
Auto-Submit: Nate Bosch <nbosch@google.com>
Commit-Queue: Nate Bosch <nbosch@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2020-07-29 00:47:01 +00:00
Alexander Markov 56708696a9 [vm/nnbd/bytecode] Distinguish function types with different nullabilities in bytecode generator
Fixes https://github.com/dart-lang/sdk/issues/42807

Change-Id: I054b79c5b199fbc53e512caf8e41ddbcb79d3675
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/155682
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2020-07-24 01:26:44 +00:00
Alexander Markov 17d7296a42 [vm/nnbd/bytecode] Fix reuse of type arguments in bytecode
Type arguments should not be reused if type parameter has a nullability
other than non-nullable or undertermined, as instantiating such type
parameter may alter the type.

Also, this change adds printing of nullability when dumping bytecode
and updates expectations accordingly.

Fixes language/nnbd/is_type_test/null_is_type_in_legacy_lib_test in
bytecode mode.

Change-Id: I4378a4e42fa0bf014840b9b1ef09a633c1825e20
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/155560
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2020-07-23 00:35:29 +00:00
William Hesse 24c7666def Update tests that have the current version number hardcoded
Some package configuration tests have the current version hardcoded
in local package_config.json files. Update these from 2.9 to 2.10.

Change-Id: I77bf63c0e5dfa73aa8a86fb1b4e8a404e8cfaa7f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/155441
Reviewed-by: Martin Kustermann <kustermann@google.com>
2020-07-22 13:22:07 +00:00
Alexander Markov b2ef76a4d1 [vm/aot] Keep source positions when replacing casts and null checks with unsafeCast
Fixes https://github.com/dart-lang/sdk/issues/42784

Change-Id: I1c507c65696b186ec34b1051e22ed23a4356e548
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/155260
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2020-07-21 22:15:45 +00:00
Ben Konyi 157ebfe50f Reland "[ VM / DartDev ] Launch DartDev in an isolate within a single main Dart process"
This reverts commit 7e373831ce.

Change-Id: Ib94d793a5753ec6352cd9a65e35f726a63336368
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/154830
Reviewed-by: Siva Annamalai <asiva@google.com>
2020-07-21 16:23:18 +00:00
Alexander Markov baf740ee92 [vm/nnbd] Remove obsolete --null-safety option
Option --null-safety was replaced with --sound-null-safety
(in https://dart-review.googlesource.com/c/sdk/+/153660).
This change cleans up obsolete option from the VM and kernel compilers.

Issue: https://github.com/dart-lang/sdk/issues/41853
Change-Id: I605703bd5bf526391b21704b842bb9e6ca452061
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/155020
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2020-07-20 23:09:29 +00:00
Alexander Aprelev 7e373831ce Revert "Reland "[ VM / DartDev ] Launch DartDev in an isolate within a single main Dart process""
This reverts commit bc4cb123a8.

Reason for revert: breaks crossword simarm tests https://ci.chromium.org/p/dart/builders/ci.sandbox/vm-kernel-precomp-linux-debug-simarm_x64/2619

Original change's description:
> Reland "[ VM / DartDev ] Launch DartDev in an isolate within a single main Dart process"
> 
> This CL changes how DartDev is run and how the run command handles executing a Dart program (will port additional commands in a separate CL). Rather than using DartDev to spawn a child process to run user code, the VM will instead launch a DartDev isolate after doing some VM options processing. DartDev will communicate information like exit codes and script/arg pairs with the VM via isolate ports. Once DartDev runs to completion and notifies the VM that a script should be run, the VM will move on to spawning another isolate with user code and continue executing in the same VM process.
> 
> By moving DartDev into an isolate within the same process that user code will eventually run in we're able to resolve the following issues that arose due to signal handling and IPC issues:
> 
> VM hangs when --enable-vm-service is supplied and there are compile time errors (https://github.com/dart-lang/sdk/issues/42630)
> Dart daemon spinning in exit code handler / zombie Dart processes (https://github.com/dart-lang/sdk/issues/41978)
> Signal handling in children of 'dartdev run' is problematic (https://github.com/dart-lang/sdk/issues/42092)
> 
> This reverts commit 3849b5061c.
> 
> Change-Id: I4fd3ba33840771a9f284d733c4a25fac6cde64ca
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/154706
> Reviewed-by: Siva Annamalai <asiva@google.com>

TBR=bkonyi@google.com,asiva@google.com

Change-Id: I649d94c668417f2edbfd7039fa5c876e10dc32fe
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/154800
Reviewed-by: Alexander Aprelev <aam@google.com>
2020-07-17 04:37:48 +00:00
Ben Konyi bc4cb123a8 Reland "[ VM / DartDev ] Launch DartDev in an isolate within a single main Dart process"
This CL changes how DartDev is run and how the run command handles executing a Dart program (will port additional commands in a separate CL). Rather than using DartDev to spawn a child process to run user code, the VM will instead launch a DartDev isolate after doing some VM options processing. DartDev will communicate information like exit codes and script/arg pairs with the VM via isolate ports. Once DartDev runs to completion and notifies the VM that a script should be run, the VM will move on to spawning another isolate with user code and continue executing in the same VM process.

By moving DartDev into an isolate within the same process that user code will eventually run in we're able to resolve the following issues that arose due to signal handling and IPC issues:

VM hangs when --enable-vm-service is supplied and there are compile time errors (https://github.com/dart-lang/sdk/issues/42630)
Dart daemon spinning in exit code handler / zombie Dart processes (https://github.com/dart-lang/sdk/issues/41978)
Signal handling in children of 'dartdev run' is problematic (https://github.com/dart-lang/sdk/issues/42092)

This reverts commit 3849b5061c.

Change-Id: I4fd3ba33840771a9f284d733c4a25fac6cde64ca
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/154706
Reviewed-by: Siva Annamalai <asiva@google.com>
2020-07-17 00:54:11 +00:00
Martin Kustermann f955b82a92 [vm/compiler] Support unboxing of return values of getters
This CL adds support for unboxing of return values of getters and
therefore completes the work on unboxing support for normal members
(closures are still missing).

As with existing unboxing support for methods and setters, we utilize
TFA information to proof a getter will always return non-nullable
int/double.

We then make such a getter return unboxed int/double. If there are
dynamic calls to the getter a dyn:get:* forwarder will be created
which performs boxing of the return value.

Overall this reduces RX by eliminating BoxInt64 instructions. It
sometimes increases metadata due to more dyn:get:* function objects.

=> On our main size benchmark targets show no significant change.

Issue https://github.com/dart-lang/sdk/issues/40876

Change-Id: If7450ef7e5e3fc9c2e0eaa6b86ffa817699a7e17
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/154329
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Tess Strickland <sstrickl@google.com>
2020-07-16 20:26:04 +00:00
Ben Konyi 3849b5061c Revert "[ VM / DartDev ] Launch DartDev in an isolate within a single main Dart process"
This reverts commit ffe258d2d4.

Reason for revert: Failures on bots

Original change's description:
> [ VM / DartDev ] Launch DartDev in an isolate within a single main Dart process
> 
> This CL changes how DartDev is run and how the run command handles executing a Dart program (will port additional commands in a separate CL). Rather than using DartDev to spawn a child process to run user code, the VM will instead launch a DartDev isolate after doing some VM options processing. DartDev will communicate information like exit codes and script/arg pairs with the VM via isolate ports. Once DartDev runs to completion and notifies the VM that a script should be run, the VM will move on to spawning another isolate with user code and continue executing in the same VM process.
> 
> By moving DartDev into an isolate within the same process that user code will eventually run in we're able to resolve the following issues that arose due to signal handling and IPC issues:
> 
> VM hangs when --enable-vm-service is supplied and there are compile time errors (https://github.com/dart-lang/sdk/issues/42630)
> Dart daemon spinning in exit code handler / zombie Dart processes (https://github.com/dart-lang/sdk/issues/41978)
> Signal handling in children of 'dartdev run' is problematic (https://github.com/dart-lang/sdk/issues/41978)
> 
> Change-Id: I1c6b1425831b691ad20284716aa80f817dbaf607
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/152588
> Commit-Queue: Ben Konyi <bkonyi@google.com>
> Reviewed-by: Siva Annamalai <asiva@google.com>
> Reviewed-by: Ryan Macnak <rmacnak@google.com>

TBR=bkonyi@google.com,rmacnak@google.com,asiva@google.com

Change-Id: Idb1d24a4524bdc3ccfb199a82710f3c0d9db539a
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/154702
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2020-07-16 19:50:57 +00:00
Ben Konyi ffe258d2d4 [ VM / DartDev ] Launch DartDev in an isolate within a single main Dart process
This CL changes how DartDev is run and how the run command handles executing a Dart program (will port additional commands in a separate CL). Rather than using DartDev to spawn a child process to run user code, the VM will instead launch a DartDev isolate after doing some VM options processing. DartDev will communicate information like exit codes and script/arg pairs with the VM via isolate ports. Once DartDev runs to completion and notifies the VM that a script should be run, the VM will move on to spawning another isolate with user code and continue executing in the same VM process.

By moving DartDev into an isolate within the same process that user code will eventually run in we're able to resolve the following issues that arose due to signal handling and IPC issues:

VM hangs when --enable-vm-service is supplied and there are compile time errors (https://github.com/dart-lang/sdk/issues/42630)
Dart daemon spinning in exit code handler / zombie Dart processes (https://github.com/dart-lang/sdk/issues/41978)
Signal handling in children of 'dartdev run' is problematic (https://github.com/dart-lang/sdk/issues/41978)

Change-Id: I1c6b1425831b691ad20284716aa80f817dbaf607
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/152588
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2020-07-16 19:03:24 +00:00
Alexander Markov 0ac6ce5f9d [vm/aot/nnbd] Avoid deduplicating mixins with different NNBD modes
CFE adds signature members to classes based on the NNBD mode of
an enclosing library, so identical anonymous mixin applications
in libraries with different NNBD modes could end up being different.

This change fixes mixin deduplication transformation to take
NNBD mode of anonymous mixin applications into account.

Fixes https://github.com/dart-lang/sdk/issues/42656

Change-Id: Ib83ae55f8193177012fa1a592fecf381ca8fdbff
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/154164
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2020-07-14 18:27:10 +00:00
Johnni Winther 76a4ae2931 [cfe] Ensure legacy result types for invocation and access in opt-out libraries
Closes #42660

Change-Id: Ied66fc6c704852d7ab7ad8fde0c78e04be6b9b0d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/154005
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2020-07-14 11:24:44 +00:00
Jens Johansen e8d3389eb5 [VM] Expression compilation when loaded from dill (part 2)
Previous version
(landed via https://dart-review.googlesource.com/c/sdk/+/135683)
only worked if the dill was loaded via
Dart_LoadScriptFromKernel where script_kernel_size was set,
and when the platform dill could be loaded from a file called the right
thing.

This CL makes it work for Dart_LoadLibraryFromKernel too and allows
the VM to send the platform along (explicitly or implicitly) and only
tries to load the platform from a file with the right name if no
platform is given in any of the inputs.

This should fix http://b/148776866

Change-Id: I62317400a932b7dcd9e126a5a88907d507f9d658
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/153609
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2020-07-09 14:55:11 +00:00
Alexander Markov 6f6b1f8818 [vm] Rename --null-safety option to --sound-null-safety
Deprecated option --null-safety still remains in order to allow
graceful migration.

Fixes https://github.com/dart-lang/sdk/issues/41853

Change-Id: Ie47b1bebc9dd6532658a60743ecb85dc7fdc108c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/153660
Reviewed-by: Siva Annamalai <asiva@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2020-07-09 01:37:23 +00:00
Alexander Markov bfd15821a7 [vm] Specialize List.generate factory constructor invocations
List.generate could return both growable and fixed-size lists.
This change specializes invocations of List.generate when value of
'growable' argument is known (constant or omitted), so it becomes
possible to infer actual type returned by the factory.

This becomes more important with null safety as List.generate is used
more often to initialize lists of non-nullable elements.

Migrated NNBD benchmarks in AOT mode on x64:
Sudoku +11%
DartMicroBenchMM.{Min,Max}Lib +11-13%
DartMicroBenchMM.{Min,Max}Code +19-27%
ForInGeneratedLoop +19%
ForEachLoop +85%
ForInLoop +64%
ForLoop +680%

This change also includes test for inferred types of various List
constructors.

Change-Id: I801231b0a70e3aa8fb14ec9fe749f1dd420b1b9c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/153388
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2020-07-08 18:29:25 +00:00
Alexander Markov 05003ab60d [vm/gen_kernel] Support package_config.json when converting main script URI to package URI
Fixes https://github.com/dart-lang/sdk/issues/42614

Change-Id: I6253412677b6954be36f519a193bed34004a1ff3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/153541
Reviewed-by: Jonah Williams <jonahwilliams@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2020-07-08 04:15:00 +00:00
Alexander Markov c5ea3e85a0 [vm/nnbd] Further specialize invocations of List.filled factory
If 'growable' argument of List.filled factory invocation is known at
compile time we can replace it with more specialized constructors
creating growable or fixed-size lists. This results in a more accurate
inferred type and more efficient code which uses the created list.

Fixes https://github.com/dart-lang/sdk/issues/42551

Change-Id: I427e1bdb8a0f2a83410a9533050d19cbca2d27d6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/153064
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2020-07-03 23:19:02 +00:00
Aske Simon Christensen 0549295eb4 [vm/aot] Partition table selector IDs based on hierarchy connectedness.
Compared to assigning selector IDs purely by name, this improves the
packing of selector rows, reducing the in-memory size of the dispatch
table by typically around 20% (75k memory usage reduction for Flutter
Gallery on ARM64).

It also improved tree shaking of methods called (or rather, not called)
via dispatch table calls, reducing the total snapshot sizes of Flutter
benchmarks by up to 2.1% (Flutter Gallery: ARM 1.8%, ARM64 2.1%).

Fixes https://github.com/dart-lang/sdk/issues/40660
Fixes https://github.com/dart-lang/sdk/issues/41647

Change-Id: Ia9ecfb0818b301bcbad631c377f3910b0a5956de
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/152323
Commit-Queue: Aske Simon Christensen <askesc@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2020-06-30 14:03:37 +00:00
Alexander Markov 9672b22099 [vm/aot/tfa] More accurate inference of results of field getters
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>
2020-06-25 00:09:58 +00:00
Jens Johansen b41471670e [CFE] Use experiment flag 'alternative-invalidation-strategy'
Change-Id: Ib7358793c8413aa0a67134e3a00fe1a6c8c4bbb8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/150342
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2020-06-24 08:35:54 +00:00
Alexander Markov 467c98b846 [vm/aot/tfa] Re-implement protobuf-aware tree shaker inside TFA
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>
2020-06-23 21:17:03 +00:00
Vyacheslav Egorov 117df0e98b [vm/tools] Move snapshot analysis tool to its own package.
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>
2020-06-23 13:14:41 +00:00
Michael Thomsen f0c87e9f21 Clean up no-publish comments in pubspecs
Change-Id: I6cc1ab404de75cd02183b862842198c85b6d9256
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/152005
Reviewed-by: Alexander Thomas <athom@google.com>
2020-06-23 10:34:09 +00:00
Vyacheslav Egorov 04a35987b0 [vm/tool] Add legend to snapshot_analysis compare/summary output.
Issue https://github.com/dart-lang/sdk/issues/41249

Change-Id: I9939ebc6bbebb32284dd55692d65482fc3ae3f2f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151387
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2020-06-22 21:50:36 +00:00
Vyacheslav Egorov 88ad237f96 [vm/tool] Support V8 profiles in snapshot_analysis treemap
Issue https://github.com/dart-lang/sdk/issues/41249

Cq-Include-Trybots: luci.dart.try:pkg-linux-debug-try,pkg-linux-release-try,pkg-win-release-try,pkg-mac-release-try
Change-Id: Ic5a3b4054f3eda6dfc5f9bf48dca97dd6a6deac6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151386
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2020-06-22 21:44:36 +00:00
Vyacheslav Egorov 4aaf13adfd [vm/tool] Improvements to snapshot_analysis summary command.
It now supports filtering by name and displaying additional
histogram bucketed by object type.

Issue https://github.com/dart-lang/sdk/issues/41249

Cq-Include-Trybots: luci.dart.try:pkg-linux-debug-try,pkg-linux-release-try,pkg-win-release-try,pkg-mac-release-try
Change-Id: I5b0dcdbea0fc0b4af36ac5a6331057406087a409
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151385
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2020-06-22 21:44:36 +00:00
Vyacheslav Egorov 91c80bb798 [vm/tool] Support reading V8 profiles in snapshot_analysis tool.
We reconstruct ProgramInfo tree structure from the snapshot
by applying a simple graph algorithm, which takes parts of the
snapshot with clear ownership (e.g. library, class, function objects)
and then attempts to attribute the rest of the snapshot to these
clearly owned objects based on reachability.

Issue https://github.com/dart-lang/sdk/issues/41249

Cq-Include-Trybots: luci.dart.try:pkg-linux-debug-try,pkg-linux-release-try,pkg-win-release-try,pkg-mac-release-try
Change-Id: I17c0f8323ee9092a2214b18bd948ff51fa2ccc49
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151384
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2020-06-22 21:38:16 +00:00
Siva Annamalai d46a696957 Revert "Reland : [VM/Runtime] Cleanup package config initialization code"
This reverts commit 03777dba31.

Reason for revert: Failures in couple of bots

Original change's description:
> Reland : [VM/Runtime] Cleanup package config initialization code
> 
> - Use _Init function for initialization of package config
> - Remove DartUtils::SetWorkingDirectory, SingleArgDart_Invoke,
> 
>   DartUtils::SetupPackageConfig
> - Rename Loader::InitForSnapshot to Loader::Init
> - Remove _setPackagesConfig, _setWorkingDirectory from builtin library
> - Rename _setPackagesMap to _setPackagesConfig
> Change-Id: I1e4a25e79706d7764247c9fbfcc8e8ce3231343c
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151633
> Reviewed-by: Alexander Aprelev <aam@google.com>
> Commit-Queue: Siva Annamalai <asiva@google.com>

TBR=aam@google.com,asiva@google.com

Change-Id: Ibea8c35fe310ac7708f00bb9ffd58715b6924cb5
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151869
Reviewed-by: Siva Annamalai <asiva@google.com>
Auto-Submit: Siva Annamalai <asiva@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
2020-06-20 08:02:53 +00:00
Zach Anderson 1a8190db49 Add --track-widget-creation to kernel_front_end.dart
Change-Id: I2ec8dbbee978a68c4e10ddb38501a4e4d2b5e004
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151868
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2020-06-20 06:54:39 +00:00
asiva 03777dba31 Reland : [VM/Runtime] Cleanup package config initialization code
- Use _Init function for initialization of package config
- Remove DartUtils::SetWorkingDirectory, SingleArgDart_Invoke,

  DartUtils::SetupPackageConfig
- Rename Loader::InitForSnapshot to Loader::Init
- Remove _setPackagesConfig, _setWorkingDirectory from builtin library
- Rename _setPackagesMap to _setPackagesConfig
Change-Id: I1e4a25e79706d7764247c9fbfcc8e8ce3231343c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151633
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
2020-06-20 05:50:49 +00:00
Ryan Macnak 6cc943957b [vm] Compute a partitioning of the program into loading units.
The partitioning has the property that for every reference from loading unit S to unit T, either
 - the reference is through a deferred prefix, or
 - T is guarenteed to be loaded before S

The partitioning is constructed by cutting the dominator tree of the library import graph at deferred imports. It is suboptimal if there are deferred imports to multiple libraries in a connected component, but the expected use case involves loading units with a single deferred entry.

Bug: https://github.com/dart-lang/sdk/issues/41974
Change-Id: I3c49044ae19112525f197b077b36e4ce874b81ac
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151470
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2020-06-19 21:35:47 +00:00
Vyacheslav Egorov 73e95f7f49 [vm/tool] Add snapshot_analysis summary command.
This CL also refactors ProgramInfo making it less structured - we remove
individual node types (LibraryInfo/FunctionInfo) and represent
the information using ProgramInfoNode class instead.

Issue https://github.com/dart-lang/sdk/issues/41249

Cq-Include-Trybots: luci.dart.try:pkg-linux-debug-try,pkg-linux-release-try,pkg-win-release-try,pkg-mac-release-try
Change-Id: I0156ae75f48a41b7689790860267ac88706d55c0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151227
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2020-06-18 11:57:13 +00:00
Daco Harkes 7eac9f355e [vm/ffi] Expose a subset of dart_(native_)api.h for dynamic linking.
This CL introduces dart_api_dl.h which exposes a subset of dart_api.h
and dart_native_api.h for dynamic linking at runtime through the FFI.
Dynamic linking is done through including dart_api_dl.cc in a shared
library and passing NativeApi.initializeApiDLData to the init function.

This CL also includes Native API versioning to deal with possible
version skew between native api version against which native libraries
are compiled and the version in the DartVM the code is run on.

The subset of symbols in the CL includes handle related symbols, error
related symbols, handle scope symbols, and native port sumbols.

Design: http://go/dart-ffi-expose-dart-api

Closes: https://github.com/dart-lang/sdk/issues/40607
Closes: https://github.com/dart-lang/sdk/issues/36858
Closes: https://github.com/dart-lang/sdk/issues/41319
Closes: https://github.com/flutter/flutter/issues/46887
Closes: https://github.com/flutter/flutter/issues/47061

Misc:
Closes: https://github.com/dart-lang/sdk/issues/42260

Change-Id: I9e557808dbc99b341f23964cbddbb05f26d7a6c5
Cq-Include-Trybots: luci.dart.try:vm-ffi-android-debug-arm-try,vm-ffi-android-debug-arm64-try,app-kernel-linux-debug-x64-try,vm-kernel-linux-debug-ia32-try,vm-kernel-win-debug-x64-try,vm-kernel-win-debug-ia32-try,vm-kernel-precomp-linux-debug-x64-try,vm-dartkb-linux-release-x64-abi-try,vm-kernel-precomp-android-release-arm64-try,vm-kernel-asan-linux-release-x64-try,vm-kernel-msan-linux-release-x64-try,vm-kernel-precomp-msan-linux-release-x64-try,vm-kernel-linux-release-simarm-try,vm-kernel-linux-release-simarm64-try,vm-kernel-precomp-android-release-arm_x64-try,vm-kernel-precomp-obfuscate-linux-release-x64-try,dart-sdk-linux-try,analyzer-analysis-server-linux-try,analyzer-linux-release-try,front-end-linux-release-x64-try,vm-kernel-precomp-win-release-x64-try,vm-kernel-mac-debug-x64-try,vm-precomp-ffi-qemu-linux-release-arm-try,vm-kernel-nnbd-linux-debug-x64-try,analyzer-nnbd-linux-release-try,front-end-nnbd-linux-release-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/145592
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2020-06-18 07:30:43 +00:00
Vyacheslav Egorov 80fed2cfc2 [vm/tool] Move snapshot analysis commands into their own directory.
Issue https://github.com/dart-lang/sdk/issues/41249

Change-Id: I3ce17d2ca2075e551c9e72e09731f99e7e0f9e69
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151226
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2020-06-17 20:57:03 +00:00
Tess Strickland c45c07592a [vm] Test disassembly in v8_snapshot_profile_writer_test separately.
Disassembling on every run makes it difficult to get an idea of which
specific configuration failed. Instead, just pick a configuration that
already succeeded and test that configuration with disassembly
separately so that it's clear if the disassembly was what caused the
failure.

Also add reasons to Expect.isTrue/isFalse uses in
package:vm/v8_snapshot_profile.dart. Now we don't have to track down the
specific line to find out what failed when reading logs. Another benefit
is that the error message now includes the values involved in the
failure and not just "Expect.isTrue(false)" or "Expect.isFalse(true)".

Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-nnbd-linux-release-x64-try,vm-kernel-precomp-linux-release-x64-try,vm-kernel-precomp-linux-product-x64-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-release-simarm_x64-try
Change-Id: I3d4b533f4df041dfcced4eaeb8bc5729dfad0b82
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151502
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
2020-06-17 11:11:43 +00:00
asiva 4b9aa2bd7e Revert "[VM/Runtime] Cleanup package config initialization code"
This reverts commit 29e93bcdbd.

Reason for revert: Windows bots are failing with package resolution
errors. Looks like we are missing a windows path sanitization step.

Change-Id: Ib56f7e926b4f385fa3fde74c9c71947f64b8be1c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151469
Reviewed-by: Siva Annamalai <asiva@google.com>
2020-06-17 00:03:19 +00:00
asiva 29e93bcdbd [VM/Runtime] Cleanup package config initialization code
- Use _Init function for initialization of package config
- Remove DartUtils::SetWorkingDirectory, SingleArgDart_Invoke,
  DartUtils::SetupPackageConfig
- Rename Loader::InitForSnapshot to Loader::Init
- Remove _setPackagesConfig, _setWorkingDirectory from builtin library
- Rename _setPackagesMap to _setPackagesConfig
Change-Id: I0b83574593fa95e1b948134fcd4a7b4858ea19c2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151045
Commit-Queue: Siva Annamalai <asiva@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2020-06-16 23:24:26 +00:00
Johnni Winther 7fce125300 [cfe,kernel] Add AstPrinter
This CL adds a Node.toText method together with an AstPrinter. These
facility and better toString implementation on AST nodes while allowing
for toString independent printing of AST to use in testing. This also
add support for an integrated toString of custom/internal nodes.

Some work is still needed in bringing the toString implementation on
all nodes to the old quality, and not all internal nodes have
customized textual representations yet. This work is left for future
CLs.

Change-Id: Ib0bf8a0bc02f489dfacdc8aa5f96da9c52f26058
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/150923
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2020-06-16 17:15:10 +00:00
Alexander Markov badc77239a [vm/aot] Avoid unbinding canonical names in AOT transformations
AOT transformations (mixin deduplication and TFA tree shaker) were
using CanonicalName.unbind() in order to make sure that kernel
writer will not be able to write dangling references to the deleted
classes or members (to detect such dangling references earlier).

This conflicts with lazy reading from a kernel file if --from-dill
option is used: lazy reader may read a reference to such class after
unbind() and it creates a new Reference object for such canonical name.
This causes crash later when the fresh Reference is used as it doesn't
have Class node filled in.

The solution is to avoid calling CanonicalName.unbind().
Instead, it is enough to nullify node.reference.canonicalName, which
won't break CanonicalName.reference used by lazy reader.

This crash can be reproduced on tests/language_2/vm/regress_flutter_55345_test.dart
if it is compiled in AOT mode using 2-step kernel generation.

Bug: b/158853113
Change-Id: Ib2004dbbbda85d9f56adc56b48882f4ef08869a7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151120
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2020-06-15 22:00:42 +00:00
Dmitry Stefantsov 929d5e4a98 [cfe,ddc,dart2js,vm] Add FutureOrType
This CL is the sum of the following 5 CLs:
* https://dart-review.googlesource.com/c/sdk/+/149297/
* https://dart-review.googlesource.com/c/sdk/+/149299/
* https://dart-review.googlesource.com/c/sdk/+/149320/
* https://dart-review.googlesource.com/c/sdk/+/149321/
* https://dart-review.googlesource.com/c/sdk/+/149323/

The reason for landing the 5 CLs as one CL is to prevent potential
troubles with bisecting over the branch because the change is fully
functional only with all 5 CLs.

Closes #40123.

Bug: https://github.com/dart-lang/sdk/issues/40123
Change-Id: Ice52250a98acfe455b1d7fa5bb0624c115ca5dac
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/150934
Commit-Queue: Dmitry Stefantsov <dmitryas@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2020-06-15 12:18:46 +00:00
Daco Harkes 6544c69e23 [vm/ffi] Convert Objects to Dart_Handles in FFI calls
This includes support for calling Dart_PropagateError in native code
when doing FFI calls, and catching uncaught exceptions with Dart_IsError
when doing FFI callbacks.

The support for Dart_PropagateError adds a catch entry to the FFI
trampoline, which prevents inlining these trampolines in AOT. This
regresses the FfiCall benchmarks by 1-2% in AOT.

In addition, Dart_PropagateError requires maintaining a bit whether we
entered native/VM code from generated code through FFI or not. That way
we can do the proper transition on the exception path. When entering
generated code, we store this bit on the stack, right after the entry
frame.

Design: http://go/dart-ffi-handles

Issue: https://github.com/dart-lang/sdk/issues/36858
Issue: https://github.com/dart-lang/sdk/issues/41319

Change-Id: Idfd7ff69132fb29cc730931a4113d914d4437396
Cq-Include-Trybots: luci.dart.try:vm-ffi-android-debug-arm-try,vm-ffi-android-debug-arm64-try,app-kernel-linux-debug-x64-try,vm-kernel-linux-debug-ia32-try,vm-kernel-win-debug-x64-try,vm-kernel-win-debug-ia32-try,vm-kernel-precomp-linux-debug-x64-try,vm-dartkb-linux-release-x64-abi-try,vm-kernel-precomp-android-release-arm64-try,vm-kernel-asan-linux-release-x64-try,vm-kernel-linux-release-simarm-try,vm-kernel-linux-release-simarm64-try,vm-kernel-precomp-android-release-arm_x64-try,vm-kernel-precomp-obfuscate-linux-release-x64-try,dart-sdk-linux-try,analyzer-analysis-server-linux-try,analyzer-linux-release-try,front-end-linux-release-x64-try,vm-kernel-precomp-win-release-x64-try,vm-kernel-mac-debug-x64-try,vm-precomp-ffi-qemu-linux-release-arm-try,vm-kernel-nnbd-linux-debug-x64-try,analyzer-nnbd-linux-release-try,front-end-nnbd-linux-release-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/145591
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2020-06-12 11:14:22 +00:00
Vyacheslav Egorov 20d2917f84 [vm/tool] Improvements to snapshot_analysis 'compare' command.
Introduce helper classes and methods for constructing program
hierarchy from a flat list of symbols as well as methods for
diffing and bucketing the program hierarchies.

Issue https://github.com/dart-lang/sdk/issues/41249

Cq-Include-Trybots: luci.dart.try:pkg-linux-debug-try,pkg-linux-release-try,pkg-win-release-try,pkg-mac-release-try
Change-Id: Ieb6ad1ccd8bc7fa1181d31e78ac351369ede5f81
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/150101
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2020-06-11 12:30:49 +00:00
Alexander Markov 2bd7cbb151 [vm/kernel] Add options to generate Fuchsia manifest to gen_kernel tool
This change adds options
  --manifest
  --component-name
  --data-dir
to gen_kernel tool.

After that, gen_kernel becomes a drop-in replacement for Fuchsia's
kernel compiler.

Change-Id: I8370b4224d1fc1973c8a850ea1e46defdb2cbac4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/150690
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2020-06-11 05:50:55 +00:00