OLD | NEW |
---|---|
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
86 class MemoryAllocator; | 86 class MemoryAllocator; |
87 class AllocationInfo; | 87 class AllocationInfo; |
88 | 88 |
89 // ----------------------------------------------------------------------------- | 89 // ----------------------------------------------------------------------------- |
90 // A page normally has 8K bytes. Large object pages may be larger. A page | 90 // A page normally has 8K bytes. Large object pages may be larger. A page |
91 // address is always aligned to the 8K page size. A page is divided into | 91 // address is always aligned to the 8K page size. A page is divided into |
92 // three areas: the first two words are used for bookkeeping, the next 248 | 92 // three areas: the first two words are used for bookkeeping, the next 248 |
93 // bytes are used as remembered set, and the rest of the page is the object | 93 // bytes are used as remembered set, and the rest of the page is the object |
94 // area. | 94 // area. |
95 // | 95 // |
96 // Pointers are aligned to the pointer size (4 bytes), only 1 bit is needed | 96 // Pointers are aligned to the pointer size (4), only 1 bit is needed |
97 // for a pointer in the remembered set. Given an address, its remembered set | 97 // for a pointer in the remembered set. Given an address, its remembered set |
98 // bit position (offset from the start of the page) is calculated by dividing | 98 // bit position (offset from the start of the page) is calculated by dividing |
99 // its page offset by 32. Therefore, the object area in a page starts at the | 99 // its page offset by 32. Therefore, the object area in a page starts at the |
100 // 256th byte (8K/32). Bytes 0 to 255 do not need the remembered set, so that | 100 // 256th byte (8K/32). Bytes 0 to 255 do not need the remembered set, so that |
101 // the first two words (64 bits) in a page can be used for other purposes. | 101 // the first two words (64 bits) in a page can be used for other purposes. |
102 // TODO(X64): This description only represents the 32-bit layout. | 102 // TODO(X64): This description only represents the 32-bit layout. |
103 // On the 64-bit platform, we add an offset to the start of the remembered set. | |
103 // | 104 // |
104 // The mark-compact collector transforms a map pointer into a page index and a | 105 // The mark-compact collector transforms a map pointer into a page index and a |
105 // page offset. The map space can have up to 1024 pages, and 8M bytes (1024 * | 106 // page offset. The map space can have up to 1024 pages, and 8M bytes (1024 * |
106 // 8K) in total. Because a map pointer is aligned to the pointer size (4 | 107 // 8K) in total. Because a map pointer is aligned to the pointer size (4 |
107 // bytes), 11 bits are enough to encode the page offset. 21 bits (10 for the | 108 // bytes), 11 bits are enough to encode the page offset. 21 bits (10 for the |
108 // page index + 11 for the offset in the page) are required to encode a map | 109 // page index + 11 for the offset in the page) are required to encode a map |
109 // pointer. | 110 // pointer. |
110 // | 111 // |
111 // The only way to get a page pointer is by calling factory methods: | 112 // The only way to get a page pointer is by calling factory methods: |
112 // Page* p = Page::FromAddress(addr); or | 113 // Page* p = Page::FromAddress(addr); or |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
210 | 211 |
211 // 8K bytes per page. | 212 // 8K bytes per page. |
212 static const int kPageSizeBits = 13; | 213 static const int kPageSizeBits = 13; |
213 | 214 |
214 // Page size in bytes. This must be a multiple of the OS page size. | 215 // Page size in bytes. This must be a multiple of the OS page size. |
215 static const int kPageSize = 1 << kPageSizeBits; | 216 static const int kPageSize = 1 << kPageSizeBits; |
216 | 217 |
217 // Page size mask. | 218 // Page size mask. |
218 static const intptr_t kPageAlignmentMask = (1 << kPageSizeBits) - 1; | 219 static const intptr_t kPageAlignmentMask = (1 << kPageSizeBits) - 1; |
219 | 220 |
221 // The offset of the remembered set in a page, in addition to the empty words | |
222 // formed as the remembered bits of the remembered set itself. | |
223 #ifdef V8_TARGET_ARCH_X64 | |
224 static const int kRSetOffset = 2 * kPointerSize; // Room for two pointers. | |
Lasse Reichstein
2009/07/01 12:30:18
Since we have room for it, we might want the RSet
| |
225 #else | |
226 static const int kRSetOffset = 0; | |
227 #endif | |
220 // The end offset of the remembered set in a page | 228 // The end offset of the remembered set in a page |
221 // (heaps are aligned to pointer size). | 229 // (heaps are aligned to pointer size). |
222 static const int kRSetEndOffset= kPageSize / kBitsPerPointer; | 230 static const int kRSetEndOffset = kRSetOffset + kPageSize / kBitsPerPointer; |
231 | |
232 // The start offset of the object area in a page. | |
233 #ifdef V8_TARGET_ARCH_X64 | |
234 static const int kObjectStartOffset = 256; | |
Lasse Reichstein
2009/07/01 12:30:18
We should be able to lower this to 160 and still w
| |
235 #else | |
236 static const int kObjectStartOffset = kRSetEndOffset; | |
237 #endif | |
223 | 238 |
224 // The start offset of the remembered set in a page. | 239 // The start offset of the remembered set in a page. |
225 static const int kRSetStartOffset = kRSetEndOffset / kBitsPerPointer; | 240 static const int kRSetStartOffset = kRSetOffset + |
226 | 241 kObjectStartOffset / kBitsPerPointer; |
227 // The start offset of the object area in a page. | |
228 static const int kObjectStartOffset = kRSetEndOffset; | |
229 | 242 |
230 // Object area size in bytes. | 243 // Object area size in bytes. |
231 static const int kObjectAreaSize = kPageSize - kObjectStartOffset; | 244 static const int kObjectAreaSize = kPageSize - kObjectStartOffset; |
232 | 245 |
233 // Maximum object size that fits in a page. | 246 // Maximum object size that fits in a page. |
234 static const int kMaxHeapObjectSize = kObjectAreaSize; | 247 static const int kMaxHeapObjectSize = kObjectAreaSize; |
235 | 248 |
236 //--------------------------------------------------------------------------- | 249 //--------------------------------------------------------------------------- |
237 // Page header description. | 250 // Page header description. |
238 // | 251 // |
(...skipping 1491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1730 | 1743 |
1731 private: | 1744 private: |
1732 LargeObjectChunk* current_; | 1745 LargeObjectChunk* current_; |
1733 HeapObjectCallback size_func_; | 1746 HeapObjectCallback size_func_; |
1734 }; | 1747 }; |
1735 | 1748 |
1736 | 1749 |
1737 } } // namespace v8::internal | 1750 } } // namespace v8::internal |
1738 | 1751 |
1739 #endif // V8_SPACES_H_ | 1752 #endif // V8_SPACES_H_ |
OLD | NEW |