/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* 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.
*
* 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.
*
*/
#include "precompiled.hpp"
#include "ci/ciField.hpp"
#include "ci/ciInstance.hpp"
#include "ci/ciInstanceKlass.hpp"
#include "ci/ciUtilities.hpp"
#include "classfile/systemDictionary.hpp"
#include "memory/allocation.hpp"
#include "memory/allocation.inline.hpp"
#include "oops/oop.inline.hpp"
#include "oops/fieldStreams.hpp"
#include "runtime/fieldDescriptor.hpp"
// ciInstanceKlass
//
// This class represents a klassOop in the HotSpot virtual machine
// whose Klass part in an instanceKlass.
// ------------------------------------------------------------------
// ciInstanceKlass::ciInstanceKlass
//
// Loaded instance klass.
{
if (ciObjectFactory::is_initialized()) {
ik->protection_domain());
_is_shared = false;
} else {
_is_shared = true;
}
// Lazy fields get filled in only upon request.
_java_mirror = NULL;
if (is_shared()) {
super();
}
//compute_nonstatic_fields(); // done outside of constructor
}
_field_cache = NULL;
}
// Version for unloaded classes:
{
_nonstatic_field_size = -1;
_has_nonstatic_fields = false;
_is_shared = false;
_java_mirror = NULL;
_field_cache = NULL;
}
// ------------------------------------------------------------------
// ciInstanceKlass::compute_shared_is_initialized
)
}
// ------------------------------------------------------------------
// ciInstanceKlass::compute_shared_has_subklass
return _has_subklass;
)
}
// ------------------------------------------------------------------
// ciInstanceKlass::loader
}
// ------------------------------------------------------------------
// ciInstanceKlass::loader_handle
return _loader;
}
// ------------------------------------------------------------------
// ciInstanceKlass::protection_domain
}
// ------------------------------------------------------------------
// ciInstanceKlass::protection_domain_handle
return _protection_domain;
}
// ------------------------------------------------------------------
// ciInstanceKlass::field_cache
//
// Get the field cache associated with this klass.
if (is_shared()) {
return NULL;
}
if (_field_cache == NULL) {
}
return _field_cache;
}
// ------------------------------------------------------------------
// ciInstanceKlass::get_canonical_holder
//
#ifdef ASSERT
this->print();
};
#endif
return CURRENT_ENV->Object_klass();
}
for (;;) {
return self;
} else {
}
}
}
// ------------------------------------------------------------------
// ciInstanceKlass::is_java_lang_Object
//
// Is this klass java.lang.Object?
}
// ------------------------------------------------------------------
// ciInstanceKlass::uses_default_loader
// Note: We do not need to resolve the handle or enter the VM
// in order to test null-ness.
}
// ------------------------------------------------------------------
// ciInstanceKlass::is_in_package
//
// Is this klass in the given package?
// To avoid class loader mischief, this test always rejects application classes.
if (!uses_default_loader())
return false;
)
}
// If packagename contains trailing '/' exclude it from the
// prefix-test since we test for it explicitly.
len--;
return false;
return false;
// Test for trailing '/'
return false;
// Make sure it's not actually in a subpackage:
return false;
return true;
}
// ------------------------------------------------------------------
// ciInstanceKlass::print_impl
//
// Implementation of the print method.
if (is_loaded()) {
layout_helper());
if (_super) {
_super->print_name();
}
if (_java_mirror) {
}
} else {
}
}
// ------------------------------------------------------------------
// ciInstanceKlass::super
//
// Get the superklass of this klass.
)
}
return _super;
}
// ------------------------------------------------------------------
// ciInstanceKlass::java_mirror
//
// Get the instance of java.lang.Class corresponding to this klass.
// Cache it on this->_java_mirror.
if (is_shared()) {
return ciKlass::java_mirror();
}
if (_java_mirror == NULL) {
}
return _java_mirror;
}
// ------------------------------------------------------------------
// ciInstanceKlass::unique_concrete_subklass
return NULL;
}
}
// ------------------------------------------------------------------
// ciInstanceKlass::has_finalizable_subclass
if (!is_loaded()) return true;
}
// ------------------------------------------------------------------
// ciInstanceKlass::get_field_by_offset
if (!is_static) {
if (field_off == field_offset)
return field;
if (field_off > field_offset)
break;
// could do binary search or check bins, but probably not worth it
}
return NULL;
}
instanceKlass* k = get_instanceKlass();
return NULL;
}
return field;
}
// ------------------------------------------------------------------
// ciInstanceKlass::get_field_by_name
instanceKlass* k = get_instanceKlass();
return NULL;
}
return field;
}
// ------------------------------------------------------------------
// ciInstanceKlass::non_static_fields.
public:
{}
}
};
if (_non_static_fields == NULL) {
}
return _non_static_fields;
}
return (*a)->offset_in_bytes() - (*b)->offset_in_bytes();
// (no worries about 32-bit overflow...)
}
// ------------------------------------------------------------------
// ciInstanceKlass::compute_nonstatic_fields
if (_nonstatic_fields != NULL)
return _nonstatic_fields->length();
if (!has_nonstatic_fields()) {
return 0;
}
// Size in bytes of my fields, including inherited fields.
// See if I am no larger than my super; if so, I can use his fields.
if (fsize == super_fsize) {
return super_fields->length();
}
}
});
// This can happen if this class (java.lang.Class) has invisible fields.
return super_fields->length();
}
// Now sort them by offset, ascending.
// (In principle, they could mix with superclass fields.)
return flen;
}
super_fields) {
int flen = 0;
instanceKlass* k = get_instanceKlass();
flen += 1;
}
// allocate the array:
if (flen == 0) {
return NULL; // return nothing if none are locally declared
}
if (super_fields != NULL) {
}
if (super_fields != NULL) {
}
}
return fields;
}
// ------------------------------------------------------------------
// ciInstanceKlass::find_method
//
// Find a method in this klass.
instanceKlass* k = get_instanceKlass();
}
// ------------------------------------------------------------------
// ciInstanceKlass::is_leaf_type
if (is_shared()) {
return is_final(); // approximately correct
} else {
return !_has_subklass && (nof_implementors() == 0);
}
}
// ------------------------------------------------------------------
// ciInstanceKlass::implementor
//
// Report an implementor of this interface.
// Note that there are various races here, since my copy
// of _nof_implementors might be out of date with respect
// to results returned by instanceKlass::implementor.
// This is OK, since any dependencies we decide to assert
// will be checked later under the Compile_lock.
// Go into the VM to fetch the implementor.
{
if (k != NULL) {
if (k == get_instanceKlass()->as_klassOop()) {
// More than one implementors. Use 'this' in this case.
impl = this;
} else {
}
}
}
// Memoize this result.
if (!is_shared()) {
_implementor = impl;
}
}
return impl;
}