[前][次][番号順一覧][スレッド一覧]

ruby-changes:68905

From: Aaron <ko1@a...>
Date: Thu, 21 Oct 2021 08:13:05 +0900 (JST)
Subject: [ruby-changes:68905] 863ff14997 (master): Add a callback in to microjit when a BOP is redefined

https://git.ruby-lang.org/ruby.git/commit/?id=863ff14997

From 863ff14997b8ffd3d3cbf52cf62d671788420c12 Mon Sep 17 00:00:00 2001
From: Aaron Patterson <tenderlove@r...>
Date: Fri, 29 Jan 2021 14:31:18 -0800
Subject: Add a callback in to microjit when a BOP is redefined

This commit adds a callback `rb_ujit_bop_redefined` when a basic
operation is redefined.
---
 ujit.h       | 1 +
 ujit_iface.c | 7 +++++++
 vm.c         | 2 ++
 3 files changed, 10 insertions(+)

diff --git a/ujit.h b/ujit.h
index 9186714387..51ce80b304 100644
--- a/ujit.h
+++ b/ujit.h
@@ -52,5 +52,6 @@ void rb_ujit_collect_vm_usage_insn(int insn); https://github.com/ruby/ruby/blob/trunk/ujit.h#L52
 void rb_ujit_method_lookup_change(VALUE cme_or_cc);
 void rb_ujit_compile_iseq(const rb_iseq_t *iseq);
 void rb_ujit_init(struct rb_ujit_options *options);
+void rb_ujit_bop_redefined(VALUE klass, const rb_method_entry_t *me);
 
 #endif // #ifndef UJIT_H
diff --git a/ujit_iface.c b/ujit_iface.c
index 9acc05181d..e9c617e351 100644
--- a/ujit_iface.c
+++ b/ujit_iface.c
@@ -413,6 +413,13 @@ iseq_end_index(VALUE self) https://github.com/ruby/ruby/blob/trunk/ujit_iface.c#L413
     return INT2NUM(block->end_idx);
 }
 
+/* Called when a basic operation is redefined */
+void
+rb_ujit_bop_redefined(VALUE klass, const rb_method_entry_t *me)
+{
+    //fprintf(stderr, "bop redefined\n");
+}
+
 #if HAVE_LIBCAPSTONE
 static const rb_data_type_t ujit_disasm_type = {
     "UJIT/Disasm",
diff --git a/vm.c b/vm.c
index 1fb366f882..f8041eab9a 100644
--- a/vm.c
+++ b/vm.c
@@ -1856,6 +1856,8 @@ rb_vm_check_redefinition_opt_method(const rb_method_entry_t *me, VALUE klass) https://github.com/ruby/ruby/blob/trunk/vm.c#L1856
     if (vm_redefinition_check_method_type(me->def)) {
         if (st_lookup(vm_opt_method_def_table, (st_data_t)me->def, &bop)) {
             int flag = vm_redefinition_check_flag(klass);
+            rb_ujit_bop_redefined(klass, me);
+
 	    ruby_vm_redefined_flag[bop] |= flag;
 	}
     }
-- 
cgit v1.2.1


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]