Commit Graph

19284 Commits

Author SHA1 Message Date
Ryan Macnak 85b79f0856 [vm, gc] Refactor the concurrent sweeper so that work-in-progress is accessible to other threads.
This is prep work for allowing the main thread to contribute during idle time or when waiting for the sweeper to catch up.

TEST=ci
Change-Id: Ia25c61a448bf5d2dada7d5b494ea08f3526d8740
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/228725
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-01-24 18:44:01 +00:00
Ryan Macnak b378da0c8b [vm, compiler] Fix constant array length overflowing I-type immediate.
TEST=fuzzer (frequently in the kernel-service)
Bug: https://github.com/dart-lang/sdk/issues/38587
Change-Id: Id42f2c5fc8cc0bc1de9147487c079fa0538eb0f1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/229327
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-01-22 00:35:40 +00:00
Ryan Macnak 884f765500 [vm] Remove --verify_handles.
TEST=ci
Change-Id: I22a84596f44d43133806b121a6404a41a00a38f3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/228901
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-01-21 21:24:20 +00:00
Ryan Macnak 90542c2903 [vm] Alternate fix for mismatch between native and intrinsic versions of writeIntoOneByteString.
TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/48194
Change-Id: I8baa500e220db43d894498c59211831d15af1b4e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/229322
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-01-21 19:32:40 +00:00
Daco Harkes 5183ba3ca4 Revert "[vm/ffi] Add common C types"
This reverts commit 85a87ca7ae.

Reason for revert: 

* Adding `Char` breaks `package:win32` which is used in Flutter so it
breaks the Flutter build:
https://logs.chromium.org/logs/flutter/buildbucket/cr-buildbucket/8824468064587445729/+/u/Android_Views_Integration_Tests/stdout

For reference: full list of Flutter failues:
https://github.com/flutter/flutter/runs/4890844911

Original change's description:
> [vm/ffi] Add common C types
>
> We're adding these types to `dart:ffi` rather than `package:ffi` so that
> they can be used with `FfiNative`s.
>
> Adds `NativeType`s for the following C types:
>
> * char
> * unsigned char
> * signed char
> * short
> * unsigned short
> * int
> * unsigned int
> * long
> * unsigned long
> * long long
> * unsigned long long
> * uintptr_t
> * size_t
> * wchar_t
>
> Because the C standard only defines minimum sizes for many of these
> types, future platforms might diverge from the typical size even if all
> platforms currently agree on a size. To avoid having to reification
> later, we define all types as AbiSpecificIntegers rather than typedefs,
> even if all current target platforms agree on the size.
>
> Closes: https://github.com/dart-lang/sdk/issues/36140
>
> TEST=tests/ffi/c_types_test.dart
>
> Change-Id: Ie97d253856d787386529231e8060f879069be886
> Cq-Include-Trybots: luci.dart.try:dart-sdk-linux-try,dart-sdk-mac-try,dart-sdk-win-try,vm-ffi-android-debug-arm64c-try,vm-ffi-android-debug-arm-try,vm-canary-linux-debug-try,vm-fuchsia-release-x64-try,vm-kernel-gcc-linux-try,vm-kernel-asan-linux-release-x64-try,vm-kernel-linux-debug-x64-try,vm-kernel-linux-debug-ia32-try,vm-kernel-mac-debug-x64-try,vm-kernel-mac-release-arm64-try,vm-kernel-nnbd-win-release-ia32-try,vm-kernel-nnbd-win-release-x64-try,vm-precomp-ffi-qemu-linux-release-arm-try,vm-kernel-win-release-x64-try
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/228541
> Reviewed-by: Martin Kustermann <kustermann@google.com>

# Not skipping CQ checks because original CL landed > 1 day ago.

Change-Id: Ic56df88c653b1395ed5e5a71af5e571b1adc3671
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/229152
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2022-01-21 17:05:42 +00:00
Alexander Markov 2a34453dd1 [vm/aot] Improve AOT compilation speed by using better hash codes
This change improves hash code implementations in multiple places in
the compiler. That reduces number of probes during lookups in hash maps
and improves AOT compilation time of large applications.

