提交 da3aa407 编写于 作者: D duke

Merge

......@@ -445,3 +445,4 @@ b803e6cff41e72a1e6d8782e1ef7c25a6e3e5ee3 jdk-10+19
d2982a786f53814367698e63efe6349c9128e1db jdk-9+180
b656dea9398ef601f7fc08d1a5157a560e0ccbe0 jdk-9+181
682e2a6df836f4731f92eb2ddcd467075047f6ea jdk-10+20
90cdfe56f1543267a8005e638bd1b44551fda189 jdk-10+21
......@@ -1046,7 +1046,7 @@ AC_DEFUN([FLAGS_SETUP_COMPILER_FLAGS_FOR_JDK_HELPER],
# Set some additional per-CPU defines.
if test "x$OPENJDK_$1_OS-$OPENJDK_$1_CPU" = xwindows-x86; then
$2JVM_CFLAGS="[$]$2JVM_CFLAGS -arch:IA32"
elif test "x$OPENJDK_$1_CPU" = xsparcv9; then
elif test "x$OPENJDK_$1_OS-$OPENJDK_$1_CPU" = xsolaris-sparcv9; then
$2JVM_CFLAGS="[$]$2JVM_CFLAGS -xarch=sparc"
elif test "x$OPENJDK_$1_CPU" = xppc64; then
if test "x$OPENJDK_$1_OS" = xlinux; then
......@@ -1358,7 +1358,7 @@ $2LDFLAGS_JDKLIB="${$2LDFLAGS_JDKLIB} ${$2JAVA_BASE_LDFLAGS}"
$2SOLARIS_LIBM_LIBS="/usr/lib/sparcv9/libm.so.1"
fi
$2JVM_LIBS="[$]$2JVM_LIBS -lsocket -lsched -ldl $SOLARIS_LIBM_LIBS -lCrun \
-lthread -ldoor -lc -ldemangle -lnsl -lkstat -lrt"
-lthread -ldoor -lc -ldemangle -lnsl -lrt"
elif test "x$OPENJDK_$1_OS" = xmacosx; then
$2JVM_LIBS="[$]$2JVM_LIBS -lm"
elif test "x$OPENJDK_$1_OS" = xaix; then
......
......@@ -5151,7 +5151,7 @@ VS_SDK_PLATFORM_NAME_2013=
#CUSTOM_AUTOCONF_INCLUDE
# Do not change or remove the following line, it is needed for consistency checks:
DATE_WHEN_GENERATED=1503411624
DATE_WHEN_GENERATED=1504187184
###############################################################################
#
......@@ -15719,6 +15719,12 @@ test -n "$target_alias" &&
VAR_CPU_BITS=32
VAR_CPU_ENDIAN=little
;;
alpha*)
VAR_CPU=alpha
VAR_CPU_ARCH=alpha
VAR_CPU_BITS=64
VAR_CPU_ENDIAN=little
;;
arm*)
VAR_CPU=arm
VAR_CPU_ARCH=arm
......@@ -15731,6 +15737,36 @@ test -n "$target_alias" &&
VAR_CPU_BITS=64
VAR_CPU_ENDIAN=little
;;
m68k)
VAR_CPU=m68k
VAR_CPU_ARCH=m68k
VAR_CPU_BITS=32
VAR_CPU_ENDIAN=big
;;
mips)
VAR_CPU=mips
VAR_CPU_ARCH=mips
VAR_CPU_BITS=32
VAR_CPU_ENDIAN=big
;;
mipsel)
VAR_CPU=mipsel
VAR_CPU_ARCH=mipsel
VAR_CPU_BITS=32
VAR_CPU_ENDIAN=little
;;
mips64)
VAR_CPU=mips64
VAR_CPU_ARCH=mips64
VAR_CPU_BITS=64
VAR_CPU_ENDIAN=big
;;
mips64el)
VAR_CPU=mips64el
VAR_CPU_ARCH=mips64el
VAR_CPU_BITS=64
VAR_CPU_ENDIAN=little
;;
powerpc)
VAR_CPU=ppc
VAR_CPU_ARCH=ppc
......@@ -15761,6 +15797,18 @@ test -n "$target_alias" &&
VAR_CPU_BITS=64
VAR_CPU_ENDIAN=big
;;
sh*eb)
VAR_CPU=sh
VAR_CPU_ARCH=sh
VAR_CPU_BITS=32
VAR_CPU_ENDIAN=big
;;
sh*)
VAR_CPU=sh
VAR_CPU_ARCH=sh
VAR_CPU_BITS=32
VAR_CPU_ENDIAN=little
;;
sparc)
VAR_CPU=sparc
VAR_CPU_ARCH=sparc
......@@ -15858,6 +15906,12 @@ $as_echo "$OPENJDK_BUILD_OS-$OPENJDK_BUILD_CPU" >&6; }
VAR_CPU_BITS=32
VAR_CPU_ENDIAN=little
;;
alpha*)
VAR_CPU=alpha
VAR_CPU_ARCH=alpha
VAR_CPU_BITS=64
VAR_CPU_ENDIAN=little
;;
arm*)
VAR_CPU=arm
VAR_CPU_ARCH=arm
......@@ -15870,6 +15924,36 @@ $as_echo "$OPENJDK_BUILD_OS-$OPENJDK_BUILD_CPU" >&6; }
VAR_CPU_BITS=64
VAR_CPU_ENDIAN=little
;;
m68k)
VAR_CPU=m68k
VAR_CPU_ARCH=m68k
VAR_CPU_BITS=32
VAR_CPU_ENDIAN=big
;;
mips)
VAR_CPU=mips
VAR_CPU_ARCH=mips
VAR_CPU_BITS=32
VAR_CPU_ENDIAN=big
;;
mipsel)
VAR_CPU=mipsel
VAR_CPU_ARCH=mipsel
VAR_CPU_BITS=32
VAR_CPU_ENDIAN=little
;;
mips64)
VAR_CPU=mips64
VAR_CPU_ARCH=mips64
VAR_CPU_BITS=64
VAR_CPU_ENDIAN=big
;;
mips64el)
VAR_CPU=mips64el
VAR_CPU_ARCH=mips64el
VAR_CPU_BITS=64
VAR_CPU_ENDIAN=little
;;
powerpc)
VAR_CPU=ppc
VAR_CPU_ARCH=ppc
......@@ -15900,6 +15984,18 @@ $as_echo "$OPENJDK_BUILD_OS-$OPENJDK_BUILD_CPU" >&6; }
VAR_CPU_BITS=64
VAR_CPU_ENDIAN=big
;;
sh*eb)
VAR_CPU=sh
VAR_CPU_ARCH=sh
VAR_CPU_BITS=32
VAR_CPU_ENDIAN=big
;;
sh*)
VAR_CPU=sh
VAR_CPU_ARCH=sh
VAR_CPU_BITS=32
VAR_CPU_ENDIAN=little
;;
sparc)
VAR_CPU=sparc
VAR_CPU_ARCH=sparc
......@@ -16045,6 +16141,12 @@ $as_echo "$COMPILE_TYPE" >&6; }
elif test "x$OPENJDK_TARGET_OS" != xmacosx && test "x$OPENJDK_TARGET_CPU" = xx86_64; then
# On all platforms except MacOSX replace x86_64 with amd64.
OPENJDK_TARGET_CPU_LEGACY="amd64"
elif test "x$OPENJDK_TARGET_CPU" = xalpha; then
# Avoid name collisions with variables named alpha
OPENJDK_TARGET_CPU_LEGACY="_alpha_"
elif test "x$OPENJDK_TARGET_CPU" = xsh; then
# Avoid name collisions with variables named sh
OPENJDK_TARGET_CPU_LEGACY="_sh_"
fi
......@@ -16197,6 +16299,12 @@ $as_echo "$COMPILE_TYPE" >&6; }
elif test "x$OPENJDK_BUILD_OS" != xmacosx && test "x$OPENJDK_BUILD_CPU" = xx86_64; then
# On all platforms except MacOSX replace x86_64 with amd64.
OPENJDK_BUILD_CPU_LEGACY="amd64"
elif test "x$OPENJDK_BUILD_CPU" = xalpha; then
# Avoid name collisions with variables named alpha
OPENJDK_BUILD_CPU_LEGACY="_alpha_"
elif test "x$OPENJDK_BUILD_CPU" = xsh; then
# Avoid name collisions with variables named sh
OPENJDK_BUILD_CPU_LEGACY="_sh_"
fi
......@@ -51563,7 +51671,7 @@ $as_echo "$as_me: GCC >= 6 detected; adding ${NO_DELETE_NULL_POINTER_CHECKS_CFLA
# Set some additional per-CPU defines.
if test "x$OPENJDK_TARGET_OS-$OPENJDK_TARGET_CPU" = xwindows-x86; then
JVM_CFLAGS="$JVM_CFLAGS -arch:IA32"
elif test "x$OPENJDK_TARGET_CPU" = xsparcv9; then
elif test "x$OPENJDK_TARGET_OS-$OPENJDK_TARGET_CPU" = xsolaris-sparcv9; then
JVM_CFLAGS="$JVM_CFLAGS -xarch=sparc"
elif test "x$OPENJDK_TARGET_CPU" = xppc64; then
if test "x$OPENJDK_TARGET_OS" = xlinux; then
......@@ -51968,7 +52076,7 @@ LDFLAGS_JDKLIB="${LDFLAGS_JDKLIB} ${JAVA_BASE_LDFLAGS}"
SOLARIS_LIBM_LIBS="/usr/lib/sparcv9/libm.so.1"
fi
JVM_LIBS="$JVM_LIBS -lsocket -lsched -ldl $SOLARIS_LIBM_LIBS -lCrun \
-lthread -ldoor -lc -ldemangle -lnsl -lkstat -lrt"
-lthread -ldoor -lc -ldemangle -lnsl -lrt"
elif test "x$OPENJDK_TARGET_OS" = xmacosx; then
JVM_LIBS="$JVM_LIBS -lm"
elif test "x$OPENJDK_TARGET_OS" = xaix; then
......@@ -52442,7 +52550,7 @@ $as_echo "$as_me: GCC >= 6 detected; adding ${NO_DELETE_NULL_POINTER_CHECKS_CFLA
# Set some additional per-CPU defines.
if test "x$OPENJDK_BUILD_OS-$OPENJDK_BUILD_CPU" = xwindows-x86; then
OPENJDK_BUILD_JVM_CFLAGS="$OPENJDK_BUILD_JVM_CFLAGS -arch:IA32"
elif test "x$OPENJDK_BUILD_CPU" = xsparcv9; then
elif test "x$OPENJDK_BUILD_OS-$OPENJDK_BUILD_CPU" = xsolaris-sparcv9; then
OPENJDK_BUILD_JVM_CFLAGS="$OPENJDK_BUILD_JVM_CFLAGS -xarch=sparc"
elif test "x$OPENJDK_BUILD_CPU" = xppc64; then
if test "x$OPENJDK_BUILD_OS" = xlinux; then
......@@ -52847,7 +52955,7 @@ OPENJDK_BUILD_LDFLAGS_JDKLIB="${OPENJDK_BUILD_LDFLAGS_JDKLIB} ${OPENJDK_BUILD_JA
OPENJDK_BUILD_SOLARIS_LIBM_LIBS="/usr/lib/sparcv9/libm.so.1"
fi
OPENJDK_BUILD_JVM_LIBS="$OPENJDK_BUILD_JVM_LIBS -lsocket -lsched -ldl $SOLARIS_LIBM_LIBS -lCrun \
-lthread -ldoor -lc -ldemangle -lnsl -lkstat -lrt"
-lthread -ldoor -lc -ldemangle -lnsl -lrt"
elif test "x$OPENJDK_BUILD_OS" = xmacosx; then
OPENJDK_BUILD_JVM_LIBS="$OPENJDK_BUILD_JVM_LIBS -lm"
elif test "x$OPENJDK_BUILD_OS" = xaix; then
......@@ -42,6 +42,12 @@ AC_DEFUN([PLATFORM_EXTRACT_VARS_FROM_CPU],
VAR_CPU_BITS=32
VAR_CPU_ENDIAN=little
;;
alpha*)
VAR_CPU=alpha
VAR_CPU_ARCH=alpha
VAR_CPU_BITS=64
VAR_CPU_ENDIAN=little
;;
arm*)
VAR_CPU=arm
VAR_CPU_ARCH=arm
......@@ -54,6 +60,36 @@ AC_DEFUN([PLATFORM_EXTRACT_VARS_FROM_CPU],
VAR_CPU_BITS=64
VAR_CPU_ENDIAN=little
;;
m68k)
VAR_CPU=m68k
VAR_CPU_ARCH=m68k
VAR_CPU_BITS=32
VAR_CPU_ENDIAN=big
;;
mips)
VAR_CPU=mips
VAR_CPU_ARCH=mips
VAR_CPU_BITS=32
VAR_CPU_ENDIAN=big
;;
mipsel)
VAR_CPU=mipsel
VAR_CPU_ARCH=mipsel
VAR_CPU_BITS=32
VAR_CPU_ENDIAN=little
;;
mips64)
VAR_CPU=mips64
VAR_CPU_ARCH=mips64
VAR_CPU_BITS=64
VAR_CPU_ENDIAN=big
;;
mips64el)
VAR_CPU=mips64el
VAR_CPU_ARCH=mips64el
VAR_CPU_BITS=64
VAR_CPU_ENDIAN=little
;;
powerpc)
VAR_CPU=ppc
VAR_CPU_ARCH=ppc
......@@ -84,6 +120,18 @@ AC_DEFUN([PLATFORM_EXTRACT_VARS_FROM_CPU],
VAR_CPU_BITS=64
VAR_CPU_ENDIAN=big
;;
sh*eb)
VAR_CPU=sh
VAR_CPU_ARCH=sh
VAR_CPU_BITS=32
VAR_CPU_ENDIAN=big
;;
sh*)
VAR_CPU=sh
VAR_CPU_ARCH=sh
VAR_CPU_BITS=32
VAR_CPU_ENDIAN=little
;;
sparc)
VAR_CPU=sparc
VAR_CPU_ARCH=sparc
......@@ -289,6 +337,12 @@ AC_DEFUN([PLATFORM_SETUP_LEGACY_VARS_HELPER],
elif test "x$OPENJDK_$1_OS" != xmacosx && test "x$OPENJDK_$1_CPU" = xx86_64; then
# On all platforms except MacOSX replace x86_64 with amd64.
OPENJDK_$1_CPU_LEGACY="amd64"
elif test "x$OPENJDK_$1_CPU" = xalpha; then
# Avoid name collisions with variables named alpha
OPENJDK_$1_CPU_LEGACY="_alpha_"
elif test "x$OPENJDK_$1_CPU" = xsh; then
# Avoid name collisions with variables named sh
OPENJDK_$1_CPU_LEGACY="_sh_"
fi
AC_SUBST(OPENJDK_$1_CPU_LEGACY)
......
......@@ -200,7 +200,7 @@ var getJibProfiles = function (input) {
data.configuration_make_arg = "CONF_NAME=";
// Exclude list to use when Jib creates a source bundle
data.src_bundle_excludes = "./build webrev .hg */.hg */*/.hg */*/*/.hg";
data.src_bundle_excludes = "./build webrev* */webrev* */*/webrev* */*/*/webrev* .hg */.hg */*/.hg */*/*/.hg";
// Include list to use when creating a minimal jib source bundle which
// contains just the jib configuration files.
data.conf_bundle_includes = "*/conf/jib-profiles.* common/autoconf/version-numbers"
......
/*
* Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2017, 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
......@@ -47,9 +47,9 @@ package jdk.test.lib.hprof.model;
public class HackJavaValue extends JavaValue {
private String value;
private int size;
private long size;
public HackJavaValue(String value, int size) {
public HackJavaValue(String value, long size) {
this.value = value;
this.size = size;
}
......@@ -58,7 +58,8 @@ public class HackJavaValue extends JavaValue {
return value;
}
public int getSize() {
@Override
public long getSize() {
return size;
}
......
/*
* Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2017, 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
......@@ -403,7 +403,8 @@ public class JavaClass extends JavaHeapObject {
/**
* @return the size of this object
*/
public int getSize() {
@Override
public long getSize() {
JavaClass cl = mySnapshot.getJavaLangClass();
if (cl == null) {
return 0;
......
/*
* Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2017, 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
......@@ -64,7 +64,7 @@ public abstract class JavaHeapObject extends JavaThing {
private int referersLen = 0; // -1 when resolved
public abstract JavaClass getClazz();
public abstract int getSize();
public abstract long getSize();
public abstract long getId();
/**
......
/*
* Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2017, 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
......@@ -47,7 +47,8 @@ public abstract class JavaLazyReadObject extends JavaHeapObject {
this.offset = offset;
}
public final int getSize() {
@Override
public final long getSize() {
return getValueLength() + getClazz().getMinimumObjectSize();
}
......@@ -55,8 +56,16 @@ public abstract class JavaLazyReadObject extends JavaHeapObject {
return offset;
}
protected ReadBuffer buf() {
return getClazz().getReadBuffer();
}
protected int idSize() {
return getClazz().getIdentifierSize();
}
// return the length of the data for this object
protected final int getValueLength() {
protected final long getValueLength() {
try {
return readValueLength();
} catch (IOException exp) {
......@@ -67,25 +76,23 @@ public abstract class JavaLazyReadObject extends JavaHeapObject {
}
// get this object's content as byte array
protected final byte[] getValue() {
protected final JavaThing[] getValue() {
try {
return readValue();
} catch (IOException exp) {
System.err.println("lazy read failed at offset " + offset);
exp.printStackTrace();
return Snapshot.EMPTY_BYTE_ARRAY;
return Snapshot.EMPTY_JAVATHING_ARRAY;
}
}
// get ID of this object
public final long getId() {
try {
ReadBuffer buf = getClazz().getReadBuffer();
int idSize = getClazz().getIdentifierSize();
if (idSize == 4) {
return ((long)buf.getInt(offset)) & Snapshot.SMALL_ID_MASK;
if (idSize() == 4) {
return ((long)buf().getInt(offset)) & Snapshot.SMALL_ID_MASK;
} else {
return buf.getLong(offset);
return buf().getLong(offset);
}
} catch (IOException exp) {
System.err.println("lazy read failed at offset " + offset);
......@@ -94,8 +101,8 @@ public abstract class JavaLazyReadObject extends JavaHeapObject {
}
}
protected abstract int readValueLength() throws IOException;
protected abstract byte[] readValue() throws IOException;
protected abstract long readValueLength() throws IOException;
protected abstract JavaThing[] readValue() throws IOException;
// make Integer or Long for given object ID
protected static Number makeId(long id) {
......@@ -116,61 +123,46 @@ public abstract class JavaLazyReadObject extends JavaHeapObject {
}
// read object ID from given index from given byte array
protected final long objectIdAt(int index, byte[] data) {
int idSize = getClazz().getIdentifierSize();
if (idSize == 4) {
return ((long)intAt(index, data)) & Snapshot.SMALL_ID_MASK;
protected final long objectIdAt(long offset) throws IOException {
if (idSize() == 4) {
return ((long)intAt(offset)) & Snapshot.SMALL_ID_MASK;
} else {
return longAt(index, data);
return longAt(offset);
}
}
// utility methods to read primitive types from byte array
protected static byte byteAt(int index, byte[] value) {
return value[index];
protected byte byteAt(long offset) throws IOException {
return buf().getByte(offset);
}
protected static boolean booleanAt(int index, byte[] value) {
return (value[index] & 0xff) == 0? false: true;
protected boolean booleanAt(long offset) throws IOException {
return byteAt(offset) == 0 ? false : true;
}
protected static char charAt(int index, byte[] value) {
int b1 = ((int) value[index++] & 0xff);
int b2 = ((int) value[index++] & 0xff);
return (char) ((b1 << 8) + b2);
protected char charAt(long offset) throws IOException {
return buf().getChar(offset);
}
protected static short shortAt(int index, byte[] value) {
int b1 = ((int) value[index++] & 0xff);
int b2 = ((int) value[index++] & 0xff);
return (short) ((b1 << 8) + b2);
protected short shortAt(long offset) throws IOException {
return buf().getShort(offset);
}
protected static int intAt(int index, byte[] value) {
int b1 = ((int) value[index++] & 0xff);
int b2 = ((int) value[index++] & 0xff);
int b3 = ((int) value[index++] & 0xff);
int b4 = ((int) value[index++] & 0xff);
return ((b1 << 24) + (b2 << 16) + (b3 << 8) + b4);
protected int intAt(long offset) throws IOException {
return buf().getInt(offset);
}
protected static long longAt(int index, byte[] value) {
long val = 0;
for (int j = 0; j < 8; j++) {
val = val << 8;
int b = ((int)value[index++]) & 0xff;
val |= b;
}
return val;
protected long longAt(long offset) throws IOException {
return buf().getLong(offset);
}
protected static float floatAt(int index, byte[] value) {
int val = intAt(index, value);
protected float floatAt(long offset) throws IOException {
int val = intAt(offset);
return Float.intBitsToFloat(val);
}
protected static double doubleAt(int index, byte[] value) {
long val = longAt(index, value);
protected double doubleAt(long offset) throws IOException {
long val = longAt(offset);
return Double.longBitsToDouble(val);
}
}
/*
* Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2017, 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
......@@ -86,7 +86,7 @@ public class JavaObject extends JavaLazyReadObject {
// while resolving, parse fields in verbose mode.
// but, getFields calls parseFields in non-verbose mode
// to avoid printing warnings repeatedly.
parseFields(getValue(), true);
parseFields(true);
cl.addInstance(this);
super.resolve(snapshot);
......@@ -114,7 +114,7 @@ public class JavaObject extends JavaLazyReadObject {
public JavaThing[] getFields() {
// pass false to verbose mode so that dereference
// warnings are not printed.
return parseFields(getValue(), false);
return parseFields(false);
}
// returns the value of field of given name
......@@ -212,35 +212,27 @@ public class JavaObject extends JavaLazyReadObject {
* data length (int)
* byte[length]
*/
protected final int readValueLength() throws IOException {
JavaClass cl = getClazz();
int idSize = cl.getIdentifierSize();
long lengthOffset = getOffset() + 2*idSize + 4;
return cl.getReadBuffer().getInt(lengthOffset);
@Override
protected final long readValueLength() throws IOException {
long lengthOffset = getOffset() + 2 * idSize() + 4;
return buf().getInt(lengthOffset);
}
protected final byte[] readValue() throws IOException {
JavaClass cl = getClazz();
int idSize = cl.getIdentifierSize();
ReadBuffer buf = cl.getReadBuffer();
long offset = getOffset() + 2*idSize + 4;
int length = buf.getInt(offset);
if (length == 0) {
return Snapshot.EMPTY_BYTE_ARRAY;
} else {
byte[] res = new byte[length];
buf.get(offset + 4, res);
return res;
}
@Override
protected final JavaThing[] readValue() throws IOException {
return parseFields(false);
}
private long dataStartOffset() {
return getOffset() + idSize() + 4 + idSize() + 4;
}
private JavaThing[] parseFields(byte[] data, boolean verbose) {
private JavaThing[] parseFields(boolean verbose) {
JavaClass cl = getClazz();
int target = cl.getNumFieldsForInstance();
JavaField[] fields = cl.getFields();
JavaThing[] fieldValues = new JavaThing[target];
Snapshot snapshot = cl.getSnapshot();
int idSize = snapshot.getIdentifierSize();
int fieldNo = 0;
// In the dump file, the fields are stored in this order:
// fields of most derived class (immediate class) are stored
......@@ -254,7 +246,7 @@ public class JavaObject extends JavaLazyReadObject {
// starts with the top of the inheritance hierarchy and works down.
target -= fields.length;
JavaClass currClass = cl;
int index = 0;
long offset = dataStartOffset();
for (int i = 0; i < fieldValues.length; i++, fieldNo++) {
while (fieldNo >= fields.length) {
currClass = currClass.getSuperclass();
......@@ -264,65 +256,72 @@ public class JavaObject extends JavaLazyReadObject {
}
JavaField f = fields[fieldNo];
char sig = f.getSignature().charAt(0);
switch (sig) {
case 'L':
case '[': {
long id = objectIdAt(index, data);
index += idSize;
JavaObjectRef ref = new JavaObjectRef(id);
fieldValues[target+fieldNo] = ref.dereference(snapshot, f, verbose);
break;
}
case 'Z': {
byte value = byteAt(index, data);
index++;
fieldValues[target+fieldNo] = new JavaBoolean(value != 0);
break;
}
case 'B': {
byte value = byteAt(index, data);
index++;
fieldValues[target+fieldNo] = new JavaByte(value);
break;
}
case 'S': {
short value = shortAt(index, data);
index += 2;
fieldValues[target+fieldNo] = new JavaShort(value);
break;
}
case 'C': {
char value = charAt(index, data);
index += 2;
fieldValues[target+fieldNo] = new JavaChar(value);
break;
}
case 'I': {
int value = intAt(index, data);
index += 4;
fieldValues[target+fieldNo] = new JavaInt(value);
break;
}
case 'J': {
long value = longAt(index, data);
index += 8;
fieldValues[target+fieldNo] = new JavaLong(value);
break;
}
case 'F': {
float value = floatAt(index, data);
index += 4;
fieldValues[target+fieldNo] = new JavaFloat(value);
break;
}
case 'D': {
double value = doubleAt(index, data);
index += 8;
fieldValues[target+fieldNo] = new JavaDouble(value);
break;
try {
switch (sig) {
case 'L':
case '[': {
long id = objectIdAt(offset);
offset += idSize();
JavaObjectRef ref = new JavaObjectRef(id);
fieldValues[target+fieldNo] = ref.dereference(snapshot, f, verbose);
break;
}
case 'Z': {
byte value = byteAt(offset);
offset++;
fieldValues[target+fieldNo] = new JavaBoolean(value != 0);
break;
}
case 'B': {
byte value = byteAt(offset);
offset++;
fieldValues[target+fieldNo] = new JavaByte(value);
break;
}
case 'S': {
short value = shortAt(offset);
offset += 2;
fieldValues[target+fieldNo] = new JavaShort(value);
break;
}
case 'C': {
char value = charAt(offset);
offset += 2;
fieldValues[target+fieldNo] = new JavaChar(value);
break;
}
case 'I': {
int value = intAt(offset);
offset += 4;
fieldValues[target+fieldNo] = new JavaInt(value);
break;
}
case 'J': {
long value = longAt(offset);
offset += 8;
fieldValues[target+fieldNo] = new JavaLong(value);
break;
}
case 'F': {
float value = floatAt(offset);
offset += 4;
fieldValues[target+fieldNo] = new JavaFloat(value);
break;
}
case 'D': {
double value = doubleAt(offset);
offset += 8;
fieldValues[target+fieldNo] = new JavaDouble(value);
break;
}
default:
throw new RuntimeException("invalid signature: " + sig);
}
default:
throw new RuntimeException("invalid signature: " + sig);
} catch (IOException exp) {
System.err.println("lazy read failed at offset " + offset);
exp.printStackTrace();
return Snapshot.EMPTY_JAVATHING_ARRAY;
}
}
return fieldValues;
......
/*
* Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2017, 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
......@@ -87,18 +87,7 @@ public class JavaObjectArray extends JavaLazyReadObject {
}
public JavaThing[] getElements() {
Snapshot snapshot = getClazz().getSnapshot();
byte[] data = getValue();
final int idSize = snapshot.getIdentifierSize();
final int numElements = data.length / idSize;
JavaThing[] elements = new JavaThing[numElements];
int index = 0;
for (int i = 0; i < elements.length; i++) {
long id = objectIdAt(index, data);
index += idSize;
elements[i] = snapshot.findThing(id);
}
return elements;
return getValue();
}
public int compareTo(JavaThing other) {
......@@ -109,7 +98,7 @@ public class JavaObjectArray extends JavaLazyReadObject {
}
public int getLength() {
return getValueLength() / getClazz().getIdentifierSize();
return (int)(getValueLength() / idSize());
}
public void visitReferencedObjects(JavaHeapObjectVisitor v) {
......@@ -146,27 +135,31 @@ public class JavaObjectArray extends JavaLazyReadObject {
* array class ID
* array element IDs
*/
protected final int readValueLength() throws IOException {
JavaClass cl = getClazz();
ReadBuffer buf = cl.getReadBuffer();
int idSize = cl.getIdentifierSize();
long offset = getOffset() + idSize + 4;
int len = buf.getInt(offset);
return len * cl.getIdentifierSize();
@Override
protected final long readValueLength() throws IOException {
long offset = getOffset() + idSize() + 4;
// length of the array in elements
long len = buf().getInt(offset);
// byte length of array
return len * idSize();
}
private long dataStartOffset() {
return getOffset() + idSize() + 4 + 4 + idSize();
}
protected final byte[] readValue() throws IOException {
JavaClass cl = getClazz();
ReadBuffer buf = cl.getReadBuffer();
int idSize = cl.getIdentifierSize();
long offset = getOffset() + idSize + 4;
int len = buf.getInt(offset);
if (len == 0) {
return Snapshot.EMPTY_BYTE_ARRAY;
} else {
byte[] res = new byte[len * idSize];
buf.get(offset + 4 + idSize, res);
return res;
}
@Override
protected final JavaThing[] readValue() throws IOException {
Snapshot snapshot = getClazz().getSnapshot();
int len = getLength();
long offset = dataStartOffset();
JavaThing[] res = new JavaThing[len];
for (int i = 0; i < len; i++) {
long id = objectIdAt(offset);
res[i] = snapshot.findThing(id);
offset += idSize();
}
return res;
}
}
/*
* Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2017, 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
......@@ -87,7 +87,8 @@ public class JavaObjectRef extends JavaThing {
return result;
}
public int getSize() {
@Override
public long getSize() {
return 0;
}
......
/*
* Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2017, 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
......@@ -81,7 +81,7 @@ public abstract class JavaThing {
/**
* @return the size of this object, in bytes, including VM overhead
*/
abstract public int getSize();
abstract public long getSize();
/**
* @return a human-readable string representation of this thing
......
/*
* Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2017, 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
......@@ -52,7 +52,8 @@ public abstract class JavaValue extends JavaThing {
abstract public String toString();
public int getSize() {
@Override
public long getSize() {
// The size of a value is already accounted for in the class
// that has the data member.
return 0;
......
/*
* Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2017, 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
......@@ -91,38 +91,92 @@ public class JavaValueArray extends JavaLazyReadObject
*
* object ID
* stack trace serial number (int)
* length of the instance data (int)
* number of elements (int)
* element type (byte)
* array data
*/
protected final int readValueLength() throws IOException {
JavaClass cl = getClazz();
ReadBuffer buf = cl.getReadBuffer();
int idSize = cl.getIdentifierSize();
long offset = getOffset() + idSize + 4;
// length of the array
int len = buf.getInt(offset);
// typecode of array element type
byte type = buf.getByte(offset + 4);
return len * elementSize(type);
@Override
protected final long readValueLength() throws IOException {
long offset = getOffset() + idSize() + 4;
// length of the array in elements
long len = buf().getInt(offset);
// byte length of array
return len * elementSize(getElementType());
}
protected final byte[] readValue() throws IOException {
JavaClass cl = getClazz();
ReadBuffer buf = cl.getReadBuffer();
int idSize = cl.getIdentifierSize();
long offset = getOffset() + idSize + 4;
// length of the array
int length = buf.getInt(offset);
// typecode of array element type
byte type = buf.getByte(offset + 4);
if (length == 0) {
return Snapshot.EMPTY_BYTE_ARRAY;
} else {
length *= elementSize(type);
byte[] res = new byte[length];
buf.get(offset + 5, res);
return res;
private long dataStartOffset() {
return getOffset() + idSize() + 4 + 4 + 1;
}
@Override
protected final JavaThing[] readValue() throws IOException {
int len = getLength();
long offset = dataStartOffset();
JavaThing[] res = new JavaThing[len];
synchronized (buf()) {
switch (getElementType()) {
case 'Z': {
for (int i = 0; i < len; i++) {
res[i] = new JavaBoolean(booleanAt(offset));
offset += 1;
}
return res;
}
case 'B': {
for (int i = 0; i < len; i++) {
res[i] = new JavaByte(byteAt(offset));
offset += 1;
}
return res;
}
case 'C': {
for (int i = 0; i < len; i++) {
res[i] = new JavaChar(charAt(offset));
offset += 2;
}
return res;
}
case 'S': {
for (int i = 0; i < len; i++) {
res[i] = new JavaShort(shortAt(offset));
offset += 2;
}
return res;
}
case 'I': {
for (int i = 0; i < len; i++) {
res[i] = new JavaInt(intAt(offset));
offset += 4;
}
return res;
}
case 'J': {
for (int i = 0; i < len; i++) {
res[i] = new JavaLong(longAt(offset));
offset += 8;
}
return res;
}
case 'F': {
for (int i = 0; i < len; i++) {
res[i] = new JavaFloat(floatAt(offset));
offset += 4;
}
return res;
}
case 'D': {
for (int i = 0; i < len; i++) {
res[i] = new JavaDouble(doubleAt(offset));
offset += 8;
}
return res;
}
default: {
throw new RuntimeException("unknown primitive type?");
}
}
}
}
......@@ -197,83 +251,11 @@ public class JavaValueArray extends JavaLazyReadObject
}
data |= (divider << LENGTH_DIVIDER_SHIFT);
}
return (getValueLength() / divider);
return (int)(getValueLength() / divider);
}
public Object getElements() {
final int len = getLength();
final byte et = getElementType();
byte[] data = getValue();
int index = 0;
switch (et) {
case 'Z': {
boolean[] res = new boolean[len];
for (int i = 0; i < len; i++) {
res[i] = booleanAt(index, data);
index++;
}
return res;
}
case 'B': {
byte[] res = new byte[len];
for (int i = 0; i < len; i++) {
res[i] = byteAt(index, data);
index++;
}
return res;
}
case 'C': {
char[] res = new char[len];
for (int i = 0; i < len; i++) {
res[i] = charAt(index, data);
index += 2;
}
return res;
}
case 'S': {
short[] res = new short[len];
for (int i = 0; i < len; i++) {
res[i] = shortAt(index, data);
index += 2;
}
return res;
}
case 'I': {
int[] res = new int[len];
for (int i = 0; i < len; i++) {
res[i] = intAt(index, data);
index += 4;
}
return res;
}
case 'J': {
long[] res = new long[len];
for (int i = 0; i < len; i++) {
res[i] = longAt(index, data);
index += 8;
}
return res;
}
case 'F': {
float[] res = new float[len];
for (int i = 0; i < len; i++) {
res[i] = floatAt(index, data);
index += 4;
}
return res;
}
case 'D': {
double[] res = new double[len];
for (int i = 0; i < len; i++) {
res[i] = doubleAt(index, data);
index += 8;
}
return res;
}
default: {
throw new RuntimeException("unknown primitive type?");
}
}
public JavaThing[] getElements() {
return getValue();
}
public byte getElementType() {
......@@ -292,54 +274,6 @@ public class JavaValueArray extends JavaLazyReadObject
}
}
public boolean getBooleanAt(int index) {
checkIndex(index);
requireType('Z');
return booleanAt(index, getValue());
}
public byte getByteAt(int index) {
checkIndex(index);
requireType('B');
return byteAt(index, getValue());
}
public char getCharAt(int index) {
checkIndex(index);
requireType('C');
return charAt(index << 1, getValue());
}
public short getShortAt(int index) {
checkIndex(index);
requireType('S');
return shortAt(index << 1, getValue());
}
public int getIntAt(int index) {
checkIndex(index);
requireType('I');
return intAt(index << 2, getValue());
}
public long getLongAt(int index) {
checkIndex(index);
requireType('J');
return longAt(index << 3, getValue());
}
public float getFloatAt(int index) {
checkIndex(index);
requireType('F');
return floatAt(index << 2, getValue());
}
public double getDoubleAt(int index) {
checkIndex(index);
requireType('D');
return doubleAt(index << 3, getValue());
}
public String valueString() {
return valueString(true);
}
......@@ -347,15 +281,12 @@ public class JavaValueArray extends JavaLazyReadObject
public String valueString(boolean bigLimit) {
// Char arrays deserve special treatment
StringBuilder result;
byte[] value = getValue();
int max = value.length;
JavaThing[] things = getValue();
byte elementSignature = getElementType();
if (elementSignature == 'C') {
result = new StringBuilder();
for (int i = 0; i < value.length; ) {
char val = charAt(i, value);
result.append(val);
i += 2;
for (int i = 0; i < things.length; i++) {
result.append(things[i]);
}
} else {
int limit = 8;
......@@ -363,61 +294,52 @@ public class JavaValueArray extends JavaLazyReadObject
limit = 1000;
}
result = new StringBuilder("{");
int num = 0;
for (int i = 0; i < value.length; ) {
if (num > 0) {
for (int i = 0; i < things.length; i++) {
if (i > 0) {
result.append(", ");
}
if (num >= limit) {
if (i >= limit) {
result.append("... ");
break;
}
num++;
switch (elementSignature) {
case 'Z': {
boolean val = booleanAt(i, value);
boolean val = ((JavaBoolean)things[i]).value;
if (val) {
result.append("true");
} else {
result.append("false");
}
i++;
break;
}
case 'B': {
int val = 0xFF & byteAt(i, value);
byte val = ((JavaByte)things[i]).value;
result.append("0x").append(Integer.toString(val, 16));
i++;
break;
}
case 'S': {
short val = shortAt(i, value);
i += 2;
short val = ((JavaShort)things[i]).value;
result.append(val);
break;
}
case 'I': {
int val = intAt(i, value);
i += 4;
int val = ((JavaInt)things[i]).value;
result.append(val);
break;
}
case 'J': { // long
long val = longAt(i, value);
long val = ((JavaLong)things[i]).value;
result.append(val);
i += 8;
break;
}
case 'F': {
float val = floatAt(i, value);
float val = ((JavaFloat)things[i]).value;
result.append(val);
i += 4;
break;
}
case 'D': { // double
double val = doubleAt(i, value);
double val = ((JavaDouble)things[i]).value;
result.append(val);
i += 8;
break;
}
default: {
......@@ -429,5 +351,4 @@ public class JavaValueArray extends JavaLazyReadObject
}
return result.toString();
}
}
/*
* Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2017, 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
......@@ -93,9 +93,9 @@ public class ReachableObjects {
public int compare(Object lhs, Object rhs) {
JavaThing left = (JavaThing) lhs;
JavaThing right = (JavaThing) rhs;
int diff = right.getSize() - left.getSize();
long diff = right.getSize() - left.getSize();
if (diff != 0) {
return diff;
return Long.signum(diff);
}
return left.compareTo(right);
}
......
/*
* Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2017, 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
......@@ -52,7 +52,7 @@ import jdk.test.lib.hprof.util.Misc;
public class Snapshot implements AutoCloseable {
public static final long SMALL_ID_MASK = 0x0FFFFFFFFL;
public static final byte[] EMPTY_BYTE_ARRAY = new byte[0];
public static final JavaThing[] EMPTY_JAVATHING_ARRAY = new JavaThing[0];
private static final JavaField[] EMPTY_FIELD_ARRAY = new JavaField[0];
private static final JavaStatic[] EMPTY_STATIC_ARRAY = new JavaStatic[0];
......
/*
* Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2017, 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
......@@ -57,26 +57,31 @@ class FileReadBuffer implements ReadBuffer {
file.read(buf);
}
@Override
public synchronized char getChar(long pos) throws IOException {
seek(pos);
return file.readChar();
}
@Override
public synchronized byte getByte(long pos) throws IOException {
seek(pos);
return (byte) file.read();
}
@Override
public synchronized short getShort(long pos) throws IOException {
seek(pos);
return file.readShort();
}
@Override
public synchronized int getInt(long pos) throws IOException {
seek(pos);
return file.readInt();
}
@Override
public synchronized long getLong(long pos) throws IOException {
seek(pos);
return file.readLong();
......
/*
* Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2017, 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
......@@ -98,31 +98,31 @@ class MappedReadBuffer implements ReadBuffer {
buf.position((int)pos);
}
public synchronized void get(long pos, byte[] res) throws IOException {
seek(pos);
buf.get(res);
}
@Override
public synchronized char getChar(long pos) throws IOException {
seek(pos);
return buf.getChar();
}
@Override
public synchronized byte getByte(long pos) throws IOException {
seek(pos);
return buf.get();
}
@Override
public synchronized short getShort(long pos) throws IOException {
seek(pos);
return buf.getShort();
}
@Override
public synchronized int getInt(long pos) throws IOException {
seek(pos);
return buf.getInt();
}
@Override
public synchronized long getLong(long pos) throws IOException {
seek(pos);
return buf.getLong();
......
/*
* Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2017, 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
......@@ -40,9 +40,6 @@ import java.io.IOException;
* @author A. Sundararajan
*/
public interface ReadBuffer extends AutoCloseable {
// read methods - only byte array and int primitive types.
// read position has to be specified always.
public void get(long pos, byte[] buf) throws IOException;
public char getChar(long pos) throws IOException;
public byte getByte(long pos) throws IOException;
public short getShort(long pos) throws IOException;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册