6 import sun.jvm.hotspot.utilities.BitMap;
7 import sun.jvm.hotspot.utilities.BitMapInterface;
8
9 /** Discontiguous bitmap for ZGC. */
10 public class ZExternalBitMap implements BitMapInterface {
11 private ZPageTable pageTable;
12 private final long oopSize;
13
14 private HashMap<ZPage, BitMap> pageToBitMap = new HashMap<ZPage, BitMap>();
15
16 public ZExternalBitMap(ZCollectedHeap collectedHeap) {
17 pageTable = collectedHeap.heap().pageTable();
18 oopSize = VM.getVM().getOopSize();
19 }
20
21 private ZPage getPage(long zOffset) {
22 if (zOffset > ZGlobals.ZAddressOffsetMask) {
23 throw new RuntimeException("Not a Z offset: " + zOffset);
24 }
25
26 ZPage page = pageTable.get(ZOop.to_address(zOffset));
27 if (page == null) {
28 throw new RuntimeException("Address not in pageTable: " + zOffset);
29 }
30 return page;
31 }
32
33 private BitMap getOrAddBitMap(ZPage page) {
34 BitMap bitMap = pageToBitMap.get(page);
35 if (bitMap == null) {
36 long size = page.size();
37
38 long maxNumObjects = size >>> page.object_alignment_shift();
39 if (maxNumObjects > Integer.MAX_VALUE) {
40 throw new RuntimeException("int overflow");
41 }
42 int intMaxNumObjects = (int)maxNumObjects;
43
44 bitMap = new BitMap(intMaxNumObjects);
45 pageToBitMap.put(page, bitMap);
46 }
|
6 import sun.jvm.hotspot.utilities.BitMap;
7 import sun.jvm.hotspot.utilities.BitMapInterface;
8
9 /** Discontiguous bitmap for ZGC. */
10 public class ZExternalBitMap implements BitMapInterface {
11 private ZPageTable pageTable;
12 private final long oopSize;
13
14 private HashMap<ZPage, BitMap> pageToBitMap = new HashMap<ZPage, BitMap>();
15
16 public ZExternalBitMap(ZCollectedHeap collectedHeap) {
17 pageTable = collectedHeap.heap().pageTable();
18 oopSize = VM.getVM().getOopSize();
19 }
20
21 private ZPage getPage(long zOffset) {
22 if (zOffset > ZGlobals.ZAddressOffsetMask) {
23 throw new RuntimeException("Not a Z offset: " + zOffset);
24 }
25
26 ZPage page = pageTable.get(ZUtils.longToAddress(zOffset));
27 if (page == null) {
28 throw new RuntimeException("Address not in pageTable: " + zOffset);
29 }
30 return page;
31 }
32
33 private BitMap getOrAddBitMap(ZPage page) {
34 BitMap bitMap = pageToBitMap.get(page);
35 if (bitMap == null) {
36 long size = page.size();
37
38 long maxNumObjects = size >>> page.object_alignment_shift();
39 if (maxNumObjects > Integer.MAX_VALUE) {
40 throw new RuntimeException("int overflow");
41 }
42 int intMaxNumObjects = (int)maxNumObjects;
43
44 bitMap = new BitMap(intMaxNumObjects);
45 pageToBitMap.put(page, bitMap);
46 }
|