Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RISC-V] Transfer arguments between calling conventions in shuffling thunks #107282

Open
wants to merge 66 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 64 commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
70cf57f
Log ShuffleEntries from GenerateShuffleArray
tomeksowi Aug 2, 2024
1377172
Add failing tests for passing FP structs through shuffling thunks
tomeksowi Aug 2, 2024
1cec66b
Report proper ShuffleEntries for lowered FP structs
tomeksowi Aug 7, 2024
329321b
Implement shuffling thunk generation in tighter, more focused loops i…
tomeksowi Aug 13, 2024
9a50786
Generate ShuffleEntries for delowered arguments
tomeksowi Aug 20, 2024
87c8397
Better ShuffleEntry mask names, one more bit for field offset
tomeksowi Aug 20, 2024
8b3b470
Fix FpStruct for dst arg loc
tomeksowi Aug 21, 2024
1a14067
Fold ShuffleEntry generation code for lowering and delowering FpStructs
tomeksowi Aug 21, 2024
6fa6d18
ShuffleEntry mask doc update
tomeksowi Aug 21, 2024
114583a
Implement forward shuffling of floating registers and delowering of F…
tomeksowi Aug 22, 2024
331d77e
Fix shuffling of integer registers for member functions
tomeksowi Aug 23, 2024
1d96d11
The delowered argument can also be put in the first stack slot
tomeksowi Aug 23, 2024
30edbc5
Stask shuffling after delowered argument doesn't start with 0. Fixes …
tomeksowi Aug 23, 2024
a445275
Code cleanup, fewer indents
tomeksowi Aug 23, 2024
bec2d89
Support second lowering
tomeksowi Aug 23, 2024
83dee89
Remove unused CondCode
tomeksowi Aug 26, 2024
b1466a0
Handle stack slot shuffling to the right
tomeksowi Aug 28, 2024
6a7d2ce
Add some stack slots to shuffle in the growing stack test case
tomeksowi Aug 28, 2024
bb28b72
Fix Equals signature on test structs
tomeksowi Aug 28, 2024
dbb5338
Remodel the shuffling with calling convention transfer to recognize t…
tomeksowi Aug 30, 2024
68e0c36
Use helper functions in EmitComputedInstantiatingMethodStub
tomeksowi Aug 30, 2024
015aed0
Implement stack growing in shuffling thunk
tomeksowi Sep 2, 2024
3dcc74c
Use signed immediate in EmitSubImm to be consistent with EmitAddImm
tomeksowi Sep 2, 2024
afdec48
Use ABI register names in logs
tomeksowi Sep 2, 2024
84bffa4
Remove LoadRegPair because it's not used
tomeksowi Sep 2, 2024
de61b96
Add logging for slli and lui
tomeksowi Sep 3, 2024
750122a
Remove stack growing from hand-emitted shuffle thunks
tomeksowi Sep 4, 2024
d12ca52
Minor FloatFloatEmpty test cleanup
tomeksowi Sep 6, 2024
461f0c3
Implement IL shuffling thunks for cases where the stack is growing
tomeksowi Sep 9, 2024
fea44e3
Test stack walking in frames laid by the IL shuffle thunk
tomeksowi Sep 9, 2024
64a4a62
Add assert and comment in CreateILDelegateShuffleThunk
tomeksowi Sep 9, 2024
1c7b0b1
Merge branch 'main' into fp-structs-shuffling-thunks
tomeksowi Sep 9, 2024
7f81c07
Fix release build
tomeksowi Sep 10, 2024
4b1b31a
Fixes for static delegates from member methods
tomeksowi Sep 10, 2024
2edf53d
Fix log and comment
tomeksowi Sep 10, 2024
74dcd7c
Remove EmitJumpAndLinkRegister because it's no longer used
tomeksowi Sep 10, 2024
c5f72c6
Use TransferredField.reg in delowering (cosmetic fix to restart CI)
tomeksowi Sep 11, 2024
5ed7466
Merge branch 'main' into fp-structs-shuffling-thunks
tomeksowi Sep 16, 2024
3bbc188
New stub type for delegate shuffle thunk so it doesn't go in multidel…
tomeksowi Sep 16, 2024
268a28b
Make Test_ShufflingThunk_MemberGrowsStack_RiscV harder by returning v…
tomeksowi Sep 16, 2024
ccd4aae
Explain lowering
tomeksowi Sep 18, 2024
1c18c46
Fold 12-bit sign extension branch in EmitMovConstant
tomeksowi Sep 18, 2024
6c7e29f
Harden Test_ShufflingThunk_PackedEmptyUintEmptyFloat_PackedEmptyDoubl…
tomeksowi Sep 18, 2024
12eb8ba
Merge branch 'main' into fp-structs-shuffling-thunks
tomeksowi Sep 20, 2024
f4620c4
Handle shuffles between calling conventions in IL stubs
tomeksowi Sep 23, 2024
2e20dfa
Merge branch 'main' into fp-structs-shuffling-thunks
tomeksowi Sep 23, 2024
c2acecb
Update comments
tomeksowi Sep 25, 2024
5773596
Don't use NewStub for IL stubs
tomeksowi Sep 26, 2024
cdd04ec
Fold some more duplicated code into SetupShuffleThunk
tomeksowi Sep 26, 2024
ae18a27
Clean up unnecessary diffs
tomeksowi Sep 26, 2024
c4025b7
Merge branch 'main' into fp-structs-shuffling-thunks
tomeksowi Sep 27, 2024
a008f20
IL shuffle thunk takes target function address from delegate object. …
tomeksowi Oct 1, 2024
2900dfb
Build target signature based on delegate signature instead of just us…
tomeksowi Oct 3, 2024
fe5d775
Test calling instance and static methods via the same delegate type
tomeksowi Oct 3, 2024
9321b07
Simplify shuffle thunk caching on DelegateEEClass
tomeksowi Oct 3, 2024
5e1455c
Clean up CreateILDelegateShuffleThunk
tomeksowi Oct 3, 2024
ec1c57a
Delete Windows X86 stack size check
tomeksowi Oct 8, 2024
27c005f
Remove #ifdefs around ILSTUB_DELEGATE_SHUFFLE_THUNK, fix typo in GetS…
tomeksowi Oct 8, 2024
b9201b1
Fix DecRef'ing path when the IL thunk is already cached on DelegateEE…
tomeksowi Oct 8, 2024
e41802f
Fix shuffle thunk destruction in EEClass::Destruct: properly handle I…
tomeksowi Oct 8, 2024
118f191
Don't use RemoveStubRange in the destructor, make code for dereferenc…
tomeksowi Oct 9, 2024
5832103
Remove unused RemoveStubRange
tomeksowi Oct 9, 2024
7fe3c4e
Cover IL shuffle thunks in ILStubManager::TraceManager
tomeksowi Oct 9, 2024
659a9e4
Remove unused start, end arguments from RangeList::RemoveRanges[Worker]
tomeksowi Oct 9, 2024
ccf1e4e
Update src/coreclr/vm/comdelegate.cpp
jkotas Oct 9, 2024
e45db16
Merge branch 'main' into fp-structs-shuffling-thunks
tomeksowi Oct 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/coreclr/inc/sigparser.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ class SigParser
void
GetSignature(
PCCOR_SIGNATURE * pSig,
uint32_t * pcbSigSize)
uint32_t * pcbSigSize) const
{
*pSig = m_ptr;
*pcbSigSize = m_dwLen;
Expand Down
12 changes: 5 additions & 7 deletions src/coreclr/inc/utilcode.h
Original file line number Diff line number Diff line change
Expand Up @@ -3098,9 +3098,9 @@ class RangeList
return this->AddRangeWorker(start, end, id);
}

