Commit graph

1401 commits

Author SHA1 Message Date
Johnni Winther
5222bfd90c [cfe] Refactor bounds checking
This CL moves the bounds checking into the TypeBuilder instead of
performing it from the outside on the computed DartType node.
This solves several problems:

  1) Errors are now reported on the type in the code instead of the
     declaration which holds the type.
  2) Checking of type aliases (both function and nonfunction type
     aliases) is now handled correctly in all cases. This achieved by
     computed the aliased type (containing TypedefType nodes)
     internally and performing the checking on this type, and only
     convert the type into the unaliased version (without TypedefType
     nodes) after checks have been performed. Previously this handled
     through the FunctionType.typedefType property for function type
     aliases and through and incomplete work-around for nonfunction
     type aliases.
  3) With 2) FunctionType.typedefType is no longer needed and is
     removed.

TEST=general/bounds_*

Change-Id: I7653bca5ccb0ebf4b3553828a298d1ad918ef235
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/243722
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2022-05-17 14:36:19 +00:00
Nate Bosch
6ebd2633cd Use any deps for all unpublished packages
It should not be necessary to ever run `pub get` for a package which is
not published. All packages used in the SDK are controlled by a single
package config, so it's not necessary to declare versions or paths for
any packages.

Remove all dependency overrides.

R=devoncarew@google.com

Change-Id: Icb328813b471f35ee4c99995f4e90aac4d8ed438
Tested: Covered by existing static analysis.
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/244767
Commit-Queue: Nate Bosch <nbosch@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
Reviewed-by: Devon Carew <devoncarew@google.com>
2022-05-17 01:22:25 +00:00
Daco Harkes
e418026d74 [vm/ffi] Support late Finalizable variables
This CL changes the IL building for reachability fences to their call
sites. This enables us to catch the field load and tell it to not emit
an initialization check for late fields.

The sentinel value will now flow into the ReachabilityFenceInstr, where
it will be discarded.

TEST=tests/language/vm/regress_49005_test.dart

Closes: https://github.com/dart-lang/sdk/issues/49005
Change-Id: Ic21c9905290925eb83860d8394b13be7dd7592c1
Cq-Include-Trybots: luci.dart.try:vm-ffi-android-debug-arm64c-try,vm-ffi-android-debug-arm-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/+/244628
Reviewed-by: Liam Appelbe <liama@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2022-05-13 16:44:26 +00:00
Alexander Markov
4075e8b3f9 [vm] New async*/yield/yield* implementation based on suspend/resume stubs
TEST=ci
Issue: https://github.com/dart-lang/sdk/issues/48378
Change-Id: I0c2ca9269b2c8f008a79c139a0ce10231996732d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/242923
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2022-05-02 20:53:01 +00:00
Alexander Markov
c4c9dc5994 [vm] Enable new implementation of async/await in AOT mode
The new implementation results in a much smaller overhead of
async/await on AOT snapshot size. The savings depend on
how often async/await is used.

On a large Flutter app (customer: money)
AOT snapshot size -13.7% (arm64), -12.86% (arm)

Another large Flutter app
AOT snapshot size -8.69% (arm64).

Part 1 (kernel): https://dart-review.googlesource.com/c/sdk/+/241842
Part 2 (vm): https://dart-review.googlesource.com/c/sdk/+/242000

TEST=ci

Issue: https://github.com/dart-lang/sdk/issues/48378
Change-Id: Idf99bb98725a1ffb21a15b111f03f5461ed2c9d9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/242384
Reviewed-by: Siva Annamalai <asiva@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2022-04-29 01:03:50 +00:00
Martin Kustermann
efdffab8b7 Reland "[vm] Fix some async* semantics issues: Only run generator if there's active subscription (not paused/cancelled)"
This fixes an issue where VM would run the async* generator after a
`yield` / `yield*` even though the subscription may be paused or
cancelled.

Furthermore this fixes an issue where `StackTrace.current` used
in async* generator crashes VM and/or produces truncated stack
trace.

This fixes the following existing tests that were failing before:

  * co19/Language/Statements/Yield_and_Yield_Each/Yield_Each/execution_async_t08
  * co19/Language/Statements/Yield_and_Yield_Each/Yield_Each/execution_async_t09
  * co19/Language/Statements/Yield_and_Yield_Each/Yield_Each/execution_async_t10
  * language/async_star/async_star_cancel_test
  * language/async_star/pause_test

New in reland: Allow the generator to to cause cancelling it's own consumer.
This addresses the issue of original revert
  -> see https://github.com/flutter/flutter/issues/101514

Issue https://github.com/flutter/flutter/issues/100441
Issue https://github.com/dart-lang/sdk/issues/48695
Issue https://github.com/dart-lang/sdk/issues/34775

TEST=vm/dart{,_2}/causal_stacks/flutter_regress_100441_test

Change-Id: I091b7159d59ea15fc31162b4b6b17260d523d7cb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/242400
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2022-04-26 12:01:34 +00:00
Alexander Markov
2afc34112c [vm,kernel] New async/await implementation in the VM, part 1 - kernel
This change includes kernel-related changes:

* --compact-async option is added to kernel compilers (front-end
  server and gen_kernel). This option disables desugaring of async
  and await on kernel AST. Note that 'await for' is still desugared.

* File offset of the 'await' is now written for AwaitExpression nodes
  in the kernel binaries (will be used for async stack traces).

* Async/async*/sync* functions and AwaitExpression nodes are supported
  in TFA.

Design doc: go/compact-async-await.

TEST=ci

Issue: https://github.com/dart-lang/sdk/issues/48378
Change-Id: I4233086b7434bc48347f4220645b0be5f9133456
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/241842
Reviewed-by: Slava Egorov <vegorov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2022-04-21 15:11:08 +00:00
Johnni Winther
f26c0e2056 [cfe] Add explicit type argument to .map(...).toList()
Expressions like

  List<VariableDeclaration> variables = ...
  List<Expression> reads = variables.map((v) => VariableGet(v)).toList()

don't get the intended type argument `<Expression>` through inference,
but instead the type inferred from the return type of the closure, in
this case `<VariableGet>`.

This causes problems when used with the AST which assumes that
expressions are interchangeable wherever they are used, and is likely
the cause of https://github.com/flutter/flutter/issues/102077 .

This CL adds an explicit type argument in these cases.

TEST=general/infer_map

Change-Id: I0bcae21f06c54f290dc20686b0d84c065d8ea04c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/241605
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2022-04-20 06:56:58 +00:00
Siva Annamalai
94bc01240c Revert "[vm] Fix some async* semantics issues: Only run generator if there's active subscription (not paused/cancelled)"
This reverts commit 837ee17b43.

Reason for revert: Please see https://github.com/flutter/flutter/issues/101514

Original change's description:
> [vm] Fix some async* semantics issues: Only run generator if there's active subscription (not paused/cancelled)
>
> This fixes an issue where VM would run the async* generator after a
> `yield` / `yield*` even though the subscription may be paused or
> cancelled.
>
> Furthermore this fixes an issue where `StackTrace.current` used
> in async* generator crashes VM and/or produces truncated stack
> trace.
>
> This fixes the following existing tests that were failing before:
>
>   * co19/Language/Statements/Yield_and_Yield_Each/Yield_Each/execution_async_t08
>   * co19/Language/Statements/Yield_and_Yield_Each/Yield_Each/execution_async_t09
>   * co19/Language/Statements/Yield_and_Yield_Each/Yield_Each/execution_async_t10
>   * language/async_star/async_star_cancel_test
>   * language/async_star/pause_test
>
> Issue https://github.com/flutter/flutter/issues/100441
> Issue https://github.com/dart-lang/sdk/issues/48695
> Issue https://github.com/dart-lang/sdk/issues/34775
>
> TEST=vm/dart{,_2}/causal_stacks/flutter_regress_100441_test
>
> Change-Id: I73f7d0b70937a3e3766b992740fa6fe6e6d57cec
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/239421
> Reviewed-by: Lasse Nielsen <lrn@google.com>
> Commit-Queue: Martin Kustermann <kustermann@google.com>

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

Change-Id: Ic3d9c0508310a33a2aaee67860c0bb2ec83bab4a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/240506
Reviewed-by: Siva Annamalai <asiva@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
2022-04-07 21:46:38 +00:00
Johnni Winther
6980a1b4c3 [kernel] Add VariableDeclaration.hasDeclaredInitializer
The computation of default values on super parameters requires the
notion of a declared initializer. By adding this as a flag to
VariableDeclarations the implementation can now be normalized across
parameter from source and dill.

TEST=existing

Change-Id: Ic980e68b569e3bdab38d2c7c7e4374e0c931a87b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/240403
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2022-04-07 14:54:08 +00:00
Martin Kustermann
837ee17b43 [vm] Fix some async* semantics issues: Only run generator if there's active subscription (not paused/cancelled)
This fixes an issue where VM would run the async* generator after a
`yield` / `yield*` even though the subscription may be paused or
cancelled.

Furthermore this fixes an issue where `StackTrace.current` used
in async* generator crashes VM and/or produces truncated stack
trace.

This fixes the following existing tests that were failing before:

  * co19/Language/Statements/Yield_and_Yield_Each/Yield_Each/execution_async_t08
  * co19/Language/Statements/Yield_and_Yield_Each/Yield_Each/execution_async_t09
  * co19/Language/Statements/Yield_and_Yield_Each/Yield_Each/execution_async_t10
  * language/async_star/async_star_cancel_test
  * language/async_star/pause_test

Issue https://github.com/flutter/flutter/issues/100441
Issue https://github.com/dart-lang/sdk/issues/48695
Issue https://github.com/dart-lang/sdk/issues/34775

TEST=vm/dart{,_2}/causal_stacks/flutter_regress_100441_test

Change-Id: I73f7d0b70937a3e3766b992740fa6fe6e6d57cec
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/239421
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2022-04-06 10:44:34 +00:00
Chloe Stefantsova
abdd5765ee [cfe] Re-own TODOs assigned to 'dmitryas'
TEST=Only the comments were changed.

Change-Id: I8d4778746759466ea4c64f0eabe498da353fdd22
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/240041
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2022-04-05 09:04:53 +00:00
Ben Konyi
23ea9f3da4 [ VM Service ] Remove dynamic callsites from VM service
Fixes https://github.com/dart-lang/sdk/issues/48405

