debase-ruby_core_source 0.8.2 → 0.8.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/lib/debase/ruby_core_source/ruby-2.0.0-p648/addr2line.h +21 -0
- data/lib/debase/ruby_core_source/ruby-2.0.0-p648/constant.h +36 -0
- data/lib/debase/ruby_core_source/ruby-2.0.0-p648/dln.h +50 -0
- data/lib/debase/ruby_core_source/ruby-2.0.0-p648/encdb.h +169 -0
- data/lib/debase/ruby_core_source/ruby-2.0.0-p648/eval_intern.h +241 -0
- data/lib/debase/ruby_core_source/ruby-2.0.0-p648/gc.h +104 -0
- data/lib/debase/ruby_core_source/ruby-2.0.0-p648/id.h +135 -0
- data/lib/debase/ruby_core_source/ruby-2.0.0-p648/insns.inc +187 -0
- data/lib/debase/ruby_core_source/ruby-2.0.0-p648/insns_info.inc +724 -0
- data/lib/debase/ruby_core_source/ruby-2.0.0-p648/internal.h +395 -0
- data/lib/debase/ruby_core_source/ruby-2.0.0-p648/iseq.h +140 -0
- data/lib/debase/ruby_core_source/ruby-2.0.0-p648/known_errors.inc +731 -0
- data/lib/debase/ruby_core_source/ruby-2.0.0-p648/method.h +141 -0
- data/lib/debase/ruby_core_source/ruby-2.0.0-p648/node.h +541 -0
- data/lib/debase/ruby_core_source/ruby-2.0.0-p648/node_name.inc +212 -0
- data/lib/debase/ruby_core_source/ruby-2.0.0-p648/opt_sc.inc +702 -0
- data/lib/debase/ruby_core_source/ruby-2.0.0-p648/optinsn.inc +83 -0
- data/lib/debase/ruby_core_source/ruby-2.0.0-p648/optunifs.inc +120 -0
- data/lib/debase/ruby_core_source/ruby-2.0.0-p648/parse.h +181 -0
- data/lib/debase/ruby_core_source/ruby-2.0.0-p648/probes_helper.h +67 -0
- data/lib/debase/ruby_core_source/ruby-2.0.0-p648/regenc.h +227 -0
- data/lib/debase/ruby_core_source/ruby-2.0.0-p648/regint.h +915 -0
- data/lib/debase/ruby_core_source/ruby-2.0.0-p648/regparse.h +367 -0
- data/lib/debase/ruby_core_source/ruby-2.0.0-p648/revision.h +1 -0
- data/lib/debase/ruby_core_source/ruby-2.0.0-p648/ruby_atomic.h +170 -0
- data/lib/debase/ruby_core_source/ruby-2.0.0-p648/siphash.h +48 -0
- data/lib/debase/ruby_core_source/ruby-2.0.0-p648/thread_pthread.h +56 -0
- data/lib/debase/ruby_core_source/ruby-2.0.0-p648/thread_win32.h +45 -0
- data/lib/debase/ruby_core_source/ruby-2.0.0-p648/timev.h +21 -0
- data/lib/debase/ruby_core_source/ruby-2.0.0-p648/transcode_data.h +127 -0
- data/lib/debase/ruby_core_source/ruby-2.0.0-p648/transdb.h +193 -0
- data/lib/debase/ruby_core_source/ruby-2.0.0-p648/version.h +52 -0
- data/lib/debase/ruby_core_source/ruby-2.0.0-p648/vm.inc +3196 -0
- data/lib/debase/ruby_core_source/ruby-2.0.0-p648/vm_core.h +1020 -0
- data/lib/debase/ruby_core_source/ruby-2.0.0-p648/vm_debug.h +41 -0
- data/lib/debase/ruby_core_source/ruby-2.0.0-p648/vm_exec.h +173 -0
- data/lib/debase/ruby_core_source/ruby-2.0.0-p648/vm_insnhelper.h +274 -0
- data/lib/debase/ruby_core_source/ruby-2.0.0-p648/vm_opts.h +56 -0
- data/lib/debase/ruby_core_source/ruby-2.0.0-p648/vmtc.inc +101 -0
- data/lib/debase/ruby_core_source/ruby-2.1.8-p440/addr2line.h +21 -0
- data/lib/debase/ruby_core_source/ruby-2.1.8-p440/constant.h +36 -0
- data/lib/debase/ruby_core_source/ruby-2.1.8-p440/dln.h +51 -0
- data/lib/debase/ruby_core_source/ruby-2.1.8-p440/encdb.h +170 -0
- data/lib/debase/ruby_core_source/ruby-2.1.8-p440/eval_intern.h +270 -0
- data/lib/debase/ruby_core_source/ruby-2.1.8-p440/gc.h +101 -0
- data/lib/debase/ruby_core_source/ruby-2.1.8-p440/id.h +171 -0
- data/lib/debase/ruby_core_source/ruby-2.1.8-p440/insns.inc +189 -0
- data/lib/debase/ruby_core_source/ruby-2.1.8-p440/insns_info.inc +731 -0
- data/lib/debase/ruby_core_source/ruby-2.1.8-p440/internal.h +896 -0
- data/lib/debase/ruby_core_source/ruby-2.1.8-p440/iseq.h +136 -0
- data/lib/debase/ruby_core_source/ruby-2.1.8-p440/known_errors.inc +731 -0
- data/lib/debase/ruby_core_source/ruby-2.1.8-p440/method.h +145 -0
- data/lib/debase/ruby_core_source/ruby-2.1.8-p440/node.h +543 -0
- data/lib/debase/ruby_core_source/ruby-2.1.8-p440/node_name.inc +212 -0
- data/lib/debase/ruby_core_source/ruby-2.1.8-p440/opt_sc.inc +710 -0
- data/lib/debase/ruby_core_source/ruby-2.1.8-p440/optinsn.inc +83 -0
- data/lib/debase/ruby_core_source/ruby-2.1.8-p440/optunifs.inc +121 -0
- data/lib/debase/ruby_core_source/ruby-2.1.8-p440/parse.h +183 -0
- data/lib/debase/ruby_core_source/ruby-2.1.8-p440/probes_helper.h +67 -0
- data/lib/debase/ruby_core_source/ruby-2.1.8-p440/regenc.h +223 -0
- data/lib/debase/ruby_core_source/ruby-2.1.8-p440/regint.h +911 -0
- data/lib/debase/ruby_core_source/ruby-2.1.8-p440/regparse.h +363 -0
- data/lib/debase/ruby_core_source/ruby-2.1.8-p440/revision.h +1 -0
- data/lib/debase/ruby_core_source/ruby-2.1.8-p440/ruby_atomic.h +170 -0
- data/lib/debase/ruby_core_source/ruby-2.1.8-p440/siphash.h +48 -0
- data/lib/debase/ruby_core_source/ruby-2.1.8-p440/thread_native.h +23 -0
- data/lib/debase/ruby_core_source/ruby-2.1.8-p440/thread_pthread.h +56 -0
- data/lib/debase/ruby_core_source/ruby-2.1.8-p440/thread_win32.h +45 -0
- data/lib/debase/ruby_core_source/ruby-2.1.8-p440/timev.h +42 -0
- data/lib/debase/ruby_core_source/ruby-2.1.8-p440/transcode_data.h +123 -0
- data/lib/debase/ruby_core_source/ruby-2.1.8-p440/transdb.h +190 -0
- data/lib/debase/ruby_core_source/ruby-2.1.8-p440/version.h +52 -0
- data/lib/debase/ruby_core_source/ruby-2.1.8-p440/vm.inc +3241 -0
- data/lib/debase/ruby_core_source/ruby-2.1.8-p440/vm_core.h +1057 -0
- data/lib/debase/ruby_core_source/ruby-2.1.8-p440/vm_debug.h +37 -0
- data/lib/debase/ruby_core_source/ruby-2.1.8-p440/vm_exec.h +182 -0
- data/lib/debase/ruby_core_source/ruby-2.1.8-p440/vm_insnhelper.h +273 -0
- data/lib/debase/ruby_core_source/ruby-2.1.8-p440/vm_opts.h +56 -0
- data/lib/debase/ruby_core_source/ruby-2.1.8-p440/vmtc.inc +102 -0
- data/lib/debase/ruby_core_source/ruby-2.2.4-p230/addr2line.h +21 -0
- data/lib/debase/ruby_core_source/ruby-2.2.4-p230/ccan/build_assert/build_assert.h +40 -0
- data/lib/debase/ruby_core_source/ruby-2.2.4-p230/ccan/check_type/check_type.h +63 -0
- data/lib/debase/ruby_core_source/ruby-2.2.4-p230/ccan/container_of/container_of.h +142 -0
- data/lib/debase/ruby_core_source/ruby-2.2.4-p230/ccan/list/list.h +635 -0
- data/lib/debase/ruby_core_source/ruby-2.2.4-p230/ccan/str/str.h +16 -0
- data/lib/debase/ruby_core_source/ruby-2.2.4-p230/constant.h +43 -0
- data/lib/debase/ruby_core_source/ruby-2.2.4-p230/dln.h +51 -0
- data/lib/debase/ruby_core_source/ruby-2.2.4-p230/eval_intern.h +275 -0
- data/lib/debase/ruby_core_source/ruby-2.2.4-p230/gc.h +107 -0
- data/lib/debase/ruby_core_source/ruby-2.2.4-p230/id.h +210 -0
- data/lib/debase/ruby_core_source/ruby-2.2.4-p230/insns.inc +107 -0
- data/lib/debase/ruby_core_source/ruby-2.2.4-p230/insns_info.inc +752 -0
- data/lib/debase/ruby_core_source/ruby-2.2.4-p230/internal.h +1196 -0
- data/lib/debase/ruby_core_source/ruby-2.2.4-p230/iseq.h +158 -0
- data/lib/debase/ruby_core_source/ruby-2.2.4-p230/known_errors.inc +746 -0
- data/lib/debase/ruby_core_source/ruby-2.2.4-p230/method.h +144 -0
- data/lib/debase/ruby_core_source/ruby-2.2.4-p230/node.h +544 -0
- data/lib/debase/ruby_core_source/ruby-2.2.4-p230/node_name.inc +212 -0
- data/lib/debase/ruby_core_source/ruby-2.2.4-p230/opt_sc.inc +734 -0
- data/lib/debase/ruby_core_source/ruby-2.2.4-p230/optinsn.inc +83 -0
- data/lib/debase/ruby_core_source/ruby-2.2.4-p230/optunifs.inc +124 -0
- data/lib/debase/ruby_core_source/ruby-2.2.4-p230/parse.h +184 -0
- data/lib/debase/ruby_core_source/ruby-2.2.4-p230/probes_helper.h +67 -0
- data/lib/debase/ruby_core_source/ruby-2.2.4-p230/regenc.h +234 -0
- data/lib/debase/ruby_core_source/ruby-2.2.4-p230/regint.h +972 -0
- data/lib/debase/ruby_core_source/ruby-2.2.4-p230/regparse.h +363 -0
- data/lib/debase/ruby_core_source/ruby-2.2.4-p230/revision.h +1 -0
- data/lib/debase/ruby_core_source/ruby-2.2.4-p230/ruby_atomic.h +170 -0
- data/lib/debase/ruby_core_source/ruby-2.2.4-p230/siphash.h +48 -0
- data/lib/debase/ruby_core_source/ruby-2.2.4-p230/symbol.h +88 -0
- data/lib/debase/ruby_core_source/ruby-2.2.4-p230/thread_pthread.h +54 -0
- data/lib/debase/ruby_core_source/ruby-2.2.4-p230/thread_win32.h +36 -0
- data/lib/debase/ruby_core_source/ruby-2.2.4-p230/timev.h +42 -0
- data/lib/debase/ruby_core_source/ruby-2.2.4-p230/transcode_data.h +123 -0
- data/lib/debase/ruby_core_source/ruby-2.2.4-p230/version.h +52 -0
- data/lib/debase/ruby_core_source/ruby-2.2.4-p230/vm.inc +3370 -0
- data/lib/debase/ruby_core_source/ruby-2.2.4-p230/vm_core.h +1160 -0
- data/lib/debase/ruby_core_source/ruby-2.2.4-p230/vm_debug.h +37 -0
- data/lib/debase/ruby_core_source/ruby-2.2.4-p230/vm_exec.h +182 -0
- data/lib/debase/ruby_core_source/ruby-2.2.4-p230/vm_insnhelper.h +233 -0
- data/lib/debase/ruby_core_source/ruby-2.2.4-p230/vm_opts.h +56 -0
- data/lib/debase/ruby_core_source/ruby-2.2.4-p230/vmtc.inc +105 -0
- data/lib/debase/ruby_core_source/version.rb +1 -1
- metadata +124 -2
@@ -0,0 +1,37 @@
|
|
1
|
+
/**********************************************************************
|
2
|
+
|
3
|
+
vm_debug.h - YARV Debug function interface
|
4
|
+
|
5
|
+
$Author: nobu $
|
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
|
+
#define bp() ruby_debug_breakpoint()
|
26
|
+
|
27
|
+
VALUE ruby_debug_print_value(int level, int debug_level, const char *header, VALUE v);
|
28
|
+
ID ruby_debug_print_id(int level, int debug_level, const char *header, ID id);
|
29
|
+
NODE *ruby_debug_print_node(int level, int debug_level, const char *header, const NODE *node);
|
30
|
+
int ruby_debug_print_indent(int level, int debug_level, int indent_level);
|
31
|
+
void ruby_debug_breakpoint(void);
|
32
|
+
void ruby_debug_gc_check_func(void);
|
33
|
+
void ruby_set_debug_option(const char *str);
|
34
|
+
|
35
|
+
RUBY_SYMBOL_EXPORT_END
|
36
|
+
|
37
|
+
#endif /* RUBY_DEBUG_H */
|
@@ -0,0 +1,182 @@
|
|
1
|
+
/**********************************************************************
|
2
|
+
|
3
|
+
vm.h -
|
4
|
+
|
5
|
+
$Author: ko1 $
|
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
|
+
#ifdef __GCC__
|
21
|
+
/* TODO: machine dependent prefetch instruction */
|
22
|
+
#define PREFETCH(pc)
|
23
|
+
#else
|
24
|
+
#define PREFETCH(pc)
|
25
|
+
#endif
|
26
|
+
|
27
|
+
#if VMDEBUG > 0
|
28
|
+
#define debugs printf
|
29
|
+
#define DEBUG_ENTER_INSN(insn) \
|
30
|
+
rb_vmdebug_debug_print_pre(th, GET_CFP(),GET_PC());
|
31
|
+
|
32
|
+
#if OPT_STACK_CACHING
|
33
|
+
#define SC_REGS() , reg_a, reg_b
|
34
|
+
#else
|
35
|
+
#define SC_REGS()
|
36
|
+
#endif
|
37
|
+
|
38
|
+
#define DEBUG_END_INSN() \
|
39
|
+
rb_vmdebug_debug_print_post(th, GET_CFP() SC_REGS());
|
40
|
+
|
41
|
+
#else
|
42
|
+
|
43
|
+
#define debugs
|
44
|
+
#define DEBUG_ENTER_INSN(insn)
|
45
|
+
#define DEBUG_END_INSN()
|
46
|
+
#endif
|
47
|
+
|
48
|
+
#define throwdebug if(0)printf
|
49
|
+
/* #define throwdebug printf */
|
50
|
+
|
51
|
+
/************************************************/
|
52
|
+
#if defined(DISPATCH_XXX)
|
53
|
+
error !
|
54
|
+
/************************************************/
|
55
|
+
#elif OPT_CALL_THREADED_CODE
|
56
|
+
|
57
|
+
#define LABEL(x) insn_func_##x
|
58
|
+
#define ELABEL(x)
|
59
|
+
#define LABEL_PTR(x) &LABEL(x)
|
60
|
+
|
61
|
+
#define INSN_ENTRY(insn) \
|
62
|
+
static rb_control_frame_t * \
|
63
|
+
FUNC_FASTCALL(LABEL(insn))(rb_thread_t *th, rb_control_frame_t *reg_cfp) {
|
64
|
+
|
65
|
+
#define END_INSN(insn) return reg_cfp;}
|
66
|
+
|
67
|
+
#define NEXT_INSN() return reg_cfp;
|
68
|
+
|
69
|
+
/************************************************/
|
70
|
+
#elif OPT_TOKEN_THREADED_CODE || OPT_DIRECT_THREADED_CODE
|
71
|
+
/* threaded code with gcc */
|
72
|
+
|
73
|
+
#define LABEL(x) INSN_LABEL_##x
|
74
|
+
#define ELABEL(x) INSN_ELABEL_##x
|
75
|
+
#define LABEL_PTR(x) &&LABEL(x)
|
76
|
+
|
77
|
+
#define INSN_ENTRY_SIG(insn)
|
78
|
+
|
79
|
+
|
80
|
+
#define INSN_DISPATCH_SIG(insn)
|
81
|
+
|
82
|
+
#define INSN_ENTRY(insn) \
|
83
|
+
LABEL(insn): \
|
84
|
+
INSN_ENTRY_SIG(insn); \
|
85
|
+
|
86
|
+
/* dispatcher */
|
87
|
+
#if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__)) && __GNUC__ == 3
|
88
|
+
#define DISPATCH_ARCH_DEPEND_WAY(addr) \
|
89
|
+
__asm__ __volatile__("jmp *%0;\t# -- inserted by vm.h\t[length = 2]" : : "r" (addr))
|
90
|
+
|
91
|
+
#else
|
92
|
+
#define DISPATCH_ARCH_DEPEND_WAY(addr) \
|
93
|
+
/* do nothing */
|
94
|
+
|
95
|
+
#endif
|
96
|
+
|
97
|
+
|
98
|
+
/**********************************/
|
99
|
+
#if OPT_DIRECT_THREADED_CODE
|
100
|
+
|
101
|
+
/* for GCC 3.4.x */
|
102
|
+
#define TC_DISPATCH(insn) \
|
103
|
+
INSN_DISPATCH_SIG(insn); \
|
104
|
+
goto *(void const *)GET_CURRENT_INSN(); \
|
105
|
+
;
|
106
|
+
|
107
|
+
#else
|
108
|
+
/* token threaded code */
|
109
|
+
|
110
|
+
#define TC_DISPATCH(insn) \
|
111
|
+
DISPATCH_ARCH_DEPEND_WAY(insns_address_table[GET_CURRENT_INSN()]); \
|
112
|
+
INSN_DISPATCH_SIG(insn); \
|
113
|
+
goto *insns_address_table[GET_CURRENT_INSN()]; \
|
114
|
+
rb_bug("tc error");
|
115
|
+
|
116
|
+
|
117
|
+
#endif /* DISPATCH_DIRECT_THREADED_CODE */
|
118
|
+
|
119
|
+
#define END_INSN(insn) \
|
120
|
+
DEBUG_END_INSN(); \
|
121
|
+
TC_DISPATCH(insn);
|
122
|
+
|
123
|
+
#define INSN_DISPATCH() \
|
124
|
+
TC_DISPATCH(__START__) \
|
125
|
+
{
|
126
|
+
|
127
|
+
#define END_INSNS_DISPATCH() \
|
128
|
+
rb_bug("unknown insn: %"PRIdVALUE, GET_CURRENT_INSN()); \
|
129
|
+
} /* end of while loop */ \
|
130
|
+
|
131
|
+
#define NEXT_INSN() TC_DISPATCH(__NEXT_INSN__)
|
132
|
+
|
133
|
+
/************************************************/
|
134
|
+
#else /* no threaded code */
|
135
|
+
/* most common method */
|
136
|
+
|
137
|
+
#define INSN_ENTRY(insn) \
|
138
|
+
case BIN(insn):
|
139
|
+
|
140
|
+
#define END_INSN(insn) \
|
141
|
+
DEBUG_END_INSN(); \
|
142
|
+
break;
|
143
|
+
|
144
|
+
|
145
|
+
#define INSN_DISPATCH() \
|
146
|
+
while (1) { \
|
147
|
+
switch (GET_CURRENT_INSN()) {
|
148
|
+
|
149
|
+
#define END_INSNS_DISPATCH() \
|
150
|
+
default: \
|
151
|
+
SDR(); \
|
152
|
+
rb_bug("unknown insn: %ld", GET_CURRENT_INSN()); \
|
153
|
+
} /* end of switch */ \
|
154
|
+
} /* end of while loop */ \
|
155
|
+
|
156
|
+
#define NEXT_INSN() goto first
|
157
|
+
|
158
|
+
#endif
|
159
|
+
|
160
|
+
#define VM_SP_CNT(th, sp) ((sp) - (th)->stack)
|
161
|
+
|
162
|
+
#if OPT_CALL_THREADED_CODE
|
163
|
+
#define THROW_EXCEPTION(exc) do { \
|
164
|
+
th->errinfo = (VALUE)(exc); \
|
165
|
+
return 0; \
|
166
|
+
} while (0)
|
167
|
+
#else
|
168
|
+
#define THROW_EXCEPTION(exc) return (VALUE)(exc)
|
169
|
+
#endif
|
170
|
+
|
171
|
+
#define SCREG(r) (reg_##r)
|
172
|
+
|
173
|
+
#define VM_DEBUG_STACKOVERFLOW 0
|
174
|
+
|
175
|
+
#if VM_DEBUG_STACKOVERFLOW
|
176
|
+
#define CHECK_VM_STACK_OVERFLOW_FOR_INSN(cfp, margin) \
|
177
|
+
WHEN_VM_STACK_OVERFLOWED(cfp, (cfp)->sp, margin) vm_stack_overflow_for_insn()
|
178
|
+
#else
|
179
|
+
#define CHECK_VM_STACK_OVERFLOW_FOR_INSN(cfp, margin)
|
180
|
+
#endif
|
181
|
+
|
182
|
+
#endif /* RUBY_VM_EXEC_H */
|
@@ -0,0 +1,233 @@
|
|
1
|
+
/**********************************************************************
|
2
|
+
|
3
|
+
insnhelper.h - helper macros to implement each instructions
|
4
|
+
|
5
|
+
$Author: nobu $
|
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
|
+
/**
|
16
|
+
* VM Debug Level
|
17
|
+
*
|
18
|
+
* debug level:
|
19
|
+
* 0: no debug output
|
20
|
+
* 1: show instruction name
|
21
|
+
* 2: show stack frame when control stack frame is changed
|
22
|
+
* 3: show stack status
|
23
|
+
* 4: show register
|
24
|
+
* 5:
|
25
|
+
* 10: gc check
|
26
|
+
*/
|
27
|
+
|
28
|
+
#ifndef VMDEBUG
|
29
|
+
#define VMDEBUG 0
|
30
|
+
#endif
|
31
|
+
|
32
|
+
#if 0
|
33
|
+
#undef VMDEBUG
|
34
|
+
#define VMDEBUG 3
|
35
|
+
#endif
|
36
|
+
|
37
|
+
extern VALUE ruby_vm_const_missing_count;
|
38
|
+
|
39
|
+
#if VM_COLLECT_USAGE_DETAILS
|
40
|
+
#define COLLECT_USAGE_INSN(insn) vm_collect_usage_insn(insn)
|
41
|
+
#define COLLECT_USAGE_OPERAND(insn, n, op) vm_collect_usage_operand((insn), (n), ((VALUE)(op)))
|
42
|
+
|
43
|
+
#define COLLECT_USAGE_REGISTER(reg, s) vm_collect_usage_register((reg), (s))
|
44
|
+
#else
|
45
|
+
#define COLLECT_USAGE_INSN(insn) /* none */
|
46
|
+
#define COLLECT_USAGE_OPERAND(insn, n, op) /* none */
|
47
|
+
#define COLLECT_USAGE_REGISTER(reg, s) /* none */
|
48
|
+
#endif
|
49
|
+
|
50
|
+
/**********************************************************/
|
51
|
+
/* deal with stack */
|
52
|
+
/**********************************************************/
|
53
|
+
|
54
|
+
#define PUSH(x) (SET_SV(x), INC_SP(1))
|
55
|
+
#define TOPN(n) (*(GET_SP()-(n)-1))
|
56
|
+
#define POPN(n) (DEC_SP(n))
|
57
|
+
#define POP() (DEC_SP(1))
|
58
|
+
#define STACK_ADDR_FROM_TOP(n) (GET_SP()-(n))
|
59
|
+
|
60
|
+
#define GET_TOS() (tos) /* dummy */
|
61
|
+
|
62
|
+
/**********************************************************/
|
63
|
+
/* deal with registers */
|
64
|
+
/**********************************************************/
|
65
|
+
|
66
|
+
#define REG_CFP (reg_cfp)
|
67
|
+
#define REG_PC (REG_CFP->pc)
|
68
|
+
#define REG_SP (REG_CFP->sp)
|
69
|
+
#define REG_EP (REG_CFP->ep)
|
70
|
+
|
71
|
+
#define RESTORE_REGS() do { \
|
72
|
+
REG_CFP = th->cfp; \
|
73
|
+
} while (0)
|
74
|
+
|
75
|
+
#define REG_A reg_a
|
76
|
+
#define REG_B reg_b
|
77
|
+
|
78
|
+
enum vm_regan_regtype {
|
79
|
+
VM_REGAN_PC = 0,
|
80
|
+
VM_REGAN_SP = 1,
|
81
|
+
VM_REGAN_EP = 2,
|
82
|
+
VM_REGAN_CFP = 3,
|
83
|
+
VM_REGAN_SELF = 4,
|
84
|
+
VM_REGAN_ISEQ = 5,
|
85
|
+
};
|
86
|
+
enum vm_regan_acttype {
|
87
|
+
VM_REGAN_ACT_GET = 0,
|
88
|
+
VM_REGAN_ACT_SET = 1,
|
89
|
+
};
|
90
|
+
|
91
|
+
#if VM_COLLECT_USAGE_DETAILS
|
92
|
+
#define COLLECT_USAGE_REGISTER_HELPER(a, b, v) \
|
93
|
+
(COLLECT_USAGE_REGISTER((VM_REGAN_##a), (VM_REGAN_ACT_##b)), (v))
|
94
|
+
#else
|
95
|
+
#define COLLECT_USAGE_REGISTER_HELPER(a, b, v) (v)
|
96
|
+
#endif
|
97
|
+
|
98
|
+
/* PC */
|
99
|
+
#define GET_PC() (COLLECT_USAGE_REGISTER_HELPER(PC, GET, REG_PC))
|
100
|
+
#define SET_PC(x) (REG_PC = (COLLECT_USAGE_REGISTER_HELPER(PC, SET, (x))))
|
101
|
+
#define GET_CURRENT_INSN() (*GET_PC())
|
102
|
+
#define GET_OPERAND(n) (GET_PC()[(n)])
|
103
|
+
#define ADD_PC(n) (SET_PC(REG_PC + (n)))
|
104
|
+
|
105
|
+
#define GET_PC_COUNT() (REG_PC - GET_ISEQ()->iseq_encoded)
|
106
|
+
#define JUMP(dst) (REG_PC += (dst))
|
107
|
+
|
108
|
+
/* frame pointer, environment pointer */
|
109
|
+
#define GET_CFP() (COLLECT_USAGE_REGISTER_HELPER(CFP, GET, REG_CFP))
|
110
|
+
#define GET_EP() (COLLECT_USAGE_REGISTER_HELPER(EP, GET, REG_EP))
|
111
|
+
#define SET_EP(x) (REG_EP = (COLLECT_USAGE_REGISTER_HELPER(EP, SET, (x))))
|
112
|
+
#define GET_LEP() (VM_EP_LEP(GET_EP()))
|
113
|
+
|
114
|
+
/* SP */
|
115
|
+
#define GET_SP() (COLLECT_USAGE_REGISTER_HELPER(SP, GET, REG_SP))
|
116
|
+
#define SET_SP(x) (REG_SP = (COLLECT_USAGE_REGISTER_HELPER(SP, SET, (x))))
|
117
|
+
#define INC_SP(x) (REG_SP += (COLLECT_USAGE_REGISTER_HELPER(SP, SET, (x))))
|
118
|
+
#define DEC_SP(x) (REG_SP -= (COLLECT_USAGE_REGISTER_HELPER(SP, SET, (x))))
|
119
|
+
#define SET_SV(x) (*GET_SP() = (x))
|
120
|
+
/* set current stack value as x */
|
121
|
+
|
122
|
+
#define GET_SP_COUNT() (REG_SP - th->stack)
|
123
|
+
|
124
|
+
/* instruction sequence C struct */
|
125
|
+
#define GET_ISEQ() (GET_CFP()->iseq)
|
126
|
+
|
127
|
+
/**********************************************************/
|
128
|
+
/* deal with variables */
|
129
|
+
/**********************************************************/
|
130
|
+
|
131
|
+
#define GET_PREV_EP(ep) ((VALUE *)((ep)[0] & ~0x03))
|
132
|
+
|
133
|
+
#define GET_GLOBAL(entry) rb_gvar_get((struct rb_global_entry*)(entry))
|
134
|
+
#define SET_GLOBAL(entry, val) rb_gvar_set((struct rb_global_entry*)(entry), (val))
|
135
|
+
|
136
|
+
#define GET_CONST_INLINE_CACHE(dst) ((IC) * (GET_PC() + (dst) + 2))
|
137
|
+
|
138
|
+
/**********************************************************/
|
139
|
+
/* deal with values */
|
140
|
+
/**********************************************************/
|
141
|
+
|
142
|
+
#define GET_SELF() (COLLECT_USAGE_REGISTER_HELPER(SELF, GET, GET_CFP()->self))
|
143
|
+
|
144
|
+
/**********************************************************/
|
145
|
+
/* deal with control flow 2: method/iterator */
|
146
|
+
/**********************************************************/
|
147
|
+
|
148
|
+
#define COPY_CREF_OMOD(c1, c2) do { \
|
149
|
+
RB_OBJ_WRITE((c1), &(c1)->nd_refinements, (c2)->nd_refinements); \
|
150
|
+
if (!NIL_P((c2)->nd_refinements)) { \
|
151
|
+
(c1)->flags |= NODE_FL_CREF_OMOD_SHARED; \
|
152
|
+
(c2)->flags |= NODE_FL_CREF_OMOD_SHARED; \
|
153
|
+
} \
|
154
|
+
} while (0)
|
155
|
+
|
156
|
+
#define COPY_CREF(c1, c2) do { \
|
157
|
+
NODE *__tmp_c2 = (c2); \
|
158
|
+
COPY_CREF_OMOD(c1, __tmp_c2); \
|
159
|
+
RB_OBJ_WRITE((c1), &(c1)->nd_clss, __tmp_c2->nd_clss); \
|
160
|
+
(c1)->nd_visi = __tmp_c2->nd_visi;\
|
161
|
+
RB_OBJ_WRITE((c1), &(c1)->nd_next, __tmp_c2->nd_next); \
|
162
|
+
if (__tmp_c2->flags & NODE_FL_CREF_PUSHED_BY_EVAL) { \
|
163
|
+
(c1)->flags |= NODE_FL_CREF_PUSHED_BY_EVAL; \
|
164
|
+
} \
|
165
|
+
} while (0)
|
166
|
+
|
167
|
+
#define CALL_METHOD(ci) do { \
|
168
|
+
VALUE v = (*(ci)->call)(th, GET_CFP(), (ci)); \
|
169
|
+
if (v == Qundef) { \
|
170
|
+
RESTORE_REGS(); \
|
171
|
+
NEXT_INSN(); \
|
172
|
+
} \
|
173
|
+
else { \
|
174
|
+
val = v; \
|
175
|
+
} \
|
176
|
+
} while (0)
|
177
|
+
|
178
|
+
/* set fastpath when cached method is *NOT* protected
|
179
|
+
* because inline method cache does not care about receiver.
|
180
|
+
*/
|
181
|
+
|
182
|
+
#ifndef OPT_CALL_FASTPATH
|
183
|
+
#define OPT_CALL_FASTPATH 1
|
184
|
+
#endif
|
185
|
+
|
186
|
+
#if OPT_CALL_FASTPATH
|
187
|
+
#define CI_SET_FASTPATH(ci, func, enabled) do { \
|
188
|
+
if (LIKELY(enabled)) ((ci)->call = (func)); \
|
189
|
+
} while (0)
|
190
|
+
#else
|
191
|
+
#define CI_SET_FASTPATH(ci, func, enabled) /* do nothing */
|
192
|
+
#endif
|
193
|
+
|
194
|
+
#define GET_BLOCK_PTR() ((rb_block_t *)(GC_GUARDED_PTR_REF(GET_LEP()[0])))
|
195
|
+
|
196
|
+
/**********************************************************/
|
197
|
+
/* deal with control flow 3: exception */
|
198
|
+
/**********************************************************/
|
199
|
+
|
200
|
+
|
201
|
+
/**********************************************************/
|
202
|
+
/* others */
|
203
|
+
/**********************************************************/
|
204
|
+
|
205
|
+
/* optimize insn */
|
206
|
+
#define FIXNUM_2_P(a, b) ((a) & (b) & 1)
|
207
|
+
#if USE_FLONUM
|
208
|
+
#define FLONUM_2_P(a, b) (((((a)^2) | ((b)^2)) & 3) == 0) /* (FLONUM_P(a) && FLONUM_P(b)) */
|
209
|
+
#else
|
210
|
+
#define FLONUM_2_P(a, b) 0
|
211
|
+
#endif
|
212
|
+
|
213
|
+
#ifndef USE_IC_FOR_SPECIALIZED_METHOD
|
214
|
+
#define USE_IC_FOR_SPECIALIZED_METHOD 1
|
215
|
+
#endif
|
216
|
+
|
217
|
+
#define CALL_SIMPLE_METHOD(recv_) do { \
|
218
|
+
ci->blockptr = 0; ci->argc = ci->orig_argc; \
|
219
|
+
vm_search_method(ci, ci->recv = (recv_)); \
|
220
|
+
CALL_METHOD(ci); \
|
221
|
+
} while (0)
|
222
|
+
|
223
|
+
#define NEXT_CLASS_SERIAL() (++ruby_vm_class_serial)
|
224
|
+
#define GET_GLOBAL_METHOD_STATE() (ruby_vm_global_method_state)
|
225
|
+
#define INC_GLOBAL_METHOD_STATE() (++ruby_vm_global_method_state)
|
226
|
+
#define GET_GLOBAL_CONSTANT_STATE() (ruby_vm_global_constant_state)
|
227
|
+
#define INC_GLOBAL_CONSTANT_STATE() (++ruby_vm_global_constant_state)
|
228
|
+
|
229
|
+
static VALUE make_no_method_exception(VALUE exc, const char *format,
|
230
|
+
VALUE obj, int argc, const VALUE *argv);
|
231
|
+
|
232
|
+
|
233
|
+
#endif /* RUBY_INSNHELPER_H */
|