Commit graph

10063 commits

Author SHA1 Message Date
Lasse R.H. Nielsen 18f37dd8f3 Add extension name getter on Enum.
We use an extension getter instead of an instance getter because
it doesn't conflict with any potential existing or future enums
which want an element named `name`.
Keeping the namespace for enum elements open is a priority.
We currently only reserve `index` and `values`.

BUG: https://github.com/dart-lang/language/issues/1511

Fixes language issue #1511, which is a long-standing request,
and should replace a number of alternative implementations
which are based on parsing the `toString()`.


This version has two fields on the shared superclass, the index
and private name, and has a separate `toString` for each `enum` class
which hard-codes that enum's class name.

An earlier version had both `"name"` and `"ClassName.name"` as fields
to be able to reuse the same `toString` method on all enum classes,
but that cost too much for JS compiled code.
Even having just `ClassName.` as a field and then combining inside
`toString` requires more code to create the enum instances.
Instead this version hardcodes the `ClassName.` string once
in the `toString` method, which means each enum class has its own
toString (which can *potentially* be tree-shaken then.)

This still tree-shakes slightly worse than the previous implementation
where every enum class had its own `index` and `_name` fields
independent of each other, which could then be tree-shaken independently.
However, the `index` was already made an interface member with the
addition of the `Enum` interface, so code which accesses `.index`
on something of the `Enum` supertype could prevent tree-shaking of
all enum classes' `index` fields.
Likewise any general access to the "name" of an enum would necessarily
do the same for the name.
This CL makes up for some of that by sharing more implementation
between enum classes.

DartVM AOT CodeSize impact: ~0.15% regression on gallery (little less on big g3 app)

TEST= New tests added to enum_test.dart

Change-Id: Id25334e6c987f470f558de3c141d0e3ff542b020
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/210480
Commit-Queue: Lasse R.H. Nielsen <lrn@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2021-09-22 14:20:16 +00:00
Nate Bosch bcaa2a320c Add fixes for Remaining renames
Add fix definitions and tests for renamed class and top level constants in
`dart:developer` and `dart:io`.

Change-Id: I6851bd61c68fdcff461117fe8f2ab1c3890cb9df
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/214000
Auto-Submit: Nate Bosch <nbosch@google.com>
Reviewed-by: Lasse R.H. Nielsen <lrn@google.com>
Commit-Queue: Nate Bosch <nbosch@google.com>
2021-09-21 16:07:30 +00:00
Nicholas Shahan 85a12eac55 [ddc] Fix missing type variable bounds subtype check
When testing the subtype relation between two generic function types,
uninstantiated type variables can appear as an argument or return type
of one function while a concrete type appears in corresponding
position of the other function. A subtype relation can be established
if the bound of the type variable is a subtype of the concrete type.
For example given a type variable T with bound B and a concrete type
C we can say:

T <: C when T <: B <: C holds.

T <: B is true by the definition of interface subtypes `T extends B`.
This change adds a test for B <: C.

Add a new class used only when it appears we may need to test these
subtype relations. The class is used to plumb the bound information
of type variables further into the subtype check algorithm where it
is now tested.

Add a top level variable to index the total number of type arguments
seen during a subtype check through nested function types.

Change-Id: If6aa13e7b758f7fedcb5dbd8e09d366082198e61
Fixes: https://github.com/dart-lang/sdk/issues/38816
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/213527
Commit-Queue: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Mayank Patke <fishythefish@google.com>
2021-09-20 23:29:45 +00:00
Nicholas Shahan e8cd9f0c44 [ddc] Refactor _isInterfaceSubtype
Move the method body out of one giant JS foreign function and into
Dart code with small JS foreign function calls inside.

* Removes the confusion around what it actually means when we use
  Dart String interpolation within the JS function template.
* Highlights the operations that actually need the JS foreign
  function.
* Allows for syntax highlighting and automatic formatting of this
  code.
* Allows for IDE "jump to definition" for class members that were
  previously inside the template.

These changes were developed by diffing the compiled output to
ensure the changes were as minimal and inconsequential as possible.
Intentional diffs include:
* Add a required message argument to `dart.assertFailed()`.
* Add local variables for `varianceType`, `typeArg1`, and
  `typeArg2`.

The only other diff was the loop variable incrementing:
`++i` -> `i = i + 1`

Change-Id: I76a1522fa4950f05748f905e1aec32c8b7dd4670
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/213526
Commit-Queue: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Srujan Gaddam <srujzs@google.com>
2021-09-20 23:06:55 +00:00
Nicholas Shahan cf7d46097b [ddc] Refactor _isSubtype
Move the method body out of one giant JS foreign function and into
Dart code with small JS foreign function calls inside.

* Removes the confusion around what it actually means when we use
  Dart String interpolation within the JS function template.
* Highlights the operations that actually need the JS foreign
  function.
* Allows for syntax highlighting and automatic formatting of this
  code.
* Allows for IDE "jump to definition" for class members that were
  previously inside the template.

These changes were developed by diffing the compiled output to
ensure the changes were as minimal and inconsequential as possible.
The only diffs that appeared beyond the intentional addition of
the `t1Bound` and `t2Bound` local variables were:

* Using the top level variable for a type:
  `dart.nullable(core.Object)` -> `T$.ObjectN()`
* Loop variable incrementing:
  `i++` -> `i = i + 1`

Change-Id: I55fa3fa94b984c67b18a744837843d458231c4d0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/213525
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
2021-09-20 21:28:29 +00:00
Ben Konyi dc58616486 [ Timeline ] Don't try to log async timeline events when Dart stream is
disabled

Related to https://github.com/flutter/flutter/issues/90061

Change-Id: Ic59cf60fe7d861109647be1a6c193fd4b63a211d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/213780
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2021-09-17 18:49:21 +00:00
Sushant Chandla 2eb37e56ca Api Docs[core/int.dart]
The unsigned right shift was [implemented](https://github.com/dart-lang/language/issues/478#issuecomment-889181121)

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

GitOrigin-RevId: ec84d6886204a05906c11b6b1ebab023b8b33e38
Change-Id: Iafc195c8df212c8f78330f6ebef230daa6a6d280
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/213560
Reviewed-by: Kevin Moore <kevmoo@google.com>
Commit-Queue: Kevin Moore <kevmoo@google.com>
2021-09-15 22:47:04 +00:00
rnewquist 2917c1cb8f [io/http] Add a HTTP Client parameter on WebSocket.connect to allow a custom HTTP Client for web socket connections.
The WebSocket abstract class was changed to allow an optional parameter called customClient that takes in a HTTPClient and passes it to the WebSocket Implementation.
The WebSocket implementation takes the customClient, checks if its null, if its not null, it uses the customClient in place of the static HTTPClient that the WebSocket Implementation offers.
This custom client does not override the static HTTPClient, so all previous functionality remains the same when the customClient is not present.

TEST=testStaticClientUserAgentStaysTheSame() in web_socket_test.dart in standalone_2/standalone
TEST=new SecurityConfiguration(secure: true).runTests(); in web_socket_error_test.dart and web_socket_test.dart in standalone_2/standalone

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

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

GitOrigin-RevId: 58fed38baa606a8a492d3729190afa5009cc2409
Change-Id: I042b1e3fa7a4effed076c0deeec1f86af0dfe26d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/200262
Reviewed-by: Alexander Aprelev <aam@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2021-09-15 18:06:42 +00:00
Clement Skau cd7c9922eb [vm/ffi] Adds FFI transform for Handle -> Pointer.
This will automatically desugar FfiNative calls passing
NativeFieldWrapperClass1 handles to use Pointer when
the underlying native function expects a pointer.
E.g.:

```
class ClassWithNativeField extends NativeFieldWrapperClass1 {}

@FfiNative<IntPtr Function(Pointer<Void>)>('PassAsPointer')
external int passAsPointer(ClassWithNativeField obj);

passAsPointer(ClassWithNativeField());
// Becomes roughly:
// #t0 = PointerClassWithNativeField();
// passAsPointer(Pointer.fromAddress(getNativeField(#t0)));
// reachabilityFence(#t0);
```

TEST=Adds new tests in tests/ffi/ffi_native_test.dart.
Change-Id: I4460f9249803054f12be5d5ff34dbdf7c96567fd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/213260
Commit-Queue: Clement Skau <cskau@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
2021-09-15 12:47:35 +00:00
Riley Porter 0dd3c97147 Optimize js_util callConstructor for 0-4 arguments.
Some usages of `callConstructor` will have unnecessary checks
removed, when checks on the arguments can be elided. The
compilers will optimize further if they can.

Example optimizations: https://paste.googleplex.com/4594240957972480

Change-Id: I0e6e7e4d1268580cbfab84599b1c9da6fc64e7c7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/213114
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Commit-Queue: Riley Porter <rileyporter@google.com>
2021-09-13 22:43:10 +00:00
Mayank Patke a6c90f1601 [dart2js] Fix some unnecessary bailouts in inference.
Change-Id: If60fe11871da062c52265d821cbf0d7a1185e643
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/209845
Reviewed-by: Stephen Adams <sra@google.com>
2021-09-13 21:59:20 +00:00
Stephen Adams 089bebcae7 Tweak Duration.toString to be more web-friendly
Change-Id: I588e089124d5c2fc62caa19cc2206c81666d6e8e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/213183
Reviewed-by: Lasse R.H. Nielsen <lrn@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2021-09-13 18:19:00 +00:00
Clement Skau 7d467e8933 [vm] Adds args_n to FFI resolver.
This makes it more closely mirror the Dart_NativeEntryResolver,
and acts as an extra sanity check that signatures (roughly)
align between the FfiNative decl. and the native function.

TEST=Updated runtime/vm/dart_api_impl_test.cc

Change-Id: I40799dc583ec14db14dc453afed4e2d1eb06fced
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/212566
Commit-Queue: Clement Skau <cskau@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
2021-09-13 07:57:00 +00:00
Murtaza Raja 7c7f6623a9 typo: patter -> pattern in lib/core/pattern.dart
Closes https://github.com/dart-lang/sdk/pull/47198
https://github.com/dart-lang/sdk/pull/47198

GitOrigin-RevId: 647929b9ed24826261d37f60bd2180d79917e954
Change-Id: Ic857fffa8232e29f8ae5248bc7c4ce9264a090b5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/213220
Reviewed-by: Kevin Moore <kevmoo@google.com>
Commit-Queue: Kevin Moore <kevmoo@google.com>
2021-09-12 18:23:08 +00:00
Lasse R.H. Nielsen 64f06ac544 Fix bug in Duration.toString().
The `toString` called `(-this).toString()` recursively
for negative durations.
If instantiated with the minimal integer on native,
that call would recurse infinitely.

The code has been wrong since we removed arbitrary precision integers.

TEST= Add test for regression case, otherwise covered by existing tests.

Change-Id: Ifb58bbc5aee38ef760f9352aede1694b79bae931
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/212300
Commit-Queue: Lasse R.H. Nielsen <lrn@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2021-09-10 14:58:47 +00:00
Nate Bosch 828d1904e5 Rephrase bool getter doc
We want to avoid the "Returns" phrasing for getters.

Change-Id: Ia738c1566f720200a7b65a4ff441e1196129a6f1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/210286
Auto-Submit: Nate Bosch <nbosch@google.com>
Reviewed-by: Lasse R.H. Nielsen <lrn@google.com>
Commit-Queue: Lasse R.H. Nielsen <lrn@google.com>
2021-09-10 14:35:28 +00:00
Jens Johansen 48d8225b17 [VM] [CFE]: Expression compilation inside extension method
This CL handles expression compilation inside extension methods better.
It is now possible to evaluate "this" and other methods defined in the
extension.

https://github.com/dart-lang/sdk/issues/46757

TEST=service tests added.

Change-Id: I3c71eb23117e26b01961f32103f4046f0b537976
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/212286
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
Reviewed-by: Anna Gringauze <annagrin@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2021-09-10 12:02:57 +00:00
Albert Mañosa 67ff459606 fix: typo in Object.hash equality operator docs
Fix doc comments regarding equality operators in the newly added `Object.hash` and `Object.hashAll` methods.

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

GitOrigin-RevId: 4e168df4b4e4ad932e12d8a90f73d724d830a9e3
Change-Id: I4b3902cbece98ee31d977882196f0c8ffc210694
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/212868
Reviewed-by: Kevin Moore <kevmoo@google.com>
Commit-Queue: Kevin Moore <kevmoo@google.com>
2021-09-09 16:40:33 +00:00
Bruno Leroux ffe3ee691c Call _profileData.finishRequest after request finalisation
Bug : request headers were not captured because finishRequest was
called to early (before headers was fully initialised)
Fixes #47115

TEST=pkg/vm_service/test/get_http_profile_test.dart

Change-Id: I544101c6f37d20e2ddfe7086698c0925f8f5bd09
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/212561
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2021-09-09 14:16:21 +00:00
Lasse R.H. Nielsen 39a165647a Add compareByIndex helper function to Enum.
Fixes https://github.com/dart-lang/language/issues/1836

Bug: https://github.com/dart-lang/language/issues/1836
Change-Id: I43ef26403a379c795a0bdcdeb470b4818ffb721e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/212573
Commit-Queue: Lasse R.H. Nielsen <lrn@google.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
2021-09-09 12:02:15 +00:00
Srujan Gaddam f34eef5b91 [dart:html] Migrate python scripts to python 3
Migrates syntax and semantics from python 2.7.

Major changes include:

- filters
- sorting
- print statements
- higher-order functions
- hashing and comparison

and other misc changes. go.sh consistently gives the libraries
in this and the previous commits with these changes.

Change-Id: I66365739887158d8f321015d36e556447da1bcd3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/211542
Commit-Queue: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Riley Porter <rileyporter@google.com>
2021-09-08 22:10:53 +00:00
Srujan Gaddam 8100b4de02 [dart:html] Fix implements order for classes
Using a set does not guarantee a consistent order from python 3
onwards, so use a OrderedDict to get a consistent order while
removing any duplicates.

Change-Id: I02d9aae2a82fd119f22b3a5e353b9445ffca963b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/211541
Commit-Queue: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Riley Porter <rileyporter@google.com>
2021-09-08 18:45:02 +00:00
Vyacheslav Egorov d8d7af15ce [vm] Migrate away from native 'name' syntax.
As part of deprecating support for native extensions we are also
migrating away from legacy VM-specific `native 'name'` syntax
towards metadata based encoding which does not require any special
syntax.

This CL is a step 1 in migration:

- introduces support for `@pragma('vm:external-name', 'name')`
which serves as a direct replacement for `native 'name'`;
- all core libraries and tests are migrated to use the annotation;

Once this CL lands and rolls we will edit internal and external embedders
to eliminate uses of the native keyword (step 2) and finally remove
support for native keyword across our parsers (step 3).

TEST=ci

Bug: https://github.com/dart-lang/sdk/issues/28791
Change-Id: Id6dea878db82dd4fd81149243c425b5c5dc6df86
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/212461
Commit-Queue: Slava Egorov <vegorov@google.com>
Reviewed-by: Lasse R.H. Nielsen <lrn@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2021-09-08 13:39:34 +00:00
Emmanuel Pellereau 0933086397 Revert "[dart:html] Update Trusted Types APIs"
This reverts commit bda31c2c13.

Reason for revert: Breaks google3 (See b/195948578).

Original change's description:
> [dart:html] Update Trusted Types APIs
>
> Closes b/195948578
>
> Modifies Trusted Types APIs to be compliant with the spec in
> https://w3c.github.io/webappsec-trusted-types/dist/spec/.
>
> Change-Id: I65d52ace12342ce777ab596a9dd2e9a3f74b2f05
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/212270
> Commit-Queue: Srujan Gaddam <srujzs@google.com>
> Reviewed-by: Riley Porter <rileyporter@google.com>

TBR=sra@google.com,srujzs@google.com,rileyporter@google.com

Change-Id: I6c74fe5bfb1ecb39e01304b882ec306d5cf34442
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/212741
Reviewed-by: Emmanuel Pellereau <emmanuelp@google.com>
Reviewed-by: Michal Terepeta <michalt@google.com>
Commit-Queue: Emmanuel Pellereau <emmanuelp@google.com>
2021-09-08 08:35:45 +00:00
Alexander Markov 16e8dc257e [vm] Faster double.floor()/ceil()/truncate() in AOT mode (x64, arm64)
1) double.truncate() now simply calls toInt(), omitting
truncateToDouble() call.

