debase-ruby_core_source 3.4.1 → 4.0.0.preview2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/addr2line.h +22 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/builtin.h +125 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/ccan/build_assert/build_assert.h +40 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/ccan/check_type/check_type.h +63 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/ccan/container_of/container_of.h +142 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/ccan/list/list.h +791 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/ccan/str/str.h +17 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/constant.h +53 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/darray.h +278 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/debug_counter.h +425 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/dln.h +33 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/encindex.h +70 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/eval_intern.h +331 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/hrtime.h +237 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/id.h +354 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/id_table.h +54 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/insns.inc +302 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/insns_info.inc +11241 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/array.h +154 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/basic_operators.h +65 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/bignum.h +245 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/bits.h +650 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/box.h +81 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/class.h +805 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/cmdlineopt.h +64 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/compar.h +29 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/compile.h +34 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/compilers.h +107 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/complex.h +29 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/concurrent_set.h +21 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/cont.h +35 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/dir.h +16 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/enc.h +19 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/encoding.h +39 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/enum.h +18 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/enumerator.h +21 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/error.h +251 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/eval.h +41 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/file.h +38 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/fixnum.h +185 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/gc.h +358 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/hash.h +194 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/imemo.h +322 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/inits.h +51 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/io.h +163 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/load.h +20 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/loadpath.h +16 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/math.h +23 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/missing.h +19 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/numeric.h +275 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/object.h +63 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/parse.h +131 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/proc.h +30 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/process.h +124 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/ractor.h +10 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/random.h +17 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/range.h +40 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/rational.h +71 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/re.h +33 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/ruby_parser.h +102 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/sanitizers.h +346 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/serial.h +23 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/set_table.h +70 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/signal.h +25 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/st.h +11 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/static_assert.h +16 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/string.h +203 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/struct.h +160 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/symbol.h +46 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/thread.h +112 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/time.h +37 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/transcode.h +23 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/util.h +27 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/variable.h +74 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/vm.h +136 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal/warnings.h +16 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/internal.h +105 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/iseq.h +357 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/known_errors.inc +1419 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/method.h +271 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/node.h +122 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/node_name.inc +224 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/optinsn.inc +128 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/optunifs.inc +41 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/parse.h +244 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/parser_bits.h +564 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/parser_node.h +32 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/parser_st.h +162 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/parser_value.h +106 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/prism/ast.h +8233 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/prism/defines.h +260 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/prism/diagnostic.h +458 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/prism/encoding.h +283 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/prism/extension.h +19 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/prism/node.h +129 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/prism/options.h +485 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/prism/pack.h +163 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/prism/parser.h +936 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/prism/prettyprint.h +34 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/prism/prism.h +408 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/prism/regexp.h +43 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/prism/static_literals.h +121 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/prism/util/pm_buffer.h +236 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/prism/util/pm_char.h +204 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/prism/util/pm_constant_pool.h +218 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/prism/util/pm_integer.h +130 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/prism/util/pm_list.h +103 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/prism/util/pm_memchr.h +29 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/prism/util/pm_newline_list.h +113 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/prism/util/pm_string.h +200 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/prism/util/pm_strncasecmp.h +32 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/prism/util/pm_strpbrk.h +46 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/prism/version.h +29 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/prism_compile.h +106 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/probes_helper.h +42 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/ractor_core.h +306 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/regenc.h +259 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/regint.h +1005 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/regparse.h +371 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/revision.h +5 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/ruby_assert.h +14 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/ruby_atomic.h +66 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/rubyparser.h +1394 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/shape.h +444 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/siphash.h +48 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/symbol.h +116 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/thread_none.h +21 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/thread_pthread.h +175 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/thread_win32.h +58 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/timev.h +58 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/transcode_data.h +138 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/variable.h +27 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/version.h +69 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/vm.inc +6183 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/vm_call_iseq_optimized.inc +244 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/vm_callinfo.h +640 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/vm_core.h +2350 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/vm_debug.h +124 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/vm_exec.h +210 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/vm_insnhelper.h +277 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/vm_opts.h +67 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/vm_sync.h +156 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/vmtc.inc +289 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/yjit.h +81 -0
- data/lib/debase/ruby_core_source/ruby-4.0.0-preview2/zjit.h +47 -0
- data/lib/debase/ruby_core_source/version.rb +1 -1
- metadata +148 -3
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
#include "prism/prism.h"
|
|
2
|
+
#include "ruby/encoding.h"
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* the getlocal and setlocal instructions require two parameters. level is how
|
|
6
|
+
* many hops up the iseq stack one needs to go before finding the correct local
|
|
7
|
+
* table. The index is the index in that table where our variable is.
|
|
8
|
+
*
|
|
9
|
+
* Because these are always calculated and used together, we'll bind them
|
|
10
|
+
* together as a tuple.
|
|
11
|
+
*/
|
|
12
|
+
typedef struct pm_local_index_struct {
|
|
13
|
+
int index, level;
|
|
14
|
+
} pm_local_index_t;
|
|
15
|
+
|
|
16
|
+
// A declaration for the struct that lives in compile.c.
|
|
17
|
+
struct iseq_link_anchor;
|
|
18
|
+
|
|
19
|
+
// ScopeNodes are helper nodes, and will never be part of the AST. We manually
|
|
20
|
+
// declare them here to avoid generating them.
|
|
21
|
+
typedef struct pm_scope_node {
|
|
22
|
+
pm_node_t base;
|
|
23
|
+
struct pm_scope_node *previous;
|
|
24
|
+
pm_node_t *ast_node;
|
|
25
|
+
pm_node_t *parameters;
|
|
26
|
+
pm_node_t *body;
|
|
27
|
+
pm_constant_id_list_t locals;
|
|
28
|
+
|
|
29
|
+
const pm_parser_t *parser;
|
|
30
|
+
rb_encoding *encoding;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* This is a pointer to the list of script lines for the ISEQs that will be
|
|
34
|
+
* associated with this scope node. It is only set if
|
|
35
|
+
* RubyVM.keep_script_lines is true. If it is set, it will be set to a
|
|
36
|
+
* pointer to an array that is always stack allocated (so no GC marking is
|
|
37
|
+
* needed by this struct). If it is not set, it will be NULL. It is
|
|
38
|
+
* inherited by all child scopes.
|
|
39
|
+
*/
|
|
40
|
+
VALUE *script_lines;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* This is the encoding of the actual filepath object that will be used when
|
|
44
|
+
* a __FILE__ node is compiled or when the path has to be set on a syntax
|
|
45
|
+
* error.
|
|
46
|
+
*/
|
|
47
|
+
rb_encoding *filepath_encoding;
|
|
48
|
+
|
|
49
|
+
// The size of the local table on the iseq which includes locals and hidden
|
|
50
|
+
// variables.
|
|
51
|
+
int local_table_for_iseq_size;
|
|
52
|
+
|
|
53
|
+
ID *constants;
|
|
54
|
+
st_table *index_lookup_table;
|
|
55
|
+
|
|
56
|
+
// The current coverage setting, passed down through the various scopes.
|
|
57
|
+
int coverage_enabled;
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* This will only be set on the top-level scope node. It will contain all of
|
|
61
|
+
* the instructions pertaining to BEGIN{} nodes.
|
|
62
|
+
*/
|
|
63
|
+
struct iseq_link_anchor *pre_execution_anchor;
|
|
64
|
+
} pm_scope_node_t;
|
|
65
|
+
|
|
66
|
+
void pm_scope_node_init(const pm_node_t *node, pm_scope_node_t *scope, pm_scope_node_t *previous);
|
|
67
|
+
void pm_scope_node_destroy(pm_scope_node_t *scope_node);
|
|
68
|
+
|
|
69
|
+
typedef struct {
|
|
70
|
+
/** The parser that will do the actual parsing. */
|
|
71
|
+
pm_parser_t parser;
|
|
72
|
+
|
|
73
|
+
/** The options that will be passed to the parser. */
|
|
74
|
+
pm_options_t options;
|
|
75
|
+
|
|
76
|
+
/** The input that represents the source to be parsed. */
|
|
77
|
+
pm_string_t input;
|
|
78
|
+
|
|
79
|
+
/** The resulting scope node that will hold the generated AST. */
|
|
80
|
+
pm_scope_node_t node;
|
|
81
|
+
|
|
82
|
+
/** Whether or not this parse result has performed its parsing yet. */
|
|
83
|
+
bool parsed;
|
|
84
|
+
} pm_parse_result_t;
|
|
85
|
+
|
|
86
|
+
#define PM_SPECIAL_CONSTANT_FLAG ((pm_constant_id_t)(1 << 31))
|
|
87
|
+
#define PM_CONSTANT_AND ((pm_constant_id_t)(idAnd | PM_SPECIAL_CONSTANT_FLAG))
|
|
88
|
+
#define PM_CONSTANT_DOT3 ((pm_constant_id_t)(idDot3 | PM_SPECIAL_CONSTANT_FLAG))
|
|
89
|
+
#define PM_CONSTANT_MULT ((pm_constant_id_t)(idMULT | PM_SPECIAL_CONSTANT_FLAG))
|
|
90
|
+
#define PM_CONSTANT_POW ((pm_constant_id_t)(idPow | PM_SPECIAL_CONSTANT_FLAG))
|
|
91
|
+
|
|
92
|
+
VALUE pm_load_file(pm_parse_result_t *result, VALUE filepath, bool load_error);
|
|
93
|
+
VALUE pm_parse_file(pm_parse_result_t *result, VALUE filepath, VALUE *script_lines);
|
|
94
|
+
VALUE pm_load_parse_file(pm_parse_result_t *result, VALUE filepath, VALUE *script_lines);
|
|
95
|
+
VALUE pm_parse_string(pm_parse_result_t *result, VALUE source, VALUE filepath, VALUE *script_lines);
|
|
96
|
+
VALUE pm_parse_stdin(pm_parse_result_t *result);
|
|
97
|
+
void pm_options_version_for_current_ruby_set(pm_options_t *options);
|
|
98
|
+
void pm_parse_result_free(pm_parse_result_t *result);
|
|
99
|
+
|
|
100
|
+
rb_iseq_t *pm_iseq_new(pm_scope_node_t *node, VALUE name, VALUE path, VALUE realpath, const rb_iseq_t *parent, enum rb_iseq_type, int *error_state);
|
|
101
|
+
rb_iseq_t *pm_iseq_new_top(pm_scope_node_t *node, VALUE name, VALUE path, VALUE realpath, const rb_iseq_t *parent, int *error_state);
|
|
102
|
+
rb_iseq_t *pm_iseq_new_main(pm_scope_node_t *node, VALUE path, VALUE realpath, const rb_iseq_t *parent, int opt, int *error_state);
|
|
103
|
+
rb_iseq_t *pm_iseq_new_eval(pm_scope_node_t *node, VALUE name, VALUE path, VALUE realpath, int first_lineno, const rb_iseq_t *parent, int isolated_depth, int *error_state);
|
|
104
|
+
rb_iseq_t *pm_iseq_new_with_opt(pm_scope_node_t *node, VALUE name, VALUE path, VALUE realpath, int first_lineno, const rb_iseq_t *parent, int isolated_depth, enum rb_iseq_type, const rb_compile_option_t *option, int *error_state);
|
|
105
|
+
|
|
106
|
+
VALUE pm_iseq_compile_node(rb_iseq_t *iseq, pm_scope_node_t *node);
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
#ifndef RUBY_PROBES_HELPER_H
|
|
2
|
+
#define RUBY_PROBES_HELPER_H
|
|
3
|
+
|
|
4
|
+
#include "ruby/ruby.h"
|
|
5
|
+
|
|
6
|
+
struct ruby_dtrace_method_hook_args {
|
|
7
|
+
const char *classname;
|
|
8
|
+
const char *methodname;
|
|
9
|
+
const char *filename;
|
|
10
|
+
int line_no;
|
|
11
|
+
volatile VALUE klass;
|
|
12
|
+
volatile VALUE name;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
NOINLINE(int rb_dtrace_setup(rb_execution_context_t *, VALUE, ID, struct ruby_dtrace_method_hook_args *));
|
|
16
|
+
|
|
17
|
+
#define RUBY_DTRACE_METHOD_HOOK(name, ec, klazz, id) \
|
|
18
|
+
do { \
|
|
19
|
+
if (UNLIKELY(RUBY_DTRACE_##name##_ENABLED())) { \
|
|
20
|
+
struct ruby_dtrace_method_hook_args args; \
|
|
21
|
+
if (rb_dtrace_setup(ec, klazz, id, &args)) { \
|
|
22
|
+
RUBY_DTRACE_##name(args.classname, \
|
|
23
|
+
args.methodname, \
|
|
24
|
+
args.filename, \
|
|
25
|
+
args.line_no); \
|
|
26
|
+
} \
|
|
27
|
+
} \
|
|
28
|
+
} while (0)
|
|
29
|
+
|
|
30
|
+
#define RUBY_DTRACE_METHOD_ENTRY_HOOK(ec, klass, id) \
|
|
31
|
+
RUBY_DTRACE_METHOD_HOOK(METHOD_ENTRY, ec, klass, id)
|
|
32
|
+
|
|
33
|
+
#define RUBY_DTRACE_METHOD_RETURN_HOOK(ec, klass, id) \
|
|
34
|
+
RUBY_DTRACE_METHOD_HOOK(METHOD_RETURN, ec, klass, id)
|
|
35
|
+
|
|
36
|
+
#define RUBY_DTRACE_CMETHOD_ENTRY_HOOK(ec, klass, id) \
|
|
37
|
+
RUBY_DTRACE_METHOD_HOOK(CMETHOD_ENTRY, ec, klass, id)
|
|
38
|
+
|
|
39
|
+
#define RUBY_DTRACE_CMETHOD_RETURN_HOOK(ec, klass, id) \
|
|
40
|
+
RUBY_DTRACE_METHOD_HOOK(CMETHOD_RETURN, ec, klass, id)
|
|
41
|
+
|
|
42
|
+
#endif /* RUBY_PROBES_HELPER_H */
|
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
#include "internal/gc.h"
|
|
2
|
+
#include "ruby/ruby.h"
|
|
3
|
+
#include "ruby/ractor.h"
|
|
4
|
+
#include "vm_core.h"
|
|
5
|
+
#include "id_table.h"
|
|
6
|
+
#include "vm_debug.h"
|
|
7
|
+
|
|
8
|
+
#ifndef RACTOR_CHECK_MODE
|
|
9
|
+
#define RACTOR_CHECK_MODE (VM_CHECK_MODE || RUBY_DEBUG) && (SIZEOF_UINT64_T == SIZEOF_VALUE)
|
|
10
|
+
#endif
|
|
11
|
+
|
|
12
|
+
struct rb_ractor_sync {
|
|
13
|
+
// ractor lock
|
|
14
|
+
rb_nativethread_lock_t lock;
|
|
15
|
+
|
|
16
|
+
#if RACTOR_CHECK_MODE > 0
|
|
17
|
+
VALUE locked_by;
|
|
18
|
+
#endif
|
|
19
|
+
|
|
20
|
+
#ifndef RUBY_THREAD_PTHREAD_H
|
|
21
|
+
rb_nativethread_cond_t wakeup_cond;
|
|
22
|
+
#endif
|
|
23
|
+
|
|
24
|
+
// incoming messages
|
|
25
|
+
struct ractor_queue *recv_queue;
|
|
26
|
+
|
|
27
|
+
// waiting threads for receiving
|
|
28
|
+
struct ccan_list_head waiters;
|
|
29
|
+
|
|
30
|
+
// ports
|
|
31
|
+
VALUE default_port_value;
|
|
32
|
+
struct st_table *ports;
|
|
33
|
+
size_t next_port_id;
|
|
34
|
+
|
|
35
|
+
// monitors
|
|
36
|
+
struct ccan_list_head monitors;
|
|
37
|
+
|
|
38
|
+
// value
|
|
39
|
+
rb_ractor_t *successor;
|
|
40
|
+
VALUE legacy;
|
|
41
|
+
bool legacy_exc;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
// created
|
|
45
|
+
// | ready to run
|
|
46
|
+
// ====================== inserted to vm->ractor
|
|
47
|
+
// v
|
|
48
|
+
// blocking <---+ all threads are blocking
|
|
49
|
+
// | |
|
|
50
|
+
// v |
|
|
51
|
+
// running -----+
|
|
52
|
+
// | all threads are terminated.
|
|
53
|
+
// ====================== removed from vm->ractor
|
|
54
|
+
// v
|
|
55
|
+
// terminated
|
|
56
|
+
//
|
|
57
|
+
// status is protected by VM lock (global state)
|
|
58
|
+
enum ractor_status {
|
|
59
|
+
ractor_created,
|
|
60
|
+
ractor_running,
|
|
61
|
+
ractor_blocking,
|
|
62
|
+
ractor_terminated,
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
struct rb_ractor_struct {
|
|
66
|
+
struct rb_ractor_pub pub;
|
|
67
|
+
struct rb_ractor_sync sync;
|
|
68
|
+
|
|
69
|
+
// thread management
|
|
70
|
+
struct {
|
|
71
|
+
struct ccan_list_head set;
|
|
72
|
+
unsigned int cnt;
|
|
73
|
+
unsigned int blocking_cnt;
|
|
74
|
+
unsigned int sleeper;
|
|
75
|
+
struct rb_thread_sched sched;
|
|
76
|
+
rb_execution_context_t *running_ec;
|
|
77
|
+
rb_thread_t *main;
|
|
78
|
+
} threads;
|
|
79
|
+
|
|
80
|
+
VALUE thgroup_default;
|
|
81
|
+
|
|
82
|
+
VALUE name;
|
|
83
|
+
VALUE loc;
|
|
84
|
+
|
|
85
|
+
enum ractor_status status_;
|
|
86
|
+
|
|
87
|
+
struct ccan_list_node vmlr_node;
|
|
88
|
+
|
|
89
|
+
// ractor local data
|
|
90
|
+
|
|
91
|
+
st_table *local_storage;
|
|
92
|
+
struct rb_id_table *idkey_local_storage;
|
|
93
|
+
VALUE local_storage_store_lock;
|
|
94
|
+
|
|
95
|
+
VALUE r_stdin;
|
|
96
|
+
VALUE r_stdout;
|
|
97
|
+
VALUE r_stderr;
|
|
98
|
+
VALUE verbose;
|
|
99
|
+
VALUE debug;
|
|
100
|
+
|
|
101
|
+
bool malloc_gc_disabled;
|
|
102
|
+
void *newobj_cache;
|
|
103
|
+
}; // rb_ractor_t is defined in vm_core.h
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
static inline VALUE
|
|
107
|
+
rb_ractor_self(const rb_ractor_t *r)
|
|
108
|
+
{
|
|
109
|
+
return r->pub.self;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
rb_ractor_t *rb_ractor_main_alloc(void);
|
|
113
|
+
void rb_ractor_main_setup(rb_vm_t *vm, rb_ractor_t *main_ractor, rb_thread_t *main_thread);
|
|
114
|
+
void rb_ractor_atexit(rb_execution_context_t *ec, VALUE result);
|
|
115
|
+
void rb_ractor_atexit_exception(rb_execution_context_t *ec);
|
|
116
|
+
void rb_ractor_teardown(rb_execution_context_t *ec);
|
|
117
|
+
void rb_ractor_receive_parameters(rb_execution_context_t *ec, rb_ractor_t *g, int len, VALUE *ptr);
|
|
118
|
+
void rb_ractor_send_parameters(rb_execution_context_t *ec, rb_ractor_t *g, VALUE args);
|
|
119
|
+
|
|
120
|
+
VALUE rb_thread_create_ractor(rb_ractor_t *g, VALUE args, VALUE proc); // defined in thread.c
|
|
121
|
+
|
|
122
|
+
int rb_ractor_living_thread_num(const rb_ractor_t *);
|
|
123
|
+
VALUE rb_ractor_thread_list(void);
|
|
124
|
+
bool rb_ractor_p(VALUE rv);
|
|
125
|
+
|
|
126
|
+
void rb_ractor_living_threads_init(rb_ractor_t *r);
|
|
127
|
+
void rb_ractor_living_threads_insert(rb_ractor_t *r, rb_thread_t *th);
|
|
128
|
+
void rb_ractor_living_threads_remove(rb_ractor_t *r, rb_thread_t *th);
|
|
129
|
+
void rb_ractor_blocking_threads_inc(rb_ractor_t *r, const char *file, int line); // TODO: file, line only for RUBY_DEBUG_LOG
|
|
130
|
+
void rb_ractor_blocking_threads_dec(rb_ractor_t *r, const char *file, int line); // TODO: file, line only for RUBY_DEBUG_LOG
|
|
131
|
+
|
|
132
|
+
void rb_ractor_vm_barrier_interrupt_running_thread(rb_ractor_t *r);
|
|
133
|
+
void rb_ractor_terminate_interrupt_main_thread(rb_ractor_t *r);
|
|
134
|
+
void rb_ractor_terminate_all(void);
|
|
135
|
+
bool rb_ractor_main_p_(void);
|
|
136
|
+
void rb_ractor_atfork(rb_vm_t *vm, rb_thread_t *th);
|
|
137
|
+
void rb_ractor_terminate_atfork(rb_vm_t *vm, rb_ractor_t *th);
|
|
138
|
+
VALUE rb_ractor_require(VALUE feature, bool silent);
|
|
139
|
+
VALUE rb_ractor_autoload_load(VALUE space, ID id);
|
|
140
|
+
|
|
141
|
+
VALUE rb_ractor_ensure_shareable(VALUE obj, VALUE name);
|
|
142
|
+
|
|
143
|
+
RUBY_SYMBOL_EXPORT_BEGIN
|
|
144
|
+
void rb_ractor_finish_marking(void);
|
|
145
|
+
|
|
146
|
+
bool rb_ractor_shareable_p_continue(VALUE obj);
|
|
147
|
+
|
|
148
|
+
// THIS FUNCTION SHOULD NOT CALL WHILE INCREMENTAL MARKING!!
|
|
149
|
+
// This function is for T_DATA::free_func
|
|
150
|
+
void rb_ractor_local_storage_delkey(rb_ractor_local_key_t key);
|
|
151
|
+
|
|
152
|
+
RUBY_SYMBOL_EXPORT_END
|
|
153
|
+
|
|
154
|
+
static inline bool
|
|
155
|
+
rb_ractor_main_p(void)
|
|
156
|
+
{
|
|
157
|
+
if (ruby_single_main_ractor) {
|
|
158
|
+
return true;
|
|
159
|
+
}
|
|
160
|
+
else {
|
|
161
|
+
return rb_ractor_main_p_();
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
static inline bool
|
|
166
|
+
rb_ractor_status_p(rb_ractor_t *r, enum ractor_status status)
|
|
167
|
+
{
|
|
168
|
+
return r->status_ == status;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
static inline void
|
|
172
|
+
rb_ractor_sleeper_threads_inc(rb_ractor_t *r)
|
|
173
|
+
{
|
|
174
|
+
r->threads.sleeper++;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
static inline void
|
|
178
|
+
rb_ractor_sleeper_threads_dec(rb_ractor_t *r)
|
|
179
|
+
{
|
|
180
|
+
r->threads.sleeper--;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
static inline void
|
|
184
|
+
rb_ractor_sleeper_threads_clear(rb_ractor_t *r)
|
|
185
|
+
{
|
|
186
|
+
r->threads.sleeper = 0;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
static inline int
|
|
190
|
+
rb_ractor_sleeper_thread_num(rb_ractor_t *r)
|
|
191
|
+
{
|
|
192
|
+
return r->threads.sleeper;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
static inline void
|
|
196
|
+
rb_ractor_thread_switch(rb_ractor_t *cr, rb_thread_t *th, bool always_reset)
|
|
197
|
+
{
|
|
198
|
+
RUBY_DEBUG_LOG("th:%d->%u%s",
|
|
199
|
+
cr->threads.running_ec ? (int)rb_th_serial(cr->threads.running_ec->thread_ptr) : -1,
|
|
200
|
+
rb_th_serial(th), cr->threads.running_ec == th->ec ? " (same)" : "");
|
|
201
|
+
|
|
202
|
+
if (cr->threads.running_ec != th->ec || always_reset) {
|
|
203
|
+
th->running_time_us = 0;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
if (cr->threads.running_ec != th->ec) {
|
|
207
|
+
if (0) {
|
|
208
|
+
ruby_debug_printf("rb_ractor_thread_switch ec:%p->%p\n",
|
|
209
|
+
(void *)cr->threads.running_ec, (void *)th->ec);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
else {
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
cr->threads.running_ec = th->ec;
|
|
217
|
+
|
|
218
|
+
VM_ASSERT(cr == GET_RACTOR());
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
#define rb_ractor_set_current_ec(cr, ec) rb_ractor_set_current_ec_(cr, ec, __FILE__, __LINE__)
|
|
222
|
+
#ifdef RB_THREAD_LOCAL_SPECIFIER
|
|
223
|
+
void rb_current_ec_set(rb_execution_context_t *ec);
|
|
224
|
+
#endif
|
|
225
|
+
|
|
226
|
+
static inline void
|
|
227
|
+
rb_ractor_set_current_ec_(rb_ractor_t *cr, rb_execution_context_t *ec, const char *file, int line)
|
|
228
|
+
{
|
|
229
|
+
#ifdef RB_THREAD_LOCAL_SPECIFIER
|
|
230
|
+
rb_current_ec_set(ec);
|
|
231
|
+
#else
|
|
232
|
+
native_tls_set(ruby_current_ec_key, ec);
|
|
233
|
+
#endif
|
|
234
|
+
RUBY_DEBUG_LOG2(file, line, "ec:%p->%p", (void *)cr->threads.running_ec, (void *)ec);
|
|
235
|
+
VM_ASSERT(ec == NULL || cr->threads.running_ec != ec);
|
|
236
|
+
cr->threads.running_ec = ec;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
void rb_vm_ractor_blocking_cnt_inc(rb_vm_t *vm, rb_ractor_t *cr, const char *file, int line);
|
|
240
|
+
void rb_vm_ractor_blocking_cnt_dec(rb_vm_t *vm, rb_ractor_t *cr, const char *file, int line);
|
|
241
|
+
|
|
242
|
+
static inline uint32_t
|
|
243
|
+
rb_ractor_id(const rb_ractor_t *r)
|
|
244
|
+
{
|
|
245
|
+
return r->pub.id;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
#if RACTOR_CHECK_MODE > 0
|
|
249
|
+
# define RACTOR_BELONGING_ID(obj) (*(uint32_t *)(((uintptr_t)(obj)) + rb_gc_obj_slot_size(obj)))
|
|
250
|
+
|
|
251
|
+
uint32_t rb_ractor_current_id(void);
|
|
252
|
+
|
|
253
|
+
static inline void
|
|
254
|
+
rb_ractor_setup_belonging_to(VALUE obj, uint32_t rid)
|
|
255
|
+
{
|
|
256
|
+
RACTOR_BELONGING_ID(obj) = rid;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
static inline uint32_t
|
|
260
|
+
rb_ractor_belonging(VALUE obj)
|
|
261
|
+
{
|
|
262
|
+
if (SPECIAL_CONST_P(obj) || RB_OBJ_SHAREABLE_P(obj)) {
|
|
263
|
+
return 0;
|
|
264
|
+
}
|
|
265
|
+
else {
|
|
266
|
+
return RACTOR_BELONGING_ID(obj);
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
extern bool rb_ractor_ignore_belonging_flag;
|
|
271
|
+
|
|
272
|
+
static inline VALUE
|
|
273
|
+
rb_ractor_confirm_belonging(VALUE obj)
|
|
274
|
+
{
|
|
275
|
+
if (rb_ractor_ignore_belonging_flag) return obj;
|
|
276
|
+
|
|
277
|
+
uint32_t id = rb_ractor_belonging(obj);
|
|
278
|
+
|
|
279
|
+
if (id == 0) {
|
|
280
|
+
if (UNLIKELY(!rb_ractor_shareable_p(obj))) {
|
|
281
|
+
rp(obj);
|
|
282
|
+
rb_bug("id == 0 but not shareable");
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
else if (UNLIKELY(id != rb_ractor_current_id())) {
|
|
286
|
+
if (rb_ractor_shareable_p(obj)) {
|
|
287
|
+
// ok
|
|
288
|
+
}
|
|
289
|
+
else {
|
|
290
|
+
rp(obj);
|
|
291
|
+
rb_bug("rb_ractor_confirm_belonging object-ractor id:%u, current-ractor id:%u", id, rb_ractor_current_id());
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
return obj;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
static inline void
|
|
298
|
+
rb_ractor_ignore_belonging(bool flag)
|
|
299
|
+
{
|
|
300
|
+
rb_ractor_ignore_belonging_flag = flag;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
#else
|
|
304
|
+
#define rb_ractor_confirm_belonging(obj) obj
|
|
305
|
+
#define rb_ractor_ignore_belonging(flag) (0)
|
|
306
|
+
#endif
|