|
38 | 38 |
|
39 | 39 | import org.graalvm.collections.EconomicMap;
|
40 | 40 | import org.graalvm.collections.EconomicSet;
|
| 41 | +import org.junit.AfterClass; |
| 42 | +import org.junit.BeforeClass; |
41 | 43 | import org.junit.Test;
|
42 | 44 |
|
43 | 45 | import com.oracle.truffle.api.Truffle;
|
|
46 | 48 | import jdk.graal.compiler.core.CompilationWrapper;
|
47 | 49 | import jdk.graal.compiler.core.GraalCompilerOptions;
|
48 | 50 | import jdk.graal.compiler.core.test.GraalCompilerTest;
|
| 51 | +import jdk.graal.compiler.debug.DebugCloseable; |
49 | 52 | import jdk.graal.compiler.debug.DebugOptions;
|
50 | 53 | import jdk.graal.compiler.debug.GlobalMetrics;
|
51 | 54 | import jdk.graal.compiler.debug.LogStream;
|
|
54 | 57 | import jdk.graal.compiler.hotspot.CompilerConfigurationFactory;
|
55 | 58 | import jdk.graal.compiler.hotspot.HotSpotGraalCompiler;
|
56 | 59 | import jdk.graal.compiler.hotspot.HotSpotGraalCompilerFactory;
|
| 60 | +import jdk.graal.compiler.hotspot.HotSpotReplacementsImpl; |
57 | 61 | import jdk.graal.compiler.hotspot.replaycomp.CompilerInterfaceDeclarations;
|
58 | 62 | import jdk.graal.compiler.hotspot.replaycomp.ReplayCompilationRunner;
|
59 | 63 | import jdk.graal.compiler.options.OptionValues;
|
| 64 | +import jdk.graal.compiler.phases.util.Providers; |
60 | 65 | import jdk.graal.compiler.runtime.RuntimeProvider;
|
61 | 66 | import jdk.vm.ci.hotspot.HotSpotCompilationRequest;
|
62 | 67 | import jdk.vm.ci.hotspot.HotSpotCompilationRequestResult;
|
|
69 | 74 | * Tests for compilation recording and replay.
|
70 | 75 | */
|
71 | 76 | public class ReplayCompilationTest extends GraalCompilerTest {
|
| 77 | + /** |
| 78 | + * A separate encoded snippet scope is necessary in case the global encoded snippets have cache |
| 79 | + * replacements. |
| 80 | + */ |
| 81 | + private static DebugCloseable snippetScope; |
| 82 | + |
| 83 | + @BeforeClass |
| 84 | + public static void setup() { |
| 85 | + Providers providers = Graal.getRequiredCapability(RuntimeProvider.class).getHostBackend().getProviders(); |
| 86 | + HotSpotReplacementsImpl replacements = (HotSpotReplacementsImpl) providers.getReplacements(); |
| 87 | + snippetScope = replacements.suppressEncodedSnippets(); |
| 88 | + replacements.encode(getInitialOptions()); |
| 89 | + } |
| 90 | + |
| 91 | + @AfterClass |
| 92 | + public static void teardown() { |
| 93 | + snippetScope.close(); |
| 94 | + } |
| 95 | + |
72 | 96 | private static int[] lengthsSquared(List<String> strings) {
|
73 | 97 | return strings.stream().mapToInt(String::length).map(i -> i * i).toArray();
|
74 | 98 | }
|
|
0 commit comments