Commit Graph

18342 Commits

Author SHA1 Message Date
Franklin Yow 40441c9685 Update LICENSE
Changes to comply with internal review

Closes https://github.com/dart-lang/sdk/pull/45621
https://github.com/dart-lang/sdk/pull/45621

GitOrigin-RevId: 65ec4580e5b01658ddcb86b6a4c9301a482236ab
Change-Id: Icf2b758f8df81240758b9a0aaf11c3e6756fa574
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/194340
Reviewed-by: Alexander Thomas <athom@google.com>
2021-04-08 07:57:10 +00:00
Ryan Macnak 37616dae79 [vm] Account for the conditional nature of WeakSerializtionReference and WeakProperty references in clustered snapshots.
Fixes missing ref for WeakSerializationReference::target; fixes incorrect treatment of WeakProperties as strong references. Note isolate message snapshots still incorrectly treat WeakProperties as strong references.

TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/45609
Change-Id: I6dba93bc6f2e94886efde021fdf5c90a0dcb09b4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/194300
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2021-04-08 00:54:08 +00:00
Ryan Macnak fb181e87b9 [vm, service] Fill in more field names in retaining paths.
TEST=manual, runtime/observatory/tests/ui/inspector.dart
Bug: https://github.com/flutter/flutter/issues/79605#issuecomment-814342601
Change-Id: I1532dff15620835805cd2a8e9ddab693864f6eb4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/194112
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2021-04-07 23:05:58 +00:00
Alexander Markov f4a9cad199 [vm/compiler] Cleanup code duplication around Representation of array elements in LoadIndexed and StoreIndexed
This change removes code duplication between
LoadIndexedInstr::representation() and
StoreIndexedInstr::RequiredInputRepresentation(), multiplied by 4
target architectures.

This change also removes duplicated logic from FFI load and store
intrinsics.

TEST=ci

Change-Id: I9f10cc8c70288ecaea33a337a880c181ecbfcd6a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/194281
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2021-04-07 20:43:58 +00:00
Ben Konyi d18d3d837f [ dart:developer ] Add serverWebSocketUri to ServiceProtocolInfo
Adds a convenience getter to ServiceProtocolInfo which transforms the VM
Service HTTP URI into a valid web socket URI that can be used to connect
to the VM service.

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

TEST=runtime/observatory/tests/service/developer_server_control_test.dart

Change-Id: Ib15de1f1a9b26ac5cf45f55a53014761a6fa7900
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/194209
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Devon Carew <devoncarew@google.com>
2021-04-07 20:02:17 +00:00
Ben Konyi 81c87c5f2b [ VM ] Skip gen_snapshot_include_resolved_urls_test on simarm configs
Test requires knowledge of gen_snapshot location.

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

Fixed: 45605
Change-Id: Ia9fc018797d006d08efb8c17a8e0e980d20fb1df
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/194280
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2021-04-07 17:09:06 +00:00
Daco Harkes d27f166b75 [vm/ffi] Tree shaking of Struct sub classes
This CL enables tree shaking of `Struct` sub classes by simulating the
native behavior in Dart code.

We call the struct constructors in let expressions where FFI trampolines
are created which allocate these struct objects in native code. This way
TFA is instructed about the native behavior. The VM recognizes these
constructor calls as dead code and removes them.

For more info see go/dart-ffi-struct-treeshaking.

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

This CL fixes the types on the generated #fromTypedDataBase constructors.

Also, this CL also cleans up the struct naming:
* _addressOf   -> _typedDataBase
* _fromPointer -> _fromTypedDataBase
* #pointer     -> #typedDataBase

These cleanups are not split into a separate CL to prevent updating
the .expect files multiple times.

Finally, this CL enables running a single transformer test through:
`dart pkg/vm/test/transformations/type_flow/transformer_test.dart name`

TEST=pkg/vm/testcases/transformations/type_flow/transformer/ffi_struct_constructors.dart
TEST=tests/ffi(_2)/function_callbacks_structs_by_value_generated_test.dart
TEST=tests/ffi(_2)/function_structs_by_value_generated_test.dart

