summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteven Webb <steve@buildkite.com>2026-01-31 22:02:13 +0800
committerGitHub <noreply@github.com>2026-01-31 14:02:13 +0000
commit4ea3d8c773e62c3d808bb5f91e90bf8704926af4 (patch)
tree8eddca07299b06cabc9b3d6dd23b6d04b12da17d
parent7ef8c470d211af63b0898340074db373d55bc225 (diff)
[DOC] Example usage for --zjit-dump-hir (#16021)
I found learning about the HIR format difficult because I couldn't get ruby/miniruby to output it using the --zjit-dump-hir option. I eventually realised it won't be generated unless the zjit-call-threshold is reached (default 30).
-rw-r--r--doc/jit/zjit.md15
1 files changed, 15 insertions, 0 deletions
diff --git a/doc/jit/zjit.md b/doc/jit/zjit.md
index a284fce811..ab215a0172 100644
--- a/doc/jit/zjit.md
+++ b/doc/jit/zjit.md
@@ -306,6 +306,21 @@ A file called `zjit_exits_{pid}.dump` will be created in the same directory as `
stackprof path/to/zjit_exits_{pid}.dump
```
+### Viewing HIR as text
+
+The compiled ZJIT HIR can be viewed as text using the `--zjit-dump-hir` option. However, HIR will only be generated if the 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`:
+
+```bash
+./miniruby --zjit --zjit-dump-hir --zjit-call-threshold=1 -e "1 + 1"
+```
+
+Note that this disables profiling. To inject interpreter profiles into ZJIT, consider running your sample code 30 times:
+
+```bash
+./miniruby --zjit --zjit-dump-hir -e "30.times { 1 + 1 }"
+```
+```
+
### Viewing HIR in Iongraph
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.