| OLD | NEW |
| 1 // Copyright 2006-2010 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2010 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | 27 |
| 28 #ifndef V8_SPACES_H_ | 28 #ifndef V8_SPACES_H_ |
| 29 #define V8_SPACES_H_ | 29 #define V8_SPACES_H_ |
| 30 | 30 |
| 31 #include "atomicops.h" | |
| 32 #include "list-inl.h" | 31 #include "list-inl.h" |
| 33 #include "log.h" | 32 #include "log.h" |
| 34 | 33 |
| 35 namespace v8 { | 34 namespace v8 { |
| 36 namespace internal { | 35 namespace internal { |
| 37 | 36 |
| 38 // ----------------------------------------------------------------------------- | 37 // ----------------------------------------------------------------------------- |
| 39 // Heap structures: | 38 // Heap structures: |
| 40 // | 39 // |
| 41 // A JS heap consists of a young generation, an old generation, and a large | 40 // A JS heap consists of a young generation, an old generation, and a large |
| (...skipping 639 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 681 private: | 680 private: |
| 682 static const int kChunkSize = kPagesPerChunk * Page::kPageSize; | 681 static const int kChunkSize = kPagesPerChunk * Page::kPageSize; |
| 683 static const int kChunkSizeLog2 = kPagesPerChunkLog2 + kPageSizeBits; | 682 static const int kChunkSizeLog2 = kPagesPerChunkLog2 + kPageSizeBits; |
| 684 static const int kChunkTableTopLevelEntries = | 683 static const int kChunkTableTopLevelEntries = |
| 685 1 << (sizeof(intptr_t) * kBitsPerByte - kChunkSizeLog2 - | 684 1 << (sizeof(intptr_t) * kBitsPerByte - kChunkSizeLog2 - |
| 686 (kChunkTableLevels - 1) * kChunkTableBitsPerLevel); | 685 (kChunkTableLevels - 1) * kChunkTableBitsPerLevel); |
| 687 | 686 |
| 688 // The chunks are not chunk-size aligned so for a given chunk-sized area of | 687 // The chunks are not chunk-size aligned so for a given chunk-sized area of |
| 689 // memory there can be two chunks that cover it. | 688 // memory there can be two chunks that cover it. |
| 690 static const int kChunkTableFineGrainedWordsPerEntry = 2; | 689 static const int kChunkTableFineGrainedWordsPerEntry = 2; |
| 691 static const AtomicWord kUnusedChunkTableEntry = 0; | 690 static const uintptr_t kUnusedChunkTableEntry = 0; |
| 692 | 691 |
| 693 // Maximum space size in bytes. | 692 // Maximum space size in bytes. |
| 694 static intptr_t capacity_; | 693 static intptr_t capacity_; |
| 695 // Maximum subset of capacity_ that can be executable | 694 // Maximum subset of capacity_ that can be executable |
| 696 static intptr_t capacity_executable_; | 695 static intptr_t capacity_executable_; |
| 697 | 696 |
| 698 // Top level table to track whether memory is part of a chunk or not. | 697 // Top level table to track whether memory is part of a chunk or not. |
| 699 static AtomicWord chunk_table_[kChunkTableTopLevelEntries]; | 698 static uintptr_t chunk_table_[kChunkTableTopLevelEntries]; |
| 700 | 699 |
| 701 // Allocated space size in bytes. | 700 // Allocated space size in bytes. |
| 702 static intptr_t size_; | 701 static intptr_t size_; |
| 703 // Allocated executable space size in bytes. | 702 // Allocated executable space size in bytes. |
| 704 static intptr_t size_executable_; | 703 static intptr_t size_executable_; |
| 705 | 704 |
| 706 struct MemoryAllocationCallbackRegistration { | 705 struct MemoryAllocationCallbackRegistration { |
| 707 MemoryAllocationCallbackRegistration(MemoryAllocationCallback callback, | 706 MemoryAllocationCallbackRegistration(MemoryAllocationCallback callback, |
| 708 ObjectSpace space, | 707 ObjectSpace space, |
| 709 AllocationAction action) | 708 AllocationAction action) |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 759 // Helpers to maintain and query the chunk tables. | 758 // Helpers to maintain and query the chunk tables. |
| 760 static void AddChunkUsingAddress( | 759 static void AddChunkUsingAddress( |
| 761 uintptr_t chunk_start, // Where the chunk starts. | 760 uintptr_t chunk_start, // Where the chunk starts. |
| 762 uintptr_t chunk_index_base); // Used to place the chunk in the tables. | 761 uintptr_t chunk_index_base); // Used to place the chunk in the tables. |
| 763 static void RemoveChunkFoundUsingAddress( | 762 static void RemoveChunkFoundUsingAddress( |
| 764 uintptr_t chunk_start, // Where the chunk starts. | 763 uintptr_t chunk_start, // Where the chunk starts. |
| 765 uintptr_t chunk_index_base); // Used to locate the entry in the tables. | 764 uintptr_t chunk_index_base); // Used to locate the entry in the tables. |
| 766 // Controls whether the lookup creates intermediate levels of tables as | 765 // Controls whether the lookup creates intermediate levels of tables as |
| 767 // needed. | 766 // needed. |
| 768 enum CreateTables { kDontCreateTables, kCreateTablesAsNeeded }; | 767 enum CreateTables { kDontCreateTables, kCreateTablesAsNeeded }; |
| 769 static AtomicWord* AllocatedChunksFinder(AtomicWord* table, | 768 static uintptr_t* AllocatedChunksFinder(uintptr_t* table, |
| 770 uintptr_t address, | 769 uintptr_t address, |
| 771 int bit_position, | 770 int bit_position, |
| 772 CreateTables create_as_needed); | 771 CreateTables create_as_needed); |
| 773 static void FreeChunkTables(AtomicWord* array, int length, int level); | 772 static void FreeChunkTables(uintptr_t* array, int length, int level); |
| 774 static int FineGrainedIndexForAddress(uintptr_t address) { | 773 static int FineGrainedIndexForAddress(uintptr_t address) { |
| 775 int index = ((address >> kChunkSizeLog2) & | 774 int index = ((address >> kChunkSizeLog2) & |
| 776 ((1 << kChunkTableBitsPerLevel) - 1)); | 775 ((1 << kChunkTableBitsPerLevel) - 1)); |
| 777 return index * kChunkTableFineGrainedWordsPerEntry; | 776 return index * kChunkTableFineGrainedWordsPerEntry; |
| 778 } | 777 } |
| 779 | 778 |
| 780 | 779 |
| 781 // Basic check whether a chunk id is in the valid range. | 780 // Basic check whether a chunk id is in the valid range. |
| 782 static inline bool IsValidChunkId(int chunk_id); | 781 static inline bool IsValidChunkId(int chunk_id); |
| 783 | 782 |
| (...skipping 1564 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2348 | 2347 |
| 2349 private: | 2348 private: |
| 2350 LargeObjectChunk* current_; | 2349 LargeObjectChunk* current_; |
| 2351 HeapObjectCallback size_func_; | 2350 HeapObjectCallback size_func_; |
| 2352 }; | 2351 }; |
| 2353 | 2352 |
| 2354 | 2353 |
| 2355 } } // namespace v8::internal | 2354 } } // namespace v8::internal |
| 2356 | 2355 |
| 2357 #endif // V8_SPACES_H_ | 2356 #endif // V8_SPACES_H_ |
| OLD | NEW |