Commit graph

1574 commits

Author SHA1 Message Date
Daco Harkes e16bb210d2 [vm/ffi] Optimize @Native calls
This CL removes static fields for storing the `@Native`'s function
addresses. Instead, the function addresses are stored in the object
pool for all archs except for ia32. ia32 has no AOT and no AppJit
snapshots, so the addresses are directly embedded in the code.

This CL removes the closure wrapping for `@Native`s. Instead of
`pointer.asFunctionInternal()()` where `asFunction` returns a closure
which contains the trampoline, the function is compiled to a body
which contains the trampoline `Native()`. This is possible for
`@Native`s because the dylib and symbol names are known statically.

Doing the compilation in kernel_to_il instead of a CFE transform
enables supporting static linking later. (The alternative would have
been to transform in the cfe to a `@pragma('vm:cachable-idempotent')`
instead of constructing the IL in kernel_to_il.

To enable running resolution in ia32 in kernel_to_il.cc, the
resolution function has been made available via
`runtime/lib/ffi_dynamic_library.h`.

Because the new calls are simply static calls, the TFA can figure
out const arguments flowing to these calls. This leads to constant
locations in the parameters to FfiCalls. So, this CL also introduces
logic to move constants into `NativeLocation`s.

TEST=runtime/vm/compiler/backend/il_test.cc
TEST=tests/ffi/function_*_native_(leaf_)test.dart
TEST=pkg/vm/testcases/transformations/ffi/ffinative_compound_return.dart

Closes: https://github.com/dart-lang/sdk/issues/47625
Closes: https://github.com/dart-lang/sdk/issues/51618
Change-Id: Ic5d017005dedcedea40c455c4d24dbe774f91603
CoreLibraryReviewExempt: Internal FFI implementation changes
Cq-Include-Trybots: luci.dart.try:vm-aot-android-release-arm64c-try,vm-aot-android-release-arm_x64-try,vm-aot-linux-debug-x64-try,vm-aot-linux-debug-x64c-try,vm-aot-mac-release-arm64-try,vm-aot-mac-release-x64-try,vm-aot-obfuscate-linux-release-x64-try,vm-aot-win-debug-arm64-try,vm-aot-win-debug-x64c-try,vm-aot-win-release-x64-try,vm-appjit-linux-debug-x64-try,vm-asan-linux-release-x64-try,vm-checked-mac-release-arm64-try,vm-eager-optimization-linux-release-ia32-try,vm-eager-optimization-linux-release-x64-try,vm-ffi-android-debug-arm-try,vm-ffi-android-debug-arm64c-try,vm-ffi-qemu-linux-release-arm-try,vm-ffi-qemu-linux-release-riscv64-try,vm-fuchsia-release-x64-try,vm-kernel-linux-debug-x64-try,vm-kernel-precomp-linux-release-x64-try,vm-linux-debug-ia32-try,vm-linux-debug-x64-try,vm-linux-debug-x64c-try,vm-mac-debug-arm64-try,vm-mac-debug-x64-try,vm-msan-linux-release-x64-try,vm-reload-linux-debug-x64-try,vm-reload-rollback-linux-debug-x64-try,vm-ubsan-linux-release-x64-try,vm-win-debug-arm64-try,vm-win-debug-x64-try,vm-win-debug-x64c-try,vm-win-release-ia32-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/284300
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2023-11-02 16:00:53 +00:00
Johnni Winther 12c4e22a4d [cfe] Handle various cases ExtensionType
Handles ExtensionType in inference of MapLiteral, inference of
ObjectPattern, and exhaustiveness.

TEST=tests/extension_type/*

Change-Id: I3284da2c69d875e192cf3f004ee1156e1aedd98b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/333160
Reviewed-by: Ömer Ağacan <omersa@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2023-11-02 10:42:48 +00:00
Alexander Markov f54ecbdf31 [vm,dart2wasm] Fix tree shaking of extension types used only in type literals
TEST=pkg/vm/testcases/transformations/type_flow/transformer/extension_type.dart
TEST=co19/LanguageFeatures/Extension-types/superinterfaces_of_extension_type_A08_t02

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

Issue: https://github.com/dart-lang/sdk/issues/49737
Change-Id: I80237a1240905a52805f5b3e7bd857ed96773609
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/332450
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>
2023-10-31 14:59:29 +00:00
Daco Harkes 14d0c0e7c5 [cfe/ffi] Test _nativeEffect for @Natives
In a follow up, we will remove the transform from `@Native` to
`_asFunctionInternal`. However, we need to ensure that we keep
emitting `_nativeEffect` for struct return values classes if
`@Native`s are the only place instances are created.

The follow up CL will change the expect files.

TEST=pkg/vm/test/transformations/ffi_test

Bug: https://github.com/dart-lang/sdk/issues/47625
Change-Id: I1685683f48f1d16d6d10606f541f13e17d8583fe
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/332800
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Auto-Submit: Daco Harkes <dacoharkes@google.com>
2023-10-30 18:51:21 +00:00
Daco Harkes f5983e4214 [ffi] Update some FfiNative docs to Native
The old FfiNatives have been deprecated for a while.

TEST=Only comments updated.

Change-Id: Ideb6e904841e5162d30df479e83b463b94682afe
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/332780
Auto-Submit: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2023-10-30 18:43:14 +00:00
Alexander Aprelev 6a464c9dee Revert "Expire 3.0.0 experiment flags."
This reverts commit 6f29e7fce4.

Reason for revert: broke g3 bot

Original change's description:
> Expire 3.0.0 experiment flags.
>
> TEST=Existing tests covers.
> Change-Id: I161eefdc28c74f63ba1ee926800a01eea03d9930
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/331960
> Commit-Queue: Lasse Nielsen <lrn@google.com>
> Reviewed-by: Alexander Thomas <athom@google.com>

Change-Id: Ied6f612dc922824ffdadc4660898f3b859922ff5
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/332582
Reviewed-by: Lasse Nielsen <lrn@google.com>
Reviewed-by: Alexander Thomas <athom@google.com>
Commit-Queue: Alexander Thomas <athom@google.com>
Auto-Submit: Alexander Aprelev <aam@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
2023-10-27 16:50:09 +00:00
Lasse R.H. Nielsen 6f29e7fce4 Expire 3.0.0 experiment flags.
TEST=Existing tests covers.
Change-Id: I161eefdc28c74f63ba1ee926800a01eea03d9930
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/331960
Commit-Queue: Lasse Nielsen <lrn@google.com>
Reviewed-by: Alexander Thomas <athom@google.com>
2023-10-27 13:57:00 +00:00
Vyacheslav Egorov ac32223cea [vm/compiler] Improve CreateArray compile type
If we have constant type arguments include them
into the type.

This CL also expands IL tests framework with the
capability to match CompileTypes.

TEST=vm/dart/regress_53817_il_test

Bug: https://github.com/dart-lang/sdk/issues/53817
Cq-Include-Trybots: luci.dart.try:vm-aot-linux-product-x64-try,vm-aot-linux-release-arm64-try,vm-aot-linux-release-simarm_x64-try,vm-aot-obfuscate-linux-release-x64-try
Change-Id: I48722b002d9cd436dbc8ca3c9afbefa124f18996
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/331900
Commit-Queue: Slava Egorov <vegorov@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
2023-10-26 12:40:02 +00:00
Vyacheslav Egorov a97f85ef0e [tfa] Make kPrintStats runtime configurable
Currently we have to ask users to run TFA from source
(which requires a lot of dances with figuring out
command line and checking out Dart SDK).

However statistics printing does not impose any runtime
overhead (as opposed for example to kPrintTimings
which tracks timings) so it can be runtime configurable.

Inspired by https://github.com/flutter/flutter/issues/136529

TEST=tested manually

Change-Id: Ie496d6babb1e8cbbbb9a665b14656ea334a2eeed
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/331881
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2023-10-26 11:19:24 +00:00
Johnni Winther e06536af2e [cfe] Create combined member signature stub
This create a stub for combined member signatures from multiple
inherited non-extension type members and adds these to the
extension type declaration.

A sealed [TypeDeclaration] superclass is added to [Class] and
[ExtensionTypeDeclaration] to support accessing the enclosing type
declaration from a [Member].

TEST=existing

Change-Id: Ic01535d27a14187d37b00868e7e90fe73558b051
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/331181
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2023-10-25 14:16:00 +00:00
Johnni Winther d252bb11a3 [cfe] Add representation field to ExtensionTypeDeclaration
This adds the representation field of an extension type declaration
as an abstract getter in the ExtensionTypeDeclaraiton marking it as
a ProcedureStubKind.RepresentationField

These are never used as interface targets and are therefore skipped
in the type flow analysis.

TEST=existing

Change-Id: Ie645e63e0995a31895e985a2025dccb1476d16bf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/330782
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Ömer Ağacan <omersa@google.com>
Reviewed-by: Mayank Patke <fishythefish@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2023-10-19 10:15:25 +00:00
Tess Strickland f303110aa1 [pkg/vm] Also check -Dtest_runner.configuration for arch-specific tests.
Add RISCV32 to the list of architectures checked for
is32BitConfiguration.

TEST=vm/dart/pointer_as_typed_list_il_test on android trybots

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

Change-Id: I0c8297dc863b6121f9b1eafb99ae273ea2d0b34e
Cq-Include-Trybots: luci.dart.try:vm-aot-android-release-arm_x64-try,vm-aot-android-release-arm64c-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/330740
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
2023-10-17 14:16:40 +00:00
Alexander Markov c9b28eb882 [vm/aot/tfa] Handle references to tree-shaken closures
Sometimes inferred closure value may reference a closure
which was eliminated by the tree shaker (as tree-shaker can prune
deeper AST). That should not cause a crash and inferred closure value
should be disregarded.

TEST=pkg/vm/testcases/transformations/type_flow/transformer/eliminated_closure.dart
Fixes b/305730721

Change-Id: Ia26e620ebc06f949be1e05c734be65ce1d708b64
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/330661
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2023-10-17 12:14:18 +00:00
Tess Strickland 4d1bdaaca9 Reland "[vm/compiler] Change MemoryCopy to also take untagged addresses."
This is a reland of commit 06d7a2352e

This version fixes an issue when a phi node has multiple inputs with
different unboxed integer representations. The original CL made a
change where only the representations were considered, not the range
of values for the Phi calculated by range analysis. The reland goes
back to the old behavior for this case.

Also fixes the new tests on 32-bit architectures.

Original change's description:
> [vm/compiler] Change MemoryCopy to also take untagged addresses.
>
> This CL adds the ability to pass the payload address of the source
> and destination directly to the MemoryCopy instruction as an untagged
> value.
>
> The new translation of the _TypedListBase._memMoveN methods use the new
> MemoryCopy constructor, retrieving the untagged value of the data field
> of both the source and destination. This way, if inlining exposes the
> allocation of the object from which the data field is being retrieved,
> then allocation sinking can remove the intermediate allocation if there
> are no escaping uses of the object.
>
> Since Pointer.asTypedList allocates such ExternalTypedData objects,
> this CL makes that method inlined if at all possible, which removes
> the intermediate allocation if the only use of the TypedData object
> is to call setRange for memory copying purposes.
>
> This CL also separates unboxed native slots into two groups: those
> that contain untagged addresses and those that do not. The former
> group now have the kUntagged representation, which mimics the old
> use of LoadUntagged for the PointerBase data field and also ensures
> that any arithmetic operations on untagged addresses must first be
> explicitly converted to an unboxed integer and then explicitly converted
> back to untagged before being stored in a slot that contains untagged
> addresses.
>
> When a unboxed native slot that contains untagged addresses is defined,
> the definition also includes a boolean which represents whether
> addresses that may be moved by the GC can be stored in this slot or not.
> The redundancy eliminator uses this to decide whether it is safe to
> eliminate a duplicate load, replace a load with the value originally
> stored in the slot, or lift a load out of a loop.
>
> In particular, the PointerBase data field may contain GC-moveable
> addresses, but only for internal TypedData objects and views, not
> for external TypedData objects or Pointers. To allow load optimizations
> involving the latter, the LoadField and StoreField instructions now
> take boolean flags for whether loads or stores from the slot are
> guaranteed to not be GC-moveable, to override the information from
> the slot argument.
>
> Notable benchmark changes on x64 (similar for other archs unless noted):
>
> JIT:
> * FfiMemory.PointerPointer: 250.7%
> * FfiStructCopy.Copy1Bytes: -26.73% (only x64)
> * FfiStructCopy.Copy32Bytes: -25.18% (only x64)
> * MemoryCopy.64.setRange.Pointer.Uint8: 19.36%
> * MemoryCopy.64.setRange.Pointer.Double: 18.96%
> * MemoryCopy.8.setRange.Pointer.Double: 17.59%
> * MemoryCopy.8.setRange.Pointer.Uint8: 19.46%
>
> AOT:
> * FfiMemory.PointerPointer: 323.5%
> * FfiStruct.FieldLoadStore: 483.3%
> * FileIO_readwrite_64kb: 15.39%
> * FileIO_readwrite_512kb (Intel Xeon): 46.22%
> * MemoryCopy.512.setRange.Pointer.Uint8: 35.20%
> * MemoryCopy.64.setRange.Pointer.Uint8: 55.40%
> * MemoryCopy.512.setRange.Pointer.Double: 29.45%
> * MemoryCopy.64.setRange.Pointer.Double: 60.37%
> * MemoryCopy.8.setRange.Pointer.Double: 59.54%
> * MemoryCopy.8.setRange.Pointer.Uint8: 55.40%
> * FfiStructCopy.Copy32Bytes: 398.3%
> * FfiStructCopy.Copy1Bytes: 1233%
>
> TEST=vm/dart/address_local_pointer, vm/dart/pointer_as_typed_list
>
> Issue: https://github.com/dart-lang/sdk/issues/42072
> Fixes: https://github.com/dart-lang/sdk/issues/53124
>
> Cq-Include-Trybots: luci.dart.try:vm-ffi-qemu-linux-release-arm-try,vm-eager-optimization-linux-release-x64-try,vm-linux-release-x64-try,vm-linux-debug-x64-try,vm-aot-linux-release-x64-try,vm-aot-linux-debug-x64-try
> Change-Id: I563e0bfac5b1ac6cf1111649934067c12891b631
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/324820
> Reviewed-by: Alexander Markov <alexmarkov@google.com>
> Commit-Queue: Tess Strickland <sstrickl@google.com>
> Reviewed-by: Martin Kustermann <kustermann@google.com>

TEST=vm/dart/address_local_pointer, vm/dart/pointer_as_typed_list

Issue: https://github.com/dart-lang/sdk/issues/42072
Fixes: https://github.com/dart-lang/sdk/issues/53124

Change-Id: Iabb0e910f12636d0ff51e711c8c9c98ad40e5811
Cq-Include-Trybots: luci.dart.try:vm-ffi-qemu-linux-release-arm-try,vm-eager-optimization-linux-release-x64-try,vm-linux-release-x64-try,vm-linux-debug-x64-try,vm-aot-linux-release-x64-try,vm-aot-linux-debug-x64-try,vm-aot-linux-release-simarm_x64-try,vm-aot-linux-debug-simarm_x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/330600
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2023-10-17 07:41:49 +00:00
Liam Appelbe 9308e6bd01 [vm/ffi] Address Lasse's post-submit comments from 328280
https://dart-review.googlesource.com/c/sdk/+/328280

1) Combine _setKeepIsolateAlive/_getKeepIsolateAlive into
abstract bool _keepIsolateAlive.

2) Refactor close to delegate to _close, rather than calling
super.close(). Makes _isClosed validation clearer.

Change-Id: I61a97f5ba35c3ff00ab4270b9f7a763968e703fc
TEST=CI (no behaviour changes)
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/330580
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Liam Appelbe <liama@google.com>
2023-10-17 01:54:00 +00:00
Alexander Markov 5362d9536b Revert "[vm/compiler] Change MemoryCopy to also take untagged addresses."
This reverts commit 06d7a2352e.

Reason for revert: everything crashes on vm-aot-linux-debug-simarm_x64

Original change's description:
> [vm/compiler] Change MemoryCopy to also take untagged addresses.
>
> This CL adds the ability to pass the payload address of the source
> and destination directly to the MemoryCopy instruction as an untagged
> value.
>
> The new translation of the _TypedListBase._memMoveN methods use the new
> MemoryCopy constructor, retrieving the untagged value of the data field
> of both the source and destination. This way, if inlining exposes the
> allocation of the object from which the data field is being retrieved,
> then allocation sinking can remove the intermediate allocation if there
> are no escaping uses of the object.
>
> Since Pointer.asTypedList allocates such ExternalTypedData objects,
> this CL makes that method inlined if at all possible, which removes
> the intermediate allocation if the only use of the TypedData object
> is to call setRange for memory copying purposes.
>
> This CL also separates unboxed native slots into two groups: those
> that contain untagged addresses and those that do not. The former
> group now have the kUntagged representation, which mimics the old
> use of LoadUntagged for the PointerBase data field and also ensures
> that any arithmetic operations on untagged addresses must first be
> explicitly converted to an unboxed integer and then explicitly converted
> back to untagged before being stored in a slot that contains untagged
> addresses.
>
> When a unboxed native slot that contains untagged addresses is defined,
> the definition also includes a boolean which represents whether
> addresses that may be moved by the GC can be stored in this slot or not.
> The redundancy eliminator uses this to decide whether it is safe to
> eliminate a duplicate load, replace a load with the value originally
> stored in the slot, or lift a load out of a loop.
>
> In particular, the PointerBase data field may contain GC-moveable
> addresses, but only for internal TypedData objects and views, not
> for external TypedData objects or Pointers. To allow load optimizations
> involving the latter, the LoadField and StoreField instructions now
> take boolean flags for whether loads or stores from the slot are
> guaranteed to not be GC-moveable, to override the information from
> the slot argument.
>
> Notable benchmark changes on x64 (similar for other archs unless noted):
>
> JIT:
> * FfiMemory.PointerPointer: 250.7%
> * FfiStructCopy.Copy1Bytes: -26.73% (only x64)
> * FfiStructCopy.Copy32Bytes: -25.18% (only x64)
> * MemoryCopy.64.setRange.Pointer.Uint8: 19.36%
> * MemoryCopy.64.setRange.Pointer.Double: 18.96%
> * MemoryCopy.8.setRange.Pointer.Double: 17.59%
> * MemoryCopy.8.setRange.Pointer.Uint8: 19.46%
>
> AOT:
> * FfiMemory.PointerPointer: 323.5%
> * FfiStruct.FieldLoadStore: 483.3%
> * FileIO_readwrite_64kb: 15.39%
> * FileIO_readwrite_512kb (Intel Xeon): 46.22%
> * MemoryCopy.512.setRange.Pointer.Uint8: 35.20%
> * MemoryCopy.64.setRange.Pointer.Uint8: 55.40%
> * MemoryCopy.512.setRange.Pointer.Double: 29.45%
> * MemoryCopy.64.setRange.Pointer.Double: 60.37%
> * MemoryCopy.8.setRange.Pointer.Double: 59.54%
> * MemoryCopy.8.setRange.Pointer.Uint8: 55.40%
> * FfiStructCopy.Copy32Bytes: 398.3%
> * FfiStructCopy.Copy1Bytes: 1233%
>
> TEST=vm/dart/address_local_pointer, vm/dart/pointer_as_typed_list
>
> Issue: https://github.com/dart-lang/sdk/issues/42072
> Fixes: https://github.com/dart-lang/sdk/issues/53124
>
> Cq-Include-Trybots: luci.dart.try:vm-ffi-qemu-linux-release-arm-try,vm-eager-optimization-linux-release-x64-try,vm-linux-release-x64-try,vm-linux-debug-x64-try,vm-aot-linux-release-x64-try,vm-aot-linux-debug-x64-try
> Change-Id: I563e0bfac5b1ac6cf1111649934067c12891b631
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/324820
> Reviewed-by: Alexander Markov <alexmarkov@google.com>
> Commit-Queue: Tess Strickland <sstrickl@google.com>
> Reviewed-by: Martin Kustermann <kustermann@google.com>

Issue: https://github.com/dart-lang/sdk/issues/42072
Change-Id: I7c31434e01108487de69a32154bbefd1538c6f0f
Cq-Include-Trybots: luci.dart.try:vm-ffi-qemu-linux-release-arm-try,vm-eager-optimization-linux-release-x64-try,vm-linux-release-x64-try,vm-linux-debug-x64-try,vm-aot-linux-release-x64-try,vm-aot-linux-debug-x64-try
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/330523
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
Auto-Submit: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2023-10-13 19:47:36 +00:00
Tess Strickland 06d7a2352e [vm/compiler] Change MemoryCopy to also take untagged addresses.
This CL adds the ability to pass the payload address of the source
and destination directly to the MemoryCopy instruction as an untagged
value.

The new translation of the _TypedListBase._memMoveN methods use the new
MemoryCopy constructor, retrieving the untagged value of the data field
of both the source and destination. This way, if inlining exposes the
allocation of the object from which the data field is being retrieved,
then allocation sinking can remove the intermediate allocation if there
are no escaping uses of the object.

Since Pointer.asTypedList allocates such ExternalTypedData objects,
this CL makes that method inlined if at all possible, which removes
the intermediate allocation if the only use of the TypedData object
is to call setRange for memory copying purposes.

This CL also separates unboxed native slots into two groups: those
that contain untagged addresses and those that do not. The former
group now have the kUntagged representation, which mimics the old
use of LoadUntagged for the PointerBase data field and also ensures
that any arithmetic operations on untagged addresses must first be
explicitly converted to an unboxed integer and then explicitly converted
back to untagged before being stored in a slot that contains untagged
addresses.

When a unboxed native slot that contains untagged addresses is defined,
the definition also includes a boolean which represents whether
addresses that may be moved by the GC can be stored in this slot or not.
The redundancy eliminator uses this to decide whether it is safe to
eliminate a duplicate load, replace a load with the value originally
stored in the slot, or lift a load out of a loop.

In particular, the PointerBase data field may contain GC-moveable
addresses, but only for internal TypedData objects and views, not
for external TypedData objects or Pointers. To allow load optimizations
involving the latter, the LoadField and StoreField instructions now
take boolean flags for whether loads or stores from the slot are
guaranteed to not be GC-moveable, to override the information from
the slot argument.

Notable benchmark changes on x64 (similar for other archs unless noted):

JIT:
* FfiMemory.PointerPointer: 250.7%
* FfiStructCopy.Copy1Bytes: -26.73% (only x64)
* FfiStructCopy.Copy32Bytes: -25.18% (only x64)
* MemoryCopy.64.setRange.Pointer.Uint8: 19.36%
* MemoryCopy.64.setRange.Pointer.Double: 18.96%
* MemoryCopy.8.setRange.Pointer.Double: 17.59%
* MemoryCopy.8.setRange.Pointer.Uint8: 19.46%

AOT:
* FfiMemory.PointerPointer: 323.5%
* FfiStruct.FieldLoadStore: 483.3%
* FileIO_readwrite_64kb: 15.39%
* FileIO_readwrite_512kb (Intel Xeon): 46.22%
* MemoryCopy.512.setRange.Pointer.Uint8: 35.20%
* MemoryCopy.64.setRange.Pointer.Uint8: 55.40%
* MemoryCopy.512.setRange.Pointer.Double: 29.45%
* MemoryCopy.64.setRange.Pointer.Double: 60.37%
* MemoryCopy.8.setRange.Pointer.Double: 59.54%
* MemoryCopy.8.setRange.Pointer.Uint8: 55.40%
* FfiStructCopy.Copy32Bytes: 398.3%
* FfiStructCopy.Copy1Bytes: 1233%

TEST=vm/dart/address_local_pointer, vm/dart/pointer_as_typed_list

Issue: https://github.com/dart-lang/sdk/issues/42072
Fixes: https://github.com/dart-lang/sdk/issues/53124

Cq-Include-Trybots: luci.dart.try:vm-ffi-qemu-linux-release-arm-try,vm-eager-optimization-linux-release-x64-try,vm-linux-release-x64-try,vm-linux-debug-x64-try,vm-aot-linux-release-x64-try,vm-aot-linux-debug-x64-try
Change-Id: I563e0bfac5b1ac6cf1111649934067c12891b631
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/324820
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2023-10-13 19:06:30 +00:00
Alexander Markov ed00c27c77 [vm/aot/tfa] Refactor hash codes in TFA
This change removes code duplication around hash code calculations
in TFA. TFA cannot use Object.hash from core library as it is not
guaranteed to be stable across different runs but compiler should be
deterministic.

TEST=ci

Change-Id: Id1b35974e89e82218d82957495c27b6aad099c86
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/330046
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2023-10-13 17:52:37 +00:00
Johnni Winther 54b588a373 [cfe] Mark implicit enum constructors as synthetic
Closes #53615

TEST=existing

Change-Id: Ic2ad21787e62c8051dc2020cc15d61195f512b80
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/330440
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2023-10-13 15:28:46 +00:00
Johnni Winther f87142fdc2 [kernel] Add ExtensionTypeDeclaration.procedures
This adds a list of `Procedure`s to `ExtensionTypeDeclaration`. This is
meant to model representation fields and combined member signatures
computed from inherited non-extension type members.

These are not meant to be handled by the backends. The combined
member signature can be the interface target of an `InstanceInvocation`
expression but will always have a `.memberSignatureOrigin` value from
one of the original class members.

TEST=existing

Change-Id: I87768ed75a3c7126b0a30f8ccf06e46678c56db6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/330301
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2023-10-13 07:42:29 +00:00
Alexander Markov 293cc6475a [vm/aot/tfa] Whole-program propagation of closure values
This change adds propagation of closure values to TFA.
For now, inferred closure values are used only when they are
constant (tear-off of a static method or a constructor).

Arbitrary closures can now be referenced from unrelated
members via closure-id metadata.

In addition, this change fixes an incorrect stack trace when
an implicit closure (tear-off) was propagated and its call was
inlined. Inlining interval was not recorded because of the missing
source position of a call to a target method within implicit closure.

TEST=pkg/vm/testcases/transformations/type_flow/transformer/closures.dart
Issue: https://github.com/dart-lang/sdk/issues/39692

Change-Id: I3590da91b6057e0b55a8614382dba1bbcc267b39
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/325447
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2023-10-12 16:16:21 +00:00
Jens Johansen 73466729f3 [vm] Pass offset and script uri for expression compilation
This CL passes the offset and uri of the file (here called a script uri
as opposed to a library uri, the two will be different if we're in a
part) when doing expression compilation.

This CL only passes the data, but doesn't actually use it.
Future CL(s) will use this data to calculate the static type of
available variables which is needed for an upcomming feature.

TEST=Existing tests.
CoreLibraryReviewExempt: Not changing SDK APIs.
Change-Id: I67ead461ab4bb9341424e693946f3e4afe35ce92
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/329322
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2023-10-12 10:22:38 +00:00
Johnni Winther 9a4c9100ae [kernel] Add DartType.extensionTypeErasure
This renames ExtensionType.typeErasure and adds it to DartType. This also fixes the extension type erasure for when extension types are used in the arguments of an extension type.

DartType.extensionTypeErasure can be used by backends to easily
access the type without extension types for any type.

TEST=pkg/kernel/test/extension_type_erasure_test.dart


Change-Id: Ia49d273ed85111e3ae822720860a3e0be5ea0252
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/329960
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2023-10-11 13:51:22 +00:00
Alexander Markov 481f2b39fc [vm] Fix noSuchMethod forwarding stubs in mixin applications
TEST=pkg/front_end/testcases/no_such_method_forwarders/regress_*

Fixes https://github.com/dart-lang/sdk/issues/53677
Fixes https://github.com/dart-lang/sdk/issues/53676
Fixes https://github.com/dart-lang/sdk/issues/53656
Fixes https://github.com/dart-lang/sdk/issues/53640

Change-Id: I282a57a6aa4d3d55235ff0fb2c1d9b8470c49c93
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/329565
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2023-10-09 16:57:22 +00:00
Devon Carew e2fe203adc [deps] roll package:lints to the latest
Change-Id: I582f956cd4b712203c2f6dd630b4e1384040446d
Tested: analysis clean (this is a lint only related change)
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/329400
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Devon Carew <devoncarew@google.com>
2023-10-05 03:36:59 +00:00
Tess Strickland 80c79a3d84 [vm/test] Support declaring multiple instruction attributes.
Using the preprocessor string literal operator # on __VA_ARGS__
in a variadic macro does not separately stringize each argument,
but instead creates a single string of the expanded arguments.

Thus, rename DECLARE_ATTRIBUTES to DECLARE_ATTRIBUTE and have it take a
single expression. For multiple attributes, DECLARE_ATTRIBUTES_NAMED
must be used instead.

Also, use a comma fold expression in AttributesSerializer::WriteTuple to
separately call WriteAttribute with each element of the tuple in turn,
instead of calling WriteAttribute once with all the tuple contents as
arguments.

Move the demangling of attribute names that are directly stringized
from expressions from the JSON consumer to the JSON producer.

To illustrate how to add multiple attributes to an instruction, this CL
adds two attributes to the StoreField instruction: slot and
is_initialization.

When printing an instruction in the IL matcher, if the instruction has
any boolean attributes, don't print the attribute if the value is false
and only print the name if the attribute is true to reduce clutter.

TEST=ci

Change-Id: Ie541364374171c3dcbee4b609942d415a1c464e8
Cq-Include-Trybots: luci.dart.try:vm-aot-linux-debug-x64-try,vm-aot-linux-release-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/327864
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
2023-09-27 13:40:06 +00:00
Tess Strickland 4352985e11 [vm/compiler] Perform inlining of _TypedList._getX in AOT.
This is a partial reland of 6673f84d that just fixes the inlining of
_TypedList._getX in AOT without the changes to the base implementation
of the _TypedList._getX and _TypedList._setX functions.

TEST=vm/dart/inline_TypedList_getUint32

Fixes: https://github.com/dart-lang/sdk/issues/53513
Cq-Include-Trybots: luci.dart.try:vm-aot-linux-debug-x64-try,vm-aot-linux-release-x64-try,vm-aot-mac-release-arm64-try,dart-sdk-linux-riscv64-try,vm-aot-linux-debug-simriscv64-try
Change-Id: I2ef5244d50b2551a2326d6d511b9b720792346a5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/327840
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2023-09-27 11:40:04 +00:00
Ryan Macnak cb39b9ff07 Revert "[vm/compiler] Perform inlining of _TypedList._getX in AOT."
This reverts commit 6673f84d59.

Reason for revert: does not honor SupportsUnboxedSimd128(), breaking RISC-V

Original change's description:
> [vm/compiler] Perform inlining of _TypedList._getX in AOT.
>
> Before, the inliner only replaced calls to the _TypedList._getX methods
> with specialized IL if speculation was allowed. This means that the
> inlining would not happen in AOT mode, even though the generated IL
> does not require speculation.
>
> In addition, this CL replaces the native functions used for the
> base definition of _TypedList._getX and _TypedList._setX with
> versions built in the FlowGraphBuilder. With this, the VM avoids
> the overhead of going to the runtime for a native call when these
> methods are not inlined, which should also reduce the impact of
> a failure to inline.
>
> TEST=vm/dart/inline_TypedList_getUint32
>
> Issue: https://github.com/dart-lang/sdk/issues/53513
> Cq-Include-Trybots: luci.dart.try:vm-aot-linux-debug-simarm_x64-try,vm-aot-linux-debug-x64-try,vm-aot-linux-debug-x64c-try,vm-kernel-linux-debug-x64-try,vm-kernel-precomp-linux-debug-x64-try,vm-linux-debug-x64-try,vm-linux-debug-x64c-try,vm-mac-debug-arm64-try,vm-aot-linux-release-simarm_x64-try,vm-aot-linux-release-x64-try,vm-aot-mac-release-arm64-try,vm-linux-release-x64-try,vm-mac-release-arm64-try,vm-kernel-precomp-linux-release-x64-try
> Change-Id: I66b6b8634b2b9b413fb745f02433eb58f2ff913e
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/325703
> Reviewed-by: Martin Kustermann <kustermann@google.com>
> Commit-Queue: Tess Strickland <sstrickl@google.com>
> Reviewed-by: Alexander Markov <alexmarkov@google.com>

Issue: https://github.com/dart-lang/sdk/issues/53513
Change-Id: If3a224e184f084fbe5d059cf036b2c2fb72cd57b
Cq-Include-Trybots: luci.dart.try:vm-aot-linux-debug-simarm_x64-try,vm-aot-linux-debug-x64-try,vm-aot-linux-debug-x64c-try,vm-kernel-linux-debug-x64-try,vm-kernel-precomp-linux-debug-x64-try,vm-linux-debug-x64-try,vm-linux-debug-x64c-try,vm-mac-debug-arm64-try,vm-aot-linux-release-simarm_x64-try,vm-aot-linux-release-x64-try,vm-aot-mac-release-arm64-try,vm-linux-release-x64-try,vm-mac-release-arm64-try,vm-kernel-precomp-linux-release-x64-try
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/327802
Auto-Submit: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
2023-09-25 21:56:57 +00:00
Tess Strickland 6673f84d59 [vm/compiler] Perform inlining of _TypedList._getX in AOT.
Before, the inliner only replaced calls to the _TypedList._getX methods
with specialized IL if speculation was allowed. This means that the
inlining would not happen in AOT mode, even though the generated IL
does not require speculation.

In addition, this CL replaces the native functions used for the
base definition of _TypedList._getX and _TypedList._setX with
versions built in the FlowGraphBuilder. With this, the VM avoids
the overhead of going to the runtime for a native call when these
methods are not inlined, which should also reduce the impact of
a failure to inline.

TEST=vm/dart/inline_TypedList_getUint32

Issue: https://github.com/dart-lang/sdk/issues/53513
Cq-Include-Trybots: luci.dart.try:vm-aot-linux-debug-simarm_x64-try,vm-aot-linux-debug-x64-try,vm-aot-linux-debug-x64c-try,vm-kernel-linux-debug-x64-try,vm-kernel-precomp-linux-debug-x64-try,vm-linux-debug-x64-try,vm-linux-debug-x64c-try,vm-mac-debug-arm64-try,vm-aot-linux-release-simarm_x64-try,vm-aot-linux-release-x64-try,vm-aot-mac-release-arm64-try,vm-linux-release-x64-try,vm-mac-release-arm64-try,vm-kernel-precomp-linux-release-x64-try
Change-Id: I66b6b8634b2b9b413fb745f02433eb58f2ff913e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/325703
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2023-09-25 16:07:17 +00:00
Chloe Stefantsova de302d7f3b [cfe] Introduce StructuralParameters
This CL introduces StructuralParameter and StructuralParameterType
classes. They are intended to replace TypeParameter and
TypeParameterType respectively where those were used as type
parameters defined by FunctionTypes. Previously, type parameters of
FunctionTypes were represented by TypeParameter objects with the
‘parent’ field set to null. By introducing StructuralParameter and
StructuralParameterType this CL unambiguously separates the two
notions of type parameters.

TEST=existing

Change-Id: Ida3feb7ad96a7b2acef55840eacba9e36bf2a3e7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/312264
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Mayank Patke <fishythefish@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2023-09-25 10:44:41 +00:00
Alexander Markov 20a7d7199f [vm/aot/tfa] Remove convariant parameter type checks when type argument is an extension type
This change improves handling of extension types when they are used in
the generic types involved in parameter type checks.
Instead of treating extension types as unknown opaque types, TFA now
uses their type erasures.

TEST=pkg/vm/testcases/transformations/type_flow/transformer/extension_type.dart

Fixes https://github.com/dart-lang/sdk/issues/53542
Issue https://github.com/dart-lang/sdk/issues/49737

Change-Id: I04bb8f1940c0983b6c09403df577b89f5de4a81d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/326681
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2023-09-18 20:15:49 +00:00
Johnni Winther 15b4758745 [cfe] Make Statement, Expression, Initializer, Constant and DartType sealed
Adds Auxiliary* nodes to support extending the AST from outside package:kernel

TEST=existing

Change-Id: I350718a1b02c188f212b3390050b60484f9f4b3b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/326305
Reviewed-by: Ömer Ağacan <omersa@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
Reviewed-by: Mayank Patke <fishythefish@google.com>
2023-09-18 10:36:28 +00:00
Alexander Markov 4b9c7c05d4 [vm, dart2wasm] Early lowering of FunctionTearOff nodes
FunctionTearOff node represents a tear-off of the 'call' method of
a Function, so it is basically a no-op:

  FunctionTearOff(receiver) == receiver

So we can remove this node early, during lowering transformation on
kernel AST and clean up handling of FunctionTearOff nodes from the VM
and dart2wasm compilation pipelines.

TEST=ci

Change-Id: Ia1500a066a0261076162e018ff0ab502258f606f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/325924
Reviewed-by: Ömer Ağacan <omersa@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2023-09-15 16:54:08 +00:00
Alexander Markov 3ca05545fa [pkg/vm] Cleanup uses of *VisitorDefaultMixin to enable static checking of visitors
Implementing a *Visistor and not extending *VisitorDefaultMixin enables
compile-time checking that visitor has all visit*** methods and
protects it from possible omissions when new AST nodes are added.

TEST=ci

Change-Id: Ie6204b06d13cebba2164af7313141a136997eb14
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/325800
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2023-09-15 14:52:25 +00:00
Vyacheslav Egorov 98d9a31dbc [vm/testing] Improve il_matchers obfuscation support
Recognize "Instance of C" string and handle it in special way:
apply renaming to class name (C) only.

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

TEST=vm/dart/comparison_canonicalization_il_test in obfuscate configuration

Fixed: 53512
Cq-Include-Trybots: luci.dart.try:vm-aot-obfuscate-linux-release-x64-try
Change-Id: I3fa31ab52aef01417d523a075913a0971158be72
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/326062
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2023-09-14 21:58:52 +00:00
Johnni Winther 36b93f6b08 [cfe] Make ConstantVisitor(1) a pure interface
This splits ConstantVisitor(1) into a pure interface and a
ConstantVisitor(1)DefaultMixin with the base implementation. This is
a step towards avoid having an accidental default implementation where
a static error would have been preferable.

Also removes BodyVisitor1 which was unused.

TEST=existing

Change-Id: I265754e13e0ebcce5c154b16c7ee36854f4ce9fe
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/325400
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Mayank Patke <fishythefish@google.com>
Reviewed-by: Ömer Ağacan <omersa@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2023-09-13 14:02:28 +00:00
Johnni Winther 79ad624ef0 [cfe] Handle extension type constructors and instance methods with the same name
These are supported but there synthesized names conflicted.

TEST=pkg/front_end/testcases/constructor_tearoffs/lowering/constructor_member_conflict.dart

Change-Id: I952907eb83d7e496eb7d53f5c6b67d8f1e87308b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/324680
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2023-09-13 13:15:20 +00:00
Vyacheslav Egorov 5c320a108a [vm/compiler] Improve flow sensitivity of CP
Before running CP find all branches of form `Branch(v eq C)`,
where `eq` is one of `===`, `==`, `!==` or `!=` and `C` is
a constant and insert a redefinition of `v` in the true
successor which captures the information that `v` is equal
to `C` guaranteed by the branch.

SCCP algorithm can then use this information when propagating
constants. After SCCP all redefinitions inserted are removed
again.

We don't actually replace `v` with `C` in the dominated code
because this might lead to issues later, for example
it might result in redundant phis `phi(C, v)` (`C` flowing
from a predecessor where `v == C`) which are complicated
to eliminate again.

TEST=vm/dart/comparison_canonicalization_il_test

Cq-Include-Trybots: luci.dart.try:vm-aot-linux-release-x64-try,vm-aot-linux-debug-simarm_x64-try,vm-aot-linux-debug-x64-try,vm-aot-android-release-arm64c-try
Change-Id: I388dddb97b5e35f09d9904000c585864f27400f6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/324980
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2023-09-12 22:39:25 +00:00
Alexander Markov 3ec9cc86c8 [pkg/vm] Bump language version to 3.0 and cleanup experimental flags
Minimum SDK version is increased in order to be able to use Dart 3.0
language features in pkg/vm.

TEST=ci

Change-Id: I4ef1139b2f8ba8acc7dbcf9bc0fe77f663cc427d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/325541
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2023-09-12 20:18:59 +00:00
Vyacheslav Egorov 7ff975c2e5 [vm/compiler] Fix InferredTypeMetadata::IsTrivial
`IsTrivial` is supposed to return true iff `ToCompileType` would
produce a trivial (dynamic) type. However `IsTrivial` was taking
some of the irrevant parts of the `InferredTypeMetadata` into
account - meaning that it returned `false` where it should have
returned `true`.

This lead us to assign useless `dynamic` result type to various `StaticCall`, some of these calls can later be lowered to
`LoadIndexed` instructions, which will then also get the `dynamic`
result type. This useless type will then take priority over more
precise element type which could be inferred by
`LoadIndexedInstr::ComputeType`

TEST=vm/dart/load_indexed_trivial_type_il_test

Cq-Include-Trybots: luci.dart.try:vm-aot-linux-release-x64-try,vm-aot-linux-debug-simarm_x64-try,vm-aot-linux-debug-x64-try,vm-aot-android-release-arm64c-try
Change-Id: I69ee965ba0d0ac85ede3989680371f0dda19d8a9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/325302
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2023-09-12 08:13:12 +00:00
Johnni Winther 4c1a94c0d3 [cfe] Embed tearoff in Extension(Type)MemberDescriptor
This simplifies handle the constructor/member and its corresponding
tearoff as a pair. Also it prepare for supporting tearoff of
extension type constructors and methods with the same name.

TEST=existing

Change-Id: Iea6cbc0250c8df6bd0f825068c1f3e865d938427
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/324202
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2023-09-11 13:35:10 +00:00
Johnni Winther fefa87d1e6 [cfe] Make DartTypeVisitor(1) a pure interface
This splits DartTypeVisitor(1) into a pure interface and a
DartTypeVisitor(1)DefaultMixin with the base implementation. This is
a step towards avoid having an accidental default implementation where
a static error would have been preferable.

TEST=existing

Change-Id: Ieea9a773a9b70897a2db10cff8d721831a702a8b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/324780
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2023-09-08 11:59:41 +00:00
Johnni Winther e401b6f18a [kernel] Add sealed classes GenericDeclaration and GenericFunction
This adds a typed `TypeParameter.declaration` property to be used
instead of the `parent` property. The `declaration` property holds the
declaration (Class, Method, Extension, etc.) that introduced the
type parameter. `GenericFunction` is the subset of `GenericDeclaration`
that is defined through a `FunctionNode`.

TEST=existing

Change-Id: Ie89e7f5fa12a7966507a250cacc098eb0ce6b30b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/323160
Reviewed-by: Mayank Patke <fishythefish@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2023-09-08 08:32:25 +00:00
Ryan Macnak 4038b4f9df [frontend_server] Forward --keep-class-names-implementing.
Cf. 708f098c4f

TEST=ci
Change-Id: I65b51d5aa93eeb0e41ee276b4288dd231d6dbc87
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/323424
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2023-08-31 22:27:45 +00:00
Ryan Macnak 708f098c4f [vm, compiler] Add option to suppress obfuscation of type names for some hierarchy.
This behaves like applying @pragma("vm:keep-name") to the hiearchy.

TEST=ci
Bug: b/285175418
Change-Id: Ibd543d294bebbfbb60f4e5d62d5e83f3aec841e7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/322582
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2023-08-25 18:55:32 +00:00
Liam Appelbe e8d7425c4e [vm/ffi] Closure callbacks for sync callbacks
Bug: https://github.com/dart-lang/sdk/issues/52689
Change-Id: I54be397cfbf8519fe5b5a51b793fe46d602124d9
Fixes: https://github.com/dart-lang/sdk/issues/52689
Bug: https://github.com/dart-lang/sdk/issues/53096
TEST=isolate_local_function_callbacks_test.dart, plus generated tests and additions to existing tests
CoreLibraryReviewExempt: The isolate and FFI packages are VM-only
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/317060
Commit-Queue: Liam Appelbe <liama@google.com>
Reviewed-by: Liam Appelbe <liama@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
2023-08-25 03:35:44 +00:00
Alexander Markov 9f40ce6e3d [vm/aot] Use inferred types of captured local variables
On a micro-benchmark from https://github.com/dart-lang/sdk/issues/48764
in AOT mode, 'for-in' case:
Before: 0.556557s
After: 0.166579s (3.3x faster)

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

Issue https://github.com/dart-lang/sdk/issues/48764
Fixes https://github.com/dart-lang/sdk/issues/51102

Change-Id: I591739b8c2154931f6c535db57c0c11ba0eeb4a5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/321543
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2023-08-24 15:21:51 +00:00
Jens Johansen 9f9da91b84 [kernel] Facilitate faster sorting of additional exports
The "additionalExports" are sorted in production code to give stable
output.
Before this CL it did `toString()` on the canonical names which is
O(n^2) because of continued string concatenation.
This CL changes it to sort on the name, going to the parent if it's the
same. This _does_ change the sorting, but should still be stable.

When compiling via the flutter frontend try bot the time spent on
sorting does from ~45 seconds to ~9 seconds (arguable still a lot, but
much better).

This will also speed up flutter testing because it will spend less time
waiting for the frontend.

TEST=Assuming existing tests.

Change-Id: If350b7c2ce49f00b2924732a7fa7eb51c38c8172
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/322280
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2023-08-24 13:21:38 +00:00
Johnni Winther 29003657e2 [parser] Remove support for 'inline class' syntax
+ removes tests using 'inline class' syntax or replace them with
  extension type syntax.

TEST=existing

Change-Id: Ic98178c4df9a1585ad0167cfd8847caa7b771e3e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/321120
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2023-08-22 11:26:54 +00:00
Ömer Sinan Ağacan 8c5f895cac [dart2wasm, vm] Use list implementation class methods in List factories
In dart2wasm, implementation class methods for `filled` and `generate`
are much faster:

- In `filled` we use a single `array.fill`.
- In `generate` we update the array directly without bounds checks.

In VM, this shouldn't make things worse, but it may make things better
as the `result[i] = ...` lines will have a more precise receiver types
in the implementation class methods.

This replaces the explicit loops in `List.filled` and `generate`
factories with implementation class `filled` and `generate` methods.

Tested: Existing tests.
Change-Id: Ib24e5be687df325a43d335657a7142f7d9f980ce
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/321040
Commit-Queue: Ömer Ağacan <omersa@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2023-08-17 12:08:30 +00:00