Commit graph

21513 commits

Author SHA1 Message Date
Sam Rawlins 3393591b3f Rewrite AST w/ Constructor reference w/ explicit type args
This should handle all cases of constructor reference w/ explicit type
args; there aren't too many cases:

* named and unnamed constructors
* referencing class and referencing type alias
* prefixed class names and not-prefixed
* null-aware access (weird)
* bound on type parameter of class, and on type parameter of alias

error cases:

* cascade
* wrong number of type arguments

Bug: https://github.com/dart-lang/sdk/issues/46020
Change-Id: If257eb561a9ad854709b6e9a7d81faa9d084d6ee
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/209622
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2021-08-10 23:54:49 +00:00
Nicholas Shahan 7ff8c6c6be [tests] Remove not-identical expectation for Type values
The instantiation at runtime implies non-constant type expressions
but canonicalization is unspecified so backends should be allowed
to optimize by canonicalizing types.

Change-Id: I2f1cab6ac68a1ce156b15af0b99e02d03b7b3dca
Issue: https://github.com/dart-lang/sdk/issues/46837
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/209663
Commit-Queue: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Erik Ernst <eernst@google.com>
2021-08-10 18:47:31 +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
Sam Rawlins 9b586a3da6 analyzer: add constructor references from PrefixedIdentifier
Bug: https://github.com/dart-lang/sdk/issues/46020
Change-Id: Ifafea6edb6c9ce7fdf1c1f092ff278738c273bb0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/209300
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2021-08-09 15:03:48 +00:00
Clement Skau bf2691c2fe [VM] Moves FfiNative fields to function parent.
Previously the synthetic field that holds the FfiNative
function pointer was injected into the current library.
This change makes sure we instead add the field to the
relevant parent - Class or Library.

TEST=Added regression test for name collision.

Bug: https://github.com/dart-lang/sdk/issues/43889
Change-Id: Ifbf2d70de00e4748c179fe7d626c495675c2b338
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/208502
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Clement Skau <cskau@google.com>
2021-08-09 09:13:38 +00:00
Alexander Markov 3097b72b2b [vm] Ignore differences in generic-covariant-impl flags of type parameters when doing a subtype check
We might get different flags on lhs and rhs of a subtype check as
lhs might come from a tear-off which has generic-covariant-impl type
parameters and rhs is a standalone function type.

TEST=language/regress/regress46816_test
Fixes https://github.com/dart-lang/sdk/issues/46816

Change-Id: Ic0f1b4a9fdf0f4c9ae65c8c372d12c1e51ad8050
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/209265
Reviewed-by: Tess Strickland <sstrickl@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2021-08-07 21:03:46 +00:00
Alexander Aprelev 003e79752c [gardening] Ensure directory_fuzz_test creates test directories in temp folder, not in check-out location.
Fixes https://github.com/dart-lang/sdk/issues/46737

This is similar to https://dart-review.googlesource.com/c/sdk/+/208285

TEST=directory_fuzz_test

Change-Id: Ia74e221ac7095fd6fc4729aec51770df5eabdbe0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/209105
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2021-08-06 15:32:22 +00:00
Erik Ernst 167cd029e2 Restore function object equality related tests
This CL restores the equality related tests in
tests/language/closure/identity_equality_tearoff_test.dart that we had
in https://dart-review.googlesource.com/c/sdk/+/202243, but removed
in order to finalize language team discussions about equality of
function objects, based on language issue #1712.

Note that these additional test cases do not include any cases involving
tearoffs of extension methods, they will be dealt with separately.

