debase-ruby_core_source 0.10.17 → 0.10.18

Sign up to get free protection for your applications and to get access to all the features.
Files changed (119) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +4 -0
  3. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/addr2line.h +20 -0
  4. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/builtin.h +121 -0
  5. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/ccan/build_assert/build_assert.h +40 -0
  6. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/ccan/check_type/check_type.h +63 -0
  7. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/ccan/container_of/container_of.h +142 -0
  8. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/ccan/list/list.h +789 -0
  9. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/ccan/str/str.h +17 -0
  10. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/constant.h +55 -0
  11. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/darray.h +179 -0
  12. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/debug_counter.h +468 -0
  13. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/dln.h +31 -0
  14. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/encindex.h +70 -0
  15. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/eval_intern.h +339 -0
  16. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/gc.h +147 -0
  17. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/hrtime.h +227 -0
  18. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/id.h +295 -0
  19. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/id_table.h +36 -0
  20. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/insns.inc +249 -0
  21. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/insns_info.inc +9061 -0
  22. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/array.h +163 -0
  23. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/bignum.h +246 -0
  24. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/bits.h +565 -0
  25. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/class.h +181 -0
  26. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/cmdlineopt.h +61 -0
  27. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/compar.h +49 -0
  28. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/compile.h +35 -0
  29. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/compilers.h +107 -0
  30. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/complex.h +29 -0
  31. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/cont.h +29 -0
  32. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/dir.h +16 -0
  33. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/enc.h +19 -0
  34. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/encoding.h +29 -0
  35. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/enum.h +18 -0
  36. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/enumerator.h +21 -0
  37. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/error.h +191 -0
  38. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/eval.h +32 -0
  39. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/file.h +38 -0
  40. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/fixnum.h +184 -0
  41. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/gc.h +191 -0
  42. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/hash.h +243 -0
  43. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/imemo.h +242 -0
  44. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/inits.h +50 -0
  45. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/io.h +38 -0
  46. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/load.h +18 -0
  47. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/loadpath.h +16 -0
  48. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/math.h +23 -0
  49. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/missing.h +18 -0
  50. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/numeric.h +275 -0
  51. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/object.h +61 -0
  52. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/parse.h +24 -0
  53. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/proc.h +32 -0
  54. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/process.h +137 -0
  55. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/ractor.h +6 -0
  56. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/random.h +16 -0
  57. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/range.h +40 -0
  58. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/rational.h +72 -0
  59. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/re.h +30 -0
  60. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/sanitizers.h +190 -0
  61. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/serial.h +23 -0
  62. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/signal.h +21 -0
  63. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/static_assert.h +16 -0
  64. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/string.h +147 -0
  65. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/struct.h +153 -0
  66. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/symbol.h +42 -0
  67. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/thread.h +55 -0
  68. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/time.h +34 -0
  69. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/transcode.h +20 -0
  70. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/util.h +27 -0
  71. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/variable.h +88 -0
  72. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/vm.h +134 -0
  73. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/warnings.h +16 -0
  74. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal.h +113 -0
  75. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/iseq.h +329 -0
  76. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/known_errors.inc +791 -0
  77. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/method.h +254 -0
  78. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/mjit.h +132 -0
  79. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/mjit_compile_attr.inc +430 -0
  80. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/mjit_compiler.h +58 -0
  81. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/mjit_unit.h +29 -0
  82. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/node.h +511 -0
  83. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/node_name.inc +210 -0
  84. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/opt_sc.inc +109 -0
  85. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/optinsn.inc +128 -0
  86. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/optunifs.inc +43 -0
  87. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/parse.h +215 -0
  88. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/probes_helper.h +44 -0
  89. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/ractor_core.h +343 -0
  90. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/regenc.h +254 -0
  91. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/regint.h +984 -0
  92. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/regparse.h +370 -0
  93. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/revision.h +5 -0
  94. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/ruby_assert.h +14 -0
  95. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/ruby_atomic.h +23 -0
  96. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/shape.h +194 -0
  97. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/siphash.h +48 -0
  98. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/symbol.h +119 -0
  99. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/thread_none.h +20 -0
  100. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/thread_pthread.h +132 -0
  101. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/thread_win32.h +63 -0
  102. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/timev.h +57 -0
  103. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/transcode_data.h +138 -0
  104. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/transient_heap.h +65 -0
  105. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/variable.h +29 -0
  106. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/version.h +65 -0
  107. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/vm.inc +5476 -0
  108. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/vm_call_iseq_optimized.inc +244 -0
  109. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/vm_callinfo.h +550 -0
  110. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/vm_core.h +2137 -0
  111. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/vm_debug.h +122 -0
  112. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/vm_exec.h +197 -0
  113. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/vm_insnhelper.h +266 -0
  114. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/vm_opts.h +73 -0
  115. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/vm_sync.h +137 -0
  116. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/vmtc.inc +243 -0
  117. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/yjit.h +72 -0
  118. data/lib/debase/ruby_core_source/version.rb +1 -1
  119. metadata +118 -3
