Skip to content

Commit 98bcd54

Browse files
committed
[DOC] Example usage for --zjit-dump-hir
Learning about the HIR format is difficult if you can't get zjit to generate it for code snippets. It's not obvious to newcomers that HIR won't be generated unless the `zjit-call-threshold` is reached (default 30).
1 parent 5add7c3 commit 98bcd54

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

doc/jit/zjit.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,14 @@ A file called `zjit_exits_{pid}.dump` will be created in the same directory as `
306306
stackprof path/to/zjit_exits_{pid}.dump
307307
```
308308

309+
### Viewing HIR as text
310+
311+
The compiled zjit HIR can be viewed as text using the `--zjit-dump-hir` option. However, HIR will only be generated if the `zjit-call-threshold` is reached (default 30). By setting the threshold to 1 you can easily view the HIR for code snippets such as `1 + 1`:
312+
313+
```bash
314+
./miniruby --zjit --zjit-dump-hir --zjit-call-threshold=1 -e "1 + 1"
315+
```
316+
309317
### Viewing HIR in Iongraph
310318

311319
Using `--zjit-dump-hir-iongraph` will dump all compiled functions into a directory named `/tmp/zjit-iongraph-{PROCESS_PID}`. Each file will be named `func_{ZJIT_FUNC_NAME}.json`. In order to use them in the Iongraph viewer, you'll need to use `jq` to collate them to a single file. An example invocation of `jq` is shown below for reference.

0 commit comments

Comments
 (0)