debase-ruby_core_source 3.2.0 → 3.2.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (122) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/CHANGELOG.md +10 -0
  4. data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/addr2line.h +20 -0
  5. data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/builtin.h +117 -0
  6. data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/ccan/build_assert/build_assert.h +40 -0
  7. data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/ccan/check_type/check_type.h +63 -0
  8. data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/ccan/container_of/container_of.h +142 -0
  9. data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/ccan/list/list.h +789 -0
  10. data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/ccan/str/str.h +17 -0
  11. data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/constant.h +53 -0
  12. data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/darray.h +246 -0
  13. data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/debug_counter.h +423 -0
  14. data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/dln.h +31 -0
  15. data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/encindex.h +70 -0
  16. data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/eval_intern.h +341 -0
  17. data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/hrtime.h +227 -0
  18. data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/id.h +343 -0
  19. data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/id_table.h +39 -0
  20. data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/insns.inc +249 -0
  21. data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/insns_info.inc +9133 -0
  22. data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/internal/array.h +144 -0
  23. data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/internal/basic_operators.h +63 -0
  24. data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/internal/bignum.h +244 -0
  25. data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/internal/bits.h +568 -0
  26. data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/internal/class.h +226 -0
  27. data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/internal/cmdlineopt.h +63 -0
  28. data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/internal/compar.h +29 -0
  29. data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/internal/compile.h +34 -0
  30. data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/internal/compilers.h +107 -0
  31. data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/internal/complex.h +29 -0
  32. data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/internal/cont.h +32 -0
  33. data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/internal/dir.h +16 -0
  34. data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/internal/enc.h +19 -0
  35. data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/internal/encoding.h +32 -0
  36. data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/internal/enum.h +18 -0
  37. data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/internal/enumerator.h +21 -0
  38. data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/internal/error.h +213 -0
  39. data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/internal/eval.h +32 -0
  40. data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/internal/file.h +38 -0
  41. data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/internal/fixnum.h +184 -0
  42. data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/internal/gc.h +361 -0
  43. data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/internal/hash.h +190 -0
  44. data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/internal/imemo.h +241 -0
  45. data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/internal/inits.h +50 -0
  46. data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/internal/io.h +137 -0
  47. data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/internal/load.h +18 -0
  48. data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/internal/loadpath.h +16 -0
  49. data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/internal/math.h +23 -0
  50. data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/internal/missing.h +18 -0
  51. data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/internal/numeric.h +273 -0
  52. data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/internal/object.h +59 -0
  53. data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/internal/parse.h +133 -0
  54. data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/internal/proc.h +30 -0
  55. data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/internal/process.h +124 -0
  56. data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/internal/ractor.h +6 -0
  57. data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/internal/random.h +16 -0
  58. data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/internal/range.h +40 -0
  59. data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/internal/rational.h +71 -0
  60. data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/internal/re.h +28 -0
  61. data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/internal/ruby_parser.h +69 -0
  62. data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/internal/sanitizers.h +186 -0
  63. data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/internal/serial.h +23 -0
  64. data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/internal/signal.h +25 -0
  65. data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/internal/static_assert.h +16 -0
  66. data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/internal/string.h +160 -0
  67. data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/internal/struct.h +127 -0
  68. data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/internal/symbol.h +42 -0
  69. data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/internal/thread.h +74 -0
  70. data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/internal/time.h +34 -0
  71. data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/internal/transcode.h +20 -0
  72. data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/internal/util.h +27 -0
  73. data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/internal/variable.h +71 -0
  74. data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/internal/vm.h +129 -0
  75. data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/internal/warnings.h +16 -0
  76. data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/internal.h +112 -0
  77. data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/iseq.h +334 -0
  78. data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/known_errors.inc +791 -0
  79. data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/method.h +254 -0
  80. data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/node.h +125 -0
  81. data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/node_name.inc +210 -0
  82. data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/optinsn.inc +128 -0
  83. data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/optunifs.inc +43 -0
  84. data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/parse.h +232 -0
  85. data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/parser_bits.h +564 -0
  86. data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/parser_node.h +133 -0
  87. data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/parser_st.h +162 -0
  88. data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/parser_value.h +106 -0
  89. data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/probes_helper.h +42 -0
  90. data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/ractor_core.h +387 -0
  91. data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/regenc.h +254 -0
  92. data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/regint.h +996 -0
  93. data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/regparse.h +370 -0
  94. data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/revision.h +5 -0
  95. data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/rjit.h +103 -0
  96. data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/rjit_c.h +165 -0
  97. data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/ruby_assert.h +14 -0
  98. data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/ruby_atomic.h +23 -0
  99. data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/rubyparser.h +628 -0
  100. data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/shape.h +232 -0
  101. data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/siphash.h +48 -0
  102. data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/symbol.h +119 -0
  103. data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/thread_none.h +20 -0
  104. data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/thread_pthread.h +126 -0
  105. data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/thread_win32.h +58 -0
  106. data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/timev.h +58 -0
  107. data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/transcode_data.h +138 -0
  108. data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/variable.h +30 -0
  109. data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/version.h +65 -0
  110. data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/vm.inc +5396 -0
  111. data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/vm_call_iseq_optimized.inc +244 -0
  112. data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/vm_callinfo.h +608 -0
  113. data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/vm_core.h +2089 -0
  114. data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/vm_debug.h +122 -0
  115. data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/vm_exec.h +199 -0
  116. data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/vm_insnhelper.h +271 -0
  117. data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/vm_opts.h +67 -0
  118. data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/vm_sync.h +137 -0
  119. data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/vmtc.inc +243 -0
  120. data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/yjit.h +70 -0
  121. data/lib/debase/ruby_core_source/version.rb +1 -1
  122. metadata +120 -3
