Commit graph

19324 commits

Author SHA1 Message Date
Alexander Aprelev 6b830c4428 [vm/isolate/spawn] Ensure spawnFunction sends closure so type args are preserved.
Fixes https://github.com/dart-lang/sdk/issues/48035

TEST=spawn_generic_function_test

Change-Id: I28d0ea9123bd31cb1aa288824c3c7688fc2ca8f1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/232160
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2022-02-09 16:49:49 +00:00
Nate Bosch 33e174084a Replace Uri.scheme == with Uri.isScheme
Use `hasScheme` in place of comparing against the empty string, and
`isScheme` to compare against all other schemes.

TEST=No behavior changes.

Change-Id: Ifc9fd13c6cf37933ebd4a754c4b500dedbcb291b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/231185
Reviewed-by: Kevin Moore <kevmoo@google.com>
Commit-Queue: Nate Bosch <nbosch@google.com>
2022-02-08 21:38:57 +00:00
Alexander Markov 0cf751215e [vm] Correct token position for AssertAssignable in implicit field setters
The real token position is required in case debugger stopped on
an exception thrown from AssertAssignable and trying to evaluate
an expression which uses receiver. Without token position all local
variables (including receiver) are considered out of scope
(as frame's token position is out of range).

TEST=runtime/observatory/tests/service/regress_48279_test.dart
Fixes https://github.com/dart-lang/sdk/issues/48279

Change-Id: Idb6a8e12185367ceac2034269b8f046272384006
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/231748
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2022-02-08 19:28:36 +00:00
Brian Quinlan 085e978ce4 Fix on Windows, renaming a file using the Directory class generates an incorrect exception
TEST=unit
Bug: https://github.com/dart-lang/sdk/issues/47713
Change-Id: I603a452cece478ad5ddd85d47e9cfe02cee3f4d9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/231801
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Brian Quinlan <bquinlan@google.com>
2022-02-07 23:15:56 +00:00
Vyacheslav Egorov 72eb59f32a [vm/compiler] Allow WB elimination for small arrays.
Previously all arrays were excluded from WB elimination pass
to avoid invariant restoration code creating excessive work
for the GC and to avoid dealing with card marking in the
invariant restoration code.

It seems reasonable to enable this for small arrays of up to 8
elements. The cut of point of 8 elements was chosen based on the
cut of point for literal<N> specialisations provided by the
core library for creating small literal arrays.

TEST=vm/cc/IRTest_WriteBarrierElimination_Arrays

Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-dwarf-linux-product-x64-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: I2b3169865f07c3ff95820c1bc6718943e96bd33b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/229903
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2022-02-07 10:47:12 +00:00
Ben Konyi ad4d10a42c [ package:vm_service ] Migrate Observatory service tests to package:vm_service (Pt 2)
See https://github.com/dart-lang/sdk/issues/45037

TEST=pkg/vm_service/test/*

Change-Id: I0632744fdea0da63a47d64299cbd1f96f45dcb3a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/186742
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2022-02-05 00:12:29 +00:00
Martin Kustermann 4eaacc3df9 [vm] Improve async performance by taking advantage of static types of returned values
In general any async function can return X or Future<X>. Though the
future implementation has to do different things depending on which case
we're in. It does so by using a `<obj> is Future<T>` test. This test is very
expensive if many different classes flow into `<obj>`.

Though most functions do not return `Future` objects from async
functions. We can determine that statically by looking if any returned
expression could be a future. If not, we can bypass the `is Future<T>`
test entirely.

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

TEST=pkg/front_end/testcases/general/async_function_returns_future_or.dart

Change-Id: If655bdbdddc214dd7b12be9905b3c788252547d0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/230662
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2022-02-04 22:06:59 +00:00
Siva Annamalai 2e731c540a Revert "[tools] Replace the Chromium binary size tool, which no longer works."
This reverts commit e32d98cd06.

Reason for revert: Dart rolls into the engine are failing because there are references to run_binary_size_analysis in the "Upload artifacts android-arm64-release" step of the build

Original change's description:
> [tools] Replace the Chromium binary size tool, which no longer works.
>
> Change-Id: Id84717e21a129a392d3bc4e9b4cce84dfb4771e1
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/231066
> Reviewed-by: Ben Konyi <bkonyi@google.com>

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

Change-Id: Ibfbdf1e0a970ad7fae9ec1d39d24722647b38730
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/231600
Reviewed-by: Siva Annamalai <asiva@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
2022-02-04 02:11:06 +00:00
Ryan Macnak 172dad5375 [vm] Fix double and mint to inherit the PostLoad for instances.
Cf. ab3aab760e.

TEST=ci, aot
Change-Id: Ia1d0b5776d9714bde94f3372824f94dd70a7ae23
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/231532
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-02-04 00:10:47 +00:00
Ryan Macnak 33a1117d62 [vm] Add missing opt-out of C instructions to vm/cc/LoadWordUnsigned_0.
TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/38587
Change-Id: I15460a970522044b50f98922fad559d26c5813ea
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/231524
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-02-03 21:52:56 +00:00
Ryan Macnak ab3aab760e [vm] Remove special cases for canonicalizing doubles and mints.
dart_precompiled_runtime -7k

TEST=ci
Change-Id: I22c8254b08d9f68be02f7210aa60f7cc728f8b9d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/231324
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-02-03 21:13:36 +00:00
Ryan Macnak 4faf01a66c [vm] Cleanup workarounds for removed flag --throw_on_javascript_int_overflow.
TEST=ci
Change-Id: I65936b5cd6e5933eadc37f3cd6bba1f0fa1b81a5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/231328
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-02-03 21:10:46 +00:00
Ryan Macnak b6ab7350be [test] Inform status files about the new simulated architectures.
TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/37299
Bug: https://github.com/dart-lang/sdk/issues/38587
Change-Id: I6f1a749690b894b14f465d608f37acf62568cdef
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/231521
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-02-03 20:32:16 +00:00
Daco Harkes eacd2b3e3e [vm] WeakReference check target type
Closes: https://github.com/dart-lang/sdk/issues/48264

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

Change-Id: I16d9d9768bcef3c832960f0cd33ba54a0b689ed2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/231481
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2022-02-03 18:29:46 +00:00
Ryan Macnak f3996e4e96 [vm] Remove some dead error entry points.
TEST=ci
Change-Id: I78e13654ba4425e07e92a5a879595cae2045ea99
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/231360
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-02-03 17:55:16 +00:00
Vyacheslav Egorov aeb3e1d73b [vm] Avoid creating unnecessary SafepointPosition's
Register allocator does not need to associate always-calls
safepoints with live ranges of constant values because
constant values are never actually spilled and are rematerialized
instead.

@alexmarkov has observed that SafepointPosition objects for
constants account for large chunk of the total memory eaten by
the register allocation pass and this change addresses this issue.

With this change the total memory consumed by the register allocator
decreases from 21 Gb to 8.6 Gb on one of the examples
in https://github.com/flutter/flutter/issues/94461.

TEST=ci

Change-Id: I245f2678bc6f5c1d63fd282812d1df2b2958512f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/231442
Auto-Submit: Slava Egorov <vegorov@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2022-02-03 15:39:06 +00:00
Ryan Macnak 08164f88c9 [vm] Add missing safepoint transition when updating or deleting API handles.
TEST=tsan, iso-stress
Change-Id: I82f8fb8ef3bbedf510e34488fdaa7d8af5902830
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/231332
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-02-03 00:41:07 +00:00
Ryan Macnak e32d98cd06 [tools] Replace the Chromium binary size tool, which no longer works.
Change-Id: Id84717e21a129a392d3bc4e9b4cce84dfb4771e1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/231066
Reviewed-by: Ben Konyi <bkonyi@google.com>
2022-02-02 17:22:38 +00:00
Alexander Markov 45f42d0be8 [vm] Refactor duplicated slots and rename offsets
This change removes distinct Slots for the same field:

PointerBase_data_field -> PointerBase_data
Pointer_data_field -> PointerBase_data
TypedDataBase_data_field -> PointerBase_data

Also, the following slot is renamed to match field name:

TypedDataView_data -> TypedDataView_typed_data

The following offsets are renamed to match field names /
declarations in Untagged* classes:

PointerBase::data_field_offset -> PointerBase::data_offset
TypedData::data_offset -> TypedData::payload_offset
TypedDataView::data_offset -> TypedDataView::typed_data_offset


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

Change-Id: I602545fc43018494bcb24d8692292fdbc6a8f3e0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/231160
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2022-02-02 16:30:50 +00:00
Ryan Macnak a7faaaa148 [vm] Properly exclude the field descriptors from product builds.
TEST=ci
Change-Id: Ia9d345f7f6488b24b780979fd624d708c7038811
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/231182
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-02-02 00:32:25 +00:00
Ryan Macnak 6f9289ca30 [vm, compiler] Avoid false positive in assertion for eliminated write barrier.
This adjusts RISC-V to match the other architectures in checking only the generational barrier.

TEST=fuzzer
Change-Id: I86965bb2caaae27aa9770769f392cffc8edb6eb8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/231046
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-02-01 17:17:05 +00:00
Alexander Markov e4942db83e [vm/compiler] Avoid speculative conversion in ffi Pointer.asTypedList
On 32-bit ARM in AOT mode Pointer.asTypedList is generated so that
there is a LoadField from Pointer.data_field which has kUnboxedFfiIntPtr
representation (uint32) and then the value is passed to a
StoreInstanceField for TypedDataBase.data_field which has kUnboxedIntPtr
representation (int32). As a result, a speculative uint32->int32
IntConverter instruction is inserted by SelectRepresentations pass.
AOT doesn't support deoptimization so code generation crashes after
retrying without speculative inlining.

This change fixes the type incompatibility by loading value with
LoadUntagged and then converting it with ConvertUntaggedToUnboxed(kUnboxedIntPtr).

TEST=ffi/regress_flutter97301_test
Fixes https://github.com/flutter/flutter/issues/97301

Change-Id: I4a00d4ac7978b4775add0ddae510841a2b4cbae0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/230956
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2022-02-01 16:49:56 +00:00
Ivan Inozemtsev d7e3fadacd Revert "[vm] Disable longjmp() wrapper in exceptional flow in TSAN until g3 issue is fixed"
This reverts commit 8d412e80e1.

Reason for revert: b/209838275#comment53

TEST=ci

Original change's description:
> [vm] Disable longjmp() wrapper in exceptional flow in TSAN until g3 issue is fixed
>
> Issue b/209838275
>
> TEST=ci
>
> Change-Id: Ie0a2e6f68a0c4f855dfd367dd3dd0a37053be479
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/222760
> Reviewed-by: Ivan Inozemtsev <iinozemtsev@google.com>
> Commit-Queue: Martin Kustermann <kustermann@google.com>

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

Change-Id: Iab202ddbd54060f609096b71f8ef83da53249d40
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/231005
Reviewed-by: Ivan Inozemtsev <iinozemtsev@google.com>
Commit-Queue: Ivan Inozemtsev <iinozemtsev@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2022-01-31 15:49:54 +00:00
Alexander Aprelev 65178de9d2 [infra] Describe how to download large isolate artifacts(core dumps)
File browser web interface might fail to download large files, so one needs
to use cas tool to download those.

Change-Id: I8053860f9ba443dc481319e5574ecd6d41baf8f7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/225560
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2022-01-29 06:21:23 +00:00
Jens Johansen adb1dc9380 [VM] [CFE]: Make VM send over type information for expression compilation
Missing:
* Function types.
* Type variables in bounds, like "method<T, S extends T>() {}" and
  "method<T extends Foo<T>>() {}"

This is in many ways a follow-up to
https://dart-review.googlesource.com/c/sdk/+/212286

TEST=service and (cfe) expression suite tests added.

Change-Id: I20472b59ed73e9845f073e176d73b2c213f9407a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/215760
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2022-01-28 07:49:21 +00:00
Alexander Aprelev c925119c2f [vm] Ensure safepoint_state is updated atomically when unwinding.
Fixes https://github.com/dart-lang/sdk/issues/48229
TEST=ci,flutter

Change-Id: Ifa88ef2415ba325e9ba6fb39d96b395ac5846026
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/230520
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2022-01-27 21:58:24 +00:00
Alexander Markov 43af470c08 [vm/compiler] Avoid assertion failure on an unreachable Unbox with incompatible types
FinalizeGraph pass removes redefinitions and can change reachable
types of values. As a result, type of an input value of Unbox
instruction can become incompatibe with representation of the result of
Unbox, even if Unbox cannot deoptimize (this may happen if
the instruction is unreachable).

Previously, code generation failed with an assertion in that case.
This change adjusts code generation to silently generate load from
box instead.

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

Change-Id: I35f80a1b3135687901cd1b57c0e5572d29c4d2e0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/230341
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2022-01-27 21:11:41 +00:00
Jens Johansen 95731547be [observatory] Fix/workaround a few crashes
TEST=N/A

Change-Id: I992acd131cee6473827d3a4306c37678cbe55d2b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/229966
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2022-01-27 18:51:24 +00:00
Ryan Macnak cf2ad9d582 [vm, gc] Have the main thread assist with concurrent sweeping when it would wait.
TEST=ci
Change-Id: If7695b91253b8004b523fd6842bee0a417e8f17c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/228062
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-01-27 18:22:52 +00:00
Alexander Markov 76167c002d [vm/aot] Issue warning when compiling huge functions
Certain optimizations are disabled when compiling huge functions.
Also, compiling large functions may cause out of memory in compiler.

This change adds a warning in order to make it easier for users to
find out about huge functions in their programs and diagnose OOM
during compilation.

TEST=ci
Issue: https://github.com/flutter/flutter/issues/94461

Change-Id: Ibc7fb69df21fa96b8159d24c1b71ef8d690b23df
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/230160
Reviewed-by: Slava Egorov <vegorov@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2022-01-27 16:35:20 +00:00
Daco Harkes 045b9c1715 Reland "[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:

* 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

Original patch in patchset 1.

* Removes `Char` for now until package:win32 has rolled to 2.3.8 in
  Flutter. https://pub.dev/packages/win32/versions/2.3.8/changelog
  https://logs.chromium.org/logs/flutter/buildbucket/cr-buildbucket/8824468064587445729/+/u/Android_Views_Integration_Tests/stdout
* Adds `c_type.dart` in `ffi_source.gni` which should fix `IntPtr`
  missing when analyzing `path_provider_linux`. (However, I was unable
  to reproduce the issue locally.)
  https://logs.chromium.org/logs/flutter/buildbucket/cr-buildbucket/8824468064571399025/+/u/run_test.dart_for_flutter_plugins_shard_and_subshard_analyze/test_stdout
  `/tmp/flutter_plugins.KZMNMC/packages/path_provider/path_provider_linux$ ~/flt/engine/src/out/host_debug/dart-sdk/bin/dart  analyze --fatal-infos`

Change-Id: I89130cccba285fc9c483bb53f5710a302f2b104f
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,flutter-analyze-try,flutter-engine-linux-try,flutter-frontend-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/229156
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2022-01-27 13:09:01 +00:00
Alexander Markov 17563522da [vm/compiler] Minor improvements in hashcodes and test for inefficient hashes
This change improves a few implementations of hashcodes in compiler.
Slightly improves AOT compilation time:
gen_snapshot 60.736s -> 58.920s (-2.9%)
(on a large Flutter app, compiled in release mode for arm64).

Also, the same large app can be now compiled with
--hash_map_probes_limit=1500, meaning that all hash maps in
the compiler perform less than 1500 probes when looking for an
element.

This change also adds a test which verifies that kernel compiler
itself can be compiled with --hash_map_probes_limit=1000.
This is a sanity check to ensure we do not have a very
badly distributed hashcode in the compiler.

TEST=ci

Issue: https://github.com/dart-lang/sdk/issues/43299
Change-Id: I7a802709727a33760c4f1d13f7b2c8cb263852d7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/229940
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2022-01-26 23:44:31 +00:00
Ryan Macnak 9a00395504 [vm, x64] Use a shorter addressing mode for UnboxInt64.
TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/48221
Change-Id: I429b2d05aef595dd3ad148ada0aeb3a3225e2995
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/230200
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-01-26 22:18:17 +00:00
Ben Konyi 1c571a12fa [ CLI ] Migrate package:dartdev to null safety
Fixes https://github.com/dart-lang/sdk/issues/47964

TEST=CQ

Change-Id: I4ee57bc5739835824b0052bd9470a0d52ccf161b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/229948
Reviewed-by: Devon Carew <devoncarew@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2022-01-26 21:16:49 +00:00
Ryan Macnak 6eb5cde512 [vm] Remove dead flag declarations.
TEST=ci
Change-Id: I32297b9791462b4a9a03918cf5ee405a3354184c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/229720
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-01-26 18:58:58 +00:00
Daco Harkes dfcd594ebd [vm] Delete dead runtime entries
We do not have a byte code interpreter anymore, these runtime entries
are dead.

With enabling inlining for external functions (previous CL), the
`external-name` annotations can also be removed.

TEST=removes dead code
TEST=hashes: runtime/vm/compiler/recognized_methods_list.h

Change-Id: Ibf7f9598cfe52756f6645473f619cf8456f8f593
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/229961
Reviewed-by: Tess Strickland <sstrickl@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2022-01-26 13:09:58 +00:00
Daco Harkes 0ac2549604 [vm] enable inlining external functions
Closes: https://github.com/dart-lang/sdk/issues/48215

TEST=vm/cc/ReachabilityFence_Loop (IL matching fails if not inlined)

Change-Id: I268bf8abe38c81b7df87d2b7aef03fbd43ee517c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/229960
Reviewed-by: Martin Kustermann <kustermann@google.com>
2022-01-26 13:09:58 +00:00
Ryan Macnak f0e63afd9e [vm, gc] Allow the main thread to perform incremental marking during idle time.
Also allow the main thread to contribute to marking if concurrent marking does not complete before we hit the hard allocation limit.

TEST=ci
Change-Id: Ia6c35cf8b54adc6f1259c6bd03701c2c4cf849c8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/229284
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-01-25 23:18:07 +00:00
Ryan Macnak 9bc03ece9a [vm, compiler] Fix BinarySmiOpInstr(USHR, reg, reg) on RV64.
TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/38587
Change-Id: I29a532e8c8a1170dbd4f20e081c1a3f397ccc591
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/229700
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-01-25 22:54:47 +00:00
Daco Harkes 356a56193e [gardening,gcc] avoid error=maybe-uninitialized
TEST=simple refactor

Change-Id: I307b67337265ef7da663e00274358262d828bbd5
Cq-Include-Trybots: luci.dart.try:vm-kernel-gcc-linux-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/229902
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2022-01-25 17:48:27 +00:00
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