tonycloud/dev
103 Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
fff4f2324d |
[vm] Remove _HashFieldBase
This class is structurally equivalent to _HashVMBase and the only reason for it to exist for inability of normal Dart classes to extend _HashVMBase - but this can worked around by properly configuring _HashVMBase class in bootstrapping. TEST=ci Change-Id: I5ca401e274920d2b4739424c6b6595306a6a6964 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/494140 Commit-Queue: Slava Egorov <vegorov@google.com> Reviewed-by: Alexander Markov <alexmarkov@google.com> |
||
|
|
bcbc47d99c |
[vm] Expose predefined class ids via runtime offsets
TEST=ci Change-Id: Ie0627c6c1ef32e1c21ee04aba84b05534f1f752b Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/486862 Reviewed-by: Ryan Macnak <rmacnak@google.com> Reviewed-by: Slava Egorov <vegorov@google.com> Commit-Queue: Alexander Markov <alexmarkov@google.com> |
||
|
|
cdf7bf9c78 |
[vm/shared] Allow const maps in deeply immutable classes.
This relies on runtime check of Map-typed variable initialization. TEST=kernel_binary_flowgraph_test Change-Id: Ia9be2644208883739f5896a223dcbe2b59c98114 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/482021 Reviewed-by: Slava Egorov <vegorov@google.com> |
||
|
|
917f452e15 |
[vm/immutable] Ensure that canonical instances are deeply-immutable.
Fix snapshot serializer/deserializer to take care of deep-immutability proprety. BUG=https://github.com/dart-lang/sdk/issues/62404 TEST=ci Change-Id: Ifa7d8f8b0af73b3a6ff9c1f79a174246280b1ce9 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/473422 Reviewed-by: Slava Egorov <vegorov@google.com> Commit-Queue: Alexander Aprelev <aam@google.com> |
||
|
|
eb75c53d95 |
[vm/shared] Perform deeply-immutable initialization runtime check.
When an initial value is assigned into a class tagged as deeply-immutable, perform runtime check of that value. This is needed to support proper initialization of the closures as part of deeply-immutable classes. BUG=https://github.com/dart-lang/sdk/issues/61962 TEST=run_isolate_group_run_test Change-Id: I550746c0d22ca06ffb89959e8384cc9e6d28d590 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/468200 Commit-Queue: Alexander Aprelev <aam@google.com> Reviewed-by: Slava Egorov <vegorov@google.com> |
||
|
|
859f6b376e |
[vm] Mark closure objects as shallowly immutable.
TEST=ci Issue: https://github.com/dart-lang/sdk/issues/55136 Change-Id: Icb39fc386439da449845eac4d0fd0df9d776aec7 Cq-Include-Trybots: luci.dart.try:vm-linux-debug-x64-try,vm-aot-linux-debug-x64-try,vm-aot-linux-debug-simarm_x64-try Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/435126 Commit-Queue: Alexander Markov <alexmarkov@google.com> Auto-Submit: Tess Strickland <sstrickl@google.com> Reviewed-by: Alexander Markov <alexmarkov@google.com> |
||
|
|
5559d1e5e7 |
[vm] Avoid massive vtables for handles.
Implement type checks for handles using one virtual function and range checks instead of per-type virtual functions, which scale quadratically with the number of handle classes.
out/ReleaseX64/exe.stripped/gen_snapshot 6886680 -> 6645512 (-3.5%)
Cf.
|
||
|
|
8fbca8ba67 |
[vm] Initial implementation of dynamic modules in the VM/AOT
TEST=Manually tested dynamic modules Change-Id: Icb2616e414167bd1fbd10f01dea64c57dbdeeac7 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/380281 Reviewed-by: Slava Egorov <vegorov@google.com> Commit-Queue: Alexander Markov <alexmarkov@google.com> |
||
|
|
0d3ade255b |
[vm/compiler] Limit exposure of untagged pointers to managed memory.
After https://dart-review.googlesource.com/c/sdk/+/330600, there were more chances for the optimizing compiler to introduce or move GC-triggering instructions like allocations or boxings between the retrieval of an untagged pointer to GC-moveable memory and its use. To limit the chance of this happening, this CL removes the explicit loading of the untagged payload address when building the initial flow graph in most cases when the array is not known to be an external array (an external string, an external typed data object, or an FFI Pointer). The remaining case is during view allocation, which extracts the payload address of the base typed data object underlying the view (which may be GC-movable) to calculate the payload address that should be stored in the data field of the view object. See https://github.com/dart-lang/sdk/issues/54884. During canonicalization of LoadIndexed, StoreIndexed, and MemoryCopy instructions, if the cid of an array input is an external array (external string, external typed data object, or Pointer), then a LoadField instruction that extracts the untagged payload address is inserted before the instruction and the corresponding input is rebound to that LoadField instruction. Once all compiler passes that involve code motion have been performed, a new pass looks for LoadIndexed, StoreIndexed, or MemoryCopy where the cid stored in the instruction for the array is a typed data cid. In these cases, if the array is not an internal typed data object, then the payload address is extracted. Waiting until this point ensures that no GC-triggering instructions are inserted between the extraction of the payload address and the use. (Internal typed data objects are left as-is because the payload address is inside the object itself and doesn't require indirection through the data field of the object). This CL also replaces code conditional on the array cid with code that is instead conditional on the array element representation in cases where it makes sense to do so, since this is a less brittle check than checking the array cid (e.g., checking for kUnboxedInt8 to load, store, or copy an signed byte from an array instead of listing all possible array cids that store signed bytes). This CL also fixes an issue with the ARM64 assembler where calling LoadFromOffset with an Address that has a non-Offset type would silently generate bad code instead of triggering the ASSERT in PrepareLargeOffset. TEST=vm/dart/typed_list_index_checkbound_il_test Issue: https://github.com/dart-lang/sdk/issues/54710 Cq-Include-Trybots: luci.dart.try:vm-aot-android-release-arm64c-try,vm-aot-android-release-arm_x64-try,vm-aot-linux-debug-x64-try,vm-aot-linux-debug-x64c-try,vm-aot-mac-release-arm64-try,vm-aot-mac-release-x64-try,vm-aot-obfuscate-linux-release-x64-try,vm-aot-optimization-level-linux-release-x64-try,vm-aot-win-debug-arm64-try,vm-appjit-linux-debug-x64-try,vm-asan-linux-release-x64-try,vm-checked-mac-release-arm64-try,vm-eager-optimization-linux-release-ia32-try,vm-eager-optimization-linux-release-x64-try,vm-ffi-android-debug-arm-try,vm-ffi-android-debug-arm64c-try,vm-ffi-qemu-linux-release-arm-try,vm-ffi-qemu-linux-release-riscv64-try,vm-fuchsia-release-x64-try,vm-linux-debug-ia32-try,vm-linux-debug-x64-try,vm-linux-debug-x64c-try,vm-mac-debug-arm64-try,vm-mac-debug-x64-try,vm-msan-linux-release-x64-try,vm-reload-linux-debug-x64-try,vm-reload-rollback-linux-debug-x64-try,vm-ubsan-linux-release-x64-try,vm-win-debug-arm64-try,vm-win-debug-x64-try,vm-win-release-ia32-try Change-Id: I25b5f314943e9254d3d28986d720a5d47f12feeb Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/352363 Reviewed-by: Daco Harkes <dacoharkes@google.com> Reviewed-by: Ryan Macnak <rmacnak@google.com> Commit-Queue: Tess Strickland <sstrickl@google.com> Reviewed-by: Alexander Markov <alexmarkov@google.com> Reviewed-by: Martin Kustermann <kustermann@google.com> |
||
|
|
17d6ba15b6 |
[vm] Remove external strings
This change removes support for external strings from the VM along with Dart_NewExternalLatin1String, Dart_NewExternalUTF16String and Dart_IsExternalString Dart C API functions. External strings are not used by the VM nor any known embedder, but Dart VM was paying the maintenance and performance price for the external string implementation classes. TEST=ci Change-Id: I094cd2d2b7ec0840e9f09e1ca9e5a7acd4e78c28 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/358760 Reviewed-by: Ryan Macnak <rmacnak@google.com> Reviewed-by: Siva Annamalai <asiva@google.com> Commit-Queue: Alexander Markov <alexmarkov@google.com> |
||
|
|
8de00e2137 |
[vm] Introduce pragma vm:deeply-immutable
This CL introduces a way to mark all instances of a class as deeply immutable. In order to statically verify that all instances of a deeply immutable class are immutable, a deeply immutable classes must have the following properties: 1. All instance fields must 1. have a deeply immutable type, 2. be final, and 3. be non-late. 2. The class must be `final` or `sealed`. This ensures no non-deeply-immutable subtypes are added by external code. 3. All subtypes must be deeply immutable. This ensures 1.1 can be trusted. 4. The super type must be deeply immutable (except for Object). Note that instances of some classes in the VM are deeply immutable while their class cannot be marked immutable. * SendPort, Capability, RegExp, and StackTrace are not `final` and can be implemented by external code. * UnmodifiableTypedDataViews do not have a public type. (It was recently deprecated.) See runtime/docs/deeply_immutable.md for more details. Use case: This enables attaching a `Dart_FinalizableHandle` to a deeply immutable object and the deeply immutable object with other isolates in the same isolate group. (Note that `NativeFinalizer`s live in an isolate, and not an isolate group. So this should currently _not_ be used with `NativeFinalizer`s. See https://github.com/dart-lang/sdk/issues/55062 for making a `NativeFinalizer.shared(` that would live in an isolate group instead of in an isolate.) Implementation details: Before this CL, the `ImmutableBit` in the object header was only ever set to true for predefined class ids (and for const objects). After this CL, the bit can also be set to true for non const instances of user-defined classes. The object allocation and initialization code has been changed to deal with this new case. The immutability of a class is saved in the class state bits. On object allocation and initialization the immutability bit is read from the class for non-predefined class ids. TEST=runtime/tests/vm/dart/isolates/fast_object_copy2_test.dart TEST=runtime/vm/isolate_reload_test.cc TEST=tests/lib/isolate/deeply_immutable_* Bug: https://github.com/dart-lang/sdk/issues/55120 Bug: https://github.com/dart-lang/sdk/issues/54885 Change-Id: Ib97fe589cb4f81673cb928c93e3093838d82132d Cq-Include-Trybots: luci.dart.try:vm-aot-android-release-arm64c-try,vm-aot-android-release-arm_x64-try,vm-aot-linux-debug-x64-try,vm-aot-linux-debug-x64c-try,vm-aot-mac-release-arm64-try,vm-aot-mac-release-x64-try,vm-aot-obfuscate-linux-release-x64-try,vm-aot-optimization-level-linux-release-x64-try,vm-appjit-linux-debug-x64-try,vm-asan-linux-release-x64-try,vm-checked-mac-release-arm64-try,vm-eager-optimization-linux-release-ia32-try,vm-eager-optimization-linux-release-x64-try,vm-ffi-android-debug-arm-try,vm-ffi-android-debug-arm64c-try,vm-ffi-qemu-linux-release-arm-try,vm-ffi-qemu-linux-release-riscv64-try,vm-fuchsia-release-x64-try,vm-kernel-linux-debug-x64-try,vm-kernel-precomp-linux-release-x64-try,vm-linux-debug-ia32-try,vm-linux-debug-x64-try,vm-linux-debug-x64c-try,vm-mac-debug-arm64-try,vm-mac-debug-x64-try,vm-msan-linux-release-x64-try,vm-reload-linux-debug-x64-try,vm-reload-rollback-linux-debug-x64-try,vm-ubsan-linux-release-x64-try Cq-Include-Trybots: dart-internal/g3.dart-internal.try:g3-cbuild-try Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/354902 Commit-Queue: Daco Harkes <dacoharkes@google.com> Reviewed-by: Martin Kustermann <kustermann@google.com> |
||
|
|
9c69bc4c6d |
[vm] Mark Type objects as sharable - even non-canonicalized ones
Fixes VM crash in object-copy implementation where non-canonicalized, non-constant types are sent across `SendPort`s. We were already sharing * `TypeArgument`s and anything they refer to * `Type`s that from type literals that are constant What was missing was * `Type`s coming from type literals that had to be instantiated TEST=vm/dart/isolates/fast_object_copy2_test Change-Id: I06d85d9849519cd185394efb5aec6a316a763f16 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/355440 Reviewed-by: Daco Harkes <dacoharkes@google.com> Commit-Queue: Martin Kustermann <kustermann@google.com> Reviewed-by: Ryan Macnak <rmacnak@google.com> |
||
|
|
d348c473b0 |
[vm] Refactor typed data cid handling.
No changes in cids, just defining kFirstTypedDataCid and kLastTypedDataCid to avoid assumptions that kTypedDataInt8ArrayCid is the first one and that kByteDataViewCid comes after the last one (outside of compile-time checks for possible new typed data cids before kTypedDataInt8ArrayCid and kByteDataViewCid). Also defining kNumTypedDataCidRemainders to be used in the place of the appropriate hardcoded 4s. TEST=ci Change-Id: Ic9f937ef0fa670b3331b9079090596d9a120ee15 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/352862 Commit-Queue: Tess Strickland <sstrickl@google.com> Reviewed-by: Alexander Markov <alexmarkov@google.com> |
||
|
|
eba0e68e1a |
[vm/ffi] Allow Pointer objects to be shared across isolates
We consider `Pointer` objects as simple value types. We may unbox them in the future to be simple integers - at which point our message sending code wouldn't even know they are pointers anymore. There's therefore no reason to prevent sending them across `SendPort`s. Owners of `Pointer`s may implement `Finalizable` and sending such finalizables across `SendPort`s is prohibited. Closes https://github.com/dart-lang/sdk/issues/50457 TEST=vm/dart/isiolates/fast_object_copy*_test Change-Id: Ia215d119c5bb0e48e2c5dc83cc82e132f46931c1 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/350822 Commit-Queue: Martin Kustermann <kustermann@google.com> Reviewed-by: Daco Harkes <dacoharkes@google.com> |
||
|
|
dfc1b6b16b |
[vm] Store the number of used inputs in SubtypeTestCaches.
Previously, SlowTypeTestStub would use the incoming instance and
destination type to determine which `SubtypeNTestCacheStub` to call,
where `N` is the number of inputs checked for each entry. The code
for generating `InstanceOf` instructions performs similar work,
inlining some checks and then falling back to checking and updating
an appropriate `SubtypeNTestCacheStub` if the inlined checks fail.
Meanwhile, the runtime would use all available information to
create a new entry when needed, depending on the `SubtypeNTestCacheStub`
called at runtime to ignore the parts of the entry it didn't need.
To illustrate a situation where the runtime might use more
information to create an entry than needed by the stub, consider
the following class header:
```
class C<T> extends D
```
If no subtype of `D` requires knowing the specific type arguments for
an instance to determine whether that instance is an instance of `D`,
then the compiler can generate a `Subtype1TestCacheStub` call, where
only the class id of the instance is checked.
However, in the runtime, when updating the cache, the runtime will
create an entry that includes the specific type arguments used to
instantiate `C` when the initial cache miss occurred, as the runtime
does not know how many inputs the code that checks that SubtypeTestCache
uses. If the cache has grown to the point that it is hash-based, that
means the runtime uses the instance type arguments of the first cache
miss to determine the correct place to create a new entry.
When the stub only performs a linear search over the cache contents,
this works, as every entry is checked until a matching entry is found,
and thus the stub can ignore unneeded information. However, if a cache
is hash-based, this doesn't work: if the first miss was an instance
of `C<int>`, then the runtime includes all that information in a new
entry. This means the stub has to calculate the instance type
arguments, which it did not have to do before, and if a subsequent
check uses different instance type arguments (e.g., an instance of
`C<String>`), the result may still be a cache miss, and the runtime
adds another entry which has the same information as the previous
entry as far as the stub was originally concerned.
Thus, to limit itself to considering only the inputs used by the
appropriate `SubtypeNTestCacheStub`, the runtime needs to be told how
many inputs are used. This CL adds an additional field to
`SubtypeTestCache`s which contains the number of used inputs, and
changes the places where `SubtypeTestCache`s are allocated in the
flow graph compiler and the `DRT_TypeCheck` runtime entry to pass the
appropriate number of inputs. To ensure that the runtime and stubs
agree on how many inputs should be used, the `SlowTypeTestStub` now
uses the value of this field to determine which `SubtypeNTestCacheStub`
to call.
TEST=vm/cc/STC_{Linear,Hash}Lookup
Bug: https://github.com/dart-lang/sdk/issues/48345
Change-Id: Ie16f2d12c4c5eae856b668f28178818203662d1c
Cq-Include-Trybots: luci.dart.try:vm-aot-linux-debug-simriscv64-try,vm-aot-linux-debug-x64-try,vm-aot-linux-release-x64-try,vm-aot-linux-product-x64-try,vm-aot-linux-release-simarm64-try,vm-aot-linux-release-simarm_x64-try,vm-aot-linux-debug-x64c-try,vm-aot-mac-release-arm64-try,vm-kernel-precomp-linux-release-x64-try,vm-kernel-precomp-linux-debug-x64-try,vm-aot-dwarf-linux-product-x64-try,vm-linux-release-ia32-try,vm-linux-debug-x64c-try,vm-linux-debug-x64-try,vm-linux-debug-simriscv64-try,vm-linux-release-simarm64-try,vm-linux-release-simarm-try,vm-mac-release-arm64-try,vm-mac-release-x64-try,vm-tsan-linux-release-x64-try,vm-reload-rollback-linux-release-x64-try,vm-reload-linux-release-x64-try,vm-ffi-qemu-linux-release-arm-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/310180
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
|
||
|
|
2ee6fcf514 |
[vm] Remove TypeRef
TypeRef type wraps around another type and it was used to represent a graph of recursive types. After [0], the only use of TypeRef is for TypeParameter.bound which may indirectly reference the same TypeParameter. This change replaces TypeParameter.bound with TypeParameter.owner and removes TypeRef entirely. Various parts of the VM no longer need to handle and support TypeRefs. TypeParameter.owner can reference a FunctionType, Class, or, as an optimization, it can be set to null in order to share class type parameters among different classes. With the exception of the 'TypeParameter.owner' back pointer, VM types are now not recursive and can be visited without additional tracking. Caveats: * Generic FunctionType cannot be cloned in a shallow way: when copying a FunctionType, type parameters should be cloned too and their owners should be updated. For that reason, a mapping between 'from' and 'to' function types (FunctionTypeMapping) is maintained during type transformations such as InstantiateFrom. FunctionType::Clone is used instead of Object::Clone where appropriate. * When testing types for subtyping and equivalence, mapping between function types is passed to make sure type parameters belong to the equivalent function types. * IL serializer needs to serialize function types as a whole before serializing any types potentially pointing into the middle of a function type (such as return type 'List<Y0>' pointing into the middle of a function type 'List<Y0> Function<Y0>()'). [0] https://dart-review.googlesource.com/c/sdk/+/296300 TEST=ci Change-Id: I67c2fd0117c6183a45e183919a7847fd1af70b3e Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/294165 Reviewed-by: Ryan Macnak <rmacnak@google.com> Commit-Queue: Alexander Markov <alexmarkov@google.com> |
||
|
|
7db7bd0573 |
[vm] Simplify is-deeply-immutable check in transitive object copy
Now that we have an immutability bit, we can set the bit in object header of newly allocated objects if those objects are always deeply immutable. That allows only checking for the immutable bit instead of checking against a whole range of cids when sending objects via `SendPort.send()` / `Isolate.exit()`. TEST=ci Change-Id: I4451a9fe11f68c7dd874d49ab632daa3102be19e Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/281842 Commit-Queue: Martin Kustermann <kustermann@google.com> Reviewed-by: Ryan Macnak <rmacnak@google.com> |
||
|
|
f3067e8740 |
[vm] Add WeakArray; to be used to create weak canonical sets.
TEST=ci Bug: https://github.com/dart-lang/sdk/issues/50648 Change-Id: I788a8e3e5e8383c0b8d6f248d64a33dc67013260 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/278860 Reviewed-by: Siva Annamalai <asiva@google.com> Commit-Queue: Ryan Macnak <rmacnak@google.com> |
||
|
|
9182d5e535 |
[vm] Raise the limit on the number of classes.
Some large applications are bumping up against the 16-bit limit. The object header changes from hash:32,cid:16,size:8,gc:8 to hash:32,cid:20,size:4,gc:8. Because the CID field is no longer a power of two, it takes two instructions to load instead of one, increasing code size. The alternative change to cid:32,hash:24,gc:8 was considered and rejected because the reduction in hash bits very noticeably affects performance in applications with large data sets. TEST=ci Bug: b/255934984 Change-Id: I5fa36ba48a6852359d994393cf80c6a761c5d84c Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/269120 Reviewed-by: Martin Kustermann <kustermann@google.com> Commit-Queue: Ryan Macnak <rmacnak@google.com> |
||
|
|
a2de36e708 |
[vm] Rename the default implementation classes of Map and Set.
_InternalLinkedHashMap => _Map _InternalImmutableLinkedHashMap => _ConstMap _InternalLinkedHashSet => _Set _InternalImmutableLinkedHashSet => _ConstSet This makes things nicer to read in places that display implementation names, such as stack traces, debuggers, profilers and inspectors. TEST=ci Change-Id: Iec851c80ea2086cbe79934565dbf35f04809a836 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/266303 Reviewed-by: Daco Harkes <dacoharkes@google.com> Commit-Queue: Ryan Macnak <rmacnak@google.com> Reviewed-by: Chloe Stefantsova <cstefantsova@google.com> |
||
|
|
b113fffb65 |
Reland "[vm/ffi] Throw on returning Error in Handle"
Fix: Check handle contents for Smi. Closes: https://github.com/flutter/flutter/issues/112726 Orignal CL description: Makes `Dart_Handle` FFI returns behave as the following snippet: ``` Dart_Handle ExampleSnippet() { Dart_Handle result = ...; if (Dart_IsError(result)) { Dart_PropagateError(result); } return result; } ``` Also makes FFI consistent with Dart_NativeFunctions, which will automatically throw upon return if Dart_SetReturnValue set the result to an error. `UnhandledExceptions` cannot flow out into Dart generated code. So, the implementation needs to be in `FfiCallInstr::EmitNativeCode`. Using `Dart_IsError` is slow compared to a machine code class id check. So, we should do the handle unwrapping and class id check in machine code. Unwrapping Handles in machine code is only safe when the GC is guaranteed to not run: Either (1) in `kThreadInGenerated`, or (2) in `kThreadInNative`, but only when transitioned into safepoint. So, the handle cannot be unwrapped immediately after the FFI call in machine code. We first need to transition back to generated. This means we need to transition again to native to do the actual `Dart_PropagateError` call. We can do so without the stub in JIT because we never return with normal control flow. Performance impact of this change is within benchmark noise in both JIT and AOT. Size impact is 42 bytes on x64, which is 10% in AOT and 12% in JIT. For more numbers see: go/dart-ffi-handle-error TEST=runtime/bin/ffi_test/ffi_test_functions_vmspecific.cc TEST=tests/ffi/vmspecific_handle_test.dart Closes: https://github.com/dart-lang/sdk/issues/49936 Change-Id: Id8edfd841a7d6246438386007d83747868a0a151 Cq-Include-Trybots: luci.dart.try:vm-canary-linux-debug-try,vm-ffi-android-debug-arm64c-try,vm-ffi-android-debug-arm-try,vm-kernel-gcc-linux-try,vm-kernel-linux-debug-x64-try,vm-kernel-linux-debug-x64c-try,vm-kernel-msvc-windows-try,vm-kernel-optcounter-threshold-linux-release-x64-try,vm-kernel-precomp-asan-linux-release-x64-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-reload-linux-debug-x64-try,vm-kernel-reload-rollback-linux-debug-x64-try,vm-kernel-tsan-linux-release-x64-try,vm-kernel-win-debug-x64-try,vm-kernel-win-debug-ia32-try,vm-precomp-ffi-qemu-linux-release-arm-try,vm-precomp-ffi-qemu-linux-release-riscv64-try,vm-kernel-linux-debug-ia32-try,vm-kernel-mac-release-arm64-try,vm-kernel-precomp-win-debug-x64c-try Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/262342 Reviewed-by: Martin Kustermann <kustermann@google.com> Auto-Submit: Daco Harkes <dacoharkes@google.com> Commit-Queue: Daco Harkes <dacoharkes@google.com> |
||
|
|
2742d90033 |
Revert "[vm/ffi] Throw on returning Error in Handle"
This reverts commit
|
||
|
|
d9c442bce8 |
[vm/ffi] Throw on returning Error in Handle
Makes `Dart_Handle` FFI returns behave as the following snippet:
```
Dart_Handle ExampleSnippet() {
Dart_Handle result;
if (Dart_IsError(result)) {
Dart_PropagateError(result);
}
return result;
}
```
Also makes FFI consistent with Dart_NativeFunctions, which will
automatically throw upon return if Dart_SetReturnValue set the result
to an error.
`UnhandledExceptions` cannot flow out into Dart generated code. So,
the implementation needs to be in `FfiCallInstr::EmitNativeCode`.
Using `Dart_IsError` is slow compared to a machine code class id
check. So, we should do the handle unwrapping and class id check in
machine code.
Unwrapping Handles in machine code is only safe when the GC is
guaranteed to not run: Either (1) in `kThreadInGenerated`, or (2) in
`kThreadInNative`, but only when transitioned into safepoint. So, the
handle cannot be unwrapped immediately after the FFI call in machine code. We first need to transition back to generated.
This means we need to transition again to native to do the actual
`Dart_PropagateError` call. We can do so without the stub in JIT
because we never return with normal control flow.
Performance impact of this change is within benchmark noise in both
JIT and AOT.
Size impact is 42 bytes on x64, which is 10% in AOT and 12% in JIT.
For more numbers see: go/dart-ffi-handle-error
TEST=runtime/bin/ffi_test/ffi_test_functions_vmspecific.cc
TEST=tests/ffi/vmspecific_handle_test.dart
Closes: https://github.com/dart-lang/sdk/issues/49936
Change-Id: Ie8fabeb6d53bc80689541bc4470cb37ee2200581
Cq-Include-Trybots: luci.dart.try:vm-canary-linux-debug-try,vm-ffi-android-debug-arm64c-try,vm-ffi-android-debug-arm-try,vm-kernel-gcc-linux-try,vm-kernel-linux-debug-x64-try,vm-kernel-linux-debug-x64c-try,vm-kernel-msvc-windows-try,vm-kernel-optcounter-threshold-linux-release-x64-try,vm-kernel-precomp-asan-linux-release-x64-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-reload-linux-debug-x64-try,vm-kernel-reload-rollback-linux-debug-x64-try,vm-kernel-tsan-linux-release-x64-try,vm-kernel-win-debug-x64-try,vm-kernel-win-debug-ia32-try,vm-precomp-ffi-qemu-linux-release-arm-try,vm-precomp-ffi-qemu-linux-release-riscv64-try,vm-kernel-linux-debug-ia32-try,vm-kernel-mac-release-arm64-try,vm-kernel-precomp-win-debug-x64c-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/261603
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
|
||
|
|
c94103ae05 |
[vm] Initial implementation of record instances
TEST=ci Issue: https://github.com/dart-lang/sdk/issues/49719 Change-Id: I82ba571d1935d616fe3d4d6d579e59eb57d65a43 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/256804 Commit-Queue: Alexander Markov <alexmarkov@google.com> Reviewed-by: Ryan Macnak <rmacnak@google.com> |
||
|
|
9a023aeae9 |
[vm] Initial implementation of record types
TEST=language/record_type_test Issue: https://github.com/dart-lang/sdk/issues/49719 Change-Id: Ib2100c23513395c9fa9c541320eacbb33a2a119e Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/256802 Reviewed-by: Ryan Macnak <rmacnak@google.com> Reviewed-by: Martin Kustermann <kustermann@google.com> Commit-Queue: Alexander Markov <alexmarkov@google.com> |
||
|
|
c1e67ac84f |
[vm] Recognize unmodifiable typed data views.
These types now work with Dart_TypedDataAcquireData. The presence of these types no longer degrades the performance of typed data indexed loads. The presence of these types degrades the performance of typed data indexed stores much less. The performance of indexed stores is somewhat regressed if these types were not used. TEST=ci Bug: https://github.com/dart-lang/sdk/issues/32028 Bug: https://github.com/dart-lang/sdk/issues/40924 Bug: https://github.com/dart-lang/sdk/issues/42785 Change-Id: Iffad865708501acf96db418985cd5a69bd9afa55 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/254501 Reviewed-by: Martin Kustermann <kustermann@google.com> Commit-Queue: Ryan Macnak <rmacnak@google.com> |
||
|
|
10bf1cfe58 |
Revert "[vm] Recognize unmodifiabled typed data views."
This reverts commit
|
||
|
|
d1112d37bd |
[vm] Recognize unmodifiabled typed data views.
These types now work with Dart_TypedDataAcquireData. The presence of these types no longer degrades the performance of typed data indexed loads. The presence of these types degrades the performance of typed data indexed stores much less. The performance of indexed stores is somewhat regressed if these types were not used. TEST=ci Bug: https://github.com/dart-lang/sdk/issues/32028 Bug: https://github.com/dart-lang/sdk/issues/40924 Bug: https://github.com/dart-lang/sdk/issues/42785 Change-Id: I05ac5c9543f6f61ac37533b9efe511254778caed Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/253700 Reviewed-by: Aske Simon Christensen <askesc@google.com> Reviewed-by: Martin Kustermann <kustermann@google.com> Commit-Queue: Ryan Macnak <rmacnak@google.com> |
||
|
|
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> |
||
|
|
532c116cd2 |
[vm] Implement NativeFinalizer
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> |
||
|
|
e151a81108 |
Reland "[vm] Implement Finalizer"
Original CL in patchset 1. Split-off https://dart-review.googlesource.com/c/sdk/+/238341 And pulled in fix https://dart-review.googlesource.com/c/sdk/+/238582 (Should merge cleanly when this lands later.) This CL implements the `Finalizer` in the GC. The GC is specially aware of two types of objects for the purposes of running finalizers. 1) `FinalizerEntry` 2) `Finalizer` (`FinalizerBase`, `_FinalizerImpl`) A `FinalizerEntry` contains the `value`, the optional `detach` key, and the `token`, and a reference to the `finalizer`. An entry only holds on weakly to the value, detach key, and finalizer. (Similar to how `WeakReference` only holds on weakly to target). A `Finalizer` contains all entries, a list of entries of which the value is collected, and a reference to the isolate. When a the value of an entry is GCed, the enry is added over to the collected list. If any entry is moved to the collected list, a message is sent that invokes the finalizer to call the callback on all entries in that list. When a finalizer is detached by the user, the entry token is set to the entry itself and is removed from the all entries set. This ensures that if the entry was already moved to the collected list, the finalizer is not executed. To speed up detaching, we use a weak map from detach keys to list of entries. This ensures entries can be GCed. Both the scavenger and marker tasks process finalizer entries in parallel. Parallel tasks use an atomic exchange on the head of the collected entries list, ensuring no entries get lost. The mutator thread is guaranteed to be stopped when processing entries. This ensures that we do not need barriers for moving entries into the finalizers collected list. Dart reads and replaces the collected entries list also with an atomic exchange, ensuring the GC doesn't run in between a load/store. When a finalizer gets posted a message to process finalized objects, it is being kept alive by the message. An alternative design would be to pre-allocate a `WeakReference` in the finalizer pointing to the finalizer, and send that itself. This would be at the cost of an extra object. Send and exit is not supported in this CL, support will be added in a follow up CL. Trying to send will throw. Bug: https://github.com/dart-lang/sdk/issues/47777 TEST=runtime/tests/vm/dart/finalizer/* TEST=runtime/tests/vm/dart_2/isolates/fast_object_copy_test.dart TEST=runtime/vm/object_test.cc Change-Id: Ibdfeadc16d5d69ade50aae5b9f794284c4c4dbab 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-analyze-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/+/238086 Reviewed-by: Martin Kustermann <kustermann@google.com> Reviewed-by: Ryan Macnak <rmacnak@google.com> Commit-Queue: Daco Harkes <dacoharkes@google.com> |
||
|
|
37526fc8d7 |
Revert "[vm] Implement Finalizer"
This reverts commit
|
||
|
|
7dca34c235 |
[vm] Implement Finalizer
This CL implements the `Finalizer` in the GC. (This CL does not yet implement `NativeFinalizer`.) The GC is specially aware of two types of objects for the purposes of running finalizers. 1) `FinalizerEntry` 2) `Finalizer` (`FinalizerBase`, `_FinalizerImpl`) A `FinalizerEntry` contains the `value`, the optional `detach` key, and the `token`, and a reference to the `finalizer`. An entry only holds on weakly to the value, detach key, and finalizer. (Similar to how `WeakReference` only holds on weakly to target). A `Finalizer` contains all entries, a list of entries of which the value is collected, and a reference to the isolate. When a the value of an entry is GCed, the enry is added over to the collected list. If any entry is moved to the collected list, a message is sent that invokes the finalizer to call the callback on all entries in that list. When a finalizer is detached by the user, the entry token is set to the entry itself and is removed from the all entries set. This ensures that if the entry was already moved to the collected list, the finalizer is not executed. To speed up detaching, we use a weak map from detach keys to list of entries. This ensures entries can be GCed. Both the scavenger and marker tasks process finalizer entries in parallel. Parallel tasks use an atomic exchange on the head of the collected entries list, ensuring no entries get lost. The mutator thread is guaranteed to be stopped when processing entries. This ensures that we do not need barriers for moving entries into the finalizers collected list. Dart reads and replaces the collected entries list also with an atomic exchange, ensuring the GC doesn't run in between a load/store. When a finalizer gets posted a message to process finalized objects, it is being kept alive by the message. An alternative design would be to pre-allocate a `WeakReference` in the finalizer pointing to the finalizer, and send that itself. This would be at the cost of an extra object. Send and exit is not supported in this CL, support will be added in a follow up CL. Trying to send will throw. Bug: https://github.com/dart-lang/sdk/issues/47777 TEST=runtime/tests/vm/dart/finalizer/* TEST=runtime/tests/vm/dart_2/isolates/fast_object_copy_test.dart TEST=runtime/vm/object_test.cc Change-Id: I03e6b4a46212316254bf46ba3f2df333abaa686c 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-analyze-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/+/229544 Reviewed-by: Lasse Nielsen <lrn@google.com> Reviewed-by: Slava Egorov <vegorov@google.com> Reviewed-by: Martin Kustermann <kustermann@google.com> Reviewed-by: Ryan Macnak <rmacnak@google.com> Commit-Queue: Daco Harkes <dacoharkes@google.com> |
||
|
|
828dcd00e8 |
[vm] Implement WeakReference in the VM
This CL implements `WeakReference` in the VM. * This reduces the size of weak references from 2 objects using 8 words to 1 object using 4 words. * This makes loads of weak reference targets a single load instead of two. * This avoids the fix-point in the GC and message object copying for weak references. (N.b. Weak references need to be processed _after_ the fix-point for weak properties.) The semantics of weak references in messages is that their target gets set to `null` if the target is not included in the message by a strong reference. The tests take particular care to exercise the case where a weak reference's target is only kept alive because a weak property key is alive and it refers to the target in its value. This exercises the fact that weak references need to be processed last. Does not add support for weak references in the app snapshot. It would be dead code until we start using weak references in for example the CFE. This CL does not try to unify weak references and weak properties in the GC or messaging (as proposed in go/dart-vm-weakreference), because their semantics differ enough. Closes: https://github.com/dart-lang/sdk/issues/48162 TEST=runtime/tests/vm/dart/finalizer/weak_reference_run_gc_test.dart TEST=runtime/tests/vm/dart/isolates/fast_object_copy_test.dart TEST=runtime/vm/object_test.cc TEST=tests/lib/isolate/weak_reference_message_1_test.dart TEST=tests/lib/isolate/weak_reference_message_2_test.dart Change-Id: I3810e919a5866f3ae8a95bd9aa23a880a0b0921c Cq-Include-Trybots: luci.dart.try:app-kernel-linux-debug-x64-try,dart-sdk-mac-arm64-try,vm-canary-linux-debug-try,vm-fuchsia-release-x64-try,vm-kernel-gcc-linux-try,vm-kernel-asan-linux-release-x64-try,vm-kernel-linux-debug-x64c-try,vm-kernel-linux-debug-x64-try,vm-kernel-linux-debug-simriscv64-try,vm-kernel-mac-debug-x64-try,vm-kernel-nnbd-linux-debug-x64-try,vm-kernel-nnbd-linux-release-ia32-try,vm-kernel-nnbd-linux-release-simarm64-try,vm-kernel-nnbd-linux-release-simarm-try,vm-kernel-nnbd-mac-debug-arm64-try,vm-kernel-nnbd-mac-debug-x64-try,vm-kernel-nnbd-win-release-ia32-try,vm-kernel-nnbd-win-release-x64-try,vm-kernel-optcounter-threshold-linux-release-x64-try,vm-kernel-precomp-android-release-arm_x64-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-debug-x64c-try,vm-kernel-precomp-win-debug-x64c-try,vm-kernel-reload-rollback-linux-debug-x64-try,vm-kernel-reload-linux-debug-x64-try,vm-kernel-win-debug-ia32-try,vm-kernel-win-debug-x64-try Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/232087 Reviewed-by: Ryan Macnak <rmacnak@google.com> Reviewed-by: Martin Kustermann <kustermann@google.com> Commit-Queue: Daco Harkes <dacoharkes@google.com> |
||
|
|
e57dae8df5 |
[vm/ffi] Implement IntPtr as AbiSpecificInteger
Closes: https://github.com/dart-lang/sdk/issues/47938 TEST=tests/ffi* Change-Id: I78cef41522813569f7e09ce31ce74ba615c070ed Cq-Include-Trybots: luci.dart.try:analyzer-linux-release-try,analyzer-nnbd-linux-release-try,app-kernel-linux-debug-x64-try,benchmark-linux-try,dart-sdk-linux-try,front-end-linux-release-x64-try,front-end-nnbd-linux-release-x64-try,pkg-linux-debug-try,vm-canary-linux-debug-try,vm-ffi-android-debug-arm-try,vm-ffi-android-debug-arm64c-try,vm-fuchsia-release-x64-try,vm-kernel-checked-linux-release-x64-try,vm-kernel-gcc-linux-try,vm-kernel-linux-debug-x64c-try,vm-kernel-mac-debug-x64-try,vm-kernel-asan-linux-release-x64-try,vm-kernel-msan-linux-release-x64-try,vm-kernel-nnbd-linux-debug-ia32-try,vm-kernel-nnbd-win-debug-x64-try,vm-kernel-nnbd-win-release-ia32-try,vm-kernel-nnbd-linux-debug-x64-try,vm-kernel-precomp-asan-linux-release-x64-try,vm-kernel-precomp-android-release-arm_x64-try,vm-kernel-precomp-android-release-arm64c-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-win-debug-x64c-try,vm-kernel-reload-linux-debug-x64-try,vm-kernel-reload-rollback-linux-debug-x64-try,vm-kernel-win-debug-ia32-try,vm-kernel-win-debug-x64-try,vm-precomp-ffi-qemu-linux-release-arm-try Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/227162 Reviewed-by: Martin Kustermann <kustermann@google.com> |
||
|
|
02549a8bce |
[vm/ffi] Optimize Pointer<T>.asTypedList()
This change refactors `_asExternalTypedData` into multiple functions, which are data type specific, e.g `_asExternalTypedDataInt8`. These functions are implemented as recognized methods. Argument checks have previously been performed in the removed runtime entry implementation of `_asExternalTypedData.` These are now handled in Dart. TEST=tests/ffi/external_typed_data_test.dart Closes https://github.com/dart-lang/sdk/issues/39843 Closes https://github.com/dart-lang/sdk/pull/47780 https://github.com/dart-lang/sdk/pull/47780 GitOrigin-RevId: 65763bddd06c633583b4adbf920c32c5a7a3720f Change-Id: I703b350d89004ebe36e70eaa44dda1d9ebb050c7 Cq-Include-Trybots: luci.dart.try:vm-kernel-reload-rollback-linux-debug-x64-try,vm-kernel-reload-linux-debug-x64-try,vm-precomp-ffi-qemu-linux-release-arm-try,vm-ffi-android-debug-arm64c-try,vm-ffi-android-debug-arm-try,app-kernel-linux-debug-x64-try,vm-kernel-nnbd-linux-debug-x64-try,vm-kernel-win-debug-x64-try,vm-kernel-nnbd-mac-debug-x64-try,vm-kernel-linux-debug-ia32-try Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/221360 Reviewed-by: Daco Harkes <dacoharkes@google.com> Commit-Queue: Daco Harkes <dacoharkes@google.com> |
||
|
|
757c2b82ce |
[vm/ffi] Add Bool
This CL adds the `Bool` `NativeType` with support for loading/storing from `Pointer<Bool>`, `Array<Bool>`, and `Struct` and `Union` fields, and support for passing booleans through FFI calls and callbacks. The assumption is that `bool` is always treated as `uint8_t` in the native ABIs. Including: (1) whether there can be garbage in the upper bytes in CPU registers, (2) stack alignment, and (3) alignment in compounds. The conversion from `bool` to `uint8_t` is implemented as follows: - bool to int: `value ? 1 : 0` - int to bool: `value != 0` The conversion is implemented in Dart in patch files for memory loads and stores (pointer, array, and struct fields) and kernel_to_il for FFI call and callback arguments and return value. TEST=runtime/vm/compiler/ffi/native_type_vm_test.cc TEST=tests/ffi/bool_test.dart TEST=tests/ffi/function_callbacks_structs_by_value_generated_test.dart TEST=tests/ffi/function_structs_by_value_generated_test.dart Closes: https://github.com/dart-lang/sdk/issues/36855 Change-Id: I75d100340ba41771abfb41c598ca92066a89370b Cq-Include-Trybots: luci.dart.try:vm-kernel-linux-debug-x64-try,vm-ffi-android-debug-arm-try,vm-kernel-mac-debug-x64-try,vm-kernel-nnbd-linux-debug-x64-try,vm-kernel-linux-debug-ia32-try,vm-kernel-precomp-linux-debug-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-ffi-android-debug-arm64c-try,vm-kernel-mac-release-arm64-try,vm-precomp-ffi-qemu-linux-release-arm-try,vm-kernel-precomp-android-release-arm64c-try,vm-kernel-precomp-android-release-arm_x64-try Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/216900 Commit-Queue: Daco Harkes <dacoharkes@google.com> Reviewed-by: Ryan Macnak <rmacnak@google.com> Reviewed-by: Clement Skau <cskau@google.com> |
||
|
|
ebcf042ed2 |
[vm] Remove kFfiPointerCid/kFfiDynamicLibraryCid
There have been duplicate cids * kPointerCid / kFfiPointerCid * kDynamicLibraryCid / kFfiDynamicLibraryCid Only one of each made sense. This CL ensures we have only the former. TEST=ci Change-Id: Icdcef40c80ed09815da6074a774a02c707f6be37 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/212592 Commit-Queue: Martin Kustermann <kustermann@google.com> Reviewed-by: Daco Harkes <dacoharkes@google.com> |
||
|
|
e8e9e1d152 |
[vm] Introduce immutable maps and sets in backend
This CL introduces immutable maps and sets in the VM backend but does not yet target them from the frontend. The changes are tested by unit tests constructing these immutable maps and sets. This CL introduces immutable variants of the hash map and set in compact_hash.dart and recognizes them in the VM. The immutable ones use a different mixin with a different recognized method for accessing members. * Data list is an immutable list with a different cid. (Otherwise the optimizer notices that immutable and mutable lists cannot be equal.) * Index is a nullable mutable typed data. (Otherwise optimizer removes necessary null checks.) * Index should use a store-release barrier when written to. Multiple isolates might lazily compute the index for const sets and maps. This is fine because all identityHashCodes and hashCodes are guaranteed to be race-free. The later isolates will override the index pointer with an identical index. This CL does not introduce support for using these immutable maps and sets in AOT (clustered_snapshot) and in messages to other isolates (message_snapshot) because that is harder to test with unit tests. That will be added in the follow-up CL. Design doc: go/dart-vm-const-maps TEST=runtime/vm/object_test.cc Bug: https://github.com/dart-lang/sdk/issues/45908 Change-Id: I4042179c15e8b37692d3255655351c01c7124991 Cq-Include-Trybots: luci.dart.try:analyzer-nnbd-linux-release-try,app-kernel-linux-debug-x64-try,dart-sdk-linux-try,front-end-nnbd-linux-release-x64-try,pkg-linux-debug-try,vm-canary-linux-debug-try,vm-kernel-asan-linux-release-x64-try,vm-kernel-checked-linux-release-x64-try,vm-kernel-linux-debug-x64c-try,vm-kernel-linux-debug-x64-try,vm-kernel-linux-debug-simarm64c-try,vm-kernel-nnbd-linux-release-simarm-try,vm-kernel-optcounter-threshold-linux-release-x64-try,vm-kernel-precomp-android-release-arm_x64-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-debug-x64c-try,vm-kernel-reload-linux-debug-x64-try,vm-kernel-reload-rollback-linux-debug-x64-try,vm-precomp-ffi-qemu-linux-release-arm-try,vm-kernel-precomp-linux-debug-simarm_x64-try,vm-kernel-precomp-linux-debug-x64-try Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/210860 Reviewed-by: Martin Kustermann <kustermann@google.com> |
||
|
|
bc387837c4 |
[VM/Runtime] Reland : Fix 'File' object leak in async file open operation
The 'File' object created in the async file open method is leaked if the operation is not completed when the isolate shuts down with an unhandled exception. This change adds a finalizable state for the 'File' object so that the message deletion that happens when ports are closed could run the callback to clean up the 'File' object. TEST=new tests added Change-Id: I64c18a7905261b0fc7bf9f220086791478232d0d Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/211340 Reviewed-by: Alexander Aprelev <aam@google.com> Commit-Queue: Siva Annamalai <asiva@google.com> |
||
|
|
637e14006c |
Revert "[VM/Runtime] Fix 'File' object leak in async file open operation"
This reverts commit
|
||
|
|
b67f45f955 |
[VM/Runtime] Fix 'File' object leak in async file open operation
The 'File' object created in the async file open method is leaked if the operation is not completed when the isolate shuts down with an unhandled exception. This change adds a finalizable state for the 'File' object so that the message deletion that happens when ports are closed could run the callback to clean up the 'File' object. TEST=new tests added Change-Id: I4a3cb28370d27306c795c1914aeb5c18a1d85e2b Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/210761 Reviewed-by: Alexander Aprelev <aam@google.com> Commit-Queue: Siva Annamalai <asiva@google.com> |
||
|
|
cfb057ddca |
Reland "[vm] Hide internal implementation List types and expose them as List"
This is a reland of
|
||
|
|
16ff4aec0e |
Revert "[vm] Hide internal implementation List types and expose them as List"
This reverts commit
|
||
|
|
cd6fb67103 |
[vm] Clean up changes around internal-only class ids.
* IsInternalOnlyId -> IsInternalOnlyClassId * Removes constexpr predicate ClassComesBeforeOtherInternalOnlyClasses() used in only two locations and inlines the returned condition. * Change IsErrorClassId to check <= kUnwindErrorCid instead of <= kLastInternalOnlyCid. TEST=Refactoring, so existing tests. Change-Id: Ib7dfc89aba16d52733de05687f0ca7055c16e7a3 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/210126 Auto-Submit: Tess Strickland <sstrickl@google.com> Commit-Queue: Tess Strickland <sstrickl@google.com> Commit-Queue: Alexander Markov <alexmarkov@google.com> Reviewed-by: Alexander Markov <alexmarkov@google.com> |
||
|
|
824bec596f |
[vm] Hide internal implementation List types and expose them as List
When taking a type of an instance with x.runtimeType we can map internal classes _List, _ImmutableList and _GrowableList to a user-visible List class. This is similar to what we do for implementation classes of int, String and Type. After that, result of x.runtimeType for built-in lists would be compatible with List<T> type literals. Also, both intrinsic and native implementations of _haveSameRuntimeType are updated to agree with new semantic of runtimeType. TEST=co19/LanguageFeatures/Constructor-tear-offs/type_literal_A01_t01 TEST=runtime/tests/vm/dart/have_same_runtime_type_test Fixes https://github.com/dart-lang/sdk/issues/46893 Issue https://github.com/dart-lang/sdk/issues/46231 Change-Id: Ie24a9f527f66a06118427b7a09e49c03dff93d8e Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/210066 Commit-Queue: Alexander Markov <alexmarkov@google.com> Reviewed-by: Tess Strickland <sstrickl@google.com> |
||
|
|
e8ddc0219f |
[vm] Abstract out internal-only cid ordering.
* Adds IsInternalOnlyCid, which replaces the old `cid < kInstanceCid`
check.
* Adds kFirstInternalOnlyCid and kLastInternalOnlyCid, which should be
used in places that loop over the internal-only cids.
* Adds ObjectComesBeforeOtherInternalOnlyClasses(), which can be used
with COMPILE_ASSERT in places that assume kObjectCid immediately
precedes the other internal-only cids.
* Replaces assumption in IsErrorId() that Instance immediately follows
the internal-only cids with an assumption that the current last error
cid is the same as kLastInternalOnlyCid.
* Separates out CLASS_LIST_NO_OBJECT_NOR_STRING_... into two pieces to
make it clearer where to add new internal-only cids and where to add
new Instance cids:
* CLASS_LIST_INTERNAL_ONLY, which contains class ids for real
classes that are VM internal, except for Object.
* CLASS_LIST_INSTANCE_SINGLETONS, which contains class ids for
subclasses of Instance that are not part of a separately handled
group of cids.
TEST=Refactoring, so existing tests.
Change-Id: I9905d5928a592164d58de1f121b9ce669f2b3ce1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/210122
Commit-Queue: Tess Strickland <sstrickl@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
|
||
|
|
483179c934 |
[vm] Recognize non-const Set in the VM
`_CompactLinkedHashSet` now extends `_HashVMBase`. The class hierarchy is organized as mixins similar to LinkedHashMap to accomodate for the other Sets not extending `_HashVMBase`. Also, rearranges some code so that introducing ImmutableHashMap and ImmutableHashSet is easier. 1) snapshot.h and snapshot.cc now have a MapReadFrom, MapWriteTo, SetReadFrom, and SetWriteTo to facilitate code sharing between mutable and immutable implementations similar to ArrayReadFrom and ArrayWriteTo. 2) Macros for CLASS_LIST_MAPS and CLASS_LIST_SETS to facilitate treating mutable and immutable implementations with the same handle. Also similar to Array. Clustered snapshots for HashMaps is currently dead code. This CL makes it explicit by marking these as unreachable. Immutable maps and sets will end up in the clustered snapshot in follow up CLs. Bug: https://github.com/dart-lang/sdk/issues/36077 Bug: https://github.com/dart-lang/sdk/issues/45908 TEST=runtime/vm/object_test.cc TEST=tests/**_test.dart on many bots Change-Id: If3cc5ebb3138535aeb0d5e06d9da3d1c9fb2deb2 Cq-Include-Trybots: luci.dart.try:analyzer-nnbd-linux-release-try,app-kernel-linux-debug-x64-try,dart-sdk-linux-try,front-end-nnbd-linux-release-x64-try,pkg-linux-debug-try,vm-canary-linux-debug-try,vm-kernel-asan-linux-release-x64-try,vm-kernel-checked-linux-release-x64-try,vm-kernel-linux-debug-x64c-try,vm-kernel-linux-debug-x64-try,vm-kernel-linux-debug-simarm64c-try,vm-kernel-nnbd-linux-release-simarm-try,vm-kernel-optcounter-threshold-linux-release-x64-try,vm-kernel-precomp-android-release-arm_x64-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-debug-x64c-try,vm-kernel-reload-linux-debug-x64-try,vm-kernel-reload-rollback-linux-debug-x64-try,vm-precomp-ffi-qemu-linux-release-arm-try,vm-kernel-precomp-linux-release-simarm_x64-try,vm-kernel-precomp-linux-debug-x64-try Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/206222 Reviewed-by: Tess Strickland <sstrickl@google.com> Reviewed-by: Ben Konyi <bkonyi@google.com> |
||
|
|
00d6b8972a |
[vm] Separate class for sentinel objects
This change adds a new VM-internal class for sentinel objects. Previously sentinel objects used class Never. TEST=existing tests Issue: https://github.com/dart-lang/sdk/issues/46141 Change-Id: Ibb3361092967132f4f1952d64fe0168659f3075e Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/202870 Commit-Queue: Alexander Markov <alexmarkov@google.com> Reviewed-by: Ryan Macnak <rmacnak@google.com> |
||
|
|
69167e2bdb |
[vm/compiler] Recognize and propagate "value can be sentinel" property
This change adds can_be_sentinel() flag to CompileType and prevents unboxing of phis which can be sentinel. This flag means that set of values can potentially contain Object::sentinel() which is used as a marker for the uninitialized value of late variables. TEST=runtime/tests/vm/dart/regress_46141_test.dart Fixes https://github.com/dart-lang/sdk/issues/46141 Change-Id: I32f19488f54c6f69932584ecec3094e3b78cc0d0 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/201600 Reviewed-by: Slava Egorov <vegorov@google.com> Commit-Queue: Alexander Markov <alexmarkov@google.com> |