91 } 92 } 93 94 private static class ObjectMonitorIterator implements Iterator { 95 96 // JVMTI raw monitors are not pointed by gBlockList 97 // and are not included by this Iterator. May add them later. 98 99 ObjectMonitorIterator() { 100 blockAddr = gBlockListAddr; 101 index = blockSize - 1; 102 block = new ObjectMonitor(blockAddr); 103 } 104 105 public boolean hasNext() { 106 return (index > 0 || block.freeNext() != null); 107 } 108 109 public Object next() { 110 Address addr; 111 if (index > 0) { 112 addr = blockAddr.addOffsetTo(index*objectMonitorTypeSize); 113 } else { 114 blockAddr = block.freeNext(); 115 index = blockSize - 1; 116 addr = blockAddr.addOffsetTo(index*objectMonitorTypeSize); 117 } 118 index --; 119 return new ObjectMonitor(addr); 120 } 121 122 public void remove() { 123 throw new UnsupportedOperationException(); 124 } 125 126 private ObjectMonitor block; 127 private int index; 128 private Address blockAddr; 129 } 130 131 private static Address gBlockListAddr; 132 private static int blockSize; 133 private static int defaultCacheLineSize; 134 private static long objectMonitorTypeSize; 135 136 } | 91 } 92 } 93 94 private static class ObjectMonitorIterator implements Iterator { 95 96 // JVMTI raw monitors are not pointed by gBlockList 97 // and are not included by this Iterator. May add them later. 98 99 ObjectMonitorIterator() { 100 blockAddr = gBlockListAddr; 101 index = blockSize - 1; 102 block = new ObjectMonitor(blockAddr); 103 } 104 105 public boolean hasNext() { 106 return (index > 0 || block.freeNext() != null); 107 } 108 109 public Object next() { 110 Address addr; 111 if (index == 0) { 112 blockAddr = block.freeNext(); 113 block = new ObjectMonitor(blockAddr); 114 index = blockSize - 1; 115 } 116 addr = blockAddr.addOffsetTo(index*objectMonitorTypeSize); 117 index --; 118 return new ObjectMonitor(addr); 119 } 120 121 public void remove() { 122 throw new UnsupportedOperationException(); 123 } 124 125 private ObjectMonitor block; 126 private int index; 127 private Address blockAddr; 128 } 129 130 private static Address gBlockListAddr; 131 private static int blockSize; 132 private static int defaultCacheLineSize; 133 private static long objectMonitorTypeSize; 134 135 } |