Skip to content

Commit

Permalink
[LoongArch64] Implement 'JIT_GetDynamicNonGCStaticBase_SingleAppDomai…
Browse files Browse the repository at this point in the history
…n', 'JIT_GetDynamicGCStaticBase_SingleAppDomain' after PR#99183. (#103467)

* Implement `JIT_GetDynamicNonGCStaticBase_SingleAppDomain`, `JIT_GetDynamicGCStaticBase_SingleAppDomain` for LoongArch64 after PR #99183.
* Also fix the build error for LA64.

Change-Id: Ifb9ee599bca3971270a5bc654770dfcc7e931955
  • Loading branch information
LuckyXu-HF authored Jun 15, 2024
1 parent 3099f31 commit b1f63db
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 16 deletions.
8 changes: 8 additions & 0 deletions src/coreclr/vm/loongarch64/asmconstants.h
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,14 @@ ASMCONSTANTS_C_ASSERT((1<<FixupPrecode_ALIGNMENT_SHIFT_1) == sizeof(FixupPrecode
ASMCONSTANTS_C_ASSERT(ResolveCacheElem__target == offsetof(ResolveCacheElem, target));
ASMCONSTANTS_C_ASSERT(ResolveCacheElem__pNext == offsetof(ResolveCacheElem, pNext));

#define OFFSETOF__DynamicStaticsInfo__m_pNonGCStatics 0x8
ASMCONSTANTS_C_ASSERT(OFFSETOF__DynamicStaticsInfo__m_pNonGCStatics
== offsetof(DynamicStaticsInfo, m_pNonGCStatics));

#define OFFSETOF__DynamicStaticsInfo__m_pGCStatics 0
ASMCONSTANTS_C_ASSERT(OFFSETOF__DynamicStaticsInfo__m_pGCStatics
== offsetof(DynamicStaticsInfo, m_pGCStatics));

// For JIT_PInvokeBegin and JIT_PInvokeEnd helpers
#define Frame__m_Next 0x08
ASMCONSTANTS_C_ASSERT(Frame__m_Next == offsetof(Frame, m_Next))
Expand Down
39 changes: 23 additions & 16 deletions src/coreclr/vm/loongarch64/asmhelpers.S
Original file line number Diff line number Diff line change
Expand Up @@ -944,28 +944,35 @@ LEAF_END setFPReturn, _TEXT

#endif // FEATURE_COMINTEROP

//
// JIT Static access helpers when coreclr host specifies single appdomain flag
//

// ------------------------------------------------------------------
// void* JIT_GetSharedNonGCStaticBase(SIZE_T moduleDomainID, DWORD dwClassDomainID)
// void* JIT_GetDynamicNonGCStaticBase(DynamicStaticsInfo* pStaticsInfo)

LEAF_ENTRY JIT_GetSharedNonGCStaticBase_SingleAppDomain, _TEXT
LEAF_ENTRY JIT_GetDynamicNonGCStaticBase_SingleAppDomain, _TEXT
// If class is not initialized, bail to C++ helper
//dext $a1, $a1, 0, 32
addi.d $a2, $a0, DomainLocalModule__m_pDataBlob
ld.d $a1, $a0, OFFSETOF__DynamicStaticsInfo__m_pNonGCStatics
bnez $a1, LOCAL_LABEL(JIT_GetDynamicNonGCStaticBase_SingleAppDomain_CallHelper)
ori $a0, $a1, 0
jirl $r0, $ra, 0

ldx.b $a2, $a2, $a1
andi $t4, $a2, 1
beq $t4, $zero, LOCAL_LABEL(JIT_GetSharedNonGCStaticBase_SingleAppDomain_CallHelper)
LOCAL_LABEL(JIT_GetDynamicNonGCStaticBase_SingleAppDomain_CallHelper):
// Tail call JIT_GetDynamicNonGCStaticBase_Portable
b JIT_GetDynamicNonGCStaticBase_Portable
LEAF_END JIT_GetDynamicNonGCStaticBase_SingleAppDomain, _TEXT

jirl $r0, $ra, 0
// ------------------------------------------------------------------
// void* JIT_GetDynamicGCStaticBase(DynamicStaticsInfo* pStaticsInfo)

LEAF_ENTRY JIT_GetDynamicGCStaticBase_SingleAppDomain, _TEXT
// If class is not initialized, bail to C++ helper
ld.d $a1, $a0, OFFSETOF__DynamicStaticsInfo__m_pGCStatics
bnez $a1, LOCAL_LABEL(JIT_GetDynamicGCStaticBase_SingleAppDomain_CallHelper)
ori $a0, $a1, 0
jirl $r0, $ra, 0

LOCAL_LABEL(JIT_GetSharedNonGCStaticBase_SingleAppDomain_CallHelper):
// Tail call JIT_GetSharedNonGCStaticBase_Helper
b JIT_GetSharedNonGCStaticBase_Helper
LEAF_END JIT_GetSharedNonGCStaticBase_SingleAppDomain, _TEXT
LOCAL_LABEL(JIT_GetDynamicGCStaticBase_SingleAppDomain_CallHelper):
// Tail call JIT_GetDynamicGCStaticBase_Portable
b JIT_GetDynamicGCStaticBase_Portable
LEAF_END JIT_GetDynamicGCStaticBase_SingleAppDomain, _TEXT

#ifdef FEATURE_READYTORUN

Expand Down
2 changes: 2 additions & 0 deletions src/coreclr/vm/loongarch64/cgencpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ inline unsigned StackElemSize(unsigned parmSize, bool isValueType, bool isFloatH
//
// Create alias for optimized implementations of helpers provided on this platform
//
#define JIT_GetDynamicGCStaticBase JIT_GetDynamicGCStaticBase_SingleAppDomain
#define JIT_GetDynamicNonGCStaticBase JIT_GetDynamicNonGCStaticBase_SingleAppDomain

//**********************************************************************
// Frames
Expand Down

0 comments on commit b1f63db

Please sign in to comment.