1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Unconditionally define TRACE_INSN_P

`TRACE_INSN_P` doesn't need to know about encoded iseqs, it just needs
to look at decoded iseqs.  We have the decoded iseqs available, so no
reason to look at encoded ones.  This change allows us to clear
`original_iseq` from the iseq struct without any segvs (previously,
clearing `original_iseq` would cause the tests to crash).

* iseq.c (rb_iseq_trace_set): Only use decoded iseq with `TRACE_INSN_P`

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62750 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
tenderlove 2018-03-14 23:27:10 +00:00
parent 999b58c1ff
commit cc7bd8e5ff

13
iseq.c
View file

@ -2758,12 +2758,12 @@ rb_iseq_defined_string(enum defined_type type)
}
#define TRACE_INSN_P(insn) ((insn) >= VM_INSTRUCTION_SIZE/2)
#if OPT_DIRECT_THREADED_CODE || OPT_CALL_THREADED_CODE
#define INSN_CODE(insn) ((VALUE)table[insn])
#define TRACE_INSN_P(insn, insn_encoded) ((VALUE)table[insn] != insn_encoded)
#else
#define INSN_CODE(insn) (insn)
#define TRACE_INSN_P(insn, insn_encoded) ((insn_encoded) >= VM_INSTRUCTION_SIZE/2)
#endif
void
@ -2793,16 +2793,13 @@ rb_iseq_trace_set(const rb_iseq_t *iseq, rb_event_flag_t turnon_events)
int insn = (int)code[i];
rb_event_flag_t events = rb_iseq_event_flags(iseq, i);
/* code represents before transformation */
VM_ASSERT(insn < VM_INSTRUCTION_SIZE/2);
if (events & turnon_events) {
if (!TRACE_INSN_P(insn, iseq_encoded[i])) {
if (!TRACE_INSN_P(insn)) {
iseq_encoded[i] = INSN_CODE(insn + VM_INSTRUCTION_SIZE/2);
}
}
else if (TRACE_INSN_P(insn, iseq_encoded[i])) {
iseq_encoded[i] = INSN_CODE(insn);
else if (TRACE_INSN_P(insn)) {
iseq_encoded[i] = INSN_CODE(insn - VM_INSTRUCTION_SIZE/2);
}
i += insn_len(insn);
}