Commit graph

13255 commits

Author SHA1 Message Date
Ryan Macnak 634fc10c52 [vm, compiler] Account for garbage in the upper half of compressed Smis in String intrinsics.
Cf. 8db0a975c1

TEST=ci
Change-Id: I60b0fb82504d1d4d3b2e65b7ca1af82b5ca88bc3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/199961
Reviewed-by: Liam Appelbe <liama@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2021-05-14 20:37:28 +00:00
asiva 2059ed4472 [VM/Runtime] - Delete unused flags
TEST=existing tests

Change-Id: I1b2548d73b9a80353bea789a1c8bc46cb6dba207
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/199841
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
2021-05-13 23:38:27 +00:00
Tess Strickland 9ad1dfb54e [vm/compiler] Fix Slot::GetTypeArgumentsSlotFor()
It needs to check whether the class the type arguments field is in
has compressed pointers, not whether TypeArguments has compressed
pointers.

Since we need the class to know whether compressed pointers are in
play, remove the version that just takes the offset.

TEST=Existing tests.

Change-Id: Ie6de8e0b2366b86f99a7fda362809dd1e10f99b8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/199484
Auto-Submit: Tess Strickland <sstrickl@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2021-05-13 21:09:46 +00:00
Tess Strickland a8864b6457 [vm] Use <Class>::ContainsCompressedPointers() when defining Slots.
Instead of specifying FINAL_COMPRESSED and VAR_COMPRESSED, the
macros for defining boxed native slots use the class's
ContainsCompressedPointers() predicate to determine whether a Slot
points to a compressed field.

Also use owner.HasCompressedPointers() when getting a Slot for a
particular Field.

TEST=Refactoring, so just running against the current test suite.

Cq-Include-Trybots: luci.dart.try:vm-kernel-linux-debug-x64c-try,vm-kernel-precomp-linux-debug-x64c-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-linux-debug-x64-try
Change-Id: I4bf25ffa2dbe89dc9a922305820dc4b752f47d13
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/198044
Commit-Queue: Tess Strickland <sstrickl@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2021-05-12 19:09:50 +00:00
Ryan Macnak b4c64a1787 [vm, x64] Shorter UnboxInt64Instr with compressed Smis.
TEST=ci
Change-Id: Ib80b9cd80f3656ea6c5f31e0dbc7229632d8783d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/198140
Reviewed-by: Liam Appelbe <liama@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2021-05-12 17:02:10 +00:00
Tess Strickland 7131d3182c [vm/compiler] Properly treat AllocateClosureInstr as an allocation.
When we switched from allocating closures with AllocateObject to
using AllocateClosure, a couple of places that needed to check for
IsAllocateClosure() were missed. This caused AllocateClosureInstrs to
never have a NotAliased Identity(), which then forced some
AllocateUninitializedContextInstrs to be kept instead of eliminated.

TEST=Checked using benchmarks that saw regressions due to this change.

Change-Id: If63d4cae190453233429b5657cbe177cac265074
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/199430
Commit-Queue: Tess Strickland <sstrickl@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
Auto-Submit: Tess Strickland <sstrickl@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2021-05-12 16:34:00 +00:00
Ryan Macnak 3fa5667c1a [vm, arm64] Combine BARRIER_MASK and HEAP_BASE into one register.
BARRIER_MASK requires 8 low bits and HEAP_BASE requires 32 high bits. Combine them into a single register HEAP_BITS, and use ARM's shifted operands to continue accessing the relevant bits in a single instruction.

TEST=ci
Change-Id: I5a4cd43fec2d19615239ec5cec2ac282d17c461c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/198100
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Liam Appelbe <liama@google.com>
2021-05-12 15:41:40 +00:00
Lasse R.H. Nielsen a5e18113f3 Remove references to triple-shift and generic-metadata experiments.
TEST= removed flags from test. No behavior should change.

Change-Id: I401bfb68c082d1bd405a118d5eca6a47a807945f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/199241
Commit-Queue: Lasse R.H. Nielsen <lrn@google.com>
Reviewed-by: Alexander Thomas <athom@google.com>
2021-05-12 13:35:00 +00:00
Martin Kustermann 535b53659b [vm/compiler] Remove dangerous FlowGraphCompiler::GenerateRuntimeCall
Doing any runtime call inside an `<XXX>Instr::EmitNativeCode()` is dangerous
because doing so almost always would require adjusting the lazy-deopt
environment to ensure the continuation in unoptimized code would have
the right stack state when returning from a runtime call.

=> Going to runtime should almost always happen via a stub call.

To discourage using runtime calls inside `EmitNativeCode()` functions we
remove the `FlowGraphCompiler::GenerateRuntimeCall()` helper method.

The remaining runtime calls used in `EmitNativeCode()`s fall into three
categories:

  * StackOverFlowInstr: In this particular case the deopt environment
    wouldn't need to be modified.
  * leaf runtime calls: Those do not need any metadata (neither deopt
    nor stackmaps) - since leaf runtime entries cannot safepoint
  * unopt-only runtime calls: Those do not need any metadata (neither
    deopt nor stackmaps) - since all slots in unoptimized frames are
    GC-able and unoptimized frames cannot be lazy-deoptimized.

We add assertions for the latter to cases with a comment to make it
clear.

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

TEST=Only adds assertions.

Change-Id: Idb8badfbe65fff55585959338129405c71908d25
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/199042
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2021-05-12 09:14:50 +00:00
Martin Kustermann 64cf9574e2 [vm] Use AbstractType instead of Type when disassembling exception handler types
Issue https://github.com/dart-lang/sdk/issues/45982

TEST=Existing test suite.

Change-Id: I87b2d41ff123a871bc1c736ca2b3c442b12aa824
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/199246
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Tess Strickland <sstrickl@google.com>
2021-05-12 08:18:08 +00:00
Martin Kustermann bdcb07c85f [vm/concurrency] Speed up debug runs of isolate tests
Running isolates tests in debug mode is currently very slow due to heap
verification and related code on isolate startup & shutdown.

This CL limits those verifications to only run on the first isolate of
an isolate group.

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

TEST=Existing test suite.

Change-Id: I1f329bca9e4c1d56ab60f36ffa8b9cc037b818f2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/199249
Reviewed-by: Alexander Aprelev <aam@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2021-05-12 07:55:38 +00:00
Tess Strickland c0f6b37d17 [vm] Store compression info during GC visit macros.
-----

Adds a few type traits for operating on (Compressed)ObjectPtr types:

* is_compressed_ptr<T>::value is true for compressed pointer types and
  false for uncompressed pointer types.
* is_uncompressed_ptr<T>::value is false for compressed pointer types
  and true for uncompressed pointer types.
* base_ptr_type<T>::type is ObjectPtr for uncompressed pointer types and
  CompressedObjectPtr for compressed pointer types.

Note: If DART_COMPRESSED_POINTERS is not enabled, all pointers are
uncompressed and the above traits function accordingly. That means
that is_compressed_ptr<T>::value is always false,
is_uncompressed_ptr<T>::value is true for all object pointers, and
base_ptr_type<T>::type is ObjectPtr for all object pointers, even if
they contain Compressed in the name.

-----

The following changes have been made to the VISIT_* macros:

* VISIT_NOTHING: no change.
* VISIT_FROM: takes only a field name now, and retrieves the type of
  the field to determine which base pointer type to use for from().
  Note that VISIT_FROM must now come _after_ the declaration of the
  field, since it retrieves the type from the declaration.
* VISIT_TO: takes only a field name now, and retrieves the type of the
  field to determine which base pointer type to use for to().
* (removed) VISIT_TO_LENGTH: Instead, VISIT_TO creates a to() method
  that takes an optional length argument (defaults to 0).
* (new) VISIT_FROM_PAYLOAD_START: takes the object pointer type of the
  payload elements and creates a from() that returns the beginning
  element of the payload. Note that a payload element must be a single
  object ptr to use this macro.
* (new) VISIT_TO_PAYLOAD_END: takes the object pointer type of the
  payload elements and creates a to() which takes a non-optional length
  argument and returns the last element of the payload.  Note that a
  payload element must be a single object ptr to use this macro.

If one of the {COMPRESSED_,}VARIABLE_POINTER_FIELDS macros are used,
then VISIT_TO_PAYLOAD_END should not be, as those macros already
include a use of it.

-----

In addition, each Untagged<Class> class now has a static constexpr bool
field kContainsCompressedPointers. This field is false for
UntaggedObject, and for other Untagged<Class> classes, it is either
inherited from the parent class or set during VISIT_FROM and the new
VISIT_FROM_PAYLOAD_START macro.

VISIT_TO and the new VISIT_TO_PAYLOAD_END macro double-check at compile
time that the type retrieved or provided is a compressed type if
kContainsCompressedPointers is true, and uncompressed if false.

If the elements of a payload are not object pointers, but rather
a composite object that contains object pointers, then
VISIT_FROM_PAYLOAD_START/VISIT_TO_PAYLOAD_END cannot be used. Instead,
use DEFINE_COMPRESSED_POINTERS(type), where type is the type of one of
the object pointers in the composite object, to appropriately define
kContainsCompressedPointers.

Note that this field will always be false when DART_COMPRESSED_POINTERS
is not defined.

-----

For classes, a static constexpr ContainsCompressedPointers() predicate
is created, based on the associated untagged class's field.

