From 896675c462df4f2c9bd9dc66fca3442b203863cd Mon Sep 17 00:00:00 2001 From: Martin Kustermann Date: Wed, 7 Dec 2022 00:48:28 +0000 Subject: [PATCH] [vm] Always share double/float32x4/float64x2/int32x4 in inter-isolate messages The JIT support for dynamically unboxing has been removed in [0]. As such all double/float32x4/float64x2/int32x4 objects are immutable and can therefore be shared across isolates. [0] https://dart-review.googlesource.com/c/sdk/+/256211 TEST=ci Change-Id: Ifd4e7c2444415b2e3b5269d9fbeb6570cc5d6768 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/273680 Reviewed-by: Ryan Macnak Commit-Queue: Martin Kustermann Reviewed-by: Alexander Aprelev --- .../vm/dart/isolates/fast_object_copy2_test.dart | 5 ++--- .../dart_2/isolates/fast_object_copy2_test.dart | 5 ++--- runtime/vm/object_graph_copy.cc | 16 ++-------------- 3 files changed, 6 insertions(+), 20 deletions(-) diff --git a/runtime/tests/vm/dart/isolates/fast_object_copy2_test.dart b/runtime/tests/vm/dart/isolates/fast_object_copy2_test.dart index 76e5679df3f..8ec58da1dca 100644 --- a/runtime/tests/vm/dart/isolates/fast_object_copy2_test.dart +++ b/runtime/tests/vm/dart/isolates/fast_object_copy2_test.dart @@ -7,9 +7,6 @@ // VMOptions=--no-enable-fast-object-copy --gc-on-foc-slow-path --force-evacuation // VMOptions=--enable-fast-object-copy --gc-on-foc-slow-path --force-evacuation -// The tests in this file will only succeed when isolate groups are enabled -// (hence the VMOptions above). - import 'dart:async'; import 'dart:isolate'; import 'dart:typed_data'; @@ -75,6 +72,8 @@ final sharableObjects = [ const {1, 2, 3}, Isolate.current.pauseCapability, Int32x4(1, 2, 3, 4), + Float32x4(1.0, 2.0, 3.0, 4.0), + Float64x2(1.0, 2.0), StackTrace.current, ]; diff --git a/runtime/tests/vm/dart_2/isolates/fast_object_copy2_test.dart b/runtime/tests/vm/dart_2/isolates/fast_object_copy2_test.dart index 0c48bc018b2..a52bd160e87 100644 --- a/runtime/tests/vm/dart_2/isolates/fast_object_copy2_test.dart +++ b/runtime/tests/vm/dart_2/isolates/fast_object_copy2_test.dart @@ -9,9 +9,6 @@ // VMOptions=--no-enable-fast-object-copy --gc-on-foc-slow-path --force-evacuation // VMOptions=--enable-fast-object-copy --gc-on-foc-slow-path --force-evacuation -// The tests in this file will only succeed when isolate groups are enabled -// (hence the VMOptions above). - import 'dart:async'; import 'dart:isolate'; import 'dart:typed_data'; @@ -76,6 +73,8 @@ final sharableObjects = [ const {1, 2, 3}, Isolate.current.pauseCapability, Int32x4(1, 2, 3, 4), + Float32x4(1.0, 2.0, 3.0, 4.0), + Float64x2(1.0, 2.0), StackTrace.current, ]; diff --git a/runtime/vm/object_graph_copy.cc b/runtime/vm/object_graph_copy.cc index b6e102d3f02..2fc3446cd6e 100644 --- a/runtime/vm/object_graph_copy.cc +++ b/runtime/vm/object_graph_copy.cc @@ -159,15 +159,10 @@ static bool CanShareObject(ObjectPtr obj, uword tags) { if (cid == kNeverCid) return true; if (cid == kSentinelCid) return true; if (cid == kStackTraceCid) return true; -#if defined(DART_PRECOMPILED_RUNTIME) - // In JIT mode we have field guards enabled which means - // double/float32x4/float64x2 boxes can be mutable and we therefore cannot - // share them. - if (cid == kDoubleCid || cid == kFloat32x4Cid || cid == kFloat64x2Cid) { + if (cid == kDoubleCid || cid == kFloat32x4Cid || cid == kFloat64x2Cid || + cid == kInt32x4Cid) { return true; } -#endif - if (cid == kInt32x4Cid) return true; // No field guards here. if (cid == kSendPortCid) return true; if (cid == kCapabilityCid) return true; @@ -227,13 +222,6 @@ static bool MightNeedReHashing(ObjectPtr object) { #endif if (cid == kInt32x4Cid) return false; - // We copy those (instead of sharing them) - see [CanShareObjct]. They rely - // on the default hashCode implementation which uses identity hash codes - // (instead of structural hash code). - if (cid == kFloat32x4Cid || cid == kFloat64x2Cid) { - return !kDartPrecompiledRuntime; - } - // If the [tags] indicates this is a canonical object we'll share it instead // of copying it. That would suggest we don't have to re-hash maps/sets // containing this object on the receiver side.