On a large Flutter app, compiled in release mode for arm64:
Total gen_snapshot time 89.184s -> 60.736s (-31.9%)

Also, this change adds --hash_map_probes_limit=N option which sets
a hard limit for the number of probes in hash maps. This option
makes it easy to find hash maps where there are many collisions
due to poor hash code implementation.

TEST=ci

Issue: https://github.com/dart-lang/sdk/issues/43299
Bug: b/154155290
Change-Id: Ibf6f37d4b9f3bf42dd6731bfb4095a7305b98b2d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/229240
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2022-01-21 02:02:00 +00:00
Daco Harkes 85a87ca7ae [vm/ffi] Add common C types
We're adding these types to `dart:ffi` rather than `package:ffi` so that
they can be used with `FfiNative`s.

Adds `NativeType`s for the following C types:

* char
* unsigned char
* signed char
* short
* unsigned short
* int
* unsigned int
* long
* unsigned long
* long long
* unsigned long long
* uintptr_t
* size_t
* wchar_t

Because the C standard only defines minimum sizes for many of these
types, future platforms might diverge from the typical size even if all
platforms currently agree on a size. To avoid having to reification
later, we define all types as AbiSpecificIntegers rather than typedefs,
even if all current target platforms agree on the size.

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

TEST=tests/ffi/c_types_test.dart

Change-Id: Ie97d253856d787386529231e8060f879069be886
Cq-Include-Trybots: luci.dart.try:dart-sdk-linux-try,dart-sdk-mac-try,dart-sdk-win-try,vm-ffi-android-debug-arm64c-try,vm-ffi-android-debug-arm-try,vm-canary-linux-debug-try,vm-fuchsia-release-x64-try,vm-kernel-gcc-linux-try,vm-kernel-asan-linux-release-x64-try,vm-kernel-linux-debug-x64-try,vm-kernel-linux-debug-ia32-try,vm-kernel-mac-debug-x64-try,vm-kernel-mac-release-arm64-try,vm-kernel-nnbd-win-release-ia32-try,vm-kernel-nnbd-win-release-x64-try,vm-precomp-ffi-qemu-linux-release-arm-try,vm-kernel-win-release-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/228541
Reviewed-by: Martin Kustermann <kustermann@google.com>
2022-01-20 14:41:46 +00:00
Daco Harkes ec25866143 [vm/status] Clean up FFI simulator and win-precomp entries
Clean up the entries related to
https://github.com/dart-lang/sdk/issues/40579 and
https://github.com/dart-lang/sdk/issues/37299.

On Windows tests should only be skipped if running in precompiled.

Change-Id: I13d2b3c197553f47ec7035fea65935bb8bb7c63a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/229142
Reviewed-by: Tess Strickland <sstrickl@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2022-01-20 09:06:36 +00:00
Ryan Macnak 04ba20aa98 [vm] Support RISC-V.
Implements a backend targeting RV32GC and RV64GC, based on Linux standardizing around GC. The assembler is written to make it easy to disable usage of C, but because the sizes of some instruction sequences are compile-time constants, an additional build configuration would need to be defined to make use of it.

The assembler and disassembler cover every RV32/64GC instruction. The simulator covers all instructions except accessing CSRs and the floating point state accessible through such, include accrued exceptions and dynamic rounding mode.

