debase-ruby_core_source 3.2.0 → 3.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/CHANGELOG.md +10 -0
- data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/addr2line.h +20 -0
- data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/builtin.h +117 -0
- data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/ccan/build_assert/build_assert.h +40 -0
- data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/ccan/check_type/check_type.h +63 -0
- data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/ccan/container_of/container_of.h +142 -0
- data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/ccan/list/list.h +789 -0
- data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/ccan/str/str.h +17 -0
- data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/constant.h +53 -0
- data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/darray.h +246 -0
- data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/debug_counter.h +423 -0
- data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/dln.h +31 -0
- data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/encindex.h +70 -0
- data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/eval_intern.h +341 -0
- data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/hrtime.h +227 -0
- data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/id.h +343 -0
- data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/id_table.h +39 -0
- data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/insns.inc +249 -0
- data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/insns_info.inc +9133 -0
- data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/internal/array.h +144 -0
- data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/internal/basic_operators.h +63 -0
- data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/internal/bignum.h +244 -0
- data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/internal/bits.h +568 -0
- data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/internal/class.h +226 -0
- data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/internal/cmdlineopt.h +63 -0
- data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/internal/compar.h +29 -0
- data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/internal/compile.h +34 -0
- data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/internal/compilers.h +107 -0
- data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/internal/complex.h +29 -0
- data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/internal/cont.h +32 -0
- data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/internal/dir.h +16 -0
- data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/internal/enc.h +19 -0
- data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/internal/encoding.h +32 -0
- data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/internal/enum.h +18 -0
- data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/internal/enumerator.h +21 -0
- data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/internal/error.h +213 -0
- data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/internal/eval.h +32 -0
- data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/internal/file.h +38 -0
- data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/internal/fixnum.h +184 -0
- data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/internal/gc.h +361 -0
- data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/internal/hash.h +190 -0
- data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/internal/imemo.h +241 -0
- data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/internal/inits.h +50 -0
- data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/internal/io.h +137 -0
- data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/internal/load.h +18 -0
- data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/internal/loadpath.h +16 -0
- data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/internal/math.h +23 -0
- data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/internal/missing.h +18 -0
- data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/internal/numeric.h +273 -0
- data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/internal/object.h +59 -0
- data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/internal/parse.h +133 -0
- data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/internal/proc.h +30 -0
- data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/internal/process.h +124 -0
- data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/internal/ractor.h +6 -0
- data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/internal/random.h +16 -0
- data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/internal/range.h +40 -0
- data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/internal/rational.h +71 -0
- data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/internal/re.h +28 -0
- data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/internal/ruby_parser.h +69 -0
- data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/internal/sanitizers.h +186 -0
- data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/internal/serial.h +23 -0
- data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/internal/signal.h +25 -0
- data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/internal/static_assert.h +16 -0
- data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/internal/string.h +160 -0
- data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/internal/struct.h +127 -0
- data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/internal/symbol.h +42 -0
- data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/internal/thread.h +74 -0
- data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/internal/time.h +34 -0
- data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/internal/transcode.h +20 -0
- data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/internal/util.h +27 -0
- data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/internal/variable.h +71 -0
- data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/internal/vm.h +129 -0
- data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/internal/warnings.h +16 -0
- data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/internal.h +112 -0
- data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/iseq.h +334 -0
- data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/known_errors.inc +791 -0
- data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/method.h +254 -0
- data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/node.h +125 -0
- data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/node_name.inc +210 -0
- data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/optinsn.inc +128 -0
- data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/optunifs.inc +43 -0
- data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/parse.h +232 -0
- data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/parser_bits.h +564 -0
- data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/parser_node.h +133 -0
- data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/parser_st.h +162 -0
- data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/parser_value.h +106 -0
- data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/probes_helper.h +42 -0
- data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/ractor_core.h +387 -0
- data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/regenc.h +254 -0
- data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/regint.h +996 -0
- data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/regparse.h +370 -0
- data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/revision.h +5 -0
- data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/rjit.h +103 -0
- data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/rjit_c.h +165 -0
- data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/ruby_assert.h +14 -0
- data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/ruby_atomic.h +23 -0
- data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/rubyparser.h +628 -0
- data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/shape.h +232 -0
- data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/siphash.h +48 -0
- data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/symbol.h +119 -0
- data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/thread_none.h +20 -0
- data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/thread_pthread.h +126 -0
- data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/thread_win32.h +58 -0
- data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/timev.h +58 -0
- data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/transcode_data.h +138 -0
- data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/variable.h +30 -0
- data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/version.h +65 -0
- data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/vm.inc +5396 -0
- data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/vm_call_iseq_optimized.inc +244 -0
- data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/vm_callinfo.h +608 -0
- data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/vm_core.h +2089 -0
- data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/vm_debug.h +122 -0
- data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/vm_exec.h +199 -0
- data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/vm_insnhelper.h +271 -0
- data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/vm_opts.h +67 -0
- data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/vm_sync.h +137 -0
- data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/vmtc.inc +243 -0
- data/lib/debase/ruby_core_source/ruby-3.3.0-preview2/yjit.h +70 -0
- data/lib/debase/ruby_core_source/version.rb +1 -1
- metadata +120 -3
@@ -0,0 +1,162 @@
|
|
1
|
+
/* This is a public domain general purpose hash table package
|
2
|
+
originally written by Peter Moore @ UCB.
|
3
|
+
|
4
|
+
The hash table data structures were redesigned and the package was
|
5
|
+
rewritten by Vladimir Makarov <vmakarov@redhat.com>. */
|
6
|
+
|
7
|
+
#ifndef RUBY_ST2_H
|
8
|
+
#define RUBY_ST2_H 1
|
9
|
+
|
10
|
+
#if defined(__cplusplus)
|
11
|
+
extern "C" {
|
12
|
+
#if 0
|
13
|
+
} /* satisfy cc-mode */
|
14
|
+
#endif
|
15
|
+
#endif
|
16
|
+
|
17
|
+
#include <stddef.h>
|
18
|
+
#include <stdint.h>
|
19
|
+
#include "ruby/config.h"
|
20
|
+
#include "ruby/backward/2/long_long.h"
|
21
|
+
#include "ruby/defines.h"
|
22
|
+
|
23
|
+
RUBY_SYMBOL_EXPORT_BEGIN
|
24
|
+
|
25
|
+
#if SIZEOF_LONG == SIZEOF_VOIDP
|
26
|
+
typedef unsigned long parser_st_data_t;
|
27
|
+
#elif SIZEOF_LONG_LONG == SIZEOF_VOIDP
|
28
|
+
typedef unsigned LONG_LONG parser_st_data_t;
|
29
|
+
#else
|
30
|
+
# error ---->> parser_st.c requires sizeof(void*) == sizeof(long) or sizeof(LONG_LONG) to be compiled. <<----
|
31
|
+
#endif
|
32
|
+
#define ST2_DATA_T_DEFINED
|
33
|
+
|
34
|
+
#ifndef CHAR_BIT
|
35
|
+
# ifdef HAVE_LIMITS_H
|
36
|
+
# include <limits.h>
|
37
|
+
# else
|
38
|
+
# define CHAR_BIT 8
|
39
|
+
# endif
|
40
|
+
#endif
|
41
|
+
#ifndef _
|
42
|
+
# define _(args) args
|
43
|
+
#endif
|
44
|
+
#ifndef ANYARGS
|
45
|
+
# ifdef __cplusplus
|
46
|
+
# define ANYARGS ...
|
47
|
+
# else
|
48
|
+
# define ANYARGS
|
49
|
+
# endif
|
50
|
+
#endif
|
51
|
+
|
52
|
+
typedef struct parser_st_table parser_st_table;
|
53
|
+
|
54
|
+
typedef parser_st_data_t parser_st_index_t;
|
55
|
+
|
56
|
+
/* Maximal value of unsigned integer type parser_st_index_t. */
|
57
|
+
#define MAX_ST2_INDEX_VAL (~(parser_st_index_t) 0)
|
58
|
+
|
59
|
+
typedef int parser_st_compare_func(parser_st_data_t, parser_st_data_t);
|
60
|
+
typedef parser_st_index_t parser_st_hash_func(parser_st_data_t);
|
61
|
+
|
62
|
+
typedef char st_check_for_sizeof_parser_st_index_t[SIZEOF_VOIDP == (int)sizeof(parser_st_index_t) ? 1 : -1];
|
63
|
+
#define SIZEOF_ST_INDEX_T SIZEOF_VOIDP
|
64
|
+
|
65
|
+
struct parser_st_hash_type {
|
66
|
+
int (*compare)(parser_st_data_t, parser_st_data_t); /* parser_st_compare_func* */
|
67
|
+
parser_st_index_t (*hash)(parser_st_data_t); /* parser_st_hash_func* */
|
68
|
+
};
|
69
|
+
|
70
|
+
#define ST_INDEX_BITS (SIZEOF_ST_INDEX_T * CHAR_BIT)
|
71
|
+
|
72
|
+
#if defined(HAVE_BUILTIN___BUILTIN_CHOOSE_EXPR) && defined(HAVE_BUILTIN___BUILTIN_TYPES_COMPATIBLE_P)
|
73
|
+
# define ST2_DATA_COMPATIBLE_P(type) \
|
74
|
+
__builtin_choose_expr(__builtin_types_compatible_p(type, parser_st_data_t), 1, 0)
|
75
|
+
#else
|
76
|
+
# define ST2_DATA_COMPATIBLE_P(type) 0
|
77
|
+
#endif
|
78
|
+
|
79
|
+
typedef struct parser_st_table_entry parser_st_table_entry;
|
80
|
+
|
81
|
+
struct parser_st_table_entry; /* defined in parser_st.c */
|
82
|
+
|
83
|
+
struct parser_st_table {
|
84
|
+
/* Cached features of the table -- see st.c for more details. */
|
85
|
+
unsigned char entry_power, bin_power, size_ind;
|
86
|
+
/* How many times the table was rebuilt. */
|
87
|
+
unsigned int rebuilds_num;
|
88
|
+
const struct parser_st_hash_type *type;
|
89
|
+
/* Number of entries currently in the table. */
|
90
|
+
parser_st_index_t num_entries;
|
91
|
+
/* Array of bins used for access by keys. */
|
92
|
+
parser_st_index_t *bins;
|
93
|
+
/* Start and bound index of entries in array entries.
|
94
|
+
entries_starts and entries_bound are in interval
|
95
|
+
[0,allocated_entries]. */
|
96
|
+
parser_st_index_t entries_start, entries_bound;
|
97
|
+
/* Array of size 2^entry_power. */
|
98
|
+
parser_st_table_entry *entries;
|
99
|
+
};
|
100
|
+
|
101
|
+
#define parser_st_is_member(table,key) rb_parser_st_lookup((table),(key),(parser_st_data_t *)0)
|
102
|
+
|
103
|
+
enum parser_st_retval {ST2_CONTINUE, ST2_STOP, ST2_DELETE, ST2_CHECK, ST2_REPLACE};
|
104
|
+
|
105
|
+
size_t rb_parser_st_table_size(const struct parser_st_table *tbl);
|
106
|
+
parser_st_table *rb_parser_st_init_table(const struct parser_st_hash_type *);
|
107
|
+
parser_st_table *rb_parser_st_init_table_with_size(const struct parser_st_hash_type *, parser_st_index_t);
|
108
|
+
parser_st_table *rb_parser_st_init_existing_table_with_size(parser_st_table *, const struct parser_st_hash_type *, parser_st_index_t);
|
109
|
+
parser_st_table *rb_parser_st_init_numtable(void);
|
110
|
+
parser_st_table *rb_parser_st_init_numtable_with_size(parser_st_index_t);
|
111
|
+
parser_st_table *rb_parser_st_init_strtable(void);
|
112
|
+
parser_st_table *rb_parser_st_init_strtable_with_size(parser_st_index_t);
|
113
|
+
parser_st_table *rb_parser_st_init_strcasetable(void);
|
114
|
+
parser_st_table *rb_parser_st_init_strcasetable_with_size(parser_st_index_t);
|
115
|
+
int rb_parser_st_delete(parser_st_table *, parser_st_data_t *, parser_st_data_t *); /* returns 0:notfound 1:deleted */
|
116
|
+
int rb_parser_st_delete_safe(parser_st_table *, parser_st_data_t *, parser_st_data_t *, parser_st_data_t);
|
117
|
+
int rb_parser_st_shift(parser_st_table *, parser_st_data_t *, parser_st_data_t *); /* returns 0:notfound 1:deleted */
|
118
|
+
int rb_parser_st_insert(parser_st_table *, parser_st_data_t, parser_st_data_t);
|
119
|
+
int rb_parser_st_insert2(parser_st_table *, parser_st_data_t, parser_st_data_t, parser_st_data_t (*)(parser_st_data_t));
|
120
|
+
int rb_parser_st_lookup(parser_st_table *, parser_st_data_t, parser_st_data_t *);
|
121
|
+
int rb_parser_st_get_key(parser_st_table *, parser_st_data_t, parser_st_data_t *);
|
122
|
+
typedef int parser_st_update_callback_func(parser_st_data_t *key, parser_st_data_t *value, parser_st_data_t arg, int existing);
|
123
|
+
/* *key may be altered, but must equal to the old key, i.e., the
|
124
|
+
* results of hash() are same and compare() returns 0, otherwise the
|
125
|
+
* behavior is undefined */
|
126
|
+
int rb_parser_st_update(parser_st_table *table, parser_st_data_t key, parser_st_update_callback_func *func, parser_st_data_t arg);
|
127
|
+
typedef int parser_st_foreach_callback_func(parser_st_data_t, parser_st_data_t, parser_st_data_t);
|
128
|
+
typedef int parser_st_foreach_check_callback_func(parser_st_data_t, parser_st_data_t, parser_st_data_t, int);
|
129
|
+
int rb_parser_st_foreach_with_replace(parser_st_table *tab, parser_st_foreach_check_callback_func *func, parser_st_update_callback_func *replace, parser_st_data_t arg);
|
130
|
+
int rb_parser_st_foreach(parser_st_table *, parser_st_foreach_callback_func *, parser_st_data_t);
|
131
|
+
int rb_parser_st_foreach_check(parser_st_table *, parser_st_foreach_check_callback_func *, parser_st_data_t, parser_st_data_t);
|
132
|
+
parser_st_index_t rb_parser_st_keys(parser_st_table *table, parser_st_data_t *keys, parser_st_index_t size);
|
133
|
+
parser_st_index_t rb_parser_st_keys_check(parser_st_table *table, parser_st_data_t *keys, parser_st_index_t size, parser_st_data_t never);
|
134
|
+
parser_st_index_t rb_parser_st_values(parser_st_table *table, parser_st_data_t *values, parser_st_index_t size);
|
135
|
+
parser_st_index_t rb_parser_st_values_check(parser_st_table *table, parser_st_data_t *values, parser_st_index_t size, parser_st_data_t never);
|
136
|
+
void rb_parser_st_add_direct(parser_st_table *, parser_st_data_t, parser_st_data_t);
|
137
|
+
void rb_parser_st_free_table(parser_st_table *);
|
138
|
+
void rb_parser_st_cleanup_safe(parser_st_table *, parser_st_data_t);
|
139
|
+
void rb_parser_st_clear(parser_st_table *);
|
140
|
+
parser_st_table *rb_parser_st_replace(parser_st_table *, parser_st_table *);
|
141
|
+
parser_st_table *rb_parser_st_copy(parser_st_table *);
|
142
|
+
CONSTFUNC(int rb_parser_st_numcmp(parser_st_data_t, parser_st_data_t));
|
143
|
+
CONSTFUNC(parser_st_index_t rb_parser_st_numhash(parser_st_data_t));
|
144
|
+
PUREFUNC(int rb_parser_st_locale_insensitive_strcasecmp(const char *s1, const char *s2));
|
145
|
+
PUREFUNC(int rb_parser_st_locale_insensitive_strncasecmp(const char *s1, const char *s2, size_t n));
|
146
|
+
PUREFUNC(size_t rb_parser_st_memsize(const parser_st_table *));
|
147
|
+
PUREFUNC(parser_st_index_t rb_parser_st_hash(const void *ptr, size_t len, parser_st_index_t h));
|
148
|
+
CONSTFUNC(parser_st_index_t rb_parser_st_hash_uint32(parser_st_index_t h, uint32_t i));
|
149
|
+
CONSTFUNC(parser_st_index_t rb_parser_st_hash_uint(parser_st_index_t h, parser_st_index_t i));
|
150
|
+
CONSTFUNC(parser_st_index_t rb_parser_st_hash_end(parser_st_index_t h));
|
151
|
+
CONSTFUNC(parser_st_index_t rb_parser_st_hash_start(parser_st_index_t h));
|
152
|
+
|
153
|
+
RUBY_SYMBOL_EXPORT_END
|
154
|
+
|
155
|
+
#if defined(__cplusplus)
|
156
|
+
#if 0
|
157
|
+
{ /* satisfy cc-mode */
|
158
|
+
#endif
|
159
|
+
} /* extern "C" { */
|
160
|
+
#endif
|
161
|
+
|
162
|
+
#endif /* RUBY_ST2_H */
|
@@ -0,0 +1,106 @@
|
|
1
|
+
#ifndef EXTERNAL_VALUE_H
|
2
|
+
#define EXTERNAL_VALUE_H
|
3
|
+
|
4
|
+
#include "ruby/config.h"
|
5
|
+
|
6
|
+
#if defined(__DOXYGEN__)
|
7
|
+
|
8
|
+
/**
|
9
|
+
* Type that represents a Ruby object. It is an unsigned integer of some kind,
|
10
|
+
* depending on platforms.
|
11
|
+
*
|
12
|
+
* ```CXX
|
13
|
+
* VALUE value = rb_eval_string("ARGF.readlines.map.with_index");
|
14
|
+
* ```
|
15
|
+
*
|
16
|
+
* @warning ::VALUE is not a pointer.
|
17
|
+
* @warning ::VALUE can be wider than `long`.
|
18
|
+
*/
|
19
|
+
typedef uintptr_t VALUE;
|
20
|
+
|
21
|
+
/**
|
22
|
+
* Type that represents a Ruby identifier such as a variable name.
|
23
|
+
*
|
24
|
+
* ```CXX
|
25
|
+
* ID method = rb_intern("method");
|
26
|
+
* VALUE result = rb_funcall(obj, method, 0);
|
27
|
+
* ```
|
28
|
+
*
|
29
|
+
* @note ::rb_cSymbol is a Ruby-level data type for the same thing.
|
30
|
+
*/
|
31
|
+
typedef uintptr_t ID;
|
32
|
+
|
33
|
+
/**
|
34
|
+
* A signed integer type that has the same width with ::VALUE.
|
35
|
+
*
|
36
|
+
* @internal
|
37
|
+
*
|
38
|
+
* @shyouhei wonders: is it guaranteed that `uintptr_t` and `intptr_t` are the
|
39
|
+
* same width? As far as I read ISO/IEC 9899:2018 section 7.20.1.4 paragraph 1
|
40
|
+
* no such description is given... or defined elsewhere?
|
41
|
+
*/
|
42
|
+
typedef intptr_t SIGNED_VALUE;
|
43
|
+
|
44
|
+
/**
|
45
|
+
* Identical to `sizeof(VALUE)`, except it is a macro that can also be used
|
46
|
+
* inside of preprocessor directives such as `#if`. Handy on occasions.
|
47
|
+
*/
|
48
|
+
#define SIZEOF_VALUE SIZEOF_UINTPTR_T
|
49
|
+
|
50
|
+
/**
|
51
|
+
* @private
|
52
|
+
*
|
53
|
+
* A compile-time constant of type ::VALUE whose value is 0.
|
54
|
+
*/
|
55
|
+
#define RBIMPL_VALUE_NULL UINTPTR_C(0)
|
56
|
+
|
57
|
+
/**
|
58
|
+
* @private
|
59
|
+
*
|
60
|
+
* A compile-time constant of type ::VALUE whose value is 1.
|
61
|
+
*/
|
62
|
+
#define RBIMPL_VALUE_ONE UINTPTR_C(1)
|
63
|
+
|
64
|
+
/**
|
65
|
+
* @private
|
66
|
+
*
|
67
|
+
* Maximum possible value that a ::VALUE can take.
|
68
|
+
*/
|
69
|
+
#define RBIMPL_VALUE_FULL UINTPTR_MAX
|
70
|
+
|
71
|
+
#elif defined HAVE_UINTPTR_T && 0
|
72
|
+
typedef uintptr_t VALUE;
|
73
|
+
typedef uintptr_t ID;
|
74
|
+
# define SIGNED_VALUE intptr_t
|
75
|
+
# define SIZEOF_VALUE SIZEOF_UINTPTR_T
|
76
|
+
# undef PRI_VALUE_PREFIX
|
77
|
+
# define RBIMPL_VALUE_NULL UINTPTR_C(0)
|
78
|
+
# define RBIMPL_VALUE_ONE UINTPTR_C(1)
|
79
|
+
# define RBIMPL_VALUE_FULL UINTPTR_MAX
|
80
|
+
|
81
|
+
#elif SIZEOF_LONG == SIZEOF_VOIDP
|
82
|
+
typedef unsigned long VALUE;
|
83
|
+
typedef unsigned long ID;
|
84
|
+
# define SIGNED_VALUE long
|
85
|
+
# define SIZEOF_VALUE SIZEOF_LONG
|
86
|
+
# define PRI_VALUE_PREFIX "l"
|
87
|
+
# define RBIMPL_VALUE_NULL 0UL
|
88
|
+
# define RBIMPL_VALUE_ONE 1UL
|
89
|
+
# define RBIMPL_VALUE_FULL ULONG_MAX
|
90
|
+
|
91
|
+
#elif SIZEOF_LONG_LONG == SIZEOF_VOIDP
|
92
|
+
typedef unsigned LONG_LONG VALUE;
|
93
|
+
typedef unsigned LONG_LONG ID;
|
94
|
+
# define SIGNED_VALUE LONG_LONG
|
95
|
+
# define LONG_LONG_VALUE 1
|
96
|
+
# define SIZEOF_VALUE SIZEOF_LONG_LONG
|
97
|
+
# define PRI_VALUE_PREFIX PRI_LL_PREFIX
|
98
|
+
# define RBIMPL_VALUE_NULL 0ULL
|
99
|
+
# define RBIMPL_VALUE_ONE 1ULL
|
100
|
+
# define RBIMPL_VALUE_FULL ULLONG_MAX
|
101
|
+
|
102
|
+
#else
|
103
|
+
# error ---->> ruby requires sizeof(void*) == sizeof(long) or sizeof(LONG_LONG) to be compiled. <<----
|
104
|
+
#endif
|
105
|
+
|
106
|
+
#endif /* EXTERNAL_VALUE_H */
|
@@ -0,0 +1,42 @@
|
|
1
|
+
#ifndef RUBY_PROBES_HELPER_H
|
2
|
+
#define RUBY_PROBES_HELPER_H
|
3
|
+
|
4
|
+
#include "ruby/ruby.h"
|
5
|
+
|
6
|
+
struct ruby_dtrace_method_hook_args {
|
7
|
+
const char *classname;
|
8
|
+
const char *methodname;
|
9
|
+
const char *filename;
|
10
|
+
int line_no;
|
11
|
+
volatile VALUE klass;
|
12
|
+
volatile VALUE name;
|
13
|
+
};
|
14
|
+
|
15
|
+
NOINLINE(int rb_dtrace_setup(rb_execution_context_t *, VALUE, ID, struct ruby_dtrace_method_hook_args *));
|
16
|
+
|
17
|
+
#define RUBY_DTRACE_METHOD_HOOK(name, ec, klazz, id) \
|
18
|
+
do { \
|
19
|
+
if (UNLIKELY(RUBY_DTRACE_##name##_ENABLED())) { \
|
20
|
+
struct ruby_dtrace_method_hook_args args; \
|
21
|
+
if (rb_dtrace_setup(ec, klazz, id, &args)) { \
|
22
|
+
RUBY_DTRACE_##name(args.classname, \
|
23
|
+
args.methodname, \
|
24
|
+
args.filename, \
|
25
|
+
args.line_no); \
|
26
|
+
} \
|
27
|
+
} \
|
28
|
+
} while (0)
|
29
|
+
|
30
|
+
#define RUBY_DTRACE_METHOD_ENTRY_HOOK(ec, klass, id) \
|
31
|
+
RUBY_DTRACE_METHOD_HOOK(METHOD_ENTRY, ec, klass, id)
|
32
|
+
|
33
|
+
#define RUBY_DTRACE_METHOD_RETURN_HOOK(ec, klass, id) \
|
34
|
+
RUBY_DTRACE_METHOD_HOOK(METHOD_RETURN, ec, klass, id)
|
35
|
+
|
36
|
+
#define RUBY_DTRACE_CMETHOD_ENTRY_HOOK(ec, klass, id) \
|
37
|
+
RUBY_DTRACE_METHOD_HOOK(CMETHOD_ENTRY, ec, klass, id)
|
38
|
+
|
39
|
+
#define RUBY_DTRACE_CMETHOD_RETURN_HOOK(ec, klass, id) \
|
40
|
+
RUBY_DTRACE_METHOD_HOOK(CMETHOD_RETURN, ec, klass, id)
|
41
|
+
|
42
|
+
#endif /* RUBY_PROBES_HELPER_H */
|
@@ -0,0 +1,387 @@
|
|
1
|
+
#include "internal/gc.h"
|
2
|
+
#include "ruby/ruby.h"
|
3
|
+
#include "ruby/ractor.h"
|
4
|
+
#include "vm_core.h"
|
5
|
+
#include "id_table.h"
|
6
|
+
#include "vm_debug.h"
|
7
|
+
|
8
|
+
#ifndef RACTOR_CHECK_MODE
|
9
|
+
#define RACTOR_CHECK_MODE (VM_CHECK_MODE || RUBY_DEBUG) && (SIZEOF_UINT64_T == SIZEOF_VALUE)
|
10
|
+
#endif
|
11
|
+
|
12
|
+
enum rb_ractor_basket_type {
|
13
|
+
// basket is empty
|
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
|
+
};
|
99
|
+
|
100
|
+
struct rb_ractor_sync {
|
101
|
+
// ractor lock
|
102
|
+
rb_nativethread_lock_t lock;
|
103
|
+
#if RACTOR_CHECK_MODE > 0
|
104
|
+
VALUE locked_by;
|
105
|
+
#endif
|
106
|
+
rb_nativethread_cond_t cond;
|
107
|
+
|
108
|
+
bool incoming_port_closed;
|
109
|
+
bool outgoing_port_closed;
|
110
|
+
|
111
|
+
// All sent messages will be pushed into recv_queue
|
112
|
+
struct rb_ractor_queue recv_queue;
|
113
|
+
|
114
|
+
// The following ractors waiting for the yielding by this ractor
|
115
|
+
struct rb_ractor_queue takers_queue;
|
116
|
+
|
117
|
+
// Enabled if the ractor already terminated and not taken yet.
|
118
|
+
struct rb_ractor_basket will_basket;
|
119
|
+
|
120
|
+
struct ractor_wait {
|
121
|
+
enum rb_ractor_wait_status status;
|
122
|
+
enum rb_ractor_wakeup_status wakeup_status;
|
123
|
+
} wait;
|
124
|
+
};
|
125
|
+
|
126
|
+
// created
|
127
|
+
// | ready to run
|
128
|
+
// ====================== inserted to vm->ractor
|
129
|
+
// v
|
130
|
+
// blocking <---+ all threads are blocking
|
131
|
+
// | |
|
132
|
+
// v |
|
133
|
+
// running -----+
|
134
|
+
// | all threads are terminated.
|
135
|
+
// ====================== removed from vm->ractor
|
136
|
+
// v
|
137
|
+
// terminated
|
138
|
+
//
|
139
|
+
// status is protected by VM lock (global state)
|
140
|
+
enum ractor_status {
|
141
|
+
ractor_created,
|
142
|
+
ractor_running,
|
143
|
+
ractor_blocking,
|
144
|
+
ractor_terminated,
|
145
|
+
};
|
146
|
+
|
147
|
+
struct rb_ractor_struct {
|
148
|
+
struct rb_ractor_pub pub;
|
149
|
+
|
150
|
+
struct rb_ractor_sync sync;
|
151
|
+
VALUE receiving_mutex;
|
152
|
+
|
153
|
+
// vm wide barrier synchronization
|
154
|
+
rb_nativethread_cond_t barrier_wait_cond;
|
155
|
+
|
156
|
+
// thread management
|
157
|
+
struct {
|
158
|
+
struct ccan_list_head set;
|
159
|
+
unsigned int cnt;
|
160
|
+
unsigned int blocking_cnt;
|
161
|
+
unsigned int sleeper;
|
162
|
+
struct rb_thread_sched sched;
|
163
|
+
rb_execution_context_t *running_ec;
|
164
|
+
rb_thread_t *main;
|
165
|
+
} threads;
|
166
|
+
VALUE thgroup_default;
|
167
|
+
|
168
|
+
VALUE name;
|
169
|
+
VALUE loc;
|
170
|
+
|
171
|
+
enum ractor_status status_;
|
172
|
+
|
173
|
+
struct ccan_list_node vmlr_node;
|
174
|
+
|
175
|
+
// ractor local data
|
176
|
+
|
177
|
+
st_table *local_storage;
|
178
|
+
struct rb_id_table *idkey_local_storage;
|
179
|
+
|
180
|
+
VALUE r_stdin;
|
181
|
+
VALUE r_stdout;
|
182
|
+
VALUE r_stderr;
|
183
|
+
VALUE verbose;
|
184
|
+
VALUE debug;
|
185
|
+
|
186
|
+
rb_ractor_newobj_cache_t newobj_cache;
|
187
|
+
|
188
|
+
// gc.c rb_objspace_reachable_objects_from
|
189
|
+
struct gc_mark_func_data_struct {
|
190
|
+
void *data;
|
191
|
+
void (*mark_func)(VALUE v, void *data);
|
192
|
+
} *mfd;
|
193
|
+
}; // rb_ractor_t is defined in vm_core.h
|
194
|
+
|
195
|
+
|
196
|
+
static inline VALUE
|
197
|
+
rb_ractor_self(const rb_ractor_t *r)
|
198
|
+
{
|
199
|
+
return r->pub.self;
|
200
|
+
}
|
201
|
+
|
202
|
+
rb_ractor_t *rb_ractor_main_alloc(void);
|
203
|
+
void rb_ractor_main_setup(rb_vm_t *vm, rb_ractor_t *main_ractor, rb_thread_t *main_thread);
|
204
|
+
void rb_ractor_atexit(rb_execution_context_t *ec, VALUE result);
|
205
|
+
void rb_ractor_atexit_exception(rb_execution_context_t *ec);
|
206
|
+
void rb_ractor_teardown(rb_execution_context_t *ec);
|
207
|
+
void rb_ractor_receive_parameters(rb_execution_context_t *ec, rb_ractor_t *g, int len, VALUE *ptr);
|
208
|
+
void rb_ractor_send_parameters(rb_execution_context_t *ec, rb_ractor_t *g, VALUE args);
|
209
|
+
|
210
|
+
VALUE rb_thread_create_ractor(rb_ractor_t *g, VALUE args, VALUE proc); // defined in thread.c
|
211
|
+
|
212
|
+
int rb_ractor_living_thread_num(const rb_ractor_t *);
|
213
|
+
VALUE rb_ractor_thread_list(void);
|
214
|
+
bool rb_ractor_p(VALUE rv);
|
215
|
+
|
216
|
+
void rb_ractor_living_threads_init(rb_ractor_t *r);
|
217
|
+
void rb_ractor_living_threads_insert(rb_ractor_t *r, rb_thread_t *th);
|
218
|
+
void rb_ractor_living_threads_remove(rb_ractor_t *r, rb_thread_t *th);
|
219
|
+
void rb_ractor_blocking_threads_inc(rb_ractor_t *r, const char *file, int line); // TODO: file, line only for RUBY_DEBUG_LOG
|
220
|
+
void rb_ractor_blocking_threads_dec(rb_ractor_t *r, const char *file, int line); // TODO: file, line only for RUBY_DEBUG_LOG
|
221
|
+
|
222
|
+
void rb_ractor_vm_barrier_interrupt_running_thread(rb_ractor_t *r);
|
223
|
+
void rb_ractor_terminate_interrupt_main_thread(rb_ractor_t *r);
|
224
|
+
void rb_ractor_terminate_all(void);
|
225
|
+
bool rb_ractor_main_p_(void);
|
226
|
+
void rb_ractor_finish_marking(void);
|
227
|
+
void rb_ractor_atfork(rb_vm_t *vm, rb_thread_t *th);
|
228
|
+
|
229
|
+
VALUE rb_ractor_ensure_shareable(VALUE obj, VALUE name);
|
230
|
+
|
231
|
+
RUBY_SYMBOL_EXPORT_BEGIN
|
232
|
+
bool rb_ractor_shareable_p_continue(VALUE obj);
|
233
|
+
|
234
|
+
// THIS FUNCTION SHOULD NOT CALL WHILE INCREMENTAL MARKING!!
|
235
|
+
// This function is for T_DATA::free_func
|
236
|
+
void rb_ractor_local_storage_delkey(rb_ractor_local_key_t key);
|
237
|
+
|
238
|
+
RUBY_SYMBOL_EXPORT_END
|
239
|
+
|
240
|
+
static inline bool
|
241
|
+
rb_ractor_main_p(void)
|
242
|
+
{
|
243
|
+
if (ruby_single_main_ractor) {
|
244
|
+
return true;
|
245
|
+
}
|
246
|
+
else {
|
247
|
+
return rb_ractor_main_p_();
|
248
|
+
}
|
249
|
+
}
|
250
|
+
|
251
|
+
static inline bool
|
252
|
+
rb_ractor_status_p(rb_ractor_t *r, enum ractor_status status)
|
253
|
+
{
|
254
|
+
return r->status_ == status;
|
255
|
+
}
|
256
|
+
|
257
|
+
static inline void
|
258
|
+
rb_ractor_sleeper_threads_inc(rb_ractor_t *r)
|
259
|
+
{
|
260
|
+
r->threads.sleeper++;
|
261
|
+
}
|
262
|
+
|
263
|
+
static inline void
|
264
|
+
rb_ractor_sleeper_threads_dec(rb_ractor_t *r)
|
265
|
+
{
|
266
|
+
r->threads.sleeper--;
|
267
|
+
}
|
268
|
+
|
269
|
+
static inline void
|
270
|
+
rb_ractor_sleeper_threads_clear(rb_ractor_t *r)
|
271
|
+
{
|
272
|
+
r->threads.sleeper = 0;
|
273
|
+
}
|
274
|
+
|
275
|
+
static inline int
|
276
|
+
rb_ractor_sleeper_thread_num(rb_ractor_t *r)
|
277
|
+
{
|
278
|
+
return r->threads.sleeper;
|
279
|
+
}
|
280
|
+
|
281
|
+
static inline void
|
282
|
+
rb_ractor_thread_switch(rb_ractor_t *cr, rb_thread_t *th)
|
283
|
+
{
|
284
|
+
RUBY_DEBUG_LOG("th:%d->%u%s",
|
285
|
+
cr->threads.running_ec ? (int)rb_th_serial(cr->threads.running_ec->thread_ptr) : -1,
|
286
|
+
rb_th_serial(th), cr->threads.running_ec == th->ec ? " (same)" : "");
|
287
|
+
|
288
|
+
if (cr->threads.running_ec != th->ec) {
|
289
|
+
if (0) {
|
290
|
+
ruby_debug_printf("rb_ractor_thread_switch ec:%p->%p\n",
|
291
|
+
(void *)cr->threads.running_ec, (void *)th->ec);
|
292
|
+
}
|
293
|
+
}
|
294
|
+
else {
|
295
|
+
return;
|
296
|
+
}
|
297
|
+
|
298
|
+
if (cr->threads.running_ec != th->ec) {
|
299
|
+
th->running_time_us = 0;
|
300
|
+
}
|
301
|
+
|
302
|
+
cr->threads.running_ec = th->ec;
|
303
|
+
|
304
|
+
VM_ASSERT(cr == GET_RACTOR());
|
305
|
+
}
|
306
|
+
|
307
|
+
#define rb_ractor_set_current_ec(cr, ec) rb_ractor_set_current_ec_(cr, ec, __FILE__, __LINE__)
|
308
|
+
|
309
|
+
static inline void
|
310
|
+
rb_ractor_set_current_ec_(rb_ractor_t *cr, rb_execution_context_t *ec, const char *file, int line)
|
311
|
+
{
|
312
|
+
#ifdef RB_THREAD_LOCAL_SPECIFIER
|
313
|
+
# ifdef __APPLE__
|
314
|
+
rb_current_ec_set(ec);
|
315
|
+
# else
|
316
|
+
ruby_current_ec = ec;
|
317
|
+
# endif
|
318
|
+
#else
|
319
|
+
native_tls_set(ruby_current_ec_key, ec);
|
320
|
+
#endif
|
321
|
+
RUBY_DEBUG_LOG2(file, line, "ec:%p->%p", (void *)cr->threads.running_ec, (void *)ec);
|
322
|
+
VM_ASSERT(ec == NULL || cr->threads.running_ec != ec);
|
323
|
+
cr->threads.running_ec = ec;
|
324
|
+
}
|
325
|
+
|
326
|
+
void rb_vm_ractor_blocking_cnt_inc(rb_vm_t *vm, rb_ractor_t *cr, const char *file, int line);
|
327
|
+
void rb_vm_ractor_blocking_cnt_dec(rb_vm_t *vm, rb_ractor_t *cr, const char *file, int line);
|
328
|
+
|
329
|
+
static inline uint32_t
|
330
|
+
rb_ractor_id(const rb_ractor_t *r)
|
331
|
+
{
|
332
|
+
return r->pub.id;
|
333
|
+
}
|
334
|
+
|
335
|
+
#if RACTOR_CHECK_MODE > 0
|
336
|
+
# define RACTOR_BELONGING_ID(obj) (*(uint32_t *)(((uintptr_t)(obj)) + rb_gc_obj_slot_size(obj)))
|
337
|
+
|
338
|
+
uint32_t rb_ractor_current_id(void);
|
339
|
+
|
340
|
+
static inline void
|
341
|
+
rb_ractor_setup_belonging_to(VALUE obj, uint32_t rid)
|
342
|
+
{
|
343
|
+
RACTOR_BELONGING_ID(obj) = rid;
|
344
|
+
}
|
345
|
+
|
346
|
+
static inline void
|
347
|
+
rb_ractor_setup_belonging(VALUE obj)
|
348
|
+
{
|
349
|
+
rb_ractor_setup_belonging_to(obj, rb_ractor_current_id());
|
350
|
+
}
|
351
|
+
|
352
|
+
static inline uint32_t
|
353
|
+
rb_ractor_belonging(VALUE obj)
|
354
|
+
{
|
355
|
+
if (SPECIAL_CONST_P(obj) || RB_OBJ_SHAREABLE_P(obj)) {
|
356
|
+
return 0;
|
357
|
+
}
|
358
|
+
else {
|
359
|
+
return RACTOR_BELONGING_ID(obj);
|
360
|
+
}
|
361
|
+
}
|
362
|
+
|
363
|
+
static inline VALUE
|
364
|
+
rb_ractor_confirm_belonging(VALUE obj)
|
365
|
+
{
|
366
|
+
uint32_t id = rb_ractor_belonging(obj);
|
367
|
+
|
368
|
+
if (id == 0) {
|
369
|
+
if (UNLIKELY(!rb_ractor_shareable_p(obj))) {
|
370
|
+
rp(obj);
|
371
|
+
rb_bug("id == 0 but not shareable");
|
372
|
+
}
|
373
|
+
}
|
374
|
+
else if (UNLIKELY(id != rb_ractor_current_id())) {
|
375
|
+
if (rb_ractor_shareable_p(obj)) {
|
376
|
+
// ok
|
377
|
+
}
|
378
|
+
else {
|
379
|
+
rp(obj);
|
380
|
+
rb_bug("rb_ractor_confirm_belonging object-ractor id:%u, current-ractor id:%u", id, rb_ractor_current_id());
|
381
|
+
}
|
382
|
+
}
|
383
|
+
return obj;
|
384
|
+
}
|
385
|
+
#else
|
386
|
+
#define rb_ractor_confirm_belonging(obj) obj
|
387
|
+
#endif
|