Commit Graph

13143 Commits

Author SHA1 Message Date
Martin Kustermann ed78971d90 [vm/concurrency] Simplify conditions for hot reload and test mode implementation
This is part of making hot-reload work with isolate groups.

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

TEST=Refactoring of existing code.

Change-Id: Id32e7d8f95ba0b1fb5bd11179dcd1805d42aba89
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/187083
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2021-03-02 15:21:22 +00:00
Martin Kustermann d7a9015268 [vm/compiler] Remove BG compiler bailouts that afaik should not be possible
Many years ago those bailouts were seemingly added due to deferred
loading in [0]. Though it seems like those bailouts might've become
obsolete.

All places that clear the IC array on the function should run inside
a [NoBackgroundCompiler] scope, therefore ensuring no optimizing
compilations are done at that time. Those places also clear code,
therefore forcing re-compilation of unoptimized code (which will
re-create the ICData).

[0] https://codereview.chromium.org/1672873003/#ps60001

TEST=Removing dead code.

Change-Id: Iec4f22be500f6e874fa5286b51396bd6d978dd6c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/187902
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2021-03-02 15:16:32 +00:00
Martin Kustermann 7fc9a1a14c [vm/compiler] Remove non-background optizable bit
The background compiler no longer has bailouts due to something that
cannot be done on BG compiler and has to be done on mutator (was
originally introduced in [0])

All optimizing compilations can happen on the BG thread. Class
finalization and other things no longer cause a bailout on BG
compiler.

If e.g. invalidated field guards cause a compilation to be discarded, it
can be retried on BG compiler.

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

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

TEST=Fixes flaky hits of an assertion.

Change-Id: I50313dbedf96b8dec205acdb8c1ed5731d00433b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/187901
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2021-03-02 14:20:02 +00:00
Martin Kustermann 29268ba7d2 [vm/concurrency] Move no-reload-scope counter to Thread
Whether a given isolate allows reloading is really a property of the
thread not the isolate (where it was before) or isolate group (where
it was moved to), so this CL moves it to Thread.

As the thread's stack is going down and up, NoReloadScope's might be
entered or exited, just as with our many other scopes, such as
NoOOBMessageScope/...

Longer term we might need to find a better mechanism to deal with
different OOB messages. For example: Reload as well as OOB messages
are disabled during static field initialization. Though that means *all*
OOB messages cannot reach the isolate during initialization of a static
field (which can do arbitrary amount of work).

This is part of making hot-reload work with isolate groups.

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

TEST=Refactoring of existing code.

Change-Id: I9e80c6d4a184c54c0373fef13af3264cc3f27ece
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/187002
Reviewed-by: Alexander Aprelev <aam@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2021-03-02 14:11:42 +00:00
Martin Kustermann f3740ced59 [vm/concurrency] Add SafepointMonitorUnlockScope to allow scoped unlocking of a monitor
In order to simplify code that needs to temporarily give up a monitor
lock, this CL adds a scoped object that releases the monitor on
construction and re-acquires it on destruction.

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

TEST=Refactoring of existing code.

Change-Id: I004a04e54dcdaea009bfbef25d2a946a307e41c6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/187001
Reviewed-by: Alexander Aprelev <aam@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2021-03-02 13:11:42 +00:00
Tess Strickland 3382bbc510 [vm] Print out canonical clusters in --print-snapshot-sizes-verbose.
TEST=Manual use of the flag.

Cq-Include-Trybots: luci.dart.try:vm-kernel-linux-debug-x64-try,vm-kernel-nnbd-linux-debug-x64-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-nnbd-linux-debug-x64-try
Change-Id: I4c506848f97f6b9a3f1455f90872093497c853a8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/188287
Commit-Queue: Tess Strickland <sstrickl@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2021-03-02 08:37:01 +00:00
Ryan Macnak 9451963493 [vm, compiler] Remove intrinsics from internal double-dispatching int methods.
If the intrinsic on int.op fails, then the intrinsic on _opFromInteger will also fail, since both handle the same range of values.

Add intrinsic on int.% as previously only _moduloFromInteger was intrinsified. All the other ops already intrinsified the public method.

Remove _bitAndFromSmi; this was once useful for handling BigInt & Smi, but this case no longer exists.

