debase-ruby_core_source 4.0.1 → 4.1.0.preview1
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/CHANGELOG.md +4 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/addr2line.h +22 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/builtin.h +127 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/ccan/build_assert/build_assert.h +40 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/ccan/check_type/check_type.h +63 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/ccan/container_of/container_of.h +142 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/ccan/list/list.h +791 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/ccan/str/str.h +17 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/constant.h +53 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/darray.h +295 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/debug_counter.h +428 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/dln.h +33 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/encindex.h +70 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/eval_intern.h +356 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/hrtime.h +237 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/id.h +365 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/id_table.h +74 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/insns.inc +315 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/insns_info.inc +11637 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/array.h +158 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/basic_operators.h +67 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/bignum.h +249 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/bits.h +647 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/box.h +103 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/class.h +797 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/cmdlineopt.h +64 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/compar.h +30 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/compile.h +34 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/compilers.h +104 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/complex.h +29 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/concurrent_set.h +21 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/cont.h +33 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/coverage.h +51 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/dir.h +16 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/enc.h +19 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/encoding.h +40 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/enum.h +18 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/enumerator.h +21 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/error.h +287 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/eval.h +43 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/file.h +40 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/fixnum.h +185 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/gc.h +411 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/hash.h +220 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/imemo.h +302 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/inits.h +54 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/io.h +167 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/io_buffer.h +36 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/jit.h +23 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/load.h +20 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/loadpath.h +16 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/marshal.h +17 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/math.h +23 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/missing.h +19 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/numeric.h +326 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/object.h +88 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/objspace.h +24 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/parse.h +131 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/proc.h +34 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/process.h +124 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/ractor.h +9 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/random.h +17 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/range.h +46 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/rational.h +92 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/re.h +87 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/ruby_parser.h +109 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/sanitizers.h +346 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/scheduler.h +7 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/serial.h +23 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/set.h +20 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/set_table.h +77 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/signal.h +25 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/simd.h +18 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/st.h +32 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/static_assert.h +16 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/string.h +240 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/struct.h +120 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/symbol.h +46 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/thread.h +108 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/time.h +34 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/transcode.h +23 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/util.h +27 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/variable.h +81 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/vm.h +144 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/vm_map.h +95 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/warnings.h +16 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal.h +106 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/iseq.h +439 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/known_errors.inc +1419 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/method.h +279 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/node.h +122 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/node_name.inc +224 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/optinsn.inc +128 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/optunifs.inc +41 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/parse.h +246 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/parser_bits.h +647 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/parser_node.h +32 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/parser_st.h +161 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/parser_value.h +116 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/arena.h +37 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/ast.h +10371 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/buffer.h +52 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/comments.h +43 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/compiler/accel.h +19 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/compiler/align.h +36 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/compiler/assume.h +25 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/compiler/exported.h +24 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/compiler/fallthrough.h +22 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/compiler/filesystem.h +32 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/compiler/flex_array.h +19 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/compiler/force_inline.h +21 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/compiler/format.h +25 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/compiler/inline.h +17 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/compiler/nodiscard.h +22 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/compiler/nonnull.h +18 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/compiler/unused.h +18 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/constant_pool.h +81 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/diagnostic.h +93 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/errors_format.h +53 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/excludes.h +29 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/extension.h +19 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/integer.h +41 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/internal/allocator.h +68 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/internal/allocator_debug.h +88 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/internal/arena.h +108 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/internal/bit.h +42 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/internal/buffer.h +91 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/internal/char.h +139 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/internal/comments.h +20 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/internal/constant_pool.h +152 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/internal/diagnostic.h +389 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/internal/encoding.h +242 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/internal/integer.h +68 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/internal/isinf.h +16 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/internal/line_offset_list.h +34 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/internal/list.h +62 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/internal/magic_comments.h +23 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/internal/memchr.h +15 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/internal/node.h +32 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/internal/options.h +224 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/internal/parser.h +971 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/internal/regexp.h +42 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/internal/serialize.h +39 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/internal/source.h +72 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/internal/static_literals.h +100 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/internal/stringy.h +35 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/internal/strncasecmp.h +18 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/internal/strpbrk.h +33 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/internal/tokens.h +11 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/json.h +32 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/line_offset_list.h +61 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/magic_comments.h +35 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/node.h +94 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/options.h +335 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/parser.h +348 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/prettyprint.h +31 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/prism.h +131 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/serialize.h +115 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/source.h +155 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/stream.h +28 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/string_query.h +63 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/stringy.h +72 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/version.h +38 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism_compile.h +204 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism_xallocator.h +6 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/probes_helper.h +42 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/ractor_core.h +421 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/regenc.h +261 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/regint.h +983 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/regparse.h +371 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/revision.h +5 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/ruby_assert.h +14 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/ruby_atomic.h +115 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/rubyparser.h +1389 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/shape.h +733 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/siphash.h +48 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/symbol.h +116 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/thread_none.h +25 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/thread_pthread.h +63 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/thread_sched.h +271 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/thread_win32.h +48 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/timev.h +58 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/transcode_data.h +138 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/variable.h +26 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/version.h +69 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/vm.inc +6457 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/vm_call_iseq_optimized.inc +244 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/vm_callinfo.h +688 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/vm_core.h +2509 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/vm_debug.h +124 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/vm_exec.h +202 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/vm_insnhelper.h +280 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/vm_opts.h +65 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/vm_sync.h +160 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/vmtc.inc +302 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/yjit.h +87 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/zjit.h +221 -0
- data/lib/debase/ruby_core_source/version.rb +1 -1
- metadata +2930 -2724
|
@@ -0,0 +1,411 @@
|
|
|
1
|
+
#ifndef INTERNAL_GC_H /*-*-C-*-vi:se ft=c:*/
|
|
2
|
+
#define INTERNAL_GC_H
|
|
3
|
+
/**
|
|
4
|
+
* @author Ruby developers <ruby-core@ruby-lang.org>
|
|
5
|
+
* @copyright This file is a part of the programming language Ruby.
|
|
6
|
+
* Permission is hereby granted, to either redistribute and/or
|
|
7
|
+
* modify this file, provided that the conditions mentioned in the
|
|
8
|
+
* file COPYING are met. Consult the file for details.
|
|
9
|
+
* @brief Internal header for GC.
|
|
10
|
+
*/
|
|
11
|
+
#include "ruby/internal/config.h"
|
|
12
|
+
|
|
13
|
+
#include <stddef.h> /* for size_t */
|
|
14
|
+
|
|
15
|
+
#include "internal/compilers.h" /* for __has_attribute */
|
|
16
|
+
#include "ruby/ruby.h" /* for rb_event_flag_t */
|
|
17
|
+
#include "ruby_atomic.h" /* for RUBY_ATOMIC_VALUE_SET */
|
|
18
|
+
|
|
19
|
+
struct rb_gc_zjit_fastpath;
|
|
20
|
+
|
|
21
|
+
#ifndef USE_MODULAR_GC
|
|
22
|
+
# define USE_MODULAR_GC 0
|
|
23
|
+
#endif
|
|
24
|
+
|
|
25
|
+
#if defined(__x86_64__) && !defined(_ILP32) && defined(__GNUC__)
|
|
26
|
+
#define SET_MACHINE_STACK_END(p) __asm__ __volatile__ ("movq\t%%rsp, %0" : "=r" (*(p)))
|
|
27
|
+
#elif defined(__i386) && defined(__GNUC__)
|
|
28
|
+
#define SET_MACHINE_STACK_END(p) __asm__ __volatile__ ("movl\t%%esp, %0" : "=r" (*(p)))
|
|
29
|
+
#elif (defined(__powerpc__) || defined(__powerpc64__)) && defined(__GNUC__) && !defined(_AIX)
|
|
30
|
+
#define SET_MACHINE_STACK_END(p) __asm__ __volatile__ ("mr\t%0, %%r1" : "=r" (*(p)))
|
|
31
|
+
#elif (defined(__powerpc__) || defined(__powerpc64__)) && defined(__GNUC__) && defined(_AIX)
|
|
32
|
+
#define SET_MACHINE_STACK_END(p) __asm__ __volatile__ ("mr %0,1" : "=r" (*(p)))
|
|
33
|
+
#elif defined(__aarch64__) && defined(__GNUC__)
|
|
34
|
+
#define SET_MACHINE_STACK_END(p) __asm__ __volatile__ ("mov\t%0, sp" : "=r" (*(p)))
|
|
35
|
+
#else
|
|
36
|
+
NOINLINE(void rb_gc_set_stack_end(VALUE **stack_end_p));
|
|
37
|
+
#define SET_MACHINE_STACK_END(p) rb_gc_set_stack_end(p)
|
|
38
|
+
#define USE_CONSERVATIVE_STACK_END
|
|
39
|
+
#endif
|
|
40
|
+
|
|
41
|
+
/* for GC debug */
|
|
42
|
+
|
|
43
|
+
#ifndef RUBY_MARK_FREE_DEBUG
|
|
44
|
+
#define RUBY_MARK_FREE_DEBUG 0
|
|
45
|
+
#endif
|
|
46
|
+
|
|
47
|
+
#if RUBY_MARK_FREE_DEBUG
|
|
48
|
+
extern int ruby_gc_debug_indent;
|
|
49
|
+
|
|
50
|
+
static inline void
|
|
51
|
+
rb_gc_debug_indent(void)
|
|
52
|
+
{
|
|
53
|
+
ruby_debug_printf("%*s", ruby_gc_debug_indent, "");
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
static inline void
|
|
57
|
+
rb_gc_debug_body(const char *mode, const char *msg, int st, void *ptr)
|
|
58
|
+
{
|
|
59
|
+
if (st == 0) {
|
|
60
|
+
ruby_gc_debug_indent--;
|
|
61
|
+
}
|
|
62
|
+
rb_gc_debug_indent();
|
|
63
|
+
ruby_debug_printf("%s: %s %s (%p)\n", mode, st ? "->" : "<-", msg, ptr);
|
|
64
|
+
|
|
65
|
+
if (st) {
|
|
66
|
+
ruby_gc_debug_indent++;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
fflush(stdout);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
#define RUBY_MARK_ENTER(msg) rb_gc_debug_body("mark", (msg), 1, ptr)
|
|
73
|
+
#define RUBY_MARK_LEAVE(msg) rb_gc_debug_body("mark", (msg), 0, ptr)
|
|
74
|
+
#define RUBY_FREE_ENTER(msg) rb_gc_debug_body("free", (msg), 1, ptr)
|
|
75
|
+
#define RUBY_FREE_LEAVE(msg) rb_gc_debug_body("free", (msg), 0, ptr)
|
|
76
|
+
#define RUBY_GC_INFO rb_gc_debug_indent(), ruby_debug_printf
|
|
77
|
+
|
|
78
|
+
#else
|
|
79
|
+
#define RUBY_MARK_ENTER(msg)
|
|
80
|
+
#define RUBY_MARK_LEAVE(msg)
|
|
81
|
+
#define RUBY_FREE_ENTER(msg)
|
|
82
|
+
#define RUBY_FREE_LEAVE(msg)
|
|
83
|
+
#define RUBY_GC_INFO if(0)printf
|
|
84
|
+
#endif
|
|
85
|
+
|
|
86
|
+
#if STACK_GROW_DIRECTION > 0
|
|
87
|
+
# define STACK_UPPER(x, a, b) (a)
|
|
88
|
+
#elif STACK_GROW_DIRECTION < 0
|
|
89
|
+
# define STACK_UPPER(x, a, b) (b)
|
|
90
|
+
#else
|
|
91
|
+
RUBY_EXTERN int ruby_stack_grow_direction;
|
|
92
|
+
int ruby_get_stack_grow_direction(volatile VALUE *addr);
|
|
93
|
+
# define stack_growup_p(x) ( \
|
|
94
|
+
(ruby_stack_grow_direction ? \
|
|
95
|
+
ruby_stack_grow_direction : \
|
|
96
|
+
ruby_get_stack_grow_direction(x)) > 0)
|
|
97
|
+
# define STACK_UPPER(x, a, b) (stack_growup_p(x) ? (a) : (b))
|
|
98
|
+
#endif
|
|
99
|
+
|
|
100
|
+
/*
|
|
101
|
+
STACK_GROW_DIR_DETECTION is used with STACK_DIR_UPPER.
|
|
102
|
+
|
|
103
|
+
On most normal systems, stacks grow from high address to lower address. In
|
|
104
|
+
this case, STACK_DIR_UPPER(a, b) will return (b), but on exotic systems where
|
|
105
|
+
the stack grows UP (from low address to high address), it will return (a).
|
|
106
|
+
*/
|
|
107
|
+
|
|
108
|
+
#if STACK_GROW_DIRECTION
|
|
109
|
+
#define STACK_GROW_DIR_DETECTION
|
|
110
|
+
#define STACK_DIR_UPPER(a,b) STACK_UPPER(0, (a), (b))
|
|
111
|
+
#else
|
|
112
|
+
#define STACK_GROW_DIR_DETECTION VALUE stack_grow_dir_detection
|
|
113
|
+
#define STACK_DIR_UPPER(a,b) STACK_UPPER(&stack_grow_dir_detection, (a), (b))
|
|
114
|
+
#endif
|
|
115
|
+
#define IS_STACK_DIR_UPPER() STACK_DIR_UPPER(1,0)
|
|
116
|
+
|
|
117
|
+
const char *rb_obj_info(VALUE obj);
|
|
118
|
+
const char *rb_raw_obj_info(char *const buff, const size_t buff_size, VALUE obj);
|
|
119
|
+
|
|
120
|
+
struct rb_execution_context_struct; /* in vm_core.h */
|
|
121
|
+
struct rb_objspace; /* in vm_core.h */
|
|
122
|
+
struct rb_ractor_struct; /* in vm_core.h */
|
|
123
|
+
|
|
124
|
+
#define EC_NEWOBJ_OF(var, T, c, f, s, ec) \
|
|
125
|
+
T *(var) = (T *)rb_ec_newobj_of((ec), (c), (f), s)
|
|
126
|
+
#define NEWOBJ_OF(var, T, c, f, s) EC_NEWOBJ_OF(var, T, c, f, s, GET_EC())
|
|
127
|
+
#define UNPROTECTED_NEWOBJ_OF(var, T, c, f, s) \
|
|
128
|
+
T *(var) = (T *)rb_newobj((GET_EC()), (c), (f), ROOT_SHAPE_ID | SHAPE_ID_LAYOUT_OTHER, false, s)
|
|
129
|
+
|
|
130
|
+
#ifndef RB_GC_OBJECT_METADATA_ENTRY_DEFINED
|
|
131
|
+
# define RB_GC_OBJECT_METADATA_ENTRY_DEFINED
|
|
132
|
+
struct rb_gc_object_metadata_entry {
|
|
133
|
+
ID name;
|
|
134
|
+
VALUE val;
|
|
135
|
+
};
|
|
136
|
+
#endif
|
|
137
|
+
|
|
138
|
+
#ifndef USE_UNALIGNED_MEMBER_ACCESS
|
|
139
|
+
# define UNALIGNED_MEMBER_ACCESS(expr) (expr)
|
|
140
|
+
#elif ! USE_UNALIGNED_MEMBER_ACCESS
|
|
141
|
+
# define UNALIGNED_MEMBER_ACCESS(expr) (expr)
|
|
142
|
+
#elif ! (__has_warning("-Waddress-of-packed-member") || GCC_VERSION_SINCE(9, 0, 0))
|
|
143
|
+
# define UNALIGNED_MEMBER_ACCESS(expr) (expr)
|
|
144
|
+
#else
|
|
145
|
+
# include "internal/warnings.h"
|
|
146
|
+
# define UNALIGNED_MEMBER_ACCESS(expr) __extension__({ \
|
|
147
|
+
COMPILER_WARNING_PUSH; \
|
|
148
|
+
COMPILER_WARNING_IGNORED(-Waddress-of-packed-member); \
|
|
149
|
+
__typeof__(expr) unaligned_member_access_result = (expr); \
|
|
150
|
+
COMPILER_WARNING_POP; \
|
|
151
|
+
unaligned_member_access_result; \
|
|
152
|
+
})
|
|
153
|
+
|
|
154
|
+
# define UNALIGNED_MEMBER_PTR(ptr, mem) __extension__({ \
|
|
155
|
+
COMPILER_WARNING_PUSH; \
|
|
156
|
+
COMPILER_WARNING_IGNORED(-Waddress-of-packed-member); \
|
|
157
|
+
const volatile void *unaligned_member_ptr_result = &(ptr)->mem; \
|
|
158
|
+
COMPILER_WARNING_POP; \
|
|
159
|
+
(__typeof__((ptr)->mem) *)unaligned_member_ptr_result; \
|
|
160
|
+
})
|
|
161
|
+
#endif
|
|
162
|
+
|
|
163
|
+
#ifndef UNALIGNED_MEMBER_PTR
|
|
164
|
+
# define UNALIGNED_MEMBER_PTR(ptr, mem) UNALIGNED_MEMBER_ACCESS(&(ptr)->mem)
|
|
165
|
+
#endif
|
|
166
|
+
|
|
167
|
+
#define RB_OBJ_WRITE_UNALIGNED(old, slot, young) do { \
|
|
168
|
+
VALUE *_slot = UNALIGNED_MEMBER_ACCESS(slot); \
|
|
169
|
+
RB_OBJ_WRITE(old, _slot, young); \
|
|
170
|
+
} while (0)
|
|
171
|
+
|
|
172
|
+
/* Used in places that could malloc during, which can cause the GC to run. We
|
|
173
|
+
* need to temporarily disable the GC to allow the malloc to happen.
|
|
174
|
+
* Allocating memory during GC is a bad idea, so use this only when absolutely
|
|
175
|
+
* necessary. */
|
|
176
|
+
/* Only re-entrant GC of the current objspace needs suppressing (the malloc happens inside this
|
|
177
|
+
* Ractor), so use the local disable. The during-GC malloc guard reads the per-objspace dont_gc
|
|
178
|
+
* flag rather than a process-wide one. */
|
|
179
|
+
#define DURING_GC_COULD_MALLOC_REGION_START() \
|
|
180
|
+
assert(rb_during_gc()); \
|
|
181
|
+
VALUE _already_disabled = rb_gc_local_disable_no_rest()
|
|
182
|
+
|
|
183
|
+
#define DURING_GC_COULD_MALLOC_REGION_END() \
|
|
184
|
+
if (_already_disabled == Qfalse) rb_gc_local_enable()
|
|
185
|
+
|
|
186
|
+
/* gc.c */
|
|
187
|
+
RUBY_ATTR_MALLOC void *ruby_mimmalloc(size_t size);
|
|
188
|
+
RUBY_ATTR_MALLOC void *ruby_mimcalloc(size_t num, size_t size);
|
|
189
|
+
void ruby_mimfree(void *ptr);
|
|
190
|
+
void rb_gc_prepare_heap(void);
|
|
191
|
+
VALUE rb_wmap_new_hidden(void);
|
|
192
|
+
VALUE rb_wmap_lookup(VALUE wmap, VALUE key);
|
|
193
|
+
void rb_wmap_aset(VALUE wmap, VALUE key, VALUE val);
|
|
194
|
+
void rb_objspace_set_event_hook(const rb_event_flag_t event);
|
|
195
|
+
VALUE rb_objspace_gc_enable(void *objspace);
|
|
196
|
+
VALUE rb_objspace_gc_disable(void *objspace);
|
|
197
|
+
void ruby_gc_set_params(void);
|
|
198
|
+
void rb_gc_copy_attributes(VALUE dest, VALUE obj);
|
|
199
|
+
size_t rb_size_mul_or_raise(size_t, size_t, VALUE); /* used in compile.c */
|
|
200
|
+
size_t rb_size_mul_add_or_raise(size_t, size_t, size_t, VALUE); /* used in iseq.h */
|
|
201
|
+
size_t rb_malloc_grow_capa(size_t current_capacity, size_t type_size);
|
|
202
|
+
RUBY_ATTR_MALLOC void *rb_xmalloc_mul_add(size_t, size_t, size_t);
|
|
203
|
+
RUBY_ATTR_MALLOC void *rb_xcalloc_mul_add(size_t, size_t, size_t);
|
|
204
|
+
void *rb_xrealloc_mul_add(const void *, size_t, size_t, size_t);
|
|
205
|
+
RUBY_ATTR_MALLOC void *rb_xmalloc_mul_add_mul(size_t, size_t, size_t, size_t);
|
|
206
|
+
RUBY_ATTR_MALLOC void *rb_xcalloc_mul_add_mul(size_t, size_t, size_t, size_t);
|
|
207
|
+
void rb_gc_register_pinning_obj(VALUE obj);
|
|
208
|
+
struct rb_execution_context_struct *rb_gc_get_ec(void);
|
|
209
|
+
VALUE rb_newobj_of_unprotected(VALUE klass, VALUE flags, size_t size);
|
|
210
|
+
|
|
211
|
+
void *rb_gc_ractor_cache_alloc(struct rb_ractor_struct *ractor);
|
|
212
|
+
void rb_gc_ractor_cache_free(void *cache);
|
|
213
|
+
bool rb_gc_zjit_new_obj_fastpath(size_t alloc_size, VALUE flags, VALUE klass, struct rb_gc_zjit_fastpath *fastpath);
|
|
214
|
+
const uintptr_t *rb_gc_zjit_writebarrier_required_p_ptr(void);
|
|
215
|
+
|
|
216
|
+
bool rb_gc_size_allocatable_p(size_t size);
|
|
217
|
+
size_t rb_gc_size_slot_size(size_t size);
|
|
218
|
+
size_t rb_gc_max_allocation_size(void);
|
|
219
|
+
|
|
220
|
+
void rb_gc_mark_and_move(VALUE *ptr);
|
|
221
|
+
|
|
222
|
+
/* The objspace a marking walk marks into, plus the per-Ractor traversal redirect slot
|
|
223
|
+
* (vm_core.h's gc_mark_func_data_struct) and the shareable-check flag cached from it.
|
|
224
|
+
* Resolving the current Ractor costs an out-of-line rb_current_ec() call on arm64, so a
|
|
225
|
+
* walk resolves it once into a ctx and threads that down instead of repeating it per
|
|
226
|
+
* reference. Only gc.c builds one; everyone else just passes the pointer along. */
|
|
227
|
+
struct gc_mark_func_data_struct;
|
|
228
|
+
|
|
229
|
+
struct rb_gc_mark_ctx {
|
|
230
|
+
void *objspace;
|
|
231
|
+
struct gc_mark_func_data_struct **mfdp;
|
|
232
|
+
bool checking_shareable;
|
|
233
|
+
};
|
|
234
|
+
|
|
235
|
+
void rb_gc_mark_and_pin_ctx(const struct rb_gc_mark_ctx *ctx, VALUE obj);
|
|
236
|
+
void rb_gc_mark_movable_ctx(const struct rb_gc_mark_ctx *ctx, VALUE obj);
|
|
237
|
+
void rb_gc_mark_maybe_ctx(const struct rb_gc_mark_ctx *ctx, VALUE obj);
|
|
238
|
+
void rb_gc_mark_and_move_ctx(const struct rb_gc_mark_ctx *ctx, VALUE *ptr);
|
|
239
|
+
void rb_gc_mark_locations_ctx(const struct rb_gc_mark_ctx *ctx, const VALUE *start, const VALUE *end);
|
|
240
|
+
void rb_mark_tbl_no_pin_ctx(const struct rb_gc_mark_ctx *ctx, st_table *tbl);
|
|
241
|
+
void rb_gc_mark_set_no_pin_ctx(const struct rb_gc_mark_ctx *ctx, st_table *tbl);
|
|
242
|
+
VALUE rb_gc_location_ctx(const struct rb_gc_mark_ctx *ctx, VALUE value);
|
|
243
|
+
void rb_gc_update_moved_ctx(const struct rb_gc_mark_ctx *ctx, VALUE *ptr);
|
|
244
|
+
|
|
245
|
+
static inline bool
|
|
246
|
+
rb_gc_checking_shareable_ctx(const struct rb_gc_mark_ctx *ctx)
|
|
247
|
+
{
|
|
248
|
+
return ctx->checking_shareable;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
void rb_gc_ref_update_table_values_only(st_table *tbl);
|
|
252
|
+
|
|
253
|
+
void rb_gc_initial_stress_set(VALUE flag);
|
|
254
|
+
|
|
255
|
+
void rb_gc_before_fork(void);
|
|
256
|
+
void rb_gc_after_fork(rb_pid_t pid);
|
|
257
|
+
|
|
258
|
+
#define rb_gc_mark_and_move_ptr(ptr) do { \
|
|
259
|
+
VALUE _obj = (VALUE)*(ptr); \
|
|
260
|
+
rb_gc_mark_and_move(&_obj); \
|
|
261
|
+
if (_obj != (VALUE)*(ptr)) *(ptr) = (void *)_obj; \
|
|
262
|
+
} while (0)
|
|
263
|
+
|
|
264
|
+
#define rb_gc_update_moved_ptr(ptr) do { \
|
|
265
|
+
VALUE _obj = (VALUE)*(ptr); \
|
|
266
|
+
rb_gc_update_moved(&_obj); \
|
|
267
|
+
if (_obj != (VALUE)*(ptr)) *(ptr) = (void *)_obj; \
|
|
268
|
+
} while (0)
|
|
269
|
+
|
|
270
|
+
#define rb_gc_mark_and_move_ptr_ctx(ctx, ptr) do { \
|
|
271
|
+
VALUE _obj = (VALUE)*(ptr); \
|
|
272
|
+
rb_gc_mark_and_move_ctx((ctx), &_obj); \
|
|
273
|
+
if (_obj != (VALUE)*(ptr)) *(ptr) = (void *)_obj; \
|
|
274
|
+
} while (0)
|
|
275
|
+
|
|
276
|
+
#define rb_gc_update_moved_ptr_ctx(ctx, ptr) do { \
|
|
277
|
+
VALUE _obj = (VALUE)*(ptr); \
|
|
278
|
+
rb_gc_update_moved_ctx((ctx), &_obj); \
|
|
279
|
+
if (_obj != (VALUE)*(ptr)) *(ptr) = (void *)_obj; \
|
|
280
|
+
} while (0)
|
|
281
|
+
|
|
282
|
+
void rb_objspace_reachable_objects_from_local(VALUE obj, void (func)(VALUE, void *), void *data);
|
|
283
|
+
|
|
284
|
+
#if USE_MODULAR_GC
|
|
285
|
+
RUBY_SYMBOL_EXPORT_BEGIN
|
|
286
|
+
#endif
|
|
287
|
+
/* Called only by the default GC's verifier, which lives in the GC's shared object in a
|
|
288
|
+
* modular build, so it needs exporting only there. */
|
|
289
|
+
void rb_objspace_reachable_objects_from_unlocked(VALUE obj, void (func)(VALUE, void *), void *data);
|
|
290
|
+
#if USE_MODULAR_GC
|
|
291
|
+
RUBY_SYMBOL_EXPORT_END
|
|
292
|
+
#endif
|
|
293
|
+
|
|
294
|
+
RUBY_SYMBOL_EXPORT_BEGIN
|
|
295
|
+
/* exports for objspace module */
|
|
296
|
+
void rb_objspace_reachable_objects_from(VALUE obj, void (func)(VALUE, void *), void *data);
|
|
297
|
+
void rb_objspace_reachable_objects_from_root(void (func)(const char *category, VALUE, void *), void *data);
|
|
298
|
+
int rb_objspace_internal_object_p(VALUE obj);
|
|
299
|
+
int rb_objspace_garbage_object_p(VALUE obj);
|
|
300
|
+
int rb_objspace_foreign_object_p(VALUE obj);
|
|
301
|
+
int rb_objspace_live_object_p(VALUE obj);
|
|
302
|
+
void rb_gc_declare_weak_references(VALUE obj);
|
|
303
|
+
bool rb_gc_handle_weak_references_alive_p(VALUE obj);
|
|
304
|
+
|
|
305
|
+
void rb_objspace_each_objects(
|
|
306
|
+
int (*callback)(void *start, void *end, size_t stride, void *data),
|
|
307
|
+
void *data);
|
|
308
|
+
|
|
309
|
+
|
|
310
|
+
size_t rb_gc_obj_slot_size(VALUE obj);
|
|
311
|
+
|
|
312
|
+
VALUE rb_gc_disable_no_rest(void);
|
|
313
|
+
/* Local GC disable/enable covering only the current Ractor's objspace. Unlike rb_gc_disable*,
|
|
314
|
+
* which became process-wide, this suppresses GC in one's own objspace only. Exported because
|
|
315
|
+
* DURING_GC_COULD_MALLOC_REGION above expands in bundled extensions. */
|
|
316
|
+
VALUE rb_gc_local_enable(void);
|
|
317
|
+
VALUE rb_gc_local_disable_no_rest(void);
|
|
318
|
+
|
|
319
|
+
#define RB_GC_MAX_NAME_LEN 20
|
|
320
|
+
|
|
321
|
+
/* gc.c (export) */
|
|
322
|
+
const char *rb_objspace_data_type_name(VALUE obj);
|
|
323
|
+
VALUE rb_newobj(struct rb_execution_context_struct *, VALUE, VALUE, uint32_t /* shape_id_t */, bool, size_t);
|
|
324
|
+
VALUE rb_newobj_of(VALUE, VALUE, size_t);
|
|
325
|
+
VALUE rb_ec_newobj_of(struct rb_execution_context_struct *, VALUE, VALUE, size_t);
|
|
326
|
+
size_t rb_obj_memsize_of(VALUE);
|
|
327
|
+
struct rb_gc_object_metadata_entry *rb_gc_object_metadata(VALUE obj);
|
|
328
|
+
void rb_gc_mark_values(long n, const VALUE *values);
|
|
329
|
+
void rb_gc_mark_vm_stack_values(long n, const VALUE *values);
|
|
330
|
+
struct rb_vm_struct;
|
|
331
|
+
void rb_gc_mark_registered_addrs(struct rb_ractor_struct *r, bool need_lock);
|
|
332
|
+
void rb_gc_registered_addrs_enroll_without_gc(struct rb_vm_struct *vm, struct rb_ractor_struct *r);
|
|
333
|
+
void rb_gc_registered_addrs_unenroll_without_gc(struct rb_vm_struct *vm, struct rb_ractor_struct *r);
|
|
334
|
+
void rb_gc_update_values(long n, VALUE *values);
|
|
335
|
+
void rb_gc_mark_set_no_pin(st_table *);
|
|
336
|
+
/* Exercised by the bundled -test-/gc/writebarrier extension, so it must be visible
|
|
337
|
+
* outside the ruby binary. */
|
|
338
|
+
void rb_gc_writebarrier_remember(VALUE obj);
|
|
339
|
+
void rb_gc_update_set_refs(st_table *);
|
|
340
|
+
|
|
341
|
+
#if USE_MODULAR_GC
|
|
342
|
+
const char *rb_gc_active_gc_name(void);
|
|
343
|
+
int rb_gc_modular_gc_loaded_p(void);
|
|
344
|
+
#endif
|
|
345
|
+
|
|
346
|
+
RUBY_SYMBOL_EXPORT_END
|
|
347
|
+
|
|
348
|
+
static inline VALUE
|
|
349
|
+
rb_obj_atomic_write(
|
|
350
|
+
VALUE a, VALUE *slot, VALUE b,
|
|
351
|
+
RBIMPL_ATTR_MAYBE_UNUSED()
|
|
352
|
+
const char *filename,
|
|
353
|
+
RBIMPL_ATTR_MAYBE_UNUSED()
|
|
354
|
+
int line)
|
|
355
|
+
{
|
|
356
|
+
#ifdef RGENGC_LOGGING_WRITE
|
|
357
|
+
RGENGC_LOGGING_WRITE(a, slot, b, filename, line);
|
|
358
|
+
#endif
|
|
359
|
+
|
|
360
|
+
RUBY_ATOMIC_VALUE_SET(*slot, b);
|
|
361
|
+
|
|
362
|
+
rb_obj_written(a, RUBY_Qundef /* ignore `oldv' now */, b, filename, line);
|
|
363
|
+
return a;
|
|
364
|
+
}
|
|
365
|
+
#define RB_OBJ_ATOMIC_WRITE(old, slot, young) \
|
|
366
|
+
RBIMPL_CAST(rb_obj_atomic_write((VALUE)(old), (VALUE *)(slot), (VALUE)(young), __FILE__, __LINE__))
|
|
367
|
+
|
|
368
|
+
int rb_ec_stack_check(struct rb_execution_context_struct *ec);
|
|
369
|
+
void rb_gc_obj_became_shareable(VALUE obj);
|
|
370
|
+
bool rb_gc_multi_objspace_p(void);
|
|
371
|
+
bool rb_gc_obj_foreign_p(VALUE obj);
|
|
372
|
+
void *rb_gc_objspace_alloc(void);
|
|
373
|
+
void rb_gc_objspace_retire_gc(void);
|
|
374
|
+
/* Build an object, or suppress GC, in a named objspace rather than the current
|
|
375
|
+
* Ractor's. Only create_ractor_alloc_thread() needs these. */
|
|
376
|
+
VALUE rb_data_typed_object_wrap_in_objspace(void *objspace, VALUE klass, void *datap, const rb_data_type_t *type);
|
|
377
|
+
VALUE rb_data_typed_object_zalloc_in_objspace(void *objspace, VALUE klass, size_t size, const rb_data_type_t *type);
|
|
378
|
+
VALUE rb_gc_objspace_disable_no_rest(void *objspace);
|
|
379
|
+
VALUE rb_gc_objspace_enable(void *objspace);
|
|
380
|
+
|
|
381
|
+
void rb_gc_objspace_retire(void **objspace_slot);
|
|
382
|
+
void rb_gc_objspace_postmortem_self(void);
|
|
383
|
+
void rb_gc_objspace_absorb_into_current(void **objspace_slot);
|
|
384
|
+
void rb_gc_objspace_absorb_all_zombies(void);
|
|
385
|
+
void rb_gc_objspace_disown(void *objspace);
|
|
386
|
+
void rb_gc_zombie_objspaces_atfork(void);
|
|
387
|
+
void rb_gc_disable_holders_atfork(void);
|
|
388
|
+
void rb_gc_atfork_global_locks(void);
|
|
389
|
+
void rb_gc_stash_cleanup_objspace(void);
|
|
390
|
+
void rb_gc_rest(void);
|
|
391
|
+
bool rb_gc_during_global_gc_p(void);
|
|
392
|
+
bool rb_gc_single_objspace_p(void);
|
|
393
|
+
const char *rb_obj_info(VALUE obj);
|
|
394
|
+
void ruby_annotate_mmap(const void *addr, unsigned long size, const char *name);
|
|
395
|
+
|
|
396
|
+
# define SIZED_REALLOC_N(v, T, m, n) \
|
|
397
|
+
((v) = (T *)ruby_xrealloc2_sized((void *)(v), (m), sizeof(T), (n)))
|
|
398
|
+
|
|
399
|
+
# define SIZED_FREE(v) ruby_xfree_sized((void *)(v), sizeof(*(v)))
|
|
400
|
+
# define SIZED_FREE_N(v, n) ruby_xfree_sized((void *)(v), sizeof(*(v)) * (n))
|
|
401
|
+
|
|
402
|
+
static inline void *
|
|
403
|
+
ruby_sized_realloc_n(void *ptr, size_t new_count, size_t element_size, size_t old_count)
|
|
404
|
+
{
|
|
405
|
+
return ruby_xrealloc2_sized(ptr, new_count, element_size, old_count);
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
void rb_gc_verify_shareable(VALUE);
|
|
409
|
+
bool rb_gc_checking_shareable(void);
|
|
410
|
+
|
|
411
|
+
#endif /* INTERNAL_GC_H */
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
#ifndef INTERNAL_HASH_H /*-*-C-*-vi:se ft=c:*/
|
|
2
|
+
#define INTERNAL_HASH_H
|
|
3
|
+
/**
|
|
4
|
+
* @author Ruby developers <ruby-core@ruby-lang.org>
|
|
5
|
+
* @copyright This file is a part of the programming language Ruby.
|
|
6
|
+
* Permission is hereby granted, to either redistribute and/or
|
|
7
|
+
* modify this file, provided that the conditions mentioned in the
|
|
8
|
+
* file COPYING are met. Consult the file for details.
|
|
9
|
+
* @brief Internal header for Hash.
|
|
10
|
+
*/
|
|
11
|
+
#include "ruby/internal/config.h"
|
|
12
|
+
#include <stddef.h> /* for size_t */
|
|
13
|
+
#include "ruby/internal/stdbool.h" /* for bool */
|
|
14
|
+
#include "ruby/ruby.h" /* for struct RBasic */
|
|
15
|
+
#include "ruby/st.h" /* for struct st_table */
|
|
16
|
+
|
|
17
|
+
#define RHASH_AR_TABLE_MAX_SIZE SIZEOF_VALUE
|
|
18
|
+
|
|
19
|
+
struct ar_table_struct;
|
|
20
|
+
typedef unsigned char ar_hint_t;
|
|
21
|
+
|
|
22
|
+
enum ruby_rhash_flags {
|
|
23
|
+
RHASH_PASS_AS_KEYWORDS = FL_USER1, /* FL 1 */
|
|
24
|
+
RHASH_PROC_DEFAULT = FL_USER2, /* FL 2 */
|
|
25
|
+
RHASH_ST_TABLE_FLAG = FL_USER3, /* FL 3 */
|
|
26
|
+
RHASH_AR_TABLE_SIZE_MASK = (FL_USER4|FL_USER5|FL_USER6|FL_USER7), /* FL 4..7 */
|
|
27
|
+
RHASH_AR_TABLE_SIZE_SHIFT = (FL_USHIFT+4),
|
|
28
|
+
RHASH_AR_TABLE_BOUND_MASK = (FL_USER8|FL_USER9|FL_USER10|FL_USER11), /* FL 8..11 */
|
|
29
|
+
RHASH_AR_TABLE_BOUND_SHIFT = (FL_USHIFT+8),
|
|
30
|
+
RHASH_COMPARE_BY_IDENTITY = FL_USER12, /* FL 12 */
|
|
31
|
+
|
|
32
|
+
// we can not put it in "enum" because it can exceed "int" range.
|
|
33
|
+
#define RHASH_LEV_MASK (FL_USER13 | FL_USER14 | FL_USER15 | /* FL 13..19 */ \
|
|
34
|
+
FL_USER16 | FL_USER17 | FL_USER18 | FL_USER19)
|
|
35
|
+
|
|
36
|
+
RHASH_LEV_SHIFT = (FL_USHIFT + 13),
|
|
37
|
+
RHASH_LEV_MAX = 127, /* 7 bits */
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
typedef struct ar_table_pair_struct {
|
|
41
|
+
VALUE key;
|
|
42
|
+
VALUE val;
|
|
43
|
+
} ar_table_pair;
|
|
44
|
+
|
|
45
|
+
typedef struct ar_table_struct {
|
|
46
|
+
union {
|
|
47
|
+
ar_hint_t ary[RHASH_AR_TABLE_MAX_SIZE];
|
|
48
|
+
VALUE word;
|
|
49
|
+
} ar_hint;
|
|
50
|
+
/* 64bit CPU: 8B * 2 * 8 = 128B */
|
|
51
|
+
ar_table_pair pairs[RHASH_AR_TABLE_MAX_SIZE];
|
|
52
|
+
} ar_table;
|
|
53
|
+
|
|
54
|
+
struct RHash {
|
|
55
|
+
struct RBasic basic;
|
|
56
|
+
const VALUE ifnone;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
#define RHASH(obj) ((struct RHash *)(obj))
|
|
60
|
+
|
|
61
|
+
#ifdef RHASH_IFNONE
|
|
62
|
+
# undef RHASH_IFNONE
|
|
63
|
+
#endif
|
|
64
|
+
|
|
65
|
+
#ifdef RHASH_SIZE
|
|
66
|
+
# undef RHASH_SIZE
|
|
67
|
+
#endif
|
|
68
|
+
|
|
69
|
+
#ifdef RHASH_EMPTY_P
|
|
70
|
+
# undef RHASH_EMPTY_P
|
|
71
|
+
#endif
|
|
72
|
+
|
|
73
|
+
/* hash.c */
|
|
74
|
+
VALUE rb_hash_default_value(VALUE hash, VALUE key);
|
|
75
|
+
VALUE rb_hash_set_default(VALUE hash, VALUE ifnone);
|
|
76
|
+
VALUE rb_hash_set_default_proc(VALUE hash, VALUE proc);
|
|
77
|
+
long rb_dbl_long_hash(double d);
|
|
78
|
+
st_table *rb_init_identtable(void);
|
|
79
|
+
void rb_init_existing_identtable_with_size(st_table *tbl, st_index_t size);
|
|
80
|
+
st_index_t rb_any_hash(VALUE a);
|
|
81
|
+
int rb_any_cmp(VALUE a, VALUE b);
|
|
82
|
+
VALUE rb_to_hash_type(VALUE obj);
|
|
83
|
+
VALUE rb_hash_key_str(VALUE);
|
|
84
|
+
VALUE rb_hash_values(VALUE hash);
|
|
85
|
+
VALUE rb_hash_rehash(VALUE hash);
|
|
86
|
+
int rb_hash_add_new_element(VALUE hash, VALUE key, VALUE val);
|
|
87
|
+
VALUE rb_hash_set_pair(VALUE hash, VALUE pair);
|
|
88
|
+
int rb_hash_stlike_delete(VALUE hash, st_data_t *pkey, st_data_t *pval);
|
|
89
|
+
int rb_hash_stlike_update(VALUE hash, st_data_t key, st_update_callback_func *func, st_data_t arg);
|
|
90
|
+
bool rb_hash_default_unredefined(VALUE hash);
|
|
91
|
+
VALUE rb_hash_alloc_fixed_size(VALUE klass, st_index_t size);
|
|
92
|
+
VALUE rb_ident_hash_new_capa(rb_len_t size);
|
|
93
|
+
void rb_hash_free(VALUE hash);
|
|
94
|
+
VALUE rb_hash_alloc_copy(VALUE klass, VALUE src);
|
|
95
|
+
RUBY_EXTERN VALUE rb_cHash_empty_frozen;
|
|
96
|
+
|
|
97
|
+
static inline unsigned RHASH_AR_TABLE_SIZE_RAW(VALUE h);
|
|
98
|
+
static inline VALUE RHASH_IFNONE(VALUE h);
|
|
99
|
+
static inline size_t RHASH_SIZE(VALUE h);
|
|
100
|
+
static inline bool RHASH_EMPTY_P(VALUE h);
|
|
101
|
+
static inline bool RHASH_AR_TABLE_P(VALUE h);
|
|
102
|
+
static inline bool RHASH_ST_TABLE_P(VALUE h);
|
|
103
|
+
static inline struct ar_table_struct *RHASH_AR_TABLE(VALUE h);
|
|
104
|
+
static inline st_table *RHASH_ST_TABLE(VALUE h);
|
|
105
|
+
static inline size_t RHASH_ST_SIZE(VALUE h);
|
|
106
|
+
static inline void RHASH_ST_CLEAR(VALUE h);
|
|
107
|
+
|
|
108
|
+
RUBY_SYMBOL_EXPORT_BEGIN
|
|
109
|
+
/* hash.c (export) */
|
|
110
|
+
VALUE rb_hash_delete_entry(VALUE hash, VALUE key);
|
|
111
|
+
VALUE rb_ident_hash_new(void);
|
|
112
|
+
int rb_hash_stlike_foreach(VALUE hash, st_foreach_callback_func *func, st_data_t arg);
|
|
113
|
+
int rb_hash_stlike_foreach_with_replace(VALUE hash, st_foreach_check_callback_func *func, st_update_callback_func *replace, st_data_t arg);
|
|
114
|
+
RUBY_SYMBOL_EXPORT_END
|
|
115
|
+
|
|
116
|
+
VALUE rb_hash_new_with_bulk_insert(rb_len_t argc, const VALUE *argv);
|
|
117
|
+
VALUE rb_hash_merge2(VALUE h1, VALUE h2, bool dup);
|
|
118
|
+
VALUE rb_hash_merge2_bulk(VALUE hash, rb_len_t argc, const VALUE *argv, bool dup);
|
|
119
|
+
VALUE rb_hash_resurrect(VALUE hash);
|
|
120
|
+
int rb_hash_stlike_lookup(VALUE hash, st_data_t key, st_data_t *pval);
|
|
121
|
+
VALUE rb_hash_keys(VALUE hash);
|
|
122
|
+
VALUE rb_hash_has_key(VALUE hash, VALUE key);
|
|
123
|
+
VALUE rb_hash_compare_by_id_p(VALUE hash);
|
|
124
|
+
|
|
125
|
+
st_table *rb_hash_tbl_raw(VALUE hash);
|
|
126
|
+
|
|
127
|
+
VALUE rb_hash_compare_by_id(VALUE hash);
|
|
128
|
+
|
|
129
|
+
static inline bool
|
|
130
|
+
RHASH_AR_TABLE_P(VALUE h)
|
|
131
|
+
{
|
|
132
|
+
return ! FL_TEST_RAW(h, RHASH_ST_TABLE_FLAG);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
RBIMPL_ATTR_RETURNS_NONNULL()
|
|
136
|
+
static inline struct ar_table_struct *
|
|
137
|
+
RHASH_AR_TABLE(VALUE h)
|
|
138
|
+
{
|
|
139
|
+
return (struct ar_table_struct *)((uintptr_t)h + sizeof(struct RHash));
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
RBIMPL_ATTR_RETURNS_NONNULL()
|
|
143
|
+
static inline st_table *
|
|
144
|
+
RHASH_ST_TABLE(VALUE h)
|
|
145
|
+
{
|
|
146
|
+
return (st_table *)((uintptr_t)h + sizeof(struct RHash));
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
static inline VALUE
|
|
150
|
+
RHASH_IFNONE(VALUE h)
|
|
151
|
+
{
|
|
152
|
+
return RHASH(h)->ifnone;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
static inline size_t
|
|
156
|
+
RHASH_SIZE(VALUE h)
|
|
157
|
+
{
|
|
158
|
+
if (RHASH_AR_TABLE_P(h)) {
|
|
159
|
+
return RHASH_AR_TABLE_SIZE_RAW(h);
|
|
160
|
+
}
|
|
161
|
+
else {
|
|
162
|
+
return RHASH_ST_SIZE(h);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
static inline bool
|
|
167
|
+
RHASH_EMPTY_P(VALUE h)
|
|
168
|
+
{
|
|
169
|
+
return RHASH_SIZE(h) == 0;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
static inline bool
|
|
173
|
+
RHASH_ST_TABLE_P(VALUE h)
|
|
174
|
+
{
|
|
175
|
+
return ! RHASH_AR_TABLE_P(h);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
static inline size_t
|
|
179
|
+
RHASH_ST_SIZE(VALUE h)
|
|
180
|
+
{
|
|
181
|
+
return RHASH_ST_TABLE(h)->num_entries;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
static inline void
|
|
185
|
+
RHASH_ST_CLEAR(VALUE h)
|
|
186
|
+
{
|
|
187
|
+
memset(RHASH_ST_TABLE(h), 0, sizeof(st_table));
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
static inline unsigned
|
|
191
|
+
RHASH_AR_TABLE_SIZE_RAW(VALUE h)
|
|
192
|
+
{
|
|
193
|
+
VALUE ret = FL_TEST_RAW(h, RHASH_AR_TABLE_SIZE_MASK);
|
|
194
|
+
ret >>= RHASH_AR_TABLE_SIZE_SHIFT;
|
|
195
|
+
return (unsigned)ret;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
#define RHASH_AR_TABLE_BOUND_RAW(h) \
|
|
199
|
+
((unsigned int)((RBASIC(h)->flags >> RHASH_AR_TABLE_BOUND_SHIFT) & \
|
|
200
|
+
(RHASH_AR_TABLE_BOUND_MASK >> RHASH_AR_TABLE_BOUND_SHIFT)))
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
static inline unsigned int
|
|
204
|
+
RHASH_AR_TABLE_BOUND(VALUE h)
|
|
205
|
+
{
|
|
206
|
+
RUBY_ASSERT(RHASH_AR_TABLE_P(h));
|
|
207
|
+
const unsigned int bound = RHASH_AR_TABLE_BOUND_RAW(h);
|
|
208
|
+
RBIMPL_ASSERT_OR_ASSUME(bound <= RHASH_AR_TABLE_MAX_SIZE);
|
|
209
|
+
return bound;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
#define RHASH_ST_SLOT_SIZE (sizeof(struct RHash) + sizeof(st_table))
|
|
213
|
+
|
|
214
|
+
static inline size_t
|
|
215
|
+
RHASH_AR_SLOT_SIZE(size_t capa)
|
|
216
|
+
{
|
|
217
|
+
return sizeof(struct RHash) + offsetof(ar_table, pairs) + capa * sizeof(ar_table_pair);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
#endif /* INTERNAL_HASH_H */
|