Skip to content

Commit ec06321

Browse files
cshungjkotas
andauthored
Fix x86 clrgc loading (#81176)
Co-authored-by: Jan Kotas <[email protected]>
1 parent 5971947 commit ec06321

File tree

5 files changed

+21
-9
lines changed

5 files changed

+21
-9
lines changed

docs/design/features/standalone-gc-loading.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ struct VersionInfo {
110110
const char* Name;
111111
};
112112

113-
extern "C" void GC_VersionInfo(
113+
extern "C" void LOCALGC_CALLCONV GC_VersionInfo(
114114
/* Out */ VersionInfo*
115115
);
116116
```
@@ -142,7 +142,7 @@ Once the EE has verified that the version of the candidate GC is valid, it then
142142
GC. It does so by loading (via `GetProcAddress`) and executing a function with this signature:
143143

144144
```c++
145-
extern "C" HRESULT GC_Initialize(
145+
extern "C" HRESULT LOCALGC_CALLCONV GC_Initialize(
146146
/* In */ IGCToCLR*,
147147
/* Out */ IGCHeap**.
148148
/* Out */ IGCHandleManager**,

src/coreclr/gc/gcinterface.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1061,11 +1061,17 @@ struct VersionInfo {
10611061
const char* Name;
10621062
};
10631063

1064-
typedef void (*GC_VersionInfoFunction)(
1064+
#ifdef TARGET_X86
1065+
#define LOCALGC_CALLCONV __cdecl
1066+
#else
1067+
#define LOCALGC_CALLCONV
1068+
#endif
1069+
1070+
typedef void (LOCALGC_CALLCONV *GC_VersionInfoFunction)(
10651071
/* Out */ VersionInfo*
10661072
);
10671073

1068-
typedef HRESULT (*GC_InitializeFunction)(
1074+
typedef HRESULT (LOCALGC_CALLCONV *GC_InitializeFunction)(
10691075
/* In */ IGCToCLR*,
10701076
/* Out */ IGCHeap**,
10711077
/* Out */ IGCHandleManager**,

src/coreclr/gc/gcload.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ namespace SVR
4242
extern void PopulateHandleTableDacVars(GcDacVars* dacVars);
4343

4444
GC_EXPORT
45-
void
45+
void LOCALGC_CALLCONV
4646
GC_VersionInfo(/* InOut */ VersionInfo* info)
4747
{
4848
#ifdef BUILD_AS_STANDALONE
@@ -59,7 +59,7 @@ GC_VersionInfo(/* InOut */ VersionInfo* info)
5959
}
6060

6161
GC_EXPORT
62-
HRESULT
62+
HRESULT LOCALGC_CALLCONV
6363
GC_Initialize(
6464
/* In */ IGCToCLR* clrToGC,
6565
/* Out */ IGCHeap** gcHeap,

src/coreclr/gc/sample/GCSample.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@
4747

4848
#include "gcdesc.h"
4949

50+
#ifdef TARGET_X86
51+
#define LOCALGC_CALLCONV __cdecl
52+
#else
53+
#define LOCALGC_CALLCONV
54+
#endif
55+
5056
//
5157
// The fast paths for object allocation and write barriers is performance critical. They are often
5258
// hand written in assembly code, etc.
@@ -106,7 +112,7 @@ void WriteBarrier(Object ** dst, Object * ref)
106112
ErectWriteBarrier(dst, ref);
107113
}
108114

109-
extern "C" HRESULT GC_Initialize(IGCToCLR* clrToGC, IGCHeap** gcHeap, IGCHandleManager** gcHandleManager, GcDacVars* gcDacVars);
115+
extern "C" HRESULT LOCALGC_CALLCONV GC_Initialize(IGCToCLR* clrToGC, IGCHeap** gcHeap, IGCHandleManager** gcHandleManager, GcDacVars* gcDacVars);
110116

111117
int __cdecl main(int argc, char* argv[])
112118
{

src/coreclr/vm/gcheaputilities.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ bool GCHeapUtilities::s_useThreadAllocationContexts;
6666

6767
// GC entrypoints for the linked-in GC. These symbols are invoked
6868
// directly if we are not using a standalone GC.
69-
extern "C" void GC_VersionInfo(/* Out */ VersionInfo* info);
70-
extern "C" HRESULT GC_Initialize(
69+
extern "C" void LOCALGC_CALLCONV GC_VersionInfo(/* Out */ VersionInfo* info);
70+
extern "C" HRESULT LOCALGC_CALLCONV GC_Initialize(
7171
/* In */ IGCToCLR* clrToGC,
7272
/* Out */ IGCHeap** gcHeap,
7373
/* Out */ IGCHandleManager** gcHandleManager,

0 commit comments

Comments
 (0)