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,254 @@
1
+ #ifndef RUBY_METHOD_H
2
+ #define RUBY_METHOD_H 1
3
+ /**********************************************************************
4
+
5
+ method.h -
6
+
7
+ $Author$
8
+ created at: Wed Jul 15 20:02:33 2009
9
+
10
+ Copyright (C) 2009 Koichi Sasada
11
+
12
+ **********************************************************************/
13
+
14
+ #include "internal.h"
15
+ #include "internal/imemo.h"
16
+ #include "internal/compilers.h"
17
+ #include "internal/static_assert.h"
18
+
19
+ #ifndef END_OF_ENUMERATION
20
+ # if defined(__GNUC__) &&! defined(__STRICT_ANSI__)
21
+ # define END_OF_ENUMERATION(key)
22
+ # else
23
+ # define END_OF_ENUMERATION(key) END_OF_##key##_PLACEHOLDER = 0
24
+ # endif
25
+ #endif
26
+
27
+ /* cref */
28
+
29
+ typedef enum {
30
+ METHOD_VISI_UNDEF = 0x00,
31
+ METHOD_VISI_PUBLIC = 0x01,
32
+ METHOD_VISI_PRIVATE = 0x02,
33
+ METHOD_VISI_PROTECTED = 0x03,
34
+
35
+ METHOD_VISI_MASK = 0x03
36
+ } rb_method_visibility_t;
37
+
38
+ typedef struct rb_scope_visi_struct {
39
+ BITFIELD(rb_method_visibility_t, method_visi, 3);
40
+ unsigned int module_func : 1;
41
+ } rb_scope_visibility_t;
42
+
43
+ /*! CREF (Class REFerence) */
44
+ typedef struct rb_cref_struct {
45
+ VALUE flags;
46
+ VALUE refinements;
47
+ VALUE klass_or_self;
48
+ struct rb_cref_struct * next;
49
+ const rb_scope_visibility_t scope_visi;
50
+ } rb_cref_t;
51
+
52
+ /* method data type */
53
+
54
+ typedef struct rb_method_entry_struct {
55
+ VALUE flags;
56
+ VALUE defined_class;
57
+ struct rb_method_definition_struct * const def;
58
+ ID called_id;
59
+ VALUE owner;
60
+ } rb_method_entry_t;
61
+
62
+ typedef struct rb_callable_method_entry_struct { /* same fields with rb_method_entry_t */
63
+ VALUE flags;
64
+ const VALUE defined_class;
65
+ struct rb_method_definition_struct * const def;
66
+ ID called_id;
67
+ const VALUE owner;
68
+ } rb_callable_method_entry_t;
69
+
70
+ #define METHOD_ENTRY_VISI(me) (rb_method_visibility_t)(((me)->flags & (IMEMO_FL_USER0 | IMEMO_FL_USER1)) >> (IMEMO_FL_USHIFT+0))
71
+ #define METHOD_ENTRY_BASIC(me) (int) (((me)->flags & (IMEMO_FL_USER2 )) >> (IMEMO_FL_USHIFT+2))
72
+ #define METHOD_ENTRY_COMPLEMENTED(me) ((me)->flags & IMEMO_FL_USER3)
73
+ #define METHOD_ENTRY_COMPLEMENTED_SET(me) ((me)->flags |= IMEMO_FL_USER3)
74
+ #define METHOD_ENTRY_CACHED(me) ((me)->flags & IMEMO_FL_USER4)
75
+ #define METHOD_ENTRY_CACHED_SET(me) ((me)->flags |= IMEMO_FL_USER4)
76
+ #define METHOD_ENTRY_INVALIDATED(me) ((me)->flags & IMEMO_FL_USER5)
77
+ #define METHOD_ENTRY_INVALIDATED_SET(me) ((me)->flags |= IMEMO_FL_USER5)
78
+
79
+ static inline void
80
+ METHOD_ENTRY_VISI_SET(rb_method_entry_t *me, rb_method_visibility_t visi)
81
+ {
82
+ VM_ASSERT((int)visi >= 0 && visi <= 3);
83
+ me->flags = (me->flags & ~(IMEMO_FL_USER0 | IMEMO_FL_USER1)) | (visi << (IMEMO_FL_USHIFT+0));
84
+ }
85
+ static inline void
86
+ METHOD_ENTRY_BASIC_SET(rb_method_entry_t *me, unsigned int basic)
87
+ {
88
+ VM_ASSERT(basic <= 1);
89
+ me->flags = (me->flags & ~(IMEMO_FL_USER2 )) | (basic << (IMEMO_FL_USHIFT+2));
90
+ }
91
+ static inline void
92
+ METHOD_ENTRY_FLAGS_SET(rb_method_entry_t *me, rb_method_visibility_t visi, unsigned int basic)
93
+ {
94
+ VM_ASSERT((int)visi >= 0 && visi <= 3);
95
+ VM_ASSERT(basic <= 1);
96
+ me->flags =
97
+ (me->flags & ~(IMEMO_FL_USER0|IMEMO_FL_USER1|IMEMO_FL_USER2)) |
98
+ ((visi << (IMEMO_FL_USHIFT+0)) | (basic << (IMEMO_FL_USHIFT+2)));
99
+ }
100
+ static inline void
101
+ METHOD_ENTRY_FLAGS_COPY(rb_method_entry_t *dst, const rb_method_entry_t *src)
102
+ {
103
+ dst->flags =
104
+ (dst->flags & ~(IMEMO_FL_USER0|IMEMO_FL_USER1|IMEMO_FL_USER2)) |
105
+ (src->flags & (IMEMO_FL_USER0|IMEMO_FL_USER1|IMEMO_FL_USER2));
106
+ }
107
+
108
+ typedef enum {
109
+ VM_METHOD_TYPE_ISEQ, /*!< Ruby method */
110
+ VM_METHOD_TYPE_CFUNC, /*!< C method */
111
+ VM_METHOD_TYPE_ATTRSET, /*!< attr_writer or attr_accessor */
112
+ VM_METHOD_TYPE_IVAR, /*!< attr_reader or attr_accessor */
113
+ VM_METHOD_TYPE_BMETHOD,
114
+ VM_METHOD_TYPE_ZSUPER,
115
+ VM_METHOD_TYPE_ALIAS,
116
+ VM_METHOD_TYPE_UNDEF,
117
+ VM_METHOD_TYPE_NOTIMPLEMENTED,
118
+ VM_METHOD_TYPE_OPTIMIZED, /*!< Kernel#send, Proc#call, etc */
119
+ VM_METHOD_TYPE_MISSING, /*!< wrapper for method_missing(id) */
120
+ VM_METHOD_TYPE_REFINED, /*!< refinement */
121
+
122
+ END_OF_ENUMERATION(VM_METHOD_TYPE)
123
+ } rb_method_type_t;
124
+ #define VM_METHOD_TYPE_MINIMUM_BITS 4
125
+ STATIC_ASSERT(VM_METHOD_TYPE_MINIMUM_BITS,
126
+ VM_METHOD_TYPE_REFINED <= (1<<VM_METHOD_TYPE_MINIMUM_BITS));
127
+
128
+ #ifndef rb_iseq_t
129
+ typedef struct rb_iseq_struct rb_iseq_t;
130
+ #define rb_iseq_t rb_iseq_t
131
+ #endif
132
+
133
+ typedef struct rb_method_iseq_struct {
134
+ const rb_iseq_t * iseqptr; /*!< iseq pointer, should be separated from iseqval */
135
+ rb_cref_t * cref; /*!< class reference, should be marked */
136
+ } rb_method_iseq_t; /* check rb_add_method_iseq() when modify the fields */
137
+
138
+ typedef struct rb_method_cfunc_struct {
139
+ VALUE (*func)(ANYARGS);
140
+ VALUE (*invoker)(VALUE recv, int argc, const VALUE *argv, VALUE (*func)(ANYARGS));
141
+ int argc;
142
+ } rb_method_cfunc_t;
143
+
144
+ typedef struct rb_method_attr_struct {
145
+ ID id;
146
+ VALUE location; /* should be marked */
147
+ } rb_method_attr_t;
148
+
149
+ typedef struct rb_method_alias_struct {
150
+ struct rb_method_entry_struct * original_me; /* original_me->klass is original owner */
151
+ } rb_method_alias_t;
152
+
153
+ typedef struct rb_method_refined_struct {
154
+ struct rb_method_entry_struct * orig_me;
155
+ VALUE owner;
156
+ } rb_method_refined_t;
157
+
158
+ typedef struct rb_method_bmethod_struct {
159
+ VALUE proc; /* should be marked */
160
+ struct rb_hook_list_struct *hooks;
161
+ VALUE defined_ractor;
162
+ } rb_method_bmethod_t;
163
+
164
+ enum method_optimized_type {
165
+ OPTIMIZED_METHOD_TYPE_SEND,
166
+ OPTIMIZED_METHOD_TYPE_CALL,
167
+ OPTIMIZED_METHOD_TYPE_BLOCK_CALL,
168
+ OPTIMIZED_METHOD_TYPE_STRUCT_AREF,
169
+ OPTIMIZED_METHOD_TYPE_STRUCT_ASET,
170
+ OPTIMIZED_METHOD_TYPE__MAX
171
+ };
172
+
173
+ typedef struct rb_method_optimized {
174
+ enum method_optimized_type type;
175
+ unsigned int index;
176
+ } rb_method_optimized_t;
177
+
178
+ struct rb_method_definition_struct {
179
+ BITFIELD(rb_method_type_t, type, VM_METHOD_TYPE_MINIMUM_BITS);
180
+ unsigned int iseq_overload: 1;
181
+ int alias_count : 27;
182
+ int complemented_count : 28;
183
+ unsigned int no_redef_warning: 1;
184
+
185
+ union {
186
+ rb_method_iseq_t iseq;
187
+ rb_method_cfunc_t cfunc;
188
+ rb_method_attr_t attr;
189
+ rb_method_alias_t alias;
190
+ rb_method_refined_t refined;
191
+ rb_method_bmethod_t bmethod;
192
+ rb_method_optimized_t optimized;
193
+ } body;
194
+
195
+ ID original_id;
196
+ uintptr_t method_serial;
197
+ };
198
+
199
+ struct rb_id_table;
200
+
201
+ typedef struct rb_method_definition_struct rb_method_definition_t;
202
+ STATIC_ASSERT(sizeof_method_def, offsetof(rb_method_definition_t, body)==8);
203
+
204
+ #define UNDEFINED_METHOD_ENTRY_P(me) (!(me) || !(me)->def || (me)->def->type == VM_METHOD_TYPE_UNDEF)
205
+ #define UNDEFINED_REFINED_METHOD_P(def) \
206
+ ((def)->type == VM_METHOD_TYPE_REFINED && \
207
+ UNDEFINED_METHOD_ENTRY_P((def)->body.refined.orig_me))
208
+
209
+ void rb_add_method(VALUE klass, ID mid, rb_method_type_t type, void *option, rb_method_visibility_t visi);
210
+ void rb_add_method_cfunc(VALUE klass, ID mid, VALUE (*func)(ANYARGS), int argc, rb_method_visibility_t visi);
211
+ void rb_add_method_iseq(VALUE klass, ID mid, const rb_iseq_t *iseq, rb_cref_t *cref, rb_method_visibility_t visi);
212
+ void rb_add_method_optimized(VALUE klass, ID mid, enum method_optimized_type, unsigned int index, rb_method_visibility_t visi);
213
+ void rb_add_refined_method_entry(VALUE refined_class, ID mid);
214
+
215
+ rb_method_entry_t *rb_method_entry_set(VALUE klass, ID mid, const rb_method_entry_t *, rb_method_visibility_t noex);
216
+ rb_method_entry_t *rb_method_entry_create(ID called_id, VALUE klass, rb_method_visibility_t visi, const rb_method_definition_t *def);
217
+
218
+ const rb_method_entry_t *rb_method_entry_at(VALUE obj, ID id);
219
+
220
+ const rb_method_entry_t *rb_method_entry(VALUE klass, ID id);
221
+ const rb_method_entry_t *rb_method_entry_with_refinements(VALUE klass, ID id, VALUE *defined_class);
222
+ const rb_method_entry_t *rb_method_entry_without_refinements(VALUE klass, ID id, VALUE *defined_class);
223
+ const rb_method_entry_t *rb_resolve_refined_method(VALUE refinements, const rb_method_entry_t *me);
224
+ RUBY_SYMBOL_EXPORT_BEGIN
225
+ const rb_method_entry_t *rb_resolve_me_location(const rb_method_entry_t *, VALUE[5]);
226
+ RUBY_SYMBOL_EXPORT_END
227
+
228
+ const rb_callable_method_entry_t *rb_callable_method_entry(VALUE klass, ID id);
229
+ const rb_callable_method_entry_t *rb_callable_method_entry_or_negative(VALUE klass, ID id);
230
+ const rb_callable_method_entry_t *rb_callable_method_entry_with_refinements(VALUE klass, ID id, VALUE *defined_class);
231
+ const rb_callable_method_entry_t *rb_callable_method_entry_without_refinements(VALUE klass, ID id, VALUE *defined_class);
232
+
233
+ int rb_method_entry_arity(const rb_method_entry_t *me);
234
+ int rb_method_entry_eq(const rb_method_entry_t *m1, const rb_method_entry_t *m2);
235
+ st_index_t rb_hash_method_entry(st_index_t hash, const rb_method_entry_t *me);
236
+
237
+ VALUE rb_method_entry_location(const rb_method_entry_t *me);
238
+
239
+ void rb_free_method_entry(const rb_method_entry_t *me);
240
+
241
+ const rb_method_entry_t *rb_method_entry_clone(const rb_method_entry_t *me);
242
+ const rb_callable_method_entry_t *rb_method_entry_complement_defined_class(const rb_method_entry_t *src_me, ID called_id, VALUE defined_class);
243
+ void rb_method_entry_copy(rb_method_entry_t *dst, const rb_method_entry_t *src);
244
+
245
+ void rb_method_table_insert(VALUE klass, struct rb_id_table *table, ID method_id, const rb_method_entry_t *me);
246
+
247
+ void rb_scope_visibility_set(rb_method_visibility_t);
248
+
249
+ VALUE rb_unnamed_parameters(int arity);
250
+
251
+ void rb_clear_method_cache(VALUE klass_or_module, ID mid);
252
+ void rb_clear_method_cache_all(void);
253
+
254
+ #endif /* RUBY_METHOD_H */
@@ -0,0 +1,132 @@
1
+ #ifndef RUBY_MJIT_H
2
+ #define RUBY_MJIT_H 1
3
+ /**********************************************************************
4
+
5
+ mjit.h - Interface to MRI method JIT compiler for Ruby's main thread
6
+
7
+ Copyright (C) 2017 Vladimir Makarov <vmakarov@redhat.com>.
8
+
9
+ **********************************************************************/
10
+
11
+ #include "ruby/internal/config.h" // defines USE_MJIT
12
+ #include "ruby/internal/stdbool.h"
13
+ #include "vm_core.h"
14
+
15
+ # if USE_MJIT
16
+
17
+ #include "debug_counter.h"
18
+ #include "ruby.h"
19
+ #include "vm_core.h"
20
+
21
+ // Special address values of a function generated from the
22
+ // corresponding iseq by MJIT:
23
+ enum rb_mjit_iseq_func {
24
+ // ISEQ has never been enqueued to unit_queue yet
25
+ NOT_ADDED_JIT_ISEQ_FUNC = 0,
26
+ // ISEQ is already queued for the machine code generation but the
27
+ // code is not ready yet for the execution
28
+ NOT_READY_JIT_ISEQ_FUNC = 1,
29
+ // ISEQ included not compilable insn, some internal assertion failed
30
+ // or the unit is unloaded
31
+ NOT_COMPILED_JIT_ISEQ_FUNC = 2,
32
+ // End mark
33
+ LAST_JIT_ISEQ_FUNC = 3
34
+ };
35
+
36
+ // MJIT options which can be defined on the MRI command line.
37
+ struct mjit_options {
38
+ // Converted from "jit" feature flag to tell the enablement
39
+ // information to ruby_show_version().
40
+ bool on;
41
+ // Save temporary files after MRI finish. The temporary files
42
+ // include the pre-compiled header, C code file generated for ISEQ,
43
+ // and the corresponding object file.
44
+ bool save_temps;
45
+ // Print MJIT warnings to stderr.
46
+ bool warnings;
47
+ // Disable compiler optimization and add debug symbols. It can be
48
+ // very slow.
49
+ bool debug;
50
+ // Add arbitrary cflags.
51
+ char* debug_flags;
52
+ // If true, all ISeqs are synchronously compiled. For testing.
53
+ bool wait;
54
+ // Number of calls to trigger JIT compilation. For testing.
55
+ unsigned int min_calls;
56
+ // Force printing info about MJIT work of level VERBOSE or
57
+ // less. 0=silence, 1=medium, 2=verbose.
58
+ int verbose;
59
+ // Maximal permitted number of iseq JIT codes in a MJIT memory
60
+ // cache.
61
+ int max_cache_size;
62
+ // [experimental] Do not start MJIT until MJIT.resume is called.
63
+ bool pause;
64
+ // [experimental] Call custom RubyVM::MJIT.compile instead of MJIT.
65
+ bool custom;
66
+ };
67
+
68
+ // State of optimization switches
69
+ struct rb_mjit_compile_info {
70
+ // Disable getinstancevariable/setinstancevariable optimizations based on inline cache (T_OBJECT)
71
+ bool disable_ivar_cache;
72
+ // Disable getinstancevariable/setinstancevariable optimizations based on inline cache (FL_EXIVAR)
73
+ bool disable_exivar_cache;
74
+ // Disable send/opt_send_without_block optimizations based on inline cache
75
+ bool disable_send_cache;
76
+ // Disable method inlining
77
+ bool disable_inlining;
78
+ // Disable opt_getinlinecache inlining
79
+ bool disable_const_cache;
80
+ };
81
+
82
+ typedef VALUE (*mjit_func_t)(rb_execution_context_t *, rb_control_frame_t *);
83
+
84
+ RUBY_SYMBOL_EXPORT_BEGIN
85
+ RUBY_EXTERN struct mjit_options mjit_opts;
86
+ RUBY_EXTERN bool mjit_call_p;
87
+
88
+ extern void rb_mjit_add_iseq_to_process(const rb_iseq_t *iseq);
89
+ extern VALUE rb_mjit_wait_call(rb_execution_context_t *ec, struct rb_iseq_constant_body *body);
90
+ extern struct rb_mjit_compile_info* rb_mjit_iseq_compile_info(const struct rb_iseq_constant_body *body);
91
+ extern void rb_mjit_recompile_send(const rb_iseq_t *iseq);
92
+ extern void rb_mjit_recompile_ivar(const rb_iseq_t *iseq);
93
+ extern void rb_mjit_recompile_exivar(const rb_iseq_t *iseq);
94
+ extern void rb_mjit_recompile_inlining(const rb_iseq_t *iseq);
95
+ extern void rb_mjit_recompile_const(const rb_iseq_t *iseq);
96
+ RUBY_SYMBOL_EXPORT_END
97
+
98
+ extern void mjit_cancel_all(const char *reason);
99
+ extern bool mjit_compile(FILE *f, const rb_iseq_t *iseq, const char *funcname, int id);
100
+ extern void mjit_init(const struct mjit_options *opts);
101
+ extern void mjit_free_iseq(const rb_iseq_t *iseq);
102
+ extern void mjit_update_references(const rb_iseq_t *iseq);
103
+ extern void mjit_mark(void);
104
+ extern void mjit_mark_cc_entries(const struct rb_iseq_constant_body *const body);
105
+ extern void mjit_notify_waitpid(int exit_code);
106
+
107
+ void mjit_child_after_fork(void);
108
+
109
+ # ifdef MJIT_HEADER
110
+ #define mjit_enabled true
111
+ # else // MJIT_HEADER
112
+ extern bool mjit_enabled;
113
+ # endif // MJIT_HEADER
114
+ VALUE mjit_pause(bool wait_p);
115
+ VALUE mjit_resume(void);
116
+ void mjit_finish(bool close_handle_p);
117
+
118
+ # else // USE_MJIT
119
+
120
+ static inline void mjit_cancel_all(const char *reason){}
121
+ static inline void mjit_free_iseq(const rb_iseq_t *iseq){}
122
+ static inline void mjit_mark(void){}
123
+ static inline VALUE jit_exec(rb_execution_context_t *ec) { return Qundef; /* unreachable */ }
124
+ static inline void mjit_child_after_fork(void){}
125
+
126
+ #define mjit_enabled false
127
+ static inline VALUE mjit_pause(bool wait_p){ return Qnil; } // unreachable
128
+ static inline VALUE mjit_resume(void){ return Qnil; } // unreachable
129
+ static inline void mjit_finish(bool close_handle_p){}
130
+
131
+ # endif // USE_MJIT
132
+ #endif // RUBY_MJIT_H