TEST=N/A

Change-Id: I975d713d27fac6221e3a06dce0cddaf1f5019b7d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/239583
Reviewed-by: Devon Carew <devoncarew@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2022-04-01 17:54:46 +00:00
Johnni Winther
e47df63488 [cfe] Refactor experimental flags
Adds GlobalFeature(s) and LibraryFeature(s) to provide more direct
and consistent access to features and their state.

TEST=existing

Change-Id: Iceb29e4fafa471e6790f2ce3c2a7108c8ae2c9a7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/239660
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2022-03-31 16:22:16 +00:00
Johnni Winther
88846ca4b4 [kernel] Remove unused Typedef fields
The fields typeParametersOfFunctionType, positionalParameters,
and namedParameters were never used.

TEST=existing

Change-Id: I0ca1c546fdf94df9c3248164a56ed88cd2468b18
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/239310
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2022-03-30 13:01:40 +00:00
Johnni Winther
a6acb1a5f0 [cfe] Include the future value type in ast-to-text
This is in preparation for including a "futureValueType" for
non-nnbd async functions.

TEST=existing

Change-Id: I15cf5e58623df07fe3c670aa866b7b04805c0f3d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/238703
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2022-03-28 10:37:25 +00:00
Brian Wilkerson
448bf930cc Remove an unneeded ignore comment in vm package
Change-Id: I3b81e1d66c2100b8ed1834815f318cf39a8da305
Tested: This only impacts the analyzer's reporting of diagnostics, so I ran the analyzer over the code and verified that no new diagnostics were being reported.
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/238983
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2022-03-26 16:10:31 +00:00
Daco Harkes
532c116cd2 [vm] Implement NativeFinalizer
This CL implements `NativeFinalizer` in the GC.

`FinalizerEntry`s are extended to track `external_size` and in which
`Heap::Space` the finalizable value is.

On attaching a native finalizer, the external size is added to the
relevant heap. When the finalizable value is promoted from new to old
space, the external size is promoted as well. And when a native
finalizer is run or is detached, the external size is removed from the
relevant heap again.

In contrast to Dart `Finalizer`s, `NativeFinalizer`s are run on isolate
shutdown.

When the `NativeFinalizer`s themselves are collected, the finalizers are
not run. Users should stick the native finalizer in a global variable to
ensure finalization. We will revisit this design when we add send and
exit support, because there is a design space to explore what to do in
that case. This current solution promises the least to users.

In this implementation native finalizers have a Dart entry to clean up
the entries from the `all_entries` field of the finalizer. We should
consider using another data structure that avoids the need for this Dart
entry. See the TODO left in the code.

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

TEST=runtime/tests/vm/dart(_2)/isolates/fast_object_copy_test.dart
TEST=runtime/vm/object_test.cc
TEST=tests/ffi(_2)/vmspecific_native_finalizer_*

Change-Id: I8f594c80c3c344ad83e1f2de10de028eb8456121
Cq-Include-Trybots: luci.dart.try:vm-kernel-reload-rollback-linux-debug-x64-try,vm-kernel-reload-linux-debug-x64-try,vm-ffi-android-debug-arm64c-try,dart-sdk-mac-arm64-try,vm-kernel-mac-release-arm64-try,pkg-mac-release-arm64-try,vm-kernel-precomp-nnbd-mac-release-arm64-try,vm-kernel-win-debug-x64c-try,vm-kernel-win-debug-x64-try,vm-kernel-precomp-win-debug-x64c-try,vm-kernel-nnbd-win-release-ia32-try,vm-ffi-android-debug-arm-try,vm-precomp-ffi-qemu-linux-release-arm-try,vm-kernel-mac-debug-x64-try,vm-kernel-nnbd-mac-debug-x64-try,vm-kernel-nnbd-linux-debug-ia32-try,benchmark-linux-try,flutter-frontend-try,pkg-linux-debug-try,vm-kernel-asan-linux-release-x64-try,vm-kernel-gcc-linux-try,vm-kernel-optcounter-threshold-linux-release-x64-try,vm-kernel-precomp-linux-debug-simarm_x64-try,vm-kernel-precomp-obfuscate-linux-release-x64-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-debug-x64c-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/236320
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2022-03-26 09:41:21 +00:00
Ryan Macnak
464bece529 [vm, compiler] Fix some stack alignment for RISC-V FFI.
- Fix bad frame walk from assuming kSavedCallerFpSlotFromFp is 0.
 - Fix sign of WChar.
 - Fix missing sign-extension in some cases of passing uint32.

TEST=qemu
Bug: https://github.com/dart-lang/sdk/issues/48164
Change-Id: Idc1699d473a115153b4b4e6fdc9f84519055de00
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/238386
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-03-24 20:45:09 +00:00
Aske Simon Christensen
8d528360a1 [ffi] Fix incorrect kernel type for size in FFI transform.
Tested: Broke FFI implementation in dart2wasm
Change-Id: I45a7a194ea66c960a0fad00d7d5826b614159f7c
Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/237685
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Aske Simon Christensen <askesc@google.com>
2022-03-21 14:33:37 +00:00
Clement Skau
2c0ba56ea1 [vm/ffi] Add error for FFI annotation with opt. args.
Optional arguments (positional and named) in @FfiNative
annotations are not meaningful, and should result in a
compile-time error.

TEST=tests/ffi/ffi_native_test.dart
Bug: https://github.com/dart-lang/sdk/issues/47169
Change-Id: I8896e6a43f9399b537e6ee7c7a0e2857a370203f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/232622
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Clement Skau <cskau@google.com>
2022-03-18 20:58:51 +00:00
Ben Konyi
b036052077 Reland "[ Service ] Update VM service message to not reference Observatory"
This reverts commit ee5837aa7a.

Updated Intellij plugins have been published which support the new
message.

TEST=CQ

Change-Id: I81f6d878f036991a95cc1f58d3102015e77aa609
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/237741
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2022-03-17 23:15:57 +00:00
Aske Simon Christensen
3b64cede6d [ffi] Use explicitly cached getters for Array nested dimensions
The FFI use sites transformation generates code accessing some late
final fields of the Array class. By changing these to be getters, the
transformation works both with and without late field lowering.

Tested: ci
Change-Id: Ib30d18e0830f7bb597214701272b1d0a922ac06a
Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/237363
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Aske Simon Christensen <askesc@google.com>
2022-03-16 11:29:03 +00:00
Aske Simon Christensen
d24354ea09 [vm/dart2wasm] Brush up mixin structure of hash implementation classes
This changes all mixins in the VM's hash map/set implementation to be
declared as mixins and introduces appropriate interfaces needed to
concisely express the prerequisites of the various mixins in the stack.

It also separates most of the implementation of immutable maps and sets
into mixins to enable sharing the implementation with dart2wasm.

Tested: ci + manual testing of dart2wasm
Change-Id: Ife1e7195aba35741629aa4dffedb929b1028a85a
Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/236180
Reviewed-by: Daco Harkes <dacoharkes@google.com>
2022-03-16 10:05:43 +00:00
Jens Johansen
280277ad30 [vm] Fix obfuscation of uri
https://github.com/flutter/flutter/issues/99477
https://github.com/dart-lang/sdk/issues/44215

TEST=Test was added.

Change-Id: I585da436f9692d7f2e08db7f74c1a71ad09a1cb1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/236220
Reviewed-by: Slava Egorov <vegorov@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2022-03-14 09:01:11 +00:00
Daco Harkes
9bc1b99472 [cfe/vm] Remove frequently changing selector ids from expect files
This causes red bots on CLs just to update the expect files.

Extra libraries apart from the main library are passed to the front-end
as additional dills, which places them last in the library list, causing
them to have very high (and often changing) selector IDs.

For reference the list of commits that just update numbers:
https://github.com/dart-lang/sdk/commits/main/pkg/vm/testcases/transformations/type_flow/transformer/enum_from_lib_used_as_type.dart.expect

TEST=pkg/vm/test/transformations/type_flow/transformer_test.dart

Change-Id: Iac4e2210bd50e6ebee130dd241c0c63351f43559
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/235605
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2022-03-07 16:30:54 +00:00
Alexander Markov
d0e8ef9816 [vm,kernel] Move transformations maintained by the VM team from pkg/kernel to pkg/vm
These transformations are maintained by the VM team and keeping them
in pkg/kernel would put a burden on the CFE team after code reviews
are tightened to require OWNERS approval.

TEST=ci

Change-Id: I931033ba987d17a2c9c6d80a16dad09bfbaa0572
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/234905
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2022-03-03 15:04:10 +00:00
Ben Konyi
ee5837aa7a Revert "[ Service ] Update VM service message to not reference Observatory"
This reverts commit f9147d933e.

TEST=N/A

Change-Id: Idef34b70f1066ddf79d02588dfba7caeec443e7f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/234325
Reviewed-by: Dan Field <dnfield@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2022-02-24 18:32:14 +00:00
Ryan Macnak
eb17dad604 [vm] Give mutable and immutable arrays a common superclass.
Allows CHA to notice `length` and `[]` have a single target the receiver is a mutable or immutable array.

TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/48361
Change-Id: I9e3ecabab1d32a4baa6e635cd660184ed9bb8fb1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/232425
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-02-23 18:34:03 +00:00
Lasse R.H. Nielsen
a3e39fadd6 Make UriData more case-insensitive.
Add `isMimeType` method to `UriData` class, to allow case-insensitive
checking of the MIME type.
Add `isCharset` and `isEncoding` methods to `UriData` class,
to allow case-insensitive and alternative-encoding-name aware checking
of the MIME type "charset" parameter.
Make `UriData.fromString` and `UriData.fromBytes` recognize and omit
a "text/plain" `mimeType` even if it is not all lower-case.

Be case-insensitive in a few cases where we weren't before
(like the `charset` getter not recognizing `CHARSET=utf-8`.)

Fixes #28592
TEST=corelib/data_uri_test.dart updated

BUG= http://dartbug.com/28592

