< prev index next >

test/hotspot/jtreg/gc/shenandoah/TestStringDedup.java

Print this page

  1 /*
  2  * Copyright (c) 2017, 2021, Red Hat, Inc. 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  *

 48  * @summary Test Shenandoah string deduplication implementation
 49  * @key randomness
 50  * @requires vm.gc.Shenandoah
 51  * @library /test/lib
 52  * @modules java.base/java.lang:open
 53  *          java.management
 54  *
 55  * @run main/othervm -Xmx256m -Xlog:gc+stats -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:+UseStringDeduplication
 56  *      -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=aggressive -XX:StringDeduplicationAgeThreshold=3
 57  *      TestStringDedup
 58  *
 59  * @run main/othervm -Xmx256m -Xlog:gc+stats -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:+UseStringDeduplication
 60  *      -XX:+UseShenandoahGC -XX:StringDeduplicationAgeThreshold=3
 61  *      TestStringDedup
 62  *
 63  * @run main/othervm -Xmx256m -Xlog:gc+stats -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:+UseStringDeduplication
 64  *      -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=compact -XX:StringDeduplicationAgeThreshold=3
 65  *      TestStringDedup
 66  */
 67 














 68 import java.lang.reflect.*;
 69 import java.util.*;
 70 import jdk.test.lib.Utils;
 71 
 72 public class TestStringDedup {
 73     private static Field valueField;
 74 
 75     private static final int UniqueStrings = 20;
 76     // How many GC cycles are needed to complete deduplication.
 77     private static final int GCCount = Integer.getInteger("GCCount", 3);
 78 
 79     static {
 80         try {
 81             valueField = String.class.getDeclaredField("value");
 82             valueField.setAccessible(true);
 83         } catch (Exception e) {
 84             throw new RuntimeException(e);
 85         }
 86     }
 87 

  1 /*
  2  * Copyright (c) 2017, 2021, 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  *

 49  * @summary Test Shenandoah string deduplication implementation
 50  * @key randomness
 51  * @requires vm.gc.Shenandoah
 52  * @library /test/lib
 53  * @modules java.base/java.lang:open
 54  *          java.management
 55  *
 56  * @run main/othervm -Xmx256m -Xlog:gc+stats -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:+UseStringDeduplication
 57  *      -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=aggressive -XX:StringDeduplicationAgeThreshold=3
 58  *      TestStringDedup
 59  *
 60  * @run main/othervm -Xmx256m -Xlog:gc+stats -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:+UseStringDeduplication
 61  *      -XX:+UseShenandoahGC -XX:StringDeduplicationAgeThreshold=3
 62  *      TestStringDedup
 63  *
 64  * @run main/othervm -Xmx256m -Xlog:gc+stats -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:+UseStringDeduplication
 65  *      -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=compact -XX:StringDeduplicationAgeThreshold=3
 66  *      TestStringDedup
 67  */
 68 
 69 /*
 70  * @test id=generational
 71  * @summary Test Shenandoah string deduplication implementation
 72  * @key randomness
 73  * @requires vm.gc.Shenandoah
 74  * @library /test/lib
 75  * @modules java.base/java.lang:open
 76  *          java.management
 77  *
 78  * @run main/othervm -Xmx256m -Xlog:gc+stats -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:+UseStringDeduplication
 79  *      -XX:+UseShenandoahGC -XX:ShenandoahGCMode=generational -XX:StringDeduplicationAgeThreshold=3
 80  *      TestStringDedup
 81  */
 82 
 83 import java.lang.reflect.*;
 84 import java.util.*;
 85 import jdk.test.lib.Utils;
 86 
 87 public class TestStringDedup {
 88     private static Field valueField;
 89 
 90     private static final int UniqueStrings = 20;
 91     // How many GC cycles are needed to complete deduplication.
 92     private static final int GCCount = Integer.getInteger("GCCount", 3);
 93 
 94     static {
 95         try {
 96             valueField = String.class.getDeclaredField("value");
 97             valueField.setAccessible(true);
 98         } catch (Exception e) {
 99             throw new RuntimeException(e);
100         }
101     }
102 
< prev index next >