Commit graph

3950 commits

Author SHA1 Message Date
Daco Harkes f1a4f0e462 [vm] Split out main from main.cc
This enables running other C/C++ code before the Dart main function
without having to implement the full embedder API by including
main_lib and friends in a build but excluding `main.cc`.

TEST=ci build + flutter bot

Change-Id: I5739eb21fa6918b0a2c0f33f7d97dad73c5cf0b1
Cq-Include-Trybots: luci.dart.try:flutter-engine-linux-try,flutter-linux-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/278518
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2023-01-16 15:12:38 +00:00
Brian Quinlan 3571b97b24 [win/io] Fix a bug where RawDataSocket would send truncated data on Windows.
Bug:https://github.com/dart-lang/sdk/issues/31873
Change-Id: I8856bad941330f24671fc2c61af736fc54cd9459
Tested: unit tests
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/278981
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Brian Quinlan <bquinlan@google.com>
2023-01-13 20:36:55 +00:00
Josh Soref 50b94ef9fc Spelling runtime bin
TEST=build VM

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

GitOrigin-RevId: ae54b37666f70f670ee3af11c984c7e9a7e9da26
Change-Id: I459fda0439a1cd368f488a70d84ee6bb915e60bb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/277761
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2023-01-06 07:48:22 +00:00
Haidar cbe458703c [vm/api] Make CObject as_string const char* instead of const
Closes https://github.com/dart-lang/sdk/pull/50884

TEST=ci

GitOrigin-RevId: f898451bb21f1e49550698fcf08ec5dfc1036dce
Change-Id: I808d37afe3e953afd632e4ffc4ab4b152b468e4f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/278140
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2023-01-04 12:51:03 +00:00
xiao xiao 7fa17936a6 [samples/ffi] Use the function arguments instead of static value
TEST=samples/ffi/async/async_test.dart

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

GitOrigin-RevId: 265298d1529dc01a8ee75aff595a647878ece1bc
Change-Id: I688ffb2369f3028a2d490ae21f50e176c9227185
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/278099
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2023-01-04 11:34:27 +00:00
Alexander Aprelev 8e7b1119b3 [vm/reload] Ensure FileModifiedCallback can handle uris on Windows.
Bug: https://github.com/dart-lang/sdk/issues/49634
Change-Id: I65b5c2a0559fdc51c003ffa6e955008850137a1c
TEST=bad_reload_test on Windows
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/277044
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2022-12-21 23:11:30 +00:00
Brian Quinlan 9b2b9df09e [io] Remove incorrect docs that listSupport is not available on Android.
Bug:https://github.com/dart-lang/sdk/issues/47894
Change-Id: Id79a37f5ba6a8118a30d2297c95cff5a7ca1a03f
TEST=unit
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/276660
Commit-Queue: Brian Quinlan <bquinlan@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2022-12-21 00:23:02 +00:00
Derek Xu 53d859f6b9 Revert "[VM/CLI] Remove dartdev.dill"
This reverts commit c09f790d37.

Reason for revert: CI failures

Original change's description:
> [VM/CLI] Remove dartdev.dill
>
> Incompatible VM flags will no longer break the CLI when running from an
> AppJIT snapshot, so the fallback logic is no longer required. This CL
> thus removes dartdev.dill and the fallback logic.
>
> Relevant past CLs: https://dart-review.googlesource.com/c/sdk/+/157601
> and https://dart-review.googlesource.com/c/sdk/+/178300
>
> Fixes https://github.com/dart-lang/sdk/issues/50504
>
> TEST=I tried running `out/ReleaseX64/dart --observe --sound-null-safety test.dart`
> and `out/ReleaseX64/dart --observe --no-sound-null-safety test.dart` and
> both worked.
>
> Change-Id: I5cdcfbccf71ec557964014fdb80733b4a7c76b4d
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/274520
> Reviewed-by: Ben Konyi <bkonyi@google.com>
> Commit-Queue: Derek Xu <derekx@google.com>

TBR=bkonyi@google.com,derekx@google.com,dart-scoped@luci-project-accounts.iam.gserviceaccount.com

Change-Id: I5117f990dfabf93f5a9bae56098831280845e84e
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/275181
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Derek Xu <derekx@google.com>
2022-12-13 15:28:19 +00:00
Derek Xu c09f790d37 [VM/CLI] Remove dartdev.dill
Incompatible VM flags will no longer break the CLI when running from an
AppJIT snapshot, so the fallback logic is no longer required. This CL
thus removes dartdev.dill and the fallback logic.

Relevant past CLs: https://dart-review.googlesource.com/c/sdk/+/157601
and https://dart-review.googlesource.com/c/sdk/+/178300

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

TEST=I tried running `out/ReleaseX64/dart --observe --sound-null-safety test.dart`
and `out/ReleaseX64/dart --observe --no-sound-null-safety test.dart` and
both worked.

Change-Id: I5cdcfbccf71ec557964014fdb80733b4a7c76b4d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/274520
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Derek Xu <derekx@google.com>
2022-12-12 18:02:47 +00:00
asiva 606a64a743 [3.0 alpha][VM/Runtime] - Flip flag to make strong null safety the default.
- Flip flag to make strong null safety the default
- Remove code that auto detects null safety mode from source files,
  it is necessary to specify --no-strong-null-safety to opt out.
- Retains sniffing of AOT/JIT snapshots and kernel files to determine
  null safety mode, the opt out has to be done when generating these
  file.

TEST=ci

Change-Id: If2c9608eedb7c46d9c3cd85e261ee9640e0d28eb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/261140
Reviewed-by: Alexander Thomas <athom@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2022-12-06 04:04:23 +00:00
Ben Konyi 3602351df0 [ VM Service ] Add support for '--[no-]serve-observatory'
To prepare for the eventual removal of Observatory, we plan on disabling
Observatory by default while providing an escape hatch to manually serve
the tool for some period of time before completely removing Observatory
from the SDK. This change adds flags that can be used to configure
whether or not Observatory is served.

Currently, '--serve-observatory' is the default behavior, but will be
changed to '--no-serve-observatory' once tooling is ready to support the
escape hatch behavior.

Part of https://github.com/dart-lang/sdk/issues/50233

TEST=run_test.dart

Change-Id: Ib6d1e1587d9fbd3c61d4a4c75d90635052835844
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/267720
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2022-11-21 17:47:31 +00:00
Tom Robinson a211fe7655 Add logging to trace invalid keys.
Per b/253491057, there are invalid keys (i.e. keys with value 0) being
passed around on occasion.  These keys are resulting in flaky test.

This change adds additional error logging to help determine when the
zero-valued keys are originating from.

This change also removes the zx_assert to avoid crashing when a
zero-value key is encountered, and instead an error is logged.

TEST=built for fuchsia and tested on nest hub device.

Bug: b/253491057
Change-Id: Ic94a3f526318ef2873d3af7a3ceab064b67859d5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/268603
Reviewed-by: Zach Anderson <zra@google.com>
Commit-Queue: Brian Quinlan <bquinlan@google.com>
Reviewed-by: Brian Quinlan <bquinlan@google.com>
2022-11-09 21:59:28 +00:00
Brian Quinlan b75f8aaaf5 [io/file] - add FileSystemNotFoundException
Thrown by when an operation fails because a file is not found.

TEST=updated unit tests
Issue: https://github.com/dart-lang/sdk/issues/12461
Change-Id: I2e6e3986f92d5bf9f3922f4e2c6bbba67cc102bc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/267280
Reviewed-by: Lasse Nielsen <lrn@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Brian Quinlan <bquinlan@google.com>
2022-11-08 19:26:19 +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
Tom Robinson 005a0a807e Do not try to handle non ZX_PKT_TYPE_SIGNAL_ONE incorrectly
Closes https://github.com/dart-lang/sdk/pull/50240
TEST=building for fuchsia and testing on Nest Hub device.

GitOrigin-RevId: 28a6d9d8654f81cdf86161b1fc884b289a035392
Change-Id: Ie84d7943ea0d874fe4e5b421ddf47b8f0a884628
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/264640
Reviewed-by: Zach Anderson <zra@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2022-10-19 19:03:28 +00:00
Ben Konyi 39168c9ef0 [ CLI ] Fix dart run --enable-experiment
Fixes issue where --enable-experiment options passed after `dart
run` weren't being handled by the VM.

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

TEST=pkg/dartdev/test/commands/run_test.dart

Change-Id: Ia9c585a16756fd4450cfd159a1b9864ebfb6d200
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/264200
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2022-10-18 13:42:32 +00:00
Tess Strickland 9df6656aa9 [build] Re-add linker flags to create empty section in AOT runtime.
To avoid these flags being applied to unexpected build rules, we
separate them out into a separate config that is then pulled in
explicitly in the `dart_precompiled_runtime{,_product}` executable
rules. Only those two executables need the additional empty section:
the product version because it becomes `dartaotruntime` in the SDK
bundle, and the non-product version because some of our tests build
standalone executables using it.

