diff options
author | Jemma Issroff <[email protected]> | 2022-11-08 14:09:43 -0500 |
---|---|---|
committer | Peter Zhu <[email protected]> | 2022-11-10 10:11:34 -0500 |
commit | c726c48a3dacd9ca1cb0d96fee98890cb74b37d3 () | |
tree | f2bbd9f9797ee63e8666fffd18c47e04571b7a6f /variable.c | |
parent | 5246f4027ec574e77809845e1b1f7822cc2a5cef (diff) |
Remove numiv from RObject
Since object shapes store the capacity of an object, we no longer need the numiv field on RObjects. This gives us one extra slot which we can use to give embedded objects one more instance variable (for a total of 3 ivs). This commit removes the concept of numiv from RObject.
Notes: Merged: https://.com/ruby/ruby/pull/6699
-rw-r--r-- | variable.c | 20 |
1 files changed, 5 insertions, 15 deletions
@@ -1346,7 +1346,7 @@ rb_obj_transient_heap_evacuate(VALUE obj, int promote) if (ROBJ_TRANSIENT_P(obj)) { assert(!RB_FL_TEST_RAW(obj, ROBJECT_EMBED)); - uint32_t len = ROBJECT_NUMIV(obj); const VALUE *old_ptr = ROBJECT_IVPTR(obj); VALUE *new_ptr; @@ -1378,7 +1378,6 @@ rb_ensure_iv_list_size(VALUE obj, uint32_t current_capacity, uint32_t new_capaci else { newptr = obj_ivar_heap_realloc(obj, current_capacity, new_capacity); } - ROBJECT_SET_NUMIV(obj, new_capacity); } struct gen_ivtbl * @@ -1405,21 +1404,14 @@ rb_ensure_generic_iv_list_size(VALUE obj, uint32_t newsize) rb_shape_t * rb_grow_iv_list(VALUE obj) { - uint32_t len = ROBJECT_NUMIV(obj); RUBY_ASSERT(len > 0); uint32_t newsize = (uint32_t)(len * 2); rb_ensure_iv_list_size(obj, len, newsize); - rb_shape_t * res; -#if USE_RVARGC - ROBJECT_SET_NUMIV(obj, newsize); -#else - ROBJECT(obj)->as.heap.numiv = newsize; -#endif - - res = rb_shape_transition_shape_capa(rb_shape_get_shape(obj), newsize); rb_shape_set_shape(obj, res); - RUBY_ASSERT(!RB_TYPE_P(obj, T_OBJECT) || ROBJECT_IV_CAPACITY(obj) == ROBJECT_NUMIV(obj)); return res; } @@ -1437,12 +1429,10 @@ obj_ivar_set(VALUE obj, ID id, VALUE val) found = false; } - uint32_t len = ROBJECT_NUMIV(obj); - // Reallocating can kick off GC. We can't set the new shape // on this object until the buffer has been allocated, otherwise // GC could read off the end of the buffer. - if (len <= index) { shape = rb_grow_iv_list(obj); } |