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

Side by Side Diff: src/heap/heap.h

Issue 1012023002: Merge old data and pointer space. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 9 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
« no previous file with comments | « src/globals.h ('k') | src/heap/heap.cc » ('j') | no next file with comments »
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_HEAP_H_ 5 #ifndef V8_HEAP_HEAP_H_
6 #define V8_HEAP_HEAP_H_ 6 #define V8_HEAP_HEAP_H_
7 7
8 #include <cmath> 8 #include <cmath>
9 9
10 #include "src/allocation.h" 10 #include "src/allocation.h"
(...skipping 623 matching lines...) Expand 10 before | Expand all | Expand 10 after
634 intptr_t SizeOfObjects(); 634 intptr_t SizeOfObjects();
635 635
636 // Return the starting address and a mask for the new space. And-masking an 636 // Return the starting address and a mask for the new space. And-masking an
637 // address with the mask will result in the start address of the new space 637 // address with the mask will result in the start address of the new space
638 // for all addresses in either semispace. 638 // for all addresses in either semispace.
639 Address NewSpaceStart() { return new_space_.start(); } 639 Address NewSpaceStart() { return new_space_.start(); }
640 uintptr_t NewSpaceMask() { return new_space_.mask(); } 640 uintptr_t NewSpaceMask() { return new_space_.mask(); }
641 Address NewSpaceTop() { return new_space_.top(); } 641 Address NewSpaceTop() { return new_space_.top(); }
642 642
643 NewSpace* new_space() { return &new_space_; } 643 NewSpace* new_space() { return &new_space_; }
644 OldSpace* old_pointer_space() { return old_pointer_space_; } 644 OldSpace* old_space() { return old_space_; }
645 OldSpace* old_data_space() { return old_data_space_; }
646 OldSpace* code_space() { return code_space_; } 645 OldSpace* code_space() { return code_space_; }
647 MapSpace* map_space() { return map_space_; } 646 MapSpace* map_space() { return map_space_; }
648 CellSpace* cell_space() { return cell_space_; } 647 CellSpace* cell_space() { return cell_space_; }
649 PropertyCellSpace* property_cell_space() { return property_cell_space_; } 648 PropertyCellSpace* property_cell_space() { return property_cell_space_; }
650 LargeObjectSpace* lo_space() { return lo_space_; } 649 LargeObjectSpace* lo_space() { return lo_space_; }
651 PagedSpace* paged_space(int idx) { 650 PagedSpace* paged_space(int idx) {
652 switch (idx) { 651 switch (idx) {
653 case OLD_POINTER_SPACE: 652 case OLD_SPACE:
654 return old_pointer_space(); 653 return old_space();
655 case OLD_DATA_SPACE:
656 return old_data_space();
657 case MAP_SPACE: 654 case MAP_SPACE:
658 return map_space(); 655 return map_space();
659 case CELL_SPACE: 656 case CELL_SPACE:
660 return cell_space(); 657 return cell_space();
661 case PROPERTY_CELL_SPACE: 658 case PROPERTY_CELL_SPACE:
662 return property_cell_space(); 659 return property_cell_space();
663 case CODE_SPACE: 660 case CODE_SPACE:
664 return code_space(); 661 return code_space();
665 case NEW_SPACE: 662 case NEW_SPACE:
666 case LO_SPACE: 663 case LO_SPACE:
667 UNREACHABLE(); 664 UNREACHABLE();
668 } 665 }
669 return NULL; 666 return NULL;
670 } 667 }
671 668
672 bool always_allocate() { return always_allocate_scope_depth_ != 0; } 669 bool always_allocate() { return always_allocate_scope_depth_ != 0; }
673 Address always_allocate_scope_depth_address() { 670 Address always_allocate_scope_depth_address() {
674 return reinterpret_cast<Address>(&always_allocate_scope_depth_); 671 return reinterpret_cast<Address>(&always_allocate_scope_depth_);
675 } 672 }
676 673
677 Address* NewSpaceAllocationTopAddress() { 674 Address* NewSpaceAllocationTopAddress() {
678 return new_space_.allocation_top_address(); 675 return new_space_.allocation_top_address();
679 } 676 }
680 Address* NewSpaceAllocationLimitAddress() { 677 Address* NewSpaceAllocationLimitAddress() {
681 return new_space_.allocation_limit_address(); 678 return new_space_.allocation_limit_address();
682 } 679 }
683 680
684 Address* OldPointerSpaceAllocationTopAddress() { 681 Address* OldSpaceAllocationTopAddress() {
685 return old_pointer_space_->allocation_top_address(); 682 return old_space_->allocation_top_address();
686 } 683 }
687 Address* OldPointerSpaceAllocationLimitAddress() { 684 Address* OldSpaceAllocationLimitAddress() {
688 return old_pointer_space_->allocation_limit_address(); 685 return old_space_->allocation_limit_address();
689 }
690
691 Address* OldDataSpaceAllocationTopAddress() {
692 return old_data_space_->allocation_top_address();
693 }
694 Address* OldDataSpaceAllocationLimitAddress() {
695 return old_data_space_->allocation_limit_address();
696 } 686 }
697 687
698 // TODO(hpayer): There is still a missmatch between capacity and actual 688 // TODO(hpayer): There is still a missmatch between capacity and actual
699 // committed memory size. 689 // committed memory size.
700 bool CanExpandOldGeneration(int size) { 690 bool CanExpandOldGeneration(int size) {
701 return (CommittedOldGenerationMemory() + size) < MaxOldGenerationSize(); 691 return (CommittedOldGenerationMemory() + size) < MaxOldGenerationSize();
702 } 692 }
703 693
704 // Returns a deep copy of the JavaScript object. 694 // Returns a deep copy of the JavaScript object.
705 // Properties and elements are copied too. 695 // Properties and elements are copied too.
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
915 void IterateAndMarkPointersToFromSpace(Address start, Address end, 905 void IterateAndMarkPointersToFromSpace(Address start, Address end,
916 ObjectSlotCallback callback); 906 ObjectSlotCallback callback);
917 907
918 // Returns whether the object resides in new space. 908 // Returns whether the object resides in new space.
919 inline bool InNewSpace(Object* object); 909 inline bool InNewSpace(Object* object);
920 inline bool InNewSpace(Address address); 910 inline bool InNewSpace(Address address);
921 inline bool InNewSpacePage(Address address); 911 inline bool InNewSpacePage(Address address);
922 inline bool InFromSpace(Object* object); 912 inline bool InFromSpace(Object* object);
923 inline bool InToSpace(Object* object); 913 inline bool InToSpace(Object* object);
924 914
925 // Returns whether the object resides in old pointer space. 915 // Returns whether the object resides in old space.
926 inline bool InOldPointerSpace(Address address); 916 inline bool InOldSpace(Address address);
927 inline bool InOldPointerSpace(Object* object); 917 inline bool InOldSpace(Object* object);
928
929 // Returns whether the object resides in old data space.
930 inline bool InOldDataSpace(Address address);
931 inline bool InOldDataSpace(Object* object);
932 918
933 // Checks whether an address/object in the heap (including auxiliary 919 // Checks whether an address/object in the heap (including auxiliary
934 // area and unused area). 920 // area and unused area).
935 bool Contains(Address addr); 921 bool Contains(Address addr);
936 bool Contains(HeapObject* value); 922 bool Contains(HeapObject* value);
937 923
938 // Checks whether an address/object in a space. 924 // Checks whether an address/object in a space.
939 // Currently used by tests, serialization and heap verification only. 925 // Currently used by tests, serialization and heap verification only.
940 bool InSpace(Address addr, AllocationSpace space); 926 bool InSpace(Address addr, AllocationSpace space);
941 bool InSpace(HeapObject* value, AllocationSpace space); 927 bool InSpace(HeapObject* value, AllocationSpace space);
942 928
943 // Finds out which space an object should get promoted to based on its type.
944 inline OldSpace* TargetSpace(HeapObject* object);
945 static inline AllocationSpace TargetSpaceId(InstanceType type);
946
947 // Checks whether the given object is allowed to be migrated from it's 929 // Checks whether the given object is allowed to be migrated from it's
948 // current space into the given destination space. Used for debugging. 930 // current space into the given destination space. Used for debugging.
949 inline bool AllowedToBeMigrated(HeapObject* object, AllocationSpace dest); 931 inline bool AllowedToBeMigrated(HeapObject* object, AllocationSpace dest);
950 932
951 // Sets the stub_cache_ (only used when expanding the dictionary). 933 // Sets the stub_cache_ (only used when expanding the dictionary).
952 void public_set_code_stubs(UnseededNumberDictionary* value) { 934 void public_set_code_stubs(UnseededNumberDictionary* value) {
953 roots_[kCodeStubsRootIndex] = value; 935 roots_[kCodeStubsRootIndex] = value;
954 } 936 }
955 937
956 // Support for computing object sizes for old objects during GCs. Returns 938 // Support for computing object sizes for old objects during GCs. Returns
(...skipping 616 matching lines...) Expand 10 before | Expand all | Expand 10 after
1573 int always_allocate_scope_depth_; 1555 int always_allocate_scope_depth_;
1574 1556
1575 // For keeping track of context disposals. 1557 // For keeping track of context disposals.
1576 int contexts_disposed_; 1558 int contexts_disposed_;
1577 1559
1578 int global_ic_age_; 1560 int global_ic_age_;
1579 1561
1580 int scan_on_scavenge_pages_; 1562 int scan_on_scavenge_pages_;
1581 1563
1582 NewSpace new_space_; 1564 NewSpace new_space_;
1583 OldSpace* old_pointer_space_; 1565 OldSpace* old_space_;
1584 OldSpace* old_data_space_;
1585 OldSpace* code_space_; 1566 OldSpace* code_space_;
1586 MapSpace* map_space_; 1567 MapSpace* map_space_;
1587 CellSpace* cell_space_; 1568 CellSpace* cell_space_;
1588 PropertyCellSpace* property_cell_space_; 1569 PropertyCellSpace* property_cell_space_;
1589 LargeObjectSpace* lo_space_; 1570 LargeObjectSpace* lo_space_;
1590 HeapState gc_state_; 1571 HeapState gc_state_;
1591 int gc_post_processing_depth_; 1572 int gc_post_processing_depth_;
1592 Address new_space_top_after_last_gc_; 1573 Address new_space_top_after_last_gc_;
1593 1574
1594 // Returns the amount of external memory registered since last global gc. 1575 // Returns the amount of external memory registered since last global gc.
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
1770 // Performs garbage collection 1751 // Performs garbage collection
1771 // Returns whether there is a chance another major GC could 1752 // Returns whether there is a chance another major GC could
1772 // collect more garbage. 1753 // collect more garbage.
1773 bool PerformGarbageCollection( 1754 bool PerformGarbageCollection(
1774 GarbageCollector collector, 1755 GarbageCollector collector,
1775 const GCCallbackFlags gc_callback_flags = kNoGCCallbackFlags); 1756 const GCCallbackFlags gc_callback_flags = kNoGCCallbackFlags);
1776 1757
1777 inline void UpdateOldSpaceLimits(); 1758 inline void UpdateOldSpaceLimits();
1778 1759
1779 // Selects the proper allocation space depending on the given object 1760 // Selects the proper allocation space depending on the given object
1780 // size, pretenuring decision, and preferred old-space. 1761 // size and pretenuring decision.
1781 static AllocationSpace SelectSpace(int object_size, 1762 static AllocationSpace SelectSpace(int object_size,
1782 AllocationSpace preferred_old_space,
1783 PretenureFlag pretenure) { 1763 PretenureFlag pretenure) {
1784 DCHECK(preferred_old_space == OLD_POINTER_SPACE ||
1785 preferred_old_space == OLD_DATA_SPACE);
1786 if (object_size > Page::kMaxRegularHeapObjectSize) return LO_SPACE; 1764 if (object_size > Page::kMaxRegularHeapObjectSize) return LO_SPACE;
1787 return (pretenure == TENURED) ? preferred_old_space : NEW_SPACE; 1765 return (pretenure == TENURED) ? OLD_SPACE : NEW_SPACE;
1788 } 1766 }
1789 1767
1790 HeapObject* DoubleAlignForDeserialization(HeapObject* object, int size); 1768 HeapObject* DoubleAlignForDeserialization(HeapObject* object, int size);
1791 1769
1792 // Allocate an uninitialized object. The memory is non-executable if the 1770 // Allocate an uninitialized object. The memory is non-executable if the
1793 // hardware and OS allow. This is the single choke-point for allocations 1771 // hardware and OS allow. This is the single choke-point for allocations
1794 // performed by the runtime and should not be bypassed (to extend this to 1772 // performed by the runtime and should not be bypassed (to extend this to
1795 // inlined allocations, use the Heap::DisableInlineAllocation() support). 1773 // inlined allocations, use the Heap::DisableInlineAllocation() support).
1796 MUST_USE_RESULT inline AllocationResult AllocateRaw( 1774 MUST_USE_RESULT inline AllocationResult AllocateRaw(
1797 int size_in_bytes, AllocationSpace space, AllocationSpace retry_space); 1775 int size_in_bytes, AllocationSpace space, AllocationSpace retry_space);
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after
2180 2158
2181 2159
2182 class HeapStats { 2160 class HeapStats {
2183 public: 2161 public:
2184 static const int kStartMarker = 0xDECADE00; 2162 static const int kStartMarker = 0xDECADE00;
2185 static const int kEndMarker = 0xDECADE01; 2163 static const int kEndMarker = 0xDECADE01;
2186 2164
2187 int* start_marker; // 0 2165 int* start_marker; // 0
2188 int* new_space_size; // 1 2166 int* new_space_size; // 1
2189 int* new_space_capacity; // 2 2167 int* new_space_capacity; // 2
2190 intptr_t* old_pointer_space_size; // 3 2168 intptr_t* old_space_size; // 3
2191 intptr_t* old_pointer_space_capacity; // 4 2169 intptr_t* old_space_capacity; // 4
2192 intptr_t* old_data_space_size; // 5 2170 intptr_t* code_space_size; // 5
2193 intptr_t* old_data_space_capacity; // 6 2171 intptr_t* code_space_capacity; // 6
2194 intptr_t* code_space_size; // 7 2172 intptr_t* map_space_size; // 7
2195 intptr_t* code_space_capacity; // 8 2173 intptr_t* map_space_capacity; // 8
2196 intptr_t* map_space_size; // 9 2174 intptr_t* cell_space_size; // 9
2197 intptr_t* map_space_capacity; // 10 2175 intptr_t* cell_space_capacity; // 10
2198 intptr_t* cell_space_size; // 11 2176 intptr_t* lo_space_size; // 11
2199 intptr_t* cell_space_capacity; // 12 2177 int* global_handle_count; // 12
2200 intptr_t* lo_space_size; // 13 2178 int* weak_global_handle_count; // 13
2201 int* global_handle_count; // 14 2179 int* pending_global_handle_count; // 14
2202 int* weak_global_handle_count; // 15 2180 int* near_death_global_handle_count; // 15
2203 int* pending_global_handle_count; // 16 2181 int* free_global_handle_count; // 16
2204 int* near_death_global_handle_count; // 17 2182 intptr_t* memory_allocator_size; // 17
2205 int* free_global_handle_count; // 18 2183 intptr_t* memory_allocator_capacity; // 18
2206 intptr_t* memory_allocator_size; // 19 2184 int* objects_per_type; // 19
2207 intptr_t* memory_allocator_capacity; // 20 2185 int* size_per_type; // 20
2208 int* objects_per_type; // 21 2186 int* os_error; // 21
2209 int* size_per_type; // 22 2187 int* end_marker; // 22
2210 int* os_error; // 23 2188 intptr_t* property_cell_space_size; // 23
2211 int* end_marker; // 24 2189 intptr_t* property_cell_space_capacity; // 24
2212 intptr_t* property_cell_space_size; // 25
2213 intptr_t* property_cell_space_capacity; // 26
2214 }; 2190 };
2215 2191
2216 2192
2217 class AlwaysAllocateScope { 2193 class AlwaysAllocateScope {
2218 public: 2194 public:
2219 explicit inline AlwaysAllocateScope(Isolate* isolate); 2195 explicit inline AlwaysAllocateScope(Isolate* isolate);
2220 inline ~AlwaysAllocateScope(); 2196 inline ~AlwaysAllocateScope();
2221 2197
2222 private: 2198 private:
2223 // Implicitly disable artificial allocation failures. 2199 // Implicitly disable artificial allocation failures.
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
2262 public: 2238 public:
2263 explicit AllSpaces(Heap* heap) : heap_(heap), counter_(FIRST_SPACE) {} 2239 explicit AllSpaces(Heap* heap) : heap_(heap), counter_(FIRST_SPACE) {}
2264 Space* next(); 2240 Space* next();
2265 2241
2266 private: 2242 private:
2267 Heap* heap_; 2243 Heap* heap_;
2268 int counter_; 2244 int counter_;
2269 }; 2245 };
2270 2246
2271 2247
2272 // Space iterator for iterating over all old spaces of the heap: Old pointer 2248 // Space iterator for iterating over all old spaces of the heap: Old space
2273 // space, old data space and code space. Returns each space in turn, and null 2249 // and code space. Returns each space in turn, and null when it is done.
2274 // when it is done.
2275 class OldSpaces BASE_EMBEDDED { 2250 class OldSpaces BASE_EMBEDDED {
2276 public: 2251 public:
2277 explicit OldSpaces(Heap* heap) : heap_(heap), counter_(OLD_POINTER_SPACE) {} 2252 explicit OldSpaces(Heap* heap) : heap_(heap), counter_(OLD_SPACE) {}
2278 OldSpace* next(); 2253 OldSpace* next();
2279 2254
2280 private: 2255 private:
2281 Heap* heap_; 2256 Heap* heap_;
2282 int counter_; 2257 int counter_;
2283 }; 2258 };
2284 2259
2285 2260
2286 // Space iterator for iterating over all the paged spaces of the heap: Map 2261 // Space iterator for iterating over all the paged spaces of the heap: Map
2287 // space, old pointer space, old data space, code space and cell space. Returns 2262 // space, old space, code space and cell space. Returns
2288 // each space in turn, and null when it is done. 2263 // each space in turn, and null when it is done.
2289 class PagedSpaces BASE_EMBEDDED { 2264 class PagedSpaces BASE_EMBEDDED {
2290 public: 2265 public:
2291 explicit PagedSpaces(Heap* heap) : heap_(heap), counter_(OLD_POINTER_SPACE) {} 2266 explicit PagedSpaces(Heap* heap) : heap_(heap), counter_(OLD_SPACE) {}
2292 PagedSpace* next(); 2267 PagedSpace* next();
2293 2268
2294 private: 2269 private:
2295 Heap* heap_; 2270 Heap* heap_;
2296 int counter_; 2271 int counter_;
2297 }; 2272 };
2298 2273
2299 2274
2300 // Space iterator for iterating over all spaces of the heap. 2275 // Space iterator for iterating over all spaces of the heap.
2301 // For each space an object iterator is provided. The deallocation of the 2276 // For each space an object iterator is provided. The deallocation of the
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
2624 DisallowHeapAllocation no_allocation; // i.e. no gc allowed. 2599 DisallowHeapAllocation no_allocation; // i.e. no gc allowed.
2625 2600
2626 private: 2601 private:
2627 DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer); 2602 DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer);
2628 }; 2603 };
2629 #endif // DEBUG 2604 #endif // DEBUG
2630 } 2605 }
2631 } // namespace v8::internal 2606 } // namespace v8::internal
2632 2607
2633 #endif // V8_HEAP_HEAP_H_ 2608 #endif // V8_HEAP_HEAP_H_
OLDNEW
« no previous file with comments | « src/globals.h ('k') | src/heap/heap.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698