@@ -1990,6 +1990,7 @@ void Compiler::compInit(ArenaAllocator* pAlloc,
1990
1990
m_outlinedCompositeSsaNums = nullptr ;
1991
1991
m_nodeToLoopMemoryBlockMap = nullptr ;
1992
1992
m_signatureToLookupInfoMap = nullptr ;
1993
+ m_significantSegmentsMap = nullptr ;
1993
1994
fgSsaPassesCompleted = 0 ;
1994
1995
fgSsaValid = false ;
1995
1996
fgVNPassesCompleted = 0 ;
@@ -8373,6 +8374,67 @@ void Compiler::TransferTestDataToNode(GenTree* from, GenTree* to)
8373
8374
8374
8375
#endif // DEBUG
8375
8376
8377
+ // ------------------------------------------------------------------------
8378
+ // GetSignificantSegments:
8379
+ // Compute a segment tree containing all significant (non-padding) segments
8380
+ // for the specified class layout.
8381
+ //
8382
+ // Parameters:
8383
+ // layout - The layout
8384
+ //
8385
+ // Returns:
8386
+ // Segment tree containing all significant parts of the layout.
8387
+ //
8388
+ const StructSegments& Compiler::GetSignificantSegments (ClassLayout* layout)
8389
+ {
8390
+ StructSegments* cached;
8391
+ if ((m_significantSegmentsMap != nullptr ) && m_significantSegmentsMap->Lookup (layout, &cached))
8392
+ {
8393
+ return *cached;
8394
+ }
8395
+
8396
+ COMP_HANDLE compHnd = info.compCompHnd ;
8397
+
8398
+ StructSegments* newSegments = new (this , CMK_Promotion) StructSegments (getAllocator (CMK_Promotion));
8399
+
8400
+ if (layout->IsBlockLayout ())
8401
+ {
8402
+ newSegments->Add (StructSegments::Segment (0 , layout->GetSize ()));
8403
+ }
8404
+ else
8405
+ {
8406
+ CORINFO_TYPE_LAYOUT_NODE nodes[256 ];
8407
+ size_t numNodes = ArrLen (nodes);
8408
+ GetTypeLayoutResult result = compHnd->getTypeLayout (layout->GetClassHandle (), nodes, &numNodes);
8409
+
8410
+ if (result != GetTypeLayoutResult::Success)
8411
+ {
8412
+ newSegments->Add (StructSegments::Segment (0 , layout->GetSize ()));
8413
+ }
8414
+ else
8415
+ {
8416
+ for (size_t i = 0 ; i < numNodes; i++)
8417
+ {
8418
+ const CORINFO_TYPE_LAYOUT_NODE& node = nodes[i];
8419
+ if ((node.type != CORINFO_TYPE_VALUECLASS) || (node.simdTypeHnd != NO_CLASS_HANDLE) ||
8420
+ node.hasSignificantPadding )
8421
+ {
8422
+ newSegments->Add (StructSegments::Segment (node.offset , node.offset + node.size ));
8423
+ }
8424
+ }
8425
+ }
8426
+ }
8427
+
8428
+ if (m_significantSegmentsMap == nullptr )
8429
+ {
8430
+ m_significantSegmentsMap = new (this , CMK_Promotion) ClassLayoutStructSegmentsMap (getAllocator (CMK_Promotion));
8431
+ }
8432
+
8433
+ m_significantSegmentsMap->Set (layout, newSegments);
8434
+
8435
+ return *newSegments;
8436
+ }
8437
+
8376
8438
/*
8377
8439
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
8378
8440
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0 commit comments