For instances of Class, there is an instance predicate
Class::HasCompressedPointers() that returns whether instances of a given
class object contain compressed pointers.

Change all calls to InitializeObject and Object::Allocate to pass in
the result of the appropriate predicate.

TEST=Refactoring, so current tests on CI, especially on x64c trybots.

Cq-Include-Trybots: luci.dart.try:vm-kernel-linux-debug-x64c-try,vm-kernel-precomp-linux-debug-x64c-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-linux-debug-x64-try
Change-Id: Ifb61f72885bd8b951167becbccf8ec3337a922b1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/196931
Reviewed-by: Liam Appelbe <liama@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
2021-05-12 07:36:58 +00:00
Ryan Macnak 634cccccc6 [vm, gc] Verify remembered cards when verifying the store buffer.
TEST=ci
Change-Id: I004a55902c65d89915ea79c141270a2c2670e53c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/199363
Reviewed-by: Liam Appelbe <liama@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2021-05-11 23:56:08 +00:00
Vyacheslav Egorov 20526d4368 [vm/aot] Scan deferred pools for code entries
When generating snapshot with loading units trace
deferred pools for code objects as well - otherwise
we might miss code references from one deferred
unit to another unit (e.g. if the only remaining
reference to some code object in the root unit is
actually from a deferred unit).

Fixes a bunch of issues with deferred libraries (Crash -> Pass):

- language_2/deferred/split_constants_canonicalization_test/1
- vm/dart_2/deferred_isolate_test
- vm/dart_2/deferred_loading_and_weak_serialization_references_test/0
- vm/dart_2/deferred_loading_and_weak_serialization_references_test/1
- vm/dart_2/deferred_loading_call_modes_test/2

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

TEST=ci

Fixed: 45917
Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-dwarf-linux-product-x64-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-release-x64-try,vm-kernel-precomp-linux-release-simarm-try
Change-Id: Iccd3efcab6a5396d4b6f70968d9176ff18d7147c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/198405
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
2021-05-11 23:08:18 +00:00
Regis Crelier fe12e366b0 [vm/runtime] Support tracing of subtype checks in runtime.
TEST=for debugging only

Change-Id: I9780e0374750b044613a654043342925eb904a17
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/199362
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Régis Crelier <regis@google.com>
2021-05-11 21:48:34 +00:00
Ben Konyi 33aa207efd fix: Context parse error, parent should be ContextRef
Bug: https://github.com/dart-lang/sdk/issues/45083
TEST=N/A
Change-Id: I1781c83ac2e8868f1d6a49fc4a01edd3e3eef460
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/192880
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2021-05-11 17:59:54 +00:00
Tess Strickland fd31aa3f33 [vm] Move function stores into the AllocateClosure stub.
Now AllocateClosureInstr takes the closure function as a Value* instead
of as a const Function&, a new kFunctionReg is added to
AllocateClosureABI, and the AllocateClosure stub sets the closure
function internally instead of initializing it to null and requiring it
to be set post-allocation.

A convenience method known_function() is added to AllocateClosureInstr
which returns either the closure function, if known at compile time,
or null otherwise.

TEST=More refactorings, so just passing current tests.

Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-simarm64c-try,vm-kernel-precomp-linux-debug-simarm_x64-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-debug-x64c-try,vm-kernel-precomp-linux-product-x64-try,vm-kernel-precomp-linux-release-x64-try,vm-kernel-precomp-linux-release-simarm64-try,vm-kernel-precomp-linux-release-simarm-try,vm-kernel-linux-debug-ia32-try,vm-kernel-linux-debug-x64-try,vm-kernel-linux-product-x64-try,vm-kernel-linux-release-simarm64-try,vm-kernel-linux-release-simarm-try,vm-kernel-linux-release-x64-try,vm-kernel-linux-debug-x64c-try
Change-Id: If843b401e0f282b191dd60b1c6c73c01f1d5bc70
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/198285
Commit-Queue: Tess Strickland <sstrickl@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2021-05-11 16:54:14 +00:00
Tess Strickland 02a8dd90e1 [vm] Add a bare-bones AllocateClosure stub.
Also create a subclass of AllocationInstr, AllocateClosureInstr,
which is used when allocating closures.

Followup CLs add inputs to this instruction and to the AllocateClosure
stub, starting with the closure function. Adding these inputs allows
the related field to be set within the stub, instead of using
StoreInstanceField manually at each closure allocation point.

Since this CL only adds the initial stub/instruction implementation,
the overhead on snapshots is minimal: just the addition of the new
stub to each isolate.

-----

This CL also adds virtual and non-virtual methods to assembler_base.h
revolving around field loads and stores and attempted inline object
allocation, to ensure all architectures have these methods.

It also adds LoadFromSlot/StoreToSlot/StoreToSlotNoBarrier, which
appropriately calls one of the other methods based on whether the slot
is compressed or not and whether it is a boxed or unboxed field.

With these additions, the AllocateClosure stub generator can be defined
in an architecture-independent way.

TEST=Basically a refactoring, so check using current test suites.

Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-simarm64c-try,vm-kernel-precomp-linux-debug-simarm_x64-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-debug-x64c-try,vm-kernel-precomp-linux-product-x64-try,vm-kernel-precomp-linux-release-x64-try,vm-kernel-precomp-linux-release-simarm64-try,vm-kernel-precomp-linux-release-simarm-try,vm-kernel-linux-debug-ia32-try,vm-kernel-linux-debug-x64-try,vm-kernel-linux-product-x64-try,vm-kernel-linux-release-simarm64-try,vm-kernel-linux-release-simarm-try,vm-kernel-linux-release-x64-try,vm-kernel-linux-debug-x64c-try
Change-Id: I71f5691307679f8d5e3604007699de4706f86eb8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/198284
Commit-Queue: Tess Strickland <sstrickl@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2021-05-11 11:22:44 +00:00
Tess Strickland 010523ee4a [vm] Fix handling of WeakSerializationReferences in v8 profile.
Instead of trying to lazily create artificial nodes when needed for
WeakSerializationReference (WSR) targets in all cases, create them
eagerly for targets in reachable WSRs, since those are guaranteed
to be needed.

Those for unreachable WSRs are still lazily created as needed, since the
WSR won't even be accessed by the clustered snapshot writer unless the
unreachable WSR is part of another unreachable object that has an
artificial node created.

This rework avoids some issues seen on upcoming CLs where the artificial
nodes for WSR targets weren't getting correctly generated.

-----

Also extend the v8 snapshot profile writer tests to check the sizes of
the text and data sections in ELF snapshots. That means the v8 snapshot
profile writer tests check up to three different measures, from most
precise to least precise, depending on the output mode:

* If writing an ELF snapshot directly: the sum of the sizes attributed
  to the text and data section symbols are checked to be exactly the
  same as the sum of the sizes of the objects in the profile.

* If writing an ELF snapshot either directly or via assembly: the sum
  of the sizes of the text and data sections are checked to be the same
  as the sum of the sizes of the objects in the profile. If using an
  assembler that merges text and data sections, then account for the
  padding between the sections using an approximate check.

* For all: Check that the size of the snapshot as a whole is
  approximately equal to the sum of the sizes of the objects in the
  profile, accounting both for possible padding and for the global
  header information and non-data/non-text sections like the dynamic
  symbol section.

TEST=vm/data{,_2}/v8_snapshot_profile_writer_test

Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-debug-x64c-try,vm-kernel-precomp-nnbd-linux-debug-x64-try,vm-kernel-precomp-mac-release-simarm64-try
Change-Id: I66e0e7fdb5bb98045621bf516f150a4723e08147
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/198942
Commit-Queue: Tess Strickland <sstrickl@google.com>
Reviewed-by: Clement Skau <cskau@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
2021-05-11 11:21:44 +00:00
Vyacheslav Egorov 34add230f6 [vm/compiler] Add --print-precompiler-timings
This flag allows dumping timings of various precompiler passes.

TEST=precompiled dart2js with --print-precompiler-timings

Change-Id: I54d6fdf26c25a0e43ae4f2717e833e09e9321d81
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/198407
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2021-05-11 11:15:53 +00:00
Dmitry Stefantsov 9f750ca0d3 [cfe] Add flags field to Extension and use it for 'extension type'
TEST=Checked by existing tests.

Change-Id: I436c0322124165f52195ebef402d7ab9104bbb30
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/198763
Commit-Queue: Dmitry Stefantsov <dmitryas@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2021-05-11 10:15:43 +00:00
Dong-Heon Jung a4e4659c82 Replace OS::PrintErr with THR_Print in bitmap
- Stack bitmap is not printed correctly with print_ssa_liveranges

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

TEST=not needed

GitOrigin-RevId: 47db0a93f94cb9bf1d663ad8d2a7431a6e6aafb9
Change-Id: I14da937330f2825a311f835cd394933c6b52d190
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/199260
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
2021-05-11 07:16:33 +00:00
Martin Kustermann 9dee9c77d7 [vm/concurrency] Make Int32x4 box allocation go to separate runtime entry
This is a follow-up to [0] which did the same for all other boxable
objects (Mint/Double/Float32x4/Float64x2).

[0] https://dart-review.googlesource.com/c/sdk/+/196928

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

TEST=Existing test suite.

