0
|
1 /*
|
|
2 * Copyright 2005 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
|
20 * CA 95054 USA or visit www.sun.com if you need additional information or
|
|
21 * have any questions.
|
|
22 *
|
|
23 */
|
|
24
|
|
25 # include "incls/_precompiled.incl"
|
|
26 # include "incls/_resolutionErrors.cpp.incl"
|
|
27
|
|
28 // add new entry to the table
|
|
29 void ResolutionErrorTable::add_entry(int index, unsigned int hash,
|
|
30 constantPoolHandle pool, int cp_index, symbolHandle error)
|
|
31 {
|
|
32 assert_locked_or_safepoint(SystemDictionary_lock);
|
|
33 assert(!pool.is_null() && !error.is_null(), "adding NULL obj");
|
|
34
|
|
35 ResolutionErrorEntry* entry = new_entry(hash, pool(), cp_index, error());
|
|
36 add_entry(index, entry);
|
|
37 }
|
|
38
|
|
39 // find entry in the table
|
|
40 ResolutionErrorEntry* ResolutionErrorTable::find_entry(int index, unsigned int hash,
|
|
41 constantPoolHandle pool, int cp_index)
|
|
42 {
|
|
43 assert_locked_or_safepoint(SystemDictionary_lock);
|
|
44
|
|
45 for (ResolutionErrorEntry *error_probe = bucket(index);
|
|
46 error_probe != NULL;
|
|
47 error_probe = error_probe->next()) {
|
|
48 if (error_probe->hash() == hash && error_probe->pool() == pool()) {
|
|
49 return error_probe;;
|
|
50 }
|
|
51 }
|
|
52 return NULL;
|
|
53 }
|
|
54
|
|
55 // create new error entry
|
|
56 ResolutionErrorEntry* ResolutionErrorTable::new_entry(int hash, constantPoolOop pool,
|
|
57 int cp_index, symbolOop error)
|
|
58 {
|
|
59 ResolutionErrorEntry* entry = (ResolutionErrorEntry*)Hashtable::new_entry(hash, pool);
|
|
60 entry->set_cp_index(cp_index);
|
|
61 entry->set_error(error);
|
|
62
|
|
63 return entry;
|
|
64 }
|
|
65
|
|
66 // create resolution error table
|
|
67 ResolutionErrorTable::ResolutionErrorTable(int table_size)
|
|
68 : Hashtable(table_size, sizeof(ResolutionErrorEntry)) {
|
|
69 }
|
|
70
|
|
71 // GC support
|
|
72 void ResolutionErrorTable::oops_do(OopClosure* f) {
|
|
73 for (int i = 0; i < table_size(); i++) {
|
|
74 for (ResolutionErrorEntry* probe = bucket(i);
|
|
75 probe != NULL;
|
|
76 probe = probe->next()) {
|
|
77 assert(probe->pool() != (constantPoolOop)NULL, "resolution error table is corrupt");
|
|
78 assert(probe->error() != (symbolOop)NULL, "resolution error table is corrupt");
|
|
79 probe->oops_do(f);
|
|
80 }
|
|
81 }
|
|
82 }
|
|
83
|
|
84 // GC support
|
|
85 void ResolutionErrorEntry::oops_do(OopClosure* blk) {
|
|
86 blk->do_oop((oop*)pool_addr());
|
|
87 blk->do_oop((oop*)error_addr());
|
|
88 }
|
|
89
|
|
90 // We must keep the symbolOop used in the error alive. The constantPoolOop will
|
|
91 // decide when the entry can be purged.
|
|
92 void ResolutionErrorTable::always_strong_classes_do(OopClosure* blk) {
|
|
93 for (int i = 0; i < table_size(); i++) {
|
|
94 for (ResolutionErrorEntry* probe = bucket(i);
|
|
95 probe != NULL;
|
|
96 probe = probe->next()) {
|
|
97 assert(probe->error() != (symbolOop)NULL, "resolution error table is corrupt");
|
|
98 blk->do_oop((oop*)probe->error_addr());
|
|
99 }
|
|
100 }
|
|
101 }
|
|
102
|
|
103 // Remove unloaded entries from the table
|
|
104 void ResolutionErrorTable::purge_resolution_errors(BoolObjectClosure* is_alive) {
|
|
105 assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint")
|
|
106 for (int i = 0; i < table_size(); i++) {
|
|
107 for (ResolutionErrorEntry** p = bucket_addr(i); *p != NULL; ) {
|
|
108 ResolutionErrorEntry* entry = *p;
|
|
109 assert(entry->pool() != (constantPoolOop)NULL, "resolution error table is corrupt");
|
|
110 constantPoolOop pool = entry->pool();
|
|
111 if (is_alive->do_object_b(pool)) {
|
|
112 p = entry->next_addr();
|
|
113 } else {
|
|
114 *p = entry->next();
|
|
115 free_entry(entry);
|
|
116 }
|
|
117 }
|
|
118 }
|
|
119 }
|