Quirks:
  - RISC-V is a compare-and-branch architecture, but some existing "architecture-independent" parts of the Dart compiler assume a condition code architecture. To avoid rewriting these parts, we use a peephole in the assembler to map to compare-and-branch. See Assembler::BranchIf. Luckily nothing depended on taking multiple branches on the same condition code set.
  - There are no hardware overflow checks, so we must use Hacker's Delight style software checks. Often these are very cheap: if the sign of one operand is known, a single branch is needed.
  - The ranges of RISC-V branches and jumps are such that we use 3 levels of generation for forward branches, instead of the 2 levels of near and far branches used on ARM[64]. Nearly all code is handled by the first two levels with 20-bits of range, with enormous regex matchers triggering the third level that uses aupic+jalr to get 32-bits of range.
  - For PC-relative calls in AOT, we always generate auipc+jalr pairs with 32-bits of range, so we never generate trampolines.
  - Only a subset of registers are available in some compressed instructions, so we assign the most popular uses to these registers. In particular, THR, TMP[2], CODE and PP. This has the effect of assigning CODE and PP to volatile registers in the C calling convention, whereas they are assigned preserved registers on the other architectures. As on ARM64, PP is untagged; this is so short indices can be accessed with a compressed instruction.
  - There are no push or pop instructions, so combining pushes and pops is preferred so we can update SP once.
  - The C calling convention has a strongly aligned stack, but unlike on ARM64 we don't need to use an alternate stack pointer. The author ensured language was added to the RISC-V psABI making the OS responsible for realigning the stack pointer for signal handlers, allowing Dart to leave the stack pointer misaligned from the C calling convention's point of view until a foreign call.
  - We don't bother with the link register tracking done on ARM[64]. Instead we make use of an alternate link register to avoid inline spilling in the write barrier.

Unimplemented:
 - non-trivial FFI cases
 - Compressed pointers - No intention to implement.
 - Unboxed SIMD - We might make use of the V extension registers when the V extension is ratified.
 - BigInt intrinsics

TEST=existing tests for IL level, new tests for assembler/disassembler/simulator
Bug: https://github.com/dart-lang/sdk/issues/38587
Bug: https://github.com/dart-lang/sdk/issues/48164
Change-Id: I991d1df4be5bf55efec5371b767b332d37dfa3e0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/217289
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-01-20 00:57:57 +00:00
Ryan Macnak 4088cd083d [vm] Add missing Dart_ThreadStartCallback.
For symmetry with Dart_ThreadExitCallback. Can be used by an embedder to change thread priority or attach native resources to the thread.

TEST=ci
Change-Id: Ic8eaba7204d0be42db26523b62cbfac3ecb7151f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/227661
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-01-19 23:14:36 +00:00
Daco Harkes 251db3d921 [vm] Implement WeakReference with WeakProperty
A simple implementation which use two objects per weak reference and
two loads for a load from a weak reference. This can be optimized later.

TEST=runtime/tests/vm/dart/finalizer/weak_reference_run_gc_test.dart

Design doc: go/dart-vm-weakreference

Bug: https://github.com/dart-lang/sdk/issues/47777

Optimization tracking bug: https://github.com/dart-lang/sdk/issues/48162

Change-Id: Id0b71caef940c610f85212fda4bdc267bf84edea
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/+/228206
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2022-01-19 20:52:56 +00:00
Alexander Markov 5bbf141e9f [vm] Support arbitrary superclasses for enums
With enhanced enums language feature enum classes can have a mixin, so
its superclass is an arbitrary class and not necessarily _Enum.
This change removes lookups of 'index' and '_name' fields in the
superclass of an enum class. They are now looked up once in _Enum
class and saved in the object store.

TEST=co19/LanguageFeatures/Enhanced-Enum/semantics_A01_t01

Issue: https://github.com/dart-lang/sdk/issues/47861
Change-Id: I2b93d389ab92e0274641e0f1bd65471e6407f3f9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/228220
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2022-01-18 21:48:56 +00:00
Ryan Macnak a5554dc945 [vm] Remove disused Dart_HintFreed.
Uses of this API were replaced with explicit disposal.

TEST=ci
Change-Id: Id6c391c74d77e6a6c6b5b70e446a8abe92294b7a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/228081
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-01-18 21:46:55 +00:00
Alexander Markov 91154e78a3 [vm/compiler] Ensure that right operand range is set for ShiftUint32Op created during range analysis
Code generation for shift instructions relies on the range information
for the right operand in order to generate shifts by constants and omit
certain runtime checks.

