Skip to content

Commit 3e121f9

Browse files
tekknolagiclaude
andcommitted
ZJIT: Write DEBUG_INFO before CODE_LOAD in jitdump
samply expects JIT_CODE_DEBUG_INFO to precede JIT_CODE_LOAD so it can associate source line info with the code. Swap the record order. This makes HIR instructions appear as source lines in the Firefox Profiler when profiling with samply. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 7bbb2c6 commit 3e121f9

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

zjit/src/codegen.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -204,11 +204,6 @@ fn emit_jitdump_for_function(
204204
// Read the generated code bytes for the CODE_LOAD record
205205
let code_bytes = unsafe { std::slice::from_raw_parts(start_ptr.raw_ptr(cb), code_size) };
206206
let func_name = format!("zjit::{iseq_name}");
207-
if let Err(e) = jitdump.write_code_load(&func_name, start_addr, &code_bytes) {
208-
debug!("Failed to write jitdump code load: {e}");
209-
return;
210-
}
211-
212207
// Build HIR text and line mapping for this function.
213208
// We write HIR as text to a single shared file, appending each method.
214209
// The line numbers in the debug entries reference lines in this file.
@@ -230,9 +225,14 @@ fn emit_jitdump_for_function(
230225
}
231226
}
232227

228+
// Write DEBUG_INFO before CODE_LOAD — samply expects this ordering
233229
if let Err(e) = jitdump.write_debug_info(start_addr, &debug_entries) {
234230
debug!("Failed to write jitdump debug info: {e}");
235231
}
232+
233+
if let Err(e) = jitdump.write_code_load(&func_name, start_addr, &code_bytes) {
234+
debug!("Failed to write jitdump code load: {e}");
235+
}
236236
}
237237

238238
/// Format a function's HIR as text for the jitdump source file.

0 commit comments

Comments
 (0)