src/share/vm/classfile/resolutionErrors.cpp

Wed, 01 Dec 2010 18:26:32 -0500

author
ikrylov
date
Wed, 01 Dec 2010 18:26:32 -0500
changeset 2322
828eafbd85cc
parent 2314
f95d63e2154a
child 2497
3582bf76420e
permissions
-rw-r--r--

6348631: remove the use of the HPI library from Hotspot
Summary: move functions from hpi library to hotspot, communicate with licensees and open source community, check jdk for dependency, file CCC request
Reviewed-by: coleenp, acorn, dsamersoff

duke@435 1 /*
stefank@2314 2 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
duke@435 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@435 4 *
duke@435 5 * This code is free software; you can redistribute it and/or modify it
duke@435 6 * under the terms of the GNU General Public License version 2 only, as
duke@435 7 * published by the Free Software Foundation.
duke@435 8 *
duke@435 9 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@435 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@435 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@435 12 * version 2 for more details (a copy is included in the LICENSE file that
duke@435 13 * accompanied this code).
duke@435 14 *
duke@435 15 * You should have received a copy of the GNU General Public License version
duke@435 16 * 2 along with this work; if not, write to the Free Software Foundation,
duke@435 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@435 18 *
trims@1907 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
trims@1907 20 * or visit www.oracle.com if you need additional information or have any
trims@1907 21 * questions.
duke@435 22 *
duke@435 23 */
duke@435 24
stefank@2314 25 #include "precompiled.hpp"
stefank@2314 26 #include "classfile/resolutionErrors.hpp"
stefank@2314 27 #include "memory/resourceArea.hpp"
stefank@2314 28 #include "oops/oop.inline.hpp"
stefank@2314 29 #include "runtime/handles.inline.hpp"
stefank@2314 30 #include "runtime/safepoint.hpp"
stefank@2314 31 #include "utilities/hashtable.inline.hpp"
duke@435 32
duke@435 33 // add new entry to the table
duke@435 34 void ResolutionErrorTable::add_entry(int index, unsigned int hash,
duke@435 35 constantPoolHandle pool, int cp_index, symbolHandle error)
duke@435 36 {
duke@435 37 assert_locked_or_safepoint(SystemDictionary_lock);
duke@435 38 assert(!pool.is_null() && !error.is_null(), "adding NULL obj");
duke@435 39
duke@435 40 ResolutionErrorEntry* entry = new_entry(hash, pool(), cp_index, error());
duke@435 41 add_entry(index, entry);
duke@435 42 }
duke@435 43
duke@435 44 // find entry in the table
duke@435 45 ResolutionErrorEntry* ResolutionErrorTable::find_entry(int index, unsigned int hash,
duke@435 46 constantPoolHandle pool, int cp_index)
duke@435 47 {
duke@435 48 assert_locked_or_safepoint(SystemDictionary_lock);
duke@435 49
duke@435 50 for (ResolutionErrorEntry *error_probe = bucket(index);
duke@435 51 error_probe != NULL;
duke@435 52 error_probe = error_probe->next()) {
duke@435 53 if (error_probe->hash() == hash && error_probe->pool() == pool()) {
duke@435 54 return error_probe;;
duke@435 55 }
duke@435 56 }
duke@435 57 return NULL;
duke@435 58 }
duke@435 59
duke@435 60 // create new error entry
duke@435 61 ResolutionErrorEntry* ResolutionErrorTable::new_entry(int hash, constantPoolOop pool,
duke@435 62 int cp_index, symbolOop error)
duke@435 63 {
duke@435 64 ResolutionErrorEntry* entry = (ResolutionErrorEntry*)Hashtable::new_entry(hash, pool);
duke@435 65 entry->set_cp_index(cp_index);
duke@435 66 entry->set_error(error);
duke@435 67
duke@435 68 return entry;
duke@435 69 }
duke@435 70
duke@435 71 // create resolution error table
duke@435 72 ResolutionErrorTable::ResolutionErrorTable(int table_size)
duke@435 73 : Hashtable(table_size, sizeof(ResolutionErrorEntry)) {
duke@435 74 }
duke@435 75
duke@435 76 // GC support
duke@435 77 void ResolutionErrorTable::oops_do(OopClosure* f) {
duke@435 78 for (int i = 0; i < table_size(); i++) {
duke@435 79 for (ResolutionErrorEntry* probe = bucket(i);
duke@435 80 probe != NULL;
duke@435 81 probe = probe->next()) {
duke@435 82 assert(probe->pool() != (constantPoolOop)NULL, "resolution error table is corrupt");
duke@435 83 assert(probe->error() != (symbolOop)NULL, "resolution error table is corrupt");
duke@435 84 probe->oops_do(f);
duke@435 85 }
duke@435 86 }
duke@435 87 }
duke@435 88
duke@435 89 // GC support
duke@435 90 void ResolutionErrorEntry::oops_do(OopClosure* blk) {
duke@435 91 blk->do_oop((oop*)pool_addr());
duke@435 92 blk->do_oop((oop*)error_addr());
duke@435 93 }
duke@435 94
duke@435 95 // We must keep the symbolOop used in the error alive. The constantPoolOop will
duke@435 96 // decide when the entry can be purged.
duke@435 97 void ResolutionErrorTable::always_strong_classes_do(OopClosure* blk) {
duke@435 98 for (int i = 0; i < table_size(); i++) {
duke@435 99 for (ResolutionErrorEntry* probe = bucket(i);
duke@435 100 probe != NULL;
duke@435 101 probe = probe->next()) {
duke@435 102 assert(probe->error() != (symbolOop)NULL, "resolution error table is corrupt");
duke@435 103 blk->do_oop((oop*)probe->error_addr());
duke@435 104 }
duke@435 105 }
duke@435 106 }
duke@435 107
duke@435 108 // Remove unloaded entries from the table
duke@435 109 void ResolutionErrorTable::purge_resolution_errors(BoolObjectClosure* is_alive) {
jcoomes@1844 110 assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint");
duke@435 111 for (int i = 0; i < table_size(); i++) {
duke@435 112 for (ResolutionErrorEntry** p = bucket_addr(i); *p != NULL; ) {
duke@435 113 ResolutionErrorEntry* entry = *p;
duke@435 114 assert(entry->pool() != (constantPoolOop)NULL, "resolution error table is corrupt");
duke@435 115 constantPoolOop pool = entry->pool();
duke@435 116 if (is_alive->do_object_b(pool)) {
duke@435 117 p = entry->next_addr();
duke@435 118 } else {
duke@435 119 *p = entry->next();
duke@435 120 free_entry(entry);
duke@435 121 }
duke@435 122 }
duke@435 123 }
duke@435 124 }

mercurial