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:
# 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
javaVersion: 11
# Please ensure that this is in sync with project/build.properties

View File

@ -563,6 +563,7 @@
- [Profile engine startup][4110]
- [Report type of polyglot values][4111]
- [Engine can now recover from serialization failures][5591]
- [Update to GraalVM 22.3.1][5602]
[3227]: https://github.com/enso-org/enso/pull/3227
[3248]: https://github.com/enso-org/enso/pull/3248
@ -657,6 +658,7 @@
[4110]: https://github.com/enso-org/enso/pull/4110
[4111]: https://github.com/enso-org/enso/pull/4111
[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)

View File

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

View File

@ -147,7 +147,7 @@ mod tests {
#[ignore]
async fn test_is_enabled() -> Result {
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 os = TARGET_OS;
let arch = Arch::X86_64;
@ -166,14 +166,14 @@ mod tests {
/// Check that we correctly recognize both the GraalVM version and the Java version.
#[test]
fn version_recognize() {
let version_string = r"openjdk 11.0.17 2022-10-18
OpenJDK Runtime Environment GraalVM CE 22.3.0 (build 11.0.17+8-jvmci-22.3-b08)
OpenJDK 64-Bit Server VM GraalVM CE 22.3.0 (build 11.0.17+8-jvmci-22.3-b08, mixed mode, sharing)";
let version_string = r"openjdk 11.0.18 2023-01-17
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.1 (build 11.0.18+10-jvmci-22.3-b13, mixed mode, sharing)";
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();
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)
configuration. This is both a version number and (if it is changed), the
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)
to contain the correct GraalVM version.
- 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 org.enso.interpreter.instrument.HostObjectDebugWrapper;
import org.enso.interpreter.runtime.EnsoContext;
import org.enso.interpreter.runtime.builtin.Builtins;
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.scope.DebugLocalScope;
import org.enso.interpreter.runtime.tag.AvoidIdInstrumentationTag;
@ -203,26 +200,6 @@ public abstract class ExpressionNode extends BaseNode implements InstrumentableN
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
boolean hasScope(Frame frame) {
return isInstrumentable();

View File

@ -42,14 +42,6 @@ final class StatementNode extends ExpressionNode {
@Override
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);
}

View File

@ -34,9 +34,7 @@ import org.enso.polyglot.RuntimeOptions;
import org.enso.polyglot.RuntimeServerInfo;
import org.graalvm.options.OptionKey;
import com.oracle.truffle.api.Assumption;
import com.oracle.truffle.api.CompilerDirectives.CompilationFinal;
import com.oracle.truffle.api.Truffle;
import com.oracle.truffle.api.TruffleFile;
import com.oracle.truffle.api.TruffleLanguage;
import com.oracle.truffle.api.TruffleLanguage.Env;
@ -80,9 +78,6 @@ public class EnsoContext {
private final LockManager lockManager;
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 IOPermissions rootIOPermissions;
@ -218,11 +213,6 @@ public class EnsoContext {
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.
*

View File

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

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
public void testHostValues() {
Value fooFunc = createEnsoMethod("""
@ -208,15 +205,12 @@ public class DebuggingEnsoTest {
assertTrue(pathValue.isReadable());
assertFalse(pathValue.isInternal());
assertFalse(pathValue.hasReadSideEffects());
assertTrue(pathValue.toDisplayString().startsWith("HostObject"));
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);
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();
@ -537,48 +531,6 @@ public class DebuggingEnsoTest {
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 final String scopeName;
private final Map<String, String> values = new HashMap<>();

View File

@ -47,7 +47,7 @@ spec =
{
"headers": {
"Content-Length": "0",
"User-Agent": "Java-http-client/11.0.17"
"User-Agent": "Java-http-client/11.0.18"
},
"origin": "127.0.0.1",
"url": "",
@ -61,7 +61,7 @@ spec =
{
"headers": {
"Content-Length": "0",
"User-Agent": "Java-http-client/11.0.17"
"User-Agent": "Java-http-client/11.0.18"
},
"origin": "127.0.0.1",
"url": "",
@ -76,7 +76,7 @@ spec =
{
"headers": {
"Content-Length": "0",
"User-Agent": "Java-http-client/11.0.17"
"User-Agent": "Java-http-client/11.0.18"
},
"origin": "127.0.0.1",
"url": "",
@ -97,7 +97,7 @@ spec =
{
"headers": {
"Content-Length": "0",
"User-Agent": "Java-http-client/11.0.17"
"User-Agent": "Java-http-client/11.0.18"
},
"origin": "127.0.0.1",
"url": "",
@ -116,7 +116,7 @@ spec =
{
"headers": {
"Content-Length": "0",
"User-Agent": "Java-http-client/11.0.17"
"User-Agent": "Java-http-client/11.0.18"
},
"origin": "127.0.0.1",
"url": "",
@ -136,7 +136,7 @@ spec =
"headers": {
"Content-Length": "12",
"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",
"url": "",
@ -156,7 +156,7 @@ spec =
"headers": {
"Content-Length": "7",
"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",
"url": "",
@ -176,7 +176,7 @@ spec =
"headers": {
"Content-Length": "7",
"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",
"url": "",
@ -206,7 +206,7 @@ spec =
"headers": {
"Content-Length": "13",
"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",
"url": "",
@ -228,7 +228,7 @@ spec =
"headers": {
"Content-Length": "13",
"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",
"url": "",
@ -250,7 +250,7 @@ spec =
"headers": {
"Content-Length": "12",
"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",
"url": "",
@ -270,7 +270,7 @@ spec =
{
"headers": {
"Content-Length": "0",
"User-Agent": "Java-http-client/11.0.17"
"User-Agent": "Java-http-client/11.0.18"
},
"origin": "127.0.0.1",
"url": "",
@ -286,7 +286,7 @@ spec =
"headers": {
"Content-Length": "13",
"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",
"url": "",
@ -310,7 +310,7 @@ spec =
"headers": {
"Content-Length": "16",
"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",
"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

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
```
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_`
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