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,245 @@
|
|
1
|
+
#ifndef RUBY_METHOD_H
|
2
|
+
#define RUBY_METHOD_H 1
|
3
|
+
/**********************************************************************
|
4
|
+
|
5
|
+
method.h -
|
6
|
+
|
7
|
+
$Author$
|
8
|
+
created at: Wed Jul 15 20:02:33 2009
|
9
|
+
|
10
|
+
Copyright (C) 2009 Koichi Sasada
|
11
|
+
|
12
|
+
**********************************************************************/
|
13
|
+
|
14
|
+
#include "internal.h"
|
15
|
+
#include "internal/imemo.h"
|
16
|
+
#include "internal/compilers.h"
|
17
|
+
#include "internal/static_assert.h"
|
18
|
+
|
19
|
+
#ifndef END_OF_ENUMERATION
|
20
|
+
# if defined(__GNUC__) &&! defined(__STRICT_ANSI__)
|
21
|
+
# define END_OF_ENUMERATION(key)
|
22
|
+
# else
|
23
|
+
# define END_OF_ENUMERATION(key) END_OF_##key##_PLACEHOLDER = 0
|
24
|
+
# endif
|
25
|
+
#endif
|
26
|
+
|
27
|
+
/* cref */
|
28
|
+
|
29
|
+
typedef enum {
|
30
|
+
METHOD_VISI_UNDEF = 0x00,
|
31
|
+
METHOD_VISI_PUBLIC = 0x01,
|
32
|
+
METHOD_VISI_PRIVATE = 0x02,
|
33
|
+
METHOD_VISI_PROTECTED = 0x03,
|
34
|
+
|
35
|
+
METHOD_VISI_MASK = 0x03
|
36
|
+
} rb_method_visibility_t;
|
37
|
+
|
38
|
+
typedef struct rb_scope_visi_struct {
|
39
|
+
BITFIELD(rb_method_visibility_t, method_visi, 3);
|
40
|
+
unsigned int module_func : 1;
|
41
|
+
} rb_scope_visibility_t;
|
42
|
+
|
43
|
+
/*! CREF (Class REFerence) */
|
44
|
+
typedef struct rb_cref_struct {
|
45
|
+
VALUE flags;
|
46
|
+
VALUE refinements;
|
47
|
+
VALUE klass;
|
48
|
+
struct rb_cref_struct * next;
|
49
|
+
const rb_scope_visibility_t scope_visi;
|
50
|
+
} rb_cref_t;
|
51
|
+
|
52
|
+
/* method data type */
|
53
|
+
|
54
|
+
typedef struct rb_method_entry_struct {
|
55
|
+
VALUE flags;
|
56
|
+
VALUE defined_class;
|
57
|
+
struct rb_method_definition_struct * const def;
|
58
|
+
ID called_id;
|
59
|
+
VALUE owner;
|
60
|
+
} rb_method_entry_t;
|
61
|
+
|
62
|
+
typedef struct rb_callable_method_entry_struct { /* same fields with rb_method_entry_t */
|
63
|
+
VALUE flags;
|
64
|
+
const VALUE defined_class;
|
65
|
+
struct rb_method_definition_struct * const def;
|
66
|
+
ID called_id;
|
67
|
+
const VALUE owner;
|
68
|
+
} rb_callable_method_entry_t;
|
69
|
+
|
70
|
+
#define METHOD_ENTRY_VISI(me) (rb_method_visibility_t)(((me)->flags & (IMEMO_FL_USER0 | IMEMO_FL_USER1)) >> (IMEMO_FL_USHIFT+0))
|
71
|
+
#define METHOD_ENTRY_BASIC(me) (int) (((me)->flags & (IMEMO_FL_USER2 )) >> (IMEMO_FL_USHIFT+2))
|
72
|
+
#define METHOD_ENTRY_COMPLEMENTED(me) ((me)->flags & IMEMO_FL_USER3)
|
73
|
+
#define METHOD_ENTRY_COMPLEMENTED_SET(me) ((me)->flags |= IMEMO_FL_USER3)
|
74
|
+
#define METHOD_ENTRY_CACHED(me) ((me)->flags & IMEMO_FL_USER4)
|
75
|
+
#define METHOD_ENTRY_CACHED_SET(me) ((me)->flags |= IMEMO_FL_USER4)
|
76
|
+
#define METHOD_ENTRY_INVALIDATED(me) ((me)->flags & IMEMO_FL_USER5)
|
77
|
+
#define METHOD_ENTRY_INVALIDATED_SET(me) ((me)->flags |= IMEMO_FL_USER5)
|
78
|
+
#define METHOD_ENTRY_CACHEABLE(me) !(METHOD_ENTRY_VISI(me) == METHOD_VISI_PROTECTED)
|
79
|
+
|
80
|
+
static inline void
|
81
|
+
METHOD_ENTRY_VISI_SET(rb_method_entry_t *me, rb_method_visibility_t visi)
|
82
|
+
{
|
83
|
+
VM_ASSERT((int)visi >= 0 && visi <= 3);
|
84
|
+
me->flags = (me->flags & ~(IMEMO_FL_USER0 | IMEMO_FL_USER1)) | (visi << (IMEMO_FL_USHIFT+0));
|
85
|
+
}
|
86
|
+
static inline void
|
87
|
+
METHOD_ENTRY_BASIC_SET(rb_method_entry_t *me, unsigned int basic)
|
88
|
+
{
|
89
|
+
VM_ASSERT(basic <= 1);
|
90
|
+
me->flags = (me->flags & ~(IMEMO_FL_USER2 )) | (basic << (IMEMO_FL_USHIFT+2));
|
91
|
+
}
|
92
|
+
static inline void
|
93
|
+
METHOD_ENTRY_FLAGS_SET(rb_method_entry_t *me, rb_method_visibility_t visi, unsigned int basic)
|
94
|
+
{
|
95
|
+
VM_ASSERT((int)visi >= 0 && visi <= 3);
|
96
|
+
VM_ASSERT(basic <= 1);
|
97
|
+
me->flags =
|
98
|
+
(me->flags & ~(IMEMO_FL_USER0|IMEMO_FL_USER1|IMEMO_FL_USER2)) |
|
99
|
+
((visi << (IMEMO_FL_USHIFT+0)) | (basic << (IMEMO_FL_USHIFT+2)));
|
100
|
+
}
|
101
|
+
static inline void
|
102
|
+
METHOD_ENTRY_FLAGS_COPY(rb_method_entry_t *dst, const rb_method_entry_t *src)
|
103
|
+
{
|
104
|
+
dst->flags =
|
105
|
+
(dst->flags & ~(IMEMO_FL_USER0|IMEMO_FL_USER1|IMEMO_FL_USER2)) |
|
106
|
+
(src->flags & (IMEMO_FL_USER0|IMEMO_FL_USER1|IMEMO_FL_USER2));
|
107
|
+
}
|
108
|
+
|
109
|
+
typedef enum {
|
110
|
+
VM_METHOD_TYPE_ISEQ, /*!< Ruby method */
|
111
|
+
VM_METHOD_TYPE_CFUNC, /*!< C method */
|
112
|
+
VM_METHOD_TYPE_ATTRSET, /*!< attr_writer or attr_accessor */
|
113
|
+
VM_METHOD_TYPE_IVAR, /*!< attr_reader or attr_accessor */
|
114
|
+
VM_METHOD_TYPE_BMETHOD,
|
115
|
+
VM_METHOD_TYPE_ZSUPER,
|
116
|
+
VM_METHOD_TYPE_ALIAS,
|
117
|
+
VM_METHOD_TYPE_UNDEF,
|
118
|
+
VM_METHOD_TYPE_NOTIMPLEMENTED,
|
119
|
+
VM_METHOD_TYPE_OPTIMIZED, /*!< Kernel#send, Proc#call, etc */
|
120
|
+
VM_METHOD_TYPE_MISSING, /*!< wrapper for method_missing(id) */
|
121
|
+
VM_METHOD_TYPE_REFINED, /*!< refinement */
|
122
|
+
|
123
|
+
END_OF_ENUMERATION(VM_METHOD_TYPE)
|
124
|
+
} rb_method_type_t;
|
125
|
+
#define VM_METHOD_TYPE_MINIMUM_BITS 4
|
126
|
+
STATIC_ASSERT(VM_METHOD_TYPE_MINIMUM_BITS,
|
127
|
+
VM_METHOD_TYPE_REFINED <= (1<<VM_METHOD_TYPE_MINIMUM_BITS));
|
128
|
+
|
129
|
+
#ifndef rb_iseq_t
|
130
|
+
typedef struct rb_iseq_struct rb_iseq_t;
|
131
|
+
#define rb_iseq_t rb_iseq_t
|
132
|
+
#endif
|
133
|
+
|
134
|
+
typedef struct rb_method_iseq_struct {
|
135
|
+
rb_iseq_t * iseqptr; /*!< iseq pointer, should be separated from iseqval */
|
136
|
+
rb_cref_t * cref; /*!< class reference, should be marked */
|
137
|
+
} rb_method_iseq_t; /* check rb_add_method_iseq() when modify the fields */
|
138
|
+
|
139
|
+
typedef struct rb_method_cfunc_struct {
|
140
|
+
VALUE (*func)(ANYARGS);
|
141
|
+
VALUE (*invoker)(VALUE recv, int argc, const VALUE *argv, VALUE (*func)(ANYARGS));
|
142
|
+
int argc;
|
143
|
+
} rb_method_cfunc_t;
|
144
|
+
|
145
|
+
typedef struct rb_method_attr_struct {
|
146
|
+
ID id;
|
147
|
+
VALUE location; /* should be marked */
|
148
|
+
} rb_method_attr_t;
|
149
|
+
|
150
|
+
typedef struct rb_method_alias_struct {
|
151
|
+
struct rb_method_entry_struct * original_me; /* original_me->klass is original owner */
|
152
|
+
} rb_method_alias_t;
|
153
|
+
|
154
|
+
typedef struct rb_method_refined_struct {
|
155
|
+
struct rb_method_entry_struct * orig_me;
|
156
|
+
VALUE owner;
|
157
|
+
} rb_method_refined_t;
|
158
|
+
|
159
|
+
typedef struct rb_method_bmethod_struct {
|
160
|
+
VALUE proc; /* should be marked */
|
161
|
+
struct rb_hook_list_struct *hooks;
|
162
|
+
VALUE defined_ractor;
|
163
|
+
} rb_method_bmethod_t;
|
164
|
+
|
165
|
+
enum method_optimized_type {
|
166
|
+
OPTIMIZED_METHOD_TYPE_SEND,
|
167
|
+
OPTIMIZED_METHOD_TYPE_CALL,
|
168
|
+
OPTIMIZED_METHOD_TYPE_BLOCK_CALL,
|
169
|
+
OPTIMIZED_METHOD_TYPE__MAX
|
170
|
+
};
|
171
|
+
|
172
|
+
struct rb_method_definition_struct {
|
173
|
+
BITFIELD(rb_method_type_t, type, VM_METHOD_TYPE_MINIMUM_BITS);
|
174
|
+
int alias_count : 28;
|
175
|
+
int complemented_count : 28;
|
176
|
+
|
177
|
+
union {
|
178
|
+
rb_method_iseq_t iseq;
|
179
|
+
rb_method_cfunc_t cfunc;
|
180
|
+
rb_method_attr_t attr;
|
181
|
+
rb_method_alias_t alias;
|
182
|
+
rb_method_refined_t refined;
|
183
|
+
rb_method_bmethod_t bmethod;
|
184
|
+
|
185
|
+
enum method_optimized_type optimize_type;
|
186
|
+
} body;
|
187
|
+
|
188
|
+
ID original_id;
|
189
|
+
uintptr_t method_serial;
|
190
|
+
};
|
191
|
+
|
192
|
+
struct rb_id_table;
|
193
|
+
|
194
|
+
typedef struct rb_method_definition_struct rb_method_definition_t;
|
195
|
+
STATIC_ASSERT(sizeof_method_def, offsetof(rb_method_definition_t, body)==8);
|
196
|
+
|
197
|
+
#define UNDEFINED_METHOD_ENTRY_P(me) (!(me) || !(me)->def || (me)->def->type == VM_METHOD_TYPE_UNDEF)
|
198
|
+
#define UNDEFINED_REFINED_METHOD_P(def) \
|
199
|
+
((def)->type == VM_METHOD_TYPE_REFINED && \
|
200
|
+
UNDEFINED_METHOD_ENTRY_P((def)->body.refined.orig_me))
|
201
|
+
|
202
|
+
void rb_add_method_cfunc(VALUE klass, ID mid, VALUE (*func)(ANYARGS), int argc, rb_method_visibility_t visi);
|
203
|
+
void rb_add_method_iseq(VALUE klass, ID mid, const rb_iseq_t *iseq, rb_cref_t *cref, rb_method_visibility_t visi);
|
204
|
+
void rb_add_refined_method_entry(VALUE refined_class, ID mid);
|
205
|
+
void rb_add_method(VALUE klass, ID mid, rb_method_type_t type, void *option, rb_method_visibility_t visi);
|
206
|
+
|
207
|
+
rb_method_entry_t *rb_method_entry_set(VALUE klass, ID mid, const rb_method_entry_t *, rb_method_visibility_t noex);
|
208
|
+
rb_method_entry_t *rb_method_entry_create(ID called_id, VALUE klass, rb_method_visibility_t visi, const rb_method_definition_t *def);
|
209
|
+
|
210
|
+
const rb_method_entry_t *rb_method_entry_at(VALUE obj, ID id);
|
211
|
+
|
212
|
+
const rb_method_entry_t *rb_method_entry(VALUE klass, ID id);
|
213
|
+
const rb_method_entry_t *rb_method_entry_with_refinements(VALUE klass, ID id, VALUE *defined_class);
|
214
|
+
const rb_method_entry_t *rb_method_entry_without_refinements(VALUE klass, ID id, VALUE *defined_class);
|
215
|
+
const rb_method_entry_t *rb_resolve_refined_method(VALUE refinements, const rb_method_entry_t *me);
|
216
|
+
RUBY_SYMBOL_EXPORT_BEGIN
|
217
|
+
const rb_method_entry_t *rb_resolve_me_location(const rb_method_entry_t *, VALUE[5]);
|
218
|
+
RUBY_SYMBOL_EXPORT_END
|
219
|
+
|
220
|
+
const rb_callable_method_entry_t *rb_callable_method_entry(VALUE klass, ID id);
|
221
|
+
const rb_callable_method_entry_t *rb_callable_method_entry_with_refinements(VALUE klass, ID id, VALUE *defined_class);
|
222
|
+
const rb_callable_method_entry_t *rb_callable_method_entry_without_refinements(VALUE klass, ID id, VALUE *defined_class);
|
223
|
+
|
224
|
+
int rb_method_entry_arity(const rb_method_entry_t *me);
|
225
|
+
int rb_method_entry_eq(const rb_method_entry_t *m1, const rb_method_entry_t *m2);
|
226
|
+
st_index_t rb_hash_method_entry(st_index_t hash, const rb_method_entry_t *me);
|
227
|
+
|
228
|
+
VALUE rb_method_entry_location(const rb_method_entry_t *me);
|
229
|
+
|
230
|
+
void rb_free_method_entry(const rb_method_entry_t *me);
|
231
|
+
|
232
|
+
const rb_method_entry_t *rb_method_entry_clone(const rb_method_entry_t *me);
|
233
|
+
const rb_callable_method_entry_t *rb_method_entry_complement_defined_class(const rb_method_entry_t *src_me, ID called_id, VALUE defined_class);
|
234
|
+
void rb_method_entry_copy(rb_method_entry_t *dst, const rb_method_entry_t *src);
|
235
|
+
|
236
|
+
void rb_method_table_insert(VALUE klass, struct rb_id_table *table, ID method_id, const rb_method_entry_t *me);
|
237
|
+
|
238
|
+
void rb_scope_visibility_set(rb_method_visibility_t);
|
239
|
+
|
240
|
+
VALUE rb_unnamed_parameters(int arity);
|
241
|
+
|
242
|
+
void rb_clear_method_cache(VALUE klass_or_module, ID mid);
|
243
|
+
void rb_clear_method_cache_all(void);
|
244
|
+
|
245
|
+
#endif /* RUBY_METHOD_H */
|
@@ -0,0 +1,220 @@
|
|
1
|
+
#ifndef RUBY_MJIT_H
|
2
|
+
#define RUBY_MJIT_H 1
|
3
|
+
/**********************************************************************
|
4
|
+
|
5
|
+
mjit.h - Interface to MRI method JIT compiler for Ruby's main thread
|
6
|
+
|
7
|
+
Copyright (C) 2017 Vladimir Makarov <vmakarov@redhat.com>.
|
8
|
+
|
9
|
+
**********************************************************************/
|
10
|
+
|
11
|
+
#include "ruby/internal/config.h" // defines USE_MJIT
|
12
|
+
#include "ruby/internal/stdbool.h"
|
13
|
+
#include "vm_core.h"
|
14
|
+
|
15
|
+
# if USE_MJIT
|
16
|
+
|
17
|
+
#include "debug_counter.h"
|
18
|
+
#include "ruby.h"
|
19
|
+
|
20
|
+
// Special address values of a function generated from the
|
21
|
+
// corresponding iseq by MJIT:
|
22
|
+
enum rb_mjit_iseq_func {
|
23
|
+
// ISEQ was not queued yet for the machine code generation
|
24
|
+
NOT_ADDED_JIT_ISEQ_FUNC = 0,
|
25
|
+
// ISEQ is already queued for the machine code generation but the
|
26
|
+
// code is not ready yet for the execution
|
27
|
+
NOT_READY_JIT_ISEQ_FUNC = 1,
|
28
|
+
// ISEQ included not compilable insn, some internal assertion failed
|
29
|
+
// or the unit is unloaded
|
30
|
+
NOT_COMPILED_JIT_ISEQ_FUNC = 2,
|
31
|
+
// End mark
|
32
|
+
LAST_JIT_ISEQ_FUNC = 3
|
33
|
+
};
|
34
|
+
|
35
|
+
// MJIT options which can be defined on the MRI command line.
|
36
|
+
struct mjit_options {
|
37
|
+
// Converted from "jit" feature flag to tell the enablement
|
38
|
+
// information to ruby_show_version().
|
39
|
+
char on;
|
40
|
+
// Save temporary files after MRI finish. The temporary files
|
41
|
+
// include the pre-compiled header, C code file generated for ISEQ,
|
42
|
+
// and the corresponding object file.
|
43
|
+
char save_temps;
|
44
|
+
// Print MJIT warnings to stderr.
|
45
|
+
char warnings;
|
46
|
+
// Disable compiler optimization and add debug symbols. It can be
|
47
|
+
// very slow.
|
48
|
+
char debug;
|
49
|
+
// Add arbitrary cflags.
|
50
|
+
char* debug_flags;
|
51
|
+
// If not 0, all ISeqs are synchronously compiled. For testing.
|
52
|
+
unsigned int wait;
|
53
|
+
// Number of calls to trigger JIT compilation. For testing.
|
54
|
+
unsigned int min_calls;
|
55
|
+
// Force printing info about MJIT work of level VERBOSE or
|
56
|
+
// less. 0=silence, 1=medium, 2=verbose.
|
57
|
+
int verbose;
|
58
|
+
// Maximal permitted number of iseq JIT codes in a MJIT memory
|
59
|
+
// cache.
|
60
|
+
int max_cache_size;
|
61
|
+
};
|
62
|
+
|
63
|
+
// State of optimization switches
|
64
|
+
struct rb_mjit_compile_info {
|
65
|
+
// Disable getinstancevariable/setinstancevariable optimizations based on inline cache (T_OBJECT)
|
66
|
+
bool disable_ivar_cache;
|
67
|
+
// Disable getinstancevariable/setinstancevariable optimizations based on inline cache (FL_EXIVAR)
|
68
|
+
bool disable_exivar_cache;
|
69
|
+
// Disable send/opt_send_without_block optimizations based on inline cache
|
70
|
+
bool disable_send_cache;
|
71
|
+
// Disable method inlining
|
72
|
+
bool disable_inlining;
|
73
|
+
// Disable opt_getinlinecache inlining
|
74
|
+
bool disable_const_cache;
|
75
|
+
};
|
76
|
+
|
77
|
+
typedef VALUE (*mjit_func_t)(rb_execution_context_t *, rb_control_frame_t *);
|
78
|
+
|
79
|
+
RUBY_SYMBOL_EXPORT_BEGIN
|
80
|
+
RUBY_EXTERN struct mjit_options mjit_opts;
|
81
|
+
RUBY_EXTERN bool mjit_call_p;
|
82
|
+
|
83
|
+
extern void rb_mjit_add_iseq_to_process(const rb_iseq_t *iseq);
|
84
|
+
extern VALUE rb_mjit_wait_call(rb_execution_context_t *ec, struct rb_iseq_constant_body *body);
|
85
|
+
extern struct rb_mjit_compile_info* rb_mjit_iseq_compile_info(const struct rb_iseq_constant_body *body);
|
86
|
+
extern void rb_mjit_before_vm_ic_update(void);
|
87
|
+
extern void rb_mjit_after_vm_ic_update(void);
|
88
|
+
extern void rb_mjit_recompile_send(const rb_iseq_t *iseq);
|
89
|
+
extern void rb_mjit_recompile_ivar(const rb_iseq_t *iseq);
|
90
|
+
extern void rb_mjit_recompile_exivar(const rb_iseq_t *iseq);
|
91
|
+
extern void rb_mjit_recompile_inlining(const rb_iseq_t *iseq);
|
92
|
+
extern void rb_mjit_recompile_const(const rb_iseq_t *iseq);
|
93
|
+
RUBY_SYMBOL_EXPORT_END
|
94
|
+
|
95
|
+
extern bool mjit_compile(FILE *f, const rb_iseq_t *iseq, const char *funcname, int id);
|
96
|
+
extern void mjit_init(const struct mjit_options *opts);
|
97
|
+
extern void mjit_gc_start_hook(void);
|
98
|
+
extern void mjit_gc_exit_hook(void);
|
99
|
+
extern void mjit_free_iseq(const rb_iseq_t *iseq);
|
100
|
+
extern void mjit_update_references(const rb_iseq_t *iseq);
|
101
|
+
extern void mjit_mark(void);
|
102
|
+
extern struct mjit_cont *mjit_cont_new(rb_execution_context_t *ec);
|
103
|
+
extern void mjit_cont_free(struct mjit_cont *cont);
|
104
|
+
extern void mjit_add_class_serial(rb_serial_t class_serial);
|
105
|
+
extern void mjit_remove_class_serial(rb_serial_t class_serial);
|
106
|
+
extern void mjit_mark_cc_entries(const struct rb_iseq_constant_body *const body);
|
107
|
+
|
108
|
+
// A threshold used to reject long iseqs from JITting as such iseqs
|
109
|
+
// takes too much time to be compiled.
|
110
|
+
#define JIT_ISEQ_SIZE_THRESHOLD 1000
|
111
|
+
|
112
|
+
// Return TRUE if given ISeq body should be compiled by MJIT
|
113
|
+
static inline int
|
114
|
+
mjit_target_iseq_p(struct rb_iseq_constant_body *body)
|
115
|
+
{
|
116
|
+
return (body->type == ISEQ_TYPE_METHOD || body->type == ISEQ_TYPE_BLOCK)
|
117
|
+
&& !body->builtin_inline_p
|
118
|
+
&& body->iseq_size < JIT_ISEQ_SIZE_THRESHOLD;
|
119
|
+
}
|
120
|
+
|
121
|
+
# ifdef MJIT_HEADER
|
122
|
+
NOINLINE(static COLDFUNC VALUE mjit_exec_slowpath(rb_execution_context_t *ec, const rb_iseq_t *iseq, struct rb_iseq_constant_body *body));
|
123
|
+
# else
|
124
|
+
static inline VALUE mjit_exec_slowpath(rb_execution_context_t *ec, const rb_iseq_t *iseq, struct rb_iseq_constant_body *body);
|
125
|
+
# endif
|
126
|
+
static VALUE
|
127
|
+
mjit_exec_slowpath(rb_execution_context_t *ec, const rb_iseq_t *iseq, struct rb_iseq_constant_body *body)
|
128
|
+
{
|
129
|
+
uintptr_t func_i = (uintptr_t)(body->jit_func);
|
130
|
+
ASSUME(func_i <= LAST_JIT_ISEQ_FUNC);
|
131
|
+
switch ((enum rb_mjit_iseq_func)func_i) {
|
132
|
+
case NOT_ADDED_JIT_ISEQ_FUNC:
|
133
|
+
RB_DEBUG_COUNTER_INC(mjit_exec_not_added);
|
134
|
+
if (body->total_calls == mjit_opts.min_calls && mjit_target_iseq_p(body)) {
|
135
|
+
rb_mjit_add_iseq_to_process(iseq);
|
136
|
+
if (UNLIKELY(mjit_opts.wait)) {
|
137
|
+
return rb_mjit_wait_call(ec, body);
|
138
|
+
}
|
139
|
+
}
|
140
|
+
break;
|
141
|
+
case NOT_READY_JIT_ISEQ_FUNC:
|
142
|
+
RB_DEBUG_COUNTER_INC(mjit_exec_not_ready);
|
143
|
+
break;
|
144
|
+
case NOT_COMPILED_JIT_ISEQ_FUNC:
|
145
|
+
RB_DEBUG_COUNTER_INC(mjit_exec_not_compiled);
|
146
|
+
break;
|
147
|
+
default: // to avoid warning with LAST_JIT_ISEQ_FUNC
|
148
|
+
break;
|
149
|
+
}
|
150
|
+
return Qundef;
|
151
|
+
}
|
152
|
+
|
153
|
+
// Try to execute the current iseq in ec. Use JIT code if it is ready.
|
154
|
+
// If it is not, add ISEQ to the compilation queue and return Qundef.
|
155
|
+
static inline VALUE
|
156
|
+
mjit_exec(rb_execution_context_t *ec)
|
157
|
+
{
|
158
|
+
const rb_iseq_t *iseq;
|
159
|
+
struct rb_iseq_constant_body *body;
|
160
|
+
|
161
|
+
if (!mjit_call_p)
|
162
|
+
return Qundef;
|
163
|
+
RB_DEBUG_COUNTER_INC(mjit_exec);
|
164
|
+
|
165
|
+
iseq = ec->cfp->iseq;
|
166
|
+
body = iseq->body;
|
167
|
+
body->total_calls++;
|
168
|
+
|
169
|
+
mjit_func_t func = body->jit_func;
|
170
|
+
if (UNLIKELY((uintptr_t)func <= LAST_JIT_ISEQ_FUNC)) {
|
171
|
+
# ifdef MJIT_HEADER
|
172
|
+
RB_DEBUG_COUNTER_INC(mjit_frame_JT2VM);
|
173
|
+
# else
|
174
|
+
RB_DEBUG_COUNTER_INC(mjit_frame_VM2VM);
|
175
|
+
# endif
|
176
|
+
return mjit_exec_slowpath(ec, iseq, body);
|
177
|
+
}
|
178
|
+
|
179
|
+
# ifdef MJIT_HEADER
|
180
|
+
RB_DEBUG_COUNTER_INC(mjit_frame_JT2JT);
|
181
|
+
# else
|
182
|
+
RB_DEBUG_COUNTER_INC(mjit_frame_VM2JT);
|
183
|
+
# endif
|
184
|
+
RB_DEBUG_COUNTER_INC(mjit_exec_call_func);
|
185
|
+
return func(ec, ec->cfp);
|
186
|
+
}
|
187
|
+
|
188
|
+
void mjit_child_after_fork(void);
|
189
|
+
|
190
|
+
# ifdef MJIT_HEADER
|
191
|
+
#define mjit_enabled true
|
192
|
+
# else // MJIT_HEADER
|
193
|
+
extern bool mjit_enabled;
|
194
|
+
# endif // MJIT_HEADER
|
195
|
+
VALUE mjit_pause(bool wait_p);
|
196
|
+
VALUE mjit_resume(void);
|
197
|
+
void mjit_finish(bool close_handle_p);
|
198
|
+
|
199
|
+
# else // USE_MJIT
|
200
|
+
|
201
|
+
static inline void rb_mjit_before_vm_ic_update(void){}
|
202
|
+
static inline void rb_mjit_after_vm_ic_update(void){}
|
203
|
+
static inline struct mjit_cont *mjit_cont_new(rb_execution_context_t *ec){return NULL;}
|
204
|
+
static inline void mjit_cont_free(struct mjit_cont *cont){}
|
205
|
+
static inline void mjit_gc_start_hook(void){}
|
206
|
+
static inline void mjit_gc_exit_hook(void){}
|
207
|
+
static inline void mjit_free_iseq(const rb_iseq_t *iseq){}
|
208
|
+
static inline void mjit_mark(void){}
|
209
|
+
static inline void mjit_add_class_serial(rb_serial_t class_serial){}
|
210
|
+
static inline void mjit_remove_class_serial(rb_serial_t class_serial){}
|
211
|
+
static inline VALUE mjit_exec(rb_execution_context_t *ec) { return Qundef; /* unreachable */ }
|
212
|
+
static inline void mjit_child_after_fork(void){}
|
213
|
+
|
214
|
+
#define mjit_enabled false
|
215
|
+
static inline VALUE mjit_pause(bool wait_p){ return Qnil; } // unreachable
|
216
|
+
static inline VALUE mjit_resume(void){ return Qnil; } // unreachable
|
217
|
+
static inline void mjit_finish(bool close_handle_p){}
|
218
|
+
|
219
|
+
# endif // USE_MJIT
|
220
|
+
#endif // RUBY_MJIT_H
|