diff options
Diffstat (limited to 'src/ToolBox/superpmi/superpmi')
25 files changed, 1334 insertions, 1606 deletions
diff --git a/src/ToolBox/superpmi/superpmi/commandline.cpp b/src/ToolBox/superpmi/superpmi/commandline.cpp index 56a2f32d1d..8546afae7c 100644 --- a/src/ToolBox/superpmi/superpmi/commandline.cpp +++ b/src/ToolBox/superpmi/superpmi/commandline.cpp @@ -16,7 +16,7 @@ // NOTE: this is parsed by parallelsuperpmi.cpp::ProcessChildStdOut() to determine if an incorrect // argument usage error has occurred. -const char* const g_SuperPMIUsageFirstLine = "SuperPMI is a JIT compiler testing tool."; +const char* const g_SuperPMIUsageFirstLine = "SuperPMI is a JIT compiler testing tool."; void CommandLine::DumpHelp(const char* program) { @@ -135,23 +135,24 @@ void CommandLine::DumpHelp(const char* program) printf(" ; if there are any failures, record their MC numbers in the file fail.mcl\n"); } -//Assumption: All inputs are initialized to default or real value. we'll just set the stuff we see on the command line. -//Assumption: Single byte names are passed in.. mb stuff doesnt cause an obvious problem... but it might have issues... -//Assumption: Values larger than 2^31 aren't expressible from the commandline.... (atoi) Unless you pass in negatives.. :-| +// Assumption: All inputs are initialized to default or real value. we'll just set the stuff we see on the command +// line. Assumption: Single byte names are passed in.. mb stuff doesnt cause an obvious problem... but it might have +// issues... Assumption: Values larger than 2^31 aren't expressible from the commandline.... (atoi) Unless you pass in +// negatives.. :-| bool CommandLine::Parse(int argc, char* argv[], /* OUT */ Options* o) { - size_t argLen = 0; - size_t tempLen = 0; - bool foundJit = false; - bool foundFile = false; + size_t argLen = 0; + size_t tempLen = 0; + bool foundJit = false; + bool foundFile = false; - if (argc == 1) //Print help when no args are passed + if (argc == 1) // Print help when no args are passed { DumpHelp(argv[0]); return false; } - for (int i = 1; i<argc; i++) + for (int i = 1; i < argc; i++) { bool isASwitch = (argv[i][0] == '-'); #ifndef FEATURE_PAL @@ -161,21 +162,20 @@ bool CommandLine::Parse(int argc, char* argv[], /* OUT */ Options* o) } #endif // !FEATURE_PAL - //Process a switch + // Process a switch if (isASwitch) { argLen = strlen(argv[i]); - if (argLen >1) - argLen--; //adjust for leading switch + if (argLen > 1) + argLen--; // adjust for leading switch else { DumpHelp(argv[0]); return false; } - if ((_strnicmp(&argv[i][1], "help", argLen) == 0) || - (_strnicmp(&argv[i][1], "HELP", argLen) == 0) || + if ((_strnicmp(&argv[i][1], "help", argLen) == 0) || (_strnicmp(&argv[i][1], "HELP", argLen) == 0) || (_strnicmp(&argv[i][1], "?", argLen) == 0)) { DumpHelp(argv[0]); @@ -219,12 +219,12 @@ bool CommandLine::Parse(int argc, char* argv[], /* OUT */ Options* o) DumpHelp(argv[0]); return false; } - char *tempStr = new char[tempLen + 1]; + char* tempStr = new char[tempLen + 1]; strcpy_s(tempStr, tempLen + 1, argv[i]); if (!foundJit) { o->nameOfJit = tempStr; - foundJit = true; + foundJit = true; } else { @@ -246,7 +246,7 @@ bool CommandLine::Parse(int argc, char* argv[], /* OUT */ Options* o) DumpHelp(argv[0]); return false; } - char *tempStr = new char[tempLen + 1]; + char* tempStr = new char[tempLen + 1]; strcpy_s(tempStr, tempLen + 1, argv[i]); o->reproName = tempStr; } @@ -354,7 +354,8 @@ bool CommandLine::Parse(int argc, char* argv[], /* OUT */ Options* o) o->compileList = argv[i]; // Save this in case we need it for -parallel. } #ifdef USE_COREDISTOOLS - else if ((_strnicmp(&argv[i][1], "coredistools", argLen) == 0)) { + else if ((_strnicmp(&argv[i][1], "coredistools", argLen) == 0)) + { o->useCoreDisTools = true; } #endif // USE_COREDISTOOLS @@ -394,13 +395,14 @@ bool CommandLine::Parse(int argc, char* argv[], /* OUT */ Options* o) if (i + 1 < argc) { // If so, does it look like a worker count? - bool isWorkerCount = true; - size_t nextlen = strlen(argv[i + 1]); + bool isWorkerCount = true; + size_t nextlen = strlen(argv[i + 1]); for (size_t j = 0; j < nextlen; j++) { if (!isdigit(argv[i + 1][j])) { - isWorkerCount = false; // Doesn't look like a worker count; bail out and let someone else handle it. + isWorkerCount = + false; // Doesn't look like a worker count; bail out and let someone else handle it. break; } } @@ -417,7 +419,8 @@ bool CommandLine::Parse(int argc, char* argv[], /* OUT */ Options* o) } if (o->workerCount > MAXIMUM_WAIT_OBJECTS) { - LogError("Invalid workers count specified, workers count cannot be more than %d.", MAXIMUM_WAIT_OBJECTS); + LogError("Invalid workers count specified, workers count cannot be more than %d.", + MAXIMUM_WAIT_OBJECTS); DumpHelp(argv[0]); return false; } @@ -455,7 +458,8 @@ bool CommandLine::Parse(int argc, char* argv[], /* OUT */ Options* o) if (o->offset < 1 || o->increment < 1) { - LogError("Incorrect offset/increment specified for -stride. Offset and increment both must be > 0."); + LogError( + "Incorrect offset/increment specified for -stride. Offset and increment both must be > 0."); DumpHelp(argv[0]); return false; } @@ -479,11 +483,11 @@ bool CommandLine::Parse(int argc, char* argv[], /* OUT */ Options* o) return false; } } - //Process an input filename - //String comparisons on file extensions must be case-insensitive since we run on Windows + // Process an input filename + //String comparisons on file extensions must be case-insensitive since we run on Windows else { - char *lastdot = strrchr(argv[i], '.'); + char* lastdot = strrchr(argv[i], '.'); if (lastdot == nullptr) { DumpHelp(argv[0]); diff --git a/src/ToolBox/superpmi/superpmi/commandline.h b/src/ToolBox/superpmi/superpmi/commandline.h index 051eb6def2..9937c3c036 100644 --- a/src/ToolBox/superpmi/superpmi/commandline.h +++ b/src/ToolBox/superpmi/superpmi/commandline.h @@ -12,33 +12,32 @@ class CommandLine { public: - class Options { public: - Options() : - nameOfJit(nullptr), - nameOfJit2(nullptr), - nameOfInputMethodContextFile(nullptr), - writeLogFile(nullptr), - reproName(nullptr), - breakOnError(false), - breakOnAssert(false), - applyDiff(false), - parallel(false), - useCoreDisTools(false), - skipCleanup(false), - workerCount(-1), - indexCount(-1), - indexes(nullptr), - hash(nullptr), - methodStatsTypes(nullptr), - mclFilename(nullptr), - diffMCLFilename(nullptr), - targetArchitecture(nullptr), - compileList(nullptr), - offset(-1), - increment(-1) + Options() + : nameOfJit(nullptr) + , nameOfJit2(nullptr) + , nameOfInputMethodContextFile(nullptr) + , writeLogFile(nullptr) + , reproName(nullptr) + , breakOnError(false) + , breakOnAssert(false) + , applyDiff(false) + , parallel(false) + , useCoreDisTools(false) + , skipCleanup(false) + , workerCount(-1) + , indexCount(-1) + , indexes(nullptr) + , hash(nullptr) + , methodStatsTypes(nullptr) + , mclFilename(nullptr) + , diffMCLFilename(nullptr) + , targetArchitecture(nullptr) + , compileList(nullptr) + , offset(-1) + , increment(-1) { } @@ -47,23 +46,23 @@ public: char* nameOfInputMethodContextFile; char* writeLogFile; char* reproName; - bool breakOnError; - bool breakOnAssert; - bool applyDiff; - bool parallel; // User specified to use /parallel mode. - bool useCoreDisTools; // Use CoreDisTools library instead of Msvcdis - bool skipCleanup; // In /parallel mode, do we skip cleanup of temporary files? Used for debugging /parallel. - int workerCount; // Number of workers to use for /parallel mode. -1 (or 1) means don't use parallel mode. - int indexCount; // If indexCount is -1 and hash points to nullptr it means compile all. - int* indexes; + bool breakOnError; + bool breakOnAssert; + bool applyDiff; + bool parallel; // User specified to use /parallel mode. + bool useCoreDisTools; // Use CoreDisTools library instead of Msvcdis + bool skipCleanup; // In /parallel mode, do we skip cleanup of temporary files? Used for debugging /parallel. + int workerCount; // Number of workers to use for /parallel mode. -1 (or 1) means don't use parallel mode. + int indexCount; // If indexCount is -1 and hash points to nullptr it means compile all. + int* indexes; char* hash; char* methodStatsTypes; char* mclFilename; char* diffMCLFilename; char* targetArchitecture; char* compileList; - int offset; - int increment; + int offset; + int increment; }; static bool Parse(int argc, char* argv[], /* OUT */ Options* o); diff --git a/src/ToolBox/superpmi/superpmi/coreclrcallbacks.cpp b/src/ToolBox/superpmi/superpmi/coreclrcallbacks.cpp index 7a66d20940..98fbe6980d 100644 --- a/src/ToolBox/superpmi/superpmi/coreclrcallbacks.cpp +++ b/src/ToolBox/superpmi/superpmi/coreclrcallbacks.cpp @@ -8,9 +8,9 @@ #include "coreclrcallbacks.h" #include "iexecutionengine.h" -IExecutionEngine* STDMETHODCALLTYPE IEE_t() +IExecutionEngine* IEE_t() { - MyIEE *iee = InitIExecutionEngine(); + MyIEE* iee = InitIExecutionEngine(); return iee; } @@ -24,46 +24,46 @@ HRESULT STDMETHODCALLTYPE GetCORSystemDirectory(LPWSTR pbuffer, DWORD cchBuffer, HANDLE ourHeap = nullptr; -LPVOID STDMETHODCALLTYPE EEHeapAllocInProcessHeap (DWORD dwFlags, SIZE_T dwBytes) +LPVOID EEHeapAllocInProcessHeap(DWORD dwFlags, SIZE_T dwBytes) { - if(ourHeap==nullptr) - ourHeap = HeapCreate(0, 4096 ,0); - if(ourHeap==nullptr) - { - LogError("HeapCreate Failed"); - __debugbreak(); - return nullptr; - } - LPVOID result = HeapAlloc(ourHeap, dwFlags, dwBytes); -// LogDebug("EEHeapAllocInProcessHeap %p %u %u", result, dwFlags, dwBytes); - return result; + if (ourHeap == nullptr) + ourHeap = HeapCreate(0, 4096, 0); + if (ourHeap == nullptr) + { + LogError("HeapCreate Failed"); + __debugbreak(); + return nullptr; + } + LPVOID result = HeapAlloc(ourHeap, dwFlags, dwBytes); + // LogDebug("EEHeapAllocInProcessHeap %p %u %u", result, dwFlags, dwBytes); + return result; } -BOOL STDMETHODCALLTYPE EEHeapFreeInProcessHeap (DWORD dwFlags, LPVOID lpMem) +BOOL EEHeapFreeInProcessHeap(DWORD dwFlags, LPVOID lpMem) { -// return true; + // return true; return HeapFree(ourHeap, dwFlags, lpMem); } -void* STDMETHODCALLTYPE GetCLRFunction(LPCSTR functionName) +void* GetCLRFunction(LPCSTR functionName) { - if(strcmp(functionName, "EEHeapAllocInProcessHeap")==0) + if (strcmp(functionName, "EEHeapAllocInProcessHeap") == 0) return (void*)EEHeapAllocInProcessHeap; - if(strcmp(functionName, "EEHeapFreeInProcessHeap")==0) + if (strcmp(functionName, "EEHeapFreeInProcessHeap") == 0) return (void*)EEHeapFreeInProcessHeap; DebugBreakorAV(132); return nullptr; } -CoreClrCallbacks *InitCoreClrCallbacks() +CoreClrCallbacks* InitCoreClrCallbacks() { - CoreClrCallbacks *temp = new CoreClrCallbacks(); + CoreClrCallbacks* temp = new CoreClrCallbacks(); ::ZeroMemory(temp, sizeof(CoreClrCallbacks)); - temp->m_hmodCoreCLR = (HINSTANCE)(size_t)0xbadbad01; // any non-null value seems okay... - temp->m_pfnIEE = IEE_t; - temp->m_pfnGetCORSystemDirectory = nullptr;//GetCORSystemDirectory; - temp->m_pfnGetCLRFunction = GetCLRFunction; + temp->m_hmodCoreCLR = (HINSTANCE)(size_t)0xbadbad01; // any non-null value seems okay... + temp->m_pfnIEE = IEE_t; + temp->m_pfnGetCORSystemDirectory = nullptr; // GetCORSystemDirectory; + temp->m_pfnGetCLRFunction = GetCLRFunction; return temp; } diff --git a/src/ToolBox/superpmi/superpmi/coreclrcallbacks.h b/src/ToolBox/superpmi/superpmi/coreclrcallbacks.h index cb3815525e..3305779535 100644 --- a/src/ToolBox/superpmi/superpmi/coreclrcallbacks.h +++ b/src/ToolBox/superpmi/superpmi/coreclrcallbacks.h @@ -6,13 +6,8 @@ #ifndef _CoreClrCallbacks #define _CoreClrCallbacks -#include "runtimedetails.h" +#include "coreclrcommoncallbacks.h" -IExecutionEngine* STDMETHODCALLTYPE IEE_t(); -HRESULT STDMETHODCALLTYPE GetCORSystemDirectory(LPWSTR pbuffer, DWORD cchBuffer, DWORD* pdwlength); -LPVOID STDMETHODCALLTYPE EEHeapAllocInProcessHeap (DWORD dwFlags, SIZE_T dwBytes); -BOOL STDMETHODCALLTYPE EEHeapFreeInProcessHeap (DWORD dwFlags, LPVOID lpMem); -void* STDMETHODCALLTYPE GetCLRFunction(LPCSTR functionName); -CoreClrCallbacks *InitCoreClrCallbacks(); +CoreClrCallbacks* InitCoreClrCallbacks(); -#endif
\ No newline at end of file +#endif diff --git a/src/ToolBox/superpmi/superpmi/cycletimer.cpp b/src/ToolBox/superpmi/superpmi/cycletimer.cpp index de0e19b935..7904e56fcb 100644 --- a/src/ToolBox/superpmi/superpmi/cycletimer.cpp +++ b/src/ToolBox/superpmi/superpmi/cycletimer.cpp @@ -8,8 +8,8 @@ CycleTimer::CycleTimer() { - start = 0; - stop = 0; + start = 0; + stop = 0; overhead = QueryOverhead(); } @@ -21,7 +21,7 @@ void CycleTimer::Start() { BOOL retVal = QueryThreadCycleTime(GetCurrentThread(), &start); - if(retVal == FALSE) + if (retVal == FALSE) { LogError("CycleTimer::Start unable to QPC. error was 0x%08x", ::GetLastError()); ::__debugbreak(); @@ -32,7 +32,7 @@ void CycleTimer::Stop() { BOOL retVal = QueryThreadCycleTime(GetCurrentThread(), &stop); - if(retVal == FALSE) + if (retVal == FALSE) { LogError("CycleTimer::Stop unable to QPC. error was 0x%08x", ::GetLastError()); ::__debugbreak(); @@ -49,12 +49,12 @@ unsigned __int64 CycleTimer::QueryOverhead() unsigned __int64 tot = 0; unsigned __int64 startCycles; unsigned __int64 endCycles; - const int N = 1000; + const int N = 1000; for (int i = 0; i < N; i++) { QueryThreadCycleTime(GetCurrentThread(), &startCycles); QueryThreadCycleTime(GetCurrentThread(), &endCycles); - tot += (endCycles-startCycles); + tot += (endCycles - startCycles); } - return tot/N; + return tot / N; }
\ No newline at end of file diff --git a/src/ToolBox/superpmi/superpmi/cycletimer.h b/src/ToolBox/superpmi/superpmi/cycletimer.h index 9ad855501a..a99d1c33dc 100644 --- a/src/ToolBox/superpmi/superpmi/cycletimer.h +++ b/src/ToolBox/superpmi/superpmi/cycletimer.h @@ -14,8 +14,8 @@ public: CycleTimer(); ~CycleTimer(); - void Start(); - void Stop(); + void Start(); + void Stop(); unsigned __int64 GetCycles(); unsigned __int64 QueryOverhead(); diff --git a/src/ToolBox/superpmi/superpmi/filecache.cpp b/src/ToolBox/superpmi/superpmi/filecache.cpp index dcd783a09b..0455fa9fe7 100644 --- a/src/ToolBox/superpmi/superpmi/filecache.cpp +++ b/src/ToolBox/superpmi/superpmi/filecache.cpp @@ -8,93 +8,89 @@ #include "standardpch.h" #include "filecache.h" -#define FileCacheSize 0xFFFFFF //needs to be bigger than the biggest read request. +#define FileCacheSize 0xFFFFFF // needs to be bigger than the biggest read request. -HANDLE FileCache::cachedHandle; -bool FileCache::openAsCache; -BYTE *FileCache::rawBuff; +HANDLE FileCache::cachedHandle; +bool FileCache::openAsCache; +BYTE* FileCache::rawBuff; unsigned int FileCache::offset; unsigned int FileCache::length; -__int64 FileCache::fileoffset; +__int64 FileCache::fileoffset; HANDLE -FileCache::CreateFileA( - _In_ LPCSTR lpFileName, - _In_ DWORD dwDesiredAccess, - _In_ DWORD dwShareMode, - _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, - _In_ DWORD dwCreationDisposition, - _In_ DWORD dwFlagsAndAttributes, - _In_opt_ HANDLE hTemplateFile - ) +FileCache::CreateFileA(_In_ LPCSTR lpFileName, + _In_ DWORD dwDesiredAccess, + _In_ DWORD dwShareMode, + _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, + _In_ DWORD dwCreationDisposition, + _In_ DWORD dwFlagsAndAttributes, + _In_opt_ HANDLE hTemplateFile) { openAsCache = false; - rawBuff = nullptr; - offset = 0; - length = 0; + rawBuff = nullptr; + offset = 0; + length = 0; - if((dwShareMode&CACHE_THIS_FILE)==CACHE_THIS_FILE) + if ((dwShareMode & CACHE_THIS_FILE) == CACHE_THIS_FILE) { dwShareMode ^= CACHE_THIS_FILE; openAsCache = true; } - HANDLE temp = ::CreateFileA(lpFileName, dwDesiredAccess, dwShareMode, lpSecurityAttributes, dwCreationDisposition, dwFlagsAndAttributes, hTemplateFile); - if(openAsCache) - cachedHandle = temp; //yes yes.. this is unsafe.. but one accessor now is okay. bswhack + HANDLE temp = ::CreateFileA(lpFileName, dwDesiredAccess, dwShareMode, lpSecurityAttributes, dwCreationDisposition, + dwFlagsAndAttributes, hTemplateFile); + if (openAsCache) + cachedHandle = temp; // yes yes.. this is unsafe.. but one accessor now is okay. bswhack return temp; } HANDLE -FileCache::CreateFileW( - _In_ LPCWSTR lpFileName, - _In_ DWORD dwDesiredAccess, - _In_ DWORD dwShareMode, - _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, - _In_ DWORD dwCreationDisposition, - _In_ DWORD dwFlagsAndAttributes, - _In_opt_ HANDLE hTemplateFile - ) +FileCache::CreateFileW(_In_ LPCWSTR lpFileName, + _In_ DWORD dwDesiredAccess, + _In_ DWORD dwShareMode, + _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, + _In_ DWORD dwCreationDisposition, + _In_ DWORD dwFlagsAndAttributes, + _In_opt_ HANDLE hTemplateFile) { openAsCache = false; - rawBuff = nullptr; - offset = 0; - length = 0; - return ::CreateFileW(lpFileName, dwDesiredAccess, dwShareMode, lpSecurityAttributes, dwCreationDisposition, dwFlagsAndAttributes, hTemplateFile); + rawBuff = nullptr; + offset = 0; + length = 0; + return ::CreateFileW(lpFileName, dwDesiredAccess, dwShareMode, lpSecurityAttributes, dwCreationDisposition, + dwFlagsAndAttributes, hTemplateFile); } - -//Somewhat sloppy quick copy... we don't treat lpNumberOfBytesRead etc correctly -BOOL -FileCache::ReadFile( - _In_ HANDLE hFile, - _Out_writes_bytes_to_opt_(nNumberOfBytesToRead, *lpNumberOfBytesRead) __out_data_source(FILE) LPVOID lpBuffer, - _In_ DWORD nNumberOfBytesToRead, - _Out_opt_ LPDWORD lpNumberOfBytesRead, - _Inout_opt_ LPOVERLAPPED lpOverlapped - ) +// Somewhat sloppy quick copy... we don't treat lpNumberOfBytesRead etc correctly +BOOL FileCache::ReadFile(_In_ HANDLE hFile, + _Out_writes_bytes_to_opt_(nNumberOfBytesToRead, *lpNumberOfBytesRead) __out_data_source(FILE) + LPVOID lpBuffer, + _In_ DWORD nNumberOfBytesToRead, + _Out_opt_ LPDWORD lpNumberOfBytesRead, + _Inout_opt_ LPOVERLAPPED lpOverlapped) { - if(!openAsCache) + if (!openAsCache) return ::ReadFile(hFile, lpBuffer, nNumberOfBytesToRead, lpNumberOfBytesRead, lpOverlapped); else { - if(rawBuff == nullptr) + if (rawBuff == nullptr) { rawBuff = new BYTE[FileCacheSize]; - length = FileCacheSize; - offset = FileCacheSize; + length = FileCacheSize; + offset = FileCacheSize; } - if(nNumberOfBytesToRead > FileCacheSize) + if (nNumberOfBytesToRead > FileCacheSize) { printf("ERROR: nNumberOfBytesToRead exceeds FileCacheSize %u > %u\n", nNumberOfBytesToRead, FileCacheSize); __debugbreak(); } - if((offset+nNumberOfBytesToRead) > length) + if ((offset + nNumberOfBytesToRead) > length) { - memmove(rawBuff, &rawBuff[offset], length-offset); //Use memmove since we have overlapping regions more than half the time - ::ReadFile(hFile, &rawBuff[length-offset], offset, lpNumberOfBytesRead, lpOverlapped); - if(*lpNumberOfBytesRead ==0) + memmove(rawBuff, &rawBuff[offset], + length - offset); // Use memmove since we have overlapping regions more than half the time + ::ReadFile(hFile, &rawBuff[length - offset], offset, lpNumberOfBytesRead, lpOverlapped); + if (*lpNumberOfBytesRead == 0) __debugbreak(); - length -= offset-(*lpNumberOfBytesRead); + length -= offset - (*lpNumberOfBytesRead); LARGE_INTEGER DataTemp; LARGE_INTEGER zero; zero.QuadPart = 0; @@ -104,23 +100,20 @@ FileCache::ReadFile( offset = 0; } memcpy(lpBuffer, &rawBuff[offset], nNumberOfBytesToRead); - offset+=nNumberOfBytesToRead; - if(offset > FileCacheSize) + offset += nNumberOfBytesToRead; + if (offset > FileCacheSize) __debugbreak(); return true; } } -BOOL -FileCache::WriteFile( - _In_ HANDLE hFile, - _In_reads_bytes_opt_(nNumberOfBytesToWrite) LPCVOID lpBuffer, - _In_ DWORD nNumberOfBytesToWrite, - _Out_opt_ LPDWORD lpNumberOfBytesWritten, - _Inout_opt_ LPOVERLAPPED lpOverlapped - ) +BOOL FileCache::WriteFile(_In_ HANDLE hFile, + _In_reads_bytes_opt_(nNumberOfBytesToWrite) LPCVOID lpBuffer, + _In_ DWORD nNumberOfBytesToWrite, + _Out_opt_ LPDWORD lpNumberOfBytesWritten, + _Inout_opt_ LPOVERLAPPED lpOverlapped) { - if(!openAsCache) + if (!openAsCache) return ::WriteFile(hFile, lpBuffer, nNumberOfBytesToWrite, lpNumberOfBytesWritten, lpOverlapped); else { @@ -130,17 +123,14 @@ FileCache::WriteFile( } } -BOOL -FileCache::CloseHandle( - _In_ HANDLE hObject - ) +BOOL FileCache::CloseHandle(_In_ HANDLE hObject) { - if(!openAsCache) + if (!openAsCache) return ::CloseHandle(hObject); else { - if(rawBuff!=nullptr) - delete []rawBuff; + if (rawBuff != nullptr) + delete[] rawBuff; return ::CloseHandle(hObject); } } diff --git a/src/ToolBox/superpmi/superpmi/filecache.h b/src/ToolBox/superpmi/superpmi/filecache.h index 51df5edde9..876100ec6e 100644 --- a/src/ToolBox/superpmi/superpmi/filecache.h +++ b/src/ToolBox/superpmi/superpmi/filecache.h @@ -19,60 +19,45 @@ class FileCache { public: - -static HANDLE -CreateFileA( - _In_ LPCSTR lpFileName, - _In_ DWORD dwDesiredAccess, - _In_ DWORD dwShareMode, - _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, - _In_ DWORD dwCreationDisposition, - _In_ DWORD dwFlagsAndAttributes, - _In_opt_ HANDLE hTemplateFile - ); - -static HANDLE -CreateFileW( - _In_ LPCWSTR lpFileName, - _In_ DWORD dwDesiredAccess, - _In_ DWORD dwShareMode, - _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, - _In_ DWORD dwCreationDisposition, - _In_ DWORD dwFlagsAndAttributes, - _In_opt_ HANDLE hTemplateFile - ); - -static BOOL -ReadFile( - _In_ HANDLE hFile, - _Out_writes_bytes_to_opt_(nNumberOfBytesToRead, *lpNumberOfBytesRead) __out_data_source(FILE) LPVOID lpBuffer, - _In_ DWORD nNumberOfBytesToRead, - _Out_opt_ LPDWORD lpNumberOfBytesRead, - _Inout_opt_ LPOVERLAPPED lpOverlapped - ); - -static BOOL -WriteFile( - _In_ HANDLE hFile, - _In_reads_bytes_opt_(nNumberOfBytesToWrite) LPCVOID lpBuffer, - _In_ DWORD nNumberOfBytesToWrite, - _Out_opt_ LPDWORD lpNumberOfBytesWritten, - _Inout_opt_ LPOVERLAPPED lpOverlapped - ); - -static BOOL -CloseHandle( - _In_ HANDLE hObject - ); - -static __int64 GetFilePos(HANDLE hFile); + static HANDLE CreateFileA(_In_ LPCSTR lpFileName, + _In_ DWORD dwDesiredAccess, + _In_ DWORD dwShareMode, + _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, + _In_ DWORD dwCreationDisposition, + _In_ DWORD dwFlagsAndAttributes, + _In_opt_ HANDLE hTemplateFile); + + static HANDLE CreateFileW(_In_ LPCWSTR lpFileName, + _In_ DWORD dwDesiredAccess, + _In_ DWORD dwShareMode, + _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, + _In_ DWORD dwCreationDisposition, + _In_ DWORD dwFlagsAndAttributes, + _In_opt_ HANDLE hTemplateFile); + + static BOOL ReadFile(_In_ HANDLE hFile, + _Out_writes_bytes_to_opt_(nNumberOfBytesToRead, *lpNumberOfBytesRead) __out_data_source(FILE) + LPVOID lpBuffer, + _In_ DWORD nNumberOfBytesToRead, + _Out_opt_ LPDWORD lpNumberOfBytesRead, + _Inout_opt_ LPOVERLAPPED lpOverlapped); + + static BOOL WriteFile(_In_ HANDLE hFile, + _In_reads_bytes_opt_(nNumberOfBytesToWrite) LPCVOID lpBuffer, + _In_ DWORD nNumberOfBytesToWrite, + _Out_opt_ LPDWORD lpNumberOfBytesWritten, + _Inout_opt_ LPOVERLAPPED lpOverlapped); + + static BOOL CloseHandle(_In_ HANDLE hObject); + + static __int64 GetFilePos(HANDLE hFile); private: - static HANDLE cachedHandle; - static bool openAsCache; - static BYTE *rawBuff; + static HANDLE cachedHandle; + static bool openAsCache; + static BYTE* rawBuff; static unsigned int offset; static unsigned int length; - static __int64 fileoffset; + static __int64 fileoffset; }; #endif diff --git a/src/ToolBox/superpmi/superpmi/icorjitinfo.cpp b/src/ToolBox/superpmi/superpmi/icorjitinfo.cpp index 6478b3c684..59ad3c5e40 100644 --- a/src/ToolBox/superpmi/superpmi/icorjitinfo.cpp +++ b/src/ToolBox/superpmi/superpmi/icorjitinfo.cpp @@ -8,17 +8,17 @@ #include "jitdebugger.h" #include "spmiutil.h" -ICorJitInfo *pICJI = nullptr; +ICorJitInfo* pICJI = nullptr; -ICorJitInfo* InitICorJitInfo(JitInstance *jitInstance) +ICorJitInfo* InitICorJitInfo(JitInstance* jitInstance) { - MyICJI *icji = new MyICJI(); + MyICJI* icji = new MyICJI(); icji->jitInstance = jitInstance; - pICJI = icji; + pICJI = icji; return icji; } -//Stuff on ICorStaticInfo +// Stuff on ICorStaticInfo /**********************************************************************************/ // // ICorMethodInfo @@ -26,54 +26,50 @@ ICorJitInfo* InitICorJitInfo(JitInstance *jitInstance) /**********************************************************************************/ // return flags (defined above, CORINFO_FLG_PUBLIC ...) -DWORD MyICJI::getMethodAttribs (CORINFO_METHOD_HANDLE ftn /* IN */) +DWORD MyICJI::getMethodAttribs(CORINFO_METHOD_HANDLE ftn /* IN */) { jitInstance->mc->cr->AddCall("getMethodAttribs"); return jitInstance->mc->repGetMethodAttribs(ftn); } // sets private JIT flags, which can be, retrieved using getAttrib. -void MyICJI::setMethodAttribs (CORINFO_METHOD_HANDLE ftn,/* IN */ - CorInfoMethodRuntimeFlags attribs/* IN */) +void MyICJI::setMethodAttribs(CORINFO_METHOD_HANDLE ftn, /* IN */ + CorInfoMethodRuntimeFlags attribs /* IN */) { jitInstance->mc->cr->AddCall("setMethodAttribs"); jitInstance->mc->cr->recSetMethodAttribs(ftn, attribs); } - // Given a method descriptor ftnHnd, extract signature information into sigInfo // // 'memberParent' is typically only set when verifying. It should be the // result of calling getMemberParent. -void MyICJI::getMethodSig ( - CORINFO_METHOD_HANDLE ftn, /* IN */ - CORINFO_SIG_INFO *sig, /* OUT */ - CORINFO_CLASS_HANDLE memberParent/* IN */ - ) +void MyICJI::getMethodSig(CORINFO_METHOD_HANDLE ftn, /* IN */ + CORINFO_SIG_INFO* sig, /* OUT */ + CORINFO_CLASS_HANDLE memberParent /* IN */ + ) { jitInstance->mc->cr->AddCall("getMethodSig"); jitInstance->mc->repGetMethodSig(ftn, sig, memberParent); } +/********************************************************************* +* Note the following methods can only be used on functions known +* to be IL. This includes the method being compiled and any method +* that 'getMethodInfo' returns true for +*********************************************************************/ - /********************************************************************* - * Note the following methods can only be used on functions known - * to be IL. This includes the method being compiled and any method - * that 'getMethodInfo' returns true for - *********************************************************************/ - - // return information about a method private to the implementation - // returns false if method is not IL, or is otherwise unavailable. - // This method is used to fetch data needed to inline functions - bool MyICJI::getMethodInfo ( - CORINFO_METHOD_HANDLE ftn, /* IN */ - CORINFO_METHOD_INFO* info /* OUT */ - ) +// return information about a method private to the implementation +// returns false if method is not IL, or is otherwise unavailable. +// This method is used to fetch data needed to inline functions +bool MyICJI::getMethodInfo(CORINFO_METHOD_HANDLE ftn, /* IN */ + CORINFO_METHOD_INFO* info /* OUT */ + ) { jitInstance->mc->cr->AddCall("getMethodInfo"); DWORD exceptionCode = 0; - bool value = jitInstance->mc->repGetMethodInfo(ftn, info, &exceptionCode); - if(exceptionCode != 0) + bool value = jitInstance->mc->repGetMethodInfo(ftn, info, &exceptionCode); + if (exceptionCode != 0) ThrowException(exceptionCode); return value; } @@ -87,17 +83,16 @@ void MyICJI::getMethodSig ( // // The inlined method need not be verified -CorInfoInline MyICJI::canInline ( - CORINFO_METHOD_HANDLE callerHnd, /* IN */ - CORINFO_METHOD_HANDLE calleeHnd, /* IN */ - DWORD* pRestrictions /* OUT */ - ) +CorInfoInline MyICJI::canInline(CORINFO_METHOD_HANDLE callerHnd, /* IN */ + CORINFO_METHOD_HANDLE calleeHnd, /* IN */ + DWORD* pRestrictions /* OUT */ + ) { jitInstance->mc->cr->AddCall("canInline"); - DWORD exceptionCode = 0; - CorInfoInline result = jitInstance->mc->repCanInline(callerHnd, calleeHnd, pRestrictions, &exceptionCode); - if(exceptionCode != 0) + DWORD exceptionCode = 0; + CorInfoInline result = jitInstance->mc->repCanInline(callerHnd, calleeHnd, pRestrictions, &exceptionCode); + if (exceptionCode != 0) ThrowException(exceptionCode); return result; } @@ -105,25 +100,23 @@ CorInfoInline MyICJI::canInline ( // Reports whether or not a method can be inlined, and why. canInline is responsible for reporting all // inlining results when it returns INLINE_FAIL and INLINE_NEVER. All other results are reported by the // JIT. -void MyICJI::reportInliningDecision (CORINFO_METHOD_HANDLE inlinerHnd, - CORINFO_METHOD_HANDLE inlineeHnd, - CorInfoInline inlineResult, - const char * reason) +void MyICJI::reportInliningDecision(CORINFO_METHOD_HANDLE inlinerHnd, + CORINFO_METHOD_HANDLE inlineeHnd, + CorInfoInline inlineResult, + const char* reason) { jitInstance->mc->cr->AddCall("reportInliningDecision"); jitInstance->mc->cr->recReportInliningDecision(inlinerHnd, inlineeHnd, inlineResult, reason); } - // Returns false if the call is across security boundaries thus we cannot tailcall // // The callerHnd must be the immediate caller (i.e. when we have a chain of inlined calls) -bool MyICJI::canTailCall ( - CORINFO_METHOD_HANDLE callerHnd, /* IN */ - CORINFO_METHOD_HANDLE declaredCalleeHnd, /* IN */ - CORINFO_METHOD_HANDLE exactCalleeHnd, /* IN */ - bool fIsTailPrefix /* IN */ - ) +bool MyICJI::canTailCall(CORINFO_METHOD_HANDLE callerHnd, /* IN */ + CORINFO_METHOD_HANDLE declaredCalleeHnd, /* IN */ + CORINFO_METHOD_HANDLE exactCalleeHnd, /* IN */ + bool fIsTailPrefix /* IN */ + ) { jitInstance->mc->cr->AddCall("canTailCall"); return jitInstance->mc->repCanTailCall(callerHnd, declaredCalleeHnd, exactCalleeHnd, fIsTailPrefix); @@ -132,40 +125,35 @@ bool MyICJI::canTailCall ( // Reports whether or not a method can be tail called, and why. // canTailCall is responsible for reporting all results when it returns // false. All other results are reported by the JIT. -void MyICJI::reportTailCallDecision (CORINFO_METHOD_HANDLE callerHnd, - CORINFO_METHOD_HANDLE calleeHnd, - bool fIsTailPrefix, - CorInfoTailCall tailCallResult, - const char * reason) +void MyICJI::reportTailCallDecision(CORINFO_METHOD_HANDLE callerHnd, + CORINFO_METHOD_HANDLE calleeHnd, + bool fIsTailPrefix, + CorInfoTailCall tailCallResult, + const char* reason) { jitInstance->mc->cr->AddCall("reportTailCallDecision"); jitInstance->mc->cr->recReportTailCallDecision(callerHnd, calleeHnd, fIsTailPrefix, tailCallResult, reason); } // get individual exception handler -void MyICJI::getEHinfo( - CORINFO_METHOD_HANDLE ftn, /* IN */ - unsigned EHnumber, /* IN */ - CORINFO_EH_CLAUSE* clause /* OUT */ - ) +void MyICJI::getEHinfo(CORINFO_METHOD_HANDLE ftn, /* IN */ + unsigned EHnumber, /* IN */ + CORINFO_EH_CLAUSE* clause /* OUT */ + ) { jitInstance->mc->cr->AddCall("getEHinfo"); jitInstance->mc->repGetEHinfo(ftn, EHnumber, clause); } // return class it belongs to -CORINFO_CLASS_HANDLE MyICJI::getMethodClass ( - CORINFO_METHOD_HANDLE method - ) +CORINFO_CLASS_HANDLE MyICJI::getMethodClass(CORINFO_METHOD_HANDLE method) { jitInstance->mc->cr->AddCall("getMethodClass"); return jitInstance->mc->repGetMethodClass(method); } // return module it belongs to -CORINFO_MODULE_HANDLE MyICJI::getMethodModule ( - CORINFO_METHOD_HANDLE method - ) +CORINFO_MODULE_HANDLE MyICJI::getMethodModule(CORINFO_METHOD_HANDLE method) { jitInstance->mc->cr->AddCall("getMethodModule"); LogError("Hit unimplemented getMethodModule"); @@ -175,11 +163,10 @@ CORINFO_MODULE_HANDLE MyICJI::getMethodModule ( // This function returns the offset of the specified method in the // vtable of it's owning class or interface. -void MyICJI::getMethodVTableOffset ( - CORINFO_METHOD_HANDLE method, /* IN */ - unsigned* offsetOfIndirection, /* OUT */ - unsigned* offsetAfterIndirection /* OUT */ - ) +void MyICJI::getMethodVTableOffset(CORINFO_METHOD_HANDLE method, /* IN */ + unsigned* offsetOfIndirection, /* OUT */ + unsigned* offsetAfterIndirection /* OUT */ + ) { jitInstance->mc->cr->AddCall("getMethodVTableOffset"); jitInstance->mc->repGetMethodVTableOffset(method, offsetOfIndirection, offsetAfterIndirection); @@ -187,41 +174,34 @@ void MyICJI::getMethodVTableOffset ( // Find the virtual method in implementingClass that overrides virtualMethod. // Return null if devirtualization is not possible. -CORINFO_METHOD_HANDLE MyICJI::resolveVirtualMethod( - CORINFO_METHOD_HANDLE virtualMethod, - CORINFO_CLASS_HANDLE implementingClass, - CORINFO_CONTEXT_HANDLE ownerType - ) +CORINFO_METHOD_HANDLE MyICJI::resolveVirtualMethod(CORINFO_METHOD_HANDLE virtualMethod, + CORINFO_CLASS_HANDLE implementingClass, + CORINFO_CONTEXT_HANDLE ownerType) { jitInstance->mc->cr->AddCall("resolveVirtualMethod"); - CORINFO_METHOD_HANDLE result = jitInstance->mc->repResolveVirtualMethod(virtualMethod, implementingClass, ownerType); + CORINFO_METHOD_HANDLE result = + jitInstance->mc->repResolveVirtualMethod(virtualMethod, implementingClass, ownerType); return result; } // If a method's attributes have (getMethodAttribs) CORINFO_FLG_INTRINSIC set, // getIntrinsicID() returns the intrinsic ID. -CorInfoIntrinsics MyICJI::getIntrinsicID( - CORINFO_METHOD_HANDLE method, - bool* pMustExpand /* OUT */ - ) +CorInfoIntrinsics MyICJI::getIntrinsicID(CORINFO_METHOD_HANDLE method, bool* pMustExpand /* OUT */ + ) { jitInstance->mc->cr->AddCall("getIntrinsicID"); return jitInstance->mc->repGetIntrinsicID(method, pMustExpand); } // Is the given module the System.Numerics.Vectors module? -bool MyICJI::isInSIMDModule( - CORINFO_CLASS_HANDLE classHnd - ) +bool MyICJI::isInSIMDModule(CORINFO_CLASS_HANDLE classHnd) { jitInstance->mc->cr->AddCall("isInSIMDModule"); return jitInstance->mc->repIsInSIMDModule(classHnd) ? true : false; } // return the unmanaged calling convention for a PInvoke -CorInfoUnmanagedCallConv MyICJI::getUnmanagedCallConv( - CORINFO_METHOD_HANDLE method - ) +CorInfoUnmanagedCallConv MyICJI::getUnmanagedCallConv(CORINFO_METHOD_HANDLE method) { jitInstance->mc->cr->AddCall("getUnmanagedCallConv"); return jitInstance->mc->repGetUnmanagedCallConv(method); @@ -229,10 +209,7 @@ CorInfoUnmanagedCallConv MyICJI::getUnmanagedCallConv( // return if any marshaling is required for PInvoke methods. Note that // method == 0 => calli. The call site sig is only needed for the varargs or calli case -BOOL MyICJI::pInvokeMarshalingRequired( - CORINFO_METHOD_HANDLE method, - CORINFO_SIG_INFO* callSiteSig - ) +BOOL MyICJI::pInvokeMarshalingRequired(CORINFO_METHOD_HANDLE method, CORINFO_SIG_INFO* callSiteSig) { jitInstance->mc->cr->AddCall("pInvokeMarshalingRequired"); return jitInstance->mc->repPInvokeMarshalingRequired(method, callSiteSig); @@ -240,10 +217,8 @@ BOOL MyICJI::pInvokeMarshalingRequired( // Check constraints on method type arguments (only). // The parent class should be checked separately using satisfiesClassConstraints(parent). -BOOL MyICJI::satisfiesMethodConstraints( - CORINFO_CLASS_HANDLE parent, // the exact parent of the method - CORINFO_METHOD_HANDLE method - ) +BOOL MyICJI::satisfiesMethodConstraints(CORINFO_CLASS_HANDLE parent, // the exact parent of the method + CORINFO_METHOD_HANDLE method) { jitInstance->mc->cr->AddCall("satisfiesMethodConstraints"); return jitInstance->mc->repSatisfiesMethodConstraints(parent, method); @@ -252,34 +227,28 @@ BOOL MyICJI::satisfiesMethodConstraints( // Given a delegate target class, a target method parent class, a target method, // a delegate class, check if the method signature is compatible with the Invoke method of the delegate // (under the typical instantiation of any free type variables in the memberref signatures). -BOOL MyICJI::isCompatibleDelegate( - CORINFO_CLASS_HANDLE objCls, /* type of the delegate target, if any */ - CORINFO_CLASS_HANDLE methodParentCls, /* exact parent of the target method, if any */ - CORINFO_METHOD_HANDLE method, /* (representative) target method, if any */ - CORINFO_CLASS_HANDLE delegateCls, /* exact type of the delegate */ - BOOL *pfIsOpenDelegate /* is the delegate open */ - ) +BOOL MyICJI::isCompatibleDelegate(CORINFO_CLASS_HANDLE objCls, /* type of the delegate target, if any */ + CORINFO_CLASS_HANDLE methodParentCls, /* exact parent of the target method, if any */ + CORINFO_METHOD_HANDLE method, /* (representative) target method, if any */ + CORINFO_CLASS_HANDLE delegateCls, /* exact type of the delegate */ + BOOL* pfIsOpenDelegate /* is the delegate open */ + ) { jitInstance->mc->cr->AddCall("isCompatibleDelegate"); return jitInstance->mc->repIsCompatibleDelegate(objCls, methodParentCls, method, delegateCls, pfIsOpenDelegate); } // Determines whether the delegate creation obeys security transparency rules -BOOL MyICJI::isDelegateCreationAllowed ( - CORINFO_CLASS_HANDLE delegateHnd, - CORINFO_METHOD_HANDLE calleeHnd - ) +BOOL MyICJI::isDelegateCreationAllowed(CORINFO_CLASS_HANDLE delegateHnd, CORINFO_METHOD_HANDLE calleeHnd) { jitInstance->mc->cr->AddCall("isDelegateCreationAllowed"); return jitInstance->mc->repIsDelegateCreationAllowed(delegateHnd, calleeHnd); } - // Indicates if the method is an instance of the generic // method that passes (or has passed) verification -CorInfoInstantiationVerification MyICJI::isInstantiationOfVerifiedGeneric ( - CORINFO_METHOD_HANDLE method /* IN */ - ) +CorInfoInstantiationVerification MyICJI::isInstantiationOfVerifiedGeneric(CORINFO_METHOD_HANDLE method /* IN */ + ) { jitInstance->mc->cr->AddCall("isInstantiationOfVerifiedGeneric"); return jitInstance->mc->repIsInstantiationOfVerifiedGeneric(method); @@ -287,38 +256,32 @@ CorInfoInstantiationVerification MyICJI::isInstantiationOfVerifiedGeneric ( // Loads the constraints on a typical method definition, detecting cycles; // for use in verification. -void MyICJI::initConstraintsForVerification( - CORINFO_METHOD_HANDLE method, /* IN */ - BOOL *pfHasCircularClassConstraints, /* OUT */ - BOOL *pfHasCircularMethodConstraint /* OUT */ - ) +void MyICJI::initConstraintsForVerification(CORINFO_METHOD_HANDLE method, /* IN */ + BOOL* pfHasCircularClassConstraints, /* OUT */ + BOOL* pfHasCircularMethodConstraint /* OUT */ + ) { jitInstance->mc->cr->AddCall("initConstraintsForVerification"); - jitInstance->mc->repInitConstraintsForVerification(method, pfHasCircularClassConstraints, pfHasCircularMethodConstraint); + jitInstance->mc->repInitConstraintsForVerification(method, pfHasCircularClassConstraints, + pfHasCircularMethodConstraint); } // Returns enum whether the method does not require verification // Also see ICorModuleInfo::canSkipVerification -CorInfoCanSkipVerificationResult MyICJI::canSkipMethodVerification ( - CORINFO_METHOD_HANDLE ftnHandle - ) +CorInfoCanSkipVerificationResult MyICJI::canSkipMethodVerification(CORINFO_METHOD_HANDLE ftnHandle) { jitInstance->mc->cr->AddCall("canSkipMethodVerification"); return jitInstance->mc->repCanSkipMethodVerification(ftnHandle, FALSE); } // load and restore the method -void MyICJI::methodMustBeLoadedBeforeCodeIsRun( - CORINFO_METHOD_HANDLE method - ) +void MyICJI::methodMustBeLoadedBeforeCodeIsRun(CORINFO_METHOD_HANDLE method) { jitInstance->mc->cr->AddCall("methodMustBeLoadedBeforeCodeIsRun"); jitInstance->mc->cr->recMethodMustBeLoadedBeforeCodeIsRun(method); } -CORINFO_METHOD_HANDLE MyICJI::mapMethodDeclToMethodImpl( - CORINFO_METHOD_HANDLE method - ) +CORINFO_METHOD_HANDLE MyICJI::mapMethodDeclToMethodImpl(CORINFO_METHOD_HANDLE method) { jitInstance->mc->cr->AddCall("mapMethodDeclToMethodImpl"); LogError("Hit unimplemented mapMethodDeclToMethodImpl"); @@ -328,10 +291,9 @@ CORINFO_METHOD_HANDLE MyICJI::mapMethodDeclToMethodImpl( // Returns the global cookie for the /GS unsafe buffer checks // The cookie might be a constant value (JIT), or a handle to memory location (Ngen) -void MyICJI::getGSCookie( - GSCookie * pCookieVal, // OUT - GSCookie ** ppCookieVal // OUT - ) +void MyICJI::getGSCookie(GSCookie* pCookieVal, // OUT + GSCookie** ppCookieVal // OUT + ) { jitInstance->mc->cr->AddCall("getGSCookie"); jitInstance->mc->repGetGSCookie(pCookieVal, ppCookieVal); @@ -344,29 +306,28 @@ void MyICJI::getGSCookie( /**********************************************************************************/ // Resolve metadata token into runtime method handles. -void MyICJI::resolveToken(/* IN, OUT */ CORINFO_RESOLVED_TOKEN * pResolvedToken) +void MyICJI::resolveToken(/* IN, OUT */ CORINFO_RESOLVED_TOKEN* pResolvedToken) { DWORD exceptionCode = 0; jitInstance->mc->cr->AddCall("resolveToken"); jitInstance->mc->repResolveToken(pResolvedToken, &exceptionCode); - if(exceptionCode != 0) + if (exceptionCode != 0) ThrowException(exceptionCode); } // Resolve metadata token into runtime method handles. -bool MyICJI::tryResolveToken(/* IN, OUT */ CORINFO_RESOLVED_TOKEN * pResolvedToken) +bool MyICJI::tryResolveToken(/* IN, OUT */ CORINFO_RESOLVED_TOKEN* pResolvedToken) { jitInstance->mc->cr->AddCall("tryResolveToken"); return jitInstance->mc->repTryResolveToken(pResolvedToken); } // Signature information about the call sig -void MyICJI::findSig ( - CORINFO_MODULE_HANDLE module, /* IN */ - unsigned sigTOK, /* IN */ - CORINFO_CONTEXT_HANDLE context, /* IN */ - CORINFO_SIG_INFO *sig /* OUT */ - ) +void MyICJI::findSig(CORINFO_MODULE_HANDLE module, /* IN */ + unsigned sigTOK, /* IN */ + CORINFO_CONTEXT_HANDLE context, /* IN */ + CORINFO_SIG_INFO* sig /* OUT */ + ) { jitInstance->mc->cr->AddCall("findSig"); jitInstance->mc->repFindSig(module, sigTOK, context, sig); @@ -375,19 +336,17 @@ void MyICJI::findSig ( // for Varargs, the signature at the call site may differ from // the signature at the definition. Thus we need a way of // fetching the call site information -void MyICJI::findCallSiteSig ( - CORINFO_MODULE_HANDLE module, /* IN */ - unsigned methTOK, /* IN */ - CORINFO_CONTEXT_HANDLE context, /* IN */ - CORINFO_SIG_INFO *sig /* OUT */ - ) +void MyICJI::findCallSiteSig(CORINFO_MODULE_HANDLE module, /* IN */ + unsigned methTOK, /* IN */ + CORINFO_CONTEXT_HANDLE context, /* IN */ + CORINFO_SIG_INFO* sig /* OUT */ + ) { jitInstance->mc->cr->AddCall("findCallSiteSig"); jitInstance->mc->repFindCallSiteSig(module, methTOK, context, sig); } -CORINFO_CLASS_HANDLE MyICJI::getTokenTypeAsHandle ( - CORINFO_RESOLVED_TOKEN * pResolvedToken /* IN */) +CORINFO_CLASS_HANDLE MyICJI::getTokenTypeAsHandle(CORINFO_RESOLVED_TOKEN* pResolvedToken /* IN */) { jitInstance->mc->cr->AddCall("getTokenTypeAsHandle"); return jitInstance->mc->repGetTokenTypeAsHandle(pResolvedToken); @@ -404,9 +363,8 @@ CORINFO_CLASS_HANDLE MyICJI::getTokenTypeAsHandle ( // Returns enum whether the module does not require verification // Also see ICorMethodInfo::canSkipMethodVerification(); -CorInfoCanSkipVerificationResult MyICJI::canSkipVerification ( - CORINFO_MODULE_HANDLE module /* IN */ - ) +CorInfoCanSkipVerificationResult MyICJI::canSkipVerification(CORINFO_MODULE_HANDLE module /* IN */ + ) { jitInstance->mc->cr->AddCall("canSkipVerification"); LogError("Hit unimplemented canSkipVerification"); @@ -415,28 +373,24 @@ CorInfoCanSkipVerificationResult MyICJI::canSkipVerification ( } // Checks if the given metadata token is valid -BOOL MyICJI::isValidToken ( - CORINFO_MODULE_HANDLE module, /* IN */ - unsigned metaTOK /* IN */ - ) +BOOL MyICJI::isValidToken(CORINFO_MODULE_HANDLE module, /* IN */ + unsigned metaTOK /* IN */ + ) { jitInstance->mc->cr->AddCall("isValidToken"); return jitInstance->mc->repIsValidToken(module, metaTOK); } // Checks if the given metadata token is valid StringRef -BOOL MyICJI::isValidStringRef ( - CORINFO_MODULE_HANDLE module, /* IN */ - unsigned metaTOK /* IN */ - ) +BOOL MyICJI::isValidStringRef(CORINFO_MODULE_HANDLE module, /* IN */ + unsigned metaTOK /* IN */ + ) { jitInstance->mc->cr->AddCall("isValidStringRef"); return jitInstance->mc->repIsValidStringRef(module, metaTOK); } -BOOL MyICJI::shouldEnforceCallvirtRestriction( - CORINFO_MODULE_HANDLE scope - ) +BOOL MyICJI::shouldEnforceCallvirtRestriction(CORINFO_MODULE_HANDLE scope) { jitInstance->mc->cr->AddCall("shouldEnforceCallvirtRestriction"); return jitInstance->mc->repShouldEnforceCallvirtRestriction(scope); @@ -450,48 +404,41 @@ BOOL MyICJI::shouldEnforceCallvirtRestriction( // If the value class 'cls' is isomorphic to a primitive type it will // return that type, otherwise it will return CORINFO_TYPE_VALUECLASS -CorInfoType MyICJI::asCorInfoType ( - CORINFO_CLASS_HANDLE cls - ) +CorInfoType MyICJI::asCorInfoType(CORINFO_CLASS_HANDLE cls) { jitInstance->mc->cr->AddCall("asCorInfoType"); return jitInstance->mc->repAsCorInfoType(cls); } // for completeness -const char* MyICJI::getClassName ( - CORINFO_CLASS_HANDLE cls - ) +const char* MyICJI::getClassName(CORINFO_CLASS_HANDLE cls) { jitInstance->mc->cr->AddCall("getClassName"); const char* result = jitInstance->mc->repGetClassName(cls); return result; } - // Append a (possibly truncated) representation of the type cls to the preallocated buffer ppBuf of length pnBufLen // If fNamespace=TRUE, include the namespace/enclosing classes // If fFullInst=TRUE (regardless of fNamespace and fAssembly), include namespace and assembly for any type parameters // If fAssembly=TRUE, suffix with a comma and the full assembly qualification // return size of representation -int MyICJI::appendClassName( - __deref_inout_ecount(*pnBufLen) WCHAR** ppBuf, - int* pnBufLen, - CORINFO_CLASS_HANDLE cls, - BOOL fNamespace, - BOOL fFullInst, - BOOL fAssembly - ) +int MyICJI::appendClassName(__deref_inout_ecount(*pnBufLen) WCHAR** ppBuf, + int* pnBufLen, + CORINFO_CLASS_HANDLE cls, + BOOL fNamespace, + BOOL fFullInst, + BOOL fAssembly) { jitInstance->mc->cr->AddCall("appendClassName"); const WCHAR* result = jitInstance->mc->repAppendClassName(cls, fNamespace, fFullInst, fAssembly); - int nLen = 0; + int nLen = 0; if (ppBuf != nullptr && result != nullptr) { nLen = (int)wcslen(result); if (*pnBufLen > nLen) { - wcscpy_s(*ppBuf, *pnBufLen, result ); + wcscpy_s(*ppBuf, *pnBufLen, result); (*ppBuf) += nLen; (*pnBufLen) -= nLen; } @@ -499,7 +446,8 @@ int MyICJI::appendClassName( return nLen; } -// Quick check whether the type is a value class. Returns the same value as getClassAttribs(cls) & CORINFO_FLG_VALUECLASS, except faster. +// Quick check whether the type is a value class. Returns the same value as getClassAttribs(cls) & +// CORINFO_FLG_VALUECLASS, except faster. BOOL MyICJI::isValueClass(CORINFO_CLASS_HANDLE cls) { jitInstance->mc->cr->AddCall("isValueClass"); @@ -515,9 +463,7 @@ BOOL MyICJI::canInlineTypeCheckWithObjectVTable(CORINFO_CLASS_HANDLE cls) } // return flags (defined above, CORINFO_FLG_PUBLIC ...) -DWORD MyICJI::getClassAttribs ( - CORINFO_CLASS_HANDLE cls - ) +DWORD MyICJI::getClassAttribs(CORINFO_CLASS_HANDLE cls) { jitInstance->mc->cr->AddCall("getClassAttribs"); return jitInstance->mc->repGetClassAttribs(cls); @@ -535,40 +481,34 @@ BOOL MyICJI::isStructRequiringStackAllocRetBuf(CORINFO_CLASS_HANDLE cls) return jitInstance->mc->repIsStructRequiringStackAllocRetBuf(cls); } -CORINFO_MODULE_HANDLE MyICJI::getClassModule ( - CORINFO_CLASS_HANDLE cls - ) +CORINFO_MODULE_HANDLE MyICJI::getClassModule(CORINFO_CLASS_HANDLE cls) { jitInstance->mc->cr->AddCall("getClassModule"); LogError("Hit unimplemented getClassModule"); DebugBreakorAV(28); return (CORINFO_MODULE_HANDLE)0; - //jitInstance->mc->getClassModule(cls); + // jitInstance->mc->getClassModule(cls); } // Returns the assembly that contains the module "mod". -CORINFO_ASSEMBLY_HANDLE MyICJI::getModuleAssembly ( - CORINFO_MODULE_HANDLE mod - ) +CORINFO_ASSEMBLY_HANDLE MyICJI::getModuleAssembly(CORINFO_MODULE_HANDLE mod) { jitInstance->mc->cr->AddCall("getModuleAssembly"); LogError("Hit unimplemented getModuleAssembly"); DebugBreakorAV(28); return (CORINFO_ASSEMBLY_HANDLE)0; -// return jitInstance->mc->getModuleAssembly(mod); + // return jitInstance->mc->getModuleAssembly(mod); } // Returns the name of the assembly "assem". -const char* MyICJI::getAssemblyName ( - CORINFO_ASSEMBLY_HANDLE assem - ) +const char* MyICJI::getAssemblyName(CORINFO_ASSEMBLY_HANDLE assem) { jitInstance->mc->cr->AddCall("getAssemblyName"); LogError("Hit unimplemented getAssemblyName"); DebugBreakorAV(28); return nullptr; -// return jitInstance->mc->getAssemblyName(assem); + // return jitInstance->mc->getAssemblyName(assem); } // Allocate and delete process-lifetime objects. Should only be @@ -590,29 +530,22 @@ void MyICJI::LongLifetimeFree(void* obj) DebugBreakorAV(33); } -size_t MyICJI::getClassModuleIdForStatics ( - CORINFO_CLASS_HANDLE cls, - CORINFO_MODULE_HANDLE *pModule, - void **ppIndirection - ) +size_t MyICJI::getClassModuleIdForStatics(CORINFO_CLASS_HANDLE cls, + CORINFO_MODULE_HANDLE* pModule, + void** ppIndirection) { jitInstance->mc->cr->AddCall("getClassModuleIdForStatics"); return jitInstance->mc->repGetClassModuleIdForStatics(cls, pModule, ppIndirection); } // return the number of bytes needed by an instance of the class -unsigned MyICJI::getClassSize ( - CORINFO_CLASS_HANDLE cls - ) +unsigned MyICJI::getClassSize(CORINFO_CLASS_HANDLE cls) { jitInstance->mc->cr->AddCall("getClassSize"); return jitInstance->mc->repGetClassSize(cls); } -unsigned MyICJI::getClassAlignmentRequirement ( - CORINFO_CLASS_HANDLE cls, - BOOL fDoubleAlignHint - ) +unsigned MyICJI::getClassAlignmentRequirement(CORINFO_CLASS_HANDLE cls, BOOL fDoubleAlignHint) { jitInstance->mc->cr->AddCall("getClassAlignmentRequirement"); return jitInstance->mc->repGetClassAlignmentRequirement(cls, fDoubleAlignHint); @@ -627,38 +560,29 @@ unsigned MyICJI::getClassAlignmentRequirement ( // to one of the CorInfoGCType values which is the GC type of // the i-th machine word of an object of type 'cls' // returns the number of GC pointers in the array -unsigned MyICJI::getClassGClayout ( - CORINFO_CLASS_HANDLE cls, /* IN */ - BYTE *gcPtrs /* OUT */ - ) +unsigned MyICJI::getClassGClayout(CORINFO_CLASS_HANDLE cls, /* IN */ + BYTE* gcPtrs /* OUT */ + ) { jitInstance->mc->cr->AddCall("getClassGClayout"); return jitInstance->mc->repGetClassGClayout(cls, gcPtrs); } // returns the number of instance fields in a class -unsigned MyICJI::getClassNumInstanceFields ( - CORINFO_CLASS_HANDLE cls /* IN */ - ) +unsigned MyICJI::getClassNumInstanceFields(CORINFO_CLASS_HANDLE cls /* IN */ + ) { jitInstance->mc->cr->AddCall("getClassNumInstanceFields"); return jitInstance->mc->repGetClassNumInstanceFields(cls); } -CORINFO_FIELD_HANDLE MyICJI::getFieldInClass( - CORINFO_CLASS_HANDLE clsHnd, - INT num - ) +CORINFO_FIELD_HANDLE MyICJI::getFieldInClass(CORINFO_CLASS_HANDLE clsHnd, INT num) { jitInstance->mc->cr->AddCall("getFieldInClass"); return jitInstance->mc->repGetFieldInClass(clsHnd, num); } -BOOL MyICJI::checkMethodModifier( - CORINFO_METHOD_HANDLE hMethod, - LPCSTR modifier, - BOOL fOptional - ) +BOOL MyICJI::checkMethodModifier(CORINFO_METHOD_HANDLE hMethod, LPCSTR modifier, BOOL fOptional) { jitInstance->mc->cr->AddCall("checkMethodModifier"); BOOL result = jitInstance->mc->repCheckMethodModifier(hMethod, modifier, fOptional); @@ -666,46 +590,34 @@ BOOL MyICJI::checkMethodModifier( } // returns the "NEW" helper optimized for "newCls." -CorInfoHelpFunc MyICJI::getNewHelper( - CORINFO_RESOLVED_TOKEN * pResolvedToken, - CORINFO_METHOD_HANDLE callerHandle - ) +CorInfoHelpFunc MyICJI::getNewHelper(CORINFO_RESOLVED_TOKEN* pResolvedToken, CORINFO_METHOD_HANDLE callerHandle) { jitInstance->mc->cr->AddCall("getNewHelper"); return jitInstance->mc->repGetNewHelper(pResolvedToken, callerHandle); } // returns the newArr (1-Dim array) helper optimized for "arrayCls." -CorInfoHelpFunc MyICJI::getNewArrHelper( - CORINFO_CLASS_HANDLE arrayCls - ) +CorInfoHelpFunc MyICJI::getNewArrHelper(CORINFO_CLASS_HANDLE arrayCls) { jitInstance->mc->cr->AddCall("getNewArrHelper"); return jitInstance->mc->repGetNewArrHelper(arrayCls); } // returns the optimized "IsInstanceOf" or "ChkCast" helper -CorInfoHelpFunc MyICJI::getCastingHelper( - CORINFO_RESOLVED_TOKEN * pResolvedToken, - bool fThrowing - ) +CorInfoHelpFunc MyICJI::getCastingHelper(CORINFO_RESOLVED_TOKEN* pResolvedToken, bool fThrowing) { jitInstance->mc->cr->AddCall("getCastingHelper"); return jitInstance->mc->repGetCastingHelper(pResolvedToken, fThrowing); } // returns helper to trigger static constructor -CorInfoHelpFunc MyICJI::getSharedCCtorHelper( - CORINFO_CLASS_HANDLE clsHnd - ) +CorInfoHelpFunc MyICJI::getSharedCCtorHelper(CORINFO_CLASS_HANDLE clsHnd) { jitInstance->mc->cr->AddCall("getSharedCCtorHelper"); return jitInstance->mc->repGetSharedCCtorHelper(clsHnd); } -CorInfoHelpFunc MyICJI::getSecurityPrologHelper( - CORINFO_METHOD_HANDLE ftn - ) +CorInfoHelpFunc MyICJI::getSecurityPrologHelper(CORINFO_METHOD_HANDLE ftn) { jitInstance->mc->cr->AddCall("getSecurityPrologHelper"); return jitInstance->mc->repGetSecurityPrologHelper(ftn); @@ -715,9 +627,7 @@ CorInfoHelpFunc MyICJI::getSecurityPrologHelper( // a boxed<T> not a boxed Nullable<T>. This call allows the verifier // to call back to the EE on the 'box' instruction and get the transformed // type to use for verification. -CORINFO_CLASS_HANDLE MyICJI::getTypeForBox( - CORINFO_CLASS_HANDLE cls - ) +CORINFO_CLASS_HANDLE MyICJI::getTypeForBox(CORINFO_CLASS_HANDLE cls) { jitInstance->mc->cr->AddCall("getTypeForBox"); return jitInstance->mc->repGetTypeForBox(cls); @@ -726,9 +636,7 @@ CORINFO_CLASS_HANDLE MyICJI::getTypeForBox( // returns the correct box helper for a particular class. Note // that if this returns CORINFO_HELP_BOX, the JIT can assume // 'standard' boxing (allocate object and copy), and optimize -CorInfoHelpFunc MyICJI::getBoxHelper( - CORINFO_CLASS_HANDLE cls - ) +CorInfoHelpFunc MyICJI::getBoxHelper(CORINFO_CLASS_HANDLE cls) { jitInstance->mc->cr->AddCall("getBoxHelper"); return jitInstance->mc->repGetBoxHelper(cls); @@ -746,39 +654,31 @@ CorInfoHelpFunc MyICJI::getBoxHelper( // The EE set 'helperCopies' on return to indicate what kind of // helper has been created. -CorInfoHelpFunc MyICJI::getUnBoxHelper( - CORINFO_CLASS_HANDLE cls - ) +CorInfoHelpFunc MyICJI::getUnBoxHelper(CORINFO_CLASS_HANDLE cls) { jitInstance->mc->cr->AddCall("getUnBoxHelper"); CorInfoHelpFunc result = jitInstance->mc->repGetUnBoxHelper(cls); return result; } -bool MyICJI::getReadyToRunHelper( - CORINFO_RESOLVED_TOKEN * pResolvedToken, - CORINFO_LOOKUP_KIND * pGenericLookupKind, - CorInfoHelpFunc id, - CORINFO_CONST_LOOKUP * pLookup - ) +bool MyICJI::getReadyToRunHelper(CORINFO_RESOLVED_TOKEN* pResolvedToken, + CORINFO_LOOKUP_KIND* pGenericLookupKind, + CorInfoHelpFunc id, + CORINFO_CONST_LOOKUP* pLookup) { jitInstance->mc->cr->AddCall("getReadyToRunHelper"); return jitInstance->mc->repGetReadyToRunHelper(pResolvedToken, pGenericLookupKind, id, pLookup); } -void MyICJI::getReadyToRunDelegateCtorHelper( - CORINFO_RESOLVED_TOKEN * pTargetMethod, - CORINFO_CLASS_HANDLE delegateType, - CORINFO_LOOKUP * pLookup - ) +void MyICJI::getReadyToRunDelegateCtorHelper(CORINFO_RESOLVED_TOKEN* pTargetMethod, + CORINFO_CLASS_HANDLE delegateType, + CORINFO_LOOKUP* pLookup) { jitInstance->mc->cr->AddCall("getReadyToRunDelegateCtorHelper"); jitInstance->mc->repGetReadyToRunDelegateCtorHelper(pTargetMethod, delegateType, pLookup); } -const char* MyICJI::getHelperName( - CorInfoHelpFunc funcNum - ) +const char* MyICJI::getHelperName(CorInfoHelpFunc funcNum) { jitInstance->mc->cr->AddCall("getHelperName"); return jitInstance->mc->repGetHelperName(funcNum); @@ -789,13 +689,13 @@ const char* MyICJI::getHelperName( // accessing static field or method. // // See code:ICorClassInfo#ClassConstruction. -CorInfoInitClassResult MyICJI::initClass( - CORINFO_FIELD_HANDLE field, // Non-nullptr - inquire about cctor trigger before static field access - // nullptr - inquire about cctor trigger in method prolog - CORINFO_METHOD_HANDLE method, // Method referencing the field or prolog - CORINFO_CONTEXT_HANDLE context, // Exact context of method - BOOL speculative // TRUE means don't actually run it - ) +CorInfoInitClassResult MyICJI::initClass(CORINFO_FIELD_HANDLE field, // Non-nullptr - inquire about cctor trigger before + // static field access nullptr - inquire about + // cctor trigger in method prolog + CORINFO_METHOD_HANDLE method, // Method referencing the field or prolog + CORINFO_CONTEXT_HANDLE context, // Exact context of method + BOOL speculative // TRUE means don't actually run it + ) { jitInstance->mc->cr->AddCall("initClass"); return jitInstance->mc->repInitClass(field, method, context, speculative); @@ -811,27 +711,21 @@ CorInfoInitClassResult MyICJI::initClass( // This is typically used to ensure value types are loaded before zapped // code that manipulates them is executed, so that the GC can access information // about those value types. -void MyICJI::classMustBeLoadedBeforeCodeIsRun( - CORINFO_CLASS_HANDLE cls - ) +void MyICJI::classMustBeLoadedBeforeCodeIsRun(CORINFO_CLASS_HANDLE cls) { jitInstance->mc->cr->AddCall("classMustBeLoadedBeforeCodeIsRun"); jitInstance->mc->cr->recClassMustBeLoadedBeforeCodeIsRun(cls); } // returns the class handle for the special builtin classes -CORINFO_CLASS_HANDLE MyICJI::getBuiltinClass ( - CorInfoClassId classId - ) +CORINFO_CLASS_HANDLE MyICJI::getBuiltinClass(CorInfoClassId classId) { jitInstance->mc->cr->AddCall("getBuiltinClass"); return jitInstance->mc->repGetBuiltinClass(classId); } // "System.Int32" ==> CORINFO_TYPE_INT.. -CorInfoType MyICJI::getTypeForPrimitiveValueClass( - CORINFO_CLASS_HANDLE cls - ) +CorInfoType MyICJI::getTypeForPrimitiveValueClass(CORINFO_CLASS_HANDLE cls) { jitInstance->mc->cr->AddCall("getTypeForPrimitiveValueClass"); return jitInstance->mc->repGetTypeForPrimitiveValueClass(cls); @@ -839,30 +733,23 @@ CorInfoType MyICJI::getTypeForPrimitiveValueClass( // TRUE if child is a subtype of parent // if parent is an interface, then does child implement / extend parent -BOOL MyICJI::canCast( - CORINFO_CLASS_HANDLE child, // subtype (extends parent) - CORINFO_CLASS_HANDLE parent // base type - ) +BOOL MyICJI::canCast(CORINFO_CLASS_HANDLE child, // subtype (extends parent) + CORINFO_CLASS_HANDLE parent // base type + ) { jitInstance->mc->cr->AddCall("canCast"); return jitInstance->mc->repCanCast(child, parent); } // TRUE if cls1 and cls2 are considered equivalent types. -BOOL MyICJI::areTypesEquivalent( - CORINFO_CLASS_HANDLE cls1, - CORINFO_CLASS_HANDLE cls2 - ) +BOOL MyICJI::areTypesEquivalent(CORINFO_CLASS_HANDLE cls1, CORINFO_CLASS_HANDLE cls2) { jitInstance->mc->cr->AddCall("areTypesEquivalent"); return jitInstance->mc->repAreTypesEquivalent(cls1, cls2); } // returns is the intersection of cls1 and cls2. -CORINFO_CLASS_HANDLE MyICJI::mergeClasses( - CORINFO_CLASS_HANDLE cls1, - CORINFO_CLASS_HANDLE cls2 - ) +CORINFO_CLASS_HANDLE MyICJI::mergeClasses(CORINFO_CLASS_HANDLE cls1, CORINFO_CLASS_HANDLE cls2) { jitInstance->mc->cr->AddCall("mergeClasses"); return jitInstance->mc->repMergeClasses(cls1, cls2); @@ -871,9 +758,7 @@ CORINFO_CLASS_HANDLE MyICJI::mergeClasses( // Given a class handle, returns the Parent type. // For COMObjectType, it returns Class Handle of System.Object. // Returns 0 if System.Object is passed in. -CORINFO_CLASS_HANDLE MyICJI::getParentType ( - CORINFO_CLASS_HANDLE cls - ) +CORINFO_CLASS_HANDLE MyICJI::getParentType(CORINFO_CLASS_HANDLE cls) { jitInstance->mc->cr->AddCall("getParentType"); return jitInstance->mc->repGetParentType(cls); @@ -883,59 +768,47 @@ CORINFO_CLASS_HANDLE MyICJI::getParentType ( // not a primitive type, *clsRet will be set. // Given an Array of Type Foo, returns Foo. // Given BYREF Foo, returns Foo -CorInfoType MyICJI::getChildType ( - CORINFO_CLASS_HANDLE clsHnd, - CORINFO_CLASS_HANDLE *clsRet - ) +CorInfoType MyICJI::getChildType(CORINFO_CLASS_HANDLE clsHnd, CORINFO_CLASS_HANDLE* clsRet) { jitInstance->mc->cr->AddCall("getChildType"); return jitInstance->mc->repGetChildType(clsHnd, clsRet); } // Check constraints on type arguments of this class and parent classes -BOOL MyICJI::satisfiesClassConstraints( - CORINFO_CLASS_HANDLE cls - ) +BOOL MyICJI::satisfiesClassConstraints(CORINFO_CLASS_HANDLE cls) { jitInstance->mc->cr->AddCall("satisfiesClassConstraints"); return jitInstance->mc->repSatisfiesClassConstraints(cls); } // Check if this is a single dimensional array type -BOOL MyICJI::isSDArray( - CORINFO_CLASS_HANDLE cls - ) +BOOL MyICJI::isSDArray(CORINFO_CLASS_HANDLE cls) { jitInstance->mc->cr->AddCall("isSDArray"); return jitInstance->mc->repIsSDArray(cls); } // Get the numbmer of dimensions in an array -unsigned MyICJI::getArrayRank( - CORINFO_CLASS_HANDLE cls - ) +unsigned MyICJI::getArrayRank(CORINFO_CLASS_HANDLE cls) { jitInstance->mc->cr->AddCall("getArrayRank"); return jitInstance->mc->repGetArrayRank(cls); } // Get static field data for an array -void * MyICJI::getArrayInitializationData( - CORINFO_FIELD_HANDLE field, - DWORD size - ) +void* MyICJI::getArrayInitializationData(CORINFO_FIELD_HANDLE field, DWORD size) { jitInstance->mc->cr->AddCall("getArrayInitializationData"); return jitInstance->mc->repGetArrayInitializationData(field, size); } // Check Visibility rules. -CorInfoIsAccessAllowedResult MyICJI::canAccessClass( - CORINFO_RESOLVED_TOKEN * pResolvedToken, - CORINFO_METHOD_HANDLE callerHandle, - CORINFO_HELPER_DESC *pAccessHelper /* If canAccessMethod returns something other - than ALLOWED, then this is filled in. */ - ) +CorInfoIsAccessAllowedResult MyICJI::canAccessClass(CORINFO_RESOLVED_TOKEN* pResolvedToken, + CORINFO_METHOD_HANDLE callerHandle, + CORINFO_HELPER_DESC* pAccessHelper /* If canAccessMethod returns + something other than ALLOWED, + then this is filled in. */ + ) { jitInstance->mc->cr->AddCall("canAccessClass"); return jitInstance->mc->repCanAccessClass(pResolvedToken, callerHandle, pAccessHelper); @@ -950,19 +823,16 @@ CorInfoIsAccessAllowedResult MyICJI::canAccessClass( // this function is for debugging only. It returns the field name // and if 'moduleName' is non-null, it sets it to something that will // says which method (a class name, or a module name) -const char* MyICJI::getFieldName ( - CORINFO_FIELD_HANDLE ftn, /* IN */ - const char **moduleName /* OUT */ - ) +const char* MyICJI::getFieldName(CORINFO_FIELD_HANDLE ftn, /* IN */ + const char** moduleName /* OUT */ + ) { jitInstance->mc->cr->AddCall("getFieldName"); return jitInstance->mc->repGetFieldName(ftn, moduleName); } // return class it belongs to -CORINFO_CLASS_HANDLE MyICJI::getFieldClass ( - CORINFO_FIELD_HANDLE field - ) +CORINFO_CLASS_HANDLE MyICJI::getFieldClass(CORINFO_FIELD_HANDLE field) { jitInstance->mc->cr->AddCall("getFieldClass"); return jitInstance->mc->repGetFieldClass(field); @@ -974,20 +844,17 @@ CORINFO_CLASS_HANDLE MyICJI::getFieldClass ( // // 'memberParent' is typically only set when verifying. It should be the // result of calling getMemberParent. -CorInfoType MyICJI::getFieldType( - CORINFO_FIELD_HANDLE field, - CORINFO_CLASS_HANDLE *structType, - CORINFO_CLASS_HANDLE memberParent/* IN */ - ) +CorInfoType MyICJI::getFieldType(CORINFO_FIELD_HANDLE field, + CORINFO_CLASS_HANDLE* structType, + CORINFO_CLASS_HANDLE memberParent /* IN */ + ) { jitInstance->mc->cr->AddCall("getFieldType"); - return jitInstance->mc->repGetFieldType(field, structType, memberParent); + return jitInstance->mc->repGetFieldType(field, structType, memberParent); } // return the data member's instance offset -unsigned MyICJI::getFieldOffset( - CORINFO_FIELD_HANDLE field - ) +unsigned MyICJI::getFieldOffset(CORINFO_FIELD_HANDLE field) { jitInstance->mc->cr->AddCall("getFieldOffset"); return jitInstance->mc->repGetFieldOffset(field); @@ -996,19 +863,17 @@ unsigned MyICJI::getFieldOffset( // TODO: jit64 should be switched to the same plan as the i386 jits - use // getClassGClayout to figure out the need for writebarrier helper, and inline the copying. // The interpretted value class copy is slow. Once this happens, USE_WRITE_BARRIER_HELPERS -bool MyICJI::isWriteBarrierHelperRequired( - CORINFO_FIELD_HANDLE field) +bool MyICJI::isWriteBarrierHelperRequired(CORINFO_FIELD_HANDLE field) { jitInstance->mc->cr->AddCall("isWriteBarrierHelperRequired"); bool result = jitInstance->mc->repIsWriteBarrierHelperRequired(field); return result; } -void MyICJI::getFieldInfo (CORINFO_RESOLVED_TOKEN * pResolvedToken, - CORINFO_METHOD_HANDLE callerHandle, - CORINFO_ACCESS_FLAGS flags, - CORINFO_FIELD_INFO *pResult - ) +void MyICJI::getFieldInfo(CORINFO_RESOLVED_TOKEN* pResolvedToken, + CORINFO_METHOD_HANDLE callerHandle, + CORINFO_ACCESS_FLAGS flags, + CORINFO_FIELD_INFO* pResult) { jitInstance->mc->cr->AddCall("getFieldInfo"); jitInstance->mc->repGetFieldInfo(pResolvedToken, callerHandle, flags, pResult); @@ -1034,22 +899,22 @@ bool MyICJI::isFieldStatic(CORINFO_FIELD_HANDLE fldHnd) // Note that unless CORJIT_FLAG_DEBUG_CODE is specified, this function will // be used only as a hint and the native compiler should not change its // code generation. -void MyICJI::getBoundaries( - CORINFO_METHOD_HANDLE ftn, // [IN] method of interest - unsigned int *cILOffsets, // [OUT] size of pILOffsets - DWORD **pILOffsets, // [OUT] IL offsets of interest - // jit MUST free with freeArray! - ICorDebugInfo::BoundaryTypes *implictBoundaries // [OUT] tell jit, all boundries of this type - ) +void MyICJI::getBoundaries(CORINFO_METHOD_HANDLE ftn, // [IN] method of interest + unsigned int* cILOffsets, // [OUT] size of pILOffsets + DWORD** pILOffsets, // [OUT] IL offsets of interest + // jit MUST free with freeArray! + ICorDebugInfo::BoundaryTypes* implictBoundaries // [OUT] tell jit, all boundries of this type + ) { jitInstance->mc->cr->AddCall("getBoundaries"); jitInstance->mc->repGetBoundaries(ftn, cILOffsets, pILOffsets, implictBoundaries); - //The JIT will want to call freearray on the array we pass back, so move the data into a form that complies with this - if(*cILOffsets > 0) + // The JIT will want to call freearray on the array we pass back, so move the data into a form that complies with + // this + if (*cILOffsets > 0) { - DWORD *realOffsets = (DWORD*)allocateArray(*cILOffsets*sizeof(ICorDebugInfo::BoundaryTypes)); - memcpy(realOffsets, *pILOffsets, *cILOffsets*sizeof(ICorDebugInfo::BoundaryTypes)); + DWORD* realOffsets = (DWORD*)allocateArray(*cILOffsets * sizeof(ICorDebugInfo::BoundaryTypes)); + memcpy(realOffsets, *pILOffsets, *cILOffsets * sizeof(ICorDebugInfo::BoundaryTypes)); *pILOffsets = realOffsets; } else @@ -1063,17 +928,16 @@ void MyICJI::getBoundaries( // Note that debugger (and profiler) is assuming that all of the // offsets form a contiguous block of memory, and that the // OffsetMapping is sorted in order of increasing native offset. -void MyICJI::setBoundaries( - CORINFO_METHOD_HANDLE ftn, // [IN] method of interest - ULONG32 cMap, // [IN] size of pMap - ICorDebugInfo::OffsetMapping *pMap // [IN] map including all points of interest. - // jit allocated with allocateArray, EE frees - ) +void MyICJI::setBoundaries(CORINFO_METHOD_HANDLE ftn, // [IN] method of interest + ULONG32 cMap, // [IN] size of pMap + ICorDebugInfo::OffsetMapping* pMap // [IN] map including all points of interest. + // jit allocated with allocateArray, EE frees + ) { jitInstance->mc->cr->AddCall("setBoundaries"); jitInstance->mc->cr->recSetBoundaries(ftn, cMap, pMap); - freeArray(pMap);//see note in recSetBoundaries... we own this array and own destroying it. + freeArray(pMap); // see note in recSetBoundaries... we own this array and own destroying it. } // Query the EE to find out the scope of local varables. @@ -1084,23 +948,24 @@ void MyICJI::setBoundaries( // Note that unless CORJIT_FLAG_DEBUG_CODE is specified, this function will // be used only as a hint and the native compiler should not change its // code generation. -void MyICJI::getVars( - CORINFO_METHOD_HANDLE ftn, // [IN] method of interest - ULONG32 *cVars, // [OUT] size of 'vars' - ICorDebugInfo::ILVarInfo **vars, // [OUT] scopes of variables of interest - // jit MUST free with freeArray! - bool *extendOthers // [OUT] it TRUE, then assume the scope - // of unmentioned vars is entire method - ) +void MyICJI::getVars(CORINFO_METHOD_HANDLE ftn, // [IN] method of interest + ULONG32* cVars, // [OUT] size of 'vars' + ICorDebugInfo::ILVarInfo** vars, // [OUT] scopes of variables of interest + // jit MUST free with freeArray! + bool* extendOthers // [OUT] it TRUE, then assume the scope + // of unmentioned vars is entire method + ) { jitInstance->mc->cr->AddCall("getVars"); jitInstance->mc->repGetVars(ftn, cVars, vars, extendOthers); - //The JIT will want to call freearray on the array we pass back, so move the data into a form that complies with this - if(*cVars > 0) + // The JIT will want to call freearray on the array we pass back, so move the data into a form that complies with + // this + if (*cVars > 0) { - ICorDebugInfo::ILVarInfo *realOffsets = (ICorDebugInfo::ILVarInfo*)allocateArray(*cVars*sizeof(ICorDebugInfo::ILVarInfo)); - memcpy(realOffsets, *vars, *cVars*sizeof(ICorDebugInfo::ILVarInfo)); + ICorDebugInfo::ILVarInfo* realOffsets = + (ICorDebugInfo::ILVarInfo*)allocateArray(*cVars * sizeof(ICorDebugInfo::ILVarInfo)); + memcpy(realOffsets, *vars, *cVars * sizeof(ICorDebugInfo::ILVarInfo)); *vars = realOffsets; } else @@ -1111,16 +976,15 @@ void MyICJI::getVars( // note that the JIT might split lifetimes into different // locations etc. -void MyICJI::setVars( - CORINFO_METHOD_HANDLE ftn, // [IN] method of interest - ULONG32 cVars, // [IN] size of 'vars' - ICorDebugInfo::NativeVarInfo *vars // [IN] map telling where local vars are stored at what points +void MyICJI::setVars(CORINFO_METHOD_HANDLE ftn, // [IN] method of interest + ULONG32 cVars, // [IN] size of 'vars' + ICorDebugInfo::NativeVarInfo* vars // [IN] map telling where local vars are stored at what points // jit allocated with allocateArray, EE frees - ) + ) { jitInstance->mc->cr->AddCall("setVars"); jitInstance->mc->cr->recSetVars(ftn, cVars, vars); - freeArray(vars);//See note in recSetVars... we own destroying this array + freeArray(vars); // See note in recSetVars... we own destroying this array } /*-------------------------- Misc ---------------------------------------*/ @@ -1128,9 +992,7 @@ void MyICJI::setVars( // Used to allocate memory that needs to handed to the EE. // For eg, use this to allocated memory for reporting debug info, // which will be handed to the EE by setVars() and setBoundaries() -void * MyICJI::allocateArray( - ULONG cBytes - ) +void* MyICJI::allocateArray(ULONG cBytes) { return jitInstance->allocateArray(cBytes); } @@ -1139,9 +1001,7 @@ void * MyICJI::allocateArray( // For eg, The EE returns memory in getVars() and getBoundaries() // to the JitCompiler, which the JitCompiler should release using // freeArray() -void MyICJI::freeArray( - void *array - ) +void MyICJI::freeArray(void* array) { jitInstance->freeArray(array); } @@ -1154,9 +1014,8 @@ void MyICJI::freeArray( // advance the pointer to the argument list. // a ptr of 0, is special and always means the first argument -CORINFO_ARG_LIST_HANDLE MyICJI::getArgNext ( - CORINFO_ARG_LIST_HANDLE args /* IN */ - ) +CORINFO_ARG_LIST_HANDLE MyICJI::getArgNext(CORINFO_ARG_LIST_HANDLE args /* IN */ + ) { jitInstance->mc->cr->AddCall("getArgNext"); return jitInstance->mc->repGetArgNext(args); @@ -1171,38 +1030,34 @@ CORINFO_ARG_LIST_HANDLE MyICJI::getArgNext ( // The return value is the type that is used for calling convention purposes // (Thus if the EE wants a value class to be passed like an int, then it will // return CORINFO_TYPE_INT -CorInfoTypeWithMod MyICJI::getArgType ( - CORINFO_SIG_INFO* sig, /* IN */ - CORINFO_ARG_LIST_HANDLE args, /* IN */ - CORINFO_CLASS_HANDLE *vcTypeRet /* OUT */ - ) +CorInfoTypeWithMod MyICJI::getArgType(CORINFO_SIG_INFO* sig, /* IN */ + CORINFO_ARG_LIST_HANDLE args, /* IN */ + CORINFO_CLASS_HANDLE* vcTypeRet /* OUT */ + ) { DWORD exceptionCode = 0; jitInstance->mc->cr->AddCall("getArgType"); CorInfoTypeWithMod value = jitInstance->mc->repGetArgType(sig, args, vcTypeRet, &exceptionCode); - if(exceptionCode != 0) + if (exceptionCode != 0) ThrowException(exceptionCode); return value; } // If the Arg is a CORINFO_TYPE_CLASS fetch the class handle associated with it -CORINFO_CLASS_HANDLE MyICJI::getArgClass ( - CORINFO_SIG_INFO* sig, /* IN */ - CORINFO_ARG_LIST_HANDLE args /* IN */ - ) +CORINFO_CLASS_HANDLE MyICJI::getArgClass(CORINFO_SIG_INFO* sig, /* IN */ + CORINFO_ARG_LIST_HANDLE args /* IN */ + ) { DWORD exceptionCode = 0; jitInstance->mc->cr->AddCall("getArgClass"); CORINFO_CLASS_HANDLE value = jitInstance->mc->repGetArgClass(sig, args, &exceptionCode); - if(exceptionCode != 0) + if (exceptionCode != 0) ThrowException(exceptionCode); return value; } // Returns type of HFA for valuetype -CorInfoType MyICJI::getHFAType ( - CORINFO_CLASS_HANDLE hClass - ) +CorInfoType MyICJI::getHFAType(CORINFO_CLASS_HANDLE hClass) { jitInstance->mc->cr->AddCall("getHFAType"); CorInfoType value = jitInstance->mc->repGetHFAType(hClass); @@ -1216,9 +1071,7 @@ CorInfoType MyICJI::getHFAType ( *****************************************************************************/ // Returns the HRESULT of the current exception -HRESULT MyICJI::GetErrorHRESULT( - struct _EXCEPTION_POINTERS *pExceptionPointers - ) +HRESULT MyICJI::GetErrorHRESULT(struct _EXCEPTION_POINTERS* pExceptionPointers) { jitInstance->mc->cr->AddCall("GetErrorHRESULT"); LogError("Hit unimplemented GetErrorHRESULT"); @@ -1229,10 +1082,7 @@ HRESULT MyICJI::GetErrorHRESULT( // Fetches the message of the current exception // Returns the size of the message (including terminating null). This can be // greater than bufferLength if the buffer is insufficient. -ULONG MyICJI::GetErrorMessage( - __inout_ecount(bufferLength) LPWSTR buffer, - ULONG bufferLength - ) +ULONG MyICJI::GetErrorMessage(__inout_ecount(bufferLength) LPWSTR buffer, ULONG bufferLength) { jitInstance->mc->cr->AddCall("GetErrorMessage"); LogError("Hit unimplemented GetErrorMessage"); @@ -1246,9 +1096,7 @@ ULONG MyICJI::GetErrorMessage( // things like ThreadStoppedException ... // returns EXCEPTION_CONTINUE_EXECUTION if exception is fixed up by the EE -int MyICJI::FilterException( - struct _EXCEPTION_POINTERS *pExceptionPointers - ) +int MyICJI::FilterException(struct _EXCEPTION_POINTERS* pExceptionPointers) { jitInstance->mc->cr->AddCall("FilterException"); int result = jitInstance->mc->repFilterException(pExceptionPointers); @@ -1256,24 +1104,20 @@ int MyICJI::FilterException( } // Cleans up internal EE tracking when an exception is caught. -void MyICJI::HandleException( - struct _EXCEPTION_POINTERS *pExceptionPointers - ) +void MyICJI::HandleException(struct _EXCEPTION_POINTERS* pExceptionPointers) { jitInstance->mc->cr->AddCall("HandleException"); } -void MyICJI::ThrowExceptionForJitResult( - HRESULT result) +void MyICJI::ThrowExceptionForJitResult(HRESULT result) { jitInstance->mc->cr->AddCall("ThrowExceptionForJitResult"); LogError("Hit unimplemented ThrowExceptionForJitResult"); DebugBreakorAV(80); } -//Throws an exception defined by the given throw helper. -void MyICJI::ThrowExceptionForHelper( - const CORINFO_HELPER_DESC * throwHelper) +// Throws an exception defined by the given throw helper. +void MyICJI::ThrowExceptionForHelper(const CORINFO_HELPER_DESC* throwHelper) { jitInstance->mc->cr->AddCall("ThrowExceptionForHelper"); LogError("Hit unimplemented ThrowExceptionForHelper"); @@ -1288,9 +1132,7 @@ void MyICJI::ThrowExceptionForHelper( *****************************************************************************/ // Return details about EE internal data structures -void MyICJI::getEEInfo( - CORINFO_EE_INFO *pEEInfoOut - ) +void MyICJI::getEEInfo(CORINFO_EE_INFO* pEEInfoOut) { jitInstance->mc->cr->AddCall("getEEInfo"); jitInstance->mc->repGetEEInfo(pEEInfoOut); @@ -1300,8 +1142,8 @@ void MyICJI::getEEInfo( LPCWSTR MyICJI::getJitTimeLogFilename() { jitInstance->mc->cr->AddCall("getJitTimeLogFilename"); - //we have the ability to replay this, but we treat it in this case as EE context -// return jitInstance->eec->jitTimeLogFilename; + // we have the ability to replay this, but we treat it in this case as EE context + // return jitInstance->eec->jitTimeLogFilename; // We want to be able to set COMPLUS_JitTimeLogFile when replaying, to collect JIT // statistics. So, just do a getenv() call. This isn't quite as thorough as @@ -1312,17 +1154,15 @@ LPCWSTR MyICJI::getJitTimeLogFilename() return GetEnvironmentVariableWithDefaultW(W("COMPlus_JitTimeLogFile")); } - /*********************************************************************************/ - // - // Diagnostic methods - // - /*********************************************************************************/ +/*********************************************************************************/ +// +// Diagnostic methods +// +/*********************************************************************************/ // this function is for debugging only. Returns method token. // Returns mdMethodDefNil for dynamic methods. -mdMethodDef MyICJI::getMethodDefFromMethod( - CORINFO_METHOD_HANDLE hMethod - ) +mdMethodDef MyICJI::getMethodDefFromMethod(CORINFO_METHOD_HANDLE hMethod) { jitInstance->mc->cr->AddCall("getMethodDefFromMethod"); mdMethodDef result = jitInstance->mc->repGetMethodDefFromMethod(hMethod); @@ -1332,10 +1172,9 @@ mdMethodDef MyICJI::getMethodDefFromMethod( // this function is for debugging only. It returns the method name // and if 'moduleName' is non-null, it sets it to something that will // says which method (a class name, or a module name) -const char* MyICJI::getMethodName ( - CORINFO_METHOD_HANDLE ftn, /* IN */ - const char **moduleName /* OUT */ - ) +const char* MyICJI::getMethodName(CORINFO_METHOD_HANDLE ftn, /* IN */ + const char** moduleName /* OUT */ + ) { jitInstance->mc->cr->AddCall("getMethodName"); return jitInstance->mc->repGetMethodName(ftn, moduleName); @@ -1344,61 +1183,52 @@ const char* MyICJI::getMethodName ( // this function is for debugging only. It returns a value that // is will always be the same for a given method. It is used // to implement the 'jitRange' functionality -unsigned MyICJI::getMethodHash ( - CORINFO_METHOD_HANDLE ftn /* IN */ - ) +unsigned MyICJI::getMethodHash(CORINFO_METHOD_HANDLE ftn /* IN */ + ) { jitInstance->mc->cr->AddCall("getMethodHash"); return jitInstance->mc->repGetMethodHash(ftn); } // this function is for debugging only. -size_t MyICJI::findNameOfToken ( - CORINFO_MODULE_HANDLE module, /* IN */ - mdToken metaTOK, /* IN */ - __out_ecount (FQNameCapacity) char * szFQName, /* OUT */ - size_t FQNameCapacity /* IN */ - ) +size_t MyICJI::findNameOfToken(CORINFO_MODULE_HANDLE module, /* IN */ + mdToken metaTOK, /* IN */ + __out_ecount(FQNameCapacity) char* szFQName, /* OUT */ + size_t FQNameCapacity /* IN */ + ) { jitInstance->mc->cr->AddCall("findNameOfToken"); return jitInstance->mc->repFindNameOfToken(module, metaTOK, szFQName, FQNameCapacity); } bool MyICJI::getSystemVAmd64PassStructInRegisterDescriptor( - /* IN */ CORINFO_CLASS_HANDLE structHnd, - /* OUT */ SYSTEMV_AMD64_CORINFO_STRUCT_REG_PASSING_DESCRIPTOR* structPassInRegDescPtr - ) + /* IN */ CORINFO_CLASS_HANDLE structHnd, + /* OUT */ SYSTEMV_AMD64_CORINFO_STRUCT_REG_PASSING_DESCRIPTOR* structPassInRegDescPtr) { jitInstance->mc->cr->AddCall("getSystemVAmd64PassStructInRegisterDescriptor"); return jitInstance->mc->repGetSystemVAmd64PassStructInRegisterDescriptor(structHnd, structPassInRegDescPtr); } -//Stuff on ICorDynamicInfo -DWORD MyICJI::getThreadTLSIndex( - void **ppIndirection - ) +// Stuff on ICorDynamicInfo +DWORD MyICJI::getThreadTLSIndex(void** ppIndirection) { jitInstance->mc->cr->AddCall("getThreadTLSIndex"); - return jitInstance->mc->repGetThreadTLSIndex(ppIndirection); + return jitInstance->mc->repGetThreadTLSIndex(ppIndirection); } -const void * MyICJI::getInlinedCallFrameVptr( - void **ppIndirection - ) +const void* MyICJI::getInlinedCallFrameVptr(void** ppIndirection) { jitInstance->mc->cr->AddCall("getInlinedCallFrameVptr"); return jitInstance->mc->repGetInlinedCallFrameVptr(ppIndirection); } -LONG * MyICJI::getAddrOfCaptureThreadGlobal( - void **ppIndirection - ) +LONG* MyICJI::getAddrOfCaptureThreadGlobal(void** ppIndirection) { jitInstance->mc->cr->AddCall("getAddrOfCaptureThreadGlobal"); return jitInstance->mc->repGetAddrOfCaptureThreadGlobal(ppIndirection); } -SIZE_T* MyICJI::getAddrModuleDomainID(CORINFO_MODULE_HANDLE module) +SIZE_T* MyICJI::getAddrModuleDomainID(CORINFO_MODULE_HANDLE module) { jitInstance->mc->cr->AddCall("getAddrModuleDomainID"); LogError("Hit unimplemented getAddrModuleDomainID"); @@ -1407,10 +1237,7 @@ SIZE_T* MyICJI::getAddrModuleDomainID(CORINFO_MODULE_HANDLE module) } // return the native entry point to an EE helper (see CorInfoHelpFunc) -void* MyICJI::getHelperFtn ( - CorInfoHelpFunc ftnNum, - void **ppIndirection - ) +void* MyICJI::getHelperFtn(CorInfoHelpFunc ftnNum, void** ppIndirection) { jitInstance->mc->cr->AddCall("getHelperFtn"); return jitInstance->mc->repGetHelperFtn(ftnNum, ppIndirection); @@ -1419,10 +1246,9 @@ void* MyICJI::getHelperFtn ( // return a callable address of the function (native code). This function // may return a different value (depending on whether the method has // been JITed or not. -void MyICJI::getFunctionEntryPoint( - CORINFO_METHOD_HANDLE ftn, /* IN */ - CORINFO_CONST_LOOKUP * pResult, /* OUT */ - CORINFO_ACCESS_FLAGS accessFlags) +void MyICJI::getFunctionEntryPoint(CORINFO_METHOD_HANDLE ftn, /* IN */ + CORINFO_CONST_LOOKUP* pResult, /* OUT */ + CORINFO_ACCESS_FLAGS accessFlags) { jitInstance->mc->cr->AddCall("getFunctionEntryPoint"); jitInstance->mc->repGetFunctionEntryPoint(ftn, pResult, accessFlags); @@ -1431,19 +1257,14 @@ void MyICJI::getFunctionEntryPoint( // return a directly callable address. This can be used similarly to the // value returned by getFunctionEntryPoint() except that it is // guaranteed to be multi callable entrypoint. -void MyICJI::getFunctionFixedEntryPoint( - CORINFO_METHOD_HANDLE ftn, - CORINFO_CONST_LOOKUP * pResult) +void MyICJI::getFunctionFixedEntryPoint(CORINFO_METHOD_HANDLE ftn, CORINFO_CONST_LOOKUP* pResult) { jitInstance->mc->cr->AddCall("getFunctionFixedEntryPoint"); jitInstance->mc->repGetFunctionFixedEntryPoint(ftn, pResult); } // get the synchronization handle that is passed to monXstatic function -void* MyICJI::getMethodSync( - CORINFO_METHOD_HANDLE ftn, - void **ppIndirection - ) +void* MyICJI::getMethodSync(CORINFO_METHOD_HANDLE ftn, void** ppIndirection) { jitInstance->mc->cr->AddCall("getMethodSync"); return jitInstance->mc->repGetMethodSync(ftn, ppIndirection); @@ -1455,46 +1276,31 @@ void* MyICJI::getMethodSync( // get slow lazy string literal helper to use (CORINFO_HELP_STRCNS*). // Returns CORINFO_HELP_UNDEF if lazy string literal helper cannot be used. -CorInfoHelpFunc MyICJI::getLazyStringLiteralHelper( - CORINFO_MODULE_HANDLE handle - ) +CorInfoHelpFunc MyICJI::getLazyStringLiteralHelper(CORINFO_MODULE_HANDLE handle) { jitInstance->mc->cr->AddCall("getLazyStringLiteralHelper"); return jitInstance->mc->repGetLazyStringLiteralHelper(handle); } - -CORINFO_MODULE_HANDLE MyICJI::embedModuleHandle( - CORINFO_MODULE_HANDLE handle, - void **ppIndirection - ) +CORINFO_MODULE_HANDLE MyICJI::embedModuleHandle(CORINFO_MODULE_HANDLE handle, void** ppIndirection) { jitInstance->mc->cr->AddCall("embedModuleHandle"); return jitInstance->mc->repEmbedModuleHandle(handle, ppIndirection); } -CORINFO_CLASS_HANDLE MyICJI::embedClassHandle( - CORINFO_CLASS_HANDLE handle, - void **ppIndirection - ) +CORINFO_CLASS_HANDLE MyICJI::embedClassHandle(CORINFO_CLASS_HANDLE handle, void** ppIndirection) { jitInstance->mc->cr->AddCall("embedClassHandle"); return jitInstance->mc->repEmbedClassHandle(handle, ppIndirection); } -CORINFO_METHOD_HANDLE MyICJI::embedMethodHandle( - CORINFO_METHOD_HANDLE handle, - void **ppIndirection - ) +CORINFO_METHOD_HANDLE MyICJI::embedMethodHandle(CORINFO_METHOD_HANDLE handle, void** ppIndirection) { jitInstance->mc->cr->AddCall("embedMethodHandle"); return jitInstance->mc->repEmbedMethodHandle(handle, ppIndirection); } -CORINFO_FIELD_HANDLE MyICJI::embedFieldHandle( - CORINFO_FIELD_HANDLE handle, - void **ppIndirection - ) +CORINFO_FIELD_HANDLE MyICJI::embedFieldHandle(CORINFO_FIELD_HANDLE handle, void** ppIndirection) { jitInstance->mc->cr->AddCall("embedFieldHandle"); return jitInstance->mc->repEmbedFieldHandle(handle, ppIndirection); @@ -1507,10 +1313,9 @@ CORINFO_FIELD_HANDLE MyICJI::embedFieldHandle( // code is shared and the token contains generic parameters) // then indicate how the handle should be looked up at run-time. // -void MyICJI::embedGenericHandle( - CORINFO_RESOLVED_TOKEN * pResolvedToken, - BOOL fEmbedParent, // TRUE - embeds parent type handle of the field/method handle - CORINFO_GENERICHANDLE_RESULT * pResult) +void MyICJI::embedGenericHandle(CORINFO_RESOLVED_TOKEN* pResolvedToken, + BOOL fEmbedParent, // TRUE - embeds parent type handle of the field/method handle + CORINFO_GENERICHANDLE_RESULT* pResult) { jitInstance->mc->cr->AddCall("embedGenericHandle"); jitInstance->mc->repEmbedGenericHandle(pResolvedToken, fEmbedParent, pResult); @@ -1523,40 +1328,29 @@ void MyICJI::embedGenericHandle( // CORINFO_LOOKUP_THISOBJ use vtable pointer of 'this' param // CORINFO_LOOKUP_CLASSPARAM use vtable hidden param // CORINFO_LOOKUP_METHODPARAM use enclosing type of method-desc hidden param -CORINFO_LOOKUP_KIND MyICJI::getLocationOfThisType( - CORINFO_METHOD_HANDLE context - ) +CORINFO_LOOKUP_KIND MyICJI::getLocationOfThisType(CORINFO_METHOD_HANDLE context) { jitInstance->mc->cr->AddCall("getLocationOfThisType"); return jitInstance->mc->repGetLocationOfThisType(context); } // return the unmanaged target *if method has already been prelinked.* -void* MyICJI::getPInvokeUnmanagedTarget( - CORINFO_METHOD_HANDLE method, - void **ppIndirection - ) +void* MyICJI::getPInvokeUnmanagedTarget(CORINFO_METHOD_HANDLE method, void** ppIndirection) { jitInstance->mc->cr->AddCall("getPInvokeUnmanagedTarget"); - void *result = jitInstance->mc->repGetPInvokeUnmanagedTarget(method, ppIndirection); + void* result = jitInstance->mc->repGetPInvokeUnmanagedTarget(method, ppIndirection); return result; } // return address of fixup area for late-bound PInvoke calls. -void* MyICJI::getAddressOfPInvokeFixup( - CORINFO_METHOD_HANDLE method, - void **ppIndirection - ) +void* MyICJI::getAddressOfPInvokeFixup(CORINFO_METHOD_HANDLE method, void** ppIndirection) { jitInstance->mc->cr->AddCall("getAddressOfPInvokeFixup"); return jitInstance->mc->repGetAddressOfPInvokeFixup(method, ppIndirection); } // return address of fixup area for late-bound PInvoke calls. -void MyICJI::getAddressOfPInvokeTarget( - CORINFO_METHOD_HANDLE method, - CORINFO_CONST_LOOKUP *pLookup - ) +void MyICJI::getAddressOfPInvokeTarget(CORINFO_METHOD_HANDLE method, CORINFO_CONST_LOOKUP* pLookup) { jitInstance->mc->cr->AddCall("getAddressOfPInvokeTarget"); jitInstance->mc->repGetAddressOfPInvokeTarget(method, pLookup); @@ -1564,10 +1358,7 @@ void MyICJI::getAddressOfPInvokeTarget( // Generate a cookie based on the signature that would needs to be passed // to CORINFO_HELP_PINVOKE_CALLI -LPVOID MyICJI::GetCookieForPInvokeCalliSig( - CORINFO_SIG_INFO* szMetaSig, - void ** ppIndirection - ) +LPVOID MyICJI::GetCookieForPInvokeCalliSig(CORINFO_SIG_INFO* szMetaSig, void** ppIndirection) { jitInstance->mc->cr->AddCall("GetCookieForPInvokeCalliSig"); return jitInstance->mc->repGetCookieForPInvokeCalliSig(szMetaSig, ppIndirection); @@ -1575,9 +1366,7 @@ LPVOID MyICJI::GetCookieForPInvokeCalliSig( // returns true if a VM cookie can be generated for it (might be false due to cross-module // inlining, in which case the inlining should be aborted) -bool MyICJI::canGetCookieForPInvokeCalliSig( - CORINFO_SIG_INFO* szMetaSig - ) +bool MyICJI::canGetCookieForPInvokeCalliSig(CORINFO_SIG_INFO* szMetaSig) { jitInstance->mc->cr->AddCall("canGetCookieForPInvokeCalliSig"); return jitInstance->mc->repCanGetCookieForPInvokeCalliSig(szMetaSig); @@ -1585,23 +1374,17 @@ bool MyICJI::canGetCookieForPInvokeCalliSig( // Gets a handle that is checked to see if the current method is // included in "JustMyCode" -CORINFO_JUST_MY_CODE_HANDLE MyICJI::getJustMyCodeHandle( - CORINFO_METHOD_HANDLE method, - CORINFO_JUST_MY_CODE_HANDLE**ppIndirection - ) +CORINFO_JUST_MY_CODE_HANDLE MyICJI::getJustMyCodeHandle(CORINFO_METHOD_HANDLE method, + CORINFO_JUST_MY_CODE_HANDLE** ppIndirection) { jitInstance->mc->cr->AddCall("getJustMyCodeHandle"); - return jitInstance->mc->repGetJustMyCodeHandle(method, ppIndirection); + return jitInstance->mc->repGetJustMyCodeHandle(method, ppIndirection); } // Gets a method handle that can be used to correlate profiling data. // This is the IP of a native method, or the address of the descriptor struct // for IL. Always guaranteed to be unique per process, and not to move. */ -void MyICJI::GetProfilingHandle( - BOOL *pbHookFunction, - void **pProfilerHandle, - BOOL *pbIndirectedHandles - ) +void MyICJI::GetProfilingHandle(BOOL* pbHookFunction, void** pProfilerHandle, BOOL* pbIndirectedHandles) { jitInstance->mc->cr->AddCall("GetProfilingHandle"); jitInstance->mc->repGetProfilingHandle(pbHookFunction, pProfilerHandle, pbIndirectedHandles); @@ -1609,31 +1392,30 @@ void MyICJI::GetProfilingHandle( // Returns instructions on how to make the call. See code:CORINFO_CALL_INFO for possible return values. void MyICJI::getCallInfo( - // Token info - CORINFO_RESOLVED_TOKEN * pResolvedToken, + // Token info + CORINFO_RESOLVED_TOKEN* pResolvedToken, - //Generics info - CORINFO_RESOLVED_TOKEN * pConstrainedResolvedToken, + // Generics info + CORINFO_RESOLVED_TOKEN* pConstrainedResolvedToken, - //Security info - CORINFO_METHOD_HANDLE callerHandle, + // Security info + CORINFO_METHOD_HANDLE callerHandle, - //Jit info - CORINFO_CALLINFO_FLAGS flags, + // Jit info + CORINFO_CALLINFO_FLAGS flags, - //out params - CORINFO_CALL_INFO *pResult - ) + // out params + CORINFO_CALL_INFO* pResult) { jitInstance->mc->cr->AddCall("getCallInfo"); DWORD exceptionCode = 0; - jitInstance->mc->repGetCallInfo(pResolvedToken, pConstrainedResolvedToken, callerHandle, flags, pResult, &exceptionCode); - if(exceptionCode != 0) + jitInstance->mc->repGetCallInfo(pResolvedToken, pConstrainedResolvedToken, callerHandle, flags, pResult, + &exceptionCode); + if (exceptionCode != 0) ThrowException(exceptionCode); } -BOOL MyICJI::canAccessFamily(CORINFO_METHOD_HANDLE hCaller, - CORINFO_CLASS_HANDLE hInstanceType) +BOOL MyICJI::canAccessFamily(CORINFO_METHOD_HANDLE hCaller, CORINFO_CLASS_HANDLE hInstanceType) { jitInstance->mc->cr->AddCall("canAccessFamily"); @@ -1650,31 +1432,21 @@ BOOL MyICJI::isRIDClassDomainID(CORINFO_CLASS_HANDLE cls) } // returns the class's domain ID for accessing shared statics -unsigned MyICJI::getClassDomainID ( - CORINFO_CLASS_HANDLE cls, - void **ppIndirection - ) +unsigned MyICJI::getClassDomainID(CORINFO_CLASS_HANDLE cls, void** ppIndirection) { jitInstance->mc->cr->AddCall("getClassDomainID"); return jitInstance->mc->repGetClassDomainID(cls, ppIndirection); } - // return the data's address (for static fields only) -void* MyICJI::getFieldAddress( - CORINFO_FIELD_HANDLE field, - void **ppIndirection - ) +void* MyICJI::getFieldAddress(CORINFO_FIELD_HANDLE field, void** ppIndirection) { jitInstance->mc->cr->AddCall("getFieldAddress"); return jitInstance->mc->repGetFieldAddress(field, ppIndirection); } // registers a vararg sig & returns a VM cookie for it (which can contain other stuff) -CORINFO_VARARGS_HANDLE MyICJI::getVarArgsHandle( - CORINFO_SIG_INFO *pSig, - void **ppIndirection - ) +CORINFO_VARARGS_HANDLE MyICJI::getVarArgsHandle(CORINFO_SIG_INFO* pSig, void** ppIndirection) { jitInstance->mc->cr->AddCall("getVarArgsHandle"); return jitInstance->mc->repGetVarArgsHandle(pSig, ppIndirection); @@ -1682,50 +1454,36 @@ CORINFO_VARARGS_HANDLE MyICJI::getVarArgsHandle( // returns true if a VM cookie can be generated for it (might be false due to cross-module // inlining, in which case the inlining should be aborted) -bool MyICJI::canGetVarArgsHandle( - CORINFO_SIG_INFO *pSig - ) +bool MyICJI::canGetVarArgsHandle(CORINFO_SIG_INFO* pSig) { jitInstance->mc->cr->AddCall("canGetVarArgsHandle"); return jitInstance->mc->repCanGetVarArgsHandle(pSig); } // Allocate a string literal on the heap and return a handle to it -InfoAccessType MyICJI::constructStringLiteral( - CORINFO_MODULE_HANDLE module, - mdToken metaTok, - void **ppValue - ) +InfoAccessType MyICJI::constructStringLiteral(CORINFO_MODULE_HANDLE module, mdToken metaTok, void** ppValue) { jitInstance->mc->cr->AddCall("constructStringLiteral"); return jitInstance->mc->repConstructStringLiteral(module, metaTok, ppValue); } -InfoAccessType MyICJI::emptyStringLiteral( - void **ppValue - ) +InfoAccessType MyICJI::emptyStringLiteral(void** ppValue) { jitInstance->mc->cr->AddCall("emptyStringLiteral"); - return jitInstance->mc->repEmptyStringLiteral(ppValue); + return jitInstance->mc->repEmptyStringLiteral(ppValue); } // (static fields only) given that 'field' refers to thread local store, // return the ID (TLS index), which is used to find the begining of the // TLS data area for the particular DLL 'field' is associated with. -DWORD MyICJI::getFieldThreadLocalStoreID ( - CORINFO_FIELD_HANDLE field, - void **ppIndirection - ) +DWORD MyICJI::getFieldThreadLocalStoreID(CORINFO_FIELD_HANDLE field, void** ppIndirection) { jitInstance->mc->cr->AddCall("getFieldThreadLocalStoreID"); return jitInstance->mc->repGetFieldThreadLocalStoreID(field, ppIndirection); } // Sets another object to intercept calls to "self" and current method being compiled -void MyICJI::setOverride( - ICorDynamicInfo *pOverride, - CORINFO_METHOD_HANDLE currentMethod - ) +void MyICJI::setOverride(ICorDynamicInfo* pOverride, CORINFO_METHOD_HANDLE currentMethod) { jitInstance->mc->cr->AddCall("setOverride"); LogError("Hit unimplemented setOverride"); @@ -1734,30 +1492,23 @@ void MyICJI::setOverride( // Adds an active dependency from the context method's module to the given module // This is internal callback for the EE. JIT should not call it directly. -void MyICJI::addActiveDependency( - CORINFO_MODULE_HANDLE moduleFrom, - CORINFO_MODULE_HANDLE moduleTo - ) +void MyICJI::addActiveDependency(CORINFO_MODULE_HANDLE moduleFrom, CORINFO_MODULE_HANDLE moduleTo) { jitInstance->mc->cr->AddCall("addActiveDependency"); LogError("Hit unimplemented addActiveDependency"); DebugBreakorAV(116); } -CORINFO_METHOD_HANDLE MyICJI::GetDelegateCtor( - CORINFO_METHOD_HANDLE methHnd, - CORINFO_CLASS_HANDLE clsHnd, - CORINFO_METHOD_HANDLE targetMethodHnd, - DelegateCtorArgs * pCtorData - ) +CORINFO_METHOD_HANDLE MyICJI::GetDelegateCtor(CORINFO_METHOD_HANDLE methHnd, + CORINFO_CLASS_HANDLE clsHnd, + CORINFO_METHOD_HANDLE targetMethodHnd, + DelegateCtorArgs* pCtorData) { jitInstance->mc->cr->AddCall("GetDelegateCtor"); - return jitInstance->mc->repGetDelegateCtor(methHnd, clsHnd, targetMethodHnd, pCtorData); + return jitInstance->mc->repGetDelegateCtor(methHnd, clsHnd, targetMethodHnd, pCtorData); } -void MyICJI::MethodCompileComplete( - CORINFO_METHOD_HANDLE methHnd - ) +void MyICJI::MethodCompileComplete(CORINFO_METHOD_HANDLE methHnd) { jitInstance->mc->cr->AddCall("MethodCompileComplete"); LogError("Hit unimplemented MethodCompileComplete"); @@ -1765,19 +1516,16 @@ void MyICJI::MethodCompileComplete( } // return a thunk that will copy the arguments for the given signature. -void* MyICJI::getTailCallCopyArgsThunk ( - CORINFO_SIG_INFO *pSig, - CorInfoHelperTailCallSpecialHandling flags - ) +void* MyICJI::getTailCallCopyArgsThunk(CORINFO_SIG_INFO* pSig, CorInfoHelperTailCallSpecialHandling flags) { jitInstance->mc->cr->AddCall("getTailCallCopyArgsThunk"); return jitInstance->mc->repGetTailCallCopyArgsThunk(pSig, flags); } -//Stuff directly on ICorJitInfo +// Stuff directly on ICorJitInfo // Returns extended flags for a particular compilation instance. -DWORD MyICJI::getJitFlags(CORJIT_FLAGS *jitFlags, DWORD sizeInBytes) +DWORD MyICJI::getJitFlags(CORJIT_FLAGS* jitFlags, DWORD sizeInBytes) { jitInstance->mc->cr->AddCall("getJitFlags"); return jitInstance->mc->repGetJitFlags(jitFlags, sizeInBytes); @@ -1786,7 +1534,7 @@ DWORD MyICJI::getJitFlags(CORJIT_FLAGS *jitFlags, DWORD sizeInBytes) // Runs the given function with the given parameter under an error trap // and returns true if the function completes successfully. We fake this // up a bit for SuperPMI and simply catch all exceptions. -bool MyICJI::runWithErrorTrap(void (*function)(void*), void *param) +bool MyICJI::runWithErrorTrap(void (*function)(void*), void* param) { return RunWithErrorTrap(function, param); } @@ -1798,26 +1546,26 @@ IEEMemoryManager* MyICJI::getMemoryManager() } // get a block of memory for the code, readonly data, and read-write data -void MyICJI::allocMem ( - ULONG hotCodeSize, /* IN */ - ULONG coldCodeSize, /* IN */ - ULONG roDataSize, /* IN */ - ULONG xcptnsCount, /* IN */ - CorJitAllocMemFlag flag, /* IN */ - void ** hotCodeBlock, /* OUT */ - void ** coldCodeBlock, /* OUT */ - void ** roDataBlock /* OUT */ - ) +void MyICJI::allocMem(ULONG hotCodeSize, /* IN */ + ULONG coldCodeSize, /* IN */ + ULONG roDataSize, /* IN */ + ULONG xcptnsCount, /* IN */ + CorJitAllocMemFlag flag, /* IN */ + void** hotCodeBlock, /* OUT */ + void** coldCodeBlock, /* OUT */ + void** roDataBlock /* OUT */ + ) { jitInstance->mc->cr->AddCall("allocMem"); - //TODO-Cleanup: investigate if we need to check roDataBlock as well. Could hot block size be ever 0? - *hotCodeBlock = HeapAlloc(jitInstance->mc->cr->getCodeHeap(),0,hotCodeSize); - if (coldCodeSize>0) - *coldCodeBlock = HeapAlloc(jitInstance->mc->cr->getCodeHeap(),0,coldCodeSize); + // TODO-Cleanup: investigate if we need to check roDataBlock as well. Could hot block size be ever 0? + *hotCodeBlock = HeapAlloc(jitInstance->mc->cr->getCodeHeap(), 0, hotCodeSize); + if (coldCodeSize > 0) + *coldCodeBlock = HeapAlloc(jitInstance->mc->cr->getCodeHeap(), 0, coldCodeSize); else *coldCodeBlock = nullptr; - *roDataBlock = HeapAlloc(jitInstance->mc->cr->getCodeHeap(),0,roDataSize); - jitInstance->mc->cr->recAllocMem(hotCodeSize, coldCodeSize, roDataSize, xcptnsCount, flag, hotCodeBlock, coldCodeBlock, roDataBlock); + *roDataBlock = HeapAlloc(jitInstance->mc->cr->getCodeHeap(), 0, roDataSize); + jitInstance->mc->cr->recAllocMem(hotCodeSize, coldCodeSize, roDataSize, xcptnsCount, flag, hotCodeBlock, + coldCodeBlock, roDataBlock); } // Reserve memory for the method/funclet's unwind information. @@ -1831,11 +1579,10 @@ void MyICJI::allocMem ( // For prejitted code we split up the unwinding information into // separate sections .rdata and .pdata. // -void MyICJI::reserveUnwindInfo ( - BOOL isFunclet, /* IN */ - BOOL isColdCode, /* IN */ - ULONG unwindSize /* IN */ - ) +void MyICJI::reserveUnwindInfo(BOOL isFunclet, /* IN */ + BOOL isColdCode, /* IN */ + ULONG unwindSize /* IN */ + ) { jitInstance->mc->cr->AddCall("reserveUnwindInfo"); jitInstance->mc->cr->recReserveUnwindInfo(isFunclet, isColdCode, unwindSize); @@ -1858,30 +1605,29 @@ void MyICJI::reserveUnwindInfo ( // pUnwindBlock pointer to unwind info // funcKind type of funclet (main method code, handler, filter) // -void MyICJI::allocUnwindInfo ( - BYTE * pHotCode, /* IN */ - BYTE * pColdCode, /* IN */ - ULONG startOffset, /* IN */ - ULONG endOffset, /* IN */ - ULONG unwindSize, /* IN */ - BYTE * pUnwindBlock, /* IN */ - CorJitFuncKind funcKind /* IN */ - ) +void MyICJI::allocUnwindInfo(BYTE* pHotCode, /* IN */ + BYTE* pColdCode, /* IN */ + ULONG startOffset, /* IN */ + ULONG endOffset, /* IN */ + ULONG unwindSize, /* IN */ + BYTE* pUnwindBlock, /* IN */ + CorJitFuncKind funcKind /* IN */ + ) { jitInstance->mc->cr->AddCall("allocUnwindInfo"); - jitInstance->mc->cr->recAllocUnwindInfo(pHotCode, pColdCode, startOffset, endOffset, unwindSize, pUnwindBlock, funcKind); + jitInstance->mc->cr->recAllocUnwindInfo(pHotCode, pColdCode, startOffset, endOffset, unwindSize, pUnwindBlock, + funcKind); } // Get a block of memory needed for the code manager information, // (the info for enumerating the GC pointers while crawling the // stack frame). // Note that allocMem must be called first -void * MyICJI::allocGCInfo ( - size_t size /* IN */ - ) +void* MyICJI::allocGCInfo(size_t size /* IN */ + ) { jitInstance->mc->cr->AddCall("allocGCInfo"); - void *temp = (unsigned char*)HeapAlloc(jitInstance->mc->cr->getCodeHeap(),0,size); + void* temp = (unsigned char*)HeapAlloc(jitInstance->mc->cr->getCodeHeap(), 0, size); jitInstance->mc->cr->recAllocGCInfo(size, temp); return temp; @@ -1896,9 +1642,8 @@ void MyICJI::yieldExecution() // Indicate how many exception handler blocks are to be returned. // This is guaranteed to be called before any 'setEHinfo' call. // Note that allocMem must be called before this method can be called. -void MyICJI::setEHcount ( - unsigned cEH /* IN */ - ) +void MyICJI::setEHcount(unsigned cEH /* IN */ + ) { jitInstance->mc->cr->AddCall("setEHcount"); jitInstance->mc->cr->recSetEHcount(cEH); @@ -1909,10 +1654,9 @@ void MyICJI::setEHcount ( // Handler regions should be lexically contiguous. // This is because FinallyIsUnwinding() uses lexicality to // determine if a "finally" clause is executing. -void MyICJI::setEHinfo ( - unsigned EHnumber, /* IN */ - const CORINFO_EH_CLAUSE *clause /* IN */ - ) +void MyICJI::setEHinfo(unsigned EHnumber, /* IN */ + const CORINFO_EH_CLAUSE* clause /* IN */ + ) { jitInstance->mc->cr->AddCall("setEHinfo"); jitInstance->mc->cr->recSetEHinfo(EHnumber, clause); @@ -1925,10 +1669,10 @@ BOOL MyICJI::logMsg(unsigned level, const char* fmt, va_list args) { jitInstance->mc->cr->AddCall("logMsg"); -// if(level<=2) -// { - //jitInstance->mc->cr->recMessageLog(fmt, args); - //DebugBreakorAV(0x99); + // if(level<=2) + // { + //jitInstance->mc->cr->recMessageLog(fmt, args); + //DebugBreakorAV(0x99); //} jitInstance->mc->cr->recMessageLog(fmt, args); return 0; @@ -1965,10 +1709,8 @@ void MyICJI::reportFatalError(CorJitResult result) // allocate a basic block profile buffer where execution counts will be stored // for jitted basic blocks. -HRESULT MyICJI::allocBBProfileBuffer ( - ULONG count, // The number of basic blocks that we have - ProfileBuffer ** profileBuffer - ) +HRESULT MyICJI::allocBBProfileBuffer(ULONG count, // The number of basic blocks that we have + ProfileBuffer** profileBuffer) { jitInstance->mc->cr->AddCall("allocBBProfileBuffer"); return jitInstance->mc->cr->repAllocBBProfileBuffer(count, profileBuffer); @@ -1976,12 +1718,10 @@ HRESULT MyICJI::allocBBProfileBuffer ( // get profile information to be used for optimizing the current method. The format // of the buffer is the same as the format the JIT passes to allocBBProfileBuffer. -HRESULT MyICJI::getBBProfileData( - CORINFO_METHOD_HANDLE ftnHnd, - ULONG * count, // The number of basic blocks that we have - ProfileBuffer ** profileBuffer, - ULONG * numRuns - ) +HRESULT MyICJI::getBBProfileData(CORINFO_METHOD_HANDLE ftnHnd, + ULONG* count, // The number of basic blocks that we have + ProfileBuffer** profileBuffer, + ULONG* numRuns) { jitInstance->mc->cr->AddCall("getBBProfileData"); return jitInstance->mc->repGetBBProfileData(ftnHnd, count, profileBuffer, numRuns); @@ -1991,11 +1731,10 @@ HRESULT MyICJI::getBBProfileData( // the signature information and method handle the JIT used to lay out the call site. If // the call site has no signature information (e.g. a helper call) or has no method handle // (e.g. a CALLI P/Invoke), then null should be passed instead. -void MyICJI::recordCallSite( - ULONG instrOffset, /* IN */ - CORINFO_SIG_INFO * callSig, /* IN */ - CORINFO_METHOD_HANDLE methodHandle /* IN */ - ) +void MyICJI::recordCallSite(ULONG instrOffset, /* IN */ + CORINFO_SIG_INFO* callSig, /* IN */ + CORINFO_METHOD_HANDLE methodHandle /* IN */ + ) { jitInstance->mc->cr->AddCall("recordCallSite"); jitInstance->mc->cr->repRecordCallSite(instrOffset, callSig, methodHandle); @@ -2003,19 +1742,18 @@ void MyICJI::recordCallSite( // A relocation is recorded if we are pre-jitting. // A jump thunk may be inserted if we are jitting -void MyICJI::recordRelocation( - void * location, /* IN */ - void * target, /* IN */ - WORD fRelocType, /* IN */ - WORD slotNum, /* IN */ - INT32 addlDelta /* IN */ - ) +void MyICJI::recordRelocation(void* location, /* IN */ + void* target, /* IN */ + WORD fRelocType, /* IN */ + WORD slotNum, /* IN */ + INT32 addlDelta /* IN */ + ) { jitInstance->mc->cr->AddCall("recordRelocation"); jitInstance->mc->cr->repRecordRelocation(location, target, fRelocType, slotNum, addlDelta); } -WORD MyICJI::getRelocTypeHint(void * target) +WORD MyICJI::getRelocTypeHint(void* target) { jitInstance->mc->cr->AddCall("getRelocTypeHint"); WORD result = jitInstance->mc->repGetRelocTypeHint(target); @@ -2025,10 +1763,9 @@ WORD MyICJI::getRelocTypeHint(void * target) // A callback to identify the range of address known to point to // compiler-generated native entry points that call back into // MSIL. -void MyICJI::getModuleNativeEntryPointRange( - void ** pStart, /* OUT */ - void ** pEnd /* OUT */ - ) +void MyICJI::getModuleNativeEntryPointRange(void** pStart, /* OUT */ + void** pEnd /* OUT */ + ) { jitInstance->mc->cr->AddCall("getModuleNativeEntryPointRange"); LogError("Hit unimplemented getModuleNativeEntryPointRange"); diff --git a/src/ToolBox/superpmi/superpmi/icorjitinfo.h b/src/ToolBox/superpmi/superpmi/icorjitinfo.h index 2182db3be6..333d69dbbe 100644 --- a/src/ToolBox/superpmi/superpmi/icorjitinfo.h +++ b/src/ToolBox/superpmi/superpmi/icorjitinfo.h @@ -9,7 +9,7 @@ #include "runtimedetails.h" #include "ieememorymanager.h" -extern ICorJitInfo *pICJI; +extern ICorJitInfo* pICJI; class MyICJI : public ICorJitInfo { @@ -17,10 +17,9 @@ class MyICJI : public ICorJitInfo #include "icorjitinfoimpl.h" public: - - //Added extras... todo add padding to detect corruption? - JitInstance *jitInstance; + // Added extras... todo add padding to detect corruption? + JitInstance* jitInstance; }; -ICorJitInfo* InitICorJitInfo(JitInstance *jitInstance); +ICorJitInfo* InitICorJitInfo(JitInstance* jitInstance); #endif diff --git a/src/ToolBox/superpmi/superpmi/ieememorymanager.cpp b/src/ToolBox/superpmi/superpmi/ieememorymanager.cpp index 8bb95b1f4d..b8d5f152af 100644 --- a/src/ToolBox/superpmi/superpmi/ieememorymanager.cpp +++ b/src/ToolBox/superpmi/superpmi/ieememorymanager.cpp @@ -7,14 +7,14 @@ #include "spmiutil.h" #include "ieememorymanager.h" -IEEMemoryManager *pIEEMM = nullptr; -HANDLE processHeap = INVALID_HANDLE_VALUE; +IEEMemoryManager* pIEEMM = nullptr; +HANDLE processHeap = INVALID_HANDLE_VALUE; //*************************************************************************** // IUnknown methods //*************************************************************************** -HRESULT STDMETHODCALLTYPE MyIEEMM::QueryInterface(REFIID id, void **pInterface) +HRESULT STDMETHODCALLTYPE MyIEEMM::QueryInterface(REFIID id, void** pInterface) { DebugBreakorAV(133); return 0; @@ -35,11 +35,14 @@ HANDLE virtHeap = INVALID_HANDLE_VALUE; //*************************************************************************** // IEEMemoryManager methods for locking //*************************************************************************** -LPVOID STDMETHODCALLTYPE MyIEEMM::ClrVirtualAlloc(LPVOID lpAddress, SIZE_T dwSize, DWORD flAllocationType, DWORD flProtect) +LPVOID STDMETHODCALLTYPE MyIEEMM::ClrVirtualAlloc(LPVOID lpAddress, + SIZE_T dwSize, + DWORD flAllocationType, + DWORD flProtect) { - if(virtHeap == INVALID_HANDLE_VALUE) + if (virtHeap == INVALID_HANDLE_VALUE) virtHeap = HeapCreate(0, 0xFFFF, 0); - if(virtHeap != INVALID_HANDLE_VALUE) + if (virtHeap != INVALID_HANDLE_VALUE) return HeapAlloc(virtHeap, HEAP_ZERO_MEMORY, dwSize); return nullptr; } @@ -47,12 +50,17 @@ BOOL STDMETHODCALLTYPE MyIEEMM::ClrVirtualFree(LPVOID lpAddress, SIZE_T dwSize, { return HeapFree(virtHeap, 0, lpAddress); } -SIZE_T STDMETHODCALLTYPE MyIEEMM::ClrVirtualQuery(LPCVOID lpAddress, PMEMORY_BASIC_INFORMATION lpBuffer, SIZE_T dwLength) +SIZE_T STDMETHODCALLTYPE MyIEEMM::ClrVirtualQuery(LPCVOID lpAddress, + PMEMORY_BASIC_INFORMATION lpBuffer, + SIZE_T dwLength) { DebugBreakorAV(136); return 0; } -BOOL STDMETHODCALLTYPE MyIEEMM::ClrVirtualProtect(LPVOID lpAddress, SIZE_T dwSize, DWORD flNewProtect, PDWORD lpflOldProtect) +BOOL STDMETHODCALLTYPE MyIEEMM::ClrVirtualProtect(LPVOID lpAddress, + SIZE_T dwSize, + DWORD flNewProtect, + PDWORD lpflOldProtect) { DebugBreakorAV(137); return 0; @@ -74,7 +82,7 @@ BOOL STDMETHODCALLTYPE MyIEEMM::ClrHeapDestroy(HANDLE hHeap) } LPVOID STDMETHODCALLTYPE MyIEEMM::ClrHeapAlloc(HANDLE hHeap, DWORD dwFlags, SIZE_T dwBytes) { - return HeapAlloc(hHeap,dwFlags,dwBytes); + return HeapAlloc(hHeap, dwFlags, dwBytes); } BOOL STDMETHODCALLTYPE MyIEEMM::ClrHeapFree(HANDLE hHeap, DWORD dwFlags, LPVOID lpMem) { @@ -98,13 +106,13 @@ HANDLE STDMETHODCALLTYPE MyIEEMM::ClrGetProcessExecutableHeap() return processHeap; } -IEEMemoryManager *InitIEEMemoryManager(JitInstance *jitInstance) +IEEMemoryManager* InitIEEMemoryManager(JitInstance* jitInstance) { - if(pIEEMM==nullptr) + if (pIEEMM == nullptr) { - MyIEEMM *ieemm = new MyIEEMM(); - ieemm->jitInstance = jitInstance; - pIEEMM = ieemm; + MyIEEMM* ieemm = new MyIEEMM(); + ieemm->jitInstance = jitInstance; + pIEEMM = ieemm; } return pIEEMM; } diff --git a/src/ToolBox/superpmi/superpmi/ieememorymanager.h b/src/ToolBox/superpmi/superpmi/ieememorymanager.h index 90763bc233..5793f2b90a 100644 --- a/src/ToolBox/superpmi/superpmi/ieememorymanager.h +++ b/src/ToolBox/superpmi/superpmi/ieememorymanager.h @@ -73,18 +73,17 @@ interface IEEMemoryManager : IUnknown }; // interface IEEMemoryManager */ -extern HANDLE virtHeap; -extern IEEMemoryManager *pIEEMM; -extern HANDLE processHeap; +extern HANDLE virtHeap; +extern IEEMemoryManager* pIEEMM; +extern HANDLE processHeap; class MyIEEMM : public IEEMemoryManager { private: - //*************************************************************************** // IUnknown methods //*************************************************************************** - HRESULT STDMETHODCALLTYPE QueryInterface(REFIID id, void **pInterface); + HRESULT STDMETHODCALLTYPE QueryInterface(REFIID id, void** pInterface); ULONG STDMETHODCALLTYPE AddRef(); ULONG STDMETHODCALLTYPE Release(); @@ -94,7 +93,10 @@ private: LPVOID STDMETHODCALLTYPE ClrVirtualAlloc(LPVOID lpAddress, SIZE_T dwSize, DWORD flAllocationType, DWORD flProtect); BOOL STDMETHODCALLTYPE ClrVirtualFree(LPVOID lpAddress, SIZE_T dwSize, DWORD dwFreeType); SIZE_T STDMETHODCALLTYPE ClrVirtualQuery(LPCVOID lpAddress, PMEMORY_BASIC_INFORMATION lpBuffer, SIZE_T dwLength); - BOOL STDMETHODCALLTYPE ClrVirtualProtect(LPVOID lpAddress, SIZE_T dwSize, DWORD flNewProtect, PDWORD lpflOldProtect); + BOOL STDMETHODCALLTYPE ClrVirtualProtect(LPVOID lpAddress, + SIZE_T dwSize, + DWORD flNewProtect, + PDWORD lpflOldProtect); HANDLE STDMETHODCALLTYPE ClrGetProcessHeap(); HANDLE STDMETHODCALLTYPE ClrHeapCreate(DWORD flOptions, SIZE_T dwInitialSize, SIZE_T dwMaximumSize); BOOL STDMETHODCALLTYPE ClrHeapDestroy(HANDLE hHeap); @@ -104,10 +106,10 @@ private: HANDLE STDMETHODCALLTYPE ClrGetProcessExecutableHeap(); public: - //Added extras... todo add padding to detect corruption? - JitInstance *jitInstance; + // Added extras... todo add padding to detect corruption? + JitInstance* jitInstance; }; -IEEMemoryManager *InitIEEMemoryManager(JitInstance *jitInstance); +IEEMemoryManager* InitIEEMemoryManager(JitInstance* jitInstance); #endif diff --git a/src/ToolBox/superpmi/superpmi/iexecutionengine.cpp b/src/ToolBox/superpmi/superpmi/iexecutionengine.cpp index db9e121d8e..7a39734500 100644 --- a/src/ToolBox/superpmi/superpmi/iexecutionengine.cpp +++ b/src/ToolBox/superpmi/superpmi/iexecutionengine.cpp @@ -9,15 +9,15 @@ LPVOID TLS_Slots[MAX_PREDEFINED_TLS_SLOT]; class MyIEE; -IExecutionEngine *pIEE = nullptr; +IExecutionEngine* pIEE = nullptr; //*************************************************************************** // IUnknown methods //*************************************************************************** -HRESULT STDMETHODCALLTYPE MyIEE::QueryInterface(REFIID id, void **pInterface) +HRESULT STDMETHODCALLTYPE MyIEE::QueryInterface(REFIID id, void** pInterface) { - //TODO-Cleanup: check the rid + // TODO-Cleanup: check the rid *pInterface = InitIEEMemoryManager(nullptr); return 0; } @@ -39,18 +39,18 @@ ULONG STDMETHODCALLTYPE MyIEE::Release() DWORD TlsIndex = 42; // Associate a callback for cleanup with a TLS slot -VOID STDMETHODCALLTYPE MyIEE::TLS_AssociateCallback(DWORD slot, PTLS_CALLBACK_FUNCTION callback) +VOID STDMETHODCALLTYPE MyIEE::TLS_AssociateCallback(DWORD slot, PTLS_CALLBACK_FUNCTION callback) { - //TODO-Cleanup: figure an appropriate realish value for this + // TODO-Cleanup: figure an appropriate realish value for this } // Get the TLS block for fast Get/Set operations LPVOID* STDMETHODCALLTYPE MyIEE::TLS_GetDataBlock() { - //We were previously allocating a TlsIndex with - //the master slot index set to a nullptr - //so in the new version we just return nullptr - //and it seems to be working for now + // We were previously allocating a TlsIndex with + //the master slot index set to a nullptr + //so in the new version we just return nullptr + //and it seems to be working for now return nullptr; } @@ -69,10 +69,10 @@ LPVOID STDMETHODCALLTYPE MyIEE::TLS_GetValue(DWORD slot) } // Get the value at a slot, return FALSE if TLS info block doesn't exist -BOOL STDMETHODCALLTYPE MyIEE::TLS_CheckValue(DWORD slot, LPVOID * pValue) +BOOL STDMETHODCALLTYPE MyIEE::TLS_CheckValue(DWORD slot, LPVOID* pValue) { DebugBreakorAV(144); - //TODO-Cleanup: does anything beyond contracts care? This seems like a pretty thin mock. + // TODO-Cleanup: does anything beyond contracts care? This seems like a pretty thin mock. return true; } // Set the value at a slot @@ -83,9 +83,9 @@ VOID STDMETHODCALLTYPE MyIEE::TLS_SetValue(DWORD slot, LPVOID pData) DebugBreakorAV(143); return; } - void *thing = TlsGetValue(TlsIndex);//TODO-Cleanup: this seems odd.. explain? + void* thing = TlsGetValue(TlsIndex); // TODO-Cleanup: this seems odd.. explain? - //TODO-Cleanup: does anything beyond contracts care? This seems like a pretty thin mock. + // TODO-Cleanup: does anything beyond contracts care? This seems like a pretty thin mock. TLS_Slots[slot] = pData; } // Free TLS memory block and make callback @@ -161,14 +161,14 @@ DWORD STDMETHODCALLTYPE MyIEE::ClrWaitForSemaphore(SEMAPHORE_COOKIE semaphore, D DebugBreakorAV(156); return 0; } -BOOL STDMETHODCALLTYPE MyIEE::ClrReleaseSemaphore(SEMAPHORE_COOKIE semaphore, LONG lReleaseCount, LONG *lpPreviousCount) +BOOL STDMETHODCALLTYPE MyIEE::ClrReleaseSemaphore(SEMAPHORE_COOKIE semaphore, LONG lReleaseCount, LONG* lpPreviousCount) { DebugBreakorAV(157); return 0; } MUTEX_COOKIE STDMETHODCALLTYPE MyIEE::ClrCreateMutex(LPSECURITY_ATTRIBUTES lpMutexAttributes, - BOOL bInitialOwner, - LPCTSTR lpName) + BOOL bInitialOwner, + LPCTSTR lpName) { DebugBreakorAV(158); return 0; @@ -182,9 +182,7 @@ BOOL STDMETHODCALLTYPE MyIEE::ClrReleaseMutex(MUTEX_COOKIE mutex) DebugBreakorAV(160); return 0; } -DWORD STDMETHODCALLTYPE MyIEE::ClrWaitForMutex(MUTEX_COOKIE mutex, - DWORD dwMilliseconds, - BOOL bAlertable) +DWORD STDMETHODCALLTYPE MyIEE::ClrWaitForMutex(MUTEX_COOKIE mutex, DWORD dwMilliseconds, BOOL bAlertable) { DebugBreakorAV(161); return 0; @@ -200,14 +198,14 @@ BOOL STDMETHODCALLTYPE MyIEE::ClrAllocationDisallowed() DebugBreakorAV(163); return 0; } -void STDMETHODCALLTYPE MyIEE::GetLastThrownObjectExceptionFromThread(void **ppvException) +void STDMETHODCALLTYPE MyIEE::GetLastThrownObjectExceptionFromThread(void** ppvException) { DebugBreakorAV(164); } -MyIEE *InitIExecutionEngine() +MyIEE* InitIExecutionEngine() { - MyIEE *iee = new MyIEE(); - pIEE = iee; + MyIEE* iee = new MyIEE(); + pIEE = iee; return iee; } diff --git a/src/ToolBox/superpmi/superpmi/iexecutionengine.h b/src/ToolBox/superpmi/superpmi/iexecutionengine.h index f1a76b9a4f..fb3a413cb4 100644 --- a/src/ToolBox/superpmi/superpmi/iexecutionengine.h +++ b/src/ToolBox/superpmi/superpmi/iexecutionengine.h @@ -85,17 +85,16 @@ interface IExecutionEngine : IUnknown }; // interface IExecutionEngine */ -extern LPVOID TLS_Slots[MAX_PREDEFINED_TLS_SLOT]; -extern IExecutionEngine *pIEE; +extern LPVOID TLS_Slots[MAX_PREDEFINED_TLS_SLOT]; +extern IExecutionEngine* pIEE; class MyIEE : public IExecutionEngine { private: - //*************************************************************************** // IUnknown methods //*************************************************************************** - HRESULT STDMETHODCALLTYPE QueryInterface(REFIID id, void **pInterface); + HRESULT STDMETHODCALLTYPE QueryInterface(REFIID id, void** pInterface); ULONG STDMETHODCALLTYPE AddRef(); ULONG STDMETHODCALLTYPE Release(); @@ -103,14 +102,14 @@ private: // IExecutionEngine methods for TLS //*************************************************************************** // Associate a callback for cleanup with a TLS slot - VOID STDMETHODCALLTYPE TLS_AssociateCallback(DWORD slot, PTLS_CALLBACK_FUNCTION callback); + VOID STDMETHODCALLTYPE TLS_AssociateCallback(DWORD slot, PTLS_CALLBACK_FUNCTION callback); // Get the TLS block for fast Get/Set operations LPVOID* STDMETHODCALLTYPE TLS_GetDataBlock(); // Get the value at a slot LPVOID STDMETHODCALLTYPE TLS_GetValue(DWORD slot); // Get the value at a slot, return FALSE if TLS info block doesn't exist - BOOL STDMETHODCALLTYPE TLS_CheckValue(DWORD slot, LPVOID * pValue); + BOOL STDMETHODCALLTYPE TLS_CheckValue(DWORD slot, LPVOID* pValue); // Set the value at a slot VOID STDMETHODCALLTYPE TLS_SetValue(DWORD slot, LPVOID pData); // Free TLS memory block and make callback @@ -133,19 +132,17 @@ private: SEMAPHORE_COOKIE STDMETHODCALLTYPE ClrCreateSemaphore(DWORD dwInitial, DWORD dwMax); void STDMETHODCALLTYPE ClrCloseSemaphore(SEMAPHORE_COOKIE semaphore); DWORD STDMETHODCALLTYPE ClrWaitForSemaphore(SEMAPHORE_COOKIE semaphore, DWORD dwMilliseconds, BOOL bAlertable); - BOOL STDMETHODCALLTYPE ClrReleaseSemaphore(SEMAPHORE_COOKIE semaphore, LONG lReleaseCount, LONG *lpPreviousCount); + BOOL STDMETHODCALLTYPE ClrReleaseSemaphore(SEMAPHORE_COOKIE semaphore, LONG lReleaseCount, LONG* lpPreviousCount); MUTEX_COOKIE STDMETHODCALLTYPE ClrCreateMutex(LPSECURITY_ATTRIBUTES lpMutexAttributes, - BOOL bInitialOwner, - LPCTSTR lpName); + BOOL bInitialOwner, + LPCTSTR lpName); void STDMETHODCALLTYPE ClrCloseMutex(MUTEX_COOKIE mutex); BOOL STDMETHODCALLTYPE ClrReleaseMutex(MUTEX_COOKIE mutex); - DWORD STDMETHODCALLTYPE ClrWaitForMutex(MUTEX_COOKIE mutex, - DWORD dwMilliseconds, - BOOL bAlertable); + DWORD STDMETHODCALLTYPE ClrWaitForMutex(MUTEX_COOKIE mutex, DWORD dwMilliseconds, BOOL bAlertable); DWORD STDMETHODCALLTYPE ClrSleepEx(DWORD dwMilliseconds, BOOL bAlertable); BOOL STDMETHODCALLTYPE ClrAllocationDisallowed(); - void STDMETHODCALLTYPE GetLastThrownObjectExceptionFromThread(void **ppvException); + void STDMETHODCALLTYPE GetLastThrownObjectExceptionFromThread(void** ppvException); }; -MyIEE *InitIExecutionEngine(); +MyIEE* InitIExecutionEngine(); #endif
\ No newline at end of file diff --git a/src/ToolBox/superpmi/superpmi/jitdebugger.cpp b/src/ToolBox/superpmi/superpmi/jitdebugger.cpp index 867664e82f..b4b4ede20f 100644 --- a/src/ToolBox/superpmi/superpmi/jitdebugger.cpp +++ b/src/ToolBox/superpmi/superpmi/jitdebugger.cpp @@ -25,17 +25,13 @@ #ifndef FEATURE_JIT_DEBUGGING -int DbgBreakCheck( - const char* szFile, - int iLine, - const char* szExpr) +int DbgBreakCheck(const char* szFile, int iLine, const char* szExpr) { LogError("SuperPMI: Assert Failure (PID %d, Thread %d/%x)\n" "%s\n" "\n" "%s, Line: %d\n", - GetCurrentProcessId(), GetCurrentThreadId(), GetCurrentThreadId(), - szExpr, szFile, iLine); + GetCurrentProcessId(), GetCurrentThreadId(), GetCurrentThreadId(), szExpr, szFile, iLine); return 1; } @@ -90,18 +86,14 @@ BOOL RunningInWow64() // Exceptions // None //------------------------------------------------------------------------------ -BOOL GetRegistryLongValue(HKEY hKeyParent, - LPCWSTR szKey, - LPCWSTR szName, - long *pValue, - BOOL fReadNonVirtualizedKey) +BOOL GetRegistryLongValue(HKEY hKeyParent, LPCWSTR szKey, LPCWSTR szName, long* pValue, BOOL fReadNonVirtualizedKey) { - DWORD ret; // Return value from registry operation. - HKEY hkey; // Registry key. - long iValue; // The value to read. - DWORD iType; // Type of value to get. - DWORD iSize; // Size of buffer. - REGSAM samDesired = KEY_READ; // Desired access rights to the key + DWORD ret; // Return value from registry operation. + HKEY hkey; // Registry key. + long iValue; // The value to read. + DWORD iType; // Type of value to get. + DWORD iSize; // Size of buffer. + REGSAM samDesired = KEY_READ; // Desired access rights to the key if (fReadNonVirtualizedKey) { @@ -118,10 +110,10 @@ BOOL GetRegistryLongValue(HKEY hKeyParent, { iType = REG_DWORD; iSize = sizeof(long); - ret = RegQueryValueExW(hkey, szName, NULL, &iType, reinterpret_cast<BYTE*>(&iValue), &iSize); + ret = RegQueryValueExW(hkey, szName, NULL, &iType, reinterpret_cast<BYTE*>(&iValue), &iSize); if (ret == ERROR_SUCCESS && iType == REG_DWORD && iSize == sizeof(long)) - { // We successfully read a DWORD value. + { // We successfully read a DWORD value. *pValue = iValue; return TRUE; } @@ -144,7 +136,7 @@ BOOL GetRegistryLongValue(HKEY hKeyParent, // Note: // //---------------------------------------------------------------------------- -HRESULT GetCurrentModuleFileName(__out_ecount(*pcchBuffer) LPWSTR pBuffer, __inout DWORD *pcchBuffer) +HRESULT GetCurrentModuleFileName(__out_ecount(*pcchBuffer) LPWSTR pBuffer, __inout DWORD* pcchBuffer) { LIMITED_METHOD_CONTRACT; @@ -165,10 +157,10 @@ HRESULT GetCurrentModuleFileName(__out_ecount(*pcchBuffer) LPWSTR pBuffer, __ino } // Pick off the part after the path. - WCHAR* appName = wcsrchr(appPath, L'\\'); + WCHAR* appName = wcsrchr(appPath, L'\\'); // If no backslash, use the whole name; if there is a backslash, skip it. - appName = appName ? appName+1 : appPath; + appName = appName ? appName + 1 : appPath; if (*pcchBuffer < wcslen(appName)) { @@ -180,7 +172,6 @@ HRESULT GetCurrentModuleFileName(__out_ecount(*pcchBuffer) LPWSTR pBuffer, __ino return S_OK; } - //---------------------------------------------------------------------------- // // IsCurrentModuleFileNameInAutoExclusionList - decide if the current module's filename @@ -232,12 +223,10 @@ BOOL IsCurrentModuleFileNameInAutoExclusionList() return FALSE; } // IsCurrentModuleFileNameInAutoExclusionList - - //***************************************************************************** // Retrieve information regarding what registered default debugger //***************************************************************************** -void GetDebuggerSettingInfo(LPWSTR wszDebuggerString, DWORD cchDebuggerString, BOOL *pfAuto) +void GetDebuggerSettingInfo(LPWSTR wszDebuggerString, DWORD cchDebuggerString, BOOL* pfAuto) { HRESULT hr = GetDebuggerSettingInfoWorker(wszDebuggerString, &cchDebuggerString, pfAuto); @@ -265,7 +254,10 @@ void GetDebuggerSettingInfo(LPWSTR wszDebuggerString, DWORD cchDebuggerString, B // * wszDebuggerString can be NULL. When wszDebuggerString is NULL, pcchDebuggerString should // * point to a DWORD of zero. pcchDebuggerString cannot be NULL, and the DWORD pointed by // * pcchDebuggerString will store the used or required string buffer size in characters. -HRESULT GetDebuggerSettingInfoWorker(__out_ecount_part_opt(*pcchDebuggerString, *pcchDebuggerString) LPWSTR wszDebuggerString, DWORD * pcchDebuggerString, BOOL * pfAuto) +HRESULT GetDebuggerSettingInfoWorker(__out_ecount_part_opt(*pcchDebuggerString, *pcchDebuggerString) + LPWSTR wszDebuggerString, + DWORD* pcchDebuggerString, + BOOL* pfAuto) { if ((pcchDebuggerString == NULL) || ((wszDebuggerString == NULL) && (*pcchDebuggerString != 0))) { @@ -289,7 +281,7 @@ HRESULT GetDebuggerSettingInfoWorker(__out_ecount_part_opt(*pcchDebuggerString, DWORD ret = WszRegOpenKeyEx(HKEY_LOCAL_MACHINE, kUnmanagedDebuggerKey, 0, KEY_READ, &hKey); if (ret != ERROR_SUCCESS) - { // Wow, there's not even an AeDebug hive, so no native debugger, no auto. + { // Wow, there's not even an AeDebug hive, so no native debugger, no auto. return S_OK; } @@ -315,7 +307,8 @@ HRESULT GetDebuggerSettingInfoWorker(__out_ecount_part_opt(*pcchDebuggerString, return S_OK; } - ret = RegQueryValueExW(hKey, kUnmanagedDebuggerValue, NULL, NULL, reinterpret_cast< LPBYTE >(wszDebuggerString), &valueSize); + ret = RegQueryValueExW(hKey, kUnmanagedDebuggerValue, NULL, NULL, reinterpret_cast<LPBYTE>(wszDebuggerString), + &valueSize); if (ret != ERROR_SUCCESS) { *wszDebuggerString = L'\0'; @@ -330,16 +323,14 @@ HRESULT GetDebuggerSettingInfoWorker(__out_ecount_part_opt(*pcchDebuggerString, // Get the appname to look up in DebugApplications key. WCHAR wzAppName[MAX_PATH]; DWORD cchAppName = NumItems(wzAppName); - long iValue; + long iValue; // Check DebugApplications setting if ((SUCCEEDED(GetCurrentModuleFileName(wzAppName, &cchAppName))) && - ( - GetRegistryLongValue(HKEY_LOCAL_MACHINE, kDebugApplicationsPoliciesKey, wzAppName, &iValue, TRUE) || - GetRegistryLongValue(HKEY_LOCAL_MACHINE, kDebugApplicationsKey, wzAppName, &iValue, TRUE) || - GetRegistryLongValue(HKEY_CURRENT_USER, kDebugApplicationsPoliciesKey, wzAppName, &iValue, TRUE) || - GetRegistryLongValue(HKEY_CURRENT_USER, kDebugApplicationsKey, wzAppName, &iValue, TRUE) - ) && + (GetRegistryLongValue(HKEY_LOCAL_MACHINE, kDebugApplicationsPoliciesKey, wzAppName, &iValue, TRUE) || + GetRegistryLongValue(HKEY_LOCAL_MACHINE, kDebugApplicationsKey, wzAppName, &iValue, TRUE) || + GetRegistryLongValue(HKEY_CURRENT_USER, kDebugApplicationsPoliciesKey, wzAppName, &iValue, TRUE) || + GetRegistryLongValue(HKEY_CURRENT_USER, kDebugApplicationsKey, wzAppName, &iValue, TRUE)) && (iValue == 1)) { fAuto = TRUE; @@ -352,7 +343,8 @@ HRESULT GetDebuggerSettingInfoWorker(__out_ecount_part_opt(*pcchDebuggerString, { WCHAR wzAutoKey[MAX_PATH]; valueSize = NumItems(wzAutoKey) * sizeof(WCHAR); - RegQueryValueExW(hKey, kUnmanagedDebuggerAutoValue, NULL, NULL, reinterpret_cast< LPBYTE >(wzAutoKey), &valueSize); + RegQueryValueExW(hKey, kUnmanagedDebuggerAutoValue, NULL, NULL, reinterpret_cast<LPBYTE>(wzAutoKey), + &valueSize); // The OS's behavior is to consider Auto to be FALSE unless the first character is set // to 1. They don't take into consideration the following characters. Also if the value @@ -379,14 +371,15 @@ BOOL LaunchJITDebugger() GetDebuggerSettingInfo(debugger, NumItems(debugger), NULL); SECURITY_ATTRIBUTES sa; - sa.nLength = sizeof(sa); + sa.nLength = sizeof(sa); sa.lpSecurityDescriptor = NULL; - sa.bInheritHandle = TRUE; + sa.bInheritHandle = TRUE; // We can leave this event as it is since it is inherited by a child process. // We will block one scheduler, but the process is asking a user if they want to attach debugger. HANDLE eventHandle = WszCreateEvent(&sa, TRUE, FALSE, NULL); - if (eventHandle == NULL) { + if (eventHandle == NULL) + { return FALSE; } @@ -395,7 +388,7 @@ BOOL LaunchJITDebugger() STARTUPINFOW StartupInfo; memset(&StartupInfo, 0, sizeof(StartupInfo)); - StartupInfo.cb = sizeof(StartupInfo); + StartupInfo.cb = sizeof(StartupInfo); StartupInfo.lpDesktop = L"Winsta0\\Default"; PROCESS_INFORMATION ProcessInformation; @@ -410,47 +403,44 @@ BOOL LaunchJITDebugger() return fSuccess; } - // See if we should invoke the just-in-time debugger on an assert. -int DbgBreakCheck( - const char* szFile, - int iLine, - const char* szExpr) +int DbgBreakCheck(const char* szFile, int iLine, const char* szExpr) { char dialogText[1000]; char dialogTitle[1000]; - sprintf_s(dialogText, sizeof(dialogText), "%s\n\n%s, Line: %d\n\nAbort - Kill program\nRetry - Debug\nIgnore - Keep running\n", - szExpr, szFile, iLine); + sprintf_s(dialogText, sizeof(dialogText), + "%s\n\n%s, Line: %d\n\nAbort - Kill program\nRetry - Debug\nIgnore - Keep running\n", szExpr, szFile, + iLine); sprintf_s(dialogTitle, sizeof(dialogTitle), "SuperPMI: Assert Failure (PID %d, Thread %d/%x) ", - GetCurrentProcessId(), GetCurrentThreadId(), GetCurrentThreadId()); + GetCurrentProcessId(), GetCurrentThreadId(), GetCurrentThreadId()); // Tell user there was an error. int ret = MessageBoxA(NULL, dialogText, dialogTitle, MB_ABORTRETRYIGNORE | MB_ICONEXCLAMATION | MB_TOPMOST); - switch(ret) + switch (ret) { - case IDABORT: - TerminateProcess(GetCurrentProcess(), 1); - break; + case IDABORT: + TerminateProcess(GetCurrentProcess(), 1); + break; - // Tell caller to break at the correct loction. - case IDRETRY: + // Tell caller to break at the correct loction. + case IDRETRY: - if (IsDebuggerPresent()) - { - SetErrorMode(0); - } - else - { - LaunchJITDebugger(); - } + if (IsDebuggerPresent()) + { + SetErrorMode(0); + } + else + { + LaunchJITDebugger(); + } - return 1; + return 1; - case IDIGNORE: - // nothing to do - break; + case IDIGNORE: + // nothing to do + break; } return 0; diff --git a/src/ToolBox/superpmi/superpmi/jitdebugger.h b/src/ToolBox/superpmi/superpmi/jitdebugger.h index eee2318f8f..27f42121b1 100644 --- a/src/ToolBox/superpmi/superpmi/jitdebugger.h +++ b/src/ToolBox/superpmi/superpmi/jitdebugger.h @@ -6,7 +6,8 @@ #ifndef _JitDebugger #define _JitDebugger -extern bool breakOnDebugBreakorAV; // It's kind of awful that I'm making this global, but it was kind of awful that it was file-global already. +extern bool breakOnDebugBreakorAV; // It's kind of awful that I'm making this global, but it was kind of awful that it + // was file-global already. // // Functions to support just-in-time debugging. @@ -15,18 +16,21 @@ extern bool breakOnDebugBreakorAV; // It's kind of awful that I'm making this gl BOOL GetRegistryLongValue(HKEY hKeyParent, // Parent key. LPCWSTR szKey, // Key name to look at. LPCWSTR szName, // Name of value to get. - long *pValue, // Put value here, if found. + long* pValue, // Put value here, if found. BOOL fReadNonVirtualizedKey); // Whether to read 64-bit hive on WOW64 -HRESULT GetCurrentModuleFileName(__out_ecount(*pcchBuffer) LPWSTR pBuffer, __inout DWORD *pcchBuffer); +HRESULT GetCurrentModuleFileName(__out_ecount(*pcchBuffer) LPWSTR pBuffer, __inout DWORD* pcchBuffer); #ifndef _WIN64 BOOL RunningInWow64(); #endif -BOOL IsCurrentModuleFileNameInAutoExclusionList(); -HRESULT GetDebuggerSettingInfoWorker(__out_ecount_part_opt(*pcchDebuggerString, *pcchDebuggerString) LPWSTR wszDebuggerString, DWORD * pcchDebuggerString, BOOL * pfAuto); -void GetDebuggerSettingInfo(LPWSTR wszDebuggerString, DWORD cchDebuggerString, BOOL *pfAuto); +BOOL IsCurrentModuleFileNameInAutoExclusionList(); +HRESULT GetDebuggerSettingInfoWorker(__out_ecount_part_opt(*pcchDebuggerString, *pcchDebuggerString) + LPWSTR wszDebuggerString, + DWORD* pcchDebuggerString, + BOOL* pfAuto); +void GetDebuggerSettingInfo(LPWSTR wszDebuggerString, DWORD cchDebuggerString, BOOL* pfAuto); int DbgBreakCheck(const char* szFile, int iLine, const char* szExpr); diff --git a/src/ToolBox/superpmi/superpmi/jithost.cpp b/src/ToolBox/superpmi/superpmi/jithost.cpp index cb61e48de2..d14909bae1 100644 --- a/src/ToolBox/superpmi/superpmi/jithost.cpp +++ b/src/ToolBox/superpmi/superpmi/jithost.cpp @@ -14,13 +14,14 @@ // value must be freed with jitInstance.freeLongLivedArray(value). wchar_t* GetCOMPlusVariable(const wchar_t* key, JitInstance& jitInstance) { - static const wchar_t Prefix[] = W("COMPlus_"); - static const size_t PrefixLen = (sizeof(Prefix) / sizeof(Prefix[0])) - 1; + static const wchar_t Prefix[] = W("COMPlus_"); + static const size_t PrefixLen = (sizeof(Prefix) / sizeof(Prefix[0])) - 1; // Prepend "COMPlus_" to the provided key - size_t keyLen = wcslen(key); - size_t keyBufferLen = keyLen + PrefixLen + 1; - wchar_t* keyBuffer = reinterpret_cast<wchar_t*>(jitInstance.allocateArray(static_cast<ULONG>(sizeof(wchar_t) * keyBufferLen))); + size_t keyLen = wcslen(key); + size_t keyBufferLen = keyLen + PrefixLen + 1; + wchar_t* keyBuffer = + reinterpret_cast<wchar_t*>(jitInstance.allocateArray(static_cast<ULONG>(sizeof(wchar_t) * keyBufferLen))); wcscpy_s(keyBuffer, keyBufferLen, Prefix); wcscpy_s(&keyBuffer[PrefixLen], keyLen + 1, key); @@ -33,8 +34,8 @@ wchar_t* GetCOMPlusVariable(const wchar_t* key, JitInstance& jitInstance) } // Note this value must live as long as the jit instance does. - wchar_t* value = reinterpret_cast<wchar_t*>(jitInstance.allocateLongLivedArray(sizeof(wchar_t) * valueLen)); - DWORD newValueLen = GetEnvironmentVariableW(keyBuffer, value, valueLen); + wchar_t* value = reinterpret_cast<wchar_t*>(jitInstance.allocateLongLivedArray(sizeof(wchar_t) * valueLen)); + DWORD newValueLen = GetEnvironmentVariableW(keyBuffer, value, valueLen); jitInstance.freeArray(keyBuffer); if (valueLen < newValueLen) @@ -86,7 +87,7 @@ int JitHost::getIntConfigValue(const wchar_t* key, int defaultValue) // Parse the value as a hex integer. wchar_t* endPtr; - result = static_cast<int>(wcstoul(complus, &endPtr, 16)); + result = static_cast<int>(wcstoul(complus, &endPtr, 16)); bool succeeded = (errno != ERANGE) && (endPtr != complus); jitInstance.freeLongLivedArray(complus); @@ -96,13 +97,13 @@ int JitHost::getIntConfigValue(const wchar_t* key, int defaultValue) const wchar_t* JitHost::getStringConfigValue(const wchar_t* key) { jitInstance.mc->cr->AddCall("getStringConfigValue"); - const wchar_t *result = jitInstance.mc->repGetStringConfigValue(key); + const wchar_t* result = jitInstance.mc->repGetStringConfigValue(key); if (result != nullptr) { // Now we need to dup it, so you can call freeStringConfigValue() on what we return. - size_t resultLenInChars = wcslen(result) + 1; - wchar_t *dupResult = (wchar_t*)jitInstance.allocateLongLivedArray((ULONG)(sizeof(wchar_t) * resultLenInChars)); + size_t resultLenInChars = wcslen(result) + 1; + wchar_t* dupResult = (wchar_t*)jitInstance.allocateLongLivedArray((ULONG)(sizeof(wchar_t) * resultLenInChars)); wcscpy_s(dupResult, resultLenInChars, result); return dupResult; diff --git a/src/ToolBox/superpmi/superpmi/jitinstance.cpp b/src/ToolBox/superpmi/superpmi/jitinstance.cpp index 5003e91f96..e463f82139 100644 --- a/src/ToolBox/superpmi/superpmi/jitinstance.cpp +++ b/src/ToolBox/superpmi/superpmi/jitinstance.cpp @@ -12,9 +12,9 @@ #include "errorhandling.h" #include "spmiutil.h" -JitInstance *JitInstance::InitJit(char *nameOfJit, bool breakOnAssert, SimpleTimer *st1, MethodContext* firstContext) +JitInstance* JitInstance::InitJit(char* nameOfJit, bool breakOnAssert, SimpleTimer* st1, MethodContext* firstContext) { - JitInstance *jit = new JitInstance(); + JitInstance* jit = new JitInstance(); if (jit == nullptr) { LogError("Failed to allocate a JitInstance"); @@ -36,12 +36,15 @@ JitInstance *JitInstance::InitJit(char *nameOfJit, bool breakOnAssert, SimpleTim return jit; } -HRESULT JitInstance::StartUp(char * PathToJit, bool copyJit, bool parambreakOnDebugBreakorAV, MethodContext* firstContext) +HRESULT JitInstance::StartUp(char* PathToJit, + bool copyJit, + bool parambreakOnDebugBreakorAV, + MethodContext* firstContext) { - //startup jit + // startup jit DWORD dwRetVal = 0; - UINT uRetVal = 0; - BOOL bRetVal = FALSE; + UINT uRetVal = 0; + BOOL bRetVal = FALSE; breakOnDebugBreakorAV = parambreakOnDebugBreakorAV; @@ -49,16 +52,16 @@ HRESULT JitInstance::StartUp(char * PathToJit, bool copyJit, bool parambreakOnDe char lpTempPathBuffer[MAX_PATH]; char szTempFileName[MAX_PATH]; -//Get an allocator instance -//Note: we do this to keep cleanup somewhat simple... - ourHeap = ::HeapCreate(0,0,0); - if(ourHeap == nullptr) + // Get an allocator instance + //Note: we do this to keep cleanup somewhat simple... + ourHeap = ::HeapCreate(0, 0, 0); + if (ourHeap == nullptr) { LogError("Failed to get a new heap (0x%08x)", ::GetLastError()); return E_FAIL; } -//find the full jit path + // find the full jit path dwRetVal = ::GetFullPathNameA(PathToJit, MAX_PATH, pFullPathName, nullptr); if (dwRetVal == 0) { @@ -66,18 +69,18 @@ HRESULT JitInstance::StartUp(char * PathToJit, bool copyJit, bool parambreakOnDe return E_FAIL; } -//Store the full path to the jit - PathToOriginalJit = (char *)::HeapAlloc(ourHeap, 0, MAX_PATH); - if(PathToOriginalJit == nullptr) + // Store the full path to the jit + PathToOriginalJit = (char*)::HeapAlloc(ourHeap, 0, MAX_PATH); + if (PathToOriginalJit == nullptr) { LogError("1st HeapAlloc failed (0x%08x)", ::GetLastError()); return E_FAIL; } ::strcpy_s(PathToOriginalJit, MAX_PATH, pFullPathName); - if(copyJit) + if (copyJit) { - //Get a temp file location + // Get a temp file location dwRetVal = ::GetTempPathA(MAX_PATH, lpTempPathBuffer); if (dwRetVal == 0) { @@ -89,7 +92,7 @@ HRESULT JitInstance::StartUp(char * PathToJit, bool copyJit, bool parambreakOnDe LogError("GetTempPath returned a path that was larger than MAX_PATH"); return E_FAIL; } - //Get a temp filename + // Get a temp filename uRetVal = ::GetTempFileNameA(lpTempPathBuffer, "Jit", 0, szTempFileName); if (uRetVal == 0) { @@ -98,16 +101,16 @@ HRESULT JitInstance::StartUp(char * PathToJit, bool copyJit, bool parambreakOnDe } dwRetVal = (DWORD)::strlen(szTempFileName); - //Store the full path to the temp jit - PathToTempJit = (char *)::HeapAlloc(ourHeap, 0, MAX_PATH); - if(PathToTempJit == nullptr) + // Store the full path to the temp jit + PathToTempJit = (char*)::HeapAlloc(ourHeap, 0, MAX_PATH); + if (PathToTempJit == nullptr) { LogError("2nd HeapAlloc failed 0x%08x)", ::GetLastError()); return E_FAIL; } ::strcpy_s(PathToTempJit, MAX_PATH, szTempFileName); - //Copy Temp File + // Copy Temp File bRetVal = ::CopyFileA(PathToOriginalJit, PathToTempJit, FALSE); if (bRetVal == FALSE) { @@ -119,25 +122,25 @@ HRESULT JitInstance::StartUp(char * PathToJit, bool copyJit, bool parambreakOnDe PathToTempJit = PathToOriginalJit; #ifndef FEATURE_PAL // No file version APIs in the PAL - //Do a quick version check + // Do a quick version check DWORD dwHandle = 0; - DWORD fviSize = GetFileVersionInfoSizeA(PathToTempJit, &dwHandle); + DWORD fviSize = GetFileVersionInfoSizeA(PathToTempJit, &dwHandle); - if ((fviSize != 0)&&(dwHandle==0)) + if ((fviSize != 0) && (dwHandle == 0)) { - unsigned char *fviData = new unsigned char[fviSize]; + unsigned char* fviData = new unsigned char[fviSize]; if (GetFileVersionInfoA(PathToTempJit, dwHandle, fviSize, fviData)) { - UINT size = 0; - VS_FIXEDFILEINFO *verInfo = nullptr; + UINT size = 0; + VS_FIXEDFILEINFO* verInfo = nullptr; if (VerQueryValueA(fviData, "\\", (LPVOID*)&verInfo, &size)) { if (size) { if (verInfo->dwSignature == 0xfeef04bd) - LogDebug("'%s' is version %u.%u.%u.%u", PathToTempJit, - (verInfo->dwFileVersionMS)>>16, (verInfo->dwFileVersionMS)&0xFFFF, - (verInfo->dwFileVersionLS)>>16, (verInfo->dwFileVersionLS)&0xFFFF); + LogDebug("'%s' is version %u.%u.%u.%u", PathToTempJit, (verInfo->dwFileVersionMS) >> 16, + (verInfo->dwFileVersionMS) & 0xFFFF, (verInfo->dwFileVersionLS) >> 16, + (verInfo->dwFileVersionLS) & 0xFFFF); } } } @@ -145,43 +148,43 @@ HRESULT JitInstance::StartUp(char * PathToJit, bool copyJit, bool parambreakOnDe } #endif // !FEATURE_PAL -//Load Library + // Load Library hLib = ::LoadLibraryA(PathToTempJit); - if(hLib == 0) + if (hLib == 0) { LogError("LoadLibrary failed (0x%08x)", ::GetLastError()); return E_FAIL; } -//get entry points + // get entry points pngetJit = (PgetJit)::GetProcAddress(hLib, "getJit"); - if(pngetJit == 0) + if (pngetJit == 0) { LogError("GetProcAddress 'getJit' failed (0x%08x)", ::GetLastError()); return -1; } pnsxsJitStartup = (PsxsJitStartup)::GetProcAddress(hLib, "sxsJitStartup"); - if(pnsxsJitStartup == 0) + if (pnsxsJitStartup == 0) { LogError("GetProcAddress 'sxsJitStartup' failed (0x%08x)", ::GetLastError()); return -1; } pnjitStartup = (PjitStartup)::GetProcAddress(hLib, "jitStartup"); - //Setup CoreClrCallbacks and call sxsJitStartup - CoreClrCallbacks *cccallbacks = InitCoreClrCallbacks(); + // Setup CoreClrCallbacks and call sxsJitStartup + CoreClrCallbacks* cccallbacks = InitCoreClrCallbacks(); pnsxsJitStartup(*cccallbacks); // Setup ICorJitHost and call jitStartup if necessary if (pnjitStartup != nullptr) { - mc = firstContext; + mc = firstContext; jitHost = new JitHost(*this); pnjitStartup(jitHost); } pJitInstance = pngetJit(); - if(pJitInstance == nullptr) + if (pJitInstance == nullptr) { LogError("pngetJit gave us null"); return -1; @@ -202,7 +205,6 @@ HRESULT JitInstance::StartUp(char * PathToJit, bool copyJit, bool parambreakOnDe return -1; } - icji = InitICorJitInfo(this); return S_OK; @@ -212,43 +214,43 @@ bool JitInstance::reLoad(MethodContext* firstContext) { FreeLibrary(hLib); -//Load Library + // Load Library hLib = ::LoadLibraryA(PathToTempJit); - if(hLib == 0) + if (hLib == 0) { LogError("LoadLibrary failed (0x%08x)", ::GetLastError()); return false; } -//get entry points + // get entry points pngetJit = (PgetJit)::GetProcAddress(hLib, "getJit"); - if(pngetJit == 0) + if (pngetJit == 0) { LogError("GetProcAddress 'getJit' failed (0x%08x)", ::GetLastError()); return false; } pnsxsJitStartup = (PsxsJitStartup)::GetProcAddress(hLib, "sxsJitStartup"); - if(pnsxsJitStartup == 0) + if (pnsxsJitStartup == 0) { LogError("GetProcAddress 'sxsJitStartup' failed (0x%08x)", ::GetLastError()); return false; } pnjitStartup = (PjitStartup)::GetProcAddress(hLib, "jitStartup"); - //Setup CoreClrCallbacks and call sxsJitStartup - CoreClrCallbacks *cccallbacks = InitCoreClrCallbacks(); + // Setup CoreClrCallbacks and call sxsJitStartup + CoreClrCallbacks* cccallbacks = InitCoreClrCallbacks(); pnsxsJitStartup(*cccallbacks); // Setup ICorJitHost and call jitStartup if necessary if (pnjitStartup != nullptr) { - mc = firstContext; + mc = firstContext; jitHost = new JitHost(*this); pnjitStartup(jitHost); } pJitInstance = pngetJit(); - if(pJitInstance == nullptr) + if (pJitInstance == nullptr) { LogError("pngetJit gave us null"); return false; @@ -259,7 +261,7 @@ bool JitInstance::reLoad(MethodContext* firstContext) return true; } -JitInstance::Result JitInstance::CompileMethod(MethodContext *MethodToCompile, int mcIndex, bool collectThroughput) +JitInstance::Result JitInstance::CompileMethod(MethodContext* MethodToCompile, int mcIndex, bool collectThroughput) { struct Param : FilterSuperPMIExceptionsParam_CaptureException { @@ -270,24 +272,24 @@ JitInstance::Result JitInstance::CompileMethod(MethodContext *MethodToCompile, i int mcIndex; bool collectThroughput; } param; - param.pThis = this; - param.result = RESULT_SUCCESS; // assume success - param.flags = 0; - param.mcIndex = mcIndex; + param.pThis = this; + param.result = RESULT_SUCCESS; // assume success + param.flags = 0; + param.mcIndex = mcIndex; param.collectThroughput = collectThroughput; - //store to instance field our raw values, so we can figure things out a bit later... + // store to instance field our raw values, so we can figure things out a bit later... mc = MethodToCompile; times[0] = 0; times[1] = 0; - mc->repEnvironmentSet(); //Sets envvars + mc->repEnvironmentSet(); // Sets envvars stj.Start(); PAL_TRY(Param*, pParam, ¶m) { - BYTE *NEntryBlock = nullptr; + BYTE* NEntryBlock = nullptr; ULONG NCodeSizeBlock = 0; pParam->pThis->mc->repCompileMethod(&pParam->info, &pParam->flags); @@ -295,7 +297,8 @@ JitInstance::Result JitInstance::CompileMethod(MethodContext *MethodToCompile, i { pParam->pThis->lt.Start(); } - CorJitResult temp = pParam->pThis->pJitInstance->compileMethod(pParam->pThis->icji, &pParam->info, pParam->flags, &NEntryBlock, &NCodeSizeBlock); + CorJitResult temp = pParam->pThis->pJitInstance->compileMethod(pParam->pThis->icji, &pParam->info, + pParam->flags, &NEntryBlock, &NCodeSizeBlock); if (pParam->collectThroughput) { pParam->pThis->lt.Stop(); @@ -308,7 +311,7 @@ JitInstance::Result JitInstance::CompileMethod(MethodContext *MethodToCompile, i } if (temp == CORJIT_OK) { - //capture the results of compilation + // capture the results of compilation pParam->pThis->mc->cr->recCompileMethod(&NEntryBlock, &NCodeSizeBlock, temp); pParam->pThis->mc->cr->recAllocMemCapture(); pParam->pThis->mc->cr->recAllocGCInfoCapture(); @@ -327,7 +330,7 @@ JitInstance::Result JitInstance::CompileMethod(MethodContext *MethodToCompile, i if (e.GetCode() == EXCEPTIONCODE_MC) { - char *message = e.GetExceptionMessage(); + char* message = e.GetExceptionMessage(); LogMissing("Method context %d failed to replay: %s", mcIndex, message); e.DeleteMessage(); param.result = RESULT_MISSING; @@ -346,7 +349,7 @@ JitInstance::Result JitInstance::CompileMethod(MethodContext *MethodToCompile, i // If we get here, we know it compiles timeResult(param.info, param.flags); } - mc->repEnvironmentUnset(); //Unsets envvars + mc->repEnvironmentUnset(); // Unsets envvars mc->cr->secondsToCompile = stj.GetSeconds(); @@ -355,7 +358,7 @@ JitInstance::Result JitInstance::CompileMethod(MethodContext *MethodToCompile, i void JitInstance::timeResult(CORINFO_METHOD_INFO info, unsigned flags) { - BYTE *NEntryBlock = nullptr; + BYTE* NEntryBlock = nullptr; ULONG NCodeSizeBlock = 0; int sampleSize = 10; @@ -398,39 +401,31 @@ void JitInstance::timeResult(CORINFO_METHOD_INFO info, unsigned flags) // Used to allocate memory that needs to handed to the EE. // For eg, use this to allocated memory for reporting debug info, // which will be handed to the EE by setVars() and setBoundaries() -void * JitInstance::allocateArray( - ULONG cBytes - ) +void* JitInstance::allocateArray(ULONG cBytes) { mc->cr->AddCall("allocateArray"); - return HeapAlloc(mc->cr->getCodeHeap(),0,cBytes); + return HeapAlloc(mc->cr->getCodeHeap(), 0, cBytes); } // Used to allocate memory that needs to live as long as the jit // instance does. -void * JitInstance::allocateLongLivedArray( - ULONG cBytes - ) +void* JitInstance::allocateLongLivedArray(ULONG cBytes) { - return HeapAlloc(ourHeap,0,cBytes); + return HeapAlloc(ourHeap, 0, cBytes); } // JitCompiler will free arrays passed by the EE using this // For eg, The EE returns memory in getVars() and getBoundaries() // to the JitCompiler, which the JitCompiler should release using // freeArray() -void JitInstance::freeArray( - void *array - ) +void JitInstance::freeArray(void* array) { mc->cr->AddCall("freeArray"); - HeapFree(mc->cr->getCodeHeap(),0,array); + HeapFree(mc->cr->getCodeHeap(), 0, array); } // Used to free memory allocated by JitInstance::allocateLongLivedArray. -void JitInstance::freeLongLivedArray( - void *array - ) +void JitInstance::freeLongLivedArray(void* array) { - HeapFree(ourHeap,0,array); + HeapFree(ourHeap, 0, array); } diff --git a/src/ToolBox/superpmi/superpmi/jitinstance.h b/src/ToolBox/superpmi/superpmi/jitinstance.h index c85c2f5bee..9db17dc1ad 100644 --- a/src/ToolBox/superpmi/superpmi/jitinstance.h +++ b/src/ToolBox/superpmi/superpmi/jitinstance.h @@ -14,18 +14,18 @@ class JitInstance { private: - char *PathToOriginalJit; - char *PathToTempJit; - HANDLE ourHeap; - HMODULE hLib; - PgetJit pngetJit; - PjitStartup pnjitStartup; + char* PathToOriginalJit; + char* PathToTempJit; + HANDLE ourHeap; + HMODULE hLib; + PgetJit pngetJit; + PjitStartup pnjitStartup; PsxsJitStartup pnsxsJitStartup; - ICorJitHost *jitHost; - ICorJitInfo *icji; - SimpleTimer stj; + ICorJitHost* jitHost; + ICorJitInfo* icji; + SimpleTimer stj; - JitInstance() {}; + JitInstance(){}; void timeResult(CORINFO_METHOD_INFO info, unsigned flags); public: @@ -35,18 +35,18 @@ public: RESULT_SUCCESS, RESULT_MISSING }; - CycleTimer lt; - MethodContext *mc; - ULONGLONG times[2]; - ICorJitCompiler *pJitInstance; + CycleTimer lt; + MethodContext* mc; + ULONGLONG times[2]; + ICorJitCompiler* pJitInstance; // Allocate and initialize the jit provided - static JitInstance *InitJit(char *nameOfJit, bool breakOnAssert, SimpleTimer *st1, MethodContext* firstContext); + static JitInstance* InitJit(char* nameOfJit, bool breakOnAssert, SimpleTimer* st1, MethodContext* firstContext); - HRESULT StartUp(char *PathToJit, bool copyJit, bool breakOnDebugBreakorAV, MethodContext* firstContext); + HRESULT StartUp(char* PathToJit, bool copyJit, bool breakOnDebugBreakorAV, MethodContext* firstContext); bool reLoad(MethodContext* firstContext); - Result CompileMethod(MethodContext *MethodToCompile, int mcIndex, bool collectThroughput); + Result CompileMethod(MethodContext* MethodToCompile, int mcIndex, bool collectThroughput); void* allocateArray(ULONG size); void* allocateLongLivedArray(ULONG size); diff --git a/src/ToolBox/superpmi/superpmi/methodstatsemitter.cpp b/src/ToolBox/superpmi/superpmi/methodstatsemitter.cpp index 5cebc97db4..2ca1adf0cf 100644 --- a/src/ToolBox/superpmi/superpmi/methodstatsemitter.cpp +++ b/src/ToolBox/superpmi/superpmi/methodstatsemitter.cpp @@ -11,12 +11,13 @@ #include "methodstatsemitter.h" #include "logging.h" -MethodStatsEmitter::MethodStatsEmitter(char *nameOfInput) +MethodStatsEmitter::MethodStatsEmitter(char* nameOfInput) { char filename[MAX_PATH + 1]; sprintf_s(filename, MAX_PATH + 1, "%s.stats", nameOfInput); - hStatsFile = CreateFileA(filename, GENERIC_WRITE, FILE_SHARE_WRITE, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + hStatsFile = + CreateFileA(filename, GENERIC_WRITE, FILE_SHARE_WRITE, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); if (hStatsFile == INVALID_HANDLE_VALUE) { LogError("Failed to open output file '%s'. GetLastError()=%u", filename, GetLastError()); @@ -34,18 +35,18 @@ MethodStatsEmitter::~MethodStatsEmitter() } } -void MethodStatsEmitter::Emit(int methodNumber, MethodContext *mc, ULONGLONG firstTime, ULONGLONG secondTime) +void MethodStatsEmitter::Emit(int methodNumber, MethodContext* mc, ULONGLONG firstTime, ULONGLONG secondTime) { if (hStatsFile != INVALID_HANDLE_VALUE) { - //Print the CSV header row - char rowData[2048]; - DWORD charCount = 0; + // Print the CSV header row + char rowData[2048]; + DWORD charCount = 0; DWORD bytesWritten = 0; if (strchr(statsTypes, '*') != NULL || strchr(statsTypes, 'h') != NULL || strchr(statsTypes, 'H') != NULL) { - //Obtain the method Hash + // Obtain the method Hash char md5Hash[MD5_HASH_BUFFER_SIZE]; if (mc->dumpMethodMD5HashToBuffer(md5Hash, MD5_HASH_BUFFER_SIZE) != MD5_HASH_BUFFER_SIZE) md5Hash[0] = 0; @@ -58,32 +59,33 @@ void MethodStatsEmitter::Emit(int methodNumber, MethodContext *mc, ULONGLONG fir } if (strchr(statsTypes, '*') != NULL || strchr(statsTypes, 'i') != NULL || strchr(statsTypes, 'I') != NULL) { - //Obtain the IL code size for this method + // Obtain the IL code size for this method CORINFO_METHOD_INFO info; - unsigned flags = 0; + unsigned flags = 0; mc->repCompileMethod(&info, &flags); charCount += sprintf_s(rowData + charCount, _countof(rowData) - charCount, "%d,", info.ILCodeSize); } if (strchr(statsTypes, '*') != NULL || strchr(statsTypes, 'a') != NULL || strchr(statsTypes, 'A') != NULL) { - //Obtain the compiled method ASM size - BYTE *temp; - DWORD codeSize; + // Obtain the compiled method ASM size + BYTE* temp; + DWORD codeSize; CorJitResult result; if (mc->cr->CompileMethod != nullptr) mc->cr->repCompileMethod(&temp, &codeSize, &result); else - codeSize = 0;//this is likely a thin mc + codeSize = 0; // this is likely a thin mc charCount += sprintf_s(rowData + charCount, _countof(rowData) - charCount, "%d,", codeSize); } if (strchr(statsTypes, '*') != NULL || strchr(statsTypes, 't') != NULL || strchr(statsTypes, 'T') != NULL) { - charCount += sprintf_s(rowData + charCount, _countof(rowData) - charCount, "%llu,%llu,", firstTime, secondTime); + charCount += + sprintf_s(rowData + charCount, _countof(rowData) - charCount, "%llu,%llu,", firstTime, secondTime); } - //get rid of the final ',' and replace it with a '\n' + // get rid of the final ',' and replace it with a '\n' rowData[charCount - 1] = '\n'; if (!WriteFile(hStatsFile, rowData, charCount, &bytesWritten, nullptr) || bytesWritten != charCount) @@ -93,15 +95,15 @@ void MethodStatsEmitter::Emit(int methodNumber, MethodContext *mc, ULONGLONG fir } } -void MethodStatsEmitter::SetStatsTypes(char *types) +void MethodStatsEmitter::SetStatsTypes(char* types) { statsTypes = types; if (hStatsFile != INVALID_HANDLE_VALUE) { - //Print the CSV header row - char rowHeader[1024]; - DWORD charCount = 0; + // Print the CSV header row + char rowHeader[1024]; + DWORD charCount = 0; DWORD bytesWritten = 0; if (strchr(statsTypes, '*') != NULL || strchr(statsTypes, 'h') != NULL || strchr(statsTypes, 'H') != NULL) @@ -115,7 +117,7 @@ void MethodStatsEmitter::SetStatsTypes(char *types) if (strchr(statsTypes, '*') != NULL || strchr(statsTypes, 't') != NULL || strchr(statsTypes, 'T') != NULL) charCount += sprintf_s(rowHeader + charCount, _countof(rowHeader) - charCount, "Time1,Time2,"); - //get rid of the final ',' and replace it with a '\n' + // get rid of the final ',' and replace it with a '\n' rowHeader[charCount - 1] = '\n'; if (!WriteFile(hStatsFile, rowHeader, charCount, &bytesWritten, nullptr) || bytesWritten != charCount) diff --git a/src/ToolBox/superpmi/superpmi/methodstatsemitter.h b/src/ToolBox/superpmi/superpmi/methodstatsemitter.h index fb651b04b2..7b03ddeea5 100644 --- a/src/ToolBox/superpmi/superpmi/methodstatsemitter.h +++ b/src/ToolBox/superpmi/superpmi/methodstatsemitter.h @@ -16,14 +16,14 @@ class MethodStatsEmitter { private: - char *statsTypes; + char* statsTypes; HANDLE hStatsFile; public: - MethodStatsEmitter(char *nameOfInput); + MethodStatsEmitter(char* nameOfInput); ~MethodStatsEmitter(); - void Emit(int methodNumber, MethodContext *mc, ULONGLONG firstTime, ULONGLONG secondTime); - void SetStatsTypes(char *types); + void Emit(int methodNumber, MethodContext* mc, ULONGLONG firstTime, ULONGLONG secondTime); + void SetStatsTypes(char* types); }; #endif
\ No newline at end of file diff --git a/src/ToolBox/superpmi/superpmi/neardiffer.cpp b/src/ToolBox/superpmi/superpmi/neardiffer.cpp index 3f2c4db3b8..d3ccae5ccc 100644 --- a/src/ToolBox/superpmi/superpmi/neardiffer.cpp +++ b/src/ToolBox/superpmi/superpmi/neardiffer.cpp @@ -23,25 +23,28 @@ // The file/linenumber information is from this helper itself, // since we are only linking with the CoreDisTools library. // -static void LogFromCoreDisToolsHelper(LogLevel level, const char *msg, va_list argList) +static void LogFromCoreDisToolsHelper(LogLevel level, const char* msg, va_list argList) { Logger::LogVprintf(__func__, __FILE__, __LINE__, level, argList, msg); } -#define LOGGER(L) \ -static void Log##L(const char *msg, ...) \ -{\ - va_list argList; \ - va_start(argList, msg); \ - LogFromCoreDisToolsHelper (LOGLEVEL_##L, msg, argList); \ - va_end(argList); \ +#define LOGGER(L) \ + \ +static void Log##L(const char* msg, ...) \ + \ +{ \ + va_list argList; \ + va_start(argList, msg); \ + LogFromCoreDisToolsHelper(LOGLEVEL_##L, msg, argList); \ + va_end(argList); \ + \ } LOGGER(VERBOSE) LOGGER(ERROR) LOGGER(WARNING) -const PrintControl CorPrinter= { LogERROR, LogWARNING, LogVERBOSE, LogVERBOSE }; +const PrintControl CorPrinter = {LogERROR, LogWARNING, LogVERBOSE, LogVERBOSE}; #endif // USE_COREDISTOOLS @@ -64,7 +67,7 @@ void NearDiffer::InitAsmDiff() NearDiffer::~NearDiffer() { #ifdef USE_COREDISTOOLS - if (corAsmDiff != nullptr) + if (corAsmDiff != nullptr) { FinishDiff(corAsmDiff); } @@ -94,7 +97,7 @@ NearDiffer::~NearDiffer() DIS* NearDiffer::GetMsVcDis() { - DIS *disasm; + DIS* disasm; #ifdef _TARGET_AMD64_ if ((TargetArchitecture != nullptr) && (0 == _stricmp(TargetArchitecture, "arm64"))) @@ -126,43 +129,44 @@ DIS* NearDiffer::GetMsVcDis() // blocksize - The size of the code block to disassemble. // originalAddr - The original base address of the code block. // -void NearDiffer::DumpCodeBlock(unsigned char *block, ULONG blocksize, void *originalAddr) +void NearDiffer::DumpCodeBlock(unsigned char* block, ULONG blocksize, void* originalAddr) { -#ifdef USE_MSVCDIS - DIS *disasm = GetMsVcDis(); - size_t offset = 0; +#ifdef USE_MSVCDIS + DIS* disasm = GetMsVcDis(); + size_t offset = 0; std::string codeBlock; while (offset < blocksize) { DIS::INSTRUCTION instr; - DIS::OPERAND ops[3]; + DIS::OPERAND ops[3]; - size_t instrSize = disasm->CbDisassemble((DIS::ADDR)originalAddr + offset, (void *)(block + offset), 15); - if(instrSize==0) + size_t instrSize = disasm->CbDisassemble((DIS::ADDR)originalAddr + offset, (void*)(block + offset), 15); + if (instrSize == 0) { LogWarning("Zero sized instruction"); break; } disasm->FDecode(&instr, ops, 3); - wchar_t instrMnemonicWide[64]; // I never know how much to allocate... + wchar_t instrMnemonicWide[64]; // I never know how much to allocate... disasm->CchFormatInstr(instrMnemonicWide, 64); - char instrMnemonic[128]; + char instrMnemonic[128]; size_t count; wcstombs_s(&count, instrMnemonic, 128, instrMnemonicWide, 64); const size_t minInstrBytes = 7; - size_t instrBytes = max(instrSize, minInstrBytes); - size_t buffSize = sizeof("%p %s\n") + 10 + count + 3 * instrBytes + 1; - char *buff = new char[buffSize]; - int written = 0; - written += sprintf_s(buff, buffSize, "%p ", (void*)((size_t)originalAddr+offset)); + size_t instrBytes = max(instrSize, minInstrBytes); + size_t buffSize = sizeof("%p %s\n") + 10 + count + 3 * instrBytes + 1; + char* buff = new char[buffSize]; + int written = 0; + written += sprintf_s(buff, buffSize, "%p ", (void*)((size_t)originalAddr + offset)); for (size_t i = 0; i < instrBytes; i++) { if (i < instrSize) { - written += sprintf_s(buff + written, buffSize - written, "%02X ", *(const uint8_t*)(block + offset + i)); + written += + sprintf_s(buff + written, buffSize - written, "%02X ", *(const uint8_t*)(block + offset + i)); } else { @@ -176,7 +180,7 @@ void NearDiffer::DumpCodeBlock(unsigned char *block, ULONG blocksize, void *orig } LogVerbose("Code dump:\n%s", codeBlock.c_str()); delete disasm; -#else // !USE_MSVCDIS +#else // !USE_MSVCDIS LogVerbose("No disassembler"); #endif // !USE_MSVCDIS } @@ -187,7 +191,7 @@ void NearDiffer::DumpCodeBlock(unsigned char *block, ULONG blocksize, void *orig struct DiffData { // Common Data - CompileResult *cr; + CompileResult* cr; // Details of the first block size_t blocksize1; @@ -213,11 +217,8 @@ struct DiffData // Determine whether two syntactically different constants are // semantically equivalent, using certain heuristics. // -bool NearDiffer::compareOffsets(const void *payload, - size_t blockOffset, - size_t instrLen, - uint64_t offset1, - uint64_t offset2) +bool NearDiffer::compareOffsets( + const void* payload, size_t blockOffset, size_t instrLen, uint64_t offset1, uint64_t offset2) { // The trivial case if (offset1 == offset2) @@ -225,91 +226,94 @@ bool NearDiffer::compareOffsets(const void *payload, return true; } - const DiffData *data = (const DiffData *)payload; - size_t ip1 = data->originalBlock1 + blockOffset; - size_t ip2 = data->originalBlock2 + blockOffset; - size_t ipRelOffset1 = ip1 + instrLen + (size_t)offset1; - size_t ipRelOffset2 = ip2 + instrLen + (size_t)offset2; + const DiffData* data = (const DiffData*)payload; + size_t ip1 = data->originalBlock1 + blockOffset; + size_t ip2 = data->originalBlock2 + blockOffset; + size_t ipRelOffset1 = ip1 + instrLen + (size_t)offset1; + size_t ipRelOffset2 = ip2 + instrLen + (size_t)offset2; // Case where we have a call into flat address -- the most common case. size_t gOffset1 = ipRelOffset1; size_t gOffset2 = ipRelOffset2; - if ((DWORD)gOffset1 == (DWORD)gOffset2) //make sure the lower 32bits match (best we can do in the current replay form) + if ((DWORD)gOffset1 == + (DWORD)gOffset2) // make sure the lower 32bits match (best we can do in the current replay form) return true; - //Case where we have an offset into the read only section (e.g. loading a float value) + // Case where we have an offset into the read only section (e.g. loading a float value) size_t roOffset1a = (size_t)offset1 - data->originalDataBlock1; size_t roOffset2a = (size_t)offset2 - data->originalDataBlock2; - if ((roOffset1a == roOffset2a) && (roOffset1a < data->datablockSize1)) //Confirm its an offset that fits inside our RoRegion + if ((roOffset1a == roOffset2a) && + (roOffset1a < data->datablockSize1)) // Confirm its an offset that fits inside our RoRegion return true; // This case is written to catch IP-relative offsets to the RO data-section // For example: - // + // size_t roOffset1b = ipRelOffset1 - data->originalDataBlock1; size_t roOffset2b = ipRelOffset2 - data->originalDataBlock2; - if ((roOffset1b == roOffset2b) && (roOffset1b < data->datablockSize1)) //Confirm its an offset that fits inside our RoRegion + if ((roOffset1b == roOffset2b) && + (roOffset1b < data->datablockSize1)) // Confirm its an offset that fits inside our RoRegion return true; - //Case where we push an address to our own code section. + // Case where we push an address to our own code section. size_t gOffset1a = (size_t)offset1 - data->originalBlock1; size_t gOffset2a = (size_t)offset2 - data->originalBlock2; - if ((gOffset1a == gOffset2a) && (gOffset1a < data->blocksize1)) //Confirm its in our code region + if ((gOffset1a == gOffset2a) && (gOffset1a < data->blocksize1)) // Confirm its in our code region return true; - //Case where we push an address in the other codeblock. + // Case where we push an address in the other codeblock. size_t gOffset1b = (size_t)offset1 - data->otherCodeBlock1; size_t gOffset2b = (size_t)offset2 - data->otherCodeBlock2; - if ((gOffset1b == gOffset2b) && (gOffset1b < data->otherCodeBlockSize1)) //Confirm it's in the other code region + if ((gOffset1b == gOffset2b) && (gOffset1b < data->otherCodeBlockSize1)) // Confirm it's in the other code region return true; - //Case where we have an offset into the hot codeblock from the cold code block (why?) + // Case where we have an offset into the hot codeblock from the cold code block (why?) size_t ocOffset1 = ipRelOffset1 - data->otherCodeBlock1; size_t ocOffset2 = ipRelOffset2 - data->otherCodeBlock2; - if (ocOffset1 == ocOffset2) //Would be nice to check to see if it fits in the other code block + if (ocOffset1 == ocOffset2) // Would be nice to check to see if it fits in the other code block return true; - //VSD calling case. + // VSD calling case. size_t Offset1 = (ipRelOffset1 - 8); if (data->cr->CallTargetTypes->GetIndex((DWORDLONG)Offset1) != (DWORD)-1) { // This logging is too noisy, so disable it. - //LogVerbose("Found VSD callsite, did softer compare than ideal"); + //LogVerbose("Found VSD callsite, did softer compare than ideal"); return true; } - //x86 VSD calling cases. + // x86 VSD calling cases. size_t Offset1b = (size_t)offset1 - 4; size_t Offset2b = (size_t)offset2; if (data->cr->CallTargetTypes->GetIndex((DWORDLONG)Offset1b) != (DWORD)-1) { // This logging is too noisy, so disable it. - //LogVerbose("Found VSD callsite, did softer compare than ideal"); + //LogVerbose("Found VSD callsite, did softer compare than ideal"); return true; } if (data->cr->CallTargetTypes->GetIndex((DWORDLONG)Offset2b) != (DWORD)-1) { // This logging is too noisy, so disable it. - //LogVerbose("Found VSD callsite, did softer compare than ideal"); + //LogVerbose("Found VSD callsite, did softer compare than ideal"); return true; } - //Case might be a field address that we handed out to handle inlined values being loaded into - //a register as an immediate value (and where the address is encoded as an indirect immediate load) + // Case might be a field address that we handed out to handle inlined values being loaded into + //a register as an immediate value (and where the address is encoded as an indirect immediate load) size_t realTargetAddr = (size_t)data->cr->searchAddressMap((void*)gOffset2); if (realTargetAddr == gOffset1) return true; - //Case might be a field address that we handed out to handle inlined values being loaded into - //a register as an immediate value (and where the address is encoded and loaded by immediate into a register) + // Case might be a field address that we handed out to handle inlined values being loaded into + //a register as an immediate value (and where the address is encoded and loaded by immediate into a register) realTargetAddr = (size_t)data->cr->searchAddressMap((void*)offset2); if (realTargetAddr == offset1) return true; - if (realTargetAddr == 0x424242)//this offset matches what we got back from a getTailCallCopyArgsThunk + if (realTargetAddr == 0x424242) // this offset matches what we got back from a getTailCallCopyArgsThunk return true; realTargetAddr = (size_t)data->cr->searchAddressMap((void*)(gOffset2)); - if (realTargetAddr != -1) //we know this was passed out as a bbloc + if (realTargetAddr != -1) // we know this was passed out as a bbloc return true; return false; @@ -366,72 +370,56 @@ bool NearDiffer::compareOffsets(const void *payload, // True if the code sections are syntactically identical; false otherwise. // -bool NearDiffer::compareCodeSection( - MethodContext *mc, - CompileResult *cr1, - CompileResult *cr2, - unsigned char *block1, - ULONG blocksize1, - unsigned char *datablock1, - ULONG datablockSize1, - void *originalBlock1, - void *originalDataBlock1, - void *otherCodeBlock1, - ULONG otherCodeBlockSize1, - unsigned char *block2, - ULONG blocksize2, - unsigned char *datablock2, - ULONG datablockSize2, - void *originalBlock2, - void *originalDataBlock2, - void *otherCodeBlock2, - ULONG otherCodeBlockSize2) +bool NearDiffer::compareCodeSection(MethodContext* mc, + CompileResult* cr1, + CompileResult* cr2, + unsigned char* block1, + ULONG blocksize1, + unsigned char* datablock1, + ULONG datablockSize1, + void* originalBlock1, + void* originalDataBlock1, + void* otherCodeBlock1, + ULONG otherCodeBlockSize1, + unsigned char* block2, + ULONG blocksize2, + unsigned char* datablock2, + ULONG datablockSize2, + void* originalBlock2, + void* originalDataBlock2, + void* otherCodeBlock2, + ULONG otherCodeBlockSize2) { - DiffData data = - { - cr2, - - // Details of the first block - (size_t)blocksize1, - (size_t)datablock1, - (size_t)datablockSize1, - (size_t)originalBlock1, - (size_t)originalDataBlock1, - (size_t)otherCodeBlock1, - (size_t)otherCodeBlockSize1, - - // Details of the second block - (size_t)blocksize2, - (size_t)datablock2, - (size_t)datablockSize2, - (size_t)originalBlock2, - (size_t)originalDataBlock2, - (size_t)otherCodeBlock2, - (size_t)otherCodeBlockSize2 - }; + DiffData data = {cr2, + + // Details of the first block + (size_t)blocksize1, (size_t)datablock1, (size_t)datablockSize1, (size_t)originalBlock1, + (size_t)originalDataBlock1, (size_t)otherCodeBlock1, (size_t)otherCodeBlockSize1, + + // Details of the second block + (size_t)blocksize2, (size_t)datablock2, (size_t)datablockSize2, (size_t)originalBlock2, + (size_t)originalDataBlock2, (size_t)otherCodeBlock2, (size_t)otherCodeBlockSize2}; #ifdef USE_COREDISTOOLS - if (UseCoreDisTools) + if (UseCoreDisTools) { - bool areSame = NearDiffCodeBlocks(corAsmDiff, &data, - (const uint8_t *)originalBlock1, block1, blocksize1, - (const uint8_t *)originalBlock2, block2, blocksize2); + bool areSame = NearDiffCodeBlocks(corAsmDiff, &data, (const uint8_t*)originalBlock1, block1, blocksize1, + (const uint8_t*)originalBlock2, block2, blocksize2); - if (!areSame) + if (!areSame) { - DumpDiffBlocks(corAsmDiff, (const uint8_t *) originalBlock1, - block1, blocksize1, (const uint8_t *) originalBlock2, - block2, blocksize2); + DumpDiffBlocks(corAsmDiff, (const uint8_t*)originalBlock1, block1, blocksize1, + (const uint8_t*)originalBlock2, block2, blocksize2); } return areSame; } #endif // USE_COREDISTOOLS -#ifdef USE_MSVCDIS +#ifdef USE_MSVCDIS bool haveSeenRet = false; - DIS *disasm_1 = GetMsVcDis(); - DIS *disasm_2 = GetMsVcDis(); + DIS* disasm_1 = GetMsVcDis(); + DIS* disasm_2 = GetMsVcDis(); size_t offset = 0; @@ -445,9 +433,9 @@ bool NearDiffer::compareCodeSection( { DIS::INSTRUCTION instr_1; DIS::INSTRUCTION instr_2; - const int MaxOperandCount = 5; - DIS::OPERAND ops_1[MaxOperandCount]; - DIS::OPERAND ops_2[MaxOperandCount]; + const int MaxOperandCount = 5; + DIS::OPERAND ops_1[MaxOperandCount]; + DIS::OPERAND ops_2[MaxOperandCount]; // Zero out the locals, just in case. memset(&instr_1, 0, sizeof(instr_1)); @@ -455,8 +443,8 @@ bool NearDiffer::compareCodeSection( memset(&ops_1, 0, sizeof(ops_1)); memset(&ops_2, 0, sizeof(ops_2)); - size_t instrSize_1 = disasm_1->CbDisassemble((DIS::ADDR)originalBlock1 + offset, (void *)(block1 + offset), 15); - size_t instrSize_2 = disasm_2->CbDisassemble((DIS::ADDR)originalBlock2 + offset, (void *)(block2 + offset), 15); + size_t instrSize_1 = disasm_1->CbDisassemble((DIS::ADDR)originalBlock1 + offset, (void*)(block1 + offset), 15); + size_t instrSize_2 = disasm_2->CbDisassemble((DIS::ADDR)originalBlock2 + offset, (void*)(block2 + offset), 15); if (instrSize_1 != instrSize_2) { @@ -468,7 +456,7 @@ bool NearDiffer::compareCodeSection( if (haveSeenRet) { // This logging is pretty noisy, so disable it. - //LogVerbose("instruction size of zero after seeing a ret (soft issue?)."); + //LogVerbose("instruction size of zero after seeing a ret (soft issue?)."); break; } LogWarning("instruction size of zero."); @@ -487,9 +475,9 @@ bool NearDiffer::compareCodeSection( FDecodeError = true; } - wchar_t instrMnemonic_1[64]; // I never know how much to allocate... + wchar_t instrMnemonic_1[64]; // I never know how much to allocate... disasm_1->CchFormatInstr(instrMnemonic_1, 64); - wchar_t instrMnemonic_2[64]; // I never know how much to allocate... + wchar_t instrMnemonic_2[64]; // I never know how much to allocate... disasm_2->CchFormatInstr(instrMnemonic_2, 64); if (wcscmp(instrMnemonic_1, L"ret") == 0) haveSeenRet = true; @@ -576,11 +564,11 @@ bool NearDiffer::compareCodeSection( // 0F 2E 05 67 00 9A FD ucomiss xmm0, dword ptr[FFFFFFFFFD9A006Eh] // - if (compareOffsets(&data, offset, 0, ops_1[i].dwl, ops_2[i].dwl)) + if (compareOffsets(&data, offset, 0, ops_1[i].dwl, ops_2[i].dwl)) { continue; } - else + else { size_t gOffset1 = (size_t)originalBlock1 + offset + (size_t)ops_1[i].dwl; size_t gOffset2 = (size_t)originalBlock2 + offset + (size_t)ops_2[i].dwl; @@ -610,16 +598,16 @@ bool NearDiffer::compareCodeSection( DumpDetails: LogVerbose("block1 %p", block1); LogVerbose("block2 %p", block2); - LogVerbose("originalBlock1 [%p,%p)", originalBlock1, (const uint8_t *)originalBlock1 + blocksize1); - LogVerbose("originalBlock2 [%p,%p)", originalBlock2, (const uint8_t *)originalBlock2 + blocksize2); + LogVerbose("originalBlock1 [%p,%p)", originalBlock1, (const uint8_t*)originalBlock1 + blocksize1); + LogVerbose("originalBlock2 [%p,%p)", originalBlock2, (const uint8_t*)originalBlock2 + blocksize2); LogVerbose("blocksize1 %08X", blocksize1); LogVerbose("blocksize2 %08X", blocksize2); - LogVerbose("dataBlock1 [%p,%p)", originalDataBlock1, (const uint8_t *)originalDataBlock1 + datablockSize1); - LogVerbose("dataBlock2 [%p,%p)", originalDataBlock2, (const uint8_t *)originalDataBlock2 + datablockSize2); + LogVerbose("dataBlock1 [%p,%p)", originalDataBlock1, (const uint8_t*)originalDataBlock1 + datablockSize1); + LogVerbose("dataBlock2 [%p,%p)", originalDataBlock2, (const uint8_t*)originalDataBlock2 + datablockSize2); LogVerbose("datablockSize1 %08X", datablockSize1); LogVerbose("datablockSize2 %08X", datablockSize2); - LogVerbose("otherCodeBlock1 [%p,%p)", otherCodeBlock1, (const uint8_t *)otherCodeBlock1 + otherCodeBlockSize1); - LogVerbose("otherCodeBlock2 [%p,%p)", otherCodeBlock2, (const uint8_t *)otherCodeBlock2 + otherCodeBlockSize2); + LogVerbose("otherCodeBlock1 [%p,%p)", otherCodeBlock1, (const uint8_t*)otherCodeBlock1 + otherCodeBlockSize1); + LogVerbose("otherCodeBlock2 [%p,%p)", otherCodeBlock2, (const uint8_t*)otherCodeBlock2 + otherCodeBlockSize2); LogVerbose("otherCodeBlockSize1 %08X", otherCodeBlockSize1); LogVerbose("otherCodeBlockSize2 %08X", otherCodeBlockSize2); @@ -643,7 +631,7 @@ DumpDetails: if (disasm_2 != nullptr) delete disasm_2; return false; -#else // !USE_MSVCDIS +#else // !USE_MSVCDIS return false; // No disassembler; assume there are differences #endif // !USE_MSVCDIS } @@ -665,21 +653,28 @@ DumpDetails: // Return Value: // True if the read-only data sections are identical; false otherwise. // -bool NearDiffer::compareReadOnlyDataBlock(MethodContext *mc, CompileResult *cr1, CompileResult *cr2, - unsigned char *block1, ULONG blocksize1, void *originalDataBlock1, - unsigned char *block2, ULONG blocksize2, void *originalDataBlock2) +bool NearDiffer::compareReadOnlyDataBlock(MethodContext* mc, + CompileResult* cr1, + CompileResult* cr2, + unsigned char* block1, + ULONG blocksize1, + void* originalDataBlock1, + unsigned char* block2, + ULONG blocksize2, + void* originalDataBlock2) { - //no rodata - if(blocksize1==0 && blocksize2==0) + // no rodata + if (blocksize1 == 0 && blocksize2 == 0) return true; - if(blocksize1!=blocksize2) + if (blocksize1 != blocksize2) { LogVerbose("compareReadOnlyDataBlock found non-matching sizes %u %u", blocksize1, blocksize2); return false; } - //TODO-Cleanup: The values on the datablock seem to wobble. Need further investigation to evaluate a good near comparison for these + // TODO-Cleanup: The values on the datablock seem to wobble. Need further investigation to evaluate a good near + // comparison for these return true; } @@ -694,7 +689,7 @@ bool NearDiffer::compareReadOnlyDataBlock(MethodContext *mc, CompileResult *cr1, // Return Value: // True if the EH info blocks are identical; false otherwise. // -bool NearDiffer::compareEHInfo(MethodContext *mc, CompileResult *cr1, CompileResult *cr2) +bool NearDiffer::compareEHInfo(MethodContext* mc, CompileResult* cr1, CompileResult* cr2) { ULONG cEHSize_1; ULONG ehFlags_1; @@ -712,40 +707,41 @@ bool NearDiffer::compareEHInfo(MethodContext *mc, CompileResult *cr1, CompileRes ULONG handlerLength_2; ULONG classToken_2; - cEHSize_1 = cr1->repSetEHcount(); cEHSize_2 = cr2->repSetEHcount(); - //no exception - if(cEHSize_1==0 && cEHSize_2==0) + // no exception + if (cEHSize_1 == 0 && cEHSize_2 == 0) return true; - if(cEHSize_1!=cEHSize_2) + if (cEHSize_1 != cEHSize_2) { LogVerbose("compareEHInfo found non-matching sizes %u %u", cEHSize_1, cEHSize_2); return false; } - for(unsigned int i=0;i<cEHSize_1;i++) + for (unsigned int i = 0; i < cEHSize_1; i++) { cr1->repSetEHinfo(i, &ehFlags_1, &tryOffset_1, &tryLength_1, &handlerOffset_1, &handlerLength_1, &classToken_1); cr2->repSetEHinfo(i, &ehFlags_2, &tryOffset_2, &tryLength_2, &handlerOffset_2, &handlerLength_2, &classToken_2); - if(ehFlags_1!=ehFlags_2) + if (ehFlags_1 != ehFlags_2) { LogVerbose("EH flags don't match %u != %u", ehFlags_1, ehFlags_2); return false; } - if((tryOffset_1!=tryOffset_2) || (tryLength_1!=tryLength_2)) + if ((tryOffset_1 != tryOffset_2) || (tryLength_1 != tryLength_2)) { - LogVerbose("EH try information don't match, offset: %u %u, length: %u %u", tryOffset_1, tryOffset_2, tryLength_1, tryLength_2); + LogVerbose("EH try information don't match, offset: %u %u, length: %u %u", tryOffset_1, tryOffset_2, + tryLength_1, tryLength_2); return false; } - if((handlerOffset_1!=handlerOffset_2) || (handlerLength_1!=handlerLength_2)) + if ((handlerOffset_1 != handlerOffset_2) || (handlerLength_1 != handlerLength_2)) { - LogVerbose("EH handler information don't match, offset: %u %u, length: %u %u", handlerOffset_1, handlerOffset_2, handlerLength_1, handlerLength_2); + LogVerbose("EH handler information don't match, offset: %u %u, length: %u %u", handlerOffset_1, + handlerOffset_2, handlerLength_1, handlerLength_2); return false; } - if(classToken_1!=classToken_2) + if (classToken_1 != classToken_2) { LogVerbose("EH class tokens don't match %u!=%u", classToken_1, classToken_2); return false; @@ -766,11 +762,11 @@ bool NearDiffer::compareEHInfo(MethodContext *mc, CompileResult *cr1, CompileRes // Return Value: // True if the GC info blocks are identical; false otherwise. // -bool NearDiffer::compareGCInfo(MethodContext *mc, CompileResult *cr1, CompileResult *cr2) +bool NearDiffer::compareGCInfo(MethodContext* mc, CompileResult* cr1, CompileResult* cr2) { - void *gcInfo1; + void* gcInfo1; size_t gcInfo1Size; - void *gcInfo2; + void* gcInfo2; size_t gcInfo2Size; cr1->repAllocGCInfo(&gcInfo1Size, &gcInfo1); @@ -802,62 +798,62 @@ bool NearDiffer::compareGCInfo(MethodContext *mc, CompileResult *cr1, CompileRes // Return Value: // True if the native var info is identical; false otherwise. // -bool NearDiffer::compareVars(MethodContext *mc, CompileResult *cr1, CompileResult *cr2) +bool NearDiffer::compareVars(MethodContext* mc, CompileResult* cr1, CompileResult* cr2) { - CORINFO_METHOD_HANDLE ftn_1; - ULONG32 cVars_1; - ICorDebugInfo::NativeVarInfo *vars_1; + CORINFO_METHOD_HANDLE ftn_1; + ULONG32 cVars_1; + ICorDebugInfo::NativeVarInfo* vars_1; - CORINFO_METHOD_HANDLE ftn_2; - ULONG32 cVars_2; - ICorDebugInfo::NativeVarInfo *vars_2; + CORINFO_METHOD_HANDLE ftn_2; + ULONG32 cVars_2; + ICorDebugInfo::NativeVarInfo* vars_2; CORINFO_METHOD_INFO info; - unsigned flags = 0; + unsigned flags = 0; mc->repCompileMethod(&info, &flags); bool set1 = cr1->repSetVars(&ftn_1, &cVars_1, &vars_1); bool set2 = cr2->repSetVars(&ftn_2, &cVars_2, &vars_2); - if((set1==false)&&(set2==false)) + if ((set1 == false) && (set2 == false)) return true; // we don't have boundaries for either of these. - if(((set1==true)&&(set2==false))||((set1==false)&&(set2==true))) + if (((set1 == true) && (set2 == false)) || ((set1 == false) && (set2 == true))) { LogVerbose("missing matching vars sets"); return false; } - //no vars - if(cVars_1==0 && cVars_2==0) + // no vars + if (cVars_1 == 0 && cVars_2 == 0) { return true; } - if(ftn_1!=ftn_2) + if (ftn_1 != ftn_2) { - //We would like to find out this situation + // We would like to find out this situation __debugbreak(); LogVerbose("compareVars found non-matching CORINFO_METHOD_HANDLE %p %p", ftn_1, ftn_2); return false; } - if(ftn_1!=info.ftn) + if (ftn_1 != info.ftn) { LogVerbose("compareVars found issues with the CORINFO_METHOD_HANDLE %p %p", ftn_1, info.ftn); return false; } - if(cVars_1!=cVars_2) + if (cVars_1 != cVars_2) { LogVerbose("compareVars found non-matching var count %u %u", cVars_1, cVars_2); return false; } - //TODO-Cleanup: The values on the NativeVarInfo array seem to wobble. Need further investigation to evaluate a good near comparison for these - //for(unsigned int i=0;i<cVars_1;i++) + // TODO-Cleanup: The values on the NativeVarInfo array seem to wobble. Need further investigation to evaluate a good + // near comparison for these for(unsigned int i=0;i<cVars_1;i++) //{ // if(vars_1[i].startOffset!=vars_2[i].startOffset) // { - // LogVerbose("compareVars found non-matching startOffsets %u %u for var: %u", vars_1[i].startOffset, vars_2[i].startOffset, i); - // return false; + // LogVerbose("compareVars found non-matching startOffsets %u %u for var: %u", vars_1[i].startOffset, + // vars_2[i].startOffset, i); return false; // } //} @@ -875,66 +871,68 @@ bool NearDiffer::compareVars(MethodContext *mc, CompileResult *cr1, CompileResul // Return Value: // True if the native offset mappings are identical; false otherwise. // -bool NearDiffer::compareBoundaries(MethodContext *mc, CompileResult *cr1, CompileResult *cr2) +bool NearDiffer::compareBoundaries(MethodContext* mc, CompileResult* cr1, CompileResult* cr2) { - CORINFO_METHOD_HANDLE ftn_1; - ULONG32 cMap_1; - ICorDebugInfo::OffsetMapping *map_1; + CORINFO_METHOD_HANDLE ftn_1; + ULONG32 cMap_1; + ICorDebugInfo::OffsetMapping* map_1; - CORINFO_METHOD_HANDLE ftn_2; - ULONG32 cMap_2; - ICorDebugInfo::OffsetMapping *map_2; + CORINFO_METHOD_HANDLE ftn_2; + ULONG32 cMap_2; + ICorDebugInfo::OffsetMapping* map_2; CORINFO_METHOD_INFO info; - unsigned flags = 0; + unsigned flags = 0; mc->repCompileMethod(&info, &flags); bool set1 = cr1->repSetBoundaries(&ftn_1, &cMap_1, &map_1); bool set2 = cr2->repSetBoundaries(&ftn_2, &cMap_2, &map_2); - if((set1==false)&&(set2==false)) + if ((set1 == false) && (set2 == false)) return true; // we don't have boundaries for either of these. - if(((set1==true)&&(set2==false))||((set1==false)&&(set2==true))) + if (((set1 == true) && (set2 == false)) || ((set1 == false) && (set2 == true))) { LogVerbose("missing matching boundary sets"); return false; } - if(ftn_1!=ftn_2) + if (ftn_1 != ftn_2) { LogVerbose("compareBoundaries found non-matching CORINFO_METHOD_HANDLE %p %p", ftn_1, ftn_2); return false; } - //no maps - if(cMap_1==0 && cMap_2==0) + // no maps + if (cMap_1 == 0 && cMap_2 == 0) return true; - if(cMap_1!=cMap_2) + if (cMap_1 != cMap_2) { LogVerbose("compareBoundaries found non-matching var count %u %u", cMap_1, cMap_2); return false; } - for(unsigned int i=0;i<cMap_1;i++) + for (unsigned int i = 0; i < cMap_1; i++) { - if(map_1[i].ilOffset!=map_2[i].ilOffset) + if (map_1[i].ilOffset != map_2[i].ilOffset) { - LogVerbose("compareBoundaries found non-matching ilOffset %u %u for map: %u", map_1[i].ilOffset, map_2[i].ilOffset, i); + LogVerbose("compareBoundaries found non-matching ilOffset %u %u for map: %u", map_1[i].ilOffset, + map_2[i].ilOffset, i); return false; } - if(map_1[i].nativeOffset!=map_2[i].nativeOffset) + if (map_1[i].nativeOffset != map_2[i].nativeOffset) { - LogVerbose("compareBoundaries found non-matching nativeOffset %u %u for map: %u", map_1[i].nativeOffset, map_2[i].nativeOffset, i); + LogVerbose("compareBoundaries found non-matching nativeOffset %u %u for map: %u", map_1[i].nativeOffset, + map_2[i].nativeOffset, i); return false; } - if(map_1[i].source!=map_2[i].source) + if (map_1[i].source != map_2[i].source) { - LogVerbose("compareBoundaries found non-matching source %u %u for map: %u", (unsigned int)map_1[i].source, (unsigned int)map_2[i].source, i); + LogVerbose("compareBoundaries found non-matching source %u %u for map: %u", (unsigned int)map_1[i].source, + (unsigned int)map_2[i].source, i); return false; } } - return true; } @@ -953,45 +951,45 @@ bool NearDiffer::compareBoundaries(MethodContext *mc, CompileResult *cr1, Compil // Return Value: // True if the compile results are identical; false otherwise. // -bool NearDiffer::compare(MethodContext *mc, CompileResult *cr1, CompileResult *cr2) +bool NearDiffer::compare(MethodContext* mc, CompileResult* cr1, CompileResult* cr2) { - ULONG hotCodeSize_1; - ULONG coldCodeSize_1; - ULONG roDataSize_1; - ULONG xcptnsCount_1; + ULONG hotCodeSize_1; + ULONG coldCodeSize_1; + ULONG roDataSize_1; + ULONG xcptnsCount_1; CorJitAllocMemFlag flag_1; - unsigned char *hotCodeBlock_1; - unsigned char *coldCodeBlock_1; - unsigned char *roDataBlock_1; - void *orig_hotCodeBlock_1; - void *orig_coldCodeBlock_1; - void *orig_roDataBlock_1; - - ULONG hotCodeSize_2; - ULONG coldCodeSize_2; - ULONG roDataSize_2; - ULONG xcptnsCount_2; + unsigned char* hotCodeBlock_1; + unsigned char* coldCodeBlock_1; + unsigned char* roDataBlock_1; + void* orig_hotCodeBlock_1; + void* orig_coldCodeBlock_1; + void* orig_roDataBlock_1; + + ULONG hotCodeSize_2; + ULONG coldCodeSize_2; + ULONG roDataSize_2; + ULONG xcptnsCount_2; CorJitAllocMemFlag flag_2; - unsigned char *hotCodeBlock_2; - unsigned char *coldCodeBlock_2; - unsigned char *roDataBlock_2; - void *orig_hotCodeBlock_2; - void *orig_coldCodeBlock_2; - void *orig_roDataBlock_2; - - cr1->repAllocMem(&hotCodeSize_1, &coldCodeSize_1, &roDataSize_1, &xcptnsCount_1, &flag_1, - &hotCodeBlock_1, &coldCodeBlock_1, &roDataBlock_1, &orig_hotCodeBlock_1, &orig_coldCodeBlock_1, &orig_roDataBlock_1); - cr2->repAllocMem(&hotCodeSize_2, &coldCodeSize_2, &roDataSize_2, &xcptnsCount_2, &flag_2, - &hotCodeBlock_2, &coldCodeBlock_2, &roDataBlock_2, &orig_hotCodeBlock_2, &orig_coldCodeBlock_2, &orig_roDataBlock_2); - - LogDebug("HCS1 %d CCS1 %d RDS1 %d xcpnt1 %d flag1 %08X, HCB %p CCB %p RDB %p ohcb %p occb %p odb %p", - hotCodeSize_1, coldCodeSize_1, roDataSize_1, xcptnsCount_1, flag_1, - hotCodeBlock_1, coldCodeBlock_1, roDataBlock_1, - orig_hotCodeBlock_1, orig_coldCodeBlock_1, orig_roDataBlock_1); - LogDebug("HCS2 %d CCS2 %d RDS2 %d xcpnt2 %d flag2 %08X, HCB %p CCB %p RDB %p ohcb %p occb %p odb %p", - hotCodeSize_2, coldCodeSize_2, roDataSize_2, xcptnsCount_2, flag_2, - hotCodeBlock_2, coldCodeBlock_2, roDataBlock_2, - orig_hotCodeBlock_2, orig_coldCodeBlock_2, orig_roDataBlock_2); + unsigned char* hotCodeBlock_2; + unsigned char* coldCodeBlock_2; + unsigned char* roDataBlock_2; + void* orig_hotCodeBlock_2; + void* orig_coldCodeBlock_2; + void* orig_roDataBlock_2; + + cr1->repAllocMem(&hotCodeSize_1, &coldCodeSize_1, &roDataSize_1, &xcptnsCount_1, &flag_1, &hotCodeBlock_1, + &coldCodeBlock_1, &roDataBlock_1, &orig_hotCodeBlock_1, &orig_coldCodeBlock_1, + &orig_roDataBlock_1); + cr2->repAllocMem(&hotCodeSize_2, &coldCodeSize_2, &roDataSize_2, &xcptnsCount_2, &flag_2, &hotCodeBlock_2, + &coldCodeBlock_2, &roDataBlock_2, &orig_hotCodeBlock_2, &orig_coldCodeBlock_2, + &orig_roDataBlock_2); + + LogDebug("HCS1 %d CCS1 %d RDS1 %d xcpnt1 %d flag1 %08X, HCB %p CCB %p RDB %p ohcb %p occb %p odb %p", hotCodeSize_1, + coldCodeSize_1, roDataSize_1, xcptnsCount_1, flag_1, hotCodeBlock_1, coldCodeBlock_1, roDataBlock_1, + orig_hotCodeBlock_1, orig_coldCodeBlock_1, orig_roDataBlock_1); + LogDebug("HCS2 %d CCS2 %d RDS2 %d xcpnt2 %d flag2 %08X, HCB %p CCB %p RDB %p ohcb %p occb %p odb %p", hotCodeSize_2, + coldCodeSize_2, roDataSize_2, xcptnsCount_2, flag_2, hotCodeBlock_2, coldCodeBlock_2, roDataBlock_2, + orig_hotCodeBlock_2, orig_coldCodeBlock_2, orig_roDataBlock_2); cr1->applyRelocs(hotCodeBlock_1, hotCodeSize_1, orig_hotCodeBlock_1); cr2->applyRelocs(hotCodeBlock_2, hotCodeSize_2, orig_hotCodeBlock_2); @@ -1000,22 +998,23 @@ bool NearDiffer::compare(MethodContext *mc, CompileResult *cr1, CompileResult *c cr1->applyRelocs(roDataBlock_1, roDataSize_1, orig_roDataBlock_1); cr2->applyRelocs(roDataBlock_2, roDataSize_2, orig_roDataBlock_2); - if(!compareCodeSection(mc, cr1, cr2, - hotCodeBlock_1, hotCodeSize_1, roDataBlock_1, roDataSize_1, orig_hotCodeBlock_1, orig_roDataBlock_1, orig_coldCodeBlock_1, coldCodeSize_1, - hotCodeBlock_2, hotCodeSize_2, roDataBlock_2, roDataSize_2, orig_hotCodeBlock_2, orig_roDataBlock_2, orig_coldCodeBlock_2, coldCodeSize_2)) + if (!compareCodeSection(mc, cr1, cr2, hotCodeBlock_1, hotCodeSize_1, roDataBlock_1, roDataSize_1, + orig_hotCodeBlock_1, orig_roDataBlock_1, orig_coldCodeBlock_1, coldCodeSize_1, + hotCodeBlock_2, hotCodeSize_2, roDataBlock_2, roDataSize_2, orig_hotCodeBlock_2, + orig_roDataBlock_2, orig_coldCodeBlock_2, coldCodeSize_2)) return false; - if(!compareCodeSection(mc, cr1, cr2, - coldCodeBlock_1, coldCodeSize_1, roDataBlock_1, roDataSize_1, orig_coldCodeBlock_1, orig_roDataBlock_1, orig_hotCodeBlock_1, hotCodeSize_1, - coldCodeBlock_2, coldCodeSize_2, roDataBlock_2, roDataSize_2, orig_coldCodeBlock_2, orig_roDataBlock_2, orig_hotCodeBlock_2, hotCodeSize_2)) + if (!compareCodeSection(mc, cr1, cr2, coldCodeBlock_1, coldCodeSize_1, roDataBlock_1, roDataSize_1, + orig_coldCodeBlock_1, orig_roDataBlock_1, orig_hotCodeBlock_1, hotCodeSize_1, + coldCodeBlock_2, coldCodeSize_2, roDataBlock_2, roDataSize_2, orig_coldCodeBlock_2, + orig_roDataBlock_2, orig_hotCodeBlock_2, hotCodeSize_2)) return false; - if(!compareReadOnlyDataBlock(mc, cr1, cr2, - roDataBlock_1, roDataSize_1, orig_roDataBlock_1, - roDataBlock_2, roDataSize_2, orig_roDataBlock_2)) + if (!compareReadOnlyDataBlock(mc, cr1, cr2, roDataBlock_1, roDataSize_1, orig_roDataBlock_1, roDataBlock_2, + roDataSize_2, orig_roDataBlock_2)) return false; - if(!compareEHInfo(mc, cr1, cr2)) + if (!compareEHInfo(mc, cr1, cr2)) return false; if (!compareGCInfo(mc, cr1, cr2)) @@ -1024,7 +1023,7 @@ bool NearDiffer::compare(MethodContext *mc, CompileResult *cr1, CompileResult *c if (!compareVars(mc, cr1, cr2)) return false; - if(!compareBoundaries(mc, cr1, cr2)) + if (!compareBoundaries(mc, cr1, cr2)) return false; return true; diff --git a/src/ToolBox/superpmi/superpmi/neardiffer.h b/src/ToolBox/superpmi/superpmi/neardiffer.h index e3ffe1c790..100f87cce2 100644 --- a/src/ToolBox/superpmi/superpmi/neardiffer.h +++ b/src/ToolBox/superpmi/superpmi/neardiffer.h @@ -15,8 +15,7 @@ class NearDiffer { public: - - NearDiffer(const char *targetArch, bool useCorDisTools) + NearDiffer(const char* targetArch, bool useCorDisTools) : TargetArchitecture(targetArch) , UseCoreDisTools(useCorDisTools) #ifdef USE_COREDISTOOLS @@ -29,58 +28,58 @@ public: void InitAsmDiff(); - bool compare(MethodContext *mc, CompileResult *cr1,CompileResult *cr2); + bool compare(MethodContext* mc, CompileResult* cr1, CompileResult* cr2); const char* TargetArchitecture; - const bool UseCoreDisTools; + const bool UseCoreDisTools; private: - - void DumpCodeBlock(unsigned char *block, ULONG blocksize, void *originalAddr); - - bool compareCodeSection( - MethodContext *mc, - CompileResult *cr1, - CompileResult *cr2, - unsigned char *block1, - ULONG blocksize1, - unsigned char *datablock1, - ULONG datablockSize1, - void *originalBlock1, - void *originalDataBlock1, - void *otherCodeBlock1, - ULONG otherCodeBlockSize1, - unsigned char *block2, - ULONG blocksize2, - unsigned char *datablock2, - ULONG datablockSize2, - void *originalBlock2, - void *originalDataBlock2, - void *otherCodeBlock2, - ULONG otherCodeBlockSize2); - - bool compareReadOnlyDataBlock(MethodContext *mc, CompileResult *cr1, CompileResult *cr2, - unsigned char *block1, ULONG blocksize1, void *originalDataBlock1, - unsigned char *block2, ULONG blocksize2, void *originalDataBlock2); - bool compareEHInfo(MethodContext *mc, CompileResult *cr1, CompileResult *cr2); - bool compareGCInfo(MethodContext *mc, CompileResult *cr1, CompileResult *cr2); - bool compareVars(MethodContext *mc, CompileResult *cr1, CompileResult *cr2); - bool compareBoundaries(MethodContext *mc, CompileResult *cr1, CompileResult *cr2); - - static bool compareOffsets(const void *payload, - size_t blockOffset, - size_t instrLen, - uint64_t offset1, - uint64_t offset2); + void DumpCodeBlock(unsigned char* block, ULONG blocksize, void* originalAddr); + + bool compareCodeSection(MethodContext* mc, + CompileResult* cr1, + CompileResult* cr2, + unsigned char* block1, + ULONG blocksize1, + unsigned char* datablock1, + ULONG datablockSize1, + void* originalBlock1, + void* originalDataBlock1, + void* otherCodeBlock1, + ULONG otherCodeBlockSize1, + unsigned char* block2, + ULONG blocksize2, + unsigned char* datablock2, + ULONG datablockSize2, + void* originalBlock2, + void* originalDataBlock2, + void* otherCodeBlock2, + ULONG otherCodeBlockSize2); + + bool compareReadOnlyDataBlock(MethodContext* mc, + CompileResult* cr1, + CompileResult* cr2, + unsigned char* block1, + ULONG blocksize1, + void* originalDataBlock1, + unsigned char* block2, + ULONG blocksize2, + void* originalDataBlock2); + bool compareEHInfo(MethodContext* mc, CompileResult* cr1, CompileResult* cr2); + bool compareGCInfo(MethodContext* mc, CompileResult* cr1, CompileResult* cr2); + bool compareVars(MethodContext* mc, CompileResult* cr1, CompileResult* cr2); + bool compareBoundaries(MethodContext* mc, CompileResult* cr1, CompileResult* cr2); + + static bool compareOffsets( + const void* payload, size_t blockOffset, size_t instrLen, uint64_t offset1, uint64_t offset2); #ifdef USE_COREDISTOOLS - CorAsmDiff *corAsmDiff; + CorAsmDiff* corAsmDiff; #endif // USE_COREDISTOOLS #ifdef USE_MSVCDIS DIS* GetMsVcDis(); #endif // USE_MSVCDIS - }; #endif // _nearDiffer diff --git a/src/ToolBox/superpmi/superpmi/parallelsuperpmi.cpp b/src/ToolBox/superpmi/superpmi/parallelsuperpmi.cpp index 301db3cfe9..0f2d31d3e5 100644 --- a/src/ToolBox/superpmi/superpmi/parallelsuperpmi.cpp +++ b/src/ToolBox/superpmi/superpmi/parallelsuperpmi.cpp @@ -10,20 +10,20 @@ #include "commandline.h" #include "errorhandling.h" -#define MAX_LOG_LINE_SIZE 0x1000 //4 KB +#define MAX_LOG_LINE_SIZE 0x1000 // 4 KB bool closeRequested = false; // global variable to communicate CTRL+C between threads. -bool StartProcess(char *commandLine, HANDLE hStdOutput, HANDLE hStdError, HANDLE *hProcess) +bool StartProcess(char* commandLine, HANDLE hStdOutput, HANDLE hStdError, HANDLE* hProcess) { LogDebug("StartProcess commandLine=%s", commandLine); - STARTUPINFO si; + STARTUPINFO si; PROCESS_INFORMATION pi; ZeroMemory(&si, sizeof(si)); - si.cb = sizeof(si); - si.dwFlags = STARTF_USESTDHANDLES; + si.cb = sizeof(si); + si.dwFlags = STARTF_USESTDHANDLES; si.hStdInput = GetStdHandle(STD_INPUT_HANDLE); si.hStdOutput = hStdOutput; si.hStdError = hStdError; @@ -31,16 +31,16 @@ bool StartProcess(char *commandLine, HANDLE hStdOutput, HANDLE hStdError, HANDLE ZeroMemory(&pi, sizeof(pi)); // Start the child process. - if (!CreateProcess(NULL, // No module name (use command line) - commandLine, // Command line - NULL, // Process handle not inheritable - NULL, // Thread handle not inheritable - TRUE, // Set handle inheritance to TRUE (required to use STARTF_USESTDHANDLES) - 0, // No creation flags - NULL, // Use parent's environment block - NULL, // Use parent's starting directory - &si, // Pointer to STARTUPINFO structure - &pi)) // Pointer to PROCESS_INFORMATION structure + if (!CreateProcess(NULL, // No module name (use command line) + commandLine, // Command line + NULL, // Process handle not inheritable + NULL, // Thread handle not inheritable + TRUE, // Set handle inheritance to TRUE (required to use STARTF_USESTDHANDLES) + 0, // No creation flags + NULL, // Use parent's environment block + NULL, // Use parent's starting directory + &si, // Pointer to STARTUPINFO structure + &pi)) // Pointer to PROCESS_INFORMATION structure { LogError("CreateProcess failed (%d). CommandLine: %s", GetLastError(), commandLine); *hProcess = INVALID_HANDLE_VALUE; @@ -51,13 +51,14 @@ bool StartProcess(char *commandLine, HANDLE hStdOutput, HANDLE hStdError, HANDLE return true; } -void ReadMCLToArray(char *mclFilename, int **arr, int *count) +void ReadMCLToArray(char* mclFilename, int** arr, int* count) { - *count = 0; - *arr = nullptr; + *count = 0; + *arr = nullptr; char* buff = nullptr; - HANDLE hFile = CreateFileA(mclFilename, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL); + HANDLE hFile = CreateFileA(mclFilename, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, + FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL); if (hFile == INVALID_HANDLE_VALUE) { @@ -99,14 +100,14 @@ void ReadMCLToArray(char *mclFilename, int **arr, int *count) return; *arr = new int[*count]; - for (int j = 0, arrIndex = 0; j < sz; ) + for (int j = 0, arrIndex = 0; j < sz;) { - //seek the first number on the line + // seek the first number on the line while (!isdigit((unsigned char)buff[j])) j++; - //read in the number + // read in the number (*arr)[arrIndex++] = atoi(&buff[j]); - //seek to the start of next line + // seek to the start of next line while ((j < sz) && (buff[j] != 0x0a)) j++; j++; @@ -120,9 +121,10 @@ Cleanup: CloseHandle(hFile); } -bool WriteArrayToMCL(char *mclFilename, int *arr, int count) +bool WriteArrayToMCL(char* mclFilename, int* arr, int count) { - HANDLE hMCLFile = CreateFileA(mclFilename, GENERIC_WRITE, FILE_SHARE_WRITE, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + HANDLE hMCLFile = + CreateFileA(mclFilename, GENERIC_WRITE, FILE_SHARE_WRITE, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); bool result = true; if (hMCLFile == INVALID_HANDLE_VALUE) @@ -134,8 +136,8 @@ bool WriteArrayToMCL(char *mclFilename, int *arr, int count) for (int i = 0; i < count; i++) { - char strMethodIndex[12]; - DWORD charCount = 0; + char strMethodIndex[12]; + DWORD charCount = 0; DWORD bytesWritten = 0; charCount = sprintf_s(strMethodIndex, sizeof(strMethodIndex), "%d\r\n", arr[i]); @@ -155,11 +157,11 @@ Cleanup: return result; } -void ProcessChildStdErr(char *stderrFilename) +void ProcessChildStdErr(char* stderrFilename) { char buff[MAX_LOG_LINE_SIZE]; - FILE *fp = fopen(stderrFilename, "r"); + FILE* fp = fopen(stderrFilename, "r"); if (fp == NULL) { @@ -169,17 +171,17 @@ void ProcessChildStdErr(char *stderrFilename) while (fgets(buff, MAX_LOG_LINE_SIZE, fp) != NULL) { - //get rid of the '\n' at the end of line + // get rid of the '\n' at the end of line size_t buffLen = strlen(buff); if (buff[buffLen - 1] == '\n') buff[buffLen - 1] = 0; if (strncmp(buff, "ERROR: ", 7) == 0) - LogError("%s", &buff[7]); //log as Error and remove the "ERROR: " in front + LogError("%s", &buff[7]); // log as Error and remove the "ERROR: " in front else if (strncmp(buff, "WARNING: ", 9) == 0) - LogWarning("%s", &buff[9]); //log as Warning and remove the "WARNING: " in front + LogWarning("%s", &buff[9]); // log as Warning and remove the "WARNING: " in front else if (strlen(buff) > 0) - LogWarning("%s", buff); //unknown output, log it as a warning + LogWarning("%s", buff); // unknown output, log it as a warning } Cleanup: @@ -187,11 +189,17 @@ Cleanup: fclose(fp); } -void ProcessChildStdOut(const CommandLine::Options& o, char *stdoutFilename, int *loaded, int *jitted, int *failed, int *diffs, bool *usageError) +void ProcessChildStdOut(const CommandLine::Options& o, + char* stdoutFilename, + int* loaded, + int* jitted, + int* failed, + int* diffs, + bool* usageError) { char buff[MAX_LOG_LINE_SIZE]; - FILE *fp = fopen(stdoutFilename, "r"); + FILE* fp = fopen(stdoutFilename, "r"); if (fp == NULL) { @@ -201,25 +209,25 @@ void ProcessChildStdOut(const CommandLine::Options& o, char *stdoutFilename, int while (fgets(buff, MAX_LOG_LINE_SIZE, fp) != NULL) { - //get rid of the '\n' at the end of line + // get rid of the '\n' at the end of line size_t buffLen = strlen(buff); if (buff[buffLen - 1] == '\n') buff[buffLen - 1] = 0; if (strncmp(buff, "MISSING: ", 9) == 0) - LogMissing("%s", &buff[9]); //log as Missing and remove the "MISSING: " in front + LogMissing("%s", &buff[9]); // log as Missing and remove the "MISSING: " in front else if (strncmp(buff, "ISSUE: ", 7) == 0) { if (strncmp(&buff[7], "<ASM_DIFF> ", 11) == 0) - LogIssue(ISSUE_ASM_DIFF, "%s", &buff[18]); //log as Issue and remove the "ISSUE: <ASM_DIFF>" in front + LogIssue(ISSUE_ASM_DIFF, "%s", &buff[18]); // log as Issue and remove the "ISSUE: <ASM_DIFF>" in front else if (strncmp(&buff[7], "<ASSERT> ", 9) == 0) - LogIssue(ISSUE_ASSERT, "%s", &buff[16]); //log as Issue and remove the "ISSUE: <ASSERT>" in front + LogIssue(ISSUE_ASSERT, "%s", &buff[16]); // log as Issue and remove the "ISSUE: <ASSERT>" in front } else if (strncmp(buff, g_SuperPMIUsageFirstLine, strlen(g_SuperPMIUsageFirstLine)) == 0) { - *usageError = true; //Signals that we had a SuperPMI command line usage error + *usageError = true; // Signals that we had a SuperPMI command line usage error - //Read the entire stdout file and printf it + // Read the entire stdout file and printf it printf("%s", buff); while (fgets(buff, MAX_LOG_LINE_SIZE, fp) != NULL) { @@ -272,61 +280,74 @@ Cleanup: #ifndef FEATURE_PAL // TODO-Porting: handle Ctrl-C signals gracefully on Unix BOOL WINAPI CtrlHandler(DWORD fdwCtrlType) { - //Since the child SuperPMI.exe processes share the same console - //We don't need to kill them individually as they also receive the Ctrl-C + // Since the child SuperPMI.exe processes share the same console + //We don't need to kill them individually as they also receive the Ctrl-C - closeRequested = true; //set a flag to indicate we need to quit + closeRequested = true; // set a flag to indicate we need to quit return TRUE; } #endif // !FEATURE_PAL -int __cdecl compareInt(const void *arg1, const void *arg2) +int __cdecl compareInt(const void* arg1, const void* arg2) { - return (*(const int *)arg1) - (*(const int *)arg2); + return (*(const int*)arg1) - (*(const int*)arg2); } // 'arrWorkerMCLPath' is an array of strings of size 'workerCount'. -void MergeWorkerMCLs(char *mclFilename, char **arrWorkerMCLPath, int workerCount) +void MergeWorkerMCLs(char* mclFilename, char** arrWorkerMCLPath, int workerCount) { - int **MCL = new int*[workerCount], *MCLCount = new int[workerCount], totalCount = 0; + int **MCL = new int *[workerCount], *MCLCount = new int[workerCount], totalCount = 0; for (int i = 0; i < workerCount; i++) { - //Read the next partial MCL file + // Read the next partial MCL file ReadMCLToArray(arrWorkerMCLPath[i], &MCL[i], &MCLCount[i]); totalCount += MCLCount[i]; } - int *mergedMCL = new int[totalCount]; - int index = 0; + int* mergedMCL = new int[totalCount]; + int index = 0; for (int i = 0; i < workerCount; i++) { - for (int j = 0; j < MCLCount[i]; j++) + for (int j = 0; j < MCLCount[i]; j++) mergedMCL[index++] = MCL[i][j]; } qsort(mergedMCL, totalCount, sizeof(int), compareInt); - //Write the merged MCL array back to disk + // Write the merged MCL array back to disk if (!WriteArrayToMCL(mclFilename, mergedMCL, totalCount)) LogError("Unable to write to MCL file %s.", mclFilename); } // From the arguments that we parsed, construct the arguments to pass to the child processes. -#define MAX_CMDLINE_SIZE 0x1000 //4 KB +#define MAX_CMDLINE_SIZE 0x1000 // 4 KB char* ConstructChildProcessArgs(const CommandLine::Options& o) { - int bytesWritten = 0; - char* spmiArgs = new char[MAX_CMDLINE_SIZE]; - *spmiArgs = '\0'; + int bytesWritten = 0; + char* spmiArgs = new char[MAX_CMDLINE_SIZE]; + *spmiArgs = '\0'; - // We don't pass through /parallel, /skipCleanup, /verbosity, /failingMCList, or /diffMCList. Everything else we need to reconstruct and pass through. +// We don't pass through /parallel, /skipCleanup, /verbosity, /failingMCList, or /diffMCList. Everything else we need to +// reconstruct and pass through. -#define ADDSTRING(s) if (s != nullptr) { bytesWritten += sprintf_s(spmiArgs + bytesWritten, MAX_CMDLINE_SIZE - bytesWritten, " %s", s); } -#define ADDARG_BOOL(b,arg) if (b) { bytesWritten += sprintf_s(spmiArgs + bytesWritten, MAX_CMDLINE_SIZE - bytesWritten, " %s", arg); } -#define ADDARG_STRING(s,arg) if (s != nullptr) { bytesWritten += sprintf_s(spmiArgs + bytesWritten, MAX_CMDLINE_SIZE - bytesWritten, " %s %s", arg, s); } +#define ADDSTRING(s) \ + if (s != nullptr) \ + { \ + bytesWritten += sprintf_s(spmiArgs + bytesWritten, MAX_CMDLINE_SIZE - bytesWritten, " %s", s); \ + } +#define ADDARG_BOOL(b, arg) \ + if (b) \ + { \ + bytesWritten += sprintf_s(spmiArgs + bytesWritten, MAX_CMDLINE_SIZE - bytesWritten, " %s", arg); \ + } +#define ADDARG_STRING(s, arg) \ + if (s != nullptr) \ + { \ + bytesWritten += sprintf_s(spmiArgs + bytesWritten, MAX_CMDLINE_SIZE - bytesWritten, " %s %s", arg, s); \ + } ADDARG_BOOL(o.breakOnError, "-boe"); ADDARG_BOOL(o.breakOnAssert, "-boa"); @@ -352,12 +373,12 @@ char* ConstructChildProcessArgs(const CommandLine::Options& o) int doParallelSuperPMI(CommandLine::Options& o) { - HRESULT hr = E_FAIL; + HRESULT hr = E_FAIL; SimpleTimer st; st.Start(); #ifndef FEATURE_PAL // TODO-Porting: handle Ctrl-C signals gracefully on Unix - //Register a ConsoleCtrlHandler + // Register a ConsoleCtrlHandler if (!SetConsoleCtrlHandler(CtrlHandler, TRUE)) { LogError("Failed to set control handler."); @@ -374,14 +395,14 @@ int doParallelSuperPMI(CommandLine::Options& o) if (o.workerCount <= 0) { - //Use the default value which is the number of processors on the machine. + // Use the default value which is the number of processors on the machine. SYSTEM_INFO sysinfo; GetSystemInfo(&sysinfo); o.workerCount = sysinfo.dwNumberOfProcessors; - //If we ever execute on a machine which has more than MAXIMUM_WAIT_OBJECTS(64) CPU cores - //we still can't spawn more than the max supported by WaitForMultipleObjects() + // If we ever execute on a machine which has more than MAXIMUM_WAIT_OBJECTS(64) CPU cores + //we still can't spawn more than the max supported by WaitForMultipleObjects() if (o.workerCount > MAXIMUM_WAIT_OBJECTS) o.workerCount = MAXIMUM_WAIT_OBJECTS; } @@ -404,9 +425,9 @@ int doParallelSuperPMI(CommandLine::Options& o) LogVerbose(" diffMCLFilename=%s", o.diffMCLFilename); LogVerbose(" workerCount=%d, skipCleanup=%d.", o.workerCount, o.skipCleanup); - HANDLE *hProcesses = new HANDLE[o.workerCount]; - HANDLE *hStdOutput = new HANDLE[o.workerCount]; - HANDLE *hStdError = new HANDLE[o.workerCount]; + HANDLE* hProcesses = new HANDLE[o.workerCount]; + HANDLE* hStdOutput = new HANDLE[o.workerCount]; + HANDLE* hStdError = new HANDLE[o.workerCount]; char** arrFailingMCListPath = new char*[o.workerCount]; char** arrDiffMCListPath = new char*[o.workerCount]; @@ -417,7 +438,7 @@ int doParallelSuperPMI(CommandLine::Options& o) unsigned int randNumber = 0; #ifdef FEATURE_PAL PAL_Random(/* bStrong */ FALSE, &randNumber, sizeof(randNumber)); -#else // !FEATURE_PAL +#else // !FEATURE_PAL rand_s(&randNumber); #endif // !FEATURE_PAL @@ -447,7 +468,7 @@ int doParallelSuperPMI(CommandLine::Options& o) arrStdErrorPath[i] = new char[MAX_PATH]; sprintf_s(arrStdOutputPath[i], MAX_PATH, "%sParallelSuperPMI-stdout-%u-%d.txt", tempPath, randNumber, i); - sprintf_s(arrStdErrorPath[i], MAX_PATH, "%sParallelSuperPMI-stderr-%u-%d.txt", tempPath, randNumber, i); + sprintf_s(arrStdErrorPath[i], MAX_PATH, "%sParallelSuperPMI-stderr-%u-%d.txt", tempPath, randNumber, i); } char cmdLine[MAX_CMDLINE_SIZE]; @@ -460,23 +481,26 @@ int doParallelSuperPMI(CommandLine::Options& o) if (o.mclFilename != nullptr) { - bytesWritten += sprintf_s(cmdLine + bytesWritten, MAX_CMDLINE_SIZE - bytesWritten, " -failingMCList %s", arrFailingMCListPath[i]); + bytesWritten += sprintf_s(cmdLine + bytesWritten, MAX_CMDLINE_SIZE - bytesWritten, " -failingMCList %s", + arrFailingMCListPath[i]); } if (o.diffMCLFilename != nullptr) { - bytesWritten += sprintf_s(cmdLine + bytesWritten, MAX_CMDLINE_SIZE - bytesWritten, " -diffMCList %s", arrDiffMCListPath[i]); + bytesWritten += sprintf_s(cmdLine + bytesWritten, MAX_CMDLINE_SIZE - bytesWritten, " -diffMCList %s", + arrDiffMCListPath[i]); } bytesWritten += sprintf_s(cmdLine + bytesWritten, MAX_CMDLINE_SIZE - bytesWritten, " -v ewmin %s", spmiArgs); SECURITY_ATTRIBUTES sa; - sa.nLength = sizeof(sa); + sa.nLength = sizeof(sa); sa.lpSecurityDescriptor = NULL; - sa.bInheritHandle = TRUE; // Let newly created stdout/stderr handles be inherited. + sa.bInheritHandle = TRUE; // Let newly created stdout/stderr handles be inherited. LogDebug("stdout %i=%s", i, arrStdOutputPath[i]); - hStdOutput[i] = CreateFileA(arrStdOutputPath[i], GENERIC_WRITE, FILE_SHARE_READ, &sa, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + hStdOutput[i] = CreateFileA(arrStdOutputPath[i], GENERIC_WRITE, FILE_SHARE_READ, &sa, CREATE_ALWAYS, + FILE_ATTRIBUTE_NORMAL, NULL); if (hStdOutput[i] == INVALID_HANDLE_VALUE) { LogError("Unable to open '%s'. GetLastError()=%u", arrStdOutputPath[i], GetLastError()); @@ -484,14 +508,15 @@ int doParallelSuperPMI(CommandLine::Options& o) } LogDebug("stderr %i=%s", i, arrStdErrorPath[i]); - hStdError[i] = CreateFileA(arrStdErrorPath[i], GENERIC_WRITE, FILE_SHARE_READ, &sa, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + hStdError[i] = CreateFileA(arrStdErrorPath[i], GENERIC_WRITE, FILE_SHARE_READ, &sa, CREATE_ALWAYS, + FILE_ATTRIBUTE_NORMAL, NULL); if (hStdError[i] == INVALID_HANDLE_VALUE) { LogError("Unable to open '%s'. GetLastError()=%u", arrStdErrorPath[i], GetLastError()); return -1; } - //Create a SuperPMI worker process and redirect its output to file + // Create a SuperPMI worker process and redirect its output to file if (!StartProcess(cmdLine, hStdOutput[i], hStdError[i], &hProcesses[i])) { return -1; @@ -516,19 +541,19 @@ int doParallelSuperPMI(CommandLine::Options& o) for (int i = 0; i < o.workerCount; i++) { DWORD exitCodeTmp; - BOOL ok = GetExitCodeProcess(hProcesses[i], &exitCodeTmp); + BOOL ok = GetExitCodeProcess(hProcesses[i], &exitCodeTmp); if (ok && (exitCodeTmp > exitCode)) { exitCode = exitCodeTmp; } } - bool usageError = false; //variable to flag if we hit a usage error in SuperPMI + bool usageError = false; // variable to flag if we hit a usage error in SuperPMI int loaded = 0, jitted = 0, failed = 0, diffs = 0; - //Read the stderr files and log them as errors - //Read the stdout files and parse them for counts and log any MISSING or ISSUE errors + // Read the stderr files and log them as errors + //Read the stdout files and parse them for counts and log any MISSING or ISSUE errors for (int i = 0; i < o.workerCount; i++) { ProcessChildStdErr(arrStdErrorPath[i]); @@ -539,13 +564,13 @@ int doParallelSuperPMI(CommandLine::Options& o) if (o.mclFilename != nullptr && !usageError) { - //Concat the resulting .mcl files + // Concat the resulting .mcl files MergeWorkerMCLs(o.mclFilename, arrFailingMCListPath, o.workerCount); } if (o.diffMCLFilename != nullptr && !usageError) { - //Concat the resulting diff .mcl files + // Concat the resulting diff .mcl files MergeWorkerMCLs(o.diffMCLFilename, arrDiffMCListPath, o.workerCount); } diff --git a/src/ToolBox/superpmi/superpmi/superpmi.cpp b/src/ToolBox/superpmi/superpmi/superpmi.cpp index 980792d4a9..c1225e419e 100644 --- a/src/ToolBox/superpmi/superpmi/superpmi.cpp +++ b/src/ToolBox/superpmi/superpmi/superpmi.cpp @@ -52,37 +52,35 @@ void SetSuperPmiTargetArchitecture(const char* targetArchitecture) // This function uses PAL_TRY, so it can't be in the a function that requires object unwinding. Extracting it out here // avoids compiler error. -// -void InvokeNearDiffer( - NearDiffer* nearDiffer, - CommandLine::Options* o, - MethodContext** mc, - CompileResult** crl, - int* matchCount, - MethodContextReader** reader, - MCList* failingMCL, - MCList* diffMCL - ) +// +void InvokeNearDiffer(NearDiffer* nearDiffer, + CommandLine::Options* o, + MethodContext** mc, + CompileResult** crl, + int* matchCount, + MethodContextReader** reader, + MCList* failingMCL, + MCList* diffMCL) { struct Param : FilterSuperPMIExceptionsParam_CaptureException { - NearDiffer* nearDiffer; - CommandLine::Options* o; - MethodContext** mc; - CompileResult** crl; - int* matchCount; - MethodContextReader** reader; - MCList* failingMCL; - MCList* diffMCL; + NearDiffer* nearDiffer; + CommandLine::Options* o; + MethodContext** mc; + CompileResult** crl; + int* matchCount; + MethodContextReader** reader; + MCList* failingMCL; + MCList* diffMCL; } param; param.nearDiffer = nearDiffer; - param.o = o; - param.mc = mc; - param.crl = crl; + param.o = o; + param.mc = mc; + param.crl = crl; param.matchCount = matchCount; - param.reader = reader; + param.reader = reader; param.failingMCL = failingMCL; - param.diffMCL = diffMCL; + param.diffMCL = diffMCL; PAL_TRY(Param*, pParam, ¶m) { @@ -92,12 +90,12 @@ void InvokeNearDiffer( } else { - LogIssue(ISSUE_ASM_DIFF, - "main method %d of size %d differs", (*pParam->reader)->GetMethodContextIndex(), (*pParam->mc)->methodSize); + LogIssue(ISSUE_ASM_DIFF, "main method %d of size %d differs", (*pParam->reader)->GetMethodContextIndex(), + (*pParam->mc)->methodSize); - //This is a difference in ASM outputs from Jit1 & Jit2 and not a playback failure - //We will add this MC to the diffMCList if one is requested - //Otherwise this will end up in failingMCList + // This is a difference in ASM outputs from Jit1 & Jit2 and not a playback failure + //We will add this MC to the diffMCList if one is requested + //Otherwise this will end up in failingMCList if ((*pParam->o).diffMCLFilename != nullptr) (*pParam->diffMCL).AddMethodToMCL((*pParam->reader)->GetMethodContextIndex()); else if ((*pParam->o).mclFilename != nullptr) @@ -109,7 +107,7 @@ void InvokeNearDiffer( SpmiException e(¶m.exceptionPointers); LogError("main method %d of size %d failed to load and compile correctly. EnvCnt=%d", - (*reader)->GetMethodContextIndex(), (*mc)->methodSize, (*mc)->repEnvironmentGetCount()); + (*reader)->GetMethodContextIndex(), (*mc)->methodSize, (*mc)->repEnvironmentGetCount()); e.ShowAndDeleteMessage(); if ((*o).mclFilename != nullptr) (*failingMCL).AddMethodToMCL((*reader)->GetMethodContextIndex()); @@ -141,13 +139,13 @@ int __cdecl main(int argc, char* argv[]) SimpleTimer st4; st2.Start(); JitInstance::Result res, res2; - HRESULT hr = E_FAIL; - MethodContext *mc = nullptr; - JitInstance *jit = nullptr, *jit2 = nullptr; - MethodStatsEmitter *methodStatsEmitter = nullptr; + HRESULT hr = E_FAIL; + MethodContext* mc = nullptr; + JitInstance * jit = nullptr, *jit2 = nullptr; + MethodStatsEmitter* methodStatsEmitter = nullptr; #ifdef SuperPMI_ChewMemory - //Chew up the base 2gb of memory on x86... helpful in finding any places where classhandles etc are de-ref'd + // Chew up the base 2gb of memory on x86... helpful in finding any places where classhandles etc are de-ref'd SYSTEM_INFO sSysInfo; GetSystemInfo(&sSysInfo); @@ -159,7 +157,7 @@ int __cdecl main(int argc, char* argv[]) } while ((size_t)lpvAddr < SuperPMI_ChewMemory); #endif - bool collectThroughput = false; + bool collectThroughput = false; MCList failingMCL, diffMCL; CommandLine::Options o; @@ -175,7 +173,9 @@ int __cdecl main(int argc, char* argv[]) SetSuperPmiTargetArchitecture(o.targetArchitecture); - if (o.methodStatsTypes != NULL && (strchr(o.methodStatsTypes, '*') != NULL || strchr(o.methodStatsTypes, 't') != NULL || strchr(o.methodStatsTypes, 'T') != NULL)) + if (o.methodStatsTypes != NULL && + (strchr(o.methodStatsTypes, '*') != NULL || strchr(o.methodStatsTypes, 't') != NULL || + strchr(o.methodStatsTypes, 'T') != NULL)) { collectThroughput = true; } @@ -222,7 +222,8 @@ int __cdecl main(int argc, char* argv[]) // The method context reader handles skipping any unrequested method contexts // Used in conjunction with an MCI file, it does a lot less work... - MethodContextReader *reader = new MethodContextReader(o.nameOfInputMethodContextFile, o.indexes, o.indexCount, o.hash, o.offset, o.increment); + MethodContextReader* reader = + new MethodContextReader(o.nameOfInputMethodContextFile, o.indexes, o.indexCount, o.hash, o.offset, o.increment); if (!reader->isValid()) { return -1; @@ -230,13 +231,13 @@ int __cdecl main(int argc, char* argv[]) int loadedCount = 0; int jittedCount = 0; - int matchCount = 0; - int failCount = 0; - int index = 0; + int matchCount = 0; + int failCount = 0; + int index = 0; st1.Start(); NearDiffer nearDiffer(o.targetArchitecture, o.useCoreDisTools); - + if (o.applyDiff) { nearDiffer.InitAsmDiff(); @@ -260,21 +261,14 @@ int __cdecl main(int argc, char* argv[]) if (o.applyDiff) { LogVerbose(" %2.1f%% - Loaded %d Jitted %d Matching %d FailedCompile %d at %d per second", - reader->PercentComplete(), - loadedCount, - jittedCount, - matchCount, - failCount, - (int)((double)500 / st1.GetSeconds())); + reader->PercentComplete(), loadedCount, jittedCount, matchCount, failCount, + (int)((double)500 / st1.GetSeconds())); } else { LogVerbose(" %2.1f%% - Loaded %d Jitted %d FailedCompile %d at %d per second", - reader->PercentComplete(), - loadedCount, - jittedCount, - failCount, - (int)((double)500 / st1.GetSeconds())); + reader->PercentComplete(), loadedCount, jittedCount, failCount, + (int)((double)500 / st1.GetSeconds())); } st1.Start(); } @@ -311,9 +305,9 @@ int __cdecl main(int argc, char* argv[]) // Here is my guess based on reading the code so far // crl initially contains the CompileResult from the MCH file // However if we have a second jit it has the CompileResult from Jit1 - CompileResult *crl = mc->cr; + CompileResult* crl = mc->cr; - mc->cr = new CompileResult(); + mc->cr = new CompileResult(); mc->originalCR = crl; jittedCount++; @@ -332,13 +326,14 @@ int __cdecl main(int argc, char* argv[]) // Lets get the results for the 2nd JIT // We will save the first JIT's CR to save space for the 2nd JIT CR // Note that the recorded CR is still stored in MC->originalCR - crl = mc->cr; + crl = mc->cr; mc->cr = new CompileResult(); st4.Start(); res2 = jit2->CompileMethod(mc, reader->GetMethodContextIndex(), collectThroughput); st4.Stop(); - LogDebug("Method %d compiled by JIT2 in %fms, result %d", reader->GetMethodContextIndex(), st4.GetMilliseconds(), res2); + LogDebug("Method %d compiled by JIT2 in %fms, result %d", reader->GetMethodContextIndex(), + st4.GetMilliseconds(), res2); if ((res2 == JitInstance::RESULT_SUCCESS) && Logger::IsLogLevelEnabled(LOGLEVEL_DEBUG)) { @@ -348,14 +343,13 @@ int __cdecl main(int argc, char* argv[]) if (res2 == JitInstance::RESULT_ERROR) { LogError("JIT2 main method %d of size %d failed to load and compile correctly. EnvCnt=%d", - reader->GetMethodContextIndex(), mc->methodSize, mc->repEnvironmentGetCount()); + reader->GetMethodContextIndex(), mc->methodSize, mc->repEnvironmentGetCount()); } // Methods that don't compile due to missing JIT-EE information // should still be added to the failing MC list. // However, we will not add this MC# if JIT1 also failed, Else there will be duplicate logging - if ((res == JitInstance::RESULT_SUCCESS) && - (res2 != JitInstance::RESULT_SUCCESS) && + if ((res == JitInstance::RESULT_SUCCESS) && (res2 != JitInstance::RESULT_SUCCESS) && (o.mclFilename != nullptr)) { failingMCL.AddMethodToMCL(reader->GetMethodContextIndex()); @@ -368,7 +362,7 @@ int __cdecl main(int argc, char* argv[]) { if (o.nameOfJit2 != nullptr && res2 == JitInstance::RESULT_SUCCESS) { - //TODO-Bug?: bug in getting the lowest cycle time?? + // TODO-Bug?: bug in getting the lowest cycle time?? ULONGLONG dif1, dif2, dif3, dif4; dif1 = (jit->times[0] - jit2->times[0]) * (jit->times[0] - jit2->times[0]); dif2 = (jit->times[0] - jit2->times[1]) * (jit->times[0] - jit2->times[1]); @@ -381,12 +375,12 @@ int __cdecl main(int argc, char* argv[]) { if (dif1 < dif3) { - crl->clockCyclesToCompile = jit->times[0]; + crl->clockCyclesToCompile = jit->times[0]; mc->cr->clockCyclesToCompile = jit2->times[0]; } else { - crl->clockCyclesToCompile = jit->times[1]; + crl->clockCyclesToCompile = jit->times[1]; mc->cr->clockCyclesToCompile = jit2->times[0]; } } @@ -394,12 +388,12 @@ int __cdecl main(int argc, char* argv[]) { if (dif1 < dif4) { - crl->clockCyclesToCompile = jit->times[0]; + crl->clockCyclesToCompile = jit->times[0]; mc->cr->clockCyclesToCompile = jit2->times[0]; } else { - crl->clockCyclesToCompile = jit->times[1]; + crl->clockCyclesToCompile = jit->times[1]; mc->cr->clockCyclesToCompile = jit2->times[1]; } } @@ -410,12 +404,12 @@ int __cdecl main(int argc, char* argv[]) { if (dif2 < dif3) { - crl->clockCyclesToCompile = jit->times[0]; + crl->clockCyclesToCompile = jit->times[0]; mc->cr->clockCyclesToCompile = jit2->times[1]; } else { - crl->clockCyclesToCompile = jit->times[1]; + crl->clockCyclesToCompile = jit->times[1]; mc->cr->clockCyclesToCompile = jit2->times[0]; } } @@ -423,12 +417,12 @@ int __cdecl main(int argc, char* argv[]) { if (dif2 < dif4) { - crl->clockCyclesToCompile = jit->times[0]; + crl->clockCyclesToCompile = jit->times[0]; mc->cr->clockCyclesToCompile = jit2->times[1]; } else { - crl->clockCyclesToCompile = jit->times[1]; + crl->clockCyclesToCompile = jit->times[1]; mc->cr->clockCyclesToCompile = jit2->times[1]; } } @@ -436,7 +430,8 @@ int __cdecl main(int argc, char* argv[]) if (methodStatsEmitter != nullptr) { - methodStatsEmitter->Emit(reader->GetMethodContextIndex(), mc, crl->clockCyclesToCompile, mc->cr->clockCyclesToCompile); + methodStatsEmitter->Emit(reader->GetMethodContextIndex(), mc, crl->clockCyclesToCompile, + mc->cr->clockCyclesToCompile); } } else @@ -454,7 +449,7 @@ int __cdecl main(int argc, char* argv[]) if (!collectThroughput && methodStatsEmitter != nullptr) { - //We have a separate call to Emit for collectThroughput + // We have a separate call to Emit for collectThroughput methodStatsEmitter->Emit(reader->GetMethodContextIndex(), mc, -1, -1); } @@ -466,7 +461,8 @@ int __cdecl main(int argc, char* argv[]) // We need to check both CompileResults to ensure we have a valid CR if (crl->AllocMem == nullptr || mc->cr->AllocMem == nullptr) { - LogError("method %d is missing a compileResult, cannot do diffing", reader->GetMethodContextIndex()); + LogError("method %d is missing a compileResult, cannot do diffing", + reader->GetMethodContextIndex()); // If we are here this means that either we have 2 Jits and the second Jit failed to compile // Or we have single Jit and the MethodContext doesn't have an originalCR @@ -489,12 +485,14 @@ int __cdecl main(int argc, char* argv[]) // to, for instance, failures caused by missing JIT-EE details). if (res == JitInstance::RESULT_ERROR) { - LogError("main method %d of size %d failed to load and compile correctly. EnvCnt=%d", reader->GetMethodContextIndex(), mc->methodSize, mc->repEnvironmentGetCount()); + LogError("main method %d of size %d failed to load and compile correctly. EnvCnt=%d", + reader->GetMethodContextIndex(), mc->methodSize, mc->repEnvironmentGetCount()); if ((o.reproName != nullptr) && (o.indexCount == -1)) { char buff[500]; sprintf_s(buff, 500, "%s-%d.mc", o.reproName, reader->GetMethodContextIndex()); - HANDLE hFileOut = CreateFileA(buff, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL); + HANDLE hFileOut = CreateFileA(buff, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, + FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL); if (hFileOut == INVALID_HANDLE_VALUE) { LogError("Failed to open output '%s'. GetLastError()=%u", buff, GetLastError()); @@ -527,7 +525,8 @@ int __cdecl main(int argc, char* argv[]) // NOTE: these output status strings are parsed by parallelsuperpmi.cpp::ProcessChildStdOut(). if (o.applyDiff) { - LogInfo(g_AsmDiffsSummaryFormatString, loadedCount, jittedCount, failCount, jittedCount - failCount - matchCount); + LogInfo(g_AsmDiffsSummaryFormatString, loadedCount, jittedCount, failCount, + jittedCount - failCount - matchCount); if (matchCount != jittedCount) { |