174 res.add(new MemRegion(regionStart, cur));
175 }
176 FreeChunk fc = (FreeChunk) VMObjectFactory.newObject(FreeChunk.class, cur);
177 long chunkSize = fc.size();
178 if (Assert.ASSERTS_ENABLED) {
179 Assert.that(chunkSize > 0, "invalid FreeChunk size");
180 }
181 // note that fc.size() gives chunk size in heap words
182 cur = cur.addOffsetTo(chunkSize * addressSize);
183 regionStart = cur;
184 } else if (k != null) {
185 Oop obj = heap.newOop(cur.addOffsetToAsOopHandle(0));
186 long objectSize = obj.getObjectSize();
187 cur = cur.addOffsetTo(adjustObjectSizeInBytes(objectSize));
188 } else {
189 // FIXME: need to do a better job here.
190 // can I use bitMap here?
191 //Find the object size using Printezis bits and skip over
192 long size = collector().blockSizeUsingPrintezisBits(cur);
193 if (size == -1) {
194 System.err.println("Printezis bits not set...");
195 break;
196 }
197 cur = cur.addOffsetTo(adjustObjectSizeInBytes(size));
198 }
199 }
200 return res;
201 }
202
203 //-- Internals only below this point
204
205 // Unlike corresponding VM code, we operate on byte size rather than
206 // HeapWord size for convenience.
207
208 private static long numQuanta(long x, long y) {
209 return ((x+y-1)/y);
210 }
211
212 public static long adjustObjectSizeInBytes(long sizeInBytes) {
213 return Oop.alignObjectSize(Math.max(sizeInBytes, MinChunkSizeInBytes));
214 }
|
174 res.add(new MemRegion(regionStart, cur));
175 }
176 FreeChunk fc = (FreeChunk) VMObjectFactory.newObject(FreeChunk.class, cur);
177 long chunkSize = fc.size();
178 if (Assert.ASSERTS_ENABLED) {
179 Assert.that(chunkSize > 0, "invalid FreeChunk size");
180 }
181 // note that fc.size() gives chunk size in heap words
182 cur = cur.addOffsetTo(chunkSize * addressSize);
183 regionStart = cur;
184 } else if (k != null) {
185 Oop obj = heap.newOop(cur.addOffsetToAsOopHandle(0));
186 long objectSize = obj.getObjectSize();
187 cur = cur.addOffsetTo(adjustObjectSizeInBytes(objectSize));
188 } else {
189 // FIXME: need to do a better job here.
190 // can I use bitMap here?
191 //Find the object size using Printezis bits and skip over
192 long size = collector().blockSizeUsingPrintezisBits(cur);
193 if (size == -1) {
194 break;
195 }
196 cur = cur.addOffsetTo(adjustObjectSizeInBytes(size));
197 }
198 }
199 return res;
200 }
201
202 //-- Internals only below this point
203
204 // Unlike corresponding VM code, we operate on byte size rather than
205 // HeapWord size for convenience.
206
207 private static long numQuanta(long x, long y) {
208 return ((x+y-1)/y);
209 }
210
211 public static long adjustObjectSizeInBytes(long sizeInBytes) {
212 return Oop.alignObjectSize(Math.max(sizeInBytes, MinChunkSizeInBytes));
213 }
|