Change-Id: I1736e9dce38435cf3d10587dd9201c41086dd51d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/199041
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2021-05-10 18:27:10 +00:00
Martin Kustermann a791ecc30e [vm/concurrency] Enforce all stub calls have (deopt-id, deopt-env)
To avoid accidental code that calls stubs without emitting proper
(deopt-id, deopt-env) metadata, we enforce that it's always present for
stub calls and add another GenerateNonLazyDeoptableStubCall for cases
where it's intentionally omitted.

The environment has in many cases been still emitted before, due to the
usage of `pending_deoptimization_env` though we make code pass it
explicitly (just as the deopt-id). We may want to consider deprecating
this `pending_deoptimization_env`.

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

TEST=Existing test suite.

Change-Id: I93f1d5ba4d74da5f9afa4b526ad57b9d032ca99e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/197164
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2021-05-10 14:55:20 +00:00
Martin Kustermann dce0263228 [vm/concurrency] Change "RunWithStoppedMutators" to use "deopt safepoint operation scope"
The "RunWithMutatorsStopped" wrapper is used in places where the invoked
callback can cause deoptimization of code. It should therefore ensure
it's running with a "deopt safpoint operation scope" to ensure mutators
are stopped at well-defined places that allow lazy-deopt.

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

TEST=Existing code base, will add "fuzzer"-like test to nightly/weekend builders.

Change-Id: Icb9a4183c13fab0f084e481c10dfc56a0308126a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/197162
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2021-05-10 13:38:37 +00:00
Martin Kustermann 31364331e9 Revert "[vm] Enable new kernel AST invocation nodes for the VM"
This reverts commit 53e3c079b7.

Reason for revert: This change has seemingly caused errors of the form
```
stderr >> Unhandled exception:
stderr >> Invalid argument(s): Missing canonical name for Reference to <XXX>
stderr >> #0      BinaryPrinter.writeNullAllowedReference (package:kernel/binary/ast_to_binary.dart:894:9)
stderr >> #1      BinaryPrinter.visitTypedefType (package:kernel/binary/ast_to_binary.dart:2410:5)
stderr >> #2      TypedefType.accept (package:kernel/ast.dart:11115:42)
stderr >> #3      BinaryPrinter.writeNode (package:kernel/binary/ast_to_binary.dart:403:10)
stderr >> #4      BinaryPrinter.writeOptionalNode (package:kernel/binary/ast_to_binary.dart:496:7)
```

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

Original change's description:
> [vm] Enable new kernel AST invocation nodes for the VM
>
> TEST=ci
>
> Issue: https://github.com/dart-lang/sdk/issues/45340
> Change-Id: Ibb307d8df8ff4ae8f2efad177880634ec9e27905
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/197586
> Commit-Queue: Alexander Markov <alexmarkov@google.com>
> Reviewed-by: Johnni Winther <johnniwinther@google.com>
> Reviewed-by: Aske Simon Christensen <askesc@google.com>

TBR=vegorov@google.com,alexmarkov@google.com,johnniwinther@google.com,askesc@google.com

Change-Id: I05d010378cfcc5ba40f2be58b01b3ed27a8fc31e
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Issue: https://github.com/dart-lang/sdk/issues/45340
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/199000
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2021-05-10 12:32:38 +00:00
Martin Kustermann 67ffc84c05 [vm] Share BoxAllocationSlowPath across architectures and use BoxABI::kResultReg
Slightly related to
Issue https://github.com/dart-lang/sdk/issues/45213

TEST=Existing test coverage.

Change-Id: I59953c9734b1e8cdba13a03c5734d084fc333130
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/196929
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Tess Strickland <sstrickl@google.com>
2021-05-10 12:08:49 +00:00
Martin Kustermann 8a4cba83a2 [vm/concurrency] Make box allocation slow paths go to separate runtime entry
The optimizing compiler can insert box instructions at various places
during the optimization pipeline. There is no guarantee that a box
instruction will get a proper (deopt-id, deopt-env) assigned to it - in
many places it will not.

Furthermore StoreInstanceField's into "unboxed fields" might cause
box allocations to happen. Those stores might also not have deopt
information associated with them.

In general we require stackmaps when allocation slow paths go to runtime
and cause GC. If GC throws OOM we theoretically would also need deopt
information in order to populate correct catch-entry state. Though OOM
is uncommon and the VM could decide to ignore the top-frame - if it's
missing deopt information - since box allocations aren't something
users are in control of (as opposed to user-allocated objects inside
try/catch).

=> This CL makes box allocations go to a runtime entry that doesn't
   support lazy-deopt. While being in those runtime entries the mutators
   will also not participate in "deopt safepoint operation" requests.

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

TEST=Existing test suite.

Change-Id: I1b61f77e3166da82efad08bb49bc1756576d220c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/196928
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2021-05-10 10:34:49 +00:00
Martin Kustermann 3c81d992ef [vm/concurrency] Distinguish "gc safepoint operations" from "deopt safepoint operations"
This extends the existing safepoint operation mechanism by allowing to
perform two different operations:

  * "gc safepoint operations": All mutators are stopped at places where
    it's safe to GC. It therefore requires stackmaps to be available for
    all optimized mutator frames.

  * "deopt safepoint operations": All mutators are stopped at places
    where it's safe to GC, but also safe to lazy-deopt mutator frames.
    It therefore requires deopt-id/deopt-info to be available for all
    optimized mutator frames.

Mutators can be asked to block for any of those two safepoint operations.
If a mutator is at a place where its safe to GC it will respond to "gc
safepoint operations" requests, if a mutator is additionally at a place
where it's also safe to lazy-deopt it will respond to "deopt safepoint
operation" requests.

Depending on how the runtime was entered (which is tracked via the
[Thread::runtime_call_deopt_ability_] value) - the mutator might
participate in both or only in gc safepoint operations.

During the start of a "deopt safepoint operation", the safepoint handler
will request all threads to stop at a "deopt safepoint". Some threads
might first want to initiate their own "gc safepoint operation"
(e.g. due to allocation failure) before they reach a "deopt safepoint".

We do allow this by letting the safepoint handler own a "deopt safepoint
operation" but still participate in other thread's "gc safepoint
operation" requests until all mutators are checked into places where
it's safe to lazy-deopt at which point the "deopt safepoint operation"
also owns a "gc safepoint operation".

In order to facilitate this, the Thread's safepoint_state will be
extended to consist of the following bits:

  * AtSafepoint
  * SafepointRequested
  * AtDeoptSafepoint
  * DeoptSafepointRequested
  * BlockedForSafepoint

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

TEST=vm/cc/SafepointOperation_*

Change-Id: Icdc2827718f6780818f99b829a5e806d6bb5b130
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/196927
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2021-05-10 09:13:09 +00:00
Martin Kustermann de767e3f2d [vm/concurrency] Track on [Thread] whether VM can deopt a mutator
As a pre-requisite of partitioning our safepoints into "gc only
safepoints" and "lazy-deopt'able safepoints" we'll let mutators keep
track of whether a runtime call into the VM is deoptable.

A mutator is lazy-deopt'able except for one particular case: When the
mutator calls into the VM from a place where no deopt-id/deopt-env
gets recorded (e.g. StoreInstanceField's box allocation goes to
runtime).

If a mutator is in the VM in a non-lazy-deopt'able state, it cannot call
out to the embedder, transition from "vm" to "native" state, ...

A future change will make new non-lazy-deopt'able runtime entries taking
advantage of this CL.

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

TEST=Existing test suite & tests in future CLs.

Change-Id: I30dbee02dc839b2ba9632b20ffa233aff4d58f64
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/196922
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2021-05-10 08:58:29 +00:00
Alexander Markov 53e3c079b7 [vm] Enable new kernel AST invocation nodes for the VM
TEST=ci

Issue: https://github.com/dart-lang/sdk/issues/45340
Change-Id: Ibb307d8df8ff4ae8f2efad177880634ec9e27905
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/197586
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
2021-05-09 21:00:28 +00:00
Clement Skau 69ebb404e7 [vm/debugger] Fix notify-debugger-.. for yielding.
For yielding functions (async, sync*, async*) we need to look for
annotations on the outer function instead of the synthetic inner
function associated with the handler frame.

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

TEST=runtime/observatory{,_2}/tests/service{,_2}/notify_debugger_on_exception_yielding_test.dart

Bug: https://github.com/dart-lang/sdk/issues/45673
Change-Id: I8b1718b3614852f6f8db98811177b21fe587fea1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/198408
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Commit-Queue: Clement Skau <cskau@google.com>
2021-05-06 17:59:33 +00:00
Clement Skau 26fa3e8e6d [lint] Fix existing lint issues.
'''
> git cl lint
runtime/vm/compiler/frontend/kernel_to_il.cc:2614:  \
Declaration has space between type name and * in \
TargetEntryInstr *null_ftav  [whitespace/declaration]
'''

TEST=Built and ran some existing tests.

Change-Id: I8095a0ea93cce9b57ce4e4965476b1e0a66e7ff0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/198402
Auto-Submit: Clement Skau <cskau@google.com>
Commit-Queue: Clement Skau <cskau@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
2021-05-06 07:32:02 +00:00
Regis Crelier 1f55b7ca10 Reland "[VM/runtime] Refactor the representation of type parameters in the VM."
This is a reland of 8a21ab195a

