Commit graph

11324 commits

Author SHA1 Message Date
Kenzie Schmoll 112c08b418 Remove deprecated APIs from dart_io_extensions.dart and add new is*Available RPCs.
Removed:
- `startSocketProfiling`
- `pauseSocketProfiling`
- `getHttpEnableTimelineLogging`
- `setHttpEnableTimelineLogging`

Added:
- `isSocketProfilingAvailable`
- `isHttpTimelineLoggingAvailable`
- `isHttpProfilingAvailable`

The added RPCs were previously implemented in DevTools with a TODO to move these into `dart_io_extensions.dart`: https://github.com/flutter/devtools/blob/master/packages/devtools_app/lib/src/service/vm_service_wrapper.dart#L896-L918

Change-Id: Ic6c14ae7c09361e39fb3b0ad8c28e3e5863ca9bb
CoreLibraryReviewExempt: VM service changes
TEST=existing tests
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/329800
Commit-Queue: Kenzie Davisson <kenzieschmoll@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2023-10-11 22:22:12 +00:00
asiva 8e6a02d899 [vm/lib] Fix for https://github.com/dart-lang/sdk/issues/45347
TEST=new tests added

Change-Id: Ic604cc9576f092c1bf96f411ae1abdea6c78c384
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/329784
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
2023-10-11 21:51:02 +00:00
Nicholas Shahan 148a1ae9d5 [dart2js, ddc] Add preamble to seal Object prototype
- Add a new dart2js preamble file that seals the native object prototype.
- Use the file when running DDC in d8 locally.

Once this change lands the new preamble can be used in the script that
runs d8 on the benchmarking bots.

If benchmark results look good, I will followup with a change to enable
the prototype sealing in SDK test configurations as well.

Change-Id: I00ffb14751a9b7e874e2e91fcb753a6382f0d577
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/329825
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
2023-10-11 20:39:24 +00:00
Sergey G. Grekhov f05bf93d3f [io/doc] Update Link.createSync() documentation to be in accordance with Link.create()
Bug: https://github.com/dart-lang/sdk/issues/30665
Bug: https://github.com/dart-lang/sdk/issues/52972
Change-Id: I7e0ef87151bee7b371335933bd1b8ab1ebd72e52
CoreLibraryReviewExempt: documentation update
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/329321
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Alexander Thomas <athom@google.com>
Reviewed-by: Brian Quinlan <bquinlan@google.com>
Reviewed-by: Alexander Thomas <athom@google.com>
2023-10-11 14:24:38 +00:00
Daco Harkes a71a1bfcfb [ffi/doc] Document the type requirements of native functions
Closes: https://github.com/dart-lang/sdk/issues/53623
CoreLibraryReviewExempt: VM and WASM API only, only updates doc.
Change-Id: Id7378da13aaac3546c9c227ed568ff346e33dddf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/328260
Reviewed-by: Lasse Nielsen <lrn@google.com>
Auto-Submit: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2023-10-11 12:50:12 +00:00
Brian Quinlan 2b137b4e1f [io/doc] Make FileSystemEvent.toString() consistent across subclasses.
Change-Id: I76bbe9b58bdee5594917410c69513160f25e519e
CoreLibraryReviewExempt: Only changes `toString`
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/329641
Commit-Queue: Brian Quinlan <bquinlan@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2023-10-10 19:19:25 +00:00
Nicholas Shahan 904972569d [dart2js][ddc] Make rti universe field names const
These names are expected to always be the same, making
them const allows DDC to recognize that more easily.

Change-Id: I80a991e1cf50b2990fd27afb4ff3793a6135cf65
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/328803
Commit-Queue: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Mayank Patke <fishythefish@google.com>
2023-10-09 21:12:48 +00:00
Ömer Sinan Ağacan 96bd779a03 [dart2wasm] Small simplifications in string patch
Change-Id: I1febd54d485681875936f5305d94f72f94d4fab8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/329461
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Commit-Queue: Ömer Ağacan <omersa@google.com>
2023-10-09 09:38:34 +00:00
Ömer Sinan Ağacan 6885e82cda [dart2wasm] Fix two TODOs in JS utils
This copies some of the TODO fixes from
https://dart-review.googlesource.com/c/sdk/+/288381.

Change-Id: I6a887414052f73be3714098e153a7644280de188
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/329103
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Commit-Queue: Ömer Ağacan <omersa@google.com>
2023-10-05 19:16:29 +00:00
Ömer Sinan Ağacan c5dd320d90 [dart2wasm] Add inline pragmas to JS typed array classes
Typed array accessors are quite small, and inlining them often leads to
avoiding boxing the return values in `operator []` and the set value in
`operator []=`.

(Native typed array classes already have these inline pragmas)

Change-Id: Ib15dda93687b5becd1dfa92d34d9d28a75df2e07
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/329100
Commit-Queue: Ömer Ağacan <omersa@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
2023-10-05 14:20:51 +00:00
Devon Carew e2fe203adc [deps] roll package:lints to the latest
Change-Id: I582f956cd4b712203c2f6dd630b4e1384040446d
Tested: analysis clean (this is a lint only related change)
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/329400
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Devon Carew <devoncarew@google.com>
2023-10-05 03:36:59 +00:00
Nicholas Shahan e7073bfd0f [core] Avoid implicit downcast from dynamic
Add a static type to the variable declaration so it isn't inferred
as dynamic causing multiple implicit downcasts downstream.

CoreLibraryReviewExempt: Trivial change.
Change-Id: Ibef1d4666f5a6a5bbab363195c4b4dea66e8eac3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/328741
Reviewed-by: Lasse Nielsen <lrn@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
2023-10-02 23:33:19 +00:00
knotmine da7f1d878c Format containsValue() description in hash_map.dart
Closes https://github.com/dart-lang/sdk/pull/53665

GitOrigin-RevId: fa521f6f779fc9f9331c7a522f9ffe1cf8b3641d
Change-Id: Iec4a31b3f2a4d099624283623de73694046325c0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/328808
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
2023-10-02 10:25:59 +00:00
Nicholas Shahan 53ba601220 [ddc] Apply select inlining for dart:_rti
Adds simple method inlining for select patterns only in the dart:_rti
library as an optimization. This helps avoid chains of costly
accesses method calls that in the end simply perform a single
operation and return the result.

For example and snipet from the compiled SDK before:

```
if (_rti._isString(object)) {...}
```
and after:

```
if(typeof object == "string") {...}
```

Issue: https://github.com/dart-lang/sdk/issues/48585
Change-Id: I90596294d35a8fd75d74014c6a12f6e8c726cfcc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/324571
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
2023-09-30 00:20:58 +00:00
Brian Quinlan 3fae23ae69 [io/doc] Document when read/readSync can return return less than requested bytes
Bug:https://github.com/dart-lang/sdk/issues/50034
Change-Id: Ib2f2b11bc3ae1fe241b71a43f2866233e066d8e2
CoreLibraryReviewExempt: Documentation-only change
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/328802
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Brian Quinlan <bquinlan@google.com>
2023-09-29 21:21:38 +00:00
Brian Quinlan c3168c4e3b Clarify that Links on Windows have types and that the target of the symlink need not exist.
CoreLibraryReviewExempt: documentation-only change
Bug: https://github.com/dart-lang/sdk/issues/30665
Bug: https://github.com/dart-lang/sdk/issues/52972
Change-Id: Ia7f02fb578d67e78dd8209d7514db0436142a085
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/328661
Commit-Queue: Brian Quinlan <bquinlan@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2023-09-29 16:22:33 +00:00
Nicholas Shahan 02f91a1064 [ddc] Cleanup dynamic calls in core_patch.dart
Change-Id: I453b9b034c4656db96bb034a39602c5514a5bed9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/328663
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
2023-09-29 16:14:30 +00:00
Piotr Rogowski a1692e3f26 Fix typos in socket send docs
Closes https://github.com/dart-lang/sdk/pull/53651

