Commit Graph

4157 Commits

Author SHA1 Message Date
Daco Harkes 592e5c144a [native assets] Support PATHEXT invocations with appended snapshot
This CL introduces an `IsolateData::asset_base_path` which contains
the fully resolved base path used for assets which are loaded with a
relative path. (Resolving both PATHEXT and symlinks.)

The asset base path is now only resolved once, instead of on every
relative asset load.

The asset base path is now eagerly resolved.
To prevent existing error messages for files not existing changing in
`dartdev` and `Isolate.spawnUri`, files not existing errors are
ignored.
To prevent `tests/standalone/io/named_pipe_script_test.dart` from
failing, failing to canonicalize a file path is treated as no asset
base path rather than reporting a failure.

TEST=pkg/dartdev/test/native_assets/*.dart

Bug: https://github.com/dart-lang/sdk/issues/60946
Change-Id: I79a9144d220dfb3e54311725d41f8f91c88db3a1
Cq-Include-Trybots: luci.dart.try:pkg-linux-debug-try,pkg-linux-release-arm64-try,pkg-linux-release-try,pkg-mac-release-try,pkg-mac-release-arm64-try,pkg-win-release-arm64-try,pkg-win-release-try,vm-aot-dyn-linux-debug-x64-try,vm-aot-android-release-arm64c-try,vm-aot-linux-debug-x64-try,vm-aot-mac-debug-arm64-try,vm-aot-win-debug-arm64-try,vm-aot-optimization-level-linux-release-x64-try,vm-aot-obfuscate-linux-release-x64-try,vm-msan-linux-release-x64-try,vm-asan-linux-release-x64-try,vm-linux-release-x64-try,vm-linux-debug-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/435421
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2025-06-26 07:47:32 -07:00
Martin Kustermann 931ec382d4 [io/gardening] Fix client address binding & fix standalone/io/socket_local_port_test
Various changes to the stanalone/io/socket_local_port_test:

  * Make server ports ephemeral: The test is testing client-side
    binding of address & port, the server part can use ephemeral ports.
    => This eliminates the issue of another process using the
       hard-coded port
  * Close sockets normally instead of using `Socket.destroy()`
  * Make dead code alive: There were test in the tests that were
    not invoked by `main()`.
  * Align the individual test helper functions.
  * ...

Then we change the dart:io implementation of `Socket::CreateBindConnect`
to set the `SO_REUSEADDR` socket option. We do this already for the
server side in `Socket::CreateBindListen`, now we do it also for the
client side.
=> This will ensure that one can bind the client side socket to
   specific address/source despite there being an old closed
   socket that's now in `TIME_WAIT` state.
=> This is the same reason we also do it in `Socket::CreateBindListen`.

Fuchsia doesn't implement `Socket::CreateBindConnect` and on Windows
the socket option seemingly has different semantics (we also don't use
`SO_REUSEADDR` on windows for the server socket, but another option).

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

TEST=standalone/io/socket_local_port_test

Change-Id: I7d07becad0cd98c3a9b973ef2f9037730d3f8b19
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/436902
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2025-06-25 02:56:21 -07:00
Ryan Macnak 42d796f7c1 [dart:io, mac] Don't create a thread pool per secure socket.
TEST=ci
Bug: https://github.com/flutter/flutter/issues/170723
Change-Id: I381c0dac8f7e308830c8bba472e11fb20939708e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/436501
Reviewed-by: Brian Quinlan <bquinlan@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2025-06-24 12:17:24 -07:00
Alexander Markov 05c2f3b0b1 [vm,dyn_modules] Hook interpreter to the standalone VM
When dynamic modules are enabled, standalone VM can now run bytecode
binaries directly. Also, if --interpreter flag is specified, Dart
source is compiled to bytecode and interpreter is used to run it.

This will allow us to test VM service capabilities including
debugging and hot reload against the interpreter.

TEST=manual

Change-Id: Ibb5a67f4844485c4ed90b8a7568dc42fa552fcac
Cq-Include-Trybots: luci.dart.try:vm-aot-dyn-linux-debug-x64-try,vm-aot-dyn-linux-product-x64-try,vm-dyn-linux-debug-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/436421
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2025-06-24 05:59:21 -07:00
Ryan Macnak 69f76f1086 [vm] Only include predefined symbols C strings in gen_snapshot.
Saves about 29k of binary size and kNumPredefinedSymbols map lookups at startup.

TEST=ci
Change-Id: I186c17a839ebfc6a800a35f08ca2f2c0776984ad
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/433862
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2025-06-23 17:00:52 -07:00
Alexander Markov 36087ec8f7 [vm] Remove unused kernel bytes in case of compile-time errors
In case of compile-time errors kernel service has been serializing kernel AST anyway and has been passing kernel bytes to the VM.
VM does not use those kernel bytes except a few unit tests.

This change removes the unnecessary kernel serialization and freeing
of kernel bytes and cleans up unit tests.

TEST=ci

Change-Id: Ic2464e50f56227bc998df53dd2b594c1abcf9468
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/436360
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2025-06-23 10:01:09 -07:00
Ryan Macnak 7973eacdd0 [vm] Rename USING_SIMULATOR to DART_INCLUDE_SIMULATOR.
We now have a mode where the simulator is available but not always used.

TEST=ci
Change-Id: If271f334150e2a125a014a4baa2e03d726300d35
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/435562
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2025-06-18 13:07:22 -07:00
Daco Harkes bed1101ecf [native assets] Propagate OS error on invocation via PATHEXT
Native assets resolution will now fail with an error message similar
to:

```
Invalid argument(s): Couldn't resolve native function '<...>' in
'<...>' : Failed to canonicalize the script uri
'<path without extension>'. OS error: 'The system cannot find the file
specified.
```

Supporting PATHEXT will be done in a follow up CL.

TEST=pkg/dartdev/test/native_assets/build_test.dart

Bug: https://github.com/dart-lang/sdk/issues/60946
Change-Id: I7db07b6c310ca8badd509c1d5d0595f671f1062d
Cq-Include-Trybots: luci.dart.try:pkg-win-release-arm64-try,pkg-win-release-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/435162
Reviewed-by: Michael Goderbauer <goderbauer@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2025-06-18 02:10:55 -07:00
Jason Simmons f1387e611c [build] Add a build flag for disabling secure sockets in the Dart IO library
See https://github.com/flutter/flutter/issues/170459

TEST=local builds of Flutter

Bug: https://github.com/flutter/flutter/issues/170459
Change-Id: Id15b9e19000bde41ae67274e5d2e43c0a0ae7a85
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/434984
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Jason Simmons <jsimmons@google.com>
2025-06-17 16:07:39 -07:00
Tess Strickland b85d7622f5 [vm] Add N_OSO symbolic debugging symbol to unstripped Mach-O symtabs.
Adding this allows dsymutil to parse a DebugMap from the Mach-O file,
which allows it to then create an appropriate .dSYM package for the
dylib if desired.

TEST=vm/dart/unobfuscated_static_symbols_test

Cq-Include-Trybots: luci.dart.try:vm-aot-mac-release-arm64-try,vm-aot-linux-release-simarm_x64-try
Bug: https://github.com/dart-lang/sdk/issues/60307
Change-Id: I723fde90b73d74e06840418c693858f5729cea58
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/434381
Reviewed-by: Slava Egorov <vegorov@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
2025-06-17 02:40:40 -07:00
Ryan Macnak ab4f9351b1 Rename vm_platform_strong.dill to vm_platform.dill.
The name has always been annoying because it did not add strong typing. And now there aren't variants of the VM platform to distinguish.

Leave a copy at the old name to not immediately break illegal uses.

TEST=ci
Cq-Include-Trybots: luci.dart.try:flutter-analyze-try,flutter-frontend-try,flutter-linux-try
Change-Id: Ie76fa7f16940aa1ba8d582eb5197f0ae55dc8938
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/429828
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2025-06-16 18:33:38 -07:00
Ben Konyi 60b217ff2d [ Observatory ] Remove Observatory from the Dart VM
Also cleans up some references to Observatory in various places.

Work towards https://github.com/dart-lang/sdk/issues/50233

TEST=N/A
CoreLibraryReviewExempt: Not modifying public core libraries.
Change-Id: I1f36b4e6f1fd9a59a579d719aafa599906eedb3f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/429141
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2025-06-11 15:19:55 -07:00
asiva 7ac79833ef Call File::GetCanonicalPath in Platform::ResolveExecutablePathInto() to make
it uniform with Platform::ResolveExecutablePath()

TEST=ci

Change-Id: Ib9e2f0c8ce2dc0d10cb67ceb3c3166f37201391f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/434040
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
2025-06-11 12:32:39 -07:00
Tess Strickland 14889cc06d [vm] Handle Windows unwinding records better in the Mach-O loader.
The Mach-O writer puts the unwinding records in a __unwind_info
section, so just find the appropriate section and use its contents
instead of forcing it to be at the end of the segment's memory space.

Create an overload of UnwindingRecordsPlatform::RegisterExecutableMemory
that takes a pointer to the start of the unwinding records for use by
the Mach-O loader.

Add __unwind_info for any executable segments that are not the text
segment as well.

Instead of testing host/target windows plus 64-bit arch, use the
defines provided by platform/unwinding_records.h in the Mach-O
writer and the ELF and Mach-O loaders.

TEST=ci on Windows trybots

Issue: https://github.com/dart-lang/sdk/issues/60307
Change-Id: Iee53c6725a681f44ac98ed9c9aecf1b75853ece5
Cq-Include-Trybots: luci.dart.try:vm-aot-linux-debug-x64-try,vm-mac-release-arm64-try,vm-aot-mac-release-arm64-try,vm-aot-mac-release-x64-try,vm-aot-dwarf-linux-product-x64-try,vm-linux-debug-x64-try,vm-mac-debug-arm64-try,vm-gcc-linux-try,vm-aot-win-release-arm64-try,vm-aot-win-release-x64-try,vm-win-release-x64-try,vm-win-release-arm64-try,vm-aot-win-debug-arm64-try,vm-win-debug-arm64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/432960
Commit-Queue: Tess Strickland <sstrickl@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2025-06-11 04:43:24 -07:00
Ryan Macnak b0fd6d4a15 [vm] Fix some Google3 ClangTidy warnings.
TEST=google3
Change-Id: I23236f32d78920388c0b7d2beb738e7cec965226
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/433580
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2025-06-09 11:05:59 -07:00
asiva 5a95bd8b2c Add mcp server instantiation to the list of commands parsed by the VM.
TEST=ci

Change-Id: I080dd6f8b1d864d35689701207d282447aaf879f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/433560
Commit-Queue: Siva Annamalai <asiva@google.com>
Reviewed-by: Jake Macdonald <jakemac@google.com>
2025-06-09 10:51:49 -07:00
Ryan Macnak bc17496b00 [vm] Fix Google3 ClangTidy warnings.
TEST=presubmit
Change-Id: Ifa4e77cc4548729526a90683ee163c68517e87ef
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/433001
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2025-06-04 15:14:15 -07:00
Tess Strickland 5c1f5cadb2 [build] Re-add targets used by Flutter.
TEST=ci

Cq-Include-Trybots: luci.dart.try:flutter-linux-try
Change-Id: Ifd8412fdc74095ffb027e80c8217ce1b5804a607
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/432702
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Auto-Submit: Tess Strickland <sstrickl@google.com>
2025-06-03 09:46:43 -07:00
Tess Strickland f7699740cc [vm] Allow manual loading of Mach-O dynamic library snapshots.
Adds a Mach-O loader, similar to the existing ELF loader, that
can be used on platforms that do not support loading Mach-O dynamic
libraries via dlopen().

Other changes:

* Renames the --force-load-elf-from-memory command line argument
  to --force-load-from-memory.
* Use CPU_TYPE_ANY and CPU_SUBTYPE_ANY for architectures that do
  not have specific constants in <mach/machine.h> (e.g., RISCV),
  as the snapshot header check after loading also catches architecture
  mismatches.
* Emit the unwinding information at the end of the text segment
  for Windows Mach-O snapshots as is done for ELF ones.

TEST=vm/dart/unobfuscated_static_symbols_test
     vm/dart/use_dwarf_stack_traces_flag_test

Issue: https://github.com/dart-lang/sdk/issues/60307
Change-Id: I34a2a334f47d18d5c4f4a712956e71fd0ac94024
Cq-Include-Trybots: luci.dart.try:vm-aot-linux-debug-x64-try,vm-mac-release-arm64-try,vm-aot-mac-release-arm64-try,vm-aot-mac-release-x64-try,vm-aot-dwarf-linux-product-x64-try,vm-linux-debug-x64-try,vm-mac-debug-arm64-try,vm-fuchsia-release-x64-try,vm-fuchsia-release-arm64-try,vm-linux-debug-ia32-try,vm-aot-linux-debug-simarm_x64-try,vm-aot-linux-debug-simriscv32-try,vm-aot-linux-debug-simriscv64-try,vm-aot-linux-release-simarm_x64-try,vm-gcc-linux-try,vm-ubsan-linux-release-arm64-try,vm-aot-win-release-arm64-try,vm-aot-win-release-x64-try,vm-win-release-x64-try,vm-win-release-arm64-try,vm-aot-win-debug-arm64-try,vm-win-debug-arm64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/430100
Reviewed-by: Slava Egorov <vegorov@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2025-06-03 05:56:59 -07:00
Ryan Macnak 03301c9bfb [vm] Support assembly output for Windows.
The resulting DLL lacks debugging information / PDB.

TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/60812
Bug: https://github.com/dart-lang/sdk/issues/60813
Cq-Include-Trybots: luci.dart.try:vm-aot-win-debug-arm64-try,vm-aot-win-debug-x64-try,vm-aot-win-release-arm64-try,vm-aot-win-release-x64-try
Change-Id: I305bad0081ec24f27249ad9b75ff8d32fa9c4893
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/428200
Reviewed-by: Tess Strickland <sstrickl@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2025-06-02 12:12:04 -07:00
asiva 2ecc1ee8e8 Close open file descriptors that are not needed during process spawn or exec.
TEST=ci

Change-Id: I8ee94b4f54bcb858646739cc6e9add333a25a724
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/430841
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
2025-05-28 10:28:20 -07:00
Tess Strickland 6b53073eae Reland "[vm, gen_snapshot] Add app-aot-macho-dylib option for AOT snapshots."
This is a reland of commit 38ef28a058

Fixes:

* Fix comparisons in ASSERT_EQUAL statements on 32-bit architectures.
* Take simulated architectures into account when deciding whether
  to use dlopen() for native shared object formats.
* Fix struct/field name collision for GCC.
* Use CPU_TYPE_ANY/CPU_SUBTYPE_ANY for architectures that do not
  have more specific cpu_type_t/cpu_subtype_t constants defined.

Original change's description:
> [vm, gen_snapshot] Add app-aot-macho-dylib option for AOT snapshots.
>
> This is the initial framework for creating snapshots as Mach-O dynamic
> libraries. Note that this framework is not 100% feature complete
> compared to generating Mach-O snapshots via assembly. In particular,
> the directly-compiled Mach-O dylib does not yet contain compact
> unwinding information.
>
> Other changes:
>
> * Adds UuidCommand to the native_stack_traces package's Mach-O reader,
>   which now appropriately returns the UUID as the build ID for Mach-O
>   shared objects.
>
> * Adds Utils::Basename(path) for portably retrieving the basename
>   from a path. (Returns nullptr for all arguments where it is not
>   currently implemented on Fuchsia or Windows.)
>
> * Adjusts vm/timeline.h to avoid pulling in <mach_o/loader.h> on MacOS,
>   as that interferes with uses of the namespaced Mach-O definitions
>   in platform/mach_o.h.
>
> * Only attempt to dlopen() a snapshot if ELF is the native format
>   for the host platform or the snapshot is not an ELF shared object.
>   If dlopen() is used, report the error message if it fails rather
>   than attempting to manually load the snapshot as an ELF shared object.
>
> * Fix the magic number stored in DylibAppSnapshot for loaded non-ELF
>   dynamic libraries.
>
> * Remove the detection of reverse-endian Mach-O magic numbers in
>   DartUtils::SniffForMagicNumber(), since all our Mach-O related code
>   assumes host-endian Mach-O files and so there's no point other than
>   to give a slightly better error message when failing.
>
> TEST=vm/dart/exported_symbols_test
>      vm/dart/unobfuscated_static_symbols_test
>      vm/dart/use_dwarf_stack_traces_flag_test
>      vm/cc/CanDetectMachOFiles
>
> Issue: https://github.com/dart-lang/sdk/issues/60307
> Change-Id: Idf5b49d6c6d035ab033509613212b95520d65965
> Cq-Include-Trybots: luci.dart.try:vm-aot-linux-debug-x64-try,vm-mac-release-arm64-try,vm-aot-mac-release-arm64-try,vm-aot-mac-release-x64-try,vm-aot-dwarf-linux-product-x64-try,vm-linux-debug-x64-try,vm-mac-debug-arm64-try,vm-fuchsia-release-x64-try,vm-fuchsia-release-arm64-try
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/415020
> Reviewed-by: Slava Egorov <vegorov@google.com>
> Commit-Queue: Tess Strickland <sstrickl@google.com>

TEST=vm/dart/exported_symbols_test
     vm/dart/unobfuscated_static_symbols_test
     vm/dart/use_dwarf_stack_traces_flag_test
     vm/cc/CanDetectMachOFiles
     ci on trybots that failed on the original CL

Cq-Include-Trybots: luci.dart.try:vm-aot-linux-debug-x64-try,vm-mac-release-arm64-try,vm-aot-mac-release-arm64-try,vm-aot-mac-release-x64-try,vm-aot-dwarf-linux-product-x64-try,vm-linux-debug-x64-try,vm-mac-debug-arm64-try,vm-fuchsia-release-x64-try,vm-fuchsia-release-arm64-try,vm-linux-debug-ia32-try,vm-aot-linux-debug-simarm_x64-try,vm-aot-linux-debug-simriscv32-try,vm-aot-linux-debug-simriscv64-try,vm-aot-linux-release-simarm_x64-try,vm-gcc-linux-try,vm-ubsan-linux-release-arm64-try
Change-Id: Iaffea0ddc6173100c8b5b2a9fe46c45f4f611a2e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/431240
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
2025-05-27 06:30:20 -07:00
Tess Strickland 38ea3a8f5e Revert "[vm, gen_snapshot] Add app-aot-macho-dylib option for AOT snapshots."
This reverts commit 38ef28a058.

Reason for revert: Breaks build on debug mode 32-bit arches,
                   release mode simarm_x64

Issue: https://github.com/dart-lang/sdk/issues/60307
Original change's description:
> [vm, gen_snapshot] Add app-aot-macho-dylib option for AOT snapshots.
>
> This is the initial framework for creating snapshots as Mach-O dynamic
> libraries. Note that this framework is not 100% feature complete
> compared to generating Mach-O snapshots via assembly. In particular,
> the directly-compiled Mach-O dylib does not yet contain compact
> unwinding information.
>
> Other changes:
>
> * Adds UuidCommand to the native_stack_traces package's Mach-O reader,
>   which now appropriately returns the UUID as the build ID for Mach-O
>   shared objects.
>
> * Adds Utils::Basename(path) for portably retrieving the basename
>   from a path. (Returns nullptr for all arguments where it is not
>   currently implemented on Fuchsia or Windows.)
>
> * Adjusts vm/timeline.h to avoid pulling in <mach_o/loader.h> on MacOS,
>   as that interferes with uses of the namespaced Mach-O definitions
>   in platform/mach_o.h.
>
> * Only attempt to dlopen() a snapshot if ELF is the native format
>   for the host platform or the snapshot is not an ELF shared object.
>   If dlopen() is used, report the error message if it fails rather
>   than attempting to manually load the snapshot as an ELF shared object.
>
> * Fix the magic number stored in DylibAppSnapshot for loaded non-ELF
>   dynamic libraries.
>
> * Remove the detection of reverse-endian Mach-O magic numbers in
>   DartUtils::SniffForMagicNumber(), since all our Mach-O related code
>   assumes host-endian Mach-O files and so there's no point other than
>   to give a slightly better error message when failing.
>
> TEST=vm/dart/exported_symbols_test
>      vm/dart/unobfuscated_static_symbols_test
>      vm/dart/use_dwarf_stack_traces_flag_test
>      vm/cc/CanDetectMachOFiles
>
> Issue: https://github.com/dart-lang/sdk/issues/60307
> Change-Id: Idf5b49d6c6d035ab033509613212b95520d65965
> Cq-Include-Trybots: luci.dart.try:vm-aot-linux-debug-x64-try,vm-mac-release-arm64-try,vm-aot-mac-release-arm64-try,vm-aot-mac-release-x64-try,vm-aot-dwarf-linux-product-x64-try,vm-linux-debug-x64-try,vm-mac-debug-arm64-try,vm-fuchsia-release-x64-try,vm-fuchsia-release-arm64-try
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/415020
> Reviewed-by: Slava Egorov <vegorov@google.com>
> Commit-Queue: Tess Strickland <sstrickl@google.com>

Issue: https://github.com/dart-lang/sdk/issues/60307
Cq-Include-Trybots: luci.dart.try:vm-aot-linux-debug-x64-try,vm-mac-release-arm64-try,vm-aot-mac-release-arm64-try,vm-aot-mac-release-x64-try,vm-aot-dwarf-linux-product-x64-try,vm-linux-debug-x64-try,vm-mac-debug-arm64-try,vm-fuchsia-release-x64-try,vm-fuchsia-release-arm64-try
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Change-Id: Iff2ab4c84a513a184784129f456bd357ae8e3a67
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/431220
Commit-Queue: Slava Egorov <vegorov@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Auto-Submit: Tess Strickland <sstrickl@google.com>
2025-05-27 01:05:48 -07:00
Tess Strickland 38ef28a058 [vm, gen_snapshot] Add app-aot-macho-dylib option for AOT snapshots.
This is the initial framework for creating snapshots as Mach-O dynamic
libraries. Note that this framework is not 100% feature complete
compared to generating Mach-O snapshots via assembly. In particular,
the directly-compiled Mach-O dylib does not yet contain compact
unwinding information.

Other changes:

* Adds UuidCommand to the native_stack_traces package's Mach-O reader,
  which now appropriately returns the UUID as the build ID for Mach-O
  shared objects.

* Adds Utils::Basename(path) for portably retrieving the basename
  from a path. (Returns nullptr for all arguments where it is not
  currently implemented on Fuchsia or Windows.)

* Adjusts vm/timeline.h to avoid pulling in <mach_o/loader.h> on MacOS,
  as that interferes with uses of the namespaced Mach-O definitions
  in platform/mach_o.h.

* Only attempt to dlopen() a snapshot if ELF is the native format
  for the host platform or the snapshot is not an ELF shared object.
  If dlopen() is used, report the error message if it fails rather
  than attempting to manually load the snapshot as an ELF shared object.

* Fix the magic number stored in DylibAppSnapshot for loaded non-ELF
  dynamic libraries.

* Remove the detection of reverse-endian Mach-O magic numbers in
  DartUtils::SniffForMagicNumber(), since all our Mach-O related code
  assumes host-endian Mach-O files and so there's no point other than
  to give a slightly better error message when failing.

TEST=vm/dart/exported_symbols_test
     vm/dart/unobfuscated_static_symbols_test
     vm/dart/use_dwarf_stack_traces_flag_test
     vm/cc/CanDetectMachOFiles

Issue: https://github.com/dart-lang/sdk/issues/60307
Change-Id: Idf5b49d6c6d035ab033509613212b95520d65965
Cq-Include-Trybots: luci.dart.try:vm-aot-linux-debug-x64-try,vm-mac-release-arm64-try,vm-aot-mac-release-arm64-try,vm-aot-mac-release-x64-try,vm-aot-dwarf-linux-product-x64-try,vm-linux-debug-x64-try,vm-mac-debug-arm64-try,vm-fuchsia-release-x64-try,vm-fuchsia-release-arm64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/415020
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
2025-05-26 08:52:26 -07:00
Martin Kustermann bbb847eb71 [vm] Allow running analyze_snapshot tool on MacOS
This allows development of the `analyze_snapshot` tool on a MacBook.

TEST=vm/dart/analyze_snapshot_binary_test

Change-Id: I3b1ec108bbff5db2f1e69dc98d65ddeaf11e5230
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/429941
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2025-05-21 02:53:49 -07:00
Chloe Stefantsova 1f26ddfee2 [ffi] Account for position variance in converting native types
This CL introduces variance-dependent treatment of the `Handle` native
type when converting native types to Dart types. Since `Handle` can
represent any object, it should match any type. To achive that in
cases when `Handle` appears as the subtype in the subtype checks, it's
converted to `Never` in covariant positions and to `Object?` in
covariant ones.

TEST=existing

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

Change-Id: Ie16a210491ada80d21f4d0f1c0fa3b3804881ede
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/426880
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2025-05-15 22:53:41 -07:00
Derek Xu 0ead16d05b [VM] Make it so that --profile-microtasks is processed by the code in both runtime/bin/main_options.h and runtime/vm/flags.h
TEST=pkg/vm_service/test/timeline_events_for_completed_microtasks_test

Change-Id: Ia544cabc7bfe6e322955d16d3078cab461b803ae
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/425100
Reviewed-by: Ben Konyi <bkonyi@google.com>
2025-05-13 14:29:37 -07:00
Ryan Macnak 018c5349a8 [vm] Handle short writes in Builtin_PrintString.
Also avoid polluting the repository working directory when fuzzing.

TEST=lib/mirrors/invocation_fuzz_test
Bug: https://github.com/dart-lang/sdk/issues/60721
Change-Id: Ibe2f2d35479bbf969cff74c954acd606c1fc0679
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/428381
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2025-05-13 14:25:36 -07:00
Ivan Inozemtsev 3e134659b2 Fix -Wunguarded-availability on Android
TEST=ci

Bug: b/417433829
Change-Id: I064c1c2c772ffd579b9e15b13333fb2cb8344f3d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/428321
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Ivan Inozemtsev <iinozemtsev@google.com>
2025-05-13 12:28:15 -07:00
Ryan Macnak e07cbdfbcc [dart:io] Use close_range when available during process spawning.
TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/60252
Change-Id: Ibfb6fa3d6dc8aff482db5178acb4caa35583fc3f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/426906
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2025-05-12 10:38:36 -07:00
Alexander Aprelev 893e37a517 [vm/shared] Add timeout to ConditionVariable.wait.
Update isolate_group_shared_callback_test to use that and also use flag to print exceptions.

TEST=ci
CoreLibraryReviewExempt: only internal library is affected
Change-Id: Ia53ca7a6dc847b551229ccf00bbbfe302a260fcb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/427680
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2025-05-09 11:29:30 -07:00
asiva aa8542e1db Enable use of Process::Start functions before initialization of
the Dart VM is done.

TEST=ci

Change-Id: I9b20368048b07af5b37b1622676ad498a0c24225
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/427021
Commit-Queue: Siva Annamalai <asiva@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2025-05-06 17:10:25 -07:00
Alexander Aprelev 50e0e0d99d [vm/shared] Introduce NativeCallable.isolateGroupShared
This method allows for synchronous execution of dart callbacks from native code. The execution happens on dart mutator thread, from which dart code can only access isolate-group variables - those which are tagged with .

Bug: https://github.com/dart-lang/sdk/issues/54530
Bug: https://github.com/dart-lang/sdk/issues/56841
Change-Id: Ia1a6b01327be493f003f1eea82e558bb6b147dd3
CoreLibraryReviewExempt: only internal library change
TEST=isolate_group_shared_callback_test
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/422920
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2025-05-06 13:28:44 -07:00
Ryan Macnak 25dfb5420d [dart:io] Always use O_CLOEXEC instead of FD_CLOEXEC on Linux.
TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/60252
Change-Id: Ide6d156d8a7c569984d4fa702dc32ac08f9ee9e1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/426580
Reviewed-by: Brian Quinlan <bquinlan@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2025-05-05 13:07:38 -07:00
Ivan Inozemtsev 29e33b00d0 Reland "watchOS target os"
This is a reland of commit 7ae1d75869

TEST=manual, no watchOS SDK on bots yet.

Original change's description:
> watchOS target os
>
> - add support for --os=watchos | --os=watchos_simulator
> - do not depend on perfetto if dart_support_perfetto is false
> - change the default value for dart_support_perfetto to !is_watchos
>
> To minimize changes and to avoid modifying third-party zlib BUILD file, is_watchos implies is_ios for now.
>
> TEST=manual, no watchOS SDK on bots yet.
>
> Cq-Include-Trybots: luci.dart.try:vm-mac-debug-arm64-try,vm-mac-release-arm64-try
> Change-Id: If2130068ef546162a07a9ba53f94b11ff25fb565
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/415021
> Reviewed-by: Ryan Macnak <rmacnak@google.com>
> Commit-Queue: Ivan Inozemtsev <iinozemtsev@google.com>

Cq-Include-Trybots: luci.dart.try:vm-mac-debug-arm64-try,vm-mac-release-arm64-try
Change-Id: I2b50f7eb4da173627aeb4833b88a08712b278d9f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/425523
Commit-Queue: Ivan Inozemtsev <iinozemtsev@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2025-05-05 06:40:30 -07:00
Ryan Macnak e36271db49 Add lint to prevent use of pthread_detach.
TEST=presubmit
Change-Id: Ia83acad9c50246af1aa365218354c01cc64e2127
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/425142
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2025-04-29 09:46:58 -07:00
Ivan Inozemtsev 10c579c7e8 Revert "watchOS target os"
This reverts commit 7ae1d75869.

Reason for revert: breaks flutter build

Original change's description:
> watchOS target os
>
> - add support for --os=watchos | --os=watchos_simulator
> - do not depend on perfetto if dart_support_perfetto is false
> - change the default value for dart_support_perfetto to !is_watchos
>
> To minimize changes and to avoid modifying third-party zlib BUILD file, is_watchos implies is_ios for now.
>
> TEST=manual, no watchOS SDK on bots yet.
>
> Cq-Include-Trybots: luci.dart.try:vm-mac-debug-arm64-try,vm-mac-release-arm64-try
> Change-Id: If2130068ef546162a07a9ba53f94b11ff25fb565
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/415021
> Reviewed-by: Ryan Macnak <rmacnak@google.com>
> Commit-Queue: Ivan Inozemtsev <iinozemtsev@google.com>

Cq-Include-Trybots: luci.dart.try:vm-mac-debug-arm64-try,vm-mac-release-arm64-try
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Change-Id: I4bede9ede04ac3c533b8ff7ae2f1adbd84eb2397
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/425262
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Reviewed-by: Alexander Thomas <athom@google.com>
Commit-Queue: Alexander Thomas <athom@google.com>
Auto-Submit: Ivan Inozemtsev <iinozemtsev@google.com>
2025-04-29 03:21:37 -07:00
Ivan Inozemtsev 7ae1d75869 watchOS target os
- add support for --os=watchos | --os=watchos_simulator
- do not depend on perfetto if dart_support_perfetto is false
- change the default value for dart_support_perfetto to !is_watchos

To minimize changes and to avoid modifying third-party zlib BUILD file, is_watchos implies is_ios for now.

TEST=manual, no watchOS SDK on bots yet.

Cq-Include-Trybots: luci.dart.try:vm-mac-debug-arm64-try,vm-mac-release-arm64-try
Change-Id: If2130068ef546162a07a9ba53f94b11ff25fb565
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/415021
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Ivan Inozemtsev <iinozemtsev@google.com>
2025-04-29 02:28:52 -07:00
Ryan Macnak 40deed0f1d [test] Avoid race in glibc's pthread_detach.
```
  if (atomic_compare_and_exchange_bool_acq (&pd->joinid, pd, NULL))
    {
      if (IS_DETACHED (pd))
```

If the thread exits between these two statements, it will destroy the TCB and the second statement will segfault.

TEST=ffi/async_void_function_callbacks_test
Change-Id: If4074c89ec2a618b69f1a1ef3300b8aef7527ef7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/424380
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2025-04-28 10:41:43 -07:00
Derek Xu 2877d78576 Reland "[VM/Service] Record timeline events representing completed microtasks"
This is a reland of commit 22021cc120

I showed some excerpts of Golem results to @mraleph for varying targets
and constant CPU, patch A, and patch B. Those constants being:
  CPU: Intel Xeon
  patch A: revision=115869&patch=20143
  patch B: revision=115876
(example results:
https://golem.corp.goog/Comparison?repository=dart#targetA%3Ddart%3BmachineTypeA%3Dlinux-x64%3BrevisionA%3D115869%3BpatchA%3Dderekx-Reland---VM%2FService--Record-timeline-events-representing-completed-microtasks--4%3BtargetB%3Ddart%3BmachineTypeB%3Dlinux-x64%3BrevisionB%3D115876%3BpatchB%3DNone)

He said that this change could be relanded as long as the following
"RunTime as Score" regressions of the "dart" target were noted in the
commit message:
  - StreamSingleSubTest: -3.907% (-0.8 noise)
  - ScheduleMicrotaskTest: -12.67% (-0.6 noise)

TEST=pkg/vm_service/test/timeline_events_for_completed_microtasks_test

Original change's description:
> [VM/Service] Record timeline events representing completed microtasks
>
> TEST=pkg/vm_service/test/timeline_events_for_completed_microtasks_test
>
> CoreLibraryReviewExempt: This CL does not include any core library API
> changes, it only modifies the implementation of microtasks (by
> instrumenting them).
> Change-Id: I54d886db9519c73f9e3218a9cc1c46bc9fe9acc3
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/420221
> Commit-Queue: Derek Xu <derekx@google.com>
> Reviewed-by: Ben Konyi <bkonyi@google.com>

CoreLibraryReviewExempt: This CL does not include any core library API
changes, it only modifies the implementation of microtasks (by
instrumenting them).
Change-Id: Ia7741a9bb9ab948e8d5fff1cf9abe9915e247d81
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/423921
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Derek Xu <derekx@google.com>
2025-04-25 08:51:22 -07:00
Ryan Macnak ecbbf4a141 [test] Bypass global destructors when exiting without shutting down the VM.
Running global destructors can interfer with VM code running on other threads, including causing MSAN to flag accesses as using uninitialized memory.

TEST=msan, ffi/vmspecific_function_callbacks_exit_test
Change-Id: Ia9a7223ecc81690a2047e5936b9a138fff620ad1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/424241
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2025-04-23 14:46:10 -07:00
Derek Xu 75311aefa8 [VM/Timeline] Add Microtask stream
TEST=runtime/vm/dart_api_impl_test.cc

Change-Id: Icb078489f3600ac0fb8b314ca3bf748f482a687e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/422860
Reviewed-by: Ben Konyi <bkonyi@google.com>
2025-04-22 07:42:27 -07:00
Derek Xu de32acf9ac [VM] Introduce ListQueue class
TEST=list_queue_test.cc

Change-Id: Ie85055475f35a9fdc4f31e61d5f1f5d04eb707a8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/420220
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Derek Xu <derekx@google.com>
2025-04-15 09:07:59 -07:00
Vyacheslav Egorov 5f32e78a09 [vm] Fix running under HWASAN
HWASAN tags stack regions (and stack pointers) with 0,
but also selectively tags some stack allocations with
non-zero tags. These tags need to be cleared when
allocation goes out of scope so that stack can be
later safely reused - otherwise stale tags confuse
HWASAN instrumentation later.

This CL teaches Exceptions::JumpToFrame to do that.

CL also adds basic build changes to support building
with HWASAN, though I don't wire it into CI for now
as it can only really run on Android ARM64

TEST=manually on Android phone and on internal tests

Bug: b/374433249
Change-Id: I678443dc1de693c999a226bee0d71a6f3582d4f9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/421180
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Auto-Submit: Slava Egorov <vegorov@google.com>
2025-04-14 10:14:54 -07:00
Ryan Macnak 4ab313cf09 [vm, test] Enable some AOT testing for Fuchsia.
Fix the standalone embedder's ELF loader to open files with the executable permission.

TEST=ci
Bug: b/399714829
Bug: https://github.com/dart-lang/sdk/issues/60442
Cq-Include-Trybots: luci.dart.try:vm-fuchsia-release-arm64-try,vm-fuchsia-release-x64-try
Change-Id: I2652a5849462ce63585550e6c581cc578a228955
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/419341
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Zijie He <zijiehe@google.com>
2025-04-01 09:50:12 -07:00
Ben Konyi 138924c1e8 [ dart:io ] Add tmux terminals to list of terminals known to support ANSI
Fixes https://github.com/flutter/flutter/issues/142861

TEST=N/A

Change-Id: I208c597f33c622d19419202351dd17d39ec82bc3
CoreLibraryReviewExempt: only dart:io
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/419280
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Brian Quinlan <bquinlan@google.com>
2025-03-31 14:31:47 -07:00
Ryan Macnak 92df34dfd5 [build] Remove Fuchsia sub-builds.
The builders at https://ci.chromium.org/p/fuchsia/g/dart/console no longer exist.

TEST=build
Change-Id: I1b801d7892b3e6cba37d7b9549e3d08306cc9723
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/417907
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2025-03-31 13:07:29 -07:00
asiva 284a7ee8c5 [VM/IO] Fix error path in SocketAddress::GetSockAddr
Dart_TypedDataReleaseData was not called in an error path.

Should fix https://github.com/dart-lang/sdk/issues/60421

TEST=tests/standalone/io/datagram_error_test.dart

Change-Id: I1935af1c5beed9d696a0543d0e97f2d549743879
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/418701
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
2025-03-28 14:49:19 -07:00
asiva 8af371c1e8 Fix for App crash when File class receive an empty string
TEST=new test added
Change-Id: I575d85c5ab13a2094114a6fa2a7fe9f06ebeabe4
FIXES: https://github.com/dart-lang/sdk/issues/60331
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/417962
Reviewed-by: Brian Quinlan <bquinlan@google.com>
2025-03-26 21:26:49 -07:00
Ivan Inozemtsev a5077aa352 Reland "Add gen_snapshot binaries, producing Linux ARM64/x64 snapshots"
This is a reland of commit e6d55c6c2f

Reworks guards for 64-bit Windows unwinding support code so that
it is not included in any 64-bit Windows gen_snapshot executable that
targets a non-64-bit Windows platform.

TEST=ci, build only

Original change's description:
> Add gen_snapshot binaries, producing Linux ARM64/x64 snapshots
>
> Inspired by `//runtime/bin:gen_snapshot_fuchsia`, required for go/dart-cross-compile.
>
> TEST=ci, build only
>
> Change-Id: Ie521c984a8f44d25f3f78d946af9416582a572dc
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/410402
> Reviewed-by: Ryan Macnak <rmacnak@google.com>
> Commit-Queue: Ivan Inozemtsev <iinozemtsev@google.com>

Change-Id: I4f1323ac8f7ab215c2dffeef188f70c466fb62ea
Cq-Include-Trybots: luci.dart.try:vm-win-release-arm64-try,vm-win-release-ia32-try,vm-win-release-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/413402
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ivan Inozemtsev <iinozemtsev@google.com>
Commit-Queue: Ivan Inozemtsev <iinozemtsev@google.com>
2025-03-13 07:23:39 -07:00