Commit graph

22026 commits

Author SHA1 Message Date
Lasse R.H. Nielsen c13676f2b7 Deprecate FallThroughError.
The error has not been thrown since Dart 2.0,
where being able to reach the end of a switch case
became a compile-time error.

TEST=Removes tests depending on discontinued behavior.

Change-Id: I76292e7c73f2b3aaf071bbb290e97db493b75477
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/261860
Reviewed-by: Michael Thomsen <mit@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
Auto-Submit: Lasse Nielsen <lrn@google.com>
Reviewed-by: Brian Quinlan <bquinlan@google.com>
2022-10-25 12:25:35 +00:00
Daco Harkes f524ec74ce [vm/ffi] FfiNative process lookup
This CL makes `FfiNative`s use `DynamicLibrary.process()` lookup if
resolving with the resolver set by `Dart_SetFfiNativeResolver` fails.

Also moves the implementation over from ffi.cc to
ffi_dynamic_library.cc so the implementation can be shared with
`DynamicLibrary.process()`.

Moves the implementation behind non-simulator and non-precompiler.
However, the implementation is tested in vm/cc tests which are in
precompiler mode. So enables the implementation if TESTED is defined.

This CL massages the build files so that TESTED is properly
defined when compiling the runtime for the vm/cc tests, and links
the ole32 symbols on windows for vm/cc tests.

(And some unrelated small cleanup changes here and there.)

TEST=tests/ffi/native_assets/process_test.dart

Change-Id: I25395d381db1d9b4b7a5759171a798a1140a6140
Cq-Include-Trybots: luci.dart.try:vm-kernel-win-debug-x64c-try,vm-kernel-win-debug-x64-try,vm-kernel-nnbd-win-debug-x64-try,vm-kernel-precomp-win-debug-x64c-try,dart-sdk-win-try,vm-kernel-win-release-x64-try,vm-kernel-win-release-ia32-try,vm-kernel-precomp-win-product-x64-try,vm-kernel-reload-linux-debug-x64-try,vm-kernel-reload-rollback-linux-debug-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/264982
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2022-10-25 10:57:07 +00:00
Ryan Macnak 9319d07e11 [vm] Fill in ArgumentValue.invalidObject when objects are rejected in isolate messages.
TEST=ci
Change-Id: I5a2816ce7fd40463aaffd971d867955a7b2bd7e6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/265043
Reviewed-by: Alexander Aprelev <aam@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-10-24 17:49:29 +00:00
Srujan Gaddam dbb793a330 [pkg:js] Refactor createStaticInteropMock tests to account for new changes
Change-Id: I4de0c94bf1f00336432d61b174703fde9476545a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/262863
Reviewed-by: Riley Porter <rileyporter@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
2022-10-24 17:37:09 +00:00
Srujan Gaddam 316031d501 [pkg:js] Test export creation
While export creation covers both exports and mocks, we only test
createDartExport here.

Change-Id: I85bd65193644930768fdab7dfae9d54cf5ad2e31
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/261765
Reviewed-by: Riley Porter <rileyporter@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2022-10-24 17:37:09 +00:00
Srujan Gaddam 9453ff5273 [pkg:js] Add tests for export validation
Tests the various checks needed for @JSExport and createDartExport,
with and without inheritance. Also renames the mock directory to export.

Change-Id: Iae0233f1080a2f12f20b46ba1a6b30aeb36843a8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/260743
Reviewed-by: Riley Porter <rileyporter@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2022-10-24 17:37:09 +00:00
Alexander Markov 882e3711ff [ffi/tests] Split large auto-generated tests into multiple tests
This change tries to avoid timeouts on debug/ia32 bots by replacing
each auto-generated

  tests/ffi{,_2}/function_structs_by_value_generated{,_leaf}_test.dart

with 3 separate tests.
Also, --optimization-counter-threshold is increased.

Fixes https://github.com/dart-lang/sdk/issues/48627
Issue: https://github.com/dart-lang/sdk/issues/45007

Change-Id: I8a9c72927d05a3da3da35a21e9ffba0f3bda2112
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/265021
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2022-10-20 22:08:53 +00:00
Alexander Aprelev 8c0df46887 [vm] Better implementation of hashCode function.
With this cl hashCode function for integers which used to be identity function becomes `uint128_t hash = value * constant; hash ^= hash >> 64; hash ^= hash >> 32; hash &= 0x3fffffff`. Note that the hashCode has to stay the same across platforms(64-bit/32-bit).

This dramatically improves performance of integer HashSet/HashMap lookups when integers differ in higher bits only(see the issue referenced below).

