Commit graph

11301 commits

Author SHA1 Message Date
Lasse R.H. Nielsen 0234a8f17f Fix bad link in updated docs.
CoreLibraryReviewExempt: Comment only.
Change-Id: Ibaec3812e430ba0c8644315fba062bca62f3c173
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/331241
Auto-Submit: Lasse Nielsen <lrn@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
Reviewed-by: Alexander Thomas <athom@google.com>
2023-10-20 14:47:26 +00:00
Lasse R.H. Nielsen 0ecb9ba545 Update documentation on fromEnvironment constructors.
CoreLibraryReviewExempt: Comments only.
Change-Id: If2e080764bc98ee6cb7fe31dffe12c66144c7352
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/331182
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2023-10-20 07:57:18 +00:00
Nicholas Shahan 8a1e69063e [ddc] Update for extra null safety checks in RTI
- In development mode (DDC) the extra null safety errors will be thrown.
- Remove extra code paths that called unsound helpers.
- Fix expectations in weak_null_safety_errors_test.dart.

Change-Id: I107c602b0ae38b13038e501564cba9b8cfc58e70
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/329568
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
2023-10-19 21:32:15 +00:00
Mayank Patke f9c3e48406 [dart2js] Add user-definable callback to report null safety diagnostics
Change-Id: Id57efb9fb6f329f8e0b81b773ec27598a2db862a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/328761
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Mayank Patke <fishythefish@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
2023-10-19 20:29:49 +00:00
Mayank Patke 918a47c973 [dart2js, ddc] Add support for extra null safety checks in RTI.
Change-Id: I68d6b8d057e738baa9f7155ec17a8c7681f507b8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/325921
Reviewed-by: Nicholas Shahan <nshahan@google.com>
2023-10-19 20:29:49 +00:00
Nate Bosch d7af8ef846 Remove indirection in Timer example
The example was originally written without a `main`, and with an example
using `Duration.operator *`. An update added a call to the example
method from a new `main`, removed the usage of `Duration.operator *`,
but did not remove the prose reference.

- Remove the sentence mentioning that the duration can be const or
  computed.
- Remove the intermediate `scheduleTimeout` method, move the `Timer`
  construction to `main`. This removes any consideration of `Duration`
  vs `int milliseconds` which had been added in an attempt make the docs
  more focused on `Timer` than `Duration`.

R=lrn@google.com

CoreLibraryReviewExempt:Documentation change.
Change-Id: I26bb4e12910eb50cf5975b8a6573701a5a862070
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/330980
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Nate Bosch <nbosch@google.com>
2023-10-19 18:26:49 +00:00
Mopriestt ddc5894d3d Unify splay tree iterators and interables constructor argument names.
Closes https://github.com/dart-lang/sdk/pull/53706

GitOrigin-RevId: 4743ba3035efd4b458300a501e9fdefc5aaf0544
Change-Id: I4753b52e3fd73bd59b3ff56860e4135c47476fa9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/329721
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
2023-10-19 14:07:37 +00:00
なつき e285a57248 [dart2js] Fix compatiblity with Node.js 21
Closes https://github.com/dart-lang/sdk/pull/53796

GitOrigin-RevId: caeeb52bb832c401a22d7ba3410f42cb50d6c8c6
Change-Id: I145ecca62875a82f348ce1ea78fb935880d10688
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/330987
Reviewed-by: Stephen Adams <sra@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2023-10-19 03:46:18 +00:00
Mayank Patke 5a0ff4ceb1 [dart2js] Lower JS_GET_FLAG in phase 0b kernel transformer
Also adds `JS_FALSE` to replace uses of `JS_GET_FLAG(false)`. See the
doc comment for details.

Change-Id: I33f89f158c1955a19fa299f22c50d51e36ede3d8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/330171
Commit-Queue: Mayank Patke <fishythefish@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Nate Biggs <natebiggs@google.com>
2023-10-18 22:32:43 +00:00
Ömer Sinan Ağacan feb81fc63f [dart2wasm] Optimize some string operations to array.copy
Change-Id: Ic14396cd6843666dd8ebfd6db0ed6056ea7cacc0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/331043
Commit-Queue: Ömer Ağacan <omersa@google.com>
Reviewed-by: Jackson Gardner <jacksongardner@google.com>
2023-10-18 17:45:36 +00:00
Ömer Sinan Ağacan fa976d75be [dart2wasm] Simpify string handling in core
Now that we have our own `dart:convert` implementations in dart2wasm
targets (1) and the internal types are now internally public (2), this
simplifies some of the string implementation code by using the
implementation classes directly.

