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>
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>
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>
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>
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>
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>
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>
`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>
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>
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>
(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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>