1 /*
2 * Copyright (c) 2015, 2016, 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 *
102 if (sym.equals(name)) {
103 return sym;
104 }
105 } else {
106 Address entryMax = entriesField.getValue(addr).addOffsetTo(nextBucketOffset * uintSize);
107 while (entry.lessThan(entryMax)) {
108 long symHash = entry.getCIntegerAt(0, uintSize, true);
109 if (symHash == hash) {
110 symOffset = entry.getCIntegerAt(uintSize, uintSize, true);
111 Address symAddr = baseAddress.addOffsetTo(symOffset);
112 sym = Symbol.create(symAddr);
113 if (sym.equals(name)) {
114 return sym;
115 }
116 }
117 entry = entry.addOffsetTo(2 * uintSize);
118 }
119 }
120 return null;
121 }
122 }
|
1 /*
2 * Copyright (c) 2015, 2018, 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 *
102 if (sym.equals(name)) {
103 return sym;
104 }
105 } else {
106 Address entryMax = entriesField.getValue(addr).addOffsetTo(nextBucketOffset * uintSize);
107 while (entry.lessThan(entryMax)) {
108 long symHash = entry.getCIntegerAt(0, uintSize, true);
109 if (symHash == hash) {
110 symOffset = entry.getCIntegerAt(uintSize, uintSize, true);
111 Address symAddr = baseAddress.addOffsetTo(symOffset);
112 sym = Symbol.create(symAddr);
113 if (sym.equals(name)) {
114 return sym;
115 }
116 }
117 entry = entry.addOffsetTo(2 * uintSize);
118 }
119 }
120 return null;
121 }
122
123 public interface SymbolVisitor {
124 public void visit(Symbol sym);
125 }
126
127 public void symbolsDo(SymbolVisitor visitor) {
128 long symOffset;
129 Symbol sym;
130 Address baseAddress = baseAddressField.getValue(addr);
131 Address bucket = bucketsField.getValue(addr);
132 for (long index = 0; index < bucketCount(); index++) {
133 int bucketInfo = (int)bucket.getCIntegerAt(index * uintSize, uintSize, true);
134 int bucketOffset = bucketOffset(bucketInfo);
135 int nextBucketInfo = (int)bucket.getCIntegerAt((index+1) * uintSize, uintSize, true);
136 int nextBucketOffset = bucketOffset(nextBucketInfo);
137
138 Address entry = entriesField.getValue(addr).addOffsetTo(bucketOffset * uintSize);
139
140 if (isValueOnlyBucket(bucketInfo)) {
141 symOffset = entry.getCIntegerAt(0, uintSize, true);
142 sym = Symbol.create(baseAddress.addOffsetTo(symOffset));
143 visitor.visit(sym);
144 } else {
145 Address entryMax = entriesField.getValue(addr).addOffsetTo(nextBucketOffset * uintSize);
146 while (entry.lessThan(entryMax)) {
147 symOffset = entry.getCIntegerAt(uintSize, uintSize, true);
148 Address symAddr = baseAddress.addOffsetTo(symOffset);
149 sym = Symbol.create(symAddr);
150 visitor.visit(sym);
151 entry = entry.addOffsetTo(2 * uintSize);
152 }
153 }
154 }
155 }
156 }
157
|