-
Notifications
You must be signed in to change notification settings - Fork 323
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using latest GraalVM bits in Enso #8885
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,7 +31,7 @@ val graalVersion = "21.0.1" | |
// Version used for the Graal/Truffle related Maven packages | ||
// Keep in sync with GraalVM.version. Do not change the name of this variable, | ||
// it is used by the Rust build script via regex matching. | ||
val graalMavenPackagesVersion = "23.1.0" | ||
val graalMavenPackagesVersion = "24.1.0-SNAPSHOT" | ||
val targetJavaVersion = "17" | ||
val defaultDevEnsoVersion = "0.0.0-dev" | ||
val ensoVersion = sys.env.getOrElse( | ||
|
@@ -1228,6 +1228,7 @@ lazy val `polyglot-api` = project | |
"runtime-fat-jar" | ||
) / Compile / fullClasspath).value, | ||
libraryDependencies ++= Seq( | ||
"org.graalvm.polyglot" % "polyglot" % graalMavenPackagesVersion % "provided", | ||
"org.graalvm.sdk" % "polyglot-tck" % graalMavenPackagesVersion % "provided", | ||
"org.graalvm.truffle" % "truffle-api" % graalMavenPackagesVersion % "provided", | ||
"com.google.flatbuffers" % "flatbuffers-java" % flatbuffersVersion, | ||
|
@@ -1261,6 +1262,7 @@ lazy val `language-server` = (project in file("engine/language-server")) | |
"com.typesafe.akka" %% "akka-http-testkit" % akkaHTTPVersion % Test, | ||
"org.scalatest" %% "scalatest" % scalatestVersion % Test, | ||
"org.scalacheck" %% "scalacheck" % scalacheckVersion % Test, | ||
"org.graalvm.polyglot" % "polyglot" % graalMavenPackagesVersion % "provided", | ||
"org.graalvm.sdk" % "polyglot-tck" % graalMavenPackagesVersion % "provided", | ||
"org.eclipse.jgit" % "org.eclipse.jgit" % jgitVersion, | ||
"org.bouncycastle" % "bcutil-jdk18on" % "1.76" % Test, | ||
|
@@ -1432,6 +1434,7 @@ lazy val frgaalJavaCompilerSetting = | |
customFrgaalJavaCompilerSettings(targetJavaVersion) | ||
|
||
def customFrgaalJavaCompilerSettings(targetJdk: String) = Seq( | ||
resolvers += Resolver.mavenLocal, | ||
Compile / compile / compilers := FrgaalJavaCompiler.compilers( | ||
(Compile / dependencyClasspath).value, | ||
compilers.value, | ||
|
@@ -1482,10 +1485,11 @@ lazy val `runtime-language-epb` = | |
Test / javaOptions ++= Seq(), | ||
instrumentationSettings, | ||
libraryDependencies ++= Seq( | ||
"junit" % "junit" % junitVersion % Test, | ||
"com.github.sbt" % "junit-interface" % junitIfVersion % Test, | ||
"org.graalvm.truffle" % "truffle-api" % graalMavenPackagesVersion % "provided", | ||
"org.graalvm.truffle" % "truffle-dsl-processor" % graalMavenPackagesVersion % "provided" | ||
"junit" % "junit" % junitVersion % Test, | ||
"com.github.sbt" % "junit-interface" % junitIfVersion % Test, | ||
"org.graalvm.polyglot" % "polyglot" % graalMavenPackagesVersion % "provided", | ||
"org.graalvm.truffle" % "truffle-api" % graalMavenPackagesVersion % "provided", | ||
"org.graalvm.truffle" % "truffle-dsl-processor" % graalMavenPackagesVersion % "provided" | ||
) | ||
) | ||
|
||
|
@@ -1562,6 +1566,7 @@ lazy val `runtime-test-instruments` = | |
libraryDependencies ++= GraalVM.modules, | ||
libraryDependencies ++= Seq( | ||
"org.graalvm.sdk" % "polyglot-tck" % graalMavenPackagesVersion, | ||
"org.graalvm.truffle" % "truffle-dsl-processor" % graalMavenPackagesVersion, | ||
"org.graalvm.truffle" % "truffle-tck" % graalMavenPackagesVersion, | ||
"org.graalvm.truffle" % "truffle-tck-common" % graalMavenPackagesVersion, | ||
"org.graalvm.truffle" % "truffle-tck-tests" % graalMavenPackagesVersion, | ||
|
@@ -1620,6 +1625,7 @@ lazy val runtime = (project in file("engine/runtime")) | |
"org.apache.tika" % "tika-core" % tikaVersion, | ||
"org.graalvm.polyglot" % "polyglot" % graalMavenPackagesVersion % "provided", | ||
"org.graalvm.sdk" % "polyglot-tck" % graalMavenPackagesVersion % "provided", | ||
"org.graalvm.sdk" % "collections" % graalMavenPackagesVersion % "provided", | ||
"org.graalvm.truffle" % "truffle-api" % graalMavenPackagesVersion % "provided", | ||
"org.graalvm.truffle" % "truffle-dsl-processor" % graalMavenPackagesVersion % "provided", | ||
"org.graalvm.truffle" % "truffle-tck" % graalMavenPackagesVersion % Test, | ||
|
@@ -1866,11 +1872,12 @@ lazy val `runtime-compiler` = | |
frgaalJavaCompilerSetting, | ||
instrumentationSettings, | ||
libraryDependencies ++= Seq( | ||
"junit" % "junit" % junitVersion % Test, | ||
"com.github.sbt" % "junit-interface" % junitIfVersion % Test, | ||
"org.scalatest" %% "scalatest" % scalatestVersion % Test, | ||
"org.netbeans.api" % "org-openide-util-lookup" % netbeansApiVersion % "provided", | ||
"com.lihaoyi" %% "fansi" % fansiVersion | ||
"junit" % "junit" % junitVersion % Test, | ||
"com.github.sbt" % "junit-interface" % junitIfVersion % Test, | ||
"org.scalatest" %% "scalatest" % scalatestVersion % Test, | ||
"org.graalvm.polyglot" % "polyglot" % graalMavenPackagesVersion % "provided", | ||
"org.netbeans.api" % "org-openide-util-lookup" % netbeansApiVersion % "provided", | ||
"com.lihaoyi" %% "fansi" % fansiVersion | ||
) | ||
) | ||
.dependsOn(`runtime-parser`) | ||
|
@@ -2085,14 +2092,15 @@ lazy val `engine-runner` = project | |
commands += WithDebugCommand.withDebug, | ||
inConfig(Compile)(truffleRunOptionsSettings), | ||
libraryDependencies ++= Seq( | ||
"org.graalvm.sdk" % "polyglot-tck" % graalMavenPackagesVersion % Provided, | ||
"org.graalvm.truffle" % "truffle-api" % graalMavenPackagesVersion % Provided, | ||
"commons-cli" % "commons-cli" % commonsCliVersion, | ||
"com.monovore" %% "decline" % declineVersion, | ||
"org.jline" % "jline" % jlineVersion, | ||
"org.typelevel" %% "cats-core" % catsVersion, | ||
"junit" % "junit" % junitVersion % Test, | ||
"com.github.sbt" % "junit-interface" % junitIfVersion % Test | ||
"org.graalvm.polyglot" % "polyglot" % graalMavenPackagesVersion % "provided", | ||
"org.graalvm.sdk" % "polyglot-tck" % graalMavenPackagesVersion % Provided, | ||
"org.graalvm.truffle" % "truffle-api" % graalMavenPackagesVersion % Provided, | ||
"commons-cli" % "commons-cli" % commonsCliVersion, | ||
"com.monovore" %% "decline" % declineVersion, | ||
"org.jline" % "jline" % jlineVersion, | ||
"org.typelevel" %% "cats-core" % catsVersion, | ||
"junit" % "junit" % junitVersion % Test, | ||
"com.github.sbt" % "junit-interface" % junitIfVersion % Test | ||
), | ||
run / connectInput := true | ||
) | ||
|
@@ -2592,6 +2600,7 @@ lazy val `std-base` = project | |
`base-polyglot-root` / "std-base.jar", | ||
libraryDependencies ++= Seq( | ||
"org.graalvm.polyglot" % "polyglot" % graalMavenPackagesVersion, | ||
"org.graalvm.sdk" % "collections" % graalMavenPackagesVersion, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Collections are now separated into its own JAR. As the group ID suggests ( |
||
"org.netbeans.api" % "org-openide-util-lookup" % netbeansApiVersion % "provided" | ||
), | ||
Compile / packageBin := Def.task { | ||
|
@@ -2708,6 +2717,7 @@ lazy val `std-table` = project | |
}, | ||
libraryDependencies ++= Seq( | ||
"org.graalvm.polyglot" % "polyglot" % graalMavenPackagesVersion % "provided", | ||
"org.graalvm.sdk" % "collections" % graalMavenPackagesVersion, | ||
"org.netbeans.api" % "org-openide-util-lookup" % netbeansApiVersion % "provided", | ||
"com.univocity" % "univocity-parsers" % univocityParsersVersion, | ||
"org.apache.poi" % "poi-ooxml" % poiOoxmlVersion, | ||
|
@@ -2797,6 +2807,7 @@ lazy val `std-database` = project | |
`database-polyglot-root` / "std-database.jar", | ||
libraryDependencies ++= Seq( | ||
"org.graalvm.polyglot" % "polyglot" % graalMavenPackagesVersion % "provided", | ||
"org.graalvm.sdk" % "collections" % graalMavenPackagesVersion % "provided", | ||
"org.netbeans.api" % "org-openide-util-lookup" % netbeansApiVersion % "provided", | ||
"org.xerial" % "sqlite-jdbc" % sqliteVersion, | ||
"org.postgresql" % "postgresql" % "42.4.0" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,20 +3,44 @@ | |
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertTrue; | ||
|
||
import java.util.Random; | ||
import java.util.concurrent.Executors; | ||
import java.util.concurrent.TimeUnit; | ||
import org.graalvm.polyglot.Context; | ||
import org.graalvm.polyglot.Value; | ||
import org.junit.AfterClass; | ||
import org.junit.BeforeClass; | ||
import org.junit.Ignore; | ||
import org.junit.Test; | ||
|
||
public class ForeignMethodInvokeTest extends TestBase { | ||
private static Context ctx; | ||
|
||
@BeforeClass | ||
public static void prepareCtx() { | ||
ctx = defaultContextBuilder("enso", "js").build(); | ||
var r = new Random(); | ||
var counter = new long[1]; | ||
var b = | ||
defaultContextBuilder("enso", "js") | ||
.onDeniedThreadAccess( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. With More info on Ethernet collision detection and behavior - most important "Calculate and wait the random backoff". |
||
(ex) -> { | ||
System.err.println( | ||
"Denied thread access: " | ||
+ ex.getMessage() | ||
+ " in " | ||
+ Thread.currentThread().getName()); | ||
if (counter[0] > 500) { | ||
throw ex; | ||
} | ||
try { | ||
long waitTime = r.nextInt(100); | ||
System.err.println("Waiting " + waitTime + " ms like Ethernet"); | ||
Thread.sleep(waitTime); | ||
counter[0] += waitTime; | ||
} catch (InterruptedException ignore) { | ||
} | ||
System.err.println("Trying again"); | ||
}); | ||
ctx = b.build(); | ||
} | ||
|
||
@AfterClass | ||
|
@@ -85,7 +109,6 @@ public void testInteropWithJavaScript() throws Exception { | |
assertEquals(12, res2.getArrayElement(2).asInt()); | ||
} | ||
|
||
@Ignore | ||
@Test | ||
public void testParallelInteropWithJavaScript() throws Exception { | ||
var source = | ||
|
@@ -95,7 +118,9 @@ public void testParallelInteropWithJavaScript() throws Exception { | |
polyglot java import java.lang.Thread | ||
|
||
foreign js js_array t f = \"\"\" | ||
print("In JavaScript...") | ||
f(300) | ||
print("In JavaScript after waiting...") | ||
return [1, 2, t] | ||
|
||
third t = js_array t (delay-> Thread.sleep delay) | ||
|
@@ -108,16 +133,37 @@ public void testParallelInteropWithJavaScript() throws Exception { | |
Executors.newSingleThreadExecutor() | ||
.submit( | ||
() -> { | ||
return third.execute(12); | ||
try { | ||
Thread.sleep(100); | ||
System.err.println( | ||
"Entering context in executor thread in " | ||
+ Thread.currentThread().getName()); | ||
ctx.enter(); | ||
System.err.println("Entered context in executor thread"); | ||
return third.execute(12); | ||
} catch (InterruptedException ex) { | ||
ex.printStackTrace(); | ||
return null; | ||
} finally { | ||
ctx.leave(); | ||
System.err.println("Left context in executor thread"); | ||
} | ||
}); | ||
ctx.enter(); | ||
System.err.println("Entered context on main thread in " + Thread.currentThread().getName()); | ||
var res = third.execute(13); | ||
System.err.println("Got result on main thread: " + res); | ||
assertTrue("It is an array", res.hasArrayElements()); | ||
assertEquals(3, res.getArraySize()); | ||
assertEquals(1, res.getArrayElement(0).asInt()); | ||
assertEquals(2, res.getArrayElement(1).asInt()); | ||
assertEquals(13, res.getArrayElement(2).asInt()); | ||
ctx.leave(); | ||
System.err.println("Context left on main thread"); | ||
|
||
var res2 = future.get(10, TimeUnit.SECONDS); | ||
|
||
var res2 = future.get(); | ||
System.err.println("Future result obtained: " + res2); | ||
|
||
assertTrue("It is an array2", res2.hasArrayElements()); | ||
assertEquals(12, res2.getArrayElement(2).asInt()); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This enables usage of JARs from
~/.m2/repository
. To install them update GraalVM to: oracle/graal#8266 in particular commit 853702c407c8fb31116decfefddef87a71203154 and do:these two commands install all Truffle & SDK JARs into local repository with version
24.1.0-SNAPSHOT
. Thesbt
build can then find them.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As of 253ded5 I am able to execute:
and that is enough for testing oracle/graal#8266