Skip to content

Commit

Permalink
[RISC-V] Implement ThisPtrRetBufPrecode::Init (#91451)
Browse files Browse the repository at this point in the history
  • Loading branch information
clamp03 authored Sep 4, 2023
1 parent 47bb554 commit 741ab87
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/coreclr/vm/riscv64/cgencpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ struct HijackArgs
// Precode to shuffle this and retbuf for closed delegates over static methods with return buffer
struct ThisPtrRetBufPrecode {

static const int Type = 0x2;
static const int Type = 0x93;

UINT32 m_rgCode[6];
TADDR m_pTarget;
Expand Down
18 changes: 17 additions & 1 deletion src/coreclr/vm/riscv64/stubs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,23 @@ void HelperMethodFrame::UpdateRegDisplay(const PREGDISPLAY pRD)
#ifndef DACCESS_COMPILE
void ThisPtrRetBufPrecode::Init(MethodDesc* pMD, LoaderAllocator *pLoaderAllocator)
{
_ASSERTE(!"RISCV64: not implementation on riscv64!!!");
WRAPPER_NO_CONTRACT;

//Initially
//a0 -This ptr
//a1 -ReturnBuffer
m_rgCode[0] = 0x00050f93; // addi t6, a0, 0x0
m_rgCode[1] = 0x00058513; // addi a0, a1, 0x0
m_rgCode[2] = 0x000f8593; // addi a1, t6, 0x0
m_rgCode[3] = 0x00000f97; // auipc t6, 0
m_rgCode[4] = 0x00cfbf83; // ld t6, 12(t6)
m_rgCode[5] = 0x000f8067; // jalr x0, 0(t6)

_ASSERTE((UINT32*)&m_pTarget == &m_rgCode[6]);
_ASSERTE(6 == ARRAY_SIZE(m_rgCode));

m_pTarget = GetPreStubEntryPoint();
m_pMethodDesc = (TADDR)pMD;
}

#endif // !DACCESS_COMPILE
Expand Down

0 comments on commit 741ab87

Please sign in to comment.