< 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,37 ****
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;
--- 27,36 ----
*** 71,81 ****
private final int autoSelectionPriority;
protected CompilerConfigurationFactory(String name, int autoSelectionPriority) {
this.name = name;
this.autoSelectionPriority = autoSelectionPriority;
- assert checkAndAddNewFactory(this);
}
public abstract CompilerConfiguration createCompilerConfiguration();
/**
--- 70,79 ----
*** 125,155 ****
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.
*/
! private static final List<CompilerConfigurationFactory> factories = Assertions.assertionsEnabled() ? new ArrayList<>() : null;
!
! private static boolean checkAndAddNewFactory(CompilerConfigurationFactory factory) {
for (CompilerConfigurationFactory other : factories) {
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() +
": " + 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)) {
candidates.add(candidate);
}
Collections.sort(candidates);
return candidates;
}
--- 123,154 ----
assert this == o : "distinct compiler configurations cannot have the same auto selection priority";
return 0;
}
/**
! * Asserts uniqueness of {@link #name} and {@link #autoSelectionPriority} for {@code factory} in
! * {@code factories}.
*/
! 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() +
": " + factory.autoSelectionPriority;
}
! }
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 >