Commit Graph

22181 Commits

Author SHA1 Message Date
Roy c9ba43db45 [vm] Adding static_field_offset to Field objects.
This adds the offset of static fields within their field table.

TEST=vm/dart/analyze_snapshot_binary_test

Change-Id: I90b13760fa3203ca2e3c5611e3fd890a74c97728
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/429880
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2025-05-23 12:45:41 -07:00
Alexander Aprelev 6497b412e2 [vm/shared] Ensure dart mutator thread stack is walked during gc.
Fix asynchronous aspect of the test.

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

Change-Id: Ife311d5663665e7fa6e8dd3977fc31f5ed22cc17
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/430580
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Liam Appelbe <liama@google.com>
2025-05-23 07:23:22 -07:00
Tess Strickland 9a2234461a [vm] Use a non-native definition of the runtime function structure.
Attempting to use the native definition when available causes problems
when cross-compiling, and the original attempts to avoid this broke in
subtle ways. Instead, just make a non-native definition that mimics
the native definition and use that with reinterpret_casts when sending
uses of the non-native definition to Windows API calls that expect
a value of the native definition.

TEST=windows ci

Fixes: https://github.com/dart-lang/sdk/issues/60771
Change-Id: I347fcaf8cccd809a3d8e6f041cc7e360b0b8226e
Cq-Include-Trybots: luci.dart.try:vm-aot-win-release-arm64-try,vm-aot-win-release-x64-try,vm-win-release-arm64-try,vm-win-release-x64-try,vm-aot-win-debug-arm64-try,vm-aot-win-debug-x64-try,pkg-win-release-try,pkg-win-release-arm64-try,dart-sdk-win-try,dart-sdk-win-arm64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/430400
Reviewed-by: Slava Egorov <vegorov@google.com>
2025-05-23 06:19:16 -07:00
Alexander Aprelev 3718baa446 [ffi/isolate_group_shared] Keep isolate alive for isolate group shared callback.
To fix encountered tsan race(patchset 3)  split Metadata into MetadataEntry as discussed on https://github.com/dart-lang/sdk/issues/60728#event-17760701621

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

Change-Id: I9308d6fb6a9b819221f7fe4668aefb3a578fe8a8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/430122
Reviewed-by: Liam Appelbe <liama@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2025-05-22 09:02:01 -07:00
Alexander Aprelev 56819231be [vm/shared] Fix LoadStaticField calls initializer behavior.
With b32e5e5a91 under --experimental_shared_data flag, `LoadStaticField` calls initializer stub to confirm presence of isolate when accessing non-shared static fields. This breaks the role that `calls_initializer` attribute/parameter used to play where it was specifically describing neccessity to call initializer, which is important in how `LoadStaticField` instruction is used in static field setters - it should not attempt to call initialzer.

This CL fixes the problem by renaming current `calls_initializer` `LoadStaticFieldInstr` attribute to `does_slow_checks`, and "adding" separate `calls_initializer` parameter to the instruction to signify specifically whether initializer has to be called.

TEST=ci

Change-Id: Ib81424864c98d889fb6dbb9dd15dac9a39c530f8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/429062
Reviewed-by: Slava Egorov <vegorov@google.com>
2025-05-22 09:02:01 -07:00
Alexander Markov f7790bb65b [gardening] Fix gcc and msvc builds
Fix the following compile-time errors:

C:\b\s\w\ir\cache\builder\sdk\runtime\vm\elf.cc(601) : error C2220: the following warning is treated as an error
C:\b\s\w\ir\cache\builder\sdk\runtime\vm\elf.cc(601) : warning C4715: 'dart::ElfSymbolTable::ElfSymbolType': not all control paths return a value

../../runtime/vm/elf.cc: In static member function ‘static intptr_t dart::ElfSymbolTable::ElfSymbolType(dart::SharedObjectWriter::SymbolData::Type)’:
../../runtime/vm/elf.cc:601:3: error: control reaches end of non-void function [-Werror=return-type]
  601 |   }
      |   ^

TEST=ci

Change-Id: Ib06339405b406ea4a6f6d395a04a16573d92c704
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/430321
Auto-Submit: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2025-05-22 07:50:49 -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
Tess Strickland 84a1b114cd [vm] Add base class for shared object writers.
This CL pulls out the refactorings used to support the new MachOWriter
in a followup CL to allow them to be reviewed separately.

