Skip to content

Commit 2821014

Browse files
Merge remote-tracking branch 'upstream/master' into record-tuple
# Conflicts: # graal-js/src/com.oracle.js.parser/src/com/oracle/js/parser/TokenType.java # graal-js/src/com.oracle.truffle.js.parser/src/com/oracle/truffle/js/parser/GraalJSTranslator.java # graal-js/src/com.oracle.truffle.js/src/com/oracle/truffle/js/nodes/access/ReadElementNode.java # graal-js/src/com.oracle.truffle.js/src/com/oracle/truffle/js/nodes/control/DeletePropertyNode.java
2 parents 1d593d2 + da4e7a6 commit 2821014

File tree

5,512 files changed

+365442
-281499
lines changed

Some content is hidden

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

5,512 files changed

+365442
-281499
lines changed

3rd_party_licenses.txt

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -931,7 +931,7 @@ THE POSSIBILITY OF SUCH DAMAGE.
931931

932932
================================================================================
933933

934-
Node.js 12.20.1
934+
Node.js 14.16.1
935935

936936
Node.js is licensed for use as follows:
937937

@@ -988,6 +988,8 @@ The externally maintained libraries used by Node.js are:
988988

989989
- Acorn, located at deps/acorn, is licensed as follows:
990990
"""
991+
MIT License
992+
991993
Copyright (C) 2012-2018 by various contributors (see AUTHORS)
992994

993995
Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -1049,29 +1051,6 @@ The externally maintained libraries used by Node.js are:
10491051
purpose. It is provided "as is" without express or implied warranty.
10501052
"""
10511053

1052-
- HTTP Parser, located at deps/http_parser, is licensed as follows:
1053-
"""
1054-
Copyright Joyent, Inc. and other Node contributors.
1055-
1056-
Permission is hereby granted, free of charge, to any person obtaining a copy
1057-
of this software and associated documentation files (the "Software"), to
1058-
deal in the Software without restriction, including without limitation the
1059-
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
1060-
sell copies of the Software, and to permit persons to whom the Software is
1061-
furnished to do so, subject to the following conditions:
1062-
1063-
The above copyright notice and this permission notice shall be included in
1064-
all copies or substantial portions of the Software.
1065-
1066-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1067-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1068-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1069-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1070-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
1071-
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
1072-
IN THE SOFTWARE.
1073-
"""
1074-
10751054
- cjs-module-lexer, located at deps/cjs-module-lexer, is licensed as follows:
10761055
"""
10771056
MIT License
@@ -2017,6 +1996,7 @@ The externally maintained libraries used by Node.js are:
20171996

20181997
- GYP, located at tools/gyp, is licensed as follows:
20191998
"""
1999+
Copyright (c) 2020 Node.js contributors. All rights reserved.
20202000
Copyright (c) 2009 Google Inc. All rights reserved.
20212001

20222002
Redistribution and use in source and binary forms, with or without

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,21 @@
33
This changelog summarizes major changes between GraalVM versions of the GraalVM JavaScript (ECMAScript) language runtime.
44
The main focus is on user-observable behavior of the engine.
55

