did_you_mean 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +2 -0
  3. data/did_you_mean.gemspec +4 -0
  4. data/ext/did_you_mean/extconf.rb +7 -2
  5. data/ext/did_you_mean/ruby_headers/220/addr2line.h +21 -0
  6. data/ext/did_you_mean/ruby_headers/220/constant.h +36 -0
  7. data/ext/did_you_mean/ruby_headers/220/dln.h +51 -0
  8. data/ext/did_you_mean/ruby_headers/220/encdb.h +170 -0
  9. data/ext/did_you_mean/ruby_headers/220/eval_intern.h +256 -0
  10. data/ext/did_you_mean/ruby_headers/220/gc.h +102 -0
  11. data/ext/did_you_mean/ruby_headers/220/id.h +171 -0
  12. data/ext/did_you_mean/ruby_headers/220/internal.h +1006 -0
  13. data/ext/did_you_mean/ruby_headers/220/iseq.h +136 -0
  14. data/ext/did_you_mean/ruby_headers/220/method.h +142 -0
  15. data/ext/did_you_mean/ruby_headers/220/node.h +543 -0
  16. data/ext/did_you_mean/ruby_headers/220/parse.h +183 -0
  17. data/ext/did_you_mean/ruby_headers/220/probes.h +83 -0
  18. data/ext/did_you_mean/ruby_headers/220/probes_helper.h +67 -0
  19. data/ext/did_you_mean/ruby_headers/220/regenc.h +223 -0
  20. data/ext/did_you_mean/ruby_headers/220/regint.h +911 -0
  21. data/ext/did_you_mean/ruby_headers/220/regparse.h +363 -0
  22. data/ext/did_you_mean/ruby_headers/220/revision.h +1 -0
  23. data/ext/did_you_mean/ruby_headers/220/ruby_atomic.h +170 -0
  24. data/ext/did_you_mean/ruby_headers/220/siphash.h +48 -0
  25. data/ext/did_you_mean/ruby_headers/220/thread_native.h +23 -0
  26. data/ext/did_you_mean/ruby_headers/220/thread_pthread.h +56 -0
  27. data/ext/did_you_mean/ruby_headers/220/thread_win32.h +45 -0
  28. data/ext/did_you_mean/ruby_headers/220/timev.h +42 -0
  29. data/ext/did_you_mean/ruby_headers/220/transcode_data.h +123 -0
  30. data/ext/did_you_mean/ruby_headers/220/transdb.h +190 -0
  31. data/ext/did_you_mean/ruby_headers/220/verconf.h +13 -0
  32. data/ext/did_you_mean/ruby_headers/220/version.h +53 -0
  33. data/ext/did_you_mean/ruby_headers/220/vm_core.h +1024 -0
  34. data/ext/did_you_mean/ruby_headers/220/vm_debug.h +37 -0
  35. data/ext/did_you_mean/ruby_headers/220/vm_exec.h +182 -0
  36. data/ext/did_you_mean/ruby_headers/220/vm_insnhelper.h +273 -0
  37. data/ext/did_you_mean/ruby_headers/220/vm_opts.h +56 -0
  38. data/lib/did_you_mean/version.rb +1 -1
  39. metadata +51 -4
