| 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 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 if (seq_length > 0) { | 258 if (seq_length > 0) { |
| 259 PrintF("%d: %dx%d\n", | 259 PrintF("%d: %dx%d\n", |
| 260 seq_start, | 260 seq_start, |
| 261 seq_type == 0 ? 0 : 1, | 261 seq_type == 0 ? 0 : 1, |
| 262 seq_length * kBitsPerCell); | 262 seq_length * kBitsPerCell); |
| 263 seq_length = 0; | 263 seq_length = 0; |
| 264 } | 264 } |
| 265 } | 265 } |
| 266 | 266 |
| 267 static bool IsSeq(uint32_t cell) { return cell == 0 || cell == 0xFFFFFFFF; } | 267 static bool IsSeq(uint32_t cell) { return cell == 0 || cell == 0xFFFFFFFF; } |
| 268 |
| 268 private: | 269 private: |
| 269 uint32_t seq_start; | 270 uint32_t seq_start; |
| 270 uint32_t seq_type; | 271 uint32_t seq_type; |
| 271 uint32_t seq_length; | 272 uint32_t seq_length; |
| 272 }; | 273 }; |
| 273 | 274 |
| 274 void Print() { | 275 void Print() { |
| 275 CellPrinter printer; | 276 CellPrinter printer; |
| 276 for (int i = 0; i < CellsCount(); i++) { | 277 for (int i = 0; i < CellsCount(); i++) { |
| 277 printer.Print(i, cells()[i]); | 278 printer.Print(i, cells()[i]); |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 444 void SetFlags(intptr_t flags, intptr_t mask) { | 445 void SetFlags(intptr_t flags, intptr_t mask) { |
| 445 flags_ = (flags_ & ~mask) | (flags & mask); | 446 flags_ = (flags_ & ~mask) | (flags & mask); |
| 446 } | 447 } |
| 447 | 448 |
| 448 // Return all current flags. | 449 // Return all current flags. |
| 449 intptr_t GetFlags() { return flags_; } | 450 intptr_t GetFlags() { return flags_; } |
| 450 | 451 |
| 451 // Manage live byte count (count of bytes known to be live, | 452 // Manage live byte count (count of bytes known to be live, |
| 452 // because they are marked black). | 453 // because they are marked black). |
| 453 void ResetLiveBytes() { | 454 void ResetLiveBytes() { |
| 455 if (FLAG_trace_live_byte_count) { |
| 456 PrintF("ResetLiveBytes:%p:%x->0\n", |
| 457 static_cast<void*>(this), live_byte_count_); |
| 458 } |
| 454 live_byte_count_ = 0; | 459 live_byte_count_ = 0; |
| 455 } | 460 } |
| 456 void IncrementLiveBytes(int by) { | 461 void IncrementLiveBytes(int by) { |
| 462 ASSERT_LE(static_cast<unsigned>(live_byte_count_), size_); |
| 463 if (FLAG_trace_live_byte_count) { |
| 464 printf("UpdateLiveBytes:%p:%x%c=%x->%x\n", |
| 465 static_cast<void*>(this), live_byte_count_, |
| 466 ((by < 0) ? '-' : '+'), ((by < 0) ? -by : by), |
| 467 live_byte_count_ + by); |
| 468 } |
| 457 live_byte_count_ += by; | 469 live_byte_count_ += by; |
| 470 ASSERT_LE(static_cast<unsigned>(live_byte_count_), size_); |
| 458 } | 471 } |
| 459 int LiveBytes() { return live_byte_count_; } | 472 int LiveBytes() { |
| 473 ASSERT(static_cast<unsigned>(live_byte_count_) <= size_); |
| 474 return live_byte_count_; |
| 475 } |
| 460 static void IncrementLiveBytes(Address address, int by) { | 476 static void IncrementLiveBytes(Address address, int by) { |
| 461 MemoryChunk::FromAddress(address)->IncrementLiveBytes(by); | 477 MemoryChunk::FromAddress(address)->IncrementLiveBytes(by); |
| 462 } | 478 } |
| 463 | 479 |
| 464 static const intptr_t kAlignment = | 480 static const intptr_t kAlignment = |
| 465 (static_cast<uintptr_t>(1) << kPageSizeBits); | 481 (static_cast<uintptr_t>(1) << kPageSizeBits); |
| 466 | 482 |
| 467 static const intptr_t kAlignmentMask = kAlignment - 1; | 483 static const intptr_t kAlignmentMask = kAlignment - 1; |
| 468 | 484 |
| 485 static const intptr_t kSizeOffset = kPointerSize + kPointerSize; |
| 486 |
| 469 static const intptr_t kLiveBytesOffset = | 487 static const intptr_t kLiveBytesOffset = |
| 470 kPointerSize + kPointerSize + kPointerSize + kPointerSize + | 488 kSizeOffset + kPointerSize + kPointerSize + kPointerSize + |
| 471 kPointerSize + kPointerSize + kPointerSize + kPointerSize + | 489 kPointerSize + kPointerSize + kPointerSize + kIntSize; |
| 472 kIntSize; | |
| 473 | 490 |
| 474 static const size_t kSlotsBufferOffset = kLiveBytesOffset + kIntSize; | 491 static const size_t kSlotsBufferOffset = kLiveBytesOffset + kIntSize; |
| 475 | 492 |
| 476 static const size_t kHeaderSize = | 493 static const size_t kHeaderSize = |
| 477 kSlotsBufferOffset + kPointerSize + kPointerSize; | 494 kSlotsBufferOffset + kPointerSize + kPointerSize; |
| 478 | 495 |
| 479 static const int kBodyOffset = | 496 static const int kBodyOffset = |
| 480 CODE_POINTER_ALIGN(MAP_POINTER_ALIGN(kHeaderSize + Bitmap::kSize)); | 497 CODE_POINTER_ALIGN(MAP_POINTER_ALIGN(kHeaderSize + Bitmap::kSize)); |
| 481 | 498 |
| 482 // The start offset of the object area in a page. Aligned to both maps and | 499 // The start offset of the object area in a page. Aligned to both maps and |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 692 bool WasSweptPrecisely() { return IsFlagSet(WAS_SWEPT_PRECISELY); } | 709 bool WasSweptPrecisely() { return IsFlagSet(WAS_SWEPT_PRECISELY); } |
| 693 bool WasSweptConservatively() { return IsFlagSet(WAS_SWEPT_CONSERVATIVELY); } | 710 bool WasSweptConservatively() { return IsFlagSet(WAS_SWEPT_CONSERVATIVELY); } |
| 694 bool WasSwept() { return WasSweptPrecisely() || WasSweptConservatively(); } | 711 bool WasSwept() { return WasSweptPrecisely() || WasSweptConservatively(); } |
| 695 | 712 |
| 696 void MarkSweptPrecisely() { SetFlag(WAS_SWEPT_PRECISELY); } | 713 void MarkSweptPrecisely() { SetFlag(WAS_SWEPT_PRECISELY); } |
| 697 void MarkSweptConservatively() { SetFlag(WAS_SWEPT_CONSERVATIVELY); } | 714 void MarkSweptConservatively() { SetFlag(WAS_SWEPT_CONSERVATIVELY); } |
| 698 | 715 |
| 699 void ClearSweptPrecisely() { ClearFlag(WAS_SWEPT_PRECISELY); } | 716 void ClearSweptPrecisely() { ClearFlag(WAS_SWEPT_PRECISELY); } |
| 700 void ClearSweptConservatively() { ClearFlag(WAS_SWEPT_CONSERVATIVELY); } | 717 void ClearSweptConservatively() { ClearFlag(WAS_SWEPT_CONSERVATIVELY); } |
| 701 | 718 |
| 719 #ifdef DEBUG |
| 720 void Print(); |
| 721 #endif // DEBUG |
| 722 |
| 702 friend class MemoryAllocator; | 723 friend class MemoryAllocator; |
| 703 }; | 724 }; |
| 704 | 725 |
| 705 | 726 |
| 706 STATIC_CHECK(sizeof(Page) <= MemoryChunk::kHeaderSize); | 727 STATIC_CHECK(sizeof(Page) <= MemoryChunk::kHeaderSize); |
| 707 | 728 |
| 708 | 729 |
| 709 class LargePage : public MemoryChunk { | 730 class LargePage : public MemoryChunk { |
| 710 public: | 731 public: |
| 711 HeapObject* GetObject() { | 732 HeapObject* GetObject() { |
| (...skipping 1884 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2596 } | 2617 } |
| 2597 // Must be small, since an iteration is used for lookup. | 2618 // Must be small, since an iteration is used for lookup. |
| 2598 static const int kMaxComments = 64; | 2619 static const int kMaxComments = 64; |
| 2599 }; | 2620 }; |
| 2600 #endif | 2621 #endif |
| 2601 | 2622 |
| 2602 | 2623 |
| 2603 } } // namespace v8::internal | 2624 } } // namespace v8::internal |
| 2604 | 2625 |
| 2605 #endif // V8_SPACES_H_ | 2626 #endif // V8_SPACES_H_ |
| OLD | NEW |