Change-Id: Ia885af69d271856af7fadfe93851e07eff6ddca2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/217366
Reviewed-by: Nate Bosch <nbosch@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
2022-02-22 10:47:41 +00:00
Ben Konyi
f9147d933e [ Service ] Update VM service message to not reference Observatory
See https://github.com/dart-lang/sdk/issues/46756

TEST=Existing

Change-Id: Ib71bf00d667369d7438a4547ae444951ec0979df
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/233504
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2022-02-18 20:53:52 +00:00
Martin Kustermann
f50b3a52e4 [vm] Make async lowering no longer use optional parameters
This CL

  * Makes :async_op only have two parameters: We take advantage
    of the fact that errors not only have exception != null but
    also stacktrace != null.
  * Makes :async_op have no optional parameters. This reduces
    code size significantly.
  * Removes unused parameter in _awaitHelper calls
  * Wrap the then callback instead of the error callback. (needed
    to make optional parameters required)

This results in 2% code savings on a big g3 app.
The size of :async_op shrinks on average by 11%

TEST=ci

Change-Id: I38d5fba4ebebc780b48dac5aa6a250d2c7952bfd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/233362
Reviewed-by: Slava Egorov <vegorov@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2022-02-18 12:09:42 +00:00
Ryan Macnak
ef60f64d81 [vm] Annotate concrete types when creating arrays and strings.
TEST=ci
Change-Id: I8881b52f9ea8a146138127ec2fc726a79f7441be
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/233220
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-02-16 20:36:30 +00:00
Alexander Thomas
30beab0f43 [infra] Add OWNERS to the Dart SDK
* Add team "groups" in tools/OWNERS_<group name>.
* Add top-level OWNERS as a fallback.
* Add OWNERS for all top-level directories.
* Add OWNERS to all packages.

For additional background information see go/dart-sdk-owners.

TEST=No op until code-owners is enabled.
Bug: b/200915407
Change-Id: I7fe6116cc599c749cd50ca16151d6d6a801d99d7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/229147
Reviewed-by: Jonas Termansen <sortie@google.com>
2022-02-14 14:06:34 +00:00
Leaf Petersen
4dbd35f04d Reland "Simplify json parser and eliminate dynamic calls."
This is a reland of e77ea8a17b.  I've
undone the change to the name of the platformScript setter, restoring
the previous behavior of accepting anything and casting.

TEST=Existing tests.

Change-Id: I7e36935ef3784035769527dc5624191f38faaa40
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/232487
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Leaf Petersen <leafp@google.com>
2022-02-11 16:06:37 +00:00
Alexander Aprelev
4fb3d2afcf Revert "Simplify json parser and eliminate dynamic calls."
This reverts commit e77ea8a17b.

Reason for revert: broke g3 builder, blocking dart->engine rolls

Original change's description:
> Simplify json parser and eliminate dynamic calls.
>
> Tighten types to eliminate some dynamic calls from the core libraries.
> Also remove some unnecessary abstraction from the json parser.
>
> TEST=Existing tests for the library.
> Change-Id: Ieb4cdec5b8c26709b5f70774c392bd373a203113
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/231800
> Reviewed-by: Lasse Nielsen <lrn@google.com>
> Reviewed-by: Alexander Markov <alexmarkov@google.com>
> Commit-Queue: Leaf Petersen <leafp@google.com>

TBR=lrn@google.com,leafp@google.com,alexmarkov@google.com

Change-Id: Iec15058734d07c1966d43c1559a35313f59f8009
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/232322
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2022-02-10 03:16:20 +00:00
Leaf Petersen
e77ea8a17b Simplify json parser and eliminate dynamic calls.
Tighten types to eliminate some dynamic calls from the core libraries.
Also remove some unnecessary abstraction from the json parser.

TEST=Existing tests for the library.
Change-Id: Ieb4cdec5b8c26709b5f70774c392bd373a203113
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/231800
Reviewed-by: Lasse Nielsen <lrn@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Leaf Petersen <leafp@google.com>
2022-02-10 00:07:49 +00:00
Nate Bosch
33e174084a Replace Uri.scheme == with Uri.isScheme
Use `hasScheme` in place of comparing against the empty string, and
`isScheme` to compare against all other schemes.

TEST=No behavior changes.

Change-Id: Ifc9fd13c6cf37933ebd4a754c4b500dedbcb291b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/231185
Reviewed-by: Kevin Moore <kevmoo@google.com>
Commit-Queue: Nate Bosch <nbosch@google.com>
2022-02-08 21:38:57 +00:00
Daco Harkes
3156c5629d [cfe/ffi] Implement Finalizable
This CL implements `Finalizable` by means of a CFE transform.
The transform is implemented in the existing FFI transform to avoid the
overhead of traversing the AST an extra time. The FFI transform slows
down ~15-30% on Flutter Gallery. For more info see the design doc.

TEST=`dart pkg/vm/test/transformations/ffi_test.dart`

Design doc: go/dart-vm-finalizable

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

Change-Id: I0bf9dead90a61631b7f215dc19fbaa9e40e63c8d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/227501
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2022-02-05 11:54:59 +00:00
Martin Kustermann
4eaacc3df9 [vm] Improve async performance by taking advantage of static types of returned values
In general any async function can return X or Future<X>. Though the
future implementation has to do different things depending on which case
we're in. It does so by using a `<obj> is Future<T>` test. This test is very
expensive if many different classes flow into `<obj>`.

Though most functions do not return `Future` objects from async
functions. We can determine that statically by looking if any returned
expression could be a future. If not, we can bypass the `is Future<T>`
test entirely.

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

TEST=pkg/front_end/testcases/general/async_function_returns_future_or.dart

Change-Id: If655bdbdddc214dd7b12be9905b3c788252547d0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/230662
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2022-02-04 22:06:59 +00:00
Martin Kustermann
07a5def205 Reland "[vm] Avoid type parameter check of _Future._asyncComplete() when caller knows its safe"
Currently we have to do a runtime `as FutureOr<T>` check for the
parameter to `_Future<T>.asyncComplete(FutureOr<T> value)`. Although
needed for general cases, for the particular usage in the VM's
async/await transformer, we know that the test is going to suceed.

This CL adds two VM-specific methods on `_Future` that take `dynamic`
and downcast via `unsafeCast<>()` to avoid this rather large runtime
type checking overhead.

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

Change after revert: Replace the
    assert(value is T || value is Future<T>);
with
    assert((value as FutureOr<T>) == value);

The former doesn't allow `null` while the ladder might (depending
on nullability of `T`).

TEST=ci

Change-Id: I2379c625003fea6aa836ac74beb1cd59201b3560
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/231704
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2022-02-04 19:54:19 +00:00
Ilya Yanok
cca927be82 Revert "[vm] Avoid type parameter check of _Future._asyncComplete() when caller knows its safe"
This reverts commit 8e0feb9fa9.

Reason for revert: breaks tests in Google3, see b/217919095

Original change's description:
> [vm] Avoid type parameter check of _Future._asyncComplete() when caller knows its safe
>
> Currently we have to do a runtime `as FutureOr<T>` check for the
> parameter to `_Future<T>.asyncComplete(FutureOr<T> value)`. Although
> needed for general cases, for the particular usage in the VM's
> async/await transformer, we know that the test is going to suceed.
>
> This CL adds two VM-specific methods on `_Future` that take `dynamic`
> and downcast via `unsafeCast<>()` to avoid this rather large runtime
> type checking overhead.
>
> Issue https://github.com/dart-lang/sdk/issues/48226
>
> TEST=ci
>
> Change-Id: Ieeffae3ac8e2960f849512cf22c51d41cadb1ecf
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/230261
> Reviewed-by: Slava Egorov <vegorov@google.com>
> Reviewed-by: Lasse Nielsen <lrn@google.com>
> Commit-Queue: Martin Kustermann <kustermann@google.com>

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

Change-Id: I37a07cbb6fb37620e5305dfe1b759b0de1c37653
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/231703
Reviewed-by: Ilya Yanok <yanok@google.com>
Commit-Queue: Ilya Yanok <yanok@google.com>
2022-02-04 17:24:19 +00:00
Martin Kustermann
8e0feb9fa9 [vm] Avoid type parameter check of _Future._asyncComplete() when caller knows its safe
Currently we have to do a runtime `as FutureOr<T>` check for the
parameter to `_Future<T>.asyncComplete(FutureOr<T> value)`. Although
needed for general cases, for the particular usage in the VM's
async/await transformer, we know that the test is going to suceed.

This CL adds two VM-specific methods on `_Future` that take `dynamic`
and downcast via `unsafeCast<>()` to avoid this rather large runtime
type checking overhead.

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

TEST=ci

Change-Id: Ieeffae3ac8e2960f849512cf22c51d41cadb1ecf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/230261
Reviewed-by: Slava Egorov <vegorov@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2022-02-04 16:42:59 +00:00
Alexander Markov
129304e09b [vm, cfe] Add an option to include extra source files into kernel compilation
This change adds --source option to kernel compilers (front-end server
and gen_kernel). This option instructs compiler to include extra source
files into compilation even if they are not referenced from main
library.

TEST=Added test cases to pkg/frontend_server/test/frontend_server_test.dart
and pkg/vm/test/kernel_front_end_test.dart

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

Change-Id: If3d71538751e9ccfa8c82a5685d810cf811e021c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/231334
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2022-02-04 15:23:39 +00:00
Ryan Macnak
4faf01a66c [vm] Cleanup workarounds for removed flag --throw_on_javascript_int_overflow.
TEST=ci
Change-Id: I65936b5cd6e5933eadc37f3cd6bba1f0fa1b81a5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/231328
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-02-03 21:10:46 +00:00
Daco Harkes
33e170ed56 [vm] Map key and value iterator speedup
Duplicates `_CompactIterable` and `_CompactIterator` to
`_CompactIterableImmutable` and `_CompactIteratorImmutable` to prevent
the `_data` field to store both modifiable and unmodifiable lists.

This speeds up iteration by about 20% (more info on the bug).

Does not use mixins for code sharing, because all the fields need to be
in the concrete classes anyway.

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

TEST=existing lib tests

