OLD | NEW |
---|---|
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef V8_HEAP_SPACES_H_ | 5 #ifndef V8_HEAP_SPACES_H_ |
6 #define V8_HEAP_SPACES_H_ | 6 #define V8_HEAP_SPACES_H_ |
7 | 7 |
8 #include "src/allocation.h" | 8 #include "src/allocation.h" |
9 #include "src/atomic-utils.h" | 9 #include "src/atomic-utils.h" |
10 #include "src/base/atomicops.h" | 10 #include "src/base/atomicops.h" |
11 #include "src/base/bits.h" | 11 #include "src/base/bits.h" |
12 #include "src/base/platform/mutex.h" | 12 #include "src/base/platform/mutex.h" |
13 #include "src/flags.h" | 13 #include "src/flags.h" |
14 #include "src/hashmap.h" | 14 #include "src/hashmap.h" |
15 #include "src/heap/store-buffer.h" | |
15 #include "src/list.h" | 16 #include "src/list.h" |
16 #include "src/objects.h" | 17 #include "src/objects.h" |
17 #include "src/utils.h" | 18 #include "src/utils.h" |
18 | 19 |
19 namespace v8 { | 20 namespace v8 { |
20 namespace internal { | 21 namespace internal { |
21 | 22 |
22 class CompactionSpaceCollection; | 23 class CompactionSpaceCollection; |
23 class Isolate; | 24 class Isolate; |
24 | 25 |
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
389 static const intptr_t kSizeOffset = 0; | 390 static const intptr_t kSizeOffset = 0; |
390 | 391 |
391 static const intptr_t kLiveBytesOffset = | 392 static const intptr_t kLiveBytesOffset = |
392 kSizeOffset + kPointerSize // size_t size | 393 kSizeOffset + kPointerSize // size_t size |
393 + kIntptrSize // intptr_t flags_ | 394 + kIntptrSize // intptr_t flags_ |
394 + kPointerSize // Address area_start_ | 395 + kPointerSize // Address area_start_ |
395 + kPointerSize // Address area_end_ | 396 + kPointerSize // Address area_end_ |
396 + 2 * kPointerSize // base::VirtualMemory reservation_ | 397 + 2 * kPointerSize // base::VirtualMemory reservation_ |
397 + kPointerSize // Address owner_ | 398 + kPointerSize // Address owner_ |
398 + kPointerSize // Heap* heap_ | 399 + kPointerSize // Heap* heap_ |
399 + kIntSize; // int store_buffer_counter_ | 400 + kIntSize; // int progress_bar_ |
400 | 401 |
401 static const size_t kSlotsBufferOffset = | 402 static const size_t kSlotsBufferOffset = |
402 kLiveBytesOffset + kIntSize; // int live_byte_count_ | 403 kLiveBytesOffset + kIntSize; // int live_byte_count_ |
403 | 404 |
404 static const size_t kWriteBarrierCounterOffset = | 405 static const size_t kWriteBarrierCounterOffset = |
405 kSlotsBufferOffset + kPointerSize // SlotsBuffer* slots_buffer_; | 406 kSlotsBufferOffset + kPointerSize // SlotsBuffer* slots_buffer_; |
406 + kPointerSize; // SkipList* skip_list_; | 407 + kPointerSize; // SkipList* skip_list_; |
407 | 408 |
408 static const size_t kMinHeaderSize = | 409 static const size_t kMinHeaderSize = |
409 kWriteBarrierCounterOffset + | 410 kWriteBarrierCounterOffset + |
410 kIntptrSize // intptr_t write_barrier_counter_ | 411 kIntptrSize // intptr_t write_barrier_counter_ |
411 + kIntSize // int progress_bar_ | |
412 + kPointerSize // AtomicValue high_water_mark_ | 412 + kPointerSize // AtomicValue high_water_mark_ |
413 + kPointerSize // base::Mutex* mutex_ | 413 + kPointerSize // base::Mutex* mutex_ |
414 + kPointerSize // base::AtomicWord parallel_sweeping_ | 414 + kPointerSize // base::AtomicWord parallel_sweeping_ |
415 + kPointerSize // AtomicValue parallel_compaction_ | 415 + kPointerSize // AtomicValue parallel_compaction_ |
416 + 5 * kPointerSize // AtomicNumber free-list statistics | 416 + 5 * kPointerSize // AtomicNumber free-list statistics |
417 + kPointerSize // AtomicValue next_chunk_ | 417 + kPointerSize // AtomicValue next_chunk_ |
418 + kPointerSize; // AtomicValue prev_chunk_ | 418 + kPointerSize; // AtomicValue prev_chunk_ |
419 | 419 |
420 // We add some more space to the computed header size to amount for missing | 420 // We add some more space to the computed header size to amount for missing |
421 // alignment requirements in our computation. | 421 // alignment requirements in our computation. |
422 // Try to get kHeaderSize properly aligned on 32-bit and 64-bit machines. | 422 // Try to get kHeaderSize properly aligned on 32-bit and 64-bit machines. |
423 static const size_t kHeaderSize = kMinHeaderSize + kIntSize; | 423 static const size_t kHeaderSize = kMinHeaderSize; |
424 | 424 |
425 static const int kBodyOffset = | 425 static const int kBodyOffset = |
426 CODE_POINTER_ALIGN(kHeaderSize + Bitmap::kSize); | 426 CODE_POINTER_ALIGN(kHeaderSize + Bitmap::kSize); |
427 | 427 |
428 // The start offset of the object area in a page. Aligned to both maps and | 428 // The start offset of the object area in a page. Aligned to both maps and |
429 // code alignment to be suitable for both. Also aligned to 32 words because | 429 // code alignment to be suitable for both. Also aligned to 32 words because |
430 // the marking bitmap is arranged in 32 bit chunks. | 430 // the marking bitmap is arranged in 32 bit chunks. |
431 static const int kObjectStartAlignment = 32 * kPointerSize; | 431 static const int kObjectStartAlignment = 32 * kPointerSize; |
432 static const int kObjectStartOffset = | 432 static const int kObjectStartOffset = |
433 kBodyOffset - 1 + | 433 kBodyOffset - 1 + |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
512 bool scan_on_scavenge() { return IsFlagSet(SCAN_ON_SCAVENGE); } | 512 bool scan_on_scavenge() { return IsFlagSet(SCAN_ON_SCAVENGE); } |
513 void initialize_scan_on_scavenge(bool scan) { | 513 void initialize_scan_on_scavenge(bool scan) { |
514 if (scan) { | 514 if (scan) { |
515 SetFlag(SCAN_ON_SCAVENGE); | 515 SetFlag(SCAN_ON_SCAVENGE); |
516 } else { | 516 } else { |
517 ClearFlag(SCAN_ON_SCAVENGE); | 517 ClearFlag(SCAN_ON_SCAVENGE); |
518 } | 518 } |
519 } | 519 } |
520 inline void set_scan_on_scavenge(bool scan); | 520 inline void set_scan_on_scavenge(bool scan); |
521 | 521 |
522 int store_buffer_counter() { return store_buffer_counter_; } | |
523 void set_store_buffer_counter(int counter) { | |
524 store_buffer_counter_ = counter; | |
525 } | |
526 | |
527 bool Contains(Address addr) { | 522 bool Contains(Address addr) { |
528 return addr >= area_start() && addr < area_end(); | 523 return addr >= area_start() && addr < area_end(); |
529 } | 524 } |
530 | 525 |
531 // Checks whether addr can be a limit of addresses in this page. | 526 // Checks whether addr can be a limit of addresses in this page. |
532 // It's a limit if it's in the page, or if it's just after the | 527 // It's a limit if it's in the page, or if it's just after the |
533 // last byte of the page. | 528 // last byte of the page. |
534 bool ContainsLimit(Address addr) { | 529 bool ContainsLimit(Address addr) { |
535 return addr >= area_start() && addr <= area_end(); | 530 return addr >= area_start() && addr <= area_end(); |
536 } | 531 } |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
744 Address area_start_; | 739 Address area_start_; |
745 Address area_end_; | 740 Address area_end_; |
746 | 741 |
747 // If the chunk needs to remember its memory reservation, it is stored here. | 742 // If the chunk needs to remember its memory reservation, it is stored here. |
748 base::VirtualMemory reservation_; | 743 base::VirtualMemory reservation_; |
749 // The identity of the owning space. This is tagged as a failure pointer, but | 744 // The identity of the owning space. This is tagged as a failure pointer, but |
750 // no failure can be in an object, so this can be distinguished from any entry | 745 // no failure can be in an object, so this can be distinguished from any entry |
751 // in a fixed array. | 746 // in a fixed array. |
752 Address owner_; | 747 Address owner_; |
753 Heap* heap_; | 748 Heap* heap_; |
754 // Used by the store buffer to keep track of which pages to mark scan-on- | 749 // Used by the incremental marker to keep track of the scanning progress in |
755 // scavenge. | 750 // large objects that have a progress bar and are scanned in increments. |
756 int store_buffer_counter_; | 751 int progress_bar_; |
757 // Count of bytes marked black on page. | 752 // Count of bytes marked black on page. |
758 int live_byte_count_; | 753 int live_byte_count_; |
759 SlotsBuffer* slots_buffer_; | 754 SlotsBuffer* slots_buffer_; |
760 SkipList* skip_list_; | 755 SkipList* skip_list_; |
761 intptr_t write_barrier_counter_; | 756 intptr_t write_barrier_counter_; |
762 // Used by the incremental marker to keep track of the scanning progress in | |
763 // large objects that have a progress bar and are scanned in increments. | |
764 int progress_bar_; | |
765 // Assuming the initial allocation on a page is sequential, | 757 // Assuming the initial allocation on a page is sequential, |
766 // count highest number of bytes ever allocated on the page. | 758 // count highest number of bytes ever allocated on the page. |
767 AtomicValue<intptr_t> high_water_mark_; | 759 AtomicValue<intptr_t> high_water_mark_; |
768 | 760 |
769 base::Mutex* mutex_; | 761 base::Mutex* mutex_; |
770 AtomicValue<ParallelSweepingState> parallel_sweeping_; | 762 AtomicValue<ParallelSweepingState> parallel_sweeping_; |
771 AtomicValue<ParallelCompactingState> parallel_compaction_; | 763 AtomicValue<ParallelCompactingState> parallel_compaction_; |
772 | 764 |
773 // PagedSpace free-list statistics. | 765 // PagedSpace free-list statistics. |
774 AtomicNumber<intptr_t> available_in_small_free_list_; | 766 AtomicNumber<intptr_t> available_in_small_free_list_; |
(...skipping 2218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2993 protected: | 2985 protected: |
2994 // The space is temporary and not included in any snapshots. | 2986 // The space is temporary and not included in any snapshots. |
2995 bool snapshotable() override { return false; } | 2987 bool snapshotable() override { return false; } |
2996 | 2988 |
2997 MUST_USE_RESULT HeapObject* SweepAndRetryAllocation( | 2989 MUST_USE_RESULT HeapObject* SweepAndRetryAllocation( |
2998 int size_in_bytes) override; | 2990 int size_in_bytes) override; |
2999 }; | 2991 }; |
3000 | 2992 |
3001 | 2993 |
3002 // A collection of |CompactionSpace|s used by a single compaction task. | 2994 // A collection of |CompactionSpace|s used by a single compaction task. |
3003 class CompactionSpaceCollection : public Malloced { | 2995 class CompactionSpaceCollection : public Malloced { |
Michael Lippautz
2016/01/14 19:51:55
This class has become a bit of a mess (contains in
| |
3004 public: | 2996 public: |
3005 explicit CompactionSpaceCollection(Heap* heap) | 2997 explicit CompactionSpaceCollection(Heap* heap) |
3006 : old_space_(heap, OLD_SPACE, Executability::NOT_EXECUTABLE), | 2998 : old_space_(heap, OLD_SPACE, Executability::NOT_EXECUTABLE), |
3007 code_space_(heap, CODE_SPACE, Executability::EXECUTABLE), | 2999 code_space_(heap, CODE_SPACE, Executability::EXECUTABLE), |
3000 local_pretenuring_feedback_(HashMap::PointersMatch, | |
3001 kInitialLocalPretenuringFeedbackCapacity), | |
3008 duration_(0.0), | 3002 duration_(0.0), |
3009 bytes_compacted_(0) {} | 3003 bytes_compacted_(0) {} |
3010 | 3004 |
3011 CompactionSpace* Get(AllocationSpace space) { | 3005 CompactionSpace* Get(AllocationSpace space) { |
3012 switch (space) { | 3006 switch (space) { |
3013 case OLD_SPACE: | 3007 case OLD_SPACE: |
3014 return &old_space_; | 3008 return &old_space_; |
3015 case CODE_SPACE: | 3009 case CODE_SPACE: |
3016 return &code_space_; | 3010 return &code_space_; |
3017 default: | 3011 default: |
3018 UNREACHABLE(); | 3012 UNREACHABLE(); |
3019 } | 3013 } |
3020 UNREACHABLE(); | 3014 UNREACHABLE(); |
3021 return nullptr; | 3015 return nullptr; |
3022 } | 3016 } |
3023 | 3017 |
3024 void ReportCompactionProgress(double duration, intptr_t bytes_compacted) { | 3018 void ReportCompactionProgress(double duration, intptr_t bytes_compacted) { |
3025 duration_ += duration; | 3019 duration_ += duration; |
3026 bytes_compacted_ += bytes_compacted; | 3020 bytes_compacted_ += bytes_compacted; |
3027 } | 3021 } |
3028 | 3022 |
3029 double duration() const { return duration_; } | 3023 double duration() const { return duration_; } |
3030 intptr_t bytes_compacted() const { return bytes_compacted_; } | 3024 intptr_t bytes_compacted() const { return bytes_compacted_; } |
3025 HashMap* local_pretenuring_feedback() { return &local_pretenuring_feedback_; } | |
3026 LocalStoreBuffer* local_store_buffer() { return &local_store_buffer_; } | |
3031 | 3027 |
3032 private: | 3028 private: |
3029 static const int kInitialLocalPretenuringFeedbackCapacity = 256; | |
Michael Lippautz
2016/01/14 19:51:55
= the length of the previously used global scratch
| |
3030 | |
3033 CompactionSpace old_space_; | 3031 CompactionSpace old_space_; |
3034 CompactionSpace code_space_; | 3032 CompactionSpace code_space_; |
3033 HashMap local_pretenuring_feedback_; | |
3034 LocalStoreBuffer local_store_buffer_; | |
3035 | 3035 |
3036 // Book keeping. | 3036 // Book keeping. |
3037 double duration_; | 3037 double duration_; |
3038 intptr_t bytes_compacted_; | 3038 intptr_t bytes_compacted_; |
3039 }; | 3039 }; |
3040 | 3040 |
3041 | 3041 |
3042 // ----------------------------------------------------------------------------- | 3042 // ----------------------------------------------------------------------------- |
3043 // Old object space (includes the old space of objects and code space) | 3043 // Old object space (includes the old space of objects and code space) |
3044 | 3044 |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3229 count = 0; | 3229 count = 0; |
3230 } | 3230 } |
3231 // Must be small, since an iteration is used for lookup. | 3231 // Must be small, since an iteration is used for lookup. |
3232 static const int kMaxComments = 64; | 3232 static const int kMaxComments = 64; |
3233 }; | 3233 }; |
3234 #endif | 3234 #endif |
3235 } // namespace internal | 3235 } // namespace internal |
3236 } // namespace v8 | 3236 } // namespace v8 |
3237 | 3237 |
3238 #endif // V8_HEAP_SPACES_H_ | 3238 #endif // V8_HEAP_SPACES_H_ |
OLD | NEW |