mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 07:14:30 +02:00
6912065: final fields in objects need to support inlining optimizations for JSR 292
Reviewed-by: twisti, kvn
This commit is contained in:
parent
815db4fcba
commit
8214fc3a3b
2 changed files with 16 additions and 1 deletions
|
@ -161,6 +161,18 @@ ciField::ciField(fieldDescriptor *fd): _known_to_link_with(NULL) {
|
||||||
"bootstrap classes must not create & cache unshared fields");
|
"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/dyn") || holder->is_in_package("sun/dyn"))
|
||||||
|
return true;
|
||||||
|
return TrustFinalNonStaticFields;
|
||||||
|
}
|
||||||
|
|
||||||
void ciField::initialize_from(fieldDescriptor* fd) {
|
void ciField::initialize_from(fieldDescriptor* fd) {
|
||||||
// Get the flags, offset, and canonical holder of the field.
|
// Get the flags, offset, and canonical holder of the field.
|
||||||
_flags = ciFlags(fd->access_flags());
|
_flags = ciFlags(fd->access_flags());
|
||||||
|
@ -172,7 +184,7 @@ void ciField::initialize_from(fieldDescriptor* fd) {
|
||||||
if (!this->is_static()) {
|
if (!this->is_static()) {
|
||||||
// A field can be constant if it's a final static field or if it's
|
// A field can be constant if it's a final static field or if it's
|
||||||
// a final non-static field of a trusted class ({java,sun}.dyn).
|
// a final non-static field of a trusted class ({java,sun}.dyn).
|
||||||
if (_holder->is_in_package("java/dyn") || _holder->is_in_package("sun/dyn")) {
|
if (trust_final_non_static_fields(_holder)) {
|
||||||
_is_constant = true;
|
_is_constant = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3370,6 +3370,9 @@ class CommandLineFlags {
|
||||||
diagnostic(bool, OptimizeMethodHandles, true, \
|
diagnostic(bool, OptimizeMethodHandles, true, \
|
||||||
"when constructing method handles, try to improve them") \
|
"when constructing method handles, try to improve them") \
|
||||||
\
|
\
|
||||||
|
experimental(bool, TrustFinalNonStaticFields, false, \
|
||||||
|
"trust final non-static declarations for constant folding") \
|
||||||
|
\
|
||||||
experimental(bool, EnableInvokeDynamic, false, \
|
experimental(bool, EnableInvokeDynamic, false, \
|
||||||
"recognize the invokedynamic instruction") \
|
"recognize the invokedynamic instruction") \
|
||||||
\
|
\
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue