1 /*
2 * Copyright (c) 2003, 2015, 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 *
179 // The amount of different protection domains used is typically magnitudes smaller
180 // than the number of system dictionary entries (loaded classes).
181 class ProtectionDomainCacheTable : public Hashtable<oop, mtClass> {
182 friend class VMStructs;
183 private:
184 ProtectionDomainCacheEntry* bucket(int i) {
185 return (ProtectionDomainCacheEntry*) Hashtable<oop, mtClass>::bucket(i);
186 }
187
188 // The following method is not MT-safe and must be done under lock.
189 ProtectionDomainCacheEntry** bucket_addr(int i) {
190 return (ProtectionDomainCacheEntry**) Hashtable<oop, mtClass>::bucket_addr(i);
191 }
192
193 ProtectionDomainCacheEntry* new_entry(unsigned int hash, oop protection_domain) {
194 ProtectionDomainCacheEntry* entry = (ProtectionDomainCacheEntry*) Hashtable<oop, mtClass>::new_entry(hash, protection_domain);
195 entry->init();
196 return entry;
197 }
198
199 static unsigned int compute_hash(oop protection_domain) {
200 return (unsigned int)(protection_domain->identity_hash());
201 }
202
203 int index_for(oop protection_domain) {
204 return hash_to_index(compute_hash(protection_domain));
205 }
206
207 ProtectionDomainCacheEntry* add_entry(int index, unsigned int hash, oop protection_domain);
208 ProtectionDomainCacheEntry* find_entry(int index, oop protection_domain);
209
210 public:
211
212 ProtectionDomainCacheTable(int table_size);
213
214 ProtectionDomainCacheEntry* get(oop protection_domain);
215 void free(ProtectionDomainCacheEntry* entry);
216
217 void unlink(BoolObjectClosure* cl);
218
219 // GC support
220 void oops_do(OopClosure* f);
221 void always_strong_oops_do(OopClosure* f);
222 void roots_oops_do(OopClosure* strong, OopClosure* weak);
223
224 static uint bucket_size();
225
226 void print() PRODUCT_RETURN;
|
1 /*
2 * Copyright (c) 2003, 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 *
179 // The amount of different protection domains used is typically magnitudes smaller
180 // than the number of system dictionary entries (loaded classes).
181 class ProtectionDomainCacheTable : public Hashtable<oop, mtClass> {
182 friend class VMStructs;
183 private:
184 ProtectionDomainCacheEntry* bucket(int i) {
185 return (ProtectionDomainCacheEntry*) Hashtable<oop, mtClass>::bucket(i);
186 }
187
188 // The following method is not MT-safe and must be done under lock.
189 ProtectionDomainCacheEntry** bucket_addr(int i) {
190 return (ProtectionDomainCacheEntry**) Hashtable<oop, mtClass>::bucket_addr(i);
191 }
192
193 ProtectionDomainCacheEntry* new_entry(unsigned int hash, oop protection_domain) {
194 ProtectionDomainCacheEntry* entry = (ProtectionDomainCacheEntry*) Hashtable<oop, mtClass>::new_entry(hash, protection_domain);
195 entry->init();
196 return entry;
197 }
198
199 static unsigned int compute_hash(oop protection_domain);
200
201 int index_for(oop protection_domain);
202 ProtectionDomainCacheEntry* add_entry(int index, unsigned int hash, oop protection_domain);
203 ProtectionDomainCacheEntry* find_entry(int index, oop protection_domain);
204
205 public:
206
207 ProtectionDomainCacheTable(int table_size);
208
209 ProtectionDomainCacheEntry* get(oop protection_domain);
210 void free(ProtectionDomainCacheEntry* entry);
211
212 void unlink(BoolObjectClosure* cl);
213
214 // GC support
215 void oops_do(OopClosure* f);
216 void always_strong_oops_do(OopClosure* f);
217 void roots_oops_do(OopClosure* strong, OopClosure* weak);
218
219 static uint bucket_size();
220
221 void print() PRODUCT_RETURN;
|