Skip to content

Commit 1412f4f

Browse files
committed
Merge branch 'topic/lkql_jit/upgrade_graalvm_version' into 'master'
Upgrade the GraalVM version to 24 Closes #451 See merge request eng/libadalang/langkit-query-language!524
2 parents 4efe59c + a2b3794 commit 1412f4f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+529
-956
lines changed

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ build/bin/liblkqllang_parse: lkql/lkql.lkt
6161
test:
6262
testsuite/testsuite.py -Edtmp
6363

64-
clean: clean_lkql clean_lkql_jit clean_lkql_checker
64+
clean: clean_lkql_jit clean_lkql_checker clean_lkql
6565

6666
clean_lkql:
6767
rm lkql/build -rf
@@ -75,11 +75,11 @@ clean_lkql_checker:
7575

7676
build_lkql_jit: lkql
7777
$(MAVEN) -f lkql/build/java/ install
78-
$(MAVEN) -f lkql_jit/ clean install $(MAVEN_ARGS)
78+
$(MAVEN) -f lkql_jit/ clean package $(MAVEN_ARGS)
7979

8080
build_lkql_native_jit: lkql
8181
$(MAVEN) -f lkql/build/java/ install
82-
$(MAVEN) -f lkql_jit/ clean install -P native,$(BUILD_MODE) $(MAVEN_ARGS)
82+
$(MAVEN) -f lkql_jit/ clean package -P native,$(BUILD_MODE) $(MAVEN_ARGS)
8383

8484
.PHONY: lkql_checker
8585

lkql_jit/.gitignore

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -13,33 +13,9 @@
1313
# Ignore the target of the LKQL JIT project
1414
target
1515

16-
# Ignore from the component module
17-
component/lkql_jit_component
18-
component/target
19-
component/lkql_jit_component.jar
20-
2116
# Ignore from the language module
22-
language/target
2317
language/.apt_generated
2418
language/.apt_generated_tests
2519

26-
# Ignore from the launcher module
27-
launcher/target
28-
29-
# Ignore from the checker module
30-
checker/target
31-
32-
# Ignore from the gnatcheck_worker module
33-
gnatcheck_worker/target
34-
35-
# Ignore from the native module
36-
native/target
37-
native/bin
38-
native/lib
39-
native/reports
40-
native/sources
41-
4220
# Test and log files
43-
my_working_dir
44-
language/src/test/java/TestRun.java
4521
*.log

lkql_jit/README.md

Lines changed: 33 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ The JIT compiler for the LKQL language.
66
Dependencies
77
------------
88

