annotate 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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
2 * Copyright 2003-2007 Sun Microsystems, Inc. All Rights Reserved.
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
a61af66fc99e Initial load
duke
parents:
diff changeset
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
a61af66fc99e Initial load
duke
parents:
diff changeset
20 * CA 95054 USA or visit www.sun.com if you need additional information or
a61af66fc99e Initial load
duke
parents:
diff changeset
21 * have any questions.
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
a61af66fc99e Initial load
duke
parents:
diff changeset
25 package sun.jvm.hotspot.memory;
a61af66fc99e Initial load
duke
parents:
diff changeset
26
a61af66fc99e Initial load
duke
parents:
diff changeset
27 import java.io.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
28 import java.util.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
29 import sun.jvm.hotspot.debugger.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
30 import sun.jvm.hotspot.oops.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
31 import sun.jvm.hotspot.runtime.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
32 import sun.jvm.hotspot.types.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
33 import sun.jvm.hotspot.utilities.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
34
a61af66fc99e Initial load
duke
parents:
diff changeset
35 public class CompactibleFreeListSpace extends CompactibleSpace {
a61af66fc99e Initial load
duke
parents:
diff changeset
36 private static AddressField collectorField;
a61af66fc99e Initial load
duke
parents:
diff changeset
37
152
c70a245cad3a 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 0
diff changeset
38 // for free size, three fields
c70a245cad3a 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 0
diff changeset
39 // FreeBlockDictionary* _dictionary; // ptr to dictionary for large size blocks
c70a245cad3a 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 0
diff changeset
40 // FreeList _indexedFreeList[IndexSetSize]; // indexed array for small size blocks
c70a245cad3a 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 0
diff changeset
41 // LinearAllocBlock _smallLinearAllocBlock; // small linear alloc in TLAB
c70a245cad3a 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 0
diff changeset
42 private static AddressField indexedFreeListField;
c70a245cad3a 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 0
diff changeset
43 private static AddressField dictionaryField;
c70a245cad3a 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 0
diff changeset
44 private static long smallLinearAllocBlockFieldOffset;
c70a245cad3a 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 0
diff changeset
45 private static long indexedFreeListSizeOf;
c70a245cad3a 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 0
diff changeset
46
c70a245cad3a 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 0
diff changeset
47 private int heapWordSize; // 4 for 32bit, 8 for 64 bits
c70a245cad3a 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 0
diff changeset
48 private int IndexSetStart; // for small indexed list
c70a245cad3a 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 0
diff changeset
49 private int IndexSetSize;
c70a245cad3a 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 0
diff changeset
50 private int IndexSetStride;
c70a245cad3a 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 0
diff changeset
51
0
a61af66fc99e Initial load
duke
parents:
diff changeset
52 static {
a61af66fc99e Initial load
duke
parents:
diff changeset
53 VM.registerVMInitializedObserver(new Observer() {
a61af66fc99e Initial load
duke
parents:
diff changeset
54 public void update(Observable o, Object data) {
a61af66fc99e Initial load
duke
parents:
diff changeset
55 initialize(VM.getVM().getTypeDataBase());
a61af66fc99e Initial load
duke
parents:
diff changeset
56 }
a61af66fc99e Initial load
duke
parents:
diff changeset
57 });
a61af66fc99e Initial load
duke
parents:
diff changeset
58 }
a61af66fc99e Initial load
duke
parents:
diff changeset
59
a61af66fc99e Initial load
duke
parents:
diff changeset
60 private static synchronized void initialize(TypeDataBase db) {
a61af66fc99e Initial load
duke
parents:
diff changeset
61 long sizeofFreeChunk = db.lookupType("FreeChunk").getSize();
a61af66fc99e Initial load
duke
parents:
diff changeset
62 VM vm = VM.getVM();
a61af66fc99e Initial load
duke
parents:
diff changeset
63 MinChunkSizeInBytes = numQuanta(sizeofFreeChunk, vm.getMinObjAlignmentInBytes()) *
a61af66fc99e Initial load
duke
parents:
diff changeset
64 vm.getMinObjAlignmentInBytes();
a61af66fc99e Initial load
duke
parents:
diff changeset
65
a61af66fc99e Initial load
duke
parents:
diff changeset
66 Type type = db.lookupType("CompactibleFreeListSpace");
a61af66fc99e Initial load
duke
parents:
diff changeset
67 collectorField = type.getAddressField("_collector");
152
c70a245cad3a 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 0
diff changeset
68 collectorField = type.getAddressField("_collector");
c70a245cad3a 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 0
diff changeset
69 dictionaryField = type.getAddressField("_dictionary");
c70a245cad3a 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 0
diff changeset
70 indexedFreeListField = type.getAddressField("_indexedFreeList[0]");
c70a245cad3a 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 0
diff changeset
71 smallLinearAllocBlockFieldOffset = type.getField("_smallLinearAllocBlock").getOffset();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
72 }
a61af66fc99e Initial load
duke
parents:
diff changeset
73
a61af66fc99e Initial load
duke
parents:
diff changeset
74 public CompactibleFreeListSpace(Address addr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
75 super(addr);
152
c70a245cad3a 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 0
diff changeset
76 if ( VM.getVM().isLP64() ) {
c70a245cad3a 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 0
diff changeset
77 heapWordSize = 8;
c70a245cad3a 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 0
diff changeset
78 IndexSetStart = 1;
c70a245cad3a 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 0
diff changeset
79 IndexSetStride = 1;
c70a245cad3a 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 0
diff changeset
80 }
c70a245cad3a 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 0
diff changeset
81 else {
c70a245cad3a 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 0
diff changeset
82 heapWordSize = 4;
c70a245cad3a 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 0
diff changeset
83 IndexSetStart = 2;
c70a245cad3a 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 0
diff changeset
84 IndexSetStride = 2;
c70a245cad3a 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 0
diff changeset
85 }
c70a245cad3a 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 0
diff changeset
86
c70a245cad3a 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 0
diff changeset
87 IndexSetSize = 257;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
88 }
a61af66fc99e Initial load
duke
parents:
diff changeset
89
a61af66fc99e Initial load
duke
parents:
diff changeset
90 // Accessing block offset table
a61af66fc99e Initial load
duke
parents:
diff changeset
91 public CMSCollector collector() {
a61af66fc99e Initial load
duke
parents:
diff changeset
92 return (CMSCollector) VMObjectFactory.newObject(
a61af66fc99e Initial load
duke
parents:
diff changeset
93 CMSCollector.class,
a61af66fc99e Initial load
duke
parents:
diff changeset
94 collectorField.getValue(addr));
152
c70a245cad3a 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 0
diff changeset
95 }
c70a245cad3a 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 0
diff changeset
96
c70a245cad3a 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 0
diff changeset
97 public long free0() {
c70a245cad3a 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 0
diff changeset
98 return capacity() - used0();
c70a245cad3a 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 0
diff changeset
99 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
100
a61af66fc99e Initial load
duke
parents:
diff changeset
101 public long used() {
152
c70a245cad3a 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 0
diff changeset
102 return capacity() - free();
c70a245cad3a 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 0
diff changeset
103 }
c70a245cad3a 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 0
diff changeset
104
c70a245cad3a 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 0
diff changeset
105 public long used0() {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
106 List regions = getLiveRegions();
a61af66fc99e Initial load
duke
parents:
diff changeset
107 long usedSize = 0L;
a61af66fc99e Initial load
duke
parents:
diff changeset
108 for (Iterator itr = regions.iterator(); itr.hasNext();) {
a61af66fc99e Initial load
duke
parents:
diff changeset
109 MemRegion mr = (MemRegion) itr.next();
a61af66fc99e Initial load
duke
parents:
diff changeset
110 usedSize += mr.byteSize();
a61af66fc99e Initial load
duke
parents:
diff changeset
111 }
a61af66fc99e Initial load
duke
parents:
diff changeset
112 return usedSize;
a61af66fc99e Initial load
duke
parents:
diff changeset
113 }
a61af66fc99e Initial load
duke
parents:
diff changeset
114
a61af66fc99e Initial load
duke
parents:
diff changeset
115 public long free() {
152
c70a245cad3a 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 0
diff changeset
116 // small chunks
c70a245cad3a 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 0
diff changeset
117 long size = 0;
c70a245cad3a 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 0
diff changeset
118 Address cur = addr.addOffsetTo( indexedFreeListField.getOffset() );
c70a245cad3a 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 0
diff changeset
119 cur = cur.addOffsetTo(IndexSetStart*FreeList.sizeOf());
c70a245cad3a 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 0
diff changeset
120 for (int i=IndexSetStart; i<IndexSetSize; i += IndexSetStride) {
c70a245cad3a 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 0
diff changeset
121 FreeList freeList = (FreeList) VMObjectFactory.newObject(FreeList.class, cur);
c70a245cad3a 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 0
diff changeset
122 size += i*freeList.count();
c70a245cad3a 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 0
diff changeset
123 cur= cur.addOffsetTo(IndexSetStride*FreeList.sizeOf());
c70a245cad3a 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 0
diff changeset
124 }
c70a245cad3a 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 0
diff changeset
125
c70a245cad3a 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 0
diff changeset
126 // large block
c70a245cad3a 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 0
diff changeset
127 BinaryTreeDictionary bfbd = (BinaryTreeDictionary) VMObjectFactory.newObject(BinaryTreeDictionary.class,
c70a245cad3a 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 0
diff changeset
128 dictionaryField.getValue(addr));
c70a245cad3a 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 0
diff changeset
129 size += bfbd.size();
c70a245cad3a 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 0
diff changeset
130
c70a245cad3a 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 0
diff changeset
131
c70a245cad3a 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 0
diff changeset
132 // linear block in TLAB
c70a245cad3a 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 0
diff changeset
133 LinearAllocBlock lab = (LinearAllocBlock) VMObjectFactory.newObject(LinearAllocBlock.class,
c70a245cad3a 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 0
diff changeset
134 addr.addOffsetTo(smallLinearAllocBlockFieldOffset));
c70a245cad3a 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 0
diff changeset
135 size += lab.word_size();
c70a245cad3a 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 0
diff changeset
136
c70a245cad3a 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 0
diff changeset
137 return size*heapWordSize;
c70a245cad3a 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 0
diff changeset
138 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
139
a61af66fc99e Initial load
duke
parents:
diff changeset
140 public void printOn(PrintStream tty) {
a61af66fc99e Initial load
duke
parents:
diff changeset
141 tty.print("free-list-space");
152
c70a245cad3a 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 0
diff changeset
142 tty.print("[ " + bottom() + " , " + end() + " ) ");
c70a245cad3a 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 0
diff changeset
143 long cap = capacity();
c70a245cad3a 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 0
diff changeset
144 long used_size = used();
c70a245cad3a 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 0
diff changeset
145 long free_size = free();
c70a245cad3a 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 0
diff changeset
146 int used_perc = (int)((double)used_size/cap*100);
c70a245cad3a 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 0
diff changeset
147 tty.print("space capacity = " + cap + " used(" + used_perc + "%)= " + used_size + " ");
c70a245cad3a 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 0
diff changeset
148 tty.print("free= " + free_size );
c70a245cad3a 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 0
diff changeset
149 tty.print("\n");
c70a245cad3a 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 0
diff changeset
150
0
a61af66fc99e Initial load
duke
parents:
diff changeset
151 }
a61af66fc99e Initial load
duke
parents:
diff changeset
152
a61af66fc99e Initial load
duke
parents:
diff changeset
153 public Address skipBlockSizeUsingPrintezisBits(Address pos) {
a61af66fc99e Initial load
duke
parents:
diff changeset
154 CMSCollector collector = collector();
a61af66fc99e Initial load
duke
parents:
diff changeset
155 long size = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
156 Address addr = null;
a61af66fc99e Initial load
duke
parents:
diff changeset
157
a61af66fc99e Initial load
duke
parents:
diff changeset
158 if (collector != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
159 size = collector.blockSizeUsingPrintezisBits(pos);
a61af66fc99e Initial load
duke
parents:
diff changeset
160 if (size >= 3) {
a61af66fc99e Initial load
duke
parents:
diff changeset
161 addr = pos.addOffsetTo(adjustObjectSizeInBytes(size));
a61af66fc99e Initial load
duke
parents:
diff changeset
162 }
a61af66fc99e Initial load
duke
parents:
diff changeset
163 }
a61af66fc99e Initial load
duke
parents:
diff changeset
164 return addr;
a61af66fc99e Initial load
duke
parents:
diff changeset
165 }
a61af66fc99e Initial load
duke
parents:
diff changeset
166
a61af66fc99e Initial load
duke
parents:
diff changeset
167 public List/*<MemRegion>*/ getLiveRegions() {
a61af66fc99e Initial load
duke
parents:
diff changeset
168 List res = new ArrayList(); // List<MemRegion>
a61af66fc99e Initial load
duke
parents:
diff changeset
169 VM vm = VM.getVM();
a61af66fc99e Initial load
duke
parents:
diff changeset
170 Debugger dbg = vm.getDebugger();
a61af66fc99e Initial load
duke
parents:
diff changeset
171 ObjectHeap heap = vm.getObjectHeap();
a61af66fc99e Initial load
duke
parents:
diff changeset
172 Address cur = bottom();
a61af66fc99e Initial load
duke
parents:
diff changeset
173 Address regionStart = cur;
a61af66fc99e Initial load
duke
parents:
diff changeset
174 Address limit = end();
a61af66fc99e Initial load
duke
parents:
diff changeset
175 final long addressSize = vm.getAddressSize();
a61af66fc99e Initial load
duke
parents:
diff changeset
176
a61af66fc99e Initial load
duke
parents:
diff changeset
177 for (; cur.lessThan(limit);) {
a61af66fc99e Initial load
duke
parents:
diff changeset
178 Address klassOop = cur.getAddressAt(addressSize);
a61af66fc99e Initial load
duke
parents:
diff changeset
179 // FIXME: need to do a better job here.
a61af66fc99e Initial load
duke
parents:
diff changeset
180 // can I use bitMap here?
a61af66fc99e Initial load
duke
parents:
diff changeset
181 if (klassOop == null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
182 //Find the object size using Printezis bits and skip over
a61af66fc99e Initial load
duke
parents:
diff changeset
183 System.err.println("Finding object size using Printezis bits and skipping over...");
a61af66fc99e Initial load
duke
parents:
diff changeset
184 long size = collector().blockSizeUsingPrintezisBits(cur);
a61af66fc99e Initial load
duke
parents:
diff changeset
185 if (size == -1) {
a61af66fc99e Initial load
duke
parents:
diff changeset
186 System.err.println("Printezis bits not set...");
a61af66fc99e Initial load
duke
parents:
diff changeset
187 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
188 }
a61af66fc99e Initial load
duke
parents:
diff changeset
189 cur = cur.addOffsetTo(adjustObjectSizeInBytes(size));
a61af66fc99e Initial load
duke
parents:
diff changeset
190 }
a61af66fc99e Initial load
duke
parents:
diff changeset
191
a61af66fc99e Initial load
duke
parents:
diff changeset
192 if (FreeChunk.secondWordIndicatesFreeChunk(dbg.getAddressValue(klassOop))) {
a61af66fc99e Initial load
duke
parents:
diff changeset
193 if (! cur.equals(regionStart)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
194 res.add(new MemRegion(regionStart, cur));
a61af66fc99e Initial load
duke
parents:
diff changeset
195 }
a61af66fc99e Initial load
duke
parents:
diff changeset
196 FreeChunk fc = (FreeChunk) VMObjectFactory.newObject(FreeChunk.class, cur);
a61af66fc99e Initial load
duke
parents:
diff changeset
197 long chunkSize = fc.size();
a61af66fc99e Initial load
duke
parents:
diff changeset
198 if (Assert.ASSERTS_ENABLED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
199 Assert.that(chunkSize > 0, "invalid FreeChunk size");
a61af66fc99e Initial load
duke
parents:
diff changeset
200 }
a61af66fc99e Initial load
duke
parents:
diff changeset
201 // note that fc.size() gives chunk size in heap words
a61af66fc99e Initial load
duke
parents:
diff changeset
202 cur = cur.addOffsetTo(chunkSize * addressSize);
a61af66fc99e Initial load
duke
parents:
diff changeset
203 System.err.println("Free chunk in CMS heap, size="+chunkSize * addressSize);
a61af66fc99e Initial load
duke
parents:
diff changeset
204 regionStart = cur;
a61af66fc99e Initial load
duke
parents:
diff changeset
205 } else if (klassOop != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
206 Oop obj = heap.newOop(cur.addOffsetToAsOopHandle(0));
a61af66fc99e Initial load
duke
parents:
diff changeset
207 long objectSize = obj.getObjectSize();
a61af66fc99e Initial load
duke
parents:
diff changeset
208 cur = cur.addOffsetTo(adjustObjectSizeInBytes(objectSize));
a61af66fc99e Initial load
duke
parents:
diff changeset
209 }
a61af66fc99e Initial load
duke
parents:
diff changeset
210 }
a61af66fc99e Initial load
duke
parents:
diff changeset
211 return res;
a61af66fc99e Initial load
duke
parents:
diff changeset
212 }
a61af66fc99e Initial load
duke
parents:
diff changeset
213
a61af66fc99e Initial load
duke
parents:
diff changeset
214 //-- Internals only below this point
a61af66fc99e Initial load
duke
parents:
diff changeset
215
a61af66fc99e Initial load
duke
parents:
diff changeset
216 // Unlike corresponding VM code, we operate on byte size rather than
a61af66fc99e Initial load
duke
parents:
diff changeset
217 // HeapWord size for convenience.
a61af66fc99e Initial load
duke
parents:
diff changeset
218
a61af66fc99e Initial load
duke
parents:
diff changeset
219 private static long numQuanta(long x, long y) {
a61af66fc99e Initial load
duke
parents:
diff changeset
220 return ((x+y-1)/y);
a61af66fc99e Initial load
duke
parents:
diff changeset
221 }
a61af66fc99e Initial load
duke
parents:
diff changeset
222
a61af66fc99e Initial load
duke
parents:
diff changeset
223 public static long adjustObjectSizeInBytes(long sizeInBytes) {
a61af66fc99e Initial load
duke
parents:
diff changeset
224 return Oop.alignObjectSize(Math.max(sizeInBytes, MinChunkSizeInBytes));
a61af66fc99e Initial load
duke
parents:
diff changeset
225 }
a61af66fc99e Initial load
duke
parents:
diff changeset
226
a61af66fc99e Initial load
duke
parents:
diff changeset
227 // FIXME: should I read this directly from VM?
a61af66fc99e Initial load
duke
parents:
diff changeset
228 private static long MinChunkSizeInBytes;
a61af66fc99e Initial load
duke
parents:
diff changeset
229 }