src/share/vm/ci/ciField.cpp
Index
Unified diffs
Context diffs
Sdiffs
Patch
New
Old
Previous File
Next File
8073191-work Cdiff src/share/vm/ci/ciField.cpp
src/share/vm/ci/ciField.cpp
Print this page
*** 196,278 ****
// 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");
}
- 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.
- if (holder->is_in_package("java/lang/invoke") || holder->is_in_package("sun/invoke"))
- return true;
- // 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;
- // 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;
- // 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;
- }
- return TrustFinalNonStaticFields;
- }
-
void ciField::initialize_from(fieldDescriptor* fd) {
// Get the flags, offset, and canonical holder of the field.
_flags = ciFlags(fd->access_flags());
_offset = fd->offset();
_holder = CURRENT_ENV->get_instance_klass(fd->field_holder());
// Check to see if the field is constant.
Klass* k = _holder->get_Klass();
bool is_stable_field = FoldStableValues && is_stable();
- if (is_final() || is_stable_field) {
- 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
- // it's a final non-static field of a trusted class (classes in
- // java.lang.invoke and sun.invoke packages and subpackages).
- _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()) {
_is_constant = true;
} else {
- // Non-final & non-stable fields are not constants.
_is_constant = false;
}
- }
}
// ------------------------------------------------------------------
// ciField::constant_value
// Get the constant value of a this static field.
--- 196,222 ----
// 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");
}
void ciField::initialize_from(fieldDescriptor* fd) {
// Get the flags, offset, and canonical holder of the field.
_flags = ciFlags(fd->access_flags());
_offset = fd->offset();
_holder = CURRENT_ENV->get_instance_klass(fd->field_holder());
// Check to see if the field is constant.
Klass* k = _holder->get_Klass();
bool is_stable_field = FoldStableValues && is_stable();
assert(SystemDictionary::CallSite_klass() != NULL, "should be already initialized");
! if (is_stable_field ||
! (k == SystemDictionary::CallSite_klass() &&
! _offset == java_lang_invoke_CallSite::target_offset_in_bytes())) {
_is_constant = true;
} else {
_is_constant = false;
}
}
// ------------------------------------------------------------------
// ciField::constant_value
// Get the constant value of a this static field.
*** 339,348 ****
--- 283,293 ----
// ciField::will_link
//
// Can a specific access to this field be made without causing
// link errors?
bool ciField::will_link(ciInstanceKlass* accessing_klass,
+ ciMethod* accessing_method,
Bytecodes::Code bc) {
VM_ENTRY_MARK;
assert(bc == Bytecodes::_getstatic || bc == Bytecodes::_putstatic ||
bc == Bytecodes::_getfield || bc == Bytecodes::_putfield,
"unexpected bytecode");
*** 372,382 ****
}
}
LinkInfo link_info(_holder->get_instanceKlass(),
_name->get_symbol(), _signature->get_symbol(),
! accessing_klass->get_Klass());
fieldDescriptor result;
LinkResolver::resolve_field(result, link_info, bc, false, KILL_COMPILE_ON_FATAL_(false));
// update the hit-cache, unless there is a problem with memory scoping:
if (accessing_klass->is_shared() || !is_shared()) {
--- 317,327 ----
}
}
LinkInfo link_info(_holder->get_instanceKlass(),
_name->get_symbol(), _signature->get_symbol(),
! accessing_klass->get_Klass(), accessing_method->get_Method());
fieldDescriptor result;
LinkResolver::resolve_field(result, link_info, bc, false, KILL_COMPILE_ON_FATAL_(false));
// update the hit-cache, unless there is a problem with memory scoping:
if (accessing_klass->is_shared() || !is_shared()) {
src/share/vm/ci/ciField.cpp
Index
Unified diffs
Context diffs
Sdiffs
Patch
New
Old
Previous File
Next File