Skip to content

Commit e8e7d9d

Browse files
Use Dual JVM mode to run StdLib Native tests (#13570)
- Use #13172 to - avoid including test classes in `enso` _native image_ binary - `ENSO_LAUNCHER=test` will only add `-ea` option - `ENSO_LAUNCHER=test` will not modify classpath - Let's build up on #12468 - switch the _non-AOT ready_ libraries into _"guest JVM"_ loading mode - e.g. all `test/Base_Test/polyglot/java/*.jar` are going to be loaded by in this _"dual JVM mode"_ - originally there were [higher ambitions](#13570 (comment)) for this PR, but just ... - getting _"dual JVM"_ working for `test/Base_Tests` is a good progress to make - to mock "dual JVM" mode in HotSpot JVM specify which libraries should use the "host JVM" and which the "guest JVM". For example: ``` sbt:enso> runEngineDistribution --vm.D=polyglot.enso.classLoading=Standard.Base:hosted,guest --run test/Base_Tests/ ``` - says that `Standard.Base` should use **hosted** JVM and all other libraries should use the **guest** JVM
1 parent 7c84e28 commit e8e7d9d

File tree

58 files changed

+1386
-739
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+1386
-739
lines changed

build.sbt

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -732,12 +732,15 @@ lazy val pkg = (project in file("lib/scala/pkg"))
732732
version := "0.1",
733733
Compile / run / mainClass := Some("org.enso.pkg.Main"),
734734
libraryDependencies ++= Seq(
735-
"io.circe" %% "circe-core" % circeVersion % "provided",
736-
"org.yaml" % "snakeyaml" % snakeyamlVersion % "provided",
737-
"org.scalatest" %% "scalatest" % scalatestVersion % Test,
735+
"org.graalvm.sdk" % "nativeimage" % graalMavenPackagesVersion % "provided",
736+
"io.circe" %% "circe-core" % circeVersion % "provided",
737+
"org.yaml" % "snakeyaml" % snakeyamlVersion % "provided",
738+
"org.scalatest" %% "scalatest" % scalatestVersion % Test,
738739
"org.apache.commons" % "commons-compress" % commonsCompressVersion
739740
),
740741
Compile / moduleDependencies ++= Seq(
742+
"org.graalvm.sdk" % "word" % graalMavenPackagesVersion,
743+
"org.graalvm.sdk" % "nativeimage" % graalMavenPackagesVersion,
741744
"org.apache.commons" % "commons-compress" % commonsCompressVersion,
742745
"org.yaml" % "snakeyaml" % snakeyamlVersion
743746
),
@@ -3824,26 +3827,8 @@ lazy val `engine-runner` = project
38243827
core ++ stdLibsJars ++ extraNITestLibs.value
38253828
},
38263829
extraNITestLibs := Def.taskDyn {
3827-
if (GraalVM.EnsoLauncher.test) Def.task {
3828-
val baseHelpers =
3829-
(`enso-test-java-helpers` / Compile / packageBin).value
3830-
.getAbsolutePath()
3831-
val snowHelpers =
3832-
(`snowflake-test-java-helpers` / Compile / packageBin).value
3833-
.getAbsolutePath()
3834-
if (GraalVM.EnsoLauncher.fast) {
3835-
Seq(baseHelpers)
3836-
} else {
3837-
Seq(
3838-
baseHelpers,
3839-
snowHelpers
3840-
)
3841-
}
3842-
}
3843-
else {
3844-
Def.task {
3845-
Seq[String]()
3846-
}
3830+
Def.task {
3831+
Seq[String]()
38473832
}
38483833
}.value,
38493834
buildSmallJdk := {

distribution/lib/Standard/Base/0.0.0-dev/docs/api/Data/Time/Date_Time_Formatter.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,14 @@
77
- format_date_time self date_time:Standard.Base.Data.Time.Date_Time.Date_Time -> Standard.Base.Any.Any
88
- format_time self time:Standard.Base.Data.Time.Time_Of_Day.Time_Of_Day -> Standard.Base.Any.Any
99
- from_iso_week_date_pattern pattern:Standard.Base.Data.Text.Text locale:Standard.Base.Data.Locale.Locale= -> Standard.Base.Any.Any
10-
- from_java pattern:Standard.Base.Any.Any locale:(Standard.Base.Data.Locale.Locale|Standard.Base.Nothing.Nothing)= -> Standard.Base.Any.Any
10+
- from_java pattern:(Standard.Base.Data.Text.Text|Standard.Base.Data.Time.Date_Time_Formatter.DateTimeFormatter) locale:(Standard.Base.Data.Locale.Locale|Standard.Base.Nothing.Nothing)= -> Standard.Base.Any.Any
1111
- from_simple_pattern pattern:Standard.Base.Data.Text.Text= locale:Standard.Base.Data.Locale.Locale= -> Standard.Base.Any.Any
1212
- get_java_formatter_for_parsing self -> Standard.Base.Any.Any
1313
- handle_java_errors self ~action:Standard.Base.Any.Any -> Standard.Base.Any.Any
1414
- iso_date -> Standard.Base.Any.Any
1515
- iso_local_date_time -> Standard.Base.Any.Any
1616
- iso_offset_date_time -> Standard.Base.Any.Any
17+
- iso_ordinal_date -> Standard.Base.Data.Time.Date_Time_Formatter.Date_Time_Formatter
1718
- iso_time -> Standard.Base.Any.Any
1819
- iso_zoned_date_time -> Standard.Base.Any.Any
1920
- parse_date self text:Standard.Base.Data.Text.Text -> Standard.Base.Any.Any

distribution/lib/Standard/Base/0.0.0-dev/src/Data/Locale.enso

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import project.Meta
77
import project.Metadata.Display
88
import project.Metadata.Widget
99
import project.Nothing.Nothing
10+
import project.Panic.Panic
1011
from project.Data.Text.Extensions import all
1112
from project.Metadata.Choice import Option
1213

@@ -24,6 +25,16 @@ polyglot java import java.util.Locale as JavaLocale
2425
These are chosen as the union of the top 10 countries by population, and the
2526
top ten countries by total (nominal, not per-capita) GDP.
2627
type Locale
28+
## ---
29+
private: true
30+
---
31+
A type representing a locale.
32+
33+
## Arguments
34+
- `java_locale`: The Java locale representation used internally.
35+
Value java_locale
36+
37+
2738
## ---
2839
icon: text_input
2940
---
@@ -449,15 +460,6 @@ type Locale
449460
us : Locale
450461
us = Locale.from_language_tag "en-US"
451462

452-
## ---
453-
private: true
454-
---
455-
A type representing a locale.
456-
457-
## Arguments
458-
- `java_locale`: The Java locale representation used internally.
459-
Value java_locale
460-
461463
## ---
462464
icon: text
463465
---
@@ -627,3 +629,12 @@ type Locale
627629
fqn = Locale.to Meta.Type . qualified_name
628630
code_string = fqn + "." + field_name
629631
Option display_string code_string
632+
633+
private with_locale locale ~test =
634+
default_locale = JavaLocale.getDefault
635+
JavaLocale.setDefault locale.java_locale
636+
result = Panic.catch Any test caught_panic->
637+
JavaLocale.setDefault default_locale
638+
Panic.throw caught_panic
639+
JavaLocale.setDefault default_locale
640+
result

distribution/lib/Standard/Base/0.0.0-dev/src/Data/Time/Date_Time_Formatter.enso

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,6 @@ polyglot java import org.enso.base.time.FormatterCacheKey
2323
polyglot java import org.enso.base.time.FormatterKind
2424

2525
type Date_Time_Formatter
26-
## ---
27-
private: true
28-
---
2926
Value (underlying : EnsoDateTimeFormatter) (~deferred_parsing_warnings = [])
3027

3128
## ---
@@ -212,8 +209,7 @@ type Date_Time_Formatter
212209
pattern. If not specified, defaults to `Locale.default`. If passing a
213210
`DateTimeFormatter` instance and this argument is set, it will
214211
overwrite the original locale of that formatter.
215-
from_java : Text | DateTimeFormatter -> Locale | Nothing -> Date_Time_Formatter ! Illegal_Argument
216-
from_java pattern locale:(Locale | Nothing)=Nothing = case pattern of
212+
from_java pattern:(Text | DateTimeFormatter) locale:(Locale | Nothing)=Nothing = case pattern of
217213
java_formatter : DateTimeFormatter ->
218214
amended_formatter = case locale of
219215
Nothing -> java_formatter
@@ -280,6 +276,15 @@ type Date_Time_Formatter
280276
iso_date =
281277
Date_Time_Formatter.Value (EnsoDateTimeFormatter.makeISOConstant DateTimeFormatter.ISO_DATE "iso_date")
282278

279+
## ---
280+
icon: convert
281+
---
282+
The ISO date formatter that formats or parses the ordinal date
283+
without an offset, such as '2012-337'.
284+
285+
iso_ordinal_date -> Date_Time_Formatter =
286+
Date_Time_Formatter.Value (EnsoDateTimeFormatter.makeISOConstant DateTimeFormatter.ISO_ORDINAL_DATE "iso_ordinal_date")
287+
283288
## ---
284289
icon: convert
285290
---

distribution/lib/Standard/Table/0.0.0-dev/src/Internal/Storage.enso

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ to_value_type storage_type = case storage_type of
5050
_ : BigIntegerType -> Value_Type.Decimal scale=0
5151
_ : NullType -> Value_Type.Null
5252
_ : AnyObjectType -> Value_Type.Mixed
53+
proxy ->
54+
if proxy.isNumeric.not then Error.throw "Unknown object "+proxy.to_text else
55+
Value_Type.Integer (Bits.from_integer proxy.bits.toInteger)
5356

5457
## ---
5558
private: true

engine/common/src/main/java/org/enso/common/RuntimeOptions.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,13 @@ private RuntimeOptions() {}
3636
OptionDescriptor.newBuilder(ENABLE_STATIC_ANALYSIS_KEY, ENABLE_STATIC_ANALYSIS).build();
3737

3838
public static final String HOST_CLASS_LOADING = optionName("classLoading");
39-
public static final OptionKey<String> HOST_CLASS_LOADING_KEY = new OptionKey<>("hosted");
39+
public static final String HOST_CLASS_LOADING_HOSTED = "hosted";
40+
public static final OptionKey<String> HOST_CLASS_LOADING_KEY =
41+
new OptionKey<>(HOST_CLASS_LOADING_HOSTED);
4042
private static final OptionDescriptor HOST_CLASS_LOADING_DESCRIPTOR =
4143
OptionDescriptor.newBuilder(HOST_CLASS_LOADING_KEY, HOST_CLASS_LOADING)
4244
.help("Controls the way Enso runtime resolves polyglot java import statements")
43-
.usageSyntax("Possible values are <hosted|service|all>")
45+
.usageSyntax("Expecting comma separated list of `[<namespace>.<name>:]?hosted|guest`")
4446
.category(OptionCategory.INTERNAL)
4547
.build();
4648

engine/runner/src/main/java/org/enso/runner/Main.java

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1277,17 +1277,26 @@ final void mainEntry(String cwd, CommandLine line, Level logLevel, boolean logMa
12771277
* @return `true` if caching should be enabled, `false`, otherwise
12781278
*/
12791279
private boolean shouldEnableIrCaches(CommandLine line) {
1280-
// Temporarily, enabling static analysis disables IR caches.
12811280
if (line.hasOption(ENABLE_STATIC_ANALYSIS_OPTION)) {
12821281
if (line.hasOption(IR_CACHES_OPTION)) {
12831282
throw exitFail(
1284-
"Currently --"
1283+
""
12851284
+ ENABLE_STATIC_ANALYSIS_OPTION
12861285
+ " requires IR caches to be disabled, so --"
12871286
+ IR_CACHES_OPTION
12881287
+ " option cannot be used in combination with this flag.");
12891288
}
1290-
1289+
return false;
1290+
}
1291+
if (line.hasOption(DISABLE_PRIVATE_CHECK_OPTION)) {
1292+
if (line.hasOption(IR_CACHES_OPTION)) {
1293+
throw exitFail(
1294+
""
1295+
+ DISABLE_PRIVATE_CHECK_OPTION
1296+
+ " requires IR caches to be disabled, so --"
1297+
+ IR_CACHES_OPTION
1298+
+ " option cannot be used in combination with this flag.");
1299+
}
12911300
return false;
12921301
}
12931302

engine/runtime-compiler/src/main/scala/org/enso/compiler/data/BindingsMap.scala

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ final class BindingsMap private (initial: BindingsMapBase.State)
5959
def ensureConvertedToConcrete(
6060
state: BindingsMapBase.State
6161
): BindingsMapBase.State = {
62-
toConcrete(state, repo, repo.getModuleMap).flatMap { s =>
62+
val opt = toConcrete(state, repo, repo.getModuleMap).flatMap { s =>
6363
val cm = s.currentModule
6464
val es = s.exportedSymbols
6565
val ri = s.resolvedImports
@@ -71,7 +71,12 @@ final class BindingsMap private (initial: BindingsMapBase.State)
7171
es
7272
)
7373
)
74-
}.get
74+
}
75+
if (opt.isEmpty) {
76+
throw new java.io.IOException("Cannot deserialize " + this)
77+
} else {
78+
opt.get
79+
}
7580
}
7681
// lazily update state
7782
this.updateState(ensureConvertedToConcrete, true)

engine/runtime-language-epb/src/main/java/org/enso/interpreter/epb/HostClassLoader.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,10 @@ protected Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundE
118118
protected String findLibrary(String libname) {
119119
if (findLibraries != null) {
120120
try {
121-
var res = InteropLibrary.getUncached().execute(findLibraries, libname);
122-
if (res instanceof String s) {
123-
return s;
121+
var iop = InteropLibrary.getUncached();
122+
var res = iop.execute(findLibraries, libname);
123+
if (iop.isString(res)) {
124+
return iop.asString(res);
124125
}
125126
} catch (InteropException ex) {
126127
logger.log(Logger.Level.WARNING, "Cannot find " + libname, ex);

engine/runtime/src/main/java/org/enso/interpreter/EnsoLanguage.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,12 @@ protected ExecutableNode parse(InlineParsingRequest request) throws InlineParsin
301301
var sco = newInlineContext.localScope().getOrElse(LocalScope::empty);
302302
var mod = newInlineContext.getModule();
303303
var toTruffle =
304-
new IrToTruffle(context, request.getSource(), mod, redirectConfigWithStrictErrors);
304+
new IrToTruffle(
305+
context,
306+
module.getPackage(),
307+
request.getSource(),
308+
mod,
309+
redirectConfigWithStrictErrors);
305310
exprNode = toTruffle.runInline(ir, sco, "<inline_source>");
306311
} else {
307312
exprNode = null;

0 commit comments

Comments
 (0)