V8 Project
v8::ResourceConstraints Class Reference

A set of constraints that specifies the limits of the runtime's memory use. More...

#include <v8.h>

+ Collaboration diagram for v8::ResourceConstraints:

Public Member Functions

 ResourceConstraints ()
 
void ConfigureDefaults (uint64_t physical_memory, uint64_t virtual_memory_limit, uint32_t number_of_processors)
 Configures the constraints with reasonable default values based on the capabilities of the current device the VM is running on. More...
 
int max_semi_space_size () const
 
void set_max_semi_space_size (int value)
 
int max_old_space_size () const
 
void set_max_old_space_size (int value)
 
int max_executable_size () const
 
void set_max_executable_size (int value)
 
uint32_tstack_limit () const
 
void set_stack_limit (uint32_t *value)
 
int max_available_threads () const
 
void set_max_available_threads (int value)
 
size_t code_range_size () const
 
void set_code_range_size (size_t value)
 

Private Attributes

int max_semi_space_size_
 
int max_old_space_size_
 
int max_executable_size_
 
uint32_tstack_limit_
 
int max_available_threads_
 
size_t code_range_size_
 

Detailed Description

A set of constraints that specifies the limits of the runtime's memory use.

You must set the heap size before initializing the VM - the size cannot be adjusted after the VM is initialized.

If you are using threads then you should hold the V8::Locker lock while setting the stack limit and you must set a non-default stack limit separately for each thread.

Definition at line 4066 of file v8.h.

Constructor & Destructor Documentation

◆ ResourceConstraints()

v8::ResourceConstraints::ResourceConstraints ( )

Definition at line 421 of file api.cc.

427  code_range_size_(0) { }
uint32_t * stack_limit_
Definition: v8.h:4108
int max_semi_space_size_
Definition: v8.h:4105
int max_available_threads_
Definition: v8.h:4109
int max_executable_size_
Definition: v8.h:4107
size_t code_range_size_
Definition: v8.h:4110
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

Member Function Documentation

◆ code_range_size()

size_t v8::ResourceConstraints::code_range_size ( ) const
inline

Definition at line 4099 of file v8.h.

4099 { return code_range_size_; }

Referenced by v8::SetResourceConstraints().

+ Here is the caller graph for this function:

◆ ConfigureDefaults()

void v8::ResourceConstraints::ConfigureDefaults ( uint64_t  physical_memory,
uint64_t  virtual_memory_limit,
uint32_t  number_of_processors 
)

Configures the constraints with reasonable default values based on the capabilities of the current device the VM is running on.

Parameters
physical_memoryThe total amount of physical memory on the current device, in bytes.
virtual_memory_limitThe amount of virtual memory on the current device, in bytes, or zero, if there is no limit.
number_of_processorsThe number of CPUs available on the current device.

Definition at line 429 of file api.cc.

431  {
432 #if V8_OS_ANDROID
433  // Android has higher physical memory requirements before raising the maximum
434  // heap size limits since it has no swap space.
435  const uint64_t low_limit = 512ul * i::MB;
436  const uint64_t medium_limit = 1ul * i::GB;
437  const uint64_t high_limit = 2ul * i::GB;
438 #else
439  const uint64_t low_limit = 512ul * i::MB;
440  const uint64_t medium_limit = 768ul * i::MB;
441  const uint64_t high_limit = 1ul * i::GB;
442 #endif
443 
444  if (physical_memory <= low_limit) {
448  } else if (physical_memory <= medium_limit) {
452  } else if (physical_memory <= high_limit) {
456  } else {
460  }
461 
462  set_max_available_threads(i::Max(i::Min(number_of_processors, 4u), 1u));
463 
464  if (virtual_memory_limit > 0 && i::kRequiresCodeRange) {
465  // Reserve no more than 1/8 of the memory for the code range, but at most
466  // kMaximalCodeRangeSize.
469  static_cast<size_t>((virtual_memory_limit >> 3) / i::MB)));
470  }
471 }
void set_max_available_threads(int value)
Definition: v8.h:4096
void set_max_executable_size(int value)
Definition: v8.h:4090
void set_max_old_space_size(int value)
Definition: v8.h:4088
void set_max_semi_space_size(int value)
Definition: v8.h:4086
void set_code_range_size(size_t value)
Definition: v8.h:4100
static const int kMaxSemiSpaceSizeHighMemoryDevice
Definition: heap.h:1019
static const int kMaxOldSpaceSizeHighMemoryDevice
Definition: heap.h:1027
static const int kMaxExecutableSizeHighMemoryDevice
Definition: heap.h:1035
static const int kMaxOldSpaceSizeMediumMemoryDevice
Definition: heap.h:1025
static const int kMaxExecutableSizeHugeMemoryDevice
Definition: heap.h:1037
static const int kMaxExecutableSizeMediumMemoryDevice
Definition: heap.h:1033
static const int kMaxOldSpaceSizeHugeMemoryDevice
Definition: heap.h:1028
static const int kMaxOldSpaceSizeLowMemoryDevice
Definition: heap.h:1024
static const int kMaxSemiSpaceSizeHugeMemoryDevice
Definition: heap.h:1020
static const int kMaxSemiSpaceSizeMediumMemoryDevice
Definition: heap.h:1018
static const int kMaxExecutableSizeLowMemoryDevice
Definition: heap.h:1032
static const int kMaxSemiSpaceSizeLowMemoryDevice
Definition: heap.h:1017
static LifetimePosition Max(LifetimePosition a, LifetimePosition b)
static LifetimePosition Min(LifetimePosition a, LifetimePosition b)
const size_t kMaximalCodeRangeSize
Definition: globals.h:156
const bool kRequiresCodeRange
Definition: globals.h:155
const int GB
Definition: globals.h:108
const int MB
Definition: d8.cc:164

