1 /*
2 * Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
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 }
|
1 /*
2 * Copyright (c) 2001, 2017, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
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 // advance to next block
113 blockAddr = block.freeNext();
114 if (blockAddr == null) {
115 throw new NoSuchElementException();
116 }
117 block = new ObjectMonitor(blockAddr);
118 index = blockSize - 1;
119 }
120 addr = blockAddr.addOffsetTo(index*objectMonitorTypeSize);
121 index --;
122 return new ObjectMonitor(addr);
123 }
124
125 public void remove() {
126 throw new UnsupportedOperationException();
127 }
128
129 private ObjectMonitor block;
130 private int index;
131 private Address blockAddr;
132 }
133
134 private static Address gBlockListAddr;
135 private static int blockSize;
136 private static int defaultCacheLineSize;
137 private static long objectMonitorTypeSize;
138
139 }
|