20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #ifndef SHARE_VM_GC_G1_YOUNGLIST_HPP
26 #define SHARE_VM_GC_G1_YOUNGLIST_HPP
27
28 #include "memory/allocation.hpp"
29 #include "runtime/globals.hpp"
30
31 class YoungList : public CHeapObj<mtGC> {
32 private:
33 G1CollectedHeap* _g1h;
34
35 HeapRegion* _head;
36
37 HeapRegion* _survivor_head;
38 HeapRegion* _survivor_tail;
39
40 HeapRegion* _curr;
41
42 uint _length;
43 uint _survivor_length;
44
45 size_t _last_sampled_rs_lengths;
46 size_t _sampled_rs_lengths;
47
48 void empty_list(HeapRegion* list);
49
50 public:
51 YoungList(G1CollectedHeap* g1h);
52
53 void push_region(HeapRegion* hr);
54 void add_survivor_region(HeapRegion* hr);
55
56 void empty_list();
57 bool is_empty() { return _length == 0; }
58 uint length() { return _length; }
59 uint eden_length() { return length() - survivor_length(); }
60 uint survivor_length() { return _survivor_length; }
61
62 // Currently we do not keep track of the used byte sum for the
63 // young list and the survivors and it'd be quite a lot of work to
64 // do so. When we'll eventually replace the young list with
65 // instances of HeapRegionLinkedList we'll get that for free. So,
66 // we'll report the more accurate information then.
67 size_t eden_used_bytes() {
68 assert(length() >= survivor_length(), "invariant");
69 return (size_t) eden_length() * HeapRegion::GrainBytes;
70 }
71 size_t survivor_used_bytes() {
72 return (size_t) survivor_length() * HeapRegion::GrainBytes;
73 }
74
75 void rs_length_sampling_init();
76 bool rs_length_sampling_more();
77 void rs_length_sampling_next();
78
79 void reset_sampled_info() {
80 _last_sampled_rs_lengths = 0;
81 }
82 size_t sampled_rs_lengths() { return _last_sampled_rs_lengths; }
83
84 // for development purposes
85 void reset_auxilary_lists();
86 void clear() { _head = NULL; _length = 0; }
87
88 void clear_survivors() {
89 _survivor_head = NULL;
90 _survivor_tail = NULL;
91 _survivor_length = 0;
92 }
93
94 HeapRegion* first_region() { return _head; }
95 HeapRegion* first_survivor_region() { return _survivor_head; }
96 HeapRegion* last_survivor_region() { return _survivor_tail; }
97
98 // debugging
99 bool check_list_well_formed();
100 bool check_list_empty(bool check_sample = true);
101 void print();
102 };
103
104 #endif // SHARE_VM_GC_G1_YOUNGLIST_HPP
|
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #ifndef SHARE_VM_GC_G1_YOUNGLIST_HPP
26 #define SHARE_VM_GC_G1_YOUNGLIST_HPP
27
28 #include "memory/allocation.hpp"
29 #include "runtime/globals.hpp"
30
31 class YoungList : public CHeapObj<mtGC> {
32 private:
33 G1CollectedHeap* _g1h;
34
35 HeapRegion* _head;
36
37 HeapRegion* _survivor_head;
38 HeapRegion* _survivor_tail;
39
40 uint _length;
41 uint _survivor_length;
42
43 void empty_list(HeapRegion* list);
44
45 public:
46 YoungList(G1CollectedHeap* g1h);
47
48 void push_region(HeapRegion* hr);
49 void add_survivor_region(HeapRegion* hr);
50
51 void empty_list();
52 bool is_empty() { return _length == 0; }
53 uint length() { return _length; }
54 uint eden_length() { return length() - survivor_length(); }
55 uint survivor_length() { return _survivor_length; }
56
57 // Currently we do not keep track of the used byte sum for the
58 // young list and the survivors and it'd be quite a lot of work to
59 // do so. When we'll eventually replace the young list with
60 // instances of HeapRegionLinkedList we'll get that for free. So,
61 // we'll report the more accurate information then.
62 size_t eden_used_bytes() {
63 assert(length() >= survivor_length(), "invariant");
64 return (size_t) eden_length() * HeapRegion::GrainBytes;
65 }
66 size_t survivor_used_bytes() {
67 return (size_t) survivor_length() * HeapRegion::GrainBytes;
68 }
69
70 // for development purposes
71 void reset_auxilary_lists();
72 void clear() { _head = NULL; _length = 0; }
73
74 void clear_survivors() {
75 _survivor_head = NULL;
76 _survivor_tail = NULL;
77 _survivor_length = 0;
78 }
79
80 HeapRegion* first_region() { return _head; }
81 HeapRegion* first_survivor_region() { return _survivor_head; }
82 HeapRegion* last_survivor_region() { return _survivor_tail; }
83
84 // debugging
85 bool check_list_well_formed();
86 bool check_list_empty();
87 void print();
88 };
89
90 #endif // SHARE_VM_GC_G1_YOUNGLIST_HPP
|