1 /* 2 * Copyright (c) 2013, 2019, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 25 package org.graalvm.compiler.hotspot.test; 26 27 import static org.graalvm.compiler.core.GraalCompilerOptions.CompilationBailoutAsFailure; 28 import static org.graalvm.compiler.core.GraalCompilerOptions.CompilationFailureAction; 29 30 import org.graalvm.compiler.core.CompilationWrapper.ExceptionAction; 31 import org.graalvm.compiler.core.phases.HighTier; 32 import org.graalvm.compiler.core.test.GraalCompilerTest; 33 import org.graalvm.compiler.hotspot.HotSpotGraalCompiler; 34 import org.graalvm.compiler.options.OptionValues; 35 import org.junit.Test; 36 37 import jdk.vm.ci.hotspot.HotSpotJVMCIRuntime; 38 39 /** 40 * Tests {@link CompileTheWorld} functionality. 41 */ 42 public class CompileTheWorldTest extends GraalCompilerTest { 43 44 @Test 45 public void testJDK() throws Throwable { 46 boolean originalBailoutAction = CompilationBailoutAsFailure.getValue(getInitialOptions()); 47 ExceptionAction originalFailureAction = CompilationFailureAction.getValue(getInitialOptions()); 48 // Compile a couple classes in rt.jar 49 HotSpotJVMCIRuntime runtime = HotSpotJVMCIRuntime.runtime(); 50 System.setProperty("CompileTheWorld.LimitModules", "java.base"); 51 OptionValues initialOptions = getInitialOptions(); 52 OptionValues harnessOptions = new OptionValues(OptionValues.newOptionMap()); 53 int startAt = 1; 54 int stopAt = 5; 55 int maxClasses = Integer.MAX_VALUE; 56 String methodFilters = null; 57 String excludeMethodFilters = null; 58 boolean verbose = false; 59 CompileTheWorld ctw = new CompileTheWorld(runtime, 60 (HotSpotGraalCompiler) runtime.getCompiler(), 61 CompileTheWorld.SUN_BOOT_CLASS_PATH, 62 startAt, 63 stopAt, 64 maxClasses, 65 methodFilters, 66 excludeMethodFilters, 67 verbose, 68 harnessOptions, 69 new OptionValues(initialOptions, HighTier.Options.Inline, false)); 70 ctw.compile(); 71 assert CompilationBailoutAsFailure.getValue(initialOptions) == originalBailoutAction; 72 assert CompilationFailureAction.getValue(initialOptions) == originalFailureAction; 73 } 74 }