debase-ruby_core_source 0.10.7 → 0.10.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +12 -0
- data/README.md +1 -1
- data/Rakefile +6 -3
- data/debase-ruby_core_source.gemspec +2 -1
- data/lib/debase/ruby_core_source.rb +0 -1
- data/lib/debase/ruby_core_source/{ruby-2.7.0-preview2 → ruby-2.7.0-p0}/addr2line.h +0 -0
- data/lib/debase/ruby_core_source/ruby-2.7.0-p0/builtin.h +78 -0
- data/lib/debase/ruby_core_source/{ruby-2.7.0-preview2 → ruby-2.7.0-p0}/ccan/build_assert/build_assert.h +0 -0
- data/lib/debase/ruby_core_source/{ruby-2.7.0-preview2 → ruby-2.7.0-p0}/ccan/check_type/check_type.h +0 -0
- data/lib/debase/ruby_core_source/{ruby-2.7.0-preview2 → ruby-2.7.0-p0}/ccan/container_of/container_of.h +0 -0
- data/lib/debase/ruby_core_source/{ruby-2.7.0-preview2 → ruby-2.7.0-p0}/ccan/list/list.h +0 -0
- data/lib/debase/ruby_core_source/{ruby-2.7.0-preview2 → ruby-2.7.0-p0}/ccan/str/str.h +0 -0
- data/lib/debase/ruby_core_source/{ruby-2.7.0-preview2 → ruby-2.7.0-p0}/constant.h +0 -4
- data/lib/debase/ruby_core_source/{ruby-2.7.0-preview2 → ruby-2.7.0-p0}/debug_counter.h +21 -9
- data/lib/debase/ruby_core_source/{ruby-2.7.0-preview2 → ruby-2.7.0-p0}/dln.h +0 -0
- data/lib/debase/ruby_core_source/{ruby-2.7.0-preview2 → ruby-2.7.0-p0}/encindex.h +0 -0
- data/lib/debase/ruby_core_source/{ruby-2.7.0-preview2 → ruby-2.7.0-p0}/eval_intern.h +1 -3
- data/lib/debase/ruby_core_source/{ruby-2.7.0-preview2 → ruby-2.7.0-p0}/gc.h +2 -0
- data/lib/debase/ruby_core_source/{ruby-2.7.0-preview2 → ruby-2.7.0-p0}/hrtime.h +0 -0
- data/lib/debase/ruby_core_source/{ruby-2.7.0-preview2 → ruby-2.7.0-p0}/id.h +1 -3
- data/lib/debase/ruby_core_source/{ruby-2.7.0-preview2 → ruby-2.7.0-p0}/id_table.h +0 -0
- data/lib/debase/ruby_core_source/{ruby-2.7.0-preview2 → ruby-2.7.0-p0}/insns.inc +6 -2
- data/lib/debase/ruby_core_source/{ruby-2.7.0-preview2 → ruby-2.7.0-p0}/insns_info.inc +1471 -1888
- data/lib/debase/ruby_core_source/{ruby-2.7.0-preview2 → ruby-2.7.0-p0}/internal.h +106 -91
- data/lib/debase/ruby_core_source/{ruby-2.7.0-preview2 → ruby-2.7.0-p0}/iseq.h +5 -5
- data/lib/debase/ruby_core_source/{ruby-2.7.0-preview2 → ruby-2.7.0-p0}/known_errors.inc +0 -0
- data/lib/debase/ruby_core_source/{ruby-2.7.0-preview2 → ruby-2.7.0-p0}/method.h +1 -4
- data/lib/debase/ruby_core_source/{ruby-2.7.0-preview2 → ruby-2.7.0-p0}/mjit.h +3 -5
- data/lib/debase/ruby_core_source/{ruby-2.7.0-preview2 → ruby-2.7.0-p0}/mjit_compile.inc +768 -872
- data/lib/debase/ruby_core_source/{ruby-2.7.0-preview2 → ruby-2.7.0-p0}/node.h +4 -11
- data/lib/debase/ruby_core_source/{ruby-2.7.0-preview2 → ruby-2.7.0-p0}/node_name.inc +0 -2
- data/lib/debase/ruby_core_source/ruby-2.7.0-p0/opt_sc.inc +109 -0
- data/lib/debase/ruby_core_source/{ruby-2.7.0-preview2 → ruby-2.7.0-p0}/optinsn.inc +0 -0
- data/lib/debase/ruby_core_source/ruby-2.7.0-p0/optunifs.inc +43 -0
- data/lib/debase/ruby_core_source/{ruby-2.7.0-preview2 → ruby-2.7.0-p0}/parse.h +1 -1
- data/lib/debase/ruby_core_source/{ruby-2.7.0-preview2 → ruby-2.7.0-p0}/probes_helper.h +0 -0
- data/lib/debase/ruby_core_source/{ruby-2.7.0-preview2 → ruby-2.7.0-p0}/regenc.h +0 -0
- data/lib/debase/ruby_core_source/{ruby-2.7.0-preview2 → ruby-2.7.0-p0}/regint.h +0 -0
- data/lib/debase/ruby_core_source/{ruby-2.7.0-preview2 → ruby-2.7.0-p0}/regparse.h +0 -0
- data/lib/debase/ruby_core_source/ruby-2.7.0-p0/revision.h +2 -0
- data/lib/debase/ruby_core_source/{ruby-2.7.0-preview2 → ruby-2.7.0-p0}/ruby_assert.h +0 -0
- data/lib/debase/ruby_core_source/{ruby-2.7.0-preview2 → ruby-2.7.0-p0}/ruby_atomic.h +0 -0
- data/lib/debase/ruby_core_source/{ruby-2.7.0-preview2 → ruby-2.7.0-p0}/siphash.h +0 -0
- data/lib/debase/ruby_core_source/{ruby-2.7.0-preview2 → ruby-2.7.0-p0}/symbol.h +0 -0
- data/lib/debase/ruby_core_source/{ruby-2.7.0-preview2 → ruby-2.7.0-p0}/thread_pthread.h +0 -0
- data/lib/debase/ruby_core_source/{ruby-2.7.0-preview2 → ruby-2.7.0-p0}/thread_win32.h +0 -0
- data/lib/debase/ruby_core_source/{ruby-2.7.0-preview2 → ruby-2.7.0-p0}/timev.h +0 -0
- data/lib/debase/ruby_core_source/{ruby-2.7.0-preview2 → ruby-2.7.0-p0}/transcode_data.h +0 -0
- data/lib/debase/ruby_core_source/{ruby-2.7.0-preview2 → ruby-2.7.0-p0}/transient_heap.h +0 -0
- data/lib/debase/ruby_core_source/ruby-2.7.0-p0/variable.h +9 -0
- data/lib/debase/ruby_core_source/{ruby-2.7.0-preview2 → ruby-2.7.0-p0}/version.h +4 -4
- data/lib/debase/ruby_core_source/{ruby-2.7.0-preview2 → ruby-2.7.0-p0}/vm.inc +604 -407
- data/lib/debase/ruby_core_source/{ruby-2.7.0-preview2 → ruby-2.7.0-p0}/vm_call_iseq_optimized.inc +49 -49
- data/lib/debase/ruby_core_source/{ruby-2.7.0-preview2 → ruby-2.7.0-p0}/vm_core.h +42 -29
- data/lib/debase/ruby_core_source/{ruby-2.7.0-preview2 → ruby-2.7.0-p0}/vm_debug.h +0 -0
- data/lib/debase/ruby_core_source/{ruby-2.7.0-preview2 → ruby-2.7.0-p0}/vm_exec.h +0 -0
- data/lib/debase/ruby_core_source/{ruby-2.7.0-preview2 → ruby-2.7.0-p0}/vm_insnhelper.h +16 -4
- data/lib/debase/ruby_core_source/{ruby-2.7.0-preview2 → ruby-2.7.0-p0}/vm_opts.h +2 -0
- data/lib/debase/ruby_core_source/{ruby-2.7.0-preview2 → ruby-2.7.0-p0}/vmtc.inc +6 -2
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/addr2line.h +20 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/builtin.h +83 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/ccan/build_assert/build_assert.h +40 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/ccan/check_type/check_type.h +63 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/ccan/container_of/container_of.h +142 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/ccan/list/list.h +788 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/ccan/str/str.h +16 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/constant.h +55 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/debug_counter.h +457 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/dln.h +36 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/encindex.h +70 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/eval_intern.h +323 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/gc.h +140 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/hrtime.h +168 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/id.h +290 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/id_table.h +36 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/insns.inc +249 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/insns_info.inc +8983 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/internal.h +107 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/internal/array.h +119 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/internal/bignum.h +246 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/internal/bits.h +566 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/internal/class.h +174 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/internal/compar.h +50 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/internal/compile.h +32 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/internal/compilers.h +108 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/internal/complex.h +29 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/internal/cont.h +25 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/internal/dir.h +17 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/internal/enc.h +20 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/internal/encoding.h +28 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/internal/enum.h +19 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/internal/enumerator.h +22 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/internal/error.h +124 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/internal/eval.h +33 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/internal/file.h +39 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/internal/fixnum.h +185 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/internal/gc.h +161 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/internal/hash.h +241 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/internal/imemo.h +243 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/internal/inits.h +51 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/internal/io.h +35 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/internal/load.h +19 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/internal/loadpath.h +17 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/internal/math.h +24 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/internal/missing.h +19 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/internal/numeric.h +255 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/internal/object.h +83 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/internal/parse.h +23 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/internal/proc.h +33 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/internal/process.h +136 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/internal/random.h +17 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/internal/range.h +41 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/internal/rational.h +71 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/internal/re.h +29 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/internal/sanitizers.h +191 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/internal/scheduler.h +44 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/internal/serial.h +24 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/internal/signal.h +22 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/internal/static_assert.h +17 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/internal/string.h +140 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/internal/struct.h +154 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/internal/symbol.h +41 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/internal/thread.h +54 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/internal/time.h +35 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/internal/transcode.h +21 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/internal/util.h +31 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/internal/variable.h +84 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/internal/vm.h +136 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/internal/warnings.h +17 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/iseq.h +305 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/known_errors.inc +791 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/method.h +245 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/mjit.h +220 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/mjit_compile.inc +8240 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/node.h +484 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/node_name.inc +210 -0
- data/lib/debase/ruby_core_source/{ruby-2.7.0-preview2 → ruby-3.0.0-p0}/opt_sc.inc +0 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/optinsn.inc +128 -0
- data/lib/debase/ruby_core_source/{ruby-2.7.0-preview2 → ruby-3.0.0-p0}/optunifs.inc +0 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/parse.h +211 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/probes_helper.h +44 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/ractor_core.h +343 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/regenc.h +254 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/regint.h +938 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/regparse.h +370 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/revision.h +2 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/ruby_assert.h +15 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/ruby_atomic.h +23 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/siphash.h +48 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/symbol.h +119 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/thread_pthread.h +115 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/thread_win32.h +61 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/timev.h +57 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/transcode_data.h +138 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/transient_heap.h +65 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/variable.h +22 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/version.h +89 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/vm.inc +5355 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/vm_call_iseq_optimized.inc +244 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/vm_callinfo.h +456 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/vm_core.h +2023 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/vm_debug.h +116 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/vm_exec.h +196 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/vm_insnhelper.h +257 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/vm_opts.h +73 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/vm_sync.h +136 -0
- data/lib/debase/ruby_core_source/ruby-3.0.0-p0/vmtc.inc +243 -0
- data/lib/debase/ruby_core_source/version.rb +1 -1
- metadata +181 -57
- data/lib/debase/ruby_core_source/ruby-2.7.0-preview2/revision.h +0 -2
@@ -0,0 +1,2023 @@
|
|
1
|
+
#ifndef RUBY_VM_CORE_H
|
2
|
+
#define RUBY_VM_CORE_H
|
3
|
+
/**********************************************************************
|
4
|
+
|
5
|
+
vm_core.h -
|
6
|
+
|
7
|
+
$Author$
|
8
|
+
created at: 04/01/01 19:41:38 JST
|
9
|
+
|
10
|
+
Copyright (C) 2004-2007 Koichi Sasada
|
11
|
+
|
12
|
+
**********************************************************************/
|
13
|
+
|
14
|
+
/*
|
15
|
+
* Enable check mode.
|
16
|
+
* 1: enable local assertions.
|
17
|
+
*/
|
18
|
+
#ifndef VM_CHECK_MODE
|
19
|
+
|
20
|
+
// respect RUBY_DUBUG: if given n is 0, then use RUBY_DEBUG
|
21
|
+
#define N_OR_RUBY_DEBUG(n) (((n) > 0) ? (n) : RUBY_DEBUG)
|
22
|
+
|
23
|
+
#define VM_CHECK_MODE N_OR_RUBY_DEBUG(0)
|
24
|
+
#endif
|
25
|
+
|
26
|
+
/**
|
27
|
+
* VM Debug Level
|
28
|
+
*
|
29
|
+
* debug level:
|
30
|
+
* 0: no debug output
|
31
|
+
* 1: show instruction name
|
32
|
+
* 2: show stack frame when control stack frame is changed
|
33
|
+
* 3: show stack status
|
34
|
+
* 4: show register
|
35
|
+
* 5:
|
36
|
+
* 10: gc check
|
37
|
+
*/
|
38
|
+
|
39
|
+
#ifndef VMDEBUG
|
40
|
+
#define VMDEBUG 0
|
41
|
+
#endif
|
42
|
+
|
43
|
+
#if 0
|
44
|
+
#undef VMDEBUG
|
45
|
+
#define VMDEBUG 3
|
46
|
+
#endif
|
47
|
+
|
48
|
+
#include "ruby/internal/config.h"
|
49
|
+
|
50
|
+
#include <stddef.h>
|
51
|
+
#include <signal.h>
|
52
|
+
#include <stdarg.h>
|
53
|
+
|
54
|
+
#include "ruby_assert.h"
|
55
|
+
|
56
|
+
#if VM_CHECK_MODE > 0
|
57
|
+
#define VM_ASSERT(expr) RUBY_ASSERT_MESG_WHEN(VM_CHECK_MODE > 0, expr, #expr)
|
58
|
+
#define VM_UNREACHABLE(func) rb_bug(#func ": unreachable")
|
59
|
+
|
60
|
+
#else
|
61
|
+
#define VM_ASSERT(expr) ((void)0)
|
62
|
+
#define VM_UNREACHABLE(func) UNREACHABLE
|
63
|
+
#endif
|
64
|
+
|
65
|
+
#include <setjmp.h>
|
66
|
+
|
67
|
+
#include "ruby/internal/stdbool.h"
|
68
|
+
#include "ccan/list/list.h"
|
69
|
+
#include "id.h"
|
70
|
+
#include "internal.h"
|
71
|
+
#include "internal/array.h"
|
72
|
+
#include "internal/serial.h"
|
73
|
+
#include "internal/vm.h"
|
74
|
+
#include "method.h"
|
75
|
+
#include "node.h"
|
76
|
+
#include "ruby/ruby.h"
|
77
|
+
#include "ruby/st.h"
|
78
|
+
#include "ruby_atomic.h"
|
79
|
+
#include "vm_opts.h"
|
80
|
+
|
81
|
+
#include "ruby/thread_native.h"
|
82
|
+
#if defined(_WIN32)
|
83
|
+
#include "thread_win32.h"
|
84
|
+
#elif defined(HAVE_PTHREAD_H)
|
85
|
+
#include "thread_pthread.h"
|
86
|
+
#endif
|
87
|
+
|
88
|
+
#define RUBY_VM_THREAD_MODEL 2
|
89
|
+
|
90
|
+
/*
|
91
|
+
* implementation selector of get_insn_info algorithm
|
92
|
+
* 0: linear search
|
93
|
+
* 1: binary search
|
94
|
+
* 2: succinct bitvector
|
95
|
+
*/
|
96
|
+
#ifndef VM_INSN_INFO_TABLE_IMPL
|
97
|
+
# define VM_INSN_INFO_TABLE_IMPL 2
|
98
|
+
#endif
|
99
|
+
|
100
|
+
#if defined(NSIG_MAX) /* POSIX issue 8 */
|
101
|
+
# undef NSIG
|
102
|
+
# define NSIG NSIG_MAX
|
103
|
+
#elif defined(_SIG_MAXSIG) /* FreeBSD */
|
104
|
+
# undef NSIG
|
105
|
+
# define NSIG _SIG_MAXSIG
|
106
|
+
#elif defined(_SIGMAX) /* QNX */
|
107
|
+
# define NSIG (_SIGMAX + 1)
|
108
|
+
#elif defined(NSIG) /* 99% of everything else */
|
109
|
+
# /* take it */
|
110
|
+
#else /* Last resort */
|
111
|
+
# define NSIG (sizeof(sigset_t) * CHAR_BIT + 1)
|
112
|
+
#endif
|
113
|
+
|
114
|
+
#define RUBY_NSIG NSIG
|
115
|
+
|
116
|
+
#if defined(SIGCLD)
|
117
|
+
# define RUBY_SIGCHLD (SIGCLD)
|
118
|
+
#elif defined(SIGCHLD)
|
119
|
+
# define RUBY_SIGCHLD (SIGCHLD)
|
120
|
+
#else
|
121
|
+
# define RUBY_SIGCHLD (0)
|
122
|
+
#endif
|
123
|
+
|
124
|
+
/* platforms with broken or non-existent SIGCHLD work by polling */
|
125
|
+
#if defined(__APPLE__)
|
126
|
+
# define SIGCHLD_LOSSY (1)
|
127
|
+
#else
|
128
|
+
# define SIGCHLD_LOSSY (0)
|
129
|
+
#endif
|
130
|
+
|
131
|
+
/* define to 0 to test old code path */
|
132
|
+
#define WAITPID_USE_SIGCHLD (RUBY_SIGCHLD || SIGCHLD_LOSSY)
|
133
|
+
|
134
|
+
#if defined(SIGSEGV) && defined(HAVE_SIGALTSTACK) && defined(SA_SIGINFO) && !defined(__NetBSD__)
|
135
|
+
# define USE_SIGALTSTACK
|
136
|
+
void *rb_allocate_sigaltstack(void);
|
137
|
+
void *rb_register_sigaltstack(void *);
|
138
|
+
# define RB_ALTSTACK_INIT(var, altstack) var = rb_register_sigaltstack(altstack)
|
139
|
+
# define RB_ALTSTACK_FREE(var) xfree(var)
|
140
|
+
# define RB_ALTSTACK(var) var
|
141
|
+
#else /* noop */
|
142
|
+
# define RB_ALTSTACK_INIT(var, altstack)
|
143
|
+
# define RB_ALTSTACK_FREE(var)
|
144
|
+
# define RB_ALTSTACK(var) (0)
|
145
|
+
#endif
|
146
|
+
|
147
|
+
/*****************/
|
148
|
+
/* configuration */
|
149
|
+
/*****************/
|
150
|
+
|
151
|
+
/* gcc ver. check */
|
152
|
+
#if defined(__GNUC__) && __GNUC__ >= 2
|
153
|
+
|
154
|
+
#if OPT_TOKEN_THREADED_CODE
|
155
|
+
#if OPT_DIRECT_THREADED_CODE
|
156
|
+
#undef OPT_DIRECT_THREADED_CODE
|
157
|
+
#endif
|
158
|
+
#endif
|
159
|
+
|
160
|
+
#else /* defined(__GNUC__) && __GNUC__ >= 2 */
|
161
|
+
|
162
|
+
/* disable threaded code options */
|
163
|
+
#if OPT_DIRECT_THREADED_CODE
|
164
|
+
#undef OPT_DIRECT_THREADED_CODE
|
165
|
+
#endif
|
166
|
+
#if OPT_TOKEN_THREADED_CODE
|
167
|
+
#undef OPT_TOKEN_THREADED_CODE
|
168
|
+
#endif
|
169
|
+
#endif
|
170
|
+
|
171
|
+
/* call threaded code */
|
172
|
+
#if OPT_CALL_THREADED_CODE
|
173
|
+
#if OPT_DIRECT_THREADED_CODE
|
174
|
+
#undef OPT_DIRECT_THREADED_CODE
|
175
|
+
#endif /* OPT_DIRECT_THREADED_CODE */
|
176
|
+
#if OPT_STACK_CACHING
|
177
|
+
#undef OPT_STACK_CACHING
|
178
|
+
#endif /* OPT_STACK_CACHING */
|
179
|
+
#endif /* OPT_CALL_THREADED_CODE */
|
180
|
+
|
181
|
+
void rb_vm_encoded_insn_data_table_init(void);
|
182
|
+
typedef unsigned long rb_num_t;
|
183
|
+
typedef signed long rb_snum_t;
|
184
|
+
|
185
|
+
enum ruby_tag_type {
|
186
|
+
RUBY_TAG_NONE = 0x0,
|
187
|
+
RUBY_TAG_RETURN = 0x1,
|
188
|
+
RUBY_TAG_BREAK = 0x2,
|
189
|
+
RUBY_TAG_NEXT = 0x3,
|
190
|
+
RUBY_TAG_RETRY = 0x4,
|
191
|
+
RUBY_TAG_REDO = 0x5,
|
192
|
+
RUBY_TAG_RAISE = 0x6,
|
193
|
+
RUBY_TAG_THROW = 0x7,
|
194
|
+
RUBY_TAG_FATAL = 0x8,
|
195
|
+
RUBY_TAG_MASK = 0xf
|
196
|
+
};
|
197
|
+
|
198
|
+
#define TAG_NONE RUBY_TAG_NONE
|
199
|
+
#define TAG_RETURN RUBY_TAG_RETURN
|
200
|
+
#define TAG_BREAK RUBY_TAG_BREAK
|
201
|
+
#define TAG_NEXT RUBY_TAG_NEXT
|
202
|
+
#define TAG_RETRY RUBY_TAG_RETRY
|
203
|
+
#define TAG_REDO RUBY_TAG_REDO
|
204
|
+
#define TAG_RAISE RUBY_TAG_RAISE
|
205
|
+
#define TAG_THROW RUBY_TAG_THROW
|
206
|
+
#define TAG_FATAL RUBY_TAG_FATAL
|
207
|
+
#define TAG_MASK RUBY_TAG_MASK
|
208
|
+
|
209
|
+
enum ruby_vm_throw_flags {
|
210
|
+
VM_THROW_NO_ESCAPE_FLAG = 0x8000,
|
211
|
+
VM_THROW_STATE_MASK = 0xff
|
212
|
+
};
|
213
|
+
|
214
|
+
/* forward declarations */
|
215
|
+
struct rb_thread_struct;
|
216
|
+
struct rb_control_frame_struct;
|
217
|
+
|
218
|
+
/* iseq data type */
|
219
|
+
typedef struct rb_compile_option_struct rb_compile_option_t;
|
220
|
+
|
221
|
+
struct iseq_inline_cache_entry {
|
222
|
+
rb_serial_t ic_serial;
|
223
|
+
const rb_cref_t *ic_cref;
|
224
|
+
VALUE value;
|
225
|
+
};
|
226
|
+
|
227
|
+
struct iseq_inline_iv_cache_entry {
|
228
|
+
struct rb_iv_index_tbl_entry *entry;
|
229
|
+
};
|
230
|
+
|
231
|
+
union iseq_inline_storage_entry {
|
232
|
+
struct {
|
233
|
+
struct rb_thread_struct *running_thread;
|
234
|
+
VALUE value;
|
235
|
+
} once;
|
236
|
+
struct iseq_inline_cache_entry cache;
|
237
|
+
struct iseq_inline_iv_cache_entry iv_cache;
|
238
|
+
};
|
239
|
+
|
240
|
+
struct rb_calling_info {
|
241
|
+
const struct rb_callinfo *ci;
|
242
|
+
const struct rb_callcache *cc;
|
243
|
+
VALUE block_handler;
|
244
|
+
VALUE recv;
|
245
|
+
int argc;
|
246
|
+
int kw_splat;
|
247
|
+
};
|
248
|
+
|
249
|
+
struct rb_execution_context_struct;
|
250
|
+
|
251
|
+
#if 1
|
252
|
+
#define CoreDataFromValue(obj, type) (type*)DATA_PTR(obj)
|
253
|
+
#else
|
254
|
+
#define CoreDataFromValue(obj, type) (type*)rb_data_object_get(obj)
|
255
|
+
#endif
|
256
|
+
#define GetCoreDataFromValue(obj, type, ptr) ((ptr) = CoreDataFromValue((obj), type))
|
257
|
+
|
258
|
+
typedef struct rb_iseq_location_struct {
|
259
|
+
VALUE pathobj; /* String (path) or Array [path, realpath]. Frozen. */
|
260
|
+
VALUE base_label; /* String */
|
261
|
+
VALUE label; /* String */
|
262
|
+
VALUE first_lineno; /* TODO: may be unsigned short */
|
263
|
+
int node_id;
|
264
|
+
rb_code_location_t code_location;
|
265
|
+
} rb_iseq_location_t;
|
266
|
+
|
267
|
+
#define PATHOBJ_PATH 0
|
268
|
+
#define PATHOBJ_REALPATH 1
|
269
|
+
|
270
|
+
static inline VALUE
|
271
|
+
pathobj_path(VALUE pathobj)
|
272
|
+
{
|
273
|
+
if (RB_TYPE_P(pathobj, T_STRING)) {
|
274
|
+
return pathobj;
|
275
|
+
}
|
276
|
+
else {
|
277
|
+
VM_ASSERT(RB_TYPE_P(pathobj, T_ARRAY));
|
278
|
+
return RARRAY_AREF(pathobj, PATHOBJ_PATH);
|
279
|
+
}
|
280
|
+
}
|
281
|
+
|
282
|
+
static inline VALUE
|
283
|
+
pathobj_realpath(VALUE pathobj)
|
284
|
+
{
|
285
|
+
if (RB_TYPE_P(pathobj, T_STRING)) {
|
286
|
+
return pathobj;
|
287
|
+
}
|
288
|
+
else {
|
289
|
+
VM_ASSERT(RB_TYPE_P(pathobj, T_ARRAY));
|
290
|
+
return RARRAY_AREF(pathobj, PATHOBJ_REALPATH);
|
291
|
+
}
|
292
|
+
}
|
293
|
+
|
294
|
+
/* Forward declarations */
|
295
|
+
struct rb_mjit_unit;
|
296
|
+
|
297
|
+
struct rb_iseq_constant_body {
|
298
|
+
enum iseq_type {
|
299
|
+
ISEQ_TYPE_TOP,
|
300
|
+
ISEQ_TYPE_METHOD,
|
301
|
+
ISEQ_TYPE_BLOCK,
|
302
|
+
ISEQ_TYPE_CLASS,
|
303
|
+
ISEQ_TYPE_RESCUE,
|
304
|
+
ISEQ_TYPE_ENSURE,
|
305
|
+
ISEQ_TYPE_EVAL,
|
306
|
+
ISEQ_TYPE_MAIN,
|
307
|
+
ISEQ_TYPE_PLAIN
|
308
|
+
} type; /* instruction sequence type */
|
309
|
+
|
310
|
+
unsigned int iseq_size;
|
311
|
+
VALUE *iseq_encoded; /* encoded iseq (insn addr and operands) */
|
312
|
+
|
313
|
+
/**
|
314
|
+
* parameter information
|
315
|
+
*
|
316
|
+
* def m(a1, a2, ..., aM, # mandatory
|
317
|
+
* b1=(...), b2=(...), ..., bN=(...), # optional
|
318
|
+
* *c, # rest
|
319
|
+
* d1, d2, ..., dO, # post
|
320
|
+
* e1:(...), e2:(...), ..., eK:(...), # keyword
|
321
|
+
* **f, # keyword_rest
|
322
|
+
* &g) # block
|
323
|
+
* =>
|
324
|
+
*
|
325
|
+
* lead_num = M
|
326
|
+
* opt_num = N
|
327
|
+
* rest_start = M+N
|
328
|
+
* post_start = M+N+(*1)
|
329
|
+
* post_num = O
|
330
|
+
* keyword_num = K
|
331
|
+
* block_start = M+N+(*1)+O+K
|
332
|
+
* keyword_bits = M+N+(*1)+O+K+(&1)
|
333
|
+
* size = M+N+O+(*1)+K+(&1)+(**1) // parameter size.
|
334
|
+
*/
|
335
|
+
|
336
|
+
struct {
|
337
|
+
struct {
|
338
|
+
unsigned int has_lead : 1;
|
339
|
+
unsigned int has_opt : 1;
|
340
|
+
unsigned int has_rest : 1;
|
341
|
+
unsigned int has_post : 1;
|
342
|
+
unsigned int has_kw : 1;
|
343
|
+
unsigned int has_kwrest : 1;
|
344
|
+
unsigned int has_block : 1;
|
345
|
+
|
346
|
+
unsigned int ambiguous_param0 : 1; /* {|a|} */
|
347
|
+
unsigned int accepts_no_kwarg : 1;
|
348
|
+
unsigned int ruby2_keywords: 1;
|
349
|
+
} flags;
|
350
|
+
|
351
|
+
unsigned int size;
|
352
|
+
|
353
|
+
int lead_num;
|
354
|
+
int opt_num;
|
355
|
+
int rest_start;
|
356
|
+
int post_start;
|
357
|
+
int post_num;
|
358
|
+
int block_start;
|
359
|
+
|
360
|
+
const VALUE *opt_table; /* (opt_num + 1) entries. */
|
361
|
+
/* opt_num and opt_table:
|
362
|
+
*
|
363
|
+
* def foo o1=e1, o2=e2, ..., oN=eN
|
364
|
+
* #=>
|
365
|
+
* # prologue code
|
366
|
+
* A1: e1
|
367
|
+
* A2: e2
|
368
|
+
* ...
|
369
|
+
* AN: eN
|
370
|
+
* AL: body
|
371
|
+
* opt_num = N
|
372
|
+
* opt_table = [A1, A2, ..., AN, AL]
|
373
|
+
*/
|
374
|
+
|
375
|
+
const struct rb_iseq_param_keyword {
|
376
|
+
int num;
|
377
|
+
int required_num;
|
378
|
+
int bits_start;
|
379
|
+
int rest_start;
|
380
|
+
const ID *table;
|
381
|
+
VALUE *default_values;
|
382
|
+
} *keyword;
|
383
|
+
} param;
|
384
|
+
|
385
|
+
rb_iseq_location_t location;
|
386
|
+
|
387
|
+
/* insn info, must be freed */
|
388
|
+
struct iseq_insn_info {
|
389
|
+
const struct iseq_insn_info_entry *body;
|
390
|
+
unsigned int *positions;
|
391
|
+
unsigned int size;
|
392
|
+
#if VM_INSN_INFO_TABLE_IMPL == 2
|
393
|
+
struct succ_index_table *succ_index_table;
|
394
|
+
#endif
|
395
|
+
} insns_info;
|
396
|
+
|
397
|
+
const ID *local_table; /* must free */
|
398
|
+
|
399
|
+
/* catch table */
|
400
|
+
struct iseq_catch_table *catch_table;
|
401
|
+
|
402
|
+
/* for child iseq */
|
403
|
+
const struct rb_iseq_struct *parent_iseq;
|
404
|
+
struct rb_iseq_struct *local_iseq; /* local_iseq->flip_cnt can be modified */
|
405
|
+
|
406
|
+
union iseq_inline_storage_entry *is_entries;
|
407
|
+
struct rb_call_data *call_data; //struct rb_call_data calls[ci_size];
|
408
|
+
|
409
|
+
struct {
|
410
|
+
rb_snum_t flip_count;
|
411
|
+
VALUE coverage;
|
412
|
+
VALUE pc2branchindex;
|
413
|
+
VALUE *original_iseq;
|
414
|
+
} variable;
|
415
|
+
|
416
|
+
unsigned int local_table_size;
|
417
|
+
unsigned int is_size;
|
418
|
+
unsigned int ci_size;
|
419
|
+
unsigned int stack_max; /* for stack overflow check */
|
420
|
+
|
421
|
+
char catch_except_p; /* If a frame of this ISeq may catch exception, set TRUE */
|
422
|
+
bool builtin_inline_p; // This ISeq's builtin func is safe to be inlined by MJIT
|
423
|
+
struct rb_id_table *outer_variables;
|
424
|
+
|
425
|
+
#if USE_MJIT
|
426
|
+
/* The following fields are MJIT related info. */
|
427
|
+
VALUE (*jit_func)(struct rb_execution_context_struct *,
|
428
|
+
struct rb_control_frame_struct *); /* function pointer for loaded native code */
|
429
|
+
long unsigned total_calls; /* number of total calls with `mjit_exec()` */
|
430
|
+
struct rb_mjit_unit *jit_unit;
|
431
|
+
#endif
|
432
|
+
};
|
433
|
+
|
434
|
+
/* T_IMEMO/iseq */
|
435
|
+
/* typedef rb_iseq_t is in method.h */
|
436
|
+
struct rb_iseq_struct {
|
437
|
+
VALUE flags; /* 1 */
|
438
|
+
VALUE wrapper; /* 2 */
|
439
|
+
|
440
|
+
struct rb_iseq_constant_body *body; /* 3 */
|
441
|
+
|
442
|
+
union { /* 4, 5 words */
|
443
|
+
struct iseq_compile_data *compile_data; /* used at compile time */
|
444
|
+
|
445
|
+
struct {
|
446
|
+
VALUE obj;
|
447
|
+
int index;
|
448
|
+
} loader;
|
449
|
+
|
450
|
+
struct {
|
451
|
+
struct rb_hook_list_struct *local_hooks;
|
452
|
+
rb_event_flag_t global_trace_events;
|
453
|
+
} exec;
|
454
|
+
} aux;
|
455
|
+
};
|
456
|
+
|
457
|
+
#ifndef USE_LAZY_LOAD
|
458
|
+
#define USE_LAZY_LOAD 0
|
459
|
+
#endif
|
460
|
+
|
461
|
+
#if USE_LAZY_LOAD
|
462
|
+
const rb_iseq_t *rb_iseq_complete(const rb_iseq_t *iseq);
|
463
|
+
#endif
|
464
|
+
|
465
|
+
static inline const rb_iseq_t *
|
466
|
+
rb_iseq_check(const rb_iseq_t *iseq)
|
467
|
+
{
|
468
|
+
#if USE_LAZY_LOAD
|
469
|
+
if (iseq->body == NULL) {
|
470
|
+
rb_iseq_complete((rb_iseq_t *)iseq);
|
471
|
+
}
|
472
|
+
#endif
|
473
|
+
return iseq;
|
474
|
+
}
|
475
|
+
|
476
|
+
static inline const rb_iseq_t *
|
477
|
+
def_iseq_ptr(rb_method_definition_t *def)
|
478
|
+
{
|
479
|
+
//TODO: re-visit. to check the bug, enable this assertion.
|
480
|
+
#if VM_CHECK_MODE > 0
|
481
|
+
if (def->type != VM_METHOD_TYPE_ISEQ) rb_bug("def_iseq_ptr: not iseq (%d)", def->type);
|
482
|
+
#endif
|
483
|
+
return rb_iseq_check(def->body.iseq.iseqptr);
|
484
|
+
}
|
485
|
+
|
486
|
+
enum ruby_special_exceptions {
|
487
|
+
ruby_error_reenter,
|
488
|
+
ruby_error_nomemory,
|
489
|
+
ruby_error_sysstack,
|
490
|
+
ruby_error_stackfatal,
|
491
|
+
ruby_error_stream_closed,
|
492
|
+
ruby_special_error_count
|
493
|
+
};
|
494
|
+
|
495
|
+
enum ruby_basic_operators {
|
496
|
+
BOP_PLUS,
|
497
|
+
BOP_MINUS,
|
498
|
+
BOP_MULT,
|
499
|
+
BOP_DIV,
|
500
|
+
BOP_MOD,
|
501
|
+
BOP_EQ,
|
502
|
+
BOP_EQQ,
|
503
|
+
BOP_LT,
|
504
|
+
BOP_LE,
|
505
|
+
BOP_LTLT,
|
506
|
+
BOP_AREF,
|
507
|
+
BOP_ASET,
|
508
|
+
BOP_LENGTH,
|
509
|
+
BOP_SIZE,
|
510
|
+
BOP_EMPTY_P,
|
511
|
+
BOP_NIL_P,
|
512
|
+
BOP_SUCC,
|
513
|
+
BOP_GT,
|
514
|
+
BOP_GE,
|
515
|
+
BOP_NOT,
|
516
|
+
BOP_NEQ,
|
517
|
+
BOP_MATCH,
|
518
|
+
BOP_FREEZE,
|
519
|
+
BOP_UMINUS,
|
520
|
+
BOP_MAX,
|
521
|
+
BOP_MIN,
|
522
|
+
BOP_CALL,
|
523
|
+
BOP_AND,
|
524
|
+
BOP_OR,
|
525
|
+
|
526
|
+
BOP_LAST_
|
527
|
+
};
|
528
|
+
|
529
|
+
#define GetVMPtr(obj, ptr) \
|
530
|
+
GetCoreDataFromValue((obj), rb_vm_t, (ptr))
|
531
|
+
|
532
|
+
struct rb_vm_struct;
|
533
|
+
typedef void rb_vm_at_exit_func(struct rb_vm_struct*);
|
534
|
+
|
535
|
+
typedef struct rb_at_exit_list {
|
536
|
+
rb_vm_at_exit_func *func;
|
537
|
+
struct rb_at_exit_list *next;
|
538
|
+
} rb_at_exit_list;
|
539
|
+
|
540
|
+
struct rb_objspace;
|
541
|
+
struct rb_objspace *rb_objspace_alloc(void);
|
542
|
+
void rb_objspace_free(struct rb_objspace *);
|
543
|
+
void rb_objspace_call_finalizer(struct rb_objspace *);
|
544
|
+
|
545
|
+
typedef struct rb_hook_list_struct {
|
546
|
+
struct rb_event_hook_struct *hooks;
|
547
|
+
rb_event_flag_t events;
|
548
|
+
unsigned int need_clean;
|
549
|
+
unsigned int running;
|
550
|
+
} rb_hook_list_t;
|
551
|
+
|
552
|
+
|
553
|
+
// see builtin.h for definition
|
554
|
+
typedef const struct rb_builtin_function *RB_BUILTIN;
|
555
|
+
|
556
|
+
typedef struct rb_vm_struct {
|
557
|
+
VALUE self;
|
558
|
+
|
559
|
+
struct {
|
560
|
+
struct list_head set;
|
561
|
+
unsigned int cnt;
|
562
|
+
unsigned int blocking_cnt;
|
563
|
+
|
564
|
+
struct rb_ractor_struct *main_ractor;
|
565
|
+
struct rb_thread_struct *main_thread; // == vm->ractor.main_ractor->threads.main
|
566
|
+
|
567
|
+
struct {
|
568
|
+
// monitor
|
569
|
+
rb_nativethread_lock_t lock;
|
570
|
+
struct rb_ractor_struct *lock_owner;
|
571
|
+
unsigned int lock_rec;
|
572
|
+
|
573
|
+
// barrier
|
574
|
+
bool barrier_waiting;
|
575
|
+
unsigned int barrier_cnt;
|
576
|
+
rb_nativethread_cond_t barrier_cond;
|
577
|
+
|
578
|
+
// join at exit
|
579
|
+
rb_nativethread_cond_t terminate_cond;
|
580
|
+
bool terminate_waiting;
|
581
|
+
} sync;
|
582
|
+
} ractor;
|
583
|
+
|
584
|
+
#ifdef USE_SIGALTSTACK
|
585
|
+
void *main_altstack;
|
586
|
+
#endif
|
587
|
+
|
588
|
+
rb_serial_t fork_gen;
|
589
|
+
rb_nativethread_lock_t waitpid_lock;
|
590
|
+
struct list_head waiting_pids; /* PID > 0: <=> struct waitpid_state */
|
591
|
+
struct list_head waiting_grps; /* PID <= 0: <=> struct waitpid_state */
|
592
|
+
struct list_head waiting_fds; /* <=> struct waiting_fd */
|
593
|
+
|
594
|
+
/* set in single-threaded processes only: */
|
595
|
+
volatile int ubf_async_safe;
|
596
|
+
|
597
|
+
unsigned int running: 1;
|
598
|
+
unsigned int thread_abort_on_exception: 1;
|
599
|
+
unsigned int thread_report_on_exception: 1;
|
600
|
+
unsigned int thread_ignore_deadlock: 1;
|
601
|
+
|
602
|
+
/* object management */
|
603
|
+
VALUE mark_object_ary;
|
604
|
+
const VALUE special_exceptions[ruby_special_error_count];
|
605
|
+
|
606
|
+
/* load */
|
607
|
+
VALUE top_self;
|
608
|
+
VALUE load_path;
|
609
|
+
VALUE load_path_snapshot;
|
610
|
+
VALUE load_path_check_cache;
|
611
|
+
VALUE expanded_load_path;
|
612
|
+
VALUE loaded_features;
|
613
|
+
VALUE loaded_features_snapshot;
|
614
|
+
struct st_table *loaded_features_index;
|
615
|
+
struct st_table *loading_table;
|
616
|
+
|
617
|
+
/* signal */
|
618
|
+
struct {
|
619
|
+
VALUE cmd[RUBY_NSIG];
|
620
|
+
} trap_list;
|
621
|
+
|
622
|
+
/* relation table of ensure - rollback for callcc */
|
623
|
+
struct st_table *ensure_rollback_table;
|
624
|
+
|
625
|
+
/* postponed_job (async-signal-safe, NOT thread-safe) */
|
626
|
+
struct rb_postponed_job_struct *postponed_job_buffer;
|
627
|
+
rb_atomic_t postponed_job_index;
|
628
|
+
|
629
|
+
int src_encoding_index;
|
630
|
+
|
631
|
+
/* workqueue (thread-safe, NOT async-signal-safe) */
|
632
|
+
struct list_head workqueue; /* <=> rb_workqueue_job.jnode */
|
633
|
+
rb_nativethread_lock_t workqueue_lock;
|
634
|
+
|
635
|
+
VALUE orig_progname, progname;
|
636
|
+
VALUE coverages;
|
637
|
+
int coverage_mode;
|
638
|
+
|
639
|
+
st_table * defined_module_hash;
|
640
|
+
|
641
|
+
struct rb_objspace *objspace;
|
642
|
+
|
643
|
+
rb_at_exit_list *at_exit;
|
644
|
+
|
645
|
+
VALUE *defined_strings;
|
646
|
+
st_table *frozen_strings;
|
647
|
+
|
648
|
+
const struct rb_builtin_function *builtin_function_table;
|
649
|
+
int builtin_inline_index;
|
650
|
+
|
651
|
+
struct rb_id_table *negative_cme_table;
|
652
|
+
|
653
|
+
#if USE_VM_CLOCK
|
654
|
+
uint32_t clock;
|
655
|
+
#endif
|
656
|
+
|
657
|
+
/* params */
|
658
|
+
struct { /* size in byte */
|
659
|
+
size_t thread_vm_stack_size;
|
660
|
+
size_t thread_machine_stack_size;
|
661
|
+
size_t fiber_vm_stack_size;
|
662
|
+
size_t fiber_machine_stack_size;
|
663
|
+
} default_params;
|
664
|
+
|
665
|
+
short redefined_flag[BOP_LAST_];
|
666
|
+
} rb_vm_t;
|
667
|
+
|
668
|
+
/* default values */
|
669
|
+
|
670
|
+
#define RUBY_VM_SIZE_ALIGN 4096
|
671
|
+
|
672
|
+
#define RUBY_VM_THREAD_VM_STACK_SIZE ( 128 * 1024 * sizeof(VALUE)) /* 512 KB or 1024 KB */
|
673
|
+
#define RUBY_VM_THREAD_VM_STACK_SIZE_MIN ( 2 * 1024 * sizeof(VALUE)) /* 8 KB or 16 KB */
|
674
|
+
#define RUBY_VM_THREAD_MACHINE_STACK_SIZE ( 128 * 1024 * sizeof(VALUE)) /* 512 KB or 1024 KB */
|
675
|
+
#define RUBY_VM_THREAD_MACHINE_STACK_SIZE_MIN ( 16 * 1024 * sizeof(VALUE)) /* 64 KB or 128 KB */
|
676
|
+
|
677
|
+
#define RUBY_VM_FIBER_VM_STACK_SIZE ( 16 * 1024 * sizeof(VALUE)) /* 64 KB or 128 KB */
|
678
|
+
#define RUBY_VM_FIBER_VM_STACK_SIZE_MIN ( 2 * 1024 * sizeof(VALUE)) /* 8 KB or 16 KB */
|
679
|
+
#define RUBY_VM_FIBER_MACHINE_STACK_SIZE ( 64 * 1024 * sizeof(VALUE)) /* 256 KB or 512 KB */
|
680
|
+
#if defined(__powerpc64__)
|
681
|
+
#define RUBY_VM_FIBER_MACHINE_STACK_SIZE_MIN ( 32 * 1024 * sizeof(VALUE)) /* 128 KB or 256 KB */
|
682
|
+
#else
|
683
|
+
#define RUBY_VM_FIBER_MACHINE_STACK_SIZE_MIN ( 16 * 1024 * sizeof(VALUE)) /* 64 KB or 128 KB */
|
684
|
+
#endif
|
685
|
+
|
686
|
+
#if __has_feature(memory_sanitizer) || __has_feature(address_sanitizer)
|
687
|
+
/* It seems sanitizers consume A LOT of machine stacks */
|
688
|
+
#undef RUBY_VM_THREAD_MACHINE_STACK_SIZE
|
689
|
+
#define RUBY_VM_THREAD_MACHINE_STACK_SIZE (1024 * 1024 * sizeof(VALUE))
|
690
|
+
#undef RUBY_VM_THREAD_MACHINE_STACK_SIZE_MIN
|
691
|
+
#define RUBY_VM_THREAD_MACHINE_STACK_SIZE_MIN ( 512 * 1024 * sizeof(VALUE))
|
692
|
+
#undef RUBY_VM_FIBER_MACHINE_STACK_SIZE
|
693
|
+
#define RUBY_VM_FIBER_MACHINE_STACK_SIZE ( 256 * 1024 * sizeof(VALUE))
|
694
|
+
#undef RUBY_VM_FIBER_MACHINE_STACK_SIZE_MIN
|
695
|
+
#define RUBY_VM_FIBER_MACHINE_STACK_SIZE_MIN ( 128 * 1024 * sizeof(VALUE))
|
696
|
+
#endif
|
697
|
+
|
698
|
+
/* optimize insn */
|
699
|
+
#define INTEGER_REDEFINED_OP_FLAG (1 << 0)
|
700
|
+
#define FLOAT_REDEFINED_OP_FLAG (1 << 1)
|
701
|
+
#define STRING_REDEFINED_OP_FLAG (1 << 2)
|
702
|
+
#define ARRAY_REDEFINED_OP_FLAG (1 << 3)
|
703
|
+
#define HASH_REDEFINED_OP_FLAG (1 << 4)
|
704
|
+
/* #define BIGNUM_REDEFINED_OP_FLAG (1 << 5) */
|
705
|
+
#define SYMBOL_REDEFINED_OP_FLAG (1 << 6)
|
706
|
+
#define TIME_REDEFINED_OP_FLAG (1 << 7)
|
707
|
+
#define REGEXP_REDEFINED_OP_FLAG (1 << 8)
|
708
|
+
#define NIL_REDEFINED_OP_FLAG (1 << 9)
|
709
|
+
#define TRUE_REDEFINED_OP_FLAG (1 << 10)
|
710
|
+
#define FALSE_REDEFINED_OP_FLAG (1 << 11)
|
711
|
+
#define PROC_REDEFINED_OP_FLAG (1 << 12)
|
712
|
+
|
713
|
+
#define BASIC_OP_UNREDEFINED_P(op, klass) (LIKELY((GET_VM()->redefined_flag[(op)]&(klass)) == 0))
|
714
|
+
|
715
|
+
#ifndef VM_DEBUG_BP_CHECK
|
716
|
+
#define VM_DEBUG_BP_CHECK 0
|
717
|
+
#endif
|
718
|
+
|
719
|
+
#ifndef VM_DEBUG_VERIFY_METHOD_CACHE
|
720
|
+
#define VM_DEBUG_VERIFY_METHOD_CACHE (VMDEBUG != 0)
|
721
|
+
#endif
|
722
|
+
|
723
|
+
struct rb_captured_block {
|
724
|
+
VALUE self;
|
725
|
+
const VALUE *ep;
|
726
|
+
union {
|
727
|
+
const rb_iseq_t *iseq;
|
728
|
+
const struct vm_ifunc *ifunc;
|
729
|
+
VALUE val;
|
730
|
+
} code;
|
731
|
+
};
|
732
|
+
|
733
|
+
enum rb_block_handler_type {
|
734
|
+
block_handler_type_iseq,
|
735
|
+
block_handler_type_ifunc,
|
736
|
+
block_handler_type_symbol,
|
737
|
+
block_handler_type_proc
|
738
|
+
};
|
739
|
+
|
740
|
+
enum rb_block_type {
|
741
|
+
block_type_iseq,
|
742
|
+
block_type_ifunc,
|
743
|
+
block_type_symbol,
|
744
|
+
block_type_proc
|
745
|
+
};
|
746
|
+
|
747
|
+
struct rb_block {
|
748
|
+
union {
|
749
|
+
struct rb_captured_block captured;
|
750
|
+
VALUE symbol;
|
751
|
+
VALUE proc;
|
752
|
+
} as;
|
753
|
+
enum rb_block_type type;
|
754
|
+
};
|
755
|
+
|
756
|
+
typedef struct rb_control_frame_struct {
|
757
|
+
const VALUE *pc; /* cfp[0] */
|
758
|
+
VALUE *sp; /* cfp[1] */
|
759
|
+
const rb_iseq_t *iseq; /* cfp[2] */
|
760
|
+
VALUE self; /* cfp[3] / block[0] */
|
761
|
+
const VALUE *ep; /* cfp[4] / block[1] */
|
762
|
+
const void *block_code; /* cfp[5] / block[2] */ /* iseq or ifunc or forwarded block handler */
|
763
|
+
VALUE *__bp__; /* cfp[6] */ /* outside vm_push_frame, use vm_base_ptr instead. */
|
764
|
+
|
765
|
+
#if VM_DEBUG_BP_CHECK
|
766
|
+
VALUE *bp_check; /* cfp[7] */
|
767
|
+
#endif
|
768
|
+
} rb_control_frame_t;
|
769
|
+
|
770
|
+
extern const rb_data_type_t ruby_threadptr_data_type;
|
771
|
+
|
772
|
+
static inline struct rb_thread_struct *
|
773
|
+
rb_thread_ptr(VALUE thval)
|
774
|
+
{
|
775
|
+
return (struct rb_thread_struct *)rb_check_typeddata(thval, &ruby_threadptr_data_type);
|
776
|
+
}
|
777
|
+
|
778
|
+
enum rb_thread_status {
|
779
|
+
THREAD_RUNNABLE,
|
780
|
+
THREAD_STOPPED,
|
781
|
+
THREAD_STOPPED_FOREVER,
|
782
|
+
THREAD_KILLED
|
783
|
+
};
|
784
|
+
|
785
|
+
#ifdef RUBY_JMP_BUF
|
786
|
+
typedef RUBY_JMP_BUF rb_jmpbuf_t;
|
787
|
+
#else
|
788
|
+
typedef void *rb_jmpbuf_t[5];
|
789
|
+
#endif
|
790
|
+
|
791
|
+
/*
|
792
|
+
the members which are written in EC_PUSH_TAG() should be placed at
|
793
|
+
the beginning and the end, so that entire region is accessible.
|
794
|
+
*/
|
795
|
+
struct rb_vm_tag {
|
796
|
+
VALUE tag;
|
797
|
+
VALUE retval;
|
798
|
+
rb_jmpbuf_t buf;
|
799
|
+
struct rb_vm_tag *prev;
|
800
|
+
enum ruby_tag_type state;
|
801
|
+
unsigned int lock_rec;
|
802
|
+
};
|
803
|
+
|
804
|
+
STATIC_ASSERT(rb_vm_tag_buf_offset, offsetof(struct rb_vm_tag, buf) > 0);
|
805
|
+
STATIC_ASSERT(rb_vm_tag_buf_end,
|
806
|
+
offsetof(struct rb_vm_tag, buf) + sizeof(rb_jmpbuf_t) <
|
807
|
+
sizeof(struct rb_vm_tag));
|
808
|
+
|
809
|
+
struct rb_vm_protect_tag {
|
810
|
+
struct rb_vm_protect_tag *prev;
|
811
|
+
};
|
812
|
+
|
813
|
+
struct rb_unblock_callback {
|
814
|
+
rb_unblock_function_t *func;
|
815
|
+
void *arg;
|
816
|
+
};
|
817
|
+
|
818
|
+
struct rb_mutex_struct;
|
819
|
+
|
820
|
+
typedef struct rb_ensure_entry {
|
821
|
+
VALUE marker;
|
822
|
+
VALUE (*e_proc)(VALUE);
|
823
|
+
VALUE data2;
|
824
|
+
} rb_ensure_entry_t;
|
825
|
+
|
826
|
+
typedef struct rb_ensure_list {
|
827
|
+
struct rb_ensure_list *next;
|
828
|
+
struct rb_ensure_entry entry;
|
829
|
+
} rb_ensure_list_t;
|
830
|
+
|
831
|
+
typedef char rb_thread_id_string_t[sizeof(rb_nativethread_id_t) * 2 + 3];
|
832
|
+
|
833
|
+
typedef struct rb_fiber_struct rb_fiber_t;
|
834
|
+
|
835
|
+
struct rb_waiting_list {
|
836
|
+
struct rb_waiting_list *next;
|
837
|
+
struct rb_thread_struct *thread;
|
838
|
+
struct rb_fiber_struct *fiber;
|
839
|
+
};
|
840
|
+
|
841
|
+
struct rb_execution_context_struct {
|
842
|
+
/* execution information */
|
843
|
+
VALUE *vm_stack; /* must free, must mark */
|
844
|
+
size_t vm_stack_size; /* size in word (byte size / sizeof(VALUE)) */
|
845
|
+
rb_control_frame_t *cfp;
|
846
|
+
|
847
|
+
struct rb_vm_tag *tag;
|
848
|
+
struct rb_vm_protect_tag *protect_tag;
|
849
|
+
|
850
|
+
/* interrupt flags */
|
851
|
+
rb_atomic_t interrupt_flag;
|
852
|
+
rb_atomic_t interrupt_mask; /* size should match flag */
|
853
|
+
#if USE_VM_CLOCK
|
854
|
+
uint32_t checked_clock;
|
855
|
+
#endif
|
856
|
+
|
857
|
+
rb_fiber_t *fiber_ptr;
|
858
|
+
struct rb_thread_struct *thread_ptr;
|
859
|
+
|
860
|
+
/* storage (ec (fiber) local) */
|
861
|
+
struct rb_id_table *local_storage;
|
862
|
+
VALUE local_storage_recursive_hash;
|
863
|
+
VALUE local_storage_recursive_hash_for_trace;
|
864
|
+
|
865
|
+
/* eval env */
|
866
|
+
const VALUE *root_lep;
|
867
|
+
VALUE root_svar;
|
868
|
+
|
869
|
+
/* ensure & callcc */
|
870
|
+
rb_ensure_list_t *ensure_list;
|
871
|
+
|
872
|
+
/* trace information */
|
873
|
+
struct rb_trace_arg_struct *trace_arg;
|
874
|
+
|
875
|
+
/* temporary places */
|
876
|
+
VALUE errinfo;
|
877
|
+
VALUE passed_block_handler; /* for rb_iterate */
|
878
|
+
|
879
|
+
uint8_t raised_flag; /* only 3 bits needed */
|
880
|
+
|
881
|
+
/* n.b. only 7 bits needed, really: */
|
882
|
+
BITFIELD(enum method_missing_reason, method_missing_reason, 8);
|
883
|
+
|
884
|
+
VALUE private_const_reference;
|
885
|
+
|
886
|
+
/* for GC */
|
887
|
+
struct {
|
888
|
+
VALUE *stack_start;
|
889
|
+
VALUE *stack_end;
|
890
|
+
size_t stack_maxsize;
|
891
|
+
RUBY_ALIGNAS(SIZEOF_VALUE) jmp_buf regs;
|
892
|
+
} machine;
|
893
|
+
};
|
894
|
+
|
895
|
+
#ifndef rb_execution_context_t
|
896
|
+
typedef struct rb_execution_context_struct rb_execution_context_t;
|
897
|
+
#define rb_execution_context_t rb_execution_context_t
|
898
|
+
#endif
|
899
|
+
|
900
|
+
// for builtin.h
|
901
|
+
#define VM_CORE_H_EC_DEFINED 1
|
902
|
+
|
903
|
+
// Set the vm_stack pointer in the execution context.
|
904
|
+
void rb_ec_set_vm_stack(rb_execution_context_t *ec, VALUE *stack, size_t size);
|
905
|
+
|
906
|
+
// Initialize the vm_stack pointer in the execution context and push the initial stack frame.
|
907
|
+
// @param ec the execution context to update.
|
908
|
+
// @param stack a pointer to the stack to use.
|
909
|
+
// @param size the size of the stack, as in `VALUE stack[size]`.
|
910
|
+
void rb_ec_initialize_vm_stack(rb_execution_context_t *ec, VALUE *stack, size_t size);
|
911
|
+
|
912
|
+
// Clear (set to `NULL`) the vm_stack pointer.
|
913
|
+
// @param ec the execution context to update.
|
914
|
+
void rb_ec_clear_vm_stack(rb_execution_context_t *ec);
|
915
|
+
|
916
|
+
struct rb_ext_config {
|
917
|
+
bool ractor_safe;
|
918
|
+
};
|
919
|
+
|
920
|
+
typedef struct rb_ractor_struct rb_ractor_t;
|
921
|
+
|
922
|
+
typedef struct rb_thread_struct {
|
923
|
+
struct list_node lt_node; // managed by a ractor
|
924
|
+
VALUE self;
|
925
|
+
rb_ractor_t *ractor;
|
926
|
+
rb_vm_t *vm;
|
927
|
+
|
928
|
+
rb_execution_context_t *ec;
|
929
|
+
|
930
|
+
VALUE last_status; /* $? */
|
931
|
+
|
932
|
+
/* for cfunc */
|
933
|
+
struct rb_calling_info *calling;
|
934
|
+
|
935
|
+
/* for load(true) */
|
936
|
+
VALUE top_self;
|
937
|
+
VALUE top_wrapper;
|
938
|
+
|
939
|
+
/* thread control */
|
940
|
+
rb_nativethread_id_t thread_id;
|
941
|
+
#ifdef NON_SCALAR_THREAD_ID
|
942
|
+
rb_thread_id_string_t thread_id_string;
|
943
|
+
#endif
|
944
|
+
BITFIELD(enum rb_thread_status, status, 2);
|
945
|
+
/* bit flags */
|
946
|
+
unsigned int to_kill : 1;
|
947
|
+
unsigned int abort_on_exception: 1;
|
948
|
+
unsigned int report_on_exception: 1;
|
949
|
+
unsigned int pending_interrupt_queue_checked: 1;
|
950
|
+
int8_t priority; /* -3 .. 3 (RUBY_THREAD_PRIORITY_{MIN,MAX}) */
|
951
|
+
uint32_t running_time_us; /* 12500..800000 */
|
952
|
+
|
953
|
+
native_thread_data_t native_thread_data;
|
954
|
+
void *blocking_region_buffer;
|
955
|
+
|
956
|
+
VALUE thgroup;
|
957
|
+
VALUE value;
|
958
|
+
|
959
|
+
/* temporary place of retval on OPT_CALL_THREADED_CODE */
|
960
|
+
#if OPT_CALL_THREADED_CODE
|
961
|
+
VALUE retval;
|
962
|
+
#endif
|
963
|
+
|
964
|
+
/* async errinfo queue */
|
965
|
+
VALUE pending_interrupt_queue;
|
966
|
+
VALUE pending_interrupt_mask_stack;
|
967
|
+
|
968
|
+
/* interrupt management */
|
969
|
+
rb_nativethread_lock_t interrupt_lock;
|
970
|
+
struct rb_unblock_callback unblock;
|
971
|
+
VALUE locking_mutex;
|
972
|
+
struct rb_mutex_struct *keeping_mutexes;
|
973
|
+
|
974
|
+
struct rb_waiting_list *join_list;
|
975
|
+
|
976
|
+
union {
|
977
|
+
struct {
|
978
|
+
VALUE proc;
|
979
|
+
VALUE args;
|
980
|
+
int kw_splat;
|
981
|
+
} proc;
|
982
|
+
struct {
|
983
|
+
VALUE (*func)(void *);
|
984
|
+
void *arg;
|
985
|
+
} func;
|
986
|
+
} invoke_arg;
|
987
|
+
|
988
|
+
enum thread_invoke_type {
|
989
|
+
thread_invoke_type_none = 0,
|
990
|
+
thread_invoke_type_proc,
|
991
|
+
thread_invoke_type_ractor_proc,
|
992
|
+
thread_invoke_type_func
|
993
|
+
} invoke_type;
|
994
|
+
|
995
|
+
/* statistics data for profiler */
|
996
|
+
VALUE stat_insn_usage;
|
997
|
+
|
998
|
+
/* fiber */
|
999
|
+
rb_fiber_t *root_fiber;
|
1000
|
+
rb_jmpbuf_t root_jmpbuf;
|
1001
|
+
|
1002
|
+
VALUE scheduler;
|
1003
|
+
unsigned blocking;
|
1004
|
+
|
1005
|
+
/* misc */
|
1006
|
+
VALUE name;
|
1007
|
+
|
1008
|
+
struct rb_ext_config ext_config;
|
1009
|
+
|
1010
|
+
#ifdef USE_SIGALTSTACK
|
1011
|
+
void *altstack;
|
1012
|
+
#endif
|
1013
|
+
} rb_thread_t;
|
1014
|
+
|
1015
|
+
typedef enum {
|
1016
|
+
VM_DEFINECLASS_TYPE_CLASS = 0x00,
|
1017
|
+
VM_DEFINECLASS_TYPE_SINGLETON_CLASS = 0x01,
|
1018
|
+
VM_DEFINECLASS_TYPE_MODULE = 0x02,
|
1019
|
+
/* 0x03..0x06 is reserved */
|
1020
|
+
VM_DEFINECLASS_TYPE_MASK = 0x07
|
1021
|
+
} rb_vm_defineclass_type_t;
|
1022
|
+
|
1023
|
+
#define VM_DEFINECLASS_TYPE(x) ((rb_vm_defineclass_type_t)(x) & VM_DEFINECLASS_TYPE_MASK)
|
1024
|
+
#define VM_DEFINECLASS_FLAG_SCOPED 0x08
|
1025
|
+
#define VM_DEFINECLASS_FLAG_HAS_SUPERCLASS 0x10
|
1026
|
+
#define VM_DEFINECLASS_SCOPED_P(x) ((x) & VM_DEFINECLASS_FLAG_SCOPED)
|
1027
|
+
#define VM_DEFINECLASS_HAS_SUPERCLASS_P(x) \
|
1028
|
+
((x) & VM_DEFINECLASS_FLAG_HAS_SUPERCLASS)
|
1029
|
+
|
1030
|
+
/* iseq.c */
|
1031
|
+
RUBY_SYMBOL_EXPORT_BEGIN
|
1032
|
+
|
1033
|
+
/* node -> iseq */
|
1034
|
+
rb_iseq_t *rb_iseq_new (const rb_ast_body_t *ast, VALUE name, VALUE path, VALUE realpath, const rb_iseq_t *parent, enum iseq_type);
|
1035
|
+
rb_iseq_t *rb_iseq_new_top (const rb_ast_body_t *ast, VALUE name, VALUE path, VALUE realpath, const rb_iseq_t *parent);
|
1036
|
+
rb_iseq_t *rb_iseq_new_main (const rb_ast_body_t *ast, VALUE path, VALUE realpath, const rb_iseq_t *parent);
|
1037
|
+
rb_iseq_t *rb_iseq_new_eval (const rb_ast_body_t *ast, VALUE name, VALUE path, VALUE realpath, VALUE first_lineno, const rb_iseq_t *parent, int isolated_depth);
|
1038
|
+
rb_iseq_t *rb_iseq_new_with_opt(const rb_ast_body_t *ast, VALUE name, VALUE path, VALUE realpath, VALUE first_lineno, const rb_iseq_t *parent, int isolated_depth,
|
1039
|
+
enum iseq_type, const rb_compile_option_t*);
|
1040
|
+
|
1041
|
+
struct iseq_link_anchor;
|
1042
|
+
struct rb_iseq_new_with_callback_callback_func {
|
1043
|
+
VALUE flags;
|
1044
|
+
VALUE reserved;
|
1045
|
+
void (*func)(rb_iseq_t *, struct iseq_link_anchor *, const void *);
|
1046
|
+
const void *data;
|
1047
|
+
};
|
1048
|
+
static inline struct rb_iseq_new_with_callback_callback_func *
|
1049
|
+
rb_iseq_new_with_callback_new_callback(
|
1050
|
+
void (*func)(rb_iseq_t *, struct iseq_link_anchor *, const void *), const void *ptr)
|
1051
|
+
{
|
1052
|
+
VALUE memo = rb_imemo_new(imemo_ifunc, (VALUE)func, (VALUE)ptr, Qundef, Qfalse);
|
1053
|
+
return (struct rb_iseq_new_with_callback_callback_func *)memo;
|
1054
|
+
}
|
1055
|
+
rb_iseq_t *rb_iseq_new_with_callback(const struct rb_iseq_new_with_callback_callback_func * ifunc,
|
1056
|
+
VALUE name, VALUE path, VALUE realpath, VALUE first_lineno,
|
1057
|
+
const rb_iseq_t *parent, enum iseq_type, const rb_compile_option_t*);
|
1058
|
+
|
1059
|
+
VALUE rb_iseq_disasm(const rb_iseq_t *iseq);
|
1060
|
+
int rb_iseq_disasm_insn(VALUE str, const VALUE *iseqval, size_t pos, const rb_iseq_t *iseq, VALUE child);
|
1061
|
+
|
1062
|
+
VALUE rb_iseq_coverage(const rb_iseq_t *iseq);
|
1063
|
+
|
1064
|
+
RUBY_EXTERN VALUE rb_cISeq;
|
1065
|
+
RUBY_EXTERN VALUE rb_cRubyVM;
|
1066
|
+
RUBY_EXTERN VALUE rb_mRubyVMFrozenCore;
|
1067
|
+
RUBY_EXTERN VALUE rb_block_param_proxy;
|
1068
|
+
RUBY_SYMBOL_EXPORT_END
|
1069
|
+
|
1070
|
+
#define GetProcPtr(obj, ptr) \
|
1071
|
+
GetCoreDataFromValue((obj), rb_proc_t, (ptr))
|
1072
|
+
|
1073
|
+
typedef struct {
|
1074
|
+
const struct rb_block block;
|
1075
|
+
unsigned int is_from_method: 1; /* bool */
|
1076
|
+
unsigned int is_lambda: 1; /* bool */
|
1077
|
+
unsigned int is_isolated: 1; /* bool */
|
1078
|
+
} rb_proc_t;
|
1079
|
+
|
1080
|
+
VALUE rb_proc_isolate(VALUE self);
|
1081
|
+
VALUE rb_proc_isolate_bang(VALUE self);
|
1082
|
+
VALUE rb_proc_ractor_make_shareable(VALUE self);
|
1083
|
+
|
1084
|
+
typedef struct {
|
1085
|
+
VALUE flags; /* imemo header */
|
1086
|
+
rb_iseq_t *iseq;
|
1087
|
+
const VALUE *ep;
|
1088
|
+
const VALUE *env;
|
1089
|
+
unsigned int env_size;
|
1090
|
+
} rb_env_t;
|
1091
|
+
|
1092
|
+
extern const rb_data_type_t ruby_binding_data_type;
|
1093
|
+
|
1094
|
+
#define GetBindingPtr(obj, ptr) \
|
1095
|
+
GetCoreDataFromValue((obj), rb_binding_t, (ptr))
|
1096
|
+
|
1097
|
+
typedef struct {
|
1098
|
+
const struct rb_block block;
|
1099
|
+
const VALUE pathobj;
|
1100
|
+
unsigned short first_lineno;
|
1101
|
+
} rb_binding_t;
|
1102
|
+
|
1103
|
+
/* used by compile time and send insn */
|
1104
|
+
|
1105
|
+
enum vm_check_match_type {
|
1106
|
+
VM_CHECKMATCH_TYPE_WHEN = 1,
|
1107
|
+
VM_CHECKMATCH_TYPE_CASE = 2,
|
1108
|
+
VM_CHECKMATCH_TYPE_RESCUE = 3
|
1109
|
+
};
|
1110
|
+
|
1111
|
+
#define VM_CHECKMATCH_TYPE_MASK 0x03
|
1112
|
+
#define VM_CHECKMATCH_ARRAY 0x04
|
1113
|
+
|
1114
|
+
enum vm_special_object_type {
|
1115
|
+
VM_SPECIAL_OBJECT_VMCORE = 1,
|
1116
|
+
VM_SPECIAL_OBJECT_CBASE,
|
1117
|
+
VM_SPECIAL_OBJECT_CONST_BASE
|
1118
|
+
};
|
1119
|
+
|
1120
|
+
enum vm_svar_index {
|
1121
|
+
VM_SVAR_LASTLINE = 0, /* $_ */
|
1122
|
+
VM_SVAR_BACKREF = 1, /* $~ */
|
1123
|
+
|
1124
|
+
VM_SVAR_EXTRA_START = 2,
|
1125
|
+
VM_SVAR_FLIPFLOP_START = 2 /* flipflop */
|
1126
|
+
};
|
1127
|
+
|
1128
|
+
/* inline cache */
|
1129
|
+
typedef struct iseq_inline_cache_entry *IC;
|
1130
|
+
typedef struct iseq_inline_iv_cache_entry *IVC;
|
1131
|
+
typedef union iseq_inline_storage_entry *ISE;
|
1132
|
+
typedef const struct rb_callinfo *CALL_INFO;
|
1133
|
+
typedef const struct rb_callcache *CALL_CACHE;
|
1134
|
+
typedef struct rb_call_data *CALL_DATA;
|
1135
|
+
|
1136
|
+
typedef VALUE CDHASH;
|
1137
|
+
|
1138
|
+
#ifndef FUNC_FASTCALL
|
1139
|
+
#define FUNC_FASTCALL(x) x
|
1140
|
+
#endif
|
1141
|
+
|
1142
|
+
typedef rb_control_frame_t *
|
1143
|
+
(FUNC_FASTCALL(*rb_insn_func_t))(rb_execution_context_t *, rb_control_frame_t *);
|
1144
|
+
|
1145
|
+
#define VM_TAGGED_PTR_SET(p, tag) ((VALUE)(p) | (tag))
|
1146
|
+
#define VM_TAGGED_PTR_REF(v, mask) ((void *)((v) & ~mask))
|
1147
|
+
|
1148
|
+
#define GC_GUARDED_PTR(p) VM_TAGGED_PTR_SET((p), 0x01)
|
1149
|
+
#define GC_GUARDED_PTR_REF(p) VM_TAGGED_PTR_REF((p), 0x03)
|
1150
|
+
#define GC_GUARDED_PTR_P(p) (((VALUE)(p)) & 0x01)
|
1151
|
+
|
1152
|
+
enum {
|
1153
|
+
/* Frame/Environment flag bits:
|
1154
|
+
* MMMM MMMM MMMM MMMM ____ _FFF FFFF EEEX (LSB)
|
1155
|
+
*
|
1156
|
+
* X : tag for GC marking (It seems as Fixnum)
|
1157
|
+
* EEE : 3 bits Env flags
|
1158
|
+
* FF..: 7 bits Frame flags
|
1159
|
+
* MM..: 15 bits frame magic (to check frame corruption)
|
1160
|
+
*/
|
1161
|
+
|
1162
|
+
/* frame types */
|
1163
|
+
VM_FRAME_MAGIC_METHOD = 0x11110001,
|
1164
|
+
VM_FRAME_MAGIC_BLOCK = 0x22220001,
|
1165
|
+
VM_FRAME_MAGIC_CLASS = 0x33330001,
|
1166
|
+
VM_FRAME_MAGIC_TOP = 0x44440001,
|
1167
|
+
VM_FRAME_MAGIC_CFUNC = 0x55550001,
|
1168
|
+
VM_FRAME_MAGIC_IFUNC = 0x66660001,
|
1169
|
+
VM_FRAME_MAGIC_EVAL = 0x77770001,
|
1170
|
+
VM_FRAME_MAGIC_RESCUE = 0x78880001,
|
1171
|
+
VM_FRAME_MAGIC_DUMMY = 0x79990001,
|
1172
|
+
|
1173
|
+
VM_FRAME_MAGIC_MASK = 0x7fff0001,
|
1174
|
+
|
1175
|
+
/* frame flag */
|
1176
|
+
VM_FRAME_FLAG_FINISH = 0x0020,
|
1177
|
+
VM_FRAME_FLAG_BMETHOD = 0x0040,
|
1178
|
+
VM_FRAME_FLAG_CFRAME = 0x0080,
|
1179
|
+
VM_FRAME_FLAG_LAMBDA = 0x0100,
|
1180
|
+
VM_FRAME_FLAG_MODIFIED_BLOCK_PARAM = 0x0200,
|
1181
|
+
VM_FRAME_FLAG_CFRAME_KW = 0x0400,
|
1182
|
+
VM_FRAME_FLAG_PASSED = 0x0800,
|
1183
|
+
|
1184
|
+
/* env flag */
|
1185
|
+
VM_ENV_FLAG_LOCAL = 0x0002,
|
1186
|
+
VM_ENV_FLAG_ESCAPED = 0x0004,
|
1187
|
+
VM_ENV_FLAG_WB_REQUIRED = 0x0008,
|
1188
|
+
VM_ENV_FLAG_ISOLATED = 0x0010,
|
1189
|
+
};
|
1190
|
+
|
1191
|
+
#define VM_ENV_DATA_SIZE ( 3)
|
1192
|
+
|
1193
|
+
#define VM_ENV_DATA_INDEX_ME_CREF (-2) /* ep[-2] */
|
1194
|
+
#define VM_ENV_DATA_INDEX_SPECVAL (-1) /* ep[-1] */
|
1195
|
+
#define VM_ENV_DATA_INDEX_FLAGS ( 0) /* ep[ 0] */
|
1196
|
+
#define VM_ENV_DATA_INDEX_ENV ( 1) /* ep[ 1] */
|
1197
|
+
|
1198
|
+
#define VM_ENV_INDEX_LAST_LVAR (-VM_ENV_DATA_SIZE)
|
1199
|
+
|
1200
|
+
static inline void VM_FORCE_WRITE_SPECIAL_CONST(const VALUE *ptr, VALUE special_const_value);
|
1201
|
+
|
1202
|
+
static inline void
|
1203
|
+
VM_ENV_FLAGS_SET(const VALUE *ep, VALUE flag)
|
1204
|
+
{
|
1205
|
+
VALUE flags = ep[VM_ENV_DATA_INDEX_FLAGS];
|
1206
|
+
VM_ASSERT(FIXNUM_P(flags));
|
1207
|
+
VM_FORCE_WRITE_SPECIAL_CONST(&ep[VM_ENV_DATA_INDEX_FLAGS], flags | flag);
|
1208
|
+
}
|
1209
|
+
|
1210
|
+
static inline void
|
1211
|
+
VM_ENV_FLAGS_UNSET(const VALUE *ep, VALUE flag)
|
1212
|
+
{
|
1213
|
+
VALUE flags = ep[VM_ENV_DATA_INDEX_FLAGS];
|
1214
|
+
VM_ASSERT(FIXNUM_P(flags));
|
1215
|
+
VM_FORCE_WRITE_SPECIAL_CONST(&ep[VM_ENV_DATA_INDEX_FLAGS], flags & ~flag);
|
1216
|
+
}
|
1217
|
+
|
1218
|
+
static inline unsigned long
|
1219
|
+
VM_ENV_FLAGS(const VALUE *ep, long flag)
|
1220
|
+
{
|
1221
|
+
VALUE flags = ep[VM_ENV_DATA_INDEX_FLAGS];
|
1222
|
+
VM_ASSERT(FIXNUM_P(flags));
|
1223
|
+
return flags & flag;
|
1224
|
+
}
|
1225
|
+
|
1226
|
+
static inline unsigned long
|
1227
|
+
VM_FRAME_TYPE(const rb_control_frame_t *cfp)
|
1228
|
+
{
|
1229
|
+
return VM_ENV_FLAGS(cfp->ep, VM_FRAME_MAGIC_MASK);
|
1230
|
+
}
|
1231
|
+
|
1232
|
+
static inline int
|
1233
|
+
VM_FRAME_LAMBDA_P(const rb_control_frame_t *cfp)
|
1234
|
+
{
|
1235
|
+
return VM_ENV_FLAGS(cfp->ep, VM_FRAME_FLAG_LAMBDA) != 0;
|
1236
|
+
}
|
1237
|
+
|
1238
|
+
static inline int
|
1239
|
+
VM_FRAME_CFRAME_KW_P(const rb_control_frame_t *cfp)
|
1240
|
+
{
|
1241
|
+
return VM_ENV_FLAGS(cfp->ep, VM_FRAME_FLAG_CFRAME_KW) != 0;
|
1242
|
+
}
|
1243
|
+
|
1244
|
+
static inline int
|
1245
|
+
VM_FRAME_FINISHED_P(const rb_control_frame_t *cfp)
|
1246
|
+
{
|
1247
|
+
return VM_ENV_FLAGS(cfp->ep, VM_FRAME_FLAG_FINISH) != 0;
|
1248
|
+
}
|
1249
|
+
|
1250
|
+
static inline int
|
1251
|
+
VM_FRAME_BMETHOD_P(const rb_control_frame_t *cfp)
|
1252
|
+
{
|
1253
|
+
return VM_ENV_FLAGS(cfp->ep, VM_FRAME_FLAG_BMETHOD) != 0;
|
1254
|
+
}
|
1255
|
+
|
1256
|
+
static inline int
|
1257
|
+
rb_obj_is_iseq(VALUE iseq)
|
1258
|
+
{
|
1259
|
+
return imemo_type_p(iseq, imemo_iseq);
|
1260
|
+
}
|
1261
|
+
|
1262
|
+
#if VM_CHECK_MODE > 0
|
1263
|
+
#define RUBY_VM_NORMAL_ISEQ_P(iseq) rb_obj_is_iseq((VALUE)iseq)
|
1264
|
+
#endif
|
1265
|
+
|
1266
|
+
static inline int
|
1267
|
+
VM_FRAME_CFRAME_P(const rb_control_frame_t *cfp)
|
1268
|
+
{
|
1269
|
+
int cframe_p = VM_ENV_FLAGS(cfp->ep, VM_FRAME_FLAG_CFRAME) != 0;
|
1270
|
+
VM_ASSERT(RUBY_VM_NORMAL_ISEQ_P(cfp->iseq) != cframe_p);
|
1271
|
+
return cframe_p;
|
1272
|
+
}
|
1273
|
+
|
1274
|
+
static inline int
|
1275
|
+
VM_FRAME_RUBYFRAME_P(const rb_control_frame_t *cfp)
|
1276
|
+
{
|
1277
|
+
return !VM_FRAME_CFRAME_P(cfp);
|
1278
|
+
}
|
1279
|
+
|
1280
|
+
#define RUBYVM_CFUNC_FRAME_P(cfp) \
|
1281
|
+
(VM_FRAME_TYPE(cfp) == VM_FRAME_MAGIC_CFUNC)
|
1282
|
+
|
1283
|
+
#define VM_GUARDED_PREV_EP(ep) GC_GUARDED_PTR(ep)
|
1284
|
+
#define VM_BLOCK_HANDLER_NONE 0
|
1285
|
+
|
1286
|
+
static inline int
|
1287
|
+
VM_ENV_LOCAL_P(const VALUE *ep)
|
1288
|
+
{
|
1289
|
+
return VM_ENV_FLAGS(ep, VM_ENV_FLAG_LOCAL) ? 1 : 0;
|
1290
|
+
}
|
1291
|
+
|
1292
|
+
static inline const VALUE *
|
1293
|
+
VM_ENV_PREV_EP(const VALUE *ep)
|
1294
|
+
{
|
1295
|
+
VM_ASSERT(VM_ENV_LOCAL_P(ep) == 0);
|
1296
|
+
return GC_GUARDED_PTR_REF(ep[VM_ENV_DATA_INDEX_SPECVAL]);
|
1297
|
+
}
|
1298
|
+
|
1299
|
+
static inline VALUE
|
1300
|
+
VM_ENV_BLOCK_HANDLER(const VALUE *ep)
|
1301
|
+
{
|
1302
|
+
VM_ASSERT(VM_ENV_LOCAL_P(ep));
|
1303
|
+
return ep[VM_ENV_DATA_INDEX_SPECVAL];
|
1304
|
+
}
|
1305
|
+
|
1306
|
+
#if VM_CHECK_MODE > 0
|
1307
|
+
int rb_vm_ep_in_heap_p(const VALUE *ep);
|
1308
|
+
#endif
|
1309
|
+
|
1310
|
+
static inline int
|
1311
|
+
VM_ENV_ESCAPED_P(const VALUE *ep)
|
1312
|
+
{
|
1313
|
+
VM_ASSERT(rb_vm_ep_in_heap_p(ep) == !!VM_ENV_FLAGS(ep, VM_ENV_FLAG_ESCAPED));
|
1314
|
+
return VM_ENV_FLAGS(ep, VM_ENV_FLAG_ESCAPED) ? 1 : 0;
|
1315
|
+
}
|
1316
|
+
|
1317
|
+
#if VM_CHECK_MODE > 0
|
1318
|
+
static inline int
|
1319
|
+
vm_assert_env(VALUE obj)
|
1320
|
+
{
|
1321
|
+
VM_ASSERT(imemo_type_p(obj, imemo_env));
|
1322
|
+
return 1;
|
1323
|
+
}
|
1324
|
+
#endif
|
1325
|
+
|
1326
|
+
static inline VALUE
|
1327
|
+
VM_ENV_ENVVAL(const VALUE *ep)
|
1328
|
+
{
|
1329
|
+
VALUE envval = ep[VM_ENV_DATA_INDEX_ENV];
|
1330
|
+
VM_ASSERT(VM_ENV_ESCAPED_P(ep));
|
1331
|
+
VM_ASSERT(vm_assert_env(envval));
|
1332
|
+
return envval;
|
1333
|
+
}
|
1334
|
+
|
1335
|
+
static inline const rb_env_t *
|
1336
|
+
VM_ENV_ENVVAL_PTR(const VALUE *ep)
|
1337
|
+
{
|
1338
|
+
return (const rb_env_t *)VM_ENV_ENVVAL(ep);
|
1339
|
+
}
|
1340
|
+
|
1341
|
+
static inline const rb_env_t *
|
1342
|
+
vm_env_new(VALUE *env_ep, VALUE *env_body, unsigned int env_size, const rb_iseq_t *iseq)
|
1343
|
+
{
|
1344
|
+
rb_env_t *env = (rb_env_t *)rb_imemo_new(imemo_env, (VALUE)env_ep, (VALUE)env_body, 0, (VALUE)iseq);
|
1345
|
+
env->env_size = env_size;
|
1346
|
+
env_ep[VM_ENV_DATA_INDEX_ENV] = (VALUE)env;
|
1347
|
+
return env;
|
1348
|
+
}
|
1349
|
+
|
1350
|
+
static inline void
|
1351
|
+
VM_FORCE_WRITE(const VALUE *ptr, VALUE v)
|
1352
|
+
{
|
1353
|
+
*((VALUE *)ptr) = v;
|
1354
|
+
}
|
1355
|
+
|
1356
|
+
static inline void
|
1357
|
+
VM_FORCE_WRITE_SPECIAL_CONST(const VALUE *ptr, VALUE special_const_value)
|
1358
|
+
{
|
1359
|
+
VM_ASSERT(RB_SPECIAL_CONST_P(special_const_value));
|
1360
|
+
VM_FORCE_WRITE(ptr, special_const_value);
|
1361
|
+
}
|
1362
|
+
|
1363
|
+
static inline void
|
1364
|
+
VM_STACK_ENV_WRITE(const VALUE *ep, int index, VALUE v)
|
1365
|
+
{
|
1366
|
+
VM_ASSERT(VM_ENV_FLAGS(ep, VM_ENV_FLAG_WB_REQUIRED) == 0);
|
1367
|
+
VM_FORCE_WRITE(&ep[index], v);
|
1368
|
+
}
|
1369
|
+
|
1370
|
+
const VALUE *rb_vm_ep_local_ep(const VALUE *ep);
|
1371
|
+
const VALUE *rb_vm_proc_local_ep(VALUE proc);
|
1372
|
+
void rb_vm_block_ep_update(VALUE obj, const struct rb_block *dst, const VALUE *ep);
|
1373
|
+
void rb_vm_block_copy(VALUE obj, const struct rb_block *dst, const struct rb_block *src);
|
1374
|
+
|
1375
|
+
VALUE rb_vm_frame_block_handler(const rb_control_frame_t *cfp);
|
1376
|
+
|
1377
|
+
#define RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp) ((cfp)+1)
|
1378
|
+
#define RUBY_VM_NEXT_CONTROL_FRAME(cfp) ((cfp)-1)
|
1379
|
+
|
1380
|
+
#define RUBY_VM_VALID_CONTROL_FRAME_P(cfp, ecfp) \
|
1381
|
+
((void *)(ecfp) > (void *)(cfp))
|
1382
|
+
|
1383
|
+
static inline const rb_control_frame_t *
|
1384
|
+
RUBY_VM_END_CONTROL_FRAME(const rb_execution_context_t *ec)
|
1385
|
+
{
|
1386
|
+
return (rb_control_frame_t *)(ec->vm_stack + ec->vm_stack_size);
|
1387
|
+
}
|
1388
|
+
|
1389
|
+
static inline int
|
1390
|
+
RUBY_VM_CONTROL_FRAME_STACK_OVERFLOW_P(const rb_execution_context_t *ec, const rb_control_frame_t *cfp)
|
1391
|
+
{
|
1392
|
+
return !RUBY_VM_VALID_CONTROL_FRAME_P(cfp, RUBY_VM_END_CONTROL_FRAME(ec));
|
1393
|
+
}
|
1394
|
+
|
1395
|
+
static inline int
|
1396
|
+
VM_BH_ISEQ_BLOCK_P(VALUE block_handler)
|
1397
|
+
{
|
1398
|
+
if ((block_handler & 0x03) == 0x01) {
|
1399
|
+
#if VM_CHECK_MODE > 0
|
1400
|
+
struct rb_captured_block *captured = VM_TAGGED_PTR_REF(block_handler, 0x03);
|
1401
|
+
VM_ASSERT(imemo_type_p(captured->code.val, imemo_iseq));
|
1402
|
+
#endif
|
1403
|
+
return 1;
|
1404
|
+
}
|
1405
|
+
else {
|
1406
|
+
return 0;
|
1407
|
+
}
|
1408
|
+
}
|
1409
|
+
|
1410
|
+
static inline VALUE
|
1411
|
+
VM_BH_FROM_ISEQ_BLOCK(const struct rb_captured_block *captured)
|
1412
|
+
{
|
1413
|
+
VALUE block_handler = VM_TAGGED_PTR_SET(captured, 0x01);
|
1414
|
+
VM_ASSERT(VM_BH_ISEQ_BLOCK_P(block_handler));
|
1415
|
+
return block_handler;
|
1416
|
+
}
|
1417
|
+
|
1418
|
+
static inline const struct rb_captured_block *
|
1419
|
+
VM_BH_TO_ISEQ_BLOCK(VALUE block_handler)
|
1420
|
+
{
|
1421
|
+
struct rb_captured_block *captured = VM_TAGGED_PTR_REF(block_handler, 0x03);
|
1422
|
+
VM_ASSERT(VM_BH_ISEQ_BLOCK_P(block_handler));
|
1423
|
+
return captured;
|
1424
|
+
}
|
1425
|
+
|
1426
|
+
static inline int
|
1427
|
+
VM_BH_IFUNC_P(VALUE block_handler)
|
1428
|
+
{
|
1429
|
+
if ((block_handler & 0x03) == 0x03) {
|
1430
|
+
#if VM_CHECK_MODE > 0
|
1431
|
+
struct rb_captured_block *captured = (void *)(block_handler & ~0x03);
|
1432
|
+
VM_ASSERT(imemo_type_p(captured->code.val, imemo_ifunc));
|
1433
|
+
#endif
|
1434
|
+
return 1;
|
1435
|
+
}
|
1436
|
+
else {
|
1437
|
+
return 0;
|
1438
|
+
}
|
1439
|
+
}
|
1440
|
+
|
1441
|
+
static inline VALUE
|
1442
|
+
VM_BH_FROM_IFUNC_BLOCK(const struct rb_captured_block *captured)
|
1443
|
+
{
|
1444
|
+
VALUE block_handler = VM_TAGGED_PTR_SET(captured, 0x03);
|
1445
|
+
VM_ASSERT(VM_BH_IFUNC_P(block_handler));
|
1446
|
+
return block_handler;
|
1447
|
+
}
|
1448
|
+
|
1449
|
+
static inline const struct rb_captured_block *
|
1450
|
+
VM_BH_TO_IFUNC_BLOCK(VALUE block_handler)
|
1451
|
+
{
|
1452
|
+
struct rb_captured_block *captured = VM_TAGGED_PTR_REF(block_handler, 0x03);
|
1453
|
+
VM_ASSERT(VM_BH_IFUNC_P(block_handler));
|
1454
|
+
return captured;
|
1455
|
+
}
|
1456
|
+
|
1457
|
+
static inline const struct rb_captured_block *
|
1458
|
+
VM_BH_TO_CAPT_BLOCK(VALUE block_handler)
|
1459
|
+
{
|
1460
|
+
struct rb_captured_block *captured = VM_TAGGED_PTR_REF(block_handler, 0x03);
|
1461
|
+
VM_ASSERT(VM_BH_IFUNC_P(block_handler) || VM_BH_ISEQ_BLOCK_P(block_handler));
|
1462
|
+
return captured;
|
1463
|
+
}
|
1464
|
+
|
1465
|
+
static inline enum rb_block_handler_type
|
1466
|
+
vm_block_handler_type(VALUE block_handler)
|
1467
|
+
{
|
1468
|
+
if (VM_BH_ISEQ_BLOCK_P(block_handler)) {
|
1469
|
+
return block_handler_type_iseq;
|
1470
|
+
}
|
1471
|
+
else if (VM_BH_IFUNC_P(block_handler)) {
|
1472
|
+
return block_handler_type_ifunc;
|
1473
|
+
}
|
1474
|
+
else if (SYMBOL_P(block_handler)) {
|
1475
|
+
return block_handler_type_symbol;
|
1476
|
+
}
|
1477
|
+
else {
|
1478
|
+
VM_ASSERT(rb_obj_is_proc(block_handler));
|
1479
|
+
return block_handler_type_proc;
|
1480
|
+
}
|
1481
|
+
}
|
1482
|
+
|
1483
|
+
static inline void
|
1484
|
+
vm_block_handler_verify(MAYBE_UNUSED(VALUE block_handler))
|
1485
|
+
{
|
1486
|
+
VM_ASSERT(block_handler == VM_BLOCK_HANDLER_NONE ||
|
1487
|
+
(vm_block_handler_type(block_handler), 1));
|
1488
|
+
}
|
1489
|
+
|
1490
|
+
static inline int
|
1491
|
+
vm_cfp_forwarded_bh_p(const rb_control_frame_t *cfp, VALUE block_handler)
|
1492
|
+
{
|
1493
|
+
return ((VALUE) cfp->block_code) == block_handler;
|
1494
|
+
}
|
1495
|
+
|
1496
|
+
static inline enum rb_block_type
|
1497
|
+
vm_block_type(const struct rb_block *block)
|
1498
|
+
{
|
1499
|
+
#if VM_CHECK_MODE > 0
|
1500
|
+
switch (block->type) {
|
1501
|
+
case block_type_iseq:
|
1502
|
+
VM_ASSERT(imemo_type_p(block->as.captured.code.val, imemo_iseq));
|
1503
|
+
break;
|
1504
|
+
case block_type_ifunc:
|
1505
|
+
VM_ASSERT(imemo_type_p(block->as.captured.code.val, imemo_ifunc));
|
1506
|
+
break;
|
1507
|
+
case block_type_symbol:
|
1508
|
+
VM_ASSERT(SYMBOL_P(block->as.symbol));
|
1509
|
+
break;
|
1510
|
+
case block_type_proc:
|
1511
|
+
VM_ASSERT(rb_obj_is_proc(block->as.proc));
|
1512
|
+
break;
|
1513
|
+
}
|
1514
|
+
#endif
|
1515
|
+
return block->type;
|
1516
|
+
}
|
1517
|
+
|
1518
|
+
static inline void
|
1519
|
+
vm_block_type_set(const struct rb_block *block, enum rb_block_type type)
|
1520
|
+
{
|
1521
|
+
struct rb_block *mb = (struct rb_block *)block;
|
1522
|
+
mb->type = type;
|
1523
|
+
}
|
1524
|
+
|
1525
|
+
static inline const struct rb_block *
|
1526
|
+
vm_proc_block(VALUE procval)
|
1527
|
+
{
|
1528
|
+
VM_ASSERT(rb_obj_is_proc(procval));
|
1529
|
+
return &((rb_proc_t *)RTYPEDDATA_DATA(procval))->block;
|
1530
|
+
}
|
1531
|
+
|
1532
|
+
static inline const rb_iseq_t *vm_block_iseq(const struct rb_block *block);
|
1533
|
+
static inline const VALUE *vm_block_ep(const struct rb_block *block);
|
1534
|
+
|
1535
|
+
static inline const rb_iseq_t *
|
1536
|
+
vm_proc_iseq(VALUE procval)
|
1537
|
+
{
|
1538
|
+
return vm_block_iseq(vm_proc_block(procval));
|
1539
|
+
}
|
1540
|
+
|
1541
|
+
static inline const VALUE *
|
1542
|
+
vm_proc_ep(VALUE procval)
|
1543
|
+
{
|
1544
|
+
return vm_block_ep(vm_proc_block(procval));
|
1545
|
+
}
|
1546
|
+
|
1547
|
+
static inline const rb_iseq_t *
|
1548
|
+
vm_block_iseq(const struct rb_block *block)
|
1549
|
+
{
|
1550
|
+
switch (vm_block_type(block)) {
|
1551
|
+
case block_type_iseq: return rb_iseq_check(block->as.captured.code.iseq);
|
1552
|
+
case block_type_proc: return vm_proc_iseq(block->as.proc);
|
1553
|
+
case block_type_ifunc:
|
1554
|
+
case block_type_symbol: return NULL;
|
1555
|
+
}
|
1556
|
+
VM_UNREACHABLE(vm_block_iseq);
|
1557
|
+
return NULL;
|
1558
|
+
}
|
1559
|
+
|
1560
|
+
static inline const VALUE *
|
1561
|
+
vm_block_ep(const struct rb_block *block)
|
1562
|
+
{
|
1563
|
+
switch (vm_block_type(block)) {
|
1564
|
+
case block_type_iseq:
|
1565
|
+
case block_type_ifunc: return block->as.captured.ep;
|
1566
|
+
case block_type_proc: return vm_proc_ep(block->as.proc);
|
1567
|
+
case block_type_symbol: return NULL;
|
1568
|
+
}
|
1569
|
+
VM_UNREACHABLE(vm_block_ep);
|
1570
|
+
return NULL;
|
1571
|
+
}
|
1572
|
+
|
1573
|
+
static inline VALUE
|
1574
|
+
vm_block_self(const struct rb_block *block)
|
1575
|
+
{
|
1576
|
+
switch (vm_block_type(block)) {
|
1577
|
+
case block_type_iseq:
|
1578
|
+
case block_type_ifunc:
|
1579
|
+
return block->as.captured.self;
|
1580
|
+
case block_type_proc:
|
1581
|
+
return vm_block_self(vm_proc_block(block->as.proc));
|
1582
|
+
case block_type_symbol:
|
1583
|
+
return Qundef;
|
1584
|
+
}
|
1585
|
+
VM_UNREACHABLE(vm_block_self);
|
1586
|
+
return Qundef;
|
1587
|
+
}
|
1588
|
+
|
1589
|
+
static inline VALUE
|
1590
|
+
VM_BH_TO_SYMBOL(VALUE block_handler)
|
1591
|
+
{
|
1592
|
+
VM_ASSERT(SYMBOL_P(block_handler));
|
1593
|
+
return block_handler;
|
1594
|
+
}
|
1595
|
+
|
1596
|
+
static inline VALUE
|
1597
|
+
VM_BH_FROM_SYMBOL(VALUE symbol)
|
1598
|
+
{
|
1599
|
+
VM_ASSERT(SYMBOL_P(symbol));
|
1600
|
+
return symbol;
|
1601
|
+
}
|
1602
|
+
|
1603
|
+
static inline VALUE
|
1604
|
+
VM_BH_TO_PROC(VALUE block_handler)
|
1605
|
+
{
|
1606
|
+
VM_ASSERT(rb_obj_is_proc(block_handler));
|
1607
|
+
return block_handler;
|
1608
|
+
}
|
1609
|
+
|
1610
|
+
static inline VALUE
|
1611
|
+
VM_BH_FROM_PROC(VALUE procval)
|
1612
|
+
{
|
1613
|
+
VM_ASSERT(rb_obj_is_proc(procval));
|
1614
|
+
return procval;
|
1615
|
+
}
|
1616
|
+
|
1617
|
+
/* VM related object allocate functions */
|
1618
|
+
VALUE rb_thread_alloc(VALUE klass);
|
1619
|
+
VALUE rb_binding_alloc(VALUE klass);
|
1620
|
+
VALUE rb_proc_alloc(VALUE klass);
|
1621
|
+
VALUE rb_proc_dup(VALUE self);
|
1622
|
+
|
1623
|
+
/* for debug */
|
1624
|
+
extern void rb_vmdebug_stack_dump_raw(const rb_execution_context_t *ec, const rb_control_frame_t *cfp);
|
1625
|
+
extern void rb_vmdebug_debug_print_pre(const rb_execution_context_t *ec, const rb_control_frame_t *cfp, const VALUE *_pc);
|
1626
|
+
extern void rb_vmdebug_debug_print_post(const rb_execution_context_t *ec, const rb_control_frame_t *cfp
|
1627
|
+
#if OPT_STACK_CACHING
|
1628
|
+
, VALUE reg_a, VALUE reg_b
|
1629
|
+
#endif
|
1630
|
+
);
|
1631
|
+
|
1632
|
+
#define SDR() rb_vmdebug_stack_dump_raw(GET_EC(), GET_EC()->cfp)
|
1633
|
+
#define SDR2(cfp) rb_vmdebug_stack_dump_raw(GET_EC(), (cfp))
|
1634
|
+
void rb_vm_bugreport(const void *);
|
1635
|
+
typedef void (*ruby_sighandler_t)(int);
|
1636
|
+
NORETURN(void rb_bug_for_fatal_signal(ruby_sighandler_t default_sighandler, int sig, const void *, const char *fmt, ...));
|
1637
|
+
|
1638
|
+
/* functions about thread/vm execution */
|
1639
|
+
RUBY_SYMBOL_EXPORT_BEGIN
|
1640
|
+
VALUE rb_iseq_eval(const rb_iseq_t *iseq);
|
1641
|
+
VALUE rb_iseq_eval_main(const rb_iseq_t *iseq);
|
1642
|
+
VALUE rb_iseq_path(const rb_iseq_t *iseq);
|
1643
|
+
VALUE rb_iseq_realpath(const rb_iseq_t *iseq);
|
1644
|
+
RUBY_SYMBOL_EXPORT_END
|
1645
|
+
|
1646
|
+
VALUE rb_iseq_pathobj_new(VALUE path, VALUE realpath);
|
1647
|
+
void rb_iseq_pathobj_set(const rb_iseq_t *iseq, VALUE path, VALUE realpath);
|
1648
|
+
|
1649
|
+
int rb_ec_frame_method_id_and_class(const rb_execution_context_t *ec, ID *idp, ID *called_idp, VALUE *klassp);
|
1650
|
+
void rb_ec_setup_exception(const rb_execution_context_t *ec, VALUE mesg, VALUE cause);
|
1651
|
+
|
1652
|
+
VALUE rb_vm_invoke_proc(rb_execution_context_t *ec, rb_proc_t *proc, int argc, const VALUE *argv, int kw_splat, VALUE block_handler);
|
1653
|
+
|
1654
|
+
VALUE rb_vm_make_proc_lambda(const rb_execution_context_t *ec, const struct rb_captured_block *captured, VALUE klass, int8_t is_lambda);
|
1655
|
+
static inline VALUE
|
1656
|
+
rb_vm_make_proc(const rb_execution_context_t *ec, const struct rb_captured_block *captured, VALUE klass)
|
1657
|
+
{
|
1658
|
+
return rb_vm_make_proc_lambda(ec, captured, klass, 0);
|
1659
|
+
}
|
1660
|
+
|
1661
|
+
static inline VALUE
|
1662
|
+
rb_vm_make_lambda(const rb_execution_context_t *ec, const struct rb_captured_block *captured, VALUE klass)
|
1663
|
+
{
|
1664
|
+
return rb_vm_make_proc_lambda(ec, captured, klass, 1);
|
1665
|
+
}
|
1666
|
+
|
1667
|
+
VALUE rb_vm_make_binding(const rb_execution_context_t *ec, const rb_control_frame_t *src_cfp);
|
1668
|
+
VALUE rb_vm_env_local_variables(const rb_env_t *env);
|
1669
|
+
const rb_env_t *rb_vm_env_prev_env(const rb_env_t *env);
|
1670
|
+
const VALUE *rb_binding_add_dynavars(VALUE bindval, rb_binding_t *bind, int dyncount, const ID *dynvars);
|
1671
|
+
void rb_vm_inc_const_missing_count(void);
|
1672
|
+
VALUE rb_vm_call_kw(rb_execution_context_t *ec, VALUE recv, VALUE id, int argc,
|
1673
|
+
const VALUE *argv, const rb_callable_method_entry_t *me, int kw_splat);
|
1674
|
+
MJIT_STATIC void rb_vm_pop_frame(rb_execution_context_t *ec);
|
1675
|
+
|
1676
|
+
void rb_gvl_destroy(rb_global_vm_lock_t *gvl);
|
1677
|
+
|
1678
|
+
void rb_thread_start_timer_thread(void);
|
1679
|
+
void rb_thread_stop_timer_thread(void);
|
1680
|
+
void rb_thread_reset_timer_thread(void);
|
1681
|
+
void rb_thread_wakeup_timer_thread(int);
|
1682
|
+
|
1683
|
+
static inline void
|
1684
|
+
rb_vm_living_threads_init(rb_vm_t *vm)
|
1685
|
+
{
|
1686
|
+
list_head_init(&vm->waiting_fds);
|
1687
|
+
list_head_init(&vm->waiting_pids);
|
1688
|
+
list_head_init(&vm->workqueue);
|
1689
|
+
list_head_init(&vm->waiting_grps);
|
1690
|
+
list_head_init(&vm->ractor.set);
|
1691
|
+
}
|
1692
|
+
|
1693
|
+
typedef int rb_backtrace_iter_func(void *, VALUE, int, VALUE);
|
1694
|
+
rb_control_frame_t *rb_vm_get_ruby_level_next_cfp(const rb_execution_context_t *ec, const rb_control_frame_t *cfp);
|
1695
|
+
rb_control_frame_t *rb_vm_get_binding_creatable_next_cfp(const rb_execution_context_t *ec, const rb_control_frame_t *cfp);
|
1696
|
+
int rb_vm_get_sourceline(const rb_control_frame_t *);
|
1697
|
+
void rb_vm_stack_to_heap(rb_execution_context_t *ec);
|
1698
|
+
void ruby_thread_init_stack(rb_thread_t *th);
|
1699
|
+
int rb_vm_control_frame_id_and_class(const rb_control_frame_t *cfp, ID *idp, ID *called_idp, VALUE *klassp);
|
1700
|
+
void rb_vm_rewind_cfp(rb_execution_context_t *ec, rb_control_frame_t *cfp);
|
1701
|
+
MJIT_STATIC VALUE rb_vm_bh_to_procval(const rb_execution_context_t *ec, VALUE block_handler);
|
1702
|
+
|
1703
|
+
void rb_vm_register_special_exception_str(enum ruby_special_exceptions sp, VALUE exception_class, VALUE mesg);
|
1704
|
+
|
1705
|
+
#define rb_vm_register_special_exception(sp, e, m) \
|
1706
|
+
rb_vm_register_special_exception_str(sp, e, rb_usascii_str_new_static((m), (long)rb_strlen_lit(m)))
|
1707
|
+
|
1708
|
+
void rb_gc_mark_machine_stack(const rb_execution_context_t *ec);
|
1709
|
+
|
1710
|
+
void rb_vm_rewrite_cref(rb_cref_t *node, VALUE old_klass, VALUE new_klass, rb_cref_t **new_cref_ptr);
|
1711
|
+
|
1712
|
+
MJIT_STATIC const rb_callable_method_entry_t *rb_vm_frame_method_entry(const rb_control_frame_t *cfp);
|
1713
|
+
|
1714
|
+
#define sysstack_error GET_VM()->special_exceptions[ruby_error_sysstack]
|
1715
|
+
|
1716
|
+
#define CHECK_VM_STACK_OVERFLOW0(cfp, sp, margin) do { \
|
1717
|
+
STATIC_ASSERT(sizeof_sp, sizeof(*(sp)) == sizeof(VALUE)); \
|
1718
|
+
STATIC_ASSERT(sizeof_cfp, sizeof(*(cfp)) == sizeof(rb_control_frame_t)); \
|
1719
|
+
const struct rb_control_frame_struct *bound = (void *)&(sp)[(margin)]; \
|
1720
|
+
if (UNLIKELY((cfp) <= &bound[1])) { \
|
1721
|
+
vm_stackoverflow(); \
|
1722
|
+
} \
|
1723
|
+
} while (0)
|
1724
|
+
|
1725
|
+
#define CHECK_VM_STACK_OVERFLOW(cfp, margin) \
|
1726
|
+
CHECK_VM_STACK_OVERFLOW0((cfp), (cfp)->sp, (margin))
|
1727
|
+
|
1728
|
+
VALUE rb_catch_protect(VALUE t, rb_block_call_func *func, VALUE data, enum ruby_tag_type *stateptr);
|
1729
|
+
|
1730
|
+
rb_execution_context_t *rb_vm_main_ractor_ec(rb_vm_t *vm); // ractor.c
|
1731
|
+
|
1732
|
+
/* for thread */
|
1733
|
+
|
1734
|
+
#if RUBY_VM_THREAD_MODEL == 2
|
1735
|
+
RUBY_SYMBOL_EXPORT_BEGIN
|
1736
|
+
|
1737
|
+
RUBY_EXTERN struct rb_ractor_struct *ruby_single_main_ractor; // ractor.c
|
1738
|
+
RUBY_EXTERN rb_vm_t *ruby_current_vm_ptr;
|
1739
|
+
RUBY_EXTERN rb_event_flag_t ruby_vm_event_flags;
|
1740
|
+
RUBY_EXTERN rb_event_flag_t ruby_vm_event_enabled_global_flags;
|
1741
|
+
RUBY_EXTERN unsigned int ruby_vm_event_local_num;
|
1742
|
+
|
1743
|
+
RUBY_SYMBOL_EXPORT_END
|
1744
|
+
|
1745
|
+
#define GET_VM() rb_current_vm()
|
1746
|
+
#define GET_RACTOR() rb_current_ractor()
|
1747
|
+
#define GET_THREAD() rb_current_thread()
|
1748
|
+
#define GET_EC() rb_current_execution_context()
|
1749
|
+
|
1750
|
+
static inline rb_thread_t *
|
1751
|
+
rb_ec_thread_ptr(const rb_execution_context_t *ec)
|
1752
|
+
{
|
1753
|
+
return ec->thread_ptr;
|
1754
|
+
}
|
1755
|
+
|
1756
|
+
static inline rb_ractor_t *
|
1757
|
+
rb_ec_ractor_ptr(const rb_execution_context_t *ec)
|
1758
|
+
{
|
1759
|
+
const rb_thread_t *th = rb_ec_thread_ptr(ec);
|
1760
|
+
if (th) {
|
1761
|
+
VM_ASSERT(th->ractor != NULL);
|
1762
|
+
return th->ractor;
|
1763
|
+
}
|
1764
|
+
else {
|
1765
|
+
return NULL;
|
1766
|
+
}
|
1767
|
+
}
|
1768
|
+
|
1769
|
+
static inline rb_vm_t *
|
1770
|
+
rb_ec_vm_ptr(const rb_execution_context_t *ec)
|
1771
|
+
{
|
1772
|
+
const rb_thread_t *th = rb_ec_thread_ptr(ec);
|
1773
|
+
if (th) {
|
1774
|
+
return th->vm;
|
1775
|
+
}
|
1776
|
+
else {
|
1777
|
+
return NULL;
|
1778
|
+
}
|
1779
|
+
}
|
1780
|
+
|
1781
|
+
static inline rb_execution_context_t *
|
1782
|
+
rb_current_execution_context(void)
|
1783
|
+
{
|
1784
|
+
#ifdef RB_THREAD_LOCAL_SPECIFIER
|
1785
|
+
#if __APPLE__
|
1786
|
+
rb_execution_context_t *ec = rb_current_ec();
|
1787
|
+
#else
|
1788
|
+
rb_execution_context_t *ec = ruby_current_ec;
|
1789
|
+
#endif
|
1790
|
+
#else
|
1791
|
+
rb_execution_context_t *ec = native_tls_get(ruby_current_ec_key);
|
1792
|
+
#endif
|
1793
|
+
VM_ASSERT(ec != NULL);
|
1794
|
+
return ec;
|
1795
|
+
}
|
1796
|
+
|
1797
|
+
static inline rb_thread_t *
|
1798
|
+
rb_current_thread(void)
|
1799
|
+
{
|
1800
|
+
const rb_execution_context_t *ec = GET_EC();
|
1801
|
+
return rb_ec_thread_ptr(ec);
|
1802
|
+
}
|
1803
|
+
|
1804
|
+
static inline rb_ractor_t *
|
1805
|
+
rb_current_ractor(void)
|
1806
|
+
{
|
1807
|
+
if (ruby_single_main_ractor) {
|
1808
|
+
return ruby_single_main_ractor;
|
1809
|
+
}
|
1810
|
+
else {
|
1811
|
+
const rb_execution_context_t *ec = GET_EC();
|
1812
|
+
return rb_ec_ractor_ptr(ec);
|
1813
|
+
}
|
1814
|
+
}
|
1815
|
+
|
1816
|
+
static inline rb_vm_t *
|
1817
|
+
rb_current_vm(void)
|
1818
|
+
{
|
1819
|
+
#if 0 // TODO: reconsider the assertions
|
1820
|
+
VM_ASSERT(ruby_current_vm_ptr == NULL ||
|
1821
|
+
ruby_current_execution_context_ptr == NULL ||
|
1822
|
+
rb_ec_thread_ptr(GET_EC()) == NULL ||
|
1823
|
+
rb_ec_thread_ptr(GET_EC())->status == THREAD_KILLED ||
|
1824
|
+
rb_ec_vm_ptr(GET_EC()) == ruby_current_vm_ptr);
|
1825
|
+
#endif
|
1826
|
+
|
1827
|
+
return ruby_current_vm_ptr;
|
1828
|
+
}
|
1829
|
+
|
1830
|
+
void rb_ec_vm_lock_rec_release(const rb_execution_context_t *ec,
|
1831
|
+
unsigned int recorded_lock_rec,
|
1832
|
+
unsigned int current_lock_rec);
|
1833
|
+
|
1834
|
+
static inline unsigned int
|
1835
|
+
rb_ec_vm_lock_rec(const rb_execution_context_t *ec)
|
1836
|
+
{
|
1837
|
+
rb_vm_t *vm = rb_ec_vm_ptr(ec);
|
1838
|
+
|
1839
|
+
if (vm->ractor.sync.lock_owner != rb_ec_ractor_ptr(ec)) {
|
1840
|
+
return 0;
|
1841
|
+
}
|
1842
|
+
else {
|
1843
|
+
return vm->ractor.sync.lock_rec;
|
1844
|
+
}
|
1845
|
+
}
|
1846
|
+
|
1847
|
+
#else
|
1848
|
+
#error "unsupported thread model"
|
1849
|
+
#endif
|
1850
|
+
|
1851
|
+
enum {
|
1852
|
+
TIMER_INTERRUPT_MASK = 0x01,
|
1853
|
+
PENDING_INTERRUPT_MASK = 0x02,
|
1854
|
+
POSTPONED_JOB_INTERRUPT_MASK = 0x04,
|
1855
|
+
TRAP_INTERRUPT_MASK = 0x08,
|
1856
|
+
TERMINATE_INTERRUPT_MASK = 0x10,
|
1857
|
+
VM_BARRIER_INTERRUPT_MASK = 0x20,
|
1858
|
+
};
|
1859
|
+
|
1860
|
+
#define RUBY_VM_SET_TIMER_INTERRUPT(ec) ATOMIC_OR((ec)->interrupt_flag, TIMER_INTERRUPT_MASK)
|
1861
|
+
#define RUBY_VM_SET_INTERRUPT(ec) ATOMIC_OR((ec)->interrupt_flag, PENDING_INTERRUPT_MASK)
|
1862
|
+
#define RUBY_VM_SET_POSTPONED_JOB_INTERRUPT(ec) ATOMIC_OR((ec)->interrupt_flag, POSTPONED_JOB_INTERRUPT_MASK)
|
1863
|
+
#define RUBY_VM_SET_TRAP_INTERRUPT(ec) ATOMIC_OR((ec)->interrupt_flag, TRAP_INTERRUPT_MASK)
|
1864
|
+
#define RUBY_VM_SET_TERMINATE_INTERRUPT(ec) ATOMIC_OR((ec)->interrupt_flag, TERMINATE_INTERRUPT_MASK)
|
1865
|
+
#define RUBY_VM_SET_VM_BARRIER_INTERRUPT(ec) ATOMIC_OR((ec)->interrupt_flag, VM_BARRIER_INTERRUPT_MASK)
|
1866
|
+
#define RUBY_VM_INTERRUPTED(ec) ((ec)->interrupt_flag & ~(ec)->interrupt_mask & \
|
1867
|
+
(PENDING_INTERRUPT_MASK|TRAP_INTERRUPT_MASK))
|
1868
|
+
|
1869
|
+
static inline bool
|
1870
|
+
RUBY_VM_INTERRUPTED_ANY(rb_execution_context_t *ec)
|
1871
|
+
{
|
1872
|
+
#if USE_VM_CLOCK
|
1873
|
+
uint32_t current_clock = rb_ec_vm_ptr(ec)->clock;
|
1874
|
+
|
1875
|
+
if (current_clock != ec->checked_clock) {
|
1876
|
+
ec->checked_clock = current_clock;
|
1877
|
+
RUBY_VM_SET_TIMER_INTERRUPT(ec);
|
1878
|
+
}
|
1879
|
+
#endif
|
1880
|
+
return ec->interrupt_flag & ~(ec)->interrupt_mask;
|
1881
|
+
}
|
1882
|
+
|
1883
|
+
VALUE rb_exc_set_backtrace(VALUE exc, VALUE bt);
|
1884
|
+
int rb_signal_buff_size(void);
|
1885
|
+
int rb_signal_exec(rb_thread_t *th, int sig);
|
1886
|
+
void rb_threadptr_check_signal(rb_thread_t *mth);
|
1887
|
+
void rb_threadptr_signal_raise(rb_thread_t *th, int sig);
|
1888
|
+
void rb_threadptr_signal_exit(rb_thread_t *th);
|
1889
|
+
int rb_threadptr_execute_interrupts(rb_thread_t *, int);
|
1890
|
+
void rb_threadptr_interrupt(rb_thread_t *th);
|
1891
|
+
void rb_threadptr_unlock_all_locking_mutexes(rb_thread_t *th);
|
1892
|
+
void rb_threadptr_pending_interrupt_clear(rb_thread_t *th);
|
1893
|
+
void rb_threadptr_pending_interrupt_enque(rb_thread_t *th, VALUE v);
|
1894
|
+
VALUE rb_ec_get_errinfo(const rb_execution_context_t *ec);
|
1895
|
+
void rb_ec_error_print(rb_execution_context_t * volatile ec, volatile VALUE errinfo);
|
1896
|
+
void rb_execution_context_update(const rb_execution_context_t *ec);
|
1897
|
+
void rb_execution_context_mark(const rb_execution_context_t *ec);
|
1898
|
+
void rb_fiber_close(rb_fiber_t *fib);
|
1899
|
+
void Init_native_thread(rb_thread_t *th);
|
1900
|
+
int rb_vm_check_ints_blocking(rb_execution_context_t *ec);
|
1901
|
+
|
1902
|
+
// vm_sync.h
|
1903
|
+
void rb_vm_cond_wait(rb_vm_t *vm, rb_nativethread_cond_t *cond);
|
1904
|
+
void rb_vm_cond_timedwait(rb_vm_t *vm, rb_nativethread_cond_t *cond, unsigned long msec);
|
1905
|
+
|
1906
|
+
#define RUBY_VM_CHECK_INTS(ec) rb_vm_check_ints(ec)
|
1907
|
+
static inline void
|
1908
|
+
rb_vm_check_ints(rb_execution_context_t *ec)
|
1909
|
+
{
|
1910
|
+
VM_ASSERT(ec == GET_EC());
|
1911
|
+
if (UNLIKELY(RUBY_VM_INTERRUPTED_ANY(ec))) {
|
1912
|
+
rb_threadptr_execute_interrupts(rb_ec_thread_ptr(ec), 0);
|
1913
|
+
}
|
1914
|
+
}
|
1915
|
+
|
1916
|
+
/* tracer */
|
1917
|
+
|
1918
|
+
struct rb_trace_arg_struct {
|
1919
|
+
rb_event_flag_t event;
|
1920
|
+
rb_execution_context_t *ec;
|
1921
|
+
const rb_control_frame_t *cfp;
|
1922
|
+
VALUE self;
|
1923
|
+
ID id;
|
1924
|
+
ID called_id;
|
1925
|
+
VALUE klass;
|
1926
|
+
VALUE data;
|
1927
|
+
|
1928
|
+
int klass_solved;
|
1929
|
+
|
1930
|
+
/* calc from cfp */
|
1931
|
+
int lineno;
|
1932
|
+
VALUE path;
|
1933
|
+
};
|
1934
|
+
|
1935
|
+
void rb_hook_list_mark(rb_hook_list_t *hooks);
|
1936
|
+
void rb_hook_list_free(rb_hook_list_t *hooks);
|
1937
|
+
void rb_hook_list_connect_tracepoint(VALUE target, rb_hook_list_t *list, VALUE tpval, unsigned int target_line);
|
1938
|
+
void rb_hook_list_remove_tracepoint(rb_hook_list_t *list, VALUE tpval);
|
1939
|
+
|
1940
|
+
void rb_exec_event_hooks(struct rb_trace_arg_struct *trace_arg, rb_hook_list_t *hooks, int pop_p);
|
1941
|
+
|
1942
|
+
#define EXEC_EVENT_HOOK_ORIG(ec_, hooks_, flag_, self_, id_, called_id_, klass_, data_, pop_p_) do { \
|
1943
|
+
const rb_event_flag_t flag_arg_ = (flag_); \
|
1944
|
+
rb_hook_list_t *hooks_arg_ = (hooks_); \
|
1945
|
+
if (UNLIKELY((hooks_arg_)->events & (flag_arg_))) { \
|
1946
|
+
/* defer evaluating the other arguments */ \
|
1947
|
+
rb_exec_event_hook_orig(ec_, hooks_arg_, flag_arg_, self_, id_, called_id_, klass_, data_, pop_p_); \
|
1948
|
+
} \
|
1949
|
+
} while (0)
|
1950
|
+
|
1951
|
+
static inline void
|
1952
|
+
rb_exec_event_hook_orig(rb_execution_context_t *ec, rb_hook_list_t *hooks, rb_event_flag_t flag,
|
1953
|
+
VALUE self, ID id, ID called_id, VALUE klass, VALUE data, int pop_p)
|
1954
|
+
{
|
1955
|
+
struct rb_trace_arg_struct trace_arg;
|
1956
|
+
|
1957
|
+
VM_ASSERT((hooks->events & flag) != 0);
|
1958
|
+
|
1959
|
+
trace_arg.event = flag;
|
1960
|
+
trace_arg.ec = ec;
|
1961
|
+
trace_arg.cfp = ec->cfp;
|
1962
|
+
trace_arg.self = self;
|
1963
|
+
trace_arg.id = id;
|
1964
|
+
trace_arg.called_id = called_id;
|
1965
|
+
trace_arg.klass = klass;
|
1966
|
+
trace_arg.data = data;
|
1967
|
+
trace_arg.path = Qundef;
|
1968
|
+
trace_arg.klass_solved = 0;
|
1969
|
+
|
1970
|
+
rb_exec_event_hooks(&trace_arg, hooks, pop_p);
|
1971
|
+
}
|
1972
|
+
|
1973
|
+
struct rb_ractor_pub {
|
1974
|
+
VALUE self;
|
1975
|
+
uint32_t id;
|
1976
|
+
rb_hook_list_t hooks;
|
1977
|
+
};
|
1978
|
+
|
1979
|
+
static inline rb_hook_list_t *
|
1980
|
+
rb_ec_ractor_hooks(const rb_execution_context_t *ec)
|
1981
|
+
{
|
1982
|
+
struct rb_ractor_pub *cr_pub = (struct rb_ractor_pub *)rb_ec_ractor_ptr(ec);
|
1983
|
+
return &cr_pub->hooks;
|
1984
|
+
}
|
1985
|
+
|
1986
|
+
#define EXEC_EVENT_HOOK(ec_, flag_, self_, id_, called_id_, klass_, data_) \
|
1987
|
+
EXEC_EVENT_HOOK_ORIG(ec_, rb_ec_ractor_hooks(ec_), flag_, self_, id_, called_id_, klass_, data_, 0)
|
1988
|
+
|
1989
|
+
#define EXEC_EVENT_HOOK_AND_POP_FRAME(ec_, flag_, self_, id_, called_id_, klass_, data_) \
|
1990
|
+
EXEC_EVENT_HOOK_ORIG(ec_, rb_ec_ractor_hooks(ec_), flag_, self_, id_, called_id_, klass_, data_, 1)
|
1991
|
+
|
1992
|
+
static inline void
|
1993
|
+
rb_exec_event_hook_script_compiled(rb_execution_context_t *ec, const rb_iseq_t *iseq, VALUE eval_script)
|
1994
|
+
{
|
1995
|
+
EXEC_EVENT_HOOK(ec, RUBY_EVENT_SCRIPT_COMPILED, ec->cfp->self, 0, 0, 0,
|
1996
|
+
NIL_P(eval_script) ? (VALUE)iseq :
|
1997
|
+
rb_ary_new_from_args(2, eval_script, (VALUE)iseq));
|
1998
|
+
}
|
1999
|
+
|
2000
|
+
void rb_vm_trap_exit(rb_vm_t *vm);
|
2001
|
+
|
2002
|
+
RUBY_SYMBOL_EXPORT_BEGIN
|
2003
|
+
|
2004
|
+
int rb_thread_check_trap_pending(void);
|
2005
|
+
|
2006
|
+
/* #define RUBY_EVENT_RESERVED_FOR_INTERNAL_USE 0x030000 */ /* from vm_core.h */
|
2007
|
+
#define RUBY_EVENT_COVERAGE_LINE 0x010000
|
2008
|
+
#define RUBY_EVENT_COVERAGE_BRANCH 0x020000
|
2009
|
+
|
2010
|
+
extern VALUE rb_get_coverages(void);
|
2011
|
+
extern void rb_set_coverages(VALUE, int, VALUE);
|
2012
|
+
extern void rb_clear_coverages(void);
|
2013
|
+
extern void rb_reset_coverages(void);
|
2014
|
+
|
2015
|
+
void rb_postponed_job_flush(rb_vm_t *vm);
|
2016
|
+
|
2017
|
+
// ractor.c
|
2018
|
+
RUBY_EXTERN VALUE rb_eRactorUnsafeError;
|
2019
|
+
RUBY_EXTERN VALUE rb_eRactorIsolationError;
|
2020
|
+
|
2021
|
+
RUBY_SYMBOL_EXPORT_END
|
2022
|
+
|
2023
|
+
#endif /* RUBY_VM_CORE_H */
|