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
Copy file name to clipboardExpand all lines: README.md
+59-31Lines changed: 59 additions & 31 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,40 +14,72 @@ The goals of GraalVM JavaScript are:
14
14
15
15
16
16
## Getting Started
17
-
The preferred way to run GraalVM JavaScript is from a [GraalVM](https://www.graalvm.org/downloads/).
18
-
Starting with GraalVM 22.2., GraalVM JavaScript is an installable component that needs to be installed with `gu install js` after downloading GraalVM.
19
-
See the documentation on the [GraalVM website](https://www.graalvm.org/docs/getting-started/) for more information on how to install and use GraalVM JavaScript.
20
-
21
-
Installing GraalVM JavaScript using the _GraalVM Updater_:
22
-
23
-
```shell
24
-
$JAVA_HOME/bin/gu install js
25
-
$JAVA_HOME/bin/js --version
17
+
The preferred way to run GraalVM JavaScript (a.k.a. GraalJS) is from a [GraalVM](https://www.graalvm.org/downloads/).
18
+
As of GraalVM for JDK 21, (23.1), GraalVM JavaScript and Node.js runtimes are available as [standalone distributions](https://github.com/oracle/graaljs/releases) and [Maven artifacts](https://central.sonatype.com/artifact/org.graalvm.polyglot/js) (but no longer as GraalVM components).
19
+
See the documentation on the [GraalVM website](https://www.graalvm.org/latest/reference-manual/js/) for more information on how to set up GraalVM JavaScript.
20
+
21
+
### Standalone Distribution
22
+
To install GraalVM JavaScript using the [standalone distribution], simply download and extract the desired archive from the [GitHub Releases](https://github.com/oracle/graaljs/releases) page.
23
+
The standalone archives for the JavaScript and Node.js distributions are named `graaljs[-community][-jvm]-<version>-<os>-<arch>.tar.gz` and `graalnodejs[-community][-jvm]-<version>-<os>-<arch>.tar.gz`, respectively.
24
+
Four different available configurations are available for each component and platform combination:
25
+
26
+
| Runtime | License | Archive Infix |
27
+
| -------------| ------- | ---------------- |
28
+
| Native | GFTC |_none_|
29
+
| JVM | GFTC |`-jvm`|
30
+
| Native | UPL |`-community`|
31
+
| JVM | UPL |`-community-jvm`|
32
+
33
+
After installation, the `js` or `node` executable in the `bin` subdirectory can be used to run JavaScript files or Node modules, respectively.
34
+
If no file is provided on the command line, an interactive shell (REPL) will be spawned.
35
+
36
+
### Maven Artifact
37
+
All required artifacts for embedding GraalVM JavaScript can be found in the Maven dependency group [`org.graalvm.polyglot`](https://central.sonatype.com/namespace/org.graalvm.polyglot).
38
+
39
+
Here is a minimal Maven dependency setup that you can copy into your `pom.xml`:
40
+
```xml
41
+
<dependency>
42
+
<groupId>org.graalvm.polyglot</groupId>
43
+
<artifactId>polyglot</artifactId>
44
+
<version>23.1.0</version>
45
+
</dependency>
46
+
<dependency>
47
+
<groupId>org.graalvm.polyglot</groupId>
48
+
<artifactId>js</artifactId>
49
+
<version>23.1.0</version>
50
+
<type>pom</type>
51
+
</dependency>
52
+
<!-- add additional languages and tools, if needed -->
26
53
```
27
54
28
-
After installation, the `js` shell can be executed and used to run JavaScript code or execute JavaScript files.
29
-
30
-
```
31
-
$JAVA_HOME/bin/js
32
-
> print("Hello JavaScript");
33
-
Hello JavaScript
34
-
>
55
+
See the [polyglot embedding demonstration](https://github.com/graalvm/polyglot-embedding-demo) on GitHub for a complete runnable example.
56
+
57
+
Language and tool dependencies use the [GraalVM Free Terms and Conditions (GFTC)](https://www.oracle.com/downloads/licenses/graal-free-license.html) license by default.
58
+
To use community-licensed versions instead, add the `-community` suffix to each language and tool dependency, e.g.:
59
+
```xml
60
+
<dependency>
61
+
<groupId>org.graalvm.polyglot</groupId>
62
+
<artifactId>js-community</artifactId>
63
+
<version>23.1.0</version>
64
+
<type>pom</type>
65
+
</dependency>
35
66
```
67
+
To access [polyglot isolate](https://www.graalvm.org/latest/reference-manual/embed-languages/#polyglot-isolates) artifacts (GFTC only), use the `-isolate` suffix instead (e.g. `js-isolate`).
36
68
37
69
If you prefer running it on a stock JVM, please have a look at the documentation in [`RunOnJDK.md`](https://github.com/graalvm/graaljs/blob/master/docs/user/RunOnJDK.md).
38
70
Note that in this mode many features and optimizations of GraalVM are not available.
39
71
Due to those limitations, running on a stock JVM is not a supported feature - please use a GraalVM instead.
40
72
41
73
## Documentation
42
74
43
-
Extensive documentation is available on [graalvm.org](https://www.graalvm.org/): how to [`Run JavaScript`](https://www.graalvm.org/docs/getting-started/#running-javascript) and the more extensive [`JavaScript & Node.js Reference Manual`](https://www.graalvm.org/reference-manual/js/).
44
-
In addition there is documentation in the source code repository in the [`docs`](https://github.com/graalvm/graaljs/tree/master/docs)folder, for [`users`](https://github.com/graalvm/graaljs/tree/master/docs/user) and [`contributors`](https://github.com/graalvm/graaljs/tree/master/docs/contributor) of the engine.
75
+
Extensive documentation is available on [graalvm.org](https://www.graalvm.org/): see [Getting Started](https://www.graalvm.org/docs/getting-started/) and the more extensive [JavaScript and Node.js Reference Manual](https://www.graalvm.org/reference-manual/js/).
76
+
In addition, there is documentation in the source code repository in the [`docs`](https://github.com/graalvm/graaljs/tree/master/docs)directory, for [users](https://github.com/graalvm/graaljs/tree/master/docs/user) and [contributors](https://github.com/graalvm/graaljs/tree/master/docs/contributor).
45
77
46
78
For contributors, a guide how to build GraalVM JavaScript from source code can be found in [`Building.md`](https://github.com/graalvm/graaljs/tree/master/docs/Building.md).
47
79
48
80
## Current Status
49
81
50
-
GraalVM JavaScript is compatible with the [ECMAScript 2022 specification](https://262.ecma-international.org/13.0/).
82
+
GraalVM JavaScript is compatible with the [ECMAScript 2023 specification](https://262.ecma-international.org/14.0/).
51
83
New features, e.g. `ECMAScript proposals` scheduled to land in future editions, are added frequently and are accessible behind a flag.
52
84
See the [CHANGELOG.md](https://github.com/graalvm/graaljs/tree/master/CHANGELOG.md) for the proposals already adopted.
53
85
@@ -56,22 +88,15 @@ In addition, some popular extensions of other engines are supported, see [`JavaS
56
88
### Node.js support
57
89
58
90
GraalVM JavaScript can execute Node.js applications.
59
-
It provides high compatibility with existing npm packages, with high likelyhood that your application will run out of the box.
91
+
It provides high compatibility with existing npm packages, with high likelihood that your application will run out of the box.
60
92
This includes npm packages with native implementations.
61
93
Note that some npm modules will require to be re-compiled from source with GraalVM JavaScript if they ship with binaries that have been compiled for Node.js based on V8.
62
-
63
-
Similar to JavaScript itself, Node.js is a separately installable component of GraalVM (since 21.1).
64
-
It can be installed using the _GraalVM Updater_:
65
-
66
-
```shell
67
-
$JAVA_HOME/bin/gu install nodejs
68
-
$JAVA_HOME/bin/node --version
69
-
```
94
+
Node.js is a separate [standalone distribution](#standalone-distribution).
70
95
71
96
### Compatibility on Operating Systems
72
97
73
98
The core JavaScript engine is a Java application and is thus in principle compatible with every operating system that provides a compatible JVM, [see `RunOnJDK.md`](https://github.com/graalvm/graaljs/tree/master/docs/user/RunOnJDK.md).
74
-
We test and support GraalVM JavaScript currently in full extent on Linux AMD64, Linux AArch64, MacOS, and Windows.
99
+
We provide binary distributions and fully support GraalVM JavaScript on Linux (AMD64, AArch64), MacOS (AMD64, AArch64), and Windows (AMD64), currently.
75
100
76
101
## GraalVM JavaScript Reference Manual
77
102
@@ -81,11 +106,14 @@ A reference manual for GraalVM JavaScript is available on the [GraalVM website](
81
106
82
107
See [graalvm.org/community](https://www.graalvm.org/community/) on how to stay connected with the development community.
83
108
The channel _graaljs_ on [graalvm.slack.com](https://www.graalvm.org/slack-invitation) is a good way to get in touch with us.
109
+
Please report JavaScript-specific issues on the [`oracle/graaljs`](https://github.com/oracle/graaljs/) GitHub repository.
84
110
85
-
## Licence
111
+
## License
86
112
87
-
GraalVM JavaScript is available under the following license:
113
+
GraalVM JavaScript source code and community distributions are available under the following license:
88
114
89
115
*[The Universal Permissive License (UPL), Version 1.0](https://opensource.org/licenses/UPL)
90
116
117
+
Non-community artifacts are provided under the following license:
91
118
119
+
*[GraalVM Free Terms and Conditions (GFTC) including License for Early Adopter Versions](https://www.oracle.com/downloads/licenses/graal-free-license.html)
Copy file name to clipboardExpand all lines: docs/Building.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -91,7 +91,7 @@ mx js [OPTION]... [FILE]...
91
91
Assuming that you also built the GraalVM compiler (using the instructions in`graal/compiler/README.md`), here is how you can use it to run GraalVM JavaScript:
Assuming that you also built the GraalVM Compiler (using the instructions in`graal/compiler/README.md`), here is how you can use it to run Node.js on GraalVM JavaScript:
Copy file name to clipboardExpand all lines: docs/user/FAQ.md
+9-8Lines changed: 9 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,7 +11,7 @@ Below are the most frequently asked questions and answers about JavaScript runni
11
11
## Compatibility
12
12
13
13
### Is GraalVM compatible with the JavaScript language?
14
-
GraalVM is compatible with the ECMAScript 2022 specification and is further developed alongside the 2023 draft specification.
14
+
GraalVM is compatible with the ECMAScript 2023 specification and is further developed alongside the 2024 draft specification.
15
15
The compatibility of GraalVM's JavaScript runtime is verified by external sources, like the [Kangax ECMAScript compatibility table](https://kangax.github.io/compat-table/es6/).
16
16
17
17
GraalVM JavaScript is tested against a set of test engines, like the official test suite of ECMAScript, [test262](https://github.com/tc39/test262), as well as tests published by V8 and Nashorn, Node.js unit tests, and GraalVM's own unit tests.
@@ -84,16 +84,17 @@ Additionally, you can upload your `package-lock.json` or `package.json` file int
84
84
85
85
### My application is slower on GraalVM JavaScript than on another engine
86
86
Reason:
87
-
* Ensure your benchmark considers warmup. During the first few iterations, GraalVM JavaScript will be slower than natively implemented engines, while on peak performance, this difference should level out.
88
-
* GraalVM JavaScript is shipped in two different modes: `native` (default) and `JVM`. While the default of `native` offers fast startup, it might show slower peak performance once the application is warmed up. In the `JVM` mode, the application might need a few hundred milliseconds more to start, but typically shows better peak performance.
87
+
* Ensure your benchmark considers warmup. During the first few iterations, GraalVM JavaScript may be slower than other engines, but after sufficient warmup, this difference should level out.
88
+
* GraalVM JavaScript is shipped in two different standalones: Native (default) and JVM (with a `-jvm` infix). While the default _Native_ mode offers faster startup and lower latency, it might exhibit slower peak performance (lower throughput) once the application is warmed up. In the _JVM_ mode, the application might need hundreds of milliseconds more to start, but typically shows better peak performance.
89
89
* Repeated execution of code via newly created `org.graalvm.polyglot.Context` is slow, despite the same code being executed every time.
90
90
91
91
Solution:
92
92
* Use proper warmup in your benchmark, and disregard the first few iterations where the application still warms up.
93
-
* Use the `--jvm` option for slower startup, but higher peak performance.
93
+
* When embedding GraalVM JavaScript in a Java application, ensure you're running on a GraalVM JDK for best performance.
94
+
* Use `-jvm` standalones for slower startup, but higher peak performance.
94
95
* Double-check you have no flags set that might lower your performance, e.g., `-ea`/`-esa`.
96
+
* When running code via `org.graalvm.polyglot.Context`, make sure that one `org.graalvm.polyglot.Engine` object is shared and passed to each newly created `Context`. Use `org.graalvm.polyglot.Source` objects and cache them when possible. Then, GraalVM makes sure already compiled code can be shared across the Contexts, leading to improved performance. See [Reference Manual: Code Caching across multiple Contexts](https://www.graalvm.org/latest/reference-manual/embed-languages/#code-caching-across-multiple-contexts) for more details and an example.
95
97
* Try to minify the problem to the root cause and [file an issue](https://github.com/graalvm/graaljs/issues) so the GraalVM team can have a look.
96
-
* When running code via `org.graalvm.polyglot.Context`, make sure that one `org.graalvm.polyglot.Engine` object is shared and passed to each newly created `Context`. Use `org.graalvm.polyglot.Source` objects and cache them when possible. Then, GraalVM makes sure already compiled code can be shared across the Contexts, leading to improved performance. See [Reference Manual: Code Caching across multiple Contexts](https://www.graalvm.org/22.1/reference-manual/embed-languages/#code-caching-across-multiple-contexts) for more details and an example.
97
98
98
99
### How to achieve the best peak performance?
99
100
Here are a few tips you can follow to analyse and improve peak performance:
@@ -106,7 +107,7 @@ Here are a few tips you can follow to analyse and improve peak performance:
106
107
107
108
### What is the difference between running GraalVM's JavaScript in Native Image compared to the JVM?
108
109
In essence, the JavaScript engine of GraalVM is a plain Java application.
109
-
Running it on any JVM (JDK 11 or higher) is possible, but, for a better result, it should be GraalVM or a compatible JVMCI-enabled JDK using the GraalVM compiler.
110
+
Running it on any JVM (JDK 21 or later) is possible, but, for a better result, it should be GraalVM JDK, or a compatible Oracle JDK or OpenJDK using the Graal Compiler.
110
111
This mode gives the JavaScript engine full access to Java at runtime, but also requires the JVM to first (just-in-time) compile the JavaScript engine when executed, just like any other Java application.
111
112
112
113
Running in Native Image means that the JavaScript engine, including all its dependencies from, e.g., the JDK, is pre-compiled into a native executable.
@@ -252,15 +253,15 @@ HostAccess ha = HostAccess.newBuilder(HostAccess.EXPLICIT)
252
253
253
254
### Warning: Implementation does not support runtime compilation.
254
255
255
-
If you get the following warning, you are not running on GraalVM or a JVMCI-enabled JVM using the GraalVM compiler:
256
+
If you get the following warning, you are not running on GraalVM JDK, or a compatible Oracle JDK or OpenJDK using the Graal Compiler:
256
257
```
257
258
[engine] WARNING: The polyglot context is using an implementation that does not support runtime compilation.
258
259
The guest application code will therefore be executed in interpreted mode only.
259
260
Execution only in interpreted mode will strongly impact the guest application performance.
260
261
To disable this warning the '--engine.WarnInterpreterOnly=false' option or use the '-Dpolyglot.engine.WarnInterpreterOnly=false' system property.
261
262
```
262
263
263
-
To resolve this, use [GraalVM](https://github.com/oracle/graal/blob/master/docs/getting-started/graalvm-community/get-started-graalvm-community.md) or see the [Run GraalVM JavaScript on a Stock JDK guide](RunOnJDK.md) for instructions how to set up the Graal compiler on a compatible JVMCI-enabled stock JDK.
264
+
To resolve this, use [GraalVM](https://github.com/oracle/graal/blob/master/docs/getting-started/graalvm-community/get-started-graalvm-community.md) or see the [Run GraalVM JavaScript on a Stock JDK guide](RunOnJDK.md) for instructions how to set up the Graal compiler on a compatible Graal-enabled stock JDK.
264
265
265
266
Nevertheless, if this is intentional, you can disable the warning and continue to run with degraded performance by setting the above mentioned option, either via the command line or using the `Context.Builder`, e.g.:
0 commit comments