Rename Elf -> ElfWriter. Also rename model classes used by ElfWriter
for concepts that exist both in ELF and Mach-O to ElfX. For example,
the old ELF-specific SymbolTable is renamed to ElfSymbolTable.

Adds SharedObjectWriter to serve as a base class for both ElfWriter
and the upcoming MachOWriter.

Adds a new AbstractWriteStream that serves as a common superclass
of both BaseWriteStream and SharedObjectWriter::WriteStream and
allows the creation of fully delegating WriteStreams that do not
maintain a local buffer.

Abstract the old Elf::SymbolData class into
SharedObjectWriter::SymbolData, which stores an enum value as the type
of the symbol instead of storing the ELF encoding of the type.

Rename the DwarfElfStream (which actually wasn't ELF specific, as
all the ELF-specific DWARF information is handled by ElfWriter) to
DwarfSharedObjectStream and put it in a separate header file.

Rename Image::compiled_to_elf() to Image::compiled_to_shared_object()
and add a separate Image::compiled_to_elf() that checks for the ELF
magic value at the DSO base. Also add Image::shared_object_start()
and Image::build_id_start() to return pointers to the DSO base and
the build ID note, respectively.

Refactor Image::build_id() and Image::build_id_length() to check
compiled_for_elf() prior to decoding the data pointed to by
build_id_start() as an ELF note section.

Create an AOTSnapshotType enum to specific the snapshot writer to use
in CreateAppAOTSnapshot instead of using an as_elf boolean.

TEST=refactorings, so existing tests on ci

Change-Id: Ia3ab37a4dff93b6e00390b123753be5a51fbdaaa
Cq-Include-Trybots: luci.dart.try:vm-aot-linux-debug-x64-try,vm-aot-mac-release-arm64-try,vm-aot-dwarf-linux-product-x64-try,vm-linux-debug-x64-try,vm-mac-debug-arm64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/421301
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
2025-05-21 01:36:22 -07:00
Vyacheslav Egorov 9ff77fd414 [vm] Mark _FutureListener.handleValue invisible
Instead of hiding it by skipping it in AsyncAwareStackUnwinder.

Skipping it manually meant that we don't expand and see
functions which are inlined into handleValue in the
stacktrace which might be undesirable and makes
stacktraces unnecessarily sensitive to inlining.

Filtering based on visibility happens after inlined
frame expansion which makes stack trace more stable.

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

