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 *
23 */
24
25 #include "precompiled.hpp"
26 #include "classfile/protectionDomainCache.hpp"
27 #include "classfile/systemDictionary.hpp"
28 #include "memory/iterator.hpp"
29 #include "memory/resourceArea.hpp"
30 #include "oops/oop.inline.hpp"
31 #include "utilities/hashtable.inline.hpp"
32
33 unsigned int ProtectionDomainCacheTable::compute_hash(Handle protection_domain) {
34 // Identity hash can safepoint, so keep protection domain in a Handle.
35 return (unsigned int)(protection_domain->identity_hash());
36 }
37
38 int ProtectionDomainCacheTable::index_for(Handle protection_domain) {
39 return hash_to_index(compute_hash(protection_domain));
40 }
41
42 ProtectionDomainCacheTable::ProtectionDomainCacheTable(int table_size)
43 : Hashtable<oop, mtClass>(table_size, sizeof(ProtectionDomainCacheEntry))
44 {
45 }
46
47 void ProtectionDomainCacheTable::unlink(BoolObjectClosure* is_alive) {
48 assert(SafepointSynchronize::is_at_safepoint(), "must be");
49 for (int i = 0; i < table_size(); ++i) {
50 ProtectionDomainCacheEntry** p = bucket_addr(i);
51 ProtectionDomainCacheEntry* entry = bucket(i);
52 while (entry != NULL) {
53 if (is_alive->do_object_b(entry->literal())) {
54 p = entry->next_addr();
55 } else {
56 if (log_is_enabled(Debug, protectiondomain)) {
57 outputStream* log = Log(protectiondomain)::debug_stream();
58 log->print("protection domain unlinked: ");
59 entry->literal()->print_value_on(log);
60 log->cr();
61 }
62 *p = entry->next();
63 free_entry(entry);
64 }
65 entry = *p;
66 }
67 }
68 }
69
70 void ProtectionDomainCacheTable::oops_do(OopClosure* f) {
71 for (int index = 0; index < table_size(); index++) {
72 for (ProtectionDomainCacheEntry* probe = bucket(index);
73 probe != NULL;
74 probe = probe->next()) {
75 probe->oops_do(f);
76 }
77 }
78 }
79
80 #ifndef PRODUCT
|
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 *
23 */
24
25 #include "precompiled.hpp"
26 #include "classfile/protectionDomainCache.hpp"
27 #include "classfile/systemDictionary.hpp"
28 #include "logging/log.hpp"
29 #include "logging/logStream.hpp"
30 #include "memory/iterator.hpp"
31 #include "memory/resourceArea.hpp"
32 #include "oops/oop.inline.hpp"
33 #include "utilities/hashtable.inline.hpp"
34
35 unsigned int ProtectionDomainCacheTable::compute_hash(Handle protection_domain) {
36 // Identity hash can safepoint, so keep protection domain in a Handle.
37 return (unsigned int)(protection_domain->identity_hash());
38 }
39
40 int ProtectionDomainCacheTable::index_for(Handle protection_domain) {
41 return hash_to_index(compute_hash(protection_domain));
42 }
43
44 ProtectionDomainCacheTable::ProtectionDomainCacheTable(int table_size)
45 : Hashtable<oop, mtClass>(table_size, sizeof(ProtectionDomainCacheEntry))
46 {
47 }
48
49 void ProtectionDomainCacheTable::unlink(BoolObjectClosure* is_alive) {
50 assert(SafepointSynchronize::is_at_safepoint(), "must be");
51 for (int i = 0; i < table_size(); ++i) {
52 ProtectionDomainCacheEntry** p = bucket_addr(i);
53 ProtectionDomainCacheEntry* entry = bucket(i);
54 while (entry != NULL) {
55 if (is_alive->do_object_b(entry->literal())) {
56 p = entry->next_addr();
57 } else {
58 LogTarget(Debug, protectiondomain) lt;
59 if (lt.is_enabled()) {
60 LogStream ls(lt);
61 ls.print("protection domain unlinked: ");
62 entry->literal()->print_value_on(&ls);
63 ls.cr();
64 }
65 *p = entry->next();
66 free_entry(entry);
67 }
68 entry = *p;
69 }
70 }
71 }
72
73 void ProtectionDomainCacheTable::oops_do(OopClosure* f) {
74 for (int index = 0; index < table_size(); index++) {
75 for (ProtectionDomainCacheEntry* probe = bucket(index);
76 probe != NULL;
77 probe = probe->next()) {
78 probe->oops_do(f);
79 }
80 }
81 }
82
83 #ifndef PRODUCT
|