Skip to content

Commit

Permalink
[vm,compiler] Support SIMD constants in IL serialization
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
alexmarkov authored and Commit Queue committed Dec 19, 2024
1 parent 3ba5bd0 commit da257d2
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 0 deletions.
1 change: 1 addition & 0 deletions runtime/tests/vm/dart/isolates/fast_object_copy2_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
// VMOptions=--enable-fast-object-copy
// 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
// VMOptions=--test_il_serialization

import 'dart:async';
import 'dart:ffi';
Expand Down
45 changes: 45 additions & 0 deletions runtime/vm/compiler/backend/il_serializer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1600,6 +1600,18 @@ void FlowGraphSerializer::WriteObjectImpl(const Object& x,
ASSERT(x.IsCanonical());
Write<double>(Double::Cast(x).value());
break;
case kFloat32x4Cid:
ASSERT(x.IsCanonical());
Write<simd128_value_t>(Float32x4::Cast(x).value());
break;
case kFloat64x2Cid:
ASSERT(x.IsCanonical());
Write<simd128_value_t>(Float64x2::Cast(x).value());
break;
case kInt32x4Cid:
ASSERT(x.IsCanonical());
Write<simd128_value_t>(Int32x4::Cast(x).value());
break;
case kFieldCid: {
const auto& field = Field::Cast(x);
const auto& owner = Class::Handle(Z, field.Owner());
Expand Down Expand Up @@ -1877,6 +1889,24 @@ const Object& FlowGraphDeserializer::ReadObjectImpl(intptr_t cid,
}
case kDoubleCid:
return Double::ZoneHandle(Z, Double::NewCanonical(Read<double>()));
case kFloat32x4Cid: {
auto& simd_value =
Float32x4::ZoneHandle(Z, Float32x4::New(Read<simd128_value_t>()));
simd_value ^= simd_value.Canonicalize(thread());
return simd_value;
}
case kFloat64x2Cid: {
auto& simd_value =
Float64x2::ZoneHandle(Z, Float64x2::New(Read<simd128_value_t>()));
simd_value ^= simd_value.Canonicalize(thread());
return simd_value;
}
case kInt32x4Cid: {
auto& simd_value =
Int32x4::ZoneHandle(Z, Int32x4::New(Read<simd128_value_t>()));
simd_value ^= simd_value.Canonicalize(thread());
return simd_value;
}
case kFieldCid: {
const classid_t owner_class_id = Read<classid_t>();
const intptr_t field_index = Read<intptr_t>();
Expand Down Expand Up @@ -2290,6 +2320,21 @@ Representation FlowGraphDeserializer::ReadTrait<Representation>::Read(
return static_cast<Representation>(d->Read<uint8_t>());
}

template <>
void FlowGraphSerializer::WriteTrait<simd128_value_t>::Write(
FlowGraphSerializer* s,
simd128_value_t x) {
s->stream()->WriteBytes(&x, sizeof(simd128_value_t));
}

template <>
simd128_value_t FlowGraphDeserializer::ReadTrait<simd128_value_t>::Read(
FlowGraphDeserializer* d) {
simd128_value_t value;
d->stream()->ReadBytes(&value, sizeof(simd128_value_t));
return value;
}

template <>
void FlowGraphSerializer::WriteTrait<const Slot&>::Write(FlowGraphSerializer* s,
const Slot& x) {
Expand Down
1 change: 1 addition & 0 deletions runtime/vm/compiler/backend/il_serializer.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ class NativeCallingConvention;
V(Range*) \
V(RecordShape) \
V(Representation) \
V(simd128_value_t) \
V(const Slot&) \
V(const Slot*) \
V(const String&) \
Expand Down

0 comments on commit da257d2

Please sign in to comment.