GitOrigin-RevId: 32ed388818bff0f0ed41b0bf44da3f3c4cff533e
Change-Id: I47dacf24ff3f2c9b7c8be637beb479559009ce82
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/328680
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2023-09-29 14:04:41 +00:00
Anna Gringauze e1efba011e [ddc] Fix exception on pausing in library with late globals
Closes: https://github.com/dart-lang/sdk/issues/53603
Change-Id: If2c9b62204dc00c5d0316e66ab34bf10855e9c92
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/327823
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Anna Gringauze <annagrin@google.com>
2023-09-28 19:59:02 +00:00
Liam Appelbe 82ff34d775 [ffi] Make nativeFunction throw if already closed
This is a *breaking change*. See
https://github.com/dart-lang/sdk/issues/53311

Make nativeFunction throw a StateError if the NativeCallable is already
closed. Also make close and keepIsolateAlive not throw.

I'm not adding an isClosed getter, as discussed on the bug.

Bug: https://github.com/dart-lang/sdk/issues/53311
Fixes: https://github.com/dart-lang/sdk/issues/53311
Change-Id: Ib0066352d3cfc01d31df8ae8fd61be426fcdf6e1
CoreLibraryReviewExempt: The FFI package is VM-only
TEST=async_void_function_callbacks_test and isolate_local_function_callbacks_test
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/328280
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Liam Appelbe <liama@google.com>
2023-09-27 22:18:47 +00:00
Jackson Gardner 2caad4c3cb Expose some APIs for translating between wasm and JS interop types.
Change-Id: Ia0e609bc06b4646949a5b8c4da24f0f8daf27ec8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/327820
Reviewed-by: Ömer Ağacan <omersa@google.com>
Commit-Queue: Jackson Gardner <jacksongardner@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
2023-09-27 21:34:38 +00:00
Brian Quinlan b1a4a35f96 [io] Ignore Content-Length if Transfer-Encoding header is set.
Bug:https://github.com/dart-lang/sdk/issues/48822
Change-Id: I250d51f9784443ef17f58b0c5b296c09e287c10c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/327703
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Brian Quinlan <bquinlan@google.com>
2023-09-27 19:12:44 +00:00
asiva 409eb5ba7e [Reland] [dartdev] Convert gen_kernel.dart.snapshot into an AOT snapshot
Convert gen_kernel to use an AOT snapshot in the
dart compile exe
command.

TEST=ci

Change-Id: I3024bdd20f40ef562936821aa936eec74662373e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/327711
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
2023-09-26 21:46:58 +00:00
asiva df266b8a44 [Reland] [dartdev] Use an AOT snapshot for dds
This change enables use of an AOT snapshot for dds execution.

TEST=ci

Change-Id: I1eba2913a4160dee5de663622aa9106dd1d83c04
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/327710
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
2023-09-26 18:27:02 +00:00
Jess Lally 3c4d4ad450 Reland "[dart2wasm] Replace struct.new_default with struct.new for object allocation."
This reverts commit 67f0d4daf0, and further optimises constructor contexts by preventing empty contexts.

Reason for revert: Includes fix for Flutter engine unit test failures.

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

Original change's description:
[dart2wasm] Replace `struct.new_default` with `struct.new` for object allocation.

