Skip to content

Commit

Permalink
[GR-7052] CompilationAlarm: Disable if assertions are enabled.
Browse files Browse the repository at this point in the history
  • Loading branch information
davleopo committed Dec 11, 2017
2 parents 47fa2a7 + 4f41df4 commit 2913d65
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 154 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
*/
package org.graalvm.compiler.core.common.util;

import org.graalvm.compiler.debug.Assertions;
import org.graalvm.compiler.options.Option;
import org.graalvm.compiler.options.OptionKey;
import org.graalvm.compiler.options.OptionType;
Expand All @@ -34,7 +35,8 @@ public final class CompilationAlarm implements AutoCloseable {

public static class Options {
// @formatter:off
@Option(help = "Time limit in seconds before a compilation expires (0 to disable the limit).", type = OptionType.Debug)
@Option(help = "Time limit in seconds before a compilation expires (0 to disable the limit). " +
"The compilation alarm will be implicitly disabled if assertions are enabled.", type = OptionType.Debug)
public static final OptionKey<Integer> CompilationExpirationPeriod = new OptionKey<>(300);
// @formatter:on
}
Expand Down Expand Up @@ -85,15 +87,16 @@ public void close() {

/**
* Starts an alarm for setting a time limit on a compilation if there isn't already an active
* alarm and {@link CompilationAlarm.Options#CompilationExpirationPeriod}{@code > 0}. The
* returned value can be used in a try-with-resource statement to disable the alarm once the
* compilation is finished.
* alarm, if assertions are disabled and
* {@link CompilationAlarm.Options#CompilationExpirationPeriod}{@code > 0}. The returned value
* can be used in a try-with-resource statement to disable the alarm once the compilation is
* finished.
*
* @return a {@link CompilationAlarm} if there was no current alarm for the calling thread
* before this call otherwise {@code null}
*/
public static CompilationAlarm trackCompilationPeriod(OptionValues options) {
int period = Options.CompilationExpirationPeriod.getValue(options);
int period = Assertions.assertionsEnabled() ? 0 : Options.CompilationExpirationPeriod.getValue(options);
if (period > 0) {
CompilationAlarm current = currentAlarm.get();
if (current == null) {
Expand All @@ -105,4 +108,5 @@ public static CompilationAlarm trackCompilationPeriod(OptionValues options) {
}
return null;
}

}

This file was deleted.

0 comments on commit 2913d65

Please sign in to comment.