Commit graph

19582 commits

Author SHA1 Message Date
Ryan Macnak f7c7076fe8 [vm, compiler] Fix annotating pool references in gen_snapshot.
This was broken by the move to the global object pool.

TEST=--disassemble
Change-Id: I2cbff1e2fa1a56d8d4d98d447a5726c0764e1a0e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/244460
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-05-11 19:52:45 +00:00
Ryan Macnak 47db18a2da [vm] Fix default log filtering to include the vm-service.
This was probably broken by some refactoring related to isolate groups.

TEST=--disassemble-stubs
Change-Id: If46259836d2276d50fefc5598f8370bf935ec95e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/244481
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2022-05-11 19:31:04 +00:00
Alexander Aprelev 1e5d063b21 [vm/sim/simd] Fix vmin/vmax implementation on simulator.
minss/maxss used by simulator 0.0==-0.0, which is inconsistent with arm native instructions.

Fixes https://github.com/dart-lang/sdk/issues/48988
Addresses https://github.com/dart-lang/sdk/issues/40426
TEST=ci

Change-Id: I9d88d89e342bb543b1e90fdbe3c7aa8303353dab
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/244320
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2022-05-11 16:59:24 +00:00
Clement Skau 4258a59789 [vm][ffi] Passes FFI handles on stack.
Passing handles in FFI calls has significant overhead due to
how each handle requires a runtime entry to allocate in the
handle scope.

This change removes that runtime entry by relying on the
register allocator to allocate all handle arguments on the stack,
so that we don't need to allocate them separately.
To pass the stack handles to the native call we then pass a pointer
to the stack slot as the native argument.

Testing:
- We already have comprehensive tests for correctness in the form
  of the FFI tests. These make calls with various combinations of
  Handle and non-handle arguments.
- Correct GC behaviour is likewise covered in
  `vmspecific_handle_test.dart` which makes calls with handles
  arguments and triggers GC in-flight.
  In case we do not correctly pass the handles on the stack, the
  GC will trash them during the call.

TEST=Existing.
Bug: https://github.com/dart-lang/sdk/issues/47624
Change-Id: Ic837bad5484daaa5534b7c2e8707ac2c5dfa480f
Cq-Include-Trybots: luci.dart.try:vm-kernel-gcc-linux-try,vm-kernel-linux-debug-simriscv64-try,vm-kernel-nnbd-mac-release-arm64-try,vm-kernel-precomp-android-release-arm64c-try,vm-kernel-precomp-android-release-arm_x64-try,vm-kernel-precomp-dwarf-linux-product-x64-try,vm-kernel-precomp-linux-debug-simarm_x64-try,vm-kernel-precomp-linux-debug-simriscv64-try,vm-precomp-ffi-qemu-linux-release-arm-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/243320
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Clement Skau <cskau@google.com>
2022-05-11 06:43:14 +00:00
Ryan Macnak 4ee35ee998 [vm, compiler] Load unboxed doubles directly from the literal pool.
TEST=ci
Change-Id: I4f881bc3e29059bce09eb0aa0ba99928e7fb10a8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/244120
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-05-10 21:31:40 +00:00
Liam Appelbe a8a29cffbb [ VM / Service ] Add libraryFilters to getSourceReport RPC
Bug: https://github.com/dart-lang/sdk/issues/48754
Change-Id: I42519d7dd751aa024860f940cbf51d2e38f7ea69
Tested: CI and new integration test
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/241180
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Liam Appelbe <liama@google.com>
2022-05-10 18:08:43 +00:00
Ryan Macnak 3c01efcbb0 Reland "[build] Fix Android build for ARM64 Mac."
Account for simarm_x64 in TargetCpuForArch.

TEST=local
Bug: https://github.com/dart-lang/sdk/issues/48792
Change-Id: I820cb49ee8925c50196cb2472266f9e248c9089d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/243642
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-05-10 16:11:53 +00:00
Alexander Aprelev 2a12dd3315 [vm/simd] Add Float64x2 clamp simd implementation
Fixes https://github.com/dart-lang/sdk/issues/40427

TEST=ci, float64x2_clamp_test

Change-Id: I12618c37135feecffb115ce4aca02af1ecb03167
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/243848
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2022-05-10 04:56:25 +00:00
asiva 96d59fe998 [VM/io] - Add missing native entry to enable resolution.
TEST=ci

