1#ifndef INTERNAL_ARRAY_H
2#define INTERNAL_ARRAY_H
11#include "ruby/internal/config.h"
13#include "internal/static_assert.h"
18# define ARRAY_DEBUG (0+RUBY_DEBUG)
21#define RARRAY_SHARED_FLAG ELTS_SHARED
22#define RARRAY_SHARED_ROOT_FLAG FL_USER12
23#define RARRAY_PTR_IN_USE_FLAG FL_USER14
27void rb_ary_set_len(
VALUE,
long);
29VALUE rb_ary_hidden_new_fill(
long capa);
31size_t rb_ary_memsize(
VALUE);
34void rb_ary_cancel_sharing(
VALUE ary);
35size_t rb_ary_size_as_embedded(
VALUE ary);
36void rb_ary_make_embedded(
VALUE ary);
37bool rb_ary_embeddable_p(
VALUE ary);
40static inline VALUE rb_ary_entry_internal(
VALUE ary,
long offset);
41static inline bool ARY_PTR_USING_P(
VALUE ary);
42static inline void RARY_TRANSIENT_SET(
VALUE ary);
43static inline void RARY_TRANSIENT_UNSET(
VALUE ary);
45MJIT_SYMBOL_EXPORT_BEGIN
57rb_ary_entry_internal(
VALUE ary,
long offset)
61 if (len == 0)
return Qnil;
64 if (offset < 0)
return Qnil;
66 else if (len <= offset) {
73ARY_PTR_USING_P(
VALUE ary)
80ary_should_not_be_shared_and_embedded(
VALUE ary)
82 return !
FL_ALL_RAW(ary, RARRAY_SHARED_FLAG|RARRAY_EMBED_FLAG);
86ARY_SHARED_P(
VALUE ary)
89 assert(ary_should_not_be_shared_and_embedded(ary));
97 assert(ary_should_not_be_shared_and_embedded(ary));
102ARY_SHARED_ROOT(
VALUE ary)
104 assert(ARY_SHARED_P(ary));
105 return RARRAY(ary)->as.heap.aux.shared_root;
109ARY_SHARED_ROOT_P(
VALUE ary)
116ARY_SHARED_ROOT_REFCNT(
VALUE ary)
118 assert(ARY_SHARED_ROOT_P(ary));
119 return RARRAY(ary)->as.heap.aux.capa;
123RARY_TRANSIENT_SET(
VALUE ary)
125#if USE_TRANSIENT_HEAP
131RARY_TRANSIENT_UNSET(
VALUE ary)
133#if USE_TRANSIENT_HEAP
138#undef rb_ary_new_from_args
139#if RBIMPL_HAS_WARNING("-Wgnu-zero-variadic-macro-arguments")
141#elif defined(__GNUC__) && defined(HAVE_VA_ARGS_MACRO)
142#define rb_ary_new_from_args(n, ...) \
144 const VALUE args_to_new_ary[] = {__VA_ARGS__}; \
145 if (__builtin_constant_p(n)) { \
146 STATIC_ASSERT(rb_ary_new_from_args, numberof(args_to_new_ary) == (n)); \
148 rb_ary_new_from_values(numberof(args_to_new_ary), args_to_new_ary); \
#define RBIMPL_ATTR_ARTIFICIAL()
Wraps (or simulates) __attribute__((artificial))
#define FL_UNSET_RAW
Old name of RB_FL_UNSET_RAW.
#define FL_TEST_RAW
Old name of RB_FL_TEST_RAW.
#define Qnil
Old name of RUBY_Qnil.
#define T_ARRAY
Old name of RUBY_T_ARRAY.
#define FL_ALL_RAW
Old name of RB_FL_ALL_RAW.
#define FL_SET_RAW
Old name of RB_FL_SET_RAW.
#define RBIMPL_ATTR_MAYBE_UNUSED()
Wraps (or simulates) [[maybe_unused]]
#define RBIMPL_ATTR_PURE_UNLESS_DEBUG()
Enables RBIMPL_ATTR_PURE if and only if.
#define RARRAY_LEN
Just another name of rb_array_len.
#define RARRAY_CONST_PTR_TRANSIENT
Just another name of rb_array_const_ptr_transient.
#define RARRAY(obj)
Convenient casting macro.
#define RARRAY_AREF(a, i)
uintptr_t VALUE
Type that represents a Ruby object.
static bool RB_TYPE_P(VALUE obj, enum ruby_value_type t)
Queries if the given object is of given type.