Change-Id: I514d058d02ef3b26b475000daea3afc12f37c566
Cq-Include-Trybots: luci.dart.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-canary-linux-debug-try,vm-kernel-asan-linux-release-x64-try,vm-kernel-checked-linux-release-x64-try,vm-kernel-linux-debug-x64c-try,vm-kernel-linux-debug-x64-try,vm-kernel-nnbd-linux-release-simarm-try,vm-kernel-optcounter-threshold-linux-release-x64-try,vm-kernel-precomp-android-release-arm_x64-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,vm-precomp-ffi-qemu-linux-release-arm-try,vm-kernel-precomp-linux-debug-simarm_x64-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-tsan-linux-release-x64-try,vm-kernel-tsan-linux-release-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/231243
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2022-02-03 14:35:56 +00:00
Aske Simon Christensen
8df763f266 Prepare for sharing TFA and patch files between the VM and dart2wasm.
The VM patch files contain many annotations that guide the TFA and the
VM compilation pipeline. Most of these are not relevant to dart2wasm,
and having the TFA look at these when running inside dart2wasm leads to
sub-optimal, and sometimes even unsound, results.

In order to enable sharing of patch files between the VM and dart2wasm,
the annotation parser is given a target flag to control which
annotations it should recognize and how to parse them. The annotation
parser thus becomes an abstraction layer between the concrete
annotations in the patch files and the parsed annotations that the TFA
sees.

Additionally, external members used by dart2wasm don't always have
external names. To support this, the signature shaker must skip all
external members, not just the ones with an external name. This makes no
difference for the VM, since all of its external members either have an
external name or are implemented in a patch file, making them no longer
external.

TEST=ci + upcoming dart2wasm CL
Change-Id: Id425dd1ccc5560721034ae83c8cdc1593801a4e5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/231102
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Aske Simon Christensen <askesc@google.com>
2022-02-01 21:08:46 +00:00
Jens Johansen
adb1dc9380 [VM] [CFE]: Make VM send over type information for expression compilation
Missing:
* Function types.
* Type variables in bounds, like "method<T, S extends T>() {}" and
  "method<T extends Foo<T>>() {}"

This is in many ways a follow-up to
https://dart-review.googlesource.com/c/sdk/+/212286

TEST=service and (cfe) expression suite tests added.

Change-Id: I20472b59ed73e9845f073e176d73b2c213f9407a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/215760
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2022-01-28 07:49:21 +00:00
Ryan Macnak
04ba20aa98 [vm] Support RISC-V.
Implements a backend targeting RV32GC and RV64GC, based on Linux standardizing around GC. The assembler is written to make it easy to disable usage of C, but because the sizes of some instruction sequences are compile-time constants, an additional build configuration would need to be defined to make use of it.

The assembler and disassembler cover every RV32/64GC instruction. The simulator covers all instructions except accessing CSRs and the floating point state accessible through such, include accrued exceptions and dynamic rounding mode.

Quirks:
  - RISC-V is a compare-and-branch architecture, but some existing "architecture-independent" parts of the Dart compiler assume a condition code architecture. To avoid rewriting these parts, we use a peephole in the assembler to map to compare-and-branch. See Assembler::BranchIf. Luckily nothing depended on taking multiple branches on the same condition code set.
  - There are no hardware overflow checks, so we must use Hacker's Delight style software checks. Often these are very cheap: if the sign of one operand is known, a single branch is needed.
  - The ranges of RISC-V branches and jumps are such that we use 3 levels of generation for forward branches, instead of the 2 levels of near and far branches used on ARM[64]. Nearly all code is handled by the first two levels with 20-bits of range, with enormous regex matchers triggering the third level that uses aupic+jalr to get 32-bits of range.
  - For PC-relative calls in AOT, we always generate auipc+jalr pairs with 32-bits of range, so we never generate trampolines.
  - Only a subset of registers are available in some compressed instructions, so we assign the most popular uses to these registers. In particular, THR, TMP[2], CODE and PP. This has the effect of assigning CODE and PP to volatile registers in the C calling convention, whereas they are assigned preserved registers on the other architectures. As on ARM64, PP is untagged; this is so short indices can be accessed with a compressed instruction.
  - There are no push or pop instructions, so combining pushes and pops is preferred so we can update SP once.
  - The C calling convention has a strongly aligned stack, but unlike on ARM64 we don't need to use an alternate stack pointer. The author ensured language was added to the RISC-V psABI making the OS responsible for realigning the stack pointer for signal handlers, allowing Dart to leave the stack pointer misaligned from the C calling convention's point of view until a foreign call.
  - We don't bother with the link register tracking done on ARM[64]. Instead we make use of an alternate link register to avoid inline spilling in the write barrier.

Unimplemented:
 - non-trivial FFI cases
 - Compressed pointers - No intention to implement.
 - Unboxed SIMD - We might make use of the V extension registers when the V extension is ratified.
 - BigInt intrinsics

TEST=existing tests for IL level, new tests for assembler/disassembler/simulator
Bug: https://github.com/dart-lang/sdk/issues/38587
Bug: https://github.com/dart-lang/sdk/issues/48164
Change-Id: I991d1df4be5bf55efec5371b767b332d37dfa3e0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/217289
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-01-20 00:57:57 +00:00
Jens Johansen
ae593598f8 [dart:ffi] Only operate on transitive dependencies of dart:ffi
This CL does two things:
* "Reenable" the skipping of the dart:ffi transformation entirely when
  the application does not use dart:ffi. This was originally added in
  ad596359a6 but was logically disabled in 4558112105 when dart:core
  started depending on it. Here we now ignore (real) dart:* libraries
  when looking for dependencies of dart:ffi.
* Find the subset of the just compiled libraries that transitively
  depend on dart:ffi and just run the dart:ffi transformation on those
  libraries.


For dart2js that doesn't use dart:ffi at all we go from:

```
$ out/ReleaseX64/dart pkg/front_end/tool/_fasta/compile.dart -v pkg/compiler/bin/dart2js.dart | grep -i "ffi"
0:00:09.003428: Transformed ffi natives in 51ms.
0:00:09.203442: Transformed ffi annotations in 199ms.
$ out/ReleaseX64/dart pkg/front_end/tool/_fasta/compile.dart -v pkg/compiler/bin/dart2js.dart | grep -i "ffi"
0:00:09.098175: Transformed ffi natives in 52ms.
0:00:09.296847: Transformed ffi annotations in 198ms.
$ out/ReleaseX64/dart pkg/front_end/tool/_fasta/compile.dart -v pkg/compiler/bin/dart2js.dart | grep -i "ffi"
0:00:08.854341: Transformed ffi natives in 57ms.
0:00:09.061804: Transformed ffi annotations in 207ms.
```

to

```
$ out/ReleaseX64/dart pkg/front_end/tool/_fasta/compile.dart -v pkg/compiler/bin/dart2js.dart | grep -i "ffi"
0:00:09.138651: Skipped ffi transformation in 1ms.
$ out/ReleaseX64/dart pkg/front_end/tool/_fasta/compile.dart -v pkg/compiler/bin/dart2js.dart | grep -i "ffi"
0:00:09.242590: Skipped ffi transformation in 1ms.
$ out/ReleaseX64/dart pkg/front_end/tool/_fasta/compile.dart -v pkg/compiler/bin/dart2js.dart | grep -i "ffi"
0:00:09.163885: Skipped ffi transformation in 1ms.
```

When compiling the flutter gallery app that does depend on dart:ffi we go from:

```
$ out/ReleaseX64/dart pkg/front_end/tool/_fasta/compile.dart -v --target=flutter --platform=/tmp/tmp.6KV5psVGIG/flutter_patched_sdk/platform_strong.dill /tmp/tmp.6KV5psVGIG/gallery/lib/main.dart | grep -i "ffi"
0:00:16.344955: Transformed ffi natives in 78ms.
0:00:16.777218: Transformed ffi annotations in 432ms.
$ out/ReleaseX64/dart pkg/front_end/tool/_fasta/compile.dart -v --target=flutter --platform=/tmp/tmp.6KV5psVGIG/flutter_patched_sdk/platform_strong.dill /tmp/tmp.6KV5psVGIG/gallery/lib/main.dart | grep -i "ffi"
0:00:15.994674: Transformed ffi natives in 80ms.
0:00:16.472779: Transformed ffi annotations in 478ms.
$ out/ReleaseX64/dart pkg/front_end/tool/_fasta/compile.dart -v --target=flutter --platform=/tmp/tmp.6KV5psVGIG/flutter_patched_sdk/platform_strong.dill /tmp/tmp.6KV5psVGIG/gallery/lib/main.dart | grep -i "ffi"
0:00:16.027488: Transformed ffi natives in 81ms.
0:00:16.491362: Transformed ffi annotations in 463ms.
```

to

```
$ out/ReleaseX64/dart pkg/front_end/tool/_fasta/compile.dart -v --target=flutter --platform=/tmp/tmp.6KV5psVGIG/flutter_patched_sdk/platform_strong.dill /tmp/tmp.6KV5psVGIG/gallery/lib/main.dart | grep -i "ffi"
0:00:15.991628: Transformed ffi natives in 30ms.
0:00:16.226564: Transformed ffi annotations in 234ms.
$ out/ReleaseX64/dart pkg/front_end/tool/_fasta/compile.dart -v --target=flutter --platform=/tmp/tmp.6KV5psVGIG/flutter_patched_sdk/platform_strong.dill /tmp/tmp.6KV5psVGIG/gallery/lib/main.dart | grep -i "ffi"
0:00:16.184984: Transformed ffi natives in 29ms.
0:00:16.404439: Transformed ffi annotations in 219ms.
$ out/ReleaseX64/dart pkg/front_end/tool/_fasta/compile.dart -v --target=flutter --platform=/tmp/tmp.6KV5psVGIG/flutter_patched_sdk/platform_strong.dill /tmp/tmp.6KV5psVGIG/gallery/lib/main.dart | grep -i "ffi"
0:00:15.933513: Transformed ffi natives in 27ms.
0:00:16.145640: Transformed ffi annotations in 212ms.
```

TEST=Assuming tests already exists.

Change-Id: Ie13be1924d3439cb710c782af81e1e42cda2a838
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/228001
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2022-01-17 09:43:14 +00:00
Stephen Adams
a45efb1555 [vm/lib] Fast path for Map.addAll
When a compact linked hash map is empty, it can add all the entries of
another compact linked hash map by a block-copy.