Change-Id: Ie293903d1fe637f05e3e70926ae4fa648e752a22
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/243886
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
2022-05-09 16:24:02 +00:00
Ben Konyi 4d77e3e645 [ VM ] Ensure TypeArguments register is preserved when regenerating allocation stubs for parameterized classes
Fixes https://github.com/flutter/flutter/issues/88104

TEST=pkg/vm_service/test/regress_88104_test.dart

Change-Id: I87affc62189bc076cf6e46c47e76f4fb005f9068
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/243850
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2022-05-06 12:57:44 +00:00
Daco Harkes efa7439c16 Revert "[vm] Only call .hashCode once when adding to Map and Set"
This reverts commit 438c1ed2ba.

Reason for revert: b/231617607 and b/230945329.
Will reland after b/230945329 is addressed.

Original change's description:
> [vm] Only call `.hashCode` once when adding to `Map` and `Set`
>
> The methods to add to hash maps and hash sets are recursive: if the
> index needs to be rehashed then the same method is called again after
> rehashing.
>
> This CL nests the actual implementation in a private method that takes
> the full hashCode as an extra argument.
>
> No significant code size or run time changes are reported on our
> benchmarks. (Our benchmarks do not contain purposefully slow hashCodes.)
>
> Note that hashCode can be called again later if rehashing of the index
> is required on adding subsequent elements.
>
> Bug: https://github.com/dart-lang/sdk/issues/48948
> Change-Id: Ia3ccff9e592d675b4922ac78c4aa7ee0287ecb50
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/243623
> Reviewed-by: Martin Kustermann <kustermann@google.com>
> Commit-Queue: Daco Harkes <dacoharkes@google.com>

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

Change-Id: I214251b65ea89e7f729564a125e226f2e6d580c0
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: https://github.com/dart-lang/sdk/issues/48948
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/243900
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
2022-05-06 10:24:29 +00:00
asiva d856e058ea [VM/Runtime] Inline first zone in a StackZone when we are not using
fibers.

TEST=ci

Change-Id: I1308b2450d77ac83c89208acb7d18ad1be5bdcbf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/243856
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
2022-05-05 23:20:25 +00:00
Ryan Macnak df21baa407 [vm, compiler] Use shorter sequences for load/store with larger offsets on ARM64.
flutter_gallery
Instructions(CodeSize): 4634496 -> 4629408 (-0.11%)
       Total(CodeSize): 7312019 -> 7306931 (-0.07%)

TEST=ci
Change-Id: Iae104eb7da82590dee2bc2018905f51efe344597
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/243382
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-05-05 22:37:26 +00:00
Ryan Macnak 322410e5cd [vm] Function::packed_fields is not used in AOT.
flutter_gallery
Isolate(CodeSize): 2199986 -> 2181807 (-0.83%)
  Total(CodeSize): 7312019 -> 7293839 (-0.25%)

TEST=ci
Change-Id: I5f71df4f0020b7702162fd44b5c0f1a9ce4c143f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/243563
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2022-05-05 22:36:56 +00:00
asiva d437877c50 [VM/Runtime] - Ensure ReusableObjectHandleScope is not active when
Errors are reported from the Dart C API implementation.

TEST=ci

Fixed: 48951
Change-Id: I954d8ef3a6b148e45335cc7c264eb542ae10bc7f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/243842
Commit-Queue: Siva Annamalai <asiva@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2022-05-05 22:15:45 +00:00
Ryan Macnak 2cf4bf72a8 [vm, compiler] Handle large offsets with double spill slots on RISC-V.
Fix non-existent addressing mode in ARM fpu spilling.

TEST=ci
Change-Id: I0ecb973059a6cab11dce5b87137b54e0d1ac5ac5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/243703
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2022-05-05 22:11:17 +00:00
Alexander Aprelev 5898dcd1ad [vm/aot] Trim user-defined entries from classes constants table.
Fixes https://github.com/dart-lang/sdk/issues/48928

flutter_gallery_isolate_size -1.970% (armv7), -1.204% (armv8)

TEST=ci

Change-Id: I6d2765d1e69c39bc6189eaf05e83b1fbf334fdcd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/243709
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2022-05-05 19:29:35 +00:00
Daco Harkes 438c1ed2ba [vm] Only call .hashCode once when adding to Map and Set
The methods to add to hash maps and hash sets are recursive: if the
index needs to be rehashed then the same method is called again after
rehashing.

This CL nests the actual implementation in a private method that takes
the full hashCode as an extra argument.

No significant code size or run time changes are reported on our
benchmarks. (Our benchmarks do not contain purposefully slow hashCodes.)

