Commit Graph

82 Commits

Author SHA1 Message Date
Ryan Macnak 9f929d1fcf [vm] Get SP without using VM generated stubs.
TEST=ci
Change-Id: Ie976408ff3cf5691a59081b7b405abe43d7adcc3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/493165
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2026-04-07 08:06:43 -07:00
Ryan Macnak 1d0195cad4 [vm] Use C++11 thread_local for TLS destructors.
Removes linker hack on Windows.

TEST=ci
Change-Id: Ib031f8f05e422084fa6652fee425f8e46884840e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/490341
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2026-03-25 11:58:38 -07:00
Slava Egorov 0fee95455c [vm] Cleanup Profiler lifecycle
Move away from setting command line flags and calling Cleanup or Init
to reinitialize the profiler. Split starting and stopping the profiler
into separate methods and keep only one-time initialization/cleanup
in Init and Cleanup methods. Create a separate method for reconfiguring
the profiler Profiler::SetConfig.

This removes data races which were plaguing older code and makes it
simpler to reason about.

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

TEST=ci

Cq-Include-Trybots: luci.dart.try:vm-tsan-mac-release-arm64-try,vm-tsan-linux-release-x64-try
Change-Id: I679aa0a8724e39624e76abfad6814fe06a6a6964
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/472862
Commit-Queue: Slava Egorov <vegorov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2026-01-20 05:58:38 -08:00
Slava Egorov 832a205895 [vm] Drop Android 6.0.0 specific workaround
Flutter does not support Android versions below Android 7 (API level 
24).

Simplify the code by removing workaround introduced in 
a013de84e0 to work-around crashes
which only happen on Android 6.0.0.

TEST=ci

Cq-Include-Trybots: luci.dart.try:vm-aot-android-release-arm_x64-try,vm-aot-android-release-arm64c-try
Change-Id: Ib29535e66e87b17bc9b2ac72bcbb46e06a6a6964
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/472861
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2026-01-14 03:53:04 -08:00
Vyacheslav Egorov 489f63a3bd [vm] Add NativeRuntime.streamTimelineTo
This API allows to programmatically generate timeline information 
including profiling samples if timeline format supports it.

This change also includes Perfetto timeline writer and profiler 
into non-mobile PRODUCT builds. The size of Mac OS X dartaotruntime
has increased by 34352 bytes (0.7%).

This relands commit 553887bc56 with fixes
for Android builds.

TEST=vm/dart/stream_timeline_to_test

CoreLibraryReviewExempt: VM specific dart:developer API.
Cq-Include-Trybots: luci.dart.try:vm-ffi-android-product-arm-try,vm-ffi-android-release-arm-try,vm-aot-android-release-arm64c-try
Change-Id: Ifb7c66982fe9d17d2f5c9acb163a94c56a6a6964
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/457301
Commit-Queue: Slava Egorov <vegorov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2025-10-24 04:34:01 -07:00
Slava Egorov b24698b9b5 Revert "[vm] Add NativeRuntime.streamTimelineTo"
This reverts commit 553887bc56.

Reason for revert: Broken android builds

Original change's description:
> [vm] Add NativeRuntime.streamTimelineTo
>
> This API allows to programmatically generate timeline information 
> including profiling samples if timeline format supports it.
>
> This change also includes Perfetto timeline writer and profiler 
> into non-mobile PRODUCT builds. The size of Mac OS X dartaotruntime
> has increased by 34352 bytes (0.7%).
>
> TEST=vm/dart/stream_timeline_to_test
>
> CoreLibraryReviewExempt: VM specific dart:developer API.
> Change-Id: I326f5fd29ee82a503160f5f5a2a857a7c55330ec
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/426220
> Reviewed-by: Ryan Macnak <rmacnak@google.com>
> Commit-Queue: Slava Egorov <vegorov@google.com>

No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Change-Id: I583ad74b850514fb47054149da464a07874fc2f6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/457000
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
2025-10-23 04:58:29 -07:00
Vyacheslav Egorov 553887bc56 [vm] Add NativeRuntime.streamTimelineTo
This API allows to programmatically generate timeline information 
including profiling samples if timeline format supports it.