Change-Id: I418d0d73bc86b234dfe5b7b04ae726c33d2b8aeb
Cq-Include-Trybots: luci.dart.try:vm-precomp-ffi-qemu-linux-release-arm-try,vm-ffi-android-debug-arm64-try,vm-kernel-precomp-asan-linux-release-x64-try,vm-kernel-precomp-dwarf-linux-product-x64-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-obfuscate-linux-release-x64-try,analyzer-analysis-server-linux-try,analyzer-linux-release-try,dart-sdk-linux-try,vm-kernel-reload-rollback-linux-debug-x64-try,vm-kernel-reload-linux-debug-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/193661
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2021-04-07 11:02:27 +00:00
Tess Strickland bc924667f4 [vm/compiler] Add artificial nodes for dropped parent functions.
Fixes https://github.com/dart-lang/sdk/issues/45483

TEST=pkg/vm_snapshot_analysis/test/instruction_sizes_test

Cq-Include-Trybots: luci.dart.try:pkg-linux-release-try,pkg-mac-release-try,pkg-win-release-try
Change-Id: I9e347bd38ec339b22d2ecefcce1b276d8ce3e3e7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/193303
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
2021-04-07 04:48:46 +00:00
Alexander Markov cbada0ac1c [vm] Fix UB in materialization of Float32List
This is the follow-up to https://dart-review.googlesource.com/c/sdk/+/193831.
This change fixes undefined behavior corresponding to read from
the member of the union that wasn't most recently written.

TEST=ci

Change-Id: I5a74a75f8dca3526068880bfd3a848b611d6cbf2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/193887
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2021-04-07 00:12:09 +00:00
Ben Konyi 2a62fc49a3 [ VM / gen_snapshot ] Include resolved script URLs in non-PRODUCT AOT snapshots
Required for https://github.com/dart-lang/sdk/issues/37553

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

Change-Id: I0a2f6293566e5e5436df92d21e6bd38bb58c7654
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/193520
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2021-04-06 22:30:48 +00:00
Ben Konyi 2a2d83e9e9 [ VM / Service ] Add support for enabling/disabling breakpoints
This change adds a `setBreakpointState` RPC which allows for breakpoints
to be enabled or disabled without needing to remove and recreate
breakpoints.

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

TEST=set_breakpoint_state_test.dart

Change-Id: I1a04e6028d4e4560fdb8d3d26420c9a05da06b4b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/193896
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2021-04-06 22:16:06 +00:00
Alexander Markov 707cd928af [vm/ffi] Fix representation of value for 8-bit and 16-bit FFI loads and stores
Previously, FFI store could use kUnboxedUint32 for value being stored
via 8-bit or 16-bit StoreIndexed instruction. However, such
StoreIndexed instructions require kUnboxedIntPtr representation.
Due to the mismatch in the representations, SelectRepresentations
pass inserts a speculative (deoptimizing) IntConverter instruction,
which cases crash in AOT mode. Similar problem exists for FFI loads.

This change corrects representation when unboxing value in the body
of FFI store intrinsics and when boxing the value in FFI loads,
so representation of the value matches representation required by
StoreIndexed / returned by LoadIndexed.

TEST=ffi/regress_flutter79441_test
Fixes https://github.com/flutter/flutter/issues/79441

Change-Id: Ida144e8d2e7a69d6767c9d4447bb20e79d847d48
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/193824
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2021-04-06 21:11:23 +00:00
Alexander Markov a38a2dd343 [vm/aot] Fix retaining of targets of FFI callbacks in precompiler
Account for the fact that a Function could be only reachable via
FfiTrampolineData in the FFI trampoline function.

TEST=ffi_2/function_callbacks_test
Fixes https://github.com/dart-lang/sdk/issues/45510

