From 5871ecf956711fcacad7c03f2aef95115ed25bc4 Mon Sep 17 00:00:00 2001 From: Peter Zhu Date: Tue, 19 Jul 2022 11:15:05 -0400 Subject: 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 --- internal/array.h | 1 + 1 file changed, 1 insertion(+) (limited to 'internal/array.h') diff --git a/internal/array.h b/internal/array.h index 690196a1e2..aa3b540153 100644 --- a/internal/array.h +++ b/internal/array.h @@ -33,6 +33,7 @@ void rb_ary_cancel_sharing(VALUE ary); size_t rb_ary_size_as_embedded(VALUE ary); void rb_ary_make_embedded(VALUE ary); bool rb_ary_embeddable_p(VALUE ary); +VALUE rb_ary_literal_new(long capa); static inline VALUE rb_ary_entry_internal(VALUE ary, long offset); static inline bool ARY_PTR_USING_P(VALUE ary); -- cgit v1.2.3