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,361 @@
|
|
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 "vm_core.h" /* for GET_EC() */
|
18
|
+
|
19
|
+
#if defined(__x86_64__) && !defined(_ILP32) && defined(__GNUC__)
|
20
|
+
#define SET_MACHINE_STACK_END(p) __asm__ __volatile__ ("movq\t%%rsp, %0" : "=r" (*(p)))
|
21
|
+
#elif defined(__i386) && defined(__GNUC__)
|
22
|
+
#define SET_MACHINE_STACK_END(p) __asm__ __volatile__ ("movl\t%%esp, %0" : "=r" (*(p)))
|
23
|
+
#elif (defined(__powerpc__) || defined(__powerpc64__)) && defined(__GNUC__) && !defined(_AIX) && !defined(__APPLE__) // Not Apple is NEEDED to unbreak ppc64 build on Darwin. Don't ask.
|
24
|
+
#define SET_MACHINE_STACK_END(p) __asm__ __volatile__ ("mr\t%0, %%r1" : "=r" (*(p)))
|
25
|
+
#elif (defined(__powerpc__) || defined(__powerpc64__)) && defined(__GNUC__) && defined(_AIX)
|
26
|
+
#define SET_MACHINE_STACK_END(p) __asm__ __volatile__ ("mr %0,1" : "=r" (*(p)))
|
27
|
+
#elif defined(__POWERPC__) && defined(__APPLE__) // Darwin ppc and ppc64
|
28
|
+
#define SET_MACHINE_STACK_END(p) __asm__ volatile("mr %0, r1" : "=r" (*(p)))
|
29
|
+
#elif defined(__aarch64__) && defined(__GNUC__)
|
30
|
+
#define SET_MACHINE_STACK_END(p) __asm__ __volatile__ ("mov\t%0, sp" : "=r" (*(p)))
|
31
|
+
#else
|
32
|
+
NOINLINE(void rb_gc_set_stack_end(VALUE **stack_end_p));
|
33
|
+
#define SET_MACHINE_STACK_END(p) rb_gc_set_stack_end(p)
|
34
|
+
#define USE_CONSERVATIVE_STACK_END
|
35
|
+
#endif
|
36
|
+
|
37
|
+
/* for GC debug */
|
38
|
+
|
39
|
+
#ifndef RUBY_MARK_FREE_DEBUG
|
40
|
+
#define RUBY_MARK_FREE_DEBUG 0
|
41
|
+
#endif
|
42
|
+
|
43
|
+
#if RUBY_MARK_FREE_DEBUG
|
44
|
+
extern int ruby_gc_debug_indent;
|
45
|
+
|
46
|
+
static inline void
|
47
|
+
rb_gc_debug_indent(void)
|
48
|
+
{
|
49
|
+
ruby_debug_printf("%*s", ruby_gc_debug_indent, "");
|
50
|
+
}
|
51
|
+
|
52
|
+
static inline void
|
53
|
+
rb_gc_debug_body(const char *mode, const char *msg, int st, void *ptr)
|
54
|
+
{
|
55
|
+
if (st == 0) {
|
56
|
+
ruby_gc_debug_indent--;
|
57
|
+
}
|
58
|
+
rb_gc_debug_indent();
|
59
|
+
ruby_debug_printf("%s: %s %s (%p)\n", mode, st ? "->" : "<-", msg, ptr);
|
60
|
+
|
61
|
+
if (st) {
|
62
|
+
ruby_gc_debug_indent++;
|
63
|
+
}
|
64
|
+
|
65
|
+
fflush(stdout);
|
66
|
+
}
|
67
|
+
|
68
|
+
#define RUBY_MARK_ENTER(msg) rb_gc_debug_body("mark", (msg), 1, ptr)
|
69
|
+
#define RUBY_MARK_LEAVE(msg) rb_gc_debug_body("mark", (msg), 0, ptr)
|
70
|
+
#define RUBY_FREE_ENTER(msg) rb_gc_debug_body("free", (msg), 1, ptr)
|
71
|
+
#define RUBY_FREE_LEAVE(msg) rb_gc_debug_body("free", (msg), 0, ptr)
|
72
|
+
#define RUBY_GC_INFO rb_gc_debug_indent(), ruby_debug_printf
|
73
|
+
|
74
|
+
#else
|
75
|
+
#define RUBY_MARK_ENTER(msg)
|
76
|
+
#define RUBY_MARK_LEAVE(msg)
|
77
|
+
#define RUBY_FREE_ENTER(msg)
|
78
|
+
#define RUBY_FREE_LEAVE(msg)
|
79
|
+
#define RUBY_GC_INFO if(0)printf
|
80
|
+
#endif
|
81
|
+
|
82
|
+
#define RUBY_MARK_MOVABLE_UNLESS_NULL(ptr) do { \
|
83
|
+
VALUE markobj = (ptr); \
|
84
|
+
if (RTEST(markobj)) {rb_gc_mark_movable(markobj);} \
|
85
|
+
} while (0)
|
86
|
+
#define RUBY_MARK_UNLESS_NULL(ptr) do { \
|
87
|
+
VALUE markobj = (ptr); \
|
88
|
+
if (RTEST(markobj)) {rb_gc_mark(markobj);} \
|
89
|
+
} while (0)
|
90
|
+
#define RUBY_FREE_UNLESS_NULL(ptr) if(ptr){ruby_xfree(ptr);(ptr)=NULL;}
|
91
|
+
|
92
|
+
#if STACK_GROW_DIRECTION > 0
|
93
|
+
# define STACK_UPPER(x, a, b) (a)
|
94
|
+
#elif STACK_GROW_DIRECTION < 0
|
95
|
+
# define STACK_UPPER(x, a, b) (b)
|
96
|
+
#else
|
97
|
+
RUBY_EXTERN int ruby_stack_grow_direction;
|
98
|
+
int ruby_get_stack_grow_direction(volatile VALUE *addr);
|
99
|
+
# define stack_growup_p(x) ( \
|
100
|
+
(ruby_stack_grow_direction ? \
|
101
|
+
ruby_stack_grow_direction : \
|
102
|
+
ruby_get_stack_grow_direction(x)) > 0)
|
103
|
+
# define STACK_UPPER(x, a, b) (stack_growup_p(x) ? (a) : (b))
|
104
|
+
#endif
|
105
|
+
|
106
|
+
/*
|
107
|
+
STACK_GROW_DIR_DETECTION is used with STACK_DIR_UPPER.
|
108
|
+
|
109
|
+
On most normal systems, stacks grow from high address to lower address. In
|
110
|
+
this case, STACK_DIR_UPPER(a, b) will return (b), but on exotic systems where
|
111
|
+
the stack grows UP (from low address to high address), it will return (a).
|
112
|
+
*/
|
113
|
+
|
114
|
+
#if STACK_GROW_DIRECTION
|
115
|
+
#define STACK_GROW_DIR_DETECTION
|
116
|
+
#define STACK_DIR_UPPER(a,b) STACK_UPPER(0, (a), (b))
|
117
|
+
#else
|
118
|
+
#define STACK_GROW_DIR_DETECTION VALUE stack_grow_dir_detection
|
119
|
+
#define STACK_DIR_UPPER(a,b) STACK_UPPER(&stack_grow_dir_detection, (a), (b))
|
120
|
+
#endif
|
121
|
+
#define IS_STACK_DIR_UPPER() STACK_DIR_UPPER(1,0)
|
122
|
+
|
123
|
+
const char *rb_obj_info(VALUE obj);
|
124
|
+
const char *rb_raw_obj_info(char *const buff, const size_t buff_size, VALUE obj);
|
125
|
+
|
126
|
+
size_t rb_size_pool_slot_size(unsigned char pool_id);
|
127
|
+
|
128
|
+
struct rb_execution_context_struct; /* in vm_core.h */
|
129
|
+
struct rb_objspace; /* in vm_core.h */
|
130
|
+
|
131
|
+
#ifdef NEWOBJ_OF
|
132
|
+
# undef NEWOBJ_OF
|
133
|
+
# undef RB_NEWOBJ_OF
|
134
|
+
#endif
|
135
|
+
|
136
|
+
#define NEWOBJ_OF_0(var, T, c, f, s, ec) \
|
137
|
+
T *(var) = (T *)(((f) & FL_WB_PROTECTED) ? \
|
138
|
+
rb_wb_protected_newobj_of(GET_EC(), (c), (f) & ~FL_WB_PROTECTED, s) : \
|
139
|
+
rb_wb_unprotected_newobj_of((c), (f), s))
|
140
|
+
#define NEWOBJ_OF_ec(var, T, c, f, s, ec) \
|
141
|
+
T *(var) = (T *)(((f) & FL_WB_PROTECTED) ? \
|
142
|
+
rb_wb_protected_newobj_of((ec), (c), (f) & ~FL_WB_PROTECTED, s) : \
|
143
|
+
rb_wb_unprotected_newobj_of((c), (f), s))
|
144
|
+
|
145
|
+
#define NEWOBJ_OF(var, T, c, f, s, ec) \
|
146
|
+
NEWOBJ_OF_HELPER(ec)(var, T, c, f, s, ec)
|
147
|
+
|
148
|
+
#define NEWOBJ_OF_HELPER(ec) NEWOBJ_OF_ ## ec
|
149
|
+
|
150
|
+
#define RB_OBJ_GC_FLAGS_MAX 6 /* used in ext/objspace */
|
151
|
+
|
152
|
+
#ifndef USE_UNALIGNED_MEMBER_ACCESS
|
153
|
+
# define UNALIGNED_MEMBER_ACCESS(expr) (expr)
|
154
|
+
#elif ! USE_UNALIGNED_MEMBER_ACCESS
|
155
|
+
# define UNALIGNED_MEMBER_ACCESS(expr) (expr)
|
156
|
+
#elif ! (__has_warning("-Waddress-of-packed-member") || GCC_VERSION_SINCE(9, 0, 0))
|
157
|
+
# define UNALIGNED_MEMBER_ACCESS(expr) (expr)
|
158
|
+
#else
|
159
|
+
# include "internal/warnings.h"
|
160
|
+
# define UNALIGNED_MEMBER_ACCESS(expr) __extension__({ \
|
161
|
+
COMPILER_WARNING_PUSH; \
|
162
|
+
COMPILER_WARNING_IGNORED(-Waddress-of-packed-member); \
|
163
|
+
__typeof__(expr) unaligned_member_access_result = (expr); \
|
164
|
+
COMPILER_WARNING_POP; \
|
165
|
+
unaligned_member_access_result; \
|
166
|
+
})
|
167
|
+
|
168
|
+
# define UNALIGNED_MEMBER_PTR(ptr, mem) __extension__({ \
|
169
|
+
COMPILER_WARNING_PUSH; \
|
170
|
+
COMPILER_WARNING_IGNORED(-Waddress-of-packed-member); \
|
171
|
+
const volatile void *unaligned_member_ptr_result = &(ptr)->mem; \
|
172
|
+
COMPILER_WARNING_POP; \
|
173
|
+
(__typeof__((ptr)->mem) *)unaligned_member_ptr_result; \
|
174
|
+
})
|
175
|
+
#endif
|
176
|
+
|
177
|
+
#ifndef UNALIGNED_MEMBER_PTR
|
178
|
+
# define UNALIGNED_MEMBER_PTR(ptr, mem) UNALIGNED_MEMBER_ACCESS(&(ptr)->mem)
|
179
|
+
#endif
|
180
|
+
|
181
|
+
#define RB_OBJ_WRITE_UNALIGNED(old, slot, young) do { \
|
182
|
+
VALUE *_slot = UNALIGNED_MEMBER_ACCESS(slot); \
|
183
|
+
RB_OBJ_WRITE(old, _slot, young); \
|
184
|
+
} while (0)
|
185
|
+
|
186
|
+
// We use SIZE_POOL_COUNT number of shape IDs for transitions out of different size pools
|
187
|
+
// The next available shape ID will be the SPECIAL_CONST_SHAPE_ID
|
188
|
+
#ifndef SIZE_POOL_COUNT
|
189
|
+
# define SIZE_POOL_COUNT 5
|
190
|
+
#endif
|
191
|
+
|
192
|
+
/* Used in places that could malloc during, which can cause the GC to run. We
|
193
|
+
* need to temporarily disable the GC to allow the malloc to happen.
|
194
|
+
* Allocating memory during GC is a bad idea, so use this only when absolutely
|
195
|
+
* necessary. */
|
196
|
+
#define DURING_GC_COULD_MALLOC_REGION_START() \
|
197
|
+
assert(rb_during_gc()); \
|
198
|
+
VALUE _already_disabled = rb_gc_disable_no_rest()
|
199
|
+
|
200
|
+
#define DURING_GC_COULD_MALLOC_REGION_END() \
|
201
|
+
if (_already_disabled == Qfalse) rb_gc_enable()
|
202
|
+
|
203
|
+
typedef struct ractor_newobj_size_pool_cache {
|
204
|
+
struct RVALUE *freelist;
|
205
|
+
struct heap_page *using_page;
|
206
|
+
} rb_ractor_newobj_size_pool_cache_t;
|
207
|
+
|
208
|
+
typedef struct ractor_newobj_cache {
|
209
|
+
size_t incremental_mark_step_allocated_slots;
|
210
|
+
rb_ractor_newobj_size_pool_cache_t size_pool_caches[SIZE_POOL_COUNT];
|
211
|
+
} rb_ractor_newobj_cache_t;
|
212
|
+
|
213
|
+
/* gc.c */
|
214
|
+
extern VALUE *ruby_initial_gc_stress_ptr;
|
215
|
+
extern int ruby_disable_gc;
|
216
|
+
RUBY_ATTR_MALLOC void *ruby_mimmalloc(size_t size);
|
217
|
+
void ruby_mimfree(void *ptr);
|
218
|
+
void rb_gc_prepare_heap(void);
|
219
|
+
void rb_objspace_set_event_hook(const rb_event_flag_t event);
|
220
|
+
VALUE rb_objspace_gc_enable(struct rb_objspace *);
|
221
|
+
VALUE rb_objspace_gc_disable(struct rb_objspace *);
|
222
|
+
void ruby_gc_set_params(void);
|
223
|
+
void rb_copy_wb_protected_attribute(VALUE dest, VALUE obj);
|
224
|
+
#if __has_attribute(alloc_align)
|
225
|
+
__attribute__((__alloc_align__(1)))
|
226
|
+
#endif
|
227
|
+
RUBY_ATTR_MALLOC void *rb_aligned_malloc(size_t, size_t) RUBY_ATTR_ALLOC_SIZE((2));
|
228
|
+
size_t rb_size_mul_or_raise(size_t, size_t, VALUE); /* used in compile.c */
|
229
|
+
size_t rb_size_mul_add_or_raise(size_t, size_t, size_t, VALUE); /* used in iseq.h */
|
230
|
+
RUBY_ATTR_MALLOC void *rb_xmalloc_mul_add(size_t, size_t, size_t);
|
231
|
+
RUBY_ATTR_MALLOC void *rb_xcalloc_mul_add(size_t, size_t, size_t);
|
232
|
+
void *rb_xrealloc_mul_add(const void *, size_t, size_t, size_t);
|
233
|
+
RUBY_ATTR_MALLOC void *rb_xmalloc_mul_add_mul(size_t, size_t, size_t, size_t);
|
234
|
+
RUBY_ATTR_MALLOC void *rb_xcalloc_mul_add_mul(size_t, size_t, size_t, size_t);
|
235
|
+
static inline void *ruby_sized_xrealloc_inlined(void *ptr, size_t new_size, size_t old_size) RUBY_ATTR_RETURNS_NONNULL RUBY_ATTR_ALLOC_SIZE((2));
|
236
|
+
static inline void *ruby_sized_xrealloc2_inlined(void *ptr, size_t new_count, size_t elemsiz, size_t old_count) RUBY_ATTR_RETURNS_NONNULL RUBY_ATTR_ALLOC_SIZE((2, 3));
|
237
|
+
static inline void ruby_sized_xfree_inlined(void *ptr, size_t size);
|
238
|
+
VALUE rb_class_allocate_instance(VALUE klass);
|
239
|
+
void rb_gc_ractor_newobj_cache_clear(rb_ractor_newobj_cache_t *newobj_cache);
|
240
|
+
size_t rb_gc_obj_slot_size(VALUE obj);
|
241
|
+
bool rb_gc_size_allocatable_p(size_t size);
|
242
|
+
int rb_objspace_garbage_object_p(VALUE obj);
|
243
|
+
bool rb_gc_is_ptr_to_obj(void *ptr);
|
244
|
+
VALUE rb_gc_id2ref_obj_tbl(VALUE objid);
|
245
|
+
VALUE rb_define_finalizer_no_check(VALUE obj, VALUE block);
|
246
|
+
|
247
|
+
void rb_gc_mark_and_move(VALUE *ptr);
|
248
|
+
|
249
|
+
void rb_gc_mark_weak(VALUE *ptr);
|
250
|
+
void rb_gc_remove_weak(VALUE parent_obj, VALUE *ptr);
|
251
|
+
|
252
|
+
#define rb_gc_mark_and_move_ptr(ptr) do { \
|
253
|
+
VALUE _obj = (VALUE)*(ptr); \
|
254
|
+
rb_gc_mark_and_move(&_obj); \
|
255
|
+
if (_obj != (VALUE)*(ptr)) *(ptr) = (void *)_obj; \
|
256
|
+
} while (0)
|
257
|
+
|
258
|
+
RUBY_SYMBOL_EXPORT_BEGIN
|
259
|
+
/* exports for objspace module */
|
260
|
+
size_t rb_objspace_data_type_memsize(VALUE obj);
|
261
|
+
void rb_objspace_reachable_objects_from(VALUE obj, void (func)(VALUE, void *), void *data);
|
262
|
+
void rb_objspace_reachable_objects_from_root(void (func)(const char *category, VALUE, void *), void *data);
|
263
|
+
int rb_objspace_markable_object_p(VALUE obj);
|
264
|
+
int rb_objspace_internal_object_p(VALUE obj);
|
265
|
+
int rb_objspace_marked_object_p(VALUE obj);
|
266
|
+
|
267
|
+
void rb_objspace_each_objects(
|
268
|
+
int (*callback)(void *start, void *end, size_t stride, void *data),
|
269
|
+
void *data);
|
270
|
+
|
271
|
+
void rb_objspace_each_objects_without_setup(
|
272
|
+
int (*callback)(void *, void *, size_t, void *),
|
273
|
+
void *data);
|
274
|
+
|
275
|
+
size_t rb_gc_obj_slot_size(VALUE obj);
|
276
|
+
|
277
|
+
VALUE rb_gc_disable_no_rest(void);
|
278
|
+
|
279
|
+
|
280
|
+
/* gc.c (export) */
|
281
|
+
const char *rb_objspace_data_type_name(VALUE obj);
|
282
|
+
VALUE rb_wb_protected_newobj_of(struct rb_execution_context_struct *, VALUE, VALUE, size_t);
|
283
|
+
VALUE rb_wb_unprotected_newobj_of(VALUE, VALUE, size_t);
|
284
|
+
size_t rb_obj_memsize_of(VALUE);
|
285
|
+
void rb_gc_verify_internal_consistency(void);
|
286
|
+
size_t rb_obj_gc_flags(VALUE, ID[], size_t);
|
287
|
+
void rb_gc_mark_values(long n, const VALUE *values);
|
288
|
+
void rb_gc_mark_vm_stack_values(long n, const VALUE *values);
|
289
|
+
void rb_gc_update_values(long n, VALUE *values);
|
290
|
+
void *ruby_sized_xrealloc(void *ptr, size_t new_size, size_t old_size) RUBY_ATTR_RETURNS_NONNULL RUBY_ATTR_ALLOC_SIZE((2));
|
291
|
+
void *ruby_sized_xrealloc2(void *ptr, size_t new_count, size_t element_size, size_t old_count) RUBY_ATTR_RETURNS_NONNULL RUBY_ATTR_ALLOC_SIZE((2, 3));
|
292
|
+
void ruby_sized_xfree(void *x, size_t size);
|
293
|
+
RUBY_SYMBOL_EXPORT_END
|
294
|
+
|
295
|
+
int rb_ec_stack_check(struct rb_execution_context_struct *ec);
|
296
|
+
void rb_gc_writebarrier_remember(VALUE obj);
|
297
|
+
const char *rb_obj_info(VALUE obj);
|
298
|
+
|
299
|
+
#if defined(HAVE_MALLOC_USABLE_SIZE) || defined(HAVE_MALLOC_SIZE) || defined(_WIN32)
|
300
|
+
|
301
|
+
static inline void *
|
302
|
+
ruby_sized_xrealloc_inlined(void *ptr, size_t new_size, size_t old_size)
|
303
|
+
{
|
304
|
+
return ruby_xrealloc(ptr, new_size);
|
305
|
+
}
|
306
|
+
|
307
|
+
static inline void *
|
308
|
+
ruby_sized_xrealloc2_inlined(void *ptr, size_t new_count, size_t elemsiz, size_t old_count)
|
309
|
+
{
|
310
|
+
return ruby_xrealloc2(ptr, new_count, elemsiz);
|
311
|
+
}
|
312
|
+
|
313
|
+
static inline void
|
314
|
+
ruby_sized_xfree_inlined(void *ptr, size_t size)
|
315
|
+
{
|
316
|
+
ruby_xfree(ptr);
|
317
|
+
}
|
318
|
+
|
319
|
+
# define SIZED_REALLOC_N(x, y, z, w) REALLOC_N(x, y, z)
|
320
|
+
|
321
|
+
static inline void *
|
322
|
+
ruby_sized_realloc_n(void *ptr, size_t new_count, size_t element_size, size_t old_count)
|
323
|
+
{
|
324
|
+
return ruby_xrealloc2(ptr, new_count, element_size);
|
325
|
+
}
|
326
|
+
|
327
|
+
#else
|
328
|
+
|
329
|
+
static inline void *
|
330
|
+
ruby_sized_xrealloc_inlined(void *ptr, size_t new_size, size_t old_size)
|
331
|
+
{
|
332
|
+
return ruby_sized_xrealloc(ptr, new_size, old_size);
|
333
|
+
}
|
334
|
+
|
335
|
+
static inline void *
|
336
|
+
ruby_sized_xrealloc2_inlined(void *ptr, size_t new_count, size_t elemsiz, size_t old_count)
|
337
|
+
{
|
338
|
+
return ruby_sized_xrealloc2(ptr, new_count, elemsiz, old_count);
|
339
|
+
}
|
340
|
+
|
341
|
+
static inline void
|
342
|
+
ruby_sized_xfree_inlined(void *ptr, size_t size)
|
343
|
+
{
|
344
|
+
ruby_sized_xfree(ptr, size);
|
345
|
+
}
|
346
|
+
|
347
|
+
# define SIZED_REALLOC_N(v, T, m, n) \
|
348
|
+
((v) = (T *)ruby_sized_xrealloc2((void *)(v), (m), sizeof(T), (n)))
|
349
|
+
|
350
|
+
static inline void *
|
351
|
+
ruby_sized_realloc_n(void *ptr, size_t new_count, size_t element_size, size_t old_count)
|
352
|
+
{
|
353
|
+
return ruby_sized_xrealloc2(ptr, new_count, element_size, old_count);
|
354
|
+
}
|
355
|
+
|
356
|
+
#endif /* HAVE_MALLOC_USABLE_SIZE */
|
357
|
+
|
358
|
+
#define ruby_sized_xrealloc ruby_sized_xrealloc_inlined
|
359
|
+
#define ruby_sized_xrealloc2 ruby_sized_xrealloc2_inlined
|
360
|
+
#define ruby_sized_xfree ruby_sized_xfree_inlined
|
361
|
+
#endif /* INTERNAL_GC_H */
|
@@ -0,0 +1,190 @@
|
|
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
|
+
|
31
|
+
// we can not put it in "enum" because it can exceed "int" range.
|
32
|
+
#define RHASH_LEV_MASK (FL_USER13 | FL_USER14 | FL_USER15 | /* FL 13..19 */ \
|
33
|
+
FL_USER16 | FL_USER17 | FL_USER18 | FL_USER19)
|
34
|
+
|
35
|
+
RHASH_LEV_SHIFT = (FL_USHIFT + 13),
|
36
|
+
RHASH_LEV_MAX = 127, /* 7 bits */
|
37
|
+
};
|
38
|
+
|
39
|
+
typedef struct ar_table_pair_struct {
|
40
|
+
VALUE key;
|
41
|
+
VALUE val;
|
42
|
+
} ar_table_pair;
|
43
|
+
|
44
|
+
typedef struct ar_table_struct {
|
45
|
+
union {
|
46
|
+
ar_hint_t ary[RHASH_AR_TABLE_MAX_SIZE];
|
47
|
+
VALUE word;
|
48
|
+
} ar_hint;
|
49
|
+
/* 64bit CPU: 8B * 2 * 8 = 128B */
|
50
|
+
ar_table_pair pairs[RHASH_AR_TABLE_MAX_SIZE];
|
51
|
+
} ar_table;
|
52
|
+
|
53
|
+
struct RHash {
|
54
|
+
struct RBasic basic;
|
55
|
+
const VALUE ifnone;
|
56
|
+
};
|
57
|
+
|
58
|
+
#define RHASH(obj) ((struct RHash *)(obj))
|
59
|
+
|
60
|
+
#ifdef RHASH_IFNONE
|
61
|
+
# undef RHASH_IFNONE
|
62
|
+
#endif
|
63
|
+
|
64
|
+
#ifdef RHASH_SIZE
|
65
|
+
# undef RHASH_SIZE
|
66
|
+
#endif
|
67
|
+
|
68
|
+
#ifdef RHASH_EMPTY_P
|
69
|
+
# undef RHASH_EMPTY_P
|
70
|
+
#endif
|
71
|
+
|
72
|
+
/* hash.c */
|
73
|
+
void rb_hash_st_table_set(VALUE hash, st_table *st);
|
74
|
+
VALUE rb_hash_default_value(VALUE hash, VALUE key);
|
75
|
+
VALUE rb_hash_set_default_proc(VALUE hash, VALUE proc);
|
76
|
+
long rb_dbl_long_hash(double d);
|
77
|
+
st_table *rb_init_identtable(void);
|
78
|
+
st_index_t rb_any_hash(VALUE a);
|
79
|
+
int rb_any_cmp(VALUE a, VALUE b);
|
80
|
+
VALUE rb_to_hash_type(VALUE obj);
|
81
|
+
VALUE rb_hash_key_str(VALUE);
|
82
|
+
VALUE rb_hash_values(VALUE hash);
|
83
|
+
VALUE rb_hash_rehash(VALUE hash);
|
84
|
+
int rb_hash_add_new_element(VALUE hash, VALUE key, VALUE val);
|
85
|
+
VALUE rb_hash_set_pair(VALUE hash, VALUE pair);
|
86
|
+
int rb_hash_stlike_delete(VALUE hash, st_data_t *pkey, st_data_t *pval);
|
87
|
+
int rb_hash_stlike_foreach_with_replace(VALUE hash, st_foreach_check_callback_func *func, st_update_callback_func *replace, st_data_t arg);
|
88
|
+
int rb_hash_stlike_update(VALUE hash, st_data_t key, st_update_callback_func *func, st_data_t arg);
|
89
|
+
VALUE rb_ident_hash_new_with_size(st_index_t size);
|
90
|
+
|
91
|
+
static inline unsigned RHASH_AR_TABLE_SIZE_RAW(VALUE h);
|
92
|
+
static inline VALUE RHASH_IFNONE(VALUE h);
|
93
|
+
static inline size_t RHASH_SIZE(VALUE h);
|
94
|
+
static inline bool RHASH_EMPTY_P(VALUE h);
|
95
|
+
static inline bool RHASH_AR_TABLE_P(VALUE h);
|
96
|
+
static inline bool RHASH_ST_TABLE_P(VALUE h);
|
97
|
+
static inline struct ar_table_struct *RHASH_AR_TABLE(VALUE h);
|
98
|
+
static inline st_table *RHASH_ST_TABLE(VALUE h);
|
99
|
+
static inline size_t RHASH_ST_SIZE(VALUE h);
|
100
|
+
static inline void RHASH_ST_CLEAR(VALUE h);
|
101
|
+
|
102
|
+
RUBY_SYMBOL_EXPORT_BEGIN
|
103
|
+
/* hash.c (export) */
|
104
|
+
VALUE rb_hash_delete_entry(VALUE hash, VALUE key);
|
105
|
+
VALUE rb_ident_hash_new(void);
|
106
|
+
int rb_hash_stlike_foreach(VALUE hash, st_foreach_callback_func *func, st_data_t arg);
|
107
|
+
RUBY_SYMBOL_EXPORT_END
|
108
|
+
|
109
|
+
VALUE rb_hash_new_with_size(st_index_t size);
|
110
|
+
VALUE rb_hash_resurrect(VALUE hash);
|
111
|
+
int rb_hash_stlike_lookup(VALUE hash, st_data_t key, st_data_t *pval);
|
112
|
+
VALUE rb_hash_keys(VALUE hash);
|
113
|
+
VALUE rb_hash_has_key(VALUE hash, VALUE key);
|
114
|
+
VALUE rb_hash_compare_by_id_p(VALUE hash);
|
115
|
+
|
116
|
+
st_table *rb_hash_tbl_raw(VALUE hash, const char *file, int line);
|
117
|
+
#define RHASH_TBL_RAW(h) rb_hash_tbl_raw(h, __FILE__, __LINE__)
|
118
|
+
|
119
|
+
VALUE rb_hash_compare_by_id(VALUE hash);
|
120
|
+
|
121
|
+
static inline bool
|
122
|
+
RHASH_AR_TABLE_P(VALUE h)
|
123
|
+
{
|
124
|
+
return ! FL_TEST_RAW(h, RHASH_ST_TABLE_FLAG);
|
125
|
+
}
|
126
|
+
|
127
|
+
RBIMPL_ATTR_RETURNS_NONNULL()
|
128
|
+
static inline struct ar_table_struct *
|
129
|
+
RHASH_AR_TABLE(VALUE h)
|
130
|
+
{
|
131
|
+
return (struct ar_table_struct *)((uintptr_t)h + sizeof(struct RHash));
|
132
|
+
}
|
133
|
+
|
134
|
+
RBIMPL_ATTR_RETURNS_NONNULL()
|
135
|
+
static inline st_table *
|
136
|
+
RHASH_ST_TABLE(VALUE h)
|
137
|
+
{
|
138
|
+
return (st_table *)((uintptr_t)h + sizeof(struct RHash));
|
139
|
+
}
|
140
|
+
|
141
|
+
static inline VALUE
|
142
|
+
RHASH_IFNONE(VALUE h)
|
143
|
+
{
|
144
|
+
return RHASH(h)->ifnone;
|
145
|
+
}
|
146
|
+
|
147
|
+
static inline size_t
|
148
|
+
RHASH_SIZE(VALUE h)
|
149
|
+
{
|
150
|
+
if (RHASH_AR_TABLE_P(h)) {
|
151
|
+
return RHASH_AR_TABLE_SIZE_RAW(h);
|
152
|
+
}
|
153
|
+
else {
|
154
|
+
return RHASH_ST_SIZE(h);
|
155
|
+
}
|
156
|
+
}
|
157
|
+
|
158
|
+
static inline bool
|
159
|
+
RHASH_EMPTY_P(VALUE h)
|
160
|
+
{
|
161
|
+
return RHASH_SIZE(h) == 0;
|
162
|
+
}
|
163
|
+
|
164
|
+
static inline bool
|
165
|
+
RHASH_ST_TABLE_P(VALUE h)
|
166
|
+
{
|
167
|
+
return ! RHASH_AR_TABLE_P(h);
|
168
|
+
}
|
169
|
+
|
170
|
+
static inline size_t
|
171
|
+
RHASH_ST_SIZE(VALUE h)
|
172
|
+
{
|
173
|
+
return RHASH_ST_TABLE(h)->num_entries;
|
174
|
+
}
|
175
|
+
|
176
|
+
static inline void
|
177
|
+
RHASH_ST_CLEAR(VALUE h)
|
178
|
+
{
|
179
|
+
memset(RHASH_ST_TABLE(h), 0, sizeof(st_table));
|
180
|
+
}
|
181
|
+
|
182
|
+
static inline unsigned
|
183
|
+
RHASH_AR_TABLE_SIZE_RAW(VALUE h)
|
184
|
+
{
|
185
|
+
VALUE ret = FL_TEST_RAW(h, RHASH_AR_TABLE_SIZE_MASK);
|
186
|
+
ret >>= RHASH_AR_TABLE_SIZE_SHIFT;
|
187
|
+
return (unsigned)ret;
|
188
|
+
}
|
189
|
+
|
190
|
+
#endif /* INTERNAL_HASH_H */
|