Skip to content

Commit da257d2

Browse files
alexmarkovCommit Queue
authored andcommitted
[vm,compiler] Support SIMD constants in IL serialization
TEST=vm/dart/isolates/fast_object_copy2_test Change-Id: I934d92f54f9ab51bbdd42edd90588d404bc9be37 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/401920 Reviewed-by: Alexander Aprelev <[email protected]> Commit-Queue: Alexander Markov <[email protected]>
1 parent 3ba5bd0 commit da257d2

File tree

3 files changed

+47
-0
lines changed

3 files changed

+47
-0
lines changed

runtime/tests/vm/dart/isolates/fast_object_copy2_test.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
// VMOptions=--enable-fast-object-copy
77
// VMOptions=--no-enable-fast-object-copy --gc-on-foc-slow-path --force-evacuation
88
// VMOptions=--enable-fast-object-copy --gc-on-foc-slow-path --force-evacuation
9+
// VMOptions=--test_il_serialization
910

1011
import 'dart:async';
1112
import 'dart:ffi';

runtime/vm/compiler/backend/il_serializer.cc

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1600,6 +1600,18 @@ void FlowGraphSerializer::WriteObjectImpl(const Object& x,
16001600
ASSERT(x.IsCanonical());
16011601
Write<double>(Double::Cast(x).value());
16021602
break;
1603+
case kFloat32x4Cid:
1604+
ASSERT(x.IsCanonical());
1605+
Write<simd128_value_t>(Float32x4::Cast(x).value());
1606+
break;
1607+
case kFloat64x2Cid:
1608+
ASSERT(x.IsCanonical());
1609+
Write<simd128_value_t>(Float64x2::Cast(x).value());
1610+
break;
1611+
case kInt32x4Cid:
1612+
ASSERT(x.IsCanonical());
1613+
Write<simd128_value_t>(Int32x4::Cast(x).value());
1614+
break;
16031615
case kFieldCid: {
16041616
const auto& field = Field::Cast(x);
16051617
const auto& owner = Class::Handle(Z, field.Owner());
@@ -1877,6 +1889,24 @@ const Object& FlowGraphDeserializer::ReadObjectImpl(intptr_t cid,
18771889
}
18781890
case kDoubleCid:
18791891
return Double::ZoneHandle(Z, Double::NewCanonical(Read<double>()));
1892+
case kFloat32x4Cid: {
1893+
auto& simd_value =
1894+
Float32x4::ZoneHandle(Z, Float32x4::New(Read<simd128_value_t>()));
1895+
simd_value ^= simd_value.Canonicalize(thread());
1896+
return simd_value;
1897+
}
1898+
case kFloat64x2Cid: {
1899+
auto& simd_value =
1900+
Float64x2::ZoneHandle(Z, Float64x2::New(Read<simd128_value_t>()));
1901+
simd_value ^= simd_value.Canonicalize(thread());
1902+
return simd_value;
1903+
}
1904+
case kInt32x4Cid: {
1905+
auto& simd_value =
1906+
Int32x4::ZoneHandle(Z, Int32x4::New(Read<simd128_value_t>()));
1907+
simd_value ^= simd_value.Canonicalize(thread());
1908+
return simd_value;
1909+
}
18801910
case kFieldCid: {
18811911
const classid_t owner_class_id = Read<classid_t>();
18821912
const intptr_t field_index = Read<intptr_t>();
@@ -2290,6 +2320,21 @@ Representation FlowGraphDeserializer::ReadTrait<Representation>::Read(
22902320
return static_cast<Representation>(d->Read<uint8_t>());
22912321
}
22922322

2323+
template <>
2324+
void FlowGraphSerializer::WriteTrait<simd128_value_t>::Write(
2325+
FlowGraphSerializer* s,
2326+
simd128_value_t x) {
2327+
s->stream()->WriteBytes(&x, sizeof(simd128_value_t));
2328+
}
2329+
2330+
template <>
2331+
simd128_value_t FlowGraphDeserializer::ReadTrait<simd128_value_t>::Read(
2332+
FlowGraphDeserializer* d) {
2333+
simd128_value_t value;
2334+
d->stream()->ReadBytes(&value, sizeof(simd128_value_t));
2335+
return value;
2336+
}
2337+
22932338
template <>
22942339
void FlowGraphSerializer::WriteTrait<const Slot&>::Write(FlowGraphSerializer* s,
22952340
const Slot& x) {

runtime/vm/compiler/backend/il_serializer.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ class NativeCallingConvention;
109109
V(Range*) \
110110
V(RecordShape) \
111111
V(Representation) \
112+
V(simd128_value_t) \
112113
V(const Slot&) \
113114
V(const Slot*) \
114115
V(const String&) \

0 commit comments

Comments
 (0)