debase-ruby_core_source 3.2.0 → 3.2.1

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 (118) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/CHANGELOG.md +5 -0
  4. data/lib/debase/ruby_core_source/ruby-3.3.0-preview1/addr2line.h +20 -0
  5. data/lib/debase/ruby_core_source/ruby-3.3.0-preview1/builtin.h +117 -0
  6. data/lib/debase/ruby_core_source/ruby-3.3.0-preview1/ccan/build_assert/build_assert.h +40 -0
  7. data/lib/debase/ruby_core_source/ruby-3.3.0-preview1/ccan/check_type/check_type.h +63 -0
  8. data/lib/debase/ruby_core_source/ruby-3.3.0-preview1/ccan/container_of/container_of.h +142 -0
  9. data/lib/debase/ruby_core_source/ruby-3.3.0-preview1/ccan/list/list.h +789 -0
  10. data/lib/debase/ruby_core_source/ruby-3.3.0-preview1/ccan/str/str.h +17 -0
  11. data/lib/debase/ruby_core_source/ruby-3.3.0-preview1/constant.h +53 -0
  12. data/lib/debase/ruby_core_source/ruby-3.3.0-preview1/darray.h +179 -0
  13. data/lib/debase/ruby_core_source/ruby-3.3.0-preview1/debug_counter.h +426 -0
  14. data/lib/debase/ruby_core_source/ruby-3.3.0-preview1/dln.h +31 -0
  15. data/lib/debase/ruby_core_source/ruby-3.3.0-preview1/encindex.h +70 -0
  16. data/lib/debase/ruby_core_source/ruby-3.3.0-preview1/eval_intern.h +339 -0
  17. data/lib/debase/ruby_core_source/ruby-3.3.0-preview1/hrtime.h +227 -0
  18. data/lib/debase/ruby_core_source/ruby-3.3.0-preview1/id.h +299 -0
  19. data/lib/debase/ruby_core_source/ruby-3.3.0-preview1/id_table.h +39 -0
  20. data/lib/debase/ruby_core_source/ruby-3.3.0-preview1/insns.inc +249 -0
  21. data/lib/debase/ruby_core_source/ruby-3.3.0-preview1/insns_info.inc +9159 -0
  22. data/lib/debase/ruby_core_source/ruby-3.3.0-preview1/internal/array.h +162 -0
  23. data/lib/debase/ruby_core_source/ruby-3.3.0-preview1/internal/basic_operators.h +63 -0
  24. data/lib/debase/ruby_core_source/ruby-3.3.0-preview1/internal/bignum.h +244 -0
  25. data/lib/debase/ruby_core_source/ruby-3.3.0-preview1/internal/bits.h +564 -0
  26. data/lib/debase/ruby_core_source/ruby-3.3.0-preview1/internal/class.h +221 -0
  27. data/lib/debase/ruby_core_source/ruby-3.3.0-preview1/internal/cmdlineopt.h +61 -0
  28. data/lib/debase/ruby_core_source/ruby-3.3.0-preview1/internal/compar.h +29 -0
  29. data/lib/debase/ruby_core_source/ruby-3.3.0-preview1/internal/compile.h +35 -0
  30. data/lib/debase/ruby_core_source/ruby-3.3.0-preview1/internal/compilers.h +107 -0
  31. data/lib/debase/ruby_core_source/ruby-3.3.0-preview1/internal/complex.h +29 -0
  32. data/lib/debase/ruby_core_source/ruby-3.3.0-preview1/internal/cont.h +32 -0
  33. data/lib/debase/ruby_core_source/ruby-3.3.0-preview1/internal/dir.h +16 -0
  34. data/lib/debase/ruby_core_source/ruby-3.3.0-preview1/internal/enc.h +19 -0
  35. data/lib/debase/ruby_core_source/ruby-3.3.0-preview1/internal/encoding.h +32 -0
  36. data/lib/debase/ruby_core_source/ruby-3.3.0-preview1/internal/enum.h +18 -0
  37. data/lib/debase/ruby_core_source/ruby-3.3.0-preview1/internal/enumerator.h +21 -0
  38. data/lib/debase/ruby_core_source/ruby-3.3.0-preview1/internal/error.h +191 -0
  39. data/lib/debase/ruby_core_source/ruby-3.3.0-preview1/internal/eval.h +32 -0
  40. data/lib/debase/ruby_core_source/ruby-3.3.0-preview1/internal/file.h +38 -0
  41. data/lib/debase/ruby_core_source/ruby-3.3.0-preview1/internal/fixnum.h +184 -0
  42. data/lib/debase/ruby_core_source/ruby-3.3.0-preview1/internal/gc.h +333 -0
  43. data/lib/debase/ruby_core_source/ruby-3.3.0-preview1/internal/hash.h +216 -0
  44. data/lib/debase/ruby_core_source/ruby-3.3.0-preview1/internal/imemo.h +241 -0
  45. data/lib/debase/ruby_core_source/ruby-3.3.0-preview1/internal/inits.h +50 -0
  46. data/lib/debase/ruby_core_source/ruby-3.3.0-preview1/internal/io.h +38 -0
  47. data/lib/debase/ruby_core_source/ruby-3.3.0-preview1/internal/load.h +18 -0
  48. data/lib/debase/ruby_core_source/ruby-3.3.0-preview1/internal/loadpath.h +16 -0
  49. data/lib/debase/ruby_core_source/ruby-3.3.0-preview1/internal/math.h +23 -0
  50. data/lib/debase/ruby_core_source/ruby-3.3.0-preview1/internal/missing.h +18 -0
  51. data/lib/debase/ruby_core_source/ruby-3.3.0-preview1/internal/numeric.h +273 -0
  52. data/lib/debase/ruby_core_source/ruby-3.3.0-preview1/internal/object.h +59 -0
  53. data/lib/debase/ruby_core_source/ruby-3.3.0-preview1/internal/parse.h +25 -0
  54. data/lib/debase/ruby_core_source/ruby-3.3.0-preview1/internal/proc.h +30 -0
  55. data/lib/debase/ruby_core_source/ruby-3.3.0-preview1/internal/process.h +138 -0
  56. data/lib/debase/ruby_core_source/ruby-3.3.0-preview1/internal/ractor.h +6 -0
  57. data/lib/debase/ruby_core_source/ruby-3.3.0-preview1/internal/random.h +16 -0
  58. data/lib/debase/ruby_core_source/ruby-3.3.0-preview1/internal/range.h +40 -0
  59. data/lib/debase/ruby_core_source/ruby-3.3.0-preview1/internal/rational.h +71 -0
  60. data/lib/debase/ruby_core_source/ruby-3.3.0-preview1/internal/re.h +28 -0
  61. data/lib/debase/ruby_core_source/ruby-3.3.0-preview1/internal/sanitizers.h +186 -0
  62. data/lib/debase/ruby_core_source/ruby-3.3.0-preview1/internal/serial.h +23 -0
  63. data/lib/debase/ruby_core_source/ruby-3.3.0-preview1/internal/signal.h +21 -0
  64. data/lib/debase/ruby_core_source/ruby-3.3.0-preview1/internal/static_assert.h +16 -0
  65. data/lib/debase/ruby_core_source/ruby-3.3.0-preview1/internal/string.h +145 -0
  66. data/lib/debase/ruby_core_source/ruby-3.3.0-preview1/internal/struct.h +152 -0
  67. data/lib/debase/ruby_core_source/ruby-3.3.0-preview1/internal/symbol.h +42 -0
  68. data/lib/debase/ruby_core_source/ruby-3.3.0-preview1/internal/thread.h +61 -0
  69. data/lib/debase/ruby_core_source/ruby-3.3.0-preview1/internal/time.h +34 -0
  70. data/lib/debase/ruby_core_source/ruby-3.3.0-preview1/internal/transcode.h +20 -0
  71. data/lib/debase/ruby_core_source/ruby-3.3.0-preview1/internal/util.h +27 -0
  72. data/lib/debase/ruby_core_source/ruby-3.3.0-preview1/internal/variable.h +88 -0
  73. data/lib/debase/ruby_core_source/ruby-3.3.0-preview1/internal/vm.h +124 -0
  74. data/lib/debase/ruby_core_source/ruby-3.3.0-preview1/internal/warnings.h +16 -0
  75. data/lib/debase/ruby_core_source/ruby-3.3.0-preview1/internal.h +112 -0
  76. data/lib/debase/ruby_core_source/ruby-3.3.0-preview1/iseq.h +334 -0
  77. data/lib/debase/ruby_core_source/ruby-3.3.0-preview1/known_errors.inc +791 -0
  78. data/lib/debase/ruby_core_source/ruby-3.3.0-preview1/method.h +254 -0
  79. data/lib/debase/ruby_core_source/ruby-3.3.0-preview1/node.h +514 -0
  80. data/lib/debase/ruby_core_source/ruby-3.3.0-preview1/node_name.inc +210 -0
  81. data/lib/debase/ruby_core_source/ruby-3.3.0-preview1/opt_sc.inc +109 -0
  82. data/lib/debase/ruby_core_source/ruby-3.3.0-preview1/optinsn.inc +128 -0
  83. data/lib/debase/ruby_core_source/ruby-3.3.0-preview1/optunifs.inc +43 -0
  84. data/lib/debase/ruby_core_source/ruby-3.3.0-preview1/parse.h +230 -0
  85. data/lib/debase/ruby_core_source/ruby-3.3.0-preview1/probes_helper.h +42 -0
  86. data/lib/debase/ruby_core_source/ruby-3.3.0-preview1/ractor_core.h +387 -0
  87. data/lib/debase/ruby_core_source/ruby-3.3.0-preview1/regenc.h +254 -0
  88. data/lib/debase/ruby_core_source/ruby-3.3.0-preview1/regint.h +996 -0
  89. data/lib/debase/ruby_core_source/ruby-3.3.0-preview1/regparse.h +370 -0
  90. data/lib/debase/ruby_core_source/ruby-3.3.0-preview1/revision.h +5 -0
  91. data/lib/debase/ruby_core_source/ruby-3.3.0-preview1/rjit.h +103 -0
  92. data/lib/debase/ruby_core_source/ruby-3.3.0-preview1/rjit_c.h +165 -0
  93. data/lib/debase/ruby_core_source/ruby-3.3.0-preview1/ruby_assert.h +14 -0
  94. data/lib/debase/ruby_core_source/ruby-3.3.0-preview1/ruby_atomic.h +23 -0
  95. data/lib/debase/ruby_core_source/ruby-3.3.0-preview1/shape.h +232 -0
  96. data/lib/debase/ruby_core_source/ruby-3.3.0-preview1/siphash.h +48 -0
  97. data/lib/debase/ruby_core_source/ruby-3.3.0-preview1/symbol.h +119 -0
  98. data/lib/debase/ruby_core_source/ruby-3.3.0-preview1/thread_none.h +20 -0
  99. data/lib/debase/ruby_core_source/ruby-3.3.0-preview1/thread_pthread.h +128 -0
  100. data/lib/debase/ruby_core_source/ruby-3.3.0-preview1/thread_win32.h +63 -0
  101. data/lib/debase/ruby_core_source/ruby-3.3.0-preview1/timev.h +58 -0
  102. data/lib/debase/ruby_core_source/ruby-3.3.0-preview1/transcode_data.h +138 -0
  103. data/lib/debase/ruby_core_source/ruby-3.3.0-preview1/transient_heap.h +65 -0
  104. data/lib/debase/ruby_core_source/ruby-3.3.0-preview1/variable.h +30 -0
  105. data/lib/debase/ruby_core_source/ruby-3.3.0-preview1/version.h +65 -0
  106. data/lib/debase/ruby_core_source/ruby-3.3.0-preview1/vm.inc +5497 -0
  107. data/lib/debase/ruby_core_source/ruby-3.3.0-preview1/vm_call_iseq_optimized.inc +244 -0
  108. data/lib/debase/ruby_core_source/ruby-3.3.0-preview1/vm_callinfo.h +574 -0
  109. data/lib/debase/ruby_core_source/ruby-3.3.0-preview1/vm_core.h +2107 -0
  110. data/lib/debase/ruby_core_source/ruby-3.3.0-preview1/vm_debug.h +122 -0
  111. data/lib/debase/ruby_core_source/ruby-3.3.0-preview1/vm_exec.h +198 -0
  112. data/lib/debase/ruby_core_source/ruby-3.3.0-preview1/vm_insnhelper.h +274 -0
  113. data/lib/debase/ruby_core_source/ruby-3.3.0-preview1/vm_opts.h +72 -0
  114. data/lib/debase/ruby_core_source/ruby-3.3.0-preview1/vm_sync.h +137 -0
  115. data/lib/debase/ruby_core_source/ruby-3.3.0-preview1/vmtc.inc +243 -0
  116. data/lib/debase/ruby_core_source/ruby-3.3.0-preview1/yjit.h +72 -0
  117. data/lib/debase/ruby_core_source/version.rb +1 -1
  118. metadata +116 -3
