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>
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>
These should be benign as actual state is guarded by
RecorderSynchronizationLock, and disabling and enabling streams can
happen concurrently with threads which actually produce events.
Issue https://github.com/dart-lang/sdk/issues/62038
TEST=ci
Cq-Include-Trybots: luci.dart.try:vm-tsan-mac-release-arm64-try,vm-tsan-linux-release-x64-try
Change-Id: I640b33e0bea475e4a4651ce212e7f91b6a6a6964
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/472860
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
This change fixes the following gcc build errors:
```
../../runtime/vm/simulator_arm.cc:1403:44: error: ‘function’ attribute directive ignored [-Werror=attributes]
1403 | int32_t r4) {
| ^
../../runtime/vm/simulator_arm.cc:1417:47: error: ‘function’ attribute directive ignored [-Werror=attributes]
1417 | double d1) {
| ^
cc1plus: note: unrecognized command-line option ‘-Wno-unused-private-field’ may have been intended to silence earlier diagnostics
cc1plus: all warnings being treated as errors
```
It looks like gcc doesn't support [[no_sanitize("function")]]
attribute, so limit its usage to clang.
TEST=ci
Change-Id: Id054970b9970dd1bf9fec78e97b4dbed5fd12c82
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/471521
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
- copy sanitizer runtime when using ubsan;
- avoid use of winnt.h CONTAINING_RECORD since it triggers ubsan "member access within null-pointer of type" error, use our copy which uses `offsetof`;
- have default virtual destructor in `ValueObject` to avoid ubsan complains about "insufficient space for an object of type 'dart:ValueObject'" at NoTemporaryAllocator use/declaration site;
- have virtual destructor in ZoneAllocated to avoid ubsan complains about "not having enough space to allocate object" at new RegExpEmpty() instantiation site;
- avoid using crashpad with ubsan as it causes dartvm to exit with error code 3;
- switch to windows, mac-friendly `[[gnu::no_sanitize(check)]]` from `__GNUC__` and `__has_feature` checks.
TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/62267
Change-Id: I8b922a8da329af276d4cefaa88fb841cc0457124
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/469840
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
When mixin is applied, its instance members are cloned and copies
of the members would override original members.
This change fixes bugs and improved usability of extendable mixins with
private members:
- All instance members of extendable mixins and mixin classes are
marked as can-be-overridden to allow overriding by cloned members
when mixin is applied.
- TFA no longer takes privacy into account, as private members of
mixins can be overridden by their clones in other libraries.
- Dynamic module validator always unwraps cloned members to originals
before verifying if overriding is allowed. This eliminates overriding
errors between clone(s) and original members of mixins.
TEST=pkg/dynamic_modules/test/data/mixin_private_member1,
pkg/dynamic_modules/test/data/mixin_private_member2
Fixes b/470461203
Fixes b/469094721
Change-Id: If369c42c58e5ea4d707be83b1e7078ee9a8cc3ce
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/470803
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
For structs, we were already loading the size of the struct at
runtime for the size of the memcopy. This CL makes that work for
the `Array`s as well.
TEST=pkg/vm/testcases/transformations/ffi/regress_62087.dart
TEST=tests/ffi/native_assets/asset_absolute_test.dart
Closes: https://github.com/dart-lang/sdk/issues/62087
Change-Id: I15a5796d713879a613971e080d18101111704b9b
Cq-Include-Trybots: dart/try:vm-aot-linux-debug-arm64-try,vm-aot-linux-debug-x64-try,vm-aot-linux-debug-x64c-try,vm-aot-mac-debug-arm64-try,vm-aot-mac-debug-x64-try,vm-aot-obfuscate-linux-release-x64-try,vm-aot-optimization-level-linux-release-x64-try,vm-aot-win-debug-arm64-try,vm-aot-win-debug-x64-try,vm-aot-win-debug-x64c-try,vm-asan-linux-release-arm64-try,vm-asan-linux-release-x64-try,vm-asan-mac-release-arm64-try,vm-asan-win-release-x64-try,vm-dyn-linux-debug-x64-try,vm-dyn-mac-debug-arm64-try,vm-ffi-dyn-mac-debug-simarm64_arm64-try,vm-msan-linux-release-arm64-try,vm-msan-linux-release-x64-try,vm-tsan-linux-release-arm64-try,vm-tsan-linux-release-x64-try,vm-tsan-mac-release-arm64-try,vm-ubsan-linux-release-arm64-try,vm-ubsan-linux-release-x64-try,vm-ubsan-mac-release-arm64-try,vm-ubsan-win-release-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/464706
Reviewed-by: Tess Strickland <sstrickl@google.com>
Reviewed-by: Michael Goderbauer <goderbauer@google.com>
Closures going into shared variables in particular have to be confirmed to capture appropriate values.
BUG=https://github.com/dart-lang/sdk/issues/62179
TEST=run_isolate_group_run_test
Cq-Include-Trybots: luci.dart.try:vm-dyn-linux-debug-x64-try,vm-dyn-mac-debug-arm64-try,vm-aot-dyn-linux-debug-x64-try
Change-Id: I27416773fd77077018739ea4dbcc6e4695e67be8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/469103
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
Inform ASAN and MSAN about reads and writes through FFI pointers or external typed data. Previously we only informed MSAN about writes, which was enough to prevent false positives in foreign code, but gave false negatives for Dart code. This mostly uses the same machinery used for TSAN, and replaces some of the existing MSAN unpoison calls.
Also fixes some marshalling of compounds by value that generate loads extending past the end of the compound.
TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/62221
Change-Id: Ia3573edb5a0aec32b6a57035a63e8f323a655ecc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/467401
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
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>
This CL makes it possible for the Dart VM to start or stop `perf` while
doing GC, which gives a significantly more stable output.
Example usage:
Bash script that creates the correct file handles and calls dart under
`perf stat` based on the arguments given to the script:
```
DART=$1
shift
AOTSNAPSHOT=$1
shift
ctl_dir=/tmp/
ctl_fifo=${ctl_dir}perf_ctl.fifo
test -p ${ctl_fifo} && unlink ${ctl_fifo}
mkfifo ${ctl_fifo}
exec {ctl_fd}<>${ctl_fifo}
ctl_ack_fifo=${ctl_dir}perf_ctl_ack.fifo
test -p ${ctl_ack_fifo} && unlink ${ctl_ack_fifo}
mkfifo ${ctl_ack_fifo}
exec {ctl_fd_ack}<>${ctl_ack_fifo}
perf_ctl_fd=$ctl_fd perf_ctl_fd_ack=$ctl_fd_ack perf stat --delay=-1 --control fd:${ctl_fd},${ctl_fd_ack} -B -e "task-clock:u,context-switches:u,cpu-migrations:u,page-faults:u,cycles:u,instructions:u,branch-misses:u" $DART --perf_ctl_fd=${ctl_fd} --perf_ctl_fd_ack=${ctl_fd_ack} --perf_ctl_usage=1 --deterministic $AOTSNAPSHOT $@
exec {ctl_fd_ack}>&-
unlink ${ctl_ack_fifo}
exec {ctl_fd}>&-
unlink ${ctl_fifo}
```
This will start `perf stat` paused (which would require the run dart
aot-compiled script to start it when it wants to) and where the VM
pauses `perf` while doing GC.
In practise, looking at instruction counts reported by `perf stat`, I've
seen the difference between runs go from 2+ mio (and in some instances
23+ mio) to around 30,000 (!) on runs of the analyzer (tool
"stable_analysis").
TEST=manually
Change-Id: Iab955a5dd35e47f22c4f693ae50effc8ee633897
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/468260
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
Thread::OffsetFromThread from runtime_api.cc assumed that all fields
between leaf and non-leaf runtime entries in Thread have word size,
so the delta between runtime entries can be translated from host to
target by multiplying by the ratio between target and host word size.
Since leaf and non-leaf runtime entries are not co-located in Thread,
this assumption is incorrect. It is now fixed by using separate
bases when calculating offsets of leaf and non-leaf runtime entries.
Also, add FatalError runtime entry which is useful for
bootstrapping of the new compiler.
TEST=ci
Issue: https://github.com/dart-lang/sdk/issues/61635
Change-Id: Iea4762b21285aa6423876b34328c863227ee1434
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/467900
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
For entry/exit frames for compiled code, print that it's an entry or
exit frame like with interpreted code instead of printing the stub name
(with an erroneous offset for exit frames, since the pc of exit frames
is always 0).
While there are two possible stubs for entry frames (InvokeDartCode
vs. InvokeDartCodeFromBytecode), which is in use can be determined
from the preceding exit frame (if any).
TEST=ci (manual testing using --trace-debugger-stacktrace)
Change-Id: I7013e08fbc635f68400c9cdfa97837905121ccf8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/467860
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
Processor thread might end up entering a safepoint while holding the
processor's monitor which will make thread calling Cleanup deadlock
while trying to acquire the monitor.
Use SafepointMonitorLocker instead to avoid this. Startup is unlikely
to exhibit this situation but we change it as well for symmetry.
TEST=manually, as reliably hitting this is hard
Change-Id: Ifb88a0418be064450374503bfc485e576a6a6964
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/467801
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
Add missing byte and halfword compare-and-swap.
Add missing clear of reservation after SC.
Define XLEN aliases for the AMOs.
Add wait-on-reservation-set.
More systematically print state on fault.
TEST=ci
Change-Id: Ia07e638a6e08cd40eecc1f8f7d242fd94ef2f2d4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/467200
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
Improves the readability of the tracing output by adding beginning and
ending markers for debugger stacktrace collection and using specific
spacing instead of \t in output, so that output is more naturally nested
via indention:
* beginning/ending markers are not indented,
* frames are indented by two spaces, and
* additional output while collecting a frame is indented by four spaces.
Adds tracing for DebuggerStackTrace::CollectAsyncAwaiters(). A different
ending marker is used in the case when the collected trace is discarded
due to a lack of async awaiters.
ActivationFrame::GetSavedCurrentContext now takes an optional out
parameter for the current context variable index, which is only used by
CollectDartFrame and used to print the index there. This eliminates
extra output when this method is used outside collecting stack traces.
When the current context variable index is requested,
GetSavedCurrentContext ignores the cached context if any so that the
index is appropriately set if an appropriate variable is found.
By default, skips tracing of non-collected frames and repeated async
suspensions in async awaiter traces. Use the new
--trace-debugger-stacktrace-verbose flag to add tracing for these cases.
TEST=ci (tested manually, only affects debugging output)
Change-Id: I2978d540f41b444251a61b62a57b6785a3dd8df0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/467300
Auto-Submit: Tess Strickland <sstrickl@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>