References v8::internal::GB, v8::internal::Heap::kMaxExecutableSizeHighMemoryDevice, v8::internal::Heap::kMaxExecutableSizeHugeMemoryDevice, v8::internal::Heap::kMaxExecutableSizeLowMemoryDevice, v8::internal::Heap::kMaxExecutableSizeMediumMemoryDevice, v8::internal::kMaximalCodeRangeSize, v8::internal::Heap::kMaxOldSpaceSizeHighMemoryDevice, v8::internal::Heap::kMaxOldSpaceSizeHugeMemoryDevice, v8::internal::Heap::kMaxOldSpaceSizeLowMemoryDevice, v8::internal::Heap::kMaxOldSpaceSizeMediumMemoryDevice, v8::internal::Heap::kMaxSemiSpaceSizeHighMemoryDevice, v8::internal::Heap::kMaxSemiSpaceSizeHugeMemoryDevice, v8::internal::Heap::kMaxSemiSpaceSizeLowMemoryDevice, v8::internal::Heap::kMaxSemiSpaceSizeMediumMemoryDevice, v8::internal::kRequiresCodeRange, v8::internal::compiler::Max(), v8::MB, v8::internal::compiler::Min(), set_code_range_size(), set_max_available_threads(), set_max_executable_size(), set_max_old_space_size(), and set_max_semi_space_size().

Referenced by v8::Shell::Main().

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

◆ max_available_threads()

int v8::ResourceConstraints::max_available_threads ( ) const
inline

Definition at line 4094 of file v8.h.

4094 { return max_available_threads_; }

Referenced by v8::SetResourceConstraints().

+ Here is the caller graph for this function:

◆ max_executable_size()

int v8::ResourceConstraints::max_executable_size ( ) const
inline

Definition at line 4089 of file v8.h.

4089 { return max_executable_size_; }

Referenced by v8::SetResourceConstraints().

+ Here is the caller graph for this function:

◆ max_old_space_size()

int v8::ResourceConstraints::max_old_space_size ( ) const
inline

Definition at line 4087 of file v8.h.

4087 { return max_old_space_size_; }

Referenced by v8::SetResourceConstraints().

+ Here is the caller graph for this function:

◆ max_semi_space_size()

int v8::ResourceConstraints::max_semi_space_size ( ) const
inline

Definition at line 4085 of file v8.h.

4085 { return max_semi_space_size_; }

Referenced by v8::SetResourceConstraints().

+ Here is the caller graph for this function:

◆ set_code_range_size()

void v8::ResourceConstraints::set_code_range_size ( size_t  value)
inline

Definition at line 4100 of file v8.h.

4100  {
4101  code_range_size_ = value;
4102  }

Referenced by ConfigureDefaults().

+ Here is the caller graph for this function:

◆ set_max_available_threads()

void v8::ResourceConstraints::set_max_available_threads ( int  value)
inline

Definition at line 4096 of file v8.h.

4096  {
4097  max_available_threads_ = value;
4098  }

Referenced by ConfigureDefaults().

+ Here is the caller graph for this function:

◆ set_max_executable_size()

void v8::ResourceConstraints::set_max_executable_size ( int  value)
inline

Definition at line 4090 of file v8.h.

4090 { max_executable_size_ = value; }

Referenced by ConfigureDefaults().

+ Here is the caller graph for this function:

◆ set_max_old_space_size()

void v8::ResourceConstraints::set_max_old_space_size ( int  value)
inline

Definition at line 4088 of file v8.h.

4088 { max_old_space_size_ = value; }

Referenced by ConfigureDefaults().

+ Here is the caller graph for this function:

◆ set_max_semi_space_size()

void v8::ResourceConstraints::set_max_semi_space_size ( int  value)
inline

Definition at line 4086 of file v8.h.

4086 { max_semi_space_size_ = value; }

Referenced by ConfigureDefaults().

+ Here is the caller graph for this function:

◆ set_stack_limit()

void v8::ResourceConstraints::set_stack_limit ( uint32_t value)
inline

Definition at line 4093 of file v8.h.

4093 { stack_limit_ = value; }

◆ stack_limit()

uint32_t* v8::ResourceConstraints::stack_limit ( ) const
inline

Definition at line 4091 of file v8.h.

4091 { return stack_limit_; }

Referenced by v8::SetResourceConstraints().

+ Here is the caller graph for this function:

Member Data Documentation

◆ code_range_size_

size_t v8::ResourceConstraints::code_range_size_
private

Definition at line 4110 of file v8.h.

◆ max_available_threads_

int v8::ResourceConstraints::max_available_threads_
private

Definition at line 4109 of file v8.h.

◆ max_executable_size_

int v8::ResourceConstraints::max_executable_size_
private

Definition at line 4107 of file v8.h.

◆ max_old_space_size_

int v8::ResourceConstraints::max_old_space_size_
private

Definition at line 4106 of file v8.h.

◆ max_semi_space_size_

int v8::ResourceConstraints::max_semi_space_size_
private

Definition at line 4105 of file v8.h.

◆ stack_limit_

uint32_t* v8::ResourceConstraints::stack_limit_
private

Definition at line 4108 of file v8.h.


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