1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/share/vm/classfile/resolutionErrors.cpp Sat Dec 01 00:00:00 2007 +0000 1.3 @@ -0,0 +1,119 @@ 1.4 +/* 1.5 + * Copyright 2005 Sun Microsystems, Inc. All Rights Reserved. 1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.7 + * 1.8 + * This code is free software; you can redistribute it and/or modify it 1.9 + * under the terms of the GNU General Public License version 2 only, as 1.10 + * published by the Free Software Foundation. 1.11 + * 1.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 1.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1.15 + * version 2 for more details (a copy is included in the LICENSE file that 1.16 + * accompanied this code). 1.17 + * 1.18 + * You should have received a copy of the GNU General Public License version 1.19 + * 2 along with this work; if not, write to the Free Software Foundation, 1.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1.21 + * 1.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 1.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 1.24 + * have any questions. 1.25 + * 1.26 + */ 1.27 + 1.28 +# include "incls/_precompiled.incl" 1.29 +# include "incls/_resolutionErrors.cpp.incl" 1.30 + 1.31 +// add new entry to the table 1.32 +void ResolutionErrorTable::add_entry(int index, unsigned int hash, 1.33 + constantPoolHandle pool, int cp_index, symbolHandle error) 1.34 +{ 1.35 + assert_locked_or_safepoint(SystemDictionary_lock); 1.36 + assert(!pool.is_null() && !error.is_null(), "adding NULL obj"); 1.37 + 1.38 + ResolutionErrorEntry* entry = new_entry(hash, pool(), cp_index, error()); 1.39 + add_entry(index, entry); 1.40 +} 1.41 + 1.42 +// find entry in the table 1.43 +ResolutionErrorEntry* ResolutionErrorTable::find_entry(int index, unsigned int hash, 1.44 + constantPoolHandle pool, int cp_index) 1.45 +{ 1.46 + assert_locked_or_safepoint(SystemDictionary_lock); 1.47 + 1.48 + for (ResolutionErrorEntry *error_probe = bucket(index); 1.49 + error_probe != NULL; 1.50 + error_probe = error_probe->next()) { 1.51 + if (error_probe->hash() == hash && error_probe->pool() == pool()) { 1.52 + return error_probe;; 1.53 + } 1.54 + } 1.55 + return NULL; 1.56 +} 1.57 + 1.58 +// create new error entry 1.59 +ResolutionErrorEntry* ResolutionErrorTable::new_entry(int hash, constantPoolOop pool, 1.60 + int cp_index, symbolOop error) 1.61 +{ 1.62 + ResolutionErrorEntry* entry = (ResolutionErrorEntry*)Hashtable::new_entry(hash, pool); 1.63 + entry->set_cp_index(cp_index); 1.64 + entry->set_error(error); 1.65 + 1.66 + return entry; 1.67 +} 1.68 + 1.69 +// create resolution error table 1.70 +ResolutionErrorTable::ResolutionErrorTable(int table_size) 1.71 + : Hashtable(table_size, sizeof(ResolutionErrorEntry)) { 1.72 +} 1.73 + 1.74 +// GC support 1.75 +void ResolutionErrorTable::oops_do(OopClosure* f) { 1.76 + for (int i = 0; i < table_size(); i++) { 1.77 + for (ResolutionErrorEntry* probe = bucket(i); 1.78 + probe != NULL; 1.79 + probe = probe->next()) { 1.80 + assert(probe->pool() != (constantPoolOop)NULL, "resolution error table is corrupt"); 1.81 + assert(probe->error() != (symbolOop)NULL, "resolution error table is corrupt"); 1.82 + probe->oops_do(f); 1.83 + } 1.84 + } 1.85 +} 1.86 + 1.87 +// GC support 1.88 +void ResolutionErrorEntry::oops_do(OopClosure* blk) { 1.89 + blk->do_oop((oop*)pool_addr()); 1.90 + blk->do_oop((oop*)error_addr()); 1.91 +} 1.92 + 1.93 +// We must keep the symbolOop used in the error alive. The constantPoolOop will 1.94 +// decide when the entry can be purged. 1.95 +void ResolutionErrorTable::always_strong_classes_do(OopClosure* blk) { 1.96 + for (int i = 0; i < table_size(); i++) { 1.97 + for (ResolutionErrorEntry* probe = bucket(i); 1.98 + probe != NULL; 1.99 + probe = probe->next()) { 1.100 + assert(probe->error() != (symbolOop)NULL, "resolution error table is corrupt"); 1.101 + blk->do_oop((oop*)probe->error_addr()); 1.102 + } 1.103 + } 1.104 +} 1.105 + 1.106 +// Remove unloaded entries from the table 1.107 +void ResolutionErrorTable::purge_resolution_errors(BoolObjectClosure* is_alive) { 1.108 + assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint") 1.109 + for (int i = 0; i < table_size(); i++) { 1.110 + for (ResolutionErrorEntry** p = bucket_addr(i); *p != NULL; ) { 1.111 + ResolutionErrorEntry* entry = *p; 1.112 + assert(entry->pool() != (constantPoolOop)NULL, "resolution error table is corrupt"); 1.113 + constantPoolOop pool = entry->pool(); 1.114 + if (is_alive->do_object_b(pool)) { 1.115 + p = entry->next_addr(); 1.116 + } else { 1.117 + *p = entry->next(); 1.118 + free_entry(entry); 1.119 + } 1.120 + } 1.121 + } 1.122 +}