Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(316)

Side by Side Diff: src/heap.h

Issue 271843005: Simplify ConfigureHeap and change --max_new_space_size to --max_semi_space_size. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/flag-definitions.h ('k') | src/heap.cc » ('j') | src/heap.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef V8_HEAP_H_ 5 #ifndef V8_HEAP_H_
6 #define V8_HEAP_H_ 6 #define V8_HEAP_H_
7 7
8 #include <cmath> 8 #include <cmath>
9 9
10 #include "allocation.h" 10 #include "allocation.h"
(...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after
539 539
540 540
541 enum ArrayStorageAllocationMode { 541 enum ArrayStorageAllocationMode {
542 DONT_INITIALIZE_ARRAY_ELEMENTS, 542 DONT_INITIALIZE_ARRAY_ELEMENTS,
543 INITIALIZE_ARRAY_ELEMENTS_WITH_HOLE 543 INITIALIZE_ARRAY_ELEMENTS_WITH_HOLE
544 }; 544 };
545 545
546 546
547 class Heap { 547 class Heap {
548 public: 548 public:
549 // Configure heap size before setup. Return false if the heap has been 549 // Configure heap size in MB before setup. Return false if the heap has been
550 // set up already. 550 // set up already.
551 bool ConfigureHeap(int max_semispace_size, 551 bool ConfigureHeap(int max_semi_space_size,
552 intptr_t max_old_space_size, 552 int max_old_space_size,
553 intptr_t max_executable_size, 553 int max_executable_size,
554 intptr_t code_range_size); 554 int code_range_size);
555 bool ConfigureHeapDefault(); 555 bool ConfigureHeapDefault();
556 556
557 // Prepares the heap, setting up memory areas that are needed in the isolate 557 // Prepares the heap, setting up memory areas that are needed in the isolate
558 // without actually creating any objects. 558 // without actually creating any objects.
559 bool SetUp(); 559 bool SetUp();
560 560
561 // Bootstraps the object heap with the core set of objects required to run. 561 // Bootstraps the object heap with the core set of objects required to run.
562 // Returns whether it succeeded. 562 // Returns whether it succeeded.
563 bool CreateHeapObjects(); 563 bool CreateHeapObjects();
564 564
565 // Destroys all memory allocated by the heap. 565 // Destroys all memory allocated by the heap.
566 void TearDown(); 566 void TearDown();
567 567
568 // Set the stack limit in the roots_ array. Some architectures generate 568 // Set the stack limit in the roots_ array. Some architectures generate
569 // code that looks here, because it is faster than loading from the static 569 // code that looks here, because it is faster than loading from the static
570 // jslimit_/real_jslimit_ variable in the StackGuard. 570 // jslimit_/real_jslimit_ variable in the StackGuard.
571 void SetStackLimits(); 571 void SetStackLimits();
572 572
573 // Returns whether SetUp has been called. 573 // Returns whether SetUp has been called.
574 bool HasBeenSetUp(); 574 bool HasBeenSetUp();
575 575
576 // Returns the maximum amount of memory reserved for the heap. For 576 // Returns the maximum amount of memory reserved for the heap. For
577 // the young generation, we reserve 4 times the amount needed for a 577 // the young generation, we reserve 4 times the amount needed for a
578 // semi space. The young generation consists of two semi spaces and 578 // semi space. The young generation consists of two semi spaces and
579 // we reserve twice the amount needed for those in order to ensure 579 // we reserve twice the amount needed for those in order to ensure
580 // that new space can be aligned to its size. 580 // that new space can be aligned to its size.
581 intptr_t MaxReserved() { 581 intptr_t MaxReserved() {
582 return 4 * reserved_semispace_size_ + max_old_generation_size_; 582 return 4 * reserved_semispace_size_ + max_old_generation_size_;
583 } 583 }
584 int MaxSemiSpaceSize() { return max_semispace_size_; } 584 int MaxSemiSpaceSize() { return max_semi_space_size_; }
585 int ReservedSemiSpaceSize() { return reserved_semispace_size_; } 585 int ReservedSemiSpaceSize() { return reserved_semispace_size_; }
586 int InitialSemiSpaceSize() { return initial_semispace_size_; } 586 int InitialSemiSpaceSize() { return initial_semispace_size_; }
587 intptr_t MaxOldGenerationSize() { return max_old_generation_size_; } 587 intptr_t MaxOldGenerationSize() { return max_old_generation_size_; }
588 intptr_t MaxExecutableSize() { return max_executable_size_; } 588 intptr_t MaxExecutableSize() { return max_executable_size_; }
589 589
590 // Returns the capacity of the heap in bytes w/o growing. Heap grows when 590 // Returns the capacity of the heap in bytes w/o growing. Heap grows when
591 // more spaces are needed until it reaches the limit. 591 // more spaces are needed until it reaches the limit.
592 intptr_t Capacity(); 592 intptr_t Capacity();
593 593
594 // Returns the amount of memory currently committed for the heap. 594 // Returns the amount of memory currently committed for the heap.
(...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after
1065 return old_generation_allocation_limit_ - PromotedTotalSize(); 1065 return old_generation_allocation_limit_ - PromotedTotalSize();
1066 } 1066 }
1067 1067
1068 inline intptr_t OldGenerationCapacityAvailable() { 1068 inline intptr_t OldGenerationCapacityAvailable() {
1069 return max_old_generation_size_ - PromotedTotalSize(); 1069 return max_old_generation_size_ - PromotedTotalSize();
1070 } 1070 }
1071 1071
1072 static const intptr_t kMinimumOldGenerationAllocationLimit = 1072 static const intptr_t kMinimumOldGenerationAllocationLimit =
1073 8 * (Page::kPageSize > MB ? Page::kPageSize : MB); 1073 8 * (Page::kPageSize > MB ? Page::kPageSize : MB);
1074 1074
1075 static const int kLumpOfMemory = (i::kPointerSize / 4) * i::MB; 1075 static const int kPointerMultiplier = i::kPointerSize / 4;
1076 1076
1077 // The new space size has to be a power of 2. 1077 // The new space size has to be a power of 2. Sizes are in MB.
1078 static const int kMaxNewSpaceSizeLowMemoryDevice = 2 * kLumpOfMemory; 1078 static const int kMaxSemiSpaceSizeLowMemoryDevice =
1079 static const int kMaxNewSpaceSizeMediumMemoryDevice = 8 * kLumpOfMemory; 1079 1 * kPointerMultiplier;
1080 static const int kMaxNewSpaceSizeHighMemoryDevice = 16 * kLumpOfMemory; 1080 static const int kMaxSemiSpaceSizeMediumMemoryDevice =
1081 static const int kMaxNewSpaceSizeHugeMemoryDevice = 16 * kLumpOfMemory; 1081 4 * kPointerMultiplier;
1082 static const int kMaxSemiSpaceSizeHighMemoryDevice =
1083 8 * kPointerMultiplier;
1084 static const int kMaxSemiSpaceSizeHugeMemoryDevice =
1085 8 * kPointerMultiplier;
1082 1086
1083 // The old space size has to be a multiple of Page::kPageSize. 1087 // The old space size has to be a multiple of Page::kPageSize.
1084 static const int kMaxOldSpaceSizeLowMemoryDevice = 128 * kLumpOfMemory; 1088 // Sizes are in MB.
1085 static const int kMaxOldSpaceSizeMediumMemoryDevice = 256 * kLumpOfMemory; 1089 static const int kMaxOldSpaceSizeLowMemoryDevice =
1086 static const int kMaxOldSpaceSizeHighMemoryDevice = 512 * kLumpOfMemory; 1090 128 * kPointerMultiplier;
1087 static const int kMaxOldSpaceSizeHugeMemoryDevice = 700 * kLumpOfMemory; 1091 static const int kMaxOldSpaceSizeMediumMemoryDevice =
1092 256 * kPointerMultiplier;
1093 static const int kMaxOldSpaceSizeHighMemoryDevice =
1094 512 * kPointerMultiplier;
1095 static const int kMaxOldSpaceSizeHugeMemoryDevice =
1096 700 * kPointerMultiplier;
1088 1097
1089 // The executable size has to be a multiple of Page::kPageSize. 1098 // The executable size has to be a multiple of Page::kPageSize.
1090 static const int kMaxExecutableSizeLowMemoryDevice = 128 * kLumpOfMemory; 1099 // Sizes are in MB.
1091 static const int kMaxExecutableSizeMediumMemoryDevice = 256 * kLumpOfMemory; 1100 static const int kMaxExecutableSizeLowMemoryDevice =
1092 static const int kMaxExecutableSizeHighMemoryDevice = 512 * kLumpOfMemory; 1101 128 * kPointerMultiplier;
1093 static const int kMaxExecutableSizeHugeMemoryDevice = 700 * kLumpOfMemory; 1102 static const int kMaxExecutableSizeMediumMemoryDevice =
1103 256 * kPointerMultiplier;
1104 static const int kMaxExecutableSizeHighMemoryDevice =
1105 512 * kPointerMultiplier;
1106 static const int kMaxExecutableSizeHugeMemoryDevice =
1107 700 * kPointerMultiplier;
1094 1108
1095 intptr_t OldGenerationAllocationLimit(intptr_t old_gen_size) { 1109 intptr_t OldGenerationAllocationLimit(intptr_t old_gen_size) {
1096 intptr_t limit = FLAG_stress_compaction 1110 intptr_t limit = FLAG_stress_compaction
1097 ? old_gen_size + old_gen_size / 10 1111 ? old_gen_size + old_gen_size / 10
1098 : old_gen_size * old_space_growing_factor_; 1112 : old_gen_size * old_space_growing_factor_;
1099 limit = Max(limit, kMinimumOldGenerationAllocationLimit); 1113 limit = Max(limit, kMinimumOldGenerationAllocationLimit);
1100 limit += new_space_.Capacity(); 1114 limit += new_space_.Capacity();
1101 intptr_t halfway_to_the_max = (old_gen_size + max_old_generation_size_) / 2; 1115 intptr_t halfway_to_the_max = (old_gen_size + max_old_generation_size_) / 2;
1102 return Min(limit, halfway_to_the_max); 1116 return Min(limit, halfway_to_the_max);
1103 } 1117 }
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after
1482 Heap(); 1496 Heap();
1483 1497
1484 // This can be calculated directly from a pointer to the heap; however, it is 1498 // This can be calculated directly from a pointer to the heap; however, it is
1485 // more expedient to get at the isolate directly from within Heap methods. 1499 // more expedient to get at the isolate directly from within Heap methods.
1486 Isolate* isolate_; 1500 Isolate* isolate_;
1487 1501
1488 Object* roots_[kRootListLength]; 1502 Object* roots_[kRootListLength];
1489 1503
1490 intptr_t code_range_size_; 1504 intptr_t code_range_size_;
1491 int reserved_semispace_size_; 1505 int reserved_semispace_size_;
1492 int max_semispace_size_; 1506 int max_semi_space_size_;
1493 int initial_semispace_size_; 1507 int initial_semispace_size_;
1494 intptr_t max_old_generation_size_; 1508 intptr_t max_old_generation_size_;
1495 intptr_t max_executable_size_; 1509 intptr_t max_executable_size_;
1496 intptr_t maximum_committed_; 1510 intptr_t maximum_committed_;
1497 1511
1498 // The old space growing factor is used in the old space heap growing 1512 // The old space growing factor is used in the old space heap growing
1499 // strategy. The new old space size is the current old space size times 1513 // strategy. The new old space size is the current old space size times
1500 // old_space_growing_factor_. 1514 // old_space_growing_factor_.
1501 int old_space_growing_factor_; 1515 int old_space_growing_factor_;
1502 1516
(...skipping 1304 matching lines...) Expand 10 before | Expand all | Expand 10 after
2807 DisallowHeapAllocation no_allocation; // i.e. no gc allowed. 2821 DisallowHeapAllocation no_allocation; // i.e. no gc allowed.
2808 2822
2809 private: 2823 private:
2810 DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer); 2824 DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer);
2811 }; 2825 };
2812 #endif // DEBUG 2826 #endif // DEBUG
2813 2827
2814 } } // namespace v8::internal 2828 } } // namespace v8::internal
2815 2829
2816 #endif // V8_HEAP_H_ 2830 #endif // V8_HEAP_H_
OLDNEW
« no previous file with comments | « src/flag-definitions.h ('k') | src/heap.cc » ('j') | src/heap.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698