Commit graph

1401 commits

Author SHA1 Message Date
Alexander Markov
cd40fb4318 [vm/aot/tfa] Tree-shake default values of parameters
This change teaches tree shaker to drop default values of parameters of
methods if their bodies are dropped (for example if a method is only
used as an interface target).

TEST=pkg/vm/testcases/transformations/type_flow/transformer/regress_46461.dart
Fixes https://github.com/dart-lang/sdk/issues/46461

Change-Id: Icb50d7ec6acd91e68ceaa3b826c15d09d1c05701
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/204840
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2021-06-24 20:36:09 +00:00
Alexander Markov
a9757d177a [vm, kernel] Cleanup support for old invocation nodes from the VM
This change concludes switching to the new invocation nodes in the VM.
Support for the old invocation nodes (MethodInvocation, PropertyGet
and PropertySet) is removed from the VM and VM-specific kernel
transformations.

TEST=ci

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

Change-Id: I0717732feb1b9c6ebdf0f6079ed42a90d00970a5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/204741
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2021-06-24 16:17:50 +00:00
Anna Gringauze
387333c5bb Keep connection open until http response is read in HttpAwareFileSystem
We are seeing CI flakes in webdev when using expression_compiler_worker
in tests involving expression evaluation, for example, see linux tests
for dwds in the following PR:

https://github.com/dart-lang/webdev/pull/1343

The logs show that HttpFileSystemEntity.exists fails due to a broken
pipe, which we suspect is due to http client closed too early.

This change is an attempt to fix the problem by
- logging exceptions thrown in expression compiler worker
- awaiting for the request to be read before closing http client in
  HttpFileSystemEntity.

TEST=pkg/dev_compiler/test/expression_compiler/asset_file_system_test.dart

See investigation of the CI issue in:
https://github.com/dart-lang/webdev/issues/1345


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

Change-Id: Iaf98f08e8ebb618bf8365bd497f01ae685f0d3f2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/203841
Commit-Queue: Anna Gringauze <annagrin@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2021-06-18 01:56:21 +00:00
Alexander Markov
93c812e5a7 [vm/kernel] Revise call site metadata for new invocation nodes
Call site attributes metadata is used to pass receiver static type
from kernel AST to the VM. In certain cases, call site metadata is
superseded by the new invocation nodes. This change revises how call
site attributes metadata is generated in call site annotator and
used in the VM for the new invocation nodes.

* When building flow graph for FunctionInvocation,
  the decision to generate unchecked calls is now done by
  looking only at the function access kind, without taking static
  receiver type into account. Call site annotator now verifies that
  static receiver type matches function access kind for
  FunctionInvocation nodes to make sure nothing is lost during this
  transition. Also, flow graph builder asserts that
  function access kind is either Function or FunctionType.

* Call site metadata is no longer generated for LocalFunctionInvocation
  and FunctionInvocation nodes, as it is no longer used by the VM.

* Call site annotator now verifies that InstanceInvocation nodes
  cannot be used for unchecked closure calls. Flow graph builder no
  longer recognizes unchecked closure calls for InstanceInvocation
  and DynamicInvocation nodes.

* When generating flow graph for DynamicInvocation and DynamicSet,
  call site metadata is no longer taken into account (metadata is not
  generated by call site annotator for these nodes).
  Also, 'this' receiver is not recognized for DynamicInvocation and
  DynamicSet nodes as it may potentially violate dynamic call semantics.

TEST=ci

Issue: https://github.com/dart-lang/sdk/issues/45340
Change-Id: Ia8c5e547965ac8d7a17908d4be4bd048e5cfb23f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/203668
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2021-06-16 18:06:17 +00:00
Alexander Markov
e3d51d0c10 [vm/kernel] Generate new invocation nodes in ffi-native transformation
This change replaces generation of old invocation AST nodes
(MethodInvocation) with new nodes (FunctionInvocation) in the recently
added ffi native transformation.
The old nodes will be deleted eventually.

Follow-up to https://dart-review.googlesource.com/c/sdk/+/170092.

TEST=ci

Issue: https://github.com/dart-lang/sdk/issues/45340
Change-Id: Ifbf882fbc96bb1307fbe2aac334b7427276146c8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/203740
Reviewed-by: Clement Skau <cskau@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2021-06-16 16:49:37 +00:00
Clement Skau
2f916ad807 [vm/ffi] Adds @FfiNative() support
Adds support for marking external functions as @FfiNative's,
which will be called using fast FFI calls.

Resolution happens by calling out to a new embedder provided
Dart_FfiNativeResolver which the embedder can specify via
Dart_SetFfiNativeResolver.

TEST=vm/cc/DartAPI_FfiNativeResolver

Bug: https://github.com/dart-lang/sdk/issues/43889
Change-Id: I3cfff360b05314499a81444b90f4ea0a1b937b0b
Cq-Do-Not-Cancel-Tryjobs: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/170092
Commit-Queue: Clement Skau <cskau@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2021-06-15 05:58:39 +00:00
Alexander Markov
dd1f384f23 [vm] Generate new invocation node in the VM-specific transformations
This change updates the remaining places in the VM-specific
transformations to generate new invocation nodes (InstanceInvocation,
EqualsNull, LocalFunctionInvocation) instead of old invocation
nodes such as MethodInvocation.
The old nodes will be deleted eventually.

TEST=existing tests

