Skip to content

Commit 8f1c524

Browse files
modulovaluedart-scoped@luci-project-accounts.iam.gserviceaccount.com
authored andcommitted
[vm] Finish Int32x4 unboxing, symmetric to the float SIMD value types
Fixes SimdFields: i32x4Field goes 2409us -> 475us in AOT and 2838us -> 730us in JIT. TEST=vm/cc/IsolateReload_ExistingInt32x4FieldUnboxedToUnboxed Issue: #64170 Change-Id: I645f80a795e12f8c9d0de75b95b2163c6c04c6ec Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/543040 Commit-Queue: Slava Egorov <vegorov@google.com> Reviewed-by: Martin Kustermann <kustermann@google.com> Auto-Submit: Modestas Valauskas <valauskasmodestas@gmail.com> Reviewed-by: Slava Egorov <vegorov@google.com>
1 parent db24e48 commit 8f1c524

17 files changed

Lines changed: 1509 additions & 1392 deletions

‎pkg/native_compiler/lib/runtime/vm_offsets.g.dart‎

Lines changed: 85 additions & 83 deletions
Large diffs are not rendered by default.

‎runtime/vm/analyze_snapshot_api_impl.cc‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,8 @@ void SnapshotAnalyzer::DumpClassInstanceSlots(
217217
slots = sizeof(simd128_value_t) / kCompressedWordSize;
218218
} else if (type.IsFloat64x2Type()) {
219219
slots = sizeof(simd128_value_t) / kCompressedWordSize;
220+
} else if (type.IsInt32x4Type()) {
221+
slots = sizeof(simd128_value_t) / kCompressedWordSize;
220222
} else {
221223
// Rare: Could be that the field type isn't telling us the unboxed
222224
// type but field is still unboxed (e.g. `dynamic` field which TFA
@@ -382,6 +384,8 @@ void SnapshotAnalyzer::DumpField(const Field& field) {
382384
unboxed_type = "Float32x4";
383385
} else if (type.IsFloat64x2Type()) {
384386
unboxed_type = "Float64x2";
387+
} else if (type.IsInt32x4Type()) {
388+
unboxed_type = "Int32x4";
385389
} else {
386390
unboxed_type = "unknown";
387391
}

‎runtime/vm/compiler/backend/flow_graph_compiler.cc‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -524,6 +524,9 @@ void FlowGraphCompiler::EmitInstructionEpilogue(Instruction* instr) {
524524
case kUnboxedFloat64x2:
525525
stub = &StubCode::BoxFloat64x2();
526526
break;
527+
case kUnboxedInt32x4:
528+
stub = &StubCode::BoxInt32x4();
529+
break;
527530
default:
528531
UNREACHABLE();
529532
break;
@@ -1774,6 +1777,7 @@ void FlowGraphCompiler::AllocateRegistersLocally(Instruction* instr) {
17741777
break;
17751778
case kUnboxedFloat32x4:
17761779
case kUnboxedFloat64x2:
1780+
case kUnboxedInt32x4:
17771781
ASSERT(fpu_reg != kNoFpuRegister);
17781782
assembler()->LoadUnboxedSimd128(
17791783
fpu_reg, reg,
@@ -3030,7 +3034,7 @@ void FlowGraphCompiler::FrameStatePush(Definition* defn) {
30303034
Representation rep = defn->representation();
30313035
ASSERT(!is_optimizing());
30323036
if ((rep == kUnboxedDouble || rep == kUnboxedFloat32x4 ||
3033-
rep == kUnboxedFloat64x2) &&
3037+
rep == kUnboxedFloat64x2 || rep == kUnboxedInt32x4) &&
30343038
defn->locs()->out(0).IsFpuRegister()) {
30353039
// Output value is boxed in the instruction epilogue.
30363040
rep = kTagged;

‎runtime/vm/compiler/backend/il.cc‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4823,6 +4823,7 @@ void LoadFieldInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
48234823
break;
48244824
case kFloat32x4Cid:
48254825
case kFloat64x2Cid:
4826+
case kInt32x4Cid:
48264827
__ LoadUnboxedSimd128(result, instance_reg,
48274828
OffsetInBytes() - kHeapObjectTag);
48284829
break;
@@ -6430,7 +6431,8 @@ void BoxAllocationSlowPath::EmitNativeCode(FlowGraphCompiler* compiler) {
64306431
ASSERT(!kAllocateMintRuntimeEntry.can_lazy_deopt() &&
64316432
!kAllocateDoubleRuntimeEntry.can_lazy_deopt() &&
64326433
!kAllocateFloat32x4RuntimeEntry.can_lazy_deopt() &&
6433-
!kAllocateFloat64x2RuntimeEntry.can_lazy_deopt());
6434+
!kAllocateFloat64x2RuntimeEntry.can_lazy_deopt() &&
6435+
!kAllocateInt32x4RuntimeEntry.can_lazy_deopt());
64346436
compiler->GenerateNonLazyDeoptableStubCall(
64356437
InstructionSource(), // No token position.
64366438
stub, UntaggedPcDescriptors::kOther, locs);
@@ -8275,6 +8277,7 @@ void StoreFieldInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
82758277
return;
82768278
case kFloat32x4Cid:
82778279
case kFloat64x2Cid:
8280+
case kInt32x4Cid:
82788281
__ StoreUnboxedSimd128(value, instance_reg,
82798282
OffsetInBytes() - kHeapObjectTag);
82808283
return;

‎runtime/vm/compiler/backend/slot.cc‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,9 @@ const Slot& Slot::Get(const Field& field,
438438
case kFloat64x2Cid:
439439
rep = kUnboxedFloat64x2;
440440
break;
441+
case kInt32x4Cid:
442+
rep = kUnboxedInt32x4;
443+
break;
441444
default:
442445
rep = kUnboxedInt64;
443446
break;

‎runtime/vm/compiler/runtime_api.cc‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1068,6 +1068,10 @@ void UnboxFieldIfSupported(const dart::Field& field,
10681068
if (FlowGraphCompiler::SupportsUnboxedSimd128()) {
10691069
cid = kFloat64x2Cid;
10701070
}
1071+
} else if (type.IsInt32x4Type()) {
1072+
if (FlowGraphCompiler::SupportsUnboxedSimd128()) {
1073+
cid = kInt32x4Cid;
1074+
}
10711075
}
10721076

10731077
if (cid != kIllegalCid) {

‎runtime/vm/compiler/runtime_offsets_extracted.h‎

Lines changed: 1306 additions & 1306 deletions
Large diffs are not rendered by default.

‎runtime/vm/compiler/stub_code_compiler.cc‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1850,6 +1850,16 @@ void StubCodeCompiler::GenerateBoxFloat64x2Stub() {
18501850
#endif
18511851
}
18521852

1853+
void StubCodeCompiler::GenerateBoxInt32x4Stub() {
1854+
#if !defined(TARGET_ARCH_RISCV32) && !defined(TARGET_ARCH_RISCV64)
1855+
GenerateBoxFpuValueStub(assembler, compiler::Int32x4Class(),
1856+
kBoxInt32x4RuntimeEntry,
1857+
&Assembler::StoreUnboxedSimd128);
1858+
#else
1859+
__ Stop("Not supported on RISC-V.");
1860+
#endif
1861+
}
1862+
18531863
void StubCodeCompiler::GenerateDoubleToIntegerStub() {
18541864
__ EnterStubFrame();
18551865
__ StoreUnboxedDouble(DoubleToIntegerStubABI::kInputReg, THR,

‎runtime/vm/interpreter.cc‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2867,6 +2867,14 @@ ObjectPtr Interpreter::Run(Thread* thread,
28672867
offset_in_words) = raw_value;
28682868
break;
28692869
}
2870+
case kInt32x4Cid: {
2871+
simd128_value_t raw_value;
2872+
raw_value.readFrom(Int32x4::RawCast(value)->untag()->value_);
2873+
*reinterpret_cast<simd128_value_t*>(
2874+
reinterpret_cast<CompressedObjectPtr*>(instance->untag()) +
2875+
offset_in_words) = raw_value;
2876+
break;
2877+
}
28702878
default: {
28712879
int64_t raw_value = Integer::Value(Integer::RawCast(value));
28722880
*reinterpret_cast<int64_t*>(

‎runtime/vm/isolate_reload.cc‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ InstanceMorpher* InstanceMorpher::CreateFromClassDescriptors(
172172
case kDoubleCid:
173173
case kFloat32x4Cid:
174174
case kFloat64x2Cid:
175+
case kInt32x4Cid:
175176
from_box_cid = field_cid;
176177
break;
177178
default:
@@ -186,6 +187,7 @@ InstanceMorpher* InstanceMorpher::CreateFromClassDescriptors(
186187
case kDoubleCid:
187188
case kFloat32x4Cid:
188189
case kFloat64x2Cid:
190+
case kInt32x4Cid:
189191
to_box_cid = field_cid;
190192
break;
191193
default:
@@ -310,6 +312,12 @@ void InstanceMorpher::CreateMorphedCopies(Become* become) {
310312
value = Float64x2::New(unboxed_value);
311313
break;
312314
}
315+
case kInt32x4Cid: {
316+
const auto unboxed_value =
317+
before.RawGetUnboxedFieldAtOffset<simd128_value_t>(from.offset);
318+
value = Int32x4::New(unboxed_value);
319+
break;
320+
}
313321
case kIntegerCid: {
314322
const auto unboxed_value =
315323
before.RawGetUnboxedFieldAtOffset<int64_t>(from.offset);
@@ -332,7 +340,8 @@ void InstanceMorpher::CreateMorphedCopies(Become* become) {
332340
break;
333341
}
334342
case kFloat32x4Cid:
335-
case kFloat64x2Cid: {
343+
case kFloat64x2Cid:
344+
case kInt32x4Cid: {
336345
const auto unboxed_value =
337346
before.RawGetUnboxedFieldAtOffset<simd128_value_t>(from.offset);
338347
after.RawSetUnboxedFieldAtOffset<simd128_value_t>(to.offset,
@@ -371,6 +380,8 @@ static const char* BoxCidToCString(intptr_t box_cid) {
371380
return "float32x4";
372381
case kFloat64x2Cid:
373382
return "float64x2";
383+
case kInt32x4Cid:
384+
return "int32x4";
374385
case kIntegerCid:
375386
return "int64";
376387
}

0 commit comments

Comments
 (0)