datadog-ruby_core_source 3.4.0 → 3.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.datadog.md +4 -0
- data/README.md +8 -5
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/ccan/build_assert/build_assert.h +40 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/ccan/check_type/check_type.h +63 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/ccan/container_of/container_of.h +142 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/ccan/list/list.h +791 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/ccan/str/str.h +17 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/id.h +352 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/id_table.h +39 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/internal/array.h +152 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/internal/basic_operators.h +65 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/internal/bignum.h +244 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/internal/bits.h +650 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/internal/class.h +283 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/internal/cmdlineopt.h +61 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/internal/compar.h +29 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/internal/compile.h +34 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/internal/compilers.h +107 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/internal/complex.h +29 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/internal/cont.h +35 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/internal/dir.h +16 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/internal/enc.h +19 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/internal/encoding.h +38 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/internal/enum.h +18 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/internal/enumerator.h +21 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/internal/error.h +244 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/internal/eval.h +33 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/internal/file.h +38 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/internal/fixnum.h +185 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/internal/gc.h +333 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/internal/hash.h +193 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/internal/imemo.h +257 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/internal/inits.h +47 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/internal/io.h +143 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/internal/load.h +18 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/internal/loadpath.h +16 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/internal/math.h +23 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/internal/missing.h +19 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/internal/numeric.h +274 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/internal/object.h +63 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/internal/parse.h +131 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/internal/proc.h +30 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/internal/process.h +124 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/internal/ractor.h +10 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/internal/random.h +17 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/internal/range.h +40 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/internal/rational.h +71 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/internal/re.h +28 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/internal/ruby_parser.h +102 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/internal/sanitizers.h +330 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/internal/serial.h +23 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/internal/signal.h +24 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/internal/st.h +11 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/internal/static_assert.h +16 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/internal/string.h +199 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/internal/struct.h +119 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/internal/symbol.h +47 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/internal/thread.h +108 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/internal/time.h +37 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/internal/transcode.h +23 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/internal/util.h +27 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/internal/variable.h +70 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/internal/vm.h +137 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/internal/warnings.h +16 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/internal.h +108 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/iseq.h +351 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/method.h +258 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/node.h +122 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/parser_st.h +162 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/parser_value.h +106 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/prism/ast.h +7964 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/prism/defines.h +260 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/prism/diagnostic.h +451 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/prism/encoding.h +283 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/prism/extension.h +19 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/prism/node.h +129 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/prism/options.h +442 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/prism/pack.h +163 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/prism/parser.h +933 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/prism/prettyprint.h +34 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/prism/prism.h +383 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/prism/regexp.h +43 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/prism/static_literals.h +121 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/prism/util/pm_buffer.h +228 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/prism/util/pm_char.h +204 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/prism/util/pm_constant_pool.h +218 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/prism/util/pm_integer.h +126 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/prism/util/pm_list.h +97 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/prism/util/pm_memchr.h +29 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/prism/util/pm_newline_list.h +113 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/prism/util/pm_string.h +190 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/prism/util/pm_strncasecmp.h +32 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/prism/util/pm_strpbrk.h +46 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/prism/version.h +29 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/prism_compile.h +105 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/ractor_core.h +382 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/ruby_assert.h +14 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/ruby_atomic.h +23 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/rubyparser.h +1380 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/shape.h +234 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/thread_none.h +21 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/thread_pthread.h +167 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/vm_core.h +2235 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/vm_debug.h +124 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/vm_opts.h +67 -0
- data/lib/datadog/ruby_core_source/version.rb +1 -1
- metadata +105 -2
@@ -0,0 +1,234 @@
|
|
1
|
+
#ifndef RUBY_SHAPE_H
|
2
|
+
#define RUBY_SHAPE_H
|
3
|
+
|
4
|
+
#include "internal/gc.h"
|
5
|
+
|
6
|
+
#if (SIZEOF_UINT64_T <= SIZEOF_VALUE)
|
7
|
+
|
8
|
+
#define SIZEOF_SHAPE_T 4
|
9
|
+
#define SHAPE_IN_BASIC_FLAGS 1
|
10
|
+
typedef uint32_t attr_index_t;
|
11
|
+
typedef uint32_t shape_id_t;
|
12
|
+
# define SHAPE_ID_NUM_BITS 32
|
13
|
+
|
14
|
+
#else
|
15
|
+
|
16
|
+
#define SIZEOF_SHAPE_T 2
|
17
|
+
#define SHAPE_IN_BASIC_FLAGS 0
|
18
|
+
typedef uint16_t attr_index_t;
|
19
|
+
typedef uint16_t shape_id_t;
|
20
|
+
# define SHAPE_ID_NUM_BITS 16
|
21
|
+
|
22
|
+
#endif
|
23
|
+
|
24
|
+
typedef uint32_t redblack_id_t;
|
25
|
+
|
26
|
+
#define MAX_IVARS (attr_index_t)(-1)
|
27
|
+
|
28
|
+
# define SHAPE_MASK (((uintptr_t)1 << SHAPE_ID_NUM_BITS) - 1)
|
29
|
+
# define SHAPE_FLAG_MASK (((VALUE)-1) >> SHAPE_ID_NUM_BITS)
|
30
|
+
|
31
|
+
# define SHAPE_FLAG_SHIFT ((SIZEOF_VALUE * 8) - SHAPE_ID_NUM_BITS)
|
32
|
+
|
33
|
+
# define SHAPE_MAX_VARIATIONS 8
|
34
|
+
|
35
|
+
# define INVALID_SHAPE_ID SHAPE_MASK
|
36
|
+
# define ROOT_SHAPE_ID 0x0
|
37
|
+
|
38
|
+
# define SPECIAL_CONST_SHAPE_ID (ROOT_SHAPE_ID + 1)
|
39
|
+
# define OBJ_TOO_COMPLEX_SHAPE_ID (SPECIAL_CONST_SHAPE_ID + 1)
|
40
|
+
# define FIRST_T_OBJECT_SHAPE_ID (OBJ_TOO_COMPLEX_SHAPE_ID + 1)
|
41
|
+
|
42
|
+
typedef struct redblack_node redblack_node_t;
|
43
|
+
|
44
|
+
struct rb_shape {
|
45
|
+
struct rb_id_table * edges; // id_table from ID (ivar) to next shape
|
46
|
+
ID edge_name; // ID (ivar) for transition from parent to rb_shape
|
47
|
+
attr_index_t next_iv_index;
|
48
|
+
uint32_t capacity; // Total capacity of the object with this shape
|
49
|
+
uint8_t type;
|
50
|
+
uint8_t heap_index;
|
51
|
+
shape_id_t parent_id;
|
52
|
+
redblack_node_t * ancestor_index;
|
53
|
+
};
|
54
|
+
|
55
|
+
typedef struct rb_shape rb_shape_t;
|
56
|
+
|
57
|
+
struct redblack_node {
|
58
|
+
ID key;
|
59
|
+
rb_shape_t * value;
|
60
|
+
redblack_id_t l;
|
61
|
+
redblack_id_t r;
|
62
|
+
};
|
63
|
+
|
64
|
+
enum shape_type {
|
65
|
+
SHAPE_ROOT,
|
66
|
+
SHAPE_IVAR,
|
67
|
+
SHAPE_FROZEN,
|
68
|
+
SHAPE_T_OBJECT,
|
69
|
+
SHAPE_OBJ_TOO_COMPLEX,
|
70
|
+
};
|
71
|
+
|
72
|
+
typedef struct {
|
73
|
+
/* object shapes */
|
74
|
+
rb_shape_t *shape_list;
|
75
|
+
rb_shape_t *root_shape;
|
76
|
+
shape_id_t next_shape_id;
|
77
|
+
|
78
|
+
redblack_node_t *shape_cache;
|
79
|
+
unsigned int cache_size;
|
80
|
+
} rb_shape_tree_t;
|
81
|
+
RUBY_EXTERN rb_shape_tree_t *rb_shape_tree_ptr;
|
82
|
+
|
83
|
+
static inline rb_shape_tree_t *
|
84
|
+
rb_current_shape_tree(void)
|
85
|
+
{
|
86
|
+
return rb_shape_tree_ptr;
|
87
|
+
}
|
88
|
+
#define GET_SHAPE_TREE() rb_current_shape_tree()
|
89
|
+
|
90
|
+
static inline shape_id_t
|
91
|
+
get_shape_id_from_flags(VALUE obj)
|
92
|
+
{
|
93
|
+
RUBY_ASSERT(!RB_SPECIAL_CONST_P(obj));
|
94
|
+
return (shape_id_t)(SHAPE_MASK & ((RBASIC(obj)->flags) >> SHAPE_FLAG_SHIFT));
|
95
|
+
}
|
96
|
+
|
97
|
+
static inline void
|
98
|
+
set_shape_id_in_flags(VALUE obj, shape_id_t shape_id)
|
99
|
+
{
|
100
|
+
// Ractors are occupying the upper 32 bits of flags, but only in debug mode
|
101
|
+
// Object shapes are occupying top bits
|
102
|
+
RBASIC(obj)->flags &= SHAPE_FLAG_MASK;
|
103
|
+
RBASIC(obj)->flags |= ((VALUE)(shape_id) << SHAPE_FLAG_SHIFT);
|
104
|
+
}
|
105
|
+
|
106
|
+
|
107
|
+
#if SHAPE_IN_BASIC_FLAGS
|
108
|
+
static inline shape_id_t
|
109
|
+
RBASIC_SHAPE_ID(VALUE obj)
|
110
|
+
{
|
111
|
+
return get_shape_id_from_flags(obj);
|
112
|
+
}
|
113
|
+
|
114
|
+
static inline void
|
115
|
+
RBASIC_SET_SHAPE_ID(VALUE obj, shape_id_t shape_id)
|
116
|
+
{
|
117
|
+
set_shape_id_in_flags(obj, shape_id);
|
118
|
+
}
|
119
|
+
#endif
|
120
|
+
|
121
|
+
static inline shape_id_t
|
122
|
+
ROBJECT_SHAPE_ID(VALUE obj)
|
123
|
+
{
|
124
|
+
RBIMPL_ASSERT_TYPE(obj, RUBY_T_OBJECT);
|
125
|
+
return get_shape_id_from_flags(obj);
|
126
|
+
}
|
127
|
+
|
128
|
+
static inline void
|
129
|
+
ROBJECT_SET_SHAPE_ID(VALUE obj, shape_id_t shape_id)
|
130
|
+
{
|
131
|
+
RBIMPL_ASSERT_TYPE(obj, RUBY_T_OBJECT);
|
132
|
+
set_shape_id_in_flags(obj, shape_id);
|
133
|
+
}
|
134
|
+
|
135
|
+
static inline shape_id_t
|
136
|
+
RCLASS_SHAPE_ID(VALUE obj)
|
137
|
+
{
|
138
|
+
RUBY_ASSERT(RB_TYPE_P(obj, T_CLASS) || RB_TYPE_P(obj, T_MODULE));
|
139
|
+
return get_shape_id_from_flags(obj);
|
140
|
+
}
|
141
|
+
|
142
|
+
static inline void
|
143
|
+
RCLASS_SET_SHAPE_ID(VALUE obj, shape_id_t shape_id)
|
144
|
+
{
|
145
|
+
RUBY_ASSERT(RB_TYPE_P(obj, T_CLASS) || RB_TYPE_P(obj, T_MODULE));
|
146
|
+
set_shape_id_in_flags(obj, shape_id);
|
147
|
+
}
|
148
|
+
|
149
|
+
rb_shape_t * rb_shape_get_root_shape(void);
|
150
|
+
int32_t rb_shape_id_offset(void);
|
151
|
+
|
152
|
+
rb_shape_t * rb_shape_get_parent(rb_shape_t * shape);
|
153
|
+
|
154
|
+
RUBY_FUNC_EXPORTED rb_shape_t *rb_shape_get_shape_by_id(shape_id_t shape_id);
|
155
|
+
RUBY_FUNC_EXPORTED shape_id_t rb_shape_get_shape_id(VALUE obj);
|
156
|
+
rb_shape_t * rb_shape_get_next_iv_shape(rb_shape_t * shape, ID id);
|
157
|
+
bool rb_shape_get_iv_index(rb_shape_t * shape, ID id, attr_index_t * value);
|
158
|
+
bool rb_shape_get_iv_index_with_hint(shape_id_t shape_id, ID id, attr_index_t * value, shape_id_t *shape_id_hint);
|
159
|
+
RUBY_FUNC_EXPORTED bool rb_shape_obj_too_complex(VALUE obj);
|
160
|
+
|
161
|
+
void rb_shape_set_shape(VALUE obj, rb_shape_t* shape);
|
162
|
+
rb_shape_t* rb_shape_get_shape(VALUE obj);
|
163
|
+
int rb_shape_frozen_shape_p(rb_shape_t* shape);
|
164
|
+
rb_shape_t* rb_shape_transition_shape_frozen(VALUE obj);
|
165
|
+
bool rb_shape_transition_shape_remove_ivar(VALUE obj, ID id, rb_shape_t *shape, VALUE * removed);
|
166
|
+
rb_shape_t* rb_shape_get_next(rb_shape_t* shape, VALUE obj, ID id);
|
167
|
+
rb_shape_t* rb_shape_get_next_no_warnings(rb_shape_t* shape, VALUE obj, ID id);
|
168
|
+
|
169
|
+
rb_shape_t * rb_shape_rebuild_shape(rb_shape_t * initial_shape, rb_shape_t * dest_shape);
|
170
|
+
|
171
|
+
static inline uint32_t
|
172
|
+
ROBJECT_IV_CAPACITY(VALUE obj)
|
173
|
+
{
|
174
|
+
RBIMPL_ASSERT_TYPE(obj, RUBY_T_OBJECT);
|
175
|
+
// Asking for capacity doesn't make sense when the object is using
|
176
|
+
// a hash table for storing instance variables
|
177
|
+
RUBY_ASSERT(!rb_shape_obj_too_complex(obj));
|
178
|
+
return rb_shape_get_shape_by_id(ROBJECT_SHAPE_ID(obj))->capacity;
|
179
|
+
}
|
180
|
+
|
181
|
+
static inline st_table *
|
182
|
+
ROBJECT_IV_HASH(VALUE obj)
|
183
|
+
{
|
184
|
+
RBIMPL_ASSERT_TYPE(obj, RUBY_T_OBJECT);
|
185
|
+
RUBY_ASSERT(rb_shape_obj_too_complex(obj));
|
186
|
+
return (st_table *)ROBJECT(obj)->as.heap.ivptr;
|
187
|
+
}
|
188
|
+
|
189
|
+
static inline void
|
190
|
+
ROBJECT_SET_IV_HASH(VALUE obj, const st_table *tbl)
|
191
|
+
{
|
192
|
+
RBIMPL_ASSERT_TYPE(obj, RUBY_T_OBJECT);
|
193
|
+
RUBY_ASSERT(rb_shape_obj_too_complex(obj));
|
194
|
+
ROBJECT(obj)->as.heap.ivptr = (VALUE *)tbl;
|
195
|
+
}
|
196
|
+
|
197
|
+
size_t rb_id_table_size(const struct rb_id_table *tbl);
|
198
|
+
|
199
|
+
static inline uint32_t
|
200
|
+
ROBJECT_IV_COUNT(VALUE obj)
|
201
|
+
{
|
202
|
+
if (rb_shape_obj_too_complex(obj)) {
|
203
|
+
return (uint32_t)rb_st_table_size(ROBJECT_IV_HASH(obj));
|
204
|
+
}
|
205
|
+
else {
|
206
|
+
RBIMPL_ASSERT_TYPE(obj, RUBY_T_OBJECT);
|
207
|
+
RUBY_ASSERT(!rb_shape_obj_too_complex(obj));
|
208
|
+
return rb_shape_get_shape_by_id(ROBJECT_SHAPE_ID(obj))->next_iv_index;
|
209
|
+
}
|
210
|
+
}
|
211
|
+
|
212
|
+
static inline uint32_t
|
213
|
+
RBASIC_IV_COUNT(VALUE obj)
|
214
|
+
{
|
215
|
+
return rb_shape_get_shape_by_id(rb_shape_get_shape_id(obj))->next_iv_index;
|
216
|
+
}
|
217
|
+
|
218
|
+
rb_shape_t *rb_shape_traverse_from_new_root(rb_shape_t *initial_shape, rb_shape_t *orig_shape);
|
219
|
+
|
220
|
+
bool rb_shape_set_shape_id(VALUE obj, shape_id_t shape_id);
|
221
|
+
|
222
|
+
VALUE rb_obj_debug_shape(VALUE self, VALUE obj);
|
223
|
+
|
224
|
+
// For ext/objspace
|
225
|
+
RUBY_SYMBOL_EXPORT_BEGIN
|
226
|
+
typedef void each_shape_callback(rb_shape_t * shape, void *data);
|
227
|
+
void rb_shape_each_shape(each_shape_callback callback, void *data);
|
228
|
+
size_t rb_shape_memsize(rb_shape_t *shape);
|
229
|
+
size_t rb_shape_edges_count(rb_shape_t *shape);
|
230
|
+
size_t rb_shape_depth(rb_shape_t *shape);
|
231
|
+
shape_id_t rb_shape_id(rb_shape_t * shape);
|
232
|
+
RUBY_SYMBOL_EXPORT_END
|
233
|
+
|
234
|
+
#endif
|
@@ -0,0 +1,21 @@
|
|
1
|
+
#ifndef RUBY_THREAD_NONE_H
|
2
|
+
#define RUBY_THREAD_NONE_H
|
3
|
+
|
4
|
+
#define RB_NATIVETHREAD_LOCK_INIT (void)(0)
|
5
|
+
#define RB_NATIVETHREAD_COND_INIT (void)(0)
|
6
|
+
|
7
|
+
// no-thread impl doesn't use TLS but define this to avoid using tls key
|
8
|
+
// based implementation in vm.c
|
9
|
+
#define RB_THREAD_LOCAL_SPECIFIER
|
10
|
+
|
11
|
+
struct rb_native_thread {
|
12
|
+
void *thread_id; // NULL
|
13
|
+
};
|
14
|
+
|
15
|
+
struct rb_thread_sched_item {};
|
16
|
+
struct rb_thread_sched {};
|
17
|
+
|
18
|
+
RUBY_EXTERN struct rb_execution_context_struct *ruby_current_ec;
|
19
|
+
NOINLINE(struct rb_execution_context_struct *rb_current_ec_noinline(void)); // for assertions
|
20
|
+
|
21
|
+
#endif /* RUBY_THREAD_NONE_H */
|
@@ -0,0 +1,167 @@
|
|
1
|
+
#ifndef RUBY_THREAD_PTHREAD_H
|
2
|
+
#define RUBY_THREAD_PTHREAD_H
|
3
|
+
/**********************************************************************
|
4
|
+
|
5
|
+
thread_pthread.h -
|
6
|
+
|
7
|
+
$Author$
|
8
|
+
|
9
|
+
Copyright (C) 2004-2007 Koichi Sasada
|
10
|
+
|
11
|
+
**********************************************************************/
|
12
|
+
|
13
|
+
#ifdef HAVE_PTHREAD_NP_H
|
14
|
+
#include <pthread_np.h>
|
15
|
+
#endif
|
16
|
+
|
17
|
+
#define RB_NATIVETHREAD_LOCK_INIT PTHREAD_MUTEX_INITIALIZER
|
18
|
+
#define RB_NATIVETHREAD_COND_INIT PTHREAD_COND_INITIALIZER
|
19
|
+
|
20
|
+
// this data should be protected by timer_th.waiting_lock
|
21
|
+
struct rb_thread_sched_waiting {
|
22
|
+
enum thread_sched_waiting_flag {
|
23
|
+
thread_sched_waiting_none = 0x00,
|
24
|
+
thread_sched_waiting_timeout = 0x01,
|
25
|
+
thread_sched_waiting_io_read = 0x02,
|
26
|
+
thread_sched_waiting_io_write = 0x08,
|
27
|
+
thread_sched_waiting_io_force = 0x40, // ignore readable
|
28
|
+
} flags;
|
29
|
+
|
30
|
+
struct {
|
31
|
+
// should be compat with hrtime.h
|
32
|
+
#ifdef MY_RUBY_BUILD_MAY_TIME_TRAVEL
|
33
|
+
int128_t timeout;
|
34
|
+
#else
|
35
|
+
uint64_t timeout;
|
36
|
+
#endif
|
37
|
+
int fd; // -1 for timeout only
|
38
|
+
int result;
|
39
|
+
} data;
|
40
|
+
|
41
|
+
// connected to timer_th.waiting
|
42
|
+
struct ccan_list_node node;
|
43
|
+
};
|
44
|
+
|
45
|
+
// per-Thead scheduler helper data
|
46
|
+
struct rb_thread_sched_item {
|
47
|
+
struct {
|
48
|
+
struct ccan_list_node ubf;
|
49
|
+
|
50
|
+
// connected to ractor->threads.sched.reqdyq
|
51
|
+
// locked by ractor->threads.sched.lock
|
52
|
+
struct ccan_list_node readyq;
|
53
|
+
|
54
|
+
// connected to vm->ractor.sched.timeslice_threads
|
55
|
+
// locked by vm->ractor.sched.lock
|
56
|
+
struct ccan_list_node timeslice_threads;
|
57
|
+
|
58
|
+
// connected to vm->ractor.sched.running_threads
|
59
|
+
// locked by vm->ractor.sched.lock
|
60
|
+
struct ccan_list_node running_threads;
|
61
|
+
|
62
|
+
// connected to vm->ractor.sched.zombie_threads
|
63
|
+
struct ccan_list_node zombie_threads;
|
64
|
+
} node;
|
65
|
+
|
66
|
+
struct rb_thread_sched_waiting waiting_reason;
|
67
|
+
|
68
|
+
bool finished;
|
69
|
+
bool malloc_stack;
|
70
|
+
void *context_stack;
|
71
|
+
struct coroutine_context *context;
|
72
|
+
};
|
73
|
+
|
74
|
+
struct rb_native_thread {
|
75
|
+
rb_atomic_t serial;
|
76
|
+
struct rb_vm_struct *vm;
|
77
|
+
|
78
|
+
rb_nativethread_id_t thread_id;
|
79
|
+
|
80
|
+
#ifdef RB_THREAD_T_HAS_NATIVE_ID
|
81
|
+
int tid;
|
82
|
+
#endif
|
83
|
+
|
84
|
+
struct rb_thread_struct *running_thread;
|
85
|
+
|
86
|
+
// to control native thread
|
87
|
+
#if defined(__GLIBC__) || defined(__FreeBSD__)
|
88
|
+
union
|
89
|
+
#else
|
90
|
+
/*
|
91
|
+
* assume the platform condvars are badly implemented and have a
|
92
|
+
* "memory" of which mutex they're associated with
|
93
|
+
*/
|
94
|
+
struct
|
95
|
+
#endif
|
96
|
+
{
|
97
|
+
rb_nativethread_cond_t intr; /* th->interrupt_lock */
|
98
|
+
rb_nativethread_cond_t readyq; /* use sched->lock */
|
99
|
+
} cond;
|
100
|
+
|
101
|
+
#ifdef USE_SIGALTSTACK
|
102
|
+
void *altstack;
|
103
|
+
#endif
|
104
|
+
|
105
|
+
struct coroutine_context *nt_context;
|
106
|
+
int dedicated;
|
107
|
+
|
108
|
+
size_t machine_stack_maxsize;
|
109
|
+
};
|
110
|
+
|
111
|
+
#undef except
|
112
|
+
#undef try
|
113
|
+
#undef leave
|
114
|
+
#undef finally
|
115
|
+
|
116
|
+
// per-Ractor
|
117
|
+
struct rb_thread_sched {
|
118
|
+
rb_nativethread_lock_t lock_;
|
119
|
+
#if VM_CHECK_MODE
|
120
|
+
struct rb_thread_struct *lock_owner;
|
121
|
+
#endif
|
122
|
+
struct rb_thread_struct *running; // running thread or NULL
|
123
|
+
bool is_running;
|
124
|
+
bool is_running_timeslice;
|
125
|
+
bool enable_mn_threads;
|
126
|
+
|
127
|
+
struct ccan_list_head readyq;
|
128
|
+
int readyq_cnt;
|
129
|
+
// ractor scheduling
|
130
|
+
struct ccan_list_node grq_node;
|
131
|
+
};
|
132
|
+
|
133
|
+
#ifdef RB_THREAD_LOCAL_SPECIFIER
|
134
|
+
NOINLINE(void rb_current_ec_set(struct rb_execution_context_struct *));
|
135
|
+
|
136
|
+
# if defined(__arm64__) || defined(__aarch64__)
|
137
|
+
// on Arm64, TLS can not be accessed across .so
|
138
|
+
NOINLINE(struct rb_execution_context_struct *rb_current_ec(void));
|
139
|
+
# else
|
140
|
+
RUBY_EXTERN RB_THREAD_LOCAL_SPECIFIER struct rb_execution_context_struct *ruby_current_ec;
|
141
|
+
|
142
|
+
// for RUBY_DEBUG_LOG()
|
143
|
+
RUBY_EXTERN RB_THREAD_LOCAL_SPECIFIER rb_atomic_t ruby_nt_serial;
|
144
|
+
#define RUBY_NT_SERIAL 1
|
145
|
+
# endif
|
146
|
+
#else
|
147
|
+
typedef pthread_key_t native_tls_key_t;
|
148
|
+
|
149
|
+
static inline void *
|
150
|
+
native_tls_get(native_tls_key_t key)
|
151
|
+
{
|
152
|
+
// return value should be checked by caller
|
153
|
+
return pthread_getspecific(key);
|
154
|
+
}
|
155
|
+
|
156
|
+
static inline void
|
157
|
+
native_tls_set(native_tls_key_t key, void *ptr)
|
158
|
+
{
|
159
|
+
if (UNLIKELY(pthread_setspecific(key, ptr) != 0)) {
|
160
|
+
rb_bug("pthread_setspecific error");
|
161
|
+
}
|
162
|
+
}
|
163
|
+
|
164
|
+
RUBY_EXTERN native_tls_key_t ruby_current_ec_key;
|
165
|
+
#endif
|
166
|
+
|
167
|
+
#endif /* RUBY_THREAD_PTHREAD_H */
|