Note that hashCode can be called again later if rehashing of the index
is required on adding subsequent elements.

Bug: https://github.com/dart-lang/sdk/issues/48948
Change-Id: Ia3ccff9e592d675b4922ac78c4aa7ee0287ecb50
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/243623
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2022-05-05 11:48:35 +00:00
Alexander Markov c3e0d770dd [vm] Introduce FUNCTION_REG constant
This refactoring introduces FUNCTION_REG constant for a register
containing target function object when calling Dart functions in JIT
mode. This register is similar to CODE_REG and ARGS_DESC_REG
registers which are also a part of Dart calling conventions.

Hardcoded registers are replaced with new constant where
appropriate. Also, ARGS_DESC_REG and IC_DATA_REG are used instead of
hardcoded registers in more places.

TEST=ci (pure refactoring)

Change-Id: I9e71022d7bca8d4e555b9e4f22558f388073495f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/243681
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2022-05-04 22:59:24 +00:00
Daco Harkes 78f218eb4c [vm] Flush thread store buffer block after processing finalizers
`MournFinalized` runs during marking and can add objects to the store
buffer. These objects are stored in the threads' store buffer block.
This block needs to be released to the central store buffer in order for
the objects' addresses to be updated during compacting.

TEST=runtime/vm/object_test.cc
TEST=tools/test.py vm/cc/Finalizer_Regress_48843

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

Change-Id: Ib2424929c86fee730d3f09fbd2f9f6c97f31abfd
Cq-Include-Trybots: luci.dart.try:vm-canary-linux-debug-try,vm-kernel-linux-debug-x64-try,vm-kernel-linux-debug-x64c-try,vm-kernel-mac-debug-x64-try,vm-kernel-win-debug-x64-try,vm-kernel-linux-release-x64-try,vm-kernel-linux-product-x64-try,vm-kernel-linux-debug-ia32-try,vm-kernel-linux-release-ia32-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/243262
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2022-05-04 20:53:15 +00:00
Ryan Macnak caf220432f [vm] Add flag to investigate array serialization optimizations.
TEST=--print_array_optimization_candidates
Bug: https://github.com/dart-lang/sdk/issues/48910
Change-Id: I6e5031ce9cca4128b8fb75dd5c9e43ad57e7013c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/243527
Reviewed-by: Dan Field <dnfield@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-05-04 18:04:04 +00:00
Martin Kustermann fe50796c6f [gardening] Remove standalone{,_2}/io/raw_datagram_socket_test from iso-stress builder
The test shows up as flaky when running in parallel on the
"iso-stress" builder and as such is not needed to test concurrency in
the VM, so we'll remove it.

The test fails with
```
FutureExpect.throws received Instance of '_RawDatagramSocket' instead of an exception
#0      FutureExpect.throws.<anonymous closure>
#1      _rootRunUnary
#2      _CustomZone.runUnary
<asynchronous suspension>
#3      FutureExpect.throws.<anonymous closure>
<asynchronous suspension>
```

TEST=Should get "iso-stress" builder geen.

Change-Id: Iad79851bda5c8eb75b2387df296b357e3884c822
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/243622
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2022-05-04 14:29:34 +00:00
Ben Konyi 4d21c01e63 [ Timeline ] Fix ASAN failures due to timeline recorder not being freed
A recent fix for a use-after-free crash created a memory leak due to
Timeline::Clear() returning immediately as the timeline had already
entered its shutdown state. This change adds a new helper function to
bypass the shutting down check in Timeline::Clear(), allowing for the
recorder to be properly cleaned up.

TEST=CQ, local testing

Change-Id: Id2ea3992ea4c4544a2c1cf82b74ea6c3882fa670
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/243480
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2022-05-03 15:38:34 +00:00
Ryan Macnak 706e62a1bf [vm] Canonicalize empty Class::interfaces_.
TEST=ci
Change-Id: I921eb1796b5e142aba8a8f8649a0105ef0e396e4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/243380
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2022-05-02 23:44:46 +00:00
Alexander Markov c9840a024f [vm] Introduce Assembler::PushRegistersInOrder to generate series of register pushes more efficiently
(Macro-)assembler helper PushRegistersInOrder generates series of
register pushes in an architecture-specific way:
 * Using STMDB on ARM (if possible).
 * Using STP on ARM64.
 * Updating SP only once on RISC-V.

TEST=ci

