Commit Graph

13143 Commits

Author SHA1 Message Date
Martin Kustermann 1e114a88d0 [vm/concurrency] Refactor SafepointRwLock to ensure unlocking never causes safepoint transition.
The previous implementation of SafepointRwLock has an issue (discovered
by Slava, see bug) with the following code pattern:

    {
      SafepointReadRwLocker locker(...);
      return Foo(); // <-- Returns raw ptr.
    }

After the return expression has been evaluated to a raw pointer
the destructor might enter safepoint and cause GC, which leaves
the raw pointer unchanged (since it's not in a handle).

This CL refactors the implementation to ensure we don't perform any
state transition in the destructor, therefore eliminate the
possibility of GC moving the object we return.

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

TEST=Relying on existing SafepointRwLock.

Change-Id: Ib7a62b36838edd4b39ad67a8c58f048aa05aa144
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/185062
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2021-02-17 09:53:49 +00:00
Martin Kustermann 5b4349de54 [vm/concurrency] Make main hot-reload implementation independent of current isolate
Since hot-reloading will affect all isolates within a group, there
should be nothing isolate-specific inside it. We therefore add a
NoActiveIsolateScope to the main part of the reloading
implementation.

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

TEST=Refactoring of existing implementation.

Change-Id: I1c8db00e6a016c77c68c2c04448de056a76d42c5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/184782
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2021-02-17 09:38:29 +00:00
Filip Filmar eea10ee6f8 Revert "[vm] Replaces fuchsia.deprecatedtimezone"
This reverts commit 9474c2355d.

Reason for revert: Doesn't compile (?)

Original change's description:
> [vm] Replaces fuchsia.deprecatedtimezone
>
> (prior attempt was rolled back as it had a regression which was not
> caught by tests.  Tests are fixed now at:
> https://fuchsia-review.googlesource.com/c/fuchsia/+/409840)
>
> The FIDL library fuchsia.deprecatedtimezone is going away.  There are
> different and better ways to obtain the same functionality.  This change
> removes the dependency on fuchsia.deprecatedtimezone from the Dart SDK.
>
> Adds inspect metrics that allow whitebox testing of the runners.  Here's
> a sample `fx iquery` excerpt from a running device, showing both a dart
> and a flutter runner exposing the same OS diagnostic metrics.
>
> Adds support for asynchronous timezone updates, which was missing from
> previous versions of this commit.
>
> ```
> /hub/c/dart_jit_runner.cmx/70981/out/diagnostics:
>   /hub/c/dart_jit_runner.cmx/70981/out/diagnostics#os:
>     dst_status = 0
>     get_profile_status = 0
>     timezone_content_status = 0
>     tz_data_close_status = 0
>     tz_data_status = 0
> /hub/c/flutter_jit_runner.cmx/29567/out/diagnostics:
>   /hub/c/flutter_jit_runner.cmx/29567/out/diagnostics#os:
>     dst_status = 0
>     get_profile_status = 0
>     timezone_content_status = 0
>     tz_data_close_status = 0
>     tz_data_status = 0
> ```
>
> Under nominal operation, all of the above values should be equal to 0.
> Nonzero values indicate an error.
>
> This functionality is guarded by Fuchsia integration tests at
> //src/tests/intl.
>
>
> Tested:
>   (compile locally for Fuchsia and deploy)
>   fx test //src/tests/intl
>
> See:
>   - https://github.com/dart-lang/sdk/issues/42245
>   - https://github.com/dart-lang/sdk/issues/39650
>
> Fixes #39650
> TEST=see Tested: above
> Change-Id: Icb72ddd554c263f970e18b9cbbaab7adf43c8710
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/155582
> Auto-Submit: Filip Filmar <fmil@google.com>
> Reviewed-by: Martin Kustermann <kustermann@google.com>
> Commit-Queue: Martin Kustermann <kustermann@google.com>

Change-Id: Ic45c09a49796f8fb8b21cfaa8005db4b57f5eb52
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/185301
Auto-Submit: Filip Filmar <fmil@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2021-02-17 06:50:22 +00:00
Filip Filmar 9474c2355d [vm] Replaces fuchsia.deprecatedtimezone
(prior attempt was rolled back as it had a regression which was not
caught by tests.  Tests are fixed now at:
https://fuchsia-review.googlesource.com/c/fuchsia/+/409840)

The FIDL library fuchsia.deprecatedtimezone is going away.  There are
different and better ways to obtain the same functionality.  This change
removes the dependency on fuchsia.deprecatedtimezone from the Dart SDK.

Adds inspect metrics that allow whitebox testing of the runners.  Here's
a sample `fx iquery` excerpt from a running device, showing both a dart
and a flutter runner exposing the same OS diagnostic metrics.

Adds support for asynchronous timezone updates, which was missing from
previous versions of this commit.

```
/hub/c/dart_jit_runner.cmx/70981/out/diagnostics:
  /hub/c/dart_jit_runner.cmx/70981/out/diagnostics#os:
    dst_status = 0
    get_profile_status = 0
    timezone_content_status = 0
    tz_data_close_status = 0
    tz_data_status = 0
/hub/c/flutter_jit_runner.cmx/29567/out/diagnostics:
  /hub/c/flutter_jit_runner.cmx/29567/out/diagnostics#os:
    dst_status = 0
    get_profile_status = 0
    timezone_content_status = 0
    tz_data_close_status = 0
    tz_data_status = 0
```

Under nominal operation, all of the above values should be equal to 0.
Nonzero values indicate an error.

This functionality is guarded by Fuchsia integration tests at
//src/tests/intl.


Tested:
  (compile locally for Fuchsia and deploy)
  fx test //src/tests/intl

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

Fixes #39650
TEST=see Tested: above
Change-Id: Icb72ddd554c263f970e18b9cbbaab7adf43c8710
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/155582
Auto-Submit: Filip Filmar <fmil@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2021-02-17 04:34:10 +00:00
Regis Crelier 4d5f027ccb [VM/runtime] Reland: Avoid comparing unfinalized type parameters.
This is done by simplifying the code looking for a type argument vector overlap between class and super class.

This is a reland of reverted https://dart-review.googlesource.com/c/sdk/+/184202
First patchset is the reverted CL.
A check for nullability was missing.

TEST=added regression test for the reland.

Change-Id: I77de3eded631d5223e9335ee9743b95878fe5bd7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/185202
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Régis Crelier <regis@google.com>
2021-02-16 22:17:00 +00:00
Ryan Macnak dd83f15826 [vm] Account for compressed pointers in pointer visitors.
TEST=ci
Change-Id: I033bb30e86dfc66ddeb7316a625e3f8925528a19
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/183784
Reviewed-by: Liam Appelbe <liama@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2021-02-16 18:27:39 +00:00
Ben Konyi 3e83400e0f [ VM / Service ] Added getAllocationTraces and setTraceClassAllocation RPCs and identity hash support
This change adds two new RPCs and various new properties:
  - getAllocationTraces
  - setTraceClassAllocation
  - classId and identityHashCode properties in CpuSample
  - traceAllocations property in Class

TEST=get_allocation_traces_test.dart

package:vm_service has been regenerated for 3.43 of the service protocol
and is ready for a 6.1.0 release.
Change-Id: Ia8ed055423798d7d17fe9f5fd74efb4239b875fc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/182666
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2021-02-12 21:15:35 +00:00
Martin Kustermann 2439c412f0 [vm/concurrency] Make main Kernel loading independent of current isolate
Since loading kernel will affect all isolates within a group, there
should be nothing isolate-specific inside the kernel loader. To ensure
we don't have (or introduce) any accidental uses, we add a
NoActiveIsolateScope to the main parts of kernel loading.

Only loading of native extensions - done by the kernel loader -
currently requires an active isolate. The reason for this is that
loading native extensions happen by calling out to embedder, which calls
back into the VM using the our embedding API (which currently requires
an active isolate)

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

TEST=Refactoring of existing implementation.

Change-Id: I96e64dbfe7148b76b8fa006fe5dbde8c1f904504
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/184269
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2021-02-12 19:45:05 +00:00
Lasse R.H. Nielsen d352bc28b8 Remove (most) uses of the "non-nullable" experiment flag.
Since the flag is now enabled by default, there should be no mention of it.
There are still some uses in front_end/testcases that are not just removable
(it also uses `no-non-nullable`). There migth be more uses that are not
as easily found as grepping for `--enable-experiment

Removes two VM tests where fixing them meant they were just duplicating
the corresponding non *_2/ tests.
Fixes #44941

TEST= Large number of tests chaged.=(no-)?non-nullable`.

Change-Id: Ief755981ccde9a5482fcdf408c2929c74433a710
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/183688
Commit-Queue: Lasse R.H. Nielsen <lrn@google.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
2021-02-12 17:16:54 +00:00
Martin Kustermann 461fb4ec8e [vm/concurrency] Remove redundant fields in Isolate
The object store related fields in [Isolate] are not needed anymore:

  Isolate::object_store_
  Isolate::cached_object_store_
  Isolate::object_store_shared_ptr_

and can be directly accessed from [IsolateGroup].

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

TEST=Refactoring of existing implementation.

Change-Id: Ia01da92cbb4e7cf5862c8419e27578ea07d4bdf2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/184268
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2021-02-12 13:14:37 +00:00
Martin Kustermann b80ab44a53 [vm/concurrency] Move class registration from Isolate to IsolateGroup
We share the program across all isolates within a group. So hot-reload
should not depend on a particular isolate. This CL moves class
registration (which hot reload triggers) from Isolate to IsolateGroup.

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

TEST=Refactoring of existing implementation.

Change-Id: Ibdb4e67a095c7f2f3e3c1a8f8194bd0ca936b140
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/184266
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2021-02-12 07:53:46 +00:00
Martin Kustermann c95714d069 [vm/concurrency] Add NoActiveIsolateScope to precompiler & bg compiler
With --enable-isolate-groups we will start sharing JITed code. The JITed
code - which will be executed by all isolates - should therefore not
depend on a particular isolate's state, flags or any other
isolate-specific information.

To avoid accidental bugs where the compiler starts using
isolate-specific information, we ensure the compiler runs without a
current isolate.

This CL doesn't add NoActiveIsolateScope because on unoptimized compiles
of natives, the compiler calls out to embedder for eager native
resolution of native functions. This API forces embedder to callback
into VM atm.

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

TEST=Adds more checking.

Change-Id: I6c86674c010b74c15855652415706dbaa8749d33
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/183692
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2021-02-12 05:59:05 +00:00
Martin Kustermann 8e887672f4 [vm/concurrency] First changes for hot-reloading with isolate gropus.
This CL moves the [ProgramReloadContext] from [Isolate] to
[IsolateGroup] - since the program is shared across isolates. Amongst
other things, it also deoptimizes stacks of all isolate mutators.

There is still future work to do for hot-reloading multiple isolates
within a group, this is only the first change.

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

TEST=Refactoring of existing implementation.

Change-Id: Ic394de265e3922f84657de2da25a46179b624647
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/183693
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2021-02-12 05:48:15 +00:00
Martin Kustermann 02f65fa501 [vm/concurrency] Make clustered snapshot serializer independent of current isolate
Issue https://github.com/dart-lang/sdk/issues/36097

TEST=Mainly refactoring, stress tests for --enable-isolate-groups with JIT will come in the future.

Change-Id: Iebb2fb8bd144cb9abd21916856a04f49f85541c0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/183680
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2021-02-12 04:32:48 +00:00
Martin Kustermann 92af830255 [vm/concurrency] Move background compiler related state from Isolate to IsolateGroup
As part of making the compiler independent of `Isolate` we have to move
various state from `Isolate` to `IsolateGroup`. This CL moves background
compiler and related state.

One background compiler will be shared for all isolates within a group.

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

TEST=Mainly refactoring, stress tests for --enable-isolate-groups with JIT will come in the future.

Change-Id: I66e863651d0b37c431ce1864e505b5413850cbde
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/183401
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2021-02-12 03:40:14 +00:00
Daco Harkes fca959e5f6 [vm/ffi] Add class to vm:ffi:struct-fields pragma
This CL changes `@pragma('vm:ffi:struct-fields', [...])` to
`@pragma('vm:ffi:struct-fields', _FfiStructLayout([...]))` which makes
it easier to add more data in subsequent CLs.

Extends `FindPragma` to allow returning multiple matched pragma's, so
that we can filter them. (In this case to avoid matching user-defined
pragma's that do not have an instance of the private class.)

Separated out from https://dart-review.googlesource.com/c/sdk/+/183640
because of the extra constant in existing expectation files.

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

TEST=tests/ffi(_2)/*_by_value_*_test.dart

Change-Id: Idef9f82e9b53c2a32dffabcec19669eae550fe2f
Cq-Include-Trybots: luci.dart.try:front-end-nnbd-mac-release-x64-try,front-end-linux-release-x64-try,vm-precomp-ffi-qemu-linux-release-arm-try,vm-kernel-nnbd-linux-debug-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/184181
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Clement Skau <cskau@google.com>
2021-02-11 18:09:05 +00:00
Alexander Aprelev 26c0de0acf [vm/deferred] Keep deferred library prefix status on isolate.
This is to ensure that deferred library status is per isolate, rather than per isolate-group.

TEST=deferred_isolate_test.dart

Issue dartbug.com/36097

Change-Id: I1fb8b8f1830aac688a078fe0a82b06c7daa856fa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/184040
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2021-02-11 18:00:59 +00:00
Ryan Macnak 34ce22dcc1 [vm] Remove "ctx" register name from ARM and ARM64.
We no longer have a fixed CTX register.

TEST=ci
Change-Id: Ie15a66077f69444e834bf14576dd7422512c1552
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/184207
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
2021-02-11 16:33:43 +00:00
Daco Harkes 096612ff46 [vm] Fix BitmapBuilder backing store growth
If the length was set longer than the backing store, on a call to
`Set(index, false)`, and subsequently a call `Set(index-1, true)` was
done, it would try to write outside the backing store.

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

TEST=runtime/vm/bitmap_test.cc
TEST=tests/ffi_2/function_structs_by_value_generated_test.dart/0

Change-Id: Ib636e90b0f6acace9ec8b71557370c281e9e4a99
Cq-Include-Trybots: luci.dart.try:app-kernel-linux-debug-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/184423
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
2021-02-11 16:14:13 +00:00
Michal Terepeta f0a4b8a6d7 Revert "[VM/runtime] Avoid comparing unfinalized type parameters."
This reverts commit 18f0599224.

Reason for revert: Breaks internal tests: http://b/179942377

Original change's description:
> [VM/runtime] Avoid comparing unfinalized type parameters.
>
> This is done by simplifying the code looking for a type argument vector overlap between class and super class.
>
> TEST=all existing ones
>
> Change-Id: I96b11deb3450de380280c693d05e9b70a01e3383
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/184202
> Commit-Queue: Régis Crelier <regis@google.com>
> Reviewed-by: Alexander Markov <alexmarkov@google.com>

TBR=alexmarkov@google.com,asiva@google.com,regis@google.com

Change-Id: I2fbebbb9f429a9ee389ab891cb3775c6d88eca9f
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/184424
Reviewed-by: Michal Terepeta <michalt@google.com>
Commit-Queue: Michal Terepeta <michalt@google.com>
2021-02-11 12:35:46 +00:00
Regis Crelier 18f0599224 [VM/runtime] Avoid comparing unfinalized type parameters.
This is done by simplifying the code looking for a type argument vector overlap between class and super class.

TEST=all existing ones

Change-Id: I96b11deb3450de380280c693d05e9b70a01e3383
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/184202
Commit-Queue: Régis Crelier <regis@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2021-02-10 23:12:16 +00:00
Martin Kustermann 0fec35f7df [vm/concurrency] Remove redundant Isolate::shared_class_table_
Issue https://github.com/dart-lang/sdk/issues/36097

TEST=Refactoring of existing implementation.

Change-Id: I4e875ed0996f86a73c712c67da3d261949603512
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/184264
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2021-02-10 20:48:05 +00:00
Martin Kustermann 75e0837f3e [vm/concurrency] Simplify logic around background compiler, allow concurrent disabling
The logic for background compiler can be simplified due to:

  * we only have one bg compiler
  * it always optimizes
  * it is allocated at isolate startup and freed on isolate shutdown
  * an existing check in the compiler for whether the BG compiler is
    disabled is racy and therefore not helpful
  * when a mutator communicates with BG compiler it will use
    SafepointMutexLocker instead of MutexLocker

This CL also ecapsulates disabling the BG compiler via a
NoBackgroundCompilerScope object. It allows nested disabling and guards
against races.

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

TEST=Refactoring of existing code.

Change-Id: I36ed6592c9a8b91e94181698b7de662b4ee984e9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/183400
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2021-02-10 19:42:55 +00:00
Ryan Macnak 4b1098577e [vm] Don't use ROData serialization when using compressed pointers.
TEST=ci
Change-Id: I7ddc7783ac57d82403681b8fbc0e3004a757aabe
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/183220
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Liam Appelbe <liama@google.com>
2021-02-10 17:44:49 +00:00
Martin Kustermann 6a60ed277b [vm/concurrency] Avoid using two different mechanisms to check for single-isolate
During isolate shutdown we remove the isolate from the list of isolates
in a group in one step and decrement a counter in another. Those are not
done atomically.

To avoid races where we use one condition and later on assume the other
holds as well, consistently use the same condition.

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

TEST=Fixes flaky tsan hits of ASSERT.

Change-Id: I41eeb00cd3e341d07cba7571b29aeb4eacdfc458
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/184260
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2021-02-10 16:50:23 +00:00
Clement Skau eea3d456a2 [Nit] bying -> being
TEST=None

Change-Id: Ib7ac7ecb6b2223c35ed0bf1c007e4bc8b39e464c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/184263
Commit-Queue: Clement Skau <cskau@google.com>
Reviewed-by: Clement Skau <cskau@google.com>
2021-02-10 14:03:30 +00:00
Daco Harkes 7a4d1c118f [vm/ffi] Support inline arrays in Structs backend
The various ABIs lay out structs with inline arrays the same way as
they do with only nested structs and primitive values.
Most notably, homogenous structs (arm and arm64) and structs spread
over a CPU and FPU register in x64 Linux/MacOS will even be laid out
this way if irregular size nested arrays are involved.
These cases are covered in the unit tests.

This CL introduces the ByteRange to ease the ContainsOnlyFloats
calculation for x64.

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

tools/build.py run_ffi_unit_tests && tools/test.py ffi_unit
TEST=runtime/vm/compiler/ffi/native_calling_convention_test.cc
TEST=runtime/vm/compiler/ffi/native_type_test.cc

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

Change-Id: I4bbcbffd47eb8901a87db64e62aa5cbe67d03e18
Cq-Include-Trybots: luci.dart.try:vm-precomp-ffi-qemu-linux-release-arm-try,vm-kernel-win-debug-ia32-try,vm-kernel-win-debug-x64-try,vm-kernel-precomp-nnbd-linux-debug-x64-try,vm-kernel-linux-debug-ia32-try,vm-kernel-mac-debug-x64-try,vm-ffi-android-debug-arm64-try,vm-ffi-android-debug-arm-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/183682
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Clement Skau <cskau@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2021-02-10 11:01:18 +00:00
Ryan Macnak 25fd0200ef [vm] Replace recanonicalization in primary snapshots with weak constant tables.
TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/41974
Change-Id: Icc4a3ebf861dca5172a0cfa2cd2eea266e814d0c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/181480
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2021-02-10 01:21:07 +00:00
Ben Konyi 40ed649ef6 [ VM ] Fix DartAPI_Invoke* tests in Product mode
Fixes https://github.com/dart-lang/sdk/issues/44896

TEST=N/A
TBR=asiva@google.com

Fixed: 44896
Change-Id: I2cc7a0d9669e5e81cacb7080da32e4eaf7317a86
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/183901
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2021-02-09 18:40:02 +00:00
Alexander Aprelev 6ac90525a0 [vm/concurrency] Allow for background compiler to disable field unboxing.
Issue dartbug.com/36097

TEST=existing test suite
Change-Id: Idd0c26fe9c81a733685105aa944b96ed58bc2765
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/182669
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2021-02-09 16:27:13 +00:00
Daco Harkes aa2a6f8581 [vm/ffi] Change type of typedDataBase parameter for load and store
So that it can be invoked from `CArray` which has a backing store
that is either TypedData or Pointer.

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

TEST=tests/ffi(_2)/*

Change-Id: I30bb0c1e848f2ac4f47919009106d5428ed66453
Cq-Include-Trybots: luci.dart.try:vm-kernel-linux-debug-x64-try,vm-kernel-precomp-nnbd-linux-debug-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/183683
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
2021-02-09 13:01:49 +00:00
Ben Konyi fbbc99e1e9 [ VM ] Ensure Dart C APIs perform type checks when invoking functions
and constructors

Dart_New, Dart_InvokeConstructor, and Dart_InvokeClosure were not
checking the types of arguments before performing invocations.

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

TEST=DartAPI_*_Issue44205

Change-Id: I6c06e3e8a0a88b9caa7e2212c4a2c8e43d39b4f4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/182962
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2021-02-08 23:30:05 +00:00
Martin Kustermann b7ad7a3000 [gardening] Use a read lock instead of a write lock
When accessing the list of isolates in a group to get the first one we
only need a read-lock, not a write-lock.

This fixes hot-reload bot timeouts where a mutator hits a StackOverflow
slowpath that triggers a reload, which loops over all isolates in a
group to stop BG compiler (takes read lock). The BG compiler in return
will try to acquire write-lock for `FirstIsolate()`, which causes a
deadlock.

TEST=Existing reload timeouts.

Change-Id: Iba9264cc4990a4f00697844c44fad407cebf2e21
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/183003
Reviewed-by: Clement Skau <cskau@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2021-02-05 10:17:22 +00:00
Martin Kustermann 6f90dd22ce [gardening] Small partial revert that enabled validating constants after reload
While addresing a comment in the review of [0], the CL removed a bailout in
`Isolate::ValidateConstants()` that disabled validating of constants
when hot-reload was performed. Apparently there is still an issue with
that. So this CL adds this bailout again.

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

TEST=Partial revert, fixes constant validation failures.

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

Change-Id: Iefe9acceb344e73fad97246064e91a32a00dad10
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/183002
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Clement Skau <cskau@google.com>
2021-02-05 10:14:14 +00:00
Ben Konyi c039ff268f [ VM ] Fix crash when accessing metrics page when no metrics have been
logged

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

TEST=regress_44859_test.dart

Change-Id: I7aa6b54f8f8d04b630d0ffe64d5414a6a9e56de2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/183041
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2021-02-05 00:31:47 +00:00
Martin Kustermann 75a4fa6e23 [vm/concurrency] Move AllClassesFinalized/RemappingCids bits from Isolate to IsolateGroup
Those bits are used by parts of the VM that should be independent of the
current isolate (e.g. class finalizer, compiler).

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

TEST=Refactoring of existing code.

Change-Id: I25c8340304d21fdfa77fa5ab4a5f77a4884d0bba
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/182620
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2021-02-04 18:09:37 +00:00
Martin Kustermann 376bf1826a [vm/concurrency] Move HasAttemptedReload() bool from Isolate to IsolateGroup
As part of making the compiler as well as hot-reload independent of
a particular isolate we move this boolean to `IsolateGroup`.

For hot-reloading isolate groups there are more changes needed that
come in the future. This CL is preparation for making the compiler
independent of current isolate.

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

TEST=Refactoring of existing code.

Change-Id: I434cf1180bc963462e2901dfa83e915df9dc1712
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/182561
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2021-02-04 17:45:57 +00:00
Alexander Markov d423a3cd7a [vm/aot] Remove reverse PC lookup from switchable calls
This is a preparation for removal of Code objects.

Issue: https://github.com/dart-lang/sdk/issues/44852
TEST=ci
Change-Id: I9765945731c91fbdac647cc448d021238f129880
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/182361
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2021-02-04 17:36:47 +00:00
Martin Kustermann 5f78a23bb9 [vm/concurrency] Remove usage of current isolate field state from compiler
As part of making the compiler independent of the current isolate (since
JITed code will be shared across all isolate) we make the compiler not
depend on global field state, with one exception: we preserve an existing
optimization that utilizes knowledge whether a global final field was
already initialized (if --enable-isolate-groups is turned off) - we do
so by asking the isolate group for it's own isolate member.

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

TEST=Refactoring of existing code.

Change-Id: I2f08d854af6102e05e5a1df8d5b66b514d6f3ce4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/182540
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2021-02-04 15:54:27 +00:00
Johnni Winther 6ce8d74761 [cfe] Add Function.futureValueType and serialize Let.fileOffset
Serializing Let.fileOffset supports positions in stacktraces resulting
from null aware expressions, like `if (o?.foo) ...` when `o` is `null`.

Adding Function.futureValueType supports the proper backend
implementation for the fix in
https://dart-review.googlesource.com/c/sdk/+/181303

Closes #44654

TEST=existing

Change-Id: Ie5939a248d3d8bf41388e8f435e4ba4195afeabd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/182269
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2021-02-04 14:06:47 +00:00
Alexander Thomas c88171c8af [sdk] Bump version to 2.13
TEST=Presubmit tests and local builds
Change-Id: I1b15d60eced0cf3f422548eda75706609f6640cb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/182624
Commit-Queue: Alexander Thomas <athom@google.com>
Auto-Submit: Alexander Thomas <athom@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2021-02-04 12:10:17 +00:00
Martin Kustermann d604461fc5 [vm/concurrency] Avoid relying on Isolate::Current() when deoptimizing code.
The background compiler can cause finalization of classes which can
cause deoptimization of code.

Any deoptimization will iterate over all mutator threads and marks
frames on the stack to be deoptimized. This requires saving old
(fp, pc) state. This state is currently saved on the current isolate's
pending deopt array (via `Thread::Current()->isolate()->AddPendingDeopt()`)
instead of the isolate whose stack got walked.

As part of making the compiler independent of `Isolate::Current()` we
pass the isolate explicitly.

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

TEST=Refactoring of existing code.

Change-Id: I9327f3b76981fc16c1879a873edf37df1cbdd8bf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/182380
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2021-02-04 11:45:22 +00:00
Martin Kustermann 59aa375d22 [vm/concurrency] Make compiler create JitCookie using IsolateGroup::random()
As part of making the compiler independent of the current isolate (since
JITed code will be shared across all isolate) we make the compiler not
depend on `Isolate::random()` but rahter on `IsolateGroup::random()`.

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

TEST=Refactoring of existing code.

Change-Id: I4a7bdd5c3e3d7ca83ef828ad6e38f117b5f2e9ce
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/182560
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2021-02-04 11:12:47 +00:00
Vyacheslav Egorov 25cf5c0517 [vm/compiler] Relax reachability fence input representation requirements
When using reachability fence as an optimization barrier (e.g. to
prevent dead code elimination or allocation sinking) it is helpful
to reduce fence's impact on optimizations themselves.

TEST=ci

Change-Id: I4581c73e4704e94870a9942e05e16ab38ca2d864
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/182625
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
2021-02-04 11:11:07 +00:00
Martin Kustermann 3020f7dca2 [vm/concurrency] Remove the unused Isolate::deoptimized_code_array_ and related
Supposedly the intention was to use this in runtime/vm/profiler.cc but
it has been seemingly unused for a while without any issues or test
failures, so this CL removes it.

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

TEST=Removing of code.

Change-Id: I53df5e92e146169b6d8d21c763dd7e8b8f50289a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/182510
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2021-02-04 10:54:12 +00:00
Martin Kustermann 3ce16de628 [vm/concurrency] Move no_reload_scope_depth from Isolate to IsolateGroup
As part of making the compiler and various other systems independent of
the current isolate, we move state from Isolate to IsolateGroup.

There is still follow-up work to do for hot-reloading isolate groups.

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

TEST=Refactoring of existing code.

Change-Id: I4a2cebd06b49696e733adde622217b4de6718260
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/182508
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2021-02-04 10:46:47 +00:00
Martin Kustermann 9f6bc62a39 [vm/concurrency] Move boxed field list form Isolate to IsolateGroup
As part of making the compiler independent of a particular isolate
(since all isolates in a group share the same JITed code) we move the
boxed field list to IsolateGroup.

Any isolate that hits the lazy compile stub will then drain the fields
to be deoptimized and performs that work.

A follow-up investigation can decide whether it's beneficial (or
hurtful) for single vs multi isolate scenarios to deoptimize the field
immediately in BG compiler (and interrupt mutator). It is possibly
disadvantagues for single isolate scenarios to do so, since it causes
more mutator interruptions.

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

TEST=Refactoring of existing code.

Change-Id: I64b42ad99056b43a7264bcc30280b9ba39389a2e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/182505
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2021-02-04 10:46:07 +00:00
Vyacheslav Egorov 6b5b74ee0e [vm/arm64] EmitLoadInt32FromBoxOrSmi should load 4 bytes only
This is follow up to 6681bce565
the intent was always to perform a sign-extending 4 bytes load.

TEST=ci

Cq-Include-Trybots: luci.dart.try:vm-kernel-linux-release-simarm64-try,vm-kernel-precomp-linux-release-simarm64-try
Change-Id: Ie2b733c4de9bd564cb666d54c9e7b483dbfbeabb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/182261
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
2021-02-04 09:53:52 +00:00
Vyacheslav Egorov 24a30defcc [vm] Ensure liveness of typed data containing Kernel binary
When handling hot reload via library tag handler's Kernel tag
VM must guarantee that external typed data it receives from the
embedder stays alive for as long as VM has any structures
referencing this kernel binary. This is achieved by attaching
original typed data to KernelProgramInfo objects containing
the views into it.

Unfortunately kernel::Reader APIs were somewhat unsafe: allowing
to construct reader object from Program's raw buffer and forget to
set the link betwen the reader and original typed data.

This created a situation where reloading using a multicomponent
Kernel binary would result in KernelProgramInfo objects without
link to the original typed data, which in turn leads to premature
finalization of external typed data and subsequent crashes
when trying to use delete kernel binary.

This CL reworks kernel::Reader API (by introducing kernel::ProgramBinary
wrapper) to make it safer and make sure that connection is preserved.

TEST=vm/cc/IsolateReload_RegressB179030011

Bug: b/179030011
Change-Id: I05f8c31c3cb8e67de6e94a20d9501a5f476b7e27
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/182280
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2021-02-04 09:46:17 +00:00
Alexander Markov 454aa9c34b [vm] Remove unused RegularStackTraceBuilder
TEST=cleanup
Change-Id: I22d0017544ab23ccb359b42e46e3681ba72093f6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/182662
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2021-02-03 21:15:09 +00:00