#ifndef V8_COMMON_CODE_MEMORY_ACCESS_INL_H_
#define V8_COMMON_CODE_MEMORY_ACCESS_INL_H_
#include "src/common/code-memory-access.h"
#include "src/flags/flags.h"
#include "src/objects/instruction-stream.h"
#include "src/objects/slots-inl.h"
#include "src/objects/tagged.h"
#if V8_HAS_PKU_JIT_WRITE_PROTECT
#include "src/base/platform/memory-protection-key.h"
#endif
#if V8_HAS_PTHREAD_JIT_WRITE_PROTECT
#include "src/base/platform/platform.h"
#endif
#if V8_HAS_BECORE_JIT_WRITE_PROTECT
#include <BrowserEngineCore/BEMemory.h>
#endif
namespace v8 {
namespace internal {
RwxMemoryWriteScope::RwxMemoryWriteScope(const char* comment) { … }
RwxMemoryWriteScope::~RwxMemoryWriteScope() { … }
WritableJitAllocation::~WritableJitAllocation() = default;
WritableJitAllocation::WritableJitAllocation(
Address addr, size_t size, ThreadIsolation::JitAllocationType type,
JitAllocationSource source)
: … { … }
WritableJitAllocation::WritableJitAllocation(
Address addr, size_t size, ThreadIsolation::JitAllocationType type)
: … { … }
WritableJitAllocation WritableJitAllocation::ForNonExecutableMemory(
Address addr, size_t size, ThreadIsolation::JitAllocationType type) { … }
WritableJumpTablePair::WritableJumpTablePair(Address jump_table_address,
size_t jump_table_size,
Address far_jump_table_address,
size_t far_jump_table_size)
: … { … }
template <typename T, size_t offset>
void WritableJitAllocation::WriteHeaderSlot(T value) { … }
template <typename T, size_t offset>
void WritableJitAllocation::WriteHeaderSlot(Tagged<T> value, ReleaseStoreTag) { … }
template <typename T, size_t offset>
void WritableJitAllocation::WriteHeaderSlot(Tagged<T> value, RelaxedStoreTag) { … }
template <typename T, size_t offset>
void WritableJitAllocation::WriteProtectedPointerHeaderSlot(Tagged<T> value,
RelaxedStoreTag) { … }
template <typename T>
V8_INLINE void WritableJitAllocation::WriteHeaderSlot(Address address, T value,
RelaxedStoreTag tag) { … }
void WritableJitAllocation::CopyCode(size_t dst_offset, const uint8_t* src,
size_t num_bytes) { … }
void WritableJitAllocation::CopyData(size_t dst_offset, const uint8_t* src,
size_t num_bytes) { … }
void WritableJitAllocation::ClearBytes(size_t offset, size_t len) { … }
WritableJitPage::~WritableJitPage() = default;
WritableJitPage::WritableJitPage(Address addr, size_t size)
: … { … }
WritableJitAllocation WritableJitPage::LookupAllocationContaining(
Address addr) { … }
V8_INLINE WritableFreeSpace WritableJitPage::FreeRange(Address addr,
size_t size) { … }
WritableFreeSpace::~WritableFreeSpace() = default;
V8_INLINE WritableFreeSpace
WritableFreeSpace::ForNonExecutableMemory(base::Address addr, size_t size) { … }
V8_INLINE WritableFreeSpace::WritableFreeSpace(base::Address addr, size_t size,
bool executable)
: … { … }
template <typename T, size_t offset>
void WritableFreeSpace::WriteHeaderSlot(Tagged<T> value,
RelaxedStoreTag) const { … }
#if V8_HAS_PTHREAD_JIT_WRITE_PROTECT
bool RwxMemoryWriteScope::IsSupported() { return true; }
void RwxMemoryWriteScope::SetWritable() { base::SetJitWriteProtected(0); }
void RwxMemoryWriteScope::SetExecutable() { base::SetJitWriteProtected(1); }
#elif V8_HAS_BECORE_JIT_WRITE_PROTECT
bool RwxMemoryWriteScope::IsSupported() {
return be_memory_inline_jit_restrict_with_witness_supported() != 0;
}
void RwxMemoryWriteScope::SetWritable() {
be_memory_inline_jit_restrict_rwx_to_rw_with_witness();
}
void RwxMemoryWriteScope::SetExecutable() {
be_memory_inline_jit_restrict_rwx_to_rx_with_witness();
}
#elif V8_HAS_PKU_JIT_WRITE_PROTECT
bool RwxMemoryWriteScope::IsSupported() { … }
void RwxMemoryWriteScope::SetWritable() { … }
void RwxMemoryWriteScope::SetExecutable() { … }
#else
bool RwxMemoryWriteScope::IsSupported() { return false; }
void RwxMemoryWriteScope::SetWritable() {}
void RwxMemoryWriteScope::SetExecutable() {}
#endif
}
}
#endif