Note: stringref patch can be ignored, it's currently unused and I'm only
updating it to make it compile. It will be rewritten based on
`JSStringImpl` in [3].

To keep the CLs as small as possible, this CL does not do any of the
optimizations we can do now, such as optimizing
`OneByteString._setRange` to Wasm `array.copy` instructions. These will
be done in follow-up CLs.

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

Change-Id: I92918d58a565ad32f5a221430e02d81562f03b00
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/331040
Reviewed-by: Jackson Gardner <jacksongardner@google.com>
Commit-Queue: Ömer Ağacan <omersa@google.com>
2023-10-18 17:37:33 +00:00
Ömer Sinan Ağacan ce9e332bb1 [dart2wasm] Make typed data implementation classes internally public
This is a part of [1] and a continuation of [2].

- Make typed data implementation file a library, to allow importing it
  in `dart:convert` patch.

- Make SIMD implementation file a library, to allow importing it from
  the typed data library.

- Make typed data implementation classes internally public (available in
  other `dart:...` libraries).

- Relax `mayDefineRestrictedType` to allow implementing restricted types
  anywhere in the standard library implementation.

[1]: https://dart-review.googlesource.com/c/sdk/+/330121
[2]: https://dart-review.googlesource.com/c/sdk/+/330781

Change-Id: I70bc6869a20fd2479bee081cfceef27d6de19974
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/330783
Commit-Queue: Ömer Ağacan <omersa@google.com>
Reviewed-by: Jackson Gardner <jacksongardner@google.com>
2023-10-18 06:40:49 +00:00
Ömer Sinan Ağacan 555e965bb1 [dart2wasm] Duplicate VM's convert patch for dart2wasm targets
This copies VM's convert implementation in dart2wasm's default and JSCM
targets, to be able to optimize the implementation based on these
targets' typed data and string implementation classes.

An example optimization that specializes UTF-8 decoder to `_U8List` can
be seen in [1], which improves a real-world benchmark (extracted from
internal) from 220ms to 90ms. (-59%)

Another optimization is we will be using the browser's UTF8 and JSON
decoders in JSCM convert patch.

VM's convert patch is moved from vm_shared to vm, as it's no longer used
outside of VM.

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

Tested: existing tests.
Change-Id: I981070615a106e4f356ed8b292a29ec950bd4d97
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/330781
Reviewed-by: Jackson Gardner <jacksongardner@google.com>
Commit-Queue: Ömer Ağacan <omersa@google.com>
2023-10-18 06:39:59 +00:00
Brian Quinlan b04c5a433e Adds tests and documentation for print line ending behavior
Bug:https://github.com/dart-lang/sdk/issues/53161
Change-Id: I3f13af3cb852b3656341922b9656ec91fc413eed
Tested: documentation + unit test only
CoreLibraryReviewExempt: Only adds documentation and adds a unit test to verify existing behavior
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/323426
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Brian Quinlan <bquinlan@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2023-10-17 22:10:38 +00:00
Vyacheslav Egorov aa893870df [dart2js] Disable Timeline is performance.measure is absent
Change d8 preamble to remove performance.measure entirely.

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

Change-Id: I4588e08e9126a0d0f8010f7a7786484da876bc85
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/330110
Commit-Queue: Slava Egorov <vegorov@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Elliott Brooks <elliottbrooks@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
2023-10-17 20:23:43 +00:00
Brian Quinlan becd3e396c [io] Make _HttpDetachedIncoming fields private
Change-Id: If1253a21613f2ea2baa69c68f0999b56e5181322
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/330703
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Brian Quinlan <bquinlan@google.com>
2023-10-17 18:37:15 +00:00
Sam Rawlins 1b4ae5a7e1 Refer to unnamed constructors in doc comments with '.new'
Cleanup for https://github.com/dart-lang/dartdoc/issues/3531

This makes these comment references more idiomatic, I think
more readable, and supports dropping the leading `new ` syntax
in doc comments.

Change-Id: Id832ad14d9ea08fe03fe3125065755f49b1b93ed
CoreLibraryReviewExempt: doc comment only change
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/330683
Reviewed-by: Devon Carew <devoncarew@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2023-10-17 14:42:38 +00:00
Tess Strickland 4d1bdaaca9 Reland "[vm/compiler] Change MemoryCopy to also take untagged addresses."
This is a reland of commit 06d7a2352e

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

Also fixes the new tests on 32-bit architectures.

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

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

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

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

