debase-ruby_core_source 0.10.6 → 0.10.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/lib/debase/ruby_core_source.rb +2 -1
- data/lib/debase/ruby_core_source/ruby-2.7.0-preview2/addr2line.h +21 -0
- data/lib/debase/ruby_core_source/ruby-2.7.0-preview2/ccan/build_assert/build_assert.h +40 -0
- data/lib/debase/ruby_core_source/ruby-2.7.0-preview2/ccan/check_type/check_type.h +63 -0
- data/lib/debase/ruby_core_source/ruby-2.7.0-preview2/ccan/container_of/container_of.h +142 -0
- data/lib/debase/ruby_core_source/ruby-2.7.0-preview2/ccan/list/list.h +788 -0
- data/lib/debase/ruby_core_source/ruby-2.7.0-preview2/ccan/str/str.h +16 -0
- data/lib/debase/ruby_core_source/ruby-2.7.0-preview2/constant.h +54 -0
- data/lib/debase/ruby_core_source/ruby-2.7.0-preview2/debug_counter.h +378 -0
- data/lib/debase/ruby_core_source/ruby-2.7.0-preview2/dln.h +51 -0
- data/lib/debase/ruby_core_source/ruby-2.7.0-preview2/encindex.h +69 -0
- data/lib/debase/ruby_core_source/ruby-2.7.0-preview2/eval_intern.h +314 -0
- data/lib/debase/ruby_core_source/ruby-2.7.0-preview2/gc.h +129 -0
- data/lib/debase/ruby_core_source/ruby-2.7.0-preview2/hrtime.h +168 -0
- data/lib/debase/ruby_core_source/ruby-2.7.0-preview2/id.h +292 -0
- data/lib/debase/ruby_core_source/ruby-2.7.0-preview2/id_table.h +34 -0
- data/lib/debase/ruby_core_source/ruby-2.7.0-preview2/insns.inc +249 -0
- data/lib/debase/ruby_core_source/ruby-2.7.0-preview2/insns_info.inc +9614 -0
- data/lib/debase/ruby_core_source/ruby-2.7.0-preview2/internal.h +2682 -0
- data/lib/debase/ruby_core_source/ruby-2.7.0-preview2/iseq.h +312 -0
- data/lib/debase/ruby_core_source/ruby-2.7.0-preview2/known_errors.inc +791 -0
- data/lib/debase/ruby_core_source/ruby-2.7.0-preview2/method.h +232 -0
- data/lib/debase/ruby_core_source/ruby-2.7.0-preview2/mjit.h +179 -0
- data/lib/debase/ruby_core_source/ruby-2.7.0-preview2/mjit_compile.inc +7883 -0
- data/lib/debase/ruby_core_source/ruby-2.7.0-preview2/node.h +483 -0
- data/lib/debase/ruby_core_source/ruby-2.7.0-preview2/node_name.inc +210 -0
- data/lib/debase/ruby_core_source/ruby-2.7.0-preview2/opt_sc.inc +109 -0
- data/lib/debase/ruby_core_source/ruby-2.7.0-preview2/optinsn.inc +128 -0
- data/lib/debase/ruby_core_source/ruby-2.7.0-preview2/optunifs.inc +43 -0
- data/lib/debase/ruby_core_source/ruby-2.7.0-preview2/parse.h +210 -0
- data/lib/debase/ruby_core_source/ruby-2.7.0-preview2/probes_helper.h +42 -0
- data/lib/debase/ruby_core_source/ruby-2.7.0-preview2/regenc.h +254 -0
- data/lib/debase/ruby_core_source/ruby-2.7.0-preview2/regint.h +938 -0
- data/lib/debase/ruby_core_source/ruby-2.7.0-preview2/regparse.h +370 -0
- data/lib/debase/ruby_core_source/ruby-2.7.0-preview2/revision.h +2 -0
- data/lib/debase/ruby_core_source/ruby-2.7.0-preview2/ruby_assert.h +15 -0
- data/lib/debase/ruby_core_source/ruby-2.7.0-preview2/ruby_atomic.h +244 -0
- data/lib/debase/ruby_core_source/ruby-2.7.0-preview2/siphash.h +48 -0
- data/lib/debase/ruby_core_source/ruby-2.7.0-preview2/symbol.h +119 -0
- data/lib/debase/ruby_core_source/ruby-2.7.0-preview2/thread_pthread.h +75 -0
- data/lib/debase/ruby_core_source/ruby-2.7.0-preview2/thread_win32.h +36 -0
- data/lib/debase/ruby_core_source/ruby-2.7.0-preview2/timev.h +56 -0
- data/lib/debase/ruby_core_source/ruby-2.7.0-preview2/transcode_data.h +139 -0
- data/lib/debase/ruby_core_source/ruby-2.7.0-preview2/transient_heap.h +62 -0
- data/lib/debase/ruby_core_source/ruby-2.7.0-preview2/version.h +77 -0
- data/lib/debase/ruby_core_source/ruby-2.7.0-preview2/vm.inc +5269 -0
- data/lib/debase/ruby_core_source/ruby-2.7.0-preview2/vm_call_iseq_optimized.inc +237 -0
- data/lib/debase/ruby_core_source/ruby-2.7.0-preview2/vm_core.h +1955 -0
- data/lib/debase/ruby_core_source/ruby-2.7.0-preview2/vm_debug.h +34 -0
- data/lib/debase/ruby_core_source/ruby-2.7.0-preview2/vm_exec.h +193 -0
- data/lib/debase/ruby_core_source/ruby-2.7.0-preview2/vm_insnhelper.h +255 -0
- data/lib/debase/ruby_core_source/ruby-2.7.0-preview2/vm_opts.h +70 -0
- data/lib/debase/ruby_core_source/ruby-2.7.0-preview2/vmtc.inc +243 -0
- data/lib/debase/ruby_core_source/version.rb +1 -1
- metadata +55 -3
@@ -0,0 +1,34 @@
|
|
1
|
+
/**********************************************************************
|
2
|
+
|
3
|
+
vm_debug.h - YARV Debug function interface
|
4
|
+
|
5
|
+
$Author$
|
6
|
+
created at: 04/08/25 02:33:49 JST
|
7
|
+
|
8
|
+
Copyright (C) 2004-2007 Koichi Sasada
|
9
|
+
|
10
|
+
**********************************************************************/
|
11
|
+
|
12
|
+
#ifndef RUBY_DEBUG_H
|
13
|
+
#define RUBY_DEBUG_H
|
14
|
+
|
15
|
+
#include "ruby/ruby.h"
|
16
|
+
#include "node.h"
|
17
|
+
|
18
|
+
RUBY_SYMBOL_EXPORT_BEGIN
|
19
|
+
|
20
|
+
#define dpv(h,v) ruby_debug_print_value(-1, 0, (h), (v))
|
21
|
+
#define dp(v) ruby_debug_print_value(-1, 0, "", (v))
|
22
|
+
#define dpi(i) ruby_debug_print_id(-1, 0, "", (i))
|
23
|
+
#define dpn(n) ruby_debug_print_node(-1, 0, "", (n))
|
24
|
+
|
25
|
+
VALUE ruby_debug_print_value(int level, int debug_level, const char *header, VALUE v);
|
26
|
+
ID ruby_debug_print_id(int level, int debug_level, const char *header, ID id);
|
27
|
+
NODE *ruby_debug_print_node(int level, int debug_level, const char *header, const NODE *node);
|
28
|
+
int ruby_debug_print_indent(int level, int debug_level, int indent_level);
|
29
|
+
void ruby_debug_gc_check_func(void);
|
30
|
+
void ruby_set_debug_option(const char *str);
|
31
|
+
|
32
|
+
RUBY_SYMBOL_EXPORT_END
|
33
|
+
|
34
|
+
#endif /* RUBY_DEBUG_H */
|
@@ -0,0 +1,193 @@
|
|
1
|
+
/**********************************************************************
|
2
|
+
|
3
|
+
vm.h -
|
4
|
+
|
5
|
+
$Author$
|
6
|
+
created at: 04/01/01 16:56:59 JST
|
7
|
+
|
8
|
+
Copyright (C) 2004-2007 Koichi Sasada
|
9
|
+
|
10
|
+
**********************************************************************/
|
11
|
+
|
12
|
+
#ifndef RUBY_VM_EXEC_H
|
13
|
+
#define RUBY_VM_EXEC_H
|
14
|
+
|
15
|
+
typedef long OFFSET;
|
16
|
+
typedef unsigned long lindex_t;
|
17
|
+
typedef VALUE GENTRY;
|
18
|
+
typedef rb_iseq_t *ISEQ;
|
19
|
+
|
20
|
+
#if VMDEBUG > 0
|
21
|
+
#define debugs printf
|
22
|
+
#define DEBUG_ENTER_INSN(insn) \
|
23
|
+
rb_vmdebug_debug_print_pre(ec, GET_CFP(), GET_PC());
|
24
|
+
|
25
|
+
#if OPT_STACK_CACHING
|
26
|
+
#define SC_REGS() , reg_a, reg_b
|
27
|
+
#else
|
28
|
+
#define SC_REGS()
|
29
|
+
#endif
|
30
|
+
|
31
|
+
#define DEBUG_END_INSN() \
|
32
|
+
rb_vmdebug_debug_print_post(ec, GET_CFP() SC_REGS());
|
33
|
+
|
34
|
+
#else
|
35
|
+
|
36
|
+
#define debugs
|
37
|
+
#define DEBUG_ENTER_INSN(insn)
|
38
|
+
#define DEBUG_END_INSN()
|
39
|
+
#endif
|
40
|
+
|
41
|
+
#define throwdebug if(0)printf
|
42
|
+
/* #define throwdebug printf */
|
43
|
+
|
44
|
+
/************************************************/
|
45
|
+
#if defined(DISPATCH_XXX)
|
46
|
+
error !
|
47
|
+
/************************************************/
|
48
|
+
#elif OPT_CALL_THREADED_CODE
|
49
|
+
|
50
|
+
#define LABEL(x) insn_func_##x
|
51
|
+
#define ELABEL(x)
|
52
|
+
#define LABEL_PTR(x) &LABEL(x)
|
53
|
+
|
54
|
+
#define INSN_ENTRY(insn) \
|
55
|
+
static rb_control_frame_t * \
|
56
|
+
FUNC_FASTCALL(LABEL(insn))(rb_execution_context_t *ec, rb_control_frame_t *reg_cfp) {
|
57
|
+
|
58
|
+
#define END_INSN(insn) return reg_cfp;}
|
59
|
+
|
60
|
+
#define NEXT_INSN() return reg_cfp;
|
61
|
+
|
62
|
+
#define START_OF_ORIGINAL_INSN(x) /* ignore */
|
63
|
+
#define DISPATCH_ORIGINAL_INSN(x) return LABEL(x)(ec, reg_cfp);
|
64
|
+
|
65
|
+
/************************************************/
|
66
|
+
#elif OPT_TOKEN_THREADED_CODE || OPT_DIRECT_THREADED_CODE
|
67
|
+
/* threaded code with gcc */
|
68
|
+
|
69
|
+
#define LABEL(x) INSN_LABEL_##x
|
70
|
+
#define ELABEL(x) INSN_ELABEL_##x
|
71
|
+
#define LABEL_PTR(x) RB_GNUC_EXTENSION(&&LABEL(x))
|
72
|
+
|
73
|
+
#define INSN_ENTRY_SIG(insn) \
|
74
|
+
if (0) fprintf(stderr, "exec: %s@(%"PRIdPTRDIFF", %"PRIdPTRDIFF")@%s:%u\n", #insn, \
|
75
|
+
(reg_pc - reg_cfp->iseq->body->iseq_encoded), \
|
76
|
+
(reg_cfp->pc - reg_cfp->iseq->body->iseq_encoded), \
|
77
|
+
RSTRING_PTR(rb_iseq_path(reg_cfp->iseq)), \
|
78
|
+
rb_iseq_line_no(reg_cfp->iseq, reg_pc - reg_cfp->iseq->body->iseq_encoded));
|
79
|
+
|
80
|
+
#define INSN_DISPATCH_SIG(insn)
|
81
|
+
|
82
|
+
#define INSN_ENTRY(insn) \
|
83
|
+
LABEL(insn): \
|
84
|
+
INSN_ENTRY_SIG(insn); \
|
85
|
+
|
86
|
+
/**********************************/
|
87
|
+
#if OPT_DIRECT_THREADED_CODE
|
88
|
+
|
89
|
+
/* for GCC 3.4.x */
|
90
|
+
#define TC_DISPATCH(insn) \
|
91
|
+
INSN_DISPATCH_SIG(insn); \
|
92
|
+
RB_GNUC_EXTENSION_BLOCK(goto *(void const *)GET_CURRENT_INSN()); \
|
93
|
+
;
|
94
|
+
|
95
|
+
#else
|
96
|
+
/* token threaded code */
|
97
|
+
|
98
|
+
/* dispatcher */
|
99
|
+
#if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__)) && __GNUC__ == 3
|
100
|
+
#define DISPATCH_ARCH_DEPEND_WAY(addr) \
|
101
|
+
__asm__ __volatile__("jmp *%0;\t# -- inserted by vm.h\t[length = 2]" : : "r" (addr))
|
102
|
+
|
103
|
+
#else
|
104
|
+
#define DISPATCH_ARCH_DEPEND_WAY(addr) \
|
105
|
+
/* do nothing */
|
106
|
+
#endif
|
107
|
+
#define TC_DISPATCH(insn) \
|
108
|
+
DISPATCH_ARCH_DEPEND_WAY(insns_address_table[GET_CURRENT_INSN()]); \
|
109
|
+
INSN_DISPATCH_SIG(insn); \
|
110
|
+
RB_GNUC_EXTENSION_BLOCK(goto *insns_address_table[GET_CURRENT_INSN()]); \
|
111
|
+
rb_bug("tc error");
|
112
|
+
|
113
|
+
#endif /* OPT_DIRECT_THREADED_CODE */
|
114
|
+
|
115
|
+
#define END_INSN(insn) \
|
116
|
+
DEBUG_END_INSN(); \
|
117
|
+
TC_DISPATCH(insn);
|
118
|
+
|
119
|
+
#define INSN_DISPATCH() \
|
120
|
+
TC_DISPATCH(__START__) \
|
121
|
+
{
|
122
|
+
|
123
|
+
#define END_INSNS_DISPATCH() \
|
124
|
+
rb_bug("unknown insn: %"PRIdVALUE, GET_CURRENT_INSN()); \
|
125
|
+
} /* end of while loop */ \
|
126
|
+
|
127
|
+
#define NEXT_INSN() TC_DISPATCH(__NEXT_INSN__)
|
128
|
+
|
129
|
+
#define START_OF_ORIGINAL_INSN(x) start_of_##x:
|
130
|
+
#define DISPATCH_ORIGINAL_INSN(x) goto start_of_##x;
|
131
|
+
|
132
|
+
/************************************************/
|
133
|
+
#else /* no threaded code */
|
134
|
+
/* most common method */
|
135
|
+
|
136
|
+
#define INSN_ENTRY(insn) \
|
137
|
+
case BIN(insn):
|
138
|
+
|
139
|
+
#define END_INSN(insn) \
|
140
|
+
DEBUG_END_INSN(); \
|
141
|
+
break;
|
142
|
+
|
143
|
+
#define INSN_DISPATCH() \
|
144
|
+
while (1) { \
|
145
|
+
switch (GET_CURRENT_INSN()) {
|
146
|
+
|
147
|
+
#define END_INSNS_DISPATCH() \
|
148
|
+
default: \
|
149
|
+
SDR(); \
|
150
|
+
rb_bug("unknown insn: %ld", GET_CURRENT_INSN()); \
|
151
|
+
} /* end of switch */ \
|
152
|
+
} /* end of while loop */ \
|
153
|
+
|
154
|
+
#define NEXT_INSN() goto first
|
155
|
+
|
156
|
+
#define START_OF_ORIGINAL_INSN(x) start_of_##x:
|
157
|
+
#define DISPATCH_ORIGINAL_INSN(x) goto start_of_##x;
|
158
|
+
|
159
|
+
#endif
|
160
|
+
|
161
|
+
#define VM_SP_CNT(ec, sp) ((sp) - (ec)->vm_stack)
|
162
|
+
|
163
|
+
#ifdef MJIT_HEADER
|
164
|
+
#define THROW_EXCEPTION(exc) do { \
|
165
|
+
ec->errinfo = (VALUE)(exc); \
|
166
|
+
EC_JUMP_TAG(ec, ec->tag->state); \
|
167
|
+
} while (0)
|
168
|
+
#else
|
169
|
+
#if OPT_CALL_THREADED_CODE
|
170
|
+
#define THROW_EXCEPTION(exc) do { \
|
171
|
+
ec->errinfo = (VALUE)(exc); \
|
172
|
+
return 0; \
|
173
|
+
} while (0)
|
174
|
+
#else
|
175
|
+
#define THROW_EXCEPTION(exc) return (VALUE)(exc)
|
176
|
+
#endif
|
177
|
+
#endif
|
178
|
+
|
179
|
+
#define SCREG(r) (reg_##r)
|
180
|
+
|
181
|
+
#define VM_DEBUG_STACKOVERFLOW 0
|
182
|
+
|
183
|
+
#if VM_DEBUG_STACKOVERFLOW
|
184
|
+
#define CHECK_VM_STACK_OVERFLOW_FOR_INSN(cfp, margin) \
|
185
|
+
WHEN_VM_STACK_OVERFLOWED(cfp, (cfp)->sp, margin) vm_stack_overflow_for_insn()
|
186
|
+
#else
|
187
|
+
#define CHECK_VM_STACK_OVERFLOW_FOR_INSN(cfp, margin)
|
188
|
+
#endif
|
189
|
+
|
190
|
+
#define INSN_LABEL2(insn, name) INSN_LABEL_ ## insn ## _ ## name
|
191
|
+
#define INSN_LABEL(x) INSN_LABEL2(NAME_OF_CURRENT_INSN, x)
|
192
|
+
|
193
|
+
#endif /* RUBY_VM_EXEC_H */
|
@@ -0,0 +1,255 @@
|
|
1
|
+
/**********************************************************************
|
2
|
+
|
3
|
+
insnhelper.h - helper macros to implement each instructions
|
4
|
+
|
5
|
+
$Author$
|
6
|
+
created at: 04/01/01 15:50:34 JST
|
7
|
+
|
8
|
+
Copyright (C) 2004-2007 Koichi Sasada
|
9
|
+
|
10
|
+
**********************************************************************/
|
11
|
+
|
12
|
+
#ifndef RUBY_INSNHELPER_H
|
13
|
+
#define RUBY_INSNHELPER_H
|
14
|
+
|
15
|
+
RUBY_SYMBOL_EXPORT_BEGIN
|
16
|
+
|
17
|
+
RUBY_EXTERN VALUE ruby_vm_const_missing_count;
|
18
|
+
RUBY_EXTERN rb_serial_t ruby_vm_global_method_state;
|
19
|
+
RUBY_EXTERN rb_serial_t ruby_vm_global_constant_state;
|
20
|
+
RUBY_EXTERN rb_serial_t ruby_vm_class_serial;
|
21
|
+
|
22
|
+
RUBY_SYMBOL_EXPORT_END
|
23
|
+
|
24
|
+
#if VM_COLLECT_USAGE_DETAILS
|
25
|
+
#define COLLECT_USAGE_INSN(insn) vm_collect_usage_insn(insn)
|
26
|
+
#define COLLECT_USAGE_OPERAND(insn, n, op) vm_collect_usage_operand((insn), (n), ((VALUE)(op)))
|
27
|
+
|
28
|
+
#define COLLECT_USAGE_REGISTER(reg, s) vm_collect_usage_register((reg), (s))
|
29
|
+
#else
|
30
|
+
#define COLLECT_USAGE_INSN(insn) /* none */
|
31
|
+
#define COLLECT_USAGE_OPERAND(insn, n, op) /* none */
|
32
|
+
#define COLLECT_USAGE_REGISTER(reg, s) /* none */
|
33
|
+
#endif
|
34
|
+
|
35
|
+
/**********************************************************/
|
36
|
+
/* deal with stack */
|
37
|
+
/**********************************************************/
|
38
|
+
|
39
|
+
#define PUSH(x) (SET_SV(x), INC_SP(1))
|
40
|
+
#define TOPN(n) (*(GET_SP()-(n)-1))
|
41
|
+
#define POPN(n) (DEC_SP(n))
|
42
|
+
#define POP() (DEC_SP(1))
|
43
|
+
#define STACK_ADDR_FROM_TOP(n) (GET_SP()-(n))
|
44
|
+
|
45
|
+
/**********************************************************/
|
46
|
+
/* deal with registers */
|
47
|
+
/**********************************************************/
|
48
|
+
|
49
|
+
#define VM_REG_CFP (reg_cfp)
|
50
|
+
#define VM_REG_PC (VM_REG_CFP->pc)
|
51
|
+
#define VM_REG_SP (VM_REG_CFP->sp)
|
52
|
+
#define VM_REG_EP (VM_REG_CFP->ep)
|
53
|
+
|
54
|
+
#define RESTORE_REGS() do { \
|
55
|
+
VM_REG_CFP = ec->cfp; \
|
56
|
+
} while (0)
|
57
|
+
|
58
|
+
#if VM_COLLECT_USAGE_DETAILS
|
59
|
+
enum vm_regan_regtype {
|
60
|
+
VM_REGAN_PC = 0,
|
61
|
+
VM_REGAN_SP = 1,
|
62
|
+
VM_REGAN_EP = 2,
|
63
|
+
VM_REGAN_CFP = 3,
|
64
|
+
VM_REGAN_SELF = 4,
|
65
|
+
VM_REGAN_ISEQ = 5
|
66
|
+
};
|
67
|
+
enum vm_regan_acttype {
|
68
|
+
VM_REGAN_ACT_GET = 0,
|
69
|
+
VM_REGAN_ACT_SET = 1
|
70
|
+
};
|
71
|
+
|
72
|
+
#define COLLECT_USAGE_REGISTER_HELPER(a, b, v) \
|
73
|
+
(COLLECT_USAGE_REGISTER((VM_REGAN_##a), (VM_REGAN_ACT_##b)), (v))
|
74
|
+
#else
|
75
|
+
#define COLLECT_USAGE_REGISTER_HELPER(a, b, v) (v)
|
76
|
+
#endif
|
77
|
+
|
78
|
+
/* PC */
|
79
|
+
#define GET_PC() (COLLECT_USAGE_REGISTER_HELPER(PC, GET, VM_REG_PC))
|
80
|
+
#define SET_PC(x) (VM_REG_PC = (COLLECT_USAGE_REGISTER_HELPER(PC, SET, (x))))
|
81
|
+
#define GET_CURRENT_INSN() (*GET_PC())
|
82
|
+
#define GET_OPERAND(n) (GET_PC()[(n)])
|
83
|
+
#define ADD_PC(n) (SET_PC(VM_REG_PC + (n)))
|
84
|
+
#define JUMP(dst) (SET_PC(VM_REG_PC + (dst)))
|
85
|
+
|
86
|
+
/* frame pointer, environment pointer */
|
87
|
+
#define GET_CFP() (COLLECT_USAGE_REGISTER_HELPER(CFP, GET, VM_REG_CFP))
|
88
|
+
#define GET_EP() (COLLECT_USAGE_REGISTER_HELPER(EP, GET, VM_REG_EP))
|
89
|
+
#define SET_EP(x) (VM_REG_EP = (COLLECT_USAGE_REGISTER_HELPER(EP, SET, (x))))
|
90
|
+
#define GET_LEP() (VM_EP_LEP(GET_EP()))
|
91
|
+
|
92
|
+
/* SP */
|
93
|
+
#define GET_SP() (COLLECT_USAGE_REGISTER_HELPER(SP, GET, VM_REG_SP))
|
94
|
+
#define SET_SP(x) (VM_REG_SP = (COLLECT_USAGE_REGISTER_HELPER(SP, SET, (x))))
|
95
|
+
#define INC_SP(x) (VM_REG_SP += (COLLECT_USAGE_REGISTER_HELPER(SP, SET, (x))))
|
96
|
+
#define DEC_SP(x) (VM_REG_SP -= (COLLECT_USAGE_REGISTER_HELPER(SP, SET, (x))))
|
97
|
+
#define SET_SV(x) (*GET_SP() = (x))
|
98
|
+
/* set current stack value as x */
|
99
|
+
|
100
|
+
/* instruction sequence C struct */
|
101
|
+
#define GET_ISEQ() (GET_CFP()->iseq)
|
102
|
+
|
103
|
+
/**********************************************************/
|
104
|
+
/* deal with variables */
|
105
|
+
/**********************************************************/
|
106
|
+
|
107
|
+
#define GET_PREV_EP(ep) ((VALUE *)((ep)[VM_ENV_DATA_INDEX_SPECVAL] & ~0x03))
|
108
|
+
|
109
|
+
/**********************************************************/
|
110
|
+
/* deal with values */
|
111
|
+
/**********************************************************/
|
112
|
+
|
113
|
+
#define GET_SELF() (COLLECT_USAGE_REGISTER_HELPER(SELF, GET, GET_CFP()->self))
|
114
|
+
|
115
|
+
/**********************************************************/
|
116
|
+
/* deal with control flow 2: method/iterator */
|
117
|
+
/**********************************************************/
|
118
|
+
|
119
|
+
/* set fastpath when cached method is *NOT* protected
|
120
|
+
* because inline method cache does not care about receiver.
|
121
|
+
*/
|
122
|
+
|
123
|
+
#define CC_SET_FASTPATH(cc, func, enabled) do { \
|
124
|
+
if (LIKELY(enabled)) ((cc)->call = (func)); \
|
125
|
+
} while (0)
|
126
|
+
|
127
|
+
#define GET_BLOCK_HANDLER() (GET_LEP()[VM_ENV_DATA_INDEX_SPECVAL])
|
128
|
+
|
129
|
+
/**********************************************************/
|
130
|
+
/* deal with control flow 3: exception */
|
131
|
+
/**********************************************************/
|
132
|
+
|
133
|
+
|
134
|
+
/**********************************************************/
|
135
|
+
/* deal with stack canary */
|
136
|
+
/**********************************************************/
|
137
|
+
|
138
|
+
#if VM_CHECK_MODE > 0
|
139
|
+
#define SETUP_CANARY() \
|
140
|
+
VALUE *canary; \
|
141
|
+
if (leaf) { \
|
142
|
+
canary = GET_SP(); \
|
143
|
+
SET_SV(vm_stack_canary); \
|
144
|
+
} \
|
145
|
+
else {\
|
146
|
+
SET_SV(Qfalse); /* cleanup */ \
|
147
|
+
}
|
148
|
+
#define CHECK_CANARY() \
|
149
|
+
if (leaf) { \
|
150
|
+
if (*canary == vm_stack_canary) { \
|
151
|
+
*canary = Qfalse; /* cleanup */ \
|
152
|
+
} \
|
153
|
+
else { \
|
154
|
+
vm_canary_is_found_dead(INSN_ATTR(bin), *canary); \
|
155
|
+
} \
|
156
|
+
}
|
157
|
+
#else
|
158
|
+
#define SETUP_CANARY() /* void */
|
159
|
+
#define CHECK_CANARY() /* void */
|
160
|
+
#endif
|
161
|
+
|
162
|
+
/**********************************************************/
|
163
|
+
/* others */
|
164
|
+
/**********************************************************/
|
165
|
+
|
166
|
+
#ifndef MJIT_HEADER
|
167
|
+
#define CALL_SIMPLE_METHOD() do { \
|
168
|
+
rb_snum_t x = leaf ? INSN_ATTR(width) : 0; \
|
169
|
+
rb_snum_t y = attr_width_opt_send_without_block(0, 0); \
|
170
|
+
rb_snum_t z = x - y; \
|
171
|
+
ADD_PC(z); \
|
172
|
+
DISPATCH_ORIGINAL_INSN(opt_send_without_block); \
|
173
|
+
} while (0)
|
174
|
+
#endif
|
175
|
+
|
176
|
+
#define NEXT_CLASS_SERIAL() (++ruby_vm_class_serial)
|
177
|
+
#define GET_GLOBAL_METHOD_STATE() (ruby_vm_global_method_state)
|
178
|
+
#define INC_GLOBAL_METHOD_STATE() (++ruby_vm_global_method_state)
|
179
|
+
#define GET_GLOBAL_CONSTANT_STATE() (ruby_vm_global_constant_state)
|
180
|
+
#define INC_GLOBAL_CONSTANT_STATE() (++ruby_vm_global_constant_state)
|
181
|
+
|
182
|
+
static inline struct vm_throw_data *
|
183
|
+
THROW_DATA_NEW(VALUE val, const rb_control_frame_t *cf, int st)
|
184
|
+
{
|
185
|
+
struct vm_throw_data *obj = (struct vm_throw_data *)rb_imemo_new(imemo_throw_data, val, (VALUE)cf, 0, 0);
|
186
|
+
obj->throw_state = st;
|
187
|
+
return obj;
|
188
|
+
}
|
189
|
+
|
190
|
+
static inline VALUE
|
191
|
+
THROW_DATA_VAL(const struct vm_throw_data *obj)
|
192
|
+
{
|
193
|
+
VM_ASSERT(THROW_DATA_P(obj));
|
194
|
+
return obj->throw_obj;
|
195
|
+
}
|
196
|
+
|
197
|
+
static inline const rb_control_frame_t *
|
198
|
+
THROW_DATA_CATCH_FRAME(const struct vm_throw_data *obj)
|
199
|
+
{
|
200
|
+
VM_ASSERT(THROW_DATA_P(obj));
|
201
|
+
return obj->catch_frame;
|
202
|
+
}
|
203
|
+
|
204
|
+
static inline int
|
205
|
+
THROW_DATA_STATE(const struct vm_throw_data *obj)
|
206
|
+
{
|
207
|
+
VM_ASSERT(THROW_DATA_P(obj));
|
208
|
+
return obj->throw_state;
|
209
|
+
}
|
210
|
+
|
211
|
+
static inline int
|
212
|
+
THROW_DATA_CONSUMED_P(const struct vm_throw_data *obj)
|
213
|
+
{
|
214
|
+
VM_ASSERT(THROW_DATA_P(obj));
|
215
|
+
return obj->flags & THROW_DATA_CONSUMED;
|
216
|
+
}
|
217
|
+
|
218
|
+
static inline void
|
219
|
+
THROW_DATA_CATCH_FRAME_SET(struct vm_throw_data *obj, const rb_control_frame_t *cfp)
|
220
|
+
{
|
221
|
+
VM_ASSERT(THROW_DATA_P(obj));
|
222
|
+
obj->catch_frame = cfp;
|
223
|
+
}
|
224
|
+
|
225
|
+
static inline void
|
226
|
+
THROW_DATA_STATE_SET(struct vm_throw_data *obj, int st)
|
227
|
+
{
|
228
|
+
VM_ASSERT(THROW_DATA_P(obj));
|
229
|
+
obj->throw_state = st;
|
230
|
+
}
|
231
|
+
|
232
|
+
static inline void
|
233
|
+
THROW_DATA_CONSUMED_SET(struct vm_throw_data *obj)
|
234
|
+
{
|
235
|
+
if (THROW_DATA_P(obj) &&
|
236
|
+
THROW_DATA_STATE(obj) == TAG_BREAK) {
|
237
|
+
obj->flags |= THROW_DATA_CONSUMED;
|
238
|
+
}
|
239
|
+
}
|
240
|
+
|
241
|
+
#define IS_ARGS_SPLAT(ci) ((ci)->flag & VM_CALL_ARGS_SPLAT)
|
242
|
+
#define IS_ARGS_KEYWORD(ci) ((ci)->flag & VM_CALL_KWARG)
|
243
|
+
#define IS_ARGS_KW_SPLAT(ci) ((ci)->flag & VM_CALL_KW_SPLAT)
|
244
|
+
#define IS_ARGS_KW_OR_KW_SPLAT(ci) ((ci)->flag & (VM_CALL_KWARG | VM_CALL_KW_SPLAT))
|
245
|
+
|
246
|
+
/* If this returns true, an optimized function returned by `vm_call_iseq_setup_func`
|
247
|
+
can be used as a fastpath. */
|
248
|
+
static bool
|
249
|
+
vm_call_iseq_optimizable_p(const struct rb_call_info *ci, const struct rb_call_cache *cc)
|
250
|
+
{
|
251
|
+
return !IS_ARGS_SPLAT(ci) && !IS_ARGS_KEYWORD(ci) &&
|
252
|
+
!(METHOD_ENTRY_VISI(cc->me) == METHOD_VISI_PROTECTED);
|
253
|
+
}
|
254
|
+
|
255
|
+
#endif /* RUBY_INSNHELPER_H */
|