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/dictionary.hpp"
27 #include "classfile/systemDictionary.hpp"
28 #include "memory/iterator.hpp"
29 #include "oops/oop.inline.hpp"
30 #include "prims/jvmtiRedefineClassesTrace.hpp"
31 #include "runtime/orderAccess.inline.hpp"
32 #include "utilities/hashtable.inline.hpp"
33
34 DictionaryEntry* Dictionary::_current_class_entry = NULL;
35 int Dictionary::_current_class_index = 0;
36
37
38 Dictionary::Dictionary(int table_size)
39 : TwoOopHashtable<Klass*, mtClass>(table_size, sizeof(DictionaryEntry)) {
40 _current_class_index = 0;
41 _current_class_entry = NULL;
42 _pd_cache_table = new ProtectionDomainCacheTable(defaultProtectionDomainCacheSize);
43 };
44
45
46 Dictionary::Dictionary(int table_size, HashtableBucket<mtClass>* t,
47 int number_of_entries)
48 : TwoOopHashtable<Klass*, mtClass>(table_size, sizeof(DictionaryEntry), t, number_of_entries) {
49 _current_class_index = 0;
50 _current_class_entry = NULL;
51 _pd_cache_table = new ProtectionDomainCacheTable(defaultProtectionDomainCacheSize);
52 };
53
54 ProtectionDomainCacheEntry* Dictionary::cache_get(oop protection_domain) {
55 return _pd_cache_table->get(protection_domain);
56 }
57
58 DictionaryEntry* Dictionary::new_entry(unsigned int hash, Klass* klass,
59 ClassLoaderData* loader_data) {
60 DictionaryEntry* entry = (DictionaryEntry*)Hashtable<Klass*, mtClass>::new_entry(hash, klass);
61 entry->set_loader_data(loader_data);
62 entry->set_pd_set(NULL);
63 assert(klass->is_instance_klass(), "Must be");
64 return entry;
65 }
66
67
68 void Dictionary::free_entry(DictionaryEntry* entry) {
69 // avoid recursion when deleting linked list
70 while (entry->pd_set() != NULL) {
71 ProtectionDomainEntry* to_delete = entry->pd_set();
72 entry->set_pd_set(to_delete->next());
73 delete to_delete;
74 }
75 Hashtable<Klass*, mtClass>::free_entry(entry);
76 }
77
78
79 bool DictionaryEntry::contains_protection_domain(oop protection_domain) const {
80 #ifdef ASSERT
81 if (protection_domain == klass()->protection_domain()) {
82 // Ensure this doesn't show up in the pd_set (invariant)
83 bool in_pd_set = false;
|
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 }
46
47 Dictionary::Dictionary(int table_size)
48 : TwoOopHashtable<Klass*, mtClass>(table_size, (int)entry_size()) {
49 _current_class_index = 0;
50 _current_class_entry = NULL;
51 _pd_cache_table = new ProtectionDomainCacheTable(defaultProtectionDomainCacheSize);
52 };
53
54
55 Dictionary::Dictionary(int table_size, HashtableBucket<mtClass>* t,
56 int number_of_entries)
57 : TwoOopHashtable<Klass*, mtClass>(table_size, (int)entry_size(), t, number_of_entries) {
58 _current_class_index = 0;
59 _current_class_entry = NULL;
60 _pd_cache_table = new ProtectionDomainCacheTable(defaultProtectionDomainCacheSize);
61 };
62
63 ProtectionDomainCacheEntry* Dictionary::cache_get(oop protection_domain) {
64 return _pd_cache_table->get(protection_domain);
65 }
66
67 DictionaryEntry* Dictionary::new_entry(unsigned int hash, Klass* klass,
68 ClassLoaderData* loader_data) {
69 DictionaryEntry* entry = (DictionaryEntry*)Hashtable<Klass*, mtClass>::new_entry(hash, klass);
70 entry->set_loader_data(loader_data);
71 entry->set_pd_set(NULL);
72 assert(klass->is_instance_klass(), "Must be");
73 if (DumpSharedSpaces) {
74 SystemDictionaryShared::init_shared_dictionary_entry(klass, entry);
75 }
76 return entry;
77 }
78
79
80 void Dictionary::free_entry(DictionaryEntry* entry) {
81 // avoid recursion when deleting linked list
82 while (entry->pd_set() != NULL) {
83 ProtectionDomainEntry* to_delete = entry->pd_set();
84 entry->set_pd_set(to_delete->next());
85 delete to_delete;
86 }
87 Hashtable<Klass*, mtClass>::free_entry(entry);
88 }
89
90
91 bool DictionaryEntry::contains_protection_domain(oop protection_domain) const {
92 #ifdef ASSERT
93 if (protection_domain == klass()->protection_domain()) {
94 // Ensure this doesn't show up in the pd_set (invariant)
95 bool in_pd_set = false;
|