Change-Id: I84daaf91229bd0d0f4c64446bb71cb87f32eedfc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/205081
Commit-Queue: Erik Ernst <eernst@google.com>
Reviewed-by: Lasse R.H. Nielsen <lrn@google.com>
2021-08-06 15:31:19 +00:00
Erik Ernst 844bdde9d9 Adjust aliased_type_literal_instantiation_test to expect dynamic
Said test expects a raw type literal (e.g., `Direct`) to evaluate to an
instantiation where the type argument is `Object?` (`Direct<Object?>`),
but the type argument is actually chosen by instantiation to bound,
so the resulting type argument is `dynamic` (`Direct<dynamic>`). This
CL adjusts the test to expect `dynamic`.

Bug: https://github.com/dart-lang/sdk/issues/46811
Change-Id: I06af0bf87ccb5e980e88416085921948dd5234d1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/209081
Reviewed-by: Lasse R.H. Nielsen <lrn@google.com>
Commit-Queue: Erik Ernst <eernst@google.com>
2021-08-05 10:05:38 +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
Alexander Markov 300a2ea952 [cfe] Create normal bodies for redirecting factories
Replace bogus body created for redirecting factories with a
normal body which calls target factory or constructor and
forwards all arguments. Such a body can be used by back-ends
if they choose to treat redirecting factories as ordinary
factories.

TEST=ci
Fixes https://github.com/dart-lang/sdk/issues/41915
Issue https://github.com/dart-lang/sdk/issues/46231

Change-Id: I62c83bcc9005995e85de049d3d929ca86a75297f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/208681
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2021-08-04 17:51:07 +00:00
Erik Ernst 996f1c945e Adjust constructor and type literal instantiation tests
The test aliased_constructor_tear_off_test.dart expected torn off
constructors to be unequal even in cases where the same constructor
is torn off and instantiated with the same type argument (albeit a
non-constant type). That equality _should_ hold, and this PR makes
the change needed to give the test that expectation.

The test tear_off_test.dart was adjusted similarly.

Change-Id: I79c8dbd312a393b4f509aa28fc46c06ffc77da5d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/208658
Reviewed-by: Lasse R.H. Nielsen <lrn@google.com>
Commit-Queue: Erik Ernst <eernst@google.com>
2021-08-04 12:53:30 +00:00
Johnni Winther 43c00097c2 [cfe] Remove isOptOutTest work-around
Change-Id: I7dd125508bba256eb4c78b02fb24e433f45b129a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/205420
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2021-08-04 10:44:00 +00:00
Ryan Macnak d9bb68f93a [vm] Fix serialization of SIMD vectors.
Broken by bbefc05748.

TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/46793
Change-Id: I8e5869caee2d705cecaf974cca3ee3f0c542ad3c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/208840
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2021-08-03 19:48:50 +00:00
Erik Ernst 0edf000b87 explicit_instantiated_tearoff should expect unequal ext. method tearoffs
Extension method closurizations are specified to be unequal unless they
are identical (because the extension itself may have different type
arguments, so it's not enough that it is "the same method").

This CL changes the test
language/generic_methods/explicit_instantiated_tearoff_test.dart
such that its expectations match that property.

Change-Id: Ife31646623099ad5d1b970d0097d37d6b00c5814
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/208645
Commit-Queue: Lasse R.H. Nielsen <lrn@google.com>
Reviewed-by: Lasse R.H. Nielsen <lrn@google.com>
2021-08-03 14:11:29 +00:00
Riley Porter d63c2dfa83 [package:js] Allow external extension members for Native classes
Change-Id: I5baf81c3c2b6b3a112327e1aea084a93677bd9b5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/208380
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Riley Porter <rileyporter@google.com>
2021-07-30 18:43:47 +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
Alexander Aprelev 2f0c35ea0b [vm/gardening] Revert changes to datagram test to accommodate unreliable nature of datagram packets delivery.
On Windows even on localhost datagrams are being sometimes dropped, which is a little surprising but not impossible.
So this CL reverts changes to the test that expects all datagrams to be received.

This is follow-up to https://dart.googlesource.com/sdk/+/d8839511737dbd1775f37cb5a13862bd7d6f4b88

TEST=raw_datagram_read_all_test on Windows

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

Change-Id: I498b9d8c2ea7849de0f3e91acc952043a9312589
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/208345
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2021-07-28 19:53:14 +00:00
Alexander Aprelev 828cd72cd8 [vm/gardening] Ensure test waits for files to be deleted before deleting temp folder.
This is follow-up to d883951173.

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

Change-Id: I342402cbe959e4f0422d84df39e4368117fd9ca5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/208342
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2021-07-28 19:03:44 +00:00
Alexander Aprelev d883951173 [vm/gardening] Cleanup file_fuzz_test and raw_datagram_read_all_test.
This is follow-up to https://dart.googlesource.com/sdk/+/babfe05e4a9e892d71f8f6ebcb6df82095bea0da and https://dart.googlesource.com/sdk/+/f424f3a4cca306513e77c7747682f1c1c99e3307.

TEST=ci

Change-Id: Ic4143f9eec90cd2a6218d4f33fdc29d298ef3c05
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/208340
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2021-07-28 16:52:54 +00:00
Alexander Aprelev f424f3a4cc [vm/gardening] Fix file_fuzz_test so it doesn't create files in the dart sdk checkout root.
Fixes https://github.com/dart-lang/sdk/issues/46737

TEST=Ensure file_fuzz_test doesn't create 'a' file

Change-Id: I200bc63a86f75e0b770f1a2240a9e2bfdc99aef6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/208285
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2021-07-28 02:20:13 +00:00
Alexander Aprelev babfe05e4a [vm/gardening] Increase wait on receive side for all datagrams to make it.
The test seems to flakily fail on regular bots, fail on reload bots because of aggressive hardcoded wait on receive side of RawDatagramSocket test.

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

TEST=raw_datagram_read_all_test on ci

Change-Id: Ic9c7cec619783b102b14396fb694467d5030b5dc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/208284
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2021-07-28 00:57:43 +00:00
Riley Porter 16ac19d097 [package:js] Add checks for external extension members.
Reports an error if there are external members in an extension,
where the extension on type is not a JS interop class. A follow
up change will allow extensions with external members on some
Native classes, like dart:html classes.

Change-Id: I01c645aa46e46071aae5f380c5e36329f61d3e18
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/207722
Commit-Queue: Riley Porter <rileyporter@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Srujan Gaddam <srujzs@google.com>
2021-07-28 00:41:43 +00:00
Irina Arkhipets d96335f874 [co19_2] Tests skipped according to issues 46483 and 42222
Change-Id: Ie81359c91e39834799cfd8cba0026fe2d0f3b345
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/207130
Reviewed-by: Alexander Thomas <athom@google.com>
Commit-Queue: Alexander Thomas <athom@google.com>
2021-07-27 08:20:57 +00:00
Daco Harkes db90fd784b [test] Replace non-implemented @DontInline() annotations
Remove the `@DontInline()` annotation. None of the backends implemented
it. (Searching for "DontInline" yields nothing in our code base.)

Instead replaced the use sites with `@pragma('vm:never-inline')` and
`@pragma('dart2js:noInline')`, which are implemented in the backends.

Original suggestion:
https://dart-review.googlesource.com/c/sdk/+/208080/4..6/tests/language_2/const/map_hashcode_override_test.dart#b11

Change-Id: Ifdcfc8ef3413d0b5964edc1bc1fa47c5ce306935
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/208082
Reviewed-by: Erik Ernst <eernst@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2021-07-26 13:22:31 +00:00
Daco Harkes a5d4e010af [test] const types and null in const maps and sets
We were lacking tests for doing a `null` lookup in const maps and sets.

Also, we were lacking tests for having type literals with user-defined
classes in const maps and sets.

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

Change-Id: I1665420ddcc71df7b47a87ee9e16d7ebbe9e13f5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/208080
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Erik Ernst <eernst@google.com>
Reviewed-by: Lasse R.H. Nielsen <lrn@google.com>
2021-07-26 12:42:20 +00:00
Johnni Winther 51d10c8c04 [test] Fix constructor tear off tests in language
Change-Id: Icf5f6e99df68cd4194e9f4d9314757eab3d3fe11
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/207661
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
2021-07-23 08:41:09 +00:00
Alexander Markov 6128a39d85 [vm/compiler] Fix handling of delayed type arguments in case of inlined closure call
Previously, prologue builder omitted loading of delayed type arguments
from closure object in case of inling. This would effectively switch
from using delayed type arguments of an instantiated generic closure to
type arguments passed on the stack (null/all-dynamic if none), which is
not correct.

The fix is to load delayed type arguments from closure object even
in case of inlining.

TEST=tests/language/regress/regress46550_test.dart
Fixes https://github.com/dart-lang/sdk/issues/46550

Change-Id: Ibe50b0bc2ebda1d3638c4940fe9a26cd5ba7ce32
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/207704
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Tess Strickland <sstrickl@google.com>
2021-07-22 17:33:39 +00:00
Sam Rawlins ea5333a23f Do not report const ctor with a mixed in abstract final field
Additionally, reduce duplicated errors regarding invalid const constructors.

Fixes https://github.com/dart-lang/sdk/issues/46641
Change-Id: Ica397ad6e28a05bc5340d5ceca236fbedf1e95f6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/207621
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2021-07-21 17:56:08 +00:00
Clement Skau 2f0b352e98 [VM] Adds compile-time error for non-static FfiNative
This makes it a compile-time error to add @FfiNative annotation
to any non-static function, such as an instance method.

TEST=tests/ffi/ffi_native_test.dart,pkg/analyzer/test/src/diagnostics/ffi_native_test.dart

Bug: https://github.com/dart-lang/sdk/issues/43889
Change-Id: Ib9ec61345bb47e735ed635c5ceea15ab643f65a6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/207306
Commit-Queue: Clement Skau <cskau@google.com>
Reviewed-by: Tess Strickland <sstrickl@google.com>
2021-07-20 11:54:30 +00:00
Nicholas Shahan 9c6b1ea4e9 [tests] Add regression tests for #46568
Two different const functions should not be identical.

Change-Id: I3974574c8d0cb34b9cf886532c41e1a77ae632a4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/206422
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
2021-07-19 21:49:49 +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
Martin Kustermann 6a87d049ac [vm] Use unique names for process-anonymous unix domain sockets in test
This will allow running the same test concurrently in multiple isolates
without causing name collisions.

It also aligns the NNBD and non-NNBD test.

TEST=Making test more robust. Fixes one issue in iso-stress builder.

Change-Id: Ic0c15a0f47de8e255d2bdfb96547d44d016b2a72
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/207125
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Tess Strickland <sstrickl@google.com>
2021-07-16 14:23:37 +00:00
Martin Kustermann 627292bcc0 [vm] Remove --experimental-enable-isolate-groups-jit, only guard via --enable-isolate-groups
The JIT support has progressed and is no longer unstable. We'll
therefore remove the experimental flag and rely on the same
--enable-isolate-groups flag as in AOT mode.

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

TEST=Existing test suite.

Change-Id: Iff0dd5b64d9b6ab91ad9ffc0ae445efc802d3908
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/207122
Auto-Submit: Martin Kustermann <kustermann@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2021-07-16 09:13:28 +00:00
Martin Kustermann 91ac6475cb [vm/concurrency] Enable more isolate tests, remove outdated TODOs, fix 2 tests
This CL

  * Removes conditional Skip markers in status files
  * Removes some outdated TODOs in the code
  * Deletes tests/lib_2/isolate/isolate_stress_test
    => It's skipped everywhere, we no longer support isolates on web
  * Fixes standalone{,_2}/io/directory_list_sync_test:
    => Instead of relying on the Platform.script which could be an ELF
       file lying somewhere else, use Platform.executable instead
  * Fixes standalone{,_2}/io/unix_socket_test:
    => The server used `sub.cancel()` to close it's reading end while
       the client tried to write to it. This is racy.
       If the server goes first, the write on client will throw (since
       no error listener was installed on socket.done)
       Avoid the race by coordinating client/server.

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

TEST=Enables more tests.

Change-Id: I0464f81f540f2eda23ef4199cc536e53e6a809b9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/207120
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2021-07-16 07:51:58 +00:00
Martin Kustermann 1ab1438431 [vm] Fix incorrect socket/unix-domain-socket binding code for shared sockets
When creating a binding socket with `shared: true` there will be one
underlying [OSSocket] used. Any following bind on the same address with
`shared: true` will re-use that [OSSocket].

The code that was searching for existing sockets is correct, but the
code that increments the refcount, ... was incorrectly using the start
of the linked list instead of the found existing socket instance.

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

TEST=standalone{,_2}/io/unix_socket_regress_46634_test

Change-Id: I3ce1bdc98ecd4b5311f826ab2597a62fe048be09
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/207083
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2021-07-16 00:27:27 +00:00
Srujan Gaddam 839408f00b Test extensions on and semantics of JavaScriptObject
Tests static extension methods on JavaScriptObject work as
expected, as well as making sure it works with package:js. Once
extension types are added, these tests need to be changed to use
those instead.

Change-Id: I9504c8a3a8e466c680b221e259d93c1df5474218
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/199601
Commit-Queue: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2021-07-16 00:15:09 +00:00
Mayank Patke c559cf04c3 [dart2js] Some DartTypeVisitor cleanup.
This CL deletes BaseDartTypeVisitor and makes all of the visit* methods
in DartTypeVisitor abstract. This forces subclasses of DartTypeVisitor
to provide definitions for all of these methods rather than relying on
some default.

The old code led to a series of bugs with the same root cause: when a
new kind of DartType was added (and a corresponding visit* method added
to DartTypeVisitor), not all concrete implementations of the visitor
were updated to handle the new DartType. This didn't produce static
errors because DartTypeVisitor provided default no-op implementations
for visit* methods. In some cases, this was the desired behavior anyway,
but in practice, any time a new DartType is added, we want our tools to
yell at us until we've validated that it's properly handled everywhere
(even if the proper handling turns out to be "do nothing").

This CL also updates Namer.getTypeRepresentationForConstant to use a
visitor pattern.

Fixes: https://github.com/dart-lang/sdk/issues/46589
Change-Id: I451b592ae1ce4afff40de913535798a62e17b8b6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/206943
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Mayank Patke <fishythefish@google.com>
2021-07-15 19:04:25 +00:00
Clement Skau 06a35b8c2e [VM] Adds test for FfiNative leaf calls.
- Tests that non-leaf calls transition generated -> native,
  and that leaf calls don't.
- Tests that leaf calls with Handle argument or return type
  results in a compile-time error.
- Adds note explaining why there is no ffi_2 version.

TEST=tests/ffi/ffi_native_test.dart

Cq-Include-Trybots: luci.dart.try:analyzer-linux-release-try,analyzer-nnbd-win-release-try,analyzer-analysis-server-linux-try,analyzer-win-release-try,analyzer-nnbd-mac-release-try,analyzer-nnbd-linux-release-try,analyzer-mac-release-try,flutter-analyze-try
Change-Id: I9af60e21f5122f2479c909a52249809850824692
Cq-Do-Not-Cancel-Tryjobs: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/206788
Commit-Queue: Clement Skau <cskau@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2021-07-15 16:14:45 +00:00
Martin Kustermann 6f8304d1f5 [vm] Fix test to use sync file system operations
The test uses a temporary directory that gets deleted once the test
finishes. Though some calls to async methods are not await'ed, so the
directory might get removed before the async methods are completed.

We instead change the test to use synchronous methods consistently. The
regression test is still testing the `rename` method as before.

TEST=Fixes iso-stress builder failures where this issue occurs.

Change-Id: Ide3098fa67de619756417e83df056cf5d1299189
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/207003
Reviewed-by: Tess Strickland <sstrickl@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2021-07-15 09:31:39 +00:00
Srujan Gaddam c261b6574a Filter is_check_and_as_cast_test from CSP target
It uses eval, which is disallowed.

Change-Id: Ib125276560903846eefa3b86125350294ff5d8fd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/206661
Auto-Submit: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2021-07-14 18:10:41 +00:00
Martin Kustermann d6d00b344a [vm] Fix standalone{,_2}/io/issue_30687_test to operate in custom temp directory
All of our tests relying on filesystem operations should operate in a
randomly created temporary directory. This ensures the test will not
interact badly with other tests - running in parallel.

This particular test couldn't be run multiple times concurrently,
since it would cause races to FSE creation/deletion.

TEST=Fixes iso-stress builder issue (which runs tests repeatedly in parallel)

Change-Id: I8b2e015bf4b6a9ecdfa471eb2ec887e634c2b233
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/206783
Reviewed-by: Tess Strickland <sstrickl@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2021-07-14 12:45:00 +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
Ryan Macnak 09cc09cb85 [vm] Don't block OOB messages or reload during field initialization; make interrupts lock-free.
- Account for initialization-in-progress sentinel when checking static field types for reload.
 - Don't read the true stack limit when setting or clearing interrupts.

TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/46596
Change-Id: I80adb4d7d69f01125b7eae8215b5da4d2e467bda
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/206662
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2021-07-14 00:09:10 +00:00
Srujan Gaddam f7c284b9f0 [pkg:js] Add tests for inheritance type checks/casts and subtyping
Adds tests for type checks/casts for pkg:js types that inherit each
other. Similarly, adds subtyping tests for both when types are made
live and when they are not.

Also adds extends_test to lib_2.

Change-Id: Ia3ca03ad9c0291092998d1d3e98d672711fcf8e6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/205602
Commit-Queue: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Riley Porter <rileyporter@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2021-07-13 20:02:49 +00:00
Martin Kustermann 430aa20a1f [vm/concurrency] Implement a fast transitive object copy for isolate message passing
We use message passing as comunication mechanism between isolates.
The transitive closure of an object to be sent is currently serialized
into a snapshot form and deserialized on the receiver side. Furthermore
the receiver side will re-hash any linked hashmaps in that graph.

If isolate gropus are enabled we have all isolates in a group work on
the same heap. That removes the need to use an intermediate
serialization format. It also removes the need for an O(n) step on the
receiver side.

This CL implements a fast transitive object copy implementation and
makes use of it a message that is to be passed to another isolate stays
within the same isolate group.

In the common case the object graph will fit into new space. So the
copy algorithm will try to take advantage of it by having a fast path
and a fallback path. Both of them effectively copy the graph in BFS
order.

The algorithm works effectively like a scavenge operation, but instead
of first copying the from-object to the to-space and then re-writing the
object in to-space to forward the pointers (which requires us writing to
the to-space memory twice), we only reserve space for to-objects and
then initialize the to-objects to it's final contents, including
forwarded pointers (i.e. write the to-space object only once).

Compared with a scavenge operation (which stores forwarding pointers in
the objects themselves), we use a [WeakTable] to store them. This is the
only remaining expensive part of the algorithm and could be further
optimized. To avoid relying on iterating the to-space, we'll remember
[from, to] addresses.

=> All of this works inside a [NoSafepointOperationScope] and avoids
   usages of handles as well as write barriers.

While doing the transitive object copy, we'll share any object we can
safely share (canonical objects, strings, sendports, ...) instead of
copying it.

If the fast path fails (due to allocation failure or hitting) we'll
handlify any raw pointers and continue almost the same algorithm in a
safe way, where GC is possible at every object allocation site and
normal barriers are used for any stores of object pointers.

The copy algorithm uses templates to share the copy logic between the
fast and slow case (same copy routines can work on raw pointers as well
as handles).

There's a few special things to take into consideration:

  * If we copy a view on external typed data we need to know the
    external typed data address to compute the inner pointer of the
    view, so we'll eagerly initialize external typed data.

  * All external typed data needs to get a finalizer attached
    (irrespective if the object copy suceeds or not) to ensure the
    `malloc()`ed data is freed again.

  * Transferables will only be transferred on successful transitive
    copies. Also they need to attach finalizers to objects (which
    requires all objects be in handles).

  * We copy linked hashmaps as they are - instead of compressing the
    data by removing deleted entries. We may need to re-hash those
    hashmaps on the receiver side (similar to the snapshot-based copy
    approach) since new object graph will have no identity hash codes
    assigned to them. Though if the hashmaps only has sharable objects
    as keys (very common, e.g. json) there is no need for re-hashing.


It changes the SendPort.* benchmarks as follows:

```
Benchmark                                     |              default |                        IG |                  IG + FOC
----------------------------------------------------------------------------------------------------------------------------
SendPort.Send.Nop(RunTimeRaw):                |        0.25 us (1 x) |       0.26 us    (0.96 x) |       0.25 us    (1.00 x)
SendPort.Send.Json.400B(RunTimeRaw):          |        4.15 us (1 x) |       1.45 us    (2.86 x) |       1.05 us    (3.95 x)
SendPort.Send.Json.5KB(RunTimeRaw):           |       82.16 us (1 x) |      27.17 us    (3.02 x) |      18.32 us    (4.48 x)
SendPort.Send.Json.50KB(RunTimeRaw):          |      784.70 us (1 x) |     242.10 us    (3.24 x) |     165.50 us    (4.74 x)
SendPort.Send.Json.500KB(RunTimeRaw):         |     8510.4  us (1 x) |    3083.80 us    (2.76 x) |    2311.29 us    (3.68 x)
SendPort.Send.Json.5MB(RunTimeRaw):           |   122381.33 us (1 x) |   62959.40 us    (1.94 x) |   55492.10 us    (2.21 x)
SendPort.Send.BinaryTree.2(RunTimeRaw):       |        1.91 us (1 x) |       0.92 us    (2.08 x) |       0.72 us    (2.65 x)
SendPort.Send.BinaryTree.4(RunTimeRaw):       |        6.32 us (1 x) |       2.70 us    (2.34 x) |       2.10 us    (3.01 x)
SendPort.Send.BinaryTree.6(RunTimeRaw):       |       25.24 us (1 x) |      10.47 us    (2.41 x) |       8.61 us    (2.93 x)
SendPort.Send.BinaryTree.8(RunTimeRaw):       |      104.08 us (1 x) |      41.08 us    (2.53 x) |      33.51 us    (3.11 x)
SendPort.Send.BinaryTree.10(RunTimeRaw):      |      373.39 us (1 x) |     174.11 us    (2.14 x) |     134.75 us    (2.77 x)
SendPort.Send.BinaryTree.12(RunTimeRaw):      |     1588.64 us (1 x) |     893.18 us    (1.78 x) |     532.05 us    (2.99 x)
SendPort.Send.BinaryTree.14(RunTimeRaw):      |     6849.55 us (1 x) |    3705.19 us    (1.85 x) |    2507.90 us    (2.73 x)
SendPort.Receive.Nop(RunTimeRaw):             |        0.67 us (1 x) |       0.69 us    (0.97 x) |       0.68 us    (0.99 x)
SendPort.Receive.Json.400B(RunTimeRaw):       |        4.37 us (1 x) |       0.78 us    (5.60 x) |       0.77 us    (5.68 x)
SendPort.Receive.Json.5KB(RunTimeRaw):        |       45.67 us (1 x) |       0.90 us   (50.74 x) |       0.87 us   (52.49 x)
SendPort.Receive.Json.50KB(RunTimeRaw):       |      498.81 us (1 x) |       1.24 us  (402.27 x) |       1.06 us  (470.58 x)
SendPort.Receive.Json.500KB(RunTimeRaw):      |     5366.02 us (1 x) |       4.22 us (1271.57 x) |       4.65 us (1153.98 x)
SendPort.Receive.Json.5MB(RunTimeRaw):        |   101050.88 us (1 x) |      20.81 us (4855.88 x) |      21.0  us (4811.95 x)
SendPort.Receive.BinaryTree.2(RunTimeRaw):    |        3.91 us (1 x) |       0.76 us    (5.14 x) |       0.74 us    (5.28 x)
SendPort.Receive.BinaryTree.4(RunTimeRaw):    |        9.90 us (1 x) |       0.79 us   (12.53 x) |       0.76 us   (13.03 x)
SendPort.Receive.BinaryTree.6(RunTimeRaw):    |       33.09 us (1 x) |       0.87 us   (38.03 x) |       0.84 us   (39.39 x)
SendPort.Receive.BinaryTree.8(RunTimeRaw):    |      126.77 us (1 x) |       0.92 us  (137.79 x) |       0.88 us  (144.06 x)
SendPort.Receive.BinaryTree.10(RunTimeRaw):   |      533.09 us (1 x) |       0.94 us  (567.12 x) |       0.92 us  (579.45 x)
SendPort.Receive.BinaryTree.12(RunTimeRaw):   |     2223.23 us (1 x) |       3.03 us  (733.74 x) |       3.04 us  (731.33 x)
SendPort.Receive.BinaryTree.14(RunTimeRaw):   |     8945.66 us (1 x) |       4.03 us (2219.77 x) |       4.30 us (2080.39 x)
```

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

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

Change-Id: I835c59dab573d365b8a4b9d7c5359a6ea8d8b0a7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/203776
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2021-07-13 19:04:20 +00:00
Srujan Gaddam 0fc2d929e3 [pkg:js] Add subtyping tests with liveness
Adds tests for subtyping between pkg:js types. Also runs tests
for both when types are made live and for when they are not.

Also adds these tests to lib_2.

Change-Id: I25fdc293e422eb21fa8a80dea66ae5d492c5aafd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/205601
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Riley Porter <rileyporter@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
2021-07-13 18:51:34 +00:00
Daco Harkes 21af69a7a5 Revert "[vm] Don't block OOB messages during field initialization; make interrupts lock-free."
This reverts commit 4d789f60d1.

Reason for revert: TSAN races
https://github.com/dart-lang/sdk/issues/46596

Original change's description:
> [vm] Don't block OOB messages during field initialization; make interrupts lock-free.
>
> TEST=ci
> Change-Id: I51d0f51995e197ab71c059f17d22259eea19c286
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/206566
> Commit-Queue: Ryan Macnak <rmacnak@google.com>
> Reviewed-by: Ben Konyi <bkonyi@google.com>

TBR=bkonyi@google.com,rmacnak@google.com

Change-Id: I777f5a0bbeb3cd60e03aff46183b19ab4e286664
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/206545
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2021-07-13 11:30:08 +00:00
Srujan Gaddam 8f11985c47 [pkg:js] Test runtime is checks
The is checks in is_check_and_as_cast_test.dart are currently optimized
by dart2js at compile time. In order to test them at runtime, is checks
are added after confusing the instance.

Also adds this test file to lib_2.

Change-Id: I3a77c779799f77342297508b89367ab8b64c3241
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/205600
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Riley Porter <rileyporter@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
2021-07-13 01:28:55 +00:00