ruby-changes:68642
From: Alan <ko1@a...>
Date: Thu, 21 Oct 2021 08:11:26 +0900 (JST)
Subject: [ruby-changes:68642] 93f6ac39f2 (master): MicroJIT: Don't compile trace instructions
https://git.ruby-lang.org/ruby.git/commit/?id=93f6ac39f2 From 93f6ac39f20f64a879507db98a16177530e9f3d4 Mon Sep 17 00:00:00 2001 From: Alan Wu <XrXr@u...> Date: Mon, 19 Oct 2020 09:47:39 -0400 Subject: MicroJIT: Don't compile trace instructions --- iseq.c | 19 +++++++++++++++++++ iseq.h | 2 ++ ujit_compile.c | 2 +- 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/iseq.c b/iseq.c index 971f1c54c7..6b8f3d0e2c 100644 --- a/iseq.c +++ b/iseq.c @@ -3232,6 +3232,25 @@ rb_vm_insn_addr2insn(const void *addr) https://github.com/ruby/ruby/blob/trunk/iseq.c#L3232 rb_bug("rb_vm_insn_addr2insn: invalid insn address: %p", addr); } +// Unlike rb_vm_insn_addr2insn, this function can return trace opcode variants. +int +rb_vm_insn_addr2opcode(const void *addr) +{ + st_data_t key = (st_data_t)addr; + st_data_t val; + + if (st_lookup(rb_encoded_insn_data, key, &val)) { + insn_data_t *e = (insn_data_t *)val; + int opcode = e->insn; + if (addr == e->trace_encoded_insn) { + opcode += VM_INSTRUCTION_SIZE/2; + } + return opcode; + } + + rb_bug("rb_vm_insn_addr2opcode: invalid insn address: %p", addr); +} + // Decode `iseq->body->iseq_encoded[i]` to an insn. int rb_vm_insn_decode(const VALUE encoded) diff --git a/iseq.h b/iseq.h index ace5a45ba3..9b5eb138ad 100644 --- a/iseq.h +++ b/iseq.h @@ -167,6 +167,8 @@ const rb_iseq_t *rb_iseq_load_iseq(VALUE fname); https://github.com/ruby/ruby/blob/trunk/iseq.h#L167 unsigned int *rb_iseq_insns_info_decode_positions(const struct rb_iseq_constant_body *body); #endif +int rb_vm_insn_addr2opcode(const void *addr); + RUBY_SYMBOL_EXPORT_BEGIN /* compile.c */ diff --git a/ujit_compile.c b/ujit_compile.c index 1d349b5664..f922088bcc 100644 --- a/ujit_compile.c +++ b/ujit_compile.c @@ -74,7 +74,7 @@ opcode_at_pc(const rb_iseq_t *iseq, const VALUE *pc) https://github.com/ruby/ruby/blob/trunk/ujit_compile.c#L74 { const VALUE at_pc = *pc; if (FL_TEST_RAW((VALUE)iseq, ISEQ_TRANSLATED)) { - return rb_vm_insn_addr2insn((const void *)at_pc); + return rb_vm_insn_addr2opcode((const void *)at_pc); } else { return (int)at_pc; -- cgit v1.2.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/