Original change's description:
> [VM/runtime] Refactor the representation of type parameters in the VM.
>
> This introduces a new VM internal class 'TypeParameters' representing the declaration of a list of type parameters, either in a class or function.
> The reference to (or use of) a type parameter is still represented by the existing 'TypeParameter' class.
>
> Fixes https://github.com/dart-lang/sdk/issues/43901
> Fixes https://github.com/dart-lang/sdk/issues/45763
>
> TEST=existing ones and a regression test
>
> Change-Id: I1fde808bf753cc1cb829f2c4383c1836651cee80
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/189942
> Commit-Queue: Régis Crelier <regis@google.com>
> Reviewed-by: Alexander Markov <alexmarkov@google.com>

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

TEST=existing ones and a regression test

Change-Id: I709d38b1df3d73fe3c9796d5aca3cbbdcf77fd38
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/198380
Commit-Queue: Régis Crelier <regis@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2021-05-05 23:43:14 +00:00
Alexander Markov b00233f128 [vm] Support new kernel AST invocation nodes in the VM
TEST=Manual testing with new invocation nodes enabled.

Issue: https://github.com/dart-lang/sdk/issues/45340
Change-Id: I7eb5f03b9d9ac16c911812a5dbcd92ad43220278
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/197585
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2021-05-05 20:39:12 +00:00
Michal Terepeta c6bffaf19e Revert "[VM/runtime] Refactor the representation of type parameters in the VM."
This reverts commit 8a21ab195a.

Reason for revert: Test failure: http://b/187227619

Original change's description:
> [VM/runtime] Refactor the representation of type parameters in the VM.
>
> This introduces a new VM internal class 'TypeParameters' representing the declaration of a list of type parameters, either in a class or function.
> The reference to (or use of) a type parameter is still represented by the existing 'TypeParameter' class.
>
> Fixes https://github.com/dart-lang/sdk/issues/43901
> Fixes https://github.com/dart-lang/sdk/issues/45763
>
> TEST=existing ones and a regression test
>
> Change-Id: I1fde808bf753cc1cb829f2c4383c1836651cee80
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/189942
> Commit-Queue: Régis Crelier <regis@google.com>
> Reviewed-by: Alexander Markov <alexmarkov@google.com>

TBR=rmacnak@google.com,alexmarkov@google.com,regis@google.com,sstrickl@google.com

Change-Id: If12caa1a84cb6d1c1b8225589f3c994d25abb120
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/198282
Reviewed-by: Michal Terepeta <michalt@google.com>
Reviewed-by: Tess Strickland <sstrickl@google.com>
Commit-Queue: Michal Terepeta <michalt@google.com>
2021-05-05 10:03:57 +00:00
Regis Crelier bde3097860 [vm/runtime] Consider instantiated type of instance method tear-offs in equality checks.
This fixes https://github.com/dart-lang/sdk/issues/45890

TEST=regression tests added

Change-Id: Id8d96e866e6da8ad848416a64967ed4fa0b29ce0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/198101
Commit-Queue: Régis Crelier <regis@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2021-05-05 00:07:52 +00:00
Martin Kustermann 5a28a719f7 [vm/compiler] Handle far-ranches in TypeTestingStub generation.
Issue https://github.com/dart-lang/sdk/issues/45898

TEST=vm/dart{,_2}/regress_45898_test

Change-Id: I5c7dfff0f7d4832e9c41f1aa2adaa332e163dfe6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/198040
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2021-05-04 17:24:01 +00:00
Ryan Macnak bc48e41811 [vm] Avoid atomic_thread_fence, which TSAN doesn't understand.
TEST=tsan
Bug: https://github.com/dart-lang/sdk/issues/45803
Change-Id: I6a2767b6dc654e05681f2062046f05c778b55b67
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/197820
Reviewed-by: Alexander Aprelev <aam@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2021-05-04 16:27:41 +00:00
Regis Crelier 8a21ab195a [VM/runtime] Refactor the representation of type parameters in the VM.
This introduces a new VM internal class 'TypeParameters' representing the declaration of a list of type parameters, either in a class or function.
The reference to (or use of) a type parameter is still represented by the existing 'TypeParameter' class.

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

TEST=existing ones and a regression test

Change-Id: I1fde808bf753cc1cb829f2c4383c1836651cee80
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/189942
Commit-Queue: Régis Crelier <regis@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2021-05-04 15:47:01 +00:00
Jens Johansen da4343348e [kernel] Change constant references; remove need for map
Previously constants were referenced via there relative binary offset,
i.e. a constant reference saying 42 meant at byte offset 42 relative to
the start of the constant table in the binary. This was done to be able
to (on the VM side) read the needed constants lazily. It meant, though,
that constants had to be stored in a map, mapping from the byte position
to the constant.

This change adds a level of indirection when needing the lazy reading,
but lets the constant references reference the constant number instead
so that a constant reference saying 42 means constant number 42,
i.e. constants can be stored in a list instead of in a map.
This is done on the dart side, but the VM still stores it in a map.

The level of indirection is a tabel next to the constant table where
each entry has constant size (4 bytes) from which one can read the
relative byte offset into the constant table from the constant number,
thus still being able to read needed constants lazily.

This CL also cleans up a leftover where for instance double constants
had their textual representation saved as a string in the string indexer
(and thus the output dill) even though they were never referenced.

File size changes:
* Platform: increses 7,816 bytes.
* Compile of dart2js (including platform): decreases 71,424 bytes.

Speed changes:
* Adding `UserTag`s to the code and looking at observatories cpu profile
  on a `pkg/kernel/test/binary_bench.dart --golem AstFromBinaryLazy`
  run of a compile of dart2js reading the constant table has gone
  from ~10% to ~5%.
* Doing statistics on
  `pkg/kernel/test/binary_bench.dart --raw AstFromBinaryLazy` run of a
  compile of dart2js says -6.28169% +/- 4.97269%.
* Golem runs has nothing above the noise level.
  It does say "AstFromBinaryLazy (Intel Xeon) -4.006% (0.4 noise)" and
  "AstFromBinaryEagerP50 (Intel Core i5) -8.929% (0.6 noise)" though.

TEST=All tests running the VM tests this.

Change-Id: I07ead457527a4477de803ee55ba742f5557413d3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/196925
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2021-05-04 11:08:31 +00:00
Ryan Macnak 86a86ab0ed [vm] Remove dead treeshaking code.
We once relied on making Symbols etc unreachable in the compiler's heap to remove unused ones from the snapshot, but we have since moved to using reachablity during snapshotting.

TEST=ci
Change-Id: I6a95bd71582deedc271441e4b6732201b2293c5b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/197442
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Tess Strickland <sstrickl@google.com>
2021-05-03 18:34:19 +00:00
Alexander Aprelev cbf16b0731 [vm/debugger] Use atomics for BreakpointLocation::token_pos/end_token_pos.
BreakpointLocation token_pos and end_token_pos are populated when
breakpoint is resolved and are read when vm needs to see if a
function has breakpoints.

Since the breakpoint is resolved once and token positions are
populated with real values only once using simple atomics is sufficient
to resolve data race.

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

TEST=service[_2]/break_on_function_many_child_isolates_test.dart on tsan

Change-Id: I92066d094ca3a86c80f0de648debea05ccde5e49
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/197561
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2021-05-03 17:46:15 +00:00
Alexander Aprelev 64cbb1a376 [vm/debugger] Fix race with CodeBreakpoint::ToCString(). Handle repeated notify compilation.
Retrieve CodeBreakpoint::ToCString() while we hold on to the CodeBreakpoint, before BreakpointLocation potentially deleted with terminated isolate.

GroupDebugger::NotifyCompilation(func) might be called several times for a given function when multiple isolates in a group race to compile it. Debugger needs to handle this scenario gracefully, ensure that already resolved breakpoints won't get resolved again.

TEST=observatory_2/tests/service_2/break_on_function_many_child_isolates_test

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

Change-Id: Ieebab86103b1999a13daff7b7bbc87ffa778ec82
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/197520
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2021-05-03 17:38:09 +00:00
Tess Strickland 5d636c6261 [vm/compiler] Handle native unboxed fields in StoreInstanceField.
Also creates LoadFromOffset/StoreToOffset variants across all
architectures (was missing in some) that take the register to
load to/store from, the memory address, and the size to load/store.

Fixes LoadFromOffset on X64 to use MOVSXD when the size is kFourBytes.

Creates slots for the data field of TypedDataBase/Pointer objects
and replaces the StoreUntagged instruction with uses of
StoreInstanceField instead to create uses of the new version of
the instruction.

BUG=https://github.com/dart-lang/sdk/issues/42793

