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 *
23 */
24
25 #include "precompiled.hpp"
26 #include "classfile/sharedClassUtil.hpp"
27 #include "classfile/dictionary.hpp"
28 #include "classfile/systemDictionary.hpp"
29 #include "classfile/systemDictionaryShared.hpp"
30 #include "memory/iterator.hpp"
31 #include "oops/oop.inline.hpp"
32 #include "prims/jvmtiRedefineClassesTrace.hpp"
33 #include "runtime/orderAccess.inline.hpp"
34 #include "utilities/hashtable.inline.hpp"
35
36 DictionaryEntry* Dictionary::_current_class_entry = NULL;
37 int Dictionary::_current_class_index = 0;
38
39 size_t Dictionary::entry_size() {
40 if (DumpSharedSpaces) {
41 return SystemDictionaryShared::dictionary_entry_size();
42 } else {
43 return sizeof(DictionaryEntry);
44 }
45 }
481 p = tmp;
482 }
483 set_entry(i, NULL);
484 }
485
486 // Add the dictionary entries back to the list in the correct buckets.
487 while (master_list != NULL) {
488 DictionaryEntry* p = master_list;
489 master_list = master_list->next();
490 p->set_next(NULL);
491 Symbol* class_name = p->klass()->name();
492 // Since the null class loader data isn't copied to the CDS archive,
493 // compute the hash with NULL for loader data.
494 unsigned int hash = compute_hash(class_name, NULL);
495 int index = hash_to_index(hash);
496 p->set_hash(hash);
497 p->set_loader_data(NULL); // loader_data isn't copied to CDS
498 p->set_next(bucket(index));
499 set_entry(index, p);
500 }
501 }
502
503 ProtectionDomainCacheTable::ProtectionDomainCacheTable(int table_size)
504 : Hashtable<oop, mtClass>(table_size, sizeof(ProtectionDomainCacheEntry))
505 {
506 }
507
508 void ProtectionDomainCacheTable::unlink(BoolObjectClosure* is_alive) {
509 assert(SafepointSynchronize::is_at_safepoint(), "must be");
510 for (int i = 0; i < table_size(); ++i) {
511 ProtectionDomainCacheEntry** p = bucket_addr(i);
512 ProtectionDomainCacheEntry* entry = bucket(i);
513 while (entry != NULL) {
514 if (is_alive->do_object_b(entry->literal())) {
515 p = entry->next_addr();
516 } else {
517 *p = entry->next();
518 free_entry(entry);
519 }
520 entry = *p;
|
1
2 /*
3 * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 *
6 * This code is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 only, as
8 * published by the Free Software Foundation.
9 *
10 * This code is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * version 2 for more details (a copy is included in the LICENSE file that
14 * accompanied this code).
15 *
16 * You should have received a copy of the GNU General Public License version
17 * 2 along with this work; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19 *
20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21 * or visit www.oracle.com if you need additional information or have any
22 * questions.
23 *
24 */
25
26 #include "precompiled.hpp"
27 #include "classfile/classLoaderData.inline.hpp"
28 #include "classfile/sharedClassUtil.hpp"
29 #include "classfile/dictionary.hpp"
30 #include "classfile/systemDictionary.hpp"
31 #include "classfile/systemDictionaryShared.hpp"
32 #include "memory/iterator.hpp"
33 #include "oops/oop.inline.hpp"
34 #include "prims/jvmtiRedefineClassesTrace.hpp"
35 #include "runtime/orderAccess.inline.hpp"
36 #include "utilities/hashtable.inline.hpp"
37
38 DictionaryEntry* Dictionary::_current_class_entry = NULL;
39 int Dictionary::_current_class_index = 0;
40
41 size_t Dictionary::entry_size() {
42 if (DumpSharedSpaces) {
43 return SystemDictionaryShared::dictionary_entry_size();
44 } else {
45 return sizeof(DictionaryEntry);
46 }
47 }
483 p = tmp;
484 }
485 set_entry(i, NULL);
486 }
487
488 // Add the dictionary entries back to the list in the correct buckets.
489 while (master_list != NULL) {
490 DictionaryEntry* p = master_list;
491 master_list = master_list->next();
492 p->set_next(NULL);
493 Symbol* class_name = p->klass()->name();
494 // Since the null class loader data isn't copied to the CDS archive,
495 // compute the hash with NULL for loader data.
496 unsigned int hash = compute_hash(class_name, NULL);
497 int index = hash_to_index(hash);
498 p->set_hash(hash);
499 p->set_loader_data(NULL); // loader_data isn't copied to CDS
500 p->set_next(bucket(index));
501 set_entry(index, p);
502 }
503 }
504
505
506 unsigned int ProtectionDomainCacheTable::compute_hash(oop protection_domain) {
507 return (unsigned int)(protection_domain->identity_hash());
508 }
509
510 int ProtectionDomainCacheTable::index_for(oop protection_domain) {
511 return hash_to_index(compute_hash(protection_domain));
512 }
513
514 ProtectionDomainCacheTable::ProtectionDomainCacheTable(int table_size)
515 : Hashtable<oop, mtClass>(table_size, sizeof(ProtectionDomainCacheEntry))
516 {
517 }
518
519 void ProtectionDomainCacheTable::unlink(BoolObjectClosure* is_alive) {
520 assert(SafepointSynchronize::is_at_safepoint(), "must be");
521 for (int i = 0; i < table_size(); ++i) {
522 ProtectionDomainCacheEntry** p = bucket_addr(i);
523 ProtectionDomainCacheEntry* entry = bucket(i);
524 while (entry != NULL) {
525 if (is_alive->do_object_b(entry->literal())) {
526 p = entry->next_addr();
527 } else {
528 *p = entry->next();
529 free_entry(entry);
530 }
531 entry = *p;
|