When range analysis creates ShiftUint32Op it has not been setting
range of the right operand, which resulted in suboptimal code.
This change fixes that by using BinaryIntegerOpInstr::Make which
initializes range of the right operand if it is a constant.

TEST=vm/cc/RangeAnalysis_ShiftUint32Op
Fixes https://github.com/dart-lang/sdk/issues/48153

Change-Id: I7df4bb86745bad8712862e3ea07c75b2c4898288
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/228684
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2022-01-18 21:21:35 +00:00
Ben Konyi 3d53bf57a0 [ Service ] Fix --log_service_response_sizes being enabled in tests by default
String.fromEnvironment doesn't return null when a variable isn't
defined, instead returning empty string by default. This was causing
service response size logging to be enabled for all tests.

TEST=N/A

Change-Id: Id05693d8a8898deee422e58f627e540cafe59aa0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/228682
Reviewed-by: Alexander Thomas <athom@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2022-01-18 19:20:05 +00:00
Daco Harkes 9e1eff924b [vm] Remove dead runtime entries for WeakProperty
TEST=This is removing dead code, running one VM bot should be enough.

Change-Id: I9938ecf89fa2f27e6434d39dd65d860e61c632e4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/228205
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2022-01-18 19:15:25 +00:00
Alexander Markov 0ffcecb93d [vm/aot] Improve AOT compilation speed by using better hash in code deduplication
On a large Flutter app, compiled in release mode for arm64:
Total gen_snapshot time 112.762s -> 89.595s (-20.5%)
(Dedup pass 34.58s -> 11.03s)

TEST=ci

Issue: https://github.com/dart-lang/sdk/issues/43299
Bug: b/154155290
Change-Id: If5ce4cf6a26e4a0300de6bc1864854f4deedffa3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/228281
Auto-Submit: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2022-01-17 15:07:24 +00:00
Ryan Macnak a771d6eaed [vm] Minor ARM64 code generation improvements discovered during RISC-V port.
TEST=ci
Change-Id: I4bd17df224933f732eb9cef0a9b2da8dfad0a7d4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/227940
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-01-13 18:28:21 +00:00
Alexander Markov 0e5a539315 [vm/aot] Keep toString methods on exception classes in toString transformer
Flutter in google3 uses --delete-tostring-package-uri compiler option
to remove toString methods in package:flutter and dart:ui to reduce
size in release mode.
This has unfortunate effect of removing toString methods from exception
classes which may provide valuable information for investigating
problems seen in the wild.

This change adds a new @pragma('flutter:keep-to-string-in-subtypes')
on classes to keep toString methods on all subtypes of the annotated
classes. This pragma is now used on Exception and Error classes in
dart:core.

TEST=pkg/vm/test/transformations/to_string_transformer_test.dart

Issue: https://github.com/flutter/flutter/issues/61562
Change-Id: Ib739c83cdf6b539208f705ba198e63b8bc54fa61
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/227920
Reviewed-by: Dan Field <dnfield@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2022-01-13 15:32:50 +00:00
Liam Appelbe 9d79a890f3 [vm] Adding branch coverage RPC to source report
TEST=Unit tests and an integration test
Bug: https://github.com/dart-lang/coverage/issues/141
Change-Id: I84958091dc6f9753f5e9446bb3517a8099019981
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/222541
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Liam Appelbe <liama@google.com>
2022-01-12 19:12:04 +00:00
Ryan Macnak d1135bbbd5 [vm, compiler] Remove magic number from WordOffsetFromFpToCpuRegister.
This constant will have a different value for RISC-V.

TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/38587
Change-Id: I2d14c42351b1c5b39aa4538a07553c347251fd3e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/227382
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-01-12 18:59:02 +00:00
Vyacheslav Egorov 226d3c69f4 [vm/compiler] Remove EmitMoveConst
This function contains some questionable and possibly buggy code.

