7#if V8_HAS_PKU_JIT_WRITE_PROTECT
17int pkey_mprotect(
void* addr,
size_t len,
int prot,
int pkey)
V8_WEAK;
19int pkey_set(
int,
unsigned)
V8_WEAK;
20int pkey_alloc(
unsigned int,
unsigned int)
V8_WEAK;
36 return PROT_READ | PROT_WRITE;
38 return PROT_READ | PROT_WRITE | PROT_EXEC;
46bool MemoryProtectionKey::HasMemoryProtectionKeySupport() {
47 if (!pkey_mprotect)
return false;
49 CHECK(pkey_get && pkey_set && pkey_alloc);
55int MemoryProtectionKey::AllocateKey() {
57 return kNoMemoryProtectionKey;
60 return pkey_alloc(0, 0);
64bool MemoryProtectionKey::SetPermissionsAndKey(
70 void* address =
reinterpret_cast<void*
>(region.begin());
71 size_t size = region.size();
75 return pkey_mprotect(address, size, protection,
key) == 0;
79void MemoryProtectionKey::SetPermissionsForKey(
int key,
80 Permission permissions) {
90MemoryProtectionKey::Permission MemoryProtectionKey::GetKeyPermission(
int key) {
96 int permission = pkey_get(
key);
97 CHECK(permission == kNoRestrictions || permission == kDisableAccess ||
98 permission == kDisableWrite);
99 return static_cast<Permission
>(permission);
int GetProtectionFromMemoryPermission(OS::MemoryPermission access)
#define DCHECK_NOT_NULL(val)
#define CHECK_NOT_NULL(val)
#define DCHECK_NE(v1, v2)
#define CHECK_EQ(lhs, rhs)
std::unique_ptr< ValueMirror > key