Skip to content
Snippets Groups Projects
Commit 6a6e0b7e authored by Paul Sokolovsky's avatar Paul Sokolovsky
Browse files

py/gc: Be sure to count last allocated block at heap end in stats.

Previously, if there was chain of allocated blocks ending with the last
block of heap, it wasn't included in number of 1/2-block or max block
size stats.
parent 69074960
No related branches found
No related tags found
No related merge requests found
......@@ -327,18 +327,9 @@ void gc_info(gc_info_t *info) {
info->num_1block = 0;
info->num_2block = 0;
info->max_block = 0;
for (size_t block = 0, len = 0; block < MP_STATE_MEM(gc_alloc_table_byte_len) * BLOCKS_PER_ATB; block++) {
bool finish = false;
for (size_t block = 0, len = 0; !finish;) {
size_t kind = ATB_GET_KIND(block);
if (kind == AT_FREE || kind == AT_HEAD) {
if (len == 1) {
info->num_1block += 1;
} else if (len == 2) {
info->num_2block += 1;
}
if (len > info->max_block) {
info->max_block = len;
}
}
switch (kind) {
case AT_FREE:
info->free += 1;
......@@ -359,6 +350,24 @@ void gc_info(gc_info_t *info) {
// shouldn't happen
break;
}
block++;
finish = (block == MP_STATE_MEM(gc_alloc_table_byte_len) * BLOCKS_PER_ATB);
// Get next block type if possible
if (!finish) {
kind = ATB_GET_KIND(block);
}
if (finish || kind == AT_FREE || kind == AT_HEAD) {
if (len == 1) {
info->num_1block += 1;
} else if (len == 2) {
info->num_2block += 1;
}
if (len > info->max_block) {
info->max_block = len;
}
}
}
info->used *= BYTES_PER_BLOCK;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment