| 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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 // three areas: the first two words are used for bookkeeping, the next 248 | 91 // three areas: the first two words are used for bookkeeping, the next 248 |
| 92 // bytes are used as remembered set, and the rest of the page is the object | 92 // bytes are used as remembered set, and the rest of the page is the object |
| 93 // area. | 93 // area. |
| 94 // | 94 // |
| 95 // Pointers are aligned to the pointer size (4 bytes), only 1 bit is needed | 95 // Pointers are aligned to the pointer size (4 bytes), only 1 bit is needed |
| 96 // for a pointer in the remembered set. Given an address, its remembered set | 96 // for a pointer in the remembered set. Given an address, its remembered set |
| 97 // bit position (offset from the start of the page) is calculated by dividing | 97 // bit position (offset from the start of the page) is calculated by dividing |
| 98 // its page offset by 32. Therefore, the object area in a page starts at the | 98 // its page offset by 32. Therefore, the object area in a page starts at the |
| 99 // 256th byte (8K/32). Bytes 0 to 255 do not need the remembered set, so that | 99 // 256th byte (8K/32). Bytes 0 to 255 do not need the remembered set, so that |
| 100 // the first two words (64 bits) in a page can be used for other purposes. | 100 // the first two words (64 bits) in a page can be used for other purposes. |
| 101 // TODO(X64): This description only represents the 32-bit layout. |
| 101 // | 102 // |
| 102 // The mark-compact collector transforms a map pointer into a page index and a | 103 // The mark-compact collector transforms a map pointer into a page index and a |
| 103 // page offset. The map space can have up to 1024 pages, and 8M bytes (1024 * | 104 // page offset. The map space can have up to 1024 pages, and 8M bytes (1024 * |
| 104 // 8K) in total. Because a map pointer is aligned to the pointer size (4 | 105 // 8K) in total. Because a map pointer is aligned to the pointer size (4 |
| 105 // bytes), 11 bits are enough to encode the page offset. 21 bits (10 for the | 106 // bytes), 11 bits are enough to encode the page offset. 21 bits (10 for the |
| 106 // page index + 11 for the offset in the page) are required to encode a map | 107 // page index + 11 for the offset in the page) are required to encode a map |
| 107 // pointer. | 108 // pointer. |
| 108 // | 109 // |
| 109 // The only way to get a page pointer is by calling factory methods: | 110 // The only way to get a page pointer is by calling factory methods: |
| 110 // Page* p = Page::FromAddress(addr); or | 111 // Page* p = Page::FromAddress(addr); or |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 static void set_rset_state(RSetState state) { rset_state_ = state; } | 207 static void set_rset_state(RSetState state) { rset_state_ = state; } |
| 207 #endif | 208 #endif |
| 208 | 209 |
| 209 // 8K bytes per page. | 210 // 8K bytes per page. |
| 210 static const int kPageSizeBits = 13; | 211 static const int kPageSizeBits = 13; |
| 211 | 212 |
| 212 // Page size in bytes. This must be a multiple of the OS page size. | 213 // Page size in bytes. This must be a multiple of the OS page size. |
| 213 static const int kPageSize = 1 << kPageSizeBits; | 214 static const int kPageSize = 1 << kPageSizeBits; |
| 214 | 215 |
| 215 // Page size mask. | 216 // Page size mask. |
| 216 static const int kPageAlignmentMask = (1 << kPageSizeBits) - 1; | 217 static const intptr_t kPageAlignmentMask = (1 << kPageSizeBits) - 1; |
| 217 | 218 |
| 218 // The end offset of the remembered set in a page | 219 // The end offset of the remembered set in a page |
| 219 // (heaps are aligned to pointer size). | 220 // (heaps are aligned to pointer size). |
| 220 static const int kRSetEndOffset= kPageSize / kBitsPerPointer; | 221 static const int kRSetEndOffset= kPageSize / kBitsPerPointer; |
| 221 | 222 |
| 222 // The start offset of the remembered set in a page. | 223 // The start offset of the remembered set in a page. |
| 223 static const int kRSetStartOffset = kRSetEndOffset / kBitsPerPointer; | 224 static const int kRSetStartOffset = kRSetEndOffset / kBitsPerPointer; |
| 224 | 225 |
| 225 // The start offset of the object area in a page. | 226 // The start offset of the object area in a page. |
| 226 static const int kObjectStartOffset = kRSetEndOffset; | 227 static const int kObjectStartOffset = kRSetEndOffset; |
| 227 | 228 |
| 228 // Object area size in bytes. | 229 // Object area size in bytes. |
| 229 static const int kObjectAreaSize = kPageSize - kObjectStartOffset; | 230 static const int kObjectAreaSize = kPageSize - kObjectStartOffset; |
| 230 | 231 |
| 231 // Maximum object size that fits in a page. | 232 // Maximum object size that fits in a page. |
| 232 static const int kMaxHeapObjectSize = kObjectAreaSize; | 233 static const int kMaxHeapObjectSize = kObjectAreaSize; |
| 233 | 234 |
| 234 //--------------------------------------------------------------------------- | 235 //--------------------------------------------------------------------------- |
| 235 // Page header description. | 236 // Page header description. |
| 236 // | 237 // |
| 237 // If a page is not in the large object space, the first word, | 238 // If a page is not in the large object space, the first word, |
| 238 // opaque_header, encodes the next page address (aligned to kPageSize 8K) | 239 // opaque_header, encodes the next page address (aligned to kPageSize 8K) |
| 239 // and the chunk number (0 ~ 8K-1). Only MemoryAllocator should use | 240 // and the chunk number (0 ~ 8K-1). Only MemoryAllocator should use |
| 240 // opaque_header. The value range of the opaque_header is [0..kPageSize[, | 241 // opaque_header. The value range of the opaque_header is [0..kPageSize[, |
| 241 // or [next_page_start, next_page_end[. It cannot point to a valid address | 242 // or [next_page_start, next_page_end[. It cannot point to a valid address |
| 242 // in the current page. If a page is in the large object space, the first | 243 // in the current page. If a page is in the large object space, the first |
| 243 // word *may* (if the page start and large object chunk start are the | 244 // word *may* (if the page start and large object chunk start are the |
| 244 // same) contain the address of the next large object chunk. | 245 // same) contain the address of the next large object chunk. |
| 245 int opaque_header; | 246 intptr_t opaque_header; |
| 246 | 247 |
| 247 // If the page is not in the large object space, the low-order bit of the | 248 // If the page is not in the large object space, the low-order bit of the |
| 248 // second word is set. If the page is in the large object space, the | 249 // second word is set. If the page is in the large object space, the |
| 249 // second word *may* (if the page start and large object chunk start are | 250 // second word *may* (if the page start and large object chunk start are |
| 250 // the same) contain the large object chunk size. In either case, the | 251 // the same) contain the large object chunk size. In either case, the |
| 251 // low-order bit for large object pages will be cleared. | 252 // low-order bit for large object pages will be cleared. |
| 252 int is_normal_page; | 253 int is_normal_page; |
| 253 | 254 |
| 254 // The following fields overlap with remembered set, they can only | 255 // The following fields overlap with remembered set, they can only |
| 255 // be used in the mark-compact collector when remembered set is not | 256 // be used in the mark-compact collector when remembered set is not |
| (...skipping 1472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1728 | 1729 |
| 1729 private: | 1730 private: |
| 1730 LargeObjectChunk* current_; | 1731 LargeObjectChunk* current_; |
| 1731 HeapObjectCallback size_func_; | 1732 HeapObjectCallback size_func_; |
| 1732 }; | 1733 }; |
| 1733 | 1734 |
| 1734 | 1735 |
| 1735 } } // namespace v8::internal | 1736 } } // namespace v8::internal |
| 1736 | 1737 |
| 1737 #endif // V8_SPACES_H_ | 1738 #endif // V8_SPACES_H_ |
| OLD | NEW |