Skip to content

Commit 4f3545e

Browse files
Adjust logic in cor.h, corhdr.h, corinfo.h, corjit.h and such so that they may be included without the PAL (#46055)
This was done via simple substitution of the standard sized integer types, and dealing with the fallout. It is tested by using the ICorJitInfo interface directly within the crossgen2 jitinterface thunk library. Effort was made to use a minimum number of casts, as casts in such a large change are likely to be wrong somewhere. - Exceptions are the use of casting to handle some calls to the existing internal metadata api and around use of char16_t. In addition, a small amount of logic from the PAL headers were pulled into the proper header to allow compilation in the presence of some SAL annotation, and other small details.
1 parent aa138f7 commit 4f3545e

File tree

102 files changed

+1970
-1865
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

102 files changed

+1970
-1865
lines changed

src/coreclr/ToolBox/superpmi/superpmi-shared/compileresult.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ void CompileResult::repAllocGCInfo(size_t* size, void** retval)
388388
*retval = (void*)AllocGCInfo->GetBuffer(value.retval_offset);
389389
}
390390

391-
void CompileResult::recCompileMethod(BYTE** nativeEntry, ULONG* nativeSizeOfCode, CorJitResult result)
391+
void CompileResult::recCompileMethod(uint8_t** nativeEntry, uint32_t* nativeSizeOfCode, CorJitResult result)
392392
{
393393
if (CompileMethod == nullptr)
394394
CompileMethod = new LightWeightMap<DWORD, Agnostic_CompileMethodResults>();

src/coreclr/ToolBox/superpmi/superpmi-shared/compileresult.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ class CompileResult
113113
void dmpAllocGCInfo(DWORD key, const Agnostic_AllocGCInfo& value);
114114
void repAllocGCInfo(size_t* size, void** retval);
115115

116-
void recCompileMethod(BYTE** nativeEntry, ULONG* nativeSizeOfCode, CorJitResult result);
116+
void recCompileMethod(uint8_t** nativeEntry, uint32_t* nativeSizeOfCode, CorJitResult result);
117117
void dmpCompileMethod(DWORD key, const Agnostic_CompileMethodResults& value);
118118
void repCompileMethod(BYTE** nativeEntry, ULONG* nativeSizeOfCode, CorJitResult* result);
119119

src/coreclr/ToolBox/superpmi/superpmi-shared/icorjitcompilerimpl.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@
2525
// * For the 64 bit jit this is implemented by code:PreJit.compileMethod
2626
//
2727
// Note: Obfuscators that are hacking the JIT depend on this method having __stdcall calling convention
28-
CorJitResult __stdcall compileMethod(ICorJitInfo* comp, /* IN */
29-
struct CORINFO_METHOD_INFO* info, /* IN */
30-
unsigned /* code:CorJitFlag */ flags, /* IN */
31-
BYTE** nativeEntry, /* OUT */
32-
ULONG* nativeSizeOfCode /* OUT */
33-
);
28+
CorJitResult compileMethod(ICorJitInfo* comp, /* IN */
29+
struct CORINFO_METHOD_INFO* info, /* IN */
30+
unsigned /* code:CorJitFlag */ flags, /* IN */
31+
uint8_t** nativeEntry, /* OUT */
32+
uint32_t* nativeSizeOfCode /* OUT */
33+
);
3434

3535
// Do any appropriate work at process shutdown. Default impl is to do nothing.
3636
void ProcessShutdownWork(ICorStaticInfo* info); /* {}; */

src/coreclr/ToolBox/superpmi/superpmi-shared/methodcontext.cpp

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -851,7 +851,7 @@ void MethodContext::repGetVars(CORINFO_METHOD_HANDLE ftn,
851851
// Note - the jit will call freearray on the array we give back....
852852
void MethodContext::recGetBoundaries(CORINFO_METHOD_HANDLE ftn,
853853
unsigned int* cILOffsets,
854-
DWORD** pILOffsets,
854+
uint32_t** pILOffsets,
855855
ICorDebugInfo::BoundaryTypes* implictBoundaries)
856856
{
857857
if (GetBoundaries == nullptr)
@@ -882,7 +882,7 @@ void MethodContext::dmpGetBoundaries(DWORDLONG key, const Agnostic_GetBoundaries
882882
}
883883
void MethodContext::repGetBoundaries(CORINFO_METHOD_HANDLE ftn,
884884
unsigned int* cILOffsets,
885-
DWORD** pILOffsets,
885+
uint32_t** pILOffsets,
886886
ICorDebugInfo::BoundaryTypes* implictBoundaries)
887887
{
888888
Agnostic_GetBoundaries value;
@@ -891,7 +891,7 @@ void MethodContext::repGetBoundaries(CORINFO_METHOD_HANDLE ftn,
891891

892892
*cILOffsets = (unsigned int)value.cILOffsets;
893893
if (*cILOffsets > 0)
894-
*pILOffsets = (DWORD*)GetBoundaries->GetBuffer(value.pILOffset_offset);
894+
*pILOffsets = (uint32_t*)GetBoundaries->GetBuffer(value.pILOffset_offset);
895895
*implictBoundaries = (ICorDebugInfo::BoundaryTypes)value.implicitBoundaries;
896896

897897
DEBUG_REP(dmpGetBoundaries(CastHandle(ftn), value));
@@ -1164,7 +1164,7 @@ LPCWSTR MethodContext::repGetJitTimeLogFilename()
11641164

11651165
void MethodContext::recCanInline(CORINFO_METHOD_HANDLE callerHnd,
11661166
CORINFO_METHOD_HANDLE calleeHnd,
1167-
DWORD* pRestrictions,
1167+
uint32_t* pRestrictions,
11681168
CorInfoInline response,
11691169
DWORD exceptionCode)
11701170
{
@@ -1196,7 +1196,7 @@ void MethodContext::dmpCanInline(DLDL key, const Agnostic_CanInline& value)
11961196
}
11971197
CorInfoInline MethodContext::repCanInline(CORINFO_METHOD_HANDLE callerHnd,
11981198
CORINFO_METHOD_HANDLE calleeHnd,
1199-
DWORD* pRestrictions,
1199+
uint32_t* pRestrictions,
12001200
DWORD* exceptionCode)
12011201
{
12021202
DLDL key;
@@ -4161,7 +4161,7 @@ const void* MethodContext::repGetInlinedCallFrameVptr(void** ppIndirection)
41614161
return (const void*)value.B;
41624162
}
41634163

4164-
void MethodContext::recGetAddrOfCaptureThreadGlobal(void** ppIndirection, LONG* result)
4164+
void MethodContext::recGetAddrOfCaptureThreadGlobal(void** ppIndirection, int32_t* result)
41654165
{
41664166
if (GetAddrOfCaptureThreadGlobal == nullptr)
41674167
GetAddrOfCaptureThreadGlobal = new LightWeightMap<DWORD, DLDL>();
@@ -4181,7 +4181,7 @@ void MethodContext::dmpGetAddrOfCaptureThreadGlobal(DWORD key, DLDL value)
41814181
{
41824182
printf("GetAddrOfCaptureThreadGlobal key %u, value ppi-%016llX res-%016llX", key, value.A, value.B);
41834183
}
4184-
LONG* MethodContext::repGetAddrOfCaptureThreadGlobal(void** ppIndirection)
4184+
int32_t* MethodContext::repGetAddrOfCaptureThreadGlobal(void** ppIndirection)
41854185
{
41864186
DLDL value;
41874187

@@ -4191,7 +4191,7 @@ LONG* MethodContext::repGetAddrOfCaptureThreadGlobal(void** ppIndirection)
41914191
LogDebug("Sparse - repGetAddrOfCaptureThreadGlobal returning nullptr and 0xCAFE0001");
41924192
if (ppIndirection != nullptr)
41934193
*ppIndirection = nullptr;
4194-
return (LONG*)(size_t)0xCAFE0001;
4194+
return (int32_t*)(size_t)0xCAFE0001;
41954195
#else
41964196
LogException(EXCEPTIONCODE_MC, "Didn't find anything for GetAddrOfCaptureThreadGlobal", "");
41974197
#endif
@@ -4201,7 +4201,7 @@ LONG* MethodContext::repGetAddrOfCaptureThreadGlobal(void** ppIndirection)
42014201
if (ppIndirection != nullptr)
42024202
*ppIndirection = (void*)value.A;
42034203
DEBUG_REP(dmpGetAddrOfCaptureThreadGlobal((DWORD)0, value));
4204-
return (LONG*)value.B;
4204+
return (int32_t*)value.B;
42054205
}
42064206

42074207
void MethodContext::recGetClassDomainID(CORINFO_CLASS_HANDLE cls, void** ppIndirection, unsigned result)
@@ -4586,7 +4586,7 @@ bool MethodContext::repIsValidStringRef(CORINFO_MODULE_HANDLE module, unsigned m
45864586
}
45874587

45884588

4589-
void MethodContext::recGetStringLiteral(CORINFO_MODULE_HANDLE module, unsigned metaTOK, int length, LPCWSTR result)
4589+
void MethodContext::recGetStringLiteral(CORINFO_MODULE_HANDLE module, unsigned metaTOK, int length, const char16_t* result)
45904590
{
45914591
if (GetStringLiteral == nullptr)
45924592
GetStringLiteral = new LightWeightMap<DLD, DD>();
@@ -4600,7 +4600,7 @@ void MethodContext::recGetStringLiteral(CORINFO_MODULE_HANDLE module, unsigned m
46004600

46014601
DWORD strBuf = (DWORD)-1;
46024602
if (result != nullptr)
4603-
strBuf = (DWORD)GetStringLiteral->AddBuffer((unsigned char*)result, (unsigned int)((wcslen(result) * 2) + 2));
4603+
strBuf = (DWORD)GetStringLiteral->AddBuffer((unsigned char*)result, (unsigned int)((wcslen((LPCWSTR)result) * 2) + 2));
46044604

46054605
DD value;
46064606
value.A = (DWORD)length;
@@ -4615,7 +4615,7 @@ void MethodContext::dmpGetStringLiteral(DLD key, DD value)
46154615
GetStringLiteral->GetBuffer(value.B), value.A);
46164616
}
46174617

4618-
LPCWSTR MethodContext::repGetStringLiteral(CORINFO_MODULE_HANDLE module, unsigned metaTOK, int* length)
4618+
const char16_t* MethodContext::repGetStringLiteral(CORINFO_MODULE_HANDLE module, unsigned metaTOK, int* length)
46194619
{
46204620
if (GetStringLiteral == nullptr)
46214621
{
@@ -4640,7 +4640,7 @@ LPCWSTR MethodContext::repGetStringLiteral(CORINFO_MODULE_HANDLE module, unsigne
46404640
{
46414641
DD result = GetStringLiteral->Get(key);
46424642
*length = (int)result.A;
4643-
return (LPCWSTR)GetStringLiteral->GetBuffer(itemIndex);
4643+
return (const char16_t*)GetStringLiteral->GetBuffer(itemIndex);
46444644
}
46454645
}
46464646

@@ -6187,7 +6187,7 @@ CORINFO_CLASS_HANDLE MethodContext::repGetTypeInstantiationArgument(CORINFO_CLAS
61876187
}
61886188

61896189
void MethodContext::recAppendClassName(
6190-
CORINFO_CLASS_HANDLE cls, bool fNamespace, bool fFullInst, bool fAssembly, const WCHAR* result)
6190+
CORINFO_CLASS_HANDLE cls, bool fNamespace, bool fFullInst, bool fAssembly, const char16_t* result)
61916191
{
61926192
if (AppendClassName == nullptr)
61936193
AppendClassName = new LightWeightMap<Agnostic_AppendClassName, DWORD>();
@@ -6202,7 +6202,7 @@ void MethodContext::recAppendClassName(
62026202

62036203
DWORD temp = (DWORD)-1;
62046204
if (result != nullptr)
6205-
temp = (DWORD)AppendClassName->AddBuffer((unsigned char*)result, (unsigned int)((wcslen(result) * 2) + 2));
6205+
temp = (DWORD)AppendClassName->AddBuffer((unsigned char*)result, (unsigned int)((wcslen((LPCWSTR)result) * 2) + 2));
62066206

62076207
AppendClassName->Add(key, (DWORD)temp);
62086208
DEBUG_REC(dmpAppendClassName(key, (DWORD)temp));

src/coreclr/ToolBox/superpmi/superpmi-shared/methodcontext.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -112,12 +112,12 @@ class MethodContext
112112

113113
void recGetBoundaries(CORINFO_METHOD_HANDLE ftn,
114114
unsigned int* cILOffsets,
115-
DWORD** pILOffsets,
115+
uint32_t** pILOffsets,
116116
ICorDebugInfo::BoundaryTypes* implictBoundaries);
117117
void dmpGetBoundaries(DWORDLONG key, const Agnostic_GetBoundaries& value);
118118
void repGetBoundaries(CORINFO_METHOD_HANDLE ftn,
119119
unsigned int* cILOffsets,
120-
DWORD** pILOffsets,
120+
uint32_t** pILOffsets,
121121
ICorDebugInfo::BoundaryTypes* implictBoundaries);
122122

123123
void recInitClass(CORINFO_FIELD_HANDLE field,
@@ -154,13 +154,13 @@ class MethodContext
154154

155155
void recCanInline(CORINFO_METHOD_HANDLE callerHnd,
156156
CORINFO_METHOD_HANDLE calleeHnd,
157-
DWORD* pRestrictions,
157+
uint32_t* pRestrictions,
158158
CorInfoInline response,
159159
DWORD exceptionCode);
160160
void dmpCanInline(DLDL key, const Agnostic_CanInline& value);
161161
CorInfoInline repCanInline(CORINFO_METHOD_HANDLE callerHnd,
162162
CORINFO_METHOD_HANDLE calleeHnd,
163-
DWORD* pRestrictions,
163+
uint32_t* pRestrictions,
164164
DWORD* exceptionCode);
165165

166166
void recResolveToken(CORINFO_RESOLVED_TOKEN* pResolvedToken, DWORD exceptionCode);
@@ -509,9 +509,9 @@ class MethodContext
509509
void dmpGetInlinedCallFrameVptr(DWORD key, DLDL value);
510510
const void* repGetInlinedCallFrameVptr(void** ppIndirection);
511511

512-
void recGetAddrOfCaptureThreadGlobal(void** ppIndirection, LONG* result);
512+
void recGetAddrOfCaptureThreadGlobal(void** ppIndirection, int32_t* result);
513513
void dmpGetAddrOfCaptureThreadGlobal(DWORD key, DLDL value);
514-
LONG* repGetAddrOfCaptureThreadGlobal(void** ppIndirection);
514+
int32_t* repGetAddrOfCaptureThreadGlobal(void** ppIndirection);
515515

516516
void recGetClassDomainID(CORINFO_CLASS_HANDLE cls, void** ppIndirection, unsigned result);
517517
void dmpGetClassDomainID(DWORDLONG key, DLD value);
@@ -567,9 +567,9 @@ class MethodContext
567567
void dmpIsValidStringRef(DLD key, DWORD value);
568568
bool repIsValidStringRef(CORINFO_MODULE_HANDLE module, unsigned metaTOK);
569569

570-
void recGetStringLiteral(CORINFO_MODULE_HANDLE module, unsigned metaTOK, int length, LPCWSTR result);
570+
void recGetStringLiteral(CORINFO_MODULE_HANDLE module, unsigned metaTOK, int length, const char16_t* result);
571571
void dmpGetStringLiteral(DLD key, DD value);
572-
LPCWSTR repGetStringLiteral(CORINFO_MODULE_HANDLE module, unsigned metaTOK, int* length);
572+
const char16_t* repGetStringLiteral(CORINFO_MODULE_HANDLE module, unsigned metaTOK, int* length);
573573

574574
void recGetHelperName(CorInfoHelpFunc funcNum, const char* result);
575575
void dmpGetHelperName(DWORD key, DWORD value);
@@ -754,7 +754,7 @@ class MethodContext
754754
CORINFO_CLASS_HANDLE repGetTypeInstantiationArgument(CORINFO_CLASS_HANDLE cls, unsigned index);
755755

756756
void recAppendClassName(
757-
CORINFO_CLASS_HANDLE cls, bool fNamespace, bool fFullInst, bool fAssembly, const WCHAR* result);
757+
CORINFO_CLASS_HANDLE cls, bool fNamespace, bool fFullInst, bool fAssembly, const char16_t* result);
758758
void dmpAppendClassName(const Agnostic_AppendClassName& key, DWORD value);
759759
const WCHAR* repAppendClassName(CORINFO_CLASS_HANDLE cls, bool fNamespace, bool fFullInst, bool fAssembly);
760760

src/coreclr/ToolBox/superpmi/superpmi-shim-collector/icorjitcompiler.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@
1010

1111
#define fatMC // this is nice to have on so ildump works...
1212

13-
CorJitResult __stdcall interceptor_ICJC::compileMethod(ICorJitInfo* comp, /* IN */
14-
struct CORINFO_METHOD_INFO* info, /* IN */
15-
unsigned /* code:CorJitFlag */ flags, /* IN */
16-
BYTE** nativeEntry, /* OUT */
17-
ULONG* nativeSizeOfCode /* OUT */
18-
)
13+
CorJitResult interceptor_ICJC::compileMethod(ICorJitInfo* comp, /* IN */
14+
struct CORINFO_METHOD_INFO* info, /* IN */
15+
unsigned /* code:CorJitFlag */ flags, /* IN */
16+
uint8_t** nativeEntry, /* OUT */
17+
uint32_t* nativeSizeOfCode /* OUT */
18+
)
1919
{
2020
interceptor_ICJI our_ICorJitInfo;
2121
our_ICorJitInfo.original_ICorJitInfo = comp;

0 commit comments

Comments
 (0)