Commit Graph

117 Commits

Author SHA1 Message Date
Ryan Macnak 1dc1b015eb [dart:io, win] Don't delete the process list mutex during shutdown.
The exit callback might fire during or after dart:io shutdown.

TEST=ci (flaky)
Bug: https://github.com/dart-lang/sdk/issues/60499
Change-Id: I950ef4a6ba1d99a8eafb55cb051a60f0cb097e71
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/493485
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2026-04-08 08:33:32 -07:00
Slava Egorov 25ffce7e36 [vm/win] Avoid unnecessary consoles for dartvm.exe
If dart.exe is not attached to the console then it should spawn
dartvm.exe detached to avoid creating an unnecessary console
window.

Fixes https://github.com/dart-lang/build/issues/4312

TEST=standalone/io/windows_no_unnecessary_console_test

Change-Id: I1de65accca5e28f3cfbe44a70f782525f0059bf0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/475000
Commit-Queue: Slava Egorov <vegorov@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
2026-01-22 08:17:43 -08:00
Slava Egorov 96eece84bd [vm/io] Avoid %ls in SetOsErrorMessage
This format specifier does not perform a wide char to utf8 conversion
but rather a locale dependent wide char to multibyte conversion 
(essentially wcstombs), which is not what this function is expecting
to do (it is expected to return utf8 encoded error message). 

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

TEST=not tested, speculative fix

Change-Id: Icd5ddbf9969dbd4acd2f7f48626ce0bd6a6a6964
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/468800
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2025-12-17 03:20:11 -08:00
Ryan Macnak 583fbe5962 [vm] Symbolize more Windows errors.
TEST=build
Bug: https://github.com/dart-lang/sdk/issues/62249
Change-Id: I66e5cff2c965c1078ee59338bf5f0c4d061cec95
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/468400
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2025-12-15 15:45:21 -08:00
Slava Egorov 473149f0b1 [io] Fix Process::Exec stdio handle inheritance
The code for inheriting stdio handles was not taking into account that
some of the stdio handles might be the same causing them to be
duplicated in the list of inherited handles. However passing duplicate
handles in PROC_THREAD_ATTRIBUTE_HANDLE_LIST causes CreateProcess to
return E_INVALIDARG.

This CL fixes the code to avoid duplicate handles.

We also fix printing of errors, which was broken when Process::Exec
was used without Dart scope causing it to print (null) instead of
actual error message.

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

TEST=vm/dart/regress_61981

Fixed: 61981
Change-Id: I93a6b56476f5020de9ebf894614cee51586b6751
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/464382
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2025-11-25 11:59:21 -08:00
Slava Egorov dec87b98f0 [io] Provide dart::bin::SetupDartIoLibrary
Instead of requiring embedder to initialize dart:io by bits and pieces
by invoking various hooks and setting fields provide a structured C++
API for preparing dart:io for execution.

TEST=ci

CoreLibraryReviewExempt: VM specific changes only
Change-Id: I66e95c0a451d384b4f7582d1df059e506a6a6964
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/454062
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2025-10-14 13:15:21 -07:00
Alexander Aprelev 010b6968b7 [win/signal] Disable ctrl-c handling in the parent dartdev process.
Ensure that ctrl-c is handled by spawned dartvm.exe process, parent dart.exe does not get in a way of handling ctrl-c, exits only after spawned dartvm.exe exits.

Fixes https://github.com/dart-lang/sdk/issues/61399
TEST=manually on windows

Change-Id: Ibdbfbb5e4863c76bbbf2e30fb2d94f72a2676d4a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/446704
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2025-08-26 16:37:40 -07:00
asiva ab44b20ab8 Reapply "[VM/dartdev] Switch dartdev to use an AOT runtime." and
Add the fixes that were done after original CL landed.

This reverts commit 97bc401163.

TEST=ci

Change-Id: I26373aecc325e4c0c379c92e779aa301e3a58c5a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/441700
Reviewed-by: Brian Quinlan <bquinlan@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
2025-07-24 14:48:03 -07:00
asiva ff05b45f5c Address code review comment.
TEST=ci

Change-Id: I778069c914146752f1f1e37dfdd11f71bff3e3a3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/441860
Commit-Queue: Siva Annamalai <asiva@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2025-07-23 12:58:52 -07:00
asiva 7e05022286 Ensure only the child Dart VM process that is spawned from the
Dart CLI process gets killed when the Dart CLI process dies.
(See https://github.com/dart-lang/sdk/issues/61148)

TEST=manual and flutter_attach_test

Change-Id: I297f6b20aa30f45ef3f4aec6f24db9fc94751b94
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/440264
Commit-Queue: Siva Annamalai <asiva@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2025-07-18 17:46:04 -07:00
asiva 97bc401163 Revert "[VM/dartdev] Switch dartdev to use an AOT runtime."
This reverts commit 5399dbf6f6.

Reason for revert : Flutter rolls are failing

TEST=ci

Change-Id: I76fede849705514496adbc2ab7f6c262de4103ca
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/439661
Reviewed-by: Jason Simmons <jsimmons@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
2025-07-09 23:08:28 -07:00
asiva 5399dbf6f6 [VM/dartdev] Switch dartdev to use an AOT runtime.
- split the Dart CLI tool out of the VM into it's own embedder which
  runs in AOT mode. The pure Dart VM executable is called 'dartvm' and
  has no Dart CLI functionality in it
- the Dart CLI executable parses the CLI commands and invokes the rest
  of the AOT tools in the same process, for the 'run' and 'test'
  commands it execs a process which runs 'dartvm' to run
- 'dart hello.dart' execs the 'dartvm' process and runs 'hello.dart'
- the Dart CLI is not generated for ia32 as we are not shipping a
  Dart SDK for ia32 anymore (support to execute the 'dartvm' for ia32
  architecture is retained)
- the Dart CLI tool is not built in the internal Dart SDK builds

TEST=ci

Some performance improvement numbers
'dart format pkg/dartdev' goes from 1.17 secs to 0.22 secs
'dart doc pkg/dartdev' goes from 100.2 secs to 66.6 secs
'dart fix pkg/dartdev' goes from 19.3 secs to 14.5 secs

Change-Id: I66984a26cb2ab014b34dc1873f1f3d2884e13518
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/364202
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2025-07-04 13:22:13 -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
asiva 1e148e651b Fix issue that was found with the flutter rolls (unable to locate
the dds snapshot)


Reland "[SDK] Switch dds and dtd to use an AOT snapshot"

This reverts commit 11ab2dfe2f.

Reason for revert: Fixes the problem that is causing Flutter G3 roll to fail.

TEST=ci

Original change's description:
> Revert "[SDK] Switch dds and dtd to use an AOT snapshot"
>
> This reverts commit 6450d76f1f.
>
> Reason for revert: Breaking Flutter G3 roll
>
> Original change's description:
> > [SDK] Switch dds and dtd to use an AOT snapshot
> >
> > TEST=ci
> >
> > Change-Id: Ib65ca1d1a05d3bc7b5f5cab25d90fc459ec8d853
> > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/387133
> > Reviewed-by: Ben Konyi <bkonyi@google.com>
> > Commit-Queue: Siva Annamalai <asiva@google.com>
>
> Change-Id: I9985919063cacfc8673b3e2946eaa163e90c9cc3
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/411200
> Auto-Submit: Ben Konyi <bkonyi@google.com>
> Reviewed-by: Siva Annamalai <asiva@google.com>
> Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
> Commit-Queue: Siva Annamalai <asiva@google.com>

Change-Id: I5ec8e58f905b4ad1d22d507acd8e22e676dc5532
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/410921
Commit-Queue: Siva Annamalai <asiva@google.com>
Reviewed-by: Brian Quinlan <bquinlan@google.com>
2025-02-25 14:32:41 -08:00
Ben Konyi 11ab2dfe2f Revert "[SDK] Switch dds and dtd to use an AOT snapshot"
This reverts commit 6450d76f1f.

Reason for revert: Breaking Flutter G3 roll

Original change's description:
> [SDK] Switch dds and dtd to use an AOT snapshot
>
> TEST=ci
>
> Change-Id: Ib65ca1d1a05d3bc7b5f5cab25d90fc459ec8d853
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/387133
> Reviewed-by: Ben Konyi <bkonyi@google.com>
> Commit-Queue: Siva Annamalai <asiva@google.com>

Change-Id: I9985919063cacfc8673b3e2946eaa163e90c9cc3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/411200
Auto-Submit: Ben Konyi <bkonyi@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
2025-02-20 15:17:16 -08:00
asiva 6450d76f1f [SDK] Switch dds and dtd to use an AOT snapshot
TEST=ci

Change-Id: Ib65ca1d1a05d3bc7b5f5cab25d90fc459ec8d853
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/387133
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
2025-02-13 09:11:38 -08:00
Ryan Macnak 2a08770912 [vm] If waiting for an active mutator slot for too long, steal a slot from a thread at a native safepoint.
The thread whose slot was stolen will take the slow path attempting to exit its safepoint and wait to reacquire an active mutator slot.

TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/54687
Change-Id: I49c4c12b38d38d7afa4df6b346c2a464f75ef6e0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/406404
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2025-02-10 09:38:42 -08:00
asiva 7b25ce88d3 [dartdev] Use VmInteropHandler for invoking sub commands
Use VmInteropHandler for invoking sub commands instead of running them
in an isolate. Running sub commands in an isolate causes an increased footprint.
Changing this to use VmInteropHandler avoids the additional memory footprint.

Commands that need to use an AOT runtime for execution now exec the AOT
runtime and run the command.

TEST=ci

Change-Id: Ic96845b19951170effea3dd3619f798e2c72968a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/402781
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
2025-01-16 09:15:01 -08:00
Ben Konyi 7783e61a02 Revert "[dartdev] Use VmInteropHandler for invoking sub commands"
This reverts commit 08252fc9e9.

Reason for revert: https://github.com/dart-lang/sdk/issues/59784

Original change's description:
> [dartdev] Use VmInteropHandler for invoking sub commands
>
> Use VmInteropHandler for invoking sub commands instead of running them
> in an isolate. Running sub commands in an isolate causes an increased footprint.
> Changing this to use VmInteropHandler avoids the additional memory footprint.
>
> Commands that need to use an AOT runtime for execution now exec the AOT
> runtime and run the command.
>
> TEST=ci
>
> Change-Id: If7aed1cab2fec9d9940bd562ad5aa9c4e9a6ac7f
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/398604
> Reviewed-by: Ben Konyi <bkonyi@google.com>
> Reviewed-by: Brian Quinlan <bquinlan@google.com>
> Commit-Queue: Siva Annamalai <asiva@google.com>

Change-Id: I82a997d49a7d52e1fdaa7d75f509603ebe5e51dd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/401901
Reviewed-by: Siva Annamalai <asiva@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
2024-12-20 11:12:00 -08:00
asiva 08252fc9e9 [dartdev] Use VmInteropHandler for invoking sub commands
Use VmInteropHandler for invoking sub commands instead of running them
in an isolate. Running sub commands in an isolate causes an increased footprint.
Changing this to use VmInteropHandler avoids the additional memory footprint.

Commands that need to use an AOT runtime for execution now exec the AOT
runtime and run the command.

TEST=ci

Change-Id: If7aed1cab2fec9d9940bd562ad5aa9c4e9a6ac7f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/398604
Reviewed-by: Ben Konyi <bkonyi@google.com>
Reviewed-by: Brian Quinlan <bquinlan@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
2024-12-17 16:00:02 -08:00
Ryan Macnak 322baef3e1 [io] Exit the isolate during Process.runSync and sleep.
This prevents such an isolate from occupying one of the limited number of mutator slots and blocking other isolates in the same group from running.

TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/51254
Bug: https://github.com/dart-lang/sdk/issues/54687
Bug: https://github.com/dart-lang/sdk/issues/57119
Change-Id: Ic04bbaa7f482d533ad0ecf2c6da17ea9f00c264e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/398927
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2024-12-05 00:16:38 +00:00
Slava Egorov bbd407725e [vm/io,win] Remove Handle::EnsureInitialized
`Handle` objects which used by Windows specific implementation of
`EventHandler` have complicated life cycle and haphazard approach
to locking. This CL is the first in a series of CLs which attempts
to clean this up a bit - with a final goal to avoid recursively
locking `Handle::monitor_`.

In this CL we remove `Handle::EnsureInitialized` method which
was primarily responsible for associating `HANDLE` with
`EventHandler`'s completion port. Instead we move this logic
into `Handle` constructor.

We also cleanup reference counting logic applied to handles which
participate in asynchronous operations: instead of eagerly
incrementing reference count when `HANDLE` is associated with
the completion port we increment it whenever asynchronous operation
is in progress and decrement it when it completes. This makes the
code much simpler to reason about and avoids necessity to write
code like:

    handle->Release();
    handle->Release();

accompanied with comments explaining why we need to drop
two references due to eager increment.

Finally we cleanup the handling of provider-specific extensions
accessed through `WSAIoctl`'s `SIO_GET_EXTENSION_FUNCTION_POINTER`.
We were fetching them for every individual socket instead of
fetching them once and caching them globally.

TEST=ci

Cq-Include-Trybots: luci.dart.try:vm-win-debug-x64-try,pkg-win-release-try,analyzer-win-release-try,vm-win-release-x64-try
Change-Id: Ia8b391b713b1a1afb9df9e931eada6abf97f7854
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/378140
Reviewed-by: Martin Kustermann <kustermann@google.com>
2024-08-06 12:26:19 +00:00
Ryan Macnak eb62be49a6 [vm, io] Assume ProcThreadAttrList functions are available on Windows.
The VM has required Vista since at least cb522bfcd2.

TEST=ci
Change-Id: I6b6d293f1e2821c441482745fef38a07aacf528c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/353231
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2024-02-21 18:27:41 +00:00
Ryan Macnak 3c298dbca5 [vm] Update to constexpr in runtime/bin.
TEST=build
Change-Id: I18fc7cfe725dc978d4b23de6191e455ac7cd75e5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/293800
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2023-04-12 20:32:29 +00:00
Ryan Macnak b68351fbc3 [vm] Update NULL to nullptr in runtime/bin.
TEST=build
Change-Id: Ie3be570c274b0275a995a0f54b5e6ccdfc77ccd3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/292287
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Brian Quinlan <bquinlan@google.com>
2023-04-12 01:11:05 +00:00
Ryan Macnak 63e6041ca9 [vm] Update to variadic FATAL.
TEST=ci
Change-Id: Ic6bc784605e10760bb28ea6df34242336a33b4d0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/286947
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2023-03-06 22:06:59 +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
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
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
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
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
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
Zach Anderson 3db3d8135e [dart:io] Remove error number print from windows process spawning
The error number is already reported in the ProcessException,
and the log print might pollute the result of GetLastError().

TEST=N/A
Change-Id: Ia280d02525e688c1891bb1ff3131b1569a35083e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/185203
Commit-Queue: Zach Anderson <zra@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2021-02-17 06:03:09 +00:00
James Clarke 50a2216b31 Changes to make support WinUWP target
TEST=no new tests added for this change, existing tests should work.
Bug: 43762
Change-Id: I1cc4c18526c0eef62c441567e8a7e55dd3dd8b0d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/167041
Commit-Queue: Siva Annamalai <asiva@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2020-12-04 22:46:12 +00:00
Zach Anderson bbebad9eca [dart:io] Don't treat a file descriptor as a signal o_o;
Prior to this CL, the signal handler finalizer passes a file descriptor
where a signal number is expected.

This went uncaught for awhile since it is innocuous in most cases.
Clearing a signal handler just involves setting it back to the
default. It is not innocuous where the VM chose to override the
default, for example in the case of SIGPIPE. When setting signal
handlers with the dart:io API, if the finalizer for a _NativeSocket
for a signal handler runs, some time later the VM may be killed by
SIGPIPE instead of getting EPIPE from an IO call.

This CL replaces the call in the finalizer with a new call that
expects a file descriptor, and uses the file descriptor to look
up the signal handler that needs to be cleaned up.

Change-Id: I54caa14a556e434872d12fd9acf8c2fcf767b91e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/146080
Commit-Queue: Zach Anderson <zra@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2020-05-04 20:19:18 +00:00
Stuart Morgan 028d37e39f Fix a dangling pointer in Windows CreateProcessW
The startup info structure includes a pointer to an array of IO handles;
this was made from the address of a local variable with a scope that
ended before the call to CreateProcessW, leading to undefined behavior.
In practice this appears to have mostly been working, but it reliably
fails under some build configurations of Flutter using clang.

This gives that array the same lifetime as the rest of the arguments to
CreateProcessW.

Change-Id: I3142353fd19004372a771e0cbaf0ed846ae73b5c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/144520
Commit-Queue: Siva Annamalai <asiva@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2020-04-27 22:29:07 +00:00
Martin Kustermann 0ae869771a [vm] Avoid allocating Monitor/Mutex/... with global initializer, use Init()/Cleanup() functions instead
This CL adds a `dart::embedder::Cleanup()` (we already have `dart::embedder::InitOnce()`).
This allows us to allocate the global state and also tear it down.

As a side-effect this will also not allocate those variables if not
needed, which should fix b/151210948

Change-Id: I3c5c619586380bf27ee863ba026bbc631f243d85
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/139640
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2020-03-17 08:49:52 +00:00
Ryan Macnak 971f4845d7 [build] Remove last platform -> vm and bin -> vm dependencies. Fix some ODR violations.
Change some static_libraries to source_sets to make ODR violations link-time errors.

This is needed to enable (stop suppressing) -fvisibility=hidden in Fuchsia product builds.

Change-Id: I699cec8d4b516beab9cebf9db0a522a7ff99e004
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/99822
Reviewed-by: Zach Anderson <zra@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2019-04-22 20:15:43 +00:00
Zachary Anderson 6523896c6f [dart:io] Adds ProcessStartMode.INHERIT_STDIO
Adds a ProcessStartMode in which the child process inherits the stdio
handles from the parent.

Change-Id: Ibe7b8ae08caccaed827ae0a911a3cced7803cb6b
Reviewed-on: https://dart-review.googlesource.com/36362
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Zach Anderson <zra@google.com>
2018-01-23 22:50:06 +00:00
Zachary Anderson d0295c873c [dart:io] Namespaces for file IO
Fuchsia requires the ability to sandbox Isolates w.r.t. file IO.
When a new Isolate starts, Fuchsia will pass the Isolate an object
called a namespace. We can translate the namespace object into a
file descriptor suitable for passing to the *at() family of
POSIX file system calls. The file system calls will then
have visibility only into the specified namespace.

We also plumb Namespaces through on all the other platforms as well to
make the change easier to test and so that in the future we can
implement e.g. per-isolate cwds.

This change adds a new internal class to dart:io called _Namespace,
which is implemented in a patch file. See:

sdk/lib/io/namespace_impl.dart
runtime/bin/namespace_patch.dart

The embedder can set up a non-default namespace by calling
_Namespace._setupNamespace during Isolate setup.

Instances of _Namespace have a native field that holds a pointer
to a native Namespace object. See:

runtime/bin/namespace.h

Calls from e.g. file_impl.dart are now also passed a
_Namespace object. The implementations in e.g. file.cc and
file_linux.cc then extract the namespace, and use it to compute a
file descriptor and path suitable for passing to e.g. openat().

related US-313

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

Review-Url: https://codereview.chromium.org/3007703002 .
2017-08-30 09:34:36 -07:00
Zachary Anderson 747868f2b1 [dart:io] Remove DART_IO_DISABLED
This was only used by Dartium.

Review-Url: https://codereview.chromium.org/3009523002 .
2017-08-24 11:17:52 -07:00
Zachary Anderson 6cd8a79078 VM: Re-format to use at most one newline between functions
R=asiva@google.com

Review-Url: https://codereview.chromium.org/2974233002 .
2017-07-13 08:08:37 -07:00
Zachary Anderson 4ecf748d5e [dart:io] Fixes a crash in VM shutdown when signals are watched
This CL fixes a crash in VM shutdown which is triggered by Dart programs
that throw unhandled exceptions while watching OS signals.

fixes #30033

R=rmacnak@google.com

Review-Url: https://codereview.chromium.org/2961993002 .
2017-06-28 11:05:07 -07:00
Zachary Anderson bdb4eb6338 [dart:io][windows] Implements RawSynchronousSocket
related #29343
fixes #29333

R=asiva@google.com

Review-Url: https://codereview.chromium.org/2830273002 .
2017-04-21 23:29:52 -07:00
Zachary Anderson 9ce608e89d [dart:io] Adds ProcessInfo.{max,current}Rss. Adds OS::MaxRSS on Fuchsia.
R=rmacnak@google.com

Review-Url: https://codereview.chromium.org/2822943002 .
2017-04-17 14:41:40 -07:00
Ben Konyi ddc4f30d75 Re-land socket refactor with fixes for Windows.
BUG=
R=zra@google.com

Review-Url: https://codereview.chromium.org/2797993005 .
2017-04-05 12:45:31 -07:00
Ben Konyi 0386f7ab6f Reverting until bots clear up.
Revert "Pulled a significant portion of Socket implementation into BaseSocket in order to prepare for the synchronous socket impementations which will also use these common methods."

This reverts commit 0422920142.

Revert "Updated incorrect call to Write in process_win.cc"

This reverts commit 9e1435148b.

Revert "Fixed incorrect call to Write from process_win.cc"

This reverts commit 11dcab2bed3c9ec8ec76bc200206ac202a4a5681.

Fixed incorrect call to Write from process_win.cc

BUG=

Review-Url: https://codereview.chromium.org/2791163004 .
2017-04-03 17:25:47 -07:00