Change-Id: I6cbd1dd5f8acf8ce8087ed899a311264a873ad37
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/243100
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2022-05-02 22:34:19 +00:00
Alexander Markov 4075e8b3f9 [vm] New async*/yield/yield* implementation based on suspend/resume stubs
TEST=ci
Issue: https://github.com/dart-lang/sdk/issues/48378
Change-Id: I0c2ca9269b2c8f008a79c139a0ce10231996732d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/242923
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2022-05-02 20:53:01 +00:00
Ryan Macnak 49c039b5ab [vm] Remove the branch from pointer decompression in the runtime.
In particular, this removes the branch from Deserializer::Ref.

Startup.ReadProgramSnapshot(StartupTime): on a Moto x4
  arm64c 46063 -> 44714 us (-2.93%)

TEST=ci
Change-Id: I1cdd6e8b36ad695f15552ebea0f3fc726b467863
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/242500
Reviewed-by: Liam Appelbe <liama@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-05-02 19:25:12 +00:00
Alexander Markov 0a2d611d39 [vm] Verify that frame size doesn't change between awaits (in AOT mode)
TEST=ci

Issue: https://github.com/dart-lang/sdk/issues/48378
Change-Id: I05e1a55070d77fea4402a9db56fca5b3be7207b5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/243042
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2022-05-02 14:15:51 +00:00
Ben Konyi b1e453e069 [ Timeline ] Fix use-after-free error at shutdown when using endless timeline recorder
Timeline::Clear() results in the linked list of events being destroyed
when using the endless timeline recorder. This call was not protected by
RecorderLock::WaitForShutdown() and could result in an event being
allocated after the recorder's list of events had been destroyed.

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

TEST=CQ

Change-Id: I7e3de2bc99535a560321159ded70aef3e8686526
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/243140
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2022-05-02 12:51:20 +00:00
Martin Kustermann a9c1cb60d1 [gardening] Mark stacktrace-asserting tests as SkipByDesign in obfuscated/non-symbolic-dwarf mode
Issue https://github.com/dart-lang/sdk/issues/48907

TEST=Updates status file.

Change-Id: I4a80611fdd91eb44f082d429553ecc778fb407cf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/242866
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2022-04-29 09:57:41 +00:00
Alexander Markov bf4bb95308 [vm] New async/await implementation in the VM, part 2 - vm
The new implementation moves away from desugaring of async
functions on kernel AST, state machine generated in the flow graph and
capturing all local variables in the context.

Instead, async/await is implemented using a few stubs
(InitSuspendableFunction, Suspend, Resume, Return and
AsyncExceptionHandler). The stubs are implemented in a
platform-independent way using (macro-)assembler helpers.
When suspending a function, its frame is copied into a SuspendState
object, and when resuming a function it is copied back onto the stack.
No extra code is generated for accessing local variables.
Callback closures are created lazily on the first await.

Design doc: go/compact-async-await.

Part 1 (kernel): https://dart-review.googlesource.com/c/sdk/+/241842

TEST=ci

Issue: https://github.com/dart-lang/sdk/issues/48378
Change-Id: Ibad757035b7cc438ebdff80b460728b1d3eff1f5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/242000
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2022-04-29 01:03:50 +00:00
Ryan Macnak fcc9169885 [vm, gc] Appease TSAN around racy access to IsolateGroup::active_mutators_.
Isolate may be entering or leaving the group while a scavenge is running and using the active mutator count to decide the size of the next to-space. A stale value seen by the scavenger only has performance implications rather than correctness implications, which will get fixed at the next scavenge.

TEST=iso-stress-linux
Bug: https://github.com/dart-lang/sdk/issues/48921
Change-Id: I171e5a460eadba3db6659dccda29c863549d27ea
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/242925
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-04-28 23:27:20 +00:00
Ryan Macnak 72c153b930 [vm] Keep snapshot cursor etc in registers during ReadFill.
Startup.ReadProgramSnapshot(StartupTime): on a Moto x4
  arm32  37510 -> 35212 us (-6.13%)
  arm64c 45080 -> 42634 us (-5.42%)

TEST=ci
Change-Id: Ie97cf8cc1bd48a7ace16baded48d656224c5252b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/242921
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-04-28 22:21:40 +00:00
Vyacheslav Egorov dff2bce0b8 [vm] Avoid sentinel entry at the end of invocation_dispatcher_cache.
No code actually relies on it being there.

This saves ~1kb of snapshot size on a large Flutter application.

Related to https://github.com/dart-lang/sdk/issues/48910

TEST=ci