Adding elements to an empty map occurs with `Map.of(m)` which is
essentially `{}..addAll(m)`.

For AOT it does not make much difference for small maps, but is better
for large maps.

dart-aot-null linux-armv8c
MapCopy.Map.Thing.of.Map.2       3.737%   410.25  395.47
MapCopy.Map.String.of.Map.2      3.858%   400.93  386.03
MapCopy.Map.Thing.of.Map.100   503.4%    2308.06  382.49
MapCopy.Map.String.of.Map.100  543.6%    2297.51  356.96

JIT seems to do well on smaller maps too
dart linux-x64
MapCopy.Map.Thing.of.Map.2      80.22%   2681.76 1488.06
MapCopy.Map.String.of.Map.2     85.56%   2671.52 1439.70
MapCopy.Map.Thing.of.Map.100   777.8%   12859.79 1465.04
MapCopy.Map.String.of.Map.100  867.3%   12829.22 1326.28

Added similar fast path for identity maps, sets, and identity sets.

TEST=existing

Change-Id: Ifa8afc95797bc603113dcc7984c6a6d61af56595
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/222249
Reviewed-by: Dan Field <dnfield@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2022-01-14 17:35:21 +00:00
Alexander Markov
0e5a539315 [vm/aot] Keep toString methods on exception classes in toString transformer
Flutter in google3 uses --delete-tostring-package-uri compiler option
to remove toString methods in package:flutter and dart:ui to reduce
size in release mode.
This has unfortunate effect of removing toString methods from exception
classes which may provide valuable information for investigating
problems seen in the wild.

This change adds a new @pragma('flutter:keep-to-string-in-subtypes')
on classes to keep toString methods on all subtypes of the annotated
classes. This pragma is now used on Exception and Error classes in
dart:core.

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

Issue: https://github.com/flutter/flutter/issues/61562
Change-Id: Ib739c83cdf6b539208f705ba198e63b8bc54fa61
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/227920
Reviewed-by: Dan Field <dnfield@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2022-01-13 15:32:50 +00:00
Simon Binder
0a3d896274 [ffi] Add .ref= setter for pointers of structs or unions
Adds the `ref` setter to the `StructPointer` and `UnionPointer`
extensions, copying a compound structure into native memory.
The FFI use-site transformation transforms invocations of this setter
into an appropriate memcopy call.

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

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

Change-Id: I3ef06ad08b8e71e39b05d662e8082fc5d0ad876d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/227542
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2022-01-12 20:48:28 +00:00
Daco Harkes
e57dae8df5 [vm/ffi] Implement IntPtr as AbiSpecificInteger
Closes: https://github.com/dart-lang/sdk/issues/47938

TEST=tests/ffi*

Change-Id: I78cef41522813569f7e09ce31ce74ba615c070ed
Cq-Include-Trybots: luci.dart.try:analyzer-linux-release-try,analyzer-nnbd-linux-release-try,app-kernel-linux-debug-x64-try,benchmark-linux-try,dart-sdk-linux-try,front-end-linux-release-x64-try,front-end-nnbd-linux-release-x64-try,pkg-linux-debug-try,vm-canary-linux-debug-try,vm-ffi-android-debug-arm-try,vm-ffi-android-debug-arm64c-try,vm-fuchsia-release-x64-try,vm-kernel-checked-linux-release-x64-try,vm-kernel-gcc-linux-try,vm-kernel-linux-debug-x64c-try,vm-kernel-mac-debug-x64-try,vm-kernel-asan-linux-release-x64-try,vm-kernel-msan-linux-release-x64-try,vm-kernel-nnbd-linux-debug-ia32-try,vm-kernel-nnbd-win-debug-x64-try,vm-kernel-nnbd-win-release-ia32-try,vm-kernel-nnbd-linux-debug-x64-try,vm-kernel-precomp-asan-linux-release-x64-try,vm-kernel-precomp-android-release-arm_x64-try,vm-kernel-precomp-android-release-arm64c-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-win-debug-x64c-try,vm-kernel-reload-linux-debug-x64-try,vm-kernel-reload-rollback-linux-debug-x64-try,vm-kernel-win-debug-ia32-try,vm-kernel-win-debug-x64-try,vm-precomp-ffi-qemu-linux-release-arm-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/227162
Reviewed-by: Martin Kustermann <kustermann@google.com>
2022-01-11 22:04:15 +00:00
Ryan Macnak
28e522ed97 [vm] Don't include an isolate in getVM until it has been registered with the service isolate routing.
TEST=low probability Collected error on all uses of vm service
Bug: https://github.com/dart-lang/sdk/issues/33747
Bug: https://github.com/dart-lang/sdk/issues/46450
Change-Id: I7b8d08a734033d0678a539230d13ec3d66413961
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/63645
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-01-11 18:19:15 +00:00
Johnni Winther
8510f27d37 [cfe] Change encoding of supported dart: libraries
This CL changes the way dart: libraries are considered supported when
used in conditional imports or bool.fromEnvironment constant using
the "dart.library.*" values.

Library nodes now has an isUnsupported flag which is set according to
the "supported" property in the libraries specification. Furthermore
the Target now supplies a DartLibrarySupport interface that allows
targets to override whether dart: libraries are unsupported.

This allows the JIT/AOT to use the same platform file but still
consider dart:mirrors unsupported in AOT mode, and dart2js to consider
the internal library `dart:_dart2js_runtime_metrics` supported.

Furthermore, the internal handling is changed so that condition imports
and bool.fromEnvironments constants are computed through the same logic
for "dart.library.*" values, avoiding the need for passing these values
through the environment.

TEST=pkg/front_end/testcases/general/supported_libraries/main

Closes https://github.com/dart-lang/sdk/issues/48057
Closes https://github.com/dart-lang/sdk/issues/47814
Closes https://github.com/dart-lang/sdk/issues/47243
Closes https://github.com/dart-lang/sdk/issues/32657
Closes https://github.com/dart-lang/sdk/issues/36460

Change-Id: Ie8f8dff99167de64ced51b71d89918bf0f3bbd13
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/227020
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2022-01-11 14:52:38 +00:00
Jens Johansen
99a902ff36 [ffi] Speedup ffi transformation
Before this CL there was a pattern of looking up size and alignment for
a specific abi by using `size[abi]` and `alignment[abi]`. The problem
being that both are often dynamic map creations, meaning that it created
tons of maps that it looked up a specific value in and threw away.

This CL instead adds handles for getting size and alignment for a
specific abi, skipping the map creation.

On my machine this more than doubles the speed of the ffi transformation
when compiling the flutter gallery app:

Before:
```
$ out/ReleaseX64/dart pkg/front_end/tool/_fasta/compile.dart -v --target=flutter --platform=/tmp/tmp.aD6a8pEOZW/flutter_patched_sdk/platform_strong.dill /tmp/tmp.aD6a8pEOZW/gallery/lib/main.dart | grep "Transformed ffi annotations"
0:00:17.861255: Transformed ffi annotations in 990ms.

$ out/ReleaseX64/dart pkg/front_end/tool/_fasta/compile.dart -v --target=flutter --platform=/tmp/tmp.aD6a8pEOZW/flutter_patched_sdk/platform_strong.dill /tmp/tmp.aD6a8pEOZW/gallery/lib/main.dart | grep "Transformed ffi annotations"
0:00:18.029886: Transformed ffi annotations in 1055ms.

$ out/ReleaseX64/dart pkg/front_end/tool/_fasta/compile.dart -v --target=flutter --platform=/tmp/tmp.aD6a8pEOZW/flutter_patched_sdk/platform_strong.dill /tmp/tmp.aD6a8pEOZW/gallery/lib/main.dart | grep "Transformed ffi annotations"
0:00:17.807917: Transformed ffi annotations in 1012ms.
```

With this fix:
```
$ out/ReleaseX64/dart pkg/front_end/tool/_fasta/compile.dart -v --target=flutter --platform=/tmp/tmp.aD6a8pEOZW/flutter_patched_sdk/platform_strong.dill /tmp/tmp.aD6a8pEOZW/gallery/lib/main.dart | grep "Transformed ffi annotations"
0:00:17.159482: Transformed ffi annotations in 457ms.

$ out/ReleaseX64/dart pkg/front_end/tool/_fasta/compile.dart -v --target=flutter --platform=/tmp/tmp.aD6a8pEOZW/flutter_patched_sdk/platform_strong.dill /tmp/tmp.aD6a8pEOZW/gallery/lib/main.dart | grep "Transformed ffi annotations"
0:00:17.385509: Transformed ffi annotations in 410ms.

$ out/ReleaseX64/dart pkg/front_end/tool/_fasta/compile.dart -v --target=flutter --platform=/tmp/tmp.aD6a8pEOZW/flutter_patched_sdk/platform_strong.dill /tmp/tmp.aD6a8pEOZW/gallery/lib/main.dart | grep "Transformed ffi annotations"
0:00:17.216748: Transformed ffi annotations in 407ms.
```

TEST=This shouldn't change functionality, assuming tests already exists.

Change-Id: I2013659376e249622d75ebd8b77f2bf70685d4f9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/226688
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2022-01-11 13:19:36 +00:00
Alexander Markov
a09c585772 [vm/aot] Keep static type of a conditional expression when removing it in tree shaker
In order to make sure static types in kernel AST are still correct
after tree shaking, tree shaker needs to insert no-op unsafeCast calls
when removing conditional expressions, as ConditionalExpression nodes
have explicit 'staticType' which may be different from static types of
sub-expressions.

Otherwise we might end up with an untyped function call
(FunctionInvocation with FunctionAccessKind.Function)
performed from a receiver with a known function type.
That would violate VM's assumptions about static type of receiver
being checked by the front-end and trigger assertion in
pkg/vm/lib/transformations/call_site_annotator.dart.

TEST=runtime/tests/vm/dart/untyped_function_invocation_with_known_function_type_test.dart
TEST=pkg/vm/testcases/transformations/type_flow/transformer/null_test_elimination2_nnbd_strong.dart

Change-Id: I6bf201a979d1b71eb48ed04f154adf2b62dac922
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/226741
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2022-01-07 14:22:26 +00:00
Lasse R.H. Nielsen
cd0606e425 Simplify asyncExpectThrows and enhance Expect.throws.
For `asyncExpectThrows`, instead of taking a function,
then checking if that function can be called with zero arguments,
and then immediately calling it and checking that it returns a future,
just take the future as argument.

