Commit Graph

21756 Commits

Author SHA1 Message Date
Ryan Macnak 1c48e59c51 [vm, reload] Reverse expectations of IsolateReload_LibraryLookup.
This test expects that a library no longer being reachable along the import graph causes the library to be removed from the isolate's library list. The incremental kernel files used during reload don't really have a way to express this. The expected semantics also are a bit unsatisfactory. If a library is "deleted" this way, there may still be instances from library floating around, and re-importing the library would be treated like the addition of a new, unreleated library instead of modified the old library kept alive by those instances. Also, if an island of "deleted" libraries have static calls among themselves, those calls stop working because reresolving their targets fails because the "deleted" libraries aren't in the top-level namespace. The mistake of a global namespace continues to inflict damage.

TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/56785
Change-Id: I743f74d59fd9f017276a118531a58c85ac142ad0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/386821
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2024-09-25 18:29:23 +00:00
Derek Xu 6121c396ee [VM/Service] Expose Service ID zone APIs in service.md and package:vm_service
TEST=pkg/vm_service/test/id_zones_test.dart, CI

Issue: https://github.com/dart-lang/sdk/issues/55869
CoreLibraryReviewExempt: This CL does not include any core library API
changes, only VM Service implementation changes in
sdk/lib/vmservice/running_isolates.dart.
Change-Id: Id63180fd08a88865064435b056fa3269835cd476
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/381400
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Derek Xu <derekx@google.com>
2024-09-25 17:28:44 +00:00
Alexander Markov c0e5b7e75d [vm] Correct typo in a comment
Follow-up to https://github.com/dart-lang/sdk/commit/ab19361e87a0248ade1e883f638542163f9100d1#r147196426

TEST=ci

Change-Id: Ic1c67737d5e69f063a4f62fa8c514c0b2d985e98
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/386682
Auto-Submit: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2024-09-25 16:53:52 +00:00
Alexander Markov ab19361e87 [vm] Masquerade VM internal types more consistently
VM has been hiding certain internal implementation types by
converting them to user-visible types in Object.runtimeType.

However, types of record fields were not converted,
which caused inconsistent hashCode of record types.

This change fixes this bug by applying the same type conversion to
types of record fields.

TEST=tests/language/records/type_equality_and_hash_code_test.dart
Fixes https://github.com/dart-lang/sdk/issues/56771

Change-Id: Ie02e76368de0026620d6ab278f49c14e06fd6eda
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/386542
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2024-09-25 13:46:40 +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
Alexander Markov 7667df56fd [gardening] Fix regress_56756_il_test on vm-aot-optimization-level-linux-release-x64
Adjust IL test to avoid much more agressive inlining on
vm-aot-optimization-level-linux-release-x64 bot.

TEST=runtime/tests/vm/dart/regress_56756_il_test.dart
Fixes https://github.com/dart-lang/sdk/issues/56776

Change-Id: I225049a93990c80773ff640e4a4a6fb9aad0c0fe
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/386540
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
Auto-Submit: Alexander Markov <alexmarkov@google.com>
2024-09-24 15:04:18 +00:00
Jens Johansen 3932452322 [VM] Allow pragma to remove bounds checks for String.codeUnitAt
Follow-up to https://dart-review.googlesource.com/c/sdk/+/384540
allowing the removal of bounds checks for `String.codeUnitAt` if the
method it is called from is annotated with
`@pragma('vm:unsafe:no-bounds-checks')`.

Done by the inliner providing the calling function to the flow graph
builder and GenericCheckBound instruction utilizing this information.

TEST=Existing tests; added runtime/tests/vm/dart/no_bound_check_il_test.dart

Change-Id: Ic6144b0b8400ec6532fb58cd5fd9b3dcdb9a2ff9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/385201
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2024-09-24 10:14:49 +00:00
Ryan Macnak 4de0c76294 [vm, gc] Refactor common setup code for safepoint tasks.
TEST=ci
Change-Id: I48239d109330f163307f4849ebc4139f95f524ec
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/385620
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2024-09-24 00:39:48 +00:00
Ryan Macnak 2a96956cd3 Roll Clang to 3928edecfbd116d56bbe7411365d50bb567380a1.
Re-run clang-format.

TEST=ci
Change-Id: If40a619e32a17ae95c5ee39e36ef0effd07e90b3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/385363
Reviewed-by: Brian Quinlan <bquinlan@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2024-09-23 23:36:48 +00:00
Ryan Macnak 5fb260ecb7 [vm, reload] Rehash constants again after become.
The become operation might have "merged" some constants, creating duplicating entries in a canonical table that will cause trouble for later reloads.

TEST=vm/cc/IsolateReload_EnumDeleteMultiple
Bug: https://github.com/dart-lang/sdk/issues/56583
Change-Id: I62171f2dd36e1d9294203ae998dc05a6941f77a4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/386321
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2024-09-23 23:25:50 +00:00
Ryan Macnak 9880444fd5 [vm, gc] Parallelize the stop-the-world phase of sweeping.
TEST=ci
Change-Id: I6dd09944c5dbe424b24e70f5c85d982c3c8874a7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/385364
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2024-09-23 23:03:51 +00:00
Ryan Macnak c3b2672a19 [vm, compiler] Make use of the zero register for unboxed stores too.
dart2js.aot.rv64 19942240 -> 19925848 (-16k)

TEST=ci
Change-Id: If3d0792e28dbfa5a4183ef4363f155f7c068db47
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/385660
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2024-09-23 21:51:31 +00:00
Alexander Markov 36054eeeaf [vm, aot] Fix inferred range of LoadClassId for nullable inputs
CompileType has a separate is_nullable() property, so
testing nullability of Dart type obtained via ToAbstractType() is not
sufficient.

Fixes https://github.com/dart-lang/sdk/issues/56756
TEST=runtime/tests/vm/dart/regress_56756_il_test.dart

Change-Id: Ifac09889dcd97d0b203f784a94e5b9085f3be8c8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/386360
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Auto-Submit: Alexander Markov <alexmarkov@google.com>
2024-09-23 20:08:58 +00:00
Vyacheslav Egorov 34fa3c1fb5 [vm] Improve same-as-first constraint handling
All other moves generated by the register allocator to satisfy
constraints were using `PrefersRegister` for the source, but
`SameAsFirstInput` was using `Any`. This lead to situations
where hot code inside a loop would repeatedly reload a constant.
To avoid these situations switch `SameAsFirstInput` to use
`PrefersRegister` when the use occurs inside a loop.

Additionally introduce an extension of `SameAsFirstInput`:
`SameAsFirstOrSecondInput`. This new constraint allows register
allocator to reorder first and second inputs if the second one
is no longer alive after the instruction. This allows register
allocator to avoid unnecessary move.

`SameAsFirstOrSecondInput` can be used as an output constraint
for commutative binary operations on X64

Additionally this CL adds a nascent infrastructure for writing
unit tests against register allocator. See `linearscan_test.cc`.

This CL improves code quality for tight loops with binary
double operations written with constants on the left, for example:


    loop {
      doubleA = C * doubleB
    }

Before this CL `C` would be reloaded into a register immediately
before multiplication, but after this CL it will be kept in
register (if register pressure allows).

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

TEST=LinearScan_TestSameAsFirstOrSecond*

Change-Id: Id8e8242a8d1c1d1b8958076f10257e21e4a00aae
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/385001
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2024-09-20 14:47:49 +00:00
Vyacheslav Egorov bb59b5c72c [vm] Fix Instance::IdentityHashCode for strings
This method should return the same value
as `String::Hash` to not be misaligned
with how `identityHashCode()` is implemented.

On 64bit platforms we also use the same
location in the object header to store
identity hash and string hash so these two
can't be misaligned.

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

TEST=vm/cc/String,vm/dart/regress_56749
R=rmacnak@google.com

Change-Id: I221cc8ad85f7ffb7f7d2bcdd0f4341c3ecf25663
Fixed: 56749
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/385860
Commit-Queue: Slava Egorov <vegorov@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2024-09-18 22:30:19 +00:00
Vyacheslav Egorov bf36861cb3 [vm] Fix race in NativeMessageHandler
Introduce `NativeMessageHandler::Cleanup` which
waits for all pending `NativeMessageHandler`
deletions to complete.

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

TEST=hard to distill this specific race into a test

Change-Id: Id6196f955ff7a874c07d3a11f766d74accbde96c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/385780
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2024-09-18 21:07:59 +00:00
Vyacheslav Egorov abf1d96d17 [vm/x64] Improve byte indexed stores
On X64 you can use `movb` instruction with any register, so there
is no need to require a fixed register. This improves the quality
of register allocation decisions around such stores.

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

TEST=ci

Change-Id: Id4d977853fec4a7900cb33c3062257735505ab8b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/384703
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Auto-Submit: Slava Egorov <vegorov@google.com>
2024-09-13 05:55:57 +00:00
Vyacheslav Egorov 3eef6652bf [vm] Fix performance tuning related pragmas
Make these pragmas apply to the function body even when
function is inlined into a caller.

* CheckStackOverflow is dropped directly in the flow graph builder;
* CheckBound is dropped when appending it if the caller is
marked with corresponding pragma.

These pragmas no longer have non-local effect and apply only
to the function which is marked with the pragma.

TEST=vm/cc/{CheckStackOverflowElimination_NoInterruptsPragma,BoundsCheckElimination_Pragma}

Change-Id: I9f4f9a5934d563049fe8e15e33c0432f0883ae3f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/384540
Commit-Queue: Slava Egorov <vegorov@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2024-09-12 19:57:45 +00:00
Vyacheslav Egorov 008b3b2e5e [vm] Avoid false dependency after CVTSI2S(S|D)
These instructions only write to the lower part
of the XMM register and leave upper bits intact.
This creates a false dependency of the subsequent
operations on these upper bits and leads to
stalls.

To avoid this problem we use XORPS to eagerly
break the dependency.

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

TEST=ci

Change-Id: I66892674e934e9357b4d124cbc64ecaee3a1fd6d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/384764
Commit-Queue: Slava Egorov <vegorov@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2024-09-12 16:29:11 +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
Alexander Markov 24eafd67d3 [vm/interpreter] Fix return value and type arguments in constructor tear-offs
TEST=ci

Change-Id: Ibe1ede1bc1c4e044285ee3b3f75ca138d7596e8a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/384682
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2024-09-12 15:15:08 +00:00
Vyacheslav Egorov 157a0dc7f9 [vm/service] Shutdown service isolate if its main errored
If main function throws an error it might leave service isolate
in an inconsitent state and it does make sense to keep the isolate running
we might even dead lock trying to shut it down later (e.g. it might have failed
to create native port).

Flutter engine has a unit test which beings startup sequence for service
isolate and then quickly shutdowns VM - in this case vmservice main throws
and error trying to create native port. If we mark service isolate as
running at this state we will end up deadlocking in shutdown sequence
because main thread can't send exit message to the service isolate (as
we failed to create a port).

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

TEST=flutter engine unit test DartIsolateTest.CanCreateServiceIsolate

Change-Id: Ia0dc089cd31f93022708ff647950febd25eb3d7c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/384482
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2024-09-12 12:18:02 +00:00
Vyacheslav Egorov 4ba2764a9b [vm] Avoid field guard on Compound._typedDataBase
`KernelLoader::FinishClassLoading` was leaving guarded state of this
field in an inconsistent state: it was setting guarded cid to
`kDynamicCid`, but not setting guarded length to `kNoFixedLength`.

As a result in JIT mode we would generate stale length guards
for these fields and these guards would inhibit allocation
sinking.

This CL fixes this.

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

TEST=vm/cc/Ffi_StructSinking
R=dacoharkes@google.com

Change-Id: I2eae6447555a7c1dfa25591e51815936aa3dbaf3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/384842
Commit-Queue: Slava Egorov <vegorov@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
2024-09-12 09:18:20 +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
Ben Konyi 9f5246e8c6 Revert "[ CLI ] Don't disable DDS when --disable-dart-dev is provided"
This reverts commit 81b9957bdd.

Reason for revert: Breaking multiple configurations.

Original change's description:
> [ CLI ] Don't disable DDS when --disable-dart-dev is provided
>
> Fixes https://github.com/dart-lang/sdk/issues/56605
> Fixes https://github.com/dart-lang/sdk/issues/54841
>
> TEST=N/A
>
> Change-Id: I6a13afe5f51fe67d2366c6d87ae74473651e24c8
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/383780
> Commit-Queue: Ben Konyi <bkonyi@google.com>
> Auto-Submit: Ben Konyi <bkonyi@google.com>
> Reviewed-by: Johnni Winther <johnniwinther@google.com>
> Reviewed-by: Phil Quitslund <pquitslund@google.com>

Change-Id: I5c6cb302d8160f19bad437341cdcd80bcc08d921
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/384881
Reviewed-by: Siva Annamalai <asiva@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Reviewed-by: Derek Xu <derekx@google.com>
Auto-Submit: Ben Konyi <bkonyi@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
2024-09-12 01:15:27 +00:00
Ben Konyi 6f1887a1f2 [ DDS ] Fix tests broken by https://dart-review.googlesource.com/c/sdk/+/383780
TEST=N/A

Change-Id: I50e12596ebb7dc687e4c3d408104e450c3e91c3c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/384900
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
2024-09-11 21:08:58 +00:00
Ben Konyi 81b9957bdd [ CLI ] Don't disable DDS when --disable-dart-dev is provided
Fixes https://github.com/dart-lang/sdk/issues/56605
Fixes https://github.com/dart-lang/sdk/issues/54841

TEST=N/A

Change-Id: I6a13afe5f51fe67d2366c6d87ae74473651e24c8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/383780
Commit-Queue: Ben Konyi <bkonyi@google.com>
Auto-Submit: Ben Konyi <bkonyi@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
2024-09-11 18:01:25 +00:00
Alexander Markov ef19c7e948 [vm] Throw error if library is already loaded when loading a dynamic module
TEST=DART_CONFIGURATION=DebugX64 out/DebugX64/dart-sdk/bin/dart pkg/dynamic_modules/test/runner/main.dart -r aot --verbose

Change-Id: I4a7e59e9bb6472fc615c2fc9d9af10bf03945adb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/384325
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2024-09-11 14:18:06 +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
Vyacheslav Egorov dfccc4a268 [vm/aot] Fix debug-info generation
The algorithm for ordering sections in `CreateProgramTable` permitted
skew between the order of sections in snapshot and corresponding
debug info. This skew can lead to inconsistencies in `.text` section
memory offset between two generated ELF files making debug info
invalid.

This skew was left unnoticed for a long time because executable
segment has a huge alignment requirement (64K) while the effect
of the skew was usually rather small and thus hidden by realignment.

This CL adds a strict verification pass (always enabled) which
guards against such skew in the future.

A better architecture would be to ditch parallel generation of
snapshot and corresponding ELF files altogether and other implement
splitting as a post processing path over generated ELF or
rely on external tooling. But this is a much bigger change
than I am willing to invest time into right now.

TEST=ci

Cq-Include-Trybots: luci.dart.try:vm-aot-linux-product-x64-try,vm-aot-linux-debug-x64-try,vm-aot-linux-release-x64-try
Change-Id: I0881783237faa6534eb3c076b6cae472bbdc7243
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/384742
Commit-Queue: Slava Egorov <vegorov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2024-09-11 12:51:23 +00:00
Ryan Macnak 11aa02365c [vm] Give a better error message on pthread_join failure.
TEST=ci
Change-Id: I53206676ed02c398c12c318fb80fe719853cad5f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/384680
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2024-09-10 22:11:32 +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 63c130629f [vm, reload] More debugging code for become conflict.
TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/56583
Change-Id: If05696d7cc8ced68ba4365e62fcbc9bab126affb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/384307
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2024-09-10 16:57:38 +00:00
Lasse R.H. Nielsen 7e75d881a0 Tweak test_runner.
Clean up and optimize some RegExps, and fix uses of `.group`.
Switch to a newer language version, to be able to use newer features.
Add a little documentation about why some RegExps are as they are.

Add (tentative) warning for multitests.

Change-Id: I59f73b87ce30caaeca1c0e0aa7954af1b97abd1b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/382620
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
2024-09-10 15:29:28 +00:00
Alexander Markov 6903672599 [dart2bytecode] Add document describing Dart bytecode file format
TEST=ci

Change-Id: Id12824cf667181122d4d2c4e7af7dc6206d1f85b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/384043
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2024-09-10 13:39:57 +00:00
Alexander Markov fcdcdeddad [dart2bytecode, vm] Adjust bytecode file format
* Switch UInt32 from big-endian to little-endian encoding.
* Reorder object kinds, constant tags, type tags and constant pool tags.
* Reorder field and function flags.
* Cleanup yield point marker from source positions.

TEST=ci

Change-Id: I05ee940b6393a478831af11ac93fee9ec1441c4e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/384040
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2024-09-10 13:37:29 +00:00
Ryan Macnak 214b83c1e4 [vm] Work around C compiler bug with simulation of ARM64 vsub.
TEST=ci, dartfuzz
Bug: https://github.com/dart-lang/sdk/issues/55879
Change-Id: Iadf71b315de3462af6b739c8b49865469368b647
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/384443
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2024-09-10 01:11:15 +00:00
Ryan Macnak 5a4bcb23f6 [gardening] Mark TypeArguments_Cache_ManyInstantiations as slow.
Change-Id: I47e3022b5081fe543ba71fd5e5a879e55fe2f782
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/384441
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2024-09-09 21:16:19 +00:00
Ryan Macnak 4af7aeb0bd [gardening] Skip new FFI test on simulators.
Change-Id: Ie1875e4816ebce84a248a0baba5ecea6d697843e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/384303
Reviewed-by: Alexander Aprelev <aam@google.com>
2024-09-09 18:08:38 +00:00
Daco Harkes fc34157dcc [vm][native assets] No assert on hot reload
TEST=ffi/native_assets/infer_native_assets_yaml_isolate_spawnuri_test

Closes: https://github.com/dart-lang/sdk/issues/51217
Change-Id: I991ce7568dbb282c604c9c5117d9b2fe0251a3c2
Cq-Include-Trybots: luci.dart.try:vm-reload-linux-debug-x64-try,vm-reload-rollback-linux-debug-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/384283
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2024-09-09 18:04:10 +00:00
Vyacheslav Egorov af82cadcec [vm] Force inlining of various Struct helpers
Specifically apply prefer-inline to:

* All generated accessors. In general we almost always seem to
select them for inlining through small-accessor heuristic,
but sometimes it does not hit. Marking with pragma ensures
that we are not dependent on specific heuristics to produce
good code.
* Various helpers involved in creating struct instances from
typed data. These we *not* hit by normal heuristics and
consequently not inlined prior to this change. Inlining them
opens possibilities to fully eliminate allocations associated
with `Struct.create(...)` if Struct does not escape.
* Array creation helpers and accessors. They were also not inlined
which meant we were producing unnecessary temporary objects
when reading from inline arrays.

TEST=/vm/dart/ffi_structs_optimizations_il_test

CoreLibraryReviewExempt: no API or behavioral changes
Cq-Include-Trybots: luci.dart.try:vm-aot-linux-product-x64-try,vm-aot-linux-release-x64-try
Change-Id: I1650023200446bd5289118777365627ca19d3e5b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/384261
Commit-Queue: Slava Egorov <vegorov@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
2024-09-09 15:03:09 +00:00
Alexander Markov 1225b45bc7 [dart2bytecode, vm/interpreter] Async exceptions
TEST=ci (vm-aot-dyn-linux-debug-x64)

Change-Id: I9d5bb0f7f2544e41078ec9aeb75bce6224087976
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/383706
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2024-09-09 13:44:04 +00:00
Ryan Macnak 309ab9ce4a [vm, reload] Debugging code for become conflict.
TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/56583
Change-Id: I8afba7689c91ebbd03ec4fcee22782205dc7959f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/383540
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2024-09-04 19:23:48 +00:00
Alexander Markov a17bc048b4 [dart2bytecode, vm/interpreter] Late final fields and variables
* Also, add implicitly overridden _Enum._enumToString to dynamic
  interface.

TEST=ci (vm-aot-dyn-linux-debug-x64)

Change-Id: I9d9d368715d0837d8b1039a46451152e03be7eec
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/383024
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2024-09-04 14:18:09 +00:00
Alexander Markov 52304b29d0 [vm/interpreter] Fix type checks and async stack traces
TEST=ci (vm-aot-dyn-linux-debug-x64)

