Commit graph

77 commits

Author SHA1 Message Date
Daco Harkes
37526fc8d7 Revert "[vm] Implement Finalizer"
This reverts commit 7dca34c235.

Reason for revert: b/226085355 dart_vm_test crashing. Unclear what
the cause is. Reverting so we can triage the issue.

TEST=This is a revert.

Original change's description:
> [vm] Implement `Finalizer`
>
> This CL implements the `Finalizer` in the GC.
>
> (This CL does not yet implement `NativeFinalizer`.)
>
> The GC is specially aware of two types of objects for the purposes of
> running finalizers.
>
> 1) `FinalizerEntry`
> 2) `Finalizer` (`FinalizerBase`, `_FinalizerImpl`)
>
> A `FinalizerEntry` contains the `value`, the optional `detach` key, and
> the `token`, and a reference to the `finalizer`.
> An entry only holds on weakly to the value, detach key, and finalizer.
> (Similar to how `WeakReference` only holds on weakly to target).
>
> A `Finalizer` contains all entries, a list of entries of which the value
> is collected, and a reference to the isolate.
>
> When a the value of an entry is GCed, the enry is added over to the
> collected list.
> If any entry is moved to the collected list, a message is sent that
> invokes the finalizer to call the callback on all entries in that list.
>
> When a finalizer is detached by the user, the entry token is set to the
> entry itself and is removed from the all entries set.
> This ensures that if the entry was already moved to the collected list,
> the finalizer is not executed.
>
> To speed up detaching, we use a weak map from detach keys to list of
> entries. This ensures entries can be GCed.
>
> Both the scavenger and marker tasks process finalizer entries in
> parallel.
> Parallel tasks use an atomic exchange on the head of the collected
> entries list, ensuring no entries get lost.
> The mutator thread is guaranteed to be stopped when processing entries.
> This ensures that we do not need barriers for moving entries into the
> finalizers collected list.
> Dart reads and replaces the collected entries list also with an atomic
> exchange, ensuring the GC doesn't run in between a load/store.
>
> When a finalizer gets posted a message to process finalized objects, it
> is being kept alive by the message.
> An alternative design would be to pre-allocate a `WeakReference` in the
> finalizer pointing to the finalizer, and send that itself.
> This would be at the cost of an extra object.
>
> Send and exit is not supported in this CL, support will be added in a
> follow up CL. Trying to send will throw.
>
> Bug: https://github.com/dart-lang/sdk/issues/47777
>
> TEST=runtime/tests/vm/dart/finalizer/*
> TEST=runtime/tests/vm/dart_2/isolates/fast_object_copy_test.dart
> TEST=runtime/vm/object_test.cc
>
> Change-Id: I03e6b4a46212316254bf46ba3f2df333abaa686c
> Cq-Include-Trybots: luci.dart.try:vm-kernel-reload-rollback-linux-debug-x64-try,vm-kernel-reload-linux-debug-x64-try,vm-ffi-android-debug-arm64c-try,dart-sdk-mac-arm64-try,vm-kernel-mac-release-arm64-try,pkg-mac-release-arm64-try,vm-kernel-precomp-nnbd-mac-release-arm64-try,vm-kernel-win-debug-x64c-try,vm-kernel-win-debug-x64-try,vm-kernel-precomp-win-debug-x64c-try,vm-kernel-nnbd-win-release-ia32-try,vm-ffi-android-debug-arm-try,vm-precomp-ffi-qemu-linux-release-arm-try,vm-kernel-mac-debug-x64-try,vm-kernel-nnbd-mac-debug-x64-try,vm-kernel-nnbd-linux-debug-ia32-try,benchmark-linux-try,flutter-analyze-try,flutter-frontend-try,pkg-linux-debug-try,vm-kernel-asan-linux-release-x64-try,vm-kernel-gcc-linux-try,vm-kernel-optcounter-threshold-linux-release-x64-try,vm-kernel-precomp-linux-debug-simarm_x64-try,vm-kernel-precomp-obfuscate-linux-release-x64-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-debug-x64c-try
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/229544
> Reviewed-by: Lasse Nielsen <lrn@google.com>
> Reviewed-by: Slava Egorov <vegorov@google.com>
> Reviewed-by: Martin Kustermann <kustermann@google.com>
> Reviewed-by: Ryan Macnak <rmacnak@google.com>
> Commit-Queue: Daco Harkes <dacoharkes@google.com>

TBR=lrn@google.com,vegorov@google.com,kustermann@google.com,rmacnak@google.com,dacoharkes@google.com

Change-Id: I991f6e49896d18a8d70210cf315d858b462d66c9
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: https://github.com/dart-lang/sdk/issues/47777
Cq-Include-Trybots: luci.dart.try:vm-kernel-reload-rollback-linux-debug-x64-try,vm-kernel-reload-linux-debug-x64-try,vm-ffi-android-debug-arm64c-try,dart-sdk-mac-arm64-try,vm-kernel-mac-release-arm64-try,pkg-mac-release-arm64-try,vm-kernel-precomp-nnbd-mac-release-arm64-try,vm-kernel-win-debug-x64c-try,vm-kernel-win-debug-x64-try,vm-kernel-precomp-win-debug-x64c-try,vm-kernel-nnbd-win-release-ia32-try,vm-ffi-android-debug-arm-try,vm-precomp-ffi-qemu-linux-release-arm-try,vm-kernel-mac-debug-x64-try,vm-kernel-nnbd-mac-debug-x64-try,vm-kernel-nnbd-linux-debug-ia32-try,benchmark-linux-try,flutter-analyze-try,flutter-frontend-try,pkg-linux-debug-try,vm-kernel-asan-linux-release-x64-try,vm-kernel-gcc-linux-try,vm-kernel-optcounter-threshold-linux-release-x64-try,vm-kernel-precomp-linux-debug-simarm_x64-try,vm-kernel-precomp-obfuscate-linux-release-x64-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-debug-x64c-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/238080
Reviewed-by: Slava Egorov <vegorov@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2022-03-22 11:55:38 +00:00
Daco Harkes
7dca34c235 [vm] Implement Finalizer
This CL implements the `Finalizer` in the GC.

(This CL does not yet implement `NativeFinalizer`.)

The GC is specially aware of two types of objects for the purposes of
running finalizers.

1) `FinalizerEntry`
2) `Finalizer` (`FinalizerBase`, `_FinalizerImpl`)

A `FinalizerEntry` contains the `value`, the optional `detach` key, and
the `token`, and a reference to the `finalizer`.
An entry only holds on weakly to the value, detach key, and finalizer.
(Similar to how `WeakReference` only holds on weakly to target).

A `Finalizer` contains all entries, a list of entries of which the value
is collected, and a reference to the isolate.

When a the value of an entry is GCed, the enry is added over to the
collected list.
If any entry is moved to the collected list, a message is sent that
invokes the finalizer to call the callback on all entries in that list.

When a finalizer is detached by the user, the entry token is set to the
entry itself and is removed from the all entries set.
This ensures that if the entry was already moved to the collected list,
the finalizer is not executed.

To speed up detaching, we use a weak map from detach keys to list of
entries. This ensures entries can be GCed.

Both the scavenger and marker tasks process finalizer entries in
parallel.
Parallel tasks use an atomic exchange on the head of the collected
entries list, ensuring no entries get lost.
The mutator thread is guaranteed to be stopped when processing entries.
This ensures that we do not need barriers for moving entries into the
finalizers collected list.
Dart reads and replaces the collected entries list also with an atomic
exchange, ensuring the GC doesn't run in between a load/store.

When a finalizer gets posted a message to process finalized objects, it
is being kept alive by the message.
An alternative design would be to pre-allocate a `WeakReference` in the
finalizer pointing to the finalizer, and send that itself.
This would be at the cost of an extra object.

Send and exit is not supported in this CL, support will be added in a
follow up CL. Trying to send will throw.

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

TEST=runtime/tests/vm/dart/finalizer/*
TEST=runtime/tests/vm/dart_2/isolates/fast_object_copy_test.dart
TEST=runtime/vm/object_test.cc

Change-Id: I03e6b4a46212316254bf46ba3f2df333abaa686c
Cq-Include-Trybots: luci.dart.try:vm-kernel-reload-rollback-linux-debug-x64-try,vm-kernel-reload-linux-debug-x64-try,vm-ffi-android-debug-arm64c-try,dart-sdk-mac-arm64-try,vm-kernel-mac-release-arm64-try,pkg-mac-release-arm64-try,vm-kernel-precomp-nnbd-mac-release-arm64-try,vm-kernel-win-debug-x64c-try,vm-kernel-win-debug-x64-try,vm-kernel-precomp-win-debug-x64c-try,vm-kernel-nnbd-win-release-ia32-try,vm-ffi-android-debug-arm-try,vm-precomp-ffi-qemu-linux-release-arm-try,vm-kernel-mac-debug-x64-try,vm-kernel-nnbd-mac-debug-x64-try,vm-kernel-nnbd-linux-debug-ia32-try,benchmark-linux-try,flutter-analyze-try,flutter-frontend-try,pkg-linux-debug-try,vm-kernel-asan-linux-release-x64-try,vm-kernel-gcc-linux-try,vm-kernel-optcounter-threshold-linux-release-x64-try,vm-kernel-precomp-linux-debug-simarm_x64-try,vm-kernel-precomp-obfuscate-linux-release-x64-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-debug-x64c-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/229544
Reviewed-by: Lasse Nielsen <lrn@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2022-03-22 10:30:18 +00:00
Vyacheslav Egorov
c97736d594 [vm/compiler] Fix DelayAllocations pass
When looking at a phi use of an allocation, we must consider *all*
inputs that refer to this allocation and not just the first one.

Otherwise, we might end up sinking allocation down to a use that does
not dominate all uses of the allocation.

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

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

Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-release-x64-try
Change-Id: Iab87b4c225a29a4967eefad56a7e425629ea4b70
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/234361
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2022-03-04 10:00:41 +00:00
Martin Kustermann
0a275f6e97 [vm] Add @pragma('vm:invisible') to mark functions as invisible for stacktraces
The pragma can be used to annotate functions which should not appear in
stack traces unless --show-invisible-frames is passed to the VM.

TEST=vm/dart{,_2}/invisible_function_pragma_test

Change-Id: I807359146f16b67913697f07416fbe8ce9aaa6e1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/233381
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2022-02-18 10:21:02 +00:00
Alexander Aprelev
65178de9d2 [infra] Describe how to download large isolate artifacts(core dumps)
File browser web interface might fail to download large files, so one needs
to use cas tool to download those.

Change-Id: I8053860f9ba443dc481319e5574ecd6d41baf8f7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/225560
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2022-01-29 06:21:23 +00:00
Alexander Markov
0e5a539315 [vm/aot] Keep toString methods on exception classes in toString transformer
Flutter in google3 uses --delete-tostring-package-uri compiler option
to remove toString methods in package:flutter and dart:ui to reduce
size in release mode.
This has unfortunate effect of removing toString methods from exception
classes which may provide valuable information for investigating
problems seen in the wild.

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

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

Issue: https://github.com/flutter/flutter/issues/61562
Change-Id: Ib739c83cdf6b539208f705ba198e63b8bc54fa61
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/227920
Reviewed-by: Dan Field <dnfield@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2022-01-13 15:32:50 +00:00
Alexander Markov
80c6896040 [vm/test] Convert vm/cc/IRTest_TypedDataAOT_{NotInlining,Regress43534} to the new IL tests
There are 2 AOT-specific unit tests which rely on disabled
--use_table_dispatch flag. That flag is enabled everywhere and was
only disabled for the vm unit tests.

These 2 tests are now migrated to the new IL tests infrastructure
and --use_table_dispatch flag is enabled in the vm unit tests.

In order to support testing of IL of closures, IL test infra is
extended with pragma

@pragma('vm:testing:match-inner-flow-graph', 'inner name')


TEST=vm/dart/typed_data_aot_not_inlining_il_test
TEST=vm/dart/typed_data_aot_regress43534_il_test

Change-Id: I900e96136ddedb408ffca05d0c71893c3e12c2c4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/225325
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2022-01-04 15:29:06 +00:00
Vyacheslav Egorov
a643e537fb [vm/infra] Improve IL testing framework
* Add support for dumping flow graphs in JSON (to make it machine
readable);
* Add support for controlling which functions are dumped through
a pragma annotation:
`@pragma('vm:testing:print-flow-graph'[, "passes filter"])`
* Replace simple matching DSL with programmatic matching
* Support obfuscated builds

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

TEST=vm/dart{,_2}/aot_prefer_equality_comparison_il_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
Change-Id: Ie067ba451d311e6019a8c3a88c012231b0c50eb5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/219240
Commit-Queue: Slava Egorov <vegorov@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2021-11-16 12:39:11 +00:00
mnordine
31afa1bf4b Incorrect wording
I think "contains" was meant here.

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

GitOrigin-RevId: ee2dee2b732723b7cf73413d8fde2612f5fb533a
Change-Id: I78be99af3584dee00e4253a1ac32e3e476a01da6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/215340
Reviewed-by: Michael Thomsen <mit@google.com>
Commit-Queue: Michael Thomsen <mit@google.com>
2021-10-04 08:39:38 +00:00
Vyacheslav Egorov
8740a4f10f [vm/infra] Nascent AOT IL tests infrastructure.
Our current unit testing infrastructure does not make it possible to
test AOT compilation pipeline end-to-end, because it does not run TFA
when generating Kernel.

This makes it challenging to write regression tests for certain issues.

Instead we extend test runner with a capability to perform IL matching
when running AOT tests.

runtime/docs/infa/il_tests.md provides details on how to write such tests.

TEST=manually

Change-Id: I6f5220b814f4a5d8c053efacd3711df495dea404
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/214961
Commit-Queue: Slava Egorov <vegorov@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2021-09-30 13:19:42 +00:00
Ryan Macnak
d89e42bef5 [vm] Rename clustered_snapshot.h/cc to app_snapshot.h/cc.
Since bbefc05748, both serialization formats in the VM are based on clustering. The distinguishing feature of the older clustered serializer is that it represents apps/programs rather than messages.

TEST=ci
Change-Id: If3185c21c6aadeec61a940b12ba23d17f2752761
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/211501
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2021-09-16 00:13:34 +00:00
Ahmed Ashour
d6975c1905 master branch to main
Fixes #47190

TEST=None, only markdown files where edited.

Change-Id: Ife204f9c792b6bce30d0cd7bf2260ced11c8f2b4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/213049
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Alexander Thomas <athom@google.com>
2021-09-15 06:22:23 +00:00
Vyacheslav Egorov
d8d7af15ce [vm] Migrate away from native 'name' syntax.
As part of deprecating support for native extensions we are also
migrating away from legacy VM-specific `native 'name'` syntax
towards metadata based encoding which does not require any special
syntax.

This CL is a step 1 in migration:

- introduces support for `@pragma('vm:external-name', 'name')`
which serves as a direct replacement for `native 'name'`;
- all core libraries and tests are migrated to use the annotation;

Once this CL lands and rolls we will edit internal and external embedders
to eliminate uses of the native keyword (step 2) and finally remove
support for native keyword across our parsers (step 3).

TEST=ci

Bug: https://github.com/dart-lang/sdk/issues/28791
Change-Id: Id6dea878db82dd4fd81149243c425b5c5dc6df86
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/212461
Commit-Queue: Slava Egorov <vegorov@google.com>
Reviewed-by: Lasse R.H. Nielsen <lrn@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2021-09-08 13:39:34 +00:00
William Hesse
8776e15f60 [build] Remove runtime_kernel target from GN build
Remove the runtime_kernel target and all uses of it in scripts or
the test matrix.  This runtime_kernel target is only an alias for
the runtime target, now that kernel is the default.

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

Change-Id: I00c0ecf8adbd7bff3fd3df48023a2976c5172066
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/210000
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: William Hesse <whesse@google.com>
2021-08-13 10:09:41 +00:00
Liam Appelbe
624ccd30f8 Don't store entry points directly in ICData and MegamorphicCache
Revert the optimization that stores function entry point addresses
directly in these caches. It doesn't work in compressed mode, and
should be an unimportant optimization these days as most cases are
handled by the dispatch table.

Change-Id: I2ebbf6549aadb49c767553574a3bafe5d867d194
TEST=CI
Bug: https://github.com/dart-lang/sdk/issues/46468
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/205636
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Liam Appelbe <liama@google.com>
2021-07-12 17:17:25 +00:00
Ryan Macnak
9a66e7931c [vm, gc] Add some discussion about not marking through new-space to the high-level docs.
Change-Id: Ibeffa5359af68cce3b13d98f750b70da26af8f53
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/206142
Reviewed-by: Liam Appelbe <liama@google.com>
2021-07-07 18:54:48 +00:00
Regis Crelier
52447f30c8 [VM/docs] Fix typos in types.md
TEST=none needed

Change-Id: Ic7e9ef25fa9ea00e69c0023a2566b25e29855976
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/205627
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Régis Crelier <regis@google.com>
2021-06-30 21:33:10 +00:00
Regis Crelier
985c80a448 [VM/runtime] Add a document describing the representation of types in the VM.
TEST=none needed

Change-Id: I50e4419bc6ed76bc41f9b9e56bbce59c9a432d40
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/205400
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Régis Crelier <regis@google.com>
2021-06-30 02:22:11 +00:00
Jeffrey Swan
fed6cadf77 fix(docs): corrects common typos in project documentation
Scope of changes is restricted to markdown docs only. Changes made in agreement with Standard American English.

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

TEST=Manual review of the changed markdown files.

GitOrigin-RevId: 6df9128b46e4e51e634baf534c0169f62bc6a67e
Change-Id: I7b67dcb5a6e0a03db2b6eea24ace8dee207c4a11
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/196742
Reviewed-by: Bob Nystrom <rnystrom@google.com>
2021-05-18 15:48:18 +00:00
Alexander Thomas
b5c63ce757 [infra] Migrate scripts to python3
* Migrate to python3; drop python support.
* Update Windows toolchain support.
* Remove some unused methods.
* Python 2.7 is still needed on Windows.
* Update gsutil to a version that supports python3.

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

TEST=Manually tested common user journeys.

Change-Id: I663a22b237a548bb82dc2e601e399e3bc3649211
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/192182
Reviewed-by: William Hesse <whesse@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2021-04-15 10:10:20 +00:00
Ryan Macnak
d007362b61 [vm, gc] Mention handles in the high-level GC documentation.
Change-Id: Ibb1eb43c7256096c0a915a2c624626a537f5f95a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/192601
Reviewed-by: Liam Appelbe <liama@google.com>
2021-03-23 21:14:45 +00:00
Vyacheslav Egorov
e5e88fd3cc [vm] Add vm:unsafe:no-interrupts pragma to force remove all CheckStackOverflow
For microbenchmarking it is good to be able to force VM to drop
all stack overflow checks in a given function to reduce overhead of the
measuring loop to the minimum.

This pragma might have other applications, e.g. to allow writing tight
loops in core libraries.

TEST=CheckStackOverflowElimination_NoInterruptsPragma

Change-Id: I07c7fec5c49a893bbb0e4f557d89f022b90be141
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/181400
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2021-02-02 11:19:00 +00:00
Clement Skau
a6dde1b121 [doc] Nit: Fixes MD formatting, pragmas.md
TEST=CQ

Change-Id: I33c1c148f37142d26de791c5b56cfef80f5de364
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/178203
Commit-Queue: Clement Skau <cskau@google.com>
Reviewed-by: Clement Skau <cskau@google.com>
2021-01-08 14:35:42 +00:00
Clement Skau
3ee490327e [VM] Adds @pragma('vm:notify-debugger-on-exception')
Note: This is a reland:
- Relocates the tests.
- Adds status file skip for dartkp.

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

Bug: https://github.com/flutter/flutter/issues/17007
Change-Id: I5c79c140c5e7dee9dfeaa6d4bf750cf4d72f6e85
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/177580
Commit-Queue: Clement Skau <cskau@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2021-01-07 14:33:48 +00:00
Clement Skau
79c6b2701e Revert "[VM] Adds @pragma('vm:notify-debugger-on-exception')"
This reverts commit 9b45fcbd1f.

Reason for revert: Broke kernel-precomp

Original change's description:
> [VM] Adds @pragma('vm:notify-debugger-on-exception')
>
> TEST=runtime/tests/vm/dart{,_2}/notify_debugger_on_exception_test.dart
>
> Bug: https://github.com/flutter/flutter/issues/17007
> Change-Id: I988d2385c3d0fc42c4eb769312278261720bb68d
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/176663
> Commit-Queue: Clement Skau <cskau@google.com>
> Reviewed-by: Martin Kustermann <kustermann@google.com>

TBR=kustermann@google.com,cskau@google.com

Change-Id: Ib0ec0ad0a0e2e11f8088c3f57c4085ffc840d1f3
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: https://github.com/flutter/flutter/issues/17007
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/176664
Reviewed-by: Clement Skau <cskau@google.com>
Commit-Queue: Clement Skau <cskau@google.com>
2020-12-22 15:49:33 +00:00
Clement Skau
9b45fcbd1f [VM] Adds @pragma('vm:notify-debugger-on-exception')
TEST=runtime/tests/vm/dart{,_2}/notify_debugger_on_exception_test.dart

Bug: https://github.com/flutter/flutter/issues/17007
Change-Id: I988d2385c3d0fc42c4eb769312278261720bb68d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/176663
Commit-Queue: Clement Skau <cskau@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2020-12-22 14:42:01 +00:00
Aske Simon Christensen
1ab705f60c [vm] Require all recognized methods to be marked with pragma.
Adds a @pragma("vm:recognized", <kind>) to all recognized methods, where
<kind> is one of "intrinsic", "graph" or "other", corresponding to the
kind of recognized method.

When running in debug mode, it is checked that all recognized methods
are marked with the correct kind of pragma, and that all methods marked
with the pragma are in fact recognized.

This enables kernel-level analyses and optimizations to query whether
a method is recognized by the VM.

TEST=Asserts that check the correspondence both ways, covered by test
suite, in particular the various CompileAll tests that compile all code.
Change-Id: I12f3305c72a93ecb1aefae2d66e3d9a7dae23b44
Cq-Do-Not-Cancel-Tryjobs: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/168951
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2020-11-16 13:49:50 +00:00
Bruno Garcia
655675a7db decode tool from native_stack_trace
I'm going through the docs to ramp up with the split debug-info/DWARF stuff.

In [this doc, I noticed a reference to `pkg/vm/bin/convert_stack_traces.dart`](52f1502191/runtime/docs/dwarf_stack_traces.md (using-the-stack-trace-converter-tool)) but [this code was deleted (moved) in this commit](a003d5e69a (diff-23252e156bc12255fd263fe5f59b6d42)).

The new file is in `pkg/native_stack_traces/bin/decode.dart` which is part of the [native_stack_traces package](https://pub.dev/packages/native_stack_traces).

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

GitOrigin-RevId: fbe926f8d1e3c0fa8cc9abcb045c9d8d750cc921
Change-Id: I5570a23af28cb66853bdc5c2835dcaf1390dd74f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/160400
Reviewed-by: Tess Strickland <sstrickl@google.com>
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
2020-08-27 10:00:37 +00:00
Daco Harkes
6544c69e23 [vm/ffi] Convert Objects to Dart_Handles in FFI calls
This includes support for calling Dart_PropagateError in native code
when doing FFI calls, and catching uncaught exceptions with Dart_IsError
when doing FFI callbacks.

The support for Dart_PropagateError adds a catch entry to the FFI
trampoline, which prevents inlining these trampolines in AOT. This
regresses the FfiCall benchmarks by 1-2% in AOT.

In addition, Dart_PropagateError requires maintaining a bit whether we
entered native/VM code from generated code through FFI or not. That way
we can do the proper transition on the exception path. When entering
generated code, we store this bit on the stack, right after the entry
frame.

Design: http://go/dart-ffi-handles

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

Change-Id: Idfd7ff69132fb29cc730931a4113d914d4437396
Cq-Include-Trybots: luci.dart.try:vm-ffi-android-debug-arm-try,vm-ffi-android-debug-arm64-try,app-kernel-linux-debug-x64-try,vm-kernel-linux-debug-ia32-try,vm-kernel-win-debug-x64-try,vm-kernel-win-debug-ia32-try,vm-kernel-precomp-linux-debug-x64-try,vm-dartkb-linux-release-x64-abi-try,vm-kernel-precomp-android-release-arm64-try,vm-kernel-asan-linux-release-x64-try,vm-kernel-linux-release-simarm-try,vm-kernel-linux-release-simarm64-try,vm-kernel-precomp-android-release-arm_x64-try,vm-kernel-precomp-obfuscate-linux-release-x64-try,dart-sdk-linux-try,analyzer-analysis-server-linux-try,analyzer-linux-release-try,front-end-linux-release-x64-try,vm-kernel-precomp-win-release-x64-try,vm-kernel-mac-debug-x64-try,vm-precomp-ffi-qemu-linux-release-arm-try,vm-kernel-nnbd-linux-debug-x64-try,analyzer-nnbd-linux-release-try,front-end-nnbd-linux-release-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/145591
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2020-06-12 11:14:22 +00:00
Ryan Macnak
9b9ca0178f [vm/tools] Update references to snapshot_analysis.dart.
Change-Id: I93ddca77cb9b2594493298c1ca41403bd92fd3aa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/149021
Reviewed-by: Siva Annamalai <asiva@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2020-05-26 21:21:19 +00:00
Ryan Macnak
4978dcc928 Reland "[vm, gc] Parallel scavenge."
Fix ScavengeVisitorBase::HasWork to account for undone allocations.

Bug: b/153524644
Change-Id: Ifc30017a411c5b65716d4e38752f2edeeb80a77e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/142908
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2020-04-10 19:27:04 +00:00
Martin Kustermann
13c84d8794 Revert "Reland "[vm, gc] Parallel scavenge.""
This reverts commit 898b080d09.

Reason for revert: Seems to cause crashes in g3, see b/153524644.

Original change's description:
> Reland "[vm, gc] Parallel scavenge."
> 
> Remove header access from typed data case in RawObject::HeapSizeFromClass.
> 
> Address data race between visiting remembered cards and allocating new large pages for promotion.
> 
> Change-Id: I92cc4604ed38ab8f42b87b140a26a8118e7030d4
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/142565
> Reviewed-by: Martin Kustermann <kustermann@google.com>
> Commit-Queue: Ryan Macnak <rmacnak@google.com>

TBR=kustermann@google.com,aam@google.com,rmacnak@google.com,asiva@google.com

Change-Id: I3ef7bd5c3d0ca575f33cf5f712f58476037d2d90
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/142861
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2020-04-08 14:21:32 +00:00
Ryan Macnak
898b080d09 Reland "[vm, gc] Parallel scavenge."
Remove header access from typed data case in RawObject::HeapSizeFromClass.

Address data race between visiting remembered cards and allocating new large pages for promotion.

Change-Id: I92cc4604ed38ab8f42b87b140a26a8118e7030d4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/142565
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2020-04-07 17:07:06 +00:00
Ryan Macnak
bb95f88139 Revert "[vm, gc] Parallel scavenge."
This reverts commit 9209f522d6.

Reason for revert: Flaky analyzer crashes

Original change's description:
> [vm, gc] Parallel scavenge.
> 
> Run N tasks that compete to copy or promote survivors. Installation of the forwarding pointer uses a CAS.
> Tasks do not share the list of copied objects to be processed.
> Tasks do share the list of promoted objects to be processed.
> Divide the freelist in N copies. Each scavenger task uses one without locking. The sweeper inserts into the freelists round-robin.
> 
> Change-Id: I54c7839ac5f15829462b3be7cf8c9635c01b785f
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/135962
> Commit-Queue: Ryan Macnak <rmacnak@google.com>
> Reviewed-by: Martin Kustermann <kustermann@google.com>

TBR=kustermann@google.com,aam@google.com,rmacnak@google.com,asiva@google.com

Change-Id: I0d97b8d9148b2a81cabafde4602512e423eba223
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/142554
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2020-04-06 22:51:08 +00:00
Ryan Macnak
9209f522d6 [vm, gc] Parallel scavenge.
Run N tasks that compete to copy or promote survivors. Installation of the forwarding pointer uses a CAS.
Tasks do not share the list of copied objects to be processed.
Tasks do share the list of promoted objects to be processed.
Divide the freelist in N copies. Each scavenger task uses one without locking. The sweeper inserts into the freelists round-robin.

Change-Id: I54c7839ac5f15829462b3be7cf8c9635c01b785f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/135962
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2020-04-06 20:14:54 +00:00
Martin Kustermann
7310377823 [vm/compiler] Tests, cleanups and fixes to Type Testing Stubs.
So far we relied on our normal Dart tests to exercise and test TTS.

This CL adds concrete TTS unit tests, which directly construct the
values the TTS accepts via the calling convention (instance,
dst_type, instantiator tav, function tav), and allows us to test

  * whether TTS handled the type test
  * whether TTS was falling back to STC which handled the type test
  * whether TTS (and STC) preserve the necessary registers

This CL also gets rid of TMP usage in TTS related code.

This CL also adds documentation about TTS to
runtime/docs/compiler/type_testing_stubs.md.

This CL also fixes two issues:

  * handle all-dynamic null vector `as Foo<..., T, ...>`
  * compare the actual type parameter value in `as Foo<..., T, ...>`
    (instead of using type_class_id>)

There seem to be no major performance changes, some benchmarks change
positive/negative but many of them seem to be bi-modal.

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

Change-Id: Iad41e405fe693c67be6221a18e3dad03cc0a5f24
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/139461
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
2020-03-17 14:11:02 +00:00
Ryan Macnak
e8f27551e5 [vm, gc] Add some high-level documentation of write barrier elimination.
Change-Id: Ied50ccd2847f7a7ded7ad8dfe25413208e13f324
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/138788
Reviewed-by: Samir Jindel <sjindel@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2020-03-10 16:50:20 +00:00
Vyacheslav Egorov
857b911f3b [vm/docs] Publish "Introduction to Dart VM" source and build tools.
Change-Id: I30068d6492bd6ec4ce42cc50d4a481960a0197fe
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/133985
Reviewed-by: Alexander Aprelev <aam@google.com>
2020-02-04 09:04:32 +00:00
Ryan Macnak
d9a0359843 [vm, gc] Document safepointing.
Change-Id: I35eca64eb6be8cd72f527644ef8fd644f30287a7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/134109
Reviewed-by: Alexander Aprelev <aam@google.com>
2020-02-03 16:58:22 +00:00
Samir Jindel
445ae73b32 [vm/tfa] Use pragma to pass type arguments to exact return types.
Change-Id: Ie2a1de07653c53e8b9506c54a0a66a5fe6503b9a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/129160
Commit-Queue: Samir Jindel <sjindel@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2020-01-03 14:08:19 +00:00
Teagan Strickland
64e256f7ce [vm] Reland "Weaken dwarf_stack_trace expected stack trace."
We only check the expected stack starting from the call to
foo in main, so we no longer depend on what is captured in
the stacktrace for how main is invoked.

Also removes the old status lines for this test, which are no
longer applicable, and cleans up the documentation a little.

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

Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-release-x64-try,vm-kernel-precomp-linux-product-x64-try,vm-kernel-precomp-obfuscate-linux-release-x64-try
Change-Id: I66746f5a5169bce425bfd1f01a6a912b062e99c7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/128737
Reviewed-by: Teagan Strickland <sstrickl@google.com>
Reviewed-by: Samir Jindel <sjindel@google.com>
Commit-Queue: Teagan Strickland <sstrickl@google.com>
Commit-Queue: Samir Jindel <sjindel@google.com>
2019-12-18 16:11:41 +00:00
Teagan Strickland
d922945601 [vm] Reland "Add docs for DWARF stack traces and related tools/libraries."
Bug: https://github.com/dart-lang/sdk/issues/35851
Change-Id: Iae4bb32fd8fc2770277cfc0b7961ff89e5928b29
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/128733
Commit-Queue: Teagan Strickland <sstrickl@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2019-12-18 14:14:41 +00:00
asiva
8a4cac1ddb Reverting a chain of commits related to debug info splitting.
REASON: the first commit in the chain contains a change that breaks internal
Flutter roll due to duplicated symbols for type testing stubs in assembly
snapshots.

Revert "[vm/compiler] Add --save-debugging-info flag to gen_snapshot."

This reverts commit c2b6c2e1db.

Revert "[vm] De-obfuscate function and file names in DWARF sections."

This reverts commit 4b8fd3c412.

Revert "[vm] Add docs for DWARF stack traces and related tools/libraries."

This reverts commit 5543e5ceb8.

Revert "[vm] Weaken dwarf_stack_trace expected stack trace."

This reverts commit 5824d3ed53.

Change-Id: I95ecd16fe493f61ae761dabfdd91a6ec0c2f0ca3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/128776
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
2019-12-18 01:02:05 +00:00
Ryan Macnak
83eeab1e63 Miscellaneous documentation updates.
Change-Id: I9cc022443ba70b0a450a86943f7636dc6f8c975c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/128373
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2019-12-13 23:10:55 +00:00
Teagan Strickland
5824d3ed53 [vm] Weaken dwarf_stack_trace expected stack trace.
We only check the expected stack starting from the call to
foo in main, so we no longer depend on what is captured in
the stacktrace for how main is invoked.

Also removes the old status lines for this test, which are no
longer applicable, and cleans up the documentation a little.

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

Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-release-x64-try,vm-kernel-precomp-linux-product-x64-try,vm-kernel-precomp-obfuscate-linux-release-x64-try
Change-Id: I61f0465dcd55d090c49db9c6af503ae9c0df6313
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/128401
Reviewed-by: Clement Skau <cskau@google.com>
Commit-Queue: Teagan Strickland <sstrickl@google.com>
2019-12-13 12:09:38 +00:00
Teagan Strickland
5543e5ceb8 [vm] Add docs for DWARF stack traces and related tools/libraries.
Bug: https://github.com/dart-lang/sdk/issues/35851
Change-Id: I3a9d16a85abab825cb698b491d0846dc50f1fff4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/127893
Commit-Queue: Teagan Strickland <sstrickl@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2019-12-12 18:38:50 +00:00
Zhan Wang
7ceceda72c Fix typo in snapshot_profiling.md. heapsnaphsot -> heapsnapshot
Change-Id: I27a879ab266dd56d949c4c9bb5bb415a9ad03991
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/126164
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2019-11-25 15:58:15 +00:00
Ryan Macnak
64329c879d [vm, docs] Describe how to run size analysis for Flutter apps.
Change-Id: I11d9ca7f3668a8705753bb9a0db261a3871fb93e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/125126
Reviewed-by: Zach Anderson <zra@google.com>
2019-11-13 21:34:57 +00:00
Samir Jindel
c885bdde1d [vm] DBC is obsolete. Remove dead code.
Change-Id: Ica33af158cca53c8e951e4b2582de83660e8a60d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/121851
Commit-Queue: Samir Jindel <sjindel@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2019-10-27 18:18:29 +00:00
Martin Kustermann
354921f955 Update runtime/docs/aot_binary_size_analysis.md with paragraph about size comparison tool
Closes #38950
https://github.com/dart-lang/sdk/pull/38950

GitOrigin-RevId: 31625fab4668271f17f4d8d980eac8973eaa69ed
Change-Id: I00cf15f5ddb019441acc8ddf84556d881832500e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/122020
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2019-10-21 21:06:39 +00:00