2) double.floor() and ceil() are now intrinsified on arm64 and AOT/x64
and generated using DoubleToInteger instruction.

3) DoubleToInteger instruction is extended to support floor and ceil.
On arm64 DoubleToInteger is implemented using fcvtms and fcvtps
instructions. On x64 DoubleToInteger is implemented using roundsd
under a check if it is supported (with a fallback to a stub and a
runtime call).

AOT/x64:
Before: BenchFloor(RunTime): 318.82148549569655 us.
After:  BenchFloor(RunTime): 133.29430189936687 us.

TEST=ci
Closes https://github.com/dart-lang/sdk/issues/46876
Closes https://github.com/dart-lang/sdk/issues/46650

Change-Id: I16ca18faf97954f8e8e25f0b72a2bbfac5bdc672
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/212381
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2021-09-07 19:52:04 +00:00
Srujan Gaddam bda31c2c13 [dart:html] Update Trusted Types APIs
Closes b/195948578

Modifies Trusted Types APIs to be compliant with the spec in
https://w3c.github.io/webappsec-trusted-types/dist/spec/.

Change-Id: I65d52ace12342ce777ab596a9dd2e9a3f74b2f05
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/212270
Commit-Queue: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Riley Porter <rileyporter@google.com>
2021-09-07 18:03:18 +00:00
Daco Harkes 40bbb6dcc2 [vm] Const map, remove invalid assert
Isolates are allowed to race each other to initialize _indexNullable,
the last isolate wins. See
https://dart-review.googlesource.com/c/sdk/+/210726 and
https://dart-review.googlesource.com/c/sdk/+/203765.

These asserts were wrong, because another isolate could have initialized
_indexNullable in between places calling _createIndex and _createIndex
itself.

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

Change-Id: I5d55b9715ef622737a6f70c0b57590076ece3225
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/212586
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2021-09-07 15:47:22 +00:00
Daco Harkes 2b5adb7231 [vm] Implement constant Maps in the VM
This CL changes the frontend to emit map and set constants which are
then processed by the constant reader in the VM.

This CL also introduces support for sending the const maps and sets
in messages between isolates and saving it in snapshots.

TEST=tests/language/const/map_test.dart (et al, for lookups)
TEST=tests/lib/isolate/message3_test.dart (et al, for isolate messages)
TEST=tools/test.py -c dartkp (for consts from clustered snapshot)
TEST=tools/test.py -n app_jitk-linux-debug-x64 (for consts from app
     jit snapshots)
TEST=Building the SDK which uses const Maps in clustered snapshots.

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

Change-Id: I1f8150a8aba8298c4e64d2571dd147743526135a
Cq-Include-Trybots: luci.dart.try:analyzer-nnbd-linux-release-try,app-kernel-linux-debug-x64-try,dart-sdk-linux-try,front-end-nnbd-linux-release-x64-try,pkg-linux-debug-try,vm-canary-linux-debug-try,vm-kernel-asan-linux-release-x64-try,vm-kernel-checked-linux-release-x64-try,vm-kernel-linux-debug-x64c-try,vm-kernel-linux-debug-x64-try,vm-kernel-linux-debug-simarm64c-try,vm-kernel-nnbd-linux-release-simarm-try,vm-kernel-optcounter-threshold-linux-release-x64-try,vm-kernel-precomp-android-release-arm_x64-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-debug-x64c-try,vm-kernel-reload-linux-debug-x64-try,vm-kernel-reload-rollback-linux-debug-x64-try,vm-precomp-ffi-qemu-linux-release-arm-try,vm-kernel-precomp-linux-debug-simarm_x64-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-tsan-linux-release-x64-try,vm-kernel-tsan-linux-release-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/203765
Reviewed-by: Martin Kustermann <kustermann@google.com>
2021-09-06 06:28:59 +00:00
Daco Harkes e8e9e1d152 [vm] Introduce immutable maps and sets in backend
This CL introduces immutable maps and sets in the VM backend but does
not yet target them from the frontend. The changes are tested by unit
tests constructing these immutable maps and sets.

This CL introduces immutable variants of the hash map and set in
compact_hash.dart and recognizes them in the VM. The immutable ones
use a different mixin with a different recognized method for accessing
members.
* Data list is an immutable list with a different cid. (Otherwise the
  optimizer notices that immutable and mutable lists cannot be equal.)
* Index is a nullable mutable typed data. (Otherwise optimizer removes
  necessary null checks.)
* Index should use a store-release barrier when written to.

Multiple isolates might lazily compute the index for const sets and
maps. This is fine because all identityHashCodes and hashCodes are
guaranteed to be race-free. The later isolates will override the index
pointer with an identical index.

This CL does not introduce support for using these immutable maps and
sets in AOT (clustered_snapshot) and in messages to other isolates
(message_snapshot) because that is harder to test with unit tests. That
will be added in the follow-up CL.

Design doc: go/dart-vm-const-maps

TEST=runtime/vm/object_test.cc

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

Change-Id: I4042179c15e8b37692d3255655351c01c7124991
Cq-Include-Trybots: luci.dart.try:analyzer-nnbd-linux-release-try,app-kernel-linux-debug-x64-try,dart-sdk-linux-try,front-end-nnbd-linux-release-x64-try,pkg-linux-debug-try,vm-canary-linux-debug-try,vm-kernel-asan-linux-release-x64-try,vm-kernel-checked-linux-release-x64-try,vm-kernel-linux-debug-x64c-try,vm-kernel-linux-debug-x64-try,vm-kernel-linux-debug-simarm64c-try,vm-kernel-nnbd-linux-release-simarm-try,vm-kernel-optcounter-threshold-linux-release-x64-try,vm-kernel-precomp-android-release-arm_x64-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-debug-x64c-try,vm-kernel-reload-linux-debug-x64-try,vm-kernel-reload-rollback-linux-debug-x64-try,vm-precomp-ffi-qemu-linux-release-arm-try,vm-kernel-precomp-linux-debug-simarm_x64-try,vm-kernel-precomp-linux-debug-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/210860
Reviewed-by: Martin Kustermann <kustermann@google.com>
2021-09-06 06:28:59 +00:00
Srujan Gaddam 07aa93a532 [dart:html] Add js_util import to dart:html
Part of https://dart-review.googlesource.com/c/sdk/+/210100

As classes get migrated to js_util, this import is needed.

Change-Id: Ib455257883257af2e145c222ab903488b22f13f9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/211540
Auto-Submit: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
2021-09-03 21:53:27 +00:00
Nicholas Shahan 5ea90ee907 [ddc] Enable construtor tearoff lowering
* Update tearoff runtime equality algorithm with newly specified
  requirements.
