Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/coreclr/gc/unix/cgroup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,10 @@ class CGroup
static void Initialize()
{
s_cgroup_version = FindCGroupVersion();
FindCGroupPath(s_cgroup_version == 1 ? &IsCGroup1MemorySubsystem : nullptr, &s_memory_cgroup_path, &s_memory_cgroup_hierarchy_mount);
if (s_cgroup_version != 0)
{
FindCGroupPath(s_cgroup_version == 1 ? &IsCGroup1MemorySubsystem : nullptr, &s_memory_cgroup_path, &s_memory_cgroup_hierarchy_mount);
}
}

static void Cleanup()
Expand Down Expand Up @@ -119,7 +122,7 @@ class CGroup
// modes because both of those involve cgroup v1 controllers managing
// resources.

#if !HAVE_NON_LEGACY_STATFS
#if !HAVE_NON_LEGACY_STATFS || TARGET_WASM
return 0;
#else

Expand Down
9 changes: 8 additions & 1 deletion src/coreclr/gc/unix/gcenv.unix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,11 @@ typedef cpuset_t cpu_set_t;
#define SYSCONF_GET_NUMPROCS _SC_NPROCESSORS_ONLN
#endif

#ifdef __EMSCRIPTEN__
#include <emscripten/heap.h>
#endif // __EMSCRIPTEN__


// The cached total number of CPUs that can be used in the OS.
static uint32_t g_totalCpuCount = 0;

Expand Down Expand Up @@ -814,7 +819,7 @@ static uint64_t GetMemorySizeMultiplier(char units)
return 1;
}

#if !defined(__APPLE__) && !defined(__HAIKU__)
#if !defined(__APPLE__) && !defined(__HAIKU__) && !defined(__EMSCRIPTEN__)
// Try to read the MemAvailable entry from /proc/meminfo.
// Return true if the /proc/meminfo existed, the entry was present and we were able to parse it.
static bool ReadMemAvailable(uint64_t* memAvailable)
Expand Down Expand Up @@ -1082,6 +1087,8 @@ uint64_t GetAvailablePhysicalMemory()
{
available = info.free_memory;
}
#elif defined(__EMSCRIPTEN__)
available = emscripten_get_heap_max();
#else // Linux
static volatile bool tryReadMemInfo = true;

Expand Down
2 changes: 2 additions & 0 deletions src/coreclr/hosts/corerun/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ else()
if (CLR_CMAKE_TARGET_BROWSER)
target_compile_options(corerun PRIVATE
-fwasm-exceptions
-mbulk-memory
-msimd128
)
target_link_libraries(corerun PRIVATE
Expand All @@ -79,6 +80,7 @@ else()
-sMAXIMUM_MEMORY=2147483648
-sALLOW_MEMORY_GROWTH=1
-sSTACK_SIZE=5MB
-sWASM_BIGINT=1
-sEXPORTED_FUNCTIONS=_main,_GetDotNetRuntimeContractDescriptor
-sENVIRONMENT=node,shell,web
-Wl,-error-limit=0)
Expand Down
24 changes: 19 additions & 5 deletions src/coreclr/interpreter/compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,10 @@ void InterpCompiler::LinkBBs(InterpBasicBlock *from, InterpBasicBlock *to)
if (newCapacity > prevCapacity)
{
InterpBasicBlock **newa = (InterpBasicBlock**)AllocMemPool(newCapacity * sizeof(InterpBasicBlock*));
memcpy(newa, from->ppOutBBs, from->outCount * sizeof(InterpBasicBlock*));
if (prevCapacity != 0)
{
memcpy(newa, from->ppOutBBs, from->outCount * sizeof(InterpBasicBlock*));
}
from->ppOutBBs = newa;
}
from->ppOutBBs [from->outCount] = to;
Expand All @@ -483,7 +486,9 @@ void InterpCompiler::LinkBBs(InterpBasicBlock *from, InterpBasicBlock *to)
int newCapacity = GetBBLinksCapacity(to->inCount + 1);
if (newCapacity > prevCapacity) {
InterpBasicBlock **newa = (InterpBasicBlock**)AllocMemPool(newCapacity * sizeof(InterpBasicBlock*));
memcpy(newa, to->ppInBBs, to->inCount * sizeof(InterpBasicBlock*));
if (prevCapacity != 0) {
memcpy(newa, to->ppInBBs, to->inCount * sizeof(InterpBasicBlock*));
}
to->ppInBBs = newa;
}
to->ppInBBs [to->inCount] = from;
Expand Down Expand Up @@ -5300,7 +5305,10 @@ void InterpCompiler::GenerateCode(CORINFO_METHOD_INFO* methodInfo)
// We need to realloc the IL code buffer to hold the extra opcodes

