datadog-ruby_core_source 3.5.4 → 3.5.5

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.
Files changed (122) hide show
  1. checksums.yaml +4 -4
  2. data/datadog-ruby_core_source.gemspec +1 -1
  3. data/lib/datadog/ruby_core_source/ruby-2.6.0-p0/ccan/build_assert/build_assert.h +40 -0
  4. data/lib/datadog/ruby_core_source/ruby-2.6.0-p0/ccan/check_type/check_type.h +63 -0
  5. data/lib/datadog/ruby_core_source/ruby-2.6.0-p0/ccan/container_of/container_of.h +142 -0
  6. data/lib/datadog/ruby_core_source/ruby-2.6.0-p0/ccan/list/list.h +788 -0
  7. data/lib/datadog/ruby_core_source/ruby-2.6.0-p0/ccan/str/str.h +16 -0
  8. data/lib/datadog/ruby_core_source/ruby-2.6.0-p0/id.h +252 -0
  9. data/lib/datadog/ruby_core_source/ruby-2.6.0-p0/internal.h +2465 -0
  10. data/lib/datadog/ruby_core_source/ruby-2.6.0-p0/iseq.h +304 -0
  11. data/lib/datadog/ruby_core_source/ruby-2.6.0-p0/method.h +229 -0
  12. data/lib/datadog/ruby_core_source/ruby-2.6.0-p0/node.h +449 -0
  13. data/lib/datadog/ruby_core_source/ruby-2.6.0-p0/ruby_assert.h +60 -0
  14. data/lib/datadog/ruby_core_source/ruby-2.6.0-p0/ruby_atomic.h +244 -0
  15. data/lib/datadog/ruby_core_source/ruby-2.6.0-p0/thread_pthread.h +75 -0
  16. data/lib/datadog/ruby_core_source/ruby-2.6.0-p0/thread_win32.h +36 -0
  17. data/lib/datadog/ruby_core_source/ruby-2.6.0-p0/vm_core.h +1902 -0
  18. data/lib/datadog/ruby_core_source/ruby-2.6.0-p0/vm_opts.h +70 -0
  19. data/lib/datadog/ruby_core_source/ruby-2.7.0-p0/ccan/build_assert/build_assert.h +40 -0
  20. data/lib/datadog/ruby_core_source/ruby-2.7.0-p0/ccan/check_type/check_type.h +63 -0
  21. data/lib/datadog/ruby_core_source/ruby-2.7.0-p0/ccan/container_of/container_of.h +142 -0
  22. data/lib/datadog/ruby_core_source/ruby-2.7.0-p0/ccan/list/list.h +788 -0
  23. data/lib/datadog/ruby_core_source/ruby-2.7.0-p0/ccan/str/str.h +16 -0
  24. data/lib/datadog/ruby_core_source/ruby-2.7.0-p0/id.h +290 -0
  25. data/lib/datadog/ruby_core_source/ruby-2.7.0-p0/internal.h +2697 -0
  26. data/lib/datadog/ruby_core_source/ruby-2.7.0-p0/iseq.h +312 -0
  27. data/lib/datadog/ruby_core_source/ruby-2.7.0-p0/method.h +229 -0
  28. data/lib/datadog/ruby_core_source/ruby-2.7.0-p0/node.h +476 -0
  29. data/lib/datadog/ruby_core_source/ruby-2.7.0-p0/ruby_assert.h +15 -0
  30. data/lib/datadog/ruby_core_source/ruby-2.7.0-p0/ruby_atomic.h +244 -0
  31. data/lib/datadog/ruby_core_source/ruby-2.7.0-p0/thread_pthread.h +75 -0
  32. data/lib/datadog/ruby_core_source/ruby-2.7.0-p0/thread_win32.h +36 -0
  33. data/lib/datadog/ruby_core_source/ruby-2.7.0-p0/vm_core.h +1968 -0
  34. data/lib/datadog/ruby_core_source/ruby-2.7.0-p0/vm_opts.h +72 -0
  35. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/ccan/build_assert/build_assert.h +40 -0
  36. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/ccan/check_type/check_type.h +63 -0
  37. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/ccan/container_of/container_of.h +142 -0
  38. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/ccan/list/list.h +788 -0
  39. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/ccan/str/str.h +16 -0
  40. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/id.h +290 -0
  41. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/id_table.h +36 -0
  42. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/internal/array.h +119 -0
  43. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/internal/class.h +174 -0
  44. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/internal/compilers.h +108 -0
  45. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/internal/gc.h +161 -0
  46. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/internal/imemo.h +243 -0
  47. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/internal/serial.h +24 -0
  48. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/internal/static_assert.h +17 -0
  49. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/internal/vm.h +136 -0
  50. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/internal/warnings.h +17 -0
  51. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/internal.h +107 -0
  52. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/iseq.h +305 -0
  53. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/method.h +245 -0
  54. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/node.h +484 -0
  55. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/ractor_core.h +343 -0
  56. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/ruby_assert.h +15 -0
  57. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/ruby_atomic.h +23 -0
  58. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/thread_pthread.h +115 -0
  59. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/thread_win32.h +61 -0
  60. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/vm_core.h +2023 -0
  61. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/vm_debug.h +116 -0
  62. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/vm_opts.h +73 -0
  63. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/ccan/build_assert/build_assert.h +40 -0
  64. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/ccan/check_type/check_type.h +63 -0
  65. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/ccan/container_of/container_of.h +142 -0
  66. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/ccan/list/list.h +788 -0
  67. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/ccan/str/str.h +16 -0
  68. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/darray.h +198 -0
  69. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/id.h +293 -0
  70. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/id_table.h +36 -0
  71. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/internal/array.h +113 -0
  72. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/internal/class.h +196 -0
  73. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/internal/compilers.h +107 -0
  74. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/internal/gc.h +186 -0
  75. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/internal/imemo.h +243 -0
  76. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/internal/serial.h +23 -0
  77. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/internal/static_assert.h +16 -0
  78. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/internal/vm.h +133 -0
  79. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/internal/warnings.h +16 -0
  80. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/internal.h +109 -0
  81. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/iseq.h +322 -0
  82. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/method.h +253 -0
  83. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/node.h +510 -0
  84. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/ractor_core.h +346 -0
  85. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/ruby_assert.h +14 -0
  86. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/ruby_atomic.h +23 -0
  87. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/thread_pthread.h +115 -0
  88. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/vm_core.h +2107 -0
  89. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/vm_debug.h +124 -0
  90. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/vm_opts.h +73 -0
  91. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/ccan/build_assert/build_assert.h +40 -0
  92. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/ccan/check_type/check_type.h +63 -0
  93. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/ccan/container_of/container_of.h +142 -0
  94. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/ccan/list/list.h +789 -0
  95. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/ccan/str/str.h +17 -0
  96. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/id.h +299 -0
  97. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/id_table.h +39 -0
  98. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/internal/array.h +163 -0
  99. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/internal/basic_operators.h +64 -0
  100. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/internal/class.h +182 -0
  101. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/internal/compilers.h +107 -0
  102. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/internal/gc.h +192 -0
  103. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/internal/imemo.h +242 -0
  104. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/internal/serial.h +23 -0
  105. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/internal/static_assert.h +16 -0
  106. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/internal/vm.h +134 -0
  107. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/internal/warnings.h +16 -0
  108. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/internal.h +113 -0
  109. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/iseq.h +329 -0
  110. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/method.h +254 -0
  111. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/node.h +514 -0
  112. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/ractor_core.h +342 -0
  113. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/ruby_assert.h +14 -0
  114. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/ruby_atomic.h +23 -0
  115. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/shape.h +232 -0
  116. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/thread_none.h +20 -0
  117. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/thread_pthread.h +133 -0
  118. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/vm_core.h +2106 -0
  119. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/vm_debug.h +122 -0
  120. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/vm_opts.h +73 -0
  121. data/lib/datadog/ruby_core_source/version.rb +1 -1
  122. metadata +122 -4