@@ -0,0 +1,232 @@
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
+ #define SIZEOF_SHAPE_T 4
8
+ #define SHAPE_IN_BASIC_FLAGS 1
9
+ typedef uint32_t attr_index_t;
10
+ #else
11
+ #define SIZEOF_SHAPE_T 2
12
+ #define SHAPE_IN_BASIC_FLAGS 0
13
+ typedef uint16_t attr_index_t;
14
+ #endif
15
+
16
+ #define MAX_IVARS (attr_index_t)(-1)
17
+
18
+ #if SIZEOF_SHAPE_T == 4
19
+ typedef uint32_t shape_id_t;
20
+ # define SHAPE_ID_NUM_BITS 32
21
+ # define SHAPE_BUFFER_SIZE 0x80000
22
+ #else
23
+ typedef uint16_t shape_id_t;
24
+ # define SHAPE_ID_NUM_BITS 16
25
+ # define SHAPE_BUFFER_SIZE 0x8000
26
+ #endif
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
+ # define SHAPE_MAX_NUM_IVS 80
35
+
36
+ # define MAX_SHAPE_ID SHAPE_BUFFER_SIZE
37
+ # define INVALID_SHAPE_ID SHAPE_MASK
38
+ # define ROOT_SHAPE_ID 0x0
39
+
40
+ # define SPECIAL_CONST_SHAPE_ID (SIZE_POOL_COUNT * 2)
41
+ # define OBJ_TOO_COMPLEX_SHAPE_ID (SPECIAL_CONST_SHAPE_ID + 1)
42
+
43
+ struct rb_shape {
44
+ struct rb_id_table * edges; // id_table from ID (ivar) to next shape
45
+ ID edge_name; // ID (ivar) for transition from parent to rb_shape
46
+ attr_index_t next_iv_index;
47
+ uint32_t capacity; // Total capacity of the object with this shape
48
+ uint8_t type;
49
+ uint8_t size_pool_index;
50
+ shape_id_t parent_id;
51
+ };
52
+
53
+ typedef struct rb_shape rb_shape_t;
54
+
55
+ enum shape_type {
56
+ SHAPE_ROOT,
57
+ SHAPE_IVAR,
58
+ SHAPE_FROZEN,
59
+ SHAPE_CAPACITY_CHANGE,
60
+ SHAPE_INITIAL_CAPACITY,
61
+ SHAPE_T_OBJECT,
62
+ SHAPE_OBJ_TOO_COMPLEX,
63
+ };
64
+
65
+ typedef struct {
66
+ /* object shapes */
67
+ rb_shape_t *shape_list;
68
+ rb_shape_t *root_shape;
69
+ shape_id_t next_shape_id;
70
+ } rb_shape_tree_t;
71
+ RUBY_EXTERN rb_shape_tree_t *rb_shape_tree_ptr;
72
+
73
+ static inline rb_shape_tree_t *
74
+ rb_current_shape_tree(void)
75
+ {
76
+ return rb_shape_tree_ptr;
77
+ }
78
+ #define GET_SHAPE_TREE() rb_current_shape_tree()
79
+
80
+ static inline shape_id_t
81
+ get_shape_id_from_flags(VALUE obj)
82
+ {
83
+ RUBY_ASSERT(!RB_SPECIAL_CONST_P(obj));
84
+ return (shape_id_t)(SHAPE_MASK & ((RBASIC(obj)->flags) >> SHAPE_FLAG_SHIFT));
85
+ }
86
+
87
+ static inline void
88
+ set_shape_id_in_flags(VALUE obj, shape_id_t shape_id)
89
+ {
90
+ // Ractors are occupying the upper 32 bits of flags, but only in debug mode
91
+ // Object shapes are occupying top bits
92
+ RBASIC(obj)->flags &= SHAPE_FLAG_MASK;
93
+ RBASIC(obj)->flags |= ((VALUE)(shape_id) << SHAPE_FLAG_SHIFT);
94
+ }
95
+
96
+
97
+ #if SHAPE_IN_BASIC_FLAGS
98
+ static inline shape_id_t
99
+ RBASIC_SHAPE_ID(VALUE obj)
100
+ {
101
+ return get_shape_id_from_flags(obj);
102
+ }
103
+
104
+ static inline void
105
+ RBASIC_SET_SHAPE_ID(VALUE obj, shape_id_t shape_id)
106
+ {
107
+ set_shape_id_in_flags(obj, shape_id);
108
+ }
109
+ #endif
110
+
111
+ static inline shape_id_t
112
+ ROBJECT_SHAPE_ID(VALUE obj)
113
+ {
114
+ RBIMPL_ASSERT_TYPE(obj, RUBY_T_OBJECT);
115
+ return get_shape_id_from_flags(obj);
116
+ }
117
+
118
+ static inline void
119
+ ROBJECT_SET_SHAPE_ID(VALUE obj, shape_id_t shape_id)
120
+ {
121
+ RBIMPL_ASSERT_TYPE(obj, RUBY_T_OBJECT);
122
+ set_shape_id_in_flags(obj, shape_id);
123
+ }
124
+
125
+ static inline shape_id_t
126
+ RCLASS_SHAPE_ID(VALUE obj)
127
+ {
128
+ RUBY_ASSERT(RB_TYPE_P(obj, T_CLASS) || RB_TYPE_P(obj, T_MODULE));
129
+ return get_shape_id_from_flags(obj);
130
+ }
131
+
132
+ static inline void
133
+ RCLASS_SET_SHAPE_ID(VALUE obj, shape_id_t shape_id)
134
+ {
135
+ RUBY_ASSERT(RB_TYPE_P(obj, T_CLASS) || RB_TYPE_P(obj, T_MODULE));
136
+ set_shape_id_in_flags(obj, shape_id);
137
+ }
138
+
139
+ rb_shape_t * rb_shape_get_root_shape(void);
140
+ int32_t rb_shape_id_offset(void);
141
+
142
+ rb_shape_t * rb_shape_get_parent(rb_shape_t * shape);
143
+
144
+ rb_shape_t* rb_shape_get_shape_by_id(shape_id_t shape_id);
145
+ shape_id_t rb_shape_get_shape_id(VALUE obj);
146
+ rb_shape_t * rb_shape_get_next_iv_shape(rb_shape_t * shape, ID id);
147
+ bool rb_shape_get_iv_index(rb_shape_t * shape, ID id, attr_index_t * value);
148
+ bool rb_shape_obj_too_complex(VALUE obj);
149
+
150
+ void rb_shape_set_shape(VALUE obj, rb_shape_t* shape);
151
+ rb_shape_t* rb_shape_get_shape(VALUE obj);
152
+ int rb_shape_frozen_shape_p(rb_shape_t* shape);
153
+ void rb_shape_transition_shape_frozen(VALUE obj);
154
+ void rb_shape_transition_shape_remove_ivar(VALUE obj, ID id, rb_shape_t *shape, VALUE * removed);
155
+ rb_shape_t * rb_shape_transition_shape_capa(rb_shape_t * shape, uint32_t new_capacity);
156
+ rb_shape_t* rb_shape_get_next(rb_shape_t* shape, VALUE obj, ID id);
157
+
158
+ rb_shape_t * rb_shape_rebuild_shape(rb_shape_t * initial_shape, rb_shape_t * dest_shape);
159
+
160
+ static inline uint32_t
161
+ ROBJECT_IV_CAPACITY(VALUE obj)
162
+ {
163
+ RBIMPL_ASSERT_TYPE(obj, RUBY_T_OBJECT);
164
+ // Asking for capacity doesn't make sense when the object is using
165
+ // a hash table for storing instance variables
166
+ RUBY_ASSERT(ROBJECT_SHAPE_ID(obj) != OBJ_TOO_COMPLEX_SHAPE_ID);
167
+ return rb_shape_get_shape_by_id(ROBJECT_SHAPE_ID(obj))->capacity;
168
+ }
169
+
170
+ static inline st_table *
171
+ ROBJECT_IV_HASH(VALUE obj)
172
+ {
173
+ RBIMPL_ASSERT_TYPE(obj, RUBY_T_OBJECT);
174
+ RUBY_ASSERT(ROBJECT_SHAPE_ID(obj) == OBJ_TOO_COMPLEX_SHAPE_ID);
175
+ return (st_table *)ROBJECT(obj)->as.heap.ivptr;
176
+ }
177
+
178
+ static inline void
179
+ ROBJECT_SET_IV_HASH(VALUE obj, const struct rb_id_table *tbl)
180
+ {
181
+ RBIMPL_ASSERT_TYPE(obj, RUBY_T_OBJECT);
182
+ RUBY_ASSERT(ROBJECT_SHAPE_ID(obj) == OBJ_TOO_COMPLEX_SHAPE_ID);
183
+ ROBJECT(obj)->as.heap.ivptr = (VALUE *)tbl;
184
+ }
185
+
186
+ size_t rb_id_table_size(const struct rb_id_table *tbl);
187
+
188
+ static inline uint32_t
189
+ ROBJECT_IV_COUNT(VALUE obj)
190
+ {
191
+ if (ROBJECT_SHAPE_ID(obj) == OBJ_TOO_COMPLEX_SHAPE_ID) {
192
+ return (uint32_t)rb_st_table_size(ROBJECT_IV_HASH(obj));
193
+ }
194
+ else {
195
+ RBIMPL_ASSERT_TYPE(obj, RUBY_T_OBJECT);
196
+ RUBY_ASSERT(ROBJECT_SHAPE_ID(obj) != OBJ_TOO_COMPLEX_SHAPE_ID);
197
+ return rb_shape_get_shape_by_id(ROBJECT_SHAPE_ID(obj))->next_iv_index;
198
+ }
199
+ }
200
+
201
+ static inline uint32_t
202
+ RBASIC_IV_COUNT(VALUE obj)
203
+ {
204
+ return rb_shape_get_shape_by_id(rb_shape_get_shape_id(obj))->next_iv_index;
205
+ }
206
+
207
+ static inline uint32_t
208
+ RCLASS_IV_COUNT(VALUE obj)
209
+ {
210
+ RUBY_ASSERT(RB_TYPE_P(obj, RUBY_T_CLASS) || RB_TYPE_P(obj, RUBY_T_MODULE));
211
+ uint32_t ivc = rb_shape_get_shape_by_id(RCLASS_SHAPE_ID(obj))->next_iv_index;
212
+ return ivc;
213
+ }
214
+
215
+ rb_shape_t *rb_shape_traverse_from_new_root(rb_shape_t *initial_shape, rb_shape_t *orig_shape);
216
+
217
+ bool rb_shape_set_shape_id(VALUE obj, shape_id_t shape_id);
218
+
219
+ VALUE rb_obj_debug_shape(VALUE self, VALUE obj);
220
+ void rb_shape_set_too_complex(VALUE obj);
221
+
222
+ // For ext/objspace
223
+ RUBY_SYMBOL_EXPORT_BEGIN
224
+ typedef void each_shape_callback(rb_shape_t * shape, void *data);
225
+ void rb_shape_each_shape(each_shape_callback callback, void *data);
226
+ size_t rb_shape_memsize(rb_shape_t *shape);
227
+ size_t rb_shape_edges_count(rb_shape_t *shape);
228
+ size_t rb_shape_depth(rb_shape_t *shape);
229
+ shape_id_t rb_shape_id(rb_shape_t * shape);
230
+ RUBY_SYMBOL_EXPORT_END
231
+
232
+ #endif
@@ -0,0 +1,48 @@
1
+ #ifndef SIPHASH_H
2
+ #define SIPHASH_H 1
3
+ #include <stdlib.h>
4
+ #ifdef HAVE_STDINT_H
5
+ #include <stdint.h>
6
+ #endif
7
+ #ifdef HAVE_INTTYPES_H
8
+ #include <inttypes.h>
9
+ #endif
10
+
11
+ #ifndef HAVE_UINT64_T
12
+ typedef struct {
13
+ uint32_t u32[2];
14
+ } sip_uint64_t;
15
+ #define uint64_t sip_uint64_t
16
+ #else
17
+ typedef uint64_t sip_uint64_t;
18
+ #endif
19
+
20
+ typedef struct {
21
+ int c;
22
+ int d;
23
+ uint64_t v[4];
24
+ uint8_t buf[sizeof(uint64_t)];
25
+ uint8_t buflen;
26
+ uint8_t msglen_byte;
27
+ } sip_state;
28
+
29
+ typedef struct sip_interface_st sip_interface;
30
+
31
+ typedef struct {
32
+ sip_state state[1];
33
+ const sip_interface *methods;
34
+ } sip_hash;
35
+
36
+ sip_hash *sip_hash_new(const uint8_t key[16], int c, int d);
37
+ sip_hash *sip_hash_init(sip_hash *h, const uint8_t key[16], int c, int d);
38
+ int sip_hash_update(sip_hash *h, const uint8_t *data, size_t len);
39
+ int sip_hash_final(sip_hash *h, uint8_t **digest, size_t *len);
40
+ int sip_hash_final_integer(sip_hash *h, uint64_t *digest);
41
+ int sip_hash_digest(sip_hash *h, const uint8_t *data, size_t data_len, uint8_t **digest, size_t *digest_len);
42
+ int sip_hash_digest_integer(sip_hash *h, const uint8_t *data, size_t data_len, uint64_t *digest);
43
+ void sip_hash_free(sip_hash *h);
44
+ void sip_hash_dump(sip_hash *h);
45
+
46
+ NO_SANITIZE("unsigned-integer-overflow", uint64_t sip_hash13(const uint8_t key[16], const uint8_t *data, size_t len));
47
+
48
+ #endif
@@ -0,0 +1,119 @@
1
+ #ifndef RUBY_SYMBOL_H
2
+ #define RUBY_SYMBOL_H 1
3
+ /**********************************************************************
4
+
5
+ symbol.h -
6
+
7
+ $Author$
8
+ created at: Tue Jul 8 15:49:54 JST 2014
9
+
10
+ Copyright (C) 2014 Yukihiro Matsumoto
11
+
12
+ **********************************************************************/
13
+
14
+ #include "id.h"
15
+ #include "ruby/encoding.h"
16
+
17
+ #define DYNAMIC_ID_P(id) (!(id&ID_STATIC_SYM)&&id>tLAST_OP_ID)
18
+ #define STATIC_ID2SYM(id) (((VALUE)(id)<<RUBY_SPECIAL_SHIFT)|SYMBOL_FLAG)
19
+
20
+ #ifdef HAVE_BUILTIN___BUILTIN_CONSTANT_P
21
+ #define rb_id2sym(id) \
22
+ RB_GNUC_EXTENSION_BLOCK(__builtin_constant_p(id) && !DYNAMIC_ID_P(id) ? \
23
+ STATIC_ID2SYM(id) : rb_id2sym(id))
24
+ #endif
25
+
26
+ struct RSymbol {
27
+ struct RBasic basic;
28
+ st_index_t hashval;
29
+ VALUE fstr;
30
+ ID id;
31
+ };
32
+
33
+ #define RSYMBOL(obj) ((struct RSymbol *)(obj))
34
+
35
+ #define is_notop_id(id) ((id)>tLAST_OP_ID)
36
+ #define is_local_id(id) (id_type(id)==ID_LOCAL)
37
+ #define is_global_id(id) (id_type(id)==ID_GLOBAL)
38
+ #define is_instance_id(id) (id_type(id)==ID_INSTANCE)
39
+ #define is_attrset_id(id) ((id)==idASET||id_type(id)==ID_ATTRSET)
40
+ #define is_const_id(id) (id_type(id)==ID_CONST)
41
+ #define is_class_id(id) (id_type(id)==ID_CLASS)
42
+ #define is_junk_id(id) (id_type(id)==ID_JUNK)
43
+
44
+ static inline int
45
+ id_type(ID id)
46
+ {
47
+ if (is_notop_id(id)) {
48
+ return (int)(id&ID_SCOPE_MASK);
49
+ }
50
+ else {
51
+ return -1;
52
+ }
53
+ }
54
+
55
+ typedef uint32_t rb_id_serial_t;
56
+ static const uint32_t RB_ID_SERIAL_MAX = /* 256M on LP32 */
57
+ UINT32_MAX >>
58
+ ((sizeof(ID)-sizeof(rb_id_serial_t))*CHAR_BIT < RUBY_ID_SCOPE_SHIFT ?
59
+ RUBY_ID_SCOPE_SHIFT : 0);
60
+
61
+ typedef struct {
62
+ rb_id_serial_t last_id;
63
+ st_table *str_sym;
64
+ VALUE ids;
65
+ VALUE dsymbol_fstr_hash;
66
+ } rb_symbols_t;
67
+
68
+ static inline rb_id_serial_t
69
+ rb_id_to_serial(ID id)
70
+ {
71
+ if (is_notop_id(id)) {
72
+ return (rb_id_serial_t)(id >> ID_SCOPE_SHIFT);
73
+ }
74
+ else {
75
+ return (rb_id_serial_t)id;
76
+ }
77
+ }
78
+
79
+ static inline int
80
+ sym_type(VALUE sym)
81
+ {
82
+ ID id;
83
+ if (STATIC_SYM_P(sym)) {
84
+ id = RSHIFT(sym, RUBY_SPECIAL_SHIFT);
85
+ if (id<=tLAST_OP_ID) {
86
+ return -1;
87
+ }
88
+ }
89
+ else {
90
+ id = RSYMBOL(sym)->id;
91
+ }
92
+ return (int)(id&ID_SCOPE_MASK);
93
+ }
94
+
95
+ #define is_local_sym(sym) (sym_type(sym)==ID_LOCAL)
96
+ #define is_global_sym(sym) (sym_type(sym)==ID_GLOBAL)
97
+ #define is_instance_sym(sym) (sym_type(sym)==ID_INSTANCE)
98
+ #define is_attrset_sym(sym) (sym_type(sym)==ID_ATTRSET)
99
+ #define is_const_sym(sym) (sym_type(sym)==ID_CONST)
100
+ #define is_class_sym(sym) (sym_type(sym)==ID_CLASS)
101
+ #define is_junk_sym(sym) (sym_type(sym)==ID_JUNK)
102
+
103
+ RUBY_FUNC_EXPORTED const uint_least32_t ruby_global_name_punct_bits[(0x7e - 0x20 + 31) / 32];
104
+
105
+ static inline int
106
+ is_global_name_punct(const int c)
107
+ {
108
+ if (c <= 0x20 || 0x7e < c) return 0;
109
+ return (ruby_global_name_punct_bits[(c - 0x20) / 32] >> (c % 32)) & 1;
110
+ }
111
+
112
+ int rb_enc_symname_type(const char *name, long len, rb_encoding *enc, unsigned int allowed_attrset);
113
+
114
+ RUBY_SYMBOL_EXPORT_BEGIN
115
+
116
+ size_t rb_sym_immortal_count(void);
117
+
118
+ RUBY_SYMBOL_EXPORT_END
119
+ #endif
@@ -0,0 +1,20 @@
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
+
20
+ #endif /* RUBY_THREAD_NONE_H */
@@ -0,0 +1,126 @@
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
+ // per-Thead scheduler helper data
21
+ struct rb_thread_sched_item {
22
+ union {
23
+ struct ccan_list_node ubf;
24
+ struct ccan_list_node readyq; // protected by sched->lock
25
+ } node;
26
+ };
27
+
28
+ struct rb_native_thread {
29
+ rb_atomic_t serial;
30
+
31
+ rb_nativethread_id_t thread_id;
32
+
33
+ #ifdef RB_THREAD_T_HAS_NATIVE_ID
34
+ int tid;
35
+ #endif
36
+
37
+ struct rb_thread_struct *running_thread;
38
+
39
+ // to control native thread
40
+ #if defined(__GLIBC__) || defined(__FreeBSD__)
41
+ union
42
+ #else
43
+ /*
44
+ * assume the platform condvars are badly implemented and have a
45
+ * "memory" of which mutex they're associated with
46
+ */
47
+ struct
48
+ #endif
49
+ {
50
+ rb_nativethread_cond_t intr; /* th->interrupt_lock */
51
+ rb_nativethread_cond_t readyq; /* use sched->lock */
52
+ } cond;
53
+
54
+ #ifdef USE_SIGALTSTACK
55
+ void *altstack;
56
+ #endif
57
+ };
58
+
59
+ #undef except
60
+ #undef try
61
+ #undef leave
62
+ #undef finally
63
+
64
+ // per-Ractor
65
+ struct rb_thread_sched {
66
+ /* fast path */
67
+
68
+ const struct rb_thread_struct *running; // running thread or NULL
69
+ rb_nativethread_lock_t lock;
70
+
71
+ /*
72
+ * slow path, protected by ractor->thread_sched->lock
73
+ * - @readyq - FIFO queue of threads waiting for running
74
+ * - @timer - it handles timeslices for @current. It is any one thread
75
+ * in @waitq, there is no @timer if @waitq is empty, but always
76
+ * a @timer if @waitq has entries
77
+ * - @timer_err tracks timeslice limit, the timeslice only resets
78
+ * when pthread_cond_timedwait returns ETIMEDOUT, so frequent
79
+ * switching between contended/uncontended GVL won't reset the
80
+ * timer.
81
+ */
82
+ struct ccan_list_head readyq;
83
+ const struct rb_thread_struct *timer;
84
+ int timer_err;
85
+
86
+ /* yield */
87
+ rb_nativethread_cond_t switch_cond;
88
+ rb_nativethread_cond_t switch_wait_cond;
89
+ int need_yield;
90
+ int wait_yield;
91
+ };
92
+
93
+ #ifdef RB_THREAD_LOCAL_SPECIFIER
94
+ # ifdef __APPLE__
95
+ // on Darwin, TLS can not be accessed across .so
96
+ struct rb_execution_context_struct *rb_current_ec(void);
97
+ void rb_current_ec_set(struct rb_execution_context_struct *);
98
+ # else
99
+ RUBY_EXTERN RB_THREAD_LOCAL_SPECIFIER struct rb_execution_context_struct *ruby_current_ec;
100
+
101
+ // for RUBY_DEBUG_LOG()
102
+ RUBY_EXTERN RB_THREAD_LOCAL_SPECIFIER rb_atomic_t ruby_nt_serial;
103
+ #define RUBY_NT_SERIAL 1
104
+ # endif
105
+ #else
106
+ typedef pthread_key_t native_tls_key_t;
107
+
108
+ static inline void *
109
+ native_tls_get(native_tls_key_t key)
110
+ {
111
+ // return value should be checked by caller
112
+ return pthread_getspecific(key);
113
+ }
114
+
115
+ static inline void
116
+ native_tls_set(native_tls_key_t key, void *ptr)
117
+ {
118
+ if (UNLIKELY(pthread_setspecific(key, ptr) != 0)) {
119
+ rb_bug("pthread_setspecific error");
120
+ }
121
+ }
122
+
123
+ RUBY_EXTERN native_tls_key_t ruby_current_ec_key;
124
+ #endif
125
+
126
+ #endif /* RUBY_THREAD_PTHREAD_H */
@@ -0,0 +1,58 @@
1
+ #ifndef RUBY_THREAD_WIN32_H
2
+ #define RUBY_THREAD_WIN32_H
3
+ /**********************************************************************
4
+
5
+ thread_win32.h -
6
+
7
+ $Author$
8
+
9
+ Copyright (C) 2004-2007 Koichi Sasada
10
+
11
+ **********************************************************************/
12
+
13
+ /* interface */
14
+
15
+ # ifdef __CYGWIN__
16
+ # undef _WIN32
17
+ # endif
18
+
19
+ #define USE_VM_CLOCK 1
20
+
21
+ WINBASEAPI BOOL WINAPI
22
+ TryEnterCriticalSection(IN OUT LPCRITICAL_SECTION lpCriticalSection);
23
+
24
+ struct rb_native_thread {
25
+ HANDLE thread_id;
26
+ HANDLE interrupt_event;
27
+ };
28
+
29
+ struct rb_thread_sched_item {
30
+ char dmy;
31
+ };
32
+
33
+ struct rb_thread_sched {
34
+ HANDLE lock;
35
+ };
36
+
37
+ typedef DWORD native_tls_key_t; // TLS index
38
+
39
+ static inline void *
40
+ native_tls_get(native_tls_key_t key)
41
+ {
42
+ // return value should be checked by caller.
43
+ return TlsGetValue(key);
44
+ }
45
+
46
+ static inline void
47
+ native_tls_set(native_tls_key_t key, void *ptr)
48
+ {
49
+ if (UNLIKELY(TlsSetValue(key, ptr) == 0)) {
50
+ rb_bug("TlsSetValue() error");
51
+ }
52
+ }
53
+
54
+ RUBY_SYMBOL_EXPORT_BEGIN
55
+ RUBY_EXTERN native_tls_key_t ruby_current_ec_key;
56
+ RUBY_SYMBOL_EXPORT_END
57
+
58
+ #endif /* RUBY_THREAD_WIN32_H */
@@ -0,0 +1,58 @@
1
+ #ifndef RUBY_TIMEV_H
2
+ #define RUBY_TIMEV_H
3
+ #include "ruby/ruby.h"
4
+
5
+ struct vtm {
6
+ VALUE year; /* 2000 for example. Integer. */
7
+ VALUE subsecx; /* 0 <= subsecx < TIME_SCALE. possibly Rational. */
8
+ VALUE utc_offset; /* -3600 as -01:00 for example. possibly Rational. */
9
+ VALUE zone; /* "JST", "EST", "EDT", etc. as String */
10
+ unsigned int yday:9; /* 1..366 */
11
+ unsigned int mon:4; /* 1..12 */
12
+ unsigned int mday:5; /* 1..31 */
13
+ unsigned int hour:5; /* 0..23 */
14
+ unsigned int min:6; /* 0..59 */
15
+ unsigned int sec:6; /* 0..60 */
16
+ unsigned int wday:3; /* 0:Sunday, 1:Monday, ..., 6:Saturday 7:init */
17
+ unsigned int isdst:2; /* 0:StandardTime 1:DayLightSavingTime 3:init */
18
+
19
+ /* Flags for struct time_object */
20
+ unsigned int tzmode:3; /* 0:localtime 1:utc 2:fixoff 3:uninitialized */
21
+ unsigned int tm_got:1;
22
+ };
23
+
24
+ #define TIME_SCALE 1000000000
25
+
26
+ #ifndef TYPEOF_TIMEVAL_TV_SEC
27
+ # define TYPEOF_TIMEVAL_TV_SEC time_t
28
+ #endif
29
+ #ifndef TYPEOF_TIMEVAL_TV_USEC
30
+ # if INT_MAX >= 1000000
31
+ # define TYPEOF_TIMEVAL_TV_USEC int
32
+ # else
33
+ # define TYPEOF_TIMEVAL_TV_USEC long
34
+ # endif
35
+ #endif
36
+
37
+ #if SIZEOF_TIME_T == SIZEOF_LONG
38
+ typedef unsigned long unsigned_time_t;
39
+ #elif SIZEOF_TIME_T == SIZEOF_INT
40
+ typedef unsigned int unsigned_time_t;
41
+ #elif SIZEOF_TIME_T == SIZEOF_LONG_LONG
42
+ typedef unsigned LONG_LONG unsigned_time_t;
43
+ #else
44
+ # error cannot find integer type which size is same as time_t.
45
+ #endif
46
+
47
+ /* strftime.c */
48
+ #ifdef RUBY_ENCODING_H
49
+ VALUE rb_strftime_timespec(const char *format, size_t format_len, rb_encoding *enc,
50
+ VALUE time, const struct vtm *vtm, struct timespec *ts, int gmt);
51
+ VALUE rb_strftime(const char *format, size_t format_len, rb_encoding *enc,
52
+ VALUE time, const struct vtm *vtm, VALUE timev, int gmt);
53
+ #endif
54
+
55
+ /* time.c */
56
+ VALUE rb_time_zone_abbreviation(VALUE zone, VALUE time);
57
+
58
+ #endif