Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
gluon-bot committed Sep 8, 2023
2 parents 40232e6 + bf5d70c commit e9f1e96
Show file tree
Hide file tree
Showing 60 changed files with 1,564 additions and 411 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
import java.util.List;
import java.util.ListIterator;
import java.util.Map;
import java.util.Random;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Supplier;
Expand Down Expand Up @@ -1075,10 +1076,13 @@ protected final InstalledCode getCode(final ResolvedJavaMethod installedCodeOwne
protected InstalledCode getCode(final ResolvedJavaMethod installedCodeOwner, StructuredGraph graph, boolean forceCompile, boolean installAsDefault, OptionValues options) {
boolean useCache = !forceCompile && getArgumentToBind() == null;
if (useCache && graph == null) {
InstalledCode cached = cache.get().get(installedCodeOwner);
HashMap<ResolvedJavaMethod, InstalledCode> tlCache = cache.get();
InstalledCode cached = tlCache.get(installedCodeOwner);
if (cached != null) {
if (cached.isValid()) {
return cached;
} else {
tlCache.remove(installedCodeOwner);
}
}
}
Expand Down Expand Up @@ -1671,4 +1675,35 @@ protected boolean isArchitecture(String name) {
protected CanonicalizerPhase createCanonicalizerPhase() {
return CanonicalizerPhase.create();
}

/**
* Defines property name for seed value.
*/
public static final String SEED_PROPERTY_NAME = "test.graal.random.seed";

/**
* Globally shared, lazily initialized random generator.
*/
private static volatile Random randomGenerator;

/**
* Returns a global {@link java.util.Random} generator. The generator is seeded with the value
* specified by {@link #SEED_PROPERTY_NAME} if it exists.
*
* The used seed printed to stdout for reproducing test failures.
*/
public static Random getRandomInstance() {
if (randomGenerator == null) {
synchronized (GraalCompilerTest.class) {
if (randomGenerator == null) {
var seedLong = Long.getLong(SEED_PROPERTY_NAME);
var seed = seedLong != null ? seedLong : new Random().nextLong();
System.out.printf("Random generator seed: %d%n", seed);
System.out.printf("To re-run test with same seed, set \"-D%s=%d\" on command line.%n", SEED_PROPERTY_NAME, seed);
randomGenerator = new Random(seed);
}
}
}
return randomGenerator;
}
}
Loading

0 comments on commit e9f1e96

Please sign in to comment.