@@ -0,0 +1,13 @@
1
+ #define RUBY_BASE_NAME "ruby"
2
+ #define RUBY_VERSION_NAME RUBY_BASE_NAME"-"RUBY_LIB_VERSION
3
+ #define RUBY_LIB_VERSION_STYLE 3 /* full */
4
+ #define RUBY_EXEC_PREFIX "/usr/local"
5
+ #define RUBY_LIB_PREFIX RUBY_EXEC_PREFIX"/lib/ruby"
6
+ #define RUBY_ARCH_PREFIX_FOR(arch) RUBY_LIB_PREFIX"/"arch
7
+ #define RUBY_SITEARCH_PREFIX_FOR(arch) RUBY_LIB_PREFIX"/"arch
8
+ #define RUBY_LIB RUBY_LIB_PREFIX"/"RUBY_LIB_VERSION
9
+ #define RUBY_ARCH_LIB_FOR(arch) RUBY_LIB"/"arch
10
+ #define RUBY_SITE_LIB RUBY_LIB_PREFIX"/site_ruby"
11
+ #define RUBY_SITE_ARCH_LIB_FOR(arch) RUBY_SITE_LIB2"/"arch
12
+ #define RUBY_VENDOR_LIB RUBY_LIB_PREFIX"/vendor_ruby"
13
+ #define RUBY_VENDOR_ARCH_LIB_FOR(arch) RUBY_VENDOR_LIB2"/"arch
@@ -0,0 +1,53 @@
1
+ #define RUBY_VERSION "2.2.0"
2
+ #define RUBY_RELEASE_DATE "2014-02-25"
3
+ #define RUBY_PATCHLEVEL -1
4
+ #define RUBY_BRANCH_NAME "trunk"
5
+
6
+ #define RUBY_RELEASE_YEAR 2014
7
+ #define RUBY_RELEASE_MONTH 2
8
+ #define RUBY_RELEASE_DAY 25
9
+
10
+ #include "ruby/version.h"
11
+
12
+ #if !defined RUBY_LIB_VERSION && defined RUBY_LIB_VERSION_STYLE
13
+ # if RUBY_LIB_VERSION_STYLE == 3
14
+ # define RUBY_LIB_VERSION STRINGIZE(RUBY_API_VERSION_MAJOR)"."STRINGIZE(RUBY_API_VERSION_MINOR)"."STRINGIZE(RUBY_API_VERSION_TEENY)
15
+ # elif RUBY_LIB_VERSION_STYLE == 2
16
+ # define RUBY_LIB_VERSION STRINGIZE(RUBY_API_VERSION_MAJOR)"."STRINGIZE(RUBY_API_VERSION_MINOR)
17
+ # endif
18
+ #endif
19
+
20
+ #if RUBY_PATCHLEVEL == -1
21
+ #define RUBY_PATCHLEVEL_STR "dev"
22
+ #else
23
+ #define RUBY_PATCHLEVEL_STR "p"STRINGIZE(RUBY_PATCHLEVEL)
24
+ #endif
25
+
26
+ #ifndef RUBY_REVISION
27
+ # include "revision.h"
28
+ #endif
29
+ #ifndef RUBY_REVISION
30
+ # define RUBY_REVISION 0
31
+ #endif
32
+
33
+ #if RUBY_REVISION
34
+ # ifdef RUBY_BRANCH_NAME
35
+ # define RUBY_REVISION_STR " "RUBY_BRANCH_NAME" "STRINGIZE(RUBY_REVISION)
36
+ # else
37
+ # define RUBY_REVISION_STR " revision "STRINGIZE(RUBY_REVISION)
38
+ # endif
39
+ #else
40
+ # define RUBY_REVISION_STR ""
41
+ #endif
42
+
43
+ # define RUBY_DESCRIPTION \
44
+ "ruby "RUBY_VERSION \
45
+ RUBY_PATCHLEVEL_STR \
46
+ " ("RUBY_RELEASE_DATE \
47
+ RUBY_REVISION_STR") " \
48
+ "["RUBY_PLATFORM"]"
49
+ # define RUBY_COPYRIGHT \
50
+ "ruby - Copyright (C) " \
51
+ STRINGIZE(RUBY_BIRTH_YEAR)"-" \
52
+ STRINGIZE(RUBY_RELEASE_YEAR)" " \
53
+ RUBY_AUTHOR
@@ -0,0 +1,1024 @@
1
+ /**********************************************************************
2
+
3
+ vm_core.h -
4
+
5
+ $Author$
6
+ created at: 04/01/01 19:41:38 JST
7
+
8
+ Copyright (C) 2004-2007 Koichi Sasada
9
+
10
+ **********************************************************************/
11
+
12
+ #ifndef RUBY_VM_CORE_H
13
+ #define RUBY_VM_CORE_H
14
+
15
+ #define RUBY_VM_THREAD_MODEL 2
16
+
17
+ #include "ruby/ruby.h"
18
+ #include "ruby/st.h"
19
+
20
+ #include "node.h"
21
+ #include "vm_debug.h"
22
+ #include "vm_opts.h"
23
+ #include "id.h"
24
+ #include "method.h"
25
+ #include "ruby_atomic.h"
26
+
27
+ #include "thread_native.h"
28
+
29
+ #ifndef ENABLE_VM_OBJSPACE
30
+ #ifdef _WIN32
31
+ /*
32
+ * TODO: object space independent st_table.
33
+ * socklist needs st_table in rb_w32_sysinit(), before object space
34
+ * initialization.
35
+ * It is too early now to change st_hash_type, since it breaks binary
36
+ * compatibility.
37
+ */
38
+ #define ENABLE_VM_OBJSPACE 0
39
+ #else
40
+ #define ENABLE_VM_OBJSPACE 1
41
+ #endif
42
+ #endif
43
+
44
+ #include <setjmp.h>
45
+ #include <signal.h>
46
+
47
+ #ifndef NSIG
48
+ # define NSIG (_SIGMAX + 1) /* For QNX */
49
+ #endif
50
+
51
+ #define RUBY_NSIG NSIG
52
+
53
+ #ifdef HAVE_STDARG_PROTOTYPES
54
+ #include <stdarg.h>
55
+ #define va_init_list(a,b) va_start((a),(b))
56
+ #else
57
+ #include <varargs.h>
58
+ #define va_init_list(a,b) va_start((a))
59
+ #endif
60
+
61
+ #if defined(SIGSEGV) && defined(HAVE_SIGALTSTACK) && defined(SA_SIGINFO) && !defined(__NetBSD__)
62
+ #define USE_SIGALTSTACK
63
+ #endif
64
+
65
+ /*****************/
66
+ /* configuration */
67
+ /*****************/
68
+
69
+ /* gcc ver. check */
70
+ #if defined(__GNUC__) && __GNUC__ >= 2
71
+
72
+ #if OPT_TOKEN_THREADED_CODE
73
+ #if OPT_DIRECT_THREADED_CODE
74
+ #undef OPT_DIRECT_THREADED_CODE
75
+ #endif
76
+ #endif
77
+
78
+ #else /* defined(__GNUC__) && __GNUC__ >= 2 */
79
+
80
+ /* disable threaded code options */
81
+ #if OPT_DIRECT_THREADED_CODE
82
+ #undef OPT_DIRECT_THREADED_CODE
83
+ #endif
84
+ #if OPT_TOKEN_THREADED_CODE
85
+ #undef OPT_TOKEN_THREADED_CODE
86
+ #endif
87
+ #endif
88
+
89
+ #ifdef __native_client__
90
+ #undef OPT_DIRECT_THREADED_CODE
91
+ #endif
92
+
93
+ /* call threaded code */
94
+ #if OPT_CALL_THREADED_CODE
95
+ #if OPT_DIRECT_THREADED_CODE
96
+ #undef OPT_DIRECT_THREADED_CODE
97
+ #endif /* OPT_DIRECT_THREADED_CODE */
98
+ #if OPT_STACK_CACHING
99
+ #undef OPT_STACK_CACHING
100
+ #endif /* OPT_STACK_CACHING */
101
+ #endif /* OPT_CALL_THREADED_CODE */
102
+
103
+ typedef unsigned long rb_num_t;
104
+
105
+ /* iseq data type */
106
+
107
+ struct iseq_compile_data_ensure_node_stack;
108
+
109
+ typedef struct rb_compile_option_struct rb_compile_option_t;
110
+
111
+
112
+ struct iseq_inline_cache_entry {
113
+ rb_serial_t ic_serial;
114
+ union {
115
+ size_t index;
116
+ VALUE value;
117
+ } ic_value;
118
+ };
119
+
120
+ union iseq_inline_storage_entry {
121
+ struct {
122
+ struct rb_thread_struct *running_thread;
123
+ VALUE value;
124
+ VALUE done;
125
+ } once;
126
+ struct iseq_inline_cache_entry cache;
127
+ };
128
+
129
+ /* to avoid warning */
130
+ struct rb_thread_struct;
131
+ struct rb_control_frame_struct;
132
+
133
+ /* rb_call_info_t contains calling information including inline cache */
134
+ typedef struct rb_call_info_struct {
135
+ /* fixed at compile time */
136
+ ID mid;
137
+ VALUE flag;
138
+ int orig_argc;
139
+ rb_iseq_t *blockiseq;
140
+
141
+ /* inline cache: keys */
142
+ rb_serial_t method_state;
143
+ rb_serial_t class_serial;
144
+ VALUE klass;
145
+
146
+ /* inline cache: values */
147
+ const rb_method_entry_t *me;
148
+ VALUE defined_class;
149
+
150
+ /* temporary values for method calling */
151
+ int argc;
152
+ struct rb_block_struct *blockptr;
153
+ VALUE recv;
154
+ union {
155
+ int opt_pc; /* used by iseq */
156
+ long index; /* used by ivar */
157
+ int missing_reason; /* used by method_missing */
158
+ int inc_sp; /* used by cfunc */
159
+ } aux;
160
+
161
+ VALUE (*call)(struct rb_thread_struct *th, struct rb_control_frame_struct *cfp, struct rb_call_info_struct *ci);
162
+ } rb_call_info_t;
163
+
164
+ #if 1
165
+ #define GetCoreDataFromValue(obj, type, ptr) do { \
166
+ (ptr) = (type*)DATA_PTR(obj); \
167
+ } while (0)
168
+ #else
169
+ #define GetCoreDataFromValue(obj, type, ptr) Data_Get_Struct((obj), type, (ptr))
170
+ #endif
171
+
172
+ #define GetISeqPtr(obj, ptr) \
173
+ GetCoreDataFromValue((obj), rb_iseq_t, (ptr))
174
+
175
+ typedef struct rb_iseq_location_struct {
176
+ const VALUE path;
177
+ const VALUE absolute_path;
178
+ const VALUE base_label;
179
+ const VALUE label;
180
+ size_t first_lineno;
181
+ } rb_iseq_location_t;
182
+
183
+ struct rb_iseq_struct;
184
+
185
+ struct rb_iseq_struct {
186
+ /***************/
187
+ /* static data */
188
+ /***************/
189
+
190
+ enum iseq_type {
191
+ ISEQ_TYPE_TOP,
192
+ ISEQ_TYPE_METHOD,
193
+ ISEQ_TYPE_BLOCK,
194
+ ISEQ_TYPE_CLASS,
195
+ ISEQ_TYPE_RESCUE,
196
+ ISEQ_TYPE_ENSURE,
197
+ ISEQ_TYPE_EVAL,
198
+ ISEQ_TYPE_MAIN,
199
+ ISEQ_TYPE_DEFINED_GUARD
200
+ } type; /* instruction sequence type */
201
+
202
+ rb_iseq_location_t location;
203
+
204
+ VALUE *iseq; /* iseq (insn number and operands) */
205
+ VALUE *iseq_encoded; /* encoded iseq */
206
+ unsigned long iseq_size;
207
+ const VALUE mark_ary; /* Array: includes operands which should be GC marked */
208
+ const VALUE coverage; /* coverage array */
209
+
210
+ /* insn info, must be freed */
211
+ struct iseq_line_info_entry *line_info_table;
212
+ size_t line_info_size;
213
+
214
+ ID *local_table; /* must free */
215
+ int local_table_size;
216
+
217
+ /* sizeof(vars) + 1 */
218
+ int local_size;
219
+
220
+ union iseq_inline_storage_entry *is_entries;
221
+ int is_size;
222
+
223
+ rb_call_info_t *callinfo_entries;
224
+ int callinfo_size;
225
+
226
+ /**
227
+ * argument information
228
+ *
229
+ * def m(a1, a2, ..., aM, # mandatory
230
+ * b1=(...), b2=(...), ..., bN=(...), # optional
231
+ * *c, # rest
232
+ * d1, d2, ..., dO, # post
233
+ * e1:(...), e2:(...), ..., eK:(...), # keyword
234
+ * **f, # keyword rest
235
+ * &g) # block
236
+ * =>
237
+ *
238
+ * argc = M // or 0 if no mandatory arg
239
+ * arg_opts = N+1 // or 0 if no optional arg
240
+ * arg_rest = M+N // or -1 if no rest arg
241
+ * arg_opt_table = [ (arg_opts entries) ]
242
+ * arg_post_start = M+N+(*1) // or 0 if no post arguments
243
+ * arg_post_len = O // or 0 if no post arguments
244
+ * arg_keywords = K // or 0 if no keyword arg
245
+ * arg_block = M+N+(*1)+O+K // or -1 if no block arg
246
+ * arg_keyword = M+N+(*1)+O+K+(&1) // or -1 if no keyword arg/rest
247
+ * arg_simple = 0 if not simple arguments.
248
+ * = 1 if no opt, rest, post, block.
249
+ * = 2 if ambiguous block parameter ({|a|}).
250
+ * arg_size = M+N+O+(*1)+K+(&1)+(**1) argument size.
251
+ */
252
+
253
+ int argc;
254
+ int arg_simple;
255
+ int arg_rest;
256
+ int arg_block;
257
+ int arg_opts;
258
+ int arg_post_len;
259
+ int arg_post_start;
260
+ int arg_size;
261
+ VALUE *arg_opt_table;
262
+ int arg_keyword;
263
+ int arg_keyword_check; /* if this is true, raise an ArgumentError when unknown keyword argument is passed */
264
+ int arg_keywords;
265
+ int arg_keyword_required;
266
+ ID *arg_keyword_table;
267
+
268
+ size_t stack_max; /* for stack overflow check */
269
+
270
+ /* catch table */
271
+ struct iseq_catch_table_entry *catch_table;
272
+ int catch_table_size;
273
+
274
+ /* for child iseq */
275
+ struct rb_iseq_struct *parent_iseq;
276
+ struct rb_iseq_struct *local_iseq;
277
+
278
+ /****************/
279
+ /* dynamic data */
280
+ /****************/
281
+
282
+ VALUE self;
283
+ const VALUE orig; /* non-NULL if its data have origin */
284
+
285
+ /* block inlining */
286
+ /*
287
+ * NODE *node;
288
+ * void *special_block_builder;
289
+ * void *cached_special_block_builder;
290
+ * VALUE cached_special_block;
291
+ */
292
+
293
+ /* klass/module nest information stack (cref) */
294
+ NODE * const cref_stack;
295
+ const VALUE klass;
296
+
297
+ /* misc */
298
+ ID defined_method_id; /* for define_method */
299
+ rb_num_t flip_cnt;
300
+
301
+ /* used at compile time */
302
+ struct iseq_compile_data *compile_data;
303
+ };
304
+
305
+ enum ruby_special_exceptions {
306
+ ruby_error_reenter,
307
+ ruby_error_nomemory,
308
+ ruby_error_sysstack,
309
+ ruby_error_closed_stream,
310
+ ruby_special_error_count
311
+ };
312
+
313
+ #define GetVMPtr(obj, ptr) \
314
+ GetCoreDataFromValue((obj), rb_vm_t, (ptr))
315
+
316
+ #if defined(ENABLE_VM_OBJSPACE) && ENABLE_VM_OBJSPACE
317
+ struct rb_objspace;
318
+ void rb_objspace_free(struct rb_objspace *);
319
+ #endif
320
+
321
+ typedef struct rb_hook_list_struct {
322
+ struct rb_event_hook_struct *hooks;
323
+ rb_event_flag_t events;
324
+ int need_clean;
325
+ } rb_hook_list_t;
326
+
327
+ typedef struct rb_vm_struct {
328
+ VALUE self;
329
+
330
+ rb_global_vm_lock_t gvl;
331
+ rb_nativethread_lock_t thread_destruct_lock;
332
+
333
+ struct rb_thread_struct *main_thread;
334
+ struct rb_thread_struct *running_thread;
335
+
336
+ st_table *living_threads;
337
+ VALUE thgroup_default;
338
+
339
+ int running;
340
+ int thread_abort_on_exception;
341
+ int trace_running;
342
+ volatile int sleeper;
343
+
344
+ /* object management */
345
+ VALUE mark_object_ary;
346
+
347
+ VALUE special_exceptions[ruby_special_error_count];
348
+
349
+ /* load */
350
+ VALUE top_self;
351
+ VALUE load_path;
352
+ VALUE load_path_snapshot;
353
+ VALUE load_path_check_cache;
354
+ VALUE expanded_load_path;
355
+ VALUE loaded_features;
356
+ VALUE loaded_features_snapshot;
357
+ struct st_table *loaded_features_index;
358
+ struct st_table *loading_table;
359
+
360
+ /* signal */
361
+ struct {
362
+ VALUE cmd;
363
+ int safe;
364
+ } trap_list[RUBY_NSIG];
365
+
366
+ /* hook */
367
+ rb_hook_list_t event_hooks;
368
+
369
+ /* relation table of ensure - rollback for callcc */
370
+ struct st_table *ensure_rollback_table;
371
+
372
+ /* postponed_job */
373
+ struct rb_postponed_job_struct *postponed_job_buffer;
374
+ int postponed_job_index;
375
+
376
+ int src_encoding_index;
377
+
378
+ VALUE verbose, debug, orig_progname, progname;
379
+ VALUE coverages;
380
+
381
+ struct unlinked_method_entry_list_entry *unlinked_method_entry_list;
382
+
383
+ VALUE defined_module_hash;
384
+
385
+ #if defined(ENABLE_VM_OBJSPACE) && ENABLE_VM_OBJSPACE
386
+ struct rb_objspace *objspace;
387
+ #endif
388
+
389
+ /*
390
+ * @shyouhei notes that this is not for storing normal Ruby
391
+ * objects so do *NOT* mark this when you GC.
392
+ */
393
+ struct RArray at_exit;
394
+
395
+ VALUE *defined_strings;
396
+
397
+ /* params */
398
+ struct { /* size in byte */
399
+ size_t thread_vm_stack_size;
400
+ size_t thread_machine_stack_size;
401
+ size_t fiber_vm_stack_size;
402
+ size_t fiber_machine_stack_size;
403
+ } default_params;
404
+ } rb_vm_t;
405
+
406
+ /* default values */
407
+
408
+ #define RUBY_VM_SIZE_ALIGN 4096
409
+
410
+ #define RUBY_VM_THREAD_VM_STACK_SIZE ( 128 * 1024 * sizeof(VALUE)) /* 512 KB or 1024 KB */
411
+ #define RUBY_VM_THREAD_VM_STACK_SIZE_MIN ( 2 * 1024 * sizeof(VALUE)) /* 8 KB or 16 KB */
412
+ #define RUBY_VM_THREAD_MACHINE_STACK_SIZE ( 128 * 1024 * sizeof(VALUE)) /* 512 KB or 1024 KB */
413
+ #define RUBY_VM_THREAD_MACHINE_STACK_SIZE_MIN ( 16 * 1024 * sizeof(VALUE)) /* 64 KB or 128 KB */
414
+
415
+ #define RUBY_VM_FIBER_VM_STACK_SIZE ( 16 * 1024 * sizeof(VALUE)) /* 64 KB or 128 KB */
416
+ #define RUBY_VM_FIBER_VM_STACK_SIZE_MIN ( 2 * 1024 * sizeof(VALUE)) /* 8 KB or 16 KB */
417
+ #define RUBY_VM_FIBER_MACHINE_STACK_SIZE ( 64 * 1024 * sizeof(VALUE)) /* 256 KB or 512 KB */
418
+ #define RUBY_VM_FIBER_MACHINE_STACK_SIZE_MIN ( 16 * 1024 * sizeof(VALUE)) /* 64 KB or 128 KB */
419
+
420
+ #ifndef VM_DEBUG_BP_CHECK
421
+ #define VM_DEBUG_BP_CHECK 0
422
+ #endif
423
+
424
+ typedef struct rb_control_frame_struct {
425
+ VALUE *pc; /* cfp[0] */
426
+ VALUE *sp; /* cfp[1] */
427
+ rb_iseq_t *iseq; /* cfp[2] */
428
+ VALUE flag; /* cfp[3] */
429
+ VALUE self; /* cfp[4] / block[0] */
430
+ VALUE klass; /* cfp[5] / block[1] */
431
+ VALUE *ep; /* cfp[6] / block[2] */
432
+ rb_iseq_t *block_iseq; /* cfp[7] / block[3] */
433
+ VALUE proc; /* cfp[8] / block[4] */
434
+ const rb_method_entry_t *me;/* cfp[9] */
435
+
436
+ #if VM_DEBUG_BP_CHECK
437
+ VALUE *bp_check; /* cfp[10] */
438
+ #endif
439
+ } rb_control_frame_t;
440
+
441
+ typedef struct rb_block_struct {
442
+ VALUE self; /* share with method frame if it's only block */
443
+ VALUE klass; /* share with method frame if it's only block */
444
+ VALUE *ep; /* share with method frame if it's only block */
445
+ rb_iseq_t *iseq;
446
+ VALUE proc;
447
+ } rb_block_t;
448
+
449
+ extern const rb_data_type_t ruby_threadptr_data_type;
450
+
451
+ #define GetThreadPtr(obj, ptr) \
452
+ TypedData_Get_Struct((obj), rb_thread_t, &ruby_threadptr_data_type, (ptr))
453
+
454
+ enum rb_thread_status {
455
+ THREAD_RUNNABLE,
456
+ THREAD_STOPPED,
457
+ THREAD_STOPPED_FOREVER,
458
+ THREAD_KILLED
459
+ };
460
+
461
+ typedef RUBY_JMP_BUF rb_jmpbuf_t;
462
+
463
+ /*
464
+ the members which are written in TH_PUSH_TAG() should be placed at
465
+ the beginning and the end, so that entire region is accessible.
466
+ */
467
+ struct rb_vm_tag {
468
+ VALUE tag;
469
+ VALUE retval;
470
+ rb_jmpbuf_t buf;
471
+ struct rb_vm_tag *prev;
472
+ };
473
+
474
+ struct rb_vm_protect_tag {
475
+ struct rb_vm_protect_tag *prev;
476
+ };
477
+
478
+ struct rb_unblock_callback {
479
+ rb_unblock_function_t *func;
480
+ void *arg;
481
+ };
482
+
483
+ struct rb_mutex_struct;
484
+
485
+ struct rb_thread_struct;
486
+ typedef struct rb_thread_list_struct{
487
+ struct rb_thread_list_struct *next;
488
+ struct rb_thread_struct *th;
489
+ } rb_thread_list_t;
490
+
491
+
492
+ typedef struct rb_ensure_entry {
493
+ VALUE marker;
494
+ VALUE (*e_proc)(ANYARGS);
495
+ VALUE data2;
496
+ } rb_ensure_entry_t;
497
+
498
+ typedef struct rb_ensure_list {
499
+ struct rb_ensure_list *next;
500
+ struct rb_ensure_entry entry;
501
+ } rb_ensure_list_t;
502
+
503
+ typedef struct rb_thread_struct {
504
+ VALUE self;
505
+ rb_vm_t *vm;
506
+
507
+ /* execution information */
508
+ VALUE *stack; /* must free, must mark */
509
+ size_t stack_size; /* size in word (byte size / sizeof(VALUE)) */
510
+ rb_control_frame_t *cfp;
511
+ int safe_level;
512
+ int raised_flag;
513
+ VALUE last_status; /* $? */
514
+
515
+ /* passing state */
516
+ int state;
517
+
518
+ int waiting_fd;
519
+
520
+ /* for rb_iterate */
521
+ const rb_block_t *passed_block;
522
+
523
+ /* for bmethod */
524
+ const rb_method_entry_t *passed_me;
525
+
526
+ /* for cfunc */
527
+ rb_call_info_t *passed_ci;
528
+
529
+ /* for load(true) */
530
+ VALUE top_self;
531
+ VALUE top_wrapper;
532
+
533
+ /* eval env */
534
+ rb_block_t *base_block;
535
+
536
+ VALUE *root_lep;
537
+ VALUE root_svar;
538
+
539
+ /* thread control */
540
+ rb_nativethread_id_t thread_id;
541
+ enum rb_thread_status status;
542
+ int to_kill;
543
+ int priority;
544
+
545
+ native_thread_data_t native_thread_data;
546
+ void *blocking_region_buffer;
547
+
548
+ VALUE thgroup;
549
+ VALUE value;
550
+
551
+ /* temporary place of errinfo */
552
+ VALUE errinfo;
553
+
554
+ /* temporary place of retval on OPT_CALL_THREADED_CODE */
555
+ #if OPT_CALL_THREADED_CODE
556
+ VALUE retval;
557
+ #endif
558
+
559
+ /* async errinfo queue */
560
+ VALUE pending_interrupt_queue;
561
+ int pending_interrupt_queue_checked;
562
+ VALUE pending_interrupt_mask_stack;
563
+
564
+ rb_atomic_t interrupt_flag;
565
+ unsigned long interrupt_mask;
566
+ rb_nativethread_lock_t interrupt_lock;
567
+ rb_nativethread_cond_t interrupt_cond;
568
+ struct rb_unblock_callback unblock;
569
+ VALUE locking_mutex;
570
+ struct rb_mutex_struct *keeping_mutexes;
571
+
572
+ struct rb_vm_tag *tag;
573
+ struct rb_vm_protect_tag *protect_tag;
574
+
575
+ /*! Thread-local state of evaluation context.
576
+ *
577
+ * If negative, this thread is evaluating the main program.
578
+ * If positive, this thread is evaluating a program under Kernel::eval
579
+ * family.
580
+ */
581
+ int parse_in_eval;
582
+
583
+ /*! Thread-local state of compiling context.
584
+ *
585
+ * If non-zero, the parser does not automatically print error messages to
586
+ * stderr. */
587
+ int mild_compile_error;
588
+
589
+ /* storage */
590
+ st_table *local_storage;
591
+
592
+ rb_thread_list_t *join_list;
593
+
594
+ VALUE first_proc;
595
+ VALUE first_args;
596
+ VALUE (*first_func)(ANYARGS);
597
+
598
+ /* for GC */
599
+ struct {
600
+ VALUE *stack_start;
601
+ VALUE *stack_end;
602
+ size_t stack_maxsize;
603
+ #ifdef __ia64
604
+ VALUE *register_stack_start;
605
+ VALUE *register_stack_end;
606
+ size_t register_stack_maxsize;
607
+ #endif
608
+ jmp_buf regs;
609
+ } machine;
610
+ int mark_stack_len;
611
+
612
+ /* statistics data for profiler */
613
+ VALUE stat_insn_usage;
614
+
615
+ /* tracer */
616
+ rb_hook_list_t event_hooks;
617
+ struct rb_trace_arg_struct *trace_arg; /* trace information */
618
+
619
+ /* fiber */
620
+ VALUE fiber;
621
+ VALUE root_fiber;
622
+ rb_jmpbuf_t root_jmpbuf;
623
+
624
+ /* ensure & callcc */
625
+ rb_ensure_list_t *ensure_list;
626
+
627
+ /* misc */
628
+ int method_missing_reason;
629
+ int abort_on_exception;
630
+ #ifdef USE_SIGALTSTACK
631
+ void *altstack;
632
+ #endif
633
+ unsigned long running_time_us;
634
+ } rb_thread_t;
635
+
636
+ typedef enum {
637
+ VM_DEFINECLASS_TYPE_CLASS = 0x00,
638
+ VM_DEFINECLASS_TYPE_SINGLETON_CLASS = 0x01,
639
+ VM_DEFINECLASS_TYPE_MODULE = 0x02,
640
+ /* 0x03..0x06 is reserved */
641
+ VM_DEFINECLASS_TYPE_MASK = 0x07
642
+ } rb_vm_defineclass_type_t;
643
+
644
+ #define VM_DEFINECLASS_TYPE(x) ((rb_vm_defineclass_type_t)(x) & VM_DEFINECLASS_TYPE_MASK)
645
+ #define VM_DEFINECLASS_FLAG_SCOPED 0x08
646
+ #define VM_DEFINECLASS_FLAG_HAS_SUPERCLASS 0x10
647
+ #define VM_DEFINECLASS_SCOPED_P(x) ((x) & VM_DEFINECLASS_FLAG_SCOPED)
648
+ #define VM_DEFINECLASS_HAS_SUPERCLASS_P(x) \
649
+ ((x) & VM_DEFINECLASS_FLAG_HAS_SUPERCLASS)
650
+
651
+ /* iseq.c */
652
+ RUBY_SYMBOL_EXPORT_BEGIN
653
+
654
+ /* node -> iseq */
655
+ VALUE rb_iseq_new(NODE*, VALUE, VALUE, VALUE, VALUE, enum iseq_type);
656
+ VALUE rb_iseq_new_top(NODE *node, VALUE name, VALUE path, VALUE absolute_path, VALUE parent);
657
+ VALUE rb_iseq_new_main(NODE *node, VALUE path, VALUE absolute_path);
658
+ VALUE rb_iseq_new_with_bopt(NODE*, VALUE, VALUE, VALUE, VALUE, VALUE, enum iseq_type, VALUE);
659
+ VALUE rb_iseq_new_with_opt(NODE*, VALUE, VALUE, VALUE, VALUE, VALUE, enum iseq_type, const rb_compile_option_t*);
660
+
661
+ /* src -> iseq */
662
+ VALUE rb_iseq_compile(VALUE src, VALUE file, VALUE line);
663
+ VALUE rb_iseq_compile_on_base(VALUE src, VALUE file, VALUE line, rb_block_t *base_block);
664
+ VALUE rb_iseq_compile_with_option(VALUE src, VALUE file, VALUE absolute_path, VALUE line, rb_block_t *base_block, VALUE opt);
665
+
666
+ VALUE rb_iseq_disasm(VALUE self);
667
+ int rb_iseq_disasm_insn(VALUE str, VALUE *iseqval, size_t pos, rb_iseq_t *iseq, VALUE child);
668
+ const char *ruby_node_name(int node);
669
+
670
+ RUBY_EXTERN VALUE rb_cISeq;
671
+ RUBY_EXTERN VALUE rb_cRubyVM;
672
+ RUBY_EXTERN VALUE rb_cEnv;
673
+ RUBY_EXTERN VALUE rb_mRubyVMFrozenCore;
674
+ RUBY_SYMBOL_EXPORT_END
675
+
676
+ #define GetProcPtr(obj, ptr) \
677
+ GetCoreDataFromValue((obj), rb_proc_t, (ptr))
678
+
679
+ typedef struct {
680
+ rb_block_t block;
681
+
682
+ VALUE envval; /* for GC mark */
683
+ VALUE blockprocval;
684
+ int safe_level;
685
+ int is_from_method;
686
+ int is_lambda;
687
+ } rb_proc_t;
688
+
689
+ #define GetEnvPtr(obj, ptr) \
690
+ GetCoreDataFromValue((obj), rb_env_t, (ptr))
691
+
692
+ typedef struct {
693
+ VALUE *env;
694
+ int env_size;
695
+ int local_size;
696
+ VALUE prev_envval; /* for GC mark */
697
+ rb_block_t block;
698
+ } rb_env_t;
699
+
700
+ extern const rb_data_type_t ruby_binding_data_type;
701
+
702
+ #define GetBindingPtr(obj, ptr) \
703
+ GetCoreDataFromValue((obj), rb_binding_t, (ptr))
704
+
705
+ typedef struct {
706
+ VALUE env;
707
+ VALUE path;
708
+ unsigned short first_lineno;
709
+ } rb_binding_t;
710
+
711
+ /* used by compile time and send insn */
712
+
713
+ enum vm_check_match_type {
714
+ VM_CHECKMATCH_TYPE_WHEN = 1,
715
+ VM_CHECKMATCH_TYPE_CASE = 2,
716
+ VM_CHECKMATCH_TYPE_RESCUE = 3
717
+ };
718
+
719
+ #define VM_CHECKMATCH_TYPE_MASK 0x03
720
+ #define VM_CHECKMATCH_ARRAY 0x04
721
+
722
+ #define VM_CALL_ARGS_SPLAT (0x01 << 1) /* m(*args) */
723
+ #define VM_CALL_ARGS_BLOCKARG (0x01 << 2) /* m(&block) */
724
+ #define VM_CALL_FCALL (0x01 << 3) /* m(...) */
725
+ #define VM_CALL_VCALL (0x01 << 4) /* m */
726
+ #define VM_CALL_TAILCALL (0x01 << 5) /* located at tail position */
727
+ #define VM_CALL_SUPER (0x01 << 6) /* super */
728
+ #define VM_CALL_OPT_SEND (0x01 << 7) /* internal flag */
729
+ #define VM_CALL_ARGS_SKIP_SETUP (0x01 << 8) /* (flag & (SPLAT|BLOCKARG)) && blockiseq == 0 */
730
+
731
+ enum vm_special_object_type {
732
+ VM_SPECIAL_OBJECT_VMCORE = 1,
733
+ VM_SPECIAL_OBJECT_CBASE,
734
+ VM_SPECIAL_OBJECT_CONST_BASE
735
+ };
736
+
737
+ #define VM_FRAME_MAGIC_METHOD 0x11
738
+ #define VM_FRAME_MAGIC_BLOCK 0x21
739
+ #define VM_FRAME_MAGIC_CLASS 0x31
740
+ #define VM_FRAME_MAGIC_TOP 0x41
741
+ #define VM_FRAME_MAGIC_CFUNC 0x61
742
+ #define VM_FRAME_MAGIC_PROC 0x71
743
+ #define VM_FRAME_MAGIC_IFUNC 0x81
744
+ #define VM_FRAME_MAGIC_EVAL 0x91
745
+ #define VM_FRAME_MAGIC_LAMBDA 0xa1
746
+ #define VM_FRAME_MAGIC_MASK_BITS 8
747
+ #define VM_FRAME_MAGIC_MASK (~(~0<<VM_FRAME_MAGIC_MASK_BITS))
748
+
749
+ #define VM_FRAME_TYPE(cfp) ((cfp)->flag & VM_FRAME_MAGIC_MASK)
750
+
751
+ /* other frame flag */
752
+ #define VM_FRAME_FLAG_PASSED 0x0100
753
+ #define VM_FRAME_FLAG_FINISH 0x0200
754
+ #define VM_FRAME_TYPE_FINISH_P(cfp) (((cfp)->flag & VM_FRAME_FLAG_FINISH) != 0)
755
+
756
+ #define RUBYVM_CFUNC_FRAME_P(cfp) \
757
+ (VM_FRAME_TYPE(cfp) == VM_FRAME_MAGIC_CFUNC)
758
+
759
+ /* inline cache */
760
+ typedef struct iseq_inline_cache_entry *IC;
761
+ typedef rb_call_info_t *CALL_INFO;
762
+
763
+ void rb_vm_change_state(void);
764
+
765
+ typedef VALUE CDHASH;
766
+
767
+ #ifndef FUNC_FASTCALL
768
+ #define FUNC_FASTCALL(x) x
769
+ #endif
770
+
771
+ typedef rb_control_frame_t *
772
+ (FUNC_FASTCALL(*rb_insn_func_t))(rb_thread_t *, rb_control_frame_t *);
773
+
774
+ #define GC_GUARDED_PTR(p) ((VALUE)((VALUE)(p) | 0x01))
775
+ #define GC_GUARDED_PTR_REF(p) ((void *)(((VALUE)(p)) & ~0x03))
776
+ #define GC_GUARDED_PTR_P(p) (((VALUE)(p)) & 0x01)
777
+
778
+ /*
779
+ * block frame:
780
+ * ep[ 0]: prev frame
781
+ * ep[-1]: CREF (for *_eval)
782
+ *
783
+ * method frame:
784
+ * ep[ 0]: block pointer (ptr | VM_ENVVAL_BLOCK_PTR_FLAG)
785
+ */
786
+
787
+ #define VM_ENVVAL_BLOCK_PTR_FLAG 0x02
788
+ #define VM_ENVVAL_BLOCK_PTR(v) (GC_GUARDED_PTR(v) | VM_ENVVAL_BLOCK_PTR_FLAG)
789
+ #define VM_ENVVAL_BLOCK_PTR_P(v) ((v) & VM_ENVVAL_BLOCK_PTR_FLAG)
790
+ #define VM_ENVVAL_PREV_EP_PTR(v) ((VALUE)GC_GUARDED_PTR(v))
791
+ #define VM_ENVVAL_PREV_EP_PTR_P(v) (!(VM_ENVVAL_BLOCK_PTR_P(v)))
792
+
793
+ #define VM_EP_PREV_EP(ep) ((VALUE *)GC_GUARDED_PTR_REF((ep)[0]))
794
+ #define VM_EP_BLOCK_PTR(ep) ((rb_block_t *)GC_GUARDED_PTR_REF((ep)[0]))
795
+ #define VM_EP_LEP_P(ep) VM_ENVVAL_BLOCK_PTR_P((ep)[0])
796
+
797
+ VALUE *rb_vm_ep_local_ep(VALUE *ep);
798
+ rb_block_t *rb_vm_control_frame_block_ptr(rb_control_frame_t *cfp);
799
+
800
+ #define RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp) ((cfp)+1)
801
+ #define RUBY_VM_NEXT_CONTROL_FRAME(cfp) ((cfp)-1)
802
+ #define RUBY_VM_END_CONTROL_FRAME(th) \
803
+ ((rb_control_frame_t *)((th)->stack + (th)->stack_size))
804
+ #define RUBY_VM_VALID_CONTROL_FRAME_P(cfp, ecfp) \
805
+ ((void *)(ecfp) > (void *)(cfp))
806
+ #define RUBY_VM_CONTROL_FRAME_STACK_OVERFLOW_P(th, cfp) \
807
+ (!RUBY_VM_VALID_CONTROL_FRAME_P((cfp), RUBY_VM_END_CONTROL_FRAME(th)))
808
+
809
+ #define RUBY_VM_IFUNC_P(ptr) (BUILTIN_TYPE(ptr) == T_NODE)
810
+ #define RUBY_VM_NORMAL_ISEQ_P(ptr) \
811
+ ((ptr) && !RUBY_VM_IFUNC_P(ptr))
812
+
813
+ #define RUBY_VM_GET_BLOCK_PTR_IN_CFP(cfp) ((rb_block_t *)(&(cfp)->self))
814
+ #define RUBY_VM_GET_CFP_FROM_BLOCK_PTR(b) \
815
+ ((rb_control_frame_t *)((VALUE *)(b) - 4))
816
+ /* magic number `4' is depend on rb_control_frame_t layout. */
817
+
818
+ /* VM related object allocate functions */
819
+ VALUE rb_thread_alloc(VALUE klass);
820
+ VALUE rb_proc_alloc(VALUE klass);
821
+
822
+ /* for debug */
823
+ extern void rb_vmdebug_stack_dump_raw(rb_thread_t *, rb_control_frame_t *);
824
+ extern void rb_vmdebug_debug_print_pre(rb_thread_t *th, rb_control_frame_t *cfp, VALUE *_pc);
825
+ extern void rb_vmdebug_debug_print_post(rb_thread_t *th, rb_control_frame_t *cfp);
826
+
827
+ #define SDR() rb_vmdebug_stack_dump_raw(GET_THREAD(), GET_THREAD()->cfp)
828
+ #define SDR2(cfp) rb_vmdebug_stack_dump_raw(GET_THREAD(), (cfp))
829
+ void rb_vm_bugreport(void);
830
+
831
+ /* functions about thread/vm execution */
832
+ RUBY_SYMBOL_EXPORT_BEGIN
833
+ VALUE rb_iseq_eval(VALUE iseqval);
834
+ VALUE rb_iseq_eval_main(VALUE iseqval);
835
+ RUBY_SYMBOL_EXPORT_END
836
+ int rb_thread_method_id_and_class(rb_thread_t *th, ID *idp, VALUE *klassp);
837
+
838
+ VALUE rb_vm_invoke_proc(rb_thread_t *th, rb_proc_t *proc,
839
+ int argc, const VALUE *argv, const rb_block_t *blockptr);
840
+ VALUE rb_vm_make_proc(rb_thread_t *th, const rb_block_t *block, VALUE klass);
841
+ VALUE rb_vm_make_env_object(rb_thread_t *th, rb_control_frame_t *cfp);
842
+ VALUE rb_binding_new_with_cfp(rb_thread_t *th, const rb_control_frame_t *src_cfp);
843
+ VALUE *rb_binding_add_dynavars(rb_binding_t *bind, int dyncount, const ID *dynvars);
844
+ void rb_vm_inc_const_missing_count(void);
845
+ void rb_vm_gvl_destroy(rb_vm_t *vm);
846
+ VALUE rb_vm_call(rb_thread_t *th, VALUE recv, VALUE id, int argc,
847
+ const VALUE *argv, const rb_method_entry_t *me,
848
+ VALUE defined_class);
849
+ void rb_unlink_method_entry(rb_method_entry_t *me);
850
+ void rb_gc_mark_unlinked_live_method_entries(void *pvm);
851
+
852
+ void rb_thread_start_timer_thread(void);
853
+ void rb_thread_stop_timer_thread(int);
854
+ void rb_thread_reset_timer_thread(void);
855
+ void rb_thread_wakeup_timer_thread(void);
856
+
857
+ int ruby_thread_has_gvl_p(void);
858
+ typedef int rb_backtrace_iter_func(void *, VALUE, int, VALUE);
859
+ rb_control_frame_t *rb_vm_get_ruby_level_next_cfp(rb_thread_t *th, const rb_control_frame_t *cfp);
860
+ rb_control_frame_t *rb_vm_get_binding_creatable_next_cfp(rb_thread_t *th, const rb_control_frame_t *cfp);
861
+ int rb_vm_get_sourceline(const rb_control_frame_t *);
862
+ VALUE rb_name_err_mesg_new(VALUE obj, VALUE mesg, VALUE recv, VALUE method);
863
+ void rb_vm_stack_to_heap(rb_thread_t *th);
864
+ void ruby_thread_init_stack(rb_thread_t *th);
865
+ int rb_vm_control_frame_id_and_class(const rb_control_frame_t *cfp, ID *idp, VALUE *klassp);
866
+
867
+ void rb_gc_mark_machine_stack(rb_thread_t *th);
868
+
869
+ int rb_autoloading_value(VALUE mod, ID id, VALUE* value);
870
+
871
+ #define sysstack_error GET_VM()->special_exceptions[ruby_error_sysstack]
872
+
873
+ #define RUBY_CONST_ASSERT(expr) (1/!!(expr)) /* expr must be a compile-time constant */
874
+ #define VM_STACK_OVERFLOWED_P(cfp, sp, margin) \
875
+ (!RUBY_CONST_ASSERT(sizeof(*(sp)) == sizeof(VALUE)) || \
876
+ !RUBY_CONST_ASSERT(sizeof(*(cfp)) == sizeof(rb_control_frame_t)) || \
877
+ ((rb_control_frame_t *)((sp) + (margin)) + 1) >= (cfp))
878
+ #define WHEN_VM_STACK_OVERFLOWED(cfp, sp, margin) \
879
+ if (LIKELY(!VM_STACK_OVERFLOWED_P(cfp, sp, margin))) {(void)0;} else /* overflowed */
880
+ #define CHECK_VM_STACK_OVERFLOW0(cfp, sp, margin) \
881
+ WHEN_VM_STACK_OVERFLOWED(cfp, sp, margin) vm_stackoverflow()
882
+ #define CHECK_VM_STACK_OVERFLOW(cfp, margin) \
883
+ WHEN_VM_STACK_OVERFLOWED(cfp, (cfp)->sp, margin) vm_stackoverflow()
884
+
885
+ /* for thread */
886
+
887
+ #if RUBY_VM_THREAD_MODEL == 2
888
+ extern rb_thread_t *ruby_current_thread;
889
+ extern rb_vm_t *ruby_current_vm;
890
+ extern rb_event_flag_t ruby_vm_event_flags;
891
+
892
+ #define GET_VM() ruby_current_vm
893
+
894
+ #ifndef OPT_CALL_CFUNC_WITHOUT_FRAME
895
+ #define OPT_CALL_CFUNC_WITHOUT_FRAME 0
896
+ #endif
897
+
898
+ static inline rb_thread_t *
899
+ GET_THREAD(void)
900
+ {
901
+ rb_thread_t *th = ruby_current_thread;
902
+ #if OPT_CALL_CFUNC_WITHOUT_FRAME
903
+ if (UNLIKELY(th->passed_ci != 0)) {
904
+ void vm_call_cfunc_push_frame(rb_thread_t *th);
905
+ vm_call_cfunc_push_frame(th);
906
+ }
907
+ #endif
908
+ return th;
909
+ }
910
+
911
+ #define rb_thread_set_current_raw(th) (void)(ruby_current_thread = (th))
912
+ #define rb_thread_set_current(th) do { \
913
+ if ((th)->vm->running_thread != (th)) { \
914
+ (th)->running_time_us = 0; \
915
+ } \
916
+ rb_thread_set_current_raw(th); \
917
+ (th)->vm->running_thread = (th); \
918
+ } while (0)
919
+
920
+ #else
921
+ #error "unsupported thread model"
922
+ #endif
923
+
924
+ enum {
925
+ TIMER_INTERRUPT_MASK = 0x01,
926
+ PENDING_INTERRUPT_MASK = 0x02,
927
+ POSTPONED_JOB_INTERRUPT_MASK = 0x04,
928
+ TRAP_INTERRUPT_MASK = 0x08
929
+ };
930
+
931
+ #define RUBY_VM_SET_TIMER_INTERRUPT(th) ATOMIC_OR((th)->interrupt_flag, TIMER_INTERRUPT_MASK)
932
+ #define RUBY_VM_SET_INTERRUPT(th) ATOMIC_OR((th)->interrupt_flag, PENDING_INTERRUPT_MASK)
933
+ #define RUBY_VM_SET_POSTPONED_JOB_INTERRUPT(th) ATOMIC_OR((th)->interrupt_flag, POSTPONED_JOB_INTERRUPT_MASK)
934
+ #define RUBY_VM_SET_TRAP_INTERRUPT(th) ATOMIC_OR((th)->interrupt_flag, TRAP_INTERRUPT_MASK)
935
+ #define RUBY_VM_INTERRUPTED(th) ((th)->interrupt_flag & ~(th)->interrupt_mask & (PENDING_INTERRUPT_MASK|TRAP_INTERRUPT_MASK))
936
+ #define RUBY_VM_INTERRUPTED_ANY(th) ((th)->interrupt_flag & ~(th)->interrupt_mask)
937
+
938
+ int rb_signal_buff_size(void);
939
+ void rb_signal_exec(rb_thread_t *th, int sig);
940
+ void rb_threadptr_check_signal(rb_thread_t *mth);
941
+ void rb_threadptr_signal_raise(rb_thread_t *th, int sig);
942
+ void rb_threadptr_signal_exit(rb_thread_t *th);
943
+ void rb_threadptr_execute_interrupts(rb_thread_t *, int);
944
+ void rb_threadptr_interrupt(rb_thread_t *th);
945
+ void rb_threadptr_unlock_all_locking_mutexes(rb_thread_t *th);
946
+ void rb_threadptr_pending_interrupt_clear(rb_thread_t *th);
947
+ void rb_threadptr_pending_interrupt_enque(rb_thread_t *th, VALUE v);
948
+ int rb_threadptr_pending_interrupt_active_p(rb_thread_t *th);
949
+
950
+ #define RUBY_VM_CHECK_INTS_BLOCKING(th) do { \
951
+ if (UNLIKELY(!rb_threadptr_pending_interrupt_empty_p(th))) { \
952
+ th->pending_interrupt_queue_checked = 0; \
953
+ RUBY_VM_SET_INTERRUPT(th); \
954
+ rb_threadptr_execute_interrupts(th, 1); \
955
+ } \
956
+ else if (UNLIKELY(RUBY_VM_INTERRUPTED_ANY(th))) { \
957
+ rb_threadptr_execute_interrupts(th, 1); \
958
+ } \
959
+ } while (0)
960
+
961
+ #define RUBY_VM_CHECK_INTS(th) do { \
962
+ if (UNLIKELY(RUBY_VM_INTERRUPTED_ANY(th))) { \
963
+ rb_threadptr_execute_interrupts(th, 0); \
964
+ } \
965
+ } while (0)
966
+
967
+ /* tracer */
968
+ struct rb_trace_arg_struct {
969
+ rb_event_flag_t event;
970
+ rb_thread_t *th;
971
+ rb_control_frame_t *cfp;
972
+ VALUE self;
973
+ ID id;
974
+ VALUE klass;
975
+ VALUE data;
976
+
977
+ int klass_solved;
978
+
979
+ /* calc from cfp */
980
+ int lineno;
981
+ VALUE path;
982
+ };
983
+
984
+ void rb_threadptr_exec_event_hooks(struct rb_trace_arg_struct *trace_arg);
985
+ void rb_threadptr_exec_event_hooks_and_pop_frame(struct rb_trace_arg_struct *trace_arg);
986
+
987
+ #define EXEC_EVENT_HOOK_ORIG(th_, flag_, self_, id_, klass_, data_, pop_p_) do { \
988
+ if (UNLIKELY(ruby_vm_event_flags & (flag_))) { \
989
+ if (((th)->event_hooks.events | (th)->vm->event_hooks.events) & (flag_)) { \
990
+ struct rb_trace_arg_struct trace_arg; \
991
+ trace_arg.event = (flag_); \
992
+ trace_arg.th = (th_); \
993
+ trace_arg.cfp = (trace_arg.th)->cfp; \
994
+ trace_arg.self = (self_); \
995
+ trace_arg.id = (id_); \
996
+ trace_arg.klass = (klass_); \
997
+ trace_arg.data = (data_); \
998
+ trace_arg.path = Qundef; \
999
+ trace_arg.klass_solved = 0; \
1000
+ if (pop_p_) rb_threadptr_exec_event_hooks_and_pop_frame(&trace_arg); \
1001
+ else rb_threadptr_exec_event_hooks(&trace_arg); \
1002
+ } \
1003
+ } \
1004
+ } while (0)
1005
+
1006
+ #define EXEC_EVENT_HOOK(th_, flag_, self_, id_, klass_, data_) \
1007
+ EXEC_EVENT_HOOK_ORIG(th_, flag_, self_, id_, klass_, data_, 0)
1008
+
1009
+ #define EXEC_EVENT_HOOK_AND_POP_FRAME(th_, flag_, self_, id_, klass_, data_) \
1010
+ EXEC_EVENT_HOOK_ORIG(th_, flag_, self_, id_, klass_, data_, 1)
1011
+
1012
+ RUBY_SYMBOL_EXPORT_BEGIN
1013
+
1014
+ int rb_thread_check_trap_pending(void);
1015
+
1016
+ extern VALUE rb_get_coverages(void);
1017
+ extern void rb_set_coverages(VALUE);
1018
+ extern void rb_reset_coverages(void);
1019
+
1020
+ void rb_postponed_job_flush(rb_vm_t *vm);
1021
+
1022
+ RUBY_SYMBOL_EXPORT_END
1023
+
1024
+ #endif /* RUBY_VM_CORE_H */