@@ -0,0 +1,16 @@
1
+ /* CC0 (Public domain) - see ccan/licenses/CC0 file for details */
2
+ #ifndef CCAN_STR_H
3
+ #define CCAN_STR_H
4
+ /**
5
+ * stringify - Turn expression into a string literal
6
+ * @expr: any C expression
7
+ *
8
+ * Example:
9
+ * #define PRINT_COND_IF_FALSE(cond) \
10
+ * ((cond) || printf("%s is false!", stringify(cond)))
11
+ */
12
+ #define stringify(expr) stringify_1(expr)
13
+ /* Double-indirection required to stringify expansions */
14
+ #define stringify_1(expr) #expr
15
+
16
+ #endif /* CCAN_STR_H */
@@ -0,0 +1,198 @@
1
+ #ifndef RUBY_DARRAY_H
2
+ #define RUBY_DARRAY_H
3
+
4
+ #include <stdint.h>
5
+ #include <stddef.h>
6
+ #include <stdlib.h>
7
+
8
+ // Type for a dynamic array. Use to declare a dynamic array.
9
+ // It is a pointer so it fits in st_table nicely. Designed
10
+ // to be fairly type-safe.
11
+ //
12
+ // NULL is a valid empty dynamic array.
13
+ //
14
+ // Example:
15
+ // rb_darray(char) char_array = NULL;
16
+ // if (!rb_darray_append(&char_array, 'e')) abort();
17
+ // printf("pushed %c\n", *rb_darray_ref(char_array, 0));
18
+ // rb_darray_free(char_array);
19
+ //
20
+ #define rb_darray(T) struct { rb_darray_meta_t meta; T data[]; } *
21
+
22
+ // Copy an element out of the array. Warning: not bounds checked.
23
+ //
24
+ // T rb_darray_get(rb_darray(T) ary, int32_t idx);
25
+ //
26
+ #define rb_darray_get(ary, idx) ((ary)->data[(idx)])
27
+
28
+ // Assign to an element. Warning: not bounds checked.
29
+ //
30
+ // void rb_darray_set(rb_darray(T) ary, int32_t idx, T element);
31
+ //
32
+ #define rb_darray_set(ary, idx, element) ((ary)->data[(idx)] = (element))
33
+
34
+ // Get a pointer to an element. Warning: not bounds checked.
35
+ //
36
+ // T *rb_darray_ref(rb_darray(T) ary, int32_t idx);
37
+ //
38
+ #define rb_darray_ref(ary, idx) (&((ary)->data[(idx)]))
39
+
40
+ // Copy a new element into the array. Return 1 on success and 0 on failure.
41
+ // ptr_to_ary is evaluated multiple times.
42
+ //
43
+ // bool rb_darray_append(rb_darray(T) *ptr_to_ary, T element);
44
+ //
45
+ #define rb_darray_append(ptr_to_ary, element) ( \
46
+ rb_darray_ensure_space((ptr_to_ary), sizeof(**(ptr_to_ary)), sizeof((*(ptr_to_ary))->data[0])) ? ( \
47
+ rb_darray_set(*(ptr_to_ary), \
48
+ (*(ptr_to_ary))->meta.size, \
49
+ (element)), \
50
+ ++((*(ptr_to_ary))->meta.size), \
51
+ 1 \
52
+ ) : 0)
53
+
54
+ // Last element of the array
55
+ //
56
+ #define rb_darray_back(ary) ((ary)->data[(ary)->meta.size - 1])
57
+
58
+ // Remove the last element of the array.
59
+ //
60
+ #define rb_darray_pop_back(ary) ((ary)->meta.size--)
61
+
62
+ // Remove element at idx and replace it by the last element
63
+ #define rb_darray_remove_unordered(ary, idx) do { \
64
+ rb_darray_set(ary, idx, rb_darray_back(ary)); \
65
+ rb_darray_pop_back(ary); \
66
+ } while (0);
67
+
68
+ // Iterate over items of the array in a for loop
69
+ //
70
+ #define rb_darray_foreach(ary, idx_name, elem_ptr_var) \
71
+ for (int idx_name = 0; idx_name < rb_darray_size(ary) && ((elem_ptr_var) = rb_darray_ref(ary, idx_name)); ++idx_name)
72
+
73
+ // Iterate over valid indicies in the array in a for loop
74
+ //
75
+ #define rb_darray_for(ary, idx_name) \
76
+ for (int idx_name = 0; idx_name < rb_darray_size(ary); ++idx_name)
77
+
78
+ // Make a dynamic array of a certain size. All bytes backing the elements are set to zero.
79
+ // Return 1 on success and 0 on failure.
80
+ //
81
+ // Note that NULL is a valid empty dynamic array.
82
+ //
83
+ // bool rb_darray_make(rb_darray(T) *ptr_to_ary, int32_t size);
84
+ //
85
+ #define rb_darray_make(ptr_to_ary, size) rb_darray_make_impl((ptr_to_ary), size, sizeof(**(ptr_to_ary)), sizeof((*(ptr_to_ary))->data[0]))
86
+
87
+ // Set the size of the array to zero without freeing the backing memory.
88
+ // Allows reusing the same array.
89
+ //
90
+ #define rb_darray_clear(ary) (ary->meta.size = 0)
91
+
92
+ typedef struct rb_darray_meta {
93
+ int32_t size;
94
+ int32_t capa;
95
+ } rb_darray_meta_t;
96
+
97
+ // Get the size of the dynamic array.
98
+ //
99
+ static inline int32_t
100
+ rb_darray_size(const void *ary)
101
+ {
102
+ const rb_darray_meta_t *meta = ary;
103
+ return meta ? meta->size : 0;
104
+ }
105
+
106
+ // Get the capacity of the dynamic array.
107
+ //
108
+ static inline int32_t
109
+ rb_darray_capa(const void *ary)
110
+ {
111
+ const rb_darray_meta_t *meta = ary;
112
+ return meta ? meta->capa : 0;
113
+ }
114
+
115
+ // Free the dynamic array.
116
+ //
117
+ static inline void
118
+ rb_darray_free(void *ary)
119
+ {
120
+ free(ary);
121
+ }
122
+
123
+ // Internal function. Calculate buffer size on malloc heap.
124
+ static inline size_t
125
+ rb_darray_buffer_size(int32_t capacity, size_t header_size, size_t element_size)
126
+ {
127
+ if (capacity == 0) return 0;
128
+ return header_size + (size_t)capacity * element_size;
129
+ }
130
+
131
+ // Internal function
132
+ // Ensure there is space for one more element. Return 1 on success and 0 on failure.
133
+ // Note: header_size can be bigger than sizeof(rb_darray_meta_t) when T is __int128_t, for example.
134
+ static inline int
135
+ rb_darray_ensure_space(void *ptr_to_ary, size_t header_size, size_t element_size)
136
+ {
137
+ rb_darray_meta_t **ptr_to_ptr_to_meta = ptr_to_ary;
138
+ rb_darray_meta_t *meta = *ptr_to_ptr_to_meta;
139
+ int32_t current_capa = rb_darray_capa(meta);
140
+ if (rb_darray_size(meta) < current_capa) return 1;
141
+
142
+ int32_t new_capa;
143
+ // Calculate new capacity
144
+ if (current_capa == 0) {
145
+ new_capa = 1;
146
+ }
147
+ else {
148
+ int64_t doubled = 2 * (int64_t)current_capa;
149
+ new_capa = (int32_t)doubled;
150
+ if (new_capa != doubled) return 0;
151
+ }
152
+
153
+ // Calculate new buffer size
154
+ size_t current_buffer_size = rb_darray_buffer_size(current_capa, header_size, element_size);
155
+ size_t new_buffer_size = rb_darray_buffer_size(new_capa, header_size, element_size);
156
+ if (new_buffer_size <= current_buffer_size) return 0;
157
+
158
+ rb_darray_meta_t *doubled_ary = realloc(meta, new_buffer_size);
159
+ if (!doubled_ary) return 0;
160
+
161
+ if (meta == NULL) {
162
+ // First allocation. Initialize size. On subsequence allocations
163
+ // realloc takes care of carrying over the size.
164
+ doubled_ary->size = 0;
165
+ }
166
+
167
+ doubled_ary->capa = new_capa;
168
+
169
+ // We don't have access to the type of the dynamic array in function context.
170
+ // Write out result with memcpy to avoid strict aliasing issue.
171
+ memcpy(ptr_to_ary, &doubled_ary, sizeof(doubled_ary));
172
+ return 1;
173
+ }
174
+
175
+ static inline int
176
+ rb_darray_make_impl(void *ptr_to_ary, int32_t array_size, size_t header_size, size_t element_size)
177
+ {
178
+ rb_darray_meta_t **ptr_to_ptr_to_meta = ptr_to_ary;
179
+ if (array_size < 0) return 0;
180
+ if (array_size == 0) {
181
+ *ptr_to_ptr_to_meta = NULL;
182
+ return 1;
183
+ }
184
+
185
+ size_t buffer_size = rb_darray_buffer_size(array_size, header_size, element_size);
186
+ rb_darray_meta_t *meta = calloc(buffer_size, 1);
187
+ if (!meta) return 0;
188
+
189
+ meta->size = array_size;
190
+ meta->capa = array_size;
191
+
192
+ // We don't have access to the type of the dynamic array in function context.
193
+ // Write out result with memcpy to avoid strict aliasing issue.
194
+ memcpy(ptr_to_ary, &meta, sizeof(meta));
195
+ return 1;
196
+ }
197
+
198
+ #endif /* RUBY_DARRAY_H */
@@ -0,0 +1,293 @@
1
+ /* DO NOT EDIT THIS FILE DIRECTLY */
2
+ /**********************************************************************
3
+
4
+ id.h -
5
+
6
+ $Author$
7
+ created at: Sun Oct 19 21:12:51 2008
8
+
9
+ Copyright (C) 2007 Koichi Sasada
10
+
11
+ **********************************************************************/
12
+
13
+ #ifndef RUBY_ID_H
14
+ #define RUBY_ID_H
15
+
16
+ enum ruby_id_types {
17
+ RUBY_ID_STATIC_SYM = 0x01,
18
+ RUBY_ID_LOCAL = 0x00,
19
+ RUBY_ID_INSTANCE = (0x01<<1),
20
+ RUBY_ID_GLOBAL = (0x03<<1),
21
+ RUBY_ID_ATTRSET = (0x04<<1),
22
+ RUBY_ID_CONST = (0x05<<1),
23
+ RUBY_ID_CLASS = (0x06<<1),
24
+ RUBY_ID_JUNK = (0x07<<1),
25
+ RUBY_ID_INTERNAL = RUBY_ID_JUNK,
26
+ RUBY_ID_SCOPE_SHIFT = 4,
27
+ RUBY_ID_SCOPE_MASK = (~(~0U<<(RUBY_ID_SCOPE_SHIFT-1))<<1)
28
+ };
29
+
30
+ #define ID_STATIC_SYM RUBY_ID_STATIC_SYM
31
+ #define ID_SCOPE_SHIFT RUBY_ID_SCOPE_SHIFT
32
+ #define ID_SCOPE_MASK RUBY_ID_SCOPE_MASK
33
+ #define ID_LOCAL RUBY_ID_LOCAL
34
+ #define ID_INSTANCE RUBY_ID_INSTANCE
35
+ #define ID_GLOBAL RUBY_ID_GLOBAL
36
+ #define ID_ATTRSET RUBY_ID_ATTRSET
37
+ #define ID_CONST RUBY_ID_CONST
38
+ #define ID_CLASS RUBY_ID_CLASS
39
+ #define ID_JUNK RUBY_ID_JUNK
40
+ #define ID_INTERNAL RUBY_ID_INTERNAL
41
+
42
+ #define symIFUNC ID2SYM(idIFUNC)
43
+ #define symCFUNC ID2SYM(idCFUNC)
44
+
45
+ #define RUBY_TOKEN_DOT2 128
46
+ #define RUBY_TOKEN_DOT3 129
47
+ #define RUBY_TOKEN_BDOT2 130
48
+ #define RUBY_TOKEN_BDOT3 131
49
+ #define RUBY_TOKEN_UPLUS 132
50
+ #define RUBY_TOKEN_UMINUS 133
51
+ #define RUBY_TOKEN_POW 134
52
+ #define RUBY_TOKEN_CMP 135
53
+ #define RUBY_TOKEN_LSHFT 136
54
+ #define RUBY_TOKEN_RSHFT 137
55
+ #define RUBY_TOKEN_LEQ 138
56
+ #define RUBY_TOKEN_GEQ 139
57
+ #define RUBY_TOKEN_EQ 140
58
+ #define RUBY_TOKEN_EQQ 141
59
+ #define RUBY_TOKEN_NEQ 142
60
+ #define RUBY_TOKEN_MATCH 143
61
+ #define RUBY_TOKEN_NMATCH 144
62
+ #define RUBY_TOKEN_AREF 145
63
+ #define RUBY_TOKEN_ASET 146
64
+ #define RUBY_TOKEN_COLON2 147
65
+ #define RUBY_TOKEN_ANDOP 148
66
+ #define RUBY_TOKEN_OROP 149
67
+ #define RUBY_TOKEN_ANDDOT 150
68
+ #define RUBY_TOKEN(t) RUBY_TOKEN_##t
69
+
70
+ #define RUBY_TOKEN2ID_TYPE(tok, type) ((tok<<RUBY_ID_SCOPE_SHIFT)|type|RUBY_ID_STATIC_SYM)
71
+ #define TOKEN2LOCALID(tok) RUBY_TOKEN2ID_TYPE(tok, RUBY_ID_LOCAL)
72
+ #define TOKEN2INSTANCEID(tok) RUBY_TOKEN2ID_TYPE(tok, RUBY_ID_INSTANCE)
73
+ #define TOKEN2GLOBALID(tok) RUBY_TOKEN2ID_TYPE(tok, RUBY_ID_GLOBAL)
74
+ #define TOKEN2CONSTID(tok) RUBY_TOKEN2ID_TYPE(tok, RUBY_ID_CONST)
75
+ #define TOKEN2CLASSID(tok) RUBY_TOKEN2ID_TYPE(tok, RUBY_ID_CLASS)
76
+ #define TOKEN2ATTRSETID(tok) RUBY_TOKEN2ID_TYPE(tok, RUBY_ID_ATTRSET)
77
+
78
+ enum ruby_method_ids {
79
+ idDot2 = RUBY_TOKEN(DOT2),
80
+ idDot3 = RUBY_TOKEN(DOT3),
81
+ idUPlus = RUBY_TOKEN(UPLUS),
82
+ idUMinus = RUBY_TOKEN(UMINUS),
83
+ idPow = RUBY_TOKEN(POW),
84
+ idCmp = RUBY_TOKEN(CMP),
85
+ idPLUS = '+',
86
+ idMINUS = '-',
87
+ idMULT = '*',
88
+ idDIV = '/',
89
+ idMOD = '%',
90
+ idLTLT = RUBY_TOKEN(LSHFT),
91
+ idGTGT = RUBY_TOKEN(RSHFT),
92
+ idLT = '<',
93
+ idLE = RUBY_TOKEN(LEQ),
94
+ idGT = '>',
95
+ idGE = RUBY_TOKEN(GEQ),
96
+ idEq = RUBY_TOKEN(EQ),
97
+ idEqq = RUBY_TOKEN(EQQ),
98
+ idNeq = RUBY_TOKEN(NEQ),
99
+ idNot = '!',
100
+ idAnd = '&',
101
+ idOr = '|',
102
+ idBackquote = '`',
103
+ idEqTilde = RUBY_TOKEN(MATCH),
104
+ idNeqTilde = RUBY_TOKEN(NMATCH),
105
+ idAREF = RUBY_TOKEN(AREF),
106
+ idASET = RUBY_TOKEN(ASET),
107
+ idCOLON2 = RUBY_TOKEN(COLON2),
108
+ idANDOP = RUBY_TOKEN(ANDOP),
109
+ idOROP = RUBY_TOKEN(OROP),
110
+ idANDDOT = RUBY_TOKEN(ANDDOT),
111
+ tPRESERVED_ID_BEGIN = 150,
112
+ idNilP,
113
+ idNULL,
114
+ idEmptyP,
115
+ idEqlP,
116
+ idRespond_to,
117
+ idRespond_to_missing,
118
+ idIFUNC,
119
+ idCFUNC,
120
+ id_core_set_method_alias,
121
+ id_core_set_variable_alias,
122
+ id_core_undef_method,
123
+ id_core_define_method,
124
+ id_core_define_singleton_method,
125
+ id_core_set_postexe,
126
+ id_core_hash_merge_ptr,
127
+ id_core_hash_merge_kwd,
128
+ id_core_raise,
129
+ id_core_sprintf,
130
+ id_debug_created_info,
131
+ tPRESERVED_ID_END,
132
+ tTOKEN_LOCAL_BEGIN = tPRESERVED_ID_END-1,
133
+ tMax,
134
+ tMin,
135
+ tFreeze,
136
+ tInspect,
137
+ tIntern,
138
+ tObject_id,
139
+ tConst_missing,
140
+ tMethodMissing,
141
+ tMethod_added,
142
+ tSingleton_method_added,
143
+ tMethod_removed,
144
+ tSingleton_method_removed,
145
+ tMethod_undefined,
146
+ tSingleton_method_undefined,
147
+ tLength,
148
+ tSize,
149
+ tGets,
150
+ tSucc,
151
+ tEach,
152
+ tProc,
153
+ tLambda,
154
+ tSend,
155
+ t__send__,
156
+ t__attached__,
157
+ t__recursive_key__,
158
+ tInitialize,
159
+ tInitialize_copy,
160
+ tInitialize_clone,
161
+ tInitialize_dup,
162
+ tTo_int,
163
+ tTo_ary,
164
+ tTo_str,
165
+ tTo_sym,
166
+ tTo_hash,
167
+ tTo_proc,
168
+ tTo_io,
169
+ tTo_a,
170
+ tTo_s,
171
+ tTo_i,
172
+ tTo_f,
173
+ tTo_r,
174
+ tBt,
175
+ tBt_locations,
176
+ tCall,
177
+ tMesg,
178
+ tException,
179
+ tLocals,
180
+ tNOT,
181
+ tAND,
182
+ tOR,
183
+ tDiv,
184
+ tDivmod,
185
+ tFdiv,
186
+ tQuo,
187
+ tName,
188
+ tNil,
189
+ tUScore,
190
+ tNUMPARAM_1,
191
+ tNUMPARAM_2,
192
+ tNUMPARAM_3,
193
+ tNUMPARAM_4,
194
+ tNUMPARAM_5,
195
+ tNUMPARAM_6,
196
+ tNUMPARAM_7,
197
+ tNUMPARAM_8,
198
+ tNUMPARAM_9,
199
+ tTOKEN_LOCAL_END,
200
+ tTOKEN_INSTANCE_BEGIN = tTOKEN_LOCAL_END-1,
201
+ tTOKEN_INSTANCE_END,
202
+ tTOKEN_GLOBAL_BEGIN = tTOKEN_INSTANCE_END-1,
203
+ tLASTLINE,
204
+ tBACKREF,
205
+ tERROR_INFO,
206
+ tTOKEN_GLOBAL_END,
207
+ tTOKEN_CONST_BEGIN = tTOKEN_GLOBAL_END-1,
208
+ tTOKEN_CONST_END,
209
+ tTOKEN_CLASS_BEGIN = tTOKEN_CONST_END-1,
210
+ tTOKEN_CLASS_END,
211
+ tTOKEN_ATTRSET_BEGIN = tTOKEN_CLASS_END-1,
212
+ tTOKEN_ATTRSET_END,
213
+ tNEXT_ID = tTOKEN_ATTRSET_END,
214
+ #define DEFINE_LOCALID_FROM_TOKEN(n) id##n = TOKEN2LOCALID(t##n)
215
+ DEFINE_LOCALID_FROM_TOKEN(Max),
216
+ DEFINE_LOCALID_FROM_TOKEN(Min),
217
+ DEFINE_LOCALID_FROM_TOKEN(Freeze),
218
+ DEFINE_LOCALID_FROM_TOKEN(Inspect),
219
+ DEFINE_LOCALID_FROM_TOKEN(Intern),
220
+ DEFINE_LOCALID_FROM_TOKEN(Object_id),
221
+ DEFINE_LOCALID_FROM_TOKEN(Const_missing),
222
+ DEFINE_LOCALID_FROM_TOKEN(MethodMissing),
223
+ DEFINE_LOCALID_FROM_TOKEN(Method_added),
224
+ DEFINE_LOCALID_FROM_TOKEN(Singleton_method_added),
225
+ DEFINE_LOCALID_FROM_TOKEN(Method_removed),
226
+ DEFINE_LOCALID_FROM_TOKEN(Singleton_method_removed),
227
+ DEFINE_LOCALID_FROM_TOKEN(Method_undefined),
228
+ DEFINE_LOCALID_FROM_TOKEN(Singleton_method_undefined),
229
+ DEFINE_LOCALID_FROM_TOKEN(Length),
230
+ DEFINE_LOCALID_FROM_TOKEN(Size),
231
+ DEFINE_LOCALID_FROM_TOKEN(Gets),
232
+ DEFINE_LOCALID_FROM_TOKEN(Succ),
233
+ DEFINE_LOCALID_FROM_TOKEN(Each),
234
+ DEFINE_LOCALID_FROM_TOKEN(Proc),
235
+ DEFINE_LOCALID_FROM_TOKEN(Lambda),
236
+ DEFINE_LOCALID_FROM_TOKEN(Send),
237
+ DEFINE_LOCALID_FROM_TOKEN(__send__),
238
+ DEFINE_LOCALID_FROM_TOKEN(__attached__),
239
+ DEFINE_LOCALID_FROM_TOKEN(__recursive_key__),
240
+ DEFINE_LOCALID_FROM_TOKEN(Initialize),
241
+ DEFINE_LOCALID_FROM_TOKEN(Initialize_copy),
242
+ DEFINE_LOCALID_FROM_TOKEN(Initialize_clone),
243
+ DEFINE_LOCALID_FROM_TOKEN(Initialize_dup),
244
+ DEFINE_LOCALID_FROM_TOKEN(To_int),
245
+ DEFINE_LOCALID_FROM_TOKEN(To_ary),
246
+ DEFINE_LOCALID_FROM_TOKEN(To_str),
247
+ DEFINE_LOCALID_FROM_TOKEN(To_sym),
248
+ DEFINE_LOCALID_FROM_TOKEN(To_hash),
249
+ DEFINE_LOCALID_FROM_TOKEN(To_proc),
250
+ DEFINE_LOCALID_FROM_TOKEN(To_io),
251
+ DEFINE_LOCALID_FROM_TOKEN(To_a),
252
+ DEFINE_LOCALID_FROM_TOKEN(To_s),
253
+ DEFINE_LOCALID_FROM_TOKEN(To_i),
254
+ DEFINE_LOCALID_FROM_TOKEN(To_f),
255
+ DEFINE_LOCALID_FROM_TOKEN(To_r),
256
+ DEFINE_LOCALID_FROM_TOKEN(Bt),
257
+ DEFINE_LOCALID_FROM_TOKEN(Bt_locations),
258
+ DEFINE_LOCALID_FROM_TOKEN(Call),
259
+ DEFINE_LOCALID_FROM_TOKEN(Mesg),
260
+ DEFINE_LOCALID_FROM_TOKEN(Exception),
261
+ DEFINE_LOCALID_FROM_TOKEN(Locals),
262
+ DEFINE_LOCALID_FROM_TOKEN(NOT),
263
+ DEFINE_LOCALID_FROM_TOKEN(AND),
264
+ DEFINE_LOCALID_FROM_TOKEN(OR),
265
+ DEFINE_LOCALID_FROM_TOKEN(Div),
266
+ DEFINE_LOCALID_FROM_TOKEN(Divmod),
267
+ DEFINE_LOCALID_FROM_TOKEN(Fdiv),
268
+ DEFINE_LOCALID_FROM_TOKEN(Quo),
269
+ DEFINE_LOCALID_FROM_TOKEN(Name),
270
+ DEFINE_LOCALID_FROM_TOKEN(Nil),
271
+ DEFINE_LOCALID_FROM_TOKEN(UScore),
272
+ DEFINE_LOCALID_FROM_TOKEN(NUMPARAM_1),
273
+ DEFINE_LOCALID_FROM_TOKEN(NUMPARAM_2),
274
+ DEFINE_LOCALID_FROM_TOKEN(NUMPARAM_3),
275
+ DEFINE_LOCALID_FROM_TOKEN(NUMPARAM_4),
276
+ DEFINE_LOCALID_FROM_TOKEN(NUMPARAM_5),
277
+ DEFINE_LOCALID_FROM_TOKEN(NUMPARAM_6),
278
+ DEFINE_LOCALID_FROM_TOKEN(NUMPARAM_7),
279
+ DEFINE_LOCALID_FROM_TOKEN(NUMPARAM_8),
280
+ DEFINE_LOCALID_FROM_TOKEN(NUMPARAM_9),
281
+ #define DEFINE_INSTANCEID_FROM_TOKEN(n) id##n = TOKEN2INSTANCEID(t##n)
282
+ #define DEFINE_GLOBALID_FROM_TOKEN(n) id##n = TOKEN2GLOBALID(t##n)
283
+ DEFINE_GLOBALID_FROM_TOKEN(LASTLINE),
284
+ DEFINE_GLOBALID_FROM_TOKEN(BACKREF),
285
+ DEFINE_GLOBALID_FROM_TOKEN(ERROR_INFO),
286
+ #define DEFINE_CONSTID_FROM_TOKEN(n) id##n = TOKEN2CONSTID(t##n)
287
+ #define DEFINE_CLASSID_FROM_TOKEN(n) id##n = TOKEN2CLASSID(t##n)
288
+ #define DEFINE_ATTRSETID_FROM_TOKEN(n) id##n = TOKEN2ATTRSETID(t##n)
289
+ tLAST_OP_ID = tPRESERVED_ID_END-1,
290
+ idLAST_OP_ID = tLAST_OP_ID >> ID_SCOPE_SHIFT
291
+ };
292
+
293
+ #endif /* RUBY_ID_H */
@@ -0,0 +1,36 @@
1
+ #ifndef RUBY_ID_TABLE_H
2
+ #define RUBY_ID_TABLE_H 1
3
+ #include "ruby/internal/config.h"
4
+ #include <stddef.h>
5
+ #include "ruby/ruby.h"
6
+
7
+ struct rb_id_table;
8
+
9
+ /* compatible with ST_* */
10
+ enum rb_id_table_iterator_result {
11
+ ID_TABLE_CONTINUE = ST_CONTINUE,
12
+ ID_TABLE_STOP = ST_STOP,
13
+ ID_TABLE_DELETE = ST_DELETE,
14
+ ID_TABLE_REPLACE = ST_REPLACE,
15
+ ID_TABLE_ITERATOR_RESULT_END
16
+ };
17
+
18
+ struct rb_id_table *rb_id_table_create(size_t size);
19
+ void rb_id_table_free(struct rb_id_table *tbl);
20
+ void rb_id_table_clear(struct rb_id_table *tbl);
21
+
22
+ size_t rb_id_table_size(const struct rb_id_table *tbl);
23
+ size_t rb_id_table_memsize(const struct rb_id_table *tbl);
24
+
25
+ int rb_id_table_insert(struct rb_id_table *tbl, ID id, VALUE val);
26
+ int rb_id_table_lookup(struct rb_id_table *tbl, ID id, VALUE *valp);
27
+ int rb_id_table_delete(struct rb_id_table *tbl, ID id);
28
+
29
+ typedef enum rb_id_table_iterator_result rb_id_table_update_callback_func_t(ID *id, VALUE *val, void *data, int existing);
30
+ typedef enum rb_id_table_iterator_result rb_id_table_foreach_func_t(ID id, VALUE val, void *data);
31
+ typedef enum rb_id_table_iterator_result rb_id_table_foreach_values_func_t(VALUE val, void *data);
32
+ void rb_id_table_foreach(struct rb_id_table *tbl, rb_id_table_foreach_func_t *func, void *data);
33
+ void rb_id_table_foreach_with_replace(struct rb_id_table *tbl, rb_id_table_foreach_func_t *func, rb_id_table_update_callback_func_t *replace, void *data);
34
+ void rb_id_table_foreach_values(struct rb_id_table *tbl, rb_id_table_foreach_values_func_t *func, void *data);
35
+
36
+ #endif /* RUBY_ID_TABLE_H */
@@ -0,0 +1,113 @@
1
+ #ifndef INTERNAL_ARRAY_H /*-*-C-*-vi:se ft=c:*/
2
+ #define INTERNAL_ARRAY_H
3
+ /**
4
+ * @author Ruby developers <ruby-core@ruby-lang.org>
5
+ * @copyright This file is a part of the programming language Ruby.
6
+ * Permission is hereby granted, to either redistribute and/or
7
+ * modify this file, provided that the conditions mentioned in the
8
+ * file COPYING are met. Consult the file for details.
9
+ * @brief Internal header for Array.
10
+ */
11
+ #include "ruby/internal/config.h"
12
+ #include <stddef.h> /* for size_t */
13
+ #include "internal/static_assert.h" /* for STATIC_ASSERT */
14
+ #include "ruby/internal/stdbool.h" /* for bool */
15
+ #include "ruby/ruby.h" /* for RARRAY_LEN */
16
+
17
+ #ifndef ARRAY_DEBUG
18
+ # define ARRAY_DEBUG (0+RUBY_DEBUG)
19
+ #endif
20
+
21
+ #define RARRAY_PTR_IN_USE_FLAG FL_USER14
22
+
23
+ /* array.c */
24
+ VALUE rb_ary_last(int, const VALUE *, VALUE);
25
+ void rb_ary_set_len(VALUE, long);
26
+ void rb_ary_delete_same(VALUE, VALUE);
27
+ VALUE rb_ary_tmp_new_fill(long capa);
28
+ VALUE rb_ary_at(VALUE, VALUE);
29
+ size_t rb_ary_memsize(VALUE);
30
+ VALUE rb_to_array_type(VALUE obj);
31
+ VALUE rb_to_array(VALUE obj);
32
+ void rb_ary_cancel_sharing(VALUE ary);
33
+
34
+ static inline VALUE rb_ary_entry_internal(VALUE ary, long offset);
35
+ static inline bool ARY_PTR_USING_P(VALUE ary);
36
+ static inline void RARY_TRANSIENT_SET(VALUE ary);
37
+ static inline void RARY_TRANSIENT_UNSET(VALUE ary);
38
+
39
+ MJIT_SYMBOL_EXPORT_BEGIN
40
+ VALUE rb_ary_tmp_new_from_values(VALUE, long, const VALUE *);
41
+ VALUE rb_check_to_array(VALUE ary);
42
+ VALUE rb_ary_behead(VALUE, long);
43
+ VALUE rb_ary_aref1(VALUE ary, VALUE i);
44
+
45
+ struct rb_execution_context_struct;
46
+ VALUE rb_ec_ary_new_from_values(struct rb_execution_context_struct *ec, long n, const VALUE *elts);
47
+ MJIT_SYMBOL_EXPORT_END
48
+
49
+ // YJIT needs this function to never allocate and never raise
50
+ static inline VALUE
51
+ rb_ary_entry_internal(VALUE ary, long offset)
52
+ {
53
+ long len = RARRAY_LEN(ary);
54
+ const VALUE *ptr = RARRAY_CONST_PTR_TRANSIENT(ary);
55
+ if (len == 0) return Qnil;
56
+ if (offset < 0) {
57
+ offset += len;
58
+ if (offset < 0) return Qnil;
59
+ }
60
+ else if (len <= offset) {
61
+ return Qnil;
62
+ }
63
+ return ptr[offset];
64
+ }
65
+
66
+ static inline bool
67
+ ARY_PTR_USING_P(VALUE ary)
68
+ {
69
+ return FL_TEST_RAW(ary, RARRAY_PTR_IN_USE_FLAG);
70
+ }
71
+
72
+ static inline void
73
+ RARY_TRANSIENT_SET(VALUE ary)
74
+ {
75
+ #if USE_TRANSIENT_HEAP
76
+ FL_SET_RAW(ary, RARRAY_TRANSIENT_FLAG);
77
+ #endif
78
+ }
79
+
80
+ static inline void
81
+ RARY_TRANSIENT_UNSET(VALUE ary)
82
+ {
83
+ #if USE_TRANSIENT_HEAP
84
+ FL_UNSET_RAW(ary, RARRAY_TRANSIENT_FLAG);
85
+ #endif
86
+ }
87
+
88
+ #undef rb_ary_new_from_args
89
+ #if RBIMPL_HAS_WARNING("-Wgnu-zero-variadic-macro-arguments")
90
+ # /* Skip it; clang -pedantic doesn't like the following */
91
+ #elif defined(__GNUC__) && defined(HAVE_VA_ARGS_MACRO)
92
+ #define rb_ary_new_from_args(n, ...) \
93
+ __extension__ ({ \
94
+ const VALUE args_to_new_ary[] = {__VA_ARGS__}; \
95
+ if (__builtin_constant_p(n)) { \
96
+ STATIC_ASSERT(rb_ary_new_from_args, numberof(args_to_new_ary) == (n)); \
97
+ } \
98
+ rb_ary_new_from_values(numberof(args_to_new_ary), args_to_new_ary); \
99
+ })
100
+ #endif
101
+
102
+ #undef RARRAY_AREF
103
+ RBIMPL_ATTR_PURE_UNLESS_DEBUG()
104
+ RBIMPL_ATTR_ARTIFICIAL()
105
+ static inline VALUE
106
+ RARRAY_AREF(VALUE ary, long i)
107
+ {
108
+ RBIMPL_ASSERT_TYPE(ary, RUBY_T_ARRAY);
109
+
110
+ return RARRAY_CONST_PTR_TRANSIENT(ary)[i];
111
+ }
112
+
113
+ #endif /* INTERNAL_ARRAY_H */