Add RARRAY_LITERAL_FLAG for array literals
commit5871ecf956711fcacad7c03f2aef95115ed25bc4
authorPeter Zhu <[email protected]>
Tue, 19 Jul 2022 15:15:05 +0000 (19 11:15 -0400)
committerPeter Zhu <[email protected]>
Wed, 20 Jul 2022 17:13:56 +0000 (20 13:13 -0400)
treeef8db409dd1acd1d2184279d8a8d3893f6b965f6
parentb25ee69e3873162689c46bc3ffdd1686151184b2
Add RARRAY_LITERAL_FLAG for array literals

Array created as literals during iseq compilation don't need a
reference count since they can never be modified. The previous
implementation would mutate the hidden array's reference count,
causing copy-on-write invalidation.

This commit adds a RARRAY_LITERAL_FLAG for arrays created through
rb_ary_literal_new. Arrays created with this flag do not have reference
count stored and just assume they have infinite number of references.

Co-authored-by: Jean Boussier <[email protected]>
array.c
compile.c
internal/array.h