TEST=Tests that involve FFI pointers or TypedData constructors.

Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-simarm64c-try,vm-kernel-precomp-linux-debug-simarm_x64-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-debug-x64c-try,vm-kernel-precomp-linux-product-x64-try,vm-kernel-precomp-linux-release-x64-try,vm-kernel-precomp-linux-release-simarm64-try,vm-kernel-precomp-linux-release-simarm-try,vm-kernel-linux-debug-ia32-try,vm-kernel-linux-debug-x64-try,vm-kernel-linux-product-x64-try,vm-kernel-linux-release-simarm64-try,vm-kernel-linux-release-simarm-try,vm-kernel-linux-release-x64-try,vm-kernel-linux-debug-x64c-try
Change-Id: I2c96e83bb086aa93c56b834e809e7141a32cfc35
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/196924
Commit-Queue: Tess Strickland <sstrickl@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2021-05-03 16:22:19 +00:00
Vyacheslav Egorov a11d9f17fb [vm] Fix race when setting identity hash codes.
We might interrupt Object._objectHashCode(obj) helper to serve a
vm-service request between checking for unset hash code and setting
a new hash code. While serving this request we might set the hash
code of [obj] (e.g. when generating heap snapshot or in
Instance::PrintJSONImpl). Later Object._objectHashCode will call
Object_setHash, which (on 64-bit platforms) assumes that
hash field in the object header is set to 0 and uses bitwise-or
to initialize it. This leads to a mismatch between hash code that
the first invocation of _objectHashCode will return and the
value stored in the header (because we OR non-zero value set
by vm-service with a value which _objectHashCode intended to
use as a hash).

This CL changes Object_setHash to avoid overwriting or mangling
the hash value if it was already set.

We also fix hash code generation in vm-service to ensure that we
only generate values which are valid Smis because the rest of the
code expects that.

TEST=pkg/front_end/test/incremental_compiler_leak_test.dart

Cq-Include-Trybots: luci.dart.try:vm-kernel-linux-release-simarm64-try,vm-kernel-precomp-linux-release-simarm64-try
Change-Id: Ica913af8bc1cfef0ad60a9e7504531ee4de53015
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/197400
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2021-05-03 11:47:08 +00:00
Daco Harkes cb636850df [vm] Exclude current_context_var from ValidatePhis
current_context_var is special cased in the liveness analysis and never
pruned even though it does not have uses by instructions. The lack of
pruning caused the assert to fire. This CL adds the special casing to
this assert as well.

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

TEST=tests/language/vm/regress_45855_test.dart

Change-Id: Ica74a43bd2449dd994639c686253449146216458
Fixed: 45855
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/197541
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2021-05-01 09:28:17 +00:00
Ben Konyi 60d149d835 [ VM / Service ] Remove bool return value for service RPC handlers
Returning 'false' from a RPC handler in service.cc results in the VM
shutting down due to an UNIMPLEMENTED error. Since we always return
'true', even in the case of RPC errors, and the TODO to handle 'false'
returns is over 6 years old, RPC handlers should just have a void
return.

Example: invoking getSourceReport on an AOT VM should just return a RPC
error, but 'false' was being returned from GetSourceReport causing the
VM to shutdown.

Fixes https://github.com/flutter/devtools/issues/2955.

TEST=Existing service tests

Change-Id: I344c2f4cf849d27f08f59e8c61fb4c17c32719d0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/197241
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2021-04-30 00:22:55 +00:00
Martin Kustermann 228b22101d [vm/compiler] Improve precision of AOT code relocator
This makes the AOT CodeRelocator more precise by removing some
heuristics which allows writing more precise tests as well.

Follow-up to:

  https://dart-review.googlesource.com/c/sdk/+/195682

TEST=vm/cc/CodeRelocator_*

Change-Id: I36e55f4c8db0bd88dc5e3a58fc2f12d889dae2a0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/197383
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2021-04-29 15:12:15 +00:00
Ryan Macnak d9f9b4dc96 [vm] Try to allocate snapshots and executable heap pages near the VM's binary.
Some 64-bit microarchitectures store only the low 32-bits of targets as part of indirect branch prediction, predicting that the target's upper bits will be the same as the call instruction's address. This leads to misprediction for indirect calls crossing a 4GB boundary. Ask mmap to place our generated code near the VM binary to avoid this.

Cf. https://chromium-review.googlesource.com/c/v8/v8/+/2726500

TEST=ci
Change-Id: If99850c50383751fcde1b71e38019c78ff97a787
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/197104
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
2021-04-28 23:22:55 +00:00
Alexander Aprelev 820cdc9265 [vm/concurrency] Use relaxed atomics to guard Field::is_nullable_.
Fixes https://github.com/dart-lang/sdk/issues/45709.

TEST=tsan ci

Change-Id: I5c710d37561450265a15c3d085a3285fc0b1c7d3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/196580
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2021-04-28 13:58:43 +00:00
Alexander Aprelev 3e317588a6 [vm/concurrency] Use acquire/release when updating Function::data and potentially array stored there.
Fixes https://github.com/dart-lang/sdk/issues/45640.

TEST=tsan ci

Change-Id: Ie3471c6bf1a46f0d667be7da74fdca91c91e1b7a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/196226
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2021-04-27 23:58:32 +00:00
Alexander Markov a98500a139 [vm/aot] Discard Code objects of invisible functions
Previously, Code objects of invisible functions were retained
in order to omit frames corresponding to such functions from stack
traces when stack trace is printed.

This change drops Code objects of invisible functions. That also
means that frames corresponding to such functions are no longer
skipped in binary DWARF stack traces.

In order to account for that, DW_AT_artificial attribute is added to
generated DWARF debug information to mark invisible functions.
Stack trace decoding now looks at this attribute and skips those
frames when symbolizing stack trace.

Flutter gallery in release-sizeopt mode:
Heap size of snapshot objects -4.2% (arm), -4.4% (arm64).

A large application in --dwarf_stack_traces mode:
Number of discarded Code objects increased from 72.4% to 83.7%
(out of all Code objects).
Heap size of Code objects -37.4%.
Heap size of all snapshot objects -5%.

TEST=tests/standalone/dwarf_stack_trace_invisible_functions_test.dart
Issue: https://github.com/dart-lang/sdk/issues/44852
Change-Id: Ib804852aba1e083670f1d9b9d66cbaab7dcdcff9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/196583
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Tess Strickland <sstrickl@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2021-04-27 23:31:02 +00:00
Nate Bosch 71fc33e427 Enable experiment generic_metadata
Change-Id: Iff050e6a2a1c0c2b8baca211a523f9dd77cfbd4a
TEST=Existing tests for the feature.
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/193748
Reviewed-by: Leaf Petersen <leafp@google.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
Commit-Queue: Leaf Petersen <leafp@google.com>
2021-04-27 20:16:08 +00:00
Daco Harkes 0aaf26d265 [vm] Fix OSR entry missing phis in indirect joins
Closes: https://github.com/dart-lang/sdk/issues/45260

TEST=tests/language/vm/regress_45260_test.dart
TEST=Added assert + optcounter bot.

Change-Id: Ic55ecf14678047a006c20bd8be4dd20c39ec4272
Cq-Include-Trybots: luci.dart.try:vm-kernel-optcounter-threshold-linux-release-ia32-try,vm-kernel-optcounter-threshold-linux-release-x64-try
Fixed: 45260
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/196320
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2021-04-27 13:12:48 +00:00
Tess Strickland 6b9210df84 [vm/compiler] Fix --resolve-dwarf-paths on Windows.
Fixes https://github.com/dart-lang/sdk/issues/45828

TEST=vm/dart{,_2}/use_resolve_dwarf_paths_flag_test

Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-win-release-x64-try
Change-Id: I40c05a5b4dbb370af197a6c50f7e7dc54e29ee4c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/196932
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
2021-04-26 22:44:28 +00:00
Ryan Macnak 11c2c4aacc [vm, compiler] Allow further folding of UnboxInt64(Constant) to UnboxedConstant.
TEST=ci
Change-Id: I3a55a007d4b8510faa33593698554f7e9bf982e2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/196225
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2021-04-26 20:23:07 +00:00
Alexander Markov db8d71d47e [vm/aot] Discard Code objects of entry points
Calls from C++ to Dart entry points are currently performed by
calling via Function::entry_point() in AOT mode
(with --use_bare_instructions). Such calls no longer use
Code objects, so Code objects can be discarded even if they
belong to a Function which is used as an entry point.

TEST=ci
Issue: https://github.com/dart-lang/sdk/issues/44852
Change-Id: Iaf9dd67392780ef4344fc518865ffbe30648762e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/196720
Reviewed-by: Tess Strickland <sstrickl@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2021-04-26 19:49:58 +00:00
Vyacheslav Egorov 9057d9812e [vm/compiler] Fold IntConverter(Constant(...))
This is important for keeping shifts compiling properly on some
platforms: because some shift variants only support constant shift
distances, so an interfering IntConverter inserted by the
representation selection pass causes compilation to fail.

This fixes Meteor benchmark, which is currently crashing the compiler.

TEST=runtime/tests/vm/dart{,_2}/regress_lsl_with_constant.dart

Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-release-simarm-try,vm-kernel-precomp-linux-release-simarm64-try
Change-Id: Ie2f316cd917a8ebd8d3d96f394b39eac4d135d95
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/196662
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2021-04-26 14:04:12 +00:00
Tess Strickland 6730b12edc [vm] Add --resolve-dwarf-paths (disabled by default).
When --resolve-dwarf-paths is enabled, then paths output to DWARF
information will be resolved to either an absolute or relative path.
If this cannot be done, snapshot creation fails.

File URIs are output as absolute paths.

SDK URIs are output as paths relative to the SDK root.