The linker flags were originally removed due to
https://github.com/flutter/flutter/issues/112687.
With the recent removal of bitcode support from Flutter (see
https://github.com/flutter/flutter/issues/107883), I can build
the `ios_release` target locally without any issue.

This also reverts the clang DEPS changes from CL 256208 (again).

TEST=pkg/dartdev/test/commands/compile_test

Bug: https://github.com/dart-lang/sdk/issues/49783
Cq-Include-Trybots: luci.dart.try:analyzer-mac-release-try,dart-sdk-mac-arm64-try,dart-sdk-mac-try,pkg-mac-release-arm64-try,pkg-mac-release-try,vm-kernel-precomp-mac-product-x64-try,vm-kernel-precomp-nnbd-mac-release-arm64-try
Change-Id: Ie46402ec2eeda23109247eb9d7a64935ec2052cb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/262429
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
2022-10-07 09:26:18 +00:00
Ben Konyi c8651ac551 [ CLI ] Force isolate running dart2js to use --no-sound-null-safety
Fixes https://github.com/dart-lang/sdk/issues/50090

TEST=N/A

Change-Id: I5e26a88a8daa107fa684009562c4eb2207f41a9d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/262621
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2022-10-04 16:59:57 +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
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
Tess Strickland b0c4ddf919 [pkg/dart2native] Avoid overwriting section contents in MachO files.
To create a Dart standalone executable on MacOS, we modify the
dartaotruntime executable to add the snapshot contents, and the
VM looks into the executable on disk to find the snapshot to load.

Previously, we did this by adding a new 64-bit segment load command
with a single section, where the section's file offset and size
describes the inserted snapshot. This meant the Mach-O header size increased by 152 bytes.

Originally, this wasn't an issue as there was plenty of padding, but
later clang updates removed most of this padding, and so writing the
new header actually overwrote the initial contents of the first section
in the file, which happens to be the __text section. In addition, since
the first section's offset was now declared to be within the header,
utilities that strictly validated the Mach-O format, like codesign,
would report errors.

This CL changes it so that we actually reserve space in the
dartaotruntime header using the -add_empty_section flag to the linker.
In addition, we change from using a segment load command to using a
(40 byte) note load command. This is because a segment load command
specifies that the contents should be loaded in memory, but we don't
use that loaded version. Instead, the VM reloads it from the executable
on disk so it can appropriately mmap the different parts of the
snapshot. A note section instead just declares a section of the
executable as arbitrary data that the owner can read from the file
and use as desired, which is semantically closer to our current usage.

This CL also adds a test to pkg/dartdev/test/commands/compile_test to
ensure that corrupting a random part of the snapshot in the executable
causes signature verification to fail.

This CL also reverts CL 256208, thus relanding the clang changes
starting from June that originally raised awareness of the issue by
greatly reduced the amount of padding after the load commands.

TEST=pkg/dartdev/test/commands/compile_test

Bug: https://github.com/dart-lang/sdk/issues/49783
Change-Id: Iee554d87b0eabaecd7a534ca4e4facfefbce6385
Cq-Include-Trybots: luci.dart.try:analyzer-mac-release-try,dart-sdk-mac-arm64-try,dart-sdk-mac-try,pkg-mac-release-arm64-try,pkg-mac-release-try,vm-kernel-precomp-mac-product-x64-try,vm-kernel-precomp-nnbd-mac-release-arm64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/260108
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
2022-09-29 08:32:47 +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
Alexander Aprelev 46bc947e75 [gardening] Fix gen_snapshot crash on msvc.
Revert change to StringRAII which used to take reference, but was changed to take pointer in 2ead86ab9d

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

Change-Id: I8d8b18e6e9ae3cd07427ee1b37df404d11dcb26e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/260402
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Liam Appelbe <liama@google.com>
2022-09-21 18:16:56 +00:00
asiva 3cdeb58c98 [VM/Runtime] - Use 'const' qualifier for CObject typed data
Addresses https://github.com/dart-lang/sdk/issues/49827

TEST=ci

Change-Id: I525cc27d0bf01945d4f700f48355a3f17e297007
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/256602
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
2022-09-13 22:38:22 +00:00
Brian Quinlan 2ead86ab9d Implement anonymous pipes and the ability to transmit them between processes using Unix Domain Sockets.
Change-Id: I9c9f4ec0e99075a29c6f4d97c503e759134eb094
TESTED=Unit tests
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/257804
Commit-Queue: Brian Quinlan <bquinlan@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2022-09-13 21:16:28 +00:00
Brian Quinlan 270350d0bd Add support for sending file descriptors over unix domain sockets on macOS
Change-Id: Ifce87fdd100f193b956de98e293e2d6859bdb95b
TEST=unix_socket_test.dart
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/256783
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Brian Quinlan <bquinlan@google.com>
2022-09-01 20:36:12 +00:00
Brian Quinlan 8c49f519ce Generate an error when starting Processes on iOS
Bug: https://github.com/dart-lang/sdk/issues/49650
Change-Id: I4fc6ab5fc964eabe45851e7a72abf0db92e2b2f2
TEST=manual :-(
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/254981
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Brian Quinlan <bquinlan@google.com>
2022-08-29 17:14:36 +00:00
Alexander Aprelev 33846f3678 [io/file] Add exclusive optional parameter to File.create, createSync.
TEST=standalone/io/file_create_test

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

Change-Id: I0b1bdc889caf5801570d7ac9e7b6694264cd6565
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/255482
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
2022-08-24 17:09:49 +00:00
Chris Evans 7962f8a119 Updates to analyze_snapshot tool
- format fixes for readme and build descriptions
- added pretty print option for tool
- changed parsing of class_table to discover library objects
  - JSON output format changes
- defines to accurately mirror platform compatibility
- other small fixes
TEST=ci
Change-Id: I3f27f6fa48ce6111d94c5a88d57fa7bf7abc210c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/252661
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Chris Evans <cmevans@google.com>
2022-08-23 12:18:00 +00:00
Tess Strickland 00bd7ff339 [vm/test] Remove checked-in binaries from MachO test.
Instead of using checked-in binaries in snapshot_utils_test.cc,
write out the binaries manually and check the written binaries.

TEST=vm/cc/CanDetectMachOFiles

Issue: https://github.com/dart-lang/.allstar/issues/159

Change-Id: I024ecac2084cfaef6bf8fe2a7cecceb9ae5d8de9
Cq-Include-Trybots: luci.dart.try:vm-kernel-mac-release-arm64-try,vm-kernel-mac-release-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/255460
Reviewed-by: Alexander Thomas <athom@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
2022-08-17 16:18:35 +00:00
Daco Harkes 1ae40d5ebf [vm/ffi] Add Fuchsia ABI unit tests
Adds the Fuchsia ABI to the ABI unit tests.

Adds an ABI test for the FFI callback on who's return the stack is/gets
corrupted from bug:
https://bugs.fuchsia.dev/p/fuchsia/issues/detail?id=105336

TEST=tools/test.py ffi_unit

Change-Id: I3c9bb9941e4883384dfba787bb6dacb4c8cdc141
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/255122
Reviewed-by: Jonas Termansen <sortie@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
2022-08-16 12:17:26 +00:00
Ben Konyi eff8c305d9 [ Service / Timeline ] Enable Compiler, Dart, and GC timeline streams when --observe is provided
TEST=pkg/vm_service/test_timeline_default_streams_test.dart

Fixes https://github.com/flutter/devtools/issues/3444

Change-Id: I3f772a54a512eb836e3e7279ee8d4d3437473393
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/255181
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2022-08-15 21:02:36 +00:00
Ryan Macnak f32392aada [standalone] Cleanup sorting classes before generating an AppJIT snapshot.
With isolate groups enabled, there is no longer an issue with spawnFunction isolates becoming out-of-sync.

Cf. be9bb43ceb.

TEST=ci
Change-Id: I242a15e132958ade3107c54ce38ea6922e0f5662
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/254761
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2022-08-11 20:58:39 +00:00
Tess Strickland 24683da915 [vm] Add OS and architecture to non-symbolic stack traces.
Examples of the new line added to non-symbolic stack traces:

os: linux arch: x64 comp: yes sim: no
(Running on linux-x64c)

os: macos arch: arm64 comp: no sim: yes
(Running on mac-simarm64)

This CL also abstracts out the separate hardcoded strings across
the codebase for host and target OS and architecture into
definitions in platform/globals.h to ensure that they stay
in sync across different uses.

TEST=vm/dart{,_2}/use_dwarf_stack_traces_flag

Issue: https://github.com/flutter/flutter/pull/101586
Change-Id: Ifdfea5138dd1003f561da0174e89aebc165bf9b0
Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-dwarf-linux-product-x64-try,vm-kernel-precomp-linux-release-simarm-try,vm-kernel-precomp-linux-release-simarm64-try,vm-kernel-precomp-linux-release-simarm_x64-try,vm-kernel-precomp-linux-release-x64-try,vm-kernel-precomp-mac-product-x64-try,vm-kernel-precomp-nnbd-linux-release-x64-try,vm-kernel-precomp-nnbd-linux-release-simarm_x64-try,vm-kernel-precomp-win-release-x64-try,vm-kernel-precomp-nnbd-mac-release-arm64-try,vm-kernel-precomp-mac-release-simarm64-try,vm-ffi-android-release-arm-try,vm-ffi-android-release-arm64c-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/253283
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
2022-08-05 11:53:37 +00:00
Ahmed Ashour 99f0fb5b70 Fix typos
Fixes #49364

TEST=ci

Change-Id: Ic643819c9cdd7b56690981b96b854b1e8d622fff
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/250160
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2022-07-12 19:35:22 +00:00
Ryan Macnak 4308eb39cf [standalone] Remove RISC-V linker hack.
TEST=ci
Change-Id: I5379bc3f537cab149742df138d76983b4f16a796
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/250141
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-06-30 21:16:04 +00:00
Daco Harkes a37502c1b8 [misc] Cleanup stale todos
TEST=tests/ffi

Change-Id: Iae97f62b1adb8dbe99ad075dfe750604db0de62c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/249301
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Tess Strickland <sstrickl@google.com>
2022-06-28 16:02:53 +00:00
Ben Konyi 95d1558109 [ VM / CLI ] Redirect users to use 'dart compile' for snapshot generation
Note: `--snapshot=` and related flags are still valid for non-DartDev
invocations of the VM (e.g., 'dart --snapshot=').

TEST=Local testing

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

Change-Id: I666f68bd46d5b22c691da15267f14f4ad5a53731
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/249220
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2022-06-23 20:35:15 +00:00
Ahmed Ashour 85700570f6 Fix typos
Fixes #49241

TEST=ci

Change-Id: I6117bf816fc8c4613cce66927f952fef75632725
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/248120
Reviewed-by: Alexander Thomas <athom@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Alexander Thomas <athom@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2022-06-15 11:08:28 +00:00
Alexander Markov de43a7c16a [vm] Cleanup --lazy-async-stacks VM option
This option was enabled by default in https://dart-review.googlesource.com/c/sdk/+/149288
This change removes old logic behind --no-lazy-async-stacks
and makes --lazy-async-stacks/--no-lazy-async-stacks options no-op.

TEST=ci

Change-Id: I5726690e90e78dd2ac37d8c5944e388042fc3acf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/247780
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2022-06-10 13:41:24 +00:00
Jonas Termansen 83850ac5fa [io] Don't restore terminal state on exit.
This is breaking change #45630.

The Dart VM has until now restored the terminal settings upon exit to
their initial values for stdin, stdout, and stderr. This change removes
that automatic behavior in favor of having the program do the
restoration. Previously the intention was that dart programs can
enable/disable echoing and line buffering and not worry about restoring
the original settings.

However, the VM doing so unconditionally leads to undesirable behavior
e.g. when the program does not care about terminal settings and is
sharing a process group with a program that does care. E.g. if dart's
output is piped into less(1), then there is a race condition where dart
might see the raw terminal settings set by less(1), and if the dart VM
exits after less(1) has exited, then it will restore the raw terminal
settings, leaving the user with a seemingly defective shell with echo
disabled. This race condition can be reproduced using:

    cat > yes.dart << EOF
    main() {
      for (int i = 0; i < 1000000; i++) {
        print("yes");
      }
    }
    EOF
    stty; (sleep 1 && dart yes.dart) | less; stty; stty sane

The user will end up with a shell with echo behavior disabled. The stty
command shows the current terminal settings, where the difference can be
seen, and 'stty sane' fixes the settings before returning to the shell
prompt. The 'stty sane' call can be omitted to see the defective shell
prompt.

This change removes the terminal restoring behavior (added in Dart
2.0.0) and instead asks applications to do the restoration themselves.
The new design matches how programs in other programming languages
implement interactive input that changes terminal settings.

Furthermore the `echoMode` setting now only controls the `echo` local
mode and no longer sets the `echonl` local mode on POSIX systems (which
controls whether newline are echoed even if the regular echo mode is
disabled). The `echonl` local mode is usually turned off in common shell
environments. Programs that wish to control the `echonl` local mode can
use the new `echoNewlineMode` setting. This change is required to
prevent the reoccurence of #30318 when programs manually restore
`echoMode`.

Windows has further considerations: It also saves the console code pages
and restore them if they were not UTF-8. This behavior is retained as it
is useful and needed for Dart's output to function properly. ANSI output
sequences are also turned on via ENABLE_VIRTUAL_TERMINAL_PROCESSING,
which is slightly changed in this change to only rsetore that setting if
it wasn't already on for consistency.

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

TEST=Reproduced with less as above

Change-Id: I2991f9c7f47b97fe475c1ad6edeb769024f8d0db
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/190484
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Jonas Termansen <sortie@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2022-05-31 15:36:33 +00:00
asiva e8290f7f5a [VM/io] - Reland : Set correct file type for files backing unix domain sockets
The file type of file backing unix domain sockets was being incorrectly
set as kDoesNotExist resulting in errors when operations like delete
on the file was done. File::Exists on the other hand returned true.
File rename and copyfile functionality have been fixed too.

TEST=new tests added

Please see https://github.com/dart-lang/sdk/issues/48569 for the original issue.

Change-Id: I28505236fbad2ea86ad65065e753b13fb7ff655a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/240300
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
2022-05-15 00:40:07 +00:00
asiva 96d59fe998 [VM/io] - Add missing native entry to enable resolution.
TEST=ci

Change-Id: Ie293903d1fe637f05e3e70926ae4fa648e752a22
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/243886
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
2022-05-09 16:24:02 +00:00
Clement Skau b514b74dee [format] Remove multiline comment that gcc errors on.
TEST=comment only change

Bug: https://github.com/dart-lang/sdk/issues/48855
Change-Id: I39ea0593d2e660803b2e6520f51c2a1c9aaaaec7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/241967
Auto-Submit: Clement Skau <cskau@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-04-21 22:30:59 +00:00
Vyacheslav Egorov d2126a3d5b [vm] Avoid deadlocks when launching subprocesses
Forked process should use _exit() rather than exit()
when exiting without exec-ing otherwise it risks
to hit an issue (e.g. deadlock) in an atexit handler.

Additionally `man fork` states:

> After a fork() in a multithreaded program, the child can
> safely call only async-signal-safe functions (see
> signal-safety(7)) until such time as it calls execve(2).

_exit is on the list of async-signal-safe functions, but
exit is not.

Fixes b/216834909

TEST=runtime/tests/vm/dart{,_2}/regress_b_216834909_test.dart

Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-android-release-arm64c-try,vm-kernel-mac-release-x64-try
Change-Id: Ia67f23825fc0ee1c1918faf2d4ef3b81033263eb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/241608
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2022-04-20 13:55:59 +00:00
Ryan Macnak 4c7840d330 [dart:io] Publish implementations of the VM file callbacks.
TEST=ci
Change-Id: I481b6fe3e7eae02ff7f2c94fa2f60bef0a972b3c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/241685
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-04-19 23:27:17 +00:00
Ryan Macnak cf2f4fc4cc [vm, ffi] Explicitly align ClobberAndCall.
Fixes `ld: warning: arm64 function not 4-byte aligned: _ClobberAndCall from obj/runtime/bin/ffi_test/libffi_test_functions.clobber_arm64.o`

TEST=ci
Change-Id: I84cc051655d48ac2eb27e0a12c1edcc8aa8e8a46
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/241080
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-04-13 16:03:14 +00:00
Oleh Prypin a3478da7fa Resolve clang-tidy warnings 'readability-redundant-smartptr-get'
4 instances of the following issue: redundant get() call on smart pointer

Tested: Only through CI. There are no changes in behavior, all possible problems would be found through a compilation failure.
Change-Id: Ib11432baef83d3daebd800b365183e1ea6621136
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/240540
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Commit-Queue: Oleh Prypin <oprypin@google.com>
2022-04-11 15:42:01 +00:00
Ryan Macnak 53c04ff910 [vm] More pieces of Windows ARM support.
TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/47824
Change-Id: Ie7388b12359b9ae11509a3f1b9e86c72507df38f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/240483
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-04-07 23:15:48 +00:00
Daco Harkes 4b322a398a [vm] Finalizer / NativeFinalizer fixes
1. Run native finalizers before sending isolate exit message. This way
   users can rely on the isolate exit message for both (1) no Dart code
   executing anymore on that isolate _and_ (2) all native finalizers
   having run. Alternatively, we could opt to not provide this second
   guarantee and document this.

2. Fix UBSAN error by making SetArgumentTo42's argument a `void*`.

3. Fix bug in debug mode, stop reading tags from forwarding addresses.

4. Small optimization: Don't promote 0 bytes from new to old space.

5. Skip finalizer_isolate_groups_run_gc_test in optcounter mode.
   In hot reload mode, GC is guaranteed to run. On all other bots GC
   does not run (nothing happens in the other isolate group). However,
   in optcounter mode enough happens in the other isolate group to
   trigger GCs. Alternatively, we could loosen the test to allow either
   a GC to happen or not.

TEST=runtime/tests/vm/dart(_2)/finalizer/*
TEST=runtime/tests/vm/dart(_2)/isolates/fast_object_copy_test.dart
TEST=runtime/vm/object_test.cc
TEST=tests/ffi(_2)/vmspecific_native_finalizer_*

Closes: https://github.com/dart-lang/sdk/issues/48740
Closes: https://github.com/dart-lang/sdk/issues/48715
Closes: https://github.com/dart-lang/sdk/issues/48674

Change-Id: I5e260e087aef48524f2214f5b332caeda18f2e37
Cq-Include-Trybots: luci.dart.try:vm-kernel-ubsan-linux-release-x64-try,vm-kernel-precomp-ubsan-linux-release-x64-try,vm-canary-linux-debug-try,vm-kernel-optcounter-threshold-linux-release-x64-try,vm-kernel-optcounter-threshold-linux-release-ia32-try,app-kernel-linux-debug-x64-try,vm-kernel-precomp-linux-debug-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/240043
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2022-04-07 07:05:27 +00:00
Ryan Macnak ea0c27523a [build] Extend bin_to_coff.py to support ARM and ARM64.
TEST=local
Bug: https://github.com/dart-lang/sdk/issues/47824
Change-Id: I9e15bb538e63ee16a2646c78fb786e135d1184ad
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/240441
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-04-06 22:21:07 +00:00
Siva Annamalai ac6f72205a Revert "[VM/io] - Set correct file type for files backing unix domain sockets"
This reverts commit dbe6d1d574.

Reason for revert: One of the new tests spawns a process and runs the script from source and so this test will fail on all AOT configurations, In addition it is failing on mac builds and needs investigation.

Original change's description:
> [VM/io] - Set correct file type for files backing unix domain sockets
>
> The file type of file backing unix domain sockets was being incorrectly
> set as kDoesNotExist resulting in errors when operations like delete
> on the file was done. File::Exists on the other hand returned true.
> File rename and copyfile functionality have been fixed too.
>
> TEST=new tests added
>
> Please see https://github.com/dart-lang/sdk/issues/48569 for the original issue.
> Change-Id: Ie9c716c84b1d818c906ecdb622ba930125f9ee30
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/237745
> Reviewed-by: Ryan Macnak <rmacnak@google.com>
> Commit-Queue: Siva Annamalai <asiva@google.com>

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

Change-Id: I517896fb90b013af1ce9a6754442a922e2b7cda5
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/240149
Reviewed-by: Siva Annamalai <asiva@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
2022-04-04 23:30:02 +00:00
asiva dbe6d1d574 [VM/io] - Set correct file type for files backing unix domain sockets
The file type of file backing unix domain sockets was being incorrectly
set as kDoesNotExist resulting in errors when operations like delete
on the file was done. File::Exists on the other hand returned true.
File rename and copyfile functionality have been fixed too.

TEST=new tests added

Please see https://github.com/dart-lang/sdk/issues/48569 for the original issue.
Change-Id: Ie9c716c84b1d818c906ecdb622ba930125f9ee30
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/237745
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
2022-04-04 22:17:42 +00:00
asiva 89f5b68ca1 [VM / IO] Fix cases where TlsExceptions were being created with an
OSError code of 0

One such example was _SecurityContext.setTrustedCertificatesBytes

TEST=new tests added

Change-Id: Ibc5d06b83bb1bb93e12f79100acc60546554c268
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/239863
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
2022-04-04 21:57:22 +00:00
asiva 4f76b9535d [VM / IO] Assert When a socket exception is being thrown with an error code of 0.
TEST=ci

Change-Id: Ie0ea5329dfe0307f47fc04db693dae4e352d0f64
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/239846
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
2022-04-04 21:34:21 +00:00
Alexander Aprelev 0b49bb6e37 [io/win] Ensure File_WriteFrom and File_Read report non-zero error code.
BUG=https://github.com/dart-lang/sdk/issues/48721
TEST=file_error2_test,file_fuzz_test on win ia32

Change-Id: I260c3fa46bc737db741b3b9ae9172c939648aa6c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/239861
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2022-04-02 04:11:59 +00:00
Slava Egorov 4c0387461c Revert "[VM / IO] - Reland : Assert when an OSError exception is reported with no error"
This reverts commit dc8002cc42.

Reason for revert: crashes internally (b/227727791) and externally (dartbug.com/48721)

Original change's description:
> [VM / IO] - Reland : Assert when an OSError exception is reported with no error
>
> 1. Add a Fatal assert when an OSError is reported with no error code (0).
> This is to ensure we get a coredum pwhen this happens so we can analyze
> it. (Please see https://github.com/flutter/flutter/issues/90921 for more
> details)
>
> TEST=ci
>
> Change-Id: I7146ac69ef8b1833f28bed8a23f0c27a2ece4bbf
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/239726
> Reviewed-by: Alexander Aprelev <aam@google.com>
> Commit-Queue: Siva Annamalai <asiva@google.com>

TBR=aam@google.com,asiva@google.com

Change-Id: Ic9302e7922b0ce2ea5ab81357804c3cd822a8052
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/239664
Reviewed-by: Slava Egorov <vegorov@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2022-04-01 10:14:37 +00:00
asiva dc8002cc42 [VM / IO] - Reland : Assert when an OSError exception is reported with no error
1. Add a Fatal assert when an OSError is reported with no error code (0).
This is to ensure we get a coredum pwhen this happens so we can analyze
it. (Please see https://github.com/flutter/flutter/issues/90921 for more
details)

TEST=ci

Change-Id: I7146ac69ef8b1833f28bed8a23f0c27a2ece4bbf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/239726
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
2022-03-31 22:18:15 +00:00
Alexander Aprelev 67c6e2311a [io/win] Use filewin api which is coordinated with GetLastError, rather than errno.
Fixes https://github.com/dart-lang/sdk/issues/48718
TEST=file_test

Change-Id: Ie47fa7807b96832140e8b9d5df53b47ffa0ecc67
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/239725
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2022-03-31 20:51:25 +00:00
Brian Quinlan c286b76c2d Allow sockets to enable TLS renegotiation.
TESTED=unit + manually tested user issue.
Bug: https://github.com/dart-lang/sdk/issues/47841
Change-Id: Iad13899135fd34f15abba3a499132d88e7f597dc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/234821
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Brian Quinlan <bquinlan@google.com>
2022-03-31 06:40:51 +00:00
Alexander Aprelev 3a4adb776e Revert "[VM / IO] - Assert when an OSError exception is reported with no error"
This reverts commit 9038f5e1f7.

Reason for revert: broke g3 bot blocking dart->engine roll

Original change's description:
> [VM / IO] - Assert when an OSError exception is reported with no error
>
> Add a Fatal assert when an OSError is reported with no error code (0).
> This is to ensure we get a coredum pwhen this happens so we can analyze
> it. (Please see https://github.com/flutter/flutter/issues/90921 for more
> details)
>
> TEST=ci
>
> Change-Id: I7f4609c2431e6ddc4eacc753356c807d7338b0a9
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/239541
> Reviewed-by: Ryan Macnak <rmacnak@google.com>
> Commit-Queue: Siva Annamalai <asiva@google.com>

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

Change-Id: I87df53a7d81802ad1a88f54a90a49f88db44108b
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/239602
Reviewed-by: Alexander Aprelev <aam@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Auto-Submit: Alexander Aprelev <aam@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2022-03-31 03:09:42 +00:00
asiva 9038f5e1f7 [VM / IO] - Assert when an OSError exception is reported with no error
Add a Fatal assert when an OSError is reported with no error code (0).
This is to ensure we get a coredum pwhen this happens so we can analyze
it. (Please see https://github.com/flutter/flutter/issues/90921 for more
details)

TEST=ci

Change-Id: I7f4609c2431e6ddc4eacc753356c807d7338b0a9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/239541
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
2022-03-31 01:24:43 +00:00
Daco Harkes 532c116cd2 [vm] Implement NativeFinalizer
This CL implements `NativeFinalizer` in the GC.

`FinalizerEntry`s are extended to track `external_size` and in which
`Heap::Space` the finalizable value is.

On attaching a native finalizer, the external size is added to the
relevant heap. When the finalizable value is promoted from new to old
space, the external size is promoted as well. And when a native
finalizer is run or is detached, the external size is removed from the
relevant heap again.

In contrast to Dart `Finalizer`s, `NativeFinalizer`s are run on isolate
shutdown.

When the `NativeFinalizer`s themselves are collected, the finalizers are
not run. Users should stick the native finalizer in a global variable to
ensure finalization. We will revisit this design when we add send and
exit support, because there is a design space to explore what to do in
that case. This current solution promises the least to users.

In this implementation native finalizers have a Dart entry to clean up
the entries from the `all_entries` field of the finalizer. We should
consider using another data structure that avoids the need for this Dart
entry. See the TODO left in the code.

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

TEST=runtime/tests/vm/dart(_2)/isolates/fast_object_copy_test.dart
TEST=runtime/vm/object_test.cc
TEST=tests/ffi(_2)/vmspecific_native_finalizer_*

Change-Id: I8f594c80c3c344ad83e1f2de10de028eb8456121
Cq-Include-Trybots: luci.dart.try:vm-kernel-reload-rollback-linux-debug-x64-try,vm-kernel-reload-linux-debug-x64-try,vm-ffi-android-debug-arm64c-try,dart-sdk-mac-arm64-try,vm-kernel-mac-release-arm64-try,pkg-mac-release-arm64-try,vm-kernel-precomp-nnbd-mac-release-arm64-try,vm-kernel-win-debug-x64c-try,vm-kernel-win-debug-x64-try,vm-kernel-precomp-win-debug-x64c-try,vm-kernel-nnbd-win-release-ia32-try,vm-ffi-android-debug-arm-try,vm-precomp-ffi-qemu-linux-release-arm-try,vm-kernel-mac-debug-x64-try,vm-kernel-nnbd-mac-debug-x64-try,vm-kernel-nnbd-linux-debug-ia32-try,benchmark-linux-try,flutter-frontend-try,pkg-linux-debug-try,vm-kernel-asan-linux-release-x64-try,vm-kernel-gcc-linux-try,vm-kernel-optcounter-threshold-linux-release-x64-try,vm-kernel-precomp-linux-debug-simarm_x64-try,vm-kernel-precomp-obfuscate-linux-release-x64-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-debug-x64c-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/236320
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2022-03-26 09:41:21 +00:00
Tess Strickland cdb703859a [dart2native] Allow for signing of Windows standalone executables.
Instead of simply concatenating the dartaotruntime executable and the
ELF snapshot, we instead insert the ELF snapshot as a COFF section,
so the resulting PE file can be signed.

TEST=pkg/dartdev/test/commands/compile_test

Bug: https://github.com/dart-lang/sdk/issues/39106
Change-Id: Iaafb5833fcb9c69c0dd374b64769f22b8b9f53a2
Cq-Include-Trybots: luci.dart.try:pkg-win-release-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/236100
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
2022-03-24 10:08:01 +00:00
Alexander Aprelev 435ebeb5a7 Fix MSVC build
- refactor designated initializers as they are c++20
- unwrap #if/#endif in macro arguments
- remove taking pointer on purely intrinsic function (setjmp_)
- use DART_WARN_UNUSED_RESULT which is msvc/clang friendly
- provide StringRAII copying constructor

Bug: https://github.com/dart-lang/sdk/issues/48544
TEST=ci,msvc build
Change-Id: I1049589c96dc0cdf49e1d31d320b6804bf6e4558
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/237929
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2022-03-22 18:28:19 +00:00
Ryan Macnak 7a597a9e66 [vm] Make [os_]thread_absl.cc compatible with Mac.
Also remove unused functions from dart::bin::Thread.

TEST=ci, cbuild
Change-Id: I670dbf2767662156607cbfbee4c3ba64f1ba7ab1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/237765
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-03-21 16:47:47 +00:00
Ben Konyi b036052077 Reland "[ Service ] Update VM service message to not reference Observatory"
This reverts commit ee5837aa7a.

Updated Intellij plugins have been published which support the new
message.

TEST=CQ

Change-Id: I81f6d878f036991a95cc1f58d3102015e77aa609
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/237741
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2022-03-17 23:15:57 +00:00
Alexander Aprelev 8a43a891f3 [io/win] Ensure no-console flag is not used if stdio is inherited.
Follow-up to b6c5e52af6 that fixes broken test.

TEST=process_inherit_stdio_test

Change-Id: Ice2188af03f3230d0b8d1161fedce333e43b862b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/237482
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2022-03-16 00:20:03 +00:00
Alexander Aprelev b6c5e52af6 [io/win] Ensure console window is not created when running in windows mode.
Fixes https://github.com/dart-lang/sdk/issues/39945

TEST=ci, manually check flutter windows app doesn't pop-up console.

Change-Id: I05983947de10058e4b0d2f9cbe795bd52f97ad05
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/237400
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2022-03-15 21:34:23 +00:00
Ben Konyi 8c484d12fe Reland "[ Service / DDS ] Remove VM service polling logic, add --enable-service-fallback-port support to DDS"
This reverts commit d4f71515c7.

TEST=CQ

Change-Id: I180f9d045870a1ff5f7f3f82b6f4782e18c18cfc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/237440
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2022-03-15 18:14:42 +00:00
Emmanuel Pellereau d4f71515c7 Revert "[ Service / DDS ] Remove VM service polling logic, add --enable-service-fallback-port support to DDS"
This reverts commit bd8590ba9b.

Reason for revert: breaks google3 (b/224731131)

TEST=Clean revert

Original change's description:
> [ Service / DDS ] Remove VM service polling logic, add --enable-service-fallback-port support to DDS
>
> Polling logic was introduced due to a bug in Fuchsia's network stack
> which could result in the VM service attempting to start the server
> before the network stack was initialized. This issue should be resolved
> now, so this logic is no longer necessary.
>
> TEST=pkg/dartdev/test/commands/run_test.dart
>
> Change-Id: I10f185dfb1be1b0363983f3e0564d65c38c99ea8
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/235763
> Reviewed-by: Ryan Macnak <rmacnak@google.com>
> Commit-Queue: Ben Konyi <bkonyi@google.com>

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

Change-Id: I3016fad25220c4e5479f17294626d79a17bd316a
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/237360
Reviewed-by: Alexander Thomas <athom@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Reviewed-by: Emmanuel Pellereau <emmanuelp@google.com>
Commit-Queue: Emmanuel Pellereau <emmanuelp@google.com>
2022-03-15 12:01:30 +00:00
Zachary Anderson 2347481619 Make dart_target_arch filters for 32-bit intel consistent
dart_target_arch can be "x86", which is handled here:
https://github.com/dart-lang/sdk/blob/main/runtime/BUILD.gn#L113.
This CL also handles it in the remaining places.

This came up in https://github.com/flutter/engine/pull/30417

TEST=N/A
Change-Id: Ib6dcd0a7236938026a0cbcb3955433960b396667
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/237120
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Zach Anderson <zra@google.com>
2022-03-15 01:52:21 +00:00
Ben Konyi bd8590ba9b [ Service / DDS ] Remove VM service polling logic, add --enable-service-fallback-port support to DDS
Polling logic was introduced due to a bug in Fuchsia's network stack
which could result in the VM service attempting to start the server
before the network stack was initialized. This issue should be resolved
now, so this logic is no longer necessary.

TEST=pkg/dartdev/test/commands/run_test.dart

Change-Id: I10f185dfb1be1b0363983f3e0564d65c38c99ea8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/235763
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2022-03-14 21:44:29 +00:00
Ryan Macnak a48d05c8f9 [vm] Add build-time option to use absl mutexes in place of pthread mutexes.
TEST=ci, cbuild
Bug: b/220994782
Change-Id: Id1a15d0d9fcef192847b25a2549730eb1014a99e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/236760
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-03-10 23:48:05 +00:00
Tess Strickland 6ef426d7df MacOS-Signable Compiled Dart Scripts
This CL implements a slightly altered compilation process for `dart
compile` on MacOS. Instead of the traditional approach of
concatenating a dart snapshot with the dart runtime, this new
implementation uses a new MachO segment to store the snapshot. Doing
so ensure users can properly sign the resulting binaries.

The dart runtime has also been updated to look for the snapshots in
this new segment.

There are new unit tests ensuring the dart runtime can correctly
identify MachO-formatted executables and an end-to-end test ensuring
`dart compile` produces code that has the new segment and produces
code that can be signed.

TEST=pkg/dartdev/test/commands/compile_test

Change-Id: Ibdce80455e02bc2b6fd345d80be8d75f989a9c28
Cq-Include-Trybots: luci.dart.try:analyzer-mac-release-try,dart-sdk-mac-arm64-try,dart-sdk-mac-try,pkg-mac-release-arm64-try,pkg-mac-release-try,vm-kernel-mac-debug-x64-try,vm-kernel-mac-product-x64-try,vm-kernel-mac-release-arm64-try,vm-kernel-mac-release-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/228080
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Tess Strickland <sstrickl@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
2022-03-09 18:02:34 +00:00
Chris Evans 23b1f38981 Fixes for reland for analyze_snapshot program
1. Disable copying of executable for SDK binary signing
2. Fixes for ASAN memory leak in executable

TEST=runtime/tests/vm/dart_2/analyze_snapshot_binary_test.dart

This is a reland of 5d7d8a377d

Original change's description:
> Reland "Reland "[vm] Add analyze_snapshot tool for AOT snapshot inspection""
>
> This is a reland of 8d1eedca64
>
> Disable builds for Fuchsia
>
> TEST=runtime/tests/vm/dart_2/analyze_snapshot_binary_test.dart
> Original change's description:
> > Reland "[vm] Add analyze_snapshot tool for AOT snapshot inspection"
> >
> > This is a reland of 19e5749308
> >
> > TEST=runtime/tests/vm/dart/analyze_snapshot_binary_test.dart
> >
> > Original change's description:
> > > [vm] Add analyze_snapshot tool for AOT snapshot inspection
> > >
> > > Current skeleton to allow for instrumentation snapshots that can be
> > > built alongside Dart compilation artifacts and easily referenced for
> > > specific versions between Snapshot hash <-> DartSDK <-> Flutter Engine
> > >
> > > TEST=runtime/tests/vm/dart/analyze_snapshot_binary_test.dart
> > >
> > > Change-Id: Ie3757a265bbf457506c72fb62a625fea7bedcb68
> > > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/221087
> > > Reviewed-by: Slava Egorov <vegorov@google.com>
> > > Commit-Queue: Slava Egorov <vegorov@google.com>
> >
> > Change-Id: Ia1ea0071d30818440ae48484ff6c406236af5a4e
> > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/224526
> > Reviewed-by: Slava Egorov <vegorov@google.com>
> > Commit-Queue: Slava Egorov <vegorov@google.com>
>
> Change-Id: I769ced4cbe6eb926b8df36a15ca13c3145632082
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/233890
> Reviewed-by: Slava Egorov <vegorov@google.com>
> Commit-Queue: Chris Evans <cmevans@google.com>

Change-Id: I1e6e57dda56f1710cc3a52e35d4067910930a701
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/234500
Reviewed-by: Slava Egorov <vegorov@google.com>
Reviewed-by: Chris Evans <cmevans@google.com>
Commit-Queue: Chris Evans <cmevans@google.com>
2022-03-09 14:17:44 +00:00
Ryan Macnak dba2b1442b [standalone, mac] Set the process title based on the main script.
This makes it easier to identify the responsible program when a Dart process has high CPU or memory usage.

Add missing include of pthread.h, which seems to be indirectly included on proper MacOS but not iOS.

TEST=look at Activity Monitor
Change-Id: I682186cf1b16ae90ce6ee775b5c5bc72cdb2810f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/235700
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-03-07 19:21:53 +00:00
Alexander Aprelev 574bc8e59c Revert "[standalone, mac] Set the process title based on the main script."
This reverts commit bd8ed80309 as it broke
sim dart->engine roller build

TEST=revert

Change-Id: Ibe513e53cfb77aa8297b650d33191cd9e3bea4f7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/235400
Auto-Submit: Alexander Aprelev <aam@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
Reviewed-by: Alexander Thomas <athom@google.com>
2022-03-04 18:03:06 +00:00
Ryan Macnak bd8ed80309 [standalone, mac] Set the process title based on the main script.
This makes it easier to identify the responsible program when a Dart process has high CPU or memory usage.

TEST=look at Activity Monitor
Change-Id: Ibcdcc1becf72a25dab5b010accdd8dcd199a0ba1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/214137
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-03-03 19:21:13 +00:00
Brian Quinlan cdcc221d60 Remove renegotiate.
TESTED=deprecation does not break unit tests.
Bug: https://github.com/dart-lang/sdk/issues/42771
Change-Id: I5c661ef91285a117c881cb15d26ab40cfd185a70
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/234880
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Brian Quinlan <bquinlan@google.com>
2022-03-02 19:50:50 +00:00
Ben Konyi ee5837aa7a Revert "[ Service ] Update VM service message to not reference Observatory"
This reverts commit f9147d933e.

TEST=N/A

Change-Id: Idef34b70f1066ddf79d02588dfba7caeec443e7f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/234325
Reviewed-by: Dan Field <dnfield@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2022-02-24 18:32:14 +00:00
Alexander Thomas 0c0cd6341d Revert "Reland "Reland "[vm] Add analyze_snapshot tool for AOT snapshot inspection"""
This reverts commit 5d7d8a377d.

Reason for revert: this CL unintentionally included analyze_snapshot in the Dart SDK distribution which is a release blocker.

Original change's description:
> Reland "Reland "[vm] Add analyze_snapshot tool for AOT snapshot inspection""
>
> This is a reland of 8d1eedca64
>
> Disable builds for Fuchsia
>
> TEST=runtime/tests/vm/dart_2/analyze_snapshot_binary_test.dart
> Original change's description:
> > Reland "[vm] Add analyze_snapshot tool for AOT snapshot inspection"
> >
> > This is a reland of 19e5749308
> >
> > TEST=runtime/tests/vm/dart/analyze_snapshot_binary_test.dart
> >
> > Original change's description:
> > > [vm] Add analyze_snapshot tool for AOT snapshot inspection
> > >
> > > Current skeleton to allow for instrumentation snapshots that can be
> > > built alongside Dart compilation artifacts and easily referenced for
> > > specific versions between Snapshot hash <-> DartSDK <-> Flutter Engine
> > >
> > > TEST=runtime/tests/vm/dart/analyze_snapshot_binary_test.dart
> > >
> > > Change-Id: Ie3757a265bbf457506c72fb62a625fea7bedcb68
> > > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/221087
> > > Reviewed-by: Slava Egorov <vegorov@google.com>
> > > Commit-Queue: Slava Egorov <vegorov@google.com>
> >
> > Change-Id: Ia1ea0071d30818440ae48484ff6c406236af5a4e
> > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/224526
> > Reviewed-by: Slava Egorov <vegorov@google.com>
> > Commit-Queue: Slava Egorov <vegorov@google.com>
>
> Change-Id: I769ced4cbe6eb926b8df36a15ca13c3145632082
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/233890
> Reviewed-by: Slava Egorov <vegorov@google.com>
> Commit-Queue: Chris Evans <cmevans@google.com>

# Not skipping CQ checks because original CL landed > 1 day ago.

Change-Id: Ie5b0b6d2f8f792a3bed9134d7d10fb4d34d9a58d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/234284
Reviewed-by: Alexander Thomas <athom@google.com>
Commit-Queue: Alexander Thomas <athom@google.com>
2022-02-24 16:56:23 +00:00
Alexander Markov 211da364be [vm] Experimental ability to spawn isolate from kernel blob in memory
TEST=runtime/tests/vm/dart/spawn_uri_from_kernel_blob_test.dart

Change-Id: Ieb327f0350d5d8ea1d344c64aa3dd217125da5fe
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/232682
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2022-02-23 16:55:52 +00:00
Chris Evans 5d7d8a377d Reland "Reland "[vm] Add analyze_snapshot tool for AOT snapshot inspection""
This is a reland of 8d1eedca64

Disable builds for Fuchsia

TEST=runtime/tests/vm/dart_2/analyze_snapshot_binary_test.dart
Original change's description:
> Reland "[vm] Add analyze_snapshot tool for AOT snapshot inspection"
>
> This is a reland of 19e5749308
>
> TEST=runtime/tests/vm/dart/analyze_snapshot_binary_test.dart
>
> Original change's description:
> > [vm] Add analyze_snapshot tool for AOT snapshot inspection
> >
> > Current skeleton to allow for instrumentation snapshots that can be
> > built alongside Dart compilation artifacts and easily referenced for
> > specific versions between Snapshot hash <-> DartSDK <-> Flutter Engine
> >
> > TEST=runtime/tests/vm/dart/analyze_snapshot_binary_test.dart
> >
> > Change-Id: Ie3757a265bbf457506c72fb62a625fea7bedcb68
> > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/221087
> > Reviewed-by: Slava Egorov <vegorov@google.com>
> > Commit-Queue: Slava Egorov <vegorov@google.com>
>
> Change-Id: Ia1ea0071d30818440ae48484ff6c406236af5a4e
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/224526
> Reviewed-by: Slava Egorov <vegorov@google.com>
> Commit-Queue: Slava Egorov <vegorov@google.com>

Change-Id: I769ced4cbe6eb926b8df36a15ca13c3145632082
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/233890
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Chris Evans <cmevans@google.com>
2022-02-23 12:04:32 +00:00
Alexander Aprelev b29bb7763b [vm/doc] Add a note to CObjectNativePointer class.
Addresses https://github.com/dart-lang/sdk/issues/48379

TEST=not needed, only documentation update

Change-Id: I2d82c6533ef64cd9ff62428e20a2e66013a35e31
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/233642
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2022-02-21 21:54:11 +00:00
Ben Konyi f9147d933e [ Service ] Update VM service message to not reference Observatory
See https://github.com/dart-lang/sdk/issues/46756

TEST=Existing

Change-Id: Ib71bf00d667369d7438a4547ae444951ec0979df
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/233504
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2022-02-18 20:53:52 +00:00
Brian Quinlan 917ae52f70 Add the ability to log TLS keys.
TEST=unit tests
Bug: https://github.com/dart-lang/sdk/issues/47838
Change-Id: I8a64e8623022215cae261eadb25b22deb9f3d910
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/231330
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Brian Quinlan <bquinlan@google.com>
2022-02-17 21:39:31 +00:00
Liam Appelbe 3a3738c6fb Revert "Reland "[vm] Add analyze_snapshot tool for AOT snapshot inspection""
This reverts commit 8d1eedca64.

Reason for revert: Broke the Fuchsia bot: https://github.com/dart-lang/sdk/issues/47950#issuecomment-1040648129

Original change's description:
> Reland "[vm] Add analyze_snapshot tool for AOT snapshot inspection"
>
> This is a reland of 19e5749308
>
> TEST=runtime/tests/vm/dart/analyze_snapshot_binary_test.dart
>
> Original change's description:
> > [vm] Add analyze_snapshot tool for AOT snapshot inspection
> >
> > Current skeleton to allow for instrumentation snapshots that can be
> > built alongside Dart compilation artifacts and easily referenced for
> > specific versions between Snapshot hash <-> DartSDK <-> Flutter Engine
> >
> > TEST=runtime/tests/vm/dart/analyze_snapshot_binary_test.dart
> >
> > Change-Id: Ie3757a265bbf457506c72fb62a625fea7bedcb68
> > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/221087
> > Reviewed-by: Slava Egorov <vegorov@google.com>
> > Commit-Queue: Slava Egorov <vegorov@google.com>
>
> Change-Id: Ia1ea0071d30818440ae48484ff6c406236af5a4e
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/224526
> Reviewed-by: Slava Egorov <vegorov@google.com>
> Commit-Queue: Slava Egorov <vegorov@google.com>

TBR=vegorov@google.com,cmevans@google.com

Change-Id: I1aa0404fa8af9bd31a5c1efbbe7f60d9da2b5b9d
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/233160
Reviewed-by: Liam Appelbe <liama@google.com>
Commit-Queue: Liam Appelbe <liama@google.com>
2022-02-15 18:45:39 +00:00
Chris Evans 8d1eedca64 Reland "[vm] Add analyze_snapshot tool for AOT snapshot inspection"
This is a reland of 19e5749308

TEST=runtime/tests/vm/dart/analyze_snapshot_binary_test.dart

Original change's description:
> [vm] Add analyze_snapshot tool for AOT snapshot inspection
>
> Current skeleton to allow for instrumentation snapshots that can be
> built alongside Dart compilation artifacts and easily referenced for
> specific versions between Snapshot hash <-> DartSDK <-> Flutter Engine
>
> TEST=runtime/tests/vm/dart/analyze_snapshot_binary_test.dart
>
> Change-Id: Ie3757a265bbf457506c72fb62a625fea7bedcb68
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/221087
> Reviewed-by: Slava Egorov <vegorov@google.com>
> Commit-Queue: Slava Egorov <vegorov@google.com>

Change-Id: Ia1ea0071d30818440ae48484ff6c406236af5a4e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/224526
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2022-02-15 10:50:10 +00:00
Martin Kustermann 31ac1d26f9 [vm] Make Isolate.spawnUri() work in AOT iff the uri is compatible AOT snapshot
Right now the implementation of `Isolate.spawnUri(<uri>, ...)` in
the standalone embedder is to ignore `<uri>` and make the spawnned
isolate from the same AOT snapshot as the main isolate.

This is very confusing and very incorrect.

Instead `Isolate.spawnUri()` should work if-and-only-if the given
`<uri>` points to a valid and compatible AOT snapshot. If not, it should
throw an appropriate exception.

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

TEST=vm/dart{,_2}/spawn_uri_aot_test

Change-Id: I279ace08ac1b9a9eed3ae03ebe5d9e2336c1e5c9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/232603
Reviewed-by: Tess Strickland <sstrickl@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2022-02-14 15:18:33 +00:00
Brian Quinlan 98634512f2 Surface errors returned by SSL_read.
TEST=repro in bug & unit test
Bug: https://github.com/dart-lang/sdk/issues/48311
Change-Id: Ib13d0e3c2b98be85533a65532119874ca504f196
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/226607
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Brian Quinlan <bquinlan@google.com>
2022-02-11 02:07:43 +00:00
Ryan Macnak 2829bfdf25 [vm] Avoid repeating parameters from prematurely destructuring Dart_InitializeParams.
TEST=ci
Change-Id: I39288fc4d79c5933d5c8b274c0a66bdd25f6bf29
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/231529
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-02-11 00:55:11 +00:00
Brian Quinlan 085e978ce4 Fix on Windows, renaming a file using the Directory class generates an incorrect exception
TEST=unit
Bug: https://github.com/dart-lang/sdk/issues/47713
Change-Id: I603a452cece478ad5ddd85d47e9cfe02cee3f4d9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/231801
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Brian Quinlan <bquinlan@google.com>
2022-02-07 23:15:56 +00:00
Daco Harkes 045b9c1715 Reland "[vm/ffi] Add common C types"
We're adding these types to `dart:ffi` rather than `package:ffi` so that
they can be used with `FfiNative`s.

Adds `NativeType`s for the following C types:

* unsigned char
* signed char
* short
* unsigned short
* int
* unsigned int
* long
* unsigned long
* long long
* unsigned long long
* uintptr_t
* size_t
* wchar_t

Because the C standard only defines minimum sizes for many of these
types, future platforms might diverge from the typical size even if all
platforms currently agree on a size. To avoid having to reification
later, we define all types as AbiSpecificIntegers rather than typedefs,
even if all current target platforms agree on the size.

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

TEST=tests/ffi/c_types_test.dart

Original patch in patchset 1.

* Removes `Char` for now until package:win32 has rolled to 2.3.8 in
  Flutter. https://pub.dev/packages/win32/versions/2.3.8/changelog
  https://logs.chromium.org/logs/flutter/buildbucket/cr-buildbucket/8824468064587445729/+/u/Android_Views_Integration_Tests/stdout
* Adds `c_type.dart` in `ffi_source.gni` which should fix `IntPtr`
  missing when analyzing `path_provider_linux`. (However, I was unable
  to reproduce the issue locally.)
  https://logs.chromium.org/logs/flutter/buildbucket/cr-buildbucket/8824468064571399025/+/u/run_test.dart_for_flutter_plugins_shard_and_subshard_analyze/test_stdout
  `/tmp/flutter_plugins.KZMNMC/packages/path_provider/path_provider_linux$ ~/flt/engine/src/out/host_debug/dart-sdk/bin/dart  analyze --fatal-infos`

Change-Id: I89130cccba285fc9c483bb53f5710a302f2b104f
Cq-Include-Trybots: luci.dart.try:dart-sdk-linux-try,dart-sdk-mac-try,dart-sdk-win-try,vm-ffi-android-debug-arm64c-try,vm-ffi-android-debug-arm-try,vm-canary-linux-debug-try,vm-fuchsia-release-x64-try,vm-kernel-gcc-linux-try,vm-kernel-asan-linux-release-x64-try,vm-kernel-linux-debug-x64-try,vm-kernel-linux-debug-ia32-try,vm-kernel-mac-debug-x64-try,vm-kernel-mac-release-arm64-try,vm-kernel-nnbd-win-release-ia32-try,vm-kernel-nnbd-win-release-x64-try,vm-precomp-ffi-qemu-linux-release-arm-try,vm-kernel-win-release-x64-try,flutter-analyze-try,flutter-engine-linux-try,flutter-frontend-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/229156
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2022-01-27 13:09:01 +00:00
Ben Konyi 1c571a12fa [ CLI ] Migrate package:dartdev to null safety
Fixes https://github.com/dart-lang/sdk/issues/47964

TEST=CQ

Change-Id: I4ee57bc5739835824b0052bd9470a0d52ccf161b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/229948
Reviewed-by: Devon Carew <devoncarew@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2022-01-26 21:16:49 +00:00
Daco Harkes 5183ba3ca4 Revert "[vm/ffi] Add common C types"
This reverts commit 85a87ca7ae.

Reason for revert: 

* Adding `Char` breaks `package:win32` which is used in Flutter so it
breaks the Flutter build:
https://logs.chromium.org/logs/flutter/buildbucket/cr-buildbucket/8824468064587445729/+/u/Android_Views_Integration_Tests/stdout

For reference: full list of Flutter failues:
https://github.com/flutter/flutter/runs/4890844911

Original change's description:
> [vm/ffi] Add common C types
>
> We're adding these types to `dart:ffi` rather than `package:ffi` so that
> they can be used with `FfiNative`s.
>
> Adds `NativeType`s for the following C types:
>
> * char
> * unsigned char
> * signed char
> * short
> * unsigned short
> * int
> * unsigned int
> * long
> * unsigned long
> * long long
> * unsigned long long
> * uintptr_t
> * size_t
> * wchar_t
>
> Because the C standard only defines minimum sizes for many of these
> types, future platforms might diverge from the typical size even if all
> platforms currently agree on a size. To avoid having to reification
> later, we define all types as AbiSpecificIntegers rather than typedefs,
> even if all current target platforms agree on the size.
>
> Closes: https://github.com/dart-lang/sdk/issues/36140
>
> TEST=tests/ffi/c_types_test.dart
>
> Change-Id: Ie97d253856d787386529231e8060f879069be886
> Cq-Include-Trybots: luci.dart.try:dart-sdk-linux-try,dart-sdk-mac-try,dart-sdk-win-try,vm-ffi-android-debug-arm64c-try,vm-ffi-android-debug-arm-try,vm-canary-linux-debug-try,vm-fuchsia-release-x64-try,vm-kernel-gcc-linux-try,vm-kernel-asan-linux-release-x64-try,vm-kernel-linux-debug-x64-try,vm-kernel-linux-debug-ia32-try,vm-kernel-mac-debug-x64-try,vm-kernel-mac-release-arm64-try,vm-kernel-nnbd-win-release-ia32-try,vm-kernel-nnbd-win-release-x64-try,vm-precomp-ffi-qemu-linux-release-arm-try,vm-kernel-win-release-x64-try
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/228541
> Reviewed-by: Martin Kustermann <kustermann@google.com>

# Not skipping CQ checks because original CL landed > 1 day ago.

Change-Id: Ic56df88c653b1395ed5e5a71af5e571b1adc3671
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/229152
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2022-01-21 17:05:42 +00:00
Daco Harkes 85a87ca7ae [vm/ffi] Add common C types
We're adding these types to `dart:ffi` rather than `package:ffi` so that
they can be used with `FfiNative`s.

Adds `NativeType`s for the following C types:

* char
* unsigned char
* signed char
* short
* unsigned short
* int
* unsigned int
* long
* unsigned long
* long long
* unsigned long long
* uintptr_t
* size_t
* wchar_t

Because the C standard only defines minimum sizes for many of these
types, future platforms might diverge from the typical size even if all
platforms currently agree on a size. To avoid having to reification
later, we define all types as AbiSpecificIntegers rather than typedefs,
even if all current target platforms agree on the size.

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

TEST=tests/ffi/c_types_test.dart

Change-Id: Ie97d253856d787386529231e8060f879069be886
Cq-Include-Trybots: luci.dart.try:dart-sdk-linux-try,dart-sdk-mac-try,dart-sdk-win-try,vm-ffi-android-debug-arm64c-try,vm-ffi-android-debug-arm-try,vm-canary-linux-debug-try,vm-fuchsia-release-x64-try,vm-kernel-gcc-linux-try,vm-kernel-asan-linux-release-x64-try,vm-kernel-linux-debug-x64-try,vm-kernel-linux-debug-ia32-try,vm-kernel-mac-debug-x64-try,vm-kernel-mac-release-arm64-try,vm-kernel-nnbd-win-release-ia32-try,vm-kernel-nnbd-win-release-x64-try,vm-precomp-ffi-qemu-linux-release-arm-try,vm-kernel-win-release-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/228541
Reviewed-by: Martin Kustermann <kustermann@google.com>
2022-01-20 14:41:46 +00:00
Ryan Macnak 04ba20aa98 [vm] Support RISC-V.
Implements a backend targeting RV32GC and RV64GC, based on Linux standardizing around GC. The assembler is written to make it easy to disable usage of C, but because the sizes of some instruction sequences are compile-time constants, an additional build configuration would need to be defined to make use of it.

The assembler and disassembler cover every RV32/64GC instruction. The simulator covers all instructions except accessing CSRs and the floating point state accessible through such, include accrued exceptions and dynamic rounding mode.

Quirks:
  - RISC-V is a compare-and-branch architecture, but some existing "architecture-independent" parts of the Dart compiler assume a condition code architecture. To avoid rewriting these parts, we use a peephole in the assembler to map to compare-and-branch. See Assembler::BranchIf. Luckily nothing depended on taking multiple branches on the same condition code set.
  - There are no hardware overflow checks, so we must use Hacker's Delight style software checks. Often these are very cheap: if the sign of one operand is known, a single branch is needed.
  - The ranges of RISC-V branches and jumps are such that we use 3 levels of generation for forward branches, instead of the 2 levels of near and far branches used on ARM[64]. Nearly all code is handled by the first two levels with 20-bits of range, with enormous regex matchers triggering the third level that uses aupic+jalr to get 32-bits of range.
  - For PC-relative calls in AOT, we always generate auipc+jalr pairs with 32-bits of range, so we never generate trampolines.
  - Only a subset of registers are available in some compressed instructions, so we assign the most popular uses to these registers. In particular, THR, TMP[2], CODE and PP. This has the effect of assigning CODE and PP to volatile registers in the C calling convention, whereas they are assigned preserved registers on the other architectures. As on ARM64, PP is untagged; this is so short indices can be accessed with a compressed instruction.
  - There are no push or pop instructions, so combining pushes and pops is preferred so we can update SP once.
  - The C calling convention has a strongly aligned stack, but unlike on ARM64 we don't need to use an alternate stack pointer. The author ensured language was added to the RISC-V psABI making the OS responsible for realigning the stack pointer for signal handlers, allowing Dart to leave the stack pointer misaligned from the C calling convention's point of view until a foreign call.
  - We don't bother with the link register tracking done on ARM[64]. Instead we make use of an alternate link register to avoid inline spilling in the write barrier.

Unimplemented:
 - non-trivial FFI cases
 - Compressed pointers - No intention to implement.
 - Unboxed SIMD - We might make use of the V extension registers when the V extension is ratified.
 - BigInt intrinsics

TEST=existing tests for IL level, new tests for assembler/disassembler/simulator
Bug: https://github.com/dart-lang/sdk/issues/38587
Bug: https://github.com/dart-lang/sdk/issues/48164
Change-Id: I991d1df4be5bf55efec5371b767b332d37dfa3e0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/217289
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-01-20 00:57:57 +00:00
Ryan Macnak 4088cd083d [vm] Add missing Dart_ThreadStartCallback.
For symmetry with Dart_ThreadExitCallback. Can be used by an embedder to change thread priority or attach native resources to the thread.

TEST=ci
Change-Id: Ic8eaba7204d0be42db26523b62cbfac3ecb7151f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/227661
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-01-19 23:14:36 +00:00
Alexander Aprelev cb64a64241 [vm/isolate_exit] Ensure ffi code exits if isolate is exiting.
When ffi code calls Dart code that requests the isolate to exit(via Isolate.exit, for example), we ensure that isolate indeed exits on return from ffi call.
This is implemented by introduction of new safepoint bit which, once set, forces ExitSafepoint to propagate unwind error.

TEST=isolate_exit_sandwich_test

Change-Id: I2e8f5ecec7f4e59ae5f99b9525cc566f20d4b6a8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/219846
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2022-01-08 06:01:08 +00:00
Alexander Aprelev eb4eade02a [vm/gen_snapshot] Avoid redundant compilation when generating kernel snapshot.
Fixes https://github.com/dart-lang/sdk/issues/39580
TEST=ci

Change-Id: I98e7201350433754c9ff1746e1d6e24b7107099e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/225740
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2022-01-05 17:51:26 +00:00
Ben Konyi dc0b571335 [ VM / CLI ] Remove service flags from VM and the CLI when building in
PRODUCT mode

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

TEST=Manual testing, CQ

Change-Id: I50e57fa653c45c892e748d4e283617200cee0c0a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/224860
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2022-01-04 19:53:11 +00:00
Ivan Inozemtsev bbde6ba9b3 Do not declare __asan_default_options if GOOGLE3 is defined.
This allows to build VM with ASAN internally.

TEST=ci
Change-Id: I56eddb38952ba5ccb97426d83c6388790a9954ba
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/224942
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Ivan Inozemtsev <iinozemtsev@google.com>
2021-12-24 06:44:34 +00:00
Daco Harkes acdf82de17 [vm/ffi] ABI-specific integers
This CL adds support for users defining integers which are mapped to
differing sizes and signedness based on the application binary interface
the Dart VM is running on.

Notable implementation design decisions:
- ABIs are open world, so that adding an ABI to the Dart VM does not
  break existing definitions. Thus, we only figure out in the VM that
  we're missing a mapping. We throw compile-time errors.
  - In AOT, these show up in the precompilation step.
  - In JIT, these show up as `_CompileTimeError` at runtime. Note that
    these can be caught. So in subsequent compilation steps we need to
    ensure that we also throw the same compile-time error.
- We match on the call-sites (streaming_flowgraph_builder) rather than
  method bodies (kernel_to_il) of AbiSpecific loads and stores so that
  we can compile for the int-size of the call site.

API design decisions:
https://github.com/dart-lang/sdk/issues/42563#issuecomment-981774001

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

TEST=tests/ffi_2/abi_*_test.dart
TEST=tests/ffi/function_*_generated_test.dart
TEST=tests/ffi/vmspecific_static_checks_test.dart
Change-Id: I8c8df36fab939b6fb614c5f1ee8e1bf46b6e9521
Cq-Include-Trybots: luci.dart.try:analyzer-linux-release-try,analyzer-nnbd-linux-release-try,app-kernel-linux-debug-x64-try,benchmark-linux-try,dart-sdk-linux-try,front-end-linux-release-x64-try,front-end-nnbd-linux-release-x64-try,pkg-linux-debug-try,vm-canary-linux-debug-try,vm-ffi-android-debug-arm-try,vm-ffi-android-debug-arm64c-try,vm-fuchsia-release-x64-try,vm-kernel-checked-linux-release-x64-try,vm-kernel-gcc-linux-try,vm-kernel-linux-debug-x64c-try,vm-kernel-mac-debug-x64-try,vm-kernel-asan-linux-release-x64-try,vm-kernel-msan-linux-release-x64-try,vm-kernel-nnbd-linux-debug-ia32-try,vm-kernel-nnbd-win-debug-x64-try,vm-kernel-nnbd-win-release-ia32-try,vm-kernel-nnbd-linux-debug-x64-try,vm-kernel-precomp-asan-linux-release-x64-try,vm-kernel-precomp-android-release-arm_x64-try,vm-kernel-precomp-android-release-arm64c-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-win-debug-x64c-try,vm-kernel-reload-linux-debug-x64-try,vm-kernel-reload-rollback-linux-debug-x64-try,vm-kernel-win-debug-ia32-try,vm-kernel-win-debug-x64-try,vm-precomp-ffi-qemu-linux-release-arm-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/221501
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2021-12-16 22:07:00 +00:00
Alexander Markov b80e682cbf [vm] Introduce --target-unknown-cpu option and use it for app-jit snapshots
App-jit and core-jit snapshots generated on one machine can be copied to
another machine with different CPU family/model, so it is incorrect to
use CPU features of the host machine to generate code for snapshots.

This change adds --target-unknown-cpu option and enables it when
generating app-jit and core-jit snapshots in standalone Dart VM and
gen_snapshot.

Currently, this flag disables SSE4.1, popcnt and ABM on ia32 and x64,
and integer division instruction on ARM. Also, new flag enables
testing of roundsd instruction availability at run time on x64
(similarly to AOT).

TEST=ci
Fixes https://github.com/dart-lang/sdk/issues/47907
Fixes https://github.com/flutter/flutter/issues/94181

Change-Id: Id28448052a21df4bae30b39e62b8532e55d4c901
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/223960
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2021-12-16 21:33:49 +00:00
Ben Konyi 3657251778 Revert "[vm] Add analyze_snapshot tool for AOT snapshot inspection"
This reverts commit 19e5749308.

Reason for revert: Multiple configurations failing (https://github.com/dart-lang/sdk/issues/47950)

Original change's description:
> [vm] Add analyze_snapshot tool for AOT snapshot inspection
>
> Current skeleton to allow for instrumentation snapshots that can be
> built alongside Dart compilation artifacts and easily referenced for
> specific versions between Snapshot hash <-> DartSDK <-> Flutter Engine
>
> TEST=runtime/tests/vm/dart/analyze_snapshot_binary_test.dart
>
> Change-Id: Ie3757a265bbf457506c72fb62a625fea7bedcb68
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/221087
> Reviewed-by: Slava Egorov <vegorov@google.com>
> Commit-Queue: Slava Egorov <vegorov@google.com>

TBR=vegorov@google.com,cmevans@google.com

Change-Id: Iaaeeeba04ac3283d2df3db8155389db2b358b60a
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/224601
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2021-12-16 18:32:20 +00:00
Chris Evans 19e5749308 [vm] Add analyze_snapshot tool for AOT snapshot inspection
Current skeleton to allow for instrumentation snapshots that can be
built alongside Dart compilation artifacts and easily referenced for
specific versions between Snapshot hash <-> DartSDK <-> Flutter Engine

TEST=runtime/tests/vm/dart/analyze_snapshot_binary_test.dart

Change-Id: Ie3757a265bbf457506c72fb62a625fea7bedcb68
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/221087
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2021-12-16 15:21:14 +00:00
Ryan Macnak 4b2309c15a [standalone] Fix reuse of va_list in syslog_android.cc.
Also add some missing va_end.

TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/47939
Change-Id: Iadfbf72493d987dfb1d102922db1b353249a4728
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/224240
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2021-12-15 22:22:36 +00:00
Liam Appelbe ac7bca37a8 [vm] Add an isolate group flag for branch coverage.
Branch coverage can't be enabled by a simple global flag, because this
causes problems when functions in an app-jit snapshot that didn't have
the flag enabled are compiled by a VM that has the flag enabled. In
particular, the coverage array will see a different set of token
positions, causing some important asserts to fail.

Change-Id: I35227252b5d271f20b01de99466c06708ec83ed8
TEST=CI
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/223360
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Liam Appelbe <liama@google.com>
2021-12-14 22:53:36 +00:00
Mo 8caaa1b9cf Added sourcePort to Socket.connect()/startConnect() as optional parameter.
This allows to specify the local port for TCP client sockets.

All prototypes in Socket,RawSocket,_Rawsocket,_NativeSocket have been adopted,
aswell as the native counterpart to nativeCreateBindConnect.

TEST=new tests added

Change-Id: I3408b687cbfd7eaaaeafdda29f7093d92c92aea0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/217604
Reviewed-by: Siva Annamalai <asiva@google.com>
Auto-Submit: Moritz Feldmann <moritz.feldmann@kabelmail.de>
Reviewed-by: Kevin Moore <kevmoo@google.com>
Commit-Queue: Kevin Moore <kevmoo@google.com>
2021-12-08 18:33:00 +00:00
Clement Skau cb33212b18 [vm] Elaborate on DartDev missing error.
This change refactors CreateAndSetupDartDevIsolate slightly to
exit as soon as we know we cannot resolve DartDev.
Expands on the error message to be a bit more informative about
what went wrong.

Before:
  Failed to start the Dart CLI isolate
  (null).
  Observatory server failed to start after 1 tries
  [...]

After:
  Failed to start the Dart CLI isolate. Could not resolve DartDev snapshot or kernel.
  [...]

TEST=CQ

Change-Id: Iad3302dc4e64eef06b97c8b76a82b04c97a7089e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/220546
Commit-Queue: Clement Skau <cskau@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2021-11-18 06:56:57 +00:00
Ryan Macnak dc3cf83bb6 [vm] Allow the embedder to provide a task runner in lieu of the VM's thread pool.
This allows the embedder to control the degree of parallelism and thread priorities.

TEST=engine
Bug: https://github.com/dart-lang/sdk/issues/44228
Change-Id: I4e8430749fcfbcbfc221c3733ee27ccbe6bcc1ae
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/215941
Reviewed-by: Kaushik Iska <kaushikiska@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2021-11-18 00:54:20 +00:00
Brian Quinlan 0e5f3f49c3 Fix an issue where rename on Windows would delete the target directory.
TEST=tests updated
Bug: https://github.com/dart-lang/sdk/issues/35217, https://github.com/dart-lang/sdk/issues/47633, https://github.com/dart-lang/sdk/issues/47634
Change-Id: I9582c76e8eb75548ba2d67205353de63d110c294
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/219501
Commit-Queue: Brian Quinlan <bquinlan@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2021-11-17 19:41:50 +00:00
Martin Kustermann 8a6e38832f [vm] Fix standalone{,_2}/io/platform_test & incorrect error handling in VM
This fixes failures of standalone{,_2}/io/platform_test in AOT / AppJIT modes
(and removes old status file markers which are ignored by approval system).

It also fixes a Crash in vm/dart{,_2}/spawn_shutdown_test - where error
handling was not correctly done - a `Dart_ExitScope()` was missing
before a return.

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

TEST=standalone{,_2}/io/platform_test & vm/dart{,_2}/spawn_shutdown_test

Change-Id: Ic4a8bcaa243c514b11f5127d77ec77259d60ca68
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/219520
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2021-11-05 17:48:49 +00:00
Ryan Macnak 2165f02867 [standalone] Inform the VM when snapshots are safe to use with madvise(DONTNEED).
TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/44019
Change-Id: Ib717ff2123b537787929cf591e0cef7149e5292e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/218064
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2021-11-04 17:23:33 +00:00
Ryan Macnak 778242fdb6 [vm, compiler] Remove --fields_may_be_reset.
This is true everywhere by default. It can only be false when isolate groups are disabled, and the ability to disable isolate groups will be removed.

TEST=ci
Change-Id: I8ce12883a6128a6c6c1883605b5e3889952ce76c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/217153
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2021-11-01 17:41:41 +00:00
Brian Quinlan 5e990591b9 Fix a bug where windows would not currently follow symlinks in stat() calls.
Also clarify documentation.

TEST=Updated tests to cover stats() calls on symlinks.
Bug: https://github.com/dart-lang/sdk/issues/20389
Change-Id: I8555bacc2f83cad024ad8ef7c2f23aa97069ed2e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/218671
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Brian Quinlan <bquinlan@google.com>
2021-11-01 16:33:01 +00:00
Brian Quinlan d1d2adb5dc Fix a bug where setAccessTime would also set the modified time on Windows.
TEST=issue_35112_test.dart
Bug: https://github.com/dart-lang/sdk/issues/35112
Change-Id: I4c7a1795250447888ec1cbde71bf2799c3467b55
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/218182
Commit-Queue: Brian Quinlan <bquinlan@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2021-10-29 18:19:49 +00:00
Ben Konyi 4de9e805ed [ CLI ] Don't resolve paths as URIs for known SDK artifacts
Handles cases where the SDK is installed on a path which includes
percent encoded characters. The OS doesn't decode these characters, so
decoding them before trying to load a snapshot with said characters in
their path will result in files not being found.

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

TEST=pkg/dartdev/test/regress_46364_test.dart

Change-Id: I5f78e8a2049cc0c83555528fcc8f41be946141f5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/218082
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2021-10-27 16:34:00 +00:00
Ian McKellar c46baff9c9 Fix a use-after free in Fuchsia process launching
The fdio_flat_namespace_t returned by fdio_ns_export holds memory for
the paths of the prefixes. If this is freed then the fdio_spawn_action_t
entries point to freed memory.

Now we explicitly copy the prefix path strings and move the handles out.

TEST=internal testing

Change-Id: If8e1e0ded86003a618610a98dd571826a6ca40c9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/218087
Reviewed-by: Zach Anderson <zra@google.com>
Commit-Queue: Zach Anderson <zra@google.com>
Auto-Submit: Ian McKellar <ianloic@google.com>
2021-10-26 22:53:41 +00:00
Brian Quinlan f1af54b3b0 Fix a bug where an abort would occur if the sourceAddress did not match the host address type.
TEST=socket_source_address_test.dart

Bug: 47447
Change-Id: I7e70393c0edb4c5d51edcafe2568f95f8ceb85c2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/217448
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Brian Quinlan <bquinlan@google.com>
2021-10-20 22:18:25 +00:00
Ahmed Ashour d041cf0478 Remove extra the, be and of
Fixes #https://github.com/dart-lang/sdk/issues/47504

TEST=No tests needed, only comments affected.

Change-Id: Ie096307b5ce314d328fea6780f396aaa226ad3b0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/216182
Reviewed-by: Lasse R.H. Nielsen <lrn@google.com>
Commit-Queue: Lasse R.H. Nielsen <lrn@google.com>
2021-10-20 09:29:01 +00:00
Brian Quinlan 8462f1da74 Fix a bug where Platform.operatingSystemVersion was incorrect in the iOS
simulator.

Also changes the MacOS implementation of that property.

TEST=platform_os_version_test.dart

Bug: 47138
Change-Id: I9134845a216423c8a383b804986af1ebb3c8d3d9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/214863
Commit-Queue: Brian Quinlan <bquinlan@google.com>
Reviewed-by: Chinmay Garde <chinmaygarde@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2021-10-19 21:25:43 +00:00
David Benjamin 3d73ae1c22 Replace old M_ASN1_* macros with their functions
M_ASN1_* is an old quirk from a very very old OpenSSL. They're just
wrappers over identically-named functions at this point.

Bug: none
TEST=ci
Change-Id: I1a204d6c1cca62861d7f11bf3c7adfa24bd47e59
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/217040
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
Auto-Submit: David Benjamin <davidben@google.com>
2021-10-18 14:48:39 +00:00
Daco Harkes 757c2b82ce [vm/ffi] Add Bool
This CL adds the `Bool` `NativeType` with support for loading/storing
from `Pointer<Bool>`, `Array<Bool>`, and `Struct` and `Union` fields,
and support for passing booleans through FFI calls and callbacks.

The assumption is that `bool` is always treated as `uint8_t` in the
native ABIs. Including: (1) whether there can be garbage in the upper
bytes in CPU registers, (2) stack alignment, and (3) alignment in
compounds.

The conversion from `bool` to `uint8_t` is implemented as follows:
- bool to int: `value ? 1 : 0`
- int to bool: `value != 0`
The conversion is implemented in Dart in patch files for memory loads
and stores (pointer, array, and struct fields) and kernel_to_il for
FFI call and callback arguments and return value.

TEST=runtime/vm/compiler/ffi/native_type_vm_test.cc
TEST=tests/ffi/bool_test.dart
TEST=tests/ffi/function_callbacks_structs_by_value_generated_test.dart
TEST=tests/ffi/function_structs_by_value_generated_test.dart

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

Change-Id: I75d100340ba41771abfb41c598ca92066a89370b
Cq-Include-Trybots: luci.dart.try:vm-kernel-linux-debug-x64-try,vm-ffi-android-debug-arm-try,vm-kernel-mac-debug-x64-try,vm-kernel-nnbd-linux-debug-x64-try,vm-kernel-linux-debug-ia32-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-win-debug-x64-try,vm-kernel-win-debug-ia32-try,vm-ffi-android-debug-arm64c-try,vm-kernel-mac-release-arm64-try,vm-precomp-ffi-qemu-linux-release-arm-try,vm-kernel-precomp-android-release-arm64c-try,vm-kernel-precomp-android-release-arm_x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/216900
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Clement Skau <cskau@google.com>
2021-10-18 10:44:11 +00:00
Daco Harkes e512402b05 [test/ffi] Make the test generator async
The `dart format` step takes 8 seconds currently on the large files.
This cuts down the total time from 21 seconds to 9 on my machine.

TEST=This only changes the test generator, nothing should change.

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

Change-Id: Ie4940fdd3a43a923ca28cb39b0673cc19f81a10a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/216664
Auto-Submit: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Clement Skau <cskau@google.com>
2021-10-14 13:05:33 +00:00
Ryan Macnak b4b7b8f116 [build] Add support for building for Fuchsia from Mac.
TEST=./tools/build.py --os=fuchsia --mode=all runtime create_sdk
Change-Id: I6b15d1cc174b84d900d526730e5f58d64d2596cb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/216540
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Liam Appelbe <liama@google.com>
2021-10-13 21:14:56 +00:00
Clement Skau 998d5f5a9b [vm/ffi] Adds FFI transform FfiNative instance methods.
- Allows FfiNative annotation to be attached to non-static
  methods of classes.
- Transforms non-static instance methods to static, adding
  wrappers with the receiver as an extra, implicit first paramters.
- Transform all parameters and arguments to Pointer if the object
  being passed supports it (i.e. extends NativeFieldWrapperClass1).
- Adds compile time errors for cases where the FfiNative annotation
  doesn't align with the annotated function. Taking into account
  implicit receivers and converted Pointers.
- Adds complimentary Analyzer checks for the above errors as well.
- Adds tests for the transforms, compile time errors and analyzer
  changes.

TEST=Adds new tests for instance methods, analyzer changes.

Change-Id: Idf54430acf2728a650008333b149b254941290ad
Cq-Do-Not-Cancel-Tryjobs: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/213773
Commit-Queue: Clement Skau <cskau@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
2021-10-12 10:58:44 +00:00
Alexander Aprelev 669073094d [io/domain_sockets] Ensure OSError is released in case Dart_ThrowException reports an error.
Fixes https://github.com/dart-lang/sdk/issues/47428.

Also truncate buffer only if allocated buffer is larger than number of bytes received.

TEST=unix_socket_test on asan

Change-Id: I4d707d3bec48a33f900bca002f09f70e017597e4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/216261
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2021-10-11 22:49:53 +00:00
Alexander Aprelev 935ee25f3b [io/unix_domain_socket] Add support for sending/receiving open files, sockets, std streams via sockets.
This adds [sendMessage] and [receiveMessage] methods to [RawSocket] class. They are only supported on Linux at the moment as they require connection opened as unix domain socket connection.

This introduces [SocketControlMessage] class that represents a message sent via socket and also introduces [ResourceHandle] class that wraps [RandomAccessFile], [Socket]/[RawSocket]/[RawDatagramSocket], [Stdin]/[Stdout] for
marshalling/unmarshalling purposes.

Underlying OS implementation supports various kinds of control messages that can be passed via sockets, this CL only adds support for sending/receiving opened file description handles.
When receiving a message recipient can attempt to extract handles out of it via [tryExtractHandles]. It returns [null] if message has no handles to extract.

This is continuation of the work started on https://dart-review.googlesource.com/c/sdk/+/205067.

Bug: https://github.com/dart-lang/sdk/issues/46328
TEST=unix_socket_test

Change-Id: Ic9125b51dc80b677452e454366bae4118c298081
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/212036
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Lasse R.H. Nielsen <lrn@google.com>
Reviewed-by: Zach Anderson <zra@google.com>
2021-10-08 15:46:23 +00:00
Brian Quinlan de45656da1 Fix a bug where calling _WindowsCodePageEncoder.convert would call an abort on non-Windows platforms.
TEST=issue_4636_test.dart

Bug: 46436,47402
Change-Id: I11579428f1d3c791ed64b7d5e6f75f41aef8c6c8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/215981
Commit-Queue: Brian Quinlan <bquinlan@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2021-10-08 00:22:12 +00:00
Alexander Aprelev 7c5b019fdf [build] Fix zero-build of few common targets on Windows.
Fixes https://github.com/dart-lang/sdk/issues/47392

TEST=zero-build on windows

Change-Id: I2b37b48b7acc8c5139e989159250c361317e4ea5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/215940
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2021-10-07 16:23:42 +00:00
Brian Quinlan bb407edfa0 Revert "Fix a bug where calling _WindowsCodePageEncoder.convert would call an abort on non-Windows platforms."
This reverts commit bfbf75a1f6.

Reason for revert: Broken some tests e.g. dartkp-strong-linux-release-x64:standalone/io/issue_46436_test

Original change's description:
> Fix a bug where calling _WindowsCodePageEncoder.convert would call an abort on non-Windows platforms.
>
> TEST=issue_4636_test.dart
>
> Bug: 46436
> Change-Id: Ib48673d3339617ca2944b3a1f7af4a3b298bb5ba
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/215801
> Commit-Queue: Brian Quinlan <bquinlan@google.com>
> Reviewed-by: Alexander Aprelev <aam@google.com>

TBR=aam@google.com,bquinlan@google.com

Change-Id: I720d9e38e48013438bd9c4821f05e95fa484cfd4
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 46436
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/215962
Reviewed-by: Brian Quinlan <bquinlan@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Brian Quinlan <bquinlan@google.com>
2021-10-07 16:17:04 +00:00
Brian Quinlan bfbf75a1f6 Fix a bug where calling _WindowsCodePageEncoder.convert would call an abort on non-Windows platforms.
TEST=issue_4636_test.dart

Bug: 46436
Change-Id: Ib48673d3339617ca2944b3a1f7af4a3b298bb5ba
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/215801
Commit-Queue: Brian Quinlan <bquinlan@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2021-10-06 22:35:52 +00:00
Ryan Macnak 88d7f53359 [standalone] Truncate names passed to pthread_setname_np.
pthread_setname_np ignores names that are too long rather than truncating. This was causing most dart:io threads to remain unnamed.

Cf. eec49f34c4.

TEST="thread info" in gdb
Change-Id: I12f47b06b81f1204f742d829e14784d792a4fb96
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/215800
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2021-10-06 17:46:29 +00:00
Loganaden Velvindron 8062c4cc67 Switch to TLS 1.2 as minimum requirement
According to https://tools.ietf.org/id/draft-ietf-tls-oldversions-deprecate-06.txt

TEST=Not applicable, config change.

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

GitOrigin-RevId: e1dc037c1e22996b2085e3d16427525c033bdc01
Change-Id: Ic8340eee7fa26846302727672ca7989ce1e93c99
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/140481
Commit-Queue: Michael Thomsen <mit@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2021-10-04 09:51:38 +00:00
Ben Konyi fc4ab33fc1 [ CLI ] Shutdown DartDev isolate properly when error condition encountered
Fixes https://github.com/dart-lang/sdk/issues/45771

TEST=CQ

Change-Id: Id0d706c9c28383fe0395eee5bbe8eeb06a8aed46
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/214343
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2021-09-29 14:41:50 +00:00
Clement Skau b012bf3f3e [vm/ffi/test] Fixes vmspecific_ffi_native_test.
Remove the static shared resource as it caused race conditions with
multiple instances of ClassWithNativeField.
Instead introduces allocatable resources which we have more control
over, but can otherwise be used in a similar fashion.

TEST=Updated existing test.

Bug: https://github.com/dart-lang/sdk/issues/47224
Fixes: https://github.com/dart-lang/sdk/issues/47224
Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-product-x64-try,vm-kernel-precomp-asan-linux-release-x64-try,vm-kernel-precomp-msan-linux-release-x64-try,vm-kernel-precomp-tsan-linux-release-x64-try,vm-kernel-precomp-ubsan-linux-release-x64-try,vm-precomp-ffi-qemu-linux-release-arm-try
Change-Id: I98dbf6ba85982392af7ce754d5b8d8fdb97f4d7e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/214600
Commit-Queue: Clement Skau <cskau@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
2021-09-29 13:52:41 +00:00
Ben Konyi 123950ffa9 [ CLI / VM ] Add support for disabling DDS
Allows for tooling (e.g., DAP) to spawn their own DDS instance without
having to disable the CLI.

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

TEST=pkg/dartdev/test/commands/run_test.dart

Change-Id: Ie9a4832d424edae67f32560399d3b0a6ca9f1dc0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/213660
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2021-09-16 20:31:45 +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
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
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
Ryan Macnak 70e3178215 [standalone] Set the process title based on the main script.
This makes it easier to identify the responsible program when a Dart process has high CPU or memory usage.

TEST=look at top
Change-Id: I0bf9e2f5c81aa82a4721b177b8db2bb6bf3fb002
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/211303
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2021-08-31 19:33:10 +00:00
Ryan Macnak be9bb43ceb [standalone] Don't sort classes in isolates loaded from app snapshots.
Sorting classes causes all generated code to be discarded because it may invalidate embedded CIDs. For the kernel-service in particular, this results in a significant slowdown. These classes were already sorted when the snapshot was generated.

TEST=ci
Change-Id: Ice443718ec43ead88e69039a7c723856f4fd448c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/211882
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2021-08-30 20:26:57 +00:00
asiva 06a471ce86 [VM/Runtime] - Return error instead of a FATAL error when failing to
communicate with the kernel isolate while accepting compilation results
during a hot reload.

TEST=reload bot tests.

Change-Id: I55f983cc8461c89e91bf1bef84f39dcda61e8142
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/210942
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
2021-08-27 20:49:39 +00:00
asiva bc387837c4 [VM/Runtime] Reland : Fix 'File' object leak in async file open operation
The 'File' object created in the async file open method is leaked
if the operation is not completed when the isolate shuts down
with an unhandled exception.
This change adds a finalizable state for the 'File' object so that
the message deletion that happens when ports are closed could run
the callback to clean up the 'File' object.


TEST=new tests added

Change-Id: I64c18a7905261b0fc7bf9f220086791478232d0d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/211340
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
2021-08-27 17:45:17 +00:00
Alexander Aprelev aa0a4410f4 [vm/certs/win] When adding root certificates consider not_before and not_after properties, only add valid ones.
boringssl seems to be confused when expired certificates are present in trusted root, only picks up the first matching one which could be expired and ignores still-valid-ones.

TEST=secure_socket_utils_test

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

Change-Id: I5bbc0a1a3331ce4dcda46eee41b02b5b6e835b2a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/211160
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2021-08-26 15:34:48 +00:00
William Hesse 637e14006c Revert "[VM/Runtime] Fix 'File' object leak in async file open operation"
This reverts commit b67f45f955.

Reason for revert: This seems to cause a crash on ARMv7 aot compiled code.

Original change's description:
> [VM/Runtime] Fix 'File' object leak in async file open operation
>
> The 'File' object created in the async file open method is leaked
> if the operation is not completed when the isolate shuts down
> with an unhandled exception.
> This change adds a finalizable state for the 'File' object so that
> the message deletion that happens when ports are closed could run
> the callback to clean up the 'File' object.
>
> TEST=new tests added
>
> Change-Id: I4a3cb28370d27306c795c1914aeb5c18a1d85e2b
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/210761
> Reviewed-by: Alexander Aprelev <aam@google.com>
> Commit-Queue: Siva Annamalai <asiva@google.com>

TBR=aam@google.com,rmacnak@google.com,asiva@google.com

Change-Id: Ie91aadd318ef19a0bb4d7f769c9e876e76d719d8
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/211021
Reviewed-by: William Hesse <whesse@google.com>
Commit-Queue: William Hesse <whesse@google.com>
2021-08-24 12:49:23 +00:00
asiva b67f45f955 [VM/Runtime] Fix 'File' object leak in async file open operation
The 'File' object created in the async file open method is leaked
if the operation is not completed when the isolate shuts down
with an unhandled exception.
This change adds a finalizable state for the 'File' object so that
the message deletion that happens when ports are closed could run
the callback to clean up the 'File' object.

TEST=new tests added

Change-Id: I4a3cb28370d27306c795c1914aeb5c18a1d85e2b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/210761
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
2021-08-23 20:57:48 +00:00
Ben Konyi d2855e703e [ CLI ] Default to printing CLI usage message instead of VM usage
--disable-dart-dev disables this behavior.

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

TEST=pkg/dartdev/test/commands/flag_test.dart

Change-Id: I46b91abc89fc3ec5e06fa7e9aad3939573cff545
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/209264
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2021-08-13 23:01:51 +00:00
asiva 1f405bf163 [VM/Runtime] Added a Dart VM initialization state to prevent racy access
to VM state from Dart API calls.

The state is used to protect the following Dart API calls that exhibit
racy behavior
- Dart_Timeline calls (see
  https://github.com/dart-lang/sdk/issues/44814,
  https://github.com/flutter/flutter/issues/74134)
- Dart Native port creation calls
- Dart VM service invocation call

TEST=new C++ api test have been added.

Change-Id: I26f6cff254366e13daff138041037696b3429f69
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/209761
Commit-Queue: Siva Annamalai <asiva@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2021-08-13 18:25:31 +00:00
Robert Ancell fb861597e4 Remove workaround for MSAN bug.
This was fixed in MSAN in March 2020.

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

TEST=vm-kernel-msan-linux-release-x64-try

GitOrigin-RevId: 8cb1476c774182181776598d2cc6668fd7435897
Change-Id: I583ccb4782a0f3d6b63ee34b856aa646c6b3f27f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/205637
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2021-08-13 09:51:21 +00:00
asiva b2b8e59b28 [VM/Runtime] Fix racy closing of sockets between the finalizers/event
handler

Sockets could be closed from multiple threads (finalizers run during
isolate shutdown and the event handler thread). This leads to potential
racy behavior.
(See https://github.com/dart-lang/sdk/issues/45641)

TEST=ci

Change-Id: I87900117a4194a71433680f68ed9b6dd31977403
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/209849
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
2021-08-13 01:08:51 +00:00
Ryan Macnak 5cec85d5ce [standalone] Remove use of dart::VirtualMemory from the standalone embedder.
Fixes the standalone embedder's ELF loader using the VM's compressed heap after Dart_Cleanup.

This removes the last non-test layering violation of runtime/bin files including runtime/vm files.

TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/46810
Bug: https://github.com/dart-lang/sdk/issues/46880
Change-Id: I6c430ae61c057016f7cd56188879a9ccb3699d30
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/209847
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2021-08-12 21:30:10 +00:00
David Benjamin e8e0a39464 Estimate the overhead of an X509 object without sizeof
To unblock optimizations in hopes of reducing the overhead, we're
planning to make X509 opaque in BoringSSL. This aligns with upstream
OpenSSL, which has made most of these structs opaque.

Instead, use an estimate. The sizeof-based estimate was undercounting
the overhead anyway because there are many structures underneath X509,
some of which are already opaque. I just rounded sizeof(X509) +
sizeof(X509_CINF) up.

(Even this is likely still undercounting it because X509 objects are
very malloc-heavy and duplicate large chunks of the certificate. They're
not a very efficient representation and can't be made efficient without
first hiding the structs. In Chrome, we stopped using them altogether
and just retain the byte string, parsing as needed.)

TEST=ci

Change-Id: Icdc729ceba7eadf002bec5e080fc3e0adf7c4b56
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/209920
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
Auto-Submit: David Benjamin <davidben@google.com>
2021-08-11 16:41:41 +00:00
Ben Konyi cccc0293c5 [ VM ] Send 'dart --help [--verbose]' output to stdout
This is consistent with the majority of other tools and the CLI
behavior.

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

TEST=pkg/dartdev/test/commands/flag_test.dart

Change-Id: I45a3ddc9728e9cc1a273d4d5f11db74cb8104745
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/204661
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2021-08-06 16:06:05 +00:00
Ben Konyi 3b1e83387f [ VM ] Add --mark-main-isolate-as-system-isolate flag
Allows for tools like the Dart test runner to hide the main isolate by
marking it as a system isolate, only showing the isolates users are
interested in.

TEST=pkg/vm_service/mark_main_isolate_as_system_isolate_test.dart

Change-Id: I24d0f20614e89076a05499c206d576c355489a13
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/207203
Reviewed-by: Jacob Richman <jacobr@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2021-07-22 18:15:10 +00:00
asiva be3c482bc3 Reinitialize the static fields in the corresponding Init functions so
that we do not have any state mismatch when the Dart VM is initialzed
and cleaned up multiple times.

TEST=existing unit test in the engine which is failing in a flaky manner

Change-Id: I073ca2b53a8c3d386be46b5222d547a29513714a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/207642
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
2021-07-21 18:12:34 +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
asiva ef9612e7ae [VM/Runtime] - Terminate exit code handler before cleanup
Terminate the exit code handler thread before calling cleanup.
This should fix https://github.com/dart-lang/sdk/issues/46275

TEST=unit test will be added to engine repo
https://github.com/flutter/engine/pull/27392

Change-Id: Ifb0b5c70cb2138d8c097d7f8f604269332f8e5c5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/206800
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
2021-07-15 18:49:06 +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 d511d177b3 [vm] Use atomic to avoid racy resolved platform string initialization
Issue https://github.com/dart-lang/sdk/issues/46626

TEST=This fixes TSAN reports on iso-stress builder.

Change-Id: I6797ff11f4d9b44ea72b2bb7beac715e2828f3a6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/207024
Reviewed-by: Alexander Aprelev <aam@google.com>
Reviewed-by: Tess Strickland <sstrickl@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2021-07-15 15:26:55 +00:00
Martin Kustermann b745cdcd82 [vm] Fix memory leak if isolate group creation fails (e.g. because VM is shutting down)
The leak can happen if isolate group creation is in-progress while the
main isolate group shuts down. This will disable isolate (group)
creation. Failure to create the isolate group will lead to the leak.

The issue can be reproduced by applying the following diff

    diff --git a/runtime/vm/isolate.cc b/runtime/vm/isolate.cc
    index 8993e5f3855..9335b5981d8 100644
    --- a/runtime/vm/isolate.cc
    +++ b/runtime/vm/isolate.cc
    @@ -1894,6 +1894,7 @@ Isolate* Isolate::InitIsolate(const char* name_prefix,
       }

       // Add to isolate list. Shutdown and delete the isolate on failure.
    +  sleep(1);
       if (!TryMarkIsolateReady(result)) {
         result->LowLevelShutdown();
         Isolate::LowLevelCleanup(result);

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

TEST=Verified this CL fixes the leak by applying the diff above.

Change-Id: Id64f6ebe88aafa589eecb7577464323a5a28cb20
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/206860
Reviewed-by: Tess Strickland <sstrickl@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2021-07-15 09:35:40 +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
Tess Strickland 298777c07d [vm] Merge text and data sections in ELF snapshots.
To do this, BitsContainer is changed to be a more rope-like
representation of section portions. In addition to containing
most of the same information stored per-section previously, each
portion also has a section-relative offset that is calculated when
it is added. Thus, merging two compatible BitsContainer sections
is just adding the portions from the second to the first, tweaking
the section-relative offset for each.

Other changes in this CL:

* Create PseudoSections subclasses for the elf header, program
  header table, and section header table, so we can treat them
  more uniformly with the other parts of the ELF snapshot.

* We now only allocate as much BSS space in the snapshot as is needed
  for any text sections in the snapshot, instead of always allocating
  a big enough BSS space for both VM and isolate, even for deferred
  snapshots where there is no VM isolate.

* We already separated segment and section alignment in previous CLs,
  so the fact that our own ELF loader needs load segments to be
  page-aligned no longer means that the sections within those segments
  also needs to be. Thus, we align individual instructions sections to
  kMaxObjectAlignment, like readonly data sections, since both hold a
  single Image object. This removes unnecessary intra-section padding.

TEST=Tests that check DWARF information and trybots that use ELF
     snapshots.

Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-simarm_x64-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-release-simarm-try,vm-kernel-precomp-linux-release-simarm64-try,vm-kernel-precomp-dwarf-linux-product-x64-try
Change-Id: If0315c8b7b0f31481b676a8901f49cd3a44b5561
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/206365
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
2021-07-13 07:40:15 +00:00
David Benjamin ee65e3efa0 Use accessors for X509_STORE and X509_OBJECT
This will avoid build failures in the future when X509_STORE and
X509_OBJECT become opaque. Along the way, it does the following:

- Remove unnecessary NULL check for the object list (it's always
  non-NULL, and STACK_OF(T) functions generally treat NULL as the empty
  list).

- Use BoringSSL's ranged-for adapters for STACK_OF(T).

By using the X509_OBJECT accessor, rather than reaching into the union
directly, this also avoids a potential memory error in the future, if
you ever put non-X509 objects into your X509_STORE.
(X509_OBJECT_get0_X509 checks the type and returns NULL.)

TEST=rely on CI tests, this is refactor

Change-Id: Iafb8c06cfdfa86948119c229837b2e20b824f612
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/206460
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
Auto-Submit: David Benjamin <davidben@google.com>
2021-07-12 19:57:34 +00:00
Zach Anderson f407419d0a [vm] Reland: Prefix HOST_OS_* and TARGET_OS_* with DART_
This relands https://dart-review.googlesource.com/c/sdk/+/205633
but without renaming TARGET_OS_IPHONE to DART_TARGET_OS_IPHONE.
It also changes uses of TARGET_OS_IOS to
DART_TARGET_OS_MACOS_IOS to be consistent with the rest of the
VM.

TargetConditionals.h for XCode 13 defines several
TARGET_OS_* preprocessor symbols that confuse the
Dart build. There is probably a more targeted fix
for this, but renaming the symbols that Dart uses
will also prevent this problem if more symbols
are added to the platform headers in the future.

See: https://github.com/dart-lang/sdk/issues/46499

TEST=It builds.

Change-Id: Ie775c19dd23cfdf5f65e5ebc6ee4ec3a561676fa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/205860
Commit-Queue: Zach Anderson <zra@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2021-07-02 19:06:45 +00:00
Slava Egorov 42164cc140 Revert "[vm] Prefix HOST_OS_* and TARGET_OS_* with DART_"
This reverts commit aa9201b76b.

Reason for revert: blocks G3 roll (b/192627187)

Original change's description:
> [vm] Prefix HOST_OS_* and TARGET_OS_* with DART_
>
> TargetConditionals.h for XCode 13 defines several
> TARGET_OS_* preprocessor symbols that confuse the
> Dart build. There is probably a more targeted fix
> for this, but renaming the symbols that Dart uses
> will also prevent this problem if more symbols
> are added to the platform headers in the future.
>
> See: https://github.com/dart-lang/sdk/issues/46499
>
> TEST=It builds.
> Change-Id: I3b33a03b4a9a14b76d55fe12f8cdefec4b3c3664
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/205633
> Commit-Queue: Zach Anderson <zra@google.com>
> Reviewed-by: Siva Annamalai <asiva@google.com>

TBR=rmacnak@google.com,zra@google.com,asiva@google.com

Change-Id: Ib06ca418c7e9d3b4df62c72c033cd39f462f7667
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/205790
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2021-07-02 14:02:02 +00:00
Zach Anderson aa9201b76b [vm] Prefix HOST_OS_* and TARGET_OS_* with DART_
TargetConditionals.h for XCode 13 defines several
TARGET_OS_* preprocessor symbols that confuse the
Dart build. There is probably a more targeted fix
for this, but renaming the symbols that Dart uses
will also prevent this problem if more symbols
are added to the platform headers in the future.

See: https://github.com/dart-lang/sdk/issues/46499

TEST=It builds.
Change-Id: I3b33a03b4a9a14b76d55fe12f8cdefec4b3c3664
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/205633
Commit-Queue: Zach Anderson <zra@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2021-07-02 06:02:48 +00:00
Ryan Macnak e2da2e21ca [build] Use .incbin to avoid horrible Clang assembler performance.
TEST=build
Change-Id: I46f8a5ef019d0afbf0de27533cd3f387ccdcbb54
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/205380
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2021-06-30 21:23:04 +00:00
Ryan Macnak fb5465c624 [vm] Remove unused compilation and type-feedback traces.
Reduces VM code size by about 33k.

TEST=ci
Change-Id: Ifc74284fa69fe209ebf12566ca81bda765f19057
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/202863
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2021-06-21 23:47:50 +00:00
Alexander Aprelev 730156116f [vm] Cleanup unused variables in anticipation of switching to new clang.
Extracted from https://dart-review.googlesource.com/c/sdk/+/201862 that switches clang to Fuchsia toolchain.

TEST=ci

Change-Id: Icd4e985a433f81862e681332dfcf905b8ec7ba4c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/204060
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2021-06-18 17:45:04 +00:00
Ryan Macnak d2e460675b [vm] Fix gcc build.
TEST=local build
Change-Id: I572aba5798a07ce5cb0cbda83d6eb3e44811ba5b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/203287
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2021-06-17 16:05:02 +00:00
Alexander Aprelev fb32ffd97f [io/mac/sigpipe] Ensure SIGPIPE is not triggered for client socket connect code.
Fixes https://github.com/flutter/flutter/issues/84499

TEST=socket_sigpipe_test.dart

Change-Id: I220558e74b41c1969efa422254867c11dd17ee91
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/203660
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2021-06-16 17:38:37 +00:00
Ryan Macnak e5bc0f0b86 [vm] Make various arrays const.
TEST=build
Change-Id: I8d3445b87caa979472c9a37df62507f152a4aefb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/203202
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2021-06-14 20:45:18 +00:00
Daco Harkes ddafaa0775 [vm/ffi] Update tests to cover MacOS arm64 after-struct alignment
Expands the test PassStruct9BytesPackedMixedx10DoubleInt32 to see how
the second integer is allocated.
Updates runtime/vm/compiler/ffi/unit_tests/structPacked to have the same
signature.

Fixes the structs by value test generator to output // @dart 2.9 for
legacy mode.
Deletes the copy of the test generator from tests/ffi, the copy did not
run in legacy mode.

TEST=only test changes

Change-Id: I65b7db56225a8e7963493dbccc2f296faca6fee1
Cq-Include-Trybots: luci.dart.try:vm-kernel-mac-release-arm64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/202968
Reviewed-by: Tess Strickland <sstrickl@google.com>
2021-06-11 12:00:26 +00:00
Daco Harkes a9f08a75a2 [vm/ffi] Fix _ClobberAndCall linking on MacOS arm64
Bug: https://github.com/dart-lang/sdk/issues/46305

TEST=tests/ffi_2/vmspecific_function_callbacks_test.dart

Change-Id: I82af08c5123b9bf637b9dc6e1983dde3fa155291
Cq-Include-Trybots: luci.dart.try:vm-kernel-mac-release-arm64-try,vm-ffi-android-debug-arm64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/202967
Reviewed-by: Tess Strickland <sstrickl@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2021-06-11 11:21:36 +00:00
Alexander Aprelev 20eb34f233 [vm/win/crypto] Cleanup use of BCryptGenRandom.
This is follow-up to https://dart.googlesource.com/sdk/+/1731050b29097b7b40d208ec1658f6f20737d276

TEST=ci

Change-Id: I682702addf50a1bf93fecbf1e1f835801c6c7f20
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/202727
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2021-06-07 23:15:13 +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
Alexander Aprelev 05e5427800 [io/mac] Ensure FSEventsWatcher::Node is deleted synchronously with Callback that uses it.
This is follow-up to ed82bb6f4c

TEST=tests/standalone/io/file_system_watcher_large_set_test.dart

Change-Id: If02c922eafe1371c6e67196158896b9cb786bfd6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/202312
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2021-06-04 14:26:36 +00:00
Ben Konyi 4b96d7a09d [ VM / CLI ] Add support for --[no-]serve-devtools
Fixes https://github.com/dart-lang/sdk/issues/45867

TEST=pkg/dartdev/test/commands/run_test.dart

Change-Id: I3e575db8298d47b69eb9e120f9792ed60d25c7d8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/199960
Auto-Submit: Ben Konyi <bkonyi@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2021-06-01 20:33:15 +00:00
asiva 0742ed66a7 [VM/Tests] - Fix new abstract_socket_test.
- Skip in configurations that do not build the abstract_socket_test
executable
- Fix MemorySanitizer: use-of-uninitialized-value error

TEST=existing test - unix-socket-test

Change-Id: Ie9bf6dc1cd6bea98cd7859584473154f6ac49eee
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/201722
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
2021-05-29 00:16:34 +00:00
Alexander Aprelev ed82bb6f4c [io/file_watcher] Ensure start/stop file watching requests are run on dart thread.
At present start/stop requests are scheduled on RunLoop thread.
This results in deadlocks since same RunLoop thread might be busy
with blocking writes of file watching events, not giving a chance
for Dart to read previously-written events. Reading would unblock
writer.
So this CL moves start/stop requests to run on Dart thread instead.

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

TEST=run analysis_server against flutter_gallery github-backed folder, switch between branches and ensure analyze_server remains responsive

Change-Id: I0464eeecf8e46ba3027fa0ed21cc323495d965c3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/201442
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2021-05-28 03:39:18 +00:00
Zach Anderson 5dc1f8db8c Trim abstract unix socket path length
Fixes https://github.com/dart-lang/sdk/issues/46149

TEST=unix_socket_test
Change-Id: Icc5273941f880f581cc2621431b5cecb7782c71e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/201441
Commit-Queue: Zach Anderson <zra@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2021-05-27 21:50:24 +00:00
Alexander Aprelev 39dead4394 [io] Ensure bcrypt.lib is declared as a lib dependency for downnstream users.
Follow-up to 1731050b29

TEST=ci

Change-Id: Ic9119069bc58af71787e225b0efbc1d79155f0c2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/201580
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2021-05-27 17:26:54 +00:00
Daco Harkes 50640bdb81 [vm/ffi] Fix ia32 struct by value return with no arguments
On IA32 arguments are passed in registers. When a struct is returned
by value, a pointer is passed in on the stack containing the address to
which the return value is written. We did not account for this pointer
in the stack-height calculation.

This problem only surfaced when there are no arguments to the function.
Because if an argument is passed it has a higher stack height than the
pointer for the result being passed in.

Fix in: runtime/vm/compiler/ffi/native_calling_convention.cc

TEST=runtime/vm/compiler/ffi/native_calling_convention_test.cc
TEST=tests/ffi/regress_46127_test.dart

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

Change-Id: Ia78fe07cc7e3a3c8625143d491935a959b4a7895
Cq-Include-Trybots: luci.dart.try:vm-kernel-linux-debug-ia32-try,vm-kernel-nnbd-linux-debug-ia32-try,vm-precomp-ffi-qemu-linux-release-arm-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/201269
Reviewed-by: Clement Skau <cskau@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2021-05-26 13:37:32 +00:00
bdbai 1731050b29 Use BCryptGenRandom for Crypto::GetRandomBytes on Windows
The current implementation of Crypto::GetRandomBytes on Windows calls
`rand_s` repeatedly until the buffer is completely filled. However,
`BCryptGenRandom` already provides the similar functionality to fill the
whole buffer at once and thus there is no need to maintain a handcrafted
implementation any more.

TEST=ci

Change-Id: I52d990b01b59be872d825f2aa0e30b500a6d3e36
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/200160
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2021-05-26 01:55:11 +00:00
Daco Harkes 35223586a3 Reland "[build] Use an absolute path for the snapshot"
When constructing the command line for creating the kernel service
snapshot, the variable `abs_output` actually contains a relative
path, which means that copy/pasting the generated command line fails
if not within the root build directory. This CL fixes that.

Previous revert: https://dart-review.googlesource.com/c/sdk/+/200940

Passes `--depfile-output-filename` with the path relative to the output
folder so that the written depfiles do not contain the absolute file
paths.

ninja only accepts paths relative to the build folder in the .d files.

Manually tested that the dependencies now work with running the
build twice:
`tools/build.py --no-start-goma -mrelease create_platform_sdk`

Inspecting the .d file in question that caused the revert:
`cat out/ReleaseX64/gen/kernel-service.dart.snapshot.d`

TEST=SDK build

Change-Id: Id781d2ed94ad7a0041e5899b8fded598de81242b
Cq-Include-Trybots: luci.dart.try:dart-sdk-linux-try,dart-sdk-mac-try,dart-sdk-win-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/200876
Reviewed-by: Tess Strickland <sstrickl@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2021-05-21 11:52:02 +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
asiva fb90f11f4b [dart:io] - Fix incorrect setting of socket options for UNIX-DOMAIN sockets
- setting of UNIX-DOMAIN socket options was not throwing the correct error
- listen in HTTPServer was trying to set TCP_NODELAY for UNIX-DOMAIN sockets

Fixes :
 https://github.com/dart-lang/sdk/issues/45977
 https://github.com/dart-lang/sdk/pull/45978
 https://github.com/dart-lang/sdk/issues/45975

TEST=new test cases added

Change-Id: Ie0341f26b1ba0f9423c08a8de968053a2af1c730
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/199640
Commit-Queue: Siva Annamalai <asiva@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2021-05-14 01:53:48 +00:00
Jens Johansen dce296cc36 [VM] Fix nullptr check in DFE
TEST=all tests running from file and none (to my knowledge) testing
the failure case as that's going to be a weird timing issue.

Change-Id: I997515587e86b324880fdd9fe11e86343e8bb973
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/199423
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2021-05-12 14:01:30 +00:00
Ben Konyi b99466d472 Reland "[ VM / DDS / CLI ] Add DevTools support to the standalone VM"
This reverts commit 5cbf10febe.

TEST=pkg/dds/devtools_observatory_connection_test.dart

Change-Id: I682d009f784b930094dae9b7d4e9a66efffb6ee8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/198561
Reviewed-by: Siva Annamalai <asiva@google.com>
2021-05-11 17:55:26 +00:00
Alexander Aprelev c438e39b23 [runtime/signal] Restore signal handlers to previous values.
Do not clear signal handlers if they were never set neither.

Fixes https://github.com/flutter/flutter/issues/81584

TEST=dart ci and flutter engine tests

Change-Id: I7e74000a72a63e264a13083554f63c50baca0bb3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/197920
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2021-05-07 16:19:17 +00:00
Alexander Aprelev bc2cf88bac [io/ssl] Add an option to bypass trusting system cert roots.
Fixes https://github.com/dart-lang/sdk/issues/45912

TEST=manually remove root certificate for pub.dev, confirm that dart is not able to establish https connection in default configuration to pub.dev, confirm that it can connect with the flag.

Change-Id: I51af7994d7cd7371a17877844dc1bf39cd5e54ca
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/198442
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Zach Anderson <zra@google.com>
2021-05-06 02:46:02 +00:00
Alexander Aprelev 8564fd0dae [io/ssl/win] Look for certificates in local machine store as well current user store.
Add certificates from "ca", "trust" and "my" stores in addition to "root".
Improve certificate tracing: print certificates as they are added.
Clean up error logging.

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

TEST=remove certs from current user store, see requests fail to connect, add cert to local machine store, confirm connection works.

Change-Id: Ied234098d56b406c9868602a2b806786ae3740be
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/198241
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Zach Anderson <zra@google.com>
2021-05-06 00:43:32 +00:00
Ben Konyi 5cbf10febe Revert "[ VM / DDS / CLI ] Add DevTools support to the standalone VM"
This reverts commit ef0e4ea107.

Reason for revert: Flutter HHH and golem builds are red. Rolls to Flutter are failing.

TEST=N/A

Original change's description:
> [ VM / DDS / CLI ] Add DevTools support to the standalone VM
>
> Example output on stdout when DevTools is enabled:
>
> Observatory listening on http://127.0.0.1:8181/CzkZzZaONW4=/
> The Dart DevTools debugger and profiler is available at: http://127.0.0.1:8181/devtools/#/?uri=ws%3A%2F%2F127.0.0.1%3A8181%2FCzkZzZaONW4%3D%2Fws
> hello world!
>
> vm-service: isolate(1674461414267555)  'main' has no debugger attached and is paused at exit.  Connect to Observatory at http://127.0.0.1:8181/CzkZzZaONW4=/ to debug.
>
> TEST=pkg/dartdev/test/commands/run_test.dart
>
> Change-Id: Icd1afda87ad4a46f228125d53094d10adf8056ec
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/188361
> Commit-Queue: Ben Konyi <bkonyi@google.com>
> Reviewed-by: Siva Annamalai <asiva@google.com>

# Not skipping CQ checks because original CL landed > 1 day ago.

Change-Id: I50e8dc4e592e13b44c2fb980b2029d5c5cc3ad2a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/198381
Reviewed-by: Ben Konyi <bkonyi@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2021-05-05 20:31:07 +00:00
Ben Konyi ef0e4ea107 [ VM / DDS / CLI ] Add DevTools support to the standalone VM
Example output on stdout when DevTools is enabled:

Observatory listening on http://127.0.0.1:8181/CzkZzZaONW4=/
The Dart DevTools debugger and profiler is available at: http://127.0.0.1:8181/devtools/#/?uri=ws%3A%2F%2F127.0.0.1%3A8181%2FCzkZzZaONW4%3D%2Fws
hello world!

vm-service: isolate(1674461414267555)  'main' has no debugger attached and is paused at exit.  Connect to Observatory at http://127.0.0.1:8181/CzkZzZaONW4=/ to debug.

TEST=pkg/dartdev/test/commands/run_test.dart

Change-Id: Icd1afda87ad4a46f228125d53094d10adf8056ec
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/188361
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2021-05-03 18:24:09 +00:00
Ryan Macnak d9f9b4dc96 [vm] Try to allocate snapshots and executable heap pages near the VM's binary.
Some 64-bit microarchitectures store only the low 32-bits of targets as part of indirect branch prediction, predicting that the target's upper bits will be the same as the call instruction's address. This leads to misprediction for indirect calls crossing a 4GB boundary. Ask mmap to place our generated code near the VM binary to avoid this.

Cf. https://chromium-review.googlesource.com/c/v8/v8/+/2726500

TEST=ci
Change-Id: If99850c50383751fcde1b71e38019c78ff97a787
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/197104
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
2021-04-28 23:22:55 +00:00
Daco Harkes 8a2b7bb5d5 [vm/ffi] Support Unions
Closes: https://github.com/dart-lang/sdk/issues/38491

tools/test.py ffi ffi_2
TEST=tests/ffi(_2)/(.*)by_value_(*.)_test.dart

Change-Id: I6d29f7e3c3046cda4a15c9b42063c66b064787be
Cq-Include-Trybots: luci.dart.try:dart-sdk-linux-try,dart-sdk-mac-try,dart-sdk-win-try,vm-ffi-android-debug-arm-try,vm-ffi-android-debug-arm64-try,vm-kernel-asan-linux-release-x64-try,vm-kernel-mac-debug-x64-try,vm-kernel-linux-debug-ia32-try,vm-kernel-linux-debug-x64-try,vm-kernel-nnbd-linux-debug-x64-try,vm-kernel-nnbd-linux-debug-ia32-try,vm-kernel-nnbd-mac-release-x64-try,vm-kernel-nnbd-win-debug-x64-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-debug-simarm_x64-try,vm-kernel-precomp-nnbd-linux-debug-x64-try,vm-kernel-precomp-win-release-x64-try,vm-kernel-reload-linux-debug-x64-try,vm-kernel-reload-rollback-linux-debug-x64-try,vm-kernel-win-debug-x64-try,vm-kernel-win-debug-ia32-try,vm-precomp-ffi-qemu-linux-release-arm-try,vm-kernel-precomp-obfuscate-linux-release-x64-try,vm-kernel-msan-linux-release-x64-try,vm-kernel-precomp-msan-linux-release-x64-try,vm-kernel-precomp-android-release-arm_x64-try,analyzer-analysis-server-linux-try,vm-kernel-precomp-linux-debug-x64c-try,vm-kernel-linux-debug-x64c-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/194420
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
2021-04-15 10:16:27 +00:00