Since synchronus errors from calling the function were not caught
anyway, doing the entire `Future` computation directly shouldn't
change behavior.

Also make `asyncExpectThrows` and `Expect.throws` return the caught error,
so that you can use normal `Expect.something` checks on it afterwards,
instead of doing that in the `check` function.
That basically makes the `check` function unnecessary (but hard to remove
with the existing test corpus using it heavily).

This makes some uses of the `asyncExpectThrows` function slightly more
complicated, those that have no other way to create a future than calling
the argument function anyway, but other uses become simpler
when they can avoid adding the function wrapper.

TEST= Refactoring. If the tests keep running, it's successful.

Change-Id: I983eb65ea4805760339073fabc27f78c57f9a471
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/226102
Reviewed-by: Bob Nystrom <rnystrom@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
2022-01-06 17:06:47 +00:00
Alexander Markov
80c6896040 [vm/test] Convert vm/cc/IRTest_TypedDataAOT_{NotInlining,Regress43534} to the new IL tests
There are 2 AOT-specific unit tests which rely on disabled
--use_table_dispatch flag. That flag is enabled everywhere and was
only disabled for the vm unit tests.

These 2 tests are now migrated to the new IL tests infrastructure
and --use_table_dispatch flag is enabled in the vm unit tests.

In order to support testing of IL of closures, IL test infra is
extended with pragma

@pragma('vm:testing:match-inner-flow-graph', 'inner name')


TEST=vm/dart/typed_data_aot_not_inlining_il_test
TEST=vm/dart/typed_data_aot_regress43534_il_test

Change-Id: I900e96136ddedb408ffca05d0c71893c3e12c2c4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/225325
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2022-01-04 15:29:06 +00:00
Ben Konyi
0c071662a7 [ VM / Service ] Add support for streaming CPU samples with specific
user tags

TEST=cpu_sample_streaming_test.dart

Change-Id: Ia983217ae2a5da8c3252fafbed8197b4f4a20e2b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/224040
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2021-12-17 00:15:09 +00:00
Daco Harkes
acdf82de17 [vm/ffi] ABI-specific integers
This CL adds support for users defining integers which are mapped to
differing sizes and signedness based on the application binary interface
the Dart VM is running on.

Notable implementation design decisions:
- ABIs are open world, so that adding an ABI to the Dart VM does not
  break existing definitions. Thus, we only figure out in the VM that
  we're missing a mapping. We throw compile-time errors.
  - In AOT, these show up in the precompilation step.
  - In JIT, these show up as `_CompileTimeError` at runtime. Note that
    these can be caught. So in subsequent compilation steps we need to
    ensure that we also throw the same compile-time error.
- We match on the call-sites (streaming_flowgraph_builder) rather than
  method bodies (kernel_to_il) of AbiSpecific loads and stores so that
  we can compile for the int-size of the call site.

API design decisions:
https://github.com/dart-lang/sdk/issues/42563#issuecomment-981774001

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

TEST=tests/ffi_2/abi_*_test.dart
TEST=tests/ffi/function_*_generated_test.dart
TEST=tests/ffi/vmspecific_static_checks_test.dart
Change-Id: I8c8df36fab939b6fb614c5f1ee8e1bf46b6e9521
Cq-Include-Trybots: luci.dart.try:analyzer-linux-release-try,analyzer-nnbd-linux-release-try,app-kernel-linux-debug-x64-try,benchmark-linux-try,dart-sdk-linux-try,front-end-linux-release-x64-try,front-end-nnbd-linux-release-x64-try,pkg-linux-debug-try,vm-canary-linux-debug-try,vm-ffi-android-debug-arm-try,vm-ffi-android-debug-arm64c-try,vm-fuchsia-release-x64-try,vm-kernel-checked-linux-release-x64-try,vm-kernel-gcc-linux-try,vm-kernel-linux-debug-x64c-try,vm-kernel-mac-debug-x64-try,vm-kernel-asan-linux-release-x64-try,vm-kernel-msan-linux-release-x64-try,vm-kernel-nnbd-linux-debug-ia32-try,vm-kernel-nnbd-win-debug-x64-try,vm-kernel-nnbd-win-release-ia32-try,vm-kernel-nnbd-linux-debug-x64-try,vm-kernel-precomp-asan-linux-release-x64-try,vm-kernel-precomp-android-release-arm_x64-try,vm-kernel-precomp-android-release-arm64c-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-win-debug-x64c-try,vm-kernel-reload-linux-debug-x64-try,vm-kernel-reload-rollback-linux-debug-x64-try,vm-kernel-win-debug-ia32-try,vm-kernel-win-debug-x64-try,vm-precomp-ffi-qemu-linux-release-arm-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/221501
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2021-12-16 22:07:00 +00:00
Ryan Macnak
ecdf148428 [vm] Refactor generation of identity hashes.
Generating identity hashes from the runtime no longer calls into Dart. On 32-bit systems, generating identity hashes from Dart now does only one runtime transition.

TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/47873
Change-Id: Ib21156cb05706f81744eb4e5ccb644f40aa84c96
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/222326
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2021-12-13 22:31:46 +00:00
Alexander Markov
e698500693 [vm/aot/tfa] Use RTA to improve AOT compilation speed
This change introduces Rapid Type Analysis (RTA) and uses it to
calculate initial set of allocated classes for Type Flow Analysis (TFA).
As a result, TFA converges much faster and AOT compilation time
improves.

RTA is less precise than TFA, so the set of allocated classes is
larger compared to the one calculated by TFA. However, it has only
marginal effect on the size of resulting AOT snapshots.

Time of AOT compilation step 2 on a large Flutter application
118.652s -> 59.907s (-49.5% / improved by a factor of 1.98x)
Snapshot size on armv8: -0.13%

Flutter gallery snapshot size in release and release-sizeopt modes
armv7 +0.19%, armv8 +0.2%

Just in case, RTA can be disabled using --no-rta option.

TEST=ci
Issue: https://github.com/dart-lang/sdk/issues/42442
Issue: b/154155290

Change-Id: Iffbdabe7d486cad2e138f7592bffcb70474ddc34
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/222500
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2021-12-10 15:00:51 +00:00
Aske Simon Christensen
7ad6ea9d11 [vm/tfa] Fix assert to permit mixins in MoveFieldInitializers
Fixes https://github.com/dart-lang/sdk/issues/47822

TEST=pkg/vm/testcases/transformations/type_flow/transformer/mixin_with_field_test.dart
Change-Id: I433bab82fa3b603054392ed10ddf64083fb8e2f9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/222761
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Auto-Submit: Aske Simon Christensen <askesc@google.com>
Commit-Queue: Aske Simon Christensen <askesc@google.com>
2021-12-10 10:42:15 +00:00
Alexander Markov
1777f769ab [vm/aot] Visit TypeParameterType.promotedBound in tree shaker
If tree shaker doesn't visit TypeParameterType.promotedBound which
contains the only reference to a particular class it may remove that
class, leaving a dangling reference from promotedBound. After that
kernel AST serialization would crash with "Missing canonical name for
Reference" error.

This change also fixes TypeParameterType.visitChildren.

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

Change-Id: I555261713240bf0be412db27efb68f32cfd8008b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/222781
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2021-12-09 20:58:20 +00:00
Paul Berry
be57c7d5ea Remove explicit bool type hack.
During the fix for https://github.com/dart-lang/language/issues/1785,
an explicit `bool` type was added to the variable `nullable` to ensure
that it would properly participate in type promotion while the fix was
still being rolled out.  Now that the fix is in place, this explicit
type is no longer needed.

TEST=standard trybots, TAP global presubmit, Golem
Change-Id: Ib81ad436876e576f85c929c205d5831214e6a05a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/214821
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2021-12-09 16:34:59 +00:00
Alexander Markov
d5b3632868 [gardening] Increase timeout for slow protobuf_aware_treeshaker/treeshaker_test
TEST=ci
Fixes https://github.com/dart-lang/sdk/issues/47872

Change-Id: Ibd0b576d5e6ba3c574c21f57a8f5eead2f2341dc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/222324
Auto-Submit: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2021-12-08 00:28:59 +00:00
Daco Harkes
734eb8e891 [cfe/ffi] Support missing Abis in NativeTypeCfe
When ABI-specific integers are introduced, their mappings can be
partial. We need to account for this in the transformation and the code
we generate.

In the transformation, all sizes and offsets become nullable.
In the generated code we add `null` constants and a call to check
whether the value is not-null at runtime.

Note that with only this CL we can not generate nulls yet, because all
size and offset mappings are still complete.

TEST=pkg/front_end/testcases/nnbd/ffi*
TEST=tests/ffi*

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

Change-Id: I80d45f3f52001670bc0679a033f7daa22198d55e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/221631
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2021-12-02 12:10:27 +00:00
Daco Harkes
eea0e48f6b [cfe/ffi] Move NativeTypeCfe to its own file
We're going to extend this logic in subsequent CLs, so lets give this
abstraction its own place to live.

TEST=just moving file contents

Change-Id: Ie6b267e77dd3a772bb3bbf0b79b33946ee767b0e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/221630
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2021-12-02 12:10:27 +00:00
Daco Harkes
663357209c [vm/ffi] Introduce Abi
This introduces the application binary interface (ABI) concept to
`dart:ffi` as a class with opaque instances.

We will use this for providing mappings for ABI-specific types.
Bug: https://github.com/dart-lang/sdk/issues/42563
Bug: https://github.com/dart-lang/sdk/issues/42816
Closes: https://github.com/dart-lang/sdk/issues/45254

Later, we might open up the contents of `Abi` if need be.

Some API design discussion notes:
https://github.com/dart-lang/sdk/issues/42563#issuecomment-981774001

TEST=tests/ffi/abi_test.dart

Change-Id: Iebf290fc12f37d6f4236432ddf27ab3e12bde06d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/221627
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2021-12-01 19:19:37 +00:00
Johnni Winther
87c953bd0c [cfe] Pass class hierarchy and core types through IncrementalCompilerResult
TEST=existing