Instead of fixing it we simply delete it because it is currently never
called and thus any fixes to this function can't really be tested
except in isolation.

TEST=ffi suite on CI.

Change-Id: Ifdc7fcb1e9bf9cfa19e0831132b52798a9da3eab
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/227741
Auto-Submit: Slava Egorov <vegorov@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2022-01-12 14:58:33 +00:00
Martin Kustermann e767dca0a6 [vm] Make stack trace generation code more conservative
If the _FutureListener.handleValue function gets deoptimized at a point
when the `this` is no longer needed/live the deoptimization procedure
may override the `this` slot in the caller frame with "<optimized out>".

This has been triggered on the "iso-stress" builder due to using VM
testing flags that cause many deoptimizations in many places.

The stack walking code should take this possibility into consideration
and be therefore conservative.

Alternatives considered:

  * Use "copy parameters" into our own frame approach - like we do
    with methods that  have optional parameters
    => This will make all unoptimized code slower.

  * Add a reachability fence to the _FutureListener.handleValue function
    => The reachabilityFench is only available in dart:_internal for VM
    => If the function could be debugged after fence but before return
       one might be able to trigger the issue nonetheless.

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

TEST=Should remove flaky crashes on "iso-stress" builder.

Change-Id: I9d953706b292e02d2ba75fd794c872865faf45d0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/227401
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2022-01-12 08:30:42 +00:00
Ben Konyi 2db8f37cfa [ Service ] Add line/column information to SourceLocation objects
Removes the need for requesting a full Script object, which can be
extremely large when including source code. This change will have a
relatively small impact on response sizes.

Related issues: https://github.com/dart-lang/sdk/issues/47215, https://github.com/flutter/devtools/issues/3382

TEST=pkg/vm_service tests updated

Change-Id: I27999c4b1da65d4f0c643fa8db1a019c0fd1d689
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/227640
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2022-01-12 02:09:24 +00:00
Ryan Macnak c9e3868afb [vm] Remove dead Dart_IsolateUnhandledExceptionCallback.
TEST=ci
Change-Id: I3446cac336330c3fcc1b09729c5a0b03eae4a4ec
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/227660
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-01-12 00:03:24 +00:00
Ben Konyi ea48265725 Reland "[ VM / Service ] Omit private fields from service responses by default"
Adds better error handling in DDS to prevent google3 breakages due to
Flutter binary update lag times.

This reverts commit 28e958febb.

TEST=N/A

Change-Id: Ida454f0ef3caeedd1b0326c37fef58d4b73557d5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/227620
Reviewed-by: Siva Annamalai <asiva@google.com>
2022-01-11 23:35:28 +00:00
Daco Harkes e57dae8df5 [vm/ffi] Implement IntPtr as AbiSpecificInteger
Closes: https://github.com/dart-lang/sdk/issues/47938

TEST=tests/ffi*

Change-Id: I78cef41522813569f7e09ce31ce74ba615c070ed
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/+/227162
Reviewed-by: Martin Kustermann <kustermann@google.com>
2022-01-11 22:04:15 +00:00
Ryan Macnak 28e522ed97 [vm] Don't include an isolate in getVM until it has been registered with the service isolate routing.
TEST=low probability Collected error on all uses of vm service
Bug: https://github.com/dart-lang/sdk/issues/33747
Bug: https://github.com/dart-lang/sdk/issues/46450
Change-Id: I7b8d08a734033d0678a539230d13ec3d66413961
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/63645
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-01-11 18:19:15 +00:00
Ryan Macnak d63a44e11f [vm] Distinguish between C and Dart frame layouts in the profiler's stack walker.
This can differ in simulator builds.

TEST=stack traces on assertion failures in simriscv64
Bug: https://github.com/dart-lang/sdk/issues/38587
Change-Id: Ib5aae0f2b7af2bf64fc4ae0f1dddadea6670a88d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/227381
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-01-11 17:57:30 +00:00
Johnni Winther 8510f27d37 [cfe] Change encoding of supported dart: libraries
This CL changes the way dart: libraries are considered supported when
used in conditional imports or bool.fromEnvironment constant using
the "dart.library.*" values.

