ZJIT: Include local variable names in Get|SetLocal insn's print value#15423
ZJIT: Include local variable names in Get|SetLocal insn's print value#15423st0012 merged 1 commit intoruby:masterfrom
Get|SetLocal insn's print value#15423Conversation
zjit/src/hir.rs
Outdated
| /// Returns | ||
| /// - `:name, ` if iseq is available and name is a real identifier, | ||
| /// - `<anon>, ` for anonymous locals. | ||
| /// - empty string if iseq is not available. |
There was a problem hiding this comment.
Could you let the comment also explain when this happens? I'm not sure why we need to support this. Is it used only for Rust-level unit tests?
There was a problem hiding this comment.
Sure. It's used in HIR dump, graphviz output, and iongraph output.
There was a problem hiding this comment.
🤔
My question was on this "empty string if iseq is not available" line, and I meant to ask "Is empty string used only for Rust-level unit tests?". Are you sure you print an empty string here on HIR dump?
There was a problem hiding this comment.
Oh I thought you meant the return value of this function in general.
Insn can also be printed in panic/debug messages too, like in disasm.rs we have:
// For each instruction in this block
for insn in insns.as_ref() {
// ...
writeln!(&mut out, " {}", format!("{insn}").trim()).unwrap();
}In these cases, I think the fmt implementation for Display trait would be called, which can't access iseq:
impl std::fmt::Display for Insn {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
self.print(&PtrPrintMap::identity(), None).fmt(f)
}
}So the empty string is for those cases.
There was a problem hiding this comment.
ok, that's probably useful to support then (as I asked above, please consider leaving the context in this line 🙏)
5fa8dcf to
9584213
Compare
zjit/src/hir.rs
Outdated
| /// Returns | ||
| /// - `:name, ` if iseq is available and name is a real identifier, | ||
| /// - `<anon>, ` for anonymous locals. | ||
| /// - empty string if iseq is not available. |
There was a problem hiding this comment.
nit: does not return empty anymore if iseq is not available--returns none. pls fix comment
zjit/src/hir.rs
Outdated
| /// - `<anon>, ` for anonymous locals. | ||
| /// - empty string if iseq is not available. |
There was a problem hiding this comment.
| /// - `<anon>, ` for anonymous locals. | |
| /// - empty string if iseq is not available. | |
| /// - `<empty>, ` for anonymous locals. | |
| /// - None if iseq is not available. |
9584213 to
56df167
Compare
|
Sweet, merge it |
Closes Shopify#881