Skip to content

Commit

Permalink
[GR-8831] Better diagnostics for permanent bailout errors if assertio…
Browse files Browse the repository at this point in the history
…ns are enabled.

PullRequest: graal/1190
  • Loading branch information
dougxc committed Mar 20, 2018
2 parents 3a9ebde + 870f5bf commit 373f367
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 61 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,10 @@ public CompilationWrapper(DiagnosticsOutputDirectory outputDirectory, Map<Except
*
* Subclasses can override this to choose a different action based on factors such as whether
* {@code actionKey} has been explicitly set in {@code options} for example.
*
* @param cause the cause of the bailout or failure
*/
protected ExceptionAction lookupAction(OptionValues options, EnumOptionKey<ExceptionAction> actionKey) {
protected ExceptionAction lookupAction(OptionValues options, EnumOptionKey<ExceptionAction> actionKey, Throwable cause) {
if (actionKey == CompilationFailureAction) {
if (ExitVMOnException.getValue(options)) {
assert CompilationFailureAction.getDefaultValue() != ExceptionAction.ExitVM;
Expand Down Expand Up @@ -175,7 +177,7 @@ public final T run(DebugContext initialDebug) {
actionKey = CompilationFailureAction;
causeType = "failure";
}
ExceptionAction action = lookupAction(initialOptions, actionKey);
ExceptionAction action = lookupAction(initialOptions, actionKey, cause);

action = adjustAction(initialOptions, actionKey, action);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public class GraalCompilerOptions {
@Option(help = "file:doc-files/CompilationBailoutActionHelp.txt", type = OptionType.User)
public static final EnumOptionKey<ExceptionAction> CompilationBailoutAction = new EnumOptionKey<>(ExceptionAction.Silent);
@Option(help = "Specifies the action to take when compilation fails with a bailout exception. " +
"The accepted values are the same as for CompilationBailoutAction.", type = OptionType.User)
"The accepted values are the same as for CompilationBailoutAction.", type = OptionType.User)
public static final EnumOptionKey<ExceptionAction> CompilationFailureAction = new EnumOptionKey<>(ExceptionAction.Diagnose);
@Option(help = "The maximum number of compilation failures or bailouts to handle with the action specified " +
"by CompilationFailureAction or CompilationBailoutAction before changing to a less verbose action.", type = OptionType.User)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@
*/
package org.graalvm.compiler.hotspot;

import static org.graalvm.compiler.core.CompilationWrapper.ExceptionAction.Diagnose;
import static org.graalvm.compiler.core.CompilationWrapper.ExceptionAction.ExitVM;
import static org.graalvm.compiler.core.GraalCompilerOptions.CompilationBailoutAction;
import static org.graalvm.compiler.core.GraalCompilerOptions.CompilationFailureAction;
import static org.graalvm.compiler.core.phases.HighTier.Options.Inline;
import static org.graalvm.compiler.java.BytecodeParserOptions.InlineDuringParsing;
Expand Down Expand Up @@ -140,17 +142,25 @@ protected HotSpotCompilationRequestResult handleException(Throwable t) {
}

@Override
protected ExceptionAction lookupAction(OptionValues values, EnumOptionKey<ExceptionAction> actionKey) {
/*
* Automatically exit VM on non-bailout during bootstrap or when asserts are enabled but
* respect CompilationFailureAction if it has been explicitly set.
*/
if (actionKey == CompilationFailureAction && !actionKey.hasBeenSet(values)) {
if (Assertions.assertionsEnabled() || compiler.getGraalRuntime().isBootstrapping()) {
return ExitVM;
protected ExceptionAction lookupAction(OptionValues values, EnumOptionKey<ExceptionAction> actionKey, Throwable cause) {
// Respect current action if it has been explicitly set.
if (!actionKey.hasBeenSet(values)) {
if (actionKey == CompilationFailureAction) {
// Automatically exit on non-bailout during bootstrap
// or when assertions are enabled.
if (Assertions.assertionsEnabled() || compiler.getGraalRuntime().isBootstrapping()) {
return ExitVM;
}
} else if (actionKey == CompilationBailoutAction && ((BailoutException) cause).isPermanent()) {
// Get more info for permanent bailouts during bootstrap
// or when assertions are enabled.
assert CompilationBailoutAction.getDefaultValue() == ExceptionAction.Silent;
if (Assertions.assertionsEnabled() || compiler.getGraalRuntime().isBootstrapping()) {
return Diagnose;
}
}
}
return super.lookupAction(values, actionKey);
return super.lookupAction(values, actionKey, cause);
}

@SuppressWarnings("try")
Expand Down Expand Up @@ -187,6 +197,7 @@ protected HotSpotCompilationRequestResult performCompilation(DebugContext debug)
}
return null;
}

}

public CompilationTask(HotSpotJVMCIRuntimeProvider jvmciRuntime, HotSpotGraalCompiler compiler, HotSpotCompilationRequest request, boolean useProfilingInfo, boolean installAsDefault,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,15 @@
import org.graalvm.compiler.options.OptionDescriptors;
import org.graalvm.compiler.options.OptionKey;
import org.graalvm.compiler.options.OptionValues;
import org.graalvm.compiler.options.OptionValuesAccess;
import org.graalvm.compiler.options.OptionsParser;
import org.graalvm.compiler.serviceprovider.ServiceProvider;

import jdk.vm.ci.common.InitTimer;

/**
* The {@link #HOTSPOT_OPTIONS} value contains the options values initialized in a HotSpot VM. The
* values are set via system properties with the {@value #GRAAL_OPTION_PROPERTY_PREFIX} prefix.
*/
@ServiceProvider(OptionValuesAccess.class)
public class HotSpotGraalOptionValues implements OptionValuesAccess {
public class HotSpotGraalOptionValues {

/**
* The name of the system property specifying a file containing extra Graal option settings.
Expand Down Expand Up @@ -131,9 +128,4 @@ private static OptionValues initializeOptions() {
return new OptionValues(values);
}
}

@Override
public OptionValues getOptions() {
return HOTSPOT_OPTIONS;
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
import org.graalvm.compiler.options.OptionDescriptors;
import org.graalvm.compiler.options.OptionKey;
import org.graalvm.compiler.options.OptionValues;
import org.graalvm.compiler.options.OptionValuesAccess;
import org.graalvm.compiler.options.OptionsParser;
import org.graalvm.compiler.test.SubprocessUtil;
import org.graalvm.compiler.test.SubprocessUtil.Subprocess;
Expand Down Expand Up @@ -232,7 +231,7 @@ private boolean isGraalClassAllowed(Class<?> cls) {
return true;
}

if (cls == Assertions.class || cls == OptionsParser.class || cls == OptionValues.class || OptionValuesAccess.class.isAssignableFrom(cls)) {
if (cls == Assertions.class || cls == OptionsParser.class || cls == OptionValues.class || cls.getName().equals("org.graalvm.compiler.hotspot.HotSpotGraalOptionValues")) {
// Classes implementing Graal option loading
return true;
}
Expand Down

0 comments on commit 373f367

Please sign in to comment.