Update GraalVM to 22.3.1 (#5602)

Updates the engine to GraalVM 22.3.1 version, which contains fixes for:
- Chrome inspector issues - 38eb3b5932

# Important Notes
- Update to GraalVM 22.3.1
- Remove host object wrapping workaround
This commit is contained in:
Pavel Marek 2023-02-14 16:51:17 +01:00 committed by GitHub
parent edfa845b34
commit 3e8467c204
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 31 additions and 231 deletions

View File

@ -8,7 +8,7 @@ on:
env: env:
# Please ensure that this is in sync with graalVersion in build.sbt # Please ensure that this is in sync with graalVersion in build.sbt
graalVersion: 22.3.0 graalVersion: 22.3.1
# Please ensure that this is in sync with javaVersion in build.sbt # Please ensure that this is in sync with javaVersion in build.sbt
javaVersion: 11 javaVersion: 11
# Please ensure that this is in sync with project/build.properties # Please ensure that this is in sync with project/build.properties

View File

@ -563,6 +563,7 @@
- [Profile engine startup][4110] - [Profile engine startup][4110]
- [Report type of polyglot values][4111] - [Report type of polyglot values][4111]
- [Engine can now recover from serialization failures][5591] - [Engine can now recover from serialization failures][5591]
- [Update to GraalVM 22.3.1][5602]
[3227]: https://github.com/enso-org/enso/pull/3227 [3227]: https://github.com/enso-org/enso/pull/3227
[3248]: https://github.com/enso-org/enso/pull/3248 [3248]: https://github.com/enso-org/enso/pull/3248
@ -657,6 +658,7 @@
[4110]: https://github.com/enso-org/enso/pull/4110 [4110]: https://github.com/enso-org/enso/pull/4110
[4111]: https://github.com/enso-org/enso/pull/4111 [4111]: https://github.com/enso-org/enso/pull/4111
[5591]: https://github.com/enso-org/enso/pull/5591 [5591]: https://github.com/enso-org/enso/pull/5591
[5602]: https://github.com/enso-org/enso/pull/5602
# Enso 2.0.0-alpha.18 (2021-10-12) # Enso 2.0.0-alpha.18 (2021-10-12)

View File

@ -21,7 +21,7 @@ import java.io.File
// ============================================================================ // ============================================================================
val scalacVersion = "2.13.8" val scalacVersion = "2.13.8"
val graalVersion = "22.3.0" val graalVersion = "22.3.1"
val javaVersion = "11" val javaVersion = "11"
val defaultDevEnsoVersion = "0.0.0-dev" val defaultDevEnsoVersion = "0.0.0-dev"
val ensoVersion = sys.env.getOrElse( val ensoVersion = sys.env.getOrElse(

View File

@ -147,7 +147,7 @@ mod tests {
#[ignore] #[ignore]
async fn test_is_enabled() -> Result { async fn test_is_enabled() -> Result {
setup_logging()?; setup_logging()?;
let graal_version = Version::parse("22.3.0").unwrap(); let graal_version = Version::parse("22.3.1").unwrap();
let java_version = java::LanguageVersion(11); let java_version = java::LanguageVersion(11);
let os = TARGET_OS; let os = TARGET_OS;
let arch = Arch::X86_64; let arch = Arch::X86_64;
@ -166,14 +166,14 @@ mod tests {
/// Check that we correctly recognize both the GraalVM version and the Java version. /// Check that we correctly recognize both the GraalVM version and the Java version.
#[test] #[test]
fn version_recognize() { fn version_recognize() {
let version_string = r"openjdk 11.0.17 2022-10-18 let version_string = r"openjdk 11.0.18 2023-01-17
OpenJDK Runtime Environment GraalVM CE 22.3.0 (build 11.0.17+8-jvmci-22.3-b08) OpenJDK Runtime Environment GraalVM CE 22.3.1 (build 11.0.18+10-jvmci-22.3-b13)
OpenJDK 64-Bit Server VM GraalVM CE 22.3.0 (build 11.0.17+8-jvmci-22.3-b08, mixed mode, sharing)"; OpenJDK 64-Bit Server VM GraalVM CE 22.3.1 (build 11.0.18+10-jvmci-22.3-b13, mixed mode, sharing)";
let found_graal = graal_version_from_version_string(version_string).unwrap(); let found_graal = graal_version_from_version_string(version_string).unwrap();
assert_eq!(found_graal, Version::new(22, 3, 0)); assert_eq!(found_graal, Version::new(22, 3, 1));
let found_java = Java.parse_version(version_string).unwrap(); let found_java = Java.parse_version(version_string).unwrap();
assert_eq!(found_java, Version::new(11, 0, 17)); assert_eq!(found_java, Version::new(11, 0, 18));
} }
} }

View File

@ -34,9 +34,6 @@ to perform the following tasks:
- Change the expected GraalVM version in the [`build.sbt`](../../build.sbt) - Change the expected GraalVM version in the [`build.sbt`](../../build.sbt)
configuration. This is both a version number and (if it is changed), the configuration. This is both a version number and (if it is changed), the
associated version of Java. associated version of Java.
- Change the expected GraalVM version in the
[`release-publish-edition`](../../.github/workflows/release-publish-edition.yml)
workflow.
- Change the base image in the [`Dockerfile`](../../tools/ci/docker/Dockerfile) - Change the base image in the [`Dockerfile`](../../tools/ci/docker/Dockerfile)
to contain the correct GraalVM version. to contain the correct GraalVM version.
- Just to be sure, search for the version regex in all the files in the repo. - Just to be sure, search for the version regex in all the files in the repo.

View File

@ -1,105 +0,0 @@
package org.enso.interpreter.instrument;
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
import com.oracle.truffle.api.TruffleLanguage;
import com.oracle.truffle.api.TruffleLanguage.Env;
import com.oracle.truffle.api.interop.InteropLibrary;
import com.oracle.truffle.api.interop.TruffleObject;
import com.oracle.truffle.api.interop.UnsupportedMessageException;
import com.oracle.truffle.api.library.ExportLibrary;
import com.oracle.truffle.api.library.ExportMessage;
import java.util.Arrays;
import org.enso.interpreter.EnsoLanguage;
import org.enso.interpreter.runtime.EnsoContext;
import org.enso.interpreter.runtime.callable.atom.Atom;
import org.enso.interpreter.runtime.callable.atom.StructsLibrary;
/**
* Wrapper for host objects. Is a workaround for a bug in chromeinspector
* (https://github.com/oracle/graal/issues/5513). All the host objects should
* be wrapped before passing to instruments.
* <p>
* Note that specifying delegate in the {@code @ExportLibrary} annotation does
* not work.
*/
@ExportLibrary(InteropLibrary.class)
public final class HostObjectDebugWrapper implements TruffleObject {
private final String stringRepr;
public HostObjectDebugWrapper(Object hostObject) {
Env env = EnsoContext.get(null).getEnvironment();
InteropLibrary interop = InteropLibrary.getUncached();
assert env.isHostObject(hostObject);
StringBuilder sb = new StringBuilder();
sb.append("HostObject{");
try {
if (interop.hasMetaObject(hostObject)) {
Object metaObject = interop.getMetaObject(hostObject);
Object metaQualifiedName = interop.getMetaQualifiedName(metaObject);
sb.append(interop.asString(metaQualifiedName)).append(": ");
}
sb.append("'").append(interop.asString(interop.toDisplayString(hostObject))).append("'");
} catch (UnsupportedMessageException e) {
sb.append("unknown");
}
sb.append("}");
this.stringRepr = sb.toString();
}
/**
* Wraps given object in {@link HostObjectDebugWrapper} if necessary. The returned
* wrapper is a string from the Truffle perspective.
* <p>
* Serves as a workaround for https://github.com/oracle/graal/issues/5513.
*
* @param object Object to potentialy wrap in {@link HostObjectDebugWrapper}.
*/
@TruffleBoundary
public static Object wrapHostValues(Object object, InteropLibrary interop, StructsLibrary structs) {
if (object instanceof Atom atom) {
Object[] fields = structs.getFields(atom);
Object[] wrappedFields = new Object[fields.length];
for (int i = 0; i < fields.length; i++) {
wrappedFields[i] = wrapHostValues(fields[i], interop, structs);
}
return atom.getConstructor().newInstance(wrappedFields);
} else if (isHostValue(object, interop)) {
return new HostObjectDebugWrapper(object);
} else {
return object;
}
}
private static boolean isHostValue(Object value, InteropLibrary interop) {
return EnsoContext.get(interop).getEnvironment().isHostObject(value);
}
@ExportMessage
boolean hasLanguage() {
return true;
}
@ExportMessage
Class<? extends TruffleLanguage<?>> getLanguage() {
return EnsoLanguage.class;
}
@ExportMessage
boolean isString() {
return true;
}
@ExportMessage
String asString() {
return stringRepr;
}
@ExportMessage
String toDisplayString(boolean allowSideEffects) {
return stringRepr;
}
}

View File

@ -21,11 +21,8 @@ import com.oracle.truffle.api.source.SourceSection;
import java.util.UUID; import java.util.UUID;
import org.enso.interpreter.instrument.HostObjectDebugWrapper;
import org.enso.interpreter.runtime.EnsoContext;
import org.enso.interpreter.runtime.builtin.Builtins; import org.enso.interpreter.runtime.builtin.Builtins;
import org.enso.interpreter.runtime.callable.atom.AtomConstructor; import org.enso.interpreter.runtime.callable.atom.AtomConstructor;
import org.enso.interpreter.runtime.callable.atom.StructsLibrary;
import org.enso.interpreter.runtime.callable.function.Function; import org.enso.interpreter.runtime.callable.function.Function;
import org.enso.interpreter.runtime.scope.DebugLocalScope; import org.enso.interpreter.runtime.scope.DebugLocalScope;
import org.enso.interpreter.runtime.tag.AvoidIdInstrumentationTag; import org.enso.interpreter.runtime.tag.AvoidIdInstrumentationTag;
@ -203,26 +200,6 @@ public abstract class ExpressionNode extends BaseNode implements InstrumentableN
return new ExpressionNodeWrapper(this, probe); return new ExpressionNodeWrapper(this, probe);
} }
/**
* Transitively converts the given value to a wrapper that treats the host objects
* as simple strings. This is a workaround for https://github.com/oracle/graal/issues/5513
* - there is a bug in chromeinspector which reinterprets host objects in host original
* language, which causes NullPointerException. Therefore, we have to wrap all the
* host objects.
*
* @param retValue Value returned from this expression node
* @return Value with all the host objects wrapped.
*/
@OutgoingConverter
public Object wrapHostObjects(Object retValue) {
// Wrap only if chrome inspector is attached.
if (EnsoContext.get(this).getChromeInspectorNotAttached().isValid()) {
return retValue;
} else {
return HostObjectDebugWrapper.wrapHostValues(retValue, InteropLibrary.getUncached(), StructsLibrary.getUncached());
}
}
@ExportMessage @ExportMessage
boolean hasScope(Frame frame) { boolean hasScope(Frame frame) {
return isInstrumentable(); return isInstrumentable();

View File

@ -42,14 +42,6 @@ final class StatementNode extends ExpressionNode {
@Override @Override
public Object executeGeneric(VirtualFrame frame) { public Object executeGeneric(VirtualFrame frame) {
if (CompilerDirectives.inInterpreter()) {
var ctx = EnsoContext.get(this);
Assumption chromeInspectorNotAttached = ctx.getChromeInspectorNotAttached();
if (chromeInspectorNotAttached.isValid()
&& ctx.getEnvironment().getInstruments().containsKey("inspect")) {
chromeInspectorNotAttached.invalidate("Chrome inspector attached");
}
}
return node.executeGeneric(frame); return node.executeGeneric(frame);
} }

View File

@ -34,9 +34,7 @@ import org.enso.polyglot.RuntimeOptions;
import org.enso.polyglot.RuntimeServerInfo; import org.enso.polyglot.RuntimeServerInfo;
import org.graalvm.options.OptionKey; import org.graalvm.options.OptionKey;
import com.oracle.truffle.api.Assumption;
import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; import com.oracle.truffle.api.CompilerDirectives.CompilationFinal;
import com.oracle.truffle.api.Truffle;
import com.oracle.truffle.api.TruffleFile; import com.oracle.truffle.api.TruffleFile;
import com.oracle.truffle.api.TruffleLanguage; import com.oracle.truffle.api.TruffleLanguage;
import com.oracle.truffle.api.TruffleLanguage.Env; import com.oracle.truffle.api.TruffleLanguage.Env;
@ -80,9 +78,6 @@ public class EnsoContext {
private final LockManager lockManager; private final LockManager lockManager;
private final AtomicLong clock = new AtomicLong(); private final AtomicLong clock = new AtomicLong();
private final Assumption chromeInspectorNotAttached =
Truffle.getRuntime().createAssumption("chromeInspectorNotAttached");
private final Shape rootStateShape = Shape.newBuilder().layout(State.Container.class).build(); private final Shape rootStateShape = Shape.newBuilder().layout(State.Container.class).build();
private final IOPermissions rootIOPermissions; private final IOPermissions rootIOPermissions;
@ -218,11 +213,6 @@ public class EnsoContext {
return compiler; return compiler;
} }
/** Returns an {@link Assumption} that Chrome inspector is not attached to this context. */
public Assumption getChromeInspectorNotAttached() {
return chromeInspectorNotAttached;
}
/** /**
* Returns the {@link Env} instance used by this context. * Returns the {@link Env} instance used by this context.
* *

View File

@ -20,7 +20,6 @@ import java.util.Map.Entry;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import org.enso.interpreter.EnsoLanguage; import org.enso.interpreter.EnsoLanguage;
import org.enso.interpreter.instrument.HostObjectDebugWrapper;
import org.enso.interpreter.node.EnsoRootNode; import org.enso.interpreter.node.EnsoRootNode;
import org.enso.interpreter.runtime.callable.atom.StructsLibrary; import org.enso.interpreter.runtime.callable.atom.StructsLibrary;
import org.enso.interpreter.runtime.callable.function.Function; import org.enso.interpreter.runtime.callable.function.Function;
@ -183,16 +182,12 @@ public class DebugLocalScope implements TruffleObject {
} }
@ExportMessage @ExportMessage
Object readMember( Object readMember(String member) {
String member,
@CachedLibrary(limit = "10") InteropLibrary interop,
@CachedLibrary(limit = "10") StructsLibrary structs) {
FramePointer framePtr = allBindings.get(member); FramePointer framePtr = allBindings.get(member);
if (framePtr == null) { if (framePtr == null) {
return null; return null;
} else { } else {
Object value = getValue(frame, framePtr); return getValue(frame, framePtr);
return HostObjectDebugWrapper.wrapHostValues(value, interop, structs);
} }
} }

View File

@ -183,9 +183,6 @@ public class DebuggingEnsoTest {
} }
} }
/**
* Host values in the stack frame are handled specially, because of https://github.com/oracle/graal/issues/5513
*/
@Test @Test
public void testHostValues() { public void testHostValues() {
Value fooFunc = createEnsoMethod(""" Value fooFunc = createEnsoMethod("""
@ -208,15 +205,12 @@ public class DebuggingEnsoTest {
assertTrue(pathValue.isReadable()); assertTrue(pathValue.isReadable());
assertFalse(pathValue.isInternal()); assertFalse(pathValue.isInternal());
assertFalse(pathValue.hasReadSideEffects()); assertFalse(pathValue.hasReadSideEffects());
assertTrue(pathValue.toDisplayString().startsWith("HostObject"));
DebugValue listValue = scope.getDeclaredValue("list"); DebugValue listValue = scope.getDeclaredValue("list");
// ArrayList is internally represented as Enso list, but as an object
// initialized in host context, it suffers from the issue mentioned in
// https://github.com/oracle/graal/issues/5513. Therefore, we display
// it just as 'HostObject' in the debugger.
assertNotNull(listValue); assertNotNull(listValue);
assertTrue(listValue.toDisplayString().startsWith("HostObject")); assertTrue(listValue.isArray());
assertEquals(10, listValue.getArray().get(0).asInt());
assertEquals(20, listValue.getArray().get(1).asInt());
} }
} }
event.getSession().suspendNextExecution(); event.getSession().suspendNextExecution();
@ -537,48 +531,6 @@ public class DebuggingEnsoTest {
testStepping(src, "foo", new Object[]{0}, steps, expectedLineNumbers); testStepping(src, "foo", new Object[]{0}, steps, expectedLineNumbers);
} }
/**
* Steps through some stdlib methods, enumerates all the values in frames and checks if all
* the host values are wrapped.
*
* Note that this is essentially a check whether the workaround for https://github.com/oracle/graal/issues/5513 works.
*/
@Test
public void testAllHostObjectsAreWrapped() {
Value fooFunc = createEnsoMethod("""
from Standard.Base import Vector
foo x =
vec = [5, 5, 1, 2, 1]
vec.distinct
""", "foo");
List<FrameEntry> frames = new ArrayList<>();
try (DebuggerSession session = debugger.startSession((SuspendedEvent event) -> {
DebugScope topScope = event.getTopStackFrame().getScope();
var frameEntry = new FrameEntry(topScope.getName(), event.getReturnValue());
for (DebugValue declaredValue : topScope.getDeclaredValues()) {
frameEntry.addValue(declaredValue);
}
frames.add(frameEntry);
event.prepareStepInto(1);
})) {
session.suspendNextExecution();
fooFunc.execute(0);
}
// Throughout Vector.distinct call, there will definitely be at least one host object
// in one of the stack frames.
long hostObjectValues = frames.stream()
.filter(frameEntry ->
frameEntry
.values
.values()
.stream()
.anyMatch(displayString -> displayString.contains("HostObject"))
)
.count();
assertTrue(frames.size() > 1);
assertTrue(hostObjectValues > 1);
}
private static final class FrameEntry { private static final class FrameEntry {
private final String scopeName; private final String scopeName;
private final Map<String, String> values = new HashMap<>(); private final Map<String, String> values = new HashMap<>();

View File

@ -47,7 +47,7 @@ spec =
{ {
"headers": { "headers": {
"Content-Length": "0", "Content-Length": "0",
"User-Agent": "Java-http-client/11.0.17" "User-Agent": "Java-http-client/11.0.18"
}, },
"origin": "127.0.0.1", "origin": "127.0.0.1",
"url": "", "url": "",
@ -61,7 +61,7 @@ spec =
{ {
"headers": { "headers": {
"Content-Length": "0", "Content-Length": "0",
"User-Agent": "Java-http-client/11.0.17" "User-Agent": "Java-http-client/11.0.18"
}, },
"origin": "127.0.0.1", "origin": "127.0.0.1",
"url": "", "url": "",
@ -76,7 +76,7 @@ spec =
{ {
"headers": { "headers": {
"Content-Length": "0", "Content-Length": "0",
"User-Agent": "Java-http-client/11.0.17" "User-Agent": "Java-http-client/11.0.18"
}, },
"origin": "127.0.0.1", "origin": "127.0.0.1",
"url": "", "url": "",
@ -97,7 +97,7 @@ spec =
{ {
"headers": { "headers": {
"Content-Length": "0", "Content-Length": "0",
"User-Agent": "Java-http-client/11.0.17" "User-Agent": "Java-http-client/11.0.18"
}, },
"origin": "127.0.0.1", "origin": "127.0.0.1",
"url": "", "url": "",
@ -116,7 +116,7 @@ spec =
{ {
"headers": { "headers": {
"Content-Length": "0", "Content-Length": "0",
"User-Agent": "Java-http-client/11.0.17" "User-Agent": "Java-http-client/11.0.18"
}, },
"origin": "127.0.0.1", "origin": "127.0.0.1",
"url": "", "url": "",
@ -136,7 +136,7 @@ spec =
"headers": { "headers": {
"Content-Length": "12", "Content-Length": "12",
"Content-Type": "text/plain", "Content-Type": "text/plain",
"User-Agent": "Java-http-client/11.0.17" "User-Agent": "Java-http-client/11.0.18"
}, },
"origin": "127.0.0.1", "origin": "127.0.0.1",
"url": "", "url": "",
@ -156,7 +156,7 @@ spec =
"headers": { "headers": {
"Content-Length": "7", "Content-Length": "7",
"Content-Type": "application/x-www-form-urlencoded", "Content-Type": "application/x-www-form-urlencoded",
"User-Agent": "Java-http-client/11.0.17" "User-Agent": "Java-http-client/11.0.18"
}, },
"origin": "127.0.0.1", "origin": "127.0.0.1",
"url": "", "url": "",
@ -176,7 +176,7 @@ spec =
"headers": { "headers": {
"Content-Length": "7", "Content-Length": "7",
"Content-Type": "application/x-www-form-urlencoded", "Content-Type": "application/x-www-form-urlencoded",
"User-Agent": "Java-http-client/11.0.17" "User-Agent": "Java-http-client/11.0.18"
}, },
"origin": "127.0.0.1", "origin": "127.0.0.1",
"url": "", "url": "",
@ -206,7 +206,7 @@ spec =
"headers": { "headers": {
"Content-Length": "13", "Content-Length": "13",
"Content-Type": "application/json", "Content-Type": "application/json",
"User-Agent": "Java-http-client/11.0.17" "User-Agent": "Java-http-client/11.0.18"
}, },
"origin": "127.0.0.1", "origin": "127.0.0.1",
"url": "", "url": "",
@ -228,7 +228,7 @@ spec =
"headers": { "headers": {
"Content-Length": "13", "Content-Length": "13",
"Content-Type": "application/json", "Content-Type": "application/json",
"User-Agent": "Java-http-client/11.0.17" "User-Agent": "Java-http-client/11.0.18"
}, },
"origin": "127.0.0.1", "origin": "127.0.0.1",
"url": "", "url": "",
@ -250,7 +250,7 @@ spec =
"headers": { "headers": {
"Content-Length": "12", "Content-Length": "12",
"Content-Type": "application/octet-stream", "Content-Type": "application/octet-stream",
"User-Agent": "Java-http-client/11.0.17" "User-Agent": "Java-http-client/11.0.18"
}, },
"origin": "127.0.0.1", "origin": "127.0.0.1",
"url": "", "url": "",
@ -270,7 +270,7 @@ spec =
{ {
"headers": { "headers": {
"Content-Length": "0", "Content-Length": "0",
"User-Agent": "Java-http-client/11.0.17" "User-Agent": "Java-http-client/11.0.18"
}, },
"origin": "127.0.0.1", "origin": "127.0.0.1",
"url": "", "url": "",
@ -286,7 +286,7 @@ spec =
"headers": { "headers": {
"Content-Length": "13", "Content-Length": "13",
"Content-Type": "application/json", "Content-Type": "application/json",
"User-Agent": "Java-http-client/11.0.17" "User-Agent": "Java-http-client/11.0.18"
}, },
"origin": "127.0.0.1", "origin": "127.0.0.1",
"url": "", "url": "",
@ -310,7 +310,7 @@ spec =
"headers": { "headers": {
"Content-Length": "16", "Content-Length": "16",
"Content-Type": "application/json", "Content-Type": "application/json",
"User-Agent": "Java-http-client/11.0.17" "User-Agent": "Java-http-client/11.0.18"
}, },
"origin": "127.0.0.1", "origin": "127.0.0.1",
"url": "", "url": "",

View File

@ -1,4 +1,4 @@
FROM ghcr.io/graalvm/graalvm-ce:ol9-java11-22.3.0 FROM ghcr.io/graalvm/graalvm-ce:ol9-java11-22.3.1
USER root USER root

View File

@ -66,7 +66,7 @@ and then launch it with special `--dump-graphs` option:
enso$ ./built-distribution/enso-engine-0.0.0-dev-linux-amd64/enso-0.0.0-dev/bin/enso --dump-graphs --run yourprogram.enso enso$ ./built-distribution/enso-engine-0.0.0-dev-linux-amd64/enso-0.0.0-dev/bin/enso --dump-graphs --run yourprogram.enso
``` ```
When executed on [GraalVM 22.3.0](http://graalvm.org) these options instruct the When executed on [GraalVM 22.3.1](http://graalvm.org) these options instruct the
_Graal/Truffle compiler_ to dump files into `graal_dumps/_sometimestamp_` _Graal/Truffle compiler_ to dump files into `graal_dumps/_sometimestamp_`
directory. Generating these files takes a while - make sure `yourprogram.enso` directory. Generating these files takes a while - make sure `yourprogram.enso`
runs long enough for the system to warmup, compile the code and run at _full runs long enough for the system to warmup, compile the code and run at _full