1) Combine _setKeepIsolateAlive/_getKeepIsolateAlive into
abstract bool _keepIsolateAlive.

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

Change-Id: I61a97f5ba35c3ff00ab4270b9f7a763968e703fc
TEST=CI (no behaviour changes)
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/330580
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Liam Appelbe <liama@google.com>
2023-10-17 01:54:00 +00:00
asiva 24155ef6f0 [IO/http] - Fix for https://github.com/dart-lang/sdk/issues/49930
Check for null 'bufferedData' even in the path when 'subscription' is
null. Should also fix https://github.com/dart-lang/sdk/issues/26379

TEST=ci

Change-Id: Iacc18c8a38e2c5b36c5234495d39cf20bfd8bac3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/330201
Reviewed-by: Brian Quinlan <bquinlan@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
2023-10-13 22:59:28 +00:00
Alexander Markov 5362d9536b Revert "[vm/compiler] Change MemoryCopy to also take untagged addresses."
This reverts commit 06d7a2352e.

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

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

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

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

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

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

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

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

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

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

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

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

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

Cq-Include-Trybots: luci.dart.try:vm-ffi-qemu-linux-release-arm-try,vm-eager-optimization-linux-release-x64-try,vm-linux-release-x64-try,vm-linux-debug-x64-try,vm-aot-linux-release-x64-try,vm-aot-linux-debug-x64-try
Change-Id: I563e0bfac5b1ac6cf1111649934067c12891b631
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/324820
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2023-10-13 19:06:30 +00:00
Brian Quinlan 0fa13d4627 [doc/io] Add documentation for HttpSession
Bug:https://github.com/dart-lang/sdk/issues/16228
Change-Id: I4e70c0b15af7325d9bfaba6dcee6b3a4c68639c1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/330169
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Brian Quinlan <bquinlan@google.com>
2023-10-13 17:59:08 +00:00
Stephen Adams 8ea74c0f2e [js_runtime] Use URLSearchParams to escape query parameters
Use URLSearchParams to escape query parameters.

- For large query parameters (>100KB), where escaping the parameters causes jank, this can be 2x-5x faster, reducing ~100ms pauses to nearer frame rate.

- For small query parameters (<100B) it can be slightly (10-20%) slower, but still well below 1 millisecond.


TEST=ci

Issue: #53712

Change-Id: I045bac7a067a658a58aaac4266409d526ccda774
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/329822
Commit-Queue: Stephen Adams <sra@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
Reviewed-by: Ömer Ağacan <omersa@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
2023-10-13 16:36:47 +00:00
Aske Simon Christensen 4090d3b909 [dart2wasm] Normalize FutureOr<T> as nullable when T is nullable
The type normalization rules specify that `FutureOr<T>?` is normalized
to `FutureOr<T>` when `T` is nullable. However, it's more practical
for subtype testing if the declared nullability on the runtime
representation of the `FutureOr` type reflects the true nullability
(nullable if the `FutureOr` is declared nullable or its type argument
is nullable), rather than being normalized as per the spec.

This changes the static and dynamic normalization rules in dart2wasm
thus and compensates by computing the proper spec normalization when
the type is converted to a string.

The added test exposed a number of bugs in DDC and the VM:

https://github.com/dart-lang/sdk/issues/53175
https://github.com/dart-lang/sdk/issues/53737
https://github.com/dart-lang/sdk/issues/53738

Change-Id: I0ad0a09fe935ccbd3eb65e6958c958d29e0bb088
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/320821
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Aske Simon Christensen <askesc@google.com>
2023-10-12 15:29:26 +00:00
Jens Johansen 73466729f3 [vm] Pass offset and script uri for expression compilation
This CL passes the offset and uri of the file (here called a script uri
as opposed to a library uri, the two will be different if we're in a
part) when doing expression compilation.

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

TEST=Existing tests.
CoreLibraryReviewExempt: Not changing SDK APIs.
Change-Id: I67ead461ab4bb9341424e693946f3e4afe35ce92
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/329322
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2023-10-12 10:22:38 +00:00
SULAPIS 5fa1830a38 Fix typo
Closes https://github.com/dart-lang/sdk/pull/53705

GitOrigin-RevId: 081385fa0e592688ffee1ecb9bd007828bf7e7c1
Change-Id: Ib4b843a5d14ef172a05adf7c2ea108e5691b6b68
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/329683
Commit-Queue: Alexander Thomas <athom@google.com>
Reviewed-by: Alexander Thomas <athom@google.com>
2023-10-12 07:54:48 +00:00
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