Add GC.auto_compact= true/false and GC.auto_compact

* `GC.auto_compact=`, `GC.auto_compact` can be used to control when
  compaction runs.  Setting `auto_compact=` to true will cause
  compaction to occurr duing major collections.  At the moment,
  compaction adds significant overhead to major collections, so please
  test first!

[Feature #17176]
This commit is contained in:
Aaron Patterson 2020-11-02 14:40:29 -08:00
parent 79b242260b
commit 67b2c21c32
No known key found for this signature in database
GPG key ID: 953170BCB4FFAFC6
9 changed files with 810 additions and 376 deletions

View file

@ -864,26 +864,17 @@ blocks_clear_marked_index(struct transient_heap_block* block)
static void
transient_heap_block_update_refs(struct transient_heap* theap, struct transient_heap_block* block)
{
int i=0, n=0;
int marked_index = block->info.last_marked_index;
while (i<block->info.index) {
void *ptr = &block->buff[i];
struct transient_alloc_header *header = ptr;
while (marked_index >= 0) {
struct transient_alloc_header *header = alloc_header(block, marked_index);
asan_unpoison_memory_region(header, sizeof *header, false);
void *poisoned = __asan_region_is_poisoned((void *)header->obj, SIZEOF_VALUE);
asan_unpoison_object(header->obj, false);
header->obj = rb_gc_location(header->obj);
if (poisoned) {
asan_poison_object(header->obj);
}
i += header->size;
marked_index = header->next_marked_index;
asan_poison_memory_region(header, sizeof *header);
n++;
}
}