[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>
This commit is contained in:
committed by
Commit Queue
parent
9ba8663773
commit
9c69bc4c6d
@@ -18,9 +18,12 @@ import 'package:ffi/ffi.dart';
|
||||
import 'fast_object_copy_test.dart'
|
||||
show UserObject, SendReceiveTestBase, notAllocatableInTLAB;
|
||||
|
||||
typedef TypeLiteral<T> = T;
|
||||
|
||||
topLevelClosure(a, b) {}
|
||||
topLevelClosureG<T>(T a, T b) {}
|
||||
Type getType<T>() => T;
|
||||
Type invokeWithType<T>(Type Function<T>() fun) => fun<T>();
|
||||
|
||||
class A<T> {
|
||||
dynamic m<H>(T a, H b) => this;
|
||||
@@ -67,8 +70,27 @@ final sharableObjects = [
|
||||
final Function(int, int) partialInstantiatedInnerClosure = topLevelClosureG;
|
||||
return partialInstantiatedInnerClosure;
|
||||
}(),
|
||||
|
||||
// Types: Type literal constants
|
||||
getType<int>(),
|
||||
getType<(int, double, Object)>(),
|
||||
getType<void Function(int, double, Object)>(),
|
||||
getType<T Function<T>(int, double, T)>(),
|
||||
|
||||
// Types: Instantiated & canonicalized types.
|
||||
invokeWithType<int>(<T>() => getType<T>()),
|
||||
invokeWithType<int>(<T>() => getType<(T, T)>()),
|
||||
invokeWithType<int>(<T>() => getType<List<T>>()),
|
||||
invokeWithType<int>(<T>() => getType<T Function(T, T)>()),
|
||||
invokeWithType<int>(<T>() => getType<H Function<H>(T, T)>()),
|
||||
|
||||
// Types: Instantiated but non-canonicalized types.
|
||||
invokeWithType<int>(<T>() => TypeLiteral<T>),
|
||||
invokeWithType<int>(<T>() => TypeLiteral<(T, T)>),
|
||||
invokeWithType<int>(<T>() => TypeLiteral<List<T>>),
|
||||
invokeWithType<int>(<T>() => TypeLiteral<T Function(T, T)>),
|
||||
invokeWithType<int>(<T>() => TypeLiteral<H Function<H>(T, T)>),
|
||||
|
||||
const [1, 2, 3],
|
||||
const {1: 1, 2: 2, 3: 2},
|
||||
const {1, 2, 3},
|
||||
|
||||
@@ -475,7 +475,8 @@ inline bool ShouldHaveImmutabilityBitSet(intptr_t index) {
|
||||
index == kFloat32x4Cid || index == kFloat64x2Cid ||
|
||||
index == kInt32x4Cid || index == kSendPortCid ||
|
||||
index == kCapabilityCid || index == kRegExpCid || index == kBoolCid ||
|
||||
index == kNullCid || index == kPointerCid;
|
||||
index == kNullCid || index == kPointerCid || index == kTypeCid ||
|
||||
index == kRecordTypeCid || index == kFunctionTypeCid;
|
||||
}
|
||||
|
||||
inline bool IsFfiTypeClassId(intptr_t index) {
|
||||
|
||||
Reference in New Issue
Block a user