Change-Id: I78a61147998a630d88997e0cebccb3e815592822
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/221088
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2021-11-25 11:27:29 +00:00
Johnni Winther
e92e60da78 [cfe] Change computeDelta to return a result object
This prepares for returning more that just the component from an
incremental compilation.

TEST=existing

Change-Id: I3ee269083290097f1a92d77d105b607a6a02f1f9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/221086
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2021-11-25 10:15:07 +00:00
Daco Harkes
00ea62f713 [cfe/ffi] Handle invalid types in Array
Closes: https://github.com/dart-lang/sdk/issues/47673

TEST=tests/ffi(_2)/regress_47673(_2)_test.dart

Change-Id: I8fdafc5378797ed071250b0caed1ab944873a218
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/220760
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Clement Skau <cskau@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2021-11-19 13:38:47 +00:00
Vyacheslav Egorov
12b1773deb [vm] Fix issues with flutter_regress_91370_il_test
* Add Canonicalize pass after CSE to erase graph differences between
64-bit and 32-bit platforms. These differences originate from different
treatment of integers (we unbox more eagerly on 64-bit platform) and
consequently affect load forwarding - which generates some redundant[1]
phis on 64-bit platform, but not on 32-bit platform. Adding this pass
also addresses other cases of unpredictable performance when IL changes
can cause CSE not to trigger a Canonicalize inside itself and regress
performance, by inhibiting subsequent optimizations.
* Allow IL tests to check whether the graph was compiled in sound
null safety mode or not - because graphs can have minor differences.
* Use `"$i"` instead of `i.toString()` in the test to allow TFA to
infer non-nullability of fields in non-sound-nullsafety mode.

[1] The definition of redundant phi differs between canonicalization
pass and load forwarding pass. The former unwraps redefinitions and
the latter does not. We are going to address this difference in a
more systematic way when we split input dependencies from control
dependencies.

TEST=ci

Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-product-x64-try,vm-kernel-precomp-linux-release-x64-try,vm-kernel-precomp-linux-release-simarm-try,vm-kernel-precomp-nnbd-linux-release-x64-try,vm-kernel-precomp-nnbd-linux-release-simarm_x64-try
Change-Id: Ifbd68fbb7f3b374ecee8ada1b3a4a2249139a108
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/220541
Commit-Queue: Slava Egorov <vegorov@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
2021-11-17 12:12:31 +00:00
Vyacheslav Egorov
a643e537fb [vm/infra] Improve IL testing framework
* Add support for dumping flow graphs in JSON (to make it machine
readable);
* Add support for controlling which functions are dumped through
a pragma annotation:
`@pragma('vm:testing:print-flow-graph'[, "passes filter"])`
* Replace simple matching DSL with programmatic matching
* Support obfuscated builds

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

TEST=vm/dart{,_2}/aot_prefer_equality_comparison_il_test

Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-product-x64-try,vm-kernel-precomp-linux-release-x64-try
Change-Id: Ie067ba451d311e6019a8c3a88c012231b0c50eb5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/219240
Commit-Queue: Slava Egorov <vegorov@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2021-11-16 12:39:11 +00:00
Alexander Markov
1f3e5ed007 [vm/aot/tfa] Approximate invocations of large methods
In order to avoid spending too much time analyzing multiple
invocations of huge methods with different combinations of
argument types, the following heuristic is added to type
flow analysis:

- if size of a method summary >= N operations, and
- number of invocations for this method >= M, then
create and use an approximate invocation with raw argument types
for all subsequent invocations (so that we would have to analyze
at most M+1 invocations per huge method).

Constants N = 300 and M = 10 are selected so that size of
Flutter gallery AOT snapshot is not affected, and at the same
time compilation time of example involving huge auto-generated
methods from issue https://github.com/dart-lang/sdk/issues/47546 is
not regressed very much (<10s).

TEST=ci
Issue https://github.com/dart-lang/sdk/issues/47546

Change-Id: I6a452872b13bd32928585fce4431ec1176833e6c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/219749
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2021-11-11 17:48:51 +00:00
Daco Harkes
ed39d3cae9 [vm/ffi] Expand Abis
This CL expands the ABIs in the FFI transform and VM from 3 groups to
18 individual ABIs in preparation of adding ABI-specific integer sizes
and structs.

This increases const lists with offsets in the kernel representation
from 3 to 18 elements. We do not expect significant size increases or
performance regressions from this. The constants are deduplicated in
Dart and the optimizer should optimize indexed lookups in const lists
away. However, landing this separately will enable us to verify that
assumption.

This also moves `Abi` to its own file and makes it an opaque class with
a predefined set of instances so that we do not depend on its internals.
That will enable us to keep `pkg/vm/lib/transformations/ffi/abi.dart`
consistent with the `Abi` abstraction to be introduced in `dart:ffi`
later for specifying ABI-specific integer sizes.

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