Issue: https://github.com/dart-lang/sdk/issues/45340
Change-Id: I00a845e8191f79584c250f57214dd5fb4d6241ed
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/203443
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2021-06-14 17:09:33 +00:00
Alexander Markov
5f8a9d33d2 [vm/aot/tfa] More robust handling of annotations in TFA
Apparently it is possible for annotations to contain InvalidExpression
AST nodes, not just ConstantExpression
(see https://github.com/flutter/flutter/issues/83466#issuecomment-856697378).

This change improves robustness of TFA by ignoring (and cleaning) all
annotations which are not ConstantExpression, instead of crashing on
them.

TEST=none
(I wasn't able to reproduce the problem and replicate the situation
where front-end generates InvalidExpression nodes.)

Change-Id: I1dbd55515f1e861488f6cc46eea50a2ef31ab564
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/203283
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2021-06-11 17:42:56 +00:00
Alexander Markov
6e989dfe35 [vm/kernel] Generate new invocation nodes in async transformers
This change replaces generation of old invocation AST nodes
(such as PropertyGet, PropertySet and MethodInvocation) in async
transformers with new nodes (InstanceGet, InstanceSet,
InstanceInvocation, LocalFunctionInvocation).
The old nodes will be deleted eventually.

TEST=existing tests

Issue: https://github.com/dart-lang/sdk/issues/45340
Change-Id: I8c2ead9509cfd2def2f75f9d82dc13b2a9490fdf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/202801
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Clement Skau <cskau@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
2021-06-09 22:14:51 +00:00
Clement Skau
f7db1b0d4c [vm] ffi_use_sites: Adds TreeNode.location null check.
TreeNode.location may return null "if the node is orphaned".
This happens for instance in cases where nodes can't use a
fileOffset due to patch files (see #31579).

This will in turn obscure other errors as the error reporting
code will crash trying to access members on null.

TEST=existing.

Bug: https://github.com/dart-lang/sdk/issues/31579
Change-Id: I85b720ecf2cb09e46cbd1296671be523567d5a83
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/202920
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Clement Skau <cskau@google.com>
2021-06-09 09:49:31 +00:00
Ryan Macnak
84e6d4a4e8 [vm] Make use of the new TypedDataBase to avoid redundant code in the runtime.
Reduces VM code size by about 18k.

TEST=ci
Change-Id: Ic0dbdb6a7807a0f0d37333c6f32bed5cb3e7b905
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/202543
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2021-06-08 19:15:38 +00:00
Alexander Markov
37806ba461 Cleanup toString transformer
This is a final cleanup of old version of toString removal transformer
which was moved to pkg/vm in https://dart-review.googlesource.com/c/sdk/+/200525.

Also, this change removes handling of _KeepToString annotation class
after dart:ui @keepToString switched to use pragma and _KeepToString
was removed.

TEST=existing tests

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

Change-Id: I7208ec70e6703d25b93d6ebbb306c18bae4b6987
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/201162
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2021-06-07 16:56:22 +00:00
Daco Harkes
939960ca0c [cfe/ffi] Remove dead code
TEST=tests/ffi

Change-Id: Idf2a81d186393aa507ef66c162cd9f080b9b534d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/201404
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2021-05-26 15:29:00 +00:00
Daco Harkes
1d38c98b69 [vm/ffi] Fix CFE crash on missing Array sizes
Closes: https://github.com/dart-lang/sdk/issues/46085

TEST=tests/ffi/regress_46085_test.dart

Change-Id: I04e05baccb6eb490ef32702677e3d5c1bb815560
Cq-Include-Trybots: luci.dart.try:vm-kernel-nnbd-linux-debug-x64-try
Fixed: 46085
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/201264
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Clement Skau <cskau@google.com>
2021-05-26 11:02:22 +00:00
Alexander Markov
7e76ac60b2 [vm] Generate new invocation node is FFI transformers
This change replaces generation of old invocation AST nodes
(such as PropertyGet, PropertySet and MethodInvocation) in FFI
transformers with new nodes (InstanceGet, InstanceSet,
InstanceInvocation). The old nodes will be deleted eventually.

TEST=existing tests

Issue: https://github.com/dart-lang/sdk/issues/45340
Change-Id: I7c01cc23c257514b4c89295a31ce63c947c18e23
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/201222
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2021-05-26 01:21:12 +00:00
Clement Skau
4d5055805f [VM/FFI] Adds FFI leaf calls.
This CL adds FFI leaf calls by adding `lookupFunction(.., isLeaf)`
and `_asFunctionInternal(.., isLeaf)`, which generate FFI leaf calls.
These calls skip a lot of the usual frame building and generated <->
native transition overhead.

`benchmark/FfiCall/` shows a 1.1x - 4.3x speed-up between the regular
FFI calls and their leaf call counterparts (JIT, x64, release).

TEST=Adds `tests/ffi{,_2}/vmspecific_leaf_call_test.dart`. Tested FFI tests.

Closes: https://github.com/dart-lang/sdk/issues/36707
Cq-Include-Trybots: luci.dart.try:vm-precomp-ffi-qemu-linux-release-arm-try,vm-ffi-android-release-arm64-try,vm-ffi-android-release-arm-try,vm-ffi-android-product-arm64-try,vm-ffi-android-product-arm-try,vm-ffi-android-debug-arm64-try,vm-ffi-android-debug-arm-try,vm-kernel-linux-debug-ia32-try,vm-kernel-win-debug-ia32-try,vm-kernel-win-debug-x64-try,vm-kernel-win-release-x64-try,vm-kernel-mac-debug-x64-try,vm-kernel-precomp-nnbd-mac-release-simarm64-try,vm-kernel-precomp-android-release-arm64-try,vm-kernel-precomp-asan-linux-release-x64-try,vm-kernel-precomp-linux-release-simarm_x64-try,vm-kernel-precomp-obfuscate-linux-release-x64-try,vm-kernel-precomp-ubsan-linux-release-x64-try,vm-kernel-precomp-tsan-linux-release-x64-try,vm-kernel-precomp-win-release-x64-try,vm-precomp-ffi-qemu-linux-release-arm-try,vm-kernel-reload-rollback-linux-debug-x64-try,vm-kernel-reload-linux-debug-x64-try
Bug: https://github.com/dart-lang/sdk/issues/36707
Change-Id: Id8824f36b0006bf09951207bd004356fe6e9f46e
Cq-Do-Not-Cancel-Tryjobs: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/179768
Commit-Queue: Clement Skau <cskau@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2021-05-21 11:12:02 +00:00
Alexander Markov
88021fd67a [vm] Enable new kernel AST invocation nodes for the VM, take 2
This change was already reviewed at
https://dart-review.googlesource.com/c/sdk/+/197586.

Bugfix is in the separate change:
https://dart-review.googlesource.com/c/sdk/+/199365.

TEST=ci

Issue: https://github.com/dart-lang/sdk/issues/45340
Change-Id: I4311909e4893af53e88895512f03d3ef84c6bc5f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/199366
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2021-05-20 18:53:45 +00:00
Daco Harkes
f18c1bfb84 [cfe/ffi] Fix user-defined getters
https://dart-review.googlesource.com/c/sdk/+/198281 introduced support
for incremental compilation to the FfiTransform. This included reading
fields from already transformed structs and unions.

However, fields which already had been transformed are indistinguishable
from user-defined getters.

So instead of re-reading the information from the fields, for already
transformed structs, we read the information from the
`vm:ffi:struct-fields` pragma on the struct class.

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

TEST=tests/ffi/regress_46004_test.dart
TEST=pkg/front_end/testcases/incremental/regress_46004.yaml

Change-Id: Iebffda037913e71349bba9685dc16e2f478a0e7b
Cq-Include-Trybots: luci.dart.try:vm-kernel-win-debug-x64-try,front-end-nnbd-linux-release-x64-try,front-end-linux-release-x64-try,vm-ffi-android-debug-arm64-try,vm-precomp-ffi-qemu-linux-release-arm-try
Fixed: 46004
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/200640
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Clement Skau <cskau@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2021-05-20 13:12:22 +00:00
Alexander Markov
b9a0c0dfba Add --delete-tostring-package-uri option to kernel compilers
This change adds toString transformation to gen_kernel and
frontend_server tools in Dart SDK.

The implementation and tests are derived from
pkg/frontend_server/lib/src/to_string_transformer.dart and
https://github.com/flutter/engine/tree/master/flutter_frontend_server/test.

In addition to _KeepToString in dart:ui, toString transformation
now supports @pragma('flutter:keep-to-string') to exclude
certain toString methods from the transformation without depending
on dart:ui.

pkg/frontend_server/lib/src/to_string_transformer.dart is not
cleaned up in this change yet as it is still used by Flutter
engine. Cleanup will be done after Flutter engine is cleaned up,
after it is switched to the implementation of toString transformer
added in this change.

This is also a step towards a unified kernel compiler
(https://github.com/dart-lang/sdk/issues/39126).

TEST=pkg/vm/test/transformations/to_string_transformer_test.dart

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

Change-Id: Icbfd3fa193d54f1fc6b2d7fa0bace82b3704f91f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/200525
Reviewed-by: Dan Field <dnfield@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2021-05-20 00:50:07 +00:00
Alexander Markov
b07305d2c3 [kernel] Visit/transform Typedef fields
Previously, certain fields of Typedef kernel AST nodes
were omitted from visitChildren(), transformChildren() and
transformOrRemoveChildren() and were not properly visited.

Also, the following related problems are fixed in this CL:
* parents of VariableDeclaration nodes in Typedef were not properly set;
* verifier didn't account for VariableDeclaration nodes in Typedefs.

TEST=existing tests

Change-Id: I4f9cb694ad9cacc9c20fe66e8a49f73f547ca245
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/96964
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2021-05-19 17:47:02 +00:00
Alexander Aprelev
95aab5b6e0 [vm/ffi] Use getter for sizeOf instead of static final field.
Static final fields don't get optimized well under jit lightweight isolate configuration: whether "a static final field was initialized"-check can not be optimized out with lightweight isolates.


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

TEST=FfiStruct.FieldLoadStore performance benchmark

Change-Id: Ieb739dd9855ff7774877d7984a918644ec36e1e2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/200320
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
2021-05-19 03:10:26 +00:00
Alexander Markov
fc15991ba7 [vm] Include constants into expectations of pkg/vm unit tests
TEST=existing tests

Change-Id: Ia7a7cde20d1e066bd551ed7a6e969d1fe27adc5d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/200041
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2021-05-15 16:31:59 +00:00
Alexander Markov
d39e794cc3 [vm/aot] Keep pragmas on VariableDeclaration nodes in tree shaker
VM can use pragmas on local functions, which are actually put on
VariableDeclaration nodes. This change teaches TFA tree shaker to
keep such pragmas.

TEST=pkg/vm/testcases/transformations/type_flow/transformer/pragmas.dart
Issue: https://github.com/dart-lang/sdk/issues/45987
Change-Id: Ic2db375a93b539a131eca2431bef0e317a4d1b2b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/199520
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2021-05-14 19:20:28 +00:00
Daco Harkes
3b9bd26f3e [vm/ffi] Union transform fix offsets
TEST=tests/ffi/regress_45988_test.dart

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

Change-Id: Ie8bf76bb2cc1781a4b59e508d0e5f2ada85d22a4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/199422
Reviewed-by: Clement Skau <cskau@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2021-05-12 09:50:00 +00:00
Alexander Markov
da4ff4e9a6 [vm/aot] Fix handling of annotations in tree shaker
Previously, annotations were not traced by global type flow analysis
(in order to avoid retaining classes which are only used in
annotations). Annotations were only traced during tree shaking
and references from such constants were treated much like
references from types. This handling of constants in annotations
conflicts with removal of fields, as tree shaker needs to know
which fields are retained upfront to be independent of the visiting
order. In a certain corner case (field was replaced with a getter
but was still used in a constant in annotation) that caused incorrect
AST and crash during serialization of AST.

In order to fix that, this change adds proper tracing through
annotations on members, classes and libraries, as if annotation
constants were used in the executable code. That also means
that annotation classes will be retained as allocated.
In order to compensate for that, a new pass is added before the global
analysis to clean all annotations except @ExternalName, @pragma
(used by the VM) and @TagNumber (used by protobuf tree shaking).

TEST=runtime/tests/vm/dart/regress_45968_test.dart
Fixes https://github.com/dart-lang/sdk/issues/45968

Change-Id: I998e4f7ec7da7b74e1738fc21b354a4ec9f0c071
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/199200
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2021-05-11 18:25:24 +00:00
Martin Kustermann
31364331e9 Revert "[vm] Enable new kernel AST invocation nodes for the VM"
This reverts commit 53e3c079b7.

Reason for revert: This change has seemingly caused errors of the form
```
stderr >> Unhandled exception:
stderr >> Invalid argument(s): Missing canonical name for Reference to <XXX>
stderr >> #0      BinaryPrinter.writeNullAllowedReference (package:kernel/binary/ast_to_binary.dart:894:9)
stderr >> #1      BinaryPrinter.visitTypedefType (package:kernel/binary/ast_to_binary.dart:2410:5)
stderr >> #2      TypedefType.accept (package:kernel/ast.dart:11115:42)
stderr >> #3      BinaryPrinter.writeNode (package:kernel/binary/ast_to_binary.dart:403:10)
stderr >> #4      BinaryPrinter.writeOptionalNode (package:kernel/binary/ast_to_binary.dart:496:7)
```

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

Original change's description:
> [vm] Enable new kernel AST invocation nodes for the VM
>
> TEST=ci
>
> Issue: https://github.com/dart-lang/sdk/issues/45340
> Change-Id: Ibb307d8df8ff4ae8f2efad177880634ec9e27905
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/197586
> Commit-Queue: Alexander Markov <alexmarkov@google.com>
> Reviewed-by: Johnni Winther <johnniwinther@google.com>
> Reviewed-by: Aske Simon Christensen <askesc@google.com>

TBR=vegorov@google.com,alexmarkov@google.com,johnniwinther@google.com,askesc@google.com

Change-Id: I05d010378cfcc5ba40f2be58b01b3ed27a8fc31e
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Issue: https://github.com/dart-lang/sdk/issues/45340
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/199000
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2021-05-10 12:32:38 +00:00
Alexander Markov
53e3c079b7 [vm] Enable new kernel AST invocation nodes for the VM
TEST=ci

Issue: https://github.com/dart-lang/sdk/issues/45340
Change-Id: Ibb307d8df8ff4ae8f2efad177880634ec9e27905
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/197586
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
2021-05-09 21:00:28 +00:00
Alexander Markov
7eb2805665 [vm/ffi] Refactor a few duplicated AST patterns in FFI transformer
This change is a pure refactoring. It extracts 3 duplicated code
snippets into helper methods. This is needed to reduce number of
places where PropertyGet and MethodInvocation nodes are created, as
these nodes are going to be replaced with InstanceGet and
InstanceInvocation nodes soon.

Issue: https://github.com/dart-lang/sdk/issues/45340
Change-Id: I694805a3761fd389ac8ee005d12ffb9bb9543ea7
TEST=ci
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/198581
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2021-05-07 16:32:07 +00:00
Daco Harkes
f53af0d445 [cfe/ffi] FFI transformation support incremental compilation
The compounds transformation converting fields into getters and setters
now retains the annotations on the getters so that they can be read
during recompilation.

This splits up `_replaceFields` into `_findFields` and `_replaceFields`.
`_findFields` works for both transformed and non-transformed compounds.

This splits up `_compoundClassDependencies` out from
`_checkFieldAnnotations`. The former is run on all compounds
transitively reached from the compounds being compiled, the latter only
on the compounds being (re)compiled.

`manualVisitInTopologicalOrder` now visits compounds from all libraries,
not just the ones in the libraries being (re)compiled. It is responsible
for filling the `compoundCache` in topological order. And, this CL
introduces the `InvalidNativeTypeCfe` to support processing compounds
with invalid fields, which might be nested later in other compounds.

Bug: https://github.com/dart-lang/sdk/issues/45899

TEST=pkg/front_end/testcases/incremental/crash_05.yaml
TEST=tests/ffi(_2)/*

Change-Id: I07a2214fd460f4d5e6a84df81e8b140dd80401dc
Cq-Include-Trybots: luci.dart.try:vm-precomp-ffi-qemu-linux-release-arm-try,vm-ffi-android-debug-arm64-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-debug-x64c-try,vm-kernel-reload-linux-debug-x64-try,vm-kernel-reload-rollback-linux-debug-x64-try
Fixed: 45899
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/198281
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2021-05-06 13:22:22 +00:00
Daco Harkes
cf647f5aad [cfe/ffi] Remove empty Struct use site check
After https://dart-review.googlesource.com/c/sdk/+/197740, I realized
we also don't need the other data structure anymore.

In https://dart-review.googlesource.com/c/sdk/+/180189, we disallow
empty `Struct`s on the definition sites, making a check on the use sites
superfluous.

This removes the last dependency between the ffi definitions and ffi
use sites transformers.

Bug: https://github.com/dart-lang/sdk/issues/45899

TEST=tests/ffi/vmspecific_static_checks_test.dart

Change-Id: I6eb5a26d4ece713107ba2a9e6bf601a6e029baa7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/198047
Reviewed-by: Clement Skau <cskau@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2021-05-05 07:19:02 +00:00
Alexander Markov
df80241899 [vm] Handle new AST invocation nodes in VM kernel transformations
This change extends VM-specific kernel transformations to handle
new AST invocation nodes. The transformations may still generate
old nodes, but they should accept and handle new nodes coming from
the front-end.

TEST=Manual testing with new invocation nodes enabled.

Issue: https://github.com/dart-lang/sdk/issues/45340
Change-Id: I2de9f0eb00fcf844ba62fdc93b15a907c2d6b69d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/197443
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2021-05-04 18:15:01 +00:00
Daco Harkes
00e5e38687 [cfe/ffi] Remove getter/setter replacement
The getter and setter replaces the field by "assuming it's identities"
When the getter (setter) is created it gets the getter (setter)
reference from the field, and the node pointed to by the reference is
updated to be the getter (setter). Everything that points to something
points to the reference so they don't change.

Before, the ffi transform updated the call sites, after replacing fields
wit getters and setters, this is no longer necessary.

TEST=tests/ffi(_2)/* and CI bots

Change-Id: Idf5a1a3f35131da6fcd75068c51c54e96b6d57a3
Cq-Include-Trybots: luci.dart.try:vm-precomp-ffi-qemu-linux-release-arm-try,vm-ffi-android-debug-arm64-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-debug-x64c-try,vm-kernel-reload-linux-debug-x64-try,vm-kernel-reload-rollback-linux-debug-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/198046
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2021-05-04 13:37:51 +00:00
Johnni Winther
b8bc0dd751 [kernel,vm] Migrate first part of vm transformations
Since the VM package isn't opted in, the individual libraries have
been annotated with `@dart=2.12` to opt in to null safety.

TEST=existing

Change-Id: I0bfbcf69cb80d32bb6b80a171f7bdb62fde7ca65
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195277
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
2021-05-03 12:13:28 +00:00
Nate Bosch
8488b37aae Update to the latest package:test
Change-Id: I0877954a967df22c76ef0d232f9985da07862118
TEST=No added tests for package roll
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/197440
Auto-Submit: Nate Bosch <nbosch@google.com>
Commit-Queue: Nate Bosch <nbosch@google.com>
Reviewed-by: Jake Macdonald <jakemac@google.com>
2021-04-30 00:19:05 +00:00
Daco Harkes
79331c788c [cfe/ffi] Fix division by 0 on @Packed(0)
Fixes: https://github.com/dart-lang/sdk/issues/45838

TEST=tests/ffi/vmspecific_static_checks_test.dart

(Looks like `dart format` also slightly changed. Committing such that
the files are in line with the formatter again.)

Change-Id: Iefd8af8c38a7490175b2e25b46cedbf85f15f17d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/197340
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Tess Strickland <sstrickl@google.com>
2021-04-29 10:55:17 +00:00
Nate Bosch
427e17dfce Allow null to flow through _throwFormatException
In the case of `tryParse` the intention was for the `onError` callback
to return `null`, however in strong mode this can't be returned through
the `int` return type so there is an exception.

Add types to the `onError` callback to make it explicit that below the
boundary of the public `parse` method the callback may return null. A
`null` return from the `onError` callback is now caught in strong mode
within `parse` with an `as int` cast.

Remove the catch-all error handler that masked this issue.

TEST=ci

Change-Id: Ib8b266e0d7e425c1811145e80b6f5bd4a81d4c6d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/193960
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Lasse R.H. Nielsen <lrn@google.com>
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
Auto-Submit: Nate Bosch <nbosch@google.com>
2021-04-29 10:22:45 +00:00
Johnni Winther
8f92864ca3 [kernel] Rename MapEntry to MapLiteralEntry
- to avoid collisions with MapEntry from dart:core

TEST=existing

Change-Id: I7b9592844345313e79ac18d18017c74de7c02106
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/196930
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
2021-04-27 10:36:38 +00:00
JustWe
ac2cd2d73c [vm/ffi] Array dimensions non-positive check in CFE
Bug: https://github.com/dart-lang/sdk/issues/45540
Closes: https://github.com/dart-lang/sdk/pull/45785

TEST=tests/ffi/vmspecific_static_checks_test.dart

GitOrigin-RevId: e4c091a617acf36f60de7ddfc957a58323663813
Change-Id: I393e1dbbf34aa9f72e2e942c3a40c2f37c90e0c4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/196246
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2021-04-27 06:56:28 +00:00
Alexander Markov
47eff41aa0 [vm/aot/tfa] Handle classes which implement Future along with another generic type in a cast to FutureOr
When handling a type check to FutureOr in TFA, there is a case
when a ConcreteType is a subtype of Future. In such case, it was
assumed that ConcreteType has only 1 type argument.
This is not true if class extends/implements/mixes-in Future along
with another generic class.

This change adds the logic to query offset of Future type arguments in
the type arguments of a class and also check if the type argument is
known.

TEST=pkg/vm/testcases/transformations/type_flow/transformer/regress_flutter81068.dart
Fixes https://github.com/flutter/flutter/issues/81068

Change-Id: I970e649823bafec433fc21a286498acc0126b331
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/196546
Auto-Submit: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Aske Simon Christensen <askesc@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2021-04-26 10:28:47 +00:00
Paul Berry
73db2ff205 Replace CFE and analyzer legacy type promotion with a shared implementation.
This allows us to remove a substantial amount of CFE and analyzer
code.

It also fixes a minor CFE type promotion bug
(language_2/type_promotion/assignment_defeats_promotion_lhs_and_test).

TEST=standard trybots
Change-Id: Ia0c159bdb9161d73648c9eb73b92822168f28d84
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/175583
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2021-04-21 14:21:30 +00:00
Johnni Winther
3e44898e08 [kernel] Make FileUriNode.fileUri non-nullable
TEST=existing

Change-Id: I72583e500cb0b69d9352b040c3e2885f9e0450c5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195681
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2021-04-19 08:03:30 +00:00
Daco Harkes
8a2b7bb5d5 [vm/ffi] Support Unions
Closes: https://github.com/dart-lang/sdk/issues/38491

tools/test.py ffi ffi_2
TEST=tests/ffi(_2)/(.*)by_value_(*.)_test.dart

Change-Id: I6d29f7e3c3046cda4a15c9b42063c66b064787be
Cq-Include-Trybots: luci.dart.try:dart-sdk-linux-try,dart-sdk-mac-try,dart-sdk-win-try,vm-ffi-android-debug-arm-try,vm-ffi-android-debug-arm64-try,vm-kernel-asan-linux-release-x64-try,vm-kernel-mac-debug-x64-try,vm-kernel-linux-debug-ia32-try,vm-kernel-linux-debug-x64-try,vm-kernel-nnbd-linux-debug-x64-try,vm-kernel-nnbd-linux-debug-ia32-try,vm-kernel-nnbd-mac-release-x64-try,vm-kernel-nnbd-win-debug-x64-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-debug-simarm_x64-try,vm-kernel-precomp-nnbd-linux-debug-x64-try,vm-kernel-precomp-win-release-x64-try,vm-kernel-reload-linux-debug-x64-try,vm-kernel-reload-rollback-linux-debug-x64-try,vm-kernel-win-debug-x64-try,vm-kernel-win-debug-ia32-try,vm-precomp-ffi-qemu-linux-release-arm-try,vm-kernel-precomp-obfuscate-linux-release-x64-try,vm-kernel-msan-linux-release-x64-try,vm-kernel-precomp-msan-linux-release-x64-try,vm-kernel-precomp-android-release-arm_x64-try,analyzer-analysis-server-linux-try,vm-kernel-precomp-linux-debug-x64c-try,vm-kernel-linux-debug-x64c-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/194420
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
2021-04-15 10:16:27 +00:00
Daco Harkes
4558112105 Rereland "[vm/ffi] Disallow Pointers and structs in finalizers and expandos"
`Dart_NewWeakPersistentHandle` and `Dart_NewFinalizableHandle` in
`dart_api.h` do no longer accept `Pointer`s and subtypes of `Struct`s
as values passed in to the `object` parameter.

Expandos no longer accept `Pointer`s and subtypes of `Struct`s
as values passed in to the `object` parameter.

Cleans up unused object_store->ffi_struct_class.

Reland 1: Allow importing `dart:ffi` from `dart:core` with
          `--enable-ffi=false`.
Reland 2: Allow the new `_Compound` class to extend `NativeType`. (This
          got triggered in this CL on the build because of the import
          from `dart:core`.)

Closes: https://github.com/dart-lang/sdk/issues/45071
Breaking change: https://github.com/dart-lang/sdk/issues/45072

TEST=vm/cc/DartAPI_FinalizableHandleErrors
TEST=vm/cc/DartAPI_WeakPersistentHandleErrors
TEST=tests/ffi(_2)/expando_test.dart

Change-Id: I133278e16bd75cd2bb6234e7ddf042ffa0a54fd6
Cq-Include-Trybots: luci.dart.try:dart-sdk-linux-try,dart-sdk-mac-try,dart-sdk-win-try,vm-ffi-android-debug-arm-try,vm-ffi-android-debug-arm64-try,vm-kernel-asan-linux-release-x64-try,vm-kernel-mac-debug-x64-try,vm-kernel-linux-debug-ia32-try,vm-kernel-linux-debug-x64-try,vm-kernel-nnbd-linux-debug-x64-try,vm-kernel-nnbd-linux-debug-ia32-try,vm-kernel-nnbd-mac-release-x64-try,vm-kernel-nnbd-win-debug-x64-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-debug-simarm_x64-try,vm-kernel-precomp-nnbd-linux-debug-x64-try,vm-kernel-precomp-win-release-x64-try,vm-kernel-reload-linux-debug-x64-try,vm-kernel-reload-rollback-linux-debug-x64-try,vm-kernel-win-debug-x64-try,vm-kernel-win-debug-ia32-try,vm-precomp-ffi-qemu-linux-release-arm-try,vm-kernel-precomp-obfuscate-linux-release-x64-try,vm-kernel-msan-linux-release-x64-try,vm-kernel-precomp-msan-linux-release-x64-try,vm-kernel-precomp-android-release-arm_x64-try,analyzer-analysis-server-linux-try,vm-kernel-precomp-linux-debug-x64c-try,vm-kernel-linux-debug-x64c-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195079
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2021-04-14 12:07:18 +00:00
Johnni Winther
d8f2b7cc44 [kernel] Make .function non-nullable on Procedure, Constructor, and LocalFunction
TEST=existing

Change-Id: I4d0ae16291414e58207b7de0466d989d27997619
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195074
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2021-04-14 08:17:28 +00:00
Ryan Macnak
55645786bc Revert "[vm, compiler] Support unboxed parameters for integer intrinsics."
This reverts commit 1d369b5000.

Reason for revert: Failures on Golem

Original change's description:
> [vm, compiler] Support unboxed parameters for integer intrinsics.
>
> TEST=ci
> Change-Id: I7f29471043c049ef1acf7cd4bcb0890db6d33aa4
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/192728
> Commit-Queue: Ryan Macnak <rmacnak@google.com>
> Reviewed-by: Alexander Markov <alexmarkov@google.com>
> Reviewed-by: Martin Kustermann <kustermann@google.com>

# Not skipping CQ checks because original CL landed > 1 day ago.

Change-Id: I09e54cd894c0f73bf3af215729567503c156ec3e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195165
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2021-04-13 17:05:47 +00:00
Daco Harkes
c33dad37e5 Revert "Reland "[vm/ffi] Disallow Pointers and structs in finalizers and expandos""
This reverts commit 3f0ad61daa.

Reason for revert: Conflicts with https://dart-review.googlesource.com/c/sdk/+/194765

Original change's description:
> Reland "[vm/ffi] Disallow `Pointer`s and structs in finalizers and expandos"
>
> `Dart_NewWeakPersistentHandle` and `Dart_NewFinalizableHandle` in
> `dart_api.h` do no longer accept `Pointer`s and subtypes of `Struct`s
> as values passed in to the `object` parameter.
>
> Expandos no longer accept `Pointer`s and subtypes of `Struct`s
> as values passed in to the `object` parameter.
>
> Cleans up unused object_store->ffi_struct_class.
>
> Closes: https://github.com/dart-lang/sdk/issues/45071
> Breaking change: https://github.com/dart-lang/sdk/issues/45072
>
> TEST=vm/cc/DartAPI_FinalizableHandleErrors
> TEST=vm/cc/DartAPI_WeakPersistentHandleErrors
> TEST=tests/ffi(_2)/expando_test.dart
>
> Change-Id: I9af6d0173db60614091068c218391f73756c135f
> Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195061
> Reviewed-by: Martin Kustermann <kustermann@google.com>
> Commit-Queue: Daco Harkes <dacoharkes@google.com>

TBR=kustermann@google.com,dacoharkes@google.com

Change-Id: I90064b6b73155a43f37388f987c6b29f72ce9770
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195076
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2021-04-13 15:05:07 +00:00
Daco Harkes
3f0ad61daa Reland "[vm/ffi] Disallow Pointers and structs in finalizers and expandos"
`Dart_NewWeakPersistentHandle` and `Dart_NewFinalizableHandle` in
`dart_api.h` do no longer accept `Pointer`s and subtypes of `Struct`s
as values passed in to the `object` parameter.

Expandos no longer accept `Pointer`s and subtypes of `Struct`s
as values passed in to the `object` parameter.

Cleans up unused object_store->ffi_struct_class.

Closes: https://github.com/dart-lang/sdk/issues/45071
Breaking change: https://github.com/dart-lang/sdk/issues/45072

TEST=vm/cc/DartAPI_FinalizableHandleErrors
TEST=vm/cc/DartAPI_WeakPersistentHandleErrors
TEST=tests/ffi(_2)/expando_test.dart

Change-Id: I9af6d0173db60614091068c218391f73756c135f
Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195061
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2021-04-13 13:52:36 +00:00
Daco Harkes
c57ca14781 [vm/ffi] Refactor CFE transform to compound
In preparation of having `Union` besides `Struct`, renames all mentions
of `Struct` to `Compound`.

Also, changes the type checking to have `allowXYZ` named arguments
always default to false, and remove redundant arguments.

Bug: https://github.com/dart-lang/sdk/issues/38491

tools/test.py ffi ffi_2
TEST=tests/ffi(_2)/(.*)by_value_(*.)_test.dart

Change-Id: Ie5f7cf4189dc315f896e3b3933ff0e0580ac540f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/194424
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
2021-04-13 12:50:17 +00:00
Daco Harkes
bde9578a39 [vm/ffi] Introduce _Compound NativeType
Introduces the class `_Compound extends NativeType`, for sharing between
`Struct` and `Union`.

Does minimal changes to CFE and IL construction. Follow up refactor CLs
rename everything.

Bug: https://github.com/dart-lang/sdk/issues/38491

tools/test.py ffi ffi_2
TEST=tests/ffi(_2)/(.*)by_value_(*.)_test.dart

Change-Id: I276ceb9249c20bd331c2f8b6ef64e35acb525e9c
Cq-Include-Trybots: luci.dart.try:vm-precomp-ffi-qemu-linux-release-arm-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-reload-linux-debug-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/194765
Reviewed-by: Aske Simon Christensen <askesc@google.com>
2021-04-13 12:50:17 +00:00
Daco Harkes
ac2412ca01 Revert "[vm/ffi] Disallow Pointers and structs in finalizers and expandos"
This reverts commit 2376ab5186.

Reason for revert: Importing dart:ffi from dart:core breaks the VM when using --enable-ffi=false

Original change's description:
> [vm/ffi] Disallow `Pointer`s and structs in finalizers and expandos
>
> `Dart_NewWeakPersistentHandle` and `Dart_NewFinalizableHandle` in
> `dart_api.h` do no longer accept `Pointer`s and subtypes of `Struct`s
> as values passed in to the `object` parameter.
>
> Expandos no longer accept `Pointer`s and subtypes of `Struct`s
> as values passed in to the `object` parameter.
>
> Cleans up unused object_store->ffi_struct_class.
>
> Closes: https://github.com/dart-lang/sdk/issues/45071
> Breaking change: https://github.com/dart-lang/sdk/issues/45072
>
> TEST=vm/cc/DartAPI_FinalizableHandleErrors
> TEST=vm/cc/DartAPI_WeakPersistentHandleErrors
> TEST=tests/ffi(_2)/expando_test.dart
>
> Change-Id: I1f11adfa073c7d2c979f3c2bb15c7444c7c767a0
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/186280
> Commit-Queue: Daco Harkes <dacoharkes@google.com>
> Reviewed-by: Martin Kustermann <kustermann@google.com>

TBR=lrn@google.com,vegorov@google.com,kustermann@google.com,dacoharkes@google.com

Change-Id: Ib76d27e59391dc6107d3f8e8fba3d67640ea9a5c
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195060
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2021-04-12 16:30:57 +00:00
Daco Harkes
2376ab5186 [vm/ffi] Disallow Pointers and structs in finalizers and expandos
`Dart_NewWeakPersistentHandle` and `Dart_NewFinalizableHandle` in
`dart_api.h` do no longer accept `Pointer`s and subtypes of `Struct`s
as values passed in to the `object` parameter.

Expandos no longer accept `Pointer`s and subtypes of `Struct`s
as values passed in to the `object` parameter.

Cleans up unused object_store->ffi_struct_class.

Closes: https://github.com/dart-lang/sdk/issues/45071
Breaking change: https://github.com/dart-lang/sdk/issues/45072

TEST=vm/cc/DartAPI_FinalizableHandleErrors
TEST=vm/cc/DartAPI_WeakPersistentHandleErrors
TEST=tests/ffi(_2)/expando_test.dart

Change-Id: I1f11adfa073c7d2c979f3c2bb15c7444c7c767a0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/186280
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2021-04-12 14:04:16 +00:00
Daco Harkes
189c36b82a [vm] Native effects
Adds a way to express native effects in Dart expressions in kernel.

This CL adds a `void _nativeEffect(Object)` to `dart:internal`.
The semantics of `_nativeEffect` are to not execute its arguments and
return `null`.

This CL uses this `_nativeEffect` to make sure that we never execute
the struct constructor invocations used to simulate the native behavior
of FFI trampolines.

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

TEST=tests/ffi(_2)/native_effect_test.dart

Change-Id: Ie06de145e49f8b1cae9e148c2d5d97d5cd8e6878
Cq-Include-Trybots: luci.dart.try:vm-precomp-ffi-qemu-linux-release-arm-try,vm-ffi-android-debug-arm64-try,vm-kernel-precomp-asan-linux-release-x64-try,vm-kernel-precomp-dwarf-linux-product-x64-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-obfuscate-linux-release-x64-try,analyzer-analysis-server-linux-try,analyzer-linux-release-try,dart-sdk-linux-try,vm-kernel-reload-rollback-linux-debug-x64-try,vm-kernel-reload-linux-debug-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/194421
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2021-04-09 16:45:13 +00:00
Aske Simon Christensen
ea50eeb4be [vm/aot] Set type context for fields in signature shaker.
Fixes https://github.com/dart-lang/sdk/issues/45642

TEST=Regression test added.
Change-Id: Ib14b27674810ac22aad21c19647e68e7ad32ceaa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/194762
Auto-Submit: Aske Simon Christensen <askesc@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2021-04-09 16:14:23 +00:00
Ryan Macnak
1d369b5000 [vm, compiler] Support unboxed parameters for integer intrinsics.
TEST=ci
Change-Id: I7f29471043c049ef1acf7cd4bcb0890db6d33aa4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/192728
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2021-04-09 00:30:10 +00:00
Daco Harkes
d27f166b75 [vm/ffi] Tree shaking of Struct sub classes
This CL enables tree shaking of `Struct` sub classes by simulating the
native behavior in Dart code.

We call the struct constructors in let expressions where FFI trampolines
are created which allocate these struct objects in native code. This way
TFA is instructed about the native behavior. The VM recognizes these
constructor calls as dead code and removes them.

For more info see go/dart-ffi-struct-treeshaking.

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

This CL fixes the types on the generated #fromTypedDataBase constructors.

Also, this CL also cleans up the struct naming:
* _addressOf   -> _typedDataBase
* _fromPointer -> _fromTypedDataBase
* #pointer     -> #typedDataBase

These cleanups are not split into a separate CL to prevent updating
the .expect files multiple times.

Finally, this CL enables running a single transformer test through:
`dart pkg/vm/test/transformations/type_flow/transformer_test.dart name`

TEST=pkg/vm/testcases/transformations/type_flow/transformer/ffi_struct_constructors.dart
TEST=tests/ffi(_2)/function_callbacks_structs_by_value_generated_test.dart
TEST=tests/ffi(_2)/function_structs_by_value_generated_test.dart

Change-Id: I418d0d73bc86b234dfe5b7b04ae726c33d2b8aeb
Cq-Include-Trybots: luci.dart.try:vm-precomp-ffi-qemu-linux-release-arm-try,vm-ffi-android-debug-arm64-try,vm-kernel-precomp-asan-linux-release-x64-try,vm-kernel-precomp-dwarf-linux-product-x64-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-obfuscate-linux-release-x64-try,analyzer-analysis-server-linux-try,analyzer-linux-release-try,dart-sdk-linux-try,vm-kernel-reload-rollback-linux-debug-x64-try,vm-kernel-reload-linux-debug-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/193661
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2021-04-07 11:02:27 +00:00
Franklin Yow
03101c0c2b Update LICENSE
Changes to comply to internal review

Closes https://github.com/dart-lang/sdk/pull/45568
https://github.com/dart-lang/sdk/pull/45568

TEST=CL contains no code changes.

No-Try: true
GitOrigin-RevId: 65796784e5fdfddaa021b5c55ad435b1db419700
Change-Id: I085a948f16dc9a0de128ed0bd456ae69adf6c124
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/193888
Reviewed-by: Alexander Thomas <athom@google.com>
Reviewed-by: Bob Nystrom <rnystrom@google.com>
Commit-Queue: Alexander Thomas <athom@google.com>
2021-04-07 10:28:38 +00:00
Johnni Winther
9d80c4db57 [kernel,vm] Migrate vm transformations in package:kernel
TEST=existing

Change-Id: I86dfda23fa32ecb924fa6c202e7142cb8a258dc6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/192145
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
2021-04-07 08:30:47 +00:00
Alexander Markov
303f1eda70 [vm/aot] Avoid reusing Reference when replacing Field with getter in tree shaker
TEST=existing tests
Change-Id: I0a661e8d1b0be418080dadfe4ffe1eabd49a16aa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/191640
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2021-03-31 15:57:59 +00:00
Ryan Macnak
6a6e08b784 Reapply "[vm, compiler] Convert binary Smi ops to graph intrinsics."
Explicitly disable unboxed parameters for these functions, previously implicitly disabled by virtue of being ASM intrinsics.

TEST=ci
Change-Id: Ic810bb8400e081c5f99a49b5035031bc9edc4bf5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/192044
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2021-03-25 21:54:44 +00:00
Daco Harkes
77dc74bcd5 [vm/ffi] Support packed Structs
Closes: https://github.com/dart-lang/sdk/issues/38158

This CL implements unaligned access for float/double on arm32, but does
not expose it in an API. Rather it only uses these loads/stores inside
the getters and setters of packed structs.
Bug: https://github.com/dart-lang/sdk/issues/45009

Besides unaligned access for float/double, this CL is mostly a CFE
change. The only VM change is reading the packing in the
`_FfiStructLayout` annotation.

The implementation of using the packing in the VM, and analyzer changes
have landed separately in earlier CLs.

tools/test.py ffi ffi_2
TEST=tests/ffi(_2)/(.*)by_value_(*.)_test.dart

Change-Id: Ic3106ecc626d2e30674a49bf03f65ae12d2b3502
Cq-Include-Trybots: luci.dart.try:dart-sdk-linux-try,dart-sdk-mac-try,dart-sdk-win-try,vm-ffi-android-debug-arm-try,vm-ffi-android-debug-arm64-try,vm-kernel-asan-linux-release-x64-try,vm-kernel-mac-debug-x64-try,vm-kernel-linux-debug-ia32-try,vm-kernel-linux-debug-x64-try,vm-kernel-nnbd-linux-debug-x64-try,vm-kernel-nnbd-linux-debug-ia32-try,vm-kernel-nnbd-mac-release-x64-try,vm-kernel-nnbd-win-debug-x64-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-debug-simarm_x64-try,vm-kernel-precomp-nnbd-linux-debug-x64-try,vm-kernel-precomp-win-release-x64-try,vm-kernel-reload-linux-debug-x64-try,vm-kernel-reload-rollback-linux-debug-x64-try,vm-kernel-win-debug-x64-try,vm-kernel-win-debug-ia32-try,vm-precomp-ffi-qemu-linux-release-arm-try,vm-kernel-precomp-obfuscate-linux-release-x64-try,vm-kernel-msan-linux-release-x64-try,vm-kernel-precomp-msan-linux-release-x64-try,vm-kernel-precomp-android-release-arm_x64-try,analyzer-analysis-server-linux-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/186143
Reviewed-by: Aske Simon Christensen <askesc@google.com>
2021-03-19 15:34:42 +00:00
Daco Harkes
55082199e7 [vm/ffi] Fix Array<Pointer> loads and stores
Closes: https://github.com/dart-lang/sdk/issues/45198

TEST=tests/ffi(_2)/regress_45198_test.dart

Change-Id: I15cf5a4d48b1bfb33de039cc8b17be8e01fba752
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/191881
Reviewed-by: Tess Strickland <sstrickl@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2021-03-18 12:26:38 +00:00
Alexander Markov
e8f57b6605 [vm/aot] Handle FieldInitializer pointing to a Field's Reference which is reused for a getter
This is a follow-up to https://dart-review.googlesource.com/c/sdk/+/186680.
After that change, tree shaker started reusing Reference to a Field
when it is replaced with a getter. As a side-effect, this makes
FieldInitializer.field to crash as Reference is now pointing to Procedure,
not a Field.

The fix is to carefully use 'node.fieldReference.asMember' instead of
'node.field' and then retrieve original Field node if it was replaced
with a getter.

TEST=pkg/vm/testcases/transformations/type_flow/transformer/regress_45324_2.dart
Fixes https://github.com/dart-lang/sdk/issues/45324

Change-Id: Ic34e8b9933b00997cd350a4ad93f798c86ac60ad
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/191323
Auto-Submit: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2021-03-16 05:43:34 +00:00
Alexander Markov
daae24b488 [vm/aot] Retain fields used in constants
Evaluated constant instances in kernel are represented as a list of
field->value pairs. Tree shaker should not remove fields used in
constants as it may potentially affect identity of constant instances
(non-identical constants may become identical).
Previously, fields used in constants were only marked as written,
so they could still be removed as write-only fields.
Furthermore, if such field was also used as an interface target
it could be converted to an abstract getter, causing the conflict
during kernel AST serialization.

This fix marks fields used in constants as also read, effectively
preventing their tree shaking.

Flutter gallery AOT snapshot size is not affected.

TEST=pkg/vm/testcases/transformations/type_flow/transformer/regress_45324.dart
Fixes https://github.com/dart-lang/sdk/issues/45324

Change-Id: Id6d35604757ad6ba1e23f7227aa9b769448c2688
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/191280
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2021-03-15 21:50:11 +00:00
Johnni Winther
1aa6f00107 [kernel] Refactor CanonicalName/Reference integration
The CL is a step towards have a more restricted and wellstructured
handled of references and canonical names.

The CL moves Reference to canonical_name.dart and makes
CanonicalName.reference private, and replaces CanonicalName.getReference
with a 'reference' getter.

It also removes NamedNode.canonicalName, Field.getterCanonicalName and
Field.setterCanonicalName so that these can only be accessed through the
corresponding reference. This is to reduce the reliance on the
canonical names which, ideally, should only be part of serialization and
deserialization.

TEST=existing

Change-Id: I955fb7d52d4e112d8741f7c12dcf38b74ae0c91a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/190442
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2021-03-10 15:39:28 +00:00
Daco Harkes
ffa5d16ae7 [vm/ffi] Support multi-dimensional inline arrays
This CL only changes dart:ffi API, CFE, and analyzer. No VM changes
were needed because the dimensions of inline arrays can be flattened
before passing them to the VM. The multi-dimensionality does not
impact the ABI.

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

TEST=pkg/analyzer/test/src/diagnostics/size_annotation_dimensions_test.dart
TEST=pkg/front_end/testcases/nnbd/ffi_struct_inline_array_multi_dimensional.dart
TEST=tests/ffi/function_structs_by_value_generated_test.dart
TEST=tests/ffi/inline_array_multi_dimensional_test.dart

Change-Id: Ica2c01fccbea7e513879365b34086d8968b54c5b
Cq-Include-Trybots: luci.dart.try:dart-sdk-linux-try,dart-sdk-mac-try,dart-sdk-win-try,vm-ffi-android-debug-arm-try,vm-ffi-android-debug-arm64-try,vm-kernel-asan-linux-release-x64-try,vm-kernel-mac-debug-x64-try,vm-kernel-linux-debug-ia32-try,vm-kernel-linux-debug-x64-try,vm-kernel-nnbd-linux-debug-x64-try,vm-kernel-nnbd-linux-debug-ia32-try,vm-kernel-nnbd-mac-release-x64-try,vm-kernel-nnbd-win-debug-x64-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-debug-simarm_x64-try,vm-kernel-precomp-nnbd-linux-debug-x64-try,vm-kernel-precomp-win-release-x64-try,vm-kernel-reload-linux-debug-x64-try,vm-kernel-reload-rollback-linux-debug-x64-try,vm-kernel-win-debug-x64-try,vm-kernel-win-debug-ia32-try,vm-precomp-ffi-qemu-linux-release-arm-try,vm-kernel-precomp-obfuscate-linux-release-x64-try,vm-kernel-msan-linux-release-x64-try,vm-kernel-precomp-msan-linux-release-x64-try,vm-kernel-precomp-android-release-arm_x64-try,analyzer-analysis-server-linux-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/188286
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
2021-03-09 10:50:17 +00:00
Johnni Winther
7d64d528ce [kernel] Migrate ast_to_binary.dart
TEST=existing

Change-Id: If080190b80776a7613f983b28c2e800727599328
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/189201
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2021-03-09 09:29:56 +00:00
Johnni Winther
2d63f26ef5 Reland "[cfe] Encode field references as @getters and @setters"
This removes the @fields and @=fields canonical name
encodings that allowed for encoding of conflicting members
and didn't support field<->getter/setter conversion
between dills or between outline and full dill.

TEST=existing tests+add aot expectation tests

Change-Id: I119b0c95f90e456356146cdc2d9241de4c1b4fff
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/186680
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2021-03-09 05:47:16 +00:00
Johnni Winther
af4757dd0b [kernel] Migrate ast_from_binary.dart
TEST=existing tests

Change-Id: Ie6b3baa9233e2f02179d0eaf31224e628436495e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/188282
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2021-03-02 12:11:12 +00:00
Jens Johansen
93f4ac0a83 [cfe] Actually have both ansi and plain text formatted messages (2nd try)
The CFEs FormattedMessage always had two getters to get the text inside
one that would supposedly give an ansi formated version of the message
and one that would supposedly give a plaintext formated version of the
message. They both returned the same string, though, which would either
be with ansi escape codes or plain text depending on the environment at
compile time.

This CL fixes that by having both messages, and letting the reporting
(i.e. whenever the message is read) decide which to use. That way we
can - for instance - report errors with color if the terminal supports
it correctly when reusing a dill (and reissuing problems, but where the
terminal support changes) and if printing the problem to an html <pre>
field (like observatory does).

It also cleans up two different implementations of whether we think
the terminal supports colors or not, by deleting one of them.

This is the second try. Patchset #1 is the original.
Patchset #2(and possibly beyond) is the changes.

TEST=Existing test suites.

Change-Id: I8e483049ce81ce1bd8e5396b588a31e0ad3a8630
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/187402
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2021-02-26 13:06:17 +00:00
Dmitry Stefantsov
c191551fac [cfe] Remove BottomType
TEST=Covered by existing tests.

Change-Id: Ied8be1874164e68e0a3a48e1b2f9a33310071381
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/183009
Commit-Queue: Dmitry Stefantsov <dmitryas@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2021-02-24 13:21:55 +00:00
Daco Harkes
d45fd0f9d5 [vm/ffi] Support inline arrays in Structs
Adds support for single dimension inline arrays in structs. Multi-
dimensional arrays will be supported in a future CL.

This CL adds:
- CFE static error checks for inline arrays.
- CFE transformations for inline arrays.
- VM consumption of inline array fields for NativeType.
- Test generator support for inline arrays + generated tests.

Previous CLs added support for inline arrays in:
- analyzer https://dart-review.googlesource.com/c/sdk/+/183684
  - updated in this CL to new API.
- ABI calculation https://dart-review.googlesource.com/c/sdk/+/183682

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

Open issue: https://github.com/dart-lang/sdk/issues/45101

CFE transformations are tested with expectation files:
TEST=pkg/front_end/testcases/(.*)/ffi_struct_inline_array.dart

Trampolines and CArray API are tested with end-to-end Dart tests:
TEST=tests/ffi(_2)/(.*)by_value(.*)test.dart
TEST=tests/ffi(_2)/inline_array_test.dart

Compile-time errors (both CFE and analyzer) are tested in:
TEST=tests/ffi(_2)/vmspecific_static_checks_test.dart

Change-Id: I014c0e4153f1b885638adce80de6ab3cac8e6bb2
Cq-Include-Trybots: luci.dart.try:dart-sdk-linux-try,dart-sdk-mac-try,dart-sdk-win-try,vm-ffi-android-debug-arm-try,vm-ffi-android-debug-arm64-try,vm-kernel-asan-linux-release-x64-try,vm-kernel-mac-debug-x64-try,vm-kernel-linux-debug-ia32-try,vm-kernel-linux-debug-x64-try,vm-kernel-nnbd-linux-debug-x64-try,vm-kernel-nnbd-linux-debug-ia32-try,vm-kernel-nnbd-mac-release-x64-try,vm-kernel-nnbd-win-debug-x64-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-debug-simarm_x64-try,vm-kernel-precomp-nnbd-linux-debug-x64-try,vm-kernel-precomp-win-release-x64-try,vm-kernel-reload-linux-debug-x64-try,vm-kernel-reload-rollback-linux-debug-x64-try,vm-kernel-win-debug-x64-try,vm-kernel-win-debug-ia32-try,vm-precomp-ffi-qemu-linux-release-arm-try,vm-kernel-precomp-obfuscate-linux-release-x64-try,vm-kernel-msan-linux-release-x64-try,vm-kernel-precomp-msan-linux-release-x64-try,vm-kernel-precomp-android-release-arm_x64-try,analyzer-analysis-server-linux-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/183640
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Clement Skau <cskau@google.com>
2021-02-24 13:02:45 +00:00
Jens Johansen
3a4a4f53d0 Revert "[cfe] Actually have both ansi and plain text formatted messages"
This reverts commit f63f7736c5.

Reason for revert: This somehow breaks the Windows bots. `python tools/test.py -n dartk-win-release-x64 standalone_2/io/process_shell_test`.

Original change's description:
> [cfe] Actually have both ansi and plain text formatted messages
>
> The CFEs FormattedMessage always had two getters to get the text inside
> one that would supposedly give an ansi formated version of the message
> and one that would supposedly give a plaintext formated version of the
> message. They both returned the same string, though, which would either
> be with ansi escape codes or plain text depending on the environment at
> compile time.
>
> This CL fixes that by having both messages, and letting the reporting
> (i.e. whenever the message is read) decide which to use. That way we
> can - for instance - report errors with color if the terminal supports
> it correctly when reusing a dill (and reissuing problems, but where the
> terminal support changes) and if printing the problem to an html <pre>
> field (like observatory does (1)).
>
> It also cleans up two different implementations of whether we think
> the terminal supports colors or not, by deleting one of them.
>
> (1) At least sometimes. It works - I think - only for 'evaluateInFrame',
>     but that's another story (and will be fixed in a follow-up CL).
>
> TEST=Existing test suites.
>
> Change-Id: Iedaedd9a5c41458d40c23ed4b706324c004ae943
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/186291
> Commit-Queue: Jens Johansen <jensj@google.com>
> Reviewed-by: Johnni Winther <johnniwinther@google.com>
> Reviewed-by: Alexander Markov <alexmarkov@google.com>

Change-Id: I0b53f943a61f76705badfead30d9e1ee35baff57
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/186941
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2021-02-24 12:30:18 +00:00
Jens Johansen
f63f7736c5 [cfe] Actually have both ansi and plain text formatted messages
The CFEs FormattedMessage always had two getters to get the text inside
one that would supposedly give an ansi formated version of the message
and one that would supposedly give a plaintext formated version of the
message. They both returned the same string, though, which would either
be with ansi escape codes or plain text depending on the environment at
compile time.

This CL fixes that by having both messages, and letting the reporting
(i.e. whenever the message is read) decide which to use. That way we
can - for instance - report errors with color if the terminal supports
it correctly when reusing a dill (and reissuing problems, but where the
terminal support changes) and if printing the problem to an html <pre>
field (like observatory does (1)).

It also cleans up two different implementations of whether we think
the terminal supports colors or not, by deleting one of them.

(1) At least sometimes. It works - I think - only for 'evaluateInFrame',
    but that's another story (and will be fixed in a follow-up CL).

TEST=Existing test suites.

Change-Id: Iedaedd9a5c41458d40c23ed4b706324c004ae943
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/186291
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2021-02-24 10:33:45 +00:00
Johnni Winther
79de274398 Revert "[cfe] Encode field references as @getters and @setters"
This reverts commit 3892e95547.

Reason for revert: Breaks Flutter web

Original change's description:
> [cfe] Encode field references as @getters and @setters
>
> This removes the @fields and @=fields canonical name
> encodings that allowed for encoding of conflicting members
> and didn't support field<->getter/setter conversion
> between dills or between outline and full dill.
>
> TEST=existing tests
>
> Change-Id: Id15e58ad4d1847d2c98a688705e5945196146c6d
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/184783
> Commit-Queue: Johnni Winther <johnniwinther@google.com>
> Reviewed-by: Jens Johansen <jensj@google.com>
> Reviewed-by: Alexander Markov <alexmarkov@google.com>

Change-Id: I744e284b16e097fa0833c5bdf1bc7653f13bdf63
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/186147
Reviewed-by: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2021-02-22 12:56:43 +00:00
Johnni Winther
3892e95547 [cfe] Encode field references as @getters and @setters
This removes the @fields and @=fields canonical name
encodings that allowed for encoding of conflicting members
and didn't support field<->getter/setter conversion
between dills or between outline and full dill.

TEST=existing tests

Change-Id: Id15e58ad4d1847d2c98a688705e5945196146c6d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/184783
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2021-02-22 09:46:18 +00:00
Johnni Winther
a8297fd7ed [kernel] Make InterfaceType.className final
TEST=pkg/vm/lib/transformations/mixin_deduplication.dart

Change-Id: I95adf2fbe31e3cabd9b1a52a0f4545b5281e6775
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/185546
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2021-02-21 09:55:17 +00:00
Daco Harkes
c7ca192d6e [cfe/ffi] Fix Struct invalid field crashes
Closes: https://github.com/dart-lang/sdk/issues/44985
Closes: https://github.com/dart-lang/sdk/issues/44986

TEST=tests/ffi(_2)/regress_4498[56]_test.dart

Change-Id: Ia21e6e41de14ef61843ce9bff0608a9235f08936
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/185860
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2021-02-19 15:50:44 +00:00
Jens Johansen
ad596359a6 [VM] Only run FFI transformation when dart:ffi is imported
Before this CL the FFI transformation was always run (for target VM),
so if for instance running dart2js (from source), e.g. like
`out/ReleaseX64/dart -DDFE_VERBOSE=true pkg/compiler/bin/dart2js.dart --help`
one could see how it spends something like 120-140 ms, which is
something along the lines of 2.5% of the entire request processing
(i.e. compile and serialization).

This CL first checks if dart:ffi is imported at all. If it's not the
transformation is skipped.
When compiling dart2js (where, at least currently, dart:ffi is not used)
this skips the transformation, thus saving the 120-140 ms (or ~2.5%).

All measurements on my machine. Your mileage may vary.

TEST=Existing tests.

Change-Id: Ia5d3d7b989f549ca5da257660c204e8c59f15d4b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/185543
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
2021-02-19 09:44:08 +00:00
Johnni Winther
8467186ca0 [kernel] Initial migration of package kernel wave 1
This CL completes the migration of the first wave of
interdependent libraries in package:kernel, including ast.dart.

In order to ensure non-nullability on AST properties, the Transformer
has been split in 2 variants: Transformer which doesn't support
removal of nodes and RemovingTransformer which supports removal where
allowed by the context using 'removal sentinels'.

Start reviewing Transformer and RemovingTransformer in visitors.dart
since many of the changes are caused by the changes here.

Included in the migration are the mixin_deduplication.dart and
unreachable_code_elimination.dart since these needed porting to
the RemovingTransformer which was aided by opting in the libraries
which only depended on ast.dart.

TEST=existing

Change-Id: I9e63b985bd24896c25edd4ee51e37770187bcc17
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/184786
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2021-02-18 16:01:17 +00:00
Johnni Winther
07ddd00e1b [cfe] Remove unneeded hide combinators
The front end previously enforced a stricter-than-spec requirement on
conflicting imports on its own code. The check was included of the
kernel snapshot and therefore always enforced, even in published sdks.

The extra check was removed a month ago and now tools/sdks/ have been
updated to use a later version of the sdk, so the unneeded hide
combinators can now be removed from the source code.

Closes #44667

TEST=existing

Change-Id: I1d1053b1ef9a40b6a918eef515a02d7b404906c9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/185084
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2021-02-18 14:23:10 +00:00
Daco Harkes
5c7f7be9c4 [vm/ffi] Remove entry-point from Structs #sizeOf
Removes the entry-point on the `#sizeOf` field of `Struct` subtypes,
because we are no longer using it in the runtime.

Does not remove the entry-point from the constructor yet, because FFI
trampolines can instantiate these objects. Updated the TODOs to reflect
this.

Bug: https://github.com/dart-lang/sdk/issues/38721

TEST=tests/ffi(_2)/* in precompiled mode.

Change-Id: If3889e782b8fe34ef1c34cf8af83da041b4d2ef5
Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-nnbd-linux-debug-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/185540
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2021-02-18 11:40:51 +00:00
Martin Kustermann
2e2d542969 [vm/concurrency] Use isolate group id as key for incremental compiler for reload
As part of implementing hot-reload for isolate groups, we have to ensure
reloads on a group are performed using the same state of incremental
compiler.

This means we cannot use a specific isolate's information (such as it's
main port) for reloading purposes. Instead we use the unqiue isolate
group id when communicating with the kernel service.

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

TEST=Existing test coverage, future test when hot-reload is fully
     implemented with isolate groups.

Change-Id: Ifab39cd2ba689c08507dfab4091cd26951ed54e5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/185320
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2021-02-18 06:59:24 +00:00
Daco Harkes
3593de9179 [vm/ffi] Change Pointer.elementAt and sizeOf to use static type
This CL changes the semantics of
`Pointer<T extends NativeType>.elementAt` and
`sizeOf<T extends NativeType>` to use the compile-time `T` rather than
the runtime `T`.

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

TEST=tests/ffi/data_test.dart
TEST=tests/ffi/sizeof_test.dart
TEST=tests/ffi/structs_test.dart
TEST=tests/ffi/vmspecific_static_checks_test.dart

Change-Id: Ifb25a4bd66d50a385d3db6dec9213b96dff21722
Cq-Include-Trybots: luci.dart.try:vm-precomp-ffi-qemu-linux-release-arm-try,analyzer-analysis-server-linux-try,analyzer-linux-release-try,analyzer-nnbd-linux-release-try,front-end-linux-release-x64-try,front-end-nnbd-linux-release-x64-try,benchmark-linux-try,dart-sdk-linux-try,pkg-linux-release-try,vm-ffi-android-release-arm-try,vm-ffi-android-release-arm64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/178200
Reviewed-by: Aske Simon Christensen <askesc@google.com>
2021-02-17 11:39:42 +00:00
Jens Johansen
f169abcee0 [CFE] Make standard filesystem more synchronous by default; add async versions
This CL:
 * Makes the standard filesystem more synchronous by default.
   This makes reading files for normal compiles faster.
 * Adds a more asynchronous version of `exists` and `readAsBytes`.
   This potentially allows for reading files faster when in a context
   where the files can actually be read in parallel. The client have
   to make the choise though.
 * Skips `Uri.base.resolveUri` when the uri has a scheme. This makes it
   slightly faster in my tests, but does not remove any `.` and `..`.
   Having those when having a scheme seems sort of weird though.
   If this turns out to be a problem we can add it back.
 * Re-orders what the standard filesystem checks in `exists` to assume files
   which seems more likely to happen. This - for files - means less checks
   and should make checking for existance faster. (This was noticed by Siggi).

Using the same measurement procedure as in
https://dart-review.googlesource.com/c/sdk/+/85442
timing how long fasta spends on *reading* files when compiling dart2js
(when compiling via the VM) I get a good speedup.

Note that the measurements are in microseconds:

Before this CL (run like `out/ReleaseX64/dart pkg/compiler/bin/dart2js.dart 2>&1 | grep "Read file (total)" | tail -n 1` 10 times):
Read file (total): 94678
Read file (total): 94232
Read file (total): 91726
Read file (total): 77472
Read file (total): 95582
Read file (total): 88113
Read file (total): 89245
Read file (total): 91575
Read file (total): 96291
Read file (total): 95730

With this CL (run like `out/ReleaseX64/dart pkg/compiler/bin/dart2js.dart 2>&1 | grep "Read file (total)" | tail -n 1` 10 times):
Read file (total): 68379
Read file (total): 69320
Read file (total): 72930
Read file (total): 69692
Read file (total): 68685
Read file (total): 73548
Read file (total): 64649
Read file (total): 71951
Read file (total): 73486
Read file (total): 70621

Difference at 95.0% confidence
        -21138.3 +/- 4193
        -23.111% +/- 4.5843%
        (Student's t, pooled s = 4462.56)


Furthermore, using an internal benchmark (discussed in an email thread)
I get these numbers (note that the measurements are in milliseconds):

before:
4453
4249
4187
4190
4216

after:
2310
2379
2449
2467
2407

Difference at 95.0% confidence
        -1856.6 +/- 131.443
        -43.5924% +/- 3.08625%
        (Student's t, pooled s = 90.1257)

Using the asynchronous versions of exists and readAsBytes and checking for
existance and reading in parallel on the same internal benchmark it gets to
1137
1185
1067
1089
1189


For completion, comparing to using "raw" `File` (again using the internal benchmark):

sequential standard
2377
2419
2485
2373
2431

sequential io_sync
2279
2182
2237
2312
2324

io_sync faster:
        -150.2 +/- 76.3122
        -6.21432% +/- 3.15731%
        (Student's t, pooled s = 52.3245)

sequential standardasync
4865
4915
4753
5185
4760

sequential io_async
4746
4834
4989
4840
4891

No difference proven at 95.0% confidence

parallel standard
2526
2563
2652
2616
2685

parallel io_sync
2335
2184
2244
2341
2401

io_async faster
Difference at 95.0% confidence
        -307.4 +/- 111.037
        -11.785% +/- 4.25691%
        (Student's t, pooled s = 76.1341)

parallel standardasync
1137
1185
1067
1089
1189

parallel io_async
1105
1088
1145
1048
1113

No difference proven at 95.0% confidence

TEST=Existing tests.

Change-Id: I8ba56ab0768df8672bcdb693782d3f1eec86b683
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/185101
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Gary Roumanis <grouma@google.com>
2021-02-17 10:28:00 +00:00
Jens Johansen
2d064faf74 [CFE] Incremental compiler guards against multiple simultaneous calls to computeDelta
package:vm "clones" an old incremental compiler when creating a new one
for a new isolate. It does that by calling .computeDelta on the first
available compiler. If that compiler is already compiling, though, things
can go bad.

The risk of that happening was made bigger by awaiting in the standard
filesystem instead of using the sync filesystem operations, but it can
happen either way.

If it has any practial importance (outside of tests) is an open quesiton
but this should nevertheless fix the issue by only letting the
incremental compiler allow one compile at the time (creating an implicit
queue when more is tried).

TEST=Existing test suites + added test.

Change-Id: I694e360aa4bce604db41908730c66ef3b96e6d8b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/184788
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2021-02-16 08:32:56 +00:00
Johnni Winther
0578c66a98 [kernel] Remove TreeNode.remove
+ restrict replaceWith and replaceChild to only support replacement and
not removal.

TEST=existing

Change-Id: I5381b4907725dd0ea7cf544e133bdb296df48ee0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/184469
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2021-02-16 08:18:51 +00:00
Daco Harkes
34e3f571ac Reland "[vm/ffi] Disallow empty Structs"
Closes: https://github.com/dart-lang/sdk/issues/43974

TEST=tests/ffi/vmspecific_static_checks_test.dart

Change-Id: I35e6f5315826a751e5ce017a6a618c2c224c0f84
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/180189
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
2021-02-12 15:35:29 +00:00
Daco Harkes
0bada8c212 [cfe/ffi] Refactor dart:ffi transformations
Introduces the `NativeTypeCfe` type hierarchy for cleaner calculation
of sizes and offsets of native types and cleaner code generation.

The transformation ensures we're only visiting the structs in
topological order, which means the struct type can always look up its
(indirectly) nested structs in the `structCache`.

This simplifies adding inline arrays
(https://dart-review.googlesource.com/c/sdk/+/183640), packed structs,
and unions to this transformation.

`typedDataBaseOffset` is moved to the `FfiTransformer` because the
dependent CL uses it in the `FfiUseSiteTransformer`.

Bug: https://github.com/dart-lang/sdk/issues/35763
Bug: https://github.com/dart-lang/sdk/issues/38158
Bug: https://github.com/dart-lang/sdk/issues/38491

TEST=tests/ffi(_2)/(.*)by_value(.*)_test.dart

Change-Id: I345e02c48844ca795f9137a5addd5ba89992e1c9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/184421
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Reviewed-by: Clement Skau <cskau@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2021-02-11 18:09:05 +00:00
Daco Harkes
fca959e5f6 [vm/ffi] Add class to vm:ffi:struct-fields pragma
This CL changes `@pragma('vm:ffi:struct-fields', [...])` to
`@pragma('vm:ffi:struct-fields', _FfiStructLayout([...]))` which makes
it easier to add more data in subsequent CLs.

Extends `FindPragma` to allow returning multiple matched pragma's, so
that we can filter them. (In this case to avoid matching user-defined
pragma's that do not have an instance of the private class.)

Separated out from https://dart-review.googlesource.com/c/sdk/+/183640
because of the extra constant in existing expectation files.

Bug: https://github.com/dart-lang/sdk/issues/35763
Bug: https://github.com/dart-lang/sdk/issues/38158

TEST=tests/ffi(_2)/*_by_value_*_test.dart

Change-Id: Idef9f82e9b53c2a32dffabcec19669eae550fe2f
Cq-Include-Trybots: luci.dart.try:front-end-nnbd-mac-release-x64-try,front-end-linux-release-x64-try,vm-precomp-ffi-qemu-linux-release-arm-try,vm-kernel-nnbd-linux-debug-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/184181
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Clement Skau <cskau@google.com>
2021-02-11 18:09:05 +00:00
Johnni Winther
ee0c0bcd57 Reland "[kernel] Ensure that visitors don't implicitly returns null"
This is in preparation to migrate package:kernel to null safety.
For the visitor interfaces to support non-nullable return types, the
implementations must avoid using `null` as return value in its base case.

TEST=Refactoring

Change-Id: Ie8fa5d41b99850d9e4abb59634c72920c64128d9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/183691
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2021-02-10 07:51:52 +00:00
Johnni Winther
b60e0aa5a1 Revert "[kernel] Ensure that visitors don't implicitly returns null"
This reverts commit ce81216885.

Reason for revert: Flutter dependency

Original change's description:
> [kernel] Ensure that visitors don't implicitly returns `null`
>
> This is in preparation to migrate package:kernel to null safety.
> For the visitor interfaces to support non-nullable return types, the
> implementations must avoid using `null` as return value in its base case.
>
> TEST=Refactoring
>
> Change-Id: Ie5e4153f8d3779d94957bb13b3d2d2a942040ff2
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/179760
> Commit-Queue: Johnni Winther <johnniwinther@google.com>
> Reviewed-by: Jens Johansen <jensj@google.com>

TBR=jensj@google.com,johnniwinther@google.com

Change-Id: I61b838d3371e6b1de2427716d056324c120be499
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/183689
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2021-02-09 12:41:12 +00:00
Johnni Winther
ce81216885 [kernel] Ensure that visitors don't implicitly returns null
This is in preparation to migrate package:kernel to null safety.
For the visitor interfaces to support non-nullable return types, the
implementations must avoid using `null` as return value in its base case.

TEST=Refactoring

Change-Id: Ie5e4153f8d3779d94957bb13b3d2d2a942040ff2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/179760
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2021-02-09 09:46:46 +00:00
Dmitry Stefantsov
63737581f8 [cfe] Encourage the use of the const NeverType objects
TEST=Covered by existing test base.
Change-Id: Ie858bd5a765d71fa4095eab3373a6ecdb063b260
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/183006
Commit-Queue: Dmitry Stefantsov <dmitryas@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2021-02-08 10:36:40 +00:00
Daco Harkes
d052156ea4 [vm/ffi] Remove .ref VM runtime entry
After https://dart-review.googlesource.com/c/sdk/+/180190 the runtime
entry has become dead code.

This CL keeps the runtime entry itself but makes it unreachable as was
the suggestion on previous a CL removing runtime entries:
https://dart-review.googlesource.com/c/sdk/+/169406

Bug: https://github.com/dart-lang/sdk/issues/38648
Bug: https://github.com/dart-lang/sdk/issues/38721

TEST=tests/ffi/vmspecific_static_checks_test.dart
TEST=tests/ffi/*struct*test_.dart

Change-Id: I84c5c925215b9dbd999826fb390df91d8050e1dd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/182627
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2021-02-04 21:31:29 +00:00
Daco Harkes
fb624c4209 Reland "[vm/ffi] Change Pointer<T extends Struct>.ref to use static type"
This CL changes the semantics of `Pointer<T extends Struct>.ref` to use
the compile-time `T` rather than the runtime `T`.

This enables tree shaking of subtypes of Struct and optimizing `.ref`.

Bug: https://github.com/dart-lang/sdk/issues/38721

TEST=tests/ffi/vmspecific_static_checks_test.dart
TEST=tests/ffi/*struct*test_.dart

Change-Id: Ie19bc3259d1cb721d0ce56d68e82d09dc3a4ad0e
Cq-Include-Trybots: luci.dart.try:analyzer-linux-release-try,analyzer-nnbd-linux-release-try,app-kernel-linux-debug-x64-try,dart-sdk-linux-try,front-end-nnbd-linux-release-x64-try,pkg-linux-debug-try,vm-kernel-linux-debug-x64-try,vm-kernel-nnbd-linux-debug-x64-try,vm-kernel-precomp-nnbd-linux-debug-x64-try,vm-kernel-reload-rollback-linux-debug-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/180190
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
2021-02-03 10:55:49 +00:00
Daco Harkes
75c17483d3 [vm/ffi] Rewrite .ref calls in CFE
This rewrites `Pointer<Struct>.ref` and `Pointer<Struct>[]` calls in
the CFE to skip the runtime entry when the type argument is constant.

The runtime entry is still used when the type argument is generic.
Forcing the type argument to be constant and removing the runtime entry
will be done in follow up CLs.

Bug: https://github.com/dart-lang/sdk/issues/38721
Bug: https://github.com/dart-lang/sdk/issues/44621

Removing the runtime entry speeds up `.ref` significantly.
before: FfiStruct.FieldLoadStore(RunTime): 18868.140186915887 us.
after: FfiStruct.FieldLoadStore(RunTime): 270.5877976190476 us.
Measurements from Linux x64 in JIT mode.

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

TEST=tests/ffi/structs_test.dart

Change-Id: I82abd930b5a9c5c78a8999c2bc49802d67d37534
Cq-Include-Trybots: luci.dart.try:analyzer-linux-release-try,analyzer-nnbd-linux-release-try,app-kernel-linux-debug-x64-try,dart-sdk-linux-try,front-end-nnbd-linux-release-x64-try,pkg-linux-debug-try,vm-kernel-linux-debug-x64-try,vm-kernel-nnbd-linux-debug-x64-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-nnbd-linux-debug-x64-try,vm-kernel-reload-linux-debug-x64-try,vm-kernel-reload-rollback-linux-debug-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/182265
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Clement Skau <cskau@google.com>
2021-02-02 16:33:54 +00:00
Daco Harkes
7cb49e2fb0 [vm/ffi] Rewrite Allocator.call calls in CFE
This rewrites `Allocator.call` calls in the CFE to skip the runtime
entry for `sizeOf` when the type argument is constant.

The runtime entry is still used when the type argument is generic.
Forcing the type argument to be constant and removing the runtime entry
will be done in follow up CLs.

Bug: https://github.com/dart-lang/sdk/issues/44621
Bug: https://github.com/dart-lang/sdk/issues/38721

TEST=test/ffi (almost all of them)

Change-Id: I5e855fa2b63a5c1b7fa70dbaa1b89c122a82da6e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/182264
Reviewed-by: Clement Skau <cskau@google.com>
2021-02-02 16:33:54 +00:00
Daco Harkes
1fff52a715 [vm/ffi] Rewrite Pointer.elementAt calls in CFE
This rewrites `elementAt` calls in the CFE to skip the runtime entry
for `sizeOf` when the type argument is constant.

The runtime entry is still used when the type argument is generic.
Forcing the type argument to be constant and removing the runtime entry
will be done in follow up CLs.

Bug: https://github.com/dart-lang/sdk/issues/44621
Bug: https://github.com/dart-lang/sdk/issues/38721

TEST=tests/ffi/data_test.dart

Change-Id: I480db43e7c115c24bd45f0ddab0cfea7eb8cfa58
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/182263
Reviewed-by: Clement Skau <cskau@google.com>
2021-02-02 16:33:54 +00:00
Daco Harkes
64bf73460f [vm/ffi] Rewrite sizeOf calls in CFE
This rewrites `sizeOf` calls in the CFE to skip the runtime entry when
the type argument is constant.

The runtime entry is still used when the type argument is generic.
Forcing the type argument to be constant and removing the runtime entry
will be done in follow up CLs.

Bug: https://github.com/dart-lang/sdk/issues/44621
Bug: https://github.com/dart-lang/sdk/issues/38721

TEST=tests/ffi/sizeof_test.dart

Change-Id: I17d14432e6ab22810729be6b5c2939a033d382c5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/182262
Reviewed-by: Clement Skau <cskau@google.com>
2021-02-02 16:33:54 +00:00
asiva
ac520f984d [ VM / CLI ] Add --verbosity to VM options
The verbosity option allows for specifying the CFE output verbosity

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

TEST=existing tests compile_test.dart and run_test.dart have new tests

Change-Id: I3d4e50811f84650aacf774ddb370a6eb765b9b24
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/181100
Commit-Queue: Siva Annamalai <asiva@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2021-01-26 03:01:58 +00:00
Johnni Winther
97a4280e52 [cfe,dartdev,dart2js] Add support for --verbosity option
In response to https://github.com/dart-lang/sdk/issues/44727

TEST=pkg/dartdev/test/commands/compile_test.dart

Change-Id: I56b67d9362a415acd721c1cce2f7e2232d2493df
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/180566
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2021-01-22 18:33:44 +00:00
Daco Harkes
d74b2f4672 [vm/ffi] Deprecate Pointer.elementAt and sizeOf generic calls
The analyzer and CFE now report a warning on calls to
`Pointer<T extends NativeType>.elementAt()` and
`sizeOf<T extends NativeType>()` where `T` is a generic.

Adapted from https://dart-review.googlesource.com/c/sdk/+/178200 to
only deprecate but not error out on generic calls.

Does not roll forward `package:ffi` to a version with the `Allocator`
but keeps the generic `sizeOf` invocation. This causes extra warnings
in the pkg/front_end testcases.

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

TEST=tests/ffi/data_test.dart
TEST=tests/ffi/sizeof_test.dart
TEST=tests/ffi/structs_test.dart
TEST=tests/ffi/vmspecific_static_checks_test.dart

Change-Id: I8f41c4dc04fc44e7e6c540ba87a3f41604130fe9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/180560
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2021-01-22 13:58:09 +00:00
Daco Harkes
f74c9d43d3 [vm/ffi] Deprecate Pointer<T extends Struct>.ref generic calls
The analyzer and CFE now report a warning on calls to
`Pointer<T extends Struct>.ref` and `Pointer<T extends Struct>.[]`
where `T` is a generic.

Adapted from https://dart-review.googlesource.com/c/sdk/+/180190 to
only deprecate but not error out on generic calls to `.ref` and `[]`.

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

TEST=tests/ffi/vmspecific_static_checks_test.dart

Change-Id: I81353089d59f093730d63792e9dbcd0b2ff0c432
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/180365
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2021-01-22 13:58:09 +00:00
Daco Harkes
c3b30df798 [vm/ffi] Deprecate empty Structs
The analyzer and CFE now report a warning on subclasses of `Struct`
which have no native fields.

Adapted from https://dart-review.googlesource.com/c/sdk/+/180189 to
only deprecate, but not disallow empty structs.

Rolls `package:ffi` forward to migrate `Utf8` and `Utf16` to `Opaque`
to prevent tests from failing on those generating warnings for empty
structs.

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

TEST=tests/ffi/vmspecific_static_checks_test.dart

Change-Id: Ia364e31da66cb195570c2e2b729d03dd261f28a2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/180361
Reviewed-by: Clement Skau <cskau@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2021-01-22 13:58:09 +00:00
Johnni Winther
55b34a467c Reland "[vm] Pass snapshot flag to kernel_service"
Enable reporting of null safety compilation mode when running
`dart compile aot-snapshot`, `dart compile jit-snapshot`,
and `dart compile kernel`.

Closes #44234

TEST=pkg/dartdev/test/commands/compile_test.dart

Change-Id: Id9e72751068d5f208055ab953d2c8392e84c4798
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/180187
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2021-01-21 21:18:32 +00:00
Daco Harkes
1fe4597638 Revert "[vm/ffi] Disallow empty structs"
Revert submission 177862

Reason for revert: breaks g3 without https://github.com/flutter/engine/pull/23808
Reverted Changes:
I50b3b4c31:[vm/ffi] Roll `package:ffi` to `Allocator` and `Op...
I3f5b08c08:[vm/ffi] Change `Pointer<T extends Struct>.ref` to...
I6141c193b:[vm/ffi] Disallow empty structs

Change-Id: Ibe9e8200dbdafe0ee684a6a0ea19e06214edf5e0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/180184
Reviewed-by: Daco Harkes <dacoharkes@google.com>
2021-01-20 21:37:11 +00:00
Daco Harkes
49ec189fb3 Revert "[vm/ffi] Change Pointer<T extends Struct>.ref to use s..."
Revert submission 177862

Reason for revert: breaks g3 without https://github.com/flutter/engine/pull/23808
Reverted Changes:
I50b3b4c31:[vm/ffi] Roll `package:ffi` to `Allocator` and `Op...
I3f5b08c08:[vm/ffi] Change `Pointer<T extends Struct>.ref` to...
I6141c193b:[vm/ffi] Disallow empty structs

Change-Id: I1bfe4d70a5f7f35039b8a01d599d33542872574c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/180183
Reviewed-by: Daco Harkes <dacoharkes@google.com>
2021-01-20 21:37:11 +00:00
Daco Harkes
2e8f9b85a6 [vm/ffi] Change Pointer<T extends Struct>.ref to use static type
This CL changes the semantics of `Pointer<T extends Struct>.ref` to use
the compile-time `T` rather than the runtime `T`.

This enables tree shaking of subtypes of Struct and optimizing `.ref`.

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

TEST=tests/ffi/vmspecific_static_checks_test.dart
TEST=tests/ffi/*struct*test_.dart

Change-Id: I3f5b08c08ec0799ef8aab3c4177e2ac70d25501c
Cq-Include-Trybots: luci.dart.try:vm-precomp-ffi-qemu-linux-release-arm-try,analyzer-analysis-server-linux-try,analyzer-linux-release-try,analyzer-nnbd-linux-release-try,front-end-linux-release-x64-try,front-end-nnbd-linux-release-x64-try,benchmark-linux-try,dart-sdk-linux-try,pkg-linux-release-try,vm-ffi-android-release-arm-try,vm-ffi-android-release-arm64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/177862
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
2021-01-20 18:08:25 +00:00
Daco Harkes
1a71f94998 [vm/ffi] Disallow empty structs
Closes: https://github.com/dart-lang/sdk/issues/43974

TEST=tests/ffi/vmspecific_static_checks_test.dart

Change-Id: I6141c193b6ac71e0dce2735322c62ffd84554cef
Cq-Include-Trybots: luci.dart.try:vm-precomp-ffi-qemu-linux-release-arm-try,analyzer-analysis-server-linux-try,analyzer-linux-release-try,analyzer-nnbd-linux-release-try,front-end-linux-release-x64-try,front-end-nnbd-linux-release-x64-try,benchmark-linux-try,dart-sdk-linux-try,pkg-linux-release-try,vm-ffi-android-release-arm-try,vm-ffi-android-release-arm64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/177710
Reviewed-by: Aske Simon Christensen <askesc@google.com>
2021-01-20 18:08:25 +00:00
Johnni Winther
e7a88b9f02 [vm] Tree shake stub targets
Stub target references for member signatures, forwarding stubs and mixin
stubs should be removed when tree shaking. Otherwise we might end up with
dangling references if the stub target was tree shaken.

Closes #44716

TEST=existing tests

Change-Id: I5fd67c0ab8db588ecbe5c40101bbea662e1ffb51
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/180141
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2021-01-20 17:07:45 +00:00
Alexander Markov
e200aebf83 [vm/aot/tfa] Add statistics for analysis time per TFA summary
While investigating AOT compilation time it could be useful to
understand which members were analyzed the most in TFA.

This change adds "global.type.flow.print.timings" environment flag to
measure and show top TFA summaries (roughly correspond to members)
which were analyzed most number of times and which took the most
time to analyze.

TEST=manual testing

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

Change-Id: I07d3253d1e6eb390074b7edf7c21686124a938d1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/179600
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
2021-01-19 18:55:42 +00:00
Alexander Markov
4f96421419 [vm/aot/tfa] Approximate wide cone types
In certain cases involving auto-generated Dart sources there could be a
huge number of allocated classes which are subtypes of a certain class.
Specializing such cone types to set types, as well as intersection and
union operations on such types may be slow and may severely affect
compilation time. Also, gradually discovering allocated classes in
such cone types may cause a lot of invalidations during analysis.

In order to avoid servere degradation of compilation time in such case,
this change adds WideConeType which works like a ConeType when number of
allocated classes is large, but it doesn't specialize to a SetType and
has more efficient but approximate implementation of union and
intersection.

Uncompressed size of Flutter gallery AOT snapshot (android/arm64):
WideConeType approximation for types with
>32 allocated subtypes: +0.1176%
>64 allocated subtypes: +0.0956%
>128 allocated subtypes: +0.0027%

For now conservative approximation is used when number of allocated
types >128.

TFA time of large app #1: 175s -> 119s (-32%)
TFA time of large app #2: 211s -> 81s (-61.6%)
Snapshot size changes are insignificant.

TEST=Stress tested on precomp bots with
maxAllocatedTypesInSetSpecializations = 3 and 0.

Issue: https://github.com/dart-lang/sdk/issues/42442
Issue: https://github.com/dart-lang/sdk/issues/43299
Change-Id: Idae33205ddda81714e4aeccc7ae292e0164be651
b/154155290, b/177498788, b/177497864
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/179200
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
2021-01-19 18:07:42 +00:00
Aske Simon Christensen
903e92a196 Revert "[vm] Pass snapshot flag to kernel_service"
This reverts commit f8b0d26cc3.

Reason for revert: Multiple test failures in app-jit and simarm(64)

Original change's description:
> [vm] Pass snapshot flag to kernel_service
>
> Enable reporting of null safety compilation mode when running
> `dart compile aot-snapshot`, `dart compile jit-snapshot`,
> and `dart compile kernel`.
>
> Closes #44234
>
> TEST=pkg/dartdev/test/commands/compile_test.dart
>
> Change-Id: I0d4b35c6ccb4167c0c7539a4eb24a5139e29cf53
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/178990
> Commit-Queue: Johnni Winther <johnniwinther@google.com>
> Reviewed-by: Ben Konyi <bkonyi@google.com>

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

Change-Id: I83aeaa8620c640d02d5ccfd1fe8112d8209a9ad4
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/179773
Auto-Submit: Aske Simon Christensen <askesc@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2021-01-18 21:00:03 +00:00
Johnni Winther
f8b0d26cc3 [vm] Pass snapshot flag to kernel_service
Enable reporting of null safety compilation mode when running
`dart compile aot-snapshot`, `dart compile jit-snapshot`,
and `dart compile kernel`.

Closes #44234

TEST=pkg/dartdev/test/commands/compile_test.dart

Change-Id: I0d4b35c6ccb4167c0c7539a4eb24a5139e29cf53
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/178990
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2021-01-18 09:27:59 +00:00
Johnni Winther
cad04f8604 [cfe,dart2js,dartdev] Show null safety mode for dart compile
This adds a new messages kind 'info' to the CFE for showing general
information during compilation. A 'configuration' options is added
to `CompilerOptions` for telling the CFE how it is run.

The configuration 'compile' is added for when the CFE is invoked to
produces an "executable" as when running `dart compile`. When
configuration is set, the CFE emits an info message about the
null safety compilation mode.

Support for `dart compile exe` and `dart compile js` is added in this
CL. Support for `dart compile kernel|app-jit|aot` is not included.

In response to https://github.com/dart-lang/sdk/issues/44234

TEST=pkg/dartdev/test/commands/compile_test.dart

Change-Id: I08f51e2a3f5ad4841c4d703bcd266b7afb63c7c6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/178982
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2021-01-15 11:28:13 +00:00
Alexander Markov
f4bb16232a [vm] Remove old version of protobuf-aware tree shaker
New, faster version of protobuf-aware tree shaker was introduced in
https://dart-review.googlesource.com/c/sdk/+/152100. It has been
used in Flutter use cases for a while.

This change replaces old version of transformation with the new one in
the pkg/vm/bin/protobuf_aware_treeshaker.dart tool and removes
the old version.

TEST=existing tests in pkg/vm/test/transformations

Change-Id: I01546ae9fdc9fea3228595270c2aff04a0894e6b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/178281
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Sigurd Meldgaard <sigurdm@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
2021-01-15 00:54:48 +00:00
Daco Harkes
5d40d52fca [vm/ffi] Add Opaque type
Issue: https://github.com/dart-lang/sdk/issues/44622
Issue: https://github.com/dart-lang/sdk/issues/43974

TEST=samples/ffi/sqlite/lib/src/bindings/types.dart
TEST=tests/ffi/vmspecific_static_checks_test.dart

Change-Id: Ib9e72df6a07b1bc2b72a7db66f945652814baf51
Cq-Include-Trybots: luci.dart.try:vm-precomp-ffi-qemu-linux-release-arm-try,analyzer-analysis-server-linux-try,analyzer-linux-release-try,analyzer-nnbd-linux-release-try,front-end-linux-release-x64-try,front-end-nnbd-linux-release-x64-try,benchmark-linux-try,dart-sdk-linux-try,pkg-linux-release-try,vm-ffi-android-release-arm-try,vm-ffi-android-release-arm64-try,vm-kernel-nnbd-win-debug-x64-try,vm-kernel-win-debug-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/178984
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Clement Skau <cskau@google.com>
2021-01-13 17:04:08 +00:00
Daco Harkes
4e2343c290 [vm/ffi] Introduce Allocator API
Introduces the Allocator API in `dart:ffi`.

This CL does not yet roll `package:ffi` to use `Allocator`, because that
breaks the checked in Dart in Fluter in g3. Instead, this coppies
`_MallocAllocator` from `package:ffi` into the ffi tests for testing.

This CL does not yet migrate off `allocate` and `free` in the SDK. That
is done in a dependent CL.

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

TEST=tests/ffi/allocator_test.dart
TEST=tests/ffi/calloc_test.dart
TEST=tests/ffi/vmspecific_static_checks_test.dart

Change-Id: I173e213a750b8b3f594bb8d4fc72575f2b6b91f7
Cq-Include-Trybots: luci.dart.try:vm-precomp-ffi-qemu-linux-release-arm-try,analyzer-analysis-server-linux-try,analyzer-linux-release-try,analyzer-nnbd-linux-release-try,front-end-linux-release-x64-try,front-end-nnbd-linux-release-x64-try,benchmark-linux-try,dart-sdk-linux-try,pkg-linux-release-try,vm-ffi-android-release-arm-try,vm-ffi-android-release-arm64-try,vm-kernel-nnbd-win-debug-x64-try,vm-kernel-win-debug-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/177705
Reviewed-by: Clement Skau <cskau@google.com>
2021-01-13 17:04:08 +00:00
Alexander Markov
9d1a307954 [vm] Add specialized factory constructors for small list literals
Flutter gallery in release mode:
AOT snapshot size arm64 -0.22%, arm -0.21%
instructions size arm64 -0.46%, arm -0.4%

TEST=existing tests

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

Change-Id: I4733e91ecf4601c0bcde725cf9e97f5db0b8bc13
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/175821
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2021-01-11 19:32:30 +00:00
Jens Johansen
5fac8d3d71 [CFE] Reproduction and fix of duplicate string-named 'abstract member-signature'
Before this CL, the map we use to "reuse" references when doing
experimental invalidation mapped from String to Reference.
In bug #44523 two abstract member-signatures have the same textual
(String) name meaning that via the lookup one would get the correct
one, one would get the wrong one, they would get the same one
which eventually causes a crash when trying to serialize.

This CL fixes the issue by mapping via the Name instead, which
basically - for private names - wraps the name and the library
which disambiguates it.

This CL also includes the reproduction of #44523.

Fixes #44523.

TEST=Mostly relying on existing test coverage.

Change-Id: Ib62ebca0b7f5092f0b8410d3c458663c3032eca1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/177704
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2021-01-07 13:11:18 +00:00
Alexander Markov
3bef6cf639 [vm/aot] Attach unboxing info to unreachable members
Unreachable members could be used as interface targets of dispatch
table calls, so they should have correct unboxing metadata.
This change fixes attaching unboxing info to such members.

TEST=runtime/tests/vm/dart/regress_44563_test.dart

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

Change-Id: I5da6a8d07048904eb94b05bfba11bdf72d655e12
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/177621
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2021-01-06 18:12:51 +00:00
Sam Rawlins
fee45f9554 VM: Remove unnecessary imports
TEST=Existing tests on existing bots

Bug: https://github.com/dart-lang/sdk/issues/44569
Change-Id: I0c8ee9afa85da3a1a39a983841e62956e76dd509
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/177242
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2020-12-30 14:52:48 +00:00
Johnni Winther
b4d4316de0 [cfe] Rename stub kinds
ForwardingStub -> AbstractForwardingStub
ForwardingSuperStub -> ConcreteForwardingStub
MixinStub -> AbstractMixinStub
MixinSuperStub -> ConcreteMixinStub

TEST=refactoring

Change-Id: Ice76a41ce8e1071f553ed8fd3ecbb29c97377161
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/177129
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2020-12-29 16:54:55 +00:00
Johnni Winther
42f09a71ba [vm] Re-resolve stub targets on mixin deduplication
This ensures that stub targets are re-resolved when performing
mixin deduplication. In particular member signatures, whose stub
target point the member signature origin, need to be re-resolved
since the origin is serialized together with the interface target
in PropertyGet, PropertySet and MethodInvocation, and if not
re-resolved, might point to removed members.

TEST=pkg/vm/test/modular_kernel_plus_ast_test.dart

Closes #44560

Change-Id: Ib2dd923fbf736a9defe2df38bbc71d442f80b7bb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/177127
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2020-12-29 15:01:35 +00:00
Johnni Winther
5ed4e5becd [cfe] Pass references instead of fields/procedures
TEST=refactoring

Change-Id: I6e2d46af9bd58673bda847ea5cf981616e1118b0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/176667
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
2020-12-29 11:46:15 +00:00
Johnni Winther
60702d4158 [cfe] Make field assignability immutable
Changes fields to be either mutable or immutable by construction.
This ensure that we don't create setter references for fields that
cannot be assigned to and is a prerequisite for replacing @fields/
@fields= canonical names with @getters/@setters.

TEST=existing expectation tests and verification

Change-Id: I70b9a504ee6f221b7c334ac02620feb0d5f7ae01
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/176665
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
2020-12-28 16:11:14 +00:00
Daco Harkes
b6b82dd3ac [vm/ffi] Support nested structs
This CL adds support for nested structs in FFI calls, callbacks, and
memory loads and stores through the Struct classes itself.

Nesting empty structs and nesting a structs in themselves (directly or
indirectly) is reported as error.

This feature is almost fully implemented in the CFE transformation.

Because structs depend on the sizes of their nested structs, the structs
now need to be processed in topological order.

Field access to nested structs branches at runtime on making a derived
Pointer if the backing memory of the outer struct was a Pointer or
making a TypedDataView if the backing memory of the outer struct was
a TypedData.

Assigning to a nested struct is a byte for byte copy from the source.

The only changes in the VM are contained in the native calling
convention calculation which now recursively needs to reason about
fundamental types instead of just 1 struct deep.

Because of the amount of corner cases in the calling conventions that
need to be covered, the tests are generated, rather than hand-written.

ABIs tested on CQ: x64 (Linux, MacOS, Windows), ia32 (Linux, Windows),
arm (Android softFP, Linux hardFP), arm64 Android.
ABIs tested locally through Flutter: arm64 iOS.
ABIs not tested: ia32 Android (emulator), x64 iOS (simulator), arm iOS.
TEST=runtime/bin/ffi_test/ffi_test_functions_generated.cc
TEST=runtime/bin/ffi_test/ffi_test_functions.cc
TEST=tests/{ffi,ffi_2}/function_structs_by_value_generated_test.dart
TEST=tests/{ffi,ffi_2}/function_callbacks_structs_by_value_generated_tes
TEST=tests/{ffi,ffi_2}/function_callbacks_structs_by_value_test.dart
TEST=tests/{ffi,ffi_2}/vmspecific_static_checks_test.dart

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

Contains a temporary workaround for
https://github.com/dart-lang/sdk/issues/44454.

Change-Id: I5e5d10e09e5c3fc209f5f7e997efe17bd362214d
Cq-Include-Trybots: luci.dart.try:dart-sdk-linux-try,dart-sdk-mac-try,dart-sdk-win-try,vm-ffi-android-debug-arm-try,vm-ffi-android-debug-arm64-try,vm-kernel-asan-linux-release-x64-try,vm-kernel-mac-debug-x64-try,vm-kernel-linux-debug-ia32-try,vm-kernel-linux-debug-x64-try,vm-kernel-nnbd-linux-debug-x64-try,vm-kernel-nnbd-linux-debug-ia32-try,vm-kernel-nnbd-mac-release-x64-try,vm-kernel-nnbd-win-debug-x64-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-debug-simarm_x64-try,vm-kernel-precomp-nnbd-linux-debug-x64-try,vm-kernel-precomp-win-release-x64-try,vm-kernel-reload-linux-debug-x64-try,vm-kernel-reload-rollback-linux-debug-x64-try,vm-kernel-win-debug-x64-try,vm-kernel-win-debug-ia32-try,vm-precomp-ffi-qemu-linux-release-arm-try,vm-kernel-precomp-obfuscate-linux-release-x64-try,vm-kernel-msan-linux-release-x64-try,vm-kernel-precomp-msan-linux-release-x64-try,vm-kernel-precomp-android-release-arm_x64-try,analyzer-analysis-server-linux-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/169221
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
2020-12-18 09:34:35 +00:00
Johnni Winther
76dcd9e37d [cfe] Ensure implicit-as and typedef reference are legacy erased
TEST=existing expectation tests

Change-Id: I48571347ef95b709a0804d284902ac6af7115afd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/176083
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
2020-12-15 15:34:40 +00:00
Daco Harkes
3e7cda8a4e [vm/ffi] Support passing structs by value
This CL adds passing structs by value in FFI trampolines.
Nested structs and inline arrays are future work.
C defines passing empty structs as undefined behavior, so that is not
supported in this CL.

Suggested review order:
1) commit message
2) ffi/marshaller (decisions for what is done in IL and what in MC)
3) frontend/kernel_to_il (IL construction)
4) backend/il (MC generation from IL)
5) rest in VM

Overall architecture is that structs are split up into word-size chunks
in IL when this is possible: 1 definition in IL per chunk, 1 Location in
IL per chunk, and 1 NativeLocation for the backend per chunk.
In some cases it is not possible or less convenient to split into
chunks. In these cases TypedDataBase objects are stored into and loaded
from directly in machine code.
The various cases:
- FFI call arguments which are not passed as pointers: pass individual
  chunks to FFI call which already have the right location.
- FFI call arguments which are passed as pointers: Pass in TypedDataBase
  to FFI call, allocate space on the stack, and make a copy on the stack
  and pass the copies' address to the callee.
- FFI call return value: pass in TypedData to FFI call, and copy result
  in machine code.
- FFI callback arguments which are not passed as pointers: IL definition
  for each chunk, and populate a new TypedData with those chunks.
- FFI callback arguments which are passed as pointer: IL definition for
  the pointer, and copying of contents in IL.
- FFI return value when location is pointer: Copy data to callee result
  location in IL.
- FFI return value when location is not a pointer: Copy data in machine
  code to the right registers.

Some other notes about the implementation:
- Due to Store/LoadIndexed loading doubles from float arrays, we use
  a int32 instead and use the BitCastInstr.
- Linux ia32 uses `ret 4` when returning structs by value. This requires
  special casing in the FFI callback trampolines to either use `ret` or
  `ret 4` when returning.
- The 1 IL definition, 1 Location, and 1 NativeLocation approach does
  not remove the need for special casing PairLocations in the machine
  code generation because they are 1 Location belonging to 1 definition.

Because of the amount of corner cases in the calling conventions that
need to be covered, the tests are generated, rather than hand-written.

ABIs tested on CQ: x64 (Linux, MacOS, Windows), ia32 (Linux, Windows),
arm (Android softFP, Linux hardFP), arm64 Android.
ABIs tested locally through Flutter: ia32 Android (emulator), x64 iOS
(simulator), arm64 iOS.
ABIs not tested: arm iOS.
TEST=runtime/bin/ffi_test/ffi_test_functions_generated.cc
TEST=runtime/bin/ffi_test/ffi_test_functions.cc
TEST=tests/{ffi,ffi_2}/function_structs_by_value_generated_test.dart
TEST=tests/{ffi,ffi_2}/function_callbacks_structs_by_value_generated_tes
TEST=tests/{ffi,ffi_2}/function_callbacks_structs_by_value_test.dart
TEST=tests/{ffi,ffi_2}/vmspecific_static_checks_test.dart

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

Change-Id: I474d3a4ee1faadbe767ddadd1b696e24d8dc364c
Cq-Include-Trybots: luci.dart.try:dart-sdk-linux-try,dart-sdk-mac-try,dart-sdk-win-try,vm-ffi-android-debug-arm-try,vm-ffi-android-debug-arm64-try,vm-kernel-asan-linux-release-x64-try,vm-kernel-mac-debug-x64-try,vm-kernel-linux-debug-ia32-try,vm-kernel-linux-debug-x64-try,vm-kernel-nnbd-linux-debug-x64-try,vm-kernel-nnbd-linux-debug-ia32-try,vm-kernel-nnbd-mac-release-x64-try,vm-kernel-nnbd-win-debug-x64-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-debug-simarm_x64-try,vm-kernel-precomp-nnbd-linux-debug-x64-try,vm-kernel-precomp-win-release-x64-try,vm-kernel-reload-linux-debug-x64-try,vm-kernel-reload-rollback-linux-debug-x64-try,vm-kernel-win-debug-x64-try,vm-kernel-win-debug-ia32-try,vm-precomp-ffi-qemu-linux-release-arm-try,vm-kernel-precomp-obfuscate-linux-release-x64-try,vm-kernel-msan-linux-release-x64-try,vm-kernel-precomp-msan-linux-release-x64-try,vm-kernel-precomp-android-release-arm_x64-try,analyzer-analysis-server-linux-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/140290
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2020-12-14 16:22:48 +00:00
Johnni Winther
5dbb6e245b [kernel,cfe,ddc] Add new method invocation node to package:kernel
This adds
* InstanceInvocation, DynamicInvocation, FunctionInvocation, and
   LocalFunctionInvocation, EqualsCall, and EqualsNull as a future
   replacement for MethodInvocation.
* InstanceGet, DynamicGet, InstanceTearOff, and FunctionTearOff as a
   future replacement for PropertyGet
* InstanceSet and DynamicSet as a future replacement of PropertySet
* StaticTearOff as an addition to StaticGet

TEST=pkg/front_end/test/binary_md_vm_tags_and_version_test.dart

This CL combines
* https://dart-review.googlesource.com/c/sdk/+/171729
* https://dart-review.googlesource.com/c/sdk/+/172649
* https://dart-review.googlesource.com/c/sdk/+/172650
* https://dart-review.googlesource.com/c/sdk/+/172651

using the initial encoding fo EqualsCall and EqualsNull

Change-Id: I98e020b5f2b405a812663bdcd2c05aba8efa74c8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/175480
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2020-12-14 10:55:48 +00:00
Jens Johansen
6c19a8fc81 [VM] Read and report constant constructor coverage from dill (2nd try)
This CL makes use of the now included constant constructor coverage
in the dill file.

It works like this:
* When the CFE evaluates constants, every constant constructor
  invocation evaluated saves the reference to the constructor in the
  `Source` (from the Components uri to source table) for the callers
  Library.
* This data is loaded into the VM in a "raw" format.
* When a request for coverage comes in, the VM - on top of the normal
  coverage processing - goes through all scripts to find constant
  constructor coverage for the requested script and offset. Note that
  all scripts must be checked because library A can have evaluated a
  constructor from library B - so even if only coverage for library B
  was requested, library A has to be checked.
  For all constructors found the start and end position is reported as
  covered. Note that this does not mark any initializes and there are
  (at least currently) no good way of marking which initializes were
  evaluated (because it has to be stable across edits even when the
  `advanced invalidation feature` is enabled).
* Note that the reason for the coverage to work on references - as
  hinted above - is because we want it to be stable across hot reloads
  even if/when advanced invalidation is enabled. This means, that
  library A cannot record "positional coverage" for library B because
  library B might get (for instance) new comments that will make any old
  offsets invalid. By using references we always lookup in the current
  world and use the correct offsets.

https://github.com/dart-lang/sdk/issues/38934

TEST=Existing test suite, new tests for the new coverage added.

Change-Id: I29531247a4b91a99d9a459cfdefbb9798e9c948f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/175246
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2020-12-08 10:47:43 +00:00
Lasse R.H. Nielsen
6e29700e16 Update List constructor documentation, deprecate constructor.
Emphasize that the operation is going away,
and mark constructor as deprecated.

TEST= Refactoring+deprecation only, covered by existing tests.

Change-Id: I82aa044cd2cf7bf347b624371399f44bda8f4a07
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/173261
Commit-Queue: Lasse R.H. Nielsen <lrn@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
2020-12-07 16:20:28 +00:00
Alexander Markov
f04757f6ea [vm] Specialize List.empty calls for growable and fixed-length lists
TEST=existing tests for List

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

Change-Id: I89eecb15b535cc5a3e1aeea350a306883b463b9f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/175003
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2020-12-06 23:31:55 +00:00
Devon Carew
8cba879f46 Add additional validations to the pkg/ package pubspecs.
TEST=these are additional validations that we run on the bots

Redux of https://dart-review.googlesource.com/c/sdk/+/161040

Change-Id: Ia32ced5d48fbfeafacfa9e51dc4774d2e9425091
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/174601
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Devon Carew <devoncarew@google.com>
2020-12-02 17:27:18 +00:00
Johnni Winther
d51ab9b62a [cfe] Add ProcedureStubKind
The enum `ProcedureStubKind` together with the flag `isSynthetic`
replaces the flags `isForwardingStub`, `isForwardingSemiStub`,
`isNoSuchMethodForwarder` and `isMemberSignature`.

The semantics of the existing properties on `Procedure` is unchanged.

The new MixinStub and MixinSuperStub stub kinds are not used yet and
the stub target for NoSuchMethodForwarder is not set yet.

TEST=refactoring


Change-Id: I6e81970dbb4baf0229f43c2a0bf0d5e575e65043
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/174462
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
2020-12-02 16:35:58 +00:00
Jens Johansen
05bac41e39 Revert "[VM] Read and report constant constructor coverage from dill"
This reverts commit 5370c56c80.

Reason for revert: Failures on
dartk-android-product-arm
dartk-android-product-arm
dartkp-linux-release-arm-qemu

like this:

sizeof(ScriptLayout) got 64, Script_InstanceSize expected 56
../../runtime/vm/dart.cc: 160: error: CheckOffsets failed. Try updating offsets by running ./tools/run_offsets_extractor.sh

sizeof(ScriptLayout) got 64, AOT_Script_InstanceSize expected 56
../../runtime/vm/dart.cc: 160: error: CheckOffsets failed. Try updating offsets by running ./tools/run_offsets_extractor.sh


Original change's description:
> [VM] Read and report constant constructor coverage from dill
>
> This CL makes use of the now included constant constructor coverage
> in the dill file.
>
> It works like this:
> * When the CFE evaluates constants, every constant constructor
>   invocation evaluated saves the reference to the constructor in the
>   `Source` (from the Components uri to source table) for the callers
>   Library.
> * This data is loaded into the VM in a "raw" format.
> * When a request for coverage comes in, the VM - on top of the normal
>   coverage processing - goes through all scripts to find constant
>   constructor coverage for the requested script and offset. Note that
>   all scripts must be checked because library A can have evaluated a
>   constructor from library B - so even if only coverage for library B
>   was requested, library A has to be checked.
>   For all constructors found the start and end position is reported as
>   covered. Note that this does not mark any initializes and there are
>   (at least currently) no good way of marking which initializes were
>   evaluated (because it has to be stable across edits even when the
>   `advanced invalidation feature` is enabled).
> * Note that the reason for the coverage to work on references - as
>   hinted above - is because we want it to be stable across hot reloads
>   even if/when advanced invalidation is enabled. This means, that
>   library A cannot record "positional coverage" for library B because
>   library B might get (for instance) new comments that will make any old
>   offsets invalid. By using references we always lookup in the current
>   world and use the correct offsets.
>
> https://github.com/dart-lang/sdk/issues/38934
>
> TEST=Existing test suite, new tests for the new coverage added.
>
> Change-Id: I925963d1a9b9907efe621c72deb7348fa3be5ae8
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/171949
> Commit-Queue: Jens Johansen <jensj@google.com>
> Reviewed-by: Ben Konyi <bkonyi@google.com>
> Reviewed-by: Vyacheslav Egorov <vegorov@google.com>

TBR=vegorov@google.com,bkonyi@google.com,jensj@google.com

Change-Id: I5187e6749d59ded250ec0933a94db0536485b70a
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/174470
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2020-12-01 14:12:16 +00:00
Jens Johansen
5370c56c80 [VM] Read and report constant constructor coverage from dill
This CL makes use of the now included constant constructor coverage
in the dill file.

It works like this:
* When the CFE evaluates constants, every constant constructor
  invocation evaluated saves the reference to the constructor in the
  `Source` (from the Components uri to source table) for the callers
  Library.
* This data is loaded into the VM in a "raw" format.
* When a request for coverage comes in, the VM - on top of the normal
  coverage processing - goes through all scripts to find constant
  constructor coverage for the requested script and offset. Note that
  all scripts must be checked because library A can have evaluated a
  constructor from library B - so even if only coverage for library B
  was requested, library A has to be checked.
  For all constructors found the start and end position is reported as
  covered. Note that this does not mark any initializes and there are
  (at least currently) no good way of marking which initializes were
  evaluated (because it has to be stable across edits even when the
  `advanced invalidation feature` is enabled).
* Note that the reason for the coverage to work on references - as
  hinted above - is because we want it to be stable across hot reloads
  even if/when advanced invalidation is enabled. This means, that
  library A cannot record "positional coverage" for library B because
  library B might get (for instance) new comments that will make any old
  offsets invalid. By using references we always lookup in the current
  world and use the correct offsets.

https://github.com/dart-lang/sdk/issues/38934

TEST=Existing test suite, new tests for the new coverage added.

Change-Id: I925963d1a9b9907efe621c72deb7348fa3be5ae8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/171949
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2020-12-01 12:32:15 +00:00
Jens Johansen
27ed7912af [kernel] Constant coverage recorded in dill
This adds the recorded constant coverage to the dill file.

runtimes for constant evaluation:
dart2js: No difference proven at 95.0% confidence
flutter gallery: No difference proven at 95.0% confidence
big internal app: No difference proven at 95.0% confidence

sdk sizes:
vm: ~0.0182%
dart2js: ~0.0137%
flutter: ~0.0197%

compile sizes:
dart2js: ~0.0179%
flutter gallery: ~0.0162%
big internal app: ~0.0414%

TEST=test was fixed.

Change-Id: I347751e4d96d4d62140d26ebe37960f46a0dfbfa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/171948
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2020-12-01 12:30:14 +00:00
Clement Skau
2d36c85ff8 [vm] Removes support for --causal-async-stacks
All existing embedders have been opted into --lazy-async-stacks, the
VM also uses it as it's default in all configurations.

After this CL, any user of --causal-async-stacks will get an error
message when trying to use it.
=> In any such case, please simply remove the flag.

TEST=Exhaustive CQ.

Bug: https://github.com/dart-lang/sdk/issues/37668
Change-Id: Ia440afcf2dba464aa8b8cf381b93bbac8eb9f8dc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/172564
Commit-Queue: Clement Skau <cskau@google.com>
Reviewed-by: Clement Skau <cskau@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2020-12-01 07:27:14 +00:00
Johnni Winther
7a130ccc49 [cfe] Rename isNullableByDefault annotation to isLegacy
TEST=Existing tests

Change-Id: I0aad4deea062ba2016a8be47489ffaa970bfc03e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/174260
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
2020-11-27 13:36:29 +00:00
Aske Simon Christensen
dcd5a8f005 [vm/aot] Two improvements to signature shaking (reland)
- Global parameter use analysis: when a parameter is only used directly
  as arguments to other calls, only consider it used if any of the
  target parameters are used.

- A parameter can be eliminated if the TFA infers that it has a constant
  value in every implementation.

This change also extends the test of the protobuf-aware tree shaker to
run the AOT global transformations on all its test cases in order to
check that the protobuf handling in that code path is not broken by
signature shaking.

Reduces ARM64 .so size of Flutter Gallery by 0.25% uncompressed, 0.37%
with gzip and 0.45% with brotli.

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

TEST=Existing test suite, expectation files for TFA test, extended test
of protobuf-aware tree shaker.
Change-Id: Ib00fe362f798c92592a260f72e7bccad04246bb2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/173727
Commit-Queue: Aske Simon Christensen <askesc@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2020-11-26 09:20:55 +00:00
Johnni Winther
79f36c9d49 [kernel] Rename readUInt to readUInt30 to match corresponding write-method.
TEST=Refactoring

Change-Id: I455c498065785909fb175a0b5fa82bd9d5b38f1f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/173524
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2020-11-24 08:50:38 +00:00
Aske Simon Christensen
2149369ffd Revert "[vm/aot] Two improvements to signature shaking"
This reverts commit 09ee7d31a6.

Reason for revert: Broke protobuf aware tree shaker.

Original change's description:
> [vm/aot] Two improvements to signature shaking
>
> - Global parameter use analysis: when a parameter is only used directly
>   as arguments to other calls, only consider it used if any of the
>   target parameters are used.
>
> - A parameter can be eliminated if the TFA infers that it has a constant
>   value in every implementation.
>
> Reduces ARM64 .so size of Flutter Gallery by 0.25% uncompressed, 0.37%
> with gzip and 0.45% with brotli.
>
> TEST=Existing test suite, expectation files for TFA test.
> Change-Id: Iedae757f180c2215569b7a031a5f7dc0035a9b7d
> Cq-Do-Not-Cancel-Tryjobs: true
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/169884
> Commit-Queue: Aske Simon Christensen <askesc@google.com>
> Reviewed-by: Alexander Markov <alexmarkov@google.com>

TBR=kustermann@google.com,alexmarkov@google.com,askesc@google.com

Change-Id: Ib64149dee605c2efa38345130c4a18e5ed8e0a4b
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/173274
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Commit-Queue: Aske Simon Christensen <askesc@google.com>
2020-11-23 10:42:16 +00:00
Aske Simon Christensen
09ee7d31a6 [vm/aot] Two improvements to signature shaking
- Global parameter use analysis: when a parameter is only used directly
  as arguments to other calls, only consider it used if any of the
  target parameters are used.

- A parameter can be eliminated if the TFA infers that it has a constant
  value in every implementation.

Reduces ARM64 .so size of Flutter Gallery by 0.25% uncompressed, 0.37%
with gzip and 0.45% with brotli.

TEST=Existing test suite, expectation files for TFA test.
Change-Id: Iedae757f180c2215569b7a031a5f7dc0035a9b7d
Cq-Do-Not-Cancel-Tryjobs: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/169884
Commit-Queue: Aske Simon Christensen <askesc@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2020-11-23 09:43:43 +00:00
Ivan Inozemtsev
d0f3471dd9 Bump protobuf, bazel_worker, and dart2js_info
Protobuf and bazel_worker are migrated to null safety, dart2js_info
just broadens dependency version range to be compatible with null safe
protobuf.

Also regenerate test protos in vm test cases and update expected ASTs
and add support for conditional expressions to protobuf aware tree shaker.

Change-Id: I019f0fd6c5688302cc5127e1be8368a3ea600439
TEST= Covered by existing tests
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/172646
Commit-Queue: Ivan Inozemtsev <iinozemtsev@google.com>
Reviewed-by: Ivan Inozemtsev <iinozemtsev@google.com>
Reviewed-by: Sigurd Meldgaard <sigurdm@google.com>
Reviewed-by: Jake Macdonald <jakemac@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: David Morgan <davidmorgan@google.com>
2020-11-19 10:15:23 +00:00
Johnni Winther
887ab360e5 Revert "[kernel] Ensure that visitors don't implicitly returns null"
This reverts commit 4a3f121341.

The changes broke flutter/engine

TEST=It's a revert!

Change-Id: I1e65e6cfab03795a21a64a96fe3ed72e6ba8ecd9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/172760
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2020-11-18 14:51:30 +00:00
Johnni Winther
4a3f121341 [kernel] Ensure that visitors don't implicitly returns null
This is in preparation to migrate package:kernel to null safety.
For the visitor interfaces to support non-nullable return types, the
implementations must avoid using `null` as return value in its base case.

TEST=Refactoring

Change-Id: I9f9b318982148d844be9826a5f8c88374a9fc402
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/172180
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2020-11-18 11:54:30 +00:00
Alexander Markov
d1f32cccd3 [vm/aot/tfa] Do not infer that late fields without initializer are nullable
This CL teaches TFA that late fields without initializer are not
default-initialized with null.

TEST=Existing tests for late fields + write_only_field3_nnbd TFA unit test.

Change-Id: I9719beab06248ec84dd2db794c3f6eacabeb9c6e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/172480
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2020-11-17 17:42:38 +00:00
Aske Simon Christensen
b11d057572 [vm] Look for the recognized pragma in the unboxer and signature shaker.
This removes the conservative exclusion of everything below num in the
unboxer, and it allows some methods marked as entry points to not be
entry points, as they are not actually referred explicitly in VM code.

TEST=Existing test suite.
Change-Id: If465b9081ac278a105ba99c23a49f5516b7bfbc0
Cq-Do-Not-Cancel-Tryjobs: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/169401
Commit-Queue: Aske Simon Christensen <askesc@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2020-11-16 13:49:50 +00:00
Liam Appelbe
504e9a32f9 Reland "[wasm] Remove dart:wasm"
This is a reland of ade333dd54

Original change's description:
> [wasm] Remove dart:wasm
>
> I'm not entirely sure why I had to modify a random set of fingerprints
> in runtime/vm/compiler/recognized_methods_list.h, but when I did a debug
> build it had some fingerprint errors.
>
> Change-Id: Ib0a0cccb37f2efba509e2b37b6eabe790fa933c4
> TEST= Deleting stuff, so not really necessary
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/170620
> Commit-Queue: Liam Appelbe <liama@google.com>
> Reviewed-by: Liam Appelbe <liama@google.com>
> Reviewed-by: Ryan Macnak <rmacnak@google.com>

Change-Id: I0d1388f6312358cc62bb32f5ac7b88a3187223c9
TEST= Deleting stuff, so not really necessary
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/171940
Commit-Queue: Ivan Inozemtsev <iinozemtsev@google.com>
Reviewed-by: Liam Appelbe <liama@google.com>
2020-11-13 20:40:24 +00:00
Siva Annamalai
54a91f26c4 Revert "[wasm] Remove dart:wasm"
This reverts commit ade333dd54.

Reason for revert: This broke both the Flutter HHH and Google3 bots. It looks like some co-ordination is required between the Google3 and Flutter engine build changes for this CL to land.

Original change's description:
> [wasm] Remove dart:wasm
>
> I'm not entirely sure why I had to modify a random set of fingerprints
> in runtime/vm/compiler/recognized_methods_list.h, but when I did a debug
> build it had some fingerprint errors.
>
> Change-Id: Ib0a0cccb37f2efba509e2b37b6eabe790fa933c4
> TEST= Deleting stuff, so not really necessary
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/170620
> Commit-Queue: Liam Appelbe <liama@google.com>
> Reviewed-by: Liam Appelbe <liama@google.com>
> Reviewed-by: Ryan Macnak <rmacnak@google.com>

TBR=rmacnak@google.com,liama@google.com

Change-Id: I244d7b3549845dd71719176a62b6ec3a4c4b5f86
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/171860
Reviewed-by: Siva Annamalai <asiva@google.com>
2020-11-13 01:54:10 +00:00
Liam Appelbe
ade333dd54 [wasm] Remove dart:wasm
I'm not entirely sure why I had to modify a random set of fingerprints
in runtime/vm/compiler/recognized_methods_list.h, but when I did a debug
build it had some fingerprint errors.

Change-Id: Ib0a0cccb37f2efba509e2b37b6eabe790fa933c4
TEST= Deleting stuff, so not really necessary
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/170620
Commit-Queue: Liam Appelbe <liama@google.com>
Reviewed-by: Liam Appelbe <liama@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2020-11-12 19:22:29 +00:00
Johnni Winther
7b89827956 [cfe] Support bit mask for enabling specific late lowerings
TEST=pkg/front_end/testcases/late_lowering/late_lowering_bitmasks.dart

Closes #43993

Change-Id: I47d238dd7cf0ea22983a38bed86e415330070596
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/171580
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
2020-11-11 14:06:30 +00:00
Dmitry Stefantsov
d54e2bb568 [cfe,ddc,dart2js,vm] Add NullType
This CL is the sum of the following 5 CLs:
* https://dart-review.googlesource.com/c/sdk/+/170342/
* https://dart-review.googlesource.com/c/sdk/+/170344/
* https://dart-review.googlesource.com/c/sdk/+/170345/
* https://dart-review.googlesource.com/c/sdk/+/170346/
* https://dart-review.googlesource.com/c/sdk/+/170347/

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 #40122.

TEST=Verified by changes in .expect files in pkg/vm/.
Bug: https://github.com/dart-lang/sdk/issues/40122
Change-Id: Ib8197802fdc69694387ae47ac990c58b3aaab7a5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/170689
Commit-Queue: Dmitry Stefantsov <dmitryas@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2020-11-06 12:43:52 +00:00
Clement Skau
27ca552ddb [SDK] Replaces async's _AsyncAwaitCompleter with _Future.
Run time (less is better) impact:
dart:
- Calls.AwaitAsyncCall  -43.95% ~ -55.50%
- Calls.AwaitAsyncCallClosureTargetPolymorphic  -40.33% ~ -53.58%
- Calls.AwaitAsyncCallInstanceTargetPolymorphic  -42.69% ~ -55.65%
- Calls.AwaitFutureOrCallInstanceTargetPolymorphicManyAwaits  -42.05% ~ -56.14%
- Calls.Await...  0% ~ -13%
dart-aot:
- Calls.AwaitAsyncCall  -9.748% ~ -11.13%
- Calls.AwaitAsyncCallClosureTargetPolymorphic  -8.673% ~ -13.19%
- Calls.AwaitAsyncCallInstanceTargetPolymorphic  -9.799% ~ -11.74%
- Calls.AwaitFutureOrCallInstanceTargetPolymorphicManyAwaits  -5.412% ~ -13.43%

Code size impact:
- flutter_gallery_app_so_brotli_size  -0.1237% ~ -0.2410%
- flutter_gallery_readonlydata_size  0.1693% ~ 0.2041%
- flutter_gallery_instructions_size  0.1157% ~ 0.1779%
- flutter_gallery_total_size  0.1021% ~ 0.1413%

Bug: https://github.com/dart-lang/sdk/issues/39119
Change-Id: I64d28a8bea078277946d7be43737e265920c8f16
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/126322
Commit-Queue: Clement Skau <cskau@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2020-11-05 09:51:13 +00:00
Jens Johansen
9ec87c2da0 [kernel] Field has 2 references
Change-Id: I9c946119e55256b9fbcbf3076ea008aaa1312e86
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/168949
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2020-11-03 16:02:16 +00:00
Leaf Petersen
a6faf8f2f9 [Language] Enable null safety in Dart 2.12.
Closes https://github.com/dart-lang/sdk/issues/22

Change-Id: I662dd17fda0ff62a871314896fbf1dbe220f41de
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/166790
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Leaf Petersen <leafp@google.com>
2020-10-29 18:25:56 +00:00
Alexander Markov
061848e97e Cleanup misc remaining references to bytecode
Change-Id: I37c2dfb29a5bc4faf1478fb31623749cb8f67d67
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/169502
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
2020-10-28 21:51:20 +00:00
Alexander Markov
7588ed86de Remove bytecode mode from the VM
Change-Id: Ief167b7ffc128105a03cc225ab750234c9a6a7a0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/169147
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2020-10-28 17:42:35 +00:00
Jens Johansen
ae5fc78992 [kernel] Remove 'addMember'
Most of the time one already knows at the call site if it's a Field,
a Procedure etc --- so use that instead.

For now I'll leave the corresponding getters that are basically
documented as "don't use" ("[...] for convenience, not efficiency.
Consider manually iterating the members [...]").

Change-Id: Ib732759432c62963e6645f85f6df301c4281df9d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/168826
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2020-10-27 11:36:58 +00:00
asiva
6cee3b5fe1 [Test] Fix some errors seen when running test with non-nullability turned on.
Change-Id: If097edc7b31c208e36cee604339495634e99f30c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/169144
Commit-Queue: Siva Annamalai <asiva@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2020-10-27 01:51:37 +00:00
Kevin Moore
063c3ede72 Update pkg dependencies on pkg:analyzer
Now `pub get` actually succeeds on `pkg:front_end`

Change-Id: Ifdab9d6741efba034ecd56f27fd83e288267e46c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/168662
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Auto-Submit: Kevin Moore <kevmoo@google.com>
2020-10-26 19:30:06 +00:00
Aske Simon Christensen
23ee425de7 [vm/aot/tfa] Signature shaking for both static and instance methods
The existing signature shaker transforms optional and named parameters
of static and top-level methods and constructors into required
parameters whenever they are always passed.

This change improves signature shaking in a number of areas:
- Extend signature shaking to cover instance methods.
- Remove parameters which are never passed.
- Remove parameters which are not used.
- Transform signatures before unboxing, enabling transformed parameters
  to be unboxed.

TFA summaries for transformed functions are updated to stay in sync with
the program for later transformations.

Reduces instructions size of Flutter Gallery on ARM64 by 2.2%.

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

Change-Id: I39e364bc23b01e4502864d7369a745a9278cfb92
Cq-Do-Not-Cancel-Tryjobs: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/161175
Commit-Queue: Aske Simon Christensen <askesc@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2020-10-26 09:48:05 +00:00
Johnni Winther
45e3fb696d Revert "[cfe] Use origin location for member signatures"
This reverts commit ed3b948b88.

This CL caused out-of-memory on some Flutter tests.

Change-Id: Ib693f5b4a7271a070c1bab5861e49ac22437b8ca
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/168952
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2020-10-24 09:19:24 +00:00
Alexander Markov
1615c04c63 Remove bytecode generator
Change-Id: Ic5fd2ab67c10ae642ee277a5acd9b4084e059861
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/167762
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2020-10-23 19:30:43 +00:00
Johnni Winther
ed3b948b88 [cfe] Use origin location for member signatures
This is relanding https://dart-review.googlesource.com/c/sdk/+/168203
after it was reverted due to a problem in
https://dart-review.googlesource.com/c/sdk/+/168200

Change-Id: Id70d3e960b1edf1c5cdf92518b8e476084b1bb49
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/168645
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
2020-10-22 07:45:29 +00:00
Johnni Winther
b42f954364 [cfe] Use experiment release version when non-nullable is enabled explicitly
Even when non-nullable is enabled by default, enabling the experiment
explicitly should result in the experiment release version (and not
the experiment enabled version) to be used for opting in.

For this change, the semantics of parseExperimentalFlags was change
to _not_ normalize the flags to a full mapping including default values.
For this reason all uses of such maps are renamed to
'explicitExperimentalFlags'.

Closes #43879

Change-Id: I0d0262e68ec1403549abcfd305ae3a4404fe93e3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/168654
Reviewed-by: Jake Macdonald <jakemac@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2020-10-22 06:17:39 +00:00
Jens Johansen
29fa4e8148 [CFE et al] Compile flutter platform as agnostic for test; set component mode more
Bug: dartbug.com/43844 dartbug.com/43807
Change-Id: Iba662f0955897244aaac86ceace73b213fa06319
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/168482
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2020-10-21 10:04:41 +00:00
Michal Terepeta
5f18d498a0 Revert "[cfe] Avoid transforming members in other classes to no-such-method forwarders"
This reverts commit 87d3e03bf8.

Reason for revert: Breaks internal builds (http://b/171258924)


Revert "[cfe] Use CombinedMemberSignature to create noSuchMethod forwarders"

This reverts commit 13b7a83d57.

Reason for revert: Depends on a commit that breaks internal builds
(http://b/171258924)


Revert "[cfe] Use CombinedMemberSignature for creating simple legacy member signatures"

This reverts commit 170f05f91b.

Reason for revert: Depends on a commit that breaks internal builds
(http://b/171258924)


Revert "[cfe] Use origin location for member signatures"

This reverts commit 354dcf4386.

Reason for revert: Depends on a commit that breaks internal builds
(http://b/171258924)

Change-Id: I51f524949f259351336a77f43847bf1d0d11f104
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/168487
Reviewed-by: David Morgan <davidmorgan@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Michal Terepeta <michalt@google.com>
2020-10-20 12:23:53 +00:00
Johnni Winther
354dcf4386 [cfe] Use origin location for member signatures
Change-Id: Iee3f79db7aa7600e9116e402d2d921308b07f8f6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/168203
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
2020-10-19 15:34:17 +00:00
Jonas Termansen
8cfaeebaa4 [vm] Use SDK_DIR in precompiler2 when locating dart.
Change-Id: I216c126a7a6953fd6f8eb1b060e27eddfafb332b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/168102
Auto-Submit: Jonas Termansen <sortie@google.com>
Commit-Queue: Jonas Termansen <sortie@google.com>
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2020-10-16 19:38:12 +00:00
Daco Harkes
b13c37726c [cfe/ffi] Transformation changes for structs-by-value
Changes the kernel representation of structs in two ways.
1. `_addressOf` field of `Struct` gets type `Object` because it will be
   either `TypedData` or `Pointer` in structs by value CL.
2. Subtypes of `Struct` get a pragma `vm:ffi:struct-fields` which
   contains a const list of the native types of the fields of the struct
   which will be read in the VM to do compute the locations of structs
   in the target ABI.

Split off from https://dart-review.googlesource.com/c/sdk/+/140290/23
to make that CL smaller. That CL will no longer have changes to the
kernel representation of FFI code after this CL lands separately.

These changes are not consumed in the VM in this CL, but they are tested
by the expect files.

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

Change-Id: I5d3babd5be07f78c6d2bd80bbc1fd492c51bc01f
Cq-Include-Trybots: luci.dart.try:front-end-linux-release-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/167280
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2020-10-16 11:16:02 +00:00
Daco Harkes
d650ea90c4 [vm/ffi] Fix alignment of Uint64 fields in structs on some ABIs
Affected ABIs: ia32 Linux, ia32 Android, ia32 MacOS, and arm32 iOS.

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

Change-Id: I35f719abb69bb46d99f647d66847e3d5874d9371
Cq-Include-Trybots: luci.dart.try:vm-kernel-linux-debug-ia32-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/166843
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Auto-Submit: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2020-10-09 16:32:08 +00:00
Alexander Markov
c7f0143900 [vm/aot/tfa] Remove uses of VariableGet.promotedType
Previously (before NNBD) VariableGet.promotedType was used when
variable type was promoted after a successful 'is' test. TFA used that
to infer non-nullability in certain cases (successful 'x is int'
implies that x is non-nullable).

However, this is no longer true as front-end started to use
promotedType in more cases. Also, TFA should be able to
infer the same non-nullability from the successful 'is' test itself.
So this change removes use of VariableGet.promotedType from TFA.

Change-Id: Id14dafad4451453572d6f20ff567b7792f17881a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/165625
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2020-10-06 20:14:53 +00:00
Johnni Winther
8b07d1902c [kernel] Remove DirectPropertyGet/DirectPropertySet/DirectMethodInvocation
These nodes are no longer used.

Change-Id: I40c8df7376f0c40a4122c22d934fb3c6f6fd520d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/165902
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2020-10-03 19:15:41 +00:00
Johnni Winther
e96698d5da [ffi] Remove use of DirectPropertyGet
Use PropertyGet instead. DirectPropertyGet is retiring.

Change-Id: Ia178e99e89c12eeba8634f5bea97baccac8dc635
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/165901
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2020-10-03 19:15:41 +00:00
Johnni Winther
6753c930c9 [kernel] Remove unused super call resolution transformation
Change-Id: Iacaadcae823eda57f85d3fcc42debab916924eda
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/165900
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2020-10-03 19:15:41 +00:00
Johnni Winther
bc06a90a0e [cfe] Stop using DirectPropertyGet for enum encoding
DirectPropertyGet is a statically bound instance access used in the
VM mixin tranformation to encode fully resolved super access. The
access to `this.name` generated in `toString` of an enum is _not_
a statically bound instance access but just a regular instance access
whose runtime target happens to be known statically because the code
is generated. In JavaScript backend a statically bound instance access
requires a unique getter to avoid the dynamic lookup, and therefore,
though using DirectPropertyGet is an optimization
to the VM, it would be a regression to the JavaScript backends if
they didn't handle DirectPropertyGet as a PropertyGet.

This CL removes the misuse and thus enables JavaScript backends to
handle DirectPropertyGet with the intended semantics.

Change-Id: Ie41aefbf19e8c63244f10a1afda1ddbfdf7d3c19
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/164085
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2020-10-02 20:21:30 +00:00
Jens Johansen
fc7de901ee [kernel] Make LogicalExpression operator an enum (and rename)
Change-Id: I6054e8e44133d2419582d74700c4223d51495978
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/165606
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2020-10-02 09:41:12 +00:00
Johnni Winther
4025dee2f8 [cfe] Ensure that default values on synthesized constructor are included in outlines
Closes #43538

Change-Id: I58f03d6d71e6de4744003cc28519a20c7e9e7f12
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/164787
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2020-09-29 11:09:14 +00:00
Alexander Markov
29fe759b33 [vm/aot/tfa] Improve AOT compilation time (step 2 / TFA)
This change improves TFA speed by adding
* Cache of dispatch targets.
* Identical types fast path to union and intersection of set and cone
  types.
* Subset fast path in the union of set types.
* More efficient ConcreteType.raw.

AOT step 2 (TFA):
app #1: 200s -> 140s (-30%)
app #2: 208s -> 150s (-27%)

Issue: https://github.com/dart-lang/sdk/issues/42442
Issue: https://github.com/dart-lang/sdk/issues/43299
b/154155290

Change-Id: Ie9039a6448a7655d2aed5f5260473c28b1d917d9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/164480
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2020-09-25 18:16:54 +00:00
Johnni Winther
5d8a9340ae [cfe] Add support for using backend defined sentinels in late lowering
Change-Id: Iabcd0c79fb8f09c9de99856e50518eb7ace38464
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/163860
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
2020-09-23 08:07:26 +00:00
Alexander Markov
3272abc93d [vm/aot/tfa] Replace assertx with assert in TFA
TFA used assertions which are always enabled (assertx utility function).
As TFA became more mature, we can now turn them into ordinary asserts,
effectively disabling them.

During development assertions can be enabled using DART_VM_FLAGS
environment variable, which is accepted by our precompiler2 and
gen_kernel scripts:

  DART_VM_FLAGS=--enable-asserts pkg/vm/tool/precompiler2 foo.dart foo.snapshot

This change may improve AOT compilation time of large applications.

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

Change-Id: I8f52862e83a6db8c2f9041fcf6afa8101509324f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/163121
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2020-09-17 20:03:43 +00:00
Johnni Winther
f4501b6e83 Reland "[kernel] Rename Name.name to Name.text"
Including a deprecated getter to avoid breaking dependent code outside
the Dart repo.

Change-Id: I365957b7c2da6e0cb5c71eb8d2906b0dc6ff18ec
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/163062
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2020-09-17 06:10:49 +00:00
Johnni Winther
b3bd2e95e7 [cfe] Fix git access in presubmit script on Windows
Change-Id: I6c871264dc1fff39b19421ce1f5513eb2e56901d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/163061
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2020-09-16 14:17:18 +00:00
Johnni Winther
644df9b9fb Revert "Reland: [kernel] Rename Name.name to Name.text"
This reverts commit c430a0ac0b.

Reason for revert: Will break flutter_frontend_server when rolled into google3

Original change's description:
> Reland: [kernel] Rename Name.name to Name.text
> 
> Change-Id: I5240b0ff09faf35184998920202d7600dc97766d
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/162746
> Reviewed-by: Johnni Winther <johnniwinther@google.com>
> Commit-Queue: Johnni Winther <johnniwinther@google.com>

TBR=jensj@google.com,johnniwinther@google.com

Change-Id: Ib6961f49dd416171c5d5935c490d79d6f7be779e
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/162748
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2020-09-16 08:22:55 +00:00
Johnni Winther
c430a0ac0b Reland: [kernel] Rename Name.name to Name.text
Change-Id: I5240b0ff09faf35184998920202d7600dc97766d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/162746
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2020-09-16 07:42:42 +00:00
Daco Harkes
7302e01a79 Revert "[kernel] Rename Name.name to Name.text"
This reverts commit 3ff8dd2f51.

Reason for revert: Fails all CI builders. Possibly something landed
in the mean time.

Original change's description:
> [kernel] Rename Name.name to Name.text
> 
> Change-Id: I93162fb387ba123b949e19a7829bd5614845b15d
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/162722
> Reviewed-by: Jens Johansen <jensj@google.com>
> Commit-Queue: Johnni Winther <johnniwinther@google.com>

TBR=jensj@google.com,johnniwinther@google.com

Change-Id: I2ffe526dabf37ae09d5e4ab1fbe514925f6e8768
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/162744
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2020-09-15 15:21:35 +00:00
Johnni Winther
3ff8dd2f51 [kernel] Rename Name.name to Name.text
Change-Id: I93162fb387ba123b949e19a7829bd5614845b15d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/162722
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2020-09-15 14:27:22 +00:00
Tess Strickland
781094f2ce [vm/bytecode] Add parameter flags to FunctionDeclaration.
We create the parameter names array when loading the
FunctionDeclaration, but the required parameter flags are only set later
when we load the Code declaration. If there's an intermediate use of the
Function object that copies the required parameter flags, like creating
an ImplicitClosureFunction when loading a tearoff stored in the object
pool, there will be no set flags at that point.

Add a copy of the parameter flags to the FunctionDeclaration so the
required flags can be set at the same time as the parameter name and
type to avoid this scenario.

To avoid adding unneeded flags to the kernel bytecode, we only serialize
the parameter flags needed for each declaration, so FunctionDeclaration
and ClosureDeclaration only contain the required flag, and Code contains
all flags _but_ the required flag.

There are no trybots for strong mode + bytecode, but manually checked
by running the following on the main branch (cherry-picking the
test_matrix.json changes) and this branch:

python tools/test.py \
    -n dartkb-mixed-strong-linux-release-x64,dartkb-interpret-strong-linux-release-x64 \
    tests/language/nnbd/required_named_parameters/missing_required_argument_dynamic_test.dart

Cq-Include-Trybots: luci.dart.try:vm-dartkb-linux-release-simarm64-try,vm-dartkb-linux-release-x64-try
Change-Id: Ic75b831d5ceed08154e2c61b8f64461705558653
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/162501
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
2020-09-14 15:28:20 +00:00
Johnni Winther
082295a61e [cfe] Support lowering of static fields with initializers
This adds support lowering the encoding of top-level/static fields
with initializers as if they were marked as late fields. This ensures
that LateInitialization is thrown if final fields are written to during
initialization.

Closes #42956

Change-Id: I488fdddd87ebd935a0cdaf82a724e9b87d5f91ba
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/160724
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2020-09-01 07:20:58 +00:00
Johnni Winther
6079377dc1 [cfe] Ensure default type on all declarations
Closes #43202

Change-Id: I3b8f6e24436aac7cdcdd2e1cce1448a1bcc122de
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/160521
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
2020-08-27 18:21:57 +00:00
Aske Simon Christensen
e0c9b5e45f [vm/aot/tfa] Group unboxing info via dispatch table selector IDs.
Also fix a copy/paste error in the unboxing metadata handling which
prevented setter parameters from being unboxed.

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

Change-Id: I0a37b432f15b34e50b4f60cefea774bacca174a5
Cq-Do-Not-Cancel-Tryjobs: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/156915
Commit-Queue: Aske Simon Christensen <askesc@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2020-08-27 11:00:27 +00:00
Aske Simon Christensen
7f3f2bcec2 [vm/kernel] Fix parent pointers in unreachable code elimination.
Change-Id: Id8d8a57d9d69cd94be83ecfb4a43cbde26e37b7f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/159665
Commit-Queue: Aske Simon Christensen <askesc@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2020-08-26 18:48:45 +00:00
Aske Simon Christensen
0f0fcbab67 [vm/aot/tfa] Assign table selector IDs eagerly to keep them more stable.
Change-Id: I4e3af321930e991276eeaba9586df6841432b307
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/160103
Commit-Queue: Aske Simon Christensen <askesc@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2020-08-26 14:34:14 +00:00
Aske Simon Christensen
5cac576915 [vm/aot/tfa] Move TableSelectorAssigner initialization out of annotator.
Also avoid generating selector IDs for implicit setters for fields that
don't have them.

Change-Id: I32dfaf22893d890fb211aedca95bbb63c4ca8b56
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/156914
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2020-08-26 14:34:14 +00:00
Devon Carew
8a0b75ced1 update the pubspec files to reflect actual package usage
Change-Id: I1fa259d0a9e827c7491312ce2e5ffe8261147038
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/159142
Commit-Queue: Devon Carew <devoncarew@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2020-08-19 19:40:47 +00:00
Alexander Markov
5e551dd926 [vm/aot/tfa] Avoid stack overflow in TFA due to deeply nested calls
Issue: https://github.com/flutter/flutter/issues/63560
Change-Id: I995adf4c7ee17123f9a4979e07e651911c9577db
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/158720
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2020-08-19 18:39:27 +00:00
Johnni Winther
de224ac5f4 [cfe] Update ast-to-text to include member signature origins
Change-Id: I46e7fe831bc5e87981e78537b37565c62646210f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/157961
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2020-08-17 13:41:49 +00:00
Tess Strickland
787446213c [vm/compiler] Move argument shape (not type) checks out of closures.
This CL performs the following checks in the invoke field dispatcher for
dynamic closure calls when lazy dispatchers are enabled:

* The provided function type arguments vector (if any) has the correct
  length.

* No function type arguments should be provided if the closure has
  delayed type arguments.

* All required arguments (positional in all modes, named in appropriate
  null safety modes) have been provided by the caller.

* If there are optional positional arguments, an appropriate number
  has been provided.

* If there are optional named arguments, their names are valid.

Since the runtime already handles checking the argument shapes when lazy
dispatchers are disabled, these checks are now completely removed from
closure bodies in all cases. Thus, the only remaining checks in closure
bodies are the type checks performed by AssertSubtype and
AssertAssignable when lazy dispatchers are enabled.

Changes in the Flutter Gallery:

* ARM7, release: -3.61% instructions, -2.19% total
* ARM7, sizeopt: -3.62% instructions, -2.55% total
* ARM8, release: -3.66% instructions, -1.98% total
* ARM8, sizeopt: -3.65% instructions, -2.37% total

Most of these changes are already exercised by existing tests such as
(but not limited to):

* corelib{,_2}/dynamic_nosuchmethod_test
* language{,_2}/call/call_test
* language{,_2}/closure/tearoff_dynamic_test
* language{,_2}/generic/function_bounds_test
* language{,_2}/parameter/named_with_conversions_test
* language{,_2}/vm/no_such_args_error_message_vm_test

I've added one test to specifically check the interaction between
dynamic calls and required named parameters. There is some coverage in
other NNBD tests, but those are not directly focused on testing this
specifically.

Other changes:

* Adds initial cached ranges for certain BinarySmiOp and ShiftIntegerOp
  instructions when the RHS is a constant, to avoid false negatives for
  deoptimization and throw checks prior to range analysis.

* Adds new slots for various Function fields.

* Adds the ability to define unboxed native slots, which are always
  unboxed after retrieval even in unoptimized code. In the first
  iteration, the backend only handles loads from Uint32 unboxed native
  slots. Part of https://github.com/dart-lang/sdk/issues/42793.

* Removed the special handling for loading from non-nullable int fields
  in AOT compilation. Instead, their treatment is unified with the
  treatment of the new unboxed native fields, since the source field is
  always unboxed and the result of the load is also always unboxed, as
  code involving them is always optimized.

Bug: https://github.com/dart-lang/sdk/issues/40813
Change-Id: Ia02aa3e872c1fefd906fd67b55021ea1797556e4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/155604
Commit-Queue: Tess Strickland <sstrickl@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2020-08-17 08:58:08 +00:00
Alexander Markov
4ef577d50e [vm/tfa] add map/set factory specializer to support infer metatype
https://github.com/dart-lang/sdk/issues/37861

Closes https://github.com/dart-lang/sdk/pull/42943
https://github.com/dart-lang/sdk/pull/42943

GitOrigin-RevId: 508f49256f1916e862c6d6f48efc77406d0b63de
Change-Id: Iec6786bcd4fa09704c533cbff6957130aa524ada
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/157240
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2020-08-12 19:20:38 +00:00
Ryan Macnak
471b01de2e [vm] Topologically sort loading units.
The VM assumes parents appear before children when iterating loading units in id order. Normally this happens as a side-effect of sources being loaded in import order, but this might not happen in environments that combine separately produced kernel files.

Bug: https://github.com/dart-lang/sdk/issues/42985
Change-Id: Ice9e2e07cf2aa89e91ab313951cc33c1924f17ed
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/158066
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2020-08-11 20:42:29 +00:00
Alexander Markov
552a8b1a0c [vm/aot/tfa] Take memberSignatureOrigin into account in tree shaking
https://dart-review.googlesource.com/c/sdk/+/157498 introduced
memberSignatureOrigin reference from Procedure nodes to another
member. This reference should be handled in TFA tree shaker
to avoid dangling references when 'memberSignatureOrigin' is
tree shaken.

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

Change-Id: I8108a00480394544162261498b993cdd0743b22b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/158147
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2020-08-11 19:53:39 +00:00
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