Commit Graph

22692 Commits

Author SHA1 Message Date
Ryan Macnak 4bb6609724 [vm] C++20 updates.
- std::atomic_ref
  - std::bit_cast
  - std::rotl,rotr
  - designated initializers

TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/42074
Change-Id: I7be17147723db6f7620a147e75d38ebe46393f8c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/484700
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2026-03-04 12:40:19 -08:00
Slava Egorov a1fcb5e863 [vm] Zero initialize registers in the regexp interpreter
RegExp compiler produces bytecode which might issue PushRegister
before SetRegister - which leads to a use of uninitialized value
under MSAN if these registers are not initialized.

TEST=ci

Change-Id: I011545cf05de62490d71503ea5a60a656a6a6964
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/485000
Commit-Queue: Slava Egorov <vegorov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2026-03-03 07:04:06 -08:00
Tess Strickland 7ad5ee3dae [vm,dyn_modules] Print line and column for synthetic token positions.
When using the --dump-kernel-bytecode flag, also print the line and
number of the source position encoded by a synthetic token position.

Also use the decoded value for a synthetic token position when
converting it as a C string for printing, which also makes it easier to
correlate real and synthetic token positions encoding the same source
position.

Also change the long outdated comment about synthetic token positions
not encoding a real source offset, as most if not all uses of them
do actually encode a real source offset.

TEST=manual use during debugging

Cq-Include-Trybots: luci.dart.try:vm-dyn-linux-debug-x64-try
Change-Id: Ic16e320e9a10d8343e8a37c8270c7076bb7052c3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/484943
Commit-Queue: Tess Strickland <sstrickl@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2026-03-03 06:58:35 -08:00
Alexander Aprelev f3bc347448 [core/shared] Allow for BigInt to work in isolategroup-bound callbacks.
Introduce runtime checks for BigInt to allow it being used as deeply immutable class.

TEST=run_isolate_group_run_test

Bug: https://github.com/dart-lang/sdk/issues/61030
Bug: https://github.com/dart-lang/sdk/issues/62601
Change-Id: I343862bdf5603be571d3bf937261dd61aca9ca0e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/477040
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2026-03-02 13:52:34 -08:00
Alexander Aprelev 6d4a7f41d9 [vm/shared] Ensure immutable list is used as backing store for const map.
This is the follow-up to https://dart-review.googlesource.com/q/commit:e9229a05859252211ebbdc99a3ea8de6edb40f1b with fixes for broken standalone/io tests.

TEST=standalone/io on vm-eager-optimization bots

Bug: https://github.com/dart-lang/sdk/issues/62801
Change-Id: Iffd0068ea71f13e91198ea239dac9e498a39061c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/484780
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2026-03-02 13:19:49 -08:00
Ryan Macnak e661d17890 [vm] Update supported-architectures.md.
Fix extra cell in table. Note increases in Mac ARM64 and Android/Fuchsia RISC-V baselines.

Change-Id: I6cfc9e55fd7d3a8ac60e4c768951b43989a95134
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/483365
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2026-03-02 10:29:33 -08:00
Alexander Markov 9657cf7a02 [vm,modular_aot] Support serialization of local function references in modular snapshots
TEST=ci

Issue: https://github.com/dart-lang/sdk/issues/61635
Change-Id: I5b5c9b0cc66d44b25691d72df34efb8071c1564b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/484221
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2026-03-02 08:13:26 -08:00
Alexander Markov ffa7e990f0 [vm,dart2bytecode] Use local function IDs to register and find functions
TEST=ci

Change-Id: I275a7f9e81a8fa69a004518b150c7dfcf1fe7bd6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/483844
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2026-03-02 07:55:38 -08:00
Alexander Markov 99929813b0 [vm,kernel] Add unique IDs for local functions in kernel AST
The unique IDs are assigned during VM-specific lowering transformation
and recomputed during TFA tree shaking.

The IDs are not assigned when local function AST nodes are created
as it makes certain AST transformations very fragile (e.g. moving
a sub-tree to another parent, cloning a tree to insert into another
member).

The IDs will be used to identify local functions within a member by
the VM and different compilers (dart2bytecode, modular AOT).

TEST=ci

Change-Id: Ifa5dc007322a0137776961d364bbf8565137b318
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/483840
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2026-03-02 06:55:31 -08:00
Tess Strickland b1005044db [gardening] Fix TRACE_TYPE_CHECKS on MSVC.
Add __VA_OPT__ to guard the trailing comma, since we use
the /Zc:preprocessor flag.

Remove the conditional guard, since __VA_OPT__ is the
portable way of doing this in C++20, and we target that
version of the language standard when compiling.

TEST=build on vm-msvc-win-x64,vm-msvc-win-arm64

Cq-Include-Trybots: luci.dart.try:vm-msvc-win-arm64-try,vm-msvc-win-x64-try
Change-Id: I5b718858300d72679e9c8bced5f1419e206a2e94
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/484621
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
2026-03-02 05:47:34 -08:00
Nate Biggs 159f427938 [vm] Update option for windows priority test.
Use a slightly higher priority than lowest to avoid flaky timeouts.

We avoid using higher priorities than the default because these require
extra permissions and setup.

Change-Id: I69ca93f270697d3e39ef9c0f49184ffb3de32610
Fixes: https://github.com/dart-lang/sdk/issues/62722
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/483980
Commit-Queue: Nate Biggs <natebiggs@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2026-02-27 09:48:51 -08:00
Alexander Aprelev cdf7bf9c78 [vm/shared] Allow const maps in deeply immutable classes.
This relies on runtime check of Map-typed variable initialization.
TEST=kernel_binary_flowgraph_test

Change-Id: Ia9be2644208883739f5896a223dcbe2b59c98114
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/482021
Reviewed-by: Slava Egorov <vegorov@google.com>
2026-02-27 07:43:14 -08:00
Slava Egorov c3bd038008 [vm] Fix profile streaming in debug mode.
Simplify isolate group enter-exit logic in EmitModuleSymbolsFor: always
call it without an active isolate group. Make sure that we 
destroy StackZone before trying to exit the isolate.

Skip unit test with deferred units on Mac OS: as we don't support
deferred units when writing out Mach-O files currently.

TEST=ci

Change-Id: I8a8615f045781f263c92c45eecf955366a6a6964
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/483760
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2026-02-26 03:28:56 -08:00
Slava Egorov d7fa1ced6a [vm] Speedup profile data streaming in AOT
Current implementation of profile data streaming inherited its 
approach to symbolization from the implementation of vm-service's
get{,Perfetto}CpuSamples methods. These methods rather expensive
as they rely on CodeLookupTable to symbolize collected samples, and
constructing CodeLookupTable requires bringing all threads to safepoint
and iterating over old-space to collect code objects. This can take
significant amount of time - especially when old-space is large (e.g.
consider 1Gb+ heaps of Dart Analysis Server).

This CL rewrites profile data streaming to use a completely different
approach in AOT mode where Dart frames are not symbolized eagerly 
and instead stored in the timeline in their raw form: a pair of
an isolate group specific Mapping and a PC value relative to the start
of that mapping. At the end of streaming (or when isolate group
exits) an additional ModuleSymbols packet is emitted which provides
symbolization information for all collected frames. ModuleSymbols
mappings can be cheaply constructed from collected PCs using 
ReversePc lookup tables.

TEST=expanded existing tests

Change-Id: I56ef1dd4c9a17fb0d2e9c24e51f2e4656a6a6964
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/482782
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2026-02-25 04:48:51 -08:00
Ryan Macnak d5e2f31993 [vm] Fix race compiling regexp.
TEST=iso-stress
Change-Id: I013d7d91d37b62ed60d7f067a62c6f419c0d0a7c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/483362
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2026-02-24 15:23:18 -08:00
Ryan Macnak c87555403c [vm] Avoid heap walk for AOT profiler.
TEST=pkg/vm_service
Change-Id: I6d5d6cc5d6f879f8a0e128c7862d0ff031552211
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/482963
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2026-02-24 10:24:31 -08:00
Ryan Macnak 5e173fa736 [vm] Mark natives as unreachable in gen_snapshot.
This allows a great deal of linker GC resulting in a much smaller binary. The benefit multiplies for Flutter development because the Flutter tool downloads many variant copies of gen_snapshot.

out/ReleaseX64/exe.stripped/gen_snapshot -1.55M (-23.4%)

TEST=ci
Change-Id: I9f6e650f78ea52c9c6953320a669b71019403236
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/482965
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2026-02-24 10:08:30 -08:00
Alexander Markov 0ec57dd561 [vm,modular_aot] Initial code generation for static field loads and stores
TEST=ci

Issue: https://github.com/dart-lang/sdk/issues/61635
Change-Id: I07aa7cabf8fe78c0f98c17b98ae85bdc903b99c3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/482920
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2026-02-24 08:54:39 -08:00
Slava Egorov 1418cb1b9c Roll Perfetto to 49c59636465f2a32f4d83cff835538ba7bf8d732
Drop libprotobuf dependency and update compile_perfetto_protos
to rely on externally provided protoc and protozero_plugin. 
This is done because protoc does not build with our current
toolchain and fixing this build requires rolling new protobuf,
protobuf_gn and perfetto. Which also pulls more external dependencies
like abseil.

Regenerate Perfetto *.pbzero{.cc,.h}, *.dart files

TEST=ci

Change-Id: I11a32aa07e810b48ac12502e526bbaee6a6a6964
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/482781
Commit-Queue: Slava Egorov <vegorov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2026-02-24 03:24:32 -08:00
Slava Egorov 33c0d4bf70 [vm/profiler] Don't give up when FP is invalid
If we have Dart stack frame information don't give up on profiler
sample if C frame is malformed due to invalid FP. We are not 
going to use C frame information anyway.

TEST=ci

Change-Id: I8da05d1397f805543b7721fa9d861a996a6a6964
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/482780
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2026-02-24 01:32:27 -08:00
Ryan Macnak 60fe67bb4b [vm] Let the C++ compiler know it can assume the low bit of a Smi is clear.
TEST=ci
Change-Id: I89f60532a6fe7923a5d4d7bbcd624228ab899854
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/481300
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2026-02-23 13:01:19 -08:00
Ryan Macnak e443b89f23 [vm] Update Irregexp to V8 commit 254cc758346f10be2a7e22e55d90d4defe9cad74.
Includes support for modifier spans and duplicate named capture groups.

Drops the flow graph implementation to ease maintenance.

TEST=corelib/regexp
Bug: https://github.com/dart-lang/sdk/issues/56573
Bug: https://github.com/dart-lang/sdk/issues/61337
Bug: https://github.com/dart-lang/sdk/issues/62349
Bug: https://github.com/dart-lang/sdk/issues/62708
Change-Id: I05640ba945a4fa5476e7ad463738f4f39d842c14
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/480121
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2026-02-23 09:54:47 -08:00
Alexander Markov 7eb7da6890 [vm,modular_aot] Initial code generation for interface calls
Also:
* Support arguments descriptors.
* Fix order of ClosureCall inputs in local function invocations.
* Fix order of passing arguments in all Dart calls.
* Fix handling of fields in InstanceSerializationCluster.
* Do not compile abstract methods and fields.
* Do not generate initializer functions for fields with trivial
  initializers.
* Initialize Code::code_source_map to an empty CodeSourceMap
  (in order to avoid failed assertions).

TEST=tools/test.py -n vm-modaot-mac-debug-arm64 language

Issue: https://github.com/dart-lang/sdk/issues/61635
Change-Id: I40ff1b8234c32c41e08f3288a23e4abc173efcfd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/480020
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2026-02-23 08:03:48 -08:00
Alexander Markov 39c5a61f89 [vm] Check covariance of type parameters of a forwarding stub instead of its target
A forwarding stub can have a covariant type parameter while the same
type parameter in its forwarding stub target is non-covariant.

We should still check bounds of such type parameters
(the bound to check is taken from the forwarding stub target).

TEST=tests/language/regress/regress62664_test.dart
Fixes https://github.com/dart-lang/sdk/issues/62664

Change-Id: I86eeb9f8a537c22fb473388f9b17f55084af6366
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/482480
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2026-02-23 07:27:56 -08:00
Tess Strickland 5792b6ecb7 [vm, dyn_modules] Fix tracing the original instruction at breakpoints.
https://dart-review.googlesource.com/c/sdk/+/481782 removed the tracing
of the original instruction for breakpoints. This CL adds it back.

Also increments icount_ before calling TraceInstruction in the dispatch
loop instead of afterwards so that breakpoint/single step tracing can
just use icount_ without adjusting it. In particular, this means tracing
the original instruction at a breakpoint can just use TraceInstruction
instead of duplicating it.

Also, now both the breakpoint instruction and the original instruction
are written to the instruction trace if requested, instead of only the
breakpoint instruction.

TEST=debugging only changes, so manually tested.

Cq-Include-Trybots: luci.dart.try:vm-dyn-linux-debug-x64-try,vm-dyn-mac-debug-arm64-try
Change-Id: I1999f1d9e7ba55b950c508e848ff12db0c8d5cab
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/482320
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Auto-Submit: Tess Strickland <sstrickl@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
2026-02-23 03:45:57 -08:00
gurusai-voleti 138eaad8cb chore: Migrate gsutil usage to gcloud storage
Closes https://github.com/dart-lang/sdk/pull/62727

GitOrigin-RevId: 05bd7ecca1d5b6a9a0faf97b14ccb7d5966fe949
Change-Id: I3f8c3a3c62cd489864fc6928e6281da0ce465f8d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/482041
Reviewed-by: Alexander Thomas <athom@google.com>
Commit-Queue: Alexander Thomas <athom@google.com>
2026-02-23 02:07:01 -08:00
Tess Strickland df48d89796 [vm,dyn_modules] Fix single stepping at breakpoints.
In compiled code, a block of instructions that calls the single step
handler in the runtime is generated for any pause points.  Enabling a
breakpoint at a pause point then patches those instructions to instead
call a stub. The stub first calls the breakpoint handler in the runtime.
The runtime's breakpoint handler returns the original call target for
the breakpoint, which the stub then calls.

Since the debugger ignores any pause points with the same source
location after hitting a breakpoint, this means that setting a
breakpoint at a pause point only generates a breakpoint hit event,
ensuring that a request to single step after hitting a breakpoint steps
to the next location, not the breakpoint location.

Similar to compiled code, enabling a breakpoint in interpreted code
replaces the original instruction with a special instruction that first
calls the breakpoint handler and then performs the original
instruction's implementation.

However, there is no specific instruction for pause points in
interpreted code. Instead, the dispatch loop in the interpreter has two
labels for each instruction: one for the instruction's implementation,
and another that is used instead when single stepping is enabled.  All
the single step labels point at the same code block, which first calls
the single step handler and then dispatches to the code for the
instruction's implementation.

This difference in handling breakpoints and single step checks means
that pause events are prioritized, not breakpoint hit events, which
means single stepping into a breakpoint generates first a pause event
and then a breakpoint hit event, which differs from the behavior
for compiled code.

To fix this, refactor single step handling in the interpreter so that
the single step label for breakpoint instructions point to a different
code block which first calls the breakpoint handler and then calls the
single step handler before dispatching to the original instruction's
implementation.

TEST=ci