@@ -0,0 +1,17 @@
1
+ /* CC0 (Public domain) - see ccan/licenses/CC0 file for details */
2
+ #ifndef CCAN_STR_H
3
+ #define CCAN_STR_H
4
+ /**
5
+ * ccan_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!", ccan_stringify(cond)))
11
+ */
12
+ #define stringify(expr) ccan_stringify_1(expr)
13
+ #define ccan_stringify(expr) ccan_stringify_1(expr)
14
+ /* Double-indirection required to stringify expansions */
15
+ #define ccan_stringify_1(expr) #expr
16
+
17
+ #endif /* CCAN_STR_H */
@@ -0,0 +1,53 @@
1
+ #ifndef CONSTANT_H
2
+ #define CONSTANT_H
3
+ /**********************************************************************
4
+
5
+ constant.h -
6
+
7
+ $Author$
8
+ created at: Sun Nov 15 00:09:33 2009
9
+
10
+ Copyright (C) 2009 Yusuke Endoh
11
+
12
+ **********************************************************************/
13
+ #include "ruby/ruby.h"
14
+ #include "id_table.h"
15
+
16
+ typedef enum {
17
+ CONST_DEPRECATED = 0x100,
18
+
19
+ CONST_VISIBILITY_MASK = 0xff,
20
+ CONST_PUBLIC = 0x00,
21
+ CONST_PRIVATE,
22
+ CONST_VISIBILITY_MAX
23
+ } rb_const_flag_t;
24
+
25
+ #define RB_CONST_PRIVATE_P(ce) \
26
+ (((ce)->flag & CONST_VISIBILITY_MASK) == CONST_PRIVATE)
27
+ #define RB_CONST_PUBLIC_P(ce) \
28
+ (((ce)->flag & CONST_VISIBILITY_MASK) == CONST_PUBLIC)
29
+
30
+ #define RB_CONST_DEPRECATED_P(ce) \
31
+ ((ce)->flag & CONST_DEPRECATED)
32
+
33
+ typedef struct rb_const_entry_struct {
34
+ rb_const_flag_t flag;
35
+ int line;
36
+ VALUE value; /* should be mark */
37
+ VALUE file; /* should be mark */
38
+ } rb_const_entry_t;
39
+
40
+ VALUE rb_mod_private_constant(int argc, const VALUE *argv, VALUE obj);
41
+ VALUE rb_mod_public_constant(int argc, const VALUE *argv, VALUE obj);
42
+ VALUE rb_mod_deprecate_constant(int argc, const VALUE *argv, VALUE obj);
43
+ void rb_free_const_table(struct rb_id_table *tbl);
44
+ VALUE rb_const_source_location(VALUE, ID);
45
+
46
+ int rb_autoloading_value(VALUE mod, ID id, VALUE *value, rb_const_flag_t *flag);
47
+ rb_const_entry_t *rb_const_lookup(VALUE klass, ID id);
48
+ VALUE rb_public_const_get_at(VALUE klass, ID id);
49
+ VALUE rb_public_const_get_from(VALUE klass, ID id);
50
+ int rb_public_const_defined_from(VALUE klass, ID id);
51
+ VALUE rb_const_source_location_at(VALUE, ID);
52
+
53
+ #endif /* CONSTANT_H */
@@ -0,0 +1,179 @@
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
+ // rb_darray_append(&char_array, 'e');
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, size_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, size_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, size_t idx);
37
+ //
38
+ #define rb_darray_ref(ary, idx) (&((ary)->data[(idx)]))
39
+
40
+ // Copy a new element into the array. ptr_to_ary is evaluated multiple times.
41
+ //
42
+ // void rb_darray_append(rb_darray(T) *ptr_to_ary, T element);
43
+ //
44
+ #define rb_darray_append(ptr_to_ary, element) do { \
45
+ rb_darray_ensure_space((ptr_to_ary), sizeof(**(ptr_to_ary)), \
46
+ 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
+ } while (0)
52
+
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 (size_t 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 indices in the array in a for loop
74
+ //
75
+ #define rb_darray_for(ary, idx_name) \
76
+ for (size_t 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
+ //
80
+ // Note that NULL is a valid empty dynamic array.
81
+ //
82
+ // void rb_darray_make(rb_darray(T) *ptr_to_ary, size_t size);
83
+ //
84
+ #define rb_darray_make(ptr_to_ary, size) \
85
+ rb_darray_make_impl((ptr_to_ary), size, sizeof(**(ptr_to_ary)), \
86
+ sizeof((*(ptr_to_ary))->data[0]))
87
+
88
+ #define rb_darray_data_ptr(ary) ((ary)->data)
89
+
90
+ // Set the size of the array to zero without freeing the backing memory.
91
+ // Allows reusing the same array.
92
+ //
93
+ #define rb_darray_clear(ary) (ary->meta.size = 0)
94
+
95
+ typedef struct rb_darray_meta {
96
+ size_t size;
97
+ size_t capa;
98
+ } rb_darray_meta_t;
99
+
100
+ // Get the size of the dynamic array.
101
+ //
102
+ static inline size_t
103
+ rb_darray_size(const void *ary)
104
+ {
105
+ const rb_darray_meta_t *meta = ary;
106
+ return meta ? meta->size : 0;
107
+ }
108
+
109
+ // Get the capacity of the dynamic array.
110
+ //
111
+ static inline size_t
112
+ rb_darray_capa(const void *ary)
113
+ {
114
+ const rb_darray_meta_t *meta = ary;
115
+ return meta ? meta->capa : 0;
116
+ }
117
+
118
+ // Free the dynamic array.
119
+ //
120
+ static inline void
121
+ rb_darray_free(void *ary)
122
+ {
123
+ rb_darray_meta_t *meta = ary;
124
+ ruby_sized_xfree(ary, meta->capa);
125
+ }
126
+
127
+ // Internal function
128
+ // Ensure there is space for one more element.
129
+ // Note: header_size can be bigger than sizeof(rb_darray_meta_t) when T is __int128_t, for example.
130
+ static inline void
131
+ rb_darray_ensure_space(void *ptr_to_ary, size_t header_size, size_t element_size)
132
+ {
133
+ rb_darray_meta_t **ptr_to_ptr_to_meta = ptr_to_ary;
134
+ rb_darray_meta_t *meta = *ptr_to_ptr_to_meta;
135
+ size_t current_capa = rb_darray_capa(meta);
136
+ if (rb_darray_size(meta) < current_capa) return;
137
+
138
+ // Double the capacity
139
+ size_t new_capa = current_capa == 0 ? 1 : current_capa * 2;
140
+
141
+ rb_darray_meta_t *doubled_ary = rb_xrealloc_mul_add(meta, new_capa, element_size, header_size);
142
+ // rb_xrealloc functions guarantee that NULL is not returned
143
+ assert(doubled_ary != NULL);
144
+
145
+ if (meta == NULL) {
146
+ // First allocation. Initialize size. On subsequence allocations
147
+ // realloc takes care of carrying over the size.
148
+ doubled_ary->size = 0;
149
+ }
150
+
151
+ doubled_ary->capa = new_capa;
152
+
153
+ // We don't have access to the type of the dynamic array in function context.
154
+ // Write out result with memcpy to avoid strict aliasing issue.
155
+ memcpy(ptr_to_ary, &doubled_ary, sizeof(doubled_ary));
156
+ }
157
+
158
+ static inline void
159
+ rb_darray_make_impl(void *ptr_to_ary, size_t array_size, size_t header_size, size_t element_size)
160
+ {
161
+ rb_darray_meta_t **ptr_to_ptr_to_meta = ptr_to_ary;
162
+ if (array_size == 0) {
163
+ *ptr_to_ptr_to_meta = NULL;
164
+ return;
165
+ }
166
+
167
+ rb_darray_meta_t *meta = rb_xcalloc_mul_add(array_size, element_size, header_size);
168
+ // rb_xcalloc functions guarantee that NULL is not returned
169
+ assert(meta != NULL);
170
+
171
+ meta->size = array_size;
172
+ meta->capa = array_size;
173
+
174
+ // We don't have access to the type of the dynamic array in function context.
175
+ // Write out result with memcpy to avoid strict aliasing issue.
176
+ memcpy(ptr_to_ary, &meta, sizeof(meta));
177
+ }
178
+
179
+ #endif /* RUBY_DARRAY_H */
@@ -0,0 +1,426 @@
1
+ /**********************************************************************
2
+
3
+ debug_counter.h -
4
+
5
+ created at: Tue Feb 21 16:51:18 2017
6
+
7
+ Copyright (C) 2017 Koichi Sasada
8
+
9
+ **********************************************************************/
10
+
11
+ #ifndef USE_DEBUG_COUNTER
12
+ #define USE_DEBUG_COUNTER 0
13
+ #endif
14
+
15
+ #ifdef RB_DEBUG_COUNTER
16
+
17
+ // method cache (IMC: inline method cache)
18
+ RB_DEBUG_COUNTER(mc_inline_hit) // IMC hit
19
+ RB_DEBUG_COUNTER(mc_inline_miss_klass) // IMC miss by different class
20
+ RB_DEBUG_COUNTER(mc_inline_miss_invalidated) // IMC miss by invalidated ME
21
+ RB_DEBUG_COUNTER(mc_inline_miss_empty) // IMC miss because prev is empty slot
22
+ RB_DEBUG_COUNTER(mc_inline_miss_same_cc) // IMC miss, but same CC
23
+ RB_DEBUG_COUNTER(mc_inline_miss_same_cme) // IMC miss, but same CME
24
+ RB_DEBUG_COUNTER(mc_inline_miss_same_def) // IMC miss, but same definition
25
+ RB_DEBUG_COUNTER(mc_inline_miss_diff) // IMC miss, different methods
26
+
27
+ RB_DEBUG_COUNTER(cvar_write_inline_hit) // cvar cache hit on write
28
+ RB_DEBUG_COUNTER(cvar_read_inline_hit) // cvar cache hit on read
29
+ RB_DEBUG_COUNTER(cvar_inline_miss) // miss inline cache
30
+ RB_DEBUG_COUNTER(cvar_class_invalidate) // invalidate cvar cache when define a cvar that's defined on a subclass
31
+ RB_DEBUG_COUNTER(cvar_include_invalidate) // invalidate cvar cache on module include or prepend
32
+
33
+ RB_DEBUG_COUNTER(mc_cme_complement) // number of acquiring complement CME
34
+ RB_DEBUG_COUNTER(mc_cme_complement_hit) // number of cache hit for complemented CME
35
+
36
+ RB_DEBUG_COUNTER(mc_search) // count for method lookup in class tree
37
+ RB_DEBUG_COUNTER(mc_search_notfound) // method lookup, but not found
38
+ RB_DEBUG_COUNTER(mc_search_super) // total traversed classes
39
+
40
+ // callinfo
41
+ RB_DEBUG_COUNTER(ci_packed) // number of packed CI
42
+ RB_DEBUG_COUNTER(ci_kw) // non-packed CI w/ keywords
43
+ RB_DEBUG_COUNTER(ci_nokw) // non-packed CI w/o keywords
44
+ RB_DEBUG_COUNTER(ci_runtime) // creating temporary CI
45
+
46
+ // callcache
47
+ RB_DEBUG_COUNTER(cc_new) // number of CC
48
+ RB_DEBUG_COUNTER(cc_temp) // dummy CC (stack-allocated)
49
+ RB_DEBUG_COUNTER(cc_found_in_ccs) // count for CC lookup success in CCS
50
+ RB_DEBUG_COUNTER(cc_not_found_in_ccs) // count for CC lookup success in CCS
51
+
52
+ RB_DEBUG_COUNTER(cc_ent_invalidate) // count for invalidating cc (cc->klass = 0)
53
+ RB_DEBUG_COUNTER(cc_cme_invalidate) // count for invalidating CME
54
+
55
+ RB_DEBUG_COUNTER(cc_invalidate_leaf) // count for invalidating klass if klass has no-subclasses
56
+ RB_DEBUG_COUNTER(cc_invalidate_leaf_ccs) // corresponding CCS
57
+ RB_DEBUG_COUNTER(cc_invalidate_leaf_callable) // complimented cache (no-subclasses)
58
+ RB_DEBUG_COUNTER(cc_invalidate_tree) // count for invalidating klass if klass has subclasses
59
+ RB_DEBUG_COUNTER(cc_invalidate_tree_cme) // cme if cme is found in this class or superclasses
60
+ RB_DEBUG_COUNTER(cc_invalidate_tree_callable) // complimented cache (subclasses)
61
+ RB_DEBUG_COUNTER(cc_invalidate_negative) // count for invalidating negative cache
62
+
63
+ RB_DEBUG_COUNTER(ccs_free) // count for free'ing ccs
64
+ RB_DEBUG_COUNTER(ccs_maxlen) // maximum length of ccs
65
+ RB_DEBUG_COUNTER(ccs_found) // count for finding corresponding ccs on method lookup
66
+ RB_DEBUG_COUNTER(ccs_not_found) // count for not found corresponding ccs on method lookup
67
+
68
+ // vm_eval.c
69
+ RB_DEBUG_COUNTER(call0_public)
70
+ RB_DEBUG_COUNTER(call0_other)
71
+ RB_DEBUG_COUNTER(gccct_hit)
72
+ RB_DEBUG_COUNTER(gccct_miss)
73
+ RB_DEBUG_COUNTER(gccct_null)
74
+
75
+ // iseq
76
+ RB_DEBUG_COUNTER(iseq_num) // number of total created iseq
77
+ RB_DEBUG_COUNTER(iseq_cd_num) // number of total created cd (call_data)
78
+
79
+ /*
80
+ * call cache fastpath usage
81
+ */
82
+ RB_DEBUG_COUNTER(ccf_general)
83
+ RB_DEBUG_COUNTER(ccf_iseq_setup)
84
+ RB_DEBUG_COUNTER(ccf_iseq_setup_0start)
85
+ RB_DEBUG_COUNTER(ccf_iseq_setup_tailcall_0start)
86
+ RB_DEBUG_COUNTER(ccf_iseq_fix) /* several functions created with tool/mk_call_iseq_optimized.rb */
87
+ RB_DEBUG_COUNTER(ccf_iseq_opt) /* has_opt == TRUE (has optional parameters), but other flags are FALSE */
88
+ RB_DEBUG_COUNTER(ccf_iseq_kw1) /* vm_call_iseq_setup_kwparm_kwarg() */
89
+ RB_DEBUG_COUNTER(ccf_iseq_kw2) /* vm_call_iseq_setup_kwparm_nokwarg() */
90
+ RB_DEBUG_COUNTER(ccf_cfunc)
91
+ RB_DEBUG_COUNTER(ccf_cfunc_with_frame)
92
+ RB_DEBUG_COUNTER(ccf_ivar) /* attr_reader */
93
+ RB_DEBUG_COUNTER(ccf_attrset) /* attr_writer */
94
+ RB_DEBUG_COUNTER(ccf_method_missing)
95
+ RB_DEBUG_COUNTER(ccf_zsuper)
96
+ RB_DEBUG_COUNTER(ccf_bmethod)
97
+ RB_DEBUG_COUNTER(ccf_opt_send)
98
+ RB_DEBUG_COUNTER(ccf_opt_call)
99
+ RB_DEBUG_COUNTER(ccf_opt_block_call)
100
+ RB_DEBUG_COUNTER(ccf_opt_struct_aref)
101
+ RB_DEBUG_COUNTER(ccf_opt_struct_aset)
102
+ RB_DEBUG_COUNTER(ccf_super_method)
103
+
104
+ /*
105
+ * control frame push counts.
106
+ *
107
+ * * frame_push: frame push counts.
108
+ * * frame_push_*: frame push counts per each type.
109
+ * * frame_R2R: Ruby frame to Ruby frame
110
+ * * frame_R2C: Ruby frame to C frame
111
+ * * frame_C2C: C frame to C frame
112
+ * * frame_C2R: C frame to Ruby frame
113
+ */
114
+ RB_DEBUG_COUNTER(frame_push)
115
+ RB_DEBUG_COUNTER(frame_push_method)
116
+ RB_DEBUG_COUNTER(frame_push_block)
117
+ RB_DEBUG_COUNTER(frame_push_class)
118
+ RB_DEBUG_COUNTER(frame_push_top)
119
+ RB_DEBUG_COUNTER(frame_push_cfunc)
120
+ RB_DEBUG_COUNTER(frame_push_ifunc)
121
+ RB_DEBUG_COUNTER(frame_push_eval)
122
+ RB_DEBUG_COUNTER(frame_push_rescue)
123
+ RB_DEBUG_COUNTER(frame_push_dummy)
124
+
125
+ RB_DEBUG_COUNTER(frame_R2R)
126
+ RB_DEBUG_COUNTER(frame_R2C)
127
+ RB_DEBUG_COUNTER(frame_C2C)
128
+ RB_DEBUG_COUNTER(frame_C2R)
129
+
130
+ /* instance variable counts */
131
+ RB_DEBUG_COUNTER(ivar_get_obj_hit) // Only T_OBJECT hits
132
+ RB_DEBUG_COUNTER(ivar_get_obj_miss) // Only T_OBJECT misses
133
+ RB_DEBUG_COUNTER(ivar_get_ic_hit) // All hits
134
+ RB_DEBUG_COUNTER(ivar_get_ic_miss) // All misses
135
+ RB_DEBUG_COUNTER(ivar_set_ic_hit) // All hits
136
+ RB_DEBUG_COUNTER(ivar_set_obj_hit) // Only T_OBJECT hits
137
+ RB_DEBUG_COUNTER(ivar_set_obj_miss) // Only T_OBJECT misses
138
+ RB_DEBUG_COUNTER(ivar_set_ic_miss) // All misses
139
+ RB_DEBUG_COUNTER(ivar_set_ic_miss_noobject) // Miss because non T_OBJECT
140
+ RB_DEBUG_COUNTER(ivar_get_base) // Calls to `rb_ivar_get` (very slow path)
141
+ RB_DEBUG_COUNTER(ivar_set_base) // Calls to `ivar_set` (very slow path)
142
+ RB_DEBUG_COUNTER(ivar_get_ic_miss_set) // Misses on IV reads where the cache was wrong
143
+ RB_DEBUG_COUNTER(ivar_get_cc_miss_set) // Misses on attr_reader where the cache was wrong
144
+ RB_DEBUG_COUNTER(ivar_get_ic_miss_unset) // Misses on IV read where the cache wasn't set
145
+ RB_DEBUG_COUNTER(ivar_get_cc_miss_unset) // Misses on attr_reader where the cache wasn't set
146
+
147
+ /* local variable counts
148
+ *
149
+ * * lvar_get: total lvar get counts (VM insn)
150
+ * * lvar_get_dynamic: lvar get counts if accessing upper env (VM insn)
151
+ * * lvar_set*: same as "get"
152
+ * * lvar_set_slowpath: counts using vm_env_write_slowpath()
153
+ */
154
+ RB_DEBUG_COUNTER(lvar_get)
155
+ RB_DEBUG_COUNTER(lvar_get_dynamic)
156
+ RB_DEBUG_COUNTER(lvar_set)
157
+ RB_DEBUG_COUNTER(lvar_set_dynamic)
158
+ RB_DEBUG_COUNTER(lvar_set_slowpath)
159
+
160
+ /* GC counts:
161
+ *
162
+ * * count: simple count
163
+ * * _minor: minor gc
164
+ * * _major: major gc
165
+ * * other suffix is corresponding to last_gc_info or
166
+ * gc_profile_record_flag in gc.c.
167
+ */
168
+ RB_DEBUG_COUNTER(gc_count)
169
+ RB_DEBUG_COUNTER(gc_minor_newobj)
170
+ RB_DEBUG_COUNTER(gc_minor_malloc)
171
+ RB_DEBUG_COUNTER(gc_minor_method)
172
+ RB_DEBUG_COUNTER(gc_minor_capi)
173
+ RB_DEBUG_COUNTER(gc_minor_stress)
174
+ RB_DEBUG_COUNTER(gc_major_nofree)
175
+ RB_DEBUG_COUNTER(gc_major_oldgen)
176
+ RB_DEBUG_COUNTER(gc_major_shady)
177
+ RB_DEBUG_COUNTER(gc_major_force)
178
+ RB_DEBUG_COUNTER(gc_major_oldmalloc)
179
+
180
+ RB_DEBUG_COUNTER(gc_enter_start)
181
+ RB_DEBUG_COUNTER(gc_enter_continue)
182
+ RB_DEBUG_COUNTER(gc_enter_rest)
183
+ RB_DEBUG_COUNTER(gc_enter_finalizer)
184
+
185
+ RB_DEBUG_COUNTER(gc_isptr_trial)
186
+ RB_DEBUG_COUNTER(gc_isptr_range)
187
+ RB_DEBUG_COUNTER(gc_isptr_align)
188
+ RB_DEBUG_COUNTER(gc_isptr_maybe)
189
+
190
+ /* object allocation counts:
191
+ *
192
+ * * obj_newobj: newobj counts
193
+ * * obj_newobj_slowpath: newobj with slowpath counts
194
+ * * obj_newobj_wb_unprotected: newobj for wb_unprotected.
195
+ * * obj_free: obj_free() counts
196
+ * * obj_promote: promoted counts (oldgen)
197
+ * * obj_wb_unprotect: wb unprotect counts
198
+ *
199
+ * * obj_[type]_[attr]: *free'ed counts* for each type.
200
+ * Note that it is not a allocated counts.
201
+ * * [type]
202
+ * * _obj: T_OBJECT
203
+ * * _str: T_STRING
204
+ * * _ary: T_ARRAY
205
+ * * _xxx: T_XXX (hash, struct, ...)
206
+ *
207
+ * * [attr]
208
+ * * _ptr: R?? is not embed.
209
+ * * _embed: R?? is embed.
210
+ * * _transient: R?? uses transient heap.
211
+ * * type specific attr.
212
+ * * str_shared: str is shared.
213
+ * * str_nofree: nofree
214
+ * * str_fstr: fstr
215
+ * * hash_empty: hash is empty
216
+ * * hash_1_4: has 1 to 4 entries
217
+ * * hash_5_8: has 5 to 8 entries
218
+ * * hash_g8: has n entries (n>8)
219
+ * * match_under4: has under 4 oniguruma regions allocated
220
+ * * match_ge4: has n regions allocated (4<=n<8)
221
+ * * match_ge8: has n regions allocated (8<=n)
222
+ * * data_empty: T_DATA but no memory free.
223
+ * * data_xfree: free'ed by xfree().
224
+ * * data_imm_free: free'ed immediately.
225
+ * * data_zombie: free'ed with zombie.
226
+ * * imemo_*: T_IMEMO with each type.
227
+ */
228
+ RB_DEBUG_COUNTER(obj_newobj)
229
+ RB_DEBUG_COUNTER(obj_newobj_slowpath)
230
+ RB_DEBUG_COUNTER(obj_newobj_wb_unprotected)
231
+ RB_DEBUG_COUNTER(obj_free)
232
+ RB_DEBUG_COUNTER(obj_promote)
233
+ RB_DEBUG_COUNTER(obj_wb_unprotect)
234
+
235
+ RB_DEBUG_COUNTER(obj_obj_embed)
236
+ RB_DEBUG_COUNTER(obj_obj_transient)
237
+ RB_DEBUG_COUNTER(obj_obj_ptr)
238
+ RB_DEBUG_COUNTER(obj_obj_too_complex)
239
+
240
+ RB_DEBUG_COUNTER(obj_str_ptr)
241
+ RB_DEBUG_COUNTER(obj_str_embed)
242
+ RB_DEBUG_COUNTER(obj_str_shared)
243
+ RB_DEBUG_COUNTER(obj_str_nofree)
244
+ RB_DEBUG_COUNTER(obj_str_fstr)
245
+
246
+ RB_DEBUG_COUNTER(obj_ary_embed)
247
+ RB_DEBUG_COUNTER(obj_ary_transient)
248
+ RB_DEBUG_COUNTER(obj_ary_ptr)
249
+ RB_DEBUG_COUNTER(obj_ary_extracapa)
250
+ /*
251
+ ary_shared_create: shared ary by Array#dup and so on.
252
+ ary_shared: finished in shard.
253
+ ary_shared_root_occupied: shared_root but has only 1 refcnt.
254
+ The number (ary_shared - ary_shared_root_occupied) is meaningful.
255
+ */
256
+ RB_DEBUG_COUNTER(obj_ary_shared_create)
257
+ RB_DEBUG_COUNTER(obj_ary_shared)
258
+ RB_DEBUG_COUNTER(obj_ary_shared_root_occupied)
259
+
260
+ RB_DEBUG_COUNTER(obj_hash_empty)
261
+ RB_DEBUG_COUNTER(obj_hash_1)
262
+ RB_DEBUG_COUNTER(obj_hash_2)
263
+ RB_DEBUG_COUNTER(obj_hash_3)
264
+ RB_DEBUG_COUNTER(obj_hash_4)
265
+ RB_DEBUG_COUNTER(obj_hash_5_8)
266
+ RB_DEBUG_COUNTER(obj_hash_g8)
267
+
268
+ RB_DEBUG_COUNTER(obj_hash_null)
269
+ RB_DEBUG_COUNTER(obj_hash_ar)
270
+ RB_DEBUG_COUNTER(obj_hash_st)
271
+ RB_DEBUG_COUNTER(obj_hash_transient)
272
+ RB_DEBUG_COUNTER(obj_hash_force_convert)
273
+
274
+ RB_DEBUG_COUNTER(obj_struct_embed)
275
+ RB_DEBUG_COUNTER(obj_struct_transient)
276
+ RB_DEBUG_COUNTER(obj_struct_ptr)
277
+
278
+ RB_DEBUG_COUNTER(obj_data_empty)
279
+ RB_DEBUG_COUNTER(obj_data_xfree)
280
+ RB_DEBUG_COUNTER(obj_data_imm_free)
281
+ RB_DEBUG_COUNTER(obj_data_zombie)
282
+
283
+ RB_DEBUG_COUNTER(obj_match_under4)
284
+ RB_DEBUG_COUNTER(obj_match_ge4)
285
+ RB_DEBUG_COUNTER(obj_match_ge8)
286
+ RB_DEBUG_COUNTER(obj_match_ptr)
287
+
288
+ RB_DEBUG_COUNTER(obj_iclass_ptr)
289
+ RB_DEBUG_COUNTER(obj_class_ptr)
290
+ RB_DEBUG_COUNTER(obj_module_ptr)
291
+
292
+ RB_DEBUG_COUNTER(obj_bignum_ptr)
293
+ RB_DEBUG_COUNTER(obj_bignum_embed)
294
+ RB_DEBUG_COUNTER(obj_float)
295
+ RB_DEBUG_COUNTER(obj_complex)
296
+ RB_DEBUG_COUNTER(obj_rational)
297
+
298
+ RB_DEBUG_COUNTER(obj_regexp_ptr)
299
+ RB_DEBUG_COUNTER(obj_file_ptr)
300
+ RB_DEBUG_COUNTER(obj_symbol)
301
+
302
+ RB_DEBUG_COUNTER(obj_imemo_ment)
303
+ RB_DEBUG_COUNTER(obj_imemo_iseq)
304
+ RB_DEBUG_COUNTER(obj_imemo_env)
305
+ RB_DEBUG_COUNTER(obj_imemo_tmpbuf)
306
+ RB_DEBUG_COUNTER(obj_imemo_ast)
307
+ RB_DEBUG_COUNTER(obj_imemo_cref)
308
+ RB_DEBUG_COUNTER(obj_imemo_svar)
309
+ RB_DEBUG_COUNTER(obj_imemo_throw_data)
310
+ RB_DEBUG_COUNTER(obj_imemo_ifunc)
311
+ RB_DEBUG_COUNTER(obj_imemo_memo)
312
+ RB_DEBUG_COUNTER(obj_imemo_parser_strterm)
313
+ RB_DEBUG_COUNTER(obj_imemo_callinfo)
314
+ RB_DEBUG_COUNTER(obj_imemo_callcache)
315
+ RB_DEBUG_COUNTER(obj_imemo_constcache)
316
+
317
+ /* ar_table */
318
+ RB_DEBUG_COUNTER(artable_hint_hit)
319
+ RB_DEBUG_COUNTER(artable_hint_miss)
320
+ RB_DEBUG_COUNTER(artable_hint_notfound)
321
+
322
+ /* heap function counts
323
+ *
324
+ * * heap_xmalloc/realloc/xfree: call counts
325
+ */
326
+ RB_DEBUG_COUNTER(heap_xmalloc)
327
+ RB_DEBUG_COUNTER(heap_xrealloc)
328
+ RB_DEBUG_COUNTER(heap_xfree)
329
+
330
+ /* transient_heap */
331
+ RB_DEBUG_COUNTER(theap_alloc)
332
+ RB_DEBUG_COUNTER(theap_alloc_fail)
333
+ RB_DEBUG_COUNTER(theap_evacuate)
334
+
335
+ // VM sync
336
+ RB_DEBUG_COUNTER(vm_sync_lock)
337
+ RB_DEBUG_COUNTER(vm_sync_lock_enter)
338
+ RB_DEBUG_COUNTER(vm_sync_lock_enter_nb)
339
+ RB_DEBUG_COUNTER(vm_sync_lock_enter_cr)
340
+ RB_DEBUG_COUNTER(vm_sync_barrier)
341
+
342
+ /* load (not implemented yet) */
343
+ /*
344
+ RB_DEBUG_COUNTER(load_files)
345
+ RB_DEBUG_COUNTER(load_path_is_not_realpath)
346
+ */
347
+ #endif
348
+
349
+ #ifndef RUBY_DEBUG_COUNTER_H
350
+ #define RUBY_DEBUG_COUNTER_H 1
351
+
352
+ #include "ruby/internal/config.h"
353
+ #include <stddef.h> /* for size_t */
354
+ #include "ruby/ruby.h" /* for VALUE */
355
+
356
+ #if !defined(__GNUC__) && USE_DEBUG_COUNTER
357
+ #error "USE_DEBUG_COUNTER is not supported by other than __GNUC__"
358
+ #endif
359
+
360
+ enum rb_debug_counter_type {
361
+ #define RB_DEBUG_COUNTER(name) RB_DEBUG_COUNTER_##name,
362
+ #include __FILE__
363
+ RB_DEBUG_COUNTER_MAX
364
+ #undef RB_DEBUG_COUNTER
365
+ };
366
+
367
+ #if USE_DEBUG_COUNTER
368
+ extern size_t rb_debug_counter[];
369
+ RUBY_EXTERN struct rb_ractor_struct *ruby_single_main_ractor;
370
+ RUBY_EXTERN void rb_debug_counter_add_atomic(enum rb_debug_counter_type type, int add);
371
+
372
+ inline static int
373
+ rb_debug_counter_add(enum rb_debug_counter_type type, int add, int cond)
374
+ {
375
+ if (cond) {
376
+ if (ruby_single_main_ractor != NULL) {
377
+ rb_debug_counter[(int)type] += add;
378
+ }
379
+ else {
380
+ rb_debug_counter_add_atomic(type, add);
381
+ }
382
+ }
383
+ return cond;
384
+ }
385
+
386
+ inline static int
387
+ rb_debug_counter_max(enum rb_debug_counter_type type, unsigned int num)
388
+ {
389
+ // TODO: sync
390
+ if (rb_debug_counter[(int)type] < num) {
391
+ rb_debug_counter[(int)type] = num;
392
+ return 1;
393
+ }
394
+ else {
395
+ return 0;
396
+ }
397
+ }
398
+
399
+ VALUE rb_debug_counter_reset(VALUE klass);
400
+ VALUE rb_debug_counter_show(VALUE klass);
401
+
402
+ #define RB_DEBUG_COUNTER_INC(type) rb_debug_counter_add(RB_DEBUG_COUNTER_##type, 1, 1)
403
+ #define RB_DEBUG_COUNTER_INC_UNLESS(type, cond) (!rb_debug_counter_add(RB_DEBUG_COUNTER_##type, 1, !(cond)))
404
+ #define RB_DEBUG_COUNTER_INC_IF(type, cond) rb_debug_counter_add(RB_DEBUG_COUNTER_##type, 1, !!(cond))
405
+ #define RB_DEBUG_COUNTER_ADD(type, num) rb_debug_counter_add(RB_DEBUG_COUNTER_##type, (num), 1)
406
+ #define RB_DEBUG_COUNTER_SETMAX(type, num) rb_debug_counter_max(RB_DEBUG_COUNTER_##type, (unsigned int)(num))
407
+
408
+ #else
409
+ #define RB_DEBUG_COUNTER_INC(type) ((void)0)
410
+ #define RB_DEBUG_COUNTER_INC_UNLESS(type, cond) (!!(cond))
411
+ #define RB_DEBUG_COUNTER_INC_IF(type, cond) (!!(cond))
412
+ #define RB_DEBUG_COUNTER_ADD(type, num) ((void)0)
413
+ #define RB_DEBUG_COUNTER_SETMAX(type, num) 0
414
+ #endif
415
+
416
+ void rb_debug_counter_show_results(const char *msg);
417
+
418
+ RUBY_SYMBOL_EXPORT_BEGIN
419
+
420
+ size_t ruby_debug_counter_get(const char **names_ptr, size_t *counters_ptr);
421
+ void ruby_debug_counter_reset(void);
422
+ void ruby_debug_counter_show_at_exit(int enable);
423
+
424
+ RUBY_SYMBOL_EXPORT_END
425
+
426
+ #endif /* RUBY_DEBUG_COUNTER_H */