comparison src/share/vm/classfile/resolutionErrors.cpp @ 2181:d25d4ca69222

Merge.
author Thomas Wuerthinger <wuerthinger@ssw.jku.at>
date Wed, 16 Feb 2011 13:47:20 +0100
parents 3582bf76420e
children 1d1603768966
comparison
equal deleted inserted replaced
2108:50b45e2d9725 2181:d25d4ca69222
30 #include "runtime/safepoint.hpp" 30 #include "runtime/safepoint.hpp"
31 #include "utilities/hashtable.inline.hpp" 31 #include "utilities/hashtable.inline.hpp"
32 32
33 // add new entry to the table 33 // add new entry to the table
34 void ResolutionErrorTable::add_entry(int index, unsigned int hash, 34 void ResolutionErrorTable::add_entry(int index, unsigned int hash,
35 constantPoolHandle pool, int cp_index, symbolHandle error) 35 constantPoolHandle pool, int cp_index, Symbol* error)
36 { 36 {
37 assert_locked_or_safepoint(SystemDictionary_lock); 37 assert_locked_or_safepoint(SystemDictionary_lock);
38 assert(!pool.is_null() && !error.is_null(), "adding NULL obj"); 38 assert(!pool.is_null() && error != NULL, "adding NULL obj");
39 39
40 ResolutionErrorEntry* entry = new_entry(hash, pool(), cp_index, error()); 40 ResolutionErrorEntry* entry = new_entry(hash, pool(), cp_index, error);
41 add_entry(index, entry); 41 add_entry(index, entry);
42 } 42 }
43 43
44 // find entry in the table 44 // find entry in the table
45 ResolutionErrorEntry* ResolutionErrorTable::find_entry(int index, unsigned int hash, 45 ResolutionErrorEntry* ResolutionErrorTable::find_entry(int index, unsigned int hash,
55 } 55 }
56 } 56 }
57 return NULL; 57 return NULL;
58 } 58 }
59 59
60 void ResolutionErrorEntry::set_error(Symbol* e) {
61 assert(e == NULL || _error == NULL, "cannot reset error");
62 _error = e;
63 if (_error != NULL) _error->increment_refcount();
64 }
65
60 // create new error entry 66 // create new error entry
61 ResolutionErrorEntry* ResolutionErrorTable::new_entry(int hash, constantPoolOop pool, 67 ResolutionErrorEntry* ResolutionErrorTable::new_entry(int hash, constantPoolOop pool,
62 int cp_index, symbolOop error) 68 int cp_index, Symbol* error)
63 { 69 {
64 ResolutionErrorEntry* entry = (ResolutionErrorEntry*)Hashtable::new_entry(hash, pool); 70 ResolutionErrorEntry* entry = (ResolutionErrorEntry*)Hashtable<constantPoolOop>::new_entry(hash, pool);
65 entry->set_cp_index(cp_index); 71 entry->set_cp_index(cp_index);
72 NOT_PRODUCT(entry->set_error(NULL);)
66 entry->set_error(error); 73 entry->set_error(error);
67 74
68 return entry; 75 return entry;
69 } 76 }
70 77
78 void ResolutionErrorTable::free_entry(ResolutionErrorEntry *entry) {
79 // decrement error refcount
80 assert(entry->error() != NULL, "error should be set");
81 entry->error()->decrement_refcount();
82 Hashtable<constantPoolOop>::free_entry(entry);
83 }
84
85
71 // create resolution error table 86 // create resolution error table
72 ResolutionErrorTable::ResolutionErrorTable(int table_size) 87 ResolutionErrorTable::ResolutionErrorTable(int table_size)
73 : Hashtable(table_size, sizeof(ResolutionErrorEntry)) { 88 : Hashtable<constantPoolOop>(table_size, sizeof(ResolutionErrorEntry)) {
74 } 89 }
75 90
76 // GC support 91 // GC support
77 void ResolutionErrorTable::oops_do(OopClosure* f) { 92 void ResolutionErrorTable::oops_do(OopClosure* f) {
78 for (int i = 0; i < table_size(); i++) { 93 for (int i = 0; i < table_size(); i++) {
79 for (ResolutionErrorEntry* probe = bucket(i); 94 for (ResolutionErrorEntry* probe = bucket(i);
80 probe != NULL; 95 probe != NULL;
81 probe = probe->next()) { 96 probe = probe->next()) {
82 assert(probe->pool() != (constantPoolOop)NULL, "resolution error table is corrupt"); 97 assert(probe->pool() != (constantPoolOop)NULL, "resolution error table is corrupt");
83 assert(probe->error() != (symbolOop)NULL, "resolution error table is corrupt"); 98 assert(probe->error() != (Symbol*)NULL, "resolution error table is corrupt");
84 probe->oops_do(f); 99 probe->oops_do(f);
85 } 100 }
86 } 101 }
87 } 102 }
88 103
89 // GC support 104 // GC support
90 void ResolutionErrorEntry::oops_do(OopClosure* blk) { 105 void ResolutionErrorEntry::oops_do(OopClosure* blk) {
91 blk->do_oop((oop*)pool_addr()); 106 blk->do_oop((oop*)pool_addr());
92 blk->do_oop((oop*)error_addr());
93 }
94
95 // We must keep the symbolOop used in the error alive. The constantPoolOop will
96 // decide when the entry can be purged.
97 void ResolutionErrorTable::always_strong_classes_do(OopClosure* blk) {
98 for (int i = 0; i < table_size(); i++) {
99 for (ResolutionErrorEntry* probe = bucket(i);
100 probe != NULL;
101 probe = probe->next()) {
102 assert(probe->error() != (symbolOop)NULL, "resolution error table is corrupt");
103 blk->do_oop((oop*)probe->error_addr());
104 }
105 }
106 } 107 }
107 108
108 // Remove unloaded entries from the table 109 // Remove unloaded entries from the table
109 void ResolutionErrorTable::purge_resolution_errors(BoolObjectClosure* is_alive) { 110 void ResolutionErrorTable::purge_resolution_errors(BoolObjectClosure* is_alive) {
110 assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint"); 111 assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint");