Some other refactorings are piggy-backed along.
TestProject.runSync no longer takes a 'command' argument. It was anyway
often not an argument.
Also stop the messy handling of pub arguments. It is no longer needed.
BUG: https://github.com/dart-lang/sdk/issues/44135
TEST=The VM change is tested via all the pkg/dartdev/test/command/* tests that invoke dart with the --no-analytics flag.
Change-Id: Ib5a1a29841a5fdb28663b7f60c5d6fc31ba252d0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/171284
Commit-Queue: Sigurd Meldgaard <sigurdm@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Jonas Jensen <jonasfj@google.com>
Dart_CreateLightweightIsolate API:
This API can be used by embedders to create a lightweight isolate
(inside an existing isolate group).
It is the analogous to Dart_CreateIsolateGroup - though taking a
parent isolate as parameter (inside whose IG we create a new isolate)
instead of taking kernel/snapshot data.
Right now this API works on AOT and returns an error in JIT, both cases
are covered by the test.
Dart_RunLoopAsync:
The API can be used by embedders to transfer ownership of an isolate to
the VM, which will take care of running the message handling loop and
shuts the isolate down once the last receive port has been closed.
It does allow listening to error/exit events generated by the message
loop implementation as well as allows setting errors-are-fatal,
effectively the same event-loop related parameters from the
`Isolate.spawn()` API, just in Dart.
It's the embedders responsibility to first launch initial dart code
which will take care of responding to events (i.e. directly/indirectly
open a receive port) - otherwise the isolate cannot be talked to and
would immediately shut down.
Since our vm/cc tests do support running in AOT, we use a hybrid
approach to test the functionality: We let a normal Dart test call a
small C wrapper using FFI, to create a lightweight isolate, run it on a
new thread and join that thread.
TEST=vm/dart{,_2}/isolates/dart_api_create_lightweight_isolate_test
Issue https://github.com/dart-lang/sdk/issues/36097
Closes https://github.com/dart-lang/sdk/issues/44088
Change-Id: Id77ba928793fdb517f6cb7e8130df98a0366ddd6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/170983
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
When Dart invokes Isolate.spawn the Dart VM calls out to the embedder to
create an isolate (group) or initialize it (in case of lightweight
isolates).
* If the embedder doesn't implement this functionality or fails to
perform the creation/initialization, it will signal this failure
via the return value it gives to the VM in the call back
implementation (i.e. Dart_InitializeParams.create_group and
Dart_InitializeParams.initialize_isolate}).
* If the embeder sucessfully completed it's work, the VM owns the
isolate after the embedder call returns. The VM is then responsible
for running it.
It is an undocumented invariant atm that the embedder is responsible
to make the isolate runnable if it signals the VM that isolate was
sucessfully created/initialized.
=> If it does not do that, we have effectively an isolate leak.
=> Though right now seemingly all of our embedders to that correctly.
To avoid this unintentional isolate leak we make the isolate runnable
ourselves if embedder callback was successful but did not make it
runnable itself.
=> This also avoids unnecessary ceremony code in the embedders that
look like this:
Dart_ExitIsolate();
Dart_IsolateMakeRunnable(child);
Dart_EnterIsolate(child);
The implementation of `Dart_IsolateMakeRunnable()` had an untested and
unused code path that caused running the isolate (on a thread pool).
This is not documented and can lead to bugs because often the
embedders enter the isolate right after making it runnable (e.g. above
code sequence) - which would be racing with the spawned message handler
thread.
=> Furtunately our embedders are well behaved and make the isolate
runnable during the callback.
=> As a safeguard we'll make `Dart_IsolateMakeRunnable()` return an
error if it's called outside the callback (which we can detect by
the presense of a spawn state)
Issue https://github.com/dart-lang/sdk/issues/44088
Issue https://github.com/dart-lang/sdk/issues/36097
TEST=Changes internal details of implementation which is already covered by tests.
Change-Id: Ieef316cc0807d99f2fcb1fbd56bbc9c41e904ba8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/170882
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
A smoke test to exercise alignment of structs with various field types
to see how they are aligned on the stack. Only contains small structs
because most ABIs only pass structs less than 16 bytes on the stack.
Especially tests iOS64, where `AlignOf(struct{float32;float32;}) == 4`
but `AlignOf(struct{int32;int32;}) == 8` due to the special treatment
of homogenous floats in the arm64 ABI combined with iOS decision to not
align everything on the stack to at least word size.
Test tested on iOS64 through Flutter.
structs_by_value_tests_configuration.dart is the only non-generated
file.
The tests are tested in the dependent CL. Tests are ignored in status
file and are un-ignored in dependent CL.
Tests for https://github.com/dart-lang/sdk/issues/36730.
Change-Id: I6ec4523208db740b8ea3f8a4ab1e5717f1088467
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/170691
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Auto-Submit: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
where --enable experiment is accepted
Adds --enable-experiment support for:
- dart compile aot-snapshot
- dart compile jit-snapshot
- dart compile js
- dart compile exe
- dart compile kernel
Also changes --enable-experiment from a top level CLI flag to a
per-command flag. --enable-experiment flags will now only be
interpreted by the VM if:
1) They are provided before a CLI command (e.g., dart
--enable-experiment=non-nullable analyze) or
2) They are provided with an explicit or implicit run command (e.g.,
dart --enable-experiment=non-nullable foo.dart or dart
--enable-experiment=non-nullable run foo.dart or dart run
--enable-experiment=non-nullable foo.dart)
This should make it more generally clear where --enable-experiment is
accepted and what subcommands can accept the flag. Prior to this change,
providing --enable-experiment anywhere, even for commands without
experiment support, would not raise an error.
Fixes https://github.com/dart-lang/sdk/issues/43623
Change-Id: I5ec48b2dd2bb6db5526185dae2edbca95ef24d9f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/169902
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Sigurd Meldgaard <sigurdm@google.com>
Reviewed-by: Jonas Jensen <jonasfj@google.com>
Changes Dart_NewWeakPersistentHandle to no longer auto delete the
weak persistent handle.
Changes the signatures of WeakPersistentHandleFinalizers to no longer
have access to the handle.
Flutter PR: https://github.com/flutter/engine/pull/19843
g3 presubmit: cl/318028238
Issue: https://github.com/dart-lang/sdk/issues/42312
TEST=runtime/vm/dart_api_impl_test.cc
Change-Id: I3f77db9954d9486759f903b78c03a494f73c68ba
Cq-Include-Trybots:dart/try:vm-ffi-android-debug-arm-try,vm-ffi-android-debug-arm64-try,app-kernel-linux-debug-x64-try,vm-kernel-linux-debug-ia32-try,vm-kernel-win-debug-x64-try,vm-kernel-win-debug-ia32-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-android-release-arm64-try,vm-kernel-asan-linux-release-x64-try,vm-kernel-msan-linux-release-x64-try,vm-kernel-precomp-msan-linux-release-x64-try,vm-kernel-linux-release-simarm-try,vm-kernel-linux-release-simarm64-try,vm-kernel-precomp-android-release-arm_x64-try,vm-kernel-precomp-obfuscate-linux-release-x64-try,dart-sdk-linux-try,analyzer-analysis-server-linux-try,analyzer-linux-release-try,front-end-linux-release-x64-try,vm-kernel-precomp-win-release-x64-try,vm-kernel-mac-debug-x64-try,vm-precomp-ffi-qemu-linux-release-arm-try,vm-kernel-nnbd-linux-debug-x64-try,analyzer-nnbd-linux-release-try,front-end-nnbd-linux-release-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151525
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
The 3 and 7 byte tests in
https://dart-review.googlesource.com/c/sdk/+/168829
had their sizes rounded up to the next power of two due to alignment of
fields inside the structs.
In order to properly exercise behavior on win32, win64 and iOS, this CL
changes those structs to only have uint8 fields to prevent alignment
influencing the sizes.
Old tests are renamed to exercise the size rounding due to alignment.
This also swaps around the two 9byte structs to have consistent naming
with the new 3 and 7-byte tests.
structs_by_value_tests_confguration.dart is the only non-generated file.
The tests are tested in the dependent CL. Tests are ignored in status
file and are un-ignored in dependent CL.
Tests for https://github.com/dart-lang/sdk/issues/36730.
Change-Id: If47cfcaebe56f43d50265f0d6e2749c56fe7b195
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/169101
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Tess Strickland <sstrickl@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Split off from https://dart-review.googlesource.com/c/sdk/+/140290/33
to make that CL smaller and review the test generator separately.
Because of the amount of corner cases in the calling conventions that
need to be covered, the tests are generated, rather than hand-written.
The tests are tested in the dependent CL. Tests are ignored in status
file and are un-ignored in dependent CL.
Change-Id: I5507f52229793fdf07da3066b49045fdb703a69d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/168829
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
The sources assignment filter is considered a misfeature of gn
and is planned for removal (see discussion at [1]).
Convert dart BUILD.gn rules to manually filter the files that
are build using explicit `if` expressions. Remove obsolete call
to set_sources_assignment_filter() to filter '*_test.*' files
as no such files are present in the variables used to build the
`sources` value.
[1]: https://groups.google.com/a/chromium.org/g/gn-dev/c/oQcYStl_WkI/m/roukYTxSDAAJ
Bug: gn:125
Change-Id: I591fbb746cf694f7d2a5a330f81652380acf5c11
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/166629
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Core snapshots should be agnostic to the sound null safety mode
(so they can be used both in weak and strong modes), and snapshot
writer verifies that.
Snapshot::kFull was previously used both for core snapshots and
app snapshots on ia32. However, app snapshots are not guaranteed to
be agnostic, which appeared as failures on a few test on ia32.
Also, VM should be able to detect null safety mode from app snapshots,
even if they do not contain code, but null safety mode was not
written into features string of kFull snapshots.
In order to disambiguate core snapshots, a new Snapshot::Kind is
added. Snapshot::kFullCore works exactly as Snapshot::kFull, except
for verification of agnostic null safety and snapshot features string
omitting null safety mode. All snapshots except kFullCore now have
null safety mode included into their features string.
Fixes https://github.com/dart-lang/sdk/issues/43626
Issue https://github.com/dart-lang/sdk/issues/43613
Change-Id: I8cd3b049ef4e428dd5e1ce666d4c7aa3b596d70c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/166308
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Running trust evaluation system api call on worker thread effectively unblocks main isolate when it attempts to establish https connection.
Execution of the worker thread is implemented via dart native port infrastructure which allows to run C++ code as a dart message handler.
TrustEvaluateHandlerFunc (if provided by platform-dependent SSLCertContext) is that handler, only mac(ios) implementation provides it.
Asynchrony of CertificateVerificationCallback (for mac/ios) is implemented via [ssl_verify_retry] return code which allows to suspend ssl handshake until certificate trust is confirmed.
When dart's _RawSecureSocket.secureHandshake() method that initiated ssl's handshake received this return code it knows it has to wait for a future that is completed by another callback([rpEvaluteResponse]) that waits for trust evaluation handler response.
rpEvaluateResponse purpose is to listen for response from TrustEvaluateHandler and also invoke user-provided [badCertficateCallback] that can override trust decision for a given connection request, for a given certificate.
Once that future is completed and CertificateVerificationCallback knows whether to trust a certificate or not, _secureHandshake retries ssl handshake.
Bug: https://github.com/dart-lang/sdk/issues/41519
Change-Id: Ifee18639c78099ec77cad50000444bc6c7b9369b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/165520
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
Fuchsia is transitioning from UTC time being tracked in the kernel,
to userspace UTC clock handles.
This preserves the existing behavior that each dart process
has access to the global UTC clock.
Bug: 43629
Change-Id: I23005bccd8bec09ed6db7c6f475b6f5d6e84613c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/165500
Auto-Submit: Adam Lesinski <adamlesinski@google.com>
Reviewed-by: Zach Anderson <zra@google.com>
Commit-Queue: Zach Anderson <zra@google.com>
Since we've run out of room for more fields in the Image object header
on 64-bit architectures, the serializer instead creates an ImageHeader
object for precompiled snapshots that is placed at the start of text
segments. The new ImageHeader object contains the following information:
* The offset of the BSS segment from the text segment, previously
stored in the Image object header.
* The relocated address of the text segment in the dynamic shared
object. Due to restrictions when generating assembly snapshots, this
field is only set for ELF snapshots, and so it can also be used to
detect whether a snapshot was compiled to assembly or ELF.
* The offset of the build ID description field from the text segment.
* The length of the build ID description field.
We replace the BSS offset in the Image object header with the offset of
the ImageHeader object within the text segment, so that we can detect
when a given Image has an ImageHeader object available.
There are no methods available on ImageHeader objects, but instead the
Image itself controls access to the information. In particular, the
relocated address method either returns the relocated address
information from the ImageHeader object or from the initialized BSS
depending on the type of snapshot, so the caller need not do this work.
Also, instead of returning the raw offset to the BSS section and having
the caller turn that into an appropriate pointer, the method for
accessing the BSS segment now returns a pointer to the segment.
Bug: https://github.com/dart-lang/sdk/issues/43274
Cq-Include-Trybots: luci.dart.try:vm-precomp-ffi-qemu-linux-release-arm-try,vm-kernel-precomp-android-release-arm64-try,vm-kernel-precomp-android-release-arm_x64-try
Change-Id: I15eae4ad0a088260b127f3d07da79374215b7f56
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/163207
Commit-Queue: Tess Strickland <sstrickl@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
The VM and dartdev were not forwarding --disable-service-auth-codes to
the DDS instance, resulting in auth codes always being enabled.
Change-Id: Ib23bfeb7c64a51fb1229f049a4b61cb1ce5018de
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/163261
Reviewed-by: Siva Annamalai <asiva@google.com>
the service
As part of the dartdev refactoring, 'dfe.Init()' was only called when
an explicit script URI was found during option parsing. However, with
--observe provided, 'script_uri' is always null as dartdev is
responsible for determining which script to run. This change ensures
that vm_platform_strong.dill is always loaded by the DFE.
Fixes https://github.com/dart-lang/sdk/issues/43207
Change-Id: I118b83390efba48e3e8d5b793444d189ba3c5ae2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/162060
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
This reverts commit 0ea18ffb36.
Reason for revert: Tree is on fire
Original change's description:
> [ Service / DDS ] Advertise DDS as the VM service, bump version to 4.0
>
> This change does the following:
> - The DDS URI will be reported by the VM as the VM service URI. If DDS
> disconnects, the VM service URI will be reported instead. This only
> impacts the standalone VM.
> - Updated the service protocol to 4.0 and removed the following
> deprecated functionality:
> - Client synchronization RPCs (these now live in DDS)
> - getWebSocketTarget (no longer needed as the VM service no longer
> tries to redirect web socket clients to DDS)
> - Regenerates package:vm_service based on the new spec, prepare for
> 5.0 release
>
> Change-Id: I8a2b401062342eb99b81ef10ef6926baa88f946e
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/160141
> Reviewed-by: Siva Annamalai <asiva@google.com>
TBR=bkonyi@google.com,rmacnak@google.com,asiva@google.com
Change-Id: I6a16e9fa7ceb18555d6424a169cfa811d3833419
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/160340
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
This change does the following:
- The DDS URI will be reported by the VM as the VM service URI. If DDS
disconnects, the VM service URI will be reported instead. This only
impacts the standalone VM.
- Updated the service protocol to 4.0 and removed the following
deprecated functionality:
- Client synchronization RPCs (these now live in DDS)
- getWebSocketTarget (no longer needed as the VM service no longer
tries to redirect web socket clients to DDS)
- Regenerates package:vm_service based on the new spec, prepare for
5.0 release
Change-Id: I8a2b401062342eb99b81ef10ef6926baa88f946e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/160141
Reviewed-by: Siva Annamalai <asiva@google.com>
was overwritten by isolate initialization code
Fixes situation where the following command would fail due to the
dartdev kernel not being compiled with null-safety:
dart --strong-null-safety --enable-experiment=non-nullable run foo.dart
Change-Id: I7e7c980eb3274a51e64c031e6bfef8650b897b8b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/158345
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>