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: docs/user/FAQ.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -89,17 +89,17 @@ Solution:
89
89
Here are a few tips you can follow to analyse and improve peak performance:
90
90
91
91
* 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.
93
93
* The Polyglot API comes with several tools and options to inspect the performance of your application:
94
94
*`--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.
95
95
*`--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.
96
96
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?
98
98
In essence, the JavaScript engine of GraalVM is a plain Java application.
99
99
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.
100
100
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.
101
101
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.
103
103
This mode, however, will only give GraalVM access to Java classes known at the time of image creation.
104
104
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.
Copy file name to clipboardExpand all lines: docs/user/Modules.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,7 +15,7 @@ GraalVM ships with a specific Node.js version that it is compatible with.
15
15
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.
16
16
To check and verify the Node.js version supported by GraalVM, simply run `bin/node --version`.
17
17
18
-
## Java-based applications (`Context` API)
18
+
## Java-based Applications (`Context` API)
19
19
20
20
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()`.
21
21
On the other hand, modules that depend on such Node.js builtins cannot be loaded in a GraalVM polyglot `Context`.
Copy file name to clipboardExpand all lines: docs/user/NodeJS.md
+6-6Lines changed: 6 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,7 +11,7 @@ Applications can freely import and use NPM packages, including native ones.
11
11
12
12
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).
13
13
14
-
## Installing the Node.js component
14
+
## Installing Node.js Component
15
15
16
16
Since GraalVM 21.1, the Node.js support is packaged in a separate GraalVM component.
Copy file name to clipboardExpand all lines: docs/user/Options.md
+5-5Lines changed: 5 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -31,13 +31,13 @@ For a full list of options of the JavaScript engine, pass the `--help:js` flag t
31
31
To include internal options, use `--help:js:internal`.
32
32
Note that those lists both include stable, supported options and experimental options.
33
33
34
-
### Provide options to the Launcher
34
+
### Provide Options to the Launcher
35
35
To the launcher, the options are passed with `--js.<option-name>=<value>`:
36
36
```shell
37
37
js --js.ecmascript-version=6
38
38
```
39
39
40
-
### Provide options programmatically using the Context API
40
+
### Provide Options Programmatically Using the Context API
41
41
When started from Java via GraalVM's Polyglot feature, the options are passed programmatically to the `Context` object:
42
42
```java
43
43
Context context =Context.newBuilder("js")
@@ -57,7 +57,7 @@ In the native launchers (`js` and `node`), `--experimental-options` has to be pa
57
57
When using a `Context`, the option `allowExperimentalOptions(true)` has to be called on the `Context.Builder`.
58
58
See [ScriptEngine Implementation](ScriptEngine.md) on how to use experimental options with a `ScriptEngine`.
59
59
60
-
### Frequently used Stable Options
60
+
### Frequently Used Stable Options
61
61
The following stable options are frequently relevant:
62
62
*`--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"`.
63
63
*`--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`,
74
74
As of GraalVM 21.2, `latest`, `staging` are supported, too.
75
75
The default in GraalVM 22.x is the [`ECMAScript 2022 specification`](https://tc39.es/ecma262/).
76
76
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`).
78
78
79
79
Available versions are:
80
80
*`5` for ECMAScript 5.x
@@ -99,7 +99,7 @@ It expects a Boolean value and the default is `false`.
99
99
This option enables JavaScript's strict mode for all scripts.
100
100
It expects a Boolean value and the default is `false`.
101
101
102
-
### Frequently used Experimental Options
102
+
### Frequently Used Experimental Options
103
103
Note that these options are experimental and are not guaranteed to be maintained or supported in the future.
104
104
To use them, the `--experimental-options` flag is required or the experimental options have to be enabled on the Context, see above.
3. Execute it on GraalVM using the `node`command as follows:
69
+
```shell
70
+
node app.js
71
+
```
67
72
68
-
3. Execute it on GraalVM using the `node` command as follows:
69
-
```shell
70
-
node app.js
71
-
```
72
73
For more information about running Node.js, continue to [Node.js Runtime](NodeJS.md).
73
74
Node.js functionality is available when an application is started from the `node` binary launcher.
74
75
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
82
83
83
84
```shell
84
85
node --jvm --polyglot
85
-
Welcome to Node.js v12.15.0.
86
+
Welcome to Node.js v16.14.2.
86
87
Type ".help"for more information.
87
88
> var array = Polyglot.eval("python", "[1,2,42,4]")
88
89
> console.log(array[2]);
@@ -147,7 +148,8 @@ Hello Java!
147
148
hello from node.js
148
149
done
149
150
```
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.
151
153
152
154
Learn more about language interoperability in the [Java Interoperability](JavaInteroperability.md) guide.
0 commit comments