Change-Id: I2db81c7730ae48d1f1355aa236339e54562ee6c4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/193893
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Tess Strickland <sstrickl@google.com>
2021-04-06 18:33:17 +00:00
Ryan Macnak ee3a86d8ab [vm] Avoid data race querying the new-space page cache.
This access is extremely infrequent, so we may as well consistently use the mutex.

TEST=tsan
Bug: https://github.com/dart-lang/sdk/issues/45521
Change-Id: I17b276f671e20c2eed8bf26735cc11c386fba9e6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/194013
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2021-04-05 22:48:16 +00:00
Ryan Macnak a6ffc74a4a [vm] Switch most Instances whose layout is determined in C++ to compressed pointers.
Instances whose layout must agree with a layout determined by Dart code are not switched: Array, GrowableObjectArray, Closure, LinkedHashMap.

TEST=ci
Change-Id: I19baf6473a29dd14f84aa1e087eee16b0e6e9d77
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/193442
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
Reviewed-by: Liam Appelbe <liama@google.com>
2021-04-05 17:43:16 +00:00
Alexander Aprelev 9302a7427b [vm/concurrency] Assert that no SafepointRwLocks are acquired while in SafepointOperationScope.
Attempts to acquire safepoint lock while in SafepointOperationScope could result
in deadlocks if somebody else was holding that lock when they were forced to a safepoint.
Clean up few places where locks were acquired in SafepointOperationScope.

Introduce StoppedMutatorsScope and GroupDebugger::RunUnderReadLockIfNeeded that acquires
a lock only if it runs outside of StoppedMutatorsScope - to prevent such deadlocks.

Also fix tsan warning about data race around message_notify_callback by making it atomic.

TEST=tsan runs of debugger CI tests

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

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

Change-Id: Ibb53d9ce760d869e044e17075aeebf20fc0016a5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/193582
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2021-04-03 03:36:32 +00:00
Leaf Petersen 39a2e69ea4 Enable non-function type aliases by default in 2.13.
TEST=language/nonfunction-type-aliases

Change-Id: Ifff4e838fbfc4f71e2d990e1f1f8a67b987adf91
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/192948
Commit-Queue: Leaf Petersen <leafp@google.com>
Reviewed-by: Erik Ernst <eernst@google.com>
2021-04-03 01:31:42 +00:00
Alexander Aprelev 8aee73537e [gardening] Another comment update to trigger g3 bot
TEST=ci

Change-Id: Iaf89c917341fdf96f344818d22f44f8d430537c3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/193894
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2021-04-02 21:44:35 +00:00
Alexander Aprelev a1697525c1 [gardening] Fix comment to trigger g3 bot
TEST=ci

Change-Id: I1a766d2bafa733b7c1914c5cdd56960493cf21d0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/193891
Reviewed-by: Alexander Aprelev <aam@google.com>
2021-04-02 19:46:43 +00:00
Alexander Aprelev abdca81fa0 Revert "[vm, service, observatory] Add ability to retrieve the set of all instances of a class, implementation hierarchy or interface hierarchy as an array."
This reverts commit 170bda2b74 as it breaks ffi test.

See https://github.com/dart-lang/sdk/issues/45564

TEST=rollback

Change-Id: Ie27cfa7c3bc093c1e8d46722942d1f2e5e3cb77e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/193882
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2021-04-02 16:46:11 +00:00
Alexander Aprelev d32e86aaff [vm/debugger] Speed up Debugger::IsDebugging and Function::HasBreakpoint checks.
Introduce GroupDebugger::IsDebugging check that doesn't need to iterate through all isolates debuggers to confirm whether some debugger is stepping through the code or if function has a breakpoint in it.
Replace Debugger::HasBreakpoint with GroupDebugger::HasBreakpoint.

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

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

TEST=existing ci test suite

Change-Id: I5250bbc05d77c1333d52fb0ecab5e9f7b6f8c651
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/193445
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2021-04-02 01:46:08 +00:00
Alexander Markov 38d05280e5 [vm/compiler] Fix materialization of Float32List
Before value is stored into Float32List, it is converted to 32-bit
float using DoubleToFloat instruction. If allocation sinking
eliminated the allocation of Float32List but we need to deoptimize,
the list is materialized and elements are filled. In such case,
we shouldn't perform double->float conversion as it already happened.

