Skip to content

Commit f23cef1

Browse files
committed
[GR-60106] Update compiler docs.
PullRequest: graal/19437
2 parents 660b121 + aaa9e9a commit f23cef1

File tree

2 files changed

+33
-75
lines changed

2 files changed

+33
-75
lines changed

compiler/README.md

+31-73
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# GraalVM Compiler
22

33
The GraalVM compiler is a dynamic compiler written in Java that integrates with the HotSpot JVM. It has a focus on high performance and extensibility.
4-
In addition, it provides optimized performance for languages implemented with [Truffle Framework](https://github.com/graalvm/graal/tree/master/truffle)-based languages running on the JVM.
4+
In addition, it provides optimized performance for languages implemented with [Truffle Framework](../truffle)-based languages running on the JVM.
55
For brevity, the GraalVM compiler is often referred to as "the compiler" below.
66

77
## Setup
@@ -10,8 +10,8 @@ Working with the GraalVM compiler will mean cloning more than one repository and
1010
recommended to create and use a separate directory:
1111

1212
```bash
13-
$ mkdir graal
14-
$ cd graal
13+
$ mkdir graal-ws
14+
$ cd graal-ws
1515
```
1616

1717
## Building the GraalVM compiler
@@ -24,63 +24,28 @@ $ git clone https://github.com/graalvm/mx.git
2424
$ export PATH=$PWD/mx:$PATH
2525
```
2626

27-
The compiler depends on a JDK that supports a compatible version of JVMCI ([JVM Compiler Interface](https://bugs.openjdk.java.net/browse/JDK-8062493)).
28-
There is a JVMCI [port](https://github.com/graalvm/graal-jvmci-8) for JDK 8 and the required JVMCI version is built into the JDK as of JDK 11.
29-
A JVMCI-enabled JDK 8 can be downloaded from [GitHub](https://github.com/graalvm/openjdk8-jvmci-builder/releases)
30-
or you can [build](#building-jvmci-jdk8) it yourself.
31-
32-
The JVMCI JDKs that Graal is currently tested against are specified in [common.json](../common.json).
33-
34-
Most compiler sources are compliant with Java 8. Some sources use API specific to JDK 8 or only introduced in JDK 9.
35-
These sources are in [versioned projects](https://github.com/graalvm/mx#versioning-sources-for-different-jdk-releases).
36-
If you don't have a JDK that satisfies the requirement of a versioned project, the project is ignored by mx.
37-
38-
If you want to develop on a single JDK version, you only need to define `JAVA_HOME`. For example:
39-
```bash
40-
$ export JAVA_HOME=/usr/lib/jvm/oraclejdk1.8.0_212-jvmci-20-b01
41-
```
42-
or:
43-
```bash
44-
$ export JAVA_HOME=/usr/lib/jvm/jdk-11
45-
```
46-
47-
If you want to ensure your changes will pass both JDK 8 and JDK 11 gates, you can specify the secondary JDK(s) in `EXTRA_JAVA_HOMES`.
48-
For example, to develop for JDK 8 while ensuring `mx build` still works with the JDK 11 specific sources:
49-
50-
```bash
51-
$ export JAVA_HOME=/usr/lib/jvm/oraclejdk1.8.0_212-jvmci-20-b01
52-
$ export EXTRA_JAVA_HOMES=/usr/lib/jvm/jdk-11
53-
```
54-
And on macOS:
27+
Set up `JAVA_HOME` to point to a JDK compatible with Graal:
5528
```bash
56-
$ export JAVA_HOME=/Library/Java/JavaVirtualMachines/oraclejdk1.8.0_212-jvmci-20-b01/Contents/Home
57-
$ export EXTRA_JAVA_HOMES=/Library/Java/JavaVirtualMachines/jdk-11.jdk/Contents/Home
29+
$ mx fetch-jdk labsjdk-ce-latest
30+
# Follow instructions emitted by the above command to set JAVA_HOME
5831
```
59-
If you omit `EXTRA_JAVA_HOMES` in the above examples, versioned projects depending on the specified JDK(s) will be ignored.
60-
Note that `JAVA_HOME` defines the *primary* JDK for development. For instance, when running `mx vm`, this is the JDK that will be used so if you want to run on JDK 11, swap JDK 8 and JDK 11 in `JAVA_HOME` and `EXTRA_JAVA_HOMES`.
6132

62-
Now change to the `graal/compiler` directory:
33+
Change to the `graal/compiler` directory:
6334
```bash
6435
$ cd graal/compiler
6536
```
6637

6738
Changing to the `graal/compiler` directory informs mx that the focus of development (called the _primary suite_) is the GraalVM compiler.
6839
All subsequent mx commands should be executed from this directory.
6940

70-
Here's the recipe for building and running the GraalVM compiler:
41+
Here's the recipe for building the VM and running a simple app with it:
7142

7243
```bash
7344
$ mx build
74-
$ mx vm
45+
$ mx vm -Djdk.graal.ShowConfiguration=info ../compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/test/CountUppercase.java
7546
```
7647

77-
When running `mx vm`, the GraalVM compiler is used as the top tier JIT compiler by default. To revert to using C2 instead,
78-
add the `-XX:-UseJVMCICompiler` option to the command line.
79-
To disable use of the GraalVM compiler altogether (i.e. for hosted compilations as well), use `-XX:-EnableJVMCI`.
80-
81-
### Windows Specifics
82-
83-
When applying above steps on Windows, replace `export` with `set`.
48+
When running `mx vm`, the GraalVM compiler is used as the top tier JIT compiler by default.
8449

8550
## IDE Configuration
8651

@@ -93,19 +58,24 @@ $ mx ideinit
9358
This will generate Eclipse, IntelliJ, and NetBeans project configurations.
9459
Further information on how to import these project configurations into individual IDEs can be found on the [IDEs](docs/IDEs.md) page.
9560

96-
The [Ideal Graph Visualizer](https://www.graalvm.org/advanced-tools/#ideal-graph-visualizer)(IGV) is very useful in terms of visualizing the compiler's intermediate representation (IR).
97-
IGV is available on [OTN](https://www.oracle.com/downloads/graalvm-downloads.html).
61+
## IGV
62+
63+
The [Ideal Graph Visualizer](https://www.graalvm.org/latest/tools/igv/)(IGV) is very useful in terms of visualizing the compiler's intermediate representation (IR).
9864
You can get a quick insight into this tool by running the commands below.
9965
The first command launches the tool and the second runs one of the unit tests included in the code base with extra options to dump the compiler IR for all methods compiled.
10066
You should wait for the GUI to appear before running the second command.
10167

10268
```bash
103-
$ $GRAALVM_EE_HOME/bin/idealgraphvisualizer &
104-
mx unittest -Djdk.graal.Dump BC_athrow0
69+
$ mx igv &
70+
$ mx unittest -Djdk.graal.Dump -Djdk.graal.PrintGraph=Network BC_athrow0
10571
```
10672

107-
If you added `-XX:+UseJVMCICompiler` as described above, you will see IR for compilations requested by the VM itself in addition to compilations requested by the unit test.
108-
The former are those with a prefix in the UI denoting the compiler thread and id of the compilation (e.g., `JVMCI CompilerThread0:390`).
73+
> Launching IGV may fail if the `JAVA_HOME` is not compatible with the version of the NetBeans
74+
> platform on which IGV is based. Running `mx help igv` will provide more help in this context
75+
> and you can use `mx fetch-jdk` to get a compatible JDK.
76+
77+
If you add `-XX:+UseJVMCICompiler` (after `unittest`), you will see IR for compilations requested by the VM itself in addition to compilations requested by the unit test.
78+
The former are those with a prefix in the UI denoting the id of the compilation.
10979

11080
Further information can be found on the [Debugging](docs/Debugging.md) page.
11181

@@ -126,8 +96,8 @@ to only be compiled by C1 (i.e., `-Djdk.graal.CompileGraalWithC1Only=true`) but
12696
of slower compilation speed.
12797

12898
To address these issues, the GraalVM compiler can be deployed as a native shared library. The shared
129-
library is a native image produced using [SubstrateVM](../substratevm/README.md). In this mode,
130-
the GraalVM compiler uses memory separate from the HotSpot heap and it runs compiled
99+
library is a native image produced using [Native Image](../substratevm/README.md). In this mode,
100+
the compiler uses memory separate from the HotSpot heap and it runs compiled
131101
from the start. That is, it has execution properties similar to other native HotSpot
132102
compilers such as C1 and C2.
133103

@@ -137,42 +107,30 @@ To build libgraal:
137107
$ cd graal/vm
138108
$ mx --env libgraal build
139109
```
140-
The newly built GraalVM image containing libgraal is available at:
110+
The newly built GraalVM image containing libgraal is shown by:
141111
```bash
142112
$ mx --env libgraal graalvm-home
143113
```
144-
or following this symlink:
114+
or by following this symlink:
145115
```bash
146116
$ ./latest_graalvm_home
147117
```
148-
For more information about building GraalVM images, see the [README file of the vm suite](../vm/README.md).
118+
119+
For more information about building Native Images, see the [README file of the vm suite](../vm/README.md).
149120

150121
Without leaving the `graal/vm` directory, you can now run libgraal as follows:
151122

152123
1. Use the GraalVM image that you just built:
153124

154125
```bash
155-
$ ./latest_graalvm_home/bin/java -XX:+UseJVMCICompiler -XX:+UseJVMCINativeLibrary ...
126+
$ ./latest_graalvm_home/bin/java ...
156127
```
157128

158129
2. Use `mx`:
159-
- On linux:
160-
```bash
161-
$ mx -p ../compiler vm -XX:JVMCILibPath=latest_graalvm_home/jre/lib/amd64 -XX:+UseJVMCICompiler -XX:+UseJVMCINativeLibrary ...
162-
```
163-
- On macOS:
164-
```bash
165-
$ mx -p ../compiler vm -XX:JVMCILibPath=latest_graalvm_home/jre/lib -XX:+UseJVMCICompiler -XX:+UseJVMCINativeLibrary ...
166-
```
130+
```bash
131+
$ mx -p ../compiler vm -XX:JVMCILibPath=latest_graalvm_home/lib ...
132+
```
167133

168134
## Publications and Presentations
169135

170136
For video tutorials, presentations and publications on the GraalVM compiler visit the [Publications](../docs/Publications.md) page.
171-
172-
## Building JVMCI JDK 8
173-
174-
For instructions for building a JVMCI enabled JDK 8, refer to the [`graal-jvmci-8` repository](https://github.com/graalvm/graal-jvmci-8).
175-
176-
## License
177-
178-
The GraalVM compiler is licensed under the [GPL 2](LICENSE.md).

compiler/docs/Debugging.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,10 @@ guarding against use in a thread different from the one in which it was instanti
6868

6969
## JVMCI and compiler specific options
7070

71-
JVMCI and GraalVM compiler options are specified by the `jvmci.*` and `graal.*` system properties
71+
JVMCI and GraalVM compiler options are specified by the `jvmci.*` and `jdk.graal.*` system properties
7272
respectively. These must be specified on the JVM command line. Modifications to these properties by
7373
application code are not seen by JVMCI and the compiler. A listing of all supported properties can be
74-
obtained with `-XX:+JVMCIPrintProperties`.
74+
obtained with `-XX:+JVMCIPrintProperties -Djdk.graal.PrintPropertiesAll=true`.
7575

7676
## Metrics
7777

0 commit comments

Comments
 (0)