57 //
58 // 01000 0 [16] Old Mask
59 //
60 // 10000 0 [32] Archive Mask
61 // 11100 0 [56] Open Archive
62 // 11100 1 [57] Closed Archive
63 //
64 typedef enum {
65 FreeTag = 0,
66
67 YoungMask = 2,
68 EdenTag = YoungMask,
69 SurvTag = YoungMask + 1,
70
71 HumongousMask = 4,
72 PinnedMask = 8,
73 StartsHumongousTag = HumongousMask | PinnedMask,
74 ContinuesHumongousTag = HumongousMask | PinnedMask + 1,
75
76 OldMask = 16,
77 OldTag = OldMask,
78
79 // Archive regions are regions with immutable content (i.e. not reclaimed, and
80 // not allocated into during regular operation). They differ in the kind of references
81 // allowed for the contained objects:
82 // - Closed archive regions form a separate self-contained (closed) object graph
83 // within the set of all of these regions. No references outside of closed
84 // archive regions are allowed.
85 // - Open archive regions have no restrictions on the references of their objects.
86 // Objects within these regions are allowed to have references to objects
87 // contained in any other kind of regions.
88 ArchiveMask = 32,
89 OpenArchiveTag = ArchiveMask | PinnedMask,
90 ClosedArchiveTag = ArchiveMask | PinnedMask + 1
91 } Tag;
92
93 volatile Tag _tag;
94
95 static bool is_valid(Tag tag);
96
97 Tag get() const {
98 hrt_assert_is_valid(_tag);
120 public:
121 // Queries
122
123 bool is_free() const { return get() == FreeTag; }
124
125 bool is_young() const { return (get() & YoungMask) != 0; }
126 bool is_eden() const { return get() == EdenTag; }
127 bool is_survivor() const { return get() == SurvTag; }
128
129 bool is_humongous() const { return (get() & HumongousMask) != 0; }
130 bool is_starts_humongous() const { return get() == StartsHumongousTag; }
131 bool is_continues_humongous() const { return get() == ContinuesHumongousTag; }
132
133 bool is_archive() const { return (get() & ArchiveMask) != 0; }
134 bool is_open_archive() const { return get() == OpenArchiveTag; }
135 bool is_closed_archive() const { return get() == ClosedArchiveTag; }
136
137 // is_old regions may or may not also be pinned
138 bool is_old() const { return (get() & OldMask) != 0; }
139
140 bool is_old_or_humongous() const { return (get() & (OldMask | HumongousMask)) != 0; }
141
142 bool is_old_or_humongous_or_archive() const { return (get() & (OldMask | HumongousMask | ArchiveMask)) != 0; }
143
144 // is_pinned regions may be archive or humongous
145 bool is_pinned() const { return (get() & PinnedMask) != 0; }
146
147 // Setters
148
149 void set_free() { set(FreeTag); }
150
151 void set_eden() { set_from(EdenTag, FreeTag); }
152 void set_eden_pre_gc() { set_from(EdenTag, SurvTag); }
153 void set_survivor() { set_from(SurvTag, FreeTag); }
154
155 void set_starts_humongous() { set_from(StartsHumongousTag, FreeTag); }
156 void set_continues_humongous() { set_from(ContinuesHumongousTag, FreeTag); }
157
158 void set_old() { set(OldTag); }
159
160 // Change the current region type to be of an old region type if not already done so.
161 // Returns whether the region type has been changed or not.
162 bool relabel_as_old() {
163 //assert(!is_free(), "Should not try to move Free region");
164 assert(!is_humongous(), "Should not try to move Humongous region");
165 if (is_old()) {
166 return false;
167 }
168 if (is_eden()) {
169 set_from(OldTag, EdenTag);
170 return true;
171 } else if (is_free()) {
172 set_from(OldTag, FreeTag);
173 return true;
174 } else {
175 set_from(OldTag, SurvTag);
176 return true;
177 }
178 }
|
57 //
58 // 01000 0 [16] Old Mask
59 //
60 // 10000 0 [32] Archive Mask
61 // 11100 0 [56] Open Archive
62 // 11100 1 [57] Closed Archive
63 //
64 typedef enum {
65 FreeTag = 0,
66
67 YoungMask = 2,
68 EdenTag = YoungMask,
69 SurvTag = YoungMask + 1,
70
71 HumongousMask = 4,
72 PinnedMask = 8,
73 StartsHumongousTag = HumongousMask | PinnedMask,
74 ContinuesHumongousTag = HumongousMask | PinnedMask + 1,
75
76 OldMask = 16,
77 PreMatureOldMask = OldMask + 1,
78 OldTag = OldMask,
79 PreMatureOldTag = PreMatureOldMask,
80 // Archive regions are regions with immutable content (i.e. not reclaimed, and
81 // not allocated into during regular operation). They differ in the kind of references
82 // allowed for the contained objects:
83 // - Closed archive regions form a separate self-contained (closed) object graph
84 // within the set of all of these regions. No references outside of closed
85 // archive regions are allowed.
86 // - Open archive regions have no restrictions on the references of their objects.
87 // Objects within these regions are allowed to have references to objects
88 // contained in any other kind of regions.
89 ArchiveMask = 32,
90 OpenArchiveTag = ArchiveMask | PinnedMask,
91 ClosedArchiveTag = ArchiveMask | PinnedMask + 1
92 } Tag;
93
94 volatile Tag _tag;
95
96 static bool is_valid(Tag tag);
97
98 Tag get() const {
99 hrt_assert_is_valid(_tag);
121 public:
122 // Queries
123
124 bool is_free() const { return get() == FreeTag; }
125
126 bool is_young() const { return (get() & YoungMask) != 0; }
127 bool is_eden() const { return get() == EdenTag; }
128 bool is_survivor() const { return get() == SurvTag; }
129
130 bool is_humongous() const { return (get() & HumongousMask) != 0; }
131 bool is_starts_humongous() const { return get() == StartsHumongousTag; }
132 bool is_continues_humongous() const { return get() == ContinuesHumongousTag; }
133
134 bool is_archive() const { return (get() & ArchiveMask) != 0; }
135 bool is_open_archive() const { return get() == OpenArchiveTag; }
136 bool is_closed_archive() const { return get() == ClosedArchiveTag; }
137
138 // is_old regions may or may not also be pinned
139 bool is_old() const { return (get() & OldMask) != 0; }
140
141 bool is_premature_old() const { return get() == PreMatureOldTag; }
142
143 bool is_old_or_humongous() const { return (get() & (OldMask | HumongousMask)) != 0; }
144
145 bool is_old_or_humongous_or_archive() const { return (get() & (OldMask | HumongousMask | ArchiveMask)) != 0; }
146
147 // is_pinned regions may be archive or humongous
148 bool is_pinned() const { return (get() & PinnedMask) != 0; }
149
150 // Setters
151
152 void set_free() { set(FreeTag); }
153
154 void set_eden() { set_from(EdenTag, FreeTag); }
155 void set_eden_pre_gc() { set_from(EdenTag, SurvTag); }
156 void set_survivor() { set_from(SurvTag, FreeTag); }
157
158 void set_starts_humongous() { set_from(StartsHumongousTag, FreeTag); }
159 void set_continues_humongous() { set_from(ContinuesHumongousTag, FreeTag); }
160
161 void set_old() { set(OldTag); }
162
163 void set_premature_old() { set(PreMatureOldTag); }
164
165 // Change the current region type to be of an old region type if not already done so.
166 // Returns whether the region type has been changed or not.
167 bool relabel_as_old() {
168 //assert(!is_free(), "Should not try to move Free region");
169 assert(!is_humongous(), "Should not try to move Humongous region");
170 if (is_old()) {
171 return false;
172 }
173 if (is_eden()) {
174 set_from(OldTag, EdenTag);
175 return true;
176 } else if (is_free()) {
177 set_from(OldTag, FreeTag);
178 return true;
179 } else {
180 set_from(OldTag, SurvTag);
181 return true;
182 }
183 }
|