annotate agent/src/share/classes/sun/jvm/hotspot/memory/CompactibleFreeListSpace.java @ 24234:ea6f94ab283b default tip

Added tag jvmci-0.36 for changeset 8128b98d4736
author Gilles Duboscq <gilles.m.duboscq@oracle.com>
date Mon, 18 Sep 2017 18:49:45 +0200
parents dd9cc155639c
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
23286
dd9cc155639c Merge with jdk8u66-b17
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 14909
diff changeset
2 * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
0
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 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 948
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 948
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 948
diff changeset
21 * questions.
0
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
23286
dd9cc155639c Merge with jdk8u66-b17
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 14909
diff changeset
27 import java.io.PrintStream;
dd9cc155639c Merge with jdk8u66-b17
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 14909
diff changeset
28 import java.util.ArrayList;
dd9cc155639c Merge with jdk8u66-b17
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 14909
diff changeset
29 import java.util.Iterator;
dd9cc155639c Merge with jdk8u66-b17
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 14909
diff changeset
30 import java.util.List;
dd9cc155639c Merge with jdk8u66-b17
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 14909
diff changeset
31 import java.util.Observable;
dd9cc155639c Merge with jdk8u66-b17
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 14909
diff changeset
32 import java.util.Observer;
dd9cc155639c Merge with jdk8u66-b17
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 14909
diff changeset
33
dd9cc155639c Merge with jdk8u66-b17
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 14909
diff changeset
34 import sun.jvm.hotspot.debugger.Address;
dd9cc155639c Merge with jdk8u66-b17
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 14909
diff changeset
35 import sun.jvm.hotspot.debugger.Debugger;
dd9cc155639c Merge with jdk8u66-b17
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 14909
diff changeset
36 import sun.jvm.hotspot.oops.ObjectHeap;
dd9cc155639c Merge with jdk8u66-b17
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 14909
diff changeset
37 import sun.jvm.hotspot.oops.Oop;
dd9cc155639c Merge with jdk8u66-b17
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 14909
diff changeset
38 import sun.jvm.hotspot.runtime.VM;
dd9cc155639c Merge with jdk8u66-b17
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 14909
diff changeset
39 import sun.jvm.hotspot.runtime.VMObjectFactory;
dd9cc155639c Merge with jdk8u66-b17
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 14909
diff changeset
40 import sun.jvm.hotspot.types.AddressField;
dd9cc155639c Merge with jdk8u66-b17
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 14909
diff changeset
41 import sun.jvm.hotspot.types.Type;
dd9cc155639c Merge with jdk8u66-b17
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 14909
diff changeset
42 import sun.jvm.hotspot.types.TypeDataBase;
dd9cc155639c Merge with jdk8u66-b17
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 14909
diff changeset
43 import sun.jvm.hotspot.utilities.Assert;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
44
a61af66fc99e Initial load
duke
parents:
diff changeset
45 public class CompactibleFreeListSpace extends CompactibleSpace {
a61af66fc99e Initial load
duke
parents:
diff changeset
46 private static AddressField collectorField;
152
c70a245cad3a 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 0
diff changeset
47 private static AddressField indexedFreeListField;
c70a245cad3a 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 0
diff changeset
48 private static AddressField dictionaryField;
c70a245cad3a 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 0
diff changeset
49 private static long smallLinearAllocBlockFieldOffset;
c70a245cad3a 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 0
diff changeset
50
c70a245cad3a 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 0
diff changeset
51 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
52 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
53 private int IndexSetSize;
c70a245cad3a 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 0
diff changeset
54 private int IndexSetStride;
c70a245cad3a 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 0
diff changeset
55
0
a61af66fc99e Initial load
duke
parents:
diff changeset
56 static {
a61af66fc99e Initial load
duke
parents:
diff changeset
57 VM.registerVMInitializedObserver(new Observer() {
a61af66fc99e Initial load
duke
parents:
diff changeset
58 public void update(Observable o, Object data) {
a61af66fc99e Initial load
duke
parents:
diff changeset
59 initialize(VM.getVM().getTypeDataBase());
a61af66fc99e Initial load
duke
parents:
diff changeset
60 }
a61af66fc99e Initial load
duke
parents:
diff changeset
61 });
a61af66fc99e Initial load
duke
parents:
diff changeset
62 }
a61af66fc99e Initial load
duke
parents:
diff changeset
63
a61af66fc99e Initial load
duke
parents:
diff changeset
64 private static synchronized void initialize(TypeDataBase db) {
a61af66fc99e Initial load
duke
parents:
diff changeset
65 long sizeofFreeChunk = db.lookupType("FreeChunk").getSize();
a61af66fc99e Initial load
duke
parents:
diff changeset
66 VM vm = VM.getVM();
a61af66fc99e Initial load
duke
parents:
diff changeset
67 MinChunkSizeInBytes = numQuanta(sizeofFreeChunk, vm.getMinObjAlignmentInBytes()) *
a61af66fc99e Initial load
duke
parents:
diff changeset
68 vm.getMinObjAlignmentInBytes();
a61af66fc99e Initial load
duke
parents:
diff changeset
69
a61af66fc99e Initial load
duke
parents:
diff changeset
70 Type type = db.lookupType("CompactibleFreeListSpace");
a61af66fc99e Initial load
duke
parents:
diff changeset
71 collectorField = type.getAddressField("_collector");
152
c70a245cad3a 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 0
diff changeset
72 collectorField = type.getAddressField("_collector");
c70a245cad3a 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 0
diff changeset
73 dictionaryField = type.getAddressField("_dictionary");
c70a245cad3a 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 0
diff changeset
74 indexedFreeListField = type.getAddressField("_indexedFreeList[0]");
c70a245cad3a 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 0
diff changeset
75 smallLinearAllocBlockFieldOffset = type.getField("_smallLinearAllocBlock").getOffset();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
76 }
a61af66fc99e Initial load
duke
parents:
diff changeset
77
a61af66fc99e Initial load
duke
parents:
diff changeset
78 public CompactibleFreeListSpace(Address addr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
79 super(addr);
1571
2d127394260e 6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents: 948
diff changeset
80 VM vm = VM.getVM();
2d127394260e 6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents: 948
diff changeset
81 heapWordSize = vm.getHeapWordSize();
2d127394260e 6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents: 948
diff changeset
82 IndexSetStart = vm.getMinObjAlignmentInBytes() / heapWordSize;
2d127394260e 6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents: 948
diff changeset
83 IndexSetStride = IndexSetStart;
2d127394260e 6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents: 948
diff changeset
84 IndexSetSize = 257;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
85 }
a61af66fc99e Initial load
duke
parents:
diff changeset
86
a61af66fc99e Initial load
duke
parents:
diff changeset
87 // Accessing block offset table
a61af66fc99e Initial load
duke
parents:
diff changeset
88 public CMSCollector collector() {
a61af66fc99e Initial load
duke
parents:
diff changeset
89 return (CMSCollector) VMObjectFactory.newObject(
a61af66fc99e Initial load
duke
parents:
diff changeset
90 CMSCollector.class,
a61af66fc99e Initial load
duke
parents:
diff changeset
91 collectorField.getValue(addr));
152
c70a245cad3a 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 0
diff changeset
92 }
c70a245cad3a 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 0
diff changeset
93
c70a245cad3a 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 0
diff changeset
94 public long free0() {
c70a245cad3a 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 0
diff changeset
95 return capacity() - used0();
c70a245cad3a 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 0
diff changeset
96 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
97
a61af66fc99e Initial load
duke
parents:
diff changeset
98 public long used() {
152
c70a245cad3a 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 0
diff changeset
99 return capacity() - free();
c70a245cad3a 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 0
diff changeset
100 }
c70a245cad3a 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 0
diff changeset
101
c70a245cad3a 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 0
diff changeset
102 public long used0() {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
103 List regions = getLiveRegions();
a61af66fc99e Initial load
duke
parents:
diff changeset
104 long usedSize = 0L;
a61af66fc99e Initial load
duke
parents:
diff changeset
105 for (Iterator itr = regions.iterator(); itr.hasNext();) {
a61af66fc99e Initial load
duke
parents:
diff changeset
106 MemRegion mr = (MemRegion) itr.next();
a61af66fc99e Initial load
duke
parents:
diff changeset
107 usedSize += mr.byteSize();
a61af66fc99e Initial load
duke
parents:
diff changeset
108 }
a61af66fc99e Initial load
duke
parents:
diff changeset
109 return usedSize;
a61af66fc99e Initial load
duke
parents:
diff changeset
110 }
a61af66fc99e Initial load
duke
parents:
diff changeset
111
a61af66fc99e Initial load
duke
parents:
diff changeset
112 public long free() {
152
c70a245cad3a 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 0
diff changeset
113 // small chunks
c70a245cad3a 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 0
diff changeset
114 long size = 0;
c70a245cad3a 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 0
diff changeset
115 Address cur = addr.addOffsetTo( indexedFreeListField.getOffset() );
23286
dd9cc155639c Merge with jdk8u66-b17
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 14909
diff changeset
116 cur = cur.addOffsetTo(IndexSetStart*AdaptiveFreeList.sizeOf());
152
c70a245cad3a 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 0
diff changeset
117 for (int i=IndexSetStart; i<IndexSetSize; i += IndexSetStride) {
23286
dd9cc155639c Merge with jdk8u66-b17
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 14909
diff changeset
118 AdaptiveFreeList freeList = (AdaptiveFreeList) VMObjectFactory.newObject(AdaptiveFreeList.class, cur);
152
c70a245cad3a 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 0
diff changeset
119 size += i*freeList.count();
23286
dd9cc155639c Merge with jdk8u66-b17
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 14909
diff changeset
120 cur= cur.addOffsetTo(IndexSetStride*AdaptiveFreeList.sizeOf());
152
c70a245cad3a 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 0
diff changeset
121 }
c70a245cad3a 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 0
diff changeset
122
c70a245cad3a 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 0
diff changeset
123 // large block
7950
6cf2530f7fd3 8005278: Serviceability Agent: jmap -heap and jstack -m fail
minqi
parents: 6725
diff changeset
124 AFLBinaryTreeDictionary aflbd = (AFLBinaryTreeDictionary) VMObjectFactory.newObject(AFLBinaryTreeDictionary.class,
152
c70a245cad3a 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 0
diff changeset
125 dictionaryField.getValue(addr));
7950
6cf2530f7fd3 8005278: Serviceability Agent: jmap -heap and jstack -m fail
minqi
parents: 6725
diff changeset
126 size += aflbd.size();
152
c70a245cad3a 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 0
diff changeset
127
c70a245cad3a 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 0
diff changeset
128
c70a245cad3a 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 0
diff changeset
129 // linear block in TLAB
c70a245cad3a 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 0
diff changeset
130 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
131 addr.addOffsetTo(smallLinearAllocBlockFieldOffset));
c70a245cad3a 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 0
diff changeset
132 size += lab.word_size();
c70a245cad3a 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 0
diff changeset
133
c70a245cad3a 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 0
diff changeset
134 return size*heapWordSize;
c70a245cad3a 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 0
diff changeset
135 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
136
a61af66fc99e Initial load
duke
parents:
diff changeset
137 public void printOn(PrintStream tty) {
a61af66fc99e Initial load
duke
parents:
diff changeset
138 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
139 tty.print("[ " + bottom() + " , " + end() + " ) ");
c70a245cad3a 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 0
diff changeset
140 long cap = capacity();
c70a245cad3a 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 0
diff changeset
141 long used_size = used();
c70a245cad3a 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 0
diff changeset
142 long free_size = free();
c70a245cad3a 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 0
diff changeset
143 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
144 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
145 tty.print("free= " + free_size );
c70a245cad3a 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 0
diff changeset
146 tty.print("\n");
c70a245cad3a 6670684: 4/5 SA command universe did not print out CMS space information
dcubed
parents: 0
diff changeset
147
0
a61af66fc99e Initial load
duke
parents:
diff changeset
148 }
a61af66fc99e Initial load
duke
parents:
diff changeset
149
a61af66fc99e Initial load
duke
parents:
diff changeset
150 public Address skipBlockSizeUsingPrintezisBits(Address pos) {
a61af66fc99e Initial load
duke
parents:
diff changeset
151 CMSCollector collector = collector();
a61af66fc99e Initial load
duke
parents:
diff changeset
152 long size = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
153 Address addr = null;
a61af66fc99e Initial load
duke
parents:
diff changeset
154
a61af66fc99e Initial load
duke
parents:
diff changeset
155 if (collector != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
156 size = collector.blockSizeUsingPrintezisBits(pos);
a61af66fc99e Initial load
duke
parents:
diff changeset
157 if (size >= 3) {
a61af66fc99e Initial load
duke
parents:
diff changeset
158 addr = pos.addOffsetTo(adjustObjectSizeInBytes(size));
a61af66fc99e Initial load
duke
parents:
diff changeset
159 }
a61af66fc99e Initial load
duke
parents:
diff changeset
160 }
a61af66fc99e Initial load
duke
parents:
diff changeset
161 return addr;
a61af66fc99e Initial load
duke
parents:
diff changeset
162 }
a61af66fc99e Initial load
duke
parents:
diff changeset
163
a61af66fc99e Initial load
duke
parents:
diff changeset
164 public List/*<MemRegion>*/ getLiveRegions() {
a61af66fc99e Initial load
duke
parents:
diff changeset
165 List res = new ArrayList(); // List<MemRegion>
a61af66fc99e Initial load
duke
parents:
diff changeset
166 VM vm = VM.getVM();
a61af66fc99e Initial load
duke
parents:
diff changeset
167 Debugger dbg = vm.getDebugger();
a61af66fc99e Initial load
duke
parents:
diff changeset
168 ObjectHeap heap = vm.getObjectHeap();
a61af66fc99e Initial load
duke
parents:
diff changeset
169 Address cur = bottom();
a61af66fc99e Initial load
duke
parents:
diff changeset
170 Address regionStart = cur;
a61af66fc99e Initial load
duke
parents:
diff changeset
171 Address limit = end();
a61af66fc99e Initial load
duke
parents:
diff changeset
172 final long addressSize = vm.getAddressSize();
a61af66fc99e Initial load
duke
parents:
diff changeset
173
a61af66fc99e Initial load
duke
parents:
diff changeset
174 for (; cur.lessThan(limit);) {
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 2042
diff changeset
175 Address k = cur.getAddressAt(addressSize);
187
790e66e5fbac 6687581: Make CMS work with compressed oops
coleenp
parents: 0
diff changeset
176 if (FreeChunk.indicatesFreeChunk(cur)) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
177 if (! cur.equals(regionStart)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
178 res.add(new MemRegion(regionStart, cur));
a61af66fc99e Initial load
duke
parents:
diff changeset
179 }
a61af66fc99e Initial load
duke
parents:
diff changeset
180 FreeChunk fc = (FreeChunk) VMObjectFactory.newObject(FreeChunk.class, cur);
a61af66fc99e Initial load
duke
parents:
diff changeset
181 long chunkSize = fc.size();
a61af66fc99e Initial load
duke
parents:
diff changeset
182 if (Assert.ASSERTS_ENABLED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
183 Assert.that(chunkSize > 0, "invalid FreeChunk size");
a61af66fc99e Initial load
duke
parents:
diff changeset
184 }
a61af66fc99e Initial load
duke
parents:
diff changeset
185 // note that fc.size() gives chunk size in heap words
a61af66fc99e Initial load
duke
parents:
diff changeset
186 cur = cur.addOffsetTo(chunkSize * addressSize);
a61af66fc99e Initial load
duke
parents:
diff changeset
187 regionStart = cur;
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 2042
diff changeset
188 } else if (k != null) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
189 Oop obj = heap.newOop(cur.addOffsetToAsOopHandle(0));
a61af66fc99e Initial load
duke
parents:
diff changeset
190 long objectSize = obj.getObjectSize();
a61af66fc99e Initial load
duke
parents:
diff changeset
191 cur = cur.addOffsetTo(adjustObjectSizeInBytes(objectSize));
904
ef671fb22f73 6868051: (SA) FreeChunk support for compressed oops is broken
never
parents: 196
diff changeset
192 } else {
ef671fb22f73 6868051: (SA) FreeChunk support for compressed oops is broken
never
parents: 196
diff changeset
193 // FIXME: need to do a better job here.
ef671fb22f73 6868051: (SA) FreeChunk support for compressed oops is broken
never
parents: 196
diff changeset
194 // can I use bitMap here?
ef671fb22f73 6868051: (SA) FreeChunk support for compressed oops is broken
never
parents: 196
diff changeset
195 //Find the object size using Printezis bits and skip over
ef671fb22f73 6868051: (SA) FreeChunk support for compressed oops is broken
never
parents: 196
diff changeset
196 long size = collector().blockSizeUsingPrintezisBits(cur);
ef671fb22f73 6868051: (SA) FreeChunk support for compressed oops is broken
never
parents: 196
diff changeset
197 if (size == -1) {
ef671fb22f73 6868051: (SA) FreeChunk support for compressed oops is broken
never
parents: 196
diff changeset
198 break;
ef671fb22f73 6868051: (SA) FreeChunk support for compressed oops is broken
never
parents: 196
diff changeset
199 }
ef671fb22f73 6868051: (SA) FreeChunk support for compressed oops is broken
never
parents: 196
diff changeset
200 cur = cur.addOffsetTo(adjustObjectSizeInBytes(size));
0
a61af66fc99e Initial load
duke
parents:
diff changeset
201 }
a61af66fc99e Initial load
duke
parents:
diff changeset
202 }
a61af66fc99e Initial load
duke
parents:
diff changeset
203 return res;
a61af66fc99e Initial load
duke
parents:
diff changeset
204 }
a61af66fc99e Initial load
duke
parents:
diff changeset
205
a61af66fc99e Initial load
duke
parents:
diff changeset
206 //-- Internals only below this point
a61af66fc99e Initial load
duke
parents:
diff changeset
207
a61af66fc99e Initial load
duke
parents:
diff changeset
208 // Unlike corresponding VM code, we operate on byte size rather than
a61af66fc99e Initial load
duke
parents:
diff changeset
209 // HeapWord size for convenience.
a61af66fc99e Initial load
duke
parents:
diff changeset
210
a61af66fc99e Initial load
duke
parents:
diff changeset
211 private static long numQuanta(long x, long y) {
a61af66fc99e Initial load
duke
parents:
diff changeset
212 return ((x+y-1)/y);
a61af66fc99e Initial load
duke
parents:
diff changeset
213 }
a61af66fc99e Initial load
duke
parents:
diff changeset
214
a61af66fc99e Initial load
duke
parents:
diff changeset
215 public static long adjustObjectSizeInBytes(long sizeInBytes) {
a61af66fc99e Initial load
duke
parents:
diff changeset
216 return Oop.alignObjectSize(Math.max(sizeInBytes, MinChunkSizeInBytes));
a61af66fc99e Initial load
duke
parents:
diff changeset
217 }
a61af66fc99e Initial load
duke
parents:
diff changeset
218
a61af66fc99e Initial load
duke
parents:
diff changeset
219 // FIXME: should I read this directly from VM?
a61af66fc99e Initial load
duke
parents:
diff changeset
220 private static long MinChunkSizeInBytes;
a61af66fc99e Initial load
duke
parents:
diff changeset
221 }