Aiden Fox Ivey 2ed287da17
ZJIT: Add Iongraph compatibility (#14999)
## Components

This PR adds functionality to visualize HIR using the [Iongraph](https://spidermonkey.dev/blog/2025/10/28/iongraph-web.html) tool first created for use with Spidermonkey.

## Justification

Iongraph's viewer is (as mentioned in the article above) a few notches above graphviz for viewing large CFGs. It also allows easily inspecting different compiler optimization passes and multiple functions in the same browser window. Since Spidermonkey is using this format, it may be beneficial to use it for our own JIT development.

The requirement for JSON is downstream from that of the Iongraph format. As for writing the implementation myself, ZJIT leans towards having fewer dependencies, so this is the preferred approach.

## How does it look?

<img width="902" height="957" alt="image" src="https://github.com/user-attachments/assets/e4e0991b-572a-41fd-9fed-1215bd1926c3" />

<img width="770" height="624" alt="image" src="https://github.com/user-attachments/assets/01398373-1f75-46b8-b1aa-7f5d4cbca6b8" />

Right now, it's aesthetically minimal, but is fairly robust.

## Functionality

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. The name of the file created does not matter to my understanding.

`jq --slurp --null-input '.functions=inputs | .version=2' /tmp/zjit-iongraph-{PROCESS_PID}/func*.json > ~/Downloads/foo.json`

From there, you can use https://mozilla-spidermonkey.github.io/iongraph/ to view your trace.

### Caveats

- The upstream Iongraph viewer doesn't allow you to click arguments to an instruction to find the instruction that they originate from when using the format that this PR generates. (I have made a small fork at https://github.com/aidenfoxivey/iongraph that fixes that functionality via 9e9c29b41c.patch)
- The upstream Iongraph viewer can sometimes show "exiting edges" in the CFG as being not attached to the box representing its basic block.

<img width="1814" height="762" alt="image" src="https://github.com/user-attachments/assets/afbbaa16-332f-498f-849e-11c69a8cb0cc" />

(Image courtesy of @tekknolagi)

This is because the original tool was (to our understanding) written for an SSA format that does not use extended basic blocks. (Extended basic blocks let you put a jump instruction, conditional or otherwise, anywhere in the basic block.) This means that our format may generate more outgoing edges than the viewer is written to handle.
2025-11-19 23:00:44 +00:00
2025-11-19 16:05:12 +09:00
2025-09-10 16:45:25 +09:00
2025-11-19 23:37:37 +01:00
2025-09-13 16:32:30 +09:00
2025-08-30 22:41:23 +09:00
2025-09-17 09:25:17 -04:00
2025-11-08 20:51:04 +09:00
2025-11-15 13:02:15 -08:00
2025-11-08 10:08:09 -05:00
2025-05-20 22:12:58 +09:00
2025-05-11 23:32:50 +09:00
2025-05-11 23:32:50 +09:00
2025-10-23 13:08:26 +09:00
2025-06-17 15:32:53 -07:00
2025-11-07 20:42:29 +09:00
2025-11-10 19:12:35 +09:00
GPL
2025-11-05 22:31:17 -05:00
2025-10-23 13:08:26 +09:00
2025-11-15 11:04:49 +09:00
2025-10-23 13:08:26 +09:00
2025-10-30 21:47:12 +09:00
2025-09-06 07:17:52 +09:00
2025-05-25 15:22:43 +09:00
2025-06-12 09:30:09 +02:00
2025-08-30 22:41:23 +09:00
2025-11-16 13:26:11 -08:00
2025-08-04 02:23:43 +09:00
2025-10-30 18:04:08 +09:00
2025-09-24 03:59:03 +09:00
2025-11-12 05:13:29 -05:00
2025-10-23 13:08:26 +09:00
2025-10-31 20:49:59 +09:00
2025-10-31 20:49:59 +09:00
2025-10-31 20:49:59 +09:00
2025-08-30 22:41:23 +09:00
2025-10-23 13:08:26 +09:00
2025-07-28 12:22:42 +02:00
2025-09-30 09:47:29 -04:00
2025-10-23 13:08:26 +09:00
2025-10-10 11:09:34 -07:00
2025-10-10 11:09:34 -07:00
2025-10-30 18:04:08 +09:00
2025-07-29 10:00:15 -07:00
2025-08-26 13:02:17 -07:00

Actions Status: MinGW Actions Status: Ubuntu Actions Status: Windows Travis Status

What is Ruby?

Ruby is an interpreted object-oriented programming language often used for web development. It also offers many scripting features to process plain text and serialized files, or manage system tasks. It is simple, straightforward, and extensible.

Features of Ruby

  • Simple Syntax
  • Normal Object-oriented Features (e.g. class, method calls)
  • Advanced Object-oriented Features (e.g. mix-in, singleton-method)
  • Operator Overloading
  • Exception Handling
  • Iterators and Closures
  • Garbage Collection
  • Dynamic Loading of Object Files (on some architectures)
  • Highly Portable (works on many Unix-like/POSIX compatible platforms as well as Windows, macOS, etc.) cf. https://docs.ruby-lang.org/en/master/maintainers_md.html#label-Platform+Maintainers

How to get Ruby

For a complete list of ways to install Ruby, including using third-party tools like rvm, see:

https://www.ruby-lang.org/en/downloads/

You can download release packages and the snapshot of the repository. If you want to download whole versions of Ruby, please visit https://www.ruby-lang.org/en/downloads/releases/.

Download with Git

The mirror of the Ruby source tree can be checked out with the following command:

$ git clone https://github.com/ruby/ruby.git

There are some other branches under development. Try the following command to see the list of branches:

$ git ls-remote https://github.com/ruby/ruby.git

You may also want to use https://git.ruby-lang.org/ruby.git (actual master of Ruby source) if you are a committer.

How to build

See Building Ruby

Ruby home page

https://www.ruby-lang.org/

Documentation

Mailing list

There is a mailing list to discuss Ruby. To subscribe to this list, please send the following phrase:

join

in the mail subject (not body) to the address ruby-talk-request@ml.ruby-lang.org.

Copying

See the file COPYING.

Feedback

Questions about the Ruby language can be asked on the Ruby-Talk mailing list or on websites like https://stackoverflow.com.

Bugs should be reported at https://bugs.ruby-lang.org. Read "Reporting Issues" for more information.

Contributing

See "Contributing to Ruby", which includes setup and build instructions.

The Author

Ruby was originally designed and developed by Yukihiro Matsumoto (Matz) in 1995.

matz@ruby-lang.org

Description
Languages
Ruby 58.9%
C 29.5%
Rust 6.1%
C++ 2.9%
Yacc 0.9%
Other 1.6%