Skip to content

Commit 7d4bf7c

Browse files
committed
[GR-53476] Backport to 24.0: Upgrading the underlying Node.js to version 18.20.2.
PullRequest: js/3122
2 parents 2e37812 + 685d8a8 commit 7d4bf7c

File tree

1,368 files changed

+140920
-160565
lines changed

Some content is hidden

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

1,368 files changed

+140920
-160565
lines changed

3rd_party_licenses.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,7 @@ THE POSSIBILITY OF SUCH DAMAGE.
512512

513513
================================================================================
514514

515-
Node.js 18.19.1
515+
Node.js 18.20.2
516516

517517
Node.js is licensed for use as follows:
518518

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ The main focus is on user-observable behavior of the engine.
55
Changelog may include unreleased versions.
66
See [release calendar](https://www.graalvm.org/release-calendar/) for release dates.
77

8+
## Version 24.0.2
9+
* Updated Node.js to version 18.20.2.
10+
811
## Version 24.0.1
912
* Updated Node.js to version 18.19.1.
1013

graal-js/src/com.oracle.truffle.js/src/com/oracle/truffle/js/lang/JavaScriptLanguage.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* The Universal Permissive License (UPL), Version 1.0
@@ -186,6 +186,8 @@ public final class JavaScriptLanguage extends TruffleLanguage<JSRealm> {
186186
ensureErrorClassesInitialized();
187187
}
188188

189+
private int realmCount;
190+
189191
public JavaScriptLanguage() {
190192
this.promiseJobsQueueEmptyAssumption = Truffle.getRuntime().createAssumption("PromiseJobsQueueEmpty");
191193
}
@@ -359,6 +361,9 @@ private JSContext newJSContext(Env env) {
359361

360362
@Override
361363
protected void initializeContext(JSRealm realm) {
364+
synchronized (this) {
365+
realmCount++;
366+
}
362367
realm.initialize();
363368
}
364369

@@ -457,6 +462,13 @@ protected void disposeContext(JSRealm realm) {
457462
realm.getContext().getTimeProfiler().printCumulative();
458463
}
459464
realm.dispose();
465+
synchronized (this) {
466+
if (--realmCount == 0) {
467+
// Clear inverted maps that are no longer needed to ensure
468+
// that they are not stored in aux engine cache
469+
realm.getContext().clearSymbolInvertedMaps();
470+
}
471+
}
460472
}
461473

462474
@Override

graal-js/src/com.oracle.truffle.js/src/com/oracle/truffle/js/runtime/JSContext.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* The Universal Permissive License (UPL), Version 1.0
@@ -269,6 +269,21 @@ public class JSContext {
269269
// Used to track singleton symbols allocations across aux engine cache runs.
270270
private Object symbolUsageMarker = new Object();
271271

272+
private final Map<Symbol, Void> unregisteredSymbols = new WeakHashMap<>();
273+
274+
@TruffleBoundary
275+
public void unregisteredSymbolCreated(Symbol symbol) {
276+
synchronized (this) {
277+
unregisteredSymbols.put(symbol, null);
278+
}
279+
}
280+
281+
public void clearSymbolInvertedMaps() {
282+
for (Symbol symbol : unregisteredSymbols.keySet()) {
283+
symbol.clearInvertedMap();
284+
}
285+
}
286+
272287
public void resetSymbolUsageMarker() {
273288
CompilerAsserts.neverPartOfCompilation();
274289
// Symbols that were used exactly once in previous executions, will most-likely

graal-js/src/com.oracle.truffle.js/src/com/oracle/truffle/js/runtime/Symbol.java

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* The Universal Permissive License (UPL), Version 1.0
@@ -69,67 +69,67 @@ public final class Symbol implements TruffleObject {
6969
* A method that determines if a constructor object recognizes an object as one of the
7070
* constructor's instances. Called by the semantics of the instanceof operator.
7171
*/
72-
public static final Symbol SYMBOL_HAS_INSTANCE = Symbol.create(Strings.constant("Symbol.hasInstance"));
72+
public static final Symbol SYMBOL_HAS_INSTANCE = createWellKnown(Strings.constant("Symbol.hasInstance"));
7373
/**
7474
* A Boolean valued property that if true indicates that an object should be flatten to its
7575
* array elements by Array.prototype.concat.
7676
*/
77-
public static final Symbol SYMBOL_IS_CONCAT_SPREADABLE = Symbol.create(Strings.constant("Symbol.isConcatSpreadable"));
77+
public static final Symbol SYMBOL_IS_CONCAT_SPREADABLE = createWellKnown(Strings.constant("Symbol.isConcatSpreadable"));
7878
/**
7979
* A method that returns the default iterator for an object. Called by the semantics of the
8080
* for-of statement.
8181
*/
82-
public static final Symbol SYMBOL_ITERATOR = Symbol.create(Strings.constant("Symbol.iterator"));
82+
public static final Symbol SYMBOL_ITERATOR = createWellKnown(Strings.constant("Symbol.iterator"));
8383
/**
8484
* A method that returns the default asynchronous iterator for an object. Called by the
8585
* semantics of the for-await-of statement.
8686
*/
87-
public static final Symbol SYMBOL_ASYNC_ITERATOR = Symbol.create(Strings.constant("Symbol.asyncIterator"));
87+
public static final Symbol SYMBOL_ASYNC_ITERATOR = createWellKnown(Strings.constant("Symbol.asyncIterator"));
8888
/**
8989
* A regular expression method that matches the regular expression against a string. Called by
9090
* the String.prototype.match method.
9191
*/
92-
public static final Symbol SYMBOL_MATCH = Symbol.create(Strings.constant("Symbol.match"));
92+
public static final Symbol SYMBOL_MATCH = createWellKnown(Strings.constant("Symbol.match"));
9393
/**
9494
* A regular expression method that returns an iterator, that yields matches of the regular
9595
* expression against a string. Called by the String.prototype.matchAll method.
9696
*/
97-
public static final Symbol SYMBOL_MATCH_ALL = Symbol.create(Strings.constant("Symbol.matchAll"));
97+
public static final Symbol SYMBOL_MATCH_ALL = createWellKnown(Strings.constant("Symbol.matchAll"));
9898
/**
9999
* A regular expression method that replaces matched substrings of a string. Called by the
100100
* String.prototype.replace method.
101101
*/
102-
public static final Symbol SYMBOL_REPLACE = Symbol.create(Strings.constant("Symbol.replace"));
102+
public static final Symbol SYMBOL_REPLACE = createWellKnown(Strings.constant("Symbol.replace"));
103103
/**
104104
* A regular expression method that returns the index within a string that matches the regular
105105
* expression. Called by the String.prototype.search method.
106106
*/
107-
public static final Symbol SYMBOL_SEARCH = Symbol.create(Strings.constant("Symbol.search"));
107+
public static final Symbol SYMBOL_SEARCH = createWellKnown(Strings.constant("Symbol.search"));
108108
/**
109109
* A function valued property that is the constructor function that is used to create derived
110110
* objects.
111111
*/
112-
public static final Symbol SYMBOL_SPECIES = Symbol.create(Strings.constant("Symbol.species"));
112+
public static final Symbol SYMBOL_SPECIES = createWellKnown(Strings.constant("Symbol.species"));
113113
/**
114114
* A regular expression method that splits a string at the indices that match the regular
115115
* expression. Called by the String.prototype.split method.
116116
*/
117-
public static final Symbol SYMBOL_SPLIT = Symbol.create(Strings.constant("Symbol.split"));
117+
public static final Symbol SYMBOL_SPLIT = createWellKnown(Strings.constant("Symbol.split"));
118118
/**
119119
* A method that converts an object to a corresponding primitive value. Called by the
120120
* ToPrimitive abstract operation.
121121
*/
122-
public static final Symbol SYMBOL_TO_PRIMITIVE = Symbol.create(Strings.constant("Symbol.toPrimitive"));
122+
public static final Symbol SYMBOL_TO_PRIMITIVE = createWellKnown(Strings.constant("Symbol.toPrimitive"));
123123
/**
124124
* A property whose String value that is used in the creation of the default string description
125125
* of an object. Called by the built-in method Object.prototype.toString.
126126
*/
127-
public static final Symbol SYMBOL_TO_STRING_TAG = Symbol.create(Strings.constant("Symbol.toStringTag"));
127+
public static final Symbol SYMBOL_TO_STRING_TAG = createWellKnown(Strings.constant("Symbol.toStringTag"));
128128
/**
129129
* A property whose value is an Object whose own property names are property names that are
130130
* excluded from the with environment bindings of the associated object.
131131
*/
132-
public static final Symbol SYMBOL_UNSCOPABLES = Symbol.create(Strings.constant("Symbol.unscopables"));
132+
public static final Symbol SYMBOL_UNSCOPABLES = createWellKnown(Strings.constant("Symbol.unscopables"));
133133

134134
/**
135135
* [[Description]] of Symbol if it is a String value, {@code null} otherwise ([[Description]] is
@@ -154,6 +154,12 @@ private Symbol(TruffleString description, boolean registered, boolean isPrivate)
154154
}
155155

156156
public static Symbol create(TruffleString description) {
157+
Symbol symbol = new Symbol(description, false, false);
158+
JavaScriptLanguage.getCurrentLanguage().getJSContext().unregisteredSymbolCreated(symbol);
159+
return symbol;
160+
}
161+
162+
private static Symbol createWellKnown(TruffleString description) {
157163
return new Symbol(description, false, false);
158164
}
159165

@@ -269,4 +275,9 @@ public void setInvertedMap(Map<WeakMap, Object> invMap) {
269275
assert this.invertedMap == null;
270276
this.invertedMap = invMap;
271277
}
278+
279+
void clearInvertedMap() {
280+
this.invertedMap = null;
281+
}
282+
272283
}

graal-nodejs/.eslintrc.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,7 @@ module.exports = {
4444
parserOptions: {
4545
babelOptions: {
4646
plugins: [
47-
[
48-
Module._findPath('@babel/plugin-syntax-import-attributes'),
49-
{ deprecatedAssertSyntax: true },
50-
],
47+
Module._findPath('@babel/plugin-syntax-import-attributes'),
5148
],
5249
},
5350
requireConfigFile: false,

graal-nodejs/CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,10 @@ release.
3232
</tr>
3333
<tr>
3434
<td valign="top">
35-
<b><a href="doc/changelogs/CHANGELOG_V18.md#18.19.1">18.19.1</a></b><br/>
35+
<b><a href="doc/changelogs/CHANGELOG_V18.md#18.20.2">18.20.2</a></b><br/>
36+
<a href="doc/changelogs/CHANGELOG_V18.md#18.20.1">18.20.1</a><br/>
37+
<a href="doc/changelogs/CHANGELOG_V18.md#18.20.0">18.20.0</a><br/>
38+
<a href="doc/changelogs/CHANGELOG_V18.md#18.19.1">18.19.1</a><br/>
3639
<a href="doc/changelogs/CHANGELOG_V18.md#18.19.0">18.19.0</a><br/>
3740
<a href="doc/changelogs/CHANGELOG_V18.md#18.18.2">18.18.2</a><br/>
3841
<a href="doc/changelogs/CHANGELOG_V18.md#18.18.1">18.18.1</a><br/>

graal-nodejs/benchmark/_http-benchmarkers.js

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,16 @@ exports.PORT = Number(process.env.PORT) || 12346;
1212

1313
class AutocannonBenchmarker {
1414
constructor() {
15+
const shell = (process.platform === 'win32');
1516
this.name = 'autocannon';
16-
this.executable =
17-
process.platform === 'win32' ? 'autocannon.cmd' : 'autocannon';
18-
const result = child_process.spawnSync(this.executable, ['-h']);
19-
this.present = !(result.error && result.error.code === 'ENOENT');
17+
this.opts = { shell };
18+
this.executable = shell ? 'autocannon.cmd' : 'autocannon';
19+
const result = child_process.spawnSync(this.executable, ['-h'], this.opts);
20+
if (shell) {
21+
this.present = (result.status === 0);
22+
} else {
23+
this.present = !(result.error && result.error.code === 'ENOENT');
24+
}
2025
}
2126

2227
create(options) {
@@ -27,11 +32,15 @@ class AutocannonBenchmarker {
2732
'-n',
2833
];
2934
for (const field in options.headers) {
30-
args.push('-H', `${field}=${options.headers[field]}`);
35+
if (this.opts.shell) {
36+
args.push('-H', `'${field}=${options.headers[field]}'`);
37+
} else {
38+
args.push('-H', `${field}=${options.headers[field]}`);
39+
}
3140
}
3241
const scheme = options.scheme || 'http';
3342
args.push(`${scheme}://127.0.0.1:${options.port}${options.path}`);
34-
const child = child_process.spawn(this.executable, args);
43+
const child = child_process.spawn(this.executable, args, this.opts);
3544
return child;
3645
}
3746

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
'use strict';
2+
3+
// This benchmarks compiling scripts that hit the in-isolate compilation
4+
// cache (by having the same source).
5+
const common = require('../common.js');
6+
const fs = require('fs');
7+
const vm = require('vm');
8+
const fixtures = require('../../test/common/fixtures.js');
9+
const scriptPath = fixtures.path('snapshot', 'typescript.js');
10+
11+
const bench = common.createBenchmark(main, {
12+
type: ['with-dynamic-import-callback', 'without-dynamic-import-callback'],
13+
n: [100],
14+
});
15+
16+
const scriptSource = fs.readFileSync(scriptPath, 'utf8');
17+
18+
function main({ n, type }) {
19+
let script;
20+
bench.start();
21+
const options = {};
22+
switch (type) {
23+
case 'with-dynamic-import-callback':
24+
// Use a dummy callback for now until we really need to benchmark it.
25+
options.importModuleDynamically = async () => {};
26+
break;
27+
case 'without-dynamic-import-callback':
28+
break;
29+
}
30+
for (let i = 0; i < n; i++) {
31+
script = new vm.Script(scriptSource, options);
32+
}
33+
bench.end(n);
34+
script.runInThisContext();
35+
}

graal-nodejs/common.gypi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636

3737
# Reset this number to 0 on major V8 upgrades.
3838
# Increment by one for each non-official patch applied to deps/v8.
39-
'v8_embedder_string': '-node.28',
39+
'v8_embedder_string': '-node.36',
4040

4141
##### V8 defaults for Node.js #####
4242

0 commit comments

Comments
 (0)