Skip to content

Commit b4530e2

Browse files
author
Jini George
committed
8204308: SA: serviceability/sa/TestInstanceKlassSize*.java fails when running in CDS mode
Use longs instead of ints while computing the identity hash of klass symbols Reviewed-by: coleenp, lfoltan
1 parent fd9fa38 commit b4530e2

5 files changed

Lines changed: 98 additions & 10 deletions

File tree

src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/Symbol.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,15 +80,16 @@ public byte getByteAt(long index) {
8080
// _identity_hash is a short
8181
private static CIntegerField idHash;
8282

83-
public int identityHash() {
83+
public long identityHash() {
8484
long addr_value = getAddress().asLongValue();
85-
int addr_bits = (int)(addr_value >> (VM.getVM().getLogMinObjAlignmentInBytes() + 3));
85+
long addr_bits =
86+
(addr_value >> (VM.getVM().getLogMinObjAlignmentInBytes() + 3)) & 0xffffffffL;
8687
int length = (int)getLength();
8788
int byte0 = getByteAt(0);
8889
int byte1 = getByteAt(1);
89-
int id_hash = (int)(0xffff & idHash.getValue(this.addr));
90-
return id_hash |
91-
((addr_bits ^ (length << 8) ^ ((byte0 << 8) | byte1)) << 16);
90+
long id_hash = 0xffffL & (long)idHash.getValue(this.addr);
91+
return (id_hash |
92+
((addr_bits ^ (length << 8) ^ ((byte0 << 8) | byte1)) << 16)) & 0xffffffffL;
9293
}
9394

9495
public boolean equals(byte[] modUTF8Chars) {

src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/Hashtable.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -49,8 +49,8 @@ protected Class getHashtableEntryClass() {
4949
return HashtableEntry.class;
5050
}
5151

52-
public int computeHash(Symbol name) {
53-
return (int) name.identityHash();
52+
public long computeHash(Symbol name) {
53+
return name.identityHash();
5454
}
5555

5656
public int hashToIndex(long fullHash) {

test/hotspot/jtreg/ProblemList-cds-mode.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,3 @@
2727
#
2828
#############################################################################
2929

30-
serviceability/sa/TestInstanceKlassSize.java 8204308 generic-all
31-
serviceability/sa/TestInstanceKlassSizeForInterface.java 8204308 generic-all

test/hotspot/jtreg/ProblemList.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ runtime/MemberName/MemberNameLeak.java 8209844 generic-all
9292
serviceability/sa/ClhsdbAttach.java 8193639 solaris-all
9393
serviceability/sa/ClhsdbCDSCore.java 8193639 solaris-all
9494
serviceability/sa/ClhsdbCDSJstackPrintAll.java 8193639 solaris-all
95+
serviceability/sa/CDSJMapClstats.java 8193639 solaris-all
9596
serviceability/sa/ClhsdbField.java 8193639 solaris-all
9697
serviceability/sa/ClhsdbFindPC.java 8193639 solaris-all
9798
serviceability/sa/ClhsdbFlags.java 8193639 solaris-all
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
/*
2+
* Copyright (c) 2018, 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+
* @test
26+
* @bug 8204308
27+
* @summary Test the jhsdb jmap -clstats command with CDS enabled
28+
* @requires vm.hasSAandCanAttach & vm.cds
29+
* @library /test/lib
30+
* @run main/othervm/timeout=2400 CDSJMapClstats
31+
*/
32+
33+
import java.util.List;
34+
import java.util.Arrays;
35+
import java.util.stream.Collectors;
36+
import jdk.test.lib.cds.CDSTestUtils;
37+
import jdk.test.lib.cds.CDSOptions;
38+
import jdk.test.lib.apps.LingeredApp;
39+
import jdk.test.lib.process.OutputAnalyzer;
40+
import jdk.test.lib.process.ProcessTools;
41+
import jdk.test.lib.JDKToolLauncher;
42+
43+
public class CDSJMapClstats {
44+
45+
private static void runClstats(long lingeredAppPid) throws Exception {
46+
47+
JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("jhsdb");
48+
launcher.addToolArg("jmap");
49+
launcher.addToolArg("--clstats");
50+
launcher.addToolArg("--pid");
51+
launcher.addToolArg(Long.toString(lingeredAppPid));
52+
53+
ProcessBuilder processBuilder = new ProcessBuilder();
54+
processBuilder.command(launcher.getCommand());
55+
System.out.println(
56+
processBuilder.command().stream().collect(Collectors.joining(" ")));
57+
58+
OutputAnalyzer SAOutput = ProcessTools.executeProcess(processBuilder);
59+
System.out.println(SAOutput.getOutput());
60+
SAOutput.shouldHaveExitValue(0);
61+
SAOutput.shouldContain("BootClassLoader");
62+
}
63+
64+
65+
public static void main(String[] args) throws Exception {
66+
System.out.println("Starting CDSJMapClstats test");
67+
String sharedArchiveName = "ArchiveForCDSJMapClstats.jsa";
68+
LingeredApp theApp = null;
69+
70+
try {
71+
CDSOptions opts = (new CDSOptions()).setArchiveName(sharedArchiveName);
72+
CDSTestUtils.createArchiveAndCheck(opts);
73+
74+
List<String> vmArgs = Arrays.asList(
75+
"-XX:+UnlockDiagnosticVMOptions",
76+
"-XX:SharedArchiveFile=" + sharedArchiveName,
77+
"-Xshare:auto");
78+
theApp = LingeredApp.startApp(vmArgs);
79+
System.out.println("Started LingeredApp with pid " + theApp.getPid());
80+
runClstats(theApp.getPid());
81+
} catch (Exception ex) {
82+
throw new RuntimeException("Test ERROR " + ex, ex);
83+
} finally {
84+
LingeredApp.stopApp(theApp);
85+
}
86+
System.out.println("Test PASSED");
87+
}
88+
}

0 commit comments

Comments
 (0)