Library nodes now has an isUnsupported flag which is set according to
the "supported" property in the libraries specification. Furthermore
the Target now supplies a DartLibrarySupport interface that allows
targets to override whether dart: libraries are unsupported.

This allows the JIT/AOT to use the same platform file but still
consider dart:mirrors unsupported in AOT mode, and dart2js to consider
the internal library `dart:_dart2js_runtime_metrics` supported.

Furthermore, the internal handling is changed so that condition imports
and bool.fromEnvironments constants are computed through the same logic
for "dart.library.*" values, avoiding the need for passing these values
through the environment.

TEST=pkg/front_end/testcases/general/supported_libraries/main

Closes https://github.com/dart-lang/sdk/issues/48057
Closes https://github.com/dart-lang/sdk/issues/47814
Closes https://github.com/dart-lang/sdk/issues/47243
Closes https://github.com/dart-lang/sdk/issues/32657
Closes https://github.com/dart-lang/sdk/issues/36460

Change-Id: Ie8f8dff99167de64ced51b71d89918bf0f3bbd13
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/227020
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2022-01-11 14:52:38 +00:00
Ivan Inozemtsev 28e958febb Revert "Reland "[ VM / Service ] Omit private fields from service responses by default""
This reverts commit 91a496e5db.

Reason for revert: breaks hot reloads internally

Original change's description:
> Reland "[ VM / Service ] Omit private fields from service responses by default"
>
> This reverts commit 7d39d2dd51.
>
> TEST=N/A
>
> Change-Id: I2119c841719c77be5380857ce209532ed036bd0e
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/226322
> Reviewed-by: Siva Annamalai <asiva@google.com>
> Commit-Queue: Ben Konyi <bkonyi@google.com>

# Not skipping CQ checks because original CL landed > 1 day ago.

Change-Id: I6e751343244a4788a1f080ea1aef5fdd18417109
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/227503
Reviewed-by: Alexander Thomas <athom@google.com>
Commit-Queue: Ivan Inozemtsev <iinozemtsev@google.com>
2022-01-11 14:06:04 +00:00
Ryan Macnak 1741c6989c Revert "[tsan] Force early ICU initialization to avoid spurious data race warnings."
This reverts commit 20f1a954fe.

Reason for revert: Didn't help

Original change's description:
> [tsan] Force early ICU initialization to avoid spurious data race warnings.
>
> TEST=isolate-stress
> Bug: https://github.com/dart-lang/sdk/issues/46699
> Bug: https://bugs.fuchsia.dev/p/fuchsia/issues/detail?id=83298
> Change-Id: I0f3c9f5e2ffde7eb84638f52e7af9e285f5316f7
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/221661
> Reviewed-by: Alexander Aprelev <aam@google.com>
> Commit-Queue: Ryan Macnak <rmacnak@google.com>

# Not skipping CQ checks because original CL landed > 1 day ago.

Bug: https://github.com/dart-lang/sdk/issues/46699
Bug: https://bugs.fuchsia.dev/p/fuchsia/issues/detail?id=83298
Change-Id: Id712efc01da8114552035f01743c88f1147fe35f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/227383
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2022-01-10 22:56:33 +00:00
Alexander Aprelev b355060ad9 [vm/isolate_exit] Fix isolate_exit_sandwich_test so it works in precompiled mode.
This is a follow-up to cb64a64241.

TEST=isolate_exit_sandwich_test in dartkp mode
Fixes https://github.com/dart-lang/sdk/issues/48106

Change-Id: I25a4d318c10250bde5f6f6bfd370b011ba3b555e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/227000
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2022-01-10 21:28:45 +00:00
Martin Kustermann e3181ae398 [vm] Initialize Scavenger::growth_control_ to avoid read of uninitialized memory
Issue b/209838275#comment31

