datadog-ruby_core_source 3.4.2 → 3.5.0
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.
- checksums.yaml +4 -4
- data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/id.h +10 -5
- data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/id_table.h +15 -0
- data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/internal/array.h +2 -0
- data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/internal/basic_operators.h +1 -0
- data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/internal/bignum.h +22 -10
- data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/internal/bits.h +14 -17
- data/lib/datadog/ruby_core_source/ruby-4.0.0-p0/internal/box.h +83 -0
- data/lib/datadog/ruby_core_source/ruby-4.0.0-p0/internal/class.h +806 -0
- data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/internal/cmdlineopt.h +3 -0
- data/lib/datadog/ruby_core_source/ruby-4.0.0-p0/internal/concurrent_set.h +21 -0
- data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/internal/cont.h +0 -1
- data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/internal/encoding.h +2 -1
- data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/internal/error.h +7 -0
- data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/internal/eval.h +10 -0
- data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/internal/gc.h +32 -5
- data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/internal/hash.h +1 -0
- data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/internal/imemo.h +87 -22
- data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/internal/inits.h +4 -0
- data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/internal/io.h +25 -5
- data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/internal/load.h +2 -0
- data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/internal/numeric.h +49 -0
- data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/internal/object.h +1 -1
- data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/internal/re.h +5 -0
- data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/internal/sanitizers.h +16 -0
- data/lib/datadog/ruby_core_source/ruby-4.0.0-p0/internal/set_table.h +70 -0
- data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/internal/signal.h +1 -0
- data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/internal/st.h +1 -1
- data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/internal/string.h +4 -0
- data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/internal/struct.h +41 -0
- data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/internal/symbol.h +4 -5
- data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/internal/thread.h +15 -11
- data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/internal/time.h +2 -5
- data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/internal/variable.h +13 -9
- data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/internal/vm.h +5 -4
- data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/internal.h +0 -3
- data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/iseq.h +10 -2
- data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/method.h +21 -3
- data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/prism/ast.h +360 -70
- data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/prism/diagnostic.h +7 -0
- data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/prism/extension.h +1 -1
- data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/prism/options.h +49 -3
- data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/prism/parser.h +3 -0
- data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/prism/prism.h +40 -15
- data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/prism/regexp.h +2 -2
- data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/prism/util/pm_buffer.h +8 -0
- data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/prism/util/pm_integer.h +4 -0
- data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/prism/util/pm_list.h +6 -0
- data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/prism/util/pm_string.h +12 -2
- data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/prism/version.h +2 -2
- data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/prism_compile.h +1 -0
- data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/ractor_core.h +63 -114
- data/lib/datadog/ruby_core_source/ruby-4.0.0-p0/ruby_atomic.h +73 -0
- data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/rubyparser.h +15 -2
- data/lib/datadog/ruby_core_source/ruby-4.0.0-p0/shape.h +464 -0
- data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/thread_pthread.h +13 -3
- data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/vm_core.h +228 -57
- data/lib/datadog/ruby_core_source/version.rb +1 -1
- metadata +108 -106
- data/CHANGELOG.datadog.md +0 -19
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/internal/class.h +0 -283
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/ruby_atomic.h +0 -23
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/shape.h +0 -234
- data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/ccan/build_assert/build_assert.h +0 -0
- data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/ccan/check_type/check_type.h +0 -0
- data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/ccan/container_of/container_of.h +0 -0
- data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/ccan/list/list.h +0 -0
- data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/ccan/str/str.h +0 -0
- data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/internal/compar.h +0 -0
- data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/internal/compile.h +0 -0
- data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/internal/compilers.h +0 -0
- data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/internal/complex.h +0 -0
- data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/internal/dir.h +0 -0
- data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/internal/enc.h +0 -0
- data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/internal/enum.h +0 -0
- data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/internal/enumerator.h +0 -0
- data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/internal/file.h +0 -0
- data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/internal/fixnum.h +0 -0
- data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/internal/loadpath.h +0 -0
- data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/internal/math.h +0 -0
- data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/internal/missing.h +0 -0
- data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/internal/parse.h +0 -0
- data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/internal/proc.h +0 -0
- data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/internal/process.h +0 -0
- data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/internal/ractor.h +0 -0
- data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/internal/random.h +0 -0
- data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/internal/range.h +0 -0
- data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/internal/rational.h +0 -0
- data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/internal/ruby_parser.h +0 -0
- data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/internal/serial.h +0 -0
- data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/internal/static_assert.h +0 -0
- data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/internal/transcode.h +0 -0
- data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/internal/util.h +0 -0
- data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/internal/warnings.h +0 -0
- data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/node.h +0 -0
- data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/parser_st.h +0 -0
- data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/parser_value.h +0 -0
- data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/prism/defines.h +0 -0
- data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/prism/encoding.h +0 -0
- data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/prism/node.h +0 -0
- data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/prism/pack.h +0 -0
- data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/prism/prettyprint.h +0 -0
- data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/prism/static_literals.h +0 -0
- data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/prism/util/pm_char.h +0 -0
- data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/prism/util/pm_constant_pool.h +0 -0
- data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/prism/util/pm_memchr.h +0 -0
- data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/prism/util/pm_newline_list.h +0 -0
- data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/prism/util/pm_strncasecmp.h +0 -0
- data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/prism/util/pm_strpbrk.h +0 -0
- data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/ruby_assert.h +0 -0
- data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/thread_none.h +0 -0
- data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/vm_debug.h +4 -4
- /data/lib/datadog/ruby_core_source/{ruby-3.5.0-preview1 → ruby-4.0.0-p0}/vm_opts.h +0 -0
|
@@ -9,122 +9,39 @@
|
|
|
9
9
|
#define RACTOR_CHECK_MODE (VM_CHECK_MODE || RUBY_DEBUG) && (SIZEOF_UINT64_T == SIZEOF_VALUE)
|
|
10
10
|
#endif
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
basket_type_none,
|
|
15
|
-
|
|
16
|
-
// value is available
|
|
17
|
-
basket_type_ref,
|
|
18
|
-
basket_type_copy,
|
|
19
|
-
basket_type_move,
|
|
20
|
-
basket_type_will,
|
|
21
|
-
|
|
22
|
-
// basket should be deleted
|
|
23
|
-
basket_type_deleted,
|
|
24
|
-
|
|
25
|
-
// basket is reserved
|
|
26
|
-
basket_type_reserved,
|
|
27
|
-
|
|
28
|
-
// take_basket is available
|
|
29
|
-
basket_type_take_basket,
|
|
30
|
-
|
|
31
|
-
// basket is keeping by yielding ractor
|
|
32
|
-
basket_type_yielding,
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
// per ractor taking configuration
|
|
36
|
-
struct rb_ractor_selector_take_config {
|
|
37
|
-
bool closed;
|
|
38
|
-
bool oneshot;
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
struct rb_ractor_basket {
|
|
42
|
-
union {
|
|
43
|
-
enum rb_ractor_basket_type e;
|
|
44
|
-
rb_atomic_t atomic;
|
|
45
|
-
} type;
|
|
46
|
-
VALUE sender;
|
|
47
|
-
|
|
48
|
-
union {
|
|
49
|
-
struct {
|
|
50
|
-
VALUE v;
|
|
51
|
-
bool exception;
|
|
52
|
-
} send;
|
|
53
|
-
|
|
54
|
-
struct {
|
|
55
|
-
struct rb_ractor_basket *basket;
|
|
56
|
-
struct rb_ractor_selector_take_config *config;
|
|
57
|
-
} take;
|
|
58
|
-
} p; // payload
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
static inline bool
|
|
62
|
-
basket_type_p(struct rb_ractor_basket *b, enum rb_ractor_basket_type type)
|
|
63
|
-
{
|
|
64
|
-
return b->type.e == type;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
static inline bool
|
|
68
|
-
basket_none_p(struct rb_ractor_basket *b)
|
|
69
|
-
{
|
|
70
|
-
return basket_type_p(b, basket_type_none);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
struct rb_ractor_queue {
|
|
74
|
-
struct rb_ractor_basket *baskets;
|
|
75
|
-
int start;
|
|
76
|
-
int cnt;
|
|
77
|
-
int size;
|
|
78
|
-
unsigned int serial;
|
|
79
|
-
unsigned int reserved_cnt;
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
enum rb_ractor_wait_status {
|
|
83
|
-
wait_none = 0x00,
|
|
84
|
-
wait_receiving = 0x01,
|
|
85
|
-
wait_taking = 0x02,
|
|
86
|
-
wait_yielding = 0x04,
|
|
87
|
-
wait_moving = 0x08,
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
enum rb_ractor_wakeup_status {
|
|
91
|
-
wakeup_none,
|
|
92
|
-
wakeup_by_send,
|
|
93
|
-
wakeup_by_yield,
|
|
94
|
-
wakeup_by_take,
|
|
95
|
-
wakeup_by_close,
|
|
96
|
-
wakeup_by_interrupt,
|
|
97
|
-
wakeup_by_retry,
|
|
98
|
-
};
|
|
12
|
+
// experimental flag because it is not sure it is the common pattern
|
|
13
|
+
#define RUBY_TYPED_FROZEN_SHAREABLE_NO_REC RUBY_FL_FINALIZE
|
|
99
14
|
|
|
100
15
|
struct rb_ractor_sync {
|
|
101
16
|
// ractor lock
|
|
102
17
|
rb_nativethread_lock_t lock;
|
|
18
|
+
|
|
103
19
|
#if RACTOR_CHECK_MODE > 0
|
|
104
20
|
VALUE locked_by;
|
|
105
21
|
#endif
|
|
106
22
|
|
|
107
|
-
|
|
108
|
-
|
|
23
|
+
#ifndef RUBY_THREAD_PTHREAD_H
|
|
24
|
+
rb_nativethread_cond_t wakeup_cond;
|
|
25
|
+
#endif
|
|
109
26
|
|
|
110
|
-
//
|
|
111
|
-
struct
|
|
27
|
+
// incoming messages
|
|
28
|
+
struct ractor_queue *recv_queue;
|
|
112
29
|
|
|
113
|
-
//
|
|
114
|
-
struct
|
|
30
|
+
// waiting threads for receiving
|
|
31
|
+
struct ccan_list_head waiters;
|
|
115
32
|
|
|
116
|
-
//
|
|
117
|
-
|
|
33
|
+
// ports
|
|
34
|
+
VALUE default_port_value;
|
|
35
|
+
struct st_table *ports;
|
|
36
|
+
size_t next_port_id;
|
|
118
37
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
enum rb_ractor_wakeup_status wakeup_status;
|
|
122
|
-
rb_thread_t *waiting_thread;
|
|
123
|
-
} wait;
|
|
38
|
+
// monitors
|
|
39
|
+
struct ccan_list_head monitors;
|
|
124
40
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
41
|
+
// value
|
|
42
|
+
rb_ractor_t *successor;
|
|
43
|
+
VALUE legacy;
|
|
44
|
+
bool legacy_exc;
|
|
128
45
|
};
|
|
129
46
|
|
|
130
47
|
// created
|
|
@@ -150,12 +67,7 @@ enum ractor_status {
|
|
|
150
67
|
|
|
151
68
|
struct rb_ractor_struct {
|
|
152
69
|
struct rb_ractor_pub pub;
|
|
153
|
-
|
|
154
70
|
struct rb_ractor_sync sync;
|
|
155
|
-
VALUE receiving_mutex;
|
|
156
|
-
|
|
157
|
-
// vm wide barrier synchronization
|
|
158
|
-
rb_nativethread_cond_t barrier_wait_cond;
|
|
159
71
|
|
|
160
72
|
// thread management
|
|
161
73
|
struct {
|
|
@@ -167,6 +79,7 @@ struct rb_ractor_struct {
|
|
|
167
79
|
rb_execution_context_t *running_ec;
|
|
168
80
|
rb_thread_t *main;
|
|
169
81
|
} threads;
|
|
82
|
+
|
|
170
83
|
VALUE thgroup_default;
|
|
171
84
|
|
|
172
85
|
VALUE name;
|
|
@@ -178,6 +91,8 @@ struct rb_ractor_struct {
|
|
|
178
91
|
|
|
179
92
|
// ractor local data
|
|
180
93
|
|
|
94
|
+
rb_serial_t next_ec_serial;
|
|
95
|
+
|
|
181
96
|
st_table *local_storage;
|
|
182
97
|
struct rb_id_table *idkey_local_storage;
|
|
183
98
|
VALUE local_storage_store_lock;
|
|
@@ -188,6 +103,7 @@ struct rb_ractor_struct {
|
|
|
188
103
|
VALUE verbose;
|
|
189
104
|
VALUE debug;
|
|
190
105
|
|
|
106
|
+
bool malloc_gc_disabled;
|
|
191
107
|
void *newobj_cache;
|
|
192
108
|
}; // rb_ractor_t is defined in vm_core.h
|
|
193
109
|
|
|
@@ -223,10 +139,12 @@ void rb_ractor_terminate_interrupt_main_thread(rb_ractor_t *r);
|
|
|
223
139
|
void rb_ractor_terminate_all(void);
|
|
224
140
|
bool rb_ractor_main_p_(void);
|
|
225
141
|
void rb_ractor_atfork(rb_vm_t *vm, rb_thread_t *th);
|
|
226
|
-
|
|
142
|
+
void rb_ractor_terminate_atfork(rb_vm_t *vm, rb_ractor_t *th);
|
|
143
|
+
VALUE rb_ractor_require(VALUE feature, bool silent);
|
|
227
144
|
VALUE rb_ractor_autoload_load(VALUE space, ID id);
|
|
228
145
|
|
|
229
146
|
VALUE rb_ractor_ensure_shareable(VALUE obj, VALUE name);
|
|
147
|
+
st_table *rb_ractor_targeted_hooks(rb_ractor_t *cr);
|
|
230
148
|
|
|
231
149
|
RUBY_SYMBOL_EXPORT_BEGIN
|
|
232
150
|
void rb_ractor_finish_marking(void);
|
|
@@ -281,12 +199,16 @@ rb_ractor_sleeper_thread_num(rb_ractor_t *r)
|
|
|
281
199
|
}
|
|
282
200
|
|
|
283
201
|
static inline void
|
|
284
|
-
rb_ractor_thread_switch(rb_ractor_t *cr, rb_thread_t *th)
|
|
202
|
+
rb_ractor_thread_switch(rb_ractor_t *cr, rb_thread_t *th, bool always_reset)
|
|
285
203
|
{
|
|
286
204
|
RUBY_DEBUG_LOG("th:%d->%u%s",
|
|
287
205
|
cr->threads.running_ec ? (int)rb_th_serial(cr->threads.running_ec->thread_ptr) : -1,
|
|
288
206
|
rb_th_serial(th), cr->threads.running_ec == th->ec ? " (same)" : "");
|
|
289
207
|
|
|
208
|
+
if (cr->threads.running_ec != th->ec || always_reset) {
|
|
209
|
+
th->running_time_us = 0;
|
|
210
|
+
}
|
|
211
|
+
|
|
290
212
|
if (cr->threads.running_ec != th->ec) {
|
|
291
213
|
if (0) {
|
|
292
214
|
ruby_debug_printf("rb_ractor_thread_switch ec:%p->%p\n",
|
|
@@ -297,10 +219,6 @@ rb_ractor_thread_switch(rb_ractor_t *cr, rb_thread_t *th)
|
|
|
297
219
|
return;
|
|
298
220
|
}
|
|
299
221
|
|
|
300
|
-
if (cr->threads.running_ec != th->ec) {
|
|
301
|
-
th->running_time_us = 0;
|
|
302
|
-
}
|
|
303
|
-
|
|
304
222
|
cr->threads.running_ec = th->ec;
|
|
305
223
|
|
|
306
224
|
VM_ASSERT(cr == GET_RACTOR());
|
|
@@ -333,6 +251,25 @@ rb_ractor_id(const rb_ractor_t *r)
|
|
|
333
251
|
return r->pub.id;
|
|
334
252
|
}
|
|
335
253
|
|
|
254
|
+
static inline void
|
|
255
|
+
rb_ractor_targeted_hooks_incr(rb_ractor_t *cr)
|
|
256
|
+
{
|
|
257
|
+
cr->pub.targeted_hooks_cnt++;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
static inline void
|
|
261
|
+
rb_ractor_targeted_hooks_decr(rb_ractor_t *cr)
|
|
262
|
+
{
|
|
263
|
+
RUBY_ASSERT(cr->pub.targeted_hooks_cnt > 0);
|
|
264
|
+
cr->pub.targeted_hooks_cnt--;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
static inline unsigned int
|
|
268
|
+
rb_ractor_targeted_hooks_cnt(rb_ractor_t *cr)
|
|
269
|
+
{
|
|
270
|
+
return cr->pub.targeted_hooks_cnt;
|
|
271
|
+
}
|
|
272
|
+
|
|
336
273
|
#if RACTOR_CHECK_MODE > 0
|
|
337
274
|
# define RACTOR_BELONGING_ID(obj) (*(uint32_t *)(((uintptr_t)(obj)) + rb_gc_obj_slot_size(obj)))
|
|
338
275
|
|
|
@@ -355,9 +292,13 @@ rb_ractor_belonging(VALUE obj)
|
|
|
355
292
|
}
|
|
356
293
|
}
|
|
357
294
|
|
|
295
|
+
extern bool rb_ractor_ignore_belonging_flag;
|
|
296
|
+
|
|
358
297
|
static inline VALUE
|
|
359
298
|
rb_ractor_confirm_belonging(VALUE obj)
|
|
360
299
|
{
|
|
300
|
+
if (rb_ractor_ignore_belonging_flag) return obj;
|
|
301
|
+
|
|
361
302
|
uint32_t id = rb_ractor_belonging(obj);
|
|
362
303
|
|
|
363
304
|
if (id == 0) {
|
|
@@ -377,6 +318,14 @@ rb_ractor_confirm_belonging(VALUE obj)
|
|
|
377
318
|
}
|
|
378
319
|
return obj;
|
|
379
320
|
}
|
|
321
|
+
|
|
322
|
+
static inline void
|
|
323
|
+
rb_ractor_ignore_belonging(bool flag)
|
|
324
|
+
{
|
|
325
|
+
rb_ractor_ignore_belonging_flag = flag;
|
|
326
|
+
}
|
|
327
|
+
|
|
380
328
|
#else
|
|
381
329
|
#define rb_ractor_confirm_belonging(obj) obj
|
|
330
|
+
#define rb_ractor_ignore_belonging(flag) (0)
|
|
382
331
|
#endif
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
#ifndef INTERNAL_ATOMIC_H
|
|
2
|
+
#define INTERNAL_ATOMIC_H
|
|
3
|
+
|
|
4
|
+
#include "ruby/atomic.h"
|
|
5
|
+
#ifdef HAVE_STDATOMIC_H
|
|
6
|
+
# include <stdatomic.h>
|
|
7
|
+
#endif
|
|
8
|
+
|
|
9
|
+
#define RUBY_ATOMIC_VALUE_LOAD(x) rbimpl_atomic_value_load(&(x), RBIMPL_ATOMIC_SEQ_CST)
|
|
10
|
+
|
|
11
|
+
/* shim macros only */
|
|
12
|
+
#define ATOMIC_ADD(var, val) RUBY_ATOMIC_ADD(var, val)
|
|
13
|
+
#define ATOMIC_CAS(var, oldval, newval) RUBY_ATOMIC_CAS(var, oldval, newval)
|
|
14
|
+
#define ATOMIC_DEC(var) RUBY_ATOMIC_DEC(var)
|
|
15
|
+
#define ATOMIC_EXCHANGE(var, val) RUBY_ATOMIC_EXCHANGE(var, val)
|
|
16
|
+
#define ATOMIC_FETCH_ADD(var, val) RUBY_ATOMIC_FETCH_ADD(var, val)
|
|
17
|
+
#define ATOMIC_FETCH_SUB(var, val) RUBY_ATOMIC_FETCH_SUB(var, val)
|
|
18
|
+
#define ATOMIC_INC(var) RUBY_ATOMIC_INC(var)
|
|
19
|
+
#define ATOMIC_OR(var, val) RUBY_ATOMIC_OR(var, val)
|
|
20
|
+
#define ATOMIC_PTR_CAS(var, oldval, newval) RUBY_ATOMIC_PTR_CAS(var, oldval, newval)
|
|
21
|
+
#define ATOMIC_PTR_EXCHANGE(var, val) RUBY_ATOMIC_PTR_EXCHANGE(var, val)
|
|
22
|
+
#define ATOMIC_SET(var, val) RUBY_ATOMIC_SET(var, val)
|
|
23
|
+
#define ATOMIC_SIZE_ADD(var, val) RUBY_ATOMIC_SIZE_ADD(var, val)
|
|
24
|
+
#define ATOMIC_SIZE_CAS(var, oldval, newval) RUBY_ATOMIC_SIZE_CAS(var, oldval, newval)
|
|
25
|
+
#define ATOMIC_SIZE_DEC(var) RUBY_ATOMIC_SIZE_DEC(var)
|
|
26
|
+
#define ATOMIC_SIZE_EXCHANGE(var, val) RUBY_ATOMIC_SIZE_EXCHANGE(var, val)
|
|
27
|
+
#define ATOMIC_SIZE_INC(var) RUBY_ATOMIC_SIZE_INC(var)
|
|
28
|
+
#define ATOMIC_SIZE_SUB(var, val) RUBY_ATOMIC_SIZE_SUB(var, val)
|
|
29
|
+
#define ATOMIC_SUB(var, val) RUBY_ATOMIC_SUB(var, val)
|
|
30
|
+
#define ATOMIC_VALUE_CAS(var, oldval, val) RUBY_ATOMIC_VALUE_CAS(var, oldval, val)
|
|
31
|
+
#define ATOMIC_VALUE_EXCHANGE(var, val) RUBY_ATOMIC_VALUE_EXCHANGE(var, val)
|
|
32
|
+
|
|
33
|
+
#define ATOMIC_LOAD_RELAXED(var) rbimpl_atomic_load(&(var), RBIMPL_ATOMIC_RELAXED)
|
|
34
|
+
|
|
35
|
+
typedef RBIMPL_ALIGNAS(8) uint64_t rbimpl_atomic_uint64_t;
|
|
36
|
+
|
|
37
|
+
static inline uint64_t
|
|
38
|
+
rbimpl_atomic_u64_load_relaxed(const volatile rbimpl_atomic_uint64_t *value)
|
|
39
|
+
{
|
|
40
|
+
#if defined(HAVE_GCC_ATOMIC_BUILTINS_64)
|
|
41
|
+
return __atomic_load_n(value, __ATOMIC_RELAXED);
|
|
42
|
+
#elif defined(_WIN32)
|
|
43
|
+
uint64_t val = *value;
|
|
44
|
+
return InterlockedCompareExchange64(RBIMPL_CAST((uint64_t *)value), val, val);
|
|
45
|
+
#elif defined(__sun) && defined(HAVE_ATOMIC_H) && (defined(_LP64) || defined(_I32LPx))
|
|
46
|
+
uint64_t val = *value;
|
|
47
|
+
return atomic_cas_64(value, val, val);
|
|
48
|
+
#else
|
|
49
|
+
// TODO: stdatomic
|
|
50
|
+
|
|
51
|
+
return *value;
|
|
52
|
+
#endif
|
|
53
|
+
}
|
|
54
|
+
#define ATOMIC_U64_LOAD_RELAXED(var) rbimpl_atomic_u64_load_relaxed(&(var))
|
|
55
|
+
|
|
56
|
+
static inline void
|
|
57
|
+
rbimpl_atomic_u64_set_relaxed(volatile rbimpl_atomic_uint64_t *address, uint64_t value)
|
|
58
|
+
{
|
|
59
|
+
#if defined(HAVE_GCC_ATOMIC_BUILTINS_64)
|
|
60
|
+
__atomic_store_n(address, value, __ATOMIC_RELAXED);
|
|
61
|
+
#elif defined(_WIN32)
|
|
62
|
+
InterlockedExchange64(address, value);
|
|
63
|
+
#elif defined(__sun) && defined(HAVE_ATOMIC_H) && (defined(_LP64) || defined(_I32LPx))
|
|
64
|
+
atomic_swap_64(address, value);
|
|
65
|
+
#else
|
|
66
|
+
// TODO: stdatomic
|
|
67
|
+
|
|
68
|
+
*address = value;
|
|
69
|
+
#endif
|
|
70
|
+
}
|
|
71
|
+
#define ATOMIC_U64_SET_RELAXED(var, val) rbimpl_atomic_u64_set_relaxed(&(var), val)
|
|
72
|
+
|
|
73
|
+
#endif
|
|
@@ -248,6 +248,7 @@ typedef struct RNode_SCOPE {
|
|
|
248
248
|
|
|
249
249
|
rb_ast_id_table_t *nd_tbl;
|
|
250
250
|
struct RNode *nd_body;
|
|
251
|
+
struct RNode *nd_parent;
|
|
251
252
|
struct RNode_ARGS *nd_args;
|
|
252
253
|
} rb_node_scope_t;
|
|
253
254
|
|
|
@@ -324,6 +325,9 @@ typedef struct RNode_IN {
|
|
|
324
325
|
struct RNode *nd_head;
|
|
325
326
|
struct RNode *nd_body;
|
|
326
327
|
struct RNode *nd_next;
|
|
328
|
+
rb_code_location_t in_keyword_loc;
|
|
329
|
+
rb_code_location_t then_keyword_loc;
|
|
330
|
+
rb_code_location_t operator_loc;
|
|
327
331
|
} rb_node_in_t;
|
|
328
332
|
|
|
329
333
|
typedef struct RNode_LOOP {
|
|
@@ -778,7 +782,6 @@ struct rb_args_info {
|
|
|
778
782
|
|
|
779
783
|
struct RNode_OPT_ARG *opt_args;
|
|
780
784
|
unsigned int no_kwarg: 1;
|
|
781
|
-
unsigned int ruby2_keywords: 1;
|
|
782
785
|
unsigned int forwarding: 1;
|
|
783
786
|
};
|
|
784
787
|
|
|
@@ -901,6 +904,8 @@ typedef struct RNode_MODULE {
|
|
|
901
904
|
|
|
902
905
|
struct RNode *nd_cpath;
|
|
903
906
|
struct RNode *nd_body;
|
|
907
|
+
rb_code_location_t module_keyword_loc;
|
|
908
|
+
rb_code_location_t end_keyword_loc;
|
|
904
909
|
} rb_node_module_t;
|
|
905
910
|
|
|
906
911
|
typedef struct RNode_SCLASS {
|
|
@@ -908,6 +913,9 @@ typedef struct RNode_SCLASS {
|
|
|
908
913
|
|
|
909
914
|
struct RNode *nd_recv;
|
|
910
915
|
struct RNode *nd_body;
|
|
916
|
+
rb_code_location_t class_keyword_loc;
|
|
917
|
+
rb_code_location_t operator_loc;
|
|
918
|
+
rb_code_location_t end_keyword_loc;
|
|
911
919
|
} rb_node_sclass_t;
|
|
912
920
|
|
|
913
921
|
typedef struct RNode_COLON2 {
|
|
@@ -915,12 +923,16 @@ typedef struct RNode_COLON2 {
|
|
|
915
923
|
|
|
916
924
|
struct RNode *nd_head;
|
|
917
925
|
ID nd_mid;
|
|
926
|
+
rb_code_location_t delimiter_loc;
|
|
927
|
+
rb_code_location_t name_loc;
|
|
918
928
|
} rb_node_colon2_t;
|
|
919
929
|
|
|
920
930
|
typedef struct RNode_COLON3 {
|
|
921
931
|
NODE node;
|
|
922
932
|
|
|
923
933
|
ID nd_mid;
|
|
934
|
+
rb_code_location_t delimiter_loc;
|
|
935
|
+
rb_code_location_t name_loc;
|
|
924
936
|
} rb_node_colon3_t;
|
|
925
937
|
|
|
926
938
|
/* NODE_DOT2, NODE_DOT3, NODE_FLIP2, NODE_FLIP3 */
|
|
@@ -958,6 +970,7 @@ typedef struct RNode_DEFINED {
|
|
|
958
970
|
NODE node;
|
|
959
971
|
|
|
960
972
|
struct RNode *nd_head;
|
|
973
|
+
rb_code_location_t keyword_loc;
|
|
961
974
|
} rb_node_defined_t;
|
|
962
975
|
|
|
963
976
|
typedef struct RNode_POSTEXE {
|
|
@@ -1153,7 +1166,7 @@ typedef struct RNode_ERROR {
|
|
|
1153
1166
|
#define RNODE_FILE(node) ((rb_node_file_t *)(node))
|
|
1154
1167
|
#define RNODE_ENCODING(node) ((rb_node_encoding_t *)(node))
|
|
1155
1168
|
|
|
1156
|
-
/* FL : 0..4: T_TYPES, 5: KEEP_WB, 6: PROMOTED, 7: FINALIZE, 8: UNUSED,
|
|
1169
|
+
/* FL : 0..4: T_TYPES, 5: KEEP_WB, 6: PROMOTED, 7: FINALIZE, 8..10: UNUSED, 11: FREEZE */
|
|
1157
1170
|
/* NODE_FL: 0..4: UNUSED, 5: UNUSED, 6: UNUSED, 7: NODE_FL_NEWLINE,
|
|
1158
1171
|
* 8..14: nd_type,
|
|
1159
1172
|
* 15..: nd_line
|