TEST=ci
Change-Id: Ie33b75126e56110db3caabb9bcb6e9198a3158bf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/187160
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2021-03-01 19:29:00 +00:00
Tess Strickland 960c944940 [vm/compiler] Get parameter names/counts from the closure signature.
Doing so removes some dependencies on the closure function itself,
making it easier to shake the function when possible in the future.

TEST=Existing tests that check dynamic closure invocations.

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

Cq-Include-Trybots: luci.dart.try:vm-kernel-linux-debug-x64-try,vm-kernel-nnbd-linux-debug-x64-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-nnbd-linux-debug-x64-try
Change-Id: I88c4b37efff9a9894633db7f380ecc39da717e6e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/187081
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
2021-03-01 16:25:24 +00:00
Vyacheslav Egorov 6e7c0ae227 [vm] Comment for RegressFlutter76919
Add a comment which describes what this test is testing.

TEST=not needed
TBR=kustermann@google.com

Change-Id: I88238595d1c11609130bfdde3219f58c39db57f6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/188284
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
2021-03-01 14:35:09 +00:00
Vyacheslav Egorov afa22dd1ab [vm/aot] Disable assert strengthening optimization in AOT
This optimization does not make sense in AOT and can actually cause
AOT compiler to segfault because it expects environment to be
attached to AssertAssignable instructions which is not always
the case on AOT compiler.

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

TEST=vm/cc/TypePropagator_RegressFlutter76919,vm/dart{,_2}/regress_flutter76919

Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-product-x64-try,vm-kernel-precomp-linux-release-x64-try
Change-Id: I8f4314d7dac276833a9050bba835616b670a88d5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/188281
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
2021-03-01 13:13:19 +00:00
Vyacheslav Egorov 1f828c7cb2 [vm/compiler] Fix IntConverter canonicalization
When going from Int64 through another representation back into Int64
you can discard a conversion if and only if it does not lose some
bits on the way. Previously we were checking for truncation flag, but
this is incorrect because it does not actually tell us anything about
about whether or not bits are going to be lost.

Instead, we should be checking the range of the source value.

In addition to fixing potential correctness issues, this CL actually
improves quality of code generated for Uint8 loads because it removes
a redundant chain of Int64->Uint32->Int64 conversions that follows
the load (which compiled 2 two redundant moves).

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

TEST=vm/cc/IL_IntConverterCanonicalization

Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-release-x64-try
Change-Id: Ifef0943a50d414bde41b2194e30b58ad3a8c106c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/187921
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
2021-03-01 09:55:09 +00:00
Alexander Markov 26e7106937 [vm/aot] Partially remove Code objects from AOT snapshots
Code objects which do not carry useful information are
marked as 'discarded' during precompilation. Snapshot
serializer only writes instructions, compressed stack
maps and state bits for discarded Code objects.

This is a preliminary step before deserializer would be able
to omit creating instances for discarded Code objects at
runtime.

On a large app, AOT-compiled in PRODUCT mode with
--dwarf-stack-traces on arm64:
Discarded: 77% of all Code objects in snapshot.
Uncompressed AOT snapshot size -1.9%.

AOT snapshot size of Flutter gallery in release-sizeopt mode:
arm64 uncompressed -2.1% (gzip -0.6%, brotli -0.7%)
arm32 uncompressed -1.9% (gzip -0.6%, brotli -0.7%)

TEST=ci
Issue: https://github.com/dart-lang/sdk/issues/44852

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,pkg-mac-release-try
Change-Id: I159cfebbdac76cc60060fedb1d22ed86672a68a1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/187600
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2021-02-27 00:41:37 +00:00
Daco Harkes 0295dfc74e [vm] Support redirecting external const factories
This CL introduces the first combination of `external const factory`
with `@patch const factory (.*) = (.*)`. This specific combination was
never used in the core libraries, and did not work.

Half of the fix is a missing flag from the CFE:
https://dart-review.googlesource.com/c/sdk/+/187440

The other half of the fix is matching on the
kRedirectingFactoryConstructor tag, and allowing constructor names
in procedure targets (even though we never compile those expressions
because they are invalid).

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

