1 /* 2 * Copyright (c) 2017, 2018, Red Hat, Inc. All rights reserved. 3 * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. 4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 5 * 6 * This code is free software; you can redistribute it and/or modify it 7 * under the terms of the GNU General Public License version 2 only, as 8 * published by the Free Software Foundation. 9 * 10 * This code is distributed in the hope that it will be useful, but WITHOUT 11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 * version 2 for more details (a copy is included in the LICENSE file that 14 * accompanied this code). 15 * 16 * You should have received a copy of the GNU General Public License version 17 * 2 along with this work; if not, write to the Free Software Foundation, 18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 19 * 20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 21 * or visit www.oracle.com if you need additional information or have any 22 * questions. 23 * 24 */ 25 26 /* 27 * @test id=passive 28 * @summary Check that Shenandoah cleans up interned strings 29 * @requires vm.gc.Shenandoah 30 * 31 * @run main/othervm -Xmx64m -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:+ClassUnloadingWithConcurrentMark 32 * -XX:+UseShenandoahGC -XX:ShenandoahGCMode=passive 33 * -XX:+ShenandoahDegeneratedGC -XX:+ShenandoahVerify 34 * TestStringInternCleanup 35 * 36 * @run main/othervm -Xmx64m -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:+ClassUnloadingWithConcurrentMark 37 * -XX:+UseShenandoahGC -XX:ShenandoahGCMode=passive 38 * -XX:-ShenandoahDegeneratedGC -XX:+ShenandoahVerify 39 * TestStringInternCleanup 40 * 41 * @run main/othervm -Xmx64m -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:+ClassUnloadingWithConcurrentMark 42 * -XX:+UseShenandoahGC -XX:ShenandoahGCMode=passive 43 * -XX:+ShenandoahDegeneratedGC 44 * TestStringInternCleanup 45 * 46 * @run main/othervm -Xmx64m -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:+ClassUnloadingWithConcurrentMark 47 * -XX:+UseShenandoahGC -XX:ShenandoahGCMode=passive 48 * -XX:-ShenandoahDegeneratedGC 49 * TestStringInternCleanup 50 */ 51 52 /* 53 * @test id=default 54 * @summary Check that Shenandoah cleans up interned strings 55 * @requires vm.gc.Shenandoah 56 * 57 * @run main/othervm -Xmx64m -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:+ClassUnloadingWithConcurrentMark 58 * -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=aggressive 59 * TestStringInternCleanup 60 * 61 * @run main/othervm -Xmx64m -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:+ClassUnloadingWithConcurrentMark 62 * -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=adaptive 63 * -XX:+ShenandoahVerify 64 * TestStringInternCleanup 65 * 66 * @run main/othervm -Xmx64m -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:+ClassUnloadingWithConcurrentMark 67 * -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=adaptive 68 * TestStringInternCleanup 69 * 70 * @run main/othervm -Xmx64m -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:+ClassUnloadingWithConcurrentMark 71 * -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=compact 72 * TestStringInternCleanup 73 * 74 * @run main/othervm -Xmx64m -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:-ClassUnloadingWithConcurrentMark 75 * -XX:+UseShenandoahGC 76 * TestStringInternCleanup 77 */ 78 79 /* 80 * @test id=generational 81 * @summary Check that Shenandoah cleans up interned strings 82 * @requires vm.gc.Shenandoah 83 * 84 * @run main/othervm -Xmx64m -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:+ClassUnloadingWithConcurrentMark 85 * -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=adaptive -XX:ShenandoahGCMode=generational 86 * -XX:+ShenandoahVerify 87 * TestStringInternCleanup 88 * 89 * @run main/othervm -Xmx64m -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:+ClassUnloadingWithConcurrentMark 90 * -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=adaptive -XX:ShenandoahGCMode=generational 91 * TestStringInternCleanup 92 */ 93 94 95 public class TestStringInternCleanup { 96 97 static final int COUNT = 1_000_000; 98 static final int WINDOW = 1_000; 99 100 static final String[] reachable = new String[WINDOW]; 101 102 public static void main(String[] args) throws Exception { 103 int rIdx = 0; 104 for (int c = 0; c < COUNT; c++) { 105 reachable[rIdx] = ("LargeInternedString" + c).intern(); 106 rIdx++; 107 if (rIdx >= WINDOW) { 108 rIdx = 0; 109 } 110 } 111 } 112 113 }