9-
* [GraalVM](https://www.graalvm.org/) : The high performance JVM
10-
* [Maven](https://maven.apache.org/) : Java project manager
9+
* [GraalVM](https://www.graalvm.org/) : The high performance JVM (version 24.2.1)
10+
* [Maven](https://maven.apache.org/) : Java building tool
1111
* [Python3](https://www.python.org/) : The language (3.9 or later)
1212
* [Langkit](https://github.com/AdaCore/langkit) : The language front-end creation framework
1313
* [Libadalang](https://github.com/AdaCore/libadalang)
@@ -17,29 +17,23 @@ How to build and run
1717
--------------------
1818

1919
First, you need to ensure that the `mvn` command is accessible and fairly recent (at least 3.8.5).
20-
21-
Then, make sure you have an accessible Python3 installation. Python 3.9 or later.
22-
23-
You also need to install GraalVM's `native-image` utility, which can be done
24-
running `gu install native-image` (where `gu` is in the `bin` directory of the GraalVM
25-
installation).
26-
27-
Also make sure that your GraalVM installation is for Java 17, as Java 19 is not supported for now.
28-
For information, the tested version of GraalVM is graalvm-ce-java17-22.3.1.
20+
Then, make sure you have an accessible Python3 installation, version 3.9 or later.
21+
Also make sure that your GraalVM installation is in the 24.2.1 version.
22+
Finally, make sure that `native-image` tool is available in your environment.
2923

3024
### 1) Install Langkit and make sure it is usable
3125

3226
```sh
3327
$[langkit]> pip3 install -r requirement-pypi.txt
3428
$[langkit]> ./manage.py make
35-
$[langkit]> eval `./manage.py setenv`
29+
$[langkit]> eval `./manage.py printenv`
3630
$[langkit]> export PATH="/path/to/langkit/scripts:$PATH"
3731
```
3832

39-
If you get a Python error about the langkit library, add the langkit directory to your `PYTHONPATH`
33+
If you get a Python error about the Langkit library, add the Langkit directory to your `PYTHONPATH`
4034
environment variable.
4135

42-
*Note: If for some reason you are not running `./manage.py setenv`, make sure that the
36+
*Note: If for some reason you are not running `./manage.py printenv`, make sure that the
4337
`sigsegv_handler` library is reachable from your `LD_LIBRARY_PATH`.*
4438

4539
Install the Java LangkitSupport library:
@@ -52,7 +46,7 @@ $[langkit]> mvn -f langkit/java_support install
5246

5347
```sh
5448
$[libadalang]> lkm make --enable-java
55-
$[libadalang]> eval `lkm setenv`
49+
$[libadalang]> eval `lkm printenv`
5650
```
5751

5852
Make sure the Java bindings are installed locally
@@ -65,7 +59,7 @@ $[libadalang]> mvn -f build/java install
6559

6660
```sh
6761
$[langkit-query-language/lkql]> lkm make --enable-java
68-
$[langkit-query-language/lkql]> eval `lkm setenv`
62+
$[langkit-query-language/lkql]> eval `lkm printenv`
6963
```
7064

7165
As for Libadalang, make sure Java bindings are installed
@@ -82,99 +76,59 @@ $[langkit-query-language/lkql]> mvn -f build/java install
8276
### 5) Build and run LKQL_JIT
8377

8478
```sh
85-
$[langkit-query-language/lkql_jit]> mvn clean install
79+
$[langkit-query-language/lkql_jit]> mvn clean package
8680
```
8781

88-
You can now access the LKQL JIT launcher using the `lkql.py` Python script that has been installed
89-
in the `languages/lkql/bin` directory of your GraalVM installation.
82+
You can now access LKQL JIT by running the `langkit-query-language/lkql_jit/standalone/target/lkql.py`
83+
script.
9084

91-
This script will launch LKQL JIT with the current accessible Java installation (`java -jar
92-
lkql_cli.jar ...`) so you have to run it in a valid environment.
85+
This script will launch LKQL JIT with the current accessible Java installation (`java -jar ...`)
86+
so you have to run it in a valid environment.
9387

9488
If you want to build LKQL JIT as a native executable, you can use the `native` Maven profile:
9589

9690
```sh
97-
$[langkit-query-language/lkql_jit]> mvn clean install -P native
91+
$[langkit-query-language/lkql_jit]> mvn clean package -P native
9892
```
9993

100-
Then the `lkql` executable will be available under the `langkit-query-language/lkql_jit/native/bin`
101-
directory and will be installed to your local GraalVM guest languages folder
102-
(`$GRAAL_HOME/languages/lkql/bin`).
94+
Then the `lkql` executable will be available under the `langkit-query-language/lkql_jit/standalone/target`
95+
directory.
10396

10497
### 6) Running the code formatter
10598

106-
LKQL JIT project uses the `google-java-format` as code formatter. It is run every time you call
107-
the `compile` Maven phase and will raise an error if there is a style violation in the LKQL JIT
108-
source code. To automatically format all Java files you can run the following command:
99+
LKQL JIT project uses `prettier-java` as code formatter, and the `spotless` Maven plugin is configured
100+
to run it on demand. You can run the following command to format all Java sources:
109101

110102
```sh
111-
$[langkit-query-language/lkql_jit] mvn spotless:apply
103+
$[langkit-query-language/lkql_jit]> mvn spotless:apply
104+
```
105+
106+
However, running it is very prone to error, thus you can install pre-commit
107+
hooks to perform this formatting operation on each commit:
108+
109+
```sh
110+
$[langkit-query-language]> pre-commit install
112111
```
113112

114113
Debugging LKQL JIT
115114
------------------
116115

117-
To debug LKQL_JIT native-image build you can use the `debug` maven profile.
116+
To debug LKQL JIT native-image builds you can use the `debug` maven profile:
118117

119118
```sh
120-
$[langkit-query-language/lkql_jit]> mvn clean install -P native,debug
119+
$[langkit-query-language/lkql_jit]> mvn clean package -P native,debug
121120
```
122121

123-
If you need to debug or profile LKQL_JIT native-image binaries there is the `dev` profile which
122+
If you need to debug or profile LKQL JIT native-image binaries there is the `dev` profile which
124123
enable support for tools like `valgrind`, `gdb` or `perf` on the produced binaries.
125124

126125
```sh
127-
$[langkit-query-language/lkql_jit]> mvn clean install -P native,dev
126+
$[langkit-query-language/lkql_jit]> mvn clean package -P native,dev
128127
```
129128

130129
If you don't need or want any of those, use the `prod` profile to disable all debugging and
131130
profiling information.
132131

133132
```sh
134-
$[langkit-query-language/lkql_jit]> mvn clean install -P native,prod
135-
```
136-
137-
Configuring Intellij IDEA
138-
-------------------------
139-
140-
To develop for LKQL JIT you may use Intellij IDEA since the LKQL JIT project use and contains a
141-
configuration for this IDE. You just have to open the LKQL JIT project (`lkql_jit/pom.xml`) with
142-
Intellij to initialize the project.
143-
144-
However, LKQL JIT project use `google-java-format` to format the Java source code, so you may
145-
configure Intellij to use this formatter and applying it when saving Java files. To make this
146-
you have to follow those steps:
147-
148-
### 1) Install Intellij plugin
149-
150-
Go to `File > Settings > Plugins` and search for "google-java-format" in the marketplace then
151-
install it.
152-
153-
### 2) Enable and configure the Intellij plugin
154-
155-
You now have to enable the "google-java-format" plugin: go to `File > Settings > Other Settings >
156-
google-java-format Settings` and check the `Enable google-java-format` option. Then you have to
157-
select the `Android Open Source Project (AOSP) style` in the `Code style` menu.
158-
159-
### 3) Configure the Intellij JRE
160-
161-
The google-java-format plugin uses some internal classes that aren't available without extra
162-
configuration. You have to go to `Help > Edit Custom VM Options...` then past these lines:
163-
164-
```
165-
--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED
166-
--add-exports=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED
167-
--add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED
168-
--add-exports=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED
169-
--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED
170-
--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED
133+
$[langkit-query-language/lkql_jit]> mvn clean package -P native,prod
171134
```
172-
173-
Then restart you IDE. Now `google-java-format` should have replaced the `Reformat Code` and
174-
`Optimize Imports` actions.
175-
176-
### 4) Set formatting hook on file saving (optional)
177-
178-
If you want Intellij to automatically reformat the current file when it is saved you can go to
179-
`File > Settings > Tools > Actions on save` then check the `Optimize imports` and `Reformat
180-
code` options.

lkql_jit/TODO.md

Lines changed: 0 additions & 13 deletions
This file was deleted.

lkql_jit/benchmarks/pom.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
<groupId>org.graalvm.js</groupId>
5151
<artifactId>js</artifactId>
5252
<version>${graalvm.version}</version>
53+
<type>pom</type>
5354
</dependency>
5455

5556
<dependency>
@@ -66,4 +67,4 @@
6667
</dependency>
6768
</dependencies>
6869

69-
</project>
70+
</project>

lkql_jit/benchmarks/src/test/java/com/adacore/lkql_jit/benchmarks/ClosureBenchmark.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@ fun baz(x) = {
2424
2525
val clos = foo(12)(13)
2626
fun r() = clos(14)
27-
repeat(1000000, r)
28-
""";
27+
repeat(1000000, r)""";
2928

3029
private static final String jsClosure =
3130
"""
@@ -47,8 +46,7 @@ function r() {
4746
4847
for (let i = 0; i < 1000000; i++) {
4948
r()
50-
}
51-
""";
49+
}""";
5250

5351
// ----- Benchmark methods -----
5452

lkql_jit/benchmarks/src/test/java/com/adacore/lkql_jit/benchmarks/ClosureCreationBenchmark.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ function baz(x) {
2727
2828
for (let i = 0; i < 10000; i++) {
2929
foo(12)(13)(14)
30-
}
31-
"""
30+
}"""
3231
);
3332
}
3433

@@ -47,8 +46,7 @@ fun baz(x) = {
4746
bar
4847
}
4948
50-
repeat(10000, () => foo(12)(13)(14))
51-
"""
49+
repeat(10000, () => foo(12)(13)(14))"""
5250
);
5351
}
5452
}

lkql_jit/builtins_annotations/pom.xml

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,6 @@
1313
<artifactId>builtins_annotations</artifactId>
1414
<version>0.1.0</version>
1515

16-
<dependencies>
17-
<dependency>
18-
<groupId>org.graalvm.truffle</groupId>
19-
<artifactId>truffle-api</artifactId>
20-
<version>${graalvm.version}</version>
21-
</dependency>
22-
<dependency>
23-
<groupId>org.graalvm.truffle</groupId>
24-
<artifactId>truffle-dsl-processor</artifactId>
25-
<version>${graalvm.version}</version>
26-
<scope>provided</scope>
27-
</dependency>
28-
</dependencies>
29-
3016
<build>
3117
<plugins>
3218
<!-- Skip the Spotless check because everything is handled by the parent -->
@@ -41,10 +27,9 @@
4127

4228
<plugin>
4329
<artifactId>maven-compiler-plugin</artifactId>
30+
<version>3.11.0</version>
4431
<configuration>
4532
<compilerArgs>
46-
<arg>--add-exports</arg>
47-
<arg>org.graalvm.truffle/com.oracle.truffle.api.dsl=ALL-UNNAMED</arg>
4833
<compilerArgument>-proc:none</compilerArgument>
4934
</compilerArgs>
5035
</configuration>

0 commit comments

Comments
 (0)