2007-12-01 00:00:00 +00:00
|
|
|
/*
|
2015-10-23 16:48:38 -04:00
|
|
|
* Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
|
2007-12-01 00:00:00 +00:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
|
|
*
|
|
|
|
* This code is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License version 2 only, as
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
|
|
* version 2 for more details (a copy is included in the LICENSE file that
|
|
|
|
* accompanied this code).
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License version
|
|
|
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
|
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*
|
2010-05-27 19:08:38 -07:00
|
|
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
|
|
* or visit www.oracle.com if you need additional information or have any
|
|
|
|
* questions.
|
2007-12-01 00:00:00 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2010-11-23 13:22:55 -08:00
|
|
|
#include "precompiled.hpp"
|
|
|
|
#include "classfile/resolutionErrors.hpp"
|
|
|
|
#include "memory/resourceArea.hpp"
|
|
|
|
#include "oops/oop.inline.hpp"
|
|
|
|
#include "runtime/handles.inline.hpp"
|
|
|
|
#include "runtime/safepoint.hpp"
|
|
|
|
#include "utilities/hashtable.inline.hpp"
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
// add new entry to the table
|
|
|
|
void ResolutionErrorTable::add_entry(int index, unsigned int hash,
|
2015-10-23 16:48:38 -04:00
|
|
|
const constantPoolHandle& pool, int cp_index,
|
2014-05-05 19:53:00 -04:00
|
|
|
Symbol* error, Symbol* message)
|
2007-12-01 00:00:00 +00:00
|
|
|
{
|
|
|
|
assert_locked_or_safepoint(SystemDictionary_lock);
|
2011-01-27 16:11:27 -08:00
|
|
|
assert(!pool.is_null() && error != NULL, "adding NULL obj");
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2014-05-05 19:53:00 -04:00
|
|
|
ResolutionErrorEntry* entry = new_entry(hash, pool(), cp_index, error, message);
|
2007-12-01 00:00:00 +00:00
|
|
|
add_entry(index, entry);
|
|
|
|
}
|
|
|
|
|
|
|
|
// find entry in the table
|
|
|
|
ResolutionErrorEntry* ResolutionErrorTable::find_entry(int index, unsigned int hash,
|
2015-10-23 16:48:38 -04:00
|
|
|
const constantPoolHandle& pool, int cp_index)
|
2007-12-01 00:00:00 +00:00
|
|
|
{
|
|
|
|
assert_locked_or_safepoint(SystemDictionary_lock);
|
|
|
|
|
|
|
|
for (ResolutionErrorEntry *error_probe = bucket(index);
|
|
|
|
error_probe != NULL;
|
|
|
|
error_probe = error_probe->next()) {
|
|
|
|
if (error_probe->hash() == hash && error_probe->pool() == pool()) {
|
|
|
|
return error_probe;;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2011-01-27 16:11:27 -08:00
|
|
|
void ResolutionErrorEntry::set_error(Symbol* e) {
|
2014-05-05 19:53:00 -04:00
|
|
|
assert(e != NULL, "must set a value");
|
2011-01-27 16:11:27 -08:00
|
|
|
_error = e;
|
2014-05-05 19:53:00 -04:00
|
|
|
_error->increment_refcount();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ResolutionErrorEntry::set_message(Symbol* c) {
|
|
|
|
assert(c != NULL, "must set a value");
|
|
|
|
_message = c;
|
|
|
|
_message->increment_refcount();
|
2011-01-27 16:11:27 -08:00
|
|
|
}
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
// create new error entry
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
ResolutionErrorEntry* ResolutionErrorTable::new_entry(int hash, ConstantPool* pool,
|
2014-05-05 19:53:00 -04:00
|
|
|
int cp_index, Symbol* error,
|
|
|
|
Symbol* message)
|
2007-12-01 00:00:00 +00:00
|
|
|
{
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
ResolutionErrorEntry* entry = (ResolutionErrorEntry*)Hashtable<ConstantPool*, mtClass>::new_entry(hash, pool);
|
2007-12-01 00:00:00 +00:00
|
|
|
entry->set_cp_index(cp_index);
|
|
|
|
entry->set_error(error);
|
2014-05-05 19:53:00 -04:00
|
|
|
entry->set_message(message);
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
return entry;
|
|
|
|
}
|
|
|
|
|
2011-01-27 16:11:27 -08:00
|
|
|
void ResolutionErrorTable::free_entry(ResolutionErrorEntry *entry) {
|
|
|
|
// decrement error refcount
|
|
|
|
assert(entry->error() != NULL, "error should be set");
|
|
|
|
entry->error()->decrement_refcount();
|
2014-05-05 19:53:00 -04:00
|
|
|
entry->message()->decrement_refcount();
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
Hashtable<ConstantPool*, mtClass>::free_entry(entry);
|
2011-01-27 16:11:27 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
// create resolution error table
|
|
|
|
ResolutionErrorTable::ResolutionErrorTable(int table_size)
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
: Hashtable<ConstantPool*, mtClass>(table_size, sizeof(ResolutionErrorEntry)) {
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
// RedefineClasses support - remove matching entry of a
|
|
|
|
// constant pool that is going away
|
|
|
|
void ResolutionErrorTable::delete_entry(ConstantPool* c) {
|
|
|
|
assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint");
|
2007-12-01 00:00:00 +00:00
|
|
|
for (int i = 0; i < table_size(); i++) {
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
for (ResolutionErrorEntry** p = bucket_addr(i); *p != NULL; ) {
|
|
|
|
ResolutionErrorEntry* entry = *p;
|
|
|
|
assert(entry->pool() != NULL, "resolution error table is corrupt");
|
|
|
|
if (entry->pool() == c) {
|
|
|
|
*p = entry->next();
|
|
|
|
free_entry(entry);
|
|
|
|
} else {
|
|
|
|
p = entry->next_addr();
|
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Remove unloaded entries from the table
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
void ResolutionErrorTable::purge_resolution_errors() {
|
2009-10-11 16:19:25 -07:00
|
|
|
assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint");
|
2007-12-01 00:00:00 +00:00
|
|
|
for (int i = 0; i < table_size(); i++) {
|
|
|
|
for (ResolutionErrorEntry** p = bucket_addr(i); *p != NULL; ) {
|
|
|
|
ResolutionErrorEntry* entry = *p;
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
assert(entry->pool() != (ConstantPool*)NULL, "resolution error table is corrupt");
|
|
|
|
ConstantPool* pool = entry->pool();
|
|
|
|
assert(pool->pool_holder() != NULL, "Constant pool without a class?");
|
|
|
|
ClassLoaderData* loader_data =
|
|
|
|
pool->pool_holder()->class_loader_data();
|
|
|
|
if (!loader_data->is_unloading()) {
|
2007-12-01 00:00:00 +00:00
|
|
|
p = entry->next_addr();
|
|
|
|
} else {
|
|
|
|
*p = entry->next();
|
|
|
|
free_entry(entry);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|