This change also updates the assertion in DoubleToFloatInstr::Canonicalize
which verifies that DoubleToFloat instruction can be used only
in certain cases.

TEST=tests/language/vm/allocation_sinking_arrays_test.dart
Fixes https://github.com/dart-lang/sdk/issues/45547

Change-Id: I9a1bd28a9fc09bccad6aa3c91a7880abd002f7c9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/193831
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2021-04-02 01:36:28 +00:00
Liam Appelbe 6b42491dcf [wasm] Remove deprecated dart_enable_wasm flag.
Change-Id: I37f326a30de20a895159f5b57a772cd808aa53d2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/193826
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Liam Appelbe <liama@google.com>
2021-04-01 22:45:07 +00:00
Ryan Macnak 170bda2b74 [vm, service, observatory] Add ability to retrieve the set of all instances of a class, implementation hierarchy or interface hierarchy as an array.
Allows developers to perform arbitrary filtering or analysis of instances, such as finding the largest strings, degreeses of duplication, histograms of various properties, etc.

TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/44479
Change-Id: I0b4005b5778038945e5f1b2d7858806c8e0dbbff
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/176381
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
2021-04-01 20:53:22 +00:00
Alexander Aprelev 22e9b612a1 [vm/isolate] Fix problems with sending RegExp to newly spawned isolate.
Fixes https://github.com/dart-lang/sdk/issues/41629

TEST=isolate_send_regex_test.dart

Change-Id: Ia8e00e175c9bca5c1c16cc2718f8b2d16cd37104
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/193755
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2021-04-01 19:52:32 +00:00
Ryan Macnak b888aeba16 [vm, compiler] Compute narrow types for unboxed fields even when their static types are wider than the unboxed type.
Fixes range analysis for loads of such fields.

TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/45524
Change-Id: I3d0bf8b3d988b74efadabcb52d06212745bb1ec3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/193745
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2021-04-01 18:29:12 +00:00
Alexander Aprelev e190a85f49 [io/socket] Handle OSError returned by Socket_GetPort.
Dart code did not expect OSError as a return value from Socket_GetPort.
This CL ensures that Dart code handles OSError in addition to int gracefully as a result of Socket_GetPort call.

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

TEST=run dart ci socket tests on mac with transparent proxy running

Change-Id: I198d99107729ccefecd9a16b71474ccdbfc0039b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/193221
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2021-04-01 18:04:12 +00:00
Ryan Macnak 76e41bc4c5 [vm, compiler] Use correct size of Smi when truncating during constant folding.
TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/45525
Change-Id: I048a90eade678f610f0fd4451b099711a1faa957
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/193750
Reviewed-by: Liam Appelbe <liama@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2021-04-01 16:19:42 +00:00
Alexander Aprelev e70690e415 [native_extensions] Convert uri to path so that on Windows native extension loading works.
Lookup of native extension library on Windows works when the library is next
to Platform.executable, this CL fixes lookup when it's next to the script.

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

TEST=updated sample_extension test

Change-Id: I91226be19ceec05e45cf90fd85428a62d95769c2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/193741
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2021-04-01 03:22:35 +00:00
Regis Crelier d0ee565bf8 [VM/runtime] Fix optimization for reusing instantiator type argument vector.
The bit vector representing the nullability of the types of a type argument vector was stored in reverse order.
This caused a problem when a longer instantiated vector is reused for a shorter uninstantiated vector.

This fixes https://github.com/dart-lang/sdk/issues/45529

TEST=added regression test

Change-Id: I0e936e45d51fa896d7562f4f03c8878437eb464f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/193751
Commit-Queue: Régis Crelier <regis@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2021-04-01 01:31:33 +00:00
Alexander Markov 2a14259fd0 [vm/compiler] Cleanup CheckedSmi* instructions
This is a final cleanup of CheckedSmiOpInstr and
CheckedSmiComparisonInstr instructions.

