From c1cb034356a96cc378106de91142784de08c6fc6 Mon Sep 17 00:00:00 2001 From: Aiden Fox Ivey Date: Tue, 7 Oct 2025 15:38:00 -0400 Subject: ZJIT: Refactor comments and rewrite frames handling --- zjit.rb | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/zjit.rb b/zjit.rb index 9e1e502536..e3e2eae144 100644 --- a/zjit.rb +++ b/zjit.rb @@ -40,13 +40,12 @@ class << RubyVM::ZJIT frames = results[:frames] samples_count = 0 - # Loop through the instructions and set the frame hash with the data. - # We use nonexistent.def for the file name, otherwise insns.def will be displayed - # and that information isn't useful in this context. + # Use nonexistent.def as a dummy file name. + frame_template = { samples: 0, total_samples: 0, edges: {}, name: name, file: "nonexistent.def", line: nil, lines: {} } + + # Loop through all possible instructions and setup the frame hash. RubyVM::INSTRUCTION_NAMES.each_with_index do |name, frame_id| - frame_hash = { samples: 0, total_samples: 0, edges: {}, name: name, file: "nonexistent.def", line: nil, lines: {} } - results[:frames][frame_id] = frame_hash - frames[frame_id] = frame_hash + frames[frame_id] = frame_template.dup.tap { |h| h[:name] = name } end # Loop through the raw_samples and build the hashes for StackProf. @@ -100,8 +99,8 @@ class << RubyVM::ZJIT end results[:samples] = samples_count - # Set missed_samples and gc_samples to 0 as their values - # don't matter to us in this context. + + # These values are mandatory to include for stackprof, but we don't use them. results[:missed_samples] = 0 results[:gc_samples] = 0 results -- cgit v1.2.3