Skip to content

Commit

Permalink
Merge pull request #19511 from zakkak/enable-parseonce
Browse files Browse the repository at this point in the history
Re-enable single parsing of compiler graphs in native-image
  • Loading branch information
geoand authored Sep 28, 2021
2 parents c84538b + b9e22a5 commit c40a024
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public class NativeConfig {
/**
* If {@code -H:+InlineBeforeAnalysis} flag will be added to the native-image run
*/
@ConfigItem
@ConfigItem(defaultValue = "true")
public boolean inlineBeforeAnalysis;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ static final class Version implements Comparable<Version> {
static final Version VERSION_20_3 = new Version("GraalVM 20.3", 20, 3, Distribution.ORACLE);
static final Version VERSION_21_1 = new Version("GraalVM 21.1", 21, 1, Distribution.ORACLE);
static final Version VERSION_21_2 = new Version("GraalVM 21.2", 21, 2, Distribution.ORACLE);
static final Version VERSION_21_3 = new Version("GraalVM 21.3", 21, 3, Distribution.ORACLE);

static final Version MINIMUM = VERSION_20_3;
static final Version CURRENT = VERSION_21_2;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,7 @@ public NativeImageInvokerInfo build() {
} else if (prop.getKey().equals("quarkus.native.enable-all-charsets") && prop.getValue() != null) {
addAllCharsets |= Boolean.parseBoolean(prop.getValue());
} else if (prop.getKey().equals("quarkus.native.inline-before-analysis") && prop.getValue() != null) {
inlineBeforeAnalysis |= Boolean.parseBoolean(prop.getValue());
inlineBeforeAnalysis = Boolean.parseBoolean(prop.getValue());
} else {
// todo maybe just -D is better than -J-D in this case
if (prop.getValue() == null) {
Expand Down Expand Up @@ -651,14 +651,14 @@ public NativeImageInvokerInfo build() {
// This option was removed in GraalVM 21.1 https://github.com/oracle/graal/pull/3258
nativeImageArgs.add("--enable-all-security-services");
}
if (inlineBeforeAnalysis) {
if (graalVMVersion.isNewerThan(GraalVM.Version.VERSION_20_3)) {
nativeImageArgs.add("-H:+InlineBeforeAnalysis");
if (graalVMVersion.isNewerThan(GraalVM.Version.VERSION_20_3)) {
if (inlineBeforeAnalysis) {
if (graalVMVersion.isOlderThan(GraalVM.Version.VERSION_21_3)) {
// Enabled by default in GraalVM >= 21.3
nativeImageArgs.add("-H:+InlineBeforeAnalysis");
}
} else {
log.warn(
"The InlineBeforeAnalysis feature is not supported in GraalVM versions prior to 21.0.0."
+ " InlineBeforeAnalysis will thus not be enabled, please consider using a newer"
+ " GraalVM version if your application relies on this feature.");
nativeImageArgs.add("-H:-InlineBeforeAnalysis");
}
}
if (!noPIE.isEmpty()) {
Expand Down Expand Up @@ -703,10 +703,6 @@ public NativeImageInvokerInfo build() {
}

if (graalVMVersion.isNewerThan(GraalVM.Version.VERSION_21_1)) {

// Disable single parsing of compiler graphs till https://github.com/oracle/graal/issues/3435 gets fixed
nativeImageArgs.add("-H:-ParseOnce");

// AdditionalSecurityProviders
if (nativeImageSecurityProviders != null && !nativeImageSecurityProviders.isEmpty()) {
String additionalSecurityProviders = nativeImageSecurityProviders.stream()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
import org.postgresql.xml.DefaultPGXmlFactoryFactory;
import org.postgresql.xml.PGXmlFactoryFactory;

import com.oracle.svm.core.annotate.NeverInline;

/**
* Used by PgSQLXML: easier to keep the actual code separated from the substitutions.
*/
Expand Down Expand Up @@ -48,10 +50,9 @@ public static String maybeProcessAsDomResult(DOMResult domResult, BaseConnection
}
}

//When GraalVM can figure out a constant name for the target method to be invoked reflectively,
//it automatically registers it for reflection. We don't want that to happen in this particular case.
@NeverInline("Prevent GraalVM from figuring out the target method to be invoked reflectively, so that it can't automatically register it for reflection")
private static String obfuscatedMethodName() {
return "reallyProcessDom" + "Result";
return "reallyProcessDomResult";
}

public static String reallyProcessDomResult(DOMResult domResult, BaseConnection conn) throws SQLException {
Expand Down

0 comments on commit c40a024

Please sign in to comment.