| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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_SPACES_H_ | 5 #ifndef V8_SPACES_H_ |
| 6 #define V8_SPACES_H_ | 6 #define V8_SPACES_H_ |
| 7 | 7 |
| 8 #include "allocation.h" | 8 #include "allocation.h" |
| 9 #include "hashmap.h" | 9 #include "hashmap.h" |
| 10 #include "list.h" | 10 #include "list.h" |
| (...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 299 } | 299 } |
| 300 | 300 |
| 301 void set_next_chunk(MemoryChunk* next) { | 301 void set_next_chunk(MemoryChunk* next) { |
| 302 Release_Store(&next_chunk_, reinterpret_cast<AtomicWord>(next)); | 302 Release_Store(&next_chunk_, reinterpret_cast<AtomicWord>(next)); |
| 303 } | 303 } |
| 304 | 304 |
| 305 void set_prev_chunk(MemoryChunk* prev) { | 305 void set_prev_chunk(MemoryChunk* prev) { |
| 306 Release_Store(&prev_chunk_, reinterpret_cast<AtomicWord>(prev)); | 306 Release_Store(&prev_chunk_, reinterpret_cast<AtomicWord>(prev)); |
| 307 } | 307 } |
| 308 | 308 |
| 309 uintptr_t shadow_data_offset() { return shadow_data_offset_; } |
| 310 |
| 311 MemoryChunk* shadow_chunk() { return shadow_chunk_; } |
| 312 void set_shadow_chunk(MemoryChunk* shadow) { shadow_chunk_ = shadow; } |
| 313 |
| 309 Space* owner() const { | 314 Space* owner() const { |
| 310 if ((reinterpret_cast<intptr_t>(owner_) & kFailureTagMask) == | 315 if ((reinterpret_cast<intptr_t>(owner_) & kFailureTagMask) == |
| 311 kFailureTag) { | 316 kFailureTag) { |
| 312 return reinterpret_cast<Space*>(reinterpret_cast<intptr_t>(owner_) - | 317 return reinterpret_cast<Space*>(reinterpret_cast<intptr_t>(owner_) - |
| 313 kFailureTag); | 318 kFailureTag); |
| 314 } else { | 319 } else { |
| 315 return NULL; | 320 return NULL; |
| 316 } | 321 } |
| 317 } | 322 } |
| 318 | 323 |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 540 static const intptr_t kAlignment = | 545 static const intptr_t kAlignment = |
| 541 (static_cast<uintptr_t>(1) << kPageSizeBits); | 546 (static_cast<uintptr_t>(1) << kPageSizeBits); |
| 542 | 547 |
| 543 static const intptr_t kAlignmentMask = kAlignment - 1; | 548 static const intptr_t kAlignmentMask = kAlignment - 1; |
| 544 | 549 |
| 545 static const intptr_t kSizeOffset = 0; | 550 static const intptr_t kSizeOffset = 0; |
| 546 | 551 |
| 547 static const intptr_t kLiveBytesOffset = | 552 static const intptr_t kLiveBytesOffset = |
| 548 kSizeOffset + kPointerSize + kPointerSize + kPointerSize + | 553 kSizeOffset + kPointerSize + kPointerSize + kPointerSize + |
| 549 kPointerSize + kPointerSize + | 554 kPointerSize + kPointerSize + |
| 555 kPointerSize + kPointerSize + kPointerSize + |
| 550 kPointerSize + kPointerSize + kPointerSize + kIntSize; | 556 kPointerSize + kPointerSize + kPointerSize + kIntSize; |
| 551 | 557 |
| 552 static const size_t kSlotsBufferOffset = kLiveBytesOffset + kIntSize; | 558 static const size_t kSlotsBufferOffset = kLiveBytesOffset + kIntSize; |
| 553 | 559 |
| 554 static const size_t kWriteBarrierCounterOffset = | 560 static const size_t kWriteBarrierCounterOffset = |
| 555 kSlotsBufferOffset + kPointerSize + kPointerSize; | 561 kSlotsBufferOffset + kPointerSize + kPointerSize; |
| 556 | 562 |
| 557 static const size_t kHeaderSize = kWriteBarrierCounterOffset + kPointerSize + | 563 static const size_t kHeaderSize = kWriteBarrierCounterOffset + kPointerSize + |
| 558 kIntSize + kIntSize + kPointerSize + | 564 kIntSize + kIntSize + kPointerSize + |
| 559 5 * kPointerSize + | 565 5 * kPointerSize + |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 678 static inline void UpdateHighWaterMark(Address mark); | 684 static inline void UpdateHighWaterMark(Address mark); |
| 679 | 685 |
| 680 protected: | 686 protected: |
| 681 size_t size_; | 687 size_t size_; |
| 682 intptr_t flags_; | 688 intptr_t flags_; |
| 683 | 689 |
| 684 // Start and end of allocatable memory on this chunk. | 690 // Start and end of allocatable memory on this chunk. |
| 685 Address area_start_; | 691 Address area_start_; |
| 686 Address area_end_; | 692 Address area_end_; |
| 687 | 693 |
| 694 MemoryChunk* shadow_chunk_; |
| 695 // Offset to object's shadow data. |
| 696 intptr_t shadow_data_offset_; |
| 697 // Shadow data storage for large objects. |
| 698 intptr_t large_object_shadow_data_; |
| 699 |
| 688 // If the chunk needs to remember its memory reservation, it is stored here. | 700 // If the chunk needs to remember its memory reservation, it is stored here. |
| 689 VirtualMemory reservation_; | 701 VirtualMemory reservation_; |
| 690 // The identity of the owning space. This is tagged as a failure pointer, but | 702 // The identity of the owning space. This is tagged as a failure pointer, but |
| 691 // no failure can be in an object, so this can be distinguished from any entry | 703 // no failure can be in an object, so this can be distinguished from any entry |
| 692 // in a fixed array. | 704 // in a fixed array. |
| 693 Address owner_; | 705 Address owner_; |
| 694 Heap* heap_; | 706 Heap* heap_; |
| 695 // Used by the store buffer to keep track of which pages to mark scan-on- | 707 // Used by the store buffer to keep track of which pages to mark scan-on- |
| 696 // scavenge. | 708 // scavenge. |
| 697 int store_buffer_counter_; | 709 int store_buffer_counter_; |
| (...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1103 #endif | 1115 #endif |
| 1104 | 1116 |
| 1105 // Returns a MemoryChunk in which the memory region from commit_area_size to | 1117 // Returns a MemoryChunk in which the memory region from commit_area_size to |
| 1106 // reserve_area_size of the chunk area is reserved but not committed, it | 1118 // reserve_area_size of the chunk area is reserved but not committed, it |
| 1107 // could be committed later by calling MemoryChunk::CommitArea. | 1119 // could be committed later by calling MemoryChunk::CommitArea. |
| 1108 MemoryChunk* AllocateChunk(intptr_t reserve_area_size, | 1120 MemoryChunk* AllocateChunk(intptr_t reserve_area_size, |
| 1109 intptr_t commit_area_size, | 1121 intptr_t commit_area_size, |
| 1110 Executability executable, | 1122 Executability executable, |
| 1111 Space* space); | 1123 Space* space); |
| 1112 | 1124 |
| 1125 // Allocates shadow page of respective size and sets it as a shadow |
| 1126 // of given chunk. |
| 1127 bool AllocateShadowChunkFor(MemoryChunk* chunk); |
| 1128 |
| 1129 // Frees and clears shadow page of given chunk. |
| 1130 void FreeShadowChunkFor(MemoryChunk* chunk); |
| 1131 |
| 1132 |
| 1113 Address ReserveAlignedMemory(size_t requested, | 1133 Address ReserveAlignedMemory(size_t requested, |
| 1114 size_t alignment, | 1134 size_t alignment, |
| 1115 VirtualMemory* controller); | 1135 VirtualMemory* controller); |
| 1116 Address AllocateAlignedMemory(size_t reserve_size, | 1136 Address AllocateAlignedMemory(size_t reserve_size, |
| 1117 size_t commit_size, | 1137 size_t commit_size, |
| 1118 size_t alignment, | 1138 size_t alignment, |
| 1119 Executability executable, | 1139 Executability executable, |
| 1120 VirtualMemory* controller); | 1140 VirtualMemory* controller); |
| 1121 | 1141 |
| 1122 bool CommitMemory(Address addr, size_t size, Executability executable); | 1142 bool CommitMemory(Address addr, size_t size, Executability executable); |
| (...skipping 1155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2278 size_t CommittedPhysicalMemory(); | 2298 size_t CommittedPhysicalMemory(); |
| 2279 | 2299 |
| 2280 private: | 2300 private: |
| 2281 // Flips the semispace between being from-space and to-space. | 2301 // Flips the semispace between being from-space and to-space. |
| 2282 // Copies the flags into the masked positions on all pages in the space. | 2302 // Copies the flags into the masked positions on all pages in the space. |
| 2283 void FlipPages(intptr_t flags, intptr_t flag_mask); | 2303 void FlipPages(intptr_t flags, intptr_t flag_mask); |
| 2284 | 2304 |
| 2285 // Updates Capacity and MaximumCommitted based on new capacity. | 2305 // Updates Capacity and MaximumCommitted based on new capacity. |
| 2286 void SetCapacity(int new_capacity); | 2306 void SetCapacity(int new_capacity); |
| 2287 | 2307 |
| 2308 // Allocates new shadow chunk for pages with indexes in the range |
| 2309 // [start_index, end_index). |
| 2310 // Returns false on allocation failure. |
| 2311 bool AllocateShadowChunksForPages(int start_index, int end_index); |
| 2312 |
| 2313 // Frees shadow chunk for pages with indexes in the range |
| 2314 // [start_index, end_index). |
| 2315 void FreeShadowChunksForPages(int start_index, int end_index); |
| 2316 |
| 2288 NewSpacePage* anchor() { return &anchor_; } | 2317 NewSpacePage* anchor() { return &anchor_; } |
| 2289 | 2318 |
| 2290 // The current and maximum capacity of the space. | 2319 // The current and maximum capacity of the space. |
| 2291 int capacity_; | 2320 int capacity_; |
| 2292 int maximum_capacity_; | 2321 int maximum_capacity_; |
| 2293 int initial_capacity_; | 2322 int initial_capacity_; |
| 2294 | 2323 |
| 2295 intptr_t maximum_committed_; | 2324 intptr_t maximum_committed_; |
| 2296 | 2325 |
| 2297 // The start address of the space. | 2326 // The start address of the space. |
| (...skipping 698 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2996 } | 3025 } |
| 2997 // Must be small, since an iteration is used for lookup. | 3026 // Must be small, since an iteration is used for lookup. |
| 2998 static const int kMaxComments = 64; | 3027 static const int kMaxComments = 64; |
| 2999 }; | 3028 }; |
| 3000 #endif | 3029 #endif |
| 3001 | 3030 |
| 3002 | 3031 |
| 3003 } } // namespace v8::internal | 3032 } } // namespace v8::internal |
| 3004 | 3033 |
| 3005 #endif // V8_SPACES_H_ | 3034 #endif // V8_SPACES_H_ |
| OLD | NEW |