V8 Project
v8::base::VirtualMemory Class Reference

#include <platform.h>

+ Collaboration diagram for v8::base::VirtualMemory:

Public Member Functions

 VirtualMemory ()
 
 VirtualMemory (size_t size)
 
 VirtualMemory (size_t size, size_t alignment)
 
 ~VirtualMemory ()
 
bool IsReserved ()
 
void Reset ()
 
void * address ()
 
size_t size ()
 
bool Commit (void *address, size_t size, bool is_executable)
 
bool Uncommit (void *address, size_t size)
 
bool Guard (void *address)
 
void Release ()
 
void TakeControl (VirtualMemory *from)
 

Static Public Member Functions

static void * ReserveRegion (size_t size)
 
static bool CommitRegion (void *base, size_t size, bool is_executable)
 
static bool UncommitRegion (void *base, size_t size)
 
static bool ReleaseRegion (void *base, size_t size)
 
static bool HasLazyCommits ()
 

Private Attributes

void * address_
 
size_t size_
 

Detailed Description

Definition at line 316 of file platform.h.

Constructor & Destructor Documentation

◆ VirtualMemory() [1/3]

v8::base::VirtualMemory::VirtualMemory ( )

Definition at line 199 of file platform-cygwin.cc.

199 : address_(NULL), size_(0) { }
enable harmony numeric enable harmony object literal extensions Optimize object Array DOM strings and string trace pretenuring decisions of HAllocate instructions Enables optimizations which favor memory size over execution speed maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining trace the tracking of allocation sites deoptimize every n garbage collections perform array bounds checks elimination analyze liveness of environment slots and zap dead values flushes the cache of optimized code for closures on every GC allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes enable context specialization in TurboFan execution budget before interrupt is triggered max percentage of megamorphic generic ICs to allow optimization enable use of SAHF instruction if enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV instructions if enable use of MLS instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of d16 d31 registers on ARM this requires VFP3 force all emitted branches to be in long enable alignment of csp to bytes on platforms which prefer the register to always be NULL

◆ VirtualMemory() [2/3]

v8::base::VirtualMemory::VirtualMemory ( size_t  size)
explicit

Definition at line 202 of file platform-cygwin.cc.

static void * ReserveRegion(size_t size)

◆ VirtualMemory() [3/3]

v8::base::VirtualMemory::VirtualMemory ( size_t  size,
size_t  alignment 
)

Definition at line 206 of file platform-cygwin.cc.

207  : address_(NULL), size_(0) {
208  DCHECK((alignment % OS::AllocateAlignment()) == 0);
209  size_t request_size = RoundUp(size + alignment,
210  static_cast<intptr_t>(OS::AllocateAlignment()));
211  void* address = ReserveRegion(request_size);
212  if (address == NULL) return;
213  uint8_t* base = RoundUp(static_cast<uint8_t*>(address), alignment);
214  // Try reducing the size by freeing and then reallocating a specific area.
215  bool result = ReleaseRegion(address, request_size);
216  USE(result);
217  DCHECK(result);
218  address = VirtualAlloc(base, size, MEM_RESERVE, PAGE_NOACCESS);
219  if (address != NULL) {
220  request_size = size;
221  DCHECK(base == static_cast<uint8_t*>(address));
222  } else {
223  // Resizing failed, just go with a bigger area.
224  address = ReserveRegion(request_size);
225  if (address == NULL) return;
226  }
227  address_ = address;
228  size_ = request_size;
229 }
static size_t AllocateAlignment()
static bool ReleaseRegion(void *base, size_t size)
#define DCHECK(condition)
Definition: logging.h:205
void USE(T)
Definition: macros.h:322
T RoundUp(T x, intptr_t m)
Definition: macros.h:407

References address(), address_, v8::base::OS::AllocateAlignment(), DCHECK, NULL, ReleaseRegion(), ReserveRegion(), RoundUp(), size(), size_, and USE().

+ Here is the call graph for this function:

◆ ~VirtualMemory()

v8::base::VirtualMemory::~VirtualMemory ( )

Definition at line 232 of file platform-cygwin.cc.