* Update kernel golden files for the dartdevc target to include
  the static method lowering for constructor tearoffs.
* Avoid adding source maps and debug symbols to the static methods
  created by the CFE lowering.
* Add additional expected non-nullable values detected in the
  nullable inference tests. These correspond to the values that
  appear in the static method return statements.

Measurements taken from large applications show the lowering causes
a code size increase of 2.5%-3.5%. That increase did not appear to
create any measurable difference in initial page load time but if
there turns out to be a regression we can revisit each of the various
lowerings to implement support in DDC at the site where the constructor
is torn off.

Fixes: https://github.com/dart-lang/sdk/issues/46486
Fixes: https://github.com/dart-lang/sdk/issues/46837
Change-Id: I01fa39d4f1d0e937919dd1466bb6a34c91a10e75
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/206960
Commit-Queue: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Mark Zhou <markzipan@google.com>
Reviewed-by: Anna Gringauze <annagrin@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2021-09-03 17:48:58 +00:00
Vyacheslav Egorov bda70c8489 [vm] Remove support for dart-ext: imports
Per breaking change #45451 we are removing support for dart-ext:
style native extensions from the Dart VM.

This CL removes the associated VM code, tests and samples. It also ports
a single test which used dart-ext: import to use FFI instead.

TEST=ci

Bug: https://github.com/dart-lang/sdk/issues/45451
Change-Id: Iae984bce32baf29a950b5de1323939006a217b94
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/212050
Commit-Queue: Slava Egorov <vegorov@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2021-09-02 14:14:35 +00:00
Alexander Markov 307bc3ef2c [vm] Faster double.toInt() in AOT mode
double.toInt() micro-benchmark on AOT/x64:
Before: BenchToInt(RunTime): 438.67258771929824 us.
After:  BenchToInt(RunTime): 118.8603434955726 us.

double.floor() micro-benchmark on AOT/x64:
Before: BenchFloor(RunTime): 537.2132688691916 us.
After:  BenchFloor(RunTime): 321.2052352657781 us.

TEST=ci
Issue https://github.com/dart-lang/sdk/issues/46876
Issue https://github.com/dart-lang/sdk/issues/46650

Change-Id: Id37c827bceb7f374ae5b91b36871ccf0d9e92441
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/211620
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2021-09-01 16:57:59 +00:00
Lasse R.H. Nielsen ed3824a220 Tweaks, refactoring and updates on DoubleLinkedQueue.
It's a badly designed class, but this change makes it slightly better.
(We should consider moving it to package:collection and removing it from
the platform libraries. Eventually.)

The changes decouples the public `DoubleLinkedQueueEntry` class from
the actual queue implementation classes, avoiding the latter having
to share a generic `_Link<DoubleLinkedQueueEntry>` interface
which would force them to do otherwise unnecessary casts.

The public class should have been abstract, but isn't.
It's mainly used as the API of the entries exposed by DoubleLinkedQueue,
but it can also be used by itself to build double-linked lists that are
not part of a Queue, and the class can be extended.
If anyone does either, it should keep working, so it needs to be a concrete,
self-contained class with a generative constructor.

That class is moved to dart:_internal to avoid its private
implementation fields from interfering with the queue implementation classes,
which have similar fields, but can now have them at different types.
That's a hack, but it works.

The internal implementation of the DoubleLinkedQueue and its entries
are updated to better follow current programming idioms, and avoids
having fields on classes which don't need them.