This change also includes Perfetto timeline writer and profiler 
into non-mobile PRODUCT builds. The size of Mac OS X dartaotruntime
has increased by 34352 bytes (0.7%).

TEST=vm/dart/stream_timeline_to_test

CoreLibraryReviewExempt: VM specific dart:developer API.
Change-Id: I326f5fd29ee82a503160f5f5a2a857a7c55330ec
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/426220
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2025-10-23 04:47:13 -07:00
Ryan Macnak a4a5bc4fc9 [vm] Fix TSAN crashes due to TSAN's own overflow.
TEST=vm/cc/DartAPI_StackOverflow
Change-Id: If5456f4f0a194332b38901f9bd677f3cd9af561c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/456421
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2025-10-21 15:57:35 -07:00
Ryan Macnak f1ba8ceacf [vm] Make some IgnoreRace functions inlinable.
Fix GCC TSAN build.
Cleanup sanitizer includes.

TEST=ci
Change-Id: Ib68bbfa701b4309c03514ed689391051094208e4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/452226
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2025-10-01 09:41:26 -07:00
Ryan Macnak ccbd0c6129 [vm] Avoid reordered stores during Thread::SuspendStateInternal.
The profiler will crash if the signal handler runs between clearing the OSThread from the Thread and setting the TLS to the OSThread if they are reordered. The window here is much larger on Android because of Android's slow emutls. This doesn't affect standalone Dart because the two stores are in different translation units, but Flutter uses LTO.

TEST=flutter
Bug: https://github.com/flutter/flutter/issues/143178
Change-Id: I96a4d154083949f6bdd33a17a75a88d611c9a34a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/388743
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2024-10-08 20:36:14 +00:00
Ryan Macnak 0c3606f0ec [vm] Systematically check for failure to start thread.
Improve error message to include the intended thread name and strerror.