Cq-Include-Trybots: luci.dart.try:vm-dyn-linux-debug-x64-try,vm-dyn-mac-debug-arm64-try
Change-Id: Id33132bbecc5d0cbd9e92bc5a13d8d8a80155344
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/481782
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
Auto-Submit: Tess Strickland <sstrickl@google.com>
2026-02-19 09:43:52 -08:00
Tess Strickland fe6ea5e39d [vm,dyn_modules] Rename DebugCheck to Nop and use after debugger() calls.
Normally, bytecodes no longer in use would be renamed to Unused<X>.
However, in the case of DebugCheck, its only use was to call the
debugger when single stepping, and since its original creation, the
interpreter has been changed to call the debugger when single stepping
on every instruction. Thus, DebugCheck instructions are effectively
no-ops, only used as a distinct PC offset for source positions, and this
CL changes their name to reflect this.

This CL also changes the bytecode generator to detect uses of debugger()
from dart:developer and to add a Nop after it, mimicking how
StreamingFlowGraphBuilder recognizes uses of debugger() and adds a
DebugStepCheck instruction afterwards. Doing this instead of just
using asm.emitSourcePosition() at the end of visitStaticInvocation
ensures that the source position isn't overwritten by the next emitted
instruction.

TEST=pkg/vm_service/test/set_sdk_library_debuggable_test

Cq-Include-Trybots: luci.dart.try:vm-dyn-linux-debug-x64-try,vm-dyn-mac-debug-arm64-try
Change-Id: Ie24bcea0b5aeb9e41d7765f25b1cd123bb2565b4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/480203
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
2026-02-19 03:00:23 -08:00
Robert Nystrom c82716b216 Enable "private-named-parameters" experiment flag.
TEST=many language, co19, and other tests

Bug: https://github.com/dart-lang/sdk/issues/61629
Change-Id: I24d761cc2dc3fa2707a2486a39bfde1b8e847b1e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/480384
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
Reviewed-by: Morgan :) <davidmorgan@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Bob Nystrom <rnystrom@google.com>
2026-02-18 15:26:18 -08:00
Ryan Macnak 293e84cd5c [vm] Use /Zc:preprocessor to get __VA_OPT__ under MSVC.
Needed by irregexp.

TEST=ci
Change-Id: Ie64ee2869ddbb5bad234aea9b49d140b96fed2be
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/481242
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2026-02-18 09:18:10 -08:00
Ryan Macnak 5196ec61ed [vm] Replace GCC __builtin_expect with C++20 [[likely]] attributes.
MSVC has no analogue of __builtin_expect but does support the standard attribute.

TEST=ci
Change-Id: Ide1edaf88425677bce784db4400a72be64e84346
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/481162
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2026-02-17 14:25:39 -08:00
Ryan Macnak 7d5361ab02 [vm] Remove helpers for pre-C++11 64-bit literals.
TEST=ci
Change-Id: Icb198c9d0eb11c11f9fa61f41c37c8705f68001c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/481165
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2026-02-17 14:14:59 -08:00
Ryan Macnak 8ea1175217 [vm] Remove CallLeafRuntimeStubCode test.
TEST=ci
Change-Id: I7371e65b31d482c519ee240660307735946d5f0f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/480401
Reviewed-by: Tess Strickland <sstrickl@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2026-02-17 10:31:46 -08:00
Arbaaz Ahmed e2c278d03b [vm] Allow to skip crash handler installation in bin::Platform::Initialize.
Closes https://github.com/dart-lang/sdk/pull/62680

GitOrigin-RevId: cfb5a10ad92bf8a2b0f56486b8b69b626b9bef44
Change-Id: I853d91c1f3a8b1184455489653510e562c17ebaf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/480880
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2026-02-17 03:56:29 -08:00
Lasse R.H. Nielsen 0a88f4ef73 Remove var or final from parameters.
Removed from `benchmarks/`, `runtime/`, `sdk/`, `tools/` and `utils/`.
(Leaving `tests/`, `pkg/` and `third_party/`.)

