diff options
author | Noah Gibbs <noah.gibbs@shopify.com> | 2021-06-29 18:25:33 +0100 |
---|---|---|
committer | Alan Wu <XrXr@users.noreply.github.com> | 2021-10-20 18:19:36 -0400 |
commit | 5e164a77d536e0eea9c76ade036a3ff4d14176c3 (patch) | |
tree | 3ea69681d94398b66a44a3c24bb5e4b94f6901c1 /yjit_iface.c | |
parent | 89ae21a09222c54ada556c449fd58a3e0e6f9816 (diff) |
Better comments where we add exits-by-opcode to the stats hash, plus a presumably-unneeded strncpy just to be sure.
Diffstat (limited to 'yjit_iface.c')
-rw-r--r-- | yjit_iface.c | 9 |
1 files 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) } { - // 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]); |