* configure.in (rb_cv_broken_glibc_ia64_erfc): renamed from
[ruby-svn.git] / vm_core.h
blob88087a7dbcdd7f16eb672817c44332e329326844
1 /**********************************************************************
3 vm_core.h -
5 $Author$
6 created at: 04/01/01 19:41:38 JST
8 Copyright (C) 2004-2007 Koichi Sasada
10 **********************************************************************/
12 #ifndef RUBY_VM_CORE_H
13 #define RUBY_VM_CORE_H
15 #define RUBY_VM_THREAD_MODEL 2
17 #include <setjmp.h>
19 #include "ruby/ruby.h"
20 #include "ruby/mvm.h"
21 #include "ruby/signal.h"
22 #include "ruby/st.h"
23 #include "ruby/node.h"
25 #include "debug.h"
26 #include "vm_opts.h"
27 #include "id.h"
29 #if defined(_WIN32)
30 #include "thread_win32.h"
31 #elif defined(HAVE_PTHREAD_H)
32 #include "thread_pthread.h"
33 #else
34 #error "unsupported thread type"
35 #endif
37 #include <signal.h>
39 #ifndef NSIG
40 # ifdef DJGPP
41 # define NSIG SIGMAX
42 # else
43 # define NSIG (_SIGMAX + 1) /* For QNX */
44 # endif
45 #endif
47 #define RUBY_NSIG NSIG
49 /*****************/
50 /* configuration */
51 /*****************/
53 /* gcc ver. check */
54 #if defined(__GNUC__) && __GNUC__ >= 2
56 #if OPT_TOKEN_THREADED_CODE
57 #if OPT_DIRECT_THREADED_CODE
58 #undef OPT_DIRECT_THREADED_CODE
59 #endif
60 #endif
62 #else /* defined(__GNUC__) && __GNUC__ >= 2 */
64 /* disable threaded code options */
65 #if OPT_DIRECT_THREADED_CODE
66 #undef OPT_DIRECT_THREADED_CODE
67 #endif
68 #if OPT_TOKEN_THREADED_CODE
69 #undef OPT_TOKEN_THREADED_CODE
70 #endif
71 #endif
73 /* call threaded code */
74 #if OPT_CALL_THREADED_CODE
75 #if OPT_DIRECT_THREADED_CODE
76 #undef OPT_DIRECT_THREADED_CODE
77 #endif /* OPT_DIRECT_THREADED_CODE */
78 #if OPT_STACK_CACHING
79 #undef OPT_STACK_CACHING
80 #endif /* OPT_STACK_CACHING */
81 #endif /* OPT_CALL_THREADED_CODE */
83 /* likely */
84 #if __GNUC__ >= 3
85 #define LIKELY(x) (__builtin_expect((x), 1))
86 #define UNLIKELY(x) (__builtin_expect((x), 0))
87 #else /* __GNUC__ >= 3 */
88 #define LIKELY(x) (x)
89 #define UNLIKELY(x) (x)
90 #endif /* __GNUC__ >= 3 */
92 typedef unsigned long rb_num_t;
94 #define ISEQ_TYPE_TOP INT2FIX(1)
95 #define ISEQ_TYPE_METHOD INT2FIX(2)
96 #define ISEQ_TYPE_BLOCK INT2FIX(3)
97 #define ISEQ_TYPE_CLASS INT2FIX(4)
98 #define ISEQ_TYPE_RESCUE INT2FIX(5)
99 #define ISEQ_TYPE_ENSURE INT2FIX(6)
100 #define ISEQ_TYPE_EVAL INT2FIX(7)
101 #define ISEQ_TYPE_DEFINED_GUARD INT2FIX(8)
103 #define CATCH_TYPE_RESCUE INT2FIX(1)
104 #define CATCH_TYPE_ENSURE INT2FIX(2)
105 #define CATCH_TYPE_RETRY INT2FIX(3)
106 #define CATCH_TYPE_BREAK INT2FIX(4)
107 #define CATCH_TYPE_REDO INT2FIX(5)
108 #define CATCH_TYPE_NEXT INT2FIX(6)
110 struct iseq_insn_info_entry {
111 unsigned short position;
112 unsigned short line_no;
113 unsigned short sp;
116 struct iseq_catch_table_entry {
117 VALUE type;
118 VALUE iseq;
119 unsigned long start;
120 unsigned long end;
121 unsigned long cont;
122 unsigned long sp;
125 #define INITIAL_ISEQ_COMPILE_DATA_STORAGE_BUFF_SIZE (512)
127 struct iseq_compile_data_storage {
128 struct iseq_compile_data_storage *next;
129 unsigned long pos;
130 unsigned long size;
131 char *buff;
134 struct iseq_compile_data_ensure_node_stack;
136 typedef struct rb_compile_option_struct {
137 int inline_const_cache;
138 int peephole_optimization;
139 int tailcall_optimization;
140 int specialized_instruction;
141 int operands_unification;
142 int instructions_unification;
143 int stack_caching;
144 int trace_instruction;
145 int debug_level;
146 } rb_compile_option_t;
148 struct iseq_compile_data {
149 /* GC is needed */
150 VALUE err_info;
151 VALUE mark_ary;
152 VALUE catch_table_ary; /* Array */
154 /* GC is not needed */
155 struct iseq_label_data *start_label;
156 struct iseq_label_data *end_label;
157 struct iseq_label_data *redo_label;
158 VALUE current_block;
159 VALUE loopval_popped; /* used by NODE_BREAK */
160 VALUE ensure_node;
161 VALUE for_iseq;
162 struct iseq_compile_data_ensure_node_stack *ensure_node_stack;
163 int cached_const;
164 struct iseq_compile_data_storage *storage_head;
165 struct iseq_compile_data_storage *storage_current;
166 int last_line;
167 int flip_cnt;
168 int label_no;
169 int node_level;
170 const rb_compile_option_t *option;
173 #if 1
174 #define GetCoreDataFromValue(obj, type, ptr) do { \
175 ptr = (type*)DATA_PTR(obj); \
176 } while (0)
177 #else
178 #define GetCoreDataFromValue(obj, type, ptr) Data_Get_Struct(obj, type, ptr)
179 #endif
181 #define GetISeqPtr(obj, ptr) \
182 GetCoreDataFromValue(obj, rb_iseq_t, ptr)
184 typedef struct rb_iseq_profile_struct {
185 VALUE count;
186 VALUE time_self;
187 VALUE time_cumu; /* cumulative */
188 } rb_iseq_profile_t;
190 struct rb_iseq_struct;
192 struct rb_iseq_struct {
193 /***************/
194 /* static data */
195 /***************/
197 VALUE type; /* instruction sequence type */
198 VALUE name; /* String: iseq name */
199 VALUE filename; /* file information where this sequence from */
200 VALUE *iseq; /* iseq (insn number and openrads) */
201 VALUE *iseq_encoded; /* encoded iseq */
202 unsigned long iseq_size;
203 VALUE mark_ary; /* Array: includes operands which should be GC marked */
204 VALUE coverage; /* coverage array */
206 /* insn info, must be freed */
207 struct iseq_insn_info_entry *insn_info_table;
208 unsigned long insn_info_size;
210 ID *local_table; /* must free */
211 int local_table_size;
213 /* method, class frame: sizeof(vars) + 1, block frame: sizeof(vars) */
214 int local_size;
217 * argument information
219 * def m(a1, a2, ..., aM, # mandatory
220 * b1=(...), b2=(...), ..., bN=(...), # optinal
221 * *c, # rest
222 * d1, d2, ..., dO, # post
223 * &e) # block
224 * =>
226 * argc = M
227 * arg_rest = M+N+1 // or -1 if no rest arg
228 * arg_opts = N
229 * arg_opts_tbl = [ (N entries) ]
230 * arg_post_len = O // 0 if no post arguments
231 * arg_post_start = M+N+2
232 * arg_block = M+N + 1 + O + 1 // -1 if no block arg
233 * arg_simple = 0 if not simple arguments.
234 * = 1 if no opt, rest, post, block.
235 * = 2 if ambiguos block parameter ({|a|}).
236 * arg_size = argument size.
239 int argc;
240 int arg_simple;
241 int arg_rest;
242 int arg_block;
243 int arg_opts;
244 int arg_post_len;
245 int arg_post_start;
246 int arg_size;
247 VALUE *arg_opt_table;
249 int stack_max; /* for stack overflow check */
251 /* catch table */
252 struct iseq_catch_table_entry *catch_table;
253 int catch_table_size;
255 /* for child iseq */
256 struct rb_iseq_struct *parent_iseq;
257 struct rb_iseq_struct *local_iseq;
259 /****************/
260 /* dynamic data */
261 /****************/
263 VALUE self;
265 /* block inlining */
267 * NODE *node;
268 * void *special_block_builder;
269 * void *cached_special_block_builder;
270 * VALUE cached_special_block;
273 /* klass/module nest information stack (cref) */
274 NODE *cref_stack;
275 VALUE klass;
277 /* misc */
278 ID defined_method_id; /* for define_method */
279 rb_iseq_profile_t profile;
281 /* used at compile time */
282 struct iseq_compile_data *compile_data;
285 enum ruby_special_exceptions {
286 ruby_error_reenter,
287 ruby_error_nomemory,
288 ruby_error_sysstack,
289 ruby_special_error_count
292 typedef struct rb_iseq_struct rb_iseq_t;
294 #define GetVMPtr(obj, ptr) \
295 GetCoreDataFromValue(obj, rb_vm_t, ptr)
297 struct rb_vm_struct
299 VALUE self;
301 rb_thread_lock_t global_vm_lock;
303 struct rb_thread_struct *main_thread;
304 struct rb_thread_struct *running_thread;
306 st_table *living_threads;
307 VALUE thgroup_default;
309 int running;
310 int thread_abort_on_exception;
311 unsigned long trace_flag;
312 volatile int sleeper;
314 /* object management */
315 VALUE mark_object_ary;
317 VALUE special_exceptions[ruby_special_error_count];
319 /* load */
320 VALUE top_self;
321 VALUE load_path;
322 VALUE loaded_features;
323 struct st_table *loading_table;
325 /* signal */
326 rb_atomic_t signal_buff[RUBY_NSIG];
327 rb_atomic_t buffered_signal_size;
329 /* hook */
330 rb_event_hook_t *event_hooks;
332 int src_encoding_index;
334 VALUE verbose, debug, progname;
335 VALUE coverages;
337 #if defined(ENABLE_VM_OBJSPACE) && ENABLE_VM_OBJSPACE
338 struct rb_objspace *objspace;
339 #endif
342 typedef struct {
343 VALUE *pc; /* cfp[0] */
344 VALUE *sp; /* cfp[1] */
345 VALUE *bp; /* cfp[2] */
346 rb_iseq_t *iseq; /* cfp[3] */
347 VALUE flag; /* cfp[4] */
348 VALUE self; /* cfp[5] / block[0] */
349 VALUE *lfp; /* cfp[6] / block[1] */
350 VALUE *dfp; /* cfp[7] / block[2] */
351 rb_iseq_t *block_iseq; /* cfp[8] / block[3] */
352 VALUE proc; /* cfp[9] / block[4] */
353 ID method_id; /* cfp[10] saved in special case */
354 VALUE method_class; /* cfp[11] saved in special case */
355 VALUE prof_time_self; /* cfp[12] */
356 VALUE prof_time_chld; /* cfp[13] */
357 } rb_control_frame_t;
359 typedef struct rb_block_struct {
360 VALUE self; /* share with method frame if it's only block */
361 VALUE *lfp; /* share with method frame if it's only block */
362 VALUE *dfp; /* share with method frame if it's only block */
363 rb_iseq_t *iseq;
364 VALUE proc;
365 } rb_block_t;
367 #define GetThreadPtr(obj, ptr) \
368 GetCoreDataFromValue(obj, rb_thread_t, ptr)
370 enum rb_thread_status {
371 THREAD_TO_KILL,
372 THREAD_RUNNABLE,
373 THREAD_STOPPED,
374 THREAD_STOPPED_FOREVER,
375 THREAD_KILLED
378 typedef RUBY_JMP_BUF rb_jmpbuf_t;
380 struct rb_vm_tag {
381 rb_jmpbuf_t buf;
382 VALUE tag;
383 VALUE retval;
384 struct rb_vm_tag *prev;
387 struct rb_vm_trap_tag {
388 struct rb_vm_trap_tag *prev;
391 #define RUBY_VM_VALUE_CACHE_SIZE 0x1000
392 #define USE_VALUE_CACHE 0
394 struct rb_unblock_callback {
395 rb_unblock_function_t *func;
396 void *arg;
399 struct rb_mutex_struct;
401 struct rb_thread_struct
403 VALUE self;
404 rb_vm_t *vm;
406 /* execution information */
407 VALUE *stack; /* must free, must mark */
408 unsigned long stack_size;
409 rb_control_frame_t *cfp;
410 int safe_level;
411 int raised_flag;
412 VALUE last_status; /* $? */
414 /* passing state */
415 int state;
417 /* for rb_iterate */
418 rb_block_t *passed_block;
420 /* for load(true) */
421 VALUE top_self;
422 VALUE top_wrapper;
424 /* eval env */
425 rb_block_t *base_block;
427 VALUE *local_lfp;
428 VALUE local_svar;
430 /* thread control */
431 rb_thread_id_t thread_id;
432 enum rb_thread_status status;
433 int priority;
435 native_thread_data_t native_thread_data;
437 VALUE thgroup;
438 VALUE value;
440 VALUE errinfo;
441 VALUE thrown_errinfo;
442 int exec_signal;
444 int interrupt_flag;
445 rb_thread_lock_t interrupt_lock;
446 struct rb_unblock_callback unblock;
447 VALUE locking_mutex;
448 struct rb_mutex_struct *keeping_mutexes;
449 int transition_for_lock;
451 struct rb_vm_tag *tag;
452 struct rb_vm_trap_tag *trap_tag;
454 int parse_in_eval;
455 int mild_compile_error;
457 /* storage */
458 st_table *local_storage;
459 #if USE_VALUE_CACHE
460 VALUE value_cache[RUBY_VM_VALUE_CACHE_SIZE + 1];
461 VALUE *value_cache_ptr;
462 #endif
464 struct rb_thread_struct *join_list_next;
465 struct rb_thread_struct *join_list_head;
467 VALUE first_proc;
468 VALUE first_args;
469 VALUE (*first_func)(ANYARGS);
471 /* for GC */
472 VALUE *machine_stack_start;
473 VALUE *machine_stack_end;
474 size_t machine_stack_maxsize;
475 #ifdef __ia64
476 VALUE *machine_register_stack_start;
477 VALUE *machine_register_stack_end;
478 size_t machine_register_stack_maxsize;
479 #endif
480 jmp_buf machine_regs;
481 int mark_stack_len;
483 /* statistics data for profiler */
484 VALUE stat_insn_usage;
486 /* tracer */
487 rb_event_hook_t *event_hooks;
488 rb_event_flag_t event_flags;
489 int tracing;
491 /* fiber */
492 VALUE fiber;
493 VALUE root_fiber;
494 rb_jmpbuf_t root_jmpbuf;
496 /* misc */
497 int method_missing_reason;
498 int abort_on_exception;
501 /* iseq.c */
502 VALUE rb_iseq_new(NODE*, VALUE, VALUE, VALUE, VALUE);
503 VALUE rb_iseq_new_with_bopt(NODE*, VALUE, VALUE, VALUE, VALUE, VALUE);
504 VALUE rb_iseq_new_with_opt(NODE*, VALUE, VALUE, VALUE, VALUE, const rb_compile_option_t*);
505 VALUE rb_iseq_compile(VALUE src, VALUE file, VALUE line);
506 VALUE ruby_iseq_disasm(VALUE self);
507 VALUE ruby_iseq_disasm_insn(VALUE str, VALUE *iseqval, int pos, rb_iseq_t *iseq, VALUE child);
508 const char *ruby_node_name(int node);
510 RUBY_EXTERN VALUE rb_cISeq;
511 RUBY_EXTERN VALUE rb_cRubyVM;
512 RUBY_EXTERN VALUE rb_cEnv;
513 RUBY_EXTERN VALUE rb_mRubyVMFrozenCore;
515 /* each thread has this size stack : 128KB */
516 #define RUBY_VM_THREAD_STACK_SIZE (128 * 1024)
518 struct global_entry {
519 struct global_variable *var;
520 ID id;
523 #define GetProcPtr(obj, ptr) \
524 GetCoreDataFromValue(obj, rb_proc_t, ptr)
526 typedef struct {
527 rb_block_t block;
529 VALUE envval; /* for GC mark */
530 VALUE blockprocval;
531 int safe_level;
532 int is_from_method;
533 int is_lambda;
534 } rb_proc_t;
536 #define GetEnvPtr(obj, ptr) \
537 GetCoreDataFromValue(obj, rb_env_t, ptr)
539 typedef struct {
540 VALUE *env;
541 int env_size;
542 int local_size;
543 VALUE prev_envval; /* for GC mark */
544 rb_block_t block;
545 } rb_env_t;
547 #define GetBindingPtr(obj, ptr) \
548 GetCoreDataFromValue(obj, rb_binding_t, ptr)
550 typedef struct {
551 VALUE env;
552 } rb_binding_t;
555 /* used by compile time and send insn */
556 #define VM_CALL_ARGS_SPLAT_BIT (0x01 << 1)
557 #define VM_CALL_ARGS_BLOCKARG_BIT (0x01 << 2)
558 #define VM_CALL_FCALL_BIT (0x01 << 3)
559 #define VM_CALL_VCALL_BIT (0x01 << 4)
560 #define VM_CALL_TAILCALL_BIT (0x01 << 5)
561 #define VM_CALL_TAILRECURSION_BIT (0x01 << 6)
562 #define VM_CALL_SUPER_BIT (0x01 << 7)
563 #define VM_CALL_SEND_BIT (0x01 << 8)
565 #define VM_SPECIAL_OBJECT_VMCORE 0x01
566 #define VM_SPECIAL_OBJECT_CBASE 0x02
568 #define VM_FRAME_MAGIC_METHOD 0x11
569 #define VM_FRAME_MAGIC_BLOCK 0x21
570 #define VM_FRAME_MAGIC_CLASS 0x31
571 #define VM_FRAME_MAGIC_TOP 0x41
572 #define VM_FRAME_MAGIC_FINISH 0x51
573 #define VM_FRAME_MAGIC_CFUNC 0x61
574 #define VM_FRAME_MAGIC_PROC 0x71
575 #define VM_FRAME_MAGIC_IFUNC 0x81
576 #define VM_FRAME_MAGIC_EVAL 0x91
577 #define VM_FRAME_MAGIC_LAMBDA 0xa1
578 #define VM_FRAME_MAGIC_MASK_BITS 8
579 #define VM_FRAME_MAGIC_MASK (~(~0<<VM_FRAME_MAGIC_MASK_BITS))
581 #define VM_FRAME_TYPE(cfp) ((cfp)->flag & VM_FRAME_MAGIC_MASK)
583 /* other frame flag */
584 #define VM_FRAME_FLAG_PASSED 0x0100
587 #define RUBYVM_CFUNC_FRAME_P(cfp) \
588 (VM_FRAME_TYPE(cfp) == VM_FRAME_MAGIC_CFUNC)
591 /* inline (method|const) cache */
592 #define NEW_INLINE_CACHE_ENTRY() NEW_WHILE(Qundef, 0, 0)
593 #define ic_class u1.value
594 #define ic_method u2.node
595 #define ic_value u2.value
596 #define ic_vmstat u3.cnt
597 typedef NODE *IC;
599 void rb_vm_change_state(void);
601 typedef VALUE CDHASH;
603 #ifndef FUNC_FASTCALL
604 #define FUNC_FASTCALL(x) x
605 #endif
607 typedef rb_control_frame_t *
608 (FUNC_FASTCALL(*rb_insn_func_t))(rb_thread_t *, rb_control_frame_t *);
610 #define GC_GUARDED_PTR(p) ((VALUE)((VALUE)(p) | 0x01))
611 #define GC_GUARDED_PTR_REF(p) ((void *)(((VALUE)p) & ~0x03))
612 #define GC_GUARDED_PTR_P(p) (((VALUE)p) & 0x01)
614 #define RUBY_VM_METHOD_NODE NODE_METHOD
616 #define RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp) (cfp+1)
617 #define RUBY_VM_NEXT_CONTROL_FRAME(cfp) (cfp-1)
618 #define RUBY_VM_END_CONTROL_FRAME(th) \
619 ((rb_control_frame_t *)((th)->stack + (th)->stack_size))
620 #define RUBY_VM_VALID_CONTROL_FRAME_P(cfp, ecfp) \
621 ((void *)(ecfp) > (void *)(cfp))
622 #define RUBY_VM_CONTROL_FRAME_STACK_OVERFLOW_P(th, cfp) \
623 (!RUBY_VM_VALID_CONTROL_FRAME_P((cfp), RUBY_VM_END_CONTROL_FRAME(th)))
625 #define RUBY_VM_IFUNC_P(ptr) (BUILTIN_TYPE(ptr) == T_NODE)
626 #define RUBY_VM_NORMAL_ISEQ_P(ptr) \
627 (ptr && !RUBY_VM_IFUNC_P(ptr))
629 #define RUBY_VM_CLASS_SPECIAL_P(ptr) (((VALUE)(ptr)) & 0x02)
631 #define RUBY_VM_GET_BLOCK_PTR_IN_CFP(cfp) ((rb_block_t *)(&(cfp)->self))
632 #define RUBY_VM_GET_CFP_FROM_BLOCK_PTR(b) \
633 ((rb_control_frame_t *)((VALUE *)(b) - 5))
635 /* defined? */
636 #define DEFINED_IVAR INT2FIX(1)
637 #define DEFINED_IVAR2 INT2FIX(2)
638 #define DEFINED_GVAR INT2FIX(3)
639 #define DEFINED_CVAR INT2FIX(4)
640 #define DEFINED_CONST INT2FIX(5)
641 #define DEFINED_METHOD INT2FIX(6)
642 #define DEFINED_YIELD INT2FIX(7)
643 #define DEFINED_REF INT2FIX(8)
644 #define DEFINED_ZSUPER INT2FIX(9)
645 #define DEFINED_FUNC INT2FIX(10)
647 /* VM related object allocate functions */
648 /* TODO: should be static functions */
649 VALUE rb_thread_alloc(VALUE klass);
650 VALUE rb_proc_alloc(VALUE klass);
652 /* for debug */
653 extern void vm_stack_dump_raw(rb_thread_t *, rb_control_frame_t *);
654 #define SDR() vm_stack_dump_raw(GET_THREAD(), GET_THREAD()->cfp)
655 #define SDR2(cfp) vm_stack_dump_raw(GET_THREAD(), (cfp))
656 void rb_vm_bugreport(void);
659 /* functions about thread/vm execution */
661 VALUE rb_iseq_eval(VALUE iseqval);
662 void rb_enable_interrupt(void);
663 void rb_disable_interrupt(void);
664 int rb_thread_method_id_and_class(rb_thread_t *th, ID *idp, VALUE *klassp);
666 VALUE vm_invoke_proc(rb_thread_t *th, rb_proc_t *proc, VALUE self,
667 int argc, const VALUE *argv, rb_block_t *blockptr);
668 VALUE vm_make_proc(rb_thread_t *th, rb_control_frame_t *cfp, const rb_block_t *block);
669 VALUE vm_make_env_object(rb_thread_t *th, rb_control_frame_t *cfp);
671 NOINLINE(void rb_gc_save_machine_context(rb_thread_t *));
673 #define sysstack_error GET_VM()->special_exceptions[ruby_error_sysstack]
675 /* for thread */
677 #if RUBY_VM_THREAD_MODEL == 2
678 RUBY_EXTERN rb_thread_t *ruby_current_thread;
679 extern rb_vm_t *ruby_current_vm;
681 #define GET_VM() ruby_current_vm
682 #define GET_THREAD() ruby_current_thread
683 #define rb_thread_set_current_raw(th) (ruby_current_thread = th)
684 #define rb_thread_set_current(th) do { \
685 rb_thread_set_current_raw(th); \
686 th->vm->running_thread = th; \
687 } while (0)
689 #else
690 #error "unsupported thread model"
691 #endif
693 #define RUBY_VM_SET_INTERRUPT(th) ((th)->interrupt_flag |= 0x02)
694 #define RUBY_VM_SET_TIMER_INTERRUPT(th) ((th)->interrupt_flag |= 0x01)
695 #define RUBY_VM_SET_FINALIZER_INTERRUPT(th) ((th)->interrupt_flag |= 0x04)
696 #define RUBY_VM_INTERRUPTED(th) ((th)->interrupt_flag & 0x02)
698 void rb_thread_execute_interrupts(rb_thread_t *);
700 #define RUBY_VM_CHECK_INTS_TH(th) do { \
701 if (th->interrupt_flag) { \
702 /* TODO: trap something event */ \
703 rb_thread_execute_interrupts(th); \
705 } while (0)
707 #define RUBY_VM_CHECK_INTS() \
708 RUBY_VM_CHECK_INTS_TH(GET_THREAD())
710 /* tracer */
711 static inline void
712 exec_event_hooks(rb_event_hook_t *hook, rb_event_flag_t flag, VALUE self, ID id, VALUE klass)
714 while (hook) {
715 if (flag & hook->flag) {
716 (*hook->func)(flag, hook->data, self, id, klass);
718 hook = hook->next;
722 #define EXEC_EVENT_HOOK(th, flag, self, id, klass) do { \
723 rb_event_flag_t wait_event__ = th->event_flags; \
724 if (UNLIKELY(wait_event__)) { \
725 if (wait_event__ & (flag | RUBY_EVENT_VM)) { \
726 VALUE self__ = (self), klass__ = (klass); \
727 ID id__ = (id); \
728 if (wait_event__ & flag) { \
729 exec_event_hooks(th->event_hooks, flag, self__, id__, klass__); \
731 if (wait_event__ & RUBY_EVENT_VM) { \
732 exec_event_hooks(th->vm->event_hooks, flag, self__, id__, klass__); \
736 } while (0)
738 #endif /* RUBY_VM_CORE_H */