Skip to content

Commit c7170b3

Browse files
woessansalond
authored andcommitted
[GR-57059] Batch backport from master into 24.1 release branch.
PullRequest: js/3228
2 parents e8a28a6 + 3a569a8 commit c7170b3

File tree

204 files changed

+4616
-3354
lines changed

Some content is hidden

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

204 files changed

+4616
-3354
lines changed

Diff for: CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ See [release calendar](https://www.graalvm.org/release-calendar/) for release da
1212
* Implemented the [Array.fromAsync](https://github.com/tc39/proposal-array-from-async) proposal. It is available in ECMAScript staging mode (`--js.ecmascript-version=staging`).
1313
* Implemented the [Resizable and Growable ArrayBuffers](https://github.com/tc39/proposal-resizablearraybuffer) proposal.
1414
* Updated Node.js to version 20.15.1.
15+
* Made option `js.esm-eval-returns-exports` stable and allowed in `SandboxPolicy.UNTRUSTED`.
16+
* Added option `js.stack-trace-api` that enables/disables `Error.captureStackTrace`, `Error.prepareStackTrace` and `Error.stackTraceLimit`.
1517

1618
## Version 24.0.0
1719
* Implemented the [WebAssembly threads](https://github.com/WebAssembly/threads) proposal.

Diff for: ci.jsonnet

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ local graalNodeJs = import 'graal-nodejs/ci.jsonnet';
66
// Used to run fewer jobs
77
local useOverlay = true,
88

9-
local overlay = 'ecbe9b07a592111b950bcb2da30a993478a1488a',
9+
local overlay = '8687d6f5e142a8fbcedab5a5d62f2c9b22b681b2',
1010

1111
local no_overlay = 'cb733e564850cd37b685fcef6f3c16b59802b22c',
1212

Diff for: common.json

+8-8
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"Jsonnet files should not include this file directly but use ci/common.jsonnet instead."
55
],
66

7-
"mx_version": "7.25.5",
7+
"mx_version": "7.27.5",
88

99
"COMMENT.jdks": "When adding or removing JDKs keep in sync with JDKs in ci/common.jsonnet",
1010
"jdks": {
@@ -45,13 +45,13 @@
4545
"labsjdk-ee-21-llvm": {"name": "labsjdk", "version": "ee-21.0.2+13-jvmci-23.1-b33-sulong", "platformspecific": true },
4646
"graalvm-ee-21": {"name": "graalvm-java21", "version": "23.1.3", "platformspecific": true },
4747

48-
"oraclejdk-latest": {"name": "jpg-jdk", "version": "23", "build_id": "jdk-23+25", "platformspecific": true, "extrabundles": ["static-libs"]},
49-
"labsjdk-ce-latest": {"name": "labsjdk", "version": "ce-23+25-jvmci-b01", "platformspecific": true },
50-
"labsjdk-ce-latestDebug": {"name": "labsjdk", "version": "ce-23+25-jvmci-b01-debug", "platformspecific": true },
51-
"labsjdk-ce-latest-llvm": {"name": "labsjdk", "version": "ce-23+25-jvmci-b01-sulong", "platformspecific": true },
52-
"labsjdk-ee-latest": {"name": "labsjdk", "version": "ee-23+25-jvmci-b01", "platformspecific": true },
53-
"labsjdk-ee-latestDebug": {"name": "labsjdk", "version": "ee-23+25-jvmci-b01-debug", "platformspecific": true },
54-
"labsjdk-ee-latest-llvm": {"name": "labsjdk", "version": "ee-23+25-jvmci-b01-sulong", "platformspecific": true }
48+
"oraclejdk-latest": {"name": "jpg-jdk", "version": "23", "build_id": "jdk-23+34", "platformspecific": true, "extrabundles": ["static-libs"]},
49+
"labsjdk-ce-latest": {"name": "labsjdk", "version": "ce-23+34-jvmci-b01", "platformspecific": true },
50+
"labsjdk-ce-latestDebug": {"name": "labsjdk", "version": "ce-23+34-jvmci-b01-debug", "platformspecific": true },
51+
"labsjdk-ce-latest-llvm": {"name": "labsjdk", "version": "ce-23+34-jvmci-b01-sulong", "platformspecific": true },
52+
"labsjdk-ee-latest": {"name": "labsjdk", "version": "ee-23+34-jvmci-b01", "platformspecific": true },
53+
"labsjdk-ee-latestDebug": {"name": "labsjdk", "version": "ee-23+34-jvmci-b01-debug", "platformspecific": true },
54+
"labsjdk-ee-latest-llvm": {"name": "labsjdk", "version": "ee-23+34-jvmci-b01-sulong", "platformspecific": true }
5555
},
5656

5757
"eclipse": {

Diff for: graal-js/ci.jsonnet

+7-5
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ local ci = import '../ci.jsonnet';
5252
['set-export', 'STANDALONE_HOME', ['mx', '--quiet', 'standalone-home', 'js', '--type=jvm']],
5353
['${STANDALONE_HOME}/bin/js', '--jvm', '-e', "print('hello:' + Array.from(new Array(10), (x,i) => i*i ).join('|'))"],
5454
['${STANDALONE_HOME}/bin/js', '--jvm', '../../js-benchmarks/harness.js', '--', '../../js-benchmarks/octane-richards.js', '--show-warmup'],
55+
# maven-downloader smoke test
56+
['VERBOSE_GRAALVM_LAUNCHERS=true', '${STANDALONE_HOME}/bin/js-polyglot-get', '-o', 'maven downloader output', '-a', 'wasm', '-v', '23.1.3'],
5557
],
5658
timelimit: '30:00',
5759
},
@@ -60,8 +62,8 @@ local ci = import '../ci.jsonnet';
6062
run+: [
6163
['mx', 'build'],
6264
['mx', '-v', 'maven-deploy', '--suppress-javadoc', '--validate', 'full', '--licenses', 'UPL,MIT', '--dry-run', 'ossrh', 'https://this-is-only-a-test'],
63-
['mx', '-p', '../../graal/vm', '--dynamicimports', '/tools,/compiler,/graal-js', 'build'],
64-
['mx', '-p', '../../graal/vm', '--dynamicimports', '/tools,/regex,/compiler,/truffle,/sdk,/graal-js', 'maven-deploy', '--suppress-javadoc', '--all-suites', '--version-string', 'GATE'],
65+
['mx', '-p', '../../graal/vm', '--dynamicimports', '/tools,/compiler,/graal-js,/wasm', 'build'],
66+
['mx', '-p', '../../graal/vm', '--dynamicimports', '/tools,/regex,/compiler,/truffle,/sdk,/graal-js,/wasm', 'maven-deploy', '--suppress-javadoc', '--all-suites', '--version-string', 'GATE'],
6567
['cd', 'test/maven-demo'],
6668
['mvn', '-Dgraalvm.version=GATE', '--batch-mode', 'package'],
6769
['mvn', '-Dgraalvm.version=GATE', '--batch-mode', 'exec:exec'],
@@ -107,8 +109,8 @@ local ci = import '../ci.jsonnet';
107109
nativeimages+:: ['lib:jsvm'],
108110
graalvmtests:: '../../graalvm-tests',
109111
run+: [
110-
['mx', 'build'],
111-
['python', '../../graalvm-tests/test.py', '-g', ['mx', '--quiet', 'graalvm-home'], '--print-revisions', '--keep-on-error', 'test/aux-engine-cache'],
112+
['mx', 'build', '--dependencies', 'ALL_GRAALVM_ARTIFACTS'],
113+
['python', self.graalvmtests + '/test.py', '-g', ['mx', '--quiet', 'standalone-home', 'js'], '--print-revisions', '--keep-on-error', 'test/aux-engine-cache', 'test/repl'],
112114
],
113115
timelimit: '1:00:00',
114116
},
@@ -174,7 +176,7 @@ local ci = import '../ci.jsonnet';
174176

175177
// Benchmark builds; need to run on a benchmark machine
176178
local benchBuilds = generateBuilds([
177-
graalJs + common.bench + interopJmhBenchmarks + {name: 'interop-jmh'},
179+
graalJs + common.dailyBench+ interopJmhBenchmarks + {name: 'interop-jmh'},
178180
], platforms=[common.jdk21 + common.e3]),
179181

180182
builds: styleBuilds + testingBuilds + otherBuilds + benchBuilds,
+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/usr/bin/env bash
2+
3+
source="${BASH_SOURCE[0]}"
4+
while [ -h "$source" ] ; do
5+
prev_source="$source"
6+
source="$(readlink "$source")";
7+
if [[ "$source" != /* ]]; then
8+
# if the link was relative, it was relative to where it came from
9+
dir="$( cd -P "$( dirname "$prev_source" )" && pwd )"
10+
source="$dir/$source"
11+
fi
12+
done
13+
14+
bin_dir="$( cd -P "$( dirname "$source" )" && pwd )"
15+
parent_dir="$( dirname "$bin_dir" )"
16+
17+
if [ ! -x "${parent_dir}/jvm/bin/java" ]; then
18+
echo "Error: ${parent_dir}/jvm/bin/java not found. $(basename "$0") is not available for the native standalone."
19+
exit 1
20+
fi
21+
22+
if [ "${VERBOSE_GRAALVM_LAUNCHERS}" == "true" ]; then
23+
set -x
24+
fi
25+
26+
exec "${parent_dir}/jvm/bin/java" "-p" "${parent_dir}/modules" "-m" "org.graalvm.maven.downloader/org.graalvm.maven.downloader.Main" "$@"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
@echo off
2+
setlocal enabledelayedexpansion
3+
4+
call :dirname "%~0" bin_dir
5+
call :dirname "%bin_dir%" parent_dir
6+
7+
if not exist "%parent_dir%/jvm/bin/java.exe" (
8+
echo "Error: %parent_dir%/jvm/bin/java.exe not found. %~nx0 is not available for the native standalone."
9+
exit /b 1
10+
)
11+
12+
if "%VERBOSE_GRAALVM_LAUNCHERS%"=="true" echo on
13+
14+
"%parent_dir%/jvm/bin/java.exe" -p "%parent_dir%/modules" -m "org.graalvm.maven.downloader/org.graalvm.maven.downloader.Main" %*
15+
16+
@echo off
17+
exit /b %errorlevel%
18+
19+
:dirname file output
20+
setlocal
21+
set "dir=%~dp1"
22+
set "dir=%dir:~0,-1%"
23+
endlocal & set "%2=%dir%"
24+
exit /b 0

Diff for: graal-js/mx.graal-js/mx_graal_js.py

+7-4
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
TEST262_REPO = "https://" + "github.com/tc39/test262.git"
4848

4949
# Git revision of Test262 to checkout
50-
TEST262_REV = "007b333af22d8b8466be3394b9248345ac4445c9"
50+
TEST262_REV = "a15874163e6a4f19ee7cd3e47592af382af0f5fd"
5151

5252
# Git repository of V8
5353
TESTV8_REPO = "https://" + "github.com/v8/v8.git"
@@ -159,9 +159,11 @@ def processDeps(self, deps):
159159
def apply(self, config):
160160
(vmArgs, mainClass, mainClassArgs) = config
161161
# Disable DefaultRuntime warning
162-
vmArgs = vmArgs + ['-Dpolyglot.engine.WarnInterpreterOnly=false']
163-
# Assert for enter/return parity of ProbeNode
164-
vmArgs = vmArgs + ['-Dpolyglot.engine.AssertProbes=true', '-Dpolyglot.engine.AllowExperimentalOptions=true']
162+
vmArgs += ['-Dpolyglot.engine.WarnInterpreterOnly=false']
163+
vmArgs += ['-Dpolyglot.engine.AllowExperimentalOptions=true']
164+
# Assert for enter/return parity of ProbeNode (if assertions are enabled only)
165+
if next((arg.startswith('-e') for arg in reversed(vmArgs) if arg in ['-ea', '-da', '-enableassertions', '-disableassertions']), False):
166+
vmArgs += ['-Dpolyglot.engine.AssertProbes=true']
165167
vmArgs += ['-Dpolyglotimpl.DisableClassPathIsolation=true']
166168
mainClassArgs += ['-JUnitOpenPackages', 'org.graalvm.js/*=com.oracle.truffle.js.test']
167169
mainClassArgs += ['-JUnitOpenPackages', 'org.graalvm.js/*=com.oracle.truffle.js.snapshot']
@@ -503,6 +505,7 @@ def mx_register_dynamic_suite_constituents(register_project, register_distributi
503505
],
504506
truffle_jars=[
505507
'graal-js:GRAALJS',
508+
'sdk:MAVEN_DOWNLOADER',
506509
],
507510
support_distributions=[
508511
'graal-js:GRAALJS_GRAALVM_SUPPORT',

Diff for: graal-js/mx.graal-js/suite.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
{
2525
"name" : "regex",
2626
"subdir" : True,
27-
"version" : "6c4f42bf5368c480ef2c9c29f0163d30d827b001",
27+
"version" : "0262bebe5db5f6f48ada94821a889a7b414279c4",
2828
"urls" : [
2929
{"url" : "https://github.com/oracle/graal.git", "kind" : "git"},
3030
]
@@ -438,6 +438,7 @@
438438
"com.oracle.truffle.js.lang to org.graalvm.nodejs",
439439
"com.oracle.truffle.js.nodes to org.graalvm.nodejs",
440440
"com.oracle.truffle.js.nodes.access to org.graalvm.nodejs",
441+
"com.oracle.truffle.js.nodes.array to org.graalvm.nodejs",
441442
"com.oracle.truffle.js.nodes.arguments to org.graalvm.nodejs",
442443
"com.oracle.truffle.js.nodes.cast to org.graalvm.nodejs",
443444
"com.oracle.truffle.js.nodes.function to org.graalvm.nodejs",
@@ -690,12 +691,16 @@
690691

691692
"GRAALJS_GRAALVM_SUPPORT" : {
692693
"native" : True,
694+
"platformDependent" : True,
693695
"description" : "Graal.js support distribution for the GraalVM",
694696
"layout" : {
695697
"native-image.properties": "file:mx.graal-js/native-image.properties",
696698
"./": [
697699
"file:README.md",
698700
],
701+
"bin/": [
702+
"file:mx.graal-js/graalvm_launchers/<cmd:js-polyglot-get>",
703+
]
699704
},
700705
},
701706

Diff for: graal-js/src/com.oracle.js.parser/src/com/oracle/js/parser/Parser.java

+21-4
Original file line numberDiff line numberDiff line change
@@ -615,7 +615,26 @@ public void parseFormalParameterList() {
615615
scanFirstToken();
616616

617617
assert lc.getCurrentScope() == null;
618-
formalParameterList(TokenType.EOF, false, false);
618+
619+
// Set up a fake function.
620+
final int functionLine = line;
621+
final long functionToken = Token.toDesc(FUNCTION, 0, source.getLength());
622+
final IdentNode ident = new IdentNode(functionToken, Token.descPosition(functionToken), lexer.stringIntern(PROGRAM_NAME));
623+
final ParserContextFunctionNode function = createParserContextFunctionNode(ident, functionToken, 0, functionLine);
624+
function.clearFlag(FunctionNode.IS_PROGRAM);
625+
626+
lc.push(function);
627+
try {
628+
final ParserContextBlockNode parameterBlock = function.createParameterBlock();
629+
lc.push(parameterBlock);
630+
try {
631+
formalParameterList(TokenType.EOF, false, false);
632+
} finally {
633+
restoreBlock(parameterBlock);
634+
}
635+
} finally {
636+
lc.pop(function);
637+
}
619638
} catch (ParserException e) {
620639
handleParseException(e);
621640
}
@@ -2681,9 +2700,7 @@ private IdentNode bindingIdentifier(boolean yield, boolean await, String context
26812700

26822701
private void addIdentifierReference(String name) {
26832702
Scope currentScope = lc.getCurrentScope();
2684-
if (currentScope != null) { // can be null when parsing/verifying a parameter list.
2685-
currentScope.addIdentifierReference(name);
2686-
}
2703+
currentScope.addIdentifierReference(name);
26872704
}
26882705

26892706
private Expression bindingPattern(boolean yield, boolean await) {

Diff for: graal-js/src/com.oracle.truffle.js.scriptengine.test/src/com/oracle/truffle/js/scriptengine/test/JSONCompatibleTest.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2018, 2019, 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
@@ -41,8 +41,8 @@
4141
package com.oracle.truffle.js.scriptengine.test;
4242

4343
import static org.hamcrest.CoreMatchers.instanceOf;
44+
import static org.hamcrest.MatcherAssert.assertThat;
4445
import static org.junit.Assert.assertEquals;
45-
import static org.junit.Assert.assertThat;
4646

4747
import java.util.Arrays;
4848
import java.util.List;

Diff for: graal-js/src/com.oracle.truffle.js.scriptengine.test/src/com/oracle/truffle/js/scriptengine/test/TestEngine.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2018, 2022, 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
@@ -76,7 +76,7 @@ public class TestEngine {
7676

7777
private final ScriptEngineManager manager = new ScriptEngineManager();
7878

79-
@Rule public ExpectedException expectedException = ExpectedException.none();
79+
@SuppressWarnings("deprecation") @Rule public ExpectedException expectedException = ExpectedException.none();
8080

8181
private ScriptEngine getEngine() {
8282
return manager.getEngineByName(TESTED_ENGINE_NAME);

Diff for: graal-js/src/com.oracle.truffle.js.shell/src/com/oracle/truffle/js/shell/JSLauncher.java

+57-5
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ private static int handlePolyglotException(PolyglotException e) {
396396
printError(e, System.err);
397397
status = 7;
398398
} else if (!e.isInternalError()) {
399-
printStackTraceSkipTrailingHost(e, System.err);
399+
printGuestException(e, System.err);
400400
status = 7;
401401
} else {
402402
e.printStackTrace();
@@ -433,7 +433,7 @@ private static int runREPL(Context context) {
433433
} else if (e.isSyntaxError()) {
434434
printError(e, System.err);
435435
} else if (!e.isInternalError()) {
436-
printStackTraceSkipTrailingHost(e, System.err);
436+
printGuestException(e, System.err);
437437
} else {
438438
e.printStackTrace();
439439
return 8;
@@ -459,7 +459,57 @@ private static void printError(Throwable e, PrintStream output) {
459459
}
460460
}
461461

462-
private static void printStackTraceSkipTrailingHost(PolyglotException e, PrintStream output) {
462+
private static Value getErrorsFromAggregateError(Value guestException) {
463+
if (guestException.isException() && guestException.hasMembers()) {
464+
Value errorMetaObject = guestException.getMetaObject();
465+
if (errorMetaObject != null && "AggregateError".equals(errorMetaObject.getMetaSimpleName())) {
466+
Value errors = guestException.getMember("errors");
467+
if (errors != null && errors.hasArrayElements()) {
468+
return errors;
469+
}
470+
}
471+
}
472+
return null;
473+
}
474+
475+
private static void printGuestException(PolyglotException e, PrintStream err) {
476+
StringBuilder output = new StringBuilder();
477+
printStackTraceSkipTrailingHost(e, output, "");
478+
Value guestException = e.getGuestObject();
479+
if (guestException != null) {
480+
int safeLength = output.length();
481+
try {
482+
// Print all errors of an AggregateError
483+
Value errors = getErrorsFromAggregateError(guestException);
484+
if (errors != null) {
485+
long size = errors.getArraySize();
486+
output.append(" {").append(System.lineSeparator());
487+
output.append(" [errors]: [").append(System.lineSeparator());
488+
String indent = " ".repeat(4);
489+
for (long i = 0; i < size; i++) {
490+
Value error = errors.getArrayElement(i);
491+
if (error.isException()) {
492+
printStackTraceSkipTrailingHost(error.as(PolyglotException.class), output, indent);
493+
} else {
494+
output.append(error.toString());
495+
}
496+
if (i != size - 1) {
497+
output.append(",");
498+
}
499+
output.append(System.lineSeparator());
500+
}
501+
output.append(" ]").append(System.lineSeparator());
502+
output.append("}");
503+
}
504+
} catch (PolyglotException ignored) {
505+
// Erase any incomplete output.
506+
output.setLength(safeLength);
507+
}
508+
}
509+
err.println(output);
510+
}
511+
512+
private static void printStackTraceSkipTrailingHost(PolyglotException e, StringBuilder output, String indent) {
463513
List<PolyglotException.StackFrame> stackTrace = new ArrayList<>();
464514
for (PolyglotException.StackFrame s : e.getPolyglotStackTrace()) {
465515
stackTrace.add(s);
@@ -473,9 +523,11 @@ private static void printStackTraceSkipTrailingHost(PolyglotException e, PrintSt
473523
break;
474524
}
475525
}
476-
output.println(e.isHostException() ? e.asHostException().toString() : e.getMessage());
526+
String message = e.isHostException() ? e.asHostException().toString() : e.getMessage();
527+
output.append(indent).append(message);
477528
for (PolyglotException.StackFrame s : stackTrace) {
478-
output.println("\tat " + s);
529+
output.append(System.lineSeparator());
530+
output.append(indent).append(" at ").append(s);
479531
}
480532
}
481533

Diff for: graal-js/src/com.oracle.truffle.js.test.external/src/com/oracle/truffle/js/test/external/test262/Test262Runnable.java

+1
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,7 @@ public class Test262Runnable extends TestRunnable {
265265
"Intl.DurationFormat",
266266
"IsHTMLDDA",
267267
"explicit-resource-management",
268+
"promise-try",
268269
"regexp-modifiers",
269270
"tail-call-optimization",
270271
});

Diff for: graal-js/src/com.oracle.truffle.js.test/js/GR-53714.js

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
* Regression test of the handling of long values.
1010
*
1111
* @option temporal
12+
* @option v8-compat
1213
*/
1314

1415
load('assert.js');
+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/*
2+
* Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
6+
*/
7+
8+
load("assert.js");
9+
10+
var time = java.lang.System.currentTimeMillis?.();
11+
assertSame('number', typeof time);
12+
13+
var result = java.lang.System.iDontExist?.();
14+
assertSame('undefined', typeof result);

0 commit comments

Comments
 (0)