Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 185 lines (133 sloc) 4.211 kb
a3e1b1c @ko1 * Merge YARV
ko1 authored
1 /**********************************************************************
2
3 vm.h -
4
5 $Author$
6 created at: 04/01/01 16:56:59 JST
7
d907cbc @ko1 * blockinlining.c, compile.c, compile.h, debug.c, debug.h,
ko1 authored
8 Copyright (C) 2004-2007 Koichi Sasada
a3e1b1c @ko1 * Merge YARV
ko1 authored
9
10 **********************************************************************/
11
40f859b @nobu * vm_exec.h (RUBY_VM_EXEC_H): fixed include guard.
nobu authored
12 #ifndef RUBY_VM_EXEC_H
13 #define RUBY_VM_EXEC_H
a3e1b1c @ko1 * Merge YARV
ko1 authored
14
15 typedef long OFFSET;
7980e65 @ko1 * call_cfunc.ci: removed.
ko1 authored
16 typedef unsigned long lindex_t;
17 typedef unsigned long dindex_t;
18 typedef rb_num_t GENTRY;
ae421c4 @ko1 * insnhelper.ci, insns.def: move some statements to functions.
ko1 authored
19 typedef rb_iseq_t *ISEQ;
7980e65 @ko1 * call_cfunc.ci: removed.
ko1 authored
20
a3e1b1c @ko1 * Merge YARV
ko1 authored
21 #ifdef COLLECT_USAGE_ANALYSIS
22 #define USAGE_ANALYSIS_INSN(insn) vm_analysis_insn(insn)
35dbe50 @akr * vm_exec.h: parenthesize macro arguments.
akr authored
23 #define USAGE_ANALYSIS_OPERAND(insn, n, op) vm_analysis_operand((insn), (n), (VALUE)(op))
24 #define USAGE_ANALYSIS_REGISTER(reg, s) vm_analysis_register((reg), (s))
a3e1b1c @ko1 * Merge YARV
ko1 authored
25 #else
6b6bf4d @ko1 * blockinlining.c: remove "yarv" prefix.
ko1 authored
26 #define USAGE_ANALYSIS_INSN(insn) /* none */
a3e1b1c @ko1 * Merge YARV
ko1 authored
27 #define USAGE_ANALYSIS_OPERAND(insn, n, op) /* none */
6b6bf4d @ko1 * blockinlining.c: remove "yarv" prefix.
ko1 authored
28 #define USAGE_ANALYSIS_REGISTER(reg, s) /* none */
a3e1b1c @ko1 * Merge YARV
ko1 authored
29 #endif
30
31 #ifdef __GCC__
32 /* TODO: machine dependent prefetch instruction */
33 #define PREFETCH(pc)
34 #else
35 #define PREFETCH(pc)
36 #endif
37
38 #if VMDEBUG > 0
39 #define debugs printf
40 #define DEBUG_ENTER_INSN(insn) \
41 debug_print_pre(th, GET_CFP());
42
43 #if OPT_STACK_CACHING
44 #define SC_REGS() , reg_a, reg_b
45 #else
46 #define SC_REGS()
47 #endif
48
49 #define DEBUG_END_INSN() \
50 debug_print_post(th, GET_CFP() SC_REGS());
51
52 #else
53
54 #define debugs
295bc2f @yugui removes the dtrace support. reverts r26239, r26238 and r26235.
yugui authored
55 #define DEBUG_ENTER_INSN(insn)
56 #define DEBUG_END_INSN()
a3e1b1c @ko1 * Merge YARV
ko1 authored
57 #endif
58
59 #define throwdebug if(0)printf
205f310 @nobu * call_cfunc.ci, compile.c, compile.h, debug.h, eval.c,
nobu authored
60 /* #define throwdebug printf */
a3e1b1c @ko1 * Merge YARV
ko1 authored
61
62 /************************************************/
63 #if DISPATCH_XXX
64 error !
65 /************************************************/
66 #elif OPT_CALL_THREADED_CODE
67
fd58a08 @ko1 * common.mk (run.gdb): fix to load $(srcdir)/.gdbinit
ko1 authored
68 #define LABEL(x) insn_func_##x
69 #define ELABEL(x)
70 #define LABEL_PTR(x) &LABEL(x)
71
a3e1b1c @ko1 * Merge YARV
ko1 authored
72 #define INSN_ENTRY(insn) \
c44e2cd @ko1 * vm_evalbody.ci: support OPT_CALL_THREADED_CODE.
ko1 authored
73 static rb_control_frame_t * \
480c602 @ko1 * win32/Makefile.sub: define FUNC_FASTCALL macro.
ko1 authored
74 FUNC_FASTCALL(LABEL(insn))(rb_thread_t *th, rb_control_frame_t *reg_cfp) {
a3e1b1c @ko1 * Merge YARV
ko1 authored
75
76 #define END_INSN(insn) return reg_cfp;}
77
78 #define NEXT_INSN() return reg_cfp;
79
80 /************************************************/
81 #elif OPT_TOKEN_THREADED_CODE || OPT_DIRECT_THREADED_CODE
82 /* threaded code with gcc */
83
84 #define LABEL(x) INSN_LABEL_##x
85 #define ELABEL(x) INSN_ELABEL_##x
86 #define LABEL_PTR(x) &&LABEL(x)
87
9f34b73 @ko1 * cont.c, vm.h: fix to support sparc machine.
ko1 authored
88 #define INSN_ENTRY_SIG(insn)
a3e1b1c @ko1 * Merge YARV
ko1 authored
89
90
9f34b73 @ko1 * cont.c, vm.h: fix to support sparc machine.
ko1 authored
91 #define INSN_DISPATCH_SIG(insn)
a3e1b1c @ko1 * Merge YARV
ko1 authored
92
93 #define INSN_ENTRY(insn) \
94 LABEL(insn): \
95 INSN_ENTRY_SIG(insn); \
96
97 /* dispather */
98 #if __GNUC__ && (__i386__ || __x86_64__) && __GNUC__ == 3
99 #define DISPATCH_ARCH_DEPEND_WAY(addr) \
100 asm volatile("jmp *%0;\t# -- inseted by vm.h\t[length = 2]" : : "r" (addr))
101
102 #else
103 #define DISPATCH_ARCH_DEPEND_WAY(addr) \
104 /* do nothing */
105
106 #endif
107
108
109 /**********************************/
110 #if OPT_DIRECT_THREADED_CODE
111
112 /* for GCC 3.4.x */
113 #define TC_DISPATCH(insn) \
114 INSN_DISPATCH_SIG(insn); \
7175a90 @nurse * class.c, compile.c, dir.c, file.c, iseq.c, parse.y, random.c:
nurse authored
115 goto *(void const *)GET_CURRENT_INSN(); \
a3e1b1c @ko1 * Merge YARV
ko1 authored
116 ;
117
118 #else
119 /* token threade code */
120
121 #define TC_DISPATCH(insn) \
122 DISPATCH_ARCH_DEPEND_WAY(insns_address_table[GET_CURRENT_INSN()]); \
123 INSN_DISPATCH_SIG(insn); \
124 goto *insns_address_table[GET_CURRENT_INSN()]; \
125 rb_bug("tc error");
126
127
128 #endif /* DISPATCH_DIRECT_THREADED_CODE */
129
130 #define END_INSN(insn) \
131 DEBUG_END_INSN(); \
132 TC_DISPATCH(insn); \
133
134 #define INSN_DISPATCH() \
135 TC_DISPATCH(__START__) \
136 {
137
138 #define END_INSNS_DISPATCH() \
cea3919 @nobu * configure.in (RUBY_CHECK_PRINTF_PREFIX): check for printf format
nobu authored
139 rb_bug("unknown insn: %"PRIdVALUE, GET_CURRENT_INSN()); \
a3e1b1c @ko1 * Merge YARV
ko1 authored
140 } /* end of while loop */ \
141
142 #define NEXT_INSN() TC_DISPATCH(__NEXT_INSN__)
143
144 /************************************************/
145 #else /* no threaded code */
146 /* most common method */
147
148 #define INSN_ENTRY(insn) \
149 case BIN(insn):
150
151 #define END_INSN(insn) \
152 DEBUG_END_INSN(); \
153 break;
154
155
156 #define INSN_DISPATCH() \
157 while(1){ \
158 switch(GET_CURRENT_INSN()){
159
160 #define END_INSNS_DISPATCH() \
161 default: \
162 SDR(); \
163 rb_bug("unknown insn: %ld", GET_CURRENT_INSN()); \
164 } /* end of switch */ \
165 } /* end of while loop */ \
166
167 #define NEXT_INSN() goto first
168
169 #endif
170
c44e2cd @ko1 * vm_evalbody.ci: support OPT_CALL_THREADED_CODE.
ko1 authored
171 #define VM_SP_CNT(th, sp) ((sp) - (th)->stack)
172
173 #if OPT_CALL_THREADED_CODE
174 #define THROW_EXCEPTION(exc) do { \
175 th->errinfo = (VALUE)(exc); \
176 return 0; \
177 } while (0)
178 #else
41e9245 @ko1 * compile.c (iseq_translate_direct_threaded_code): fix prototype
ko1 authored
179 #define THROW_EXCEPTION(exc) return (VALUE)(exc)
c44e2cd @ko1 * vm_evalbody.ci: support OPT_CALL_THREADED_CODE.
ko1 authored
180 #endif
181
a3e1b1c @ko1 * Merge YARV
ko1 authored
182 #define SCREG(r) (reg_##r)
183
40f859b @nobu * vm_exec.h (RUBY_VM_EXEC_H): fixed include guard.
nobu authored
184 #endif /* RUBY_VM_EXEC_H */
Something went wrong with that request. Please try again.