TEST=vm/dart{,_2}/use_resolve_dwarf_paths_flag_test

Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-dwarf-linux-product-x64-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-release-x64-try,vm-kernel-precomp-nnbd-linux-debug-x64-try,vm-kernel-precomp-nnbd-linux-release-x64-try,vm-kernel-precomp-linux-product-x64-try
Change-Id: I63c694f0f707ef6a3d3faa690e001fefe2b26094
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/196491
Commit-Queue: Tess Strickland <sstrickl@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
2021-04-26 11:44:47 +00:00
Tess Strickland ca224adba0 [vm] Make --code-comments a VM global flag.
This way, it is appropriately enabled if possible during snapshot
loading if the snapshot was compiled with --code-comments, instead of
forcing the user to remember to run the snapshot loader with
--code-comments to avoid a runtime failure.

TEST=vm/dart{,_2}/use_code_comments_flag_test

Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-product-x64-try,vm-kernel-precomp-linux-release-x64-try,vm-kernel-precomp-nnbd-linux-debug-x64-try,vm-kernel-precomp-nnbd-linux-release-x64-try
Change-Id: Ib3de04ecbd95ee4069c3d31ef3e4dc4b2a3ac94c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/196668
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
2021-04-26 11:44:38 +00:00
Vyacheslav Egorov 9a266c7fde [vm/arm] Fix vmovd Dd[x], ... simulation
This instruction operations on the lo/hi parts of D register and not
on S registers - which means we should not be using D->(S, S) projection
helpers because not all D registers have corresponding even/odd S
registers.

vmovd D20[0], ...  is a valid ARM instruction, but viewing it as
vmovd S40, ... is incorrect (because there is no such thing as S40).

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

TEST=lib_2/typed_data/float32x4_test on dartkp-linux-debug-simarm-crossword


Change-Id: Ia2fc827e1e629cdf5f2b66502681a080274fd73c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/196660
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2021-04-26 11:08:07 +00:00
Ivan Inozemtsev a5ff656da1 Revert "[vm] Switch datastream Write/WriteUnsigned to (S)LEB128."
This reverts commit 80102c981b.

Reason for revert: b/186359854

Original change's description:
> [vm] Switch datastream Write/WriteUnsigned to (S)LEB128.
>
> This reduces the number of variable-length integer encodings in our
> database from 2 to 1, and chooses the more standard one.
>
> TEST=Existing tests, in particular any that involve snapshots.
>
> Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-asan-linux-release-x64-try,vm-kernel-precomp-dwarf-linux-product-x64-try,vm-kernel-precomp-msan-linux-release-x64-try,vm-kernel-precomp-ubsan-linux-release-x64-try,vm-kernel-precomp-tsan-linux-release-x64-try,vm-kernel-precomp-nnbd-linux-debug-x64-try,vm-kernel-precomp-nnbd-linux-debug-simarm_x64-try,vm-kernel-precomp-linux-debug-simarm64c-try,vm-kernel-precomp-linux-debug-simarm_x64-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-debug-x64c-try,vm-kernel-precomp-linux-product-x64-try,vm-kernel-precomp-linux-release-x64-try
> Change-Id: Ia700158ac873ad32ac28c1027a669895961bc715
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/196321
> Commit-Queue: Tess Strickland <sstrickl@google.com>
> Reviewed-by: Ryan Macnak <rmacnak@google.com>
> Reviewed-by: Martin Kustermann <kustermann@google.com>

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

Change-Id: Idf32bdd879cf8bb7407f6dae764312140ad6eeb2
Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-asan-linux-release-x64-try,vm-kernel-precomp-dwarf-linux-product-x64-try,vm-kernel-precomp-msan-linux-release-x64-try,vm-kernel-precomp-ubsan-linux-release-x64-try,vm-kernel-precomp-tsan-linux-release-x64-try,vm-kernel-precomp-nnbd-linux-debug-x64-try,vm-kernel-precomp-nnbd-linux-debug-simarm_x64-try,vm-kernel-precomp-linux-debug-simarm64c-try,vm-kernel-precomp-linux-debug-simarm_x64-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-debug-x64c-try,vm-kernel-precomp-linux-product-x64-try,vm-kernel-precomp-linux-release-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/196920
Reviewed-by: Ivan Inozemtsev <iinozemtsev@google.com>
Commit-Queue: Ivan Inozemtsev <iinozemtsev@google.com>
2021-04-26 07:52:47 +00:00
Alexander Aprelev c11fe8c93e [vm/concurrency] Ensure declaration_type is updated under program_lock.
TEST=tsan ci reload_many_isolates flaky failure

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

Change-Id: I3b8c2042eeeee0efb7746484496d4a9c9618f7e3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/196500
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2021-04-23 15:10:41 +00:00
Martin Kustermann 6d0b689c76 [gardening] Add some nops into test function.
Right now the vm/cc/CodeRelocator_* tests are written in a strange way
to work around the conservative assumptions the relocator makes.

A future CL will make the relocator insert tramppolines precisely when
they are needed (not conservatively), which will allow writing precise
tests.

TEST=Fixes ARM64 vm/cc/CodeRelocator_* tests

Change-Id: I68f9bcce29f42a2264608f867f177e8f557804fb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/196666
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2021-04-23 15:00:31 +00:00
Martin Kustermann d17a02626c [gardening] Add missing parenthesis to CL which fixed vm/cc/CodeRelocator_* tests
TEST=Fixes arm build.

Change-Id: I4f90ab1994d13484c8b30ce8d8386f8acec59b8e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/196663
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2021-04-23 14:15:09 +00:00
Martin Kustermann 2b50aff493 [gardening] Fix missing RestoreCSP() from vm/cc/RelocationTest_* tests
The tests generate & run relocated instructions. On ARM64 our macro
assembler uses X15 as stack pointer instead of the normal sp.
-> There was a missing RestoreCSP() in the generation of the call
   instructions.
-> It's not an issue for running the test in simulator if CSP is wrong
   when returning, though it is for HW.

Adding RestoreCSP() would require the code to be larger, so instead we
use lower level assembly instructions that operate on the normal ARM64
stack.

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

TEST=Fixes vm/cc/RelocatinoTest_* on arm64 hw

Change-Id: I0c65e3d22897f536e39f0cf7e9af2be871051b0d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/196498
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2021-04-23 14:05:21 +00:00
Tess Strickland 80102c981b [vm] Switch datastream Write/WriteUnsigned to (S)LEB128.
This reduces the number of variable-length integer encodings in our
database from 2 to 1, and chooses the more standard one.

TEST=Existing tests, in particular any that involve snapshots.

Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-asan-linux-release-x64-try,vm-kernel-precomp-dwarf-linux-product-x64-try,vm-kernel-precomp-msan-linux-release-x64-try,vm-kernel-precomp-ubsan-linux-release-x64-try,vm-kernel-precomp-tsan-linux-release-x64-try,vm-kernel-precomp-nnbd-linux-debug-x64-try,vm-kernel-precomp-nnbd-linux-debug-simarm_x64-try,vm-kernel-precomp-linux-debug-simarm64c-try,vm-kernel-precomp-linux-debug-simarm_x64-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-debug-x64c-try,vm-kernel-precomp-linux-product-x64-try,vm-kernel-precomp-linux-release-x64-try
Change-Id: Ia700158ac873ad32ac28c1027a669895961bc715
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/196321
Commit-Queue: Tess Strickland <sstrickl@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2021-04-23 07:35:41 +00:00
Alexander Markov f49a95fec9 [vm] Reduce Class object size in JIT mode
The following fields in Class objects

  target_instance_size_in_words_
  target_type_arguments_field_offset_in_words_
  target_next_field_offset_in_words_

are only useful when cross-compiling.

This change removes these fields if DART_PRECOMPILER is not defined.

TEST=ci
Change-Id: I45e6e60ad6d0a738e2ac3afd45328209167393ff
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/196222
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2021-04-22 22:10:06 +00:00
Alexander Aprelev ab9ccf1e4e [vm] Use memory_order type argument provided for Array At/SetAt.
Issue https://github.com/dart-lang/sdk/issues/45170

TEST=ci

Change-Id: I8583a0df77914c4dc69a5b4565124a21a46421cf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/196562
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2021-04-22 21:53:56 +00:00
Alexander Markov 9af507e0f5 [vm] Auto-generate InstanceSize definitions for array objects in runtime_api
Previously, compiler::target::Foo::InstanceSize(intptr_t length)
definitions were hand-written and compiler::target::Foo::InstanceSize()
were often defined using the size of UntaggedFoo for array-like objects.
This results in an unnecessary code duplication and discrepancy
between Foo::InstanceSize() which returns 0 and
compiler::target::Foo::InstanceSize() which returns size of the header.

This change adds ARRAY_SIZEOF variant to runtime_offsets_list.h
and switches array-like objects to auto-generated InstanceSize methods.

Also, this change strengthens assertions around host and target
values of InstanceSize() and NextFieldOffset() being the same
unless DART_PRECOMPILER is defined (which may do cross-compilation).

Stronger assertions flushed out a few discrepancies between
runtime_api.h and object.h, which are also fixed in this change.

TEST=ci

Change-Id: I9f67c6a71b9300af5e656fdc70f6a3e341c1d029
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/196345
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Tess Strickland <sstrickl@google.com>
2021-04-22 18:21:16 +00:00
Tess Strickland 6616bb4696 [vm] Mark canonical-ness in written cluster.
Instead of depending on all canonical clusters being written first,
followed by all non-canonical clusters, mark whether a cluster is
canonical or not in its written form. This allows future changes to
interleave canonical and non-canonical clusters as needed.