AOT ARM64 benchmarks:
===
WordSolverIdentity -3.630% (-0.9 noise)
BigInt.parse.0064.bits 15.43% (0.9 noise)
BigInt.parse.4096.bits 40.80% (1.6 noise)
BigInt.parse.0256.bits 42.01% (2.3 noise)
BigInt.parse.1024.bits 50.91% (2.6 noise)
IntegerSetLookup.DefaultHashSet 549916% (14727.6 noise)
IntegerSetLookup.DefaultHashSet 597150% (55520.2 noise)
IntegerSetLookup.HashSet 846924% (78126.7 noise)
IntegerSetLookup.HashSet 791864% (107221.1 noise)
===

AOT x64:
===
Havlak -14.25% (-1.7 noise)
DartMicroBench.Int64Div -7.091% (-1.2 noise)
ObjectHash.manual.5 -9.541% (-0.8 noise)
AsyncLiveVars.LiveInt1 4.726% (0.8 noise)
IsolateJson.SendAndExit_Decode1MBx1 9.067% (0.8 noise)
SplayHarderLatency 4.629% (0.9 noise)
TypedDataDuplicate.Float64List.32.loop 35.01% (1.8 noise)
IntegerSetLookup.DefaultHashSet 627996% (124823.6 noise)
IntegerSetLookup.HashSet 1245362% (244705.3 noise)
===

JIT ARM64:
===
IntegerSetLookup.DefaultHashSet_Random 73.80% (1.2 noise)
IntegerSetLookup.DefaultHashSet 344999% (6202.9 noise)
IntegerSetLookup.HashSet 483731% (7845.7 noise)
===

JIT x64:
===
CollectionSieves-Set-removeLoop -6.294% (-0.9 noise)
Utf8Encode.ru.10M 59.11% (0.8 noise)
Utf8Encode.ru.10k 71.62% (0.9 noise)
Utf8Encode.zh.10M 53.93% (0.9 noise)
Utf8Encode.ne.10k 71.34% (0.9 noise)
Utf8Encode.zh.10k 72.52% (0.9 noise)
Utf8Encode.ne.10M 53.17% (0.9 noise)
IntegerSetLookup.HashSet_Random 27.80% (1.1 noise)
String.replaceAll.String.Zero 8.659% (1.2 noise)
IntegerSetLookup.DefaultHashSet_Random 96.20% (1.3 noise)
IntegerSetLookup.HashSet 481037% (18028.8 noise)
IntegerSetLookup.DefaultHashSet 454450% (31501.3 noise)
==

Fixes https://github.com/dart-lang/sdk/issues/48641
TEST=ci

Change-Id: Id982e4aa30cd1d6a63f93c73917a8b921ad464a3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/258600
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2022-10-20 20:31:20 +00:00
Lukas Klingsbo 6e4e12922a DateTime copyWith extension
This change has been discussed for 8+ years and it would of course be preferred
to be added as an instance method, but since that is a breaking change I added it as an extension as discussed here:
https://github.com/dart-lang/sdk/issues/24644#issuecomment-1241695835