TEST=ci

Change-Id: Ie879e6295580ed3422ee430fae3e78457a3308a9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/227160
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2022-01-10 12:05:31 +00:00
William Hesse 05b19a2218 Bump SDK version to 2.17
TEST=Standard CQ

Change-Id: I0eba9fa6eaa73bf9da8abdd93645a8e6eb8e601b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/226691
Reviewed-by: Alexander Thomas <athom@google.com>
Commit-Queue: William Hesse <whesse@google.com>
2022-01-10 11:05:10 +00:00
Alexander Aprelev cb64a64241 [vm/isolate_exit] Ensure ffi code exits if isolate is exiting.
When ffi code calls Dart code that requests the isolate to exit(via Isolate.exit, for example), we ensure that isolate indeed exits on return from ffi call.
This is implemented by introduction of new safepoint bit which, once set, forces ExitSafepoint to propagate unwind error.

TEST=isolate_exit_sandwich_test

Change-Id: I2e8f5ecec7f4e59ae5f99b9525cc566f20d4b6a8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/219846
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2022-01-08 06:01:08 +00:00
Alexander Markov 8ec91ff653 [vm] Support absent 'values' field in enum classes
VM queries the list of enum elements during class finalization
in order to be prepared for the future hot reload. This is done by
reading 'values' field. However, 'values' field can be missing if
running from a dill file which was tree-shaken. This change avoids
crash in that case and handles missing 'values' field as if it was
declared with an empty list.

TEST=Manually tested in g3.

Issue: https://github.com/dart-lang/sdk/issues/47861
Bug: b/213584901
Change-Id: Ic7271476ee115aa93a73a824af3a867784b820eb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/226981
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2022-01-07 22:13:36 +00:00
Ben Konyi 4475267f70 [ VM / Service ] Add --log_service_response_sizes=<log.csv> debug option
Providing `--log_service_response_sizes` will cause the VM to log VM service
response sizes to the provided file in CSV format.

Also added `--service_response_sizes_directory` to the service test
runner to allow for collecting response size data for the entire service
test suite.

TEST=Local

Change-Id: I7aaf4ba936e2593e67d46ff9052e2130374ef461
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/226805
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2022-01-07 21:22:56 +00:00
Alexander Markov a09c585772 [vm/aot] Keep static type of a conditional expression when removing it in tree shaker
In order to make sure static types in kernel AST are still correct
after tree shaking, tree shaker needs to insert no-op unsafeCast calls
when removing conditional expressions, as ConditionalExpression nodes
have explicit 'staticType' which may be different from static types of
sub-expressions.

Otherwise we might end up with an untyped function call
(FunctionInvocation with FunctionAccessKind.Function)
performed from a receiver with a known function type.
That would violate VM's assumptions about static type of receiver
being checked by the front-end and trigger assertion in
pkg/vm/lib/transformations/call_site_annotator.dart.

TEST=runtime/tests/vm/dart/untyped_function_invocation_with_known_function_type_test.dart
TEST=pkg/vm/testcases/transformations/type_flow/transformer/null_test_elimination2_nnbd_strong.dart

Change-Id: I6bf201a979d1b71eb48ed04f154adf2b62dac922
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/226741
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2022-01-07 14:22:26 +00:00
Ryan Macnak afe3c12b25 [vm] Move handles for the no-callbacks and unwind-in-progress errors to the VM isolate so there is no Dart allocation and no handle allocation during these errors.
TEST=ci
Change-Id: I0567cf8a9b4361df312cb4958fc7438296b65604
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/226605
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-01-06 18:38:28 +00:00
Ben Konyi 91a496e5db Reland "[ VM / Service ] Omit private fields from service responses by default"
This reverts commit 7d39d2dd51.

TEST=N/A

