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,304 @@
1
+ /**********************************************************************
2
+
3
+ iseq.h -
4
+
5
+ $Author: ko1 $
6
+ created at: 04/01/01 23:36:57 JST
7
+
8
+ Copyright (C) 2004-2008 Koichi Sasada
9
+
10
+ **********************************************************************/
11
+
12
+ #ifndef RUBY_ISEQ_H
13
+ #define RUBY_ISEQ_H 1
14
+
15
+ RUBY_EXTERN const int ruby_api_version[];
16
+ #define ISEQ_MAJOR_VERSION ((unsigned int)ruby_api_version[0])
17
+ #define ISEQ_MINOR_VERSION ((unsigned int)ruby_api_version[1])
18
+
19
+ #ifndef rb_iseq_t
20
+ typedef struct rb_iseq_struct rb_iseq_t;
21
+ #define rb_iseq_t rb_iseq_t
22
+ #endif
23
+
24
+ static inline size_t
25
+ rb_call_info_kw_arg_bytes(int keyword_len)
26
+ {
27
+ return sizeof(struct rb_call_info_kw_arg) + sizeof(VALUE) * (keyword_len - 1);
28
+ }
29
+
30
+ #define ISEQ_COVERAGE(iseq) iseq->body->variable.coverage
31
+ #define ISEQ_COVERAGE_SET(iseq, cov) RB_OBJ_WRITE(iseq, &iseq->body->variable.coverage, cov)
32
+ #define ISEQ_LINE_COVERAGE(iseq) RARRAY_AREF(ISEQ_COVERAGE(iseq), COVERAGE_INDEX_LINES)
33
+ #define ISEQ_BRANCH_COVERAGE(iseq) RARRAY_AREF(ISEQ_COVERAGE(iseq), COVERAGE_INDEX_BRANCHES)
34
+
35
+ #define ISEQ_PC2BRANCHINDEX(iseq) iseq->body->variable.pc2branchindex
36
+ #define ISEQ_PC2BRANCHINDEX_SET(iseq, h) RB_OBJ_WRITE(iseq, &iseq->body->variable.pc2branchindex, h)
37
+
38
+ #define ISEQ_FLIP_CNT(iseq) (iseq)->body->variable.flip_count
39
+
40
+ static inline rb_snum_t
41
+ ISEQ_FLIP_CNT_INCREMENT(const rb_iseq_t *iseq)
42
+ {
43
+ rb_snum_t cnt = iseq->body->variable.flip_count;
44
+ iseq->body->variable.flip_count += 1;
45
+ return cnt;
46
+ }
47
+
48
+ static inline VALUE *
49
+ ISEQ_ORIGINAL_ISEQ(const rb_iseq_t *iseq)
50
+ {
51
+ return iseq->body->variable.original_iseq;
52
+ }
53
+
54
+ static inline void
55
+ ISEQ_ORIGINAL_ISEQ_CLEAR(const rb_iseq_t *iseq)
56
+ {
57
+ void *ptr = iseq->body->variable.original_iseq;
58
+ iseq->body->variable.original_iseq = NULL;
59
+ if (ptr) {
60
+ ruby_xfree(ptr);
61
+ }
62
+ }
63
+
64
+ static inline VALUE *
65
+ ISEQ_ORIGINAL_ISEQ_ALLOC(const rb_iseq_t *iseq, long size)
66
+ {
67
+ return iseq->body->variable.original_iseq =
68
+ ruby_xmalloc2(size, sizeof(VALUE));
69
+ }
70
+
71
+ #define ISEQ_TRACE_EVENTS (RUBY_EVENT_LINE | \
72
+ RUBY_EVENT_CLASS | \
73
+ RUBY_EVENT_END | \
74
+ RUBY_EVENT_CALL | \
75
+ RUBY_EVENT_RETURN| \
76
+ RUBY_EVENT_B_CALL| \
77
+ RUBY_EVENT_B_RETURN| \
78
+ RUBY_EVENT_COVERAGE_LINE| \
79
+ RUBY_EVENT_COVERAGE_BRANCH)
80
+
81
+ #define ISEQ_NOT_LOADED_YET IMEMO_FL_USER1
82
+ #define ISEQ_USE_COMPILE_DATA IMEMO_FL_USER2
83
+ #define ISEQ_TRANSLATED IMEMO_FL_USER3
84
+ #define ISEQ_MARKABLE_ISEQ IMEMO_FL_USER4
85
+
86
+ #define ISEQ_EXECUTABLE_P(iseq) (FL_TEST_RAW((iseq), ISEQ_NOT_LOADED_YET | ISEQ_USE_COMPILE_DATA) == 0)
87
+
88
+ struct iseq_compile_data {
89
+ /* GC is needed */
90
+ const VALUE err_info;
91
+ VALUE mark_ary;
92
+ const VALUE catch_table_ary; /* Array */
93
+
94
+ /* GC is not needed */
95
+ struct iseq_label_data *start_label;
96
+ struct iseq_label_data *end_label;
97
+ struct iseq_label_data *redo_label;
98
+ const rb_iseq_t *current_block;
99
+ VALUE ensure_node;
100
+ VALUE for_iseq;
101
+ struct iseq_compile_data_ensure_node_stack *ensure_node_stack;
102
+ struct iseq_compile_data_storage *storage_head;
103
+ struct iseq_compile_data_storage *storage_current;
104
+ int loopval_popped; /* used by NODE_BREAK */
105
+ int last_line;
106
+ int label_no;
107
+ int node_level;
108
+ unsigned int ci_index;
109
+ unsigned int ci_kw_index;
110
+ const rb_compile_option_t *option;
111
+ struct rb_id_table *ivar_cache_table;
112
+ #if SUPPORT_JOKE
113
+ st_table *labels_table;
114
+ #endif
115
+ };
116
+
117
+ static inline struct iseq_compile_data *
118
+ ISEQ_COMPILE_DATA(const rb_iseq_t *iseq)
119
+ {
120
+ if (iseq->flags & ISEQ_USE_COMPILE_DATA) {
121
+ return iseq->aux.compile_data;
122
+ }
123
+ else {
124
+ return NULL;
125
+ }
126
+ }
127
+
128
+ static inline void
129
+ ISEQ_COMPILE_DATA_ALLOC(rb_iseq_t *iseq)
130
+ {
131
+ iseq->aux.compile_data = ZALLOC(struct iseq_compile_data);
132
+ iseq->flags |= ISEQ_USE_COMPILE_DATA;
133
+ }
134
+
135
+ static inline void
136
+ ISEQ_COMPILE_DATA_CLEAR(rb_iseq_t *iseq)
137
+ {
138
+ iseq->flags &= ~ISEQ_USE_COMPILE_DATA;
139
+ iseq->aux.compile_data = NULL;
140
+ }
141
+
142
+ static inline rb_iseq_t *
143
+ iseq_imemo_alloc(void)
144
+ {
145
+ return (rb_iseq_t *)rb_imemo_new(imemo_iseq, 0, 0, 0, 0);
146
+ }
147
+
148
+ VALUE rb_iseq_ibf_dump(const rb_iseq_t *iseq, VALUE opt);
149
+ void rb_ibf_load_iseq_complete(rb_iseq_t *iseq);
150
+ const rb_iseq_t *rb_iseq_ibf_load(VALUE str);
151
+ VALUE rb_iseq_ibf_load_extra_data(VALUE str);
152
+ void rb_iseq_init_trace(rb_iseq_t *iseq);
153
+ int rb_iseq_add_local_tracepoint_recursively(const rb_iseq_t *iseq, rb_event_flag_t turnon_events, VALUE tpval, unsigned int target_line);
154
+ int rb_iseq_remove_local_tracepoint_recursively(const rb_iseq_t *iseq, VALUE tpval);
155
+ const rb_iseq_t *rb_iseq_load_iseq(VALUE fname);
156
+
157
+ #if VM_INSN_INFO_TABLE_IMPL == 2
158
+ unsigned int *rb_iseq_insns_info_decode_positions(const struct rb_iseq_constant_body *body);
159
+ #endif
160
+
161
+ RUBY_SYMBOL_EXPORT_BEGIN
162
+
163
+ /* compile.c */
164
+ VALUE rb_iseq_compile_node(rb_iseq_t *iseq, const NODE *node);
165
+ VALUE rb_iseq_compile_ifunc(rb_iseq_t *iseq, const struct vm_ifunc *ifunc);
166
+ int rb_iseq_translate_threaded_code(rb_iseq_t *iseq);
167
+ VALUE *rb_iseq_original_iseq(const rb_iseq_t *iseq);
168
+ void rb_iseq_build_from_ary(rb_iseq_t *iseq, VALUE misc,
169
+ VALUE locals, VALUE args,
170
+ VALUE exception, VALUE body);
171
+
172
+ /* iseq.c */
173
+ VALUE rb_iseq_load(VALUE data, VALUE parent, VALUE opt);
174
+ VALUE rb_iseq_parameters(const rb_iseq_t *iseq, int is_proc);
175
+ struct st_table *ruby_insn_make_insn_table(void);
176
+ unsigned int rb_iseq_line_no(const rb_iseq_t *iseq, size_t pos);
177
+ void rb_iseq_trace_set(const rb_iseq_t *iseq, rb_event_flag_t turnon_events);
178
+ void rb_iseq_trace_set_all(rb_event_flag_t turnon_events);
179
+ void rb_iseq_trace_on_all(void);
180
+ void rb_iseq_insns_info_encode_positions(const rb_iseq_t *iseq);
181
+
182
+ VALUE rb_iseqw_new(const rb_iseq_t *iseq);
183
+ const rb_iseq_t *rb_iseqw_to_iseq(VALUE iseqw);
184
+
185
+ VALUE rb_iseq_absolute_path(const rb_iseq_t *iseq); /* obsolete */
186
+ VALUE rb_iseq_label(const rb_iseq_t *iseq);
187
+ VALUE rb_iseq_base_label(const rb_iseq_t *iseq);
188
+ VALUE rb_iseq_first_lineno(const rb_iseq_t *iseq);
189
+ VALUE rb_iseq_method_name(const rb_iseq_t *iseq);
190
+ void rb_iseq_code_location(const rb_iseq_t *iseq, int *first_lineno, int *first_column, int *last_lineno, int *last_column);
191
+
192
+ void rb_iseq_remove_coverage_all(void);
193
+
194
+ /* proc.c */
195
+ const rb_iseq_t *rb_method_iseq(VALUE body);
196
+ const rb_iseq_t *rb_proc_get_iseq(VALUE proc, int *is_proc);
197
+
198
+ struct rb_compile_option_struct {
199
+ unsigned int inline_const_cache: 1;
200
+ unsigned int peephole_optimization: 1;
201
+ unsigned int tailcall_optimization: 1;
202
+ unsigned int specialized_instruction: 1;
203
+ unsigned int operands_unification: 1;
204
+ unsigned int instructions_unification: 1;
205
+ unsigned int stack_caching: 1;
206
+ unsigned int frozen_string_literal: 1;
207
+ unsigned int debug_frozen_string_literal: 1;
208
+ unsigned int coverage_enabled: 1;
209
+ int debug_level;
210
+ };
211
+
212
+ struct iseq_insn_info_entry {
213
+ int line_no;
214
+ rb_event_flag_t events;
215
+ };
216
+
217
+ struct iseq_catch_table_entry {
218
+ enum catch_type {
219
+ CATCH_TYPE_RESCUE = INT2FIX(1),
220
+ CATCH_TYPE_ENSURE = INT2FIX(2),
221
+ CATCH_TYPE_RETRY = INT2FIX(3),
222
+ CATCH_TYPE_BREAK = INT2FIX(4),
223
+ CATCH_TYPE_REDO = INT2FIX(5),
224
+ CATCH_TYPE_NEXT = INT2FIX(6)
225
+ } type;
226
+
227
+ /*
228
+ * iseq type:
229
+ * CATCH_TYPE_RESCUE, CATCH_TYPE_ENSURE:
230
+ * use iseq as continuation.
231
+ *
232
+ * CATCH_TYPE_BREAK (iter):
233
+ * use iseq as key.
234
+ *
235
+ * CATCH_TYPE_BREAK (while), CATCH_TYPE_RETRY,
236
+ * CATCH_TYPE_REDO, CATCH_TYPE_NEXT:
237
+ * NULL.
238
+ */
239
+ const rb_iseq_t *iseq;
240
+
241
+ unsigned int start;
242
+ unsigned int end;
243
+ unsigned int cont;
244
+ unsigned int sp;
245
+ };
246
+
247
+ PACKED_STRUCT_UNALIGNED(struct iseq_catch_table {
248
+ unsigned int size;
249
+ struct iseq_catch_table_entry entries[FLEX_ARY_LEN];
250
+ });
251
+
252
+ static inline int
253
+ iseq_catch_table_bytes(int n)
254
+ {
255
+ enum {
256
+ catch_table_entry_size = sizeof(struct iseq_catch_table_entry),
257
+ catch_table_entries_max = (INT_MAX - offsetof(struct iseq_catch_table, entries)) / catch_table_entry_size
258
+ };
259
+ if (n > catch_table_entries_max) rb_fatal("too large iseq_catch_table - %d", n);
260
+ return (int)(offsetof(struct iseq_catch_table, entries) +
261
+ n * catch_table_entry_size);
262
+ }
263
+
264
+ #define INITIAL_ISEQ_COMPILE_DATA_STORAGE_BUFF_SIZE (512)
265
+
266
+ struct iseq_compile_data_storage {
267
+ struct iseq_compile_data_storage *next;
268
+ unsigned int pos;
269
+ unsigned int size;
270
+ char buff[FLEX_ARY_LEN];
271
+ };
272
+
273
+ /* defined? */
274
+
275
+ enum defined_type {
276
+ DEFINED_NOT_DEFINED,
277
+ DEFINED_NIL = 1,
278
+ DEFINED_IVAR,
279
+ DEFINED_LVAR,
280
+ DEFINED_GVAR,
281
+ DEFINED_CVAR,
282
+ DEFINED_CONST,
283
+ DEFINED_METHOD,
284
+ DEFINED_YIELD,
285
+ DEFINED_ZSUPER,
286
+ DEFINED_SELF,
287
+ DEFINED_TRUE,
288
+ DEFINED_FALSE,
289
+ DEFINED_ASGN,
290
+ DEFINED_EXPR,
291
+ DEFINED_IVAR2,
292
+ DEFINED_REF,
293
+ DEFINED_FUNC
294
+ };
295
+
296
+ VALUE rb_iseq_defined_string(enum defined_type type);
297
+ void rb_iseq_make_compile_option(struct rb_compile_option_struct *option, VALUE opt);
298
+
299
+ /* vm.c */
300
+ VALUE rb_iseq_local_variables(const rb_iseq_t *iseq);
301
+
302
+ RUBY_SYMBOL_EXPORT_END
303
+
304
+ #endif /* RUBY_ISEQ_H */
@@ -0,0 +1,229 @@
1
+ /**********************************************************************
2
+
3
+ method.h -
4
+
5
+ $Author: nobu $
6
+ created at: Wed Jul 15 20:02:33 2009
7
+
8
+ Copyright (C) 2009 Koichi Sasada
9
+
10
+ **********************************************************************/
11
+ #ifndef RUBY_METHOD_H
12
+ #define RUBY_METHOD_H 1
13
+
14
+ #include "internal.h"
15
+
16
+ #ifndef END_OF_ENUMERATION
17
+ # if defined(__GNUC__) &&! defined(__STRICT_ANSI__)
18
+ # define END_OF_ENUMERATION(key)
19
+ # else
20
+ # define END_OF_ENUMERATION(key) END_OF_##key##_PLACEHOLDER = 0
21
+ # endif
22
+ #endif
23
+
24
+ /* cref */
25
+
26
+ typedef enum {
27
+ METHOD_VISI_UNDEF = 0x00,
28
+ METHOD_VISI_PUBLIC = 0x01,
29
+ METHOD_VISI_PRIVATE = 0x02,
30
+ METHOD_VISI_PROTECTED = 0x03,
31
+
32
+ METHOD_VISI_MASK = 0x03
33
+ } rb_method_visibility_t;
34
+
35
+ typedef struct rb_scope_visi_struct {
36
+ BITFIELD(rb_method_visibility_t, method_visi, 3);
37
+ unsigned int module_func : 1;
38
+ } rb_scope_visibility_t;
39
+
40
+ /*! CREF (Class REFerence) */
41
+ typedef struct rb_cref_struct {
42
+ VALUE flags;
43
+ const VALUE refinements;
44
+ const VALUE klass;
45
+ struct rb_cref_struct * const next;
46
+ const rb_scope_visibility_t scope_visi;
47
+ } rb_cref_t;
48
+
49
+ /* method data type */
50
+
51
+ typedef struct rb_method_entry_struct {
52
+ VALUE flags;
53
+ const VALUE defined_class;
54
+ struct rb_method_definition_struct * const def;
55
+ ID called_id;
56
+ const VALUE owner;
57
+ } rb_method_entry_t;
58
+
59
+ typedef struct rb_callable_method_entry_struct { /* same fields with rb_method_entry_t */
60
+ VALUE flags;
61
+ const VALUE defined_class;
62
+ struct rb_method_definition_struct * const def;
63
+ ID called_id;
64
+ const VALUE owner;
65
+ } rb_callable_method_entry_t;
66
+
67
+ #define METHOD_ENTRY_VISI(me) (rb_method_visibility_t)(((me)->flags & (IMEMO_FL_USER0 | IMEMO_FL_USER1)) >> (IMEMO_FL_USHIFT+0))
68
+ #define METHOD_ENTRY_BASIC(me) (int) (((me)->flags & (IMEMO_FL_USER2 )) >> (IMEMO_FL_USHIFT+2))
69
+ #define METHOD_ENTRY_COMPLEMENTED(me) ((me)->flags & IMEMO_FL_USER3)
70
+ #define METHOD_ENTRY_COMPLEMENTED_SET(me) ((me)->flags = (me)->flags | IMEMO_FL_USER3)
71
+
72
+ static inline void
73
+ METHOD_ENTRY_VISI_SET(rb_method_entry_t *me, rb_method_visibility_t visi)
74
+ {
75
+ VM_ASSERT((int)visi >= 0 && visi <= 3);
76
+ me->flags = (me->flags & ~(IMEMO_FL_USER0 | IMEMO_FL_USER1)) | (visi << (IMEMO_FL_USHIFT+0));
77
+ }
78
+ static inline void
79
+ METHOD_ENTRY_BASIC_SET(rb_method_entry_t *me, unsigned int basic)
80
+ {
81
+ VM_ASSERT(basic <= 1);
82
+ me->flags = (me->flags & ~(IMEMO_FL_USER2 )) | (basic << (IMEMO_FL_USHIFT+2));
83
+ }
84
+ static inline void
85
+ METHOD_ENTRY_FLAGS_SET(rb_method_entry_t *me, rb_method_visibility_t visi, unsigned int basic)
86
+ {
87
+ VM_ASSERT((int)visi >= 0 && visi <= 3);
88
+ VM_ASSERT(basic <= 1);
89
+ me->flags =
90
+ (me->flags & ~(IMEMO_FL_USER0|IMEMO_FL_USER1|IMEMO_FL_USER2)) |
91
+ ((visi << (IMEMO_FL_USHIFT+0)) | (basic << (IMEMO_FL_USHIFT+2)));
92
+ }
93
+ static inline void
94
+ METHOD_ENTRY_FLAGS_COPY(rb_method_entry_t *dst, const rb_method_entry_t *src)
95
+ {
96
+ dst->flags =
97
+ (dst->flags & ~(IMEMO_FL_USER0|IMEMO_FL_USER1|IMEMO_FL_USER2)) |
98
+ (src->flags & (IMEMO_FL_USER0|IMEMO_FL_USER1|IMEMO_FL_USER2));
99
+ }
100
+
101
+ typedef enum {
102
+ VM_METHOD_TYPE_ISEQ, /*!< Ruby method */
103
+ VM_METHOD_TYPE_CFUNC, /*!< C method */
104
+ VM_METHOD_TYPE_ATTRSET, /*!< attr_writer or attr_accessor */
105
+ VM_METHOD_TYPE_IVAR, /*!< attr_reader or attr_accessor */
106
+ VM_METHOD_TYPE_BMETHOD,
107
+ VM_METHOD_TYPE_ZSUPER,
108
+ VM_METHOD_TYPE_ALIAS,
109
+ VM_METHOD_TYPE_UNDEF,
110
+ VM_METHOD_TYPE_NOTIMPLEMENTED,
111
+ VM_METHOD_TYPE_OPTIMIZED, /*!< Kernel#send, Proc#call, etc */
112
+ VM_METHOD_TYPE_MISSING, /*!< wrapper for method_missing(id) */
113
+ VM_METHOD_TYPE_REFINED, /*!< refinement */
114
+
115
+ END_OF_ENUMERATION(VM_METHOD_TYPE)
116
+ } rb_method_type_t;
117
+ #define VM_METHOD_TYPE_MINIMUM_BITS 4
118
+ /* TODO: STATIC_ASSERT for VM_METHOD_TYPE_MINIMUM_BITS */
119
+
120
+ #ifndef rb_iseq_t
121
+ typedef struct rb_iseq_struct rb_iseq_t;
122
+ #define rb_iseq_t rb_iseq_t
123
+ #endif
124
+
125
+ typedef struct rb_method_iseq_struct {
126
+ const rb_iseq_t * const iseqptr; /*!< iseq pointer, should be separated from iseqval */
127
+ rb_cref_t * const cref; /*!< class reference, should be marked */
128
+ } rb_method_iseq_t; /* check rb_add_method_iseq() when modify the fields */
129
+
130
+ typedef struct rb_method_cfunc_struct {
131
+ VALUE (*func)(ANYARGS);
132
+ VALUE (*invoker)(VALUE (*func)(ANYARGS), VALUE recv, int argc, const VALUE *argv);
133
+ int argc;
134
+ } rb_method_cfunc_t;
135
+
136
+ typedef struct rb_method_attr_struct {
137
+ ID id;
138
+ const VALUE location; /* should be marked */
139
+ } rb_method_attr_t;
140
+
141
+ typedef struct rb_method_alias_struct {
142
+ const struct rb_method_entry_struct * const original_me; /* original_me->klass is original owner */
143
+ } rb_method_alias_t;
144
+
145
+ typedef struct rb_method_refined_struct {
146
+ const struct rb_method_entry_struct * const orig_me;
147
+ const VALUE owner;
148
+ } rb_method_refined_t;
149
+
150
+ typedef struct rb_method_bmethod_struct {
151
+ const VALUE proc; /* should be marked */
152
+ struct rb_hook_list_struct *hooks;
153
+ } rb_method_bmethod_t;
154
+
155
+ enum method_optimized_type {
156
+ OPTIMIZED_METHOD_TYPE_SEND,
157
+ OPTIMIZED_METHOD_TYPE_CALL,
158
+ OPTIMIZED_METHOD_TYPE_BLOCK_CALL,
159
+ OPTIMIZED_METHOD_TYPE__MAX
160
+ };
161
+
162
+ PACKED_STRUCT_UNALIGNED(struct rb_method_definition_struct {
163
+ BITFIELD(rb_method_type_t, type, VM_METHOD_TYPE_MINIMUM_BITS);
164
+ int alias_count : 28;
165
+ int complemented_count : 28;
166
+
167
+ union {
168
+ rb_method_iseq_t iseq;
169
+ rb_method_cfunc_t cfunc;
170
+ rb_method_attr_t attr;
171
+ rb_method_alias_t alias;
172
+ rb_method_refined_t refined;
173
+ rb_method_bmethod_t bmethod;
174
+
175
+ enum method_optimized_type optimize_type;
176
+ } body;
177
+
178
+ ID original_id;
179
+ });
180
+
181
+ typedef struct rb_method_definition_struct rb_method_definition_t;
182
+
183
+ #define UNDEFINED_METHOD_ENTRY_P(me) (!(me) || !(me)->def || (me)->def->type == VM_METHOD_TYPE_UNDEF)
184
+ #define UNDEFINED_REFINED_METHOD_P(def) \
185
+ ((def)->type == VM_METHOD_TYPE_REFINED && \
186
+ UNDEFINED_METHOD_ENTRY_P((def)->body.refined.orig_me))
187
+
188
+ void rb_add_method_cfunc(VALUE klass, ID mid, VALUE (*func)(ANYARGS), int argc, rb_method_visibility_t visi);
189
+ void rb_add_method_iseq(VALUE klass, ID mid, const rb_iseq_t *iseq, rb_cref_t *cref, rb_method_visibility_t visi);
190
+ void rb_add_refined_method_entry(VALUE refined_class, ID mid);
191
+
192
+ rb_method_entry_t *rb_add_method(VALUE klass, ID mid, rb_method_type_t type, void *option, rb_method_visibility_t visi);
193
+ rb_method_entry_t *rb_method_entry_set(VALUE klass, ID mid, const rb_method_entry_t *, rb_method_visibility_t noex);
194
+ rb_method_entry_t *rb_method_entry_create(ID called_id, VALUE klass, rb_method_visibility_t visi, const rb_method_definition_t *def);
195
+
196
+ const rb_method_entry_t *rb_method_entry_at(VALUE obj, ID id);
197
+
198
+ const rb_method_entry_t *rb_method_entry(VALUE klass, ID id);
199
+ const rb_method_entry_t *rb_method_entry_without_refinements(VALUE klass, ID id, VALUE *defined_class);
200
+ const rb_method_entry_t *rb_resolve_refined_method(VALUE refinements, const rb_method_entry_t *me);
201
+ RUBY_SYMBOL_EXPORT_BEGIN
202
+ const rb_callable_method_entry_t *rb_resolve_refined_method_callable(VALUE refinements, const rb_callable_method_entry_t *me);
203
+ const rb_method_entry_t *rb_resolve_me_location(const rb_method_entry_t *, VALUE[5]);
204
+ RUBY_SYMBOL_EXPORT_END
205
+
206
+ const rb_callable_method_entry_t *rb_callable_method_entry(VALUE klass, ID id);
207
+ const rb_callable_method_entry_t *rb_callable_method_entry_with_refinements(VALUE klass, ID id, VALUE *defined_class);
208
+ const rb_callable_method_entry_t *rb_callable_method_entry_without_refinements(VALUE klass, ID id, VALUE *defined_class);
209
+
210
+ int rb_method_entry_arity(const rb_method_entry_t *me);
211
+ int rb_method_entry_eq(const rb_method_entry_t *m1, const rb_method_entry_t *m2);
212
+ st_index_t rb_hash_method_entry(st_index_t hash, const rb_method_entry_t *me);
213
+
214
+ VALUE rb_method_entry_location(const rb_method_entry_t *me);
215
+ VALUE rb_mod_method_location(VALUE mod, ID id);
216
+ VALUE rb_obj_method_location(VALUE obj, ID id);
217
+
218
+ void rb_free_method_entry(const rb_method_entry_t *me);
219
+ void rb_sweep_method_entry(void *vm);
220
+
221
+ const rb_method_entry_t *rb_method_entry_clone(const rb_method_entry_t *me);
222
+ const rb_callable_method_entry_t *rb_method_entry_complement_defined_class(const rb_method_entry_t *src_me, ID called_id, VALUE defined_class);
223
+ void rb_method_entry_copy(rb_method_entry_t *dst, const rb_method_entry_t *src);
224
+
225
+ void rb_scope_visibility_set(rb_method_visibility_t);
226
+
227
+ VALUE rb_unnamed_parameters(int arity);
228
+
229
+ #endif /* RUBY_METHOD_H */