Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
12 changes: 8 additions & 4 deletions src/coreclr/gc/unix/gcenv.unix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -520,13 +520,13 @@ bool GCToOSInterface::VirtualDecommit(void* address, size_t size)
#endif
bool bRetVal = mmap(address, size, PROT_NONE, mmapFlags, -1, 0) != MAP_FAILED;

#ifdef MADV_DONTDUMP
#if defined(MADV_DONTDUMP) && !defined(TARGET_WASM)
if (bRetVal)
{
// Do not include freed memory in coredump.
madvise(address, size, MADV_DONTDUMP);
}
#endif
#endif // defined(MADV_DONTDUMP) && !defined(TARGET_WASM)

return bRetVal;
}
Expand All @@ -541,6 +541,10 @@ bool GCToOSInterface::VirtualDecommit(void* address, size_t size)
// true if it has succeeded, false if it has failed
bool GCToOSInterface::VirtualReset(void * address, size_t size, bool unlock)
{
#ifdef TARGET_WASM
return true;
#endif // TARGET_WASM

int st = EINVAL;

#if defined(MADV_DONTDUMP) || defined(HAVE_MADV_FREE)
Expand All @@ -560,14 +564,14 @@ bool GCToOSInterface::VirtualReset(void * address, size_t size, bool unlock)

st = madvise(address, size, madviseFlags);

#endif //defined(MADV_DONTDUMP) || defined(HAVE_MADV_FREE)
#endif // defined(MADV_DONTDUMP) || defined(HAVE_MADV_FREE)

#if defined(HAVE_POSIX_MADVISE) && !defined(MADV_DONTDUMP)
// DONTNEED is the nearest posix equivalent of FREE.
// Prefer FREE as, since glibc2.6 DONTNEED is a nop.
st = posix_madvise(address, size, POSIX_MADV_DONTNEED);

#endif //defined(HAVE_POSIX_MADVISE) && !defined(MADV_DONTDUMP)
#endif // defined(HAVE_POSIX_MADVISE) && !defined(MADV_DONTDUMP)

return (st == 0);
}
Expand Down
4 changes: 2 additions & 2 deletions src/coreclr/pal/src/map/map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2551,7 +2551,7 @@ BOOL MAPMarkSectionAsNotNeeded(LPCVOID lpAddress)

BOOL retval = TRUE;

#ifndef TARGET_ANDROID
#if !defined(TARGET_ANDROID) && !defined(TARGET_WASM)
minipal_mutex_enter(&mapping_critsec);
PLIST_ENTRY pLink, pLinkNext = NULL;

Expand Down Expand Up @@ -2581,7 +2581,7 @@ BOOL MAPMarkSectionAsNotNeeded(LPCVOID lpAddress)
}

minipal_mutex_leave(&mapping_critsec);
#endif // TARGET_ANDROID
#endif // !TARGET_ANDROID && !TARGET_WASM

TRACE_(LOADER)("MAPMarkSectionAsNotNeeded returning %d\n", retval);
return retval;
Expand Down
4 changes: 2 additions & 2 deletions src/native/libs/System.Native/pal_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -1036,13 +1036,13 @@ int32_t SystemNative_MAdvise(void* address, uint64_t length, int32_t advice)
switch (advice)
{
case PAL_MADV_DONTFORK:
#if defined(MADV_DONTFORK) && !defined(TARGET_WASI)
#if defined(MADV_DONTFORK) && !defined(TARGET_WASI) && !defined(TARGET_WASM)
return madvise(address, (size_t)length, MADV_DONTFORK);
#else
(void)address, (void)length, (void)advice;
errno = ENOTSUP;
return -1;
#endif
#endif // MADV_DONTFORK && !TARGET_WASI && !TARGET_WASM
default:
break; // fall through to error
}
Expand Down
Loading