TEST=Using redirecting const factory in patch file in core lib.
TEST=tests/ffi(_2)/*

Change-Id: I5524bde928290bf32aaea9170eda1f2d03127fa6
Cq-Include-Trybots: luci.dart.try:benchmark-linux-try,front-end-linux-release-x64-try,vm-kernel-linux-release-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/187003
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Reviewed-by: Clement Skau <cskau@google.com>
2021-02-26 11:15:26 +00:00
Vyacheslav Egorov 7ba12664ea [vm/compiler] Fix LoadStaticField::ComputeCanDeoptimize
It should only return true in JIT mode similar to other calls.

Discovered when looking at allocation sinking in FFI version of
reverse-complement microbenchmark.

TEST=ci

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

Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-product-x64-try,vm-kernel-precomp-linux-release-x64-try
Change-Id: I79f432ffb88a467336fcb412a2d9fcdedc390cd8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/187404
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
2021-02-26 10:24:27 +00:00
Clement Skau f2dfe3a8be [vm/debugger] Fixes async CollectAwaiterReturn()
The async, off-stack part of DebuggerStackTrace::CollectAwaiterReturn's
stack unwinding incorrectly looked on the stack instead of following
the Closure's awaiter chain.
This caused the async stack traces to be truncated and missing any
async frames, in turn causing ShouldPauseOnException to incorrectly
conclude no handler frame existing.
This would affect any case where the exception handling was located
around any except for the inner most awaiter.

TEST=Added regression test to pause_on_unhandled_exceptions_catcherror_test

Closes: https://github.com/dart-lang/sdk/issues/37953
Bug: https://github.com/dart-lang/sdk/issues/37953
Change-Id: I34a2b5ce3c7532032b2ef3dfbc2af7294d13a4c7
Cq-Do-Not-Cancel-Tryjobs: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/187405
Commit-Queue: Clement Skau <cskau@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
2021-02-26 06:46:36 +00:00
Ryan Macnak 20bc0a0ce1 [vm] Fix annotated pool references when disassembling in JIT mode.
FLAG_use_bare_instructions is vacuously true in JIT mode, so use GetObjectPool which additionally accounts for JIT versus AOT.

TEST=examine output of --disassemble in JIT, AOT compile and AOT runtime
Change-Id: Idae17b779f16a6b823cf702bf868b232ca0e03ab
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/187521
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2021-02-25 21:09:57 +00:00
Liam Appelbe 807874d51a [vm] Align compressed pointer allocations on windows.
Change-Id: I95ad0a2cf679a5918d42b12bb95f1503bb219fca
TEST=CI
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/184846
Commit-Queue: Liam Appelbe <liama@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2021-02-25 20:48:07 +00:00
Martin Kustermann c78f12c550 [vm/concurrency] Allow caller of Thread::{Exit,Enter}Isolate to specify nesting
It's mainly hoisting an expression out of
IsolateGroup::{Increase,Decrease}MutatorCount to callers of it.

Right now we consider a Thread::{Exit,Enter} to be nested if there are
existing Dart frames on the stack. A future CL will have a case where
there's a nested exit&re-enter without Dart frames on the stack.

Trying to do this automatically by checking whether there's an
active api scope / zone on the thread fails due to some
asymmetry in our codebase.

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

TEST=Refactoring of existing code.

Change-Id: Id70eda03efb2099487c5f0c8affd25ddff926553
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/186287
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2021-02-25 18:44:16 +00:00
asiva 02c1e2e56b Remove obsolete comment,
Full snapshots are generated from the clustered snapshot modules
and code in this file is used for only isolate messaging and the comment
about full snapshot does not apply here.

TEST=no tests, just a comment delete.

Change-Id: Ib2453514639aae1c99d3eab6bb120f0ec5ac9f4b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/186747
Reviewed-by: Siva Annamalai <asiva@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
2021-02-24 23:05:14 +00:00
Ryan Macnak 9876de6838 [vm, x64] Cleanup BoxInteger32Instr to remove effects when not using compressed pointers.
TEST=ci
Change-Id: I28dd873a27d6ecc96855b810db55f568c71645ce
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/186763
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Liam Appelbe <liama@google.com>
2021-02-24 21:23:54 +00:00
Alexander Aprelev 203532a647 [vm/concurrency] Use SafepointMonitorLocker when enabling background compiler.
The way how BackgroundCompiler::Enable manipulates done_monitor_ lock should match how BackgroundCompiler::Disable manipulates it - by getting to a safepoint if needed.

TEST=Fixes flaky timeouts

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

Change-Id: Iac3e4b864951ccbe904a1031bc7f5a557faf3b41
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/187061
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2021-02-24 20:43:54 +00:00
Ryan Macnak 1a83a454dd [vm, arm64] Fix simulation of 32-bit clz.
TEST=ci
Change-Id: Ie9cd4d39ed95ec3c770b94c40362c5827ceb4a76
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/186460
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Liam Appelbe <liama@google.com>
2021-02-24 20:18:44 +00:00
Dmitry Stefantsov c191551fac [cfe] Remove BottomType
TEST=Covered by existing tests.

Change-Id: Ied8be1874164e68e0a3a48e1b2f9a33310071381
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/183009
Commit-Queue: Dmitry Stefantsov <dmitryas@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2021-02-24 13:21:55 +00:00
Daco Harkes d45fd0f9d5 [vm/ffi] Support inline arrays in Structs
Adds support for single dimension inline arrays in structs. Multi-
dimensional arrays will be supported in a future CL.

This CL adds:
- CFE static error checks for inline arrays.
- CFE transformations for inline arrays.
- VM consumption of inline array fields for NativeType.
- Test generator support for inline arrays + generated tests.

Previous CLs added support for inline arrays in:
- analyzer https://dart-review.googlesource.com/c/sdk/+/183684
  - updated in this CL to new API.
- ABI calculation https://dart-review.googlesource.com/c/sdk/+/183682

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

Open issue: https://github.com/dart-lang/sdk/issues/45101

CFE transformations are tested with expectation files:
TEST=pkg/front_end/testcases/(.*)/ffi_struct_inline_array.dart

Trampolines and CArray API are tested with end-to-end Dart tests:
TEST=tests/ffi(_2)/(.*)by_value(.*)test.dart
TEST=tests/ffi(_2)/inline_array_test.dart

Compile-time errors (both CFE and analyzer) are tested in:
TEST=tests/ffi(_2)/vmspecific_static_checks_test.dart

Change-Id: I014c0e4153f1b885638adce80de6ab3cac8e6bb2
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
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/183640
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Clement Skau <cskau@google.com>
2021-02-24 13:02:45 +00:00
Regis Crelier ba611b720b [VM/runtime] Dereference top-level TypeRefs type arguments during finalization and hashing.
This fixes https://github.com/dart-lang/sdk/issues/45060

TEST= added regression tests

Change-Id: Ie6e3fd8514ee5b42af1ab5a5c72883c2510da31d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/186421
Reviewed-by: Régis Crelier <regis@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Régis Crelier <regis@google.com>
2021-02-24 02:39:27 +00:00
Alexander Markov 7f8001218b [vm] Support unsigned shift operator int.>>>
TEST=runtime/tests/vm/dart/unsigned_shift_right_test.dart and other
tests for >>>.

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

Change-Id: I7f0a9e1e486be06576c5d9bff3659b0aa6d68c23
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/184921
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
2021-02-24 00:14:57 +00:00
Ryan Macnak a32b550034 [vm, arm64] Fix simulation of 32-bit sbfm.
Use the preferred disassembly for asr/lsr/lsl aliases of sbfm/ubfm.

TEST=ci
Change-Id: I80a16c3faa06885354b786bcbd078d0c1e39e387
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/186080
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Liam Appelbe <liama@google.com>
2021-02-24 00:02:58 +00:00
Ryan Macnak 0080a1a43b [vm, gc] Don't hold PageSpace::tasks_lock_ while visiting remembered cards.
The scavenger may abort while visiting the remembered cards if we run out of memory. The longjmp implementing this abort would skip ~MonitorLocker, leaving the monitor locked and (in debug mode) Thread::no_safepoint_scope_ unbalanced.

TEST=fragmentation_test
Bug: https://github.com/dart-lang/sdk/issues/45059
Change-Id: I63d77709c8d8948b5827f7ecde5b0ecb3af9a245
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/186640
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Liam Appelbe <liama@google.com>
2021-02-23 22:28:01 +00:00
Alexander Aprelev f87723a638 [vm/debugger] Refactor Debugger class so locally-visible methods are static functions.
This is to reduce size of Debugger class, simplify splitting it into isolate and isolate_group parts.
There is no functional change in this cl.

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

TEST=existing tests, no functional changes, refactoring.

Change-Id: I3199a7a791dc6c8d1d22e83f7d88911e4cf5fac6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/186021
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2021-02-23 05:08:09 +00:00
Liam Appelbe be0978cbde Reland "[vm] Align heap allocations to 2GB regions in comp ptr mode"
Fixed the mac build.

This reverts commit 0ed3fb3dee.

Bug: https://github.com/dart-lang/sdk/issues/45059
Change-Id: I0cd6710a641b195403dda717108bdbe3395a21fa
TEST=CI
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/186340
Commit-Queue: Liam Appelbe <liama@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2021-02-22 19:58:49 +00:00
Johnni Winther 79de274398 Revert "[cfe] Encode field references as @getters and @setters"
This reverts commit 3892e95547.

Reason for revert: Breaks Flutter web

Original change's description:
> [cfe] Encode field references as @getters and @setters
>
> This removes the @fields and @=fields canonical name
> encodings that allowed for encoding of conflicting members
> and didn't support field<->getter/setter conversion
> between dills or between outline and full dill.
>
> TEST=existing tests
>
> Change-Id: Id15e58ad4d1847d2c98a688705e5945196146c6d
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/184783
> Commit-Queue: Johnni Winther <johnniwinther@google.com>
> Reviewed-by: Jens Johansen <jensj@google.com>
> Reviewed-by: Alexander Markov <alexmarkov@google.com>

Change-Id: I744e284b16e097fa0833c5bdf1bc7653f13bdf63
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/186147
Reviewed-by: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2021-02-22 12:56:43 +00:00
Alexander Markov ddfc98337b Reland "[vm/aot] Avoid using most Code objects in stack traces with --dwarf-stack-traces"
This is a reland of b6dc4dad4d

TEST=ci

Original change's description:
> [vm/aot] Avoid using most Code objects in stack traces with --dwarf-stack-traces
>
> The following changes are done in preparation for the removal of Code
> objects in AOT with --dwarf-stack-traces:
>
> * Stack trace objects are extended to hold uword PCs (which may not
>   fit into Smi range).
>
> * Scanning stack frames in GC (StackFrame::VisitObjectPointers)
>   now avoids using Code objects.
>   In order to find CompressedStackMaps it now calls
>   ReversePc::FindCompressedStackMaps.
>
> * Singleton Code object (StubCode::UnknownDartCode()) is prepared as
>   a replacement for Code objects in stack traces. It has
>   PayloadStart() == 0 and Size() == kUwordMax so it includes
>   arbitrary PCs.
>
> * In --dwarf-stack-traces mode, most Code objects obtained from stack
>   frames are replaced with StubCode::UnknownDartCode().
>   This simulates future behavior of ReversePc::Lookup when Code objects
>   will be removed.
>
> Issue: https://github.com/dart-lang/sdk/issues/44852
> Change-Id: I7cec7b8b9396c9cfeca3c256a412ba4e82a7e0c4
> TEST=ci
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/182720
> Commit-Queue: Alexander Markov <alexmarkov@google.com>
> Reviewed-by: Tess Strickland <sstrickl@google.com>
> Reviewed-by: Martin Kustermann <kustermann@google.com>

Change-Id: Ia2fc4672a085cd963b7fc103369851df3603590c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/186202
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Tess Strickland <sstrickl@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2021-02-22 10:46:28 +00:00
Daco Harkes bad5cc26c7 [vm/ffi] Support packed Structs backend
With packed structs, the x64 non-Windows ABI only put structs in CPU/FPU
registers when all it fields happen to be aligned.

This CL introduces the `NativeType::ContainsUnalignedMembers` query
for calling convention calculations.

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

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
These tests are exercised on vm-precomp-ffi-qemu-linux-release-arm-try.

Change-Id: I504f67ae22a6af375d5eb57ff26b58d340099df8
Cq-Include-Trybots: luci.dart.try:vm-precomp-ffi-qemu-linux-release-arm-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/186142
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Clement Skau <cskau@google.com>
2021-02-22 10:12:38 +00:00
Tess Strickland 348c704b25 [vm] Add heap sizes to --print-snapshot-sizes output.
TEST=Tested manually with the flag.

Bug: https://github.com/dart-lang/sdk/issues/44005
Change-Id: I553f88b2552b693801793203cffc33e096143023
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/185801
Commit-Queue: Tess Strickland <sstrickl@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2021-02-22 09:59:30 +00:00
Johnni Winther 3892e95547 [cfe] Encode field references as @getters and @setters
This removes the @fields and @=fields canonical name
encodings that allowed for encoding of conflicting members
and didn't support field<->getter/setter conversion
between dills or between outline and full dill.

TEST=existing tests

Change-Id: Id15e58ad4d1847d2c98a688705e5945196146c6d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/184783
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2021-02-22 09:46:18 +00:00
Vyacheslav Egorov d499f68df5 [vm] Fix vm_snapshot_analysis logic and tests
* When looking for Code node owner simply always check for synthetic
  owner (referenced through ':owner_' property) first. If it is present
  then it means 'owner_' property is invalid anyway. 25fd0200ef changed
  how WSRs are written into snapshot (instead of writing WSRs we are
  simply writing SMI CIDs) which broke previous logic.
* When building ProgramInfoNode for a Class node accommodate for the
  existence of classes which don't have 'library_' property (e.g. base
  objects like void and dynamic). Additionally, adjust how these base
  objects are written into the snapshot profile so that we preserve
  their names.
* Tweak tests diff and diff-collapse tests to pass, they were failing
  because prologue removal compiler change made some of the diffs so
  tiny that they are ignored by threshold filtering.
* Add two more tests: one that verifies that tracings flags don't have
  any impact on the snapshot size and one that checks we correct
  attribute instructions size to the function node from which these
  instructions originated. This last test is added in anticipation of
  Code object removal to make sure that vm_snapshot_analysis continues
  to work correctly.
* Adjust sorting rules for Code cluster to make it more stable between
  slightly different programs to stabilize output of
  --print-instructions-sizes-to (depends on the sorting algorithm used
  in libc, the test was failing on Mac but not on Linux).

These fixes should unblock relanding of b6dc4dad4d

Fixes #44507
Fixes flutter/flutter#76313

TEST=pkg/vm_snapshot_analysis/test/instruction_sizes_test.dart

Cq-Include-Trybots: luci.dart.try:pkg-linux-release-try,pkg-win-release-try,pkg-mac-release-try
Change-Id: Iee0221dd3a507cb4f36d530404693ebfab3b7bf2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/185826
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2021-02-21 15:48:27 +00:00
Vyacheslav Egorov 0ed3fb3dee Revert "[vm] Align heap allocations to 2GB regions in comp ptr mode"
This reverts commit d10d17cca2.

Reason for revert: Broke Mac builds

Original change's description:
> [vm] Align heap allocations to 2GB regions in comp ptr mode
>
> This only handles the POSIX case. The Windows case will work exactly the
> same as this, so I want to get this reviewed before I start porting it
> to windows.
>
> TEST=Manual testing. I'll update the unit tests once it's ported.
>
> Bug: https://github.com/dart-lang/sdk/issues/45059
> Change-Id: I0bc0eddd95101fc2fddfe5668488670e741af586
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/183142
> Reviewed-by: Ryan Macnak <rmacnak@google.com>
> Commit-Queue: Liam Appelbe <liama@google.com>

Bug: https://github.com/dart-lang/sdk/issues/45059
Change-Id: I840c31ead015f60bca32b551c8f8d31fa75ad645
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/186101
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2021-02-21 15:25:03 +00:00
Liam Appelbe d10d17cca2 [vm] Align heap allocations to 2GB regions in comp ptr mode
This only handles the POSIX case. The Windows case will work exactly the
same as this, so I want to get this reviewed before I start porting it
to windows.

TEST=Manual testing. I'll update the unit tests once it's ported.

Bug: https://github.com/dart-lang/sdk/issues/45059
Change-Id: I0bc0eddd95101fc2fddfe5668488670e741af586
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/183142
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Liam Appelbe <liama@google.com>
2021-02-20 01:29:35 +00:00
Ryan Macnak d0707f6695 [vm, compiler] Remove one branch from the array allocation stubs.
TEST=ci
Change-Id: Id95988ff233af9a754d419cd5be8750b3af31315
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/185700
Reviewed-by: Liam Appelbe <liama@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2021-02-19 22:08:15 +00:00
Ben Konyi b563a592ca [ package:vm_service ] Fix documentation not appearing on pub, update CHANGELOG for 6.1.0
TEST=N/A

Change-Id: Ic585afc5a74701cd9a787319e4dad8b2ec12b748
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/185900
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Gary Roumanis <grouma@google.com>
2021-02-19 21:35:45 +00:00
Dmitry Stefantsov 32fe29617e [cfe] Remove line enabling 'extension-types' flag
TEST=The flag is updated according to the documented recommendations.

Change-Id: I0997b29eafc40844b6ab6dc089ad91723071d4e5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/185880
Commit-Queue: Dmitry Stefantsov <dmitryas@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2021-02-19 17:43:17 +00:00
Ryan Macnak 109d963bf9 [vm] Use 31-bit Smis in compressed pointer mode.
The range of Smis must be reduced so that pointer compression is not lossy.

Smis are kept in sign-extended form. In the future, we might track down all places that perform Smi comparisons or otherwise assume sign-extension. Allowing garbage in the upper half would make it safe to unconditionally add the heap base during pointer decompression.

Based on cf78da8a48.

TEST=ci
Change-Id: If8c76da3166c170618e5b3f3991353bab5c84e6f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/181760
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Liam Appelbe <liama@google.com>
2021-02-18 20:40:20 +00:00
Alexander Markov fde0ed2e93 Revert "[vm/aot] Avoid using most Code objects in stack traces with --dwarf-stack-traces"
This reverts commit b6dc4dad4d.

Reason for revert: broke package:vm_snapshot_analysis in Flutter
(https://github.com/flutter/flutter/issues/76313).

Original change's description:
> [vm/aot] Avoid using most Code objects in stack traces with --dwarf-stack-traces
>
> The following changes are done in preparation for the removal of Code
> objects in AOT with --dwarf-stack-traces:
>
> * Stack trace objects are extended to hold uword PCs (which may not
>   fit into Smi range).
>
> * Scanning stack frames in GC (StackFrame::VisitObjectPointers)
>   now avoids using Code objects.
>   In order to find CompressedStackMaps it now calls
>   ReversePc::FindCompressedStackMaps.
>
> * Singleton Code object (StubCode::UnknownDartCode()) is prepared as
>   a replacement for Code objects in stack traces. It has
>   PayloadStart() == 0 and Size() == kUwordMax so it includes
>   arbitrary PCs.
>
> * In --dwarf-stack-traces mode, most Code objects obtained from stack
>   frames are replaced with StubCode::UnknownDartCode().
>   This simulates future behavior of ReversePc::Lookup when Code objects
>   will be removed.
>
> Issue: https://github.com/dart-lang/sdk/issues/44852
> Change-Id: I7cec7b8b9396c9cfeca3c256a412ba4e82a7e0c4
> TEST=ci
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/182720
> Commit-Queue: Alexander Markov <alexmarkov@google.com>
> Reviewed-by: Tess Strickland <sstrickl@google.com>
> Reviewed-by: Martin Kustermann <kustermann@google.com>

Issue: https://github.com/dart-lang/sdk/issues/44852
Change-Id: I6f66171eecf1133363a7ce56193e782e43a20baf
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/185488
Reviewed-by: Zach Anderson <zra@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2021-02-18 18:04:29 +00:00
Ryan Macnak 2905d0835e [vm, arm64] Reserve a register for pointer decompression.
TEST=ci
Change-Id: I661cffec3de58fbbba70e13e9b4ad612574f494b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/185200
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Liam Appelbe <liama@google.com>
2021-02-18 17:47:37 +00:00
Alexander Aprelev cb129b71a7 [vm/concurrency] Skip installation of unoptimized code if it's already installed.
In presence of multiple mutators in one isolate group, same function might be unoptimized-compiled by more than one mutator. Avoid reinstallation of newly compiled unoptimized code if that happens. Unoptimized compilation itself is not that expensive, so we don't prevent multiple mutators to do actual compilation of the same function.

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

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

TEST=standalone_2\io\http_basic_test.dart on windows

Change-Id: I0fbd62e8f8299a5d8289a6689da157a691715b81
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/185460
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2021-02-18 17:16:17 +00:00
Filip Filmar 9f68048cae [vm] Replaces fuchsia.deprecatedtimezone
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.
Thus setting the stage for the removal of `fuchsia.deprecatedtimezone`.

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

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

```
dart.cmx:
  metadata:
    filename = fuchsia.inspect.Tree
    component_url = fuchsia-pkg://fuchsia.com/dart_test_debug#meta/dart.cmx
    timestamp = 12241877209826
  payload:
    root:
      os:
        dst_status = 1
        get_profile_status = 0
        num_get_profile_calls = 1
        num_intl_provider_errors = 0
        num_on_change_calls = 0
        timezone_content_status = 0
        tz_data_close_status = -1
        tz_data_status = -1
```

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

Tested:

1. (compile locally for Fuchsia and deploy)

  ```
  fx test //src/tests/intl
  ```

  This runs the specific timezone tests that should break if the
  functionality itself is broken.

2. Compile dart for Fuchsia and run tests:

   The instructions are here: https://github.com/dart-lang/sdk/commit/15dfcca89f0d7eabd60ff049444e203a82dbcb1e

   I used the instructions above to build and run all tests from
   `dart_test_debug` package.  The tests were ran against the main
   branch (and then, the tests that failed there were filtered out),
   then the remaining tests were ran against a Dart version that
   contains this change.

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

Prior attempts (most recent first):

- rolled back as it... didn't compile.  It turned out, when building the
  change with flutter the compilation process has some different
  settings, so the compilation of the change worked in flutter, but
  didn't in dart.  The compilation error is now fixed, and I ran
  additional tests: https://dart-review.googlesource.com/c/sdk/+/155582

- 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

Fixes #39650

TEST=See "Tested" section above.
Change-Id: Idd78ea42e3ae38dca2ab4c4126e930e53ef8a793
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/185302
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2021-02-18 07:38:04 +00:00
Martin Kustermann 2e2d542969 [vm/concurrency] Use isolate group id as key for incremental compiler for reload
As part of implementing hot-reload for isolate groups, we have to ensure
reloads on a group are performed using the same state of incremental
compiler.

This means we cannot use a specific isolate's information (such as it's
main port) for reloading purposes. Instead we use the unqiue isolate
group id when communicating with the kernel service.

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

TEST=Existing test coverage, future test when hot-reload is fully
     implemented with isolate groups.

Change-Id: Ifab39cd2ba689c08507dfab4091cd26951ed54e5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/185320
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2021-02-18 06:59:24 +00:00
Alexander Markov b6dc4dad4d [vm/aot] Avoid using most Code objects in stack traces with --dwarf-stack-traces
The following changes are done in preparation for the removal of Code
objects in AOT with --dwarf-stack-traces:

* Stack trace objects are extended to hold uword PCs (which may not
  fit into Smi range).

* Scanning stack frames in GC (StackFrame::VisitObjectPointers)
  now avoids using Code objects.
  In order to find CompressedStackMaps it now calls
  ReversePc::FindCompressedStackMaps.

* Singleton Code object (StubCode::UnknownDartCode()) is prepared as
  a replacement for Code objects in stack traces. It has
  PayloadStart() == 0 and Size() == kUwordMax so it includes
  arbitrary PCs.

* In --dwarf-stack-traces mode, most Code objects obtained from stack
  frames are replaced with StubCode::UnknownDartCode().
  This simulates future behavior of ReversePc::Lookup when Code objects
  will be removed.

Issue: https://github.com/dart-lang/sdk/issues/44852
Change-Id: I7cec7b8b9396c9cfeca3c256a412ba4e82a7e0c4
TEST=ci
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/182720
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Tess Strickland <sstrickl@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2021-02-17 20:12:32 +00:00
Dmitry Stefantsov 3a79baed23 [cfe] Add 'extension-types' experimental flag
TEST=The flag is added as per recommended instructions.

Change-Id: I7135fa772e884d083f7388741bc2b3c3a4e6f0e7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/185360
Commit-Queue: Dmitry Stefantsov <dmitryas@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2021-02-17 14:08:15 +00:00
Daco Harkes e5732b1886 [vm/ffi] Remove VM sizeOf runtime entry
After changing `elementAt` and `sizeOf` to only accept static types
(https://dart-review.googlesource.com/c/sdk/+/178200) and rewrite all
the calls with static types in the CFE
(https://dart-review.googlesource.com/c/sdk/+/182262), the runtime entry
can now be removed.

One less place where the runtime relies on `Struct` subtypes not being
tree shaken.
Issue: https://github.com/dart-lang/sdk/issues/38721

Because we're no longer using `NativeType`s in a RTE to calculate their
size, these do no longer need to be available in the precompiled
runtime.
Closes: https://github.com/dart-lang/sdk/issues/42809

TEST=tests/ffi(_2)/*

Change-Id: I8682a3bb4d2dc3ee71531cf71909e47489e96f12
Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-nnbd-linux-debug-x64-try,vm-precomp-ffi-qemu-linux-release-arm-try,vm-ffi-android-debug-arm64-try,vm-ffi-android-debug-arm-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/185085
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Clement Skau <cskau@google.com>
2021-02-17 11:39:42 +00:00