uint8_t* newILCode = (uint8_t*)AllocMemPool(newILCodeSize);
memcpy(newILCode, m_pILCode, m_ILCodeSize);
if (m_ILCodeSize)
{
memcpy(newILCode, m_pILCode, m_ILCodeSize);
}
memcpy(newILCode + m_synchronizedFinallyStartOffset, opCodesForSynchronizedMethodFinally, sizeof(opCodesForSynchronizedMethodFinally));
memcpy(newILCode + m_synchronizedPostFinallyOffset, opCodesForSynchronizedMethodEpilog, sizeof(opCodesForSynchronizedMethodEpilog));
m_pILCode = newILCode;
Expand Down Expand Up @@ -5512,7 +5520,10 @@ void InterpCompiler::GenerateCode(CORINFO_METHOD_INFO* methodInfo)
{
MergeStackTypeInfo(m_pStackBase, pNewBB->pStackState, pNewBB->stackHeight);
// This is relevant only for copying the vars associated with the values on the stack
memcpy(m_pStackBase, pNewBB->pStackState, pNewBB->stackHeight * sizeof(StackInfo));
if (pNewBB->stackHeight != 0)
{
memcpy(m_pStackBase, pNewBB->pStackState, pNewBB->stackHeight * sizeof(StackInfo));
}
m_pStackPointer = m_pStackBase + pNewBB->stackHeight;
}
else
Expand All @@ -5527,7 +5538,10 @@ void InterpCompiler::GenerateCode(CORINFO_METHOD_INFO* methodInfo)
if (pNewBB->stackHeight >= 0)
{
// This is relevant only for copying the vars associated with the values on the stack
memcpy (m_pStackBase, pNewBB->pStackState, pNewBB->stackHeight * sizeof(StackInfo));
if (pNewBB->stackHeight != 0)
{
memcpy (m_pStackBase, pNewBB->pStackState, pNewBB->stackHeight * sizeof(StackInfo));
}
m_pStackPointer = m_pStackBase + pNewBB->stackHeight;
pNewBB->emitState = BBStateEmitting;
emittedBBlocks = true;
Expand Down
1 change: 1 addition & 0 deletions src/coreclr/pal/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ if (NOT CLR_CMAKE_TARGET_BROWSER)
else()
add_compile_options(
-fwasm-exceptions
-mbulk-memory
-msimd128
)
add_link_options(
Expand Down
7 changes: 5 additions & 2 deletions src/coreclr/pal/src/misc/cgroup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,10 @@ class CGroup
static void Initialize()
{
s_cgroup_version = FindCGroupVersion();
FindCGroupPath(s_cgroup_version == 1 ? &IsCGroup1CpuSubsystem : nullptr, &s_cpu_cgroup_path);
if (s_cgroup_version != 0)
{
FindCGroupPath(s_cgroup_version == 1 ? &IsCGroup1CpuSubsystem : nullptr, &s_cpu_cgroup_path);
}
}

static void Cleanup()
Expand Down Expand Up @@ -84,7 +87,7 @@ class CGroup
// modes because both of those involve cgroup v1 controllers managing
// resources.

#if !HAVE_NON_LEGACY_STATFS
#if !HAVE_NON_LEGACY_STATFS || TARGET_WASM
return 0;
#else
struct statfs stats;
Expand Down
5 changes: 4 additions & 1 deletion src/coreclr/vm/methodtablebuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3678,7 +3678,10 @@ VOID MethodTableBuilder::AllocateWorkingSlotTables()

// Allocate a FieldDesc* for each field
bmtMFDescs->ppFieldDescList = new (GetStackingAllocator()) FieldDesc*[bmtMetaData->cFields];
ZeroMemory(bmtMFDescs->ppFieldDescList, bmtMetaData->cFields * sizeof(FieldDesc *));
if (bmtMetaData->cFields != 0)
{
ZeroMemory(bmtMFDescs->ppFieldDescList, bmtMetaData->cFields * sizeof(FieldDesc *));
}

// Create a temporary function table (we don't know how large the vtable will be until the very end,
// since we don't yet know how many declared methods are overrides vs. newslots).
Expand Down
3 changes: 3 additions & 0 deletions src/native/corehost/browserhost/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ set_target_properties(BrowserHost-Static PROPERTIES OUTPUT_NAME BrowserHost CLEA

target_compile_options(BrowserHost-Static PRIVATE
-fwasm-exceptions
-mbulk-memory
-msimd128
)
target_link_libraries(BrowserHost-Static PRIVATE
Expand Down Expand Up @@ -87,6 +88,7 @@ set_target_properties(browserhost PROPERTIES

target_compile_options(browserhost PRIVATE
-fwasm-exceptions
-mbulk-memory
-msimd128
)

Expand All @@ -108,6 +110,7 @@ target_link_options(browserhost PRIVATE
-sMAXIMUM_MEMORY=2147483648
-sALLOW_MEMORY_GROWTH=1
-sSTACK_SIZE=5MB
-sWASM_BIGINT=1
-sMODULARIZE=1
-sEXPORT_ES6=1
-sEXIT_RUNTIME=0
Expand Down
1 change: 1 addition & 0 deletions src/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ else()

add_compile_options(
-fwasm-exceptions
-mbulk-memory
-msimd128)
add_link_options(
-fwasm-exceptions
Expand Down
Loading