List of ABIs decided based on what's currently used (as Dart SDK target
platform, or Flutter target platform, or G3 target) and added
windows_arm64 in anticipation of
(https://github.com/flutter/flutter/issues/53120).
Excluded are macos_ia32 (https://github.com/dart-lang/sdk/issues/39810)
because we discontinued support; and windows_arm, fuchsia_arm,
fuchsia_ia32, ios_ia32, and macos_arm because these are
unlikely to be added.

TEST=pkg/front_end/testcases/*.expect
TEST=tests/ffi/*

Change-Id: I437707c18d8667490c063272a5f8a33d846e6061
Cq-Include-Trybots: luci.dart.try:vm-kernel-linux-debug-x64-try,vm-ffi-android-debug-arm-try,vm-kernel-mac-debug-x64-try,vm-kernel-nnbd-linux-debug-x64-try,vm-kernel-linux-debug-ia32-try,vm-kernel-precomp-linux-debug-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-ffi-android-debug-arm64c-try,vm-kernel-mac-release-arm64-try,vm-precomp-ffi-qemu-linux-release-arm-try,vm-kernel-precomp-android-release-arm64c-try,vm-kernel-precomp-android-release-arm_x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/217184
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Clement Skau <cskau@google.com>
2021-11-03 19:29:03 +00:00
Daco Harkes
cb29cd3af9 [test/ffi] rename ffinative_test to ffi_test
It runs tests from the pkg/vm/testcases/transformations/ffi, where I'd
like to add ffi, but non-ffinative tests.

TEST=renames a test

Change-Id: I2c4128fd5ded154ab483b05d9002afdbb3dc33a4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/217642
Reviewed-by: Clement Skau <cskau@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2021-10-28 06:53:39 +00:00
Kevin Moore
83286de2a8 Allow pub get/upgrade to run on a number of packages in pkg/
Zero runtime affect to these unpublished packages
Allows using standard tools such as dart test, etc
Also allows better checking of dependency constraints

TEST=no effect on SDK build process

Change-Id: Ic6fbe6ce8f57724a87c058eccad64ce8e7473af1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/218180
Auto-Submit: Kevin Moore <kevmoo@google.com>
Reviewed-by: Devon Carew <devoncarew@google.com>
2021-10-27 23:15:56 +00:00
Clement Skau
0c0a72e3ae [vm/ffi] Adds unsafeCast to FfiNative return values.
This change replaces a `r as T` with `unsafeCast<T>(r)` to avoid
unnecessary type checking.
It is the responsibility of the native function to return the
expected type.

See discussion on https://dart-review.googlesource.com/c/sdk/+/218101

TEST=Updated expect file.

Change-Id: Ic6f0a642a4ffe60c421b1af1127cc1450dc93eec
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/218261
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Clement Skau <cskau@google.com>
2021-10-27 13:20:47 +00:00
Clement Skau
933055b142 [vm/ffi] Adds nullability to FfiNative closure.
This change makes the FfiNative closure inherit the nullability
of the associated Dart function.
Example:

  @FfiNative<Handle Function()>('MaybeStr')
  external String? maybeStr();

Generates a closure of type `() →  core::Object?`.

This enables @FfiNatives to return nullable types where they
previously would be forced non-nullable.

TEST=Updated expect file.

Change-Id: I85cf9f2f43749e97ab97779f911789034e6b9ab1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/218101
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Clement Skau <cskau@google.com>
2021-10-27 10:25:38 +00:00
Alexander Markov
53debdc1c3 [vm/aot/tfa] Minor improvements for AOT compilation time
This change contains a few small improvements which reduce
time of type flow analysis (AOT compilation step 2):

* Faster construction of _DirectInvocation objects
* Eager approximation of arguments of operator==
* Eager approximation of arguments of identical

Improves time of AOT compilation step 2 (TFA) on a large
Flutter application 137s -> 124s (-9.4%).

Doesn't affect size of Flutter gallery AOT snapshot.

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

Change-Id: I9da0b0e68d1ee8062d86094fb5cdb9462fb7ea6b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/217741
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2021-10-26 17:23:21 +00:00
Kevin Moore
7d8459dc3c dart:_http: apply and fix most of pkg:lints recommended lints
TEST=N/A

Change-Id: I3e3f0cd1d94743fbbe8cfcc5723eb38608be2a8b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/217503
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
Auto-Submit: Kevin Moore <kevmoo@google.com>
2021-10-21 16:33:15 +00:00
Clement Skau
7a3d38f08d [vm] Types lists in FfiNative transform.
Adds explicit types to list literals used in the ffi/native
transform, as the list type inferred will otherwise be too
narrow.
This triggers a problem later on when a different transform
then tries to add a broader typed value into these lists,
triggering a typing error:
`type 'ConstantExpression' is not a subtype of type 'VariableGet'`

TEST=ffi/vmspecific_ffi_native_test
Bug: https://github.com/dart-lang/sdk/issues/47512
Change-Id: Ie3ba10da02083e16e7325b225febdc43b31077f5
Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-nnbd-linux-release-x64-try,vm-kernel-precomp-linux-release-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/217302
Reviewed-by: Liam Appelbe <liama@google.com>
Commit-Queue: Liam Appelbe <liama@google.com>
Auto-Submit: Clement Skau <cskau@google.com>
2021-10-20 21:31:32 +00:00
Clement Skau
4522d4b07c [vm/ffi] Adds transforms for FfiNative return type of Handle.
FFI functions return Handles as Object so we have to add a cast
to get the expected return type. E.g.:
  @FfiNative<Handle Function()>(..)
  external String getSomeStr();
Will have a synthetic FFI function of type `Object Function()`,
which we need to add a `as String` to.

This CL also refactors the overlapping parts of
`_transformInstanceMethod` and `_transformInstanceFunction` into
two shared functions.

TEST=Updated .expect file.
Change-Id: I0f74d34ee3eef4928f7beb38a1180180c13672ad
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/216286
Commit-Queue: Clement Skau <cskau@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
2021-10-20 13:33:11 +00:00
Clement Skau
0cd81027f4 Set correct fileUri on FfiNative fields.
`currentLibrary.fileUri` points to the library file (e.g. ui.dart)
and not the class-containing `part` file (e.g. compositing.dart).
This causes `fileOffset` out-of-bounds and `location` to fail.

Failing stack trace:
Unhandled exception: Crash when compiling null, at character offset null:
RangeError (offset): Invalid value: Not in inclusive range 0..1257: 1543
#0      RangeError.checkValueInInterval (dart:core/errors.dart:282:7)
#1      Source.getLocation (package:kernel/ast.dart:13919:16)
#2      Component.getLocation (package:kernel/ast.dart:13692:31)
#3      _getLocationInComponent (package:kernel/ast.dart:14212:22)
#4      Field._getLocationInEnclosingFile (package:kernel/ast.dart:2363:12)
#5      TreeNode._getLocationInEnclosingFile (package:kernel/ast.dart:206:20)
#6      TreeNode.location (package:kernel/ast.dart:202:12)
#7      _FfiUseSiteTransformer._ensureNativeTypeToDartType (package:vm/transformations/ffi_use_sites.dart:744:35)
[...]

TEST=Existing.
Change-Id: I17b3ab23abcb04aca046509e7cdbb177ed156e54
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/217186
Commit-Queue: Clement Skau <cskau@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
2021-10-19 13:09:46 +00:00
Daco Harkes
0cd586486b [cfe/ffi] Move FFI transforms into folder
Having the transforms in a dedicated folder enables us to add more files
without cluttering the transformations folder itself.

TEST=This only moves files. Bots test whether imports are correct.

Change-Id: Icf1d64b5ec09a7d19915b1cb72464fa67b6cfe15
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/217180
Reviewed-by: Clement Skau <cskau@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2021-10-19 07:25:09 +00:00
Daco Harkes
1868b119e7 [vm/ffi] Cleanup outdated documentation
This file as not been updated in a long time, and we're not using it
as the ground truth for CFE/analyzer checks.

TEST=This is deleting a markdown file.

Change-Id: I4872223a889407800c2f0d6a6092f7db4200967c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/217018
Auto-Submit: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2021-10-19 05:50:58 +00:00
Daco Harkes
757c2b82ce [vm/ffi] Add Bool
This CL adds the `Bool` `NativeType` with support for loading/storing
from `Pointer<Bool>`, `Array<Bool>`, and `Struct` and `Union` fields,
and support for passing booleans through FFI calls and callbacks.

The assumption is that `bool` is always treated as `uint8_t` in the
native ABIs. Including: (1) whether there can be garbage in the upper
bytes in CPU registers, (2) stack alignment, and (3) alignment in
compounds.

The conversion from `bool` to `uint8_t` is implemented as follows:
- bool to int: `value ? 1 : 0`
- int to bool: `value != 0`
The conversion is implemented in Dart in patch files for memory loads
and stores (pointer, array, and struct fields) and kernel_to_il for
FFI call and callback arguments and return value.

TEST=runtime/vm/compiler/ffi/native_type_vm_test.cc
TEST=tests/ffi/bool_test.dart
TEST=tests/ffi/function_callbacks_structs_by_value_generated_test.dart
TEST=tests/ffi/function_structs_by_value_generated_test.dart

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

Change-Id: I75d100340ba41771abfb41c598ca92066a89370b
Cq-Include-Trybots: luci.dart.try:vm-kernel-linux-debug-x64-try,vm-ffi-android-debug-arm-try,vm-kernel-mac-debug-x64-try,vm-kernel-nnbd-linux-debug-x64-try,vm-kernel-linux-debug-ia32-try,vm-kernel-precomp-linux-debug-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-ffi-android-debug-arm64c-try,vm-kernel-mac-release-arm64-try,vm-precomp-ffi-qemu-linux-release-arm-try,vm-kernel-precomp-android-release-arm64c-try,vm-kernel-precomp-android-release-arm_x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/216900
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Clement Skau <cskau@google.com>
2021-10-18 10:44:11 +00:00
Daco Harkes
4031e6a82c [cfe/ffi] Refactor transform lists into sets and maps
Addressing https://dart-review.googlesource.com/c/sdk/+/216900/3/pkg/vm/lib/transformations/ffi.dart#77

TEST=FFI test suite

Change-Id: I96a88534d452fd727b7cc693cc5d37fd49d06977
Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/217002
Reviewed-by: Clement Skau <cskau@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2021-10-15 09:23:42 +00:00
Clement Skau
998d5f5a9b [vm/ffi] Adds FFI transform FfiNative instance methods.
- Allows FfiNative annotation to be attached to non-static
  methods of classes.
- Transforms non-static instance methods to static, adding
  wrappers with the receiver as an extra, implicit first paramters.
- Transform all parameters and arguments to Pointer if the object
  being passed supports it (i.e. extends NativeFieldWrapperClass1).
- Adds compile time errors for cases where the FfiNative annotation
  doesn't align with the annotated function. Taking into account
  implicit receivers and converted Pointers.
- Adds complimentary Analyzer checks for the above errors as well.
- Adds tests for the transforms, compile time errors and analyzer
  changes.

TEST=Adds new tests for instance methods, analyzer changes.

Change-Id: Idf54430acf2728a650008333b149b254941290ad
Cq-Do-Not-Cancel-Tryjobs: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/213773
Commit-Queue: Clement Skau <cskau@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
2021-10-12 10:58:44 +00:00
Alexander Aprelev
e270bbe95c [io/unix-domain-sockets] Ensure runtime-looked up entry points are marked as such.
This is needed to ensure that entry points looked from native code are preserved, not tree-shaken.

This is follow-up to https://dart.googlesource.com/sdk/+/935ee25f3b72e7fe81047220cadae1f61c505da4

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

TEST=unix_socket_test on dartkp bots

Change-Id: I5cf3071507947b1c24b2808e46dc92186e4b9476
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/216062
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2021-10-08 20:22:28 +00:00
Alexander Markov
3aaad7817b [vm/aot/tfa] Build cache of dispatch targets in TFA instead of using ClosedWorldClassHierarchy from CFE
Previously, TFA used ClosedWorldClassHierarchy from CFE to look for
dispatch targets of invocations, and cached those lookups. However,
doing lookups via ClosedWorldClassHierarchy for the first time is still
slow. Now TFA builds maps of dispatch targets from AST and no longer
uses ClosedWorldClassHierarchy for the lookup.

Improves time of AOT compilation step 2 (TFA) on a large
Flutter application 170s -> 152s (-10.5%).

TEST=ci

Issue: https://github.com/dart-lang/sdk/issues/42442
Change-Id: I1a22d298e5b2c0ead57c38ddfbf5ebbd1876732f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/215985
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2021-10-08 11:02:16 +00:00
Clement Skau
d5fada929d [vm/ffi/test] Replaces FfiNative transform test with expect.
We can't rely on GC to trigger the finalizer of a given test object,
so the previous liveness test was unreliable.

Instead we add an expect test to verify we generate the necessary
`reachabilityFence(..)`s to ensure liveness.

TEST=Adds expect.
Bug: https://github.com/dart-lang/sdk/issues/47362
Change-Id: Ia57a07522c8b8265b24780f00f3339b50534eb60
Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-nnbd-mac-release-arm64-try,vm-kernel-nnbd-mac-debug-x64-try,vm-kernel-mac-product-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/215542
Commit-Queue: Clement Skau <cskau@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
2021-10-06 10:40:16 +00:00
Johnni Winther
3aaea30f10 [cfe] Pass references to lowered tear-offs
TEST=existing

Change-Id: I7e2625f87b357ceec45ec2664f7444af38ec0cf1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/215402
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2021-10-05 09:20:41 +00:00
Robert Nystrom
3ac34f791d Change references to "dartfmt" in runtime and tools to "dart format".
In Dart 2.15, we're removing "dartfmt" in favor of "dart format", so I'm
going through and fixing all the dangling references to the old name.

TEST=Only changing tools

Change-Id: I83a5c00be925fdb536014a47dff2b488ed9f478b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/215186
Auto-Submit: Bob Nystrom <rnystrom@google.com>
Commit-Queue: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2021-10-01 18:16:27 +00:00
Vyacheslav Egorov
8740a4f10f [vm/infra] Nascent AOT IL tests infrastructure.
Our current unit testing infrastructure does not make it possible to
test AOT compilation pipeline end-to-end, because it does not run TFA
when generating Kernel.

This makes it challenging to write regression tests for certain issues.

Instead we extend test runner with a capability to perform IL matching
when running AOT tests.

runtime/docs/infa/il_tests.md provides details on how to write such tests.

TEST=manually

Change-Id: I6f5220b814f4a5d8c053efacd3711df495dea404
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/214961
Commit-Queue: Slava Egorov <vegorov@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2021-09-30 13:19:42 +00:00
Alexander Markov
d78abd0a69 [vm/aot/tfa] Cache negative results of dispatch target lookup
When looking for a dispatch target, also cache not found selectors
to avoid repeated lookups.

Improves time of AOT compilation step 2 (TFA) on a large
Flutter application 189s -> 171s (-9.5%).

TEST=ci

Issue: https://github.com/dart-lang/sdk/issues/42442
Change-Id: I21686e1f40a09ef62abf010bfa3670615c108942
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/214342
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2021-09-24 16:27:45 +00:00
Clement Skau
22652a3b49 [vm/ffi] Privatizes dart:nativewrappers' getNativeField(..)
TEST=Updated dart_api_impl_test.

Change-Id: Ib72667b2a20adc342f724a6eff7d326e2e106257
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/214401
Commit-Queue: Clement Skau <cskau@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2021-09-24 13:13:55 +00:00