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.
- checksums.yaml +4 -4
- data/README.md +0 -2
- data/datadog-ruby_core_source.gemspec +1 -1
- data/lib/datadog/ruby_core_source/ruby-2.6.0-p0/ccan/build_assert/build_assert.h +40 -0
- data/lib/datadog/ruby_core_source/ruby-2.6.0-p0/ccan/check_type/check_type.h +63 -0
- data/lib/datadog/ruby_core_source/ruby-2.6.0-p0/ccan/container_of/container_of.h +142 -0
- data/lib/datadog/ruby_core_source/ruby-2.6.0-p0/ccan/list/list.h +788 -0
- data/lib/datadog/ruby_core_source/ruby-2.6.0-p0/ccan/str/str.h +16 -0
- data/lib/datadog/ruby_core_source/ruby-2.6.0-p0/id.h +252 -0
- data/lib/datadog/ruby_core_source/ruby-2.6.0-p0/internal.h +2465 -0
- data/lib/datadog/ruby_core_source/ruby-2.6.0-p0/iseq.h +304 -0
- data/lib/datadog/ruby_core_source/ruby-2.6.0-p0/method.h +229 -0
- data/lib/datadog/ruby_core_source/ruby-2.6.0-p0/node.h +449 -0
- data/lib/datadog/ruby_core_source/ruby-2.6.0-p0/ruby_assert.h +60 -0
- data/lib/datadog/ruby_core_source/ruby-2.6.0-p0/ruby_atomic.h +244 -0
- data/lib/datadog/ruby_core_source/ruby-2.6.0-p0/thread_pthread.h +75 -0
- data/lib/datadog/ruby_core_source/ruby-2.6.0-p0/thread_win32.h +36 -0
- data/lib/datadog/ruby_core_source/ruby-2.6.0-p0/vm_core.h +1902 -0
- data/lib/datadog/ruby_core_source/ruby-2.6.0-p0/vm_opts.h +70 -0
- data/lib/datadog/ruby_core_source/ruby-2.7.0-p0/ccan/build_assert/build_assert.h +40 -0
- data/lib/datadog/ruby_core_source/ruby-2.7.0-p0/ccan/check_type/check_type.h +63 -0
- data/lib/datadog/ruby_core_source/ruby-2.7.0-p0/ccan/container_of/container_of.h +142 -0
- data/lib/datadog/ruby_core_source/ruby-2.7.0-p0/ccan/list/list.h +788 -0
- data/lib/datadog/ruby_core_source/ruby-2.7.0-p0/ccan/str/str.h +16 -0
- data/lib/datadog/ruby_core_source/ruby-2.7.0-p0/id.h +290 -0
- data/lib/datadog/ruby_core_source/ruby-2.7.0-p0/internal.h +2697 -0
- data/lib/datadog/ruby_core_source/ruby-2.7.0-p0/iseq.h +312 -0
- data/lib/datadog/ruby_core_source/ruby-2.7.0-p0/method.h +229 -0
- data/lib/datadog/ruby_core_source/ruby-2.7.0-p0/node.h +476 -0
- data/lib/datadog/ruby_core_source/ruby-2.7.0-p0/ruby_assert.h +15 -0
- data/lib/datadog/ruby_core_source/ruby-2.7.0-p0/ruby_atomic.h +244 -0
- data/lib/datadog/ruby_core_source/ruby-2.7.0-p0/thread_pthread.h +75 -0
- data/lib/datadog/ruby_core_source/ruby-2.7.0-p0/thread_win32.h +36 -0
- data/lib/datadog/ruby_core_source/ruby-2.7.0-p0/vm_core.h +1968 -0
- data/lib/datadog/ruby_core_source/ruby-2.7.0-p0/vm_opts.h +72 -0
- data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/ccan/build_assert/build_assert.h +40 -0
- data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/ccan/check_type/check_type.h +63 -0
- data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/ccan/container_of/container_of.h +142 -0
- data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/ccan/list/list.h +788 -0
- data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/ccan/str/str.h +16 -0
- data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/id.h +290 -0
- data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/id_table.h +36 -0
- data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/internal/array.h +119 -0
- data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/internal/class.h +174 -0
- data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/internal/compilers.h +108 -0
- data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/internal/gc.h +161 -0
- data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/internal/imemo.h +243 -0
- data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/internal/serial.h +24 -0
- data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/internal/static_assert.h +17 -0
- data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/internal/vm.h +136 -0
- data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/internal/warnings.h +17 -0
- data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/internal.h +107 -0
- data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/iseq.h +305 -0
- data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/method.h +245 -0
- data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/node.h +484 -0
- data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/ractor_core.h +343 -0
- data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/ruby_assert.h +15 -0
- data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/ruby_atomic.h +23 -0
- data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/thread_pthread.h +115 -0
- data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/thread_win32.h +61 -0
- data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/vm_core.h +2023 -0
- data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/vm_debug.h +116 -0
- data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/vm_opts.h +73 -0
- data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/ccan/build_assert/build_assert.h +40 -0
- data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/ccan/check_type/check_type.h +63 -0
- data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/ccan/container_of/container_of.h +142 -0
- data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/ccan/list/list.h +788 -0
- data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/ccan/str/str.h +16 -0
- data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/darray.h +198 -0
- data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/id.h +293 -0
- data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/id_table.h +36 -0
- data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/internal/array.h +113 -0
- data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/internal/class.h +196 -0
- data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/internal/compilers.h +107 -0
- data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/internal/gc.h +186 -0
- data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/internal/imemo.h +243 -0
- data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/internal/serial.h +23 -0
- data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/internal/static_assert.h +16 -0
- data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/internal/vm.h +133 -0
- data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/internal/warnings.h +16 -0
- data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/internal.h +109 -0
- data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/iseq.h +322 -0
- data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/method.h +253 -0
- data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/node.h +510 -0
- data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/ractor_core.h +346 -0
- data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/ruby_assert.h +14 -0
- data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/ruby_atomic.h +23 -0
- data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/thread_pthread.h +115 -0
- data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/vm_core.h +2107 -0
- data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/vm_debug.h +124 -0
- data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/vm_opts.h +73 -0
- data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/ccan/build_assert/build_assert.h +40 -0
- data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/ccan/check_type/check_type.h +63 -0
- data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/ccan/container_of/container_of.h +142 -0
- data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/ccan/list/list.h +789 -0
- data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/ccan/str/str.h +17 -0
- data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/id.h +299 -0
- data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/id_table.h +39 -0
- data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/internal/array.h +163 -0
- data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/internal/basic_operators.h +64 -0
- data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/internal/class.h +182 -0
- data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/internal/compilers.h +107 -0
- data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/internal/gc.h +192 -0
- data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/internal/imemo.h +242 -0
- data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/internal/serial.h +23 -0
- data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/internal/static_assert.h +16 -0
- data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/internal/vm.h +134 -0
- data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/internal/warnings.h +16 -0
- data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/internal.h +113 -0
- data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/iseq.h +329 -0
- data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/method.h +254 -0
- data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/node.h +514 -0
- data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/ractor_core.h +342 -0
- data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/ruby_assert.h +14 -0
- data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/ruby_atomic.h +23 -0
- data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/shape.h +232 -0
- data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/thread_none.h +20 -0
- data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/thread_pthread.h +133 -0
- data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/vm_core.h +2106 -0
- data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/vm_debug.h +122 -0
- data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/vm_opts.h +73 -0
- data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/ccan/build_assert/build_assert.h +40 -0
- data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/ccan/check_type/check_type.h +63 -0
- data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/ccan/container_of/container_of.h +142 -0
- data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/ccan/list/list.h +791 -0
- data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/ccan/str/str.h +17 -0
- data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/constant.h +53 -0
- data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/debug_counter.h +428 -0
- data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/hrtime.h +237 -0
- data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/id.h +365 -0
- data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/id_table.h +74 -0
- data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/internal/array.h +158 -0
- data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/internal/basic_operators.h +67 -0
- data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/internal/bits.h +647 -0
- data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/internal/box.h +103 -0
- data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/internal/class.h +797 -0
- data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/internal/compilers.h +104 -0
- data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/internal/coverage.h +51 -0
- data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/internal/gc.h +411 -0
- data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/internal/imemo.h +302 -0
- data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/internal/sanitizers.h +346 -0
- data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/internal/serial.h +23 -0
- data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/internal/set_table.h +77 -0
- data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/internal/static_assert.h +16 -0
- data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/internal/time.h +34 -0
- data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/internal/variable.h +81 -0
- data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/internal/vm.h +144 -0
- data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/internal/warnings.h +16 -0
- data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/internal.h +106 -0
- data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/iseq.h +439 -0
- data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/method.h +279 -0
- data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/node.h +122 -0
- data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/parser_st.h +161 -0
- data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/parser_value.h +116 -0
- data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/arena.h +37 -0
- data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/ast.h +10371 -0
- data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/buffer.h +52 -0
- data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/comments.h +43 -0
- data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/compiler/align.h +36 -0
- data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/compiler/exported.h +24 -0
- data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/compiler/filesystem.h +32 -0
- data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/compiler/nodiscard.h +22 -0
- data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/compiler/nonnull.h +18 -0
- data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/constant_pool.h +81 -0
- data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/diagnostic.h +93 -0
- data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/errors_format.h +53 -0
- data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/excludes.h +29 -0
- data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/integer.h +41 -0
- data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/json.h +32 -0
- data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/line_offset_list.h +61 -0
- data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/magic_comments.h +35 -0
- data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/node.h +94 -0
- data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/options.h +335 -0
- data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/parser.h +348 -0
- data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/prettyprint.h +31 -0
- data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/prism.h +131 -0
- data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/serialize.h +115 -0
- data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/source.h +155 -0
- data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/stream.h +28 -0
- data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/string_query.h +63 -0
- data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/stringy.h +72 -0
- data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/version.h +38 -0
- data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism_compile.h +204 -0
- data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/ractor_core.h +421 -0
- data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/ruby_assert.h +14 -0
- data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/ruby_atomic.h +115 -0
- data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/rubyparser.h +1389 -0
- data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/shape.h +733 -0
- data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/thread_none.h +25 -0
- data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/thread_pthread.h +63 -0
- data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/thread_sched.h +271 -0
- data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/vm_core.h +2509 -0
- data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/vm_debug.h +124 -0
- data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/vm_opts.h +65 -0
- data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/vm_sync.h +160 -0
- data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/zjit.h +221 -0
- data/lib/datadog/ruby_core_source/version.rb +1 -1
- metadata +197 -4
|
@@ -0,0 +1,421 @@
|
|
|
1
|
+
#ifndef RUBY_RACTOR_CORE_H
|
|
2
|
+
#define RUBY_RACTOR_CORE_H
|
|
3
|
+
#include "internal/gc.h"
|
|
4
|
+
#include "internal/sanitizers.h"
|
|
5
|
+
#include "ruby/ruby.h"
|
|
6
|
+
#include "ruby/ractor.h"
|
|
7
|
+
#include "vm_core.h"
|
|
8
|
+
#include "id_table.h"
|
|
9
|
+
#include "vm_debug.h"
|
|
10
|
+
#include "hrtime.h"
|
|
11
|
+
|
|
12
|
+
#ifndef RACTOR_CHECK_MODE
|
|
13
|
+
#define RACTOR_CHECK_MODE (VM_CHECK_MODE || RUBY_DEBUG) && (SIZEOF_UINT64_T == SIZEOF_VALUE)
|
|
14
|
+
#endif
|
|
15
|
+
|
|
16
|
+
/* Record the registration-time VALUE in each rb_gc_register_address entry so the
|
|
17
|
+
* verifier can distinguish a transitioned cross-Ractor store from conservative
|
|
18
|
+
* garbage. Debug and ASAN builds only; production keeps one-word entries. */
|
|
19
|
+
#ifndef RB_GC_REGISTERED_ADDR_CHECK
|
|
20
|
+
# if RUBY_DEBUG || defined(RUBY_ASAN_ENABLED)
|
|
21
|
+
# define RB_GC_REGISTERED_ADDR_CHECK 1
|
|
22
|
+
# else
|
|
23
|
+
# define RB_GC_REGISTERED_ADDR_CHECK 0
|
|
24
|
+
# endif
|
|
25
|
+
#endif
|
|
26
|
+
|
|
27
|
+
// experimental flag because it is not sure it is the common pattern
|
|
28
|
+
#define RUBY_TYPED_FROZEN_SHAREABLE_NO_REC RUBY_FL_FINALIZE
|
|
29
|
+
|
|
30
|
+
/* An in-flight move payload, serialized off-heap (defined in ractor.c). */
|
|
31
|
+
struct rb_ractor_courier;
|
|
32
|
+
|
|
33
|
+
struct rb_ractor_sync {
|
|
34
|
+
// ractor lock
|
|
35
|
+
rb_nativethread_lock_t lock;
|
|
36
|
+
|
|
37
|
+
#if RACTOR_CHECK_MODE > 0
|
|
38
|
+
VALUE locked_by;
|
|
39
|
+
#endif
|
|
40
|
+
|
|
41
|
+
// incoming messages
|
|
42
|
+
struct ractor_queue *recv_queue;
|
|
43
|
+
|
|
44
|
+
// waiting threads for receiving
|
|
45
|
+
struct ccan_list_head waiters;
|
|
46
|
+
|
|
47
|
+
// ports
|
|
48
|
+
VALUE default_port_value;
|
|
49
|
+
struct st_table *ports;
|
|
50
|
+
size_t next_port_id;
|
|
51
|
+
|
|
52
|
+
/* The baskets this Ractor holds that are on no queue: one it is building to send,
|
|
53
|
+
* and one it has taken off a queue and is materializing. A queued basket is rooted
|
|
54
|
+
* by its queue instead. Only the owner touches this list. */
|
|
55
|
+
struct ccan_list_head off_queue_baskets;
|
|
56
|
+
|
|
57
|
+
// monitors
|
|
58
|
+
struct ccan_list_head monitors;
|
|
59
|
+
|
|
60
|
+
// value
|
|
61
|
+
rb_ractor_t *successor;
|
|
62
|
+
VALUE legacy;
|
|
63
|
+
bool legacy_exc;
|
|
64
|
+
bool legacy_taken; /* Ractor#value already returned the value */
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
struct ractor_basket;
|
|
68
|
+
|
|
69
|
+
// created
|
|
70
|
+
// | ready to run
|
|
71
|
+
// ====================== inserted to vm->ractor
|
|
72
|
+
// v
|
|
73
|
+
// blocking <---+ all threads are blocking
|
|
74
|
+
// | |
|
|
75
|
+
// v |
|
|
76
|
+
// running -----+
|
|
77
|
+
// | all threads are terminated.
|
|
78
|
+
// ====================== removed from vm->ractor
|
|
79
|
+
// v
|
|
80
|
+
// terminated
|
|
81
|
+
//
|
|
82
|
+
// status is protected by VM lock (global state)
|
|
83
|
+
enum ractor_status {
|
|
84
|
+
ractor_created,
|
|
85
|
+
ractor_running,
|
|
86
|
+
ractor_blocking,
|
|
87
|
+
ractor_terminated,
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
struct rb_ractor_registered_addr {
|
|
91
|
+
VALUE *addr;
|
|
92
|
+
#if RB_GC_REGISTERED_ADDR_CHECK
|
|
93
|
+
/* A raw provenance snapshot for verification only. Never mark or dereference it. */
|
|
94
|
+
VALUE initial_value;
|
|
95
|
+
#endif
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
struct rb_ractor_struct {
|
|
99
|
+
struct rb_ractor_pub pub;
|
|
100
|
+
struct rb_ractor_sync sync;
|
|
101
|
+
|
|
102
|
+
/* rb_gc_register_mark_object pins, per Ractor: the owner marks them (live via
|
|
103
|
+
* rb_ractor_mark_local_roots, unmerged zombie via the zombie scan) and a merge moves
|
|
104
|
+
* them to the survivor. Raw malloc, so a merge during sweep cannot re-enter GC. */
|
|
105
|
+
VALUE *registered_marks;
|
|
106
|
+
size_t registered_marks_cnt, registered_marks_capa;
|
|
107
|
+
|
|
108
|
+
struct rb_ractor_registered_addr *registered_addrs;
|
|
109
|
+
size_t registered_addrs_cnt, registered_addrs_capa;
|
|
110
|
+
bool registered_addrs_listed;
|
|
111
|
+
|
|
112
|
+
/* traversal-API mark redirect (NULL outside a traversal). Per Ractor so a
|
|
113
|
+
* concurrent traversal on another Ractor is never observed. A modular GC's
|
|
114
|
+
* Ractor-less marking worker threads read vm->gc.mark_func_data instead. */
|
|
115
|
+
struct gc_mark_func_data_struct *mark_func_data;
|
|
116
|
+
|
|
117
|
+
// thread management
|
|
118
|
+
struct {
|
|
119
|
+
struct ccan_list_head set;
|
|
120
|
+
unsigned int cnt;
|
|
121
|
+
unsigned int blocking_cnt;
|
|
122
|
+
unsigned int sleeper;
|
|
123
|
+
struct rb_thread_sched sched;
|
|
124
|
+
rb_execution_context_t *running_ec;
|
|
125
|
+
rb_thread_t *main;
|
|
126
|
+
// MN termination epilogue: keeps the dying thread marked (like a set
|
|
127
|
+
// member) between leaving the living set and its last use
|
|
128
|
+
rb_thread_t *dying_th;
|
|
129
|
+
|
|
130
|
+
// `main` is in rb_thread_terminate_all(), waiting for the others to go
|
|
131
|
+
bool terminating;
|
|
132
|
+
} threads;
|
|
133
|
+
|
|
134
|
+
/* Postponed jobs targeted at this Ractor
|
|
135
|
+
* (rb_postponed_job_trigger_for_ractor): bits index the VM-wide
|
|
136
|
+
* preregistration table; any of this Ractor's threads drains them
|
|
137
|
+
* in rb_postponed_job_flush. */
|
|
138
|
+
rb_atomic_t postponed_job_triggered_bits;
|
|
139
|
+
|
|
140
|
+
VALUE thgroup_default;
|
|
141
|
+
|
|
142
|
+
VALUE name;
|
|
143
|
+
VALUE loc;
|
|
144
|
+
|
|
145
|
+
enum ractor_status status_;
|
|
146
|
+
|
|
147
|
+
struct ccan_list_node vmlr_node;
|
|
148
|
+
bool in_terminated_set; /* vmlr_node is on vm->ractor.terminated_set */
|
|
149
|
+
/* The final self collection ran (ractor_postmortem_collect): from then on
|
|
150
|
+
* rb_ractor_mark_local_roots roots only the join value and the registered_marks
|
|
151
|
+
* pins, so the dying thread's own scaffolding can be collected. */
|
|
152
|
+
bool postmortem;
|
|
153
|
+
|
|
154
|
+
// ractor local data
|
|
155
|
+
|
|
156
|
+
rb_serial_t next_ec_serial;
|
|
157
|
+
|
|
158
|
+
st_table *local_storage;
|
|
159
|
+
struct rb_id_table *idkey_local_storage;
|
|
160
|
+
VALUE local_storage_store_lock;
|
|
161
|
+
|
|
162
|
+
/* 0 until first use: rb_ractor_stdin and friends build them lazily, with plain
|
|
163
|
+
* stores (rooted via ractor_mark_unshareable_parts; a write barrier on the
|
|
164
|
+
* shareable wrapper would shref-pin them). */
|
|
165
|
+
VALUE r_stdin;
|
|
166
|
+
VALUE r_stdout;
|
|
167
|
+
VALUE r_stderr;
|
|
168
|
+
VALUE verbose;
|
|
169
|
+
VALUE debug;
|
|
170
|
+
|
|
171
|
+
bool malloc_gc_disabled;
|
|
172
|
+
bool main_ractor;
|
|
173
|
+
void *newobj_cache;
|
|
174
|
+
|
|
175
|
+
/* This Ractor's objspace. The main Ractor receives the boot objspace from
|
|
176
|
+
* rb_gc_init_objspaces; a non-main Ractor shares the main one until it gets its
|
|
177
|
+
* own (while this is NULL). */
|
|
178
|
+
void *objspace;
|
|
179
|
+
|
|
180
|
+
/* A child Ractor's objspace is populated (Thread/Fiber wrappers) before it joins
|
|
181
|
+
* vm->ractor.set, so a whole-VM walk would miss it. Park it here from wrapper
|
|
182
|
+
* allocation until vm_insert_ractor clears it (under the VM lock) so the global GC
|
|
183
|
+
* still enumerates it. */
|
|
184
|
+
void *creating_child_objspace;
|
|
185
|
+
|
|
186
|
+
}; // rb_ractor_t is defined in vm_core.h
|
|
187
|
+
|
|
188
|
+
/* Mark the GC roots held in Ractor r's C structs (from the root scan in gc.c). */
|
|
189
|
+
void rb_ractor_mark_local_roots(rb_ractor_t *r);
|
|
190
|
+
void rb_ractor_mark_terminated_join_value(rb_ractor_t *r);
|
|
191
|
+
void rb_ractor_reap_dead_ports(rb_ractor_t *r);
|
|
192
|
+
|
|
193
|
+
/* Move src's registered_marks to dst and leave src empty (on join or when an orphan
|
|
194
|
+
* is absorbed). An absorb can run during a GC sweep, so the implementation uses raw
|
|
195
|
+
* realloc (ractor.c). */
|
|
196
|
+
void rb_ractor_absorb_registered_marks(rb_ractor_t *dst, rb_ractor_t *src);
|
|
197
|
+
|
|
198
|
+
void rb_ractor_absorb_registered_addrs_without_gc(rb_ractor_t *dst, rb_ractor_t *src);
|
|
199
|
+
|
|
200
|
+
enum ractor_wakeup_status {
|
|
201
|
+
wakeup_none,
|
|
202
|
+
wakeup_by_send,
|
|
203
|
+
wakeup_by_interrupt,
|
|
204
|
+
wakeup_by_close,
|
|
205
|
+
};
|
|
206
|
+
|
|
207
|
+
struct ractor_waiter {
|
|
208
|
+
enum ractor_wakeup_status wakeup_status;
|
|
209
|
+
rb_thread_t *th;
|
|
210
|
+
struct ccan_list_node node;
|
|
211
|
+
rb_atomic_t event_serial;
|
|
212
|
+
|
|
213
|
+
// absolute deadline for this wait, NULL when there is no timeout
|
|
214
|
+
const rb_hrtime_t *end;
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
static inline VALUE
|
|
218
|
+
rb_ractor_self(const rb_ractor_t *r)
|
|
219
|
+
{
|
|
220
|
+
return r->pub.self;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
rb_ractor_t *rb_ractor_main_alloc(void);
|
|
224
|
+
void rb_ractor_main_setup(rb_vm_t *vm, rb_ractor_t *main_ractor, rb_thread_t *main_thread);
|
|
225
|
+
void rb_ractor_atexit(rb_execution_context_t *ec, VALUE result);
|
|
226
|
+
void rb_ractor_atexit_exception(rb_execution_context_t *ec);
|
|
227
|
+
void rb_ractor_teardown(rb_execution_context_t *ec);
|
|
228
|
+
void rb_ractor_receive_parameters(rb_execution_context_t *ec, rb_ractor_t *g, int len, VALUE *ptr);
|
|
229
|
+
void rb_ractor_send_parameters(rb_execution_context_t *ec, rb_ractor_t *g, VALUE args);
|
|
230
|
+
void rb_ractor_setup_default_port(rb_ractor_t *r);
|
|
231
|
+
|
|
232
|
+
VALUE rb_thread_create_ractor(rb_ractor_t *g, VALUE args, VALUE proc); // defined in thread.c
|
|
233
|
+
|
|
234
|
+
int rb_ractor_living_thread_num(const rb_ractor_t *);
|
|
235
|
+
VALUE rb_ractor_thread_list(void);
|
|
236
|
+
bool rb_ractor_p(VALUE rv);
|
|
237
|
+
|
|
238
|
+
void rb_ractor_living_threads_init(rb_ractor_t *r);
|
|
239
|
+
void rb_ractor_living_threads_insert(rb_ractor_t *r, rb_thread_t *th);
|
|
240
|
+
void rb_ractor_living_threads_remove(rb_ractor_t *r, rb_thread_t *th);
|
|
241
|
+
|
|
242
|
+
/* The structs the final self collection swept while the dying thread still stood on
|
|
243
|
+
* them; that thread frees them at its very last step (rb_ractor_postmortem_free). */
|
|
244
|
+
struct rb_ractor_postmortem_frees {
|
|
245
|
+
struct rb_thread_struct *th;
|
|
246
|
+
struct rb_fiber_struct *fiber;
|
|
247
|
+
};
|
|
248
|
+
void rb_ractor_postmortem(rb_thread_t *th, struct rb_ractor_postmortem_frees *pf);
|
|
249
|
+
void rb_ractor_postmortem_free(const struct rb_ractor_postmortem_frees *pf);
|
|
250
|
+
void rb_ractor_cancel_creation(rb_ractor_t *r, rb_thread_t *th);
|
|
251
|
+
void rb_ractor_blocking_threads_inc(rb_ractor_t *r, const char *file, int line); // TODO: file, line only for RUBY_DEBUG_LOG
|
|
252
|
+
void rb_ractor_blocking_threads_dec(rb_ractor_t *r, const char *file, int line); // TODO: file, line only for RUBY_DEBUG_LOG
|
|
253
|
+
|
|
254
|
+
void rb_ractor_vm_barrier_interrupt_running_thread(rb_ractor_t *r);
|
|
255
|
+
void rb_ractor_terminate_interrupt_main_thread(rb_ractor_t *r);
|
|
256
|
+
void rb_ractor_terminate_all(void);
|
|
257
|
+
bool rb_ractor_main_p_(void);
|
|
258
|
+
void rb_ractor_atfork(rb_vm_t *vm, rb_thread_t *th);
|
|
259
|
+
void rb_ractor_terminate_atfork(rb_vm_t *vm, rb_ractor_t *th);
|
|
260
|
+
VALUE rb_ractor_require(VALUE feature, bool silent);
|
|
261
|
+
VALUE rb_ractor_autoload_load(VALUE space, ID id);
|
|
262
|
+
|
|
263
|
+
VALUE rb_ractor_ensure_shareable(VALUE obj, VALUE name);
|
|
264
|
+
st_table *rb_ractor_targeted_hooks(rb_ractor_t *cr);
|
|
265
|
+
|
|
266
|
+
RUBY_SYMBOL_EXPORT_BEGIN
|
|
267
|
+
void rb_ractor_finish_marking(bool full_mark);
|
|
268
|
+
|
|
269
|
+
bool rb_ractor_shareable_p_continue(VALUE obj);
|
|
270
|
+
|
|
271
|
+
// THIS FUNCTION SHOULD NOT CALL WHILE INCREMENTAL MARKING!!
|
|
272
|
+
// This function is for T_DATA::free_func
|
|
273
|
+
void rb_ractor_local_storage_delkey(rb_ractor_local_key_t key);
|
|
274
|
+
|
|
275
|
+
RUBY_SYMBOL_EXPORT_END
|
|
276
|
+
|
|
277
|
+
static inline bool
|
|
278
|
+
rb_ractor_main_p(void)
|
|
279
|
+
{
|
|
280
|
+
if (ruby_single_main_ractor) {
|
|
281
|
+
return true;
|
|
282
|
+
}
|
|
283
|
+
else {
|
|
284
|
+
return rb_ractor_main_p_();
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
static inline bool
|
|
289
|
+
rb_ractor_status_p(rb_ractor_t *r, enum ractor_status status)
|
|
290
|
+
{
|
|
291
|
+
return r->status_ == status;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
static inline void
|
|
295
|
+
rb_ractor_sleeper_threads_inc(rb_ractor_t *r)
|
|
296
|
+
{
|
|
297
|
+
r->threads.sleeper++;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
static inline void
|
|
301
|
+
rb_ractor_sleeper_threads_dec(rb_ractor_t *r)
|
|
302
|
+
{
|
|
303
|
+
r->threads.sleeper--;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
static inline void
|
|
307
|
+
rb_ractor_sleeper_threads_clear(rb_ractor_t *r)
|
|
308
|
+
{
|
|
309
|
+
r->threads.sleeper = 0;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
static inline int
|
|
313
|
+
rb_ractor_sleeper_thread_num(rb_ractor_t *r)
|
|
314
|
+
{
|
|
315
|
+
return r->threads.sleeper;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
static inline void
|
|
319
|
+
rb_ractor_thread_switch(rb_ractor_t *cr, rb_thread_t *th, bool always_reset)
|
|
320
|
+
{
|
|
321
|
+
RUBY_DEBUG_LOG("th:%d->%u%s",
|
|
322
|
+
cr->threads.running_ec ? (int)rb_th_serial(cr->threads.running_ec->thread_ptr) : -1,
|
|
323
|
+
rb_th_serial(th), cr->threads.running_ec == th->ec ? " (same)" : "");
|
|
324
|
+
|
|
325
|
+
if (cr->threads.running_ec != th->ec || always_reset) {
|
|
326
|
+
th->running_time_us = 0;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
if (cr->threads.running_ec != th->ec) {
|
|
330
|
+
if (0) {
|
|
331
|
+
ruby_debug_printf("rb_ractor_thread_switch ec:%p->%p\n",
|
|
332
|
+
(void *)cr->threads.running_ec, (void *)th->ec);
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
else {
|
|
336
|
+
return;
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
cr->threads.running_ec = th->ec;
|
|
340
|
+
|
|
341
|
+
VM_ASSERT(cr == GET_RACTOR());
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
#define rb_ractor_set_current_ec(cr, ec) rb_ractor_set_current_ec_(cr, ec, __FILE__, __LINE__)
|
|
345
|
+
#ifdef RB_THREAD_LOCAL_SPECIFIER
|
|
346
|
+
void rb_current_ec_set(rb_execution_context_t *ec);
|
|
347
|
+
#endif
|
|
348
|
+
|
|
349
|
+
static inline void
|
|
350
|
+
rb_ractor_set_current_ec_(rb_ractor_t *cr, rb_execution_context_t *ec, const char *file, int line)
|
|
351
|
+
{
|
|
352
|
+
#ifdef RB_THREAD_LOCAL_SPECIFIER
|
|
353
|
+
rb_current_ec_set(ec);
|
|
354
|
+
#else
|
|
355
|
+
native_tls_set(ruby_current_ec_key, ec);
|
|
356
|
+
#endif
|
|
357
|
+
RUBY_DEBUG_LOG2(file, line, "ec:%p->%p", (void *)cr->threads.running_ec, (void *)ec);
|
|
358
|
+
VM_ASSERT(ec == NULL || cr->threads.running_ec != ec);
|
|
359
|
+
cr->threads.running_ec = ec;
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
void rb_vm_ractor_blocking_cnt_inc(rb_vm_t *vm, rb_ractor_t *cr, const char *file, int line);
|
|
363
|
+
void rb_vm_ractor_blocking_cnt_dec(rb_vm_t *vm, rb_ractor_t *cr, const char *file, int line);
|
|
364
|
+
|
|
365
|
+
static inline rb_serial_t
|
|
366
|
+
rb_ractor_id(const rb_ractor_t *r)
|
|
367
|
+
{
|
|
368
|
+
return r->pub.id;
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
static inline void
|
|
372
|
+
rb_ractor_targeted_hooks_incr(rb_ractor_t *cr)
|
|
373
|
+
{
|
|
374
|
+
cr->pub.targeted_hooks_cnt++;
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
static inline void
|
|
378
|
+
rb_ractor_targeted_hooks_decr(rb_ractor_t *cr)
|
|
379
|
+
{
|
|
380
|
+
RUBY_ASSERT(cr->pub.targeted_hooks_cnt > 0);
|
|
381
|
+
cr->pub.targeted_hooks_cnt--;
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
static inline unsigned int
|
|
385
|
+
rb_ractor_targeted_hooks_cnt(rb_ractor_t *cr)
|
|
386
|
+
{
|
|
387
|
+
return cr->pub.targeted_hooks_cnt;
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
#if RACTOR_CHECK_MODE > 0
|
|
391
|
+
|
|
392
|
+
extern bool rb_ractor_ignore_belonging_flag;
|
|
393
|
+
|
|
394
|
+
/* An object's owning Ractor is decided by the objspace its page belongs to
|
|
395
|
+
* (rb_gc_obj_foreign_p). Putting an unshareable object on the VM stack of anyone
|
|
396
|
+
* but its owner is a containment violation. */
|
|
397
|
+
static inline VALUE
|
|
398
|
+
rb_ractor_confirm_belonging(VALUE obj)
|
|
399
|
+
{
|
|
400
|
+
if (rb_ractor_ignore_belonging_flag) return obj;
|
|
401
|
+
if (SPECIAL_CONST_P(obj) || RB_OBJ_SHAREABLE_P(obj)) return obj;
|
|
402
|
+
|
|
403
|
+
if (UNLIKELY(rb_gc_obj_foreign_p(obj))) {
|
|
404
|
+
rp(obj);
|
|
405
|
+
rb_bug("rb_ractor_confirm_belonging: unshareable object of another Ractor's objspace");
|
|
406
|
+
}
|
|
407
|
+
return obj;
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
static inline void
|
|
411
|
+
rb_ractor_ignore_belonging(bool flag)
|
|
412
|
+
{
|
|
413
|
+
rb_ractor_ignore_belonging_flag = flag;
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
#else
|
|
417
|
+
#define rb_ractor_confirm_belonging(obj) obj
|
|
418
|
+
#define rb_ractor_ignore_belonging(flag) (0)
|
|
419
|
+
#endif
|
|
420
|
+
|
|
421
|
+
#endif /* RUBY_RACTOR_CORE_H */
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#ifndef RUBY_TOPLEVEL_ASSERT_H /*-*-C-*-vi:se ft=c:*/
|
|
2
|
+
#define RUBY_TOPLEVEL_ASSERT_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
|
+
*/
|
|
10
|
+
#include "ruby/assert.h"
|
|
11
|
+
#undef assert
|
|
12
|
+
#define assert RUBY_ASSERT_NDEBUG
|
|
13
|
+
|
|
14
|
+
#endif /* RUBY_TOPLEVEL_ASSERT_H */
|
|
@@ -0,0 +1,115 @@
|
|
|
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(_M_X64) && !defined(_M_ARM64EC)
|
|
43
|
+
return *value;
|
|
44
|
+
#elif defined(_WIN32)
|
|
45
|
+
uint64_t val = *value;
|
|
46
|
+
return InterlockedCompareExchange64(RBIMPL_CAST((uint64_t *)value), val, val);
|
|
47
|
+
#elif defined(__sun) && defined(HAVE_ATOMIC_H) && (defined(_LP64) || defined(_I32LPx))
|
|
48
|
+
uint64_t val = *value;
|
|
49
|
+
return atomic_cas_64(value, val, val);
|
|
50
|
+
#else
|
|
51
|
+
// TODO: stdatomic
|
|
52
|
+
|
|
53
|
+
return *value;
|
|
54
|
+
#endif
|
|
55
|
+
}
|
|
56
|
+
#define ATOMIC_U64_LOAD_RELAXED(var) rbimpl_atomic_u64_load_relaxed(&(var))
|
|
57
|
+
|
|
58
|
+
static inline void
|
|
59
|
+
rbimpl_atomic_u64_set_relaxed(volatile rbimpl_atomic_uint64_t *address, uint64_t value)
|
|
60
|
+
{
|
|
61
|
+
#if defined(HAVE_GCC_ATOMIC_BUILTINS_64)
|
|
62
|
+
__atomic_store_n(address, value, __ATOMIC_RELAXED);
|
|
63
|
+
#elif defined(_WIN32)
|
|
64
|
+
InterlockedExchange64(address, value);
|
|
65
|
+
#elif defined(__sun) && defined(HAVE_ATOMIC_H) && (defined(_LP64) || defined(_I32LPx))
|
|
66
|
+
atomic_swap_64(address, value);
|
|
67
|
+
#else
|
|
68
|
+
// TODO: stdatomic
|
|
69
|
+
|
|
70
|
+
*address = value;
|
|
71
|
+
#endif
|
|
72
|
+
}
|
|
73
|
+
#define ATOMIC_U64_SET_RELAXED(var, val) rbimpl_atomic_u64_set_relaxed(&(var), val)
|
|
74
|
+
|
|
75
|
+
static inline uint64_t
|
|
76
|
+
rbimpl_atomic_u64_fetch_add_relaxed(volatile rbimpl_atomic_uint64_t *value, uint64_t addend)
|
|
77
|
+
{
|
|
78
|
+
#if defined(HAVE_GCC_ATOMIC_BUILTINS_64)
|
|
79
|
+
return __atomic_fetch_add(value, addend, __ATOMIC_RELAXED);
|
|
80
|
+
#elif defined(_WIN32)
|
|
81
|
+
return (uint64_t)InterlockedExchangeAdd64((LONG64 *)value, (LONG64)addend);
|
|
82
|
+
#elif defined(__sun) && defined(HAVE_ATOMIC_H) && (defined(_LP64) || defined(_I32LPx))
|
|
83
|
+
return atomic_add_64_nv(value, addend) - addend;
|
|
84
|
+
#else
|
|
85
|
+
// TODO: stdatomic
|
|
86
|
+
uint64_t prev = *value;
|
|
87
|
+
*value = prev + addend;
|
|
88
|
+
return prev;
|
|
89
|
+
#endif
|
|
90
|
+
}
|
|
91
|
+
#define ATOMIC_U64_FETCH_ADD_RELAXED(var, val) rbimpl_atomic_u64_fetch_add_relaxed(&(var), val)
|
|
92
|
+
|
|
93
|
+
static inline uint64_t
|
|
94
|
+
rbimpl_atomic_u64_load_acquire(const volatile rbimpl_atomic_uint64_t *value)
|
|
95
|
+
{
|
|
96
|
+
#if defined(HAVE_GCC_ATOMIC_BUILTINS_64)
|
|
97
|
+
return __atomic_load_n(value, __ATOMIC_ACQUIRE);
|
|
98
|
+
#else
|
|
99
|
+
return rbimpl_atomic_u64_load_relaxed(value);
|
|
100
|
+
#endif
|
|
101
|
+
}
|
|
102
|
+
#define ATOMIC_U64_LOAD_ACQUIRE(var) rbimpl_atomic_u64_load_acquire(&(var))
|
|
103
|
+
|
|
104
|
+
static inline void
|
|
105
|
+
rbimpl_atomic_u64_set_release(volatile rbimpl_atomic_uint64_t *address, uint64_t value)
|
|
106
|
+
{
|
|
107
|
+
#if defined(HAVE_GCC_ATOMIC_BUILTINS_64)
|
|
108
|
+
__atomic_store_n(address, value, __ATOMIC_RELEASE);
|
|
109
|
+
#else
|
|
110
|
+
rbimpl_atomic_u64_set_relaxed(address, value);
|
|
111
|
+
#endif
|
|
112
|
+
}
|
|
113
|
+
#define ATOMIC_U64_SET_RELEASE(var, val) rbimpl_atomic_u64_set_release(&(var), val)
|
|
114
|
+
|
|
115
|
+
#endif
|