datadog-ruby_core_source 3.5.4 → 3.5.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (122) hide show
  1. checksums.yaml +4 -4
  2. data/datadog-ruby_core_source.gemspec +1 -1
  3. data/lib/datadog/ruby_core_source/ruby-2.6.0-p0/ccan/build_assert/build_assert.h +40 -0
  4. data/lib/datadog/ruby_core_source/ruby-2.6.0-p0/ccan/check_type/check_type.h +63 -0
  5. data/lib/datadog/ruby_core_source/ruby-2.6.0-p0/ccan/container_of/container_of.h +142 -0
  6. data/lib/datadog/ruby_core_source/ruby-2.6.0-p0/ccan/list/list.h +788 -0
  7. data/lib/datadog/ruby_core_source/ruby-2.6.0-p0/ccan/str/str.h +16 -0
  8. data/lib/datadog/ruby_core_source/ruby-2.6.0-p0/id.h +252 -0
  9. data/lib/datadog/ruby_core_source/ruby-2.6.0-p0/internal.h +2465 -0
  10. data/lib/datadog/ruby_core_source/ruby-2.6.0-p0/iseq.h +304 -0
  11. data/lib/datadog/ruby_core_source/ruby-2.6.0-p0/method.h +229 -0
  12. data/lib/datadog/ruby_core_source/ruby-2.6.0-p0/node.h +449 -0
  13. data/lib/datadog/ruby_core_source/ruby-2.6.0-p0/ruby_assert.h +60 -0
  14. data/lib/datadog/ruby_core_source/ruby-2.6.0-p0/ruby_atomic.h +244 -0
  15. data/lib/datadog/ruby_core_source/ruby-2.6.0-p0/thread_pthread.h +75 -0
  16. data/lib/datadog/ruby_core_source/ruby-2.6.0-p0/thread_win32.h +36 -0
  17. data/lib/datadog/ruby_core_source/ruby-2.6.0-p0/vm_core.h +1902 -0
  18. data/lib/datadog/ruby_core_source/ruby-2.6.0-p0/vm_opts.h +70 -0
  19. data/lib/datadog/ruby_core_source/ruby-2.7.0-p0/ccan/build_assert/build_assert.h +40 -0
  20. data/lib/datadog/ruby_core_source/ruby-2.7.0-p0/ccan/check_type/check_type.h +63 -0
  21. data/lib/datadog/ruby_core_source/ruby-2.7.0-p0/ccan/container_of/container_of.h +142 -0
  22. data/lib/datadog/ruby_core_source/ruby-2.7.0-p0/ccan/list/list.h +788 -0
  23. data/lib/datadog/ruby_core_source/ruby-2.7.0-p0/ccan/str/str.h +16 -0
  24. data/lib/datadog/ruby_core_source/ruby-2.7.0-p0/id.h +290 -0
  25. data/lib/datadog/ruby_core_source/ruby-2.7.0-p0/internal.h +2697 -0
  26. data/lib/datadog/ruby_core_source/ruby-2.7.0-p0/iseq.h +312 -0
  27. data/lib/datadog/ruby_core_source/ruby-2.7.0-p0/method.h +229 -0
  28. data/lib/datadog/ruby_core_source/ruby-2.7.0-p0/node.h +476 -0
  29. data/lib/datadog/ruby_core_source/ruby-2.7.0-p0/ruby_assert.h +15 -0
  30. data/lib/datadog/ruby_core_source/ruby-2.7.0-p0/ruby_atomic.h +244 -0
  31. data/lib/datadog/ruby_core_source/ruby-2.7.0-p0/thread_pthread.h +75 -0
  32. data/lib/datadog/ruby_core_source/ruby-2.7.0-p0/thread_win32.h +36 -0
  33. data/lib/datadog/ruby_core_source/ruby-2.7.0-p0/vm_core.h +1968 -0
  34. data/lib/datadog/ruby_core_source/ruby-2.7.0-p0/vm_opts.h +72 -0
  35. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/ccan/build_assert/build_assert.h +40 -0
  36. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/ccan/check_type/check_type.h +63 -0
  37. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/ccan/container_of/container_of.h +142 -0
  38. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/ccan/list/list.h +788 -0
  39. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/ccan/str/str.h +16 -0
  40. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/id.h +290 -0
  41. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/id_table.h +36 -0
  42. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/internal/array.h +119 -0
  43. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/internal/class.h +174 -0
  44. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/internal/compilers.h +108 -0
  45. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/internal/gc.h +161 -0
  46. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/internal/imemo.h +243 -0
  47. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/internal/serial.h +24 -0
  48. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/internal/static_assert.h +17 -0
  49. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/internal/vm.h +136 -0
  50. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/internal/warnings.h +17 -0
  51. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/internal.h +107 -0
  52. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/iseq.h +305 -0
  53. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/method.h +245 -0
  54. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/node.h +484 -0
  55. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/ractor_core.h +343 -0
  56. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/ruby_assert.h +15 -0
  57. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/ruby_atomic.h +23 -0
  58. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/thread_pthread.h +115 -0
  59. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/thread_win32.h +61 -0
  60. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/vm_core.h +2023 -0
  61. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/vm_debug.h +116 -0
  62. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/vm_opts.h +73 -0
  63. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/ccan/build_assert/build_assert.h +40 -0
  64. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/ccan/check_type/check_type.h +63 -0
  65. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/ccan/container_of/container_of.h +142 -0
  66. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/ccan/list/list.h +788 -0
  67. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/ccan/str/str.h +16 -0
  68. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/darray.h +198 -0
  69. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/id.h +293 -0
  70. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/id_table.h +36 -0
  71. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/internal/array.h +113 -0
  72. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/internal/class.h +196 -0
  73. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/internal/compilers.h +107 -0
  74. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/internal/gc.h +186 -0
  75. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/internal/imemo.h +243 -0
  76. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/internal/serial.h +23 -0
  77. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/internal/static_assert.h +16 -0
  78. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/internal/vm.h +133 -0
  79. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/internal/warnings.h +16 -0
  80. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/internal.h +109 -0
  81. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/iseq.h +322 -0
  82. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/method.h +253 -0
  83. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/node.h +510 -0
  84. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/ractor_core.h +346 -0
  85. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/ruby_assert.h +14 -0
  86. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/ruby_atomic.h +23 -0
  87. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/thread_pthread.h +115 -0
  88. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/vm_core.h +2107 -0
  89. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/vm_debug.h +124 -0
  90. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/vm_opts.h +73 -0
  91. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/ccan/build_assert/build_assert.h +40 -0
  92. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/ccan/check_type/check_type.h +63 -0
  93. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/ccan/container_of/container_of.h +142 -0
  94. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/ccan/list/list.h +789 -0
  95. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/ccan/str/str.h +17 -0
  96. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/id.h +299 -0
  97. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/id_table.h +39 -0
  98. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/internal/array.h +163 -0
  99. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/internal/basic_operators.h +64 -0
  100. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/internal/class.h +182 -0
  101. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/internal/compilers.h +107 -0
  102. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/internal/gc.h +192 -0
  103. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/internal/imemo.h +242 -0
  104. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/internal/serial.h +23 -0
  105. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/internal/static_assert.h +16 -0
  106. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/internal/vm.h +134 -0
  107. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/internal/warnings.h +16 -0
  108. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/internal.h +113 -0
  109. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/iseq.h +329 -0
  110. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/method.h +254 -0
  111. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/node.h +514 -0
  112. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/ractor_core.h +342 -0
  113. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/ruby_assert.h +14 -0
  114. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/ruby_atomic.h +23 -0
  115. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/shape.h +232 -0
  116. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/thread_none.h +20 -0
  117. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/thread_pthread.h +133 -0
  118. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/vm_core.h +2106 -0
  119. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/vm_debug.h +122 -0
  120. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/vm_opts.h +73 -0
  121. data/lib/datadog/ruby_core_source/version.rb +1 -1
  122. metadata +122 -4
@@ -0,0 +1,182 @@
1
+ #ifndef INTERNAL_CLASS_H /*-*-C-*-vi:se ft=c:*/
2
+ #define INTERNAL_CLASS_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 Class.
10
+ */
11
+ #include "id_table.h" /* for struct rb_id_table */
12
+ #include "internal/gc.h" /* for RB_OBJ_WRITE */
13
+ #include "internal/serial.h" /* for rb_serial_t */
14
+ #include "ruby/internal/stdbool.h" /* for bool */
15
+ #include "ruby/intern.h" /* for rb_alloc_func_t */
16
+ #include "ruby/ruby.h" /* for struct RBasic */
17
+ #include "shape.h"
18
+
19
+ #ifdef RCLASS_SUPER
20
+ # undef RCLASS_SUPER
21
+ #endif
22
+
23
+ struct rb_subclass_entry {
24
+ VALUE klass;
25
+ struct rb_subclass_entry *next;
26
+ struct rb_subclass_entry *prev;
27
+ };
28
+
29
+ struct rb_cvar_class_tbl_entry {
30
+ uint32_t index;
31
+ rb_serial_t global_cvar_state;
32
+ VALUE class_value;
33
+ };
34
+
35
+ struct rb_classext_struct {
36
+ VALUE *iv_ptr;
37
+ struct rb_id_table *const_tbl;
38
+ struct rb_id_table *callable_m_tbl;
39
+ struct rb_id_table *cc_tbl; /* ID -> [[ci, cc1], cc2, ...] */
40
+ struct rb_id_table *cvc_tbl;
41
+ size_t superclass_depth;
42
+ VALUE *superclasses;
43
+ struct rb_subclass_entry *subclasses;
44
+ struct rb_subclass_entry *subclass_entry;
45
+ /**
46
+ * In the case that this is an `ICLASS`, `module_subclasses` points to the link
47
+ * in the module's `subclasses` list that indicates that the klass has been
48
+ * included. Hopefully that makes sense.
49
+ */
50
+ struct rb_subclass_entry *module_subclass_entry;
51
+ const VALUE origin_;
52
+ const VALUE refined_class;
53
+ rb_alloc_func_t allocator;
54
+ const VALUE includer;
55
+ uint32_t max_iv_count;
56
+ uint32_t variation_count;
57
+ #if !SHAPE_IN_BASIC_FLAGS
58
+ shape_id_t shape_id;
59
+ #endif
60
+ };
61
+
62
+ struct RClass {
63
+ struct RBasic basic;
64
+ VALUE super;
65
+ struct rb_id_table *m_tbl;
66
+ #if SIZE_POOL_COUNT == 1
67
+ struct rb_classext_struct *ptr;
68
+ #endif
69
+ };
70
+
71
+ typedef struct rb_subclass_entry rb_subclass_entry_t;
72
+ typedef struct rb_classext_struct rb_classext_t;
73
+
74
+ #if RCLASS_EXT_EMBEDDED
75
+ # define RCLASS_EXT(c) ((rb_classext_t *)((char *)(c) + sizeof(struct RClass)))
76
+ #else
77
+ # define RCLASS_EXT(c) (RCLASS(c)->ptr)
78
+ #endif
79
+ #define RCLASS_CONST_TBL(c) (RCLASS_EXT(c)->const_tbl)
80
+ #define RCLASS_M_TBL(c) (RCLASS(c)->m_tbl)
81
+ #define RCLASS_IVPTR(c) (RCLASS_EXT(c)->iv_ptr)
82
+ #define RCLASS_CALLABLE_M_TBL(c) (RCLASS_EXT(c)->callable_m_tbl)
83
+ #define RCLASS_CC_TBL(c) (RCLASS_EXT(c)->cc_tbl)
84
+ #define RCLASS_CVC_TBL(c) (RCLASS_EXT(c)->cvc_tbl)
85
+ #define RCLASS_ORIGIN(c) (RCLASS_EXT(c)->origin_)
86
+ #define RCLASS_REFINED_CLASS(c) (RCLASS_EXT(c)->refined_class)
87
+ #define RCLASS_INCLUDER(c) (RCLASS_EXT(c)->includer)
88
+ #define RCLASS_SUBCLASS_ENTRY(c) (RCLASS_EXT(c)->subclass_entry)
89
+ #define RCLASS_MODULE_SUBCLASS_ENTRY(c) (RCLASS_EXT(c)->module_subclass_entry)
90
+ #define RCLASS_ALLOCATOR(c) (RCLASS_EXT(c)->allocator)
91
+ #define RCLASS_SUBCLASSES(c) (RCLASS_EXT(c)->subclasses)
92
+ #define RCLASS_SUPERCLASS_DEPTH(c) (RCLASS_EXT(c)->superclass_depth)
93
+ #define RCLASS_SUPERCLASSES(c) (RCLASS_EXT(c)->superclasses)
94
+
95
+ #define RICLASS_IS_ORIGIN FL_USER0
96
+ #define RCLASS_CLONED FL_USER1
97
+ #define RCLASS_SUPERCLASSES_INCLUDE_SELF FL_USER2
98
+ #define RICLASS_ORIGIN_SHARED_MTBL FL_USER3
99
+
100
+ /* class.c */
101
+ void rb_class_subclass_add(VALUE super, VALUE klass);
102
+ void rb_class_remove_from_super_subclasses(VALUE);
103
+ void rb_class_update_superclasses(VALUE);
104
+ size_t rb_class_superclasses_memsize(VALUE);
105
+ void rb_class_remove_subclass_head(VALUE);
106
+ int rb_singleton_class_internal_p(VALUE sklass);
107
+ VALUE rb_class_boot(VALUE);
108
+ VALUE rb_class_s_alloc(VALUE klass);
109
+ VALUE rb_module_s_alloc(VALUE klass);
110
+ void rb_module_set_initialized(VALUE module);
111
+ void rb_module_check_initializable(VALUE module);
112
+ VALUE rb_make_metaclass(VALUE, VALUE);
113
+ VALUE rb_include_class_new(VALUE, VALUE);
114
+ void rb_class_foreach_subclass(VALUE klass, void (*f)(VALUE, VALUE), VALUE);
115
+ void rb_class_detach_subclasses(VALUE);
116
+ void rb_class_detach_module_subclasses(VALUE);
117
+ void rb_class_remove_from_module_subclasses(VALUE);
118
+ VALUE rb_obj_methods(int argc, const VALUE *argv, VALUE obj);
119
+ VALUE rb_obj_protected_methods(int argc, const VALUE *argv, VALUE obj);
120
+ VALUE rb_obj_private_methods(int argc, const VALUE *argv, VALUE obj);
121
+ VALUE rb_obj_public_methods(int argc, const VALUE *argv, VALUE obj);
122
+ VALUE rb_class_undefined_instance_methods(VALUE mod);
123
+ VALUE rb_special_singleton_class(VALUE);
124
+ VALUE rb_singleton_class_clone_and_attach(VALUE obj, VALUE attach);
125
+ VALUE rb_singleton_class_get(VALUE obj);
126
+ void rb_undef_methods_from(VALUE klass, VALUE super);
127
+
128
+ static inline void RCLASS_SET_ORIGIN(VALUE klass, VALUE origin);
129
+ static inline void RICLASS_SET_ORIGIN_SHARED_MTBL(VALUE iclass);
130
+ static inline VALUE RCLASS_SUPER(VALUE klass);
131
+ static inline VALUE RCLASS_SET_SUPER(VALUE klass, VALUE super);
132
+ static inline void RCLASS_SET_INCLUDER(VALUE iclass, VALUE klass);
133
+
134
+ MJIT_SYMBOL_EXPORT_BEGIN
135
+ VALUE rb_class_inherited(VALUE, VALUE);
136
+ VALUE rb_keyword_error_new(const char *, VALUE);
137
+ MJIT_SYMBOL_EXPORT_END
138
+
139
+ static inline void
140
+ RCLASS_SET_ORIGIN(VALUE klass, VALUE origin)
141
+ {
142
+ RB_OBJ_WRITE(klass, &RCLASS_ORIGIN(klass), origin);
143
+ if (klass != origin) FL_SET(origin, RICLASS_IS_ORIGIN);
144
+ }
145
+
146
+ static inline void
147
+ RICLASS_SET_ORIGIN_SHARED_MTBL(VALUE iclass)
148
+ {
149
+ FL_SET(iclass, RICLASS_ORIGIN_SHARED_MTBL);
150
+ }
151
+
152
+ static inline bool
153
+ RICLASS_OWNS_M_TBL_P(VALUE iclass)
154
+ {
155
+ return FL_TEST_RAW(iclass, RICLASS_IS_ORIGIN | RICLASS_ORIGIN_SHARED_MTBL) == RICLASS_IS_ORIGIN;
156
+ }
157
+
158
+ static inline void
159
+ RCLASS_SET_INCLUDER(VALUE iclass, VALUE klass)
160
+ {
161
+ RB_OBJ_WRITE(iclass, &RCLASS_INCLUDER(iclass), klass);
162
+ }
163
+
164
+ static inline VALUE
165
+ RCLASS_SUPER(VALUE klass)
166
+ {
167
+ return RCLASS(klass)->super;
168
+ }
169
+
170
+ static inline VALUE
171
+ RCLASS_SET_SUPER(VALUE klass, VALUE super)
172
+ {
173
+ if (super) {
174
+ rb_class_remove_from_super_subclasses(klass);
175
+ rb_class_subclass_add(super, klass);
176
+ }
177
+ RB_OBJ_WRITE(klass, &RCLASS(klass)->super, super);
178
+ rb_class_update_superclasses(klass);
179
+ return super;
180
+ }
181
+
182
+ #endif /* INTERNAL_CLASS_H */
@@ -0,0 +1,107 @@
1
+ #ifndef INTERNAL_COMPILERS_H /*-*-C-*-vi:se ft=c:*/
2
+ #define INTERNAL_COMPILERS_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 absorbing C compiler differences.
10
+ */
11
+ #include "ruby/internal/compiler_since.h"
12
+ #include "ruby/internal/has/attribute.h"
13
+ #include "ruby/internal/has/builtin.h"
14
+ #include "ruby/internal/has/c_attribute.h"
15
+ #include "ruby/internal/has/declspec_attribute.h"
16
+ #include "ruby/internal/has/extension.h"
17
+ #include "ruby/internal/has/feature.h"
18
+ #include "ruby/internal/has/warning.h"
19
+ #include "ruby/backward/2/gcc_version_since.h"
20
+
21
+ #define MSC_VERSION_SINCE(_) RBIMPL_COMPILER_SINCE(MSVC, (_) / 100, (_) % 100, 0)
22
+ #define MSC_VERSION_BEFORE(_) RBIMPL_COMPILER_BEFORE(MSVC, (_) / 100, (_) % 100, 0)
23
+
24
+ #ifndef __has_attribute
25
+ # define __has_attribute(...) RBIMPL_HAS_ATTRIBUTE(__VA_ARGS__)
26
+ #endif
27
+
28
+ #ifndef __has_c_attribute
29
+ # /* As of writing everything that lacks __has_c_attribute also completely
30
+ # * lacks C2x attributes as well. Might change in future? */
31
+ # define __has_c_attribute(...) 0
32
+ #endif
33
+
34
+ #ifndef __has_declspec_attribute
35
+ # define __has_declspec_attribute(...) RBIMPL_HAS_DECLSPEC_ATTRIBUTE(__VA_ARGS__)
36
+ #endif
37
+
38
+ #ifndef __has_builtin
39
+ # define __has_builtin(...) RBIMPL_HAS_BUILTIN(__VA_ARGS__)
40
+ #endif
41
+
42
+ #ifndef __has_feature
43
+ # define __has_feature(...) RBIMPL_HAS_FEATURE(__VA_ARGS__)
44
+ #endif
45
+
46
+ #ifndef __has_extension
47
+ # define __has_extension(...) RBIMPL_HAS_EXTENSION(__VA_ARGS__)
48
+ #endif
49
+
50
+ #ifndef __has_warning
51
+ # define __has_warning(...) RBIMPL_HAS_WARNING(__VA_ARGS__)
52
+ #endif
53
+
54
+ #ifndef __GNUC__
55
+ # define __extension__ /* void */
56
+ #endif
57
+
58
+ #ifndef MAYBE_UNUSED
59
+ # define MAYBE_UNUSED(x) x
60
+ #endif
61
+
62
+ #ifndef WARN_UNUSED_RESULT
63
+ # define WARN_UNUSED_RESULT(x) x
64
+ #endif
65
+
66
+ #define RB_OBJ_BUILTIN_TYPE(obj) rb_obj_builtin_type(obj)
67
+ #define OBJ_BUILTIN_TYPE(obj) RB_OBJ_BUILTIN_TYPE(obj)
68
+ #ifdef __GNUC__
69
+ #define rb_obj_builtin_type(obj) \
70
+ __extension__({ \
71
+ VALUE arg_obj = (obj); \
72
+ RB_SPECIAL_CONST_P(arg_obj) ? -1 : \
73
+ (int)RB_BUILTIN_TYPE(arg_obj); \
74
+ })
75
+ #else
76
+ # include "ruby/ruby.h"
77
+ static inline int
78
+ rb_obj_builtin_type(VALUE obj)
79
+ {
80
+ return RB_SPECIAL_CONST_P(obj) ? -1 :
81
+ (int)RB_BUILTIN_TYPE(obj);
82
+ }
83
+ #endif
84
+
85
+ /* A macro for defining a flexible array, like: VALUE ary[FLEX_ARY_LEN]; */
86
+ #if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
87
+ # define FLEX_ARY_LEN /* VALUE ary[]; */
88
+ #elif defined(__GNUC__) && !defined(__STRICT_ANSI__)
89
+ # define FLEX_ARY_LEN 0 /* VALUE ary[0]; */
90
+ #else
91
+ # define FLEX_ARY_LEN 1 /* VALUE ary[1]; */
92
+ #endif
93
+
94
+ /*
95
+ * For declaring bitfields out of non-unsigned int types:
96
+ * struct date {
97
+ * BITFIELD(enum months, month, 4);
98
+ * ...
99
+ * };
100
+ */
101
+ #if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
102
+ # define BITFIELD(type, name, size) type name : size
103
+ #else
104
+ # define BITFIELD(type, name, size) unsigned int name : size
105
+ #endif
106
+
107
+ #endif /* INTERNAL_COMPILERS_H */
@@ -0,0 +1,192 @@
1
+ #ifndef INTERNAL_GC_H /*-*-C-*-vi:se ft=c:*/
2
+ #define INTERNAL_GC_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 GC.
10
+ */
11
+ #include "ruby/internal/config.h"
12
+
13
+ #include <stddef.h> /* for size_t */
14
+
15
+ #include "internal/compilers.h" /* for __has_attribute */
16
+ #include "ruby/ruby.h" /* for rb_event_flag_t */
17
+
18
+ struct rb_execution_context_struct; /* in vm_core.h */
19
+ struct rb_objspace; /* in vm_core.h */
20
+
21
+ #ifdef NEWOBJ_OF
22
+ # undef NEWOBJ_OF
23
+ # undef RB_NEWOBJ_OF
24
+ # undef RB_OBJ_WRITE
25
+ #endif
26
+
27
+ #define RVALUE_SIZE (sizeof(struct RBasic) + sizeof(VALUE[RBIMPL_RVALUE_EMBED_LEN_MAX]))
28
+
29
+ #define RB_RVARGC_NEWOBJ_OF(var, T, c, f, s) \
30
+ T *(var) = (T *)(((f) & FL_WB_PROTECTED) ? \
31
+ rb_wb_protected_newobj_of((c), (f) & ~FL_WB_PROTECTED, s) : \
32
+ rb_wb_unprotected_newobj_of((c), (f), s))
33
+
34
+ #define RB_RVARGC_EC_NEWOBJ_OF(ec, var, T, c, f, s) \
35
+ T *(var) = (T *)(((f) & FL_WB_PROTECTED) ? \
36
+ rb_ec_wb_protected_newobj_of((ec), (c), (f) & ~FL_WB_PROTECTED, s) : \
37
+ rb_wb_unprotected_newobj_of((c), (f), s))
38
+
39
+ /* optimized version of NEWOBJ() */
40
+ #define RB_NEWOBJ_OF(var, T, c, f) RB_RVARGC_NEWOBJ_OF(var, T, c, f, RVALUE_SIZE)
41
+
42
+ #define RB_EC_NEWOBJ_OF(ec, var, T, c, f) RB_RVARGC_EC_NEWOBJ_OF(ec, var, T, c, f, RVALUE_SIZE)
43
+
44
+ #define NEWOBJ_OF(var, T, c, f) RB_NEWOBJ_OF((var), T, (c), (f))
45
+ #define RVARGC_NEWOBJ_OF(var, T, c, f, s) RB_RVARGC_NEWOBJ_OF((var), T, (c), (f), (s))
46
+ #define RB_OBJ_GC_FLAGS_MAX 6 /* used in ext/objspace */
47
+
48
+ #ifndef USE_UNALIGNED_MEMBER_ACCESS
49
+ # define UNALIGNED_MEMBER_ACCESS(expr) (expr)
50
+ #elif ! USE_UNALIGNED_MEMBER_ACCESS
51
+ # define UNALIGNED_MEMBER_ACCESS(expr) (expr)
52
+ #elif ! (__has_warning("-Waddress-of-packed-member") || GCC_VERSION_SINCE(9, 0, 0))
53
+ # define UNALIGNED_MEMBER_ACCESS(expr) (expr)
54
+ #else
55
+ # include "internal/warnings.h"
56
+ # define UNALIGNED_MEMBER_ACCESS(expr) __extension__({ \
57
+ COMPILER_WARNING_PUSH; \
58
+ COMPILER_WARNING_IGNORED(-Waddress-of-packed-member); \
59
+ __typeof__(expr) unaligned_member_access_result = (expr); \
60
+ COMPILER_WARNING_POP; \
61
+ unaligned_member_access_result; \
62
+ })
63
+ #endif
64
+
65
+ #define UNALIGNED_MEMBER_PTR(ptr, mem) UNALIGNED_MEMBER_ACCESS(&(ptr)->mem)
66
+ #define RB_OBJ_WRITE(a, slot, b) \
67
+ rb_obj_write((VALUE)(a), UNALIGNED_MEMBER_ACCESS((VALUE *)(slot)), \
68
+ (VALUE)(b), __FILE__, __LINE__)
69
+
70
+ // We use SIZE_POOL_COUNT number of shape IDs for transitions out of different size pools
71
+ // The next available shapd ID will be the SPECIAL_CONST_SHAPE_ID
72
+ #if USE_RVARGC && (SIZEOF_UINT64_T == SIZEOF_VALUE)
73
+ # define SIZE_POOL_COUNT 5
74
+ #else
75
+ # define SIZE_POOL_COUNT 1
76
+ #endif
77
+
78
+ #define RCLASS_EXT_EMBEDDED (SIZE_POOL_COUNT > 1)
79
+
80
+ typedef struct ractor_newobj_size_pool_cache {
81
+ struct RVALUE *freelist;
82
+ struct heap_page *using_page;
83
+ } rb_ractor_newobj_size_pool_cache_t;
84
+
85
+ typedef struct ractor_newobj_cache {
86
+ size_t incremental_mark_step_allocated_slots;
87
+ rb_ractor_newobj_size_pool_cache_t size_pool_caches[SIZE_POOL_COUNT];
88
+ } rb_ractor_newobj_cache_t;
89
+
90
+ /* gc.c */
91
+ extern VALUE *ruby_initial_gc_stress_ptr;
92
+ extern int ruby_disable_gc;
93
+ RUBY_ATTR_MALLOC void *ruby_mimmalloc(size_t size);
94
+ void ruby_mimfree(void *ptr);
95
+ void rb_objspace_set_event_hook(const rb_event_flag_t event);
96
+ VALUE rb_objspace_gc_enable(struct rb_objspace *);
97
+ VALUE rb_objspace_gc_disable(struct rb_objspace *);
98
+ void ruby_gc_set_params(void);
99
+ void rb_copy_wb_protected_attribute(VALUE dest, VALUE obj);
100
+ #if __has_attribute(alloc_align)
101
+ __attribute__((__alloc_align__(1)))
102
+ #endif
103
+ RUBY_ATTR_MALLOC void *rb_aligned_malloc(size_t, size_t) RUBY_ATTR_ALLOC_SIZE((2));
104
+ size_t rb_size_mul_or_raise(size_t, size_t, VALUE); /* used in compile.c */
105
+ size_t rb_size_mul_add_or_raise(size_t, size_t, size_t, VALUE); /* used in iseq.h */
106
+ RUBY_ATTR_MALLOC void *rb_xmalloc_mul_add(size_t, size_t, size_t);
107
+ RUBY_ATTR_MALLOC void *rb_xcalloc_mul_add(size_t, size_t, size_t);
108
+ void *rb_xrealloc_mul_add(const void *, size_t, size_t, size_t);
109
+ RUBY_ATTR_MALLOC void *rb_xmalloc_mul_add_mul(size_t, size_t, size_t, size_t);
110
+ RUBY_ATTR_MALLOC void *rb_xcalloc_mul_add_mul(size_t, size_t, size_t, size_t);
111
+ static inline void *ruby_sized_xrealloc_inlined(void *ptr, size_t new_size, size_t old_size) RUBY_ATTR_RETURNS_NONNULL RUBY_ATTR_ALLOC_SIZE((2));
112
+ static inline void *ruby_sized_xrealloc2_inlined(void *ptr, size_t new_count, size_t elemsiz, size_t old_count) RUBY_ATTR_RETURNS_NONNULL RUBY_ATTR_ALLOC_SIZE((2, 3));
113
+ static inline void ruby_sized_xfree_inlined(void *ptr, size_t size);
114
+ VALUE rb_class_allocate_instance(VALUE klass);
115
+ void rb_gc_ractor_newobj_cache_clear(rb_ractor_newobj_cache_t *newobj_cache);
116
+ size_t rb_gc_obj_slot_size(VALUE obj);
117
+ bool rb_gc_size_allocatable_p(size_t size);
118
+ int rb_objspace_garbage_object_p(VALUE obj);
119
+
120
+ RUBY_SYMBOL_EXPORT_BEGIN
121
+ /* gc.c (export) */
122
+ const char *rb_objspace_data_type_name(VALUE obj);
123
+ VALUE rb_wb_protected_newobj_of(VALUE, VALUE, size_t);
124
+ VALUE rb_wb_unprotected_newobj_of(VALUE, VALUE, size_t);
125
+ VALUE rb_ec_wb_protected_newobj_of(struct rb_execution_context_struct *ec, VALUE klass, VALUE flags, size_t);
126
+ size_t rb_obj_memsize_of(VALUE);
127
+ void rb_gc_verify_internal_consistency(void);
128
+ size_t rb_obj_gc_flags(VALUE, ID[], size_t);
129
+ void rb_gc_mark_values(long n, const VALUE *values);
130
+ void rb_gc_mark_vm_stack_values(long n, const VALUE *values);
131
+ void *ruby_sized_xrealloc(void *ptr, size_t new_size, size_t old_size) RUBY_ATTR_RETURNS_NONNULL RUBY_ATTR_ALLOC_SIZE((2));
132
+ void *ruby_sized_xrealloc2(void *ptr, size_t new_count, size_t element_size, size_t old_count) RUBY_ATTR_RETURNS_NONNULL RUBY_ATTR_ALLOC_SIZE((2, 3));
133
+ void ruby_sized_xfree(void *x, size_t size);
134
+ RUBY_SYMBOL_EXPORT_END
135
+
136
+ MJIT_SYMBOL_EXPORT_BEGIN
137
+ int rb_ec_stack_check(struct rb_execution_context_struct *ec);
138
+ void rb_gc_writebarrier_remember(VALUE obj);
139
+ const char *rb_obj_info(VALUE obj);
140
+ MJIT_SYMBOL_EXPORT_END
141
+
142
+ #if defined(HAVE_MALLOC_USABLE_SIZE) || defined(HAVE_MALLOC_SIZE) || defined(_WIN32)
143
+
144
+ static inline void *
145
+ ruby_sized_xrealloc_inlined(void *ptr, size_t new_size, size_t old_size)
146
+ {
147
+ return ruby_xrealloc(ptr, new_size);
148
+ }
149
+
150
+ static inline void *
151
+ ruby_sized_xrealloc2_inlined(void *ptr, size_t new_count, size_t elemsiz, size_t old_count)
152
+ {
153
+ return ruby_xrealloc2(ptr, new_count, elemsiz);
154
+ }
155
+
156
+ static inline void
157
+ ruby_sized_xfree_inlined(void *ptr, size_t size)
158
+ {
159
+ ruby_xfree(ptr);
160
+ }
161
+
162
+ # define SIZED_REALLOC_N(x, y, z, w) REALLOC_N(x, y, z)
163
+
164
+ #else
165
+
166
+ static inline void *
167
+ ruby_sized_xrealloc_inlined(void *ptr, size_t new_size, size_t old_size)
168
+ {
169
+ return ruby_sized_xrealloc(ptr, new_size, old_size);
170
+ }
171
+
172
+ static inline void *
173
+ ruby_sized_xrealloc2_inlined(void *ptr, size_t new_count, size_t elemsiz, size_t old_count)
174
+ {
175
+ return ruby_sized_xrealloc2(ptr, new_count, elemsiz, old_count);
176
+ }
177
+
178
+ static inline void
179
+ ruby_sized_xfree_inlined(void *ptr, size_t size)
180
+ {
181
+ ruby_sized_xfree(ptr, size);
182
+ }
183
+
184
+ # define SIZED_REALLOC_N(v, T, m, n) \
185
+ ((v) = (T *)ruby_sized_xrealloc2((void *)(v), (m), sizeof(T), (n)))
186
+
187
+ #endif /* HAVE_MALLOC_USABLE_SIZE */
188
+
189
+ #define ruby_sized_xrealloc ruby_sized_xrealloc_inlined
190
+ #define ruby_sized_xrealloc2 ruby_sized_xrealloc2_inlined
191
+ #define ruby_sized_xfree ruby_sized_xfree_inlined
192
+ #endif /* INTERNAL_GC_H */