232  {
233  if (IsReserved()) {
234  bool result = ReleaseRegion(address_, size_);
235  DCHECK(result);
236  USE(result);
237  }
238 }

References address_, DCHECK, IsReserved(), ReleaseRegion(), size_, and USE().

+ Here is the call graph for this function:

Member Function Documentation

◆ address()

void* v8::base::VirtualMemory::address ( )
inline

Definition at line 343 of file platform.h.

343  {
344  DCHECK(IsReserved());
345  return address_;
346  }

References address_, DCHECK, and IsReserved().

Referenced by Commit(), v8::internal::CodeRange::contains(), v8::internal::IncrementalMarking::EnsureMarkingDequeIsCommitted(), v8::internal::MemoryAllocator::FreeMemory(), Guard(), Release(), v8::internal::MemoryAllocator::ReserveAlignedMemory(), v8::internal::StoreBuffer::SetUp(), v8::internal::CodeRange::SetUp(), v8::internal::CodeRange::start(), v8::internal::IncrementalMarking::StartMarking(), Uncommit(), v8::internal::IncrementalMarking::UncommitMarkingDeque(), and VirtualMemory().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Commit()

bool v8::base::VirtualMemory::Commit ( void *  address,
size_t  size,
bool  is_executable 
)

Definition at line 252 of file platform-cygwin.cc.

252  {
253  return CommitRegion(address, size, is_executable);
254 }
static bool CommitRegion(void *base, size_t size, bool is_executable)

References address(), CommitRegion(), and size().

Referenced by v8::internal::MemoryAllocator::AllocateAlignedMemory(), v8::internal::MemoryAllocator::CommitExecutableMemory(), v8::internal::IncrementalMarking::EnsureMarkingDequeIsCommitted(), v8::internal::StoreBuffer::EnsureSpace(), and v8::internal::StoreBuffer::SetUp().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CommitRegion()

bool v8::base::VirtualMemory::CommitRegion ( void *  base,
size_t  size,
bool  is_executable 
)
static

Definition at line 268 of file platform-cygwin.cc.

268  {
269  int prot = is_executable ? PAGE_EXECUTE_READWRITE : PAGE_READWRITE;
270  if (NULL == VirtualAlloc(base, size, MEM_COMMIT, prot)) {
271  return false;
272  }
273  return true;
274 }

References NULL, and size().

Referenced by Commit(), and v8::internal::MemoryAllocator::CommitMemory().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Guard()

bool v8::base::VirtualMemory::Guard ( void *  address)

Definition at line 277 of file platform-cygwin.cc.

277  {
278  if (NULL == VirtualAlloc(address,
280  MEM_COMMIT,
281  PAGE_NOACCESS)) {
282  return false;
283  }
284  return true;
285 }
static intptr_t CommitPageSize()

References address(), v8::base::OS::CommitPageSize(), and NULL.

Referenced by v8::internal::MemoryAllocator::CommitExecutableMemory().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ HasLazyCommits()

bool v8::base::VirtualMemory::HasLazyCommits ( )
static

Definition at line 298 of file platform-cygwin.cc.

298  {
299  // TODO(alph): implement for the platform.
300  return false;
301 }

Referenced by v8::internal::PagedSpace::CommittedPhysicalMemory(), v8::internal::NewSpace::CommittedPhysicalMemory(), and v8::internal::LargeObjectSpace::CommittedPhysicalMemory().

+ Here is the caller graph for this function:

◆ IsReserved()

bool v8::base::VirtualMemory::IsReserved ( )

Definition at line 241 of file platform-cygwin.cc.

241  {
242  return address_ != NULL;
243 }

References address_, and NULL.

Referenced by address(), v8::internal::MemoryChunk::CommitArea(), v8::internal::MemoryAllocator::Free(), v8::internal::MemoryAllocator::FreeMemory(), Release(), v8::internal::MemoryAllocator::ReserveAlignedMemory(), v8::internal::CodeRange::SetUp(), TakeControl(), v8::internal::NewSpace::TearDown(), Uncommit(), and ~VirtualMemory().

+ Here is the caller graph for this function:

◆ Release()

void v8::base::VirtualMemory::Release ( )
inline

Definition at line 363 of file platform.h.

363  {
364  DCHECK(IsReserved());
365  // Notice: Order is important here. The VirtualMemory object might live
366  // inside the allocated region.
367  void* address = address_;
368  size_t size = size_;
369  Reset();
370  bool result = ReleaseRegion(address, size);
371  USE(result);
372  DCHECK(result);
373  }

References address(), address_, DCHECK, IsReserved(), ReleaseRegion(), Reset(), size(), size_, and USE().

Referenced by v8::internal::MemoryAllocator::AllocateAlignedMemory(), and v8::internal::MemoryAllocator::FreeMemory().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ReleaseRegion()

bool v8::base::VirtualMemory::ReleaseRegion ( void *  base,
size_t  size 
)
static

Definition at line 293 of file platform-cygwin.cc.

293  {
294  return VirtualFree(base, 0, MEM_RELEASE) != 0;
295 }

Referenced by v8::internal::MemoryAllocator::FreeMemory(), Release(), VirtualMemory(), and ~VirtualMemory().

+ Here is the caller graph for this function:

◆ ReserveRegion()

void * v8::base::VirtualMemory::ReserveRegion ( size_t  size)
static

Definition at line 263 of file platform-cygwin.cc.

263  {
264  return RandomizedVirtualAlloc(size, MEM_RESERVE, PAGE_NOACCESS);
265 }
static void * RandomizedVirtualAlloc(size_t size, int action, int protection)

References v8::base::RandomizedVirtualAlloc(), and size().

Referenced by VirtualMemory().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Reset()

void v8::base::VirtualMemory::Reset ( )

Definition at line 246 of file platform-cygwin.cc.

246  {
247  address_ = NULL;
248  size_ = 0;
249 }

References address_, NULL, and size_.

Referenced by v8::internal::MemoryChunk::InitializeReservedMemory(), Release(), and TakeControl().

+ Here is the caller graph for this function:

◆ size()

◆ TakeControl()

void v8::base::VirtualMemory::TakeControl ( VirtualMemory from)
inline

Definition at line 377 of file platform.h.

377  {
378  DCHECK(!IsReserved());
379  address_ = from->address_;
380  size_ = from->size_;
381  from->Reset();
382  }

References address_, DCHECK, IsReserved(), Reset(), and size_.

Referenced by v8::internal::MemoryAllocator::AllocateAlignedMemory(), v8::internal::MemoryAllocator::ReserveAlignedMemory(), and v8::internal::MemoryChunk::set_reserved_memory().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Uncommit()

bool v8::base::VirtualMemory::Uncommit ( void *  address,
size_t  size 
)

Definition at line 257 of file platform-cygwin.cc.

257  {
258  DCHECK(IsReserved());
259  return UncommitRegion(address, size);
260 }
static bool UncommitRegion(void *base, size_t size)

References address(), DCHECK, IsReserved(), size(), and UncommitRegion().

Referenced by v8::internal::MemoryChunk::CommitArea(), v8::internal::CodeRange::FreeRawMemory(), v8::internal::IncrementalMarking::UncommitMarkingDeque(), and v8::internal::CodeRange::UncommitRawMemory().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ UncommitRegion()

bool v8::base::VirtualMemory::UncommitRegion ( void *  base,
size_t  size 
)
static

Definition at line 288 of file platform-cygwin.cc.

288  {
289  return VirtualFree(base, size, MEM_DECOMMIT) != 0;
290 }

References size().

Referenced by Uncommit(), and v8::internal::MemoryAllocator::UncommitBlock().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ address_

void* v8::base::VirtualMemory::address_
private

Definition at line 400 of file platform.h.

Referenced by address(), IsReserved(), Release(), Reset(), TakeControl(), VirtualMemory(), and ~VirtualMemory().

◆ size_

size_t v8::base::VirtualMemory::size_
private

Definition at line 401 of file platform.h.

Referenced by Release(), Reset(), size(), TakeControl(), VirtualMemory(), and ~VirtualMemory().


The documentation for this class was generated from the following files: