datadog-ruby_core_source 3.5.4 → 3.5.6

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 (198) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +0 -2
  3. data/datadog-ruby_core_source.gemspec +1 -1
  4. data/lib/datadog/ruby_core_source/ruby-2.6.0-p0/ccan/build_assert/build_assert.h +40 -0
  5. data/lib/datadog/ruby_core_source/ruby-2.6.0-p0/ccan/check_type/check_type.h +63 -0
  6. data/lib/datadog/ruby_core_source/ruby-2.6.0-p0/ccan/container_of/container_of.h +142 -0
  7. data/lib/datadog/ruby_core_source/ruby-2.6.0-p0/ccan/list/list.h +788 -0
  8. data/lib/datadog/ruby_core_source/ruby-2.6.0-p0/ccan/str/str.h +16 -0
  9. data/lib/datadog/ruby_core_source/ruby-2.6.0-p0/id.h +252 -0
  10. data/lib/datadog/ruby_core_source/ruby-2.6.0-p0/internal.h +2465 -0
  11. data/lib/datadog/ruby_core_source/ruby-2.6.0-p0/iseq.h +304 -0
  12. data/lib/datadog/ruby_core_source/ruby-2.6.0-p0/method.h +229 -0
  13. data/lib/datadog/ruby_core_source/ruby-2.6.0-p0/node.h +449 -0
  14. data/lib/datadog/ruby_core_source/ruby-2.6.0-p0/ruby_assert.h +60 -0
  15. data/lib/datadog/ruby_core_source/ruby-2.6.0-p0/ruby_atomic.h +244 -0
  16. data/lib/datadog/ruby_core_source/ruby-2.6.0-p0/thread_pthread.h +75 -0
  17. data/lib/datadog/ruby_core_source/ruby-2.6.0-p0/thread_win32.h +36 -0
  18. data/lib/datadog/ruby_core_source/ruby-2.6.0-p0/vm_core.h +1902 -0
  19. data/lib/datadog/ruby_core_source/ruby-2.6.0-p0/vm_opts.h +70 -0
  20. data/lib/datadog/ruby_core_source/ruby-2.7.0-p0/ccan/build_assert/build_assert.h +40 -0
  21. data/lib/datadog/ruby_core_source/ruby-2.7.0-p0/ccan/check_type/check_type.h +63 -0
  22. data/lib/datadog/ruby_core_source/ruby-2.7.0-p0/ccan/container_of/container_of.h +142 -0
  23. data/lib/datadog/ruby_core_source/ruby-2.7.0-p0/ccan/list/list.h +788 -0
  24. data/lib/datadog/ruby_core_source/ruby-2.7.0-p0/ccan/str/str.h +16 -0
  25. data/lib/datadog/ruby_core_source/ruby-2.7.0-p0/id.h +290 -0
  26. data/lib/datadog/ruby_core_source/ruby-2.7.0-p0/internal.h +2697 -0
  27. data/lib/datadog/ruby_core_source/ruby-2.7.0-p0/iseq.h +312 -0
  28. data/lib/datadog/ruby_core_source/ruby-2.7.0-p0/method.h +229 -0
  29. data/lib/datadog/ruby_core_source/ruby-2.7.0-p0/node.h +476 -0
  30. data/lib/datadog/ruby_core_source/ruby-2.7.0-p0/ruby_assert.h +15 -0
  31. data/lib/datadog/ruby_core_source/ruby-2.7.0-p0/ruby_atomic.h +244 -0
  32. data/lib/datadog/ruby_core_source/ruby-2.7.0-p0/thread_pthread.h +75 -0
  33. data/lib/datadog/ruby_core_source/ruby-2.7.0-p0/thread_win32.h +36 -0
  34. data/lib/datadog/ruby_core_source/ruby-2.7.0-p0/vm_core.h +1968 -0
  35. data/lib/datadog/ruby_core_source/ruby-2.7.0-p0/vm_opts.h +72 -0
  36. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/ccan/build_assert/build_assert.h +40 -0
  37. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/ccan/check_type/check_type.h +63 -0
  38. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/ccan/container_of/container_of.h +142 -0
  39. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/ccan/list/list.h +788 -0
  40. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/ccan/str/str.h +16 -0
  41. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/id.h +290 -0
  42. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/id_table.h +36 -0
  43. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/internal/array.h +119 -0
  44. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/internal/class.h +174 -0
  45. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/internal/compilers.h +108 -0
  46. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/internal/gc.h +161 -0
  47. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/internal/imemo.h +243 -0
  48. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/internal/serial.h +24 -0
  49. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/internal/static_assert.h +17 -0
  50. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/internal/vm.h +136 -0
  51. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/internal/warnings.h +17 -0
  52. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/internal.h +107 -0
  53. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/iseq.h +305 -0
  54. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/method.h +245 -0
  55. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/node.h +484 -0
  56. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/ractor_core.h +343 -0
  57. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/ruby_assert.h +15 -0
  58. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/ruby_atomic.h +23 -0
  59. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/thread_pthread.h +115 -0
  60. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/thread_win32.h +61 -0
  61. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/vm_core.h +2023 -0
  62. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/vm_debug.h +116 -0
  63. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/vm_opts.h +73 -0
  64. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/ccan/build_assert/build_assert.h +40 -0
  65. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/ccan/check_type/check_type.h +63 -0
  66. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/ccan/container_of/container_of.h +142 -0
  67. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/ccan/list/list.h +788 -0
  68. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/ccan/str/str.h +16 -0
  69. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/darray.h +198 -0
  70. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/id.h +293 -0
  71. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/id_table.h +36 -0
  72. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/internal/array.h +113 -0
  73. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/internal/class.h +196 -0
  74. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/internal/compilers.h +107 -0
  75. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/internal/gc.h +186 -0
  76. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/internal/imemo.h +243 -0
  77. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/internal/serial.h +23 -0
  78. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/internal/static_assert.h +16 -0
  79. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/internal/vm.h +133 -0
  80. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/internal/warnings.h +16 -0
  81. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/internal.h +109 -0
  82. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/iseq.h +322 -0
  83. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/method.h +253 -0
  84. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/node.h +510 -0
  85. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/ractor_core.h +346 -0
  86. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/ruby_assert.h +14 -0
  87. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/ruby_atomic.h +23 -0
  88. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/thread_pthread.h +115 -0
  89. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/vm_core.h +2107 -0
  90. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/vm_debug.h +124 -0
  91. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/vm_opts.h +73 -0
  92. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/ccan/build_assert/build_assert.h +40 -0
  93. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/ccan/check_type/check_type.h +63 -0
  94. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/ccan/container_of/container_of.h +142 -0
  95. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/ccan/list/list.h +789 -0
  96. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/ccan/str/str.h +17 -0
  97. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/id.h +299 -0
  98. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/id_table.h +39 -0
  99. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/internal/array.h +163 -0
  100. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/internal/basic_operators.h +64 -0
  101. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/internal/class.h +182 -0
  102. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/internal/compilers.h +107 -0
  103. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/internal/gc.h +192 -0
  104. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/internal/imemo.h +242 -0
  105. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/internal/serial.h +23 -0
  106. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/internal/static_assert.h +16 -0
  107. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/internal/vm.h +134 -0
  108. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/internal/warnings.h +16 -0
  109. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/internal.h +113 -0
  110. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/iseq.h +329 -0
  111. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/method.h +254 -0
  112. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/node.h +514 -0
  113. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/ractor_core.h +342 -0
  114. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/ruby_assert.h +14 -0
  115. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/ruby_atomic.h +23 -0
  116. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/shape.h +232 -0
  117. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/thread_none.h +20 -0
  118. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/thread_pthread.h +133 -0
  119. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/vm_core.h +2106 -0
  120. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/vm_debug.h +122 -0
  121. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/vm_opts.h +73 -0
  122. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/ccan/build_assert/build_assert.h +40 -0
  123. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/ccan/check_type/check_type.h +63 -0
  124. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/ccan/container_of/container_of.h +142 -0
  125. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/ccan/list/list.h +791 -0
  126. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/ccan/str/str.h +17 -0
  127. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/constant.h +53 -0
  128. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/debug_counter.h +428 -0
  129. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/hrtime.h +237 -0
  130. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/id.h +365 -0
  131. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/id_table.h +74 -0
  132. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/internal/array.h +158 -0
  133. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/internal/basic_operators.h +67 -0
  134. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/internal/bits.h +647 -0
  135. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/internal/box.h +103 -0
  136. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/internal/class.h +797 -0
  137. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/internal/compilers.h +104 -0
  138. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/internal/coverage.h +51 -0
  139. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/internal/gc.h +411 -0
  140. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/internal/imemo.h +302 -0
  141. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/internal/sanitizers.h +346 -0
  142. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/internal/serial.h +23 -0
  143. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/internal/set_table.h +77 -0
  144. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/internal/static_assert.h +16 -0
  145. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/internal/time.h +34 -0
  146. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/internal/variable.h +81 -0
  147. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/internal/vm.h +144 -0
  148. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/internal/warnings.h +16 -0
  149. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/internal.h +106 -0
  150. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/iseq.h +439 -0
  151. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/method.h +279 -0
  152. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/node.h +122 -0
  153. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/parser_st.h +161 -0
  154. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/parser_value.h +116 -0
  155. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/arena.h +37 -0
  156. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/ast.h +10371 -0
  157. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/buffer.h +52 -0
  158. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/comments.h +43 -0
  159. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/compiler/align.h +36 -0
  160. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/compiler/exported.h +24 -0
  161. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/compiler/filesystem.h +32 -0
  162. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/compiler/nodiscard.h +22 -0
  163. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/compiler/nonnull.h +18 -0
  164. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/constant_pool.h +81 -0
  165. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/diagnostic.h +93 -0
  166. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/errors_format.h +53 -0
  167. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/excludes.h +29 -0
  168. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/integer.h +41 -0
  169. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/json.h +32 -0
  170. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/line_offset_list.h +61 -0
  171. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/magic_comments.h +35 -0
  172. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/node.h +94 -0
  173. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/options.h +335 -0
  174. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/parser.h +348 -0
  175. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/prettyprint.h +31 -0
  176. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/prism.h +131 -0
  177. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/serialize.h +115 -0
  178. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/source.h +155 -0
  179. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/stream.h +28 -0
  180. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/string_query.h +63 -0
  181. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/stringy.h +72 -0
  182. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/version.h +38 -0
  183. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism_compile.h +204 -0
  184. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/ractor_core.h +421 -0
  185. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/ruby_assert.h +14 -0
  186. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/ruby_atomic.h +115 -0
  187. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/rubyparser.h +1389 -0
  188. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/shape.h +733 -0
  189. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/thread_none.h +25 -0
  190. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/thread_pthread.h +63 -0
  191. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/thread_sched.h +271 -0
  192. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/vm_core.h +2509 -0
  193. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/vm_debug.h +124 -0
  194. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/vm_opts.h +65 -0
  195. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/vm_sync.h +160 -0
  196. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/zjit.h +221 -0
  197. data/lib/datadog/ruby_core_source/version.rb +1 -1
  198. metadata +197 -4
@@ -0,0 +1,302 @@
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
+ struct rb_gc_mark_ctx; /* internal/gc.h */
19
+
20
+ #define IMEMO_MASK (FL_USER0 | FL_USER1 | FL_USER2 | FL_USER3 | FL_USER4)
21
+
22
+ /* FL_USER0 to FL_USER4 is for type */
23
+ #define IMEMO_FL_USHIFT (FL_USHIFT + 5)
24
+ #define IMEMO_FL_USER0 FL_USER5
25
+ #define IMEMO_FL_USER1 FL_USER6
26
+ #define IMEMO_FL_USER2 FL_USER7
27
+ #define IMEMO_FL_USER3 FL_USER8
28
+ #define IMEMO_FL_USER4 FL_USER9
29
+ #define IMEMO_FL_USER5 FL_USER10
30
+ #define IMEMO_FL_USER6 FL_USER11
31
+
32
+ enum imemo_type {
33
+ imemo_env = 0,
34
+ imemo_cref = 1, /*!< class reference */
35
+ imemo_svar = 2, /*!< special variable */
36
+ imemo_throw_data = 3,
37
+ imemo_ifunc = 4, /*!< iterator function */
38
+ imemo_memo = 5,
39
+ imemo_ment = 6,
40
+ imemo_iseq = 7,
41
+ imemo_tmpbuf = 8,
42
+ imemo_cvar_entry = 9,
43
+ imemo_callinfo = 10,
44
+ imemo_callcache = 11,
45
+ imemo_constcache = 12,
46
+ imemo_fields = 13,
47
+ imemo_subclasses = 14,
48
+ imemo_cdhash = 15,
49
+ };
50
+
51
+ /* CREF (Class REFerence) is defined in method.h */
52
+
53
+ /*! SVAR (Special VARiable) */
54
+ struct vm_svar {
55
+ VALUE flags;
56
+ const VALUE cref_or_me; /*!< class reference or rb_method_entry_t */
57
+ const VALUE lastline;
58
+ const VALUE backref;
59
+ const VALUE others;
60
+ };
61
+
62
+ /*! THROW_DATA */
63
+ struct vm_throw_data {
64
+ VALUE flags;
65
+ const VALUE throw_obj;
66
+ const struct rb_control_frame_struct *catch_frame;
67
+ int throw_state;
68
+ };
69
+
70
+ #define THROW_DATA_CONSUMED IMEMO_FL_USER0
71
+
72
+ /* IFUNC (Internal FUNCtion) */
73
+
74
+ struct vm_ifunc_argc {
75
+ #if SIZEOF_INT * 2 > SIZEOF_VALUE
76
+ signed int min: (SIZEOF_VALUE * CHAR_BIT) / 2;
77
+ signed int max: (SIZEOF_VALUE * CHAR_BIT) / 2;
78
+ #else
79
+ int min, max;
80
+ #endif
81
+ };
82
+
83
+ /*! IFUNC (Internal FUNCtion)
84
+ *
85
+ * Bookkeeping for converting a C function and some closed-over data into a
86
+ * block passable to methods. Like Ruby Proc, but not directly accessible at
87
+ * Ruby level since this is an imemo. See rb_block_call() and friends.
88
+ */
89
+ struct vm_ifunc {
90
+ VALUE flags;
91
+ VALUE *svar_lep;
92
+ rb_block_call_func_t func;
93
+ const void *data;
94
+ struct vm_ifunc_argc argc;
95
+ };
96
+ #define IFUNC_YIELD_OPTIMIZABLE IMEMO_FL_USER0
97
+
98
+ struct rb_imemo_tmpbuf_struct {
99
+ VALUE flags;
100
+ VALUE *ptr; /* malloc'ed buffer */
101
+ size_t size; /* buffer size in bytes */
102
+ bool marked; /* whether the buffer may contain object references */
103
+ };
104
+
105
+ struct rb_imemo_cdhash {
106
+ VALUE flags;
107
+ st_table tbl;
108
+ };
109
+
110
+ /* Set on imemo_memo when u3 holds a VALUE that GC must mark.
111
+ * When unset, u3 is a non-VALUE (cnt/ucnt/state). */
112
+ #define MEMO_U3_IS_VALUE IMEMO_FL_USER0
113
+
114
+ /*! MEMO
115
+ *
116
+ * @see imemo_type
117
+ * */
118
+ struct MEMO {
119
+ VALUE flags;
120
+ const VALUE v1;
121
+ const VALUE v2;
122
+ union {
123
+ rb_len_t cnt;
124
+ rb_ulen_t ucnt;
125
+ long state;
126
+ const VALUE value;
127
+ } u3;
128
+ };
129
+
130
+ #define IMEMO_NEW(T, type, v0) ((T *)rb_imemo_new((type), (v0), sizeof(T), false))
131
+ #define SHAREABLE_IMEMO_NEW(T, type, v0) ((T *)rb_imemo_new((type), (v0), sizeof(T), true))
132
+
133
+ /* ment is in method.h */
134
+
135
+ #define THROW_DATA_P(err) imemo_throw_data_p((VALUE)err)
136
+ #define MEMO_CAST(m) ((struct MEMO *)(m))
137
+ #define MEMO_FOR(type, value) ((type *)RARRAY_PTR(value))
138
+ #define NEW_MEMO_FOR(type, value) \
139
+ ((value) = rb_ary_hidden_new_fill(type_roomof(type, VALUE)), MEMO_FOR(type, value))
140
+ #define NEW_PARTIAL_MEMO_FOR(type, value, member) \
141
+ ((value) = rb_ary_hidden_new_fill(type_roomof(type, VALUE)), \
142
+ rb_ary_set_len((value), offsetof(type, member) / sizeof(VALUE)), \
143
+ MEMO_FOR(type, value))
144
+
145
+ #ifndef RUBY_RUBYPARSER_H
146
+ typedef struct rb_imemo_tmpbuf_struct rb_imemo_tmpbuf_t;
147
+ #endif
148
+ VALUE rb_imemo_new(enum imemo_type type, VALUE v0, size_t size, bool is_shareable);
149
+ struct MEMO *rb_imemo_memo_new(VALUE a, VALUE b, rb_len_t c);
150
+ struct MEMO *rb_imemo_memo_new_value(VALUE a, VALUE b, VALUE c);
151
+ struct vm_ifunc *rb_vm_ifunc_new(rb_block_call_func_t func, const void *data, int min_argc, int max_argc);
152
+ static inline enum imemo_type imemo_type(VALUE imemo);
153
+ static inline int imemo_type_p(VALUE imemo, enum imemo_type imemo_type);
154
+ static inline bool imemo_throw_data_p(VALUE imemo);
155
+ static inline struct vm_ifunc *rb_vm_ifunc_proc_new(rb_block_call_func_t func, const void *data);
156
+ static inline void *RB_IMEMO_TMPBUF_PTR(VALUE v);
157
+ static inline void MEMO_V1_SET(struct MEMO *m, VALUE v);
158
+ static inline void MEMO_V2_SET(struct MEMO *m, VALUE v);
159
+
160
+ size_t rb_imemo_memsize(VALUE obj);
161
+ void rb_imemo_mark_and_move(const struct rb_gc_mark_ctx *ctx, VALUE obj, bool reference_updating);
162
+ void rb_imemo_free(VALUE obj);
163
+
164
+ RUBY_SYMBOL_EXPORT_BEGIN
165
+ const char *rb_imemo_name(enum imemo_type type);
166
+ ID rb_imemo_callinfo_mid(VALUE obj);
167
+ struct rb_imemo_callcache_data {
168
+ VALUE klass;
169
+ ID called_id;
170
+ };
171
+ bool rb_imemo_callcache_get_data(VALUE obj, struct rb_imemo_callcache_data *data);
172
+ RUBY_SYMBOL_EXPORT_END
173
+
174
+ static inline enum imemo_type
175
+ imemo_type(VALUE imemo)
176
+ {
177
+ return (RBASIC(imemo)->flags & IMEMO_MASK) >> FL_USHIFT;
178
+ }
179
+
180
+ static inline int
181
+ imemo_type_p(VALUE imemo, enum imemo_type imemo_type)
182
+ {
183
+ if (LIKELY(!RB_SPECIAL_CONST_P(imemo))) {
184
+ /* fixed at compile time if imemo_type is given. */
185
+ const VALUE mask = IMEMO_MASK | RUBY_T_MASK;
186
+ const VALUE expected_type = (imemo_type << FL_USHIFT) | T_IMEMO;
187
+ /* fixed at runtime. */
188
+ return expected_type == (RBASIC(imemo)->flags & mask);
189
+ }
190
+ else {
191
+ return 0;
192
+ }
193
+ }
194
+
195
+ #define IMEMO_TYPE_P(v, t) imemo_type_p((VALUE)(v), t)
196
+
197
+ static inline bool
198
+ imemo_throw_data_p(VALUE imemo)
199
+ {
200
+ return RB_TYPE_P(imemo, T_IMEMO);
201
+ }
202
+
203
+ static inline struct vm_ifunc *
204
+ rb_vm_ifunc_proc_new(rb_block_call_func_t func, const void *data)
205
+ {
206
+ return rb_vm_ifunc_new(func, data, 0, UNLIMITED_ARGUMENTS);
207
+ }
208
+
209
+ static inline void *
210
+ RB_IMEMO_TMPBUF_PTR(VALUE v)
211
+ {
212
+ const struct rb_imemo_tmpbuf_struct *p = (const void *)v;
213
+ return p->ptr;
214
+ }
215
+
216
+ static inline VALUE
217
+ rb_imemo_tmpbuf_new_from_an_RString(VALUE str)
218
+ {
219
+ VALUE imemo;
220
+ size_t len;
221
+
222
+ StringValue(str);
223
+ len = RSTRING_LEN(str);
224
+ rb_alloc_tmp_buffer(&imemo, len, false);
225
+ memcpy(RB_IMEMO_TMPBUF_PTR(imemo), RSTRING_PTR(str), len);
226
+ return imemo;
227
+ }
228
+
229
+ static inline void
230
+ MEMO_V1_SET(struct MEMO *m, VALUE v)
231
+ {
232
+ RB_OBJ_WRITE(m, &m->v1, v);
233
+ }
234
+
235
+ static inline void
236
+ MEMO_V2_SET(struct MEMO *m, VALUE v)
237
+ {
238
+ RB_OBJ_WRITE(m, &m->v2, v);
239
+ }
240
+
241
+ VALUE rb_imemo_cdhash_new(size_t size, const struct st_hash_type *type);
242
+
243
+ static inline st_table *
244
+ rb_imemo_cdhash_tbl(VALUE obj)
245
+ {
246
+ RUBY_ASSERT(IMEMO_TYPE_P(obj, imemo_cdhash));
247
+ return &((struct rb_imemo_cdhash *)obj)->tbl;
248
+ }
249
+
250
+ struct rb_fields {
251
+ struct RBasic basic;
252
+ union {
253
+ struct {
254
+ VALUE fields[1];
255
+ } embed;
256
+ struct {
257
+ st_table table;
258
+ } complex;
259
+ } as;
260
+ };
261
+
262
+ // IMEMO/fields and T_OBJECT have exactly the same layout.
263
+ // This is useful for JIT and common codepaths.
264
+ STATIC_ASSERT(imemo_fields_embed_offset, offsetof(struct RObject, as.ary) == offsetof(struct rb_fields, as.embed.fields));
265
+
266
+ #define IMEMO_OBJ_FIELDS(fields) ((struct rb_fields *)fields)
267
+
268
+ #define IMEMO_SUBCLASSES_HEAP IMEMO_FL_USER0
269
+
270
+ struct rb_subclasses {
271
+ VALUE flags;
272
+ uint32_t count;
273
+ uint32_t capacity;
274
+ union {
275
+ VALUE *external;
276
+ VALUE embed[1];
277
+ } as;
278
+ };
279
+
280
+ static inline VALUE *
281
+ rb_imemo_subclasses_entries(VALUE v)
282
+ {
283
+ struct rb_subclasses *s = (struct rb_subclasses *)v;
284
+ return FL_TEST_RAW(v, IMEMO_SUBCLASSES_HEAP) ? s->as.external : s->as.embed;
285
+ }
286
+
287
+ VALUE rb_imemo_fields_new(VALUE owner, /* shape_id_t */ uint32_t shape_id, bool shareable);
288
+ VALUE rb_imemo_subclasses_new(uint32_t capacity);
289
+ VALUE rb_imemo_fields_new_complex(VALUE owner, /* shape_id_t */ uint32_t shape_id, size_t capa, bool shareable);
290
+ VALUE rb_imemo_fields_new_complex_empty(VALUE owner);
291
+ VALUE rb_imemo_fields_clone(VALUE fields_obj);
292
+ void rb_imemo_fields_clear(VALUE fields_obj);
293
+
294
+ static inline VALUE
295
+ rb_imemo_fields_owner(VALUE fields_obj)
296
+ {
297
+ RUBY_ASSERT(IMEMO_TYPE_P(fields_obj, imemo_fields));
298
+
299
+ return CLASS_OF(fields_obj);
300
+ }
301
+
302
+ #endif /* INTERNAL_IMEMO_H */
@@ -0,0 +1,346 @@
1
+ #ifndef INTERNAL_SANITIZERS_H /*-*-C-*-vi:se ft=c:*/
2
+ #define INTERNAL_SANITIZERS_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 ASAN / MSAN / etc.
10
+ */
11
+ #include "ruby/internal/config.h"
12
+ #include "internal/compilers.h" /* for __has_feature */
13
+
14
+ #ifdef HAVE_VALGRIND_MEMCHECK_H
15
+ # include <valgrind/memcheck.h>
16
+ #endif
17
+
18
+ #ifdef HAVE_SANITIZER_ASAN_INTERFACE_H
19
+ # if __has_feature(address_sanitizer) || defined(__SANITIZE_ADDRESS__)
20
+ # define RUBY_ASAN_ENABLED
21
+ # include <sanitizer/asan_interface.h>
22
+ # endif
23
+ #endif
24
+
25
+ #ifdef HAVE_SANITIZER_MSAN_INTERFACE_H
26
+ # if __has_feature(memory_sanitizer)
27
+ # define RUBY_MSAN_ENABLED
28
+ # include <sanitizer/msan_interface.h>
29
+ # endif
30
+ #endif
31
+
32
+ #ifdef HAVE_SANITIZER_TSAN_INTERFACE_H
33
+ # if __has_feature(thread_sanitizer) || defined(__SANITIZE_THREAD__)
34
+ # define RUBY_TSAN_ENABLED
35
+ # include <sanitizer/tsan_interface.h>
36
+ # endif
37
+ #endif
38
+
39
+ #include "ruby/internal/stdbool.h" /* for bool */
40
+ #include "ruby/ruby.h" /* for VALUE */
41
+
42
+ #if 0
43
+ #elif defined(RUBY_ASAN_ENABLED) && defined(RUBY_MSAN_ENABLED)
44
+ # define ATTRIBUTE_NO_ADDRESS_SAFETY_ANALYSIS(x) \
45
+ __attribute__((__no_sanitize__("memory, address"), __noinline__)) x
46
+ #elif defined(RUBY_ASAN_ENABLED)
47
+ # define ATTRIBUTE_NO_ADDRESS_SAFETY_ANALYSIS(x) \
48
+ __attribute__((__no_sanitize__("address"), __noinline__)) x
49
+ #elif defined(RUBY_MSAN_ENABLED)
50
+ # define ATTRIBUTE_NO_ADDRESS_SAFETY_ANALYSIS(x) \
51
+ __attribute__((__no_sanitize__("memory"), __noinline__)) x
52
+ #elif defined(RUBY_TSAN_ENABLED)
53
+ # define ATTRIBUTE_NO_ADDRESS_SAFETY_ANALYSIS(x) \
54
+ __attribute__((__no_sanitize__("thread"), __noinline__)) x
55
+ #elif defined(NO_SANITIZE_ADDRESS)
56
+ # define ATTRIBUTE_NO_ADDRESS_SAFETY_ANALYSIS(x) \
57
+ NO_SANITIZE_ADDRESS(NOINLINE(x))
58
+ #elif defined(NO_ADDRESS_SAFETY_ANALYSIS)
59
+ # define ATTRIBUTE_NO_ADDRESS_SAFETY_ANALYSIS(x) \
60
+ NO_ADDRESS_SAFETY_ANALYSIS(NOINLINE(x))
61
+ #else
62
+ # define ATTRIBUTE_NO_ADDRESS_SAFETY_ANALYSIS(x) x
63
+ #endif
64
+
65
+ #if defined(NO_SANITIZE) && RBIMPL_COMPILER_IS(GCC)
66
+ /* GCC warns about unknown sanitizer, which is annoying. */
67
+ # include "internal/warnings.h"
68
+ # undef NO_SANITIZE
69
+ # define NO_SANITIZE(x, y) \
70
+ COMPILER_WARNING_PUSH \
71
+ COMPILER_WARNING_IGNORED(-Wattributes) \
72
+ __attribute__((__no_sanitize__(x))) y; \
73
+ COMPILER_WARNING_POP \
74
+ y
75
+ #endif
76
+
77
+ #ifndef NO_SANITIZE
78
+ # define NO_SANITIZE(x, y) y
79
+ #endif
80
+
81
+ #ifndef RUBY_ASAN_ENABLED
82
+ # define __asan_poison_memory_region(x, y)
83
+ # define __asan_unpoison_memory_region(x, y)
84
+ # define __asan_region_is_poisoned(x, y) 0
85
+ # define __asan_get_current_fake_stack() NULL
86
+ # define __asan_addr_is_in_fake_stack(fake_stack, slot, start, end) NULL
87
+ #endif
88
+
89
+ #ifndef RUBY_MSAN_ENABLED
90
+ # define __msan_allocated_memory(x, y) ((void)(x), (void)(y))
91
+ # define __msan_poison(x, y) ((void)(x), (void)(y))
92
+ # define __msan_unpoison(x, y) ((void)(x), (void)(y))
93
+ # define __msan_unpoison_string(x) ((void)(x))
94
+ #endif
95
+
96
+ #ifdef VALGRIND_MAKE_READABLE
97
+ # define VALGRIND_MAKE_MEM_DEFINED(p, n) VALGRIND_MAKE_READABLE((p), (n))
98
+ #endif
99
+
100
+ #ifdef VALGRIND_MAKE_WRITABLE
101
+ # define VALGRIND_MAKE_MEM_UNDEFINED(p, n) VALGRIND_MAKE_WRITABLE((p), (n))
102
+ #endif
103
+
104
+ #ifndef VALGRIND_MAKE_MEM_DEFINED
105
+ # define VALGRIND_MAKE_MEM_DEFINED(p, n) 0
106
+ #endif
107
+
108
+ #ifndef VALGRIND_MAKE_MEM_UNDEFINED
109
+ # define VALGRIND_MAKE_MEM_UNDEFINED(p, n) 0
110
+ #endif
111
+
112
+ /**
113
+ * This function asserts that a (continuous) memory region from ptr to size
114
+ * being "poisoned". Both read / write access to such memory region are
115
+ * prohibited until properly unpoisoned. The region must be previously
116
+ * allocated (do not pass a freed pointer here), but not necessarily be an
117
+ * entire object that the malloc returns. You can punch hole a part of a
118
+ * gigantic heap arena. This is handy when you do not free an allocated memory
119
+ * region to reuse later: poison when you keep it unused, and unpoison when you
120
+ * reuse.
121
+ *
122
+ * @param[in] ptr pointer to the beginning of the memory region to poison.
123
+ * @param[in] size the length of the memory region to poison.
124
+ */
125
+ static inline void
126
+ asan_poison_memory_region(const volatile void *ptr, size_t size)
127
+ {
128
+ __msan_poison(ptr, size);
129
+ __asan_poison_memory_region(ptr, size);
130
+ }
131
+
132
+ #ifdef RUBY_ASAN_ENABLED
133
+ #define asan_poison_object_if(ptr, obj) do { \
134
+ if (ptr) rb_asan_poison_object(obj); \
135
+ } while (0)
136
+ #else
137
+ #define asan_poison_object_if(ptr, obj) ((void)(ptr), (void)(obj))
138
+ #endif
139
+
140
+ #ifdef RUBY_ASAN_ENABLED
141
+ RUBY_SYMBOL_EXPORT_BEGIN
142
+ /**
143
+ * This is a variant of asan_poison_memory_region that takes a VALUE.
144
+ *
145
+ * @param[in] obj target object.
146
+ */
147
+ void rb_asan_poison_object(VALUE obj);
148
+
149
+ /**
150
+ * This function predicates if the given object is fully addressable or not.
151
+ *
152
+ * @param[in] obj target object.
153
+ * @retval 0 the given object is fully addressable.
154
+ * @retval otherwise pointer to first such byte who is poisoned.
155
+ */
156
+ void *rb_asan_poisoned_object_p(VALUE obj);
157
+
158
+ /**
159
+ * This is a variant of asan_unpoison_memory_region that takes a VALUE.
160
+ *
161
+ * @param[in] obj target object.
162
+ * @param[in] malloc_p if the memory region is like a malloc's return value or not.
163
+ */
164
+ void rb_asan_unpoison_object(VALUE obj, bool newobj_p);
165
+
166
+ RUBY_SYMBOL_EXPORT_END
167
+ #else
168
+ # define rb_asan_poison_object(obj) ((void)obj)
169
+ # define rb_asan_poisoned_object_p(obj) ((void)obj, NULL)
170
+ # define rb_asan_unpoison_object(obj, newobj_p) ((void)obj, (void)newobj_p)
171
+ #endif
172
+
173
+ /**
174
+ * This function asserts that a (formally poisoned) memory region from ptr to
175
+ * size is now addressable. Write access to such memory region gets allowed.
176
+ * However read access might or might not be possible depending on situations,
177
+ * because the region can have contents of previous usages. That information
178
+ * should be passed by the malloc_p flag. If that is true, the contents of the
179
+ * region is _not_ fully defined (like the return value of malloc behaves).
180
+ * Reading from there is NG; write something first. If malloc_p is false on
181
+ * the other hand, that memory region is fully defined and can be read
182
+ * immediately.
183
+ *
184
+ * @param[in] ptr pointer to the beginning of the memory region to unpoison.
185
+ * @param[in] size the length of the memory region.
186
+ * @param[in] malloc_p if the memory region is like a malloc's return value or not.
187
+ */
188
+ static inline void
189
+ asan_unpoison_memory_region(const volatile void *ptr, size_t size, bool malloc_p)
190
+ {
191
+ __asan_unpoison_memory_region(ptr, size);
192
+ if (malloc_p) {
193
+ __msan_allocated_memory(ptr, size);
194
+ }
195
+ else {
196
+ __msan_unpoison(ptr, size);
197
+ }
198
+ }
199
+
200
+ static inline void *
201
+ asan_unpoison_object_temporary(VALUE obj)
202
+ {
203
+ void *ptr = rb_asan_poisoned_object_p(obj);
204
+ rb_asan_unpoison_object(obj, false);
205
+ return ptr;
206
+ }
207
+
208
+ static inline void *
209
+ asan_poison_object_restore(VALUE obj, void *ptr)
210
+ {
211
+ if (ptr) {
212
+ rb_asan_poison_object(obj);
213
+ }
214
+ return NULL;
215
+ }
216
+
217
+ #define asan_unpoisoning_object(obj) \
218
+ for (void *poisoned = asan_unpoison_object_temporary(obj), \
219
+ *unpoisoning = &poisoned; /* flag to loop just once */ \
220
+ unpoisoning; \
221
+ unpoisoning = asan_poison_object_restore(obj, poisoned))
222
+
223
+
224
+ static inline void *
225
+ asan_unpoison_memory_region_temporary(void *ptr, size_t len)
226
+ {
227
+ void *poisoned_ptr = __asan_region_is_poisoned(ptr, len);
228
+ asan_unpoison_memory_region(ptr, len, false);
229
+ return poisoned_ptr;
230
+ }
231
+
232
+ static inline void *
233
+ asan_poison_memory_region_restore(void *ptr, size_t len, void *poisoned_ptr)
234
+ {
235
+ if (poisoned_ptr) {
236
+ asan_poison_memory_region(ptr, len);
237
+ }
238
+ return NULL;
239
+ }
240
+
241
+ #define asan_unpoisoning_memory_region(ptr, len) \
242
+ for (void *poisoned = asan_unpoison_memory_region_temporary(ptr, len), \
243
+ *unpoisoning = &poisoned; /* flag to loop just once */ \
244
+ unpoisoning; \
245
+ unpoisoning = asan_poison_memory_region_restore(ptr, len, poisoned))
246
+
247
+ /**
248
+ * Checks if the given pointer is on an ASAN fake stack. If so, it returns the
249
+ * address this variable has on the real frame; if not, it returns the origin
250
+ * address unmodified.
251
+ *
252
+ * n.b. - _dereferencing_ the returned address is meaningless and should not
253
+ * be done; even though ASAN reserves space for the variable in both the real and
254
+ * fake stacks, the _value_ of that variable is only in the fake stack.
255
+ *
256
+ * n.b. - this only works for addresses passed in from local variables on the same
257
+ * thread, because the ASAN fake stacks are threadlocal.
258
+ *
259
+ * @param[in] slot the address of some local variable
260
+ * @retval a pointer to something from that frame on the _real_ machine stack
261
+ */
262
+ static inline void *
263
+ asan_get_real_stack_addr(void* slot)
264
+ {
265
+ VALUE *addr;
266
+ addr = __asan_addr_is_in_fake_stack(__asan_get_current_fake_stack(), slot, NULL, NULL);
267
+ return addr ? addr : slot;
268
+ }
269
+
270
+ /**
271
+ * Gets the current thread's fake stack handle, which can be passed into get_fake_stack_extents
272
+ *
273
+ * @retval An opaque value which can be passed to asan_get_fake_stack_extents
274
+ */
275
+ static inline void *
276
+ asan_get_thread_fake_stack_handle(void)
277
+ {
278
+ return __asan_get_current_fake_stack();
279
+ }
280
+
281
+ /**
282
+ * Checks if the given VALUE _actually_ represents a pointer to an ASAN fake stack.
283
+ *
284
+ * If the given slot _is_ actually a reference to an ASAN fake stack, and that fake stack
285
+ * contains the real values for the passed-in range of machine stack addresses, returns true
286
+ * and the range of the fake stack through the outparams.
287
+ *
288
+ * Otherwise, returns false, and sets the outparams to NULL.
289
+ *
290
+ * Note that this function expects "start" to be > "end" on downward-growing stack architectures;
291
+ *
292
+ * @param[in] thread_fake_stack_handle The asan fake stack reference for the thread we're scanning
293
+ * @param[in] slot The value on the machine stack we want to inspect
294
+ * @param[in] machine_stack_start The extents of the real machine stack on which slot lives
295
+ * @param[in] machine_stack_end The extents of the real machine stack on which slot lives
296
+ * @param[out] fake_stack_start_out The extents of the fake stack which contains real VALUEs
297
+ * @param[out] fake_stack_end_out The extents of the fake stack which contains real VALUEs
298
+ * @return Whether slot is a pointer to a fake stack for the given machine stack range
299
+ */
300
+
301
+ static inline bool
302
+ asan_get_fake_stack_extents(void *thread_fake_stack_handle, VALUE slot,
303
+ void *machine_stack_start, void *machine_stack_end,
304
+ void **fake_stack_start_out, void **fake_stack_end_out)
305
+ {
306
+ /* the ifdef is needed here to suppress a warning about fake_frame_{start/end} being
307
+ uninitialized if __asan_addr_is_in_fake_stack is an empty macro */
308
+ #ifdef RUBY_ASAN_ENABLED
309
+ void *fake_frame_start;
310
+ void *fake_frame_end;
311
+ void *real_stack_frame = __asan_addr_is_in_fake_stack(
312
+ thread_fake_stack_handle, (void *)slot, &fake_frame_start, &fake_frame_end
313
+ );
314
+ if (real_stack_frame) {
315
+ bool in_range;
316
+ #if STACK_GROW_DIRECTION < 0
317
+ in_range = machine_stack_start >= real_stack_frame && real_stack_frame >= machine_stack_end;
318
+ #else
319
+ in_range = machine_stack_start <= real_stack_frame && real_stack_frame <= machine_stack_end;
320
+ #endif
321
+ if (in_range) {
322
+ *fake_stack_start_out = fake_frame_start;
323
+ *fake_stack_end_out = fake_frame_end;
324
+ return true;
325
+ }
326
+ }
327
+ #endif
328
+ *fake_stack_start_out = 0;
329
+ *fake_stack_end_out = 0;
330
+ return false;
331
+ }
332
+
333
+ extern const char ruby_asan_default_options[];
334
+
335
+ #ifdef RUBY_ASAN_ENABLED
336
+ /* Compile in the ASAN options Ruby needs, rather than relying on environment variables, so
337
+ * that even tests which fork ruby with a clean environment will run ASAN with the right
338
+ * settings */
339
+ # undef RUBY__ASAN_DEFAULT_OPTIONS
340
+ # define RUBY__ASAN_DEFAULT_OPTIONS \
341
+ RBIMPL_SYMBOL_EXPORT_BEGIN() \
342
+ const char * __asan_default_options(void) {return ruby_asan_default_options;} \
343
+ RBIMPL_SYMBOL_EXPORT_END()
344
+ #endif
345
+
346
+ #endif /* INTERNAL_SANITIZERS_H */
@@ -0,0 +1,23 @@
1
+ #ifndef INTERNAL_SERIAL_H /*-*-C-*-vi:se ft=c:*/
2
+ #define INTERNAL_SERIAL_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 rb_serial_t.
10
+ */
11
+ #include "ruby/internal/config.h" /* for HAVE_LONG_LONG */
12
+ #include "ruby/defines.h" /* for LONG_LONG */
13
+
14
+ #ifndef HAVE_LONG_LONG
15
+ # error need C99+
16
+ #endif
17
+
18
+ typedef unsigned LONG_LONG rb_serial_t;
19
+ #define SERIALT2NUM ULL2NUM
20
+ #define PRI_SERIALT_PREFIX PRI_LL_PREFIX
21
+ #define SIZEOF_SERIAL_T SIZEOF_LONG_LONG
22
+
23
+ #endif /* INTERNAL_SERIAL_H */