@@ -6405,7 +6405,19 @@ V8_INLINE Local<Boolean> False(Isolate* isolate);
64056405 */
64066406class V8_EXPORT ResourceConstraints {
64076407 public:
6408- ResourceConstraints ();
6408+ /* *
6409+ * Configures the constraints with reasonable default values based on the
6410+ * provided heap size limit. The heap size includes both the young and
6411+ * the old generation.
6412+ *
6413+ * \param maximum_heap_size_in_bytes The hard limit for the heap size.
6414+ * When the heap size approaches this limit, V8 will perform series of
6415+ * garbage collections and invoke the NearHeapLimitCallback.
6416+ * If the garbage collections do not help and the callback does not
6417+ * increase the limit, then V8 will crash with V8::FatalProcessOutOfMemory.
6418+ */
6419+ void ConfigureDefaultsFromHeapSize (size_t initial_heap_size_in_bytes,
6420+ size_t maximum_heap_size_in_bytes);
64096421
64106422 /* *
64116423 * Configures the constraints with reasonable default values based on the
@@ -6419,26 +6431,81 @@ class V8_EXPORT ResourceConstraints {
64196431 void ConfigureDefaults (uint64_t physical_memory,
64206432 uint64_t virtual_memory_limit);
64216433
6422- // Returns the max semi-space size in KB.
6423- size_t max_semi_space_size_in_kb () const {
6424- return max_semi_space_size_in_kb_;
6434+ /* *
6435+ * The address beyond which the VM's stack may not grow.
6436+ */
6437+ uint32_t * stack_limit () const { return stack_limit_; }
6438+ void set_stack_limit (uint32_t * value) { stack_limit_ = value; }
6439+
6440+ /* *
6441+ * The amount of virtual memory reserved for generated code. This is relevant
6442+ * for 64-bit architectures that rely on code range for calls in code.
6443+ */
6444+ size_t code_range_size_in_bytes () const { return code_range_size_; }
6445+ void set_code_range_size_in_bytes (size_t limit) { code_range_size_ = limit; }
6446+
6447+ /* *
6448+ * The maximum size of the old generation.
6449+ * When the old generation approaches this limit, V8 will perform series of
6450+ * garbage collections and invoke the NearHeapLimitCallback.
6451+ * If the garbage collections do not help and the callback does not
6452+ * increase the limit, then V8 will crash with V8::FatalProcessOutOfMemory.
6453+ */
6454+ size_t max_old_generation_size_in_bytes () const {
6455+ return max_old_generation_size_;
6456+ }
6457+ void set_max_old_generation_size_in_bytes (size_t limit) {
6458+ max_old_generation_size_ = limit;
6459+ }
6460+
6461+ /* *
6462+ * The maximum size of the young generation, which consists of two semi-spaces
6463+ * and a large object space. This affects frequency of Scavenge garbage
6464+ * collections and should be typically much smaller that the old generation.
6465+ */
6466+ size_t max_young_generation_size_in_bytes () const {
6467+ return max_young_generation_size_;
6468+ }
6469+ void set_max_young_generation_size_in_bytes (size_t limit) {
6470+ max_young_generation_size_ = limit;
64256471 }
64266472
6427- // Sets the max semi-space size in KB.
6428- void set_max_semi_space_size_in_kb (size_t limit_in_kb) {
6429- max_semi_space_size_in_kb_ = limit_in_kb;
6473+ size_t initial_old_generation_size_in_bytes () const {
6474+ return initial_old_generation_size_;
6475+ }
6476+ void set_initial_old_generation_size_in_bytes (size_t initial_size) {
6477+ initial_old_generation_size_ = initial_size;
64306478 }
64316479
6432- size_t max_old_space_size () const { return max_old_space_size_; }
6433- void set_max_old_space_size (size_t limit_in_mb) {
6434- max_old_space_size_ = limit_in_mb;
6480+ size_t initial_young_generation_size_in_bytes () const {
6481+ return initial_young_generation_size_;
64356482 }
6436- uint32_t * stack_limit () const { return stack_limit_; }
6437- // Sets an address beyond which the VM's stack may not grow.
6438- void set_stack_limit (uint32_t * value) { stack_limit_ = value; }
6439- size_t code_range_size () const { return code_range_size_; }
6440- void set_code_range_size (size_t limit_in_mb) {
6441- code_range_size_ = limit_in_mb;
6483+ void set_initial_young_generation_size_in_bytes (size_t initial_size) {
6484+ initial_young_generation_size_ = initial_size;
6485+ }
6486+
6487+ /* *
6488+ * Deprecated functions. Do not use in new code.
6489+ */
6490+ V8_DEPRECATE_SOON (" Use code_range_size_in_bytes." ,
6491+ size_t code_range_size () const ) {
6492+ return code_range_size_ / kMB ;
6493+ }
6494+ V8_DEPRECATE_SOON (" Use set_code_range_size_in_bytes." ,
6495+ void set_code_range_size (size_t limit_in_mb)) {
6496+ code_range_size_ = limit_in_mb * kMB ;
6497+ }
6498+ V8_DEPRECATE_SOON (" Use max_young_generation_size_in_bytes." ,
6499+ size_t max_semi_space_size_in_kb () const );
6500+ V8_DEPRECATE_SOON (" Use set_max_young_generation_size_in_bytes." ,
6501+ void set_max_semi_space_size_in_kb (size_t limit_in_kb));
6502+ V8_DEPRECATE_SOON (" Use max_old_generation_size_in_bytes." ,
6503+ size_t max_old_space_size () const ) {
6504+ return max_old_generation_size_ / kMB ;
6505+ }
6506+ V8_DEPRECATE_SOON (" Use set_max_old_generation_size_in_bytes." ,
6507+ void set_max_old_space_size (size_t limit_in_mb)) {
6508+ max_old_generation_size_ = limit_in_mb * kMB ;
64426509 }
64436510 V8_DEPRECATE_SOON (" Zone does not pool memory any more." ,
64446511 size_t max_zone_pool_size () const ) {
@@ -6450,14 +6517,14 @@ class V8_EXPORT ResourceConstraints {
64506517 }
64516518
64526519 private:
6453- // max_semi_space_size_ is in KB
6454- size_t max_semi_space_size_in_kb_ ;
6455-
6456- // The remaining limits are in MB
6457- size_t max_old_space_size_ ;
6458- uint32_t * stack_limit_ ;
6459- size_t code_range_size_ ;
6460- size_t max_zone_pool_size_ ;
6520+ static constexpr size_t kMB = 1048576u ;
6521+ size_t code_range_size_ = 0 ;
6522+ size_t max_old_generation_size_ = 0 ;
6523+ size_t max_young_generation_size_ = 0 ;
6524+ size_t max_zone_pool_size_ = 0 ;
6525+ size_t initial_old_generation_size_ = 0 ;
6526+ size_t initial_young_generation_size_ = 0 ;
6527+ uint32_t * stack_limit_ = nullptr ;
64616528};
64626529
64636530
0 commit comments