This CL adds support for users defining integers which are mapped to
differing sizes and signedness based on the application binary interface
the Dart VM is running on.
Notable implementation design decisions:
- ABIs are open world, so that adding an ABI to the Dart VM does not
break existing definitions. Thus, we only figure out in the VM that
we're missing a mapping. We throw compile-time errors.
- In AOT, these show up in the precompilation step.
- In JIT, these show up as `_CompileTimeError` at runtime. Note that
these can be caught. So in subsequent compilation steps we need to
ensure that we also throw the same compile-time error.
- We match on the call-sites (streaming_flowgraph_builder) rather than
method bodies (kernel_to_il) of AbiSpecific loads and stores so that
we can compile for the int-size of the call site.
API design decisions:
https://github.com/dart-lang/sdk/issues/42563#issuecomment-981774001
Closes: https://github.com/dart-lang/sdk/issues/42563
TEST=tests/ffi_2/abi_*_test.dart
TEST=tests/ffi/function_*_generated_test.dart
TEST=tests/ffi/vmspecific_static_checks_test.dart
Change-Id: I8c8df36fab939b6fb614c5f1ee8e1bf46b6e9521
Cq-Include-Trybots: luci.dart.try:analyzer-linux-release-try,analyzer-nnbd-linux-release-try,app-kernel-linux-debug-x64-try,benchmark-linux-try,dart-sdk-linux-try,front-end-linux-release-x64-try,front-end-nnbd-linux-release-x64-try,pkg-linux-debug-try,vm-canary-linux-debug-try,vm-ffi-android-debug-arm-try,vm-ffi-android-debug-arm64c-try,vm-fuchsia-release-x64-try,vm-kernel-checked-linux-release-x64-try,vm-kernel-gcc-linux-try,vm-kernel-linux-debug-x64c-try,vm-kernel-mac-debug-x64-try,vm-kernel-asan-linux-release-x64-try,vm-kernel-msan-linux-release-x64-try,vm-kernel-nnbd-linux-debug-ia32-try,vm-kernel-nnbd-win-debug-x64-try,vm-kernel-nnbd-win-release-ia32-try,vm-kernel-nnbd-linux-debug-x64-try,vm-kernel-precomp-asan-linux-release-x64-try,vm-kernel-precomp-android-release-arm_x64-try,vm-kernel-precomp-android-release-arm64c-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-win-debug-x64c-try,vm-kernel-reload-linux-debug-x64-try,vm-kernel-reload-rollback-linux-debug-x64-try,vm-kernel-win-debug-ia32-try,vm-kernel-win-debug-x64-try,vm-precomp-ffi-qemu-linux-release-arm-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/221501
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
App-jit and core-jit snapshots generated on one machine can be copied to
another machine with different CPU family/model, so it is incorrect to
use CPU features of the host machine to generate code for snapshots.
This change adds --target-unknown-cpu option and enables it when
generating app-jit and core-jit snapshots in standalone Dart VM and
gen_snapshot.
Currently, this flag disables SSE4.1, popcnt and ABM on ia32 and x64,
and integer division instruction on ARM. Also, new flag enables
testing of roundsd instruction availability at run time on x64
(similarly to AOT).
TEST=ci
Fixes https://github.com/dart-lang/sdk/issues/47907
Fixes https://github.com/flutter/flutter/issues/94181
Change-Id: Id28448052a21df4bae30b39e62b8532e55d4c901
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/223960
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
I could do a separate package if you think that would be better, but putting it here I think makes things simpler.
Change-Id: I4e62bc18dcd9d3bb84a7aceb8f4e2821c84d1361
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/224280
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Previously, when concatenating two fragments of flow graph
F1(entry1, end1)
F2(entry2, end2)
we discarded F2 if F1 is closed. This is not correct
when F2 contains yield continuation point in the middle,
because later we add a branch targeting that continuation point,
making end2 reachable.
This change fixes concatenation of fragments to continue building
flow graph with the fragment
F(entry1, end2)
even if F1 is closed (but we don't link end1 to entry2
in such case).
TEST=runtime/tests/vm/dart/regress_flutter66765_test.dart
Issue: https://github.com/flutter/flutter/issues/66765
Change-Id: I145cb4a8952e29665353688dccd232b3e9268878
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/224220
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Using this style makes the tests more robust to refactoring the
analyzer, since the tests exercise the analyzer in end-to-end fashion.
Change-Id: I7038e542109cb6556f3db190d7a0e527f32e1788
Bug: https://github.com/dart-lang/sdk/issues/44522
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/224260
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Current skeleton to allow for instrumentation snapshots that can be
built alongside Dart compilation artifacts and easily referenced for
specific versions between Snapshot hash <-> DartSDK <-> Flutter Engine
TEST=runtime/tests/vm/dart/analyze_snapshot_binary_test.dart
Change-Id: Ie3757a265bbf457506c72fb62a625fea7bedcb68
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/221087
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
Make sure that the whole InstructionsTable::Data structure
is zeroed out before writing it out into the snapshot.
Otherwise we end up writing random garbage bytes into it which
makes AOT snapshot build bitwise unstable: running build twice
should produce bitwise equivalent snapshots but it does not.
Fixes https://github.com/dart-lang/sdk/issues/47949
TEST=vm/dart_2/use_save_debugging_info_flag_test on dartkp-win-release-x64
Bug: 47949
Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-win-release-x64-try
Change-Id: I0475d617ebff6dff2f108e0d6338848f4668fba8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/224524
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
This change bakes binary search table which maps PC ranges
to corresponding stack maps and Code objects (if still present
in the snapshot) into RO data section of the snapshot - instead
of constructing it at load time.
This allows to considerably reduce amount of work done when
loading Code cluster for programs which have majority of their
Code objects discarded (i.e. in DWARF stack traces mode): as
we no longer write / read any information for discarded Code
objects.
This CL also changes program visitor to deduplicate Code objects
if their instructions are deduplicated in AOT mode. Only a single
Code object can be choose as a representative for the given
PC range so it does not make sense to write multiple Code objects
into the snapshot which refer to the same Instructions.
The overall improvement is hard to quantify but ReadProgramSnapshot
shows the following improvement when starting a large
Flutter application on a slow Android device:
before 223.55±59.94 (192.02 .. 391.74) ms
after 178.06±47.03 (151.31 .. 291.34) ms
This CL packs CompressedStackMaps next to the binary search table
itself allowing us to address them via offsets instead of
pointers.
Snapshot sizes are actually affected positively by this change. On
the same large Flutter application I see
DWARF stack traces on: -1.34% total SO size
DWARF stack traces off: -1.63% total SO size
Issue https://github.com/dart-lang/sdk/issues/46116
TEST=ci
Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-dwarf-linux-product-x64-try,vm-kernel-precomp-linux-debug-simarm64c-try,vm-kernel-precomp-linux-debug-simarm_x64-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-debug-x64c-try,vm-kernel-precomp-linux-product-x64-try,vm-kernel-precomp-linux-release-simarm-try,vm-kernel-precomp-linux-release-simarm64-try,vm-kernel-precomp-linux-release-simarm_x64-try,vm-kernel-precomp-linux-release-x64-try
Change-Id: Ic997045a33daa81ec68df462a0792915885df66b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/220766
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
Updates documentation now that static interop features are
available. This should be the last component before the new
`package:js` version is published.
Change-Id: I9ddb494a5723036ca699bdcf10a000f7670cdfd8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/224401
Reviewed-by: Riley Porter <rileyporter@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
The source report RPC needs to be able to distinguish branch coverage vs
normal coverage token positions. So encode normal positions as 2 * pos
and branch positions as 2 * pos + 1.
TEST=CI
Change-Id: I247796d1eb4c97947f9b38aa56bc318ecea09425
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/224320
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Liam Appelbe <liama@google.com>
The breakage is due to this analyzer exception:
```
Unhandled exception:
type 'ConstructorReferenceImpl' is not a subtype of type 'Identifier' in type cast
```
I cannot figure out how to reproduce this in a unit test, but this patch fixes google3.
Bug: b/210848863
Change-Id: I8c340b6ff80d03d9493fdc481b8f17071ff969ca
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/224241
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
The failure is within std::ostringstream without any obvious errors
on our side, but just appending to std::string instead should be
fine for a failure case.
TEST=vm/cc/IsolateReload_PendingUnqualifiedCall_StaticToInstance on MSAN trybot
Change-Id: I36e91c4ba4019856c709834d29ce9c4595e6a336
Cq-Include-Trybots: luci.dart.try:vm-kernel-msan-linux-release-x64-try
Bug: https://github.com/dart-lang/sdk/issues/47933
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/224200
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
This separates the reading of entry-points, which do not have an
accessor library, from reading of imports, exports and parts, which must
have an access library.
This change also disallows access to platform private libraries, like
dart:_internal, as entry-points.
Change-Id: I017ca30231eb99dc8463266dca0973a02f6f0e30
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/223423
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Change-Id: Ida732167c7cbf7a8daec16220b7c3c4bc951dfa4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/223804
Reviewed-by: William Hesse <whesse@google.com>
Commit-Queue: Alexander Thomas <athom@google.com>
This expands the front_end's and analyzer's support for doc comment
references to include `/// [a.b.c]`. Such a reference must be to a
getter, setter, method, or constructor of a class or extension which
is referenced with an import prefix, such as `[async.Future.value]`.
In the existing support for two words, the two words are named
"prefix" and "token". In a three-word reference, the _first_ word
must be an import prefix, but I've chosen the new names,
"leadingPrefix", "prefix", and "token", to minimize the change.
If an improved change is desirable, considering the names from scratch,
I might choose something like "prefix", "container", and "identifier".
But these names will be applied to one-word and two-word references as
well, so `[async.Future]`, a reference to the Future class provided by
an import prefixed as 'async', would have a 'prefix' of null, a
'container' of 'async', and an identifier of 'Future'.
Bug: https://github.com/dart-lang/sdk/issues/47444
Change-Id: I7758ec16872677221c456dd1dd6dc2a4df0f6102
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/223661
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Branch coverage can't be enabled by a simple global flag, because this
causes problems when functions in an app-jit snapshot that didn't have
the flag enabled are compiled by a VM that has the flag enabled. In
particular, the coverage array will see a different set of token
positions, causing some important asserts to fail.
Change-Id: I35227252b5d271f20b01de99466c06708ec83ed8
TEST=CI
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/223360
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Liam Appelbe <liama@google.com>
Don't need to explicitly specify atomic library when using clang.
Fixes b/210496462
TEST=manual build, ci
Change-Id: I18d9e1f17541fad0a0bc28ab046bb79805c0da9f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/224000
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
Not every statement has a serialized position we can use for coverage.
For example, the otherwise part of an if statement doesn't have a
position. So for branch coverage, BuildStatement needs to return a token
position of the statement, so that we can pass it to the record coverage
instruction.
For example, if statement's otherwise fragment will look like this:
TokenPosition other_pos = TokenPosition::kNoSource;
Fragment otherwise_statement = BuildStatement(&other_pos);
otherwise_fragment += flow_graph_builder_->RecordCoverage(other_pos);
otherwise_fragment += otherwise_statement;
TEST=CI
Change-Id: Ibfb7b81bf0b98b12e850e60f565fcc0ced521f04
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/223900
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Liam Appelbe <liama@google.com>
This is not implied by ARMv7 per se, but is implied by the Debian and Android ABIs.
TEST=ci
Change-Id: Ie838eeec0e7e2e7e64e29e9ad69338532df16cbf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/223740
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
I'm experimenting with refactoring some code in a way that changes the
interface between the ResolverVisitor and the two visitors that
invokes (ElementResolver and StaticTypeAnalyzer). The division of
responsibility among these three classes is not very well-defined or
consistent due to their highly coupled nature and the fact that they
are always invoked in tandem. This makes it difficult to refactor
them without causing churn on the ElementResolver and StaticAnalyzer
unit tests.
This change reduces the churn by changing the ElementResolver and
StaticAnalyzer unit tests to invoke the full ResolverVisitor; this
makes the interface among the three classes a fully private
implementation detail, so that we can adjust it without causing any
test breakages.
Change-Id: Ice4c0d98138e59bac52ed67eecf3ee535ca75e1b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/223141
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
- Fix disassembly of 32-bit stxr/ldxr/stlr/ldar.
- Add missing disassembly of rbit.
- Use the standard names for arithmetic/logical ops with immediates.
- Fix name of csel.
- Fix operand ordering for conditional moves.
- Add preferred disassembly 'ret lr' -> 'ret'.
- Add preferred disassembly 'ands zr, a, b' -> 'tst a, b'.
- Add preferred disassembly 'sub a, zr, b' -> 'neg a, b'.
Overall our disassembly is nearly the same as standard A64 disassembly, except we use a "w" suffix for 32-bit operations instead of using "w" versus "x" register names, and we use our own register names.
TEST=ci
Change-Id: Ifb4e587b5cc490beb4c6a09145149d95b09d412d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/223680
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Minor refactoring to share building the map from argument names to
compiled instructions.
Fixes#47047
Change-Id: I20b8d37673bd4cb18aa8b2091af79e40ec498370
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/223381
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Stephen Adams <sra@google.com>