Change-Id: I03cf8811f39fc8882f7c650a79f01d350b520e5d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/242863
Commit-Queue: Slava Egorov <vegorov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2022-04-28 21:45:00 +00:00
Vyacheslav Egorov bd950da0a8 [vm] Avoid duplicate entries in invocation dispatcher cache.
We would add function itself to the invocation dispatcher cache
if the function itself can handle dynamic invocation.

However GetInvocationDispatcher will never be able to find this
entry because it looks specifically for functions with
kDynamicInvocationForwarder kind.

This lead us to add many duplicated entries to the cache.

The logic in the resolver does not actually need the cache to contain
the function because it falls through to lookup using unmangled name.

For a large Flutter application: before this change invocation dispatcher caches were contributing 129244 bytes to the snapshot, after this change they contribute 7764 bytes.

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

TEST=ci

Change-Id: I639d268e75fd43d2f4f0b1ea5a7873ba169f9d66
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/242862
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2022-04-28 21:43:10 +00:00
Ryan Macnak 3458b041df [vm] Avoid querying clocks for timeline recorders that don't take the timestamps as input.
TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/48900
Change-Id: Idb689b07a8da1655535798bcd223460818a84c57
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/242640
Reviewed-by: Dan Field <dnfield@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-04-28 21:16:01 +00:00
Vyacheslav Egorov 6f24cbcb5c [vm] Drop Library::used_scripts in PRODUCT AOT mode.
This field is only used only by vm-service (including
hot reload and debugging), Kernel loading and mirrors.

So drop it to prevent putting it into the AOT snapshot.

Saves at 125Kb of snapshot size on large Flutter app.

Related to https://github.com/dart-lang/sdk/issues/48910

TEST=ci

Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-dwarf-linux-product-x64-try,vm-kernel-precomp-linux-product-x64-try
Change-Id: Id7c47496e87482d462c2b318307f617d48758ad1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/242864
Commit-Queue: Slava Egorov <vegorov@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2022-04-28 20:45:40 +00:00
Ahmed Ashour 1586ac81a0 Fix typos
TEST=comment only change

Fixes #48853

Change-Id: I1fd47b8f186514af95a49ef253170045c584f970
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/241963
Reviewed-by: Lasse Nielsen <lrn@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
2022-04-28 12:53:43 +00:00
Alexander Markov 609ba96115 [vm] Fix assertion failure during class finalization
TEST=vm/dart/regress_48323_1_test

Issue: https://github.com/dart-lang/sdk/issues/48323
Change-Id: I50c04a269183c0df5b4ce0ce7be32cd2385e95d8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/242601
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2022-04-27 19:19:54 +00:00
Ryan Macnak ad4126bba4 [vm, compiler] Use more compressed instructions on RISC-V.
dart2js.aot.rv64 25290024 -> 25042040 (-0.98%)
dart2js.aot.rv32 24466620 -> 24000012 (-1.91%)

TEST=ci
Change-Id: I0b60d0c3bd8df036426898e00cf650b398abb397
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/242065
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2022-04-27 17:11:35 +00:00
Ryan Macnak 5748add35c [vm] Use a big-endian encoding for snapshot ref ids.
When unconditionally adding in each byte, this causes the last-byte marker to appear in a constant position. The correction factor for each exit branch is the same, allowing it to be folded into subsequent load offsets.

Startup.ReadProgramSnapshot(StartupTime): on a Moto x4
  arm32  40456 -> 37414 us (-7.52%)
  arm64c 46012 -> 44457 us (-3.38%)

TEST=ci
Change-Id: Ie7fd69504f9d9edf0c17458281a3750931d7d97b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/242392
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-04-27 16:08:19 +00:00
Vyacheslav Egorov df29275537 [vm/aot] Strip google3 scheme in --resolve_dwarf_paths
This makes some internal tools work better with our DWARF information.

TEST=tested manually internally

Bug: b/230585082
Change-Id: I7223ff368dc75b4f45eecee8478f29816670051c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/242560
Reviewed-by: Tess Strickland <sstrickl@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2022-04-27 13:07:21 +00:00
Martin Kustermann b85679eaf3 [vm] Avoid runtime call in common type literal "T" case
Right now all type literal usages will perform a runtime call which is
rather slow.

Flutter happens to use type literals such as `return T;` in hot code
which causes this to show up in the profile.

This CL adds fast paths for type parameter type literals if
the type parameter value (i.e. entry of TAV corresponding to T):

    * is `null`: return `dynamic`
    * is a non-FutureOr [Type] with compatible nullability: return value
    * is [FunctionType] with compatible nullability: return value

otherwise fall back to runtime call.

It makes simple type literal uses 10x+ faster - the kinds that Flutter
is using.

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

TEST=vm/dart{,_2}/instantiate_type_literal_test

Change-Id: I1139d6689aedbc68321f47ee6c9946a3323fbf6e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/241968
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2022-04-27 10:26:25 +00:00
Ryan Macnak 57f68b377a [vm, gc] Don't round Scavenger::UsedInWords up to the nearest TLAB.
Rounding usage up to the TLAB causes excessive growth because it gives the growth policy a very inflated view of the survivor ratio.

Ensure new-space grows specifically to provide enough TLABs for active mutators.

TEST=golem
Change-Id: Iab01df18c6a8ac996e0f0b2707c9da7e14c7f4a4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/241689
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-04-26 23:35:54 +00:00
Ryan Macnak 19a59df399 [vm, compiler] Unroll object initialized to the allocation unit.
1/2 or 1/4 branches executed per object initialization for uncompressed and compressed pointers respectively.

Note ARM32 already has double-wide initialization.

TEST=ci
Change-Id: Iacc61cac39f74191bb2e5e06cd48b90c006b8585
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/241622
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-04-26 21:49:34 +00:00
Martin Kustermann efdffab8b7 Reland "[vm] Fix some async* semantics issues: Only run generator if there's active subscription (not paused/cancelled)"
This fixes an issue where VM would run the async* generator after a
`yield` / `yield*` even though the subscription may be paused or
cancelled.

Furthermore this fixes an issue where `StackTrace.current` used
in async* generator crashes VM and/or produces truncated stack
trace.

This fixes the following existing tests that were failing before:

  * co19/Language/Statements/Yield_and_Yield_Each/Yield_Each/execution_async_t08
  * co19/Language/Statements/Yield_and_Yield_Each/Yield_Each/execution_async_t09
  * co19/Language/Statements/Yield_and_Yield_Each/Yield_Each/execution_async_t10
  * language/async_star/async_star_cancel_test
  * language/async_star/pause_test

New in reland: Allow the generator to to cause cancelling it's own consumer.
This addresses the issue of original revert
  -> see https://github.com/flutter/flutter/issues/101514

Issue https://github.com/flutter/flutter/issues/100441
Issue https://github.com/dart-lang/sdk/issues/48695
Issue https://github.com/dart-lang/sdk/issues/34775

TEST=vm/dart{,_2}/causal_stacks/flutter_regress_100441_test

Change-Id: I091b7159d59ea15fc31162b4b6b17260d523d7cb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/242400
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2022-04-26 12:01:34 +00:00
Martin Kustermann 0b5a8faa01 [vm] Ensure hot-reload will allocate-finalize new classes if old ones were
This was missed when is_allocate_finalized() was introduced and is now
revealed due to [0] having added

  ASSERT(cls.is_allocate_finalized());

into object allocation paths that were calling finalization code before.

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

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

TEST=Fixes test failures.

Change-Id: I5ff0491d4980630cbdbf799f15aa45089ee4d15f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/242101
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2022-04-26 11:45:48 +00:00
Dan Field fe30c3f235 [vm] Expose whether extension stream has listeners, guard postEvent
This avoids json encoding that was otherwise happening even in product mode. JSON encoding shows up CPU profiling as taking significant time, particularly on low end devices.

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

Bug: https://github.com/dart-lang/sdk/issues/48860
Change-Id: I2cf4d949e85c0b23de01ec2033b04527d40c76fe
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/242081
Reviewed-by: Ben Konyi <bkonyi@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Dan Field <dnfield@google.com>
2022-04-26 07:53:43 +00:00
Chris Bracken eabec1c6a5 Use Utils::StrDup in place of strdup
This avoids warnings about strdup being deprecated in favour of _strdup
on Windows.

TEST=manual build, observe no warnings are produced

Bug: https://github.com/flutter/flutter/issues/59199
Change-Id: Ide390f3a719b9598bea0fc9976be3fb337f4de37
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/242386
Reviewed-by: Alexander Aprelev <aam@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2022-04-25 23:12:53 +00:00
Martin Kustermann ca4ad74b53 [vm] Attempt to avoid timeouts / flakiness of vm/dart_2/isolates/reload_many_isolates_live_and_die_test
Closes https://github.com/dart-lang/sdk/issues/48847

TEST=Addresses flakiness, timeouts of the mentioned test.

Change-Id: I91472c903e1f9f595c35217ac4c7e5613044fabb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/242107
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2022-04-22 15:23:29 +00:00