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

ruby-changes:72365

From: Aaron <ko1@a...>
Date: Thu, 30 Jun 2022 08:22:06 +0900 (JST)
Subject: [ruby-changes:72365] 8d157bc806 (master): Move function to `static inline` so we don't have leaked globals

https://git.ruby-lang.org/ruby.git/commit/?id=8d157bc806

From 8d157bc80614be1b222ca2158d211399c40d151c Mon Sep 17 00:00:00 2001
From: Aaron Patterson <tenderlove@r...>
Date: Mon, 27 Jun 2022 16:30:32 -0700
Subject: Move function to `static inline` so we don't have leaked globals

This function shouldn't leak and is only needed during instruction
assembly
---
 iseq.c                                  | 20 --------------------
 iseq.h                                  |  1 -
 tool/ruby_vm/views/_insn_type_chars.erb | 16 ++++++++++++++++
 3 files changed, 16 insertions(+), 21 deletions(-)

diff --git a/iseq.c b/iseq.c
index 0ac67f62bc..cd20297bad 100644
--- a/iseq.c
+++ b/iseq.c
@@ -2943,26 +2943,6 @@ iseq_type_id(enum iseq_type type) https://github.com/ruby/ruby/blob/trunk/iseq.c#L2943
     rb_bug("unsupported iseq type: %d", (int)type);
 }
 
-union iseq_inline_storage_entry *
-ISEQ_IS_ENTRY_START(const struct rb_iseq_constant_body *body, char op_type)
-{
-    unsigned int relative_ic_offset = 0;
-
-    switch(op_type) {
-      case TS_IC:
-          relative_ic_offset += body->ise_size;
-      case TS_ISE:
-          relative_ic_offset += body->ivc_size;
-      case TS_IVC:
-      case TS_ICVARC:
-          break;
-      default:
-          rb_bug("Wrong op type");
-    }
-
-    return &body->is_entries[relative_ic_offset];
-}
-
 static VALUE
 iseq_data_to_ary(const rb_iseq_t *iseq)
 {
diff --git a/iseq.h b/iseq.h
index afec0bae20..46a8b1b010 100644
--- a/iseq.h
+++ b/iseq.h
@@ -169,7 +169,6 @@ void rb_iseq_init_trace(rb_iseq_t *iseq); https://github.com/ruby/ruby/blob/trunk/iseq.h#L169
 int rb_iseq_add_local_tracepoint_recursively(const rb_iseq_t *iseq, rb_event_flag_t turnon_events, VALUE tpval, unsigned int target_line, bool target_bmethod);
 int rb_iseq_remove_local_tracepoint_recursively(const rb_iseq_t *iseq, VALUE tpval);
 const rb_iseq_t *rb_iseq_load_iseq(VALUE fname);
-union iseq_inline_storage_entry *ISEQ_IS_ENTRY_START(const struct rb_iseq_constant_body *body, char op_type);
 
 #if VM_INSN_INFO_TABLE_IMPL == 2
 unsigned int *rb_iseq_insns_info_decode_positions(const struct rb_iseq_constant_body *body);
diff --git a/tool/ruby_vm/views/_insn_type_chars.erb b/tool/ruby_vm/views/_insn_type_chars.erb
index 4e1f63e660..a9c112d369 100644
--- a/tool/ruby_vm/views/_insn_type_chars.erb
+++ b/tool/ruby_vm/views/_insn_type_chars.erb
@@ -11,3 +11,19 @@ enum ruby_insn_type_chars { https://github.com/ruby/ruby/blob/trunk/tool/ruby_vm/views/_insn_type_chars.erb#L11
     <%= t %> = '<%= c %>',
 % end
 };
+
+static inline union iseq_inline_storage_entry * ISEQ_IS_ENTRY_START(const struct rb_iseq_constant_body *body, char op_type) {
+    unsigned int relative_ic_offset = 0;
+    switch(op_type) {
+      case TS_IC:
+          relative_ic_offset += body->ise_size;
+      case TS_ISE:
+          relative_ic_offset += body->ivc_size;
+      case TS_IVC:
+      case TS_ICVARC:
+          break;
+      default:
+          rb_bug("Wrong op type");
+    }
+    return &body->is_entries[relative_ic_offset];
+}
-- 
cgit v1.2.1


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

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