Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 858 lines (684 sloc) 23.021 kB
a3e1b1c @ko1 * Merge YARV
ko1 authored
1 /**********************************************************************
2
9e8367a @nobu * vm_core.h: removed trailing garbage spaces.
nobu authored
3 vm_core.h -
a3e1b1c @ko1 * Merge YARV
ko1 authored
4
5 $Author$
6 created at: 04/01/01 19:41:38 JST
7
6b6bf4d @ko1 * blockinlining.c: remove "yarv" prefix.
ko1 authored
8 Copyright (C) 2004-2007 Koichi Sasada
a3e1b1c @ko1 * Merge YARV
ko1 authored
9
10 **********************************************************************/
11
8a9993d @nobu * eval_intern.h, insnhelper.h, thread_pthread.h, vm_core.h, vm_opts.h:
nobu authored
12 #ifndef RUBY_VM_CORE_H
13 #define RUBY_VM_CORE_H
a3e1b1c @ko1 * Merge YARV
ko1 authored
14
8ee7d07 @ko1 * blockinlining.c, compile.c, compile.h, error.c, eval.c,
ko1 authored
15 #define RUBY_VM_THREAD_MODEL 2
a3e1b1c @ko1 * Merge YARV
ko1 authored
16
2b59258 @nobu * include/ruby: moved public headers.
nobu authored
17 #include "ruby/ruby.h"
18 #include "ruby/st.h"
a3e1b1c @ko1 * Merge YARV
ko1 authored
19
2e311f6 @ko1 * include/ruby/node.h, node.h: move node.h from include path.
ko1 authored
20 #include "node.h"
a3e1b1c @ko1 * Merge YARV
ko1 authored
21 #include "debug.h"
22 #include "vm_opts.h"
6b6bf4d @ko1 * blockinlining.c: remove "yarv" prefix.
ko1 authored
23 #include "id.h"
c330876 @ko1 * method.h, vm_core.h: add rb_method_entry_t. Remove nodes around
ko1 authored
24 #include "method.h"
9d4e471 @kosaki * vm_core.h (RUBY_VM_SET_TIMER_INTERRUPT, RUBY_VM_SET_INTERRUPT,
kosaki authored
25 #include "atomic.h"
a3e1b1c @ko1 * Merge YARV
ko1 authored
26
ae317b5 @ko1 * yarvcore.h, thread.c: fix to use pthread on cygwin.
ko1 authored
27 #if defined(_WIN32)
a3e1b1c @ko1 * Merge YARV
ko1 authored
28 #include "thread_win32.h"
29 #elif defined(HAVE_PTHREAD_H)
30 #include "thread_pthread.h"
31 #else
32 #error "unsupported thread type"
33 #endif
34
d36c76d @nobu * common.mk (eval.o): needs vm.h.
nobu authored
35 #ifndef ENABLE_VM_OBJSPACE
8892dd7 @nobu * vm_core.h (ENABLE_VM_OBJSPACE): socklist needs st_table in
nobu authored
36 #ifdef _WIN32
37 /*
a420957 @nobu * insns.def, vm_core.h: fixed typo. reported by Rocky Bernstein
nobu authored
38 * TODO: object space independent st_table.
8892dd7 @nobu * vm_core.h (ENABLE_VM_OBJSPACE): socklist needs st_table in
nobu authored
39 * socklist needs st_table in rb_w32_sysinit(), before object space
40 * initialization.
41 * It is too early now to change st_hash_type, since it breaks binary
42 * compatibility.
43 */
44 #define ENABLE_VM_OBJSPACE 0
45 #else
d36c76d @nobu * common.mk (eval.o): needs vm.h.
nobu authored
46 #define ENABLE_VM_OBJSPACE 1
47 #endif
8892dd7 @nobu * vm_core.h (ENABLE_VM_OBJSPACE): socklist needs st_table in
nobu authored
48 #endif
d36c76d @nobu * common.mk (eval.o): needs vm.h.
nobu authored
49
705b8b4 @shyouhei * vm_core.h: ruby/ruby.h should be included at the very first
shyouhei authored
50 #include <setjmp.h>
a3e1b1c @ko1 * Merge YARV
ko1 authored
51 #include <signal.h>
52
53 #ifndef NSIG
642e081 @yugui * dln.c: Ruby no longer supports MacOS 9 or before.
yugui authored
54 # define NSIG (_SIGMAX + 1) /* For QNX */
a3e1b1c @ko1 * Merge YARV
ko1 authored
55 #endif
56
57 #define RUBY_NSIG NSIG
58
7f7834a @ko1 * include/ruby/node.h, vm_core.h: move definition of
ko1 authored
59 #ifdef HAVE_STDARG_PROTOTYPES
60 #include <stdarg.h>
741e778 @akr * vm_core.h: parenthesize macro arguments.
akr authored
61 #define va_init_list(a,b) va_start((a),(b))
7f7834a @ko1 * include/ruby/node.h, vm_core.h: move definition of
ko1 authored
62 #else
63 #include <varargs.h>
741e778 @akr * vm_core.h: parenthesize macro arguments.
akr authored
64 #define va_init_list(a,b) va_start((a))
7f7834a @ko1 * include/ruby/node.h, vm_core.h: move definition of
ko1 authored
65 #endif
66
5058731 @mame * vm_core.c (rb_thread_struct): add a field for sigaltstack.
mame authored
67 #if defined(SIGSEGV) && defined(HAVE_SIGALTSTACK) && defined(SA_SIGINFO) && !defined(__NetBSD__)
68 #define USE_SIGALTSTACK
69 #endif
70
a3e1b1c @ko1 * Merge YARV
ko1 authored
71 /*****************/
72 /* configuration */
73 /*****************/
74
75 /* gcc ver. check */
76 #if defined(__GNUC__) && __GNUC__ >= 2
77
78 #if OPT_TOKEN_THREADED_CODE
79 #if OPT_DIRECT_THREADED_CODE
80 #undef OPT_DIRECT_THREADED_CODE
81 #endif
82 #endif
83
84 #else /* defined(__GNUC__) && __GNUC__ >= 2 */
85
86 /* disable threaded code options */
87 #if OPT_DIRECT_THREADED_CODE
88 #undef OPT_DIRECT_THREADED_CODE
89 #endif
90 #if OPT_TOKEN_THREADED_CODE
91 #undef OPT_TOKEN_THREADED_CODE
92 #endif
93 #endif
94
76bc2d1 @yugui Imports Ruby's port to NativeClient (a.k.a NaCl).
yugui authored
95 #ifdef __native_client__
96 #undef OPT_DIRECT_THREADED_CODE
97 #endif
98
a3e1b1c @ko1 * Merge YARV
ko1 authored
99 /* call threaded code */
100 #if OPT_CALL_THREADED_CODE
101 #if OPT_DIRECT_THREADED_CODE
102 #undef OPT_DIRECT_THREADED_CODE
103 #endif /* OPT_DIRECT_THREADED_CODE */
104 #if OPT_STACK_CACHING
105 #undef OPT_STACK_CACHING
106 #endif /* OPT_STACK_CACHING */
107 #endif /* OPT_CALL_THREADED_CODE */
108
295bc2f @yugui removes the dtrace support. reverts r26239, r26238 and r26235.
yugui authored
109 /* likely */
110 #if __GNUC__ >= 3
111 #define LIKELY(x) (__builtin_expect((x), 1))
112 #define UNLIKELY(x) (__builtin_expect((x), 0))
113 #else /* __GNUC__ >= 3 */
114 #define LIKELY(x) (x)
115 #define UNLIKELY(x) (x)
116 #endif /* __GNUC__ >= 3 */
117
75ce784 @kosaki * vm_core.h: Introduce UNINITIALIZED_VAR() macro.
kosaki authored
118 #if __GNUC__ >= 3
119 #define UNINITIALIZED_VAR(x) x = x
120 #else
121 #define UNINITIALIZED_VAR(x) x
122 #endif
123
59432db @nobu * vm_core.h (rb_num_t): moved form vm.h.
nobu authored
124 typedef unsigned long rb_num_t;
125
c330876 @ko1 * method.h, vm_core.h: add rb_method_entry_t. Remove nodes around
ko1 authored
126 /* iseq data type */
127
a3e1b1c @ko1 * Merge YARV
ko1 authored
128 struct iseq_compile_data_ensure_node_stack;
129
b76fd82 @ko1 * vm_core.h: some refactoring.
ko1 authored
130 typedef struct rb_compile_option_struct rb_compile_option_t;
a3e1b1c @ko1 * Merge YARV
ko1 authored
131
20d9aef @ko1 * vm_core.h, compile.c: declare struct iseq_inline_cache_entry.
ko1 authored
132 struct iseq_inline_cache_entry {
fe1ce93 @nobu * compile.c, cont.c, gc.c, insns.def, iseq.c, iseq.h, process.c,
nobu authored
133 VALUE ic_vmstat;
20d9aef @ko1 * vm_core.h, compile.c: declare struct iseq_inline_cache_entry.
ko1 authored
134 VALUE ic_class;
6f817b6 @ko1 * vm_core.h: change members of iseq_inline_cache_entry.
ko1 authored
135 union {
136 VALUE value;
137 rb_method_entry_t *method;
138 long index;
139 } ic_value;
319088e @shugo * class.c, insns.def, method.h, proc.c, vm.c, vm_core.h, vm_eval.c,
shugo authored
140 union {
141 VALUE defined_class;
142 } ic_value2;
20d9aef @ko1 * vm_core.h, compile.c: declare struct iseq_inline_cache_entry.
ko1 authored
143 };
144
144ff32 @ko1 * insnhelper.ci (caller_setup_args): add need_block_check option.
ko1 authored
145 #if 1
146 #define GetCoreDataFromValue(obj, type, ptr) do { \
741e778 @akr * vm_core.h: parenthesize macro arguments.
akr authored
147 (ptr) = (type*)DATA_PTR(obj); \
144ff32 @ko1 * insnhelper.ci (caller_setup_args): add need_block_check option.
ko1 authored
148 } while (0)
149 #else
741e778 @akr * vm_core.h: parenthesize macro arguments.
akr authored
150 #define GetCoreDataFromValue(obj, type, ptr) Data_Get_Struct((obj), type, (ptr))
144ff32 @ko1 * insnhelper.ci (caller_setup_args): add need_block_check option.
ko1 authored
151 #endif
152
153 #define GetISeqPtr(obj, ptr) \
741e778 @akr * vm_core.h: parenthesize macro arguments.
akr authored
154 GetCoreDataFromValue((obj), rb_iseq_t, (ptr))
a3e1b1c @ko1 * Merge YARV
ko1 authored
155
bac9f65 @ko1 * vm_core.h (rb_location_t): fix type and field name.
ko1 authored
156 typedef struct rb_iseq_location_struct {
157 VALUE path;
158 VALUE absolute_path;
159 VALUE base_label;
160 VALUE label;
161 size_t first_lineno;
162 } rb_iseq_location_t;
8bcf7fc @ko1 * vm_core.h: add a data type rb_location_t to store iseq location
ko1 authored
163
8ee7d07 @ko1 * blockinlining.c, compile.c, compile.h, error.c, eval.c,
ko1 authored
164 struct rb_iseq_struct;
a3e1b1c @ko1 * Merge YARV
ko1 authored
165
8ee7d07 @ko1 * blockinlining.c, compile.c, compile.h, error.c, eval.c,
ko1 authored
166 struct rb_iseq_struct {
6a69ad4 @ko1 * yarvcore.h: some refactoring on rb_iseq_t.
ko1 authored
167 /***************/
168 /* static data */
169 /***************/
170
b76fd82 @ko1 * vm_core.h: some refactoring.
ko1 authored
171 enum iseq_type {
172 ISEQ_TYPE_TOP,
173 ISEQ_TYPE_METHOD,
174 ISEQ_TYPE_BLOCK,
175 ISEQ_TYPE_CLASS,
176 ISEQ_TYPE_RESCUE,
177 ISEQ_TYPE_ENSURE,
178 ISEQ_TYPE_EVAL,
179 ISEQ_TYPE_MAIN,
fe1f0df @znz remove a comma at end of enumerator list.
znz authored
180 ISEQ_TYPE_DEFINED_GUARD
b76fd82 @ko1 * vm_core.h: some refactoring.
ko1 authored
181 } type; /* instruction sequence type */
182
bac9f65 @ko1 * vm_core.h (rb_location_t): fix type and field name.
ko1 authored
183 rb_iseq_location_t location;
8bcf7fc @ko1 * vm_core.h: add a data type rb_location_t to store iseq location
ko1 authored
184
a420957 @nobu * insns.def, vm_core.h: fixed typo. reported by Rocky Bernstein
nobu authored
185 VALUE *iseq; /* iseq (insn number and operands) */
6a69ad4 @ko1 * yarvcore.h: some refactoring on rb_iseq_t.
ko1 authored
186 VALUE *iseq_encoded; /* encoded iseq */
187 unsigned long iseq_size;
27013e7 @ko1 * yarvcore.h, compile.c, insnhelper.ci, iseq.c, vm.c:
ko1 authored
188 VALUE mark_ary; /* Array: includes operands which should be GC marked */
5874de9 @mame * Add coverage measurement constant COVERAGE__. This constant is not
mame authored
189 VALUE coverage; /* coverage array */
cb61ea5 @nobu remove trailing spaces
nobu authored
190
a3e1b1c @ko1 * Merge YARV
ko1 authored
191 /* insn info, must be freed */
7049d9c @ko1 * iseq.h, iseq.c, compile.c: Change the line number data structure
ko1 authored
192 struct iseq_line_info_entry *line_info_table;
193 size_t line_info_size;
a3e1b1c @ko1 * Merge YARV
ko1 authored
194
71986ef @ko1 * yarvcore.h:
ko1 authored
195 ID *local_table; /* must free */
196 int local_table_size;
197
198 /* method, class frame: sizeof(vars) + 1, block frame: sizeof(vars) */
9e8367a @nobu * vm_core.h: removed trailing garbage spaces.
nobu authored
199 int local_size;
a3e1b1c @ko1 * Merge YARV
ko1 authored
200
20d9aef @ko1 * vm_core.h, compile.c: declare struct iseq_inline_cache_entry.
ko1 authored
201 struct iseq_inline_cache_entry *ic_entries;
202 int ic_size;
203
abcbd7e @ko1 * yarvcore.h: remove rb_control_frame_t#callee_id.
ko1 authored
204 /**
205 * argument information
206 *
6a69ad4 @ko1 * yarvcore.h: some refactoring on rb_iseq_t.
ko1 authored
207 * def m(a1, a2, ..., aM, # mandatory
a420957 @nobu * insns.def, vm_core.h: fixed typo. reported by Rocky Bernstein
nobu authored
208 * b1=(...), b2=(...), ..., bN=(...), # optional
6a69ad4 @ko1 * yarvcore.h: some refactoring on rb_iseq_t.
ko1 authored
209 * *c, # rest
210 * d1, d2, ..., dO, # post
211 * &e) # block
abcbd7e @ko1 * yarvcore.h: remove rb_control_frame_t#callee_id.
ko1 authored
212 * =>
213 *
6a69ad4 @ko1 * yarvcore.h: some refactoring on rb_iseq_t.
ko1 authored
214 * argc = M
215 * arg_rest = M+N+1 // or -1 if no rest arg
6c38e61 @marcandre * vm_core.h: Fix comment about arg_opts of iseq and some typos
marcandre authored
216 * arg_opts = N+1 // or 0 if no optional arg
217 * arg_opt_table = [ (arg_opts entries) ]
6a69ad4 @ko1 * yarvcore.h: some refactoring on rb_iseq_t.
ko1 authored
218 * arg_post_len = O // 0 if no post arguments
219 * arg_post_start = M+N+2
220 * arg_block = M+N + 1 + O + 1 // -1 if no block arg
221 * arg_simple = 0 if not simple arguments.
222 * = 1 if no opt, rest, post, block.
6c38e61 @marcandre * vm_core.h: Fix comment about arg_opts of iseq and some typos
marcandre authored
223 * = 2 if ambiguous block parameter ({|a|}).
6a69ad4 @ko1 * yarvcore.h: some refactoring on rb_iseq_t.
ko1 authored
224 * arg_size = argument size.
abcbd7e @ko1 * yarvcore.h: remove rb_control_frame_t#callee_id.
ko1 authored
225 */
a3e1b1c @ko1 * Merge YARV
ko1 authored
226
227 int argc;
228 int arg_simple;
229 int arg_rest;
230 int arg_block;
231 int arg_opts;
75d28f8 @ko1 * yarvcore.h, compile.c (set_arguments): support post arguments.
ko1 authored
232 int arg_post_len;
68e02f2 @ko1 * vm.c (callee_setup_arg): added. support correct post arg.
ko1 authored
233 int arg_post_start;
234 int arg_size;
27013e7 @ko1 * yarvcore.h, compile.c, insnhelper.ci, iseq.c, vm.c:
ko1 authored
235 VALUE *arg_opt_table;
a0a2c14 @mame * vm_core.h (struct rb_iseq_struct), compile.c (iseq_set_arguments, i…
mame authored
236 int arg_keyword;
d0baa0d @mame * vm_core.h (struct rb_iseq_struct), compile.c (iseq_set_arguments), …
mame authored
237 int arg_keyword_check; /* if this is true, raise an ArgumentError when unknown keyword argument is passed */
a0a2c14 @mame * vm_core.h (struct rb_iseq_struct), compile.c (iseq_set_arguments, i…
mame authored
238 int arg_keywords;
239 ID *arg_keyword_table;
a3e1b1c @ko1 * Merge YARV
ko1 authored
240
6120338 @nobu * vm_core.h (struct rb_iseq_struct): fixed types.
nobu authored
241 size_t stack_max; /* for stack overflow check */
a3e1b1c @ko1 * Merge YARV
ko1 authored
242
243 /* catch table */
27013e7 @ko1 * yarvcore.h, compile.c, insnhelper.ci, iseq.c, vm.c:
ko1 authored
244 struct iseq_catch_table_entry *catch_table;
a3e1b1c @ko1 * Merge YARV
ko1 authored
245 int catch_table_size;
246
247 /* for child iseq */
8ee7d07 @ko1 * blockinlining.c, compile.c, compile.h, error.c, eval.c,
ko1 authored
248 struct rb_iseq_struct *parent_iseq;
249 struct rb_iseq_struct *local_iseq;
a3e1b1c @ko1 * Merge YARV
ko1 authored
250
6a69ad4 @ko1 * yarvcore.h: some refactoring on rb_iseq_t.
ko1 authored
251 /****************/
252 /* dynamic data */
253 /****************/
254
255 VALUE self;
e956f28 * class.c (clone_method): should copy cbase in cref as well.
matz authored
256 VALUE orig; /* non-NULL if its data have origin */
6a69ad4 @ko1 * yarvcore.h: some refactoring on rb_iseq_t.
ko1 authored
257
a3e1b1c @ko1 * Merge YARV
ko1 authored
258 /* block inlining */
9e8367a @nobu * vm_core.h: removed trailing garbage spaces.
nobu authored
259 /*
bfc19ad @ko1 * iseq.c, vm_core.h: comment out unused fields.
ko1 authored
260 * NODE *node;
261 * void *special_block_builder;
262 * void *cached_special_block_builder;
263 * VALUE cached_special_block;
264 */
a3e1b1c @ko1 * Merge YARV
ko1 authored
265
6a69ad4 @ko1 * yarvcore.h: some refactoring on rb_iseq_t.
ko1 authored
266 /* klass/module nest information stack (cref) */
267 NODE *cref_stack;
268 VALUE klass;
269
a3e1b1c @ko1 * Merge YARV
ko1 authored
270 /* misc */
271 ID defined_method_id; /* for define_method */
8ee7d07 @ko1 * blockinlining.c, compile.c, compile.h, error.c, eval.c,
ko1 authored
272
6a69ad4 @ko1 * yarvcore.h: some refactoring on rb_iseq_t.
ko1 authored
273 /* used at compile time */
a3e1b1c @ko1 * Merge YARV
ko1 authored
274 struct iseq_compile_data *compile_data;
275 };
276
9b45b33 @nobu * vm_core.h (rb_vm_t), vm.c (rb_vm_mark): moved preallocated special
nobu authored
277 enum ruby_special_exceptions {
278 ruby_error_reenter,
279 ruby_error_nomemory,
280 ruby_error_sysstack,
58b3253 @nobu * thread.c (rb_thread_io_blocking_region): new function to run
nobu authored
281 ruby_error_closed_stream,
9b45b33 @nobu * vm_core.h (rb_vm_t), vm.c (rb_vm_mark): moved preallocated special
nobu authored
282 ruby_special_error_count
283 };
284
a3e1b1c @ko1 * Merge YARV
ko1 authored
285 #define GetVMPtr(obj, ptr) \
741e778 @akr * vm_core.h: parenthesize macro arguments.
akr authored
286 GetCoreDataFromValue((obj), rb_vm_t, (ptr))
a3e1b1c @ko1 * Merge YARV
ko1 authored
287
d36c76d @nobu * common.mk (eval.o): needs vm.h.
nobu authored
288 #if defined(ENABLE_VM_OBJSPACE) && ENABLE_VM_OBJSPACE
289 struct rb_objspace;
290 void rb_objspace_free(struct rb_objspace *);
291 #endif
292
4a4a702 @ko1 * vm_trace.c, vm_core.h: simplify tracing mechanism.
ko1 authored
293 typedef struct rb_hook_list_struct {
294 struct rb_event_hook_struct *hooks;
295 rb_event_flag_t events;
296 int need_clean;
297 } rb_hook_list_t;
298
34d1e9b @ko1 * include/ruby/vm.h: write a comment.
ko1 authored
299 typedef struct rb_vm_struct {
a3e1b1c @ko1 * Merge YARV
ko1 authored
300 VALUE self;
301
450463d @ko1 * thread.c, vm_core.h: make gvl_acquire/release/init/destruct
ko1 authored
302 rb_global_vm_lock_t gvl;
a3e1b1c @ko1 * Merge YARV
ko1 authored
303
8ee7d07 @ko1 * blockinlining.c, compile.c, compile.h, error.c, eval.c,
ko1 authored
304 struct rb_thread_struct *main_thread;
305 struct rb_thread_struct *running_thread;
a3e1b1c @ko1 * Merge YARV
ko1 authored
306
307 st_table *living_threads;
308 VALUE thgroup_default;
309
59c0612 @ko1 * eval_method.c: renamed from vm_method.c. "vm_method.c" is included
ko1 authored
310 int running;
a119b9d @kosaki * vm_core.h (typedef struct rb_vm_struct): create a new
kosaki authored
311 int inhibit_thread_creation;
a3e1b1c @ko1 * Merge YARV
ko1 authored
312 int thread_abort_on_exception;
313 unsigned long trace_flag;
6f5aaff @mame * thread.c, vm_core.h, vm.c, thread_pthread.c, thread_win32.c: add
mame authored
314 volatile int sleeper;
a3e1b1c @ko1 * Merge YARV
ko1 authored
315
316 /* object management */
317 VALUE mark_object_ary;
318
9b45b33 @nobu * vm_core.h (rb_vm_t), vm.c (rb_vm_mark): moved preallocated special
nobu authored
319 VALUE special_exceptions[ruby_special_error_count];
320
9895ce9 @ko1 * eval_load.c, yarvcore.h: use rb_vm_t#loaded_features instead of
ko1 authored
321 /* load */
6b6bf4d @ko1 * blockinlining.c: remove "yarv" prefix.
ko1 authored
322 VALUE top_self;
01b773a @nobu * load.c (rb_load_path), vm_core.h (rb_vm_t): moved to VM.
nobu authored
323 VALUE load_path;
9895ce9 @ko1 * eval_load.c, yarvcore.h: use rb_vm_t#loaded_features instead of
ko1 authored
324 VALUE loaded_features;
1a89cc3 @nobu * configure.in, defines.h, eval_load.c (rb_feature_p, rb_provided,
nobu authored
325 struct st_table *loading_table;
9e8367a @nobu * vm_core.h: removed trailing garbage spaces.
nobu authored
326
9895ce9 @ko1 * eval_load.c, yarvcore.h: use rb_vm_t#loaded_features instead of
ko1 authored
327 /* signal */
c5bf9ce @nobu * vm_core.h (struct rb_vm_struct): replaced signal staff with trap
nobu authored
328 struct {
329 VALUE cmd;
330 int safe;
331 } trap_list[RUBY_NSIG];
a738943 @ko1 * eval.c, node.h, thread.c, yarvcore.[ch], eval_intern.h:
ko1 authored
332
333 /* hook */
4a4a702 @ko1 * vm_trace.c, vm_core.h: simplify tracing mechanism.
ko1 authored
334 rb_hook_list_t event_hooks;
09007cc @nobu * vm_core.h (rb_vm_t), gc.c (rb_objspace, rb_newobj), vm.c
nobu authored
335
9fb5215 @nobu * vm_core.h (struct rb_vm_struct): moved src_encoding_index.
nobu authored
336 int src_encoding_index;
337
6cdc893 @nobu * vm_core.h (struct rb_vm_struct): moved ruby_debug, ruby_verbose, and
nobu authored
338 VALUE verbose, debug, progname;
f08581c @mame * ext/coverage/coverage.c, ext/coverage/extconf.rb: eliminate
mame authored
339 VALUE coverages;
6cdc893 @nobu * vm_core.h (struct rb_vm_struct): moved ruby_debug, ruby_verbose, and
nobu authored
340
833cade @ko1 * vm_method.c (rb_unlink_method_entry, rb_sweep_method_entry):
ko1 authored
341 struct unlinked_method_entry_list_entry *unlinked_method_entry_list;
342
09007cc @nobu * vm_core.h (rb_vm_t), gc.c (rb_objspace, rb_newobj), vm.c
nobu authored
343 #if defined(ENABLE_VM_OBJSPACE) && ENABLE_VM_OBJSPACE
344 struct rb_objspace *objspace;
345 #endif
51da92e @shyouhei * vm.c (ruby_vm_at_exit): new API. This enables extension libs to
shyouhei authored
346
347 /*
348 * @shyouhei notes that this is not for storing normal Ruby
349 * objects so do *NOT* mark this when you GC.
350 */
351 struct RArray at_exit;
2314b80 @nobu Feature #7035
nobu authored
352
353 VALUE *defined_strings;
34d1e9b @ko1 * include/ruby/vm.h: write a comment.
ko1 authored
354 } rb_vm_t;
a3e1b1c @ko1 * Merge YARV
ko1 authored
355
d50483d @ko1 * vm_core.h: remove rb_control_frame_t::bp (bp: base pointer).
ko1 authored
356 #ifndef VM_DEBUG_BP_CHECK
64f5b6a @ko1 * vm_core.h: now VM_DEBUG_BP_CHECK should be 1.
ko1 authored
357 #define VM_DEBUG_BP_CHECK 1
d50483d @ko1 * vm_core.h: remove rb_control_frame_t::bp (bp: base pointer).
ko1 authored
358 #endif
359
a3e1b1c @ko1 * Merge YARV
ko1 authored
360 typedef struct {
205f310 @nobu * call_cfunc.ci, compile.c, compile.h, debug.h, eval.c,
nobu authored
361 VALUE *pc; /* cfp[0] */
362 VALUE *sp; /* cfp[1] */
d50483d @ko1 * vm_core.h: remove rb_control_frame_t::bp (bp: base pointer).
ko1 authored
363 rb_iseq_t *iseq; /* cfp[2] */
364 VALUE flag; /* cfp[3] */
365 VALUE self; /* cfp[4] / block[0] */
366 VALUE klass; /* cfp[5] / block[1] */
367 VALUE *ep; /* cfp[6] / block[2] */
368 rb_iseq_t *block_iseq; /* cfp[7] / block[3] */
369 VALUE proc; /* cfp[8] / block[4] */
370 const rb_method_entry_t *me;/* cfp[9] */
371
372 #if VM_DEBUG_BP_CHECK
373 VALUE *bp_check; /* cfp[10] */
374 #endif
8ee7d07 @ko1 * blockinlining.c, compile.c, compile.h, error.c, eval.c,
ko1 authored
375 } rb_control_frame_t;
a3e1b1c @ko1 * Merge YARV
ko1 authored
376
f2400ec @mame * include/ruby/ruby.h, vm_core.h: add a type rb_blockptr.
mame authored
377 typedef struct rb_block_struct {
a3e1b1c @ko1 * Merge YARV
ko1 authored
378 VALUE self; /* share with method frame if it's only block */
319088e @shugo * class.c, insns.def, method.h, proc.c, vm.c, vm_core.h, vm_eval.c,
shugo authored
379 VALUE klass; /* share with method frame if it's only block */
0a71db8 @ko1 * vm_core.h: remove lfp (local frame pointer) and rename
ko1 authored
380 VALUE *ep; /* share with method frame if it's only block */
8ee7d07 @ko1 * blockinlining.c, compile.c, compile.h, error.c, eval.c,
ko1 authored
381 rb_iseq_t *iseq;
a3e1b1c @ko1 * Merge YARV
ko1 authored
382 VALUE proc;
8ee7d07 @ko1 * blockinlining.c, compile.c, compile.h, error.c, eval.c,
ko1 authored
383 } rb_block_t;
a3e1b1c @ko1 * Merge YARV
ko1 authored
384
0dee724 @nobu * vm.c (ruby_threadptr_data_type): rename to hide.
nobu authored
385 extern const rb_data_type_t ruby_threadptr_data_type;
034540d @kosaki * vm_core.h (GetThreadPtr): use TypedData_Get_Struct() instead
kosaki authored
386
a3e1b1c @ko1 * Merge YARV
ko1 authored
387 #define GetThreadPtr(obj, ptr) \
0dee724 @nobu * vm.c (ruby_threadptr_data_type): rename to hide.
nobu authored
388 TypedData_Get_Struct((obj), rb_thread_t, &ruby_threadptr_data_type, (ptr))
a3e1b1c @ko1 * Merge YARV
ko1 authored
389
8ee7d07 @ko1 * blockinlining.c, compile.c, compile.h, error.c, eval.c,
ko1 authored
390 enum rb_thread_status {
a3e1b1c @ko1 * Merge YARV
ko1 authored
391 THREAD_TO_KILL,
392 THREAD_RUNNABLE,
393 THREAD_STOPPED,
6f5aaff @mame * thread.c, vm_core.h, vm.c, thread_pthread.c, thread_win32.c: add
mame authored
394 THREAD_STOPPED_FOREVER,
3e69e83 @shyouhei * include/ruby/ruby.h (enum ruby_special_consts): ISO C forbids
shyouhei authored
395 THREAD_KILLED
a3e1b1c @ko1 * Merge YARV
ko1 authored
396 };
397
b39676f @nobu * configure.in (RUBY_SETJMP, RUBY_LONGJMP, RUBY_JMP_BUF): prefers
nobu authored
398 typedef RUBY_JMP_BUF rb_jmpbuf_t;
a3e1b1c @ko1 * Merge YARV
ko1 authored
399
8ee7d07 @ko1 * blockinlining.c, compile.c, compile.h, error.c, eval.c,
ko1 authored
400 struct rb_vm_tag {
a3e1b1c @ko1 * Merge YARV
ko1 authored
401 rb_jmpbuf_t buf;
402 VALUE tag;
403 VALUE retval;
8ee7d07 @ko1 * blockinlining.c, compile.c, compile.h, error.c, eval.c,
ko1 authored
404 struct rb_vm_tag *prev;
a3e1b1c @ko1 * Merge YARV
ko1 authored
405 };
406
f53d825 @mame * cont.c, vm_core.h, eval.c: because rb_protect must not be jumped by
mame authored
407 struct rb_vm_protect_tag {
408 struct rb_vm_protect_tag *prev;
409 };
410
1b63d7b @nobu * vm_core.h (struct rb_unblock_callback), thread.c
nobu authored
411 struct rb_unblock_callback {
412 rb_unblock_function_t *func;
413 void *arg;
414 };
415
d76ab40 @mame * vm_core.h, thread.c: It is now prohibited to use Data_Get_Struct in
mame authored
416 struct rb_mutex_struct;
417
ac397a9 @kosaki * vm_core.h (ALT_STACK_SIZE): use MINSIGSTKSZ*2 instead of SIGSTKSZ*2.
kosaki authored
418 #ifdef MINSIGSTKSZ
419 #define ALT_STACK_SIZE (MINSIGSTKSZ*2)
18bc6c3 @kosaki * vm.c (th_init): preallocate alternative stack.
kosaki authored
420 #else
421 #define ALT_STACK_SIZE (4*1024)
422 #endif
423
b76fd82 @ko1 * vm_core.h: some refactoring.
ko1 authored
424 typedef struct rb_thread_struct {
a3e1b1c @ko1 * Merge YARV
ko1 authored
425 VALUE self;
8ee7d07 @ko1 * blockinlining.c, compile.c, compile.h, error.c, eval.c,
ko1 authored
426 rb_vm_t *vm;
a3e1b1c @ko1 * Merge YARV
ko1 authored
427
428 /* execution information */
429 VALUE *stack; /* must free, must mark */
430 unsigned long stack_size;
8ee7d07 @ko1 * blockinlining.c, compile.c, compile.h, error.c, eval.c,
ko1 authored
431 rb_control_frame_t *cfp;
a3e1b1c @ko1 * Merge YARV
ko1 authored
432 int safe_level;
433 int raised_flag;
1a5f1a8 @nobu * vm_core.h (rb_thread_t), vm.c (rb_thread_mark), process.c
nobu authored
434 VALUE last_status; /* $? */
9e8367a @nobu * vm_core.h: removed trailing garbage spaces.
nobu authored
435
a3e1b1c @ko1 * Merge YARV
ko1 authored
436 /* passing state */
437 int state;
6978b8c @ko1 * vm_core.h (rb_thread_t#yielding): add a field.
ko1 authored
438 int yielding;
a3e1b1c @ko1 * Merge YARV
ko1 authored
439
58b3253 @nobu * thread.c (rb_thread_io_blocking_region): new function to run
nobu authored
440 int waiting_fd;
441
a3e1b1c @ko1 * Merge YARV
ko1 authored
442 /* for rb_iterate */
c330876 @ko1 * method.h, vm_core.h: add rb_method_entry_t. Remove nodes around
ko1 authored
443 const rb_block_t *passed_block;
a3e1b1c @ko1 * Merge YARV
ko1 authored
444
833cade @ko1 * vm_method.c (rb_unlink_method_entry, rb_sweep_method_entry):
ko1 authored
445 /* for bmethod */
446 const rb_method_entry_t *passed_me;
447
9987d53 @ko1 * yarvcore.h: add rb_thread_t#top_wrapper, top_self.
ko1 authored
448 /* for load(true) */
449 VALUE top_self;
450 VALUE top_wrapper;
451
a3e1b1c @ko1 * Merge YARV
ko1 authored
452 /* eval env */
8ee7d07 @ko1 * blockinlining.c, compile.c, compile.h, error.c, eval.c,
ko1 authored
453 rb_block_t *base_block;
a3e1b1c @ko1 * Merge YARV
ko1 authored
454
0a71db8 @ko1 * vm_core.h: remove lfp (local frame pointer) and rename
ko1 authored
455 VALUE *root_lep;
456 VALUE root_svar;
a3e1b1c @ko1 * Merge YARV
ko1 authored
457
458 /* thread control */
8ee7d07 @ko1 * blockinlining.c, compile.c, compile.h, error.c, eval.c,
ko1 authored
459 rb_thread_id_t thread_id;
460 enum rb_thread_status status;
a3e1b1c @ko1 * Merge YARV
ko1 authored
461 int priority;
462
463 native_thread_data_t native_thread_data;
9c04a06 @ko1 * thread.c (rb_thread_blocking_region): add a comment.
ko1 authored
464 void *blocking_region_buffer;
a3e1b1c @ko1 * Merge YARV
ko1 authored
465
466 VALUE thgroup;
467 VALUE value;
468
2814443 @ko1 * thread.c (rb_threadptr_async_errinfo_*): manage async errors queue.
ko1 authored
469 /* temporary place of errinfo */
a3e1b1c @ko1 * Merge YARV
ko1 authored
470 VALUE errinfo;
2814443 @ko1 * thread.c (rb_threadptr_async_errinfo_*): manage async errors queue.
ko1 authored
471
0d1a905 @ko1 * vm_exec.c, insns.def (leave): solve problems on
ko1 authored
472 /* temporary place of retval on OPT_CALL_THREADED_CODE */
473 #if OPT_CALL_THREADED_CODE
474 VALUE retval;
475 #endif
476
2814443 @ko1 * thread.c (rb_threadptr_async_errinfo_*): manage async errors queue.
ko1 authored
477 /* async errinfo queue */
478 VALUE async_errinfo_queue;
479 int async_errinfo_queue_checked;
480 VALUE async_errinfo_mask_stack;
a3e1b1c @ko1 * Merge YARV
ko1 authored
481
9d4e471 @kosaki * vm_core.h (RUBY_VM_SET_TIMER_INTERRUPT, RUBY_VM_SET_INTERRUPT,
kosaki authored
482 rb_atomic_t interrupt_flag;
8ee7d07 @ko1 * blockinlining.c, compile.c, compile.h, error.c, eval.c,
ko1 authored
483 rb_thread_lock_t interrupt_lock;
1b63d7b @nobu * vm_core.h (struct rb_unblock_callback), thread.c
nobu authored
484 struct rb_unblock_callback unblock;
6f5aaff @mame * thread.c, vm_core.h, vm.c, thread_pthread.c, thread_win32.c: add
mame authored
485 VALUE locking_mutex;
d76ab40 @mame * vm_core.h, thread.c: It is now prohibited to use Data_Get_Struct in
mame authored
486 struct rb_mutex_struct *keeping_mutexes;
a3e1b1c @ko1 * Merge YARV
ko1 authored
487
8ee7d07 @ko1 * blockinlining.c, compile.c, compile.h, error.c, eval.c,
ko1 authored
488 struct rb_vm_tag *tag;
f53d825 @mame * cont.c, vm_core.h, eval.c: because rb_protect must not be jumped by
mame authored
489 struct rb_vm_protect_tag *protect_tag;
a3e1b1c @ko1 * Merge YARV
ko1 authored
490
f8601bd @yugui * eval.c: Add doxygen comments.
yugui authored
491 /*! Thread-local state of evaluation context.
0732977 @nobu fix r36079
nobu authored
492 *
f8601bd @yugui * eval.c: Add doxygen comments.
yugui authored
493 * If negative, this thread is evaluating the main program.
494 * If positive, this thread is evaluating a program under Kernel::eval
495 * family.
496 */
a3e1b1c @ko1 * Merge YARV
ko1 authored
497 int parse_in_eval;
f8601bd @yugui * eval.c: Add doxygen comments.
yugui authored
498
499 /*! Thread-local state of compiling context.
500 *
501 * If non-zero, the parser does not automatically print error messages to
502 * stderr. */
5874de9 @mame * Add coverage measurement constant COVERAGE__. This constant is not
mame authored
503 int mild_compile_error;
a3e1b1c @ko1 * Merge YARV
ko1 authored
504
505 /* storage */
506 st_table *local_storage;
507
8ee7d07 @ko1 * blockinlining.c, compile.c, compile.h, error.c, eval.c,
ko1 authored
508 struct rb_thread_struct *join_list_next;
509 struct rb_thread_struct *join_list_head;
a3e1b1c @ko1 * Merge YARV
ko1 authored
510
511 VALUE first_proc;
512 VALUE first_args;
025cfde @ko1 * eval_thread.c, common.mk: remove eval_thread.c.
ko1 authored
513 VALUE (*first_func)(ANYARGS);
a3e1b1c @ko1 * Merge YARV
ko1 authored
514
515 /* for GC */
516 VALUE *machine_stack_start;
517 VALUE *machine_stack_end;
4f13113 @akr * vm_core.h (rb_thread_t): new member machine_stack_maxsize and
akr authored
518 size_t machine_stack_maxsize;
3cd5af5 @akr * eval_load.c (Init_load): delay allocating an array for rb_load_path
akr authored
519 #ifdef __ia64
520 VALUE *machine_register_stack_start;
521 VALUE *machine_register_stack_end;
4f13113 @akr * vm_core.h (rb_thread_t): new member machine_stack_maxsize and
akr authored
522 size_t machine_register_stack_maxsize;
3cd5af5 @akr * eval_load.c (Init_load): delay allocating an array for rb_load_path
akr authored
523 #endif
a3e1b1c @ko1 * Merge YARV
ko1 authored
524 jmp_buf machine_regs;
fba2420 @ko1 * vm.c, yarvcore.h, yarvcore.c, insns.def: fix to mark VM stack
ko1 authored
525 int mark_stack_len;
a3e1b1c @ko1 * Merge YARV
ko1 authored
526
527 /* statistics data for profiler */
528 VALUE stat_insn_usage;
529
a738943 @ko1 * eval.c, node.h, thread.c, yarvcore.[ch], eval_intern.h:
ko1 authored
530 /* tracer */
4a4a702 @ko1 * vm_trace.c, vm_core.h: simplify tracing mechanism.
ko1 authored
531 rb_hook_list_t event_hooks;
532 int trace_running;
a738943 @ko1 * eval.c, node.h, thread.c, yarvcore.[ch], eval_intern.h:
ko1 authored
533
57062d9 @ko1 * cont.c: support Fiber. Check test/ruby/test_fiber.rb for detail.
ko1 authored
534 /* fiber */
535 VALUE fiber;
536 VALUE root_fiber;
537 rb_jmpbuf_t root_jmpbuf;
538
a3e1b1c @ko1 * Merge YARV
ko1 authored
539 /* misc */
540 int method_missing_reason;
541 int abort_on_exception;
5058731 @mame * vm_core.c (rb_thread_struct): add a field for sigaltstack.
mame authored
542 #ifdef USE_SIGALTSTACK
543 void *altstack;
544 #endif
bcfc22b @kosaki * thread_pthread.c: rewrite GVL completely.
kosaki authored
545 unsigned long running_time_us;
8cd252a @ko1 * common.mk: clean up
ko1 authored
546 } rb_thread_t;
a3e1b1c @ko1 * Merge YARV
ko1 authored
547
6b6bf4d @ko1 * blockinlining.c: remove "yarv" prefix.
ko1 authored
548 /* iseq.c */
097d58a @nobu * load.c (ruby_init_ext): export for golfers.
nobu authored
549 #if defined __GNUC__ && __GNUC__ >= 4
550 #pragma GCC visibility push(default)
551 #endif
c4bc9b5 @ko1 * iseq.c, vm_eval.c: set th->base_block properly.
ko1 authored
552
553 /* node -> iseq */
f600389 @nobu * compile.c (new_child_iseq): adjust argument types.
nobu authored
554 VALUE rb_iseq_new(NODE*, VALUE, VALUE, VALUE, VALUE, enum iseq_type);
bac9f65 @ko1 * vm_core.h (rb_location_t): fix type and field name.
ko1 authored
555 VALUE rb_iseq_new_top(NODE *node, VALUE name, VALUE path, VALUE absolute_path, VALUE parent);
556 VALUE rb_iseq_new_main(NODE *node, VALUE path, VALUE absolute_path);
f600389 @nobu * compile.c (new_child_iseq): adjust argument types.
nobu authored
557 VALUE rb_iseq_new_with_bopt(NODE*, VALUE, VALUE, VALUE, VALUE, VALUE, enum iseq_type, VALUE);
558 VALUE rb_iseq_new_with_opt(NODE*, VALUE, VALUE, VALUE, VALUE, VALUE, enum iseq_type, const rb_compile_option_t*);
c4bc9b5 @ko1 * iseq.c, vm_eval.c: set th->base_block properly.
ko1 authored
559
560 /* src -> iseq */
6b6bf4d @ko1 * blockinlining.c: remove "yarv" prefix.
ko1 authored
561 VALUE rb_iseq_compile(VALUE src, VALUE file, VALUE line);
c4bc9b5 @ko1 * iseq.c, vm_eval.c: set th->base_block properly.
ko1 authored
562 VALUE rb_iseq_compile_on_base(VALUE src, VALUE file, VALUE line, rb_block_t *base_block);
563 VALUE rb_iseq_compile_with_option(VALUE src, VALUE file, VALUE absolute_path, VALUE line, rb_block_t *base_block, VALUE opt);
564
c4c3f23 @ko1 * iseq.c:
ko1 authored
565 VALUE rb_iseq_disasm(VALUE self);
fe1ce93 @nobu * compile.c, cont.c, gc.c, insns.def, iseq.c, iseq.h, process.c,
nobu authored
566 int rb_iseq_disasm_insn(VALUE str, VALUE *iseqval, size_t pos, rb_iseq_t *iseq, VALUE child);
46603a7 @nobu * include/ruby/{intern,ruby}.h, compile.[ch], error.c, eval.c,
nobu authored
567 const char *ruby_node_name(int node);
e2ca783 @nobu * iseq.c (rb_iseq_first_lineno): constified.
nobu authored
568 int rb_iseq_first_lineno(const rb_iseq_t *iseq);
a3e1b1c @ko1 * Merge YARV
ko1 authored
569
9ebf647 @ko1 * vm.c, vm_core.h,vm_core.h, vm_dump.c, iseq.c: rename class name
ko1 authored
570 RUBY_EXTERN VALUE rb_cISeq;
571 RUBY_EXTERN VALUE rb_cRubyVM;
572 RUBY_EXTERN VALUE rb_cEnv;
eb33f91 @ko1 * compile.c, insns.def, vm.c, vm_core.h: remove some insns
ko1 authored
573 RUBY_EXTERN VALUE rb_mRubyVMFrozenCore;
097d58a @nobu * load.c (ruby_init_ext): export for golfers.
nobu authored
574 #if defined __GNUC__ && __GNUC__ >= 4
575 #pragma GCC visibility pop
576 #endif
a3e1b1c @ko1 * Merge YARV
ko1 authored
577
6b6bf4d @ko1 * blockinlining.c: remove "yarv" prefix.
ko1 authored
578 /* each thread has this size stack : 128KB */
8ee7d07 @ko1 * blockinlining.c, compile.c, compile.h, error.c, eval.c,
ko1 authored
579 #define RUBY_VM_THREAD_STACK_SIZE (128 * 1024)
a3e1b1c @ko1 * Merge YARV
ko1 authored
580
581 #define GetProcPtr(obj, ptr) \
741e778 @akr * vm_core.h: parenthesize macro arguments.
akr authored
582 GetCoreDataFromValue((obj), rb_proc_t, (ptr))
a3e1b1c @ko1 * Merge YARV
ko1 authored
583
584 typedef struct {
8ee7d07 @ko1 * blockinlining.c, compile.c, compile.h, error.c, eval.c,
ko1 authored
585 rb_block_t block;
a3e1b1c @ko1 * Merge YARV
ko1 authored
586
587 VALUE envval; /* for GC mark */
588 VALUE blockprocval;
589 int safe_level;
cd30220 @ko1 * insnhelper.ci (vm_call_bmethod): fix to propagate information
ko1 authored
590 int is_from_method;
a3e1b1c @ko1 * Merge YARV
ko1 authored
591 int is_lambda;
8ee7d07 @ko1 * blockinlining.c, compile.c, compile.h, error.c, eval.c,
ko1 authored
592 } rb_proc_t;
a3e1b1c @ko1 * Merge YARV
ko1 authored
593
594 #define GetEnvPtr(obj, ptr) \
741e778 @akr * vm_core.h: parenthesize macro arguments.
akr authored
595 GetCoreDataFromValue((obj), rb_env_t, (ptr))
a3e1b1c @ko1 * Merge YARV
ko1 authored
596
597 typedef struct {
598 VALUE *env;
599 int env_size;
600 int local_size;
601 VALUE prev_envval; /* for GC mark */
8ee7d07 @ko1 * blockinlining.c, compile.c, compile.h, error.c, eval.c,
ko1 authored
602 rb_block_t block;
603 } rb_env_t;
a3e1b1c @ko1 * Merge YARV
ko1 authored
604
605 #define GetBindingPtr(obj, ptr) \
741e778 @akr * vm_core.h: parenthesize macro arguments.
akr authored
606 GetCoreDataFromValue((obj), rb_binding_t, (ptr))
a3e1b1c @ko1 * Merge YARV
ko1 authored
607
608 typedef struct {
609 VALUE env;
bac9f65 @ko1 * vm_core.h (rb_location_t): fix type and field name.
ko1 authored
610 VALUE path;
611 unsigned short first_lineno;
8ee7d07 @ko1 * blockinlining.c, compile.c, compile.h, error.c, eval.c,
ko1 authored
612 } rb_binding_t;
a3e1b1c @ko1 * Merge YARV
ko1 authored
613
614 /* used by compile time and send insn */
93b6f8d @ko1 * compile.c, insns.def (checkmatch):
ko1 authored
615
616 enum vm_check_match_type {
617 VM_CHECKMATCH_TYPE_WHEN = 1,
618 VM_CHECKMATCH_TYPE_CASE = 2,
619 VM_CHECKMATCH_TYPE_RESCUE = 3
620 };
621
622 #define VM_CHECKMATCH_TYPE_MASK 0x03
623 #define VM_CHECKMATCH_ARRAY 0x04
624
ce55b4c @ko1 * insns.def : support direct method dispatch with "send" or "funcall".
ko1 authored
625 #define VM_CALL_ARGS_SPLAT_BIT (0x01 << 1)
626 #define VM_CALL_ARGS_BLOCKARG_BIT (0x01 << 2)
627 #define VM_CALL_FCALL_BIT (0x01 << 3)
628 #define VM_CALL_VCALL_BIT (0x01 << 4)
629 #define VM_CALL_TAILCALL_BIT (0x01 << 5)
630 #define VM_CALL_TAILRECURSION_BIT (0x01 << 6)
631 #define VM_CALL_SUPER_BIT (0x01 << 7)
07de51f @ko1 * vm_core.h, vm_insnhelper.c (vm_call_method): revive
ko1 authored
632 #define VM_CALL_OPT_SEND_BIT (0x01 << 8)
a3e1b1c @ko1 * Merge YARV
ko1 authored
633
b76fd82 @ko1 * vm_core.h: some refactoring.
ko1 authored
634 enum vm_special_object_type {
635 VM_SPECIAL_OBJECT_VMCORE = 1,
636 VM_SPECIAL_OBJECT_CBASE,
fe1f0df @znz remove a comma at end of enumerator list.
znz authored
637 VM_SPECIAL_OBJECT_CONST_BASE
b76fd82 @ko1 * vm_core.h: some refactoring.
ko1 authored
638 };
eb33f91 @ko1 * compile.c, insns.def, vm.c, vm_core.h: remove some insns
ko1 authored
639
9e324fd @ko1 * vm.c, eval_intern.h (PASS_PASSED_BLOCK):
ko1 authored
640 #define VM_FRAME_MAGIC_METHOD 0x11
641 #define VM_FRAME_MAGIC_BLOCK 0x21
642 #define VM_FRAME_MAGIC_CLASS 0x31
643 #define VM_FRAME_MAGIC_TOP 0x41
644 #define VM_FRAME_MAGIC_CFUNC 0x61
645 #define VM_FRAME_MAGIC_PROC 0x71
646 #define VM_FRAME_MAGIC_IFUNC 0x81
647 #define VM_FRAME_MAGIC_EVAL 0x91
648 #define VM_FRAME_MAGIC_LAMBDA 0xa1
649 #define VM_FRAME_MAGIC_MASK_BITS 8
650 #define VM_FRAME_MAGIC_MASK (~(~0<<VM_FRAME_MAGIC_MASK_BITS))
651
652 #define VM_FRAME_TYPE(cfp) ((cfp)->flag & VM_FRAME_MAGIC_MASK)
653
654 /* other frame flag */
655 #define VM_FRAME_FLAG_PASSED 0x0100
745c23b @ko1 * vm_core.h: remove VM_FRAME_MAGIC_FINISH (finish frame type).
ko1 authored
656 #define VM_FRAME_FLAG_FINISH 0x0200
68f3ece @nobu suppress warnings
nobu authored
657 #define VM_FRAME_TYPE_FINISH_P(cfp) (((cfp)->flag & VM_FRAME_FLAG_FINISH) != 0)
9e324fd @ko1 * vm.c, eval_intern.h (PASS_PASSED_BLOCK):
ko1 authored
658
659 #define RUBYVM_CFUNC_FRAME_P(cfp) \
660 (VM_FRAME_TYPE(cfp) == VM_FRAME_MAGIC_CFUNC)
661
20d9aef @ko1 * vm_core.h, compile.c: declare struct iseq_inline_cache_entry.
ko1 authored
662 /* inline cache */
663 typedef struct iseq_inline_cache_entry *IC;
a3e1b1c @ko1 * Merge YARV
ko1 authored
664
33163ad * regparse.c, etc.: K&R to ANSI code cleanup patch from Stefan
matz authored
665 void rb_vm_change_state(void);
44aef0b @ko1 * this commit is a result of refactoring. only renaming functions,
ko1 authored
666
a3e1b1c @ko1 * Merge YARV
ko1 authored
667 typedef VALUE CDHASH;
668
27013e7 @ko1 * yarvcore.h, compile.c, insnhelper.ci, iseq.c, vm.c:
ko1 authored
669 #ifndef FUNC_FASTCALL
670 #define FUNC_FASTCALL(x) x
671 #endif
a3e1b1c @ko1 * Merge YARV
ko1 authored
672
27013e7 @ko1 * yarvcore.h, compile.c, insnhelper.ci, iseq.c, vm.c:
ko1 authored
673 typedef rb_control_frame_t *
674 (FUNC_FASTCALL(*rb_insn_func_t))(rb_thread_t *, rb_control_frame_t *);
44aef0b @ko1 * this commit is a result of refactoring. only renaming functions,
ko1 authored
675
a3e1b1c @ko1 * Merge YARV
ko1 authored
676 #define GC_GUARDED_PTR(p) ((VALUE)((VALUE)(p) | 0x01))
741e778 @akr * vm_core.h: parenthesize macro arguments.
akr authored
677 #define GC_GUARDED_PTR_REF(p) ((void *)(((VALUE)(p)) & ~0x03))
678 #define GC_GUARDED_PTR_P(p) (((VALUE)(p)) & 0x01)
a3e1b1c @ko1 * Merge YARV
ko1 authored
679
0a71db8 @ko1 * vm_core.h: remove lfp (local frame pointer) and rename
ko1 authored
680 /*
681 * block frame:
682 * ep[ 0]: prev frame
683 * ep[-1]: CREF (for *_eval)
684 *
685 * method frame:
686 * ep[ 0]: block pointer (ptr | VM_ENVVAL_BLOCK_PTR_FLAG)
687 */
688
689 #define VM_ENVVAL_BLOCK_PTR_FLAG 0x02
690 #define VM_ENVVAL_BLOCK_PTR(v) (GC_GUARDED_PTR(v) | VM_ENVVAL_BLOCK_PTR_FLAG)
691 #define VM_ENVVAL_BLOCK_PTR_P(v) ((v) & VM_ENVVAL_BLOCK_PTR_FLAG)
692 #define VM_ENVVAL_PREV_EP_PTR(v) ((VALUE)GC_GUARDED_PTR(v))
693 #define VM_ENVVAL_PREV_EP_PTR_P(v) (!(VM_ENVVAL_BLOCK_PTR_P(v)))
694
695 #define VM_EP_PREV_EP(ep) ((VALUE *)GC_GUARDED_PTR_REF((ep)[0]))
696 #define VM_EP_BLOCK_PTR(ep) ((rb_block_t *)GC_GUARDED_PTR_REF((ep)[0]))
697 #define VM_EP_LEP_P(ep) VM_ENVVAL_BLOCK_PTR_P((ep)[0])
698
699 VALUE *rb_vm_ep_local_ep(VALUE *ep);
700 rb_block_t *rb_vm_control_frame_block_ptr(rb_control_frame_t *cfp);
06513cc @ko1 * vm_insnhelper.h: remove magical code "lfp[0] & 0x02".
ko1 authored
701
741e778 @akr * vm_core.h: parenthesize macro arguments.
akr authored
702 #define RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp) ((cfp)+1)
703 #define RUBY_VM_NEXT_CONTROL_FRAME(cfp) ((cfp)-1)
8ee7d07 @ko1 * blockinlining.c, compile.c, compile.h, error.c, eval.c,
ko1 authored
704 #define RUBY_VM_END_CONTROL_FRAME(th) \
705 ((rb_control_frame_t *)((th)->stack + (th)->stack_size))
706 #define RUBY_VM_VALID_CONTROL_FRAME_P(cfp, ecfp) \
a3e1b1c @ko1 * Merge YARV
ko1 authored
707 ((void *)(ecfp) > (void *)(cfp))
8ee7d07 @ko1 * blockinlining.c, compile.c, compile.h, error.c, eval.c,
ko1 authored
708 #define RUBY_VM_CONTROL_FRAME_STACK_OVERFLOW_P(th, cfp) \
709 (!RUBY_VM_VALID_CONTROL_FRAME_P((cfp), RUBY_VM_END_CONTROL_FRAME(th)))
a3e1b1c @ko1 * Merge YARV
ko1 authored
710
8ee7d07 @ko1 * blockinlining.c, compile.c, compile.h, error.c, eval.c,
ko1 authored
711 #define RUBY_VM_IFUNC_P(ptr) (BUILTIN_TYPE(ptr) == T_NODE)
712 #define RUBY_VM_NORMAL_ISEQ_P(ptr) \
741e778 @akr * vm_core.h: parenthesize macro arguments.
akr authored
713 ((ptr) && !RUBY_VM_IFUNC_P(ptr))
a3e1b1c @ko1 * Merge YARV
ko1 authored
714
8ee7d07 @ko1 * blockinlining.c, compile.c, compile.h, error.c, eval.c,
ko1 authored
715 #define RUBY_VM_GET_BLOCK_PTR_IN_CFP(cfp) ((rb_block_t *)(&(cfp)->self))
716 #define RUBY_VM_GET_CFP_FROM_BLOCK_PTR(b) \
d50483d @ko1 * vm_core.h: remove rb_control_frame_t::bp (bp: base pointer).
ko1 authored
717 ((rb_control_frame_t *)((VALUE *)(b) - 4))
718 /* magic number `4' is depend on rb_control_frame_t layout. */
a3e1b1c @ko1 * Merge YARV
ko1 authored
719
720 /* VM related object allocate functions */
a45cd8a @ko1 * eval.c, eval_intern.h, include/ruby/intern.h, include/ruby/ruby.h,
ko1 authored
721 VALUE rb_thread_alloc(VALUE klass);
6b6bf4d @ko1 * blockinlining.c: remove "yarv" prefix.
ko1 authored
722 VALUE rb_proc_alloc(VALUE klass);
a3e1b1c @ko1 * Merge YARV
ko1 authored
723
724 /* for debug */
651f0e4 @ko1 * vm_dump.c: add a prefix "rb_vmdebug_" to
ko1 authored
725 extern void rb_vmdebug_stack_dump_raw(rb_thread_t *, rb_control_frame_t *);
0a71db8 @ko1 * vm_core.h: remove lfp (local frame pointer) and rename
ko1 authored
726 extern void rb_vmdebug_debug_print_pre(rb_thread_t *th, rb_control_frame_t *cfp);
727 extern void rb_vmdebug_debug_print_post(rb_thread_t *th, rb_control_frame_t *cfp);
728
651f0e4 @ko1 * vm_dump.c: add a prefix "rb_vmdebug_" to
ko1 authored
729 #define SDR() rb_vmdebug_stack_dump_raw(GET_THREAD(), GET_THREAD()->cfp)
730 #define SDR2(cfp) rb_vmdebug_stack_dump_raw(GET_THREAD(), (cfp))
6b6bf4d @ko1 * blockinlining.c: remove "yarv" prefix.
ko1 authored
731 void rb_vm_bugreport(void);
44aef0b @ko1 * this commit is a result of refactoring. only renaming functions,
ko1 authored
732
733 /* functions about thread/vm execution */
097d58a @nobu * load.c (ruby_init_ext): export for golfers.
nobu authored
734 #if defined __GNUC__ && __GNUC__ >= 4
735 #pragma GCC visibility push(default)
736 #endif
a45cd8a @ko1 * eval.c, eval_intern.h, include/ruby/intern.h, include/ruby/ruby.h,
ko1 authored
737 VALUE rb_iseq_eval(VALUE iseqval);
597220e @ko1 * vm.c (Init_VM): create and define TOPLEVEL_BINDING at first.
ko1 authored
738 VALUE rb_iseq_eval_main(VALUE iseqval);
097d58a @nobu * load.c (ruby_init_ext): export for golfers.
nobu authored
739 #if defined __GNUC__ && __GNUC__ >= 4
740 #pragma GCC visibility pop
741 #endif
a45cd8a @ko1 * eval.c, eval_intern.h, include/ruby/intern.h, include/ruby/ruby.h,
ko1 authored
742 int rb_thread_method_id_and_class(rb_thread_t *th, ID *idp, VALUE *klassp);
743
ceece46 @nobu vm_insnhelper.c: iclass as klass in cfp
nobu authored
744 VALUE rb_vm_invoke_proc(rb_thread_t *th, rb_proc_t *proc,
c330876 @ko1 * method.h, vm_core.h: add rb_method_entry_t. Remove nodes around
ko1 authored
745 int argc, const VALUE *argv, const rb_block_t *blockptr);
cf23d0f @ko1 * vm.c: add a prefix "rb_" to exposed functions
ko1 authored
746 VALUE rb_vm_make_proc(rb_thread_t *th, const rb_block_t *block, VALUE klass);
747 VALUE rb_vm_make_env_object(rb_thread_t *th, rb_control_frame_t *cfp);
0a71db8 @ko1 * vm_core.h: remove lfp (local frame pointer) and rename
ko1 authored
748 void rb_vm_rewrite_ep_in_errinfo(rb_thread_t *th, rb_control_frame_t *cfp);
0987b3c @nobu * vm_core.h (rb_vm_inc_const_missing_count): missing prototype.
nobu authored
749 void rb_vm_inc_const_missing_count(void);
925da00 @nobu * thread_pthread.c (gvl_release, gvl_init): suppress warnings.
nobu authored
750 void rb_vm_gvl_destroy(rb_vm_t *vm);
5ed8c08 @akr * eval.c, hash.c, load.c, proc.c, range.c, thread.c, time.c: don't
akr authored
751 VALUE rb_vm_call(rb_thread_t *th, VALUE recv, VALUE id, int argc,
319088e @shugo * class.c, insns.def, method.h, proc.c, vm.c, vm_core.h, vm_eval.c,
shugo authored
752 const VALUE *argv, const rb_method_entry_t *me,
753 VALUE defined_class);
9a27239 @mame * proc.c (struct METHOD), gc.c (gc_marks), vm_method.c
mame authored
754 void rb_unlink_method_entry(rb_method_entry_t *me);
755 void rb_gc_mark_unlinked_live_method_entries(void *pvm);
44aef0b @ko1 * this commit is a result of refactoring. only renaming functions,
ko1 authored
756
046a581 @nobu * vm_core.h: add missing prototypes.
nobu authored
757 void rb_thread_start_timer_thread(void);
d1d5d5e @ko1 * thread_pthread.c: Stop polling in the timer thread when there are
ko1 authored
758 void rb_thread_stop_timer_thread(int);
046a581 @nobu * vm_core.h: add missing prototypes.
nobu authored
759 void rb_thread_reset_timer_thread(void);
d1d5d5e @ko1 * thread_pthread.c: Stop polling in the timer thread when there are
ko1 authored
760 void rb_thread_wakeup_timer_thread(void);
761
6f09fc2 @ko1 * thread.c: fix comment (terminology: Global VM Lock).
ko1 authored
762 int ruby_thread_has_gvl_p(void);
cd48eb8 @nobu * vm.c (vm_backtrace_each, vm_backtrace_push),
nobu authored
763 typedef int rb_backtrace_iter_func(void *, VALUE, int, VALUE);
0cb68b6 @ko1 * vm_eval.c (eval_string_with_cref): use rb_vm_get_ruby_level_next_cfp()
ko1 authored
764 rb_control_frame_t *rb_vm_get_ruby_level_next_cfp(rb_thread_t *th, rb_control_frame_t *cfp);
04daf20 @nobu * vm_core.h (rb_vm_get_sourceline): moved from eval_intern.h for
nobu authored
765 int rb_vm_get_sourceline(const rb_control_frame_t *);
0d9386d @nobu * vm_core.h (rb_name_err_mesg_new): added prototype.
nobu authored
766 VALUE rb_name_err_mesg_new(VALUE obj, VALUE mesg, VALUE recv, VALUE method);
ef86308 @kosaki * vm.c, vm_core.h (rb_vm_stack_to_heap): remove const.
kosaki authored
767 void rb_vm_stack_to_heap(rb_thread_t *th);
e7996eb @akr * internal.h: declare internal functions here.
akr authored
768 void ruby_thread_init_stack(rb_thread_t *th);
6f09fc2 @ko1 * thread.c: fix comment (terminology: Global VM Lock).
ko1 authored
769
3453b2b @ko1 * gc.h, vm_core.h: decl of rb_gc_save_machine_context()
ko1 authored
770 NOINLINE(void rb_gc_save_machine_context(rb_thread_t *));
e7996eb @akr * internal.h: declare internal functions here.
akr authored
771 void rb_gc_mark_machine_stack(rb_thread_t *th);
3453b2b @ko1 * gc.h, vm_core.h: decl of rb_gc_save_machine_context()
ko1 authored
772
5d486be @ko1 * vm_core.h: add a decl. of rb_autoloading_value().
ko1 authored
773 int rb_autoloading_value(VALUE mod, ID id, VALUE* value);
774
9b45b33 @nobu * vm_core.h (rb_vm_t), vm.c (rb_vm_mark): moved preallocated special
nobu authored
775 #define sysstack_error GET_VM()->special_exceptions[ruby_error_sysstack]
9c708ba @ko1 * eval_intern.h, yarvcore.h: move declaration of sysstack_error
ko1 authored
776
a3e1b1c @ko1 * Merge YARV
ko1 authored
777 /* for thread */
778
44aef0b @ko1 * this commit is a result of refactoring. only renaming functions,
ko1 authored
779 #if RUBY_VM_THREAD_MODEL == 2
eb21db7 @nobu * vm_core.h (ruby_current_thread): probeprofiler has been removed
nobu authored
780 extern rb_thread_t *ruby_current_thread;
8a1b1c2 @ko1 * yarvcore.h, vm.h: rename th_invoke_yield() to th_yield().
ko1 authored
781 extern rb_vm_t *ruby_current_vm;
4a4a702 @ko1 * vm_trace.c, vm_core.h: simplify tracing mechanism.
ko1 authored
782 extern rb_event_flag_t ruby_vm_event_flags;
44aef0b @ko1 * this commit is a result of refactoring. only renaming functions,
ko1 authored
783
8a1b1c2 @ko1 * yarvcore.h, vm.h: rename th_invoke_yield() to th_yield().
ko1 authored
784 #define GET_VM() ruby_current_vm
785 #define GET_THREAD() ruby_current_thread
c5bf9ce @nobu * vm_core.h (struct rb_vm_struct): replaced signal staff with trap
nobu authored
786 #define rb_thread_set_current_raw(th) (void)(ruby_current_thread = (th))
44aef0b @ko1 * this commit is a result of refactoring. only renaming functions,
ko1 authored
787 #define rb_thread_set_current(th) do { \
bcfc22b @kosaki * thread_pthread.c: rewrite GVL completely.
kosaki authored
788 if ((th)->vm->running_thread != (th)) { \
789 (th)->vm->running_thread->running_time_us = 0; \
790 } \
44aef0b @ko1 * this commit is a result of refactoring. only renaming functions,
ko1 authored
791 rb_thread_set_current_raw(th); \
741e778 @akr * vm_core.h: parenthesize macro arguments.
akr authored
792 (th)->vm->running_thread = (th); \
44aef0b @ko1 * this commit is a result of refactoring. only renaming functions,
ko1 authored
793 } while (0)
794
795 #else
796 #error "unsupported thread model"
797 #endif
a3e1b1c @ko1 * Merge YARV
ko1 authored
798
9d4e471 @kosaki * vm_core.h (RUBY_VM_SET_TIMER_INTERRUPT, RUBY_VM_SET_INTERRUPT,
kosaki authored
799 #define RUBY_VM_SET_TIMER_INTERRUPT(th) ATOMIC_OR((th)->interrupt_flag, 0x01)
800 #define RUBY_VM_SET_INTERRUPT(th) ATOMIC_OR((th)->interrupt_flag, 0x02)
801 #define RUBY_VM_SET_FINALIZER_INTERRUPT(th) ATOMIC_OR((th)->interrupt_flag, 0x04)
5f0b8af @ko1 * vm_core.h, thread.c, cont.c: add RUBY_VM_SET_INTERRUPT(),
ko1 authored
802 #define RUBY_VM_INTERRUPTED(th) ((th)->interrupt_flag & 0x02)
803
ff6ce77 @nobu * vm_core.h (rb_signal_buff_size, rb_signal_exec): moved
nobu authored
804 int rb_signal_buff_size(void);
805 void rb_signal_exec(rb_thread_t *th, int sig);
046a581 @nobu * vm_core.h: add missing prototypes.
nobu authored
806 void rb_threadptr_check_signal(rb_thread_t *mth);
79b62da @ko1 * thread.c: rename functions which require a parameter
ko1 authored
807 void rb_threadptr_signal_raise(rb_thread_t *th, int sig);
808 void rb_threadptr_signal_exit(rb_thread_t *th);
f4a8db6 @ko1 * thread.c (rb_thread_s_control_interrupt,
ko1 authored
809 void rb_threadptr_execute_interrupts(rb_thread_t *, int);
5ed8c08 @akr * eval.c, hash.c, load.c, proc.c, range.c, thread.c, time.c: don't
akr authored
810 void rb_threadptr_interrupt(rb_thread_t *th);
8741274 @kosaki * thread.c (thread_unlock_all_locking_mutexes): rename to
kosaki authored
811 void rb_threadptr_unlock_all_locking_mutexes(rb_thread_t *th);
2814443 @ko1 * thread.c (rb_threadptr_async_errinfo_*): manage async errors queue.
ko1 authored
812 void rb_threadptr_async_errinfo_clear(rb_thread_t *th);
813 void rb_threadptr_async_errinfo_enque(rb_thread_t *th, VALUE v);
814 int rb_threadptr_async_errinfo_active_p(rb_thread_t *th);
a3e1b1c @ko1 * Merge YARV
ko1 authored
815
a1d4164 @nobu * thread.c (thread_start_func_2): unlock all locking mutexes
nobu authored
816 void rb_thread_lock_unlock(rb_thread_lock_t *);
817 void rb_thread_lock_destroy(rb_thread_lock_t *);
818
f4a8db6 @ko1 * thread.c (rb_thread_s_control_interrupt,
ko1 authored
819 #define RUBY_VM_CHECK_INTS_BLOCKING(th) do { \
9d0fbe2 @nobu * vm_core.h (RUBY_VM_CHECK_INTS_TH): merge a patch by ko1
nobu authored
820 if (UNLIKELY((th)->interrupt_flag)) { \
f4a8db6 @ko1 * thread.c (rb_thread_s_control_interrupt,
ko1 authored
821 rb_threadptr_execute_interrupts(th, 1); \
9d0fbe2 @nobu * vm_core.h (RUBY_VM_CHECK_INTS_TH): merge a patch by ko1
nobu authored
822 } \
a3e1b1c @ko1 * Merge YARV
ko1 authored
823 } while (0)
824
f4a8db6 @ko1 * thread.c (rb_thread_s_control_interrupt,
ko1 authored
825 #define RUBY_VM_CHECK_INTS(th) do { \
826 if (UNLIKELY((th)->interrupt_flag)) { \
827 rb_threadptr_execute_interrupts(th, 0); \
828 } \
829 } while (0)
a3e1b1c @ko1 * Merge YARV
ko1 authored
830
ee457d9 @ko1 * compile.c: rename iseq_translate_direct_threaded_code()
ko1 authored
831 /* tracer */
b35d1e7 @nobu * thread.c (rb_threadptr_exec_event_hooks): new function to
nobu authored
832 void
833 rb_threadptr_exec_event_hooks(rb_thread_t *th, rb_event_flag_t flag, VALUE self, ID id, VALUE klass);
ee457d9 @ko1 * compile.c: rename iseq_translate_direct_threaded_code()
ko1 authored
834
835 #define EXEC_EVENT_HOOK(th, flag, self, id, klass) do { \
4a4a702 @ko1 * vm_trace.c, vm_core.h: simplify tracing mechanism.
ko1 authored
836 if (UNLIKELY(ruby_vm_event_flags & (flag))) { \
837 if (((th)->event_hooks.events | (th)->vm->event_hooks.events) & (flag)) { \
741e778 @akr * vm_core.h: parenthesize macro arguments.
akr authored
838 rb_threadptr_exec_event_hooks((th), (flag), (self), (id), (klass)); \
ee457d9 @ko1 * compile.c: rename iseq_translate_direct_threaded_code()
ko1 authored
839 } \
840 } \
841 } while (0)
842
a5e6532 @nobu * vm_core.h (rb_thread_check_trap_pending): hidden API for tcl/tk wra…
nobu authored
843 #if defined __GNUC__ && __GNUC__ >= 4
844 #pragma GCC visibility push(default)
845 #endif
846
847 int rb_thread_check_trap_pending(void);
848
a33fdc4 @nobu * vm_core.h (rb_{get,set,reset}_coverages): used in coverage.
nobu authored
849 extern VALUE rb_get_coverages(void);
850 extern void rb_set_coverages(VALUE);
851 extern void rb_reset_coverages(void);
852
a5e6532 @nobu * vm_core.h (rb_thread_check_trap_pending): hidden API for tcl/tk wra…
nobu authored
853 #if defined __GNUC__ && __GNUC__ >= 4
854 #pragma GCC visibility pop
855 #endif
856
8a9993d @nobu * eval_intern.h, insnhelper.h, thread_pthread.h, vm_core.h, vm_opts.h:
nobu authored
857 #endif /* RUBY_VM_CORE_H */
Something went wrong with that request. Please try again.