Skip to content

Commit 2f4befa

Browse files
committed
[GR-37716] Review the usage of NI terminology; Node version update.
PullRequest: js/2471
2 parents ece3229 + 3ae5ece commit 2f4befa

File tree

6 files changed

+47
-40
lines changed

6 files changed

+47
-40
lines changed

docs/user/FAQ.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,17 +89,17 @@ Solution:
8989
Here are a few tips you can follow to analyse and improve peak performance:
9090

9191
* When measuring, ensure you have given the GraalVM compiler enough time to compile all hot methods before starting to measure peak performance. A useful command line option for that is `--engine.TraceCompilation=true` -- this outputs a message whenever a (JavaScript) method is compiled. As long as this still prints frequently, measurement should not yet start.
92-
* Compare the performance between the Native Image and the JVM mode if possible. Depending on the characteristics of your application, one or the other might show better peak performance.
92+
* Compare the performance between Native Image and the JVM mode if possible. Depending on the characteristics of your application, one or the other might show better peak performance.
9393
* The Polyglot API comes with several tools and options to inspect the performance of your application:
9494
* `--cpusampler` and `--cputracer` will print a list of the hottest methods when the application is terminated. Use that list to figure out where most time is spent in your application.
9595
* `--experimental-options --memtracer` can help you understand the memory allocations of your application. Refer to the [Profiling Command Line Tool](https://github.com/oracle/graal/blob/master/docs/tools/profiling.md) reference for more detail.
9696

97-
### What is the difference between running GraalVM's JavaScript in a Native Image compared to the JVM?
97+
### What is the difference between running GraalVM's JavaScript in Native Image compared to the JVM?
9898
In essence, the JavaScript engine of GraalVM is a plain Java application.
9999
Running it on any JVM (JDK 8 or higher) is possible, but, for a better result, it should be GraalVM or a compatible JVMCI-enabled JDK using the GraalVM compiler.
100100
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.
101101

102-
Running in a Native Image means that the JavaScript engine, including all its dependencies from, e.g., the JDK, is pre-compiled into a native binary. This will tremendously speed up the startup of any JavaScript application, as GraalVM can immediately start to compile JavaScript code, without itself requiring to be compiled first.
102+
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. This will tremendously speed up the startup of any JavaScript application, as GraalVM can immediately start to compile JavaScript code, without itself requiring to be compiled first.
103103
This mode, however, will only give GraalVM access to Java classes known at the time of image creation.
104104
Most significantly, this means that the JavaScript-to-Java interoperability features are not available in this mode, as they would require dynamic class loading and execution of arbitrary Java code at runtime.
105105

docs/user/JavaInteroperability.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,12 @@ See the [Embedding Reference](https://www.graalvm.org/reference-manual/embed-lan
1414
The [Polyglot Programming](https://www.graalvm.org/reference-manual/polyglot-programming/) guide can be of additional help in that area.
1515
Specific migration guides for [Rhino](RhinoMigrationGuide.md) and [Nashorn](NashornMigrationGuide.md) are also available.
1616

17-
By default, GraalVM ships with `js` and `node` native launchers.
17+
GraalVM ships with the `js` native launcher.
18+
The Node.js support is packaged separately and can be installed with GraalVM Updater:
19+
```shell
20+
$GRAALVM/bin/gu install nodejs
21+
```
22+
Then the `node` launcher becomes available.
1823
Although other builds are possible, the following examples assume this setup is used.
1924

2025
## Enabling Java Interoperability

docs/user/Modules.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ GraalVM ships with a specific Node.js version that it is compatible with.
1515
Applications can therefore freely import and use NPM packages compatible with the supported Node.js version, including CommonJS, ES modules, and modules that use native bindings.
1616
To check and verify the Node.js version supported by GraalVM, simply run `bin/node --version`.
1717

18-
## Java-based applications (`Context` API)
18+
## Java-based Applications (`Context` API)
1919

2020
When embedded in a Java application (using the `Context` API), GraalVM JavaScript can execute JavaScript applications and modules that _do not_ depend on Node.js' built-in modules such as `'fs'`, `'events'`, or `'http'` or Node.js-specific functions such as `setTimeout()` or `setInterval()`.
2121
On the other hand, modules that depend on such Node.js builtins cannot be loaded in a GraalVM polyglot `Context`.

docs/user/NodeJS.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Applications can freely import and use NPM packages, including native ones.
1111

1212
For the differences between running the `node` native launcher and accessing Node.js/npm modules/ECMAScript modules from a Java Context, see [NodeJSVSJavaScriptContext](NodeJSVSJavaScriptContext.md).
1313

14-
## Installing the Node.js component
14+
## Installing Node.js Component
1515

1616
Since GraalVM 21.1, the Node.js support is packaged in a separate GraalVM component.
1717
It can be installed with the _GraalVM Updater_.
@@ -22,28 +22,28 @@ $GRAALVM/bin/gu install nodejs
2222

2323
This installs the `node` and `npm` binaries in the `$GRAALVM/bin` directory.
2424

25-
### Polyglot support in Node.js
25+
### Polyglot Support in Node.js
2626

2727
The Node.js component is able to use the polyglot language interoperability (flag: `--polyglot`) with other installed polyglot languages.
2828
This feature is available by default in JVM mode (flag: `--jvm`).
2929
For polyglot access to the Ruby language, you can e.g. use this command:
3030

3131
```shell
32-
$GRAALVM/bin/node --jvm --polyglot -e 'var array = Polyglot.eval("ruby", "[1,2,42,4]"); console.log(array[2]);'
32+
$GRAALVM_HOME/bin/node --jvm --polyglot -e 'var array = Polyglot.eval("ruby", "[1,2,42,4]"); console.log(array[2]);'
3333
```
3434

3535
To use the polyglot capabilities of `node` in the native mode (flag: `--native`), the `libpolyglot` needs to be rebuilt first.
3636
For this, the `native-image` component and the other languages need to be installed first, before the image can be rebuilt:
3737

3838
```shell
39-
$GRAALVM/bin/gu install native-image
40-
$GRAALVM/bin/gu rebuild-images libpolyglot
39+
$GRAALVM_HOME/bin/gu install native-image
40+
$GRAALVM_HOME/bin/gu rebuild-images libpolyglot
4141
```
4242

4343
After a successfull rebuild, the polyglot access is also available in the `--native` mode:
4444

4545
```shell
46-
$GRAALVM/bin/node --native --polyglot -e 'var array = Polyglot.eval("ruby", "[1,2,42,4]"); console.log(array[2]);'
46+
$GRAALVM_HOME/bin/node --native --polyglot -e 'var array = Polyglot.eval("ruby", "[1,2,42,4]"); console.log(array[2]);'
4747
```
4848

4949
## Running Node.js Applications

docs/user/Options.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@ For a full list of options of the JavaScript engine, pass the `--help:js` flag t
3131
To include internal options, use `--help:js:internal`.
3232
Note that those lists both include stable, supported options and experimental options.
3333

34-
### Provide options to the Launcher
34+
### Provide Options to the Launcher
3535
To the launcher, the options are passed with `--js.<option-name>=<value>`:
3636
```shell
3737
js --js.ecmascript-version=6
3838
```
3939

40-
### Provide options programmatically using the Context API
40+
### Provide Options Programmatically Using the Context API
4141
When started from Java via GraalVM's Polyglot feature, the options are passed programmatically to the `Context` object:
4242
```java
4343
Context context = Context.newBuilder("js")
@@ -57,7 +57,7 @@ In the native launchers (`js` and `node`), `--experimental-options` has to be pa
5757
When using a `Context`, the option `allowExperimentalOptions(true)` has to be called on the `Context.Builder`.
5858
See [ScriptEngine Implementation](ScriptEngine.md) on how to use experimental options with a `ScriptEngine`.
5959

60-
### Frequently used Stable Options
60+
### Frequently Used Stable Options
6161
The following stable options are frequently relevant:
6262
* `--js.ecmascript-version`: emulate a specific ECMAScript version. Integer value (`5`, `6`, etc., `2015`-`2022`), `"latest"` (latest supported version of the spec, including finished proposals), or `"staging"` (latest version including supported unfinished proposals), default is `"latest"`.
6363
* `--js.foreign-object-prototype`: provide JavaScript's default prototype to foreign objects that mimic JavaScript's own types (foreign Arrays, Objects and Functions). Boolean value, default is `false`.
@@ -74,7 +74,7 @@ It expects an integer value, where both the counting version numbers (`5`, `6`,
7474
As of GraalVM 21.2, `latest`, `staging` are supported, too.
7575
The default in GraalVM 22.x is the [`ECMAScript 2022 specification`](https://tc39.es/ecma262/).
7676
GraalVM JavaScript implements some features of the future draft specification and of open proposals, if you explicitly select that version and/or enable specific experimental flags.
77-
For production settings, it is recommended to set the `ecmascript-version` to a released, finalized version of the specification (e.g. `2021`).
77+
For production settings, it is recommended to set the `ecmascript-version` to a released, finalized version of the specification (e.g., `2021`).
7878

7979
Available versions are:
8080
* `5` for ECMAScript 5.x
@@ -99,7 +99,7 @@ It expects a Boolean value and the default is `false`.
9999
This option enables JavaScript's strict mode for all scripts.
100100
It expects a Boolean value and the default is `false`.
101101

102-
### Frequently used Experimental Options
102+
### Frequently Used Experimental Options
103103
Note that these options are experimental and are not guaranteed to be maintained or supported in the future.
104104
To use them, the `--experimental-options` flag is required or the experimental options have to be enabled on the Context, see above.
105105

docs/user/README.md

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ $GRAALVM/bin/gu install nodejs
3333
Alternatively, you can also download the Node.js runtime plugin installable manually and install it from a file, e.g.:
3434

3535
```shell
36-
$ $GRAALVM/bin/gu install --file ~/Downloads/nodejs-installable-svm-java17-linux-amd64-21.3.0.jar
36+
$ $GRAALVM/bin/gu install --file ~/Downloads/nodejs-installable-...-.jar
3737
```
3838

39-
This installs the `node` and `npm` binaries in the `$GRAALVM/bin` directory.
39+
This installs the `node` and `npm` binaries in the `$GRAALVM_HOME/bin` directory.
4040
Use the `node` utility to execute Node.js applications:
4141
```shell
4242
node [options] [filename] [args]
@@ -45,30 +45,31 @@ node [options] [filename] [args]
4545
To install a Node.js package, use the `npm` launcher from the GraalVM's `/bin` folder.
4646
The `npm` command is equivalent to the default Node.js command and supports all Node.js APIs.
4747

48-
1&#46; Install the `colors` and `ansispan` packages using `npm install` as follows:
49-
```shell
50-
npm install colors ansispan
51-
```
52-
After the packages are installed, you can use them from your application.
48+
1. Install the `colors` and `ansispan` packages using `npm install` as follows:
49+
```shell
50+
npm install colors ansispan
51+
```
52+
After the packages are installed, you can use them from your application.
5353

54-
2&#46; Add the following code snippet to a file named `app.js` and save it in the same directory where you installed the Node.js packages:
55-
```js
56-
const http = require("http");
57-
const span = require("ansispan");
58-
require("colors");
54+
2. Add the following code snippet to a file named `app.js` and save it in the same directory where you installed the Node.js packages:
55+
```js
56+
const http = require("http");
57+
const span = require("ansispan");
58+
require("colors");
5959
60-
http.createServer(function (request, response) {
61-
response.writeHead(200, {"Content-Type": "text/html"});
62-
response.end(span("Hello Graal.js!".green));
63-
}).listen(8000, function() { console.log("Graal.js server running at http://127.0.0.1:8000/".red); });
60+
http.createServer(function (request, response) {
61+
response.writeHead(200, {"Content-Type": "text/html"});
62+
response.end(span("Hello Graal.js!".green));
63+
}).listen(8000, function() { console.log("Graal.js server running at http://127.0.0.1:8000/".red); });
6464
65-
setTimeout(function() { console.log("DONE!"); process.exit(); }, 2000);
66-
```
65+
setTimeout(function() { console.log("DONE!"); process.exit(); }, 2000);
66+
```
67+
68+
3. Execute it on GraalVM using the `node` command as follows:
69+
```shell
70+
node app.js
71+
```
6772
68-
3&#46; Execute it on GraalVM using the `node` command as follows:
69-
```shell
70-
node app.js
71-
```
7273
For more information about running Node.js, continue to [Node.js Runtime](NodeJS.md).
7374
Node.js functionality is available when an application is started from the `node` binary launcher.
7475
Certain limits apply when launching a Node.js application or accessing npm packages from a Java context, see [Node.js vs. Java Script Context](NodeJSVSJavaScriptContext.md).
@@ -82,7 +83,7 @@ To enable Node.js or JavaScript interoperability with other languages, pass the
8283
8384
```shell
8485
node --jvm --polyglot
85-
Welcome to Node.js v12.15.0.
86+
Welcome to Node.js v16.14.2.
8687
Type ".help" for more information.
8788
> var array = Polyglot.eval("python", "[1,2,42,4]")
8889
> console.log(array[2]);
@@ -147,7 +148,8 @@ Hello Java!
147148
hello from node.js
148149
done
149150
```
150-
By setting the classpath, you instruct `node` to start a JVM properly. Both Node.js and JVM then run in the same process and the interoperability works using the same `Value` classes as above.
151+
By setting the classpath, you instruct `node` to start a JVM properly.
152+
Both Node.js and JVM then run in the same process and the interoperability works using the same `Value` classes as above.
151153
152154
Learn more about language interoperability in the [Java Interoperability](JavaInteroperability.md) guide.
153155

0 commit comments

Comments
 (0)