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

ruby-changes:68974

From: Noah <ko1@a...>
Date: Thu, 21 Oct 2021 08:19:31 +0900 (JST)
Subject: [ruby-changes:68974] 5e164a77d5 (master): Better comments where we add exits-by-opcode to the stats hash, plus a presumably-unneeded strncpy just to be sure.

https://git.ruby-lang.org/ruby.git/commit/?id=5e164a77d5

From 5e164a77d536e0eea9c76ade036a3ff4d14176c3 Mon Sep 17 00:00:00 2001
From: Noah Gibbs <noah.gibbs@s...>
Date: Tue, 29 Jun 2021 18:25:33 +0100
Subject: Better comments where we add exits-by-opcode to the stats hash, plus
 a presumably-unneeded strncpy just to be sure.

---
 yjit_iface.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/yjit_iface.c b/yjit_iface.c
index c94268fda1..83ca0b4e82 100644
--- a/yjit_iface.c
+++ b/yjit_iface.c
@@ -762,13 +762,14 @@ get_yjit_stats(rb_execution_context_t *ec, VALUE self) https://github.com/ruby/ruby/blob/trunk/yjit_iface.c#L762
     }
 
     {
-        // Iterate through exit_op_count
+        // For each entry in exit_op_count, add a stats entry with key "exit_INSTRUCTION_NAME",
+        // where the value is the count of side exits for that instruction.
 
-        char key_string[rb_vm_max_insn_name_size + 6]; // Leave room for exit_ and a final NUL
+        char key_string[rb_vm_max_insn_name_size + 6]; // Leave room for "exit_" and a final NUL
         strcpy(key_string, "exit_");
         for (int i = 0; i < VM_INSTRUCTION_SIZE; i++) {
-            const char *i_name = insn_name(i);
-            strcpy(key_string + 5, i_name);
+            const char *i_name = insn_name(i); // Look up Ruby's NUL-terminated insn name string
+            strncpy(key_string + 5, i_name, rb_vm_max_insn_name_size + 1);
 
             VALUE key = ID2SYM(rb_intern(key_string));
             VALUE value = LL2NUM((long long)exit_op_count[i]);
-- 
cgit v1.2.1


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

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