Upgrade Truffle and Graal to Version 21.3.0 (#3258)

This commit is contained in:
Edward Kmett 2022-02-11 11:05:13 -05:00 committed by GitHub
parent 593a603582
commit 0c25ee736c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
21 changed files with 59 additions and 76 deletions

View File

@ -17,7 +17,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: 21.1.0 graalVersion: 21.3.0
# 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

@ -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: 21.1.0 graalVersion: 21.3.0
# 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

@ -10,7 +10,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: 21.1.0 graalVersion: 21.3.0
# 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

@ -6,7 +6,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: 21.1.0 graalVersion: 21.3.0
# 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

@ -7,7 +7,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: 21.1.0 graalVersion: 21.3.0
# 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

@ -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: 21.1.0 graalVersion: 21.3.0
# 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

@ -54,8 +54,10 @@
#### Enso Compiler #### Enso Compiler
- [Added overloaded `from` conversions.][3227] - [Added overloaded `from` conversions.][3227]
- [Upgraded to Graal VM 21.3.0][3258]
[3227]: https://github.com/enso-org/enso/pull/3227 [3227]: https://github.com/enso-org/enso/pull/3227
[3258]: https://github.com/enso-org/enso/pull/3258
# Enso 2.0.0-alpha.18 (2021-10-12) # Enso 2.0.0-alpha.18 (2021-10-12)

View File

@ -9,6 +9,9 @@
transitive dependencies of the library. transitive dependencies of the library.
- Updated the Scala compiler and dependencies - Updated the Scala compiler and dependencies
([#3214](https://github.com/enso-org/enso/pull/3214)). ([#3214](https://github.com/enso-org/enso/pull/3214)).
- Updated to
[GraalVM 21.3.0](https://github.com/graalvm/graalvm-ce-builds/releases/tag/vm-21.3.0)
([#3258](https://github.com/enso-org/enso/pull/3258)).
## Interpreter/Runtime ## Interpreter/Runtime

View File

@ -16,7 +16,7 @@ import java.io.File
// ============================================================================ // ============================================================================
val scalacVersion = "2.13.7" val scalacVersion = "2.13.7"
val graalVersion = "21.1.0" val graalVersion = "21.3.0"
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

@ -46,17 +46,17 @@ bundle containing all requirements for a static build with `musl`. It only
requires a `tar` command to be available to extract the bundle. requires a `tar` command to be available to extract the bundle.
Currently, to use `musl`, the `--libc=musl` option has to be added to the build Currently, to use `musl`, the `--libc=musl` option has to be added to the build
and `gcc-musl` must be available in the system PATH for the native-image. In the and `x86_64-linux-musl-gcc` must be available in the system PATH for the
future it is possible that a different option will be used or that the bundle native-image. In the future it is possible that a different option will be used
will not be required anymore if it became prepackaged. This task may thus need or that the bundle will not be required anymore if it became prepackaged. This
an update when moving to a newer version of Graal. More information may be found task may thus need an update when moving to a newer version of Graal. More
in information may be found in
[the Native Image documentation](https://github.com/oracle/graal/blob/master/substratevm/STATIC-IMAGES.md). [the Native Image documentation](https://github.com/oracle/graal/blob/master/substratevm/STATIC-IMAGES.md).
To make the bundle work correctly with GraalVM 20.2, a shell script called To make the bundle work correctly with GraalVM 20.2, a shell script called
`gcc-musl` which loads the bundle's configuration is created by the task and the `x86_64-linux-musl-gcc` which loads the bundle's configuration is created by the
paths starting with `/build/bundle` in `musl-gcc.specs` are replaced with task and the paths starting with `/build/bundle` in `musl-gcc.specs` are
absolute paths to the bundle location. replaced with absolute paths to the bundle location.
## Static Builds ## Static Builds

View File

@ -65,7 +65,7 @@ public class ClosureRootNode extends EnsoRootNode {
@Override @Override
public Object execute(VirtualFrame frame) { public Object execute(VirtualFrame frame) {
if (CompilerDirectives.inCompilationRoot() || CompilerDirectives.inInterpreter()) { if (CompilerDirectives.inCompilationRoot() || CompilerDirectives.inInterpreter()) {
lookupContextReference(Language.class).get().getThreadManager().poll(); com.oracle.truffle.api.TruffleSafepoint.poll(this);
} }
Object state = Function.ArgumentsHelper.getState(frame.getArguments()); Object state = Function.ArgumentsHelper.getState(frame.getArguments());
frame.setObject(this.getStateFrameSlot(), state); frame.setObject(this.getStateFrameSlot(), state);

View File

@ -14,7 +14,6 @@ import com.oracle.truffle.api.nodes.LoopNode;
import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.nodes.Node;
import com.oracle.truffle.api.nodes.NodeInfo; import com.oracle.truffle.api.nodes.NodeInfo;
import com.oracle.truffle.api.nodes.RepeatingNode; import com.oracle.truffle.api.nodes.RepeatingNode;
import org.enso.interpreter.Language;
import org.enso.interpreter.node.callable.ExecuteCallNode; import org.enso.interpreter.node.callable.ExecuteCallNode;
import org.enso.interpreter.node.callable.ExecuteCallNodeGen; import org.enso.interpreter.node.callable.ExecuteCallNodeGen;
import org.enso.interpreter.runtime.callable.CallerInfo; import org.enso.interpreter.runtime.callable.CallerInfo;
@ -210,7 +209,7 @@ public abstract class LoopingCallOptimiserNode extends CallOptimiserNode {
*/ */
@Override @Override
public boolean executeRepeating(VirtualFrame frame) { public boolean executeRepeating(VirtualFrame frame) {
lookupContextReference(Language.class).get().getThreadManager().poll(); com.oracle.truffle.api.TruffleSafepoint.poll(this);
try { try {
Function function = getNextFunction(frame); Function function = getNextFunction(frame);
Object state = getNextState(frame); Object state = getNextState(frame);

View File

@ -1,8 +1,6 @@
package org.enso.interpreter.node.expression.builtin.io; package org.enso.interpreter.node.expression.builtin.io;
import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.nodes.Node;
import org.apache.commons.lang3.SystemUtils;
import org.enso.interpreter.dsl.BuiltinMethod; import org.enso.interpreter.dsl.BuiltinMethod;
import org.enso.interpreter.runtime.data.text.Text; import org.enso.interpreter.runtime.data.text.Text;

View File

@ -1,6 +1,5 @@
package org.enso.interpreter.node.expression.builtin.number.bigInteger; package org.enso.interpreter.node.expression.builtin.number.bigInteger;
import cats.derived.IterState.Cont;
import com.oracle.truffle.api.TruffleLanguage.ContextReference; import com.oracle.truffle.api.TruffleLanguage.ContextReference;
import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Cached;
import com.oracle.truffle.api.dsl.CachedContext; import com.oracle.truffle.api.dsl.CachedContext;

View File

@ -1,6 +1,5 @@
package org.enso.interpreter.node.expression.builtin.number.utils; package org.enso.interpreter.node.expression.builtin.number.utils;
import com.fasterxml.jackson.databind.node.BigIntegerNode;
import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.CompilerDirectives;
import java.math.BigDecimal; import java.math.BigDecimal;

View File

@ -82,7 +82,7 @@ public class Context {
this.err = new PrintStream(environment.err()); this.err = new PrintStream(environment.err());
this.in = environment.in(); this.in = environment.in();
this.inReader = new BufferedReader(new InputStreamReader(environment.in())); this.inReader = new BufferedReader(new InputStreamReader(environment.in()));
this.threadManager = new ThreadManager(); this.threadManager = new ThreadManager(environment);
this.resourceManager = new ResourceManager(this); this.resourceManager = new ResourceManager(this);
this.isInlineCachingDisabled = this.isInlineCachingDisabled =
environment.getOptions().get(RuntimeOptions.DISABLE_INLINE_CACHES_KEY); environment.getOptions().get(RuntimeOptions.DISABLE_INLINE_CACHES_KEY);

View File

@ -1,33 +1,25 @@
package org.enso.interpreter.runtime; package org.enso.interpreter.runtime;
import com.oracle.truffle.api.Assumption; import com.oracle.truffle.api.ThreadLocalAction;
import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.TruffleLanguage.Env;
import com.oracle.truffle.api.Truffle;
import com.oracle.truffle.api.nodes.InvalidAssumptionException;
import org.enso.interpreter.runtime.control.ThreadInterruptedException; import org.enso.interpreter.runtime.control.ThreadInterruptedException;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.Phaser;
import java.util.concurrent.locks.ReentrantLock; import java.util.concurrent.locks.ReentrantLock;
/** Manages threads running guest code, exposing a safepoint-like functionality. */ /** Manages threads running guest code, exposing a safepoint-like functionality. */
public class ThreadManager { public class ThreadManager {
private final Phaser safepointPhaser =
new Phaser() {
@Override
protected boolean onAdvance(int phase, int registeredParties) {
// Ensure the phaser never terminates, even if the number of parties drops to zero at some
// point.
return false;
}
};
private final ReentrantLock lock = new ReentrantLock(); private final ReentrantLock lock = new ReentrantLock();
private final Env env;
private volatile boolean safepoint = false;
private final ConcurrentHashMap<Thread, Boolean> interruptFlags = new ConcurrentHashMap<>(); private final ConcurrentHashMap<Thread, Boolean> interruptFlags = new ConcurrentHashMap<>();
private static final Object ENTERED = new Object(); private static final Object ENTERED = new Object();
private static final Object NO_OP = new Object(); private static final Object NO_OP = new Object();
public ThreadManager(Env env) {
this.env = env;
}
/** /**
* Registers the current thread as running guest code. * Registers the current thread as running guest code.
* *
@ -42,7 +34,6 @@ public class ThreadManager {
*/ */
public Object enter() { public Object enter() {
if (interruptFlags.get(Thread.currentThread()) == null) { if (interruptFlags.get(Thread.currentThread()) == null) {
safepointPhaser.register();
interruptFlags.put(Thread.currentThread(), false); interruptFlags.put(Thread.currentThread(), false);
return ENTERED; return ENTERED;
} }
@ -58,23 +49,10 @@ public class ThreadManager {
*/ */
public void leave(Object token) { public void leave(Object token) {
if (token != NO_OP) { if (token != NO_OP) {
safepointPhaser.arriveAndDeregister();
interruptFlags.remove(Thread.currentThread()); interruptFlags.remove(Thread.currentThread());
} }
} }
/** Called from the interpreter to periodically perform a safepoint check. */
public void poll() {
if (safepoint) {
CompilerDirectives.transferToInterpreter();
safepointPhaser.arriveAndAwaitAdvance();
if (interruptFlags.get(Thread.currentThread())) {
interruptFlags.put(Thread.currentThread(), false);
throw new ThreadInterruptedException();
}
}
}
/** /**
* Forces all threads managed by this system to halt at the next safepoint (i.e. a {@link #poll()} * Forces all threads managed by this system to halt at the next safepoint (i.e. a {@link #poll()}
* call) and throw a {@link ThreadInterruptedException}. * call) and throw a {@link ThreadInterruptedException}.
@ -91,9 +69,15 @@ public class ThreadManager {
interruptFlags.replaceAll((t, b) -> true); interruptFlags.replaceAll((t, b) -> true);
Object p = enter(); Object p = enter();
try { try {
safepoint = true; env.submitThreadLocal(null, new ThreadLocalAction(true, false) {
safepointPhaser.arriveAndAwaitAdvance(); @Override
safepoint = false; protected void perform(ThreadLocalAction.Access access) {
Boolean interrupt = interruptFlags.get(access.getThread());
if (Boolean.TRUE.equals(interrupt)) {
throw new ThreadInterruptedException();
}
}
});
} finally { } finally {
leave(p); leave(p);
} }

View File

@ -20,7 +20,6 @@ import org.enso.interpreter.runtime.error.PanicSentinel;
import org.enso.interpreter.runtime.number.EnsoBigInteger; import org.enso.interpreter.runtime.number.EnsoBigInteger;
import org.enso.interpreter.runtime.scope.ModuleScope; import org.enso.interpreter.runtime.scope.ModuleScope;
import org.enso.polyglot.data.TypeGraph; import org.enso.polyglot.data.TypeGraph;
import org.yaml.snakeyaml.scanner.Constant;
/** /**
* This class defines the interpreter-level type system for Enso. * This class defines the interpreter-level type system for Enso.

View File

@ -201,7 +201,7 @@ object NativeImage {
* Checks for existence of its directory and if it does not exist, downloads * Checks for existence of its directory and if it does not exist, downloads
* and extracts the bundle. After extracting it does the required * and extracts the bundle. After extracting it does the required
* initialization (renaming paths to be absolute and creating a shell script * initialization (renaming paths to be absolute and creating a shell script
* called `musl-gcc`). * called `x86_64-linux-musl-gcc`).
* *
* `musl` is needed for static builds on Linux. * `musl` is needed for static builds on Linux.
* *
@ -217,7 +217,7 @@ object NativeImage {
val muslRoot = buildCache / "musl-1.2.0" val muslRoot = buildCache / "musl-1.2.0"
val bundleLocation = muslRoot / "bundle" val bundleLocation = muslRoot / "bundle"
val binaryLocation = bundleLocation / "bin" val binaryLocation = bundleLocation / "bin"
val gccLocation = binaryLocation / "musl-gcc" val gccLocation = binaryLocation / "x86_64-linux-musl-gcc"
def isMuslInstalled = def isMuslInstalled =
gccLocation.exists() && gccLocation.isOwnerExecutable gccLocation.exists() && gccLocation.isOwnerExecutable
if (!isMuslInstalled) { if (!isMuslInstalled) {
@ -297,7 +297,7 @@ object NativeImage {
s"""#!/bin/sh s"""#!/bin/sh
|exec "$${REALGCC:-gcc}" "$$@" -specs "$bundlePath/lib/musl-gcc.specs" |exec "$${REALGCC:-gcc}" "$$@" -specs "$bundlePath/lib/musl-gcc.specs"
|""".stripMargin |""".stripMargin
val wrapper = bundleLocation / "bin" / "musl-gcc" val wrapper = bundleLocation / "bin" / "x86_64-linux-musl-gcc"
IO.write(wrapper, content) IO.write(wrapper, content)
wrapper.setExecutable(true) wrapper.setExecutable(true)
} }
@ -320,14 +320,14 @@ object NativeImage {
* errors may arise. * errors may arise.
* *
* Currently, to use `musl`, the `--libc=musl` option has to be added to the * Currently, to use `musl`, the `--libc=musl` option has to be added to the
* build and `gcc-musl` must be available in the system PATH for the * build and `x86_64-linux-musl-gcc` must be available in the system PATH for the
* native-image. In the future it is possible that a different option will be * native-image. In the future it is possible that a different option will be
* used or that the bundle will not be required anymore if it became * used or that the bundle will not be required anymore if it became
* prepackaged. This task may thus need an update when moving to a newer version * prepackaged. This task may thus need an update when moving to a newer version
* of Graal. * of Graal.
* *
* Currently to make the bundle work correctly with GraalVM 20.2, a shell script * Currently to make the bundle work correctly with GraalVM 20.2, a shell script
* called `gcc-musl` which loads the bundle's configuration is created by the * called `x86_64-linux-musl-gcc` which loads the bundle's configuration is created by the
* task and the paths starting with `/build/bundle` in `musl-gcc.specs` are * task and the paths starting with `/build/bundle` in `musl-gcc.specs` are
* replaced with absolute paths to the bundle location. * replaced with absolute paths to the bundle location.
*/ */

View File

@ -47,7 +47,7 @@ spec =
{ {
"headers": { "headers": {
"Content-Length": "0", "Content-Length": "0",
"User-Agent": "Java-http-client/11.0.11" "User-Agent": "Java-http-client/11.0.13"
}, },
"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.11" "User-Agent": "Java-http-client/11.0.13"
}, },
"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.11" "User-Agent": "Java-http-client/11.0.13"
}, },
"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.11" "User-Agent": "Java-http-client/11.0.13"
}, },
"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.11" "User-Agent": "Java-http-client/11.0.13"
}, },
"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.11" "User-Agent": "Java-http-client/11.0.13"
}, },
"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.11" "User-Agent": "Java-http-client/11.0.13"
}, },
"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.11" "User-Agent": "Java-http-client/11.0.13"
}, },
"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.11" "User-Agent": "Java-http-client/11.0.13"
}, },
"origin": "127.0.0.1", "origin": "127.0.0.1",
"url": "", "url": "",
@ -229,7 +229,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.11" "User-Agent": "Java-http-client/11.0.13"
}, },
"origin": "127.0.0.1", "origin": "127.0.0.1",
"url": "", "url": "",
@ -252,7 +252,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.11" "User-Agent": "Java-http-client/11.0.13"
}, },
"origin": "127.0.0.1", "origin": "127.0.0.1",
"url": "", "url": "",
@ -272,7 +272,7 @@ spec =
{ {
"headers": { "headers": {
"Content-Length": "0", "Content-Length": "0",
"User-Agent": "Java-http-client/11.0.11" "User-Agent": "Java-http-client/11.0.13"
}, },
"origin": "127.0.0.1", "origin": "127.0.0.1",
"url": "", "url": "",
@ -288,7 +288,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.11" "User-Agent": "Java-http-client/11.0.13"
}, },
"origin": "127.0.0.1", "origin": "127.0.0.1",
"url": "", "url": "",
@ -313,7 +313,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.11" "User-Agent": "Java-http-client/11.0.13"
}, },
"origin": "127.0.0.1", "origin": "127.0.0.1",
"url": "", "url": "",

View File

@ -1,4 +1,4 @@
FROM ghcr.io/graalvm/graalvm-ce:java11-21.1.0 FROM ghcr.io/graalvm/graalvm-ce:java11-21.3.0
USER root USER root