6+
## Version 21.2.0
7+
* Graal.js now prints a warning when runtime compilation is not supported. This warning can be disabled using the '--engine.WarnInterpreterOnly=false' option or the '-Dpolyglot.engine.WarnInterpreterOnly=false' system property.
8+
* Added the `js.unhandled-rejections` option to track unhandled promise rejections in a polyglot `Context`. By default, the option is set to `none`, and unhandled promise rejections are not tracked.
9+
* Implemented the [New Set Methods](https://github.com/tc39/proposal-set-methods) proposal. It is available behind an experimental flag (`--js.new-set-methods`).
10+
611
## Version 21.1.0
12+
* Updated Node.js to version 14.16.1.
713
* Prototype of WebAssembly JavaScript Interface implemented. It is available behind the `--js.webassembly` flag.
814
* Implemented iterator interop support, enabling foreign objects that have an iterator to be used where JS expects iterables, as well as JS iterables to be used in other languages and via the [Value](https://www.graalvm.org/sdk/javadoc/org/graalvm/polyglot/Value.html#getIterator--) API.
915
* Adopted new buffer interop support, allowing foreign buffers to be used with typed arrays and `DataView`, without copying. Likewise enables `ArrayBuffer` to be used in other languages.
1016
* Experimental option `js.array-sort-inherited` was removed. Values visible through holes in array(-like) object are always sorted according to the latest version of ECMAScript specification.
1117
* Updated ICU4J library to version 68.2.
18+
* Implemented the [Atomics.waitAsync](https://github.com/tc39/proposal-atomics-wait-async) proposal. It is available in ECMAScript 2022 mode (`--js.ecmascript-version=2022`).
19+
* Implemented hash map interop support. Allows foreign hash maps to be iterated using `for in/of` loops, `new Map(hash)`, `Array.from(hash)`, etc. If the `--js.foreign-hash-properties` option is enabled (default), foreign hash maps can also be accessed using `hash[key]`, `hash.key`, and used in `{...hash}`. If the `--js.foreign-object-prototype` option is enabled, foreign hash maps also have `Map.prototype` methods.
20+
* Moved GraalVM-Node.js to a separate installable component. In a GraalVM distribution it needs to be manually installed with `$GRAALVM/bin/gu install nodejs`.
1221

1322
## Version 21.0.0
1423
* ECMAScript 2021 mode/features enabled by default.

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,21 @@ New features, e.g. `ECMAScript proposals` scheduled to land in future editions,
4141

4242
In addition, some popular extensions of other engines are supported, see [`JavaScriptCompatibility.md`](https://github.com/graalvm/graaljs/tree/master/docs/user/JavaScriptCompatibility.md).
4343

44+
### Node.js support
45+
4446
GraalVM JavaScript can execute Node.js applications.
4547
It provides high compatibility with existing npm packages, with high likelyhood that your application will run out of the box.
4648
This includes npm packages with native implementations.
4749
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.
4850
Node.js support is only available in full GraalVM releases, but not in the `standalone` GraalVM JavaScript distribution.
4951

52+
Since GraalVM 21.1, the Node.js support is packaged as a separate component that can be installed using the _GraalVM Updater_:
53+
54+
```shell
55+
$ $GRAALVM/bin/gu install nodejs
56+
$ $GRAALVM/bin/node --version
57+
```
58+
5059
### Compatibility on Operating Systems
5160

5261
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).

ci.jsonnet

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ local common = import 'common.jsonnet';
66
// Used to run fewer jobs
77
local debug = false,
88

9-
local overlay = 'bbf690a852d1b13508d41437c5a5566d6f8f963e',
9+
local overlay = '886aca6f23b314483bf8ff1e6b889d008aa8236a',
1010

1111
local no_overlay = 'cb733e564850cd37b685fcef6f3c16b59802b22c',
1212

common.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,20 @@
22
"README": "This file contains definitions that are useful for the hocon and jsonnet CI files of multiple repositories.",
33

44
"jdks": {
5-
"openjdk8": {"name": "openjdk", "version": "8u292+05-jvmci-21.1-b02", "platformspecific": true },
6-
"oraclejdk8": {"name": "oraclejdk", "version": "8u291+07-jvmci-21.1-b02", "platformspecific": true },
7-
"oraclejdk8Debug": {"name": "oraclejdk", "version": "8u291+07-jvmci-21.1-b02-fastdebug", "platformspecific": true },
5+
"openjdk8": {"name": "openjdk", "version": "8u292+09-jvmci-21.1-b05", "platformspecific": true },
6+
"oraclejdk8": {"name": "oraclejdk", "version": "8u291+10-jvmci-21.1-b05", "platformspecific": true },
7+
"oraclejdk8Debug": {"name": "oraclejdk", "version": "8u291+10-jvmci-21.1-b05-fastdebug", "platformspecific": true },
88

99
"openjdk11": {"name": "openjdk", "version": "11.0.3+7", "platformspecific": true },
1010
"oraclejdk11": {"name": "oraclejdk", "version": "11.0.6+8", "platformspecific": true },
11-
"labsjdk-ce-11": {"name": "labsjdk", "version": "ce-11.0.11+5-jvmci-21.1-b02", "platformspecific": true },
12-
"labsjdk-ee-11": {"name": "labsjdk", "version": "ee-11.0.11+5-jvmci-21.1-b02", "platformspecific": true },
11+
"labsjdk-ce-11": {"name": "labsjdk", "version": "ce-11.0.11+8-jvmci-21.1-b05", "platformspecific": true },
12+
"labsjdk-ee-11": {"name": "labsjdk", "version": "ee-11.0.11+9-jvmci-21.1-b05", "platformspecific": true },
1313

1414
"oraclejdk16": {"name": "oraclejdk", "version": "16.0.1+4", "platformspecific": true },
15-
"labsjdk-ce-16": {"name": "labsjdk", "version": "ce-16+36-jvmci-21.1-b02", "platformspecific": true },
16-
"labsjdk-ce-16Debug": {"name": "labsjdk", "version": "ce-16+36-jvmci-21.1-b02-debug", "platformspecific": true },
17-
"labsjdk-ee-16": {"name": "labsjdk", "version": "ee-16+36-jvmci-21.1-b02", "platformspecific": true },
18-
"labsjdk-ee-16Debug": {"name": "labsjdk", "version": "ee-16+36-jvmci-21.1-b02-debug", "platformspecific": true }
15+
"labsjdk-ce-16": {"name": "labsjdk", "version": "ce-16.0.1+9-jvmci-21.1-b05", "platformspecific": true },
16+
"labsjdk-ce-16Debug": {"name": "labsjdk", "version": "ce-16.0.1+9-jvmci-21.1-b05-debug", "platformspecific": true },
17+
"labsjdk-ee-16": {"name": "labsjdk", "version": "ee-16.0.1+9-jvmci-21.1-b05", "platformspecific": true },
18+
"labsjdk-ee-16Debug": {"name": "labsjdk", "version": "ee-16.0.1+9-jvmci-21.1-b05-debug", "platformspecific": true }
1919
},
2020

2121
"COMMENT" : "The devkits versions reflect those used to build the JVMCI JDKs (e.g., see devkit_platform_revisions in <jdk>/make/conf/jib-profiles.js)",

common.jsonnet

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,9 @@ local common_json = (import "common.json");
5252
linux: common + {
5353
packages+: common_json.sulong.deps.linux.packages + {
5454
'apache/ab': '==2.3',
55-
binutils: '==2.23.2',
56-
gcc: '==8.3.0',
55+
devtoolset: '==7', # GCC 7.3.1, make 4.2.1, binutils 2.28, valgrind 3.13.0
5756
git: '>=1.8.3',
5857
maven: '==3.3.9',
59-
valgrind: '>=3.9.0',
6058
},
6159
capabilities+: ['linux', 'amd64'],
6260
},
@@ -72,7 +70,7 @@ local common_json = (import "common.json");
7270
linux_aarch64: common + {
7371
capabilities+: ['linux', 'aarch64'],
7472
packages+: {
75-
gcc: '==8.3.0',
73+
devtoolset: '==7', # GCC 7.3.1, make 4.2.1, binutils 2.28, valgrind 3.13.0
7674
}
7775
},
7876

@@ -82,7 +80,7 @@ local common_json = (import "common.json");
8280
// for compatibility with macOS El Capitan
8381
MACOSX_DEPLOYMENT_TARGET: '10.11',
8482
},
85-
capabilities: ['darwin', 'amd64'],
83+
capabilities: ['darwin_mojave', 'amd64'],
8684
},
8785

8886
windows: common + {

docs/user/FAQ.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ Still, several sources of differences have to be considered:
2020
- **Setup:**
2121
GraalVM mostly mimicks the original setup of Node, including the `node` executable, `npm`, and similar. However, not all command-line options are supported (or behave exactly identically). You need to (re-)compile native modules against the v8.h file, etc.
2222

23+
Since GraalVM 21.1, Node.js and all related executables (e.g., `node`, `npm`, etc.) are not included by default in the GraalVM binary.
24+
Node.js support is now packaged in a separate component that can be installed with the _GraalVM Updater_ using `$GRAALVM/bin/gu install nodejs`.
25+
2326
- **Internals:**
2427
GraalVM is implemented on top of a JVM, and thus has a different internal architecture than Node.js based on V8. This implies that some internal mechanisms behave differently and cannot exactly replicate V8 behaviour. This will hardly ever affect user code, but might affect modules implemented natively, depending on V8 internals.
2528

@@ -233,3 +236,35 @@ HostAccess ha = HostAccess.newBuilder(HostAccess.EXPLICIT)
233236
.allowAccess(Function.class.getMethod("apply", Object.class))
234237
.build();
235238
```
239+
240+
### Warning: Implementation does not support runtime compilation.
241+
242+
If you get the following warning, you are not running on GraalVM or a JVMCI-enabled JVM using the GraalVM compiler:
243+
```
244+
[engine] WARNING: The polyglot context is using an implementation that does not support runtime compilation.
245+
The guest application code will therefore be executed in interpreted mode only.
246+
Execution only in interpreted mode will strongly impact the guest application performance.
247+
For more information on using GraalVM see https://www.graalvm.org/java/quickstart/.
248+
To disable this warning the '--engine.WarnInterpreterOnly=false' option or use the '-Dpolyglot.engine.WarnInterpreterOnly=false' system property.
249+
```
250+
251+
To resolve this, use [GraalVM](https://www.graalvm.org/java/quickstart/) or see [RunOnJDK.md](https://github.com/oracle/graaljs/blob/master/docs/user/RunOnJDK.md) for instructions how to set up the Graal compiler on a compatible JVMCI-enabled stock JDK.
252+
253+
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.:
254+
```java
255+
try (Context ctx = Context.newBuilder("js")
256+
.option("engine.WarnInterpreterOnly", "false")
257+
.build()) {
258+
ctx.eval("js", "console.log('Greetings!');");
259+
}
260+
```
261+
Note that when using an explicit polyglot engine, the option has to be set on the `Engine`, e.g.:
262+
```java
263+
try (Engine engine = Engine.newBuilder()
264+
.option("engine.WarnInterpreterOnly", "false")
265+
.build()) {
266+
try (Context ctx = Context.newBuilder("js").engine(engine).build()) {
267+
ctx.eval("js", "console.log('Greetings!');");
268+
}
269+
}
270+
```

docs/user/NodeJS.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,41 @@ Applications can freely import and use NPM packages, including native ones.
55

66
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).
77

8+
## Installing the Node.js component
9+
10+
Since GraalVM 21.1, the Node.js support is packaged in a separate GraalVM component.
11+
It can be installed with the _GraalVM Updater_.
12+
13+
```shell
14+
$ $GRAALVM/bin/gu install nodejs
15+
```
16+
17+
This installs the `node` and `npm` binaries in the `$GRAALVM/bin` directory.
18+
19+
### Polyglot support in Node.js
20+
21+
The Node.js component is able to use the polyglot language interoperability (flag: `--polyglot`) with other installed polyglot languages.
22+
This feature is available by default in JVM mode (flag: `--jvm`).
23+
For polyglot access to the Ruby language, you can e.g. use this command:
24+
25+
```shell
26+
$ $GRAALVM/bin/node --jvm --polyglot -e 'var array = Polyglot.eval("ruby", "[1,2,42,4]"); console.log(array[2]);'
27+
```
28+
29+
To use the polyglot capabilities of `node` in the native mode (flag: `--native`), the `libpolyglot` needs to be rebuilt first.
30+
For this, the `native-image` component and the other languages need to be installed first, before the image can be rebuilt:
31+
32+
```shell
33+
$ $GRAALVM/bin/gu install native-image
34+
$ $GRAALVM/bin/gu rebuild-images libpolyglot
35+
```
36+
37+
After a successfull rebuild, the polyglot access is also available in the `--native` mode:
38+
39+
```shell
40+
$ $GRAALVM/bin/node --native --polyglot -e 'var array = Polyglot.eval("ruby", "[1,2,42,4]"); console.log(array[2]);'
41+
```
42+
843
## Running Node.js Applications
944

1045
To run Node.js-based applications, use the `node` launcher in the GraalVM distribution:

docs/user/README.md

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,32 +7,39 @@ To migrate the code previously targeted to the Nashorn or Rhino engines, migrati
77

88
## Running JavaScript
99

10-
GraalVM can run plain JavaScript code:
10+
GraalVM can run plain JavaScript (ECMAScript) code:
1111
```shell
1212
js [options] [filename...] -- [args]
1313
```
1414

1515
For information about the compatibility of GraalVM JavaScript with existing standards and engines, see [JavaScriptCompatibility](JavaScriptCompatibility.md).
1616

1717
## Running Node.js
18-
GraalVM is adapted to run unmodified Node.js applications. Applications can
19-
import npm modules, including native ones.
18+
GraalVM is capable of executing unmodified Node.js applications.
19+
Applications can import npm modules, including native ones.
20+
Since GraalVM 21.1, the Node.js support is packaged in a separate GraalVM component.
21+
It can be installed with the _GraalVM Updater_.
2022

21-
To run Node.js-based applications, use the `node` utility bundled with GraalVM by default:
23+
```shell
24+
$ $GRAALVM/bin/gu install nodejs
25+
```
26+
27+
This installs the `node` and `npm` binaries in the `$GRAALVM/bin` directory.
28+
Use the `node` utility to execute Node.js applications:
2229
```shell
2330
node [options] [filename] [args]
2431
```
2532

26-
To install a Node.js module, use the `npm` launcher from the GraalVM's `/bin` folder. The `npm` command is equivalent to the default Node.js command and supports all Node.js APIs.
33+
To install a Node.js package, use the `npm` launcher from the GraalVM's `/bin` folder.
34+
The `npm` command is equivalent to the default Node.js command and supports all Node.js APIs.
2735

28-
1&#46; Install the `colors` and `ansispan` modules using `npm install` as
29-
follows:
36+
1&#46; Install the `colors` and `ansispan` packages using `npm install` as follows:
3037
```shell
3138
npm install colors ansispan
3239
```
33-
After the modules are installed, you can use them from your application.
40+
After the packages are installed, you can use them from your application.
3441

35-
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 modules:
42+
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:
3643
```js
3744
const http = require("http");
3845
const span = require("ansispan");
@@ -52,7 +59,7 @@ node app.js
5259
```
5360
For more information about running Node.js, continue to [Node.js Runtime](NodeJS.md).
5461
Node.js functionality is available when an application is started from the `node` binary launcher.
55-
Certain limits apply when launching a Node.js application or accessing npm modules from a Java context, see [Node.js vs. Java Script Context](NodeJSVSJavaScriptContext.md).
62+
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).
5663

5764
## Interoperability
5865

graal-js/mx.graal-js/mx_graal_js.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,10 @@ def parse_js_args(args, default_cp=None, useDoubleDash=False):
127127
if skip:
128128
skip = False
129129
continue
130-
elif any(arg.startswith(prefix) for prefix in ['-X', '-G:', '-D', '-verbose', '-ea', '-javaagent']) or arg in ['-esa', '-d64', '-server']:
130+
elif any(arg.startswith(prefix) for prefix in ['-X', '-D', '-verbose', '-ea', '-javaagent:', '-agentlib:', '-agentpath:']) or arg in ['-esa', '-d64', '-server']:
131131
vm_args += [arg]
132+
elif arg.startswith('--vm.D') or arg.startswith('--vm.X'):
133+
vm_args += ['-' + arg[5:]]
132134
elif useDoubleDash and arg == '--':
133135
remainder += args[i:]
134136
break
@@ -158,6 +160,10 @@ def _append_default_js_vm_args(vm_args, min_heap='2g', max_heap='2g', stack_size
158160
vm_args += ['-Xmx' + max_heap]
159161
if stack_size and not any(x.startswith('-Xss') for x in vm_args):
160162
vm_args += ['-Xss' + stack_size]
163+
164+
if mx.suite('compiler', fatalIfMissing=False) is None and not any(x.startswith('-Dpolyglot.engine.WarnInterpreterOnly') for x in vm_args + get_jdk().java_args):
165+
vm_args += ['-Dpolyglot.engine.WarnInterpreterOnly=false']
166+
161167
return vm_args
162168

163169
def _js_cmd_line(args, main_class, default_cp=None, append_default_args=True):
@@ -324,7 +330,8 @@ def is_included(path):
324330
)
325331
],
326332
boot_jars=['graal-js:GRAALJS_SCRIPTENGINE'],
327-
supported=True,
333+
installable=True,
334+
stability="supported",
328335
))
329336

330337
def verify_ci(args):

graal-js/mx.graal-js/native-image.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ JavaArgs = -Xmx3G \
77
-Dpolyglot.image-build-time.PreinitializeContexts=js
88

99
Args = -H:MaxRuntimeCompileMethods=9200 \
10-
--initialize-at-build-time=com.oracle.truffle.js,com.oracle.js.parser,com.oracle.truffle.trufflenode,com.oracle.truffle.regex \
10+
--initialize-at-build-time=com.oracle.truffle.js,com.oracle.js.parser,com.oracle.truffle.regex \
1111
--initialize-at-run-time=com.ibm.icu \
1212
-H:ReflectionConfigurationResources=com/oracle/truffle/js/runtime/resources/reflect-config.json \
1313
-H:ResourceConfigurationResources=com/oracle/truffle/js/runtime/resources/resource-config.json

0 commit comments

Comments
 (0)