@@ -0,0 +1,243 @@
1
+ #ifndef INTERNAL_HASH_H /*-*-C-*-vi:se ft=c:*/
2
+ #define INTERNAL_HASH_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 Hash.
10
+ */
11
+ #include "ruby/internal/config.h"
12
+ #include <stddef.h> /* for size_t */
13
+ #include "ruby/internal/stdbool.h" /* for bool */
14
+ #include "ruby/ruby.h" /* for struct RBasic */
15
+ #include "ruby/st.h" /* for struct st_table */
16
+
17
+ #define RHASH_AR_TABLE_MAX_SIZE SIZEOF_VALUE
18
+
19
+ struct ar_table_struct;
20
+ typedef unsigned char ar_hint_t;
21
+
22
+ enum ruby_rhash_flags {
23
+ RHASH_PASS_AS_KEYWORDS = FL_USER1, /* FL 1 */
24
+ RHASH_PROC_DEFAULT = FL_USER2, /* FL 2 */
25
+ RHASH_ST_TABLE_FLAG = FL_USER3, /* FL 3 */
26
+ RHASH_AR_TABLE_SIZE_MASK = (FL_USER4|FL_USER5|FL_USER6|FL_USER7), /* FL 4..7 */
27
+ RHASH_AR_TABLE_SIZE_SHIFT = (FL_USHIFT+4),
28
+ RHASH_AR_TABLE_BOUND_MASK = (FL_USER8|FL_USER9|FL_USER10|FL_USER11), /* FL 8..11 */
29
+ RHASH_AR_TABLE_BOUND_SHIFT = (FL_USHIFT+8),
30
+
31
+ #if USE_TRANSIENT_HEAP
32
+ RHASH_TRANSIENT_FLAG = FL_USER12, /* FL 12 */
33
+ #endif
34
+
35
+ // we can not put it in "enum" because it can exceed "int" range.
36
+ #define RHASH_LEV_MASK (FL_USER13 | FL_USER14 | FL_USER15 | /* FL 13..19 */ \
37
+ FL_USER16 | FL_USER17 | FL_USER18 | FL_USER19)
38
+
39
+ RHASH_LEV_SHIFT = (FL_USHIFT + 13),
40
+ RHASH_LEV_MAX = 127, /* 7 bits */
41
+ };
42
+
43
+ struct RHash {
44
+ struct RBasic basic;
45
+ union {
46
+ st_table *st;
47
+ struct ar_table_struct *ar; /* possibly 0 */
48
+ } as;
49
+ const VALUE ifnone;
50
+ union {
51
+ ar_hint_t ary[RHASH_AR_TABLE_MAX_SIZE];
52
+ VALUE word;
53
+ } ar_hint;
54
+ };
55
+
56
+ #define RHASH(obj) ((struct RHash *)(obj))
57
+
58
+ #ifdef RHASH_IFNONE
59
+ # undef RHASH_IFNONE
60
+ #endif
61
+
62
+ #ifdef RHASH_SIZE
63
+ # undef RHASH_SIZE
64
+ #endif
65
+
66
+ #ifdef RHASH_EMPTY_P
67
+ # undef RHASH_EMPTY_P
68
+ #endif
69
+
70
+ /* hash.c */
71
+ void rb_hash_st_table_set(VALUE hash, st_table *st);
72
+ VALUE rb_hash_default_value(VALUE hash, VALUE key);
73
+ VALUE rb_hash_set_default_proc(VALUE hash, VALUE proc);
74
+ long rb_dbl_long_hash(double d);
75
+ st_table *rb_init_identtable(void);
76
+ VALUE rb_to_hash_type(VALUE obj);
77
+ VALUE rb_hash_key_str(VALUE);
78
+ VALUE rb_hash_values(VALUE hash);
79
+ VALUE rb_hash_rehash(VALUE hash);
80
+ int rb_hash_add_new_element(VALUE hash, VALUE key, VALUE val);
81
+ VALUE rb_hash_set_pair(VALUE hash, VALUE pair);
82
+ int rb_hash_stlike_delete(VALUE hash, st_data_t *pkey, st_data_t *pval);
83
+ int rb_hash_stlike_foreach_with_replace(VALUE hash, st_foreach_check_callback_func *func, st_update_callback_func *replace, st_data_t arg);
84
+ int rb_hash_stlike_update(VALUE hash, st_data_t key, st_update_callback_func *func, st_data_t arg);
85
+ extern st_table *rb_hash_st_table(VALUE hash);
86
+ VALUE rb_ident_hash_new_with_size(st_index_t size);
87
+
88
+ static inline unsigned RHASH_AR_TABLE_SIZE_RAW(VALUE h);
89
+ static inline VALUE RHASH_IFNONE(VALUE h);
90
+ static inline size_t RHASH_SIZE(VALUE h);
91
+ static inline bool RHASH_EMPTY_P(VALUE h);
92
+ static inline bool RHASH_AR_TABLE_P(VALUE h);
93
+ static inline bool RHASH_ST_TABLE_P(VALUE h);
94
+ static inline struct ar_table_struct *RHASH_AR_TABLE(VALUE h);
95
+ static inline st_table *RHASH_ST_TABLE(VALUE h);
96
+ static inline size_t RHASH_ST_SIZE(VALUE h);
97
+ static inline void RHASH_ST_CLEAR(VALUE h);
98
+ static inline bool RHASH_TRANSIENT_P(VALUE h);
99
+ static inline void RHASH_SET_TRANSIENT_FLAG(VALUE h);
100
+ static inline void RHASH_UNSET_TRANSIENT_FLAG(VALUE h);
101
+
102
+ RUBY_SYMBOL_EXPORT_BEGIN
103
+ /* hash.c (export) */
104
+ VALUE rb_hash_delete_entry(VALUE hash, VALUE key);
105
+ VALUE rb_ident_hash_new(void);
106
+ int rb_hash_stlike_foreach(VALUE hash, st_foreach_callback_func *func, st_data_t arg);
107
+ RUBY_SYMBOL_EXPORT_END
108
+
109
+ MJIT_SYMBOL_EXPORT_BEGIN
110
+ VALUE rb_hash_new_with_size(st_index_t size);
111
+ VALUE rb_hash_resurrect(VALUE hash);
112
+ int rb_hash_stlike_lookup(VALUE hash, st_data_t key, st_data_t *pval);
113
+ VALUE rb_hash_keys(VALUE hash);
114
+ VALUE rb_hash_has_key(VALUE hash, VALUE key);
115
+ VALUE rb_hash_compare_by_id_p(VALUE hash);
116
+
117
+ st_table *rb_hash_tbl_raw(VALUE hash, const char *file, int line);
118
+ #define RHASH_TBL_RAW(h) rb_hash_tbl_raw(h, __FILE__, __LINE__)
119
+ MJIT_SYMBOL_EXPORT_END
120
+
121
+ VALUE rb_hash_compare_by_id(VALUE hash);
122
+
123
+ #if 0 /* for debug */
124
+
125
+ static inline bool
126
+ RHASH_AR_TABLE_P(VALUE h)
127
+ {
128
+ extern int rb_hash_ar_table_p(VALUE hash);
129
+ return rb_hash_ar_table_p(h)
130
+ }
131
+
132
+ static inline struct ar_table_struct *
133
+ RHASH_AR_TABLE(VALUE h)
134
+ {
135
+ extern struct ar_table_struct *rb_hash_ar_table(VALUE hash);
136
+ return rb_hash_ar_table(h)
137
+ }
138
+
139
+ static inline st_table *
140
+ RHASH_ST_TABLE(VALUE h)
141
+ {
142
+ return rb_hash_st_table(h)
143
+ }
144
+
145
+ #else
146
+
147
+ static inline bool
148
+ RHASH_AR_TABLE_P(VALUE h)
149
+ {
150
+ return ! FL_TEST_RAW(h, RHASH_ST_TABLE_FLAG);
151
+ }
152
+
153
+ static inline struct ar_table_struct *
154
+ RHASH_AR_TABLE(VALUE h)
155
+ {
156
+ return RHASH(h)->as.ar;
157
+ }
158
+
159
+ static inline st_table *
160
+ RHASH_ST_TABLE(VALUE h)
161
+ {
162
+ return RHASH(h)->as.st;
163
+ }
164
+
165
+ #endif
166
+
167
+ static inline VALUE
168
+ RHASH_IFNONE(VALUE h)
169
+ {
170
+ return RHASH(h)->ifnone;
171
+ }
172
+
173
+ static inline size_t
174
+ RHASH_SIZE(VALUE h)
175
+ {
176
+ if (RHASH_AR_TABLE_P(h)) {
177
+ return RHASH_AR_TABLE_SIZE_RAW(h);
178
+ }
179
+ else {
180
+ return RHASH_ST_SIZE(h);
181
+ }
182
+ }
183
+
184
+ static inline bool
185
+ RHASH_EMPTY_P(VALUE h)
186
+ {
187
+ return RHASH_SIZE(h) == 0;
188
+ }
189
+
190
+ static inline bool
191
+ RHASH_ST_TABLE_P(VALUE h)
192
+ {
193
+ return ! RHASH_AR_TABLE_P(h);
194
+ }
195
+
196
+ static inline size_t
197
+ RHASH_ST_SIZE(VALUE h)
198
+ {
199
+ return RHASH_ST_TABLE(h)->num_entries;
200
+ }
201
+
202
+ static inline void
203
+ RHASH_ST_CLEAR(VALUE h)
204
+ {
205
+ FL_UNSET_RAW(h, RHASH_ST_TABLE_FLAG);
206
+ RHASH(h)->as.ar = NULL;
207
+ }
208
+
209
+ static inline unsigned
210
+ RHASH_AR_TABLE_SIZE_RAW(VALUE h)
211
+ {
212
+ VALUE ret = FL_TEST_RAW(h, RHASH_AR_TABLE_SIZE_MASK);
213
+ ret >>= RHASH_AR_TABLE_SIZE_SHIFT;
214
+ return (unsigned)ret;
215
+ }
216
+
217
+ static inline bool
218
+ RHASH_TRANSIENT_P(VALUE h)
219
+ {
220
+ #if USE_TRANSIENT_HEAP
221
+ return FL_TEST_RAW(h, RHASH_TRANSIENT_FLAG);
222
+ #else
223
+ return false;
224
+ #endif
225
+ }
226
+
227
+ static inline void
228
+ RHASH_SET_TRANSIENT_FLAG(VALUE h)
229
+ {
230
+ #if USE_TRANSIENT_HEAP
231
+ FL_SET_RAW(h, RHASH_TRANSIENT_FLAG);
232
+ #endif
233
+ }
234
+
235
+ static inline void
236
+ RHASH_UNSET_TRANSIENT_FLAG(VALUE h)
237
+ {
238
+ #if USE_TRANSIENT_HEAP
239
+ FL_UNSET_RAW(h, RHASH_TRANSIENT_FLAG);
240
+ #endif
241
+ }
242
+
243
+ #endif /* INTERNAL_HASH_H */
@@ -0,0 +1,242 @@
1
+ #ifndef INTERNAL_IMEMO_H /*-*-C-*-vi:se ft=c:*/
2
+ #define INTERNAL_IMEMO_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 IMEMO: Internal memo object.
10
+ */
11
+ #include "ruby/internal/config.h"
12
+ #include <stddef.h> /* for size_t */
13
+ #include "internal/array.h" /* for rb_ary_hidden_new_fill */
14
+ #include "internal/gc.h" /* for RB_OBJ_WRITE */
15
+ #include "ruby/internal/stdbool.h" /* for bool */
16
+ #include "ruby/ruby.h" /* for rb_block_call_func_t */
17
+
18
+ #ifndef IMEMO_DEBUG
19
+ # define IMEMO_DEBUG 0
20
+ #endif
21
+
22
+ #define IMEMO_MASK 0x0f
23
+
24
+ /* FL_USER0 to FL_USER3 is for type */
25
+ #define IMEMO_FL_USHIFT (FL_USHIFT + 4)
26
+ #define IMEMO_FL_USER0 FL_USER4
27
+ #define IMEMO_FL_USER1 FL_USER5
28
+ #define IMEMO_FL_USER2 FL_USER6
29
+ #define IMEMO_FL_USER3 FL_USER7
30
+ #define IMEMO_FL_USER4 FL_USER8
31
+ #define IMEMO_FL_USER5 FL_USER9
32
+
33
+ enum imemo_type {
34
+ imemo_env = 0,
35
+ imemo_cref = 1, /*!< class reference */
36
+ imemo_svar = 2, /*!< special variable */
37
+ imemo_throw_data = 3,
38
+ imemo_ifunc = 4, /*!< iterator function */
39
+ imemo_memo = 5,
40
+ imemo_ment = 6,
41
+ imemo_iseq = 7,
42
+ imemo_tmpbuf = 8,
43
+ imemo_ast = 9,
44
+ imemo_parser_strterm = 10,
45
+ imemo_callinfo = 11,
46
+ imemo_callcache = 12,
47
+ imemo_constcache = 13,
48
+ };
49
+
50
+ /* CREF (Class REFerence) is defined in method.h */
51
+
52
+ /*! SVAR (Special VARiable) */
53
+ struct vm_svar {
54
+ VALUE flags;
55
+ const VALUE cref_or_me; /*!< class reference or rb_method_entry_t */
56
+ const VALUE lastline;
57
+ const VALUE backref;
58
+ const VALUE others;
59
+ };
60
+
61
+ /*! THROW_DATA */
62
+ struct vm_throw_data {
63
+ VALUE flags;
64
+ VALUE reserved;
65
+ const VALUE throw_obj;
66
+ const struct rb_control_frame_struct *catch_frame;
67
+ int throw_state;
68
+ };
69
+
70
+ #define THROW_DATA_CONSUMED IMEMO_FL_USER0
71
+
72
+ /* IFUNC (Internal FUNCtion) */
73
+
74
+ struct vm_ifunc_argc {
75
+ #if SIZEOF_INT * 2 > SIZEOF_VALUE
76
+ signed int min: (SIZEOF_VALUE * CHAR_BIT) / 2;
77
+ signed int max: (SIZEOF_VALUE * CHAR_BIT) / 2;
78
+ #else
79
+ int min, max;
80
+ #endif
81
+ };
82
+
83
+ /*! IFUNC (Internal FUNCtion) */
84
+ struct vm_ifunc {
85
+ VALUE flags;
86
+ VALUE reserved;
87
+ rb_block_call_func_t func;
88
+ const void *data;
89
+ struct vm_ifunc_argc argc;
90
+ };
91
+
92
+ struct rb_imemo_tmpbuf_struct {
93
+ VALUE flags;
94
+ VALUE reserved;
95
+ VALUE *ptr; /* malloc'ed buffer */
96
+ struct rb_imemo_tmpbuf_struct *next; /* next imemo */
97
+ size_t cnt; /* buffer size in VALUE */
98
+ };
99
+
100
+ /*! MEMO
101
+ *
102
+ * @see imemo_type
103
+ * */
104
+ struct MEMO {
105
+ VALUE flags;
106
+ VALUE reserved;
107
+ const VALUE v1;
108
+ const VALUE v2;
109
+ union {
110
+ long cnt;
111
+ long state;
112
+ const VALUE value;
113
+ void (*func)(void);
114
+ } u3;
115
+ };
116
+
117
+ /* ment is in method.h */
118
+
119
+ #define THROW_DATA_P(err) imemo_throw_data_p((VALUE)err)
120
+ #define MEMO_CAST(m) ((struct MEMO *)(m))
121
+ #define MEMO_NEW(a, b, c) ((struct MEMO *)rb_imemo_new(imemo_memo, (VALUE)(a), (VALUE)(b), (VALUE)(c), 0))
122
+ #define MEMO_FOR(type, value) ((type *)RARRAY_PTR(value))
123
+ #define NEW_MEMO_FOR(type, value) \
124
+ ((value) = rb_ary_hidden_new_fill(type_roomof(type, VALUE)), MEMO_FOR(type, value))
125
+ #define NEW_PARTIAL_MEMO_FOR(type, value, member) \
126
+ ((value) = rb_ary_hidden_new_fill(type_roomof(type, VALUE)), \
127
+ rb_ary_set_len((value), offsetof(type, member) / sizeof(VALUE)), \
128
+ MEMO_FOR(type, value))
129
+
130
+ typedef struct rb_imemo_tmpbuf_struct rb_imemo_tmpbuf_t;
131
+ rb_imemo_tmpbuf_t *rb_imemo_tmpbuf_parser_heap(void *buf, rb_imemo_tmpbuf_t *old_heap, size_t cnt);
132
+ struct vm_ifunc *rb_vm_ifunc_new(rb_block_call_func_t func, const void *data, int min_argc, int max_argc);
133
+ void rb_strterm_mark(VALUE obj);
134
+ static inline enum imemo_type imemo_type(VALUE imemo);
135
+ static inline int imemo_type_p(VALUE imemo, enum imemo_type imemo_type);
136
+ static inline bool imemo_throw_data_p(VALUE imemo);
137
+ static inline struct vm_ifunc *rb_vm_ifunc_proc_new(rb_block_call_func_t func, const void *data);
138
+ static inline VALUE rb_imemo_tmpbuf_auto_free_pointer(void);
139
+ static inline void *RB_IMEMO_TMPBUF_PTR(VALUE v);
140
+ static inline void *rb_imemo_tmpbuf_set_ptr(VALUE v, void *ptr);
141
+ static inline VALUE rb_imemo_tmpbuf_auto_free_pointer_new_from_an_RString(VALUE str);
142
+ static inline void MEMO_V1_SET(struct MEMO *m, VALUE v);
143
+ static inline void MEMO_V2_SET(struct MEMO *m, VALUE v);
144
+
145
+ RUBY_SYMBOL_EXPORT_BEGIN
146
+ #if IMEMO_DEBUG
147
+ VALUE rb_imemo_new_debug(enum imemo_type type, VALUE v1, VALUE v2, VALUE v3, VALUE v0, const char *file, int line);
148
+ #define rb_imemo_new(type, v1, v2, v3, v0) rb_imemo_new_debug(type, v1, v2, v3, v0, __FILE__, __LINE__)
149
+ #else
150
+ VALUE rb_imemo_new(enum imemo_type type, VALUE v1, VALUE v2, VALUE v3, VALUE v0);
151
+ #endif
152
+ const char *rb_imemo_name(enum imemo_type type);
153
+ RUBY_SYMBOL_EXPORT_END
154
+
155
+ static inline enum imemo_type
156
+ imemo_type(VALUE imemo)
157
+ {
158
+ return (RBASIC(imemo)->flags >> FL_USHIFT) & IMEMO_MASK;
159
+ }
160
+
161
+ static inline int
162
+ imemo_type_p(VALUE imemo, enum imemo_type imemo_type)
163
+ {
164
+ if (LIKELY(!RB_SPECIAL_CONST_P(imemo))) {
165
+ /* fixed at compile time if imemo_type is given. */
166
+ const VALUE mask = (IMEMO_MASK << FL_USHIFT) | RUBY_T_MASK;
167
+ const VALUE expected_type = (imemo_type << FL_USHIFT) | T_IMEMO;
168
+ /* fixed at runtime. */
169
+ return expected_type == (RBASIC(imemo)->flags & mask);
170
+ }
171
+ else {
172
+ return 0;
173
+ }
174
+ }
175
+
176
+ #define IMEMO_TYPE_P(v, t) imemo_type_p((VALUE)v, t)
177
+
178
+ static inline bool
179
+ imemo_throw_data_p(VALUE imemo)
180
+ {
181
+ return RB_TYPE_P(imemo, T_IMEMO);
182
+ }
183
+
184
+ static inline struct vm_ifunc *
185
+ rb_vm_ifunc_proc_new(rb_block_call_func_t func, const void *data)
186
+ {
187
+ return rb_vm_ifunc_new(func, data, 0, UNLIMITED_ARGUMENTS);
188
+ }
189
+
190
+ static inline VALUE
191
+ rb_imemo_tmpbuf_auto_free_pointer(void)
192
+ {
193
+ return rb_imemo_new(imemo_tmpbuf, 0, 0, 0, 0);
194
+ }
195
+
196
+ static inline void *
197
+ RB_IMEMO_TMPBUF_PTR(VALUE v)
198
+ {
199
+ const struct rb_imemo_tmpbuf_struct *p = (const void *)v;
200
+ return p->ptr;
201
+ }
202
+
203
+ static inline void *
204
+ rb_imemo_tmpbuf_set_ptr(VALUE v, void *ptr)
205
+ {
206
+ return ((rb_imemo_tmpbuf_t *)v)->ptr = ptr;
207
+ }
208
+
209
+ static inline VALUE
210
+ rb_imemo_tmpbuf_auto_free_pointer_new_from_an_RString(VALUE str)
211
+ {
212
+ const void *src;
213
+ VALUE imemo;
214
+ rb_imemo_tmpbuf_t *tmpbuf;
215
+ void *dst;
216
+ size_t len;
217
+
218
+ SafeStringValue(str);
219
+ /* create tmpbuf to keep the pointer before xmalloc */
220
+ imemo = rb_imemo_tmpbuf_auto_free_pointer();
221
+ tmpbuf = (rb_imemo_tmpbuf_t *)imemo;
222
+ len = RSTRING_LEN(str);
223
+ src = RSTRING_PTR(str);
224
+ dst = ruby_xmalloc(len);
225
+ memcpy(dst, src, len);
226
+ tmpbuf->ptr = dst;
227
+ return imemo;
228
+ }
229
+
230
+ static inline void
231
+ MEMO_V1_SET(struct MEMO *m, VALUE v)
232
+ {
233
+ RB_OBJ_WRITE(m, &m->v1, v);
234
+ }
235
+
236
+ static inline void
237
+ MEMO_V2_SET(struct MEMO *m, VALUE v)
238
+ {
239
+ RB_OBJ_WRITE(m, &m->v2, v);
240
+ }
241
+
242
+ #endif /* INTERNAL_IMEMO_H */
@@ -0,0 +1,50 @@
1
+ #ifndef INTERNAL_INITS_H /*-*-C-*-vi:se ft=c:*/
2
+ #define INTERNAL_INITS_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 aggregating init functions.
10
+ */
11
+
12
+ /* class.c */
13
+ void Init_class_hierarchy(void);
14
+
15
+ /* dmyext.c */
16
+ void Init_enc(void);
17
+ void Init_ext(void);
18
+
19
+ /* file.c */
20
+ void Init_File(void);
21
+
22
+ /* gc.c */
23
+ void Init_heap(void);
24
+
25
+ /* localeinit.c */
26
+ int Init_enc_set_filesystem_encoding(void);
27
+
28
+ /* newline.c */
29
+ void Init_newline(void);
30
+
31
+ /* vm.c */
32
+ void Init_BareVM(void);
33
+ void Init_vm_objects(void);
34
+
35
+ /* vm_backtrace.c */
36
+ void Init_vm_backtrace(void);
37
+
38
+ /* vm_eval.c */
39
+ void Init_vm_eval(void);
40
+
41
+ /* vm_insnhelper.c */
42
+ void Init_vm_stack_canary(void);
43
+
44
+ /* vm_method.c */
45
+ void Init_eval_method(void);
46
+
47
+ /* inits.c */
48
+ void rb_call_inits(void);
49
+
50
+ #endif /* INTERNAL_INITS_H */
@@ -0,0 +1,38 @@
1
+ #ifndef INTERNAL_IO_H /*-*-C-*-vi:se ft=c:*/
2
+ #define INTERNAL_IO_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 IO.
10
+ */
11
+ #include "ruby/ruby.h" /* for VALUE */
12
+ #include "ruby/io.h" /* for rb_io_t */
13
+
14
+ /* io.c */
15
+ void ruby_set_inplace_mode(const char *);
16
+ void rb_stdio_set_default_encoding(void);
17
+ VALUE rb_io_flush_raw(VALUE, int);
18
+ size_t rb_io_memsize(const rb_io_t *);
19
+ int rb_stderr_tty_p(void);
20
+ void rb_io_fptr_finalize_internal(void *ptr);
21
+ #ifdef rb_io_fptr_finalize
22
+ # undef rb_io_fptr_finalize
23
+ #endif
24
+ #define rb_io_fptr_finalize rb_io_fptr_finalize_internal
25
+ VALUE rb_io_popen(VALUE pname, VALUE pmode, VALUE env, VALUE opt);
26
+
27
+ VALUE rb_io_prep_stdin(void);
28
+ VALUE rb_io_prep_stdout(void);
29
+ VALUE rb_io_prep_stderr(void);
30
+
31
+ RUBY_SYMBOL_EXPORT_BEGIN
32
+ /* io.c (export) */
33
+ void rb_maygvl_fd_fix_cloexec(int fd);
34
+ int rb_gc_for_fd(int err);
35
+ void rb_write_error_str(VALUE mesg);
36
+ RUBY_SYMBOL_EXPORT_END
37
+
38
+ #endif /* INTERNAL_IO_H */
@@ -0,0 +1,18 @@
1
+ #ifndef INTERNAL_LOAD_H /*-*-C-*-vi:se ft=c:*/
2
+ #define INTERNAL_LOAD_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 require.
10
+ */
11
+ #include "ruby/ruby.h" /* for VALUE */
12
+
13
+ /* load.c */
14
+ VALUE rb_get_expanded_load_path(void);
15
+ int rb_require_internal(VALUE fname);
16
+ NORETURN(void rb_load_fail(VALUE, const char*));
17
+
18
+ #endif /* INTERNAL_LOAD_H */
@@ -0,0 +1,16 @@
1
+ #ifndef INTERNAL_LOADPATH_H /*-*-C-*-vi:se ft=c:*/
2
+ #define INTERNAL_LOADPATH_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 $LOAD_PATH.
10
+ */
11
+
12
+ /* loadpath.c */
13
+ extern const char ruby_exec_prefix[];
14
+ extern const char ruby_initial_load_paths[];
15
+
16
+ #endif /* INTERNAL_LOADPATH_H */
@@ -0,0 +1,23 @@
1
+ #ifndef INTERNAL_MATH_H /*-*-C-*-vi:se ft=c:*/
2
+ #define INTERNAL_MATH_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 Math.
10
+ */
11
+ #include "ruby/ruby.h" /* for VALUE */
12
+
13
+ /* math.c */
14
+ VALUE rb_math_atan2(VALUE, VALUE);
15
+ VALUE rb_math_cos(VALUE);
16
+ VALUE rb_math_cosh(VALUE);
17
+ VALUE rb_math_exp(VALUE);
18
+ VALUE rb_math_hypot(VALUE, VALUE);
19
+ VALUE rb_math_log(int argc, const VALUE *argv);
20
+ VALUE rb_math_sin(VALUE);
21
+ VALUE rb_math_sinh(VALUE);
22
+
23
+ #endif /* INTERNAL_MATH_H */
@@ -0,0 +1,18 @@
1
+ #ifndef INTERNAL_MISSING_H /*-*-C-*-vi:se ft=c:*/
2
+ #define INTERNAL_MISSING_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 corresponding missing.
10
+ */
11
+ #include "ruby/internal/config.h" /* for HAVE_SETPROCTITLE */
12
+
13
+ /* missing/setproctitle.c */
14
+ #ifndef HAVE_SETPROCTITLE
15
+ extern void ruby_init_setproctitle(int argc, char *argv[]);
16
+ #endif
17
+
18
+ #endif /* INTERNAL_MISSING_H */