void RemoveRanges(void *id, const BYTE *start = NULL, const BYTE *end = NULL)
void RemoveRanges(void *id)
{
return this->RemoveRangesWorker(id, start, end);
return this->RemoveRangesWorker(id);
}

BOOL IsInRange(TADDR address, TADDR *pID = NULL)
Expand All @@ -3114,16 +3114,14 @@ class RangeList

// You can overload these two for synchronization (as LockedRangeList does)
virtual BOOL AddRangeWorker(const BYTE *start, const BYTE *end, void *id);
// If both "start" and "end" are NULL, then this method deletes all ranges with
// the given id (i.e. the original behaviour). Otherwise, it ignores the given
// id and deletes all ranges falling in the region [start, end).
virtual void RemoveRangesWorker(void *id, const BYTE *start = NULL, const BYTE *end = NULL);
// Deletes all ranges with the given id
virtual void RemoveRangesWorker(void *id);
#else
virtual BOOL AddRangeWorker(const BYTE *start, const BYTE *end, void *id)
{
return TRUE;
}
virtual void RemoveRangesWorker(void *id, const BYTE *start = NULL, const BYTE *end = NULL) { }
virtual void RemoveRangesWorker(void *id) { }
#endif // !DACCESS_COMPILE

virtual BOOL IsInRangeWorker(TADDR address, TADDR *pID = NULL);
Expand Down
21 changes: 3 additions & 18 deletions src/coreclr/utilcode/loaderheap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ BOOL RangeList::AddRangeWorker(const BYTE *start, const BYTE *end, void *id)
}
}

