summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Harter <sharter@microsoft.com>2015-11-05 18:41:48 -0600
committerSteve Harter <sharter@microsoft.com>2015-11-17 10:57:16 -0600
commit4e06e4271162ac65a57719398e3b5572de9f5185 (patch)
tree1ca0a0122505a5d1eeca015267cbaa3a29456378
parent48617ae01367b2aad76938d101199cf369bead64 (diff)
downloadcoreclr-4e06e4271162ac65a57719398e3b5572de9f5185.tar.gz
coreclr-4e06e4271162ac65a57719398e3b5572de9f5185.tar.bz2
coreclr-4e06e4271162ac65a57719398e3b5572de9f5185.zip
Enable CLANG sanitizers for native debug builds
-rw-r--r--CMakeLists.txt55
-rwxr-xr-xenablesanitizers.sh107
-rw-r--r--src/pal/src/CMakeLists.txt2
-rw-r--r--src/utilcode/clrhost_nodependencies.cpp37
-rw-r--r--src/vm/arm/stubs.cpp2
-rw-r--r--src/vm/ceeload.cpp2
-rw-r--r--src/vm/ceeload.h20
-rw-r--r--src/vm/codeman.cpp14
-rw-r--r--src/vm/codeman.h54
-rw-r--r--src/vm/frames.h3
-rw-r--r--src/vm/loaderallocator.cpp19
-rw-r--r--src/vm/loaderallocator.hpp4
-rw-r--r--src/vm/stubmgr.h7
-rw-r--r--src/vm/virtualcallstub.h5
14 files changed, 272 insertions, 59 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index b880d7ec05..1541710792 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -242,7 +242,6 @@ if (CLR_CMAKE_PLATFORM_UNIX)
else()
clr_unknown_arch()
endif()
-
endif(CLR_CMAKE_PLATFORM_LINUX)
if(CLR_CMAKE_PLATFORM_DARWIN)
@@ -253,23 +252,52 @@ if (CLR_CMAKE_PLATFORM_UNIX)
message("Detected FreeBSD amd64")
endif(CLR_CMAKE_PLATFORM_FREEBSD)
+ # Disable frame pointer optimizations so profilers can get better call stacks
+ add_compile_options(-fno-omit-frame-pointer)
+
+ # set the CLANG sanitizer flags for debug build
+ if(UPPERCASE_CMAKE_BUILD_TYPE STREQUAL DEBUG)
+ # obtain settings from running enablesanitizers.sh
+ string(FIND "$ENV{DEBUG_SANITIZERS}" "asan" __ASAN_POS)
+ string(FIND "$ENV{DEBUG_SANITIZERS}" "ubsan" __UBSAN_POS)
+ if ((${__ASAN_POS} GREATER -1) OR (${__UBSAN_POS} GREATER -1))
+ set(CLR_SANITIZE_CXX_FLAGS "${CLR_SANITIZE_CXX_FLAGS} -fsanitize=")
+ set(CLR_SANITIZE_LINK_FLAGS "${CLR_SANITIZE_LINK_FLAGS} -fsanitize=")
+ if (${__ASAN_POS} GREATER -1)
+ set(CLR_SANITIZE_CXX_FLAGS "${CLR_SANITIZE_CXX_FLAGS}address,")
+ set(CLR_SANITIZE_LINK_FLAGS "${CLR_SANITIZE_LINK_FLAGS}address,")
+ message("Address Sanitizer (asan) enabled")
+ endif ()
+ if (${__UBSAN_POS} GREATER -1)
+ set(CLR_SANITIZE_CXX_FLAGS "${CLR_SANITIZE_CXX_FLAGS}undefined")
+ set(CLR_SANITIZE_LINK_FLAGS "${CLR_SANITIZE_LINK_FLAGS}undefined")
+ message("Undefined Behavior Sanitizer (ubsan) enabled")
+ endif ()
+
+ # -fdata-sections -ffunction-sections: each function has own section instead of one per .o file (needed for --gc-sections)
+ # -fPIC: enable Position Independent Code normally just for shared libraries but required when linking with address sanitizer
+ # -O1: optimization level used instead of -O0 to avoid compile error "invalid operand for inline asm constraint"
+ set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${CLR_SANITIZE_CXX_FLAGS} -fdata-sections -ffunction-sections -fPIC -O1")
+
+ set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} ${CLR_SANITIZE_LINK_FLAGS}")
+
+ # -Wl and --gc-sections: drop unused sections\functions (similar to Windows /Gy function-level-linking)
+ set(CMAKE_SHARED_LINKER_FLAGS_DEBUG "${CMAKE_SHARED_LINKER_FLAGS_DEBUG} ${CLR_SANITIZE_LINK_FLAGS} -Wl,--gc-sections")
+ endif ()
+ endif(UPPERCASE_CMAKE_BUILD_TYPE STREQUAL DEBUG)
+
+ add_subdirectory(src/ToolBox/SOS/lldbplugin)
+ add_subdirectory(src/pal)
+ add_subdirectory(src/corefx)
+ add_subdirectory(src/coreclr/hosts/unixcorerun)
+ add_subdirectory(src/coreclr/hosts/unixcoreconsole)
endif(CLR_CMAKE_PLATFORM_UNIX)
-if(CLR_CMAKE_PLATFORM_UNIX)
- add_subdirectory(src/ToolBox/SOS/lldbplugin)
- add_subdirectory(src/pal)
- add_subdirectory(src/corefx)
- add_subdirectory(src/coreclr/hosts/unixcorerun)
- add_subdirectory(src/coreclr/hosts/unixcoreconsole)
-endif(CLR_CMAKE_PLATFORM_UNIX)
-
-
if(CLR_CMAKE_PLATFORM_DARWIN)
- add_subdirectory(src/coreclr/hosts/osxbundlerun)
+ add_subdirectory(src/coreclr/hosts/osxbundlerun)
endif(CLR_CMAKE_PLATFORM_DARWIN)
# Add this subdir. We install the headers for the jit.
-
add_subdirectory(src/pal/prebuilt/inc)
# Set to 1 if you want to clear the CMAKE initial compiler flags and set all the flags explicitly
@@ -438,9 +466,6 @@ add_compile_options(-fms-extensions )
#-fms-compatibility Enable full Microsoft Visual C++ compatibility
#-fms-extensions Accept some non-standard constructs supported by the Microsoft compiler
-# Disable frame pointer optimizations so profilers can get better call stacks
-add_compile_options(-fno-omit-frame-pointer)
-
endif(CLR_CMAKE_PLATFORM_UNIX)
add_subdirectory(src/debug/debug-pal)
diff --git a/enablesanitizers.sh b/enablesanitizers.sh
new file mode 100755
index 0000000000..0afec5d1ee
--- /dev/null
+++ b/enablesanitizers.sh
@@ -0,0 +1,107 @@
+#!/usr/bin/env bash
+
+if [ $# -eq 0 ]; then
+ echo "Script for enabling CLang sanitizers for debug builds."
+ echo "*Only tested on Ubuntu x64."
+ echo "*This script must be 'sourced' (via dot+space) so that changes to environment variables are preserved. Run like this:"
+ if [ "$(dirname $0)" = "." ]; then
+ echo " . enablesanitizers.sh [options]"
+ else
+ echo " cd $(dirname $0);. enablesanitizers.sh [options]; cd -"
+ fi
+ echo "Usage: [asan] [ubsan] [lsan] [all] [off] [clangx.y]"
+ echo "asan: optional argument to enable Address Sanitizer."
+ echo "ubsan: optional argument to enable Undefined Behavior Sanitizer."
+ echo "lsan - optional argument to enable memory Leak Sanitizer."
+ echo "all - optional argument to enable asan, ubsan and lsan."
+ echo "off - optional argument to turn off all sanitizers."
+ echo "clangx.y - optional argument to specify clang version x.y. which is used to resolve stack traces."
+else
+ __ClangMajorVersion=3
+ __ClangMinorVersion=5
+ __EnableASan=0
+ __EnableUBSan=0
+ __EnableLSan=0
+ __TurnOff=0
+ __Options=
+
+ for i in "$@"
+ do
+ lowerI="$(echo $i | awk '{print tolower($0)}')"
+ case $lowerI in
+ asan)
+ __EnableASan=1
+ ;;
+ ubsan)
+ __EnableUBSan=1
+ ;;
+ lsan)
+ __EnableASan=1
+ __EnableLSan=1
+ ;;
+ all)
+ __EnableASan=1
+ __EnableUBSan=1
+ __EnableLSan=1
+ ;;
+ off)
+ __TurnOff=1
+ ;;
+ clang3.5)
+ __ClangMajorVersion=3
+ __ClangMinorVersion=5
+ ;;
+ clang3.6)
+ __ClangMajorVersion=3
+ __ClangMinorVersion=6
+ ;;
+ clang3.7)
+ __ClangMajorVersion=3
+ __ClangMinorVersion=7
+ ;;
+ *)
+ echo "Unknown arg: $i"
+ return 1
+ esac
+ done
+
+ if [ $__TurnOff == 1 ]; then
+ unset DEBUG_SANITIZERS
+ echo "Setting DEBUG_SANITIZERS="
+ else
+ ASAN_OPTIONS="symbolize=1"
+
+ if [ $__EnableASan == 1 ]; then
+ __Options="$__Options asan"
+ fi
+ if [ $__EnableUBSan == 1 ]; then
+ __Options="$__Options ubsan"
+ fi
+ if [ $__EnableLSan == 1 ]; then
+ ASAN_OPTIONS="$ASAN_OPTIONS detect_leaks"
+ fi
+
+ # passed to build.sh
+ DEBUG_SANITIZERS="$__Options"
+ export DEBUG_SANITIZERS
+ echo "Setting DEBUG_SANITIZERS=$DEBUG_SANITIZERS"
+
+ # used by ASan at run-time
+ ASAN_OPTIONS="\"$ASAN_OPTIONS\""
+ export ASAN_OPTIONS
+ echo "Setting ASAN_OPTIONS=$ASAN_OPTIONS"
+
+ # used by ASan at run-time
+ ASAN_SYMBOLIZER_PATH="/usr/bin/llvm-symbolizer-$__ClangMajorVersion.$__ClangMinorVersion"
+ export ASAN_SYMBOLIZER_PATH
+ echo "Setting ASAN_SYMBOLIZER_PATH=$ASAN_SYMBOLIZER_PATH"
+ fi
+
+ unset __ClangMajorVersion
+ unset __ClangMinorVersion
+ unset __EnableASan
+ unset __EnableUBSan
+ unset __EnableLSan
+ unset __TurnOff
+ unset __Options
+fi \ No newline at end of file
diff --git a/src/pal/src/CMakeLists.txt b/src/pal/src/CMakeLists.txt
index b1f11bd9e3..ad5425b8df 100644
--- a/src/pal/src/CMakeLists.txt
+++ b/src/pal/src/CMakeLists.txt
@@ -66,6 +66,8 @@ elseif(PAL_CMAKE_PLATFORM_ARCH_ARM64)
add_definitions(-D_WIN64=1)
endif()
+# turn off capability to remove unused functions (which was enabled in debug build with sanitizers)
+set(CMAKE_SHARED_LINKER_FLAGS_DEBUG "${CMAKE_SHARED_LINKER_FLAGS_DEBUG} -Wl,--no-gc-sections")
add_compile_options(-fno-builtin)
add_compile_options(-fPIC)
diff --git a/src/utilcode/clrhost_nodependencies.cpp b/src/utilcode/clrhost_nodependencies.cpp
index 33f270ecb3..30000dc12d 100644
--- a/src/utilcode/clrhost_nodependencies.cpp
+++ b/src/utilcode/clrhost_nodependencies.cpp
@@ -17,6 +17,12 @@
#include "contract.h"
#include "tls.h"
+#if defined __llvm__
+# if defined(__has_feature) && __has_feature(address_sanitizer)
+# define HAS_ADDRESS_SANITIZER
+# endif
+#endif
+
#ifdef _DEBUG_IMPL
//
@@ -37,6 +43,10 @@ void DisableThrowCheck()
dbg_fDisableThrowCheck = TRUE;
}
+#ifdef HAS_ADDRESS_SANITIZER
+// use the functionality from address santizier (which does not throw exceptions)
+#else
+
#define CLRThrowsExceptionWorker() RealCLRThrowsExceptionWorker(__FUNCTION__, __FILE__, __LINE__)
static void RealCLRThrowsExceptionWorker(__in_z const char *szFunction,
@@ -53,6 +63,7 @@ static void RealCLRThrowsExceptionWorker(__in_z const char *szFunction,
CONTRACT_THROWSEX(szFunction, szFile, lineNum);
}
+#endif // HAS_ADDRESS_SANITIZER
#endif //_DEBUG_IMPL
#if defined(_DEBUG_IMPL) && defined(ENABLE_CONTRACTS_IMPL)
@@ -383,6 +394,10 @@ FastFreeInProcessHeapFunc __ClrFreeInProcessHeap = (FastFreeInProcessHeapFunc) C
const NoThrow nothrow = { 0 };
+#ifdef HAS_ADDRESS_SANITIZER
+// use standard heap functions for address santizier
+#else
+
#ifdef __llvm__
__attribute__((visibility("hidden")))
#endif
@@ -431,11 +446,17 @@ operator new[](size_t n)
return result;
};
+#endif // HAS_ADDRESS_SANITIZER
+
#ifdef __llvm__
__attribute__((visibility("hidden")))
#endif
void * __cdecl operator new(size_t n, const NoThrow&)
{
+#ifdef HAS_ADDRESS_SANITIZER
+ // use standard heap functions for address santizier (which doesn't provide for NoThrow)
+ void * result = operator new(n);
+#else
STATIC_CONTRACT_NOTHROW;
STATIC_CONTRACT_GC_NOTRIGGER;
STATIC_CONTRACT_FAULT;
@@ -445,7 +466,8 @@ void * __cdecl operator new(size_t n, const NoThrow&)
INCONTRACT(_ASSERTE(!ARE_FAULTS_FORBIDDEN()));
void * result = ClrAllocInProcessHeap(0, S_SIZE_T(n));
- TRASH_LASTERROR;
+#endif // HAS_ADDRESS_SANITIZER
+ TRASH_LASTERROR;
return result;
}
@@ -454,6 +476,10 @@ __attribute__((visibility("hidden")))
#endif
void * __cdecl operator new[](size_t n, const NoThrow&)
{
+#ifdef HAS_ADDRESS_SANITIZER
+ // use standard heap functions for address santizier (which doesn't provide for NoThrow)
+ void * result = operator new[](n);
+#else
STATIC_CONTRACT_NOTHROW;
STATIC_CONTRACT_GC_NOTRIGGER;
STATIC_CONTRACT_FAULT;
@@ -463,10 +489,14 @@ void * __cdecl operator new[](size_t n, const NoThrow&)
INCONTRACT(_ASSERTE(!ARE_FAULTS_FORBIDDEN()));
void * result = ClrAllocInProcessHeap(0, S_SIZE_T(n));
- TRASH_LASTERROR;
+#endif // HAS_ADDRESS_SANITIZER
+ TRASH_LASTERROR;
return result;
}
+#ifdef HAS_ADDRESS_SANITIZER
+// use standard heap functions for address santizier
+#else
#ifdef __llvm__
__attribute__((visibility("hidden")))
#endif
@@ -499,6 +529,9 @@ operator delete[](void *p) NOEXCEPT
TRASH_LASTERROR;
}
+#endif // HAS_ADDRESS_SANITIZER
+
+
/* ------------------------------------------------------------------------ *
* New operator overloading for the executable heap
* ------------------------------------------------------------------------ */
diff --git a/src/vm/arm/stubs.cpp b/src/vm/arm/stubs.cpp
index 42f56a6da7..b4e312200e 100644
--- a/src/vm/arm/stubs.cpp
+++ b/src/vm/arm/stubs.cpp
@@ -2270,6 +2270,7 @@ void TransitionFrame::UpdateRegDisplay(const PREGDISPLAY pRD)
LOG((LF_GCROOTS, LL_INFO100000, "STACKWALK TransitionFrame::UpdateRegDisplay(rip:%p, rsp:%p)\n", pRD->ControlPC, pRD->SP));
}
+#endif // !CROSSGEN_COMPILE
void TailCallFrame::UpdateRegDisplay(const PREGDISPLAY pRD)
{
@@ -2311,7 +2312,6 @@ void TailCallFrame::InitFromContext(T_CONTEXT * pContext)
}
#endif // !DACCESS_COMPILE
-#endif // !CROSSGEN_COMPILE
void FaultingExceptionFrame::UpdateRegDisplay(const PREGDISPLAY pRD)
{
diff --git a/src/vm/ceeload.cpp b/src/vm/ceeload.cpp
index 6fa1e44519..12734fd7db 100644
--- a/src/vm/ceeload.cpp
+++ b/src/vm/ceeload.cpp
@@ -14846,7 +14846,7 @@ void ReflectionModule::ReleaseILData()
Module::ReleaseILData();
}
-#endif // CROSSGEN_COMPILE
+#endif // !CROSSGEN_COMPILE
#endif // !DACCESS_COMPILE
diff --git a/src/vm/ceeload.h b/src/vm/ceeload.h
index 4fecdef22e..9fc905cc8a 100644
--- a/src/vm/ceeload.h
+++ b/src/vm/ceeload.h
@@ -3686,6 +3686,7 @@ private:
// If true, then only other transient modules can depend on this module.
bool m_fIsTransient;
+#if !defined DACCESS_COMPILE && !defined CROSSGEN_COMPILE
// Returns true iff metadata capturing is suppressed
bool IsMetadataCaptureSuppressed();
@@ -3705,8 +3706,8 @@ private:
pModule->ResumeMetadataCapture();
}
-
ReflectionModule(Assembly *pAssembly, mdFile token, PEFile *pFile);
+#endif // !DACCESS_COMPILE && !CROSSGEN_COMPILE
public:
@@ -3715,14 +3716,13 @@ public:
PTR_SBuffer GetDynamicMetadataBuffer() const;
#endif
+#if !defined DACCESS_COMPILE && !defined CROSSGEN_COMPILE
static ReflectionModule *Create(Assembly *pAssembly, PEFile *pFile, AllocMemTracker *pamTracker, LPCWSTR szName, BOOL fIsTransient);
-
void Initialize(AllocMemTracker *pamTracker, LPCWSTR szName);
-
void Destruct();
-#ifndef DACCESS_COMPILE
+
void ReleaseILData();
-#endif
+#endif // !DACCESS_COMPILE && !CROSSGEN_COMPILE
// Overides functions to access sections
virtual TADDR GetIL(RVA target);
@@ -3786,17 +3786,14 @@ public:
}
#ifndef DACCESS_COMPILE
+#ifndef CROSSGEN_COMPILE
typedef Wrapper<
ReflectionModule*,
ReflectionModule::SuppressCaptureWrapper,
ReflectionModule::ResumeCaptureWrapper> SuppressMetadataCaptureHolder;
+#endif // !CROSSGEN_COMPILE
-
-
- // Eagerly serialize the metadata to a buffer that the debugger can retrieve.
- void CaptureModuleMetaDataToMemory();
-
HRESULT SetISymUnmanagedWriter(ISymUnmanagedWriter *pWriter)
{
CONTRACTL
@@ -3825,6 +3822,9 @@ public:
return S_OK;
}
#endif // !DACCESS_COMPILE
+
+ // Eagerly serialize the metadata to a buffer that the debugger can retrieve.
+ void CaptureModuleMetaDataToMemory();
};
// Module holders
diff --git a/src/vm/codeman.cpp b/src/vm/codeman.cpp
index 9dcd5eb25e..482553b9cb 100644
--- a/src/vm/codeman.cpp
+++ b/src/vm/codeman.cpp
@@ -1823,7 +1823,7 @@ void CodeFragmentHeap::RealBackoutMem(void *pMem
AddBlock(pMem, dwSize);
}
-#endif // CROSSGEN_COMPILE
+#endif // !CROSSGEN_COMPILE
//**************************************************************************
@@ -4012,7 +4012,17 @@ void EEJitManager::EnumMemoryRegions(CLRDataEnumMemoryFlags flags)
}
#endif // #ifdef DACCESS_COMPILE
-#endif // CROSSGEN_COMPILE
+#else // CROSSGEN_COMPILE
+// stub for compilation
+BOOL EEJitManager::JitCodeToMethodInfo(RangeSection * pRangeSection,
+ PCODE currentPC,
+ MethodDesc ** ppMethodDesc,
+ EECodeInfo * pCodeInfo)
+{
+ _ASSERTE(FALSE);
+ return FALSE;
+}
+#endif // !CROSSGEN_COMPILE
#ifndef DACCESS_COMPILE
diff --git a/src/vm/codeman.h b/src/vm/codeman.h
index 8e2c6293dc..e6ddde08fc 100644
--- a/src/vm/codeman.h
+++ b/src/vm/codeman.h
@@ -923,12 +923,13 @@ public:
return ret;
}
-#ifndef DACCESS_COMPILE
+#if !defined CROSSGEN_COMPILE && !defined DACCESS_COMPILE
EEJitManager();
// No destructor necessary. Only one instance of this class that is destroyed at process shutdown.
// ~EEJitManager();
-#endif // #ifndef DACCESS_COMPILE
+#endif // !CROSSGEN_COMPILE && !DACCESS_COMPILE
+
virtual DWORD GetCodeType()
{
@@ -936,6 +937,7 @@ public:
return (miManaged | miIL);
}
+#ifndef CROSSGEN_COMPILE
// Used to read debug info.
virtual BOOL GetBoundariesAndVars(
const DebugInfoRequest & request,
@@ -945,27 +947,29 @@ public:
OUT ULONG32 * pcVars,
OUT ICorDebugInfo::NativeVarInfo **ppVars);
+ virtual PCODE GetCodeAddressForRelOffset(const METHODTOKEN& MethodToken, DWORD relOffset);
+#endif // !CROSSGEN_COMPILE
+
virtual BOOL JitCodeToMethodInfo(RangeSection * pRangeSection,
PCODE currentPC,
MethodDesc ** ppMethodDesc,
EECodeInfo * pCodeInfo);
- virtual PCODE GetCodeAddressForRelOffset(const METHODTOKEN& MethodToken, DWORD relOffset);
-
virtual TADDR JitTokenToStartAddress(const METHODTOKEN& MethodToken);
virtual void JitTokenToMethodRegionInfo(const METHODTOKEN& MethodToken, MethodRegionInfo *methodRegionInfo);
+#ifndef CROSSGEN_COMPILE
virtual unsigned InitializeEHEnumeration(const METHODTOKEN& MethodToken, EH_CLAUSE_ENUMERATOR* pEnumState);
virtual PTR_EXCEPTION_CLAUSE_TOKEN GetNextEHClause(EH_CLAUSE_ENUMERATOR* pEnumState,
EE_ILEXCEPTION_CLAUSE* pEHclause);
#ifndef DACCESS_COMPILE
virtual TypeHandle ResolveEHClause(EE_ILEXCEPTION_CLAUSE* pEHClause,
CrawlFrame *pCf);
-#endif // #ifndef DACCESS_COMPILE
+#endif // !DACCESS_COMPILE
PTR_VOID GetGCInfo(const METHODTOKEN& MethodToken);
-#ifndef DACCESS_COMPILE
+#endif // !CROSSGEN_COMPILE
+#if !defined DACCESS_COMPILE && !defined CROSSGEN_COMPILE
void RemoveJitData(CodeHeader * pCHdr, size_t GCinfo_len, size_t EHinfo_len);
-
void Unload(LoaderAllocator* pAllocator);
void CleanupCodeHeaps();
@@ -977,7 +981,6 @@ public:
, TADDR * pModuleBase
#endif
);
- void allocEntryChunk(MethodDescChunk *pMDChunk);
BYTE * allocGCInfo(CodeHeader* pCodeHeader, DWORD blockSize, size_t * pAllocationSize);
EE_ILEXCEPTION* allocEHInfo(CodeHeader* pCodeHeader, unsigned numClauses, size_t * pAllocationSize);
JumpStubBlockHeader* allocJumpStubBlock(MethodDesc* pMD, DWORD numJumps,
@@ -985,11 +988,12 @@ public:
LoaderAllocator *pLoaderAllocator);
void * allocCodeFragmentBlock(size_t blockSize, unsigned alignment, LoaderAllocator *pLoaderAllocator, StubCodeBlockKind kind);
-#endif // #ifndef DACCESS_COMPILE
+#endif // !DACCESS_COMPILE && !CROSSGEN_COMPILE
static CodeHeader * GetCodeHeader(const METHODTOKEN& MethodToken);
static CodeHeader * GetCodeHeaderFromStartAddress(TADDR methodStartAddress);
+#ifndef CROSSGEN_COMPILE
#if defined(WIN64EXCEPTIONS)
// Compute function entry lazily. Do not call directly. Use EECodeInfo::GetFunctionEntry instead.
virtual PTR_RUNTIME_FUNCTION LazyGetFunctionEntry(EECodeInfo * pCodeInfo);
@@ -1002,6 +1006,7 @@ public:
#if defined(DACCESS_COMPILE)
virtual void EnumMemoryRegions(CLRDataEnumMemoryFlags flags);
virtual void EnumMemoryRegionsForMethodDebugInfo(CLRDataEnumMemoryFlags flags, MethodDesc * pMD);
+#endif // DACCESS_COMPILE
#if defined(WIN64EXCEPTIONS)
// Enumerate the memory necessary to retrieve the unwind info for a specific method
virtual void EnumMemoryRegionsForMethodUnwindInfo(CLRDataEnumMemoryFlags flags, EECodeInfo * pCodeInfo)
@@ -1013,21 +1018,24 @@ public:
// available at debug time).
}
#endif // WIN64EXCEPTIONS
-#endif // DACCESS_COMPILE
+#endif // !CROSSGEN_COMPILE
- // Heap Management functions
+#ifndef CROSSGEN_COMPILE
+#ifndef DACCESS_COMPILE
+ // Heap Management functions
void NibbleMapSet(HeapList * pHp, TADDR pCode, BOOL bSet);
+#endif // !DACCESS_COMPILE
static TADDR FindMethodCode(RangeSection * pRangeSection, PCODE currentPC);
static TADDR FindMethodCode(PCODE currentPC);
-
-#ifndef DACCESS_COMPILE
+#endif // !CROSSGEN_COMPILE
+
+#if !defined DACCESS_COMPILE && !defined CROSSGEN_COMPILE
void FreeCodeMemory(HostCodeHeap *pCodeHeap, void * codeStart);
void RemoveFromCleanupList(HostCodeHeap *pCodeHeap);
void AddToCleanupList(HostCodeHeap *pCodeHeap);
void DeleteCodeHeap(HeapList *pHeapList);
void RemoveCodeHeapFromDomainList(CodeHeap *pHeap, LoaderAllocator *pAllocator);
-#endif
private :
struct DomainCodeHeapList {
@@ -1036,8 +1044,11 @@ private :
DomainCodeHeapList();
~DomainCodeHeapList();
};
+#endif // !DACCESS_COMPILE && !CROSSGEN_COMPILE
+
#ifndef DACCESS_COMPILE
- HeapList* NewCodeHeap(CodeHeapRequestInfo *pInfo, DomainCodeHeapList *pADHeapList);
+#ifndef CROSSGEN_COMPILE
+ HeapList* NewCodeHeap(CodeHeapRequestInfo *pInfo, DomainCodeHeapList *pADHeapList);
HeapList* GetCodeHeap(CodeHeapRequestInfo *pInfo);
bool CanUseCodeHeap(CodeHeapRequestInfo *pInfo, HeapList *pCodeHeap);
void* allocCodeRaw(CodeHeapRequestInfo *pInfo,
@@ -1047,16 +1058,19 @@ private :
DomainCodeHeapList *GetCodeHeapList(MethodDesc *pMD, LoaderAllocator *pAllocator, BOOL fDynamicOnly = FALSE);
DomainCodeHeapList *CreateCodeHeapList(CodeHeapRequestInfo *pInfo);
LoaderHeap* GetJitMetaHeap(MethodDesc *pMD);
+#endif // !CROSSGEN_COMPILE
HeapList * GetCodeHeapList()
{
return m_pCodeHeap;
}
-protected :
+#ifndef CROSSGEN_COMPILE
+protected:
void * allocEHInfoRaw(CodeHeader* pCodeHeader, DWORD blockSize, size_t * pAllocationSize);
-private :
-#endif // #ifndef DACCESS_COMPILE
+private:
+#endif
+#endif // !DACCESS_COMPILE
PTR_HeapList m_pCodeHeap;
@@ -1096,7 +1110,9 @@ public:
private:
DWORD m_dwCPUCompileFlags;
+#if !defined CROSSGEN_COMPILE && !defined DACCESS_COMPILE
void SetCpuInfo();
+#endif
public:
inline DWORD GetCPUCompileFlags()
@@ -1110,9 +1126,11 @@ private :
//When EH Clauses are resolved we need to atomically update the TypeHandle
Crst m_EHClauseCritSec;
+#if !defined CROSSGEN_COMPILE && !defined DACCESS_COMPILE
// must hold critical section to access this structure.
CUnorderedArray<DomainCodeHeapList *, 5> m_DomainCodeHeaps;
CUnorderedArray<DomainCodeHeapList *, 5> m_DynamicDomainCodeHeaps;
+#endif
#ifdef _TARGET_AMD64_
private:
diff --git a/src/vm/frames.h b/src/vm/frames.h
index 4c4331403b..1030bc2777 100644
--- a/src/vm/frames.h
+++ b/src/vm/frames.h
@@ -3311,6 +3311,7 @@ class TailCallFrame : public Frame
#endif
public:
+#ifndef CROSSGEN_COMPILE
#if !defined(_TARGET_X86_)
#ifndef DACCESS_COMPILE
@@ -3360,7 +3361,7 @@ public:
}
virtual void UpdateRegDisplay(const PREGDISPLAY pRD);
-
+#endif // !CROSSGEN_COMPILE
#ifdef _TARGET_AMD64_
void SetGCLayout(TADDR pGCLayout)
{
diff --git a/src/vm/loaderallocator.cpp b/src/vm/loaderallocator.cpp
index 545d94fa51..6c30c7d80c 100644
--- a/src/vm/loaderallocator.cpp
+++ b/src/vm/loaderallocator.cpp
@@ -52,7 +52,10 @@ LoaderAllocator::LoaderAllocator()
m_pFatTokenSet = NULL;
#endif
+#ifndef CROSSGEN_COMPILE
m_pVirtualCallStubManager = NULL;
+#endif
+
m_fGCPressure = false;
m_fTerminated = false;
m_fUnloaded = false;
@@ -298,7 +301,7 @@ BOOL LoaderAllocator::EnsureInstantiation(Module *pDefiningModule, Instantiation
{
return FALSE;
}
-#endif // CROSSGEN_COMPILE
+#endif // !CROSSGEN_COMPILE
#ifndef CROSSGEN_COMPILE
bool LoaderAllocator::Marked()
@@ -881,7 +884,7 @@ void LoaderAllocator::ActivateManagedTracking()
LOADERALLOCATORREF loaderAllocator = (LOADERALLOCATORREF)ObjectFromHandle(m_hLoaderAllocatorObjectHandle);
loaderAllocator->SetNativeLoaderAllocator(this);
}
-#endif // CROSSGEN_COMPILE
+#endif // !CROSSGEN_COMPILE
// We don't actually allocate a low frequency heap for collectible types
@@ -1217,7 +1220,7 @@ void LoaderAllocator::Terminate()
LOG((LF_CLASSLOADER, LL_INFO100, "End LoaderAllocator::Terminate for loader allocator %p\n", reinterpret_cast<void *>(static_cast<PTR_LoaderAllocator>(this))));
}
-#endif // CROSSGEN_COMPILE
+#endif // !CROSSGEN_COMPILE
#else //DACCESS_COMPILE
@@ -1260,8 +1263,10 @@ SIZE_T LoaderAllocator::EstimateSize()
retval+=m_pStubHeap->GetSize();
if(m_pStringLiteralMap)
retval+=m_pStringLiteralMap->GetSize();
+#ifndef CROSSGEN_COMPILE
if(m_pVirtualCallStubManager)
retval+=m_pVirtualCallStubManager->GetSize();
+#endif
return retval;
}
@@ -1421,9 +1426,9 @@ void LoaderAllocator::UninitVirtualCallStubManager()
m_pVirtualCallStubManager = NULL;
}
}
-#endif // CROSSGEN_COMPILE
+#endif // !CROSSGEN_COMPILE
-#endif // DACCESS_COMPILE
+#endif // !DACCESS_COMPILE
BOOL GlobalLoaderAllocator::CanUnload()
{
@@ -1661,6 +1666,6 @@ void LoaderAllocator::CleanupFailedTypeInit()
pLock->Unlink(pItem->m_pListLockEntry);
}
}
-#endif // CROSSGEN_COMPILE
+#endif // !CROSSGEN_COMPILE
-#endif //!DACCES_COMPILE
+#endif // !DACCESS_COMPILE
diff --git a/src/vm/loaderallocator.hpp b/src/vm/loaderallocator.hpp
index a9166ea9f2..ec537c72b4 100644
--- a/src/vm/loaderallocator.hpp
+++ b/src/vm/loaderallocator.hpp
@@ -144,7 +144,9 @@ protected:
FatTokenSet *m_pFatTokenSet;
#endif
+#ifndef CROSSGEN_COMPILE
VirtualCallStubManager *m_pVirtualCallStubManager;
+#endif
private:
typedef SHash<PtrSetSHashTraits<LoaderAllocator * > > LoaderAllocatorSet;
@@ -432,11 +434,13 @@ public:
void InitVirtualCallStubManager(BaseDomain *pDomain, BOOL fCollectible = FALSE);
void UninitVirtualCallStubManager();
+#ifndef CROSSGEN_COMPILE
inline VirtualCallStubManager *GetVirtualCallStubManager()
{
LIMITED_METHOD_CONTRACT;
return m_pVirtualCallStubManager;
}
+#endif
}; // class LoaderAllocator
typedef VPTR(LoaderAllocator) PTR_LoaderAllocator;
diff --git a/src/vm/stubmgr.h b/src/vm/stubmgr.h
index 8dfb6686ad..d578171985 100644
--- a/src/vm/stubmgr.h
+++ b/src/vm/stubmgr.h
@@ -193,6 +193,7 @@ typedef VPTR(class StubManager) PTR_StubManager;
class StubManager
{
+#ifndef CROSSGEN_COMPILE
friend class StubManagerIterator;
VPTR_BASE_VTABLE_CLASS(StubManager)
@@ -326,6 +327,7 @@ private:
PTR_StubManager m_pNextManager;
static CrstStatic s_StubManagerListCrst;
+#endif // !CROSSGEN_COMPILE
};
// -------------------------------------------------------
@@ -375,6 +377,8 @@ class LockedRangeList : public RangeList
SimpleRWLock m_RangeListRWLock;
};
+#ifndef CROSSGEN_COMPILE
+
//-----------------------------------------------------------
// Stub manager for the prestub. Although there is just one, it has
// unique behavior so it gets its own stub manager.
@@ -991,4 +995,5 @@ public:
};
-#endif
+#endif // !CROSSGEN_COMPILE
+#endif // !__stubmgr_h__
diff --git a/src/vm/virtualcallstub.h b/src/vm/virtualcallstub.h
index 02605f237d..4d09d074a9 100644
--- a/src/vm/virtualcallstub.h
+++ b/src/vm/virtualcallstub.h
@@ -16,6 +16,8 @@
#ifndef _VIRTUAL_CALL_STUB_H
#define _VIRTUAL_CALL_STUB_H
+#ifndef CROSSGEN_COMPILE
+
#define CHAIN_LOOKUP
#if defined(_TARGET_X86_)
@@ -1619,5 +1621,6 @@ private:
static FastTable* dead; //linked list head of to be deleted (abandoned) buckets
};
-#endif // !_VIRTUAL_CALL_STUB_H
+#endif // !CROSSGEN_COMPILE
+#endif // !_VIRTUAL_CALL_STUB_H