93 // | | | |
94 // +--------------+ <- bottom --+ --+
95
96 // ChunkIndex defines the type of chunk.
97 // Chunk types differ by size: specialized < small < medium, chunks
98 // larger than medium are humongous chunks of varying size.
99 enum ChunkIndex {
100 ZeroIndex = 0,
101 SpecializedIndex = ZeroIndex,
102 SmallIndex = SpecializedIndex + 1,
103 MediumIndex = SmallIndex + 1,
104 HumongousIndex = MediumIndex + 1,
105 NumberOfFreeLists = 3,
106 NumberOfInUseLists = 4
107 };
108
109 // Utility functions.
110 size_t get_size_for_nonhumongous_chunktype(ChunkIndex chunk_type, bool is_class);
111 ChunkIndex get_chunk_type_by_size(size_t size, bool is_class);
112
113 // Returns a descriptive name for a chunk type.
114 const char* chunk_size_name(ChunkIndex index);
115
116 // Verify chunk type.
117 inline bool is_valid_chunktype(ChunkIndex index) {
118 return index == SpecializedIndex || index == SmallIndex ||
119 index == MediumIndex || index == HumongousIndex;
120 }
121
122 inline bool is_valid_nonhumongous_chunktype(ChunkIndex index) {
123 return is_valid_chunktype(index) && index != HumongousIndex;
124 }
125
126 enum ChunkOrigin {
127 // Chunk normally born (via take_from_committed)
128 origin_normal = 1,
129 // Chunk was born as padding chunk
130 origin_pad = 2,
131 // Chunk was born as leftover chunk in VirtualSpaceNode::retire
132 origin_leftover = 3,
167 const bool _is_class;
168 // Whether the chunk is free (in freelist) or in use by some class loader.
169 bool _is_tagged_free;
170
171 ChunkOrigin _origin;
172 int _use_count;
173
174 MetaWord* initial_top() const { return (MetaWord*)this + overhead(); }
175 MetaWord* top() const { return _top; }
176
177 public:
178 // Metachunks are allocated out of a MetadataVirtualSpace and
179 // and use some of its space to describe itself (plus alignment
180 // considerations). Metadata is allocated in the rest of the chunk.
181 // This size is the overhead of maintaining the Metachunk within
182 // the space.
183
184 // Alignment of each allocation in the chunks.
185 static size_t object_alignment();
186
187 // Size of the Metachunk header, including alignment.
188 static size_t overhead();
189
190 Metachunk(ChunkIndex chunktype, bool is_class, size_t word_size, VirtualSpaceNode* container);
191
192 MetaWord* allocate(size_t word_size);
193
194 VirtualSpaceNode* container() const { return _container; }
195
196 MetaWord* bottom() const { return (MetaWord*) this; }
197
198 // Reset top to bottom so chunk can be reused.
199 void reset_empty() { _top = initial_top(); clear_next(); clear_prev(); }
200 bool is_empty() { return _top == initial_top(); }
201
202 // used (has been allocated)
203 // free (available for future allocations)
204 size_t word_size() const { return size(); }
205 size_t used_word_size() const;
206 size_t free_word_size() const;
207
|
93 // | | | |
94 // +--------------+ <- bottom --+ --+
95
96 // ChunkIndex defines the type of chunk.
97 // Chunk types differ by size: specialized < small < medium, chunks
98 // larger than medium are humongous chunks of varying size.
99 enum ChunkIndex {
100 ZeroIndex = 0,
101 SpecializedIndex = ZeroIndex,
102 SmallIndex = SpecializedIndex + 1,
103 MediumIndex = SmallIndex + 1,
104 HumongousIndex = MediumIndex + 1,
105 NumberOfFreeLists = 3,
106 NumberOfInUseLists = 4
107 };
108
109 // Utility functions.
110 size_t get_size_for_nonhumongous_chunktype(ChunkIndex chunk_type, bool is_class);
111 ChunkIndex get_chunk_type_by_size(size_t size, bool is_class);
112
113 ChunkIndex next_chunk_index(ChunkIndex i);
114 ChunkIndex prev_chunk_index(ChunkIndex i);
115
116 // Returns a descriptive name for a chunk type.
117 const char* chunk_size_name(ChunkIndex index);
118
119 // Verify chunk type.
120 inline bool is_valid_chunktype(ChunkIndex index) {
121 return index == SpecializedIndex || index == SmallIndex ||
122 index == MediumIndex || index == HumongousIndex;
123 }
124
125 inline bool is_valid_nonhumongous_chunktype(ChunkIndex index) {
126 return is_valid_chunktype(index) && index != HumongousIndex;
127 }
128
129 enum ChunkOrigin {
130 // Chunk normally born (via take_from_committed)
131 origin_normal = 1,
132 // Chunk was born as padding chunk
133 origin_pad = 2,
134 // Chunk was born as leftover chunk in VirtualSpaceNode::retire
135 origin_leftover = 3,
170 const bool _is_class;
171 // Whether the chunk is free (in freelist) or in use by some class loader.
172 bool _is_tagged_free;
173
174 ChunkOrigin _origin;
175 int _use_count;
176
177 MetaWord* initial_top() const { return (MetaWord*)this + overhead(); }
178 MetaWord* top() const { return _top; }
179
180 public:
181 // Metachunks are allocated out of a MetadataVirtualSpace and
182 // and use some of its space to describe itself (plus alignment
183 // considerations). Metadata is allocated in the rest of the chunk.
184 // This size is the overhead of maintaining the Metachunk within
185 // the space.
186
187 // Alignment of each allocation in the chunks.
188 static size_t object_alignment();
189
190 // Size of the Metachunk header, in words, including alignment.
191 static size_t overhead();
192
193 Metachunk(ChunkIndex chunktype, bool is_class, size_t word_size, VirtualSpaceNode* container);
194
195 MetaWord* allocate(size_t word_size);
196
197 VirtualSpaceNode* container() const { return _container; }
198
199 MetaWord* bottom() const { return (MetaWord*) this; }
200
201 // Reset top to bottom so chunk can be reused.
202 void reset_empty() { _top = initial_top(); clear_next(); clear_prev(); }
203 bool is_empty() { return _top == initial_top(); }
204
205 // used (has been allocated)
206 // free (available for future allocations)
207 size_t word_size() const { return size(); }
208 size_t used_word_size() const;
209 size_t free_word_size() const;
210
|