Commit graph

11202 commits

Author SHA1 Message Date
Devon Carew e2aac0b8e8 [web docs] add package:web to the main sdk docs - api.dart.dev
Change-Id: I858db7090563cc7366d22f191b7cd3cf49047d5e
CoreLibraryReviewExempt: doc only change to the web libraries
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/348182
Commit-Queue: Devon Carew <devoncarew@google.com>
Reviewed-by: Srujan Gaddam <srujzs@google.com>
2024-01-26 15:54:59 +00:00
Srujan Gaddam 3b294fdab2 [dart:js_interop] Add isA helper
Closes https://github.com/dart-lang/sdk/issues/54138

Adds a helper to do better type-checks so that users don't
accidentally using is checks or have to manually do the right
typeof or instanceof checks. In order to do this, there is
some refactoring to make ExportCreator a SharedInteropTransformer
(as it's shared across all backends) so that we can reuse an
existing visitor. In the same class, we remove unnecessary setting
of parent pointers. We should clean up the fileOffsets as well,
but dart2js verifies that those are set, so we keep them as is
for now. Also adds some static errors for edge cases.

CoreLibraryReviewExempt: Helper for web-specific library.
Change-Id: I34d818ada1349b69afd15d170d3fafa0460f65fa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/347225
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
2024-01-25 18:52:45 +00:00
Martin Kustermann 7f668b63c3 [dart2wasm] Introduce a --minify flag to dart2wasm that uses "minified:Class<cid>" for class names
The `minified:...` encoding of class names mirrors the one used by
dart2js. So the added test will work in both modes.

This reduces optimized dart2wasm output

* hello world by 20%
* flute complex by 8.5%

Change-Id: I080de40919ee3f25f0f0d8c9b82aa662f7e734aa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/347741
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2024-01-24 09:10:15 +00:00
Srujan Gaddam a6e8759888 [dart2wasm] Add concrete box and symbol for JSBoxedDartObject
The current implementation externalizes and internalizes the Dart
value instead of adding a box and using a runtime-specific symbol.
This makes the implementation consistent with the JS backends.

Change-Id: Iefa382f742bc819b18dfe27ca33741b12473ee39
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/347222
Commit-Queue: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2024-01-23 23:39:49 +00:00
Mayank Patke b4be031505 [dart2js] Ensure SSA builder doesn't omit casts with SNS checks enabled
Change-Id: I108e73e45e98047b45e3f904fe7b93acc5dd2221
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/348040
Commit-Queue: Mayank Patke <fishythefish@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2024-01-23 23:22:51 +00:00
Anna Gringauze 389d66a515 Fix inner DDC types display
Closes: https://github.com/dart-lang/sdk/issues/54694
Change-Id: Ie141959eedc9cdbb5c675d33da985eb1ac5588e1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/347761
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Anna Gringauze <annagrin@google.com>
2024-01-23 18:26:43 +00:00
Lasse R.H. Nielsen 64b03d1998 Add extra documentation to Enum to point to EnumName.
Closes https://github.com/dart-lang/sdk/pull/53164

GitOrigin-RevId: 0c96101a1239a4e3a04cd01c4765e5687c39dc0f
Change-Id: I26391dddde87cdea0cc6ae4a70d04be1a48576f2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/319463
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
2024-01-23 09:34:32 +00:00
Nicholas Shahan b811ab5b04 [ddc] Reset all initialized consts on hot restart
Clear local caches storing const values in each module.

Change-Id: I7766e92df6b8d1f91bad5fbb2addb8ace7763646
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/347220
Reviewed-by: Mark Zhou <markzipan@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
2024-01-22 23:25:18 +00:00
Devon Carew 335a9b0c68 [docs] update the messaging for dart:html and related libraries
Change-Id: Idca54c94a583d688e3f2470f1e062e9f44f0d131
CoreLibraryReviewExempt: doc only change to the web libraries
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/347387
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Commit-Queue: Devon Carew <devoncarew@google.com>
2024-01-22 21:28:02 +00:00
Graciliano Monteiro Passos 5d18799eae HTMLSelectElement: fix selectedOptions when selectedIndex < 0
Closes https://github.com/dart-lang/sdk/pull/54618

Also adds a comment to go.sh mentioning vpython3 comes with
depot_tools.

GitOrigin-RevId: 5e057703067c24d9d41bac75b6251c8f3a2fddd3
Change-Id: I937d8618c24602b4c0844d8a52ff00095836bca8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/346220
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
2024-01-22 20:15:26 +00:00
Parker Lougheed eb5c77e7c2 [sdk] Mark dart:developer APIs with since information
Without the since information added, packages can use these APIs despite their SDK constraints potentially allowing SDK versions without them. For example, in package:leak_tracker recently: https://github.com/dart-lang/leak_tracker/issues/201.

I only added Since information to APIs added since Dart 2.12 since that's the lowest relevant SDK constraint with sound null safety.

TEST=ci

Cq-Include-Trybots: luci.dart.try:flutter-analyze-try
CoreLibraryReviewExempt: This CL does not change any APIs or their implementation, only adding relevant Since documentation to support correct triggering of the sdk_version_since diagnostic.
Change-Id: I27613ebf745f084a3056b8ffd2542221d939a838
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/346200
Commit-Queue: Derek Xu <derekx@google.com>
Reviewed-by: Derek Xu <derekx@google.com>
Auto-Submit: Parker Lougheed <parlough@gmail.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
2024-01-22 14:58:12 +00:00
Oleh Prypin 5a1ef6089c Revert "[ffi]: Remove pointer elementAt method."
This reverts commit f706ff4ee2.

Reason for revert: b/321667799 - package:win32 uses this method - a78ff108fb/lib/src/com/iapplicationactivationmanager.dart (L46)

Original change's description:
> [ffi]: Remove pointer elementAt method.
>
> Closes #54250
>
> TEST=test/ffi
>
> R=dacoharkes@google.com
> Change-Id: I0e88adfcfe3caef0ad3bb6814ad8f27dce5dc7f4
> CoreLibraryReviewExempt: FFI only
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/346380
> Reviewed-by: Daco Harkes <dacoharkes@google.com>
> Commit-Queue: Martin Kustermann <kustermann@google.com>
> Reviewed-by: Martin Kustermann <kustermann@google.com>
> Auto-Submit: Shikhar <shikharish05@gmail.com>

Change-Id: I1b7a48d14e9b85676a27f76a926e21cac9c76c85
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/347600
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2024-01-22 12:20:48 +00:00
Martin Kustermann 3a314331a7 [dart2wasm] Add support for testing dart2wasm with JSC
JSC only supports `print()` but not `console.log()`.

=> The changes to `printToConsole()` are therefore extended
to check for `console.log()` as well as `print()`.
=> This is extending it to a broader subset of dart2js's print

Change-Id: I7efa697477aa60e473d01716b104fc1526035c67
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/347283
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2024-01-22 12:04:37 +00:00
Shikhar Soni f706ff4ee2 [ffi]: Remove pointer elementAt method.
Closes #54250

TEST=test/ffi

R=dacoharkes@google.com
Change-Id: I0e88adfcfe3caef0ad3bb6814ad8f27dce5dc7f4
CoreLibraryReviewExempt: FFI only
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/346380
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Auto-Submit: Shikhar <shikharish05@gmail.com>
2024-01-22 11:34:18 +00:00
Anna Gringauze 67e052d7e9 [dev_compiler] Fix incorrect debugger information on record types.
Closes: https://github.com/dart-lang/sdk/issues/54609
Change-Id: Ib8a24974ab1a5865d00ee361a151afebdf8a5e65
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/345825
Commit-Queue: Anna Gringauze <annagrin@google.com>
Reviewed-by: Elliott Brooks <elliottbrooks@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
2024-01-19 18:13:39 +00:00
Bernardo Ferrari 4b273b4481 Make sign faster.
Closes https://github.com/dart-lang/sdk/pull/54653

GitOrigin-RevId: af94934e2fb2bac0989742364fd2e33b49398469
Change-Id: I412d48ff24bd80120cf1de4e580b85eeca8e9619
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/346687
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2024-01-17 21:39:34 +00:00
Brian Quinlan b325bc6a43 [doc,io]: Document how errors with File.openRead are exposed
Bug:https://github.com/dart-lang/sdk/issues/53904
Change-Id: Ib457ceb62f6745753e047b5d8160bf6d50fa12cb
CoreLibraryReviewExempt: documentation-only change
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/346586
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Brian Quinlan <bquinlan@google.com>
2024-01-17 18:43:50 +00:00
Tess Strickland 743c0c862c [vm] Revert caching of default type arguments within closure.
Since we already cache instantiation of type argument vectors to avoid
runtime calls as long as the cache has room, remove the default
type arguments field from Closure objects. Instead, just perform any
needed instantiation when the default type arguments are needed
using the instantiator and parent function type arguments stored
in the closure.

Also rename DefaultTypeArgumentsKind to InstantiationMode and
generalize the calculations to determine how to instantiate default
type arguments to an operation that can be performed on type arguments
in general.

TEST=ci

Fixes: https://github.com/dart-lang/sdk/issues/54589
Issue: https://github.com/dart-lang/sdk/issues/54564
Change-Id: I704ea4244fb10cbc08175629c8e92cf05b8aabea
Cq-Include-Trybots: luci.dart.try:vm-aot-linux-release-arm64-try,vm-aot-linux-release-x64-try,vm-aot-tsan-linux-release-x64-try,vm-tsan-linux-release-x64-try,vm-aot-linux-debug-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/346021
Commit-Queue: Tess Strickland <sstrickl@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2024-01-17 14:36:48 +00:00
Tien Do Nam 5ad284b1a4 feat: add missing generic type to Stream.close
Closes https://github.com/dart-lang/sdk/pull/53958

GitOrigin-RevId: d551aad6994bcd8cc4f441818c82d13021d25e81
Change-Id: Ie0cec357ceb243d408eddcface4c919da774ebaf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/334121
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
2024-01-15 17:00:43 +00:00
Nicholas Shahan 4405a98d22 [ddc] Convert to a Dart StackOverflowError
When an error appears to be a stack overflow from JavaScript it will
be converted to a Dart StackOverflowError.

Change-Id: Icbb2b60126002bf7749a400ab008a142eee0f0f5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/343692
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
2024-01-13 00:51:11 +00:00
Devon Carew a246fbb9cb [docs] update dart:html template files
Change-Id: I6084ba14a903945372b67f5e066ed6ed7d4e2969
CoreLibraryReviewExempt: doc only change
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/345741
Commit-Queue: Devon Carew <devoncarew@google.com>
Reviewed-by: Kevin Moore <kevmoo@google.com>
2024-01-12 18:17:13 +00:00
Tess Strickland df72359786 [vm/compiler] Convert _TypedList get and set methods to normal methods.
Previously, they were implemented as native methods with special
replacements in the inliner.

Instead, create force-compiled versions of the original inliner
replacements and use those instead of native methods, unless the
flow graph compiler doesn't support unboxing the requested element type.
In that case, the force-compiled version just calls a native method,
and we only keep the native methods that might be needed (that is,
for double/SIMD element access).

Also, revert the change in 26911a6176, since now the _getX/_setX
methods are appropriately inlined instead of failing to inline due
to being native methods.

TEST=vm/dart/typed_list_index_checkbound_il_test

Cq-Include-Trybots: luci.dart.try:vm-aot-linux-debug-x64-try,vm-aot-linux-release-x64-try,vm-linux-debug-x64-try,vm-aot-linux-release-simarm_x64-try,vm-linux-release-simarm-try,vm-ffi-qemu-linux-release-arm-try
Change-Id: I4840883d1fc12b36a450803da339406bec149044
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/330786
Commit-Queue: Tess Strickland <sstrickl@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2024-01-12 10:29:09 +00:00
Daco Harkes ac5e3d38c3 [vm/ffi] Introduce SizedNativeType
Both `sizeOf` and `AllocatorAlloc.call` use the new type as bound.
This prevents runtime errors on trying to call these two static
methods with unsized native types. All tests testing for these runtime
errors have been deleted.

The `NativeTypes` implementing `SizedNativeType` are as follows:
* The native integer types, `Float`, and `Double`.
* `AbiSpecificInteger` and it's subtypes.
* `Struct` and `Union` and their subtypes. The

The `NativeTypes` not implementing `SizedNativeType` are as follows:
* `Void` has no size.
* `Opaque` and subtypes have unknown size.
* `Handle` is considered opaque. Cannot be used as field in compounds.
* `Array` does not carry a size in its type. Can be used as fields in
  compounds with an annotation specifying the size.
* `NativeFunction` is considered opaque. Would have variable size.
* `VarArgs` is only a marker in function signatures.

`Struct`s and `Union`s can have only `SizedNativeType`s and `Array`s
as fields. Documentation for these is in flux in another CL, so we
should update it there.

This CL also replaces a bunch of `extends NativeType` with
`implements` clauses and made `NativeType` itself `abstract`.

TEST=Dart SDK build
TEST=ffi test suite

Bug: https://github.com/dart-lang/sdk/issues/54542
CoreLibraryReviewExempt: VM and dart2wasm feature only.
Change-Id: Ib4f6b58f7204bd063ace20133162798d8c9483e8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/345221
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2024-01-12 10:13:39 +00:00
Nicholas Shahan 1572bb563f [ddc] Delete typeRep() and legacyTypeRep()
Replaces all uses with the equivalent `TYPE_REF()` and 
`LEGACY_TYPE_REF()` because they are used in the shared dart:_rti 
library and there is no need to support both.

Change-Id: I8c04eb12856cf6933a168f3e63351a45cd5d704e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/344608
Reviewed-by: Mark Zhou <markzipan@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
2024-01-12 00:45:47 +00:00
Nicholas Shahan 1f35476e63 [ddc] Delete compileTimeFlag()
Replaces all uses with the equivalent `JS_GET_FLAG` because it is
used in the shared dart:_rti library and there is no need to support
both.

Change-Id: I4e347d568444caab63e4217845c14353c429cb10
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/344607
Commit-Queue: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Mark Zhou <markzipan@google.com>
2024-01-12 00:12:35 +00:00
Devon Carew 8379b85eab [docs] move several older dart: web libraries into a 'legacy' category
Change-Id: Ie4c3413191c14976f85614fab11ee94830a25aab
CoreLibraryReviewExempt: documentation only change in the web libraries
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/345566
Auto-Submit: Devon Carew <devoncarew@google.com>
Commit-Queue: Devon Carew <devoncarew@google.com>
Reviewed-by: Kevin Moore <kevmoo@google.com>
2024-01-11 18:18:59 +00:00
Aravind 8945d1be75 [io] Changed Minimum Limit for Trimming File or Dir Path in Windows
Closes https://github.com/dart-lang/sdk/pull/54536

GitOrigin-RevId: 9d8b1eafac9a6ff88f5277826dff1e51236b661c
Change-Id: Id65f5778a4173be3d253398c0c030d322c1b42df
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/345201
Reviewed-by: Brian Quinlan <bquinlan@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2024-01-11 10:53:09 +00:00
osama 9329f7bad7 fix tiny typo in lib/io/file.dart
Closes https://github.com/dart-lang/sdk/pull/54562

GitOrigin-RevId: f3b2502c0124f287f3eccc021c5f1623839ae3d7
Change-Id: I6af749c16a5358e910bc883ef1ddfc65c30a0c3c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/345369
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Kevin Moore <kevmoo@google.com>
Reviewed-by: Brian Quinlan <bquinlan@google.com>
Commit-Queue: Brian Quinlan <bquinlan@google.com>
2024-01-10 20:46:38 +00:00
Sergey G. Grekhov 77886bf641 [doc/async] Remove excessive statement from Timer.periodic() documentation
Bug:#54423
Change-Id: I483d51861390cd4c5def02295a976db4363b84bb
CoreLibraryReviewExempt: Documentation-only change
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/342762
Reviewed-by: Lasse Nielsen <lrn@google.com>
Reviewed-by: Alexander Thomas <athom@google.com>
Commit-Queue: Alexander Thomas <athom@google.com>
2024-01-09 09:10:44 +00:00
Tess Strickland 6672353e0f [vm] Fix instantiation of default type args in closure functions.
Previously, the default type arguments for closure functions were
instantiated in the same way as other types of functions, where the
instantiator and function type arguments of the call were used. However,
the defaults for closure functions should be instantiated with the
instantiator and parent function type arguments stored within the
closure itself.

Since the instantiation of the default type arguments only depends on
the instantiator and parent function type arguments, which are shared
between partial instantiations of the same generic closure, the VM
performs this instantiation once at closure creation and caches it in
the closure object, so it can be retrieved when the default type
arguments are needed and copied to new partial instantiations of the
same closure without need for recalculation.

As a side effect, this should speed up dynamic invocation of generic
closures, since the invoke field dispatcher that implements them
previously performed this instantiation when needed on every invocation,
but now it just retrieves the cached version instead.

TEST=language/closure/type_arguments vm/dart/regress_54426

Fixes: https://github.com/dart-lang/sdk/issues/54426
Change-Id: I9baad807befa0323f3c5b66196b9664e4d78af0a
Cq-Include-Trybots: luci.dart.try:vm-aot-linux-release-x64-try,vm-reload-linux-release-x64-try,vm-reload-rollback-linux-release-x64-try,vm-tsan-linux-release-x64-try,vm-aot-tsan-linux-release-x64-try,vm-aot-msan-linux-release-x64-try,vm-msan-linux-release-x64-try,vm-aot-linux-release-arm64-try,vm-aot-dwarf-linux-product-x64-try,vm-aot-mac-product-arm64-try,vm-aot-obfuscate-linux-release-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/344700
Reviewed-by: Daco Harkes <dacoharkes@google.com>
2024-01-08 13:07:16 +00:00
Ömer Sinan Ağacan f23abcd593 [dart2wasm] Implement wrapping awaited values with Future.value
Fixes tests:

- language/async/await_flatten_test
- language/async/await_type_check_test
- language/await_type_test

Change-Id: I42344073864c4927d07b951048a6425fd116a4b6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/344720
Commit-Queue: Ömer Ağacan <omersa@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2024-01-08 12:19:30 +00:00
Parker Lougheed 2da2375bcf [js_runtime/js_dev_runtime] Don't consider running on Windows when compiled for web
This bool is used to check if certain Uri functions should default to Windows behavior on Node. If running on the web, these checks will always be false though, so add a check to enable tree shaking to remove unused Windows functionality.

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

Change-Id: I1ef830f7b14af928a16a875d50cf6ab0db727dfc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/345100
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Mayank Patke <fishythefish@google.com>
Auto-Submit: Parker Lougheed <parlough@gmail.com>
2024-01-05 23:58:56 +00:00
Martin Kustermann cbe0e6443d [dart2wasm] Use [WasmArray]s for type arguments in dynamic calls
This avoids allocating lists in dynamic calls for type
arguments.

So far the closure shape checking functionality also
- as a side-effect of shape checking - added default type arguments
to a growable list. We now cleanly separate the logic to use
default type arguments vs shape checking.

=> Doing so allows removing the remaining usages of [List] in the RTT.
=> Probably also results in smaller & faster dynamic calls.

The list allocation is now pushed to the slow path where we
create [Invocation] object that is then used for NoSuchMethod
handling.

Change-Id: I4823cda0aa9b5f1f137813bc5848c365665da5fd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/344822
Reviewed-by: Ömer Ağacan <omersa@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2024-01-05 15:40:40 +00:00
Martin Kustermann 3343b7a841 [dart2wasm] Use [WasmArray]s for positional/named arguments in dynamic calls
This avoids allocating lists in dynamic calls for positional/named
arguments.

=> Doing so allows removing more usages of [List] in the RTT.
=> Also results in up to 50% faster dynamic calls.
=> Probably also results in smaller code.

The list allocation is now pushed to the slow path where we
create [Invocation] object that is then used for NoSuchMethod
handling.

Change-Id: If578fb044a6cf7f31bd409c177b361181ba68a01
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/344821
Reviewed-by: Ömer Ağacan <omersa@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2024-01-05 15:00:19 +00:00
Daco Harkes d4f8f24dc8 [vm/ffi] Array fixes
`_checkIndex` was returning dynamic.

And it was missing for `PointerArray`.
Bug: https://github.com/dart-lang/sdk/issues/54379

TEST=tests/ffi/inline_array_test.dart

Change-Id: I148545e50463e89fb3a884757ef92444addefc61
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/345000
Reviewed-by: Tess Strickland <sstrickl@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2024-01-05 12:35:49 +00:00
Parker Lougheed f2e2c97600 [dart2wasm] Fix DateTime.timeZoneOffset calculation
This use of JS returns the value with the opposite sign of what it should be (in Dart). This is because Dart uses the difference between local time and UTC, while JS uses the opposite.

Also updates the test for this to also accept the longer style of timezone names as that is what Chrome and d8 on my mac are returning. I'm assuming that's why this wasn't caught earlier.

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

CoreLibraryReviewExempt: Specific to dart2wasm backend
Bug: https://github.com/dart-lang/sdk/issues/54448
Change-Id: I54ab721fa33ef638ccd158d08738ca68273a790b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/343520
Reviewed-by: Ömer Ağacan <omersa@google.com>
Auto-Submit: Parker Lougheed <parlough@gmail.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2024-01-03 08:53:48 +00:00
Daco Harkes 020421df65 [vm/ffi] Add Since annotation to Pointer + and -
To prevent breaking things on older SDKs when users chose to migrate.

CoreLibraryReviewExempt: VM & WASM only. Only adding an annotation.
Bug: https://github.com/dart-lang/sdk/issues/54250
Change-Id: Id026e34e78527117c571aa118445cd73b16f9a9a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/344022
Auto-Submit: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2024-01-03 08:53:07 +00:00
Srujan Gaddam 4804d54792 [dart:js_interop] Add support for dynamically importing modules
Closes https://github.com/dart-lang/sdk/issues/52852

Allows importing of modules using the JS "import()" expression.
The result is a promise that resolves to a module, from which users
can then access exported members from.

CoreLibraryReviewExempt: Backend-specific library.
Change-Id: I4c1caae689be55d1dbb038448e3243bcb80ac8b5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/343683
Commit-Queue: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2024-01-03 01:00:19 +00:00
Srujan Gaddam 3f275d858f [dart:js_interop_unsafe] Add has helper
Shorthand of hasProperty for the common case. Reworded some docs
to be less strict about not using this library (since has and
hasProperty have no good alternatives).

CoreLibraryReviewExempt: Backend-specific library.
Change-Id: I7e82385fd18ff4fbc83266e9b08c9d854ca62a78
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/343681
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2024-01-03 01:00:19 +00:00
Liam Appelbe 55c8bc8377 [ffi] Fix mistake in NativeCallable.isolateLocal documentation.
NativeCallable.isolateLocal *does* keep the isolate alive by default.
This was changed during review of the original CL, but the documentation
wasn't updated.

I've just copied the wording from `NativeCallable.listener` to make them
totally consistent.

Bug: https://github.com/dart-lang/sdk/issues/54294
Fixes: https://github.com/dart-lang/sdk/issues/54294
Change-Id: I2953da648f34b0a3cf1eb0fefb8edb2cccb0bf8d
CoreLibraryReviewExempt: FFI is VM-only
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/343980
Auto-Submit: Liam Appelbe <liama@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2023-12-29 08:44:09 +00:00
Nicholas Shahan 0c4147675f [collection] Update example code in dartdoc
Added 'final' to the example class `EntryItem` that extends
`LinkedListEntry` from 'dart:collection'.

The code as written now produces the error:

```
The type 'EntryItem' must be 'base', 'final' or 'sealed' because the
supertype 'LinkedListEntry' is 'base'.
```

Also applied dartfmt to get new line break locations.

Change-Id: I78e76c7d9d4e6cd29c2e229ab1054efad21c6248
CoreLibraryReviewExempt: Comments only
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/343688
Reviewed-by: Nate Bosch <nbosch@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
2023-12-28 23:37:27 +00:00
Srujan Gaddam 53548c66cb [dart:_js_types] Change representation type of JS functions to JavaScriptFunction
Now that DDC is using the new RTI, we can safely move to
JavaScriptFunction.

Change-Id: I2572667f15bcc53c726eac1a2c297a78792b1a0c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/343642
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
2023-12-26 23:36:48 +00:00
Srujan Gaddam 4fc73d2d52 [dart:js_interop] Add createJSInteropWrapper
This method is the JS typed replacement of createDartExport. Tests
are duplicated to make sure this method is tested as well. We avoid
exposing a JS typed version of createStaticInteropMock as the
signature would not be compatible with @staticInterop classes, and
due to the low usage (there's only 1 result in google3 and 0 in
GitHub afaict), we should wait until we support interop extension
types in this method before exposing it.

CoreLibraryReviewExempt: Backend-specific library.
Change-Id: I1a47e86e33563f740e0813d4657c26d555e57508
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/342520
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
2023-12-25 20:02:49 +00:00
Srujan Gaddam 6fbd07f2b0 [dart:js_interop] Reach (mostly) parity with js_util
https://github.com/dart-lang/sdk/issues/54004

In order to reach parity with js_util, we expose operators
through an extension and do some partial renames in order
to make the member names sound better e.g. `equals` instead
of `equal`. We also expose the following from js_util:

- NullRejectionException

We don't expose `isJavaScriptArray` and `isJavaScriptSimpleObject`
as they can expressed through other forms of interop. There
was an esoteric bug where we needed these members for Firefox
in pkg:test, but the package no longer uses these members, so to
avoid increasing the API space too much, we do not export them.

For the same reason, we also don't expose `objectGetPrototypeOf`,
`objectPrototype`, `objectKeys`.

We don't expose `allowInteropCaptureThis` as it will take some
work to handle this in dart2wasm. That work is tracked in
https://github.com/dart-lang/sdk/issues/54381.

Lastly, `instanceof` and `instanceOfString` is moved to be on
`JSAny?`, as this operator is useful to avoid needing to
downcast to `JSObject` e.g. `any.instanceOfString('Window')`
instead of `any.typeofEquals('object') &&
(any as JSObject).instanceOfString('Window')`.

Extensions are reorganized and renamed to handle these changes.

CoreLibraryReviewExempt: Backend-specific library.
Change-Id: Ib1a7fabc3fa985ef6638620becccd27eeca68c25
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/341140
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2023-12-25 20:02:49 +00:00
Ömer Sinan Ağacan 5410d97493 [dart2wasm] Fix JSArrayImpl.setRange on BigInt arrays
Fixes `setRange` tests reported in #54409.

Change-Id: I04698563f44aa44f634d7c0418f8056d361836a5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/343160
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Ömer Ağacan <omersa@google.com>
2023-12-23 10:21:19 +00:00
Kallen Tu 64584c128a [web] Move Variance to js_shared/lib/ for shared use.
Moving variance to `js_shared/lib/variance.dart` so we can use the same synced indices when marking variance in both dart2js and ddc.

This avoids needing to sync multiple data structures that all represent variance.

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

Change-Id: Ia6fda84decd43374c08ed3bd0d0b240071310d9a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/341840
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
2023-12-22 18:16:01 +00:00
Nicholas Shahan 4bebe882be [ddc] Fix broken named record elements
Some named elements were colliding with existing properties on
record object instances.

Use a symbol in the runtime library for the shape and values
properties.

Ensure that the `.constructor` and `.prototype` getters are renamed
to match the expectation when compiling the access.

Add regression test for all 4 named elements.

Fixes: https://github.com/dart-lang/sdk/issues/54375
Change-Id: I7f3577455bfcff7dece6350e8c7e3ee7ffdbbac6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/342703
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Mark Zhou <markzipan@google.com>
2023-12-21 19:23:04 +00:00
Mayank Patke de871364c3 [dart2js, rti] Add missing cases for record types.
Fixes: #54373
Change-Id: I8acd7363d1b712bb702f044dbd7836f58dcbacaf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/343041
Commit-Queue: Mayank Patke <fishythefish@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
2023-12-20 23:21:33 +00:00
Derek Xu cd5d399e2b Reland "[ DDS ] Fix DDS AOT snapshot build rules"
This is a reland of commit 0a393f1b69

The problem was that the checks for whether or not dartaotruntime
existed were always returning false on Windows because the ".exe" suffix
wasn't being taken into account. Patchset 2 addresses this.

Original change's description:
> [ DDS ] Fix DDS AOT snapshot build rules
>
> dds_aot.dart.snapshot was not being generated for runtime build targets,
> and dds.dart.snapshot was being built regardless of whether or not we
> were building for an IA32 target.
>
> This change also adds a check for IA32 in 'dart run' so the "Could not
> find dds_aot.dart.snapshot. Have you built the full Dart SDK?" message
> isn't printed when we fall back to using dds.dart.snapshot.
>
> This change also reverts 2cc08595a6, which
> failed to fix the issue it was attempting to fix.
>
> TEST=pkg/vm_service tests
>
> Change-Id: Ic990082c25b0d022093ad66600332dfb2878709f
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/341760
> Reviewed-by: Siva Annamalai <asiva@google.com>
> Commit-Queue: Ben Konyi <bkonyi@google.com>

TEST=pkg-win-release-try, pkg-win-release-arm64-try, and pkg/vm_service
tests

Change-Id: Ieab41edcb6bffca3be6bf628e357871f28949323
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/342640
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Derek Xu <derekx@google.com>
2023-12-19 21:17:15 +00:00
Martin Kustermann 338fd6501b [dart2wasm] Make _RecordType use WasmArray<>s instead of List<>s
Change-Id: I063d35209dbd5a66fbcf591ccb6a04d5139afa26
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/341901
Reviewed-by: Ömer Ağacan <omersa@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2023-12-19 07:43:17 +00:00
James Lin 48ac398f11 Fix Directory.current setter compatibility with IOOverrides
The `Directory.current` setter has a `dynamic` parameter so that it
can accept either `String` or `Directory` arguments. (This is
asymmetric with the getter, which always returns a `Directory`.)

The corresponding `IOOverrides` callback, however, assumes that the
argument is always a `String`, and `Directory.current` passed its
`dynamic` argument through unchanged.  Consequently, overriding
the `Directory.current` setter would result in a `TypeError` when
setting `Directory.current` to a `Directory` object.

Changing `IOOverrides.setCurrentDirectory` to use a `dynamic`
parameter would be a breaking change, so instead make the
`Directory.current` setter check the argument's runtime type before
passing it along.

Bug: https://github.com/dart-lang/sdk/issues/52140
Change-Id: I3c5bba6b442b314c798bd7949dfeb5eb6251dc6e
CoreLibraryReviewExempt: No API changes and VM-only.
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/336604
Reviewed-by: Brian Quinlan <bquinlan@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
Auto-Submit: James Lin <jamesdlin@gmail.com>
Commit-Queue: Brian Quinlan <bquinlan@google.com>
2023-12-18 20:23:21 +00:00
Derek Xu ba0835f5e2 Revert "[ DDS ] Fix DDS AOT snapshot build rules"
This reverts commit 0a393f1b69.

Reason for revert: breaks dartdev on Windows

Original change's description:
> [ DDS ] Fix DDS AOT snapshot build rules
>
> dds_aot.dart.snapshot was not being generated for runtime build targets,
> and dds.dart.snapshot was being built regardless of whether or not we
> were building for an IA32 target.
>
> This change also adds a check for IA32 in 'dart run' so the "Could not
> find dds_aot.dart.snapshot. Have you built the full Dart SDK?" message
> isn't printed when we fall back to using dds.dart.snapshot.
>
> This change also reverts 2cc08595a6, which
> failed to fix the issue it was attempting to fix.
>
> TEST=pkg/vm_service tests
>
> Change-Id: Ic990082c25b0d022093ad66600332dfb2878709f
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/341760
> Reviewed-by: Siva Annamalai <asiva@google.com>
> Commit-Queue: Ben Konyi <bkonyi@google.com>

Change-Id: I479a026184fc1fe27926d1ab0d7d3221dec3130e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/342440
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Derek Xu <derekx@google.com>
2023-12-18 17:13:59 +00:00
Ben Konyi 0a393f1b69 [ DDS ] Fix DDS AOT snapshot build rules
dds_aot.dart.snapshot was not being generated for runtime build targets,
and dds.dart.snapshot was being built regardless of whether or not we
were building for an IA32 target.

This change also adds a check for IA32 in 'dart run' so the "Could not
find dds_aot.dart.snapshot. Have you built the full Dart SDK?" message
isn't printed when we fall back to using dds.dart.snapshot.

This change also reverts 2cc08595a6, which
failed to fix the issue it was attempting to fix.

TEST=pkg/vm_service tests

Change-Id: Ic990082c25b0d022093ad66600332dfb2878709f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/341760
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2023-12-15 19:05:59 +00:00
Alexander Markov dcdfcc2b8d Reland "[vm/ffi] Express FFI call closures explicitly in AST"
This reverts commit 1800039c2a.

The changes fd2e9b9f1a and
c20f9eaf6f are relanded as is.

Reason for revert was fixed separately in
https://dart-review.googlesource.com/c/sdk/+/341621

TEST=ci

CoreLibraryReviewExempt: Implementation change only.
Issue: https://github.com/dart-lang/sdk/issues/54172
Issue: https://github.com/dart-lang/sdk/issues/39692
Change-Id: I1a2324768502e5ffbce328127938c0d3c96c38ba
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/341642
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2023-12-15 15:25:29 +00:00
Simon Binder 150e61a662 [vm/ffi] Support @Native fields
Allow annotating top-level or static fields with `@Native` to create
fields backed by native memory.
By using the `_addressOf` operator implemented in the VM, these fields
can be implemented in the CFE by replacing them with accessors looking
up the pointer and then using existing methods to load and store the
value.

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

TEST=tests/ffi/native_assets/asset_*_test.dart
TEST=pkg/analyzer/test/src/diagnostics/ffi_native_test.dart

CoreLibraryReviewExempt: VM & dart2wasm only feature
Change-Id: I61dccc88076723d6a6ba02d7fd848b18e4caf780
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/338020
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2023-12-15 11:20:23 +00:00
Shikhar Soni efb60eac59 [ffi]: Add extension operator methods(+,-) for pointer arithmetic
Closes [#54250](https://github.com/dart-lang/sdk/issues/54250).

TEST=test/ffi

Change-Id: I2299e019b6c0b0db74662e4f9439feac46bc9b40
CoreLibraryReviewExempt: FFI only
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/341420
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
Auto-Submit: Shikhar <shikharish05@gmail.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
2023-12-14 11:42:38 +00:00
Daco Harkes 593a3d3c2c [vm/ffi] Document API handle scopes on Handle
Bug: https://github.com/dart-lang/sdk/issues/54263
CoreLibraryReviewExempt: Doc updated of VM-only feature.
Change-Id: Ie9c643ca6028b86239099932112a88ff59d123df
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/341461
Reviewed-by: Martin Kustermann <kustermann@google.com>
Auto-Submit: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2023-12-14 10:16:30 +00:00
Alexander Markov 1800039c2a Revert "[vm/ffi] Express FFI call closures explicitly in AST"
This reverts commit fd2e9b9f1a.

Revert "[vm/ffi] Cleanup FFI call trampolines"

This reverts commit c20f9eaf6f.

Reason: https://github.com/flutter/flutter/issues/140074
TEST=ci
CoreLibraryReviewExempt: Implementation change only.
Change-Id: Ib193d8f015fc66461fe3cc90550a92e1ba65f236
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/341620
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Auto-Submit: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2023-12-14 01:14:58 +00:00
Nicholas Shahan fbcae44b96 [ddc] Update dynamic NSM errors to match
Makes the error messages consistent between stable and canary mode.

Change-Id: I2e7e0b78e2f81dedd24b6ef7cdd034dfe0c4b6a2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/341390
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
2023-12-14 00:51:50 +00:00
Ömer Sinan Ağacan d794b26a6a [dart2wasm] Simplify bool return types in two imports
JS bool type can be returned as `i32`, which avoids boxing.

Change-Id: I491b1da58a740bd992099fc6ee40eca1f38811c0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/341481
Commit-Queue: Ömer Ağacan <omersa@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2023-12-13 13:12:20 +00:00
Alexander Markov fd2e9b9f1a [vm/ffi] Express FFI call closures explicitly in AST
Instead of implicitly creating closures for FFI
asFunction/lookupFunction APIs in the VM, now they are explicitly expressed in the kernel AST. That makes it possible to analyze
them in TFA.

FFI calls from Dart code into native are now performed in the following way:

```
  block {
    Pointer #ffiTarget0 = target;
    @pragma('vm:ffi:call-closure', _FfiCall<Int32 Function(Int32)>(isLeaf: false))
    #ffiClosure0(int arg1) {
      _nativeEffect(arg1);
      return _ffiCall<int>(#ffiTarget0);
    }
  } =>#ffiClosure0;
```

_ffiCall method is recognized by the VM and its call is replaced
directly with FFI calling sequence. _ffiCall uses closure
parameters implicitly. No extra trampolines are generated for FFI calls.

TEST=existing
Fixes https://github.com/dart-lang/sdk/issues/54172
Issue https://github.com/dart-lang/sdk/issues/39692

CoreLibraryReviewExempt: Implementation change only.
Change-Id: I92b3ff7391470686151ad0807e2cdbbf1a69d256
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/339662
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
2023-12-12 18:34:39 +00:00
Olzhas Suleimen aca875dfea [io] Use _addConnection instead _add in _HttpParser
This is a cleanup and minor performance tweak that should not change any semantics.

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

GitOrigin-RevId: b9a9c6d341eb3e422fc3ec4a008fdbe2b89ade07
Change-Id: Id9f9ef2c1e8f49f5c10cbff5864f020f5e78cfee
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/340200
Commit-Queue: Brian Quinlan <bquinlan@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
Reviewed-by: Brian Quinlan <bquinlan@google.com>
2023-12-12 18:25:19 +00:00
Ryan Macnak 1256db2277 [build] Python 3.12 compatibility.
Bug: https://github.com/dart-lang/sdk/issues/54306
Change-Id: I974e5e70c6c1cbb87343139a26052996d8df858f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/341023
Reviewed-by: Brian Quinlan <bquinlan@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2023-12-12 18:19:35 +00:00
Martin Kustermann bdefe5fa7e Move Wasm{Object,Int,Float}Array -> WasmArray, use extensions on WasmArray for static dispatc0h
The dart2wasm compiler treats wasm arrays of objects/ints/floats pretty
much the same, there's no reason to have complicated class hierarchy and
different kinds of wasm array classes.

Also: We rely on all operations on wasm arrays (and other built-in
types) to be handled on the call site. Wasm arrays are not dart objects,
don't support virtual dispatch. So we make operations operating on the
wasm types extensions.

This also makes now loads and stores into the wasm arrays simple `[]` and
`[]=` operations. We still have special extensions for reading/writing
to integer/double arrays that not only read/write but also
sign-extend/zero-extend and operate on Dart's `int` / `double`.

The compiler will allow `WasmArray<X>(length)` for types `X` that have
default-value in wasm arrays (nullable / integer / double types) and
have another `WasmArray<X>.filled(length, X)` for non-nullable reference
types.

Overall this reduces LOCs and simplifies things

Change-Id: I885bed3dfd1c602dc7b0747c69927d464376383d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/340881
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ömer Ağacan <omersa@google.com>
2023-12-12 17:05:49 +00:00
Sergey G. Grekhov 0334fea865 [doc/async] Change StreamController.broadcast() doc according to the current behavior
Bug: #29403
Change-Id: I9ef53b3c4e039bdc84d4cdfa9e306efb6eb0ffba
CoreLibraryReviewExempt: Documentation-only change
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/340860
Reviewed-by: Lasse Nielsen <lrn@google.com>
Reviewed-by: Alexander Thomas <athom@google.com>
Commit-Queue: Alexander Thomas <athom@google.com>
2023-12-12 13:08:56 +00:00
Sergey G. Grekhov 911f7edc5f [doc/async] Change Stream.asyncMap doc according to the current behavior
Bug: #29615
Change-Id: I74309b9a488999bc73efa4c0a2310261da74c879
CoreLibraryReviewExempt: Documentation-only change
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/340402
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Alexander Thomas <athom@google.com>
Reviewed-by: Alexander Thomas <athom@google.com>
2023-12-12 11:10:55 +00:00
Srujan Gaddam e6a313568c [dart:js_interop] Add generics to JSArray and JSPromise
In order to support this, adds necessary changes to conversion
functions (including cast-lists) and makes JSArrayImpl a generic
type.

CoreLibraryReviewExempt: Backend-specific library changes.
Change-Id: I58bcfb67ef21c90be5e25735757d780aac52dc23
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/337923
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
2023-12-12 04:50:13 +00:00
Brian Quinlan f494e771a2 [doc/io] Add a strong caution against using HttpClient and HttpRequest directly.
CoreLibraryReviewExempt: documentation-only change
Bug:https://github.com/dart-lang/sdk/issues/52023
Change-Id: I9d4b4bde676f2c85acb95e872fdaf7b5a92c6de5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/340283
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Brian Quinlan <bquinlan@google.com>
2023-12-12 00:45:45 +00:00
Martin Kustermann 72f6db9261 Use WasmObjectArray instead of List in RTT metadata
This reduces flute's complex.dart slightly

  complex.wasm 1596131 -> 1563506 (-2%)
  complex.wasm.unopt 3562573 -> 3535797 (-0.7%)

And makes the code probably slightly faster

Change-Id: Id35f2b156d39b6e77b62240a83f78914999bb744
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/340565
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ömer Ağacan <omersa@google.com>
2023-12-11 12:24:04 +00:00
Nate Biggs f057c39255 [dart2js] Add dartDeferredLibraryMultiLoader API to js_helper.
This will allow users who are implementing their own deferred loading mechanism
to batch all the loads for a specific library. Today in order to do batching users have to gather the URIs passed to the `dartDeferedLibraryLoader` hook in a list and schedule (e.g. via setTimeout) a load for some future task.

The need to schedule a task has been shown to cause delays in IPL. But loading each part file individually can also be very expensive. So this allows for a compromise where bundling can be done synchronously per loaded library.

Adds ~8kB to unminified main files and ~2.5kB to minified main files.

Bug: https://github.com/dart-lang/sdk/issues/54202
Change-Id: I623643b03920988cda8b0f8b297944be35ffa606
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/340480
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
2023-12-08 21:10:48 +00:00
Martin Kustermann e0485a4fc0 Make _FunctionType fields use WasmObjectArray instead of List
This reduces flute's complex.dart slightly

  complex.wasm: 1601793  -> 1596131 (-0.35%)
  complex.wasm.unopt: 3570856 -> 3562573 (-0.23%)

And makes the code probably slightly faster

Change-Id: I5b5cb8f95509930ce23c7d4bc0385740ad9f429b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/340562
Reviewed-by: Ömer Ağacan <omersa@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2023-12-08 18:48:00 +00:00
Ömer Sinan Ağacan 7cceaebd49 [dart2wasm] Start using WebAssembly.String imports
Refactor `JSStringImpl` to use the js-string-builtins API[1].

When the module `WebAssembly.String` is not available we define a
"polyfill" with the previous imports, so this change is backwards
compatible.

Also updates some of the methods to use avoid multiple `this.length`
calls (which do an FFI call), and use unchecked getters when possible.

A new library `dart:_error_utils` is introduced for faster range and
index checks when the length (or max value) is known to be positive
(e.g. when it's the length of a string).

For now only `JSStringImpl` and `operator []` and `operator []=` of
`JSArrayImpl` are updated to use the new range and index checks. Rest of
the libraries will be updated separately.

[1]: https://github.com/WebAssembly/js-string-builtins

CoreLibraryReviewExempt: dart2wasm specific library change.
Change-Id: I9436def0cfe59c631f6f4e15ea06cc18a47a738e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/335043
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Ömer Ağacan <omersa@google.com>
2023-12-08 10:04:41 +00:00
Alexander Markov fe2ea6a55f [vm] Add minimal support for mirrors of extension type members
Support extension type members in dart:mirrors similarly to extensions.
Add MethodMirror.isExtensionTypeMember and VariableMirror.isExtensionTypeMember.

TEST=tests/lib/mirrors/method_mirror_extension_test.dart
Fixes https://github.com/dart-lang/sdk/issues/54266

CoreLibraryReviewExempt: VM-only dart:mirrors API change
Change-Id: I9c1c22118ee52e98d5013c881eb6ad5686df656e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/340284
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2023-12-07 21:48:50 +00:00
Parker Lougheed 0cc7b25fbf [sdk] Fix broken markdown in future.dart dartdoc
The unclosed code block isn't useful and causes GitHub to improperly highlight the rest of the file.

CoreLibraryReviewExempt: Just fixing Markdown rendering error. No code change.
Change-Id: I2d1e1fa494deb80caa15f846ded6d822bdaf6e7f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/340360
Reviewed-by: Marya Belanger <mbelanger@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Marya Belanger <mbelanger@google.com>
2023-12-07 17:34:14 +00:00
Aske Simon Christensen e0ccd5341d [dart2wasm] Cache the length of JS typed arrays and ByteData
This improves most benchmarks in the TypedData suite by more than 2x
and TypedDataCopy.ByteSwap by 1.5x.

Change-Id: Icf611471b4edffeedaefe9480a25724ce6571d8a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/340420
Reviewed-by: Ömer Ağacan <omersa@google.com>
Commit-Queue: Aske Simon Christensen <askesc@google.com>
2023-12-07 11:23:28 +00:00
Srujan Gaddam b1a7ca77e0 [dart:js_interop] Move JS types to extension types
- Removes @staticInterop JS types declarations in favor of
typedefs (the function types' reified types and the typed data's
reified types have changed to make the type hierarchy work in the
JS backends).
- Adds extension types to dart:js_interop
- Adds a fromInteropObject helper to JSObject to avoid casting to
an extension type
- Deletes now stale tests
- Refactors some dart2wasm @staticInterop declarations since they
can no longer implement JS types
- Updates extension types tests to use the prefix extension_type
instead of inline_class
- Updates comments

CoreLibraryReviewExempt: Backend-specific library.
Change-Id: Ibe04afac9585ddb99fcf6dbaa7f12050d8b876dc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/332860
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
2023-12-06 21:59:58 +00:00
Aske Simon Christensen d58f1ec00f [dart2wasm] Dispatch type checks to avoid creating runtime type
Change-Id: I4ae9ffa7fa030e0a893178b8061f568e69a7bd79
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/336903
Reviewed-by: Ömer Ağacan <omersa@google.com>
Commit-Queue: Aske Simon Christensen <askesc@google.com>
2023-12-06 10:04:01 +00:00
Simon Binder a44a524bb0 [vm/ffi]: Add Native.addressOf
This adds the `Native.addressOf` function, which takes a constant tear-
off of a method annotated with `@Native` as a parameter and returns a
pointer to the underlying C function.

The CFE will resolve these calls in two steps: First, the existing
transformer for `@Native` methods adds a pragma describing the fully-
resolved native annotation (with the asset id inferred from the library
if not given explicitly). Then, the FFI use sites transformer rewrites
calls to `Native.addressOf` by searching for this pragma on the passed
function and passing the `Native` constants to `Native._addressOf`. The
latter method is implemented in the VM, which can re-use existing parts
already used for `@Native` calls.
An alternative implementation strategy would have been to forward
`addressOf` calls to `Native.ffi_resolver_function` directly without
any special consideration in the VM. However, the chosen approach makes
it easier to support static linking in the future, as this requires
unresolved symbols in the generated assembly.

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

TEST=pkg/vm/testcases/transformations/ffi/ffinative.dart
TEST=tests/ffi/native_assets/asset_*_test.dart
TEST=tests/ffi/vmspecific_static_checks_ffinative_test.dart
TEST=pkg/analyzer/test/src/diagnostics/ffi_native_test.dart

Cq-Include-Trybots: luci.dart.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-optimization-level-linux-release-x64-try,vm-aot-win-debug-arm64-try,vm-aot-win-debug-x64c-try,vm-aot-win-release-x64-try,vm-kernel-precomp-linux-release-x64-try
CoreLibraryReviewExempt: VM & dart2wasm only feature
Change-Id: Ic8e3a390146dffd44c95578f975a4472db79a0ee
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/333920
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-12-05 13:10:36 +00:00
Tess Strickland 7ffb8574ee [vm] Ensure element type is checked for typed data setRange calls.
In c93f924c82, the separate setRange definitions in _TypedIntListMixin,
_TypedDoubleListMixin, _Float32x4ListMixin, _Float64x2ListMixin, and
_Int32x4ListMixin were replaced with a single definition in
_TypedListBase. In doing so, the signature was changed: now the `from`
argument is just an Iterable, instead of the more specific
Iterable<int>/Iterable<double>/etc in the original definitions.

setRange calls two helper methods, _fastSetRange, when from is also a
_TypedListBase whose elements are the same size, and _slowSetRange, for
all other cases.

In _slowSetRange, various casts and checks ensure that the setRange
method was called with a compatible element type, but _fastSetRange only
checks the _size_ of the element type, not the element type itself,
before doing a memory move between the two _TypedListBase objects. That
means via upcasting, elements can be copied from an argument with an
incompatible element type to the receiver, which would have resulted in
a TypeError being thrown before.

Change the unified setRange definition to _setRange and recreate the old
separate setRange definitions with the more specific signatures, with
the separate definitions delegating to _setRange.

TEST=vm/dart/regress_53945

Fixes: https://github.com/dart-lang/sdk/issues/53945
Cq-Include-Trybots: luci.dart.try:vm-aot-linux-debug-x64-try,vm-aot-linux-release-x64-try
Change-Id: If7eef0b2e07c63aaf776de7b26b1c2cc8c57607d
Fixed: 53945
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/334201
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
2023-12-04 16:20:50 +00:00
Ömer Sinan Ağacan fc4b352f2d [dart2wasm] Use unsigned comparison in list bounds checks
In typed data classes we've found that this optimization in bounds
checks can be quite significant. This does the same optimizations in
List classes.

Change-Id: Ia6e80d5aafa621398ed7b7175be8794838e82b89
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/337725
Commit-Queue: Ömer Ağacan <omersa@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2023-12-04 09:58:17 +00:00
Ömer Sinan Ağacan 3f3e4264e2 [dart2wasm] Use browser decoder when possible in non-JSCM mode
- Move `TextDecoder` code to decode JS `Uint8Array`s as UTF-8 to its own
  module `dart:_js_string_convert`.

- Use the module in default mode (non-JSCM) `dart:convert` when decoding
  JS `Uint8Array`s.

Change-Id: I6921b2a99c37ec8920ab79482228ede777bf2b4e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/338520
Commit-Queue: Ömer Ağacan <omersa@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2023-12-01 09:36:41 +00:00
Vyacheslav Egorov 6249b7ed34 [vm/compiler] Clean up typed data stores
Implementation of stores and their inlinings had some
stuff left over their since Dart 1:

* No need to insert null-checks (in sound null-safety mode).
* Since Dart 2 there is no need to insert (speculative)
cid checks. Inputs are guaranteed to be a value of a
supported implementation type. Inserting narrow speculative
checks for Smis is actually leads to worse code in JIT.
* There is no need to convert incomming integer values to
smaller representation - the store will take care of it. This was
left over from Dart 1 times when incomming integer could be _Bigint.

TEST=existing tests

Cq-Include-Trybots: luci.dart.try:vm-aot-linux-release-simarm_x64-try,vm-aot-linux-release-arm64-try,vm-aot-linux-release-x64-try,vm-aot-mac-product-arm64-try,vm-aot-linux-product-x64-try,vm-aot-linux-debug-x64c-try,vm-aot-linux-debug-x64-try,vm-aot-linux-debug-simarm_x64-try,vm-aot-linux-debug-simriscv64-try,vm-aot-android-release-arm_x64-try,vm-aot-android-release-arm64c-try
Change-Id: I72cdaaecc524f1dccc63825df4f7b71241ab47a0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/338600
Commit-Queue: Slava Egorov <vegorov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2023-11-29 09:26:14 +00:00
Ömer Sinan Ağacan f67b219f0f [dart2wasm] Return JS string in StackTrace.current
Avoid copying JS string to Dart.

The test co19/LibTest/convert/Latin1Codec_A01_t01 throws a lot of
exceptions. Before this patch it runs in d8 in 4.1s, after it runs in
1.5s.

Change-Id: I1b9bf06876d63e92c93a03cdbf14587e369978ad
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/338400
Commit-Queue: Ömer Ağacan <omersa@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2023-11-29 08:32:08 +00:00
Ömer Sinan Ağacan 0e0dd31f7e [dart2wasm] Fix stack trace to string conversion on Firefox
Change-Id: I602200cd0b4f0e4836b4ef1dbd6ffbe3953b4849
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/338000
Commit-Queue: Ömer Ağacan <omersa@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
2023-11-27 15:35:27 +00:00
Erik Ernst efe3d00dcd Adjust internal hash_map libraries to match updated UP
SDK issue #54002 is a breaking change request about a change to the
rules about the type function `UP`. This CL serves as a preparation
for landing the tool changes that are the topic of #54002. It changes
a few conditional expressions such that one branch gets an explicit
type based on an `as` expression, which means that the code has the
same semantics as before the change, but now it will compile without
errors both before and after the change in #54002 has been landed.

Change-Id: Iddc99c1c184c1f36744d089c15c5cf29aea699df
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/337780
Commit-Queue: Erik Ernst <eernst@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
2023-11-23 12:34:07 +00:00
Ömer Sinan Ağacan cba120dbac Remove Utf8Decoder._convertIntercepted hook
Fixes #54018.

Tested: existing tests.
Change-Id: I0d0cbc414a239bfc00c023ac8b9313c6f413ba83
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/337540
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Ömer Ağacan <omersa@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
2023-11-23 12:25:26 +00:00
Ömer Sinan Ağacan bf733de31d [dart2wasm] Store the backing array in fixed-size list iterator
Store the Wasm array instead of the List to remove one layer of
indirection when accessing the next element.

We can't do the same in growable list iterator as we need to check
whether the list's length has changed, to be able to throw
`ConcurrentModificationError`.

Change-Id: Iac0fd43dc0c0d249973301903dd34c46fff440f4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/337721
Commit-Queue: Ömer Ağacan <omersa@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
2023-11-23 11:22:20 +00:00
Daco Harkes 47357d8535 Reland "[vm/ffi] Optimize @Native calls"
Original change in patchset 1.

The reland contains a fix for handles. The objects passed in handles
must live on the stack (or in the heap) so that that memory location
can be used as a handle.

This CL introduces a new allocation policy `RequiresRegister` which
forces constants to be spilled to the stack during register
allocation.
Note: Parameters to FfiCall instructions are currently not used in a
way that can make the parameters assigned to registers. So only
constants are treated currently. If we have a way to reproduce params
being assigned to registers, then we can force spilling for
non-consts as well in the register allocator.

Original change's description:
> [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=tests/ffi/vmspecific_ffi_native_handles_test.dart
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
CoreLibraryReviewExempt: Internal FFI implementation changes
Change-Id: Ia1401b335524dcbf50c663a8770d9a02802923df
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-optimization-level-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/+/333841
Reviewed-by: Slava Egorov <vegorov@google.com>
2023-11-22 16:13:42 +00:00
Stephen Adams 3f2432f36c [js_runtime] Utf8 - reuse buffer to avoid creating many small buffers
Allocating typed data on Chrome is surprisingly expensive
(e.g. https://bugs.chromium.org/p/v8/issues/detail?id=9199).  This
makes it worthwhile to keep a buffer around for reuse rather than
allocating a new one for each conversion that requires copying.

Change-Id: I8b2823f487cd8b869fc8b22f309490475c7c010d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/337462
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2023-11-21 22:40:10 +00:00
Ömer Sinan Ağacan 7f5cba2e53 [dart2wasm] Stop using Utf8Decoder._convertIntercepted
Issue: #54018.

Change-Id: Ic8ee663f45acc3ae0300cdd3f1cbb9132110c6f3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/337481
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Commit-Queue: Ömer Ağacan <omersa@google.com>
2023-11-21 11:18:12 +00:00
Ömer Sinan Ağacan dd8952f575 [dart2wasm] Avoid bounds check in some dart:convert functions
Also improves `codeUnitAt` bounds checks by using unsigned comparisons.

`package:characters` benchmarks before:

    Index Iteration: 23316 gc/ms
    String Iteration: 15329 cu/ms
    String Reversing: 6974.1 cu/ms
    String Replacing: 222.88 changes/ms

After:

    Index Iteration: 29729 gc/ms
    String Iteration: 17923 cu/ms
    String Reversing: 7270.9 cu/ms
    String Replacing: 236.28 changes/ms

Change-Id: I36832206b99ba9704e6e5863028d7eaa76412c3f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/337181
Commit-Queue: Ömer Ağacan <omersa@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
2023-11-21 10:51:50 +00:00
Stephen Adams 00dc14d6d6 [js_runtime/js_dev_runtime] Stop using Utf8Decoder._convertIntercepted.
- Share Utf8Decoder patch between DDC and dart2js
- Don't use the `_convertIntercepted` hook
- Provide improved `_Utf8Decoder.{convertSingle,convertChunked}` methods that copy the input if not a Uint8Array, and use a TextDecoder if available

Issue: #54018
Issue: b/308643579

Change-Id: I6a37f77280e4e1a97086874dd3b03f1a20552938
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/335660
Reviewed-by: Ömer Ağacan <omersa@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2023-11-21 00:01:46 +00:00
Daco Harkes df4ef72c01 [vm/ffi] Remove deprecated FfiNative
TEST=pkg/analyzer/test/
TEST=CI build with class removed from `dart:ffi`

Closes: https://github.com/dart-lang/sdk/issues/53923
CoreLibraryReviewExempt: VM & dart2wasm only.
Change-Id: I45a39b623754f9f1b65cac55ea9adae390199f5d
Cq-Include-Trybots: luci.dart.try:vm-ffi-android-debug-arm64c-try,analyzer-analysis-server-linux-try,analyzer-mac-release-try,dart-sdk-linux-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/336960
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2023-11-20 13:16:28 +00:00
Olzhas Suleimen 5918e012cc Fix close drain error callback.
Closes https://github.com/dart-lang/sdk/pull/54020

GitOrigin-RevId: c9791a23035d980665dba73927d2a5bed2be861b
Change-Id: Id70d6d42f2460fa6c853fb334167a67d00f8ef8c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/335506
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2023-11-20 08:03:39 +00:00
Robert Nystrom 2ee771a4f6 Remove the legacy "_2" tests. \o/
I also cleaned up a bunch of places that referred to them.

Change-Id: I45f68818c892f8620ea04257885ffa3763374bb5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/335863
Auto-Submit: Bob Nystrom <rnystrom@google.com>
Commit-Queue: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Alexander Thomas <athom@google.com>
2023-11-17 20:17:23 +00:00
Tess Strickland 904354f108 [vm/compiler] Convert index checks in TypedData methods to CheckBound.
Create a _typedDataIndexCheck abstraction for the conditional throwing
of IndexError in TypedData indexing operations. Recognize that
abstraction in the inliner and replace it with the equivalent CheckBound
instruction.

Do the same for byte offset checking in ByteData operations.

TEST=vm/dart/typed_list_index_checkbound

Change-Id: Ia6c4a3b7ae4667af69aa5bf214d4f187557dac06
Cq-Include-Trybots: luci.dart.try:vm-aot-linux-debug-x64-try,vm-aot-linux-release-x64-try,vm-linux-debug-x64-try,vm-eager-optimization-linux-release-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/330800
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
2023-11-17 15:35:42 +00:00
Lasse R.H. Nielsen a1783a9c34 String.fromCharCodes allows start and end after end of iterable.
The current `String.fromCharCodes` behavior, throwing if `start`
or `end` is larger than the length of the `charCodes` iterable,
is inconsistent with the argument being an `Iterable<int>`,
which the user is not expected to know the length of.

Most other operations that accepts or produces an `Iterable` and
restricts it to a range, will allow the range to exceed the length
of the iterable, acting like `.take(end).skip(start)`, just without
needing to create wrappers that hide the original value.

(`List.setRange` is another exception, and should probably be fixed
by allowing the range to be partially filled, since it's too hard
to change it to require a `List` argument.)

Fixes #50253, #53937

Tested: Added to `corelib/string_fromcharcodes_test.dart`
Bug: https://dartbug.com/53937, https://dartbug.com/50253, https://dartbug.com/23282
Change-Id: Ie19c5fa8e715ea1c58c9c77c247f2a563654c1aa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/333921
Commit-Queue: Lasse Nielsen <lrn@google.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ömer Ağacan <omersa@google.com>
2023-11-17 13:34:22 +00:00
Lasse R.H. Nielsen 5543293a16 Reland "Expire 3.0.0 experiment flags."
This is a reland of commit 6f29e7fce4

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>

TEST=Existing tests covers.
Change-Id: I384e77744c74774a250be413358a7fa176117167
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/332684
Reviewed-by: Alexander Thomas <athom@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
2023-11-17 13:10:01 +00:00
Aske Simon Christensen 4b880aec60 [dart2wasm] Avoid using _Closure as a type
`_Closure` is the implementation class for function objects. When used
as a type, it translated to the same Wasm type as the `Function` type,
but in the type system it missed the special property of `Function`
that it is a supertype of all functions. Instead, it was translated
into an interface type, leading to incorrect type check results.

Thus, we must always use the `Function` type when referring to any
function.

The problem was hidden by the type check specialization for simple
interface type checks and exposed by `--verify-type-checks`.

Change-Id: I384d35506c0c8cd932ba789e977f8257e684b8d7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/336423
Reviewed-by: Ömer Ağacan <omersa@google.com>
Commit-Queue: Aske Simon Christensen <askesc@google.com>
2023-11-16 15:04:58 +00:00
Aske Simon Christensen c605dfc4e8 [dart2wasm] Bypass list indexing checks inside type checks
Apart from improving the performance of type checks, this avoids type
checks inside type checks, which could lead to infinite recursion.

The recursion problem was hidden by the type check specialization for
simple interface type checks and exposed by `--verify-type-checks`.

Change-Id: Icbaebd6d68e6576a784fe3efaee81d4479adba5a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/336422
Reviewed-by: Ömer Ağacan <omersa@google.com>
2023-11-16 15:04:58 +00:00
Aske Simon Christensen 80a69223e0 [dart2wasm] Add option to verify type check implementations
This adds a `--verify-type-checks` option to dart2wasm to instrument
the code such that whenever we are able to generate specialized code
for a type check, we generate both the specialized code and also call
the general fallback path, then compare the results.

This can be used to expose bugs in the type check specializations, or
in the reference implementation, as it may be.

Change-Id: I081540a8eedc7d029b332919283810220b21b3ea
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/336023
Reviewed-by: Ömer Ağacan <omersa@google.com>
2023-11-16 15:04:58 +00:00
Ömer Sinan Ağacan 4c34b6534d [dart2wasm] Fix Float32x4List, Float64x2List, Int32x4List setRange
In the current slow implementation of SIMD lists we can't check for
aliasing (as we don't know the storage type) and can't do `memmove`, so
for now we copy the iterable to a list before setting the elements.

Fixes #52979.

Change-Id: I2ebf69c6e0cef32b762cf9f35534d03fb9918f39
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/336363
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Commit-Queue: Ömer Ağacan <omersa@google.com>
2023-11-16 14:37:48 +00:00
Ömer Sinan Ağacan 817adbc7cc [dart2wasm] Use bitwise-and instead of modulo in typed data ops
Generated code for modulo is not as good as bitwise-and, even after
inlining modulo as we inline truncating division in [12e0690][1].

Bitwise-and saves 0.3% binary space in the TypedData benchmark. It
should also be faster.

[1]: 12e0690dfe

Change-Id: I4ebac592d7c93d0e81e8b28e789f671ce261780a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/336361
Commit-Queue: Ömer Ağacan <omersa@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
2023-11-16 09:00:48 +00:00
Ömer Sinan Ağacan ba596c51a3 [dart2wasm] Simplify native ByteBuffer implmenetation view conversions
After checking alignment of the offset we know that it's aligned (as the
check throws otherwise), so we return the fast view class without
checking the alignment again.

Change-Id: I11e64cf867da8a837e6087ee6548cc509e686ab7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/336360
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Commit-Queue: Ömer Ağacan <omersa@google.com>
2023-11-15 11:41:15 +00:00
Ömer Sinan Ağacan bf587fbb71 [dart2wasm] Use unsigned comparison in native typed array index checks
wasm-opt is not able to do this optimization and using one unsigned
comparison instead of two comparisons saves some binary space and runs
faster.

(JS typed array classes already do this)

Change-Id: Ia51d0d501af9bfd119b53d2373456bd4f0c36f25
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/335825
Commit-Queue: Ömer Ağacan <omersa@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
2023-11-15 10:33:29 +00:00
Brian Quinlan 1b8382b14d Revert "Call the HttpClient constructor when connecting a WebSocket to allow HttpOverrides to work."
This reverts commit 92e7989fbc.

Reason for revert: Causes VmService WebSocket creating to fail because HttpClient is mocked during Flutter Widget tests. See https://github.com/flutter/flutter/issues/138413

Original change's description:
> Call the HttpClient constructor when connecting a WebSocket to allow HttpOverrides to work.
>
> One consequence of this is that there will be one HttpClient per WebSocket connection rather than one for all WebSocket connections. This does *not* affect connection pooling because the sockets are detached from the HttpClient after the WebSocket connection is made.
>
> Closes https://github.com/dart-lang/sdk/pull/52509
>
> GitOrigin-RevId: 28ca642a56e3bbc6112df844b07026b9e0ae8ae6
> Change-Id: I8d9c6f2a883b0f79bafca30abd1dfd98291cf0e0
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/305620
> Reviewed-by: Alexander Aprelev <aam@google.com>
> Commit-Queue: Brian Quinlan <bquinlan@google.com>

Change-Id: Ie1d029e7acf477503cd601f6a03e121cd17d1695
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/336100
Auto-Submit: Brian Quinlan <bquinlan@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Brian Quinlan <bquinlan@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2023-11-14 16:32:50 +00:00
Ömer Sinan Ağacan 932ed2e364 [dart2wasm] Allocate TextDecoder once when decoding UTF-8 to JSStringImpl
Improves a protobuf decoding benchmark from 348ms to 305ms.

Change-Id: Ib47d4271981c16c196594e435c807fecb8fb02f5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/336020
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Commit-Queue: Ömer Ağacan <omersa@google.com>
2023-11-14 11:42:23 +00:00
Ömer Sinan Ağacan 1fccfb8be7 [dart2wasm] Fix JSCM convert patch TextDecoder use
Change-Id: Ib2de3df8495ab16c172a39627c8d79c1c442ef16
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/336000
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Commit-Queue: Ömer Ağacan <omersa@google.com>
2023-11-14 11:12:39 +00:00
Ömer Sinan Ağacan cfccc7c037 [dart2wasm] Update typed list asUnmodifiableView methods
Getting unmodifiable view of a list via `UnmodifiableUint8ListView` (and
other `...ListView` classes) is a bit indirect as the constructor runs a
type test:

  @patch
  class UnmodifiableUint8ListView {
    @patch
    factory UnmodifiableUint8ListView(Uint8List list) {
      if (list is U8List) {
        return UnmodifiableU8List(list);
      } else {
        return UnmodifiableSlowU8List(list);
      }
    }
  }

This updates `asUnmodifiableView` methods to return the right
unmodifiable list type without a type test.

I didn't check if this affects the final optimized code, but it doesn't
hurt to generate good code straight away.

Also removes dart2wasm-specific `immutable` method from `ByteDataBase`
as the new `asUnmodifiableView` does the same thing.

Change-Id: If28ff4e28f059cf915fe1422b6fe61456f9d6b5c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/335464
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Commit-Queue: Ömer Ağacan <omersa@google.com>
2023-11-14 08:37:41 +00:00
Brian Quinlan 2cec317548 Document FileSystemEntity.delete when the type of object on the file system does not match the FileSystemEntity type.
Bug:https://github.com/dart-lang/sdk/issues/53917
Change-Id: I71d95e36c193314afa1872de6e34b1b5a41d7bd9
CoreLibraryReviewExempt: Documentation-only change
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/335328
Commit-Queue: Brian Quinlan <bquinlan@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2023-11-13 20:09:08 +00:00
Brian Quinlan 92e7989fbc Call the HttpClient constructor when connecting a WebSocket to allow HttpOverrides to work.
One consequence of this is that there will be one HttpClient per WebSocket connection rather than one for all WebSocket connections. This does *not* affect connection pooling because the sockets are detached from the HttpClient after the WebSocket connection is made.

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

GitOrigin-RevId: 28ca642a56e3bbc6112df844b07026b9e0ae8ae6
Change-Id: I8d9c6f2a883b0f79bafca30abd1dfd98291cf0e0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/305620
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Brian Quinlan <bquinlan@google.com>
2023-11-13 19:46:09 +00:00
Brian Quinlan a826354365 Document that writeAsBytes truncates values beyond 0..255
Closes https://github.com/dart-lang/sdk/pull/53782

GitOrigin-RevId: 5453268e4ebad23c4085efbab78b53cec551930d
Change-Id: I7804cbe65c93bc34f56db6da7bc68aa1ef4e9303
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/330944
Commit-Queue: Brian Quinlan <bquinlan@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
2023-11-10 23:54:40 +00:00
Ömer Sinan Ağacan a332c17c50 [dart2wasm] Refactor JSCM typed list class hierarchy
- Add mixins to the implementation classes rather than the base classes.
  This makes `this.member` calls in the mixed-in members direct calls
  and allows inlining.

- Make immutable classes subclasses of mutable classes. This makes sure
  we have one `[]` implementation per typed list type and allows
  inlining `[]`.

- Implement specialized iterators for each typed list. This allows
  unboxed and unchecked iteration of array elements.

# Final class hierarchy:

- `final class JSARrayBufferImpl implements ByteBuffer`:
  The JS `ArrayBuffer` class.

- `final class JSDataViewImpl implements ByteData`:
  The JS `DataView` class.

- `abstract class JSArrayBase implements TypedData`:
  Base class for all typed array classes. Implements common operations
  on the the `DataView` `externref`.

## Array classes

- `_IntListMixin`:
  Implements `List<int>` operations. Declares unchecked getters and
  setters and uses them when possible for performance.

- `_UnmodifiableIntListMixin`:
  Overrides only `get buffer`, `[]=`, and `setRange` to convert a
  `List<int>` implemented with `_IntListMixin` to unmodifiable.

- `JSUint8ArrayImpl extends JSArrayBase with _IntListMixin implements Uint8List`:
  The `Uint8Array` class.

- One class as above for `Int8Array`, `Uint16Array` etc.

- `UnmodifiableJSUint8Array extends JSUint8ArrayImpl with _UnmodifiableIntListMixin implements UnmodifiableUint8ListView`:
  Same as `JSUint8ArrayImpl`, but made immutable with
  `_UnmodifiableIntListMixin`.

- One class as above for the rest of the int arrays.

- `double` classes have the same structure as the `int` classes.

## Iterator classes

To allow fast iteration with `get iterator`, each array class has its
own iterator class. Compared to a generic iterator shared by all
classes, these classes (1) do direct (instead of virtual) and unchecked
(instead of bound checked) calls to read the elements (2) avoid boxing
the `current` elements by having a field with the right non-nullable
type, `int` or `double`.

# Benchmarks

In a benchmark that decodes a 1.3M large protobuf:

- Before: 35.9 seconds.
- After: 3.2 seconds.

(Remaining performance issues in this benchmark are in the
`dart:convert` implementation for JSCM, which I will be optimizing
separately)

Change-Id: I5f29882600c1ca95972e2a62af22b181787cb73a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/334465
Commit-Queue: Ömer Ağacan <omersa@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
2023-11-10 16:40:11 +00:00
Ömer Sinan Ağacan 75c975fe6d [dart2wasm] Remove stringref target
stringref target won't be used any time soon (probably ever). To help
with build times and avoid keeping it updated remove it for now.

Change-Id: I0df33b7ab2e19bae5090e8ea32ea6a3dc3751652
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/334881
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Commit-Queue: Ömer Ağacan <omersa@google.com>
2023-11-10 09:49:37 +00:00
Srujan Gaddam c050c8ac22 [dart2wasm] Fix various null toExternRef calls for JS interop
A lot of JS inline function calls were being passed null
instead of nullRef. Extension conversions are changed to better
handle WasmExternRef?s. There were a few spots in the
dart:js_interop_unsafe API surface as well that were not handling
nulls consistently.

CoreLibraryReviewExempt: Doc changes to backend-specific lib.
Change-Id: I08c5020e65156faed3841b0446aafb1e51242342
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/334380
Reviewed-by: Aske Simon Christensen <askesc@google.com>
2023-11-09 21:58:33 +00:00
Ömer Sinan Ağacan f78759775e Reland "[dart2wasm] Use DataView in JS typed arrays"
This is a reland of commit b9b7de14e0

Previous version broke engine tests because of incorrect array impl
class (e.g. `JSUint16ArrayImpl`) to JS array externref conversion. Since
array implementation classes now store an `externref` to a `DataView`,
we can't use `toExternRef`, we need to use the new `toJSArrayExternRef`.

Original change's description:
> [dart2wasm] Use DataView in JS typed arrays
>
> Refcator JS typed array classes to store JS `DataView`s (instead of JS
> typed array with the matching type), and use V8's new optimized
> `DataView` imports.
>
> Brings JS typed array class performance from unusable to reasonable
> levels. In `SkeletalAnimation` benchmark:
>
> - Before: 1444 us.
> - After: 101 us.
>
> Future work:
>
> - Make immutable classes extend the mutable ones. This will allow `[]`
>   calls to be always inlined in JSCM.
>
> - Move list mixin applications from the base class to implementation
>   classes. This will allow members like `elementAt`, `forEach` etc. to
>   have direct calls to other methods of the same class.
>
> - Try adding a `length` field to avoid JS calls in bounds checks.
>
> Change-Id: Ief6165fe9c4a825072077db820b105c4fca30dce
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/328920
> Reviewed-by: Aske Simon Christensen <askesc@google.com>
> Commit-Queue: Ömer Ağacan <omersa@google.com>

Change-Id: If913aed837d09570b82b0f6dcb9553abb17fd708
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/334468
Commit-Queue: Ömer Ağacan <omersa@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
2023-11-09 10:23:31 +00:00
Siva Annamalai e64dd81a4a Revert "[dart2wasm] Use DataView in JS typed arrays"
This reverts commit b9b7de14e0.

Reason for revert: Dart to Engine rolls are failing, please see
https://github.com/flutter/engine/runs/18494538711

Original change's description:
> [dart2wasm] Use DataView in JS typed arrays
>
> Refcator JS typed array classes to store JS `DataView`s (instead of JS
> typed array with the matching type), and use V8's new optimized
> `DataView` imports.
>
> Brings JS typed array class performance from unusable to reasonable
> levels. In `SkeletalAnimation` benchmark:
>
> - Before: 1444 us.
> - After: 101 us.
>
> Future work:
>
> - Make immutable classes extend the mutable ones. This will allow `[]`
>   calls to be always inlined in JSCM.
>
> - Move list mixin applications from the base class to implementation
>   classes. This will allow members like `elementAt`, `forEach` etc. to
>   have direct calls to other methods of the same class.
>
> - Try adding a `length` field to avoid JS calls in bounds checks.
>
> Change-Id: Ief6165fe9c4a825072077db820b105c4fca30dce
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/328920
> Reviewed-by: Aske Simon Christensen <askesc@google.com>
> Commit-Queue: Ömer Ağacan <omersa@google.com>

Change-Id: Iba46cfc409805bcd6f86bcc52a06ed8d54eea671
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/335026
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
2023-11-08 22:44:18 +00:00
Ömer Sinan Ağacan b9b7de14e0 [dart2wasm] Use DataView in JS typed arrays
Refcator JS typed array classes to store JS `DataView`s (instead of JS
typed array with the matching type), and use V8's new optimized
`DataView` imports.

Brings JS typed array class performance from unusable to reasonable
levels. In `SkeletalAnimation` benchmark:

- Before: 1444 us.
- After: 101 us.

Future work:

- Make immutable classes extend the mutable ones. This will allow `[]`
  calls to be always inlined in JSCM.

- Move list mixin applications from the base class to implementation
  classes. This will allow members like `elementAt`, `forEach` etc. to
  have direct calls to other methods of the same class.

- Try adding a `length` field to avoid JS calls in bounds checks.

Change-Id: Ief6165fe9c4a825072077db820b105c4fca30dce
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/328920
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Commit-Queue: Ömer Ağacan <omersa@google.com>
2023-11-08 13:48:59 +00:00
Nate Bosch 0801939ef4 Mention detached processes in exitCode doc
In response to #35874

The class level doc mentions the restriction that `exitCode` is
unavailable for detached processes. Repeat this in the doc for that
member since it is the API where it is the most relevant.

Change-Id: I14ca7bd32614b1d1c1ae4a7d96d87428215d3dd7
CoreLibraryReviewExempt: Doc change.
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/334360
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Nate Bosch <nbosch@google.com>
Reviewed-by: Brian Quinlan <bquinlan@google.com>
Auto-Submit: Nate Bosch <nbosch@google.com>
2023-11-07 21:56:55 +00:00
Nicholas Shahan dae322d5b1 [ddc] Fix custom formatters with new type system
Change-Id: I164e837a65cc90195836126b1c90162a99e0546d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/334007
Reviewed-by: Anna Gringauze <annagrin@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
2023-11-07 00:57:01 +00:00
Nicholas Shahan 2ef46a1fff [ddc] Fix custom formatter for classes
Classes were mistakenly being formatted by the function formatter.

Change-Id: I6c513803c7c211f02bb9267914b5988cd6c02c5e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/334005
Commit-Queue: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2023-11-07 00:48:58 +00:00
Nicholas Shahan 406e92dba6 [ddc] Remove implements text from custom formatter
Change-Id: I814dfc5b80ae3d59ad3ad53d22c4d40866c6d926
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/334004
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
2023-11-07 00:38:34 +00:00
Stephen Adams 048c7b036b [js_runtime] Polyfill WeakReference and Finalizer for ancient browsers
Dart does not officially support browsers before the introduction of WeakRef and FinalizationRegistry but there are users of Dart that have a few customers still using these browsers.

As a result, both ACX and Flutter have ad-hoc polyfills for these classes. Adding the polyfill in js_runtime will allow the other polyfills to be removed. The polyfill is as small as possible (omitting checks, avoiding extra Dart classes, detecting as late as possible), so it should be a net code size improvement of a few bytes for ACX and Flutter use cases.

The polyfill leaks memory by retaining the weak reference target and never calls the finalization callbacks. This is permitted behaviour.

Change-Id: I4f0d08ee6322dab26728d95ca8c24a7fd59b3314
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/333304
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2023-11-03 22:15:38 +00:00
Brian Quinlan 258863c6d1 Fix a bug where proxy usernames/passwords containing @ were not correctly parsed.
Bug:https://github.com/dart-lang/sdk/issues/53157
Change-Id: I068fd770dac7f0f762cefbe8ca158fee8ba882fb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/333901
Commit-Queue: Brian Quinlan <bquinlan@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2023-11-03 19:48:42 +00:00
Martin Kustermann 96921245f9 Revert "[vm/ffi] Optimize @Native calls"
This reverts commit e16bb210d2.

Reason for revert: Indication this caused engine test
failures of the kind:
```
[ RUN      ] EmbedderA11yTest.A11yTreeIsConsistentUsingV1Callbacks
../../flutter/shell/platform/embedder/tests/embedder_a11y_unittests.cc:639: Failure
Expected equality of these values:
  std::strncmp(kTooltip, node->tooltip, sizeof(kTooltip) - 1)
    Which is: 116
  0
```

Original change's description:
> [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>

Change-Id: Icc87a6ca33bffecabb15c6b168a06ccc38c2fe5b
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
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/333840
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2023-11-03 09:04:24 +00:00
Mayank Patke 7a343d0cc1 [rti] Codegen improvements in isSubtype.
Change-Id: If68a3c150b33e2029d7e6538cb3efff23bb9809f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/333701
Commit-Queue: Mayank Patke <fishythefish@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
2023-11-02 21:37:38 +00:00
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
Ömer Sinan Ağacan d0a2656611 [dart2wasm] Use the same Dart object when to{Upper,Lower}Case returns the argument
This fixes `identical` checks when the input doesn't need case mapping.

This change was originally made in [1], but I'm trying to split it into
smaller CLs as it currently has a lot of conflicts with the main branch.

[1]: https://dart-review.googlesource.com/c/sdk/+/316628

Change-Id: I88da52a3a73c9d587acefe2b14fd39edaf01c966
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/332200
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Commit-Queue: Ömer Ağacan <omersa@google.com>
2023-11-02 12:21:24 +00:00
Ömer Sinan Ağacan 9ed368c2e1 [dart2wasm] Use only JS strings in JSCM
Refactor libraries so that JSCM will only use `JSStringImpl` class for
strings.

The goal is to disentangle the native string classes and `JSStringImpl`
and start testing `JSStringImpl` in isolation.

Changes:

- `dart:_string` is no longer available in JSCM.

- Make `int.toString` external to allow patching it differently in JSCM
  and normal modes.

  `toString` implementations are in `boxed_int_to_string.dart` patch
  files.

- `int.parse` now uses JS `parseInt`. However `parseInt` is not
  compatible with Dart's `int.parse` so this will cause some more test
  failures in JSCM for now.

- Any dependencies to `dart:_string` from JSCM `dart:convert` are
  removed. The library implementation now uses JS `TextDecoder` for
  UTF-8 decoding.

  Note: `TextDecoder` is not available on d8, so text decoding tests
  will fail on d8.

  JSON encoding and decoding in `dart:convert` will be updated in a
  follow-up CL.

- Compiler (translator, constant generator, code generator etc.) is
  updated to allocate the `JSStringImpl`s in JSCM.

Initially this will make some JSCM test fail as `int` parsing is not
quite right, those will be fixed in follow-up CLs.

Co-authored-by: Joshua Litt <joshualitt@google.com>
Change-Id: I366e06f44cdc369d28fe47b24015234260304399
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/332680
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Commit-Queue: Ömer Ağacan <omersa@google.com>
2023-10-31 12:58:26 +00:00
Daco Harkes acad65713c [vm] Mark NativeFieldWrapperClasses as base
TEST=build SDK (modified patch files)
TEST=tests/ffi/*
TEST=runtime/vm/*_test.cc
TEST=runtime/tests/vm/dart/*

Closes: https://github.com/dart-lang/sdk/issues/51896
CoreLibraryReviewExempt: VM only.
Change-Id: I349849001adf8f3a62f3d4f94d4bdd295c36ef4d
Cq-Include-Trybots: luci.dart.try:flutter-linux-try,vm-aot-linux-debug-x64c-try,vm-ffi-android-debug-arm-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/291761
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2023-10-31 10:23:12 +00:00
Brian Quinlan 942e897bf5 [doc/io] Add a RawSocketEvent example.
Bug: https://github.com/dart-lang/sdk/issues/33721
Change-Id: I4e8f35cec8d3e689469a63826d118cfa2fe42218
CoreLibraryReviewExempt: Documentation-only change
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/277701
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Brian Quinlan <bquinlan@google.com>
2023-10-30 16:53:17 +00:00
Ilya Yanok 8c55f3eb0b Revert "[analyzer] simplify the libraries.dart file"
This reverts commit 29979649bd.

Reason for revert: makes `promiseToFuture` not exported from `dart:html`, see b/295129286

Original change's description:
> [analyzer] simplify the libraries.dart file
>
> Cleanup and re-landing of https://dart-review.googlesource.com/c/sdk/+/317803.
>
> Change-Id: I9fd679fdb111895ce662ecbe6d0fc5844909c3bc
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/332441
> Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
> Commit-Queue: Devon Carew <devoncarew@google.com>

Change-Id: Id93b4a1d4bdea706ae10cfb089319514a0238a7d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/332683
Reviewed-by: Alexander Thomas <athom@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Ilya Yanok <yanok@google.com>
2023-10-30 11:22:27 +00:00
Johnni Winther f900eb95b7 Enable extension types in package:web and dart:js_interop
This uses the allowed_experiments.json to opt package:web and
dart:js_interop in to the inline-class experiment (the extension
types feature) for early access and development.

Change-Id: Ieb828b654f2320b147a3c48bbb4a142da1c18380
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/332421
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Reviewed-by: William Hesse <whesse@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2023-10-30 10:58:45 +00:00
Brian Quinlan c31b4c0ef5 [doc/io] Minor Link.create documentation fixes.
Change-Id: I50932e9cd0c26b2070dd2930866f3fb18bc80763
CoreLibraryReviewExempt: documentation-only change
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/332483
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Brian Quinlan <bquinlan@google.com>
2023-10-27 17:25:40 +00:00
Stephen Adams c87fec8663 Revert "[typed_data] Deprecate unmodifiable views"
This reverts commit b4bae467d4.

Reason for revert: Flutter plugin contains use of deprecated method.

Original change's description:
> [typed_data] Deprecate unmodifiable views
>
> CoreLibraryReviewExempt: Reviewed in https://dart-review.googlesource.com/c/sdk/+/321922
> Bug: #53785
> Change-Id: I23a064e76a4b359e804f41676b3b775dd02ea183
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/331723
> Commit-Queue: Stephen Adams <sra@google.com>
> Reviewed-by: Lasse Nielsen <lrn@google.com>

Bug: #53785
Change-Id: I01998a3d74681ef2d8c804f59a82d51a2e4290e7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/332580
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Reviewed-by: William Hesse <whesse@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2023-10-27 15:22:54 +00:00
Devon Carew 29979649bd [analyzer] simplify the libraries.dart file
Cleanup and re-landing of https://dart-review.googlesource.com/c/sdk/+/317803.

Change-Id: I9fd679fdb111895ce662ecbe6d0fc5844909c3bc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/332441
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Devon Carew <devoncarew@google.com>
2023-10-26 21:43:31 +00:00
Brian Quinlan 097c84f11b [io/doc/test] Modify the Windows symlink resolution behavior so that resolving a link that points to a non-existent file results in a type of notFound, which is consistent with all other platforms.
Bug:https://github.com/dart-lang/sdk/issues/53684
Change-Id: I1b594e1a85906d1f510358eec71792ea15ab801b
CoreLibraryReviewExempt: VM- and doc-only
Tested: unit tests
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/331841
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Brian Quinlan <bquinlan@google.com>
2023-10-25 23:14:38 +00:00
Stephen Adams b4bae467d4 [typed_data] Deprecate unmodifiable views
CoreLibraryReviewExempt: Reviewed in https://dart-review.googlesource.com/c/sdk/+/321922
Bug: #53785
Change-Id: I23a064e76a4b359e804f41676b3b775dd02ea183
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/331723
Commit-Queue: Stephen Adams <sra@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
2023-10-25 19:14:06 +00:00
sgrekhov 79d359ed45 [io/doc] Fix typo in File.createSync() documentation
Change-Id: Id077d3c56b6e9835821cf9d4463df34c626ffb32
CoreLibraryReviewExempt: documentation update
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/331920
Reviewed-by: Brian Quinlan <bquinlan@google.com>
Commit-Queue: Brian Quinlan <bquinlan@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2023-10-25 19:11:30 +00:00
Nate Bosch 7ba47c6040 Remove some now unnecessary casts
Flow analysis has improved and issue #40041 is resolved. These
`FutureOr<T>` conditionals are promoting to `Future<T>` or `T` and no
longer need an explicit cast.

R=lrn@google.com

Change-Id: I925db6d7f52aad54c88434ff02e1d0ae4e72278b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/331206
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Ömer Ağacan <omersa@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Auto-Submit: Nate Bosch <nbosch@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ömer Ağacan <omersa@google.com>
2023-10-24 19:09:22 +00:00
Ömer Sinan Ağacan 1b426ea6f8 [dart2wasm] Fix string array copy in UTF8 decoder
Bug introduced with [1] and broke the Flutter engine [2].

[1]: https://dart-review.googlesource.com/c/sdk/+/331187
[2]: https://github.com/flutter/flutter/issues/137120

Change-Id: I334db1bbf1440b53b7a7856f16a0e116d82efae5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/331922
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Ömer Ağacan <omersa@google.com>
2023-10-24 12:02:48 +00:00
Brian Quinlan 4122919684 Remove documentation that indicates that the maximum received datagram size is 64K.
Bug:https://github.com/dart-lang/sdk/issues/31733
CoreLibraryReviewExempt:documentation-only
Change-Id: Icde611deb9a0172a5caacf518e9ce01904baf8ad
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/331422
Commit-Queue: Brian Quinlan <bquinlan@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2023-10-23 19:37:40 +00:00
Sergey G. Grekhov 09fc3f9554 [io/doc] Improve Link.createSync() documentation
Change-Id: I70c593ca2b7f9ba6b7cc94886f622f4af5dd20fd
CoreLibraryReviewExempt: documentation update
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/330620
Reviewed-by: Brian Quinlan <bquinlan@google.com>
Commit-Queue: Alexander Thomas <athom@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2023-10-23 19:15:57 +00:00
Ömer Sinan Ağacan 405a03909c [dart2wasm] Optimize UTF8 decoder when decoding a native array
Intercept all `Utf8Decoder.convert` calls to check the input type and
call the right UTF8 decoder function.

This currently only optimizes `U8List` parsing, and only the fastest
path where the input is an ASCII string. Follow-up CLs will optimize JS
typed array parsing by calling browser's UTF8 decoder and the slow paths
of non-ASCII and malformed buffers.

Results from an internal benchmark extracted from a real use case:

Before:

    Parse(RunTime):     330,500 us.

After:

    Parse(RunTime):     90,310 us.  (-72%)

dart2js -O4 results of the same benchmark:

    Parse(RunTime):     234,250 us.

Change-Id: I470697a9eb516e1e031e9b865ddb29e8f25569bf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/331187
Commit-Queue: Ömer Ağacan <omersa@google.com>
Reviewed-by: Jackson Gardner <jacksongardner@google.com>
2023-10-23 18:36:52 +00:00
Stephen Adams 0a436b7005 Reapply "[typed_data] Deprecate UnmodifiableUint8ListView and friends"
This reverts commit 4918d3ef8c.

`@Deprecated` annotations have been commented out.

CoreLibraryReviewExempt: reviewed as https://dart-review.googlesource.com/c/sdk/+/321922
TEST=ci
Bug: #53785
Change-Id: I3239251c2aba5f188aa947f0ff0208271d6be5cc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/331741
Commit-Queue: Stephen Adams <sra@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
Reviewed-by: Derek Xu <derekx@google.com>
2023-10-23 18:14:33 +00:00
Ömer Sinan Ağacan fa7c42a84d [dart2wasm] Small optimizations and simplifications in string and convert patches
Change-Id: I3838f052cff13734cd5612785a5724454231be8b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/331183
Reviewed-by: Jackson Gardner <jacksongardner@google.com>
Commit-Queue: Ömer Ağacan <omersa@google.com>
2023-10-23 18:08:22 +00:00
Derek Xu 4918d3ef8c Revert "[typed_data] Deprecate UnmodifiableUint8ListView and friends"
This reverts commit b657773d58.

Reason for revert: blocking Dart SDK -> Engine roll (https://github.com/flutter/flutter/issues/137054)

Original change's description:
> [typed_data] Deprecate UnmodifiableUint8ListView and friends
>
> This is the first of several steps to remove the unmodifiable views for typed data classes. The end goal is that dart2js has only one class implementing `Uint8List` so that `Uint8List` accesses can always be compiled down to JavaScript code that directly uses indexed property accesses (`a[i]`).
>
> This first step deprecates the unmodifiable view classes to help prevent their use in new code, and adds `asUnmodifiableView()` methods as a replacement for the small number of places that use the classes.
>
> The next steps (see #53785) are to remove uses of the unmodifiable view classes from the SDK. Once this is complete the classes themselves can be removed.
>
> TEST=ci
>
> Issue: #53218
> Issue: #53785
>
> Change-Id: I04d4feb0d9f1619e6eee65236e559f5e6adf2661
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/321922
> Reviewed-by: Nicholas Shahan <nshahan@google.com>
> Reviewed-by: Lasse Nielsen <lrn@google.com>
> Commit-Queue: Stephen Adams <sra@google.com>
> Reviewed-by: Alexander Markov <alexmarkov@google.com>
> Reviewed-by: Martin Kustermann <kustermann@google.com>
> Reviewed-by: Ömer Ağacan <omersa@google.com>

Issue: #53218
Issue: #53785
Change-Id: I0bb042269f9ff8e5cd69619cf97b60c79ea98cbf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/331680
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Derek Xu <derekx@google.com>
2023-10-23 15:03:25 +00:00
Stephen Adams b657773d58 [typed_data] Deprecate UnmodifiableUint8ListView and friends
This is the first of several steps to remove the unmodifiable views for typed data classes. The end goal is that dart2js has only one class implementing `Uint8List` so that `Uint8List` accesses can always be compiled down to JavaScript code that directly uses indexed property accesses (`a[i]`).

This first step deprecates the unmodifiable view classes to help prevent their use in new code, and adds `asUnmodifiableView()` methods as a replacement for the small number of places that use the classes.

The next steps (see #53785) are to remove uses of the unmodifiable view classes from the SDK. Once this is complete the classes themselves can be removed.

TEST=ci

Issue: #53218
Issue: #53785

Change-Id: I04d4feb0d9f1619e6eee65236e559f5e6adf2661
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/321922
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ömer Ağacan <omersa@google.com>
2023-10-20 17:14:48 +00:00
Lasse R.H. Nielsen 0234a8f17f Fix bad link in updated docs.
CoreLibraryReviewExempt: Comment only.
Change-Id: Ibaec3812e430ba0c8644315fba062bca62f3c173
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/331241
Auto-Submit: Lasse Nielsen <lrn@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
Reviewed-by: Alexander Thomas <athom@google.com>
2023-10-20 14:47:26 +00:00
Lasse R.H. Nielsen 0ecb9ba545 Update documentation on fromEnvironment constructors.
CoreLibraryReviewExempt: Comments only.
Change-Id: If2e080764bc98ee6cb7fe31dffe12c66144c7352
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/331182
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2023-10-20 07:57:18 +00:00