diff options
| author | Aiden Fox Ivey <aiden.foxivey@shopify.com> | 2025-10-07 15:38:00 -0400 |
|---|---|---|
| committer | Takashi Kokubun <takashikkbn@gmail.com> | 2025-10-07 15:13:46 -0700 |
| commit | c1cb034356a96cc378106de91142784de08c6fc6 (patch) | |
| tree | 133e1642d3212b7d024cb189db45c1e1ef252363 | |
| parent | 4d0f53520c09eab591ba69fb3fa16d7f55103bc8 (diff) | |
ZJIT: Refactor comments and rewrite frames handling
| -rw-r--r-- | zjit.rb | 15 |
1 files changed, 7 insertions, 8 deletions
@@ -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 |
