-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Truffle Espresso and Truffle JS behave differently under Hotspot #5850
Comments
|
We do not publish (full) Espresso on Maven, only some guest APIs as .jars. Running Espresso in other JVMs will run in interpreter only mode, performance will be substantially lower. If that is not an issue then: Download the latest GraalVM matching the Java version of your MS JVM: Here's the modified plugins {
id 'java'
}
group 'com.lingh'
version '1.0-SNAPSHOT'
repositories {
mavenCentral()
}
dependencies {
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.9.2'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.9.2'
implementation 'org.graalvm.js:js:22.3.1'
// These are guest APIs, can only be used within Espresso.
// implementation 'org.graalvm.espresso:polyglot:22.3.1'
// implementation 'org.graalvm.espresso:hotswap:22.3.1'
// Some deps are missing on 22.3.1, so we add them manually, see below
// implementation 'org.graalvm.truffle:truffle-nfi:22.3.1'
// implementation 'org.graalvm.truffle:truffle-nfi-libffi:22.3.1'
implementation files('languages/java/espresso.jar')
implementation files('languages/nfi/truffle-nfi.jar')
implementation files('languages/nfi-libffi/truffle-nfi-libffi.jar')
}
test {
useJUnitPlatform()
systemProperty "org.graalvm.language.java.home", "languages/java"
File nfiLibrary = file('lib/libtrufflenfi.so')
systemProperty "truffle.nfi.library", nfiLibrary.absolutePath
} To create an Espresso context, you'll need some extra options: @Test
void testEspresso() {
try (Context polyglot = Context.newBuilder()
.allowNativeAccess(true)
.allowExperimentalOptions(true)
.option("java.JavaHome", System.getProperty("java.home")) // guest Java home, can be any 8/11/17 Java Home.
.option("java.JVMLibraryPath", "languages/java/lib/") // required, we need to know where to look for Espresso's libjvm.so
.build()) {
Value java_lang_Math = polyglot.getBindings("java").getMember(Math.class.getName());
double sqrt2 = java_lang_Math.invokeMember("sqrt", 2).asDouble();
double pi = java_lang_Math.getMember("PI").asDouble();
System.err.println("PI=" + pi);
System.err.println("sqrt2=" + sqrt2);
}
} And that's it. Please note that this franken-JVM is not recommended, running Espresso on GraalVM will give you, at least, one order of magnitude better performance. |
@linghengqian if you have a convincing use case, please file a feature request to run Espresso standalone from Maven. |
|
Describe GraalVM and your environment :
22.3.1
CE
JDK17
Ubuntu 22.04
amd64
java -Xinternalversion
:Have you verified this issue still happens when using the latest snapshot?
You can find snapshot builds here: https://github.com/graalvm/graalvm-ce-dev-builds/releases
Describe the issue
A clear and concise description of the issue.
Code snippet or code repository that reproduces the issue
Steps to reproduce the issue
Please include both build steps as well as run steps
Expected behavior
A clear and concise description of what you expected to happen.
./gradlew clean test
should be fine.Additional context
Add any other context about the problem here. Specially important are stack traces or log output. Feel free to link to gists or to screenshots if necesary
UnsupportedFeatureError
#5522 , Some plan to write additional unit tests for the class library need GraalVM Reachability Metadata linghengqian/graalvm-trace-metadata-smoketest#1 and Make ShardingSphere Proxy in GraalVM Native Image form available apache/shardingsphere#21347 .Details
The text was updated successfully, but these errors were encountered: