From ec3ae53b8500f8c74f6e1a418eb4516a79a3b2ec Mon Sep 17 00:00:00 2001 From: Pavel Marek Date: Fri, 30 Jun 2023 12:12:50 +0200 Subject: [PATCH 01/51] Update GraalVM to 23.0.0 JDK17 --- build.sbt | 2 +- build/ci_utils/src/cache/goodie/graalvm.rs | 10 ++++---- test/Tests/src/Network/Http_Spec.enso | 28 +++++++++++----------- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/build.sbt b/build.sbt index 93b0a1dbd41b..c31a76423b06 100644 --- a/build.sbt +++ b/build.sbt @@ -20,7 +20,7 @@ import java.io.File // ============================================================================ val scalacVersion = "2.13.11" -val graalVersion = "22.3.1" +val graalVersion = "23.0.0" val javaVersion = "17" val defaultDevEnsoVersion = "0.0.0-dev" val ensoVersion = sys.env.getOrElse( diff --git a/build/ci_utils/src/cache/goodie/graalvm.rs b/build/ci_utils/src/cache/goodie/graalvm.rs index 35a117e9ecf1..770e7dc3bf37 100644 --- a/build/ci_utils/src/cache/goodie/graalvm.rs +++ b/build/ci_utils/src/cache/goodie/graalvm.rs @@ -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 version 17.0.6 2023-01-17 -OpenJDK Runtime Environment GraalVM CE 22.3.1 (build 17.0.6+10-jvmci-22.3-b13) -OpenJDK 64-Bit Server VM GraalVM CE 22.3.1 (build 17.0.6+10-jvmci-22.3-b13, mixed mode, sharing)"; + let version_string = "java version \"17.0.7\" 2023-04-18 LTS +Java(TM) SE Runtime Environment Oracle GraalVM 17.0.7+8.1 (build 17.0.7+8-LTS-jvmci-23.0-b12) +Java HotSpot(TM) 64-Bit Server VM Oracle GraalVM 17.0.7+8.1 (build 17.0.7+8-LTS-jvmci-23.0-b12, mixed mode, sharing)"; let found_graal = graal_version_from_version_string(version_string).unwrap(); - assert_eq!(found_graal, Version::new(22, 3, 1)); + assert_eq!(found_graal, Version::new(23, 0, 0)); let found_java = Java.parse_version(version_string).unwrap(); - assert_eq!(found_java, Version::new(17, 0, 6)); + assert_eq!(found_java, Version::new(17, 0, 7)); } } diff --git a/test/Tests/src/Network/Http_Spec.enso b/test/Tests/src/Network/Http_Spec.enso index 57affaae8afb..7e93d9b9f8bc 100644 --- a/test/Tests/src/Network/Http_Spec.enso +++ b/test/Tests/src/Network/Http_Spec.enso @@ -46,7 +46,7 @@ spec = { "headers": { "Content-Length": "0", - "User-Agent": "Java-http-client/17.0.6" + "User-Agent": "Java-http-client/17.0.7" }, "origin": "127.0.0.1", "url": "", @@ -60,7 +60,7 @@ spec = { "headers": { "Content-Length": "0", - "User-Agent": "Java-http-client/17.0.6" + "User-Agent": "Java-http-client/17.0.7" }, "origin": "127.0.0.1", "url": "", @@ -75,7 +75,7 @@ spec = { "headers": { "Content-Length": "0", - "User-Agent": "Java-http-client/17.0.6" + "User-Agent": "Java-http-client/17.0.7" }, "origin": "127.0.0.1", "url": "", @@ -96,7 +96,7 @@ spec = { "headers": { "Content-Length": "0", - "User-Agent": "Java-http-client/17.0.6" + "User-Agent": "Java-http-client/17.0.7" }, "origin": "127.0.0.1", "url": "", @@ -115,7 +115,7 @@ spec = { "headers": { "Content-Length": "0", - "User-Agent": "Java-http-client/17.0.6" + "User-Agent": "Java-http-client/17.0.7" }, "origin": "127.0.0.1", "url": "", @@ -135,7 +135,7 @@ spec = "headers": { "Content-Length": "12", "Content-Type": "text/plain", - "User-Agent": "Java-http-client/17.0.6" + "User-Agent": "Java-http-client/17.0.7" }, "origin": "127.0.0.1", "url": "", @@ -155,7 +155,7 @@ spec = "headers": { "Content-Length": "7", "Content-Type": "application/x-www-form-urlencoded", - "User-Agent": "Java-http-client/17.0.6" + "User-Agent": "Java-http-client/17.0.7" }, "origin": "127.0.0.1", "url": "", @@ -175,7 +175,7 @@ spec = "headers": { "Content-Length": "7", "Content-Type": "application/x-www-form-urlencoded", - "User-Agent": "Java-http-client/17.0.6" + "User-Agent": "Java-http-client/17.0.7" }, "origin": "127.0.0.1", "url": "", @@ -205,7 +205,7 @@ spec = "headers": { "Content-Length": "13", "Content-Type": "application/json", - "User-Agent": "Java-http-client/17.0.6" + "User-Agent": "Java-http-client/17.0.7" }, "origin": "127.0.0.1", "url": "", @@ -227,7 +227,7 @@ spec = "headers": { "Content-Length": "13", "Content-Type": "application/json", - "User-Agent": "Java-http-client/17.0.6" + "User-Agent": "Java-http-client/17.0.7" }, "origin": "127.0.0.1", "url": "", @@ -249,7 +249,7 @@ spec = "headers": { "Content-Length": "12", "Content-Type": "application/octet-stream", - "User-Agent": "Java-http-client/17.0.6" + "User-Agent": "Java-http-client/17.0.7" }, "origin": "127.0.0.1", "url": "", @@ -269,7 +269,7 @@ spec = { "headers": { "Content-Length": "0", - "User-Agent": "Java-http-client/17.0.6" + "User-Agent": "Java-http-client/17.0.7" }, "origin": "127.0.0.1", "url": "", @@ -285,7 +285,7 @@ spec = "headers": { "Content-Length": "13", "Content-Type": "application/json", - "User-Agent": "Java-http-client/17.0.6" + "User-Agent": "Java-http-client/17.0.7" }, "origin": "127.0.0.1", "url": "", @@ -309,7 +309,7 @@ spec = "headers": { "Content-Length": "16", "Content-Type": "application/json", - "User-Agent": "Java-http-client/17.0.6" + "User-Agent": "Java-http-client/17.0.7" }, "origin": "127.0.0.1", "url": "", From 075d1ac9ef05f3fc8b0cb5338a27af0e13b6dedf Mon Sep 17 00:00:00 2001 From: Pavel Marek Date: Fri, 30 Jun 2023 12:14:18 +0200 Subject: [PATCH 02/51] Update CHANGELOG --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c048c3e642f0..fd63b7e40158 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -846,6 +846,7 @@ - [Added retries when executing GraalVM updater][7079] - [Add method call info for infix operators][7090] - [`executionComplete` response is sent on successful execution only][7143] +- [Update to GraalVM 23.0.0][7176] [3227]: https://github.com/enso-org/enso/pull/3227 [3248]: https://github.com/enso-org/enso/pull/3248 @@ -969,6 +970,7 @@ [7079]: https://github.com/enso-org/enso/pull/7079 [7090]: https://github.com/enso-org/enso/pull/7090 [7143]: https://github.com/enso-org/enso/pull/7143 +[7176]: https://github.com/enso-org/enso/pull/7176 # Enso 2.0.0-alpha.18 (2021-10-12) From 39ef06ab9eb4301a847e24df9ffdd2b621081064 Mon Sep 17 00:00:00 2001 From: Pavel Marek Date: Fri, 30 Jun 2023 19:25:12 +0200 Subject: [PATCH 03/51] Update build tool for new Graal release names --- build.sbt | 81 +++++++++++----------- build/build/src/engine.rs | 2 - build/build/src/engine/context.rs | 2 +- build/ci_utils/src/cache/goodie/graalvm.rs | 53 ++++++++------ build/ci_utils/src/programs/graal.rs | 7 +- build/ci_utils/src/programs/java.rs | 2 +- tools/ci/docker/Dockerfile | 2 +- 7 files changed, 80 insertions(+), 69 deletions(-) diff --git a/build.sbt b/build.sbt index c31a76423b06..392115103304 100644 --- a/build.sbt +++ b/build.sbt @@ -20,8 +20,11 @@ import java.io.File // ============================================================================ val scalacVersion = "2.13.11" -val graalVersion = "23.0.0" -val javaVersion = "17" +// Since the release of GraalVM 23.0.0, the versioning is the same for Graal and Java +val graalVersion = "17.0.7" +// Verwsion used for the Graal/Truffle related Maven packages +val graalMavenVersion = "23.0.0" +val javaLangVersion = "17" val defaultDevEnsoVersion = "0.0.0-dev" val ensoVersion = sys.env.getOrElse( "ENSO_VERSION", @@ -153,8 +156,8 @@ analyzeDependency := GatherLicenses.analyzeDependency.evaluated val packageBuilder = new DistributionPackage.Builder( ensoVersion = ensoVersion, - graalVersion = graalVersion, - graalJavaVersion = javaVersion, + graalVersion = graalMavenVersion, + graalJavaVersion = javaLangVersion, artifactRoot = file("built-distribution") ) @@ -638,7 +641,7 @@ lazy val `akka-native` = project akkaActor ), // Note [Native Image Workaround for GraalVM 20.2] - libraryDependencies += "org.graalvm.nativeimage" % "svm" % graalVersion % "provided" + libraryDependencies += "org.graalvm.nativeimage" % "svm" % graalMavenVersion % "provided" ) lazy val `profiling-utils` = project @@ -692,7 +695,7 @@ lazy val `logging-service` = project "junit" % "junit" % junitVersion % Test, "com.novocode" % "junit-interface" % junitIfVersion % Test exclude ("junit", "junit-dep"), "org.scalatest" %% "scalatest" % scalatestVersion % Test, - "org.graalvm.nativeimage" % "svm" % graalVersion % "provided" + "org.graalvm.nativeimage" % "svm" % graalMavenVersion % "provided" ) ) .settings( @@ -711,7 +714,7 @@ lazy val `logging-truffle-connector` = project version := "0.1", libraryDependencies ++= Seq( "org.slf4j" % "slf4j-api" % slf4jVersion, - "org.graalvm.truffle" % "truffle-api" % graalVersion % "provided" + "org.graalvm.truffle" % "truffle-api" % graalMavenVersion % "provided" ) ) .dependsOn(`logging-utils`) @@ -760,7 +763,7 @@ lazy val `version-output` = (project in file("lib/scala/version-output")) defaultDevEnsoVersion = defaultDevEnsoVersion, ensoVersion = ensoVersion, scalacVersion = scalacVersion, - graalVersion = graalVersion, + graalVersion = graalMavenVersion, currentEdition = currentEdition ) }.taskValue @@ -960,8 +963,8 @@ lazy val `interpreter-dsl-test` = ), commands += WithDebugCommand.withDebug, libraryDependencies ++= Seq( - "org.graalvm.truffle" % "truffle-api" % graalVersion % "provided", - "org.graalvm.truffle" % "truffle-dsl-processor" % graalVersion % "provided", + "org.graalvm.truffle" % "truffle-api" % graalMavenVersion % "provided", + "org.graalvm.truffle" % "truffle-dsl-processor" % graalMavenVersion % "provided", "junit" % "junit" % junitVersion % Test, "com.novocode" % "junit-interface" % junitIfVersion % Test exclude ("junit", "junit-dep") ) @@ -1014,8 +1017,8 @@ lazy val `polyglot-api` = project Seq(s"-Dtruffle.class.path.append=$runtimeClasspath") }, libraryDependencies ++= Seq( - "org.graalvm.sdk" % "polyglot-tck" % graalVersion % "provided", - "org.graalvm.truffle" % "truffle-api" % graalVersion % "provided", + "org.graalvm.sdk" % "polyglot-tck" % graalMavenVersion % "provided", + "org.graalvm.truffle" % "truffle-api" % graalMavenVersion % "provided", "com.google.flatbuffers" % "flatbuffers-java" % flatbuffersVersion, "org.scalatest" %% "scalatest" % scalatestVersion % Test, "org.scalacheck" %% "scalacheck" % scalacheckVersion % Test @@ -1046,7 +1049,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.sdk" % "polyglot-tck" % graalVersion % "provided", + "org.graalvm.sdk" % "polyglot-tck" % graalMavenVersion % "provided", "org.eclipse.jgit" % "org.eclipse.jgit" % jgitVersion ), Test / testOptions += Tests @@ -1134,7 +1137,7 @@ lazy val frgaalJavaCompilerSetting = Seq( Compile / compile / compilers := FrgaalJavaCompiler.compilers( (Compile / dependencyClasspath).value, compilers.value, - javaVersion + javaLangVersion ), // This dependency is needed only so that developers don't download Frgaal manually. // Sadly it cannot be placed under plugins either because meta dependencies are not easily @@ -1160,8 +1163,8 @@ lazy val instrumentationSettings = frgaalJavaCompilerSetting ++ Seq( "--enable-preview" ), libraryDependencies ++= Seq( - "org.graalvm.truffle" % "truffle-api" % graalVersion % "provided", - "org.graalvm.truffle" % "truffle-dsl-processor" % graalVersion % "provided" + "org.graalvm.truffle" % "truffle-api" % graalMavenVersion % "provided", + "org.graalvm.truffle" % "truffle-dsl-processor" % graalMavenVersion % "provided" ), (Compile / javacOptions) ++= Seq( "-s", @@ -1277,16 +1280,16 @@ lazy val runtime = (project in file("engine/runtime")) libraryDependencies ++= jmh ++ jaxb ++ circe ++ Seq( "org.apache.commons" % "commons-lang3" % commonsLangVersion, "org.apache.tika" % "tika-core" % tikaVersion, - "org.graalvm.sdk" % "graal-sdk" % graalVersion % "provided", - "org.graalvm.sdk" % "polyglot-tck" % graalVersion % "provided", - "org.graalvm.truffle" % "truffle-api" % graalVersion % "provided", - "org.graalvm.truffle" % "truffle-dsl-processor" % graalVersion % "provided", - "org.graalvm.truffle" % "truffle-tck" % graalVersion % "provided", - "org.graalvm.truffle" % "truffle-tck-common" % graalVersion % "provided", + "org.graalvm.sdk" % "graal-sdk" % graalMavenVersion % "provided", + "org.graalvm.sdk" % "polyglot-tck" % graalMavenVersion % "provided", + "org.graalvm.truffle" % "truffle-api" % graalMavenVersion % "provided", + "org.graalvm.truffle" % "truffle-dsl-processor" % graalMavenVersion % "provided", + "org.graalvm.truffle" % "truffle-tck" % graalMavenVersion % "provided", + "org.graalvm.truffle" % "truffle-tck-common" % graalMavenVersion % "provided", "org.scalacheck" %% "scalacheck" % scalacheckVersion % Test, "org.scalactic" %% "scalactic" % scalacticVersion % Test, "org.scalatest" %% "scalatest" % scalatestVersion % Test, - "org.graalvm.truffle" % "truffle-api" % graalVersion % Benchmark, + "org.graalvm.truffle" % "truffle-api" % graalMavenVersion % Benchmark, "org.typelevel" %% "cats-core" % catsVersion, "junit" % "junit" % junitVersion % Test, "com.novocode" % "junit-interface" % junitIfVersion % Test exclude ("junit", "junit-dep"), @@ -1306,8 +1309,8 @@ lazy val runtime = (project in file("engine/runtime")) ), bootstrap := CopyTruffleJAR.bootstrapJARs.value, Global / onLoad := EnvironmentCheck.addVersionCheck( - graalVersion, - javaVersion + graalMavenVersion, + javaLangVersion )((Global / onLoad).value) ) .settings( @@ -1450,8 +1453,8 @@ lazy val `runtime-with-instruments` = ), libraryDependencies ++= Seq( "org.scalatest" %% "scalatest" % scalatestVersion % Test, - "org.graalvm.truffle" % "truffle-api" % graalVersion % Test, - "org.graalvm.truffle" % "truffle-dsl-processor" % graalVersion % Test + "org.graalvm.truffle" % "truffle-api" % graalMavenVersion % Test, + "org.graalvm.truffle" % "truffle-dsl-processor" % graalMavenVersion % Test ), // Note [Unmanaged Classpath] Test / unmanagedClasspath += (baseDirectory.value / ".." / ".." / "app" / "gui" / "view" / "graph-editor" / "src" / "builtin" / "visualization" / "native" / "inc"), @@ -1519,7 +1522,7 @@ lazy val `runtime-with-polyglot` = "ENSO_TEST_DISABLE_IR_CACHE" -> "false" ), libraryDependencies ++= Seq( - "org.graalvm.sdk" % "graal-sdk" % graalVersion % "provided", + "org.graalvm.sdk" % "graal-sdk" % graalMavenVersion % "provided", "org.scalatest" %% "scalatest" % scalatestVersion % Test ) ) @@ -1580,8 +1583,8 @@ lazy val `engine-runner` = project commands += WithDebugCommand.withDebug, inConfig(Compile)(truffleRunOptionsSettings), libraryDependencies ++= Seq( - "org.graalvm.sdk" % "polyglot-tck" % graalVersion % "provided", - "org.graalvm.truffle" % "truffle-api" % graalVersion % "provided", + "org.graalvm.sdk" % "polyglot-tck" % graalMavenVersion % "provided", + "org.graalvm.truffle" % "truffle-api" % graalMavenVersion % "provided", "commons-cli" % "commons-cli" % commonsCliVersion, "com.monovore" %% "decline" % declineVersion, "org.jline" % "jline" % jlineVersion, @@ -1918,7 +1921,7 @@ lazy val `std-base` = project Compile / packageBin / artifactPath := `base-polyglot-root` / "std-base.jar", libraryDependencies ++= Seq( - "org.graalvm.sdk" % "graal-sdk" % graalVersion % "provided", + "org.graalvm.sdk" % "graal-sdk" % graalMavenVersion % "provided", "org.netbeans.api" % "org-openide-util-lookup" % netbeansApiVersion % "provided" ), Compile / packageBin := Def.task { @@ -1946,7 +1949,7 @@ lazy val `common-polyglot-core-utils` = project `base-polyglot-root` / "common-polyglot-core-utils.jar", libraryDependencies ++= Seq( "com.ibm.icu" % "icu4j" % icuVersion, - "org.graalvm.sdk" % "graal-sdk" % graalVersion % "provided" + "org.graalvm.sdk" % "graal-sdk" % graalMavenVersion % "provided" ) ) @@ -1958,7 +1961,7 @@ lazy val `enso-test-java-helpers` = project Compile / packageBin / artifactPath := file("test/Tests/polyglot/java/helpers.jar"), libraryDependencies ++= Seq( - "org.graalvm.sdk" % "graal-sdk" % graalVersion % "provided" + "org.graalvm.sdk" % "graal-sdk" % graalMavenVersion % "provided" ), Compile / packageBin := Def.task { val result = (Compile / packageBin).value @@ -1991,7 +1994,7 @@ lazy val `std-table` = project (Antlr4 / sourceManaged).value / "main" / "antlr4" }, libraryDependencies ++= Seq( - "org.graalvm.sdk" % "graal-sdk" % graalVersion % "provided", + "org.graalvm.sdk" % "graal-sdk" % graalMavenVersion % "provided", "org.netbeans.api" % "org-openide-util-lookup" % netbeansApiVersion % "provided", "com.univocity" % "univocity-parsers" % univocityParsersVersion, "org.apache.poi" % "poi-ooxml" % poiOoxmlVersion, @@ -2069,7 +2072,7 @@ lazy val `std-database` = project Compile / packageBin / artifactPath := `database-polyglot-root` / "std-database.jar", libraryDependencies ++= Seq( - "org.graalvm.sdk" % "graal-sdk" % graalVersion % "provided", + "org.graalvm.sdk" % "graal-sdk" % graalMavenVersion % "provided", "org.netbeans.api" % "org-openide-util-lookup" % netbeansApiVersion % "provided", "org.xerial" % "sqlite-jdbc" % sqliteVersion, "org.postgresql" % "postgresql" % "42.4.0" @@ -2175,8 +2178,8 @@ buildEngineDistribution := { distributionRoot = root, cacheFactory = cacheFactory, log = log, - graalVersion = graalVersion, - javaVersion = javaVersion, + graalVersion = graalMavenVersion, + javaVersion = javaLangVersion, ensoVersion = ensoVersion, editionName = currentEdition, sourceStdlibVersion = stdLibVersion, @@ -2199,8 +2202,8 @@ buildEngineDistributionNoIndex := { distributionRoot = root, cacheFactory = cacheFactory, log = log, - graalVersion = graalVersion, - javaVersion = javaVersion, + graalVersion = graalMavenVersion, + javaVersion = javaLangVersion, ensoVersion = ensoVersion, editionName = currentEdition, sourceStdlibVersion = stdLibVersion, diff --git a/build/build/src/engine.rs b/build/build/src/engine.rs index a1e6fd5814d0..f28217f47985 100644 --- a/build/build/src/engine.rs +++ b/build/build/src/engine.rs @@ -5,7 +5,6 @@ use crate::prelude::*; use crate::get_graal_version; -use crate::get_java_major_version; use crate::paths::generated; use artifact::IsArtifact; @@ -304,7 +303,6 @@ pub async fn deduce_graal( Ok(ide_ci::cache::goodie::graalvm::GraalVM { client, graal_version: get_graal_version(&build_sbt_content)?, - java_version: get_java_major_version(&build_sbt_content)?, os: TARGET_OS, arch: TARGET_ARCH, }) diff --git a/build/build/src/engine/context.rs b/build/build/src/engine/context.rs index 5bc30e423279..aad7d5b4ecb2 100644 --- a/build/build/src/engine/context.rs +++ b/build/build/src/engine/context.rs @@ -201,7 +201,7 @@ impl RunContext { // Some GraalVM components depend on Sulong and are not available on all platforms (like // Windows or M1 macOS). Thus, we treat them as optional. See e.g. // https://github.com/oracle/graalpython/issues/156 - let optional_components = [graal::ComponentId::Python, graal::ComponentId::R]; + let optional_components = [graal::ComponentId::Python]; graal::install_missing_components(required_components, optional_components).await?; prepare_simple_library_server.await??; Ok(()) diff --git a/build/ci_utils/src/cache/goodie/graalvm.rs b/build/ci_utils/src/cache/goodie/graalvm.rs index 770e7dc3bf37..6983347431cb 100644 --- a/build/ci_utils/src/cache/goodie/graalvm.rs +++ b/build/ci_utils/src/cache/goodie/graalvm.rs @@ -5,13 +5,12 @@ use crate::cache::goodie::Goodie; use crate::cache::Cache; use crate::env::known::PATH; use crate::github::RepoRef; -use crate::programs::java; use crate::programs::java::JAVA_HOME; use crate::programs::Java; -const PACKAGE_PREFIX: &str = "graalvm-ce"; +const PACKAGE_PREFIX: &str = "graalvm-community"; pub const CE_BUILDS_REPOSITORY: RepoRef = RepoRef { owner: "graalvm", name: "graalvm-ce-builds" }; @@ -41,7 +40,6 @@ pub struct GraalVM { /// Used to query GitHub about releases. pub client: Octocrab, pub graal_version: Version, - pub java_version: java::LanguageVersion, pub os: OS, pub arch: Arch, } @@ -54,17 +52,9 @@ impl Goodie for GraalVM { fn is_active(&self) -> BoxFuture<'static, Result> { let expected_graal_version = self.graal_version.clone(); - let expected_java_language_version = self.java_version; async move { let found_version = find_graal_version().await?; ensure!(found_version == expected_graal_version, "GraalVM version mismatch. Expected {expected_graal_version}, found {found_version}."); - - let found_java_version = Java.check_language_version().await?; - ensure!( - found_java_version == expected_java_language_version, - "Java language version mismatch. Expected {expected_java_language_version}, found {found_java_version}." - ); - Result::Ok(true) } .boxed() @@ -98,7 +88,7 @@ impl GraalVM { } pub fn platform_string(&self) -> String { - let Self { graal_version: _graal_version, java_version, arch, os, client: _client } = &self; + let Self { graal_version: _graal_version, arch, os, client: _client } = &self; let os_name = match *os { OS::Linux => "linux", OS::Windows => "windows", @@ -106,18 +96,16 @@ impl GraalVM { other_os => unimplemented!("System `{}` is not supported!", other_os), }; let arch_name = match *arch { - Arch::X86_64 => "amd64", - // No Graal packages for Apple Silicon. - Arch::AArch64 if TARGET_OS == OS::MacOS => "amd64", + Arch::X86_64 => "x64", Arch::AArch64 => "aarch64", other_arch => unimplemented!("Architecture `{}` is not supported!", other_arch), }; - let java_version = format!("java{}", java_version.0); - format!("{PACKAGE_PREFIX}-{java_version}-{os_name}-{arch_name}") + let java_version = format!("jdk-{}", _graal_version); + format!("{PACKAGE_PREFIX}-{java_version}_{os_name}-{arch_name}") } pub fn root_directory_name(&self) -> PathBuf { - PathBuf::from(format!("{}-{}-{}", PACKAGE_PREFIX, self.java_version, self.graal_version)) + PathBuf::from(format!("{}-{}", PACKAGE_PREFIX, self.graal_version)) } } @@ -137,6 +125,7 @@ pub fn locate_graal() -> Result { #[cfg(test)] mod tests { + use semver::{BuildMetadata, Prerelease}; use super::*; use crate::cache; use crate::log::setup_logging; @@ -147,12 +136,11 @@ mod tests { #[ignore] async fn test_is_enabled() -> Result { setup_logging()?; - let graal_version = Version::parse("22.3.1").unwrap(); - let java_version = java::LanguageVersion(17); + let graal_version = Version::parse("17.0.7").unwrap(); let os = TARGET_OS; let arch = Arch::X86_64; let client = Octocrab::default(); - let graalvm = GraalVM { graal_version, java_version, os, arch, client }; + let graalvm = GraalVM { graal_version, os, arch, client }; graalvm.install_if_missing(&cache::Cache::new_default().await?).await?; @@ -171,9 +159,30 @@ Java(TM) SE Runtime Environment Oracle GraalVM 17.0.7+8.1 (build 17.0.7+8-LTS-jv Java HotSpot(TM) 64-Bit Server VM Oracle GraalVM 17.0.7+8.1 (build 17.0.7+8-LTS-jvmci-23.0-b12, mixed mode, sharing)"; let found_graal = graal_version_from_version_string(version_string).unwrap(); - assert_eq!(found_graal, Version::new(23, 0, 0)); + let expected_graal_version = Version { + major: 17, + minor: 0, + patch: 7, + pre: Prerelease::EMPTY, + build: BuildMetadata::new("8.1").unwrap() + }; + assert_eq!(found_graal, expected_graal_version); let found_java = Java.parse_version(version_string).unwrap(); assert_eq!(found_java, Version::new(17, 0, 7)); } + + #[test] + fn recognize_oneline_version() { + let version_line = "Java(TM) SE Runtime Environment Oracle GraalVM 17.0.7+8.1 (build 17.0.7+8-LTS-jvmci-23.0-b12)"; + let graal_version = Version::find_in_text(version_line).unwrap(); + let expected_graal_version = Version { + major: 17, + minor: 0, + patch: 7, + pre: Prerelease::EMPTY, + build: BuildMetadata::new("8.1").unwrap() + }; + assert_eq!(graal_version, expected_graal_version); + } } diff --git a/build/ci_utils/src/programs/graal.rs b/build/ci_utils/src/programs/graal.rs index da91401e0613..be66b4c26fb0 100644 --- a/build/ci_utils/src/programs/graal.rs +++ b/build/ci_utils/src/programs/graal.rs @@ -111,9 +111,6 @@ pub enum ComponentId { NodeJs, /// Graal.Python Python, - /// FastR - #[strum(serialize = "R")] - R, /// TruffleRuby Ruby, #[strum(serialize = "visualvm")] @@ -121,6 +118,10 @@ pub enum ComponentId { VisualVm, /// GraalWasm Wasm, + #[strum(serialize = "icu4j")] + Icu4J, + Regex, + Jipher, #[strum(disabled)] Unrecognized(String), } diff --git a/build/ci_utils/src/programs/java.rs b/build/ci_utils/src/programs/java.rs index aae9e61abba0..cf30c56f66b8 100644 --- a/build/ci_utils/src/programs/java.rs +++ b/build/ci_utils/src/programs/java.rs @@ -87,6 +87,6 @@ impl std::str::FromStr for LanguageVersion { impl Display for LanguageVersion { fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { - write!(f, "java{}", self.0) + write!(f, "jdk{}", self.0) } } diff --git a/tools/ci/docker/Dockerfile b/tools/ci/docker/Dockerfile index 5761644fca74..7d69f0d88c5a 100644 --- a/tools/ci/docker/Dockerfile +++ b/tools/ci/docker/Dockerfile @@ -1,4 +1,4 @@ -FROM ghcr.io/graalvm/graalvm-ce:ol9-java17-22.3.1 +FROM ghcr.io/graalvm/graalvm-community:17.0.7 USER root From cba65de7c8d70a73126f6bc0126a8c9b7d7d33b8 Mon Sep 17 00:00:00 2001 From: Pavel Marek Date: Mon, 3 Jul 2023 11:43:22 +0200 Subject: [PATCH 04/51] Do not use @CachedLibrary parameter in method behind TruffleBoundary --- .../runtime/data/hash/EnsoHashMap.java | 27 +++++++++++-------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/engine/runtime/src/main/java/org/enso/interpreter/runtime/data/hash/EnsoHashMap.java b/engine/runtime/src/main/java/org/enso/interpreter/runtime/data/hash/EnsoHashMap.java index 6c768e448b48..acd054d1e70f 100644 --- a/engine/runtime/src/main/java/org/enso/interpreter/runtime/data/hash/EnsoHashMap.java +++ b/engine/runtime/src/main/java/org/enso/interpreter/runtime/data/hash/EnsoHashMap.java @@ -166,14 +166,25 @@ Type getMetaObject(@CachedLibrary("this") InteropLibrary thisLib) { @ExportMessage @TruffleBoundary Object toDisplayString( - boolean allowSideEffects, @CachedLibrary(limit = "5") InteropLibrary interop) { + boolean allowSideEffects) { + return toString(true); + } + + @Override + public String toString() { + // We are not using uncached InteropLibrary in this method, as it may substantially + // slow down Java debugger. + return toString(false); + } + + private String toString(boolean useInterop) { var sb = new StringBuilder(); sb.append("{"); boolean empty = true; for (StorageEntry entry : mapBuilder.getStorage().getValues()) { if (isEntryInThisMap(entry)) { empty = false; - sb.append(entryToString(entry, interop)).append(", "); + sb.append(entryToString(entry, useInterop)).append(", "); } } if (!empty) { @@ -184,17 +195,11 @@ Object toDisplayString( return sb.toString(); } - @Override - public String toString() { - // We are not using uncached InteropLibrary in this method, as it may substantially - // slow down Java debugger. - return (String) toDisplayString(true, null); - } - - private static String entryToString(StorageEntry entry, InteropLibrary interop) { + private static String entryToString(StorageEntry entry, boolean useInterop) { String keyStr; String valStr; - if (interop != null) { + if (useInterop) { + var interop = InteropLibrary.getUncached(); try { keyStr = interop.asString(interop.toDisplayString(entry.key())); valStr = interop.asString(interop.toDisplayString(entry.value())); From 5b55b63526616d091288950dbfa3f18046ae1eb9 Mon Sep 17 00:00:00 2001 From: Pavel Marek Date: Mon, 3 Jul 2023 12:21:08 +0200 Subject: [PATCH 05/51] Add .idea dir to gitignore in tools/enso4igv --- tools/enso4igv/.gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/enso4igv/.gitignore b/tools/enso4igv/.gitignore index b7afd66f44e6..323f71b0f9e8 100644 --- a/tools/enso4igv/.gitignore +++ b/tools/enso4igv/.gitignore @@ -1,2 +1,4 @@ *.vsix nbcode +!.idea +.idea/* From c8d90916694bf6df4147204649352e4098278669 Mon Sep 17 00:00:00 2001 From: Pavel Marek Date: Mon, 3 Jul 2023 13:17:53 +0200 Subject: [PATCH 06/51] Improve .gitignore So that run git-clean does not remove .vscode directory --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index e58dc78cb62a..e8acf96118fa 100644 --- a/.gitignore +++ b/.gitignore @@ -60,7 +60,8 @@ node_modules/ !.idea .idea/* !.idea/runConfigurations/ -.vscode/ +!.vscode +.vscode/* .metals/ *.swp .projections.json From e8bb86d813335bf4917a8ee14fc119ab72a1adb6 Mon Sep 17 00:00:00 2001 From: Pavel Marek Date: Mon, 3 Jul 2023 18:32:34 +0200 Subject: [PATCH 07/51] Fix gu program find --- build/build/src/lib.rs | 6 ----- build/ci_utils/src/cache/goodie/graalvm.rs | 29 ++++++++++++---------- build/ci_utils/src/env.rs | 3 +++ build/ci_utils/src/programs/graal.rs | 1 - 4 files changed, 19 insertions(+), 20 deletions(-) diff --git a/build/build/src/lib.rs b/build/build/src/lib.rs index 5cea94cf1df4..282384c50b0a 100644 --- a/build/build/src/lib.rs +++ b/build/build/src/lib.rs @@ -36,7 +36,6 @@ extern crate core; use crate::prelude::*; use anyhow::Context; -use ide_ci::programs::java; use regex::Regex; @@ -106,11 +105,6 @@ pub fn get_graal_version(build_sbt_contents: &str) -> Result { get_string_assignment_value(build_sbt_contents, "graalVersion")?.parse2() } -/// Get version of Enso from the `build.sbt` file contents. -pub fn get_java_major_version(build_sbt_contents: &str) -> Result { - get_string_assignment_value(build_sbt_contents, "javaVersion")?.parse2() -} - #[cfg(test)] mod tests { use super::*; diff --git a/build/ci_utils/src/cache/goodie/graalvm.rs b/build/ci_utils/src/cache/goodie/graalvm.rs index 6983347431cb..90e81008e1b4 100644 --- a/build/ci_utils/src/cache/goodie/graalvm.rs +++ b/build/ci_utils/src/cache/goodie/graalvm.rs @@ -10,7 +10,8 @@ use crate::programs::Java; -const PACKAGE_PREFIX: &str = "graalvm-community"; +const PACKAGE_PREFIX_URL: &str = "graalvm-community"; +const PACKAGE_PREFIX_UNZIPPED: &str = "graalvm-community-openjdk"; pub const CE_BUILDS_REPOSITORY: RepoRef = RepoRef { owner: "graalvm", name: "graalvm-ce-builds" }; @@ -23,7 +24,7 @@ crate::define_env_var! { } pub fn graal_version_from_version_string(version_string: &str) -> Result { - let line = version_string.lines().find(|line| line.contains("GraalVM")).context( + let line = version_string.lines().find(|line| line.contains("GraalVM CE")).context( "There is a Java environment available but it is not recognizable as GraalVM one.", )?; Version::find_in_text(line) @@ -78,10 +79,11 @@ impl GraalVM { pub fn url(&self) -> BoxFuture<'static, Result> { let platform_string = self.platform_string(); let graal_version = self.graal_version.clone(); + let graal_version_tag = format!("{}.{}.{}", graal_version.major, graal_version.minor, graal_version.patch); let client = self.client.clone(); async move { let repo = CE_BUILDS_REPOSITORY.handle(&client); - let release = repo.find_release_by_text(&graal_version.to_string()).await?; + let release = repo.find_release_by_text(&graal_version_tag).await?; crate::github::find_asset_url_by_text(&release, &platform_string).cloned() } .boxed() @@ -100,12 +102,13 @@ impl GraalVM { Arch::AArch64 => "aarch64", other_arch => unimplemented!("Architecture `{}` is not supported!", other_arch), }; - let java_version = format!("jdk-{}", _graal_version); - format!("{PACKAGE_PREFIX}-{java_version}_{os_name}-{arch_name}") + let java_version = format!("jdk-{}.{}.{}", _graal_version.major, _graal_version.minor, _graal_version.patch); + format!("{PACKAGE_PREFIX_URL}-{java_version}_{os_name}-{arch_name}") } pub fn root_directory_name(&self) -> PathBuf { - PathBuf::from(format!("{}-{}", PACKAGE_PREFIX, self.graal_version)) + let jdk_version = format!("{}.{}.{}+{}", self.graal_version.major, self.graal_version.minor, self.graal_version.patch, self.graal_version.build); + PathBuf::from(format!("{}-{}", PACKAGE_PREFIX_UNZIPPED, jdk_version)) } } @@ -136,7 +139,7 @@ mod tests { #[ignore] async fn test_is_enabled() -> Result { setup_logging()?; - let graal_version = Version::parse("17.0.7").unwrap(); + let graal_version = Version::parse("17.0.7+7.1").unwrap(); let os = TARGET_OS; let arch = Arch::X86_64; let client = Octocrab::default(); @@ -154,9 +157,9 @@ mod tests { /// Check that we correctly recognize both the GraalVM version and the Java version. #[test] fn version_recognize() { - let version_string = "java version \"17.0.7\" 2023-04-18 LTS -Java(TM) SE Runtime Environment Oracle GraalVM 17.0.7+8.1 (build 17.0.7+8-LTS-jvmci-23.0-b12) -Java HotSpot(TM) 64-Bit Server VM Oracle GraalVM 17.0.7+8.1 (build 17.0.7+8-LTS-jvmci-23.0-b12, mixed mode, sharing)"; + let version_string = "openjdk version \"17.0.7\" 2023-04-18 +OpenJDK Runtime Environment GraalVM CE 17.0.7+7.1 (build 17.0.7+7-jvmci-23.0-b12) +OpenJDK 64-Bit Server VM GraalVM CE 17.0.7+7.1 (build 17.0.7+7-jvmci-23.0-b12, mixed mode, sharing)"; let found_graal = graal_version_from_version_string(version_string).unwrap(); let expected_graal_version = Version { @@ -164,7 +167,7 @@ Java HotSpot(TM) 64-Bit Server VM Oracle GraalVM 17.0.7+8.1 (build 17.0.7+8-LTS- minor: 0, patch: 7, pre: Prerelease::EMPTY, - build: BuildMetadata::new("8.1").unwrap() + build: BuildMetadata::new("7.1").unwrap() }; assert_eq!(found_graal, expected_graal_version); @@ -174,14 +177,14 @@ Java HotSpot(TM) 64-Bit Server VM Oracle GraalVM 17.0.7+8.1 (build 17.0.7+8-LTS- #[test] fn recognize_oneline_version() { - let version_line = "Java(TM) SE Runtime Environment Oracle GraalVM 17.0.7+8.1 (build 17.0.7+8-LTS-jvmci-23.0-b12)"; + let version_line = "OpenJDK Runtime Environment GraalVM CE 17.0.7+7.1 (build 17.0.7+7-jvmci-23.0-b12)"; let graal_version = Version::find_in_text(version_line).unwrap(); let expected_graal_version = Version { major: 17, minor: 0, patch: 7, pre: Prerelease::EMPTY, - build: BuildMetadata::new("8.1").unwrap() + build: BuildMetadata::new("7.1").unwrap() }; assert_eq!(graal_version, expected_graal_version); } diff --git a/build/ci_utils/src/env.rs b/build/ci_utils/src/env.rs index 6f60f3a4f934..5dea648c3878 100644 --- a/build/ci_utils/src/env.rs +++ b/build/ci_utils/src/env.rs @@ -182,6 +182,9 @@ impl Modification { "Prepending to {} the following paths: {:?}", self.variable_name, paths_to_prepend ); + for path in paths_to_prepend { + assert!(path.exists()); + } let new_paths_set = paths_to_prepend.iter().collect::>(); let old_paths = std::env::split_paths(&old_value).collect_vec(); diff --git a/build/ci_utils/src/programs/graal.rs b/build/ci_utils/src/programs/graal.rs index be66b4c26fb0..fefea8164dca 100644 --- a/build/ci_utils/src/programs/graal.rs +++ b/build/ci_utils/src/programs/graal.rs @@ -4,7 +4,6 @@ use serde::Deserializer; use serde::Serializer; - /// GraalVM Updater, `gu`, is a command-line tool for installing and managing optional GraalVM /// language runtimes and utilities. #[derive(Clone, Copy, Debug, Default)] From efe8afe779f9b43d53d76e30dd5aeff529ae670d Mon Sep 17 00:00:00 2001 From: Pavel Marek Date: Tue, 4 Jul 2023 12:30:40 +0200 Subject: [PATCH 08/51] GraalVM root directory name includes the build metadata identifier --- build.sbt | 9 +++++---- build/ci_utils/src/cache/goodie/graalvm.rs | 15 +++++++++++++++ 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/build.sbt b/build.sbt index 392115103304..292a23584c8c 100644 --- a/build.sbt +++ b/build.sbt @@ -20,11 +20,12 @@ import java.io.File // ============================================================================ val scalacVersion = "2.13.11" -// Since the release of GraalVM 23.0.0, the versioning is the same for Graal and Java -val graalVersion = "17.0.7" -// Verwsion used for the Graal/Truffle related Maven packages +// Since the release of GraalVM 23.0.0, the versioning is the same for Graal and OpenJDK. +// Note that it is important to keep the build metadata (the part after +) in this version. +val graalVersion = "17.0.7+7.1" +// Version used for the Graal/Truffle related Maven packages val graalMavenVersion = "23.0.0" -val javaLangVersion = "17" +val javaLangVersion = graalVersion.split("\\.")(0) val defaultDevEnsoVersion = "0.0.0-dev" val ensoVersion = sys.env.getOrElse( "ENSO_VERSION", diff --git a/build/ci_utils/src/cache/goodie/graalvm.rs b/build/ci_utils/src/cache/goodie/graalvm.rs index 90e81008e1b4..f2cda4926b1e 100644 --- a/build/ci_utils/src/cache/goodie/graalvm.rs +++ b/build/ci_utils/src/cache/goodie/graalvm.rs @@ -107,6 +107,7 @@ impl GraalVM { } pub fn root_directory_name(&self) -> PathBuf { + assert!(!self.graal_version.build.is_empty()); let jdk_version = format!("{}.{}.{}+{}", self.graal_version.major, self.graal_version.minor, self.graal_version.patch, self.graal_version.build); PathBuf::from(format!("{}-{}", PACKAGE_PREFIX_UNZIPPED, jdk_version)) } @@ -188,4 +189,18 @@ OpenJDK 64-Bit Server VM GraalVM CE 17.0.7+7.1 (build 17.0.7+7-jvmci-23.0-b12, m }; assert_eq!(graal_version, expected_graal_version); } + + #[test] + fn version_to_string() { + let version_with_build_metadata = Version { + major: 17, + minor: 0, + patch: 7, + pre: Prerelease::EMPTY, + build: BuildMetadata::new("7.1").unwrap() + }; + let version_str = format!("{}.{}.{}+{}", version_with_build_metadata.major, version_with_build_metadata.minor, + version_with_build_metadata.patch, version_with_build_metadata.build); + assert_eq!(version_str, "17.0.7+7.1"); + } } From 01b0577d2e7be094af0cee1c9248d1e29535a38c Mon Sep 17 00:00:00 2001 From: Pavel Marek Date: Tue, 4 Jul 2023 13:59:05 +0200 Subject: [PATCH 09/51] Fix native image build of engine-runner --- build.sbt | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/build.sbt b/build.sbt index 292a23584c8c..5e24386dda2c 100644 --- a/build.sbt +++ b/build.sbt @@ -1609,7 +1609,7 @@ lazy val `engine-runner` = project // "-g", // "-H:+DashboardAll", // "-H:DashboardDump=runner.bgv" - "-Dnic=nic" + "-Dnic=nic", ), mainClass = Option("org.enso.runner.Main"), cp = Option("runtime.jar"), @@ -1619,7 +1619,14 @@ lazy val `engine-runner` = project "org.jline.nativ.JLineLibrary", "io.methvin.watchservice.jna.CarbonAPI", "org.enso.syntax2.Parser", - "zio.internal.ZScheduler$$anon$4" + "org.enso.loggingservice", + "zio.internal.ZScheduler$$anon$4", + "sun.awt", + "sun.java2d", + "sun.font", + "java.awt", + "com.sun.imageio", + "akka.http" ) ) .dependsOn(installNativeImage) From ef99bea12d2383890884cf1157a1e70767e9a725 Mon Sep 17 00:00:00 2001 From: Pavel Marek Date: Tue, 4 Jul 2023 16:41:29 +0200 Subject: [PATCH 10/51] Remove deprecations --- .../run-enso-build-cli-native.xml | 22 +++++++------------ .../AvoidIdInstrumentationTagTest.java | 3 ++- .../WarningInstrumentationTest.java | 4 +++- .../interpreter/test/InsightForEnsoTest.java | 3 ++- .../VerifyJavaScriptIsAvailableTest.java | 3 ++- .../semantic/ArrayProxyBenchmarks.java | 3 ++- .../semantic/CurriedFunctionBenchmarks.java | 3 ++- .../benchmarks/semantic/EqualsBenchmarks.java | 3 ++- .../semantic/IfVsCaseBenchmarks.java | 3 ++- .../benchmarks/semantic/ListBenchmarks.java | 3 ++- .../NestedPatternCompilationBenchmarks.java | 3 ++- .../benchmarks/semantic/SieveBenchmarks.java | 3 ++- .../benchmarks/semantic/StringBenchmarks.java | 3 ++- .../semantic/TypePatternBenchmarks.java | 3 ++- .../benchmarks/semantic/VectorBenchmarks.java | 3 ++- .../org/enso/compiler/ExecCompilerTest.java | 3 ++- .../org/enso/compiler/SerdeCompilerTest.java | 3 ++- .../org/enso/compiler/SerializerTest.java | 3 ++- .../runtime/ModuleSourcesTest.java | 3 ++- .../enso/interpreter/runtime/ModuleTest.java | 3 ++- .../interpreter/test/DebuggingEnsoTest.java | 3 ++- .../org/enso/interpreter/test/TestBase.java | 3 ++- 22 files changed, 51 insertions(+), 35 deletions(-) diff --git a/.idea/runConfigurations/run-enso-build-cli-native.xml b/.idea/runConfigurations/run-enso-build-cli-native.xml index ddb8a1b4aa80..4a8a188d3e29 100644 --- a/.idea/runConfigurations/run-enso-build-cli-native.xml +++ b/.idea/runConfigurations/run-enso-build-cli-native.xml @@ -1,27 +1,21 @@ - - - - \ No newline at end of file diff --git a/engine/runtime-with-instruments/src/test/java/org/enso/interpreter/test/instrument/AvoidIdInstrumentationTagTest.java b/engine/runtime-with-instruments/src/test/java/org/enso/interpreter/test/instrument/AvoidIdInstrumentationTagTest.java index f55629de28be..1c9eee06e48c 100644 --- a/engine/runtime-with-instruments/src/test/java/org/enso/interpreter/test/instrument/AvoidIdInstrumentationTagTest.java +++ b/engine/runtime-with-instruments/src/test/java/org/enso/interpreter/test/instrument/AvoidIdInstrumentationTagTest.java @@ -15,6 +15,7 @@ import org.graalvm.polyglot.Context; import org.graalvm.polyglot.Language; import org.graalvm.polyglot.Source; +import org.graalvm.polyglot.io.IOAccess; import org.junit.After; import org.junit.Assert; import static org.junit.Assert.assertEquals; @@ -39,7 +40,7 @@ public void initContext() { ) .logHandler(OutputStream.nullOutputStream()) .allowExperimentalOptions(true) - .allowIO(true) + .allowIO(IOAccess.ALL) .allowAllAccess(true) .build(); diff --git a/engine/runtime-with-instruments/src/test/java/org/enso/interpreter/test/instrument/WarningInstrumentationTest.java b/engine/runtime-with-instruments/src/test/java/org/enso/interpreter/test/instrument/WarningInstrumentationTest.java index cf0003e35f44..16b508802ce3 100644 --- a/engine/runtime-with-instruments/src/test/java/org/enso/interpreter/test/instrument/WarningInstrumentationTest.java +++ b/engine/runtime-with-instruments/src/test/java/org/enso/interpreter/test/instrument/WarningInstrumentationTest.java @@ -11,6 +11,8 @@ import org.graalvm.polyglot.Language; import org.graalvm.polyglot.Source; import static org.junit.Assert.assertEquals; + +import org.graalvm.polyglot.io.IOAccess; import org.junit.After; import org.junit.Assert; import org.junit.Before; @@ -35,7 +37,7 @@ public void initContext() { ) .logHandler(OutputStream.nullOutputStream()) .allowExperimentalOptions(true) - .allowIO(true) + .allowIO(IOAccess.ALL) .allowAllAccess(true) .build(); diff --git a/engine/runtime-with-polyglot/src/test/java/org/enso/interpreter/test/InsightForEnsoTest.java b/engine/runtime-with-polyglot/src/test/java/org/enso/interpreter/test/InsightForEnsoTest.java index ec65ebf0d141..9517f1b19603 100644 --- a/engine/runtime-with-polyglot/src/test/java/org/enso/interpreter/test/InsightForEnsoTest.java +++ b/engine/runtime-with-polyglot/src/test/java/org/enso/interpreter/test/InsightForEnsoTest.java @@ -9,6 +9,7 @@ import org.graalvm.polyglot.Context; import org.graalvm.polyglot.Language; import org.graalvm.polyglot.Source; +import org.graalvm.polyglot.io.IOAccess; import org.junit.After; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotEquals; @@ -31,7 +32,7 @@ public void initContext() throws Exception { ) .logHandler(OutputStream.nullOutputStream()) .allowExperimentalOptions(true) - .allowIO(true) + .allowIO(IOAccess.ALL) .out(out) .allowAllAccess(true) .build(); diff --git a/engine/runtime-with-polyglot/src/test/java/org/enso/interpreter/test/instrument/VerifyJavaScriptIsAvailableTest.java b/engine/runtime-with-polyglot/src/test/java/org/enso/interpreter/test/instrument/VerifyJavaScriptIsAvailableTest.java index b9b811c9ed76..d9caa382207a 100644 --- a/engine/runtime-with-polyglot/src/test/java/org/enso/interpreter/test/instrument/VerifyJavaScriptIsAvailableTest.java +++ b/engine/runtime-with-polyglot/src/test/java/org/enso/interpreter/test/instrument/VerifyJavaScriptIsAvailableTest.java @@ -6,6 +6,7 @@ import java.nio.file.Paths; import org.enso.polyglot.RuntimeOptions; import org.graalvm.polyglot.Context; +import org.graalvm.polyglot.io.IOAccess; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; @@ -20,7 +21,7 @@ public static void initEnsoContext() { ctx = Context.newBuilder() .allowExperimentalOptions(true) - .allowIO(true) + .allowIO(IOAccess.ALL) .option(RuntimeOptions.PREINITIALIZE, "js") .option( RuntimeOptions.LANGUAGE_HOME_OVERRIDE, diff --git a/engine/runtime/src/bench/java/org/enso/interpreter/bench/benchmarks/semantic/ArrayProxyBenchmarks.java b/engine/runtime/src/bench/java/org/enso/interpreter/bench/benchmarks/semantic/ArrayProxyBenchmarks.java index a74fc1b8ff2a..e81288ee03c4 100644 --- a/engine/runtime/src/bench/java/org/enso/interpreter/bench/benchmarks/semantic/ArrayProxyBenchmarks.java +++ b/engine/runtime/src/bench/java/org/enso/interpreter/bench/benchmarks/semantic/ArrayProxyBenchmarks.java @@ -7,6 +7,7 @@ import org.graalvm.polyglot.Context; import org.graalvm.polyglot.Engine; import org.graalvm.polyglot.Value; +import org.graalvm.polyglot.io.IOAccess; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.infra.BenchmarkParams; import org.openjdk.jmh.infra.Blackhole; @@ -39,7 +40,7 @@ public void initializeBenchmark(BenchmarkParams params) throws Exception { "enso.languageHomeOverride", Paths.get("../../distribution/component").toFile().getAbsolutePath()) .build(); - var ctx = Context.newBuilder().engine(eng).allowIO(true).allowAllAccess(true).build(); + var ctx = Context.newBuilder().engine(eng).allowIO(IOAccess.ALL).allowAllAccess(true).build(); var code = """ import Standard.Base.Data.Vector.Vector import Standard.Base.Data.Array_Proxy.Array_Proxy diff --git a/engine/runtime/src/bench/java/org/enso/interpreter/bench/benchmarks/semantic/CurriedFunctionBenchmarks.java b/engine/runtime/src/bench/java/org/enso/interpreter/bench/benchmarks/semantic/CurriedFunctionBenchmarks.java index bdb9c4824f2d..b181a2e425dc 100644 --- a/engine/runtime/src/bench/java/org/enso/interpreter/bench/benchmarks/semantic/CurriedFunctionBenchmarks.java +++ b/engine/runtime/src/bench/java/org/enso/interpreter/bench/benchmarks/semantic/CurriedFunctionBenchmarks.java @@ -6,6 +6,7 @@ import java.util.function.Function; import org.graalvm.polyglot.Context; import org.graalvm.polyglot.Value; +import org.graalvm.polyglot.io.IOAccess; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; @@ -35,7 +36,7 @@ public void initializeBenchmark(BenchmarkParams params) throws Exception { var ctx = Context.newBuilder() .allowExperimentalOptions(true) .logHandler(new ByteArrayOutputStream()) - .allowIO(true) + .allowIO(IOAccess.ALL) .allowAllAccess(true) .option( "enso.languageHomeOverride", diff --git a/engine/runtime/src/bench/java/org/enso/interpreter/bench/benchmarks/semantic/EqualsBenchmarks.java b/engine/runtime/src/bench/java/org/enso/interpreter/bench/benchmarks/semantic/EqualsBenchmarks.java index 10eb026eb964..8211724eba35 100644 --- a/engine/runtime/src/bench/java/org/enso/interpreter/bench/benchmarks/semantic/EqualsBenchmarks.java +++ b/engine/runtime/src/bench/java/org/enso/interpreter/bench/benchmarks/semantic/EqualsBenchmarks.java @@ -12,6 +12,7 @@ import org.enso.polyglot.MethodNames.Module; import org.graalvm.polyglot.Context; import org.graalvm.polyglot.Value; +import org.graalvm.polyglot.io.IOAccess; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; @@ -61,7 +62,7 @@ public void initializeBenchmark(BenchmarkParams params) throws Exception { var ctx = Context.newBuilder() .allowExperimentalOptions(true) .logHandler(new ByteArrayOutputStream()) - .allowIO(true) + .allowIO(IOAccess.ALL) .allowAllAccess(true) .option( "enso.languageHomeOverride", diff --git a/engine/runtime/src/bench/java/org/enso/interpreter/bench/benchmarks/semantic/IfVsCaseBenchmarks.java b/engine/runtime/src/bench/java/org/enso/interpreter/bench/benchmarks/semantic/IfVsCaseBenchmarks.java index ac938e7d825b..b1938c0dbdc6 100644 --- a/engine/runtime/src/bench/java/org/enso/interpreter/bench/benchmarks/semantic/IfVsCaseBenchmarks.java +++ b/engine/runtime/src/bench/java/org/enso/interpreter/bench/benchmarks/semantic/IfVsCaseBenchmarks.java @@ -15,6 +15,7 @@ import org.graalvm.polyglot.Context; import org.graalvm.polyglot.Source; import org.graalvm.polyglot.Value; +import org.graalvm.polyglot.io.IOAccess; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; @@ -53,7 +54,7 @@ public void initializeBench(BenchmarkParams params) throws IOException { .logHandler(out) .out(out) .err(out) - .allowIO(true) + .allowIO(IOAccess.ALL) .allowExperimentalOptions(true) .option( "enso.languageHomeOverride", diff --git a/engine/runtime/src/bench/java/org/enso/interpreter/bench/benchmarks/semantic/ListBenchmarks.java b/engine/runtime/src/bench/java/org/enso/interpreter/bench/benchmarks/semantic/ListBenchmarks.java index c9db1bc92550..582e6ad30a99 100644 --- a/engine/runtime/src/bench/java/org/enso/interpreter/bench/benchmarks/semantic/ListBenchmarks.java +++ b/engine/runtime/src/bench/java/org/enso/interpreter/bench/benchmarks/semantic/ListBenchmarks.java @@ -6,6 +6,7 @@ import java.util.function.Function; import org.graalvm.polyglot.Context; import org.graalvm.polyglot.Value; +import org.graalvm.polyglot.io.IOAccess; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; @@ -38,7 +39,7 @@ public class ListBenchmarks { public void initializeBenchmark(BenchmarkParams params) throws Exception { var ctx = Context.newBuilder() .allowExperimentalOptions(true) - .allowIO(true) + .allowIO(IOAccess.ALL) .allowAllAccess(true) .logHandler(new ByteArrayOutputStream()) .option( diff --git a/engine/runtime/src/bench/java/org/enso/interpreter/bench/benchmarks/semantic/NestedPatternCompilationBenchmarks.java b/engine/runtime/src/bench/java/org/enso/interpreter/bench/benchmarks/semantic/NestedPatternCompilationBenchmarks.java index 0cb7b76ecb64..ee5e914cb1e2 100644 --- a/engine/runtime/src/bench/java/org/enso/interpreter/bench/benchmarks/semantic/NestedPatternCompilationBenchmarks.java +++ b/engine/runtime/src/bench/java/org/enso/interpreter/bench/benchmarks/semantic/NestedPatternCompilationBenchmarks.java @@ -8,6 +8,7 @@ import java.util.function.Function; import org.graalvm.polyglot.Context; import org.graalvm.polyglot.Value; +import org.graalvm.polyglot.io.IOAccess; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; @@ -38,7 +39,7 @@ public class NestedPatternCompilationBenchmarks { public void initializeBenchmark(BenchmarkParams params) throws Exception { ctx = Context.newBuilder() .allowExperimentalOptions(true) - .allowIO(true) + .allowIO(IOAccess.ALL) .allowAllAccess(true) .logHandler(new ByteArrayOutputStream()) .option( diff --git a/engine/runtime/src/bench/java/org/enso/interpreter/bench/benchmarks/semantic/SieveBenchmarks.java b/engine/runtime/src/bench/java/org/enso/interpreter/bench/benchmarks/semantic/SieveBenchmarks.java index 1c8f2d897b4d..5ab3175fd777 100644 --- a/engine/runtime/src/bench/java/org/enso/interpreter/bench/benchmarks/semantic/SieveBenchmarks.java +++ b/engine/runtime/src/bench/java/org/enso/interpreter/bench/benchmarks/semantic/SieveBenchmarks.java @@ -5,6 +5,7 @@ import java.util.concurrent.TimeUnit; import org.graalvm.polyglot.Context; import org.graalvm.polyglot.Value; +import org.graalvm.polyglot.io.IOAccess; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; @@ -32,7 +33,7 @@ public class SieveBenchmarks { public void initializeBenchmark(BenchmarkParams params) throws Exception { var ctx = Context.newBuilder() .allowExperimentalOptions(true) - .allowIO(true) + .allowIO(IOAccess.ALL) .allowAllAccess(true) .logHandler(new ByteArrayOutputStream()) .option( diff --git a/engine/runtime/src/bench/java/org/enso/interpreter/bench/benchmarks/semantic/StringBenchmarks.java b/engine/runtime/src/bench/java/org/enso/interpreter/bench/benchmarks/semantic/StringBenchmarks.java index 77c2b3fa30a2..40046af9e879 100644 --- a/engine/runtime/src/bench/java/org/enso/interpreter/bench/benchmarks/semantic/StringBenchmarks.java +++ b/engine/runtime/src/bench/java/org/enso/interpreter/bench/benchmarks/semantic/StringBenchmarks.java @@ -6,6 +6,7 @@ import java.util.function.Function; import org.graalvm.polyglot.Context; import org.graalvm.polyglot.Value; +import org.graalvm.polyglot.io.IOAccess; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; @@ -35,7 +36,7 @@ public class StringBenchmarks { public void initializeBenchmark(BenchmarkParams params) throws Exception { var ctx = Context.newBuilder() .allowExperimentalOptions(true) - .allowIO(true) + .allowIO(IOAccess.ALL) .allowAllAccess(true) .logHandler(new ByteArrayOutputStream()) .option( diff --git a/engine/runtime/src/bench/java/org/enso/interpreter/bench/benchmarks/semantic/TypePatternBenchmarks.java b/engine/runtime/src/bench/java/org/enso/interpreter/bench/benchmarks/semantic/TypePatternBenchmarks.java index d7ec93fee7a8..dfafd9529d91 100644 --- a/engine/runtime/src/bench/java/org/enso/interpreter/bench/benchmarks/semantic/TypePatternBenchmarks.java +++ b/engine/runtime/src/bench/java/org/enso/interpreter/bench/benchmarks/semantic/TypePatternBenchmarks.java @@ -3,6 +3,7 @@ import org.enso.polyglot.MethodNames.Module; import org.graalvm.polyglot.Context; import org.graalvm.polyglot.Value; +import org.graalvm.polyglot.io.IOAccess; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.infra.BenchmarkParams; import org.openjdk.jmh.infra.Blackhole; @@ -28,7 +29,7 @@ public class TypePatternBenchmarks { public void initializeBenchmark(BenchmarkParams params) throws Exception { var ctx = Context.newBuilder() .allowExperimentalOptions(true) - .allowIO(true) + .allowIO(IOAccess.ALL) .allowAllAccess(true) .logHandler(new ByteArrayOutputStream()) .option( diff --git a/engine/runtime/src/bench/java/org/enso/interpreter/bench/benchmarks/semantic/VectorBenchmarks.java b/engine/runtime/src/bench/java/org/enso/interpreter/bench/benchmarks/semantic/VectorBenchmarks.java index ae62b8b0b163..db62ab652f23 100644 --- a/engine/runtime/src/bench/java/org/enso/interpreter/bench/benchmarks/semantic/VectorBenchmarks.java +++ b/engine/runtime/src/bench/java/org/enso/interpreter/bench/benchmarks/semantic/VectorBenchmarks.java @@ -7,6 +7,7 @@ import java.util.function.Function; import org.graalvm.polyglot.Context; import org.graalvm.polyglot.Value; +import org.graalvm.polyglot.io.IOAccess; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; @@ -36,7 +37,7 @@ public class VectorBenchmarks { public void initializeBenchmark(BenchmarkParams params) throws Exception { var ctx = Context.newBuilder() .allowExperimentalOptions(true) - .allowIO(true) + .allowIO(IOAccess.ALL) .allowAllAccess(true) .logHandler(new ByteArrayOutputStream()) .option( diff --git a/engine/runtime/src/test/java/org/enso/compiler/ExecCompilerTest.java b/engine/runtime/src/test/java/org/enso/compiler/ExecCompilerTest.java index 85fd720aee79..8b5a5e0af2b1 100644 --- a/engine/runtime/src/test/java/org/enso/compiler/ExecCompilerTest.java +++ b/engine/runtime/src/test/java/org/enso/compiler/ExecCompilerTest.java @@ -5,6 +5,7 @@ import org.enso.polyglot.RuntimeOptions; import org.graalvm.polyglot.Context; import org.graalvm.polyglot.PolyglotException; +import org.graalvm.polyglot.io.IOAccess; import org.junit.AfterClass; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; @@ -20,7 +21,7 @@ public class ExecCompilerTest { public static void initEnsoContext() { ctx = Context.newBuilder() .allowExperimentalOptions(true) - .allowIO(true) + .allowIO(IOAccess.ALL) .option( RuntimeOptions.LANGUAGE_HOME_OVERRIDE, Paths.get("../../distribution/component").toFile().getAbsolutePath() diff --git a/engine/runtime/src/test/java/org/enso/compiler/SerdeCompilerTest.java b/engine/runtime/src/test/java/org/enso/compiler/SerdeCompilerTest.java index 00f22b81b0d5..65816025914b 100644 --- a/engine/runtime/src/test/java/org/enso/compiler/SerdeCompilerTest.java +++ b/engine/runtime/src/test/java/org/enso/compiler/SerdeCompilerTest.java @@ -23,6 +23,7 @@ import org.enso.polyglot.MethodNames; import org.enso.polyglot.RuntimeOptions; import org.graalvm.polyglot.Context; +import org.graalvm.polyglot.io.IOAccess; import org.junit.Test; public class SerdeCompilerTest { @@ -109,7 +110,7 @@ private Context ensoContextForPackage(String name, File pkgFile, boolean disable Context ctx = Context.newBuilder() .allowExperimentalOptions(true) - .allowIO(true) + .allowIO(IOAccess.ALL) .option(RuntimeOptions.PROJECT_ROOT, pkgFile.getAbsolutePath()) .option(RuntimeOptions.DISABLE_IR_CACHES, "" + disableIrCaching) .option( diff --git a/engine/runtime/src/test/java/org/enso/compiler/SerializerTest.java b/engine/runtime/src/test/java/org/enso/compiler/SerializerTest.java index b961d804f102..badac510af6c 100644 --- a/engine/runtime/src/test/java/org/enso/compiler/SerializerTest.java +++ b/engine/runtime/src/test/java/org/enso/compiler/SerializerTest.java @@ -14,6 +14,7 @@ import org.enso.polyglot.MethodNames; import org.enso.polyglot.RuntimeOptions; import org.graalvm.polyglot.Context; +import org.graalvm.polyglot.io.IOAccess; import org.junit.Test; public class SerializerTest { @@ -21,7 +22,7 @@ public Context ensoContextForPackage(String name, File pkgFile) throws IOExcepti Context ctx = Context.newBuilder() .allowExperimentalOptions(true) - .allowIO(true) + .allowIO(IOAccess.ALL) .option(RuntimeOptions.PROJECT_ROOT, pkgFile.getAbsolutePath()) .option( RuntimeOptions.LANGUAGE_HOME_OVERRIDE, diff --git a/engine/runtime/src/test/java/org/enso/interpreter/runtime/ModuleSourcesTest.java b/engine/runtime/src/test/java/org/enso/interpreter/runtime/ModuleSourcesTest.java index da1ef323a42f..d16286863355 100644 --- a/engine/runtime/src/test/java/org/enso/interpreter/runtime/ModuleSourcesTest.java +++ b/engine/runtime/src/test/java/org/enso/interpreter/runtime/ModuleSourcesTest.java @@ -12,6 +12,7 @@ import org.enso.text.buffer.Rope$; import org.graalvm.polyglot.Context; import org.graalvm.polyglot.Engine; +import org.graalvm.polyglot.io.IOAccess; import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -33,7 +34,7 @@ public void prepareTest() throws IOException { RuntimeOptions.LANGUAGE_HOME_OVERRIDE, Paths.get("../../distribution/component").toFile().getAbsolutePath()) .build(); - this.ctx = Context.newBuilder().engine(eng).allowIO(true).allowAllAccess(true).build(); + this.ctx = Context.newBuilder().engine(eng).allowIO(IOAccess.ALL).allowAllAccess(true).build(); } @After diff --git a/engine/runtime/src/test/java/org/enso/interpreter/runtime/ModuleTest.java b/engine/runtime/src/test/java/org/enso/interpreter/runtime/ModuleTest.java index 70db0ab62558..8b49260e1d62 100644 --- a/engine/runtime/src/test/java/org/enso/interpreter/runtime/ModuleTest.java +++ b/engine/runtime/src/test/java/org/enso/interpreter/runtime/ModuleTest.java @@ -12,6 +12,7 @@ import org.enso.polyglot.RuntimeOptions; import org.graalvm.polyglot.Context; import org.graalvm.polyglot.Engine; +import org.graalvm.polyglot.io.IOAccess; import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -33,7 +34,7 @@ public void prepareTest() throws IOException { RuntimeOptions.LANGUAGE_HOME_OVERRIDE, Paths.get("../../distribution/component").toFile().getAbsolutePath()) .build(); - this.ctx = Context.newBuilder().engine(eng).allowIO(true).allowAllAccess(true).build(); + this.ctx = Context.newBuilder().engine(eng).allowIO(IOAccess.ALL).allowAllAccess(true).build(); } @After diff --git a/engine/runtime/src/test/java/org/enso/interpreter/test/DebuggingEnsoTest.java b/engine/runtime/src/test/java/org/enso/interpreter/test/DebuggingEnsoTest.java index 4330e59119c3..72a848f568ac 100644 --- a/engine/runtime/src/test/java/org/enso/interpreter/test/DebuggingEnsoTest.java +++ b/engine/runtime/src/test/java/org/enso/interpreter/test/DebuggingEnsoTest.java @@ -36,6 +36,7 @@ import org.graalvm.polyglot.Language; import org.graalvm.polyglot.Source; import org.graalvm.polyglot.Value; +import org.graalvm.polyglot.io.IOAccess; import org.junit.After; import org.junit.Assert; import org.junit.Before; @@ -60,7 +61,7 @@ public void initContext() { context = Context.newBuilder() .engine(engine) .allowExperimentalOptions(true) - .allowIO(true) + .allowIO(IOAccess.ALL) .allowAllAccess(true) .build(); diff --git a/engine/runtime/src/test/java/org/enso/interpreter/test/TestBase.java b/engine/runtime/src/test/java/org/enso/interpreter/test/TestBase.java index 47d1fc272631..d26f3d5138ea 100644 --- a/engine/runtime/src/test/java/org/enso/interpreter/test/TestBase.java +++ b/engine/runtime/src/test/java/org/enso/interpreter/test/TestBase.java @@ -21,6 +21,7 @@ import org.graalvm.polyglot.Language; import org.graalvm.polyglot.Source; import org.graalvm.polyglot.Value; +import org.graalvm.polyglot.io.IOAccess; import org.graalvm.polyglot.proxy.ProxyExecutable; public abstract class TestBase { @@ -41,7 +42,7 @@ protected static Context createDefaultContext(OutputStream out) { private static Context.Builder defaultContextBuilder() { return Context.newBuilder() .allowExperimentalOptions(true) - .allowIO(true) + .allowIO(IOAccess.ALL) .allowAllAccess(true) .logHandler(new ByteArrayOutputStream()) .option(RuntimeOptions.STRICT_ERRORS, "true") From a341b2b922dabcb3a22ab14a813eed5ae79db161 Mon Sep 17 00:00:00 2001 From: Pavel Marek Date: Tue, 4 Jul 2023 16:50:07 +0200 Subject: [PATCH 11/51] Dispose context before System.exit --- .../src/main/java/org/enso/interpreter/EnsoLanguage.java | 5 +++++ .../java/org/enso/interpreter/runtime/system/System.java | 3 +++ 2 files changed, 8 insertions(+) diff --git a/engine/runtime/src/main/java/org/enso/interpreter/EnsoLanguage.java b/engine/runtime/src/main/java/org/enso/interpreter/EnsoLanguage.java index 66c5a75c7509..4a4298db4632 100644 --- a/engine/runtime/src/main/java/org/enso/interpreter/EnsoLanguage.java +++ b/engine/runtime/src/main/java/org/enso/interpreter/EnsoLanguage.java @@ -173,6 +173,11 @@ protected void finalizeContext(EnsoContext context) { context.shutdown(); } + @Override + public void disposeContext(EnsoContext context) { + super.disposeContext(context); + } + /** * Checks if this Enso execution environment is accessible in a multithreaded context. * diff --git a/engine/runtime/src/main/java/org/enso/interpreter/runtime/system/System.java b/engine/runtime/src/main/java/org/enso/interpreter/runtime/system/System.java index 0f44b86a9776..29e1dd5d4aca 100644 --- a/engine/runtime/src/main/java/org/enso/interpreter/runtime/system/System.java +++ b/engine/runtime/src/main/java/org/enso/interpreter/runtime/system/System.java @@ -10,6 +10,7 @@ import java.io.InputStream; import java.io.OutputStream; import org.apache.commons.lang3.SystemUtils; +import org.enso.interpreter.EnsoLanguage; import org.enso.interpreter.dsl.Builtin; import org.enso.interpreter.node.expression.builtin.mutable.CoerceArrayNode; import org.enso.interpreter.node.expression.builtin.text.util.ExpectStringNode; @@ -50,6 +51,8 @@ public static long nanoTime() { autoRegister = false) @CompilerDirectives.TruffleBoundary public static void exit(long code) { + var ctx = EnsoContext.get(null); + EnsoLanguage.get(null).disposeContext(ctx); java.lang.System.exit((int) code); } From 15244d270eab05c7cba0a97254da91a818a68cb7 Mon Sep 17 00:00:00 2001 From: Pavel Marek Date: Tue, 4 Jul 2023 17:07:40 +0200 Subject: [PATCH 12/51] Get rid of some warnings - Add @Shared to some @Cached parameters --- .../epb/node/ContextRewrapNode.java | 7 +- .../epb/runtime/PolyglotProxy.java | 220 +++++++++--------- .../callable/IndirectInvokeCallableNode.java | 5 +- .../callable/thunk/ThunkExecutorNode.java | 5 +- .../builtin/error/ThrowPanicNode.java | 6 +- .../builtin/meta/IsSameObjectNode.java | 9 +- .../builtin/meta/IsValueOfTypeNode.java | 11 +- .../expression/builtin/meta/TypeOfNode.java | 9 +- .../runtime/data/hash/EnsoHashMap.java | 3 +- 9 files changed, 147 insertions(+), 128 deletions(-) diff --git a/engine/runtime-language-epb/src/main/java/org/enso/interpreter/epb/node/ContextRewrapNode.java b/engine/runtime-language-epb/src/main/java/org/enso/interpreter/epb/node/ContextRewrapNode.java index 7157b071fc51..96605a2856f4 100644 --- a/engine/runtime-language-epb/src/main/java/org/enso/interpreter/epb/node/ContextRewrapNode.java +++ b/engine/runtime-language-epb/src/main/java/org/enso/interpreter/epb/node/ContextRewrapNode.java @@ -1,5 +1,6 @@ package org.enso.interpreter.epb.node; +import com.oracle.truffle.api.dsl.Cached.Shared; import com.oracle.truffle.api.dsl.Fallback; import com.oracle.truffle.api.dsl.GenerateUncached; import com.oracle.truffle.api.dsl.ReportPolymorphism; @@ -79,7 +80,7 @@ boolean doWrappedBoolean( Object b, GuardedTruffleContext origin, GuardedTruffleContext target, - @CachedLibrary(limit = "5") InteropLibrary bools) { + @Shared("interop") @CachedLibrary(limit = "5") InteropLibrary bools) { try { return bools.asBoolean(b); } catch (UnsupportedMessageException e) { @@ -92,7 +93,7 @@ long doWrappedLong( Object l, GuardedTruffleContext origin, GuardedTruffleContext target, - @CachedLibrary(limit = "5") InteropLibrary numbers) { + @Shared("interop") @CachedLibrary(limit = "5") InteropLibrary numbers) { try { return numbers.asLong(l); } catch (UnsupportedMessageException e) { @@ -106,7 +107,7 @@ long doWrappedLong( Object d, GuardedTruffleContext origin, GuardedTruffleContext target, - @CachedLibrary(limit = "5") InteropLibrary numbers) { + @Shared("interop") @CachedLibrary(limit = "5") InteropLibrary numbers) { try { return numbers.asDouble(d); } catch (UnsupportedMessageException e) { diff --git a/engine/runtime-language-epb/src/main/java/org/enso/interpreter/epb/runtime/PolyglotProxy.java b/engine/runtime-language-epb/src/main/java/org/enso/interpreter/epb/runtime/PolyglotProxy.java index a4bb8d4e6b86..9bb3ecc4f45c 100644 --- a/engine/runtime-language-epb/src/main/java/org/enso/interpreter/epb/runtime/PolyglotProxy.java +++ b/engine/runtime-language-epb/src/main/java/org/enso/interpreter/epb/runtime/PolyglotProxy.java @@ -1,6 +1,8 @@ package org.enso.interpreter.epb.runtime; import com.oracle.truffle.api.dsl.Cached; +import com.oracle.truffle.api.dsl.Cached.Exclusive; +import com.oracle.truffle.api.dsl.Cached.Shared; import com.oracle.truffle.api.exception.AbstractTruffleException; import com.oracle.truffle.api.interop.ArityException; import com.oracle.truffle.api.interop.ExceptionType; @@ -81,8 +83,8 @@ public boolean isNull( @CachedLibrary("this.delegate") InteropLibrary nulls, @CachedLibrary("this") InteropLibrary node, @CachedLibrary(limit = "5") InteropLibrary errors, - @Cached @Cached.Exclusive ContextRewrapExceptionNode contextRewrapExceptionNode, - @Cached @Cached.Exclusive BranchProfile profile) { + @Exclusive @Cached ContextRewrapExceptionNode contextRewrapExceptionNode, + @Exclusive @Cached BranchProfile profile) { Object p = enterOrigin(node); try { return nulls.isNull(this.delegate); @@ -104,9 +106,9 @@ public boolean isNull( public boolean hasMembers( @CachedLibrary("this.delegate") InteropLibrary members, @CachedLibrary("this") InteropLibrary node, - @CachedLibrary(limit = "5") InteropLibrary errors, - @Cached @Cached.Exclusive ContextRewrapExceptionNode contextRewrapExceptionNode, - @Cached @Cached.Exclusive BranchProfile profile) { + @Shared("interop") @CachedLibrary(limit = "5") InteropLibrary errors, + @Exclusive @Cached ContextRewrapExceptionNode contextRewrapExceptionNode, + @Exclusive @Cached BranchProfile profile) { Object p = enterOrigin(node); try { return members.hasMembers(this.delegate); @@ -129,10 +131,10 @@ public Object getMembers( boolean includeInternal, @CachedLibrary("this.delegate") InteropLibrary members, @CachedLibrary("this") InteropLibrary node, - @CachedLibrary(limit = "5") InteropLibrary errors, - @Cached @Cached.Exclusive ContextRewrapNode contextRewrapNode, - @Cached @Cached.Exclusive ContextRewrapExceptionNode contextRewrapExceptionNode, - @Cached @Cached.Exclusive BranchProfile profile) + @Shared("interop") @CachedLibrary(limit = "5") InteropLibrary errors, + @Exclusive @Cached ContextRewrapNode contextRewrapNode, + @Exclusive @Cached ContextRewrapExceptionNode contextRewrapExceptionNode, + @Exclusive @Cached BranchProfile profile) throws UnsupportedMessageException { Object p = enterOrigin(node); try { @@ -157,9 +159,9 @@ public boolean isMemberInvocable( String member, @CachedLibrary("this.delegate") InteropLibrary members, @CachedLibrary("this") InteropLibrary node, - @CachedLibrary(limit = "5") InteropLibrary errors, - @Cached @Cached.Exclusive ContextRewrapExceptionNode contextRewrapExceptionNode, - @Cached @Cached.Exclusive BranchProfile profile) { + @Shared("interop") @CachedLibrary(limit = "5") InteropLibrary errors, + @Exclusive @Cached ContextRewrapExceptionNode contextRewrapExceptionNode, + @Exclusive @Cached BranchProfile profile) { Object p = enterOrigin(node); try { return members.isMemberInvocable(this.delegate, member); @@ -183,10 +185,10 @@ public Object invokeMember( Object[] arguments, @CachedLibrary("this.delegate") InteropLibrary members, @CachedLibrary("this") InteropLibrary node, - @CachedLibrary(limit = "5") InteropLibrary errors, - @Cached @Cached.Exclusive ContextRewrapExceptionNode contextRewrapExceptionNode, - @Cached @Cached.Exclusive ContextRewrapNode contextRewrapNode, - @Cached @Cached.Exclusive BranchProfile profile) + @Shared("interop") @CachedLibrary(limit = "5") InteropLibrary errors, + @Exclusive @Cached ContextRewrapExceptionNode contextRewrapExceptionNode, + @Exclusive @Cached ContextRewrapNode contextRewrapNode, + @Exclusive @Cached BranchProfile profile) throws ArityException, UnknownIdentifierException, UnsupportedMessageException, UnsupportedTypeException { Object[] wrappedArgs = new Object[arguments.length]; @@ -216,9 +218,9 @@ public boolean isMemberReadable( String member, @CachedLibrary("this.delegate") InteropLibrary members, @CachedLibrary("this") InteropLibrary node, - @CachedLibrary(limit = "5") InteropLibrary errors, - @Cached @Cached.Exclusive ContextRewrapExceptionNode contextRewrapExceptionNode, - @Cached @Cached.Exclusive BranchProfile profile) { + @Shared("interop") @CachedLibrary(limit = "5") InteropLibrary errors, + @Exclusive @Cached ContextRewrapExceptionNode contextRewrapExceptionNode, + @Exclusive @Cached BranchProfile profile) { Object p = enterOrigin(node); try { return members.isMemberReadable(this.delegate, member); @@ -241,10 +243,10 @@ public Object readMember( String member, @CachedLibrary("this.delegate") InteropLibrary members, @CachedLibrary("this") InteropLibrary node, - @CachedLibrary(limit = "5") InteropLibrary errors, - @Cached @Cached.Exclusive ContextRewrapNode contextRewrapNode, - @Cached @Cached.Exclusive ContextRewrapExceptionNode contextRewrapExceptionNode, - @Cached @Cached.Exclusive BranchProfile profile) + @Shared("interop") @CachedLibrary(limit = "5") InteropLibrary errors, + @Exclusive @Cached ContextRewrapNode contextRewrapNode, + @Exclusive @Cached ContextRewrapExceptionNode contextRewrapExceptionNode, + @Exclusive @Cached BranchProfile profile) throws UnknownIdentifierException, UnsupportedMessageException { Object p = enterOrigin(node); try { @@ -267,9 +269,9 @@ public Object readMember( public boolean isExecutable( @CachedLibrary("this.delegate") InteropLibrary functions, @CachedLibrary("this") InteropLibrary node, - @CachedLibrary(limit = "5") InteropLibrary errors, - @Cached @Cached.Exclusive ContextRewrapExceptionNode contextRewrapExceptionNode, - @Cached @Cached.Exclusive BranchProfile profile) { + @Shared("interop") @CachedLibrary(limit = "5") InteropLibrary errors, + @Exclusive @Cached ContextRewrapExceptionNode contextRewrapExceptionNode, + @Exclusive @Cached BranchProfile profile) { Object p = enterOrigin(node); try { return functions.isExecutable(this.delegate); @@ -292,10 +294,10 @@ public Object execute( Object[] arguments, @CachedLibrary("this.delegate") InteropLibrary functions, @CachedLibrary("this") InteropLibrary node, - @CachedLibrary(limit = "5") InteropLibrary errors, - @Cached @Cached.Exclusive ContextRewrapNode contextRewrapNode, - @Cached @Cached.Exclusive ContextRewrapExceptionNode contextRewrapExceptionNode, - @Cached @Cached.Exclusive BranchProfile profile) + @Shared("interop") @CachedLibrary(limit = "5") InteropLibrary errors, + @Exclusive @Cached ContextRewrapNode contextRewrapNode, + @Exclusive @Cached ContextRewrapExceptionNode contextRewrapExceptionNode, + @Exclusive @Cached BranchProfile profile) throws UnsupportedMessageException, ArityException, UnsupportedTypeException { Object[] wrappedArgs = new Object[arguments.length]; for (int i = 0; i < arguments.length; i++) { @@ -323,9 +325,9 @@ public Object execute( public boolean hasArrayElements( @CachedLibrary("this.delegate") InteropLibrary arrays, @CachedLibrary("this") InteropLibrary node, - @CachedLibrary(limit = "5") InteropLibrary errors, - @Cached @Cached.Exclusive ContextRewrapExceptionNode contextRewrapExceptionNode, - @Cached @Cached.Exclusive BranchProfile profile) { + @Shared("interop") @CachedLibrary(limit = "5") InteropLibrary errors, + @Exclusive @Cached ContextRewrapExceptionNode contextRewrapExceptionNode, + @Exclusive @Cached BranchProfile profile) { Object p = enterOrigin(node); try { return arrays.hasArrayElements(this.delegate); @@ -347,9 +349,9 @@ public boolean hasArrayElements( public long getArraySize( @CachedLibrary("this.delegate") InteropLibrary arrays, @CachedLibrary("this") InteropLibrary node, - @CachedLibrary(limit = "5") InteropLibrary errors, - @Cached @Cached.Exclusive ContextRewrapExceptionNode contextRewrapExceptionNode, - @Cached @Cached.Exclusive BranchProfile profile) + @Shared("interop") @CachedLibrary(limit = "5") InteropLibrary errors, + @Exclusive @Cached ContextRewrapExceptionNode contextRewrapExceptionNode, + @Exclusive @Cached BranchProfile profile) throws UnsupportedMessageException { Object p = enterOrigin(node); try { @@ -373,9 +375,9 @@ public boolean isArrayElementReadable( long idx, @CachedLibrary("this.delegate") InteropLibrary arrays, @CachedLibrary("this") InteropLibrary node, - @CachedLibrary(limit = "5") InteropLibrary errors, - @Cached @Cached.Exclusive ContextRewrapExceptionNode contextRewrapExceptionNode, - @Cached @Cached.Exclusive BranchProfile profile) { + @Shared("interop") @CachedLibrary(limit = "5") InteropLibrary errors, + @Exclusive @Cached ContextRewrapExceptionNode contextRewrapExceptionNode, + @Exclusive @Cached BranchProfile profile) { Object p = enterOrigin(node); try { return arrays.isArrayElementReadable(this.delegate, idx); @@ -398,10 +400,10 @@ public Object readArrayElement( long index, @CachedLibrary("this.delegate") InteropLibrary arrays, @CachedLibrary("this") InteropLibrary node, - @CachedLibrary(limit = "5") InteropLibrary errors, - @Cached @Cached.Exclusive ContextRewrapNode contextRewrapNode, - @Cached @Cached.Exclusive ContextRewrapExceptionNode contextRewrapExceptionNode, - @Cached @Cached.Exclusive BranchProfile profile) + @Shared("interop") @CachedLibrary(limit = "5") InteropLibrary errors, + @Exclusive @Cached ContextRewrapNode contextRewrapNode, + @Exclusive @Cached ContextRewrapExceptionNode contextRewrapExceptionNode, + @Exclusive @Cached BranchProfile profile) throws InvalidArrayIndexException, UnsupportedMessageException { Object p = enterOrigin(node); try { @@ -425,9 +427,9 @@ public Object readArrayElement( public boolean hasHashEntries( @CachedLibrary("this.delegate") InteropLibrary hashMaps, @CachedLibrary("this") InteropLibrary node, - @CachedLibrary(limit = "5") InteropLibrary errors, - @Cached @Cached.Exclusive ContextRewrapExceptionNode contextRewrapExceptionNode, - @Cached @Cached.Exclusive BranchProfile profile) { + @Shared("interop") @CachedLibrary(limit = "5") InteropLibrary errors, + @Exclusive @Cached ContextRewrapExceptionNode contextRewrapExceptionNode, + @Exclusive @Cached BranchProfile profile) { Object p = enterOrigin(node); try { return hashMaps.hasHashEntries(this.delegate); @@ -449,9 +451,9 @@ public boolean hasHashEntries( public long getHashSize( @CachedLibrary("this.delegate") InteropLibrary hashes, @CachedLibrary("this") InteropLibrary node, - @CachedLibrary(limit = "5") InteropLibrary errors, - @Cached @Cached.Exclusive ContextRewrapExceptionNode contextRewrapExceptionNode, - @Cached @Cached.Exclusive BranchProfile profile) + @Shared("interop") @CachedLibrary(limit = "5") InteropLibrary errors, + @Exclusive @Cached ContextRewrapExceptionNode contextRewrapExceptionNode, + @Exclusive @Cached BranchProfile profile) throws UnsupportedMessageException { Object p = enterOrigin(node); try { @@ -475,9 +477,9 @@ public boolean isHashEntryReadable( Object key, @CachedLibrary("this.delegate") InteropLibrary hashes, @CachedLibrary("this") InteropLibrary node, - @CachedLibrary(limit = "5") InteropLibrary errors, - @Cached @Cached.Exclusive ContextRewrapExceptionNode contextRewrapExceptionNode, - @Cached @Cached.Exclusive BranchProfile profile) { + @Shared("interop") @CachedLibrary(limit = "5") InteropLibrary errors, + @Exclusive @Cached ContextRewrapExceptionNode contextRewrapExceptionNode, + @Exclusive @Cached BranchProfile profile) { Object p = enterOrigin(node); try { return hashes.isHashEntryReadable(this.delegate, key); @@ -500,9 +502,9 @@ public Object readHashValue( Object key, @CachedLibrary("this.delegate") InteropLibrary hashes, @CachedLibrary("this") InteropLibrary node, - @CachedLibrary(limit = "5") InteropLibrary errors, - @Cached @Cached.Exclusive ContextRewrapExceptionNode contextRewrapExceptionNode, - @Cached @Cached.Exclusive BranchProfile profile) + @Shared("interop") @CachedLibrary(limit = "5") InteropLibrary errors, + @Exclusive @Cached ContextRewrapExceptionNode contextRewrapExceptionNode, + @Exclusive @Cached BranchProfile profile) throws UnsupportedMessageException, UnknownKeyException { Object p = enterOrigin(node); try { @@ -525,9 +527,9 @@ public Object readHashValue( public Object getHashEntriesIterator( @CachedLibrary("this.delegate") InteropLibrary hashes, @CachedLibrary("this") InteropLibrary node, - @CachedLibrary(limit = "5") InteropLibrary errors, - @Cached @Cached.Exclusive ContextRewrapExceptionNode contextRewrapExceptionNode, - @Cached @Cached.Exclusive BranchProfile profile) + @Shared("interop") @CachedLibrary(limit = "5") InteropLibrary errors, + @Exclusive @Cached ContextRewrapExceptionNode contextRewrapExceptionNode, + @Exclusive @Cached BranchProfile profile) throws UnsupportedMessageException { Object p = enterOrigin(node); try { @@ -550,9 +552,9 @@ public Object getHashEntriesIterator( public boolean isString( @CachedLibrary("this.delegate") InteropLibrary strings, @CachedLibrary("this") InteropLibrary node, - @CachedLibrary(limit = "5") InteropLibrary errors, - @Cached @Cached.Exclusive ContextRewrapExceptionNode contextRewrapExceptionNode, - @Cached @Cached.Exclusive BranchProfile profile) { + @Shared("interop") @CachedLibrary(limit = "5") InteropLibrary errors, + @Exclusive @Cached ContextRewrapExceptionNode contextRewrapExceptionNode, + @Exclusive @Cached BranchProfile profile) { Object p = enterOrigin(node); try { return strings.isString(this.delegate); @@ -574,9 +576,9 @@ public boolean isString( public String asString( @CachedLibrary("this.delegate") InteropLibrary strings, @CachedLibrary("this") InteropLibrary node, - @CachedLibrary(limit = "5") InteropLibrary errors, - @Cached @Cached.Exclusive ContextRewrapExceptionNode contextRewrapExceptionNode, - @Cached @Cached.Exclusive BranchProfile profile) + @Shared("interop") @CachedLibrary(limit = "5") InteropLibrary errors, + @Exclusive @Cached ContextRewrapExceptionNode contextRewrapExceptionNode, + @Exclusive @Cached BranchProfile profile) throws UnsupportedMessageException { Object p = enterOrigin(node); try { @@ -599,9 +601,9 @@ public String asString( public boolean isNumber( @CachedLibrary("this.delegate") InteropLibrary numbers, @CachedLibrary("this") InteropLibrary node, - @CachedLibrary(limit = "5") InteropLibrary errors, - @Cached @Cached.Exclusive ContextRewrapExceptionNode contextRewrapExceptionNode, - @Cached @Cached.Exclusive BranchProfile profile) { + @Shared("interop") @CachedLibrary(limit = "5") InteropLibrary errors, + @Exclusive @Cached ContextRewrapExceptionNode contextRewrapExceptionNode, + @Exclusive @Cached BranchProfile profile) { Object p = enterOrigin(node); try { return numbers.isNumber(this.delegate); @@ -623,9 +625,9 @@ public boolean isNumber( public boolean fitsInByte( @CachedLibrary("this.delegate") InteropLibrary numbers, @CachedLibrary("this") InteropLibrary node, - @CachedLibrary(limit = "5") InteropLibrary errors, - @Cached @Cached.Exclusive ContextRewrapExceptionNode contextRewrapExceptionNode, - @Cached @Cached.Exclusive BranchProfile profile) { + @Shared("interop") @CachedLibrary(limit = "5") InteropLibrary errors, + @Exclusive @Cached ContextRewrapExceptionNode contextRewrapExceptionNode, + @Exclusive @Cached BranchProfile profile) { Object p = enterOrigin(node); try { return numbers.fitsInByte(this.delegate); @@ -647,9 +649,9 @@ public boolean fitsInByte( public boolean fitsInShort( @CachedLibrary("this.delegate") InteropLibrary numbers, @CachedLibrary("this") InteropLibrary node, - @CachedLibrary(limit = "5") InteropLibrary errors, - @Cached @Cached.Exclusive ContextRewrapExceptionNode contextRewrapExceptionNode, - @Cached @Cached.Exclusive BranchProfile profile) { + @Shared("interop") @CachedLibrary(limit = "5") InteropLibrary errors, + @Exclusive @Cached ContextRewrapExceptionNode contextRewrapExceptionNode, + @Exclusive @Cached BranchProfile profile) { Object p = enterOrigin(node); try { return numbers.fitsInShort(this.delegate); @@ -671,9 +673,9 @@ public boolean fitsInShort( public boolean fitsInInt( @CachedLibrary("this.delegate") InteropLibrary numbers, @CachedLibrary("this") InteropLibrary node, - @CachedLibrary(limit = "5") InteropLibrary errors, - @Cached @Cached.Exclusive ContextRewrapExceptionNode contextRewrapExceptionNode, - @Cached @Cached.Exclusive BranchProfile profile) { + @Shared("interop") @CachedLibrary(limit = "5") InteropLibrary errors, + @Exclusive @Cached ContextRewrapExceptionNode contextRewrapExceptionNode, + @Exclusive @Cached BranchProfile profile) { Object p = enterOrigin(node); try { return numbers.fitsInInt(this.delegate); @@ -695,9 +697,9 @@ public boolean fitsInInt( public boolean fitsInLong( @CachedLibrary("this.delegate") InteropLibrary numbers, @CachedLibrary("this") InteropLibrary node, - @CachedLibrary(limit = "5") InteropLibrary errors, - @Cached @Cached.Exclusive ContextRewrapExceptionNode contextRewrapExceptionNode, - @Cached @Cached.Exclusive BranchProfile profile) { + @Shared("interop") @CachedLibrary(limit = "5") InteropLibrary errors, + @Exclusive @Cached ContextRewrapExceptionNode contextRewrapExceptionNode, + @Exclusive @Cached BranchProfile profile) { Object p = enterOrigin(node); try { return numbers.fitsInLong(this.delegate); @@ -719,9 +721,9 @@ public boolean fitsInLong( public boolean fitsInFloat( @CachedLibrary("this.delegate") InteropLibrary numbers, @CachedLibrary("this") InteropLibrary node, - @CachedLibrary(limit = "5") InteropLibrary errors, - @Cached @Cached.Exclusive ContextRewrapExceptionNode contextRewrapExceptionNode, - @Cached @Cached.Exclusive BranchProfile profile) { + @Shared("interop") @CachedLibrary(limit = "5") InteropLibrary errors, + @Exclusive @Cached ContextRewrapExceptionNode contextRewrapExceptionNode, + @Exclusive @Cached BranchProfile profile) { Object p = enterOrigin(node); try { return numbers.fitsInFloat(this.delegate); @@ -743,9 +745,9 @@ public boolean fitsInFloat( public boolean fitsInDouble( @CachedLibrary("this.delegate") InteropLibrary numbers, @CachedLibrary("this") InteropLibrary node, - @CachedLibrary(limit = "5") InteropLibrary errors, - @Cached @Cached.Exclusive ContextRewrapExceptionNode contextRewrapExceptionNode, - @Cached @Cached.Exclusive BranchProfile profile) { + @Shared("interop") @CachedLibrary(limit = "5") InteropLibrary errors, + @Exclusive @Cached ContextRewrapExceptionNode contextRewrapExceptionNode, + @Exclusive @Cached BranchProfile profile) { Object p = enterOrigin(node); try { return numbers.fitsInDouble(this.delegate); @@ -767,9 +769,9 @@ public boolean fitsInDouble( public byte asByte( @CachedLibrary("this.delegate") InteropLibrary numbers, @CachedLibrary("this") InteropLibrary node, - @CachedLibrary(limit = "5") InteropLibrary errors, - @Cached @Cached.Exclusive ContextRewrapExceptionNode contextRewrapExceptionNode, - @Cached @Cached.Exclusive BranchProfile profile) + @Shared("interop") @CachedLibrary(limit = "5") InteropLibrary errors, + @Exclusive @Cached ContextRewrapExceptionNode contextRewrapExceptionNode, + @Exclusive @Cached BranchProfile profile) throws UnsupportedMessageException { Object p = enterOrigin(node); try { @@ -792,9 +794,9 @@ public byte asByte( public short asShort( @CachedLibrary("this.delegate") InteropLibrary numbers, @CachedLibrary("this") InteropLibrary node, - @CachedLibrary(limit = "5") InteropLibrary errors, - @Cached @Cached.Exclusive ContextRewrapExceptionNode contextRewrapExceptionNode, - @Cached @Cached.Exclusive BranchProfile profile) + @Shared("interop") @CachedLibrary(limit = "5") InteropLibrary errors, + @Exclusive @Cached ContextRewrapExceptionNode contextRewrapExceptionNode, + @Exclusive @Cached BranchProfile profile) throws UnsupportedMessageException { Object p = enterOrigin(node); try { @@ -817,9 +819,9 @@ public short asShort( public int asInt( @CachedLibrary("this.delegate") InteropLibrary numbers, @CachedLibrary("this") InteropLibrary node, - @CachedLibrary(limit = "5") InteropLibrary errors, - @Cached @Cached.Exclusive ContextRewrapExceptionNode contextRewrapExceptionNode, - @Cached @Cached.Exclusive BranchProfile profile) + @Shared("interop") @CachedLibrary(limit = "5") InteropLibrary errors, + @Exclusive @Cached ContextRewrapExceptionNode contextRewrapExceptionNode, + @Exclusive @Cached BranchProfile profile) throws UnsupportedMessageException { Object p = enterOrigin(node); try { @@ -842,9 +844,9 @@ public int asInt( public long asLong( @CachedLibrary("this.delegate") InteropLibrary numbers, @CachedLibrary("this") InteropLibrary node, - @CachedLibrary(limit = "5") InteropLibrary errors, - @Cached @Cached.Exclusive ContextRewrapExceptionNode contextRewrapExceptionNode, - @Cached @Cached.Exclusive BranchProfile profile) + @Shared("interop") @CachedLibrary(limit = "5") InteropLibrary errors, + @Exclusive @Cached ContextRewrapExceptionNode contextRewrapExceptionNode, + @Exclusive @Cached BranchProfile profile) throws UnsupportedMessageException { Object p = enterOrigin(node); try { @@ -867,9 +869,9 @@ public long asLong( public float asFloat( @CachedLibrary("this.delegate") InteropLibrary numbers, @CachedLibrary("this") InteropLibrary node, - @CachedLibrary(limit = "5") InteropLibrary errors, - @Cached @Cached.Exclusive ContextRewrapExceptionNode contextRewrapExceptionNode, - @Cached @Cached.Exclusive BranchProfile profile) + @Shared("interop") @CachedLibrary(limit = "5") InteropLibrary errors, + @Exclusive @Cached ContextRewrapExceptionNode contextRewrapExceptionNode, + @Exclusive @Cached BranchProfile profile) throws UnsupportedMessageException { Object p = enterOrigin(node); try { @@ -892,9 +894,9 @@ public float asFloat( public double asDouble( @CachedLibrary("this.delegate") InteropLibrary numbers, @CachedLibrary("this") InteropLibrary node, - @CachedLibrary(limit = "5") InteropLibrary errors, - @Cached @Cached.Exclusive ContextRewrapExceptionNode contextRewrapExceptionNode, - @Cached @Cached.Exclusive BranchProfile profile) + @Shared("interop") @CachedLibrary(limit = "5") InteropLibrary errors, + @Exclusive @Cached ContextRewrapExceptionNode contextRewrapExceptionNode, + @Exclusive @Cached BranchProfile profile) throws UnsupportedMessageException { Object p = enterOrigin(node); try { @@ -918,9 +920,9 @@ public Object toDisplayString( boolean allowSideEffects, @CachedLibrary("this.delegate") InteropLibrary displays, @CachedLibrary("this") InteropLibrary node, - @CachedLibrary(limit = "5") InteropLibrary errors, - @Cached @Cached.Exclusive ContextRewrapExceptionNode contextRewrapExceptionNode, - @Cached @Cached.Exclusive BranchProfile profile) { + @Shared("interop") @CachedLibrary(limit = "5") InteropLibrary errors, + @Exclusive @Cached ContextRewrapExceptionNode contextRewrapExceptionNode, + @Exclusive @Cached BranchProfile profile) { Object p = enterOrigin(node); try { return displays.toDisplayString(this.delegate, allowSideEffects); @@ -954,8 +956,8 @@ boolean isException( RuntimeException throwException( @CachedLibrary("this.delegate") InteropLibrary delegate, @CachedLibrary("this") InteropLibrary node, - @CachedLibrary(limit = "5") InteropLibrary errors, - @Cached @Cached.Exclusive ContextRewrapExceptionNode contextRewrapExceptionNode) + @Shared("interop") @CachedLibrary(limit = "5") InteropLibrary errors, + @Exclusive @Cached ContextRewrapExceptionNode contextRewrapExceptionNode) throws UnsupportedMessageException { Object p = enterOrigin(node); try { @@ -1028,7 +1030,7 @@ boolean hasExceptionMessage( Object getExceptionMessage( @CachedLibrary("this.delegate") InteropLibrary errors, @CachedLibrary("this") InteropLibrary node, - @Cached @Cached.Exclusive ContextRewrapNode contextRewrapNode) + @Exclusive @Cached ContextRewrapNode contextRewrapNode) throws UnsupportedMessageException { Object p = enterOrigin(node); try { diff --git a/engine/runtime/src/main/java/org/enso/interpreter/node/callable/IndirectInvokeCallableNode.java b/engine/runtime/src/main/java/org/enso/interpreter/node/callable/IndirectInvokeCallableNode.java index 798dc5afd453..aa0a071e7dda 100644 --- a/engine/runtime/src/main/java/org/enso/interpreter/node/callable/IndirectInvokeCallableNode.java +++ b/engine/runtime/src/main/java/org/enso/interpreter/node/callable/IndirectInvokeCallableNode.java @@ -2,6 +2,7 @@ import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.dsl.Cached; +import com.oracle.truffle.api.dsl.Cached.Exclusive; import com.oracle.truffle.api.dsl.Fallback; import com.oracle.truffle.api.dsl.GenerateUncached; import com.oracle.truffle.api.dsl.Specialization; @@ -103,7 +104,7 @@ Object invokeFunction( InvokeCallableNode.DefaultsExecutionMode defaultsExecutionMode, InvokeCallableNode.ArgumentsExecutionMode argumentsExecutionMode, BaseNode.TailStatus isTail, - @Cached IndirectInvokeFunctionNode invokeFunctionNode) { + @Exclusive @Cached IndirectInvokeFunctionNode invokeFunctionNode) { return invokeFunctionNode.execute( function, callerFrame, @@ -125,7 +126,7 @@ Object invokeConstructor( InvokeCallableNode.DefaultsExecutionMode defaultsExecutionMode, InvokeCallableNode.ArgumentsExecutionMode argumentsExecutionMode, BaseNode.TailStatus isTail, - @Cached IndirectInvokeFunctionNode invokeFunctionNode) { + @Exclusive @Cached IndirectInvokeFunctionNode invokeFunctionNode) { return invokeFunction( constructor.getConstructorFunction(), callerFrame, diff --git a/engine/runtime/src/main/java/org/enso/interpreter/node/callable/thunk/ThunkExecutorNode.java b/engine/runtime/src/main/java/org/enso/interpreter/node/callable/thunk/ThunkExecutorNode.java index 388d2c690c37..914e3d79b88e 100644 --- a/engine/runtime/src/main/java/org/enso/interpreter/node/callable/thunk/ThunkExecutorNode.java +++ b/engine/runtime/src/main/java/org/enso/interpreter/node/callable/thunk/ThunkExecutorNode.java @@ -2,6 +2,7 @@ import com.oracle.truffle.api.CompilerAsserts; import com.oracle.truffle.api.dsl.*; +import com.oracle.truffle.api.dsl.Cached.Exclusive; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.DirectCallNode; import com.oracle.truffle.api.nodes.IndirectCallNode; @@ -58,7 +59,7 @@ Object doCached( State state, BaseNode.TailStatus isTail, @Cached("create(function.getCallTarget())") DirectCallNode callNode, - @Cached LoopingCallOptimiserNode loopingCallOptimiserNode) { + @Exclusive @Cached LoopingCallOptimiserNode loopingCallOptimiserNode) { CompilerAsserts.partialEvaluationConstant(isTail); if (isTail != BaseNode.TailStatus.NOT_TAIL) { return callNode.call(Function.ArgumentsHelper.buildArguments(function, state)); @@ -79,7 +80,7 @@ Object doUncached( State state, BaseNode.TailStatus isTail, @Cached IndirectCallNode callNode, - @Cached LoopingCallOptimiserNode loopingCallOptimiserNode) { + @Exclusive @Cached LoopingCallOptimiserNode loopingCallOptimiserNode) { if (isTail != BaseNode.TailStatus.NOT_TAIL) { return callNode.call( function.getCallTarget(), Function.ArgumentsHelper.buildArguments(function, state)); diff --git a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/error/ThrowPanicNode.java b/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/error/ThrowPanicNode.java index be8726355ec3..18a2eec3788b 100644 --- a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/error/ThrowPanicNode.java +++ b/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/error/ThrowPanicNode.java @@ -1,6 +1,7 @@ package org.enso.interpreter.node.expression.builtin.error; import com.oracle.truffle.api.dsl.Cached; +import com.oracle.truffle.api.dsl.Cached.Shared; import com.oracle.truffle.api.dsl.Fallback; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.frame.VirtualFrame; @@ -38,7 +39,7 @@ EnsoContext getContext() { Object doCaughtPanic( VirtualFrame frame, Atom payload, - @CachedLibrary(limit = "5") InteropLibrary interopLibrary, + @Shared("interop") @CachedLibrary(limit = "5") InteropLibrary interopLibrary, @CachedLibrary(limit = "5") StructsLibrary structs, @Cached BranchProfile typeErrorProfile) { // Note [Original Exception Type] @@ -63,7 +64,8 @@ Object doCaughtPanic( @Specialization(guards = "interopLibrary.isException(payload)") Object doOtherException( - Object payload, @CachedLibrary(limit = "5") InteropLibrary interopLibrary) { + Object payload, + @Shared("interop") @CachedLibrary(limit = "5") InteropLibrary interopLibrary) { try { throw interopLibrary.throwException(payload); } catch (UnsupportedMessageException e) { diff --git a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/meta/IsSameObjectNode.java b/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/meta/IsSameObjectNode.java index 24d25edad247..98b707ee6def 100644 --- a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/meta/IsSameObjectNode.java +++ b/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/meta/IsSameObjectNode.java @@ -1,5 +1,6 @@ package org.enso.interpreter.node.expression.builtin.meta; +import com.oracle.truffle.api.dsl.Cached.Shared; import com.oracle.truffle.api.dsl.Fallback; import com.oracle.truffle.api.dsl.GenerateUncached; import com.oracle.truffle.api.dsl.Specialization; @@ -50,7 +51,9 @@ boolean isSameType(Type typeLeft, Type typeRight) { */ @Specialization(guards = {"interop.isMetaObject(metaLeft)", "interop.isMetaObject(metaRight)"}) boolean isSameMetaObjects( - Object metaLeft, Object metaRight, @CachedLibrary(limit = "2") InteropLibrary interop) { + Object metaLeft, + Object metaRight, + @Shared("interop") @CachedLibrary(limit = "2") InteropLibrary interop) { try { Object metaLeftName = interop.getMetaQualifiedName(metaLeft); Object metaRightName = interop.getMetaQualifiedName(metaRight); @@ -62,7 +65,9 @@ boolean isSameMetaObjects( @Fallback boolean isIdenticalObjects( - Object left, Object right, @CachedLibrary(limit = "2") InteropLibrary interop) { + Object left, + Object right, + @Shared("interop") @CachedLibrary(limit = "2") InteropLibrary interop) { if (left == right) { return true; } diff --git a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/meta/IsValueOfTypeNode.java b/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/meta/IsValueOfTypeNode.java index 3ec792ac9691..8a9cc4c401cb 100644 --- a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/meta/IsValueOfTypeNode.java +++ b/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/meta/IsValueOfTypeNode.java @@ -1,6 +1,7 @@ package org.enso.interpreter.node.expression.builtin.meta; import com.oracle.truffle.api.dsl.Cached; +import com.oracle.truffle.api.dsl.Cached.Shared; import com.oracle.truffle.api.dsl.Fallback; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.interop.InteropLibrary; @@ -30,7 +31,7 @@ public static IsValueOfTypeNode build() { boolean doTyped( Object expectedType, Object payload, - @CachedLibrary(limit = "3") TypesLibrary types, + @Shared("types") @CachedLibrary(limit = "3") TypesLibrary types, @Cached Typed typed) { return typed.execute(expectedType, payload); } @@ -39,7 +40,7 @@ boolean doTyped( boolean doPolyglot( Object expectedType, Object payload, - @CachedLibrary(limit = "3") TypesLibrary types, + @Shared("types") @CachedLibrary(limit = "3") TypesLibrary types, @Cached Untyped untyped) { return untyped.execute(expectedType, payload); } @@ -120,7 +121,9 @@ private boolean checkParentTypes(Type actual, Type expected) { @Specialization(guards = {"!isArrayType(expectedType)", "!isAnyType(expectedType)"}) boolean doType( - Type expectedType, Object payload, @CachedLibrary(limit = "3") TypesLibrary types) { + Type expectedType, + Object payload, + @Shared("types") @CachedLibrary(limit = "3") TypesLibrary types) { return typeAndCheck(payload, expectedType, typeOfNode, isSameObject, profile); } @@ -133,7 +136,7 @@ public boolean doArrayViaType( Object expectedType, Object payload, @CachedLibrary(limit = "3") InteropLibrary interop, - @CachedLibrary(limit = "3") TypesLibrary types) { + @Shared("types") @CachedLibrary(limit = "3") TypesLibrary types) { return EnsoContext.get(this).getBuiltins().array() == types.getType(payload); } diff --git a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/meta/TypeOfNode.java b/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/meta/TypeOfNode.java index 0e10a6652982..f75cedc83b7e 100644 --- a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/meta/TypeOfNode.java +++ b/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/meta/TypeOfNode.java @@ -2,6 +2,7 @@ import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.dsl.Cached; +import com.oracle.truffle.api.dsl.Cached.Shared; import com.oracle.truffle.api.dsl.Fallback; import com.oracle.truffle.api.dsl.GenerateUncached; import com.oracle.truffle.api.dsl.Specialization; @@ -126,7 +127,9 @@ Type doPolyglotString(Interop type, Object value) { @Specialization(guards = {"type.isNumber()"}) Type doPolyglotNumber( - Interop type, Object value, @CachedLibrary(limit = "3") InteropLibrary interop) { + Interop type, + Object value, + @Shared("interop") @CachedLibrary(limit = "3") InteropLibrary interop) { Builtins builtins = EnsoContext.get(this).getBuiltins(); if (interop.fitsInInt(value)) { return builtins.number().getInteger(); @@ -170,7 +173,9 @@ Type doDuration(Interop type, Object value) { @Specialization(guards = {"type.isMetaObject()"}) Object doMetaObject( - Interop type, Object value, @CachedLibrary(limit = "3") InteropLibrary interop) { + Interop type, + Object value, + @Shared("interop") @CachedLibrary(limit = "3") InteropLibrary interop) { try { return interop.getMetaObject(value); } catch (UnsupportedMessageException e) { diff --git a/engine/runtime/src/main/java/org/enso/interpreter/runtime/data/hash/EnsoHashMap.java b/engine/runtime/src/main/java/org/enso/interpreter/runtime/data/hash/EnsoHashMap.java index acd054d1e70f..c07a405b9933 100644 --- a/engine/runtime/src/main/java/org/enso/interpreter/runtime/data/hash/EnsoHashMap.java +++ b/engine/runtime/src/main/java/org/enso/interpreter/runtime/data/hash/EnsoHashMap.java @@ -165,8 +165,7 @@ Type getMetaObject(@CachedLibrary("this") InteropLibrary thisLib) { @ExportMessage @TruffleBoundary - Object toDisplayString( - boolean allowSideEffects) { + Object toDisplayString(boolean allowSideEffects) { return toString(true); } From 24ea89dd875aaea86f54860893bb63207d3c4d3f Mon Sep 17 00:00:00 2001 From: Pavel Marek Date: Wed, 5 Jul 2023 11:30:29 +0200 Subject: [PATCH 13/51] Suppress all the Node inlining warnings in runtime projects --- build.sbt | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/build.sbt b/build.sbt index 5e24386dda2c..99c40c2bd4c9 100644 --- a/build.sbt +++ b/build.sbt @@ -1131,6 +1131,12 @@ val distributionEnvironmentOverrides = { val frgaalSourceLevel = FrgaalJavaCompiler.sourceLevel +lazy val truffleDslSuppressWarnsSetting = Seq( + Compile / javacOptions ++= Seq( + "-Atruffle.dsl.SuppressWarnings=truffle-inlining" + ) +) + /** A setting to replace javac with Frgaal compiler, allowing to use latest Java features in the code * and still compile down to JDK 11 */ @@ -1178,6 +1184,7 @@ lazy val `runtime-language-epb` = (project in file("engine/runtime-language-epb")) .settings( inConfig(Compile)(truffleRunOptionsSettings), + truffleDslSuppressWarnsSetting, instrumentationSettings ) @@ -1257,6 +1264,7 @@ lazy val runtime = (project in file("engine/runtime")) .configs(Benchmark) .settings( frgaalJavaCompilerSetting, + truffleDslSuppressWarnsSetting, Compile / logManager := sbt.internal.util.CustomLogManager.excludeMsg( "Could not determine source for class ", @@ -1386,6 +1394,7 @@ lazy val `runtime-instrument-common` = .configs(Benchmark) .settings( frgaalJavaCompilerSetting, + truffleDslSuppressWarnsSetting, inConfig(Compile)(truffleRunOptionsSettings), inConfig(Benchmark)(Defaults.testSettings), instrumentationSettings, @@ -1408,6 +1417,7 @@ lazy val `runtime-instrument-id-execution` = (project in file("engine/runtime-instrument-id-execution")) .settings( inConfig(Compile)(truffleRunOptionsSettings), + truffleDslSuppressWarnsSetting, instrumentationSettings ) .dependsOn(runtime) @@ -1417,6 +1427,7 @@ lazy val `runtime-instrument-repl-debugger` = (project in file("engine/runtime-instrument-repl-debugger")) .settings( inConfig(Compile)(truffleRunOptionsSettings), + truffleDslSuppressWarnsSetting, instrumentationSettings ) .dependsOn(runtime) @@ -1426,6 +1437,7 @@ lazy val `runtime-instrument-runtime-server` = (project in file("engine/runtime-instrument-runtime-server")) .settings( inConfig(Compile)(truffleRunOptionsSettings), + truffleDslSuppressWarnsSetting, instrumentationSettings ) .dependsOn(runtime) @@ -1436,6 +1448,7 @@ lazy val `runtime-with-instruments` = .configs(Benchmark) .settings( frgaalJavaCompilerSetting, + truffleDslSuppressWarnsSetting, inConfig(Compile)(truffleRunOptionsSettings), inConfig(Benchmark)(Defaults.testSettings), commands += WithDebugCommand.withDebug, @@ -1494,6 +1507,7 @@ lazy val `runtime-with-polyglot` = .configs(Benchmark) .settings( frgaalJavaCompilerSetting, + truffleDslSuppressWarnsSetting, inConfig(Compile)(truffleRunOptionsNoAssertSettings), inConfig(Benchmark)(Defaults.testSettings), commands += WithDebugCommand.withDebug, @@ -1548,6 +1562,7 @@ lazy val `engine-runner` = project .in(file("engine/runner")) .settings( frgaalJavaCompilerSetting, + truffleDslSuppressWarnsSetting, javaOptions ++= { // Note [Classpath Separation] val runtimeClasspath = From f279100477a38527e26277320a4f67c1678c70c8 Mon Sep 17 00:00:00 2001 From: Pavel Marek Date: Wed, 5 Jul 2023 14:01:27 +0200 Subject: [PATCH 14/51] Suppress BigInteger message implement warning --- .../java/org/enso/interpreter/runtime/number/EnsoBigInteger.java | 1 + 1 file changed, 1 insertion(+) diff --git a/engine/runtime/src/main/java/org/enso/interpreter/runtime/number/EnsoBigInteger.java b/engine/runtime/src/main/java/org/enso/interpreter/runtime/number/EnsoBigInteger.java index 0c061f742672..2af3fac89132 100644 --- a/engine/runtime/src/main/java/org/enso/interpreter/runtime/number/EnsoBigInteger.java +++ b/engine/runtime/src/main/java/org/enso/interpreter/runtime/number/EnsoBigInteger.java @@ -16,6 +16,7 @@ /** Internal wrapper for a {@link BigInteger}. */ @ExportLibrary(InteropLibrary.class) @ExportLibrary(TypesLibrary.class) +@SuppressWarnings("truffle-abstract-export") public final class EnsoBigInteger extends Number implements TruffleObject { private final BigInteger value; From 74b6e048eb78e29347b7672c6bb81c944e8cc686 Mon Sep 17 00:00:00 2001 From: Pavel Marek Date: Wed, 5 Jul 2023 14:06:30 +0200 Subject: [PATCH 15/51] Get rid of warnings in runtime. - Remove deprecated `ConditionProfile.createCountingProfile()`. - Add `@Shared` to some `@Cached` parameters. - Specialization method names should not start with execute - Add limit attribute to some specialization methods - Add `@NeverDefault` for some cached initializer expressions - Add `@Idempotent` or `@NonIdempotent` where appropriate --- .../epb/runtime/PolyglotProxy.java | 52 ++++++- .../node/callable/CaptureCallerInfoNode.java | 3 + .../node/callable/ExecuteCallNode.java | 4 +- .../IndirectInvokeConversionNode.java | 30 ++-- .../callable/IndirectInvokeMethodNode.java | 31 +++-- .../node/callable/InteropApplicationNode.java | 6 +- .../callable/InteropConversionCallNode.java | 7 +- .../node/callable/InteropMethodCallNode.java | 7 +- .../node/callable/InvokeConversionNode.java | 49 +++---- .../node/callable/InvokeMethodNode.java | 130 ++++++++++-------- .../callable/argument/ReadArgumentNode.java | 3 +- .../callable/dispatch/InvokeFunctionNode.java | 4 + .../dispatch/LoopingCallOptimiserNode.java | 11 +- .../resolver/ConversionResolverNode.java | 2 + .../callable/resolver/HostMethodCallNode.java | 13 +- .../callable/resolver/MethodResolverNode.java | 2 + .../callable/thunk/ThunkExecutorNode.java | 1 + .../caseexpr/BooleanBranchNode.java | 4 +- .../node/controlflow/caseexpr/BranchNode.java | 8 +- .../node/controlflow/caseexpr/CaseNode.java | 13 +- .../caseexpr/CatchTypeBranchNode.java | 4 +- .../caseexpr/ConstructorBranchNode.java | 4 +- .../caseexpr/NumericLiteralBranchNode.java | 4 +- .../caseexpr/ObjectEqualityBranchNode.java | 4 +- .../caseexpr/PolyglotBranchNode.java | 6 +- .../PolyglotSymbolTypeBranchNode.java | 6 +- .../caseexpr/StringLiteralBranchNode.java | 4 +- .../node/expression/atom/InstantiateNode.java | 21 +-- .../node/expression/builtin/bool/AndNode.java | 6 +- .../builtin/bool/IfThenElseNode.java | 4 +- .../expression/builtin/bool/IfThenNode.java | 4 +- .../node/expression/builtin/bool/OrNode.java | 6 +- .../builtin/date/ToEnsoDateNode.java | 2 +- .../builtin/error/CatchPanicNode.java | 4 +- .../immutable/SliceArrayVectorNode.java | 19 ++- .../interop/syntax/HostValueToEnsoNode.java | 1 + .../expression/builtin/io/PrintErrNode.java | 8 +- .../expression/builtin/io/PrintlnNode.java | 9 +- .../builtin/meta/AtomWithAHoleNode.java | 3 + .../builtin/meta/EqualsAtomNode.java | 5 +- .../builtin/meta/EqualsComplexNode.java | 54 ++++---- .../expression/builtin/meta/EqualsNode.java | 11 +- .../meta/GetConstructorFieldNamesNode.java | 6 +- .../expression/builtin/meta/HashCodeNode.java | 62 +++++---- .../builtin/meta/IsValueOfTypeNode.java | 8 +- .../expression/builtin/meta/TypeOfNode.java | 8 +- .../builtin/mutable/CoerceArrayNode.java | 7 +- .../number/bigInteger/BitShiftNode.java | 12 +- .../number/bigInteger/BitShiftRightNode.java | 9 +- .../builtin/number/decimal/CeilNode.java | 4 +- .../builtin/number/decimal/FloorNode.java | 4 +- .../builtin/number/decimal/TruncateNode.java | 4 +- .../number/smallInteger/BitShiftNode.java | 16 ++- .../smallInteger/BitShiftRightNode.java | 8 +- .../number/utils/ToEnsoNumberNode.java | 4 +- .../ordering/CustomComparatorNode.java | 4 +- .../builtin/ordering/HashCallbackNode.java | 3 + .../builtin/ordering/SortVectorNode.java | 23 ++-- .../builtin/state/RunStateNode.java | 5 +- .../builtin/text/util/ExpectStringNode.java | 2 + .../builtin/text/util/ToJavaStringNode.java | 2 + .../node/expression/debug/EvalNode.java | 9 +- .../expression/foreign/CoerceNothing.java | 4 +- .../runtime/callable/atom/Atom.java | 3 +- .../runtime/callable/function/Function.java | 2 + .../enso/interpreter/runtime/data/Array.java | 10 +- .../interpreter/runtime/data/ArraySlice.java | 18 ++- .../enso/interpreter/runtime/data/Vector.java | 17 ++- .../runtime/data/hash/HashMapGetNode.java | 5 +- .../runtime/error/PanicException.java | 2 + .../runtime/error/WithWarnings.java | 7 +- .../enso/interpreter/dsl/MethodProcessor.java | 6 +- .../builtins/SpecializedMethodParameter.java | 4 +- 73 files changed, 519 insertions(+), 328 deletions(-) diff --git a/engine/runtime-language-epb/src/main/java/org/enso/interpreter/epb/runtime/PolyglotProxy.java b/engine/runtime-language-epb/src/main/java/org/enso/interpreter/epb/runtime/PolyglotProxy.java index 9bb3ecc4f45c..656696a5164d 100644 --- a/engine/runtime-language-epb/src/main/java/org/enso/interpreter/epb/runtime/PolyglotProxy.java +++ b/engine/runtime-language-epb/src/main/java/org/enso/interpreter/epb/runtime/PolyglotProxy.java @@ -17,6 +17,7 @@ import com.oracle.truffle.api.library.ExportLibrary; import com.oracle.truffle.api.library.ExportMessage; import com.oracle.truffle.api.profiles.BranchProfile; +import java.math.BigInteger; import java.time.LocalDate; import java.time.LocalTime; import java.time.ZoneId; @@ -82,7 +83,7 @@ void leaveOrigin(InteropLibrary node, Object prev) { public boolean isNull( @CachedLibrary("this.delegate") InteropLibrary nulls, @CachedLibrary("this") InteropLibrary node, - @CachedLibrary(limit = "5") InteropLibrary errors, + @Shared("interop") @CachedLibrary(limit = "5") InteropLibrary errors, @Exclusive @Cached ContextRewrapExceptionNode contextRewrapExceptionNode, @Exclusive @Cached BranchProfile profile) { Object p = enterOrigin(node); @@ -693,6 +694,30 @@ public boolean fitsInInt( } } + @ExportMessage + public boolean fitsInBigInteger( + @CachedLibrary("this.delegate") InteropLibrary numbers, + @CachedLibrary("this") InteropLibrary node, + @Shared("interop") @CachedLibrary(limit = "5") InteropLibrary errors, + @Exclusive @Cached ContextRewrapExceptionNode contextRewrapExceptionNode, + @Exclusive @Cached BranchProfile profile) { + Object p = enterOrigin(node); + try { + return numbers.fitsInBigInteger(this.delegate); + } catch (Throwable e) { + profile.enter(); + if (errors.isException(e)) { + // `isException` means this must be AbstractTruffleException + //noinspection ConstantConditions + throw contextRewrapExceptionNode.execute((AbstractTruffleException) e, origin, target); + } else { + throw e; + } + } finally { + leaveOrigin(node, p); + } + } + @ExportMessage public boolean fitsInLong( @CachedLibrary("this.delegate") InteropLibrary numbers, @@ -840,6 +865,31 @@ public int asInt( } } + @ExportMessage + public BigInteger asBigInteger( + @CachedLibrary("this.delegate") InteropLibrary numbers, + @CachedLibrary("this") InteropLibrary node, + @Shared("interop") @CachedLibrary(limit = "5") InteropLibrary errors, + @Exclusive @Cached ContextRewrapExceptionNode contextRewrapExceptionNode, + @Exclusive @Cached BranchProfile profile) + throws UnsupportedMessageException { + Object p = enterOrigin(node); + try { + return numbers.asBigInteger(this.delegate); + } catch (Throwable e) { + profile.enter(); + if (errors.isException(e)) { + // `isException` means this must be AbstractTruffleException + //noinspection ConstantConditions + throw contextRewrapExceptionNode.execute((AbstractTruffleException) e, origin, target); + } else { + throw e; + } + } finally { + leaveOrigin(node, p); + } + } + @ExportMessage public long asLong( @CachedLibrary("this.delegate") InteropLibrary numbers, diff --git a/engine/runtime/src/main/java/org/enso/interpreter/node/callable/CaptureCallerInfoNode.java b/engine/runtime/src/main/java/org/enso/interpreter/node/callable/CaptureCallerInfoNode.java index d8487fad705c..8dfd54fd7d8c 100644 --- a/engine/runtime/src/main/java/org/enso/interpreter/node/callable/CaptureCallerInfoNode.java +++ b/engine/runtime/src/main/java/org/enso/interpreter/node/callable/CaptureCallerInfoNode.java @@ -5,6 +5,7 @@ import com.oracle.truffle.api.Truffle; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.GenerateUncached; +import com.oracle.truffle.api.dsl.NeverDefault; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.frame.MaterializedFrame; import com.oracle.truffle.api.nodes.Node; @@ -59,12 +60,14 @@ public ModuleScope getModuleScope() { } } + @NeverDefault ScopeInfo buildScopeInfo() { EnsoRootNode rootNode = (EnsoRootNode) getRootNode(); return new ScopeInfo(rootNode.getLocalScope(), rootNode.getModuleScope()); } @CompilerDirectives.TruffleBoundary + @NeverDefault ScopeInfo buildUncachedScopeInfo() { RootCallTarget ct = Truffle.getRuntime() diff --git a/engine/runtime/src/main/java/org/enso/interpreter/node/callable/ExecuteCallNode.java b/engine/runtime/src/main/java/org/enso/interpreter/node/callable/ExecuteCallNode.java index 6606f73a5e6a..390879210f06 100644 --- a/engine/runtime/src/main/java/org/enso/interpreter/node/callable/ExecuteCallNode.java +++ b/engine/runtime/src/main/java/org/enso/interpreter/node/callable/ExecuteCallNode.java @@ -50,7 +50,7 @@ public static ExecuteCallNode build() { @Specialization(guards = { "function.getCallTarget() == cachedTarget", "callNode != null" - }) + }, limit = "3") protected Object callInlineable( VirtualFrame frame, Function function, @@ -79,7 +79,7 @@ protected Object callInlineable( */ @Specialization(guards = { "function.getCallTarget() == cachedTarget", - }) + }, limit = "3") protected Object callDirect( Function function, CallerInfo callerInfo, diff --git a/engine/runtime/src/main/java/org/enso/interpreter/node/callable/IndirectInvokeConversionNode.java b/engine/runtime/src/main/java/org/enso/interpreter/node/callable/IndirectInvokeConversionNode.java index 7029749f7829..6f117eea487c 100644 --- a/engine/runtime/src/main/java/org/enso/interpreter/node/callable/IndirectInvokeConversionNode.java +++ b/engine/runtime/src/main/java/org/enso/interpreter/node/callable/IndirectInvokeConversionNode.java @@ -1,6 +1,7 @@ package org.enso.interpreter.node.callable; import com.oracle.truffle.api.dsl.*; +import com.oracle.truffle.api.dsl.Cached.Shared; import com.oracle.truffle.api.frame.MaterializedFrame; import com.oracle.truffle.api.interop.InteropLibrary; import com.oracle.truffle.api.interop.UnsupportedMessageException; @@ -42,7 +43,7 @@ public abstract Object execute( BaseNode.TailStatus isTail, int thatArgumentPosition); - @Specialization(guards = {"dispatch.hasType(that)", "!dispatch.hasSpecialDispatch(that)"}) + @Specialization(guards = {"typesLib.hasType(that)", "!typesLib.hasSpecialDispatch(that)"}) Object doConvertFrom( MaterializedFrame frame, Object state, @@ -55,14 +56,15 @@ Object doConvertFrom( InvokeCallableNode.ArgumentsExecutionMode argumentsExecutionMode, BaseNode.TailStatus isTail, int thatArgumentPosition, - @CachedLibrary(limit = "10") TypesLibrary dispatch, - @Cached ConversionResolverNode conversionResolverNode, - @Cached IndirectInvokeFunctionNode indirectInvokeFunctionNode) { + @Shared("typesLib") @CachedLibrary(limit = "10") TypesLibrary typesLib, + @Shared("conversionResolverNode") @Cached ConversionResolverNode conversionResolverNode, + @Shared("indirectInvokeFunctionNode") @Cached + IndirectInvokeFunctionNode indirectInvokeFunctionNode) { Function function = conversionResolverNode.expectNonNull( that, InvokeConversionNode.extractConstructor(this, self), - dispatch.getType(that), + typesLib.getType(that), conversion); return indirectInvokeFunctionNode.execute( function, @@ -88,9 +90,9 @@ Object doDataflowError( InvokeCallableNode.ArgumentsExecutionMode argumentsExecutionMode, BaseNode.TailStatus isTail, int thatArgumentPosition, - @CachedLibrary(limit = "10") TypesLibrary dispatch, - @Cached IndirectInvokeFunctionNode indirectInvokeFunctionNode, - @Cached ConversionResolverNode conversionResolverNode) { + @Shared("indirectInvokeFunctionNode") @Cached + IndirectInvokeFunctionNode indirectInvokeFunctionNode, + @Shared("conversionResolverNode") @Cached ConversionResolverNode conversionResolverNode) { Function function = conversionResolverNode.execute( InvokeConversionNode.extractConstructor(this, self), @@ -172,10 +174,10 @@ Object doConvertText( InvokeCallableNode.ArgumentsExecutionMode argumentsExecutionMode, BaseNode.TailStatus isTail, int thatArgumentPosition, - @CachedLibrary(limit = "10") TypesLibrary methods, - @CachedLibrary(limit = "10") InteropLibrary interop, - @Cached ConversionResolverNode conversionResolverNode, - @Cached IndirectInvokeFunctionNode indirectInvokeFunctionNode) { + @Shared("interop") @CachedLibrary(limit = "10") InteropLibrary interop, + @Shared("conversionResolverNode") @Cached ConversionResolverNode conversionResolverNode, + @Shared("indirectInvokeFunctionNode") @Cached + IndirectInvokeFunctionNode indirectInvokeFunctionNode) { try { String str = interop.asString(that); Text txt = Text.create(str); @@ -218,8 +220,8 @@ Object doFallback( InvokeCallableNode.ArgumentsExecutionMode argumentsExecutionMode, BaseNode.TailStatus isTail, int thatArgumentPosition, - @CachedLibrary(limit = "10") TypesLibrary methods, - @CachedLibrary(limit = "10") InteropLibrary interop) { + @Shared("typesLib") @CachedLibrary(limit = "10") TypesLibrary methods, + @Shared("interop") @CachedLibrary(limit = "10") InteropLibrary interop) { throw new PanicException( EnsoContext.get(this).getBuiltins().error().makeNoSuchConversion(self, that, conversion), this); diff --git a/engine/runtime/src/main/java/org/enso/interpreter/node/callable/IndirectInvokeMethodNode.java b/engine/runtime/src/main/java/org/enso/interpreter/node/callable/IndirectInvokeMethodNode.java index 1e07c4af54a1..02436c21f8d5 100644 --- a/engine/runtime/src/main/java/org/enso/interpreter/node/callable/IndirectInvokeMethodNode.java +++ b/engine/runtime/src/main/java/org/enso/interpreter/node/callable/IndirectInvokeMethodNode.java @@ -2,6 +2,7 @@ import com.oracle.truffle.api.dsl.*; import com.oracle.truffle.api.dsl.Cached; +import com.oracle.truffle.api.dsl.Cached.Shared; import com.oracle.truffle.api.dsl.GenerateUncached; import com.oracle.truffle.api.dsl.ReportPolymorphism; import com.oracle.truffle.api.dsl.Specialization; @@ -60,9 +61,9 @@ Object doFunctionalDispatch( InvokeCallableNode.ArgumentsExecutionMode argumentsExecutionMode, BaseNode.TailStatus isTail, int thisArgumentPosition, - @CachedLibrary(limit = "10") TypesLibrary dispatch, - @Cached MethodResolverNode methodResolverNode, - @Cached IndirectInvokeFunctionNode invokeFunctionNode) { + @Shared("typesLib") @CachedLibrary(limit = "10") TypesLibrary dispatch, + @Shared("methodResolverNode") @Cached MethodResolverNode methodResolverNode, + @Shared("indirectInvokeFunctionNode") @Cached IndirectInvokeFunctionNode invokeFunctionNode) { Function function = methodResolverNode.expectNonNull(self, dispatch.getType(self), symbol); return invokeFunctionNode.execute( function, @@ -87,8 +88,8 @@ Object doDataflowError( InvokeCallableNode.ArgumentsExecutionMode argumentsExecutionMode, BaseNode.TailStatus isTail, int thisArgumentPosition, - @Cached MethodResolverNode methodResolverNode, - @Cached IndirectInvokeFunctionNode invokeFunctionNode, + @Shared("methodResolverNode") @Cached MethodResolverNode methodResolverNode, + @Shared("indirectInvokeFunctionNode") @Cached IndirectInvokeFunctionNode invokeFunctionNode, @Cached ConditionProfile profile) { Function function = methodResolverNode.execute(EnsoContext.get(this).getBuiltins().dataflowError(), symbol); @@ -170,8 +171,8 @@ Object doPolyglot( InvokeCallableNode.ArgumentsExecutionMode argumentsExecutionMode, BaseNode.TailStatus isTail, int thisArgumentPosition, - @CachedLibrary(limit = "10") TypesLibrary methods, - @CachedLibrary(limit = "10") InteropLibrary interop, + @Shared("typesLib") @CachedLibrary(limit = "10") TypesLibrary methods, + @Shared("interopLib") @CachedLibrary(limit = "10") InteropLibrary interop, @Bind("getPolyglotCallType(self, symbol, interop)") HostMethodCallNode.PolyglotCallType polyglotCallType, @Cached ThunkExecutorNode argExecutor, @@ -205,10 +206,10 @@ Object doConvertText( InvokeCallableNode.ArgumentsExecutionMode argumentsExecutionMode, BaseNode.TailStatus isTail, int thisArgumentPosition, - @CachedLibrary(limit = "10") TypesLibrary methods, - @Cached MethodResolverNode methodResolverNode, - @CachedLibrary(limit = "10") InteropLibrary interop, - @Cached IndirectInvokeFunctionNode invokeFunctionNode) { + @Shared("typesLib") @CachedLibrary(limit = "10") TypesLibrary methods, + @Shared("methodResolverNode") @Cached MethodResolverNode methodResolverNode, + @Shared("interopLib") @CachedLibrary(limit = "10") InteropLibrary interop, + @Shared("indirectInvokeFunctionNode") @Cached IndirectInvokeFunctionNode invokeFunctionNode) { try { var str = interop.asString(self); var text = Text.create(str); @@ -248,10 +249,10 @@ Object doFallback( InvokeCallableNode.ArgumentsExecutionMode argumentsExecutionMode, BaseNode.TailStatus isTail, int thisArgumentPosition, - @Cached MethodResolverNode methodResolverNode, - @CachedLibrary(limit = "10") TypesLibrary types, - @CachedLibrary(limit = "10") InteropLibrary interop, - @Cached IndirectInvokeFunctionNode invokeFunctionNode) { + @Shared("methodResolverNode") @Cached MethodResolverNode methodResolverNode, + @Shared("typesLib") @CachedLibrary(limit = "10") TypesLibrary types, + @Shared("interopLib") @CachedLibrary(limit = "10") InteropLibrary interop, + @Shared("indirectInvokeFunctionNode") @Cached IndirectInvokeFunctionNode invokeFunctionNode) { Function function = methodResolverNode.expectNonNull(self, EnsoContext.get(this).getBuiltins().any(), symbol); return invokeFunctionNode.execute( diff --git a/engine/runtime/src/main/java/org/enso/interpreter/node/callable/InteropApplicationNode.java b/engine/runtime/src/main/java/org/enso/interpreter/node/callable/InteropApplicationNode.java index 0c3b7d537dfe..7eb2e1917779 100644 --- a/engine/runtime/src/main/java/org/enso/interpreter/node/callable/InteropApplicationNode.java +++ b/engine/runtime/src/main/java/org/enso/interpreter/node/callable/InteropApplicationNode.java @@ -2,6 +2,7 @@ import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.dsl.*; +import com.oracle.truffle.api.dsl.Cached.Shared; import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.nodes.NodeInfo; import org.enso.interpreter.Constants; @@ -58,6 +59,7 @@ InvokeFunctionNode buildSorter(int length) { InvokeCallableNode.ArgumentsExecutionMode.PRE_EXECUTED); } + @NonIdempotent EnsoContext getContext() { return EnsoContext.get(this); } @@ -71,7 +73,7 @@ Object callCached( Object[] arguments, @Cached("arguments.length") int cachedArgsLength, @Cached("buildSorter(cachedArgsLength)") InvokeFunctionNode sorterNode, - @Cached("build()") HostValueToEnsoNode hostValueToEnsoNode) { + @Shared @Cached("build()") HostValueToEnsoNode hostValueToEnsoNode) { Object[] args = new Object[cachedArgsLength]; for (int i = 0; i < cachedArgsLength; i++) { args[i] = hostValueToEnsoNode.execute(arguments[i]); @@ -85,7 +87,7 @@ Object callUncached( Object state, Object[] arguments, @Cached IndirectInvokeFunctionNode indirectInvokeFunctionNode, - @Cached("build()") HostValueToEnsoNode hostValueToEnsoNode) { + @Shared @Cached("build()") HostValueToEnsoNode hostValueToEnsoNode) { Object[] args = new Object[arguments.length]; for (int i = 0; i < arguments.length; i++) { args[i] = hostValueToEnsoNode.execute(arguments[i]); diff --git a/engine/runtime/src/main/java/org/enso/interpreter/node/callable/InteropConversionCallNode.java b/engine/runtime/src/main/java/org/enso/interpreter/node/callable/InteropConversionCallNode.java index 194b5a80ee5b..d0015980e148 100644 --- a/engine/runtime/src/main/java/org/enso/interpreter/node/callable/InteropConversionCallNode.java +++ b/engine/runtime/src/main/java/org/enso/interpreter/node/callable/InteropConversionCallNode.java @@ -2,7 +2,9 @@ import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.dsl.Cached; +import com.oracle.truffle.api.dsl.Cached.Shared; import com.oracle.truffle.api.dsl.GenerateUncached; +import com.oracle.truffle.api.dsl.NonIdempotent; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.interop.ArityException; import com.oracle.truffle.api.nodes.ExplodeLoop; @@ -46,6 +48,7 @@ InvokeConversionNode buildInvoker(int length) { args, DefaultsExecutionMode.EXECUTE, ArgumentsExecutionMode.PRE_EXECUTED, 1); } + @NonIdempotent EnsoContext getContext() { return EnsoContext.get(this); } @@ -60,7 +63,7 @@ Object callCached( Object[] arguments, @Cached("arguments.length") int cachedArgsLength, @Cached("buildInvoker(cachedArgsLength)") InvokeConversionNode invokerNode, - @Cached("build()") HostValueToEnsoNode hostValueToEnsoNode) + @Shared @Cached("build()") HostValueToEnsoNode hostValueToEnsoNode) throws ArityException { Object[] args = new Object[cachedArgsLength]; for (int i = 0; i < cachedArgsLength; i++) { @@ -76,7 +79,7 @@ Object callUncached( State state, Object[] arguments, @Cached IndirectInvokeConversionNode indirectInvokeConversionNode, - @Cached("build()") HostValueToEnsoNode hostValueToEnsoNode) + @Shared @Cached("build()") HostValueToEnsoNode hostValueToEnsoNode) throws ArityException { Object[] args = new Object[arguments.length]; for (int i = 0; i < arguments.length; i++) { diff --git a/engine/runtime/src/main/java/org/enso/interpreter/node/callable/InteropMethodCallNode.java b/engine/runtime/src/main/java/org/enso/interpreter/node/callable/InteropMethodCallNode.java index 59912eee70f2..156e03f49256 100644 --- a/engine/runtime/src/main/java/org/enso/interpreter/node/callable/InteropMethodCallNode.java +++ b/engine/runtime/src/main/java/org/enso/interpreter/node/callable/InteropMethodCallNode.java @@ -2,7 +2,9 @@ import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.dsl.Cached; +import com.oracle.truffle.api.dsl.Cached.Shared; import com.oracle.truffle.api.dsl.GenerateUncached; +import com.oracle.truffle.api.dsl.NonIdempotent; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.interop.ArityException; import com.oracle.truffle.api.nodes.Node; @@ -61,6 +63,7 @@ InvokeMethodNode buildSorter(int length) { 0); } + @NonIdempotent EnsoContext getContext() { return EnsoContext.get(this); } @@ -74,7 +77,7 @@ Object callCached( Object[] arguments, @Cached("arguments.length") int cachedArgsLength, @Cached("buildSorter(cachedArgsLength)") InvokeMethodNode sorterNode, - @Cached("build()") HostValueToEnsoNode hostValueToEnsoNode) + @Shared @Cached("build()") HostValueToEnsoNode hostValueToEnsoNode) throws ArityException { Object[] args = new Object[cachedArgsLength]; for (int i = 0; i < cachedArgsLength; i++) { @@ -90,7 +93,7 @@ Object callUncached( State state, Object[] arguments, @Cached IndirectInvokeMethodNode indirectInvokeMethodNode, - @Cached("build()") HostValueToEnsoNode hostValueToEnsoNode) + @Shared @Cached("build()") HostValueToEnsoNode hostValueToEnsoNode) throws ArityException { Object[] args = new Object[arguments.length]; for (int i = 0; i < arguments.length; i++) { diff --git a/engine/runtime/src/main/java/org/enso/interpreter/node/callable/InvokeConversionNode.java b/engine/runtime/src/main/java/org/enso/interpreter/node/callable/InvokeConversionNode.java index 252f67ee2da4..9433ad33efdd 100644 --- a/engine/runtime/src/main/java/org/enso/interpreter/node/callable/InvokeConversionNode.java +++ b/engine/runtime/src/main/java/org/enso/interpreter/node/callable/InvokeConversionNode.java @@ -2,6 +2,7 @@ import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.dsl.*; +import com.oracle.truffle.api.dsl.Cached.Shared; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.interop.InteropLibrary; import com.oracle.truffle.api.interop.UnsupportedMessageException; @@ -100,8 +101,8 @@ Object doConvertFrom( Object self, Object that, Object[] arguments, - @CachedLibrary(limit = "10") TypesLibrary dispatch, - @Cached ConversionResolverNode conversionResolverNode) { + @Shared("typesLib") @CachedLibrary(limit = "10") TypesLibrary dispatch, + @Shared("conversionResolverNode") @Cached ConversionResolverNode conversionResolverNode) { Function function = conversionResolverNode.expectNonNull( that, extractConstructor(self), dispatch.getType(that), conversion); @@ -116,8 +117,8 @@ Object doDataflowError( Object self, DataflowError that, Object[] arguments, - @CachedLibrary(limit = "10") TypesLibrary dispatch, - @Cached ConversionResolverNode conversionResolverNode) { + @Shared("typesLib") @CachedLibrary(limit = "10") TypesLibrary dispatch, + @Shared("conversionResolverNode") @Cached ConversionResolverNode conversionResolverNode) { Function function = conversionResolverNode.execute( extractConstructor(self), @@ -190,8 +191,8 @@ Object doConvertText( Object self, Object that, Object[] arguments, - @CachedLibrary(limit = "10") InteropLibrary interop, - @Cached ConversionResolverNode conversionResolverNode) { + @Shared("interop") @CachedLibrary(limit = "10") InteropLibrary interop, + @Shared("conversionResolverNode") @Cached ConversionResolverNode conversionResolverNode) { try { String str = interop.asString(that); Text txt = Text.create(str); @@ -222,9 +223,9 @@ Object doConvertDate( Object self, Object that, Object[] arguments, - @CachedLibrary(limit = "10") InteropLibrary interop, - @CachedLibrary(limit = "10") TypesLibrary typesLib, - @Cached ConversionResolverNode conversionResolverNode) { + @Shared("interop") @CachedLibrary(limit = "10") InteropLibrary interop, + @Shared("typesLib") @CachedLibrary(limit = "10") TypesLibrary typesLib, + @Shared("conversionResolverNode") @Cached ConversionResolverNode conversionResolverNode) { Function function = conversionResolverNode.expectNonNull( that, extractConstructor(self), EnsoContext.get(this).getBuiltins().date(), conversion); @@ -245,9 +246,9 @@ Object doConvertTime( Object self, Object that, Object[] arguments, - @CachedLibrary(limit = "10") InteropLibrary interop, - @CachedLibrary(limit = "10") TypesLibrary typesLib, - @Cached ConversionResolverNode conversionResolverNode) { + @Shared("interop") @CachedLibrary(limit = "10") InteropLibrary interop, + @Shared("typesLib") @CachedLibrary(limit = "10") TypesLibrary typesLib, + @Shared("conversionResolverNode") @Cached ConversionResolverNode conversionResolverNode) { Function function = conversionResolverNode.expectNonNull( that, @@ -271,9 +272,9 @@ Object doConvertDateTime( Object self, Object that, Object[] arguments, - @CachedLibrary(limit = "10") InteropLibrary interop, - @CachedLibrary(limit = "10") TypesLibrary typesLib, - @Cached ConversionResolverNode conversionResolverNode) { + @Shared("interop") @CachedLibrary(limit = "10") InteropLibrary interop, + @Shared("typesLib") @CachedLibrary(limit = "10") TypesLibrary typesLib, + @Shared("conversionResolverNode") @Cached ConversionResolverNode conversionResolverNode) { Function function = conversionResolverNode.expectNonNull( that, @@ -296,9 +297,9 @@ Object doConvertDuration( Object self, Object that, Object[] arguments, - @CachedLibrary(limit = "10") InteropLibrary interop, - @CachedLibrary(limit = "10") TypesLibrary typesLib, - @Cached ConversionResolverNode conversionResolverNode) { + @Shared("interop") @CachedLibrary(limit = "10") InteropLibrary interop, + @Shared("typesLib") @CachedLibrary(limit = "10") TypesLibrary typesLib, + @Shared("conversionResolverNode") @Cached ConversionResolverNode conversionResolverNode) { Function function = conversionResolverNode.expectNonNull( that, @@ -321,9 +322,9 @@ Object doConvertMap( Object self, Object thatMap, Object[] arguments, - @CachedLibrary(limit = "10") InteropLibrary interop, - @CachedLibrary(limit = "10") TypesLibrary typesLib, - @Cached ConversionResolverNode conversionResolverNode) { + @Shared("interop") @CachedLibrary(limit = "10") InteropLibrary interop, + @Shared("typesLib") @CachedLibrary(limit = "10") TypesLibrary typesLib, + @Shared("conversionResolverNode") @Cached ConversionResolverNode conversionResolverNode) { Function function = conversionResolverNode.expectNonNull( thatMap, @@ -346,9 +347,9 @@ Object doFallback( Object self, Object that, Object[] arguments, - @CachedLibrary(limit = "10") TypesLibrary methods, - @CachedLibrary(limit = "10") InteropLibrary interop, - @Cached ConversionResolverNode conversionResolverNode) { + @Shared("typesLib") @CachedLibrary(limit = "10") TypesLibrary methods, + @Shared("interop") @CachedLibrary(limit = "10") InteropLibrary interop, + @Shared("conversionResolverNode") @Cached ConversionResolverNode conversionResolverNode) { var ctx = EnsoContext.get(this); var function = conversionResolverNode.execute( diff --git a/engine/runtime/src/main/java/org/enso/interpreter/node/callable/InvokeMethodNode.java b/engine/runtime/src/main/java/org/enso/interpreter/node/callable/InvokeMethodNode.java index 913ce252c2fa..e22735fbef92 100644 --- a/engine/runtime/src/main/java/org/enso/interpreter/node/callable/InvokeMethodNode.java +++ b/engine/runtime/src/main/java/org/enso/interpreter/node/callable/InvokeMethodNode.java @@ -3,7 +3,9 @@ import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; +import com.oracle.truffle.api.dsl.Cached.Shared; import com.oracle.truffle.api.dsl.ImportStatic; +import com.oracle.truffle.api.dsl.NonIdempotent; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.interop.InteropLibrary; @@ -14,6 +16,7 @@ import com.oracle.truffle.api.nodes.RootNode; import com.oracle.truffle.api.profiles.BranchProfile; import com.oracle.truffle.api.profiles.ConditionProfile; +import com.oracle.truffle.api.profiles.CountingConditionProfile; import com.oracle.truffle.api.source.SourceSection; import java.time.LocalDate; import java.time.LocalTime; @@ -69,7 +72,7 @@ public abstract class InvokeMethodNode extends BaseNode { */ private @Child InvokeFunctionNode invokeAnyStaticFunctionNode; - private final ConditionProfile errorReceiverProfile = ConditionProfile.createCountingProfile(); + private final CountingConditionProfile errorReceiverProfile = CountingConditionProfile.create(); private @Child InvokeMethodNode childDispatch; private final int argumentCount; @@ -119,6 +122,7 @@ public void setTailStatus(TailStatus tailStatus) { public abstract Object execute( VirtualFrame frame, State state, UnresolvedSymbol symbol, Object self, Object[] arguments); + @NonIdempotent boolean isAnyEigenType(Type type) { return EnsoContext.get(this).getBuiltins().any().getEigentype() == type; } @@ -139,8 +143,8 @@ Object doFunctionalDispatchCachedSymbol( UnresolvedSymbol symbol, Object self, Object[] arguments, - @CachedLibrary(limit = "10") TypesLibrary typesLibrary, - @Cached MethodResolverNode methodResolverNode, + @Shared("typesLib") @CachedLibrary(limit = "10") TypesLibrary typesLibrary, + @Shared("methodResolverNode") @Cached MethodResolverNode methodResolverNode, @Cached("symbol") UnresolvedSymbol cachedSymbol, @Cached("typesLibrary.getType(self)") Type cachedSelfTpe, @Cached("resolveFunction(cachedSymbol, cachedSelfTpe, methodResolverNode)") @@ -184,6 +188,7 @@ private boolean typeCanOverride(MethodRootNode node, EnsoContext ctx) { && warning.getEigentype() != methodOwnerType; } + @NonIdempotent @Specialization( replaces = "doFunctionalDispatchCachedSymbol", guards = {"typesLibrary.hasType(self)", "!typesLibrary.hasSpecialDispatch(self)"}) @@ -193,8 +198,8 @@ Object doFunctionalDispatchUncachedSymbol( UnresolvedSymbol symbol, Object self, Object[] arguments, - @CachedLibrary(limit = "10") TypesLibrary typesLibrary, - @Cached MethodResolverNode methodResolverNode) { + @Shared("typesLib") @CachedLibrary(limit = "10") TypesLibrary typesLibrary, + @Shared("methodResolverNode") @Cached MethodResolverNode methodResolverNode) { Type selfTpe = typesLibrary.getType(self); Function function = resolveFunction(symbol, selfTpe, methodResolverNode); if (function == null) { @@ -267,7 +272,7 @@ Object doDataflowError( UnresolvedSymbol symbol, DataflowError self, Object[] arguments, - @Cached MethodResolverNode methodResolverNode) { + @Shared("methodResolverNode") @Cached MethodResolverNode methodResolverNode) { Function function = methodResolverNode.execute(EnsoContext.get(this).getBuiltins().dataflowError(), symbol); if (errorReceiverProfile.profile(function == null)) { @@ -350,6 +355,7 @@ public InvokeFunctionNode buildInvokeFunctionWithSelf() { invokeFunctionNode.getArgumentsExecutionMode()); } + @NonIdempotent @Specialization( guards = { "warnings.hasWarnings(self)", @@ -362,8 +368,8 @@ Object doWarningsCustom( UnresolvedSymbol symbol, Object self, Object[] arguments, - @CachedLibrary(limit = "10") TypesLibrary types, - @CachedLibrary(limit = "10") WarningsLibrary warnings, + @Shared("typesLib") @CachedLibrary(limit = "10") TypesLibrary types, + @Shared("warnsLib") @CachedLibrary(limit = "10") WarningsLibrary warnings, @Cached("resolveWarningFunction(self, symbol, types, warnings)") Function resolvedFunction, @Cached("resolvedFunction.getSchema()") FunctionSchema cachedSchema, @Cached("buildInvokeFunctionWithSelf()") InvokeFunctionNode warningFunctionNode) { @@ -376,6 +382,7 @@ Object doWarningsCustom( return warningFunctionNode.execute(resolvedFunction, frame, state, arguments1); } + @NonIdempotent @Specialization(guards = "warnings.hasWarnings(self)") Object doWarning( VirtualFrame frame, @@ -383,7 +390,7 @@ Object doWarning( UnresolvedSymbol symbol, Object self, Object[] arguments, - @CachedLibrary(limit = "10") WarningsLibrary warnings) { + @Shared("warnsLib") @CachedLibrary(limit = "10") WarningsLibrary warnings) { Object selfWithoutWarnings; Warning[] arrOfWarnings; try { @@ -427,6 +434,7 @@ Object doWarning( } } + @NonIdempotent @ExplodeLoop @Specialization( guards = { @@ -434,17 +442,17 @@ Object doWarning( "!methods.hasType(self)", "!methods.hasSpecialDispatch(self)", "polyglotCallType.isInteropLibrary()", - }) + }, limit = "3") Object doPolyglot( VirtualFrame frame, State state, UnresolvedSymbol symbol, Object self, Object[] arguments, - @CachedLibrary(limit = "10") TypesLibrary methods, - @CachedLibrary(limit = "10") InteropLibrary interop, - @CachedLibrary(limit = "10") WarningsLibrary warnings, - @Cached MethodResolverNode preResolveMethod, + @Shared("typesLib") @CachedLibrary(limit = "10") TypesLibrary methods, + @Shared("interop") @CachedLibrary(limit = "10") InteropLibrary interop, + @Shared("warnsLib") @CachedLibrary(limit = "10") WarningsLibrary warnings, + @Shared("methodResolverNode") @Cached MethodResolverNode preResolveMethod, @Bind("getPolyglotCallType(self, symbol, interop, preResolveMethod)") HostMethodCallNode.PolyglotCallType polyglotCallType, @Cached(value = "buildExecutors()") ThunkExecutorNode[] argExecutors, @@ -481,6 +489,7 @@ Object doPolyglot( return res; } + @NonIdempotent @Specialization( guards = { "!warnings.hasWarnings(self)", @@ -494,10 +503,10 @@ Object doConvertText( UnresolvedSymbol symbol, Object self, Object[] arguments, - @CachedLibrary(limit = "10") InteropLibrary interop, - @CachedLibrary(limit = "10") TypesLibrary types, - @CachedLibrary(limit = "10") WarningsLibrary warnings, - @Cached MethodResolverNode methodResolverNode) { + @Shared("interop") @CachedLibrary(limit = "10") InteropLibrary interop, + @Shared("typesLib") @CachedLibrary(limit = "10") TypesLibrary types, + @Shared("warnsLib") @CachedLibrary(limit = "10") WarningsLibrary warnings, + @Shared("methodResolverNode") @Cached MethodResolverNode methodResolverNode) { try { var str = interop.asString(self); var text = Text.create(str); @@ -511,23 +520,24 @@ Object doConvertText( } } + @NonIdempotent @Specialization( guards = { "!warnings.hasWarnings(self)", "!types.hasType(self)", "!types.hasSpecialDispatch(self)", "getPolyglotCallType(self, symbol, interop, methodResolverNode) == CONVERT_TO_ARRAY", - }) + }, limit = "3") Object doConvertArray( VirtualFrame frame, State state, UnresolvedSymbol symbol, Object self, Object[] arguments, - @CachedLibrary(limit = "10") InteropLibrary interop, - @CachedLibrary(limit = "10") TypesLibrary types, - @CachedLibrary(limit = "10") WarningsLibrary warnings, - @Cached MethodResolverNode methodResolverNode) { + @Shared("interop") @CachedLibrary(limit = "10") InteropLibrary interop, + @Shared("typesLib") @CachedLibrary(limit = "10") TypesLibrary types, + @Shared("warnsLib") @CachedLibrary(limit = "10") WarningsLibrary warnings, + @Shared("methodResolverNode") @Cached MethodResolverNode methodResolverNode) { var ctx = EnsoContext.get(this); var arrayType = ctx.getBuiltins().array(); var function = methodResolverNode.expectNonNull(self, arrayType, symbol); @@ -535,23 +545,24 @@ Object doConvertArray( return invokeFunctionNode.execute(function, frame, state, arguments); } + @NonIdempotent @Specialization( guards = { "!warnings.hasWarnings(self)", "!types.hasType(self)", "!types.hasSpecialDispatch(self)", "getPolyglotCallType(self, symbol, interop, methodResolverNode) == CONVERT_TO_HASH_MAP", - }) + }, limit = "3") Object doConvertHashMap( VirtualFrame frame, State state, UnresolvedSymbol symbol, Object self, Object[] arguments, - @CachedLibrary(limit = "10") InteropLibrary interop, - @CachedLibrary(limit = "10") TypesLibrary types, - @CachedLibrary(limit = "10") WarningsLibrary warnings, - @Cached MethodResolverNode methodResolverNode) { + @Shared("interop") @CachedLibrary(limit = "10") InteropLibrary interop, + @Shared("typesLib") @CachedLibrary(limit = "10") TypesLibrary types, + @Shared("warnsLib") @CachedLibrary(limit = "10") WarningsLibrary warnings, + @Shared("methodResolverNode") @Cached MethodResolverNode methodResolverNode) { var ctx = EnsoContext.get(this); var hashMapType = ctx.getBuiltins().map(); var function = methodResolverNode.expectNonNull(self, hashMapType, symbol); @@ -559,6 +570,7 @@ Object doConvertHashMap( return invokeFunctionNode.execute(function, frame, state, arguments); } + @NonIdempotent @Specialization( guards = { "!warnings.hasWarnings(self)", @@ -572,10 +584,10 @@ Object doConvertDate( UnresolvedSymbol symbol, Object self, Object[] arguments, - @CachedLibrary(limit = "10") TypesLibrary types, - @CachedLibrary(limit = "10") InteropLibrary interop, - @CachedLibrary(limit = "10") WarningsLibrary warnings, - @Cached MethodResolverNode methodResolverNode) { + @Shared("typesLib") @CachedLibrary(limit = "10") TypesLibrary types, + @Shared("interop") @CachedLibrary(limit = "10") InteropLibrary interop, + @Shared("warnsLib") @CachedLibrary(limit = "10") WarningsLibrary warnings, + @Shared("methodResolverNode") @Cached MethodResolverNode methodResolverNode) { var ctx = EnsoContext.get(this); try { var hostLocalDate = interop.asDate(self); @@ -589,6 +601,7 @@ Object doConvertDate( } } + @NonIdempotent @Specialization( guards = { "!warnings.hasWarnings(self)", @@ -602,10 +615,10 @@ Object doConvertDateTime( UnresolvedSymbol symbol, Object self, Object[] arguments, - @CachedLibrary(limit = "10") TypesLibrary types, - @CachedLibrary(limit = "10") InteropLibrary interop, - @CachedLibrary(limit = "10") WarningsLibrary warnings, - @Cached MethodResolverNode methodResolverNode) { + @Shared("typesLib") @CachedLibrary(limit = "10") TypesLibrary types, + @Shared("interop") @CachedLibrary(limit = "10") InteropLibrary interop, + @Shared("warnsLib") @CachedLibrary(limit = "10") WarningsLibrary warnings, + @Shared("methodResolverNode") @Cached MethodResolverNode methodResolverNode) { var ctx = EnsoContext.get(this); try { var hostLocalDate = interop.asDate(self); @@ -621,6 +634,7 @@ Object doConvertDateTime( } } + @NonIdempotent @Specialization( guards = { "!warnings.hasWarnings(self)", @@ -634,10 +648,10 @@ Object doConvertDuration( UnresolvedSymbol symbol, Object self, Object[] arguments, - @CachedLibrary(limit = "10") TypesLibrary types, - @CachedLibrary(limit = "10") InteropLibrary interop, - @CachedLibrary(limit = "10") WarningsLibrary warnings, - @Cached MethodResolverNode methodResolverNode) { + @Shared("typesLib") @CachedLibrary(limit = "10") TypesLibrary types, + @Shared("interop") @CachedLibrary(limit = "10") InteropLibrary interop, + @Shared("warnsLib") @CachedLibrary(limit = "10") WarningsLibrary warnings, + @Shared("methodResolverNode") @Cached MethodResolverNode methodResolverNode) { var ctx = EnsoContext.get(this); try { var duration = interop.asDuration(self); @@ -661,6 +675,7 @@ private ZonedDateTime dateTime(LocalDate date, LocalTime time, ZoneId zone) { return date.atTime(time).atZone(zone); } + @NonIdempotent @Specialization( guards = { "!warnings.hasWarnings(self)", @@ -674,10 +689,10 @@ Object doConvertZonedDateTime( UnresolvedSymbol symbol, Object self, Object[] arguments, - @CachedLibrary(limit = "10") TypesLibrary types, - @CachedLibrary(limit = "10") InteropLibrary interop, - @CachedLibrary(limit = "10") WarningsLibrary warnings, - @Cached MethodResolverNode methodResolverNode) { + @Shared("typesLib") @CachedLibrary(limit = "10") TypesLibrary types, + @Shared("interop") @CachedLibrary(limit = "10") InteropLibrary interop, + @Shared("warnsLib") @CachedLibrary(limit = "10") WarningsLibrary warnings, + @Shared("methodResolverNode") @Cached MethodResolverNode methodResolverNode) { var ctx = EnsoContext.get(this); try { var hostLocalDate = interop.asDate(self); @@ -693,6 +708,7 @@ Object doConvertZonedDateTime( } } + @NonIdempotent @Specialization( guards = { "!warnings.hasWarnings(self)", @@ -706,10 +722,10 @@ Object doConvertZone( UnresolvedSymbol symbol, Object self, Object[] arguments, - @CachedLibrary(limit = "10") TypesLibrary types, - @CachedLibrary(limit = "10") InteropLibrary interop, - @CachedLibrary(limit = "10") WarningsLibrary warnings, - @Cached MethodResolverNode methodResolverNode) { + @Shared("typesLib") @CachedLibrary(limit = "10") TypesLibrary types, + @Shared("interop") @CachedLibrary(limit = "10") InteropLibrary interop, + @Shared("warnsLib") @CachedLibrary(limit = "10") WarningsLibrary warnings, + @Shared("methodResolverNode") @Cached MethodResolverNode methodResolverNode) { var ctx = EnsoContext.get(this); try { var hostZone = interop.asTimeZone(self); @@ -723,6 +739,7 @@ Object doConvertZone( } } + @NonIdempotent @Specialization( guards = { "!warnings.hasWarnings(self)", @@ -736,10 +753,10 @@ Object doConvertTimeOfDay( UnresolvedSymbol symbol, Object self, Object[] arguments, - @CachedLibrary(limit = "10") TypesLibrary types, - @CachedLibrary(limit = "10") InteropLibrary interop, - @CachedLibrary(limit = "10") WarningsLibrary warnings, - @Cached MethodResolverNode methodResolverNode) { + @Shared("typesLib") @CachedLibrary(limit = "10") TypesLibrary types, + @Shared("interop") @CachedLibrary(limit = "10") InteropLibrary interop, + @Shared("warnsLib") @CachedLibrary(limit = "10") WarningsLibrary warnings, + @Shared("methodResolverNode") @Cached MethodResolverNode methodResolverNode) { var ctx = EnsoContext.get(this); try { var hostLocalTime = interop.asTime(self); @@ -753,6 +770,7 @@ Object doConvertTimeOfDay( } } + @NonIdempotent @Specialization( guards = { "!warnings.hasWarnings(self)", @@ -766,10 +784,10 @@ Object doFallback( UnresolvedSymbol symbol, Object self, Object[] arguments, - @CachedLibrary(limit = "10") TypesLibrary methods, - @CachedLibrary(limit = "10") InteropLibrary interop, - @CachedLibrary(limit = "10") WarningsLibrary warnings, - @Cached MethodResolverNode resolverNode) { + @Shared("typesLib") @CachedLibrary(limit = "10") TypesLibrary methods, + @Shared("interop") @CachedLibrary(limit = "10") InteropLibrary interop, + @Shared("warnsLib") @CachedLibrary(limit = "10") WarningsLibrary warnings, + @Shared("methodResolverNode") @Cached MethodResolverNode resolverNode) { var ctx = EnsoContext.get(this); Function function = resolverNode.expectNonNull(self, ctx.getBuiltins().function(), symbol); return invokeFunctionNode.execute(function, frame, state, arguments); diff --git a/engine/runtime/src/main/java/org/enso/interpreter/node/callable/argument/ReadArgumentNode.java b/engine/runtime/src/main/java/org/enso/interpreter/node/callable/argument/ReadArgumentNode.java index c7673858e1ed..a35a0eb4fbf6 100644 --- a/engine/runtime/src/main/java/org/enso/interpreter/node/callable/argument/ReadArgumentNode.java +++ b/engine/runtime/src/main/java/org/enso/interpreter/node/callable/argument/ReadArgumentNode.java @@ -5,6 +5,7 @@ import com.oracle.truffle.api.nodes.ExplodeLoop; import com.oracle.truffle.api.nodes.NodeInfo; import com.oracle.truffle.api.profiles.ConditionProfile; +import com.oracle.truffle.api.profiles.CountingConditionProfile; import java.util.Arrays; import java.util.List; import java.util.stream.Collectors; @@ -26,7 +27,7 @@ public class ReadArgumentNode extends ExpressionNode { private final int index; @Child ExpressionNode defaultValue; @Child IsValueOfTypeNode checkType; - private final ConditionProfile defaultingProfile = ConditionProfile.createCountingProfile(); + private final CountingConditionProfile defaultingProfile = CountingConditionProfile.create(); // XXX: Type in a Node is wrong!!!!! @CompilerDirectives.CompilationFinal(dimensions = 1) private final Type[] expectedTypes; diff --git a/engine/runtime/src/main/java/org/enso/interpreter/node/callable/dispatch/InvokeFunctionNode.java b/engine/runtime/src/main/java/org/enso/interpreter/node/callable/dispatch/InvokeFunctionNode.java index 6d8d55709c5d..db379e8a1ced 100644 --- a/engine/runtime/src/main/java/org/enso/interpreter/node/callable/dispatch/InvokeFunctionNode.java +++ b/engine/runtime/src/main/java/org/enso/interpreter/node/callable/dispatch/InvokeFunctionNode.java @@ -2,6 +2,8 @@ import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.ImportStatic; +import com.oracle.truffle.api.dsl.NeverDefault; +import com.oracle.truffle.api.dsl.NonIdempotent; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.Node; @@ -67,6 +69,7 @@ public static InvokeFunctionNode build( * @param arity number of arguments to pass to the function * @return instance of this node to handle a {@code arity}-arity function invocation */ + @NeverDefault public static InvokeFunctionNode buildWithArity(int arity) { var schema = new CallArgumentInfo[arity]; for (int idx = 0; idx < schema.length; idx++) { @@ -78,6 +81,7 @@ public static InvokeFunctionNode buildWithArity(int arity) { InvokeCallableNode.ArgumentsExecutionMode.EXECUTE); } + @NonIdempotent EnsoContext getContext() { return EnsoContext.get(this); } diff --git a/engine/runtime/src/main/java/org/enso/interpreter/node/callable/dispatch/LoopingCallOptimiserNode.java b/engine/runtime/src/main/java/org/enso/interpreter/node/callable/dispatch/LoopingCallOptimiserNode.java index ddb34a735aa6..7508db56209d 100644 --- a/engine/runtime/src/main/java/org/enso/interpreter/node/callable/dispatch/LoopingCallOptimiserNode.java +++ b/engine/runtime/src/main/java/org/enso/interpreter/node/callable/dispatch/LoopingCallOptimiserNode.java @@ -3,7 +3,9 @@ import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.Truffle; import com.oracle.truffle.api.dsl.Cached; +import com.oracle.truffle.api.dsl.Cached.Shared; import com.oracle.truffle.api.dsl.GenerateUncached; +import com.oracle.truffle.api.dsl.NeverDefault; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.frame.FrameDescriptor; import com.oracle.truffle.api.frame.FrameSlotKind; @@ -64,7 +66,7 @@ public Object cachedDispatch( State state, Object[] arguments, Warning[] warnings, - @Cached(value = "createLoopNode()") LoopNode loopNode) { + @Shared("loopNode") @Cached(value = "createLoopNode()") LoopNode loopNode) { return dispatch(function, callerInfo, state, arguments, loopNode); } @@ -75,7 +77,7 @@ public Object cachedDispatchWarnings( State state, Object[] arguments, Warning[] warnings, - @Cached(value = "createLoopNode()") LoopNode loopNode) { + @Shared("loopNode") @Cached(value = "createLoopNode()") LoopNode loopNode) { Object result = dispatch(function, callerInfo, state, arguments, loopNode); return WithWarnings.appendTo(EnsoContext.get(this), result, warnings); } @@ -103,7 +105,7 @@ public Object uncachedDispatch( State state, Object[] arguments, Warning[] warnings, - @Cached ExecuteCallNode executeCallNode) { + @Shared("executeCallNode") @Cached ExecuteCallNode executeCallNode) { return loopUntilCompletion(frame, function, callerInfo, state, arguments, executeCallNode); } @@ -116,7 +118,7 @@ public Object uncachedDispatchWarnings( State state, Object[] arguments, Warning[] warnings, - @Cached ExecuteCallNode executeCallNode) { + @Shared("executeCallNode") @Cached ExecuteCallNode executeCallNode) { Object result = loopUntilCompletion(frame, function, callerInfo, state, arguments, executeCallNode); return WithWarnings.appendTo(EnsoContext.get(this), result, warnings); @@ -145,6 +147,7 @@ private Object loopUntilCompletion( * * @return a loop node */ + @NeverDefault static LoopNode createLoopNode() { return Truffle.getRuntime().createLoopNode(new RepeatedCallNode()); } diff --git a/engine/runtime/src/main/java/org/enso/interpreter/node/callable/resolver/ConversionResolverNode.java b/engine/runtime/src/main/java/org/enso/interpreter/node/callable/resolver/ConversionResolverNode.java index 5f15af18cc37..8de016e91ed2 100644 --- a/engine/runtime/src/main/java/org/enso/interpreter/node/callable/resolver/ConversionResolverNode.java +++ b/engine/runtime/src/main/java/org/enso/interpreter/node/callable/resolver/ConversionResolverNode.java @@ -3,6 +3,7 @@ import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.GenerateUncached; +import com.oracle.truffle.api.dsl.NonIdempotent; import com.oracle.truffle.api.dsl.ReportPolymorphism; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.nodes.Node; @@ -17,6 +18,7 @@ public abstract class ConversionResolverNode extends Node { static final int CACHE_SIZE = 10; + @NonIdempotent EnsoContext getContext() { return EnsoContext.get(this); } diff --git a/engine/runtime/src/main/java/org/enso/interpreter/node/callable/resolver/HostMethodCallNode.java b/engine/runtime/src/main/java/org/enso/interpreter/node/callable/resolver/HostMethodCallNode.java index fa9d6f62ce71..9399ad67ad1c 100644 --- a/engine/runtime/src/main/java/org/enso/interpreter/node/callable/resolver/HostMethodCallNode.java +++ b/engine/runtime/src/main/java/org/enso/interpreter/node/callable/resolver/HostMethodCallNode.java @@ -1,6 +1,7 @@ package org.enso.interpreter.node.callable.resolver; import com.oracle.truffle.api.dsl.Cached; +import com.oracle.truffle.api.dsl.Cached.Shared; import com.oracle.truffle.api.dsl.GenerateUncached; import com.oracle.truffle.api.dsl.ImportStatic; import com.oracle.truffle.api.dsl.ReportPolymorphism; @@ -202,8 +203,8 @@ Object resolveHostMethod( String symbol, Object self, Object[] args, - @CachedLibrary(limit = "LIB_LIMIT") InteropLibrary members, - @Cached HostValueToEnsoNode hostValueToEnsoNode) { + @Shared("interop") @CachedLibrary(limit = "LIB_LIMIT") InteropLibrary members, + @Shared("hostValueToEnsoNode") @Cached HostValueToEnsoNode hostValueToEnsoNode) { try { return hostValueToEnsoNode.execute(members.invokeMember(self, symbol, args)); } catch (UnsupportedMessageException | UnknownIdentifierException e) { @@ -232,8 +233,8 @@ Object resolveHostField( String symbol, Object self, Object[] args, - @CachedLibrary(limit = "LIB_LIMIT") InteropLibrary members, - @Cached HostValueToEnsoNode hostValueToEnsoNode, + @Shared("interop") @CachedLibrary(limit = "LIB_LIMIT") InteropLibrary members, + @Shared("hostValueToEnsoNode") @Cached HostValueToEnsoNode hostValueToEnsoNode, @Cached BranchProfile errorProfile) { if (args.length != 0) { errorProfile.enter(); @@ -254,8 +255,8 @@ Object resolveHostConstructor( String symbol, Object self, Object[] args, - @CachedLibrary(limit = "LIB_LIMIT") InteropLibrary instances, - @Cached HostValueToEnsoNode hostValueToEnsoNode) { + @Shared("interop") @CachedLibrary(limit = "LIB_LIMIT") InteropLibrary instances, + @Shared("hostValueToEnsoNode") @Cached HostValueToEnsoNode hostValueToEnsoNode) { try { return hostValueToEnsoNode.execute(instances.instantiate(self, args)); } catch (UnsupportedMessageException e) { diff --git a/engine/runtime/src/main/java/org/enso/interpreter/node/callable/resolver/MethodResolverNode.java b/engine/runtime/src/main/java/org/enso/interpreter/node/callable/resolver/MethodResolverNode.java index 2195d0ec9c02..188e4ccffd0f 100644 --- a/engine/runtime/src/main/java/org/enso/interpreter/node/callable/resolver/MethodResolverNode.java +++ b/engine/runtime/src/main/java/org/enso/interpreter/node/callable/resolver/MethodResolverNode.java @@ -2,6 +2,7 @@ import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.GenerateUncached; +import com.oracle.truffle.api.dsl.NonIdempotent; import com.oracle.truffle.api.dsl.ReportPolymorphism; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.nodes.Node; @@ -16,6 +17,7 @@ public abstract class MethodResolverNode extends Node { protected static final int CACHE_SIZE = 10; + @NonIdempotent EnsoContext getContext() { return EnsoContext.get(this); } diff --git a/engine/runtime/src/main/java/org/enso/interpreter/node/callable/thunk/ThunkExecutorNode.java b/engine/runtime/src/main/java/org/enso/interpreter/node/callable/thunk/ThunkExecutorNode.java index 914e3d79b88e..7c9ef8943bb2 100644 --- a/engine/runtime/src/main/java/org/enso/interpreter/node/callable/thunk/ThunkExecutorNode.java +++ b/engine/runtime/src/main/java/org/enso/interpreter/node/callable/thunk/ThunkExecutorNode.java @@ -30,6 +30,7 @@ public abstract class ThunkExecutorNode extends Node { * * @return an instance of this node */ + @NeverDefault public static ThunkExecutorNode build() { return ThunkExecutorNodeGen.create(); } diff --git a/engine/runtime/src/main/java/org/enso/interpreter/node/controlflow/caseexpr/BooleanBranchNode.java b/engine/runtime/src/main/java/org/enso/interpreter/node/controlflow/caseexpr/BooleanBranchNode.java index 4c086150c285..ad82c644d3d3 100644 --- a/engine/runtime/src/main/java/org/enso/interpreter/node/controlflow/caseexpr/BooleanBranchNode.java +++ b/engine/runtime/src/main/java/org/enso/interpreter/node/controlflow/caseexpr/BooleanBranchNode.java @@ -5,13 +5,13 @@ import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.NodeInfo; -import com.oracle.truffle.api.profiles.ConditionProfile; +import com.oracle.truffle.api.profiles.CountingConditionProfile; /** An implementation of the case expression specialised to working on booleans. */ @NodeInfo(shortName = "BooleanMatch") public abstract class BooleanBranchNode extends BranchNode { private final boolean matched; - private final ConditionProfile profile = ConditionProfile.createCountingProfile(); + private final CountingConditionProfile profile = CountingConditionProfile.create(); BooleanBranchNode(boolean matched, RootCallTarget branch, boolean terminalBranch) { super(branch, terminalBranch); diff --git a/engine/runtime/src/main/java/org/enso/interpreter/node/controlflow/caseexpr/BranchNode.java b/engine/runtime/src/main/java/org/enso/interpreter/node/controlflow/caseexpr/BranchNode.java index 73200a813bc4..aceac105f1f7 100644 --- a/engine/runtime/src/main/java/org/enso/interpreter/node/controlflow/caseexpr/BranchNode.java +++ b/engine/runtime/src/main/java/org/enso/interpreter/node/controlflow/caseexpr/BranchNode.java @@ -4,7 +4,7 @@ import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.DirectCallNode; import com.oracle.truffle.api.nodes.NodeInfo; -import com.oracle.truffle.api.profiles.ConditionProfile; +import com.oracle.truffle.api.profiles.CountingConditionProfile; import org.enso.interpreter.node.BaseNode; import org.enso.interpreter.runtime.callable.function.Function; @@ -14,9 +14,9 @@ public abstract class BranchNode extends BaseNode { private @Child DirectCallNode callNode; private final boolean terminalBranch; - private final ConditionProfile finalBranchProfiler = ConditionProfile.createCountingProfile(); - private final ConditionProfile propgateResultProfiler = ConditionProfile.createCountingProfile(); - private final ConditionProfile ensureWrappedProfiler = ConditionProfile.createCountingProfile(); + private final CountingConditionProfile finalBranchProfiler = CountingConditionProfile.create(); + private final CountingConditionProfile propgateResultProfiler = CountingConditionProfile.create(); + private final CountingConditionProfile ensureWrappedProfiler = CountingConditionProfile.create(); BranchNode(RootCallTarget branch, boolean terminalBranch) { this.callNode = DirectCallNode.create(branch); diff --git a/engine/runtime/src/main/java/org/enso/interpreter/node/controlflow/caseexpr/CaseNode.java b/engine/runtime/src/main/java/org/enso/interpreter/node/controlflow/caseexpr/CaseNode.java index 6e1cd3042709..f75f87ccf200 100644 --- a/engine/runtime/src/main/java/org/enso/interpreter/node/controlflow/caseexpr/CaseNode.java +++ b/engine/runtime/src/main/java/org/enso/interpreter/node/controlflow/caseexpr/CaseNode.java @@ -1,6 +1,7 @@ package org.enso.interpreter.node.controlflow.caseexpr; import com.oracle.truffle.api.CompilerDirectives; +import com.oracle.truffle.api.dsl.Cached.Shared; import com.oracle.truffle.api.dsl.NodeChild; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.frame.VirtualFrame; @@ -8,7 +9,7 @@ import com.oracle.truffle.api.library.CachedLibrary; import com.oracle.truffle.api.nodes.ExplodeLoop; import com.oracle.truffle.api.nodes.NodeInfo; -import com.oracle.truffle.api.profiles.ConditionProfile; +import com.oracle.truffle.api.profiles.CountingConditionProfile; import org.enso.interpreter.node.ExpressionNode; import org.enso.interpreter.runtime.EnsoContext; import org.enso.interpreter.runtime.callable.function.Function; @@ -30,7 +31,7 @@ public abstract class CaseNode extends ExpressionNode { @Children private final BranchNode[] cases; private final boolean isNested; - private final ConditionProfile fallthroughProfile = ConditionProfile.createCountingProfile(); + private final CountingConditionProfile fallthroughProfile = CountingConditionProfile.create(); CaseNode(boolean isNested, BranchNode[] cases) { this.cases = cases; @@ -79,7 +80,9 @@ public Object doPanicSentinel(VirtualFrame frame, PanicSentinel sentinel) { @Specialization(guards = {"object != null", "warnings.hasWarnings(object)"}) Object doWarning( - VirtualFrame frame, Object object, @CachedLibrary(limit = "3") WarningsLibrary warnings) { + VirtualFrame frame, + Object object, + @Shared("warnsLib") @CachedLibrary(limit = "3") WarningsLibrary warnings) { try { EnsoContext ctx = EnsoContext.get(this); Warning[] ws = warnings.getWarnings(object, this); @@ -105,7 +108,9 @@ Object doWarning( }) @ExplodeLoop public Object doMatch( - VirtualFrame frame, Object object, @CachedLibrary(limit = "3") WarningsLibrary warnings) { + VirtualFrame frame, + Object object, + @Shared("warnsLib") @CachedLibrary(limit = "3") WarningsLibrary warnings) { State state = Function.ArgumentsHelper.getState(frame.getArguments()); try { for (BranchNode branchNode : cases) { diff --git a/engine/runtime/src/main/java/org/enso/interpreter/node/controlflow/caseexpr/CatchTypeBranchNode.java b/engine/runtime/src/main/java/org/enso/interpreter/node/controlflow/caseexpr/CatchTypeBranchNode.java index 4e3f6c1d2c84..f29b5876fe00 100644 --- a/engine/runtime/src/main/java/org/enso/interpreter/node/controlflow/caseexpr/CatchTypeBranchNode.java +++ b/engine/runtime/src/main/java/org/enso/interpreter/node/controlflow/caseexpr/CatchTypeBranchNode.java @@ -3,7 +3,7 @@ import com.oracle.truffle.api.RootCallTarget; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.NodeInfo; -import com.oracle.truffle.api.profiles.ConditionProfile; +import com.oracle.truffle.api.profiles.CountingConditionProfile; import org.enso.interpreter.node.expression.builtin.meta.IsValueOfTypeNode; import org.enso.interpreter.runtime.data.Type; @@ -13,7 +13,7 @@ public class CatchTypeBranchNode extends BranchNode { private final Type expectedType; private @Child IsValueOfTypeNode isValueOfTypeNode = IsValueOfTypeNode.build(); - private final ConditionProfile profile = ConditionProfile.createCountingProfile(); + private final CountingConditionProfile profile = CountingConditionProfile.create(); CatchTypeBranchNode(Type tpe, RootCallTarget functionNode, boolean terminalBranch) { super(functionNode, terminalBranch); diff --git a/engine/runtime/src/main/java/org/enso/interpreter/node/controlflow/caseexpr/ConstructorBranchNode.java b/engine/runtime/src/main/java/org/enso/interpreter/node/controlflow/caseexpr/ConstructorBranchNode.java index ff7435d98356..4f1dc6b38b89 100644 --- a/engine/runtime/src/main/java/org/enso/interpreter/node/controlflow/caseexpr/ConstructorBranchNode.java +++ b/engine/runtime/src/main/java/org/enso/interpreter/node/controlflow/caseexpr/ConstructorBranchNode.java @@ -6,7 +6,7 @@ import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.library.CachedLibrary; import com.oracle.truffle.api.nodes.NodeInfo; -import com.oracle.truffle.api.profiles.ConditionProfile; +import com.oracle.truffle.api.profiles.CountingConditionProfile; import org.enso.interpreter.runtime.callable.atom.Atom; import org.enso.interpreter.runtime.callable.atom.AtomConstructor; import org.enso.interpreter.runtime.callable.atom.StructsLibrary; @@ -15,7 +15,7 @@ @NodeInfo(shortName = "ConstructorMatch") public abstract class ConstructorBranchNode extends BranchNode { private final AtomConstructor matcher; - private final ConditionProfile profile = ConditionProfile.createCountingProfile(); + private final CountingConditionProfile profile = CountingConditionProfile.create(); ConstructorBranchNode(AtomConstructor matcher, RootCallTarget branch, boolean terminalBranch) { super(branch, terminalBranch); diff --git a/engine/runtime/src/main/java/org/enso/interpreter/node/controlflow/caseexpr/NumericLiteralBranchNode.java b/engine/runtime/src/main/java/org/enso/interpreter/node/controlflow/caseexpr/NumericLiteralBranchNode.java index 72b889833023..19cd414d0079 100644 --- a/engine/runtime/src/main/java/org/enso/interpreter/node/controlflow/caseexpr/NumericLiteralBranchNode.java +++ b/engine/runtime/src/main/java/org/enso/interpreter/node/controlflow/caseexpr/NumericLiteralBranchNode.java @@ -7,14 +7,14 @@ import com.oracle.truffle.api.interop.InteropLibrary; import com.oracle.truffle.api.library.CachedLibrary; import com.oracle.truffle.api.nodes.NodeInfo; -import com.oracle.truffle.api.profiles.ConditionProfile; +import com.oracle.truffle.api.profiles.CountingConditionProfile; import java.math.BigInteger; @NodeInfo(shortName = "NumericLiteralMatch", description = "Allows matching on numeric literals") public abstract class NumericLiteralBranchNode extends BranchNode { private final Object literal; - private final ConditionProfile numProfile = ConditionProfile.createCountingProfile(); + private final CountingConditionProfile numProfile = CountingConditionProfile.create(); NumericLiteralBranchNode(Object literal, RootCallTarget branch, boolean terminalBranch) { super(branch, terminalBranch); diff --git a/engine/runtime/src/main/java/org/enso/interpreter/node/controlflow/caseexpr/ObjectEqualityBranchNode.java b/engine/runtime/src/main/java/org/enso/interpreter/node/controlflow/caseexpr/ObjectEqualityBranchNode.java index 91c1470fed9b..b1d7cf9c1445 100644 --- a/engine/runtime/src/main/java/org/enso/interpreter/node/controlflow/caseexpr/ObjectEqualityBranchNode.java +++ b/engine/runtime/src/main/java/org/enso/interpreter/node/controlflow/caseexpr/ObjectEqualityBranchNode.java @@ -2,13 +2,13 @@ import com.oracle.truffle.api.RootCallTarget; import com.oracle.truffle.api.frame.VirtualFrame; -import com.oracle.truffle.api.profiles.ConditionProfile; +import com.oracle.truffle.api.profiles.CountingConditionProfile; import org.enso.interpreter.node.expression.builtin.meta.IsSameObjectNode; public class ObjectEqualityBranchNode extends BranchNode { private final Object expected; private @Child IsSameObjectNode isSameObject = IsSameObjectNode.build(); - private final ConditionProfile profile = ConditionProfile.createCountingProfile(); + private final CountingConditionProfile profile = CountingConditionProfile.create(); private ObjectEqualityBranchNode(RootCallTarget branch, Object expected, boolean terminalBranch) { super(branch, terminalBranch); diff --git a/engine/runtime/src/main/java/org/enso/interpreter/node/controlflow/caseexpr/PolyglotBranchNode.java b/engine/runtime/src/main/java/org/enso/interpreter/node/controlflow/caseexpr/PolyglotBranchNode.java index 946faf6a7fe0..f5f74a0501ee 100644 --- a/engine/runtime/src/main/java/org/enso/interpreter/node/controlflow/caseexpr/PolyglotBranchNode.java +++ b/engine/runtime/src/main/java/org/enso/interpreter/node/controlflow/caseexpr/PolyglotBranchNode.java @@ -5,15 +5,15 @@ import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.NodeInfo; -import com.oracle.truffle.api.profiles.ConditionProfile; +import com.oracle.truffle.api.profiles.CountingConditionProfile; import org.enso.interpreter.runtime.EnsoContext; import org.enso.interpreter.runtime.data.Type; @NodeInfo(shortName = "PolyglotMatch", description = "Allows matching on polyglot objects.") public abstract class PolyglotBranchNode extends BranchNode { private final Type polyglot; - private final ConditionProfile constructorProfile = ConditionProfile.createCountingProfile(); - private final ConditionProfile polyglotProfile = ConditionProfile.createCountingProfile(); + private final CountingConditionProfile constructorProfile = CountingConditionProfile.create(); + private final CountingConditionProfile polyglotProfile = CountingConditionProfile.create(); PolyglotBranchNode(Type polyglot, RootCallTarget branch, boolean terminalBranch) { super(branch, terminalBranch); diff --git a/engine/runtime/src/main/java/org/enso/interpreter/node/controlflow/caseexpr/PolyglotSymbolTypeBranchNode.java b/engine/runtime/src/main/java/org/enso/interpreter/node/controlflow/caseexpr/PolyglotSymbolTypeBranchNode.java index f40e4c80659e..96264a289fc8 100644 --- a/engine/runtime/src/main/java/org/enso/interpreter/node/controlflow/caseexpr/PolyglotSymbolTypeBranchNode.java +++ b/engine/runtime/src/main/java/org/enso/interpreter/node/controlflow/caseexpr/PolyglotSymbolTypeBranchNode.java @@ -8,7 +8,7 @@ import com.oracle.truffle.api.interop.UnsupportedMessageException; import com.oracle.truffle.api.library.CachedLibrary; import com.oracle.truffle.api.nodes.NodeInfo; -import com.oracle.truffle.api.profiles.ConditionProfile; +import com.oracle.truffle.api.profiles.CountingConditionProfile; import org.enso.interpreter.node.expression.builtin.meta.IsSameObjectNode; import org.enso.interpreter.node.expression.builtin.meta.TypeOfNode; import org.enso.interpreter.runtime.EnsoContext; @@ -23,8 +23,8 @@ public abstract class PolyglotSymbolTypeBranchNode extends BranchNode { private final Object polyglotSymbol; private @Child TypeOfNode typeOfNode = TypeOfNode.build(); private @Child IsSameObjectNode isSameObject = IsSameObjectNode.build(); - private final ConditionProfile profile = ConditionProfile.createCountingProfile(); - private final ConditionProfile subtypeProfile = ConditionProfile.createCountingProfile(); + private final CountingConditionProfile profile = CountingConditionProfile.create(); + private final CountingConditionProfile subtypeProfile = CountingConditionProfile.create(); PolyglotSymbolTypeBranchNode( Object polyglotSymbol, RootCallTarget functionNode, boolean terminalBranch) { diff --git a/engine/runtime/src/main/java/org/enso/interpreter/node/controlflow/caseexpr/StringLiteralBranchNode.java b/engine/runtime/src/main/java/org/enso/interpreter/node/controlflow/caseexpr/StringLiteralBranchNode.java index e75799adc18b..ce8e052f7f65 100644 --- a/engine/runtime/src/main/java/org/enso/interpreter/node/controlflow/caseexpr/StringLiteralBranchNode.java +++ b/engine/runtime/src/main/java/org/enso/interpreter/node/controlflow/caseexpr/StringLiteralBranchNode.java @@ -8,7 +8,7 @@ import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.NodeInfo; -import com.oracle.truffle.api.profiles.ConditionProfile; +import com.oracle.truffle.api.profiles.CountingConditionProfile; import org.enso.interpreter.node.expression.builtin.text.util.ToJavaStringNode; import org.enso.interpreter.runtime.data.text.Text; @@ -16,7 +16,7 @@ public abstract class StringLiteralBranchNode extends BranchNode { private final String literal; - private final ConditionProfile textProfile = ConditionProfile.createCountingProfile(); + private final CountingConditionProfile textProfile = CountingConditionProfile.create(); StringLiteralBranchNode(String literal, RootCallTarget branch, boolean terminalBranch) { super(branch, terminalBranch); diff --git a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/atom/InstantiateNode.java b/engine/runtime/src/main/java/org/enso/interpreter/node/expression/atom/InstantiateNode.java index c3562d4878cd..1eacac0e113a 100644 --- a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/atom/InstantiateNode.java +++ b/engine/runtime/src/main/java/org/enso/interpreter/node/expression/atom/InstantiateNode.java @@ -8,7 +8,7 @@ import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.nodes.NodeInfo; import com.oracle.truffle.api.profiles.BranchProfile; -import com.oracle.truffle.api.profiles.ConditionProfile; +import com.oracle.truffle.api.profiles.CountingConditionProfile; import org.enso.interpreter.node.ExpressionNode; import org.enso.interpreter.runtime.EnsoContext; import org.enso.interpreter.runtime.callable.atom.AtomConstructor; @@ -28,21 +28,21 @@ public abstract class InstantiateNode extends ExpressionNode { final AtomConstructor constructor; private @Children ExpressionNode[] arguments; private @Child WarningsLibrary warnings = WarningsLibrary.getFactory().createDispatched(3); - private @CompilationFinal(dimensions = 1) ConditionProfile[] profiles; - private @CompilationFinal(dimensions = 1) ConditionProfile[] warningProfiles; + private @CompilationFinal(dimensions = 1) CountingConditionProfile[] profiles; + private @CompilationFinal(dimensions = 1) CountingConditionProfile[] warningProfiles; private @CompilationFinal(dimensions = 1) BranchProfile[] sentinelProfiles; - private final ConditionProfile anyWarningsProfile = ConditionProfile.createCountingProfile(); + private final CountingConditionProfile anyWarningsProfile = CountingConditionProfile.create(); InstantiateNode(AtomConstructor constructor, ExpressionNode[] arguments) { this.constructor = constructor; this.arguments = arguments; - this.profiles = new ConditionProfile[arguments.length]; + this.profiles = new CountingConditionProfile[arguments.length]; this.sentinelProfiles = new BranchProfile[arguments.length]; - this.warningProfiles = new ConditionProfile[arguments.length]; + this.warningProfiles = new CountingConditionProfile[arguments.length]; for (int i = 0; i < arguments.length; ++i) { - this.profiles[i] = ConditionProfile.createCountingProfile(); + this.profiles[i] = CountingConditionProfile.create(); this.sentinelProfiles[i] = BranchProfile.create(); - this.warningProfiles[i] = ConditionProfile.createCountingProfile(); + this.warningProfiles[i] = CountingConditionProfile.create(); } } @@ -73,8 +73,8 @@ Object doExecute( boolean anyWarnings = false; ArrayRope accumulatedWarnings = new ArrayRope<>(); for (int i = 0; i < arguments.length; i++) { - ConditionProfile profile = profiles[i]; - ConditionProfile warningProfile = warningProfiles[i]; + CountingConditionProfile profile = profiles[i]; + CountingConditionProfile warningProfile = warningProfiles[i]; BranchProfile sentinelProfile = sentinelProfiles[i]; Object argument = arguments[i].executeGeneric(frame); if (profile.profile(TypesGen.isDataflowError(argument))) { @@ -104,6 +104,7 @@ Object doExecute( @ReportPolymorphism public abstract static class CreateInstanceNode extends Node { + @NeverDefault static CreateInstanceNode create(AtomConstructor constructor) { if (Layout.isAritySupported(constructor.getArity())) { return Layout.CreateUnboxedInstanceNode.create(constructor); diff --git a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/bool/AndNode.java b/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/bool/AndNode.java index ca26e8a21e9d..ddd5cb0a0bb2 100644 --- a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/bool/AndNode.java +++ b/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/bool/AndNode.java @@ -4,7 +4,7 @@ import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.Node; -import com.oracle.truffle.api.profiles.ConditionProfile; +import com.oracle.truffle.api.profiles.CountingConditionProfile; import org.enso.interpreter.dsl.BuiltinMethod; import org.enso.interpreter.dsl.Suspend; import org.enso.interpreter.node.BaseNode; @@ -18,7 +18,7 @@ inlineable = true) public abstract class AndNode extends Node { - private final ConditionProfile conditionProfile = ConditionProfile.createCountingProfile(); + private final CountingConditionProfile conditionProfile = CountingConditionProfile.create(); public static AndNode build() { return AndNodeGen.create(); @@ -27,7 +27,7 @@ public static AndNode build() { abstract Object execute(VirtualFrame frame, State state, boolean self, @Suspend Object that); @Specialization - Object executeBool( + Object doIt( VirtualFrame frame, State state, boolean self, diff --git a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/bool/IfThenElseNode.java b/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/bool/IfThenElseNode.java index 95151c9901bd..289df4dd2bcc 100644 --- a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/bool/IfThenElseNode.java +++ b/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/bool/IfThenElseNode.java @@ -2,7 +2,7 @@ import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.Node; -import com.oracle.truffle.api.profiles.ConditionProfile; +import com.oracle.truffle.api.profiles.CountingConditionProfile; import org.enso.interpreter.dsl.BuiltinMethod; import org.enso.interpreter.dsl.Suspend; import org.enso.interpreter.node.BaseNode; @@ -17,7 +17,7 @@ public final class IfThenElseNode extends Node { private @Child ThunkExecutorNode leftThunkExecutorNode = ThunkExecutorNode.build(); private @Child ThunkExecutorNode rightThunkExecutorNode = ThunkExecutorNode.build(); - private final ConditionProfile condProfile = ConditionProfile.createCountingProfile(); + private final CountingConditionProfile condProfile = CountingConditionProfile.create(); public Object execute( VirtualFrame frame, diff --git a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/bool/IfThenNode.java b/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/bool/IfThenNode.java index 868dde221304..9c040d49129f 100644 --- a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/bool/IfThenNode.java +++ b/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/bool/IfThenNode.java @@ -3,7 +3,7 @@ import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.Node; -import com.oracle.truffle.api.profiles.ConditionProfile; +import com.oracle.truffle.api.profiles.CountingConditionProfile; import org.enso.interpreter.dsl.BuiltinMethod; import org.enso.interpreter.dsl.Suspend; import org.enso.interpreter.node.BaseNode; @@ -18,7 +18,7 @@ inlineable = true) public abstract class IfThenNode extends Node { private @Child ThunkExecutorNode leftThunkExecutorNode = ThunkExecutorNode.build(); - private final ConditionProfile condProfile = ConditionProfile.createCountingProfile(); + private final CountingConditionProfile condProfile = CountingConditionProfile.create(); static IfThenNode build() { return IfThenNodeGen.create(); diff --git a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/bool/OrNode.java b/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/bool/OrNode.java index 01d459af3f9b..628422daed5d 100644 --- a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/bool/OrNode.java +++ b/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/bool/OrNode.java @@ -4,7 +4,7 @@ import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.Node; -import com.oracle.truffle.api.profiles.ConditionProfile; +import com.oracle.truffle.api.profiles.CountingConditionProfile; import org.enso.interpreter.dsl.BuiltinMethod; import org.enso.interpreter.dsl.Suspend; import org.enso.interpreter.node.BaseNode; @@ -18,7 +18,7 @@ inlineable = true) public abstract class OrNode extends Node { - private final ConditionProfile conditionProfile = ConditionProfile.createCountingProfile(); + private final CountingConditionProfile conditionProfile = CountingConditionProfile.create(); public static OrNode build() { return OrNodeGen.create(); @@ -27,7 +27,7 @@ public static OrNode build() { abstract Object execute(VirtualFrame frame, State state, boolean self, @Suspend Object that); @Specialization - Object executeBool( + Object doIt( VirtualFrame frame, State state, boolean self, diff --git a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/date/ToEnsoDateNode.java b/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/date/ToEnsoDateNode.java index 55409921af03..58f9defc6c0b 100644 --- a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/date/ToEnsoDateNode.java +++ b/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/date/ToEnsoDateNode.java @@ -21,7 +21,7 @@ public static ToEnsoDateNode build() { abstract EnsoDate execute(Object self); @Specialization - EnsoDate executeConversion(Object self, @CachedLibrary(limit = "3") InteropLibrary iop) { + EnsoDate doIt(Object self, @CachedLibrary(limit = "3") InteropLibrary iop) { try { return new EnsoDate(iop.asDate(self)); } catch (UnsupportedMessageException ex) { diff --git a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/error/CatchPanicNode.java b/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/error/CatchPanicNode.java index 28822e1bbfd5..10922abad10b 100644 --- a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/error/CatchPanicNode.java +++ b/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/error/CatchPanicNode.java @@ -9,7 +9,7 @@ import com.oracle.truffle.api.library.CachedLibrary; import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.profiles.BranchProfile; -import com.oracle.truffle.api.profiles.ConditionProfile; +import com.oracle.truffle.api.profiles.CountingConditionProfile; import org.enso.interpreter.dsl.BuiltinMethod; import org.enso.interpreter.dsl.Suspend; import org.enso.interpreter.node.BaseNode; @@ -31,7 +31,7 @@ public abstract class CatchPanicNode extends Node { private @Child InvokeCallableNode invokeCallableNode; private @Child ThunkExecutorNode thunkExecutorNode = ThunkExecutorNode.build(); private @Child IsValueOfTypeNode isValueOfTypeNode = IsValueOfTypeNode.build(); - private final ConditionProfile profile = ConditionProfile.createCountingProfile(); + private final CountingConditionProfile profile = CountingConditionProfile.create(); CatchPanicNode() { this.invokeCallableNode = diff --git a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/immutable/SliceArrayVectorNode.java b/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/immutable/SliceArrayVectorNode.java index 5422f9ebcba8..c6073ba6c46c 100644 --- a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/immutable/SliceArrayVectorNode.java +++ b/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/immutable/SliceArrayVectorNode.java @@ -1,6 +1,7 @@ package org.enso.interpreter.node.expression.builtin.immutable; import com.oracle.truffle.api.CompilerDirectives; +import com.oracle.truffle.api.dsl.Cached.Shared; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.interop.InteropLibrary; import com.oracle.truffle.api.interop.UnsupportedMessageException; @@ -23,13 +24,16 @@ public static SliceArrayVectorNode build() { abstract Object execute(Object self, long start, long end); @Specialization - Object executeArray(Array self, long start, long end) { + Object sliceArray(Array self, long start, long end) { return Array.slice(self, start, end, self.length()); } @Specialization - Object executeVector( - Vector self, long start, long end, @CachedLibrary(limit = "3") InteropLibrary iop) { + Object sliceVector( + Vector self, + long start, + long end, + @Shared("interop") @CachedLibrary(limit = "3") InteropLibrary iop) { try { return Array.slice(self, start, end, self.length(iop)); } catch (UnsupportedMessageException ex) { @@ -38,9 +42,12 @@ Object executeVector( } } - @Specialization(replaces = {"executeArray", "executeVector"}) - Object executeArrayLike( - Object self, long start, long end, @CachedLibrary(limit = "3") InteropLibrary iop) { + @Specialization(replaces = {"sliceArray", "sliceVector"}) + Object sliceArrayLike( + Object self, + long start, + long end, + @Shared("interop") @CachedLibrary(limit = "3") InteropLibrary iop) { try { long len = iop.getArraySize(self); return Array.slice(self, start, end, len); diff --git a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/interop/syntax/HostValueToEnsoNode.java b/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/interop/syntax/HostValueToEnsoNode.java index 5aedc038af4f..3d76ed05247b 100644 --- a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/interop/syntax/HostValueToEnsoNode.java +++ b/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/interop/syntax/HostValueToEnsoNode.java @@ -15,6 +15,7 @@ @ReportPolymorphism @GenerateUncached public abstract class HostValueToEnsoNode extends Node { + @NeverDefault public static HostValueToEnsoNode build() { return HostValueToEnsoNodeGen.create(); } diff --git a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/io/PrintErrNode.java b/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/io/PrintErrNode.java index cc69fc53e87a..706d58d474cf 100644 --- a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/io/PrintErrNode.java +++ b/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/io/PrintErrNode.java @@ -2,6 +2,8 @@ import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.dsl.Cached; +import com.oracle.truffle.api.dsl.Cached.Shared; +import com.oracle.truffle.api.dsl.NeverDefault; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.interop.InteropLibrary; @@ -36,7 +38,7 @@ Object doPrintText( VirtualFrame frame, State state, Object message, - @CachedLibrary(limit = "10") InteropLibrary strings) { + @Shared("interop") @CachedLibrary(limit = "10") InteropLibrary strings) { EnsoContext ctx = EnsoContext.get(this); try { print(ctx.getErr(), strings.asString(message)); @@ -51,7 +53,7 @@ Object doPrint( VirtualFrame frame, State state, Object message, - @CachedLibrary(limit = "10") InteropLibrary strings, + @Shared("interop") @CachedLibrary(limit = "10") InteropLibrary strings, @Cached("buildSymbol()") UnresolvedSymbol symbol, @Cached("buildInvokeCallableNode()") InvokeCallableNode invokeCallableNode, @Cached ExpectStringNode expectStringNode) { @@ -70,6 +72,7 @@ boolean isText(Object o) { return TypesGen.isText(o); } + @NeverDefault InvokeCallableNode buildInvokeCallableNode() { return InvokeCallableNode.build( new CallArgumentInfo[] {new CallArgumentInfo()}, @@ -77,6 +80,7 @@ InvokeCallableNode buildInvokeCallableNode() { InvokeCallableNode.ArgumentsExecutionMode.PRE_EXECUTED); } + @NeverDefault UnresolvedSymbol buildSymbol() { return UnresolvedSymbol.build("to_text", EnsoContext.get(this).getBuiltins().getScope()); } diff --git a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/io/PrintlnNode.java b/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/io/PrintlnNode.java index fc4329f8556d..8006408094a5 100644 --- a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/io/PrintlnNode.java +++ b/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/io/PrintlnNode.java @@ -2,6 +2,8 @@ import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.dsl.Cached; +import com.oracle.truffle.api.dsl.Cached.Shared; +import com.oracle.truffle.api.dsl.NeverDefault; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.interop.InteropLibrary; @@ -37,7 +39,7 @@ Object doPrintText( VirtualFrame frame, State state, Object message, - @CachedLibrary(limit = "10") InteropLibrary strings) { + @Shared("interop") @CachedLibrary(limit = "10") InteropLibrary strings) { EnsoContext ctx = EnsoContext.get(this); try { print(ctx.getOut(), strings.asString(message)); @@ -52,7 +54,7 @@ Object doPrint( VirtualFrame frame, State state, Object message, - @CachedLibrary(limit = "10") InteropLibrary strings, + @Shared("interop") @CachedLibrary(limit = "10") InteropLibrary strings, @CachedLibrary(limit = "10") WarningsLibrary warnings, @Cached("buildSymbol()") UnresolvedSymbol symbol, @Cached("buildInvokeCallableNode()") InvokeCallableNode invokeCallableNode) { @@ -91,10 +93,12 @@ private void print(PrintStream out, Object str) { out.println(str); } + @NeverDefault UnresolvedSymbol buildSymbol() { return UnresolvedSymbol.build("to_text", EnsoContext.get(this).getBuiltins().getScope()); } + @NeverDefault InvokeCallableNode buildInvokeCallableNode() { return InvokeCallableNode.build( new CallArgumentInfo[] {new CallArgumentInfo()}, @@ -102,6 +106,7 @@ InvokeCallableNode buildInvokeCallableNode() { InvokeCallableNode.ArgumentsExecutionMode.PRE_EXECUTED); } + @NeverDefault static PrintlnNode build() { return PrintlnNodeGen.create(); } diff --git a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/meta/AtomWithAHoleNode.java b/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/meta/AtomWithAHoleNode.java index 86332206692c..7bf58f225d0d 100644 --- a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/meta/AtomWithAHoleNode.java +++ b/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/meta/AtomWithAHoleNode.java @@ -1,5 +1,6 @@ package org.enso.interpreter.node.expression.builtin.meta; +import com.oracle.truffle.api.dsl.NeverDefault; import org.enso.interpreter.dsl.BuiltinMethod; import org.enso.interpreter.runtime.EnsoContext; import org.enso.interpreter.runtime.callable.Annotation; @@ -39,6 +40,7 @@ static AtomWithAHoleNode build() { abstract Object execute(VirtualFrame frame, Object factory, State state); + @NeverDefault static InvokeCallableNode callWithHole() { return InvokeCallableNode.build( new CallArgumentInfo[] {new CallArgumentInfo()}, @@ -130,6 +132,7 @@ private SwapAtomFieldNode() { }, new CallArgumentInfo[0], new Annotation[0]); } + @NeverDefault static SwapAtomFieldNode create() { return new SwapAtomFieldNode(); } diff --git a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/meta/EqualsAtomNode.java b/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/meta/EqualsAtomNode.java index 411016c3e4e5..5048012d61fc 100644 --- a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/meta/EqualsAtomNode.java +++ b/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/meta/EqualsAtomNode.java @@ -4,6 +4,7 @@ import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.dsl.Cached; +import com.oracle.truffle.api.dsl.Cached.Shared; import com.oracle.truffle.api.dsl.GenerateUncached; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.library.CachedLibrary; @@ -54,7 +55,7 @@ boolean equalsAtomsWithDefaultComparator( int fieldsLenCached, @Cached(value = "createEqualsNodes(fieldsLenCached)", allowUncached = true) EqualsNode[] fieldEqualsNodes, - @Cached CustomComparatorNode customComparatorNode, + @Shared("customComparatorNode") @Cached CustomComparatorNode customComparatorNode, @Cached ConditionProfile constructorsNotEqualProfile, @CachedLibrary(limit = "5") StructsLibrary structsLib) { if (constructorsNotEqualProfile.profile(self.getConstructor() != other.getConstructor())) { @@ -85,7 +86,7 @@ boolean equalsAtomsWithCustomComparator( Atom self, Atom other, @Cached("self.getConstructor()") AtomConstructor selfCtorCached, - @Cached CustomComparatorNode customComparatorNode, + @Shared("customComparatorNode") @Cached CustomComparatorNode customComparatorNode, @Cached(value = "customComparatorNode.execute(self)") Type cachedComparator, @Cached(value = "findCompareMethod(cachedComparator)", allowUncached = true) Function compareFn, diff --git a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/meta/EqualsComplexNode.java b/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/meta/EqualsComplexNode.java index fb25ace6a1ea..71cb5b41f650 100644 --- a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/meta/EqualsComplexNode.java +++ b/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/meta/EqualsComplexNode.java @@ -2,6 +2,8 @@ import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.dsl.Cached; +import com.oracle.truffle.api.dsl.Cached.Exclusive; +import com.oracle.truffle.api.dsl.Cached.Shared; import com.oracle.truffle.api.dsl.GenerateUncached; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.interop.ArityException; @@ -42,7 +44,9 @@ public static EqualsComplexNode build() { /** Enso specific types */ @Specialization boolean equalsUnresolvedSymbols( - UnresolvedSymbol self, UnresolvedSymbol otherSymbol, @Cached EqualsNode equalsNode) { + UnresolvedSymbol self, + UnresolvedSymbol otherSymbol, + @Shared("equalsNode") @Cached EqualsNode equalsNode) { return self.getName().equals(otherSymbol.getName()) && equalsNode.execute(self.getScope(), otherSymbol.getScope()); } @@ -51,24 +55,28 @@ boolean equalsUnresolvedSymbols( boolean equalsUnresolvedConversion( UnresolvedConversion selfConversion, UnresolvedConversion otherConversion, - @Cached EqualsNode equalsNode) { + @Shared("equalsNode") @Cached EqualsNode equalsNode) { return equalsNode.execute(selfConversion.getScope(), otherConversion.getScope()); } @Specialization boolean equalsModuleScopes( - ModuleScope selfModuleScope, ModuleScope otherModuleScope, @Cached EqualsNode equalsNode) { + ModuleScope selfModuleScope, + ModuleScope otherModuleScope, + @Shared("equalsNode") @Cached EqualsNode equalsNode) { return equalsNode.execute(selfModuleScope.getModule(), otherModuleScope.getModule()); } @Specialization @TruffleBoundary - boolean equalsModules(Module selfModule, Module otherModule, @Cached EqualsNode equalsNode) { + boolean equalsModules( + Module selfModule, Module otherModule, @Shared("equalsNode") @Cached EqualsNode equalsNode) { return equalsNode.execute(selfModule.getName().toString(), otherModule.getName().toString()); } @Specialization - boolean equalsFiles(EnsoFile selfFile, EnsoFile otherFile, @Cached EqualsNode equalsNode) { + boolean equalsFiles( + EnsoFile selfFile, EnsoFile otherFile, @Shared("equalsNode") @Cached EqualsNode equalsNode) { return equalsNode.execute(selfFile.getPath(), otherFile.getPath()); } @@ -81,8 +89,8 @@ boolean equalsFiles(EnsoFile selfFile, EnsoFile otherFile, @Cached EqualsNode eq boolean equalsTypes( Type selfType, Type otherType, - @Cached EqualsNode equalsNode, - @CachedLibrary(limit = "5") TypesLibrary typesLib) { + @Shared("equalsNode") @Cached EqualsNode equalsNode, + @Shared("typesLib") @CachedLibrary(limit = "10") TypesLibrary typesLib) { return equalsNode.execute( selfType.getQualifiedName().toString(), otherType.getQualifiedName().toString()); } @@ -100,7 +108,7 @@ boolean equalsWithWarnings( Object otherWithWarnings, @CachedLibrary("selfWithWarnings") WarningsLibrary selfWarnLib, @CachedLibrary("otherWithWarnings") WarningsLibrary otherWarnLib, - @Cached EqualsNode equalsNode) { + @Shared("equalsNode") @Cached EqualsNode equalsNode) { try { Object self = selfWarnLib.hasWarnings(selfWithWarnings) @@ -279,9 +287,9 @@ boolean equalsArrays( Object otherArray, @CachedLibrary("selfArray") InteropLibrary selfInterop, @CachedLibrary("otherArray") InteropLibrary otherInterop, - @Cached EqualsNode equalsNode, + @Shared("equalsNode") @Cached EqualsNode equalsNode, @Cached CustomComparatorNode hasCustomComparatorNode, - @Cached HostValueToEnsoNode valueToEnsoNode) { + @Shared("hostValueToEnsoNode") @Cached HostValueToEnsoNode valueToEnsoNode) { try { long selfSize = selfInterop.getArraySize(selfArray); if (selfSize != otherInterop.getArraySize(otherArray)) { @@ -314,10 +322,10 @@ boolean equalsHashMaps( Object otherHashMap, @CachedLibrary("selfHashMap") InteropLibrary selfInterop, @CachedLibrary("otherHashMap") InteropLibrary otherInterop, - @CachedLibrary(limit = "5") InteropLibrary entriesInterop, - @Cached EqualsNode equalsNode, - @Cached HostValueToEnsoNode keyToEnsoNode, - @Cached HostValueToEnsoNode valueToEnsoNode) { + @Shared("interop") @CachedLibrary(limit = "10") InteropLibrary entriesInterop, + @Shared("equalsNode") @Cached EqualsNode equalsNode, + @Exclusive @Cached HostValueToEnsoNode keyToEnsoNode, + @Exclusive @Cached HostValueToEnsoNode valueToEnsoNode) { try { int selfHashSize = (int) selfInterop.getHashSize(selfHashMap); int otherHashSize = (int) otherInterop.getHashSize(otherHashMap); @@ -358,10 +366,10 @@ boolean equalsHashMaps( boolean equalsInteropObjectWithMembers( Object selfObject, Object otherObject, - @CachedLibrary(limit = "10") InteropLibrary interop, - @CachedLibrary(limit = "5") TypesLibrary typesLib, - @Cached EqualsNode equalsNode, - @Cached HostValueToEnsoNode valueToEnsoNode) { + @Shared("interop") @CachedLibrary(limit = "10") InteropLibrary interop, + @Shared("typesLib") @CachedLibrary(limit = "10") TypesLibrary typesLib, + @Shared("equalsNode") @Cached EqualsNode equalsNode, + @Shared("hostValueToEnsoNode") @Cached HostValueToEnsoNode valueToEnsoNode) { try { Object selfMembers = interop.getMembers(selfObject); Object otherMembers = interop.getMembers(otherObject); @@ -413,7 +421,7 @@ boolean equalsInteropObjectWithMembers( boolean equalsHostObjects( Object selfHostObject, Object otherHostObject, - @CachedLibrary(limit = "5") InteropLibrary interop) { + @Shared("interop") @CachedLibrary(limit = "10") InteropLibrary interop) { try { return interop.asBoolean(interop.invokeMember(selfHostObject, "equals", otherHostObject)); } catch (UnsupportedMessageException @@ -430,8 +438,8 @@ boolean equalsHostObjects( boolean equalsHostFunctions( Object selfHostFunc, Object otherHostFunc, - @CachedLibrary(limit = "5") InteropLibrary interop, - @Cached EqualsNode equalsNode) { + @Shared("interop") @CachedLibrary(limit = "10") InteropLibrary interop, + @Shared("equalsNode") @Cached EqualsNode equalsNode) { Object selfFuncStrRepr = interop.toDisplayString(selfHostFunc); Object otherFuncStrRepr = interop.toDisplayString(otherHostFunc); return equalsNode.execute(selfFuncStrRepr, otherFuncStrRepr); @@ -442,8 +450,8 @@ boolean equalsHostFunctions( boolean equalsGeneric( Object left, Object right, - @CachedLibrary(limit = "10") InteropLibrary interop, - @CachedLibrary(limit = "10") TypesLibrary typesLib, + @Shared("interop") @CachedLibrary(limit = "10") InteropLibrary interop, + @Shared("typesLib") @CachedLibrary(limit = "10") TypesLibrary typesLib, @CachedLibrary(limit = "10") WarningsLibrary warningsLib) { return left == right || interop.isIdentical(left, right, interop) diff --git a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/meta/EqualsNode.java b/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/meta/EqualsNode.java index 8b9ff2465338..306c6a20a7d0 100644 --- a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/meta/EqualsNode.java +++ b/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/meta/EqualsNode.java @@ -3,6 +3,7 @@ import com.ibm.icu.text.Normalizer; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.dsl.Cached; +import com.oracle.truffle.api.dsl.Cached.Shared; import com.oracle.truffle.api.dsl.GenerateUncached; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.interop.InteropLibrary; @@ -213,7 +214,9 @@ boolean equalsStrings( @Specialization(guards = "isPrimitive(self, interop) != isPrimitive(other, interop)") boolean equalsDifferent( - Object self, Object other, @CachedLibrary(limit = "10") InteropLibrary interop) { + Object self, + Object other, + @Shared("interop") @CachedLibrary(limit = "10") InteropLibrary interop) { return false; } @@ -228,7 +231,7 @@ boolean equalsAtoms( Atom self, Atom other, @Cached EqualsAtomNode equalsAtomNode, - @Cached IsSameObjectNode isSameObjectNode) { + @Shared("isSameObjectNode") @Cached IsSameObjectNode isSameObjectNode) { return isSameObjectNode.execute(self, other) || equalsAtomNode.execute(self, other); } @@ -237,8 +240,8 @@ boolean equalsComplex( Object self, Object other, @Cached EqualsComplexNode equalsComplex, - @Cached IsSameObjectNode isSameObjectNode, - @CachedLibrary(limit = "10") InteropLibrary interop, + @Shared("isSameObjectNode") @Cached IsSameObjectNode isSameObjectNode, + @Shared("interop") @CachedLibrary(limit = "10") InteropLibrary interop, @CachedLibrary(limit = "5") WarningsLibrary warnings) { return isSameObjectNode.execute(self, other) || equalsComplex.execute(self, other); } diff --git a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/meta/GetConstructorFieldNamesNode.java b/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/meta/GetConstructorFieldNamesNode.java index 0096e7b59fe7..6ba9f2b7d4e7 100644 --- a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/meta/GetConstructorFieldNamesNode.java +++ b/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/meta/GetConstructorFieldNamesNode.java @@ -22,8 +22,8 @@ static GetConstructorFieldNamesNode build() { abstract Array execute(Object obj); @Specialization - final Array executeAtomConstructor(AtomConstructor atom_constructor) { - ArgumentDefinition[] fields = atom_constructor.getFields(); + final Array fieldNamesForAtomCtor(AtomConstructor atomConstructor) { + ArgumentDefinition[] fields = atomConstructor.getFields(); Object[] result = new Object[fields.length]; for (int i = 0; i < fields.length; i++) { result[i] = Text.create(fields[i].getName()); @@ -32,7 +32,7 @@ final Array executeAtomConstructor(AtomConstructor atom_constructor) { } @Fallback - final Array executeAny(Object any) { + final Array fieldNamesForAny(Object any) { return Array.empty(); } } diff --git a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/meta/HashCodeNode.java b/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/meta/HashCodeNode.java index 6f780f3d41a6..46b9b7ab4a68 100644 --- a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/meta/HashCodeNode.java +++ b/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/meta/HashCodeNode.java @@ -5,7 +5,9 @@ import com.oracle.truffle.api.CompilerAsserts; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.dsl.Cached; +import com.oracle.truffle.api.dsl.Cached.Shared; import com.oracle.truffle.api.dsl.GenerateUncached; +import com.oracle.truffle.api.dsl.NeverDefault; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.interop.ArityException; import com.oracle.truffle.api.interop.InteropLibrary; @@ -147,7 +149,7 @@ long hashCodeForAtomConstructor(AtomConstructor atomConstructor) { @Specialization @TruffleBoundary long hashCodeForUnresolvedSymbol(UnresolvedSymbol unresolvedSymbol, - @Cached HashCodeNode hashCodeNode) { + @Shared("hashCodeNode") @Cached HashCodeNode hashCodeNode) { long nameHash = hashCodeNode.execute(unresolvedSymbol.getName()); long scopeHash = hashCodeNode.execute(unresolvedSymbol.getScope()); return Objects.hashCode(nameHash, scopeHash); @@ -155,26 +157,26 @@ long hashCodeForUnresolvedSymbol(UnresolvedSymbol unresolvedSymbol, @Specialization long hashCodeForUnresolvedConversion(UnresolvedConversion unresolvedConversion, - @CachedLibrary(limit = "5") InteropLibrary interop) { + @Shared("interop") @CachedLibrary(limit = "10") InteropLibrary interop) { return hashCodeForModuleScope(unresolvedConversion.getScope(), interop); } @Specialization long hashCodeForModuleScope(ModuleScope moduleScope, - @CachedLibrary(limit = "5") InteropLibrary interop) { + @Shared("interop") @CachedLibrary(limit = "10") InteropLibrary interop) { return hashCodeForModule(moduleScope.getModule(), interop); } @Specialization @TruffleBoundary long hashCodeForModule(Module module, - @CachedLibrary(limit = "5") InteropLibrary interop) { + @Shared("interop") @CachedLibrary(limit = "10") InteropLibrary interop) { return hashCodeForString(module.toString(), interop); } @Specialization long hashCodeForFile(EnsoFile file, - @CachedLibrary(limit = "5") InteropLibrary interop) { + @Shared("interop") @CachedLibrary(limit = "10") InteropLibrary interop) { return hashCodeForString(file.getPath(), interop); } @@ -186,7 +188,7 @@ long hashCodeForFile(EnsoFile file, */ @Specialization long hashCodeForType(Type type, - @Cached HashCodeNode hashCodeNode) { + @Shared("hashCodeNode") @Cached HashCodeNode hashCodeNode) { if (EnsoContext.get(this).getNothing() == type) { // Nothing should be equal to `null` return 0; @@ -195,6 +197,7 @@ long hashCodeForType(Type type, } } + @NeverDefault static HashCodeNode[] createHashCodeNodes(int size) { HashCodeNode[] nodes = new HashCodeNode[size]; Arrays.fill(nodes, HashCodeNode.build()); @@ -204,7 +207,7 @@ static HashCodeNode[] createHashCodeNodes(int size) { @Specialization(guards = { "atomCtorCached == atom.getConstructor()", "customComparatorNode.execute(atom) == null", - }, limit = "10") + }, limit = "5") @ExplodeLoop long hashCodeForAtomWithDefaultComparator( Atom atom, @@ -214,8 +217,8 @@ long hashCodeForAtomWithDefaultComparator( HashCodeNode[] fieldHashCodeNodes, @Cached ConditionProfile isHashCodeCached, @CachedLibrary(limit = "10") StructsLibrary structs, - @Cached CustomComparatorNode customComparatorNode, - @Cached HashCallbackNode hashCallbackNode) { + @Shared("customComparatorNode") @Cached CustomComparatorNode customComparatorNode, + @Shared("hashCallbackNode") @Cached HashCallbackNode hashCallbackNode) { if (isHashCodeCached.profile(atom.getHashCode() != null)) { return atom.getHashCode(); } @@ -246,13 +249,14 @@ long hashCodeForAtomWithDefaultComparator( guards = { "atomCtorCached == atom.getConstructor()", "cachedComparator != null" - } + }, + limit = "5" ) long hashCodeForAtomWithCustomComparator( Atom atom, @Cached("atom.getConstructor()") AtomConstructor atomCtorCached, - @Cached CustomComparatorNode customComparatorNode, - @CachedLibrary(limit = "5") InteropLibrary interop, + @Shared("customComparatorNode") @Cached CustomComparatorNode customComparatorNode, + @Shared("interop") @CachedLibrary(limit = "10") InteropLibrary interop, @Cached(value = "customComparatorNode.execute(atom)") Type cachedComparator, @Cached(value = "findHashMethod(cachedComparator)", allowUncached = true) Function compareMethod, @@ -281,6 +285,7 @@ static Function findHashMethod(Type comparator) { return fn; } + @NeverDefault static InvokeFunctionNode createInvokeNode(Function compareFn) { CallArgumentInfo[] argsInfo = new CallArgumentInfo[compareFn.getSchema().getArgumentsCount()]; for (int i = 0; i < argsInfo.length; i++) { @@ -337,7 +342,7 @@ long hashCodeForAtomUncached(Atom atom) { long hashCodeForWarning( Object selfWithWarning, @CachedLibrary("selfWithWarning") WarningsLibrary warnLib, - @Cached HashCodeNode hashCodeNode) { + @Shared("hashCodeNode") @Cached HashCodeNode hashCodeNode) { try { return hashCodeNode.execute(warnLib.removeWarnings(selfWithWarning)); } catch (UnsupportedMessageException e) { @@ -458,7 +463,9 @@ long hashCodeForDurationInterop( } @Specialization - long hashCodeForText(Text text, @CachedLibrary(limit = "3") InteropLibrary interop) { + long hashCodeForText( + Text text, + @Shared("interop") @CachedLibrary(limit = "10") InteropLibrary interop) { if (text.is_normalized()) { return text.toString().hashCode(); } else { @@ -470,7 +477,9 @@ long hashCodeForText(Text text, @CachedLibrary(limit = "3") InteropLibrary inter @Specialization( guards = {"interop.isString(selfStr)"}, limit = "3") - long hashCodeForString(Object selfStr, @CachedLibrary("selfStr") InteropLibrary interop) { + long hashCodeForString( + Object selfStr, + @CachedLibrary("selfStr") InteropLibrary interop) { String str; try { str = interop.asString(selfStr); @@ -494,10 +503,10 @@ long hashCodeForString(Object selfStr, @CachedLibrary("selfStr") InteropLibrary long hashCodeForArray( Object selfArray, @CachedLibrary("selfArray") InteropLibrary interop, - @Cached HashCodeNode hashCodeNode, - @Cached("createCountingProfile()") LoopConditionProfile loopProfile, - @Cached HashCallbackNode hashCallbackNode, - @Cached CustomComparatorNode customComparatorNode) { + @Shared("hashCodeNode") @Cached HashCodeNode hashCodeNode, + @Cached LoopConditionProfile loopProfile, + @Shared("hashCallbackNode") @Cached HashCallbackNode hashCallbackNode, + @Shared("customComparatorNode") @Cached CustomComparatorNode customComparatorNode) { try { long arraySize = interop.getArraySize(selfArray); loopProfile.profileCounted(arraySize); @@ -528,8 +537,8 @@ long hashCodeForArray( }) long hashCodeForMap( Object selfMap, - @CachedLibrary(limit = "5") InteropLibrary interop, - @Cached HashCodeNode hashCodeNode) { + @Shared("interop") @CachedLibrary(limit = "10") InteropLibrary interop, + @Shared("hashCodeNode") @Cached HashCodeNode hashCodeNode) { int mapSize; long keysHashCode = 0; long valuesHashCode = 0; @@ -561,9 +570,9 @@ long hashCodeForMap( "!typesLib.hasType(objectWithMembers)", }) long hashCodeForInteropObjectWithMembers(Object objectWithMembers, - @CachedLibrary(limit = "10") InteropLibrary interop, + @Shared("interop") @CachedLibrary(limit = "10") InteropLibrary interop, @CachedLibrary(limit = "5") TypesLibrary typesLib, - @Cached HashCodeNode hashCodeNode) { + @Shared("hashCodeNode") @Cached HashCodeNode hashCodeNode) { try { Object members = interop.getMembers(objectWithMembers); assert interop.getArraySize(members) < Integer.MAX_VALUE : "long array size not supported"; @@ -600,7 +609,8 @@ long hashCodeForNull(Object selfNull, @CachedLibrary("selfNull") InteropLibrary @Specialization(guards = "isHostObject(hostObject)") long hashCodeForHostObject( - Object hostObject, @CachedLibrary(limit = "3") InteropLibrary interop) { + Object hostObject, + @Shared("interop") @CachedLibrary(limit = "10") InteropLibrary interop) { try { Object hashCodeRes = interop.invokeMember(hostObject, "hashCode"); assert interop.fitsInInt(hashCodeRes); @@ -620,8 +630,8 @@ long hashCodeForHostObject( @TruffleBoundary @Specialization(guards = "isHostFunction(hostFunction)") long hashCodeForHostFunction(Object hostFunction, - @CachedLibrary(limit = "3") InteropLibrary interop, - @Cached HashCodeNode hashCodeNode) { + @Shared("interop") @CachedLibrary(limit = "10") InteropLibrary interop, + @Shared("hashCodeNode") @Cached HashCodeNode hashCodeNode) { return hashCodeNode.execute(interop.toDisplayString(hostFunction)); } diff --git a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/meta/IsValueOfTypeNode.java b/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/meta/IsValueOfTypeNode.java index 8a9cc4c401cb..197c2e58a881 100644 --- a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/meta/IsValueOfTypeNode.java +++ b/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/meta/IsValueOfTypeNode.java @@ -10,7 +10,7 @@ import com.oracle.truffle.api.nodes.ExplodeLoop; import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.nodes.NodeInfo; -import com.oracle.truffle.api.profiles.ConditionProfile; +import com.oracle.truffle.api.profiles.CountingConditionProfile; import org.enso.interpreter.runtime.EnsoContext; import org.enso.interpreter.runtime.callable.UnresolvedSymbol; import org.enso.interpreter.runtime.data.Type; @@ -50,7 +50,7 @@ private static boolean typeAndCheck( Object expectedType, TypeOfNode typeOfNode, IsSameObjectNode isSameObject, - ConditionProfile isSameObjectProfile) { + CountingConditionProfile isSameObjectProfile) { Object tpeOfPayload = typeOfNode.execute(payload); if (isSameObjectProfile.profile(isSameObject.execute(expectedType, tpeOfPayload))) { return true; @@ -73,7 +73,7 @@ private static boolean typeAndCheck( abstract static class Typed extends Node { private @Child IsSameObjectNode isSameObject = IsSameObjectNode.build(); private @Child TypeOfNode typeOfNode = TypeOfNode.build(); - private final ConditionProfile profile = ConditionProfile.createCountingProfile(); + private final CountingConditionProfile profile = CountingConditionProfile.create(); abstract boolean execute(Object expectedType, Object payload); @@ -157,7 +157,7 @@ boolean isArrayType(Object expectedType) { abstract static class Untyped extends Node { private @Child IsSameObjectNode isSameObject = IsSameObjectNode.build(); private @Child TypeOfNode typeOfNode = TypeOfNode.build(); - private final ConditionProfile profile = ConditionProfile.createCountingProfile(); + private final CountingConditionProfile profile = CountingConditionProfile.create(); abstract boolean execute(Object expectedType, Object payload); diff --git a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/meta/TypeOfNode.java b/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/meta/TypeOfNode.java index f75cedc83b7e..3102fd59b598 100644 --- a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/meta/TypeOfNode.java +++ b/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/meta/TypeOfNode.java @@ -80,8 +80,8 @@ Object doWarning(WithWarnings value) { @Specialization(guards = {"!types.hasType(value)"}) Object withoutType( Object value, - @CachedLibrary(limit = "3") InteropLibrary interop, - @CachedLibrary(limit = "3") TypesLibrary types, + @Shared("interop") @CachedLibrary(limit = "3") InteropLibrary interop, + @Shared("types") @CachedLibrary(limit = "3") TypesLibrary types, @Cached WithoutType delegate) { var type = WithoutType.Interop.resolve(value, interop); return delegate.execute(type, value); @@ -90,8 +90,8 @@ Object withoutType( @Specialization(guards = {"types.hasType(value)", "!interop.isNumber(value)"}) Object doType( Object value, - @CachedLibrary(limit = "3") InteropLibrary interop, - @CachedLibrary(limit = "3") TypesLibrary types) { + @Shared("interop") @CachedLibrary(limit = "3") InteropLibrary interop, + @Shared("types") @CachedLibrary(limit = "3") TypesLibrary types) { return types.getType(value); } diff --git a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/mutable/CoerceArrayNode.java b/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/mutable/CoerceArrayNode.java index 143ccd53079d..ecde9831f20b 100644 --- a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/mutable/CoerceArrayNode.java +++ b/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/mutable/CoerceArrayNode.java @@ -1,7 +1,9 @@ package org.enso.interpreter.node.expression.builtin.mutable; import com.oracle.truffle.api.dsl.Cached; +import com.oracle.truffle.api.dsl.Cached.Shared; import com.oracle.truffle.api.dsl.Fallback; +import com.oracle.truffle.api.dsl.NeverDefault; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.interop.InteropLibrary; import com.oracle.truffle.api.interop.InvalidArrayIndexException; @@ -19,6 +21,7 @@ public abstract class CoerceArrayNode extends Node { private @Child InteropLibrary library = InteropLibrary.getFactory().createDispatched(10); + @NeverDefault public static CoerceArrayNode build() { return CoerceArrayNodeGen.create(); } @@ -31,7 +34,7 @@ Object[] doArray(Array arr) { } @Specialization - Object[] doVector(Vector arr, @Cached HostValueToEnsoNode hostValueToEnsoNode) { + Object[] doVector(Vector arr, @Shared @Cached HostValueToEnsoNode hostValueToEnsoNode) { try { return convertToArray(arr, hostValueToEnsoNode); } catch (UnsupportedMessageException e) { @@ -49,7 +52,7 @@ Object[] doVector(Vector arr, @Cached HostValueToEnsoNode hostValueToEnsoNode) { Object[] doArrayLike( Object arr, @CachedLibrary(limit = "5") InteropLibrary interop, - @Cached HostValueToEnsoNode hostValueToEnsoNode) { + @Shared @Cached HostValueToEnsoNode hostValueToEnsoNode) { try { return convertToArray(arr, hostValueToEnsoNode); } catch (UnsupportedMessageException e) { diff --git a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/number/bigInteger/BitShiftNode.java b/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/number/bigInteger/BitShiftNode.java index 7612fdff45ab..6a8379f0a859 100644 --- a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/number/bigInteger/BitShiftNode.java +++ b/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/number/bigInteger/BitShiftNode.java @@ -2,9 +2,10 @@ import com.oracle.truffle.api.dsl.Fallback; import com.oracle.truffle.api.dsl.ImportStatic; +import com.oracle.truffle.api.dsl.NeverDefault; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.nodes.Node; -import com.oracle.truffle.api.profiles.ConditionProfile; +import com.oracle.truffle.api.profiles.CountingConditionProfile; import org.enso.interpreter.dsl.BuiltinMethod; import org.enso.interpreter.node.expression.builtin.number.utils.BigIntegerOps; import org.enso.interpreter.node.expression.builtin.number.utils.ToEnsoNumberNode; @@ -22,13 +23,14 @@ aliases = "bit_shift_l") public abstract class BitShiftNode extends Node { private @Child ToEnsoNumberNode toEnsoNumberNode = ToEnsoNumberNode.build(); - private final ConditionProfile fitsInIntProfileLeftShift = - ConditionProfile.createCountingProfile(); - private final ConditionProfile fitsInIntProfileRightShift = - ConditionProfile.createCountingProfile(); + private final CountingConditionProfile fitsInIntProfileLeftShift = + CountingConditionProfile.create(); + private final CountingConditionProfile fitsInIntProfileRightShift = + CountingConditionProfile.create(); abstract Object execute(Object self, Object that); + @NeverDefault static BitShiftNode build() { return BitShiftNodeGen.create(); } diff --git a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/number/bigInteger/BitShiftRightNode.java b/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/number/bigInteger/BitShiftRightNode.java index cf8834516477..638a7ae1d690 100644 --- a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/number/bigInteger/BitShiftRightNode.java +++ b/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/number/bigInteger/BitShiftRightNode.java @@ -1,6 +1,7 @@ package org.enso.interpreter.node.expression.builtin.number.bigInteger; import com.oracle.truffle.api.dsl.Cached; +import com.oracle.truffle.api.dsl.Cached.Shared; import com.oracle.truffle.api.dsl.Fallback; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.nodes.Node; @@ -21,13 +22,17 @@ static BitShiftRightNode build() { @Specialization Object doBigInteger( - EnsoBigInteger self, long that, @Cached("build()") BitShiftNode bitShiftNode) { + EnsoBigInteger self, + long that, + @Shared("bitShiftNode") @Cached("build()") BitShiftNode bitShiftNode) { return bitShiftNode.execute(self, -1L * that); } @Specialization Object doBigInteger( - EnsoBigInteger self, EnsoBigInteger that, @Cached("build()") BitShiftNode bitShiftNode) { + EnsoBigInteger self, + EnsoBigInteger that, + @Shared("bitShiftNode") @Cached("build()") BitShiftNode bitShiftNode) { return bitShiftNode.execute(self, new EnsoBigInteger(BigIntegerOps.negate(that.getValue()))); } diff --git a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/number/decimal/CeilNode.java b/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/number/decimal/CeilNode.java index cdfd8e966b2b..fd0a82d5d6f1 100644 --- a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/number/decimal/CeilNode.java +++ b/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/number/decimal/CeilNode.java @@ -2,7 +2,7 @@ import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.nodes.Node; -import com.oracle.truffle.api.profiles.ConditionProfile; +import com.oracle.truffle.api.profiles.CountingConditionProfile; import java.math.BigDecimal; import java.math.BigInteger; import org.enso.interpreter.dsl.BuiltinMethod; @@ -14,7 +14,7 @@ name = "ceil", description = "Decimal ceiling, converting to a small or big integer depending on size.") public class CeilNode extends Node { - private final ConditionProfile fitsProfile = ConditionProfile.createCountingProfile(); + private final CountingConditionProfile fitsProfile = CountingConditionProfile.create(); Object execute(double self) { double ceil = Math.ceil(self); diff --git a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/number/decimal/FloorNode.java b/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/number/decimal/FloorNode.java index adba588907e0..a4abfb07ed34 100644 --- a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/number/decimal/FloorNode.java +++ b/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/number/decimal/FloorNode.java @@ -2,7 +2,7 @@ import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.nodes.Node; -import com.oracle.truffle.api.profiles.ConditionProfile; +import com.oracle.truffle.api.profiles.CountingConditionProfile; import java.math.BigDecimal; import java.math.BigInteger; import org.enso.interpreter.dsl.BuiltinMethod; @@ -14,7 +14,7 @@ name = "floor", description = "Decimal floor, converting to a small or big integer depending on size.") public class FloorNode extends Node { - private final ConditionProfile fitsProfile = ConditionProfile.createCountingProfile(); + private final CountingConditionProfile fitsProfile = CountingConditionProfile.create(); Object execute(double self) { double floor = Math.floor(self); diff --git a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/number/decimal/TruncateNode.java b/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/number/decimal/TruncateNode.java index 9b9ca3d0661e..57abfe285a8c 100644 --- a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/number/decimal/TruncateNode.java +++ b/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/number/decimal/TruncateNode.java @@ -2,7 +2,7 @@ import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.nodes.Node; -import com.oracle.truffle.api.profiles.ConditionProfile; +import com.oracle.truffle.api.profiles.CountingConditionProfile; import java.math.BigDecimal; import java.math.BigInteger; import org.enso.interpreter.dsl.BuiltinMethod; @@ -14,7 +14,7 @@ name = "truncate_builtin", description = "Truncate a floating-point number to an integer by dropping the fractional part.") public class TruncateNode extends Node { - private final ConditionProfile fitsProfile = ConditionProfile.createCountingProfile(); + private final CountingConditionProfile fitsProfile = CountingConditionProfile.create(); Object execute(double self) { if (fitsProfile.profile(BigIntegerOps.fitsInLong(self))) { diff --git a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/number/smallInteger/BitShiftNode.java b/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/number/smallInteger/BitShiftNode.java index d4dcedd573a3..63da858da7e9 100644 --- a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/number/smallInteger/BitShiftNode.java +++ b/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/number/smallInteger/BitShiftNode.java @@ -2,9 +2,10 @@ import com.oracle.truffle.api.dsl.Fallback; import com.oracle.truffle.api.dsl.ImportStatic; +import com.oracle.truffle.api.dsl.NeverDefault; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.nodes.Node; -import com.oracle.truffle.api.profiles.ConditionProfile; +import com.oracle.truffle.api.profiles.CountingConditionProfile; import org.enso.interpreter.dsl.BuiltinMethod; import org.enso.interpreter.node.expression.builtin.number.utils.BigIntegerOps; import org.enso.interpreter.node.expression.builtin.number.utils.ToEnsoNumberNode; @@ -22,15 +23,16 @@ aliases = "bit_shift_l") public abstract class BitShiftNode extends Node { private @Child ToEnsoNumberNode toEnsoNumberNode = ToEnsoNumberNode.build(); - private final ConditionProfile canShiftLeftInLongProfile = - ConditionProfile.createCountingProfile(); - private final ConditionProfile positiveFitsInInt = ConditionProfile.createCountingProfile(); - private final ConditionProfile negativeFitsInInt = ConditionProfile.createCountingProfile(); - private final ConditionProfile rightShiftExceedsLongWidth = - ConditionProfile.createCountingProfile(); + private final CountingConditionProfile canShiftLeftInLongProfile = + CountingConditionProfile.create(); + private final CountingConditionProfile positiveFitsInInt = CountingConditionProfile.create(); + private final CountingConditionProfile negativeFitsInInt = CountingConditionProfile.create(); + private final CountingConditionProfile rightShiftExceedsLongWidth = + CountingConditionProfile.create(); abstract Object execute(long self, Object that); + @NeverDefault static BitShiftNode build() { return BitShiftNodeGen.create(); } diff --git a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/number/smallInteger/BitShiftRightNode.java b/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/number/smallInteger/BitShiftRightNode.java index 489054001b71..a8752966e835 100644 --- a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/number/smallInteger/BitShiftRightNode.java +++ b/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/number/smallInteger/BitShiftRightNode.java @@ -1,6 +1,7 @@ package org.enso.interpreter.node.expression.builtin.number.smallInteger; import com.oracle.truffle.api.dsl.Cached; +import com.oracle.truffle.api.dsl.Cached.Shared; import com.oracle.truffle.api.dsl.Fallback; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.nodes.Node; @@ -20,13 +21,16 @@ static BitShiftRightNode build() { } @Specialization - Object doBigInteger(long self, long that, @Cached("build()") BitShiftNode bitShiftNode) { + Object doBigInteger( + long self, long that, @Shared("bitShiftNode") @Cached("build()") BitShiftNode bitShiftNode) { return bitShiftNode.execute(self, -1L * that); } @Specialization Object doBigInteger( - long self, EnsoBigInteger that, @Cached("build()") BitShiftNode bitShiftNode) { + long self, + EnsoBigInteger that, + @Shared("bitShiftNode") @Cached("build()") BitShiftNode bitShiftNode) { return bitShiftNode.execute(self, new EnsoBigInteger(BigIntegerOps.negate(that.getValue()))); } diff --git a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/number/utils/ToEnsoNumberNode.java b/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/number/utils/ToEnsoNumberNode.java index 515af3d4be45..ff32d5ce243d 100644 --- a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/number/utils/ToEnsoNumberNode.java +++ b/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/number/utils/ToEnsoNumberNode.java @@ -4,14 +4,14 @@ import com.oracle.truffle.api.dsl.ReportPolymorphism; import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.nodes.NodeInfo; -import com.oracle.truffle.api.profiles.ConditionProfile; +import com.oracle.truffle.api.profiles.CountingConditionProfile; import java.math.BigInteger; import org.enso.interpreter.runtime.number.EnsoBigInteger; @ReportPolymorphism @NodeInfo(description = "Takes a big integer and casts it to a long, if the operation is safe.") public class ToEnsoNumberNode extends Node { - private final ConditionProfile fitsProfile = ConditionProfile.createCountingProfile(); + private final CountingConditionProfile fitsProfile = CountingConditionProfile.create(); /** @return a new instance of this node. */ public static ToEnsoNumberNode build() { diff --git a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/ordering/CustomComparatorNode.java b/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/ordering/CustomComparatorNode.java index dc31e8b9f741..13c1c422a4c7 100644 --- a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/ordering/CustomComparatorNode.java +++ b/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/ordering/CustomComparatorNode.java @@ -2,6 +2,7 @@ import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.GenerateUncached; +import com.oracle.truffle.api.dsl.NeverDefault; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.nodes.Node; import org.enso.interpreter.node.callable.InvokeCallableNode.ArgumentsExecutionMode; @@ -48,17 +49,18 @@ Type hasCustomComparatorCached( return res instanceof Type result && result != ctx.getBuiltins().defaultComparator().getType() ? result : null; } + @NeverDefault UnresolvedConversion createConversion() { var ctx = EnsoContext.get(this); var comparableType = ctx.getBuiltins().comparable().getType(); return UnresolvedConversion.build(comparableType.getDefinitionScope()); } + @NeverDefault static InvokeConversionNode buildConvertionNode() { CallArgumentInfo[] argSchema = new CallArgumentInfo[2]; argSchema[0] = new CallArgumentInfo(); argSchema[1] = new CallArgumentInfo(); - return InvokeConversionNode.build(argSchema, DefaultsExecutionMode.EXECUTE, ArgumentsExecutionMode.EXECUTE, 1); } } diff --git a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/ordering/HashCallbackNode.java b/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/ordering/HashCallbackNode.java index ad5f104b8009..cbe1b5ce8b3e 100644 --- a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/ordering/HashCallbackNode.java +++ b/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/ordering/HashCallbackNode.java @@ -3,6 +3,7 @@ import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.GenerateUncached; +import com.oracle.truffle.api.dsl.NeverDefault; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.interop.InteropLibrary; import com.oracle.truffle.api.interop.UnsupportedMessageException; @@ -65,6 +66,7 @@ long hashCallbackCached( /** * Builds an {@link InvokeFunctionNode} for a method with just one argument named {@code atom}. */ + @NeverDefault static InvokeFunctionNode buildInvokeNodeWithAtomArgument() { return InvokeFunctionNode.build( new CallArgumentInfo[] {new CallArgumentInfo("self"), new CallArgumentInfo("atom")}, @@ -72,6 +74,7 @@ static InvokeFunctionNode buildInvokeNodeWithAtomArgument() { ArgumentsExecutionMode.EXECUTE); } + @NeverDefault @TruffleBoundary Function getHashCallbackFunction() { var comparableType = EnsoContext.get(this).getBuiltins().comparable().getType(); diff --git a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/ordering/SortVectorNode.java b/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/ordering/SortVectorNode.java index 2e485fa517c2..78bcbaad246d 100644 --- a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/ordering/SortVectorNode.java +++ b/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/ordering/SortVectorNode.java @@ -3,6 +3,7 @@ import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.dsl.Cached; +import com.oracle.truffle.api.dsl.Cached.Shared; import com.oracle.truffle.api.dsl.GenerateUncached; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.interop.InteropLibrary; @@ -99,7 +100,7 @@ public abstract Object execute( "areAllDefaultComparators(interop, hostValueToEnsoNode, comparators)", "interop.isNull(byFunc)", "interop.isNull(onFunc)" - }) + }, limit = "3") Object sortPrimitives( State state, Object self, @@ -109,12 +110,12 @@ Object sortPrimitives( Object byFunc, Object onFunc, long problemBehavior, - @Cached LessThanNode lessThanNode, - @Cached EqualsNode equalsNode, + @Shared("lessThanNode") @Cached LessThanNode lessThanNode, + @Shared("equalsNode") @Cached EqualsNode equalsNode, @Cached HostValueToEnsoNode hostValueToEnsoNode, - @Cached TypeOfNode typeOfNode, - @Cached AnyToTextNode toTextNode, - @CachedLibrary(limit = "10") InteropLibrary interop) { + @Shared("typeOfNode") @Cached TypeOfNode typeOfNode, + @Shared("anyToTextNode") @Cached AnyToTextNode toTextNode, + @Shared("interop") @CachedLibrary(limit = "10") InteropLibrary interop) { EnsoContext ctx = EnsoContext.get(this); Object[] elems; try { @@ -182,13 +183,13 @@ Object sortGeneric( Object byFunc, Object onFunc, long problemBehaviorNum, - @CachedLibrary(limit = "10") InteropLibrary interop, + @Shared("interop") @CachedLibrary(limit = "10") InteropLibrary interop, @CachedLibrary(limit = "5") WarningsLibrary warningsLib, @CachedLibrary(limit = "5") TypesLibrary typesLib, - @Cached LessThanNode lessThanNode, - @Cached EqualsNode equalsNode, - @Cached TypeOfNode typeOfNode, - @Cached AnyToTextNode toTextNode, + @Shared("lessThanNode") @Cached LessThanNode lessThanNode, + @Shared("equalsNode") @Cached EqualsNode equalsNode, + @Shared("typeOfNode") @Cached TypeOfNode typeOfNode, + @Shared("anyToTextNode") @Cached AnyToTextNode toTextNode, @Cached MethodResolverNode methodResolverNode, @Cached(value = "build()", uncached = "build()") HostValueToEnsoNode hostValueToEnsoNode, @Cached(value = "build()", uncached = "build()") CallOptimiserNode callNode) { diff --git a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/state/RunStateNode.java b/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/state/RunStateNode.java index 61854b3e3dee..451982d06de3 100644 --- a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/state/RunStateNode.java +++ b/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/state/RunStateNode.java @@ -1,6 +1,7 @@ package org.enso.interpreter.node.expression.builtin.state; import com.oracle.truffle.api.dsl.Bind; +import com.oracle.truffle.api.dsl.Cached.Shared; import com.oracle.truffle.api.dsl.ReportPolymorphism; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.frame.VirtualFrame; @@ -38,7 +39,7 @@ Object doExisting( Object local, Object computation, @Bind("state.getContainer()") State.Container data, - @CachedLibrary(limit = "10") DynamicObjectLibrary objects) { + @Shared("dynamicObjectLib") @CachedLibrary(limit = "10") DynamicObjectLibrary objects) { var old = objects.getOrDefault(data, key, null); objects.put(data, key, local); try { @@ -57,7 +58,7 @@ Object doFresh( Object local, Object computation, @Bind("state.getContainer()") State.Container data, - @CachedLibrary(limit = "10") DynamicObjectLibrary objects) { + @Shared("dynamicObjectLib") @CachedLibrary(limit = "10") DynamicObjectLibrary objects) { objects.put(data, key, local); try { return thunkExecutorNode.executeThunk( diff --git a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/text/util/ExpectStringNode.java b/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/text/util/ExpectStringNode.java index 8f092d656711..805247cd74c1 100644 --- a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/text/util/ExpectStringNode.java +++ b/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/text/util/ExpectStringNode.java @@ -2,6 +2,7 @@ import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Fallback; +import com.oracle.truffle.api.dsl.NeverDefault; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.interop.InteropLibrary; import com.oracle.truffle.api.interop.UnsupportedMessageException; @@ -19,6 +20,7 @@ public abstract class ExpectStringNode extends Node { public abstract String execute(Object str); + @NeverDefault public static ExpectStringNode build() { return ExpectStringNodeGen.create(); } diff --git a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/text/util/ToJavaStringNode.java b/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/text/util/ToJavaStringNode.java index de9f85dac364..fe4b7b73b78f 100644 --- a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/text/util/ToJavaStringNode.java +++ b/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/text/util/ToJavaStringNode.java @@ -1,5 +1,6 @@ package org.enso.interpreter.node.expression.builtin.text.util; +import com.oracle.truffle.api.dsl.NeverDefault; import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.nodes.NodeInfo; import org.enso.interpreter.runtime.data.text.Text; @@ -24,6 +25,7 @@ public static ToJavaStringNode getUncached() { * * @return a new instance of this node. */ + @NeverDefault public static ToJavaStringNode build() { return new ToJavaStringNode(); } diff --git a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/debug/EvalNode.java b/engine/runtime/src/main/java/org/enso/interpreter/node/expression/debug/EvalNode.java index 17bb485dbad1..d39d45f1f0de 100644 --- a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/debug/EvalNode.java +++ b/engine/runtime/src/main/java/org/enso/interpreter/node/expression/debug/EvalNode.java @@ -3,6 +3,7 @@ import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.RootCallTarget; import com.oracle.truffle.api.dsl.Cached; +import com.oracle.truffle.api.dsl.Cached.Shared; import com.oracle.truffle.api.dsl.ReportPolymorphism; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.nodes.NodeInfo; @@ -93,13 +94,13 @@ Object doCached( State state, Text expression, @Cached("expression") Text cachedExpression, - @Cached("build()") ToJavaStringNode toJavaStringNode, + @Shared("toJavaStringNode") @Cached("build()") ToJavaStringNode toJavaStringNode, @Cached("toJavaStringNode.execute(expression)") String expressionStr, @Cached("callerInfo") CallerInfo cachedCallerInfo, @Cached( "parseExpression(callerInfo.getLocalScope(), callerInfo.getModuleScope(), expressionStr)") RootCallTarget cachedCallTarget, - @Cached("build()") ThunkExecutorNode thunkExecutorNode) { + @Shared("thunkExecutorNode") @Cached("build()") ThunkExecutorNode thunkExecutorNode) { Function thunk = Function.thunk(cachedCallTarget, callerInfo.getFrame()); return thunkExecutorNode.executeThunk(callerInfo.getFrame(), thunk, state, getTailStatus()); } @@ -109,8 +110,8 @@ Object doUncached( CallerInfo callerInfo, State state, Text expression, - @Cached("build()") ThunkExecutorNode thunkExecutorNode, - @Cached("build()") ToJavaStringNode toJavaStringNode) { + @Shared("thunkExecutorNode") @Cached("build()") ThunkExecutorNode thunkExecutorNode, + @Shared("toJavaStringNode") @Cached("build()") ToJavaStringNode toJavaStringNode) { RootCallTarget callTarget = parseExpression( callerInfo.getLocalScope(), diff --git a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/foreign/CoerceNothing.java b/engine/runtime/src/main/java/org/enso/interpreter/node/expression/foreign/CoerceNothing.java index d41147e24dd2..cd95f482b14c 100644 --- a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/foreign/CoerceNothing.java +++ b/engine/runtime/src/main/java/org/enso/interpreter/node/expression/foreign/CoerceNothing.java @@ -8,7 +8,7 @@ import com.oracle.truffle.api.interop.UnsupportedMessageException; import com.oracle.truffle.api.library.CachedLibrary; import com.oracle.truffle.api.nodes.Node; -import com.oracle.truffle.api.profiles.ConditionProfile; +import com.oracle.truffle.api.profiles.CountingConditionProfile; import org.enso.interpreter.runtime.EnsoContext; import org.enso.interpreter.runtime.error.Warning; import org.enso.interpreter.runtime.error.WarningsLibrary; @@ -34,7 +34,7 @@ public Object doNothing( Object value, @CachedLibrary(limit = "1") InteropLibrary interop, @CachedLibrary(limit = "3") WarningsLibrary warningsLibrary, - @Cached("createCountingProfile()") ConditionProfile nullWarningProfile) { + @Cached CountingConditionProfile nullWarningProfile) { var ctx = EnsoContext.get(this); var nothing = ctx.getBuiltins().nothing(); if (nullWarningProfile.profile(warningsLibrary.hasWarnings(value))) { diff --git a/engine/runtime/src/main/java/org/enso/interpreter/runtime/callable/atom/Atom.java b/engine/runtime/src/main/java/org/enso/interpreter/runtime/callable/atom/Atom.java index 8367bb08d71d..a6fa66bc1e0d 100644 --- a/engine/runtime/src/main/java/org/enso/interpreter/runtime/callable/atom/Atom.java +++ b/engine/runtime/src/main/java/org/enso/interpreter/runtime/callable/atom/Atom.java @@ -188,7 +188,8 @@ static UnresolvedSymbol buildSym(AtomConstructor cons, String name) { } @Specialization( - guards = {"receiver.getConstructor() == cachedConstructor", "member.equals(cachedMember)"}) + guards = {"receiver.getConstructor() == cachedConstructor", "member.equals(cachedMember)"}, + limit = "3") static Object doCached( Atom receiver, String member, diff --git a/engine/runtime/src/main/java/org/enso/interpreter/runtime/callable/function/Function.java b/engine/runtime/src/main/java/org/enso/interpreter/runtime/callable/function/Function.java index 3e527a8501f3..1052c0ee5082 100644 --- a/engine/runtime/src/main/java/org/enso/interpreter/runtime/callable/function/Function.java +++ b/engine/runtime/src/main/java/org/enso/interpreter/runtime/callable/function/Function.java @@ -4,6 +4,7 @@ import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; import com.oracle.truffle.api.RootCallTarget; import com.oracle.truffle.api.dsl.Cached; +import com.oracle.truffle.api.dsl.Idempotent; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.frame.MaterializedFrame; import com.oracle.truffle.api.interop.*; @@ -141,6 +142,7 @@ public MaterializedFrame getScope() { * * @return the function's argument schema */ + @Idempotent public FunctionSchema getSchema() { return schema; } diff --git a/engine/runtime/src/main/java/org/enso/interpreter/runtime/data/Array.java b/engine/runtime/src/main/java/org/enso/interpreter/runtime/data/Array.java index 57ba8e1a3e88..d026a89054a1 100644 --- a/engine/runtime/src/main/java/org/enso/interpreter/runtime/data/Array.java +++ b/engine/runtime/src/main/java/org/enso/interpreter/runtime/data/Array.java @@ -2,6 +2,7 @@ import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.dsl.Cached; +import com.oracle.truffle.api.dsl.Cached.Shared; import com.oracle.truffle.api.interop.InteropLibrary; import com.oracle.truffle.api.interop.InvalidArrayIndexException; import com.oracle.truffle.api.interop.TruffleObject; @@ -199,7 +200,7 @@ private boolean hasWarningElements(Object[] items, WarningsLibrary warnings) { } @ExportMessage - boolean hasWarnings(@CachedLibrary(limit = "3") WarningsLibrary warnings) { + boolean hasWarnings(@Shared("warnsLib") @CachedLibrary(limit = "3") WarningsLibrary warnings) { if (withWarnings == null) { withWarnings = hasWarningElements(items, warnings); } @@ -207,7 +208,8 @@ boolean hasWarnings(@CachedLibrary(limit = "3") WarningsLibrary warnings) { } @ExportMessage - Warning[] getWarnings(Node location, @CachedLibrary(limit = "3") WarningsLibrary warnings) + Warning[] getWarnings( + Node location, @Shared("warnsLib") @CachedLibrary(limit = "3") WarningsLibrary warnings) throws UnsupportedMessageException { if (cachedWarnings == null) { cachedWarnings = Warning.fromSetToArray(collectAllWarnings(warnings, location)); @@ -228,7 +230,7 @@ private EconomicSet collectAllWarnings(WarningsLibrary warnings, Node l } @ExportMessage - Array removeWarnings(@CachedLibrary(limit = "3") WarningsLibrary warnings) + Array removeWarnings(@Shared("warnsLib") @CachedLibrary(limit = "3") WarningsLibrary warnings) throws UnsupportedMessageException { Object[] items = new Object[this.items.length]; for (int i = 0; i < this.items.length; i++) { @@ -242,7 +244,7 @@ Array removeWarnings(@CachedLibrary(limit = "3") WarningsLibrary warnings) } @ExportMessage - boolean isLimitReached(@CachedLibrary(limit = "3") WarningsLibrary warnings) { + boolean isLimitReached(@Shared("warnsLib") @CachedLibrary(limit = "3") WarningsLibrary warnings) { try { int limit = EnsoContext.get(warnings).getWarningsLimit(); return getWarnings(null, warnings).length >= limit; diff --git a/engine/runtime/src/main/java/org/enso/interpreter/runtime/data/ArraySlice.java b/engine/runtime/src/main/java/org/enso/interpreter/runtime/data/ArraySlice.java index eedb6132dd1e..f1b6149606ba 100644 --- a/engine/runtime/src/main/java/org/enso/interpreter/runtime/data/ArraySlice.java +++ b/engine/runtime/src/main/java/org/enso/interpreter/runtime/data/ArraySlice.java @@ -2,6 +2,7 @@ import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.dsl.Cached; +import com.oracle.truffle.api.dsl.Cached.Shared; import com.oracle.truffle.api.interop.InteropLibrary; import com.oracle.truffle.api.interop.TruffleObject; import com.oracle.truffle.api.interop.InvalidArrayIndexException; @@ -66,7 +67,8 @@ public boolean hasArrayElements() { } @ExportMessage - public long getArraySize(@CachedLibrary(limit = "3") InteropLibrary interop) + public long getArraySize( + @Shared("interop") @CachedLibrary(limit = "3") InteropLibrary interop) throws UnsupportedMessageException { long storageSize = interop.getArraySize(storage); return Math.max(0, Math.min(storageSize, end) - start); @@ -82,7 +84,7 @@ public long getArraySize(@CachedLibrary(limit = "3") InteropLibrary interop) @ExportMessage public Object readArrayElement( long index, - @CachedLibrary(limit = "3") InteropLibrary interop, + @Shared("interop") @CachedLibrary(limit = "3") InteropLibrary interop, @CachedLibrary(limit = "3") WarningsLibrary warnings, @Cached HostValueToEnsoNode toEnso) throws InvalidArrayIndexException, UnsupportedMessageException { @@ -108,7 +110,9 @@ public Object readArrayElement( * @return {@code true} if the index is valid, {@code false} otherwise. */ @ExportMessage - boolean isArrayElementReadable(long index, @CachedLibrary(limit = "3") InteropLibrary interop) { + boolean isArrayElementReadable( + long index, + @Shared("interop") @CachedLibrary(limit = "3") InteropLibrary interop) { try { return index >= 0 && index < getArraySize(interop); } catch (UnsupportedMessageException e) { @@ -143,23 +147,23 @@ final void removeArrayElement(long index) throws UnsupportedMessageException { } @ExportMessage - boolean hasWarnings(@CachedLibrary(limit = "3") WarningsLibrary warnings) { + boolean hasWarnings(@Shared("warnsLib") @CachedLibrary(limit = "3") WarningsLibrary warnings) { return warnings.hasWarnings(this.storage); } @ExportMessage - Warning[] getWarnings(Node location, @CachedLibrary(limit = "3") WarningsLibrary warnings) throws UnsupportedMessageException { + Warning[] getWarnings(Node location, @Shared("warnsLib") @CachedLibrary(limit = "3") WarningsLibrary warnings) throws UnsupportedMessageException { return warnings.getWarnings(this.storage, location); } @ExportMessage - Object removeWarnings(@CachedLibrary(limit = "3") WarningsLibrary warnings) throws UnsupportedMessageException { + Object removeWarnings(@Shared("warnsLib") @CachedLibrary(limit = "3") WarningsLibrary warnings) throws UnsupportedMessageException { Object newStorage = warnings.removeWarnings(this.storage); return new ArraySlice(newStorage, start, end); } @ExportMessage - boolean isLimitReached(@CachedLibrary(limit = "3") WarningsLibrary warnings) { + boolean isLimitReached(@Shared("warnsLib") @CachedLibrary(limit = "3") WarningsLibrary warnings) { return warnings.isLimitReached(this.storage); } diff --git a/engine/runtime/src/main/java/org/enso/interpreter/runtime/data/Vector.java b/engine/runtime/src/main/java/org/enso/interpreter/runtime/data/Vector.java index 9f730a760e92..a966d47a5d99 100644 --- a/engine/runtime/src/main/java/org/enso/interpreter/runtime/data/Vector.java +++ b/engine/runtime/src/main/java/org/enso/interpreter/runtime/data/Vector.java @@ -2,6 +2,7 @@ import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.dsl.Cached; +import com.oracle.truffle.api.dsl.Cached.Shared; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.interop.InteropLibrary; import com.oracle.truffle.api.interop.InvalidArrayIndexException; @@ -91,7 +92,7 @@ boolean hasArrayElements() { } @ExportMessage - long getArraySize(@CachedLibrary(limit = "3") InteropLibrary interop) + long getArraySize(@Shared("interop") @CachedLibrary(limit = "3") InteropLibrary interop) throws UnsupportedMessageException { return interop.getArraySize(storage); } @@ -106,7 +107,7 @@ long getArraySize(@CachedLibrary(limit = "3") InteropLibrary interop) @ExportMessage public Object readArrayElement( long index, - @CachedLibrary(limit = "3") InteropLibrary interop, + @Shared("interop") @CachedLibrary(limit = "3") InteropLibrary interop, @CachedLibrary(limit = "3") WarningsLibrary warnings, @Cached HostValueToEnsoNode toEnso) throws InvalidArrayIndexException, UnsupportedMessageException { @@ -132,7 +133,8 @@ public static Vector fromArray(Object arr) { * @return {@code true} if the index is valid, {@code false} otherwise. */ @ExportMessage - boolean isArrayElementReadable(long index, @CachedLibrary(limit = "3") InteropLibrary interop) { + boolean isArrayElementReadable( + long index, @Shared("interop") @CachedLibrary(limit = "3") InteropLibrary interop) { try { var size = interop.getArraySize(storage); return index < size && index >= 0; @@ -199,24 +201,25 @@ Type getType(@CachedLibrary("this") TypesLibrary thisLib) { } @ExportMessage - boolean hasWarnings(@CachedLibrary(limit = "3") WarningsLibrary warnings) { + boolean hasWarnings(@Shared("warnsLib") @CachedLibrary(limit = "3") WarningsLibrary warnings) { return warnings.hasWarnings(this.storage); } @ExportMessage - Warning[] getWarnings(Node location, @CachedLibrary(limit = "3") WarningsLibrary warnings) + Warning[] getWarnings( + Node location, @Shared("warnsLib") @CachedLibrary(limit = "3") WarningsLibrary warnings) throws UnsupportedMessageException { return warnings.getWarnings(this.storage, location); } @ExportMessage - Vector removeWarnings(@CachedLibrary(limit = "3") WarningsLibrary warnings) + Vector removeWarnings(@Shared("warnsLib") @CachedLibrary(limit = "3") WarningsLibrary warnings) throws UnsupportedMessageException { return new Vector(warnings.removeWarnings(this.storage)); } @ExportMessage - boolean isLimitReached(@CachedLibrary(limit = "3") WarningsLibrary warnings) { + boolean isLimitReached(@Shared("warnsLib") @CachedLibrary(limit = "3") WarningsLibrary warnings) { return warnings.isLimitReached(this.storage); } diff --git a/engine/runtime/src/main/java/org/enso/interpreter/runtime/data/hash/HashMapGetNode.java b/engine/runtime/src/main/java/org/enso/interpreter/runtime/data/hash/HashMapGetNode.java index 8004337561c5..af7a47dae47a 100644 --- a/engine/runtime/src/main/java/org/enso/interpreter/runtime/data/hash/HashMapGetNode.java +++ b/engine/runtime/src/main/java/org/enso/interpreter/runtime/data/hash/HashMapGetNode.java @@ -1,6 +1,7 @@ package org.enso.interpreter.runtime.data.hash; import com.oracle.truffle.api.dsl.Cached; +import com.oracle.truffle.api.dsl.Cached.Shared; import com.oracle.truffle.api.dsl.Fallback; import com.oracle.truffle.api.dsl.GenerateUncached; import com.oracle.truffle.api.dsl.Specialization; @@ -39,7 +40,7 @@ Object hashMapGet( VirtualFrame frame, State state, Object self, Object key, Object defaultValue, @CachedLibrary("self") InteropLibrary interop, - @Cached("build()") ThunkExecutorNode thunkExecutorNode) { + @Shared @Cached("build()") ThunkExecutorNode thunkExecutorNode) { if (interop.isHashEntryReadable(self, key)) { try { return interop.readHashValue(self, key); @@ -53,7 +54,7 @@ Object hashMapGet( @Fallback Object fallback(VirtualFrame frame, State state, Object self, Object key, Object defaultValue, - @Cached("build()") ThunkExecutorNode thunkExecutorNode) { + @Shared @Cached("build()") ThunkExecutorNode thunkExecutorNode) { return thunkExecutorNode.executeThunk(frame, defaultValue, state, TailStatus.NOT_TAIL); } } diff --git a/engine/runtime/src/main/java/org/enso/interpreter/runtime/error/PanicException.java b/engine/runtime/src/main/java/org/enso/interpreter/runtime/error/PanicException.java index 08bd42434d7c..3dd6c112b0f2 100644 --- a/engine/runtime/src/main/java/org/enso/interpreter/runtime/error/PanicException.java +++ b/engine/runtime/src/main/java/org/enso/interpreter/runtime/error/PanicException.java @@ -2,6 +2,7 @@ import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.dsl.Cached; +import com.oracle.truffle.api.dsl.NeverDefault; import com.oracle.truffle.api.exception.AbstractTruffleException; import com.oracle.truffle.api.interop.ExceptionType; import com.oracle.truffle.api.interop.InteropLibrary; @@ -87,6 +88,7 @@ boolean hasExceptionMessage() { return true; } + @NeverDefault static UnresolvedSymbol toDisplayText(IndirectInvokeMethodNode payloads) { var ctx = EnsoContext.get(payloads); var scope = ctx.getBuiltins().panic().getDefinitionScope(); diff --git a/engine/runtime/src/main/java/org/enso/interpreter/runtime/error/WithWarnings.java b/engine/runtime/src/main/java/org/enso/interpreter/runtime/error/WithWarnings.java index 7504c188bb53..19afb9bfc911 100644 --- a/engine/runtime/src/main/java/org/enso/interpreter/runtime/error/WithWarnings.java +++ b/engine/runtime/src/main/java/org/enso/interpreter/runtime/error/WithWarnings.java @@ -1,6 +1,7 @@ package org.enso.interpreter.runtime.error; import com.oracle.truffle.api.CompilerDirectives; +import com.oracle.truffle.api.dsl.Cached.Shared; import org.enso.interpreter.runtime.EnsoContext; import org.enso.interpreter.runtime.data.ArrayRope; import org.enso.interpreter.runtime.library.dispatch.TypesLibrary; @@ -161,7 +162,8 @@ boolean hasWarnings() { @ExportMessage Warning[] getWarnings( - Node location, @CachedLibrary(limit = "3") WarningsLibrary warningsLibrary) { + Node location, + @Shared("warnsLib") @CachedLibrary(limit = "3") WarningsLibrary warningsLibrary) { if (location != null) { return getReassignedWarnings(location, warningsLibrary); } else { @@ -170,7 +172,8 @@ Warning[] getWarnings( } @ExportMessage - Object removeWarnings(@CachedLibrary(limit = "3") WarningsLibrary warnings) + Object removeWarnings( + @Shared("warnsLib") @CachedLibrary(limit = "3") WarningsLibrary warnings) throws UnsupportedMessageException { if (warnings.hasWarnings(value)) { return warnings.removeWarnings(value); diff --git a/lib/scala/interpreter-dsl/src/main/java/org/enso/interpreter/dsl/MethodProcessor.java b/lib/scala/interpreter-dsl/src/main/java/org/enso/interpreter/dsl/MethodProcessor.java index 1347a1eed1bc..6af6343a26ea 100644 --- a/lib/scala/interpreter-dsl/src/main/java/org/enso/interpreter/dsl/MethodProcessor.java +++ b/lib/scala/interpreter-dsl/src/main/java/org/enso/interpreter/dsl/MethodProcessor.java @@ -125,7 +125,7 @@ private void handleTypeElement(TypeElement element, RoundEnvironment roundEnv, B "com.oracle.truffle.api.nodes.RootNode", "com.oracle.truffle.api.nodes.UnexpectedResultException", "com.oracle.truffle.api.profiles.BranchProfile", - "com.oracle.truffle.api.profiles.ConditionProfile", + "com.oracle.truffle.api.profiles.CountingConditionProfile", "java.nio.file.OpenOption", "org.enso.interpreter.EnsoLanguage", "org.enso.interpreter.node.InlineableNode", @@ -177,9 +177,9 @@ private void generateCode(MethodDefinition methodDefinition) throws IOException if (arg.shouldCheckErrors()) { String condName = mkArgumentInternalVarName(arg) + DATAFLOW_ERROR_PROFILE; out.println( - " private final ConditionProfile " + " private final CountingConditionProfile " + condName - + " = ConditionProfile.createCountingProfile();"); + + " = CountingConditionProfile.create();"); } if (arg.isPositional() && !arg.isSelf()) { diff --git a/lib/scala/interpreter-dsl/src/main/java/org/enso/interpreter/dsl/builtins/SpecializedMethodParameter.java b/lib/scala/interpreter-dsl/src/main/java/org/enso/interpreter/dsl/builtins/SpecializedMethodParameter.java index 755b4102880d..69fdbc745bd8 100644 --- a/lib/scala/interpreter-dsl/src/main/java/org/enso/interpreter/dsl/builtins/SpecializedMethodParameter.java +++ b/lib/scala/interpreter-dsl/src/main/java/org/enso/interpreter/dsl/builtins/SpecializedMethodParameter.java @@ -91,7 +91,7 @@ public Optional auxParamDef() { public Stream declaredParameter() { return Stream.of( "Object " + param.name(), - "@Cached(\"" + cachedExpr + "\") " + cacheNode + " " + cacheNodeParam); + "@Cached.Exclusive @Cached(\"" + cachedExpr + "\") " + cacheNode + " " + cacheNodeParam); } } @@ -116,7 +116,7 @@ public Optional auxParamDef() { @Override public Stream declaredParameter() { - return Stream.of("@CachedLibrary(" + cachedExpr + ") " + param.tpe() + " " + param.name()); + return Stream.of("@Cached.Exclusive @CachedLibrary(" + cachedExpr + ") " + param.tpe() + " " + param.name()); } public static final String INTEROP_LIBRARY = "com.oracle.truffle.api.interop.InteropLibrary"; From 04dbffaf6c5700f33ab403bd3e98fbe2066bedeb Mon Sep 17 00:00:00 2001 From: Pavel Marek Date: Wed, 5 Jul 2023 16:44:36 +0200 Subject: [PATCH 16/51] Fix build.sbt after merge --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index ae8e1059992a..c845588f19e7 100644 --- a/build.sbt +++ b/build.sbt @@ -2046,7 +2046,7 @@ lazy val `std-image` = project Compile / packageBin / artifactPath := `image-polyglot-root` / "std-image.jar", libraryDependencies ++= Seq( - "org.graalvm.sdk" % "graal-sdk" % graalVersion % "provided", + "org.graalvm.sdk" % "graal-sdk" % graalMavenVersion % "provided", "org.netbeans.api" % "org-openide-util-lookup" % netbeansApiVersion % "provided", "org.openpnp" % "opencv" % "4.7.0-0" ), From fdbf42124a76591b8ae5f82b7b641898d03d7c81 Mon Sep 17 00:00:00 2001 From: Pavel Marek Date: Wed, 5 Jul 2023 16:45:05 +0200 Subject: [PATCH 17/51] Add some `@Shared` parameters after develop merge --- .../builtin/immutable/FlattenVectorNode.java | 13 +++++++--- .../immutable/InsertBuiltinVectorNode.java | 25 ++++++++++--------- .../builtin/immutable/RemoveAtVectorNode.java | 13 +++++----- .../builtin/mutable/CoerceArrayNode.java | 4 +-- 4 files changed, 32 insertions(+), 23 deletions(-) diff --git a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/immutable/FlattenVectorNode.java b/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/immutable/FlattenVectorNode.java index 6d8f26957040..ca7ef1bd7aed 100644 --- a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/immutable/FlattenVectorNode.java +++ b/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/immutable/FlattenVectorNode.java @@ -2,6 +2,7 @@ import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.dsl.Cached; +import com.oracle.truffle.api.dsl.Cached.Shared; import com.oracle.truffle.api.dsl.Fallback; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.interop.InteropLibrary; @@ -31,7 +32,9 @@ static FlattenVectorNode build() { @Specialization Vector fromVector( - Vector self, @Cached CopyNode copyNode, @CachedLibrary(limit = "3") InteropLibrary interop) { + Vector self, + @Shared("copyNode") @Cached CopyNode copyNode, + @Shared("interop") @CachedLibrary(limit = "3") InteropLibrary interop) { try { return flatten(self.toArray(), copyNode, interop); } catch (UnsupportedMessageException e) { @@ -44,7 +47,9 @@ Vector fromVector( @Specialization Vector fromArray( - Array self, @Cached CopyNode copyNode, @CachedLibrary(limit = "3") InteropLibrary interop) { + Array self, + @Shared("copyNode") @Cached CopyNode copyNode, + @Shared("interop") @CachedLibrary(limit = "3") InteropLibrary interop) { try { return flatten(self, copyNode, interop); } catch (UnsupportedMessageException e) { @@ -54,7 +59,9 @@ Vector fromArray( @Specialization(guards = "interop.hasArrayElements(self)") Vector fromArrayLike( - Object self, @Cached CopyNode copyNode, @CachedLibrary(limit = "3") InteropLibrary interop) { + Object self, + @Shared("copyNode") @Cached CopyNode copyNode, + @Shared("interop") @CachedLibrary(limit = "3") InteropLibrary interop) { try { return flatten(self, copyNode, interop); } catch (UnsupportedMessageException e) { diff --git a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/immutable/InsertBuiltinVectorNode.java b/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/immutable/InsertBuiltinVectorNode.java index 4c04475962c8..58ec218c7575 100644 --- a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/immutable/InsertBuiltinVectorNode.java +++ b/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/immutable/InsertBuiltinVectorNode.java @@ -1,6 +1,7 @@ package org.enso.interpreter.node.expression.builtin.immutable; import com.oracle.truffle.api.dsl.Cached; +import com.oracle.truffle.api.dsl.Cached.Shared; import com.oracle.truffle.api.dsl.Fallback; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.interop.InteropLibrary; @@ -31,8 +32,8 @@ Vector fromVector( Vector vec, long index, Vector values, - @Cached CopyNode copyNode, - @CachedLibrary(limit = "3") InteropLibrary interop) { + @Shared("copyNode") @Cached CopyNode copyNode, + @Shared("interop") @CachedLibrary(limit = "3") InteropLibrary interop) { return insertBuiltin(vec.toArray(), index, values.toArray(), copyNode, interop); } @@ -41,8 +42,8 @@ Vector fromArray( Array vec, long index, Vector values, - @Cached CopyNode copyNode, - @CachedLibrary(limit = "3") InteropLibrary interop) { + @Shared("copyNode") @Cached CopyNode copyNode, + @Shared("interop") @CachedLibrary(limit = "3") InteropLibrary interop) { return insertBuiltin(vec, index, values.toArray(), copyNode, interop); } @@ -51,8 +52,8 @@ Vector fromArrayLike( Object vec, long index, Vector values, - @Cached CopyNode copyNode, - @CachedLibrary(limit = "3") InteropLibrary interop) { + @Shared("copyNode") @Cached CopyNode copyNode, + @Shared("interop") @CachedLibrary(limit = "3") InteropLibrary interop) { return insertBuiltin(vec, index, values.toArray(), copyNode, interop); } @@ -61,8 +62,8 @@ Vector fromVectorWithArrayLikeObject( Vector vec, long index, Object values, - @Cached CopyNode copyNode, - @CachedLibrary(limit = "3") InteropLibrary interop) { + @Shared("copyNode") @Cached CopyNode copyNode, + @Shared("interop") @CachedLibrary(limit = "3") InteropLibrary interop) { return insertBuiltin(vec.toArray(), index, values, copyNode, interop); } @@ -71,8 +72,8 @@ Vector fromArrayWithArrayLikeObject( Array vec, long index, Object values, - @Cached CopyNode copyNode, - @CachedLibrary(limit = "3") InteropLibrary interop) { + @Shared("copyNode") @Cached CopyNode copyNode, + @Shared("interop") @CachedLibrary(limit = "3") InteropLibrary interop) { return insertBuiltin(vec, index, values, copyNode, interop); } @@ -81,8 +82,8 @@ Vector fromArrayLikeWithArrayLikeObject( Object vec, long index, Object values, - @Cached CopyNode copyNode, - @CachedLibrary(limit = "3") InteropLibrary interop) { + @Shared("copyNode") @Cached CopyNode copyNode, + @Shared("interop") @CachedLibrary(limit = "3") InteropLibrary interop) { return insertBuiltin(vec, index, values, copyNode, interop); } diff --git a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/immutable/RemoveAtVectorNode.java b/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/immutable/RemoveAtVectorNode.java index cc4bed49ff2d..0eb966b8fb43 100644 --- a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/immutable/RemoveAtVectorNode.java +++ b/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/immutable/RemoveAtVectorNode.java @@ -2,6 +2,7 @@ import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.dsl.Cached; +import com.oracle.truffle.api.dsl.Cached.Shared; import com.oracle.truffle.api.dsl.Fallback; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.interop.InteropLibrary; @@ -32,8 +33,8 @@ static RemoveAtVectorNode build() { Vector fromVector( Vector vec, long index, - @Cached CopyNode copyNode, - @CachedLibrary(limit = "3") InteropLibrary interop) { + @Shared("copyNode") @Cached CopyNode copyNode, + @Shared("interop") @CachedLibrary(limit = "3") InteropLibrary interop) { try { return removeAtIndex(vec.toArray(), index, copyNode, interop); } catch (UnsupportedMessageException e) { @@ -47,8 +48,8 @@ Vector fromVector( Vector fromArray( Array vec, long index, - @Cached CopyNode copyNode, - @CachedLibrary(limit = "3") InteropLibrary interop) { + @Shared("copyNode") @Cached CopyNode copyNode, + @Shared("interop") @CachedLibrary(limit = "3") InteropLibrary interop) { try { return removeAtIndex(vec, index, copyNode, interop); } catch (UnsupportedMessageException e) { @@ -60,8 +61,8 @@ Vector fromArray( Vector fromArrayLike( Object vec, long index, - @Cached CopyNode copyNode, - @CachedLibrary(limit = "3") InteropLibrary interop) { + @Shared("copyNode") @Cached CopyNode copyNode, + @Shared("interop") @CachedLibrary(limit = "3") InteropLibrary interop) { try { return removeAtIndex(vec, index, copyNode, interop); } catch (UnsupportedMessageException e) { diff --git a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/mutable/CoerceArrayNode.java b/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/mutable/CoerceArrayNode.java index ce59eac91cc8..284e9d05f76d 100644 --- a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/mutable/CoerceArrayNode.java +++ b/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/mutable/CoerceArrayNode.java @@ -34,7 +34,7 @@ Object[] doArray(Array arr) { } @Specialization - Object[] doVector(Vector arr, @Shared @Cached CoerceArrayNode coerceArrayNode) { + Object[] doVector(Vector arr, @Cached CoerceArrayNode coerceArrayNode) { return coerceArrayNode.execute(arr.toArray()); } @@ -42,7 +42,7 @@ Object[] doVector(Vector arr, @Shared @Cached CoerceArrayNode coerceArrayNode) { Object[] doArrayLike( Object arr, @CachedLibrary(limit = "5") InteropLibrary interop, - @Shared @Cached HostValueToEnsoNode hostValueToEnsoNode) { + @Cached HostValueToEnsoNode hostValueToEnsoNode) { try { return convertToArray(arr, hostValueToEnsoNode); } catch (UnsupportedMessageException e) { From f0a24aa51726aeeef0792f95549edffa41425ab9 Mon Sep 17 00:00:00 2001 From: Pavel Marek Date: Wed, 5 Jul 2023 16:52:21 +0200 Subject: [PATCH 18/51] Remove Truffle DSL processor options from projects that don't run the processor --- build.sbt | 4 ---- 1 file changed, 4 deletions(-) diff --git a/build.sbt b/build.sbt index c845588f19e7..78be0b94c466 100644 --- a/build.sbt +++ b/build.sbt @@ -1394,7 +1394,6 @@ lazy val `runtime-instrument-common` = .configs(Benchmark) .settings( frgaalJavaCompilerSetting, - truffleDslSuppressWarnsSetting, inConfig(Compile)(truffleRunOptionsSettings), inConfig(Benchmark)(Defaults.testSettings), instrumentationSettings, @@ -1417,7 +1416,6 @@ lazy val `runtime-instrument-id-execution` = (project in file("engine/runtime-instrument-id-execution")) .settings( inConfig(Compile)(truffleRunOptionsSettings), - truffleDslSuppressWarnsSetting, instrumentationSettings ) .dependsOn(runtime) @@ -1427,7 +1425,6 @@ lazy val `runtime-instrument-repl-debugger` = (project in file("engine/runtime-instrument-repl-debugger")) .settings( inConfig(Compile)(truffleRunOptionsSettings), - truffleDslSuppressWarnsSetting, instrumentationSettings ) .dependsOn(runtime) @@ -1437,7 +1434,6 @@ lazy val `runtime-instrument-runtime-server` = (project in file("engine/runtime-instrument-runtime-server")) .settings( inConfig(Compile)(truffleRunOptionsSettings), - truffleDslSuppressWarnsSetting, instrumentationSettings ) .dependsOn(runtime) From 1f59a629bae7c8a744a6b7bf85849f3a7deaef05 Mon Sep 17 00:00:00 2001 From: Pavel Marek Date: Wed, 5 Jul 2023 16:57:54 +0200 Subject: [PATCH 19/51] Rollback .idea run configuration changes --- .../run-enso-build-cli-native.xml | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/.idea/runConfigurations/run-enso-build-cli-native.xml b/.idea/runConfigurations/run-enso-build-cli-native.xml index 4a8a188d3e29..ddb8a1b4aa80 100644 --- a/.idea/runConfigurations/run-enso-build-cli-native.xml +++ b/.idea/runConfigurations/run-enso-build-cli-native.xml @@ -1,21 +1,27 @@ - - - + \ No newline at end of file From 83ca38475c51168ea7d1257d532e5a6208208d4e Mon Sep 17 00:00:00 2001 From: Pavel Marek Date: Wed, 5 Jul 2023 17:49:00 +0200 Subject: [PATCH 20/51] Build tool: No Aarch64 graalvm package for Apple M1 --- build/ci_utils/src/cache/goodie/graalvm.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/build/ci_utils/src/cache/goodie/graalvm.rs b/build/ci_utils/src/cache/goodie/graalvm.rs index f2cda4926b1e..861bd520deca 100644 --- a/build/ci_utils/src/cache/goodie/graalvm.rs +++ b/build/ci_utils/src/cache/goodie/graalvm.rs @@ -99,6 +99,8 @@ impl GraalVM { }; let arch_name = match *arch { Arch::X86_64 => "x64", + // No Graal packages for Apple Silicon. + Arch::AArch64 if TARGET_OS == OS::MacOS => "x64", Arch::AArch64 => "aarch64", other_arch => unimplemented!("Architecture `{}` is not supported!", other_arch), }; From 611212cf69922e0891863ac73f11da50ae1c0c27 Mon Sep 17 00:00:00 2001 From: Pavel Marek Date: Thu, 6 Jul 2023 10:08:55 +0200 Subject: [PATCH 21/51] Fix order in CHANGELOG --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a0a801d1d8f2..c629e84e7fd8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -851,8 +851,8 @@ - [Added retries when executing GraalVM updater][7079] - [Add method call info for infix operators][7090] - [`executionComplete` response is sent on successful execution only][7143] -- [Update to GraalVM 23.0.0][7176] - [Send info about function values][7168] +- [Update to GraalVM 23.0.0][7176] [3227]: https://github.com/enso-org/enso/pull/3227 [3248]: https://github.com/enso-org/enso/pull/3248 @@ -976,8 +976,8 @@ [7079]: https://github.com/enso-org/enso/pull/7079 [7090]: https://github.com/enso-org/enso/pull/7090 [7143]: https://github.com/enso-org/enso/pull/7143 -[7176]: https://github.com/enso-org/enso/pull/7176 [7168]: https://github.com/enso-org/enso/pull/7168 +[7176]: https://github.com/enso-org/enso/pull/7176 # Enso 2.0.0-alpha.18 (2021-10-12) From c5a892ebda152a58450584adf4be05356c517507 Mon Sep 17 00:00:00 2001 From: Pavel Marek Date: Thu, 6 Jul 2023 10:24:45 +0200 Subject: [PATCH 22/51] Remove every dir in PATH exists asserts from build script Windows sets up unrelated PATHS that do not exist and therefore panics. --- build/ci_utils/src/env.rs | 3 --- 1 file changed, 3 deletions(-) diff --git a/build/ci_utils/src/env.rs b/build/ci_utils/src/env.rs index 5dea648c3878..6f60f3a4f934 100644 --- a/build/ci_utils/src/env.rs +++ b/build/ci_utils/src/env.rs @@ -182,9 +182,6 @@ impl Modification { "Prepending to {} the following paths: {:?}", self.variable_name, paths_to_prepend ); - for path in paths_to_prepend { - assert!(path.exists()); - } let new_paths_set = paths_to_prepend.iter().collect::>(); let old_paths = std::env::split_paths(&old_value).collect_vec(); From c98693780626cca8ee3ab4b41e0bc52a6c6598a4 Mon Sep 17 00:00:00 2001 From: Pavel Marek Date: Tue, 11 Jul 2023 17:10:25 +0200 Subject: [PATCH 23/51] Bools and numbers do not share interop lib --- .../java/org/enso/interpreter/epb/node/ContextRewrapNode.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/engine/runtime-language-epb/src/main/java/org/enso/interpreter/epb/node/ContextRewrapNode.java b/engine/runtime-language-epb/src/main/java/org/enso/interpreter/epb/node/ContextRewrapNode.java index 96605a2856f4..d93dc8e26f59 100644 --- a/engine/runtime-language-epb/src/main/java/org/enso/interpreter/epb/node/ContextRewrapNode.java +++ b/engine/runtime-language-epb/src/main/java/org/enso/interpreter/epb/node/ContextRewrapNode.java @@ -1,5 +1,6 @@ package org.enso.interpreter.epb.node; +import com.oracle.truffle.api.dsl.Cached.Exclusive; import com.oracle.truffle.api.dsl.Cached.Shared; import com.oracle.truffle.api.dsl.Fallback; import com.oracle.truffle.api.dsl.GenerateUncached; @@ -80,7 +81,7 @@ boolean doWrappedBoolean( Object b, GuardedTruffleContext origin, GuardedTruffleContext target, - @Shared("interop") @CachedLibrary(limit = "5") InteropLibrary bools) { + @Exclusive @CachedLibrary(limit = "5") InteropLibrary bools) { try { return bools.asBoolean(b); } catch (UnsupportedMessageException e) { From 1cd76f9bf4c1044f17e77e704a5380c8ec9d11cd Mon Sep 17 00:00:00 2001 From: Pavel Marek Date: Tue, 11 Jul 2023 18:03:06 +0200 Subject: [PATCH 24/51] Remove `@NonIdempotent` annotation from specialization --- .../org/enso/interpreter/node/callable/InvokeMethodNode.java | 1 - 1 file changed, 1 deletion(-) diff --git a/engine/runtime/src/main/java/org/enso/interpreter/node/callable/InvokeMethodNode.java b/engine/runtime/src/main/java/org/enso/interpreter/node/callable/InvokeMethodNode.java index e22735fbef92..ddfc9c60d203 100644 --- a/engine/runtime/src/main/java/org/enso/interpreter/node/callable/InvokeMethodNode.java +++ b/engine/runtime/src/main/java/org/enso/interpreter/node/callable/InvokeMethodNode.java @@ -634,7 +634,6 @@ Object doConvertDateTime( } } - @NonIdempotent @Specialization( guards = { "!warnings.hasWarnings(self)", From 7118056bb79aeb0a7e25790f7304e5ce25b34ab2 Mon Sep 17 00:00:00 2001 From: Pavel Marek Date: Tue, 11 Jul 2023 18:05:53 +0200 Subject: [PATCH 25/51] Rename shared cached parameter names --- .../node/callable/InvokeMethodNode.java | 54 +++++++++---------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/engine/runtime/src/main/java/org/enso/interpreter/node/callable/InvokeMethodNode.java b/engine/runtime/src/main/java/org/enso/interpreter/node/callable/InvokeMethodNode.java index ddfc9c60d203..dddfe4e98116 100644 --- a/engine/runtime/src/main/java/org/enso/interpreter/node/callable/InvokeMethodNode.java +++ b/engine/runtime/src/main/java/org/enso/interpreter/node/callable/InvokeMethodNode.java @@ -143,7 +143,7 @@ Object doFunctionalDispatchCachedSymbol( UnresolvedSymbol symbol, Object self, Object[] arguments, - @Shared("typesLib") @CachedLibrary(limit = "10") TypesLibrary typesLibrary, + @Shared("types") @CachedLibrary(limit = "10") TypesLibrary typesLibrary, @Shared("methodResolverNode") @Cached MethodResolverNode methodResolverNode, @Cached("symbol") UnresolvedSymbol cachedSymbol, @Cached("typesLibrary.getType(self)") Type cachedSelfTpe, @@ -198,7 +198,7 @@ Object doFunctionalDispatchUncachedSymbol( UnresolvedSymbol symbol, Object self, Object[] arguments, - @Shared("typesLib") @CachedLibrary(limit = "10") TypesLibrary typesLibrary, + @Shared("types") @CachedLibrary(limit = "10") TypesLibrary typesLibrary, @Shared("methodResolverNode") @Cached MethodResolverNode methodResolverNode) { Type selfTpe = typesLibrary.getType(self); Function function = resolveFunction(symbol, selfTpe, methodResolverNode); @@ -368,8 +368,8 @@ Object doWarningsCustom( UnresolvedSymbol symbol, Object self, Object[] arguments, - @Shared("typesLib") @CachedLibrary(limit = "10") TypesLibrary types, - @Shared("warnsLib") @CachedLibrary(limit = "10") WarningsLibrary warnings, + @Shared("types") @CachedLibrary(limit = "10") TypesLibrary types, + @Shared("warnings") @CachedLibrary(limit = "10") WarningsLibrary warnings, @Cached("resolveWarningFunction(self, symbol, types, warnings)") Function resolvedFunction, @Cached("resolvedFunction.getSchema()") FunctionSchema cachedSchema, @Cached("buildInvokeFunctionWithSelf()") InvokeFunctionNode warningFunctionNode) { @@ -390,7 +390,7 @@ Object doWarning( UnresolvedSymbol symbol, Object self, Object[] arguments, - @Shared("warnsLib") @CachedLibrary(limit = "10") WarningsLibrary warnings) { + @Shared("warnings") @CachedLibrary(limit = "10") WarningsLibrary warnings) { Object selfWithoutWarnings; Warning[] arrOfWarnings; try { @@ -449,9 +449,9 @@ Object doPolyglot( UnresolvedSymbol symbol, Object self, Object[] arguments, - @Shared("typesLib") @CachedLibrary(limit = "10") TypesLibrary methods, + @Shared("types") @CachedLibrary(limit = "10") TypesLibrary methods, @Shared("interop") @CachedLibrary(limit = "10") InteropLibrary interop, - @Shared("warnsLib") @CachedLibrary(limit = "10") WarningsLibrary warnings, + @Shared("warnings") @CachedLibrary(limit = "10") WarningsLibrary warnings, @Shared("methodResolverNode") @Cached MethodResolverNode preResolveMethod, @Bind("getPolyglotCallType(self, symbol, interop, preResolveMethod)") HostMethodCallNode.PolyglotCallType polyglotCallType, @@ -504,8 +504,8 @@ Object doConvertText( Object self, Object[] arguments, @Shared("interop") @CachedLibrary(limit = "10") InteropLibrary interop, - @Shared("typesLib") @CachedLibrary(limit = "10") TypesLibrary types, - @Shared("warnsLib") @CachedLibrary(limit = "10") WarningsLibrary warnings, + @Shared("types") @CachedLibrary(limit = "10") TypesLibrary types, + @Shared("warnings") @CachedLibrary(limit = "10") WarningsLibrary warnings, @Shared("methodResolverNode") @Cached MethodResolverNode methodResolverNode) { try { var str = interop.asString(self); @@ -535,8 +535,8 @@ Object doConvertArray( Object self, Object[] arguments, @Shared("interop") @CachedLibrary(limit = "10") InteropLibrary interop, - @Shared("typesLib") @CachedLibrary(limit = "10") TypesLibrary types, - @Shared("warnsLib") @CachedLibrary(limit = "10") WarningsLibrary warnings, + @Shared("types") @CachedLibrary(limit = "10") TypesLibrary types, + @Shared("warnings") @CachedLibrary(limit = "10") WarningsLibrary warnings, @Shared("methodResolverNode") @Cached MethodResolverNode methodResolverNode) { var ctx = EnsoContext.get(this); var arrayType = ctx.getBuiltins().array(); @@ -560,8 +560,8 @@ Object doConvertHashMap( Object self, Object[] arguments, @Shared("interop") @CachedLibrary(limit = "10") InteropLibrary interop, - @Shared("typesLib") @CachedLibrary(limit = "10") TypesLibrary types, - @Shared("warnsLib") @CachedLibrary(limit = "10") WarningsLibrary warnings, + @Shared("types") @CachedLibrary(limit = "10") TypesLibrary types, + @Shared("warnings") @CachedLibrary(limit = "10") WarningsLibrary warnings, @Shared("methodResolverNode") @Cached MethodResolverNode methodResolverNode) { var ctx = EnsoContext.get(this); var hashMapType = ctx.getBuiltins().map(); @@ -584,9 +584,9 @@ Object doConvertDate( UnresolvedSymbol symbol, Object self, Object[] arguments, - @Shared("typesLib") @CachedLibrary(limit = "10") TypesLibrary types, + @Shared("types") @CachedLibrary(limit = "10") TypesLibrary types, @Shared("interop") @CachedLibrary(limit = "10") InteropLibrary interop, - @Shared("warnsLib") @CachedLibrary(limit = "10") WarningsLibrary warnings, + @Shared("warnings") @CachedLibrary(limit = "10") WarningsLibrary warnings, @Shared("methodResolverNode") @Cached MethodResolverNode methodResolverNode) { var ctx = EnsoContext.get(this); try { @@ -615,9 +615,9 @@ Object doConvertDateTime( UnresolvedSymbol symbol, Object self, Object[] arguments, - @Shared("typesLib") @CachedLibrary(limit = "10") TypesLibrary types, + @Shared("types") @CachedLibrary(limit = "10") TypesLibrary types, @Shared("interop") @CachedLibrary(limit = "10") InteropLibrary interop, - @Shared("warnsLib") @CachedLibrary(limit = "10") WarningsLibrary warnings, + @Shared("warnings") @CachedLibrary(limit = "10") WarningsLibrary warnings, @Shared("methodResolverNode") @Cached MethodResolverNode methodResolverNode) { var ctx = EnsoContext.get(this); try { @@ -647,9 +647,9 @@ Object doConvertDuration( UnresolvedSymbol symbol, Object self, Object[] arguments, - @Shared("typesLib") @CachedLibrary(limit = "10") TypesLibrary types, + @Shared("types") @CachedLibrary(limit = "10") TypesLibrary types, @Shared("interop") @CachedLibrary(limit = "10") InteropLibrary interop, - @Shared("warnsLib") @CachedLibrary(limit = "10") WarningsLibrary warnings, + @Shared("warnings") @CachedLibrary(limit = "10") WarningsLibrary warnings, @Shared("methodResolverNode") @Cached MethodResolverNode methodResolverNode) { var ctx = EnsoContext.get(this); try { @@ -688,9 +688,9 @@ Object doConvertZonedDateTime( UnresolvedSymbol symbol, Object self, Object[] arguments, - @Shared("typesLib") @CachedLibrary(limit = "10") TypesLibrary types, + @Shared("types") @CachedLibrary(limit = "10") TypesLibrary types, @Shared("interop") @CachedLibrary(limit = "10") InteropLibrary interop, - @Shared("warnsLib") @CachedLibrary(limit = "10") WarningsLibrary warnings, + @Shared("warnings") @CachedLibrary(limit = "10") WarningsLibrary warnings, @Shared("methodResolverNode") @Cached MethodResolverNode methodResolverNode) { var ctx = EnsoContext.get(this); try { @@ -721,9 +721,9 @@ Object doConvertZone( UnresolvedSymbol symbol, Object self, Object[] arguments, - @Shared("typesLib") @CachedLibrary(limit = "10") TypesLibrary types, + @Shared("types") @CachedLibrary(limit = "10") TypesLibrary types, @Shared("interop") @CachedLibrary(limit = "10") InteropLibrary interop, - @Shared("warnsLib") @CachedLibrary(limit = "10") WarningsLibrary warnings, + @Shared("warnings") @CachedLibrary(limit = "10") WarningsLibrary warnings, @Shared("methodResolverNode") @Cached MethodResolverNode methodResolverNode) { var ctx = EnsoContext.get(this); try { @@ -752,9 +752,9 @@ Object doConvertTimeOfDay( UnresolvedSymbol symbol, Object self, Object[] arguments, - @Shared("typesLib") @CachedLibrary(limit = "10") TypesLibrary types, + @Shared("types") @CachedLibrary(limit = "10") TypesLibrary types, @Shared("interop") @CachedLibrary(limit = "10") InteropLibrary interop, - @Shared("warnsLib") @CachedLibrary(limit = "10") WarningsLibrary warnings, + @Shared("warnings") @CachedLibrary(limit = "10") WarningsLibrary warnings, @Shared("methodResolverNode") @Cached MethodResolverNode methodResolverNode) { var ctx = EnsoContext.get(this); try { @@ -783,9 +783,9 @@ Object doFallback( UnresolvedSymbol symbol, Object self, Object[] arguments, - @Shared("typesLib") @CachedLibrary(limit = "10") TypesLibrary methods, + @Shared("types") @CachedLibrary(limit = "10") TypesLibrary methods, @Shared("interop") @CachedLibrary(limit = "10") InteropLibrary interop, - @Shared("warnsLib") @CachedLibrary(limit = "10") WarningsLibrary warnings, + @Shared("warnings") @CachedLibrary(limit = "10") WarningsLibrary warnings, @Shared("methodResolverNode") @Cached MethodResolverNode resolverNode) { var ctx = EnsoContext.get(this); Function function = resolverNode.expectNonNull(self, ctx.getBuiltins().function(), symbol); From 4888b7ad89cc598531b7a63dbfd863eb462f7f97 Mon Sep 17 00:00:00 2001 From: Pavel Marek Date: Thu, 13 Jul 2023 09:21:03 +0200 Subject: [PATCH 26/51] Remove project/EnvironmentCheck It is no longer needed - Java and GraalVM have the same version nowadays. --- build.sbt | 4 -- project/EnvironmentCheck.scala | 88 ---------------------------------- 2 files changed, 92 deletions(-) delete mode 100644 project/EnvironmentCheck.scala diff --git a/build.sbt b/build.sbt index 78be0b94c466..1a7ab5cee8f5 100644 --- a/build.sbt +++ b/build.sbt @@ -1317,10 +1317,6 @@ lazy val runtime = (project in file("engine/runtime")) "ENSO_TEST_DISABLE_IR_CACHE" -> "false" ), bootstrap := CopyTruffleJAR.bootstrapJARs.value, - Global / onLoad := EnvironmentCheck.addVersionCheck( - graalMavenVersion, - javaLangVersion - )((Global / onLoad).value) ) .settings( (Compile / javacOptions) ++= Seq( diff --git a/project/EnvironmentCheck.scala b/project/EnvironmentCheck.scala deleted file mode 100644 index 43cd7b2aa669..000000000000 --- a/project/EnvironmentCheck.scala +++ /dev/null @@ -1,88 +0,0 @@ -import java.io.IOException - -import sbt._ -import sbt.internal.util.ManagedLogger - -import scala.sys.process._ - -object EnvironmentCheck { - - /** Compares the version of JVM running sbt with the GraalVM versions defined - * in project configuration and reports errors if the versions do not match. - * - * @param expectedGraalVersion the GraalVM version that should be used for - * building this project - * @param expectedJavaVersion the Java version of the used GraalVM - * distribution - * @param log a logger used to report errors if the versions are mismatched - */ - def graalVersionOk( - expectedGraalVersion: String, - expectedJavaVersion: String, - log: ManagedLogger - ): Boolean = { - val javaSpecificationVersion = - System.getProperty("java.vm.specification.version") - val versionProperty = "java.vendor.version" - val rawGraalVersion = System.getProperty(versionProperty) - def graalVersion: Option[String] = { - val versionRegex = """GraalVM (CE|EE) ([\d.]+.*)""".r - rawGraalVersion match { - case versionRegex(_, version) => Some(version) - case _ => None - } - } - - val graalOk = if (rawGraalVersion == null) { - log.error( - s"Property $versionProperty is not defined. " + - s"Make sure your current JVM is set to " + - s"GraalVM $expectedGraalVersion Java $expectedJavaVersion." - ) - false - } else - graalVersion match { - case Some(version) if version == expectedGraalVersion => true - case _ => - log.error( - s"GraalVM version mismatch - you are running $rawGraalVersion " + - s"but GraalVM $expectedGraalVersion is expected." - ) - false - } - - val javaOk = - if (javaSpecificationVersion != expectedJavaVersion) { - log.error( - s"Java version mismatch - you are running " + - s"Java $javaSpecificationVersion " + - s"but Java $expectedJavaVersion is expected." - ) - false - } else true - - graalOk && javaOk - } - - /** Augments a state transition to do a Rust and GraalVM version check. - * - * @param graalVersion the GraalVM version that should be used for - * building this project - * @param javaVersion the Java version of the used GraalVM distribution - * @param oldTransition the state transition to be augmented - * @return an augmented state transition that does all the state changes of - * oldTransition but also runs the version checks - */ - def addVersionCheck( - graalVersion: String, - javaVersion: String - )( - oldTransition: State => State - ): State => State = - (state: State) => { - val newState = oldTransition(state) - val logger = newState.log - - newState - } -} From ea95a16eb61eb865b6cb7d21b3ca3548a4d542a9 Mon Sep 17 00:00:00 2001 From: Pavel Marek Date: Mon, 17 Jul 2023 10:35:52 +0200 Subject: [PATCH 27/51] Remove @CachedLibrary parameters from methods behind @TruffleBoundary --- .../interpreter/runtime/data/EnsoFile.java | 21 +++++++------------ 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/engine/runtime/src/main/java/org/enso/interpreter/runtime/data/EnsoFile.java b/engine/runtime/src/main/java/org/enso/interpreter/runtime/data/EnsoFile.java index b4270b5263f4..94dfaaa22a25 100644 --- a/engine/runtime/src/main/java/org/enso/interpreter/runtime/data/EnsoFile.java +++ b/engine/runtime/src/main/java/org/enso/interpreter/runtime/data/EnsoFile.java @@ -51,10 +51,8 @@ public EnsoFile(TruffleFile truffleFile) { @Builtin.ReturningGuestObject @Builtin.Specialize @CompilerDirectives.TruffleBoundary - public OutputStream outputStream(Object opts, - EnsoContext ctx, - @CachedLibrary(limit = "5") InteropLibrary interop) throws IOException { - OpenOption[] openOptions = convertInteropArray(opts, interop, ctx, OpenOption[]::new); + public OutputStream outputStream(Object opts, EnsoContext ctx) throws IOException { + OpenOption[] openOptions = convertInteropArray(opts, InteropLibrary.getUncached(), ctx, OpenOption[]::new); return this.truffleFile.newOutputStream(openOptions); } @@ -63,10 +61,8 @@ public OutputStream outputStream(Object opts, @Builtin.Specialize @Builtin.ReturningGuestObject @CompilerDirectives.TruffleBoundary - public InputStream inputStream(Object opts, - EnsoContext ctx, - @CachedLibrary(limit = "5") InteropLibrary interop) throws IOException { - OpenOption[] openOptions = convertInteropArray(opts, interop, ctx, OpenOption[]::new); + public InputStream inputStream(Object opts, EnsoContext ctx) throws IOException { + OpenOption[] openOptions = convertInteropArray(opts, InteropLibrary.getUncached(), ctx, OpenOption[]::new); return this.truffleFile.newInputStream(openOptions); } @@ -268,10 +264,8 @@ public void delete() throws IOException { @Builtin.WrapException(from = IOException.class) @Builtin.Specialize @CompilerDirectives.TruffleBoundary - public void copy(EnsoFile target, Object options, - @CachedLibrary(limit = "5") InteropLibrary interop, - EnsoContext ctx) throws IOException { - CopyOption[] copyOptions = convertInteropArray(options, interop, ctx, CopyOption[]::new); + public void copy(EnsoFile target, Object options, EnsoContext ctx) throws IOException { + CopyOption[] copyOptions = convertInteropArray(options, InteropLibrary.getUncached(), ctx, CopyOption[]::new); truffleFile.copy(target.truffleFile, copyOptions); } @@ -280,9 +274,8 @@ public void copy(EnsoFile target, Object options, @Builtin.Specialize @CompilerDirectives.TruffleBoundary public void move(EnsoFile target, Object options, - @CachedLibrary(limit = "5") InteropLibrary interop, EnsoContext ctx) throws IOException { - CopyOption[] copyOptions = convertInteropArray(options, interop, ctx, CopyOption[]::new); + CopyOption[] copyOptions = convertInteropArray(options, InteropLibrary.getUncached(), ctx, CopyOption[]::new); truffleFile.move(target.truffleFile, copyOptions); } From 07ce2bfa3cbe6af7709806de727634c7a5c84fa2 Mon Sep 17 00:00:00 2001 From: Pavel Marek Date: Mon, 17 Jul 2023 16:38:23 +0200 Subject: [PATCH 28/51] Fix GraalVM version handling in project-manager --- build.sbt | 76 +++++++++---------- .../components/GraalRuntime.scala | 2 +- .../GraalVMComponentConfiguration.scala | 3 + .../components/GraalVMVersion.scala | 16 +++- .../components/RuntimeVersionManager.scala | 11 +-- .../locking/Resources.scala | 2 +- .../graalvm/GraalCEReleaseProvider.scala | 26 +++++-- .../GraalVMComponentConfigurationSpec.scala | 22 ++++++ 8 files changed, 104 insertions(+), 54 deletions(-) diff --git a/build.sbt b/build.sbt index db23fd021cc9..bd52888bd6ec 100644 --- a/build.sbt +++ b/build.sbt @@ -24,8 +24,8 @@ val scalacVersion = "2.13.11" // Note that it is important to keep the build metadata (the part after +) in this version. val graalVersion = "17.0.7+7.1" // Version used for the Graal/Truffle related Maven packages -val graalMavenVersion = "23.0.0" -val javaLangVersion = graalVersion.split("\\.")(0) +val graalMavenPackagesVersion = "23.0.0" +val targetJavaVersion = graalVersion.split("\\.")(0) val defaultDevEnsoVersion = "0.0.0-dev" val ensoVersion = sys.env.getOrElse( "ENSO_VERSION", @@ -157,8 +157,8 @@ analyzeDependency := GatherLicenses.analyzeDependency.evaluated val packageBuilder = new DistributionPackage.Builder( ensoVersion = ensoVersion, - graalVersion = graalMavenVersion, - graalJavaVersion = javaLangVersion, + graalVersion = graalMavenPackagesVersion, + graalJavaVersion = graalVersion, artifactRoot = file("built-distribution") ) @@ -643,7 +643,7 @@ lazy val `akka-native` = project akkaActor ), // Note [Native Image Workaround for GraalVM 20.2] - libraryDependencies += "org.graalvm.nativeimage" % "svm" % graalMavenVersion % "provided" + libraryDependencies += "org.graalvm.nativeimage" % "svm" % graalMavenPackagesVersion % "provided" ) lazy val `profiling-utils` = project @@ -697,7 +697,7 @@ lazy val `logging-service` = project "junit" % "junit" % junitVersion % Test, "com.novocode" % "junit-interface" % junitIfVersion % Test exclude ("junit", "junit-dep"), "org.scalatest" %% "scalatest" % scalatestVersion % Test, - "org.graalvm.nativeimage" % "svm" % graalMavenVersion % "provided" + "org.graalvm.nativeimage" % "svm" % graalMavenPackagesVersion % "provided" ) ) .settings( @@ -716,7 +716,7 @@ lazy val `logging-truffle-connector` = project version := "0.1", libraryDependencies ++= Seq( "org.slf4j" % "slf4j-api" % slf4jVersion, - "org.graalvm.truffle" % "truffle-api" % graalMavenVersion % "provided" + "org.graalvm.truffle" % "truffle-api" % graalMavenPackagesVersion % "provided" ) ) .dependsOn(`logging-utils`) @@ -765,7 +765,7 @@ lazy val `version-output` = (project in file("lib/scala/version-output")) defaultDevEnsoVersion = defaultDevEnsoVersion, ensoVersion = ensoVersion, scalacVersion = scalacVersion, - graalVersion = graalMavenVersion, + graalVersion = graalVersion, currentEdition = currentEdition ) }.taskValue @@ -974,8 +974,8 @@ lazy val `interpreter-dsl-test` = ), commands += WithDebugCommand.withDebug, libraryDependencies ++= Seq( - "org.graalvm.truffle" % "truffle-api" % graalMavenVersion % "provided", - "org.graalvm.truffle" % "truffle-dsl-processor" % graalMavenVersion % "provided", + "org.graalvm.truffle" % "truffle-api" % graalMavenPackagesVersion % "provided", + "org.graalvm.truffle" % "truffle-dsl-processor" % graalMavenPackagesVersion % "provided", "junit" % "junit" % junitVersion % Test, "com.novocode" % "junit-interface" % junitIfVersion % Test exclude ("junit", "junit-dep") ) @@ -1028,8 +1028,8 @@ lazy val `polyglot-api` = project Seq(s"-Dtruffle.class.path.append=$runtimeClasspath") }, libraryDependencies ++= Seq( - "org.graalvm.sdk" % "polyglot-tck" % graalMavenVersion % "provided", - "org.graalvm.truffle" % "truffle-api" % graalMavenVersion % "provided", + "org.graalvm.sdk" % "polyglot-tck" % graalMavenPackagesVersion % "provided", + "org.graalvm.truffle" % "truffle-api" % graalMavenPackagesVersion % "provided", "com.google.flatbuffers" % "flatbuffers-java" % flatbuffersVersion, "org.scalatest" %% "scalatest" % scalatestVersion % Test, "org.scalacheck" %% "scalacheck" % scalacheckVersion % Test @@ -1060,7 +1060,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.sdk" % "polyglot-tck" % graalMavenVersion % "provided", + "org.graalvm.sdk" % "polyglot-tck" % graalMavenPackagesVersion % "provided", "org.eclipse.jgit" % "org.eclipse.jgit" % jgitVersion ), Test / testOptions += Tests @@ -1154,7 +1154,7 @@ lazy val frgaalJavaCompilerSetting = Seq( Compile / compile / compilers := FrgaalJavaCompiler.compilers( (Compile / dependencyClasspath).value, compilers.value, - javaLangVersion + targetJavaVersion ), // This dependency is needed only so that developers don't download Frgaal manually. // Sadly it cannot be placed under plugins either because meta dependencies are not easily @@ -1180,8 +1180,8 @@ lazy val instrumentationSettings = frgaalJavaCompilerSetting ++ Seq( "--enable-preview" ), libraryDependencies ++= Seq( - "org.graalvm.truffle" % "truffle-api" % graalMavenVersion % "provided", - "org.graalvm.truffle" % "truffle-dsl-processor" % graalMavenVersion % "provided" + "org.graalvm.truffle" % "truffle-api" % graalMavenPackagesVersion % "provided", + "org.graalvm.truffle" % "truffle-dsl-processor" % graalMavenPackagesVersion % "provided" ), (Compile / javacOptions) ++= Seq( "-s", @@ -1299,16 +1299,16 @@ lazy val runtime = (project in file("engine/runtime")) libraryDependencies ++= jmh ++ jaxb ++ circe ++ Seq( "org.apache.commons" % "commons-lang3" % commonsLangVersion, "org.apache.tika" % "tika-core" % tikaVersion, - "org.graalvm.sdk" % "graal-sdk" % graalMavenVersion % "provided", - "org.graalvm.sdk" % "polyglot-tck" % graalMavenVersion % "provided", - "org.graalvm.truffle" % "truffle-api" % graalMavenVersion % "provided", - "org.graalvm.truffle" % "truffle-dsl-processor" % graalMavenVersion % "provided", - "org.graalvm.truffle" % "truffle-tck" % graalMavenVersion % "provided", - "org.graalvm.truffle" % "truffle-tck-common" % graalMavenVersion % "provided", + "org.graalvm.sdk" % "graal-sdk" % graalMavenPackagesVersion % "provided", + "org.graalvm.sdk" % "polyglot-tck" % graalMavenPackagesVersion % "provided", + "org.graalvm.truffle" % "truffle-api" % graalMavenPackagesVersion % "provided", + "org.graalvm.truffle" % "truffle-dsl-processor" % graalMavenPackagesVersion % "provided", + "org.graalvm.truffle" % "truffle-tck" % graalMavenPackagesVersion % "provided", + "org.graalvm.truffle" % "truffle-tck-common" % graalMavenPackagesVersion % "provided", "org.scalacheck" %% "scalacheck" % scalacheckVersion % Test, "org.scalactic" %% "scalactic" % scalacticVersion % Test, "org.scalatest" %% "scalatest" % scalatestVersion % Test, - "org.graalvm.truffle" % "truffle-api" % graalMavenVersion % Benchmark, + "org.graalvm.truffle" % "truffle-api" % graalMavenPackagesVersion % Benchmark, "org.typelevel" %% "cats-core" % catsVersion, "junit" % "junit" % junitVersion % Test, "com.novocode" % "junit-interface" % junitIfVersion % Test exclude ("junit", "junit-dep"), @@ -1469,8 +1469,8 @@ lazy val `runtime-with-instruments` = ), libraryDependencies ++= Seq( "org.scalatest" %% "scalatest" % scalatestVersion % Test, - "org.graalvm.truffle" % "truffle-api" % graalMavenVersion % Test, - "org.graalvm.truffle" % "truffle-dsl-processor" % graalMavenVersion % Test + "org.graalvm.truffle" % "truffle-api" % graalMavenPackagesVersion % Test, + "org.graalvm.truffle" % "truffle-dsl-processor" % graalMavenPackagesVersion % Test ), // Note [Unmanaged Classpath] Test / unmanagedClasspath += (baseDirectory.value / ".." / ".." / "app" / "gui" / "view" / "graph-editor" / "src" / "builtin" / "visualization" / "native" / "inc"), @@ -1539,7 +1539,7 @@ lazy val `runtime-with-polyglot` = "ENSO_TEST_DISABLE_IR_CACHE" -> "false" ), libraryDependencies ++= Seq( - "org.graalvm.sdk" % "graal-sdk" % graalMavenVersion % "provided", + "org.graalvm.sdk" % "graal-sdk" % graalMavenPackagesVersion % "provided", "org.scalatest" %% "scalatest" % scalatestVersion % Test ) ) @@ -1601,8 +1601,8 @@ lazy val `engine-runner` = project commands += WithDebugCommand.withDebug, inConfig(Compile)(truffleRunOptionsSettings), libraryDependencies ++= Seq( - "org.graalvm.sdk" % "polyglot-tck" % graalMavenVersion % "provided", - "org.graalvm.truffle" % "truffle-api" % graalMavenVersion % "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, @@ -1946,7 +1946,7 @@ lazy val `std-base` = project Compile / packageBin / artifactPath := `base-polyglot-root` / "std-base.jar", libraryDependencies ++= Seq( - "org.graalvm.sdk" % "graal-sdk" % graalMavenVersion % "provided", + "org.graalvm.sdk" % "graal-sdk" % graalMavenPackagesVersion % "provided", "org.netbeans.api" % "org-openide-util-lookup" % netbeansApiVersion % "provided" ), Compile / packageBin := Def.task { @@ -1974,7 +1974,7 @@ lazy val `common-polyglot-core-utils` = project `base-polyglot-root` / "common-polyglot-core-utils.jar", libraryDependencies ++= Seq( "com.ibm.icu" % "icu4j" % icuVersion, - "org.graalvm.sdk" % "graal-sdk" % graalMavenVersion % "provided" + "org.graalvm.sdk" % "graal-sdk" % graalMavenPackagesVersion % "provided" ) ) @@ -1986,7 +1986,7 @@ lazy val `enso-test-java-helpers` = project Compile / packageBin / artifactPath := file("test/Tests/polyglot/java/helpers.jar"), libraryDependencies ++= Seq( - "org.graalvm.sdk" % "graal-sdk" % graalMavenVersion % "provided" + "org.graalvm.sdk" % "graal-sdk" % graalMavenPackagesVersion % "provided" ), Compile / packageBin := Def.task { val result = (Compile / packageBin).value @@ -2019,7 +2019,7 @@ lazy val `std-table` = project (Antlr4 / sourceManaged).value / "main" / "antlr4" }, libraryDependencies ++= Seq( - "org.graalvm.sdk" % "graal-sdk" % graalMavenVersion % "provided", + "org.graalvm.sdk" % "graal-sdk" % graalMavenPackagesVersion % "provided", "org.netbeans.api" % "org-openide-util-lookup" % netbeansApiVersion % "provided", "com.univocity" % "univocity-parsers" % univocityParsersVersion, "org.apache.poi" % "poi-ooxml" % poiOoxmlVersion, @@ -2048,7 +2048,7 @@ lazy val `std-image` = project Compile / packageBin / artifactPath := `image-polyglot-root` / "std-image.jar", libraryDependencies ++= Seq( - "org.graalvm.sdk" % "graal-sdk" % graalMavenVersion % "provided", + "org.graalvm.sdk" % "graal-sdk" % graalMavenPackagesVersion % "provided", "org.netbeans.api" % "org-openide-util-lookup" % netbeansApiVersion % "provided", "org.openpnp" % "opencv" % "4.7.0-0" ), @@ -2098,7 +2098,7 @@ lazy val `std-database` = project Compile / packageBin / artifactPath := `database-polyglot-root` / "std-database.jar", libraryDependencies ++= Seq( - "org.graalvm.sdk" % "graal-sdk" % graalMavenVersion % "provided", + "org.graalvm.sdk" % "graal-sdk" % graalMavenPackagesVersion % "provided", "org.netbeans.api" % "org-openide-util-lookup" % netbeansApiVersion % "provided", "org.xerial" % "sqlite-jdbc" % sqliteVersion, "org.postgresql" % "postgresql" % "42.4.0" @@ -2204,8 +2204,8 @@ buildEngineDistribution := { distributionRoot = root, cacheFactory = cacheFactory, log = log, - graalVersion = graalMavenVersion, - javaVersion = javaLangVersion, + graalVersion = graalMavenPackagesVersion, + javaVersion = graalVersion, ensoVersion = ensoVersion, editionName = currentEdition, sourceStdlibVersion = stdLibVersion, @@ -2228,8 +2228,8 @@ buildEngineDistributionNoIndex := { distributionRoot = root, cacheFactory = cacheFactory, log = log, - graalVersion = graalMavenVersion, - javaVersion = javaLangVersion, + graalVersion = graalMavenPackagesVersion, + javaVersion = graalVersion, ensoVersion = ensoVersion, editionName = currentEdition, sourceStdlibVersion = stdLibVersion, diff --git a/lib/scala/runtime-version-manager/src/main/scala/org/enso/runtimeversionmanager/components/GraalRuntime.scala b/lib/scala/runtime-version-manager/src/main/scala/org/enso/runtimeversionmanager/components/GraalRuntime.scala index 77ba54d4c82c..adb077a9409b 100644 --- a/lib/scala/runtime-version-manager/src/main/scala/org/enso/runtimeversionmanager/components/GraalRuntime.scala +++ b/lib/scala/runtime-version-manager/src/main/scala/org/enso/runtimeversionmanager/components/GraalRuntime.scala @@ -24,7 +24,7 @@ case class GraalRuntime(version: GraalVMVersion, path: Path) { /** @inheritdoc */ override def toString: String = - s"GraalVM ${version.graalVersion}-java${version.java}" + s"GraalVM ${version.graalVersion}-java${version.javaVersion}" /** The path to the JAVA_HOME directory associated with this runtime. */ diff --git a/lib/scala/runtime-version-manager/src/main/scala/org/enso/runtimeversionmanager/components/GraalVMComponentConfiguration.scala b/lib/scala/runtime-version-manager/src/main/scala/org/enso/runtimeversionmanager/components/GraalVMComponentConfiguration.scala index fd236d31161c..5f2c34b6656e 100644 --- a/lib/scala/runtime-version-manager/src/main/scala/org/enso/runtimeversionmanager/components/GraalVMComponentConfiguration.scala +++ b/lib/scala/runtime-version-manager/src/main/scala/org/enso/runtimeversionmanager/components/GraalVMComponentConfiguration.scala @@ -17,6 +17,9 @@ class GraalVMComponentConfiguration extends RuntimeComponentConfiguration { val optRComponent = if (os.hasRSupport) Seq(GraalVMComponent.R) else Seq() version.graalVersion match { + case GraalVersions.Major(v) if v >= 23 => + // Since 23.0.0, R is not bundled in the Graal release anymore. + Seq(GraalVMComponent.js) ++ optPythonComponent case GraalVersions.Major(v) if v >= 22 => Seq(GraalVMComponent.js) ++ optRComponent ++ optPythonComponent case GraalVersions.Major(v) diff --git a/lib/scala/runtime-version-manager/src/main/scala/org/enso/runtimeversionmanager/components/GraalVMVersion.scala b/lib/scala/runtime-version-manager/src/main/scala/org/enso/runtimeversionmanager/components/GraalVMVersion.scala index c0feda2f5463..7b9200b5a326 100644 --- a/lib/scala/runtime-version-manager/src/main/scala/org/enso/runtimeversionmanager/components/GraalVMVersion.scala +++ b/lib/scala/runtime-version-manager/src/main/scala/org/enso/runtimeversionmanager/components/GraalVMVersion.scala @@ -4,11 +4,21 @@ package org.enso.runtimeversionmanager.components * release. * * @param graalVersion version of the GraalVM - * @param java Java version of the GraalVM flavour that should be used + * @param javaVersion Java version of the GraalVM flavour that should be used */ -case class GraalVMVersion(graalVersion: String, java: String) { +case class GraalVMVersion(graalVersion: String, javaVersion: String) { /** @inheritdoc */ - override def toString: String = s"GraalVM $graalVersion Java $java" + override def toString: String = s"GraalVM $graalVersion Java $javaVersion" + + def graalMajorVersion: Int = graalVersion.split("\\.").head.toInt + + def javaMajorVersion: Int = { + if (javaVersion.contains(".")) { + javaVersion.split("\\.").head.toInt + } else { + javaVersion.toInt + } + } } diff --git a/lib/scala/runtime-version-manager/src/main/scala/org/enso/runtimeversionmanager/components/RuntimeVersionManager.scala b/lib/scala/runtime-version-manager/src/main/scala/org/enso/runtimeversionmanager/components/RuntimeVersionManager.scala index 5aaa2654eee6..b31431294446 100644 --- a/lib/scala/runtime-version-manager/src/main/scala/org/enso/runtimeversionmanager/components/RuntimeVersionManager.scala +++ b/lib/scala/runtime-version-manager/src/main/scala/org/enso/runtimeversionmanager/components/RuntimeVersionManager.scala @@ -602,8 +602,9 @@ class RuntimeVersionManager( /** Returns name of the directory containing the runtime of that version. */ - private def graalRuntimeNameForVersion(version: GraalVMVersion): String = - s"graalvm-ce-java${version.java}-${version.graalVersion}" + private def graalRuntimeNameForVersion(version: GraalVMVersion): String = { + s"graalvm-ce-java${version.javaVersion}-${version.graalVersion}" + } /** Loads the GraalVM runtime definition. */ @@ -654,7 +655,7 @@ class RuntimeVersionManager( private def parseGraalRuntimeVersionString( name: String ): Option[GraalVMVersion] = { - val regex = """graalvm-ce-java(\d+)-(.+)""".r + val regex = """graalvm-ce-java(.+)-(.+)""".r name match { case regex(javaVersionString, graalVersionString) => Some(GraalVMVersion(graalVersionString, javaVersionString)) @@ -734,7 +735,7 @@ class RuntimeVersionManager( val runtimeDirectoryName = graalDirectoryForVersion(runtimeVersion) val localTmpDirectory = temporaryDirectoryManager.temporarySubdirectory( - s"runtime-${runtimeVersion.graalVersion}-java${runtimeVersion.java}" + s"runtime-${runtimeVersion.graalVersion}-java${runtimeVersion.javaVersion}" ) val extractionTask = Archive.extractArchive( @@ -835,7 +836,7 @@ class RuntimeVersionManager( Path.of(version.toString()) private def graalDirectoryForVersion(version: GraalVMVersion): Path = - Path.of(s"graalvm-ce-java${version.java}-${version.graalVersion}") + Path.of(s"graalvm-ce-java${version.javaVersion}-${version.graalVersion}") /** Removes runtimes that are not used by any installed engines. * diff --git a/lib/scala/runtime-version-manager/src/main/scala/org/enso/runtimeversionmanager/locking/Resources.scala b/lib/scala/runtime-version-manager/src/main/scala/org/enso/runtimeversionmanager/locking/Resources.scala index f8e2ee977271..55f2ac77e6c8 100644 --- a/lib/scala/runtime-version-manager/src/main/scala/org/enso/runtimeversionmanager/locking/Resources.scala +++ b/lib/scala/runtime-version-manager/src/main/scala/org/enso/runtimeversionmanager/locking/Resources.scala @@ -43,7 +43,7 @@ object Resources { */ case class Runtime(version: GraalVMVersion) extends Resource { override def name: String = - s"runtime-${version.graalVersion}-${version.java}" + s"runtime-${version.graalVersion}-${version.javaVersion}" override def waitMessage: String = s"Another process is using $version, " + "the current process must wait until other processes complete." diff --git a/lib/scala/runtime-version-manager/src/main/scala/org/enso/runtimeversionmanager/releases/graalvm/GraalCEReleaseProvider.scala b/lib/scala/runtime-version-manager/src/main/scala/org/enso/runtimeversionmanager/releases/graalvm/GraalCEReleaseProvider.scala index 5dc403bc2175..51ace05482be 100644 --- a/lib/scala/runtime-version-manager/src/main/scala/org/enso/runtimeversionmanager/releases/graalvm/GraalCEReleaseProvider.scala +++ b/lib/scala/runtime-version-manager/src/main/scala/org/enso/runtimeversionmanager/releases/graalvm/GraalCEReleaseProvider.scala @@ -20,17 +20,22 @@ class GraalCEReleaseProvider(releaseProvider: SimpleReleaseProvider) extends GraalVMRuntimeReleaseProvider { /** @inheritdoc */ - override def packageFileName(version: GraalVMVersion): String = + override def packageFileName(version: GraalVMVersion): String = { GraalCEReleaseProvider.packageFileNameForCurrentOS(version) + } /** @inheritdoc */ override def downloadPackage( version: GraalVMVersion, destination: Path ): TaskProgress[Unit] = { - val tagName = s"vm-${version.graalVersion}" val packageName = packageFileName(version) - val release = releaseProvider.releaseForTag(tagName) + val tagName = if (version.graalMajorVersion < 23) { + s"vm-${version.graalVersion}" + } else { + s"jdk-${version.javaVersion}" + } + val release = releaseProvider.releaseForTag(tagName) release match { case Failure(exception) => TaskProgress.immediateFailure(exception) @@ -67,13 +72,22 @@ object GraalCEReleaseProvider { case OS.MacOS => "darwin" case OS.Windows => "windows" } - val arch = OS.architecture val extension = OS.operatingSystem match { case OS.Linux => ".tar.gz" case OS.MacOS => ".tar.gz" case OS.Windows => ".zip" } - s"graalvm-ce-" + - s"java${version.java}-$os-$arch-${version.graalVersion}$extension" + if (version.graalMajorVersion < 23) { + val arch = OS.architecture + "graalvm-ce-" + + s"java${version.javaVersion}-$os-$arch-${version.graalVersion}$extension" + } else { + val arch = OS.architecture match { + case "amd64" => "x64" + case arch => arch + } + "graalvm-community-jdk-" + + s"${version.javaVersion}_${os}-${arch}_bin$extension" + } } } diff --git a/lib/scala/runtime-version-manager/src/test/scala/org/enso/runtimeversionmanager/components/GraalVMComponentConfigurationSpec.scala b/lib/scala/runtime-version-manager/src/test/scala/org/enso/runtimeversionmanager/components/GraalVMComponentConfigurationSpec.scala index 8cac48c7dcbc..a64ce3f81bfb 100644 --- a/lib/scala/runtime-version-manager/src/test/scala/org/enso/runtimeversionmanager/components/GraalVMComponentConfigurationSpec.scala +++ b/lib/scala/runtime-version-manager/src/test/scala/org/enso/runtimeversionmanager/components/GraalVMComponentConfigurationSpec.scala @@ -59,6 +59,28 @@ class GraalVMComponentConfigurationSpec extends AnyWordSpec with Matchers { OS.Linux ) should contain theSameElementsAs Seq() + conf.getRequiredComponents( + GraalVMVersion("23.0.0", "17.0.7+7.1"), + OS.Linux + ) should contain theSameElementsAs Seq( + GraalVMComponent.js, + GraalVMComponent.python + ) + + conf.getRequiredComponents( + GraalVMVersion("23.0.0", "11"), + OS.Linux + ) should contain theSameElementsAs Seq( + GraalVMComponent.js, + GraalVMComponent.python + ) + + conf.getRequiredComponents( + GraalVMVersion("23.0.0", "17.0.7+7.1"), + OS.Windows + ) should contain theSameElementsAs Seq( + GraalVMComponent.js + ) } } } From b69bc0d240b9b169a5cd5df34543ca657cfffae3 Mon Sep 17 00:00:00 2001 From: Pavel Marek Date: Mon, 17 Jul 2023 16:39:26 +0200 Subject: [PATCH 29/51] fmt --- .../node/expression/builtin/mutable/CoerceArrayNode.java | 1 - .../interpreter/dsl/builtins/SpecializedMethodParameter.java | 3 ++- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/mutable/CoerceArrayNode.java b/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/mutable/CoerceArrayNode.java index 284e9d05f76d..658ebaf7fdf8 100644 --- a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/mutable/CoerceArrayNode.java +++ b/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/mutable/CoerceArrayNode.java @@ -1,7 +1,6 @@ package org.enso.interpreter.node.expression.builtin.mutable; import com.oracle.truffle.api.dsl.Cached; -import com.oracle.truffle.api.dsl.Cached.Shared; import com.oracle.truffle.api.dsl.Fallback; import com.oracle.truffle.api.dsl.NeverDefault; import com.oracle.truffle.api.dsl.Specialization; diff --git a/lib/scala/interpreter-dsl/src/main/java/org/enso/interpreter/dsl/builtins/SpecializedMethodParameter.java b/lib/scala/interpreter-dsl/src/main/java/org/enso/interpreter/dsl/builtins/SpecializedMethodParameter.java index 69fdbc745bd8..4070c9876f55 100644 --- a/lib/scala/interpreter-dsl/src/main/java/org/enso/interpreter/dsl/builtins/SpecializedMethodParameter.java +++ b/lib/scala/interpreter-dsl/src/main/java/org/enso/interpreter/dsl/builtins/SpecializedMethodParameter.java @@ -116,7 +116,8 @@ public Optional auxParamDef() { @Override public Stream declaredParameter() { - return Stream.of("@Cached.Exclusive @CachedLibrary(" + cachedExpr + ") " + param.tpe() + " " + param.name()); + return Stream.of( + "@Cached.Exclusive @CachedLibrary(" + cachedExpr + ") " + param.tpe() + " " + param.name()); } public static final String INTEROP_LIBRARY = "com.oracle.truffle.api.interop.InteropLibrary"; From 8e26c2ef69aa253f462cae0970831ac2a96fc1d2 Mon Sep 17 00:00:00 2001 From: Pavel Marek Date: Mon, 17 Jul 2023 16:51:30 +0200 Subject: [PATCH 30/51] java version is specified as SemVer --- build.sbt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/build.sbt b/build.sbt index bd52888bd6ec..ee8e666c6672 100644 --- a/build.sbt +++ b/build.sbt @@ -21,8 +21,7 @@ import java.io.File val scalacVersion = "2.13.11" // Since the release of GraalVM 23.0.0, the versioning is the same for Graal and OpenJDK. -// Note that it is important to keep the build metadata (the part after +) in this version. -val graalVersion = "17.0.7+7.1" +val graalVersion = "17.0.7" // Version used for the Graal/Truffle related Maven packages val graalMavenPackagesVersion = "23.0.0" val targetJavaVersion = graalVersion.split("\\.")(0) From 0fc2621e9bbba8d6d3f95b235e62866703ef8194 Mon Sep 17 00:00:00 2001 From: Pavel Marek Date: Mon, 17 Jul 2023 16:51:40 +0200 Subject: [PATCH 31/51] Add version requirements to GraalVMVersion --- .../components/GraalVMVersion.scala | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/lib/scala/runtime-version-manager/src/main/scala/org/enso/runtimeversionmanager/components/GraalVMVersion.scala b/lib/scala/runtime-version-manager/src/main/scala/org/enso/runtimeversionmanager/components/GraalVMVersion.scala index 7b9200b5a326..1aded78242f4 100644 --- a/lib/scala/runtime-version-manager/src/main/scala/org/enso/runtimeversionmanager/components/GraalVMVersion.scala +++ b/lib/scala/runtime-version-manager/src/main/scala/org/enso/runtimeversionmanager/components/GraalVMVersion.scala @@ -1,12 +1,19 @@ package org.enso.runtimeversionmanager.components +import nl.gn0s1s.bump.SemVer + /** Version information identifying the runtime that can be used with an engine * release. * - * @param graalVersion version of the GraalVM - * @param javaVersion Java version of the GraalVM flavour that should be used + * @param graalVersion version of the GraalVM. Can be specified as a semantic + * version. + * @param javaVersion Java version of the GraalVM flavour that should be used. + * Can be specified either as a single integer or as a + * semantic version */ case class GraalVMVersion(graalVersion: String, javaVersion: String) { + require(isCorrectVersionFormat(graalVersion)) + require(isCorrectVersionFormat(javaVersion)) /** @inheritdoc */ @@ -21,4 +28,15 @@ case class GraalVMVersion(graalVersion: String, javaVersion: String) { javaVersion.toInt } } + + private def isCorrectVersionFormat(version: String): Boolean = { + version.toIntOption match { + case Some(_) => true + case None => + SemVer(version) match { + case Some(_) => true + case None => false + } + } + } } From 3d4ccc60d22ce1152c712eca7463eee8285f5a86 Mon Sep 17 00:00:00 2001 From: Pavel Marek Date: Tue, 18 Jul 2023 13:55:15 +0200 Subject: [PATCH 32/51] Fix enso-build-cli GraalVM version handling --- build/ci_utils/src/cache/goodie/graalvm.rs | 27 ++++++++++++++-------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/build/ci_utils/src/cache/goodie/graalvm.rs b/build/ci_utils/src/cache/goodie/graalvm.rs index 861bd520deca..c30f20aec50b 100644 --- a/build/ci_utils/src/cache/goodie/graalvm.rs +++ b/build/ci_utils/src/cache/goodie/graalvm.rs @@ -11,7 +11,6 @@ use crate::programs::Java; const PACKAGE_PREFIX_URL: &str = "graalvm-community"; -const PACKAGE_PREFIX_UNZIPPED: &str = "graalvm-community-openjdk"; pub const CE_BUILDS_REPOSITORY: RepoRef = RepoRef { owner: "graalvm", name: "graalvm-ce-builds" }; @@ -62,10 +61,24 @@ impl Goodie for GraalVM { } fn activation_env_changes(&self, package_path: &Path) -> Result> { - let package_path = package_path.join(self.root_directory_name()); + let dir_entries = package_path + .read_dir() + .context("Failed to read GraalVM cache directory") + .unwrap() + .collect_vec(); + assert_eq!(dir_entries.len(), 1, "GraalVM cache directory should contain exactly one directory"); + let graalvm_dir = match dir_entries.get(0).unwrap() { + Ok(dir_entry) => dir_entry, + Err(err) => bail!("Failed to read GraalVM cache directory: {}", err), + }; + let dir_name_tmp = graalvm_dir.file_name(); + let dir_name = dir_name_tmp.as_str(); + assert!(dir_name.contains("graalvm")); + let graal_version_str = format!("{}.{}.{}", self.graal_version.major, self.graal_version.minor, self.graal_version.patch); + assert!(dir_name.contains(&graal_version_str)); let root = match TARGET_OS { - OS::MacOS => package_path.join_iter(["Contents", "Home"]), - _ => package_path, + OS::MacOS => graalvm_dir.path().join_iter(["Contents", "Home"]), + _ => graalvm_dir.path(), }; Ok(vec![ crate::env::Modification::set(&JAVA_HOME, &root)?, @@ -107,12 +120,6 @@ impl GraalVM { let java_version = format!("jdk-{}.{}.{}", _graal_version.major, _graal_version.minor, _graal_version.patch); format!("{PACKAGE_PREFIX_URL}-{java_version}_{os_name}-{arch_name}") } - - pub fn root_directory_name(&self) -> PathBuf { - assert!(!self.graal_version.build.is_empty()); - let jdk_version = format!("{}.{}.{}+{}", self.graal_version.major, self.graal_version.minor, self.graal_version.patch, self.graal_version.build); - PathBuf::from(format!("{}-{}", PACKAGE_PREFIX_UNZIPPED, jdk_version)) - } } /// Locate the directory with GraalVM installation. From 955868e6c5cb1e401b87c376fd38d6dab2f8bfa2 Mon Sep 17 00:00:00 2001 From: Pavel Marek Date: Tue, 18 Jul 2023 17:08:53 +0200 Subject: [PATCH 33/51] Loose requirements for GraalVMVersion --- .../RuntimeVersionManagerSpec.scala | 20 +++++++++---------- .../components/GraalVMVersion.scala | 3 ++- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/lib/scala/runtime-version-manager-test/src/test/scala/org/enso/runtimeversionmanager/components/RuntimeVersionManagerSpec.scala b/lib/scala/runtime-version-manager-test/src/test/scala/org/enso/runtimeversionmanager/components/RuntimeVersionManagerSpec.scala index 3852aa6370e8..9bce7e53b2b8 100644 --- a/lib/scala/runtime-version-manager-test/src/test/scala/org/enso/runtimeversionmanager/components/RuntimeVersionManagerSpec.scala +++ b/lib/scala/runtime-version-manager-test/src/test/scala/org/enso/runtimeversionmanager/components/RuntimeVersionManagerSpec.scala @@ -56,7 +56,7 @@ class RuntimeVersionManagerSpec Set(SemVer(0, 0, 0), SemVer(0, 0, 1), SemVer(0, 0, 1, Some("pre"))) val runtimeVersions = Set( - components.GraalVMVersion("1.foo", "11"), + components.GraalVMVersion("1.0.0", "11"), components.GraalVMVersion("2.0.0", "11") ) engineVersions.map(componentsManager.findOrInstallEngine) @@ -159,7 +159,7 @@ class RuntimeVersionManagerSpec val runtimes2 = componentsManager.listInstalledGraalRuntimes() runtimes2 should have length 1 runtimes2.map(_.version).head shouldEqual components.GraalVMVersion( - "1.foo", + "1.0.0", "11" ) @@ -204,7 +204,7 @@ class RuntimeVersionManagerSpec "support bundled components" in { val engineVersion = SemVer(0, 1, 0) - val runtimeVersion = GraalVMVersion("1.foo", "11") + val runtimeVersion = GraalVMVersion("1.0.0", "11") prepareBundle( engines = Seq(engineVersion), runtimes = Seq(runtimeVersion) @@ -222,7 +222,7 @@ class RuntimeVersionManagerSpec "fail to uninstall a read-only bundled component" taggedAs OsUnix in { val engineVersion = SemVer(0, 1, 0) - val runtimeVersion = GraalVMVersion("1.foo", "11") + val runtimeVersion = GraalVMVersion("1.0.0", "11") prepareBundle( engines = Seq(engineVersion), runtimes = Seq(runtimeVersion) @@ -234,7 +234,7 @@ class RuntimeVersionManagerSpec val enginePath = getTestDirectory / "dist" / "0.1.0" val runtimePath = - getTestDirectory / "runtime" / "graalvm-ce-java11-1.foo" + getTestDirectory / "runtime" / "graalvm-ce-java11-1.0.0" enginePath.toFile.setWritable(false) try { @@ -268,7 +268,7 @@ class RuntimeVersionManagerSpec "include both bundled and installed components in list" in { prepareBundle( engines = Seq(SemVer(0, 0, 1)), - runtimes = Seq(GraalVMVersion("1.foo", "11")) + runtimes = Seq(GraalVMVersion("1.0.0", "11")) ) val manager = makeRuntimeVersionManager() manager.findOrInstallEngine(SemVer(0, 1, 0)) @@ -282,10 +282,10 @@ class RuntimeVersionManagerSpec val runtimeVersions = manager.listInstalledGraalRuntimes().map(_.version) runtimeVersions.map(_.graalVersion) should contain theSameElementsAs Seq( - "1.foo", + "1.0.0", "2.0.0" ) - runtimeVersions.map(_.java).toSet shouldEqual Set("11") + runtimeVersions.map(_.javaVersion).toSet shouldEqual Set("11") } } @@ -308,7 +308,7 @@ class RuntimeVersionManagerSpec private def fakeInstallEngine(searchPath: Path, version: SemVer): Unit = { val manifest = """minimum-launcher-version: 0.0.0-dev |minimum-project-manager-version: 0.0.0-dev - |graal-vm-version: 1.foo + |graal-vm-version: 1.0.0 |graal-java-version: 11""".stripMargin val root = searchPath / version.toString Files.createDirectories(root) @@ -324,7 +324,7 @@ class RuntimeVersionManagerSpec version: GraalVMVersion ): Unit = { val root = - searchPath / s"graalvm-ce-java${version.java}-${version.graalVersion}" + searchPath / s"graalvm-ce-java${version.javaVersion}-${version.graalVersion}" val bin = if (OS.operatingSystem == OS.MacOS) root / "Contents" / "Home" / "bin" else root / "bin" diff --git a/lib/scala/runtime-version-manager/src/main/scala/org/enso/runtimeversionmanager/components/GraalVMVersion.scala b/lib/scala/runtime-version-manager/src/main/scala/org/enso/runtimeversionmanager/components/GraalVMVersion.scala index 1aded78242f4..9e0d30166c1d 100644 --- a/lib/scala/runtime-version-manager/src/main/scala/org/enso/runtimeversionmanager/components/GraalVMVersion.scala +++ b/lib/scala/runtime-version-manager/src/main/scala/org/enso/runtimeversionmanager/components/GraalVMVersion.scala @@ -35,7 +35,8 @@ case class GraalVMVersion(graalVersion: String, javaVersion: String) { case None => SemVer(version) match { case Some(_) => true - case None => false + case None => + version.matches("^(\\d+\\.){3}\\d+$") } } } From f56f742c0ac0b90d0c95c4ce7bb860e161052af1 Mon Sep 17 00:00:00 2001 From: Pavel Marek Date: Tue, 18 Jul 2023 18:00:15 +0200 Subject: [PATCH 34/51] Do not use invalid GraalVM version in tests --- .../test/fake-releases/enso/enso-0.0.0/manifest.yaml | 2 +- .../graalvm-ce-java11-1.0.0}/Contents/Home/bin/java | 0 .../graalvm-ce-java11-1.0.0}/bin/java | 0 .../graalvm-ce-java11-1.foo/bin/java.exe | 1 - .../runtimeversionmanager/components/GraalVMVersion.scala | 8 +++++--- .../enso/runtimeversionmanager/components/Manifest.scala | 2 ++ 6 files changed, 8 insertions(+), 5 deletions(-) rename lib/scala/runtime-version-manager-test/src/main/resources/org/enso/runtimeversionmanager/test/fake-releases/graalvm/{vm-1.foo/graalvm-ce-java11-darwin-amd64-1.foo.tar.gz/graalvm-ce-java11-1.foo => vm-1.0.0/graalvm-ce-java11-darwin-amd64-1.0.0.tar.gz/graalvm-ce-java11-1.0.0}/Contents/Home/bin/java (100%) rename lib/scala/runtime-version-manager-test/src/main/resources/org/enso/runtimeversionmanager/test/fake-releases/graalvm/{vm-1.foo/graalvm-ce-java11-linux-amd64-1.foo.tar.gz/graalvm-ce-java11-1.foo => vm-1.0.0/graalvm-ce-java11-linux-amd64-1.0.0.tar.gz/graalvm-ce-java11-1.0.0}/bin/java (100%) delete mode 100755 lib/scala/runtime-version-manager-test/src/main/resources/org/enso/runtimeversionmanager/test/fake-releases/graalvm/vm-1.foo/graalvm-ce-java11-windows-amd64-1.foo.zip/graalvm-ce-java11-1.foo/bin/java.exe diff --git a/lib/scala/runtime-version-manager-test/src/main/resources/org/enso/runtimeversionmanager/test/fake-releases/enso/enso-0.0.0/manifest.yaml b/lib/scala/runtime-version-manager-test/src/main/resources/org/enso/runtimeversionmanager/test/fake-releases/enso/enso-0.0.0/manifest.yaml index a4729e979e27..7f418964da66 100644 --- a/lib/scala/runtime-version-manager-test/src/main/resources/org/enso/runtimeversionmanager/test/fake-releases/enso/enso-0.0.0/manifest.yaml +++ b/lib/scala/runtime-version-manager-test/src/main/resources/org/enso/runtimeversionmanager/test/fake-releases/enso/enso-0.0.0/manifest.yaml @@ -1,6 +1,6 @@ minimum-launcher-version: 0.0.0-dev minimum-project-manager-version: 0.0.0-dev -graal-vm-version: 1.foo +graal-vm-version: 1.0.0 graal-java-version: 11 jvm-options: - value: "-Dtruffle.class.path.append=$enginePackagePath\\component\\runtime.jar" diff --git a/lib/scala/runtime-version-manager-test/src/main/resources/org/enso/runtimeversionmanager/test/fake-releases/graalvm/vm-1.foo/graalvm-ce-java11-darwin-amd64-1.foo.tar.gz/graalvm-ce-java11-1.foo/Contents/Home/bin/java b/lib/scala/runtime-version-manager-test/src/main/resources/org/enso/runtimeversionmanager/test/fake-releases/graalvm/vm-1.0.0/graalvm-ce-java11-darwin-amd64-1.0.0.tar.gz/graalvm-ce-java11-1.0.0/Contents/Home/bin/java similarity index 100% rename from lib/scala/runtime-version-manager-test/src/main/resources/org/enso/runtimeversionmanager/test/fake-releases/graalvm/vm-1.foo/graalvm-ce-java11-darwin-amd64-1.foo.tar.gz/graalvm-ce-java11-1.foo/Contents/Home/bin/java rename to lib/scala/runtime-version-manager-test/src/main/resources/org/enso/runtimeversionmanager/test/fake-releases/graalvm/vm-1.0.0/graalvm-ce-java11-darwin-amd64-1.0.0.tar.gz/graalvm-ce-java11-1.0.0/Contents/Home/bin/java diff --git a/lib/scala/runtime-version-manager-test/src/main/resources/org/enso/runtimeversionmanager/test/fake-releases/graalvm/vm-1.foo/graalvm-ce-java11-linux-amd64-1.foo.tar.gz/graalvm-ce-java11-1.foo/bin/java b/lib/scala/runtime-version-manager-test/src/main/resources/org/enso/runtimeversionmanager/test/fake-releases/graalvm/vm-1.0.0/graalvm-ce-java11-linux-amd64-1.0.0.tar.gz/graalvm-ce-java11-1.0.0/bin/java similarity index 100% rename from lib/scala/runtime-version-manager-test/src/main/resources/org/enso/runtimeversionmanager/test/fake-releases/graalvm/vm-1.foo/graalvm-ce-java11-linux-amd64-1.foo.tar.gz/graalvm-ce-java11-1.foo/bin/java rename to lib/scala/runtime-version-manager-test/src/main/resources/org/enso/runtimeversionmanager/test/fake-releases/graalvm/vm-1.0.0/graalvm-ce-java11-linux-amd64-1.0.0.tar.gz/graalvm-ce-java11-1.0.0/bin/java diff --git a/lib/scala/runtime-version-manager-test/src/main/resources/org/enso/runtimeversionmanager/test/fake-releases/graalvm/vm-1.foo/graalvm-ce-java11-windows-amd64-1.foo.zip/graalvm-ce-java11-1.foo/bin/java.exe b/lib/scala/runtime-version-manager-test/src/main/resources/org/enso/runtimeversionmanager/test/fake-releases/graalvm/vm-1.foo/graalvm-ce-java11-windows-amd64-1.foo.zip/graalvm-ce-java11-1.foo/bin/java.exe deleted file mode 100755 index 48cdce852872..000000000000 --- a/lib/scala/runtime-version-manager-test/src/main/resources/org/enso/runtimeversionmanager/test/fake-releases/graalvm/vm-1.foo/graalvm-ce-java11-windows-amd64-1.foo.zip/graalvm-ce-java11-1.foo/bin/java.exe +++ /dev/null @@ -1 +0,0 @@ -placeholder diff --git a/lib/scala/runtime-version-manager/src/main/scala/org/enso/runtimeversionmanager/components/GraalVMVersion.scala b/lib/scala/runtime-version-manager/src/main/scala/org/enso/runtimeversionmanager/components/GraalVMVersion.scala index 9e0d30166c1d..0712dd1eb43e 100644 --- a/lib/scala/runtime-version-manager/src/main/scala/org/enso/runtimeversionmanager/components/GraalVMVersion.scala +++ b/lib/scala/runtime-version-manager/src/main/scala/org/enso/runtimeversionmanager/components/GraalVMVersion.scala @@ -12,8 +12,8 @@ import nl.gn0s1s.bump.SemVer * semantic version */ case class GraalVMVersion(graalVersion: String, javaVersion: String) { - require(isCorrectVersionFormat(graalVersion)) - require(isCorrectVersionFormat(javaVersion)) + require(GraalVMVersion.isCorrectVersionFormat(graalVersion)) + require(GraalVMVersion.isCorrectVersionFormat(javaVersion)) /** @inheritdoc */ @@ -28,8 +28,10 @@ case class GraalVMVersion(graalVersion: String, javaVersion: String) { javaVersion.toInt } } +} - private def isCorrectVersionFormat(version: String): Boolean = { +object GraalVMVersion { + def isCorrectVersionFormat(version: String): Boolean = { version.toIntOption match { case Some(_) => true case None => diff --git a/lib/scala/runtime-version-manager/src/main/scala/org/enso/runtimeversionmanager/components/Manifest.scala b/lib/scala/runtime-version-manager/src/main/scala/org/enso/runtimeversionmanager/components/Manifest.scala index 478a9803a553..3d51b7cafe2e 100644 --- a/lib/scala/runtime-version-manager/src/main/scala/org/enso/runtimeversionmanager/components/Manifest.scala +++ b/lib/scala/runtime-version-manager/src/main/scala/org/enso/runtimeversionmanager/components/Manifest.scala @@ -41,6 +41,8 @@ case class Manifest( jvmOptions: Seq[JVMOption], brokenMark: Boolean ) { + require(GraalVMVersion.isCorrectVersionFormat(graalVMVersion)) + require(GraalVMVersion.isCorrectVersionFormat(graalJavaVersion)) /** Returns a [[GraalVMVersion]] which encapsulates all version information * needed to find the runtime required for this release. From cd1a3d2f906c37007bb70977f179cab25873ba51 Mon Sep 17 00:00:00 2001 From: Pavel Marek Date: Tue, 18 Jul 2023 19:56:55 +0200 Subject: [PATCH 35/51] fmt --- .../runtimeversionmanager/components/GraalVMVersion.scala | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/scala/runtime-version-manager/src/main/scala/org/enso/runtimeversionmanager/components/GraalVMVersion.scala b/lib/scala/runtime-version-manager/src/main/scala/org/enso/runtimeversionmanager/components/GraalVMVersion.scala index 0712dd1eb43e..368e8ca17b12 100644 --- a/lib/scala/runtime-version-manager/src/main/scala/org/enso/runtimeversionmanager/components/GraalVMVersion.scala +++ b/lib/scala/runtime-version-manager/src/main/scala/org/enso/runtimeversionmanager/components/GraalVMVersion.scala @@ -6,10 +6,10 @@ import nl.gn0s1s.bump.SemVer * release. * * @param graalVersion version of the GraalVM. Can be specified as a semantic - * version. + * version. * @param javaVersion Java version of the GraalVM flavour that should be used. - * Can be specified either as a single integer or as a - * semantic version + * Can be specified either as a single integer or as a + * semantic version */ case class GraalVMVersion(graalVersion: String, javaVersion: String) { require(GraalVMVersion.isCorrectVersionFormat(graalVersion)) From e9079fc80e27616b683a9c38d3eb890f0be94071 Mon Sep 17 00:00:00 2001 From: Jaroslav Tulach Date: Wed, 19 Jul 2023 07:29:56 +0200 Subject: [PATCH 36/51] Formatting build.sbt --- build.sbt | 96 +++++++++++++++++++++++++++---------------------------- 1 file changed, 48 insertions(+), 48 deletions(-) diff --git a/build.sbt b/build.sbt index ee8e666c6672..bd32c89be704 100644 --- a/build.sbt +++ b/build.sbt @@ -19,13 +19,13 @@ import java.io.File // === Global Configuration =================================================== // ============================================================================ -val scalacVersion = "2.13.11" +val scalacVersion = "2.13.11" // Since the release of GraalVM 23.0.0, the versioning is the same for Graal and OpenJDK. -val graalVersion = "17.0.7" +val graalVersion = "17.0.7" // Version used for the Graal/Truffle related Maven packages -val graalMavenPackagesVersion = "23.0.0" -val targetJavaVersion = graalVersion.split("\\.")(0) -val defaultDevEnsoVersion = "0.0.0-dev" +val graalMavenPackagesVersion = "23.0.0" +val targetJavaVersion = graalVersion.split("\\.")(0) +val defaultDevEnsoVersion = "0.0.0-dev" val ensoVersion = sys.env.getOrElse( "ENSO_VERSION", defaultDevEnsoVersion @@ -693,10 +693,10 @@ lazy val `logging-service` = project akkaHttp, "io.circe" %% "circe-core" % circeVersion, "io.circe" %% "circe-parser" % circeVersion, - "junit" % "junit" % junitVersion % Test, - "com.novocode" % "junit-interface" % junitIfVersion % Test exclude ("junit", "junit-dep"), - "org.scalatest" %% "scalatest" % scalatestVersion % Test, - "org.graalvm.nativeimage" % "svm" % graalMavenPackagesVersion % "provided" + "junit" % "junit" % junitVersion % Test, + "com.novocode" % "junit-interface" % junitIfVersion % Test exclude ("junit", "junit-dep"), + "org.scalatest" %% "scalatest" % scalatestVersion % Test, + "org.graalvm.nativeimage" % "svm" % graalMavenPackagesVersion % "provided" ) ) .settings( @@ -973,10 +973,10 @@ lazy val `interpreter-dsl-test` = ), commands += WithDebugCommand.withDebug, libraryDependencies ++= Seq( - "org.graalvm.truffle" % "truffle-api" % graalMavenPackagesVersion % "provided", - "org.graalvm.truffle" % "truffle-dsl-processor" % graalMavenPackagesVersion % "provided", - "junit" % "junit" % junitVersion % Test, - "com.novocode" % "junit-interface" % junitIfVersion % Test exclude ("junit", "junit-dep") + "org.graalvm.truffle" % "truffle-api" % graalMavenPackagesVersion % "provided", + "org.graalvm.truffle" % "truffle-dsl-processor" % graalMavenPackagesVersion % "provided", + "junit" % "junit" % junitVersion % Test, + "com.novocode" % "junit-interface" % junitIfVersion % Test exclude ("junit", "junit-dep") ) ) .dependsOn(`interpreter-dsl`) @@ -1027,11 +1027,11 @@ lazy val `polyglot-api` = project Seq(s"-Dtruffle.class.path.append=$runtimeClasspath") }, libraryDependencies ++= Seq( - "org.graalvm.sdk" % "polyglot-tck" % graalMavenPackagesVersion % "provided", - "org.graalvm.truffle" % "truffle-api" % graalMavenPackagesVersion % "provided", + "org.graalvm.sdk" % "polyglot-tck" % graalMavenPackagesVersion % "provided", + "org.graalvm.truffle" % "truffle-api" % graalMavenPackagesVersion % "provided", "com.google.flatbuffers" % "flatbuffers-java" % flatbuffersVersion, - "org.scalatest" %% "scalatest" % scalatestVersion % Test, - "org.scalacheck" %% "scalacheck" % scalacheckVersion % Test + "org.scalatest" %% "scalatest" % scalatestVersion % Test, + "org.scalacheck" %% "scalacheck" % scalacheckVersion % Test ), libraryDependencies ++= jackson, GenerateFlatbuffers.flatcVersion := flatbuffersVersion, @@ -1056,10 +1056,10 @@ lazy val `language-server` = (project in file("engine/language-server")) "com.google.flatbuffers" % "flatbuffers-java" % flatbuffersVersion, "commons-io" % "commons-io" % commonsIoVersion, akkaTestkit % Test, - "com.typesafe.akka" %% "akka-http-testkit" % akkaHTTPVersion % Test, - "org.scalatest" %% "scalatest" % scalatestVersion % Test, - "org.scalacheck" %% "scalacheck" % scalacheckVersion % Test, - "org.graalvm.sdk" % "polyglot-tck" % graalMavenPackagesVersion % "provided", + "com.typesafe.akka" %% "akka-http-testkit" % akkaHTTPVersion % Test, + "org.scalatest" %% "scalatest" % scalatestVersion % Test, + "org.scalacheck" %% "scalacheck" % scalacheckVersion % Test, + "org.graalvm.sdk" % "polyglot-tck" % graalMavenPackagesVersion % "provided", "org.eclipse.jgit" % "org.eclipse.jgit" % jgitVersion ), Test / testOptions += Tests @@ -1298,19 +1298,19 @@ lazy val runtime = (project in file("engine/runtime")) libraryDependencies ++= jmh ++ jaxb ++ circe ++ Seq( "org.apache.commons" % "commons-lang3" % commonsLangVersion, "org.apache.tika" % "tika-core" % tikaVersion, - "org.graalvm.sdk" % "graal-sdk" % graalMavenPackagesVersion % "provided", - "org.graalvm.sdk" % "polyglot-tck" % graalMavenPackagesVersion % "provided", - "org.graalvm.truffle" % "truffle-api" % graalMavenPackagesVersion % "provided", - "org.graalvm.truffle" % "truffle-dsl-processor" % graalMavenPackagesVersion % "provided", - "org.graalvm.truffle" % "truffle-tck" % graalMavenPackagesVersion % "provided", - "org.graalvm.truffle" % "truffle-tck-common" % graalMavenPackagesVersion % "provided", - "org.scalacheck" %% "scalacheck" % scalacheckVersion % Test, - "org.scalactic" %% "scalactic" % scalacticVersion % Test, - "org.scalatest" %% "scalatest" % scalatestVersion % Test, - "org.graalvm.truffle" % "truffle-api" % graalMavenPackagesVersion % Benchmark, + "org.graalvm.sdk" % "graal-sdk" % graalMavenPackagesVersion % "provided", + "org.graalvm.sdk" % "polyglot-tck" % graalMavenPackagesVersion % "provided", + "org.graalvm.truffle" % "truffle-api" % graalMavenPackagesVersion % "provided", + "org.graalvm.truffle" % "truffle-dsl-processor" % graalMavenPackagesVersion % "provided", + "org.graalvm.truffle" % "truffle-tck" % graalMavenPackagesVersion % "provided", + "org.graalvm.truffle" % "truffle-tck-common" % graalMavenPackagesVersion % "provided", + "org.scalacheck" %% "scalacheck" % scalacheckVersion % Test, + "org.scalactic" %% "scalactic" % scalacticVersion % Test, + "org.scalatest" %% "scalatest" % scalatestVersion % Test, + "org.graalvm.truffle" % "truffle-api" % graalMavenPackagesVersion % Benchmark, "org.typelevel" %% "cats-core" % catsVersion, - "junit" % "junit" % junitVersion % Test, - "com.novocode" % "junit-interface" % junitIfVersion % Test exclude ("junit", "junit-dep"), + "junit" % "junit" % junitVersion % Test, + "com.novocode" % "junit-interface" % junitIfVersion % Test exclude ("junit", "junit-dep"), "com.lihaoyi" %% "fansi" % fansiVersion ), Compile / compile / compileInputs := (Compile / compile / compileInputs) @@ -1325,7 +1325,7 @@ lazy val runtime = (project in file("engine/runtime")) Test / envVars ++= distributionEnvironmentOverrides ++ Map( "ENSO_TEST_DISABLE_IR_CACHE" -> "false" ), - bootstrap := CopyTruffleJAR.bootstrapJARs.value, + bootstrap := CopyTruffleJAR.bootstrapJARs.value ) .settings( (Compile / javacOptions) ++= Seq( @@ -1467,9 +1467,9 @@ lazy val `runtime-with-instruments` = "ENSO_TEST_DISABLE_IR_CACHE" -> "false" ), libraryDependencies ++= Seq( - "org.scalatest" %% "scalatest" % scalatestVersion % Test, - "org.graalvm.truffle" % "truffle-api" % graalMavenPackagesVersion % Test, - "org.graalvm.truffle" % "truffle-dsl-processor" % graalMavenPackagesVersion % Test + "org.scalatest" %% "scalatest" % scalatestVersion % Test, + "org.graalvm.truffle" % "truffle-api" % graalMavenPackagesVersion % Test, + "org.graalvm.truffle" % "truffle-dsl-processor" % graalMavenPackagesVersion % Test ), // Note [Unmanaged Classpath] Test / unmanagedClasspath += (baseDirectory.value / ".." / ".." / "app" / "gui" / "view" / "graph-editor" / "src" / "builtin" / "visualization" / "native" / "inc"), @@ -1538,8 +1538,8 @@ lazy val `runtime-with-polyglot` = "ENSO_TEST_DISABLE_IR_CACHE" -> "false" ), libraryDependencies ++= Seq( - "org.graalvm.sdk" % "graal-sdk" % graalMavenPackagesVersion % "provided", - "org.scalatest" %% "scalatest" % scalatestVersion % Test + "org.graalvm.sdk" % "graal-sdk" % graalMavenPackagesVersion % "provided", + "org.scalatest" %% "scalatest" % scalatestVersion % Test ) ) .dependsOn(runtime % "compile->compile;test->test;runtime->runtime") @@ -1625,7 +1625,7 @@ lazy val `engine-runner` = project // "-g", // "-H:+DashboardAll", // "-H:DashboardDump=runner.bgv" - "-Dnic=nic", + "-Dnic=nic" ), mainClass = Option("org.enso.runner.Main"), cp = Option("runtime.jar"), @@ -1945,8 +1945,8 @@ lazy val `std-base` = project Compile / packageBin / artifactPath := `base-polyglot-root` / "std-base.jar", libraryDependencies ++= Seq( - "org.graalvm.sdk" % "graal-sdk" % graalMavenPackagesVersion % "provided", - "org.netbeans.api" % "org-openide-util-lookup" % netbeansApiVersion % "provided" + "org.graalvm.sdk" % "graal-sdk" % graalMavenPackagesVersion % "provided", + "org.netbeans.api" % "org-openide-util-lookup" % netbeansApiVersion % "provided" ), Compile / packageBin := Def.task { val result = (Compile / packageBin).value @@ -2018,8 +2018,8 @@ lazy val `std-table` = project (Antlr4 / sourceManaged).value / "main" / "antlr4" }, libraryDependencies ++= Seq( - "org.graalvm.sdk" % "graal-sdk" % graalMavenPackagesVersion % "provided", - "org.netbeans.api" % "org-openide-util-lookup" % netbeansApiVersion % "provided", + "org.graalvm.sdk" % "graal-sdk" % graalMavenPackagesVersion % "provided", + "org.netbeans.api" % "org-openide-util-lookup" % netbeansApiVersion % "provided", "com.univocity" % "univocity-parsers" % univocityParsersVersion, "org.apache.poi" % "poi-ooxml" % poiOoxmlVersion, "org.apache.xmlbeans" % "xmlbeans" % xmlbeansVersion, @@ -2047,8 +2047,8 @@ lazy val `std-image` = project Compile / packageBin / artifactPath := `image-polyglot-root` / "std-image.jar", libraryDependencies ++= Seq( - "org.graalvm.sdk" % "graal-sdk" % graalMavenPackagesVersion % "provided", - "org.netbeans.api" % "org-openide-util-lookup" % netbeansApiVersion % "provided", + "org.graalvm.sdk" % "graal-sdk" % graalMavenPackagesVersion % "provided", + "org.netbeans.api" % "org-openide-util-lookup" % netbeansApiVersion % "provided", "org.openpnp" % "opencv" % "4.7.0-0" ), Compile / packageBin := Def.task { @@ -2097,8 +2097,8 @@ lazy val `std-database` = project Compile / packageBin / artifactPath := `database-polyglot-root` / "std-database.jar", libraryDependencies ++= Seq( - "org.graalvm.sdk" % "graal-sdk" % graalMavenPackagesVersion % "provided", - "org.netbeans.api" % "org-openide-util-lookup" % netbeansApiVersion % "provided", + "org.graalvm.sdk" % "graal-sdk" % graalMavenPackagesVersion % "provided", + "org.netbeans.api" % "org-openide-util-lookup" % netbeansApiVersion % "provided", "org.xerial" % "sqlite-jdbc" % sqliteVersion, "org.postgresql" % "postgresql" % "42.4.0" ), From 276f059a8dd4a22b282c6f5844b794a991358a2c Mon Sep 17 00:00:00 2001 From: Jaroslav Tulach Date: Wed, 19 Jul 2023 07:30:12 +0200 Subject: [PATCH 37/51] Formatting scala sources --- .../runtimeversionmanager/components/GraalVMVersion.scala | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/scala/runtime-version-manager/src/main/scala/org/enso/runtimeversionmanager/components/GraalVMVersion.scala b/lib/scala/runtime-version-manager/src/main/scala/org/enso/runtimeversionmanager/components/GraalVMVersion.scala index 9e0d30166c1d..aeae20e87b72 100644 --- a/lib/scala/runtime-version-manager/src/main/scala/org/enso/runtimeversionmanager/components/GraalVMVersion.scala +++ b/lib/scala/runtime-version-manager/src/main/scala/org/enso/runtimeversionmanager/components/GraalVMVersion.scala @@ -6,10 +6,10 @@ import nl.gn0s1s.bump.SemVer * release. * * @param graalVersion version of the GraalVM. Can be specified as a semantic - * version. + * version. * @param javaVersion Java version of the GraalVM flavour that should be used. - * Can be specified either as a single integer or as a - * semantic version + * Can be specified either as a single integer or as a + * semantic version */ case class GraalVMVersion(graalVersion: String, javaVersion: String) { require(isCorrectVersionFormat(graalVersion)) From 800aa1b797b99b9d20bb46abcb8fd8f36a6aee36 Mon Sep 17 00:00:00 2001 From: Jaroslav Tulach Date: Wed, 19 Jul 2023 07:30:19 +0200 Subject: [PATCH 38/51] cargo fmt --- build/ci_utils/src/cache/goodie/graalvm.rs | 48 +++++++++++++++------- 1 file changed, 33 insertions(+), 15 deletions(-) diff --git a/build/ci_utils/src/cache/goodie/graalvm.rs b/build/ci_utils/src/cache/goodie/graalvm.rs index c30f20aec50b..ed5a302e7ae9 100644 --- a/build/ci_utils/src/cache/goodie/graalvm.rs +++ b/build/ci_utils/src/cache/goodie/graalvm.rs @@ -66,15 +66,22 @@ impl Goodie for GraalVM { .context("Failed to read GraalVM cache directory") .unwrap() .collect_vec(); - assert_eq!(dir_entries.len(), 1, "GraalVM cache directory should contain exactly one directory"); - let graalvm_dir = match dir_entries.get(0).unwrap() { + assert_eq!( + dir_entries.len(), + 1, + "GraalVM cache directory should contain exactly one directory" + ); + let graalvm_dir = match dir_entries.get(0).unwrap() { Ok(dir_entry) => dir_entry, Err(err) => bail!("Failed to read GraalVM cache directory: {}", err), }; let dir_name_tmp = graalvm_dir.file_name(); let dir_name = dir_name_tmp.as_str(); assert!(dir_name.contains("graalvm")); - let graal_version_str = format!("{}.{}.{}", self.graal_version.major, self.graal_version.minor, self.graal_version.patch); + let graal_version_str = format!( + "{}.{}.{}", + self.graal_version.major, self.graal_version.minor, self.graal_version.patch + ); assert!(dir_name.contains(&graal_version_str)); let root = match TARGET_OS { OS::MacOS => graalvm_dir.path().join_iter(["Contents", "Home"]), @@ -92,7 +99,8 @@ impl GraalVM { pub fn url(&self) -> BoxFuture<'static, Result> { let platform_string = self.platform_string(); let graal_version = self.graal_version.clone(); - let graal_version_tag = format!("{}.{}.{}", graal_version.major, graal_version.minor, graal_version.patch); + let graal_version_tag = + format!("{}.{}.{}", graal_version.major, graal_version.minor, graal_version.patch); let client = self.client.clone(); async move { let repo = CE_BUILDS_REPOSITORY.handle(&client); @@ -117,7 +125,10 @@ impl GraalVM { Arch::AArch64 => "aarch64", other_arch => unimplemented!("Architecture `{}` is not supported!", other_arch), }; - let java_version = format!("jdk-{}.{}.{}", _graal_version.major, _graal_version.minor, _graal_version.patch); + let java_version = format!( + "jdk-{}.{}.{}", + _graal_version.major, _graal_version.minor, _graal_version.patch + ); format!("{PACKAGE_PREFIX_URL}-{java_version}_{os_name}-{arch_name}") } } @@ -138,12 +149,13 @@ pub fn locate_graal() -> Result { #[cfg(test)] mod tests { - use semver::{BuildMetadata, Prerelease}; use super::*; use crate::cache; use crate::log::setup_logging; use crate::programs::graal::Gu; use crate::programs::Java; + use semver::BuildMetadata; + use semver::Prerelease; #[tokio::test] #[ignore] @@ -176,8 +188,8 @@ OpenJDK 64-Bit Server VM GraalVM CE 17.0.7+7.1 (build 17.0.7+7-jvmci-23.0-b12, m major: 17, minor: 0, patch: 7, - pre: Prerelease::EMPTY, - build: BuildMetadata::new("7.1").unwrap() + pre: Prerelease::EMPTY, + build: BuildMetadata::new("7.1").unwrap(), }; assert_eq!(found_graal, expected_graal_version); @@ -187,14 +199,15 @@ OpenJDK 64-Bit Server VM GraalVM CE 17.0.7+7.1 (build 17.0.7+7-jvmci-23.0-b12, m #[test] fn recognize_oneline_version() { - let version_line = "OpenJDK Runtime Environment GraalVM CE 17.0.7+7.1 (build 17.0.7+7-jvmci-23.0-b12)"; + let version_line = + "OpenJDK Runtime Environment GraalVM CE 17.0.7+7.1 (build 17.0.7+7-jvmci-23.0-b12)"; let graal_version = Version::find_in_text(version_line).unwrap(); let expected_graal_version = Version { major: 17, minor: 0, patch: 7, - pre: Prerelease::EMPTY, - build: BuildMetadata::new("7.1").unwrap() + pre: Prerelease::EMPTY, + build: BuildMetadata::new("7.1").unwrap(), }; assert_eq!(graal_version, expected_graal_version); } @@ -205,11 +218,16 @@ OpenJDK 64-Bit Server VM GraalVM CE 17.0.7+7.1 (build 17.0.7+7-jvmci-23.0-b12, m major: 17, minor: 0, patch: 7, - pre: Prerelease::EMPTY, - build: BuildMetadata::new("7.1").unwrap() + pre: Prerelease::EMPTY, + build: BuildMetadata::new("7.1").unwrap(), }; - let version_str = format!("{}.{}.{}+{}", version_with_build_metadata.major, version_with_build_metadata.minor, - version_with_build_metadata.patch, version_with_build_metadata.build); + let version_str = format!( + "{}.{}.{}+{}", + version_with_build_metadata.major, + version_with_build_metadata.minor, + version_with_build_metadata.patch, + version_with_build_metadata.build + ); assert_eq!(version_str, "17.0.7+7.1"); } } From c66e3bd0be8825820c475455ecdef092a30d65ec Mon Sep 17 00:00:00 2001 From: Pavel Marek Date: Wed, 19 Jul 2023 11:21:39 +0200 Subject: [PATCH 39/51] Remove @Shared warning in ReadArgumentCheckNode --- .../node/callable/argument/ReadArgumentCheckNode.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/engine/runtime/src/main/java/org/enso/interpreter/node/callable/argument/ReadArgumentCheckNode.java b/engine/runtime/src/main/java/org/enso/interpreter/node/callable/argument/ReadArgumentCheckNode.java index fc39f8537158..7ec3a1e31e55 100644 --- a/engine/runtime/src/main/java/org/enso/interpreter/node/callable/argument/ReadArgumentCheckNode.java +++ b/engine/runtime/src/main/java/org/enso/interpreter/node/callable/argument/ReadArgumentCheckNode.java @@ -3,6 +3,7 @@ import com.oracle.truffle.api.CompilerAsserts; import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.dsl.Cached; +import com.oracle.truffle.api.dsl.Cached.Shared; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.frame.MaterializedFrame; import com.oracle.truffle.api.frame.VirtualFrame; @@ -65,7 +66,7 @@ Object doCheckNoConversionNeeded(VirtualFrame frame, Object v) throws InvalidAss }) Object doWithConversionCached( VirtualFrame frame, Object v, - @Cached TypeOfNode typeOfNode, + @Shared("typeOfNode") @Cached TypeOfNode typeOfNode, @Cached("findType(typeOfNode, v)") Type cachedType, @Cached("findConversionNode(cachedType)") ApplicationNode convertNode ) { @@ -75,7 +76,7 @@ Object doWithConversionCached( @Specialization(replaces = "doWithConversionCached") Object doWithConversionUncached( VirtualFrame frame, Object v, - @Cached TypeOfNode typeOfNode + @Shared("typeOfNode") @Cached TypeOfNode typeOfNode ) { var type = findType(typeOfNode, v); return doWithConversionUncachedBoundary(frame.materialize(), v, type); From 051b2cdad62fe44cde27eb2f3ce9cc8fce37472b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rados=C5=82aw=20Wa=C5=9Bko?= Date: Wed, 19 Jul 2023 17:06:38 +0200 Subject: [PATCH 40/51] Add a missing placeholder for a runtime-version-manager-test --- .../graalvm-ce-java11-1.0.0/bin/java.exe | 1 + 1 file changed, 1 insertion(+) create mode 100644 lib/scala/runtime-version-manager-test/src/main/resources/org/enso/runtimeversionmanager/test/fake-releases/graalvm/vm-1.0.0/graalvm-ce-java11-windows-amd64-1.0.0.zip/graalvm-ce-java11-1.0.0/bin/java.exe diff --git a/lib/scala/runtime-version-manager-test/src/main/resources/org/enso/runtimeversionmanager/test/fake-releases/graalvm/vm-1.0.0/graalvm-ce-java11-windows-amd64-1.0.0.zip/graalvm-ce-java11-1.0.0/bin/java.exe b/lib/scala/runtime-version-manager-test/src/main/resources/org/enso/runtimeversionmanager/test/fake-releases/graalvm/vm-1.0.0/graalvm-ce-java11-windows-amd64-1.0.0.zip/graalvm-ce-java11-1.0.0/bin/java.exe new file mode 100644 index 000000000000..48cdce852872 --- /dev/null +++ b/lib/scala/runtime-version-manager-test/src/main/resources/org/enso/runtimeversionmanager/test/fake-releases/graalvm/vm-1.0.0/graalvm-ce-java11-windows-amd64-1.0.0.zip/graalvm-ce-java11-1.0.0/bin/java.exe @@ -0,0 +1 @@ +placeholder From 93f504c085114ca26782f38fb670303cf6d137f7 Mon Sep 17 00:00:00 2001 From: Pavel Marek Date: Wed, 19 Jul 2023 17:51:53 +0200 Subject: [PATCH 41/51] Add RuntimeVersionManager test for the new GraalVM versioning --- .../enso/enso-0.0.3/manifest.yaml | 13 +++++ .../Contents/Home/bin/java | 2 + .../graalvm-ce-java17.0.7-23.0.0/bin/java | 2 + .../RuntimeVersionManagerSpec.scala | 54 ++++++++++++------- 4 files changed, 52 insertions(+), 19 deletions(-) create mode 100644 lib/scala/runtime-version-manager-test/src/main/resources/org/enso/runtimeversionmanager/test/fake-releases/enso/enso-0.0.3/manifest.yaml create mode 100755 lib/scala/runtime-version-manager-test/src/main/resources/org/enso/runtimeversionmanager/test/fake-releases/graalvm/vm-23.0.0/graalvm-ce-java17.0.7-darwin-amd64-23.0.0.tar.gz/graalvm-ce-java17.0.7-23.0.0/Contents/Home/bin/java create mode 100755 lib/scala/runtime-version-manager-test/src/main/resources/org/enso/runtimeversionmanager/test/fake-releases/graalvm/vm-23.0.0/graalvm-ce-java17.0.7-linux-amd64-23.0.0.tar.gz/graalvm-ce-java17.0.7-23.0.0/bin/java diff --git a/lib/scala/runtime-version-manager-test/src/main/resources/org/enso/runtimeversionmanager/test/fake-releases/enso/enso-0.0.3/manifest.yaml b/lib/scala/runtime-version-manager-test/src/main/resources/org/enso/runtimeversionmanager/test/fake-releases/enso/enso-0.0.3/manifest.yaml new file mode 100644 index 000000000000..eaea47d13ace --- /dev/null +++ b/lib/scala/runtime-version-manager-test/src/main/resources/org/enso/runtimeversionmanager/test/fake-releases/enso/enso-0.0.3/manifest.yaml @@ -0,0 +1,13 @@ +minimum-launcher-version: 0.0.0-dev +minimum-project-manager-version: 0.0.0-dev +graal-vm-version: 23.0.0 +graal-java-version: 17.0.7 +jvm-options: + - value: "-Dpolyglot.engine.IterativePartialEscape=true" + - value: "-Dtruffle.class.path.append=$enginePackagePath\\component\\runtime.jar" + os: "windows" + - value: "-Dtruffle.class.path.append=$enginePackagePath/component/runtime.jar" + os: "linux" + - value: "-Dtruffle.class.path.append=$enginePackagePath/component/runtime.jar" + os: "macos" + - value: "-Denso.version.override=0.0.1" diff --git a/lib/scala/runtime-version-manager-test/src/main/resources/org/enso/runtimeversionmanager/test/fake-releases/graalvm/vm-23.0.0/graalvm-ce-java17.0.7-darwin-amd64-23.0.0.tar.gz/graalvm-ce-java17.0.7-23.0.0/Contents/Home/bin/java b/lib/scala/runtime-version-manager-test/src/main/resources/org/enso/runtimeversionmanager/test/fake-releases/graalvm/vm-23.0.0/graalvm-ce-java17.0.7-darwin-amd64-23.0.0.tar.gz/graalvm-ce-java17.0.7-23.0.0/Contents/Home/bin/java new file mode 100755 index 000000000000..c075a6a031bc --- /dev/null +++ b/lib/scala/runtime-version-manager-test/src/main/resources/org/enso/runtimeversionmanager/test/fake-releases/graalvm/vm-23.0.0/graalvm-ce-java17.0.7-darwin-amd64-23.0.0.tar.gz/graalvm-ce-java17.0.7-23.0.0/Contents/Home/bin/java @@ -0,0 +1,2 @@ +#!/bin/sh +echo "Fake JVM executable has been executed" diff --git a/lib/scala/runtime-version-manager-test/src/main/resources/org/enso/runtimeversionmanager/test/fake-releases/graalvm/vm-23.0.0/graalvm-ce-java17.0.7-linux-amd64-23.0.0.tar.gz/graalvm-ce-java17.0.7-23.0.0/bin/java b/lib/scala/runtime-version-manager-test/src/main/resources/org/enso/runtimeversionmanager/test/fake-releases/graalvm/vm-23.0.0/graalvm-ce-java17.0.7-linux-amd64-23.0.0.tar.gz/graalvm-ce-java17.0.7-23.0.0/bin/java new file mode 100755 index 000000000000..c075a6a031bc --- /dev/null +++ b/lib/scala/runtime-version-manager-test/src/main/resources/org/enso/runtimeversionmanager/test/fake-releases/graalvm/vm-23.0.0/graalvm-ce-java17.0.7-linux-amd64-23.0.0.tar.gz/graalvm-ce-java17.0.7-23.0.0/bin/java @@ -0,0 +1,2 @@ +#!/bin/sh +echo "Fake JVM executable has been executed" diff --git a/lib/scala/runtime-version-manager-test/src/test/scala/org/enso/runtimeversionmanager/components/RuntimeVersionManagerSpec.scala b/lib/scala/runtime-version-manager-test/src/test/scala/org/enso/runtimeversionmanager/components/RuntimeVersionManagerSpec.scala index 9bce7e53b2b8..5594526f80c9 100644 --- a/lib/scala/runtime-version-manager-test/src/test/scala/org/enso/runtimeversionmanager/components/RuntimeVersionManagerSpec.scala +++ b/lib/scala/runtime-version-manager-test/src/test/scala/org/enso/runtimeversionmanager/components/RuntimeVersionManagerSpec.scala @@ -206,8 +206,8 @@ class RuntimeVersionManagerSpec val engineVersion = SemVer(0, 1, 0) val runtimeVersion = GraalVMVersion("1.0.0", "11") prepareBundle( - engines = Seq(engineVersion), - runtimes = Seq(runtimeVersion) + engineVersion = engineVersion, + runtimeVersion = runtimeVersion ) val manager = makeRuntimeVersionManager() @@ -224,8 +224,8 @@ class RuntimeVersionManagerSpec val engineVersion = SemVer(0, 1, 0) val runtimeVersion = GraalVMVersion("1.0.0", "11") prepareBundle( - engines = Seq(engineVersion), - runtimes = Seq(runtimeVersion) + engineVersion = engineVersion, + runtimeVersion = runtimeVersion ) val manager = makeRuntimeVersionManager() def installedEngines = manager.listInstalledEngines().map(_.version) @@ -267,8 +267,8 @@ class RuntimeVersionManagerSpec "include both bundled and installed components in list" in { prepareBundle( - engines = Seq(SemVer(0, 0, 1)), - runtimes = Seq(GraalVMVersion("1.0.0", "11")) + engineVersion = SemVer(0, 0, 1), + runtimeVersion = GraalVMVersion("1.0.0", "11") ) val manager = makeRuntimeVersionManager() manager.findOrInstallEngine(SemVer(0, 1, 0)) @@ -287,30 +287,46 @@ class RuntimeVersionManagerSpec ) runtimeVersions.map(_.javaVersion).toSet shouldEqual Set("11") } + + "cope with semantic versioning of Java" in { + val engineVersion = SemVer(0, 0, 3) + val graalVersion = GraalVMVersion("23.0.0", "17.0.7") + prepareBundle( + engineVersion = engineVersion, + runtimeVersion = graalVersion + ) + val manager = makeRuntimeVersionManager() + val engine = manager.findEngine(engineVersion).value + engine.version shouldEqual engineVersion + engine.ensureValid() + + manager.findGraalRuntime(engine).value.version shouldEqual graalVersion + manager.findGraalRuntime(graalVersion).value.ensureValid() + } } private def prepareBundle( - engines: Seq[SemVer], - runtimes: Seq[GraalVMVersion] + engineVersion: SemVer, + runtimeVersion: GraalVMVersion ): Unit = { FileSystem.writeTextFile( getTestDirectory / ".enso.bundle", "Enso Bundle Marker" ) - for (engineVersion <- engines) { - fakeInstallEngine(getTestDirectory / "dist", engineVersion) - } - for (runtimeVersion <- runtimes) { - fakeInstallRuntime(getTestDirectory / "runtime", runtimeVersion) - } + fakeInstallEngine(getTestDirectory / "dist", engineVersion, runtimeVersion) + fakeInstallRuntime(getTestDirectory / "runtime", runtimeVersion) } - private def fakeInstallEngine(searchPath: Path, version: SemVer): Unit = { - val manifest = """minimum-launcher-version: 0.0.0-dev + private def fakeInstallEngine( + searchPath: Path, + engineVersion: SemVer, + runtimeVersion: GraalVMVersion + ): Unit = { + val manifest = s"""minimum-launcher-version: 0.0.0-dev |minimum-project-manager-version: 0.0.0-dev - |graal-vm-version: 1.0.0 - |graal-java-version: 11""".stripMargin - val root = searchPath / version.toString + |graal-vm-version: ${runtimeVersion.graalVersion} + |graal-java-version: ${runtimeVersion.javaVersion}""".stripMargin + val root = searchPath / engineVersion.toString Files.createDirectories(root) FileSystem.writeTextFile(root / "manifest.yaml", manifest) val components = root / "component" From 881c98378864df8e7f3e6f06550819c07e6dee5f Mon Sep 17 00:00:00 2001 From: Pavel Marek Date: Wed, 19 Jul 2023 17:55:19 +0200 Subject: [PATCH 42/51] Bump minimal versions in manifest template --- distribution/manifest.template.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/distribution/manifest.template.yaml b/distribution/manifest.template.yaml index 9c9f6b6767dd..0060b867df2d 100644 --- a/distribution/manifest.template.yaml +++ b/distribution/manifest.template.yaml @@ -1,5 +1,5 @@ -minimum-launcher-version: 0.2.13 -minimum-project-manager-version: 0.2.13 +minimum-launcher-version: 2023.2.1-nightly.2023.7.20 +minimum-project-manager-version: 2023.2.1-nightly.2023.7.20 jvm-options: - value: "-Dpolyglot.engine.IterativePartialEscape=true" - value: "-Dtruffle.class.path.append=$enginePackagePath\\component\\runtime.jar" From 821a5b84e62244ed815428bc3c0f4040a5855e3d Mon Sep 17 00:00:00 2001 From: Pavel Marek Date: Wed, 19 Jul 2023 17:59:21 +0200 Subject: [PATCH 43/51] fmt --- .../components/RuntimeVersionManagerSpec.scala | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/scala/runtime-version-manager-test/src/test/scala/org/enso/runtimeversionmanager/components/RuntimeVersionManagerSpec.scala b/lib/scala/runtime-version-manager-test/src/test/scala/org/enso/runtimeversionmanager/components/RuntimeVersionManagerSpec.scala index 5594526f80c9..c62c33201563 100644 --- a/lib/scala/runtime-version-manager-test/src/test/scala/org/enso/runtimeversionmanager/components/RuntimeVersionManagerSpec.scala +++ b/lib/scala/runtime-version-manager-test/src/test/scala/org/enso/runtimeversionmanager/components/RuntimeVersionManagerSpec.scala @@ -290,13 +290,13 @@ class RuntimeVersionManagerSpec "cope with semantic versioning of Java" in { val engineVersion = SemVer(0, 0, 3) - val graalVersion = GraalVMVersion("23.0.0", "17.0.7") + val graalVersion = GraalVMVersion("23.0.0", "17.0.7") prepareBundle( - engineVersion = engineVersion, + engineVersion = engineVersion, runtimeVersion = graalVersion ) val manager = makeRuntimeVersionManager() - val engine = manager.findEngine(engineVersion).value + val engine = manager.findEngine(engineVersion).value engine.version shouldEqual engineVersion engine.ensureValid() @@ -323,9 +323,9 @@ class RuntimeVersionManagerSpec runtimeVersion: GraalVMVersion ): Unit = { val manifest = s"""minimum-launcher-version: 0.0.0-dev - |minimum-project-manager-version: 0.0.0-dev - |graal-vm-version: ${runtimeVersion.graalVersion} - |graal-java-version: ${runtimeVersion.javaVersion}""".stripMargin + |minimum-project-manager-version: 0.0.0-dev + |graal-vm-version: ${runtimeVersion.graalVersion} + |graal-java-version: ${runtimeVersion.javaVersion}""".stripMargin val root = searchPath / engineVersion.toString Files.createDirectories(root) FileSystem.writeTextFile(root / "manifest.yaml", manifest) From 71aa1e9e286609977345884d9140ea13d44900a3 Mon Sep 17 00:00:00 2001 From: Pavel Marek Date: Thu, 20 Jul 2023 09:00:36 +0200 Subject: [PATCH 44/51] Fix EngineManagementApi project-manager test --- .../enso/projectmanager/protocol/EngineManagementApiSpec.scala | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/scala/project-manager/src/test/scala/org/enso/projectmanager/protocol/EngineManagementApiSpec.scala b/lib/scala/project-manager/src/test/scala/org/enso/projectmanager/protocol/EngineManagementApiSpec.scala index 1775b52ffe15..80915e2219e2 100644 --- a/lib/scala/project-manager/src/test/scala/org/enso/projectmanager/protocol/EngineManagementApiSpec.scala +++ b/lib/scala/project-manager/src/test/scala/org/enso/projectmanager/protocol/EngineManagementApiSpec.scala @@ -45,6 +45,7 @@ class EngineManagementApiSpec extends BaseServerSpec with FlakySpec { "versions" : [ {"version": "0.9999.0-broken", "markedAsBroken": true}, {"version": "0.1.0", "markedAsBroken": false}, + {"version": "0.0.3", "markedAsBroken": false}, {"version": "0.0.1", "markedAsBroken": false}, {"version": "0.0.1-pre", "markedAsBroken": false}, {"version": "0.0.0", "markedAsBroken": false} From 7389e4191986dbc49916ab9a64af46bee300c1a0 Mon Sep 17 00:00:00 2001 From: Pavel Marek Date: Thu, 20 Jul 2023 12:06:04 +0200 Subject: [PATCH 45/51] Use raw string literal --- build/ci_utils/src/cache/goodie/graalvm.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build/ci_utils/src/cache/goodie/graalvm.rs b/build/ci_utils/src/cache/goodie/graalvm.rs index ed5a302e7ae9..e1a800e49ed4 100644 --- a/build/ci_utils/src/cache/goodie/graalvm.rs +++ b/build/ci_utils/src/cache/goodie/graalvm.rs @@ -179,9 +179,9 @@ mod tests { /// Check that we correctly recognize both the GraalVM version and the Java version. #[test] fn version_recognize() { - let version_string = "openjdk version \"17.0.7\" 2023-04-18 + let version_string = r#"openjdk version "17.0.7" 2023-04-18 OpenJDK Runtime Environment GraalVM CE 17.0.7+7.1 (build 17.0.7+7-jvmci-23.0-b12) -OpenJDK 64-Bit Server VM GraalVM CE 17.0.7+7.1 (build 17.0.7+7-jvmci-23.0-b12, mixed mode, sharing)"; +OpenJDK 64-Bit Server VM GraalVM CE 17.0.7+7.1 (build 17.0.7+7-jvmci-23.0-b12, mixed mode, sharing)"#; let found_graal = graal_version_from_version_string(version_string).unwrap(); let expected_graal_version = Version { From 2064a5ca162fd6ba02b4e4c7f1d354b403732f8b Mon Sep 17 00:00:00 2001 From: Pavel Marek Date: Thu, 20 Jul 2023 12:14:07 +0200 Subject: [PATCH 46/51] Do not use new variable name just to hold temporary expression. --- build/ci_utils/src/cache/goodie/graalvm.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build/ci_utils/src/cache/goodie/graalvm.rs b/build/ci_utils/src/cache/goodie/graalvm.rs index e1a800e49ed4..d958e315bc9e 100644 --- a/build/ci_utils/src/cache/goodie/graalvm.rs +++ b/build/ci_utils/src/cache/goodie/graalvm.rs @@ -75,8 +75,8 @@ impl Goodie for GraalVM { Ok(dir_entry) => dir_entry, Err(err) => bail!("Failed to read GraalVM cache directory: {}", err), }; - let dir_name_tmp = graalvm_dir.file_name(); - let dir_name = dir_name_tmp.as_str(); + let dir_name = graalvm_dir.file_name(); + let dir_name = dir_name.as_str(); assert!(dir_name.contains("graalvm")); let graal_version_str = format!( "{}.{}.{}", From 57c37ed3f08d7c0b07a14ba9aa6ccaeb8b07c0c5 Mon Sep 17 00:00:00 2001 From: Pavel Marek Date: Thu, 20 Jul 2023 12:51:01 +0200 Subject: [PATCH 47/51] Implement VersionExt.to_string_core --- build/ci_utils/src/cache/goodie/graalvm.rs | 14 ++++---------- build/ci_utils/src/extensions/version.rs | 6 ++++++ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/build/ci_utils/src/cache/goodie/graalvm.rs b/build/ci_utils/src/cache/goodie/graalvm.rs index d958e315bc9e..dda7717f4a7c 100644 --- a/build/ci_utils/src/cache/goodie/graalvm.rs +++ b/build/ci_utils/src/cache/goodie/graalvm.rs @@ -78,11 +78,7 @@ impl Goodie for GraalVM { let dir_name = graalvm_dir.file_name(); let dir_name = dir_name.as_str(); assert!(dir_name.contains("graalvm")); - let graal_version_str = format!( - "{}.{}.{}", - self.graal_version.major, self.graal_version.minor, self.graal_version.patch - ); - assert!(dir_name.contains(&graal_version_str)); + assert!(dir_name.contains(self.graal_version.to_string_core().as_str())); let root = match TARGET_OS { OS::MacOS => graalvm_dir.path().join_iter(["Contents", "Home"]), _ => graalvm_dir.path(), @@ -98,9 +94,7 @@ impl Goodie for GraalVM { impl GraalVM { pub fn url(&self) -> BoxFuture<'static, Result> { let platform_string = self.platform_string(); - let graal_version = self.graal_version.clone(); - let graal_version_tag = - format!("{}.{}.{}", graal_version.major, graal_version.minor, graal_version.patch); + let graal_version_tag = self.graal_version.to_string_core(); let client = self.client.clone(); async move { let repo = CE_BUILDS_REPOSITORY.handle(&client); @@ -126,8 +120,8 @@ impl GraalVM { other_arch => unimplemented!("Architecture `{}` is not supported!", other_arch), }; let java_version = format!( - "jdk-{}.{}.{}", - _graal_version.major, _graal_version.minor, _graal_version.patch + "jdk-{}", + _graal_version.to_string_core() ); format!("{PACKAGE_PREFIX_URL}-{java_version}_{os_name}-{arch_name}") } diff --git a/build/ci_utils/src/extensions/version.rs b/build/ci_utils/src/extensions/version.rs index 979693ec27c5..368d00ef032f 100644 --- a/build/ci_utils/src/extensions/version.rs +++ b/build/ci_utils/src/extensions/version.rs @@ -14,6 +14,12 @@ pub trait VersionExt { self.core() == other.core() } + /// Get the version numbers, excluding the prerelease or build metadata, as a string. + fn to_string_core(&self) -> String { + let (major, minor, patch) = self.core(); + format!("{}.{}.{}", major, minor, patch) + } + /// Get the identifiers (i.e. the dot-separated parts after the hyphen) of the prerelease. /// /// ``` From 0a0545ef71140d754ec539a5d6d1cc6cc9345bca Mon Sep 17 00:00:00 2001 From: Pavel Marek Date: Thu, 20 Jul 2023 12:52:12 +0200 Subject: [PATCH 48/51] Remove unnecessary test. It tested just semver library. --- build/ci_utils/src/cache/goodie/graalvm.rs | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/build/ci_utils/src/cache/goodie/graalvm.rs b/build/ci_utils/src/cache/goodie/graalvm.rs index dda7717f4a7c..7df777ad4b85 100644 --- a/build/ci_utils/src/cache/goodie/graalvm.rs +++ b/build/ci_utils/src/cache/goodie/graalvm.rs @@ -205,23 +205,4 @@ OpenJDK 64-Bit Server VM GraalVM CE 17.0.7+7.1 (build 17.0.7+7-jvmci-23.0-b12, m }; assert_eq!(graal_version, expected_graal_version); } - - #[test] - fn version_to_string() { - let version_with_build_metadata = Version { - major: 17, - minor: 0, - patch: 7, - pre: Prerelease::EMPTY, - build: BuildMetadata::new("7.1").unwrap(), - }; - let version_str = format!( - "{}.{}.{}+{}", - version_with_build_metadata.major, - version_with_build_metadata.minor, - version_with_build_metadata.patch, - version_with_build_metadata.build - ); - assert_eq!(version_str, "17.0.7+7.1"); - } } From 2a1f553404518fdfe312f3c29dd5900c7d8f43c1 Mon Sep 17 00:00:00 2001 From: Pavel Marek Date: Thu, 20 Jul 2023 13:04:35 +0200 Subject: [PATCH 49/51] Do not use assert! in non-tests --- build/ci_utils/src/cache/goodie/graalvm.rs | 22 ++++++++-------------- build/ci_utils/src/programs/graal.rs | 1 + 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/build/ci_utils/src/cache/goodie/graalvm.rs b/build/ci_utils/src/cache/goodie/graalvm.rs index 7df777ad4b85..cc816ca194b7 100644 --- a/build/ci_utils/src/cache/goodie/graalvm.rs +++ b/build/ci_utils/src/cache/goodie/graalvm.rs @@ -63,22 +63,19 @@ impl Goodie for GraalVM { fn activation_env_changes(&self, package_path: &Path) -> Result> { let dir_entries = package_path .read_dir() - .context("Failed to read GraalVM cache directory") - .unwrap() + .context("Failed to read GraalVM cache directory")? .collect_vec(); - assert_eq!( - dir_entries.len(), - 1, - "GraalVM cache directory should contain exactly one directory" - ); - let graalvm_dir = match dir_entries.get(0).unwrap() { + let [graalvm_dir] = dir_entries.as_slice() else { + bail!("GraalVM cache directory should contain exactly one directory"); + }; + let graalvm_dir = match graalvm_dir { Ok(dir_entry) => dir_entry, Err(err) => bail!("Failed to read GraalVM cache directory: {}", err), }; let dir_name = graalvm_dir.file_name(); let dir_name = dir_name.as_str(); - assert!(dir_name.contains("graalvm")); - assert!(dir_name.contains(self.graal_version.to_string_core().as_str())); + ensure!(dir_name.contains("graalvm")); + ensure!(dir_name.contains(self.graal_version.to_string_core().as_str())); let root = match TARGET_OS { OS::MacOS => graalvm_dir.path().join_iter(["Contents", "Home"]), _ => graalvm_dir.path(), @@ -119,10 +116,7 @@ impl GraalVM { Arch::AArch64 => "aarch64", other_arch => unimplemented!("Architecture `{}` is not supported!", other_arch), }; - let java_version = format!( - "jdk-{}", - _graal_version.to_string_core() - ); + let java_version = format!("jdk-{}", _graal_version.to_string_core()); format!("{PACKAGE_PREFIX_URL}-{java_version}_{os_name}-{arch_name}") } } diff --git a/build/ci_utils/src/programs/graal.rs b/build/ci_utils/src/programs/graal.rs index fefea8164dca..be66b4c26fb0 100644 --- a/build/ci_utils/src/programs/graal.rs +++ b/build/ci_utils/src/programs/graal.rs @@ -4,6 +4,7 @@ use serde::Deserializer; use serde::Serializer; + /// GraalVM Updater, `gu`, is a command-line tool for installing and managing optional GraalVM /// language runtimes and utilities. #[derive(Clone, Copy, Debug, Default)] From aca13c014adf70b15fb1158acee231939cce357a Mon Sep 17 00:00:00 2001 From: Pavel Marek Date: Thu, 20 Jul 2023 13:28:49 +0200 Subject: [PATCH 50/51] fix linter errors --- build/ci_utils/src/extensions/version.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/ci_utils/src/extensions/version.rs b/build/ci_utils/src/extensions/version.rs index 368d00ef032f..134676a8059f 100644 --- a/build/ci_utils/src/extensions/version.rs +++ b/build/ci_utils/src/extensions/version.rs @@ -17,7 +17,7 @@ pub trait VersionExt { /// Get the version numbers, excluding the prerelease or build metadata, as a string. fn to_string_core(&self) -> String { let (major, minor, patch) = self.core(); - format!("{}.{}.{}", major, minor, patch) + format!("{major}.{minor}.{patch}") } /// Get the identifiers (i.e. the dot-separated parts after the hyphen) of the prerelease. From 0cf26c323007a7d1cf17589830d480876742793d Mon Sep 17 00:00:00 2001 From: Pavel Marek Date: Thu, 20 Jul 2023 13:32:58 +0200 Subject: [PATCH 51/51] Remove @NonIdempotent annotation from specializations --- .../interpreter/node/callable/InvokeMethodNode.java | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/engine/runtime/src/main/java/org/enso/interpreter/node/callable/InvokeMethodNode.java b/engine/runtime/src/main/java/org/enso/interpreter/node/callable/InvokeMethodNode.java index dddfe4e98116..c9677a195f0d 100644 --- a/engine/runtime/src/main/java/org/enso/interpreter/node/callable/InvokeMethodNode.java +++ b/engine/runtime/src/main/java/org/enso/interpreter/node/callable/InvokeMethodNode.java @@ -188,7 +188,6 @@ private boolean typeCanOverride(MethodRootNode node, EnsoContext ctx) { && warning.getEigentype() != methodOwnerType; } - @NonIdempotent @Specialization( replaces = "doFunctionalDispatchCachedSymbol", guards = {"typesLibrary.hasType(self)", "!typesLibrary.hasSpecialDispatch(self)"}) @@ -355,7 +354,6 @@ public InvokeFunctionNode buildInvokeFunctionWithSelf() { invokeFunctionNode.getArgumentsExecutionMode()); } - @NonIdempotent @Specialization( guards = { "warnings.hasWarnings(self)", @@ -382,7 +380,6 @@ Object doWarningsCustom( return warningFunctionNode.execute(resolvedFunction, frame, state, arguments1); } - @NonIdempotent @Specialization(guards = "warnings.hasWarnings(self)") Object doWarning( VirtualFrame frame, @@ -434,7 +431,6 @@ Object doWarning( } } - @NonIdempotent @ExplodeLoop @Specialization( guards = { @@ -489,7 +485,6 @@ Object doPolyglot( return res; } - @NonIdempotent @Specialization( guards = { "!warnings.hasWarnings(self)", @@ -520,7 +515,6 @@ Object doConvertText( } } - @NonIdempotent @Specialization( guards = { "!warnings.hasWarnings(self)", @@ -545,7 +539,6 @@ Object doConvertArray( return invokeFunctionNode.execute(function, frame, state, arguments); } - @NonIdempotent @Specialization( guards = { "!warnings.hasWarnings(self)", @@ -570,7 +563,6 @@ Object doConvertHashMap( return invokeFunctionNode.execute(function, frame, state, arguments); } - @NonIdempotent @Specialization( guards = { "!warnings.hasWarnings(self)", @@ -601,7 +593,6 @@ Object doConvertDate( } } - @NonIdempotent @Specialization( guards = { "!warnings.hasWarnings(self)", @@ -674,7 +665,6 @@ private ZonedDateTime dateTime(LocalDate date, LocalTime time, ZoneId zone) { return date.atTime(time).atZone(zone); } - @NonIdempotent @Specialization( guards = { "!warnings.hasWarnings(self)", @@ -707,7 +697,6 @@ Object doConvertZonedDateTime( } } - @NonIdempotent @Specialization( guards = { "!warnings.hasWarnings(self)", @@ -738,7 +727,6 @@ Object doConvertZone( } } - @NonIdempotent @Specialization( guards = { "!warnings.hasWarnings(self)", @@ -769,7 +757,6 @@ Object doConvertTimeOfDay( } } - @NonIdempotent @Specialization( guards = { "!warnings.hasWarnings(self)",