diff options
author | Peter Zhu <[email protected]> | 2022-07-11 10:09:39 -0400 |
---|---|---|
committer | Peter Zhu <[email protected]> | 2022-07-15 09:21:07 -0400 |
commit | 7424ea184f9d67c1c7f3ee97494ed3bd1aa60833 (patch) | |
tree | 822838e39d81cd2785c970cb45a86854823af6fe /object.c | |
parent | 7fda741f6e67b809b08423f0d4e903c078da2eed (diff) |
Implement Objects on VWA
This commit implements Objects on Variable Width Allocation. This allows
Objects with more ivars to be embedded (i.e. contents directly follow the
object header) which improves performance through better cache locality.
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/6117
Diffstat (limited to 'object.c')
-rw-r--r-- | object.c | 33 |
1 files changed, 6 insertions, 27 deletions
@@ -267,34 +267,13 @@ rb_obj_singleton_class(VALUE obj) MJIT_FUNC_EXPORTED void rb_obj_copy_ivar(VALUE dest, VALUE obj) { - VALUE *dst_buf = 0; - VALUE *src_buf = 0; - uint32_t len = ROBJECT_EMBED_LEN_MAX; + VALUE *dest_buf = ROBJECT_IVPTR(dest); + VALUE *src_buf = ROBJECT_IVPTR(obj); + uint32_t dest_len = ROBJECT_NUMIV(dest); + uint32_t src_len = ROBJECT_NUMIV(obj); + uint32_t len = dest_len < src_len ? dest_len : src_len; - if (RBASIC(obj)->flags & ROBJECT_EMBED) { - src_buf = ROBJECT(obj)->as.ary; - - // embedded -> embedded - if (RBASIC(dest)->flags & ROBJECT_EMBED) { - dst_buf = ROBJECT(dest)->as.ary; - } - // embedded -> extended - else { - dst_buf = ROBJECT(dest)->as.heap.ivptr; - } - } - // extended -> extended - else { - RUBY_ASSERT(!(RBASIC(dest)->flags & ROBJECT_EMBED)); - uint32_t src_len = ROBJECT(obj)->as.heap.numiv; - uint32_t dst_len = ROBJECT(dest)->as.heap.numiv; - - len = src_len < dst_len ? src_len : dst_len; - dst_buf = ROBJECT(dest)->as.heap.ivptr; - src_buf = ROBJECT(obj)->as.heap.ivptr; - } - - MEMCPY(dst_buf, src_buf, VALUE, len); + MEMCPY(dest_buf, src_buf, VALUE, len); } static void |