TEST=ci
Change-Id: Iba61a40b312f6574e8e352d51a0c3de535f6a0c0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/386361
Reviewed-by: Brian Quinlan <bquinlan@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2024-09-24 22:41:40 +00:00
Vyacheslav Egorov e2efffa005 [vm] Simplify implementation of native ports
This reland commit 5a32d8bc7c with a fix
for thread leak (Issue #56717): when `ThreadPool` is shutting down
asynchronously the last worker should detach itself to prevent
leaking associated low-level data structures, because no thread will
join it.

A hang in service isolate shutdown (caused by an existing bug) was fixed by commit 157a0dc7f9.

This CL turns native ports into a thin abstraction over underlying
thread pool instead of building them as full fledged MessageHandler.

This allows to easily implement a variation of native ports which can
handle messages concurrently with the given degree of concurrency.
This type of port can be used to greatly simplify implementation of
IOService - which previously had to do its own concurrency management
on top of "single threaded" native ports. This capability is exposed
as `Dart_NewConcurrentNativePort` API.

The new implementation is in general much cleaner then the old one
with one exception: `Dart_CloseNativePort` API has unfortunate design
where underlying message handler is destroyed asynchronously and
`Dart_CloseNativePort` returns immediately without waiting for pending
tasks to complete. Implementing this on top of `ThreadPool` requires
some changes to thread pool implementation.

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

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

TEST=ci

Change-Id: Ic68bfb60757685afd75c80a70cdec66cc13c149b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/385000
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2024-09-12 15:16:12 +00:00
Slava Egorov 120dac365d Revert "[vm] Simplify implementation of native ports"
This reverts commit 5a32d8bc7c.

Reason for revert: DartIsolateTest.CanCreateServiceIsolate flutter engine unit test hangs on Windows.

Original change's description:
> [vm] Simplify implementation of native ports
>
> This CL turns native ports into a thin abstraction over underlying
> thread pool instead of building them as full fledged MessageHandler.
>
> This allows to easily implement a variation of native ports which can
> handle messages concurrently with the given degree of concurrency.
> This type of port can be used to greatly simplify implementation of
> IOService - which previously had to do its own concurrency management
> on top of "single threaded" native ports. This capability is exposed
> as `Dart_NewConcurrentNativePort` API.
>
> The new implementation is in general much cleaner then the old one
> with one exception: `Dart_CloseNativePort` API has unfortunate design
> where underlying message handler is destroyed asynchronously and
> `Dart_CloseNativePort` returns immediately without waiting for pending
> tasks to complete. Implementing this on top of `ThreadPool` requires
> some changes to thread pool implementation.
>
> Issue https://github.com/dart-lang/sdk/issues/55844
>
> TEST=ci
>
> Change-Id: I062040ff233e93962ae93684e9b044d8facdaffc
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/382163
> Commit-Queue: Slava Egorov <vegorov@google.com>
> Reviewed-by: Martin Kustermann <kustermann@google.com>

Change-Id: I7de27793a54072e974bf1a9f17a07c12159a202d
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/384481
Commit-Queue: Slava Egorov <vegorov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
2024-09-12 08:25:27 +00:00
Vyacheslav Egorov 5a32d8bc7c [vm] Simplify implementation of native ports
This CL turns native ports into a thin abstraction over underlying
thread pool instead of building them as full fledged MessageHandler.

This allows to easily implement a variation of native ports which can
handle messages concurrently with the given degree of concurrency.
This type of port can be used to greatly simplify implementation of
IOService - which previously had to do its own concurrency management
on top of "single threaded" native ports. This capability is exposed
as `Dart_NewConcurrentNativePort` API.

The new implementation is in general much cleaner then the old one
with one exception: `Dart_CloseNativePort` API has unfortunate design
where underlying message handler is destroyed asynchronously and
`Dart_CloseNativePort` returns immediately without waiting for pending
tasks to complete. Implementing this on top of `ThreadPool` requires
some changes to thread pool implementation.

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

TEST=ci

Change-Id: I062040ff233e93962ae93684e9b044d8facdaffc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/382163
Commit-Queue: Slava Egorov <vegorov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2024-09-11 13:38:24 +00:00
Ryan Macnak 2719e10bfa [vm, timeline] Include thread names when using the file recorder.
TEST=ci
Change-Id: I95fb30d4da30dcdb0ee725827120e266133af2b8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/384581
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Derek Xu <derekx@google.com>
2024-09-10 21:07:18 +00:00
Ryan Macnak 639f6735a8 [vm] Don't rely on UB in OSThread::GetCurrentStackPointer.
TEST=ci
Change-Id: Ic0fd502148ed4666140849f9d6e2af3006818b03
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/350694
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2024-02-21 22:13:09 +00:00
Derek Xu 2428382e9c [VM/Timeline] Fix race between Timeline::Cleanup() and OSThread's destructor
TEST=checked that the timeline still worked correctly in DevTools, used
ASAN and TSAN to check that this change doesn't introduce new problems

Issue: https://github.com/flutter/flutter/issues/136402
Change-Id: Ic63a067aed21fefa890c49c73a73f60979f1e809
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/330320
Commit-Queue: Derek Xu <derekx@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2023-10-12 16:58:27 +00:00
Vyacheslav Egorov ec6def53de [vm] Explicitly exclude interrupt related state in PRODUCT
This is follow up for the previous change somewhat incorrectly used
FLAG_profiler in ~OSThread to determine whether we need to delete
interrupter related state. FLAG_profiler is mutable in non-PRODUCT
builds so this could create memory leak.

TEST=testing PRODUCT and non-PRODUCT builds manually

Change-Id: Icf5ca6b83daab91daa125755261700ba2dbb9533
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/328422
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2023-09-28 19:53:33 +00:00
Vyacheslav Egorov a013de84e0 [vm] Reserve larger alternative signal stack if needed
Commit 18bdb28ef6 have configured `SIGPROF` handler on Android
to use alternative signal stack to workaround a [bug][1] in Bionic
implementation of `setjmp`. However when implementing the
workaround we have misinterpreted `sigaltstack` documentation
and assumed that `sigaltstack` configures alternative stack
*globally*, similar to how `sigaction` configures the signal handler.
This is not correct: `sigaltstack` configures alternative stack
for the current thread only.

Nevertheless our workaround kinda worked as intended because Bionic's
`pthread_create` actually assigns an individual alternative
stack to each new thread since [Android L][2].

However older version of Bionic (pre [Android 6.0.1][3]) configured
alternative signal stack which was too small for ARM64. This meant
that non-trivial signal handler could easily overflow the stack
and cause a SIGSEGV when hitting a guard page.

This is what we observe in the flutter/flutter#130003: launching
Flutter application with profiler enabled in a ARM64 emulator
running Android 6.0 causes an immediate segfault in the
signal handler.

This CL changes our code to make sure that alternative signal
stack associated with the current thread is present and is large
enough and allocate a new one if it is not.

[1]: b/152210274
[2]: https://android-review.git.corp.google.com/c/platform/bionic/+/62238
[3]: https://android-review.git.corp.google.com/c/platform/bionic/+/172213
[4]: https://github.com/flutter/flutter/issues/130003

TEST=manually on an Android 6.0.0 ARM64 emulator

Cq-Include-Trybots: luci.dart.try:vm-aot-android-release-arm64c-try,vm-ffi-android-release-arm64c-try,vm-ffi-android-release-arm-try
Change-Id: Ib87df25e72ad3f486e90cf2fc6d7f980a8e0b1dc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/327866
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2023-09-27 15:11:05 +00:00
Derek Xu f0310b5b7c [VM/Timeline] Change locking scheme used by TimelineEventRingRecorder to prevent races
TEST=Loaded the timeline in DevTools on a debug build with the recorder
set to ring, endless, and startup. Recorded traces on a debug build with
the recorder set to systrace, file, and perfettofile. Ran the
vm/cc/TimelineRingRecorderRace test on ASAN and TSAN.

Issue: https://github.com/flutter/flutter/issues/129258
Change-Id: I39920ac3e4a70e5714915fcd554ae171ed82504a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/312721
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Derek Xu <derekx@google.com>
2023-07-10 20:33:33 +00:00
Ryan Macnak f9a6a5bdd2 [vm] Update NULL to nullptr in runtime/vm.
TEST=build
Change-Id: I2834ef7cf7cb7c8770f8167a2438cbedcee5c623
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/292063
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2023-04-10 18:15:12 +00:00
Ryan Macnak e31c3713bf Reland "[build, vm] Access TLS with less code."
- Avoid TLS initialization checks by using inline initialization.
 - Avoid global offset table indirection by reducing -fPIC to -fPIE.

out/ReleaseXARM64/exe.stripped/dart_precompiled_runtime
11137992 -> 11274776 (-1.21%)

We still need -fPIC in some places because we build a few shared libraries for FFI, so copy some of Fuchsia's GN setup to use -fPIE or -fPIC as appropriate.

Account for older gcc that does not default to -fpie.

TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/51602
Change-Id: I85072153cb1aef9047c1adbf36c7496fbeb11e10
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/286221
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2023-03-02 23:07:16 +00:00
William Hesse ec53fdd0bf Revert "[build, vm] Access TLS with less code."
This reverts commit aa79cf2708.

Reason for revert: -fPIC is needed in more places than the CL adds it to, see CI builds at https://ci.chromium.org/ui/p/dart-internal/builders/ci/dart-sdk-linux-riscv64-dev/405/overview

Original change's description:
> [build, vm] Access TLS with less code.
>
> - Avoid TLS initialization checks by using inline initialization.
> - Avoid global offset table indirection by reducing -fPIC to -fPIE.
>
> out/ReleaseXARM64/exe.stripped/dart_precompiled_runtime
> 11137992 -> 11274776 (-1.21%)
>
> We still need -fPIC in some places because we build a few shared libraries for FFI, so copy some of Fuchsia's GN setup to use -fPIE or -fPIC as appropriate.
>
> TEST=ci
> Change-Id: I6402fce3366a9c4b2741ffb4811562292b8ecb71
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/285704
> Commit-Queue: Ryan Macnak <rmacnak@google.com>
> Reviewed-by: Daco Harkes <dacoharkes@google.com>

Change-Id: Idacb7869e9fa9ad0f7ed7b0caa2bae19deece7d0
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/286144
Reviewed-by: Martin Kustermann <kustermann@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Auto-Submit: William Hesse <whesse@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2023-03-01 12:19:07 +00:00
Ryan Macnak aa79cf2708 [build, vm] Access TLS with less code.
- Avoid TLS initialization checks by using inline initialization.
- Avoid global offset table indirection by reducing -fPIC to -fPIE.

out/ReleaseXARM64/exe.stripped/dart_precompiled_runtime
11137992 -> 11274776 (-1.21%)

We still need -fPIC in some places because we build a few shared libraries for FFI, so copy some of Fuchsia's GN setup to use -fPIE or -fPIC as appropriate.

TEST=ci
Change-Id: I6402fce3366a9c4b2741ffb4811562292b8ecb71
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/285704
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
2023-03-01 01:21:55 +00:00
Ryan Macnak 347c49354e [vm] Lock-free management of the profiler's sample blocks.
Add asserts against using mutexes or monitors during the signal handler or suspended thread scopes. Poison use of Thread::Current during these scopes.

TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/51124
Change-Id: If1df06520114105b2b4d8c81b4650bdb4efeaf50
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/283703
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2023-02-21 19:07:57 +00:00
asiva 7ef8c77ad2 [VM/Runtime] Fuse the shutdown and initialization states in the timeline
recorder under a single synchronization scope.

TEST=ci

Change-Id: Iff41297427674b307a8ed0cdef9c3010a15ca03e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/283481
Reviewed-by: Derek Xu <derekx@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
2023-02-17 00:23:18 +00:00
Derek Xu 52a5f4d9cd [VM/Timeline] Prevent races between reading / modifying the value of Timeline::recorder_
TEST=Checked that the problem described in the GitHub issue has been resolved.

Fixes https://github.com/dart-lang/sdk/issues/51408
Change-Id: I688d32a7cdd81b4f877e212d4f1376735013175c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/283141
Commit-Queue: Derek Xu <derekx@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2023-02-15 17:52:59 +00:00
Derek Xu ec876310e0 [VM/Timeline] Rename RecorderLock to RecorderShutdownSynchronizationLock to make its purpose clearer
TEST=CI

Change-Id: I433bf456fd6f86a76469cb0f0b1f5156871b2edb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/283140
Reviewed-by: Ben Konyi <bkonyi@google.com>
2023-02-15 17:52:59 +00:00
Derek Xu 94f9fba3ce Reland "[VM/Timeline] Add test that makes TSAN check the track metadata map"
TEST=MSVC tryjob

This is a reland of commit d9f1aefe9e

Original change's description:
> Reland "[VM/Timeline] Add test that makes TSAN check the track metadata map"
>
> This is a reland of commit 8a39d781ce
>
> Fixed by changing accidental usages of `kInvalidThreadId` to
> `kInvalidThreadJoinId`.
>
> TEST=Windows tryjobs
>
> Original change's description:
> > [VM/Timeline] Add test that makes TSAN check the track metadata map
> >
> > TEST=CI
> >
> > Change-Id: I9e4fa4bbc08e77a1365e84f2d048384d7f0b1350
> > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/281720
> > Reviewed-by: Ben Konyi <bkonyi@google.com>
> > Commit-Queue: Derek Xu <derekx@google.com>
>
> Fixes https://github.com/dart-lang/sdk/issues/51328
> Change-Id: I9219ed9bee212ecb50e3d0a0ed639d3ac8676238
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/281920
> Reviewed-by: Ben Konyi <bkonyi@google.com>
> Commit-Queue: Derek Xu <derekx@google.com>

Change-Id: I6bcc9e02c1ac1e35ba08559d3098ba0cf69b7eba
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/282360
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Derek Xu <derekx@google.com>
2023-02-10 18:05:00 +00:00
Derek Xu 41d6db8ce5 Revert "Reland "[VM/Timeline] Add test that makes TSAN check the track metadata map""
This reverts commit d9f1aefe9e.

Reason for revert: broke vm-kernel-msvc-windows

Original change's description:
> Reland "[VM/Timeline] Add test that makes TSAN check the track metadata map"
>
> This is a reland of commit 8a39d781ce
>
> Fixed by changing accidental usages of `kInvalidThreadId` to
> `kInvalidThreadJoinId`.
>
> TEST=Windows tryjobs
>
> Original change's description:
> > [VM/Timeline] Add test that makes TSAN check the track metadata map
> >
> > TEST=CI
> >
> > Change-Id: I9e4fa4bbc08e77a1365e84f2d048384d7f0b1350
> > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/281720
> > Reviewed-by: Ben Konyi <bkonyi@google.com>
> > Commit-Queue: Derek Xu <derekx@google.com>
>
> Fixes https://github.com/dart-lang/sdk/issues/51328
> Change-Id: I9219ed9bee212ecb50e3d0a0ed639d3ac8676238
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/281920
> 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: Iea36a34a392a51b53699527a7af36b93f924057f
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/282340
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Derek Xu <derekx@google.com>
2023-02-10 13:49:06 +00:00
Derek Xu d9f1aefe9e Reland "[VM/Timeline] Add test that makes TSAN check the track metadata map"
This is a reland of commit 8a39d781ce

Fixed by changing accidental usages of `kInvalidThreadId` to
`kInvalidThreadJoinId`.

TEST=Windows tryjobs

Original change's description:
> [VM/Timeline] Add test that makes TSAN check the track metadata map
>
> TEST=CI
>
> Change-Id: I9e4fa4bbc08e77a1365e84f2d048384d7f0b1350
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/281720
> Reviewed-by: Ben Konyi <bkonyi@google.com>
> Commit-Queue: Derek Xu <derekx@google.com>

Fixes https://github.com/dart-lang/sdk/issues/51328
Change-Id: I9219ed9bee212ecb50e3d0a0ed639d3ac8676238
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/281920
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Derek Xu <derekx@google.com>
2023-02-09 16:25:14 +00:00
Alexander Aprelev ec6712542c Revert "[VM/Timeline] Add test that makes TSAN check the track metadata map"
This reverts commit 8a39d781ce.

Reason for revert: https://github.com/dart-lang/sdk/issues/51328 - breaks windows buildbot

Original change's description:
> [VM/Timeline] Add test that makes TSAN check the track metadata map
>
> TEST=CI
>
> Change-Id: I9e4fa4bbc08e77a1365e84f2d048384d7f0b1350
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/281720
> 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: I1228676f3a6a3e622b47a3e15f2b40b2e68fe676
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/281865
Reviewed-by: Alexander Aprelev <aam@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2023-02-08 21:55:43 +00:00
Derek Xu 8a39d781ce [VM/Timeline] Add test that makes TSAN check the track metadata map
TEST=CI

Change-Id: I9e4fa4bbc08e77a1365e84f2d048384d7f0b1350
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/281720
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Derek Xu <derekx@google.com>
2023-02-08 19:57:48 +00:00
Derek Xu e6d5d32d3b Reland "[VM/Timeline] Improve handling of track metadata"
This is a reland of commit 3787601dd0

TEST=CI, TSAN, ASAN, and I manually checked that more track names are
populated when the changes in this CL are applied.

Original change's description:
> [VM/Timeline] Improve handling of track metadata
>
> The track information that we send over the service is currently
> incomplete. Since we only iterate over the threads that exist at the
> time when getVMTimeline is called, we're missing information about any
> threads that were joined before that. This CL fixes this issue.
>
> TEST=CI, ASAN, and I manually checked that more track names are
> populated when the changes in this CL are applied.
>
> Change-Id: Ic4edc9910884c3f4743dc0ca65aa7d2a695ff09d
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/280058
> Reviewed-by: Ben Konyi <bkonyi@google.com>
> Commit-Queue: Derek Xu <derekx@google.com>

Change-Id: I5e56d8cff6a6d641bc9a7ac51f8df4cdf78082c9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/281200
Reviewed-by: Ben Konyi <bkonyi@google.com>
2023-02-08 19:57:48 +00:00
Derek Xu 5577eafdba [VM] Add OSThread::GetCurrentThreadName() method
Some fields of `OSThread` are initialized by retrieving information by
calling OS functions. For example, `trace_id_` is initialized by calling
`OSThread::GetCurrentThreadTraceId()`. Similarly, this CL adds the
`OSThread::GetCurrentThreadName()` method and uses it to initialize
`name_`.

TEST=CI

Change-Id: Iee121d71e660be01ff684a298144fa7d59e3b61d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/278662
Commit-Queue: Derek Xu <derekx@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2023-01-31 22:37:30 +00:00
Josh Soref 0633041729 Spelling runtime vm
Closes https://github.com/dart-lang/sdk/pull/50786

TEST=ci

GitOrigin-RevId: 781a38e2925ba505f0223ecd578faa9be8e1485c
Change-Id: Ia3c615012d1bac3f0cf64dc01c2ceb40d50d1193
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/276684
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2022-12-29 10:18:02 +00:00
Ryan Macnak 700969604a [vm] Require C11 thread_local support.
Thus requiring iOS 9+.

TEST=build
Change-Id: I40062753ae030231d4e4ae428c9145f4370cb9a0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/213283
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Chinmay Garde <chinmaygarde@google.com>
2021-09-13 19:30:30 +00:00
Alexander Aprelev 8ce78ca107 [vm/msan] Fix msan error triggered when building debug gen_snapshot.
Fixes https://github.com/dart-lang/sdk/issues/43433.

Change-Id: Ia7558251ab7a6115c3e0092ad57011e7e1f42340
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/163722
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2020-09-21 19:42:42 +00:00
Martin Kustermann 3d53df52af Revert "[vm] Call OSThread::Cleanup() during VM shutdown (as with all other Init/Cleanup functions)"
See b/157883819: Custom embedder doesn't correctly join threads that
interacted with Dart API, which causes us to hit the newly added
RELEASE_ASSERT.

This reverts commit ea4b17533c.

Change-Id: I9fec45196646f67ae46efccc2f83a43e8941a626
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/149592
Reviewed-by: David Morgan <davidmorgan@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2020-06-02 13:25:01 +00:00
Martin Kustermann ea4b17533c [vm] Call OSThread::Cleanup() during VM shutdown (as with all other Init/Cleanup functions)
Change-Id: I3cfa51714247a62fe39951636ca1a75c34f6c95b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/149293
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2020-05-29 08:02:59 +00:00
Ryan Macnak 16253c0a54 [vm] Fix LSAN when used without ASAN.
Mostly interesting on Mac, where ASAN does not include LSAN.

Bug: https://github.com/dart-lang/sdk/issues/41811
Change-Id: Icbbe57946a6d3b3406a9e3a6541b6c4958cbfa91
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/147685
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2020-05-12 17:38:19 +00:00
Ryan Macnak c873220e43 [vm, arm64] Adjust CSP during the invocation stub instead of each function prologue.
Since 6e2c4636cd, we have more reliable information about the stack limit.

This saves 8 bytes from each function.

Flutter Gallery:
Instructions(CodeSize): 6491472 ->  6375472 (-1.79%)
Total(CodeSize):       10375882 -> 10258802 (-1.13%)

Bug: https://github.com/dart-lang/sdk/issues/26472
Bug: https://github.com/dart-lang/sdk/issues/39083
Change-Id: I1d8e4c4bfd858eca1d0e4e5640faae15f4dbbe8e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/122845
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2019-10-25 19:21:56 +00:00
Ryan Macnak 86af66a3ee Revert "[vm, arm64] Adjust CSP during the invocation stub instead of each function prologue."
This reverts commit b5b322962a.

Reason for revert: low frequency of crashes in service tests

Original change's description:
> [vm, arm64] Adjust CSP during the invocation stub instead of each function prologue.
> 
> Since 6e2c4636cd, we have more reliable information about the stack limit.
> 
> This saves 8 bytes from each function.
> 
> Flutter Gallery:
> Instructions(CodeSize): 6491472 ->  6375472 (-1.79%)
> Total(CodeSize):       10375882 -> 10258802 (-1.13%)
> 
> Bug: http://dartbug.com/26472
> Change-Id: Ief1ddd25eecd32a8314c71fdb470dd73046e5dc0
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/122408
> Commit-Queue: Ryan Macnak <rmacnak@google.com>
> Reviewed-by: Alexander Markov <alexmarkov@google.com>

TBR=rmacnak@google.com,alexmarkov@google.com,ajcbik@google.com

Change-Id: I0b45e1c81c1534e123dd85d27b7af27217e08795
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: http://dartbug.com/26472
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/122725
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2019-10-24 04:12:16 +00:00
Ryan Macnak b5b322962a [vm, arm64] Adjust CSP during the invocation stub instead of each function prologue.
Since 6e2c4636cd, we have more reliable information about the stack limit.

This saves 8 bytes from each function.

Flutter Gallery:
Instructions(CodeSize): 6491472 ->  6375472 (-1.79%)
Total(CodeSize):       10375882 -> 10258802 (-1.13%)

Bug: http://dartbug.com/26472
Change-Id: Ief1ddd25eecd32a8314c71fdb470dd73046e5dc0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/122408
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2019-10-24 02:40:43 +00:00
Ryan Macnak f4f0831c69 [vm] Fix TSAN failures related to object headers and GC task phases.
Change-Id: I15078e845712e8e712e2cb0a044fc7550127ea36
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/120629
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2019-10-09 21:48:20 +00:00
Matthew Dempsky 6d5f763952 [vm] Eliminate Mutex/Monitor indirection where possible
In many cases, the Mutexes and Monitors have to be marked "mutable"
because they're used to synchronize const accessor methods.

Small text segment improvement for Product builds:

$ size dart.{arm,x64}.{before,after}
   text	   data	    bss	    dec	    hex	filename
19726069	 409960	 392332	20528361	1393ce9	dart.arm.before
19725525	 409960	 392332	20527817	1393ac9	dart.arm.after
22576021	 600376	1782824	24959221	17cd8f5	dart.x64.before
22574821	 600376	1782824	24958021	17cd445	dart.x64.after

Change-Id: I68f5cd5ad452044df8bfebd160910496036a3e6b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/101745
Commit-Queue: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2019-05-13 21:17:51 +00:00
Liam Appelbe 924a934fe1 Shrink the stack headroom if the stack is very small
Bug: https://github.com/dart-lang/sdk/issues/36100
Change-Id: I9d887e74c7f888dbeebaf02556522d375e30b97f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/95703
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Liam Appelbe <liama@google.com>
2019-03-07 17:32:59 +00:00
Liam Appelbe df59b09756 Fail early if a thread has no stack headroom
Bug: https://github.com/dart-lang/sdk/issues/35745
Change-Id: I6a9dff8608385d4dde74a16b6d4dea42fe91460f
Reviewed-on: https://dart-review.googlesource.com/c/95041
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Liam Appelbe <liama@google.com>
2019-03-01 22:34:21 +00:00
Ryan Macnak 06a1e6e9e3 [vm] Enable timeline on Fuchsia even in product mode.
On Fuchsia, the timeline is accessed without involving the service isolate or vm-service.

Change-Id: Ia0d4e1ca252604e8fcef466a31e3d2a8b0912251
Reviewed-on: https://dart-review.googlesource.com/c/90100
Reviewed-by: Zach Anderson <zra@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2019-01-18 00:06:10 +00:00
Ryan Macnak 07f95e7761 Revert "[vm] Enable timeline on Fuchsia even in product mode."
This reverts commit 3f7b371f2c.

Reason for revert: Some modes failing to find new constant?

Original change's description:
> [vm] Enable timeline on Fuchsia even in product mode.
> 
> On Fuchsia, the timeline is accessed without involving the service isolate or vm-service.
> 
> Change-Id: I0d2351dcadcfc47835732235e1b8fafa8212f883
> Reviewed-on: https://dart-review.googlesource.com/c/89880
> Reviewed-by: Zach Anderson <zra@google.com>
> Commit-Queue: Ryan Macnak <rmacnak@google.com>

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

Change-Id: Ic03a78d14821e0361d54587f1f7510bc9ebfef1c
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/89942
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2019-01-17 00:39:39 +00:00