void RangeList::RemoveRangesWorker(void *id, const BYTE* start, const BYTE* end)
void RangeList::RemoveRangesWorker(void *id)
{
CONTRACTL
{
Expand All @@ -177,24 +177,9 @@ void RangeList::RemoveRangesWorker(void *id, const BYTE* start, const BYTE* end)

while (r < rEnd)
{
if (r->id != (TADDR)NULL)
if (r->id == (TADDR)id)
{
if (start != NULL)
{
_ASSERTE(end != NULL);

if (r->start >= (TADDR)start && r->start < (TADDR)end)
{
CONSISTENCY_CHECK_MSGF(r->end >= (TADDR)start &&
r->end <= (TADDR)end,
("r: %p start: %p end: %p", r, start, end));
r->id = (TADDR)NULL;
}
}
else if (r->id == (TADDR)id)
{
r->id = (TADDR)NULL;
}
r->id = (TADDR)NULL;
}

r++;
Expand Down
4 changes: 2 additions & 2 deletions src/coreclr/vm/callingconvention.h
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,7 @@ class ArgIteratorTemplate : public ARGITERATOR_BASE
//------------------------------------------------------------
int GetNextOffset();

CorElementType GetArgType(TypeHandle *pTypeHandle = NULL)
CorElementType GetArgType(TypeHandle *pTypeHandle = NULL) const
{
LIMITED_METHOD_CONTRACT;
if (pTypeHandle != NULL)
Expand All @@ -652,7 +652,7 @@ class ArgIteratorTemplate : public ARGITERATOR_BASE
return m_argType;
}

int GetArgSize()
int GetArgSize() const
{
LIMITED_METHOD_CONTRACT;
return m_argSize;
Expand Down
29 changes: 13 additions & 16 deletions src/coreclr/vm/class.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,25 +124,22 @@ void EEClass::Destruct(MethodTable * pOwningMT)
if (IsDelegate())
{
DelegateEEClass* pDelegateEEClass = (DelegateEEClass*)this;

if (pDelegateEEClass->m_pStaticCallStub)
for (Stub* pThunk : {pDelegateEEClass->m_pStaticCallStub, pDelegateEEClass->m_pInstRetBuffCallStub})
{
// Collect data to remove stub entry from StubManager if
// stub is deleted.
BYTE* entry = (BYTE*)pDelegateEEClass->m_pStaticCallStub->GetEntryPoint();
UINT length = pDelegateEEClass->m_pStaticCallStub->GetNumCodeBytes();

ExecutableWriterHolder<Stub> stubWriterHolder(pDelegateEEClass->m_pStaticCallStub, sizeof(Stub));
BOOL fStubDeleted = stubWriterHolder.GetRW()->DecRef();
if (fStubDeleted)
if (pThunk == nullptr)
continue;

_ASSERTE(pThunk->IsShuffleThunk());

if (pThunk->HasExternalEntryPoint()) // IL thunk
{
StubLinkStubManager::g_pManager->RemoveStubRange(entry, length);
pThunk->DecRef();
}
else
{
ExecutableWriterHolder<Stub> stubWriterHolder(pThunk, sizeof(Stub));
stubWriterHolder.GetRW()->DecRef();
}
}
if (pDelegateEEClass->m_pInstRetBuffCallStub)
{
ExecutableWriterHolder<Stub> stubWriterHolder(pDelegateEEClass->m_pInstRetBuffCallStub, sizeof(Stub));
stubWriterHolder.GetRW()->DecRef();
}
}

Expand Down
Loading
Loading