summaryrefslogtreecommitdiff
path: root/vm_insnhelper.h
diff options
context:
space:
mode:
Diffstat (limited to 'vm_insnhelper.h')
-rw-r--r--vm_insnhelper.h37
1 files changed, 23 insertions, 14 deletions
diff --git a/vm_insnhelper.h b/vm_insnhelper.h
index 7c7745a..25459f1 100644
--- a/vm_insnhelper.h
+++ b/vm_insnhelper.h
@@ -62,6 +62,15 @@ enum {
extern char ruby_vm_redefined_flag[BOP_LAST_];
extern VALUE ruby_vm_const_missing_count;
+#if VM_COLLECT_USAGE_DETAILS
+#define COLLECT_USAGE_INSN(insn) vm_collect_usage_insn(insn)
+#define COLLECT_USAGE_OPERAND(insn, n, op) vm_collect_usage_operand((insn), (n), ((VALUE)(op)))
+#define COLLECT_USAGE_REGISTER(reg, s) vm_collect_usage_register((reg), (s))
+#else
+#define COLLECT_USAGE_INSN(insn) /* none */
+#define COLLECT_USAGE_OPERAND(insn, n, op) /* none */
+#define COLLECT_USAGE_REGISTER(reg, s) /* none */
+#endif
/**********************************************************/
/* deal with stack */
@@ -104,16 +113,16 @@ enum vm_regan_acttype {
VM_REGAN_ACT_SET = 1,
};
-#ifdef COLLECT_USAGE_ANALYSIS
-#define USAGE_ANALYSIS_REGISTER_HELPER(a, b, v) \
- (USAGE_ANALYSIS_REGISTER((VM_REGAN_#a), (VM_REGAN_ACT_#b)), (v))
+#if VM_COLLECT_USAGE_DETAILS
+#define COLLECT_USAGE_REGISTER_HELPER(a, b, v) \
+ (COLLECT_USAGE_REGISTER((VM_REGAN_##a), (VM_REGAN_ACT_##b)), (v))
#else
-#define USAGE_ANALYSIS_REGISTER_HELPER(a, b, v) (v)
+#define COLLECT_USAGE_REGISTER_HELPER(a, b, v) (v)
#endif
/* PC */
-#define GET_PC() (USAGE_ANALYSIS_REGISTER_HELPER(PC, GET, REG_PC))
-#define SET_PC(x) (REG_PC = (USAGE_ANALYSIS_REGISTER_HELPER(PC, SET, (x))))
+#define GET_PC() (COLLECT_USAGE_REGISTER_HELPER(PC, GET, REG_PC))
+#define SET_PC(x) (REG_PC = (COLLECT_USAGE_REGISTER_HELPER(PC, SET, (x))))
#define GET_CURRENT_INSN() (*GET_PC())
#define GET_OPERAND(n) (GET_PC()[(n)])
#define ADD_PC(n) (SET_PC(REG_PC + (n)))
@@ -122,16 +131,16 @@ enum vm_regan_acttype {
#define JUMP(dst) (REG_PC += (dst))
/* frame pointer, environment pointer */
-#define GET_CFP() (USAGE_ANALYSIS_REGISTER_HELPER(CFP, GET, REG_CFP))
-#define GET_EP() (USAGE_ANALYSIS_REGISTER_HELPER(EP, GET, REG_EP))
-#define SET_EP(x) (REG_EP = (USAGE_ANALYSIS_REGISTER_HELPER(EP, SET, (x))))
+#define GET_CFP() (COLLECT_USAGE_REGISTER_HELPER(CFP, GET, REG_CFP))
+#define GET_EP() (COLLECT_USAGE_REGISTER_HELPER(EP, GET, REG_EP))
+#define SET_EP(x) (REG_EP = (COLLECT_USAGE_REGISTER_HELPER(EP, SET, (x))))
#define GET_LEP() (VM_EP_LEP(GET_EP()))
/* SP */
-#define GET_SP() (USAGE_ANALYSIS_REGISTER_HELPER(SP, GET, REG_SP))
-#define SET_SP(x) (REG_SP = (USAGE_ANALYSIS_REGISTER_HELPER(SP, SET, (x))))
-#define INC_SP(x) (REG_SP += (USAGE_ANALYSIS_REGISTER_HELPER(SP, SET, (x))))
-#define DEC_SP(x) (REG_SP -= (USAGE_ANALYSIS_REGISTER_HELPER(SP, SET, (x))))
+#define GET_SP() (COLLECT_USAGE_REGISTER_HELPER(SP, GET, REG_SP))
+#define SET_SP(x) (REG_SP = (COLLECT_USAGE_REGISTER_HELPER(SP, SET, (x))))
+#define INC_SP(x) (REG_SP += (COLLECT_USAGE_REGISTER_HELPER(SP, SET, (x))))
+#define DEC_SP(x) (REG_SP -= (COLLECT_USAGE_REGISTER_HELPER(SP, SET, (x))))
#define SET_SV(x) (*GET_SP() = (x))
/* set current stack value as x */
@@ -155,7 +164,7 @@ enum vm_regan_acttype {
/* deal with values */
/**********************************************************/
-#define GET_SELF() (USAGE_ANALYSIS_REGISTER_HELPER(5, 0, GET_CFP()->self))
+#define GET_SELF() (COLLECT_USAGE_REGISTER_HELPER(SELF, GET, GET_CFP()->self))
/**********************************************************/
/* deal with control flow 2: method/iterator */