diff options
author | Aaron Patterson <tenderlove@ruby-lang.org> | 2022-06-23 16:02:42 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2022-06-23 16:52:00 -0700 |
commit | 0b58059f15d8ec7bd9dbe1638a77b4a531b0df25 (patch) | |
tree | 2c1677460b6aa416c70f391ac6fff5e531ce9852 /iseq.c | |
parent | 8d63a0470392f3b5810941bdf36f23d2122df16a (diff) |
Free bitmap buffer if it's not used
If the iseqs don't have any objects in them that need marking, then
immediately free the bitmap buffer
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/6058
Diffstat (limited to 'iseq.c')
-rw-r--r-- | iseq.c | 10 |
1 files changed, 6 insertions, 4 deletions
@@ -193,7 +193,7 @@ rb_iseq_free(const rb_iseq_t *iseq) } ruby_xfree((void *)body->catch_table); ruby_xfree((void *)body->param.opt_table); - if (ISEQ_MBITS_BUFLEN(body->iseq_size) > 1) { + if (ISEQ_MBITS_BUFLEN(body->iseq_size) > 1 && body->mark_bits.list) { ruby_xfree((void *)body->mark_bits.list); } @@ -388,9 +388,11 @@ rb_iseq_each_value(const rb_iseq_t *iseq, iseq_value_itr_t * func, void *data) iseq_scan_bits(0, body->mark_bits.single, code, func, data); } else { - for (unsigned int i = 0; i < ISEQ_MBITS_BUFLEN(size); i++) { - iseq_bits_t bits = body->mark_bits.list[i]; - iseq_scan_bits(i, bits, code, func, data); + if (body->mark_bits.list) { + for (unsigned int i = 0; i < ISEQ_MBITS_BUFLEN(size); i++) { + iseq_bits_t bits = body->mark_bits.list[i]; + iseq_scan_bits(i, bits, code, func, data); + } } } } |