debase-ruby_core_source 0.10.5 → 0.10.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +5 -0
  3. data/lib/debase/ruby_core_source.rb +1 -1
  4. data/lib/debase/ruby_core_source/ruby-2.6.5-p114/addr2line.h +21 -0
  5. data/lib/debase/ruby_core_source/ruby-2.6.5-p114/ccan/build_assert/build_assert.h +40 -0
  6. data/lib/debase/ruby_core_source/ruby-2.6.5-p114/ccan/check_type/check_type.h +63 -0
  7. data/lib/debase/ruby_core_source/ruby-2.6.5-p114/ccan/container_of/container_of.h +142 -0
  8. data/lib/debase/ruby_core_source/ruby-2.6.5-p114/ccan/list/list.h +788 -0
  9. data/lib/debase/ruby_core_source/ruby-2.6.5-p114/ccan/str/str.h +16 -0
  10. data/lib/debase/ruby_core_source/ruby-2.6.5-p114/constant.h +51 -0
  11. data/lib/debase/ruby_core_source/ruby-2.6.5-p114/debug_counter.h +283 -0
  12. data/lib/debase/ruby_core_source/ruby-2.6.5-p114/dln.h +51 -0
  13. data/lib/debase/ruby_core_source/ruby-2.6.5-p114/encindex.h +69 -0
  14. data/lib/debase/ruby_core_source/ruby-2.6.5-p114/eval_intern.h +333 -0
  15. data/lib/debase/ruby_core_source/ruby-2.6.5-p114/gc.h +116 -0
  16. data/lib/debase/ruby_core_source/ruby-2.6.5-p114/hrtime.h +168 -0
  17. data/lib/debase/ruby_core_source/ruby-2.6.5-p114/id.h +252 -0
  18. data/lib/debase/ruby_core_source/ruby-2.6.5-p114/id_table.h +31 -0
  19. data/lib/debase/ruby_core_source/ruby-2.6.5-p114/insns.inc +249 -0
  20. data/lib/debase/ruby_core_source/ruby-2.6.5-p114/insns_info.inc +9374 -0
  21. data/lib/debase/ruby_core_source/ruby-2.6.5-p114/internal.h +2470 -0
  22. data/lib/debase/ruby_core_source/ruby-2.6.5-p114/iseq.h +304 -0
  23. data/lib/debase/ruby_core_source/ruby-2.6.5-p114/known_errors.inc +791 -0
  24. data/lib/debase/ruby_core_source/ruby-2.6.5-p114/method.h +229 -0
  25. data/lib/debase/ruby_core_source/ruby-2.6.5-p114/mjit.h +148 -0
  26. data/lib/debase/ruby_core_source/ruby-2.6.5-p114/mjit_compile.inc +4226 -0
  27. data/lib/debase/ruby_core_source/ruby-2.6.5-p114/node.h +449 -0
  28. data/lib/debase/ruby_core_source/ruby-2.6.5-p114/node_name.inc +200 -0
  29. data/lib/debase/ruby_core_source/ruby-2.6.5-p114/opt_sc.inc +109 -0
  30. data/lib/debase/ruby_core_source/ruby-2.6.5-p114/optinsn.inc +128 -0
  31. data/lib/debase/ruby_core_source/ruby-2.6.5-p114/optunifs.inc +43 -0
  32. data/lib/debase/ruby_core_source/ruby-2.6.5-p114/parse.h +207 -0
  33. data/lib/debase/ruby_core_source/ruby-2.6.5-p114/probes_helper.h +42 -0
  34. data/lib/debase/ruby_core_source/ruby-2.6.5-p114/regenc.h +254 -0
  35. data/lib/debase/ruby_core_source/ruby-2.6.5-p114/regint.h +938 -0
  36. data/lib/debase/ruby_core_source/ruby-2.6.5-p114/regparse.h +370 -0
  37. data/lib/debase/ruby_core_source/ruby-2.6.5-p114/revision.h +1 -0
  38. data/lib/debase/ruby_core_source/ruby-2.6.5-p114/ruby_assert.h +60 -0
  39. data/lib/debase/ruby_core_source/ruby-2.6.5-p114/ruby_atomic.h +244 -0
  40. data/lib/debase/ruby_core_source/ruby-2.6.5-p114/siphash.h +48 -0
  41. data/lib/debase/ruby_core_source/ruby-2.6.5-p114/symbol.h +112 -0
  42. data/lib/debase/ruby_core_source/ruby-2.6.5-p114/thread_pthread.h +75 -0
  43. data/lib/debase/ruby_core_source/ruby-2.6.5-p114/thread_win32.h +36 -0
  44. data/lib/debase/ruby_core_source/ruby-2.6.5-p114/timev.h +53 -0
  45. data/lib/debase/ruby_core_source/ruby-2.6.5-p114/transcode_data.h +139 -0
  46. data/lib/debase/ruby_core_source/ruby-2.6.5-p114/transient_heap.h +60 -0
  47. data/lib/debase/ruby_core_source/ruby-2.6.5-p114/version.h +73 -0
  48. data/lib/debase/ruby_core_source/ruby-2.6.5-p114/vm.inc +4504 -0
  49. data/lib/debase/ruby_core_source/ruby-2.6.5-p114/vm_call_iseq_optimized.inc +213 -0
  50. data/lib/debase/ruby_core_source/ruby-2.6.5-p114/vm_core.h +1910 -0
  51. data/lib/debase/ruby_core_source/ruby-2.6.5-p114/vm_debug.h +37 -0
  52. data/lib/debase/ruby_core_source/ruby-2.6.5-p114/vm_exec.h +202 -0
  53. data/lib/debase/ruby_core_source/ruby-2.6.5-p114/vm_insnhelper.h +316 -0
  54. data/lib/debase/ruby_core_source/ruby-2.6.5-p114/vm_opts.h +70 -0
  55. data/lib/debase/ruby_core_source/ruby-2.6.5-p114/vmtc.inc +243 -0
  56. data/lib/debase/ruby_core_source/version.rb +1 -1
  57. metadata +55 -3