Change-Id: Ia8d5dff98ef1b1afa97108a40f1835545e08790f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/382962
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
Auto-Submit: Alexander Markov <alexmarkov@google.com>
2024-09-04 08:14:18 +00:00
Ryan Macnak 8ab9c0a9cf Reland "[vm, gc] Run parallel GC tasks on mutator threads blocked for the safepoint instead of new thread pool workers."
Set thread execution state to VM before running safepoint tasks.

TEST=vm/cc/Splay_WeakPersistentHandle
Bug: https://github.com/dart-lang/sdk/issues/55713
Change-Id: I0318a33449772d1fc3b4248e66a5360b316eca39
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/382220
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2024-09-03 23:14:49 +00:00
Ryan Macnak 56f8071f4e [vm, gc] Add variant of splay test using both variants of weak handle.
TEST=vm/cc/Splay_*
Change-Id: Ica1c2206299968c5d6aabf25c591ad797cae4502
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/383441
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2024-09-03 22:24:28 +00:00
Ryan Macnak b87378f8a5 [vm] Avoid race on TTS testing flag.
TEST=tsan
Change-Id: I939fbd756f114dbf0db027b4eb05a63b8b940833
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/383421
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2024-09-03 21:58:20 +00:00
Ivan Inozemtsev ad15bc4b47 Add support for iOS target os
- `build/mac/find_sdk.py` can search for iPhone and Watch SDKs and their simulators
- `tools/build.py` supports `--os=ios` and `-os=ios_simulator` now. Treating simulator as a separate os to minimize changes and avoid an additional dimension for configs.
- `vm-mac-(release|debug)-arm64-try` tryjobs make sure a shared library builds successfully for ios.

TEST=ci

Change-Id: I76358ec8fd33752260bf0b8462da22a13cd7562e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/381623
Auto-Submit: Ivan Inozemtsev <iinozemtsev@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Thomas <athom@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2024-09-03 19:53:58 +00:00
Daco Harkes 7909241431 [vm] Fix clamp runtime entries zero sign on arm and arm64
In Dart, we use the architecture specific logic for float signs
on clamping https://github.com/dart-lang/sdk/issues/40426.

The simulator was patched to account for this
https://dart-review.googlesource.com/c/sdk/+/244320.

However, the runtime entry was not patched leading, to inconsistent
results in unoptimized and optimized code on arm and arm64
architectures (including simulators).

This CL ports the simulator fix to the runtime entry.

RISC-V, x64, and ia32 are untouched.

TEST=runtime/tests/vm/dart/regress_56589_test.dart

Bug: https://github.com/dart-lang/sdk/issues/56589
Change-Id: Ie8a7e5e707b8529b5bf8c1d7397743d056ca5a13
Cq-Include-Trybots: dart/try:vm-aot-android-release-arm64c-try,vm-aot-android-release-arm_x64-try,vm-aot-asan-linux-release-x64-try,vm-aot-linux-debug-simarm_x64-try,vm-aot-linux-debug-simriscv64-try,vm-aot-linux-debug-x64-try,vm-aot-linux-debug-x64c-try,vm-aot-mac-release-arm64-try,vm-aot-mac-release-x64-try,vm-aot-msan-linux-release-x64-try,vm-aot-obfuscate-linux-release-x64-try,vm-aot-optimization-level-linux-release-x64-try,vm-aot-tsan-linux-release-x64-try,vm-aot-ubsan-linux-release-x64-try,vm-aot-win-debug-arm64-try,vm-aot-win-debug-x64-try,vm-aot-win-debug-x64c-try,vm-appjit-linux-debug-x64-try,vm-asan-linux-release-x64-try,vm-checked-mac-release-arm64-try,vm-eager-optimization-linux-release-ia32-try,vm-eager-optimization-linux-release-x64-try,vm-linux-debug-ia32-try,vm-linux-debug-simriscv64-try,vm-linux-debug-x64-try,vm-linux-debug-x64c-try,vm-linux-release-simarm-try,vm-mac-debug-arm64-try,vm-mac-debug-x64-try,vm-msan-linux-release-x64-try,vm-reload-linux-debug-x64-try,vm-reload-rollback-linux-debug-x64-try,vm-tsan-linux-release-x64-try,vm-ubsan-linux-release-x64-try,vm-win-debug-arm64-try,vm-win-debug-x64-try,vm-win-debug-x64c-try,vm-win-release-ia32-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/382600
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2024-08-30 16:11:40 +00:00