Mon, 17 Feb 2014 09:51:37 +0100
8033440: jmap reports unexpected used/free size of concurrent mark-sweep generation
Summary: SA used the wrong type for the indexedFreeList in CompactibleFreeListSpace.
Reviewed-by: coleenp, dsamersoff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/agent/src/share/classes/sun/jvm/hotspot/memory/AdaptiveFreeList.java Mon Feb 17 09:51:37 2014 +0100 1.3 @@ -0,0 +1,77 @@ 1.4 +/* 1.5 + * @(#)AdaptiveFreeList.java 1.6 + * 1.7 + * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. 1.8 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.9 + * 1.10 + * This code is free software; you can redistribute it and/or modify it 1.11 + * under the terms of the GNU General Public License version 2 only, as 1.12 + * published by the Free Software Foundation. 1.13 + * 1.14 + * This code is distributed in the hope that it will be useful, but WITHOUT 1.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1.17 + * version 2 for more details (a copy is included in the LICENSE file that 1.18 + * accompanied this code). 1.19 + * 1.20 + * You should have received a copy of the GNU General Public License version 1.21 + * 2 along with this work; if not, write to the Free Software Foundation, 1.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1.23 + * 1.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 1.25 + * or visit www.oracle.com if you need additional information or have any 1.26 + * questions. 1.27 + * 1.28 + */ 1.29 + 1.30 +package sun.jvm.hotspot.memory; 1.31 + 1.32 +import java.util.Observable; 1.33 +import java.util.Observer; 1.34 + 1.35 +import sun.jvm.hotspot.debugger.Address; 1.36 +import sun.jvm.hotspot.runtime.VM; 1.37 +import sun.jvm.hotspot.runtime.VMObject; 1.38 +import sun.jvm.hotspot.types.CIntegerField; 1.39 +import sun.jvm.hotspot.types.Type; 1.40 +import sun.jvm.hotspot.types.TypeDataBase; 1.41 + 1.42 +public class AdaptiveFreeList extends VMObject { 1.43 + static { 1.44 + VM.registerVMInitializedObserver(new Observer() { 1.45 + public void update(Observable o, Object data) { 1.46 + initialize(VM.getVM().getTypeDataBase()); 1.47 + } 1.48 + }); 1.49 + } 1.50 + 1.51 + private static synchronized void initialize(TypeDataBase db) { 1.52 + Type type = db.lookupType("AdaptiveFreeList<FreeChunk>"); 1.53 + sizeField = type.getCIntegerField("_size"); 1.54 + countField = type.getCIntegerField("_count"); 1.55 + headerSize = type.getSize(); 1.56 + } 1.57 + 1.58 + // Fields 1.59 + private static CIntegerField sizeField; 1.60 + private static CIntegerField countField; 1.61 + private static long headerSize; 1.62 + 1.63 + //Constructor 1.64 + public AdaptiveFreeList(Address address) { 1.65 + super(address); 1.66 + } 1.67 + 1.68 + // Accessors 1.69 + public long size() { 1.70 + return sizeField.getValue(addr); 1.71 + } 1.72 + 1.73 + public long count() { 1.74 + return countField.getValue(addr); 1.75 + } 1.76 + 1.77 + public static long sizeOf() { 1.78 + return headerSize; 1.79 + } 1.80 +}
2.1 --- a/agent/src/share/classes/sun/jvm/hotspot/memory/CompactibleFreeListSpace.java Mon Feb 02 23:26:33 2015 -0500 2.2 +++ b/agent/src/share/classes/sun/jvm/hotspot/memory/CompactibleFreeListSpace.java Mon Feb 17 09:51:37 2014 +0100 2.3 @@ -1,5 +1,5 @@ 2.4 /* 2.5 - * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. 2.6 + * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved. 2.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 2.8 * 2.9 * This code is free software; you can redistribute it and/or modify it 2.10 @@ -24,25 +24,29 @@ 2.11 2.12 package sun.jvm.hotspot.memory; 2.13 2.14 -import java.io.*; 2.15 -import java.util.*; 2.16 -import sun.jvm.hotspot.debugger.*; 2.17 -import sun.jvm.hotspot.oops.*; 2.18 -import sun.jvm.hotspot.runtime.*; 2.19 -import sun.jvm.hotspot.types.*; 2.20 -import sun.jvm.hotspot.utilities.*; 2.21 +import java.io.PrintStream; 2.22 +import java.util.ArrayList; 2.23 +import java.util.Iterator; 2.24 +import java.util.List; 2.25 +import java.util.Observable; 2.26 +import java.util.Observer; 2.27 + 2.28 +import sun.jvm.hotspot.debugger.Address; 2.29 +import sun.jvm.hotspot.debugger.Debugger; 2.30 +import sun.jvm.hotspot.oops.ObjectHeap; 2.31 +import sun.jvm.hotspot.oops.Oop; 2.32 +import sun.jvm.hotspot.runtime.VM; 2.33 +import sun.jvm.hotspot.runtime.VMObjectFactory; 2.34 +import sun.jvm.hotspot.types.AddressField; 2.35 +import sun.jvm.hotspot.types.Type; 2.36 +import sun.jvm.hotspot.types.TypeDataBase; 2.37 +import sun.jvm.hotspot.utilities.Assert; 2.38 2.39 public class CompactibleFreeListSpace extends CompactibleSpace { 2.40 private static AddressField collectorField; 2.41 - 2.42 - // for free size, three fields 2.43 - // FreeBlockDictionary* _dictionary; // ptr to dictionary for large size blocks 2.44 - // FreeList _indexedFreeList[IndexSetSize]; // indexed array for small size blocks 2.45 - // LinearAllocBlock _smallLinearAllocBlock; // small linear alloc in TLAB 2.46 private static AddressField indexedFreeListField; 2.47 private static AddressField dictionaryField; 2.48 private static long smallLinearAllocBlockFieldOffset; 2.49 - private static long indexedFreeListSizeOf; 2.50 2.51 private int heapWordSize; // 4 for 32bit, 8 for 64 bits 2.52 private int IndexSetStart; // for small indexed list 2.53 @@ -109,11 +113,11 @@ 2.54 // small chunks 2.55 long size = 0; 2.56 Address cur = addr.addOffsetTo( indexedFreeListField.getOffset() ); 2.57 - cur = cur.addOffsetTo(IndexSetStart*FreeList.sizeOf()); 2.58 + cur = cur.addOffsetTo(IndexSetStart*AdaptiveFreeList.sizeOf()); 2.59 for (int i=IndexSetStart; i<IndexSetSize; i += IndexSetStride) { 2.60 - FreeList freeList = (FreeList) VMObjectFactory.newObject(FreeList.class, cur); 2.61 + AdaptiveFreeList freeList = (AdaptiveFreeList) VMObjectFactory.newObject(AdaptiveFreeList.class, cur); 2.62 size += i*freeList.count(); 2.63 - cur= cur.addOffsetTo(IndexSetStride*FreeList.sizeOf()); 2.64 + cur= cur.addOffsetTo(IndexSetStride*AdaptiveFreeList.sizeOf()); 2.65 } 2.66 2.67 // large block
3.1 --- a/agent/src/share/classes/sun/jvm/hotspot/memory/FreeList.java Mon Feb 02 23:26:33 2015 -0500 3.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 3.3 @@ -1,72 +0,0 @@ 3.4 -/* 3.5 - * @(#)FreeList.java 3.6 - * 3.7 - * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. 3.8 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3.9 - * 3.10 - * This code is free software; you can redistribute it and/or modify it 3.11 - * under the terms of the GNU General Public License version 2 only, as 3.12 - * published by the Free Software Foundation. 3.13 - * 3.14 - * This code is distributed in the hope that it will be useful, but WITHOUT 3.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 3.16 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 3.17 - * version 2 for more details (a copy is included in the LICENSE file that 3.18 - * accompanied this code). 3.19 - * 3.20 - * You should have received a copy of the GNU General Public License version 3.21 - * 2 along with this work; if not, write to the Free Software Foundation, 3.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 3.23 - * 3.24 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 3.25 - * or visit www.oracle.com if you need additional information or have any 3.26 - * questions. 3.27 - * 3.28 - */ 3.29 - 3.30 -package sun.jvm.hotspot.memory; 3.31 - 3.32 -import java.util.*; 3.33 -import sun.jvm.hotspot.debugger.*; 3.34 -import sun.jvm.hotspot.types.*; 3.35 -import sun.jvm.hotspot.runtime.*; 3.36 - 3.37 -public class FreeList extends VMObject { 3.38 - static { 3.39 - VM.registerVMInitializedObserver(new Observer() { 3.40 - public void update(Observable o, Object data) { 3.41 - initialize(VM.getVM().getTypeDataBase()); 3.42 - } 3.43 - }); 3.44 - } 3.45 - 3.46 - private static synchronized void initialize(TypeDataBase db) { 3.47 - Type type = db.lookupType("FreeList<FreeChunk>"); 3.48 - sizeField = type.getCIntegerField("_size"); 3.49 - countField = type.getCIntegerField("_count"); 3.50 - headerSize = type.getSize(); 3.51 - } 3.52 - 3.53 - // Fields 3.54 - private static CIntegerField sizeField; 3.55 - private static CIntegerField countField; 3.56 - private static long headerSize; 3.57 - 3.58 - //Constructor 3.59 - public FreeList(Address address) { 3.60 - super(address); 3.61 - } 3.62 - 3.63 - // Accessors 3.64 - public long size() { 3.65 - return sizeField.getValue(addr); 3.66 - } 3.67 - 3.68 - public long count() { 3.69 - return countField.getValue(addr); 3.70 - } 3.71 - 3.72 - public static long sizeOf() { 3.73 - return headerSize; 3.74 - } 3.75 -}
4.1 --- a/src/share/vm/gc_implementation/concurrentMarkSweep/vmStructs_cms.hpp Mon Feb 02 23:26:33 2015 -0500 4.2 +++ b/src/share/vm/gc_implementation/concurrentMarkSweep/vmStructs_cms.hpp Mon Feb 17 09:51:37 2014 +0100 4.3 @@ -1,5 +1,5 @@ 4.4 /* 4.5 - * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved. 4.6 + * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved. 4.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4.8 * 4.9 * This code is free software; you can redistribute it and/or modify it 4.10 @@ -41,7 +41,7 @@ 4.11 nonstatic_field(LinearAllocBlock, _word_size, size_t) \ 4.12 nonstatic_field(AFLBinaryTreeDictionary, _total_size, size_t) \ 4.13 nonstatic_field(CompactibleFreeListSpace, _dictionary, AFLBinaryTreeDictionary*) \ 4.14 - nonstatic_field(CompactibleFreeListSpace, _indexedFreeList[0], FreeList<FreeChunk>) \ 4.15 + nonstatic_field(CompactibleFreeListSpace, _indexedFreeList[0], AdaptiveFreeList<FreeChunk>) \ 4.16 nonstatic_field(CompactibleFreeListSpace, _smallLinearAllocBlock, LinearAllocBlock) 4.17 4.18
5.1 --- a/src/share/vm/runtime/vmStructs.cpp Mon Feb 02 23:26:33 2015 -0500 5.2 +++ b/src/share/vm/runtime/vmStructs.cpp Mon Feb 17 09:51:37 2014 +0100 5.3 @@ -1,5 +1,5 @@ 5.4 /* 5.5 - * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. 5.6 + * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. 5.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 5.8 * 5.9 * This code is free software; you can redistribute it and/or modify it 5.10 @@ -248,7 +248,6 @@ 5.11 typedef Hashtable<Klass*, mtClass> KlassHashtable; 5.12 typedef HashtableEntry<Klass*, mtClass> KlassHashtableEntry; 5.13 typedef TwoOopHashtable<Symbol*, mtClass> SymbolTwoOopHashtable; 5.14 -typedef BinaryTreeDictionary<Metablock, FreeList<Metablock> > MetablockTreeDictionary; 5.15 5.16 //-------------------------------------------------------------------------------- 5.17 // VM_STRUCTS 5.18 @@ -1290,11 +1289,8 @@ 5.19 volatile_nonstatic_field(FreeChunk, _size, size_t) \ 5.20 nonstatic_field(FreeChunk, _next, FreeChunk*) \ 5.21 nonstatic_field(FreeChunk, _prev, FreeChunk*) \ 5.22 - nonstatic_field(FreeList<FreeChunk>, _size, size_t) \ 5.23 - nonstatic_field(FreeList<Metablock>, _size, size_t) \ 5.24 - nonstatic_field(FreeList<FreeChunk>, _count, ssize_t) \ 5.25 - nonstatic_field(FreeList<Metablock>, _count, ssize_t) \ 5.26 - nonstatic_field(MetablockTreeDictionary, _total_size, size_t) 5.27 + nonstatic_field(AdaptiveFreeList<FreeChunk>, _size, size_t) \ 5.28 + nonstatic_field(AdaptiveFreeList<FreeChunk>, _count, ssize_t) 5.29 5.30 5.31 //-------------------------------------------------------------------------------- 5.32 @@ -2166,14 +2162,8 @@ 5.33 \ 5.34 /* freelist */ \ 5.35 declare_toplevel_type(FreeChunk*) \ 5.36 - declare_toplevel_type(Metablock*) \ 5.37 - declare_toplevel_type(FreeBlockDictionary<FreeChunk>*) \ 5.38 - declare_toplevel_type(FreeList<FreeChunk>*) \ 5.39 - declare_toplevel_type(FreeList<FreeChunk>) \ 5.40 - declare_toplevel_type(FreeBlockDictionary<Metablock>*) \ 5.41 - declare_toplevel_type(FreeList<Metablock>*) \ 5.42 - declare_toplevel_type(FreeList<Metablock>) \ 5.43 - declare_type(MetablockTreeDictionary, FreeBlockDictionary<Metablock>) 5.44 + declare_toplevel_type(AdaptiveFreeList<FreeChunk>*) \ 5.45 + declare_toplevel_type(AdaptiveFreeList<FreeChunk>) 5.46 5.47 5.48 //--------------------------------------------------------------------------------