You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ZJIT: Reformat and add highlighting to ZJIT documentation
* Add bash above code blocks that can use highlighting
* Move Useful dev commands below documentation, testing, and building
* Rewrite testing documentation to better explain what each form of test
does
Copy file name to clipboardExpand all lines: doc/zjit.md
+51-57Lines changed: 51 additions & 57 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,7 +3,8 @@
3
3
## Build Instructions
4
4
5
5
To build ZJIT on macOS:
6
-
```
6
+
7
+
```bash
7
8
./autogen.sh
8
9
9
10
./configure \
@@ -15,113 +16,89 @@ To build ZJIT on macOS:
15
16
make -j miniruby
16
17
```
17
18
18
-
## Useful dev commands
19
-
20
-
To view YARV output for code snippets:
21
-
```
22
-
./miniruby --dump=insns -e0
23
-
```
24
-
25
-
To run code snippets with ZJIT:
26
-
```
27
-
./miniruby --zjit -e0
28
-
```
29
-
30
-
You can also try https://www.rubyexplorer.xyz/ to view Ruby YARV disasm output with syntax highlighting
31
-
in a way that can be easily shared with other team members.
32
-
33
19
## Documentation
34
20
35
21
You can generate and open the source level documentation in your browser using:
36
-
```
22
+
23
+
```bash
37
24
cargo doc --document-private-items -p zjit --open
38
25
```
39
26
40
27
## Testing
41
28
42
-
Make sure you have a `--enable-zjit=dev` build, and install the following tools:
43
-
```
44
-
cargo install cargo-nextest
45
-
cargo install cargo-insta
46
-
```
47
-
`cargo-nextest` is required for running tests, whereas `cargo-insta` is used for updating snapshots.
29
+
Note that tests link against CRuby, so directly calling `cargo test`, or `cargo nextest` should not build. All tests are instead accessed through `make`.
48
30
49
-
### make zjit-check
31
+
### Setup
50
32
51
-
This command runs all ZJIT tests: `make zjit-test` and `test/ruby/test_zjit.rb`.
33
+
First, ensure you have `cargo` installed. If you do not already have it, you can use [rustup.rs](https://rustup.rs/).
52
34
53
-
```
54
-
make zjit-check
35
+
Make sure to add `--enable-zjit=dev` when you run `configure`, then install the following tools:
36
+
37
+
```bash
38
+
cargo install cargo-nextest
39
+
cargo install cargo-insta
55
40
```
56
41
57
-
### make zjit-test
42
+
`cargo-insta` is used for updating snapshots. `cargo-nextest` runs each test in its own process, which is valuable since CRuby only supports booting once per process, and most APIs are not thread safe.
58
43
59
-
This command runs Rust unit tests using `insta` for snapshot testing.
44
+
### Running unit tests
60
45
61
-
```
46
+
For testing functionality within ZJIT, use:
47
+
48
+
```bash
62
49
make zjit-test
63
50
```
64
51
65
52
You can also run a single test case by specifying the function name:
66
53
67
-
```
54
+
```bash
68
55
make zjit-test ZJIT_TESTS=test_putobject
69
56
```
70
57
71
58
#### Snapshot Testing
72
59
73
-
ZJIT uses [insta](https://insta.rs/) for snapshot testing. When tests fail due to snapshot mismatches, pending snapshots are created. The test command will notify you if there are pending snapshots:
60
+
ZJIT uses [insta](https://insta.rs/) for snapshot testing within unit tests. When tests fail due to snapshot mismatches, pending snapshots are created. The test command will notify you if there are pending snapshots:
74
61
75
62
```
76
63
Pending snapshots found. Accept with: make zjit-test-update
77
64
```
78
65
79
66
To update/accept all the snapshot changes:
80
67
81
-
```
68
+
```bash
82
69
make zjit-test-update
83
70
```
84
71
85
72
You can also review snapshot changes interactively one by one:
86
73
87
-
```
74
+
```bash
88
75
cd zjit && cargo insta review
89
76
```
90
77
91
78
Test changes will be reviewed alongside code changes.
92
79
93
-
<details>
94
-
95
-
<summary>Setting up zjit-test</summary>
96
-
97
-
ZJIT uses `cargo-nextest` for Rust unit tests instead of `cargo test`.
98
-
`cargo-nextest` runs each test in its own process, which is valuable since
99
-
CRuby only supports booting once per process, and most APIs are not thread
100
-
safe. Use `brew install cargo-nextest` to install it on macOS, otherwise, refer
101
-
to <https://nexte.st/docs/installation/pre-built-binaries/> for installation
102
-
instructions.
103
-
104
-
Since it uses Cargo, you'll also need a `configure --enable-zjit=dev ...` build
105
-
for `make zjit-test`. Since the tests need to link against CRuby, directly
106
-
calling `cargo test`, or `cargo nextest` likely won't build. Make sure to
107
-
use `make`.
108
-
109
-
</details>
110
-
111
-
### test/ruby/test\_zjit.rb
80
+
### Running integration tests
112
81
113
82
This command runs Ruby execution tests.
114
83
115
-
```
84
+
```bash
116
85
make test-all TESTS="test/ruby/test_zjit.rb"
117
86
```
118
87
119
88
You can also run a single test case by matching the method name:
120
89
121
-
```
90
+
```bash
122
91
make test-all TESTS="test/ruby/test_zjit.rb -n TestZJIT#test_putobject"
123
92
```
124
93
94
+
### Running all tests
95
+
96
+
Runs both `make zjit-test` and `test/ruby/test_zjit.rb`:
97
+
98
+
```bash
99
+
make zjit-check
100
+
```
101
+
125
102
## Statistics Collection
126
103
127
104
ZJIT provides detailed statistics about JIT compilation and execution behavior.
@@ -173,12 +150,29 @@ Through [Stackprof](https://github.com/tmm1/stackprof), detailed information abo
173
150
./miniruby --zjit-trace-exits script.rb
174
151
```
175
152
176
-
A file called `zjit_exit_locations.dump` will be created in the same directory as `script.rb`. Viewing the side exited methods can be done with Stackprof:
153
+
A file called `zjit_exit_locations{timestamp}.dump` will be created in the same directory as `script.rb`. Viewing the side exited methods can be done with Stackprof:
0 commit comments