< prev index next >
src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/CompilerConfigurationFactory.java
Print this page
@@ -27,11 +27,10 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
-import org.graalvm.compiler.debug.Assertions;
import org.graalvm.compiler.debug.GraalError;
import org.graalvm.compiler.options.Option;
import org.graalvm.compiler.options.OptionKey;
import org.graalvm.compiler.options.OptionType;
import org.graalvm.compiler.options.OptionValues;
@@ -71,11 +70,10 @@
private final int autoSelectionPriority;
protected CompilerConfigurationFactory(String name, int autoSelectionPriority) {
this.name = name;
this.autoSelectionPriority = autoSelectionPriority;
- assert checkAndAddNewFactory(this);
}
public abstract CompilerConfiguration createCompilerConfiguration();
/**
@@ -125,31 +123,32 @@
assert this == o : "distinct compiler configurations cannot have the same auto selection priority";
return 0;
}
/**
- * List used to assert uniqueness of {@link #name} and {@link #autoSelectionPriority} across all
- * {@link CompilerConfigurationFactory} instances.
+ * Asserts uniqueness of {@link #name} and {@link #autoSelectionPriority} for {@code factory} in
+ * {@code factories}.
*/
- private static final List<CompilerConfigurationFactory> factories = Assertions.assertionsEnabled() ? new ArrayList<>() : null;
-
- private static boolean checkAndAddNewFactory(CompilerConfigurationFactory factory) {
+ private static boolean checkUnique(CompilerConfigurationFactory factory, List<CompilerConfigurationFactory> factories) {
for (CompilerConfigurationFactory other : factories) {
+ if (other != factory) {
assert !other.name.equals(factory.name) : factory.getClass().getName() + " cannot have the same selector as " + other.getClass().getName() + ": " + factory.name;
- assert other.autoSelectionPriority != factory.autoSelectionPriority : factory.getClass().getName() + " cannot have the same auto-selection priority as " + other.getClass().getName() +
+ assert other.autoSelectionPriority != factory.autoSelectionPriority : factory.getClass().getName() + " cannot have the same auto-selection priority as " +
+ other.getClass().getName() +
": " + factory.autoSelectionPriority;
}
- factories.add(factory);
+ }
return true;
}
/**
* @return sorted list of {@link CompilerConfigurationFactory}s
*/
private static List<CompilerConfigurationFactory> getAllCandidates() {
List<CompilerConfigurationFactory> candidates = new ArrayList<>();
for (CompilerConfigurationFactory candidate : GraalServices.load(CompilerConfigurationFactory.class)) {
+ assert checkUnique(candidate, candidates);
candidates.add(candidate);
}
Collections.sort(candidates);
return candidates;
}
< prev index next >