ruby-changes:50601
From: tenderlove <ko1@a...>
Date: Thu, 15 Mar 2018 08:27:15 +0900 (JST)
Subject: [ruby-changes:50601] tenderlove:r62750 (trunk): Unconditionally define `TRACE_INSN_P`
tenderlove 2018-03-15 08:27:10 +0900 (Thu, 15 Mar 2018) New Revision: 62750 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=62750 Log: 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` Modified files: trunk/iseq.c Index: iseq.c =================================================================== --- iseq.c (revision 62749) +++ iseq.c (revision 62750) @@ -2758,12 +2758,12 @@ rb_iseq_defined_string(enum defined_type https://github.com/ruby/ruby/blob/trunk/iseq.c#L2758 } +#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, https://github.com/ruby/ruby/blob/trunk/iseq.c#L2793 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); } -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/