summaryrefslogtreecommitdiff
path: root/iseq.c
diff options
context:
space:
mode:
authorTakashi Kokubun <takashikkbn@gmail.com>2021-06-02 01:16:49 -0700
committerTakashi Kokubun <takashikkbn@gmail.com>2021-06-02 01:16:50 -0700
commit070caf54d2a17168d3de05aa1633979c8545f8f4 (patch)
tree61ec56b0fd8090f5b367b770226607e1e963507c /iseq.c
parentc32ce2cbf100edd2a88e4230f08879c7cc73a891 (diff)
Refactor rb_vm_insn_addr2insn calls
It's been a way too much amount of ifdefs.
Diffstat (limited to 'iseq.c')
-rw-r--r--iseq.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/iseq.c b/iseq.c
index fdaf55ced0..4ad1fc23be 100644
--- a/iseq.c
+++ b/iseq.c
@@ -3192,6 +3192,18 @@ rb_vm_insn_addr2insn(const void *addr)
rb_bug("rb_vm_insn_addr2insn: invalid insn address: %p", addr);
}
+// Decode `iseq->body->iseq_encoded[i]` to an insn.
+int
+rb_vm_insn_decode(const VALUE encoded)
+{
+#if OPT_DIRECT_THREADED_CODE || OPT_CALL_THREADED_CODE
+ int insn = rb_vm_insn_addr2insn((void *)encoded);
+#else
+ int insn = (int)encoded;
+#endif
+ return insn;
+}
+
static inline int
encoded_iseq_trace_instrument(VALUE *iseq_encoded_insn, rb_event_flag_t turnon, bool remain_current_trace)
{