TEST=vm/dart/awaiter_stacks/*

CoreLibraryReviewExempt: pragma only change
Cq-Include-Trybots: luci.dart.try:vm-aot-linux-release-x64-try,vm-aot-linux-product-x64-try
Change-Id: Ie6e0ad65285dd1d6f77e27e7488e8d46d30c176c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/429660
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2025-05-20 11:12:02 -07:00
Ben Konyi a067d75f8f [ Observatory ] Remove legacy Observatory VM service tests
Clean up test_runner and the test matrix to remove all references to
the service test suite and delete the tests.

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

TEST=N/A

Change-Id: Ie3adb0d007d71f9a223843d739e57cbdb5be0d59
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/429140
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Ivan Inozemtsev <iinozemtsev@google.com>
2025-05-20 10:33:53 -07:00
Ryan Macnak 0a6fa7ac03 [vm] Fix --gc_at_throw, etc for isolate group callbacks.
TEST=ffi/isolate_group_shared_callback_test
Change-Id: Ib4c241d59a36544495c264c51848753a0bc22bf4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/429460
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2025-05-19 14:07:50 -07:00
Ryan Macnak 3d32a60b55 [vm] Fix race between VM shutdown and in-flight API call.
TEST=vm/cc/DartAPI_TimelineEvents_Loop
Change-Id: I4175fb50991f8bf842437507cc4bf18fc926889d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/428622
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2025-05-19 10:44:33 -07:00
Ryan Macnak ecfce50b5d [infra] Remove IA32 from dartfuzz, GCC and MSVC testing.
Bug: https://github.com/dart-lang/sdk/issues/49969
Cq-Include-Trybots: luci.dart.try:vm-gcc-linux-try,vm-msvc-windows-try
Change-Id: Idf24c48fee5fc5bb757b49bd8941573822496090
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/429223
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2025-05-19 10:28:00 -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
Alexander Aprelev e6784e0580 [gardening] Fix temp variable intptr_t type to match offset uint32_t.
Follow-up to 52dc7979c6
Fixes failed build https://ci.chromium.org/ui/p/dart/builders/ci.sandbox/vm-aot-linux-debug-simarm_x64/4968/overview

TEST=ci

Change-Id: Ifea13d795638e2ba7b6a1e6d50f3e91f012945cf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/428841
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2025-05-15 09:47:40 -07:00
Ryan Macnak 52dc7979c6 [vm] Fix truncation of slot offsets during heap snapshots.
Truncation caused sorting to place the field at offset 2^16 before the field at offset 8, etc.

TEST=iso-stress
Bug: https://github.com/dart-lang/sdk/issues/60717
Change-Id: Ie75c9fa74b830bc08b386533b16e8b01127b0f26
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/428565
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2025-05-15 09:02:20 -07:00
Alexander Markov 1f4707ae0c [vm,dyn_modules] Avoid static calls to bytecode functions from optimized JIT code
Static (direct) calls in the optimized JIT are performed through Code
objects without passing Function objects. This is not compatible with
bytecode interpreter calling conventions, so optimized JIT should
avoid static calls to bytecode functions.

This change disables devirtualized and guarded static calls to
functions declared in bytecode.

TEST=ci

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

Change-Id: I95e4fa0706f376355f4fa7aea7fddf44f303e0a0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/428340
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2025-05-15 07:11:23 -07:00
Alexander Markov e0673fec9c [vm,dyn_modules] Fix printing of interpreter entry and exit frames
TEST=ci

Change-Id: I49139dd3f03df74e3a6a94f7a4366b9d4dfdc0fb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/428580
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2025-05-15 06:46:16 -07:00
Alexander Markov 081211fd4d [vm,dyn_modules] Fix parameter names for closures declared in bytecode
TEST=existing (e.g. language/vm/regress_32502_test)

Change-Id: I2ea118aa34046a52c7c0d648e60f0d928c7702f5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/428620
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2025-05-15 06:46:11 -07:00
Derek Xu 3dc9d8dcf9 [VM/Service] Add getQueuedMicrotasks RPC
TEST=pkg/vm_service/test/get_queued_microtasks_rpc_test

CoreLibraryReviewExempt: This CL does not include any core library API
changes, only VM Service implementation changes within
sdk/lib/vmservice/.
Change-Id: Ie5488f498e4d0f3d201e3f31423fd5029b74a726
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/425160
Commit-Queue: Derek Xu <derekx@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2025-05-13 14:29:37 -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
Alexander Markov b75b5dcbdd [vm] Cleanup unused Library::GetFunctionClosure
TEST=ci

Change-Id: I303ea1fc07c9a682f8c3b2800c9baebd78fc567f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/428302
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2025-05-13 14:17:33 -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 c0e2f38f02 [dart:io] Fix some code to be safe in the face of reflective invocation.
Reflection can invoke public members of dart:* private types when values of the private types can be returned from public members.

TEST=lib/mirrors/invocation_fuzz_test
CoreLibraryReviewExempt: does not change public API
Bug: https://github.com/dart-lang/sdk/issues/31838
Bug: https://github.com/dart-lang/sdk/issues/46435
Bug: https://github.com/dart-lang/sdk/issues/51213
Change-Id: I969cd935d60455bd9cf4775b8df19838f9e6107c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/428065
Reviewed-by: Brian Quinlan <bquinlan@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2025-05-13 10:39:23 -07:00
Ryan Macnak c1f11fed3f [tools] Fix binary_size to work with Dart AOT snapshots.
- Make the size tools less dependent on quirks mode.
 - Add explicit language attribute so Chrome stops offering to translate.
 - Add zip_size to look at the Dart SDK and Flutter APKs.

Change-Id: I0017bd68145344e2427644fcccd13f9b9f307218
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/428064
Reviewed-by: Brian Quinlan <bquinlan@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2025-05-12 15:29:08 -07:00
Ryan Macnak 21dd5d02d9 [vm] Fix assert in heap snapshot writer.
TEST=iso-stress
Bug: https://github.com/dart-lang/sdk/issues/60701
Change-Id: I0e66fc1e9ce38eb566f68eddb63ebbe5e2200275
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/428081
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2025-05-12 13:15:33 -07:00
Ryan Macnak 564444d92b [vm] Fix race in thread pool test.
TEST=vm/cc/ThreadPool_RunOne
Bug: https://github.com/dart-lang/sdk/issues/60698
Change-Id: I97dedcea70d389c5f3b9c94ebd99b617cbd70bc9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/428082
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2025-05-12 12:32:19 -07:00
Ryan Macnak eb563faf6d [vm, gc] Report RSS as timeline counter events, sampled before and after GC.
Catapult will display a nice graph for this.

TEST=view timeline
Change-Id: I6b6fdede463b37dbb10841cfa7c1e08c95e7cb62
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/427060
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2025-05-12 10:46:39 -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 e252d458e5 [vm/shared] Fix check for presence of dart mutator stack.
For GC purposes dart mutator thread could be identified by task kind, or if gc task is occupying the thread, by presence of scheduled isolate or (in case of isolategroup-shared thread) by presence of top_exit_frame.

Fixes dartbug.com/60705
TEST=ci

Change-Id: I09d212caf06e92a36efe1e5d397e5bb89846ced2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/427981
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2025-05-12 07:49:30 -07:00
Paul Berry a757d2af41 Enable sound-flow-analysis for Dart 3.9.
Bug: https://github.com/dart-lang/sdk/issues/60438
Change-Id: I908d4e4a9143142281d8198870f40eba6cf6f67f
Tested: trybots
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/427500
Reviewed-by: Ivan Inozemtsev <iinozemtsev@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Morgan :) <davidmorgan@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2025-05-09 14:50:26 -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
Martin Kustermann b09f6ab9cb [vm] Fix snapshot analyzer test in product mode
Closes https://github.com/dart-lang/sdk/issues/60680

Change-Id: I99ce3606edb748470ab94bbbe0d84a3a5c270768
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/427540
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2025-05-09 01:49:22 -07:00
Ryan Macnak 119116f8a6 [gardening] Mark some slow tests.
Change-Id: I68c45a230a77819af29264eb352cba35e3036787
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/427326
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2025-05-07 19:47:04 -07:00
Ryan Macnak b7e0e10f68 [vm] Fix hang in mutator slot stealing when no waiters have a timeout.
TEST=vm/dart/isolates/many_isolates_blocked_at_process_run_sync_test
Change-Id: I9d5f300c91ecfeb798f467d5624ada3baa3fb453
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/427306
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2025-05-07 19:47:01 -07:00
Alexander Aprelev e7f373f3ad [gardening] Fix analyzer findings on observatory.
Follow-up to 6a6b9ac2bf
TEST=ci

Change-Id: I8bda3591671ee1d0941d3313469c1df7095c03f1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/427321
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2025-05-07 17:10:29 -07:00
Alexander Aprelev 82ec8df3a4 [observatory] Fix broken infobox and rare source view errors.
Element-handling code doesn't work properly with dynamic types so
explicit types are required.
TokenToLine info can be absent, handle nulls there to prevent crashes.

TEST=manually

Change-Id: Ie223a785e12ded8c344ee3c5256d1f6a3b544528
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/427301
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2025-05-07 14:32:00 -07:00
Ryan Macnak 326bda3493 [test] Fix analysis supression for VMInternalsForTesting.
TEST=ci
Cq-Include-Trybots: luci.dart.try:analyzer-analysis-server-linux-try
Change-Id: Ib0855d9c64282bf95bfec82f290019c796c11c6f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/427324
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2025-05-07 14:21:21 -07:00
Alexander Aprelev a296c7c76b [gardening] Fix dart2js chrome observatory test.
Follow-up to 6a6b9ac2bf
TEST=ci

Change-Id: Ib3bbb53a06820ab75b059e96358e0b6c6076d211
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/427302
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2025-05-07 10:58:40 -07:00
Alexander Aprelev 6a6b9ac2bf [observatory] Migrate off dart:html to package:web.
Remove use of svg, use unicode characters instead.
Run dart format on observatory sources.
Sort import statements with import_sorter.

No functional changes.

TEST=ci, manual
Change-Id: I7e4f67be06a27c8ab510ae8e50ce30b162780d30
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/426683
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2025-05-07 10:03:10 -07:00
Ryan Macnak 57ee563bc9 Roll Clang from 0454dd8c48cd to 8c7a2ce01a77
TEST=ci
Cq-Include-Trybots: luci.dart.try:dart-sdk-linux-try;luci.dart.try:dart-sdk-mac-try;luci.dart.try:dart-sdk-mac-arm64-try;luci.dart.try:dart-sdk-win-try
Change-Id: I9d4e7abe9541f74a67e469c4ba4ba3cecfaec431
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/427280
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2025-05-07 09:22:20 -07:00
Vyacheslav Egorov 3e65c9d2a7 [vm] Buffer writes in TimelineEventFileRecorderBase
Previous implementation allocated individual events and then
executed writes directly - both of these add unnecessary overhead.

Instead allocate and process events in blocks just like other
recorders and buffer writes in a temporary buffer before passing
data to Dart::file_write_callback().

Currently if you write something like this:

    int fib(int n) {
      return Timeline.timeSync('fib', () {
        // typical recursive fib implementation here.
      });
    }

    for (var i = 0; i < 1000; i++) {
      fib(10);
    }

and then run it with perfettofile recorder you end up waiting several
seconds before recorder is drained with program spending most time
doing small writes via File::WriteFully.

This is no longer the case after this change.

TEST=ci

Change-Id: I6a33ccdb1f293a94669ad0dd7d883837b86c8b6f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/426861
Commit-Queue: Slava Egorov <vegorov@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2025-05-07 08:13:17 -07:00
Ryan Macnak ee16e3625e Rebalance isolate stress testing shards.
Cq-Include-Trybots: luci.dart.try:iso-stress-linux-x64-try,iso-stress-linux-arm64-try
Change-Id: Ie47b15116053870b04ad95eba0efb6f36d7a35cb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/424341
Reviewed-by: Alexander Aprelev <aam@google.com>
2025-05-07 07:49:51 -07:00
Alexander Aprelev 66a57a8c53 [gardening] Fix trampoline near jump to far jump.
Fuchsia has slightly more code in FfiCallbackTrampoline, so near jump don't work, has to be far jump.

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

Change-Id: Iaabdcfe59c821eeed00fff7faf1dbd661145922b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/426905
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2025-05-07 07:47:59 -07:00
Vyacheslav Egorov a72f25effd [vm] Fix Profiler::UpdateRunningState
It was calling Profiler::Cleanup() to shut the profiler down but
Cleanup did nothing if FLAG_profiler is false. So we need to
adjust condition at the start of Cleanup().

TEST=pkg/dds/test/profiler_can_be_stopped_test.dart

Change-Id: I9921334d264c5cae879e37148d0d784494cb2d63
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/426464
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2025-05-07 07:23:14 -07:00
Vyacheslav Egorov a6a99dc45f [vm] Fix issues in SampleBlockProcessor
This is follow up to commit cb0c2bf5ed.

SampleBlockProcessor only enters isolate group and not a specific
isolate so the code must not rely on thread->isolate(). This fixes two
places where this was not the case:

* ProfileBuilder::IsPCInDartHeap
* UserTags::TagName

pkg/dds/test/get_cached_cpu_samples_test was supposed to cover this but
it has two problems:

First I observed that SampleBlockProcessor never gets a chance to
process a block if mutator thread always gets to it first (via a
scheduled interrupt), so this code is not well exercised. I started by
adding a variant of the test where interrupts are inhibited via a
vm:unsafe:no-interrupts pragma - which revealed the crashes in the
SampleBlockProcessor code.

This revealed the second problem: get_cached_cpu_samples_test does not
actually fail if testee crashes during the test, it just silently
completes with success. This seems to happen because disposal of
VmService connection is not forwarded into the future on which the test
is awaiting - and the whole process just exits once VmService connection
to the testee disappears (because all ports are closed, no pending
activity is possible after that one). I have fixed this by adding a
helper function which checks that connection to VmService only goes away
when we dispose it.

Note: there is another obvious issue here, which I am leaving unfixed
for now. SampleBlockProcessor calls UserTags::TagName in a way that can
race with isolate itself modifying the table. I think this race is
extremely unlikely but it can cause crashes on ARMs with its weak memory
model (e.g. we might end up reading garbage due to the reordering of
stores).

TEST=pkg/dds/test/get_cached_cpu_samples_test

Change-Id: Iee15ec2b019928b798c312e63edc76696abf5527
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/426300
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2025-05-07 07:18:41 -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 73971941f5 [gardening] Clean up fuchsia build for IsolateGroup shared callbacks.
Follow-up to 50e0e0d99d

TEST=ci

Change-Id: I48114f5677a010561638fedf37390479885c8eef
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/427041
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2025-05-06 15:39:57 -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