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
This commit is contained in:
parent
fd9fa38d21
commit
b4530e2447
@ -80,15 +80,16 @@ public class Symbol extends VMObject {
|
||||
// _identity_hash is a short
|
||||
private static CIntegerField idHash;
|
||||
|
||||
public int identityHash() {
|
||||
public long identityHash() {
|
||||
long addr_value = getAddress().asLongValue();
|
||||
int addr_bits = (int)(addr_value >> (VM.getVM().getLogMinObjAlignmentInBytes() + 3));
|
||||
long addr_bits =
|
||||
(addr_value >> (VM.getVM().getLogMinObjAlignmentInBytes() + 3)) & 0xffffffffL;
|
||||
int length = (int)getLength();
|
||||
int byte0 = getByteAt(0);
|
||||
int byte1 = getByteAt(1);
|
||||
int id_hash = (int)(0xffff & idHash.getValue(this.addr));
|
||||
return id_hash |
|
||||
((addr_bits ^ (length << 8) ^ ((byte0 << 8) | byte1)) << 16);
|
||||
long id_hash = 0xffffL & (long)idHash.getValue(this.addr);
|
||||
return (id_hash |
|
||||
((addr_bits ^ (length << 8) ^ ((byte0 << 8) | byte1)) << 16)) & 0xffffffffL;
|
||||
}
|
||||
|
||||
public boolean equals(byte[] modUTF8Chars) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -49,8 +49,8 @@ public class Hashtable extends BasicHashtable {
|
||||
return HashtableEntry.class;
|
||||
}
|
||||
|
||||
public int computeHash(Symbol name) {
|
||||
return (int) name.identityHash();
|
||||
public long computeHash(Symbol name) {
|
||||
return name.identityHash();
|
||||
}
|
||||
|
||||
public int hashToIndex(long fullHash) {
|
||||
|
@ -27,5 +27,3 @@
|
||||
#
|
||||
#############################################################################
|
||||
|
||||
serviceability/sa/TestInstanceKlassSize.java 8204308 generic-all
|
||||
serviceability/sa/TestInstanceKlassSizeForInterface.java 8204308 generic-all
|
||||
|
@ -92,6 +92,7 @@ runtime/MemberName/MemberNameLeak.java 8209844 generic-all
|
||||
serviceability/sa/ClhsdbAttach.java 8193639 solaris-all
|
||||
serviceability/sa/ClhsdbCDSCore.java 8193639 solaris-all
|
||||
serviceability/sa/ClhsdbCDSJstackPrintAll.java 8193639 solaris-all
|
||||
serviceability/sa/CDSJMapClstats.java 8193639 solaris-all
|
||||
serviceability/sa/ClhsdbField.java 8193639 solaris-all
|
||||
serviceability/sa/ClhsdbFindPC.java 8193639 solaris-all
|
||||
serviceability/sa/ClhsdbFlags.java 8193639 solaris-all
|
||||
|
88
test/hotspot/jtreg/serviceability/sa/CDSJMapClstats.java
Normal file
88
test/hotspot/jtreg/serviceability/sa/CDSJMapClstats.java
Normal file
@ -0,0 +1,88 @@
|
||||
/*
|
||||
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @bug 8204308
|
||||
* @summary Test the jhsdb jmap -clstats command with CDS enabled
|
||||
* @requires vm.hasSAandCanAttach & vm.cds
|
||||
* @library /test/lib
|
||||
* @run main/othervm/timeout=2400 CDSJMapClstats
|
||||
*/
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Arrays;
|
||||
import java.util.stream.Collectors;
|
||||
import jdk.test.lib.cds.CDSTestUtils;
|
||||
import jdk.test.lib.cds.CDSOptions;
|
||||
import jdk.test.lib.apps.LingeredApp;
|
||||
import jdk.test.lib.process.OutputAnalyzer;
|
||||
import jdk.test.lib.process.ProcessTools;
|
||||
import jdk.test.lib.JDKToolLauncher;
|
||||
|
||||
public class CDSJMapClstats {
|
||||
|
||||
private static void runClstats(long lingeredAppPid) throws Exception {
|
||||
|
||||
JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("jhsdb");
|
||||
launcher.addToolArg("jmap");
|
||||
launcher.addToolArg("--clstats");
|
||||
launcher.addToolArg("--pid");
|
||||
launcher.addToolArg(Long.toString(lingeredAppPid));
|
||||
|
||||
ProcessBuilder processBuilder = new ProcessBuilder();
|
||||
processBuilder.command(launcher.getCommand());
|
||||
System.out.println(
|
||||
processBuilder.command().stream().collect(Collectors.joining(" ")));
|
||||
|
||||
OutputAnalyzer SAOutput = ProcessTools.executeProcess(processBuilder);
|
||||
System.out.println(SAOutput.getOutput());
|
||||
SAOutput.shouldHaveExitValue(0);
|
||||
SAOutput.shouldContain("BootClassLoader");
|
||||
}
|
||||
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
System.out.println("Starting CDSJMapClstats test");
|
||||
String sharedArchiveName = "ArchiveForCDSJMapClstats.jsa";
|
||||
LingeredApp theApp = null;
|
||||
|
||||
try {
|
||||
CDSOptions opts = (new CDSOptions()).setArchiveName(sharedArchiveName);
|
||||
CDSTestUtils.createArchiveAndCheck(opts);
|
||||
|
||||
List<String> vmArgs = Arrays.asList(
|
||||
"-XX:+UnlockDiagnosticVMOptions",
|
||||
"-XX:SharedArchiveFile=" + sharedArchiveName,
|
||||
"-Xshare:auto");
|
||||
theApp = LingeredApp.startApp(vmArgs);
|
||||
System.out.println("Started LingeredApp with pid " + theApp.getPid());
|
||||
runClstats(theApp.getPid());
|
||||
} catch (Exception ex) {
|
||||
throw new RuntimeException("Test ERROR " + ex, ex);
|
||||
} finally {
|
||||
LingeredApp.stopApp(theApp);
|
||||
}
|
||||
System.out.println("Test PASSED");
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user