Sfoglia il codice sorgente

xplat: add valgrind support

Oguz Bastemur 8 anni fa
parent
commit
e09ef745b8

+ 10 - 1
CMakeLists.txt

@@ -36,7 +36,7 @@ endif()
 
 if(CC_TARGETS_AMD64_SH)
     set(CC_TARGETS_AMD64 1)
-elseif (CC_TARGETS_ARM_SH)
+elseif(CC_TARGETS_ARM_SH)
     set(CC_TARGETS_ARM 1)
     add_definitions(-D_ARM_=1)
     set(CMAKE_SYSTEM_PROCESSOR "armv7l")
@@ -51,6 +51,15 @@ unset(CC_TARGETS_ARM_SH CACHE)
 unset(CC_TARGETS_X86_SH CACHE)
 unset(CC_TARGETS_AMD64_SH CACHE)
 
+if(ENABLE_VALGRIND_SH)
+    unset(ENABLE_VALGRIND_SH CACHE)
+    if(NOT CC_TARGETS_X86)
+        # Enable Valgrind is not needed for x86 builds. Already <= 32Gb address space
+        set(ENABLE_VALGRIND 1)
+        add_definitions(-DENABLE_VALGRIND=1)
+    endif()
+endif()
+
 if(ICU_SETTINGS_RESET)
     unset(ICU_SETTINGS_RESET CACHE)
     unset(ICU_INCLUDE_PATH CACHE)

+ 1 - 1
bin/CMakeLists.txt

@@ -1,5 +1,5 @@
 if(NOT CC_LIBS_ONLY_BUILD)
-    if(NOT CC_TARGET_OS_ANDROID)
+    if(NOT (CC_TARGET_OS_ANDROID OR ENABLE_VALGRIND))
         add_subdirectory (GCStress)
     endif()
 

+ 7 - 5
build.sh

@@ -59,8 +59,9 @@ PRINT_USAGE() {
     echo "     --trace           Enables experimental built-in trace."
     echo "     --xcode           Generate XCode project."
     echo "     --without=FEATURE,FEATURE,..."
-    echo "                       Disable FEATUREs from JSRT experimental"
-    echo "                       features."
+    echo "                       Disable FEATUREs from JSRT experimental features."
+    echo "     --valgrind        Enable Valgrind support"
+    echo "                       !!! Disables Concurrent GC (lower performance)"
     echo " -v, --verbose         Display verbose output including all options"
     echo "     --wb-check CPPFILE"
     echo "                       Write-barrier check given CPPFILE (git path)"
@@ -103,6 +104,7 @@ WB_CHECK=
 WB_ANALYZE=
 WB_ARGS=
 TARGET_PATH=0
+VALGRIND=0
 # -DCMAKE_EXPORT_COMPILE_COMMANDS=ON useful for clang-query tool
 CMAKE_EXPORT_COMPILE_COMMANDS="-DCMAKE_EXPORT_COMPILE_COMMANDS=ON"
 LIBS_ONLY_BUILD=
@@ -297,8 +299,8 @@ while [[ $# -gt 0 ]]; do
         WB_ARGS=${WB_ARGS// /;}  # replace space with ; to generate a cmake list
         ;;
 
-    -y | -Y)
-        ALWAYS_YES=1
+    --valgrind)
+        VALGRIND="-DENABLE_VALGRIND_SH=1"
         ;;
 
     *)
@@ -538,7 +540,7 @@ echo Generating $BUILD_TYPE makefiles
 cmake $CMAKE_GEN $CC_PREFIX $ICU_PATH $LTO $STATIC_LIBRARY $ARCH $TARGET_OS \
     $ENABLE_CC_XPLAT_TRACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE $SANITIZE $NO_JIT \
     $WITHOUT_FEATURES $WB_FLAG $WB_ARGS $CMAKE_EXPORT_COMPILE_COMMANDS $LIBS_ONLY_BUILD\
-    $BUILD_RELATIVE_DIRECTORY
+    $VALGRIND $BUILD_RELATIVE_DIRECTORY
 
 _RET=$?
 if [[ $? == 0 ]]; then

+ 4 - 0
lib/Common/CommonDefines.h

@@ -140,7 +140,11 @@
 #define ENABLE_JS_ETW                               // ETW support
 #else
 #define SYSINFO_IMAGE_BASE_AVAILABLE 0
+#ifndef ENABLE_VALGRIND
 #define ENABLE_CONCURRENT_GC 1
+#else
+#define ENABLE_CONCURRENT_GC 0
+#endif
 #define SUPPORT_WIN32_SLIST 0
 #endif
 

+ 7 - 1
lib/Common/Memory/RecyclerWriteBarrierManager.cpp

@@ -255,6 +255,11 @@ X64WriteBarrierCardTableManager::Initialize()
         // of a reservation can be approximated as 2KB per MB of reserved size. In our case, we take
         // an overhead of 96KB for our card table.
 
+#if defined(ENABLE_VALGRIND)
+        // this will fail (cardTable) due to stack ptr > 32GB
+#error  "Not supported. Disable concurrent GC and try again"
+#endif
+
         // xplat: GetRLimit AS / RSS for ``the maximum size of the process's virtual memory``
         size_t memoryLimit;
         if (!PlatformAgnostic::SystemInfo::GetMaxVirtualMemory(&memoryLimit))
@@ -268,7 +273,8 @@ X64WriteBarrierCardTableManager::Initialize()
         }
         const unsigned __int64 maxUmProcessAddressSpace = (__int64) memoryLimit;
 
-        _cardTableNumEntries = Math::Align<size_t>(maxUmProcessAddressSpace / AutoSystemInfo::PageSize, AutoSystemInfo::PageSize) /* s_writeBarrierPageSize */;
+        _cardTableNumEntries = Math::Align<size_t>(maxUmProcessAddressSpace / AutoSystemInfo::PageSize,
+            AutoSystemInfo::PageSize) /* s_writeBarrierPageSize */;
 
         LPVOID cardTableSpace = ::VirtualAlloc(NULL, _cardTableNumEntries, MEM_RESERVE, PAGE_READWRITE);
         if (!cardTableSpace) // Crash Early with a meaningful message. Otherwise the behavior is undefined.