Commit graph

11604 commits

Author SHA1 Message Date
Nicholas Shahan 3c13e9f273 [ddc] Cleanup dead code from the runtime library
This code is no longer used now that the new runtime types are always
enabled.

Change-Id: I0c7d627199a10e023d5d1afa581812b360e9a0f0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/344609
Reviewed-by: Mark Zhou <markzipan@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
2024-02-16 22:33:54 +00:00
Brian Quinlan 770f44d4e9 [io] Make it possible to change the line ending output by stdout and stderr.
There is a performance impact in:
`stdout.lineTerminator = "\r\n";`

For small writes (<100 chars), the performance loss is lost in the noise of the `write` system call.

For writes of ~500 chars, the performance is about half of that without line terminator translation. But, on a M2 Mac laptop, ~80M characters can be written per second.

Bug: https://github.com/dart-lang/sdk/issues/53161
Change-Id: Icfa0f981dcf6edb856d8aac5e0e270bc0148d498
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/326761
Reviewed-by: Siva Annamalai <asiva@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Ömer Ağacan <omersa@google.com>
Reviewed-by: Brian Quinlan <bquinlan@google.com>
Commit-Queue: Brian Quinlan <bquinlan@google.com>
2024-02-16 20:06:03 +00:00
Vyacheslav Egorov 2280b06202 [vm] Improve detection of handled async errors
Improve the handling of code where the async flow forks:
e.g. for `fut.whenComplete(c.complete)` we might proceed
unwinding through awaiters of `c.future` and forget about the
future returned from `whenComplete`. This happens because
we choose to present result of the unwinding as a single
stack and not a tree. In this situation the error will only
propagate into that future and whether or not the error will be
handled depends on that future alone.

As part of this change also start respecting ignored bit on
futures without listeners.

TEST=pkg/vm_service/test/pause_on_unhandled_async_exceptions7_test.dart

CoreLibraryReviewExempt: Comment only changes to core library
Change-Id: I27b689ab07a725e8faa8d91cf40e88ebc8c441a0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/352904
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2024-02-16 12:55:22 +00:00
Vyacheslav Egorov df6fd34f75 [vm] Improve asynchronous unwinding through Stream methods
This CL adds @pragma('vm:awaiter-link') in various places in
Stream implementation to facilitate unwinding and expands
async unwinding logic with more information about
Stream internals.

At the same time be more conservative when checking if an
exception thrown from async method handled: failing to unwind
the stack fully creates situations when we incorrectly report
caught exceptions as uncaught, which frustrates users.

To distinguish stream subscriptions with and without error
handlers we add a state bit. Otherwise, it looks like all
subscriptions have error handlers because if no error
handler is installed we eagerly install error handler forwarding
the error to `Zone.handleUncaughtError`.

Fixes https://github.com/dart-lang/sdk/issues/53334
Fixes https://github.com/dart-lang/sdk/issues/54788
Fixes https://github.com/dart-lang/sdk/issues/47985

TEST=runtime/vm/dart/awaiter_stacks/stream_methods_test.dart,pkg/vm_service/test/pause_on_unhandled_async_exceptions6_test.dart,pkg/vm_service/test/pause_on_unhandled_async_exceptions7_test.dart

CoreLibraryReviewExempt: No behavioral change. Async changes reviewed by lrhn@
Cq-Include-Trybots: luci.dart.try:vm-aot-android-release-arm64c-try,vm-aot-android-release-arm_x64-try,vm-aot-dwarf-linux-product-x64-try,vm-aot-obfuscate-linux-release-x64-try,vm-aot-optimization-level-linux-release-x64-try
Change-Id: Ic51f926867092dd0adbe801b753f57c357c7ace2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/322720
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2024-02-15 23:00:44 +00:00
Derek Xu 628d744391 [dart:developer][VM/Service] Add APIs to dart:developer for recording HTTP profiling information, and for later retrieving that information
The APIs mentioned above are `addHttpClientProfilingData` and
`getHttpClientProfilingData`.

This CL also makes it so that profiling information recorded using
`addHttpClientProfilingData` is included in dart:io service extension
responses.

TEST= pkg/vm_service/test/get_http_profile_test.dart

Change-Id: I892a7a8485369bb92cbb0c086b93498bcec25d5f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/341440
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Derek Xu <derekx@google.com>
Reviewed-by: Ömer Ağacan <omersa@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
Reviewed-by: Leaf Petersen <leafp@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2024-02-15 18:56:08 +00:00
Nicholas Shahan f6ffe00f28 [ddc] Avoid calling addTypeCaches with new types
Some preparation for deleting all the old type system code.

