diff --git a/src/coreclr/gc/unix/gcenv.unix.cpp b/src/coreclr/gc/unix/gcenv.unix.cpp index 0f0f90fae1d9..34e543b363ce 100644 --- a/src/coreclr/gc/unix/gcenv.unix.cpp +++ b/src/coreclr/gc/unix/gcenv.unix.cpp @@ -1263,6 +1263,8 @@ uint64_t GetAvailablePhysicalMemory() sysctlbyname("vm.stats.vm.v_free_count", &free_count, &sz, NULL, 0); available = (inactive_count + laundry_count + free_count) * sysconf(_SC_PAGESIZE); +#elif defined(TARGET_WASM) + available = sysconf(SYSCONF_PAGES) * sysconf(_SC_PAGE_SIZE); #else // Linux static volatile bool tryReadMemInfo = true; diff --git a/src/coreclr/gc/wasm/gcenv.wasm.cpp b/src/coreclr/gc/wasm/gcenv.wasm.cpp index 74d640074aeb..02e489de60a5 100644 --- a/src/coreclr/gc/wasm/gcenv.wasm.cpp +++ b/src/coreclr/gc/wasm/gcenv.wasm.cpp @@ -4,7 +4,6 @@ #include "common.h" #include "gcenv.h" - // Flush write buffers of processors that are executing threads of the current process - a NOP for Wasm void GCToOSInterface::FlushProcessWriteBuffers() { @@ -118,3 +117,24 @@ bool GCToOSInterface::VirtualReset(void* address, size_t size, bool unlock) { return false; } + +// +// CPU and memory limits - not avaliable on WASM (yet). +// +void InitializeCGroup() +{ +} + +void CleanupCGroup() +{ +} + +size_t GetRestrictedPhysicalMemoryLimit() +{ + return 0; // 'Unlimited'. +} + +bool GetPhysicalMemoryUsed(size_t* val) +{ + return false; // 'Unknown'. +} diff --git a/src/coreclr/nativeaot/Runtime/CMakeLists.txt b/src/coreclr/nativeaot/Runtime/CMakeLists.txt index 2ce1d40e8e99..56e4269ece7e 100644 --- a/src/coreclr/nativeaot/Runtime/CMakeLists.txt +++ b/src/coreclr/nativeaot/Runtime/CMakeLists.txt @@ -163,12 +163,15 @@ else() ) if (CLR_CMAKE_TARGET_ARCH_WASM) + list(REMOVE_ITEM COMMON_RUNTIME_SOURCES + ${GC_DIR}/unix/cgroup.cpp + unix/PalCreateDump.cpp + ) list(APPEND COMMON_RUNTIME_SOURCES ${GC_DIR}/wasm/gcenv.wasm.cpp wasm/PalCreateDump.cpp - unix/cgroupcpu.cpp + wasm/cgroupcpu.cpp ) - list(REMOVE_ITEM COMMON_RUNTIME_SOURCES unix/PalCreateDump.cpp) endif() list(APPEND FULL_RUNTIME_SOURCES diff --git a/src/coreclr/nativeaot/Runtime/wasm/cgroupcpu.cpp b/src/coreclr/nativeaot/Runtime/wasm/cgroupcpu.cpp new file mode 100644 index 000000000000..9260ffd58b31 --- /dev/null +++ b/src/coreclr/nativeaot/Runtime/wasm/cgroupcpu.cpp @@ -0,0 +1,16 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +#include + +// +// No CPU or memory limits on WASM as yet. +// +void InitializeCpuCGroup() +{ +} + +bool GetCpuLimit(uint32_t* val) +{ + return false; +}