CoreLibraryReviewExempt: No real change.
Tested: No test changes for no real code changes.
Change-Id: Ieb42441457ca3d0ea4443dd153ee902ea33b28de
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/480241
Commit-Queue: Lasse Nielsen <lrn@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
2026-02-13 03:35:34 -08:00
Alexander Markov 5c319b2914 [vm] Remove most uses of inc/dec instructions on x64 and ia32
Inc/dec instructions partially update flags register,
which creates false dependencies between instructions,
so they should be only used when optimizing for size.

TEST=ci

Change-Id: I0be2a00044820592689884037dd4784ee4765e4b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/479700
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2026-02-11 10:01:50 -08:00
Alexander Markov 7712167f28 [vm,modular_aot] Refactor Smi size to depend on compressed word size
Smi should fit into the compressed word, so its size in bits
can be defined using kCompressedWordSize.

TEST=ci

Change-Id: Iabea40318edadd7245d3a4771b4606f81b689867
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/479521
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2026-02-10 09:05:51 -08:00
Alexander Markov a4be844171 Support more kinds of constant objects in module snapshots
Add support for constant lists, maps, sets, ints, doubles,
symbols, type literals and user-defined instances.

Also add initial support for function types (without
type parameters), extension types, nullable Never.

TEST=tools/test.py -n vm-modaot-mac-debug-arm64 language

Issue: https://github.com/dart-lang/sdk/issues/61635
Change-Id: I9f73925759b44ac33515895c06ef2a3fcb97e04b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/479066
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2026-02-09 15:11:53 -08:00
Alexander Markov c9e8e8a1f1 [vm] Fix handling of overflow in Bigint_mulAdd intrinsic
'inc' x86/x64 instruction does not affect CF.

TEST=corelib/bigint_test
Fixes https://github.com/dart-lang/sdk/issues/62572

Change-Id: Ibca032c5cc354d8d8df29fddd80353a04c6f1763
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/478800
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Bob Nystrom <rnystrom@google.com>
2026-02-09 09:43:28 -08:00
Liam Appelbe 4679c040c6 [vm] Sync ffi callbacks can enter owned target isolate
Adds a new code path for NativeCallable.isolateLocal invocations. If
the current thread is not entered into any isolate, but owns the
target isolate, then it enters the target isolate, invokes, then exits
the isolate.

Fixes: https://github.com/dart-lang/sdk/issues/61623
TEST=tests/ffi/function_callbacks_isolate_ownership_test.dart
Change-Id: I401f185fadf7d2a55190dafd15387e1c418c67c9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/452380
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Liam Appelbe <liama@google.com>
2026-02-05 01:29:23 -08:00
Ryan Macnak 737888b223 [vm] Make Dart Zones more similar to V8 Zones.
This eases the porting of Irregexp.

TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/56573
Change-Id: If31a0585ced3eabaf2dac6af04f83d387a8eab5d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/478080
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2026-02-04 10:16:41 -08:00
Alexander Markov 151bc79032 Object allocation
TEST=tools/test.py -n vm-modaot-mac-debug-arm64 language
Issue: https://github.com/dart-lang/sdk/issues/61635
Change-Id: Ie569c19ef37e27f7f711dfc3d62db818691f28fd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/476600
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2026-02-03 13:09:02 -08:00
Alexander Markov 46cbb8152f [vm,arm64] Fix disassembly of add/sub with extended register and rd = SP
Aliases cmn and cmp should be used only for adds/subs (with S bit set).

TEST=vm/cc/AddExtReg

Change-Id: Id453282f8397a1a696771d901e66bf77697bf7dd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/476864
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2026-02-02 09:41:16 -08:00
Alexander Aprelev 37b14e84f4 [core/shared] Allow for RegExp to work in isolategroup-bound callbacks.
TEST=run_isolate_group_run_test