Change-Id: I9319064100ce19a4122612c36781c7e4a71094aa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/352724
Reviewed-by: Mark Zhou <markzipan@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
2024-02-15 18:28:49 +00:00
Kenzie Schmoll 0cb3fcca48 [developer] Update dart doc for Service.getIsolateId
Change-Id: I487bdd22362c73051d62147bacb5fe35c3f0445b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/352500
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Kenzie Davisson <kenzieschmoll@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Leaf Petersen <leafp@google.com>
Reviewed-by: Ömer Ağacan <omersa@google.com>
2024-02-15 17:48:00 +00:00
Ömer Sinan Ağacan 2bdcfb7035 [dart2wasm] Fix instantiation closure equality
We can't generate a virtual call to `Object.==` in generated code as
`Object.==` may not be added to the dispatch table, even with
`@pragma(wasm:entry-point)`.

Instead this adds a top-level `_runtimeTypeEquals` function that calls
`==` on the `_Type` argument. Effectively this forces adding `_Type.==`
to the dispatch table and calls it virtually.

Fixes #54926.

Change-Id: Ice3306ed00f66c8abedb3ef11b58c15296457eb0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/352900
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Ömer Ağacan <omersa@google.com>
2024-02-15 17:33:01 +00:00
Parker Lougheed b55ecc907e [sdk/lib] Update SystemHash.smear for improved parameters
The linked README(https://github.com/skeeto/hash-prospector#two-round-functions) has been updated with these parameters that result in a significantly lower bias that other projects have also began adapting.

For context, this function is used internally by `Object.hashAllUnordered`.

Change-Id: I7ca042196bbfdb5abdb28f8d6d9cbca69d21fb2b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/351920
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
Auto-Submit: Parker Lougheed <parlough@gmail.com>
Reviewed-by: Ömer Ağacan <omersa@google.com>
2024-02-15 15:06:58 +00:00
Liam Appelbe c3a626f729 [lib] Private API for disabling Isolate.exit().
This is needed to prevent users from closing the platform isolate.

Bug: https://github.com/flutter/flutter/issues/136314
Change-Id: I98ab0a847dad245a1f1d6c16e96f2f4add39a84f
TEST=runtime/vm/isolate_test.cc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/352760
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Liam Appelbe <liama@google.com>
2024-02-15 01:18:40 +00:00
Parker Lougheed 885126e51b [sdk/math] Mark Point, Rectangle, and MutableRectangle as legacy
These can't be deprecated for a while, at least not until 'dart:html' itself is.

In the mean time, we can at least discourage usage of it and direct developers to more appropriate, long-term solutions.

Contributes to https://github.com/dart-lang/sdk/issues/54852

CoreLibraryReviewExempt: Documentation only change that directs developers to more specific, performant, or flexible solutions.
Change-Id: I9d099a49909673f8af23eab480fdd225e56bcab2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/351961
Reviewed-by: Nate Bosch <nbosch@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
2024-02-14 18:35:17 +00:00
Martin Kustermann 5d664b4bd4 [dart2wasm] Avoid using allowInterop in Promise<->Future conversion
The dart closures for the then/onError callbacks we use on a JS promise
will not flow back into dart. There's therefore no reason to use the
very heavyweight `allowInterop` mechanism.

This makes (after [0]) asynchronous calls to JS from Dart more than 2x
as fast.

This also aligns the `promiseToFuture` implementation with the extension on
`JSPromise` (see sdk/lib/_internal/wasm/lib/js_interop_patch.dart)
modulo the fact that the API doesn't work on interop types but Dart
types and needs therefore the full JS<->Dart conversion.

=> Maybe it would make sense to deprecate `promiseToFuture` / not offer it
in dart2wasm and make users use instead the extension on `JSPromise`
instead?

[0] https://dart-review.googlesource.com/c/sdk/+/352520

Change-Id: Ibc80bf083e7ec817f000257d6995108954060277
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/352521
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2024-02-14 11:48:15 +00:00
Srujan Gaddam f20cd26533 Update JSExport docs to refer to createJSInteropWrapper
Also cleans up some wording and better explains all the possible
features of the annotation.

CoreLibraryReviewExempt: Docs for backend-specific library.
Change-Id: Id5f3e1ea09d2ceaf9f727eb7885b38319b978dd6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/352441
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
2024-02-14 00:36:25 +00:00
Martin Kustermann 385ab26022 [dart2wasm] Use identity hashmap for allowInterop closure map
This significantly speeds up certain operations as it avoids calling
complex closure equality logic in the hashmap operations.

See also [0] regarding us leaking those closures.

[0] https://github.com/dart-lang/sdk/issues/54908

Change-Id: I046063884b88fbe53bc3cb397b0087693c9b928a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/352520
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2024-02-13 21:49:58 +00:00
Brian Quinlan 9967075787 [io] Fix a bug where Process.stdin.add exceptions could not be caught
Change-Id: I2383a74bfa6950ab8f8934087fb68218f06dd681
Bug:https://github.com/dart-lang/sdk/issues/48501
Tested: Unit test
CoreLibraryReviewExempt: dart:io only
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/351380
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Brian Quinlan <bquinlan@google.com>
2024-02-13 18:26:49 +00:00
Lasse R.H. Nielsen 712df96202 Avoid type checks in Future.wait
CoreLibraryReviewExempt: Bypassing because Wasm-approver is OOO.
Change-Id: I484e900c14f181f56083b6e90a0d1f34546c85e1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/341504
Commit-Queue: Lasse Nielsen <lrn@google.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
2024-02-13 16:07:12 +00:00
Parker Lougheed 78dbc184b1 [sdk/js_interop] Clean up and add a few minimal API docs
CoreLibraryReviewExempt: Only touches JS core library documentation.
Change-Id: I7d7f0a2b646f95de8340e9e77d8207cd99c9a1b0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/351940
Reviewed-by: Alexander Thomas <athom@google.com>
Commit-Queue: Alexander Thomas <athom@google.com>
Reviewed-by: Kevin Moore <kevmoo@google.com>
2024-02-12 14:44:54 +00:00
Martin Kustermann aadac65a2e [dart2wasm] Faster string equality
There should be no need to use polymorphic `.codeUnitAt()` calls in
the common case: comparing OneByteString with OneByteString, etc

This increases e.g. LongStringCompare.* benchmarks by 600+%

Change-Id: I1b7b2b53f35237d1ddc1c177c01728629a4acf40
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/352020
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2024-02-12 14:06:50 +00:00
Martin Kustermann 790297b812 [dart2wasm] Use WasmArray<>s for string interpolation expressions
* Use `WasmArray<>`s in string interoplation expressions
* Use `WasmArray<>`s in string buffer implementation
* Avoid making OneByteString+JSString imply TwoByteString

This also increases performance significantly, e.g.
JsonObjectRoundTrip & StringBuffer by 40% in -O4 and even more
speedup in -O2

Change-Id: I25485a6c532c3afed7d92943b6de4d1452930606
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/352000
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2024-02-12 14:01:12 +00:00
Daco Harkes ddfc00e773 [vm/ffi] Unify TypedDataBase wrappers
For getting the address of `Struct` fields and `Array` elements
it would be useful to access the `_typedDataBase` field in these
'wrappers' in a unified way.

This CL makes `Array` extend `_Compound`.
Since `Array` is not a `SizedNativeType`, the implements clauses
for `Struct` and `Union` are moved to these classes.

Moreover, any references to 'compound' which only apply to struct or
union are updated.

TEST=test/ffi

Bug: https://github.com/dart-lang/sdk/issues/44589
Bug: https://github.com/dart-lang/sdk/issues/54739
Bug: https://github.com/dart-lang/sdk/issues/41237

CoreLibraryReviewExempt: No API change, only refactoring.
Change-Id: Ib9d8bccd4872df04bcc67731e4052f826ab70af4
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-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-release-ia32-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/350960
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Liam Appelbe <liama@google.com>
2024-02-09 21:27:29 +00:00
Mayank Patke c556766395 [dart2js] Expose JS_TRUE and JS_FALSE via dart2js_runtime_metrics.
dart2js already had an external function in foreign_helper called
JS_FALSE. This function is completely opaque until it is lowered to the
constant value `false` in SSA, so one can write `if (JS_FALSE())` in
order to ensure that the guarded code is treated as live and compiled,
but eventually tree-shaken and omitted from SSA and codegen.

This CL adds a JS_TRUE counterpart for completeness, and exposes both
JS_TRUE and JS_FALSE through package:dart2js_runtime_metrics.

Change-Id: I9b375fa37ada1b65fb9183902bb295e05fa6b8c5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/349704
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Mayank Patke <fishythefish@google.com>
2024-02-09 18:38:55 +00:00
Mayank Patke 85037bf96d [dart2js, ddc] Clean up conditional imports in dart2js_runtime_metrics
This CL:
* adds empty dart:_dart2js_only and dart:_ddc_only libraries for use in
  conditional imports,
* updates pkg/dart2js_runtime_metrics to use the new libraries rather
  than dart:_dart2js_runtime_metrics and dart:js,
* and removes some unnecessary libraries, including VM-specific
  implementations in pkg/dart2js_runtime_metrics and the DDC
  implementation of dart:_dart2js_runtime_metrics.

Change-Id: I9500aa303fa5ad8aba0e1d413f69957c268f3f11
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/350681
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2024-02-09 18:38:55 +00:00
Sigmund Cherem 5941ee7560 [dart:html] minor fix to clearWatch.
This is a fix to not include a null assert when it's
possible the value was null.

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

CoreLibraryReviewExempt: bug fix only affecting html library implementation
Change-Id: I26e6ebf3dc2d1ea3f9f458a32f519c5235e6d273
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/350982
Commit-Queue: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Srujan Gaddam <srujzs@google.com>
2024-02-08 23:23:20 +00:00
Martin Kustermann 26aa50fdbf [dart2wasm] Fix off-by-one error in List.insert()
Closes https://github.com/dart-lang/sdk/issues/54845

TEST=lib/collection/regress_54845_test

Change-Id: I1af7f59a57c70ef5ec724b089555ebbcbd88a484
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/351120
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2024-02-08 14:05:44 +00:00
Kevin Moore 53056b663e js_interop[_unsafe]: update library documentation
CoreLibraryReviewExempt: just changing web libraries
changekind:NO_CODE_CHANGE
Change-Id: Idc8ab1865f43f33c3ab0824142b38fa715b1579b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/350520
Auto-Submit: Kevin Moore <kevmoo@google.com>
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Kevin Moore <kevmoo@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
2024-02-07 01:47:27 +00:00
Stephen Adams 7ef215a4a5 Reapply "[typed_data] Deprecate unmodifiable views"
This change, for Dart 3.4, deprecates the unmodifiable typed data constructors. Users of these constructors can upgrade the use of the constructors to instance method `asUnmodifiableView()`, or pin to Dart 3.3.

See https://github.com/dart-lang/sdk/issues/53785 for context.

CoreLibraryReviewExempt: Reviewed in https://dart-review.googlesource.com/c/sdk/+/321922
Issue: #53785
Change-Id: Icd52f2b6cd05cf3a328c82c197ef44d0b340b171
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/332581
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2024-02-06 23:30:49 +00:00
Derek Xu 60833d9cd9 [VM/Service] Update dart:io service extension spec
The main purpose of these changes is to make sure that the types in
package:http_profile are compatible with the interfaces in the spec.

See runtime/vm/service/service_extension.md and
pkg/vm_service/CHANGELOG.md for the full list of changes.

TEST=pkg/vm_service/test/get_http_profile_test.dart, DevTools tests

CoreLibraryReviewExempt: Only touches sdk/lib/io/network_profiling.dart
to update the version returned by the getVersion dart:io service
extension.
Change-Id: I1b9d0b7d43defbc857a2a8fde003012effd1ee15
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/341120
Reviewed-by: Ben Konyi <bkonyi@google.com>
2024-02-06 19:26:06 +00:00
Polina Cherkasova 166c796179 Implement toChunks and allow optimization.
1. Implement HeapSnapshotGraph.toChunks
2. Add parameter calculateReferrers, to allow to skip calculation of referrers, when they are not needed.

Change-Id: I312f01f1527e6b2bf4c8ddce6017ca6c53c8dd3a
CoreLibraryReviewExempt: minor dart:io documentation change
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/348802
Commit-Queue: Polina Cherkasova <polinach@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2024-02-06 16:55:20 +00:00
Martin Kustermann 1c5e12c212 [dart2wasm] Fix int.parse(<str>) for when <str> is a JSString
The `int.parse()` function would - if radix is provided and not 10 - use
functions that `unsafeCast<StringBase>()`.

=> The string can be a JSString.

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

CoreLibraryReviewExempt: Adding test that should pass on all backends.
Change-Id: Ie6efa5bc545cadce5ea946e2c1d732b2cf94e306
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/350303
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2024-02-05 22:38:18 +00:00
Martin Kustermann cca3ffd278 [dart2wasm] Ensure we convert Dart string *once* to JS string in regexp matching
Improves the third_party/pkg/crypto/test/sha1_test.dart by 100x

Change-Id: I16f0d75a43acd15642b4a62c9bba97f3479efb03
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/350322
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2024-02-05 21:32:29 +00:00
Parker Lougheed 0a0f6915ca [ffi] Add missing changelog entries for dart:ffi
Includes changelog additions and `@Since` version fixes for https://dart-review.googlesource.com/c/sdk/+/349260.

CoreLibraryReviewExempt: No functional change and dart:ffi is only supported by the VM and dart2wasm.
Change-Id: Iad0c4d3686278312715ec5fc5374b3c983b71d1e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/349765
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Auto-Submit: Parker Lougheed <parlough@gmail.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2024-02-05 16:28:04 +00:00
Martin Kustermann 0bc92a4333 [dart2wasm] Remove usage of type category table
The type category table is a O(number-of-classes) sized byte array that
maps from class-id to either a type category (function, record, ...) or
a masqueraded class-id.

* for flute this table takes up around 1 KB.
* this prevents from making concrete class-ids come before all abstract
  class ids

After recent changes the core RTT implementation no longer involves
masqueraded types (i.e. `<obj> is/as <type>` and `<type> <: <type>`
queries don't trigger masquerading functionality)

This CL removes the type category table, the special casing in the
class-id assignment and the compiler support for building the table.

Instead we move the logic to pure dart code, which can use normal `is`
checks to perform its function.

We add one optimization: The compiler will provide the class-id from
which one only non-masqueraded classes come. This makes the masquerading
function have a fast path.

* We use `Wasm{TypedData,String}Base` marker interfaces i
 `dart:_internal` to check for wasm-backed implementations
* We use `-Ddart.wasm.js_compatibility` to provide JSCM mode

We add a test that actually exercises the 2 modes.

Change-Id: I051c35b17878950402a1336df871a686b649f732
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/349641
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2024-02-02 19:01:49 +00:00
Martin Kustermann 32c22da2b6 [dart2wasm] Record type related cleanups
* avoid allocating _RecordType objects for `<obj> is/as <record-type>`
  => Introduce `Record._checkRecordType()`
  => Use `Record._recordRuntimeType` (which is now not masquerading) for
  other purposes (e.g. verification)

* avoid using masqueraded types for `<obj> is/as <record-type>`
  => Introduce `Record._masqueradedRecordRuntimeType`

Although we introduce 2 extra methods on `Record` that are overriden,
it's O(record-shapes-in-program) and therefore not a big overhead.

=> This will enforce the invariant that the actual type check
   implementation (i.e. for `<obj> is/as <type>` or
   for `<type> <: <type>`) *never* calls back into
   masquerading functionality

=> This in return means we can make the masquerading functionality
   using `<obj> is <type>` checks.

Change-Id: I3e3a0411022042a8e735aaeed396cc8f90d8c9c5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/349800
Reviewed-by: Slava Egorov <vegorov@google.com>
2024-02-02 11:52:23 +00:00
Johnni Winther fe52b9bfe5 [macros] Add dart:_macros
This adds the dart:_macros library to the SDK and adds support for accessing dart:_macros from package:macros. The library is not used yet.

This change is needed as a prestep to adding the package:macros and using it in the CFE and analyzer, and needs to be rolled in as the checked in sdk before package:macros can be supported.

TEST=ci

Change-Id: Ife3ffd48527e3a196048d2ddf7387b8b7818f3a3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/348680
Reviewed-by: Jake Macdonald <jakemac@google.com>
Reviewed-by: William Hesse <whesse@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2024-02-02 07:47:59 +00:00
Parker Lougheed df7c3197af [docs/api] Minor adjustments and fixes to api.dart.dev homepage
- Since "Futures", "Streams", and "Zones" are plural and not in code syntax, can make them lowercase to be consistent with the `dart:core` entry in the same list.
- Use the full "platform interopability" term when introducing the libraries, as it might be a newer term for readers.
- Replaces "interoping" term as after searching it seems not common and easily mistaken.
- Fixes spelling of "function"

Change-Id: Ia887b427789a50d70cb47228c677fe2fd03499e2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/349421
Reviewed-by: Kevin Moore <kevmoo@google.com>
Commit-Queue: Kevin Moore <kevmoo@google.com>
Reviewed-by: Marya Belanger <mbelanger@google.com>
2024-02-01 21:41:38 +00:00
Daco Harkes c0c7c1ef49 [vm/ffi] Update inner pointer accesses in IL
FFI loads and stores via structs can have a TypedData as receiver,
so this CL updates those loads to `kMayBeInnerPointer`.

This CL adds an IL test to verify that for `Pointer` loads the untagged
value is treated correctly as `kCannotBeInnerPointer`.
(And adds some prefer-inline pragmas to make some common operations
be inlined to avoid allocating `Pointer` objects.)

This CL updates the load in the FFI closures to use a load-field.
This can also potentially enable not allocating a pointer object when
this closure is inlined.

TEST=tests/ffi/unwrap_typeddata_generated_test.dart
TEST=tests/ffi

CoreLibraryReviewExempt: Only adding some pragmas.
Change-Id: If687e54c676f275cc849b3fed526a13766ab331a
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-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-release-ia32-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/349241
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2024-02-01 18:28:53 +00:00
Daco Harkes bf683bacbb Reland "[vm/ffi] Introduce Struct.create and Union.create"
Analyzer fix https://github.com/dart-lang/sdk/issues/54754 has
landed. A new version of package:analyzer and package:dartdoc have
been released. `pub global activate dartdoc` should now work.

Patchset 1 is identical to the original CL.
The only difference is an extra test testing with negative offsets.

=== Original CL description ===

Structs and unions can now be created from an existing typed data
with the new `create` methods.

The typed data argument to these `create` methods is optional. If
the typed data argument is omitted, a new typed data of the right
size will be allocated.

Compound field reads and writes are unchecked. (These are
TypedDataBase loads and stores, rather than TypedData loads and stores.
And Pointers have no byte length.) Therefore the `create` method taking
existing TypedData objects check whether the length in bytes it at
least the size of the compound.

TEST=pkg/analyzer/test/src/diagnostics/creation_of_struct_or_union_test.dart
TEST=pkg/vm/testcases/transformations/ffi/struct_typed_data.dart
TEST=tests/ffi/structs_typed_data_test.dart
TEST=tests/ffi/vmspecific_static_checks_test.dart

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

Change-Id: Id7f30bcd4a6ae55a8298b39c9eadf4e80bc699a9
CoreLibraryReviewExempt: FFI is a VM and WASM only feature.
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-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-release-ia32-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/349260
Reviewed-by: Martin Kustermann <kustermann@google.com>
2024-02-01 18:28:03 +00:00
Martin Kustermann 2b396dd95a [dart2wasm] Fix type substitution bug if records are involved
Fixes https://github.com/dart-lang/sdk/issues/54794

Change-Id: I13b4ae619fad7d7e00f4a17e199b85ebea4e6de7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/349680
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2024-02-01 11:38:58 +00:00
Martin Kustermann 8ea636f9f8 [dart2wasm] Make throw call to helper function that gets stacktrace and throws object
This reduces flute complex compiled with `-O4` by 3.2% (or 41kb)

Change-Id: I46e1e933b5b283a7e502571971802885c1c79372
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/349261
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2024-01-31 08:43:18 +00:00
Marya cce16ed108 Drop dart:html from readme
Closes https://github.com/dart-lang/sdk/pull/54775

GitOrigin-RevId: aeef490725f4bc0b627eaaa980920b8b9dfb5d26
Change-Id: I52c2c64826be2304006e1c27f55abf9a402ca5b5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/349402
Reviewed-by: Kevin Moore <kevmoo@google.com>
Reviewed-by: Devon Carew <devoncarew@google.com>
Commit-Queue: Devon Carew <devoncarew@google.com>
2024-01-30 22:35:52 +00:00
Stephen Adams bc2a1ef233 [js_dev_runtime] dart format --fix
Update js_dev_runtime and js_shared formatting.

Most changes are doc comments (`/**` to `///`) and some removal of unnecessary `new`.

This brings js_dev_runtime a little closer to js_runtime after the similar automated formatting of js_runtime.

Change-Id: I21b3d01ba4ad75b22c8c9623ac740502d1906d2e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/349084
Commit-Queue: Stephen Adams <sra@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
2024-01-30 20:41:20 +00:00
MarkZ 91d22a7e40 [ddc] Renaming dart_library.js to ddc_module_loader.js
This also removes deprecated references to the DDC module system as the "legacy" module system.

This is part of an ongoing effort to deprecate the AMD module system: https://github.com/dart-lang/sdk/issues/52361

Change-Id: Ic32c6c6a0b7bf2c3bf0326be42cc9a88db8e303e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/348183
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Mark Zhou <markzipan@google.com>
Reviewed-by: Jake Macdonald <jakemac@google.com>
2024-01-30 19:43:49 +00:00
Daco Harkes f992bfc7b1 Revert "[vm/ffi] Introduce Struct.create and Union.create"
This reverts commit c2e15cff6d.

Reason for revert: https://github.com/dart-lang/sdk/issues/54754
Version skew somewhere in the analyzer/dartdoc/flutter combination.
We need to land the fix inside ffi_verifier.dart first, and then
reland the API docs that trigger the code path in the analyzer
that throws the exception.

Original change's description:
> [vm/ffi] Introduce `Struct.create` and `Union.create`
>
> Structs and unions can now be created from an existing typed data
> with the new `create` methods.
>
> The typed data argument to these `create` methods is optional. If
> the typed data argument is omitted, a new typed data of the right
> size will be allocated.
>
> Compound field reads and writes are unchecked. (These are
> TypedDataBase loads and stores, rather than TypedData loads and stores.
> And Pointers have no byte length.) Therefore the `create` method taking
> existing TypedData objects check whether the length in bytes it at
> least the size of the compound.
>
> TEST=pkg/analyzer/test/src/diagnostics/creation_of_struct_or_union_test.dart
> TEST=pkg/vm/testcases/transformations/ffi/struct_typed_data.dart
> TEST=tests/ffi/structs_typed_data_test.dart
> TEST=tests/ffi/vmspecific_static_checks_test.dart
>
> Closes: https://github.com/dart-lang/sdk/issues/45697
> Closes: https://github.com/dart-lang/sdk/issues/53418
>
> Change-Id: If12c56106c7ca56611bccfacbc1c680c2d4ce407
> CoreLibraryReviewExempt: FFI is a VM and WASM only feature.
> 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/+/342763
> Commit-Queue: Daco Harkes <dacoharkes@google.com>
> Reviewed-by: Johnni Winther <johnniwinther@google.com>
> Reviewed-by: Lasse Nielsen <lrn@google.com>
> Reviewed-by: Martin Kustermann <kustermann@google.com>

Change-Id: I285dc39946b5659219b37a1d8f10de479133957e
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/+/349061
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Reviewed-by: Zach Anderson <zra@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2024-01-30 10:43:22 +00:00
Brian Quinlan af79f2fe22 [io] Fix a bug where Socket.addStream never completes after the socket is destroyed.
Bug:https://github.com/dart-lang/sdk/issues/54735
Change-Id: I8895ff6271eb1019ddad13c171f36cbec5fd84cd
TEST=tests/standalone/io/client_socket_destroy_and_add_stream_test.dart
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/348764
Commit-Queue: Brian Quinlan <bquinlan@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2024-01-29 23:09:22 +00:00
Stephen Adams 0a0e9fb713 [js_runtime] dart format --fix
Update js_runtime formatting.
Almost entirely dropping unnecessary `new`.

Change-Id: I8016c77f405972abd17d2242497a400994e15be5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/348860
Commit-Queue: Stephen Adams <sra@google.com>
Reviewed-by: Mayank Patke <fishythefish@google.com>
2024-01-29 20:48:09 +00:00
Martin Kustermann a2ee738dfc [dart2wasm] Make cid numbering of concrete classes perfect DFS pre-order
The CL removes a hack that assigned fixed class ids due to the need of
special treatment for masquerading types.

=> Instead of hard coding the type category values, we discover feasible
slots automatically, so we can remove the hack
=> Makes our cid numbering of concrete classes pure DFS pre-order
=> Ensures all concrete subclasses of a class have continious class ids

We also replace an assembly stub that deals with masquerading with one
written in Dart, adding the necessary primitives (e.g.
getting category type table & kinds).

We also align how to get the function type of a closure, namely
add `_Closure._getClosureRuntimeType()` analogous to the method on
`_Record._getRecordRuntimeType()`

Change-Id: I5169fc4953e8e99c4f84a1bbe8e535c08fb47cc5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/348840
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2024-01-29 12:53:57 +00:00
Daco Harkes c2e15cff6d [vm/ffi] Introduce Struct.create and Union.create
Structs and unions can now be created from an existing typed data
with the new `create` methods.

The typed data argument to these `create` methods is optional. If
the typed data argument is omitted, a new typed data of the right
size will be allocated.

Compound field reads and writes are unchecked. (These are
TypedDataBase loads and stores, rather than TypedData loads and stores.
And Pointers have no byte length.) Therefore the `create` method taking
existing TypedData objects check whether the length in bytes it at
least the size of the compound.

TEST=pkg/analyzer/test/src/diagnostics/creation_of_struct_or_union_test.dart
TEST=pkg/vm/testcases/transformations/ffi/struct_typed_data.dart
TEST=tests/ffi/structs_typed_data_test.dart
TEST=tests/ffi/vmspecific_static_checks_test.dart

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

Change-Id: If12c56106c7ca56611bccfacbc1c680c2d4ce407
CoreLibraryReviewExempt: FFI is a VM and WASM only feature.
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/+/342763
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2024-01-27 09:28:40 +00:00
Alexander Aprelev 55310a1c70 [vm] Create a gni listing vm internal dart sources.
This is needed by flutter engine when it packages dart sdk sources.

Fixes https://github.com/flutter/flutter/issues/128880
TEST=manually flutter build

Change-Id: If3fce581e997eea44e4d377172ab9ce573bb1508
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/348180
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2024-01-26 22:04:04 +00:00
Nate Bosch 9bac969596 Mention future callback ordering is undefined
Closes #29168

R=lrn@google.com

Change-Id: Ia15ae8ef2977d8dde4b24674c389562d27a238cf
CoreLibraryReviewExempt: Documentation change.
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/310771
Auto-Submit: Nate Bosch <nbosch@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Nate Bosch <nbosch@google.com>
2024-01-26 19:32:14 +00:00
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
Martin Kustermann 1fc755eb54 [dart2wasm] Remove sdk/bin/dart2wasm{,_developer} scripts
We already have a shell script that compiles dart code to wasm and
optimizes it. I think it's rather confusing to have multiple, they
contain somewhat duplicated code as well.

We therefore remove `sdk/bin/dart2wasm{,_developer}` (which is
not used by any CI but purely for developers) in favor of
`pkg/dart2wasm/tool/compile_benchmark`.

=> It support with/without binaryen
=> It support measuring size/time/memory of dart2was & binaryen
=> It supports running compiler with assertions

Some flags/vars are not supported anymore:

* `DART_VM_OPTIONS`: Has no effect (as there's no need to support this)
* `sdk/bin/dart2wasm_developer`: Pass `--compiler-asserts` to `compile_benchmark`.
* `-O`: Optimizes now by-default, pass `--no-binaryen` to `compile_benchmark` to disable
* `-O`: Doesn't implicitly pass `--inlining-limit=10`

Change-Id: Ice656d1bfc216a536522b254e2d52bd4cad73e8e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/347040
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2024-01-19 16:05:27 +00:00
Martin Kustermann 1d92908169 [dart2wasm] Have binaryen/wasm-opt flags in one place (dart compile exe), make all other places take it from there
Golem build configuration is setup in a way that includes the `pkg/`
folder entirely, so the shell scripts should have access to the
`dart compile exe` sources.

Change-Id: I5395413ce85f11098d14eacbd6ce392f665ddce5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/347021
Reviewed-by: Slava Egorov <vegorov@google.com>
2024-01-19 07:47:52 +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
Ben Konyi 3c42222b7e [ CLI ] Add tooling-daemon command to support launching the Dart Tooling Daemon (DTD)
This change includes the following:
 - A new `tooling-daemon` CLI command to launch DTD
 - Minor refactoring of package:dtd_impl to better match expected
   Dart package structure
 - Updated build rules to create dart_tooling_daemon.dart.snapshot

Change-Id: Idd91bc4ce64ce790db5bad323a50d9cf65523dc2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/344800
Reviewed-by: Dan Chevalier <danchevalier@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2024-01-08 17:07:55 +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
Jonas Termansen 669060f8c7 [build] Omit SDK and Git hashes on RBE.
Bug: b/296994239
Change-Id: I70c10fddc3bd01fef5ed5182e1d28d0797c431e3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/342421
Commit-Queue: Jonas Termansen <sortie@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2023-12-20 12:23:56 +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
MarkZ 02446654db [ddc] Copying dart_library.js in SDK builds.
This renames 'dart_library.js' to 'ddc_module_loader.js' when referenced externally (e.g., Flutter Web).

This change is in preparation for DDC module system support in Flutter.

See: #52361

Change-Id: I47e7bfa1058114c2977529a97ec58f0659200472
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/334400
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Mark Zhou <markzipan@google.com>
2023-11-27 18:36:09 +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