This CL implements `NativeFinalizer` in the GC.
`FinalizerEntry`s are extended to track `external_size` and in which
`Heap::Space` the finalizable value is.
On attaching a native finalizer, the external size is added to the
relevant heap. When the finalizable value is promoted from new to old
space, the external size is promoted as well. And when a native
finalizer is run or is detached, the external size is removed from the
relevant heap again.
In contrast to Dart `Finalizer`s, `NativeFinalizer`s are run on isolate
shutdown.
When the `NativeFinalizer`s themselves are collected, the finalizers are
not run. Users should stick the native finalizer in a global variable to
ensure finalization. We will revisit this design when we add send and
exit support, because there is a design space to explore what to do in
that case. This current solution promises the least to users.
In this implementation native finalizers have a Dart entry to clean up
the entries from the `all_entries` field of the finalizer. We should
consider using another data structure that avoids the need for this Dart
entry. See the TODO left in the code.
Bug: https://github.com/dart-lang/sdk/issues/47777
TEST=runtime/tests/vm/dart(_2)/isolates/fast_object_copy_test.dart
TEST=runtime/vm/object_test.cc
TEST=tests/ffi(_2)/vmspecific_native_finalizer_*
Change-Id: I8f594c80c3c344ad83e1f2de10de028eb8456121
Cq-Include-Trybots: luci.dart.try:vm-kernel-reload-rollback-linux-debug-x64-try,vm-kernel-reload-linux-debug-x64-try,vm-ffi-android-debug-arm64c-try,dart-sdk-mac-arm64-try,vm-kernel-mac-release-arm64-try,pkg-mac-release-arm64-try,vm-kernel-precomp-nnbd-mac-release-arm64-try,vm-kernel-win-debug-x64c-try,vm-kernel-win-debug-x64-try,vm-kernel-precomp-win-debug-x64c-try,vm-kernel-nnbd-win-release-ia32-try,vm-ffi-android-debug-arm-try,vm-precomp-ffi-qemu-linux-release-arm-try,vm-kernel-mac-debug-x64-try,vm-kernel-nnbd-mac-debug-x64-try,vm-kernel-nnbd-linux-debug-ia32-try,benchmark-linux-try,flutter-frontend-try,pkg-linux-debug-try,vm-kernel-asan-linux-release-x64-try,vm-kernel-gcc-linux-try,vm-kernel-optcounter-threshold-linux-release-x64-try,vm-kernel-precomp-linux-debug-simarm_x64-try,vm-kernel-precomp-obfuscate-linux-release-x64-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-debug-x64c-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/236320
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
MixinApplicationBuilder was never a real TypeBuilder and just cluttered
the interface.
MixinApplicationBuilder.supertype is also removed and instead passed
separately.
Change-Id: Iac4e119aff39e27e6e589b5123da1d0cc0604dbb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/238081
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
This adds support for generating truly unique fresh names when building
augmentation library code. The synthesized names are used for import
prefixes and as placeholders for not-yet-inferred omitted type
annotations.
Change-Id: I6fe9bc37b39a243c93187f561ee32e07237341f1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/237823
Reviewed-by: Jake Macdonald <jakemac@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Previously, this field existed as a sanity check to help ensure that
the client didn't accidentally call `functionExpression_end` more
often than `functionExpression_begin`. However now that flow analysis
maintains an explicit stack of what constructs have been begun and not
ended, the check is redundant, because trying to pop from an empty
stack would cause a runtime failure anyway.
Change-Id: I4a56c66169a6de6b4c19d67800d8d0083e7bd59f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/237382
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
This implements TypeDeclarationResolver for the CFE. Adds a test to
the macro api test, which includes support for throwing and catching
the ArgumentError required by the api.
Change-Id: I5bb7948064ba5a2c215289915fc10314fd28aa1d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/237020
Reviewed-by: Jake Macdonald <jakemac@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
This adds support for [interfacesOf] and [mixinsOf] of the
[ClassIntrospector] interface. To support this, the mixed in
[ClassHierarchyNode] is now included in the [ClassHierarchyNode] for
a mixin application.
Change-Id: I30cef4b462b1b2b52acf1bd286d82ebc1c5caa4e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/236883
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
The old code tries to determine something by using a forwarding listener
without forwarding to anything. It leaked a rewrite though, meaning that
the rewrite stayed, but the error given when rewriting wasn't passed on.
When then parsing it with the real listener, the rewrite was in effect
and there was no error to report. In total no errors were reported.
This fixes the issue by undoing any rewrites in this situation.
Fixes https://github.com/dart-lang/sdk/issues/47020
Change-Id: I5342ae6969f00dea830fb7abb30f21932907b8bf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/236540
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
This adds direct support for class member augmentation, including checks
that the 'augment' modifier is used correctly. Different from the patch
member support, non-augment members added in augment classes are now
part of the interface of the class and can therefore be used outside
the augmentation library.
The CL includes support for using the 'import augment' syntax to import
libraries as augmentation libraries. The enable direct testing of the
augmentation features in expectation tests.
Change-Id: I9961e15862dba827050bec4aceb7dfc45e053d7d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/234520
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
This adds support for the `import augment <uri>` import syntax when
the 'macros' experiment is enabled.
The CL also include propagation of the augment modifier on class methods
which was missed in a previous CL.
Change-Id: Ic843e7e34559bcac728c810590f34b727b5f7090
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/234401
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
This changes the way the 'augment' modifier is handled in the parser.
Instead of being special cased for class declarations, it is now a
built-in identifier recognized only when the scanner is configured to
support augmentation libraries.
The change supports the used of the 'augment' modifier on not only
class declarations but also mixin and member declarations, as needed
for supporting macros.
Change-Id: I2679d198dea360900cfc478fae9c1660702a8a02
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/233887
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Results of Phase 2 macros are now applied. The macro application code
has been refactored to support that Phase 1 can apply all macro
applications within a library in bulk, but Phase 2 can apply each
macro application in sequence.
The later is to prepare for making added member visible to subsequent
macro applications within Phase 2. This functionality has not been
completed yet.
Change-Id: Idaf2702e21bde75aedb1509d88e02f270196af5e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/233380
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
This also:
- Adds support to the bootstrap code to handle communicating via sendPort or stdio
- Refactors pretty heavily the isolate executor code such that it can be reused.
- Refactors the isolated executor test into a shared test for all executors
- Removes the mirror based executor entirely - I don't see a path forward with this one.
- Reorganizes all executor based files under macros/executor
Change-Id: I2fc6bb3e6ce56c8b331719f4dc08617b3a521398
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/233200
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jake Macdonald <jakemac@google.com>
This adds support for the generating a synthesized augmentation
library for each library in which phase 1 macros were applied.
Current implementation piggybacks on the patch library support. The
intension is that both patches and augmentations are handled through
the same general mechanism. For now, the wording refers to augmentation
libraries as patch libraries where the implementation is shared.
Testing is extended to verify that the generated classes are
included in the resulting AST.
Change-Id: Ie0d4cfdc84b55ca87e0014794f14b38e442f08eb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/233101
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
- Support TransferableTypedData in the bootstrap code and IsolatedExecutor.
- Also removed the fake executor and conditional import. Mode will likely be chosen based on factors other than just the availability of `dart:isolate`.
- Run the tests in both serialization modes.
Change-Id: I5c731d192c0d3a8cdc5f7fb900dc07a32f4f4d51
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/232981
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Auto-Submit: Jake Macdonald <jakemac@google.com>
Commit-Queue: Jake Macdonald <jakemac@google.com>
* Add team "groups" in tools/OWNERS_<group name>.
* Add top-level OWNERS as a fallback.
* Add OWNERS for all top-level directories.
* Add OWNERS to all packages.
For additional background information see go/dart-sdk-owners.
TEST=No op until code-owners is enabled.
Bug: b/200915407
Change-Id: I7fe6116cc599c749cd50ca16151d6d6a801d99d7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/229147
Reviewed-by: Jonas Termansen <sortie@google.com>
This CL add support for identifier resolution to use the
MacroExecutor.buildAugmentationLibrary for generating the code.
The CL updates the ResolvedIdentifier to have a nullable [uri] in
order to support built in identifiers, such as `void`.
Change-Id: I9436ea77c06cf5618f1977f4c9ac0490ff059587
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/232623
Reviewed-by: Jake Macdonald <jakemac@google.com>
Auto-Submit: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
With the optimizations suggested this does now equal or outperform the JSON serializer in all scenarios, the latest numbers from the benchmark are as follows:
Isolate.spawn + SerializationMode.jsonClient: 0:00:00.041666
Isolate.spawnUri + SerializationMode.jsonClient: 0:00:00.069551
Separate process + SerializationMode.jsonClient: 0:00:00.177171
Isolate.spawn + SerializationMode.byteDataClient: 0:00:00.040990
Isolate.spawnUri + SerializationMode.byteDataClient: 0:00:00.059319
Separate process + SerializationMode.byteDataClient: 0:00:00.080008
Change-Id: If5431513c7487d8b7af350381e794cbd61c1be42
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/232027
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Auto-Submit: Jake Macdonald <jakemac@google.com>
Commit-Queue: Jake Macdonald <jakemac@google.com>
This adds an initial test for implementation of the macro api that
can be shared between implementations.
The test consists of a set of macros and a library of declarations that
apply these macros. When applied the macros work as unittest tests that
check that the macro api give the expected results for the various
declarations.
Change-Id: Id4183e8ac90fa96ef1ebc01b1c9f15cc413b6443
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/232383
Auto-Submit: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jake Macdonald <jakemac@google.com>
Commit-Queue: Jake Macdonald <jakemac@google.com>