OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 CellType mask_; | 157 CellType mask_; |
158 // This boolean indicates that the object is in a data-only space with no | 158 // This boolean indicates that the object is in a data-only space with no |
159 // pointers. This enables some optimizations when marking. | 159 // pointers. This enables some optimizations when marking. |
160 // It is expected that this field is inlined and turned into control flow | 160 // It is expected that this field is inlined and turned into control flow |
161 // at the place where the MarkBit object is created. | 161 // at the place where the MarkBit object is created. |
162 bool data_only_; | 162 bool data_only_; |
163 }; | 163 }; |
164 | 164 |
165 | 165 |
166 // Bitmap is a sequence of cells each containing fixed number of bits. | 166 // Bitmap is a sequence of cells each containing fixed number of bits. |
167 template<typename StorageDescriptor> | |
168 class Bitmap { | 167 class Bitmap { |
169 public: | 168 public: |
170 static const uint32_t kBitsPerCell = 32; | 169 static const uint32_t kBitsPerCell = 32; |
171 static const uint32_t kBitsPerCellLog2 = 5; | 170 static const uint32_t kBitsPerCellLog2 = 5; |
172 static const uint32_t kBitIndexMask = kBitsPerCell - 1; | 171 static const uint32_t kBitIndexMask = kBitsPerCell - 1; |
173 | 172 |
| 173 static const size_t kLength = |
| 174 (1 << kPageSizeBits) >> (kPointerSizeLog2); |
| 175 |
| 176 static const size_t kSize = |
| 177 (1 << kPageSizeBits) >> (kPointerSizeLog2 + kBitsPerByteLog2); |
| 178 |
| 179 |
174 static int CellsForLength(int length) { | 180 static int CellsForLength(int length) { |
175 return (length + kBitsPerCell - 1) >> kBitsPerCellLog2; | 181 return (length + kBitsPerCell - 1) >> kBitsPerCellLog2; |
176 } | 182 } |
177 | 183 |
178 int CellsCount() { | 184 int CellsCount() { |
179 return StorageDescriptor::CellsCount(this->address()); | 185 return CellsForLength(kLength); |
180 } | 186 } |
181 | 187 |
182 static int SizeFor(int cells_count) { | 188 static int SizeFor(int cells_count) { |
183 return sizeof(MarkBit::CellType)*cells_count; | 189 return sizeof(MarkBit::CellType)*cells_count; |
184 } | 190 } |
185 | 191 |
186 INLINE(static uint32_t IndexToCell(uint32_t index)) { | 192 INLINE(static uint32_t IndexToCell(uint32_t index)) { |
187 return index >> kBitsPerCellLog2; | 193 return index >> kBitsPerCellLog2; |
188 } | 194 } |
189 | 195 |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
388 flags_ = chunk->flags_; | 394 flags_ = chunk->flags_; |
389 } | 395 } |
390 | 396 |
391 static const intptr_t kAlignment = (1 << kPageSizeBits); | 397 static const intptr_t kAlignment = (1 << kPageSizeBits); |
392 | 398 |
393 static const intptr_t kAlignmentMask = kAlignment - 1; | 399 static const intptr_t kAlignmentMask = kAlignment - 1; |
394 | 400 |
395 static const size_t kHeaderSize = kPointerSize + kPointerSize + kPointerSize + | 401 static const size_t kHeaderSize = kPointerSize + kPointerSize + kPointerSize + |
396 kPointerSize + kPointerSize + kPointerSize + kPointerSize + kPointerSize; | 402 kPointerSize + kPointerSize + kPointerSize + kPointerSize + kPointerSize; |
397 | 403 |
398 static const size_t kMarksBitmapLength = | |
399 (1 << kPageSizeBits) >> (kPointerSizeLog2); | |
400 | |
401 static const size_t kMarksBitmapSize = | |
402 (1 << kPageSizeBits) >> (kPointerSizeLog2 + kBitsPerByteLog2); | |
403 | |
404 static const int kBodyOffset = | 404 static const int kBodyOffset = |
405 CODE_POINTER_ALIGN(MAP_POINTER_ALIGN(kHeaderSize + kMarksBitmapSize)); | 405 CODE_POINTER_ALIGN(MAP_POINTER_ALIGN(kHeaderSize + Bitmap::kSize)); |
406 | 406 |
407 // The start offset of the object area in a page. Aligned to both maps and | 407 // The start offset of the object area in a page. Aligned to both maps and |
408 // code alignment to be suitable for both. Also aligned to 32 words because | 408 // code alignment to be suitable for both. Also aligned to 32 words because |
409 // the marking bitmap is arranged in 32 bit chunks. | 409 // the marking bitmap is arranged in 32 bit chunks. |
410 static const int kObjectStartAlignment = 32 * kPointerSize; | 410 static const int kObjectStartAlignment = 32 * kPointerSize; |
411 static const int kObjectStartOffset = kBodyOffset - 1 + | 411 static const int kObjectStartOffset = kBodyOffset - 1 + |
412 (kObjectStartAlignment - (kBodyOffset - 1) % kObjectStartAlignment); | 412 (kObjectStartAlignment - (kBodyOffset - 1) % kObjectStartAlignment); |
413 | 413 |
414 size_t size() const { return size_; } | 414 size_t size() const { return size_; } |
415 | 415 |
416 Executability executable() { | 416 Executability executable() { |
417 return IsFlagSet(IS_EXECUTABLE) ? EXECUTABLE : NOT_EXECUTABLE; | 417 return IsFlagSet(IS_EXECUTABLE) ? EXECUTABLE : NOT_EXECUTABLE; |
418 } | 418 } |
419 | 419 |
420 bool ContainsOnlyData() { | 420 bool ContainsOnlyData() { |
421 return IsFlagSet(CONTAINS_ONLY_DATA); | 421 return IsFlagSet(CONTAINS_ONLY_DATA); |
422 } | 422 } |
423 | 423 |
424 // --------------------------------------------------------------------- | 424 // --------------------------------------------------------------------- |
425 // Markbits support | 425 // Markbits support |
426 | 426 |
427 class BitmapStorageDescriptor { | 427 inline Bitmap* markbits() { |
428 public: | 428 return Bitmap::FromAddress(address() + kHeaderSize); |
429 INLINE(static int CellsCount(Address addr)) { | |
430 return Bitmap<BitmapStorageDescriptor>::CellsForLength( | |
431 kMarksBitmapLength); | |
432 } | |
433 }; | |
434 | |
435 typedef Bitmap<BitmapStorageDescriptor> MarkbitsBitmap; | |
436 | |
437 inline MarkbitsBitmap* markbits() { | |
438 return MarkbitsBitmap::FromAddress(address() + kHeaderSize); | |
439 } | 429 } |
440 | 430 |
441 void PrintMarkbits() { markbits()->Print(); } | 431 void PrintMarkbits() { markbits()->Print(); } |
442 | 432 |
443 inline uint32_t AddressToMarkbitIndex(Address addr) { | 433 inline uint32_t AddressToMarkbitIndex(Address addr) { |
444 return static_cast<uint32_t>(addr - this->address()) >> kPointerSizeLog2; | 434 return static_cast<uint32_t>(addr - this->address()) >> kPointerSizeLog2; |
445 } | 435 } |
446 | 436 |
447 inline static uint32_t FastAddressToMarkbitIndex(Address addr) { | 437 inline static uint32_t FastAddressToMarkbitIndex(Address addr) { |
448 const intptr_t offset = | 438 const intptr_t offset = |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
551 // Page size mask. | 541 // Page size mask. |
552 static const intptr_t kPageAlignmentMask = (1 << kPageSizeBits) - 1; | 542 static const intptr_t kPageAlignmentMask = (1 << kPageSizeBits) - 1; |
553 | 543 |
554 // Object area size in bytes. | 544 // Object area size in bytes. |
555 static const int kObjectAreaSize = kPageSize - kObjectStartOffset; | 545 static const int kObjectAreaSize = kPageSize - kObjectStartOffset; |
556 | 546 |
557 // Maximum object size that fits in a page. | 547 // Maximum object size that fits in a page. |
558 static const int kMaxHeapObjectSize = kObjectAreaSize; | 548 static const int kMaxHeapObjectSize = kObjectAreaSize; |
559 | 549 |
560 static const int kFirstUsedCell = | 550 static const int kFirstUsedCell = |
561 (kObjectStartOffset/kPointerSize) >> MarkbitsBitmap::kBitsPerCellLog2; | 551 (kObjectStartOffset/kPointerSize) >> Bitmap::kBitsPerCellLog2; |
562 | 552 |
563 static const int kLastUsedCell = | 553 static const int kLastUsedCell = |
564 ((kPageSize - kPointerSize)/kPointerSize) >> | 554 ((kPageSize - kPointerSize)/kPointerSize) >> |
565 MarkbitsBitmap::kBitsPerCellLog2; | 555 Bitmap::kBitsPerCellLog2; |
566 | 556 |
567 inline void ClearGCFields(); | 557 inline void ClearGCFields(); |
568 | 558 |
569 static inline Page* Initialize(Heap* heap, | 559 static inline Page* Initialize(Heap* heap, |
570 MemoryChunk* chunk, | 560 MemoryChunk* chunk, |
571 Executability executable, | 561 Executability executable, |
572 PagedSpace* owner); | 562 PagedSpace* owner); |
573 | 563 |
574 void InitializeAsAnchor(PagedSpace* owner); | 564 void InitializeAsAnchor(PagedSpace* owner); |
575 | 565 |
(...skipping 1287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1863 } | 1853 } |
1864 | 1854 |
1865 inline intptr_t inline_alloction_limit_step() { | 1855 inline intptr_t inline_alloction_limit_step() { |
1866 return inline_alloction_limit_step_; | 1856 return inline_alloction_limit_step_; |
1867 } | 1857 } |
1868 | 1858 |
1869 NewSpacePage* ActivePage() { | 1859 NewSpacePage* ActivePage() { |
1870 return to_space_.current_page(); | 1860 return to_space_.current_page(); |
1871 } | 1861 } |
1872 | 1862 |
| 1863 NewSpacePage* InactivePage() { |
| 1864 return from_space_.current_page(); |
| 1865 } |
| 1866 |
1873 private: | 1867 private: |
1874 Address chunk_base_; | 1868 Address chunk_base_; |
1875 uintptr_t chunk_size_; | 1869 uintptr_t chunk_size_; |
1876 | 1870 |
1877 // The semispaces. | 1871 // The semispaces. |
1878 SemiSpace to_space_; | 1872 SemiSpace to_space_; |
1879 SemiSpace from_space_; | 1873 SemiSpace from_space_; |
1880 | 1874 |
1881 // Start address and bit mask for containment testing. | 1875 // Start address and bit mask for containment testing. |
1882 Address start_; | 1876 Address start_; |
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2259 } | 2253 } |
2260 // Must be small, since an iteration is used for lookup. | 2254 // Must be small, since an iteration is used for lookup. |
2261 static const int kMaxComments = 64; | 2255 static const int kMaxComments = 64; |
2262 }; | 2256 }; |
2263 #endif | 2257 #endif |
2264 | 2258 |
2265 | 2259 |
2266 } } // namespace v8::internal | 2260 } } // namespace v8::internal |
2267 | 2261 |
2268 #endif // V8_SPACES_H_ | 2262 #endif // V8_SPACES_H_ |
OLD | NEW |