Repository navigation
[LoongArch64] Fix the ArgIteratorTemplate::GetNextOffset() return argOfs for 'ELEMENT_TYPE_VALUETYPE' which is flattened liking struct{Arr[], float}. - #103108
Conversation
…rgOfs for 'ELEMENT_TYPE_VALUETYPE' which is flattened liking struct{Arr[], float}.
* The 'ELEMENT_TYPE_VALUETYPE' is marked to 'TYPE_GC_OTHER' and the first flattened element Arr[] should GC.
* This also fixed the assert failure "!CREATE_CHECK_STRING(pMT && pMT->Validate())" under GC=8 of MarshalStructAsLayoutSeq.sh.
|
The problem case is liking the following:
###### MarshalStructAsLayoutSeq.cs
...
333 [DllImport("MarshalStructAsParam")]
334 static extern bool MarshalStructAsParam_AsSeqByValFixedBufferClassificationTest(FixedArrayClassificationTest str, float f);
...
687 Console.WriteLine("\tCalling MarshalStructAsParam_AsSeqByValFixedBufferClassificationTest with fixed array...");
688 FixedArrayClassificationTest fixedArrayTest = new FixedArrayClassificationTest
689 {
690 arr = new Int32Wrapper[3]
691 {
692 new Int32Wrapper { i = 123456 },
693 new Int32Wrapper { i = 78910 },
694 new Int32Wrapper { i = 1234 }
695 },
696 f = 56.789f
697 };
698
699 if (!MarshalStructAsParam_AsSeqByValFixedBufferClassificationTest(fixedArrayTest, fixedArrayTest.f))
700 {
701 Console.WriteLine("\tFAILED! Managed to Native failed in MarshalStructAsParam_AsSeqByValFixedBufferClassificationTest. Expected:True;Actual:False");
702 failures++;
703 }
...
###### ./src/tests/Interop/StructMarshalling/PInvoke/Struct.cs:
...
510 [StructLayout(LayoutKind.Sequential)]
511 public unsafe struct FixedArrayClassificationTest
512 {
513 [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)]
514 public Int32Wrapper[] arr;
515 public float f;
516 }
...
#### src/coreclr/vm/frames.cpp:
1375 void TransitionFrame::PromoteCallerStackHelper(promote_func* fn, ScanContext* sc,
1376 MethodDesc *pFunction, MetaSig *pmsig)
1377 {
1378 WRAPPER_NO_CONTRACT;
...
...
1417 int argOffset;
1418 while ((argOffset = argit.GetNextOffset()) != TransitionBlock::InvalidOffset) <---@@@
1419 {
1420 ArgDestination argDest(dac_cast<PTR_VOID>(pTransitionBlock), argOffset, argit.GetArgLocDescForStructInRegs());
1421 pmsig->GcScanRoots(&argDest, fn, sc);
1422 }
1423 }The |
|
cc @shushanhf |
|
@clamp03 @tomeksowi , as RISC-V has the same parse logic with LA64 in |
|
Hi @jkotas , could you please review this PR? Thank you. |
tomeksowi
left a comment
There was a problem hiding this comment.
LGTM. Thank you for heads-up, I'll fix for RISC-V shortly.
delete redundancy condition.
[LoongArch64] Fix the
ArgIteratorTemplate::GetNextOffset()return argOfs for 'ELEMENT_TYPE_VALUETYPE' which is flattened liking struct{Arr[], float}.