Bug: https://github.com/dart-lang/sdk/issues/61030
Change-Id: I3c4734464e1902458edb4a03f5a9e9384509356b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/476860
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2026-01-30 11:16:13 -08:00
Alexander Markov a677c369d9 [vm] Use atomics when accessing patchable object pool entries
Although the data races on patchable object pool entries are benign,
without proper release-acquire ordering there is no happens-before
relationship between store and load and there is a data race as defined
by the C++ standard (and detected by TSAN), which is an undefined
behavior.

It seems like additional memory_order_acquire loads only happen in
runtime entries when we need to patch calls, which is rather
infrequent. Unless additional barriers measurably affect
performance, we should prefer to avoid UB.

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

Change-Id: I3a4d8c3dca7ce1ee1a75efd1ea8ba4e9c06c9dd6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/476500
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2026-01-29 13:18:24 -08:00
Tess Strickland 62b145efbb [vm] Abstract out object header initialization.
Previously there were two separate implementations of the same
initialization code, one in object.cc and one in interpreter.cc.
Now they both use Object::InitializeHeader.

Make TryAllocate a static method of Interpreter instead of a file-local
function in interpreter.cc so that it gets access to the private method
Object::InitializeHeader.

TEST=ci (just code refactoring)

Cq-Include-Trybots: luci.dart.try:vm-dyn-linux-debug-x64-try,vm-aot-dyn-linux-product-x64-try
Change-Id: I4e042fbf0db84e02c88f7ca0f3e025723660001b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/476120
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
2026-01-29 06:59:12 -08:00
Slava Egorov 4ec7f9c25d [vm] Fix timeline track metadata handling
AddTrackMetadataBasedOnThread was looking at FLAG_timeline_recorder
to determine if it can skip recording metadata. However the flag
value is not necessary in sync with the current recorder because
NativeRuntime.streamTimelineTo can reconfigure recorder itself
without changing flag value.

It seems strange to be checking the flag instead of using proper OOP
anyway - the function is already virtual. This CL removes code
which was checking the FLAG and instead overrides the method in
subclasses which don't care about track metadata.

TEST=existing tests were updated to cover this case

Change-Id: I2a2859ab5ef28d8d6d2358259cc9ed8d6a6a6964
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/476400
Commit-Queue: Slava Egorov <vegorov@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
2026-01-29 02:55:30 -08:00
Alexander Markov f29628fe63 [vm] Move constants related to heap pages into Page
Moving these constants from global namespace to Page class prevents
possible conflicts with other kPageSize/kPageMask/kBlockSize constants
and allows us to export value of Page::kPageMask constant into runtime
offsets via runtime/vm/compiler/runtime_offsets_list.h.

TEST=ci

Change-Id: I4357f4644f0f5f7beba50184231fef55dd86b124
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/476147
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2026-01-28 13:49:00 -08:00
Slava Egorov 84fe6c204b [vm] Binary search in AddToSortedListOfRanges
This function is used from two different places: when preparing for 
allocation and during the allocation process itself. In the former
case linear search is better (because we build ranges backwards and
their start positions are monotonically decreasing), in the later
case we perform splits at arbitrary positions and as such binary 
search is likely better.

Significantly improves performance of register allocator with large 
number of live-ranges: compilation time goes to 3.5s from ~30s on
tests/co19/src/LibTest/core/List/List_all_t04.dart (measured prior
to 1d91605c25 which removed most 
of constant live-ranges in this test by allowing constant to 
be used directly by indexing operation).

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

TEST=ci

Change-Id: Ia8f502ff08085ae66b50c4f334bfd22b6a6a6964
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/476161
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2026-01-28 11:43:22 -08:00
Ryan Macnak f2e1df1997 [vm] Avoid deadlock in Isolate.debugName.
TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/62237
Change-Id: I57bfcc341e34aa9e873092e0f7ebf44bc2f95cfc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/476143
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2026-01-28 11:10:42 -08:00