Their uses were removed in the following changes:

  https://dart-review.googlesource.com/c/sdk/+/191761
  https://dart-review.googlesource.com/c/sdk/+/191760
  https://dart-review.googlesource.com/c/sdk/+/193447

TEST=ci
Issue: https://github.com/dart-lang/sdk/issues/44852
Change-Id: Ica52ab9e2fcabab1913228818642a27a8d842f92
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/193449
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2021-03-31 22:10:42 +00:00
Corey Tabaka db0fa84d59 [vm] Optimize get current thread id in Fuchsia.
OSThread::GetCurrentThreadId() is used in many places throughout
the vm, particularly in facilities that are used heavily, such as
SafepointRwLock. The high frequency of invocations means that the
runtime overhead of getting the current thread id has a significant
impact on the overall performance of the vm.

The current Fuchsia implemention of OSThread::GetCurrentThreadId()
makes a syscall to get the koid of the current thread's handle,
resulting in hundreds of nanoseconds of unnecessary overhead per
invocation.

This patch changes to using the thread's handle as the id, which is
guaranteed to be unique for the lifetime of the thread, unless it
is closed prematurely (nothing in the vm does this). This approach
is similar to what MUSL libc (the libc used by Fuchsia) does for
the same purpose and has significant mileage.

Bug: b/182183059
TEST=existing ci test suite; manually deployed into Fuchsia build.

Change-Id: I274a793a823a717c8dd206b396001c6acb897b9a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/193643
Reviewed-by: Chase Latta <chaselatta@google.com>
Commit-Queue: Chase Latta <chaselatta@google.com>
2021-03-31 20:51:32 +00:00
Alexander Markov 4bf6de784c [vm/compiler] Null-aware EqualityCompare instruction
This change extends EqualityCompare IL instruction to handle case
when operands are nullable ints.

Unlike CheckedSmiComparison, EqualityCompare performs comparison
without making a dynamic call on a slow path. Dynamic call in
CheckedSmiComparison is a problem because it is not present in
the original program and not properly tracked in TFA and precompiler,
so precompiler is not able to drop Code objects (needed for
dynamic calls) reliably.

This change removes the remaining case when CheckedSmiComparison
instruction was used. The cleanup will follow in a separate CL.

TEST=ci
Issue: https://github.com/dart-lang/sdk/issues/32166
Issue: https://github.com/dart-lang/sdk/issues/44852
Change-Id: I8114a2616becf632462d4cb3bfc255691f24e1ef
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/193447
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2021-03-31 18:48:42 +00:00
Johnni Winther 9ca19cac6f [kernel] Change encoding of types in constants to not be offset by the context
Function type parameters in occurring in constants were using an offset
based on the context in which the constant first occurred. This meant
that function type parameters occurring in a generic context would have
a different offset that those occurring in a non-generic context.

The loading of .dill in ast_from_binary would read all constants outside
the context and would therefore get the indices wrong on generic
function types.

This CL changes the encoding of these type parameters to always use
a fresh context.

Closes #45415

TEST=pkg/front_end/testcases/generic_metadata/from_dill/main.dart

Change-Id: Ifdaedb4581f1e022c908fc58a58ceac3d7b0900e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/193481
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2021-03-31 12:31:43 +00:00
Alexander Aprelev 43333c319d Revert "[vm/debugger] Fix deadlock around GroupDebugger::breakpoint_locations_lock."
This reverts commit 6c710d27c2 as it
introduces a deadlock with use of readlock in ContainsOnlyOneIsolate
that runs under RunWithStoppedMutators.

https://dart-review.googlesource.com/c/sdk/+/193582 should be better fix
for the original problem.

TEST=ci

Change-Id: Ib7a0c5af5e55bbdeaa3d868f75482cb426a416fe
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/193640
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2021-03-31 05:12:26 +00:00
Alexander Aprelev 6c710d27c2 [vm/debugger] Fix deadlock around GroupDebugger::breakpoint_locations_lock.
We should not attempt to acquire a lock while we are in SafepointOperationsScope already.

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

