Commit 6bfc99c
committed
ZJIT: Add HIR DebugStatement insn to enable print-style debugging
Useful for printing more information while debugging
but keeping the statements interleaved with the HIR.
With a local change like this
diff --git a/zjit/src/hir.rs b/zjit/src/hir.rs
index bff384f..de5b41caa1 100644
--- a/zjit/src/hir.rs
+++ b/zjit/src/hir.rs
@@ -2491,6 +2491,8 @@ fn type_specialize(&mut self) {
cme = unsafe { rb_aliased_callable_method_entry(cme) };
def_type = unsafe { get_cme_def_type(cme) };
}
+ eprintln!("WTH");
+ hir_debug_statement!(self, block, "HOWDY def_type {:?}", def_type);
if def_type == VM_METHOD_TYPE_ISEQ {
// TODO(max): Allow non-iseq; cache cme
// Only specialize positional-positional calls
The print statement (1) shows up early (anywhere)
whereas the HIR debug statement (2) is interleaved with the rest of
the HIR so you can easily correlate debug info to the compilation of
whatever function you are observing:
1. WTH <- shows up before all hir is dumped
Optimized HIR:
fn test@test.rb:2:
bb0():
EntryPoint interpreter
v1:BasicObject = LoadSelf
Jump bb2(v1)
bb1(v4:BasicObject):
EntryPoint JIT(0)
Jump bb2(v4)
bb2(v6:BasicObject):
v11:Fixnum[1] = Const Value(1)
2. # HOWDY def_type 0
PatchPoint MethodRedefined(Object@0x10184ed10, foo@0x9c01, cme:0x101967060)
The debug statements show up in HIR, LIR, and disasm:
bb2(v6:BasicObject):
v11:Fixnum[1] = Const Value(1)
# HOWDY def_type 0
PatchPoint MethodRedefined(Object@0x1220fed10, foo@0x9c01, cme:0x123717060)
--
PatchPoint Exit(PatchPoint(NoTracePoint))
# Insn: v11 Const Value(1)
# Insn: v18 # HOWDY def_type 0
# Insn: v19 PatchPoint MethodRedefined(Object@0x103aaed00, foo@0x9c01, cme:0x103bc7080)
PatchPoint Exit(PatchPoint(MethodRedefined(Object@0x103aaed00, foo@0x9c01, cme:0x103bc7080)))
--
0x1230bc0f0: nop
# Insn: v11 Const Value(1)
# Insn: v18 # HOWDY def_type 0
# Insn: v19 PatchPoint MethodRedefined(Object@0x103c6ed20, foo@0x9c01, cme:0x103d87070)
0x1230bc0f4: nop1 parent 465a86c commit 6bfc99c
2 files changed
Lines changed: 29 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
375 | 375 | | |
376 | 376 | | |
377 | 377 | | |
| 378 | + | |
378 | 379 | | |
379 | 380 | | |
380 | 381 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
23 | 33 | | |
24 | 34 | | |
25 | 35 | | |
| |||
932 | 942 | | |
933 | 943 | | |
934 | 944 | | |
| 945 | + | |
| 946 | + | |
| 947 | + | |
935 | 948 | | |
936 | 949 | | |
937 | 950 | | |
| |||
943 | 956 | | |
944 | 957 | | |
945 | 958 | | |
946 | | - | |
| 959 | + | |
| 960 | + | |
947 | 961 | | |
948 | 962 | | |
949 | 963 | | |
| |||
1011 | 1025 | | |
1012 | 1026 | | |
1013 | 1027 | | |
| 1028 | + | |
1014 | 1029 | | |
1015 | 1030 | | |
1016 | 1031 | | |
| |||
1340 | 1355 | | |
1341 | 1356 | | |
1342 | 1357 | | |
| 1358 | + | |
1343 | 1359 | | |
1344 | 1360 | | |
1345 | 1361 | | |
| |||
1692 | 1708 | | |
1693 | 1709 | | |
1694 | 1710 | | |
| 1711 | + | |
| 1712 | + | |
| 1713 | + | |
| 1714 | + | |
1695 | 1715 | | |
1696 | 1716 | | |
1697 | 1717 | | |
| |||
1811 | 1831 | | |
1812 | 1832 | | |
1813 | 1833 | | |
1814 | | - | |
| 1834 | + | |
| 1835 | + | |
1815 | 1836 | | |
1816 | 1837 | | |
1817 | 1838 | | |
| |||
2023 | 2044 | | |
2024 | 2045 | | |
2025 | 2046 | | |
2026 | | - | |
| 2047 | + | |
2027 | 2048 | | |
2028 | 2049 | | |
2029 | 2050 | | |
| |||
3602 | 3623 | | |
3603 | 3624 | | |
3604 | 3625 | | |
3605 | | - | |
| 3626 | + | |
| 3627 | + | |
3606 | 3628 | | |
3607 | 3629 | | |
3608 | 3630 | | |
| |||
4329 | 4351 | | |
4330 | 4352 | | |
4331 | 4353 | | |
4332 | | - | |
| 4354 | + | |
| 4355 | + | |
4333 | 4356 | | |
4334 | 4357 | | |
4335 | 4358 | | |
| |||
0 commit comments