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

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

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