Also fixes #27920
(`clear`ing a list now detaches each entry from the list so later `.contains`
won't give the wrong answer).

And moves queue tests from tests/corelib to tests/lib/collection,
since Queue isn't exposed by `dart:core`.

BUG= https://github.com/dart-lang/sdk/issues/27920

Change-Id: Ia3bb340a75886de160cc0e449947e8e7ee587061
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/211265
Commit-Queue: Lasse R.H. Nielsen <lrn@google.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
2021-08-31 12:44:39 +00:00
Alexander Markov 28348d650f [vm] Move implementation of dart:math intrinsics to flow graph builder
This change removes duplicated implementations of dart:math intrinsics
from GraphIntrinsifier/AsmIntrinsifier and FlowGraphInliner, and adds
a single implementation in FlowGraphBuilder.

TEST=ci

Change-Id: Ifcf285aba15e1b240144215463cd6b2703a8937c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/211481
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2021-08-27 17:42:27 +00:00
Daco Harkes d8093982aa [vm] Cleanup dead code RTE ClassID_getID
This has been dead code since the bytecode interpreter has been removed.

TEST=This removes dead code. Building the SDK tests this code is not
     imported. Running the CQ tests it was not executed.

Change-Id: I75ce3fc2dfccb57d3287db7e716901a8b5a0c20e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/211264
Auto-Submit: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Tess Strickland <sstrickl@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
2021-08-27 07:09:26 +00:00
Stephen Adams 5c582f82f0 [dart2js, js_runtime, js_dev_runtime] NaN-safe range checks.
`int` variables can attain NaN values because web int arithmetic
implemented by JavaScript numbers (doubles) is not closed under many
operations. It is possible get NaN using only addition:

    int a = 1, b = -1;
    while (a + a != a) { a += a; b += b; }
    int nan = a + b;

On the VM, a, b and nan are all zero.
On the web, a, b and nan are Infinity, -Infinity and NaN, respectively.

Since NaN can leak into int arithmetic, is it helpful if bounds checks
catch NaN indexes. NaN compares false in any comparison, so a test
of the form

   if (index < 0 || index >= a.length) throw ioore(a, index);

fails to detect a NaN value of `index`.
This is fixed by negating the comparisons, and applying De Morgan's law:

   if (!(index >= 0 && index < a.length)) throw ioore(a, index);

These changes have been applied to JSArray.[], JSArray.[]= and String.[]

For dart2js the change is a little more involved. Primitive indexing is
lowered to code with a HBoundsCheck check instruction. The code generated
for the instruction now uses, e.g. `!(i>=0)` instead of `i<0`.
This leads to a small code size regression.

There is no regression at -O4 since bounds checks are omitted at -O4.

At -O3 (where the regression is largest) the regression is
   0.01% for cm
   0.06% for flutter gallery -- array-heavy diff and layout
   0.21% for Meteor          -- array-heavy code
   0.30% for Box2DOctane     -- array-heavy code

I believe the regression can be largely alleviated by determining if
NaN is impossible at the index check, and if so, reverting to the smaller
code pattern. The analysis could be global, incorporating NaN into the
global abstract value domain, or a much simpler a local dataflow
analysis. Many indexes are loop driven and cannot reach infinity because
they are incremented by a small bump and eventually (even without a loop
guard) the index would stop growing when the increment falls below the
rounding error in O(2^53) iterations.


Change-Id: I23ab1eb779f1d0c9c6655e13d69f65d453db9284
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/210321
Commit-Queue: Stephen Adams <sra@google.com>
Reviewed-by: Mayank Patke <fishythefish@google.com>
2021-08-27 00:37:56 +00:00
Alexander Markov f0d6b8864d [vm] Faster double.floorToDouble/ceilToDouble/truncateToDouble/roundToDouble in AOT mode
This change replaces graph intrinsics and call specializer code for
certain _Double methods with a body created in FlowGraphBuilder.

double.floorToDouble micro-benchmark on AOT/x64:
Before BenchFloorToDouble(RunTime): 642.3240205523442 us.
After: BenchFloorToDouble(RunTime): 268.0320289466631 us.

double.floor micro-benchmark on AOT/x64:
Before BenchFloor(RunTime): 760.7630277672118 us.
After: BenchFloor(RunTime): 537.2132688691916 us.

TEST=ci
Issue: https://github.com/dart-lang/sdk/issues/46650
Change-Id: I47f5d8a1bdc0f71965ad1763c7bc46540428c6cd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/210652
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2021-08-27 00:33:46 +00:00
suragch a5194c80c2 Correcting misnamed variable in doc comments
Unless I'm missing something, the map that is being referenced here is `x` from the function argument. It looks like calling it `map` was just a typo. Alternatively rename `x` to `map`.

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

GitOrigin-RevId: 940442bfaa1517b33f811488773618e6f2e387d8
Change-Id: I0d24e28edef7f6e941d3247f7d647b22670a35b9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/211360
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2021-08-26 09:48:31 +00:00
Stephen Adams 7731eea468 [dart2js] Instantiation.== and Instantiation.hashCode
Change-Id: Ic4e9c882b27a6490a913899d74141ff73c4aebab
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/210981
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2021-08-25 21:07:02 +00:00
Sigurd Meldgaard ae81cd5dab Deprecate top level pub.
Also makes the `pub` shell script (and its .bat counterpart)
forward to a `dart __deprecated_pub` command that implements the
old top-level.

This allows us to get rid of pub.dart.snapshot saving ~15 MB in a
unzipped sdk.

The reason for not forwarding directly to `dart pub` is that the
interface is slightly different (for example there is no `dart pub --version`).


The only new commit in pub is: `3c2ce330 Expose toplevel as a command`


Bug: https://github.com/dart-lang/pub/issues/2736
Change-Id: I6eb08d120c4844b3a12bc29544df6a868cd6fcc8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/210582
Commit-Queue: Sigurd Meldgaard <sigurdm@google.com>
Reviewed-by: Jonas Jensen <jonasfj@google.com>
2021-08-24 08:34:58 +00:00
Michael Thomsen 6c5fb84716 Discontinue dart2native (use dart compile)
TEST=Existing tests updated to use dart compile

Change-Id: Ia3478069df2354a3bf057fedae0f1eea9415de95
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/210241
Commit-Queue: Michael Thomsen <mit@google.com>
Reviewed-by: Devon Carew <devoncarew@google.com>
Reviewed-by: Tess Strickland <sstrickl@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2021-08-23 20:53:09 +00:00
Martin Kustermann 0201d76154 [vm/concurrency] Remove internal-only "Isolate.spawn() into new group" functionality
This was mainly used as a backup plan which is no longer needed at this
point.

This CL removes internal only functionality that couldn't be used by
end-users.

TEST=ci

Change-Id: Ie0828bda1ba48ee6a5a460ff039267e0549e0060
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/210340
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2021-08-19 15:19:00 +00:00
Alexander Aprelev 386338edd8 [vm/sendport] Do port handler lookup and message dispatch in one dart call.
This improves performance of SendPort.Receive.Nop benchmark with isolate groups enabled on Intel Xeon by ~17%.
This benchmark emphasizes performance of handle message flow.

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

TEST=ci

Change-Id: I3b9be3283047631e8989bb56f90af2b3b007afe8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/209642
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2021-08-18 13:31:43 +00:00
Lasse R.H. Nielsen c98ee0bfdb Fix and update StreamTransformer constructor documentation.
Fixes #46924

BUG= https://dartbug.com/46924

Change-Id: I8a5d2aa3f60680ec419c4f0d614f6ec186106b08
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/210360
Auto-Submit: Lasse R.H. Nielsen <lrn@google.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
Commit-Queue: Nate Bosch <nbosch@google.com>
2021-08-18 01:41:37 +00:00
Lasse R.H. Nielsen f4ddc8dc6b Deprecate the dart:cli library and waitFor method.
Change-Id: Ia7af0febf17b310de9561eca254f1bd9add079ac
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/210125
Commit-Queue: Lasse R.H. Nielsen <lrn@google.com>
Reviewed-by: Michael Thomsen <mit@google.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
2021-08-16 13:49:48 +00:00
Vyacheslav Egorov 493fe772d0 [vm] Rewrite Double.~/ in pure Dart
Avoid going into runtime for every operation.

https://github.com/dart-lang/sdk/issues/46855

TEST=ci

Change-Id: I5ab1d224f895342c8dd7fb9b8a7a98cfb0359db0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/209705
Reviewed-by: Stephen Adams <sra@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2021-08-10 17:54:40 +00:00
Lasse R.H. Nielsen 020f21261a Add documentation to .fromEnvironment-like constructors.
Document that only `const` invocations are guaranteed to work.
(But leave open the door that some platforms might allow `new`.)

Thanks to @irvine5k for the initial work (see #46846).

Change-Id: I16ad26186e91898cf1dc2922a492ce4eb0dac207
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/209543
Reviewed-by: Nate Bosch <nbosch@google.com>
Commit-Queue: Lasse R.H. Nielsen <lrn@google.com>
2021-08-10 14:37:37 +00:00
niku 005e496e1e Fix isAfter method code example on DateTime class
The code example looks similar as [isBefore method](b8d040e523/sdk/lib/core/date_time.dart (L405-L417)) except in this change.

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

GitOrigin-RevId: 4087032bcbd64e8aaf58dab81babb971d4642c86
Change-Id: I0b01d82ce4fad9ae076c4a1d46ee03cbc3b08d25
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/209460
Reviewed-by: Lasse R.H. Nielsen <lrn@google.com>
Commit-Queue: Lasse R.H. Nielsen <lrn@google.com>
2021-08-10 11:58:34 +00:00
Martin Kustermann d7c0271ac0 [vm/concurrency] Add missing WeakProperty support to transitive copy
The transitive copy algorithm was missing support for [WeakProperty]s,
thereby ensuring that we only copy the values if the keys are reachable.

Furthermore we might need to re-hash [Expando]s - since the copied
objects start with no identity hash codes.

The CL also makes us avoid calling to Dart for each [Expando]
separately and instead use a list - just as we do in the re-hashing of
maps/sets.

We also move the C++ code to invoke rehashing logic into
DartLibraryCalls::*.

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

TEST=vm/dart{,_2}/isolates/fast_object_copy{,2}_test

Change-Id: I836745feef8a6d7573faa94e29a19c1eca0c39f2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/209106
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2021-08-09 23:56:19 +00:00
Lasse R.H. Nielsen ae1e2bd3a6 Add HTTP access control headers to CHANGELOG and add @Since.
Change-Id: I860fbe6b821061695c50319204d8d6ba9c98a839
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/209109
Auto-Submit: Lasse R.H. Nielsen <lrn@google.com>
Commit-Queue: Kevin Moore <kevmoo@google.com>
Reviewed-by: Kevin Moore <kevmoo@google.com>
2021-08-09 14:48:38 +00:00
Clement Skau 0f7f8e361c Revert "[VM] Adds getNativeFieldPtr(..)"
This reverts commit 2e17bb219f.

Reason for revert: Breaks precomp. due to import of dart:ffi.

Original change's description:
> [VM] Adds getNativeFieldPtr(..)
>
> Adds a convenience function for working with FfiNatives
> where we often end up doing:
>
> class SomeClass extends NativeFieldWrapperClass1 {
>   void doThing() => _doThing(Pointer.fromAddress(getNativeField(this)))
>   @FfiNative<Void Function(Pointer)>
>   external static void _doThing(Pointer self);
> }
>
> TEST=Existing.
>
> Bug: https://github.com/dart-lang/sdk/issues/43889
> Change-Id: I983ba882574732b71b7ceafcb98b8ce5339e9003
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/208503
> Commit-Queue: Clement Skau <cskau@google.com>
> Reviewed-by: Tess Strickland <sstrickl@google.com>

TBR=cskau@google.com,sstrickl@google.com

Change-Id: I7bc9376f05664fda4fcf27b584081295195d5562
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: https://github.com/dart-lang/sdk/issues/43889
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/209542
Reviewed-by: Clement Skau <cskau@google.com>
Commit-Queue: Clement Skau <cskau@google.com>
2021-08-09 10:43:50 +00:00
Clement Skau 2e17bb219f [VM] Adds getNativeFieldPtr(..)
Adds a convenience function for working with FfiNatives
where we often end up doing:

class SomeClass extends NativeFieldWrapperClass1 {
  void doThing() => _doThing(Pointer.fromAddress(getNativeField(this)))
  @FfiNative<Void Function(Pointer)>
  external static void _doThing(Pointer self);
}

TEST=Existing.

Bug: https://github.com/dart-lang/sdk/issues/43889
Change-Id: I983ba882574732b71b7ceafcb98b8ce5339e9003
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/208503
Commit-Queue: Clement Skau <cskau@google.com>
Reviewed-by: Tess Strickland <sstrickl@google.com>
2021-08-09 10:08:38 +00:00
Lasse R.H. Nielsen de999e8ea3 Add access-control-allow-* headers
cc @kevmoo if you know who can handle this.

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

GitOrigin-RevId: ae62a578d11095dd225ecb02f83e29ce5bd99864
Change-Id: If56f362b92c9226e94a8ea29b162de21ca548710
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/198780
Reviewed-by: Lasse R.H. Nielsen <lrn@google.com>
Commit-Queue: Lasse R.H. Nielsen <lrn@google.com>
2021-08-05 09:48:19 +00:00
Stephen Adams bda99fe9cd Update comment in dart2js_startup_metrics
Change-Id: Ia73d0cdd49f0a072efc7e64a1950d896dba564fa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/208923
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2021-08-05 00:34:07 +00:00
Stephen Adams 5ff2459d88 Remove obsolete internal dart2js annotations
These annotations have all been replaced with @pragma('dart2js:xxx')
versions:

@ForceInline, @NoInline, @NoThrows, @NoSideEffects, @AssumeDynamic.

Change-Id: Ia4730670c6864ccbe0fa4120108c3c16ab887c23
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/208863
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2021-08-04 23:27:18 +00:00
Stephen Adams 23b50dfa7d [dart2js] Add dart:_dart2js_runtime_metrics library and package
The internal dart:_dart2js_runtime_metrics library is accessed via
package:dart2js_runtime_metrics.

There is currently one API: startupMetrics.

On non-dart2js configurations the API is stubbed for ease-of-use.

Change-Id: I80c56a83fd166ec19c3846fb6937cf0440ed2c6b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/208563
Commit-Queue: Stephen Adams <sra@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2021-08-03 18:25:00 +00:00
Lasse R.H. Nielsen 59069f399a Update phrasing of cast docs as suggested in review.
Change-Id: Ieb17fc9583eacee0d01a1aa1cdf5f6575cc8d15c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/208652
Reviewed-by: Erik Ernst <eernst@google.com>
Commit-Queue: Lasse R.H. Nielsen <lrn@google.com>
2021-08-03 15:32:49 +00:00
Mateus Felipe C. C. Pinto a95a663c23 Improve String.substring documentation
This PR provides additional info on the `substring` method, as it will throw a `RangeError` in the following cases:

* `start` is negative;
* `end` is negative;
* `start` is greater than `length`;
* `end` is greater than `length`;
* `start` is greater than `end`.

Although some of them are a little obvious, it's better to be explicit about the expectations. One could expect that, for example, that `'abc'.substring(0, 4)` would return `'abc'` instead of throwing.

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

GitOrigin-RevId: d878a4cfbd1eedc7b7e7fc5d6860321c87317346
Change-Id: If3c55b294e2fefd83b7ee5cdeed6478dbe2c7448
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/207200
Reviewed-by: Lasse R.H. Nielsen <lrn@google.com>
Commit-Queue: Lasse R.H. Nielsen <lrn@google.com>
2021-08-03 15:29:00 +00:00
Lasse R.H. Nielsen 9056b20180 Update various documentations.
Documents Stream.timeout better.
Documents that collection.cast doesn't affect
methods accepting `Object?`.

Fixes #30163
Documents issue of #46336

Bug: http://dartbug.com/30163
Change-Id: Ie228a81d838a14c383da2f75af8b5dbb31e8ea3d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/208651
Commit-Queue: Lasse R.H. Nielsen <lrn@google.com>
Commit-Queue: Erik Ernst <eernst@google.com>
Auto-Submit: Lasse R.H. Nielsen <lrn@google.com>
Reviewed-by: Erik Ernst <eernst@google.com>
2021-08-03 11:20:44 +00:00
Srujan Gaddam f5a98e7676 [ddc] Unify pkg:js types and allow subtyping between them
Removes the lazy loading of the underlying type in LazyJSTypes.
As such, this removes the need to keep AnonymousJSType and
LazyJSType separate, and is therefore refactored to
PackageJSType. Similarly, subtyping is fixed such that
PackageJSTypes are all subtypes of each other.

Change-Id: If489defdbeb5cb932db802a7d146ad2fc393b12c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/207982
Commit-Queue: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2021-07-30 00:33:54 +00:00
Ryan Macnak bbefc05748 [vm] Rewrite isolate message serialization.
TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/25559
Bug: https://github.com/dart-lang/sdk/issues/27285
Bug: https://github.com/flutter/flutter/issues/84691
Change-Id: I04608c5d337144195748d5f3509a29eb3116585d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/207865
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2021-07-29 16:55:55 +00:00
Lasse R.H. Nielsen 706a633050 Fix wrong version in @Since on unawaited/Future.ignore.
The CHANGELOG.md lists them under 2.14, but the annotation said "2.15".

Change-Id: I87ccd23c9843e34f8b6a30997550b3eb9cd0f4d7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/208320
Auto-Submit: Lasse R.H. Nielsen <lrn@google.com>
Commit-Queue: Nate Bosch <nbosch@google.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
2021-07-28 17:43:04 +00:00
Clement Skau 94bdcc2084 [VM] Adds native field accessor in Dart.
Adds GetNativeField(o,i) to access NativeFieldWrapperClass{1-4}
native fields directly in Dart instead of through VM API.
This will allow us to pass `this` as a raw pointer instead of as
a Dart handle which needs to be unwrapped.
This will in turn allow ffi native calls for instance methods.

TEST=Adds vm/cc/DartAPI_NativeFieldAccess

Bug: https://github.com/dart-lang/sdk/issues/43889
Change-Id: I8006c735569fcbe5e49915a4c7e72c4ca85b356e
Cq-Do-Not-Cancel-Tryjobs: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/205482
Commit-Queue: Clement Skau <cskau@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2021-07-28 08:31:17 +00:00
Devon Carew c17e2a13da update the tooling to generate libraries.json from libraries.yaml
Change-Id: I960187ae02834f42a2b7fce2135a8b84b1f21979
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/208260
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Devon Carew <devoncarew@google.com>
2021-07-27 23:02:50 +00:00
Ryan Macnak b1132a7a40 [vm] Fix dart:developer to only send basic types across ports.
TEST=ci
Change-Id: Ifa6b8010f8b9d4af6e7eab5f50e569f8815a94f8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/208242
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2021-07-27 20:17:39 +00:00
Sigmund Cherem 5de7dfb90b [web] fix io_patch files to match nullability of encoding parameters
Fixes #46726

Change-Id: Idf9b8b2fcfd3eb59dd25a84ade0ad2a36fe7648d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/208145
Reviewed-by: Mark Zhou <markzipan@google.com>
Commit-Queue: Sigmund Cherem <sigmund@google.com>
2021-07-27 03:05:37 +00:00
Mayank Patke e605ccbac4 Clean up unused internal Symbol API.
Change-Id: I9287130074d0a183985b53e16d0c31b49750e012
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/205660
Reviewed-by: Erik Ernst <eernst@google.com>
Reviewed-by: Lasse R.H. Nielsen <lrn@google.com>
Commit-Queue: Mayank Patke <fishythefish@google.com>
2021-07-26 17:49:06 +00:00
Daco Harkes 12d1bc7236 [vm] Change Symbol CanonicalizeHash to hashCode
Aligns the CanonicalizeHash for Symbol with it's hashCode in Dart.

Motivation for aligning hashCode and CanonicalizeHash in
go/dart-vm-const-maps.
Bug: https://github.com/dart-lang/sdk/issues/45908

TEST=runtime/vm/object_test.cc

Change-Id: I228405364c930d81a269fd87cbc59cf95e97c649
Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/206260
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Tess Strickland <sstrickl@google.com>
2021-07-26 11:39:54 +00:00
Srujan Gaddam 7e60aa2eff Reland "[ddc] Allow JS objects to be casted to JavaScriptObject"
This is a reland of 7926035c8f

Original change's description:
> [ddc] Allow JS objects to be casted to JavaScriptObject
>
> Replaces jsobject instance with JavaScriptObject as the base type of
> all JS objects.
>
> It does NOT treat the object as an instance of the class however,
> so any members defined in JavaScriptObject are ignored, which is why
> any existing ones are stripped from the class. It also avoids
> impacting the calling convention on these types. Lastly, the CL
> allows transitive subtyping between the JS type hierarchy and the
> JavaScriptObject type hierarchy.
>
> Change-Id: Iccabcd6580870cac8d2a8f24494bc41325eb17f3
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/199600
> Reviewed-by: Mayank Patke <fishythefish@google.com>
> Reviewed-by: Nicholas Shahan <nshahan@google.com>
> Reviewed-by: Sigmund Cherem <sigmund@google.com>

Change-Id: I43d5d1eff9abf41b82ba3de49c8404bd633732b2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/207880
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
2021-07-22 22:27:36 +00:00
Srujan Gaddam 6085e065e9 [dart:html] Add doc changes to templates and source files
https://dart-review.googlesource.com/c/sdk/+/205068 and
https://dart-review.googlesource.com/c/sdk/+/205300 were added
to fix doc issues in dart:html. This CL adds those changes to
the source and template files and fixes some grammar.

Change-Id: I59ab35c5076fba5d67e4e99cff503bb98eb55549
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/207800
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
2021-07-22 19:59:54 +00:00
Nicholas Shahan f638d06292 [ddc] Fix generic method constant tearoffs
Previously all functions objects returned by `dart.gbind()` would
contain the same 3 properties: name, length, and runtimeType. For
two distinct functions, if these three properties were the same
our constant canonicalization would incorrectly canonicalize to the
same value. Attaching the original function and the type arguments
used in instantiation ensures the const canonicalization will treat
different functions or instantiations as different values.

These values will also be used for equality checks proposed here:
https://github.com/dart-lang/language/issues/1712

Fixes: https://github.com/dart-lang/sdk/issues/46568
Issue: https://github.com/dart-lang/sdk/issues/46486
Change-Id: I65111df9af80d878eb3127c5e3dfac1ffba95535
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/206423
Commit-Queue: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2021-07-20 00:15:34 +00:00
Stephen Adams cfc8ad4e7f [js_runtime] Use custom hashCode for GeneralConstantMap
Fixes #46580

Change-Id: Ida2b7df75415881973085f9afeacd9ee384fd910
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/207160
Commit-Queue: Stephen Adams <sra@google.com>
Reviewed-by: Mayank Patke <fishythefish@google.com>
2021-07-16 22:58:02 +00:00
Srujan Gaddam 8857097556 Revert "[ddc] Allow JS objects to be casted to JavaScriptObject"
This reverts commit 7926035c8f.

Reason for revert: https://github.com/flutter/flutter/issues/86581

Original change's description:
> [ddc] Allow JS objects to be casted to JavaScriptObject
>
> Replaces jsobject instance with JavaScriptObject as the base type of
> all JS objects.
>
> It does NOT treat the object as an instance of the class however,
> so any members defined in JavaScriptObject are ignored, which is why
> any existing ones are stripped from the class. It also avoids
> impacting the calling convention on these types. Lastly, the CL
> allows transitive subtyping between the JS type hierarchy and the
> JavaScriptObject type hierarchy.
>
> Change-Id: Iccabcd6580870cac8d2a8f24494bc41325eb17f3
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/199600
> Reviewed-by: Mayank Patke <fishythefish@google.com>
> Reviewed-by: Nicholas Shahan <nshahan@google.com>
> Reviewed-by: Sigmund Cherem <sigmund@google.com>

TBR=sigmund@google.com,nshahan@google.com,fishythefish@google.com,srujzs@google.com,rileyporter@google.com

Change-Id: I82b3ab913aa6c1f8ceb515d938880725721248ea
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/207261
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
2021-07-16 22:27:59 +00:00
Stephen Adams 1e7db45b31 [dart2js] Remove ConstantProtoMapClass
Change-Id: I1917db995d12bbde3024f774de49e75bced3b6a5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/207101
Commit-Queue: Stephen Adams <sra@google.com>
Reviewed-by: Mayank Patke <fishythefish@google.com>
2021-07-16 19:28:47 +00:00
Srujan Gaddam 7926035c8f [ddc] Allow JS objects to be casted to JavaScriptObject
Replaces jsobject instance with JavaScriptObject as the base type of
all JS objects.

It does NOT treat the object as an instance of the class however,
so any members defined in JavaScriptObject are ignored, which is why
any existing ones are stripped from the class. It also avoids
impacting the calling convention on these types. Lastly, the CL
allows transitive subtyping between the JS type hierarchy and the
JavaScriptObject type hierarchy.

Change-Id: Iccabcd6580870cac8d2a8f24494bc41325eb17f3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/199600
Reviewed-by: Mayank Patke <fishythefish@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2021-07-15 22:43:39 +00:00
Clement Skau 460e00a6a6 [VM] Adds leaf call option to FfiNative.
This change essentially exposes `asFunction`'s `isLeaf` in
`@FfiNative`, allowing us to declare FFI Natives as leaf calls.

TEST=Adds tests/ffi/ffi_native_test.dart

Bug: https://github.com/dart-lang/sdk/issues/43889
Change-Id: I2a396fae2ab28d21df282f3afb35fa401485ed52
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/206375
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Clement Skau <cskau@google.com>
2021-07-14 09:13:51 +00:00
Martin Kustermann 723df3d4a4 [vm] Use correct static type for the port mapping in Dart
The keys in the map are integers.

TEST=Existing test suite.

Change-Id: I989a8be01f3abb6b50f0c0d692b84c1494a60ab6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/206542
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2021-07-13 17:15:27 +00:00
Marcin Radomski 8236db13ee [vm] Use IP address for joining IPv4 multicast on iOS
The socket implementation has a workaround for MacOS, which is also required on iOS. @alexbatalov suggested this fix in https://github.com/dart-lang/sdk/issues/42250#issuecomment-759026385.

Verified on iPhone 11 with iOS 14.6.

Bug: http://dartbug.com/42250

TEST=Existing test base. Manually verified on iOS

Change-Id: I9942ccaf3bdd65e04842a38697eadc19feb317d9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/206020
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
Auto-Submit: Marcin Radomski <dextero@google.com>
2021-07-13 12:27:46 +00:00
Martin Kustermann a92fe49002 Reland "[vm/concurrency] Ensure fixes to switchable call (due to disabled code) is correctly performed""
If two mutators concurrently execute a switchable call that targets a
code object which has been disabled, they both go to runtime trying to
fix that switchable call site's object pool.

This Cl ensures we use the same logic as for other miss handlers to
ensure we properly guard against concurrent accesses.

The attached regression test will trigger a segfault - though only
with low probability.

The changes to first land is: Avoid assuming the target can be called
directly. Instead always go through IC Stub when returning from miss
handler. We do that since a call site might not provide ARGS_DESC but
the target might need it.

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

TEST=vm/dart{,_2}/isolates/regress_46539_test

Change-Id: I18018fa286173d905c52b6e058a6c87b544ff18e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/206373
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2021-07-13 07:30:18 +00:00
Lasse R.H. Nielsen 66f22f9b81 Optimize BigInt.bitLength.
Change-Id: I5b60ec5932aa538588349129d78e8e3f91752b4c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/206369
Auto-Submit: Lasse R.H. Nielsen <lrn@google.com>
Commit-Queue: Régis Crelier <regis@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
2021-07-12 18:04:05 +00:00
Daco Harkes 483179c934 [vm] Recognize non-const Set in the VM
`_CompactLinkedHashSet` now extends `_HashVMBase`. The class hierarchy
is organized as mixins similar to LinkedHashMap to accomodate for the
other Sets not extending `_HashVMBase`.

Also, rearranges some code so that introducing ImmutableHashMap and
ImmutableHashSet is easier.
1) snapshot.h and snapshot.cc now have a MapReadFrom, MapWriteTo,
   SetReadFrom, and SetWriteTo to facilitate code sharing between
   mutable and immutable implementations similar to ArrayReadFrom and
   ArrayWriteTo.
2) Macros for CLASS_LIST_MAPS and CLASS_LIST_SETS to facilitate
   treating mutable and immutable implementations with the same handle.
   Also similar to Array.

Clustered snapshots for HashMaps is currently dead code. This CL makes
it explicit by marking these as unreachable. Immutable maps and sets
will end up in the clustered snapshot in follow up CLs.

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

TEST=runtime/vm/object_test.cc
TEST=tests/**_test.dart on many bots

Change-Id: If3cc5ebb3138535aeb0d5e06d9da3d1c9fb2deb2
Cq-Include-Trybots: luci.dart.try:analyzer-nnbd-linux-release-try,app-kernel-linux-debug-x64-try,dart-sdk-linux-try,front-end-nnbd-linux-release-x64-try,pkg-linux-debug-try,vm-canary-linux-debug-try,vm-kernel-asan-linux-release-x64-try,vm-kernel-checked-linux-release-x64-try,vm-kernel-linux-debug-x64c-try,vm-kernel-linux-debug-x64-try,vm-kernel-linux-debug-simarm64c-try,vm-kernel-nnbd-linux-release-simarm-try,vm-kernel-optcounter-threshold-linux-release-x64-try,vm-kernel-precomp-android-release-arm_x64-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-debug-x64c-try,vm-kernel-reload-linux-debug-x64-try,vm-kernel-reload-rollback-linux-debug-x64-try,vm-precomp-ffi-qemu-linux-release-arm-try,vm-kernel-precomp-linux-release-simarm_x64-try,vm-kernel-precomp-linux-debug-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/206222
Reviewed-by: Tess Strickland <sstrickl@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2021-07-12 09:36:19 +00:00
Daco Harkes 172e1bee70 [vm] Introduce LinkedHashBase
In separate CL so that the LinkedHashMap CL is a bit smaller.

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

TEST=tests/**_test.dart

Change-Id: I4ecff40a40fffbad4d9c37ca426066128c0ed7f7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/206223
Reviewed-by: Tess Strickland <sstrickl@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2021-07-08 20:28:44 +00:00
Johnni Winther 91d55ad64d [sdk] Update String.substring to use RangeError.checkValidRange
This improves the runtime error by correctly reporting that the end
index is not within range for `"abcdefgh".substring(5, 2)` instead of
reporting that the start index is invalid.

Change-Id: If6fd0223f311c75fc44fe9123b4b2b070031e6c7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/194240
Reviewed-by: Lasse R.H. Nielsen <lrn@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2021-07-07 13:16:57 +00:00
Lasse R.H. Nielsen 3835374fb9 Update Symbol constructor documentation.
No longer state that it only accepts some strings as arguments.
Document the expected equality, and the relation to symbol literals.

Fixes #46521

BUG= https://github.com/dart-lang/sdk/issues/46521

Change-Id: If317beda0ac4fef380583105f0f5a3b4b456049b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/205791
Commit-Queue: Lasse R.H. Nielsen <lrn@google.com>
Reviewed-by: Erik Ernst <eernst@google.com>
2021-07-05 16:41:57 +00:00
Martin Kustermann 7159c26400 Revert "[vm/concurrency] Ensure fixes to switchable call (due to disabled code) is correctly performed"
This reverts commit 606a1e76be.

Reason for revert:

   - Caused failures on dartk-optcounter-linux-release-x64 builders.
   - Caused failures of MicroClosureCreateTearoffClassSecondTime benchmark

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

TEST=Existing test coverage.

Change-Id: I5da92bd6b82a33e6283d3b438575376e53b0bed1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/205795
Reviewed-by: Martin Kustermann <kustermann@google.com>
2021-07-03 07:38:18 +00:00
Martin Kustermann 606a1e76be [vm/concurrency] Ensure fixes to switchable call (due to disabled code) is correctly performed
If two mutators concurrently execute a switchable call that targets a
code object which has been disabled, they both go to runtime trying to
fix that switchable call site's object pool.

This Cl ensures we use the same logic as for other miss handlers to
ensure we properly guard against concurrent accesses.

The attached regression test will trigger a segfault - though only
with low probability.

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

TEST=vm/dart{,_2}/isolates/regress_46539_test

Change-Id: I91d84d25d74fb742ea992016a581b118345dd404
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/205649
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2021-07-02 12:47:31 +00:00
Vyacheslav Egorov f5326473c2 [vm/compiler] Remove StringInterpolate instruction
This instruction is essentially just a StaticCall to a fixed
target. Make this explicit by actually using StaticCall to
represent it.

TEST=existing tests

Change-Id: I50b8415ed917eb7c784170e4ee8836f1b99186b3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/205640
Commit-Queue: Slava Egorov <vegorov@google.com>
Reviewed-by: Tess Strickland <sstrickl@google.com>
2021-07-01 12:57:32 +00:00
michaellee8 4160a6b361 [Http] Fix handling of ipv6 address in host header
The current implementation of _HttpHeaders._addHost does not handle
ipv6 address correctly. This patch fixes the handling and add test
case for that.

References:

- https://github.com/flutter/flutter/issues/83609#issuecomment-870356766

TEST=http_headers_test.dart has been updated with new cases.

Bug: https://github.com/flutter/flutter/issues/83609#issuecomment-870356766
Change-Id: Idc4e9bbe66d66f0d846c7a32a40854201c3b0153
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/205280
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
2021-07-01 01:18:44 +00:00
Mayank Patke c6e3cd8228 [dart2js] Save some array allocations in the RTI.
Change-Id: Ie77ed930c69caf5d0eba1b6171299c02d97a29be
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/204945
Reviewed-by: Stephen Adams <sra@google.com>
Commit-Queue: Mayank Patke <fishythefish@google.com>
2021-06-30 22:29:05 +00:00
Riley Porter 63ac437e99 Optimize js_util callMethod calls for 0-4 arguments.
Change completes initial set of js_util optimizations. Some usages
of `getProperty`, `setProperty`, and `callMethod` with <= 4
arguments will have unnecessary checks removed by the compilers.

Change-Id: I94d5402ca9a64ad2818fd6d6a5f7f114f87348c5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/204562
Commit-Queue: Riley Porter <rileyporter@google.com>
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2021-06-30 20:11:44 +00:00
Nicholas Shahan 77e34329ef [ddc] Fix performance regression in dynamic calls
A previous fix for `Function.apply()` correctness caused a regression in
all dynamic calls that pass positional and named arguments.
- https://dart-review.googlesource.com/c/sdk/+/204900
- Performance regression: https://golem.corp.goog/PerformanceChanges?repository=dart&revision=92977
- Performance fix: https://golem.corp.goog/Comparison?repository=dart&team=dartdevc#targetA%3Ddartdevc%3BmachineTypeA%3Dlinux-x64%3BrevisionA%3D92979%3BpatchA%3Dnshahan-dynamic-perf%3BtargetB%3Ddartdevc%3BmachineTypeB%3Dlinux-x64%3BrevisionB%3D92978%3BpatchB%3DNone

Now, the positional arguments list is only copied when necessary in
`Function.apply()` before passing to `_checkAndCall()` which may modify
the list of provided positional arguments. The modification is fine in
all other cases since the list is created by the compiler as defined by
the dynamic calling conventions.

Change-Id: Ia7caffa49156e120c0e00653c8d49462a28f8276
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/205243
Commit-Queue: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Mark Zhou <markzipan@google.com>
2021-06-30 01:33:22 +00:00
Konstantin Shcheglov a14726a886 Issue 46506. Remove 'ignore: unused_element' for @pragma(vm:entry-point)
Now that we understand them, we don't need to ignore.

Bug: https://github.com/dart-lang/sdk/issues/46506
Change-Id: Iab94f14a34f09826dd2101fd4a1bc54909915d56
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/205341
Reviewed-by: Devon Carew <devoncarew@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2021-06-29 20:51:49 +00:00
Zach Anderson 46189bcb19 Allow configuring the destination of the SDK in the build output directory
This is needed for the Flutter Engine to use a prebuilt Dart SDK as in
https://github.com/flutter/engine/pull/26931. When using a prebuilt
Dart SDK, the rules producing the built SDK are directed to a
different location so that GN doesn't warn about multiple rules that
produce the same file.

TEST=locally with a flutter/engine checkout
Change-Id: I4095f379c772c63f93a1c88c7f4e44804f3a6fc7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/204760
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Zach Anderson <zra@google.com>
2021-06-29 18:45:29 +00:00
Devon Carew ee1774ca6c several minor edits to various dart-lang/sdk files
Change-Id: I62e5b46811ef5d4d4f280a9e334ba87a355bc1cc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/205302
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Devon Carew <devoncarew@google.com>
2021-06-29 17:47:48 +00:00
Janice Collins 6876eb83b6 Correct a link error that snuck in after the last pass.
Change-Id: I71fa21ef33e7726f8b663809c605c9a2a8dfe6da
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/205300
Commit-Queue: Janice Collins <jcollins@google.com>
Reviewed-by: Devon Carew <devoncarew@google.com>
2021-06-29 17:12:30 +00:00
Janice Collins f899fd1310 Update SDK documentation for new lookup code.
This fixes existing problems in the SDK documentation, and corrects
expressions that were invalid but ignored in the previous version of
dartdoc.

Change-Id: Ic06b6bce7a886f8e5ce797594d37e382fe37bd40
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/205068
Commit-Queue: Janice Collins <jcollins@google.com>
Reviewed-by: Devon Carew <devoncarew@google.com>
2021-06-28 17:33:30 +00:00
Hoylen Sue 4b82a5f5c2 Added documentation about out-of-range components to DateTime.parse.
The [DateTime.parse](https://api.dart.dev/stable/2.10.4/dart-core/DateTime/parse.html) method accepts out-of-range components. For example, parsing the string "2020-01-42" produces "2020-02-11".

This was raised as a bug in https://github.com/dart-lang/sdk/issues/11189, but after more than 7 years that issue was closed with the solution being "use parseStrict from the intl package" instead.

This pull request simply **updates the documentation of DateTime's _parse_ method** so that users know:

1. This is how the method behaves. Otherwise they might be surprised when it unexpectedly happens in their code.
2. This behaviour is a feature and not a bug. Otherwise they might raise another issue for it.
3. The _parseStrict_ method in the intl package exists. Otherwise they might reinvent the wheel.

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

GitOrigin-RevId: a88ada479d6664cac69a6dc44de3fe2a41f8e9be
Change-Id: Ic45e4db118bd3fad3a612659a35ca7a5d80937b4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/176680
Reviewed-by: Lasse R.H. Nielsen <lrn@google.com>
Commit-Queue: Lasse R.H. Nielsen <lrn@google.com>
2021-06-28 06:45:51 +00:00
Mayank Patke 58ad941a5a [dart2js] Fix interface subtyping bug.
Previously, when checking S <: T, we only checked if S and T had the
same interface name once. However, it's possible that redirections
eventually cause them to become equal. For example, if S is an interop
type and T is JavaScriptObject, after following the redirection from S
to JavaScriptObject, we end up checking JavaScriptObject <:
JavaScriptObject. Therefore, we need to recheck after following each
redirection.

Change-Id: Ie3eb9530627a0e48a5ea704fd4078ae238a65c78
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/204744
Commit-Queue: Mayank Patke <fishythefish@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
2021-06-25 22:34:06 +00:00
Stephen Adams 3d081f907a [dart2js] Clean up tear-off code
- Simplify tear-off signatures
- Make BoundClosure have consistent Dart receiver
- Use receiver/interceptor terminology rather than self / self+receiver

Change-Id: Ifb6c52cc7a9475b79e468efb19eb76f70ec5cd09
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/204680
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2021-06-25 21:51:20 +00:00
Nicholas Shahan e2cb0b8553 [ddc] Fix function apply arguments list
- Fix default value assignment when passing a list of positional
  arguments that isn't a dart:core `List` at runtime.
- Fix modification of the original list passed as positional arguments
  when also passing named arguments.

Change-Id: I3aef6b1584f159c92251b963ffb927e1f75d3472
Fixes: https://github.com/dart-lang/sdk/issues/46457
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/204900
Reviewed-by: Stephen Adams <sra@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
2021-06-25 15:44:15 +00:00
Lasse R.H. Nielsen 43cff26365 Add supertype to enum classes.
TEST= language/enum/enum_test

Change-Id: I83b7fd1c29103c3aa4dc7ad3e41141fb8c62339e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/203564
Commit-Queue: Lasse R.H. Nielsen <lrn@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2021-06-25 14:08:16 +00:00
Lasse R.H. Nielsen 83376bf1ee Add Object.hash and Object.hashAll static helper methods.
Fixes #11617.

Bug: http://dartbug.com/11617
Change-Id: Id06fb5b3914bee24713427edbd3b9b7e86f86449
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/73360
Commit-Queue: Lasse R.H. Nielsen <lrn@google.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
2021-06-25 11:40:35 +00:00
Stephen Adams 8fda1d6cf3 [js_runtime] Don't modify inputs to Function.apply
In some cases adding default arguments modified the 'positional'
arguments input List.  Since there are 'accelerated' paths for small
numbers of arguments, this bug did not show in any other tests.

Change-Id: I5075c96ecfdc9645b85b9beeeb38305415153d20
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/204747
Commit-Queue: Stephen Adams <sra@google.com>
Reviewed-by: Mayank Patke <fishythefish@google.com>
2021-06-24 03:29:38 +00:00
Mayank Patke 3405b94338 [dart2js] Remove Symbol.validated.
Bug: https://github.com/dart-lang/sdk/issues/46397
Fixes: https://github.com/dart-lang/sdk/issues/46397
Change-Id: I307f486deb7afe72c347bfeb6779cb9389d1ff13
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/204601
Reviewed-by: Stephen Adams <sra@google.com>
Commit-Queue: Mayank Patke <fishythefish@google.com>
2021-06-23 20:58:18 +00:00
Mayank Patke c015e02180 [dart2js] Fix spurious ! in ConstantMap.
Change-Id: I45ab75005c4f3d658c476886ede3ba37dbb067e9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/204625
Commit-Queue: Mayank Patke <fishythefish@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
2021-06-23 18:30:11 +00:00
Stephen Adams 11991056b6 Specialize closures for 0 and 2 arguments
Change-Id: Ia21249cb9671960eb3e0d96afef5e5efb8ba7ee2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/105200
Commit-Queue: Stephen Adams <sra@google.com>
Reviewed-by: Joshua Litt <joshualitt@google.com>
2021-06-23 16:54:41 +00:00
Lasse R.H. Nielsen f89ed9bfc3 More elaborate error when a future error handler returns something of the wrong type.
Bug: https://github.com/dart-lang/sdk/issues/44386, https://github.com/dart-lang/sdk/issues/41313
Change-Id: I87b10c3cd03475f4cd80b7a7c5cba6a558167748
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/175062
Reviewed-by: Nate Bosch <nbosch@google.com>
Commit-Queue: Lasse R.H. Nielsen <lrn@google.com>
2021-06-23 11:25:25 +00:00
Ben Konyi 3a4b3514bc [ VM / Service ] Add UserTag support to C-API and send UserTagChanged
events on Developer stream.

Also removes intrinsic implementations for UserTag_makeCurrent to allow
for service events to be sent on UserTag change.

TEST=DartAPI_UserTags,pkg/vm_service/test/user_tag_changed_test.dart

Change-Id: I5dc9ee77c0048590d3c6e33a652eee5bc3bf522a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/204440
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2021-06-23 00:58:47 +00:00
Nate Bosch 1948bd6109 Add fixes for HttpStatus constants
Add rename migrations for all the screaming snake case constants that
were renamed to lower camel case during the Dart 2 migraiton.

Rename the test from `file.dart` to `io.dart` so that we can test all
deprecations for the same import together. Add a test for the same
deprecations when imported through `dart:html`.

Change-Id: Iee91d88b1b11648e8c65cfcc8d2fcfabac3954ec
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/203820
Auto-Submit: Nate Bosch <nbosch@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Lasse R.H. Nielsen <lrn@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
2021-06-22 23:39:57 +00:00
Lasse R.H. Nielsen 902f149e2c Add unawaited function and ignore extensions member.
The `unawaited` function in `dart:async` is intended for use with the `unawaited_futures` lint which is hopefully going to be part of the Dart recommended set of lints.

The `ignore` extension method is there to provide an alternative if you even want to ignore errors from a future. By having both, it makes the distinction clearer and makes it easier to not think one can be used for everything.

Change-Id: Ib96ed5ff64ead4b228721e5210efa82f76119c9f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/200428
Reviewed-by: Jacob Richman <jacobr@google.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
Commit-Queue: Lasse R.H. Nielsen <lrn@google.com>
2021-06-22 20:03:13 +00:00
Lasse R.H. Nielsen 19252d5786 Fix behavior for -infinity width/height of rectangles.
Fixes #30186
BUG= dartbug.com/30186

Change-Id: I2994d180a4dc4d4e4bba7edec67bc2bcc2e8fc0b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/201568
Auto-Submit: Lasse R.H. Nielsen <lrn@google.com>
Commit-Queue: Lasse R.H. Nielsen <lrn@google.com>
Reviewed-by: Erik Ernst <eernst@google.com>
2021-06-21 13:29:39 +00:00
Jason Simmons 2f9f746d83 Fix a typo in the Object docs (exception -> except)
Change-Id: Ie160e4b7daa2f989e23edf9f5248b612681d285e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/204262
Reviewed-by: Lasse R.H. Nielsen <lrn@google.com>
Commit-Queue: Lasse R.H. Nielsen <lrn@google.com>
2021-06-19 11:19:13 +00:00
Martin Kustermann 2ed0bb3596 [vm/concurrency] Allow rehashing of linked hashmaps that contain deleted entries
When rehashing linked hash maps we'll allow rehashing of hashmaps that
have deleted entries in them. This avoids making assumptions about the
state of a linked hashmap object at the time when it's transitively
copied.

It was split out of a follow-up CL that adds transitive object copies,
which will copy linked hashmaps as they are.

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

TEST=Existing test coverage.

Change-Id: Ia844a14a3893e2416a11fa99d9de38025d6fac7e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/203773
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2021-06-18 05:58:11 +00:00
Tomasz Kontusz b14e5ed355 [doc] setTrustedCertificates doesn't replace certs
With the previous wording, "Sets the set of ... certificates", I've assumed it always replaces everything in the store (at least on non-iOS).
This change should make it clear that the certificates are added.

(See also bc2cf88bac/runtime/bin/security_context.cc (L181) for the actual implementation).

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

GitOrigin-RevId: 04d6cdece5f707af3e4d74aca983e4025fcc6cde
Change-Id: Ib3d3dcf41b78cb3925947d58e5c980b7bb82f331
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/203720
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2021-06-16 08:35:05 +00:00
Nicholas Shahan c83eeac5b8 [ddc] Avoid sending messages to console.debug
Calling `postEvent()` or `registerExtension()` from the
dart:developer library now sends messages via global functions
that can be set by the development infrastructure. For example,
these hooks are set by package:dwds.

When there is no debugger attached to the app, calling `postEvent()`
or `registerExtension()` will produce a warning once each to avoid
spamming the debug log with messages that do nothing.

For backwards compatibility, when a debugger is attached but the
hooks have not defined continue to write the events to the
console.debug log. This support will be removed when package:dwds
no longer reads from the log.
https://github.com/dart-lang/webdev/issues/1342

Change-Id: I126446666b5a85c68424546b8b1198d1582bba74
Issue: https://github.com/flutter/flutter/issues/75225
Fixes: https://github.com/dart-lang/sdk/issues/36143
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/202540
Commit-Queue: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Gary Roumanis <grouma@google.com>
Reviewed-by: Mark Zhou <markzipan@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2021-06-15 23:28:03 +00:00
Stephen Adams 8a60ce9e6d [dart2js] Pass tear-off parameters in an object
- Pass tear-off parameters in an object rather than a large number
  of variables.

- Reduce number of fields for BoundClosure. This speeds up tear-off
  creation 7-20%

-

Change-Id: Idf5313d5709a098cd5c877871417304f4e4c5b56
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/203445
Commit-Queue: Stephen Adams <sra@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2021-06-15 22:19:13 +00:00
Clement Skau a7210551ca [VM] Nit: rename var with keyword name "native"
Change-Id: Id612c11d21f67734a95aaafd6ff19a017e44dd32
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/203681
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Clement Skau <cskau@google.com>
2021-06-15 11:07:50 +00:00
Clement Skau 2f916ad807 [vm/ffi] Adds @FfiNative() support
Adds support for marking external functions as @FfiNative's,
which will be called using fast FFI calls.

Resolution happens by calling out to a new embedder provided
Dart_FfiNativeResolver which the embedder can specify via
Dart_SetFfiNativeResolver.

TEST=vm/cc/DartAPI_FfiNativeResolver

Bug: https://github.com/dart-lang/sdk/issues/43889
Change-Id: I3cfff360b05314499a81444b90f4ea0a1b937b0b
Cq-Do-Not-Cancel-Tryjobs: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/170092
Commit-Queue: Clement Skau <cskau@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2021-06-15 05:58:39 +00:00
Gabriel Castro 820ba59dda [html] Fix nested JS Map to Dart assignment
Added check to convertNativeToDart_Dictionary to recursively convert native objects within a map to their Dart equivalent.

Fixes: https://github.com/dart-lang/sdk/issues/44319
Change-Id: I80a2bc0541454900b1c7d9635debaf72d7c120f2
Bug: 44319
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/201200
Commit-Queue: Gabriel Castro <gabrielmcastro@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Srujan Gaddam <srujzs@google.com>
2021-06-14 21:18:08 +00:00
Lasse Reichstein Holst Nielsen fdcc930bd0 Update String.split documentation.
Fixes #46280
BUG= http://dartbug.com/46280

Change-Id: I8425cb71fb3cdf97bd59ad48232f0ebb07878e3b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/202771
Auto-Submit: Lasse R.H. Nielsen <lrn@google.com>
Commit-Queue: Nate Bosch <nbosch@google.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
2021-06-14 19:15:07 +00:00
Martin Kustermann 65bca53b6e [vm] Avoid going to runtime for String.split()
This makes the small benchmark on the github issue more than 2.5x
faster.

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

TEST=Existing test suite.

Change-Id: I82c53b3553e04f2afe23606b09b3199cb9b6a926
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/203502
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Tess Strickland <sstrickl@google.com>
2021-06-14 14:41:33 +00:00
Lasse Reichstein Holst Nielsen 2951e33b24 Add extra documentation on asBroadcastStream.
Fixes #30395
BUG= https://github.com/dart-lang/sdk/issues/30395

Change-Id: I887b4b5882b9f4801f29690c2d039941eb99efd1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/201567
Auto-Submit: Lasse R.H. Nielsen <lrn@google.com>
Commit-Queue: Lasse R.H. Nielsen <lrn@google.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
2021-06-14 09:44:42 +00:00
Alexander Aprelev 52aa8508f1 [io/stacktraces] Ensure websocket connect reports callers stacktrace.
Introduce dwarf-friendly socket connect stacktrace test.

TEST=socket_connect_dwarf_stacktrace_test

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

Change-Id: I428ac4b334d9d80ea06c64283ece3ff411abfa19
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/203160
Reviewed-by: Zach Anderson <zra@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2021-06-10 16:16:50 +00:00
Stephen Adams 8ee467361b [dart2js] Fix for #46175
Pass compile-time shadowing information through tearoff code, rather
than trying to feature-test for potential overrides of the method
accessed via a super-getter.

Bug: 46175

Change-Id: Idca8e440cf12bb6cbae020f305763575e6a37b08
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/202803
Commit-Queue: Stephen Adams <sra@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2021-06-10 03:30:09 +00:00
Ryan Macnak 84e6d4a4e8 [vm] Make use of the new TypedDataBase to avoid redundant code in the runtime.
Reduces VM code size by about 18k.

TEST=ci
Change-Id: Ic0dbdb6a7807a0f0d37333c6f32bed5cb3e7b905
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/202543
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2021-06-08 19:15:38 +00:00
Alexander Aprelev 80749188ca [io/socket] When socket connection fails report stacktrace of the callsite.
Currently stack trace reported on thrown exceptions is null.

TEST=socket_connect_stacktrace_test.dart

Bug: https://github.com/dart-lang/sdk/issues/44994
Change-Id: I188aff197ab519272f63f41387b94458c2f1cec7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/202802
Reviewed-by: Zach Anderson <zra@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2021-06-08 16:17:47 +00:00
Lasse Reichstein Holst Nielsen 1154efb073 Fix null-safety migration bug in VM version of fuse JSON-UTF-8 decoder.
A JSON value can be `null`, so the return type must be `Object?`, not `Object`.

Fixes #46205.

Bug: http://dartbug.com/462051
Change-Id: I9a5522e09765457dcf8cd2639abbe385d97a3186
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/202623
Reviewed-by: Erik Ernst <eernst@google.com>
Commit-Queue: Lasse R.H. Nielsen <lrn@google.com>
2021-06-07 11:43:02 +00:00
Alexander Aprelev 3cd209692c [io/android] Enable file watching on Android.
Fixes https://github.com/dart-lang/sdk/issues/46261
File watching was partially disabled on android despite working as expected with
minor detail that [read] from inotify returns -1 at the end of the stream.

TEST=file_system_watcher_large_set

Change-Id: I4ce7a89ab1e531d91b62d0363ebc36f919d5b8a7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/202500
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2021-06-05 01:33:27 +00:00
Sigmund Cherem 80160d3efb [dart:html] add syntax highlighting to code blocks
Change-Id: I7dc008c01e776be8010da4845b3dc95643e34194
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/202401
Auto-Submit: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Srujan Gaddam <srujzs@google.com>
2021-06-04 01:07:35 +00:00
Alexander Aprelev 6c254fab89 [io/http] Don't add zero-valued content-length header on GET, HEAD, DELETE, CONNECT requests.
Per https://tools.ietf.org/html/rfc7230#section-3.3.2:
"... A user agent SHOULD NOT send a
Content-Length header field when the request message does not contain
a payload body and the method semantics do not anticipate such a
body."

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

Change-Id: I96b735c06038eb3d12a303ee5329228a9b594726
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/194881
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
Reviewed-by: Lasse R.H. Nielsen <lrn@google.com>
2021-06-03 16:14:24 +00:00
Robert Nystrom 4333b3db98 Add deprecation warning to dartfmt.
Change-Id: I7c67041fc84cddbc44b54e629eee79548fd6566b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/202144
Reviewed-by: Michael Thomsen <mit@google.com>
Commit-Queue: Michael Thomsen <mit@google.com>
Auto-Submit: Bob Nystrom <rnystrom@google.com>
2021-06-03 10:11:24 +00:00
Mayank Patke 93c96d5857 [dart2js] Implement basic lowering for late instance variables.
This feature is gated behind the --experiment-late-instance-variables
flag.

Change-Id: I1ecb2d4d960b58204207ea055361463efa3a0bcb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/200922
Commit-Queue: Mayank Patke <fishythefish@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
2021-06-02 23:21:24 +00:00
Stephen Adams d3d6c86fe1 [dart2js] Migrate shared libraries to 2.12
Change-Id: I5600fe01e90963b56a6ffa36ec9edf0096088b2b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/202000
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2021-06-02 21:41:34 +00:00
Simon Binder be893fdf27 [vm/ffi] Add providesSymbol to DynamicLibrary
This adds the providesSymbol method to DynamicLibrary. It returns
whether the library contains a function with the given name.

As per dlsym(3), it is valid for dlsym to return nullptr in a success
case if the symbol actually has a NULL value. So I've changed the logic
to check for dlerror() after we invoke dlsym(), both in the existing
lookup and in the new method.

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

TEST=tests/ffi(_2)/has_symbol_test.dart

Change-Id: Ibcb1c051cc0cdd95a104fe86ef2fc76da5bafb5d
Cq-Include-Trybots: luci.dart.try:vm-precomp-ffi-qemu-linux-release-arm-try,vm-ffi-android-debug-arm64-try,vm-ffi-android-debug-arm-try,vm-kernel-linux-debug-x64-try,vm-kernel-win-debug-x64-try,vm-kernel-mac-debug-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/201900
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2021-06-02 16:01:43 +00:00
Jason Simmons b67de429e0 Move the frontend server snapshot into the platform SDK
Change-Id: I15bfa8690fe792a4f0c4ac66a337fdc9c2647626
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/201920
Reviewed-by: Jake Macdonald <jakemac@google.com>
Reviewed-by: Zach Anderson <zra@google.com>
Commit-Queue: Jake Macdonald <jakemac@google.com>
2021-06-01 21:05:35 +00:00
Ryan Macnak ab91ef643c [vm] Remove code dead since the type 'int' stopped supporting integers.
Change-Id: I72e1760a8172d8486b634abddbfc1ca8759a375c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/197441
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2021-06-01 17:18:33 +00:00
Riley Porter f08edad8ce Optimize js_util setProperty calls for non-function values to
_setPropertyUnchecked version that can be inlined.

No change in the generated JavaScript for dart2js.

Change-Id: Ie4a8e5a34826b6c9083d34656aaa27050635cb21
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/200933
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Riley Porter <rileyporter@google.com>
2021-05-25 19:28:01 +00:00
Stephen Adams 7572e5ba4a [js_runtime] Speed up 'is List' test on negative path
Change-Id: Ie8849837a394724fb3e8419eacc283d8cd370d69
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/201229
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2021-05-25 18:03:01 +00:00
Michael Thomsen cac00e9d95 Add deprecations notices to dart2native
Related to: https://github.com/dart-lang/sdk/issues/46100

Change-Id: I2bcd4aadfbc96fa6ba265aec04cd60e3e81eef41
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/199429
Commit-Queue: Michael Thomsen <mit@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
Reviewed-by: Devon Carew <devoncarew@google.com>
2021-05-25 13:20:30 +00:00
Clement Skau 4d5055805f [VM/FFI] Adds FFI leaf calls.
This CL adds FFI leaf calls by adding `lookupFunction(.., isLeaf)`
and `_asFunctionInternal(.., isLeaf)`, which generate FFI leaf calls.
These calls skip a lot of the usual frame building and generated <->
native transition overhead.

`benchmark/FfiCall/` shows a 1.1x - 4.3x speed-up between the regular
FFI calls and their leaf call counterparts (JIT, x64, release).

TEST=Adds `tests/ffi{,_2}/vmspecific_leaf_call_test.dart`. Tested FFI tests.

Closes: https://github.com/dart-lang/sdk/issues/36707
Cq-Include-Trybots: luci.dart.try:vm-precomp-ffi-qemu-linux-release-arm-try,vm-ffi-android-release-arm64-try,vm-ffi-android-release-arm-try,vm-ffi-android-product-arm64-try,vm-ffi-android-product-arm-try,vm-ffi-android-debug-arm64-try,vm-ffi-android-debug-arm-try,vm-kernel-linux-debug-ia32-try,vm-kernel-win-debug-ia32-try,vm-kernel-win-debug-x64-try,vm-kernel-win-release-x64-try,vm-kernel-mac-debug-x64-try,vm-kernel-precomp-nnbd-mac-release-simarm64-try,vm-kernel-precomp-android-release-arm64-try,vm-kernel-precomp-asan-linux-release-x64-try,vm-kernel-precomp-linux-release-simarm_x64-try,vm-kernel-precomp-obfuscate-linux-release-x64-try,vm-kernel-precomp-ubsan-linux-release-x64-try,vm-kernel-precomp-tsan-linux-release-x64-try,vm-kernel-precomp-win-release-x64-try,vm-precomp-ffi-qemu-linux-release-arm-try,vm-kernel-reload-rollback-linux-debug-x64-try,vm-kernel-reload-linux-debug-x64-try
Bug: https://github.com/dart-lang/sdk/issues/36707
Change-Id: Id8824f36b0006bf09951207bd004356fe6e9f46e
Cq-Do-Not-Cancel-Tryjobs: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/179768
Commit-Queue: Clement Skau <cskau@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2021-05-21 11:12:02 +00:00
Alexander Aprelev 8d54a30825 [io/http] Introduce callback that embedder can override to provide custom HTTPClient connection validation.
For example, this can be used to ban insecure http connections, force use of https ones - see https://github.com/flutter/engine/pull/26226.

Issue https://github.com/flutter/flutter/issues/69685
Issue https://github.com/flutter/flutter/issues/54448

Change-Id: Id81aeae9aff0d469ac6f911e4e502b39ce9558bf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/200524
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Lasse R.H. Nielsen <lrn@google.com>
2021-05-20 15:17:52 +00:00
Daco Harkes 413abf0d82 [sdk] Recover folder structure in include folder 2
Such that runtime/include/internal/dart_api_dl_impl.h ends up in
include/internal/dart_api_dl_impl.h in the sdk release.

Long explanation:

https://dart-review.googlesource.com/c/sdk/+/164320 tried to recover the
folder structure but failed to do so correctly. It put
runtime/include/internal/dart_api_dl_impl.h in
include/runtime/dart_api_dl_impl.h rather than
include/internal/dart_api_dl_impl.h.

The gn copy action only supports a single `outputs` string.
https://gn.googlesource.com/gn/+/HEAD/docs/reference.md#var_outputs

This string can have 'placeholders'.
https://gn.googlesource.com/gn/+/HEAD/docs/reference.md#placeholders

The only placeholder that preserves the original folder structure,
without also nesting deeply inside folders is `source_target_relative`.

If `source_target_relative` inside sdk/BUILD.gn it starts including
`runtime/include/` in its path. So the only way to achieve the correct
copy is by doing it in runtime/include/BUILD.gn.

TEST=Manual testing, we don't have tests verifying the SDK structure.

Change-Id: I9d503626266edcdd8417f5cafb0f8ff9746f89f7
Cq-Include-Trybots: luci.dart.try:dart-sdk-linux-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/200866
Reviewed-by: Tess Strickland <sstrickl@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2021-05-20 13:54:42 +00:00
Lasse R.H. Nielsen cf627eb01c Change signature of HttpClient.authenticate{,Proxy}.
Allow the `realm` argument to callbacks to be `null`.
This is a breaking change, but it only affects null-safe code.

Also fix a bug in http_impl.dart where an error function with
an *optional* stack trace parameter would be called without a stack trace.

Bug: https://github.com/dart-lang/sdk/issues/44039
Change-Id: I4b38382328e26478661bf45f46cd3017631f4ebd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/170094
Commit-Queue: Lasse R.H. Nielsen <lrn@google.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
2021-05-20 13:13:42 +00:00
asiva 6f2eeae1a4 [sdk] - Fix for issue 46050 (Allow spaces in environment constants)
TEST=Manual command line test

Change-Id: I0e6e70093df32b4878b32b91ab101af5ffb8d1a9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/200661
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
2021-05-19 19:09:02 +00:00
Stephen Adams cb23be0b5f [rti] Specialized is List<dynamic> test
Change-Id: I7ded143b8316a5b3f78f8fe358cf7341f42d8ddd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/200288
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2021-05-19 01:12:43 +00:00
Lasse R.H. Nielsen 59526f4311 Address missed comments from CL https://dart-review.googlesource.com/c/sdk/+/200189
Change-Id: I54baa2ca802c6524ddf5baf9c205d5c6bb2e9779
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/200223
Reviewed-by: Erik Ernst <eernst@google.com>
Commit-Queue: Lasse R.H. Nielsen <lrn@google.com>
2021-05-18 11:00:14 +00:00
Jacob MacDonald 4da697ce56 fix todos linked to issue #38725
Change-Id: I06fd71b4027673105be8a3219af61fbc9b93e216
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/200282
Auto-Submit: Jake Macdonald <jakemac@google.com>
Commit-Queue: Jake Macdonald <jakemac@google.com>
Commit-Queue: Lasse R.H. Nielsen <lrn@google.com>
Reviewed-by: Lasse R.H. Nielsen <lrn@google.com>
2021-05-17 20:51:52 +00:00
Alexander Aprelev 0aeb8731e5 [vm] Use recognized method for has63BitSmis, drop static final field.
This should improve performance of lightweight isolates configuration

TEST=ci, perf benchmarks

Change-Id: I98ac9a7e02318d58db3431a6d33f08ab95e607fb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/199700
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2021-05-17 17:22:13 +00:00
Lasse R.H. Nielsen c88d8163c0 Update documentation for num.operator< and other members.
Fixes #46015.

Bug: http://dartbug.com/46015
Change-Id: I6a8b245e10c644df84f767df4f24404b332af9b9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/200189
Reviewed-by: Erik Ernst <eernst@google.com>
Commit-Queue: Lasse R.H. Nielsen <lrn@google.com>
2021-05-17 16:56:22 +00:00