TEST=Existing tests, as this is purely a refactoring.

Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-dwarf-linux-product-x64-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-debug-x64c-try,vm-kernel-precomp-nnbd-linux-debug-x64-try
Change-Id: I0ab835c262e061ffd3dd93be0c8f5358c9b51fc2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195994
Commit-Queue: Tess Strickland <sstrickl@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2021-04-22 15:27:46 +00:00
Tess Strickland 927c59104f [vm] Re-tighten requirements that the node type be set before writing.
Fixes the case where the Image name and type was not written
to the v8 snapshot profile in non-precompiled mode.

Adds core-jit snapshot tests to the v8 snapshot profile writer test.

In core-jit and app-aot-elf modes, verify that all bytes in the
snapshot sections are accounted for in the profile.

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

TEST=vm/dart{,_2}/v8_snapshot_profile_writer_test

Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-product-x64-try,vm-kernel-precomp-linux-release-x64-try,vm-kernel-precomp-linux-debug-x64-try
Change-Id: I88be309cdea6293d768e2fa458492387d70fde22
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/196323
Commit-Queue: Tess Strickland <sstrickl@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
2021-04-22 15:27:38 +00:00
Ryan Macnak 571908fbec [vm, compiler] Make UnboxedConstant more like Constant.
TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/45555
Change-Id: Ib396b0281d4e138cc252baacaac18e42057d7bb6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/194502
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2021-04-21 22:45:31 +00:00
Tess Strickland 8f30423bee [vm] Allow unknown type nodes in v8 snapshot profile in non-DEBUG.
Fixes https://github.com/dart-lang/sdk/issues/45787

TEST=Flutter HHH/web tests.

Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-product-x64-try,vm-kernel-precomp-linux-release-x64-try
Change-Id: Id223f667b4571d0733e578207d160e86f24687bb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/196322
Commit-Queue: Tess Strickland <sstrickl@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2021-04-21 14:03:10 +00:00
Johnni Winther fdc765faad [cfe] Make TypeParameter.defaultType non-nullable
TEST=existing

Change-Id: I0a8fdf09f742b55357411f12dc6164d4050bb83c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/196283
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
2021-04-21 13:51:50 +00:00
Dong-Heon Jung ba3e7a60e3 Enable print_ssa_liveranges
Assert when print_ssa_liveranges flag is set.
Check two conditions to print spill slot.
- HasStackIndex
- FP base register

TEST=ci

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

GitOrigin-RevId: 513db2a2cdfceb17e7914835aa244225190c40ce
Change-Id: Ifae645e3688e86b54df5f6fe64483a9f83207441
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/196244
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
2021-04-21 13:14:20 +00:00
Ryan Macnak 7e1d1963e5 [vm] Switch TypeArguments to compressed pointers.
TEST=ci
Change-Id: Ic3162ef1558fb803ab68749f1f1a4d820645ec7e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/194017
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Liam Appelbe <liama@google.com>
2021-04-21 00:06:58 +00:00
Vyacheslav Egorov f88ce677e1 [vm/debugger] Avoid treating a try/finally as a catch
There is a synthetic try/catch within a try/finally block.

When trying to assess whether an exception is caught, the debugger
should skip such generated try/catch blocks. Otherwise, it considers
that try/finally actually handles the exception, which is wrong.

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

TEST=runtime/observatory{,_2}/tests/service{,_2}/regress_45684_test.dart

Change-Id: I60e8837204cf97ee1ab02ffd03364e7f69857004
Fixed: 45684
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/196124
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2021-04-20 23:14:38 +00:00
Ben Konyi 302e42da44 [ VM / Service ] Allow for resolving breakpoints in multiple Script
objects

It's possible for scripts to appear in multiple components provided by
the front end in certain situations (e.g., mixin applications in
different libraries). Previously when trying to set a breakpoint, if
multiple scripts were found matching the target URI the debugger would
give up and not set the breakpoint.

This change allows for multiple Scripts to be associated with a
BreakpointLocation.

Fixes https://github.com/flutter/flutter/issues/66832

TEST=runtime/observatory_2/tests/service_2/sdk_break_with_mixin_test.dart

Change-Id: I935721f4753675a9a2051a71cc1720e590f8d4f6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195664
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2021-04-20 22:34:38 +00:00
Alexander Markov 17c33d8d52 Reland "[vm] Reduce size of Class objects in AOT and PRODUCT modes"
This is a reland of 2852408881

Original change's description:
> [vm] Reduce size of Class objects in AOT and PRODUCT modes
>
> This change conditionally removes certain fields from Class objects
> in AOT and PRODUCT modes.
>
> Flutter gallery in release-sizeopt mode:
> Snapshot size -0.47% (arm64), -0.44% (arm)
> Heap size of snapshot objects -4.1% (arm64), -4.3% (arm)
>
> On a large Flutter application compiled in --dwarf-stack-traces mode:
> Heap size of Class objects -26%
> Heap size of all snapshot objects -3.6%
>
> TEST=ci
> Issue: https://github.com/dart-lang/sdk/issues/44020
> Change-Id: I795c625b71558cd2f336f92fc326c36fd339cd4b
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195700
> Commit-Queue: Alexander Markov <alexmarkov@google.com>
> Reviewed-by: Ryan Macnak <rmacnak@google.com>

TEST=ci
Change-Id: Ib473a959a2c610b7a0e6f4000b2101e5256c6119
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/196103
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2021-04-20 21:11:58 +00:00
Alexander Markov 867a95c50e Revert "[vm] Reduce size of Class objects in AOT and PRODUCT modes"
This reverts commit 2852408881.

Reason for revert: failures on Flutter engine tests.
Issue: https://github.com/flutter/flutter/issues/80801

Original change's description:
> [vm] Reduce size of Class objects in AOT and PRODUCT modes
>
> This change conditionally removes certain fields from Class objects
> in AOT and PRODUCT modes.
>
> Flutter gallery in release-sizeopt mode:
> Snapshot size -0.47% (arm64), -0.44% (arm)
> Heap size of snapshot objects -4.1% (arm64), -4.3% (arm)
>
> On a large Flutter application compiled in --dwarf-stack-traces mode:
> Heap size of Class objects -26%
> Heap size of all snapshot objects -3.6%
>
> TEST=ci
> Issue: https://github.com/dart-lang/sdk/issues/44020
> Change-Id: I795c625b71558cd2f336f92fc326c36fd339cd4b
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195700
> Commit-Queue: Alexander Markov <alexmarkov@google.com>
> Reviewed-by: Ryan Macnak <rmacnak@google.com>

TBR=vegorov@google.com,rmacnak@google.com,alexmarkov@google.com,sstrickl@google.com

Change-Id: I0dbf1d5fc139f3654ce52f185b799c09bba66de7
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Issue: https://github.com/dart-lang/sdk/issues/44020
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/196102
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2021-04-20 16:54:29 +00:00
Tess Strickland a2b8da3fed [vm] Cast to unsigned before left shift in V8 snapshot profile writer.
TEST=vm/dart_2/v8_snapshot_profile_writer_test on UBSAN.

Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-ubsan-linux-release-x64-try
Change-Id: Ide25bf08c27b6962637639429aa8ff9deadbe283
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/196121
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
2021-04-20 16:40:18 +00:00
Alexander Aprelev f93be7cec2 [vm/concurrency] Enable field unboxing optimization in lightweight isolate configuration.
With f3520ff11b landed it is safe to enable
field unboxing for lightweight isolates.

TEST=ci

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

Change-Id: I4fcac2370435408f875a6f3a47f69bfb136ae07d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/196023
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2021-04-20 14:36:47 +00:00
Tess Strickland 6c8f4aa190 Reland "[vm] Fix V8 snapshot profile handling of the dispatch table."
This is a reland of 5909fd111d

Does a large refactoring on the V8 snapshot profile writer
to clean things up, add more debugging support, and to fix
the problems that surfaced during the original landing.

Other changes:

Changes Serializer::CreateArtificialNodeIfNeeded() to create
artificial nodes for Code objects and immutable arrays.

Fixes CodeSerializationCluster::Trace() to only push needed parts of
discarded code objects, instead of tracing them like full code objects.

Adds test cases to v8_snapshot_profile_writer_test that exercise
the following situations (both separately and together):

* Non-symbolic stack traces are enabled and code and function objects
  are dropped when not needed at runtime.

* Creation of the dispatch table is disabled.

TEST=vm/dart{,_2}/v8_snapshot_profile_writer_test

Original change's description:
> [vm] Fix V8 snapshot profile handling of the dispatch table.
>
> Fixes https://github.com/dart-lang/sdk/issues/45702.
>
> TEST=Tests listed in the issue above.
>
> Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try
> Change-Id: Ibf5e3ccf3828c01f9dda47de360314dabe8cb8a9
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195272
> Reviewed-by: Daco Harkes <dacoharkes@google.com>
> Commit-Queue: Tess Strickland <sstrickl@google.com>

Change-Id: I8e7030267fe190079a8f68d00fe20bf7170e5719
Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-product-x64-try,vm-kernel-precomp-mac-release-simarm64-try,vm-kernel-precomp-linux-debug-x64c-try,vm-kernel-precomp-obfuscate-linux-release-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195513
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
2021-04-20 11:17:36 +00:00
Alexander Markov 2852408881 [vm] Reduce size of Class objects in AOT and PRODUCT modes
This change conditionally removes certain fields from Class objects
in AOT and PRODUCT modes.

