#include "src/init/isolate-group.h"
#include "src/base/bounded-page-allocator.h"
#include "src/base/platform/memory.h"
#include "src/common/ptr-compr-inl.h"
#include "src/execution/isolate.h"
#include "src/heap/code-range.h"
#include "src/heap/trusted-range.h"
#include "src/sandbox/sandbox.h"
#include "src/utils/memcopy.h"
#include "src/utils/utils.h"
namespace v8 {
namespace internal {
#ifdef V8_COMPRESS_POINTERS_IN_MULTIPLE_CAGES
thread_local IsolateGroup* IsolateGroup::current_ = nullptr;
IsolateGroup* IsolateGroup::current_non_inlined() { return current_; }
void IsolateGroup::set_current_non_inlined(IsolateGroup* group) {
current_ = group;
}
#endif
#ifdef V8_COMPRESS_POINTERS
struct PtrComprCageReservationParams
: public VirtualMemoryCage::ReservationParams { … };
#endif
#ifndef V8_COMPRESS_POINTERS_IN_MULTIPLE_CAGES
IsolateGroup* IsolateGroup::GetProcessWideIsolateGroup() { … }
#endif
IsolateGroup::IsolateGroup() { … }
IsolateGroup::~IsolateGroup() { … }
#ifdef V8_ENABLE_SANDBOX
void IsolateGroup::Initialize(bool process_wide, Sandbox* sandbox) { … }
#elif defined(V8_COMPRESS_POINTERS)
void IsolateGroup::Initialize(bool process_wide) {
DCHECK(!reservation_.IsReserved());
process_wide_ = process_wide;
PtrComprCageReservationParams params;
if (!reservation_.InitReservation(params)) {
V8::FatalProcessOutOfMemory(
nullptr,
"Failed to reserve virtual memory for process-wide V8 "
"pointer compression cage");
}
page_allocator_ = reservation_.page_allocator();
pointer_compression_cage_ = &reservation_;
trusted_pointer_compression_cage_ = &reservation_;
}
#else
void IsolateGroup::Initialize(bool process_wide) {
process_wide_ = process_wide;
page_allocator_ = GetPlatformPageAllocator();
}
#endif
void IsolateGroup::InitializeOncePerProcess() { … }
namespace {
void InitCodeRangeOnce(std::unique_ptr<CodeRange>* code_range_member,
v8::PageAllocator* page_allocator, size_t requested_size,
bool immutable) { … }
}
CodeRange* IsolateGroup::EnsureCodeRange(size_t requested_size) { … }
IsolateGroup* IsolateGroup::New() { … }
IsolateGroup* IsolateGroup::AcquireGlobal() { … }
void IsolateGroup::ReleaseGlobal() { … }
}
}