2007-12-01 00:00:00 +00:00
|
|
|
/*
|
2018-03-07 21:57:36 +01:00
|
|
|
* Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved.
|
2007-12-01 00:00:00 +00:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
|
|
*
|
|
|
|
* This code is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License version 2 only, as
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
|
|
* version 2 for more details (a copy is included in the LICENSE file that
|
|
|
|
* accompanied this code).
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License version
|
|
|
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
|
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*
|
2010-05-27 19:08:38 -07:00
|
|
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
|
|
* or visit www.oracle.com if you need additional information or have any
|
|
|
|
* questions.
|
2007-12-01 00:00:00 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2010-11-23 13:22:55 -08:00
|
|
|
#include "precompiled.hpp"
|
|
|
|
#include "ci/ciField.hpp"
|
|
|
|
#include "ci/ciInstanceKlass.hpp"
|
|
|
|
#include "ci/ciUtilities.hpp"
|
|
|
|
#include "classfile/systemDictionary.hpp"
|
2015-05-13 15:16:06 +02:00
|
|
|
#include "gc/shared/collectedHeap.inline.hpp"
|
2010-11-23 13:22:55 -08:00
|
|
|
#include "interpreter/linkResolver.hpp"
|
2018-03-07 21:57:36 +01:00
|
|
|
#include "memory/universe.hpp"
|
2010-11-23 13:22:55 -08:00
|
|
|
#include "oops/oop.inline.hpp"
|
|
|
|
#include "runtime/fieldDescriptor.hpp"
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
// ciField
|
|
|
|
//
|
|
|
|
// This class represents the result of a field lookup in the VM.
|
|
|
|
// The lookup may not succeed, in which case the information in
|
|
|
|
// the ciField will be incomplete.
|
|
|
|
|
|
|
|
// The ciObjectFactory cannot create circular data structures in one query.
|
|
|
|
// To avoid vicious circularities, we initialize ciField::_type to NULL
|
|
|
|
// for reference types and derive it lazily from the ciField::_signature.
|
|
|
|
// Primitive types are eagerly initialized, and basic layout queries
|
|
|
|
// can succeed without initialization, using only the BasicType of the field.
|
|
|
|
|
|
|
|
// Notes on bootstrapping and shared CI objects: A field is shared if and
|
|
|
|
// only if it is (a) non-static and (b) declared by a shared instance klass.
|
|
|
|
// This allows non-static field lists to be cached on shared types.
|
|
|
|
// Because the _type field is lazily initialized, however, there is a
|
|
|
|
// special restriction that a shared field cannot cache an unshared type.
|
|
|
|
// This puts a small performance penalty on shared fields with unshared
|
|
|
|
// types, such as StackTraceElement[] Throwable.stackTrace.
|
|
|
|
// (Throwable is shared because ClassCastException is shared, but
|
|
|
|
// StackTraceElement is not presently shared.)
|
|
|
|
|
|
|
|
// It is not a vicious circularity for a ciField to recursively create
|
|
|
|
// the ciSymbols necessary to represent its name and signature.
|
|
|
|
// Therefore, these items are created eagerly, and the name and signature
|
|
|
|
// of a shared field are themselves shared symbols. This somewhat
|
|
|
|
// pollutes the set of shared CI objects: It grows from 50 to 93 items,
|
|
|
|
// with all of the additional 43 being uninteresting shared ciSymbols.
|
|
|
|
// This adds at most one step to the binary search, an amount which
|
|
|
|
// decreases for complex compilation tasks.
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------
|
|
|
|
// ciField::ciField
|
2016-06-15 14:27:58 +02:00
|
|
|
ciField::ciField(ciInstanceKlass* klass, int index) :
|
|
|
|
_known_to_link_with_put(NULL), _known_to_link_with_get(NULL) {
|
2007-12-01 00:00:00 +00:00
|
|
|
ASSERT_IN_VM;
|
|
|
|
CompilerThread *thread = CompilerThread::current();
|
|
|
|
|
|
|
|
assert(ciObjectFactory::is_initialized(), "not a shared field");
|
|
|
|
|
2016-02-03 10:39:49 +01:00
|
|
|
assert(klass->get_instanceKlass()->is_linked(), "must be linked before using its constant-pool");
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
constantPoolHandle cpool(thread, klass->get_instanceKlass()->constants());
|
|
|
|
|
|
|
|
// Get the field's name, signature, and type.
|
2011-01-27 16:11:27 -08:00
|
|
|
Symbol* name = cpool->name_ref_at(index);
|
|
|
|
_name = ciEnv::current(thread)->get_symbol(name);
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
int nt_index = cpool->name_and_type_ref_index_at(index);
|
|
|
|
int sig_index = cpool->signature_ref_index_at(nt_index);
|
2011-01-27 16:11:27 -08:00
|
|
|
Symbol* signature = cpool->symbol_at(sig_index);
|
|
|
|
_signature = ciEnv::current(thread)->get_symbol(signature);
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2011-01-27 16:11:27 -08:00
|
|
|
BasicType field_type = FieldType::basic_type(signature);
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
// If the field is a pointer type, get the klass of the
|
|
|
|
// field.
|
|
|
|
if (field_type == T_OBJECT || field_type == T_ARRAY) {
|
|
|
|
bool ignore;
|
|
|
|
// This is not really a class reference; the index always refers to the
|
|
|
|
// field's type signature, as a symbol. Linkage checks do not apply.
|
2010-01-05 15:21:25 +01:00
|
|
|
_type = ciEnv::current(thread)->get_klass_by_index(cpool, sig_index, ignore, klass);
|
2007-12-01 00:00:00 +00:00
|
|
|
} else {
|
|
|
|
_type = ciType::make(field_type);
|
|
|
|
}
|
|
|
|
|
2011-01-27 16:11:27 -08:00
|
|
|
_name = (ciSymbol*)ciEnv::current(thread)->get_symbol(name);
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
// Get the field's declared holder.
|
|
|
|
//
|
|
|
|
// Note: we actually create a ciInstanceKlass for this klass,
|
|
|
|
// even though we may not need to.
|
|
|
|
int holder_index = cpool->klass_ref_index_at(index);
|
|
|
|
bool holder_is_accessible;
|
2016-02-03 10:39:49 +01:00
|
|
|
|
|
|
|
ciKlass* generic_declared_holder = ciEnv::current(thread)->get_klass_by_index(cpool, holder_index,
|
|
|
|
holder_is_accessible,
|
|
|
|
klass);
|
|
|
|
|
|
|
|
if (generic_declared_holder->is_array_klass()) {
|
|
|
|
// If the declared holder of the field is an array class, assume that
|
|
|
|
// the canonical holder of that field is java.lang.Object. Arrays
|
|
|
|
// do not have fields; java.lang.Object is the only supertype of an
|
|
|
|
// array type that can declare fields and is therefore the canonical
|
|
|
|
// holder of the array type.
|
|
|
|
//
|
|
|
|
// Furthermore, the compilers assume that java.lang.Object does not
|
|
|
|
// have any fields. Therefore, the field is not looked up. Instead,
|
|
|
|
// the method returns partial information that will trigger special
|
|
|
|
// handling in ciField::will_link and will result in a
|
|
|
|
// java.lang.NoSuchFieldError exception being thrown by the compiled
|
|
|
|
// code (the expected behavior in this case).
|
|
|
|
_holder = ciEnv::current(thread)->Object_klass();
|
|
|
|
_offset = -1;
|
|
|
|
_is_constant = false;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ciInstanceKlass* declared_holder = generic_declared_holder->as_instance_klass();
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
// The declared holder of this field may not have been loaded.
|
|
|
|
// Bail out with partial field information.
|
|
|
|
if (!holder_is_accessible) {
|
2013-09-13 22:38:02 -04:00
|
|
|
// _type has already been set.
|
2007-12-01 00:00:00 +00:00
|
|
|
// The default values for _flags and _constant_value will suffice.
|
|
|
|
// We need values for _holder, _offset, and _is_constant,
|
|
|
|
_holder = declared_holder;
|
|
|
|
_offset = -1;
|
|
|
|
_is_constant = false;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
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* loaded_decl_holder = declared_holder->get_instanceKlass();
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
// Perform the field lookup.
|
|
|
|
fieldDescriptor field_desc;
|
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* canonical_holder =
|
2011-01-27 16:11:27 -08:00
|
|
|
loaded_decl_holder->find_field(name, signature, &field_desc);
|
2007-12-01 00:00:00 +00:00
|
|
|
if (canonical_holder == NULL) {
|
|
|
|
// Field lookup failed. Will be detected by will_link.
|
|
|
|
_holder = declared_holder;
|
|
|
|
_offset = -1;
|
|
|
|
_is_constant = false;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-07-18 09:04:01 +02:00
|
|
|
// Access check based on declared_holder. canonical_holder should not be used
|
|
|
|
// to check access because it can erroneously succeed. If this check fails,
|
|
|
|
// propagate the declared holder to will_link() which in turn will bail out
|
|
|
|
// compilation for this field access.
|
|
|
|
if (!Reflection::verify_field_access(klass->get_Klass(), declared_holder->get_Klass(), canonical_holder, field_desc.access_flags(), true)) {
|
|
|
|
_holder = declared_holder;
|
|
|
|
_offset = -1;
|
|
|
|
_is_constant = false;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
assert(canonical_holder == field_desc.field_holder(), "just checking");
|
|
|
|
initialize_from(&field_desc);
|
|
|
|
}
|
|
|
|
|
2016-06-15 14:27:58 +02:00
|
|
|
ciField::ciField(fieldDescriptor *fd) :
|
|
|
|
_known_to_link_with_put(NULL), _known_to_link_with_get(NULL) {
|
2007-12-01 00:00:00 +00:00
|
|
|
ASSERT_IN_VM;
|
|
|
|
|
|
|
|
// Get the field's name, signature, and type.
|
|
|
|
ciEnv* env = CURRENT_ENV;
|
2011-01-27 16:11:27 -08:00
|
|
|
_name = env->get_symbol(fd->name());
|
|
|
|
_signature = env->get_symbol(fd->signature());
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
BasicType field_type = fd->field_type();
|
|
|
|
|
|
|
|
// If the field is a pointer type, get the klass of the
|
|
|
|
// field.
|
|
|
|
if (field_type == T_OBJECT || field_type == T_ARRAY) {
|
|
|
|
_type = NULL; // must call compute_type on first access
|
|
|
|
} else {
|
|
|
|
_type = ciType::make(field_type);
|
|
|
|
}
|
|
|
|
|
|
|
|
initialize_from(fd);
|
|
|
|
|
|
|
|
// Either (a) it is marked shared, or else (b) we are done bootstrapping.
|
|
|
|
assert(is_shared() || ciObjectFactory::is_initialized(),
|
|
|
|
"bootstrap classes must not create & cache unshared fields");
|
|
|
|
}
|
|
|
|
|
2010-01-13 23:05:52 -08:00
|
|
|
static bool trust_final_non_static_fields(ciInstanceKlass* holder) {
|
|
|
|
if (holder == NULL)
|
|
|
|
return false;
|
|
|
|
if (holder->name() == ciSymbol::java_lang_System())
|
|
|
|
// Never trust strangely unstable finals: System.out, etc.
|
|
|
|
return false;
|
|
|
|
// Even if general trusting is disabled, trust system-built closures in these packages.
|
2011-03-11 22:34:57 -08:00
|
|
|
if (holder->is_in_package("java/lang/invoke") || holder->is_in_package("sun/invoke"))
|
2010-01-13 23:05:52 -08:00
|
|
|
return true;
|
2015-06-15 15:27:04 +03:00
|
|
|
// Trust VM anonymous classes. They are private API (sun.misc.Unsafe) and can't be serialized,
|
|
|
|
// so there is no hacking of finals going on with them.
|
|
|
|
if (holder->is_anonymous())
|
|
|
|
return true;
|
2016-02-15 23:45:15 +03:00
|
|
|
// Trust final fields in all boxed classes
|
|
|
|
if (holder->is_box_klass())
|
|
|
|
return true;
|
|
|
|
// Trust final fields in String
|
|
|
|
if (holder->name() == ciSymbol::java_lang_String())
|
|
|
|
return true;
|
2015-10-29 14:08:19 +03:00
|
|
|
// Trust Atomic*FieldUpdaters: they are very important for performance, and make up one
|
|
|
|
// more reason not to use Unsafe, if their final fields are trusted. See more in JDK-8140483.
|
|
|
|
if (holder->name() == ciSymbol::java_util_concurrent_atomic_AtomicIntegerFieldUpdater_Impl() ||
|
|
|
|
holder->name() == ciSymbol::java_util_concurrent_atomic_AtomicLongFieldUpdater_CASUpdater() ||
|
|
|
|
holder->name() == ciSymbol::java_util_concurrent_atomic_AtomicLongFieldUpdater_LockedUpdater() ||
|
|
|
|
holder->name() == ciSymbol::java_util_concurrent_atomic_AtomicReferenceFieldUpdater_Impl()) {
|
|
|
|
return true;
|
|
|
|
}
|
2010-01-13 23:05:52 -08:00
|
|
|
return TrustFinalNonStaticFields;
|
|
|
|
}
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
void ciField::initialize_from(fieldDescriptor* fd) {
|
|
|
|
// Get the flags, offset, and canonical holder of the field.
|
|
|
|
_flags = ciFlags(fd->access_flags());
|
|
|
|
_offset = fd->offset();
|
2017-12-22 22:01:53 -08:00
|
|
|
Klass* field_holder = fd->field_holder();
|
|
|
|
assert(field_holder != NULL, "null field_holder");
|
|
|
|
_holder = CURRENT_ENV->get_instance_klass(field_holder);
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
// Check to see if the field is constant.
|
2016-04-11 21:42:55 +03:00
|
|
|
Klass* k = _holder->get_Klass();
|
|
|
|
bool is_stable_field = FoldStableValues && is_stable();
|
2016-06-15 14:27:58 +02:00
|
|
|
if ((is_final() && !has_initialized_final_update()) || is_stable_field) {
|
2016-04-11 21:42:55 +03:00
|
|
|
if (is_static()) {
|
|
|
|
// This field just may be constant. The only case where it will
|
|
|
|
// not be constant is when the field is a *special* static & final field
|
|
|
|
// whose value may change. The three examples are java.lang.System.in,
|
|
|
|
// java.lang.System.out, and java.lang.System.err.
|
|
|
|
assert(SystemDictionary::System_klass() != NULL, "Check once per vm");
|
|
|
|
if (k == SystemDictionary::System_klass()) {
|
|
|
|
// Check offsets for case 2: System.in, System.out, or System.err
|
|
|
|
if( _offset == java_lang_System::in_offset_in_bytes() ||
|
|
|
|
_offset == java_lang_System::out_offset_in_bytes() ||
|
|
|
|
_offset == java_lang_System::err_offset_in_bytes() ) {
|
|
|
|
_is_constant = false;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
_is_constant = true;
|
|
|
|
} else {
|
|
|
|
// An instance field can be constant if it's a final static field or if
|
2011-03-11 22:34:57 -08:00
|
|
|
// it's a final non-static field of a trusted class (classes in
|
|
|
|
// java.lang.invoke and sun.invoke packages and subpackages).
|
2016-04-11 21:42:55 +03:00
|
|
|
_is_constant = is_stable_field || trust_final_non_static_fields(_holder);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// For CallSite objects treat the target field as a compile time constant.
|
|
|
|
assert(SystemDictionary::CallSite_klass() != NULL, "should be already initialized");
|
|
|
|
if (k == SystemDictionary::CallSite_klass() &&
|
|
|
|
_offset == java_lang_invoke_CallSite::target_offset_in_bytes()) {
|
2016-06-15 14:27:58 +02:00
|
|
|
assert(!has_initialized_final_update(), "CallSite is not supposed to have writes to final fields outside initializers");
|
2016-04-11 21:42:55 +03:00
|
|
|
_is_constant = true;
|
|
|
|
} else {
|
|
|
|
// Non-final & non-stable fields are not constants.
|
2010-01-05 15:21:25 +01:00
|
|
|
_is_constant = false;
|
|
|
|
}
|
2016-04-11 21:42:55 +03:00
|
|
|
}
|
|
|
|
}
|
2010-01-05 15:21:25 +01:00
|
|
|
|
2016-04-11 21:42:55 +03:00
|
|
|
// ------------------------------------------------------------------
|
|
|
|
// ciField::constant_value
|
|
|
|
// Get the constant value of a this static field.
|
|
|
|
ciConstant ciField::constant_value() {
|
|
|
|
assert(is_static() && is_constant(), "illegal call to constant_value()");
|
|
|
|
if (!_holder->is_initialized()) {
|
|
|
|
return ciConstant(); // Not initialized yet
|
|
|
|
}
|
|
|
|
if (_constant_value.basic_type() == T_ILLEGAL) {
|
|
|
|
// Static fields are placed in mirror objects.
|
|
|
|
VM_ENTRY_MARK;
|
|
|
|
ciInstance* mirror = CURRENT_ENV->get_instance(_holder->get_Klass()->java_mirror());
|
|
|
|
_constant_value = mirror->field_value_impl(type()->basic_type(), offset());
|
|
|
|
}
|
|
|
|
if (FoldStableValues && is_stable() && _constant_value.is_null_or_zero()) {
|
|
|
|
return ciConstant();
|
|
|
|
}
|
|
|
|
return _constant_value;
|
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2016-04-11 21:42:55 +03:00
|
|
|
// ------------------------------------------------------------------
|
|
|
|
// ciField::constant_value_of
|
|
|
|
// Get the constant value of non-static final field in the given object.
|
|
|
|
ciConstant ciField::constant_value_of(ciObject* object) {
|
|
|
|
assert(!is_static() && is_constant(), "only if field is non-static constant");
|
|
|
|
assert(object->is_instance(), "must be instance");
|
|
|
|
ciConstant field_value = object->as_instance()->field_value(this);
|
|
|
|
if (FoldStableValues && is_stable() && field_value.is_null_or_zero()) {
|
|
|
|
return ciConstant();
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
2016-04-11 21:42:55 +03:00
|
|
|
return field_value;
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------
|
|
|
|
// ciField::compute_type
|
|
|
|
//
|
|
|
|
// Lazily compute the type, if it is an instance klass.
|
|
|
|
ciType* ciField::compute_type() {
|
|
|
|
GUARDED_VM_ENTRY(return compute_type_impl();)
|
|
|
|
}
|
|
|
|
|
|
|
|
ciType* ciField::compute_type_impl() {
|
2011-06-23 17:14:06 -07:00
|
|
|
ciKlass* type = CURRENT_ENV->get_klass_by_name_impl(_holder, constantPoolHandle(), _signature, false);
|
2007-12-01 00:00:00 +00:00
|
|
|
if (!type->is_primitive_type() && is_shared()) {
|
|
|
|
// We must not cache a pointer to an unshared type, in a shared field.
|
|
|
|
bool type_is_also_shared = false;
|
|
|
|
if (type->is_type_array_klass()) {
|
|
|
|
type_is_also_shared = true; // int[] etc. are explicitly bootstrapped
|
|
|
|
} else if (type->is_instance_klass()) {
|
|
|
|
type_is_also_shared = type->as_instance_klass()->is_shared();
|
|
|
|
} else {
|
|
|
|
// Currently there is no 'shared' query for array types.
|
|
|
|
type_is_also_shared = !ciObjectFactory::is_initialized();
|
|
|
|
}
|
|
|
|
if (!type_is_also_shared)
|
|
|
|
return type; // Bummer.
|
|
|
|
}
|
|
|
|
_type = type;
|
|
|
|
return type;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------
|
|
|
|
// ciField::will_link
|
|
|
|
//
|
|
|
|
// Can a specific access to this field be made without causing
|
|
|
|
// link errors?
|
2016-06-15 14:27:58 +02:00
|
|
|
bool ciField::will_link(ciMethod* accessing_method,
|
2007-12-01 00:00:00 +00:00
|
|
|
Bytecodes::Code bc) {
|
|
|
|
VM_ENTRY_MARK;
|
2012-04-04 20:44:38 -07:00
|
|
|
assert(bc == Bytecodes::_getstatic || bc == Bytecodes::_putstatic ||
|
|
|
|
bc == Bytecodes::_getfield || bc == Bytecodes::_putfield,
|
|
|
|
"unexpected bytecode");
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
if (_offset == -1) {
|
|
|
|
// at creation we couldn't link to our holder so we need to
|
|
|
|
// maintain that stance, otherwise there's no safe way to use this
|
|
|
|
// ciField.
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2012-04-04 20:44:38 -07:00
|
|
|
// Check for static/nonstatic mismatch
|
|
|
|
bool is_static = (bc == Bytecodes::_getstatic || bc == Bytecodes::_putstatic);
|
|
|
|
if (is_static != this->is_static()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Get and put can have different accessibility rules
|
|
|
|
bool is_put = (bc == Bytecodes::_putfield || bc == Bytecodes::_putstatic);
|
|
|
|
if (is_put) {
|
2016-06-15 14:27:58 +02:00
|
|
|
if (_known_to_link_with_put == accessing_method) {
|
2012-04-04 20:44:38 -07:00
|
|
|
return true;
|
|
|
|
}
|
2012-04-12 12:07:09 -07:00
|
|
|
} else {
|
2016-06-15 14:27:58 +02:00
|
|
|
if (_known_to_link_with_get == accessing_method->holder()) {
|
2012-04-04 20:44:38 -07:00
|
|
|
return true;
|
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
2015-05-29 11:35:51 -04:00
|
|
|
LinkInfo link_info(_holder->get_instanceKlass(),
|
|
|
|
_name->get_symbol(), _signature->get_symbol(),
|
2016-06-15 14:27:58 +02:00
|
|
|
accessing_method->get_Method());
|
2013-09-13 22:38:02 -04:00
|
|
|
fieldDescriptor result;
|
2015-05-29 11:35:51 -04:00
|
|
|
LinkResolver::resolve_field(result, link_info, bc, false, KILL_COMPILE_ON_FATAL_(false));
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
// update the hit-cache, unless there is a problem with memory scoping:
|
2016-06-15 14:27:58 +02:00
|
|
|
if (accessing_method->holder()->is_shared() || !is_shared()) {
|
2012-04-04 20:44:38 -07:00
|
|
|
if (is_put) {
|
2016-06-15 14:27:58 +02:00
|
|
|
_known_to_link_with_put = accessing_method;
|
2012-04-04 20:44:38 -07:00
|
|
|
} else {
|
2016-06-15 14:27:58 +02:00
|
|
|
_known_to_link_with_get = accessing_method->holder();
|
2012-04-04 20:44:38 -07:00
|
|
|
}
|
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------
|
|
|
|
// ciField::print
|
|
|
|
void ciField::print() {
|
2012-12-18 14:55:25 +01:00
|
|
|
tty->print("<ciField name=");
|
2007-12-01 00:00:00 +00:00
|
|
|
_holder->print_name();
|
|
|
|
tty->print(".");
|
|
|
|
_name->print_symbol();
|
2012-12-18 14:55:25 +01:00
|
|
|
tty->print(" signature=");
|
|
|
|
_signature->print_symbol();
|
2007-12-01 00:00:00 +00:00
|
|
|
tty->print(" offset=%d type=", _offset);
|
2013-09-10 14:51:48 -07:00
|
|
|
if (_type != NULL)
|
|
|
|
_type->print_name();
|
|
|
|
else
|
|
|
|
tty->print("(reference)");
|
|
|
|
tty->print(" flags=%04x", flags().as_int());
|
2007-12-01 00:00:00 +00:00
|
|
|
tty->print(" is_constant=%s", bool_to_str(_is_constant));
|
2010-07-23 10:07:46 -07:00
|
|
|
if (_is_constant && is_static()) {
|
2007-12-01 00:00:00 +00:00
|
|
|
tty->print(" constant_value=");
|
|
|
|
_constant_value.print();
|
|
|
|
}
|
|
|
|
tty->print(">");
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------
|
|
|
|
// ciField::print_name_on
|
|
|
|
//
|
|
|
|
// Print the name of this field
|
|
|
|
void ciField::print_name_on(outputStream* st) {
|
|
|
|
name()->print_symbol_on(st);
|
|
|
|
}
|