Skip to content

Commit 50e81ba

Browse files
matinzddanielleadams
authored andcommitted
deps: V8: cherry-pick 0c8b6e415c30
Original commit message: [mac][wasm] Work around MacOS 11.2 code page decommit failures MacOS 11.2 refuses to set "no access" permissions on memory that we previously used for JIT-compiled code. It is still unclear whether this is WAI on the part of the kernel. In the meantime, as a workaround, we use madvise(..., MADV_FREE_REUSABLE) instead of mprotect(..., NONE) when discarding code pages. This is inspired by what Chromium's gin platform does. Fixed: v8:11389 Change-Id: I866586932573b4253002436ae5eee4e0411c45fc Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2679688 Commit-Queue: Jakob Kummerow <[email protected]> Commit-Queue: Michael Lippautz <[email protected]> Auto-Submit: Jakob Kummerow <[email protected]> Reviewed-by: Michael Lippautz <[email protected]> Cr-Commit-Position: refs/heads/master@{#72559} Refs: v8/v8@0c8b6e4 Fixes: #37061 PR-URL: #37276 Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Ash Cripps <[email protected]>
1 parent 3464c9f commit 50e81ba

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

common.gypi

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636

3737
# Reset this number to 0 on major V8 upgrades.
3838
# Increment by one for each non-official patch applied to deps/v8.
39-
'v8_embedder_string': '-node.24',
39+
'v8_embedder_string': '-node.25',
4040

4141
##### V8 defaults for Node.js #####
4242

deps/v8/src/base/platform/platform-posix.cc

+10
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,16 @@ bool OS::SetPermissions(void* address, size_t size, MemoryPermission access) {
414414

415415
int prot = GetProtectionFromMemoryPermission(access);
416416
int ret = mprotect(address, size, prot);
417+
418+
// MacOS 11.2 on Apple Silicon refuses to switch permissions from
419+
// rwx to none. Just use madvise instead.
420+
#if defined(V8_OS_MACOSX)
421+
if (ret != 0 && access == OS::MemoryPermission::kNoAccess) {
422+
ret = madvise(address, size, MADV_FREE_REUSABLE);
423+
return ret == 0;
424+
}
425+
#endif
426+
417427
if (ret == 0 && access == OS::MemoryPermission::kNoAccess) {
418428
// This is advisory; ignore errors and continue execution.
419429
USE(DiscardSystemPages(address, size));

0 commit comments

Comments
 (0)