debase-ruby_core_source 3.4.1 → 4.0.0.preview2

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 (149) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +4 -0
  3. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/addr2line.h +22 -0
  4. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/builtin.h +125 -0
  5. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/ccan/build_assert/build_assert.h +40 -0
  6. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/ccan/check_type/check_type.h +63 -0
  7. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/ccan/container_of/container_of.h +142 -0
  8. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/ccan/list/list.h +791 -0
  9. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/ccan/str/str.h +17 -0
  10. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/constant.h +53 -0
  11. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/darray.h +278 -0
  12. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/debug_counter.h +425 -0
  13. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/dln.h +33 -0
  14. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/encindex.h +70 -0
  15. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/eval_intern.h +331 -0
  16. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/hrtime.h +237 -0
  17. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/id.h +354 -0
  18. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/id_table.h +54 -0
  19. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/insns.inc +302 -0
  20. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/insns_info.inc +11241 -0
  21. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/array.h +154 -0
  22. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/basic_operators.h +65 -0
  23. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/bignum.h +245 -0
  24. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/bits.h +650 -0
  25. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/box.h +81 -0
  26. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/class.h +805 -0
  27. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/cmdlineopt.h +64 -0
  28. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/compar.h +29 -0
  29. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/compile.h +34 -0
  30. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/compilers.h +107 -0
  31. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/complex.h +29 -0
  32. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/concurrent_set.h +21 -0
  33. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/cont.h +35 -0
  34. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/dir.h +16 -0
  35. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/enc.h +19 -0
  36. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/encoding.h +39 -0
  37. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/enum.h +18 -0
  38. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/enumerator.h +21 -0
  39. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/error.h +251 -0
  40. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/eval.h +41 -0
  41. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/file.h +38 -0
  42. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/fixnum.h +185 -0
  43. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/gc.h +358 -0
  44. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/hash.h +194 -0
  45. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/imemo.h +322 -0
  46. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/inits.h +51 -0
  47. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/io.h +163 -0
  48. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/load.h +20 -0
  49. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/loadpath.h +16 -0
  50. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/math.h +23 -0
  51. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/missing.h +19 -0
  52. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/numeric.h +275 -0
  53. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/object.h +63 -0
  54. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/parse.h +131 -0
  55. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/proc.h +30 -0
  56. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/process.h +124 -0
  57. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/ractor.h +10 -0
  58. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/random.h +17 -0
  59. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/range.h +40 -0
  60. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/rational.h +71 -0
  61. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/re.h +33 -0
  62. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/ruby_parser.h +102 -0
  63. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/sanitizers.h +346 -0
  64. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/serial.h +23 -0
  65. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/set_table.h +70 -0
  66. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/signal.h +25 -0
  67. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/st.h +11 -0
  68. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/static_assert.h +16 -0
  69. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/string.h +203 -0
  70. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/struct.h +160 -0
  71. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/symbol.h +46 -0
  72. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/thread.h +112 -0
  73. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/time.h +37 -0
  74. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/transcode.h +23 -0
  75. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/util.h +27 -0
  76. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/variable.h +74 -0
  77. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/vm.h +136 -0
  78. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/warnings.h +16 -0
  79. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal.h +105 -0
  80. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/iseq.h +357 -0
  81. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/known_errors.inc +1419 -0
  82. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/method.h +271 -0
  83. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/node.h +122 -0
  84. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/node_name.inc +224 -0
  85. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/optinsn.inc +128 -0
  86. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/optunifs.inc +41 -0
  87. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/parse.h +244 -0
  88. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/parser_bits.h +564 -0
  89. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/parser_node.h +32 -0
  90. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/parser_st.h +162 -0
  91. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/parser_value.h +106 -0
  92. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/prism/ast.h +8233 -0
  93. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/prism/defines.h +260 -0
  94. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/prism/diagnostic.h +458 -0
  95. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/prism/encoding.h +283 -0
  96. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/prism/extension.h +19 -0
  97. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/prism/node.h +129 -0
  98. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/prism/options.h +485 -0
  99. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/prism/pack.h +163 -0
  100. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/prism/parser.h +936 -0
  101. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/prism/prettyprint.h +34 -0
  102. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/prism/prism.h +408 -0
  103. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/prism/regexp.h +43 -0
  104. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/prism/static_literals.h +121 -0
  105. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/prism/util/pm_buffer.h +236 -0
  106. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/prism/util/pm_char.h +204 -0
  107. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/prism/util/pm_constant_pool.h +218 -0
  108. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/prism/util/pm_integer.h +130 -0
  109. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/prism/util/pm_list.h +103 -0
  110. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/prism/util/pm_memchr.h +29 -0
  111. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/prism/util/pm_newline_list.h +113 -0
  112. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/prism/util/pm_string.h +200 -0
  113. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/prism/util/pm_strncasecmp.h +32 -0
  114. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/prism/util/pm_strpbrk.h +46 -0
  115. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/prism/version.h +29 -0
  116. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/prism_compile.h +106 -0
  117. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/probes_helper.h +42 -0
  118. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/ractor_core.h +306 -0
  119. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/regenc.h +259 -0
  120. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/regint.h +1005 -0
  121. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/regparse.h +371 -0
  122. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/revision.h +5 -0
  123. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/ruby_assert.h +14 -0
  124. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/ruby_atomic.h +66 -0
  125. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/rubyparser.h +1394 -0
  126. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/shape.h +444 -0
  127. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/siphash.h +48 -0
  128. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/symbol.h +116 -0
  129. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/thread_none.h +21 -0
  130. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/thread_pthread.h +175 -0
  131. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/thread_win32.h +58 -0
  132. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/timev.h +58 -0
  133. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/transcode_data.h +138 -0
  134. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/variable.h +27 -0
  135. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/version.h +69 -0
  136. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/vm.inc +6183 -0
  137. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/vm_call_iseq_optimized.inc +244 -0
  138. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/vm_callinfo.h +640 -0
  139. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/vm_core.h +2350 -0
  140. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/vm_debug.h +124 -0
  141. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/vm_exec.h +210 -0
  142. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/vm_insnhelper.h +277 -0
  143. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/vm_opts.h +67 -0
  144. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/vm_sync.h +156 -0
  145. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/vmtc.inc +289 -0
  146. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/yjit.h +81 -0
  147. data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/zjit.h +47 -0
  148. data/lib/debase/ruby_core_source/version.rb +1 -1
  149. metadata +148 -3
@@ -0,0 +1,322 @@
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 "id_table.h"
14
+ #include "internal/array.h" /* for rb_ary_hidden_new_fill */
15
+ #include "ruby/internal/stdbool.h" /* for bool */
16
+ #include "ruby/ruby.h" /* for rb_block_call_func_t */
17
+
18
+ #define IMEMO_MASK 0x0f
19
+
20
+ /* FL_USER0 to FL_USER3 is for type */
21
+ #define IMEMO_FL_USHIFT (FL_USHIFT + 4)
22
+ #define IMEMO_FL_USER0 FL_USER4
23
+ #define IMEMO_FL_USER1 FL_USER5
24
+ #define IMEMO_FL_USER2 FL_USER6
25
+ #define IMEMO_FL_USER3 FL_USER7
26
+ #define IMEMO_FL_USER4 FL_USER8
27
+ #define IMEMO_FL_USER5 FL_USER9
28
+ #define IMEMO_FL_USER6 FL_USER10
29
+
30
+ enum imemo_type {
31
+ imemo_env = 0,
32
+ imemo_cref = 1, /*!< class reference */
33
+ imemo_svar = 2, /*!< special variable */
34
+ imemo_throw_data = 3,
35
+ imemo_ifunc = 4, /*!< iterator function */
36
+ imemo_memo = 5,
37
+ imemo_ment = 6,
38
+ imemo_iseq = 7,
39
+ imemo_tmpbuf = 8,
40
+ imemo_callinfo = 10,
41
+ imemo_callcache = 11,
42
+ imemo_constcache = 12,
43
+ imemo_fields = 13,
44
+ };
45
+
46
+ /* CREF (Class REFerence) is defined in method.h */
47
+
48
+ /*! SVAR (Special VARiable) */
49
+ struct vm_svar {
50
+ VALUE flags;
51
+ const VALUE cref_or_me; /*!< class reference or rb_method_entry_t */
52
+ const VALUE lastline;
53
+ const VALUE backref;
54
+ const VALUE others;
55
+ };
56
+
57
+ /*! THROW_DATA */
58
+ struct vm_throw_data {
59
+ VALUE flags;
60
+ VALUE reserved;
61
+ const VALUE throw_obj;
62
+ const struct rb_control_frame_struct *catch_frame;
63
+ int throw_state;
64
+ };
65
+
66
+ #define THROW_DATA_CONSUMED IMEMO_FL_USER0
67
+
68
+ /* IFUNC (Internal FUNCtion) */
69
+
70
+ struct vm_ifunc_argc {
71
+ #if SIZEOF_INT * 2 > SIZEOF_VALUE
72
+ signed int min: (SIZEOF_VALUE * CHAR_BIT) / 2;
73
+ signed int max: (SIZEOF_VALUE * CHAR_BIT) / 2;
74
+ #else
75
+ int min, max;
76
+ #endif
77
+ };
78
+
79
+ /*! IFUNC (Internal FUNCtion)
80
+ *
81
+ * Bookkeeping for converting a C function and some closed-over data into a
82
+ * block passable to methods. Like Ruby Proc, but not directly accessible at
83
+ * Ruby level since this is an imemo. See rb_block_call() and friends.
84
+ */
85
+ struct vm_ifunc {
86
+ VALUE flags;
87
+ VALUE *svar_lep;
88
+ rb_block_call_func_t func;
89
+ const void *data;
90
+ struct vm_ifunc_argc argc;
91
+ };
92
+ #define IFUNC_YIELD_OPTIMIZABLE IMEMO_FL_USER0
93
+
94
+ struct rb_imemo_tmpbuf_struct {
95
+ VALUE flags;
96
+ VALUE *ptr; /* malloc'ed buffer */
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
+ #define IMEMO_NEW(T, type, v0) ((T *)rb_imemo_new((type), (v0), sizeof(T), false))
118
+ #define SHAREABLE_IMEMO_NEW(T, type, v0) ((T *)rb_imemo_new((type), (v0), sizeof(T), true))
119
+
120
+ /* ment is in method.h */
121
+
122
+ #define THROW_DATA_P(err) imemo_throw_data_p((VALUE)err)
123
+ #define MEMO_CAST(m) ((struct MEMO *)(m))
124
+ #define MEMO_FOR(type, value) ((type *)RARRAY_PTR(value))
125
+ #define NEW_MEMO_FOR(type, value) \
126
+ ((value) = rb_ary_hidden_new_fill(type_roomof(type, VALUE)), MEMO_FOR(type, value))
127
+ #define NEW_PARTIAL_MEMO_FOR(type, value, member) \
128
+ ((value) = rb_ary_hidden_new_fill(type_roomof(type, VALUE)), \
129
+ rb_ary_set_len((value), offsetof(type, member) / sizeof(VALUE)), \
130
+ MEMO_FOR(type, value))
131
+
132
+ #ifndef RUBY_RUBYPARSER_H
133
+ typedef struct rb_imemo_tmpbuf_struct rb_imemo_tmpbuf_t;
134
+ #endif
135
+ VALUE rb_imemo_new(enum imemo_type type, VALUE v0, size_t size, bool is_shareable);
136
+ VALUE rb_imemo_tmpbuf_new(void);
137
+ struct vm_ifunc *rb_vm_ifunc_new(rb_block_call_func_t func, const void *data, int min_argc, int max_argc);
138
+ static inline enum imemo_type imemo_type(VALUE imemo);
139
+ static inline int imemo_type_p(VALUE imemo, enum imemo_type imemo_type);
140
+ static inline bool imemo_throw_data_p(VALUE imemo);
141
+ static inline struct vm_ifunc *rb_vm_ifunc_proc_new(rb_block_call_func_t func, const void *data);
142
+ static inline void *RB_IMEMO_TMPBUF_PTR(VALUE v);
143
+ static inline void *rb_imemo_tmpbuf_set_ptr(VALUE v, void *ptr);
144
+ static inline void MEMO_V1_SET(struct MEMO *m, VALUE v);
145
+ static inline void MEMO_V2_SET(struct MEMO *m, VALUE v);
146
+
147
+ size_t rb_imemo_memsize(VALUE obj);
148
+ void rb_imemo_mark_and_move(VALUE obj, bool reference_updating);
149
+ void rb_imemo_free(VALUE obj);
150
+
151
+ RUBY_SYMBOL_EXPORT_BEGIN
152
+ const char *rb_imemo_name(enum imemo_type type);
153
+ RUBY_SYMBOL_EXPORT_END
154
+
155
+ static inline struct MEMO *
156
+ MEMO_NEW(VALUE a, VALUE b, VALUE c)
157
+ {
158
+ struct MEMO *memo = IMEMO_NEW(struct MEMO, imemo_memo, 0);
159
+ *((VALUE *)&memo->v1) = a;
160
+ *((VALUE *)&memo->v2) = b;
161
+ *((VALUE *)&memo->u3.value) = c;
162
+
163
+ return memo;
164
+ }
165
+
166
+ static inline enum imemo_type
167
+ imemo_type(VALUE imemo)
168
+ {
169
+ return (RBASIC(imemo)->flags >> FL_USHIFT) & IMEMO_MASK;
170
+ }
171
+
172
+ static inline int
173
+ imemo_type_p(VALUE imemo, enum imemo_type imemo_type)
174
+ {
175
+ if (LIKELY(!RB_SPECIAL_CONST_P(imemo))) {
176
+ /* fixed at compile time if imemo_type is given. */
177
+ const VALUE mask = (IMEMO_MASK << FL_USHIFT) | RUBY_T_MASK;
178
+ const VALUE expected_type = (imemo_type << FL_USHIFT) | T_IMEMO;
179
+ /* fixed at runtime. */
180
+ return expected_type == (RBASIC(imemo)->flags & mask);
181
+ }
182
+ else {
183
+ return 0;
184
+ }
185
+ }
186
+
187
+ #define IMEMO_TYPE_P(v, t) imemo_type_p((VALUE)(v), t)
188
+
189
+ static inline bool
190
+ imemo_throw_data_p(VALUE imemo)
191
+ {
192
+ return RB_TYPE_P(imemo, T_IMEMO);
193
+ }
194
+
195
+ static inline struct vm_ifunc *
196
+ rb_vm_ifunc_proc_new(rb_block_call_func_t func, const void *data)
197
+ {
198
+ return rb_vm_ifunc_new(func, data, 0, UNLIMITED_ARGUMENTS);
199
+ }
200
+
201
+ static inline void *
202
+ RB_IMEMO_TMPBUF_PTR(VALUE v)
203
+ {
204
+ const struct rb_imemo_tmpbuf_struct *p = (const void *)v;
205
+ return p->ptr;
206
+ }
207
+
208
+ static inline void *
209
+ rb_imemo_tmpbuf_set_ptr(VALUE v, void *ptr)
210
+ {
211
+ return ((rb_imemo_tmpbuf_t *)v)->ptr = ptr;
212
+ }
213
+
214
+ static inline VALUE
215
+ rb_imemo_tmpbuf_new_from_an_RString(VALUE str)
216
+ {
217
+ const void *src;
218
+ VALUE imemo;
219
+ rb_imemo_tmpbuf_t *tmpbuf;
220
+ void *dst;
221
+ size_t len;
222
+
223
+ StringValue(str);
224
+ /* create tmpbuf to keep the pointer before xmalloc */
225
+ imemo = rb_imemo_tmpbuf_new();
226
+ tmpbuf = (rb_imemo_tmpbuf_t *)imemo;
227
+ len = RSTRING_LEN(str);
228
+ src = RSTRING_PTR(str);
229
+ dst = ruby_xmalloc(len);
230
+ memcpy(dst, src, len);
231
+ tmpbuf->ptr = dst;
232
+ return imemo;
233
+ }
234
+
235
+ static inline void
236
+ MEMO_V1_SET(struct MEMO *m, VALUE v)
237
+ {
238
+ RB_OBJ_WRITE(m, &m->v1, v);
239
+ }
240
+
241
+ static inline void
242
+ MEMO_V2_SET(struct MEMO *m, VALUE v)
243
+ {
244
+ RB_OBJ_WRITE(m, &m->v2, v);
245
+ }
246
+
247
+ struct rb_fields {
248
+ struct RBasic basic;
249
+ union {
250
+ struct {
251
+ VALUE fields[1];
252
+ } embed;
253
+ struct {
254
+ VALUE *ptr;
255
+ } external;
256
+ struct {
257
+ // Note: the st_table could be embedded, but complex T_CLASS should be rare to
258
+ // non-existent, so not really worth the trouble.
259
+ st_table *table;
260
+ } complex;
261
+ } as;
262
+ };
263
+
264
+ // IMEMO/fields and T_OBJECT have exactly the same layout.
265
+ // This is useful for JIT and common codepaths.
266
+ #define OBJ_FIELD_HEAP ROBJECT_HEAP
267
+ STATIC_ASSERT(imemo_fields_flags, OBJ_FIELD_HEAP == IMEMO_FL_USER0);
268
+ STATIC_ASSERT(imemo_fields_embed_offset, offsetof(struct RObject, as.ary) == offsetof(struct rb_fields, as.embed.fields));
269
+ STATIC_ASSERT(imemo_fields_embed_offset, offsetof(struct RObject, as.heap.fields) == offsetof(struct rb_fields, as.external.ptr));
270
+ STATIC_ASSERT(imemo_fields_embed_offset, offsetof(struct RObject, as.heap.fields) == offsetof(struct rb_fields, as.complex.table));
271
+
272
+ #define IMEMO_OBJ_FIELDS(fields) ((struct rb_fields *)fields)
273
+
274
+ VALUE rb_imemo_fields_new(VALUE owner, size_t capa, bool shareable);
275
+ VALUE rb_imemo_fields_new_complex(VALUE owner, size_t capa, bool shareable);
276
+ VALUE rb_imemo_fields_new_complex_tbl(VALUE owner, st_table *tbl, bool shareable);
277
+ VALUE rb_imemo_fields_clone(VALUE fields_obj);
278
+ void rb_imemo_fields_clear(VALUE fields_obj);
279
+
280
+ static inline VALUE
281
+ rb_imemo_fields_owner(VALUE fields_obj)
282
+ {
283
+ RUBY_ASSERT(IMEMO_TYPE_P(fields_obj, imemo_fields));
284
+
285
+ return CLASS_OF(fields_obj);
286
+ }
287
+
288
+ static inline VALUE *
289
+ rb_imemo_fields_ptr(VALUE fields_obj)
290
+ {
291
+ if (!fields_obj) {
292
+ return NULL;
293
+ }
294
+
295
+ RUBY_ASSERT(IMEMO_TYPE_P(fields_obj, imemo_fields) || RB_TYPE_P(fields_obj, T_OBJECT));
296
+
297
+ if (UNLIKELY(FL_TEST_RAW(fields_obj, OBJ_FIELD_HEAP))) {
298
+ return IMEMO_OBJ_FIELDS(fields_obj)->as.external.ptr;
299
+ }
300
+ else {
301
+ return IMEMO_OBJ_FIELDS(fields_obj)->as.embed.fields;
302
+ }
303
+ }
304
+
305
+ static inline st_table *
306
+ rb_imemo_fields_complex_tbl(VALUE fields_obj)
307
+ {
308
+ if (!fields_obj) {
309
+ return NULL;
310
+ }
311
+
312
+ RUBY_ASSERT(IMEMO_TYPE_P(fields_obj, imemo_fields) || RB_TYPE_P(fields_obj, T_OBJECT));
313
+ RUBY_ASSERT(FL_TEST_RAW(fields_obj, OBJ_FIELD_HEAP));
314
+
315
+ // Some codepaths unconditionally access the fields_ptr, and assume it can be used as st_table if the
316
+ // shape is too_complex.
317
+ RUBY_ASSERT((st_table *)rb_imemo_fields_ptr(fields_obj) == IMEMO_OBJ_FIELDS(fields_obj)->as.complex.table);
318
+
319
+ return IMEMO_OBJ_FIELDS(fields_obj)->as.complex.table;
320
+ }
321
+
322
+ #endif /* INTERNAL_IMEMO_H */
@@ -0,0 +1,51 @@
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
+ /* box.c */
13
+ void Init_enable_box(void);
14
+ void Init_root_box(void);
15
+
16
+ /* class.c */
17
+ void Init_class_hierarchy(void);
18
+
19
+ /* dmyext.c */
20
+ void Init_enc(void);
21
+ void Init_ext(void);
22
+
23
+ /* file.c */
24
+ void Init_File(void);
25
+
26
+ /* localeinit.c */
27
+ int Init_enc_set_filesystem_encoding(void);
28
+
29
+ /* newline.c */
30
+ void Init_newline(void);
31
+
32
+ /* vm.c */
33
+ void Init_BareVM(void);
34
+ void Init_vm_objects(void);
35
+
36
+ /* vm_backtrace.c */
37
+ void Init_vm_backtrace(void);
38
+
39
+ /* vm_eval.c */
40
+ void Init_vm_eval(void);
41
+
42
+ /* vm_insnhelper.c */
43
+ void Init_vm_stack_canary(void);
44
+
45
+ /* vm_method.c */
46
+ void Init_eval_method(void);
47
+
48
+ /* inits.c */
49
+ void rb_call_inits(void);
50
+
51
+ #endif /* INTERNAL_INITS_H */
@@ -0,0 +1,163 @@
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
+
13
+ #define HAVE_RB_IO_T
14
+ struct rb_io;
15
+
16
+ #include "ruby/io.h" /* for rb_io_t */
17
+ #include "ccan/list/list.h"
18
+ #include "serial.h"
19
+
20
+ #define IO_WITHOUT_GVL(func, arg) rb_nogvl(func, arg, RUBY_UBF_IO, 0, RB_NOGVL_OFFLOAD_SAFE)
21
+ #define IO_WITHOUT_GVL_INT(func, arg) (int)(VALUE)IO_WITHOUT_GVL(func, arg)
22
+
23
+ // Represents an in-flight blocking operation:
24
+ struct rb_io_blocking_operation {
25
+ // The linked list data structure.
26
+ struct ccan_list_node list;
27
+
28
+ // The execution context of the blocking operation.
29
+ struct rb_execution_context_struct *ec;
30
+ };
31
+
32
+ /** Ruby's IO, metadata and buffers. */
33
+ struct rb_io {
34
+
35
+ /** The IO's Ruby level counterpart. */
36
+ VALUE self;
37
+
38
+ /** stdio ptr for read/write, if available. */
39
+ FILE *stdio_file;
40
+
41
+ /** file descriptor. */
42
+ int fd;
43
+
44
+ /** mode flags: FMODE_XXXs */
45
+ enum rb_io_mode mode;
46
+
47
+ /** child's pid (for pipes) */
48
+ rb_pid_t pid;
49
+
50
+ /** number of lines read */
51
+ int lineno;
52
+
53
+ /** pathname for file */
54
+ VALUE pathv;
55
+
56
+ /** finalize proc */
57
+ void (*finalize)(struct rb_io*,int);
58
+
59
+ /** Write buffer. */
60
+ rb_io_buffer_t wbuf;
61
+
62
+ /**
63
+ * (Byte) read buffer. Note also that there is a field called
64
+ * ::rb_io_t::cbuf, which also concerns read IO.
65
+ */
66
+ rb_io_buffer_t rbuf;
67
+
68
+ /**
69
+ * Duplex IO object, if set.
70
+ *
71
+ * @see rb_io_set_write_io()
72
+ */
73
+ VALUE tied_io_for_writing;
74
+
75
+ struct rb_io_encoding encs; /**< Decomposed encoding flags. */
76
+
77
+ /** Encoding converter used when reading from this IO. */
78
+ rb_econv_t *readconv;
79
+
80
+ /**
81
+ * rb_io_ungetc() destination. This buffer is read before checking
82
+ * ::rb_io_t::rbuf
83
+ */
84
+ rb_io_buffer_t cbuf;
85
+
86
+ /** Encoding converter used when writing to this IO. */
87
+ rb_econv_t *writeconv;
88
+
89
+ /**
90
+ * This is, when set, an instance of ::rb_cString which holds the "common"
91
+ * encoding. Write conversion can convert strings twice... In case
92
+ * conversion from encoding X to encoding Y does not exist, Ruby finds an
93
+ * encoding Z that bridges the two, so that X to Z to Y conversion happens.
94
+ */
95
+ VALUE writeconv_asciicompat;
96
+
97
+ /** Whether ::rb_io_t::writeconv is already set up. */
98
+ int writeconv_initialized;
99
+
100
+ /**
101
+ * Value of ::rb_io_t::rb_io_enc_t::ecflags stored right before
102
+ * initialising ::rb_io_t::writeconv.
103
+ */
104
+ int writeconv_pre_ecflags;
105
+
106
+ /**
107
+ * Value of ::rb_io_t::rb_io_enc_t::ecopts stored right before initialising
108
+ * ::rb_io_t::writeconv.
109
+ */
110
+ VALUE writeconv_pre_ecopts;
111
+
112
+ /**
113
+ * This is a Ruby level mutex. It avoids multiple threads to write to an
114
+ * IO at once; helps for instance rb_io_puts() to ensure newlines right
115
+ * next to its arguments.
116
+ *
117
+ * This of course doesn't help inter-process IO interleaves, though.
118
+ */
119
+ VALUE write_lock;
120
+
121
+ /**
122
+ * The timeout associated with this IO when performing blocking operations.
123
+ */
124
+ VALUE timeout;
125
+
126
+ /**
127
+ * Threads that are performing a blocking operation without the GVL using
128
+ * this IO. On calling IO#close, these threads will be interrupted so that
129
+ * the operation can be cancelled.
130
+ */
131
+ struct ccan_list_head blocking_operations;
132
+ struct rb_execution_context_struct *closing_ec;
133
+ VALUE wakeup_mutex;
134
+
135
+ // The fork generation of the blocking operations list.
136
+ rb_serial_t fork_generation;
137
+ };
138
+
139
+ /* io.c */
140
+ void ruby_set_inplace_mode(const char *);
141
+ void rb_stdio_set_default_encoding(void);
142
+ VALUE rb_io_flush_raw(VALUE, int);
143
+ size_t rb_io_memsize(const rb_io_t *);
144
+ int rb_stderr_tty_p(void);
145
+ VALUE rb_io_popen(VALUE pname, VALUE pmode, VALUE env, VALUE opt);
146
+
147
+ VALUE rb_io_prep_stdin(void);
148
+ VALUE rb_io_prep_stdout(void);
149
+ VALUE rb_io_prep_stderr(void);
150
+
151
+ int rb_io_notify_close(struct rb_io *fptr);
152
+
153
+ RUBY_SYMBOL_EXPORT_BEGIN
154
+ /* io.c (export) */
155
+ void rb_maygvl_fd_fix_cloexec(int fd);
156
+ int rb_gc_for_fd(int err);
157
+ void rb_write_error_str(VALUE mesg);
158
+
159
+ VALUE rb_io_blocking_region_wait(struct rb_io *io, rb_blocking_function_t *function, void *argument, enum rb_io_event events);
160
+ VALUE rb_io_blocking_region(struct rb_io *io, rb_blocking_function_t *function, void *argument);
161
+ RUBY_SYMBOL_EXPORT_END
162
+
163
+ #endif /* INTERNAL_IO_H */
@@ -0,0 +1,20 @@
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
+ VALUE rb_load_entrypoint(VALUE args);
16
+ VALUE rb_require_relative_entrypoint(VALUE fname);
17
+ int rb_require_internal(VALUE fname);
18
+ NORETURN(void rb_load_fail(VALUE, const char*));
19
+
20
+ #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,19 @@
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
+ extern void ruby_free_proctitle(void);
17
+ #endif
18
+
19
+ #endif /* INTERNAL_MISSING_H */