Mercurial > hg > truffle
comparison agent/src/share/classes/sun/jvm/hotspot/memory/CompactibleFreeListSpace.java @ 152:c70a245cad3a
6670684: 4/5 SA command universe did not print out CMS space information
Summary: Forward port of Yumin's fix for 6670684 from HSX-11; Yumin verified the port was correct.
Reviewed-by: dcubed
author | dcubed |
---|---|
date | Fri, 09 May 2008 08:55:13 -0700 |
parents | a61af66fc99e |
children | c0ecab83e6f3 |
comparison
equal
deleted
inserted
replaced
83:d3cd40645d0d | 152:c70a245cad3a |
---|---|
33 import sun.jvm.hotspot.utilities.*; | 33 import sun.jvm.hotspot.utilities.*; |
34 | 34 |
35 public class CompactibleFreeListSpace extends CompactibleSpace { | 35 public class CompactibleFreeListSpace extends CompactibleSpace { |
36 private static AddressField collectorField; | 36 private static AddressField collectorField; |
37 | 37 |
38 // for free size, three fields | |
39 // FreeBlockDictionary* _dictionary; // ptr to dictionary for large size blocks | |
40 // FreeList _indexedFreeList[IndexSetSize]; // indexed array for small size blocks | |
41 // LinearAllocBlock _smallLinearAllocBlock; // small linear alloc in TLAB | |
42 private static AddressField indexedFreeListField; | |
43 private static AddressField dictionaryField; | |
44 private static long smallLinearAllocBlockFieldOffset; | |
45 private static long indexedFreeListSizeOf; | |
46 | |
47 private int heapWordSize; // 4 for 32bit, 8 for 64 bits | |
48 private int IndexSetStart; // for small indexed list | |
49 private int IndexSetSize; | |
50 private int IndexSetStride; | |
51 | |
38 static { | 52 static { |
39 VM.registerVMInitializedObserver(new Observer() { | 53 VM.registerVMInitializedObserver(new Observer() { |
40 public void update(Observable o, Object data) { | 54 public void update(Observable o, Object data) { |
41 initialize(VM.getVM().getTypeDataBase()); | 55 initialize(VM.getVM().getTypeDataBase()); |
42 } | 56 } |
49 MinChunkSizeInBytes = numQuanta(sizeofFreeChunk, vm.getMinObjAlignmentInBytes()) * | 63 MinChunkSizeInBytes = numQuanta(sizeofFreeChunk, vm.getMinObjAlignmentInBytes()) * |
50 vm.getMinObjAlignmentInBytes(); | 64 vm.getMinObjAlignmentInBytes(); |
51 | 65 |
52 Type type = db.lookupType("CompactibleFreeListSpace"); | 66 Type type = db.lookupType("CompactibleFreeListSpace"); |
53 collectorField = type.getAddressField("_collector"); | 67 collectorField = type.getAddressField("_collector"); |
68 collectorField = type.getAddressField("_collector"); | |
69 dictionaryField = type.getAddressField("_dictionary"); | |
70 indexedFreeListField = type.getAddressField("_indexedFreeList[0]"); | |
71 smallLinearAllocBlockFieldOffset = type.getField("_smallLinearAllocBlock").getOffset(); | |
54 } | 72 } |
55 | 73 |
56 public CompactibleFreeListSpace(Address addr) { | 74 public CompactibleFreeListSpace(Address addr) { |
57 super(addr); | 75 super(addr); |
76 if ( VM.getVM().isLP64() ) { | |
77 heapWordSize = 8; | |
78 IndexSetStart = 1; | |
79 IndexSetStride = 1; | |
80 } | |
81 else { | |
82 heapWordSize = 4; | |
83 IndexSetStart = 2; | |
84 IndexSetStride = 2; | |
85 } | |
86 | |
87 IndexSetSize = 257; | |
58 } | 88 } |
59 | 89 |
60 // Accessing block offset table | 90 // Accessing block offset table |
61 public CMSCollector collector() { | 91 public CMSCollector collector() { |
62 return (CMSCollector) VMObjectFactory.newObject( | 92 return (CMSCollector) VMObjectFactory.newObject( |
63 CMSCollector.class, | 93 CMSCollector.class, |
64 collectorField.getValue(addr)); | 94 collectorField.getValue(addr)); |
65 } | 95 } |
96 | |
97 public long free0() { | |
98 return capacity() - used0(); | |
99 } | |
66 | 100 |
67 public long used() { | 101 public long used() { |
102 return capacity() - free(); | |
103 } | |
104 | |
105 public long used0() { | |
68 List regions = getLiveRegions(); | 106 List regions = getLiveRegions(); |
69 long usedSize = 0L; | 107 long usedSize = 0L; |
70 for (Iterator itr = regions.iterator(); itr.hasNext();) { | 108 for (Iterator itr = regions.iterator(); itr.hasNext();) { |
71 MemRegion mr = (MemRegion) itr.next(); | 109 MemRegion mr = (MemRegion) itr.next(); |
72 usedSize += mr.byteSize(); | 110 usedSize += mr.byteSize(); |
73 } | 111 } |
74 return usedSize; | 112 return usedSize; |
75 } | 113 } |
76 | 114 |
77 public long free() { | 115 public long free() { |
78 return capacity() - used(); | 116 // small chunks |
79 } | 117 long size = 0; |
118 Address cur = addr.addOffsetTo( indexedFreeListField.getOffset() ); | |
119 cur = cur.addOffsetTo(IndexSetStart*FreeList.sizeOf()); | |
120 for (int i=IndexSetStart; i<IndexSetSize; i += IndexSetStride) { | |
121 FreeList freeList = (FreeList) VMObjectFactory.newObject(FreeList.class, cur); | |
122 size += i*freeList.count(); | |
123 cur= cur.addOffsetTo(IndexSetStride*FreeList.sizeOf()); | |
124 } | |
125 | |
126 // large block | |
127 BinaryTreeDictionary bfbd = (BinaryTreeDictionary) VMObjectFactory.newObject(BinaryTreeDictionary.class, | |
128 dictionaryField.getValue(addr)); | |
129 size += bfbd.size(); | |
130 | |
131 | |
132 // linear block in TLAB | |
133 LinearAllocBlock lab = (LinearAllocBlock) VMObjectFactory.newObject(LinearAllocBlock.class, | |
134 addr.addOffsetTo(smallLinearAllocBlockFieldOffset)); | |
135 size += lab.word_size(); | |
136 | |
137 return size*heapWordSize; | |
138 } | |
80 | 139 |
81 public void printOn(PrintStream tty) { | 140 public void printOn(PrintStream tty) { |
82 tty.print("free-list-space"); | 141 tty.print("free-list-space"); |
142 tty.print("[ " + bottom() + " , " + end() + " ) "); | |
143 long cap = capacity(); | |
144 long used_size = used(); | |
145 long free_size = free(); | |
146 int used_perc = (int)((double)used_size/cap*100); | |
147 tty.print("space capacity = " + cap + " used(" + used_perc + "%)= " + used_size + " "); | |
148 tty.print("free= " + free_size ); | |
149 tty.print("\n"); | |
150 | |
83 } | 151 } |
84 | 152 |
85 public Address skipBlockSizeUsingPrintezisBits(Address pos) { | 153 public Address skipBlockSizeUsingPrintezisBits(Address pos) { |
86 CMSCollector collector = collector(); | 154 CMSCollector collector = collector(); |
87 long size = 0; | 155 long size = 0; |