Change-Id: Iebb9f300e449920ae8891abac88f30b271321661
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/258541
Commit-Queue: Lasse Nielsen <lrn@google.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
2022-10-20 10:50:25 +00:00
Paul Berry d9a5551af9 Front end logic for field promotion.
This is the common front end implementation of the new field promotion
feature (https://github.com/dart-lang/language/issues/2020).

There is no behavioral change yet unless the user activates field
promotion by enabling the experiment flag `inference-update-2`.

Change-Id: I0d1e0893af862c3af8a0ef4ea10e803606d48d7e
Bug: https://github.com/dart-lang/language/issues/2020
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/260451
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2022-10-19 14:53:51 +00:00
Alexander Thomas 0b26f4816b [testing] Remove --compiler=none from test.py
* Use dartk as the default compiler for runtime=vm.
* Status file entries for checking for the `none` compiler now either
  use dartk or are deleted.

Tested: Standard CQ and local testing.
Fixes: https://github.com/dart-lang/sdk/issues/50241
Change-Id: I7a08d3e491ae1c82a0348fb66ea7b557398f97e5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/264682
Reviewed-by: Siva Annamalai <asiva@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Alexander Thomas <athom@google.com>
2022-10-19 08:09:58 +00:00
Alexander Markov d7852e4786 [vm] Account for named record fields which can be named like positional
It is allowed to have named fields $N in records unless they conflict
with corresponding positional fields. So when accessing $N fields
dynamically we should look for both positional field and named field.

TEST=language/records/simple/dynamic_field_access_test

Issue: https://github.com/dart-lang/sdk/issues/49719
Change-Id: Id31dcb82e753aeeaeed74d5d07aac556ae08a7b2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/264740
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2022-10-18 21:03:09 +00:00
Srujan Gaddam 521cbcdd47 [pkg:js] Disallow external extension members with type parameters
Bug: https://github.com/dart-lang/sdk/issues/49350

Checks to see that external extension members on `@staticInterop` types
do not declare or use a type parameter.

Change-Id: Id8646b599094b748c5490810b64d872065676014
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/254103
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Joshua Litt <joshualitt@google.com>
2022-10-18 17:47:29 +00:00
Srujan Gaddam b6526beeab [pkg:js] Disallow staticInterop generative constructors
Fixes https://github.com/dart-lang/sdk/issues/48730

Change-Id: I4c7f687ec8d2724de0e031aa5ebe887f93843761
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/254101
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2022-10-18 17:47:29 +00:00
Sigmund Cherem 770c9d77c5 [typed_data] Fix breakage introduced in recent change.
This fixes a regression introduced by
https://dart-review.googlesource.com/c/sdk/+/254501. The change
accidentally excluded some  clauses. This was not detected by the
CFE (it should be a static error), and as a result unsound
optimizations were made by dart2js.

Fixes https://dart-review.googlesource.com/c/sdk/+/254501

Change-Id: Iff52cba277546f2a9fab3c2c2736410d272dad7e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/264601
Reviewed-by: Stephen Adams <sra@google.com>
Commit-Queue: Sigmund Cherem <sigmund@google.com>
2022-10-18 01:16:27 +00:00
Ryan Macnak d2a43581a3 [io] Avoid serializing unwritten bytes in async I/O.
TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/50206
Change-Id: Ibe6c326578ec4a2ca90634714e4628c02a5e5bcc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/264260
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-10-17 17:42:54 +00:00
Ahmed Ashour c8bda70c66 Remove nbsp
Fixes #50202

Change-Id: I67e2f02f49deaf1bd9dc1f32a35310704f4d921b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/264120
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Alexander Thomas <athom@google.com>
2022-10-17 08:18:49 +00:00
Ahmed Ashour 0b5d908221 [analyzer] NOT_ENOUGH_POSITIONAL_ARGUMENTS
To report at the token of the expected positional argument

Fixes #50127

Change-Id: I5eb31c6d354fb15d482c2046f7faaa4505658f4e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/262603
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2022-10-11 17:56:11 +00:00
Sergey G. Grekhov e4a8525d86 [co19] RawDatargamSocket tests enabled
Change-Id: I3ea1e20eaa14f546da333a8841bfa2ef75891bda
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/263301
Reviewed-by: Alexander Thomas <athom@google.com>
2022-10-11 02:42:00 +00:00
Alexander Markov 3cb81a5a07 [tests] Fix types in standalone/io/web_socket_pipe_test
WebSocket is a Stream<dynamic> and StreamSink<dynamic>, so it
should be transformed as Stream<dynamic> and to Stream<dynamic>
in order to be able to pipe it to itself.

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

Change-Id: If3162cc51e6d95398a6f069f2ccd7ea935b508c2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/263440
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2022-10-11 00:34:50 +00:00
Alexander Markov 24b8399086 [tests] Avoid small --optimization-counter-threshold in tests
Small --optimization-counter-threshold makes tests very slow,
especially on architectures where kernel service runs from
kernel and not from app-jit snapshot.

TEST=change in tests, *-ia32 bots
Fixes https://github.com/dart-lang/sdk/issues/48627

Change-Id: I63e7e201ef9a0e4f645016c39a5be1819b61822d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/263421
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2022-10-10 21:04:18 +00:00
Ryan Macnak 5b119191a5 [test] Add missing architectures when skipping tests using FFI on simulators.
Bug: https://github.com/dart-lang/sdk/issues/37299
Change-Id: If4553d20ca13bdc3191cad19a987c875c1c88d73
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/262849
Reviewed-by: Derek Xu <derekx@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-10-06 19:24:08 +00:00
Jens Johansen e860cf241b [parser] Empty record
https://github.com/dart-lang/language/pull/2535

Change-Id: I8241119ee858ce39673472056b88c9393799e1a0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/262600
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2022-10-06 06:34:58 +00:00
Nicholas Shahan 76b615b80d [test] Fix expected and actual ordering
Not a big deal but I was confused for longer than I would like to
admit because the failure message labels the "expected" and "actual"
values as such.

Change-Id: I433d263b873286a54725b7a2a0ba536dd29aae47
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/262664
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
2022-10-04 23:47:59 +00:00
Sam Rawlins 15be61ed9a Remove INVALID_OVERRIDE_DIFFERENT_DEFAULT_VALUES warnings
Fixes https://github.com/dart-lang/sdk/issues/49112

It was decided to remove the "override with equal default value"
restriction both for null safe code, and for pre-null safe code.

CFE had never issued this static warning, and her we remove it from
analyzer.

Change-Id: I1244e4fe46da8bb4bd8c3a77ec8beb95811e30a1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/262267
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2022-10-04 18:23:10 +00:00
Sam Rawlins c7fe783d11 Language test for unnamed-libraries
Bug: https://github.com/dart-lang/language/issues/1073
Change-Id: I9d57c86c35b5712029c610197e6ad823d34c492e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/262580
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Erik Ernst <eernst@google.com>
2022-10-04 16:45:21 +00:00
Chloe Stefantsova 1d768f3c75 Reland "Reland "[cfe,corelib] Add class 'Record' to the core library""
This is a reland of commit 4b6a8f35b9

Original change's description:
> Reland "[cfe,corelib] Add class 'Record' to the core library"
>
> Part of https://github.com/dart-lang/sdk/issues/49713
>
> Change-Id: I56bfca49492d14bb561b32993fd9adfe775b7400
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/259583
> Reviewed-by: Johnni Winther <johnniwinther@google.com>
> Reviewed-by: Slava Egorov <vegorov@google.com>
> Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>

Change-Id: Idaab98c028312ca36bd07f569374ca8b76151a02
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/260101
Reviewed-by: Slava Egorov <vegorov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2022-10-04 12:29:47 +00:00
Ömer Sinan Ağacan 88539e58ea [dart2wasm] Update tracking issue for skipped async tests
Change-Id: I163c2125fb69438ff1339e1aa26eb590b8710e83
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/262426
Commit-Queue: Ömer Ağacan <omersa@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
2022-10-04 10:39:49 +00:00
Johnni Winther 3931dc6b08 [cfe] Use reportIfNotEnabled in endRecordLiteral
Change-Id: I9a2bd53838a40419f9aa4779380488b547db5b39
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/262421
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2022-10-04 09:30:07 +00:00
Alexander Markov b5061ffae1 [vm] Support dynamic access to record fields in JIT mode
TEST=language/records/simple/dynamic_field_access_test

Issue: https://github.com/dart-lang/sdk/issues/49719
Change-Id: I18df67e0bf97944c8e5ef8a71f075b5cd40fec29
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/262300
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2022-10-03 21:24:47 +00:00
Nicholas Shahan da79baa962 [ddc] Fix bug in FutureOr type normalization
The correct normalization should only normalize FutureOr<Never>
when Never is non-nullable.

Change-Id: I592f3a4856c219b33a8f1ac8377567a956e1148c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/261000
Commit-Queue: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Mayank Patke <fishythefish@google.com>
Reviewed-by: Erik Ernst <eernst@google.com>
2022-10-03 20:09:38 +00:00
Daco Harkes b113fffb65 Reland "[vm/ffi] Throw on returning Error in Handle"
Fix: Check handle contents for Smi.
Closes: https://github.com/flutter/flutter/issues/112726

Orignal CL description:

Makes `Dart_Handle` FFI returns behave as the following snippet:

```
Dart_Handle ExampleSnippet() {
  Dart_Handle result = ...;
  if (Dart_IsError(result)) {
    Dart_PropagateError(result);
  }
  return result;
}
```

Also makes FFI consistent with Dart_NativeFunctions, which will
automatically throw upon return if Dart_SetReturnValue set the result
to an error.

`UnhandledExceptions` cannot flow out into Dart generated code. So,
the implementation needs to be in `FfiCallInstr::EmitNativeCode`.

Using `Dart_IsError` is slow compared to a machine code class id
check. So, we should do the handle unwrapping and class id check in
machine code.

Unwrapping Handles in machine code is only safe when the GC is
guaranteed to not run: Either (1) in `kThreadInGenerated`, or (2) in
`kThreadInNative`, but only when transitioned into safepoint. So, the
handle cannot be unwrapped immediately after the FFI call in machine code. We first need to transition back to generated.

This means we need to transition again to native to do the actual
`Dart_PropagateError` call. We can do so without the stub in JIT
because we never return with normal control flow.

Performance impact of this change is within benchmark noise in both
JIT and AOT.
Size impact is 42 bytes on x64, which is 10% in AOT and 12% in JIT.

For more numbers see: go/dart-ffi-handle-error

TEST=runtime/bin/ffi_test/ffi_test_functions_vmspecific.cc
TEST=tests/ffi/vmspecific_handle_test.dart

Closes: https://github.com/dart-lang/sdk/issues/49936
Change-Id: Id8edfd841a7d6246438386007d83747868a0a151
Cq-Include-Trybots: luci.dart.try:vm-canary-linux-debug-try,vm-ffi-android-debug-arm64c-try,vm-ffi-android-debug-arm-try,vm-kernel-gcc-linux-try,vm-kernel-linux-debug-x64-try,vm-kernel-linux-debug-x64c-try,vm-kernel-msvc-windows-try,vm-kernel-optcounter-threshold-linux-release-x64-try,vm-kernel-precomp-asan-linux-release-x64-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-reload-linux-debug-x64-try,vm-kernel-reload-rollback-linux-debug-x64-try,vm-kernel-tsan-linux-release-x64-try,vm-kernel-win-debug-x64-try,vm-kernel-win-debug-ia32-try,vm-precomp-ffi-qemu-linux-release-arm-try,vm-precomp-ffi-qemu-linux-release-riscv64-try,vm-kernel-linux-debug-ia32-try,vm-kernel-mac-release-arm64-try,vm-kernel-precomp-win-debug-x64c-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/262342
Reviewed-by: Martin Kustermann <kustermann@google.com>
Auto-Submit: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2022-10-03 12:25:08 +00:00
Zach Anderson 2742d90033 Revert "[vm/ffi] Throw on returning Error in Handle"
This reverts commit d9c442bce8.

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

Original change's description:
> [vm/ffi] Throw on returning `Error` in `Handle`
>
> Makes `Dart_Handle` FFI returns behave as the following snippet:
>
> ```
> Dart_Handle ExampleSnippet() {
>   Dart_Handle result;
>   if (Dart_IsError(result)) {
>     Dart_PropagateError(result);
>   }
>   return result;
> }
> ```
>
> Also makes FFI consistent with Dart_NativeFunctions, which will
> automatically throw upon return if Dart_SetReturnValue set the result
> to an error.
>
> `UnhandledExceptions` cannot flow out into Dart generated code. So,
> the implementation needs to be in `FfiCallInstr::EmitNativeCode`.
>
> Using `Dart_IsError` is slow compared to a machine code class id
> check. So, we should do the handle unwrapping and class id check in
> machine code.
>
> Unwrapping Handles in machine code is only safe when the GC is
> guaranteed to not run: Either (1) in `kThreadInGenerated`, or (2) in
> `kThreadInNative`, but only when transitioned into safepoint. So, the
> handle cannot be unwrapped immediately after the FFI call in machine code. We first need to transition back to generated.
>
> This means we need to transition again to native to do the actual
> `Dart_PropagateError` call. We can do so without the stub in JIT
> because we never return with normal control flow.
>
> Performance impact of this change is within benchmark noise in both
> JIT and AOT.
> Size impact is 42 bytes on x64, which is 10% in AOT and 12% in JIT.
>
> For more numbers see: go/dart-ffi-handle-error
>
> TEST=runtime/bin/ffi_test/ffi_test_functions_vmspecific.cc
> TEST=tests/ffi/vmspecific_handle_test.dart
>
> Closes: https://github.com/dart-lang/sdk/issues/49936
> Change-Id: Ie8fabeb6d53bc80689541bc4470cb37ee2200581
> Cq-Include-Trybots: luci.dart.try:vm-canary-linux-debug-try,vm-ffi-android-debug-arm64c-try,vm-ffi-android-debug-arm-try,vm-kernel-gcc-linux-try,vm-kernel-linux-debug-x64-try,vm-kernel-linux-debug-x64c-try,vm-kernel-msvc-windows-try,vm-kernel-optcounter-threshold-linux-release-x64-try,vm-kernel-precomp-asan-linux-release-x64-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-reload-linux-debug-x64-try,vm-kernel-reload-rollback-linux-debug-x64-try,vm-kernel-tsan-linux-release-x64-try,vm-kernel-win-debug-x64-try,vm-kernel-win-debug-ia32-try,vm-precomp-ffi-qemu-linux-release-arm-try,vm-precomp-ffi-qemu-linux-release-riscv64-try,vm-kernel-linux-debug-ia32-try,vm-kernel-mac-release-arm64-try,vm-kernel-precomp-win-debug-x64c-try
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/261603
> Reviewed-by: Ryan Macnak <rmacnak@google.com>
> Reviewed-by: Martin Kustermann <kustermann@google.com>
> Commit-Queue: Daco Harkes <dacoharkes@google.com>

TBR=kustermann@google.com,rmacnak@google.com,dacoharkes@google.com,dart-scoped@luci-project-accounts.iam.gserviceaccount.com

Change-Id: I94cc63de16b54db2b0a4f92759c39a1e569b8e63
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Cq-Include-Trybots: luci.dart.try:vm-canary-linux-debug-try,vm-ffi-android-debug-arm64c-try,vm-ffi-android-debug-arm-try,vm-kernel-gcc-linux-try,vm-kernel-linux-debug-x64-try,vm-kernel-linux-debug-x64c-try,vm-kernel-msvc-windows-try,vm-kernel-optcounter-threshold-linux-release-x64-try,vm-kernel-precomp-asan-linux-release-x64-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-reload-linux-debug-x64-try,vm-kernel-reload-rollback-linux-debug-x64-try,vm-kernel-tsan-linux-release-x64-try,vm-kernel-win-debug-x64-try,vm-kernel-win-debug-ia32-try,vm-precomp-ffi-qemu-linux-release-arm-try,vm-precomp-ffi-qemu-linux-release-riscv64-try,vm-kernel-linux-debug-ia32-try,vm-kernel-mac-release-arm64-try,vm-kernel-precomp-win-debug-x64c-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/262270
Reviewed-by: Zach Anderson <zra@google.com>
Reviewed-by: Liam Appelbe <liama@google.com>
Commit-Queue: Zach Anderson <zra@google.com>
2022-09-30 21:51:59 +00:00
Joshua Litt 29de68d38e [dart2wasm] Correctly handle null when jsifying maps.
Change-Id: Ibda04bf6012447dcab86079da8d4d41771e8e9bc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/262102
Commit-Queue: Joshua Litt <joshualitt@google.com>
Reviewed-by: Srujan Gaddam <srujzs@google.com>
2022-09-30 21:09:29 +00:00
Joshua Litt c6b141e9e5 [dart2wasm] Fix bug in dartify.
Change-Id: Ia922d3ac6e3849db13877259c65c7d8d884c5828
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/262100
Commit-Queue: Joshua Litt <joshualitt@google.com>
Reviewed-by: Srujan Gaddam <srujzs@google.com>
2022-09-30 18:14:07 +00:00
Daco Harkes d9c442bce8 [vm/ffi] Throw on returning Error in Handle
Makes `Dart_Handle` FFI returns behave as the following snippet:

```
Dart_Handle ExampleSnippet() {
  Dart_Handle result;
  if (Dart_IsError(result)) {
    Dart_PropagateError(result);
  }
  return result;
}
```

Also makes FFI consistent with Dart_NativeFunctions, which will
automatically throw upon return if Dart_SetReturnValue set the result
to an error.

`UnhandledExceptions` cannot flow out into Dart generated code. So,
the implementation needs to be in `FfiCallInstr::EmitNativeCode`.

Using `Dart_IsError` is slow compared to a machine code class id
check. So, we should do the handle unwrapping and class id check in
machine code.

Unwrapping Handles in machine code is only safe when the GC is
guaranteed to not run: Either (1) in `kThreadInGenerated`, or (2) in
`kThreadInNative`, but only when transitioned into safepoint. So, the
handle cannot be unwrapped immediately after the FFI call in machine code. We first need to transition back to generated.

This means we need to transition again to native to do the actual
`Dart_PropagateError` call. We can do so without the stub in JIT
because we never return with normal control flow.

Performance impact of this change is within benchmark noise in both
JIT and AOT.
Size impact is 42 bytes on x64, which is 10% in AOT and 12% in JIT.

For more numbers see: go/dart-ffi-handle-error

TEST=runtime/bin/ffi_test/ffi_test_functions_vmspecific.cc
TEST=tests/ffi/vmspecific_handle_test.dart

Closes: https://github.com/dart-lang/sdk/issues/49936
Change-Id: Ie8fabeb6d53bc80689541bc4470cb37ee2200581
Cq-Include-Trybots: luci.dart.try:vm-canary-linux-debug-try,vm-ffi-android-debug-arm64c-try,vm-ffi-android-debug-arm-try,vm-kernel-gcc-linux-try,vm-kernel-linux-debug-x64-try,vm-kernel-linux-debug-x64c-try,vm-kernel-msvc-windows-try,vm-kernel-optcounter-threshold-linux-release-x64-try,vm-kernel-precomp-asan-linux-release-x64-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-reload-linux-debug-x64-try,vm-kernel-reload-rollback-linux-debug-x64-try,vm-kernel-tsan-linux-release-x64-try,vm-kernel-win-debug-x64-try,vm-kernel-win-debug-ia32-try,vm-precomp-ffi-qemu-linux-release-arm-try,vm-precomp-ffi-qemu-linux-release-riscv64-try,vm-kernel-linux-debug-ia32-try,vm-kernel-mac-release-arm64-try,vm-kernel-precomp-win-debug-x64c-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/261603
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2022-09-30 13:29:51 +00:00
Paul Berry f388946354 Fix test to account for obfuscation
This change generalizes no_such_method_restriction_stack_trace_test so
that it recognizes all circumstances where there is stack obfuscation
(not just Javascript builds).

Fixes test failures on `vm-kernel-precomp-obfuscate-linux-release-x64` bot.
Fixes #50074

Bug: https://github.com/dart-lang/sdk/issues/50074
Change-Id: I53f3eaa6ae3cf3585b3d4c492d80dd1e72ca216b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/261621
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2022-09-28 19:24:26 +00:00
Alexander Markov 9c3e52aaf3 [vm] Support record types in special cases of type testing stubs for generic types
TEST=language/records/simple/type_checks2_test

Issue: https://github.com/dart-lang/sdk/issues/49719
Change-Id: I9117331d8e985675a8adba1aaa4d50a6b17758f4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/261182
Reviewed-by: Tess Strickland <sstrickl@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2022-09-28 19:01:11 +00:00
Alexander Markov b860d9ee36 [vm] Support record types and record constants in IL serialization
TEST=language/records/simple/constants_and_field_access_test

Issue: https://github.com/dart-lang/sdk/issues/49719
Change-Id: I47b1c300195249d0e07e2adfdeeba0c4e44f5de7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/261480
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2022-09-28 16:41:56 +00:00
Paul Berry 54906759b9 Don't delegate foreign private names to noSuchMethod.
If a concrete class implements an interface containing a name that's
private to a different library, any attempt to invoke that name will
result in an exception getting thrown.  Previously, such attempts
would result in the call being diverted to noSuchMethod.

This change closes a loophole in Dart's privacy system, and paves the way for
a future implementation of promotion for private final fields (see
https://github.com/dart-lang/language/issues/2020).

Bug: https://github.com/dart-lang/sdk/issues/49687
Change-Id: Ie55805e0fc77dc39713761a80a42c28bd0504722
Tested: language tests
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/255640
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
2022-09-27 21:20:35 +00:00
Daco Harkes 8a78aaf463 [analyzer/ffi] Fix FfiNative Pointer params
TEST=pkg/analyzer/test/src/diagnostics/ffi_native_test.dart
TEST=tests/ffi/regress_49684_test.dart

Closes: https://github.com/dart-lang/sdk/issues/49684
Change-Id: I756635c0a34aa18f3a3a2cbdcc0657b08cb5050e
Cq-Include-Trybots: luci.dart.try:analyzer-linux-release-try,analyzer-mac-release-try,analyzer-win-release-try,analyzer-analysis-server-linux-try,vm-ffi-android-debug-arm64c-try,vm-precomp-ffi-qemu-linux-release-arm-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/261400
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Auto-Submit: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2022-09-27 15:58:16 +00:00
Daco Harkes c04673f44b [vm/ffi] Support DynamicLibrary.process() on Windows
Support looking up a symbol in the process on Windows by using the
Windows Process Status API to iterate over all loaded Modules.

TEST=tests/ffi/has_symbol_test.dart
TEST=tests/ffi/vmspecific_dynamic_library_test.dart

Change-Id: I1029f1c7dae9a193b662d942388affb681842c90
Cq-Include-Trybots: luci.dart.try:vm-kernel-win-debug-x64c-try,vm-kernel-win-debug-x64-try,vm-kernel-nnbd-win-debug-x64-try,vm-kernel-precomp-win-debug-x64c-try,dart-sdk-win-try,vm-kernel-win-release-x64-try,vm-kernel-win-release-ia32-try,vm-kernel-precomp-win-product-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/260760
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Tess Strickland <sstrickl@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2022-09-27 08:42:03 +00:00
Ryan Macnak cba1a09e5c [vm, compiler] Inform MSan about parameters coming from FFI.
- Mark the outgoing arguments stack area as initialized.
 - Mark the trampoline's incoming parameter slots as initialized in case they are used as local handles.
 - Mark the outgoing register arguments as initialized.

TEST=msan
Bug: https://github.com/dart-lang/sdk/issues/42314
Bug: https://github.com/dart-lang/sdk/issues/49298
Bug: https://github.com/dart-lang/sdk/issues/49957
Change-Id: Ifa978e1b905a424ec9f64b89879cea6e82f70d12
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/259102
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-09-23 21:31:14 +00:00
Ömer Sinan Ağacan affc3392a0 [dart2wasm] Implement Wasm FfiNative support
This CL introduces a new kernel-to-kernel pass in Wasm backend to
compile `FfiNative`-annotated external functions to external functions
with `wasm:import` pragmas.

The new pass `WasmFfiNativeTransformer` extends `FfiNativeTransformer`.
Some `FfiNativeTransformer` methods made public to allow reuse in the
pass.

The conversion works like this: when we see a member like:

    @FfiNative<Int8 Function(Int8, Int8)>("ffi.addInt8")
    external int addInt8(int a, int b);

We generate a Wasm import using Wasm ABI types according to emscripten
calling conventions:

    @pragma('wasm:import', 'ffi.addInt8')
    external static WasmI32 addInt8_$import(WasmI32 a, WasmI32 b);

and convert the original member (`addInt8()`) to a wrapper function that
calls the Wasm import, converting the arguments and return values to
Dart types:

    static int addInt8(int a, int b) {
      return WasmI32.toIntSigned(
        addInt8_$import(
            WasmI32::int8FromInt(a),
            WasmI32::int8FromInt(b),
        ));
    }

Build, test, and CI changes:

- Test runner now uses `// SharedObjects=...` lines in dart2wasm tests
  to pass extra Wasm modules to d8 command used to run the tests.

  Support for `// SharedObjects=...` lines were already used in
  native/AOT FFI tests, not added in this CL. We just start to use those
  lines in dart2wasm tests.

- dart2wasm gn file updated with a target "test_wasm_modules" that
  builds FFI test Wasm modules to Wasm using emcc (emscripten C
  compiler).

- CI dart2wasm_hostasserts configuration updated to copy the Wasm files
  generated by the "test_wasm_modules" target to the shards.

TEST=tests/web/wasm/ffi_native_test

Change-Id: I6527fe4e2ca2b582e16d84fee244e9cbe6dee307
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/252822
Reviewed-by: Alexander Thomas <athom@google.com>
Commit-Queue: Ömer Ağacan <omersa@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
2022-09-23 09:41:22 +00:00
Nicholas Shahan 76a4d351b8 [ddc] Add non-null assertions when setting fields
!!! NOTE to Google3 rollers:
If this change causes test failures in google3 you can temporarily
set `null_safety_asserts = False` on the failing
`dart_browser_binary` targets until we can fix the mistyped code.
That should allow the test to pass with this change.

Of course feel free to revert this change again if the number of
failures is too high.

Re-land previously reverted change:
https://dart-review.googlesource.com/c/sdk/+/258780

Adds additional tests and more checks to ensure assertions are only
added in libraries that have been migrated to null safety.

Issue: https://github.com/dart-lang/sdk/issues/49918
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/259120
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
Change-Id: Idcab0fe49a8dd98cdd73192eabae4439aebe2013
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/260070
2022-09-23 01:22:11 +00:00
Alexander Markov 1139ed3373 [vm] Record toString()
TEST=language/records/simple/to_string_test

Issue: https://github.com/dart-lang/sdk/issues/49719
Change-Id: I7e55a2486b1d964b24a287ffcf87c40c20f9cfe9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/260480
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2022-09-22 21:49:08 +00:00
Alexander Markov ed593585cc [vm] Record operator== and hashCode
TEST=language/records/simple/equals_and_hashcode_test
TEST=co19/LanguageFeatures/Records/equality_*

Issue: https://github.com/dart-lang/sdk/issues/49719
Change-Id: I63842f980389d63650d00638f1cb1501db88b025
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/260442
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2022-09-22 21:24:58 +00:00
Joshua Litt fea406591e [dart2wasm] Fix for tearoffs in allowInterop.
Change-Id: Ic753bb22af345e4825f2a142fa262504a562e7c4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/260283
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Commit-Queue: Joshua Litt <joshualitt@google.com>
2022-09-22 03:04:17 +00:00
Aske Simon Christensen d0d509d4fc [dart2wasm] Add relevant co19 and lib tests
A few co19 tests are marked as skipped for now, as they are hanging
due to https://github.com/dart-lang/sdk/issues/50026

Increase the number of shards to match the increased number of tests.

Change-Id: Ib91127986d13140164c357a22f2d1d9b7b2b7636
Cq-Include-Trybots: luci.dart.try:dart2wasm-linux-x64-d8-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/260361
Reviewed-by: Alexander Thomas <athom@google.com>
Commit-Queue: Aske Simon Christensen <askesc@google.com>
2022-09-21 16:11:22 +00:00
Chloe Stefantsova 9f75d4426e [tests] Split out tests involving Record.empty
This is needed because the Record.empty constant isn't implemented
yet, to avoid compile-time errors in tests that don't expect any.

Change-Id: Ic7e61fb285a65a5809979e4c32b632f73f9e2d88
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/260107
Reviewed-by: Erik Ernst <eernst@google.com>
Reviewed-by: Bob Nystrom <rnystrom@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2022-09-21 08:05:47 +00:00