Skip to content
Closed
Show file tree
Hide file tree
Changes from all 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
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 <jkummerow@chromium.org>
    Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
    Auto-Submit: Jakob Kummerow <jkummerow@chromium.org>
    Reviewed-by: Michael Lippautz <mlippautz@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#72559}

Refs: v8/v8@0c8b6e4
  • Loading branch information
mcollina committed Feb 9, 2021
commit f1d20b91a4889e8c9b768db2885036e6901607f1
2 changes: 1 addition & 1 deletion common.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

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

##### V8 defaults for Node.js #####

Expand Down
10 changes: 10 additions & 0 deletions deps/v8/src/base/platform/platform-posix.cc
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,16 @@ bool OS::SetPermissions(void* address, size_t size, MemoryPermission access) {

int prot = GetProtectionFromMemoryPermission(access);
int ret = mprotect(address, size, prot);

// MacOS 11.2 on Apple Silicon refuses to switch permissions from
// rwx to none. Just use madvise instead.
#if defined(V8_OS_MACOSX)
if (ret != 0 && access == OS::MemoryPermission::kNoAccess) {
ret = madvise(address, size, MADV_FREE_REUSABLE);
return ret == 0;
}
#endif

if (ret == 0 && access == OS::MemoryPermission::kNoAccess) {
// This is advisory; ignore errors and continue execution.
USE(DiscardSystemPages(address, size));
Expand Down
57 changes: 57 additions & 0 deletions deps/v8/src/heap/remembered-set-inl.h~HEAD
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// Copyright 2016 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef V8_HEAP_REMEMBERED_SET_INL_H_
#define V8_HEAP_REMEMBERED_SET_INL_H_

#include "src/common/ptr-compr-inl.h"
#include "src/heap/remembered-set.h"

namespace v8 {
namespace internal {

template <typename Callback>
SlotCallbackResult UpdateTypedSlotHelper::UpdateTypedSlot(Heap* heap,
SlotType slot_type,
Address addr,
Callback callback) {
switch (slot_type) {
case CODE_TARGET_SLOT: {
RelocInfo rinfo(addr, RelocInfo::CODE_TARGET, 0, Code());
return UpdateCodeTarget(&rinfo, callback);
}
case CODE_ENTRY_SLOT: {
return UpdateCodeEntry(addr, callback);
}
case COMPRESSED_EMBEDDED_OBJECT_SLOT: {
RelocInfo rinfo(addr, RelocInfo::COMPRESSED_EMBEDDED_OBJECT, 0, Code());
return UpdateEmbeddedPointer(heap, &rinfo, callback);
}
case FULL_EMBEDDED_OBJECT_SLOT: {
RelocInfo rinfo(addr, RelocInfo::FULL_EMBEDDED_OBJECT, 0, Code());
return UpdateEmbeddedPointer(heap, &rinfo, callback);
}
case COMPRESSED_OBJECT_SLOT: {
HeapObject old_target = HeapObject::cast(Object(
DecompressTaggedAny(heap->isolate(), base::Memory<Tagged_t>(addr))));
HeapObject new_target = old_target;
SlotCallbackResult result = callback(FullMaybeObjectSlot(&new_target));
DCHECK(!HasWeakHeapObjectTag(new_target));
if (new_target != old_target) {
base::Memory<Tagged_t>(addr) = CompressTagged(new_target.ptr());
}
return result;
}
case FULL_OBJECT_SLOT: {
return callback(FullMaybeObjectSlot(addr));
}
case CLEARED_SLOT:
break;
}
UNREACHABLE();
}

} // namespace internal
} // namespace v8
#endif // V8_HEAP_REMEMBERED_SET_INL_H_