@@ -0,0 +1,37 @@
1
+ /**********************************************************************
2
+
3
+ vm_debug.h - YARV Debug function interface
4
+
5
+ $Author: nobu $
6
+ created at: 04/08/25 02:33:49 JST
7
+
8
+ Copyright (C) 2004-2007 Koichi Sasada
9
+
10
+ **********************************************************************/
11
+
12
+ #ifndef RUBY_DEBUG_H
13
+ #define RUBY_DEBUG_H
14
+
15
+ #include "ruby/ruby.h"
16
+ #include "node.h"
17
+
18
+ RUBY_SYMBOL_EXPORT_BEGIN
19
+
20
+ #define dpv(h,v) ruby_debug_print_value(-1, 0, (h), (v))
21
+ #define dp(v) ruby_debug_print_value(-1, 0, "", (v))
22
+ #define dpi(i) ruby_debug_print_id(-1, 0, "", (i))
23
+ #define dpn(n) ruby_debug_print_node(-1, 0, "", (n))
24
+
25
+ #define bp() ruby_debug_breakpoint()
26
+
27
+ VALUE ruby_debug_print_value(int level, int debug_level, const char *header, VALUE v);
28
+ ID ruby_debug_print_id(int level, int debug_level, const char *header, ID id);
29
+ NODE *ruby_debug_print_node(int level, int debug_level, const char *header, const NODE *node);
30
+ int ruby_debug_print_indent(int level, int debug_level, int indent_level);
31
+ void ruby_debug_breakpoint(void);
32
+ void ruby_debug_gc_check_func(void);
33
+ void ruby_set_debug_option(const char *str);
34
+
35
+ RUBY_SYMBOL_EXPORT_END
36
+
37
+ #endif /* RUBY_DEBUG_H */
@@ -0,0 +1,202 @@
1
+ /**********************************************************************
2
+
3
+ vm.h -
4
+
5
+ $Author: ko1 $
6
+ created at: 04/01/01 16:56:59 JST
7
+
8
+ Copyright (C) 2004-2007 Koichi Sasada
9
+
10
+ **********************************************************************/
11
+
12
+ #ifndef RUBY_VM_EXEC_H
13
+ #define RUBY_VM_EXEC_H
14
+
15
+ typedef long OFFSET;
16
+ typedef unsigned long lindex_t;
17
+ typedef VALUE GENTRY;
18
+ typedef rb_iseq_t *ISEQ;
19
+
20
+ #ifdef __GCC__
21
+ /* TODO: machine dependent prefetch instruction */
22
+ #define PREFETCH(pc)
23
+ #else
24
+ #define PREFETCH(pc)
25
+ #endif
26
+
27
+ #if VMDEBUG > 0
28
+ #define debugs printf
29
+ #define DEBUG_ENTER_INSN(insn) \
30
+ rb_vmdebug_debug_print_pre(ec, GET_CFP(), GET_PC());
31
+
32
+ #if OPT_STACK_CACHING
33
+ #define SC_REGS() , reg_a, reg_b
34
+ #else
35
+ #define SC_REGS()
36
+ #endif
37
+
38
+ #define DEBUG_END_INSN() \
39
+ rb_vmdebug_debug_print_post(ec, GET_CFP() SC_REGS());
40
+
41
+ #else
42
+
43
+ #define debugs
44
+ #define DEBUG_ENTER_INSN(insn)
45
+ #define DEBUG_END_INSN()
46
+ #endif
47
+
48
+ #define throwdebug if(0)printf
49
+ /* #define throwdebug printf */
50
+
51
+ /************************************************/
52
+ #if defined(DISPATCH_XXX)
53
+ error !
54
+ /************************************************/
55
+ #elif OPT_CALL_THREADED_CODE
56
+
57
+ #define LABEL(x) insn_func_##x
58
+ #define ELABEL(x)
59
+ #define LABEL_PTR(x) &LABEL(x)
60
+
61
+ #define INSN_ENTRY(insn) \
62
+ static rb_control_frame_t * \
63
+ FUNC_FASTCALL(LABEL(insn))(rb_execution_context_t *ec, rb_control_frame_t *reg_cfp) {
64
+
65
+ #define END_INSN(insn) return reg_cfp;}
66
+
67
+ #define NEXT_INSN() return reg_cfp;
68
+
69
+ #define START_OF_ORIGINAL_INSN(x) /* ignore */
70
+ #define DISPATCH_ORIGINAL_INSN(x) return LABEL(x)(ec, reg_cfp);
71
+
72
+ /************************************************/
73
+ #elif OPT_TOKEN_THREADED_CODE || OPT_DIRECT_THREADED_CODE
74
+ /* threaded code with gcc */
75
+
76
+ #define LABEL(x) INSN_LABEL_##x
77
+ #define ELABEL(x) INSN_ELABEL_##x
78
+ #define LABEL_PTR(x) RB_GNUC_EXTENSION(&&LABEL(x))
79
+
80
+ #define INSN_ENTRY_SIG(insn) \
81
+ if (0) fprintf(stderr, "exec: %s@(%d, %d)@%s:%d\n", #insn, \
82
+ (int)(reg_pc - reg_cfp->iseq->body->iseq_encoded), \
83
+ (int)(reg_cfp->pc - reg_cfp->iseq->body->iseq_encoded), \
84
+ RSTRING_PTR(rb_iseq_path(reg_cfp->iseq)), \
85
+ (int)(rb_iseq_line_no(reg_cfp->iseq, reg_pc - reg_cfp->iseq->body->iseq_encoded)));
86
+
87
+ #define INSN_DISPATCH_SIG(insn)
88
+
89
+ #define INSN_ENTRY(insn) \
90
+ LABEL(insn): \
91
+ INSN_ENTRY_SIG(insn); \
92
+
93
+ /* dispatcher */
94
+ #if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__)) && __GNUC__ == 3
95
+ #define DISPATCH_ARCH_DEPEND_WAY(addr) \
96
+ __asm__ __volatile__("jmp *%0;\t# -- inserted by vm.h\t[length = 2]" : : "r" (addr))
97
+
98
+ #else
99
+ #define DISPATCH_ARCH_DEPEND_WAY(addr) \
100
+ /* do nothing */
101
+ #endif
102
+
103
+ /**********************************/
104
+ #if OPT_DIRECT_THREADED_CODE
105
+
106
+ /* for GCC 3.4.x */
107
+ #define TC_DISPATCH(insn) \
108
+ INSN_DISPATCH_SIG(insn); \
109
+ RB_GNUC_EXTENSION_BLOCK(goto *(void const *)GET_CURRENT_INSN()); \
110
+ ;
111
+
112
+ #else
113
+ /* token threaded code */
114
+
115
+ #define TC_DISPATCH(insn) \
116
+ DISPATCH_ARCH_DEPEND_WAY(insns_address_table[GET_CURRENT_INSN()]); \
117
+ INSN_DISPATCH_SIG(insn); \
118
+ RB_GNUC_EXTENSION_BLOCK(goto *insns_address_table[GET_CURRENT_INSN()]); \
119
+ rb_bug("tc error");
120
+
121
+
122
+ #endif /* DISPATCH_DIRECT_THREADED_CODE */
123
+
124
+ #define END_INSN(insn) \
125
+ DEBUG_END_INSN(); \
126
+ TC_DISPATCH(insn);
127
+
128
+ #define INSN_DISPATCH() \
129
+ TC_DISPATCH(__START__) \
130
+ {
131
+
132
+ #define END_INSNS_DISPATCH() \
133
+ rb_bug("unknown insn: %"PRIdVALUE, GET_CURRENT_INSN()); \
134
+ } /* end of while loop */ \
135
+
136
+ #define NEXT_INSN() TC_DISPATCH(__NEXT_INSN__)
137
+
138
+ #define START_OF_ORIGINAL_INSN(x) start_of_##x:
139
+ #define DISPATCH_ORIGINAL_INSN(x) goto start_of_##x;
140
+
141
+ /************************************************/
142
+ #else /* no threaded code */
143
+ /* most common method */
144
+
145
+ #define INSN_ENTRY(insn) \
146
+ case BIN(insn):
147
+
148
+ #define END_INSN(insn) \
149
+ DEBUG_END_INSN(); \
150
+ break;
151
+
152
+ #define INSN_DISPATCH() \
153
+ while (1) { \
154
+ switch (GET_CURRENT_INSN()) {
155
+
156
+ #define END_INSNS_DISPATCH() \
157
+ default: \
158
+ SDR(); \
159
+ rb_bug("unknown insn: %ld", GET_CURRENT_INSN()); \
160
+ } /* end of switch */ \
161
+ } /* end of while loop */ \
162
+
163
+ #define NEXT_INSN() goto first
164
+
165
+ #define START_OF_ORIGINAL_INSN(x) start_of_##x:
166
+ #define DISPATCH_ORIGINAL_INSN(x) goto start_of_##x;
167
+
168
+ #endif
169
+
170
+ #define VM_SP_CNT(ec, sp) ((sp) - (ec)->vm_stack)
171
+
172
+ #ifdef MJIT_HEADER
173
+ #define THROW_EXCEPTION(exc) do { \
174
+ ec->errinfo = (VALUE)(exc); \
175
+ EC_JUMP_TAG(ec, ec->tag->state); \
176
+ } while (0)
177
+ #else
178
+ #if OPT_CALL_THREADED_CODE
179
+ #define THROW_EXCEPTION(exc) do { \
180
+ ec->errinfo = (VALUE)(exc); \
181
+ return 0; \
182
+ } while (0)
183
+ #else
184
+ #define THROW_EXCEPTION(exc) return (VALUE)(exc)
185
+ #endif
186
+ #endif
187
+
188
+ #define SCREG(r) (reg_##r)
189
+
190
+ #define VM_DEBUG_STACKOVERFLOW 0
191
+
192
+ #if VM_DEBUG_STACKOVERFLOW
193
+ #define CHECK_VM_STACK_OVERFLOW_FOR_INSN(cfp, margin) \
194
+ WHEN_VM_STACK_OVERFLOWED(cfp, (cfp)->sp, margin) vm_stack_overflow_for_insn()
195
+ #else
196
+ #define CHECK_VM_STACK_OVERFLOW_FOR_INSN(cfp, margin)
197
+ #endif
198
+
199
+ #define INSN_LABEL2(insn, name) INSN_LABEL_ ## insn ## _ ## name
200
+ #define INSN_LABEL(x) INSN_LABEL2(NAME_OF_CURRENT_INSN, x)
201
+
202
+ #endif /* RUBY_VM_EXEC_H */
@@ -0,0 +1,316 @@
1
+ /**********************************************************************
2
+
3
+ insnhelper.h - helper macros to implement each instructions
4
+
5
+ $Author: k0kubun $
6
+ created at: 04/01/01 15:50:34 JST
7
+
8
+ Copyright (C) 2004-2007 Koichi Sasada
9
+
10
+ **********************************************************************/
11
+
12
+ #ifndef RUBY_INSNHELPER_H
13
+ #define RUBY_INSNHELPER_H
14
+
15
+ RUBY_SYMBOL_EXPORT_BEGIN
16
+
17
+ RUBY_EXTERN VALUE ruby_vm_const_missing_count;
18
+ RUBY_EXTERN rb_serial_t ruby_vm_global_method_state;
19
+ RUBY_EXTERN rb_serial_t ruby_vm_global_constant_state;
20
+ RUBY_EXTERN rb_serial_t ruby_vm_class_serial;
21
+
22
+ RUBY_SYMBOL_EXPORT_END
23
+
24
+ #if VM_COLLECT_USAGE_DETAILS
25
+ #define COLLECT_USAGE_INSN(insn) vm_collect_usage_insn(insn)
26
+ #define COLLECT_USAGE_OPERAND(insn, n, op) vm_collect_usage_operand((insn), (n), ((VALUE)(op)))
27
+
28
+ #define COLLECT_USAGE_REGISTER(reg, s) vm_collect_usage_register((reg), (s))
29
+ #else
30
+ #define COLLECT_USAGE_INSN(insn) /* none */
31
+ #define COLLECT_USAGE_OPERAND(insn, n, op) /* none */
32
+ #define COLLECT_USAGE_REGISTER(reg, s) /* none */
33
+ #endif
34
+
35
+ /**********************************************************/
36
+ /* deal with stack */
37
+ /**********************************************************/
38
+
39
+ static inline int
40
+ rb_obj_hidden_p(VALUE obj)
41
+ {
42
+ if (SPECIAL_CONST_P(obj)) {
43
+ return FALSE;
44
+ }
45
+ else {
46
+ return RBASIC_CLASS(obj) ? FALSE : TRUE;
47
+ }
48
+ }
49
+
50
+ #define PUSH(x) (SET_SV(x), INC_SP(1))
51
+ #define TOPN(n) (*(GET_SP()-(n)-1))
52
+ #define POPN(n) (DEC_SP(n))
53
+ #define POP() (DEC_SP(1))
54
+ #define STACK_ADDR_FROM_TOP(n) (GET_SP()-(n))
55
+
56
+ #define GET_TOS() (tos) /* dummy */
57
+
58
+ /**********************************************************/
59
+ /* deal with registers */
60
+ /**********************************************************/
61
+
62
+ #define VM_REG_CFP (reg_cfp)
63
+ #define VM_REG_PC (VM_REG_CFP->pc)
64
+ #define VM_REG_SP (VM_REG_CFP->sp)
65
+ #define VM_REG_EP (VM_REG_CFP->ep)
66
+
67
+ #define RESTORE_REGS() do { \
68
+ VM_REG_CFP = ec->cfp; \
69
+ } while (0)
70
+
71
+ #define REG_A reg_a
72
+ #define REG_B reg_b
73
+
74
+ enum vm_regan_regtype {
75
+ VM_REGAN_PC = 0,
76
+ VM_REGAN_SP = 1,
77
+ VM_REGAN_EP = 2,
78
+ VM_REGAN_CFP = 3,
79
+ VM_REGAN_SELF = 4,
80
+ VM_REGAN_ISEQ = 5
81
+ };
82
+ enum vm_regan_acttype {
83
+ VM_REGAN_ACT_GET = 0,
84
+ VM_REGAN_ACT_SET = 1
85
+ };
86
+
87
+ #if VM_COLLECT_USAGE_DETAILS
88
+ #define COLLECT_USAGE_REGISTER_HELPER(a, b, v) \
89
+ (COLLECT_USAGE_REGISTER((VM_REGAN_##a), (VM_REGAN_ACT_##b)), (v))
90
+ #else
91
+ #define COLLECT_USAGE_REGISTER_HELPER(a, b, v) (v)
92
+ #endif
93
+
94
+ /* PC */
95
+ #define GET_PC() (COLLECT_USAGE_REGISTER_HELPER(PC, GET, VM_REG_PC))
96
+ #define SET_PC(x) (VM_REG_PC = (COLLECT_USAGE_REGISTER_HELPER(PC, SET, (x))))
97
+ #define GET_CURRENT_INSN() (*GET_PC())
98
+ #define GET_OPERAND(n) (GET_PC()[(n)])
99
+ #define ADD_PC(n) (SET_PC(VM_REG_PC + (n)))
100
+ #define JUMP(dst) (SET_PC(VM_REG_PC + (dst)))
101
+
102
+ /* frame pointer, environment pointer */
103
+ #define GET_CFP() (COLLECT_USAGE_REGISTER_HELPER(CFP, GET, VM_REG_CFP))
104
+ #define GET_EP() (COLLECT_USAGE_REGISTER_HELPER(EP, GET, VM_REG_EP))
105
+ #define SET_EP(x) (VM_REG_EP = (COLLECT_USAGE_REGISTER_HELPER(EP, SET, (x))))
106
+ #define GET_LEP() (VM_EP_LEP(GET_EP()))
107
+
108
+ /* SP */
109
+ #define GET_SP() (COLLECT_USAGE_REGISTER_HELPER(SP, GET, VM_REG_SP))
110
+ #define SET_SP(x) (VM_REG_SP = (COLLECT_USAGE_REGISTER_HELPER(SP, SET, (x))))
111
+ #define INC_SP(x) (VM_REG_SP += (COLLECT_USAGE_REGISTER_HELPER(SP, SET, (x))))
112
+ #define DEC_SP(x) (VM_REG_SP -= (COLLECT_USAGE_REGISTER_HELPER(SP, SET, (x))))
113
+ #define SET_SV(x) (*GET_SP() = (x))
114
+ /* set current stack value as x */
115
+
116
+ /* instruction sequence C struct */
117
+ #define GET_ISEQ() (GET_CFP()->iseq)
118
+
119
+ /**********************************************************/
120
+ /* deal with variables */
121
+ /**********************************************************/
122
+
123
+ #define GET_PREV_EP(ep) ((VALUE *)((ep)[VM_ENV_DATA_INDEX_SPECVAL] & ~0x03))
124
+
125
+ #define GET_GLOBAL(entry) rb_gvar_get((struct rb_global_entry*)(entry))
126
+ #define SET_GLOBAL(entry, val) rb_gvar_set((struct rb_global_entry*)(entry), (val))
127
+
128
+ #define GET_CONST_INLINE_CACHE(dst) ((IC) * (GET_PC() + (dst) + 2))
129
+
130
+ /**********************************************************/
131
+ /* deal with values */
132
+ /**********************************************************/
133
+
134
+ #define GET_SELF() (COLLECT_USAGE_REGISTER_HELPER(SELF, GET, GET_CFP()->self))
135
+
136
+ /**********************************************************/
137
+ /* deal with control flow 2: method/iterator */
138
+ /**********************************************************/
139
+
140
+ #ifdef MJIT_HEADER
141
+ /* When calling ISeq which may catch an exception from JIT-ed code, we should not call
142
+ mjit_exec directly to prevent the caller frame from being canceled. That's because
143
+ the caller frame may have stack values in the local variables and the cancelling
144
+ the caller frame will purge them. But directly calling mjit_exec is faster... */
145
+ #define EXEC_EC_CFP(val) do { \
146
+ if (ec->cfp->iseq->body->catch_except_p) { \
147
+ VM_ENV_FLAGS_SET(ec->cfp->ep, VM_FRAME_FLAG_FINISH); \
148
+ val = vm_exec(ec, TRUE); \
149
+ } \
150
+ else if ((val = mjit_exec(ec)) == Qundef) { \
151
+ VM_ENV_FLAGS_SET(ec->cfp->ep, VM_FRAME_FLAG_FINISH); \
152
+ val = vm_exec(ec, FALSE); \
153
+ } \
154
+ } while (0)
155
+ #else
156
+ /* When calling from VM, longjmp in the callee won't purge any JIT-ed caller frames.
157
+ So it's safe to directly call mjit_exec. */
158
+ #define EXEC_EC_CFP(val) do { \
159
+ if ((val = mjit_exec(ec)) == Qundef) { \
160
+ RESTORE_REGS(); \
161
+ NEXT_INSN(); \
162
+ } \
163
+ } while (0)
164
+ #endif
165
+
166
+ #define CALL_METHOD(calling, ci, cc) do { \
167
+ VALUE v = (*(cc)->call)(ec, GET_CFP(), (calling), (ci), (cc)); \
168
+ if (v == Qundef) { \
169
+ EXEC_EC_CFP(val); \
170
+ } \
171
+ else { \
172
+ val = v; \
173
+ } \
174
+ } while (0)
175
+
176
+ /* set fastpath when cached method is *NOT* protected
177
+ * because inline method cache does not care about receiver.
178
+ */
179
+
180
+ #define CC_SET_FASTPATH(cc, func, enabled) do { \
181
+ if (LIKELY(enabled)) ((cc)->call = (func)); \
182
+ } while (0)
183
+
184
+ #define GET_BLOCK_HANDLER() (GET_LEP()[VM_ENV_DATA_INDEX_SPECVAL])
185
+
186
+ /**********************************************************/
187
+ /* deal with control flow 3: exception */
188
+ /**********************************************************/
189
+
190
+
191
+ /**********************************************************/
192
+ /* deal with stack canary */
193
+ /**********************************************************/
194
+
195
+ #if VM_CHECK_MODE > 0
196
+ #define SETUP_CANARY() \
197
+ if (leaf) { \
198
+ canary = GET_SP(); \
199
+ SET_SV(vm_stack_canary); \
200
+ }
201
+ #define CHECK_CANARY() \
202
+ if (leaf && (*canary != vm_stack_canary)) { \
203
+ vm_canary_is_found_dead(INSN_ATTR(bin), *canary); \
204
+ }
205
+ #else
206
+ #define SETUP_CANARY() /* void */
207
+ #define CHECK_CANARY() /* void */
208
+ #endif
209
+
210
+ /**********************************************************/
211
+ /* others */
212
+ /**********************************************************/
213
+
214
+ /* optimize insn */
215
+ #define FIXNUM_2_P(a, b) ((a) & (b) & 1)
216
+ #if USE_FLONUM
217
+ #define FLONUM_2_P(a, b) (((((a)^2) | ((b)^2)) & 3) == 0) /* (FLONUM_P(a) && FLONUM_P(b)) */
218
+ #else
219
+ #define FLONUM_2_P(a, b) 0
220
+ #endif
221
+ #define FLOAT_HEAP_P(x) (!SPECIAL_CONST_P(x) && RBASIC_CLASS(x) == rb_cFloat)
222
+ #define FLOAT_INSTANCE_P(x) (FLONUM_P(x) || FLOAT_HEAP_P(x))
223
+
224
+ #ifndef USE_IC_FOR_SPECIALIZED_METHOD
225
+ #define USE_IC_FOR_SPECIALIZED_METHOD 1
226
+ #endif
227
+
228
+ #ifndef MJIT_HEADER
229
+ #define CALL_SIMPLE_METHOD() do { \
230
+ rb_snum_t x = leaf ? INSN_ATTR(width) : 0; \
231
+ rb_snum_t y = attr_width_opt_send_without_block(0, 0); \
232
+ rb_snum_t z = x - y; \
233
+ ADD_PC(z); \
234
+ DISPATCH_ORIGINAL_INSN(opt_send_without_block); \
235
+ } while (0)
236
+ #endif
237
+
238
+ #define NEXT_CLASS_SERIAL() (++ruby_vm_class_serial)
239
+ #define GET_GLOBAL_METHOD_STATE() (ruby_vm_global_method_state)
240
+ #define INC_GLOBAL_METHOD_STATE() (++ruby_vm_global_method_state)
241
+ #define GET_GLOBAL_CONSTANT_STATE() (ruby_vm_global_constant_state)
242
+ #define INC_GLOBAL_CONSTANT_STATE() (++ruby_vm_global_constant_state)
243
+
244
+ extern rb_method_definition_t *rb_method_definition_create(rb_method_type_t type, ID mid);
245
+ extern void rb_method_definition_set(const rb_method_entry_t *me, rb_method_definition_t *def, void *opts);
246
+ extern int rb_method_definition_eq(const rb_method_definition_t *d1, const rb_method_definition_t *d2);
247
+
248
+ extern VALUE rb_make_no_method_exception(VALUE exc, VALUE format, VALUE obj,
249
+ int argc, const VALUE *argv, int priv);
250
+
251
+ static inline struct vm_throw_data *
252
+ THROW_DATA_NEW(VALUE val, const rb_control_frame_t *cf, VALUE st)
253
+ {
254
+ return (struct vm_throw_data *)rb_imemo_new(imemo_throw_data, val, (VALUE)cf, st, 0);
255
+ }
256
+
257
+ static inline VALUE
258
+ THROW_DATA_VAL(const struct vm_throw_data *obj)
259
+ {
260
+ VM_ASSERT(THROW_DATA_P(obj));
261
+ return obj->throw_obj;
262
+ }
263
+
264
+ static inline const rb_control_frame_t *
265
+ THROW_DATA_CATCH_FRAME(const struct vm_throw_data *obj)
266
+ {
267
+ VM_ASSERT(THROW_DATA_P(obj));
268
+ return obj->catch_frame;
269
+ }
270
+
271
+ static inline int
272
+ THROW_DATA_STATE(const struct vm_throw_data *obj)
273
+ {
274
+ VM_ASSERT(THROW_DATA_P(obj));
275
+ return (int)obj->throw_state;
276
+ }
277
+
278
+ static inline int
279
+ THROW_DATA_CONSUMED_P(const struct vm_throw_data *obj)
280
+ {
281
+ VM_ASSERT(THROW_DATA_P(obj));
282
+ return obj->flags & THROW_DATA_CONSUMED;
283
+ }
284
+
285
+ static inline void
286
+ THROW_DATA_CATCH_FRAME_SET(struct vm_throw_data *obj, const rb_control_frame_t *cfp)
287
+ {
288
+ VM_ASSERT(THROW_DATA_P(obj));
289
+ obj->catch_frame = cfp;
290
+ }
291
+
292
+ static inline void
293
+ THROW_DATA_STATE_SET(struct vm_throw_data *obj, int st)
294
+ {
295
+ VM_ASSERT(THROW_DATA_P(obj));
296
+ obj->throw_state = (VALUE)st;
297
+ }
298
+
299
+ static inline void
300
+ THROW_DATA_CONSUMED_SET(struct vm_throw_data *obj)
301
+ {
302
+ if (THROW_DATA_P(obj) &&
303
+ THROW_DATA_STATE(obj) == TAG_BREAK) {
304
+ obj->flags |= THROW_DATA_CONSUMED;
305
+ }
306
+ }
307
+
308
+ #define IS_ARGS_SPLAT(ci) ((ci)->flag & VM_CALL_ARGS_SPLAT)
309
+ #define IS_ARGS_KEYWORD(ci) ((ci)->flag & VM_CALL_KWARG)
310
+
311
+ #define CALLER_SETUP_ARG(cfp, calling, ci) do { \
312
+ if (UNLIKELY(IS_ARGS_SPLAT(ci))) vm_caller_setup_arg_splat((cfp), (calling)); \
313
+ if (UNLIKELY(IS_ARGS_KEYWORD(ci))) vm_caller_setup_arg_kw((cfp), (calling), (ci)); \
314
+ } while (0)
315
+
316
+ #endif /* RUBY_INSNHELPER_H */