Change-Id: I2119c841719c77be5380857ce209532ed036bd0e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/226322
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2022-01-06 18:05:36 +00:00
Alexander Markov 540dde6329 [vm] Replace synthetic expression evaluation classes with real classes in types
When loading and compiling a function for expression evaluation
we might reference synthetic class of that function in types
(e.g. receiver type). However, that class is not registered
(so it could be garbage collected) and it has kIllegalCid.
Types constructed using such class are not very useful and
may crash if class is queried (for example if type is finalized).

This change attempts to replace such synthetic classes with
real classes in types constructed during loading.

TEST=ci

Issue: https://github.com/dart-lang/sdk/issues/48024
Change-Id: I6c5c1b1d20ac2ce4c43e5a7e456d5a8756a43727
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/226603
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2022-01-06 16:12:55 +00:00
Vyacheslav Egorov 47328d209e [gardening] Update Inliner_List_generate test expectations.
6daf74f845 has eliminated the boxing
operation on 32-bit platforms.

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

TEST=ci

Fixed: 48083
Cq-Include-Trybots: luci.dart.try:vm-kernel-linux-release-simarm-try
Change-Id: I69f716edb97cf565910dc71da85af0d9ac5cf3a8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/226680
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2022-01-06 10:47:30 +00:00
Ryan Macnak 0ec95bf5ee [vm] Define kFpuRegisterSize based on the target architecture, not the host architecture.
TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/47802
Change-Id: Icf4522df4109dd653727aa988ba4dccd8f939ae2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/226420
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-01-05 22:03:44 +00:00
Alexander Aprelev eb4eade02a [vm/gen_snapshot] Avoid redundant compilation when generating kernel snapshot.
Fixes https://github.com/dart-lang/sdk/issues/39580
TEST=ci

Change-Id: I98e7201350433754c9ff1746e1d6e24b7107099e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/225740
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2022-01-05 17:51:26 +00:00
Alexander Markov 48124495f6 [vm/compiler] Do not forward loads of late fields to the uninitialized sentinel
This change avoids incorrect load forwarding when a load which calls
initializer is forwarded to a value which can potentially be
uninitialized sentinel.

If the value is actually uninitialized, then such load should
invoke initializer which may throw an exception or produce a different
value.

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

Change-Id: I48ee571747557b8a31e1afde67989809859ac6fa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/226281
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2022-01-05 16:11:54 +00:00
Alexander Markov b8690f8ea7 [vm/test] Fix vm/cc/IRTest_TypedDataAOT_FunctionalGetSet on arm
Make sure this unit test does not rely on AOT table dispatch as it is
not available in unit tests. This is done by avoiding 'operator ~/`
which is not optimized on certain ARMs and generated as a call which
needs dispatch table.

TEST=vm/cc/IRTest_TypedDataAOT_FunctionalGetSet
Fixes https://github.com/dart-lang/sdk/issues/48054

Change-Id: Icf102fbd01d7a479b5a79e6b840045642b20cc74
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/226300
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2022-01-05 15:21:14 +00:00
Alexander Markov f013751bf3 [vm] Prepare for enhanced enums
This change prepares VM for enhanced enums language feature.
List of enum values is now queried using 'values' static field
and not inferred from the list of fields (as enhanced enums allow
arbitrary fields).

TEST=ci

Issue: https://github.com/dart-lang/sdk/issues/47861
Change-Id: Id6eabb6c4ac5a5f03b22ceb67d57431082e22576
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/225020
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2022-01-04 22:40:03 +00:00
Ben Konyi dc0b571335 [ VM / CLI ] Remove service flags from VM and the CLI when building in
PRODUCT mode

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

TEST=Manual testing, CQ

Change-Id: I50e57fa653c45c892e748d4e283617200cee0c0a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/224860
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2022-01-04 19:53:11 +00:00
Ryan Macnak edde1ba38a [vm, compiler] Avoid one indirection when loading double constants.
TEST=ci
Change-Id: I3fc0a506121c660ae6c15a7c5e112fdf93a8ad90
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/224400
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-01-04 18:58:25 +00:00