Flutter gallery in release-sizeopt mode:
Snapshot size -0.47% (arm64), -0.44% (arm)
Heap size of snapshot objects -4.1% (arm64), -4.3% (arm)

On a large Flutter application compiled in --dwarf-stack-traces mode:
Heap size of Class objects -26%
Heap size of all snapshot objects -3.6%

TEST=ci
Issue: https://github.com/dart-lang/sdk/issues/44020
Change-Id: I795c625b71558cd2f336f92fc326c36fd339cd4b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195700
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2021-04-20 00:45:38 +00:00
Ryan Macnak a3f1dee0a0 [vm, arm64] Fix Address::OperandSizeFor.
TEST=ci
Change-Id: If9fa591e0da7f09ecdc408f1b181a50cc365e7d5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/196021
Reviewed-by: Liam Appelbe <liama@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2021-04-19 21:44:28 +00:00
Nate Bosch 9443e248ee Enable the triple shift experiment
Update the golden for a front_end test which adds additional constant evaluation
information now that the experiment is enabled.

A co19 test will start failing. https://github.com/dart-lang/co19/issues/1062

Change-Id: I18ec586f57deda83f6cd75e476137ab75d50a92f
TEST=No new tests.
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/193747
Auto-Submit: Nate Bosch <nbosch@google.com>
Commit-Queue: Nate Bosch <nbosch@google.com>
Reviewed-by: Leaf Petersen <leafp@google.com>
2021-04-19 21:04:38 +00:00
Alexander Aprelev 701c06d033 [vm/reload] Do class reload type parameter count check before finalization.
Fixes https://github.com/dart-lang/sdk/issues/45602

TEST=pkg/vm/test/incremental_compiler_test.dart

Change-Id: Iebf64c4d7ca8ba42209de27fe35ab1e03302d308
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195305
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2021-04-19 19:57:08 +00:00
Ryan Macnak bc21edaf17 [vm] Increase alignment in VM-generated ELF to 16k.
ARM64 Mac has 16k pages, so we need snapshot parts to be 16k aligned for our ELF loader to load them via mmap.

TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/42773
Change-Id: Ifa3d70e453ea72883d821e48cfc76b0d983391f2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/193821
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2021-04-19 18:12:48 +00:00
Alexander Aprelev f3520ff11b [vm/concurrency] Ensure field unboxed->boxed deoptimization runs with stopped mutators.
In lightweight isolate mode if some isolate or background compiler decides
to deopt unboxed field, we need to bring to stop all other isolates
to prevent to-be-deoptimized code from running.

If isolates are not stopped they might continue running the code that
still assumes the field is unboxed(reusable mutable box), overwriting
(now immutable) boxed value.

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

TEST=ci

Change-Id: I5d2492650b8aa00491a1bd6ba2a7fb4817460f14
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195662
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2021-04-19 16:03:18 +00:00
Martin Kustermann 8156646b0c [vm] Fix constant in PcRelativeCall pattern on x64
This fixes windows build which has different integer size
so the literal constant makes a difference.

This is a follow-up to [0] which added a test that revealed this
issue.

[0] https://dart-review.googlesource.com/c/sdk/+/195682

TEST=Fixes vm/cc/PCRelativeCallPatterns on windows.

Change-Id: I82403753126e95b86ccca5de039fd703b61a119b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195921
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2021-04-19 14:11:38 +00:00
Martin Kustermann d41f9a738e [vm/compiler] Fix relocator to take out-of-range backwards calls into acount
There was a missing check for whether a backwards call is out-of-range.

The CL also removes leftover code related to [max_offset_into_target_] -
which wasn't used. The intended use is already over approximated via
[max_instructions_size_].

The CL makes the pc-relative call/tail-call distances pluggable so a
newly added test can modify them for testing in-range/out-of-range
forward/backwards calls.

TEST=vm/cc/CodeRelocator_*

Fixes https://github.com/flutter/flutter/issues/80043

Change-Id: Id4bdb7176108b61235dafb7ffc125da4a2bf07fa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195682
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2021-04-19 09:42:00 +00:00
Johnni Winther 3e44898e08 [kernel] Make FileUriNode.fileUri non-nullable
TEST=existing

Change-Id: I72583e500cb0b69d9352b040c3e2885f9e0450c5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195681
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2021-04-19 08:03:30 +00:00
Alexander Markov b802aadf71 [vm] Fix materialization of instances with uninitialized late fields
When materializing objects during deoptimization, their fields were
set using Instance::SetField. However, Instance::SetField updates
field guards and it is strict about not taking 'sentinel' value.
That caused assertion to fail when trying to materialize an instances
with late fields which were not initialized yet and have 'sentinel'
value.

Changed materialization to use a more low-level SetFieldAtOffset
in case of sentinel value.

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

Change-Id: If39a1e4f2fc0d0fe7f988a80c7a0073cafff28b0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195490
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2021-04-17 00:39:26 +00:00
Tess Strickland 3fdecfc169 Revert "[vm] Fix V8 snapshot profile handling of the dispatch table."
This reverts commit 5909fd111d.

Reason for revert: Ended up breaking tests on non-x64c as well, investigating.

Original change's description:
> [vm] Fix V8 snapshot profile handling of the dispatch table.
>
> Fixes https://github.com/dart-lang/sdk/issues/45702.
>
> TEST=Tests listed in the issue above.
>
> Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try
> Change-Id: Ibf5e3ccf3828c01f9dda47de360314dabe8cb8a9
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195272
> Reviewed-by: Daco Harkes <dacoharkes@google.com>
> Commit-Queue: Tess Strickland <sstrickl@google.com>

TBR=rmacnak@google.com,dacoharkes@google.com,sstrickl@google.com

Change-Id: I61d0eb217e7be04a0841fb9e7dddd180e31bed2a
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195512
Reviewed-by: Tess Strickland <sstrickl@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
2021-04-16 09:48:57 +00:00
Tess Strickland 5909fd111d [vm] Fix V8 snapshot profile handling of the dispatch table.
Fixes https://github.com/dart-lang/sdk/issues/45702.

TEST=Tests listed in the issue above.

Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try
Change-Id: Ibf5e3ccf3828c01f9dda47de360314dabe8cb8a9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195272
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
2021-04-16 09:08:13 +00:00
Alexander Markov 6cf73fc7d9 [vm/compiler] Fix canonicalization of Slots corresponding to captured variables
It is possible for 2 slots which correspond to different captured
variables to have the same offset, flags and name.
So Slot::Equals should also take the rest of the information into
account (static type) in order to prevent incorrect canonicalization
of Slot objects.

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

Change-Id: Ib64dc5b8a83f64efd06f4139949c637d7c6dd3a8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195423
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2021-04-15 16:54:57 +00:00
Daco Harkes 8a2b7bb5d5 [vm/ffi] Support Unions
Closes: https://github.com/dart-lang/sdk/issues/38491

tools/test.py ffi ffi_2
TEST=tests/ffi(_2)/(.*)by_value_(*.)_test.dart

Change-Id: I6d29f7e3c3046cda4a15c9b42063c66b064787be
Cq-Include-Trybots: luci.dart.try:dart-sdk-linux-try,dart-sdk-mac-try,dart-sdk-win-try,vm-ffi-android-debug-arm-try,vm-ffi-android-debug-arm64-try,vm-kernel-asan-linux-release-x64-try,vm-kernel-mac-debug-x64-try,vm-kernel-linux-debug-ia32-try,vm-kernel-linux-debug-x64-try,vm-kernel-nnbd-linux-debug-x64-try,vm-kernel-nnbd-linux-debug-ia32-try,vm-kernel-nnbd-mac-release-x64-try,vm-kernel-nnbd-win-debug-x64-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-debug-simarm_x64-try,vm-kernel-precomp-nnbd-linux-debug-x64-try,vm-kernel-precomp-win-release-x64-try,vm-kernel-reload-linux-debug-x64-try,vm-kernel-reload-rollback-linux-debug-x64-try,vm-kernel-win-debug-x64-try,vm-kernel-win-debug-ia32-try,vm-precomp-ffi-qemu-linux-release-arm-try,vm-kernel-precomp-obfuscate-linux-release-x64-try,vm-kernel-msan-linux-release-x64-try,vm-kernel-precomp-msan-linux-release-x64-try,vm-kernel-precomp-android-release-arm_x64-try,analyzer-analysis-server-linux-try,vm-kernel-precomp-linux-debug-x64c-try,vm-kernel-linux-debug-x64c-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/194420
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
2021-04-15 10:16:27 +00:00
Alexander Markov 37f723520f [vm/compiler] Canonicalize v1 = Phi(v2, v1)
Previously, compiler canonicalized Phi instructions which reference
only one value (modulo redefinitions):

   v1 = Phi(v2, v2, ..., v2)

This change extends the canonicalization rule to also allow the Phi
to reference itself:

  v1 = Phi(v2, v2, ...., v2, v1, ...., v1)

Such Phi instructions may occur in loops when local variable is not
mutated (remains the same on the back-edge).

TEST=ci
Change-Id: I2838c4307a6dd3067d52624db66487ba4682538c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195043
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2021-04-14 21:51:11 +00:00