When using the `struct.new_default` instruction for object allocation,
fields are always nullable and mutable. By using the `struct.new`
instruction instead, class fields can now have the same mutability and
nullability in Wasm as declared in Dart. In addition, the class ID and
type parameters (which are also stored in an object's struct), can now
be immutable and nonnullable as well.

To do this, object construction is now split into three functions:
(1) Initializer: evaluates initializers for instance fields and
constructor initializers (this constructor before super constructor).
(2) Constructor body: executes the constructor body (super constructor
before this constructor), with `this` pointed to the constructed object.
(3) Constructor allocator: which calls (1), allocates the object using
`struct.new`, then calls (2).

Because fields now have the correct mutability and nullability in Wasm,
this removes unnecessary null checks for nonnullable fields, and may
allow for better optimisations by Binaryen.

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

Change-Id: I13499bdc412f474bc76473115b6e63d6954f4d23
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/326080
Reviewed-by: Ömer Ağacan <omersa@google.com>
Commit-Queue: Jess Lally <jessicalally@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
2023-09-26 10:07:42 +00:00
Ryan Macnak cb39b9ff07 Revert "[vm/compiler] Perform inlining of _TypedList._getX in AOT."
This reverts commit 6673f84d59.

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

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

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

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

TEST=vm/dart/inline_TypedList_getUint32

Issue: https://github.com/dart-lang/sdk/issues/53513
Cq-Include-Trybots: luci.dart.try:vm-aot-linux-debug-simarm_x64-try,vm-aot-linux-debug-x64-try,vm-aot-linux-debug-x64c-try,vm-kernel-linux-debug-x64-try,vm-kernel-precomp-linux-debug-x64-try,vm-linux-debug-x64-try,vm-linux-debug-x64c-try,vm-mac-debug-arm64-try,vm-aot-linux-release-simarm_x64-try,vm-aot-linux-release-x64-try,vm-aot-mac-release-arm64-try,vm-linux-release-x64-try,vm-mac-release-arm64-try,vm-kernel-precomp-linux-release-x64-try
Change-Id: I66b6b8634b2b9b413fb745f02433eb58f2ff913e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/325703
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2023-09-25 16:07:17 +00:00
Tess Strickland 03c2003222 Revert "[dartdev] Convert gen_kernel.dart.snapshot into an AOT snapshot"
This reverts commit 0f8069d9d0.

Reason for revert: Broke the following builds:
* vm-appjit-linux-product-x64
* vm-aot-*-product-*
* vm-ffi-android-product-*
as well as the following tests:
* pkg/dartdev/test/commands/compile_test
* pkg/vm_snapshot_analysis/test/instruction_sizes_test
* pkg/vm_snapshot_analysis/test/precompiler_trace_test

Original change's description:
> [dartdev] Convert gen_kernel.dart.snapshot into an AOT snapshot
>
> Convert gen_kernel to use an AOT snapshot in the
> dart compile exe
> command.
>
> TEST=ci
>
> Change-Id: I6e338525dabb4e84dc1edff8f0bbac803223e74d
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/327520
> Reviewed-by: Alexander Markov <alexmarkov@google.com>
> Reviewed-by: Siva Annamalai <asiva@google.com>
> Reviewed-by: Ben Konyi <bkonyi@google.com>
> Commit-Queue: Siva Annamalai <asiva@google.com>

Change-Id: Ia7225516a17cab52c8506abee05ce0935941f1cc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/327641
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
2023-09-25 10:17:52 +00:00
Liam Appelbe 7cb4779869 Reland "[ffi] NativeCallable.listener example."
But only reland the documentation. The test will need some more work.

This is a reland of commit 5354df624a

Original change's description:
> [ffi] NativeCallable.listener example.
>
> Add an example to the NativeCallable.listener documentation.
>
> Bug: https://github.com/dart-lang/sdk/issues/53435
> Change-Id: I4b664b14ca1dbc474913a9e191e38ca6f290350f
> Fixes: https://github.com/dart-lang/sdk/issues/53435
> CoreLibraryReviewExempt: The FFI package is VM-only
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/326580
> Reviewed-by: Daco Harkes <dacoharkes@google.com>
> Commit-Queue: Liam Appelbe <liama@google.com>

Bug: https://github.com/dart-lang/sdk/issues/53435
Change-Id: Iafbf83ddcad47c7ae919f0730f5aa01a999eb083
CoreLibraryReviewExempt: The FFI package is VM-only
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/327440
Reviewed-by: Lasse Nielsen <lrn@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Liam Appelbe <liama@google.com>
Auto-Submit: Liam Appelbe <liama@google.com>
2023-09-24 23:33:19 +00:00
Srujan Gaddam 74c407da2f [dart:js_interop] Add/fix some js_interop helpers
Minus all the operator-related functionalities, members that
can be worked around using static interop e.g. getPrototypeOf,
and createDartExport/createStaticInteropMock, this bridges the
gap of js_util.

Adds:
- instanceOfString from js_util as an extension methods
- JSObject constructor to replace js_util.newObject
- Unnamed factory constructor to JSAny so users can't extend it

Fixes:
- JSArray.withLength to take an int
- typeofEquals to take a String and return a bool
- instanceof to return a bool

CoreLibraryReviewExempt: Backend-specific library.
Change-Id: I7db1651f641a4fc84392957dfa7ad64904f110e8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/326691
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
2023-09-23 18:32:59 +00:00
Srujan Gaddam e130bb36ce [dart:js_interop] Make isUndefined and isNull throw on dart2wasm
null and undefined cannot be distinguished on dart2wasm in its
current state, so these helpers should only work on the JS
compilers. Some comments are updated to reflect the current state
of this internalization. Also fixes a pending TODO in isNull and
isUndefined on the JS backends.

CoreLibraryReviewExempt: Backend-specific library.
Change-Id: Ic56e8aa346af99cb99d01fe3c7ac5e37e965db23
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/326690
Commit-Queue: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2023-09-23 01:46:50 +00:00
Srujan Gaddam e3852368b5 [dart:js_interop] Add Future.toJS and add some helpers
Adds Future.toJS that creates a Promise using a Dart callback.
Resolving is simple as we just pass the value (if any). Rejection
boxes the error and stack trace and sets them as properties of
a JSObject, which is then passed to the reject function.

Also adds:
- JSPromise constructor
- JSFunction.callAsFunction helper

CoreLibraryReviewExempt: Backend-specific library.
Change-Id: If2ce8018a2c8b3c4dc5d5af710c9bb4c2f688f87
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/326689
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
2023-09-23 00:52:48 +00:00
Siva Annamalai e854243a3d Revert "[dartdev] Use an AOT snapshot for dds"
This reverts commit 5f33a9ab80.

Reason for revert: There is speculation that this CL might have caused some errors invoking the analysis server from dartdev, leading to the error "dartdev: Error: Error when reading 'dartdev': No such file or directory"

TEST=ci

Original change's description:
> [dartdev] Use an AOT snapshot for dds
>
> This change enables use of an AOT snapshot for dds execution.
>
> TEST=ci
>
> Change-Id: I500be544e168bd487745ee1232fd925d5ef546b8
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/327140
> Reviewed-by: Ben Konyi <bkonyi@google.com>
> Reviewed-by: Derek Xu <derekx@google.com>
> Commit-Queue: Siva Annamalai <asiva@google.com>

Change-Id: I33a53a17f53714d3df5aba539870574a631cd416
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/327523
Reviewed-by: Ben Konyi <bkonyi@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
2023-09-22 23:09:25 +00:00
asiva 0f8069d9d0 [dartdev] Convert gen_kernel.dart.snapshot into an AOT snapshot
Convert gen_kernel to use an AOT snapshot in the
dart compile exe
command.

TEST=ci

Change-Id: I6e338525dabb4e84dc1edff8f0bbac803223e74d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/327520
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
2023-09-22 20:03:29 +00:00
asiva 5f33a9ab80 [dartdev] Use an AOT snapshot for dds
This change enables use of an AOT snapshot for dds execution.

TEST=ci

Change-Id: I500be544e168bd487745ee1232fd925d5ef546b8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/327140
Reviewed-by: Ben Konyi <bkonyi@google.com>
Reviewed-by: Derek Xu <derekx@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
2023-09-22 15:50:50 +00:00
Liam Appelbe 18d0afdce1 Revert "[ffi] NativeCallable.listener example."
This reverts commit 5354df624a.

Reason for revert: Broke debian-x64-main bot
https://logs.chromium.org/logs/dart-internal/buildbucket/cr-buildbucket/8769282695204884177/+/u/build/stdout

Original change's description:
> [ffi] NativeCallable.listener example.
>
> Add an example to the NativeCallable.listener documentation.
>
> Bug: https://github.com/dart-lang/sdk/issues/53435
> Change-Id: I4b664b14ca1dbc474913a9e191e38ca6f290350f
> Fixes: https://github.com/dart-lang/sdk/issues/53435
> CoreLibraryReviewExempt: The FFI package is VM-only
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/326580
> Reviewed-by: Daco Harkes <dacoharkes@google.com>
> Commit-Queue: Liam Appelbe <liama@google.com>

Bug: https://github.com/dart-lang/sdk/issues/53435
Change-Id: Id959500df51d0eaa9bd452d3d9d0a8b21191de1c
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/327420
Reviewed-by: Alexander Aprelev <aam@google.com>
Reviewed-by: Liam Appelbe <liama@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
Auto-Submit: Liam Appelbe <liama@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
2023-09-22 05:15:18 +00:00
Liam Appelbe 5354df624a [ffi] NativeCallable.listener example.
Add an example to the NativeCallable.listener documentation.

Bug: https://github.com/dart-lang/sdk/issues/53435
Change-Id: I4b664b14ca1dbc474913a9e191e38ca6f290350f
Fixes: https://github.com/dart-lang/sdk/issues/53435
CoreLibraryReviewExempt: The FFI package is VM-only
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/326580
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Liam Appelbe <liama@google.com>
2023-09-22 04:02:20 +00:00
Srujan Gaddam d54f0acd02 [dart2wasm] Fix null rejection exception and add tests for conversions
Then callbacks should accept and return a JSAny?. Some JS types tests
were incomplete as well.

Change-Id: Id46e2a53f8f83ce17247fbd23d5be82f3f986f30
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/326688
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
2023-09-21 21:41:39 +00:00
Srujan Gaddam 94e4a4dfb5 [dart:js_interop] Modify some documentation around arrays/lists
Just some clarifications around what to expect when using these
conversion functions.

CoreLibraryReviewExempt: Documentation change.
Change-Id: I7fcd26a0fb14ac48bf80df1f9252584a730cb47f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/326687
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2023-09-21 21:41:39 +00:00
Nicholas Shahan 3a0f4d63bc [ddc] Avoid implicit downcast from dynamic
Defensively save and restore the value of the global counter used
when performing a type check. This value was being accidentally
reset to zero because of the implicit type check being performed
during another type check.

Change-Id: I51484456734e258a354fe2246d957ad3512ae340
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/327102
Commit-Queue: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Srujan Gaddam <srujzs@google.com>
2023-09-21 16:48:59 +00:00
Aske Simon Christensen a2c47adfba Update Binaryen to a51bd6df919a5b79574f0996a760cc20cb05697e
This version fixes an issue with optimizing tuple-valued blocks, which
would arise when inlining functions with multiple return values.

Use the newly added `--type-unfinalizing` and `--type-finalizing`
options to improve the effectiveness of the TypeSSA and TypeMerging
passes.

https://github.com/WebAssembly/binaryen/issues/5923
https://github.com/WebAssembly/binaryen/issues/5933

Change-Id: I1d5bc1052a355bf404f81a420a2352270030fd4c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/327000
Reviewed-by: William Hesse <whesse@google.com>
Auto-Submit: Aske Simon Christensen <askesc@google.com>
Commit-Queue: Aske Simon Christensen <askesc@google.com>
2023-09-21 11:47:59 +00:00
Mayank Patke c047b76439 [dart2js] Remove IE11 polyfill from StackTrace.current
Change-Id: Id0eb8a75e1d555dcef6c2451b3d363baf141ddd6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/326863
Commit-Queue: Mayank Patke <fishythefish@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2023-09-20 19:32:42 +00:00
Brian Quinlan 5b7b8aab40 [docs/io]: Clarify the semantics of FileSystemEntity.rename(Sync).
CoreLibraryReviewExempt: Documentation-only change
Bug: https://github.com/dart-lang/sdk/issues/53274
Change-Id: Ifa3e94c6d8503790d3f6d29e9a99700e83d511d2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/326862
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Brian Quinlan <bquinlan@google.com>
2023-09-19 19:29:07 +00:00
Ömer Sinan Ağacan 3ee5bdfcf3 [dart2wasm] Add test configuration to test with wasm-opt
- Update dart2wasm script to accept a `-O` argument. When passed it also
  passed `--inlining-limit 10` to dart2wasm (unless it's already passed
  by the caller) and runs wasm-opt on the output, with the same
  arguments as `compile_benchmark`.

- Add new test configurations to run tests with optimized binaries.
  Example configuration: `dart2wasm-linux-optimized-d8`.

Change-Id: Ia7bd8d9c99d3a4baecb72b92b2ba38c0e92807c6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/326620
Commit-Queue: Ömer Ağacan <omersa@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
2023-09-19 10:29:43 +00:00
Nicholas Shahan 6bf8844ab9 [ddc] Change JSArray rti property into a getter
- Avoids the need to set the value in the JSArray factories.
- Delays the construction of the rti value until it is actually needed.

Issue: https://github.com/dart-lang/sdk/issues/48585
Change-Id: Iecc28533453742eaeedc0cbc48053b7660e3eee3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/325450
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
2023-09-15 22:02:20 +00:00
rmasarovic 1cd720afe9 web_audio is not part sky_engine
Closes https://github.com/dart-lang/sdk/pull/53242

GitOrigin-RevId: 74b22f59aed05bce89b0d17d5e0aba5477c1060a
Change-Id: Iedb79fc297009cb4b046ebd57ff61b26939c1bbe
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/321340
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2023-09-14 10:33:17 +00:00
Vyacheslav Egorov 61b03b49b1 [vm] Disable dart:cli waitFor by default
Per breaking change request we are now disabling
waitFor by default.

Users can still enable it by passing the flag:

     --enabled-deprecated-wait-for

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

TEST=standalone/io/wait_for_deprecation_test

CoreLibraryReviewExempt: standalone VM only change
Change-Id: Ied78f91344d15cb77e932514e2b752bb6ac5dc5d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/326021
Commit-Queue: Slava Egorov <vegorov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Michael Thomsen <mit@google.com>
2023-09-14 10:08:29 +00:00
Martin Kustermann 781a8ef9c0 [vm] Mark external methods used in Pointer.asTypedList() with resulting type
It allows the compiler to propagate this information in TFA - which
may be beneficial for cases when those methods aren't inlined.

TEST=ci

Change-Id: I55711806800e2a56e83a42cd51be705b68c3a4f3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/324701
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Tess Strickland <sstrickl@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2023-09-13 09:48:56 +00:00
Srujan Gaddam 4efb33e128 [dart:js_interop_unsafe] Rename extensions and make []/[]= take String properties
Strings are the most likely use case of getting and setting
properties, and therefore we should make that easier to use.
This CL also renames the extensions in dart:js_interop_unsafe
to a more relevant name and to avoid conflicts in dart:js_interop.

CoreLibraryReviewExempt: Backend-specific library.
Change-Id: Ia8ce6593167c648f9710b47cfe27f80c854be407
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/324572
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
2023-09-12 23:11:55 +00:00
Jackson Gardner 67f0d4daf0 Revert "[dart2wasm] Replace struct.new_default with struct.new for object"
This reverts commit 5a4b252252.

Reason for revert: Causing Flutter engine unit test failures, see https://github.com/dart-lang/sdk/issues/53506

Original change's description:
> [dart2wasm] Replace `struct.new_default` with `struct.new` for object
> allocation.
>
> When using the `struct.new_default` instruction for object allocation,
> fields are always nullable and mutable. By using the `struct.new`
> instruction instead, class fields can now have the same mutability and
> nullability in Wasm as declared in Dart. In addition, the class ID and
> type parameters (which are also stored in an object's struct), can now
> be immutable and nonnullable as well.
>
> To do this, object construction is now split into three functions:
> (1) Initializer: evaluates initializers for instance fields and
> constructor initializers (this constructor before super constructor).
> (2) Constructor body: executes the constructor body (super constructor
> before this constructor), with `this` pointed to the constructed object.
> (3) Constructor allocator: which calls (1), allocates the object using
> `struct.new`, then calls (2).
>
> Because fields now have the correct mutability and nullability in Wasm,
> this removes unnecessary null checks for nonnullable fields, and may
> allow for better optimisations by Binaryen.
>
> Fixes https://github.com/dart-lang/sdk/issues/51492
>
> Change-Id: Ib26046686f772a70509a870301217e9b1c91b77e
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/315820
> Commit-Queue: Jess Lally <jessicalally@google.com>
> Reviewed-by: Aske Simon Christensen <askesc@google.com>

Change-Id: I034d3acf3715abadc6811a7393ba780bee974329
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/325445
Commit-Queue: Martin Kustermann <kustermann@google.com>
Commit-Queue: Jackson Gardner <jacksongardner@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2023-09-12 20:16:56 +00:00
Brian Quinlan f0632629c3 [io/doc]: Provide more references to SocketOption.tcpNoDelay.
Bug: https://github.com/dart-lang/sdk/issues/52102
Change-Id: I759735acfb0a67a3c0e359d6cf4c0ecab97c6c2a
CoreLibraryReviewExempt: doc-only change
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/325443
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Brian Quinlan <bquinlan@google.com>
2023-09-12 18:15:08 +00:00
Lasse R.H. Nielsen c15f054809 Hide the existence of EfficientLengthIterable better.
The `EfficientLengthIterable` is an internal marker interface
that allows the SDK to more efficiently check, effectively,
`v is List || v is Set || v is Queue`, and some other
known internal types, which allows it to assume that `.length`
is efficient and doesn't iterate the iterable.

It's not intended for external use, but the current design
both has the name mentioned specifically in the declaration
of the public types `List`, `Set` and `Queue`,
and possibly allows the type to leak through the
least-upper-bound algorithm.

This change moves the mention of `EfficientLengthIterable`
from the public types to an anonymously named private type,
and ensures that the private type is never the result of
a least-upper-bound computation, by adding another
interface with the same depth that all the public
types implementing `EfficientLengthIterable` also implement.

(A longer term solution to `EfficientLengthIterable` looking
like it's a public name could be combining the collection-
related code from `dart:collection`, `dart:core` and
`dart:_internal` into a single `dart:_collection_impl`,
and exporting the relevant types from there. Then
we could make the interface be `_EfficientLengthIterable`
again.)

Change-Id: I717743f0ca253782162be0ad9ff05036fdf57159
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/322320
Reviewed-by: Nate Bosch <nbosch@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
2023-09-12 11:08:42 +00:00
Tess Strickland 3f53d22d43 [vm/compiler] Create leaf runtime entry for memmove.
Instead of making a StaticCall to _TypedListBase.nativeSetRange
inside _memMoveN, make a CCall to the memmove leaf runtime entry.

Rename _TypedListBase._nativeSetRange to _setClampedRange, since
it's now only used when per-element clamping is necessary.

Fix the load optimizer so that loads of unboxed fields from freshly
allocated objects do not have the tagged null value forwarded
as their initial post-allocation value.

TEST=co19{,_2}/LibTest/typed_data lib{,_2}/typed_data
     corelib{,_2}/list_test
     vm/cc/LoadOptimizer_LoadDataFieldOfNewTypedData

Issue: https://github.com/dart-lang/sdk/issues/42072
Change-Id: Ib82e24a5b3287fa53099fffd3b563a27d777507e
Cq-Include-Trybots: luci.dart.try:vm-aot-linux-debug-simarm_x64-try,vm-aot-linux-debug-x64-try,vm-aot-linux-debug-x64c-try,vm-kernel-linux-debug-x64-try,vm-kernel-precomp-linux-debug-x64-try,vm-linux-debug-x64-try,vm-linux-debug-x64c-try,vm-mac-debug-arm64-try,vm-aot-linux-release-simarm_x64-try,vm-aot-linux-release-x64-try,vm-aot-mac-release-arm64-try,vm-aot-msan-linux-release-x64-try,vm-msan-linux-release-x64-try,vm-aot-tsan-linux-release-x64-try,vm-tsan-linux-release-x64-try,vm-linux-release-x64-try,vm-mac-release-arm64-try,vm-kernel-precomp-linux-release-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/324080
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
2023-09-11 21:25:09 +00:00
Brian Quinlan 8a91749e42 Fix parsing of folded header field values.
Bug: https://github.com/dart-lang/sdk/issues/53227
Bug: https://github.com/dart-lang/sdk/issues/53185
Change-Id: Ibbdbdf9c8f2875e8f687244982810fffee20e69c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/320920
Commit-Queue: Brian Quinlan <bquinlan@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2023-09-11 21:13:58 +00:00
Ryan Macnak a4381f127c [vm, lib] Fix out-of-bounds access in BigInt.>>.
The library code and the intrisic code disagreed about the capacity of the result digits array. Compare similar adjustment for <<.

TEST=ci
Change-Id: I81395a242965d53de3a30f87637a6f1588300969
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/325122
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2023-09-11 21:05:38 +00:00
Nicholas Shahan 027f57227f [ddc, dart2js] Add results cache to isSubtype
Optimize repetitive calls to isSubtype with a caches to store pairwise
results.

There are currently two caches for sound and unsound results but in the
future that can be combined into a single cache once the library is
aware of error reporting. That single cache could stores "pass", "fail", 
or "fails when sound mode but passes in unsound null safety".

Issue: https://github.com/dart-lang/sdk/issues/48585
Change-Id: I49e5794703fd58f1b2bba50e426e25146800fbb8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/323707
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
2023-09-08 18:39:53 +00:00
Srujan Gaddam fedc687bd3 [dart:js_interop] Add toJSProxyOrRef
Adds a conversion function on List<JSAny?> so that users can
modify the original list and have those changes carry forward
to the array. Creates a proxy object for dart2wasm when the
list is not a JSArrayImpl. This proxy uses handler methods and
the fact that Array methods are generic to provide an Array
interface. Also fixes a small issue in the exporting so that
toJS'd function types have a valid return type.

CoreLibraryReviewExempt: Backend-specific library.
Change-Id: I00f453aa82dd19f2913820579eb2675b799288d3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/323446
Commit-Queue: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2023-09-07 22:58:22 +00:00
MarkZ dacf4a8f46 [ddc] Cleaning up extraneous null checks in runtime.
Change-Id: Ia32b15ec9ac572332da7904e94ec9c9615bf3de1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/324842
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Mark Zhou <markzipan@google.com>
Auto-Submit: Mark Zhou <markzipan@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
2023-09-07 22:57:39 +00:00
Nicholas Shahan c4d2f64dd8 [ddc] Avoid unnecessary cast as Object
Change-Id: I96ffb4e91bf1656818fd5a71077f034a1acd1b93
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/324641
Commit-Queue: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Mark Zhou <markzipan@google.com>
2023-09-07 21:20:44 +00:00
Jess Lally 5a4b252252 [dart2wasm] Replace struct.new_default with struct.new for object
allocation.

When using the `struct.new_default` instruction for object allocation,
fields are always nullable and mutable. By using the `struct.new`
instruction instead, class fields can now have the same mutability and
nullability in Wasm as declared in Dart. In addition, the class ID and
type parameters (which are also stored in an object's struct), can now
be immutable and nonnullable as well.

To do this, object construction is now split into three functions:
(1) Initializer: evaluates initializers for instance fields and
constructor initializers (this constructor before super constructor).
(2) Constructor body: executes the constructor body (super constructor
before this constructor), with `this` pointed to the constructed object.
(3) Constructor allocator: which calls (1), allocates the object using
`struct.new`, then calls (2).

Because fields now have the correct mutability and nullability in Wasm,
this removes unnecessary null checks for nonnullable fields, and may
allow for better optimisations by Binaryen.

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

Change-Id: Ib26046686f772a70509a870301217e9b1c91b77e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/315820
Commit-Queue: Jess Lally <jessicalally@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
2023-09-07 09:52:57 +00:00
Aske Simon Christensen 36d6676833 [dart2wasm] Use Wasm array for type arguments in interface type
This avoids the overhead of Dart lists in subtype checks. It also
alleviates a potential source of infinite recursion by avoiding some
list operations with implicit type checks inside the type check code
(though there are still more of these).

With this change, we no longer have the const object cycle between
the empty list of `_Type` objects and the interface type object for
`_Type`. In combination with the the `struct.new` optimization, this
enables type argument fields to become non-nullable and immutable.

Change-Id: Ib46ea70a078a0c580713090163fecd63fe363bd9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/322900
Commit-Queue: Aske Simon Christensen <askesc@google.com>
Reviewed-by: Jess Lally <jessicalally@google.com>
2023-09-07 05:29:30 +00:00
Aske Simon Christensen 3a72c7a56e [dart2wasm] Support initial value and literals for Wasm object arrays
Change-Id: I6de2c1f507623afac40dab0b1601582569ef1129
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/322760
Reviewed-by: Jess Lally <jessicalally@google.com>
2023-09-07 05:29:30 +00:00
asiva f7ef52616a [IO] - Use try/catch in lookupAddresses instead of Future error.
Applying patch from @aam for using try/catch in lookupAddresses instead
of Future error.

This will be cherry picked into the stable branch to ensure we
address the expedient issue in https://github.com/dart-lang/sdk/issues/53334

TEST=new test added.

Change-Id: Ia5375cbd118d8d6437cf6869383f173cab48aa3f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/323684
Commit-Queue: Siva Annamalai <asiva@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2023-09-06 18:39:14 +00:00
Vyacheslav Egorov c121db286a [lib] Improve IndexedIterable performance on VM
* Check against raw `EfficientLengthIterable` instead of specifying
  its type parameter. Both checks are equivalent in this context as
  `EfficientLengthIterable` is an internal marker interface and an
  instance of `Iterable<T>` can never be an instance of
  `EfficientLengthIterable` but not an instance of
  `EfficientLengthIterable<T>`.
  VM compiler is currently not good enough to eliminate the
  `is` check if involves an uninstantiated type
  (see https://dartbug.com/53445).
* Force inlining of `IndexedIterable` factory,
  `IndexedIterable.get iterator` and `IterableExtensions.indexed`.

These changes significantly reduce overhead of for-in-indexed
when compared to baseline classical loop: before these changes
for-in-indexed is 13x slower than classical loop, after these
changes it is only 2.8x slower.

Performance comparison was using the following benchmark kernels:

```dart
final list = List<int>.generate(10000, (i) => i);

// For for-in-indexed
var result = 0;
for (var (i, e) in list.indexed) {
  result ^= (i & e);
}

// For classical loop
var result = 0;
for (var i = 0; i < list.length; i++) {
  result ^= (i & list[i]);
}
```

CoreLibraryReviewExempt: No API changes, VM specific optimisations.
Change-Id: Ic935a2aab2eda0837981184d872ee1eeef89ee7a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/324461
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2023-09-06 14:09:11 +00:00
Ryan Macnak b8ee3a9996 [build] Don't export all symbols to the dynamic table.
We were exporting all symbols to the dynamic table so that they could be looked up using `dladdr` for the profiler and backtracer. The symbols include our statically-linked libcxx, which can create trouble when another DSO has a different version of libcxx. Now we export only the VM embedding API functions (`Dart_*`) and use a specially produced table to do the symbolization.

TEST=runtime/tests/vm/dart/exported_symbols_test.dart
TEST=runtime/tests/vm/dart/symbolized_crash_test.dart
Bug: https://github.com/dart-lang/sdk/issues/53267
Change-Id: I2ee494fba86f67127ba0f6f402622f01a4662207
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/323702
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2023-09-05 21:47:59 +00:00
Ryan Macnak 72e8b555aa [vm, compiler] Add TestRangeInstr.
- Avoid Smi tagging for CID checks.
 - Use one branch for CID range checks.

dart2js.aot.arm64 20744832 -> 20690216 (-54k)

TEST=ci
Change-Id: I0690bd98774ffc2f24758b1a303c605b57da65b0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/323231
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2023-09-05 19:56:07 +00:00
Tess Strickland b94d3f730d [vm/compiler] Move setRange bounds checking entirely into Dart.
The bounds checking was implemented in Dart previously, but this
removes _checkSetRangeArguments, inlining it into
_TypedListBase.setRange, renames _checkBoundsAndMemcpyN to _memMoveN
since it no longer performs bounds checking, and also removes the now
unneeded bounds checking from the native function TypedData_setRange.

TEST=co19{,_2}/LibTest/typed_data lib{,_2}/typed_data
     corelib{,_2}/list_test

Issue: https://github.com/dart-lang/sdk/issues/42072
Cq-Include-Trybots: luci.dart.try:vm-aot-linux-debug-simarm_x64-try,vm-aot-linux-debug-x64-try,vm-aot-linux-debug-x64c-try,vm-kernel-linux-debug-x64-try,vm-kernel-precomp-linux-debug-x64-try,vm-linux-debug-x64-try,vm-linux-debug-x64c-try,vm-mac-debug-arm64-try,vm-aot-linux-release-simarm_x64-try,vm-aot-linux-release-x64-try,vm-aot-mac-release-arm64-try,vm-linux-release-x64-try,vm-mac-release-arm64-try,vm-kernel-precomp-linux-release-x64-try
Change-Id: I85ec751708f603f68729f4109d7339dd8407ae77
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/324102
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
2023-09-05 17:10:51 +00:00
Tess Strickland c93f924c82 [vm/compiler] Further optimize setRange on TypedData receivers.
When setRange is called on a TypedData receiver and the source is also
a TypedData object with the same element size and clamping is not
required, the VM implementation now calls _boundsCheckAndMemcpyN for
element size N. The generated IL for these methods performs the copy
using the MemoryCopy instruction (mostly, see the note below).

Since the two TypedData objects might have the same underlying
buffer, the CL adds a can_overlap flag to the MemoryCopy instruction
which checks for overlapping regions. If can_overlap is set, then
the copy is performed backwards instead of forwards when needed
to ensure that elements of the source region are read before
they are overwritten.

The existing uses of the MemoryCopy instruction are adjusted as
follows:
* The IL generated for copyRangeFromUint8ListToOneByteString
  passes false for can_overlap, as all uses currently ensure that
  the OneByteString is non-external and thus cannot overlap.
* The IL generated for _memCopy, used by the FFI library, passes
  true for can_overlap, as there is no guarantee that the regions
  pointed at by the Pointer objects do not overlap.

The MemoryCopy instruction has also been adjusted so that all numeric
inputs (the two start offsets and the length) are either boxed or
unboxed instead of just the length. This exposed an issue
in the inliner, where unboxed constants in the callee graph were
replaced with boxed constants when inlining into the caller graph,
since withList calls setRange with constant starting offsets of 0.
Now the representation of constants in the callee graph are preserved
when inlining the callee graph into the caller graph.

Fixes https://github.com/dart-lang/sdk/issues/51237 by using TMP
and TMP2 for the LDP/STP calls in the 16-byte element size case, so no
temporaries need to be allocated for the instruction.

On ARM when not unrolling the memory copy loop, uses TMP and a single
additional temporary for LDM/STM calls in the 8-byte and 16-byte
element cases, with the latter just using two LDM/STM calls within
the loop, a different approach than the one described in
https://github.com/dart-lang/sdk/issues/51229 .

Note: Once the number of elements being copied reaches a certain
threshold (1048576 on X86, 256 otherwise), _boundsCheckAndMemcpyN
instead calls _nativeSetRange, which is a native call that uses memmove
from the standard C library for non-clamped inputs. It does this
because the code currently emitted for MemoryCopy performs poorly
compared to the more optimized memmove implementation when copying
larger regions of memory.

Notable benchmark changes for dart-aot:
* X64
  * TypedDataDuplicate.*.fromList improvement from ~13%-~250%
  * Uf8Encode.*.10 improvement from ~50%-~75%
  * MapCopy.Map.*.of.Map.* improvement from ~13%-~65%
  * MemoryCopy.*.setRange.* improvement from ~13%-~500%
* ARM7
  * Uf8Encode.*.10 improvement from ~35%-~70%
  * MapCopy.Map.*.of.Map.* improvement from ~6%-~75%
  * MemoryCopy.*.setRange.{8,64} improvement from ~22%-~500%
    * Improvement of ~100%-~200% for MemoryCopy.512.setRange.*.Double
    * Regression of ~40% for MemoryCopy.512.setRange.*.Uint8
    * Regression of ~85% for MemoryCopy.4096.setRange.*.Uint8
* ARM8
  * Uf8Encode.*.10 improvement from ~35%-~70%
  * MapCopy.Map.*.of.Map.* improvement from ~7%-~75%
  * MemoryCopy.*.setRange.{8,64} improvement from ~22%-~500%
    * Improvement of ~75%-~160% for MemoryCopy.512.setRange.*.Double
    * Regression of ~40% for MemoryCopy.512.setRange.*.Uint8
    * Regression of ~85% for MemoryCopy.4096.setRange.*.Uint8

TEST=vm/cc/IRTest_Memory, co19{,_2}/LibTest/typed_data,
     lib{,_2}/typed_data, corelib{,_2}/list_test

Issue: https://github.com/dart-lang/sdk/issues/42072
Issue: b/294114694
Issue: b/259315681

Change-Id: Ic75521c5fe10b952b5b9ce5f2020c7e3f03672a9
Cq-Include-Trybots: luci.dart.try:vm-aot-linux-debug-simarm_x64-try,vm-aot-linux-debug-simriscv64-try,vm-aot-linux-debug-x64-try,vm-aot-linux-debug-x64c-try,vm-kernel-linux-debug-x64-try,vm-kernel-precomp-linux-debug-x64-try,vm-linux-debug-ia32-try,vm-linux-debug-simriscv64-try,vm-linux-debug-x64-try,vm-linux-debug-x64c-try,vm-mac-debug-arm64-try,vm-mac-debug-x64-try,vm-aot-linux-release-simarm64-try,vm-aot-linux-release-simarm_x64-try,vm-aot-linux-release-x64-try,vm-aot-mac-release-arm64-try,vm-aot-mac-release-x64-try,vm-ffi-qemu-linux-release-riscv64-try,vm-ffi-qemu-linux-release-arm-try,vm-aot-msan-linux-release-x64-try,vm-msan-linux-release-x64-try,vm-aot-tsan-linux-release-x64-try,vm-tsan-linux-release-x64-try,vm-linux-release-ia32-try,vm-linux-release-simarm-try,vm-linux-release-simarm64-try,vm-linux-release-x64-try,vm-mac-release-arm64-try,vm-mac-release-x64-try,vm-kernel-precomp-linux-release-x64-try,vm-aot-android-release-arm64c-try,vm-ffi-android-debug-arm64c-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/319521
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
2023-09-04 14:38:27 +00:00
Nicholas Shahan 83bbef0dba [dart2js, ddc] Avoid multiple _getKind() calls
Add a local variable for the result.

Change-Id: Iff4002ecd3d491c9b12b3e7baf98394612983520
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/323710
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
2023-09-01 21:16:08 +00:00
Nicholas Shahan 4b3e1a234d [ddc] Avoid casts to Rti
Implicit downcasts from dynamic were accidentally added in this
code that is only exercised by DDC.

Change-Id: I8514b0d8c09a76ac58dec0faed853ce007a144c7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/323709
Reviewed-by: Mayank Patke <fishythefish@google.com>
2023-09-01 21:16:08 +00:00
Nicholas Shahan b6c90d027b [ddc] Avoid Object casts in JsArray constructors
Implicit downcasts from dynamic were accidentally introduced
when changing to use the `jsObjectSetPrototypeOf()` helper.

Change-Id: Idda8c553b4aa0f6c3387f8c6682c23938c7959a2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/323708
Reviewed-by: Mark Zhou <markzipan@google.com>
2023-09-01 21:16:08 +00:00
Stephen Adams 42fbb693f3 [js_runtime] NullError always reports as a failed null check
Bug: b/244438673
Change-Id: Iaccfe428b4db2a8d0f910d5028aed77ac5d5ea80
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/306912
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2023-09-01 00:05:09 +00:00
Stephen Adams 565919a80f [js_runtime] Clean up String.trim{Left,Right}
- Use the standardized JavaScript names `trimStart` and `trimEnd`.
- Remove IE11 polyfill.

Change-Id: I9a469b8bf076efd16ef06b88c7fa111784054bb7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/323300
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2023-08-31 19:06:29 +00:00
MarkZ d4261d12ff [ddc] Adding a flag for new loadLibrary timing semantics.
This change helps us incrementally roll out changes to breaking tests internally.

Change-Id: I686b76ebf35816db8f875eccc935b957c81104fd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/323433
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Mark Zhou <markzipan@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2023-08-31 15:56:29 +00:00
Vyacheslav Egorov 46ac1f653f [vm] Treat Future.then(..., onError:...) as catch all handler
Commit a52f2b9 which reworked awaiter stack unwinding and its
integration with debugger introduced the following regression:
it stopped treating `Future` listeners which had both `onValue`
and `onError` callbacks as catch all exception handlers. Only
listners with `onError` callback (those created with
`Future.onError`) were treated as a catch all handler.

This meant that debugger started to treat exceptions in the
code below as uncaught:

```
Future<void> foo() {
  await 0;
  throw '';
}

await foo().then(..., onError: (e, st) {

});
```

This change fixes this regression by checking if
`FutureListener.state & stateCatchError != 0` instead of
more narrow `FutureListener.state == stateCatchError` which
only detects listeners which only catch errors but do not
handle values. The new predicate matches
`FutureListener.handlesError`.

This relands 38e0046cad
with a fix to ensure that we correctly detect `onError`
callbacks which simply forward to a suspended async
function. We do this by marking FutureListener's that originate
from `await` using a bit in the state.

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

TEST=service/pause_on_unhandled_async_exceptions{_zones,}_test

Fixed: 53334
CoreLibraryReviewExempt: No fundamental changes to _FutureListener implementation, just additional bit to detect that this listener originates from await
Change-Id: I90385fc619cbb52925e075dd5c7b171a31ca4cab
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/323481
Commit-Queue: Slava Egorov <vegorov@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2023-08-31 11:47:54 +00:00
Ryan Macnak 54faa31964 [standalone, io] Don't register service extensions in product mode.
dart2js.aot.x64 20942544 -> 20852448 (-90k)

TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/45469
CoreLibraryReviewExempt: VM-only
Change-Id: I5ee6a4019af1fa4a0815ac05a42bb4883d74d8a3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/323503
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2023-08-30 21:46:17 +00:00
Aske Simon Christensen e2971da563 [dart2wasm] Consolidate runtime type classes for bottom and top types
This merges the representations for the `Null` and `Never` types into
a single `_BottomType` class and for the `Object`, `Object?`,
`dynamic` and `void` types into a single `_TopType` class.

Since the merged classes behave identically in subtype checking apart
from nullability, this simplifies subtype checking.

Also makes the runtime type representations for these types plus
`Function`, `Function?`, `Record` and `Record?` singletons in order to
simplify their equality and `hashCode`.

Change-Id: Iad51d1042d0f2f01c1190ba3f63edaeb32dac1dd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/320540
Reviewed-by: Ömer Ağacan <omersa@google.com>
Commit-Queue: Aske Simon Christensen <askesc@google.com>
2023-08-30 08:54:38 +00:00
Aske Simon Christensen adb2be018f [dart2wasm] Factor isSubtype to compare nullabilities first
Factor `isSubtype` into a comparison of nullabilities followed by a
comparison of the types ignoring their nullabilities. This simplifies
the flow and prepares for a more direct dispatch of the comparison
based on type categories.

Change-Id: I86c8c49783c9b6cfc43e5193fd30008a2e7b34ba
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/319983
Reviewed-by: Ömer Ağacan <omersa@google.com>
2023-08-30 08:54:38 +00:00
Nicholas Shahan 3a65ac91f1 [ddc] Cleanup old "dartdevc" build targets
Use the new "ddc" targets everywhere and delete
the old targets.

Change-Id: I89d3351006a2c3eb0d1b9d526b868cbb676dce6b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/315561
Commit-Queue: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2023-08-29 21:33:48 +00:00
Derek Xu 2e6203df1f [SDK] Add frontend_server AOT snapshot to the SDK
The size of the AppJIT snapshot that is already in the SDK is around
44.53 MB. The size of this new AOT snapshot is around 14.57 MB. We
temporarily need to have both snapshots in the SDK, but we plan on
removing the AppJIT snapshot.

Change-Id: I1247f0ecbd3d05d18d22c8b36ac078e26de2c183
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/322180
Commit-Queue: Derek Xu <derekx@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2023-08-25 20:29:09 +00:00
Liam Appelbe e8d7425c4e [vm/ffi] Closure callbacks for sync callbacks
Bug: https://github.com/dart-lang/sdk/issues/52689
Change-Id: I54be397cfbf8519fe5b5a51b793fe46d602124d9
Fixes: https://github.com/dart-lang/sdk/issues/52689
Bug: https://github.com/dart-lang/sdk/issues/53096
TEST=isolate_local_function_callbacks_test.dart, plus generated tests and additions to existing tests
CoreLibraryReviewExempt: The isolate and FFI packages are VM-only
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/317060
Commit-Queue: Liam Appelbe <liama@google.com>
Reviewed-by: Liam Appelbe <liama@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
2023-08-25 03:35:44 +00:00
Mayank Patke 5be5d29cd7 [dart2js] Implement await runtime check using kernel transformation.
This replaces the lowering during SSA which requires manually
registering impacts in multiple places. Instead, we use a kernel
transformation to invoke a helper function which implements the
specified semantics.

Change-Id: I58fd11f6d4d1e4f90d00fa826453de024c8686aa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/319901
Reviewed-by: Stephen Adams <sra@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Mayank Patke <fishythefish@google.com>
2023-08-23 22:58:49 +00:00
Parker Lougheed a0d8796c94 [dart:html] Fix incorrect parameter mention in drawImageScaledFromSource docs
Closes https://github.com/dart-lang/site-www/issues/5138

Bug: https://github.com/dart-lang/site-www/issues/5138
CoreLibraryReviewExempt: Only updating a doc comment in dart:html which is web specific.
Change-Id: I58bd36764a6a86cfb7c30dbc60070025dfb2e51c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/322181
Commit-Queue: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Srujan Gaddam <srujzs@google.com>
2023-08-23 00:25:29 +00:00
Slava Egorov f5d3814455 [ffi] Update comment for NativeFinalizer
Closes https://github.com/dart-lang/sdk/pull/53306

GitOrigin-RevId: d91cb731ae74042a3e210bc1aaa1bf3d0beafcc0
Change-Id: Id38ceb846009dfebbe8b9e3c05d9e79b7a458a74
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/322064
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2023-08-22 11:17:47 +00:00
Parker Lougheed b199896be5 Mark packageConfigSync and resolvePackageUriSync as released in 3.2
Closes https://github.com/dart-lang/sdk/issues/53285

Bug: https://github.com/dart-lang/sdk/issues/53285
CoreLibraryReviewExempt: dart:isolate is only supported on the VM and this CL only changes a Since annotation.
Change-Id: If525aed83d3ccd69558f348e6a4a287a35b1d2ca
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/322040
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2023-08-22 08:05:19 +00:00
Srujan Gaddam a38fb595cf [dart:js_interop] Add JS types for Symbol/BigInt
Adds JSSymbol and JSBigInt and erases to either their respective
interceptor types in the JS backends or JSValue in dart2wasm.

CoreLibraryReviewExempt: Backend-specific library.
Change-Id: Ib2c70d22a70c6308733cd170b91eafa8ec3b3aeb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/321749
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2023-08-21 21:54:15 +00:00
Srujan Gaddam c738fe1d7b [ddc] Add BigInt and Symbol interceptors
Adds the same interceptors from dart2js as JsPeerInterfaces
and handles typeof differences in getReifiedType. These must
be JsPeerInterfaces so that Object members can be stored in
their prototype. Tests are added so that dart2js and ddc are
consistent.

Change-Id: Iadc3dd26957c0a21b4039c49c1c1ff162ae286e6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/321748
Reviewed-by: Stephen Adams <sra@google.com>
2023-08-21 21:54:15 +00:00
Nicholas Shahan 7b6d9fb46e [ddc] Cleanup temporary fix in strSafe
Fix allowed it to accept null but it should never be called with a
nullable value.

Change-Id: I03b5d9b4906e9e4557a4f2720350c0c8176fec53
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/320841
Commit-Queue: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Auto-Submit: Nicholas Shahan <nshahan@google.com>
2023-08-21 17:42:33 +00:00
Alexander Aprelev 40894511bb [vm/compiler] Tag non-ffi force-optimized functions idempotent.
This is follow-up to https://dart.googlesource.com/sdk/+/54234979a32368c2e6fe5a45468aae939ccc7700

BUG=https://github.com/dart-lang/sdk/issues/38985
TEST=ci
CoreLibraryReviewExempt: vm-specific pragma
Change-Id: Ib24d283634708902bbabfc750c7a4496745e69ab
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/321300
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2023-08-18 18:27:58 +00:00
Aske Simon Christensen da758538d3 [dart2wasm] Make the index field in _HashFieldBase nullable
This is to allow `_HashFieldBase` to be used for immutable maps and
sets (which initialize their index lazily) without using an intrinsics
hack to allow a non-nullable field to be `null`.

This change is necessary for the upcoming optimization that will
use non-nullable Wasm types for non-nullable Dart fields.

Even though this code is shared with the VM, the change doesn't affect
VM performance in practice, since the VM compiler is able to infer
that the field is always non-null. Benchmark runs see no measurable
performance difference.

Change-Id: I3ba2f78044f965473a0ab10ddf864c78e7095634
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/321400
Commit-Queue: Aske Simon Christensen <askesc@google.com>
Reviewed-by: Jess Lally <jessicalally@google.com>
2023-08-18 10:19:22 +00:00
Martin Kustermann 851e696270 [vm] Allow inlining of typed data view factories
TEST=ci

Change-Id: I88b9661437ad63d0fe2e56c30c621f59e84d8294
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/321480
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2023-08-18 07:37:08 +00:00
Stephen Adams 9d15643d7a [js_runtime] Fix for #53105
Avoid trying to add a property to a non-object exception value to
cache the stack trace.

In "use strict" mode this is an error.

Otherwise the property is added to an ephemeral Object and then lost.
The observable behaviour is unchanged - returning a fresh
`_StackTrace` object each time.

Bug: #53105
Change-Id: I406ff14db4ed24b71e0cfe95cd87783621a5b809
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/321622
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2023-08-18 01:24:21 +00:00
Nicholas Shahan aac40f1776 [ddc] Fix runtime FutureOr normalization
Normalize when the type argument is nullable.

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

Change-Id: Iaa8b2f65b300962b1fd5d0d0c315d936b045cace
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/321601
Commit-Queue: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Mark Zhou <markzipan@google.com>
2023-08-18 00:58:04 +00:00
Nicholas Shahan 7a93d80473 [ddc] Isolate function signature per app
Fix function signatures from one app leaking into another app when
communicating via JavaScript interop.

Change-Id: Iba881f78bbe5444e3888c55fd317b8eda8e19f18
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/321520
Commit-Queue: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Mark Zhou <markzipan@google.com>
2023-08-17 22:56:57 +00:00
Lasse R.H. Nielsen 4a38cb09f5 Fix behavior of Stream.empty.
The underlying subscription would invoke the `onDone` handler even
after a `cancel`.
It also forgot to register the `onDone` callback in the zone before
running it.

Tweaked the behavior of `pause` and `resume` to make sure they make
no difference after `cancel` or after a done event has been omitted.
(Test now checks that the behavior matches other streams.)

Fixes #53201

Bug: https://dartbug.com/53201
Change-Id: Iba35be2c4b44b5c4ec97d5a4dbcd3aff7fee8b75
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/320561
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
2023-08-17 15:26:59 +00:00
Ömer Sinan Ağacan 8c5f895cac [dart2wasm, vm] Use list implementation class methods in List factories
In dart2wasm, implementation class methods for `filled` and `generate`
are much faster:

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

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

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

Tested: Existing tests.
Change-Id: Ib24e5be687df325a43d335657a7142f7d9f980ce
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/321040
Commit-Queue: Ömer Ağacan <omersa@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2023-08-17 12:08:30 +00:00
Martin Kustermann 554cc8c002 [vm] Mark various FFI load/store/asTypedList as idempotent, allowing them to be inlined
This will allow us to create a better baseline for our MemoryCopy
benchmark optimizations.

TEST=ci

Change-Id: I1ca3928e72fbe49d0239b64ea4f4b78ca0b0a3bb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/321160
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2023-08-16 20:28:48 +00:00
Derek Xu f6bc011b37 [dart:developer] Improve documentation of Service.getIsolateId and Service.getObjectId
This CL addresses https://dart-review.googlesource.com/c/sdk/+/317220/comment/7e05218f_882e21cd/

CoreLibraryReviewExempt: This CL does not change any APIs, it just adds
an @Since annotation to a method.
Change-Id: I4187c50498668553806bb2eee6584114363b417a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/320900
Reviewed-by: Ben Konyi <bkonyi@google.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
Commit-Queue: Derek Xu <derekx@google.com>
2023-08-16 15:13:47 +00:00
Srujan Gaddam ad62f6033b [dart:js_interop] Relabel globalJSObject as globalContext and point to object used in static interop lowerings
This is likely more useful than returning globalThis always. It
allows users to workaround issues with lowerings without having
to worry about browser compatibility differences.

CoreLibraryReviewExempt: Backend-specific library.
Change-Id: I01479211fe6b573c845de5b134d36338c40fc10d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/319301
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
2023-08-15 20:57:17 +00:00