TEST=flaky tsan failure on runtime/observatory_2/tests/service_2/break_on_function_many_child_isolates_test.dart with isolate groups enabled

Change-Id: I5f0072be20ed0a70135301121f6116b8e1c7d5f8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/193523
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2021-03-30 21:52:31 +00:00
Ryan Macnak fbc25f3dff [vm, compiler] Avoid undefined behavior when tracking induction variables wraps around.
TEST=ubsan
Bug: https://github.com/dart-lang/sdk/issues/45511
Change-Id: Iaa5733dc048a811c87f479fa54fdb89bf64a0373
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/193443
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2021-03-30 17:06:16 +00:00
Johnni Winther 13556d623f [cfe] Add DartType.toNonNull
Add helper on DartType to compute the `NonNull` of a type and use this
instead of `withDeclaredNullability(Nullability.nonNullable).

Includes a fix in the computation of NonNull of FutureOr.

TEST=existing

Change-Id: I3399cbf89c7d3f3e90f1315b01f40957e798a1b1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/193400
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
2021-03-30 10:25:28 +00:00
Alexander Aprelev 2ac0590f29 [vm/debugger] Refactor NotifyCompilation from per-isolate to per-isolate_group.
Keep list of all per-isolate BreakpointLocations on isolate_group so all of them
can be traversed by isolate group when function is compiled and
GroupDebugger::NotifyCompilation() is invoked.

This also fixes data race around line_number lazy-initialization.

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

TEST=existing ci test suite

Change-Id: I821b49a56cdc28da8d0c0c97e7d850995285c48a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/193380
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2021-03-30 00:46:07 +00:00
Regis Crelier e35ba5b9e3 [VM/runtime] Consider trail when comparing type parameter and bounds of function types.
Fixes https://github.com/dart-lang/sdk/issues/45443

TEST=added regression test

Change-Id: I82c581d9627d9eb1cf31d108a534fd4f5d6bb0a0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/192947
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Régis Crelier <regis@google.com>
2021-03-29 16:49:47 +00:00
Ben Konyi 0ab30e584b [ Service ] Mark pause_on_exception_from_slow_path_test as Slow
TEST=N/A

Change-Id: I570d977a84e60c478e08e933abf184a227231d05
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/193441
Reviewed-by: Siva Annamalai <asiva@google.com>
2021-03-29 16:45:06 +00:00
Ryan Macnak a4fa50892d [dartfuzz] Add compressed pointer modes.
Change-Id: I2a3b3ae6c5d903e654ec73d5fc7f285f4fa73b9a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/193082
Reviewed-by: Ben Konyi <bkonyi@google.com>
2021-03-29 15:56:21 +00:00
Ryan Macnak 6a6e08b784 Reapply "[vm, compiler] Convert binary Smi ops to graph intrinsics."
Explicitly disable unboxed parameters for these functions, previously implicitly disabled by virtue of being ASM intrinsics.

TEST=ci
Change-Id: Ic810bb8400e081c5f99a49b5035031bc9edc4bf5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/192044
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2021-03-25 21:54:44 +00:00
Ryan Macnak fa900734e2 [dartfuzz] Opt out of NNBD.
Currently all programs generated by Dart fuzz have NNBD errors.

Change-Id: I6f55447ad4c2986ae4ffceff8c88ba263d40e280
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/193081
Reviewed-by: Ben Konyi <bkonyi@google.com>
2021-03-25 20:06:40 +00:00
Alexander Markov 320ad6adb4 [vm/aot] Remove heuristic selection of checked Smi operations
TEST=existing tests

Change-Id: Id1fb01d6efa51e272636f54595393cebab3d45b4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/191760
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2021-03-25 19:18:47 +00:00
Alexander Aprelev 024ff88ce8 [vm/debugger] Refactor reference to Function out of BreakpointLocation.
BreakpointLocation represents source code location, which can
correspond to multiple Functions(in case of some mixin method
mixed-in in several classes, for example).
BreakpointLocation is connected to a Function via CodeBreakpoint.
CodeBreakpoint represents some point in the generated Code in some
Function. BreakpointLocation connects to multiple
CodeBreakpoints - one per Function that source code location was
generated into.

This CL removes Function reference stored directly in BreakpointLocation
as it is misleading.

This CL also removes some source-code-related attributes(uri/token_pos)
stored in CodeBreakpoint. If CodeBreakpoint code needs that information
it can find it in BreakpointLocation it references.

This should help with further refactoring to support BreakpointLocation
that map to multiple scripts

TEST=ci

Change-Id: I41b82fddc5018ef7df61c9d3a3c4aee657cee528
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/192946
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2021-03-25 17:57:04 +00:00
Ryan Macnak 2c371ff74e [vm, compiler] Respect --use_slow_path in CheckedSmiOp/Comparison.
TEST=ci
Change-Id: Ib2b1a9b067beb1cbeea2b12355e62a45396697f5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/192726
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2021-03-25 17:39:24 +00:00
Ben Konyi 3b76190e02 [ Service ] Skip sigquit_starts_service_test on AppJIT configurations
TEST=N/A

Change-Id: If118d8254b1f918306723e7677680fffefe836e4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/193060
Reviewed-by: Ben Konyi <bkonyi@google.com>
2021-03-25 17:02:31 +00:00
Martin Kustermann 1453eebebc Reland "[vm/compiler] Always allow CSE of LoadStaticField & loosen assertion in AllowsCSE"
Loosening of assertion:

There is no guarantee that a static-final field has been initialized by
the time a function is compiled (in optimized mode) that uses such a
field.

We should therefore loosen the ASSERT to not require the field to be
initialized and rather allows CSE

Enabling of CSE:

In the past we had separate InitStaticField and LoadStaticField. The
load itself had no side-effects and could therefore be moved
arbitrarily. Though we couldn't allow it to be moved before it's
InitStaticField. This dependency was not explicitly made and we
therefore disabled CSE / LICM if the actual field was not initialized
(or field may be reset) - see [0].

Though after merging of InitStaticField and LoadStaticField in [1] there
is no longer a need for tracking any dependencies: The side-effects
of InitStaticField are now reported by LoadStaticField.
=> We can therefore always allow CSE of LoadStaticFieldinstr and
any code motion would respect side-effects of the instruction.

[0] https://codereview.chromium.org/1497783002
[1] https://dart-review.googlesource.com/c/sdk/+/148283

TEST=Fixes flaky test.

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

Change-Id: I4a699e9b1dc9dfec9a91208ed78ed0a0c41f5cad
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/192924
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2021-03-25 15:04:43 +00:00
Tess Strickland bf74cad477 [vm/compiler] Change when parents of local functions are retained.
Now they are only retained if one of the following is true:

* The parent is Future.wait or Future.timeout.
* The local function is a generated body of an async/async*/sync*
  function.
* Symbolic stack traces are enabled.

When a local closure's parent is dropped, the parent name will
be printed as `<optimized out>` in places like exceptions.

Changes in Flutter gallery in release-sizeopt mode:

* ARM7: ROData -1.41%, Isolate snapshot -2.35%, Total snapshot -0.54%,
        Isolate heap -1.38%, Total heap -1.38%
* ARM8: ROData -1.55%, Isolate snapshot -2.34%, Total snapshot -0.65%,
        Isolate heap -1.41%, Total heap -1.41%

TEST=Existing tests on CI.

Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-release-x64-try,vm-kernel-precomp-linux-product-x64-try,vm-kernel-precomp-nnbd-linux-release-x64-try, vm-kernel-precomp-dwarf-linux-product-x64-try
Change-Id: I9d05f9e0e30e9f428eff16a15b0f1eeb974419c8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/190023
Commit-Queue: Tess Strickland <sstrickl@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2021-03-25 13:47:03 +00:00