2007-12-01 00:00:00 +00:00
|
|
|
/*
|
2013-01-17 13:40:31 -05:00
|
|
|
* Copyright (c) 1997, 2013, 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"
|
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
|
|
|
#include "classfile/classLoaderData.hpp"
|
2010-11-23 13:22:55 -08:00
|
|
|
#include "classfile/javaClasses.hpp"
|
2013-01-23 10:34:29 -05:00
|
|
|
#include "classfile/metadataOnStackMark.hpp"
|
2010-11-23 13:22:55 -08:00
|
|
|
#include "classfile/symbolTable.hpp"
|
|
|
|
#include "classfile/systemDictionary.hpp"
|
|
|
|
#include "classfile/vmSymbols.hpp"
|
|
|
|
#include "interpreter/linkResolver.hpp"
|
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
|
|
|
#include "memory/metadataFactory.hpp"
|
2010-11-23 13:22:55 -08:00
|
|
|
#include "memory/oopFactory.hpp"
|
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
|
|
|
#include "oops/constantPool.hpp"
|
2010-11-23 13:22:55 -08:00
|
|
|
#include "oops/instanceKlass.hpp"
|
|
|
|
#include "oops/objArrayKlass.hpp"
|
|
|
|
#include "runtime/fieldType.hpp"
|
|
|
|
#include "runtime/init.hpp"
|
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
|
|
|
#include "runtime/javaCalls.hpp"
|
2010-11-23 13:22:55 -08:00
|
|
|
#include "runtime/signature.hpp"
|
|
|
|
#include "runtime/vframe.hpp"
|
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
|
|
|
ConstantPool* ConstantPool::allocate(ClassLoaderData* loader_data, int length, TRAPS) {
|
|
|
|
// Tags are RW but comment below applies to tags also.
|
|
|
|
Array<u1>* tags = MetadataFactory::new_writeable_array<u1>(loader_data, length, 0, CHECK_NULL);
|
|
|
|
|
|
|
|
int size = ConstantPool::size(length);
|
|
|
|
|
|
|
|
// CDS considerations:
|
|
|
|
// Allocate read-write but may be able to move to read-only at dumping time
|
|
|
|
// if all the klasses are resolved. The only other field that is writable is
|
|
|
|
// the resolved_references array, which is recreated at startup time.
|
|
|
|
// But that could be moved to InstanceKlass (although a pain to access from
|
|
|
|
// assembly code). Maybe it could be moved to the cpCache which is RW.
|
|
|
|
return new (loader_data, size, false, THREAD) ConstantPool(tags);
|
|
|
|
}
|
|
|
|
|
|
|
|
ConstantPool::ConstantPool(Array<u1>* tags) {
|
|
|
|
set_length(tags->length());
|
|
|
|
set_tags(NULL);
|
|
|
|
set_cache(NULL);
|
|
|
|
set_reference_map(NULL);
|
|
|
|
set_resolved_references(NULL);
|
|
|
|
set_operands(NULL);
|
|
|
|
set_pool_holder(NULL);
|
|
|
|
set_flags(0);
|
2013-01-23 10:34:29 -05: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
|
|
|
// only set to non-zero if constant pool is merged by RedefineClasses
|
2013-01-17 13:40:31 -05:00
|
|
|
set_version(0);
|
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
|
|
|
set_lock(new Monitor(Monitor::nonleaf + 2, "A constant pool lock"));
|
|
|
|
|
|
|
|
// initialize tag array
|
|
|
|
int length = tags->length();
|
|
|
|
for (int index = 0; index < length; index++) {
|
|
|
|
tags->at_put(index, JVM_CONSTANT_Invalid);
|
|
|
|
}
|
|
|
|
set_tags(tags);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ConstantPool::deallocate_contents(ClassLoaderData* loader_data) {
|
|
|
|
MetadataFactory::free_metadata(loader_data, cache());
|
|
|
|
set_cache(NULL);
|
|
|
|
MetadataFactory::free_array<jushort>(loader_data, operands());
|
|
|
|
set_operands(NULL);
|
|
|
|
|
|
|
|
release_C_heap_structures();
|
|
|
|
|
|
|
|
// free tag array
|
|
|
|
MetadataFactory::free_array<u1>(loader_data, tags());
|
|
|
|
set_tags(NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ConstantPool::release_C_heap_structures() {
|
|
|
|
// walk constant pool and decrement symbol reference counts
|
|
|
|
unreference_symbols();
|
|
|
|
|
|
|
|
delete _lock;
|
|
|
|
set_lock(NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
objArrayOop ConstantPool::resolved_references() const {
|
|
|
|
return (objArrayOop)JNIHandles::resolve(_resolved_references);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Create resolved_references array and mapping array for original cp indexes
|
|
|
|
// The ldc bytecode was rewritten to have the resolved reference array index so need a way
|
|
|
|
// to map it back for resolving and some unlikely miscellaneous uses.
|
|
|
|
// The objects created by invokedynamic are appended to this list.
|
|
|
|
void ConstantPool::initialize_resolved_references(ClassLoaderData* loader_data,
|
|
|
|
intStack reference_map,
|
|
|
|
int constant_pool_map_length,
|
|
|
|
TRAPS) {
|
|
|
|
// Initialized the resolved object cache.
|
|
|
|
int map_length = reference_map.length();
|
|
|
|
if (map_length > 0) {
|
|
|
|
// Only need mapping back to constant pool entries. The map isn't used for
|
|
|
|
// invokedynamic resolved_reference entries. The constant pool cache index
|
|
|
|
// has the mapping back to both the constant pool and to the resolved
|
|
|
|
// reference index.
|
|
|
|
if (constant_pool_map_length > 0) {
|
|
|
|
Array<u2>* om = MetadataFactory::new_array<u2>(loader_data, map_length, CHECK);
|
|
|
|
|
|
|
|
for (int i = 0; i < constant_pool_map_length; i++) {
|
|
|
|
int x = reference_map.at(i);
|
|
|
|
assert(x == (int)(jushort) x, "klass index is too big");
|
|
|
|
om->at_put(i, (jushort)x);
|
|
|
|
}
|
|
|
|
set_reference_map(om);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Create Java array for holding resolved strings, methodHandles,
|
|
|
|
// methodTypes, invokedynamic and invokehandle appendix objects, etc.
|
|
|
|
objArrayOop stom = oopFactory::new_objArray(SystemDictionary::Object_klass(), map_length, CHECK);
|
|
|
|
Handle refs_handle (THREAD, (oop)stom); // must handleize.
|
|
|
|
set_resolved_references(loader_data->add_handle(refs_handle));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// CDS support. Create a new resolved_references array.
|
|
|
|
void ConstantPool::restore_unshareable_info(TRAPS) {
|
2012-09-05 20:08:08 -04:00
|
|
|
|
|
|
|
// restore the C++ vtable from the shared archive
|
|
|
|
restore_vtable();
|
|
|
|
|
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
|
|
|
if (SystemDictionary::Object_klass_loaded()) {
|
|
|
|
// Recreate the object array and add to ClassLoaderData.
|
|
|
|
int map_length = resolved_reference_length();
|
|
|
|
if (map_length > 0) {
|
|
|
|
objArrayOop stom = oopFactory::new_objArray(SystemDictionary::Object_klass(), map_length, CHECK);
|
|
|
|
Handle refs_handle (THREAD, (oop)stom); // must handleize.
|
|
|
|
|
|
|
|
ClassLoaderData* loader_data = pool_holder()->class_loader_data();
|
|
|
|
set_resolved_references(loader_data->add_handle(refs_handle));
|
|
|
|
}
|
|
|
|
|
|
|
|
// Also need to recreate the mutex. Make sure this matches the constructor
|
|
|
|
set_lock(new Monitor(Monitor::nonleaf + 2, "A constant pool lock"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ConstantPool::remove_unshareable_info() {
|
|
|
|
// Resolved references are not in the shared archive.
|
|
|
|
// Save the length for restoration. It is not necessarily the same length
|
|
|
|
// as reference_map.length() if invokedynamic is saved.
|
|
|
|
set_resolved_reference_length(
|
|
|
|
resolved_references() != NULL ? resolved_references()->length() : 0);
|
|
|
|
set_resolved_references(NULL);
|
|
|
|
set_lock(NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
int ConstantPool::cp_to_object_index(int cp_index) {
|
|
|
|
// this is harder don't do this so much.
|
|
|
|
for (int i = 0; i< reference_map()->length(); i++) {
|
|
|
|
if (reference_map()->at(i) == cp_index) return i;
|
|
|
|
// Zero entry is divider between constant pool indices for strings,
|
|
|
|
// method handles and method types. After that the index is a constant
|
|
|
|
// pool cache index for invokedynamic. Stop when zero (which can never
|
|
|
|
// be a constant pool index)
|
|
|
|
if (reference_map()->at(i) == 0) break;
|
|
|
|
}
|
|
|
|
// We might not find the index.
|
|
|
|
return _no_index_sentinel;
|
|
|
|
}
|
|
|
|
|
|
|
|
Klass* ConstantPool::klass_at_impl(constantPoolHandle this_oop, int which, TRAPS) {
|
|
|
|
// A resolved constantPool entry will contain a Klass*, otherwise a Symbol*.
|
2007-12-01 00:00:00 +00:00
|
|
|
// It is not safe to rely on the tag bit's here, since we don't have a lock, and the entry and
|
|
|
|
// tag is not updated atomicly.
|
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
|
|
|
|
2011-01-27 16:11:27 -08:00
|
|
|
CPSlot entry = this_oop->slot_at(which);
|
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
|
|
|
if (entry.is_resolved()) {
|
|
|
|
assert(entry.get_klass()->is_klass(), "must be");
|
2007-12-01 00:00:00 +00:00
|
|
|
// Already resolved - return 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
|
|
|
return entry.get_klass();
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Acquire lock on constant oop while doing update. After we get the lock, we check if another object
|
|
|
|
// already has updated the object
|
|
|
|
assert(THREAD->is_Java_thread(), "must be a Java thread");
|
|
|
|
bool do_resolve = false;
|
|
|
|
bool in_error = false;
|
|
|
|
|
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
|
|
|
// Create a handle for the mirror. This will preserve the resolved class
|
|
|
|
// until the loader_data is registered.
|
|
|
|
Handle mirror_handle;
|
|
|
|
|
2011-01-27 16:11:27 -08:00
|
|
|
Symbol* name = NULL;
|
2007-12-01 00:00:00 +00:00
|
|
|
Handle loader;
|
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
|
|
|
{ MonitorLockerEx ml(this_oop->lock());
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
if (this_oop->tag_at(which).is_unresolved_klass()) {
|
|
|
|
if (this_oop->tag_at(which).is_unresolved_klass_in_error()) {
|
|
|
|
in_error = true;
|
|
|
|
} else {
|
|
|
|
do_resolve = true;
|
2011-01-27 16:11:27 -08:00
|
|
|
name = this_oop->unresolved_klass_at(which);
|
2012-11-06 15:09:37 -05:00
|
|
|
loader = Handle(THREAD, this_oop->pool_holder()->class_loader());
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} // unlocking constantPool
|
|
|
|
|
|
|
|
|
|
|
|
// The original attempt to resolve this constant pool entry failed so find the
|
|
|
|
// original error and throw it again (JVMS 5.4.3).
|
|
|
|
if (in_error) {
|
2011-01-27 16:11:27 -08:00
|
|
|
Symbol* error = SystemDictionary::find_resolution_error(this_oop, which);
|
|
|
|
guarantee(error != (Symbol*)NULL, "tag mismatch with resolution error table");
|
2007-12-01 00:00:00 +00:00
|
|
|
ResourceMark rm;
|
|
|
|
// exception text will be the class name
|
|
|
|
const char* className = this_oop->unresolved_klass_at(which)->as_C_string();
|
|
|
|
THROW_MSG_0(error, className);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (do_resolve) {
|
|
|
|
// this_oop must be unlocked during resolve_or_fail
|
2012-11-06 15:09:37 -05:00
|
|
|
oop protection_domain = this_oop->pool_holder()->protection_domain();
|
2007-12-01 00:00:00 +00:00
|
|
|
Handle h_prot (THREAD, protection_domain);
|
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
|
|
|
Klass* k_oop = SystemDictionary::resolve_or_fail(name, loader, h_prot, true, THREAD);
|
2007-12-01 00:00:00 +00:00
|
|
|
KlassHandle k;
|
|
|
|
if (!HAS_PENDING_EXCEPTION) {
|
|
|
|
k = KlassHandle(THREAD, k_oop);
|
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
|
|
|
// preserve the resolved klass.
|
|
|
|
mirror_handle = Handle(THREAD, k_oop->java_mirror());
|
2007-12-01 00:00:00 +00:00
|
|
|
// Do access check for klasses
|
|
|
|
verify_constant_pool_resolve(this_oop, k, THREAD);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Failed to resolve class. We must record the errors so that subsequent attempts
|
|
|
|
// to resolve this constant pool entry fail with the same error (JVMS 5.4.3).
|
|
|
|
if (HAS_PENDING_EXCEPTION) {
|
|
|
|
ResourceMark rm;
|
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
|
|
|
Symbol* error = PENDING_EXCEPTION->klass()->name();
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
bool throw_orig_error = false;
|
|
|
|
{
|
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
|
|
|
MonitorLockerEx ml(this_oop->lock());
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
// some other thread has beaten us and has resolved the class.
|
|
|
|
if (this_oop->tag_at(which).is_klass()) {
|
|
|
|
CLEAR_PENDING_EXCEPTION;
|
|
|
|
entry = this_oop->resolved_klass_at(which);
|
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
|
|
|
return entry.get_klass();
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!PENDING_EXCEPTION->
|
2010-01-06 14:22:39 -08:00
|
|
|
is_a(SystemDictionary::LinkageError_klass())) {
|
2007-12-01 00:00:00 +00:00
|
|
|
// Just throw the exception and don't prevent these classes from
|
|
|
|
// being loaded due to virtual machine errors like StackOverflow
|
|
|
|
// and OutOfMemoryError, etc, or if the thread was hit by stop()
|
|
|
|
// Needs clarification to section 5.4.3 of the VM spec (see 6308271)
|
|
|
|
}
|
|
|
|
else if (!this_oop->tag_at(which).is_unresolved_klass_in_error()) {
|
|
|
|
SystemDictionary::add_resolution_error(this_oop, which, error);
|
|
|
|
this_oop->tag_at_put(which, JVM_CONSTANT_UnresolvedClassInError);
|
|
|
|
} else {
|
|
|
|
// some other thread has put the class in error state.
|
2011-01-27 16:11:27 -08:00
|
|
|
error = SystemDictionary::find_resolution_error(this_oop, which);
|
|
|
|
assert(error != NULL, "checking");
|
2007-12-01 00:00:00 +00:00
|
|
|
throw_orig_error = true;
|
|
|
|
}
|
|
|
|
} // unlocked
|
|
|
|
|
|
|
|
if (throw_orig_error) {
|
|
|
|
CLEAR_PENDING_EXCEPTION;
|
|
|
|
ResourceMark rm;
|
|
|
|
const char* className = this_oop->unresolved_klass_at(which)->as_C_string();
|
|
|
|
THROW_MSG_0(error, className);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
if (TraceClassResolution && !k()->oop_is_array()) {
|
2007-12-01 00:00:00 +00:00
|
|
|
// skip resolving the constant pool so that this code get's
|
|
|
|
// called the next time some bytecodes refer to this class.
|
|
|
|
ResourceMark rm;
|
|
|
|
int line_number = -1;
|
|
|
|
const char * source_file = NULL;
|
|
|
|
if (JavaThread::current()->has_last_Java_frame()) {
|
|
|
|
// try to identify the method which called this function.
|
|
|
|
vframeStream vfst(JavaThread::current());
|
|
|
|
if (!vfst.at_end()) {
|
|
|
|
line_number = vfst.method()->line_number_from_bci(vfst.bci());
|
2012-11-06 15:09:37 -05:00
|
|
|
Symbol* s = vfst.method()->method_holder()->source_file_name();
|
2007-12-01 00:00:00 +00:00
|
|
|
if (s != NULL) {
|
|
|
|
source_file = s->as_C_string();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (k() != this_oop->pool_holder()) {
|
|
|
|
// only print something if the classes are different
|
|
|
|
if (source_file != NULL) {
|
|
|
|
tty->print("RESOLVE %s %s %s:%d\n",
|
2012-11-06 15:09:37 -05:00
|
|
|
this_oop->pool_holder()->external_name(),
|
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
|
|
|
InstanceKlass::cast(k())->external_name(), source_file, line_number);
|
2007-12-01 00:00:00 +00:00
|
|
|
} else {
|
|
|
|
tty->print("RESOLVE %s %s\n",
|
2012-11-06 15:09:37 -05:00
|
|
|
this_oop->pool_holder()->external_name(),
|
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
|
|
|
InstanceKlass::cast(k())->external_name());
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return k();
|
|
|
|
} else {
|
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
|
|
|
MonitorLockerEx ml(this_oop->lock());
|
2007-12-01 00:00:00 +00:00
|
|
|
// Only updated constant pool - if it is resolved.
|
|
|
|
do_resolve = this_oop->tag_at(which).is_unresolved_klass();
|
|
|
|
if (do_resolve) {
|
2012-11-06 15:09:37 -05:00
|
|
|
ClassLoaderData* this_key = this_oop->pool_holder()->class_loader_data();
|
2012-11-29 16:50:29 -05:00
|
|
|
this_key->record_dependency(k(), CHECK_NULL); // Can throw OOM
|
2007-12-01 00:00:00 +00:00
|
|
|
this_oop->klass_at_put(which, k());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
entry = this_oop->resolved_klass_at(which);
|
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.is_resolved() && entry.get_klass()->is_klass(), "must be resolved at this point");
|
|
|
|
return entry.get_klass();
|
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
|
|
|
// Does not update ConstantPool* - to avoid any exception throwing. Used
|
2007-12-01 00:00:00 +00:00
|
|
|
// by compiler and exception handling. Also used to avoid classloads for
|
|
|
|
// instanceof operations. Returns NULL if the class has not been loaded or
|
|
|
|
// if the verification of constant pool failed
|
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
|
|
|
Klass* ConstantPool::klass_at_if_loaded(constantPoolHandle this_oop, int which) {
|
2011-01-27 16:11:27 -08:00
|
|
|
CPSlot entry = this_oop->slot_at(which);
|
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
|
|
|
if (entry.is_resolved()) {
|
|
|
|
assert(entry.get_klass()->is_klass(), "must be");
|
|
|
|
return entry.get_klass();
|
2007-12-01 00:00:00 +00:00
|
|
|
} else {
|
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.is_unresolved(), "must be either symbol or klass");
|
2007-12-01 00:00:00 +00:00
|
|
|
Thread *thread = Thread::current();
|
2011-01-27 16:11:27 -08:00
|
|
|
Symbol* name = entry.get_symbol();
|
2012-11-06 15:09:37 -05:00
|
|
|
oop loader = this_oop->pool_holder()->class_loader();
|
|
|
|
oop protection_domain = this_oop->pool_holder()->protection_domain();
|
2007-12-01 00:00:00 +00:00
|
|
|
Handle h_prot (thread, protection_domain);
|
|
|
|
Handle h_loader (thread, loader);
|
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
|
|
|
Klass* k = SystemDictionary::find(name, h_loader, h_prot, thread);
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
if (k != NULL) {
|
|
|
|
// Make sure that resolving is legal
|
|
|
|
EXCEPTION_MARK;
|
|
|
|
KlassHandle klass(THREAD, k);
|
|
|
|
// return NULL if verification fails
|
|
|
|
verify_constant_pool_resolve(this_oop, klass, THREAD);
|
|
|
|
if (HAS_PENDING_EXCEPTION) {
|
|
|
|
CLEAR_PENDING_EXCEPTION;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
return klass();
|
|
|
|
} else {
|
|
|
|
return k;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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
|
|
|
Klass* ConstantPool::klass_ref_at_if_loaded(constantPoolHandle this_oop, int which) {
|
2007-12-01 00:00:00 +00:00
|
|
|
return klass_at_if_loaded(this_oop, this_oop->klass_ref_index_at(which));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// This is an interface for the compiler that allows accessing non-resolved entries
|
|
|
|
// in the constant pool - but still performs the validations tests. Must be used
|
|
|
|
// in a pre-parse of the compiler - to determine what it can do and not do.
|
|
|
|
// Note: We cannot update the ConstantPool from the vm_thread.
|
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
|
|
|
Klass* ConstantPool::klass_ref_at_if_loaded_check(constantPoolHandle this_oop, int index, TRAPS) {
|
2007-12-01 00:00:00 +00:00
|
|
|
int which = this_oop->klass_ref_index_at(index);
|
2011-01-27 16:11:27 -08:00
|
|
|
CPSlot entry = this_oop->slot_at(which);
|
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
|
|
|
if (entry.is_resolved()) {
|
|
|
|
assert(entry.get_klass()->is_klass(), "must be");
|
|
|
|
return entry.get_klass();
|
2007-12-01 00:00:00 +00:00
|
|
|
} else {
|
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.is_unresolved(), "must be either symbol or klass");
|
2011-01-27 16:11:27 -08:00
|
|
|
Symbol* name = entry.get_symbol();
|
2012-11-06 15:09:37 -05:00
|
|
|
oop loader = this_oop->pool_holder()->class_loader();
|
|
|
|
oop protection_domain = this_oop->pool_holder()->protection_domain();
|
2007-12-01 00:00:00 +00:00
|
|
|
Handle h_loader(THREAD, loader);
|
|
|
|
Handle h_prot (THREAD, protection_domain);
|
|
|
|
KlassHandle k(THREAD, SystemDictionary::find(name, h_loader, h_prot, THREAD));
|
|
|
|
|
|
|
|
// Do access check for klasses
|
|
|
|
if( k.not_null() ) verify_constant_pool_resolve(this_oop, k, CHECK_NULL);
|
|
|
|
return k();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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
|
|
|
Method* ConstantPool::method_at_if_loaded(constantPoolHandle cpool,
|
2012-07-24 10:51:00 -07:00
|
|
|
int which) {
|
2012-01-30 12:36:49 +01:00
|
|
|
if (cpool->cache() == NULL) return NULL; // nothing to load yet
|
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
|
|
|
int cache_index = decode_cpcache_index(which, true);
|
2011-06-23 17:14:06 -07:00
|
|
|
if (!(cache_index >= 0 && cache_index < cpool->cache()->length())) {
|
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
|
|
|
// FIXME: should be an assert
|
2011-06-23 17:14:06 -07:00
|
|
|
if (PrintMiscellaneous && (Verbose||WizardMode)) {
|
2012-07-24 10:51:00 -07:00
|
|
|
tty->print_cr("bad operand %d in:", which); cpool->print();
|
2011-06-23 17:14:06 -07:00
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
ConstantPoolCacheEntry* e = cpool->cache()->entry_at(cache_index);
|
2012-07-24 10:51:00 -07:00
|
|
|
return e->method_if_resolved(cpool);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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
|
|
|
bool ConstantPool::has_appendix_at_if_loaded(constantPoolHandle cpool, int which) {
|
2012-07-24 10:51:00 -07:00
|
|
|
if (cpool->cache() == NULL) return false; // nothing to load yet
|
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
|
|
|
int cache_index = decode_cpcache_index(which, true);
|
|
|
|
ConstantPoolCacheEntry* e = cpool->cache()->entry_at(cache_index);
|
2012-07-24 10:51:00 -07:00
|
|
|
return e->has_appendix();
|
|
|
|
}
|
|
|
|
|
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
|
|
|
oop ConstantPool::appendix_at_if_loaded(constantPoolHandle cpool, int which) {
|
2012-07-24 10:51:00 -07:00
|
|
|
if (cpool->cache() == NULL) return NULL; // nothing to load yet
|
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
|
|
|
int cache_index = decode_cpcache_index(which, true);
|
|
|
|
ConstantPoolCacheEntry* e = cpool->cache()->entry_at(cache_index);
|
|
|
|
return e->appendix_if_resolved(cpool);
|
2011-06-23 17:14:06 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-10-01 14:50:10 -07:00
|
|
|
bool ConstantPool::has_method_type_at_if_loaded(constantPoolHandle cpool, int which) {
|
|
|
|
if (cpool->cache() == NULL) return false; // nothing to load yet
|
|
|
|
int cache_index = decode_cpcache_index(which, true);
|
|
|
|
ConstantPoolCacheEntry* e = cpool->cache()->entry_at(cache_index);
|
|
|
|
return e->has_method_type();
|
|
|
|
}
|
|
|
|
|
|
|
|
oop ConstantPool::method_type_at_if_loaded(constantPoolHandle cpool, int which) {
|
|
|
|
if (cpool->cache() == NULL) return NULL; // nothing to load yet
|
|
|
|
int cache_index = decode_cpcache_index(which, true);
|
|
|
|
ConstantPoolCacheEntry* e = cpool->cache()->entry_at(cache_index);
|
|
|
|
return e->method_type_if_resolved(cpool);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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
|
|
|
Symbol* ConstantPool::impl_name_ref_at(int which, bool uncached) {
|
2009-04-21 23:21:04 -07:00
|
|
|
int name_index = name_ref_index_at(impl_name_and_type_ref_index_at(which, uncached));
|
2007-12-01 00:00:00 +00:00
|
|
|
return symbol_at(name_index);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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
|
|
|
Symbol* ConstantPool::impl_signature_ref_at(int which, bool uncached) {
|
2009-04-21 23:21:04 -07:00
|
|
|
int signature_index = signature_ref_index_at(impl_name_and_type_ref_index_at(which, uncached));
|
2007-12-01 00:00:00 +00:00
|
|
|
return symbol_at(signature_index);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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
|
|
|
int ConstantPool::impl_name_and_type_ref_index_at(int which, bool uncached) {
|
2009-10-30 16:22:59 -07:00
|
|
|
int i = which;
|
|
|
|
if (!uncached && cache() != NULL) {
|
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
|
|
|
if (ConstantPool::is_invokedynamic_index(which)) {
|
|
|
|
// Invokedynamic index is index into resolved_references
|
|
|
|
int pool_index = invokedynamic_cp_cache_entry_at(which)->constant_pool_index();
|
2011-04-07 17:02:30 -07:00
|
|
|
pool_index = invoke_dynamic_name_and_type_ref_index_at(pool_index);
|
2010-07-15 18:40:45 -07:00
|
|
|
assert(tag_at(pool_index).is_name_and_type(), "");
|
|
|
|
return pool_index;
|
|
|
|
}
|
2009-10-30 16:22:59 -07:00
|
|
|
// change byte-ordering and go via cache
|
|
|
|
i = remap_instruction_operand_from_cache(which);
|
|
|
|
} else {
|
2010-10-30 13:08:23 -07:00
|
|
|
if (tag_at(which).is_invoke_dynamic()) {
|
|
|
|
int pool_index = invoke_dynamic_name_and_type_ref_index_at(which);
|
|
|
|
assert(tag_at(pool_index).is_name_and_type(), "");
|
|
|
|
return pool_index;
|
|
|
|
}
|
2009-10-30 16:22:59 -07:00
|
|
|
}
|
|
|
|
assert(tag_at(i).is_field_or_method(), "Corrupted constant pool");
|
2010-10-30 13:08:23 -07:00
|
|
|
assert(!tag_at(i).is_invoke_dynamic(), "Must be handled above");
|
2009-10-30 16:22:59 -07:00
|
|
|
jint ref_index = *int_at_addr(i);
|
2007-12-01 00:00:00 +00:00
|
|
|
return extract_high_short_from_int(ref_index);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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
|
|
|
int ConstantPool::impl_klass_ref_index_at(int which, bool uncached) {
|
|
|
|
guarantee(!ConstantPool::is_invokedynamic_index(which),
|
2009-10-30 16:22:59 -07:00
|
|
|
"an invokedynamic instruction does not have a klass");
|
|
|
|
int i = which;
|
|
|
|
if (!uncached && cache() != NULL) {
|
|
|
|
// change byte-ordering and go via cache
|
|
|
|
i = remap_instruction_operand_from_cache(which);
|
|
|
|
}
|
|
|
|
assert(tag_at(i).is_field_or_method(), "Corrupted constant pool");
|
|
|
|
jint ref_index = *int_at_addr(i);
|
2007-12-01 00:00:00 +00:00
|
|
|
return extract_low_short_from_int(ref_index);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-04-21 23:21:04 -07: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
|
|
|
int ConstantPool::remap_instruction_operand_from_cache(int operand) {
|
2010-05-23 01:38:26 -07:00
|
|
|
int cpc_index = operand;
|
|
|
|
DEBUG_ONLY(cpc_index -= CPCACHE_INDEX_TAG);
|
|
|
|
assert((int)(u2)cpc_index == cpc_index, "clean u2");
|
2009-10-30 16:22:59 -07:00
|
|
|
int member_index = cache()->entry_at(cpc_index)->constant_pool_index();
|
|
|
|
return member_index;
|
2009-04-21 23:21:04 -07: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
|
|
|
void ConstantPool::verify_constant_pool_resolve(constantPoolHandle this_oop, KlassHandle k, TRAPS) {
|
2007-12-01 00:00:00 +00:00
|
|
|
if (k->oop_is_instance() || k->oop_is_objArray()) {
|
|
|
|
instanceKlassHandle holder (THREAD, this_oop->pool_holder());
|
2012-09-29 06:40:00 -04:00
|
|
|
Klass* elem_oop = k->oop_is_instance() ? k() : ObjArrayKlass::cast(k())->bottom_klass();
|
2007-12-01 00:00:00 +00:00
|
|
|
KlassHandle element (THREAD, elem_oop);
|
|
|
|
|
|
|
|
// The element type could be a typeArray - we only need the access check if it is
|
|
|
|
// an reference to another class
|
|
|
|
if (element->oop_is_instance()) {
|
|
|
|
LinkResolver::check_klass_accessability(holder, element, CHECK);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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
|
|
|
int ConstantPool::name_ref_index_at(int which_nt) {
|
2009-04-21 23:21:04 -07:00
|
|
|
jint ref_index = name_and_type_at(which_nt);
|
2007-12-01 00:00:00 +00:00
|
|
|
return extract_low_short_from_int(ref_index);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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
|
|
|
int ConstantPool::signature_ref_index_at(int which_nt) {
|
2009-04-21 23:21:04 -07:00
|
|
|
jint ref_index = name_and_type_at(which_nt);
|
2007-12-01 00:00:00 +00:00
|
|
|
return extract_high_short_from_int(ref_index);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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
|
|
|
Klass* ConstantPool::klass_ref_at(int which, TRAPS) {
|
2007-12-01 00:00:00 +00:00
|
|
|
return klass_at(klass_ref_index_at(which), CHECK_NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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
|
|
|
Symbol* ConstantPool::klass_name_at(int which) {
|
2007-12-01 00:00:00 +00:00
|
|
|
assert(tag_at(which).is_unresolved_klass() || tag_at(which).is_klass(),
|
|
|
|
"Corrupted constant pool");
|
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
|
|
|
// A resolved constantPool entry will contain a Klass*, otherwise a Symbol*.
|
2007-12-01 00:00:00 +00:00
|
|
|
// It is not safe to rely on the tag bit's here, since we don't have a lock, and the entry and
|
|
|
|
// tag is not updated atomicly.
|
2011-01-27 16:11:27 -08:00
|
|
|
CPSlot entry = slot_at(which);
|
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
|
|
|
if (entry.is_resolved()) {
|
2007-12-01 00:00:00 +00:00
|
|
|
// Already resolved - return entry's name.
|
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.get_klass()->is_klass(), "must be");
|
|
|
|
return entry.get_klass()->name();
|
2007-12-01 00:00:00 +00:00
|
|
|
} else {
|
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.is_unresolved(), "must be either symbol or klass");
|
2011-01-27 16:11:27 -08:00
|
|
|
return entry.get_symbol();
|
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
|
|
|
Symbol* ConstantPool::klass_ref_at_noresolve(int which) {
|
2007-12-01 00:00:00 +00:00
|
|
|
jint ref_index = klass_ref_index_at(which);
|
|
|
|
return klass_at_noresolve(ref_index);
|
|
|
|
}
|
|
|
|
|
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
|
|
|
Symbol* ConstantPool::uncached_klass_ref_at_noresolve(int which) {
|
2010-06-09 18:50:45 -07:00
|
|
|
jint ref_index = uncached_klass_ref_index_at(which);
|
|
|
|
return klass_at_noresolve(ref_index);
|
|
|
|
}
|
|
|
|
|
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
|
|
|
char* ConstantPool::string_at_noresolve(int which) {
|
|
|
|
Symbol* s = unresolved_string_at(which);
|
|
|
|
if (s == NULL) {
|
2008-11-12 22:33:26 -08:00
|
|
|
return (char*)"<pseudo-string>";
|
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
|
|
|
} else {
|
|
|
|
return unresolved_string_at(which)->as_C_string();
|
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
|
|
|
BasicType ConstantPool::basic_type_for_signature_at(int which) {
|
2007-12-01 00:00:00 +00:00
|
|
|
return FieldType::basic_type(symbol_at(which));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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 ConstantPool::resolve_string_constants_impl(constantPoolHandle this_oop, TRAPS) {
|
2007-12-01 00:00:00 +00:00
|
|
|
for (int index = 1; index < this_oop->length(); index++) { // Index 0 is unused
|
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
|
|
|
if (this_oop->tag_at(index).is_string()) {
|
2007-12-01 00:00:00 +00:00
|
|
|
this_oop->string_at(index, CHECK);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
|
|
// Resolve all the classes in the constant pool. If they are all resolved,
|
|
|
|
// the constant pool is read-only. Enhancement: allocate cp entries to
|
|
|
|
// another metaspace, and copy to read-only or read-write space if this
|
|
|
|
// bit is set.
|
|
|
|
bool ConstantPool::resolve_class_constants(TRAPS) {
|
|
|
|
constantPoolHandle cp(THREAD, this);
|
|
|
|
for (int index = 1; index < length(); index++) { // Index 0 is unused
|
|
|
|
if (tag_at(index).is_unresolved_klass() &&
|
|
|
|
klass_at_if_loaded(cp, index) == NULL) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// set_preresolution(); or some bit for future use
|
|
|
|
return true;
|
|
|
|
}
|
2010-10-30 13:08:23 -07: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
|
|
|
// If resolution for MethodHandle or MethodType fails, save the exception
|
|
|
|
// in the resolution error table, so that the same exception is thrown again.
|
|
|
|
void ConstantPool::save_and_throw_exception(constantPoolHandle this_oop, int which,
|
|
|
|
int tag, TRAPS) {
|
|
|
|
ResourceMark rm;
|
|
|
|
Symbol* error = PENDING_EXCEPTION->klass()->name();
|
|
|
|
MonitorLockerEx ml(this_oop->lock()); // lock cpool to change tag.
|
|
|
|
|
|
|
|
int error_tag = (tag == JVM_CONSTANT_MethodHandle) ?
|
|
|
|
JVM_CONSTANT_MethodHandleInError : JVM_CONSTANT_MethodTypeInError;
|
|
|
|
|
|
|
|
if (!PENDING_EXCEPTION->
|
|
|
|
is_a(SystemDictionary::LinkageError_klass())) {
|
|
|
|
// Just throw the exception and don't prevent these classes from
|
|
|
|
// being loaded due to virtual machine errors like StackOverflow
|
|
|
|
// and OutOfMemoryError, etc, or if the thread was hit by stop()
|
|
|
|
// Needs clarification to section 5.4.3 of the VM spec (see 6308271)
|
|
|
|
|
|
|
|
} else if (this_oop->tag_at(which).value() != error_tag) {
|
|
|
|
SystemDictionary::add_resolution_error(this_oop, which, error);
|
|
|
|
this_oop->tag_at_put(which, error_tag);
|
|
|
|
} else {
|
|
|
|
// some other thread has put the class in error state.
|
|
|
|
error = SystemDictionary::find_resolution_error(this_oop, which);
|
|
|
|
assert(error != NULL, "checking");
|
|
|
|
CLEAR_PENDING_EXCEPTION;
|
|
|
|
THROW_MSG(error, "");
|
2010-10-30 13:08:23 -07: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
|
|
|
|
|
|
|
// Called to resolve constants in the constant pool and return an oop.
|
|
|
|
// Some constant pool entries cache their resolved oop. This is also
|
|
|
|
// called to create oops from constants to use in arguments for invokedynamic
|
|
|
|
oop ConstantPool::resolve_constant_at_impl(constantPoolHandle this_oop, int index, int cache_index, TRAPS) {
|
2010-06-09 18:50:45 -07:00
|
|
|
oop result_oop = NULL;
|
2010-10-30 13:08:23 -07:00
|
|
|
Handle throw_exception;
|
|
|
|
|
|
|
|
if (cache_index == _possible_index_sentinel) {
|
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
|
|
|
// It is possible that this constant is one which is cached in the objects.
|
2010-10-30 13:08:23 -07:00
|
|
|
// We'll do a linear search. This should be OK because this usage is rare.
|
|
|
|
assert(index > 0, "valid index");
|
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
|
|
|
cache_index = this_oop->cp_to_object_index(index);
|
2010-10-30 13:08:23 -07:00
|
|
|
}
|
|
|
|
assert(cache_index == _no_index_sentinel || cache_index >= 0, "");
|
|
|
|
assert(index == _no_index_sentinel || index >= 0, "");
|
|
|
|
|
2010-06-09 18:50:45 -07:00
|
|
|
if (cache_index >= 0) {
|
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
|
|
|
result_oop = this_oop->resolved_references()->obj_at(cache_index);
|
2010-06-09 18:50:45 -07:00
|
|
|
if (result_oop != NULL) {
|
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
|
|
|
return result_oop;
|
2010-10-30 13:08:23 -07:00
|
|
|
// That was easy...
|
2010-06-09 18:50:45 -07: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
|
|
|
index = this_oop->object_to_cp_index(cache_index);
|
2010-06-09 18:50:45 -07:00
|
|
|
}
|
|
|
|
|
2010-10-30 13:08:23 -07:00
|
|
|
jvalue prim_value; // temp used only in a few cases below
|
|
|
|
|
2010-06-09 18:50:45 -07:00
|
|
|
int tag_value = this_oop->tag_at(index).value();
|
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
|
|
|
|
2010-06-09 18:50:45 -07:00
|
|
|
switch (tag_value) {
|
|
|
|
|
|
|
|
case JVM_CONSTANT_UnresolvedClass:
|
|
|
|
case JVM_CONSTANT_UnresolvedClassInError:
|
|
|
|
case JVM_CONSTANT_Class:
|
|
|
|
{
|
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(cache_index == _no_index_sentinel, "should not have been set");
|
|
|
|
Klass* resolved = klass_at_impl(this_oop, index, CHECK_NULL);
|
2010-06-09 18:50:45 -07:00
|
|
|
// ldc wants the java mirror.
|
2011-03-18 16:00:34 -07:00
|
|
|
result_oop = resolved->java_mirror();
|
2010-06-09 18:50:45 -07:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case JVM_CONSTANT_String:
|
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(cache_index != _no_index_sentinel, "should have been set");
|
2010-06-09 18:50:45 -07:00
|
|
|
if (this_oop->is_pseudo_string_at(index)) {
|
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
|
|
|
result_oop = this_oop->pseudo_string_at(index, cache_index);
|
2010-06-09 18:50:45 -07:00
|
|
|
break;
|
|
|
|
}
|
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
|
|
|
result_oop = string_at_impl(this_oop, index, cache_index, CHECK_NULL);
|
2010-06-09 18:50:45 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case JVM_CONSTANT_Object:
|
|
|
|
result_oop = this_oop->object_at(index);
|
|
|
|
break;
|
|
|
|
|
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
|
|
|
case JVM_CONSTANT_MethodHandleInError:
|
|
|
|
case JVM_CONSTANT_MethodTypeInError:
|
|
|
|
{
|
|
|
|
Symbol* error = SystemDictionary::find_resolution_error(this_oop, index);
|
|
|
|
guarantee(error != (Symbol*)NULL, "tag mismatch with resolution error table");
|
|
|
|
ResourceMark rm;
|
|
|
|
THROW_MSG_0(error, "");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2010-06-09 18:50:45 -07:00
|
|
|
case JVM_CONSTANT_MethodHandle:
|
|
|
|
{
|
|
|
|
int ref_kind = this_oop->method_handle_ref_kind_at(index);
|
|
|
|
int callee_index = this_oop->method_handle_klass_index_at(index);
|
2011-01-27 16:11:27 -08:00
|
|
|
Symbol* name = this_oop->method_handle_name_ref_at(index);
|
|
|
|
Symbol* signature = this_oop->method_handle_signature_ref_at(index);
|
2010-06-09 18:50:45 -07:00
|
|
|
if (PrintMiscellaneous)
|
|
|
|
tty->print_cr("resolve JVM_CONSTANT_MethodHandle:%d [%d/%d/%d] %s.%s",
|
|
|
|
ref_kind, index, this_oop->method_handle_index_at(index),
|
|
|
|
callee_index, name->as_C_string(), signature->as_C_string());
|
|
|
|
KlassHandle callee;
|
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
|
|
|
{ Klass* k = klass_at_impl(this_oop, callee_index, CHECK_NULL);
|
2010-06-09 18:50:45 -07:00
|
|
|
callee = KlassHandle(THREAD, k);
|
|
|
|
}
|
|
|
|
KlassHandle klass(THREAD, this_oop->pool_holder());
|
|
|
|
Handle value = SystemDictionary::link_method_handle_constant(klass, ref_kind,
|
|
|
|
callee, name, signature,
|
2010-10-30 13:08:23 -07:00
|
|
|
THREAD);
|
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
|
|
|
result_oop = value();
|
2010-10-30 13:08:23 -07:00
|
|
|
if (HAS_PENDING_EXCEPTION) {
|
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
|
|
|
save_and_throw_exception(this_oop, index, tag_value, CHECK_NULL);
|
2010-10-30 13:08:23 -07:00
|
|
|
}
|
2010-06-09 18:50:45 -07:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case JVM_CONSTANT_MethodType:
|
|
|
|
{
|
2011-01-27 16:11:27 -08:00
|
|
|
Symbol* signature = this_oop->method_type_signature_at(index);
|
2010-06-09 18:50:45 -07:00
|
|
|
if (PrintMiscellaneous)
|
|
|
|
tty->print_cr("resolve JVM_CONSTANT_MethodType [%d/%d] %s",
|
|
|
|
index, this_oop->method_type_index_at(index),
|
|
|
|
signature->as_C_string());
|
|
|
|
KlassHandle klass(THREAD, this_oop->pool_holder());
|
2012-07-24 10:51:00 -07:00
|
|
|
Handle value = SystemDictionary::find_method_handle_type(signature, klass, THREAD);
|
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
|
|
|
result_oop = value();
|
2010-10-30 13:08:23 -07:00
|
|
|
if (HAS_PENDING_EXCEPTION) {
|
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
|
|
|
save_and_throw_exception(this_oop, index, tag_value, CHECK_NULL);
|
2010-10-30 13:08:23 -07:00
|
|
|
}
|
2010-06-09 18:50:45 -07:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case JVM_CONSTANT_Integer:
|
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(cache_index == _no_index_sentinel, "should not have been set");
|
2010-10-30 13:08:23 -07:00
|
|
|
prim_value.i = this_oop->int_at(index);
|
|
|
|
result_oop = java_lang_boxing_object::create(T_INT, &prim_value, CHECK_NULL);
|
|
|
|
break;
|
|
|
|
|
2010-06-09 18:50:45 -07:00
|
|
|
case JVM_CONSTANT_Float:
|
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(cache_index == _no_index_sentinel, "should not have been set");
|
2010-10-30 13:08:23 -07:00
|
|
|
prim_value.f = this_oop->float_at(index);
|
|
|
|
result_oop = java_lang_boxing_object::create(T_FLOAT, &prim_value, CHECK_NULL);
|
|
|
|
break;
|
|
|
|
|
2010-06-09 18:50:45 -07:00
|
|
|
case JVM_CONSTANT_Long:
|
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(cache_index == _no_index_sentinel, "should not have been set");
|
2010-10-30 13:08:23 -07:00
|
|
|
prim_value.j = this_oop->long_at(index);
|
|
|
|
result_oop = java_lang_boxing_object::create(T_LONG, &prim_value, CHECK_NULL);
|
|
|
|
break;
|
|
|
|
|
2010-06-09 18:50:45 -07:00
|
|
|
case JVM_CONSTANT_Double:
|
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(cache_index == _no_index_sentinel, "should not have been set");
|
2010-10-30 13:08:23 -07:00
|
|
|
prim_value.d = this_oop->double_at(index);
|
|
|
|
result_oop = java_lang_boxing_object::create(T_DOUBLE, &prim_value, CHECK_NULL);
|
2010-06-09 18:50:45 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
DEBUG_ONLY( tty->print_cr("*** %p: tag at CP[%d/%d] = %d",
|
|
|
|
this_oop(), index, cache_index, tag_value) );
|
|
|
|
assert(false, "unexpected constant tag");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (cache_index >= 0) {
|
|
|
|
// Cache the oop here also.
|
2010-10-30 13:08:23 -07:00
|
|
|
Handle result_handle(THREAD, result_oop);
|
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
|
|
|
MonitorLockerEx ml(this_oop->lock()); // don't know if we really need this
|
|
|
|
oop result = this_oop->resolved_references()->obj_at(cache_index);
|
|
|
|
// Benign race condition: resolved_references may already be filled in while we were trying to lock.
|
2010-10-30 13:08:23 -07:00
|
|
|
// The important thing here is that all threads pick up the same result.
|
|
|
|
// It doesn't matter which racing thread wins, as long as only one
|
|
|
|
// result is used by all threads, and all future queries.
|
|
|
|
// That result may be either a resolved constant or a failure exception.
|
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
|
|
|
if (result == NULL) {
|
|
|
|
this_oop->resolved_references()->obj_at_put(cache_index, result_handle());
|
|
|
|
return result_handle();
|
|
|
|
} else {
|
|
|
|
// Return the winning thread's result. This can be different than
|
|
|
|
// result_handle() for MethodHandles.
|
|
|
|
return result;
|
2010-06-09 18:50:45 -07:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return result_oop;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
|
|
oop ConstantPool::uncached_string_at(int which, TRAPS) {
|
|
|
|
Symbol* sym = unresolved_string_at(which);
|
|
|
|
oop str = StringTable::intern(sym, CHECK_(NULL));
|
|
|
|
assert(java_lang_String::is_instance(str), "must be string");
|
|
|
|
return str;
|
|
|
|
}
|
|
|
|
|
2012-07-24 10:51:00 -07: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
|
|
|
oop ConstantPool::resolve_bootstrap_specifier_at_impl(constantPoolHandle this_oop, int index, TRAPS) {
|
2012-07-24 10:51:00 -07:00
|
|
|
assert(this_oop->tag_at(index).is_invoke_dynamic(), "Corrupted constant pool");
|
|
|
|
|
|
|
|
Handle bsm;
|
|
|
|
int argc;
|
|
|
|
{
|
|
|
|
// JVM_CONSTANT_InvokeDynamic is an ordered pair of [bootm, name&type], plus optional arguments
|
|
|
|
// The bootm, being a JVM_CONSTANT_MethodHandle, has its own cache entry.
|
|
|
|
// It is accompanied by the optional arguments.
|
|
|
|
int bsm_index = this_oop->invoke_dynamic_bootstrap_method_ref_index_at(index);
|
|
|
|
oop bsm_oop = this_oop->resolve_possibly_cached_constant_at(bsm_index, CHECK_NULL);
|
|
|
|
if (!java_lang_invoke_MethodHandle::is_instance(bsm_oop)) {
|
|
|
|
THROW_MSG_NULL(vmSymbols::java_lang_LinkageError(), "BSM not an MethodHandle");
|
|
|
|
}
|
|
|
|
|
|
|
|
// Extract the optional static arguments.
|
|
|
|
argc = this_oop->invoke_dynamic_argument_count_at(index);
|
|
|
|
if (argc == 0) return bsm_oop;
|
|
|
|
|
|
|
|
bsm = Handle(THREAD, bsm_oop);
|
|
|
|
}
|
|
|
|
|
|
|
|
objArrayHandle info;
|
|
|
|
{
|
|
|
|
objArrayOop info_oop = oopFactory::new_objArray(SystemDictionary::Object_klass(), 1+argc, CHECK_NULL);
|
|
|
|
info = objArrayHandle(THREAD, info_oop);
|
|
|
|
}
|
|
|
|
|
|
|
|
info->obj_at_put(0, bsm());
|
|
|
|
for (int i = 0; i < argc; i++) {
|
|
|
|
int arg_index = this_oop->invoke_dynamic_argument_index_at(index, i);
|
|
|
|
oop arg_oop = this_oop->resolve_possibly_cached_constant_at(arg_index, CHECK_NULL);
|
|
|
|
info->obj_at_put(1+i, arg_oop);
|
|
|
|
}
|
|
|
|
|
|
|
|
return info();
|
|
|
|
}
|
|
|
|
|
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
|
|
|
oop ConstantPool::string_at_impl(constantPoolHandle this_oop, int which, int obj_index, TRAPS) {
|
|
|
|
// If the string has already been interned, this entry will be non-null
|
|
|
|
oop str = this_oop->resolved_references()->obj_at(obj_index);
|
|
|
|
if (str != NULL) return str;
|
|
|
|
|
2011-01-27 16:11:27 -08:00
|
|
|
Symbol* sym = this_oop->unresolved_string_at(which);
|
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
|
|
|
str = StringTable::intern(sym, CHECK_(NULL));
|
|
|
|
this_oop->string_at_put(which, obj_index, str);
|
2011-01-27 16:11:27 -08:00
|
|
|
assert(java_lang_String::is_instance(str), "must be string");
|
|
|
|
return str;
|
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
|
|
|
bool ConstantPool::klass_name_at_matches(instanceKlassHandle k,
|
2007-12-01 00:00:00 +00:00
|
|
|
int which) {
|
2011-01-27 16:11:27 -08:00
|
|
|
// Names are interned, so we can compare Symbol*s directly
|
|
|
|
Symbol* cp_name = klass_name_at(which);
|
2007-12-01 00:00:00 +00:00
|
|
|
return (cp_name == k->name());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-01-27 16:11:27 -08:00
|
|
|
// Iterate over symbols and decrement ones which are Symbol*s.
|
|
|
|
// This is done during GC so do not need to lock constantPool unless we
|
|
|
|
// have per-thread safepoints.
|
|
|
|
// Only decrement the UTF8 symbols. Unresolved classes and strings point to
|
|
|
|
// these symbols but didn't increment the reference count.
|
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 ConstantPool::unreference_symbols() {
|
2011-01-27 16:11:27 -08:00
|
|
|
for (int index = 1; index < length(); index++) { // Index 0 is unused
|
|
|
|
constantTag tag = tag_at(index);
|
|
|
|
if (tag.is_symbol()) {
|
|
|
|
symbol_at(index)->decrement_refcount();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
|
|
|
|
// Compare this constant pool's entry at index1 to the constant pool
|
|
|
|
// cp2's entry at index2.
|
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
|
|
|
bool ConstantPool::compare_entry_to(int index1, constantPoolHandle cp2,
|
2007-12-01 00:00:00 +00:00
|
|
|
int index2, TRAPS) {
|
|
|
|
|
|
|
|
jbyte t1 = tag_at(index1).value();
|
|
|
|
jbyte t2 = cp2->tag_at(index2).value();
|
|
|
|
|
|
|
|
|
|
|
|
// JVM_CONSTANT_UnresolvedClassInError is equal to JVM_CONSTANT_UnresolvedClass
|
|
|
|
// when comparing
|
|
|
|
if (t1 == JVM_CONSTANT_UnresolvedClassInError) {
|
|
|
|
t1 = JVM_CONSTANT_UnresolvedClass;
|
|
|
|
}
|
|
|
|
if (t2 == JVM_CONSTANT_UnresolvedClassInError) {
|
|
|
|
t2 = JVM_CONSTANT_UnresolvedClass;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (t1 != t2) {
|
|
|
|
// Not the same entry type so there is nothing else to check. Note
|
|
|
|
// that this style of checking will consider resolved/unresolved
|
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
|
|
|
// class pairs as different.
|
|
|
|
// From the ConstantPool* API point of view, this is correct
|
|
|
|
// behavior. See VM_RedefineClasses::merge_constant_pools() to see how this
|
|
|
|
// plays out in the context of ConstantPool* merging.
|
2007-12-01 00:00:00 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (t1) {
|
|
|
|
case JVM_CONSTANT_Class:
|
|
|
|
{
|
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
|
|
|
Klass* k1 = klass_at(index1, CHECK_false);
|
|
|
|
Klass* k2 = cp2->klass_at(index2, CHECK_false);
|
2007-12-01 00:00:00 +00:00
|
|
|
if (k1 == k2) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
} break;
|
|
|
|
|
|
|
|
case JVM_CONSTANT_ClassIndex:
|
|
|
|
{
|
|
|
|
int recur1 = klass_index_at(index1);
|
|
|
|
int recur2 = cp2->klass_index_at(index2);
|
|
|
|
bool match = compare_entry_to(recur1, cp2, recur2, CHECK_false);
|
|
|
|
if (match) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
} break;
|
|
|
|
|
|
|
|
case JVM_CONSTANT_Double:
|
|
|
|
{
|
|
|
|
jdouble d1 = double_at(index1);
|
|
|
|
jdouble d2 = cp2->double_at(index2);
|
|
|
|
if (d1 == d2) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
} break;
|
|
|
|
|
|
|
|
case JVM_CONSTANT_Fieldref:
|
|
|
|
case JVM_CONSTANT_InterfaceMethodref:
|
|
|
|
case JVM_CONSTANT_Methodref:
|
|
|
|
{
|
|
|
|
int recur1 = uncached_klass_ref_index_at(index1);
|
|
|
|
int recur2 = cp2->uncached_klass_ref_index_at(index2);
|
|
|
|
bool match = compare_entry_to(recur1, cp2, recur2, CHECK_false);
|
|
|
|
if (match) {
|
|
|
|
recur1 = uncached_name_and_type_ref_index_at(index1);
|
|
|
|
recur2 = cp2->uncached_name_and_type_ref_index_at(index2);
|
|
|
|
match = compare_entry_to(recur1, cp2, recur2, CHECK_false);
|
|
|
|
if (match) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} break;
|
|
|
|
|
|
|
|
case JVM_CONSTANT_Float:
|
|
|
|
{
|
|
|
|
jfloat f1 = float_at(index1);
|
|
|
|
jfloat f2 = cp2->float_at(index2);
|
|
|
|
if (f1 == f2) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
} break;
|
|
|
|
|
|
|
|
case JVM_CONSTANT_Integer:
|
|
|
|
{
|
|
|
|
jint i1 = int_at(index1);
|
|
|
|
jint i2 = cp2->int_at(index2);
|
|
|
|
if (i1 == i2) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
} break;
|
|
|
|
|
|
|
|
case JVM_CONSTANT_Long:
|
|
|
|
{
|
|
|
|
jlong l1 = long_at(index1);
|
|
|
|
jlong l2 = cp2->long_at(index2);
|
|
|
|
if (l1 == l2) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
} break;
|
|
|
|
|
|
|
|
case JVM_CONSTANT_NameAndType:
|
|
|
|
{
|
|
|
|
int recur1 = name_ref_index_at(index1);
|
|
|
|
int recur2 = cp2->name_ref_index_at(index2);
|
|
|
|
bool match = compare_entry_to(recur1, cp2, recur2, CHECK_false);
|
|
|
|
if (match) {
|
|
|
|
recur1 = signature_ref_index_at(index1);
|
|
|
|
recur2 = cp2->signature_ref_index_at(index2);
|
|
|
|
match = compare_entry_to(recur1, cp2, recur2, CHECK_false);
|
|
|
|
if (match) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} break;
|
|
|
|
|
|
|
|
case JVM_CONSTANT_StringIndex:
|
|
|
|
{
|
|
|
|
int recur1 = string_index_at(index1);
|
|
|
|
int recur2 = cp2->string_index_at(index2);
|
|
|
|
bool match = compare_entry_to(recur1, cp2, recur2, CHECK_false);
|
|
|
|
if (match) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
} break;
|
|
|
|
|
|
|
|
case JVM_CONSTANT_UnresolvedClass:
|
|
|
|
{
|
2011-01-27 16:11:27 -08:00
|
|
|
Symbol* k1 = unresolved_klass_at(index1);
|
|
|
|
Symbol* k2 = cp2->unresolved_klass_at(index2);
|
2007-12-01 00:00:00 +00:00
|
|
|
if (k1 == k2) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
} break;
|
|
|
|
|
2010-06-09 18:50:45 -07:00
|
|
|
case JVM_CONSTANT_MethodType:
|
|
|
|
{
|
|
|
|
int k1 = method_type_index_at(index1);
|
|
|
|
int k2 = cp2->method_type_index_at(index2);
|
2010-12-03 15:53:57 -08:00
|
|
|
bool match = compare_entry_to(k1, cp2, k2, CHECK_false);
|
|
|
|
if (match) {
|
2010-06-09 18:50:45 -07:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
} break;
|
|
|
|
|
|
|
|
case JVM_CONSTANT_MethodHandle:
|
|
|
|
{
|
|
|
|
int k1 = method_handle_ref_kind_at(index1);
|
|
|
|
int k2 = cp2->method_handle_ref_kind_at(index2);
|
|
|
|
if (k1 == k2) {
|
|
|
|
int i1 = method_handle_index_at(index1);
|
|
|
|
int i2 = cp2->method_handle_index_at(index2);
|
2010-12-03 15:53:57 -08:00
|
|
|
bool match = compare_entry_to(i1, cp2, i2, CHECK_false);
|
|
|
|
if (match) {
|
2010-06-09 18:50:45 -07:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} break;
|
|
|
|
|
2010-07-15 18:40:45 -07:00
|
|
|
case JVM_CONSTANT_InvokeDynamic:
|
|
|
|
{
|
2010-12-03 15:53:57 -08:00
|
|
|
int k1 = invoke_dynamic_bootstrap_method_ref_index_at(index1);
|
|
|
|
int k2 = cp2->invoke_dynamic_bootstrap_method_ref_index_at(index2);
|
|
|
|
bool match = compare_entry_to(k1, cp2, k2, CHECK_false);
|
|
|
|
if (!match) return false;
|
|
|
|
k1 = invoke_dynamic_name_and_type_ref_index_at(index1);
|
|
|
|
k2 = cp2->invoke_dynamic_name_and_type_ref_index_at(index2);
|
|
|
|
match = compare_entry_to(k1, cp2, k2, CHECK_false);
|
|
|
|
if (!match) return false;
|
|
|
|
int argc = invoke_dynamic_argument_count_at(index1);
|
|
|
|
if (argc == cp2->invoke_dynamic_argument_count_at(index2)) {
|
|
|
|
for (int j = 0; j < argc; j++) {
|
|
|
|
k1 = invoke_dynamic_argument_index_at(index1, j);
|
|
|
|
k2 = cp2->invoke_dynamic_argument_index_at(index2, j);
|
|
|
|
match = compare_entry_to(k1, cp2, k2, CHECK_false);
|
|
|
|
if (!match) return false;
|
2010-07-15 18:40:45 -07:00
|
|
|
}
|
2010-12-03 15:53:57 -08:00
|
|
|
return true; // got through loop; all elements equal
|
2010-07-15 18:40:45 -07:00
|
|
|
}
|
|
|
|
} break;
|
|
|
|
|
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
|
|
|
case JVM_CONSTANT_String:
|
2007-12-01 00:00:00 +00:00
|
|
|
{
|
2011-01-27 16:11:27 -08:00
|
|
|
Symbol* s1 = unresolved_string_at(index1);
|
|
|
|
Symbol* s2 = cp2->unresolved_string_at(index2);
|
2007-12-01 00:00:00 +00:00
|
|
|
if (s1 == s2) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
} break;
|
|
|
|
|
|
|
|
case JVM_CONSTANT_Utf8:
|
|
|
|
{
|
2011-01-27 16:11:27 -08:00
|
|
|
Symbol* s1 = symbol_at(index1);
|
|
|
|
Symbol* s2 = cp2->symbol_at(index2);
|
2007-12-01 00:00:00 +00:00
|
|
|
if (s1 == s2) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
} break;
|
|
|
|
|
|
|
|
// Invalid is used as the tag for the second constant pool entry
|
|
|
|
// occupied by JVM_CONSTANT_Double or JVM_CONSTANT_Long. It should
|
|
|
|
// not be seen by itself.
|
|
|
|
case JVM_CONSTANT_Invalid: // fall through
|
|
|
|
|
|
|
|
default:
|
|
|
|
ShouldNotReachHere();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
} // end compare_entry_to()
|
|
|
|
|
|
|
|
|
|
|
|
// Copy this constant pool's entries at start_i to end_i (inclusive)
|
|
|
|
// to the constant pool to_cp's entries starting at to_i. A total of
|
|
|
|
// (end_i - start_i) + 1 entries are copied.
|
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 ConstantPool::copy_cp_to_impl(constantPoolHandle from_cp, int start_i, int end_i,
|
2007-12-01 00:00:00 +00:00
|
|
|
constantPoolHandle to_cp, int to_i, TRAPS) {
|
|
|
|
|
|
|
|
int dest_i = to_i; // leave original alone for debug purposes
|
|
|
|
|
|
|
|
for (int src_i = start_i; src_i <= end_i; /* see loop bottom */ ) {
|
2010-12-03 15:53:57 -08:00
|
|
|
copy_entry_to(from_cp, src_i, to_cp, dest_i, CHECK);
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2010-12-03 15:53:57 -08:00
|
|
|
switch (from_cp->tag_at(src_i).value()) {
|
2007-12-01 00:00:00 +00:00
|
|
|
case JVM_CONSTANT_Double:
|
|
|
|
case JVM_CONSTANT_Long:
|
|
|
|
// double and long take two constant pool entries
|
|
|
|
src_i += 2;
|
|
|
|
dest_i += 2;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
// all others take one constant pool entry
|
|
|
|
src_i++;
|
|
|
|
dest_i++;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2010-12-03 15:53:57 -08:00
|
|
|
|
|
|
|
int from_oplen = operand_array_length(from_cp->operands());
|
|
|
|
int old_oplen = operand_array_length(to_cp->operands());
|
|
|
|
if (from_oplen != 0) {
|
2012-10-11 12:25:42 -04:00
|
|
|
ClassLoaderData* loader_data = to_cp->pool_holder()->class_loader_data();
|
2010-12-03 15:53:57 -08:00
|
|
|
// append my operands to the target's operands array
|
|
|
|
if (old_oplen == 0) {
|
2012-10-11 12:25:42 -04:00
|
|
|
// Can't just reuse from_cp's operand list because of deallocation issues
|
|
|
|
int len = from_cp->operands()->length();
|
|
|
|
Array<u2>* new_ops = MetadataFactory::new_array<u2>(loader_data, len, CHECK);
|
|
|
|
Copy::conjoint_memory_atomic(
|
|
|
|
from_cp->operands()->adr_at(0), new_ops->adr_at(0), len * sizeof(u2));
|
|
|
|
to_cp->set_operands(new_ops);
|
2010-12-03 15:53:57 -08:00
|
|
|
} else {
|
|
|
|
int old_len = to_cp->operands()->length();
|
|
|
|
int from_len = from_cp->operands()->length();
|
|
|
|
int old_off = old_oplen * sizeof(u2);
|
|
|
|
int from_off = from_oplen * sizeof(u2);
|
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
|
|
|
// Use the metaspace for the destination constant pool
|
|
|
|
Array<u2>* new_operands = MetadataFactory::new_array<u2>(loader_data, old_len + from_len, CHECK);
|
2010-12-03 15:53:57 -08:00
|
|
|
int fillp = 0, len = 0;
|
|
|
|
// first part of dest
|
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
|
|
|
Copy::conjoint_memory_atomic(to_cp->operands()->adr_at(0),
|
|
|
|
new_operands->adr_at(fillp),
|
2010-12-03 15:53:57 -08:00
|
|
|
(len = old_off) * sizeof(u2));
|
|
|
|
fillp += len;
|
|
|
|
// first part of src
|
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
|
|
|
Copy::conjoint_memory_atomic(to_cp->operands()->adr_at(0),
|
|
|
|
new_operands->adr_at(fillp),
|
2010-12-03 15:53:57 -08:00
|
|
|
(len = from_off) * sizeof(u2));
|
|
|
|
fillp += len;
|
|
|
|
// second part of dest
|
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
|
|
|
Copy::conjoint_memory_atomic(to_cp->operands()->adr_at(old_off),
|
|
|
|
new_operands->adr_at(fillp),
|
2010-12-03 15:53:57 -08:00
|
|
|
(len = old_len - old_off) * sizeof(u2));
|
|
|
|
fillp += len;
|
|
|
|
// second part of src
|
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
|
|
|
Copy::conjoint_memory_atomic(to_cp->operands()->adr_at(from_off),
|
|
|
|
new_operands->adr_at(fillp),
|
2010-12-03 15:53:57 -08:00
|
|
|
(len = from_len - from_off) * sizeof(u2));
|
|
|
|
fillp += len;
|
|
|
|
assert(fillp == new_operands->length(), "");
|
|
|
|
|
|
|
|
// Adjust indexes in the first part of the copied operands array.
|
|
|
|
for (int j = 0; j < from_oplen; j++) {
|
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
|
|
|
int offset = operand_offset_at(new_operands, old_oplen + j);
|
2010-12-03 15:53:57 -08:00
|
|
|
assert(offset == operand_offset_at(from_cp->operands(), j), "correct copy");
|
|
|
|
offset += old_len; // every new tuple is preceded by old_len extra u2's
|
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
|
|
|
operand_offset_at_put(new_operands, old_oplen + j, offset);
|
2010-12-03 15:53:57 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
// replace target operands array with combined array
|
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
|
|
|
to_cp->set_operands(new_operands);
|
2010-12-03 15:53:57 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
} // end copy_cp_to()
|
|
|
|
|
|
|
|
|
|
|
|
// Copy this constant pool's entry at from_i to the constant pool
|
|
|
|
// to_cp's entry at to_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
|
|
|
void ConstantPool::copy_entry_to(constantPoolHandle from_cp, int from_i,
|
2010-12-03 15:53:57 -08:00
|
|
|
constantPoolHandle to_cp, int to_i,
|
|
|
|
TRAPS) {
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2010-12-03 15:53:57 -08:00
|
|
|
int tag = from_cp->tag_at(from_i).value();
|
|
|
|
switch (tag) {
|
2007-12-01 00:00:00 +00:00
|
|
|
case JVM_CONSTANT_Class:
|
|
|
|
{
|
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
|
|
|
Klass* k = from_cp->klass_at(from_i, CHECK);
|
2007-12-01 00:00:00 +00:00
|
|
|
to_cp->klass_at_put(to_i, k);
|
|
|
|
} break;
|
|
|
|
|
|
|
|
case JVM_CONSTANT_ClassIndex:
|
|
|
|
{
|
2010-12-03 15:53:57 -08:00
|
|
|
jint ki = from_cp->klass_index_at(from_i);
|
2007-12-01 00:00:00 +00:00
|
|
|
to_cp->klass_index_at_put(to_i, ki);
|
|
|
|
} break;
|
|
|
|
|
|
|
|
case JVM_CONSTANT_Double:
|
|
|
|
{
|
2010-12-03 15:53:57 -08:00
|
|
|
jdouble d = from_cp->double_at(from_i);
|
2007-12-01 00:00:00 +00:00
|
|
|
to_cp->double_at_put(to_i, d);
|
|
|
|
// double takes two constant pool entries so init second entry's tag
|
|
|
|
to_cp->tag_at_put(to_i + 1, JVM_CONSTANT_Invalid);
|
|
|
|
} break;
|
|
|
|
|
|
|
|
case JVM_CONSTANT_Fieldref:
|
|
|
|
{
|
2010-12-03 15:53:57 -08:00
|
|
|
int class_index = from_cp->uncached_klass_ref_index_at(from_i);
|
|
|
|
int name_and_type_index = from_cp->uncached_name_and_type_ref_index_at(from_i);
|
2007-12-01 00:00:00 +00:00
|
|
|
to_cp->field_at_put(to_i, class_index, name_and_type_index);
|
|
|
|
} break;
|
|
|
|
|
|
|
|
case JVM_CONSTANT_Float:
|
|
|
|
{
|
2010-12-03 15:53:57 -08:00
|
|
|
jfloat f = from_cp->float_at(from_i);
|
2007-12-01 00:00:00 +00:00
|
|
|
to_cp->float_at_put(to_i, f);
|
|
|
|
} break;
|
|
|
|
|
|
|
|
case JVM_CONSTANT_Integer:
|
|
|
|
{
|
2010-12-03 15:53:57 -08:00
|
|
|
jint i = from_cp->int_at(from_i);
|
2007-12-01 00:00:00 +00:00
|
|
|
to_cp->int_at_put(to_i, i);
|
|
|
|
} break;
|
|
|
|
|
|
|
|
case JVM_CONSTANT_InterfaceMethodref:
|
|
|
|
{
|
2010-12-03 15:53:57 -08:00
|
|
|
int class_index = from_cp->uncached_klass_ref_index_at(from_i);
|
|
|
|
int name_and_type_index = from_cp->uncached_name_and_type_ref_index_at(from_i);
|
2007-12-01 00:00:00 +00:00
|
|
|
to_cp->interface_method_at_put(to_i, class_index, name_and_type_index);
|
|
|
|
} break;
|
|
|
|
|
|
|
|
case JVM_CONSTANT_Long:
|
|
|
|
{
|
2010-12-03 15:53:57 -08:00
|
|
|
jlong l = from_cp->long_at(from_i);
|
2007-12-01 00:00:00 +00:00
|
|
|
to_cp->long_at_put(to_i, l);
|
|
|
|
// long takes two constant pool entries so init second entry's tag
|
|
|
|
to_cp->tag_at_put(to_i + 1, JVM_CONSTANT_Invalid);
|
|
|
|
} break;
|
|
|
|
|
|
|
|
case JVM_CONSTANT_Methodref:
|
|
|
|
{
|
2010-12-03 15:53:57 -08:00
|
|
|
int class_index = from_cp->uncached_klass_ref_index_at(from_i);
|
|
|
|
int name_and_type_index = from_cp->uncached_name_and_type_ref_index_at(from_i);
|
2007-12-01 00:00:00 +00:00
|
|
|
to_cp->method_at_put(to_i, class_index, name_and_type_index);
|
|
|
|
} break;
|
|
|
|
|
|
|
|
case JVM_CONSTANT_NameAndType:
|
|
|
|
{
|
2010-12-03 15:53:57 -08:00
|
|
|
int name_ref_index = from_cp->name_ref_index_at(from_i);
|
|
|
|
int signature_ref_index = from_cp->signature_ref_index_at(from_i);
|
2007-12-01 00:00:00 +00:00
|
|
|
to_cp->name_and_type_at_put(to_i, name_ref_index, signature_ref_index);
|
|
|
|
} break;
|
|
|
|
|
|
|
|
case JVM_CONSTANT_StringIndex:
|
|
|
|
{
|
2010-12-03 15:53:57 -08:00
|
|
|
jint si = from_cp->string_index_at(from_i);
|
2007-12-01 00:00:00 +00:00
|
|
|
to_cp->string_index_at_put(to_i, si);
|
|
|
|
} break;
|
|
|
|
|
|
|
|
case JVM_CONSTANT_UnresolvedClass:
|
|
|
|
{
|
2011-03-03 19:52:23 -05:00
|
|
|
// Can be resolved after checking tag, so check the slot first.
|
|
|
|
CPSlot entry = from_cp->slot_at(from_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
|
|
|
if (entry.is_resolved()) {
|
|
|
|
assert(entry.get_klass()->is_klass(), "must be");
|
2011-03-03 19:52:23 -05:00
|
|
|
// Already resolved
|
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
|
|
|
to_cp->klass_at_put(to_i, entry.get_klass());
|
2011-03-03 19:52:23 -05:00
|
|
|
} else {
|
|
|
|
to_cp->unresolved_klass_at_put(to_i, entry.get_symbol());
|
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
} break;
|
|
|
|
|
|
|
|
case JVM_CONSTANT_UnresolvedClassInError:
|
|
|
|
{
|
2011-01-27 16:11:27 -08:00
|
|
|
Symbol* k = from_cp->unresolved_klass_at(from_i);
|
2007-12-01 00:00:00 +00:00
|
|
|
to_cp->unresolved_klass_at_put(to_i, k);
|
|
|
|
to_cp->tag_at_put(to_i, JVM_CONSTANT_UnresolvedClassInError);
|
|
|
|
} break;
|
|
|
|
|
|
|
|
|
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
|
|
|
case JVM_CONSTANT_String:
|
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
|
|
|
Symbol* s = from_cp->unresolved_string_at(from_i);
|
|
|
|
to_cp->unresolved_string_at_put(to_i, s);
|
2007-12-01 00:00:00 +00:00
|
|
|
} break;
|
|
|
|
|
|
|
|
case JVM_CONSTANT_Utf8:
|
|
|
|
{
|
2011-01-27 16:11:27 -08:00
|
|
|
Symbol* s = from_cp->symbol_at(from_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
|
|
|
// Need to increase refcount, the old one will be thrown away and deferenced
|
|
|
|
s->increment_refcount();
|
2007-12-01 00:00:00 +00:00
|
|
|
to_cp->symbol_at_put(to_i, s);
|
|
|
|
} break;
|
|
|
|
|
2010-06-09 18:50:45 -07:00
|
|
|
case JVM_CONSTANT_MethodType:
|
|
|
|
{
|
2010-12-03 15:53:57 -08:00
|
|
|
jint k = from_cp->method_type_index_at(from_i);
|
2010-06-09 18:50:45 -07:00
|
|
|
to_cp->method_type_index_at_put(to_i, k);
|
|
|
|
} break;
|
|
|
|
|
|
|
|
case JVM_CONSTANT_MethodHandle:
|
|
|
|
{
|
2010-12-03 15:53:57 -08:00
|
|
|
int k1 = from_cp->method_handle_ref_kind_at(from_i);
|
|
|
|
int k2 = from_cp->method_handle_index_at(from_i);
|
2010-06-09 18:50:45 -07:00
|
|
|
to_cp->method_handle_index_at_put(to_i, k1, k2);
|
|
|
|
} break;
|
|
|
|
|
2010-07-15 18:40:45 -07:00
|
|
|
case JVM_CONSTANT_InvokeDynamic:
|
|
|
|
{
|
2010-12-03 15:53:57 -08:00
|
|
|
int k1 = from_cp->invoke_dynamic_bootstrap_specifier_index(from_i);
|
|
|
|
int k2 = from_cp->invoke_dynamic_name_and_type_ref_index_at(from_i);
|
|
|
|
k1 += operand_array_length(to_cp->operands()); // to_cp might already have operands
|
|
|
|
to_cp->invoke_dynamic_at_put(to_i, k1, k2);
|
2010-07-15 18:40:45 -07:00
|
|
|
} break;
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
// Invalid is used as the tag for the second constant pool entry
|
|
|
|
// occupied by JVM_CONSTANT_Double or JVM_CONSTANT_Long. It should
|
|
|
|
// not be seen by itself.
|
|
|
|
case JVM_CONSTANT_Invalid: // fall through
|
|
|
|
|
|
|
|
default:
|
|
|
|
{
|
|
|
|
ShouldNotReachHere();
|
|
|
|
} break;
|
|
|
|
}
|
|
|
|
} // end copy_entry_to()
|
|
|
|
|
|
|
|
|
|
|
|
// Search constant pool search_cp for an entry that matches this
|
|
|
|
// constant pool's entry at pattern_i. Returns the index of a
|
|
|
|
// matching entry or zero (0) if there is no matching 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
|
|
|
int ConstantPool::find_matching_entry(int pattern_i,
|
2007-12-01 00:00:00 +00:00
|
|
|
constantPoolHandle search_cp, TRAPS) {
|
|
|
|
|
|
|
|
// index zero (0) is not used
|
|
|
|
for (int i = 1; i < search_cp->length(); i++) {
|
|
|
|
bool found = compare_entry_to(pattern_i, search_cp, i, CHECK_0);
|
|
|
|
if (found) {
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0; // entry not found; return unused index zero (0)
|
|
|
|
} // end find_matching_entry()
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef PRODUCT
|
|
|
|
|
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
|
|
|
const char* ConstantPool::printable_name_at(int which) {
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
constantTag tag = tag_at(which);
|
|
|
|
|
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
|
|
|
if (tag.is_string()) {
|
2007-12-01 00:00:00 +00:00
|
|
|
return string_at_noresolve(which);
|
|
|
|
} else if (tag.is_klass() || tag.is_unresolved_klass()) {
|
|
|
|
return klass_name_at(which)->as_C_string();
|
|
|
|
} else if (tag.is_symbol()) {
|
|
|
|
return symbol_at(which)->as_C_string();
|
|
|
|
}
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // PRODUCT
|
|
|
|
|
|
|
|
|
|
|
|
// JVMTI GetConstantPool support
|
|
|
|
|
|
|
|
// For temporary use until code is stable.
|
|
|
|
#define DBG(code)
|
|
|
|
|
|
|
|
static const char* WARN_MSG = "Must not be such entry!";
|
|
|
|
|
|
|
|
static void print_cpool_bytes(jint cnt, u1 *bytes) {
|
|
|
|
jint size = 0;
|
|
|
|
u2 idx1, idx2;
|
|
|
|
|
|
|
|
for (jint idx = 1; idx < cnt; idx++) {
|
|
|
|
jint ent_size = 0;
|
|
|
|
u1 tag = *bytes++;
|
|
|
|
size++; // count tag
|
|
|
|
|
|
|
|
printf("const #%03d, tag: %02d ", idx, tag);
|
|
|
|
switch(tag) {
|
|
|
|
case JVM_CONSTANT_Invalid: {
|
|
|
|
printf("Invalid");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case JVM_CONSTANT_Unicode: {
|
|
|
|
printf("Unicode %s", WARN_MSG);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case JVM_CONSTANT_Utf8: {
|
|
|
|
u2 len = Bytes::get_Java_u2(bytes);
|
|
|
|
char str[128];
|
|
|
|
if (len > 127) {
|
|
|
|
len = 127;
|
|
|
|
}
|
|
|
|
strncpy(str, (char *) (bytes+2), len);
|
|
|
|
str[len] = '\0';
|
|
|
|
printf("Utf8 \"%s\"", str);
|
|
|
|
ent_size = 2 + len;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case JVM_CONSTANT_Integer: {
|
|
|
|
u4 val = Bytes::get_Java_u4(bytes);
|
|
|
|
printf("int %d", *(int *) &val);
|
|
|
|
ent_size = 4;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case JVM_CONSTANT_Float: {
|
|
|
|
u4 val = Bytes::get_Java_u4(bytes);
|
|
|
|
printf("float %5.3ff", *(float *) &val);
|
|
|
|
ent_size = 4;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case JVM_CONSTANT_Long: {
|
|
|
|
u8 val = Bytes::get_Java_u8(bytes);
|
2011-09-25 16:03:29 -07:00
|
|
|
printf("long "INT64_FORMAT, (int64_t) *(jlong *) &val);
|
2007-12-01 00:00:00 +00:00
|
|
|
ent_size = 8;
|
|
|
|
idx++; // Long takes two cpool slots
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case JVM_CONSTANT_Double: {
|
|
|
|
u8 val = Bytes::get_Java_u8(bytes);
|
|
|
|
printf("double %5.3fd", *(jdouble *)&val);
|
|
|
|
ent_size = 8;
|
|
|
|
idx++; // Double takes two cpool slots
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case JVM_CONSTANT_Class: {
|
|
|
|
idx1 = Bytes::get_Java_u2(bytes);
|
|
|
|
printf("class #%03d", idx1);
|
|
|
|
ent_size = 2;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case JVM_CONSTANT_String: {
|
|
|
|
idx1 = Bytes::get_Java_u2(bytes);
|
|
|
|
printf("String #%03d", idx1);
|
|
|
|
ent_size = 2;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case JVM_CONSTANT_Fieldref: {
|
|
|
|
idx1 = Bytes::get_Java_u2(bytes);
|
|
|
|
idx2 = Bytes::get_Java_u2(bytes+2);
|
|
|
|
printf("Field #%03d, #%03d", (int) idx1, (int) idx2);
|
|
|
|
ent_size = 4;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case JVM_CONSTANT_Methodref: {
|
|
|
|
idx1 = Bytes::get_Java_u2(bytes);
|
|
|
|
idx2 = Bytes::get_Java_u2(bytes+2);
|
|
|
|
printf("Method #%03d, #%03d", idx1, idx2);
|
|
|
|
ent_size = 4;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case JVM_CONSTANT_InterfaceMethodref: {
|
|
|
|
idx1 = Bytes::get_Java_u2(bytes);
|
|
|
|
idx2 = Bytes::get_Java_u2(bytes+2);
|
|
|
|
printf("InterfMethod #%03d, #%03d", idx1, idx2);
|
|
|
|
ent_size = 4;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case JVM_CONSTANT_NameAndType: {
|
|
|
|
idx1 = Bytes::get_Java_u2(bytes);
|
|
|
|
idx2 = Bytes::get_Java_u2(bytes+2);
|
|
|
|
printf("NameAndType #%03d, #%03d", idx1, idx2);
|
|
|
|
ent_size = 4;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case JVM_CONSTANT_ClassIndex: {
|
|
|
|
printf("ClassIndex %s", WARN_MSG);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case JVM_CONSTANT_UnresolvedClass: {
|
|
|
|
printf("UnresolvedClass: %s", WARN_MSG);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case JVM_CONSTANT_UnresolvedClassInError: {
|
|
|
|
printf("UnresolvedClassInErr: %s", WARN_MSG);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case JVM_CONSTANT_StringIndex: {
|
|
|
|
printf("StringIndex: %s", WARN_MSG);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
printf(";\n");
|
|
|
|
bytes += ent_size;
|
|
|
|
size += ent_size;
|
|
|
|
}
|
|
|
|
printf("Cpool size: %d\n", size);
|
|
|
|
fflush(0);
|
|
|
|
return;
|
|
|
|
} /* end print_cpool_bytes */
|
|
|
|
|
|
|
|
|
|
|
|
// Returns size of constant pool 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
|
|
|
jint ConstantPool::cpool_entry_size(jint idx) {
|
2007-12-01 00:00:00 +00:00
|
|
|
switch(tag_at(idx).value()) {
|
|
|
|
case JVM_CONSTANT_Invalid:
|
|
|
|
case JVM_CONSTANT_Unicode:
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
case JVM_CONSTANT_Utf8:
|
|
|
|
return 3 + symbol_at(idx)->utf8_length();
|
|
|
|
|
|
|
|
case JVM_CONSTANT_Class:
|
|
|
|
case JVM_CONSTANT_String:
|
|
|
|
case JVM_CONSTANT_ClassIndex:
|
|
|
|
case JVM_CONSTANT_UnresolvedClass:
|
|
|
|
case JVM_CONSTANT_UnresolvedClassInError:
|
|
|
|
case JVM_CONSTANT_StringIndex:
|
2010-06-09 18:50:45 -07:00
|
|
|
case JVM_CONSTANT_MethodType:
|
2007-12-01 00:00:00 +00:00
|
|
|
return 3;
|
|
|
|
|
2010-06-09 18:50:45 -07:00
|
|
|
case JVM_CONSTANT_MethodHandle:
|
|
|
|
return 4; //tag, ref_kind, ref_index
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
case JVM_CONSTANT_Integer:
|
|
|
|
case JVM_CONSTANT_Float:
|
|
|
|
case JVM_CONSTANT_Fieldref:
|
|
|
|
case JVM_CONSTANT_Methodref:
|
|
|
|
case JVM_CONSTANT_InterfaceMethodref:
|
|
|
|
case JVM_CONSTANT_NameAndType:
|
|
|
|
return 5;
|
|
|
|
|
2010-10-30 13:08:23 -07:00
|
|
|
case JVM_CONSTANT_InvokeDynamic:
|
2010-12-03 15:53:57 -08:00
|
|
|
// u1 tag, u2 bsm, u2 nt
|
|
|
|
return 5;
|
2010-10-30 13:08:23 -07:00
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
case JVM_CONSTANT_Long:
|
|
|
|
case JVM_CONSTANT_Double:
|
|
|
|
return 9;
|
|
|
|
}
|
|
|
|
assert(false, "cpool_entry_size: Invalid constant pool entry tag");
|
|
|
|
return 1;
|
|
|
|
} /* end cpool_entry_size */
|
|
|
|
|
|
|
|
|
|
|
|
// SymbolHashMap is used to find a constant pool index from a string.
|
|
|
|
// This function fills in SymbolHashMaps, one for utf8s and one for
|
|
|
|
// class names, returns size of the cpool raw bytes.
|
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
|
|
|
jint ConstantPool::hash_entries_to(SymbolHashMap *symmap,
|
2007-12-01 00:00:00 +00:00
|
|
|
SymbolHashMap *classmap) {
|
|
|
|
jint size = 0;
|
|
|
|
|
|
|
|
for (u2 idx = 1; idx < length(); idx++) {
|
|
|
|
u2 tag = tag_at(idx).value();
|
|
|
|
size += cpool_entry_size(idx);
|
|
|
|
|
|
|
|
switch(tag) {
|
|
|
|
case JVM_CONSTANT_Utf8: {
|
2011-01-27 16:11:27 -08:00
|
|
|
Symbol* sym = symbol_at(idx);
|
2007-12-01 00:00:00 +00:00
|
|
|
symmap->add_entry(sym, idx);
|
|
|
|
DBG(printf("adding symbol entry %s = %d\n", sym->as_utf8(), idx));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case JVM_CONSTANT_Class:
|
|
|
|
case JVM_CONSTANT_UnresolvedClass:
|
|
|
|
case JVM_CONSTANT_UnresolvedClassInError: {
|
2011-01-27 16:11:27 -08:00
|
|
|
Symbol* sym = klass_name_at(idx);
|
2007-12-01 00:00:00 +00:00
|
|
|
classmap->add_entry(sym, idx);
|
|
|
|
DBG(printf("adding class entry %s = %d\n", sym->as_utf8(), idx));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case JVM_CONSTANT_Long:
|
|
|
|
case JVM_CONSTANT_Double: {
|
|
|
|
idx++; // Both Long and Double take two cpool slots
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return size;
|
|
|
|
} /* end hash_utf8_entries_to */
|
|
|
|
|
|
|
|
|
|
|
|
// Copy cpool bytes.
|
|
|
|
// Returns:
|
|
|
|
// 0, in case of OutOfMemoryError
|
|
|
|
// -1, in case of internal error
|
|
|
|
// > 0, count of the raw cpool bytes that have been copied
|
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
|
|
|
int ConstantPool::copy_cpool_bytes(int cpool_size,
|
2007-12-01 00:00:00 +00:00
|
|
|
SymbolHashMap* tbl,
|
|
|
|
unsigned char *bytes) {
|
|
|
|
u2 idx1, idx2;
|
|
|
|
jint size = 0;
|
|
|
|
jint cnt = length();
|
|
|
|
unsigned char *start_bytes = bytes;
|
|
|
|
|
|
|
|
for (jint idx = 1; idx < cnt; idx++) {
|
|
|
|
u1 tag = tag_at(idx).value();
|
|
|
|
jint ent_size = cpool_entry_size(idx);
|
|
|
|
|
|
|
|
assert(size + ent_size <= cpool_size, "Size mismatch");
|
|
|
|
|
|
|
|
*bytes = tag;
|
|
|
|
DBG(printf("#%03hd tag=%03hd, ", idx, tag));
|
|
|
|
switch(tag) {
|
|
|
|
case JVM_CONSTANT_Invalid: {
|
|
|
|
DBG(printf("JVM_CONSTANT_Invalid"));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case JVM_CONSTANT_Unicode: {
|
|
|
|
assert(false, "Wrong constant pool tag: JVM_CONSTANT_Unicode");
|
|
|
|
DBG(printf("JVM_CONSTANT_Unicode"));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case JVM_CONSTANT_Utf8: {
|
2011-01-27 16:11:27 -08:00
|
|
|
Symbol* sym = symbol_at(idx);
|
2007-12-01 00:00:00 +00:00
|
|
|
char* str = sym->as_utf8();
|
|
|
|
// Warning! It's crashing on x86 with len = sym->utf8_length()
|
|
|
|
int len = (int) strlen(str);
|
|
|
|
Bytes::put_Java_u2((address) (bytes+1), (u2) len);
|
|
|
|
for (int i = 0; i < len; i++) {
|
|
|
|
bytes[3+i] = (u1) str[i];
|
|
|
|
}
|
|
|
|
DBG(printf("JVM_CONSTANT_Utf8: %s ", str));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case JVM_CONSTANT_Integer: {
|
|
|
|
jint val = int_at(idx);
|
|
|
|
Bytes::put_Java_u4((address) (bytes+1), *(u4*)&val);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case JVM_CONSTANT_Float: {
|
|
|
|
jfloat val = float_at(idx);
|
|
|
|
Bytes::put_Java_u4((address) (bytes+1), *(u4*)&val);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case JVM_CONSTANT_Long: {
|
|
|
|
jlong val = long_at(idx);
|
|
|
|
Bytes::put_Java_u8((address) (bytes+1), *(u8*)&val);
|
|
|
|
idx++; // Long takes two cpool slots
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case JVM_CONSTANT_Double: {
|
|
|
|
jdouble val = double_at(idx);
|
|
|
|
Bytes::put_Java_u8((address) (bytes+1), *(u8*)&val);
|
|
|
|
idx++; // Double takes two cpool slots
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case JVM_CONSTANT_Class:
|
|
|
|
case JVM_CONSTANT_UnresolvedClass:
|
|
|
|
case JVM_CONSTANT_UnresolvedClassInError: {
|
|
|
|
*bytes = JVM_CONSTANT_Class;
|
2011-01-27 16:11:27 -08:00
|
|
|
Symbol* sym = klass_name_at(idx);
|
2007-12-01 00:00:00 +00:00
|
|
|
idx1 = tbl->symbol_to_value(sym);
|
|
|
|
assert(idx1 != 0, "Have not found a hashtable entry");
|
|
|
|
Bytes::put_Java_u2((address) (bytes+1), idx1);
|
|
|
|
DBG(printf("JVM_CONSTANT_Class: idx=#%03hd, %s", idx1, sym->as_utf8()));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case JVM_CONSTANT_String: {
|
|
|
|
*bytes = JVM_CONSTANT_String;
|
2011-01-27 16:11:27 -08:00
|
|
|
Symbol* sym = unresolved_string_at(idx);
|
2007-12-01 00:00:00 +00:00
|
|
|
idx1 = tbl->symbol_to_value(sym);
|
|
|
|
assert(idx1 != 0, "Have not found a hashtable entry");
|
|
|
|
Bytes::put_Java_u2((address) (bytes+1), idx1);
|
|
|
|
DBG(char *str = sym->as_utf8());
|
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
|
|
|
DBG(printf("JVM_CONSTANT_String: idx=#%03hd, %s", idx1, str));
|
2007-12-01 00:00:00 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case JVM_CONSTANT_Fieldref:
|
|
|
|
case JVM_CONSTANT_Methodref:
|
|
|
|
case JVM_CONSTANT_InterfaceMethodref: {
|
|
|
|
idx1 = uncached_klass_ref_index_at(idx);
|
|
|
|
idx2 = uncached_name_and_type_ref_index_at(idx);
|
|
|
|
Bytes::put_Java_u2((address) (bytes+1), idx1);
|
|
|
|
Bytes::put_Java_u2((address) (bytes+3), idx2);
|
|
|
|
DBG(printf("JVM_CONSTANT_Methodref: %hd %hd", idx1, idx2));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case JVM_CONSTANT_NameAndType: {
|
|
|
|
idx1 = name_ref_index_at(idx);
|
|
|
|
idx2 = signature_ref_index_at(idx);
|
|
|
|
Bytes::put_Java_u2((address) (bytes+1), idx1);
|
|
|
|
Bytes::put_Java_u2((address) (bytes+3), idx2);
|
|
|
|
DBG(printf("JVM_CONSTANT_NameAndType: %hd %hd", idx1, idx2));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case JVM_CONSTANT_ClassIndex: {
|
|
|
|
*bytes = JVM_CONSTANT_Class;
|
|
|
|
idx1 = klass_index_at(idx);
|
|
|
|
Bytes::put_Java_u2((address) (bytes+1), idx1);
|
|
|
|
DBG(printf("JVM_CONSTANT_ClassIndex: %hd", idx1));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case JVM_CONSTANT_StringIndex: {
|
|
|
|
*bytes = JVM_CONSTANT_String;
|
|
|
|
idx1 = string_index_at(idx);
|
|
|
|
Bytes::put_Java_u2((address) (bytes+1), idx1);
|
|
|
|
DBG(printf("JVM_CONSTANT_StringIndex: %hd", idx1));
|
|
|
|
break;
|
|
|
|
}
|
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
|
|
|
case JVM_CONSTANT_MethodHandle:
|
|
|
|
case JVM_CONSTANT_MethodHandleInError: {
|
2010-06-09 18:50:45 -07:00
|
|
|
*bytes = JVM_CONSTANT_MethodHandle;
|
|
|
|
int kind = method_handle_ref_kind_at(idx);
|
|
|
|
idx1 = method_handle_index_at(idx);
|
|
|
|
*(bytes+1) = (unsigned char) kind;
|
|
|
|
Bytes::put_Java_u2((address) (bytes+2), idx1);
|
|
|
|
DBG(printf("JVM_CONSTANT_MethodHandle: %d %hd", kind, idx1));
|
|
|
|
break;
|
|
|
|
}
|
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
|
|
|
case JVM_CONSTANT_MethodType:
|
|
|
|
case JVM_CONSTANT_MethodTypeInError: {
|
2010-06-09 18:50:45 -07:00
|
|
|
*bytes = JVM_CONSTANT_MethodType;
|
|
|
|
idx1 = method_type_index_at(idx);
|
|
|
|
Bytes::put_Java_u2((address) (bytes+1), idx1);
|
|
|
|
DBG(printf("JVM_CONSTANT_MethodType: %hd", idx1));
|
|
|
|
break;
|
|
|
|
}
|
2010-07-15 18:40:45 -07:00
|
|
|
case JVM_CONSTANT_InvokeDynamic: {
|
2010-12-03 15:53:57 -08:00
|
|
|
*bytes = tag;
|
|
|
|
idx1 = extract_low_short_from_int(*int_at_addr(idx));
|
|
|
|
idx2 = extract_high_short_from_int(*int_at_addr(idx));
|
|
|
|
assert(idx2 == invoke_dynamic_name_and_type_ref_index_at(idx), "correct half of u4");
|
2010-07-15 18:40:45 -07:00
|
|
|
Bytes::put_Java_u2((address) (bytes+1), idx1);
|
|
|
|
Bytes::put_Java_u2((address) (bytes+3), idx2);
|
2010-12-03 15:53:57 -08:00
|
|
|
DBG(printf("JVM_CONSTANT_InvokeDynamic: %hd %hd", idx1, idx2));
|
2010-07-15 18:40:45 -07:00
|
|
|
break;
|
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
DBG(printf("\n"));
|
|
|
|
bytes += ent_size;
|
|
|
|
size += ent_size;
|
|
|
|
}
|
|
|
|
assert(size == cpool_size, "Size mismatch");
|
|
|
|
|
|
|
|
// Keep temorarily for debugging until it's stable.
|
|
|
|
DBG(print_cpool_bytes(cnt, start_bytes));
|
|
|
|
return (int)(bytes - start_bytes);
|
|
|
|
} /* end copy_cpool_bytes */
|
|
|
|
|
|
|
|
|
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 ConstantPool::set_on_stack(const bool value) {
|
2013-01-23 10:34:29 -05:00
|
|
|
if (value) {
|
|
|
|
_flags |= _on_stack;
|
|
|
|
} else {
|
|
|
|
_flags &= ~_on_stack;
|
|
|
|
}
|
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
|
|
|
if (value) MetadataOnStackMark::record(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
// JSR 292 support for patching constant pool oops after the class is linked and
|
|
|
|
// the oop array for resolved references are created.
|
|
|
|
// We can't do this during classfile parsing, which is how the other indexes are
|
|
|
|
// patched. The other patches are applied early for some error checking
|
|
|
|
// so only defer the pseudo_strings.
|
|
|
|
void ConstantPool::patch_resolved_references(
|
|
|
|
GrowableArray<Handle>* cp_patches) {
|
|
|
|
assert(EnableInvokeDynamic, "");
|
|
|
|
for (int index = 1; index < cp_patches->length(); index++) { // Index 0 is unused
|
|
|
|
Handle patch = cp_patches->at(index);
|
|
|
|
if (patch.not_null()) {
|
|
|
|
assert (tag_at(index).is_string(), "should only be string left");
|
|
|
|
// Patching a string means pre-resolving it.
|
|
|
|
// The spelling in the constant pool is ignored.
|
|
|
|
// The constant reference may be any object whatever.
|
|
|
|
// If it is not a real interned string, the constant is referred
|
|
|
|
// to as a "pseudo-string", and must be presented to the CP
|
|
|
|
// explicitly, because it may require scavenging.
|
|
|
|
int obj_index = cp_to_object_index(index);
|
|
|
|
pseudo_string_at_put(index, obj_index, patch());
|
|
|
|
DEBUG_ONLY(cp_patches->at_put(index, Handle());)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#ifdef ASSERT
|
|
|
|
// Ensure that all the patches have been used.
|
|
|
|
for (int index = 0; index < cp_patches->length(); index++) {
|
|
|
|
assert(cp_patches->at(index).is_null(),
|
|
|
|
err_msg("Unused constant pool patch at %d in class file %s",
|
|
|
|
index,
|
2012-11-06 15:09:37 -05:00
|
|
|
pool_holder()->external_name()));
|
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
|
|
|
}
|
|
|
|
#endif // ASSERT
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifndef PRODUCT
|
|
|
|
|
|
|
|
// CompileTheWorld support. Preload all classes loaded references in the passed in constantpool
|
|
|
|
void ConstantPool::preload_and_initialize_all_classes(ConstantPool* obj, TRAPS) {
|
|
|
|
guarantee(obj->is_constantPool(), "object must be constant pool");
|
|
|
|
constantPoolHandle cp(THREAD, (ConstantPool*)obj);
|
|
|
|
guarantee(cp->pool_holder() != NULL, "must be fully loaded");
|
|
|
|
|
|
|
|
for (int i = 0; i< cp->length(); i++) {
|
|
|
|
if (cp->tag_at(i).is_unresolved_klass()) {
|
|
|
|
// This will force loading of the class
|
|
|
|
Klass* klass = cp->klass_at(i, CHECK);
|
|
|
|
if (klass->oop_is_instance()) {
|
|
|
|
// Force initialization of class
|
|
|
|
InstanceKlass::cast(klass)->initialize(CHECK);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
// Printing
|
|
|
|
|
|
|
|
void ConstantPool::print_on(outputStream* st) const {
|
|
|
|
EXCEPTION_MARK;
|
|
|
|
assert(is_constantPool(), "must be constantPool");
|
|
|
|
st->print_cr(internal_name());
|
|
|
|
if (flags() != 0) {
|
|
|
|
st->print(" - flags: 0x%x", flags());
|
|
|
|
if (has_pseudo_string()) st->print(" has_pseudo_string");
|
|
|
|
if (has_invokedynamic()) st->print(" has_invokedynamic");
|
|
|
|
if (has_preresolution()) st->print(" has_preresolution");
|
2013-01-23 10:34:29 -05:00
|
|
|
if (on_stack()) st->print(" on_stack");
|
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
|
|
|
st->cr();
|
|
|
|
}
|
|
|
|
if (pool_holder() != NULL) {
|
|
|
|
st->print_cr(" - holder: " INTPTR_FORMAT, pool_holder());
|
|
|
|
}
|
|
|
|
st->print_cr(" - cache: " INTPTR_FORMAT, cache());
|
|
|
|
st->print_cr(" - resolved_references: " INTPTR_FORMAT, resolved_references());
|
|
|
|
st->print_cr(" - reference_map: " INTPTR_FORMAT, reference_map());
|
|
|
|
|
|
|
|
for (int index = 1; index < length(); index++) { // Index 0 is unused
|
|
|
|
((ConstantPool*)this)->print_entry_on(index, st);
|
|
|
|
switch (tag_at(index).value()) {
|
|
|
|
case JVM_CONSTANT_Long :
|
|
|
|
case JVM_CONSTANT_Double :
|
|
|
|
index++; // Skip entry following eigth-byte constant
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
st->cr();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Print one constant pool entry
|
|
|
|
void ConstantPool::print_entry_on(const int index, outputStream* st) {
|
|
|
|
EXCEPTION_MARK;
|
|
|
|
st->print(" - %3d : ", index);
|
|
|
|
tag_at(index).print_on(st);
|
|
|
|
st->print(" : ");
|
|
|
|
switch (tag_at(index).value()) {
|
|
|
|
case JVM_CONSTANT_Class :
|
|
|
|
{ Klass* k = klass_at(index, CATCH);
|
|
|
|
k->print_value_on(st);
|
|
|
|
st->print(" {0x%lx}", (address)k);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case JVM_CONSTANT_Fieldref :
|
|
|
|
case JVM_CONSTANT_Methodref :
|
|
|
|
case JVM_CONSTANT_InterfaceMethodref :
|
|
|
|
st->print("klass_index=%d", uncached_klass_ref_index_at(index));
|
|
|
|
st->print(" name_and_type_index=%d", uncached_name_and_type_ref_index_at(index));
|
|
|
|
break;
|
|
|
|
case JVM_CONSTANT_String :
|
|
|
|
unresolved_string_at(index)->print_value_on(st);
|
|
|
|
break;
|
|
|
|
case JVM_CONSTANT_Object : {
|
|
|
|
oop anObj = object_at(index);
|
|
|
|
anObj->print_value_on(st);
|
|
|
|
st->print(" {0x%lx}", (address)anObj);
|
|
|
|
} break;
|
|
|
|
case JVM_CONSTANT_Integer :
|
|
|
|
st->print("%d", int_at(index));
|
|
|
|
break;
|
|
|
|
case JVM_CONSTANT_Float :
|
|
|
|
st->print("%f", float_at(index));
|
|
|
|
break;
|
|
|
|
case JVM_CONSTANT_Long :
|
|
|
|
st->print_jlong(long_at(index));
|
|
|
|
break;
|
|
|
|
case JVM_CONSTANT_Double :
|
|
|
|
st->print("%lf", double_at(index));
|
|
|
|
break;
|
|
|
|
case JVM_CONSTANT_NameAndType :
|
|
|
|
st->print("name_index=%d", name_ref_index_at(index));
|
|
|
|
st->print(" signature_index=%d", signature_ref_index_at(index));
|
|
|
|
break;
|
|
|
|
case JVM_CONSTANT_Utf8 :
|
|
|
|
symbol_at(index)->print_value_on(st);
|
|
|
|
break;
|
|
|
|
case JVM_CONSTANT_UnresolvedClass : // fall-through
|
|
|
|
case JVM_CONSTANT_UnresolvedClassInError: {
|
|
|
|
// unresolved_klass_at requires lock or safe world.
|
|
|
|
CPSlot entry = slot_at(index);
|
|
|
|
if (entry.is_resolved()) {
|
|
|
|
entry.get_klass()->print_value_on(st);
|
|
|
|
} else {
|
|
|
|
entry.get_symbol()->print_value_on(st);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case JVM_CONSTANT_MethodHandle :
|
|
|
|
case JVM_CONSTANT_MethodHandleInError :
|
|
|
|
st->print("ref_kind=%d", method_handle_ref_kind_at(index));
|
|
|
|
st->print(" ref_index=%d", method_handle_index_at(index));
|
|
|
|
break;
|
|
|
|
case JVM_CONSTANT_MethodType :
|
|
|
|
case JVM_CONSTANT_MethodTypeInError :
|
|
|
|
st->print("signature_index=%d", method_type_index_at(index));
|
|
|
|
break;
|
|
|
|
case JVM_CONSTANT_InvokeDynamic :
|
|
|
|
{
|
|
|
|
st->print("bootstrap_method_index=%d", invoke_dynamic_bootstrap_method_ref_index_at(index));
|
|
|
|
st->print(" name_and_type_index=%d", invoke_dynamic_name_and_type_ref_index_at(index));
|
|
|
|
int argc = invoke_dynamic_argument_count_at(index);
|
|
|
|
if (argc > 0) {
|
|
|
|
for (int arg_i = 0; arg_i < argc; arg_i++) {
|
|
|
|
int arg = invoke_dynamic_argument_index_at(index, arg_i);
|
|
|
|
st->print((arg_i == 0 ? " arguments={%d" : ", %d"), arg);
|
|
|
|
}
|
|
|
|
st->print("}");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ShouldNotReachHere();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
st->cr();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ConstantPool::print_value_on(outputStream* st) const {
|
|
|
|
assert(is_constantPool(), "must be constantPool");
|
|
|
|
st->print("constant pool [%d]", length());
|
|
|
|
if (has_pseudo_string()) st->print("/pseudo_string");
|
|
|
|
if (has_invokedynamic()) st->print("/invokedynamic");
|
|
|
|
if (has_preresolution()) st->print("/preresolution");
|
|
|
|
if (operands() != NULL) st->print("/operands[%d]", operands()->length());
|
|
|
|
print_address_on(st);
|
|
|
|
st->print(" for ");
|
|
|
|
pool_holder()->print_value_on(st);
|
|
|
|
if (pool_holder() != NULL) {
|
2012-11-06 15:09:37 -05:00
|
|
|
bool extra = (pool_holder()->constants() != this);
|
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
|
|
|
if (extra) st->print(" (extra)");
|
|
|
|
}
|
|
|
|
if (cache() != NULL) {
|
|
|
|
st->print(" cache=" PTR_FORMAT, cache());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Verification
|
|
|
|
|
|
|
|
void ConstantPool::verify_on(outputStream* st) {
|
|
|
|
guarantee(is_constantPool(), "object must be constant pool");
|
|
|
|
for (int i = 0; i< length(); i++) {
|
|
|
|
constantTag tag = tag_at(i);
|
|
|
|
CPSlot entry = slot_at(i);
|
|
|
|
if (tag.is_klass()) {
|
|
|
|
if (entry.is_resolved()) {
|
|
|
|
guarantee(entry.get_klass()->is_metadata(), "should be metadata");
|
|
|
|
guarantee(entry.get_klass()->is_klass(), "should be klass");
|
|
|
|
}
|
|
|
|
} else if (tag.is_unresolved_klass()) {
|
|
|
|
if (entry.is_resolved()) {
|
|
|
|
guarantee(entry.get_klass()->is_metadata(), "should be metadata");
|
|
|
|
guarantee(entry.get_klass()->is_klass(), "should be klass");
|
|
|
|
}
|
|
|
|
} else if (tag.is_symbol()) {
|
|
|
|
guarantee(entry.get_symbol()->refcount() != 0, "should have nonzero reference count");
|
|
|
|
} else if (tag.is_string()) {
|
|
|
|
guarantee(entry.get_symbol()->refcount() != 0, "should have nonzero reference count");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (cache() != NULL) {
|
|
|
|
// Note: cache() can be NULL before a class is completely setup or
|
|
|
|
// in temporary constant pools used during constant pool merging
|
|
|
|
guarantee(cache()->is_metadata(), "should be metadata");
|
|
|
|
guarantee(cache()->is_constantPoolCache(), "should be constant pool cache");
|
|
|
|
}
|
|
|
|
if (pool_holder() != NULL) {
|
|
|
|
// Note: pool_holder() can be NULL in temporary constant pools
|
|
|
|
// used during constant pool merging
|
|
|
|
guarantee(pool_holder()->is_metadata(), "should be metadata");
|
|
|
|
guarantee(pool_holder()->is_klass(), "should be klass");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-01-27 16:11:27 -08:00
|
|
|
void SymbolHashMap::add_entry(Symbol* sym, u2 value) {
|
2007-12-01 00:00:00 +00:00
|
|
|
char *str = sym->as_utf8();
|
|
|
|
unsigned int hash = compute_hash(str, sym->utf8_length());
|
|
|
|
unsigned int index = hash % table_size();
|
|
|
|
|
|
|
|
// check if already in map
|
|
|
|
// we prefer the first entry since it is more likely to be what was used in
|
|
|
|
// the class file
|
|
|
|
for (SymbolHashMapEntry *en = bucket(index); en != NULL; en = en->next()) {
|
|
|
|
assert(en->symbol() != NULL, "SymbolHashMapEntry symbol is NULL");
|
|
|
|
if (en->hash() == hash && en->symbol() == sym) {
|
|
|
|
return; // already there
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
SymbolHashMapEntry* entry = new SymbolHashMapEntry(hash, sym, value);
|
|
|
|
entry->set_next(bucket(index));
|
|
|
|
_buckets[index].set_entry(entry);
|
|
|
|
assert(entry->symbol() != NULL, "SymbolHashMapEntry symbol is NULL");
|
|
|
|
}
|
|
|
|
|
2011-01-27 16:11:27 -08:00
|
|
|
SymbolHashMapEntry* SymbolHashMap::find_entry(Symbol* sym) {
|
2007-12-01 00:00:00 +00:00
|
|
|
assert(sym != NULL, "SymbolHashMap::find_entry - symbol is NULL");
|
|
|
|
char *str = sym->as_utf8();
|
|
|
|
int len = sym->utf8_length();
|
|
|
|
unsigned int hash = SymbolHashMap::compute_hash(str, len);
|
|
|
|
unsigned int index = hash % table_size();
|
|
|
|
for (SymbolHashMapEntry *en = bucket(index); en != NULL; en = en->next()) {
|
|
|
|
assert(en->symbol() != NULL, "SymbolHashMapEntry symbol is NULL");
|
|
|
|
if (en->hash() == hash && en->symbol() == sym) {
|
|
|
|
return en;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|