12 #ifndef RUBY_INSNHELPER_H 13 #define RUBY_INSNHELPER_H 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))) 28 #define COLLECT_USAGE_REGISTER(reg, s) vm_collect_usage_register((reg), (s)) 30 #define COLLECT_USAGE_INSN(insn) 31 #define COLLECT_USAGE_OPERAND(insn, n, op) 32 #define COLLECT_USAGE_REGISTER(reg, s) 39 #define PUSH(x) (SET_SV(x), INC_SP(1)) 40 #define TOPN(n) (*(GET_SP()-(n)-1)) 41 #define POPN(n) (DEC_SP(n)) 42 #define POP() (DEC_SP(1)) 43 #define STACK_ADDR_FROM_TOP(n) (GET_SP()-(n)) 45 #define GET_TOS() (tos) 51 #define VM_REG_CFP (reg_cfp) 52 #define VM_REG_PC (VM_REG_CFP->pc) 53 #define VM_REG_SP (VM_REG_CFP->sp) 54 #define VM_REG_EP (VM_REG_CFP->ep) 56 #define RESTORE_REGS() do { \ 57 VM_REG_CFP = th->ec.cfp; \ 76 #if VM_COLLECT_USAGE_DETAILS 77 #define COLLECT_USAGE_REGISTER_HELPER(a, b, v) \ 78 (COLLECT_USAGE_REGISTER((VM_REGAN_##a), (VM_REGAN_ACT_##b)), (v)) 80 #define COLLECT_USAGE_REGISTER_HELPER(a, b, v) (v) 84 #define GET_PC() (COLLECT_USAGE_REGISTER_HELPER(PC, GET, VM_REG_PC)) 85 #define SET_PC(x) (VM_REG_PC = (COLLECT_USAGE_REGISTER_HELPER(PC, SET, (x)))) 86 #define GET_CURRENT_INSN() (*GET_PC()) 87 #define GET_OPERAND(n) (GET_PC()[(n)]) 88 #define ADD_PC(n) (SET_PC(VM_REG_PC + (n))) 89 #define JUMP(dst) (VM_REG_PC += (dst)) 92 #define GET_CFP() (COLLECT_USAGE_REGISTER_HELPER(CFP, GET, VM_REG_CFP)) 93 #define GET_EP() (COLLECT_USAGE_REGISTER_HELPER(EP, GET, VM_REG_EP)) 94 #define SET_EP(x) (VM_REG_EP = (COLLECT_USAGE_REGISTER_HELPER(EP, SET, (x)))) 95 #define GET_LEP() (VM_EP_LEP(GET_EP())) 98 #define GET_SP() (COLLECT_USAGE_REGISTER_HELPER(SP, GET, VM_REG_SP)) 99 #define SET_SP(x) (VM_REG_SP = (COLLECT_USAGE_REGISTER_HELPER(SP, SET, (x)))) 100 #define INC_SP(x) (VM_REG_SP += (COLLECT_USAGE_REGISTER_HELPER(SP, SET, (x)))) 101 #define DEC_SP(x) (VM_REG_SP -= (COLLECT_USAGE_REGISTER_HELPER(SP, SET, (x)))) 102 #define SET_SV(x) (*GET_SP() = (x)) 105 #define GET_SP_COUNT() (VM_REG_SP - th->ec.vm_stack) 108 #define GET_ISEQ() (GET_CFP()->iseq) 114 #define GET_PREV_EP(ep) ((VALUE *)((ep)[VM_ENV_DATA_INDEX_SPECVAL] & ~0x03)) 116 #define GET_GLOBAL(entry) rb_gvar_get((struct rb_global_entry*)(entry)) 117 #define SET_GLOBAL(entry, val) rb_gvar_set((struct rb_global_entry*)(entry), (val)) 119 #define GET_CONST_INLINE_CACHE(dst) ((IC) * (GET_PC() + (dst) + 2)) 125 #define GET_SELF() (COLLECT_USAGE_REGISTER_HELPER(SELF, GET, GET_CFP()->self)) 131 #define CALL_METHOD(calling, ci, cc) do { \ 132 VALUE v = (*(cc)->call)(th, GET_CFP(), (calling), (ci), (cc)); \ 146 #ifndef OPT_CALL_FASTPATH 147 #define OPT_CALL_FASTPATH 1 150 #if OPT_CALL_FASTPATH 151 #define CI_SET_FASTPATH(cc, func, enabled) do { \ 152 if (LIKELY(enabled)) ((cc)->call = (func)); \ 155 #define CI_SET_FASTPATH(ci, func, enabled) 158 #define GET_BLOCK_HANDLER() (GET_LEP()[VM_ENV_DATA_INDEX_SPECVAL]) 170 #define FIXNUM_2_P(a, b) ((a) & (b) & 1) 172 #define FLONUM_2_P(a, b) (((((a)^2) | ((b)^2)) & 3) == 0) 174 #define FLONUM_2_P(a, b) 0 176 #define FLOAT_HEAP_P(x) (!SPECIAL_CONST_P(x) && RBASIC_CLASS(x) == rb_cFloat) 177 #define FLOAT_INSTANCE_P(x) (FLONUM_P(x) || FLOAT_HEAP_P(x)) 179 #ifndef USE_IC_FOR_SPECIALIZED_METHOD 180 #define USE_IC_FOR_SPECIALIZED_METHOD 1 183 #define CALL_SIMPLE_METHOD(recv_) do { \ 184 struct rb_calling_info calling; \ 185 calling.block_handler = VM_BLOCK_HANDLER_NONE; \ 186 calling.argc = ci->orig_argc; \ 187 vm_search_method(ci, cc, calling.recv = (recv_)); \ 188 CALL_METHOD(&calling, ci, cc); \ 191 #define NEXT_CLASS_SERIAL() (++ruby_vm_class_serial) 192 #define GET_GLOBAL_METHOD_STATE() (ruby_vm_global_method_state) 193 #define INC_GLOBAL_METHOD_STATE() (++ruby_vm_global_method_state) 194 #define GET_GLOBAL_CONSTANT_STATE() (ruby_vm_global_constant_state) 195 #define INC_GLOBAL_CONSTANT_STATE() (++ruby_vm_global_constant_state)
VALUE rb_imemo_new(enum imemo_type type, VALUE v1, VALUE v2, VALUE v3, VALUE v0)
#define THROW_DATA_P(err)
#define THROW_DATA_CONSUMED
RUBY_SYMBOL_EXPORT_BEGIN VALUE ruby_vm_const_missing_count
rb_serial_t ruby_vm_global_method_state
rb_serial_t ruby_vm_class_serial
unsigned long rb_serial_t
#define RUBY_SYMBOL_EXPORT_END
#define RUBY_SYMBOL_EXPORT_BEGIN
const struct rb_control_frame_struct * catch_frame
rb_serial_t ruby_vm_global_constant_state