debase-ruby_core_source 4.0.1 → 4.1.0.preview1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/addr2line.h +22 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/builtin.h +127 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/ccan/build_assert/build_assert.h +40 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/ccan/check_type/check_type.h +63 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/ccan/container_of/container_of.h +142 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/ccan/list/list.h +791 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/ccan/str/str.h +17 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/constant.h +53 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/darray.h +295 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/debug_counter.h +428 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/dln.h +33 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/encindex.h +70 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/eval_intern.h +356 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/hrtime.h +237 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/id.h +365 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/id_table.h +74 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/insns.inc +315 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/insns_info.inc +11637 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/array.h +158 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/basic_operators.h +67 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/bignum.h +249 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/bits.h +647 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/box.h +103 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/class.h +797 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/cmdlineopt.h +64 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/compar.h +30 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/compile.h +34 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/compilers.h +104 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/complex.h +29 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/concurrent_set.h +21 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/cont.h +33 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/coverage.h +51 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/dir.h +16 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/enc.h +19 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/encoding.h +40 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/enum.h +18 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/enumerator.h +21 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/error.h +287 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/eval.h +43 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/file.h +40 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/fixnum.h +185 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/gc.h +411 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/hash.h +220 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/imemo.h +302 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/inits.h +54 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/io.h +167 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/io_buffer.h +36 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/jit.h +23 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/load.h +20 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/loadpath.h +16 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/marshal.h +17 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/math.h +23 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/missing.h +19 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/numeric.h +326 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/object.h +88 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/objspace.h +24 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/parse.h +131 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/proc.h +34 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/process.h +124 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/ractor.h +9 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/random.h +17 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/range.h +46 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/rational.h +92 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/re.h +87 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/ruby_parser.h +109 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/sanitizers.h +346 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/scheduler.h +7 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/serial.h +23 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/set.h +20 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/set_table.h +77 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/signal.h +25 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/simd.h +18 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/st.h +32 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/static_assert.h +16 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/string.h +240 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/struct.h +120 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/symbol.h +46 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/thread.h +108 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/time.h +34 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/transcode.h +23 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/util.h +27 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/variable.h +81 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/vm.h +144 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/vm_map.h +95 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/warnings.h +16 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal.h +106 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/iseq.h +439 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/known_errors.inc +1419 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/method.h +279 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/node.h +122 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/node_name.inc +224 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/optinsn.inc +128 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/optunifs.inc +41 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/parse.h +246 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/parser_bits.h +647 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/parser_node.h +32 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/parser_st.h +161 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/parser_value.h +116 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/arena.h +37 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/ast.h +10371 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/buffer.h +52 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/comments.h +43 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/compiler/accel.h +19 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/compiler/align.h +36 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/compiler/assume.h +25 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/compiler/exported.h +24 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/compiler/fallthrough.h +22 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/compiler/filesystem.h +32 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/compiler/flex_array.h +19 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/compiler/force_inline.h +21 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/compiler/format.h +25 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/compiler/inline.h +17 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/compiler/nodiscard.h +22 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/compiler/nonnull.h +18 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/compiler/unused.h +18 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/constant_pool.h +81 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/diagnostic.h +93 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/errors_format.h +53 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/excludes.h +29 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/extension.h +19 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/integer.h +41 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/internal/allocator.h +68 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/internal/allocator_debug.h +88 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/internal/arena.h +108 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/internal/bit.h +42 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/internal/buffer.h +91 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/internal/char.h +139 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/internal/comments.h +20 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/internal/constant_pool.h +152 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/internal/diagnostic.h +389 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/internal/encoding.h +242 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/internal/integer.h +68 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/internal/isinf.h +16 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/internal/line_offset_list.h +34 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/internal/list.h +62 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/internal/magic_comments.h +23 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/internal/memchr.h +15 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/internal/node.h +32 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/internal/options.h +224 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/internal/parser.h +971 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/internal/regexp.h +42 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/internal/serialize.h +39 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/internal/source.h +72 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/internal/static_literals.h +100 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/internal/stringy.h +35 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/internal/strncasecmp.h +18 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/internal/strpbrk.h +33 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/internal/tokens.h +11 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/json.h +32 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/line_offset_list.h +61 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/magic_comments.h +35 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/node.h +94 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/options.h +335 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/parser.h +348 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/prettyprint.h +31 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/prism.h +131 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/serialize.h +115 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/source.h +155 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/stream.h +28 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/string_query.h +63 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/stringy.h +72 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/version.h +38 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism_compile.h +204 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism_xallocator.h +6 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/probes_helper.h +42 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/ractor_core.h +421 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/regenc.h +261 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/regint.h +983 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/regparse.h +371 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/revision.h +5 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/ruby_assert.h +14 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/ruby_atomic.h +115 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/rubyparser.h +1389 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/shape.h +733 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/siphash.h +48 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/symbol.h +116 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/thread_none.h +25 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/thread_pthread.h +63 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/thread_sched.h +271 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/thread_win32.h +48 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/timev.h +58 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/transcode_data.h +138 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/variable.h +26 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/version.h +69 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/vm.inc +6457 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/vm_call_iseq_optimized.inc +244 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/vm_callinfo.h +688 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/vm_core.h +2509 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/vm_debug.h +124 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/vm_exec.h +202 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/vm_insnhelper.h +280 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/vm_opts.h +65 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/vm_sync.h +160 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/vmtc.inc +302 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/yjit.h +87 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/zjit.h +221 -0
- data/lib/debase/ruby_core_source/version.rb +1 -1
- metadata +2930 -2724
|
@@ -0,0 +1,688 @@
|
|
|
1
|
+
#ifndef RUBY_VM_CALLINFO_H /*-*-C-*-vi:se ft=c:*/
|
|
2
|
+
#define RUBY_VM_CALLINFO_H
|
|
3
|
+
/**
|
|
4
|
+
* @author Ruby developers <ruby-core@ruby-lang.org>
|
|
5
|
+
* @copyright This file is a part of the programming language Ruby.
|
|
6
|
+
* Permission is hereby granted, to either redistribute and/or
|
|
7
|
+
* modify this file, provided that the conditions mentioned in the
|
|
8
|
+
* file COPYING are met. Consult the file for details.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
#include "debug_counter.h"
|
|
12
|
+
#include "internal/class.h"
|
|
13
|
+
#include "shape.h"
|
|
14
|
+
|
|
15
|
+
enum vm_call_flag_bits {
|
|
16
|
+
VM_CALL_ARGS_SPLAT_bit, // m(*args)
|
|
17
|
+
VM_CALL_ARGS_BLOCKARG_bit, // m(&block)
|
|
18
|
+
VM_CALL_FCALL_bit, // m(args) # receiver is self
|
|
19
|
+
VM_CALL_VCALL_bit, // m # method call that looks like a local variable
|
|
20
|
+
VM_CALL_ARGS_SIMPLE_bit, // !(ci->flag & (SPLAT|BLOCKARG|KWARG|KW_SPLAT|FORWARDING)) && !has_block_iseq
|
|
21
|
+
VM_CALL_KWARG_bit, // has kwarg
|
|
22
|
+
VM_CALL_KW_SPLAT_bit, // m(**opts)
|
|
23
|
+
VM_CALL_TAILCALL_bit, // located at tail position
|
|
24
|
+
VM_CALL_SUPER_bit, // super
|
|
25
|
+
VM_CALL_ZSUPER_bit, // zsuper
|
|
26
|
+
VM_CALL_OPT_SEND_bit, // internal flag
|
|
27
|
+
VM_CALL_KW_SPLAT_MUT_bit, // kw splat hash can be modified (to avoid allocating a new one)
|
|
28
|
+
VM_CALL_ARGS_SPLAT_MUT_bit, // args splat can be modified (to avoid allocating a new one)
|
|
29
|
+
VM_CALL_FORWARDING_bit, // m(...)
|
|
30
|
+
VM_CALL__END
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
#define VM_CALL_ARGS_SPLAT (0x01 << VM_CALL_ARGS_SPLAT_bit)
|
|
34
|
+
#define VM_CALL_ARGS_BLOCKARG (0x01 << VM_CALL_ARGS_BLOCKARG_bit)
|
|
35
|
+
#define VM_CALL_FCALL (0x01 << VM_CALL_FCALL_bit)
|
|
36
|
+
#define VM_CALL_VCALL (0x01 << VM_CALL_VCALL_bit)
|
|
37
|
+
#define VM_CALL_ARGS_SIMPLE (0x01 << VM_CALL_ARGS_SIMPLE_bit)
|
|
38
|
+
#define VM_CALL_KWARG (0x01 << VM_CALL_KWARG_bit)
|
|
39
|
+
#define VM_CALL_KW_SPLAT (0x01 << VM_CALL_KW_SPLAT_bit)
|
|
40
|
+
#define VM_CALL_TAILCALL (0x01 << VM_CALL_TAILCALL_bit)
|
|
41
|
+
#define VM_CALL_SUPER (0x01 << VM_CALL_SUPER_bit)
|
|
42
|
+
#define VM_CALL_ZSUPER (0x01 << VM_CALL_ZSUPER_bit)
|
|
43
|
+
#define VM_CALL_OPT_SEND (0x01 << VM_CALL_OPT_SEND_bit)
|
|
44
|
+
#define VM_CALL_KW_SPLAT_MUT (0x01 << VM_CALL_KW_SPLAT_MUT_bit)
|
|
45
|
+
#define VM_CALL_ARGS_SPLAT_MUT (0x01 << VM_CALL_ARGS_SPLAT_MUT_bit)
|
|
46
|
+
#define VM_CALL_FORWARDING (0x01 << VM_CALL_FORWARDING_bit)
|
|
47
|
+
|
|
48
|
+
struct rb_callinfo_kwarg {
|
|
49
|
+
int keyword_len;
|
|
50
|
+
rb_atomic_t references;
|
|
51
|
+
VALUE keywords[];
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
static inline size_t
|
|
55
|
+
rb_callinfo_kwarg_bytes(int keyword_len)
|
|
56
|
+
{
|
|
57
|
+
return rb_size_mul_add_or_raise(
|
|
58
|
+
keyword_len,
|
|
59
|
+
sizeof(VALUE),
|
|
60
|
+
sizeof(struct rb_callinfo_kwarg),
|
|
61
|
+
rb_eRuntimeError);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
static inline void
|
|
65
|
+
rb_callinfo_kwarg_retain(struct rb_callinfo_kwarg *kwarg)
|
|
66
|
+
{
|
|
67
|
+
if (kwarg) RUBY_ATOMIC_INC(kwarg->references);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
static inline void
|
|
71
|
+
rb_callinfo_kwarg_release(struct rb_callinfo_kwarg *kwarg)
|
|
72
|
+
{
|
|
73
|
+
if (kwarg && RUBY_ATOMIC_FETCH_SUB(kwarg->references, 1) == 1) {
|
|
74
|
+
ruby_xfree_sized(kwarg, rb_callinfo_kwarg_bytes(kwarg->keyword_len));
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// imemo_callinfo
|
|
79
|
+
struct rb_callinfo {
|
|
80
|
+
VALUE flags;
|
|
81
|
+
const struct rb_callinfo_kwarg *kwarg;
|
|
82
|
+
VALUE mid;
|
|
83
|
+
unsigned int flag;
|
|
84
|
+
unsigned int argc;
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
#if !defined(USE_EMBED_CI) || (USE_EMBED_CI+0)
|
|
88
|
+
#undef USE_EMBED_CI
|
|
89
|
+
#define USE_EMBED_CI 1
|
|
90
|
+
#else
|
|
91
|
+
#undef USE_EMBED_CI
|
|
92
|
+
#define USE_EMBED_CI 0
|
|
93
|
+
#endif
|
|
94
|
+
|
|
95
|
+
#if SIZEOF_VALUE == 8
|
|
96
|
+
#define CI_EMBED_TAG_bits 1
|
|
97
|
+
#define CI_EMBED_ARGC_bits 15
|
|
98
|
+
#define CI_EMBED_FLAG_bits 16
|
|
99
|
+
#define CI_EMBED_ID_bits 32
|
|
100
|
+
#elif SIZEOF_VALUE == 4
|
|
101
|
+
#define CI_EMBED_TAG_bits 1
|
|
102
|
+
#define CI_EMBED_ARGC_bits 3
|
|
103
|
+
#define CI_EMBED_FLAG_bits 13
|
|
104
|
+
#define CI_EMBED_ID_bits 15
|
|
105
|
+
#endif
|
|
106
|
+
|
|
107
|
+
#if (CI_EMBED_TAG_bits + CI_EMBED_ARGC_bits + CI_EMBED_FLAG_bits + CI_EMBED_ID_bits) != (SIZEOF_VALUE * 8)
|
|
108
|
+
#error
|
|
109
|
+
#endif
|
|
110
|
+
|
|
111
|
+
#define CI_EMBED_FLAG 0x01
|
|
112
|
+
#define CI_EMBED_ARGC_SHFT (CI_EMBED_TAG_bits)
|
|
113
|
+
#define CI_EMBED_ARGC_MASK ((((VALUE)1)<<CI_EMBED_ARGC_bits) - 1)
|
|
114
|
+
#define CI_EMBED_FLAG_SHFT (CI_EMBED_TAG_bits + CI_EMBED_ARGC_bits)
|
|
115
|
+
#define CI_EMBED_FLAG_MASK ((((VALUE)1)<<CI_EMBED_FLAG_bits) - 1)
|
|
116
|
+
#define CI_EMBED_ID_SHFT (CI_EMBED_TAG_bits + CI_EMBED_ARGC_bits + CI_EMBED_FLAG_bits)
|
|
117
|
+
#define CI_EMBED_ID_MASK ((((VALUE)1)<<CI_EMBED_ID_bits) - 1)
|
|
118
|
+
|
|
119
|
+
static inline bool
|
|
120
|
+
vm_ci_packed_p(const struct rb_callinfo *ci)
|
|
121
|
+
{
|
|
122
|
+
if (!USE_EMBED_CI) {
|
|
123
|
+
return 0;
|
|
124
|
+
}
|
|
125
|
+
if (LIKELY(((VALUE)ci) & 0x01)) {
|
|
126
|
+
return 1;
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
VM_ASSERT(IMEMO_TYPE_P(ci, imemo_callinfo));
|
|
130
|
+
return 0;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
static inline bool
|
|
135
|
+
vm_ci_p(const struct rb_callinfo *ci)
|
|
136
|
+
{
|
|
137
|
+
if (vm_ci_packed_p(ci) || IMEMO_TYPE_P(ci, imemo_callinfo)) {
|
|
138
|
+
return 1;
|
|
139
|
+
}
|
|
140
|
+
else {
|
|
141
|
+
return 0;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
static inline ID
|
|
146
|
+
vm_ci_mid(const struct rb_callinfo *ci)
|
|
147
|
+
{
|
|
148
|
+
if (vm_ci_packed_p(ci)) {
|
|
149
|
+
return (((VALUE)ci) >> CI_EMBED_ID_SHFT) & CI_EMBED_ID_MASK;
|
|
150
|
+
}
|
|
151
|
+
else {
|
|
152
|
+
return (ID)ci->mid;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
static inline unsigned int
|
|
157
|
+
vm_ci_flag(const struct rb_callinfo *ci)
|
|
158
|
+
{
|
|
159
|
+
if (vm_ci_packed_p(ci)) {
|
|
160
|
+
return (unsigned int)((((VALUE)ci) >> CI_EMBED_FLAG_SHFT) & CI_EMBED_FLAG_MASK);
|
|
161
|
+
}
|
|
162
|
+
else {
|
|
163
|
+
return ci->flag;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
static inline unsigned int
|
|
168
|
+
vm_ci_argc(const struct rb_callinfo *ci)
|
|
169
|
+
{
|
|
170
|
+
if (vm_ci_packed_p(ci)) {
|
|
171
|
+
return (unsigned int)((((VALUE)ci) >> CI_EMBED_ARGC_SHFT) & CI_EMBED_ARGC_MASK);
|
|
172
|
+
}
|
|
173
|
+
else {
|
|
174
|
+
return ci->argc;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
static inline const struct rb_callinfo_kwarg *
|
|
179
|
+
vm_ci_kwarg(const struct rb_callinfo *ci)
|
|
180
|
+
{
|
|
181
|
+
if (vm_ci_packed_p(ci)) {
|
|
182
|
+
return NULL;
|
|
183
|
+
}
|
|
184
|
+
else {
|
|
185
|
+
return ci->kwarg;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
static inline void
|
|
190
|
+
vm_ci_dump(const struct rb_callinfo *ci)
|
|
191
|
+
{
|
|
192
|
+
if (vm_ci_packed_p(ci)) {
|
|
193
|
+
ruby_debug_printf("packed_ci ID:%s flag:%x argc:%u\n",
|
|
194
|
+
rb_id2name(vm_ci_mid(ci)), vm_ci_flag(ci), vm_ci_argc(ci));
|
|
195
|
+
}
|
|
196
|
+
else {
|
|
197
|
+
rp(ci);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
#define vm_ci_new(mid, flag, argc, kwarg) vm_ci_new_(mid, flag, argc, kwarg, __FILE__, __LINE__)
|
|
202
|
+
#define vm_ci_new_runtime(mid, flag, argc, kwarg) vm_ci_new_runtime_(mid, flag, argc, kwarg, __FILE__, __LINE__)
|
|
203
|
+
|
|
204
|
+
/* This is passed to STATIC_ASSERT. Cannot be an inline function. */
|
|
205
|
+
#define VM_CI_EMBEDDABLE_P(mid, flag, argc, kwarg) \
|
|
206
|
+
(((mid ) & ~CI_EMBED_ID_MASK) ? false : \
|
|
207
|
+
((flag) & ~CI_EMBED_FLAG_MASK) ? false : \
|
|
208
|
+
((argc) & ~CI_EMBED_ARGC_MASK) ? false : \
|
|
209
|
+
(kwarg) ? false : true)
|
|
210
|
+
|
|
211
|
+
#define vm_ci_new_id(mid, flag, argc, must_zero) \
|
|
212
|
+
((const struct rb_callinfo *) \
|
|
213
|
+
((((VALUE)(mid )) << CI_EMBED_ID_SHFT) | \
|
|
214
|
+
(((VALUE)(flag)) << CI_EMBED_FLAG_SHFT) | \
|
|
215
|
+
(((VALUE)(argc)) << CI_EMBED_ARGC_SHFT) | \
|
|
216
|
+
RUBY_FIXNUM_FLAG))
|
|
217
|
+
|
|
218
|
+
// vm_method.c
|
|
219
|
+
const struct rb_callinfo *rb_vm_ci_lookup(ID mid, unsigned int flag, unsigned int argc, const struct rb_callinfo_kwarg *kwarg);
|
|
220
|
+
void rb_vm_ci_free(const struct rb_callinfo *);
|
|
221
|
+
|
|
222
|
+
static inline const struct rb_callinfo *
|
|
223
|
+
vm_ci_new_(ID mid, unsigned int flag, unsigned int argc, const struct rb_callinfo_kwarg *kwarg, const char *file, int line)
|
|
224
|
+
{
|
|
225
|
+
if (USE_EMBED_CI && VM_CI_EMBEDDABLE_P(mid, flag, argc, kwarg)) {
|
|
226
|
+
RB_DEBUG_COUNTER_INC(ci_packed);
|
|
227
|
+
return vm_ci_new_id(mid, flag, argc, kwarg);
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
const bool debug = 0;
|
|
231
|
+
if (debug) ruby_debug_printf("%s:%d ", file, line);
|
|
232
|
+
|
|
233
|
+
const struct rb_callinfo *ci = rb_vm_ci_lookup(mid, flag, argc, kwarg);
|
|
234
|
+
|
|
235
|
+
if (debug) rp(ci);
|
|
236
|
+
if (kwarg) {
|
|
237
|
+
RB_DEBUG_COUNTER_INC(ci_kw);
|
|
238
|
+
}
|
|
239
|
+
else {
|
|
240
|
+
RB_DEBUG_COUNTER_INC(ci_nokw);
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
VM_ASSERT(vm_ci_flag(ci) == flag);
|
|
244
|
+
VM_ASSERT(vm_ci_argc(ci) == argc);
|
|
245
|
+
|
|
246
|
+
return ci;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
static inline const struct rb_callinfo *
|
|
251
|
+
vm_ci_new_runtime_(ID mid, unsigned int flag, unsigned int argc, const struct rb_callinfo_kwarg *kwarg, const char *file, int line)
|
|
252
|
+
{
|
|
253
|
+
RB_DEBUG_COUNTER_INC(ci_runtime);
|
|
254
|
+
return vm_ci_new_(mid, flag, argc, kwarg, file, line);
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
#define VM_CALLINFO_NOT_UNDER_GC IMEMO_FL_USER0
|
|
258
|
+
|
|
259
|
+
static inline bool
|
|
260
|
+
vm_ci_markable(const struct rb_callinfo *ci)
|
|
261
|
+
{
|
|
262
|
+
if (! ci) {
|
|
263
|
+
return false; /* or true? This is Qfalse... */
|
|
264
|
+
}
|
|
265
|
+
else if (vm_ci_packed_p(ci)) {
|
|
266
|
+
return true;
|
|
267
|
+
}
|
|
268
|
+
else {
|
|
269
|
+
VM_ASSERT(IMEMO_TYPE_P(ci, imemo_callinfo));
|
|
270
|
+
return ! FL_ANY_RAW((VALUE)ci, VM_CALLINFO_NOT_UNDER_GC);
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
#define VM_CI_ON_STACK(mid_, flags_, argc_, kwarg_) \
|
|
275
|
+
(struct rb_callinfo) { \
|
|
276
|
+
.flags = T_IMEMO | \
|
|
277
|
+
(imemo_callinfo << FL_USHIFT) | \
|
|
278
|
+
VM_CALLINFO_NOT_UNDER_GC, \
|
|
279
|
+
.mid = mid_, \
|
|
280
|
+
.flag = flags_, \
|
|
281
|
+
.argc = argc_, \
|
|
282
|
+
.kwarg = kwarg_, \
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
typedef VALUE (*vm_call_handler)(
|
|
286
|
+
struct rb_execution_context_struct *ec,
|
|
287
|
+
struct rb_control_frame_struct *cfp,
|
|
288
|
+
struct rb_calling_info *calling);
|
|
289
|
+
|
|
290
|
+
// imemo_callcache
|
|
291
|
+
|
|
292
|
+
struct rb_callcache {
|
|
293
|
+
const VALUE flags;
|
|
294
|
+
|
|
295
|
+
/* inline cache: key */
|
|
296
|
+
const VALUE klass; // Weak reference. When klass is collected, `cc->klass = Qundef`.
|
|
297
|
+
|
|
298
|
+
/* inline cache: values */
|
|
299
|
+
const struct rb_callable_method_entry_struct * const cme_;
|
|
300
|
+
const vm_call_handler call_;
|
|
301
|
+
|
|
302
|
+
union {
|
|
303
|
+
struct {
|
|
304
|
+
uint64_t value; // Shape ID in former half, index in latter half
|
|
305
|
+
} attr;
|
|
306
|
+
const enum method_missing_reason method_missing_reason; /* used by method_missing */
|
|
307
|
+
VALUE v;
|
|
308
|
+
const struct rb_builtin_function *bf;
|
|
309
|
+
} aux_;
|
|
310
|
+
};
|
|
311
|
+
|
|
312
|
+
/* VM_CALLCACHE_IVAR used for IVAR/ATTRSET/STRUCT_AREF/STRUCT_ASET methods */
|
|
313
|
+
#define VM_CALLCACHE_IVAR IMEMO_FL_USER0
|
|
314
|
+
#define VM_CALLCACHE_BF IMEMO_FL_USER1
|
|
315
|
+
#define VM_CALLCACHE_SUPER IMEMO_FL_USER2
|
|
316
|
+
#define VM_CALLCACHE_REFINEMENT IMEMO_FL_USER3
|
|
317
|
+
#define VM_CALLCACHE_UNMARKABLE IMEMO_FL_USER4
|
|
318
|
+
#define VM_CALLCACHE_ON_STACK IMEMO_FL_USER5
|
|
319
|
+
#define VM_CALLCACHE_INVALID_SUPER IMEMO_FL_USER6
|
|
320
|
+
|
|
321
|
+
enum vm_cc_type {
|
|
322
|
+
cc_type_normal, // chained from ccs
|
|
323
|
+
cc_type_super,
|
|
324
|
+
cc_type_refinement,
|
|
325
|
+
};
|
|
326
|
+
|
|
327
|
+
extern const struct rb_callcache *rb_vm_empty_cc(void);
|
|
328
|
+
extern const struct rb_callcache *rb_vm_empty_cc_for_super(void);
|
|
329
|
+
|
|
330
|
+
#define vm_cc_empty() rb_vm_empty_cc()
|
|
331
|
+
|
|
332
|
+
static inline VALUE
|
|
333
|
+
cc_check_class(VALUE klass)
|
|
334
|
+
{
|
|
335
|
+
VM_ASSERT(klass == Qundef || RB_TYPE_P(klass, T_CLASS) || RB_TYPE_P(klass, T_ICLASS));
|
|
336
|
+
return klass;
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
VALUE rb_vm_cc_table_create(size_t capa);
|
|
340
|
+
VALUE rb_vm_cc_table_dup(VALUE old_table);
|
|
341
|
+
void rb_vm_cc_table_delete(VALUE table, ID mid);
|
|
342
|
+
|
|
343
|
+
static inline void vm_cc_attr_index_set(const struct rb_callcache *cc, uint64_t packed_cache);
|
|
344
|
+
|
|
345
|
+
static inline const struct rb_callcache *
|
|
346
|
+
vm_cc_new(VALUE klass,
|
|
347
|
+
const struct rb_callable_method_entry_struct *cme,
|
|
348
|
+
vm_call_handler call,
|
|
349
|
+
enum vm_cc_type type)
|
|
350
|
+
{
|
|
351
|
+
cc_check_class(klass);
|
|
352
|
+
struct rb_callcache *cc = SHAREABLE_IMEMO_NEW(struct rb_callcache, imemo_callcache, klass);
|
|
353
|
+
rb_gc_declare_weak_references((VALUE)cc);
|
|
354
|
+
|
|
355
|
+
*((struct rb_callable_method_entry_struct **)&cc->cme_) = (struct rb_callable_method_entry_struct *)cme;
|
|
356
|
+
*((vm_call_handler *)&cc->call_) = call;
|
|
357
|
+
|
|
358
|
+
switch (type) {
|
|
359
|
+
case cc_type_normal:
|
|
360
|
+
break;
|
|
361
|
+
case cc_type_super:
|
|
362
|
+
*(VALUE *)&cc->flags |= VM_CALLCACHE_SUPER;
|
|
363
|
+
break;
|
|
364
|
+
case cc_type_refinement:
|
|
365
|
+
*(VALUE *)&cc->flags |= VM_CALLCACHE_REFINEMENT;
|
|
366
|
+
rb_vm_insert_cc_refinement(cc);
|
|
367
|
+
break;
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
if (cme) {
|
|
371
|
+
if (cme->def->type == VM_METHOD_TYPE_ATTRSET) {
|
|
372
|
+
vm_cc_attr_index_set(cc, IVAR_CACHE_INIT);
|
|
373
|
+
}
|
|
374
|
+
else if (cme->def->type == VM_METHOD_TYPE_IVAR) {
|
|
375
|
+
vm_cc_attr_index_set(cc, rb_getivar_cache_pack(ROOT_SHAPE_ID, ATTR_INDEX_NOT_SET));
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
else {
|
|
379
|
+
*(VALUE *)&cc->flags |= VM_CALLCACHE_INVALID_SUPER;
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
RB_DEBUG_COUNTER_INC(cc_new);
|
|
383
|
+
return cc;
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
static inline bool
|
|
387
|
+
vm_cc_super_p(const struct rb_callcache *cc)
|
|
388
|
+
{
|
|
389
|
+
return (cc->flags & VM_CALLCACHE_SUPER) != 0;
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
static inline bool
|
|
393
|
+
vm_cc_refinement_p(const struct rb_callcache *cc)
|
|
394
|
+
{
|
|
395
|
+
return (cc->flags & VM_CALLCACHE_REFINEMENT) != 0;
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
#define VM_CC_ON_STACK(clazz, call, aux, cme) \
|
|
399
|
+
(struct rb_callcache) { \
|
|
400
|
+
.flags = T_IMEMO | \
|
|
401
|
+
(imemo_callcache << FL_USHIFT) | \
|
|
402
|
+
VM_CALLCACHE_UNMARKABLE | \
|
|
403
|
+
VM_CALLCACHE_ON_STACK, \
|
|
404
|
+
.klass = cc_check_class(clazz), \
|
|
405
|
+
.cme_ = cme, \
|
|
406
|
+
.call_ = call, \
|
|
407
|
+
.aux_ = aux, \
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
static inline bool
|
|
411
|
+
vm_cc_class_check(const struct rb_callcache *cc, VALUE klass)
|
|
412
|
+
{
|
|
413
|
+
VM_ASSERT(IMEMO_TYPE_P(cc, imemo_callcache));
|
|
414
|
+
VM_ASSERT(cc_check_class(cc->klass));
|
|
415
|
+
return cc->klass == klass;
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
static inline int
|
|
419
|
+
vm_cc_markable(const struct rb_callcache *cc)
|
|
420
|
+
{
|
|
421
|
+
VM_ASSERT(IMEMO_TYPE_P(cc, imemo_callcache));
|
|
422
|
+
return FL_TEST_RAW((VALUE)cc, VM_CALLCACHE_UNMARKABLE) == 0;
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
static inline bool
|
|
426
|
+
vm_cc_invalid_super(const struct rb_callcache *cc)
|
|
427
|
+
{
|
|
428
|
+
VM_ASSERT(IMEMO_TYPE_P(cc, imemo_callcache));
|
|
429
|
+
// Set when calling super and there is no superclass.
|
|
430
|
+
return FL_TEST_RAW((VALUE)cc, VM_CALLCACHE_INVALID_SUPER);
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
static inline bool
|
|
434
|
+
vm_cc_valid(const struct rb_callcache *cc)
|
|
435
|
+
{
|
|
436
|
+
VM_ASSERT(IMEMO_TYPE_P(cc, imemo_callcache));
|
|
437
|
+
VM_ASSERT(cc_check_class(cc->klass));
|
|
438
|
+
|
|
439
|
+
return !UNDEF_P(cc->klass);
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
/* Whether another ractor may have invalidated this cc mid-use (see
|
|
443
|
+
* vm_cc_invalidate()). Extensions cannot use rb_multi_ractor_p() here: with
|
|
444
|
+
* assertions enabled at -O0 (e.g. --enable-yjit=dev on macOS) the inline
|
|
445
|
+
* materializes references to core-internal globals (ruby_current_vm_ptr,
|
|
446
|
+
* ruby_single_main_ractor) that are not exported to them, and objspace.bundle
|
|
447
|
+
* fails to load. RUBY_EXPORT marks a core TU. */
|
|
448
|
+
#ifdef RUBY_EXPORT
|
|
449
|
+
# define VM_CC_RACED_P() rb_multi_ractor_p()
|
|
450
|
+
#else
|
|
451
|
+
# define VM_CC_RACED_P() true
|
|
452
|
+
#endif
|
|
453
|
+
|
|
454
|
+
static inline const struct rb_callable_method_entry_struct *
|
|
455
|
+
vm_cc_cme(const struct rb_callcache *cc)
|
|
456
|
+
{
|
|
457
|
+
VM_ASSERT(IMEMO_TYPE_P(cc, imemo_callcache));
|
|
458
|
+
// VM_CC_RACED_P(): another ractor can invalidate this cc (klass = Qundef)
|
|
459
|
+
// while a call using it is in flight; cme_/call_ stay intact, so the call
|
|
460
|
+
// proceeds with the method resolved before the redefinition.
|
|
461
|
+
VM_ASSERT(cc->klass != Qundef || !vm_cc_markable(cc) || vm_cc_invalid_super(cc) || VM_CC_RACED_P());
|
|
462
|
+
VM_ASSERT(cc_check_class(cc->klass));
|
|
463
|
+
VM_ASSERT(cc->call_ == NULL || // not initialized yet
|
|
464
|
+
!vm_cc_markable(cc) ||
|
|
465
|
+
vm_cc_invalid_super(cc) ||
|
|
466
|
+
cc->cme_ != NULL);
|
|
467
|
+
|
|
468
|
+
return cc->cme_;
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
static inline vm_call_handler
|
|
472
|
+
vm_cc_call(const struct rb_callcache *cc)
|
|
473
|
+
{
|
|
474
|
+
VM_ASSERT(IMEMO_TYPE_P(cc, imemo_callcache));
|
|
475
|
+
VM_ASSERT(cc->call_ != NULL);
|
|
476
|
+
VM_ASSERT(cc->klass != Qundef || !vm_cc_markable(cc) || vm_cc_invalid_super(cc) || VM_CC_RACED_P());
|
|
477
|
+
VM_ASSERT(cc_check_class(cc->klass));
|
|
478
|
+
return cc->call_;
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
static inline uint64_t
|
|
482
|
+
vm_cc_atomic_cache_read(const struct rb_callcache *cc)
|
|
483
|
+
{
|
|
484
|
+
return ATOMIC_U64_LOAD_RELAXED(cc->aux_.attr.value);
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
static inline uint64_t
|
|
488
|
+
vm_ic_atomic_cache_read(const struct iseq_inline_iv_cache_entry *ic)
|
|
489
|
+
{
|
|
490
|
+
return ATOMIC_U64_LOAD_RELAXED(ic->value);
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
static inline uint64_t
|
|
494
|
+
vm_cache_attr_index_atomic_read(bool is_attr, const struct iseq_inline_iv_cache_entry *ic, const struct rb_callcache *cc)
|
|
495
|
+
{
|
|
496
|
+
if (is_attr) {
|
|
497
|
+
return vm_cc_atomic_cache_read(cc);
|
|
498
|
+
}
|
|
499
|
+
else {
|
|
500
|
+
return vm_ic_atomic_cache_read(ic);
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
static inline unsigned int
|
|
505
|
+
vm_cc_cmethod_missing_reason(const struct rb_callcache *cc)
|
|
506
|
+
{
|
|
507
|
+
VM_ASSERT(IMEMO_TYPE_P(cc, imemo_callcache));
|
|
508
|
+
return cc->aux_.method_missing_reason;
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
static inline bool
|
|
512
|
+
vm_cc_invalidated_p(const struct rb_callcache *cc)
|
|
513
|
+
{
|
|
514
|
+
if (vm_cc_valid(cc) && !METHOD_ENTRY_INVALIDATED(vm_cc_cme(cc))) {
|
|
515
|
+
return false;
|
|
516
|
+
}
|
|
517
|
+
else {
|
|
518
|
+
return true;
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
/* callcache: mutate */
|
|
523
|
+
|
|
524
|
+
static inline void
|
|
525
|
+
vm_cc_call_set(const struct rb_callcache *cc, vm_call_handler call)
|
|
526
|
+
{
|
|
527
|
+
VM_ASSERT(IMEMO_TYPE_P(cc, imemo_callcache));
|
|
528
|
+
VM_ASSERT(cc != vm_cc_empty());
|
|
529
|
+
*(vm_call_handler *)&cc->call_ = call;
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
static inline void
|
|
533
|
+
set_vm_cc_ivar(const struct rb_callcache *cc)
|
|
534
|
+
{
|
|
535
|
+
*(VALUE *)&cc->flags |= VM_CALLCACHE_IVAR;
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
static inline bool
|
|
539
|
+
vm_cc_ivar_p(const struct rb_callcache *cc)
|
|
540
|
+
{
|
|
541
|
+
return (cc->flags & VM_CALLCACHE_IVAR) != 0;
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
static inline void
|
|
545
|
+
vm_cc_attr_index_set(const struct rb_callcache *cc, uint64_t packed_cache)
|
|
546
|
+
{
|
|
547
|
+
uint64_t *attr_value = (uint64_t *)&cc->aux_.attr.value;
|
|
548
|
+
if (!vm_cc_markable(cc)) {
|
|
549
|
+
*attr_value = IVAR_CACHE_INIT;
|
|
550
|
+
return;
|
|
551
|
+
}
|
|
552
|
+
VM_ASSERT(IMEMO_TYPE_P(cc, imemo_callcache));
|
|
553
|
+
VM_ASSERT(cc != vm_cc_empty());
|
|
554
|
+
*attr_value = packed_cache;
|
|
555
|
+
set_vm_cc_ivar(cc);
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
static inline void
|
|
559
|
+
vm_cache_attr_index_set(bool is_attr, struct iseq_inline_iv_cache_entry *ic, const struct rb_callcache *cc, uint64_t packed_cache)
|
|
560
|
+
{
|
|
561
|
+
if (is_attr) {
|
|
562
|
+
vm_cc_attr_index_set(cc, packed_cache);
|
|
563
|
+
}
|
|
564
|
+
else {
|
|
565
|
+
ATOMIC_U64_SET_RELAXED(ic->value, packed_cache);
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
static inline void
|
|
570
|
+
vm_cc_method_missing_reason_set(const struct rb_callcache *cc, enum method_missing_reason reason)
|
|
571
|
+
{
|
|
572
|
+
VM_ASSERT(IMEMO_TYPE_P(cc, imemo_callcache));
|
|
573
|
+
VM_ASSERT(cc != vm_cc_empty());
|
|
574
|
+
*(enum method_missing_reason *)&cc->aux_.method_missing_reason = reason;
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
static inline void
|
|
578
|
+
vm_cc_bf_set(const struct rb_callcache *cc, const struct rb_builtin_function *bf)
|
|
579
|
+
{
|
|
580
|
+
VM_ASSERT(IMEMO_TYPE_P(cc, imemo_callcache));
|
|
581
|
+
VM_ASSERT(cc != vm_cc_empty());
|
|
582
|
+
*(const struct rb_builtin_function **)&cc->aux_.bf = bf;
|
|
583
|
+
*(VALUE *)&cc->flags |= VM_CALLCACHE_BF;
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
static inline bool
|
|
587
|
+
vm_cc_bf_p(const struct rb_callcache *cc)
|
|
588
|
+
{
|
|
589
|
+
return (cc->flags & VM_CALLCACHE_BF) != 0;
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
static inline void
|
|
593
|
+
vm_cc_invalidate(const struct rb_callcache *cc)
|
|
594
|
+
{
|
|
595
|
+
VM_ASSERT(IMEMO_TYPE_P(cc, imemo_callcache));
|
|
596
|
+
VM_ASSERT(cc != vm_cc_empty());
|
|
597
|
+
// TODO: rb_multi_ractor_p() is a workaround to stabilize CI
|
|
598
|
+
VM_ASSERT(cc->klass != Qundef || rb_multi_ractor_p()); // should be enable
|
|
599
|
+
|
|
600
|
+
*(VALUE *)&cc->klass = Qundef;
|
|
601
|
+
RB_DEBUG_COUNTER_INC(cc_ent_invalidate);
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
/* calldata */
|
|
605
|
+
|
|
606
|
+
struct rb_call_data {
|
|
607
|
+
const struct rb_callinfo *ci;
|
|
608
|
+
const struct rb_callcache *cc;
|
|
609
|
+
};
|
|
610
|
+
|
|
611
|
+
struct rb_class_cc_entries {
|
|
612
|
+
#if VM_CHECK_MODE > 0
|
|
613
|
+
VALUE debug_sig;
|
|
614
|
+
#endif
|
|
615
|
+
int capa;
|
|
616
|
+
int len;
|
|
617
|
+
const struct rb_callable_method_entry_struct *cme;
|
|
618
|
+
struct rb_class_cc_entries_entry {
|
|
619
|
+
const struct rb_callcache *cc;
|
|
620
|
+
unsigned int argc;
|
|
621
|
+
unsigned short flag;
|
|
622
|
+
unsigned short kw_len;
|
|
623
|
+
} entries[FLEX_ARY_LEN];
|
|
624
|
+
};
|
|
625
|
+
|
|
626
|
+
/* entries[].flag is an unsigned short, so every VM_CALL flag bit must fit in 16 bits. */
|
|
627
|
+
STATIC_ASSERT(cc_entries_flag_fits_in_short, VM_CALL__END <= 16);
|
|
628
|
+
|
|
629
|
+
/* entries[].kw_len is an unsigned short, so a call site cannot carry, nor a method
|
|
630
|
+
declare, more keyword arguments than this. Enforced at compile time. */
|
|
631
|
+
#define VM_CALL_KW_LEN_MAX UINT16_MAX
|
|
632
|
+
|
|
633
|
+
static inline size_t
|
|
634
|
+
vm_ccs_alloc_size(size_t capa)
|
|
635
|
+
{
|
|
636
|
+
return offsetof(struct rb_class_cc_entries, entries) + (sizeof(struct rb_class_cc_entries_entry) * capa);
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
#if VM_CHECK_MODE > 0
|
|
640
|
+
|
|
641
|
+
const rb_callable_method_entry_t *rb_vm_lookup_overloaded_cme(const rb_callable_method_entry_t *cme);
|
|
642
|
+
void rb_vm_dump_overloaded_cme_table(void);
|
|
643
|
+
|
|
644
|
+
static inline bool
|
|
645
|
+
vm_ccs_p(const struct rb_class_cc_entries *ccs)
|
|
646
|
+
{
|
|
647
|
+
return ccs->debug_sig == ~(VALUE)ccs;
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
static inline bool
|
|
651
|
+
vm_cc_check_cme_unlocked(const struct rb_callcache *cc, const rb_callable_method_entry_t *cme)
|
|
652
|
+
{
|
|
653
|
+
return vm_cc_cme(cc) == cme ||
|
|
654
|
+
(cme->def->iseq_overload && vm_cc_cme(cc) == rb_vm_lookup_overloaded_cme(cme));
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
static inline bool
|
|
658
|
+
vm_cc_check_cme(const struct rb_callcache *cc, const rb_callable_method_entry_t *cme)
|
|
659
|
+
{
|
|
660
|
+
bool valid;
|
|
661
|
+
if (rb_current_execution_context(false) == NULL) {
|
|
662
|
+
valid = vm_cc_check_cme_unlocked(cc, cme);
|
|
663
|
+
}
|
|
664
|
+
else {
|
|
665
|
+
RB_VM_LOCKING_NO_BARRIER() {
|
|
666
|
+
valid = vm_cc_check_cme_unlocked(cc, cme);
|
|
667
|
+
}
|
|
668
|
+
}
|
|
669
|
+
if (valid) {
|
|
670
|
+
return true;
|
|
671
|
+
}
|
|
672
|
+
#if 1
|
|
673
|
+
// debug print
|
|
674
|
+
|
|
675
|
+
fprintf(stderr, "iseq_overload:%d, cme:%p (def:%p), cm_cc_cme(cc):%p (def:%p)\n",
|
|
676
|
+
(int)cme->def->iseq_overload,
|
|
677
|
+
(void *)cme, (void *)cme->def,
|
|
678
|
+
(void *)vm_cc_cme(cc), (void *)vm_cc_cme(cc)->def);
|
|
679
|
+
rp(cme);
|
|
680
|
+
rp(vm_cc_cme(cc));
|
|
681
|
+
rp(rb_vm_lookup_overloaded_cme(cme));
|
|
682
|
+
#endif
|
|
683
|
+
return false;
|
|
684
|
+
}
|
|
685
|
+
|
|
686
|
+
#endif
|
|
687
|
+
|
|
688
|
+
#endif /* RUBY_VM_CALLINFO_H */
|